LibreOffice Module oox (master)  1
customshapeproperties.hxx
Go to the documentation of this file.
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>
31 #include <oox/token/tokens.hxx>
32 
33 namespace oox::drawingml {
34 
36 
37 typedef std::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr;
38 
40 {
41  OUString maName;
42  OUString maFormula;
43 };
44 
46 {
47  bool polar;
48  css::drawing::EnhancedCustomShapeParameterPair
49  pos;
50 
51  // depending to the type (polar or not):
52  OptValue< OUString > gdRef1; // gdRefX or gdRefR
54  min1; // minX or minR
56  max1; // maxX or maxR
57  OptValue< OUString > gdRef2; // gdRefY or gdRefAng
59  min2; // minX or minAng
61  max2; // maxY or maxAng
62 
63  AdjustHandle( bool bPolar ) : polar( bPolar ) {};
64 };
65 
67 {
68  css::drawing::EnhancedCustomShapeParameterPair
69  pos;
70  css::drawing::EnhancedCustomShapeParameter
71  ang;
72 };
73 
74 struct GeomRect
75 {
76  css::drawing::EnhancedCustomShapeParameter l;
77  css::drawing::EnhancedCustomShapeParameter t;
78  css::drawing::EnhancedCustomShapeParameter r;
79  css::drawing::EnhancedCustomShapeParameter b;
80 };
81 
82 struct Path2D
83 {
84  sal_Int64 w;
85  sal_Int64 h;
86  sal_Int32 fill;
87  bool stroke;
89  std::vector< css::drawing::EnhancedCustomShapeParameterPair > parameter;
90 
91  Path2D() : w( 0 ), h( 0 ), fill( XML_norm ), stroke( true ), extrusionOk( true ) {};
92 };
93 
94 
96 {
97 public:
99 
100  void pushToPropSet( const css::uno::Reference < css::beans::XPropertySet > & xPropSet,
101  const css::awt::Size &aSize );
102 
103  sal_Int32 getShapePresetType() const { return mnShapePresetType; }
104  css::uno::Sequence< sal_Int8 > const & getShapePresetTypeName() const;
105  void setShapePresetType( sal_Int32 nShapePresetType ){ mnShapePresetType = nShapePresetType; };
106  bool getShapeTypeOverride() const { return mbShapeTypeOverride; };
107  void setShapeTypeOverride( bool bShapeTypeOverride ) { mbShapeTypeOverride = bShapeTypeOverride; };
108 
109  std::vector< CustomShapeGuide >& getAdjustmentGuideList(){ return maAdjustmentGuideList; };
110  std::vector< CustomShapeGuide >& getGuideList(){ return maGuideList; };
111  std::vector< AdjustHandle >& getAdjustHandleList(){ return maAdjustHandleList; };
112  std::vector< ConnectionSite >& getConnectionSiteList(){ return maConnectionSiteList; };
114  std::vector< Path2D >& getPath2DList(){ return maPath2DList; };
115  std::vector< css::drawing::EnhancedCustomShapeSegment >& getSegments(){ return maSegments; };
116  void setMirroredX( bool bMirroredX ) { mbMirroredX = bMirroredX; };
117  void setMirroredY( bool bMirroredY ) { mbMirroredY = bMirroredY; };
118  void setTextRotateAngle( sal_Int32 nAngle ) { mnTextRotateAngle = nAngle; };
119  void setTextCameraZRotateAngle( sal_Int32 nAngle ) { mnTextCameraZRotateAngle = nAngle; };
120 
121  static sal_Int32 SetCustomShapeGuideValue( std::vector< CustomShapeGuide >& rGuideList, const CustomShapeGuide& rGuide );
122  static sal_Int32 GetCustomShapeGuideValue( const std::vector< CustomShapeGuide >& rGuideList, std::u16string_view rFormulaName );
123 
124  sal_Int32 getArcNum() { return mnArcNum++; }
125 
130  bool representsDefaultShape() const;
131 
132 private:
133 
134  sal_Int32 mnShapePresetType;
136  std::vector< CustomShapeGuide > maAdjustmentGuideList;
137  std::vector< CustomShapeGuide > maGuideList;
138  std::vector< AdjustHandle > maAdjustHandleList;
139  std::vector< ConnectionSite > maConnectionSiteList;
141  std::vector< Path2D > maPath2DList;
142 
143  std::vector< css::drawing::EnhancedCustomShapeSegment >
147  sal_Int32 mnTextRotateAngle;
149 
150  typedef std::unordered_map< sal_Int32, PropertyMap > PresetDataMap;
151 
152  static PresetDataMap maPresetDataMap;
153  static void initializePresetDataMap();
154 
155  sal_Int32 mnArcNum;
156 };
157 
158 }
159 
160 #endif // INCLUDED_OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX
161 
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< AdjustHandle > & getAdjustHandleList()
std::vector< ConnectionSite > maConnectionSiteList
css::drawing::EnhancedCustomShapeParameter b
void setShapeTypeOverride(bool bShapeTypeOverride)
static sal_Int32 GetCustomShapeGuideValue(const std::vector< CustomShapeGuide > &rGuideList, std::u16string_view rFormulaName)
std::vector< CustomShapeGuide > & getGuideList()
void setShapePresetType(sal_Int32 nShapePresetType)
OptValue< css::drawing::EnhancedCustomShapeParameter > min1
std::unordered_map< sal_Int32, PropertyMap > PresetDataMap
std::vector< CustomShapeGuide > maGuideList
std::vector< AdjustHandle > maAdjustHandleList
bool representsDefaultShape() const
Returns whether or not the current CustomShapeProperties represent a default shape preset that is rec...
std::vector< ConnectionSite > & getConnectionSiteList()
css::drawing::EnhancedCustomShapeParameter ang
XML_norm
css::drawing::EnhancedCustomShapeParameterPair pos
OptValue< css::drawing::EnhancedCustomShapeParameter > min2
std::vector< css::drawing::EnhancedCustomShapeSegment > maSegments
css::drawing::EnhancedCustomShapeParameter t
css::drawing::EnhancedCustomShapeParameterPair pos
std::vector< CustomShapeGuide > & getAdjustmentGuideList()
css::uno::Sequence< sal_Int8 > const & getShapePresetTypeName() const
css::drawing::EnhancedCustomShapeParameter r
std::vector< css::drawing::EnhancedCustomShapeParameterPair > parameter
OptValue< css::drawing::EnhancedCustomShapeParameter > max1
OptValue< css::drawing::EnhancedCustomShapeParameter > max2
static sal_Int32 SetCustomShapeGuideValue(std::vector< CustomShapeGuide > &rGuideList, const CustomShapeGuide &rGuide)
std::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr
void pushToPropSet(const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const css::awt::Size &aSize)
std::vector< css::drawing::EnhancedCustomShapeSegment > & getSegments()
std::vector< CustomShapeGuide > maAdjustmentGuideList
css::drawing::EnhancedCustomShapeParameter l