tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / oox / inc / drawingml / customshapeproperties.hxx
blob1c627ec7448fbc72d2d5e3264079a01c41b8cfa9
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_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX
21 #define INCLUDED_OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX
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>
33 namespace oox::drawingml {
35 class CustomShapeProperties;
37 typedef std::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr;
39 struct CustomShapeGuide
41 OUString maName;
42 OUString maFormula;
45 class CustomShapeGuideContainer
47 public:
48 sal_Int32 GetCustomShapeGuideValue( const OUString& rFormulaName ) const;
49 sal_Int32 SetCustomShapeGuideValue( const CustomShapeGuide& rGuide );
51 void push_back( const CustomShapeGuide& rGuide );
52 size_t size() const { return maGuideList.size(); };
53 bool empty() const { return maGuideList.empty(); };
54 std::vector< CustomShapeGuide >::const_iterator begin() const { return maGuideList.begin(); };
55 std::vector< CustomShapeGuide >::const_iterator end() const { return maGuideList.end(); };
56 const CustomShapeGuide& operator[](size_t nIndex) const { return maGuideList[ nIndex ]; };
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;
64 void ActualizeLookupMap() const;
67 struct AdjustHandle
69 bool polar;
70 css::drawing::EnhancedCustomShapeParameterPair
71 pos;
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
85 AdjustHandle( bool bPolar ) : polar( bPolar ) {};
88 struct ConnectionSite
90 css::drawing::EnhancedCustomShapeParameterPair
91 pos;
92 css::drawing::EnhancedCustomShapeParameter
93 ang;
96 struct GeomRect
98 css::drawing::EnhancedCustomShapeParameter l;
99 css::drawing::EnhancedCustomShapeParameter t;
100 css::drawing::EnhancedCustomShapeParameter r;
101 css::drawing::EnhancedCustomShapeParameter b;
104 struct Path2D
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;
113 Path2D() : w( 0 ), h( 0 ), fill( XML_norm ), stroke( true ), extrusionOk( true ) {};
117 class CustomShapeProperties final
119 public:
120 CustomShapeProperties();
122 void pushToPropSet( const css::uno::Reference < css::beans::XPropertySet > & xPropSet,
123 const css::awt::Size &aSize );
125 sal_Int32 getShapePresetType() const { return mnShapePresetType; }
126 OUString getShapePresetTypeName() const;
127 void setShapePresetType( sal_Int32 nShapePresetType ){ mnShapePresetType = nShapePresetType; };
128 bool getShapeTypeOverride() const { return mbShapeTypeOverride; };
129 void setShapeTypeOverride( bool bShapeTypeOverride ) { mbShapeTypeOverride = bShapeTypeOverride; };
131 CustomShapeGuideContainer& getAdjustmentGuideList(){ return maAdjustmentGuideList; };
132 CustomShapeGuideContainer& getGuideList(){ return maGuideList; };
133 std::vector< AdjustHandle >& getAdjustHandleList(){ return maAdjustHandleList; };
134 std::vector< ConnectionSite >& getConnectionSiteList(){ return maConnectionSiteList; };
135 std::optional< GeomRect >& getTextRect(){ return maTextRect; };
136 std::vector< Path2D >& getPath2DList(){ return maPath2DList; };
137 std::vector< css::drawing::EnhancedCustomShapeSegment >& getSegments(){ return maSegments; };
138 void setMirroredX( bool bMirroredX ) { mbMirroredX = bMirroredX; };
139 void setMirroredY( bool bMirroredY ) { mbMirroredY = bMirroredY; };
140 void setTextPreRotateAngle( sal_Int32 nAngle ) { mnTextPreRotateAngle = nAngle; };
141 void setTextCameraZRotateAngle( sal_Int32 nAngle ) { mnTextCameraZRotateAngle = nAngle; };
142 void setTextAreaRotateAngle(sal_Int32 nAngle) { moTextAreaRotateAngle = nAngle; };
144 sal_Int32 getArcNum() { return mnArcNum++; }
145 sal_Int32 countArcTo() { return mnArcNum; }
146 PropertyMap& getExtrusionPropertyMap() { return maExtrusionPropertyMap; }
149 Returns whether or not the current CustomShapeProperties
150 represent a default shape preset that is rectangular.
152 bool representsDefaultShape() const;
154 private:
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;
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
173 typedef std::unordered_map< sal_Int32, PropertyMap > PresetDataMap;
175 static PresetDataMap maPresetDataMap;
176 static void initializePresetDataMap();
178 sal_Int32 mnArcNum;
179 PropertyMap maExtrusionPropertyMap;
184 #endif // INCLUDED_OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */