Get the style color and number just once
[LibreOffice.git] / include / oox / vml / vmlshapecontext.hxx
blob6f7a2eff7d5b89cad3524dfd3c511653bf11ae53
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_OOX_VML_VMLSHAPECONTEXT_HXX
21 #define INCLUDED_OOX_VML_VMLSHAPECONTEXT_HXX
23 #include <oox/core/contexthandler.hxx>
24 #include <oox/core/contexthandler2.hxx>
25 #include <rtl/ustring.hxx>
26 #include <sal/types.h>
27 //#include <oox/dllapi.h>
29 #include <optional>
31 namespace oox { class AttributeList; }
33 namespace oox::vml {
35 class Drawing;
37 struct ShapeTypeModel;
38 class ShapeType;
40 struct ClientData;
41 struct ShapeModel;
42 class ShapeBase;
43 class GroupShape;
44 class RectangleShape;
46 class ShapeContainer;
49 class ShapeLayoutContext final : public ::oox::core::ContextHandler2
51 public:
52 explicit ShapeLayoutContext(
53 ::oox::core::ContextHandler2Helper const & rParent,
54 Drawing& rDrawing );
56 virtual ::oox::core::ContextHandlerRef
57 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
59 private:
60 Drawing& mrDrawing;
64 class ClientDataContext final : public ::oox::core::ContextHandler2
66 public:
67 explicit ClientDataContext(
68 ::oox::core::ContextHandler2Helper const & rParent,
69 ClientData& rClientData,
70 const AttributeList& rAttribs );
72 virtual ::oox::core::ContextHandlerRef
73 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
74 virtual void onCharacters( const OUString& rChars ) override;
75 virtual void onEndElement() override;
77 private:
78 ClientData& mrClientData;
79 OUString maElementText;
83 class SAL_DLLPUBLIC_RTTI ShapeContextBase : public ::oox::core::ContextHandler2
85 public:
86 static ::oox::core::ContextHandlerRef
87 createShapeContext(
88 ::oox::core::ContextHandler2Helper const & rParent,
89 ShapeContainer& rShapes,
90 sal_Int32 nElement,
91 const AttributeList& rAttribs );
93 protected:
94 explicit ShapeContextBase( ::oox::core::ContextHandler2Helper const & rParent );
98 class SAL_DLLPUBLIC_RTTI ShapeTypeContext : public ShapeContextBase
100 public:
101 explicit ShapeTypeContext(
102 ::oox::core::ContextHandler2Helper const & rParent,
103 std::shared_ptr<ShapeType> const& pShapeType,
104 const AttributeList& rAttribs );
106 virtual ::oox::core::ContextHandlerRef
107 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
109 private:
110 /** Processes the 'style' attribute. */
111 void setStyle( std::u16string_view rStyle );
113 /** Resolve a relation identifier to a fragment path. */
114 std::optional< OUString > decodeFragmentPath( const AttributeList& rAttribs, sal_Int32 nToken ) const;
116 private:
117 std::shared_ptr<ShapeType> m_pShapeType;
118 ShapeTypeModel& mrTypeModel;
122 class SAL_DLLPUBLIC_RTTI ShapeContext : public ShapeTypeContext
124 public:
125 explicit ShapeContext(::oox::core::ContextHandler2Helper const& rParent,
126 const std::shared_ptr<ShapeBase>& pShape, const AttributeList& rAttribs);
128 virtual ::oox::core::ContextHandlerRef
129 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
131 void OOX_DLLPUBLIC setWriterShape();
133 private:
134 /** Processes the 'points' attribute. */
135 void setPoints( std::u16string_view rPoints );
136 /** Processes the 'from' attribute. */
137 void setFrom( const OUString& rPoints );
138 /** Processes the 'to' attribute. */
139 void setTo( const OUString& rPoints );
140 /** Processes the 'control1' attribute. */
141 void setControl1( const OUString& rPoints );
142 /** Processes the 'control2' attribute. */
143 void setControl2( const OUString& rPoints );
144 /** Processes the 'path' attribute. */
145 void setVmlPath( const OUString& rPath );
146 /** Processes the 'href' attribute. */
147 void setHyperlink( const OUString& rHyperlink );
149 private:
150 ShapeBase& mrShape;
151 ShapeModel& mrShapeModel;
155 class GroupShapeContext final : public ShapeContext
157 public:
158 explicit GroupShapeContext(::oox::core::ContextHandler2Helper const& rParent,
159 const std::shared_ptr<GroupShape>& pShape,
160 const AttributeList& rAttribs);
162 virtual ::oox::core::ContextHandlerRef
163 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
165 private:
166 ShapeContainer& mrShapes;
170 class RectangleShapeContext final : public ShapeContext
172 public:
173 explicit RectangleShapeContext(::oox::core::ContextHandler2Helper const& rParent,
174 const AttributeList& rAttribs,
175 const std::shared_ptr<RectangleShape>& pShape);
177 virtual ::oox::core::ContextHandlerRef
178 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
181 class ControlShapeContext final : public ShapeContextBase
183 public:
184 explicit ControlShapeContext(
185 ::oox::core::ContextHandler2Helper const & rParent,
186 ShapeContainer& rShapes,
187 const AttributeList& rAttribs );
191 } // namespace oox::vml
193 #endif
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */