sw/source/filter/ww8/ww8scan.cxx | 17 +++++++++++++---- sw/source/filter/ww8/ww8scan.hxx | 9 ++++++++- 2 files changed, 21 insertions(+), 5 deletions(-)
New commits: commit 29ed64eb53427e51a9a0f6102c4d41d7f13ff01c Author: Caolán McNamara <caol...@redhat.com> Date: Wed Jan 17 11:03:20 2018 +0000 ofz#5447 on plcf save force current Fkp to stick in cache Change-Id: Id7b6c442df10c6de7226702a9bf3ba559a0c2e9a Reviewed-on: https://gerrit.libreoffice.org/48054 Reviewed-by: Michael Stahl <mst...@redhat.com> Tested-by: Michael Stahl <mst...@redhat.com> diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index b5fd3dcc7451..f5ed1818f832 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -2403,8 +2403,8 @@ void WW8PLCFx_Fc_FKP::WW8Fkp::FillEntry(WW8PLCFx_Fc_FKP::WW8Fkp::Entry &rEntry, WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(const WW8Fib& rFib, SvStream* pSt, SvStream* pDataSt, long _nFilePos, long nItemSiz, ePLCFT ePl, WW8_FC nStartFc) - : nItemSize(nItemSiz), nFilePos(_nFilePos), mnIdx(0), ePLCF(ePl) - , maSprmParser(rFib) + : nItemSize(nItemSiz), nFilePos(_nFilePos), mnIdx(0), ePLCF(ePl) + , mnMustRemainCached(0), maSprmParser(rFib) { memset(maRawData, 0, 512); @@ -2874,8 +2874,12 @@ bool WW8PLCFx_Fc_FKP::NewFkp() if (maFkpCache.size() > eMaxCache) { - delete maFkpCache.front(); - maFkpCache.pop_front(); + WW8Fkp* pCachedFkp = maFkpCache.front(); + if (!pCachedFkp->IsMustRemainCache()) + { + delete pCachedFkp; + maFkpCache.pop_front(); + } } } } @@ -5287,6 +5291,8 @@ void WW8PLCFx_Cp_FKP::SetIdx2(sal_uInt32 nIdx) void WW8PLCFx_Cp_FKP::Save( WW8PLCFxSave1& rSave ) const { + if (pFkp) + pFkp->IncMustRemainCache(); WW8PLCFx::Save( rSave ); rSave.nAttrStart = nAttrStart; @@ -5301,6 +5307,9 @@ void WW8PLCFx_Cp_FKP::Restore( const WW8PLCFxSave1& rSave ) nAttrStart = rSave.nAttrStart; nAttrEnd = rSave.nAttrEnd; bLineEnd = rSave.bLineEnd; + + if (pFkp) + pFkp->DecMustRemainCache(); } void WW8PLCFxDesc::Save( WW8PLCFxSave1& rSave ) const diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx index 9a1b277c8480..7e6281008c69 100644 --- a/sw/source/filter/ww8/ww8scan.hxx +++ b/sw/source/filter/ww8/ww8scan.hxx @@ -534,6 +534,7 @@ public: sal_uInt8 mnIdx; // Pos marker ePLCFT ePLCF; sal_uInt8 mnIMax; // number of entries + int mnMustRemainCached; // after SaveAllPLCFx, before RestoreAllPLCFx wwSprmParser maSprmParser; @@ -574,13 +575,19 @@ public: void HasSprm(sal_uInt16 nId, std::vector<SprmResult> &rResult); const wwSprmParser &GetSprmParser() const { return maSprmParser; } + + void IncMustRemainCache() { ++mnMustRemainCached; } + bool IsMustRemainCache() const { return mnMustRemainCached > 0; } + void DecMustRemainCache() { --mnMustRemainCached; } }; private: SvStream* pFKPStrm; // input file SvStream* pDataStrm; // input file WW8PLCF* pPLCF; +protected: WW8Fkp* pFkp; +private: /* Keep a cache of eMaxCache entries of previously seen pFkps, which @@ -596,7 +603,7 @@ private: */ typedef std::list<WW8Fkp*>::iterator myiter; std::list<WW8Fkp*> maFkpCache; - enum Limits {eMaxCache = 5}; + enum Limits {eMaxCache = 50000}; bool NewFkp(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits