[Libreoffice-commits] .: Branch 'libreoffice-3-4' - 4 commits - sw/source

Michael Meeks michael at kemper.freedesktop.org
Fri Jul 8 03:38:59 PDT 2011


 sw/source/filter/ww8/ww8par.cxx     |    2 +-
 sw/source/filter/ww8/ww8par2.cxx    |   24 +++++-------------------
 sw/source/filter/ww8/ww8par3.cxx    |   15 +--------------
 sw/source/filter/ww8/ww8scan.cxx    |   21 +++++++++++++++++++++
 sw/source/filter/ww8/ww8scan.hxx    |    5 +++++
 sw/source/filter/ww8/ww8toolbar.cxx |    6 ++++--
 6 files changed, 37 insertions(+), 36 deletions(-)

New commits:
commit 410105ca3c9ec448e162d66a072ffd2b2b42424f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Jun 18 00:39:59 2011 +0100

    handle truncated stream
    
    Signed-off-by: Michael Meeks <michael.meeks at novell.com>

diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index ce86fd2..163b078 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -5358,7 +5358,7 @@ sal_uLong SwWW8ImplReader::LoadDoc( SwPaM& rPaM,WW8Glossary *pGloss)
         m_bRegardHindiDigits = aVal[ 12 ] > 0;
     }
 
-    sal_uInt16 nMagic;
+    sal_uInt16 nMagic(0);
     *pStrm >> nMagic;
 
     // beachte: 6 steht fuer "6 ODER 7",  7 steht fuer "NUR 7"
commit 0e34784737d4f654aba92932680c521a9430f63f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jun 17 23:48:50 2011 +0100

    merge these sprm finders and do it right
    
    Signed-off-by: Michael Meeks <michael.meeks at novell.com>

diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index bda689b..0ee1b97 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -3699,21 +3699,7 @@ const sal_uInt8* WW8RStyle::HasParaSprm( sal_uInt16 nId ) const
     if( !pParaSprms || !nSprmsLen )
         return 0;
 
-    const sal_uInt8* pSprms = pParaSprms;
-    sal_uInt16 i, x;
-
-    for( i=0; i < nSprmsLen; )
-    {
-        sal_uInt16 nAktId = maSprmParser.GetSprmId(pSprms);
-        // Sprm found ?
-        if( nAktId == nId )
-            return pSprms + maSprmParser.DistanceToData(nId);
-
-        x = maSprmParser.GetSprmSize(nAktId, pSprms);
-        i = i + x;
-        pSprms += x;
-    }
-    return 0;                               // Sprm not found
+    return maSprmParser.findSprmData(nId, pParaSprms, nSprmsLen);
 }
 
 void WW8RStyle::ImportSprms(sal_uInt8 *pSprms, short nLen, bool bPap)
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index c1062da..bbc99af 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -470,20 +470,7 @@ SV_IMPL_PTRARR( WW8LFOInfos, WW8LFOInfo_Ptr );
 sal_uInt8* WW8ListManager::GrpprlHasSprm(sal_uInt16 nId, sal_uInt8& rSprms,
     sal_uInt8 nLen)
 {
-    sal_uInt8* pSprms = &rSprms;
-    sal_uInt16 nRemLen=nLen;
-    while (nRemLen > (maSprmParser.getVersion()?1:0))
-    {
-        sal_uInt16 nAktId = maSprmParser.GetSprmId(pSprms);
-        if( nAktId == nId ) // Sprm found
-            return pSprms + maSprmParser.DistanceToData(nId);
-
-        // gib Zeiger auf Daten
-        sal_uInt16 nSize = maSprmParser.GetSprmSize(nAktId, pSprms);
-        pSprms += nSize;
-        nRemLen -= nSize;
-    }
-    return 0;                           // Sprm not found
+    return maSprmParser.findSprmData(nId, &rSprms, nLen);
 }
 
 class ListWithId : public std::unary_function<const WW8LSTInfo *, bool>
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index dbb8d2c..3db9bf6 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -7280,6 +7280,27 @@ sal_uInt16 wwSprmParser::DistanceToData(sal_uInt16 nId) const
     return 1 + mnDelta + SprmDataOfs(nId);
 }
 
