[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Aug 20 10:14:48 UTC 2018
sw/source/filter/ww8/ww8scan.cxx | 39 +++++++++++++--------------------------
sw/source/filter/ww8/ww8scan.hxx | 2 +-
2 files changed, 14 insertions(+), 27 deletions(-)
New commits:
commit 121ebbf097045c0dbb3eb8cb2b0cf2ffc1c4cd09
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Aug 15 17:28:41 2018 +0100
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Mon Aug 20 12:14:27 2018 +0200
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/59119
Tested-by: Jenkins
Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index a7e91b17aadd..16cc14b4132d 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -916,7 +916,7 @@ void WW8SprmIter::UpdateMyMembers()
}
}
-SprmResult WW8SprmIter::FindSprm(sal_uInt16 nId)
+SprmResult WW8SprmIter::FindSprm(sal_uInt16 nId, sal_uInt8* pNextByteMatch)
{
while (GetSprms())
{
@@ -924,7 +924,13 @@ SprmResult WW8SprmIter::FindSprm(sal_uInt16 nId)
{
sal_uInt16 nFixedLen = mrSprmParser.DistanceToData(nId);
sal_uInt16 nL = mrSprmParser.GetSprmSize(nId, GetSprms(), GetRemLen());
- return SprmResult(GetCurrentParams(), nL - nFixedLen); // SPRM found!
+ SprmResult aRet(GetCurrentParams(), 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();
}
@@ -3834,32 +3840,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 nCurrentId = maSprmParser.GetSprmId(pSp);
- const sal_uInt16 x = maSprmParser.GetSprmSize(nCurrentId, pSp, nSprmSiz - i);
- if (nCurrentId == 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 69ff529233a2..e3331305e5a2 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -282,7 +282,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; }
More information about the Libreoffice-commits
mailing list