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::uno::Reference < css::drawing::XShape > & xShape,
102  const css::awt::Size &aSize );
103 
104  sal_Int32 getShapePresetType() const { return mnShapePresetType; }
105  css::uno::Sequence< sal_Int8 > const & getShapePresetTypeName() const;
106  void setShapePresetType( sal_Int32 nShapePresetType ){ mnShapePresetType = nShapePresetType; };
107  bool getShapeTypeOverride() const { return mbShapeTypeOverride; };
108  void setShapeTypeOverride( bool bShapeTypeOverride ) { mbShapeTypeOverride = bShapeTypeOverride; };
109 
110  std::vector< CustomShapeGuide >& getAdjustmentGuideList(){ return maAdjustmentGuideList; };
111  std::vector< CustomShapeGuide >& getGuideList(){ return maGuideList; };
112  std::vector< AdjustHandle >& getAdjustHandleList(){ return maAdjustHandleList; };
113  std::vector< ConnectionSite >& getConnectionSiteList(){ return maConnectionSiteList; };
115  std::vector< Path2D >& getPath2DList(){ return maPath2DList; };
116  std::vector< css::drawing::EnhancedCustomShapeSegment >& getSegments(){ return maSegments; };
117  void setMirroredX( bool bMirroredX ) { mbMirroredX = bMirroredX; };
118  void setMirroredY( bool bMirroredY ) { mbMirroredY = bMirroredY; };
119  void setTextRotateAngle( sal_Int32 nAngle ) { mnTextRotateAngle = nAngle; };
120  void setTextCameraZRotateAngle( sal_Int32 nAngle ) { mnTextCameraZRotateAngle = nAngle; };
121 
122  static sal_Int32 SetCustomShapeGuideValue( std::vector< CustomShapeGuide >& rGuideList, const CustomShapeGuide& rGuide );
123  static sal_Int32 GetCustomShapeGuideValue( const std::vector< CustomShapeGuide >& rGuideList, std::u16string_view rFormulaName );
124 
125  sal_Int32 getArcNum() { return mnArcNum++; }
126 
127 private:
128 
129  sal_Int32 mnShapePresetType;
131  std::vector< CustomShapeGuide > maAdjustmentGuideList;
132  std::vector< CustomShapeGuide > maGuideList;
133  std::vector< AdjustHandle > maAdjustHandleList;
134  std::vector< ConnectionSite > maConnectionSiteList;
136  std::vector< Path2D > maPath2DList;
137 
138  std::vector< css::drawing::EnhancedCustomShapeSegment >
142  sal_Int32 mnTextRotateAngle;
144 
145  typedef std::unordered_map< sal_Int32, PropertyMap > PresetDataMap;
146 
147  static PresetDataMap maPresetDataMap;
148  static void initializePresetDataMap();
149 
150  sal_Int32 mnArcNum;
151 };
152 
153 }
154 
155 #endif // INCLUDED_OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX
156 
157 /* 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
void pushToPropSet(const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const css::uno::Reference< css::drawing::XShape > &xShape, const css::awt::Size &aSize)
std::vector< ConnectionSite > & getConnectionSiteList()
css::drawing::EnhancedCustomShapeParameter ang
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
std::vector< css::drawing::EnhancedCustomShapeSegment > & getSegments()
std::vector< CustomShapeGuide > maAdjustmentGuideList
css::drawing::EnhancedCustomShapeParameter l