diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-08-13 10:58:06 +0100 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2015-08-18 10:01:55 +0000 |
commit | 570ad4544297bc110245032eae972f0628abba26 (patch) | |
tree | 4a914625506e821ad1cacfe25a8d898e4f76d3d0 | |
parent | 0464718dfe7401bc7e19e76226b9a1fe74c68a9e (diff) |
convert pStatus to vector and use at to check offsets
Change-Id: I5186f6a65bb9d5ed8a0d1ab1d71f7e2c13865411
(cherry picked from commit ea70088895ed45dc60abf18319acc1b4fa3018dd)
Reviewed-on: https://gerrit.libreoffice.org/17694
Reviewed-by: Eike Rathke <erack@redhat.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Reviewed-by: David Tardon <dtardon@redhat.com>
-rw-r--r-- | sw/source/filter/ww8/ww8scan.cxx | 18 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.hxx | 4 |
2 files changed, 11 insertions, 11 deletions
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index c97db22e6b1a..5895568540f8 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -3988,7 +3988,7 @@ void WW8ReadSTTBF(bool bVer8, SvStream& rStrm, sal_uInt32 nStart, sal_Int32 nLen } WW8PLCFx_Book::WW8PLCFx_Book(SvStream* pTableSt, const WW8Fib& rFib) - : WW8PLCFx(rFib.GetFIBVersion(), false), pStatus(0), nIsEnd(0), nBookmarkId(1) + : WW8PLCFx(rFib.GetFIBVersion(), false), nIsEnd(0), nBookmarkId(1) { if( !rFib.fcPlcfbkf || !rFib.lcbPlcfbkf || !rFib.fcPlcfbkl || !rFib.lcbPlcfbkl || !rFib.fcSttbfbkmk || !rFib.lcbSttbfbkmk ) @@ -4013,14 +4013,12 @@ WW8PLCFx_Book::WW8PLCFx_Book(SvStream* pTableSt, const WW8Fib& rFib) nIMax = pBook[0]->GetIMax(); if( pBook[1]->GetIMax() < nIMax ) nIMax = pBook[1]->GetIMax(); - pStatus = new eBookStatus[ nIMax ]; - memset( pStatus, 0, nIMax * sizeof( eBookStatus ) ); + aStatus.resize(nIMax); } } WW8PLCFx_Book::~WW8PLCFx_Book() { - delete[] pStatus; delete pBook[1]; delete pBook[0]; } @@ -4138,18 +4136,20 @@ long WW8PLCFx_Book::GetLen() const return nNum; } -void WW8PLCFx_Book::SetStatus(sal_uInt16 nIndex, eBookStatus eStat ) +void WW8PLCFx_Book::SetStatus(sal_uInt16 nIndex, eBookStatus eStat) { - OSL_ENSURE(nIndex < nIMax, "set status of non existing bookmark!"); - pStatus[nIndex] = (eBookStatus)( pStatus[nIndex] | eStat ); + SAL_WARN_IF(nIndex >= nIMax, "sw.ww8", + "bookmark index " << nIndex << " invalid"); + eBookStatus eStatus = aStatus.at(nIndex); + aStatus[nIndex] = static_cast<eBookStatus>(eStatus | eStat); } eBookStatus WW8PLCFx_Book::GetStatus() const { - if( !pStatus ) + if (aStatus.empty()) return BOOK_NORMAL; long nEndIdx = GetHandle(); - return ( nEndIdx < nIMax ) ? pStatus[nEndIdx] : BOOK_NORMAL; + return ( nEndIdx < nIMax ) ? aStatus[nEndIdx] : BOOK_NORMAL; } long WW8PLCFx_Book::GetHandle() const diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx index 678482f85e9c..57ccae3aca50 100644 --- a/sw/source/filter/ww8/ww8scan.hxx +++ b/sw/source/filter/ww8/ww8scan.hxx @@ -724,8 +724,8 @@ class WW8PLCFx_Book : public WW8PLCFx { private: WW8PLCFspecial* pBook[2]; // Start and End Position - ::std::vector<OUString> aBookNames; // Name - eBookStatus* pStatus; + std::vector<OUString> aBookNames; // Name + std::vector<eBookStatus> aStatus; long nIMax; // Number of Booknotes sal_uInt16 nIsEnd; sal_Int32 nBookmarkId; // counter incremented by GetUniqueBookmarkName. |