[Libreoffice-commits] .: sw/source

Caolán McNamara caolan at kemper.freedesktop.org
Tue Jul 5 02:51:18 PDT 2011


 sw/source/filter/ww8/ww8par3.cxx |   41 +++++++++++++++++++++++++--------------
 sw/source/filter/ww8/ww8scan.cxx |    5 ++++
 sw/source/filter/ww8/ww8scan.hxx |    2 +
 3 files changed, 34 insertions(+), 14 deletions(-)

New commits:
commit a43fc1fc37bd98b10ddf592b830a8b83c6515716
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jul 5 10:46:05 2011 +0100

    check seeks for list positions

diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 7335579..3559ca4 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -1072,27 +1072,33 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
     //
     // 1. PLCF LST auslesen und die Listen Vorlagen im Writer anlegen
     //
-    rSt.Seek( rFib.fcPlcfLst );
-    sal_uInt16 nListCount;
-    rSt >> nListCount;
-    bool bOk = 0 < nListCount;
+    bool bOk = checkSeek(rSt, rFib.fcPlcfLst);
+    sal_uInt16 nListCount(0);
+    if (bOk)
+    {
+        rSt >> nListCount;
+        bOk = 0 < nListCount;
+    }
     if( bOk )
     {
-        WW8LST aLST;
         //
         // 1.1 alle LST einlesen
         //
         for (sal_uInt16 nList=0; nList < nListCount; ++nList)
         {
             bOk = false;
+
+            if (rSt.IsEof())
+                break;
+
+            WW8LST aLST;
             memset(&aLST, 0, sizeof( aLST ));
-            sal_uInt16 nLevel;
             //
             // 1.1.1 Daten einlesen
             //
             rSt >> aLST.nIdLst;
             rSt >> aLST.nTplC;
-            for (nLevel = 0; nLevel < nMaxLevel; ++nLevel)
+            for (sal_uInt16 nLevel = 0; nLevel < nMaxLevel; ++nLevel)
                 rSt >> aLST.aIdSty[ nLevel ];
 
 
@@ -1138,7 +1144,6 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
         //
         // 1.2 alle LVL aller aLST einlesen
         //
-        sal_uInt8 nLevel;
         sal_uInt16 nLSTInfos = static_cast< sal_uInt16 >(maLSTInfos.size());
         for (sal_uInt16 nList = 0; nList < nLSTInfos; ++nList)
         {
@@ -1153,7 +1158,7 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
             std::deque<bool> aNotReallyThere;
             aNotReallyThere.resize(nMaxLevel);
             pListInfo->maParaSprms.resize(nMaxLevel);
-            for (nLevel = 0; nLevel < nLvlCount; ++nLevel)
+            for (sal_uInt8 nLevel = 0; nLevel < nLvlCount; ++nLevel)
             {
                 SwNumFmt aNumFmt( rMyNumRule.Get( nLevel ) );
                 // LVLF einlesen
@@ -1171,16 +1176,16 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
             // 1.2.2 die ItemPools mit den CHPx Einstellungen der verschiedenen
             //       Level miteinander vergleichen und ggfs. Style(s) erzeugen
             //
-            bool bDummy;
-            for (nLevel = 0; nLevel < nLvlCount; ++nLevel)
+            for (sal_uInt8 nLevel = 0; nLevel < nLvlCount; ++nLevel)
             {
+                bool bDummy;
                 AdjustLVL( nLevel, rMyNumRule, pListInfo->aItemSet,
                                                pListInfo->aCharFmt, bDummy );
             }
             //
             // 1.2.3 ItemPools leeren und loeschen
             //
-            for (nLevel = 0; nLevel < nLvlCount; ++nLevel)
+            for (sal_uInt8 nLevel = 0; nLevel < nLvlCount; ++nLevel)
                 delete pListInfo->aItemSet[ nLevel ];
             bOk = true;
         }
@@ -1196,9 +1201,12 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
     // 2. PLF LFO auslesen und speichern
     //
     long nLfoCount(0);
+
+    if (bOk)
+        bOk = checkSeek(rSt, rFib.fcPlfLfo);
+
     if (bOk)
     {
-        rSt.Seek(rFib.fcPlfLfo);
         rSt >> nLfoCount;
         if (0 >= nLfoCount)
             bOk = false;
@@ -1206,14 +1214,19 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
 
     if(bOk)
     {
-        WW8LFO aLFO;
         //
         // 2.1 alle LFO einlesen
         //
         for (sal_uInt16 nLfo = 0; nLfo < nLfoCount; ++nLfo)
         {
             bOk = false;
+
+            if (rSt.IsEof())
+                break;
+
+            WW8LFO aLFO;
             memset(&aLFO, 0, sizeof( aLFO ));
+
             rSt >> aLFO.nIdLst;
             rSt.SeekRel( 8 );
             rSt >> aLFO.nLfoLvl;
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 3a18004..ba38e49 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -7319,4 +7319,9 @@ SEPr::SEPr() :
     memset(rgdxaColumnWidthSpacing, 0, sizeof(rgdxaColumnWidthSpacing));
 }
 
+bool checkSeek(SvStream &rSt, WW8_FC nOffset)
+{
+    return (rSt.Seek(nOffset) == static_cast<sal_Size>(nOffset));
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index 7d809d8..6e76cdc 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -1780,6 +1780,8 @@ std::vector<sal_uInt8> ChpxToSprms(const Word2CHPX &rChpx);
 
 sal_uLong SafeReadString(ByteString &rStr,sal_uInt16 nLen,SvStream &rStrm);
 
+bool checkSeek(SvStream &rSt, WW8_FC nOffset);
+
 //MS has a (slightly) inaccurate view of how many twips
 //are in the default letter size of a page
 const sal_uInt16 lLetterWidth = 12242;


More information about the Libreoffice-commits mailing list