[Libreoffice-commits] core.git: sw/source
Caolán McNamara
caolanm at redhat.com
Wed Jan 17 14:33:44 UTC 2018
sw/source/filter/ww8/ww8scan.cxx | 17 +++++++++++++----
sw/source/filter/ww8/ww8scan.hxx | 9 ++++++++-
2 files changed, 21 insertions(+), 5 deletions(-)
New commits:
commit 1e46bf5e15e9b149537ca636669beab9702dba93
Author: Caolán McNamara <caolanm at 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/48040
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 526ea5c1eea5..f5b1dba65470 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -2558,8 +2558,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);
@@ -3027,8 +3027,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();
+ }
}
}
}
@@ -5530,6 +5534,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;
@@ -5544,6 +5550,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 696ae22e651e..27ff05559042 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();
More information about the Libreoffice-commits
mailing list