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:35:39 -0400
commit0484239b2704235fef611820af6780364120fbe4 (patch)
treecfec7b6d24ba0de31d31749d24a6cd350e6ea43a
parent16be10d016c8ecb2e5df21466510bc0e9e2e3a27 (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 1b58d21bd153..638d29f985cc 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 )