summaryrefslogtreecommitdiff
path: root/include/oox
diff options
context:
space:
mode:
authorAttila Bakos (NISZ) <bakos.attilakaroly@nisz.hu>2021-05-14 13:53:32 +0200
committerLászló Németh <nemeth@numbertext.org>2021-06-23 12:57:40 +0200
commit63cd67e5e18f01aca303131e148c80398a181a41 (patch)
treef096ec2a12b32517fa031019aa57e7acf2914998 /include/oox
parentae31c8503c568171cadc87a0b3de0ca23619afdd (diff)
tdf#92525 tdf#142398: fix export of simple custom shapes
Most of the custom shapes were exported with DrawingML custom geometry instead of DOCX preset shapes, losing their preset type, adjust handles and text position. Add a preset exporter class to handle all possible preset shapes later, and fix the export of the following shapes now: "bevel", "blockArc", "bracePair", "bracketPair", "hexagon", "octagon", "parallelogram", "plus", "roundRect" and "triangle". tdf#92525: keep text position in triangles with different adjustments, too. tdf#142398: part 1: export simple shapes as preset shapes. Change-Id: I6aee74f7670bea8c1fe5909cbf307778ea728669 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115606 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'include/oox')
-rw-r--r--include/oox/export/DMLPresetShapeExport.hxx138
1 files changed, 138 insertions, 0 deletions
diff --git a/include/oox/export/DMLPresetShapeExport.hxx b/include/oox/export/DMLPresetShapeExport.hxx
new file mode 100644
index 000000000000..1ab460d26845
--- /dev/null
+++ b/include/oox/export/DMLPresetShapeExport.hxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+* This file is part of the LibreOffice project.
+*
+* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/.
+*/
+
+#ifndef INCLUDED_OOX_EXPORT_DMLPRESETSHAPEXPORT_HXX
+#define INCLUDED_OOX_EXPORT_DMLPRESETSHAPEXPORT_HXX
+
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+#include <string_view>
+
+#include <oox/export/drawingml.hxx>
+
+namespace com::sun::star::beans
+{
+struct PropertyValue;
+}
+
+namespace com::sun::star::drawing
+{
+class XShape;
+struct EnhancedCustomShapeAdjustmentValue;
+}
+
+namespace oox::core
+{
+class XmlFilterBase;
+}
+
+namespace oox::drawingml
+{
+/// Class for exporting the custom shapes to OOXML preset ones, if possible.
+/// This functionality needed for keeping the information for the office programs
+/// about the shape type, and geometry data. Before these shapes were exported
+/// with custom geometry, and they kept their geometry but has no information
+/// about the shape itself. This lead to lost textbox size/position/padding for
+/// example.
+class DMLPresetShapeExporter
+{
+private:
+ // the shape to export
+ css::uno::Reference<css::drawing::XShape> m_xShape;
+ // the DMLwriter
+ DrawingML* m_pDMLexporter;
+ // the type of the custom shape (diamond/rectangle/circle/triangle...)
+ OUString m_sPresetShapeType;
+ // True if the shape has points where its geometry can be modified
+ bool m_bHasHandleValues;
+ // The first the x the second the y coordinate, of flipping
+ std::pair<bool, bool> m_bIsFlipped;
+
+ // Custom Shape Geometry information for export:
+
+ // The adjusting values stored in this sequence:
+ css::uno::Sequence<css::drawing::EnhancedCustomShapeAdjustmentValue> m_AdjustmentValues;
+ // Shapes what have adjusting points, the range of these points
+ // and the index of the value stored in this sequence:
+ css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>> m_HandleValues;
+
+ //TODO:
+ //css::awt::Rectangle m_ViewBox;
+ //css::uno::Sequence<css::beans::PropertyValue> m_Path;
+ //css::uno::Sequence<OUString> m_Equations;
+
+public:
+ DMLPresetShapeExporter() = delete;
+ ~DMLPresetShapeExporter();
+
+ DMLPresetShapeExporter(DrawingML* pDMLExporter,
+ css::uno::Reference<css::drawing::XShape> xShape);
+
+ // Writes the preset shape to the xml
+ bool WriteShape();
+
+private:
+ struct AdjustmentPointValueBase
+ {
+ double nMaxVal;
+ double nMinVal;
+ double nCurrVal;
+ };
+
+ typedef AdjustmentPointValueBase RadiusAdjustmentValue;
+ typedef AdjustmentPointValueBase AngleAdjustmentValue;
+ typedef AdjustmentPointValueBase XAdjustmentValue;
+ typedef AdjustmentPointValueBase YAdjustmentValue;
+
+ // Returns true, if the shape has adjusting points
+ bool HasHandleValue();
+
+ // Returns true if the shape flipped.
+ bool IsXFlipped() { return m_bIsFlipped.first; };
+ bool IsYFlipped() { return m_bIsFlipped.second; };
+
+ // Returns with the shape type, like triangle for example
+ OUString GetShapeType();
+ // Returns with the handle points
+ css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>> GetHandleValues();
+ // Returns with the adjustment values
+ css::uno::Sequence<css::drawing::EnhancedCustomShapeAdjustmentValue> GetAdjustmentValues();
+ // Returns with the raw value of the given property of the shape geometry.
+ css::uno::Any GetHandleValueOfModificationPoint(sal_Int32 nPoint, std::u16string_view sType);
+ // Returns with the appropriate value of the handle point.
+ RadiusAdjustmentValue GetAdjustmentPointRadiusValue(sal_Int32 nPoint);
+ AngleAdjustmentValue GetAdjustmentPointAngleValue(sal_Int32 nPoint);
+ XAdjustmentValue GetAdjustmentPointXValue(sal_Int32 nPoint);
+ YAdjustmentValue GetAdjustmentPointYValue(sal_Int32 nPoint);
+
+ // Writes one adjustment point.
+ bool WriteAV(const OUString& sValName, const OUString& sVal);
+ // Opens/Closes the AVlist tag.
+ bool StartAVListWriting();
+ bool EndAVListWriting();
+
+ // Finds the given value in the sequence
+ static css::uno::Any FindHandleValue(css::uno::Sequence<css::beans::PropertyValue> aValues,
+ std::u16string_view sKey);
+ // Writes and converts the adjustment points from sdr to ooxml ones per shape type.
+ bool WriteShapeWithAVlist();
+
+}; // end of DMLPresetShapeExporter class
+
+} // end of namespace oox::drawingml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */