diff options
author | Radek Doulik <rodo@novell.com> | 2010-10-08 14:49:01 +0200 |
---|---|---|
committer | Radek Doulik <rodo@novell.com> | 2010-10-08 14:49:01 +0200 |
commit | 35c33de8728f8d8d7301f7b0619c4575dca9326d (patch) | |
tree | 9bb0c02525631d372d41a3e8c82269136e055ebd /oox | |
parent | 0cbc98860cb1740ed787887cc4245db963285600 (diff) |
oox-pptx-import-fix-groups-2: fix group shapes (final part).
n#619678
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/oox/drawingml/shape.hxx | 3 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 52 |
2 files changed, 24 insertions, 31 deletions
diff --git a/oox/inc/oox/drawingml/shape.hxx b/oox/inc/oox/drawingml/shape.hxx index fdbda167e69a..530055373bbd 100644 --- a/oox/inc/oox/drawingml/shape.hxx +++ b/oox/inc/oox/drawingml/shape.hxx @@ -187,6 +187,9 @@ protected: std::vector< ShapePtr > maChildren; // only used for group shapes com::sun::star::awt::Size maChSize; // only used for group shapes com::sun::star::awt::Point maChPosition; // only used for group shapes + com::sun::star::awt::Size maAbsoluteSize; // only used for group shapes + com::sun::star::awt::Point maAbsolutePosition; // only used for group shapes + sal_Bool mbIsChild; TextBodyPtr mpTextBody; LinePropertiesPtr mpLinePropertiesPtr; diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 2cc18319dc8d..05df9e519f97 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -85,7 +85,8 @@ void CreateShapeCallback::onXShapeCreated( const Reference< XShape >&, const Ref // ============================================================================ Shape::Shape( const sal_Char* pServiceName ) -: mpLinePropertiesPtr( new LineProperties ) +: mbIsChild( false ) +, mpLinePropertiesPtr( new LineProperties ) , mpFillPropertiesPtr( new FillProperties ) , mpGraphicPropertiesPtr( new GraphicProperties ) , mpCustomShapePropertiesPtr( new CustomShapeProperties ) @@ -193,45 +194,34 @@ void Shape::addChildren( Shape& rMaster, const Theme* pTheme, const Reference< XShapes >& rxShapes, - const awt::Rectangle& rClientRect, + const awt::Rectangle&, ShapeIdMap* pShapeMap ) { - // first the global child union needs to be calculated - sal_Int32 nGlobalLeft = SAL_MAX_INT32; - sal_Int32 nGlobalRight = SAL_MIN_INT32; - sal_Int32 nGlobalTop = SAL_MAX_INT32; - sal_Int32 nGlobalBottom= SAL_MIN_INT32; + awt::Point& aPosition( mbIsChild ? maAbsolutePosition : maPosition ); + awt::Size& aSize( mbIsChild ? maAbsoluteSize : maSize ); + std::vector< ShapePtr >::iterator aIter( rMaster.maChildren.begin() ); while( aIter != rMaster.maChildren.end() ) { - sal_Int32 l = (*aIter)->maPosition.X; - sal_Int32 t = (*aIter)->maPosition.Y; - sal_Int32 r = l + (*aIter)->maSize.Width; - sal_Int32 b = t + (*aIter)->maSize.Height; - if ( nGlobalLeft > l ) - nGlobalLeft = l; - if ( nGlobalRight < r ) - nGlobalRight = r; - if ( nGlobalTop > t ) - nGlobalTop = t; - if ( nGlobalBottom < b ) - nGlobalBottom = b; - aIter++; - } - aIter = rMaster.maChildren.begin(); - while( aIter != rMaster.maChildren.end() ) - { awt::Rectangle aShapeRect; awt::Rectangle* pShapeRect = 0; Shape& rChild = *(*aIter); - if ( rChild.maSize.Width != maSize.Width || rChild.maSize.Height != maSize.Height || rChild.maPosition.X != maPosition.X || rChild.maPosition.Y != maPosition.Y ) { - aShapeRect.X = maPosition.X + rChild.maPosition.X - maChPosition.X; - aShapeRect.Y = maPosition.Y + rChild.maPosition.Y - maChPosition.Y; - aShapeRect.Width = maSize.Width + rChild.maSize.Width - maChSize.Width; - aShapeRect.Height = maSize.Height + rChild.maSize.Height - maChSize.Height; - pShapeRect = &aShapeRect; - } + double sx = ((double)aSize.Width)/maChSize.Width; + double sy = ((double)aSize.Height)/maChSize.Height; + 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; + rChild.maAbsoluteSize.Height = rChild.maSize.Height*sy; + rChild.mbIsChild = true; + + aShapeRect.X = rChild.maAbsolutePosition.X; + aShapeRect.Y = rChild.maAbsolutePosition.Y; + aShapeRect.Width = rChild.maAbsoluteSize.Width; + aShapeRect.Height = rChild.maAbsoluteSize.Height; + + pShapeRect = &aShapeRect; + (*aIter++)->addShape( rFilterBase, pTheme, rxShapes, pShapeRect, pShapeMap ); } } |