[Libreoffice-commits] core.git: 2 commits - sw/source

Caolán McNamara caolanm at redhat.com
Thu Aug 13 02:59:06 PDT 2015


 sw/source/filter/ww8/ww8scan.cxx |   18 +++++++++---------
 sw/source/filter/ww8/ww8scan.hxx |    4 ++--
 sw/source/ui/app/error.src       |    4 ++--
 3 files changed, 13 insertions(+), 13 deletions(-)

New commits:
commit ea70088895ed45dc60abf18319acc1b4fa3018dd
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Aug 13 10:58:06 2015 +0100

    convert pStatus to vector and use at to check offsets
    
    Change-Id: I5186f6a65bb9d5ed8a0d1ab1d71f7e2c13865411

diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 59b133d..ad1ef67 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -3957,7 +3957,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 )
@@ -3982,14 +3982,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];
 }
@@ -4109,18 +4107,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 5c3970c..26a94ac 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -721,8 +721,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.
commit 77a38b460eab172e2d19388d2ef3f5eefb981d74
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Aug 13 10:56:48 2015 +0100

    modify error messages a little
    
    Change-Id: I5c2c5a567ffb16d3e072cba2930dffe762a744f3

diff --git a/sw/source/ui/app/error.src b/sw/source/ui/app/error.src
index 7768772..cc5266d 100644
--- a/sw/source/ui/app/error.src
+++ b/sw/source/ui/app/error.src
@@ -70,7 +70,7 @@ Resource RID_SW_ERRHDL
     };
     String ERR_CODE ( ERRCODE_CLASS_READ , ERR_WW6_NO_WW6_FILE_ERR )
     {
-        Text [ en-US ] = "This is not a WinWord6 file." ;
+        Text [ en-US ] = "This is not a valid WinWord6 file." ;
     };
     String ERR_CODE ( ERRCODE_CLASS_READ , ERR_WW6_FASTSAVE_ERR )
     {
@@ -86,7 +86,7 @@ Resource RID_SW_ERRHDL
     };
     String ERR_CODE ( ERRCODE_CLASS_READ , ERR_WW8_NO_WW8_FILE_ERR )
     {
-        Text [ en-US ] = "This is not a WinWord97 file.";
+        Text [ en-US ] = "This is not a valid WinWord97 file.";
     };
     String ERR_CODE ( ERRCODE_CLASS_READ , ERR_FORMAT_FILE_ROWCOL )
     {


More information about the Libreoffice-commits mailing list