diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-08-15 17:28:41 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-08-21 10:53:47 +0200 |
commit | d3ffdd1e7fa391911c2396af375beb2f569c3481 (patch) | |
tree | 63fe14d59842af5a8d09af5a9a224e85f9f0d421 /sw/source/filter | |
parent | 589133a43f199d9638cd3cb3a24d3557a407134e (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>
(cherry picked from commit c57538b2b3c9ffbb206590089c0a5ca69056304d)
Diffstat (limited to 'sw/source/filter')
-rw-r--r-- | sw/source/filter/ww8/ww8scan.cxx | 39 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.hxx | 2 |
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; } |