[Libreoffice-commits] .: Branch 'libreoffice-3-6' - sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Thu Aug 16 08:35:28 PDT 2012


 sc/source/filter/xml/XMLTableShapeImportHelper.cxx |   37 +++++++++++++++++++++
 1 file changed, 37 insertions(+)

New commits:
commit 0484239b2704235fef611820af6780364120fbe4
Author: Noel Power <noel.power at suse.com>
Date:   Wed Aug 15 13:03:04 2012 +0100

    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 at gmail.com>

diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
index 1b58d21..638d29f 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 )


More information about the Libreoffice-commits mailing list