merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0342-oox-custom-shape-polygons.diff
blob69531a97d719e7b719fd60e632a732de093b1630
1 diff -rup oox-orig-1/inc/oox/drawingml/customshapegeometry.hxx oox/inc/oox/drawingml/customshapegeometry.hxx
2 --- oox-orig-1/inc/oox/drawingml/customshapegeometry.hxx 2009-10-05 18:17:28.000000000 +0200
3 +++ oox/inc/oox/drawingml/customshapegeometry.hxx 2009-10-05 18:18:01.000000000 +0200
4 @@ -44,11 +44,11 @@ namespace oox { namespace drawingml {
5 class CustomShapeGeometryContext : public ::oox::core::ContextHandler
7 public:
8 - CustomShapeGeometryContext( ::oox::core::ContextHandler& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, CustomShapeProperties& rCustomShapeProperties );
9 + CustomShapeGeometryContext( ::oox::core::ContextHandler& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, Shape& rShape );
10 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);
12 private:
13 - CustomShapeProperties& mrCustomShapeProperties;
14 + Shape& mrShape;
17 // ---------------------------------------------------------------------
18 diff -rup oox-orig-1/inc/oox/drawingml/customshapeproperties.hxx oox/inc/oox/drawingml/customshapeproperties.hxx
19 --- oox-orig-1/inc/oox/drawingml/customshapeproperties.hxx 2009-10-05 18:17:28.000000000 +0200
20 +++ oox/inc/oox/drawingml/customshapeproperties.hxx 2009-10-05 18:18:01.000000000 +0200
21 @@ -35,6 +35,7 @@
22 #include "oox/drawingml/color.hxx"
23 #include <com/sun/star/graphic/XGraphic.hpp>
24 #include <boost/shared_ptr.hpp>
25 +#include <basegfx/polygon/b2dpolypolygon.hxx>
26 #include "tokens.hxx"
27 #include <vector>
28 #include <map>
29 @@ -80,11 +81,12 @@ public:
30 std::vector< CustomShapeGuide >& getAdjustmentValues(){ return maAdjustmentValues; };
32 double getValue( const std::vector< CustomShapeGuide >&, sal_uInt32 nIndex ) const;
34 + ::basegfx::B2DPolyPolygon& getPolygon() { return maPolygon; }
35 private:
37 rtl::OUString maShapePresetType;
38 std::vector< CustomShapeGuide > maAdjustmentValues;
39 + ::basegfx::B2DPolyPolygon maPolygon;
42 } }
43 diff -rup oox-orig-1/inc/oox/drawingml/shape.hxx oox/inc/oox/drawingml/shape.hxx
44 --- oox-orig-1/inc/oox/drawingml/shape.hxx 2009-10-05 18:17:28.000000000 +0200
45 +++ oox/inc/oox/drawingml/shape.hxx 2009-10-05 18:18:01.000000000 +0200
46 @@ -33,7 +33,7 @@
48 #include "oox/helper/propertymap.hxx"
49 #include "oox/drawingml/drawingmltypes.hxx"
50 -#include "oox/drawingml/customshapeproperties.hxx"
51 +//#include "oox/drawingml/customshapeproperties.hxx"
52 #include "oox/drawingml/textliststyle.hxx"
54 #include <com/sun/star/frame/XModel.hpp>
55 @@ -45,6 +45,9 @@
57 namespace oox { namespace drawingml {
59 +class CustomShapeProperties;
60 +typedef boost::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr;
62 typedef ::std::map< ::rtl::OUString, ShapePtr > ShapeIdMap;
64 struct ShapeStyleRef
65 diff -rup oox-orig-1/source/drawingml/chart/plotareaconverter.cxx oox/source/drawingml/chart/plotareaconverter.cxx
66 --- oox-orig-1/source/drawingml/chart/plotareaconverter.cxx 2009-10-05 18:17:28.000000000 +0200
67 +++ oox/source/drawingml/chart/plotareaconverter.cxx 2009-10-05 18:18:01.000000000 +0200
68 @@ -31,6 +31,7 @@
70 #include "oox/drawingml/chart/plotareaconverter.hxx"
71 #include <com/sun/star/drawing/Direction3D.hpp>
72 +#include <com/sun/star/drawing/ProjectionMode.hpp>
73 #include <com/sun/star/drawing/ShadeMode.hpp>
74 #include <com/sun/star/chart2/XChartDocument.hpp>
75 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
76 diff -rup oox-orig-1/source/drawingml/customshapegeometry.cxx oox/source/drawingml/customshapegeometry.cxx
77 --- oox-orig-1/source/drawingml/customshapegeometry.cxx 2009-10-05 18:17:28.000000000 +0200
78 +++ oox/source/drawingml/customshapegeometry.cxx 2009-10-05 18:18:01.000000000 +0200
79 @@ -29,10 +29,12 @@
80 ************************************************************************/
82 #include "oox/drawingml/customshapegeometry.hxx"
83 +#include "oox/drawingml/customshapeproperties.hxx"
85 #include <com/sun/star/xml/sax/FastToken.hpp>
86 #include <comphelper/stl_types.hxx>
87 #include <hash_map>
88 +#include <basegfx/polygon/b2dpolygon.hxx>
90 #include "oox/helper/helper.hxx"
91 #include "oox/helper/propertymap.hxx"
92 @@ -40,6 +42,7 @@
93 #include "tokens.hxx"
95 using ::rtl::OUString;
96 +using namespace ::basegfx;
97 using namespace ::oox::core;
98 using namespace ::com::sun::star::uno;
99 using namespace ::com::sun::star::xml::sax;
100 @@ -183,6 +186,88 @@ Reference< XFastContextHandler > Adjustm
102 // ---------------------------------------------------------------------
104 +class PathListContext : public ContextHandler
106 +public:
107 + PathListContext( ContextHandler& rParent, Shape& rShape );
108 + 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);
109 + virtual void SAL_CALL endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException);
111 +protected:
112 + Shape& mrShape;
113 + sal_Int32 maPointToken;
114 + ::basegfx::B2DPolygon maPolygon;
117 +PathListContext::PathListContext( ContextHandler& rParent, Shape& rShape )
118 +: ContextHandler( rParent )
119 +, mrShape( rShape )
123 +Reference< XFastContextHandler > PathListContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
125 + switch( aElementToken ) {
126 + case NMSP_DRAWINGML | XML_path:
127 + maPolygon.clear();
128 + break;
129 + case NMSP_DRAWINGML | XML_close:
130 + maPolygon.setClosed( true );
131 + break;
132 + case NMSP_DRAWINGML | XML_pt:
134 + OUString sX, sY;
136 + sX = xAttribs->getOptionalValue( XML_x );
137 + sY = xAttribs->getOptionalValue( XML_y );
139 + double dX, dY;
141 + dX = sX.toDouble();
142 + dY = sY.toDouble();
144 + maPolygon.append( B2DPoint ( dX, dY ) );
145 + break;
147 + case NMSP_DRAWINGML | XML_lnTo:
148 + case NMSP_DRAWINGML | XML_moveTo:
149 + maPointToken = aElementToken;
150 + break;
153 + return this;
156 +void PathListContext::endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException)
158 + switch( aElementToken ) {
159 + case NMSP_DRAWINGML|XML_pathLst:
161 + B2DPolyPolygon& rPoly = mrShape.getCustomShapeProperties()->getPolygon();
162 + if( rPoly.count() ) {
163 + if( rPoly.areControlPointsUsed() ) {
164 + if( rPoly.isClosed() )
165 + mrShape.setServiceName( "com.sun.star.drawing.ClosedBezierShape" );
166 + else
167 + mrShape.setServiceName( "com.sun.star.drawing.OpenBezierShape" );
168 + } else {
169 + if( rPoly.isClosed() )
170 + mrShape.setServiceName( "com.sun.star.drawing.PolyPolygonPathShape" );
171 + else
172 + mrShape.setServiceName( "com.sun.star.drawing.PolyLinePathShape" );
175 + break;
177 + case NMSP_DRAWINGML|XML_path:
178 + if( maPolygon.count() > 0 )
179 + mrShape.getCustomShapeProperties()->getPolygon().append( maPolygon );
180 + break;
184 +// ---------------------------------------------------------------------
186 OUString GetShapeType( sal_Int32 nType )
188 OUString sType;
189 @@ -984,9 +1069,9 @@ static OUString GetTextShapeType( sal_In
191 // ---------------------------------------------------------------------
192 // CT_CustomGeometry2D
193 -CustomShapeGeometryContext::CustomShapeGeometryContext( ContextHandler& rParent, const Reference< XFastAttributeList >& /* xAttribs */, CustomShapeProperties& rCustomShapeProperties )
194 +CustomShapeGeometryContext::CustomShapeGeometryContext( ContextHandler& rParent, const Reference< XFastAttributeList >& /* xAttribs */, Shape& rShape )
195 : ContextHandler( rParent )
196 -, mrCustomShapeProperties( rCustomShapeProperties )
197 +, mrShape( rShape )
201 @@ -1000,8 +1085,9 @@ Reference< XFastContextHandler > CustomS
202 case NMSP_DRAWINGML|XML_ahLst: // CT_AdjustHandleList adjust handle list
203 case NMSP_DRAWINGML|XML_cxnLst: // CT_ConnectionSiteList connection site list
204 case NMSP_DRAWINGML|XML_rect: // CT_GeomRectList geometry rect list
205 + break;
206 case NMSP_DRAWINGML|XML_pathLst: // CT_Path2DList 2d path list
207 - break;
208 + return new PathListContext( *this, mrShape );
211 Reference< XFastContextHandler > xEmpty;
212 diff -rup oox-orig-1/source/drawingml/diagram/diagramdefinitioncontext.cxx oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
213 --- oox-orig-1/source/drawingml/diagram/diagramdefinitioncontext.cxx 2009-10-05 18:17:28.000000000 +0200
214 +++ oox/source/drawingml/diagram/diagramdefinitioncontext.cxx 2009-10-05 18:18:01.000000000 +0200
215 @@ -33,6 +33,7 @@
216 #include "oox/helper/helper.hxx"
217 #include "layoutnodecontext.hxx"
218 #include "oox/drawingml/diagram/datamodelcontext.hxx"
219 +#include "tokens.hxx"
221 using namespace ::oox::core;
222 using namespace ::com::sun::star::uno;
223 diff -rup oox-orig-1/source/drawingml/diagram/diagramfragmenthandler.cxx oox/source/drawingml/diagram/diagramfragmenthandler.cxx
224 --- oox-orig-1/source/drawingml/diagram/diagramfragmenthandler.cxx 2009-10-05 18:17:28.000000000 +0200
225 +++ oox/source/drawingml/diagram/diagramfragmenthandler.cxx 2009-10-05 18:18:01.000000000 +0200
226 @@ -34,7 +34,7 @@
227 #include "oox/drawingml/diagram/datamodelcontext.hxx"
228 #include "oox/core/namespaces.hxx"
229 #include "diagramdefinitioncontext.hxx"
231 +#include "tokens.hxx"
233 using namespace ::oox::core;
234 using namespace ::com::sun::star::xml::sax;
235 diff -rup oox-orig-1/source/drawingml/graphicshapecontext.cxx oox/source/drawingml/graphicshapecontext.cxx
236 --- oox-orig-1/source/drawingml/graphicshapecontext.cxx 2009-10-05 18:17:28.000000000 +0200
237 +++ oox/source/drawingml/graphicshapecontext.cxx 2009-10-05 18:18:01.000000000 +0200
238 @@ -33,6 +33,7 @@
239 #include <com/sun/star/chart2/XChartDocument.hpp>
241 #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
242 +#include "oox/drawingml/customshapeproperties.hxx"
243 #include "oox/drawingml/diagram/diagramfragmenthandler.hxx"
244 #include "oox/drawingml/table/tablecontext.hxx"
245 #include "oox/core/namespaces.hxx"
246 diff -rup oox-orig-1/source/drawingml/shape.cxx oox/source/drawingml/shape.cxx
247 --- oox-orig-1/source/drawingml/shape.cxx 2009-10-05 18:17:28.000000000 +0200
248 +++ oox/source/drawingml/shape.cxx 2009-10-05 18:19:24.000000000 +0200
249 @@ -29,6 +29,7 @@
250 ************************************************************************/
252 #include "oox/drawingml/shape.hxx"
253 +#include "oox/drawingml/customshapeproperties.hxx"
254 #include "oox/drawingml/theme.hxx"
255 #include "oox/drawingml/fillproperties.hxx"
256 #include "oox/drawingml/lineproperties.hxx"
257 @@ -217,8 +218,8 @@ void Shape::addChildren(
258 aIter = rMaster.maChildren.begin();
259 while( aIter != rMaster.maChildren.end() )
261 - Rectangle aShapeRect;
262 - Rectangle* pShapeRect = 0;
263 + awt::Rectangle aShapeRect;
264 + awt::Rectangle* pShapeRect = 0;
265 if ( ( nGlobalLeft != SAL_MAX_INT32 ) && ( nGlobalRight != SAL_MIN_INT32 ) && ( nGlobalTop != SAL_MAX_INT32 ) && ( nGlobalBottom != SAL_MIN_INT32 ) )
267 sal_Int32 nGlobalWidth = nGlobalRight - nGlobalLeft;
268 @@ -297,6 +298,35 @@ Reference< XShape > Shape::createAndInse
269 aTransformation.translate( aPosition.X / 360.0, aPosition.Y / 360.0 );
272 + if ( mpCustomShapePropertiesPtr && mpCustomShapePropertiesPtr->getPolygon().count() )
274 + ::basegfx::B2DPolyPolygon& rPolyPoly = mpCustomShapePropertiesPtr->getPolygon();
276 + if( rPolyPoly.count() > 0 ) {
277 + if( rPolyPoly.areControlPointsUsed() ) {
278 + // TODO Beziers
279 + } else {
280 + uno::Sequence< uno::Sequence< awt::Point > > aPolyPolySequence( rPolyPoly.count() );
282 + for (sal_uInt32 j = 0; j < rPolyPoly.count(); j++ ) {
283 + ::basegfx::B2DPolygon aPoly = rPolyPoly.getB2DPolygon( j );
285 + // now creating the corresponding PolyPolygon
286 + sal_Int32 i, nNumPoints = aPoly.count();
287 + uno::Sequence< awt::Point > aPointSequence( nNumPoints );
288 + awt::Point* pPoints = aPointSequence.getArray();
289 + for( i = 0; i < nNumPoints; ++i )
291 + const ::basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) );
292 + pPoints[ i ] = awt::Point( static_cast< sal_Int32 >( aPoint.getX() ), static_cast< sal_Int32 >( aPoint.getY() ) );
294 + aPolyPolySequence.getArray()[ j ] = aPointSequence;
296 + maShapeProperties[ PROP_PolyPolygon ] <<= aPolyPolySequence;
301 // special for lineshape
302 if ( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.LineShape" ) )
304 diff -rup oox-orig-1/source/drawingml/shapepropertiescontext.cxx oox/source/drawingml/shapepropertiescontext.cxx
305 --- oox-orig-1/source/drawingml/shapepropertiescontext.cxx 2009-10-05 18:17:28.000000000 +0200
306 +++ oox/source/drawingml/shapepropertiescontext.cxx 2009-10-05 18:18:01.000000000 +0200
307 @@ -77,7 +77,7 @@ Reference< XFastContextHandler > ShapePr
309 // GeometryGroup
310 case NMSP_DRAWINGML|XML_custGeom: // custom geometry "CT_CustomGeometry2D"
311 - xRet.set( new CustomShapeGeometryContext( *this, xAttribs, *(mrShape.getCustomShapeProperties()) ) );
312 + xRet.set( new CustomShapeGeometryContext( *this, xAttribs, mrShape ) );
313 break;
316 diff -rup oox-orig-1/source/drawingml/table/tablerowcontext.cxx oox/source/drawingml/table/tablerowcontext.cxx
317 --- oox-orig-1/source/drawingml/table/tablerowcontext.cxx 2009-10-05 18:17:28.000000000 +0200
318 +++ oox/source/drawingml/table/tablerowcontext.cxx 2009-10-05 18:18:01.000000000 +0200
319 @@ -34,6 +34,7 @@
320 #include "oox/drawingml/table/tablecellcontext.hxx"
321 #include "oox/drawingml/table/tablerow.hxx"
322 #include "oox/core/namespaces.hxx"
323 +#include "tokens.hxx"
325 using namespace ::oox::core;
326 using namespace ::com::sun::star;
327 diff -rup oox-orig-1/source/drawingml/theme.cxx oox/source/drawingml/theme.cxx
328 --- oox-orig-1/source/drawingml/theme.cxx 2009-10-05 18:17:28.000000000 +0200
329 +++ oox/source/drawingml/theme.cxx 2009-10-05 18:18:01.000000000 +0200
330 @@ -29,6 +29,7 @@
331 ************************************************************************/
333 #include "oox/drawingml/theme.hxx"
334 +#include "tokens.hxx"
336 using ::rtl::OUString;
338 diff -rup oox-orig-1/source/shape/ShapeContextHandler.cxx oox/source/shape/ShapeContextHandler.cxx
339 --- oox-orig-1/source/shape/ShapeContextHandler.cxx 2009-10-05 18:17:28.000000000 +0200
340 +++ oox/source/shape/ShapeContextHandler.cxx 2009-10-05 18:18:01.000000000 +0200
341 @@ -32,6 +32,7 @@
342 #include "oox/vml/vmldrawingfragment.hxx"
343 #include "oox/vml/vmlshape.hxx"
344 #include "oox/vml/vmlshapecontainer.hxx"
345 +#include "tokens.hxx"
347 namespace oox { namespace shape {
349 diff -rup oox-orig-1/source/xls/themebuffer.cxx oox/source/xls/themebuffer.cxx
350 --- oox-orig-1/source/xls/themebuffer.cxx 2009-10-05 18:17:28.000000000 +0200
351 +++ oox/source/xls/themebuffer.cxx 2009-10-05 18:18:01.000000000 +0200
352 @@ -30,6 +30,7 @@
354 #include "oox/xls/themebuffer.hxx"
355 #include "oox/xls/stylesbuffer.hxx"
356 +#include "tokens.hxx"
358 using ::oox::drawingml::ClrScheme;