summaryrefslogtreecommitdiff
path: root/patches/dev300/oox-pptx-import-fix-groups-2.diff
blob: 2021decea6e170df3ab84f6ee678cde07c084c48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
diff -rup ../ooo330-m2-orig/oox/inc/oox/drawingml/shape.hxx oox/inc/oox/drawingml/shape.hxx
--- ../ooo330-m2-orig/oox/inc/oox/drawingml/shape.hxx	2010-08-24 20:25:50.000000000 +0200
+++ oox/inc/oox/drawingml/shape.hxx	2010-08-24 12:41:18.000000000 +0200
@@ -203,6 +203,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 -rup ../ooo330-m2-orig/oox/source/drawingml/shape.cxx oox/source/drawingml/shape.cxx
--- ../ooo330-m2-orig/oox/source/drawingml/shape.cxx	2010-08-24 20:25:50.000000000 +0200
+++ oox/source/drawingml/shape.cxx	2010-08-25 10:52:08.000000000 +0200
@@ -88,7 +88,8 @@ void CreateShapeCallback::onXShapeCreate
 // ============================================================================
 
 Shape::Shape( const sal_Char* pServiceName )
-: mpLinePropertiesPtr( new LineProperties )
+: mbIsChild( false )
+, mpLinePropertiesPtr( new LineProperties )
 , mpFillPropertiesPtr( new FillProperties )
 , mpGraphicPropertiesPtr( new GraphicProperties )
 , mpCustomShapePropertiesPtr( new CustomShapeProperties )
@@ -107,6 +108,7 @@ Shape::Shape( const sal_Char* pServiceNa
 
 Shape::Shape( const ShapePtr& pSourceShape )
 : maChildren()
+, mbIsChild( pSourceShape->mbIsChild )
 , mpTextBody(pSourceShape->mpTextBody)
 , mpLinePropertiesPtr( pSourceShape->mpLinePropertiesPtr )
 , mpFillPropertiesPtr( pSourceShape->mpFillPropertiesPtr )
@@ -237,45 +239,34 @@ void Shape::addChildren(
         Shape& rMaster,
         const ThemePtr& rxTheme,
         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, rxTheme, rxShapes, pShapeRect, pShapeMap );
     }
 }