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 .
23 #include <cppuhelper/implbase.hxx>
24 #include <oox/drawingml/color.hxx>
25 #include <oox/drawingml/graphicshapecontext.hxx>
26 #include <oox/core/fragmenthandler2.hxx>
27 #include <oox/core/xmlfilterbase.hxx>
28 #include <rtl/ref.hxx>
29 #include <com/sun/star/document/XDocumentProperties.hpp>
30 #include <com/sun/star/graphic/XGraphicMapper.hpp>
31 #include <com/sun/star/drawing/XDrawPage.hpp>
32 #include <com/sun/star/frame/XModel.hpp>
34 namespace oox::vml
{ class DrawingFragment
; }
36 namespace oox::shape
{
38 class LockedCanvasContext
;
39 class ShapeFilterBase
;
40 class WordprocessingCanvasContext
;
44 class ShapeFragmentHandler final
: public core::FragmentHandler2
47 typedef rtl::Reference
<ShapeFragmentHandler
> Pointer_t
;
49 explicit ShapeFragmentHandler(core::XmlFilterBase
& rFilter
,
50 const OUString
& rFragmentPath
)
51 : FragmentHandler2(rFilter
, rFragmentPath
)
56 class OOX_DLLPUBLIC ShapeContextHandler final
:
57 public ::cppu::WeakImplHelper
< css::xml::sax::XFastContextHandler
>
60 explicit ShapeContextHandler(rtl::Reference
<ShapeFilterBase
> xFilterBase
);
62 virtual ~ShapeContextHandler() override
;
64 // css::xml::sax::XFastContextHandler:
65 virtual void SAL_CALL startFastElement
67 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
) override
;
69 virtual void SAL_CALL startUnknownElement
70 (const OUString
& Namespace
,
71 const OUString
& Name
,
72 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
) override
;
74 virtual void SAL_CALL
endFastElement(::sal_Int32 Element
) override
;
76 virtual void SAL_CALL endUnknownElement
77 (const OUString
& Namespace
,
78 const OUString
& Name
) override
;
80 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
81 createFastChildContext
83 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
) override
;
85 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
86 createUnknownChildContext
87 (const OUString
& Namespace
,
88 const OUString
& Name
,
89 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
) override
;
91 virtual void SAL_CALL
characters(const OUString
& aChars
) override
;
93 css::uno::Reference
< css::drawing::XShape
> getShape();
95 void setDrawPage(const css::uno::Reference
< css::drawing::XDrawPage
> & the_value
);
97 void setModel(const css::uno::Reference
< css::frame::XModel
> & the_value
);
99 void setRelationFragmentPath(const OUString
& the_value
);
101 sal_Int32
getStartToken() const;
102 void popStartToken();
103 void pushStartToken( sal_Int32 _starttoken
);
105 void setPosition(const css::awt::Point
& rPosition
);
106 void setSize(const css::awt::Size
& rSize
);
108 const bool& getFullWPGSupport() { return m_bFullWPGSUpport
; }
109 void setFullWPGSupport(bool bUse
) { m_bFullWPGSUpport
= bUse
; }
111 bool isWordProcessingGroupShape() const { return mxWpgContext
? true : false; }
112 bool isWordprocessingCanvas() const { return mxWordprocessingCanvasContext
? true : false; }
114 void setDocumentProperties(const css::uno::Reference
<css::document::XDocumentProperties
>& xDocProps
);
115 void setMediaDescriptor(const css::uno::Sequence
<css::beans::PropertyValue
>& rMediaDescriptor
);
117 void setGraphicMapper(css::uno::Reference
<css::graphic::XGraphicMapper
> const & rGraphicMapper
);
119 void setTheme(const oox::drawingml::ThemePtr
& pTheme
) { mpThemePtr
= pTheme
; }
120 const oox::drawingml::ThemePtr
& getTheme() const { return mpThemePtr
; }
123 ShapeContextHandler(ShapeContextHandler
const &) = delete;
124 void operator =(ShapeContextHandler
const &) = delete;
126 // Special stack which always has at least one element.
127 // In case of group shapes with embedded content it will have more element than one.
128 std::stack
<sal_uInt32
> mnStartTokenStack
;
130 css::awt::Point maPosition
;
131 css::awt::Size maSize
; // from cx and cy, in EMU
132 bool m_bFullWPGSUpport
; // Is this DrawingML shape supposed to be processed as WPG?
134 drawingml::ShapePtr mpShape
;
135 std::shared_ptr
< vml::Drawing
> mpDrawing
;
137 typedef rtl::Reference
<drawingml::GraphicShapeContext
>
138 GraphicShapeContextPtr
;
139 rtl::Reference
<vml::DrawingFragment
> mxDrawingFragmentHandler
;
140 css::uno::Reference
<XFastContextHandler
> mxGraphicShapeContext
;
141 rtl::Reference
<drawingml::DiagramGraphicDataContext
> mxDiagramShapeContext
;
142 rtl::Reference
<LockedCanvasContext
> mxLockedCanvasContext
;
143 rtl::Reference
<WordprocessingCanvasContext
> mxWordprocessingCanvasContext
;
144 rtl::Reference
<WpsContext
> mxWpsContext
;
145 css::uno::Reference
<css::drawing::XShape
> mxSavedShape
;
146 rtl::Reference
<WpgContext
> mxWpgContext
;
147 rtl::Reference
<drawingml::ChartGraphicDataContext
> mxChartShapeContext
;
148 css::uno::Reference
<css::document::XDocumentProperties
> mxDocumentProperties
;
149 css::uno::Sequence
<css::beans::PropertyValue
> maMediaDescriptor
;
151 ::rtl::Reference
< ShapeFilterBase
> mxShapeFilterBase
;
152 drawingml::ThemePtr mpThemePtr
;
153 css::uno::Reference
<css::drawing::XDrawPage
> mxDrawPage
;
154 OUString msRelationFragmentPath
;
156 css::uno::Reference
<XFastContextHandler
> const & getGraphicShapeContext(::sal_Int32 Element
);
157 css::uno::Reference
<XFastContextHandler
> getChartShapeContext(::sal_Int32 Element
);
158 css::uno::Reference
<XFastContextHandler
> getDrawingShapeContext();
159 css::uno::Reference
<XFastContextHandler
> getDiagramShapeContext();
160 css::uno::Reference
<XFastContextHandler
> getLockedCanvasContext(sal_Int32 nElement
);
161 css::uno::Reference
<XFastContextHandler
> getWordprocessingCanvasContext(sal_Int32 nElement
);
162 css::uno::Reference
<XFastContextHandler
> getWpsContext(sal_Int32 nStartElement
, sal_Int32 nElement
);
163 css::uno::Reference
<XFastContextHandler
> getWpgContext(sal_Int32 nElement
);
164 css::uno::Reference
<XFastContextHandler
> getContextHandler(sal_Int32 nElement
= 0);
166 void applyFontRefColor(const oox::drawingml::ShapePtr
& pShape
,
167 const oox::drawingml::Color
& rFontRefColor
);
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */