1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_XMLOFF_SOURCE_DRAW_XIMPSHAP_HXX
21 #define INCLUDED_XMLOFF_SOURCE_DRAW_XIMPSHAP_HXX
23 #include <com/sun/star/io/XOutputStream.hpp>
24 #include <com/sun/star/document/XActionLockable.hpp>
25 #include <com/sun/star/drawing/Alignment.hpp>
26 #include <com/sun/star/drawing/CircleKind.hpp>
27 #include <com/sun/star/drawing/ConnectorType.hpp>
28 #include <com/sun/star/drawing/EscapeDirection.hpp>
29 #include <com/sun/star/container/XIdentifierContainer.hpp>
30 #include <xmloff/xmlictxt.hxx>
31 #include <com/sun/star/drawing/XShapes.hpp>
32 #include <com/sun/star/text/XTextCursor.hpp>
33 #include <com/sun/star/awt/Point.hpp>
34 #include <xexptran.hxx>
36 #include <xmloff/shapeimport.hxx>
37 #include <xmlmultiimagehelper.hxx>
38 #include <basegfx/matrix/b2dhommatrix.hxx>
40 template<typename EnumT
> struct SvXMLEnumMapEntry
;
42 // common shape context
44 class SdXMLShapeContext
: public SvXMLShapeContext
47 // the shape group this object should be created inside
48 css::uno::Reference
< css::drawing::XShapes
> mxShapes
;
49 css::uno::Reference
< css::text::XTextCursor
> mxCursor
;
50 css::uno::Reference
< css::text::XTextCursor
> mxOldCursor
;
51 css::uno::Reference
< css::xml::sax::XAttributeList
> mxAttrList
;
52 css::uno::Reference
< css::container::XIdentifierContainer
> mxGluePoints
;
53 css::uno::Reference
< css::document::XActionLockable
> mxLockable
;
55 OUString maDrawStyleName
;
56 OUString maTextStyleName
;
57 OUString maPresentationClass
;
59 OUString maThumbnailURL
;
61 /// whether to restore list context (#91964#)
62 bool mbListContextPushed
;
64 XmlStyleFamily mnStyleFamily
;
66 bool mbClearDefaultAttributes
;
67 bool mbIsUserTransformed
;
72 SdXMLImExTransform2D mnTransform
;
73 css::awt::Size maSize
;
75 sal_Int16 mnRelHeight
;
76 css::awt::Point maPosition
;
77 basegfx::B2DHomMatrix maUsedTransformation
;
82 bool mbTextBox
; ///< If the text of this shape is handled by a Writer TextFrame.
84 /** if bSupportsStyle is false, auto styles will be set but not a style */
85 void SetStyle( bool bSupportsStyle
= true );
89 void AddShape(css::uno::Reference
< css::drawing::XShape
>& xShape
);
90 void AddShape(OUString
const & serviceName
);
91 void SetTransformation();
93 using SvXMLImportContext::GetImport
;
95 void addGluePoint( const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
);
97 bool isPresentationShape() const;
101 SdXMLShapeContext( SvXMLImport
& rImport
,
102 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
103 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
,
104 bool bTemporaryShape
);
105 virtual ~SdXMLShapeContext() override
;
107 virtual void StartElement(const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
108 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
110 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
, const OUString
& rLocalName
,
111 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
113 // this is called from the parent group for each unparsed attribute in the attribute list
114 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
);
120 class SdXMLRectShapeContext
: public SdXMLShapeContext
126 SdXMLRectShapeContext( SvXMLImport
& rImport
,
127 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
128 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
,
129 bool bTemporaryShape
);
130 virtual ~SdXMLRectShapeContext() override
;
131 virtual void StartElement(const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
133 // this is called from the parent group for each unparsed attribute in the attribute list
134 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
139 class SdXMLLineShapeContext
: public SdXMLShapeContext
148 SdXMLLineShapeContext( SvXMLImport
& rImport
,
149 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
150 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
,
151 bool bTemporaryShape
);
152 virtual ~SdXMLLineShapeContext() override
;
153 virtual void StartElement(const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
155 // this is called from the parent group for each unparsed attribute in the attribute list
156 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
159 // draw:ellipse and draw:circle context
161 class SdXMLEllipseShapeContext
: public SdXMLShapeContext
168 css::drawing::CircleKind meKind
;
169 sal_Int32 mnStartAngle
;
170 sal_Int32 mnEndAngle
;
173 SdXMLEllipseShapeContext( SvXMLImport
& rImport
,
174 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
175 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
,
176 bool bTemporaryShape
);
177 virtual ~SdXMLEllipseShapeContext() override
;
178 virtual void StartElement(const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
180 // this is called from the parent group for each unparsed attribute in the attribute list
181 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
184 // draw:polyline and draw:polygon context
186 class SdXMLPolygonShapeContext
: public SdXMLShapeContext
194 SdXMLPolygonShapeContext( SvXMLImport
& rImport
,
195 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
196 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
, bool bClosed
, bool bTemporaryShape
);
197 virtual ~SdXMLPolygonShapeContext() override
;
198 virtual void StartElement(const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
200 // this is called from the parent group for each unparsed attribute in the attribute list
201 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
206 class SdXMLPathShapeContext
: public SdXMLShapeContext
213 SdXMLPathShapeContext( SvXMLImport
& rImport
,
214 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
215 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
,
216 bool bTemporaryShape
);
217 virtual ~SdXMLPathShapeContext() override
;
218 virtual void StartElement(const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
220 // this is called from the parent group for each unparsed attribute in the attribute list
221 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
224 // draw:text-box context
226 class SdXMLTextBoxShapeContext
: public SdXMLShapeContext
229 OUString maChainNextName
;
233 SdXMLTextBoxShapeContext( SvXMLImport
& rImport
,
234 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
235 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
);
236 virtual ~SdXMLTextBoxShapeContext() override
;
237 virtual void StartElement(const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
239 // this is called from the parent group for each unparsed attribute in the attribute list
240 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
243 // draw:control context
245 class SdXMLControlShapeContext
: public SdXMLShapeContext
252 SdXMLControlShapeContext( SvXMLImport
& rImport
,
253 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
254 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
,
255 bool bTemporaryShape
);
256 virtual ~SdXMLControlShapeContext() override
;
257 virtual void StartElement(const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
259 // this is called from the parent group for each unparsed attribute in the attribute list
260 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
263 // draw:connector context
265 class SdXMLConnectorShapeContext
: public SdXMLShapeContext
268 css::awt::Point maStart
;
269 css::awt::Point maEnd
;
271 css::drawing::ConnectorType
274 OUString maStartShapeId
;
275 sal_Int32 mnStartGlueId
;
276 OUString maEndShapeId
;
277 sal_Int32 mnEndGlueId
;
283 css::uno::Any maPath
;
287 SdXMLConnectorShapeContext( SvXMLImport
& rImport
,
288 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
289 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
,
290 bool bTemporaryShape
);
291 virtual ~SdXMLConnectorShapeContext() override
;
292 virtual void StartElement(const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
294 // this is called from the parent group for each unparsed attribute in the attribute list
295 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
298 // draw:measure context
300 class SdXMLMeasureShapeContext
: public SdXMLShapeContext
303 css::awt::Point maStart
;
304 css::awt::Point maEnd
;
308 SdXMLMeasureShapeContext( SvXMLImport
& rImport
,
309 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
310 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
,
311 bool bTemporaryShape
);
312 virtual ~SdXMLMeasureShapeContext() override
;
313 virtual void StartElement(const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
314 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
316 // this is called from the parent group for each unparsed attribute in the attribute list
317 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
322 class SdXMLPageShapeContext
: public SdXMLShapeContext
325 sal_Int32 mnPageNumber
;
328 SdXMLPageShapeContext( SvXMLImport
& rImport
,
329 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
330 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
,
331 bool bTemporaryShape
);
332 virtual ~SdXMLPageShapeContext() override
;
333 virtual void StartElement(const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
335 // this is called from the parent group for each unparsed attribute in the attribute list
336 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
339 // draw:caption context
341 class SdXMLCaptionShapeContext
: public SdXMLShapeContext
344 css::awt::Point maCaptionPoint
;
349 SdXMLCaptionShapeContext( SvXMLImport
& rImport
,
350 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
351 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
,
352 bool bTemporaryShape
);
353 virtual ~SdXMLCaptionShapeContext() override
;
354 virtual void StartElement(const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
356 // this is called from the parent group for each unparsed attribute in the attribute list
357 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
360 // office:image context
362 class SdXMLGraphicObjectShapeContext
: public SdXMLShapeContext
366 css::uno::Reference
< css::io::XOutputStream
> mxBase64Stream
;
370 SdXMLGraphicObjectShapeContext( SvXMLImport
& rImport
,
371 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
372 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
);
373 virtual ~SdXMLGraphicObjectShapeContext() override
;
375 virtual void StartElement( const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
376 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
377 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
, const OUString
& rLocalName
,
378 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
380 // this is called from the parent group for each unparsed attribute in the attribute list
381 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
384 // chart:chart context
386 class SdXMLChartShapeContext
: public SdXMLShapeContext
388 SvXMLImportContextRef mxChartContext
;
392 SdXMLChartShapeContext( SvXMLImport
& rImport
,
393 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
394 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
,
395 bool bTemporaryShape
);
397 virtual void StartElement( const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
398 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
399 virtual void SAL_CALL
characters( const OUString
& rChars
) override
;
400 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
, const OUString
& rLocalName
,
401 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
404 // draw:object and draw:object_ole context
406 class SdXMLObjectShapeContext
: public SdXMLShapeContext
412 css::uno::Reference
< css::io::XOutputStream
> mxBase64Stream
;
416 SdXMLObjectShapeContext( SvXMLImport
& rImport
,
417 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
418 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
);
419 virtual ~SdXMLObjectShapeContext() override
;
421 virtual void StartElement( const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
422 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
424 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
, const OUString
& rLocalName
,
425 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
427 // this is called from the parent group for each unparsed attribute in the attribute list
428 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
433 class SdXMLAppletShapeContext
: public SdXMLShapeContext
436 OUString maAppletName
;
437 OUString maAppletCode
;
441 css::uno::Sequence
< css::beans::PropertyValue
> maParams
;
445 SdXMLAppletShapeContext( SvXMLImport
& rImport
,
446 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
447 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
);
448 virtual ~SdXMLAppletShapeContext() override
;
450 virtual void StartElement( const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
451 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
453 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
, const OUString
& rLocalName
,
454 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
456 // this is called from the parent group for each unparsed attribute in the attribute list
457 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
462 class SdXMLPluginShapeContext
: public SdXMLShapeContext
469 css::uno::Sequence
< css::beans::PropertyValue
> maParams
;
473 SdXMLPluginShapeContext( SvXMLImport
& rImport
,
474 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
475 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
);
476 virtual ~SdXMLPluginShapeContext() override
;
478 virtual void StartElement( const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
479 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
481 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
, const OUString
& rLocalName
,
482 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
484 // this is called from the parent group for each unparsed attribute in the attribute list
485 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
487 const OUString
& getMimeType() const { return maMimeType
; }
490 // draw:floating-frame
492 class SdXMLFloatingFrameShapeContext
: public SdXMLShapeContext
495 OUString maFrameName
;
500 SdXMLFloatingFrameShapeContext( SvXMLImport
& rImport
,
501 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
502 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
);
503 virtual ~SdXMLFloatingFrameShapeContext() override
;
505 virtual void StartElement( const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
506 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
508 // this is called from the parent group for each unparsed attribute in the attribute list
509 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
514 class SdXMLFrameShapeContext
: public SdXMLShapeContext
, public MultiImageImportHelper
517 bool mbSupportsReplacement
;
518 SvXMLImportContextRef mxImplContext
;
519 SvXMLImportContextRef mxReplImplContext
;
522 /// helper to get the created xShape instance, needs to be overridden
523 void removeGraphicFromImportContext(const SvXMLImportContext
& rContext
) override
;
524 OUString
getGraphicPackageURLFromImportContext(const SvXMLImportContext
& rContext
) const override
;
525 css::uno::Reference
<css::graphic::XGraphic
> getGraphicFromImportContext(const SvXMLImportContext
& rContext
) const override
;
529 SdXMLFrameShapeContext( SvXMLImport
& rImport
,
530 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
531 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
,
532 bool bTemporaryShape
);
533 virtual ~SdXMLFrameShapeContext() override
;
535 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
, const OUString
& rLocalName
,
536 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
538 virtual void StartElement( const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
539 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
541 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
544 class SdXMLCustomShapeContext
: public SdXMLShapeContext
546 OUString maCustomShapeEngine
;
547 OUString maCustomShapeData
;
549 std::vector
< css::beans::PropertyValue
> maCustomShapeGeometry
;
554 SdXMLCustomShapeContext( SvXMLImport
& rImport
,
555 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
556 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
);
557 virtual ~SdXMLCustomShapeContext() override
;
559 virtual void StartElement( const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
560 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
562 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
, const OUString
& rLocalName
,
563 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
565 // this is called from the parent group for each unparsed attribute in the attribute list
566 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
571 class SdXMLTableShapeContext
: public SdXMLShapeContext
575 SdXMLTableShapeContext( SvXMLImport
& rImport
,
576 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
577 css::uno::Reference
< css::drawing::XShapes
> const & rShapes
);
578 virtual ~SdXMLTableShapeContext() override
;
580 virtual void StartElement( const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
581 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
583 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
585 // this is called from the parent group for each unparsed attribute in the attribute list
586 virtual void processAttribute( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const OUString
& rValue
) override
;
589 SvXMLImportContextRef mxTableImportContext
;
590 OUString msTemplateStyleName
;
591 bool maTemplateStylesUsed
[6] = {};
594 extern SvXMLEnumMapEntry
<css::drawing::Alignment
> const aXML_GlueAlignment_EnumMap
[];
595 extern SvXMLEnumMapEntry
<css::drawing::EscapeDirection
> const aXML_GlueEscapeDirection_EnumMap
[];
597 #endif // INCLUDED_XMLOFF_SOURCE_DRAW_XIMPSHAP_HXX
599 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */