Kaydet (Commit) 4404b718 authored tarafından Daniel Sikeler's avatar Daniel Sikeler Kaydeden (comit) Michael Stahl

fdo#79761: parse BlockList.xml only once

Change-Id: I3cfc5b66ee73b0e4d07a84c8255c5a006e4fbb25
Reviewed-on: https://gerrit.libreoffice.org/12210Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
Tested-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst fc4d04d5
......@@ -56,6 +56,7 @@ SvXMLWordListContext::SvXMLWordListContext(
SvXMLImportContext ( rImport ),
rLocalRef(rImport)
{
rLocalRef.rAutoCorrect.refreshBlockList( rLocalRef.xStorage );
}
com::sun::star::uno::Reference<XFastContextHandler> SAL_CALL SvXMLWordListContext::createFastChildContext(
......@@ -94,7 +95,7 @@ SvXMLWordContext::SvXMLWordContext(
if( !bOnlyTxt )
{
const OUString sLongSave( sRight );
if( !rLocalRef.rAutoCorrect.GetLongText( rLocalRef.xStorage, sWrong, sRight ) &&
if( !rLocalRef.rAutoCorrect.GetLongText( sWrong, sRight ) &&
!sLongSave.isEmpty() )
{
sRight = sLongSave;
......
......@@ -1627,12 +1627,15 @@ bool SvxAutoCorrect::MakeCombinedChanges( std::vector<SvxAutocorrWord>& aNewEntr
// - return the replacement text (only for SWG-Format, all other
// can be taken from the word list!)
bool SvxAutoCorrect::GetLongText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&,
const OUString&, OUString& )
bool SvxAutoCorrect::GetLongText( const OUString&, OUString& )
{
return false;
}
void SvxAutoCorrect::refreshBlockList( const uno::Reference< embed::XStorage >& )
{
}
// Text with attribution (only the SWG - SWG format!)
bool SvxAutoCorrect::PutText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&,
const OUString&, const OUString&, SfxObjectShell&, OUString& )
......
......@@ -275,8 +275,9 @@ public:
sal_Unicode GetQuote( sal_Unicode cInsChar, bool bSttQuote,
LanguageType eLang ) const;
virtual bool GetLongText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg,
const OUString& rShort, OUString& rLong );
virtual bool GetLongText( const OUString& rShort, OUString& rLong );
virtual void refreshBlockList( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg);
TYPEINFO();
......
......@@ -24,15 +24,20 @@
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/embed/XStorage.hpp>
#include "SwXMLTextBlocks.hxx"
class SwAutoCorrect : public SvxAutoCorrect
{
using SvxAutoCorrect::PutText;
std::unique_ptr<SwXMLTextBlocks> m_pTextBlocks;
protected:
// Return replacement text (only for SWG-format, all others can be obtained from wordlist!).
// rShort is stream-name - encrypted!
virtual bool GetLongText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&,
const OUString& rShort, OUString& rLong ) SAL_OVERRIDE;
virtual bool GetLongText( const OUString& rShort, OUString& rLong ) SAL_OVERRIDE;
virtual void refreshBlockList( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& ) SAL_OVERRIDE;
// Text with attributes (only SWG-format!).
// rShort is stream-name - encrypted!
......
......@@ -37,20 +37,24 @@ TYPEINIT1( SwAutoCorrect, SvxAutoCorrect );
*
* @param rShort - the stream name (encrypted)
*/
bool SwAutoCorrect::GetLongText( const uno::Reference < embed::XStorage >& rStg,
const OUString& rShort, OUString& rLong )
bool SwAutoCorrect::GetLongText( const OUString& rShort, OUString& rLong )
{
sal_uLong nRet = 0;
assert( m_pTextBlocks );
nRet = m_pTextBlocks->GetText( rShort, rLong );
return !IsError( nRet ) && !rLong.isEmpty();
}
void SwAutoCorrect::refreshBlockList( const uno::Reference< embed::XStorage >& rStg )
{
if (rStg.is())
{
// mba: relative URLs don't make sense here
SwXMLTextBlocks aBlk( rStg, OUString() );
nRet = aBlk.GetText( rShort, rLong );
m_pTextBlocks.reset( new SwXMLTextBlocks( rStg, OUString() ) );
}
else {
OSL_ENSURE( rStg.is(), "Someone passed SwAutoCorrect::GetLongText a dud storage!");
OSL_ENSURE( rStg.is(), "Someone passed SwAutoCorrect::refreshBlockList a dud storage!");
}
return !IsError( nRet ) && !rLong.isEmpty();
}
// - Text mit Attributierung (kann nur der SWG - SWG-Format!)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment