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