[Libreoffice-commits] .: oox/inc oox/source

Radek Doulík rodo at kemper.freedesktop.org
Wed Apr 27 10:01:01 PDT 2011


 oox/inc/oox/drawingml/shape.hxx                     |    8 ++-
 oox/inc/oox/ppt/pptshape.hxx                        |    1 
 oox/source/drawingml/chart/chartdrawingfragment.cxx |    6 +-
 oox/source/drawingml/shape.cxx                      |   43 +++++++++++++++-----
 oox/source/ppt/pptshape.cxx                         |    5 +-
 oox/source/ppt/slidepersist.cxx                     |    5 +-
 oox/source/shape/ShapeContextHandler.cxx            |    3 -
 oox/source/xls/drawingfragment.cxx                  |    3 -
 8 files changed, 55 insertions(+), 19 deletions(-)

New commits:
commit e6501aa5b2f84616172ebbfbff9971b037c769df
Author: Radek Doulik <rodo at novell.com>
Date:   Wed Apr 27 18:59:10 2011 +0200

    fix group shape transformations - part of n#621739

diff --git a/oox/inc/oox/drawingml/shape.hxx b/oox/inc/oox/drawingml/shape.hxx
index d5b102a..f0adce0 100644
--- a/oox/inc/oox/drawingml/shape.hxx
+++ b/oox/inc/oox/drawingml/shape.hxx
@@ -38,6 +38,7 @@
 #include <com/sun/star/drawing/XDrawPage.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/enable_shared_from_this.hpp>
+#include <basegfx/matrix/b2dhommatrix.hxx>
 #include <vector>
 #include <map>
 
@@ -142,6 +143,7 @@ public:
                             ::oox::core::XmlFilterBase& rFilterBase,
                             const Theme* pTheme,
                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
+                            basegfx::B2DHomMatrix& aTransformation,
                             const ::com::sun::star::awt::Rectangle* pShapeRect = 0,
                             ShapeIdMap* pShapeMap = 0 );
 
@@ -161,7 +163,8 @@ protected:
                             const Theme* pTheme,
                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
                             const ::com::sun::star::awt::Rectangle* pShapeRect,
-                            sal_Bool bClearText );
+                            sal_Bool bClearText,
+                            basegfx::B2DHomMatrix& aTransformation );
 
     void                addChildren(
                             ::oox::core::XmlFilterBase& rFilterBase,
@@ -169,7 +172,8 @@ protected:
                             const Theme* pTheme,
                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
                             const ::com::sun::star::awt::Rectangle& rClientRect,
-                            ShapeIdMap* pShapeMap );
+                            ShapeIdMap* pShapeMap,
+                            basegfx::B2DHomMatrix& aTransformation );
 
     virtual ::rtl::OUString finalizeServiceName(
                             ::oox::core::XmlFilterBase& rFilter,
diff --git a/oox/inc/oox/ppt/pptshape.hxx b/oox/inc/oox/ppt/pptshape.hxx
index 79bfdb1..c552d0a 100644
--- a/oox/inc/oox/ppt/pptshape.hxx
+++ b/oox/inc/oox/ppt/pptshape.hxx
@@ -53,6 +53,7 @@ public:
             const SlidePersist& rPersist,
             const oox::drawingml::Theme* pTheme,
             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
+            basegfx::B2DHomMatrix& aTransformation,
             const com::sun::star::awt::Rectangle* pShapeRect = 0,
             ::oox::drawingml::ShapeIdMap* pShapeMap = 0 );
 
diff --git a/oox/source/drawingml/chart/chartdrawingfragment.cxx b/oox/source/drawingml/chart/chartdrawingfragment.cxx
index 6c9c2e7..912f641 100644
--- a/oox/source/drawingml/chart/chartdrawingfragment.cxx
+++ b/oox/source/drawingml/chart/chartdrawingfragment.cxx
@@ -218,8 +218,10 @@ void ChartDrawingFragment::onEndElement()
         if( mxDrawPage.is() && mxShape.get() && mxAnchor.get() )
         {
             Rectangle aLoc = mxAnchor->calcEmuLocation( maEmuChartRect );
-            if( (aLoc.X >= 0) && (aLoc.Y >= 0) && (aLoc.Width >= 0) && (aLoc.Height >= 0) )
-                mxShape->addShape( getFilter(), getFilter().getCurrentTheme(), mxDrawPage, &aLoc );
+            if( (aLoc.X >= 0) && (aLoc.Y >= 0) && (aLoc.Width >= 0) && (aLoc.Height >= 0) ) {
+                basegfx::B2DHomMatrix aMatrix;
+                mxShape->addShape( getFilter(), getFilter().getCurrentTheme(), mxDrawPage, aMatrix, &aLoc );
+            }
         }
         mxShape.reset();
         mxAnchor.reset();
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 601cb36..2855ff3 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -167,6 +167,7 @@ void Shape::addShape(
         ::oox::core::XmlFilterBase& rFilterBase,
         const Theme* pTheme,
         const Reference< XShapes >& rxShapes,
+        basegfx::B2DHomMatrix& aTransformation,
         const awt::Rectangle* pShapeRect,
         ShapeIdMap* pShapeMap )
 {
@@ -175,7 +176,8 @@ void Shape::addShape(
         rtl::OUString sServiceName( msServiceName );
         if( sServiceName.getLength() )
         {
-            Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, sal_False ) );
+            basegfx::B2DHomMatrix aMatrix( aTransformation );
+            Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, sal_False, aMatrix ) );
 
             if( pShapeMap && msId.getLength() )
             {
@@ -185,7 +187,7 @@ void Shape::addShape(
             // if this is a group shape, we have to add also each child shape
             Reference< XShapes > xShapes( xShape, UNO_QUERY );
             if ( xShapes.is() )
-                addChildren( rFilterBase, *this, pTheme, xShapes, pShapeRect ? *pShapeRect : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ), pShapeMap );
+                addChildren( rFilterBase, *this, pTheme, xShapes, pShapeRect ? *pShapeRect : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ), pShapeMap, aMatrix );
         }
         Reference< document::XActionLockable > xLockable( mxShape, UNO_QUERY );
         if( xLockable.is() )
