/src/libreoffice/oox/inc/drawingml/customshapeproperties.hxx
Line | Count | Source |
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_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX |
21 | | #define INCLUDED_OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX |
22 | | |
23 | | #include <memory> |
24 | | #include <unordered_map> |
25 | | #include <vector> |
26 | | #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> |
27 | | #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> |
28 | | #include <com/sun/star/drawing/XShape.hpp> |
29 | | #include <oox/helper/helper.hxx> |
30 | | #include <oox/helper/propertymap.hxx> |
31 | | #include <oox/token/tokens.hxx> |
32 | | |
33 | | namespace oox::drawingml { |
34 | | |
35 | | class CustomShapeProperties; |
36 | | |
37 | | typedef std::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr; |
38 | | |
39 | | struct CustomShapeGuide |
40 | | { |
41 | | OUString maName; |
42 | | OUString maFormula; |
43 | | }; |
44 | | |
45 | | class CustomShapeGuideContainer |
46 | | { |
47 | | public: |
48 | | sal_Int32 GetCustomShapeGuideValue( const OUString& rFormulaName ) const; |
49 | | sal_Int32 SetCustomShapeGuideValue( const CustomShapeGuide& rGuide ); |
50 | | |
51 | | void push_back( const CustomShapeGuide& rGuide ); |
52 | 3.31k | size_t size() const { return maGuideList.size(); }; |
53 | 21.2k | bool empty() const { return maGuideList.empty(); }; |
54 | 570 | std::vector< CustomShapeGuide >::const_iterator begin() const { return maGuideList.begin(); }; |
55 | 570 | std::vector< CustomShapeGuide >::const_iterator end() const { return maGuideList.end(); }; |
56 | 159 | const CustomShapeGuide& operator[](size_t nIndex) const { return maGuideList[ nIndex ]; }; |
57 | | |
58 | | private: |
59 | | std::vector< CustomShapeGuide > maGuideList; |
60 | | mutable std::unordered_map< OUString, sal_Int32 > maGuideListLookupMap; |
61 | | mutable bool mbLookupMapStale = false; |
62 | | mutable sal_Int32 mnPreviousActSize = 0; |
63 | | |
64 | | void ActualizeLookupMap() const; |
65 | | }; |
66 | | |
67 | | struct AdjustHandle |
68 | | { |
69 | | bool polar; |
70 | | css::drawing::EnhancedCustomShapeParameterPair |
71 | | pos; |
72 | | |
73 | | // depending to the type (polar or not): |
74 | | std::optional< OUString > gdRef1; // gdRefX or gdRefR |
75 | | std::optional< css::drawing::EnhancedCustomShapeParameter > |
76 | | min1; // minX or minR |
77 | | std::optional< css::drawing::EnhancedCustomShapeParameter > |
78 | | max1; // maxX or maxR |
79 | | std::optional< OUString > gdRef2; // gdRefY or gdRefAng |
80 | | std::optional< css::drawing::EnhancedCustomShapeParameter > |
81 | | min2; // minX or minAng |
82 | | std::optional< css::drawing::EnhancedCustomShapeParameter > |
83 | | max2; // maxY or maxAng |
84 | | |
85 | 0 | AdjustHandle( bool bPolar ) : polar( bPolar ) {}; |
86 | | }; |
87 | | |
88 | | struct ConnectionSite |
89 | | { |
90 | | css::drawing::EnhancedCustomShapeParameterPair |
91 | | pos; |
92 | | css::drawing::EnhancedCustomShapeParameter |
93 | | ang; |
94 | | }; |
95 | | |
96 | | struct GeomRect |
97 | | { |
98 | | css::drawing::EnhancedCustomShapeParameter l; |
99 | | css::drawing::EnhancedCustomShapeParameter t; |
100 | | css::drawing::EnhancedCustomShapeParameter r; |
101 | | css::drawing::EnhancedCustomShapeParameter b; |
102 | | }; |
103 | | |
104 | | struct Path2D |
105 | | { |
106 | | sal_Int64 w; |
107 | | sal_Int64 h; |
108 | | sal_Int32 fill; |
109 | | bool stroke; |
110 | | bool extrusionOk; |
111 | | std::vector< css::drawing::EnhancedCustomShapeParameterPair > parameter; |
112 | | |
113 | 339 | Path2D() : w( 0 ), h( 0 ), fill( XML_norm ), stroke( true ), extrusionOk( true ) {}; |
114 | | }; |
115 | | |
116 | | |
117 | | class CustomShapeProperties final |
118 | | { |
119 | | public: |
120 | | CustomShapeProperties(); |
121 | | |
122 | | void pushToPropSet( const css::uno::Reference < css::beans::XPropertySet > & xPropSet, |
123 | | const css::awt::Size &aSize ); |
124 | | |
125 | 56.7k | sal_Int32 getShapePresetType() const { return mnShapePresetType; } |
126 | | OUString getShapePresetTypeName() const; |
127 | 87.1k | void setShapePresetType( sal_Int32 nShapePresetType ){ mnShapePresetType = nShapePresetType; }; |
128 | 0 | bool getShapeTypeOverride() const { return mbShapeTypeOverride; }; |
129 | 513 | void setShapeTypeOverride( bool bShapeTypeOverride ) { mbShapeTypeOverride = bShapeTypeOverride; }; |
130 | | |
131 | 90.1k | CustomShapeGuideContainer& getAdjustmentGuideList(){ return maAdjustmentGuideList; }; |
132 | 3.18k | CustomShapeGuideContainer& getGuideList(){ return maGuideList; }; |
133 | 661 | std::vector< AdjustHandle >& getAdjustHandleList(){ return maAdjustHandleList; }; |
134 | 1.68k | std::vector< ConnectionSite >& getConnectionSiteList(){ return maConnectionSiteList; }; |
135 | 661 | std::optional< GeomRect >& getTextRect(){ return maTextRect; }; |
136 | 665 | std::vector< Path2D >& getPath2DList(){ return maPath2DList; }; |
137 | 665 | std::vector< css::drawing::EnhancedCustomShapeSegment >& getSegments(){ return maSegments; }; |
138 | 9 | void setMirroredX( bool bMirroredX ) { mbMirroredX = bMirroredX; }; |
139 | 39 | void setMirroredY( bool bMirroredY ) { mbMirroredY = bMirroredY; }; |
140 | 11.4k | void setTextPreRotateAngle( sal_Int32 nAngle ) { mnTextPreRotateAngle = nAngle; }; |
141 | 11.4k | void setTextCameraZRotateAngle( sal_Int32 nAngle ) { mnTextCameraZRotateAngle = nAngle; }; |
142 | 67 | void setTextAreaRotateAngle(sal_Int32 nAngle) { moTextAreaRotateAngle = nAngle; }; |
143 | | |
144 | 59 | sal_Int32 getArcNum() { return mnArcNum++; } |
145 | 345 | sal_Int32 countArcTo() { return mnArcNum; } |
146 | 74.9k | PropertyMap& getExtrusionPropertyMap() { return maExtrusionPropertyMap; } |
147 | | |
148 | | /** |
149 | | Returns whether or not the current CustomShapeProperties |
150 | | represent a default shape preset that is rectangular. |
151 | | */ |
152 | | bool representsDefaultShape() const; |
153 | | |
154 | | private: |
155 | | |
156 | | sal_Int32 mnShapePresetType; |
157 | | bool mbShapeTypeOverride; |
158 | | CustomShapeGuideContainer maAdjustmentGuideList; |
159 | | CustomShapeGuideContainer maGuideList; |
160 | | std::vector< AdjustHandle > maAdjustHandleList; |
161 | | std::vector< ConnectionSite > maConnectionSiteList; |
162 | | std::optional< GeomRect > maTextRect; |
163 | | std::vector< Path2D > maPath2DList; |
164 | | |
165 | | std::vector< css::drawing::EnhancedCustomShapeSegment > |
166 | | maSegments; |
167 | | bool mbMirroredX; |
168 | | bool mbMirroredY; |
169 | | sal_Int32 mnTextPreRotateAngle; // TextPreRotateAngle |
170 | | sal_Int32 mnTextCameraZRotateAngle; |
171 | | std::optional< sal_Int32 > moTextAreaRotateAngle; // TextRotateAngle |
172 | | |
173 | | typedef std::unordered_map< sal_Int32, PropertyMap > PresetDataMap; |
174 | | |
175 | | static PresetDataMap maPresetDataMap; |
176 | | static void initializePresetDataMap(); |
177 | | |
178 | | sal_Int32 mnArcNum; |
179 | | PropertyMap maExtrusionPropertyMap; |
180 | | }; |
181 | | |
182 | | } |
183 | | |
184 | | #endif // INCLUDED_OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX |
185 | | |
186 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |