tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / oox / source / export / DMLPresetShapeExport.cxx
blob3e383ac13d8b98da2b73a11eb314e3e995384929
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <oox/export/DMLPresetShapeExport.hxx>
11 #include <oox/token/tokens.hxx>
13 #include <com/sun/star/beans/XPropertySet.hpp>
14 #include <com/sun/star/beans/PropertyValue.hpp>
15 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
16 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
17 #include <com/sun/star/drawing/XShape.hpp>
19 #include <osl/diagnose.h>
20 #include <filter/msfilter/util.hxx>
22 #include <string_view>
24 using namespace ::css;
25 using namespace ::css::drawing;
27 namespace oox::drawingml
29 // DMLPresetShapeExporter class
31 // ctor
32 DMLPresetShapeExporter::DMLPresetShapeExporter(DrawingML* pDMLExporter,
33 css::uno::Reference<css::drawing::XShape> xShape)
34 : m_pDMLexporter(pDMLExporter)
36 // This class only work with custom shapes!
37 OSL_ASSERT(xShape->getShapeType() == "com.sun.star.drawing.CustomShape");
39 m_xShape = std::move(xShape);
40 m_bHasHandleValues = false;
41 uno::Reference<beans::XPropertySet> xShapeProps(m_xShape, uno::UNO_QUERY);
42 css::uno::Sequence<css::beans::PropertyValue> aCustomShapeGeometry
43 = xShapeProps->getPropertyValue(u"CustomShapeGeometry"_ustr)
44 .get<uno::Sequence<beans::PropertyValue>>();
46 for (auto const& rCustomShapeGeometryItem : aCustomShapeGeometry)
48 if (rCustomShapeGeometryItem.Name == "Type")
50 m_sPresetShapeType = rCustomShapeGeometryItem.Value.get<OUString>();
52 if (rCustomShapeGeometryItem.Name == "Handles")
54 m_bHasHandleValues = true;
55 m_HandleValues
56 = rCustomShapeGeometryItem.Value
57 .get<css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>>>();
59 if (rCustomShapeGeometryItem.Name == "AdjustmentValues")
61 m_AdjustmentValues
62 = rCustomShapeGeometryItem.Value
63 .get<css::uno::Sequence<css::drawing::EnhancedCustomShapeAdjustmentValue>>();
65 if (rCustomShapeGeometryItem.Name == "MirroredX")
67 m_bIsFlipped.first = rCustomShapeGeometryItem.Value.get<bool>();
69 if (rCustomShapeGeometryItem.Name == "MirroredY")
71 m_bIsFlipped.second = rCustomShapeGeometryItem.Value.get<bool>();
73 //if (rCustomShapeGeometryItem.Name == "Equations")
74 //{
75 // m_Equations = rCustomShapeGeometryItem.Value.get<css::uno::Sequence<OUString>>();
76 //}
77 //if (rCustomShapeGeometryItem.Name == "Path")
78 //{
79 // m_Path = rCustomShapeGeometryItem
80 // .Value.get<css::uno::Sequence<css::beans::PropertyValue>>();
81 //}
82 //if (rCustomShapeGeometryItem.Name == "ViewBox")
83 //{
84 // m_ViewBox = rCustomShapeGeometryItem.Value.get<css::awt::Rectangle>();
85 //}
89 // dtor
90 DMLPresetShapeExporter::~DMLPresetShapeExporter(){
91 // Do nothing
94 bool DMLPresetShapeExporter::HasHandleValue() const { return m_bHasHandleValues; }
96 const OUString& DMLPresetShapeExporter::GetShapeType() const { return m_sPresetShapeType; }
98 const css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>>&
99 DMLPresetShapeExporter::GetHandleValues() const
101 return m_HandleValues;
104 const css::uno::Sequence<css::drawing::EnhancedCustomShapeAdjustmentValue>&
105 DMLPresetShapeExporter::GetAdjustmentValues() const
107 return m_AdjustmentValues;
110 css::uno::Any DMLPresetShapeExporter::GetHandleValueOfModificationPoint(sal_Int32 nPoint,
111 std::u16string_view sType)
113 uno::Any aRet;
114 if (GetHandleValues().getLength() > nPoint)
116 for (sal_Int32 i = 0; i < GetHandleValues()[nPoint].getLength(); i++)
118 if (GetHandleValues()[nPoint][i].Name == sType)
120 aRet = GetHandleValues()[nPoint][i].Value;
121 break;
125 return aRet;
128 DMLPresetShapeExporter::RadiusAdjustmentValue
129 DMLPresetShapeExporter::GetAdjustmentPointRadiusValue(sal_Int32 nPoint)
131 RadiusAdjustmentValue aRet;
134 auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
135 .get<EnhancedCustomShapeParameterPair>();
136 aRet.nMinVal = GetHandleValueOfModificationPoint(nPoint, u"RadiusRangeMinimum")
137 .get<EnhancedCustomShapeParameter>()
138 .Value.get<double>();
139 aRet.nMaxVal = GetHandleValueOfModificationPoint(nPoint, u"RadiusRangeMaximum")
140 .get<EnhancedCustomShapeParameter>()
141 .Value.get<double>();
142 aRet.nCurrVal = GetAdjustmentValues()[aValPos.First.Value.get<long>()].Value.get<double>();
144 catch (...)
146 // Do nothing.
148 return aRet;
151 DMLPresetShapeExporter::AngleAdjustmentValue
152 DMLPresetShapeExporter::GetAdjustmentPointAngleValue(sal_Int32 nPoint)
154 AngleAdjustmentValue aRet;
157 auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
158 .get<EnhancedCustomShapeParameterPair>();
159 aRet.nMinVal = 0;
160 aRet.nMaxVal = 360;
161 aRet.nCurrVal = GetAdjustmentValues()[aValPos.Second.Value.get<long>()].Value.get<double>();
163 catch (...)
165 // Do nothing.
167 return aRet;
170 DMLPresetShapeExporter::XAdjustmentValue
171 DMLPresetShapeExporter::GetAdjustmentPointXValue(sal_Int32 nPoint)
173 XAdjustmentValue aRet;
176 auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
177 .get<EnhancedCustomShapeParameterPair>();
178 aRet.nMinVal = GetHandleValueOfModificationPoint(nPoint, u"RangeXMinimum")
179 .get<EnhancedCustomShapeParameter>()
180 .Value.get<double>();
181 aRet.nMaxVal = GetHandleValueOfModificationPoint(nPoint, u"RangeXMaximum")
182 .get<EnhancedCustomShapeParameter>()
183 .Value.get<double>();
184 aRet.nCurrVal = GetAdjustmentValues()[aValPos.First.Value.get<long>()].Value.get<double>();
186 catch (...)
188 // Do nothing.
190 return aRet;
193 DMLPresetShapeExporter::YAdjustmentValue
194 DMLPresetShapeExporter::GetAdjustmentPointYValue(sal_Int32 nPoint)
196 YAdjustmentValue aRet;
199 auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
200 .get<EnhancedCustomShapeParameterPair>();
201 aRet.nMinVal = GetHandleValueOfModificationPoint(nPoint, u"RangeYMinimum")
202 .get<EnhancedCustomShapeParameter>()
203 .Value.get<double>();
204 aRet.nMaxVal = GetHandleValueOfModificationPoint(nPoint, u"RangeYMaximum")
205 .get<EnhancedCustomShapeParameter>()
206 .Value.get<double>();
207 aRet.nCurrVal = GetAdjustmentValues()[aValPos.Second.Value.get<long>()].Value.get<double>();
209 catch (...)
211 // Do nothing.
213 return aRet;
216 bool DMLPresetShapeExporter::WriteShape()
218 if (m_pDMLexporter && m_xShape)
220 // Case 1: We do not have adjustment points of the shape: just export it as preset
221 if (!m_bHasHandleValues)
223 OUString sShapeType = GetShapeType();
224 const OString sPresetShape = msfilter::util::GetOOXMLPresetGeometry(sShapeType);
225 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
226 false, false);
227 m_pDMLexporter->WritePresetShape(sPresetShape);
228 return true;
230 else // Case2: There are adjustment points what have to be converted and exported.
232 return WriteShapeWithAVlist();
235 return false;
238 bool DMLPresetShapeExporter::WriteAV(const OUString& sValName, const OUString& sVal)
242 m_pDMLexporter->GetFS()->singleElementNS(XML_a, XML_gd, XML_name, sValName, XML_fmla, sVal);
243 return true;
245 catch (...)
247 return false;
251 bool DMLPresetShapeExporter::StartAVListWriting()
255 const OString aShape = msfilter::util::GetOOXMLPresetGeometry(GetShapeType());
256 m_pDMLexporter->GetFS()->startElementNS(XML_a, XML_prstGeom, XML_prst, aShape);
257 m_pDMLexporter->GetFS()->startElementNS(XML_a, XML_avLst);
258 return true;
260 catch (...)
262 return false;
265 bool DMLPresetShapeExporter::EndAVListWriting()
269 m_pDMLexporter->GetFS()->endElementNS(XML_a, XML_avLst);
270 m_pDMLexporter->GetFS()->endElementNS(XML_a, XML_prstGeom);
271 return true;
273 catch (...)
275 return false;
279 bool DMLPresetShapeExporter::WriteShapeWithAVlist()
281 // Remark: This method is under development. If a shape type is implemented, the corresponding,
282 // return must be set to true. False means nothing done true, export done. There are many
283 // types which do not have pairs in LO, they are do not have to be mapped, because import
284 // filter it does with GrabBag, this method only maps the SDR ones to OOXML shapes.
286 OString sShapeType(msfilter::util::GetOOXMLPresetGeometry(GetShapeType()));
288 // OOXML uses 60th of degree, so 360 degree is 21 600 000 60thdeg
289 const tools::Long nConstOfMaxDegreeOf60th = 21600000;
292 if (sShapeType == "accentBorderCallout1")
294 // LO does not have this type, so it does not necessary to be mapped.
295 return false;
297 if (sShapeType == "accentBorderCallout2")
299 // LO does not have this type, so it does not necessary to be mapped.
300 return false;
302 if (sShapeType == "accentBorderCallout3")
304 // LO does not have this type, so it does not necessary to be mapped.
305 return false;
307 if (sShapeType == "accentCallout1")
309 // LO does not have this type, so it does not necessary to be mapped.
310 return false;
312 if (sShapeType == "accentCallout2")
314 // LO does not have this type, so it does not necessary to be mapped.
315 return false;
317 if (sShapeType == "accentCallout3")
319 // LO does not have this type, so it does not necessary to be mapped.
320 return false;
322 if (sShapeType == "actionButtonBackPrevious")
324 // LO does not have this type, so it does not necessary to be mapped.
325 return false;
327 if (sShapeType == "actionButtonBeginning")
329 // LO does not have this type, so it does not necessary to be mapped.
330 return false;
332 if (sShapeType == "actionButtonBlank")
334 // LO does not have this type, so it does not necessary to be mapped.
335 return false;
337 if (sShapeType == "actionButtonDocument")
339 // LO does not have this type, so it does not necessary to be mapped.
340 return false;
342 if (sShapeType == "actionButtonEnd")
344 // LO does not have this type, so it does not necessary to be mapped.
345 return false;
347 if (sShapeType == "actionButtonForwardNext")
349 // LO does not have this type, so it does not necessary to be mapped.
350 return false;
352 if (sShapeType == "actionButtonHelp")
354 // LO does not have this type, so it does not necessary to be mapped.
355 return false;
357 if (sShapeType == "actionButtonHome")
359 // LO does not have this type, so it does not necessary to be mapped.
360 return false;
362 if (sShapeType == "actionButtonInformation")
364 // LO does not have this type, so it does not necessary to be mapped.
365 return false;
367 if (sShapeType == "actionButtonMovie")
369 // LO does not have this type, so it does not necessary to be mapped.
370 return false;
372 if (sShapeType == "actionButtonReturn")
374 // LO does not have this type, so it does not necessary to be mapped.
375 return false;
377 if (sShapeType == "actionButtonSound")
379 // LO does not have this type, so it does not necessary to be mapped.
380 return false;
382 if (sShapeType == "arc")
384 // LO does not have handle points for this, so CustGeom is enough.
385 return false;
387 if (sShapeType == "bentArrow")
389 // LO has only one type, which have to be rotated, without handling points
390 // So CustGeom enough.
391 return false;
393 if (sShapeType == "bentConnector2")
395 // CustGeom Enough
396 return false;
398 if (sShapeType == "bentConnector3")
400 // CustGeom Enough
401 return false;
403 if (sShapeType == "bentConnector4")
405 // CustGeom Enough
406 return false;
408 if (sShapeType == "bentConnector5")
410 // CustGeom Enough
411 return false;
413 if (sShapeType == "bentUpArrow")
415 // CustGeom Enough, no handle points
416 return false;
418 if (sShapeType == "bevel")
420 auto aPoint1 = GetAdjustmentPointXValue(0);
421 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
422 || !aPoint1.nMinVal.has_value())
423 return false;
424 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
425 false, false);
427 tools::Long nVal1
428 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * 50000);
429 return StartAVListWriting()
430 && WriteAV(u"adj"_ustr, OUString(u"val " + OUString::number(nVal1)))
431 && EndAVListWriting();
433 if (sShapeType == "blockArc")
435 auto aPointR = GetAdjustmentPointRadiusValue(0);
436 auto aPointA = GetAdjustmentPointAngleValue(0);
437 if (!aPointA.nCurrVal.has_value() || !aPointA.nMaxVal.has_value()
438 || !aPointA.nMinVal.has_value() || !aPointR.nCurrVal.has_value()
439 || !aPointR.nMaxVal.has_value() || !aPointR.nMinVal.has_value())
440 return false;
441 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
442 false, false);
443 tools::Long nVal1
444 = std::lround((*aPointA.nCurrVal < 0 ? 360 + *aPointA.nCurrVal : *aPointA.nCurrVal)
445 / (*aPointA.nMaxVal - *aPointA.nMinVal) * nConstOfMaxDegreeOf60th);
446 tools::Long nVal2 = std::lround(
447 (*aPointA.nCurrVal > 180 ? 360 - *aPointA.nCurrVal : 180 - *aPointA.nCurrVal)
448 / (*aPointA.nMaxVal - *aPointA.nMinVal) * nConstOfMaxDegreeOf60th);
449 tools::Long nVal3 = std::lround(
450 50000 - (*aPointR.nCurrVal / (*aPointR.nMaxVal - *aPointR.nMinVal) * 50000));
451 return StartAVListWriting()
452 && WriteAV(u"adj1"_ustr, OUString(u"val " + OUString::number(nVal1)))
453 && WriteAV(u"adj2"_ustr, OUString(u"val " + OUString::number(nVal2)))
454 && WriteAV(u"adj3"_ustr, OUString(u"val " + OUString::number(nVal3)))
455 && EndAVListWriting();
457 if (sShapeType == "borderCallout1")
459 // LO does not have this type, so it does not necessary to be mapped.
460 return false;
462 if (sShapeType == "borderCallout2")
464 // LO does not have this type, so it does not necessary to be mapped.
465 return false;
467 if (sShapeType == "borderCallout3")
469 // LO does not have this type, so it does not necessary to be mapped.
470 return false;
472 if (sShapeType == "bracePair")
474 auto aPoint1 = GetAdjustmentPointYValue(0);
475 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
476 || !aPoint1.nMinVal.has_value())
477 return false;
479 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
480 false, false);
481 tools::Long nVal1
482 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * 25000);
483 return StartAVListWriting()
484 && WriteAV(u"adj"_ustr, OUString(u"val " + OUString::number(nVal1)))
485 && EndAVListWriting();
487 if (sShapeType == "bracketPair")
489 auto aPoint1 = GetAdjustmentPointYValue(0);
490 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
491 || !aPoint1.nMinVal.has_value())
492 return false;
494 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
495 false, false);
496 tools::Long nVal1
497 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * 50000);
498 return StartAVListWriting()
499 && WriteAV(u"adj"_ustr, OUString(u"val " + OUString::number(nVal1)))
500 && EndAVListWriting();
502 if (sShapeType == "callout1")
504 // LO does not have this type, so it does not necessary to be mapped.
505 return false;
507 if (sShapeType == "callout2")
509 // LO does not have this type, so it does not necessary to be mapped.
510 return false;
512 if (sShapeType == "callout3")
514 // LO does not have this type, so it does not necessary to be mapped.
515 return false;
517 if (sShapeType == "can")
519 return false;
520 // Do the export as before.
522 if (sShapeType == "chartPlus")
524 // LO does not have this type, so it does not necessary to be mapped.
525 return false;
527 if (sShapeType == "chartStar")
529 // LO does not have this type, so it does not necessary to be mapped.
530 return false;
532 if (sShapeType == "chartX")
534 // LO does not have this type, so it does not necessary to be mapped.
535 return false;
537 if (sShapeType == "chord")
539 // CustGeom, because LO does not have handle points
540 return false;
542 if (sShapeType == "circularArrow")
544 // LO does not have this type, so it does not necessary to be mapped.
545 return false;
547 if (sShapeType == "cloud")
549 // CustGeom enough
550 return false;
552 if (sShapeType == "cloudCallout")
554 return false;
555 // Works fine without this, so export it like before.
557 if (sShapeType == "cornerTabs")
559 // LO does not have this type, so it does not necessary to be mapped.
560 return false;
562 if (sShapeType == "cube")
564 // Works fine without this, so export it like before.
565 return false;
567 if (sShapeType == "curvedConnector2")
569 // Not necessary to be mapped
570 return false;
572 if (sShapeType == "curvedConnector3")
574 // Not necessary to be mapped
575 return false;
577 if (sShapeType == "curvedConnector4")
579 // Not necessary to be mapped
580 return false;
582 if (sShapeType == "curvedConnector5")
584 // Not necessary to be mapped
585 return false;
587 if (sShapeType == "curvedDownArrow")
589 // LO does not have this type, so it does not necessary to be mapped.
590 return false;
592 if (sShapeType == "curvedLeftArrow")
594 // LO does not have this type, so it does not necessary to be mapped.
595 return false;
597 if (sShapeType == "curvedRightArrow")
599 // LO does not have this type, so it does not necessary to be mapped.
600 return false;
602 if (sShapeType == "curvedUpArrow")
604 // LO does not have this type, so it does not necessary to be mapped.
605 return false;
607 if (sShapeType == "decagon")
609 // LO does not have this type, so it does not necessary to be mapped.
610 return false;
612 if (sShapeType == "diagStripe")
614 // LO does not have this type, so it does not necessary to be mapped.
615 return false;
617 if (sShapeType == "diamond")
619 // It does not have handle points so it do not have to be mapped.
620 return false;
622 if (sShapeType == "dodecagon")
624 // LO does not have this type, so it does not necessary to be mapped.
625 return false;
627 if (sShapeType == "donut")
629 // TODO
630 return false;
632 if (sShapeType == "doubleWave")
634 // LO does not have this type, so it does not necessary to be mapped.
635 return false;
637 if (sShapeType == "downArrow")
639 auto aPointX = GetAdjustmentPointXValue(0);
640 auto aPointY = GetAdjustmentPointYValue(0);
641 if (!aPointX.nCurrVal.has_value() || !aPointX.nMaxVal.has_value()
642 || !aPointX.nMinVal.has_value() || !aPointY.nCurrVal.has_value()
643 || !aPointY.nMaxVal.has_value() || !aPointY.nMinVal.has_value())
644 return false;
646 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
647 false, false);
648 tools::Long nMaxVal1 = 100000;
649 tools::Long nMaxVal2
650 = 100000 * m_xShape->getSize().Height
651 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
652 tools::Long nVal1 = std::lround((*aPointX.nMaxVal - *aPointX.nCurrVal)
653 / (*aPointX.nMaxVal - *aPointX.nMinVal) * nMaxVal1);
654 tools::Long nVal2 = std::lround((*aPointY.nMaxVal - *aPointY.nCurrVal)
655 / (*aPointY.nMaxVal - *aPointY.nMinVal) * nMaxVal2);
656 return StartAVListWriting()
657 && WriteAV(u"adj1"_ustr, OUString(u"val " + OUString::number(nVal1)))
658 && WriteAV(u"adj2"_ustr, OUString(u"val " + OUString::number(nVal2)))
659 && EndAVListWriting();
661 if (sShapeType == "downArrowCallout")
663 auto aNeckFromBox = GetAdjustmentPointXValue(1);
664 auto aHeadFromNeck = GetAdjustmentPointXValue(2);
665 auto aHeadHeight = GetAdjustmentPointYValue(1);
666 auto aBoxHeight = GetAdjustmentPointYValue(0);
667 if (!aNeckFromBox.nCurrVal.has_value() || !aNeckFromBox.nMaxVal.has_value()
668 || !aNeckFromBox.nMinVal.has_value() || !aHeadFromNeck.nCurrVal.has_value()
669 || !aHeadFromNeck.nMaxVal.has_value() || !aHeadFromNeck.nMinVal.has_value()
670 || !aHeadHeight.nCurrVal.has_value() || !aHeadHeight.nMaxVal.has_value()
671 || !aHeadHeight.nMinVal.has_value() || !aBoxHeight.nCurrVal.has_value()
672 || !aBoxHeight.nMaxVal.has_value() || !aBoxHeight.nMinVal.has_value())
673 return false;
675 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
676 false, false);
677 tools::Long nMaxVal1
678 = 100000 * m_xShape->getSize().Width
679 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
680 tools::Long nMaxVal2
681 = 50000 * m_xShape->getSize().Width
682 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
683 tools::Long nMaxVal3
684 = 100000 * m_xShape->getSize().Height
685 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
686 tools::Long nVal1
687 = std::lround((*aNeckFromBox.nMaxVal - *aNeckFromBox.nCurrVal)
688 / (*aNeckFromBox.nMaxVal - *aNeckFromBox.nMinVal) * nMaxVal1);
689 tools::Long nVal2 = std::lround((10800 - *aHeadFromNeck.nCurrVal)
690 / (10800 - *aHeadFromNeck.nMinVal) * nMaxVal2);
691 tools::Long nVal3
692 = std::lround((*aHeadHeight.nMaxVal - *aHeadHeight.nCurrVal)
693 / (*aHeadHeight.nMaxVal - *aHeadHeight.nMinVal) * nMaxVal3);
694 tools::Long nVal4 = std::lround((*aBoxHeight.nCurrVal - *aBoxHeight.nMinVal)
695 / (21600 - *aBoxHeight.nMinVal) * 100000);
696 return StartAVListWriting()
697 && WriteAV(u"adj1"_ustr, OUString(u"val " + OUString::number(nVal1)))
698 && WriteAV(u"adj2"_ustr, OUString(u"val " + OUString::number(nVal2)))
699 && WriteAV(u"adj3"_ustr, OUString(u"val " + OUString::number(nVal3)))
700 && WriteAV(u"adj4"_ustr, OUString(u"val " + OUString::number(nVal4)))
701 && EndAVListWriting();
703 if (sShapeType == "ellipse")
705 // Does not have handle points, so preset enough.
706 return false;
708 if (sShapeType == "ellipseRibbon")
710 // LO does not have this type, so it does not necessary to be mapped.
711 return false;
713 if (sShapeType == "ellipseRibbon2")
715 // LO does not have this type, so it does not necessary to be mapped.
716 return false;
718 if (sShapeType == "flowChartAlternateProcess")
720 // Does not have handle points, so preset enough.
721 return false;
723 if (sShapeType == "flowChartCollate")
725 // Does not have handle points, so preset enough.
726 return false;
728 if (sShapeType == "flowChartConnector")
730 // Does not have handle points, so preset enough.
731 return false;
733 if (sShapeType == "flowChartDecision")
735 // Does not have handle points, so preset enough.
736 return false;
738 if (sShapeType == "flowChartDelay")
740 // Does not have handle points, so preset enough.
741 return false;
743 if (sShapeType == "flowChartDisplay")
745 // Does not have handle points, so preset enough.
746 return false;
748 if (sShapeType == "flowChartDocument")
750 // Does not have handle points, so preset enough.
751 return false;
753 if (sShapeType == "flowChartExtract")
755 // Does not have handle points, so preset enough.
756 return false;
758 if (sShapeType == "flowChartInputOutput")
760 // Does not have handle points, so preset enough.
761 return false;
763 if (sShapeType == "flowChartInternalStorage")
765 // Does not have handle points, so preset enough.
766 return false;
768 if (sShapeType == "flowChartMagneticDisk")
770 // Does not have handle points, so preset enough.
771 return false;
773 if (sShapeType == "flowChartMagneticDrum")
775 // Does not have handle points, so preset enough.
776 return false;
778 if (sShapeType == "flowChartMagneticTape")
780 // Does not have handle points, so preset enough.
781 return false;
783 if (sShapeType == "flowChartManualInput")
785 // Does not have handle points, so preset enough.
786 return false;
788 if (sShapeType == "flowChartManualOperation")
790 // Does not have handle points, so preset enough.
791 return false;
793 if (sShapeType == "flowChartMerge")
795 // Does not have handle points, so preset enough.
796 return false;
798 if (sShapeType == "flowChartMultidocument")
800 // Does not have handle points, so preset enough.
801 return false;
803 if (sShapeType == "flowChartOfflineStorage")
805 // Does not have handle points, so preset enough.
806 return false;
808 if (sShapeType == "flowChartOffpageConnector")
810 // Does not have handle points, so preset enough.
811 return false;
813 if (sShapeType == "flowChartOnlineStorage")
815 // Does not have handle points, so preset enough.
816 return false;
818 if (sShapeType == "flowChartOr")
820 // Does not have handle points, so preset enough.
821 return false;
823 if (sShapeType == "flowChartPredefinedProcess")
825 // Does not have handle points, so preset enough.
826 return false;
828 if (sShapeType == "flowChartPreparation")
830 // Does not have handle points, so preset enough.
831 return false;
833 if (sShapeType == "flowChartPunchedCard")
835 // Does not have handle points, so preset enough.
836 return false;
838 if (sShapeType == "flowChartPunchedTape")
840 // Does not have handle points, so preset enough.
841 return false;
843 if (sShapeType == "flowChartSort")
845 // Does not have handle points, so preset enough.
846 return false;
848 if (sShapeType == "flowChartSummingJunction")
850 // Does not have handle points, so preset enough.
851 return false;
853 if (sShapeType == "flowChartTerminator")
855 // Does not have handle points, so preset enough.
856 return false;
858 if (sShapeType == "foldedCorner")
860 // TODO
861 return false;
863 if (sShapeType == "frame")
865 // TODO
866 return false;
868 if (sShapeType == "funnel")
870 // Not found in word
871 return false;
873 if (sShapeType == "gear6")
875 // Not found in word
876 return false;
878 if (sShapeType == "gear9")
880 // Not found in word
881 return false;
883 if (sShapeType == "halfFrame")
885 // LO does not have this type, not necessary to map
886 return false;
888 if (sShapeType == "heart")
890 // TODO
891 return false;
893 if (sShapeType == "heptagon")
895 // LO does not have this type, not necessary to map
896 return false;
898 if (sShapeType == "hexagon")
900 auto aPoint1 = GetAdjustmentPointXValue(0);
901 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
902 || !aPoint1.nMinVal.has_value())
903 return false;
905 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
906 false, false);
907 tools::Long nMaxVal = 50000 * m_xShape->getSize().Width
908 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
909 tools::Long nVal1
910 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * nMaxVal);
911 return StartAVListWriting()
912 && WriteAV(u"adj"_ustr, OUString(u"val " + OUString::number(nVal1)))
913 && WriteAV(u"vf"_ustr, OUString(u"val " + OUString::number(115470)))
914 && EndAVListWriting();
916 if (sShapeType == "homePlate")
918 // Not found in word
919 return false;
921 if (sShapeType == "horizontalScroll")
923 // TODO
924 return false;
926 if (sShapeType == "irregularSeal1")
928 // Not found in word
929 return false;
931 if (sShapeType == "irregularSeal2")
933 // Not found in word
934 return false;
936 if (sShapeType == "leftArrow")
938 auto aPointX = GetAdjustmentPointXValue(0);
939 auto aPointY = GetAdjustmentPointYValue(0);
940 if (!aPointX.nCurrVal.has_value() || !aPointX.nMaxVal.has_value()
941 || !aPointX.nMinVal.has_value() || !aPointY.nCurrVal.has_value()
942 || !aPointY.nMaxVal.has_value() || !aPointY.nMinVal.has_value())
943 return false;
945 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
946 false, false);
947 tools::Long nMaxVal1 = 100000;
948 tools::Long nMaxVal2
949 = 100000
950 * (double(m_xShape->getSize().Width)
951 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height));
952 tools::Long nVal1 = std::lround((*aPointY.nMaxVal - *aPointY.nCurrVal)
953 / (*aPointY.nMaxVal - *aPointY.nMinVal) * nMaxVal1);
954 tools::Long nVal2 = std::lround((*aPointX.nCurrVal - *aPointX.nMinVal)
955 / (*aPointX.nMaxVal - *aPointX.nMinVal) * nMaxVal2);
956 return StartAVListWriting()
957 && WriteAV(u"adj1"_ustr, OUString(u"val " + OUString::number(nVal1)))
958 && WriteAV(u"adj2"_ustr, OUString(u"val " + OUString::number(nVal2)))
959 && EndAVListWriting();
961 if (sShapeType == "leftArrowCallout")
963 auto aBoxWidth = GetAdjustmentPointXValue(0);
964 auto aNeckLength = GetAdjustmentPointXValue(1);
965 auto aNeckFromBox = GetAdjustmentPointYValue(1);
966 auto aHeadFromNeck = GetAdjustmentPointYValue(2);
967 if (!aBoxWidth.nCurrVal.has_value() || !aBoxWidth.nMaxVal.has_value()
968 || !aBoxWidth.nMinVal.has_value() || !aNeckLength.nCurrVal.has_value()
969 || !aNeckLength.nMaxVal.has_value() || !aNeckLength.nMinVal.has_value()
970 || !aNeckFromBox.nCurrVal.has_value() || !aNeckFromBox.nMaxVal.has_value()
971 || !aNeckFromBox.nMinVal.has_value() || !aHeadFromNeck.nCurrVal.has_value()
972 || !aHeadFromNeck.nMaxVal.has_value() || !aHeadFromNeck.nMinVal.has_value())
973 return false;
975 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
976 false, false);
977 tools::Long nMaxVal1
978 = 100000 * m_xShape->getSize().Height
979 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
980 tools::Long nMaxVal2
981 = 50000 * m_xShape->getSize().Height
982 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
983 tools::Long nMaxVal3
984 = 100000 * m_xShape->getSize().Width
985 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
986 tools::Long nVal1
987 = std::lround((*aNeckFromBox.nMaxVal - *aNeckFromBox.nCurrVal)
988 / (*aNeckFromBox.nMaxVal - *aNeckFromBox.nMinVal) * nMaxVal1);
989 tools::Long nVal2 = std::lround((10800 - *aHeadFromNeck.nCurrVal)
990 / (10800 - *aHeadFromNeck.nMinVal) * nMaxVal2);
991 tools::Long nVal3 = std::lround((*aNeckLength.nCurrVal - *aNeckLength.nMinVal)
992 / (21600 - *aNeckLength.nMinVal) * nMaxVal3);
993 tools::Long nVal4 = std::lround((*aBoxWidth.nMaxVal - *aBoxWidth.nCurrVal)
994 / (*aBoxWidth.nMaxVal - *aBoxWidth.nMinVal) * 100000);
995 return StartAVListWriting()
996 && WriteAV(u"adj1"_ustr, OUString(u"val " + OUString::number(nVal1)))
997 && WriteAV(u"adj2"_ustr, OUString(u"val " + OUString::number(nVal2)))
998 && WriteAV(u"adj3"_ustr, OUString(u"val " + OUString::number(nVal3)))
999 && WriteAV(u"adj4"_ustr, OUString(u"val " + OUString::number(nVal4)))
1000 && EndAVListWriting();
1002 if (sShapeType == "leftBrace")
1004 // TODO
1005 return false;
1007 if (sShapeType == "leftBracket")
1009 // TODO
1010 return false;
1012 if (sShapeType == "leftCircularArrow")
1014 // LO does not have this type, not necessary to map
1015 return false;
1017 if (sShapeType == "leftRightArrow")
1019 auto aPointX = GetAdjustmentPointXValue(0);
1020 auto aPointY = GetAdjustmentPointYValue(0);
1021 if (!aPointX.nCurrVal.has_value() || !aPointX.nMaxVal.has_value()
1022 || !aPointX.nMinVal.has_value() || !aPointY.nCurrVal.has_value()
1023 || !aPointY.nMaxVal.has_value() || !aPointY.nMinVal.has_value())
1024 return false;
1026 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
1027 false, false);
1028 tools::Long nMaxVal1 = 100000;
1029 tools::Long nMaxVal2
1030 = 50000
1031 * (double(m_xShape->getSize().Width)
1032 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height));
1033 tools::Long nVal1 = std::lround((*aPointY.nMaxVal - *aPointY.nCurrVal)
1034 / (*aPointY.nMaxVal - *aPointY.nMinVal) * nMaxVal1);
1035 tools::Long nVal2 = std::lround((*aPointX.nCurrVal - *aPointX.nMinVal)
1036 / (*aPointX.nMaxVal - *aPointX.nMinVal) * nMaxVal2);
1037 return StartAVListWriting()
1038 && WriteAV(u"adj1"_ustr, OUString(u"val " + OUString::number(nVal1)))
1039 && WriteAV(u"adj2"_ustr, OUString(u"val " + OUString::number(nVal2)))
1040 && EndAVListWriting();
1042 if (sShapeType == "leftRightArrowCallout")
1044 auto aNeckFromBox = GetAdjustmentPointXValue(1);
1045 auto aHeadFromNeck = GetAdjustmentPointXValue(2);
1046 auto aHeadHeight = GetAdjustmentPointYValue(1);
1047 auto aBoxHeight = GetAdjustmentPointYValue(0);
1048 if (!aNeckFromBox.nCurrVal.has_value() || !aNeckFromBox.nMaxVal.has_value()
1049 || !aNeckFromBox.nMinVal.has_value() || !aHeadFromNeck.nCurrVal.has_value()
1050 || !aHeadFromNeck.nMaxVal.has_value() || !aHeadFromNeck.nMinVal.has_value()
1051 || !aHeadHeight.nCurrVal.has_value() || !aHeadHeight.nMaxVal.has_value()
1052 || !aHeadHeight.nMinVal.has_value() || !aBoxHeight.nCurrVal.has_value()
1053 || !aBoxHeight.nMaxVal.has_value() || !aBoxHeight.nMinVal.has_value())
1054 return false;
1056 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
1057 false, false);
1058 tools::Long nMaxVal1
1059 = 100000 * m_xShape->getSize().Width
1060 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1061 tools::Long nMaxVal2
1062 = 50000 * m_xShape->getSize().Width
1063 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1064 tools::Long nMaxVal3
1065 = 100000 * m_xShape->getSize().Height
1066 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1067 tools::Long nVal1
1068 = std::lround((*aNeckFromBox.nMaxVal - *aNeckFromBox.nCurrVal)
1069 / (*aNeckFromBox.nMaxVal - *aNeckFromBox.nMinVal) * nMaxVal1);
1070 tools::Long nVal2 = std::lround((10800 - *aHeadFromNeck.nCurrVal)
1071 / (10800 - *aHeadFromNeck.nMinVal) * nMaxVal2);
1072 tools::Long nVal3 = std::lround((*aHeadHeight.nCurrVal - *aHeadHeight.nMinVal)
1073 / (21600 - *aHeadHeight.nMinVal) * nMaxVal3);
1074 tools::Long nVal4 = std::lround((*aBoxHeight.nCurrVal - *aBoxHeight.nMinVal)
1075 / (10800 - *aBoxHeight.nMinVal) * 100000);
1076 return StartAVListWriting()
1077 && WriteAV(u"adj1"_ustr, OUString(u"val " + OUString::number(nVal1)))
1078 && WriteAV(u"adj2"_ustr, OUString(u"val " + OUString::number(nVal2)))
1079 && WriteAV(u"adj3"_ustr, OUString(u"val " + OUString::number(nVal3)))
1080 && WriteAV(u"adj4"_ustr, OUString(u"val " + OUString::number(nVal4)))
1081 && EndAVListWriting();
1083 if (sShapeType == "leftRightCircularArrow")
1085 // Not found in word
1086 return false;
1088 if (sShapeType == "leftRightRibbon")
1090 // LO does not have this type so mapping not necessary
1091 return false;
1093 if (sShapeType == "leftRightUpArrow")
1095 // TODO?
1096 // MS Word stretches the arrow to fit the bounding box; LO doesn't
1097 return false;
1099 if (sShapeType == "leftUpArrow")
1101 // MS Word's and LO's interpretations of what a leftUpArrow should look like
1102 // are too different to find a compromise :(
1104 if (sShapeType == "lightningBolt")
1106 // Difference between the SDR and OOXML variants, custgeom?
1107 return false;
1109 if (sShapeType == "line")
1111 // Not necessary
1112 return false;
1114 if (sShapeType == "lineInv")
1116 // Not necessary
1117 return false;
1119 if (sShapeType == "mathDivide")
1121 // LO does not have this type so mapping not necessary
1122 return false;
1124 if (sShapeType == "mathEqual")
1126 // LO does not have this type so mapping not necessary
1127 return false;
1129 if (sShapeType == "mathMinus")
1131 // LO does not have this type so mapping not necessary
1132 return false;
1134 if (sShapeType == "mathMultiply")
1136 // LO does not have this type so mapping not necessary
1137 return false;
1139 if (sShapeType == "mathNotEqual")
1141 // LO does not have this type so mapping not necessary
1142 return false;
1144 if (sShapeType == "mathPlus")
1146 // LO does not have this type so mapping not necessary
1147 return false;
1149 if (sShapeType == "nonIsoscelesTrapezoid")
1151 // TODO
1152 return false;
1154 if (sShapeType == "noSmoking")
1156 // TODO
1157 return false;
1159 if (sShapeType == "notchedRightArrow")
1161 // TODO
1162 return false;
1164 if (sShapeType == "octagon")
1166 auto aPoint1 = GetAdjustmentPointXValue(0);
1167 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
1168 || !aPoint1.nMinVal.has_value())
1169 return false;
1171 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
1172 false, false);
1173 tools::Long nVal1
1174 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * 50000);
1175 return StartAVListWriting()
1176 && WriteAV(u"adj"_ustr, OUString(u"val " + OUString::number(nVal1)))
1177 && EndAVListWriting();
1179 if (sShapeType == "parallelogram")
1181 auto aPoint1 = GetAdjustmentPointXValue(0);
1182 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
1183 || !aPoint1.nMinVal.has_value())
1184 return false;
1186 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
1187 false, false);
1188 tools::Long nMaxVal = 100000 * m_xShape->getSize().Width
1189 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1190 tools::Long nVal1
1191 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * nMaxVal);
1192 return StartAVListWriting()
1193 && WriteAV(u"adj"_ustr, OUString(u"val " + OUString::number(nVal1)))
1194 && EndAVListWriting();
1196 if (sShapeType == "pentagon")
1198 // TODO
1199 return false;
1201 if (sShapeType == "pie")
1203 // TODO
1204 return false;
1206 if (sShapeType == "pieWedge")
1208 // Not found in word.
1209 return false;
1211 if (sShapeType == "plaque")
1213 // TODO
1214 return false;
1216 if (sShapeType == "plaqueTabs")
1218 // LO does not have this, so not necessary to map.
1219 return false;
1221 if (sShapeType == "plus")
1223 auto aPoint1 = GetAdjustmentPointXValue(0);
1224 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
1225 || !aPoint1.nMinVal.has_value())
1226 return false;
1228 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
1229 false, false);
1230 tools::Long nVal1
1231 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * 50000);
1232 return StartAVListWriting()
1233 && WriteAV(u"adj"_ustr, OUString(u"val " + OUString::number(nVal1)))
1234 && EndAVListWriting();
1236 if (sShapeType == "quadArrow")
1238 // TODO
1239 return false;
1241 if (sShapeType == "quadArrowCallout")
1243 // TODO
1244 return false;
1246 if (sShapeType == "rect")
1248 // preset enough without AV points.
1249 return false;
1251 if (sShapeType == "ribbon")
1253 // LO does not have this, so not necessary to map.
1254 return false;
1256 if (sShapeType == "ribbon2")
1258 // LO does not have this, so not necessary to map.
1259 return false;
1261 if (sShapeType == "rightArrow")
1263 auto aPointX = GetAdjustmentPointXValue(0);
1264 auto aPointY = GetAdjustmentPointYValue(0);
1265 if (!aPointX.nCurrVal.has_value() || !aPointX.nMaxVal.has_value()
1266 || !aPointX.nMinVal.has_value() || !aPointY.nCurrVal.has_value()
1267 || !aPointY.nMaxVal.has_value() || !aPointY.nMinVal.has_value())
1268 return false;
1270 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
1271 false, false);
1272 tools::Long nMaxVal1 = 100000;
1273 tools::Long nMaxVal2
1274 = 100000
1275 * (double(m_xShape->getSize().Width)
1276 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height));
1277 tools::Long nVal1 = std::lround((*aPointY.nMaxVal - *aPointY.nCurrVal)
1278 / (*aPointY.nMaxVal - *aPointY.nMinVal) * nMaxVal1);
1279 tools::Long nVal2 = std::lround((*aPointX.nMaxVal - *aPointX.nCurrVal)
1280 / (*aPointX.nMaxVal - *aPointX.nMinVal) * nMaxVal2);
1281 return StartAVListWriting()
1282 && WriteAV(u"adj1"_ustr, OUString(u"val " + OUString::number(nVal1)))
1283 && WriteAV(u"adj2"_ustr, OUString(u"val " + OUString::number(nVal2)))
1284 && EndAVListWriting();
1286 if (sShapeType == "rightArrowCallout")
1288 auto aBoxWidth = GetAdjustmentPointXValue(0);
1289 auto aNeckLength = GetAdjustmentPointXValue(1);
1290 auto aNeckFromBox = GetAdjustmentPointYValue(1);
1291 auto aHeadFromNeck = GetAdjustmentPointYValue(2);
1292 if (!aBoxWidth.nCurrVal.has_value() || !aBoxWidth.nMaxVal.has_value()
1293 || !aBoxWidth.nMinVal.has_value() || !aNeckLength.nCurrVal.has_value()
1294 || !aNeckLength.nMaxVal.has_value() || !aNeckLength.nMinVal.has_value()
1295 || !aNeckFromBox.nCurrVal.has_value() || !aNeckFromBox.nMaxVal.has_value()
1296 || !aNeckFromBox.nMinVal.has_value() || !aHeadFromNeck.nCurrVal.has_value()
1297 || !aHeadFromNeck.nMaxVal.has_value() || !aHeadFromNeck.nMinVal.has_value())
1298 return false;
1300 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
1301 false, false);
1302 tools::Long nMaxVal1
1303 = 100000 * m_xShape->getSize().Height
1304 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1305 tools::Long nMaxVal2
1306 = 50000 * m_xShape->getSize().Height
1307 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1308 tools::Long nMaxVal3
1309 = 100000 * m_xShape->getSize().Width
1310 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1311 tools::Long nVal1
1312 = std::lround((*aNeckFromBox.nMaxVal - *aNeckFromBox.nCurrVal)
1313 / (*aNeckFromBox.nMaxVal - *aNeckFromBox.nMinVal) * nMaxVal1);
1314 tools::Long nVal2 = std::lround((10800 - *aHeadFromNeck.nCurrVal)
1315 / (10800 - *aHeadFromNeck.nMinVal) * nMaxVal2);
1316 tools::Long nVal3
1317 = std::lround((*aNeckLength.nMaxVal - *aNeckLength.nCurrVal)
1318 / (*aNeckLength.nMaxVal - *aNeckLength.nMinVal) * nMaxVal3);
1319 tools::Long nVal4 = std::lround((*aBoxWidth.nCurrVal - *aBoxWidth.nMinVal)
1320 / (21600 - *aBoxWidth.nMinVal) * 100000);
1321 return StartAVListWriting()
1322 && WriteAV(u"adj1"_ustr, OUString(u"val " + OUString::number(nVal1)))
1323 && WriteAV(u"adj2"_ustr, OUString(u"val " + OUString::number(nVal2)))
1324 && WriteAV(u"adj3"_ustr, OUString(u"val " + OUString::number(nVal3)))
1325 && WriteAV(u"adj4"_ustr, OUString(u"val " + OUString::number(nVal4)))
1326 && EndAVListWriting();
1328 if (sShapeType == "rightBrace")
1330 // TODO
1331 return false;
1333 if (sShapeType == "rightBracket")
1335 // TODO
1336 return false;
1338 if (sShapeType == "round1Rect")
1340 // LO does not have this, so not necessary to map.
1341 return false;
1343 if (sShapeType == "round2DiagRect")
1345 // LO does not have this, so not necessary to map.
1346 return false;
1348 if (sShapeType == "round2SameRect")
1350 // LO does not have this, so not necessary to map.
1351 return false;
1353 if (sShapeType == "roundRect")
1355 tools::Long nVal1 = 0;
1356 if (m_xShape->getSize().Width >= m_xShape->getSize().Height)
1358 auto aPointX = GetAdjustmentPointXValue(0);
1359 if (!aPointX.nCurrVal.has_value() || !aPointX.nMaxVal.has_value()
1360 || !aPointX.nMinVal.has_value())
1361 return false;
1362 nVal1 = std::lround(*aPointX.nCurrVal / (*aPointX.nMaxVal - *aPointX.nMinVal)
1363 * 50000);
1365 else
1367 auto aPointY = GetAdjustmentPointYValue(0);
1368 if (!aPointY.nCurrVal.has_value() || !aPointY.nMaxVal.has_value()
1369 || !aPointY.nMinVal.has_value())
1370 return false;
1371 nVal1 = std::lround(*aPointY.nCurrVal / (*aPointY.nMaxVal - *aPointY.nMinVal)
1372 * 50000);
1375 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
1376 false, false);
1377 return StartAVListWriting()
1378 && WriteAV(u"adj"_ustr, OUString(u"val " + OUString::number(nVal1)))
1379 && EndAVListWriting();
1381 if (sShapeType == "rtTriangle")
1383 // Does not have AV points not necessary to map
1384 return false;
1386 if (sShapeType == "smileyFace")
1388 // TODO
1389 return false;
1391 if (sShapeType == "snip1Rect")
1393 // LO does not have this, so not necessary to map.
1394 return false;
1396 if (sShapeType == "snip2DiagRect")
1398 // LO does not have this, so not necessary to map.
1399 return false;
1401 if (sShapeType == "snip2SameRect")
1403 // LO does not have this, so not necessary to map.
1404 return false;
1406 if (sShapeType == "snipRoundRect")
1408 // LO does not have this, so not necessary to map.
1409 return false;
1411 if (sShapeType == "squareTabs")
1413 // LO does not have this, so not necessary to map.
1414 return false;
1416 if (sShapeType == "star10")
1418 // LO does not have this, so not necessary to map.
1419 return false;
1421 if (sShapeType == "star12")
1423 // TODO
1424 return false;
1426 if (sShapeType == "star16")
1428 // LO does not have this, so not necessary to map.
1429 return false;
1431 if (sShapeType == "star24")
1433 // TODO
1434 return false;
1436 if (sShapeType == "star32")
1438 // LO does not have this, so not necessary to map.
1439 return false;
1441 if (sShapeType == "star4")
1443 // TODO
1444 return false;
1446 if (sShapeType == "star5")
1448 // TODO
1449 return false;
1451 if (sShapeType == "star6")
1453 // TODO
1454 return false;
1456 if (sShapeType == "star7")
1458 // LO does not have this, so not necessary to map.
1459 return false;
1461 if (sShapeType == "star8")
1463 // TODO
1464 return false;
1466 if (sShapeType == "straightConnector1")
1468 // Not necessary to map.
1469 return false;
1471 if (sShapeType == "stripedRightArrow")
1473 // TODO
1474 return false;
1476 if (sShapeType == "sun")
1478 // TODO
1479 return false;
1481 if (sShapeType == "swooshArrow")
1483 // Not found in word.
1484 return false;
1486 if (sShapeType == "teardrop")
1488 // TODO
1489 return false;
1491 if (sShapeType == "trapezoid")
1493 // Preset enough.
1494 return false;
1496 if (sShapeType == "triangle")
1498 auto aPoint1 = GetAdjustmentPointXValue(0);
1499 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
1500 || !aPoint1.nMinVal.has_value())
1501 return false;
1503 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
1504 false, false);
1505 tools::Long nMaxVal = 100000;
1506 tools::Long nVal1
1507 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * nMaxVal);
1508 return StartAVListWriting()
1509 && WriteAV(u"adj"_ustr, OUString(u"val " + OUString::number(nVal1)))
1510 && EndAVListWriting();
1512 if (sShapeType == "upArrowCallout")
1514 auto aNeckFromBox = GetAdjustmentPointXValue(1);
1515 auto aHeadFromNeck = GetAdjustmentPointXValue(2);
1516 auto aHeadHeight = GetAdjustmentPointYValue(1);
1517 auto aBoxHeight = GetAdjustmentPointYValue(0);
1518 if (!aNeckFromBox.nCurrVal.has_value() || !aNeckFromBox.nMaxVal.has_value()
1519 || !aNeckFromBox.nMinVal.has_value() || !aHeadFromNeck.nCurrVal.has_value()
1520 || !aHeadFromNeck.nMaxVal.has_value() || !aHeadFromNeck.nMinVal.has_value()
1521 || !aHeadHeight.nCurrVal.has_value() || !aHeadHeight.nMaxVal.has_value()
1522 || !aHeadHeight.nMinVal.has_value() || !aBoxHeight.nCurrVal.has_value()
1523 || !aBoxHeight.nMaxVal.has_value() || !aBoxHeight.nMinVal.has_value())
1524 return false;
1526 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
1527 false, false);
1528 tools::Long nMaxVal1
1529 = 100000 * m_xShape->getSize().Width
1530 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1531 tools::Long nMaxVal2
1532 = 50000 * m_xShape->getSize().Width
1533 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1534 tools::Long nMaxVal3
1535 = 100000 * m_xShape->getSize().Height
1536 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1537 tools::Long nVal1
1538 = std::lround((*aNeckFromBox.nMaxVal - *aNeckFromBox.nCurrVal)
1539 / (*aNeckFromBox.nMaxVal - *aNeckFromBox.nMinVal) * nMaxVal1);
1540 tools::Long nVal2 = std::lround((10800 - *aHeadFromNeck.nCurrVal)
1541 / (10800 - *aHeadFromNeck.nMinVal) * nMaxVal2);
1542 tools::Long nVal3 = std::lround((*aHeadHeight.nCurrVal - *aHeadHeight.nMinVal)
1543 / (21600 - *aHeadHeight.nMinVal) * nMaxVal3);
1544 tools::Long nVal4 = std::lround((*aBoxHeight.nCurrVal - *aBoxHeight.nMinVal)
1545 / (10800 - *aBoxHeight.nMinVal) * 100000);
1546 return StartAVListWriting()
1547 && WriteAV(u"adj1"_ustr, OUString(u"val " + OUString::number(nVal1)))
1548 && WriteAV(u"adj2"_ustr, OUString(u"val " + OUString::number(nVal2)))
1549 && WriteAV(u"adj3"_ustr, OUString(u"val " + OUString::number(nVal3)))
1550 && WriteAV(u"adj4"_ustr, OUString(u"val " + OUString::number(nVal4)))
1551 && EndAVListWriting();
1553 if (sShapeType == "upDownArrow")
1555 auto aPointX = GetAdjustmentPointXValue(0);
1556 auto aPointY = GetAdjustmentPointYValue(0);
1557 if (!aPointX.nCurrVal.has_value() || !aPointX.nMaxVal.has_value()
1558 || !aPointX.nMinVal.has_value() || !aPointY.nCurrVal.has_value()
1559 || !aPointY.nMaxVal.has_value() || !aPointY.nMinVal.has_value())
1560 return false;
1562 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
1563 false, false);
1564 tools::Long nMaxVal1 = 100000;
1565 tools::Long nMaxVal2
1566 = 50000 * m_xShape->getSize().Height
1567 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1568 tools::Long nVal1 = std::lround((*aPointX.nMaxVal - *aPointX.nCurrVal)
1569 / (*aPointX.nMaxVal - *aPointX.nMinVal) * nMaxVal1);
1570 tools::Long nVal2 = std::lround((*aPointY.nCurrVal - *aPointY.nMinVal)
1571 / (*aPointY.nMaxVal - *aPointY.nMinVal) * nMaxVal2);
1572 return StartAVListWriting()
1573 && WriteAV(u"adj1"_ustr, OUString(u"val " + OUString::number(nVal1)))
1574 && WriteAV(u"adj2"_ustr, OUString(u"val " + OUString::number(nVal2)))
1575 && EndAVListWriting();
1577 if (sShapeType == "upArrow")
1579 auto aPointX = GetAdjustmentPointXValue(0);
1580 auto aPointY = GetAdjustmentPointYValue(0);
1581 if (!aPointX.nCurrVal.has_value() || !aPointX.nMaxVal.has_value()
1582 || !aPointX.nMinVal.has_value() || !aPointY.nCurrVal.has_value()
1583 || !aPointY.nMaxVal.has_value() || !aPointY.nMinVal.has_value())
1584 return false;
1586 m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
1587 false, false);
1588 tools::Long nMaxVal1 = 100000;
1589 tools::Long nMaxVal2
1590 = 100000 * m_xShape->getSize().Height
1591 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1592 tools::Long nVal1 = std::lround((*aPointX.nMaxVal - *aPointX.nCurrVal)
1593 / (*aPointX.nMaxVal - *aPointX.nMinVal) * nMaxVal1);
1594 tools::Long nVal2 = std::lround((*aPointY.nCurrVal - *aPointY.nMinVal)
1595 / (*aPointY.nMaxVal - *aPointY.nMinVal) * nMaxVal2);
1596 return StartAVListWriting()
1597 && WriteAV(u"adj1"_ustr, OUString(u"val " + OUString::number(nVal1)))
1598 && WriteAV(u"adj2"_ustr, OUString(u"val " + OUString::number(nVal2)))
1599 && EndAVListWriting();
1601 if (sShapeType == "upDownArrowCallout")
1603 // TODO
1604 return false;
1606 if (sShapeType == "uturnArrow")
1608 // LO does not have like this.
1609 return false;
1611 if (sShapeType == "verticalScroll")
1613 // TODO
1614 return false;
1616 if (sShapeType == "wave")
1618 // LO does not have.
1619 return false;
1621 if (sShapeType == "wedgeEllipseCallout")
1623 // TODO
1624 return false;
1626 if (sShapeType == "wedgeRectCallout")
1628 // TODO
1629 return false;
1631 if (sShapeType == "wedgeRoundRectCallout")
1633 // TODO
1634 return false;
1637 catch (...)
1639 // Problem detected with the writing, aborting and trying to find another way.
1640 return false;
1643 // Default, nothing happened return.
1644 return false;