[Libreoffice-commits] core.git: 2 commits - chart2/qa include/oox oox/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Tue Mar 4 12:19:06 PST 2014


 chart2/qa/extras/chart2import.cxx              |   10 ++-----
 dev/null                                       |binary
 include/oox/drawingml/shapepropertymap.hxx     |    8 +++--
 oox/source/drawingml/chart/objectformatter.cxx |   35 ++++++++++++++++++++-----
 oox/source/drawingml/shapepropertymap.cxx      |   15 +++++++---
 oox/source/helper/propertymap.cxx              |    7 +----
 oox/source/token/properties.pl                 |    1 
 7 files changed, 50 insertions(+), 26 deletions(-)

New commits:
commit 20a7a705b572f02049ebe76b2e8cc84c4f4b3d05
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Mar 4 21:10:10 2014 +0100

    in the old design all lists needed to be the same size, fdo75200
    
    We did not crash in the invalid memory access because the lists were
    continuous in memory and we would just pick the next id. However it
    crashed when trying to map some of the ids to non existant strings. This
    commit also removes the need for the earlier fix for this bug that just
    hit the problem behind some checks much later in the call chain.
    
    Change-Id: Ic6658987815c4e84ed2449934c310e30dcd0ed4c

diff --git a/include/oox/drawingml/shapepropertymap.hxx b/include/oox/drawingml/shapepropertymap.hxx
index c2c6896..29b0ba2 100644
--- a/include/oox/drawingml/shapepropertymap.hxx
+++ b/include/oox/drawingml/shapepropertymap.hxx
@@ -23,6 +23,8 @@
 #include <oox/helper/propertymap.hxx>
 #include <oox/dllapi.h>
 
+#include <vector>
+
 namespace oox { class ModelObjectHelper; }
 
 namespace oox {
@@ -70,7 +72,7 @@ enum ShapePropertyId
 
 struct OOX_DLLPUBLIC ShapePropertyInfo
 {
-    const sal_Int32*    mpnPropertyIds;         /// Pointer to array of property identifiers for all SHAPEPROP properties.
+    std::vector<sal_Int32> maPropertyIds;
     bool                mbNamedLineMarker;      /// True = use named line marker instead of explicit line marker.
     bool                mbNamedLineDash;        /// True = use named line dash instead of explicit line dash.
     bool                mbNamedFillGradient;    /// True = use named fill gradient instead of explicit fill gradient.
@@ -85,8 +87,8 @@ struct OOX_DLLPUBLIC ShapePropertyInfo
                             bool bNamedFillGradient,
                             bool bNamedFillBitmapUrl );
 
-    bool         has( ShapePropertyId ePropId ) const { return mpnPropertyIds[ ePropId ] >= 0; }
-    sal_Int32    operator[]( ShapePropertyId ePropId ) const { return mpnPropertyIds[ ePropId ]; }
+    bool         has( ShapePropertyId ePropId ) const { return maPropertyIds.size() > size_t(ePropId) && maPropertyIds[ ePropId ] >= 0; }
+    sal_Int32    operator[]( ShapePropertyId ePropId ) const { return maPropertyIds[ ePropId ]; }
 };
 
 
diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx
index 297ad7b..adcc3f3 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -469,7 +469,8 @@ static const sal_Int32 spnCommonPropIds[] =
     PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
     PROP_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_INVALID, PROP_FillGradientName,
     PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY,
-    PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint
+    PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint,
+    PROP_END_LIST
 };
 
 /** Property identifiers for linear data series, to be used in ShapePropertyInfo. */
@@ -479,17 +480,37 @@ static const sal_Int32 spnLinearPropIds[] =
     PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
     PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
     PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
-    PROP_INVALID, PROP_INVALID, PROP_INVALID
+    PROP_INVALID, PROP_INVALID, PROP_INVALID,
+    PROP_END_LIST
 };
 
 /** Property identifiers for filled data series, to be used in ShapePropertyInfo. */
 static const sal_Int32 spnFilledPropIds[] =
 {
-    PROP_BorderStyle, PROP_BorderWidth, PROP_BorderColor, PROP_BorderTransparency, PROP_BorderDashName,
-    PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
-    PROP_FillStyle, PROP_Color, PROP_Transparency, PROP_GradientName,
-    PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY,
-    PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint
+    PROP_BorderStyle,
+    PROP_BorderWidth,
+    PROP_BorderColor,
+    PROP_BorderTransparency,
+    PROP_BorderDashName,
+    PROP_INVALID,
+    PROP_INVALID,
+    PROP_INVALID,
+    PROP_INVALID,
+    PROP_INVALID,
+    PROP_INVALID,
+    PROP_INVALID,
+    PROP_FillStyle,
+    PROP_Color,
+    PROP_Transparency,
+    PROP_GradientName,
+    PROP_FillBitmapName,
+    PROP_FillBitmapMode,
+    PROP_FillBitmapSizeX,
+    PROP_FillBitmapSizeY,
+    PROP_FillBitmapPositionOffsetX,
+    PROP_FillBitmapPositionOffsetY,
+    PROP_FillBitmapRectanglePoint,
+    PROP_END_LIST
 };
 
 /** Property info for common chart objects, to be used in ShapePropertyMap. */
