summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2012-08-15 17:50:26 +0100
committerNoel Power <noel.power@suse.com>2012-08-15 17:54:48 +0100
commit6c70bd9e2748b375b53eea4454a5b4f922c439ae (patch)
tree39f320af489446c9c58e56cecff6add0afb4a084 /sc
parente25d4e7d2b7b65535d3ea3707ad8a9d5ec7ed371 (diff)
followup patch for commit:541986fef0993d749cc7ed790eacace322f43bb0 fdo#53229
discovered 2 bugs with the previous patch, 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: I2edc0cccca439b3103b61c8116d1cde1536519da
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/xml/XMLTableShapeImportHelper.cxx27
1 files changed, 22 insertions, 5 deletions
diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
index 5bc2553fd969..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,22 +203,28 @@ void XMLTableShapeImportHelper::finishShape(
}
else //this are grouped shapes which should also get the layerid
{
- if ( !bOnTable )
+ 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 left positioned shape within
+ // 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() );
- if (SvxShape* pGroupShapeImp = SvxShape::getImplementation(rShapes))
+ 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 )
- || ( aStartPoint.IsAbove( pAnchor->maStartOffset ) && aStartPoint.IsLeft( pAnchor->maStartOffset ) ) )
+ 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() );
}
}
}