LibreOffice Module oox (master) 1
DMLPresetShapeExport.cxx
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
11#include <oox/token/tokens.hxx>
12
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>
18
19#include <osl/diagnose.h>
21
22#include <string_view>
23
24using namespace ::css;
25using namespace ::css::drawing;
26
27namespace oox::drawingml
28{
29// DMLPresetShapeExporter class
30
31// ctor
33 css::uno::Reference<css::drawing::XShape> xShape)
34 : m_pDMLexporter(pDMLExporter)
35{
36 // This class only work with custom shapes!
37 OSL_ASSERT(xShape->getShapeType() == "com.sun.star.drawing.CustomShape");
38
39 m_xShape = 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("CustomShapeGeometry")
44 .get<uno::Sequence<beans::PropertyValue>>();
45
46 for (auto const& rCustomShapeGeometryItem : aCustomShapeGeometry)
47 {
48 if (rCustomShapeGeometryItem.Name == "Type")
49 {
50 m_sPresetShapeType = rCustomShapeGeometryItem.Value.get<OUString>();
51 }
52 if (rCustomShapeGeometryItem.Name == "Handles")
53 {
54 m_bHasHandleValues = true;
56 = rCustomShapeGeometryItem.Value
57 .get<css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>>>();
58 }
59 if (rCustomShapeGeometryItem.Name == "AdjustmentValues")
60 {
62 = rCustomShapeGeometryItem.Value
63 .get<css::uno::Sequence<css::drawing::EnhancedCustomShapeAdjustmentValue>>();
64 }
65 if (rCustomShapeGeometryItem.Name == "MirroredX")
66 {
67 m_bIsFlipped.first = rCustomShapeGeometryItem.Value.get<bool>();
68 }
69 if (rCustomShapeGeometryItem.Name == "MirroredY")
70 {
71 m_bIsFlipped.second = rCustomShapeGeometryItem.Value.get<bool>();
72 }
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 //}
86 }
87};
88
89// dtor
91 // Do nothing
92};
93
95
97
98const css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>>&
100{
101 return m_HandleValues;
102};
103
104const css::uno::Sequence<css::drawing::EnhancedCustomShapeAdjustmentValue>&
106{
107 return m_AdjustmentValues;
108};
109
111 std::u16string_view sType)
112{
113 uno::Any aRet;
114 if (GetHandleValues().getLength() > nPoint)
115 {
116 for (sal_Int32 i = 0; i < GetHandleValues()[nPoint].getLength(); i++)
117 {
118 if (GetHandleValues()[nPoint][i].Name == sType)
119 {
120 aRet = GetHandleValues()[nPoint][i].Value;
121 break;
122 }
123 }
124 }
125 return aRet;
126};
127
130{
132 try
133 {
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>();
143 }
144 catch (...)
145 {
146 // Do nothing.
147 }
148 return aRet;
149};
150
153{
155 try
156 {
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>();
162 }
163 catch (...)
164 {
165 // Do nothing.
166 }
167 return aRet;
168};
169
172{
173 XAdjustmentValue aRet;
174 try
175 {
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>();
185 }
186 catch (...)
187 {
188 // Do nothing.
189 }
190 return aRet;
191};
192
195{
196 YAdjustmentValue aRet;
197 try
198 {
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>();
208 }
209 catch (...)
210 {
211 // Do nothing.
212 }
213 return aRet;
214};
215
217{
219 {
220 // Case 1: We do not have adjustment points of the shape: just export it as preset
222 {
223 OUString sShapeType = GetShapeType();
224 const OString& sPresetShape = msfilter::util::GetOOXMLPresetGeometry(sShapeType);
226 false, false);
227 m_pDMLexporter->WritePresetShape(sPresetShape);
228 return true;
229 }
230 else // Case2: There are adjustment points what have to be converted and exported.
231 {
232 return WriteShapeWithAVlist();
233 }
234 }
235 return false;
236};
237
238bool DMLPresetShapeExporter::WriteAV(const OUString& sValName, const OUString& sVal)
239{
240 try
241 {
242 m_pDMLexporter->GetFS()->singleElementNS(XML_a, XML_gd, XML_name, sValName, XML_fmla, sVal);
243 return true;
244 }
245 catch (...)
246 {
247 return false;
248 }
249};
250
252{
253 try
254 {
255 const OString& pShape = msfilter::util::GetOOXMLPresetGeometry(GetShapeType());
256 m_pDMLexporter->GetFS()->startElementNS(XML_a, XML_prstGeom, XML_prst, pShape);
257 m_pDMLexporter->GetFS()->startElementNS(XML_a, XML_avLst);
258 return true;
259 }
260 catch (...)
261 {
262 return false;
263 }
264};
266{
267 try
268 {
269 m_pDMLexporter->GetFS()->endElementNS(XML_a, XML_avLst);
270 m_pDMLexporter->GetFS()->endElementNS(XML_a, XML_prstGeom);
271 return true;
272 }
273 catch (...)
274 {
275 return false;
276 }
277};
278
280{
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.
285
287
288 // OOXML uses 60th of degree, so 360 degree is 21 600 000 60thdeg
289 const tools::Long nConstOfMaxDegreeOf60th = 21600000;
290 try
291 {
292 if (sShapeType == "accentBorderCallout1")
293 {
294 // LO does not have this type, so it does not necessary to be mapped.
295 return false;
296 }
297 if (sShapeType == "accentBorderCallout2")
298 {
299 // LO does not have this type, so it does not necessary to be mapped.
300 return false;
301 }
302 if (sShapeType == "accentBorderCallout3")
303 {
304 // LO does not have this type, so it does not necessary to be mapped.
305 return false;
306 }
307 if (sShapeType == "accentCallout1")
308 {
309 // LO does not have this type, so it does not necessary to be mapped.
310 return false;
311 }
312 if (sShapeType == "accentCallout2")
313 {
314 // LO does not have this type, so it does not necessary to be mapped.
315 return false;
316 }
317 if (sShapeType == "accentCallout3")
318 {
319 // LO does not have this type, so it does not necessary to be mapped.
320 return false;
321 }
322 if (sShapeType == "actionButtonBackPrevious")
323 {
324 // LO does not have this type, so it does not necessary to be mapped.
325 return false;
326 }
327 if (sShapeType == "actionButtonBeginning")
328 {
329 // LO does not have this type, so it does not necessary to be mapped.
330 return false;
331 }
332 if (sShapeType == "actionButtonBlank")
333 {
334 // LO does not have this type, so it does not necessary to be mapped.
335 return false;
336 }
337 if (sShapeType == "actionButtonDocument")
338 {
339 // LO does not have this type, so it does not necessary to be mapped.
340 return false;
341 }
342 if (sShapeType == "actionButtonEnd")
343 {
344 // LO does not have this type, so it does not necessary to be mapped.
345 return false;
346 }
347 if (sShapeType == "actionButtonForwardNext")
348 {
349 // LO does not have this type, so it does not necessary to be mapped.
350 return false;
351 }
352 if (sShapeType == "actionButtonHelp")
353 {
354 // LO does not have this type, so it does not necessary to be mapped.
355 return false;
356 }
357 if (sShapeType == "actionButtonHome")
358 {
359 // LO does not have this type, so it does not necessary to be mapped.
360 return false;
361 }
362 if (sShapeType == "actionButtonInformation")
363 {
364 // LO does not have this type, so it does not necessary to be mapped.
365 return false;
366 }
367 if (sShapeType == "actionButtonMovie")
368 {
369 // LO does not have this type, so it does not necessary to be mapped.
370 return false;
371 }
372 if (sShapeType == "actionButtonReturn")
373 {
374 // LO does not have this type, so it does not necessary to be mapped.
375 return false;
376 }
377 if (sShapeType == "actionButtonSound")
378 {
379 // LO does not have this type, so it does not necessary to be mapped.
380 return false;
381 }
382 if (sShapeType == "arc")
383 {
384 // LO does not have handle points for this, so CustGeom is enough.
385 return false;
386 }
387 if (sShapeType == "bentArrow")
388 {
389 // LO has only one type, which have to be rotated, without handling points
390 // So CustGeom enough.
391 return false;
392 }
393 if (sShapeType == "bentConnector2")
394 {
395 // CustGeom Enough
396 return false;
397 }
398 if (sShapeType == "bentConnector3")
399 {
400 // CustGeom Enough
401 return false;
402 }
403 if (sShapeType == "bentConnector4")
404 {
405 // CustGeom Enough
406 return false;
407 }
408 if (sShapeType == "bentConnector5")
409 {
410 // CustGeom Enough
411 return false;
412 }
413 if (sShapeType == "bentUpArrow")
414 {
415 // CustGeom Enough, no handle points
416 return false;
417 }
418 if (sShapeType == "bevel")
419 {
420 auto aPoint1 = GetAdjustmentPointXValue(0);
421 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
422 || !aPoint1.nMinVal.has_value())
423 return false;
425 false, false);
426
427 tools::Long nVal1
428 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * 50000);
429 return StartAVListWriting()
430 && WriteAV(u"adj", OUString(u"val " + OUString::number(nVal1)))
431 && EndAVListWriting();
432 }
433 if (sShapeType == "blockArc")
434 {
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;
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", OUString(u"val " + OUString::number(nVal1)))
453 && WriteAV(u"adj2", OUString(u"val " + OUString::number(nVal2)))
454 && WriteAV(u"adj3", OUString(u"val " + OUString::number(nVal3)))
455 && EndAVListWriting();
456 }
457 if (sShapeType == "borderCallout1")
458 {
459 // LO does not have this type, so it does not necessary to be mapped.
460 return false;
461 }
462 if (sShapeType == "borderCallout2")
463 {
464 // LO does not have this type, so it does not necessary to be mapped.
465 return false;
466 }
467 if (sShapeType == "borderCallout3")
468 {
469 // LO does not have this type, so it does not necessary to be mapped.
470 return false;
471 }
472 if (sShapeType == "bracePair")
473 {
474 auto aPoint1 = GetAdjustmentPointYValue(0);
475 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
476 || !aPoint1.nMinVal.has_value())
477 return false;
478
480 false, false);
481 tools::Long nVal1
482 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * 25000);
483 return StartAVListWriting()
484 && WriteAV(u"adj", OUString(u"val " + OUString::number(nVal1)))
485 && EndAVListWriting();
486 }
487 if (sShapeType == "bracketPair")
488 {
489 auto aPoint1 = GetAdjustmentPointYValue(0);
490 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
491 || !aPoint1.nMinVal.has_value())
492 return false;
493
495 false, false);
496 tools::Long nVal1
497 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * 50000);
498 return StartAVListWriting()
499 && WriteAV(u"adj", OUString(u"val " + OUString::number(nVal1)))
500 && EndAVListWriting();
501 }
502 if (sShapeType == "callout1")
503 {
504 // LO does not have this type, so it does not necessary to be mapped.
505 return false;
506 }
507 if (sShapeType == "callout2")
508 {
509 // LO does not have this type, so it does not necessary to be mapped.
510 return false;
511 }
512 if (sShapeType == "callout3")
513 {
514 // LO does not have this type, so it does not necessary to be mapped.
515 return false;
516 }
517 if (sShapeType == "can")
518 {
519 return false;
520 // Do the export as before.
521 }
522 if (sShapeType == "chartPlus")
523 {
524 // LO does not have this type, so it does not necessary to be mapped.
525 return false;
526 }
527 if (sShapeType == "chartStar")
528 {
529 // LO does not have this type, so it does not necessary to be mapped.
530 return false;
531 }
532 if (sShapeType == "chartX")
533 {
534 // LO does not have this type, so it does not necessary to be mapped.
535 return false;
536 }
537 if (sShapeType == "chord")
538 {
539 // CustGeom, because LO does not have handle points
540 return false;
541 }
542 if (sShapeType == "circularArrow")
543 {
544 // LO does not have this type, so it does not necessary to be mapped.
545 return false;
546 }
547 if (sShapeType == "cloud")
548 {
549 // CustGeom enough
550 return false;
551 }
552 if (sShapeType == "cloudCallout")
553 {
554 return false;
555 // Works fine without this, so export it like before.
556 }
557 if (sShapeType == "cornerTabs")
558 {
559 // LO does not have this type, so it does not necessary to be mapped.
560 return false;
561 }
562 if (sShapeType == "cube")
563 {
564 // Works fine without this, so export it like before.
565 return false;
566 }
567 if (sShapeType == "curvedConnector2")
568 {
569 // Not necessary to be mapped
570 return false;
571 }
572 if (sShapeType == "curvedConnector3")
573 {
574 // Not necessary to be mapped
575 return false;
576 }
577 if (sShapeType == "curvedConnector4")
578 {
579 // Not necessary to be mapped
580 return false;
581 }
582 if (sShapeType == "curvedConnector5")
583 {
584 // Not necessary to be mapped
585 return false;
586 }
587 if (sShapeType == "curvedDownArrow")
588 {
589 // LO does not have this type, so it does not necessary to be mapped.
590 return false;
591 }
592 if (sShapeType == "curvedLeftArrow")
593 {
594 // LO does not have this type, so it does not necessary to be mapped.
595 return false;
596 }
597 if (sShapeType == "curvedRightArrow")
598 {
599 // LO does not have this type, so it does not necessary to be mapped.
600 return false;
601 }
602 if (sShapeType == "curvedUpArrow")
603 {
604 // LO does not have this type, so it does not necessary to be mapped.
605 return false;
606 }
607 if (sShapeType == "decagon")
608 {
609 // LO does not have this type, so it does not necessary to be mapped.
610 return false;
611 }
612 if (sShapeType == "diagStripe")
613 {
614 // LO does not have this type, so it does not necessary to be mapped.
615 return false;
616 }
617 if (sShapeType == "diamond")
618 {
619 // It does not have handle points so it do not have to be mapped.
620 return false;
621 }
622 if (sShapeType == "dodecagon")
623 {
624 // LO does not have this type, so it does not necessary to be mapped.
625 return false;
626 }
627 if (sShapeType == "donut")
628 {
629 // TODO
630 return false;
631 }
632 if (sShapeType == "doubleWave")
633 {
634 // LO does not have this type, so it does not necessary to be mapped.
635 return false;
636 }
637 if (sShapeType == "downArrow")
638 {
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;
645
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", OUString(u"val " + OUString::number(nVal1)))
658 && WriteAV(u"adj2", OUString(u"val " + OUString::number(nVal2)))
659 && EndAVListWriting();
660 }
661 if (sShapeType == "downArrowCallout")
662 {
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;
674
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", OUString(u"val " + OUString::number(nVal1)))
698 && WriteAV(u"adj2", OUString(u"val " + OUString::number(nVal2)))
699 && WriteAV(u"adj3", OUString(u"val " + OUString::number(nVal3)))
700 && WriteAV(u"adj4", OUString(u"val " + OUString::number(nVal4)))
701 && EndAVListWriting();
702 }
703 if (sShapeType == "ellipse")
704 {
705 // Does not have handle points, so preset enough.
706 return false;
707 }
708 if (sShapeType == "ellipseRibbon")
709 {
710 // LO does not have this type, so it does not necessary to be mapped.
711 return false;
712 }
713 if (sShapeType == "ellipseRibbon2")
714 {
715 // LO does not have this type, so it does not necessary to be mapped.
716 return false;
717 }
718 if (sShapeType == "flowChartAlternateProcess")
719 {
720 // Does not have handle points, so preset enough.
721 return false;
722 }
723 if (sShapeType == "flowChartCollate")
724 {
725 // Does not have handle points, so preset enough.
726 return false;
727 }
728 if (sShapeType == "flowChartConnector")
729 {
730 // Does not have handle points, so preset enough.
731 return false;
732 }
733 if (sShapeType == "flowChartDecision")
734 {
735 // Does not have handle points, so preset enough.
736 return false;
737 }
738 if (sShapeType == "flowChartDecision")
739 {
740 // Does not have handle points, so preset enough.
741 return false;
742 }
743 if (sShapeType == "flowChartDelay")
744 {
745 // Does not have handle points, so preset enough.
746 return false;
747 }
748 if (sShapeType == "flowChartDisplay")
749 {
750 // Does not have handle points, so preset enough.
751 return false;
752 }
753 if (sShapeType == "flowChartDocument")
754 {
755 // Does not have handle points, so preset enough.
756 return false;
757 }
758 if (sShapeType == "flowChartExtract")
759 {
760 // Does not have handle points, so preset enough.
761 return false;
762 }
763 if (sShapeType == "flowChartInputOutput")
764 {
765 // Does not have handle points, so preset enough.
766 return false;
767 }
768 if (sShapeType == "flowChartInternalStorage")
769 {
770 // Does not have handle points, so preset enough.
771 return false;
772 }
773 if (sShapeType == "flowChartMagneticDisk")
774 {
775 // Does not have handle points, so preset enough.
776 return false;
777 }
778 if (sShapeType == "flowChartMagneticDrum")
779 {
780 // Does not have handle points, so preset enough.
781 return false;
782 }
783 if (sShapeType == "flowChartMagneticTape")
784 {
785 // Does not have handle points, so preset enough.
786 return false;
787 }
788 if (sShapeType == "flowChartManualInput")
789 {
790 // Does not have handle points, so preset enough.
791 return false;
792 }
793 if (sShapeType == "flowChartManualOperation")
794 {
795 // Does not have handle points, so preset enough.
796 return false;
797 }
798 if (sShapeType == "flowChartMerge")
799 {
800 // Does not have handle points, so preset enough.
801 return false;
802 }
803 if (sShapeType == "flowChartMultidocument")
804 {
805 // Does not have handle points, so preset enough.
806 return false;
807 }
808 if (sShapeType == "flowChartOfflineStorage")
809 {
810 // Does not have handle points, so preset enough.
811 return false;
812 }
813 if (sShapeType == "flowChartOffpageConnector")
814 {
815 // Does not have handle points, so preset enough.
816 return false;
817 }
818 if (sShapeType == "flowChartOnlineStorage")
819 {
820 // Does not have handle points, so preset enough.
821 return false;
822 }
823 if (sShapeType == "flowChartOr")
824 {
825 // Does not have handle points, so preset enough.
826 return false;
827 }
828 if (sShapeType == "flowChartDecision")
829 {
830 // Does not have handle points, so preset enough.
831 return false;
832 }
833 if (sShapeType == "flowChartPredefinedProcess")
834 {
835 // Does not have handle points, so preset enough.
836 return false;
837 }
838 if (sShapeType == "flowChartPreparation")
839 {
840 // Does not have handle points, so preset enough.
841 return false;
842 }
843 if (sShapeType == "flowChartPunchedCard")
844 {
845 // Does not have handle points, so preset enough.
846 return false;
847 }
848 if (sShapeType == "flowChartPunchedTape")
849 {
850 // Does not have handle points, so preset enough.
851 return false;
852 }
853 if (sShapeType == "flowChartSort")
854 {
855 // Does not have handle points, so preset enough.
856 return false;
857 }
858 if (sShapeType == "flowChartSummingJunction")
859 {
860 // Does not have handle points, so preset enough.
861 return false;
862 }
863 if (sShapeType == "flowChartTerminator")
864 {
865 // Does not have handle points, so preset enough.
866 return false;
867 }
868 if (sShapeType == "foldedCorner")
869 {
870 // TODO
871 return false;
872 }
873 if (sShapeType == "frame")
874 {
875 // TODO
876 return false;
877 }
878 if (sShapeType == "funnel")
879 {
880 // Not found in word
881 return false;
882 }
883 if (sShapeType == "gear6")
884 {
885 // Not found in word
886 return false;
887 }
888 if (sShapeType == "gear9")
889 {
890 // Not found in word
891 return false;
892 }
893 if (sShapeType == "halfFrame")
894 {
895 // LO does not have this type, not necessary to map
896 return false;
897 }
898 if (sShapeType == "heart")
899 {
900 // TODO
901 return false;
902 }
903 if (sShapeType == "heptagon")
904 {
905 // LO does not have this type, not necessary to map
906 return false;
907 }
908 if (sShapeType == "hexagon")
909 {
910 auto aPoint1 = GetAdjustmentPointXValue(0);
911 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
912 || !aPoint1.nMinVal.has_value())
913 return false;
914
916 false, false);
917 tools::Long nMaxVal = 50000 * m_xShape->getSize().Width
918 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
919 tools::Long nVal1
920 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * nMaxVal);
921 return StartAVListWriting()
922 && WriteAV(u"adj", OUString(u"val " + OUString::number(nVal1)))
923 && WriteAV(u"vf", OUString(u"val " + OUString::number(115470)))
924 && EndAVListWriting();
925 }
926 if (sShapeType == "homePlate")
927 {
928 // Not found in word
929 return false;
930 }
931 if (sShapeType == "horizontalScroll")
932 {
933 // TODO
934 return false;
935 }
936 if (sShapeType == "irregularSeal1")
937 {
938 // Not found in word
939 return false;
940 }
941 if (sShapeType == "irregularSeal2")
942 {
943 // Not found in word
944 return false;
945 }
946 if (sShapeType == "leftArrow")
947 {
948 auto aPointX = GetAdjustmentPointXValue(0);
949 auto aPointY = GetAdjustmentPointYValue(0);
950 if (!aPointX.nCurrVal.has_value() || !aPointX.nMaxVal.has_value()
951 || !aPointX.nMinVal.has_value() || !aPointY.nCurrVal.has_value()
952 || !aPointY.nMaxVal.has_value() || !aPointY.nMinVal.has_value())
953 return false;
954
956 false, false);
957 tools::Long nMaxVal1 = 100000;
958 tools::Long nMaxVal2
959 = 100000
960 * (double(m_xShape->getSize().Width)
961 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height));
962 tools::Long nVal1 = std::lround((*aPointY.nMaxVal - *aPointY.nCurrVal)
963 / (*aPointY.nMaxVal - *aPointY.nMinVal) * nMaxVal1);
964 tools::Long nVal2 = std::lround((*aPointX.nCurrVal - *aPointX.nMinVal)
965 / (*aPointX.nMaxVal - *aPointX.nMinVal) * nMaxVal2);
966 return StartAVListWriting()
967 && WriteAV(u"adj1", OUString(u"val " + OUString::number(nVal1)))
968 && WriteAV(u"adj2", OUString(u"val " + OUString::number(nVal2)))
969 && EndAVListWriting();
970 }
971 if (sShapeType == "leftArrowCallout")
972 {
973 auto aBoxWidth = GetAdjustmentPointXValue(0);
974 auto aNeckLength = GetAdjustmentPointXValue(1);
975 auto aNeckFromBox = GetAdjustmentPointYValue(1);
976 auto aHeadFromNeck = GetAdjustmentPointYValue(2);
977 if (!aBoxWidth.nCurrVal.has_value() || !aBoxWidth.nMaxVal.has_value()
978 || !aBoxWidth.nMinVal.has_value() || !aNeckLength.nCurrVal.has_value()
979 || !aNeckLength.nMaxVal.has_value() || !aNeckLength.nMinVal.has_value()
980 || !aNeckFromBox.nCurrVal.has_value() || !aNeckFromBox.nMaxVal.has_value()
981 || !aNeckFromBox.nMinVal.has_value() || !aHeadFromNeck.nCurrVal.has_value()
982 || !aHeadFromNeck.nMaxVal.has_value() || !aHeadFromNeck.nMinVal.has_value())
983 return false;
984
986 false, false);
987 tools::Long nMaxVal1
988 = 100000 * m_xShape->getSize().Height
989 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
990 tools::Long nMaxVal2
991 = 50000 * m_xShape->getSize().Height
992 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
993 tools::Long nMaxVal3
994 = 100000 * m_xShape->getSize().Width
995 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
996 tools::Long nVal1
997 = std::lround((*aNeckFromBox.nMaxVal - *aNeckFromBox.nCurrVal)
998 / (*aNeckFromBox.nMaxVal - *aNeckFromBox.nMinVal) * nMaxVal1);
999 tools::Long nVal2 = std::lround((10800 - *aHeadFromNeck.nCurrVal)
1000 / (10800 - *aHeadFromNeck.nMinVal) * nMaxVal2);
1001 tools::Long nVal3 = std::lround((*aNeckLength.nCurrVal - *aNeckLength.nMinVal)
1002 / (21600 - *aNeckLength.nMinVal) * nMaxVal3);
1003 tools::Long nVal4 = std::lround((*aBoxWidth.nMaxVal - *aBoxWidth.nCurrVal)
1004 / (*aBoxWidth.nMaxVal - *aBoxWidth.nMinVal) * 100000);
1005 return StartAVListWriting()
1006 && WriteAV(u"adj1", OUString(u"val " + OUString::number(nVal1)))
1007 && WriteAV(u"adj2", OUString(u"val " + OUString::number(nVal2)))
1008 && WriteAV(u"adj3", OUString(u"val " + OUString::number(nVal3)))
1009 && WriteAV(u"adj4", OUString(u"val " + OUString::number(nVal4)))
1010 && EndAVListWriting();
1011 }
1012 if (sShapeType == "leftBrace")
1013 {
1014 // TODO
1015 return false;
1016 }
1017 if (sShapeType == "leftBracket")
1018 {
1019 // TODO
1020 return false;
1021 }
1022 if (sShapeType == "leftCircularArrow")
1023 {
1024 // LO does not have this type, not necessary to map
1025 return false;
1026 }
1027 if (sShapeType == "leftRightArrow")
1028 {
1029 auto aPointX = GetAdjustmentPointXValue(0);
1030 auto aPointY = GetAdjustmentPointYValue(0);
1031 if (!aPointX.nCurrVal.has_value() || !aPointX.nMaxVal.has_value()
1032 || !aPointX.nMinVal.has_value() || !aPointY.nCurrVal.has_value()
1033 || !aPointY.nMaxVal.has_value() || !aPointY.nMinVal.has_value())
1034 return false;
1035
1037 false, false);
1038 tools::Long nMaxVal1 = 100000;
1039 tools::Long nMaxVal2
1040 = 50000
1041 * (double(m_xShape->getSize().Width)
1042 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height));
1043 tools::Long nVal1 = std::lround((*aPointY.nMaxVal - *aPointY.nCurrVal)
1044 / (*aPointY.nMaxVal - *aPointY.nMinVal) * nMaxVal1);
1045 tools::Long nVal2 = std::lround((*aPointX.nCurrVal - *aPointX.nMinVal)
1046 / (*aPointX.nMaxVal - *aPointX.nMinVal) * nMaxVal2);
1047 return StartAVListWriting()
1048 && WriteAV(u"adj1", OUString(u"val " + OUString::number(nVal1)))
1049 && WriteAV(u"adj2", OUString(u"val " + OUString::number(nVal2)))
1050 && EndAVListWriting();
1051 }
1052 if (sShapeType == "leftRightArrowCallout")
1053 {
1054 auto aNeckFromBox = GetAdjustmentPointXValue(1);
1055 auto aHeadFromNeck = GetAdjustmentPointXValue(2);
1056 auto aHeadHeight = GetAdjustmentPointYValue(1);
1057 auto aBoxHeight = GetAdjustmentPointYValue(0);
1058 if (!aNeckFromBox.nCurrVal.has_value() || !aNeckFromBox.nMaxVal.has_value()
1059 || !aNeckFromBox.nMinVal.has_value() || !aHeadFromNeck.nCurrVal.has_value()
1060 || !aHeadFromNeck.nMaxVal.has_value() || !aHeadFromNeck.nMinVal.has_value()
1061 || !aHeadHeight.nCurrVal.has_value() || !aHeadHeight.nMaxVal.has_value()
1062 || !aHeadHeight.nMinVal.has_value() || !aBoxHeight.nCurrVal.has_value()
1063 || !aBoxHeight.nMaxVal.has_value() || !aBoxHeight.nMinVal.has_value())
1064 return false;
1065
1067 false, false);
1068 tools::Long nMaxVal1
1069 = 100000 * m_xShape->getSize().Width
1070 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1071 tools::Long nMaxVal2
1072 = 50000 * m_xShape->getSize().Width
1073 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1074 tools::Long nMaxVal3
1075 = 100000 * m_xShape->getSize().Height
1076 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1077 tools::Long nVal1
1078 = std::lround((*aNeckFromBox.nMaxVal - *aNeckFromBox.nCurrVal)
1079 / (*aNeckFromBox.nMaxVal - *aNeckFromBox.nMinVal) * nMaxVal1);
1080 tools::Long nVal2 = std::lround((10800 - *aHeadFromNeck.nCurrVal)
1081 / (10800 - *aHeadFromNeck.nMinVal) * nMaxVal2);
1082 tools::Long nVal3 = std::lround((*aHeadHeight.nCurrVal - *aHeadHeight.nMinVal)
1083 / (21600 - *aHeadHeight.nMinVal) * nMaxVal3);
1084 tools::Long nVal4 = std::lround((*aBoxHeight.nCurrVal - *aBoxHeight.nMinVal)
1085 / (10800 - *aBoxHeight.nMinVal) * 100000);
1086 return StartAVListWriting()
1087 && WriteAV(u"adj1", OUString(u"val " + OUString::number(nVal1)))
1088 && WriteAV(u"adj2", OUString(u"val " + OUString::number(nVal2)))
1089 && WriteAV(u"adj3", OUString(u"val " + OUString::number(nVal3)))
1090 && WriteAV(u"adj4", OUString(u"val " + OUString::number(nVal4)))
1091 && EndAVListWriting();
1092 }
1093 if (sShapeType == "leftRightCircularArrow")
1094 {
1095 // Not found in word
1096 return false;
1097 }
1098 if (sShapeType == "leftRightRibbon")
1099 {
1100 // LO does not have this type so mapping not necessary
1101 return false;
1102 }
1103 if (sShapeType == "leftRightUpArrow")
1104 {
1105 // TODO?
1106 // MS Word stretches the arrow to fit the bounding box; LO doesn't
1107 return false;
1108 }
1109 if (sShapeType == "leftUpArrow")
1110 {
1111 // MS Word's and LO's interpretations of what a leftUpArrow should look like
1112 // are too different to find a compromise :(
1113 }
1114 if (sShapeType == "lightningBolt")
1115 {
1116 // Difference between the SDR and OOXML variants, custgeom?
1117 return false;
1118 }
1119 if (sShapeType == "line")
1120 {
1121 // Not necessary
1122 return false;
1123 }
1124 if (sShapeType == "lineInv")
1125 {
1126 // Not necessary
1127 return false;
1128 }
1129 if (sShapeType == "mathDivide")
1130 {
1131 // LO does not have this type so mapping not necessary
1132 return false;
1133 }
1134 if (sShapeType == "mathEqual")
1135 {
1136 // LO does not have this type so mapping not necessary
1137 return false;
1138 }
1139 if (sShapeType == "mathMinus")
1140 {
1141 // LO does not have this type so mapping not necessary
1142 return false;
1143 }
1144 if (sShapeType == "mathMultiply")
1145 {
1146 // LO does not have this type so mapping not necessary
1147 return false;
1148 }
1149 if (sShapeType == "mathNotEqual")
1150 {
1151 // LO does not have this type so mapping not necessary
1152 return false;
1153 }
1154 if (sShapeType == "mathPlus")
1155 {
1156 // LO does not have this type so mapping not necessary
1157 return false;
1158 }
1159 if (sShapeType == "nonIsoscelesTrapezoid")
1160 {
1161 // TODO
1162 return false;
1163 }
1164 if (sShapeType == "noSmoking")
1165 {
1166 // TODO
1167 return false;
1168 }
1169 if (sShapeType == "notchedRightArrow")
1170 {
1171 // TODO
1172 return false;
1173 }
1174 if (sShapeType == "octagon")
1175 {
1176 auto aPoint1 = GetAdjustmentPointXValue(0);
1177 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
1178 || !aPoint1.nMinVal.has_value())
1179 return false;
1180
1182 false, false);
1183 tools::Long nVal1
1184 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * 50000);
1185 return StartAVListWriting()
1186 && WriteAV(u"adj", OUString(u"val " + OUString::number(nVal1)))
1187 && EndAVListWriting();
1188 }
1189 if (sShapeType == "parallelogram")
1190 {
1191 auto aPoint1 = GetAdjustmentPointXValue(0);
1192 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
1193 || !aPoint1.nMinVal.has_value())
1194 return false;
1195
1197 false, false);
1198 tools::Long nMaxVal = 100000 * m_xShape->getSize().Width
1199 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1200 tools::Long nVal1
1201 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * nMaxVal);
1202 return StartAVListWriting()
1203 && WriteAV(u"adj", OUString(u"val " + OUString::number(nVal1)))
1204 && EndAVListWriting();
1205 }
1206 if (sShapeType == "pentagon")
1207 {
1208 // TODO
1209 return false;
1210 }
1211 if (sShapeType == "pie")
1212 {
1213 // TODO
1214 return false;
1215 }
1216 if (sShapeType == "pieWedge")
1217 {
1218 // Not found in word.
1219 return false;
1220 }
1221 if (sShapeType == "plaque")
1222 {
1223 // TODO
1224 return false;
1225 }
1226 if (sShapeType == "plaqueTabs")
1227 {
1228 // LO does not have this, so not necessary to map.
1229 return false;
1230 }
1231 if (sShapeType == "plus")
1232 {
1233 auto aPoint1 = GetAdjustmentPointXValue(0);
1234 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
1235 || !aPoint1.nMinVal.has_value())
1236 return false;
1237
1239 false, false);
1240 tools::Long nVal1
1241 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * 50000);
1242 return StartAVListWriting()
1243 && WriteAV(u"adj", OUString(u"val " + OUString::number(nVal1)))
1244 && EndAVListWriting();
1245 }
1246 if (sShapeType == "quadArrow")
1247 {
1248 // TODO
1249 return false;
1250 }
1251 if (sShapeType == "quadArrowCallout")
1252 {
1253 // TODO
1254 return false;
1255 }
1256 if (sShapeType == "rect")
1257 {
1258 // preset enough without AV points.
1259 return false;
1260 }
1261 if (sShapeType == "ribbon")
1262 {
1263 // LO does not have this, so not necessary to map.
1264 return false;
1265 }
1266 if (sShapeType == "ribbon2")
1267 {
1268 // LO does not have this, so not necessary to map.
1269 return false;
1270 }
1271 if (sShapeType == "rightArrow")
1272 {
1273 auto aPointX = GetAdjustmentPointXValue(0);
1274 auto aPointY = GetAdjustmentPointYValue(0);
1275 if (!aPointX.nCurrVal.has_value() || !aPointX.nMaxVal.has_value()
1276 || !aPointX.nMinVal.has_value() || !aPointY.nCurrVal.has_value()
1277 || !aPointY.nMaxVal.has_value() || !aPointY.nMinVal.has_value())
1278 return false;
1279
1281 false, false);
1282 tools::Long nMaxVal1 = 100000;
1283 tools::Long nMaxVal2
1284 = 100000
1285 * (double(m_xShape->getSize().Width)
1286 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height));
1287 tools::Long nVal1 = std::lround((*aPointY.nMaxVal - *aPointY.nCurrVal)
1288 / (*aPointY.nMaxVal - *aPointY.nMinVal) * nMaxVal1);
1289 tools::Long nVal2 = std::lround((*aPointX.nMaxVal - *aPointX.nCurrVal)
1290 / (*aPointX.nMaxVal - *aPointX.nMinVal) * nMaxVal2);
1291 return StartAVListWriting()
1292 && WriteAV(u"adj1", OUString(u"val " + OUString::number(nVal1)))
1293 && WriteAV(u"adj2", OUString(u"val " + OUString::number(nVal2)))
1294 && EndAVListWriting();
1295 }
1296 if (sShapeType == "rightArrowCallout")
1297 {
1298 auto aBoxWidth = GetAdjustmentPointXValue(0);
1299 auto aNeckLength = GetAdjustmentPointXValue(1);
1300 auto aNeckFromBox = GetAdjustmentPointYValue(1);
1301 auto aHeadFromNeck = GetAdjustmentPointYValue(2);
1302 if (!aBoxWidth.nCurrVal.has_value() || !aBoxWidth.nMaxVal.has_value()
1303 || !aBoxWidth.nMinVal.has_value() || !aNeckLength.nCurrVal.has_value()
1304 || !aNeckLength.nMaxVal.has_value() || !aNeckLength.nMinVal.has_value()
1305 || !aNeckFromBox.nCurrVal.has_value() || !aNeckFromBox.nMaxVal.has_value()
1306 || !aNeckFromBox.nMinVal.has_value() || !aHeadFromNeck.nCurrVal.has_value()
1307 || !aHeadFromNeck.nMaxVal.has_value() || !aHeadFromNeck.nMinVal.has_value())
1308 return false;
1309
1311 false, false);
1312 tools::Long nMaxVal1
1313 = 100000 * m_xShape->getSize().Height
1314 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1315 tools::Long nMaxVal2
1316 = 50000 * m_xShape->getSize().Height
1317 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1318 tools::Long nMaxVal3
1319 = 100000 * m_xShape->getSize().Width
1320 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1321 tools::Long nVal1
1322 = std::lround((*aNeckFromBox.nMaxVal - *aNeckFromBox.nCurrVal)
1323 / (*aNeckFromBox.nMaxVal - *aNeckFromBox.nMinVal) * nMaxVal1);
1324 tools::Long nVal2 = std::lround((10800 - *aHeadFromNeck.nCurrVal)
1325 / (10800 - *aHeadFromNeck.nMinVal) * nMaxVal2);
1326 tools::Long nVal3
1327 = std::lround((*aNeckLength.nMaxVal - *aNeckLength.nCurrVal)
1328 / (*aNeckLength.nMaxVal - *aNeckLength.nMinVal) * nMaxVal3);
1329 tools::Long nVal4 = std::lround((*aBoxWidth.nCurrVal - *aBoxWidth.nMinVal)
1330 / (21600 - *aBoxWidth.nMinVal) * 100000);
1331 return StartAVListWriting()
1332 && WriteAV(u"adj1", OUString(u"val " + OUString::number(nVal1)))
1333 && WriteAV(u"adj2", OUString(u"val " + OUString::number(nVal2)))
1334 && WriteAV(u"adj3", OUString(u"val " + OUString::number(nVal3)))
1335 && WriteAV(u"adj4", OUString(u"val " + OUString::number(nVal4)))
1336 && EndAVListWriting();
1337 }
1338 if (sShapeType == "rightBrace")
1339 {
1340 // TODO
1341 return false;
1342 }
1343 if (sShapeType == "rightBracket")
1344 {
1345 // TODO
1346 return false;
1347 }
1348 if (sShapeType == "round1Rect")
1349 {
1350 // LO does not have this, so not necessary to map.
1351 return false;
1352 }
1353 if (sShapeType == "round2DiagRect")
1354 {
1355 // LO does not have this, so not necessary to map.
1356 return false;
1357 }
1358 if (sShapeType == "round2SameRect")
1359 {
1360 // LO does not have this, so not necessary to map.
1361 return false;
1362 }
1363 if (sShapeType == "roundRect")
1364 {
1365 tools::Long nVal1 = 0;
1366 if (m_xShape->getSize().Width >= m_xShape->getSize().Height)
1367 {
1368 auto aPointX = GetAdjustmentPointXValue(0);
1369 if (!aPointX.nCurrVal.has_value() || !aPointX.nMaxVal.has_value()
1370 || !aPointX.nMinVal.has_value())
1371 return false;
1372 nVal1 = std::lround(*aPointX.nCurrVal / (*aPointX.nMaxVal - *aPointX.nMinVal)
1373 * 50000);
1374 }
1375 else
1376 {
1377 auto aPointY = GetAdjustmentPointYValue(0);
1378 if (!aPointY.nCurrVal.has_value() || !aPointY.nMaxVal.has_value()
1379 || !aPointY.nMinVal.has_value())
1380 return false;
1381 nVal1 = std::lround(*aPointY.nCurrVal / (*aPointY.nMaxVal - *aPointY.nMinVal)
1382 * 50000);
1383 }
1384
1386 false, false);
1387 return StartAVListWriting()
1388 && WriteAV(u"adj", OUString(u"val " + OUString::number(nVal1)))
1389 && EndAVListWriting();
1390 }
1391 if (sShapeType == "rtTriangle")
1392 {
1393 // Does not have AV points not necessary to map
1394 return false;
1395 }
1396 if (sShapeType == "smileyFace")
1397 {
1398 // TODO
1399 return false;
1400 }
1401 if (sShapeType == "snip1Rect")
1402 {
1403 // LO does not have this, so not necessary to map.
1404 return false;
1405 }
1406 if (sShapeType == "snip2DiagRect")
1407 {
1408 // LO does not have this, so not necessary to map.
1409 return false;
1410 }
1411 if (sShapeType == "snip2SameRect")
1412 {
1413 // LO does not have this, so not necessary to map.
1414 return false;
1415 }
1416 if (sShapeType == "snipRoundRect")
1417 {
1418 // LO does not have this, so not necessary to map.
1419 return false;
1420 }
1421 if (sShapeType == "squareTabs")
1422 {
1423 // LO does not have this, so not necessary to map.
1424 return false;
1425 }
1426 if (sShapeType == "star10")
1427 {
1428 // LO does not have this, so not necessary to map.
1429 return false;
1430 }
1431 if (sShapeType == "star12")
1432 {
1433 // TODO
1434 return false;
1435 }
1436 if (sShapeType == "star16")
1437 {
1438 // LO does not have this, so not necessary to map.
1439 return false;
1440 }
1441 if (sShapeType == "star24")
1442 {
1443 // TODO
1444 return false;
1445 }
1446 if (sShapeType == "star32")
1447 {
1448 // LO does not have this, so not necessary to map.
1449 return false;
1450 }
1451 if (sShapeType == "star4")
1452 {
1453 // TODO
1454 return false;
1455 }
1456 if (sShapeType == "star5")
1457 {
1458 // TODO
1459 return false;
1460 }
1461 if (sShapeType == "star6")
1462 {
1463 // TODO
1464 return false;
1465 }
1466 if (sShapeType == "star7")
1467 {
1468 // LO does not have this, so not necessary to map.
1469 return false;
1470 }
1471 if (sShapeType == "star8")
1472 {
1473 // TODO
1474 return false;
1475 }
1476 if (sShapeType == "straightConnector1")
1477 {
1478 // Not necessary to map.
1479 return false;
1480 }
1481 if (sShapeType == "stripedRightArrow")
1482 {
1483 // TODO
1484 return false;
1485 }
1486 if (sShapeType == "sun")
1487 {
1488 // TODO
1489 return false;
1490 }
1491 if (sShapeType == "swooshArrow")
1492 {
1493 // Not found in word.
1494 return false;
1495 }
1496 if (sShapeType == "teardrop")
1497 {
1498 // TODO
1499 return false;
1500 }
1501 if (sShapeType == "trapezoid")
1502 {
1503 // Preset enough.
1504 return false;
1505 }
1506 if (sShapeType == "triangle")
1507 {
1508 auto aPoint1 = GetAdjustmentPointXValue(0);
1509 if (!aPoint1.nCurrVal.has_value() || !aPoint1.nMaxVal.has_value()
1510 || !aPoint1.nMinVal.has_value())
1511 return false;
1512
1514 false, false);
1515 tools::Long nMaxVal = 100000;
1516 tools::Long nVal1
1517 = std::lround(*aPoint1.nCurrVal / (*aPoint1.nMaxVal - *aPoint1.nMinVal) * nMaxVal);
1518 return StartAVListWriting()
1519 && WriteAV(u"adj", OUString(u"val " + OUString::number(nVal1)))
1520 && EndAVListWriting();
1521 }
1522 if (sShapeType == "upArrowCallout")
1523 {
1524 auto aNeckFromBox = GetAdjustmentPointXValue(1);
1525 auto aHeadFromNeck = GetAdjustmentPointXValue(2);
1526 auto aHeadHeight = GetAdjustmentPointYValue(1);
1527 auto aBoxHeight = GetAdjustmentPointYValue(0);
1528 if (!aNeckFromBox.nCurrVal.has_value() || !aNeckFromBox.nMaxVal.has_value()
1529 || !aNeckFromBox.nMinVal.has_value() || !aHeadFromNeck.nCurrVal.has_value()
1530 || !aHeadFromNeck.nMaxVal.has_value() || !aHeadFromNeck.nMinVal.has_value()
1531 || !aHeadHeight.nCurrVal.has_value() || !aHeadHeight.nMaxVal.has_value()
1532 || !aHeadHeight.nMinVal.has_value() || !aBoxHeight.nCurrVal.has_value()
1533 || !aBoxHeight.nMaxVal.has_value() || !aBoxHeight.nMinVal.has_value())
1534 return false;
1535
1537 false, false);
1538 tools::Long nMaxVal1
1539 = 100000 * m_xShape->getSize().Width
1540 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1541 tools::Long nMaxVal2
1542 = 50000 * m_xShape->getSize().Width
1543 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1544 tools::Long nMaxVal3
1545 = 100000 * m_xShape->getSize().Height
1546 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1547 tools::Long nVal1
1548 = std::lround((*aNeckFromBox.nMaxVal - *aNeckFromBox.nCurrVal)
1549 / (*aNeckFromBox.nMaxVal - *aNeckFromBox.nMinVal) * nMaxVal1);
1550 tools::Long nVal2 = std::lround((10800 - *aHeadFromNeck.nCurrVal)
1551 / (10800 - *aHeadFromNeck.nMinVal) * nMaxVal2);
1552 tools::Long nVal3 = std::lround((*aHeadHeight.nCurrVal - *aHeadHeight.nMinVal)
1553 / (21600 - *aHeadHeight.nMinVal) * nMaxVal3);
1554 tools::Long nVal4 = std::lround((*aBoxHeight.nCurrVal - *aBoxHeight.nMinVal)
1555 / (10800 - *aBoxHeight.nMinVal) * 100000);
1556 return StartAVListWriting()
1557 && WriteAV(u"adj1", OUString(u"val " + OUString::number(nVal1)))
1558 && WriteAV(u"adj2", OUString(u"val " + OUString::number(nVal2)))
1559 && WriteAV(u"adj3", OUString(u"val " + OUString::number(nVal3)))
1560 && WriteAV(u"adj4", OUString(u"val " + OUString::number(nVal4)))
1561 && EndAVListWriting();
1562 }
1563 if (sShapeType == "upDownArrow")
1564 {
1565 auto aPointX = GetAdjustmentPointXValue(0);
1566 auto aPointY = GetAdjustmentPointYValue(0);
1567 if (!aPointX.nCurrVal.has_value() || !aPointX.nMaxVal.has_value()
1568 || !aPointX.nMinVal.has_value() || !aPointY.nCurrVal.has_value()
1569 || !aPointY.nMaxVal.has_value() || !aPointY.nMinVal.has_value())
1570 return false;
1571
1573 false, false);
1574 tools::Long nMaxVal1 = 100000;
1575 tools::Long nMaxVal2
1576 = 50000 * m_xShape->getSize().Height
1577 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1578 tools::Long nVal1 = std::lround((*aPointX.nMaxVal - *aPointX.nCurrVal)
1579 / (*aPointX.nMaxVal - *aPointX.nMinVal) * nMaxVal1);
1580 tools::Long nVal2 = std::lround((*aPointY.nCurrVal - *aPointY.nMinVal)
1581 / (*aPointY.nMaxVal - *aPointY.nMinVal) * nMaxVal2);
1582 return StartAVListWriting()
1583 && WriteAV(u"adj1", OUString(u"val " + OUString::number(nVal1)))
1584 && WriteAV(u"adj2", OUString(u"val " + OUString::number(nVal2)))
1585 && EndAVListWriting();
1586 }
1587 if (sShapeType == "upArrow")
1588 {
1589 auto aPointX = GetAdjustmentPointXValue(0);
1590 auto aPointY = GetAdjustmentPointYValue(0);
1591 if (!aPointX.nCurrVal.has_value() || !aPointX.nMaxVal.has_value()
1592 || !aPointX.nMinVal.has_value() || !aPointY.nCurrVal.has_value()
1593 || !aPointY.nMaxVal.has_value() || !aPointY.nMinVal.has_value())
1594 return false;
1595
1597 false, false);
1598 tools::Long nMaxVal1 = 100000;
1599 tools::Long nMaxVal2
1600 = 100000 * m_xShape->getSize().Height
1601 / std::min(m_xShape->getSize().Width, m_xShape->getSize().Height);
1602 tools::Long nVal1 = std::lround((*aPointX.nMaxVal - *aPointX.nCurrVal)
1603 / (*aPointX.nMaxVal - *aPointX.nMinVal) * nMaxVal1);
1604 tools::Long nVal2 = std::lround((*aPointY.nCurrVal - *aPointY.nMinVal)
1605 / (*aPointY.nMaxVal - *aPointY.nMinVal) * nMaxVal2);
1606 return StartAVListWriting()
1607 && WriteAV(u"adj1", OUString(u"val " + OUString::number(nVal1)))
1608 && WriteAV(u"adj2", OUString(u"val " + OUString::number(nVal2)))
1609 && EndAVListWriting();
1610 }
1611 if (sShapeType == "upDownArrowCallout")
1612 {
1613 // TODO
1614 return false;
1615 }
1616 if (sShapeType == "uturnArrow")
1617 {
1618 // LO does not have like this.
1619 return false;
1620 }
1621 if (sShapeType == "verticalScroll")
1622 {
1623 // TODO
1624 return false;
1625 }
1626 if (sShapeType == "wave")
1627 {
1628 // LO does not have.
1629 return false;
1630 }
1631 if (sShapeType == "wedgeEllipseCallout")
1632 {
1633 // TODO
1634 return false;
1635 }
1636 if (sShapeType == "wedgeRectCallout")
1637 {
1638 // TODO
1639 return false;
1640 }
1641 if (sShapeType == "wedgeRoundRectCallout")
1642 {
1643 // TODO
1644 return false;
1645 }
1646 }
1647 catch (...)
1648 {
1649 // Problem detected with the writing, aborting and trying to find another way.
1650 return false;
1651 }
1652
1653 // Default, nothing happened return.
1654 return false;
1655};
1656}
OptionalString sType
const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > & GetHandleValues() const
AngleAdjustmentValue GetAdjustmentPointAngleValue(sal_Int32 nPoint)
const css::uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > & GetAdjustmentValues() const
RadiusAdjustmentValue GetAdjustmentPointRadiusValue(sal_Int32 nPoint)
YAdjustmentValue GetAdjustmentPointYValue(sal_Int32 nPoint)
XAdjustmentValue GetAdjustmentPointXValue(sal_Int32 nPoint)
css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > m_HandleValues
css::uno::Reference< css::drawing::XShape > m_xShape
css::uno::Any GetHandleValueOfModificationPoint(sal_Int32 nPoint, std::u16string_view sType)
bool WriteAV(const OUString &sValName, const OUString &sVal)
css::uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > m_AdjustmentValues
const ::sax_fastparser::FSHelperPtr & GetFS() const
Definition: drawingml.hxx:345
void WriteShapeTransformation(const css::uno::Reference< css::drawing::XShape > &rXShape, sal_Int32 nXmlNamespace, bool bFlipH=false, bool bFlipV=false, bool bSuppressRotation=false, bool bSuppressFlipping=false, bool bFlippedBeforeRotation=false)
Definition: drawingml.cxx:2214
void WritePresetShape(const OString &pShape, std::vector< std::pair< sal_Int32, sal_Int32 > > &rAvList)
Definition: drawingml.cxx:4260
float u
double getLength(const B2DPolygon &rCandidate)
Value
OString GetOOXMLPresetGeometry(std::u16string_view rShapeType)
long Long