1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _XMLOFF_SHAPEEXPORT_HXX_ 28 #define _XMLOFF_SHAPEEXPORT_HXX_ 29 30 #include "sal/config.h" 31 #include "xmloff/dllapi.h" 32 #include "sal/types.h" 33 34 #include <rtl/ref.hxx> 35 #include <rtl/ustring.hxx> 36 #include <rtl/ustrbuf.hxx> 37 #include <xmloff/uniref.hxx> 38 39 #include <com/sun/star/drawing/XShape.hpp> 40 #include <com/sun/star/drawing/XShapes.hpp> 41 #include <com/sun/star/awt/Point.hpp> 42 #include <com/sun/star/beans/PropertyValue.hpp> 43 44 #include <map> 45 #include <xmloff/xmlprmap.hxx> 46 #include <xmloff/xmlexppr.hxx> 47 #include <xmloff/animexp.hxx> 48 #include <xmloff/families.hxx> 49 50 #include "xmloff/table/XMLTableExport.hxx" 51 52 // shape export features are bits used for the nFeature 53 // parameter of XMLShapeExport::exportShape 54 55 #define SEF_EXPORT_X 0x0001 56 #define SEF_EXPORT_Y 0x0002 57 #define SEF_EXPORT_POSITION 0x0003 58 59 #define SEF_EXPORT_WIDTH 0x0004 60 #define SEF_EXPORT_HEIGHT 0x0008 61 #define SEF_EXPORT_SIZE 0x000c 62 63 // when you set this flag a chart does NOT export its own data as table element 64 #define SEF_EXPORT_NO_CHART_DATA 0x0010 65 66 // When setting the flag below no ignorableWhiteSpace will be called around 67 // the drawing object elements 68 #define SEF_EXPORT_NO_WS 0x0020 69 70 // When setting the flag below a callout shape is exported as office:annotation 71 #define SEF_EXPORT_ANNOTATION 0x0040 72 73 #define SEF_DEFAULT SEF_EXPORT_POSITION|SEF_EXPORT_SIZE 74 75 enum XmlShapeType 76 { 77 XmlShapeTypeUnknown, // not known 78 79 XmlShapeTypeDrawRectangleShape, // "com.sun.star.drawing.RectangleShape" 80 XmlShapeTypeDrawEllipseShape, // "com.sun.star.drawing.EllipseShape" 81 XmlShapeTypeDrawControlShape, // "com.sun.star.drawing.ControlShape" 82 XmlShapeTypeDrawConnectorShape, // "com.sun.star.drawing.ConnectorShape" 83 XmlShapeTypeDrawMeasureShape, // "com.sun.star.drawing.MeasureShape" 84 XmlShapeTypeDrawLineShape, // "com.sun.star.drawing.LineShape" 85 XmlShapeTypeDrawPolyPolygonShape, // "com.sun.star.drawing.PolyPolygonShape" 86 XmlShapeTypeDrawPolyLineShape, // "com.sun.star.drawing.PolyLineShape" 87 XmlShapeTypeDrawOpenBezierShape, // "com.sun.star.drawing.OpenBezierShape" 88 XmlShapeTypeDrawClosedBezierShape, // "com.sun.star.drawing.ClosedBezierShape" 89 XmlShapeTypeDrawGraphicObjectShape, // "com.sun.star.drawing.GraphicObjectShape" 90 XmlShapeTypeDrawGroupShape, // "com.sun.star.drawing.GroupShape" 91 XmlShapeTypeDrawTextShape, // "com.sun.star.drawing.TextShape" 92 XmlShapeTypeDrawOLE2Shape, // "com.sun.star.drawing.OLE2Shape" 93 XmlShapeTypeDrawChartShape, // embedded com.sun.star.chart 94 XmlShapeTypeDrawSheetShape, // embedded com.sun.star.sheet 95 XmlShapeTypeDrawPageShape, // "com.sun.star.drawing.PageShape" 96 XmlShapeTypeDrawFrameShape, // "com.sun.star.drawing.FrameShape" 97 XmlShapeTypeDrawCaptionShape, // "com.sun.star.drawing.CaptionShape" 98 XmlShapeTypeDrawAppletShape, // "com.sun.star.drawing.AppletShape" 99 XmlShapeTypeDrawPluginShape, // "com.sun.star.drawing.PlugginShape" 100 101 XmlShapeTypeDraw3DSceneObject, // "com.sun.star.drawing.Shape3DSceneObject" 102 XmlShapeTypeDraw3DCubeObject, // "com.sun.star.drawing.Shape3DCubeObject" 103 XmlShapeTypeDraw3DSphereObject, // "com.sun.star.drawing.Shape3DSphereObject" 104 XmlShapeTypeDraw3DLatheObject, // "com.sun.star.drawing.Shape3DLatheObject" 105 XmlShapeTypeDraw3DExtrudeObject, // "com.sun.star.drawing.Shape3DExtrudeObject" 106 107 XmlShapeTypePresTitleTextShape, // "com.sun.star.presentation.TitleTextShape" 108 XmlShapeTypePresOutlinerShape, // "com.sun.star.presentation.OutlinerShape" 109 XmlShapeTypePresSubtitleShape, // "com.sun.star.presentation.SubtitleShape" 110 XmlShapeTypePresGraphicObjectShape, // "com.sun.star.presentation.GraphicObjectShape" 111 XmlShapeTypePresPageShape, // "com.sun.star.presentation.PageShape" 112 XmlShapeTypePresOLE2Shape, // "com.sun.star.presentation.OLE2Shape" 113 XmlShapeTypePresChartShape, // "com.sun.star.presentation.ChartShape" 114 XmlShapeTypePresSheetShape, // "com.sun.star.presentation.CalcShape" 115 XmlShapeTypePresTableShape, // "com.sun.star.presentation.TableShape" 116 XmlShapeTypePresOrgChartShape, // "com.sun.star.presentation.OrgChartShape" 117 XmlShapeTypePresNotesShape, // "com.sun.star.presentation.NotesShape" 118 XmlShapeTypeHandoutShape, // "com.sun.star.presentation.HandoutShape" 119 120 XmlShapeTypePresHeaderShape, // "com.sun.star.presentation.HeaderShape" 121 XmlShapeTypePresFooterShape, // "com.sun.star.presentation.FooterShape" 122 XmlShapeTypePresSlideNumberShape, // "com.sun.star.presentation.SlideNumberShape" 123 XmlShapeTypePresDateTimeShape, // "com.sun.star.presentation.DateTimeShape" 124 125 XmlShapeTypeDrawCustomShape, // "com.sun.star.drawing.CustomShape" 126 XmlShapeTypeDrawMediaShape, // "com.sun.star.drawing.MediaShape" 127 XmlShapeTypePresMediaShape, // "com.sun.star.presentation.MediaShape" 128 129 XmlShapeTypeDrawTableShape, // "com.sun.star.drawing.TableShape" 130 131 XmlShapeTypeNotYetSet 132 }; 133 134 /** caches style and type info after a collectShapeAutostyle for later use in exportShape */ 135 struct ImplXMLShapeExportInfo 136 { 137 rtl::OUString msStyleName; 138 rtl::OUString msTextStyleName; 139 sal_Int32 mnFamily; 140 XmlShapeType meShapeType; 141 142 com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xCustomShapeReplacement; 143 144 ImplXMLShapeExportInfo() : mnFamily( XML_STYLE_FAMILY_SD_GRAPHICS_ID ), meShapeType( XmlShapeTypeNotYetSet ) {} 145 }; 146 147 /** a vector for shape style and type cache information */ 148 typedef std::vector< ImplXMLShapeExportInfo > ImplXMLShapeExportInfoVector; 149 150 /** a map to store all cache data for already collected XShapes */ 151 typedef std::map< com::sun::star::uno::Reference < com::sun::star::drawing::XShapes >, ImplXMLShapeExportInfoVector > ShapesInfos; 152 153 ////////////////////////////////////////////////////////////////////////////// 154 // predeclarations 155 156 class SvXMLExport; 157 class SvXMLExportPropertyMapper; 158 159 namespace basegfx 160 { 161 class B2DTuple; 162 class B2DHomMatrix; 163 } // end of namespace basegfx 164 165 class XMLOFF_DLLPUBLIC XMLShapeExport : public UniRefBase 166 { 167 private: 168 169 SvXMLExport& mrExport; 170 UniReference< XMLPropertyHandlerFactory > mxSdPropHdlFactory; 171 UniReference< SvXMLExportPropertyMapper > mxPropertySetMapper; 172 UniReference< XMLAnimationsExporter > mxAnimationsExporter; 173 sal_Int32 mnNextUniqueShapeId; 174 ShapesInfos maShapesInfos; 175 ShapesInfos::iterator maCurrentShapesIter; 176 sal_Bool mbExportLayer; 177 ImplXMLShapeExportInfoVector maShapeInfos; 178 ImplXMLShapeExportInfoVector::iterator maCurrentInfo; 179 rtl::OUString msPresentationStylePrefix; 180 181 // #88546# possibility to swich progress bar handling on/off 182 sal_Bool mbHandleProgressBar; 183 184 rtl::Reference< XMLTableExport > mxShapeTableExport; 185 186 protected: 187 SvXMLExport& GetExport() { return mrExport; } 188 const SvXMLExport& GetExport() const { return mrExport; } 189 private: 190 191 SAL_DLLPRIVATE UniReference< SvXMLExportPropertyMapper > GetPropertySetMapper() const { return mxPropertySetMapper; } 192 193 const rtl::OUString msZIndex; 194 const rtl::OUString msPrintable; 195 const rtl::OUString msVisible; 196 197 const rtl::OUString msEmptyPres; 198 const rtl::OUString msModel; 199 const rtl::OUString msStartShape; 200 const rtl::OUString msEndShape; 201 const rtl::OUString msOnClick; 202 #ifdef ISSUE66550_HLINK_FOR_SHAPES 203 const rtl::OUString msOnAction; 204 const rtl::OUString msAction; 205 const rtl::OUString msURL; 206 #endif 207 const rtl::OUString msEventType; 208 const rtl::OUString msPresentation; 209 const rtl::OUString msMacroName; 210 const rtl::OUString msScript; 211 const rtl::OUString msLibrary; 212 const rtl::OUString msClickAction; 213 const rtl::OUString msBookmark; 214 const rtl::OUString msEffect; 215 const rtl::OUString msPlayFull; 216 const rtl::OUString msVerb; 217 const rtl::OUString msSoundURL; 218 const rtl::OUString msSpeed; 219 const rtl::OUString msStarBasic; 220 221 rtl::OUStringBuffer msBuffer; 222 223 SAL_DLLPRIVATE void ImpCalcShapeType(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType& eShapeType); 224 225 SAL_DLLPRIVATE void ImpExportNewTrans(const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint); 226 SAL_DLLPRIVATE void ImpExportNewTrans_GetB2DHomMatrix(::basegfx::B2DHomMatrix& rMatrix, const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet); 227 SAL_DLLPRIVATE void ImpExportNewTrans_DecomposeAndRefPoint(const ::basegfx::B2DHomMatrix& rMat, ::basegfx::B2DTuple& rTRScale, double& fTRShear, double& fTRRotate, ::basegfx::B2DTuple& rTRTranslate, com::sun::star::awt::Point* pRefPoint); 228 SAL_DLLPRIVATE void ImpExportNewTrans_FeaturesAndWrite(::basegfx::B2DTuple& rTRScale, double fTRShear, double fTRRotate, ::basegfx::B2DTuple& rTRTranslate, const sal_Int32 nFeatures); 229 SAL_DLLPRIVATE sal_Bool ImpExportPresentationAttributes( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet, const rtl::OUString& rClass ); 230 SAL_DLLPRIVATE void ImpExportText( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape ); 231 SAL_DLLPRIVATE void ImpExportEvents( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape ); 232 SAL_DLLPRIVATE void ImpExportDescription( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape ); // #i68101# 233 SAL_DLLPRIVATE void ImpExportGluePoints( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape ); 234 235 // single shape exporters 236 SAL_DLLPRIVATE void ImpExportGroupShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 237 SAL_DLLPRIVATE void ImpExport3DSceneShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 238 SAL_DLLPRIVATE void ImpExportRectangleShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 239 SAL_DLLPRIVATE void ImpExportLineShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 240 SAL_DLLPRIVATE void ImpExportEllipseShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 241 SAL_DLLPRIVATE void ImpExportPolygonShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 242 SAL_DLLPRIVATE void ImpExportTextBoxShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 243 SAL_DLLPRIVATE void ImpExportGraphicObjectShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 244 SAL_DLLPRIVATE void ImpExportChartShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL, SvXMLAttributeList* pAttrList = NULL ); 245 SAL_DLLPRIVATE void ImpExportControlShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 246 SAL_DLLPRIVATE void ImpExportConnectorShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 247 SAL_DLLPRIVATE void ImpExportMeasureShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 248 SAL_DLLPRIVATE void ImpExportOLE2Shape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL, SvXMLAttributeList* pAttrList = NULL ); 249 SAL_DLLPRIVATE void ImpExportPageShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 250 SAL_DLLPRIVATE void ImpExportCaptionShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 251 SAL_DLLPRIVATE void ImpExport3DShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 252 SAL_DLLPRIVATE void ImpExportFrameShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 253 SAL_DLLPRIVATE void ImpExportPluginShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 254 SAL_DLLPRIVATE void ImpExportAppletShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 255 SAL_DLLPRIVATE void ImpExportCustomShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 256 SAL_DLLPRIVATE void ImpExportMediaShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 257 SAL_DLLPRIVATE void ImpExportTableShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); 258 public: 259 XMLShapeExport(SvXMLExport& rExp, SvXMLExportPropertyMapper *pExtMapper=0 ); 260 virtual ~XMLShapeExport(); 261 262 // This method collects all automatic styles for the given XShape 263 void collectShapeAutoStyles( 264 const com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& xShape); 265 266 // This method exports the given XShape 267 void exportShape( 268 const com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& xShape, 269 sal_Int32 nFeatures = SEF_DEFAULT, 270 com::sun::star::awt::Point* pRefPoint = NULL, 271 SvXMLAttributeList* pAttrList = NULL 272 ); 273 274 // This method collects all automatic styles for the shapes inside the given XShapes collection 275 void collectShapesAutoStyles( 276 const com::sun::star::uno::Reference < com::sun::star::drawing::XShapes >& xShapes); 277 278 // This method exports all XShape inside the given XShapes collection 279 void exportShapes( 280 const com::sun::star::uno::Reference < com::sun::star::drawing::XShapes >& xShapes, 281 sal_Int32 nFeatures = SEF_DEFAULT, 282 com::sun::star::awt::Point* pRefPoint = NULL 283 ); 284 285 /** initializes some internal structures for fast access to the given XShapes collection 286 287 <p>This method has to be called before you use exportShape or collectShapeAutoStyles. 288 It is automaticly called if you use collectShapesAutoStyles and exportShapes. 289 290 @see collectShapeAutoStyles 291 @see exportShape 292 @see collectShapesAutoStyles 293 @see exportShapes 294 */ 295 void seekShapes( 296 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes ) throw(); 297 298 void exportAutoStyles(); 299 300 /** sets a new reference to an XMLAnimationExporter. 301 If this is a non NULL reference, the animation information from all shapes given to exportShape() 302 from now on are collected. 303 */ 304 void setAnimationsExporter( UniReference< XMLAnimationsExporter > xAnimExport ) { mxAnimationsExporter = xAnimExport; } 305 306 /** returns the last set XMLAnimationExport */ 307 UniReference< XMLAnimationsExporter > getAnimationsExporter() const { return mxAnimationsExporter; } 308 309 /// returns the export property mapper for external chaining 310 static SvXMLExportPropertyMapper* CreateShapePropMapper( SvXMLExport& rExport ); 311 312 void enableLayerExport( sal_Bool bEnable = sal_True ) { mbExportLayer = bEnable; } 313 sal_Bool IsLayerExportEnabled() const { return mbExportLayer; } 314 315 // #88546# 316 /** defines if the export should increment the progress bar or not */ 317 void enableHandleProgressBar( sal_Bool bEnable = sal_True ) { mbHandleProgressBar = bEnable; } 318 sal_Bool IsHandleProgressBarEnabled() const { return mbHandleProgressBar; } 319 320 void setPresentationStylePrefix( const rtl::OUString& rPrefix ) { msPresentationStylePrefix = rPrefix; } 321 322 /** helper for chart that adds all attributes of a 3d scene element to the export */ 323 void export3DSceneAttributes( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet ); 324 325 /** helper for chart that exports all lamps from the propertyset */ 326 void export3DLamps( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet ); 327 328 /** sj: replacing CustomShapes with standard objects that are also supported in OpenOffice.org format */ 329 com::sun::star::uno::Reference < com::sun::star::drawing::XShape > checkForCustomShapeReplacement( 330 const com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& ); 331 332 /** helper to export the style for graphic defaults */ 333 void ExportGraphicDefaults(); 334 335 /** is called before a shape element for the given XShape is exported */ 336 virtual void onExport( const com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& xShape ); 337 338 const rtl::Reference< XMLTableExport >& GetShapeTableExport(); 339 }; 340 341 342 #endif 343