LibreOffice Module oox (master)  1
DMLPresetShapeExport.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 
10 #ifndef INCLUDED_OOX_EXPORT_DMLPRESETSHAPEXPORT_HXX
11 #define INCLUDED_OOX_EXPORT_DMLPRESETSHAPEXPORT_HXX
12 
13 #include <com/sun/star/awt/Rectangle.hpp>
14 #include <com/sun/star/uno/Any.hxx>
15 #include <com/sun/star/uno/Reference.hxx>
16 #include <com/sun/star/uno/Sequence.hxx>
17 
18 #include <rtl/ustring.hxx>
19 #include <sal/types.h>
20 
21 #include <string_view>
22 
23 #include <oox/export/drawingml.hxx>
24 
25 namespace com::sun::star::beans
26 {
27 struct PropertyValue;
28 }
29 
31 {
32 class XShape;
33 struct EnhancedCustomShapeAdjustmentValue;
34 }
35 
36 namespace oox::core
37 {
38 class XmlFilterBase;
39 }
40 
41 namespace oox::drawingml
42 {
50 {
51 private:
52  // the shape to export
53  css::uno::Reference<css::drawing::XShape> m_xShape;
54  // the DMLwriter
56  // the type of the custom shape (diamond/rectangle/circle/triangle...)
58  // True if the shape has points where its geometry can be modified
60  // The first the x the second the y coordinate, of flipping
61  std::pair<bool, bool> m_bIsFlipped;
62 
63  // Custom Shape Geometry information for export:
64 
65  // The adjusting values stored in this sequence:
66  css::uno::Sequence<css::drawing::EnhancedCustomShapeAdjustmentValue> m_AdjustmentValues;
67  // Shapes what have adjusting points, the range of these points
68  // and the index of the value stored in this sequence:
69  css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>> m_HandleValues;
70 
71  //TODO:
72  //css::awt::Rectangle m_ViewBox;
73  //css::uno::Sequence<css::beans::PropertyValue> m_Path;
74  //css::uno::Sequence<OUString> m_Equations;
75 
76 public:
77  DMLPresetShapeExporter() = delete;
79 
80  DMLPresetShapeExporter(DrawingML* pDMLExporter,
81  css::uno::Reference<css::drawing::XShape> xShape);
82 
83  // Writes the preset shape to the xml
84  bool WriteShape();
85 
86 private:
88  {
89  std::optional<double> nMaxVal;
90  std::optional<double> nMinVal;
91  std::optional<double> nCurrVal;
92  };
93 
98 
99  // Returns true, if the shape has adjusting points
100  bool HasHandleValue() const;
101 
102  // Returns true if the shape flipped.
103  bool IsXFlipped() const { return m_bIsFlipped.first; };
104  bool IsYFlipped() const { return m_bIsFlipped.second; };
105 
106  // Returns with the shape type, like triangle for example
107  const OUString& GetShapeType() const;
108  // Returns with the handle points
109  const css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>>&
110  GetHandleValues() const;
111  // Returns with the adjustment values
112  const css::uno::Sequence<css::drawing::EnhancedCustomShapeAdjustmentValue>&
113  GetAdjustmentValues() const;
114  // Returns with the raw value of the given property of the shape geometry.
115  css::uno::Any GetHandleValueOfModificationPoint(sal_Int32 nPoint, std::u16string_view sType);
116  // Returns with the appropriate value of the handle point.
117  RadiusAdjustmentValue GetAdjustmentPointRadiusValue(sal_Int32 nPoint);
118  AngleAdjustmentValue GetAdjustmentPointAngleValue(sal_Int32 nPoint);
119  XAdjustmentValue GetAdjustmentPointXValue(sal_Int32 nPoint);
120  YAdjustmentValue GetAdjustmentPointYValue(sal_Int32 nPoint);
121 
122  // Writes one adjustment point.
123  bool WriteAV(const OUString& sValName, const OUString& sVal);
124  // Opens/Closes the AVlist tag.
125  bool StartAVListWriting();
126  bool EndAVListWriting();
127 
128  // Finds the given value in the sequence
129  static css::uno::Any FindHandleValue(css::uno::Sequence<css::beans::PropertyValue> aValues,
130  std::u16string_view sKey);
131  // Writes and converts the adjustment points from sdr to ooxml ones per shape type.
132  bool WriteShapeWithAVlist();
133 
134 }; // end of DMLPresetShapeExporter class
135 
136 } // end of namespace oox::drawingml
137 
138 #endif
139 
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > m_AdjustmentValues
css::uno::Reference< css::drawing::XShape > m_xShape
const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > & GetHandleValues() const
css::uno::Any GetHandleValueOfModificationPoint(sal_Int32 nPoint, std::u16string_view sType)
const css::uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > & GetAdjustmentValues() const
XAdjustmentValue GetAdjustmentPointXValue(sal_Int32 nPoint)
YAdjustmentValue GetAdjustmentPointYValue(sal_Int32 nPoint)
css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > m_HandleValues
RadiusAdjustmentValue GetAdjustmentPointRadiusValue(sal_Int32 nPoint)
AngleAdjustmentValue GetAdjustmentPointAngleValue(sal_Int32 nPoint)
bool WriteAV(const OUString &sValName, const OUString &sVal)
Class for exporting the custom shapes to OOXML preset ones, if possible.
static css::uno::Any FindHandleValue(css::uno::Sequence< css::beans::PropertyValue > aValues, std::u16string_view sKey)