Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / oox / vml / vmlshapecontext.hxx
blob8252e0e6ebe63138154f5ad621e5167bae6db4e0
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>
28 #include <optional>
30 namespace oox { class AttributeList; }
32 namespace oox::vml {
34 class Drawing;
36 struct ShapeTypeModel;
37 class ShapeType;
39 struct ClientData;
40 struct ShapeModel;
41 class ShapeBase;
42 class GroupShape;
43 class RectangleShape;
45 class ShapeContainer;
48 class ShapeLayoutContext final : public ::oox::core::ContextHandler2
50 public:
51 explicit ShapeLayoutContext(
52 ::oox::core::ContextHandler2Helper const & rParent,
53 Drawing& rDrawing );
55 virtual ::oox::core::ContextHandlerRef
56 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
58 private:
59 Drawing& mrDrawing;
63 class ClientDataContext final : public ::oox::core::ContextHandler2
65 public:
66 explicit ClientDataContext(
67 ::oox::core::ContextHandler2Helper const & rParent,
68 ClientData& rClientData,
69 const AttributeList& rAttribs );
71 virtual ::oox::core::ContextHandlerRef
72 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
73 virtual void onCharacters( const OUString& rChars ) override;
74 virtual void onEndElement() override;
76 private:
77 ClientData& mrClientData;
78 OUString maElementText;
82 class ShapeContextBase : public ::oox::core::ContextHandler2
84 public:
85 static ::oox::core::ContextHandlerRef
86 createShapeContext(
87 ::oox::core::ContextHandler2Helper const & rParent,
88 ShapeContainer& rShapes,
89 sal_Int32 nElement,
90 const AttributeList& rAttribs );
92 protected:
93 explicit ShapeContextBase( ::oox::core::ContextHandler2Helper const & rParent );
97 class ShapeTypeContext : public ShapeContextBase
99 public:
100 explicit ShapeTypeContext(
101 ::oox::core::ContextHandler2Helper const & rParent,
102 std::shared_ptr<ShapeType> const& pShapeType,
103 const AttributeList& rAttribs );
105 virtual ::oox::core::ContextHandlerRef
106 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
108 private:
109 /** Processes the 'style' attribute. */
110 void setStyle( std::u16string_view rStyle );
112 /** Resolve a relation identifier to a fragment path. */
113 std::optional< OUString > decodeFragmentPath( const AttributeList& rAttribs, sal_Int32 nToken ) const;
115 private:
116 std::shared_ptr<ShapeType> m_pShapeType;
117 ShapeTypeModel& mrTypeModel;
121 class ShapeContext : public ShapeTypeContext
123 public:
124 explicit ShapeContext(::oox::core::ContextHandler2Helper const& rParent,
125 const std::shared_ptr<ShapeBase>& pShape, const AttributeList& rAttribs);
127 virtual ::oox::core::ContextHandlerRef
128 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
130 private:
131 /** Processes the 'points' attribute. */
132 void setPoints( std::u16string_view rPoints );
133 /** Processes the 'from' attribute. */
134 void setFrom( const OUString& rPoints );
135 /** Processes the 'to' attribute. */
136 void setTo( const OUString& rPoints );
137 /** Processes the 'control1' attribute. */
138 void setControl1( const OUString& rPoints );
139 /** Processes the 'control2' attribute. */
140 void setControl2( const OUString& rPoints );
141 /** Processes the 'path' attribute. */
142 void setVmlPath( const OUString& rPath );
143 /** Processes the 'href' attribute. */
144 void setHyperlink( const OUString& rHyperlink );
146 private:
147 ShapeBase& mrShape;
148 ShapeModel& mrShapeModel;
152 class GroupShapeContext final : public ShapeContext
154 public:
155 explicit GroupShapeContext(::oox::core::ContextHandler2Helper const& rParent,
156 const std::shared_ptr<GroupShape>& pShape,
157 const AttributeList& rAttribs);
159 virtual ::oox::core::ContextHandlerRef
160 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
162 private:
163 ShapeContainer& mrShapes;
167 class RectangleShapeContext final : public ShapeContext
169 public:
170 explicit RectangleShapeContext(::oox::core::ContextHandler2Helper const& rParent,
171 const AttributeList& rAttribs,
172 const std::shared_ptr<RectangleShape>& pShape);
174 virtual ::oox::core::ContextHandlerRef
175 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
178 class ControlShapeContext final : public ShapeContextBase
180 public:
181 explicit ControlShapeContext(
182 ::oox::core::ContextHandler2Helper const & rParent,
183 ShapeContainer& rShapes,
184 const AttributeList& rAttribs );
188 } // namespace oox::vml
190 #endif
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */