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

Caolán McNamara caolan at kemper.freedesktop.org
Tue Aug 9 03:15:32 PDT 2011


 sw/source/filter/ww8/ww8par6.cxx |   29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

New commits:
commit 2f151aae24ac54b5efd675f4b2f162e07e02ac10
Author: Marc-Andre Laverdiere <marc-andre at atc.tcs.com>
Date:   Mon Jul 25 17:15:04 2011 +0530

    Fixed invalid array dereference
    (cherry picked from commit 560b004d9812a76783c701724043f6cee70c0928)

diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 65aa924..3df4de1 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -332,19 +332,21 @@ void SwWW8ImplReader::Read_ParaBiDi(sal_uInt16, const sal_uInt8* pData, short nL
 bool wwSectionManager::SetCols(SwFrmFmt &rFmt, const wwSection &rSection,
     sal_uInt32 nNettoWidth) const
 {
-    //sprmSCcolumns - Anzahl der Spalten - 1
-    sal_Int16 nCols = rSection.NoCols();
+    //sprmSCcolumns - number of columns - 1
+    const sal_Int16 nCols = rSection.NoCols();
 
-    if (nCols < 2)
-        return false;                   // keine oder bloedsinnige Spalten
+    if (nCols < 2)          //check for no columns or other wierd state
+        return false;
 
-    SwFmtCol aCol;                      // Erzeuge SwFmtCol
+    SwFmtCol aCol;                      // Create SwFmtCol
 
-    //sprmSDxaColumns   - Default-Abstand 1.25 cm
+    //sprmSDxaColumns   - Default distance is 1.25 cm
     sal_Int32 nColSpace = rSection.StandardColSeperation();
 
+    const SEPr& rSep = rSection.maSep;
+
     // sprmSLBetween
-    if (rSection.maSep.fLBetween)
+    if (rSep.fLBetween)
     {
         aCol.SetLineAdj(COLADJ_TOP);      // Line
         aCol.SetLineHeight(100);
@@ -356,21 +358,20 @@ bool wwSectionManager::SetCols(SwFrmFmt &rFmt, const wwSection &rSection,
         writer_cast<sal_uInt16>(nNettoWidth));
 
     // sprmSFEvenlySpaced
-    if (!rSection.maSep.fEvenlySpaced)
+    if (!rSep.fEvenlySpaced)
     {
         aCol._SetOrtho(false);
-        int nIdx = 1;
-        for (sal_uInt16 i = 0; i < nCols; i++ )
+        const sal_uInt16 maxIdx = SAL_N_ELEMENTS(rSep.rgdxaColumnWidthSpacing);
+        for (sal_uInt16 i = 0, nIdx = 1; i < nCols && nIdx < maxIdx; i++, nIdx+=2 )
         {
             SwColumn* pCol = aCol.GetColumns()[i];
-            sal_Int32 nLeft = rSection.maSep.rgdxaColumnWidthSpacing[nIdx-1]/2;
-            sal_Int32 nRight = rSection.maSep.rgdxaColumnWidthSpacing[nIdx+1]/2;
-            sal_Int32 nWishWidth = rSection.maSep.rgdxaColumnWidthSpacing[nIdx]
+            const sal_Int32 nLeft = rSep.rgdxaColumnWidthSpacing[nIdx-1]/2;
+            const sal_Int32 nRight = rSep.rgdxaColumnWidthSpacing[nIdx+1]/2;
+            const sal_Int32 nWishWidth = rSep.rgdxaColumnWidthSpacing[nIdx]
                 + nLeft + nRight;
             pCol->SetWishWidth(writer_cast<sal_uInt16>(nWishWidth));
             pCol->SetLeft(writer_cast<sal_uInt16>(nLeft));
             pCol->SetRight(writer_cast<sal_uInt16>(nRight));
-            nIdx += 2;
         }
         aCol.SetWishWidth(writer_cast<sal_uInt16>(nNettoWidth));
     }


More information about the Libreoffice-commits mailing list