+sal_uInt8* wwSprmParser::findSprmData(sal_uInt16 nId, sal_uInt8* pSprms,
+    sal_uInt16 nLen) const
+{
+    while (nLen > (getVersion()?1:0))
+    {
+        sal_uInt16 nAktId = GetSprmId(pSprms);
+        if (nAktId == nId) // Sprm found
+            return pSprms + DistanceToData(nId);
+
+        // gib Zeiger auf Daten
+        sal_uInt16 nSize = GetSprmSize(nAktId, pSprms);
+        OSL_ENSURE(nSize <= nLen, "sprm longer than remaining bytes");
+        //Clip to available size if wrong
+        nSize = std::min(nSize, nLen);
+        pSprms += nSize;
+        nLen -= nSize;
+    }
+    // Sprm not found
+    return 0;
+}
+
 SEPr::SEPr() :
     bkc(2), fTitlePage(0), fAutoPgn(0), nfcPgn(0), fUnlocked(0), cnsPgn(0),
     fPgnRestart(0), fEndNote(1), lnc(0), grpfIhdt(0), nLnnMod(0), dxaLnn(0),
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index 0bb532a..7d809d8 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -145,6 +145,11 @@ public:
     /// The minimum acceptable sprm len possible for this type of parser
     int MinSprmLen() const { return (IsSevenMinus(meVersion)) ? 2 : 3; }
 
+    /// Returns the offset to data of the first sprm of id nId, 0
+    //  if not found. nLen must be the <= length of pSprms
+    sal_uInt8* findSprmData(sal_uInt16 nId, sal_uInt8* pSprms, sal_uInt16 nLen)
+        const;
+
     inline int getVersion() const { return meVersion; } //cmc, I'm dubious about the usage of this, how can it be 0
 };
 
commit deba57d90339fa6083a54495aa410872ffa5e15e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Jul 2 21:34:14 2011 +0100

    Resolves: fdo#34023 hang on load of .doc
    
    Signed-off-by: Michael Meeks <michael.meeks at novell.com>

diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx
index 0f4a644..20bfcf3 100644
--- a/sw/source/filter/ww8/ww8toolbar.cxx
+++ b/sw/source/filter/ww8/ww8toolbar.cxx
@@ -906,12 +906,13 @@ bool Tcg255::Read(SvStream *pS)
 {
     OSL_TRACE("Tcg255::Read() stream pos 0x%x", pS->Tell() );
     nOffSet = pS->Tell();
-    sal_uInt8 nId = 0; //
+    sal_uInt8 nId = 0x40;
     *pS >> nId;
     while (  nId != 0x40  )
     {
         if ( !processSubStruct( nId, pS ) )
             return false;
+        nId = 0x40;
         *pS >> nId;
     }
     return true;
@@ -948,9 +949,10 @@ bool Tcg255SubStruct::Read(SvStream *pS)
     return true;
 }
 
-PlfMcd::PlfMcd( bool bReadId ): Tcg255SubStruct( bReadId ), rgmcd( NULL )
+PlfMcd::PlfMcd( bool bReadId ): Tcg255SubStruct( bReadId ), iMac(0), rgmcd( NULL )
 {
 }
+
 PlfMcd::~PlfMcd()
 {
     if ( rgmcd )
commit b00c51c9fb1a69431248e3bfa3d8e9265e69a83c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Jul 2 01:55:56 2011 +0100

    Related: fdo#37057 use standard sprm iterator
    
    Signed-off-by: Michael Meeks <michael.meeks at novell.com>

diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 4ab1be3..bda689b 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -3727,11 +3727,11 @@ void WW8RStyle::ImportSprms(sal_uInt8 *pSprms, short nLen, bool bPap)
         nSprmsLen = nLen;
     }
 
-    while ( nLen > 0 )
+    WW8SprmIter aSprmIter(pSprms, nLen, maSprmParser);
+    while (const sal_uInt8* pSprm = aSprmIter.GetSprms())
     {
-        sal_uInt16 nL1 = pIo->ImportSprm(pSprms);
-        nLen = nLen - nL1;
-        pSprms += nL1;
+        pIo->ImportSprm(pSprm);
+        aSprmIter.advance();
     }
 
     pParaSprms = 0;


More information about the Libreoffice-commits mailing list