From 4404b718bdb547cb9b7b17c73a53574724cdeeb7 Mon Sep 17 00:00:00 2001 From: Daniel Sikeler Date: Thu, 30 Oct 2014 14:53:48 +0000 Subject: fdo#79761: parse BlockList.xml only once Change-Id: I3cfc5b66ee73b0e4d07a84c8255c5a006e4fbb25 Reviewed-on: https://gerrit.libreoffice.org/12210 Reviewed-by: Michael Stahl Tested-by: Michael Stahl --- sw/inc/swacorr.hxx | 9 +++++++-- sw/source/core/sw3io/swacorr.cxx | 16 ++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'sw') diff --git a/sw/inc/swacorr.hxx b/sw/inc/swacorr.hxx index 5bb3c93474fc..33598c6dbc16 100644 --- a/sw/inc/swacorr.hxx +++ b/sw/inc/swacorr.hxx @@ -24,15 +24,20 @@ #include #include +#include "SwXMLTextBlocks.hxx" + class SwAutoCorrect : public SvxAutoCorrect { using SvxAutoCorrect::PutText; + std::unique_ptr 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! diff --git a/sw/source/core/sw3io/swacorr.cxx b/sw/source/core/sw3io/swacorr.cxx index 8472942872f0..0a08b012264b 100644 --- a/sw/source/core/sw3io/swacorr.cxx +++ b/sw/source/core/sw3io/swacorr.cxx @@ -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!) -- cgit