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 #include <sax/fastattribs.hxx>
31 
33 #include <vector>
34 #include <memory>
35 
36 namespace com::sun::star::beans { class XPropertySet; }
37 namespace com::sun::star::drawing { class XShape; }
38 namespace com::sun::star::drawing { class XShapes; }
39 namespace com::sun::star::frame { class XModel; }
40 namespace com::sun::star::xml::sax { class XAttributeList; }
41 
42 class SvXMLImport;
43 class SvXMLTokenMap;
44 class SvXMLStylesContext;
47 class XMLTableImport;
48 
49 // dr3d:3dlight context
50 
52 {
53  // local parameters which need to be read
54  sal_Int32 maDiffuseColor;
56  bool mbEnabled;
57  bool mbSpecular;
58 
59 public:
61  SvXMLImport& rImport,
62  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList);
63  virtual ~SdXML3DLightContext() override;
64 
65  sal_Int32 GetDiffuseColor() const { return maDiffuseColor; }
66  const ::basegfx::B3DVector& GetDirection() const { return maDirection; }
67  bool GetEnabled() const { return mbEnabled; }
68 };
69 
70 
72 {
73 protected:
75 
76  // list for local light contexts
77  ::std::vector< rtl::Reference< SdXML3DLightContext > >
79 
80  // local parameters which need to be read
81  css::drawing::HomogenMatrix mxHomMat;
83 
84  css::drawing::ProjectionMode mxPrjMode;
85  sal_Int32 mnDistance;
86  sal_Int32 mnFocalLength;
87  sal_Int32 mnShadowSlant;
88  css::drawing::ShadeMode mxShadeMode;
89  sal_Int32 maAmbientColor;
91 
95  bool mbVRPUsed;
96 
97 public:
99 
101  SvXMLImportContext * create3DLightContext( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList);
102 
105 
107  void setSceneAttributes( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
108 };
109 
110 
112 {
113 protected:
114  css::uno::Reference< css::drawing::XShape > mxShape;
116  OUString msHyperlink;
117 
118 public:
119  SvXMLShapeContext( SvXMLImport& rImp, bool bTemporaryShape ) : SvXMLImportContext( rImp ), mbTemporaryShape(bTemporaryShape) {}
120 
121 
122  const css::uno::Reference< css::drawing::XShape >& getShape() const { return mxShape; }
123 
124  void setHyperlink( const OUString& rHyperlink );
125 };
126 
127 
130 struct SdXMLEventContextData;
131 
133 {
134  std::unique_ptr<XMLShapeImportHelperImpl> mpImpl;
135 
136  std::shared_ptr<XMLShapeImportPageContextImpl> mpPageContext;
137 
138  // PropertySetMappers and factory
142 
143  // contexts for Style and AutoStyle import
146 
148 
149 protected:
151 
152 public:
153  XMLShapeImportHelper( SvXMLImport& rImporter,
154  const css::uno::Reference< css::frame::XModel>& rModel,
155  SvXMLImportPropertyMapper *pExtMapper=nullptr );
156 
157  virtual ~XMLShapeImportHelper() override;
158 
159  static SvXMLShapeContext* CreateGroupChildContext(
160  SvXMLImport& rImport, sal_Int32 nElement,
161  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
162  css::uno::Reference< css::drawing::XShapes > const & rShapes,
163  bool bTemporaryShape = false);
164 
165  static SvXMLShapeContext* CreateFrameChildContext(
166  SvXMLImport& rImport, sal_Int32 nElement,
167  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
168  css::uno::Reference< css::drawing::XShapes > const & rShapes,
169  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xFrameAttrList);
170  static css::uno::Reference< css::xml::sax::XFastContextHandler > CreateFrameChildContext(
171  SvXMLImportContext *pThisContext, sal_Int32 nElement,
172  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList );
173 
174  static SvXMLShapeContext* Create3DSceneChildContext(
175  SvXMLImport& rImport, sal_Int32 nElement,
176  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
177  css::uno::Reference< css::drawing::XShapes > const & rShapes);
178 
179  // Styles and AutoStyles contexts
180  SvXMLStylesContext* GetStylesContext() const { return mxStylesContext.get(); }
181  void SetStylesContext(SvXMLStylesContext* pNew);
182  SvXMLStylesContext* GetAutoStylesContext() const { return mxAutoStylesContext.get(); }
183  void SetAutoStylesContext(SvXMLStylesContext* pNew);
184 
185  // get factories and mappers
186  SvXMLImportPropertyMapper* GetPropertySetMapper() const { return mpPropertySetMapper.get(); }
187  SvXMLImportPropertyMapper* GetPresPagePropsMapper() const { return mpPresPagePropsMapper.get(); }
188 
189  // this function is called whenever the implementation classes like to add this new
190  // shape to the given XShapes.
191  virtual void addShape(
192  css::uno::Reference< css::drawing::XShape >& rShape,
193  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
194  css::uno::Reference< css::drawing::XShapes >& rShapes);
195 
196  // this function is called whenever the implementation classes have finished importing
197  // a shape to the given XShapes. The shape is already inserted into its XShapes and
198  // all properties and styles are set.
199  virtual void finishShape(
200  css::uno::Reference< css::drawing::XShape >& rShape,
201  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
202  css::uno::Reference< css::drawing::XShapes >& rShapes);
203 
204  // tdf#127791 help function for group shape events
205  void addShapeEvents(SdXMLEventContextData& rData);
206 
207  // helper functions processing groups after their component shapes are collected
208  // e.g. for z-order sorting or adding events to the group
209  void pushGroupForPostProcessing( css::uno::Reference< css::drawing::XShapes >& rShapes );
210  void popGroupAndPostProcess();
211 
212  void shapeWithZIndexAdded( css::uno::Reference< css::drawing::XShape > const & rShape,
213  sal_Int32 nZIndex );
216  void shapeRemoved(const css::uno::Reference<css::drawing::XShape>& rShape);
217 
218  void addShapeConnection( css::uno::Reference< css::drawing::XShape > const & rConnectorShape,
219  bool bStart,
220  const OUString& rDestShapeId,
221  sal_Int32 nDestGlueId );
222 
225  void addGluePointMapping( css::uno::Reference< css::drawing::XShape > const & xShape,
226  sal_Int32 nSourceId, sal_Int32 nDestinnationId );
227 
229  void moveGluePointMapping( const css::uno::Reference< css::drawing::XShape >& xShape, const sal_Int32 n );
230 
233  sal_Int32 getGluePointId( const css::uno::Reference< css::drawing::XShape >& xShape, sal_Int32 nSourceId );
234 
237  void startPage( css::uno::Reference< css::drawing::XShapes > const & rShapes );
238 
241  void endPage( css::uno::Reference< css::drawing::XShapes > const & rShapes );
242 
243  void restoreConnections();
244 
246  static SvXMLImportPropertyMapper* CreateShapePropMapper(
247  const css::uno::Reference< css::frame::XModel>& rModel, SvXMLImport& rImport );
248 
250  void enableHandleProgressBar();
251  bool IsHandleProgressBarEnabled() const;
252 
254  bool IsPresentationShapesSupported() const;
255 
256  XMLSdPropHdlFactory* GetSdPropHdlFactory() const { return mpSdPropHdlFactory.get(); }
257 
258  const rtl::Reference< XMLTableImport >& GetShapeTableImport();
259 };
260 
261 #endif // INCLUDED_XMLOFF_SHAPEIMPORT_HXX
262 
263 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference< SvXMLImportPropertyMapper > mpPresPagePropsMapper
sal_Int32 GetDiffuseColor() const
Definition: shapeimport.hxx:65
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:54
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:67
::basegfx::B3DVector maVUP
Definition: shapeimport.hxx:94
virtual ~SdXML3DLightContext() override
Definition: ximp3dscene.cxx:89
css::drawing::ShadeMode mxShadeMode
Definition: shapeimport.hxx:88
::basegfx::B3DVector maVPN
Definition: shapeimport.hxx:93
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:66
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:44
std::shared_ptr< XMLShapeImportPageContextImpl > mpPageContext
::basegfx::B3DVector maDirection
Definition: shapeimport.hxx:55
rtl::Reference< XMLSdPropHdlFactory > mpSdPropHdlFactory
this struct is created for each startPage() call and stores information that is needed during import ...
Definition: shapeimport.cxx:82
css::drawing::ProjectionMode mxPrjMode
Definition: shapeimport.hxx:84
::basegfx::B3DVector maVRP
Definition: shapeimport.hxx:92
SvXMLImportPropertyMapper * GetPropertySetMapper() const
this class is to enable adding members to the XMLShapeImportHelper without getting incompatible ...
Definition: shapeimport.cxx:92
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
::std::vector< rtl::Reference< SdXML3DLightContext > > maList
Definition: shapeimport.hxx:78
css::drawing::HomogenMatrix mxHomMat
Definition: shapeimport.hxx:81