[Libreoffice-commits] core.git: 5 commits - filter/source include/svx include/tools svx/source tools/source vcl/source

Armin Le Grand alg at apache.org
Sun May 19 08:32:56 PDT 2013


 filter/source/msfilter/msdffimp.cxx                     |   11 +
 include/svx/sdr/primitive2d/sdrattributecreator.hxx     |    5 
 include/tools/poly.hxx                                  |    2 
 svx/source/customshapes/EnhancedCustomShape3d.cxx       |  103 ++++++++++++++--
 svx/source/customshapes/EnhancedCustomShapeGeometry.cxx |    1 
 tools/source/generic/poly2.cxx                          |   17 --
 vcl/source/filter/wmf/enhwmf.cxx                        |   31 +++-
 vcl/source/filter/wmf/winwmf.cxx                        |   80 ++++++------
 8 files changed, 174 insertions(+), 76 deletions(-)

New commits:
commit d0a956f1d80aaf4be6d19d339bd46addc8c16861
Author: Armin Le Grand <alg at apache.org>
Date:   Wed Aug 15 13:18:59 2012 +0000

    Resolves: #i119496# Correct flags AutoGrowWidth/Height for WordArt
    
    Patch by: SunYing
    Review by: Jianyuan Li, alg(cherry picked from commit 3048c821bb664f39c7b5e2533af4568fbcd22f73)
    
    Change-Id: Ib0ea2de7699e94bda81768e210ad7d921aefce48

diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index b8b92db..bc6f9a9 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -4233,6 +4233,10 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
                         }
                         if ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x1000 ) // SJ: Font Kerning On ?
                             aSet.Put( SvxKerningItem( 1, EE_CHAR_KERNING ) );
+
+                        // #i119496# the resize autoshape to fit text attr of word art in MS PPT is always false
+                        aSet.Put(SdrTextAutoGrowHeightItem(false));
+                        aSet.Put(SdrTextAutoGrowWidthItem(false));
                     }
                     pRet->SetMergedItemSet( aSet );
 
commit 42b4dc4f8cad68ebd1386c5b8ea76ffaf59fdeb4
Author: Armin Le Grand <alg at apache.org>
Date:   Wed Aug 22 13:17:43 2012 +0000

    Related: #i120569# Corrected 3D object creations
    
    (cherry picked from commit 753dd9ee0c8101ce613cdc7e1a68141e0f8561d3)
    
    Change-Id: Ic7534a310b8d8c526b2639243c9d734e26b55560

diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx
index a879ddc..010b037 100644
--- a/svx/source/customshapes/EnhancedCustomShape3d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx
@@ -372,7 +372,9 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
         }
 
         Rectangle aBoundRect2d;
