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 // dr3d:3dlight context
49 
51 {
52  // local parameters which need to be read
53  sal_Int32 maDiffuseColor;
55  bool mbEnabled;
56  bool mbSpecular;
57 
58 public:
60  SvXMLImport& rImport,
61  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList);
62  virtual ~SdXML3DLightContext() override;
63 
64  sal_Int32 GetDiffuseColor() const { return maDiffuseColor; }
65  const ::basegfx::B3DVector& GetDirection() const { return maDirection; }
66  bool GetEnabled() const { return mbEnabled; }
67 };
68 
69 
71 {
72 protected:
74 
75  // list for local light contexts
76  ::std::vector< rtl::Reference< SdXML3DLightContext > >
78 
79  // local parameters which need to be read
80  css::drawing::HomogenMatrix mxHomMat;
82 
83  css::drawing::ProjectionMode mxPrjMode;
84  sal_Int32 mnDistance;
85  sal_Int32 mnFocalLength;
86  sal_Int32 mnShadowSlant;
87  css::drawing::ShadeMode mxShadeMode;
88  sal_Int32 maAmbientColor;
90 
94  bool mbVRPUsed;
95  bool mbVPNUsed;
96  bool mbVUPUsed;
97 
98 public:
100 
102  SvXMLImportContext * create3DLightContext( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList);
103 
106 
108  void setSceneAttributes( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
109 };
110 
111 
113 {
114 protected:
115  css::uno::Reference< css::drawing::XShape > mxShape;
117  OUString msHyperlink;
118 
119 public:
120  SvXMLShapeContext( SvXMLImport& rImp, bool bTemporaryShape ) : SvXMLImportContext( rImp ), mbTemporaryShape(bTemporaryShape) {}
121 
122 
123  const css::uno::Reference< css::drawing::XShape >& getShape() const { return mxShape; }
124 
125  void setHyperlink( const OUString& rHyperlink );
126 };
127 
128 
131 struct SdXMLEventContextData;
132 
134 {
135  std::unique_ptr<XMLShapeImportHelperImpl> mpImpl;
136 
137  std::shared_ptr<XMLShapeImportPageContextImpl> mpPageContext;
138 
139  // PropertySetMappers and factory
143 
144  // contexts for Style and AutoStyle import
147 
149 
150 protected:
152 
153 public:
154  XMLShapeImportHelper( SvXMLImport& rImporter,
155  const css::uno::Reference< css::frame::XModel>& rModel,
156  SvXMLImportPropertyMapper *pExtMapper=nullptr );
157 
158  virtual ~XMLShapeImportHelper() override;
159 
160  static SvXMLShapeContext* CreateGroupChildContext(
161  SvXMLImport& rImport, sal_Int32 nElement,
162  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
163  css::uno::Reference< css::drawing::XShapes > const & rShapes,
164  bool bTemporaryShape = false);
165 
166  static SvXMLShapeContext* CreateFrameChildContext(
167  SvXMLImport& rImport, sal_Int32 nElement,
168  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
169  css::uno::Reference< css::drawing::XShapes > const & rShapes,
170  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xFrameAttrList);
171  static css::uno::Reference< css::xml::sax::XFastContextHandler > CreateFrameChildContext(
172  SvXMLImportContext *pThisContext, sal_Int32 nElement,
173  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList );
174 
175  static SvXMLShapeContext* Create3DSceneChildContext(
176  SvXMLImport& rImport, sal_Int32 nElement,
177  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
178  css::uno::Reference< css::drawing::XShapes > const & rShapes);
179 
180  // Styles and AutoStyles contexts
181  SvXMLStylesContext* GetStylesContext() const { return mxStylesContext.get(); }
182  void SetStylesContext(SvXMLStylesContext* pNew);
183  SvXMLStylesContext* GetAutoStylesContext() const { return mxAutoStylesContext.get(); }
184  void SetAutoStylesContext(SvXMLStylesContext* pNew);
185 
186  // get factories and mappers
187  SvXMLImportPropertyMapper* GetPropertySetMapper() const { return mpPropertySetMapper.get(); }
188  SvXMLImportPropertyMapper* GetPresPagePropsMapper() const { return mpPresPagePropsMapper.get(); }
189 
190  // this function is called whenever the implementation classes like to add this new
191  // shape to the given XShapes.
192  virtual void addShape(
193  css::uno::Reference< css::drawing::XShape >& rShape,
194  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
195  css::uno::Reference< css::drawing::XShapes >& rShapes);
196 
197  // this function is called whenever the implementation classes have finished importing
198  // a shape to the given XShapes. The shape is already inserted into its XShapes and
199  // all properties and styles are set.
200  virtual void finishShape(
201  css::uno::Reference< css::drawing::XShape >& rShape,
202  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
203  css::uno::Reference< css::drawing::XShapes >& rShapes);
204 
205  // tdf#127791 help function for group shape events
206  void addShapeEvents(SdXMLEventContextData& rData);
207 
208  // helper functions processing groups after their component shapes are collected
209  // e.g. for z-order sorting or adding events to the group
210  void pushGroupForPostProcessing( css::uno::Reference< css::drawing::XShapes >& rShapes );
211  void popGroupAndPostProcess();
212 
213  void shapeWithZIndexAdded( css::uno::Reference< css::drawing::XShape > const & rShape,
214  sal_Int32 nZIndex );
217  void shapeRemoved(const css::uno::Reference<css::drawing::XShape>& rShape);
218 
219  void addShapeConnection( css::uno::Reference< css::drawing::XShape > const & rConnectorShape,
220  bool bStart,
221  const OUString& rDestShapeId,
222  sal_Int32 nDestGlueId );
223 
226  void addGluePointMapping( css::uno::Reference< css::drawing::XShape > const & xShape,
227  sal_Int32 nSourceId, sal_Int32 nDestinnationId );
228 
230  void moveGluePointMapping( const css::uno::Reference< css::drawing::XShape >& xShape, const sal_Int32 n );
231 
234  sal_Int32 getGluePointId( const css::uno::Reference< css::drawing::XShape >& xShape, sal_Int32 nSourceId );
235 
238  void startPage( css::uno::Reference< css::drawing::XShapes > const & rShapes );
239 
242  void endPage( css::uno::Reference< css::drawing::XShapes > const & rShapes );
243 
244  void restoreConnections();
245 
247  static SvXMLImportPropertyMapper* CreateShapePropMapper(
248  const css::uno::Reference< css::frame::XModel>& rModel, SvXMLImport& rImport );
249 
251  void enableHandleProgressBar();
252  bool IsHandleProgressBarEnabled() const;
253 
255  bool IsPresentationShapesSupported() const;
256 
257  XMLSdPropHdlFactory* GetSdPropHdlFactory() const { return mpSdPropHdlFactory.get(); }
258 
259  const rtl::Reference< XMLTableImport >& GetShapeTableImport();
260 };
261 
262 #endif // INCLUDED_XMLOFF_SHAPEIMPORT_HXX
263 
264 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference< SvXMLImportPropertyMapper > mpPresPagePropsMapper
sal_Int32 GetDiffuseColor() const
Definition: shapeimport.hxx:64
void setSceneAttributes(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
this sets the scene attributes at this propertyset
XMLSdPropHdlFactory * GetSdPropHdlFactory() const
void processSceneAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter)
this should be called for each scene attribute
rtl::Reference< SvXMLImportPropertyMapper > mpPropertySetMapper
void setHyperlink(const OUString &rHyperlink)
SvXMLImportPropertyMapper * GetPresPagePropsMapper() const
sal_Int32 maDiffuseColor
Definition: shapeimport.hxx:53
SdXML3DLightContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Definition: ximp3dscene.cxx:40
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
bool GetEnabled() const
Definition: shapeimport.hxx:66
::basegfx::B3DVector maVUP
Definition: shapeimport.hxx:93
virtual ~SdXML3DLightContext() override
Definition: ximp3dscene.cxx:89
css::drawing::ShadeMode mxShadeMode
Definition: shapeimport.hxx:87
::basegfx::B3DVector maVPN
Definition: shapeimport.hxx:92
rtl::Reference< SvXMLStylesContext > mxStylesContext
class SAL_NO_VTABLE XPropertySet
SdXML3DSceneAttributesHelper(SvXMLImport &rImporter)
SvXMLImport & mrImporter
css::uno::Reference< css::drawing::XShape > mxShape
const ::basegfx::B3DVector & GetDirection() const
Definition: shapeimport.hxx:65
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
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:45
std::shared_ptr< XMLShapeImportPageContextImpl > mpPageContext
::basegfx::B3DVector maDirection
Definition: shapeimport.hxx:54
rtl::Reference< XMLSdPropHdlFactory > mpSdPropHdlFactory
this struct is created for each startPage() call and stores information that is needed during import ...
Definition: shapeimport.cxx:91
css::drawing::ProjectionMode mxPrjMode
Definition: shapeimport.hxx:83
::basegfx::B3DVector maVRP
Definition: shapeimport.hxx:91
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
Definition: shapeimport.hxx:77
css::drawing::HomogenMatrix mxHomMat
Definition: shapeimport.hxx:80