diff --git a/oox/source/drawingml/shapepropertymap.cxx b/oox/source/drawingml/shapepropertymap.cxx
index 2ea89e6..446282b 100644
--- a/oox/source/drawingml/shapepropertymap.cxx
+++ b/oox/source/drawingml/shapepropertymap.cxx
@@ -39,7 +39,7 @@ using namespace ::com::sun::star::uno;
 
 namespace {
 
-static const sal_Int32 spnDefaultShapeIds[ SHAPEPROP_END ] =
+static const sal_Int32 spnDefaultShapeIds[ SHAPEPROP_END + 1 ] = // one for the PROP_END_LIST
 {
     PROP_LineStyle, PROP_LineWidth, PROP_LineColor, PROP_LineTransparence, PROP_LineDash, PROP_LineJoint,
     PROP_LineStartName, PROP_LineStartWidth, PROP_LineStartCenter, PROP_LineEndName, PROP_LineEndWidth, PROP_LineEndCenter,
@@ -47,7 +47,8 @@ static const sal_Int32 spnDefaultShapeIds[ SHAPEPROP_END ] =
     PROP_FillBitmapURL, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY,
     PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint,
     PROP_FillHatch,
-    PROP_ShadowXDistance
+    PROP_ShadowXDistance,
+    PROP_END_LIST
 };
 
 } // namespace
@@ -56,13 +57,19 @@ ShapePropertyInfo ShapePropertyInfo::DEFAULT( spnDefaultShapeIds, true, false, f
 
 ShapePropertyInfo::ShapePropertyInfo( const sal_Int32* pnPropertyIds,
         bool bNamedLineMarker, bool bNamedLineDash, bool bNamedFillGradient, bool bNamedFillBitmapUrl ) :
-    mpnPropertyIds( pnPropertyIds ),
     mbNamedLineMarker( bNamedLineMarker ),
     mbNamedLineDash( bNamedLineDash ),
     mbNamedFillGradient( bNamedFillGradient ),
     mbNamedFillBitmapUrl( bNamedFillBitmapUrl )
 {
-    OSL_ENSURE( mpnPropertyIds != 0, "ShapePropertyInfo::ShapePropertyInfo - missing property identifiers" );
+    assert(pnPropertyIds);
+    for(size_t i = 0;; ++i)
+    {
+        if(pnPropertyIds[i] == PROP_END_LIST)
+            break;
+
+        maPropertyIds.push_back(pnPropertyIds[i]);
+    }
 }
 
 
diff --git a/oox/source/token/properties.pl b/oox/source/token/properties.pl
index d2a2d80..3a8e872 100644
--- a/oox/source/token/properties.pl
+++ b/oox/source/token/properties.pl
@@ -53,6 +53,7 @@ foreach( sort( keys( %props ) ) )
 
 print( IDFILE "const sal_Int32 PROP_COUNT = $i;\n" );
 print( IDFILE "const sal_Int32 PROP_INVALID = -1;\n" );
+print( IDFILE "const sal_Int32 PROP_END_LIST = -2;\n" );
 
 close( IDFILE );
 close( NAMEFILE );
commit bbaad88a5c5643365afc438fc53e864e4233a628
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Mar 4 19:00:45 2014 +0100

    Revert "fdo#75200:Libreoffice crash while opening the file"
    
    This reverts commit 0b6a1f2afa7954afcf1f27b066169455ed6cff7a.

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 17940fe..2d4259b 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -34,7 +34,6 @@ public:
     void testPPTChartSeries();
     void testODPChartSeries();
     void testBnc864396();
-    void testChartFileOpen();
 
     CPPUNIT_TEST_SUITE(Chart2ImportTest);
     CPPUNIT_TEST(Fdo60083);
@@ -46,7 +45,6 @@ public:
     CPPUNIT_TEST(testODTChartSeries);
     CPPUNIT_TEST(testDOCChartSeries);
     CPPUNIT_TEST(testDOCXChartSeries);
-    CPPUNIT_TEST(testChartFileOpen);
 /*
  *  Disabling Impress Uts.
  *  ChartTest::tearDown() calls dispose of mxComponent
@@ -262,6 +260,7 @@ void Chart2ImportTest::testPPTChartSeries()
     CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
     CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
     CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
+
 }
 
 void Chart2ImportTest::testPPTXChartSeries()
@@ -271,6 +270,7 @@ void Chart2ImportTest::testPPTXChartSeries()
     CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[1]);
     CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[2]);
     CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[3]);
+
 }
 
 void Chart2ImportTest::testODPChartSeries()
@@ -280,6 +280,7 @@ void Chart2ImportTest::testODPChartSeries()
     CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
     CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
     CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
+
 }
 
 void Chart2ImportTest::testBnc864396()
@@ -297,11 +298,6 @@ void Chart2ImportTest::testBnc864396()
     }
 }
 
-void Chart2ImportTest::testChartFileOpen()
-{
-    load("/chart2/qa/extras/data/docx/", "barChart.docx");
-}
-
 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/docx/barChart.docx b/chart2/qa/extras/data/docx/barChart.docx
deleted file mode 100644
index 9b9152b..0000000
Binary files a/chart2/qa/extras/data/docx/barChart.docx and /dev/null differ
diff --git a/oox/source/helper/propertymap.cxx b/oox/source/helper/propertymap.cxx
index 968aea1..5e27b44 100644
--- a/oox/source/helper/propertymap.cxx
+++ b/oox/source/helper/propertymap.cxx
@@ -267,11 +267,8 @@ void PropertyMap::fillSequences( Sequence< OUString >& rNames, Sequence< Any >&
         for( PropertyMapType::const_iterator aIt = maProperties.begin(), aEnd = maProperties.end(); aIt != aEnd; ++aIt, ++pNames, ++pValues )
         {
             OSL_ENSURE( (0 <= aIt->first) && (aIt->first < PROP_COUNT), "PropertyMap::fillSequences - invalid property identifier" );
-            if((sal_uInt32)aIt->first <= mpPropNames->size())
-            {
-               *pNames = (*mpPropNames)[ aIt->first ];
-               *pValues = aIt->second;
-            }
+            *pNames = (*mpPropNames)[ aIt->first ];
+            *pValues = aIt->second;
         }
     }
 }


More information about the Libreoffice-commits mailing list