summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-08-15 17:28:41 +0100
committerMichael Stahl <Michael.Stahl@cib.de>2018-08-20 12:14:32 +0200
commitc57538b2b3c9ffbb206590089c0a5ca69056304d (patch)
treecffcd6f294c339853bd6cce99f1f9c9987e391ae
parent319db92f96c9b886cecee97136175e12e94da547 (diff)
ofz#9917 use a WW8SprmIter to find the sprm
extend WW8SprmIter to support the needed paramater match feature and drop the custom WW8PLCFx_SEPX::HasSprm logic Change-Id: I5893e04402ed03493add398f0939a578807561ef Reviewed-on: https://gerrit.libreoffice.org/59120 Tested-by: Jenkins Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx39
-rw-r--r--sw/source/filter/ww8/ww8scan.hxx2
2 files changed, 14 insertions, 27 deletions
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 6a90d83e8e3c..6e5e863767c7 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -917,7 +917,7 @@ void WW8SprmIter::UpdateMyMembers()
}
}
-SprmResult WW8SprmIter::FindSprm(sal_uInt16 nId)
+SprmResult WW8SprmIter::FindSprm(sal_uInt16 nId, sal_uInt8* pNextByteMatch)
{
while (GetSprms())
{
@@ -925,7 +925,13 @@ SprmResult WW8SprmIter::FindSprm(sal_uInt16 nId)
{
sal_uInt16 nFixedLen = mrSprmParser.DistanceToData(nId);
sal_uInt16 nL = mrSprmParser.GetSprmSize(nId, GetSprms(), GetRemLen());
- return SprmResult(GetAktParams(), nL - nFixedLen); // SPRM found!
+ SprmResult aRet(GetAktParams(), nL - nFixedLen); // SPRM found!
+ // typically pNextByteMatch is nullptr and we just return the first match
+ if (!pNextByteMatch)
+ return aRet;
+ // very occasionally we want one with a specific following byte
+ if (aRet.nRemainingData >= 1 && *aRet.pSprm == *pNextByteMatch)
+ return aRet;
}
advance();
}
@@ -3769,32 +3775,13 @@ bool WW8PLCFx_SEPX::Find4Sprms(sal_uInt16 nId1,sal_uInt16 nId2,sal_uInt16 nId3,s
SprmResult WW8PLCFx_SEPX::HasSprm( sal_uInt16 nId, sal_uInt8 n2nd ) const
{
- if (!pPLCF)
- return SprmResult();
-
- sal_uInt8* pSp = pSprms.get();
- size_t i = 0;
- while (i + maSprmParser.MinSprmLen() <= nSprmSiz)
+ SprmResult aRet;
+ if (pPLCF)
{
- // Sprm found?
- const sal_uInt16 nAktId = maSprmParser.GetSprmId(pSp);
- const sal_uInt16 x = maSprmParser.GetSprmSize(nAktId, pSp, nSprmSiz - i);
- if (nAktId == nId)
- {
- sal_uInt16 nFixedLen = maSprmParser.DistanceToData(nId);
- const sal_uInt8 *pRet = pSp + nFixedLen;
- SprmResult aRet(pRet, x - nFixedLen);
- if (aRet.nRemainingData >= 1 && *aRet.pSprm == n2nd)
- {
- return aRet;
- }
- }
- // increment pointer so that it points to next SPRM
- i += x;
- pSp += x;
+ WW8SprmIter aIter(pSprms.get(), nSprmSiz, maSprmParser);
+ aRet = aIter.FindSprm(nId, &n2nd);
}
-
- return SprmResult(); // Sprm not found
+ return aRet;
}
WW8PLCFx_SubDoc::WW8PLCFx_SubDoc(SvStream* pSt, const WW8Fib& rFib,
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index ff2246155899..841067d2a241 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -281,7 +281,7 @@ public:
explicit WW8SprmIter(const sal_uInt8* pSprms_, sal_Int32 nLen_,
const wwSprmParser &rSprmParser);
void SetSprms(const sal_uInt8* pSprms_, sal_Int32 nLen_);
- SprmResult FindSprm(sal_uInt16 nId);
+ SprmResult FindSprm(sal_uInt16 nId, sal_uInt8* pNextByteMatch = nullptr);
void advance();
const sal_uInt8* GetSprms() const
{ return ( pSprms && (0 < nRemLen) ) ? pSprms : nullptr; }