LibreOffice Module xmloff (master)  1
shapeimport.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_XMLOFF_SHAPEIMPORT_HXX
21 #define INCLUDED_XMLOFF_SHAPEIMPORT_HXX
22 
23 #include <sal/config.h>
24 #include <xmloff/dllapi.h>
25 #include <com/sun/star/drawing/HomogenMatrix.hpp>
26 #include <com/sun/star/drawing/ProjectionMode.hpp>
27 #include <com/sun/star/drawing/ShadeMode.hpp>
29 #include <xmloff/xmlictxt.hxx>
30 
32 #include <vector>
33 #include <memory>
34 
35 namespace com::sun::star::beans { class XPropertySet; }
36 namespace com::sun::star::drawing { class XShape; }
37 namespace com::sun::star::drawing { class XShapes; }
38 namespace com::sun::star::frame { class XModel; }
39 namespace com::sun::star::xml::sax { class XAttributeList; }
40 
41 class SvXMLImport;
42 class SvXMLTokenMap;
43 class SvXMLStylesContext;
46 class XMLTableImport;
47 
48 
50 {
59 
65 
68 
70 
72 
74 
76 };
77 
79 {
88 };
89 
91 {
97 };
98 
100 {
103 };
104 
106 {
109 };
110 
112 {
115 };
116 
118 {
121 };
122 
124 {
129 };
130 
131 
132 // dr3d:3dlight context
133 
135 {
136  // local parameters which need to be read
137  sal_Int32 maDiffuseColor;
139  bool mbEnabled;
141 
142 public:
144  SvXMLImport& rImport,
145  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList);
146  virtual ~SdXML3DLightContext() override;
147 
148  sal_Int32 GetDiffuseColor() const { return maDiffuseColor; }
149  const ::basegfx::B3DVector& GetDirection() const { return maDirection; }
150  bool GetEnabled() const { return mbEnabled; }
151 };
152 
153 
155 {
156 protected:
158 
159  // list for local light contexts
160  ::std::vector< rtl::Reference< SdXML3DLightContext > >
162 
163  // local parameters which need to be read
164  css::drawing::HomogenMatrix mxHomMat;
166 
167  css::drawing::ProjectionMode mxPrjMode;
168  sal_Int32 mnDistance;
169  sal_Int32 mnFocalLength;
170  sal_Int32 mnShadowSlant;
171  css::drawing::ShadeMode mxShadeMode;
172  sal_Int32 maAmbientColor;
174 
178  bool mbVRPUsed;
179  bool mbVPNUsed;
180  bool mbVUPUsed;
181 
182 public:
184 
186  SvXMLImportContext * create3DLightContext( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList);
187 
189  void processSceneAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue );
190 
192  void setSceneAttributes( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
193 };
194 
195 
197 {
198 protected:
199  css::uno::Reference< css::drawing::XShape > mxShape;
201  OUString msHyperlink;
202 
203 public:
204  SvXMLShapeContext( SvXMLImport& rImp, bool bTemporaryShape ) : SvXMLImportContext( rImp ), mbTemporaryShape(bTemporaryShape) {}
205 
206 
207  const css::uno::Reference< css::drawing::XShape >& getShape() const { return mxShape; }
208 
209  void setHyperlink( const OUString& rHyperlink );
210 };
211 
212 
215 struct SdXMLEventContextData;
216 
218 {
219  std::unique_ptr<XMLShapeImportHelperImpl> mpImpl;
220 
221  std::shared_ptr<XMLShapeImportPageContextImpl> mpPageContext;
222 
223  // PropertySetMappers and factory
227 
228  // contexts for Style and AutoStyle import
231 
232  // contexts for xShape contents TokenMaps
233  std::unique_ptr<SvXMLTokenMap> mpGroupShapeElemTokenMap;
234  std::unique_ptr<SvXMLTokenMap> mpFrameShapeElemTokenMap;
235  std::unique_ptr<SvXMLTokenMap> mp3DSceneShapeElemTokenMap;
236  std::unique_ptr<SvXMLTokenMap> mp3DObjectAttrTokenMap;
237  std::unique_ptr<SvXMLTokenMap> mp3DPolygonBasedAttrTokenMap;
238  std::unique_ptr<SvXMLTokenMap> mp3DCubeObjectAttrTokenMap;
239  std::unique_ptr<SvXMLTokenMap> mp3DSphereObjectAttrTokenMap;
240  std::unique_ptr<SvXMLTokenMap> mp3DLightAttrTokenMap;
241 
243 
244 protected:
246 
247 public:
248  XMLShapeImportHelper( SvXMLImport& rImporter,
249  const css::uno::Reference< css::frame::XModel>& rModel,
250  SvXMLImportPropertyMapper *pExtMapper=nullptr );
251 
252  virtual ~XMLShapeImportHelper() override;
253 
254  SvXMLShapeContext* CreateGroupChildContext(
255  SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
256  const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList,
257  css::uno::Reference< css::drawing::XShapes > const & rShapes,
258  bool bTemporaryShape = false);
259 
260  SvXMLShapeContext* CreateFrameChildContext(
261  SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
262  const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList,
263  css::uno::Reference< css::drawing::XShapes > const & rShapes,
264  const css::uno::Reference< css::xml::sax::XAttributeList >& xFrameAttrList);
265  static SvXMLImportContextRef CreateFrameChildContext(
266  SvXMLImportContext *pThisContext, sal_uInt16 nPrefix, const OUString& rLocalName,
267  const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList );
268 
269  SvXMLShapeContext* Create3DSceneChildContext(
270  SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
271  const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList,
272  css::uno::Reference< css::drawing::XShapes > const & rShapes);
273 
274  const SvXMLTokenMap& GetGroupShapeElemTokenMap();
275  const SvXMLTokenMap& GetFrameShapeElemTokenMap();
276  const SvXMLTokenMap& Get3DSceneShapeElemTokenMap();
277  const SvXMLTokenMap& Get3DObjectAttrTokenMap();
278  const SvXMLTokenMap& Get3DPolygonBasedAttrTokenMap();
279  const SvXMLTokenMap& Get3DCubeObjectAttrTokenMap();
280  const SvXMLTokenMap& Get3DSphereObjectAttrTokenMap();
281  const SvXMLTokenMap& Get3DLightAttrTokenMap();
282 
283  // Styles and AutoStyles contexts
284  SvXMLStylesContext* GetStylesContext() const { return mxStylesContext.get(); }
285  void SetStylesContext(SvXMLStylesContext* pNew);
286  SvXMLStylesContext* GetAutoStylesContext() const { return mxAutoStylesContext.get(); }
287  void SetAutoStylesContext(SvXMLStylesContext* pNew);
288 
289  // get factories and mappers
290  SvXMLImportPropertyMapper* GetPropertySetMapper() const { return mpPropertySetMapper.get(); }
291  SvXMLImportPropertyMapper* GetPresPagePropsMapper() const { return mpPresPagePropsMapper.get(); }
292 
293  // this function is called whenever the implementation classes like to add this new
294  // shape to the given XShapes.
295  virtual void addShape(
296  css::uno::Reference< css::drawing::XShape >& rShape,
297  const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList,
298  css::uno::Reference< css::drawing::XShapes >& rShapes);
299 
300  // this function is called whenever the implementation classes have finished importing
301  // a shape to the given XShapes. The shape is already inserted into its XShapes and
302  // all properties and styles are set.
303  virtual void finishShape(
304  css::uno::Reference< css::drawing::XShape >& rShape,
305  const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList,
306  css::uno::Reference< css::drawing::XShapes >& rShapes);
307 
308  // tdf#127791 help function for group shape events
309  void addShapeEvents(SdXMLEventContextData& rData);
310 
311  // helper functions processing groups after their component shapes are collected
312  // e.g. for z-order sorting or adding events to the group
313  void pushGroupForPostProcessing( css::uno::Reference< css::drawing::XShapes >& rShapes );
314  void popGroupAndPostProcess();
315 
316  void shapeWithZIndexAdded( css::uno::Reference< css::drawing::XShape > const & rShape,
317  sal_Int32 nZIndex );
320  void shapeRemoved(const css::uno::Reference<css::drawing::XShape>& rShape);
321 
322  void addShapeConnection( css::uno::Reference< css::drawing::XShape > const & rConnectorShape,
323  bool bStart,
324  const OUString& rDestShapeId,
325  sal_Int32 nDestGlueId );
326 
329  void addGluePointMapping( css::uno::Reference< css::drawing::XShape > const & xShape,
330  sal_Int32 nSourceId, sal_Int32 nDestinnationId );
331 
333  void moveGluePointMapping( const css::uno::Reference< css::drawing::XShape >& xShape, const sal_Int32 n );
334 
337  sal_Int32 getGluePointId( const css::uno::Reference< css::drawing::XShape >& xShape, sal_Int32 nSourceId );
338 
341  void startPage( css::uno::Reference< css::drawing::XShapes > const & rShapes );
342 
345  void endPage( css::uno::Reference< css::drawing::XShapes > const & rShapes );
346 
347  void restoreConnections();
348 
350  static SvXMLImportPropertyMapper* CreateShapePropMapper(
351  const css::uno::Reference< css::frame::XModel>& rModel, SvXMLImport& rImport );
352 
354  void enableHandleProgressBar();
355  bool IsHandleProgressBarEnabled() const;
356 
358  bool IsPresentationShapesSupported() const;
359 
360  XMLSdPropHdlFactory* GetSdPropHdlFactory() const { return mpSdPropHdlFactory.get(); }
361 
362  const rtl::Reference< XMLTableImport >& GetShapeTableImport();
363 };
364 
365 #endif // INCLUDED_XMLOFF_SHAPEIMPORT_HXX
366 
367 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference< SvXMLImportPropertyMapper > mpPresPagePropsMapper
std::unique_ptr< SvXMLTokenMap > mpGroupShapeElemTokenMap
std::unique_ptr< SvXMLTokenMap > mp3DObjectAttrTokenMap
SdXML3DCubeObjectAttrTokenMap
sal_Int32 GetDiffuseColor() const
std::unique_ptr< SvXMLTokenMap > mpFrameShapeElemTokenMap
void setSceneAttributes(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
this sets the scene attributes at this propertyset
XMLSdPropHdlFactory * GetSdPropHdlFactory() const
SdXML3DLightAttrTokenMap
rtl::Reference< SvXMLImportPropertyMapper > mpPropertySetMapper
void setHyperlink(const OUString &rHyperlink)
SvXMLImportPropertyMapper * GetPresPagePropsMapper() const
sal_Int32 maDiffuseColor
SdXML3DLightContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Definition: ximp3dscene.cxx:40
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
std::unique_ptr< SvXMLTokenMap > mp3DCubeObjectAttrTokenMap
rtl::Reference< XMLTableImport > mxShapeTableImport
SvXMLStylesContext * GetStylesContext() const
SvXMLShapeContext(SvXMLImport &rImp, bool bTemporaryShape)
const css::uno::Reference< css::drawing::XShape > & getShape() const
rtl::Reference< SvXMLStylesContext > mxAutoStylesContext
SdXML3DPolygonBasedAttrTokenMap
bool GetEnabled() const
::basegfx::B3DVector maVUP
std::unique_ptr< SvXMLTokenMap > mp3DSphereObjectAttrTokenMap
std::unique_ptr< SvXMLTokenMap > mp3DLightAttrTokenMap
virtual ~SdXML3DLightContext() override
Definition: ximp3dscene.cxx:90
css::drawing::ShadeMode mxShadeMode
::basegfx::B3DVector maVPN
rtl::Reference< SvXMLStylesContext > mxStylesContext
class SAL_NO_VTABLE XPropertySet
SdXML3DSceneAttributesHelper(SvXMLImport &rImporter)
SvXMLImport & mrImporter
std::unique_ptr< SvXMLTokenMap > mp3DSceneShapeElemTokenMap
css::uno::Reference< css::drawing::XShape > mxShape
const ::basegfx::B3DVector & GetDirection() const
void processSceneAttribute(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rValue)
this should be called for each scene attribute
SdXML3DObjectAttrTokenMap
Definition: shapeimport.hxx:99
SvXMLStylesContext * GetAutoStylesContext() const
SvXMLImportContext * create3DLightContext(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
creates a 3d light context and adds it to the internal list for later processing
std::unique_ptr< XMLShapeImportHelperImpl > mpImpl
SdXMLGroupShapeElemTokenMap
Definition: shapeimport.hxx:49
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:45
SdXML3DSphereObjectAttrTokenMap
std::shared_ptr< XMLShapeImportPageContextImpl > mpPageContext
::basegfx::B3DVector maDirection
rtl::Reference< XMLSdPropHdlFactory > mpSdPropHdlFactory
this struct is created for each startPage() call and stores information that is needed during import ...
Definition: shapeimport.cxx:90
SdXML3DSceneShapeElemTokenMap
Definition: shapeimport.hxx:90
SdXMLFrameShapeElemTokenMap
Definition: shapeimport.hxx:78
std::unique_ptr< SvXMLTokenMap > mp3DPolygonBasedAttrTokenMap
css::drawing::ProjectionMode mxPrjMode
::basegfx::B3DVector maVRP
SvXMLImportPropertyMapper * GetPropertySetMapper() const
this class is to enable adding members to the XMLShapeImportHelper without getting incompatible ...
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
::std::vector< rtl::Reference< SdXML3DLightContext > > maList
css::drawing::HomogenMatrix mxHomMat