summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-01-17 11:03:20 +0000
committerAndras Timar <andras.timar@collabora.com>2018-03-06 14:48:11 +0100
commit5bb823a362ce855843cbca4cd86c11b473346247 (patch)
treec4cd88f150e9573211be98cb057b748da8570191
parentc5a9e69472aa9262f92029c9da7671563314792f (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)
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx17
-rw-r--r--sw/source/filter/ww8/ww8scan.hxx9
2 files changed, 21 insertions, 5 deletions
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 422211a9abb3..a6db457c61e0 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -2414,8 +2414,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);
@@ -2877,8 +2877,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();
+ }
}
}
}
@@ -5274,6 +5278,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;
@@ -5288,6 +5294,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 00ed18c625ce..2e7e1bca445b 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -525,6 +525,7 @@ public:
sal_uInt8 mnIdx; // Pos marker
ePLCFT ePLCF;
sal_uInt8 mnIMax; // number of entries
+ int mnMustRemainCached; // after SaveAllPLCFx, before RestoreAllPLCFx
wwSprmParser maSprmParser;
@@ -565,13 +566,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
@@ -587,7 +594,7 @@ private:
*/
typedef std::list<WW8Fkp*>::iterator myiter;
std::list<WW8Fkp*> maFkpCache;
- enum Limits {eMaxCache = 5};
+ enum Limits {eMaxCache = 50000};
bool NewFkp();