-        SdrObjListIter aIter( *pShape2d, IM_DEEPWITHGROUPS );
+        SdrObjListIter aIter( *pShape2d, IM_DEEPNOGROUPS );
+        const bool bMultipleSubObjects(aIter.Count() > 1);
+
         while( aIter.IsMore() )
         {
             const SdrObject* pNext = aIter.Next();
@@ -385,19 +387,34 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
             if ( pNext->ISA( SdrPathObj ) )
             {
                 const SfxItemSet& rSet = pNext->GetMergedItemSet();
-                const drawinglayer::attribute::SdrLineAttribute aLine(
-                    drawinglayer::primitive2d::createNewSdrLineAttribute(rSet));
-                bool bNeedToConvertToContour(0.0 <= aLine.getWidth() || 0.0 != aLine.getFullDotDashLen());
+                bool bNeedToConvertToContour(false);
 
-                if(!bNeedToConvertToContour && !aLine.isDefault())
+                // do conversion only for single line objects; for all others a fill and a
+                // line object get created. When we have fill, we want no line. That line has
+                // always been there, but since it was never converted to contour, it kept
+                // invisible (all this 'hidden' logic should be migrated to primitives).
+                if(!bMultipleSubObjects)
                 {
-                    const drawinglayer::attribute::SdrLineStartEndAttribute aLineStartEnd(
-                        drawinglayer::primitive2d::createNewSdrLineStartEndAttribute(rSet, aLine.getWidth()));
+                    const XFillStyle eStyle(((XFillStyleItem&)(rSet.Get(XATTR_FILLSTYLE))).GetValue());
 
-                    if((aLineStartEnd.getStartWidth() && aLineStartEnd.isStartActive())
-                        || (aLineStartEnd.getEndWidth() && aLineStartEnd.isEndActive()))
+                    if(XFILL_NONE == eStyle)
                     {
-                        bNeedToConvertToContour = true;
+                        const drawinglayer::attribute::SdrLineAttribute aLine(
+                            drawinglayer::primitive2d::createNewSdrLineAttribute(rSet));
+
+                        bNeedToConvertToContour = (0.0 < aLine.getWidth() || 0.0 != aLine.getFullDotDashLen());
+
+                        if(!bNeedToConvertToContour && !aLine.isDefault())
+                        {
+                            const drawinglayer::attribute::SdrLineStartEndAttribute aLineStartEnd(
+                                drawinglayer::primitive2d::createNewSdrLineStartEndAttribute(rSet, aLine.getWidth()));
+
+                            if((aLineStartEnd.getStartWidth() && aLineStartEnd.isStartActive())
+                                || (aLineStartEnd.getEndWidth() && aLineStartEnd.isEndActive()))
+                            {
+                                bNeedToConvertToContour = true;
+                            }
+                        }
                     }
                 }
 
@@ -413,12 +430,23 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
                         if(aPolyPoly.isClosed())
                         {
                             // correct item properties from line to fill style
-                            aLocalSet.Put(XLineWidthItem(0));
-                            aLocalSet.Put(XLineStyleItem(XLINE_NONE));
-                            aLocalSet.Put(XFillColorItem(XubString(), ((const XLineColorItem&)(aLocalSet.Get(XATTR_LINECOLOR))).GetColorValue()));
-                            aLocalSet.Put(XFillStyleItem(XFILL_SOLID));
-                            aLocalSet.Put(XFillTransparenceItem(((const XLineTransparenceItem&)(aLocalSet.Get(XATTR_LINETRANSPARENCE))).GetValue()));
-                            aLocalFillStyle = XFILL_SOLID;
+                            if(eShadeMode == drawing::ShadeMode_DRAFT)
+                            {
+                                // for draft, create wireframe with fixed line width
+                                aLocalSet.Put(XLineStyleItem(XLINE_SOLID));
+                                aLocalSet.Put(XLineWidthItem(40));
+                                aLocalFillStyle = XFILL_NONE;
+                            }
+                            else
+                            {
+                                // switch from line to fill, copy line attr to fill attr (color, transparence)
+                                aLocalSet.Put(XLineWidthItem(0));
+                                aLocalSet.Put(XLineStyleItem(XLINE_NONE));
+                                aLocalSet.Put(XFillColorItem(XubString(), ((const XLineColorItem&)(aLocalSet.Get(XATTR_LINECOLOR))).GetColorValue()));
+                                aLocalSet.Put(XFillStyleItem(XFILL_SOLID));
+                                aLocalSet.Put(XFillTransparenceItem(((const XLineTransparenceItem&)(aLocalSet.Get(XATTR_LINETRANSPARENCE))).GetValue()));
+                                aLocalFillStyle = XFILL_SOLID;
+                            }
                         }
                         else
                         {
commit 118a8ad8c6287e7a4cc81ec46504f6cdffdf826d
Author: Armin Le Grand <alg at apache.org>
Date:   Wed Aug 15 09:58:09 2012 +0000

    Resolves: #i120569# Enhanced 3D visualisation of line custom shapes
    
    (cherry picked from commit aa4649b8feb28c250cbbab65c749ae01524726fe)
    
    Conflicts:
    	svx/inc/svx/sdr/primitive2d/sdrattributecreator.hxx
    
    Change-Id: I642428e988e7bed9a5c1d2d2db0f95fe775f06cf

diff --git a/include/svx/sdr/primitive2d/sdrattributecreator.hxx b/include/svx/sdr/primitive2d/sdrattributecreator.hxx
index e3e9409..1b3ade7 100644
--- a/include/svx/sdr/primitive2d/sdrattributecreator.hxx
+++ b/include/svx/sdr/primitive2d/sdrattributecreator.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_SDR_PRIMITIVE2D_SDRATTRIBUTECREATOR_HXX
 
 #include <sal/types.h>
+#include <svx/svxdllapi.h>
 
 //////////////////////////////////////////////////////////////////////////////
 // predefines
@@ -55,10 +56,10 @@ namespace drawinglayer
     namespace primitive2d
     {
         // SdrAttribute creators
-        attribute::SdrLineAttribute createNewSdrLineAttribute(
+        attribute::SdrLineAttribute SVX_DLLPUBLIC createNewSdrLineAttribute(
             const SfxItemSet& rSet);
 
-        attribute::SdrLineStartEndAttribute createNewSdrLineStartEndAttribute(
+        attribute::SdrLineStartEndAttribute SVX_DLLPUBLIC createNewSdrLineStartEndAttribute(
             const SfxItemSet& rSet,
             double fWidth);
 
diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx
index 510e976..a879ddc 100644
--- a/svx/source/customshapes/EnhancedCustomShape3d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx
@@ -50,6 +50,12 @@
 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
 #include <basegfx/polygon/b2dpolypolygontools.hxx>
 #include <basegfx/range/b2drange.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <drawinglayer/attribute/sdrlineattribute.hxx>
+#include <drawinglayer/attribute/sdrlinestartendattribute.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xlntrit.hxx>
+#include <svx/xfltrit.hxx>
 
 #define ITEMVALUE(ItemSet,Id,Cast)  ((const Cast&)(ItemSet).Get(Id)).GetValue()
 using namespace com::sun::star;
@@ -373,14 +379,60 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
             bool bIsPlaceholderObject = (((XFillStyleItem&)pNext->GetMergedItem( XATTR_FILLSTYLE )).GetValue() == XFILL_NONE )
                                         && (((XLineStyleItem&)pNext->GetMergedItem( XATTR_LINESTYLE )).GetValue() == XLINE_NONE );
             basegfx::B2DPolyPolygon aPolyPoly;
+            SfxItemSet aLocalSet(aSet);
+            XFillStyle aLocalFillStyle(eFillStyle);
 
             if ( pNext->ISA( SdrPathObj ) )
             {
-                aPolyPoly = ((SdrPathObj*)pNext)->GetPathPoly();
+                const SfxItemSet& rSet = pNext->GetMergedItemSet();
+                const drawinglayer::attribute::SdrLineAttribute aLine(
+                    drawinglayer::primitive2d::createNewSdrLineAttribute(rSet));
+                bool bNeedToConvertToContour(0.0 <= aLine.getWidth() || 0.0 != aLine.getFullDotDashLen());
 
-                if(aPolyPoly.areControlPointsUsed())
+                if(!bNeedToConvertToContour && !aLine.isDefault())
                 {
-                    aPolyPoly = basegfx::tools::adaptiveSubdivideByAngle(aPolyPoly);
+                    const drawinglayer::attribute::SdrLineStartEndAttribute aLineStartEnd(
+                        drawinglayer::primitive2d::createNewSdrLineStartEndAttribute(rSet, aLine.getWidth()));
+
+                    if((aLineStartEnd.getStartWidth() && aLineStartEnd.isStartActive())
+                        || (aLineStartEnd.getEndWidth() && aLineStartEnd.isEndActive()))
+                    {
+                        bNeedToConvertToContour = true;
+                    }
+                }
+
+                if(bNeedToConvertToContour)
+                {
+                    SdrObject* pNewObj = pNext->ConvertToContourObj(const_cast< SdrObject* >(pNext));
+                    SdrPathObj* pNewPathObj = dynamic_cast< SdrPathObj* >(pNewObj);
+
+                    if(pNewPathObj)
+                    {
+                        aPolyPoly = pNewPathObj->GetPathPoly();
+
+                        if(aPolyPoly.isClosed())
+                        {
+                            // correct item properties from line to fill style
+                            aLocalSet.Put(XLineWidthItem(0));
+                            aLocalSet.Put(XLineStyleItem(XLINE_NONE));
+                            aLocalSet.Put(XFillColorItem(XubString(), ((const XLineColorItem&)(aLocalSet.Get(XATTR_LINECOLOR))).GetColorValue()));
+                            aLocalSet.Put(XFillStyleItem(XFILL_SOLID));
+                            aLocalSet.Put(XFillTransparenceItem(((const XLineTransparenceItem&)(aLocalSet.Get(XATTR_LINETRANSPARENCE))).GetValue()));
+                            aLocalFillStyle = XFILL_SOLID;
+                        }
+                        else
+                        {
+                            // correct item properties to hairlines
+                            aLocalSet.Put(XLineWidthItem(0));
+                            aLocalSet.Put(XLineStyleItem(XLINE_SOLID));
+                        }
+                    }
+
+                    SdrObject::Free(pNewObj);
+                }
+                else
+                {
+                    aPolyPoly = ((SdrPathObj*)pNext)->GetPathPoly();
                 }
             }
             else
@@ -394,13 +446,18 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
 
             if( aPolyPoly.count() )
             {
+                if(aPolyPoly.areControlPointsUsed())
+                {
+                    aPolyPoly = basegfx::tools::adaptiveSubdivideByAngle(aPolyPoly);
+                }
+
                 const basegfx::B2DRange aTempRange(basegfx::tools::getRange(aPolyPoly));
                 const Rectangle aBoundRect(basegfx::fround(aTempRange.getMinX()), basegfx::fround(aTempRange.getMinY()), basegfx::fround(aTempRange.getMaxX()), basegfx::fround(aTempRange.getMaxY()));
                 aBoundRect2d.Union( aBoundRect );
 
                 E3dCompoundObject* p3DObj = new E3dExtrudeObj( a3DDefaultAttr, aPolyPoly, bUseTwoFillStyles ? 10 : fDepth );
                 p3DObj->NbcSetLayer( pShape2d->GetLayer() );
-                p3DObj->SetMergedItemSet( aSet );
+                p3DObj->SetMergedItemSet( aLocalSet );
                 if ( bIsPlaceholderObject )
                     aPlaceholderObjectList.push_back( p3DObj );
                 else if ( bUseTwoFillStyles )
@@ -444,7 +501,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
                     pScene->Insert3DObj( p3DObj );
                     p3DObj = new E3dExtrudeObj( a3DDefaultAttr, aPolyPoly, fDepth );
                     p3DObj->NbcSetLayer( pShape2d->GetLayer() );
-                    p3DObj->SetMergedItemSet( aSet );
+                    p3DObj->SetMergedItemSet( aLocalSet );
                     if ( bUseExtrusionColor )
                         p3DObj->SetMergedItem( XFillColorItem( String(), ((XSecondaryFillColorItem&)pCustomShape->GetMergedItem( XATTR_SECONDARYFILLCOLOR )).GetColorValue() ) );
                     p3DObj->SetMergedItem( XFillStyleItem( XFILL_SOLID ) );
@@ -453,18 +510,18 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
                     pScene->Insert3DObj( p3DObj );
                     p3DObj = new E3dExtrudeObj( a3DDefaultAttr, aPolyPoly, 10 );
                     p3DObj->NbcSetLayer( pShape2d->GetLayer() );
-                    p3DObj->SetMergedItemSet( aSet );
+                    p3DObj->SetMergedItemSet( aLocalSet );
 
                     basegfx::B3DHomMatrix aFrontTransform( p3DObj->GetTransform() );
                     aFrontTransform.translate( 0.0, 0.0, fDepth );
                     p3DObj->NbcSetTransform( aFrontTransform );
 
-                    if ( ( eFillStyle == XFILL_BITMAP ) && !aFillBmp.IsEmpty() )
+                    if ( ( aLocalFillStyle == XFILL_BITMAP ) && !aFillBmp.IsEmpty() )
                     {
                         p3DObj->SetMergedItem(XFillBitmapItem(String(), Graphic(aFillBmp)));
                     }
                 }
-                else if ( eFillStyle == XFILL_NONE )
+                else if ( aLocalFillStyle == XFILL_NONE )
                 {
                     XLineColorItem& rLineColor = (XLineColorItem&)p3DObj->GetMergedItem( XATTR_LINECOLOR );
                     p3DObj->SetMergedItem( XFillColorItem( String(), rLineColor.GetColorValue() ) );
commit 8feb5a20b8d7c4c4484153215b2dd688a52cf50c
Author: Armin Le Grand <alg at apache.org>
Date:   Tue Aug 14 09:35:19 2012 +0000

    Resolves: #i119443# Import lines from ppt as one point connectors
    
    Patch by: Jianjuan Li
    Review by: alg
    
    (cherry picked from commit acd62709ad0d1d54764f00aabbd6c59ccb41a409)
    
    Change-Id: I1978444641d5f7c053dfae815096e7f2bacce15a

diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index dc726b1..b8b92db 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -4143,7 +4143,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
                 ApplyAttributes( rSt, aSet, aObjData );
                 pRet->SetMergedItemSet(aSet);
             }
-            else if ( aObjData.eShapeType == mso_sptLine )
+            else if ( aObjData.eShapeType == mso_sptLine && !( GetPropertyValue( DFF_Prop_fc3DLightFace ) & 8 ) )
             {
                 basegfx::B2DPolygon aPoly;
                 aPoly.append(basegfx::B2DPoint(aObjData.aBoundRect.Left(), aObjData.aBoundRect.Top()));
@@ -4561,6 +4561,11 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
                         ((SdrEdgeObj*)pRet)->SetEdgeTrackPath( aPoly );
                         pRet->SetMergedItemSet( aSet );
                     }
+                    if ( aObjData.eShapeType == mso_sptLine )
+                    {
+                        pRet->SetMergedItemSet(aSet);
+                        ((SdrObjCustomShape*)pRet)->MergeDefaultAttributes();
+                    }
                 }
             }
 
diff --git a/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx b/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx
index abdc77b..0c8e447 100644
--- a/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx
@@ -8271,6 +8271,7 @@ const mso_CustomShape* GetCustomShapeContent( MSO_SPT eSpType )
     switch( eSpType )
     {
         case mso_sptArc :                       pCustomShape = &msoArc; break;
+        case mso_sptLine:                       pCustomShape = &msoStraightConnector1; break;
         case mso_sptRectangle :                 pCustomShape = &msoRectangle; break;
         case mso_sptParallelogram :             pCustomShape = &msoParallelogram; break;
         case mso_sptTrapezoid :                 pCustomShape = &msoTrapezoid; break;
commit abb6f47bd3941ec63a41a9b9fa4c7de620b5177d
Author: Armin Le Grand <alg at apache.org>
Date:   Mon Aug 13 15:10:02 2012 +0000

    Secured some places where PolyPolygons were created
    
    using a all-points count and a all-points array
    
    (cherry picked from commit 8ee49906f04106317997e9ca3bb890870816e274)
    
    Conflicts:
    	svtools/source/filter/wmf/enhwmf.cxx
    	svtools/source/filter/wmf/winwmf.cxx
    	tools/inc/tools/poly.hxx
    	tools/source/generic/poly2.cxx
    
    Change-Id: I57f7f08d8dd87c83c30ab2d16ca22b772b2bd834

diff --git a/include/tools/poly.hxx b/include/tools/poly.hxx
index 980840f..4229195 100644
--- a/include/tools/poly.hxx
+++ b/include/tools/poly.hxx
@@ -206,8 +206,6 @@ private:
 public:
                         PolyPolygon( sal_uInt16 nInitSize = 16, sal_uInt16 nResize = 16 );
                         PolyPolygon( const Polygon& rPoly );
-                        PolyPolygon( sal_uInt16 nPoly, const sal_uInt16* pPointCountAry,
-                                     const Point* pPtAry );
                         PolyPolygon( const PolyPolygon& rPolyPoly );
                         ~PolyPolygon();
 
diff --git a/tools/source/generic/poly2.cxx b/tools/source/generic/poly2.cxx
index 869ac0a..535ff9a 100644
--- a/tools/source/generic/poly2.cxx
+++ b/tools/source/generic/poly2.cxx
@@ -99,23 +99,6 @@ PolyPolygon::PolyPolygon( const Polygon& rPoly )
         mpImplPolyPolygon = new ImplPolyPolygon( 16, 16 );
 }
 
-PolyPolygon::PolyPolygon( sal_uInt16 nPoly, const sal_uInt16* pPointCountAry,
-                          const Point* pPtAry )
-{
-    DBG_CTOR( PolyPolygon, NULL );
-
-    if ( nPoly > MAX_POLYGONS )
-        nPoly = MAX_POLYGONS;
-
-    mpImplPolyPolygon = new ImplPolyPolygon( nPoly );
-    for ( sal_uInt16 i = 0; i < nPoly; i++ )
-    {
-        mpImplPolyPolygon->mpPolyAry[i] = new Polygon( *pPointCountAry, pPtAry );
-        pPtAry += *pPointCountAry;
-        pPointCountAry++;
-    }
-}
-
 PolyPolygon::PolyPolygon( const PolyPolygon& rPolyPoly )
 {
     DBG_CTOR( PolyPolygon, NULL );
diff --git a/vcl/source/filter/wmf/enhwmf.cxx b/vcl/source/filter/wmf/enhwmf.cxx
index 560fc9e..9fd8a9f 100644
--- a/vcl/source/filter/wmf/enhwmf.cxx
+++ b/vcl/source/filter/wmf/enhwmf.cxx
@@ -399,7 +399,7 @@ void EnhWMFReader::ReadAndDrawPolyLine()
 template <class T>
 void EnhWMFReader::ReadAndDrawPolyPolygon()
 {
-    sal_uInt32  i, nPoly, nGesPoints, nPoints;
+    sal_uInt32 nPoly(0), nGesPoints(0), nReadPoints(0);
     pWMF->SeekRel( 0x10 );
     // Number of polygons
     *pWMF >> nPoly >> nGesPoints;
@@ -410,27 +410,38 @@ void EnhWMFReader::ReadAndDrawPolyPolygon()
     {
         // Get number of points in each polygon
         sal_uInt16 * pnPoints = new sal_uInt16[ nPoly ];
-        for ( i = 0; i < nPoly && pWMF->good(); i++ )
+        for (sal_uInt32 i = 0; i < nPoly && pWMF->good(); ++i)
         {
+            sal_uInt32 nPoints(0);
             *pWMF >> nPoints;
             pnPoints[ i ] = (sal_uInt16)nPoints;
         }
         if ( pWMF->good() && ( nGesPoints * (sizeof(T)+sizeof(T)) ) <= ( nEndPos - pWMF->Tell() ) )
         {
             // Get polygon points
-            Point * pPtAry  = new Point[ nGesPoints ];
-            for ( i = 0; i < nGesPoints && pWMF->good(); i++ )
+            PolyPolygon aPolyPoly(nPoly, nPoly);
+            for (sal_uInt32 i = 0; i < nPoly && pWMF->good(); ++i)
             {
-                T nX, nY;
-                *pWMF >> nX >> nY;
-                pPtAry[ i ] = Point( nX, nY );
+                const sal_uInt16 nPointCount(pnPoints[i]);
+                Point* pPtAry = new Point[nPointCount];
+                for (sal_uInt16 j = 0; j < nPointCount && pWMF->good(); ++j)
+                {
+                    T nX(0), nY(0);
+                    *pWMF >> nX >> nY;
+                    pPtAry[ i ] = Point( nX, nY );
+                    ++nReadPoints;
+                }
+
+                aPolyPoly.Insert(Polygon(nPointCount, pPtAry));
+                delete[] pPtAry;
             }
-            // Create PolyPolygon Actions
-            PolyPolygon aPolyPoly( (sal_uInt16)nPoly, pnPoints, pPtAry );
+
             pOut->DrawPolyPolygon( aPolyPoly, bRecordPath );
-            delete[] pPtAry;
         }
         delete[] pnPoints;
+
+        OSL_ENSURE(nReadPoints == nGesPoints, "The number Points processed from EMR_POLYPOLYGON is unequal imported number (!)");
+
     }
 }
 
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index f16f1d8..84b1a78 100644
--- a/vcl/source/filter/wmf/winwmf.cxx
+++ b/vcl/source/filter/wmf/winwmf.cxx
@@ -348,54 +348,64 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
         case W_META_POLYPOLYGON:
         {
             bool bRecordOk = true;
-            sal_uInt16  nPoly = 0;
-            Point*  pPtAry;
+            sal_uInt16 nPolyCount(0);
             // Number of polygons:
-            *pWMF >> nPoly;
-            // Number of points of each polygon. Determine total number of points
-            boost::scoped_array<sal_uInt16> xPolygonPointCounts(new sal_uInt16[nPoly]);
-            sal_uInt16* pnPoints = xPolygonPointCounts.get();
-            sal_uInt16 nPoints = 0;
-            for(sal_uInt16 i = 0; i < nPoly; i++ )
+            *pWMF >> nPolyCount;
+            if (nPolyCount && pWMF->good())
             {
-                *pWMF >> pnPoints[i];
+                // Number of points of each polygon. Determine total number of points
+                boost::scoped_array<sal_uInt16> xPolygonPointCounts(new sal_uInt16[nPolyCount]);
+                sal_uInt16* pnPoints = xPolygonPointCounts.get();
+                PolyPolygon aPolyPoly(nPolyCount, nPolyCount);
+                sal_uInt16 nPoints = 0;
+                for (sal_uInt16 a = 0; a < nPolyCount && pWMF->good(); ++a)
+                {
+                    *pWMF >> pnPoints[a];
+
+                    if (pnPoints[a] > SAL_MAX_UINT16 - nPoints)
+                    {
+                        bRecordOk = false;
+                        break;
+                    }
+
+                    nPoints += pnPoints[a];
+                }
 
-                if (pnPoints[i] > SAL_MAX_UINT16 - nPoints)
+                SAL_WARN_IF(!bRecordOk, "svtools.filter", "polypolygon record has more polygons than we can handle");
+
+                bRecordOk &= pWMF->good();
+
+                if (!bRecordOk)
                 {
-                    bRecordOk = false;
+                    pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR );
                     break;
                 }
 
-                nPoints += pnPoints[i];
-            }
-
-            SAL_WARN_IF(!bRecordOk, "svtools.filter", "polypolygon record has more polygons than we can handle");
+                // Polygon points are:
+                for (sal_uInt16 a = 0; a < nPolyCount && pWMF->good(); ++a)
+                {
+                    const sal_uInt16 nPointCount(pnPoints[a]);
+                    boost::scoped_array<Point> xPolygonPoints(new Point[nPointCount]);
+                    Point* pPtAry = xPolygonPoints.get();
 
-            bRecordOk &= pWMF->good();
+                    for(sal_uInt16 b(0); b < nPointCount && pWMF->good(); ++b)
+                    {
+                        pPtAry[b] = ReadPoint();
+                    }
 
-            if (!bRecordOk)
-            {
-                pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR );
-                break;
-            }
+                    aPolyPoly.Insert(Polygon(nPointCount, pPtAry));
+                }
 
-            // Polygon points are:
-            boost::scoped_array<Point> xPolygonPoints(new Point[nPoints]);
-            pPtAry = xPolygonPoints.get();
-            for (sal_uInt16 i = 0; i < nPoints; i++ )
-                pPtAry[ i ] = ReadPoint();
+                bRecordOk &= pWMF->good();
 
-            bRecordOk &= pWMF->good();
+                if (!bRecordOk)
+                {
+                    pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR );
+                    break;
+                }
 
-            if (!bRecordOk)
-            {
-                pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR );
-                break;
+                pOut->DrawPolyPolygon( aPolyPoly );
             }
-
-            // Produce PolyPolygon Actions
-            PolyPolygon aPolyPoly( nPoly, pnPoints, pPtAry );
-            pOut->DrawPolyPolygon( aPolyPoly );
         }
         break;
 


More information about the Libreoffice-commits mailing list