update ooo310-m15
[ooovba.git] / applied_patches / 0473-oox-custom-shape-polygons.diff
bloba07c7c7428b7451d198b10d0f1e3609ad4c24b04
1 diff --git oox/inc/oox/drawingml/customshapegeometry.hxx oox/inc/oox/drawingml/customshapegeometry.hxx
2 index af1e6fe..fc86081 100644
3 --- oox/inc/oox/drawingml/customshapegeometry.hxx
4 +++ oox/inc/oox/drawingml/customshapegeometry.hxx
5 @@ -44,11 +44,11 @@ namespace oox { namespace drawingml {
6 class CustomShapeGeometryContext : public ::oox::core::ContextHandler
8 public:
9 - CustomShapeGeometryContext( ::oox::core::ContextHandler& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, CustomShapeProperties& rCustomShapeProperties );
10 + CustomShapeGeometryContext( ::oox::core::ContextHandler& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, Shape& rShape );
11 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
13 private:
14 - CustomShapeProperties& mrCustomShapeProperties;
15 + Shape& mrShape;
18 // ---------------------------------------------------------------------
19 diff --git oox/inc/oox/drawingml/customshapeproperties.hxx oox/inc/oox/drawingml/customshapeproperties.hxx
20 index 2fe36f2..53554d7 100644
21 --- oox/inc/oox/drawingml/customshapeproperties.hxx
22 +++ oox/inc/oox/drawingml/customshapeproperties.hxx
23 @@ -35,6 +35,7 @@
24 #include "oox/drawingml/color.hxx"
25 #include <com/sun/star/graphic/XGraphic.hpp>
26 #include <boost/shared_ptr.hpp>
27 +#include <basegfx/polygon/b2dpolypolygon.hxx>
28 #include "tokens.hxx"
29 #include <vector>
30 #include <map>
31 @@ -80,11 +81,12 @@ public:
32 std::vector< CustomShapeGuide >& getAdjustmentValues(){ return maAdjustmentValues; };
34 double getValue( const std::vector< CustomShapeGuide >&, sal_uInt32 nIndex ) const;
36 + ::basegfx::B2DPolyPolygon& getPolygon() { return maPolygon; }
37 private:
39 rtl::OUString maShapePresetType;
40 std::vector< CustomShapeGuide > maAdjustmentValues;
41 + ::basegfx::B2DPolyPolygon maPolygon;
44 } }
45 diff --git oox/inc/oox/drawingml/shape.hxx oox/inc/oox/drawingml/shape.hxx
46 index 5a7e7e5..547f72e 100644
47 --- oox/inc/oox/drawingml/shape.hxx
48 +++ oox/inc/oox/drawingml/shape.hxx
49 @@ -33,7 +33,7 @@
51 #include "oox/helper/propertymap.hxx"
52 #include "oox/drawingml/drawingmltypes.hxx"
53 -#include "oox/drawingml/customshapeproperties.hxx"
54 +//#include "oox/drawingml/customshapeproperties.hxx"
55 #include "oox/drawingml/textliststyle.hxx"
57 #include <com/sun/star/frame/XModel.hpp>
58 @@ -45,6 +45,9 @@
60 namespace oox { namespace drawingml {
62 +class CustomShapeProperties;
63 +typedef boost::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr;
65 typedef ::std::map< ::rtl::OUString, ShapePtr > ShapeIdMap;
67 struct ShapeStyleRef
68 diff --git oox/source/drawingml/chart/plotareaconverter.cxx oox/source/drawingml/chart/plotareaconverter.cxx
69 index f3baa2c..ce6e3e7 100644
70 --- oox/source/drawingml/chart/plotareaconverter.cxx
71 +++ oox/source/drawingml/chart/plotareaconverter.cxx
72 @@ -31,6 +31,7 @@
74 #include "oox/drawingml/chart/plotareaconverter.hxx"
75 #include <com/sun/star/drawing/Direction3D.hpp>
76 +#include <com/sun/star/drawing/ProjectionMode.hpp>
77 #include <com/sun/star/drawing/ShadeMode.hpp>
78 #include <com/sun/star/chart2/XChartDocument.hpp>
79 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
80 diff --git oox/source/drawingml/customshapegeometry.cxx oox/source/drawingml/customshapegeometry.cxx
81 index 752c7b1..e4b99d6 100644
82 --- oox/source/drawingml/customshapegeometry.cxx
83 +++ oox/source/drawingml/customshapegeometry.cxx
84 @@ -29,10 +29,12 @@
85 ************************************************************************/
87 #include "oox/drawingml/customshapegeometry.hxx"
88 +#include "oox/drawingml/customshapeproperties.hxx"
90 #include <com/sun/star/xml/sax/FastToken.hpp>
91 #include <comphelper/stl_types.hxx>
92 #include <hash_map>
93 +#include <basegfx/polygon/b2dpolygon.hxx>
95 #include "oox/helper/helper.hxx"
96 #include "oox/helper/propertymap.hxx"
97 @@ -41,6 +43,7 @@
99 using ::rtl::OUString;
100 using ::com::sun::star::beans::NamedValue;
101 +using namespace ::basegfx;
102 using namespace ::oox::core;
103 using namespace ::com::sun::star::uno;
104 using namespace ::com::sun::star::xml::sax;
105 @@ -184,6 +187,88 @@ Reference< XFastContextHandler > AdjustmentValueContext::createFastChildContext(
107 // ---------------------------------------------------------------------
109 +class PathListContext : public ContextHandler
111 +public:
112 + PathListContext( ContextHandler& rParent, Shape& rShape );
113 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
114 + virtual void SAL_CALL endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException);
116 +protected:
117 + Shape& mrShape;
118 + sal_Int32 maPointToken;
119 + ::basegfx::B2DPolygon maPolygon;
122 +PathListContext::PathListContext( ContextHandler& rParent, Shape& rShape )
123 +: ContextHandler( rParent )
124 +, mrShape( rShape )
128 +Reference< XFastContextHandler > PathListContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
130 + switch( aElementToken ) {
131 + case NMSP_DRAWINGML | XML_path:
132 + maPolygon.clear();
133 + break;
134 + case NMSP_DRAWINGML | XML_close:
135 + maPolygon.setClosed( true );
136 + break;
137 + case NMSP_DRAWINGML | XML_pt:
139 + OUString sX, sY;
141 + sX = xAttribs->getOptionalValue( XML_x );
142 + sY = xAttribs->getOptionalValue( XML_y );
144 + double dX, dY;
146 + dX = sX.toDouble();
147 + dY = sY.toDouble();
149 + maPolygon.append( B2DPoint ( dX, dY ) );
150 + break;
152 + case NMSP_DRAWINGML | XML_lnTo:
153 + case NMSP_DRAWINGML | XML_moveTo:
154 + maPointToken = aElementToken;
155 + break;
158 + return this;
161 +void PathListContext::endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException)
163 + switch( aElementToken ) {
164 + case NMSP_DRAWINGML|XML_pathLst:
166 + B2DPolyPolygon& rPoly = mrShape.getCustomShapeProperties()->getPolygon();
167 + if( rPoly.count() ) {
168 + if( rPoly.areControlPointsUsed() ) {
169 + if( rPoly.isClosed() )
170 + mrShape.setServiceName( "com.sun.star.drawing.ClosedBezierShape" );
171 + else
172 + mrShape.setServiceName( "com.sun.star.drawing.OpenBezierShape" );
173 + } else {
174 + if( rPoly.isClosed() )
175 + mrShape.setServiceName( "com.sun.star.drawing.PolyPolygonPathShape" );
176 + else
177 + mrShape.setServiceName( "com.sun.star.drawing.PolyLinePathShape" );
180 + break;
182 + case NMSP_DRAWINGML|XML_path:
183 + if( maPolygon.count() > 0 )
184 + mrShape.getCustomShapeProperties()->getPolygon().append( maPolygon );
185 + break;
189 +// ---------------------------------------------------------------------
191 OUString GetShapeType( sal_Int32 nType )
193 OUString sType;
194 @@ -985,9 +1070,9 @@ static OUString GetTextShapeType( sal_Int32 nType )
196 // ---------------------------------------------------------------------
197 // CT_CustomGeometry2D
198 -CustomShapeGeometryContext::CustomShapeGeometryContext( ContextHandler& rParent, const Reference< XFastAttributeList >& /* xAttribs */, CustomShapeProperties& rCustomShapeProperties )
199 +CustomShapeGeometryContext::CustomShapeGeometryContext( ContextHandler& rParent, const Reference< XFastAttributeList >& /* xAttribs */, Shape& rShape )
200 : ContextHandler( rParent )
201 -, mrCustomShapeProperties( rCustomShapeProperties )
202 +, mrShape( rShape )
206 @@ -1001,8 +1086,9 @@ Reference< XFastContextHandler > CustomShapeGeometryContext::createFastChildCont
207 case NMSP_DRAWINGML|XML_ahLst: // CT_AdjustHandleList adjust handle list
208 case NMSP_DRAWINGML|XML_cxnLst: // CT_ConnectionSiteList connection site list
209 case NMSP_DRAWINGML|XML_rect: // CT_GeomRectList geometry rect list
210 + break;
211 case NMSP_DRAWINGML|XML_pathLst: // CT_Path2DList 2d path list
212 - break;
213 + return new PathListContext( *this, mrShape );
216 Reference< XFastContextHandler > xEmpty;
217 diff --git oox/source/drawingml/diagram/diagramdefinitioncontext.cxx oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
218 index c28e8eb..94441be 100644
219 --- oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
220 +++ oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
221 @@ -34,6 +34,7 @@
222 #include "layoutnodecontext.hxx"
223 #include "diagramdefinitioncontext.hxx"
224 #include "oox/drawingml/diagram/datamodelcontext.hxx"
225 +#include "tokens.hxx"
227 using namespace ::oox::core;
228 using namespace ::com::sun::star::uno;
229 diff --git oox/source/drawingml/diagram/diagramfragmenthandler.cxx oox/source/drawingml/diagram/diagramfragmenthandler.cxx
230 index fc5fe05..f666fb8 100644
231 --- oox/source/drawingml/diagram/diagramfragmenthandler.cxx
232 +++ oox/source/drawingml/diagram/diagramfragmenthandler.cxx
233 @@ -34,7 +34,7 @@
234 #include "oox/drawingml/diagram/datamodelcontext.hxx"
235 #include "oox/core/namespaces.hxx"
236 #include "diagramdefinitioncontext.hxx"
238 +#include "tokens.hxx"
240 using namespace ::oox::core;
241 using namespace ::com::sun::star::xml::sax;
242 diff --git oox/source/drawingml/graphicshapecontext.cxx oox/source/drawingml/graphicshapecontext.cxx
243 index 42e6156..da97719 100644
244 --- oox/source/drawingml/graphicshapecontext.cxx
245 +++ oox/source/drawingml/graphicshapecontext.cxx
246 @@ -32,6 +32,7 @@
248 #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
249 #include "oox/drawingml/graphicshapecontext.hxx"
250 +#include "oox/drawingml/customshapeproperties.hxx"
251 #include "oox/drawingml/diagram/diagramfragmenthandler.hxx"
252 #include "oox/drawingml/table/tablecontext.hxx"
253 #include "oox/core/namespaces.hxx"
254 diff --git oox/source/drawingml/shape.cxx oox/source/drawingml/shape.cxx
255 index b1f3559..655083c 100644
256 --- oox/source/drawingml/shape.cxx
257 +++ oox/source/drawingml/shape.cxx
258 @@ -29,6 +29,7 @@
259 ************************************************************************/
261 #include "oox/drawingml/shape.hxx"
262 +#include "oox/drawingml/customshapeproperties.hxx"
263 #include "oox/drawingml/theme.hxx"
264 #include "oox/drawingml/fillproperties.hxx"
265 #include "oox/drawingml/lineproperties.hxx"
266 @@ -209,8 +210,8 @@ void Shape::addChildren(
267 aIter = rMaster.maChildren.begin();
268 while( aIter != rMaster.maChildren.end() )
270 - Rectangle aShapeRect;
271 - Rectangle* pShapeRect = 0;
272 + awt::Rectangle aShapeRect;
273 + awt::Rectangle* pShapeRect = 0;
274 if ( ( nGlobalLeft != SAL_MAX_INT32 ) && ( nGlobalRight != SAL_MIN_INT32 ) && ( nGlobalTop != SAL_MAX_INT32 ) && ( nGlobalBottom != SAL_MIN_INT32 ) )
276 sal_Int32 nGlobalWidth = nGlobalRight - nGlobalLeft;
277 @@ -284,6 +285,36 @@ Reference< XShape > Shape::createAndInsert(
278 aTransformation.translate( aPosition.X / 360.0, aPosition.Y / 360.0 );
281 + if ( mpCustomShapePropertiesPtr && mpCustomShapePropertiesPtr->getPolygon().count() )
283 + ::basegfx::B2DPolyPolygon& rPolyPoly = mpCustomShapePropertiesPtr->getPolygon();
285 + if( rPolyPoly.count() > 0 ) {
286 + if( rPolyPoly.areControlPointsUsed() ) {
287 + // TODO Beziers
288 + } else {
289 + uno::Sequence< uno::Sequence< awt::Point > > aPolyPolySequence( rPolyPoly.count() );
291 + for (sal_uInt32 j = 0; j < rPolyPoly.count(); j++ ) {
292 + ::basegfx::B2DPolygon aPoly = rPolyPoly.getB2DPolygon( j );
294 + // now creating the corresponding PolyPolygon
295 + sal_Int32 i, nNumPoints = aPoly.count();
296 + uno::Sequence< awt::Point > aPointSequence( nNumPoints );
297 + awt::Point* pPoints = aPointSequence.getArray();
298 + for( i = 0; i < nNumPoints; ++i )
300 + const ::basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) );
301 + pPoints[ i ] = awt::Point( static_cast< sal_Int32 >( aPoint.getX() ), static_cast< sal_Int32 >( aPoint.getY() ) );
303 + aPolyPolySequence.getArray()[ j ] = aPointSequence;
305 + static const OUString sPolyPolygon(RTL_CONSTASCII_USTRINGPARAM("PolyPolygon"));
306 + maShapeProperties[ sPolyPolygon ] <<= aPolyPolySequence;
311 // special for lineshape
312 if ( rServiceName == OUString::createFromAscii( "com.sun.star.drawing.LineShape" ) )
314 diff --git oox/source/drawingml/shapepropertiescontext.cxx oox/source/drawingml/shapepropertiescontext.cxx
315 index 9ef39a4..479b706 100644
316 --- oox/source/drawingml/shapepropertiescontext.cxx
317 +++ oox/source/drawingml/shapepropertiescontext.cxx
318 @@ -77,7 +77,7 @@ Reference< XFastContextHandler > ShapePropertiesContext::createFastChildContext(
320 // GeometryGroup
321 case NMSP_DRAWINGML|XML_custGeom: // custom geometry "CT_CustomGeometry2D"
322 - xRet.set( new CustomShapeGeometryContext( *this, xAttribs, *(mrShape.getCustomShapeProperties()) ) );
323 + xRet.set( new CustomShapeGeometryContext( *this, xAttribs, mrShape ) );
324 break;
327 diff --git oox/source/drawingml/table/tablerowcontext.cxx oox/source/drawingml/table/tablerowcontext.cxx
328 index f3ae44c..09913a0 100644
329 --- oox/source/drawingml/table/tablerowcontext.cxx
330 +++ oox/source/drawingml/table/tablerowcontext.cxx
331 @@ -34,6 +34,7 @@
332 #include "oox/drawingml/table/tablecellcontext.hxx"
333 #include "oox/drawingml/table/tablerow.hxx"
334 #include "oox/core/namespaces.hxx"
335 +#include "tokens.hxx"
337 using namespace ::oox::core;
338 using namespace ::com::sun::star;
339 diff --git oox/source/drawingml/theme.cxx oox/source/drawingml/theme.cxx
340 index e1a7f63..84e1506 100644
341 --- oox/source/drawingml/theme.cxx
342 +++ oox/source/drawingml/theme.cxx
343 @@ -29,6 +29,7 @@
344 ************************************************************************/
346 #include "oox/drawingml/theme.hxx"
347 +#include "tokens.hxx"
349 using ::rtl::OUString;
351 diff --git oox/source/shape/ShapeContextHandler.cxx oox/source/shape/ShapeContextHandler.cxx
352 index fd72690..90239fa 100644
353 --- oox/source/shape/ShapeContextHandler.cxx
354 +++ oox/source/shape/ShapeContextHandler.cxx
355 @@ -30,6 +30,7 @@
357 #include "ShapeContextHandler.hxx"
358 #include "oox/vml/drawingfragmenthandler.hxx"
359 +#include "tokens.hxx"
361 namespace oox { namespace shape {
363 diff --git oox/source/xls/themebuffer.cxx oox/source/xls/themebuffer.cxx
364 index 65f9a2f..ca499c5 100644
365 --- oox/source/xls/themebuffer.cxx
366 +++ oox/source/xls/themebuffer.cxx
367 @@ -31,6 +31,7 @@
368 #include "oox/xls/themebuffer.hxx"
369 #include "oox/xls/stylesbuffer.hxx"
370 #include "oox/xls/stylespropertyhelper.hxx"
371 +#include "tokens.hxx"
373 using ::oox::drawingml::ClrScheme;
374 using ::oox::drawingml::Color;