summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2012-08-15 13:03:04 +0100
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-08-16 11:39:46 -0400
commite7f9b7642c7a2f7723871e72de9f8ed6b3a07e26 (patch)
treec87522af23a4fe0099b3aa987a824eafc2224354
parent38d18fcd644fafeb0234a1804563853a17b47c4f (diff)
fix for fdo#53229, import group shapes position and size correctly
a) need to properly calculate the topleftmost position for the combined shapes in the group. b) when you have groups within groups then the offsets need to be applied to the topmost parent. Change-Id: Ie1967f3625030fcd0201f2ab43a0740153cd4bd7 Signed-off-by: Kohei Yoshida <kohei.yoshida@gmail.com>
-rw-r--r--sc/source/filter/xml/XMLTableShapeImportHelper.cxx37
1 files changed, 37 insertions, 0 deletions
diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
index e2b121672ec5..2dafec570cf3 100644
--- a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
+++ b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
@@ -76,6 +76,17 @@ void XMLTableShapeImportHelper::SetLayer(uno::Reference<drawing::XShape>& rShape
}
}
+// Attempt to find the topmost parent of the group, this is the one we apply
+// offsets to
+uno::Reference< drawing::XShape > lcl_getTopLevelParent( const uno::Reference< drawing::XShape >& rShape )
+{
+ uno::Reference< container::XChild > xChild( rShape, uno::UNO_QUERY );
+ uno::Reference< drawing::XShape > xParent( xChild->getParent(), uno::UNO_QUERY );
+ if ( xParent.is() )
+ return lcl_getTopLevelParent( xParent );
+ return rShape;
+}
+
void XMLTableShapeImportHelper::finishShape(
uno::Reference< drawing::XShape >& rShape,
const uno::Reference< xml::sax::XAttributeList >& xAttrList,
@@ -192,6 +203,32 @@ void XMLTableShapeImportHelper::finishShape(
}
else //this are grouped shapes which should also get the layerid
{
+ uno::Reference< drawing::XShapes > xGroup( rShape, uno::UNO_QUERY );
+ // ignore the group ( within group ) object it it exists
+ if ( !bOnTable && !xGroup.is() )
+ {
+ // For cell anchored grouped shape we need to set the start
+ // position from the most top and left positioned shape(s) within
+ // the group
+ Point aStartPoint( rShape->getPosition().X,rShape->getPosition().Y );
+ awt::Size aSize(rShape->getSize() );
+ uno::Reference< drawing::XShape > xChild( rShapes, uno::UNO_QUERY );
+ if (SvxShape* pGroupShapeImp = SvxShape::getImplementation( lcl_getTopLevelParent( xChild ) ))
+ {
+ if (SdrObject *pSdrObj = pGroupShapeImp->GetSdrObject())
+ {
+ if ( ScDrawObjData* pAnchor = ScDrawLayer::GetObjData( pSdrObj ) )
+ {
+ if ( pAnchor->maStartOffset.getX() == 0 && pAnchor->maStartOffset.getY() == 0 )
+ pAnchor->maStartOffset = aStartPoint;
+ if ( aStartPoint.getX() < pAnchor->maStartOffset.getX() )
+ pAnchor->maStartOffset.setX( aStartPoint.getX() );
+ if ( aStartPoint.getY() < pAnchor->maStartOffset.getY() )
+ pAnchor->maStartOffset.setY( aStartPoint.getY() );
+ }
+ }
+ }
+ }
sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
sal_Int16 nLayerID(-1);
for( sal_Int16 i=0; i < nAttrCount; ++i )