1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #ifndef INCLUDED_OOX_EXPORT_DMLPRESETSHAPEXPORT_HXX
11 #define INCLUDED_OOX_EXPORT_DMLPRESETSHAPEXPORT_HXX
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>
18 #include <rtl/ustring.hxx>
19 #include <sal/types.h>
21 #include <string_view>
23 #include <oox/export/drawingml.hxx>
25 namespace com::sun::star::beans
30 namespace com::sun::star::drawing
33 struct EnhancedCustomShapeAdjustmentValue
;
41 namespace oox::drawingml
43 /// Class for exporting the custom shapes to OOXML preset ones, if possible.
44 /// This functionality needed for keeping the information for the office programs
45 /// about the shape type, and geometry data. Before these shapes were exported
46 /// with custom geometry, and they kept their geometry but has no information
47 /// about the shape itself. This lead to lost textbox size/position/padding for
49 class DMLPresetShapeExporter
52 // the shape to export
53 css::uno::Reference
<css::drawing::XShape
> m_xShape
;
55 DrawingML
* m_pDMLexporter
;
56 // the type of the custom shape (diamond/rectangle/circle/triangle...)
57 OUString m_sPresetShapeType
;
58 // True if the shape has points where its geometry can be modified
59 bool m_bHasHandleValues
;
60 // The first the x the second the y coordinate, of flipping
61 std::pair
<bool, bool> m_bIsFlipped
;
63 // Custom Shape Geometry information for export:
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
;
72 //css::awt::Rectangle m_ViewBox;
73 //css::uno::Sequence<css::beans::PropertyValue> m_Path;
74 //css::uno::Sequence<OUString> m_Equations;
77 DMLPresetShapeExporter() = delete;
78 ~DMLPresetShapeExporter();
80 DMLPresetShapeExporter(DrawingML
* pDMLExporter
,
81 css::uno::Reference
<css::drawing::XShape
> xShape
);
83 // Writes the preset shape to the xml
87 struct AdjustmentPointValueBase
89 std::optional
<double> nMaxVal
;
90 std::optional
<double> nMinVal
;
91 std::optional
<double> nCurrVal
;
94 typedef AdjustmentPointValueBase RadiusAdjustmentValue
;
95 typedef AdjustmentPointValueBase AngleAdjustmentValue
;
96 typedef AdjustmentPointValueBase XAdjustmentValue
;
97 typedef AdjustmentPointValueBase YAdjustmentValue
;
99 // Returns true, if the shape has adjusting points
100 bool HasHandleValue() const;
102 // Returns true if the shape flipped.
103 bool IsXFlipped() const { return m_bIsFlipped
.first
; };
104 bool IsYFlipped() const { return m_bIsFlipped
.second
; };
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
);
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();
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();
134 }; // end of DMLPresetShapeExporter class
136 } // end of namespace oox::drawingml
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */