diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-01-17 11:03:20 +0000 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-03-06 21:37:53 +0100 |
commit | 8589bb5c946baa6c7cc4c68f96a9af8515562e01 (patch) | |
tree | 053f247e1c012e379ed7e9ec29fe80d1f1476d54 /sw | |
parent | 1ea276b4034f5bd8d0b0d748914d0760aba54600 (diff) |
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 <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
(cherry picked from commit 29ed64eb53427e51a9a0f6102c4d41d7f13ff01c)
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/ww8scan.cxx | 17 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.hxx | 9 |
2 files changed, 21 insertions, 5 deletions
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 82e56f82bca9..0fc129b8bba8 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -2416,8 +2416,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); @@ -2879,8 +2879,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(); + } } } } @@ -5278,6 +5282,8 @@ void WW8PLCFx_Cp_FKP::SetIdx2( sal_uLong nIdx ) void WW8PLCFx_Cp_FKP::Save( WW8PLCFxSave1& rSave ) const { + if (pFkp) + pFkp->IncMustRemainCache(); WW8PLCFx::Save( rSave ); rSave.nAttrStart = nAttrStart; @@ -5292,6 +5298,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 b71d8885a719..6b65efedd3e3 100644 --- a/sw/source/filter/ww8/ww8scan.hxx +++ b/sw/source/filter/ww8/ww8scan.hxx @@ -524,6 +524,7 @@ public: sal_uInt8 mnIdx; // Pos marker ePLCFT ePLCF; sal_uInt8 mnIMax; // number of entries + int mnMustRemainCached; // after SaveAllPLCFx, before RestoreAllPLCFx wwSprmParser maSprmParser; @@ -564,13 +565,19 @@ public: void HasSprm(sal_uInt16 nId, std::vector<const sal_uInt8 *> &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 @@ -586,7 +593,7 @@ private: */ typedef std::list<WW8Fkp*>::iterator myiter; std::list<WW8Fkp*> maFkpCache; - enum Limits {eMaxCache = 5}; + enum Limits {eMaxCache = 50000}; bool NewFkp(); |