@@ -224,10 +226,12 @@ void Shape::addChildren(
         const Theme* pTheme,
         const Reference< XShapes >& rxShapes,
         const awt::Rectangle&,
-        ShapeIdMap* pShapeMap )
+        ShapeIdMap* pShapeMap,
+        basegfx::B2DHomMatrix& aTransformation )
 {
     awt::Point& aPosition( mbIsChild ? maAbsolutePosition : maPosition );
     awt::Size& aSize( mbIsChild ? maAbsoluteSize : maSize );
+    basegfx::B2DHomMatrix aChildTransformation;
 
     std::vector< ShapePtr >::iterator aIter( rMaster.maChildren.begin() );
     while( aIter != rMaster.maChildren.end() )
@@ -236,8 +240,8 @@ void Shape::addChildren(
         awt::Rectangle* pShapeRect = 0;
         Shape& rChild = *(*aIter);
 
-        double sx = ((double)aSize.Width)/maChSize.Width;
-        double sy = ((double)aSize.Height)/maChSize.Height;
+        double sx = (maChSize.Width) ?  ((double)aSize.Width)/maChSize.Width : 1.0;
+        double sy = (maChSize.Height) ?  ((double)aSize.Height)/maChSize.Height : 1.0;
         rChild.maAbsolutePosition.X = aPosition.X + sx*(rChild.maPosition.X - maChPosition.X);
         rChild.maAbsolutePosition.Y = aPosition.Y + sy*(rChild.maPosition.Y - maChPosition.Y);
         rChild.maAbsoluteSize.Width = rChild.maSize.Width*sx;
@@ -249,9 +253,14 @@ void Shape::addChildren(
         aShapeRect.Width = rChild.maAbsoluteSize.Width;
         aShapeRect.Height = rChild.maAbsoluteSize.Height;
 
-        pShapeRect = &aShapeRect;
+        //pShapeRect = &aShapeRect;
+
+        aChildTransformation = aTransformation;
 
-        (*aIter++)->addShape( rFilterBase, pTheme, rxShapes, pShapeRect, pShapeMap );
+        aChildTransformation.translate((-maChPosition.X)/360.0, (-maChPosition.Y)/360.0);
+        aChildTransformation.scale((360.0*sx)/(maSize.Width ? maSize.Width : 1.0), (360.0*sy)/(maSize.Height ? maSize.Height : 1.0));
+
+        (*aIter++)->addShape( rFilterBase, pTheme, rxShapes, aChildTransformation, pShapeRect, pShapeMap );
     }
 }
 
@@ -261,7 +270,8 @@ Reference< XShape > Shape::createAndInsert(
         const Theme* pTheme,
         const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
         const awt::Rectangle* pShapeRect,
-        sal_Bool bClearText )
+        sal_Bool bClearText,
+        basegfx::B2DHomMatrix& aParentTransformation )
 {
     awt::Size aSize( pShapeRect ? awt::Size( pShapeRect->Width, pShapeRect->Height ) : maSize );
     awt::Point aPosition( pShapeRect ? awt::Point( pShapeRect->X, pShapeRect->Y ) : maPosition );
@@ -270,7 +280,7 @@ Reference< XShape > Shape::createAndInsert(
     OUString aServiceName = finalizeServiceName( rFilterBase, rServiceName, aShapeRectHmm );
     sal_Bool bIsCustomShape = aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.CustomShape" ) );
 
-    basegfx::B2DHomMatrix aTransformation;
+    basegfx::B2DHomMatrix aTransformation( aParentTransformation );
     if( aSize.Width != 1 || aSize.Height != 1)
     {
         // take care there are no zeros used by error
@@ -310,6 +320,17 @@ Reference< XShape > Shape::createAndInsert(
         aTransformation.translate( aPosition.X / 360.0, aPosition.Y / 360.0 );
     }
 
+    OSL_TRACE("transformation:\n%f %f %f\n%f %f %f\n%f %f %f\n",
+              aTransformation.get(0,0),
+              aTransformation.get(0,1),
+              aTransformation.get(0,2),
+              aTransformation.get(1,0),
+              aTransformation.get(1,1),
+              aTransformation.get(1,2),
+              aTransformation.get(2,0),
+              aTransformation.get(2,1),
+              aTransformation.get(2,2));
+
     // special for lineshape
     if ( aServiceName == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.LineShape")) )
     {
@@ -352,6 +373,7 @@ Reference< XShape > Shape::createAndInsert(
         // now set transformation for this object
         HomogenMatrix3 aMatrix;
 
+
         aMatrix.Line1.Column1 = aTransformation.get(0,0);
         aMatrix.Line1.Column2 = aTransformation.get(0,1);
         aMatrix.Line1.Column3 = aTransformation.get(0,2);
@@ -366,6 +388,9 @@ Reference< XShape > Shape::createAndInsert(
 
         maShapeProperties[ PROP_Transformation ] <<= aMatrix;
     }
+
+    aParentTransformation = aTransformation;
+
     Reference< lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW );
     if ( !mxShape.is() )
         mxShape = Reference< drawing::XShape >( xServiceFact->createInstance( aServiceName ), UNO_QUERY_THROW );
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index 5ed5ccb..bf2d101 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -122,6 +122,7 @@ void PPTShape::addShape(
         const SlidePersist& rSlidePersist,
         const oox::drawingml::Theme* pTheme,
         const Reference< XShapes >& rxShapes,
+        basegfx::B2DHomMatrix& aTransformation,
         const awt::Rectangle* pShapeRect,
         ::oox::drawingml::ShapeIdMap* pShapeMap )
 {
@@ -292,7 +293,7 @@ void PPTShape::addShape(
             } else
                 setMasterTextListStyle( aMasterTextListStyle );
  
-                Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, bClearText ) );
+            Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, bClearText, aTransformation ) );
                 if ( !rSlidePersist.isMasterPage() && rSlidePersist.getPage().is() && ( (sal_Int32)mnSubType == XML_title ) )
                  {
                     try
@@ -319,7 +320,7 @@ void PPTShape::addShape(
                 // if this is a group shape, we have to add also each child shape
                 Reference< XShapes > xShapes( xShape, UNO_QUERY );
                 if ( xShapes.is() )
-                    addChildren( rFilterBase, *this, pTheme, xShapes, pShapeRect ? *pShapeRect : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ), pShapeMap );
+                    addChildren( rFilterBase, *this, pTheme, xShapes, pShapeRect ? *pShapeRect : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ), pShapeMap, aTransformation );
             }
         }
     }
diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index 15615d2..c436e89 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -150,10 +150,11 @@ void SlidePersist::createXShapes( XmlFilterBase& rFilterBase )
         while( aChildIter != rChildren.end() )
         {
             PPTShape* pPPTShape = dynamic_cast< PPTShape* >( (*aChildIter).get() );
+            basegfx::B2DHomMatrix aTransformation;
             if ( pPPTShape )
-                pPPTShape->addShape( rFilterBase, *this, getTheme().get(), xShapes, 0, &getShapeMap() );
+                pPPTShape->addShape( rFilterBase, *this, getTheme().get(), xShapes, aTransformation, 0, &getShapeMap() );
             else
-                (*aChildIter)->addShape( rFilterBase, getTheme().get(), xShapes, 0, &getShapeMap() );
+                (*aChildIter)->addShape( rFilterBase, getTheme().get(), xShapes, aTransformation, 0, &getShapeMap() );
             aChildIter++;
         }
     }
diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index 9737c45..2715aa7 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -252,7 +252,8 @@ ShapeContextHandler::getShape() throw (uno::RuntimeException)
         }
         else if (mpShape.get() != NULL)
         {
-            mpShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes);
+            basegfx::B2DHomMatrix aTransformation;
+            mpShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aTransformation);
             xResult.set(mpShape->getXShape());
             mxGraphicShapeContext.clear( );
         }
diff --git a/oox/source/xls/drawingfragment.cxx b/oox/source/xls/drawingfragment.cxx
index 3c3d856..290d203 100644
--- a/oox/source/xls/drawingfragment.cxx
+++ b/oox/source/xls/drawingfragment.cxx
@@ -603,7 +603,8 @@ void DrawingFragment::onEndElement()
                 Rectangle aShapeRect = mxAnchor->calcEmuLocation( maEmuSheetSize );
                 if( (aShapeRect.X >= 0) && (aShapeRect.Y >= 0) && (aShapeRect.Width >= 0) && (aShapeRect.Height >= 0) )
                 {
-                    mxShape->addShape( getOoxFilter(), &getTheme(), mxDrawPage, &aShapeRect );
+                    basegfx::B2DHomMatrix aTransformation;
+                    mxShape->addShape( getOoxFilter(), &getTheme(), mxDrawPage, aTransformation, &aShapeRect );
                     /*  Collect all shape positions in the WorksheetHelper base
                         class. But first, scale EMUs to 1/100 mm. */
                     const UnitConverter& rUnitConv = getUnitConverter();


More information about the Libreoffice-commits mailing list