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_OOX_VML_VMLSHAPECONTEXT_HXX 21 #define INCLUDED_OOX_VML_VMLSHAPECONTEXT_HXX 22 23 #include <oox/core/contexthandler.hxx> 24 #include <oox/core/contexthandler2.hxx> 25 #include <oox/helper/helper.hxx> 26 #include <rtl/ustring.hxx> 27 #include <sal/types.h> 28 29 namespace oox { class AttributeList; } 30 31 namespace oox::vml { 32 33 class Drawing; 34 35 struct ShapeTypeModel; 36 class ShapeType; 37 38 struct ClientData; 39 struct ShapeModel; 40 class ShapeBase; 41 class GroupShape; 42 class RectangleShape; 43 44 class ShapeContainer; 45 46 47 class ShapeLayoutContext final : public ::oox::core::ContextHandler2 48 { 49 public: 50 explicit ShapeLayoutContext( 51 ::oox::core::ContextHandler2Helper const & rParent, 52 Drawing& rDrawing ); 53 54 virtual ::oox::core::ContextHandlerRef 55 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; 56 57 private: 58 Drawing& mrDrawing; 59 }; 60 61 62 class ClientDataContext final : public ::oox::core::ContextHandler2 63 { 64 public: 65 explicit ClientDataContext( 66 ::oox::core::ContextHandler2Helper const & rParent, 67 ClientData& rClientData, 68 const AttributeList& rAttribs ); 69 70 virtual ::oox::core::ContextHandlerRef 71 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; 72 virtual void onCharacters( const OUString& rChars ) override; 73 virtual void onEndElement() override; 74 75 private: 76 ClientData& mrClientData; 77 OUString maElementText; 78 }; 79 80 81 class ShapeContextBase : public ::oox::core::ContextHandler2 82 { 83 public: 84 static ::oox::core::ContextHandlerRef 85 createShapeContext( 86 ::oox::core::ContextHandler2Helper const & rParent, 87 ShapeContainer& rShapes, 88 sal_Int32 nElement, 89 const AttributeList& rAttribs ); 90 91 protected: 92 explicit ShapeContextBase( ::oox::core::ContextHandler2Helper const & rParent ); 93 }; 94 95 96 class ShapeTypeContext : public ShapeContextBase 97 { 98 public: 99 explicit ShapeTypeContext( 100 ::oox::core::ContextHandler2Helper const & rParent, 101 std::shared_ptr<ShapeType> const& pShapeType, 102 const AttributeList& rAttribs ); 103 104 virtual ::oox::core::ContextHandlerRef 105 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; 106 107 private: 108 /** Processes the 'style' attribute. */ 109 void setStyle( const OUString& rStyle ); 110 111 /** Resolve a relation identifier to a fragment path. */ 112 OptValue< OUString > decodeFragmentPath( const AttributeList& rAttribs, sal_Int32 nToken ) const; 113 114 private: 115 std::shared_ptr<ShapeType> m_pShapeType; 116 ShapeTypeModel& mrTypeModel; 117 }; 118 119 120 class ShapeContext : public ShapeTypeContext 121 { 122 public: 123 explicit ShapeContext(::oox::core::ContextHandler2Helper const& rParent, 124 const std::shared_ptr<ShapeBase>& pShape, const AttributeList& rAttribs); 125 126 virtual ::oox::core::ContextHandlerRef 127 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; 128 129 private: 130 /** Processes the 'points' attribute. */ 131 void setPoints( const OUString& rPoints ); 132 /** Processes the 'from' attribute. */ 133 void setFrom( const OUString& rPoints ); 134 /** Processes the 'to' attribute. */ 135 void setTo( const OUString& rPoints ); 136 /** Processes the 'control1' attribute. */ 137 void setControl1( const OUString& rPoints ); 138 /** Processes the 'control2' attribute. */ 139 void setControl2( const OUString& rPoints ); 140 /** Processes the 'path' attribute. */ 141 void setVmlPath( const OUString& rPath ); 142 143 private: 144 ShapeBase& mrShape; 145 ShapeModel& mrShapeModel; 146 }; 147 148 149 class GroupShapeContext final : public ShapeContext 150 { 151 public: 152 explicit GroupShapeContext(::oox::core::ContextHandler2Helper const& rParent, 153 const std::shared_ptr<GroupShape>& pShape, 154 const AttributeList& rAttribs); 155 156 virtual ::oox::core::ContextHandlerRef 157 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; 158 159 private: 160 ShapeContainer& mrShapes; 161 }; 162 163 164 class RectangleShapeContext final : public ShapeContext 165 { 166 public: 167 explicit RectangleShapeContext(::oox::core::ContextHandler2Helper const& rParent, 168 const AttributeList& rAttribs, 169 const std::shared_ptr<RectangleShape>& pShape); 170 171 virtual ::oox::core::ContextHandlerRef 172 onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; 173 }; 174 175 class ControlShapeContext final : public ShapeContextBase 176 { 177 public: 178 explicit ControlShapeContext( 179 ::oox::core::ContextHandler2Helper const & rParent, 180 ShapeContainer& rShapes, 181 const AttributeList& rAttribs ); 182 }; 183 184 185 } // namespace oox::vml 186 187 #endif 188 189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 190