summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/source/filter/ww8/ww8graf.cxx6
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx73
-rw-r--r--sw/source/filter/ww8/ww8scan.hxx2
3 files changed, 52 insertions, 29 deletions
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 6a193700b7c2..3939b8667e95 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -867,7 +867,8 @@ bool SwWW8ImplReader::GetTxbxTextSttEndCp(WW8_CP& rStartCp, WW8_CP& rEndCp,
// den um -2 (bzw. -1 bei Ver8) korrigierten End-Cp zurueck
sal_Int32 SwWW8ImplReader::GetRangeAsDrawingString(OUString& rString, long nStartCp, long nEndCp, ManTypes eType)
{
- WW8_CP nOffset = m_pWwFib->GetBaseCp(eType);
+ WW8_CP nOffset = 0;
+ m_pWwFib->GetBaseCp(eType, &nOffset); //TODO: check return value
OSL_ENSURE(nStartCp <= nEndCp, "+Wo ist der Grafik-Text (7) ?");
if (nStartCp == nEndCp)
@@ -2390,7 +2391,8 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp )
::SetProgressState(m_nProgress, m_pDocShell); // Update
- m_nDrawCpO = m_pWwFib->GetBaseCp(m_pPlcxMan->GetManType() == MAN_HDFT ? MAN_TXBX_HDFT : MAN_TXBX);
+ m_nDrawCpO = 0;
+ m_pWwFib->GetBaseCp(m_pPlcxMan->GetManType() == MAN_HDFT ? MAN_TXBX_HDFT : MAN_TXBX, &m_nDrawCpO); //TODO: check return value
GrafikCtor();
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index dcef904dce88..dcebc0c415b3 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -4563,7 +4563,9 @@ WW8PLCFMan::WW8PLCFMan(WW8ScannerBase* pBase, ManTypes nType, long nStartCp,
break;
}
- nCpO = pWwFib->GetBaseCp(nType);
+ WW8_CP cp = 0;
+ pWwFib->GetBaseCp(nType, &cp); //TODO: check return value
+ nCpO = cp;
if( nStartCp || nCpO )
SeekPos( nStartCp ); // adjust PLCFe at text StartPos
@@ -5203,46 +5205,65 @@ namespace
}
}
-WW8_CP WW8Fib::GetBaseCp(ManTypes nType) const
+bool WW8Fib::GetBaseCp(ManTypes nType, WW8_CP * cp) const
{
+ assert(cp != nullptr);
WW8_CP nOffset = 0;
switch( nType )
{
default:
- case MAN_MAINTEXT:
- break;
- case MAN_FTN:
- nOffset = ccpText;
- break;
- case MAN_HDFT:
- nOffset = ccpText + ccpFootnote;
- break;
+ case MAN_TXBX_HDFT:
+ nOffset = ccpTxbx;
+ // fall through
+ case MAN_TXBX:
+ if (ccpEdn > std::numeric_limits<WW8_CP>::max() - nOffset) {
+ return false;
+ }
+ nOffset += ccpEdn;
+ // fall through
+ case MAN_EDN:
+ if (ccpAtn > std::numeric_limits<WW8_CP>::max() - nOffset) {
+ return false;
+ }
+ nOffset += ccpAtn;
+ // fall through
+ case MAN_AND:
+ if (ccpMcr > std::numeric_limits<WW8_CP>::max() - nOffset) {
+ return false;
+ }
+ nOffset += ccpMcr;
/*
+ // fall through
+
A subdocument of this kind (MAN_MACRO) probably exists in some defunct
version of MSWord, but now ccpMcr is always 0. If some example that
uses this comes to light, this is the likely calculation required
case MAN_MACRO:
- nOffset = ccpText + ccpFootnote + ccpHdr;
- break;
-
*/
- case MAN_AND:
- nOffset = ccpText + ccpFootnote + ccpHdr + ccpMcr;
- break;
- case MAN_EDN:
- nOffset = ccpText + ccpFootnote + ccpHdr + ccpMcr + ccpAtn;
- break;
- case MAN_TXBX:
- nOffset = ccpText + ccpFootnote + ccpHdr + ccpMcr + ccpAtn + ccpEdn;
- break;
- case MAN_TXBX_HDFT:
- nOffset = ccpText + ccpFootnote + ccpHdr + ccpMcr + ccpAtn + ccpEdn +
- ccpTxbx;
+ if (ccpHdr > std::numeric_limits<WW8_CP>::max() - nOffset) {
+ return false;
+ }
+ nOffset += ccpHdr;
+ // fall through
+ case MAN_HDFT:
+ if (ccpFootnote > std::numeric_limits<WW8_CP>::max() - nOffset) {
+ return false;
+ }
+ nOffset += ccpFootnote;
+ // fall through
+ case MAN_FTN:
+ if (ccpText > std::numeric_limits<WW8_CP>::max() - nOffset) {
+ return false;
+ }
+ nOffset += ccpText;
+ // fall through
+ case MAN_MAINTEXT:
break;
}
- return nOffset;
+ *cp = nOffset;
+ return true;
}
ww::WordVersion WW8Fib::GetFIBVersion() const
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index 54e8165251f6..019bf5c0e03a 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -1452,7 +1452,7 @@ public:
bool Write(SvStream& rStrm);
static rtl_TextEncoding GetFIBCharset(sal_uInt16 chs, sal_uInt16 nLidLocale);
ww::WordVersion GetFIBVersion() const;
- WW8_CP GetBaseCp(ManTypes nType) const;
+ bool GetBaseCp(ManTypes nType, WW8_CP * cp) const;
sal_Unicode getNumDecimalSep() const { return nNumDecimalSep;}
};