10#include <config_folders.h>
11#include <rtl/bootstrap.hxx>
17#include <oox/token/properties.hxx>
19#include <com/sun/star/awt/Rectangle.hpp>
20#include <com/sun/star/beans/PropertyValue.hpp>
21#include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
22#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
30void lcl_parseAdjustmentValue(
31 std::vector<drawing::EnhancedCustomShapeAdjustmentValue>& rAdjustmentValues,
32 std::string_view rValue)
35 drawing::EnhancedCustomShapeAdjustmentValue aAdjustmentValue;
39 static const char aNamePrefix[] =
"Name = \"";
40 static const char aValuePrefix[] =
"Value = (any) { (long) ";
43 OString
aName = aToken.copy(strlen(aNamePrefix),
44 aToken.getLength() - strlen(aNamePrefix) - strlen(
"\""));
45 aAdjustmentValue.Name = OUString::fromUtf8(aName);
49 OString aValue = aToken.copy(strlen(aValuePrefix),
50 aToken.getLength() - strlen(aValuePrefix) - strlen(
" }"));
51 aAdjustmentValue.Value <<= aValue.toInt32();
54 SAL_WARN(
"oox",
"lcl_parseAdjustmentValue: unexpected prefix: " << aToken);
55 }
while (nIndex >= 0);
56 rAdjustmentValues.push_back(aAdjustmentValue);
60void lcl_parseAdjustmentValues(
61 std::vector<drawing::EnhancedCustomShapeAdjustmentValue>& rAdjustmentValues,
62 std::string_view rValue)
66 for (
size_t i = 0;
i < rValue.size(); ++
i)
74 else if (rValue[
i] ==
'}')
79 lcl_parseAdjustmentValue(
81 rValue.substr(nStart + strlen(
"{ "),
i - nStart - strlen(
" },")));
87drawing::EnhancedCustomShapeParameterPair
88lcl_parseEnhancedCustomShapeParameterPair(std::string_view rValue)
90 drawing::EnhancedCustomShapeParameterPair aPair;
92 static const char aExpectedFVPrefix[]
93 =
"First = (com.sun.star.drawing.EnhancedCustomShapeParameter) { Value = (any) { (long) ";
95 sal_Int32
nIndex = strlen(aExpectedFVPrefix);
99 static const char aExpectedFTPrefix[] =
", Type = (short) ";
100 assert(nIndex >= 0 &&
o3tl::starts_with(rValue.substr(nIndex), aExpectedFTPrefix));
101 nIndex += strlen(aExpectedFTPrefix);
105 static const char aExpectedSVPrefix[] =
", Second = "
106 "(com.sun.star.drawing.EnhancedCustomShapeParameter) { "
107 "Value = (any) { (long) ";
108 assert(nIndex >= 0 &&
o3tl::starts_with(rValue.substr(nIndex), aExpectedSVPrefix));
109 nIndex += strlen(aExpectedSVPrefix);
113 static const char aExpectedSTPrefix[] =
", Type = (short) ";
114 assert(nIndex >= 0 &&
o3tl::starts_with(rValue.substr(nIndex), aExpectedSTPrefix));
115 nIndex += strlen(aExpectedSTPrefix);
121drawing::EnhancedCustomShapeSegment lcl_parseEnhancedCustomShapeSegment(std::string_view rValue)
123 drawing::EnhancedCustomShapeSegment aSegment;
125 static const char aExpectedCommandPrefix[] =
"Command = (short) ";
127 sal_Int32
nIndex = strlen(aExpectedCommandPrefix);
131 static const char aExpectedCountPrefix[] =
" Count = (short) ";
132 assert(nIndex >= 0 &&
o3tl::starts_with(rValue.substr(nIndex), aExpectedCountPrefix));
133 nIndex += strlen(aExpectedCountPrefix);
138awt::Rectangle lcl_parseRectangle(std::string_view rValue)
140 awt::Rectangle aRectangle;
142 static const char aExpectedXPrefix[] =
"X = (long) ";
144 sal_Int32
nIndex = strlen(aExpectedXPrefix);
147 static const char aExpectedYPrefix[] =
" Y = (long) ";
148 assert(nIndex >= 0 &&
o3tl::starts_with(rValue.substr(nIndex), aExpectedYPrefix));
149 nIndex += strlen(aExpectedYPrefix);
152 static const char aExpectedWidthPrefix[] =
" Width = (long) ";
153 assert(nIndex >= 0 &&
o3tl::starts_with(rValue.substr(nIndex), aExpectedWidthPrefix));
154 nIndex += strlen(aExpectedWidthPrefix);
157 static const char aExpectedHeightPrefix[] =
" Height = (long) ";
158 assert(nIndex >= 0 &&
o3tl::starts_with(rValue.substr(nIndex), aExpectedHeightPrefix));
159 nIndex += strlen(aExpectedHeightPrefix);
165awt::Size lcl_parseSize(std::string_view rValue)
169 static const char aExpectedWidthPrefix[] =
"Width = (long) ";
171 sal_Int32
nIndex = strlen(aExpectedWidthPrefix);
174 static const char aExpectedHeightPrefix[] =
" Height = (long) ";
175 assert(nIndex >= 0 &&
o3tl::starts_with(rValue.substr(nIndex), aExpectedHeightPrefix));
176 nIndex += strlen(aExpectedHeightPrefix);
182drawing::EnhancedCustomShapeTextFrame lcl_parseEnhancedCustomShapeTextFrame(std::string_view rValue)
184 drawing::EnhancedCustomShapeTextFrame aTextFrame;
185 sal_Int32 nLevel = 0;
186 bool bIgnore =
false;
187 sal_Int32 nStart = 0;
188 for (
size_t i = 0;
i < rValue.size(); ++
i)
190 if (rValue[
i] ==
'{')
196 else if (rValue[
i] ==
'}')
202 else if (rValue[
i] ==
',' && !bIgnore)
204 std::string_view aToken = rValue.substr(nStart,
i - nStart);
205 static const char aExpectedPrefix[]
206 =
"TopLeft = (com.sun.star.drawing.EnhancedCustomShapeParameterPair) { ";
209 aToken = aToken.substr(strlen(aExpectedPrefix),
210 aToken.size() - strlen(aExpectedPrefix) - strlen(
" }"));
211 aTextFrame.TopLeft = lcl_parseEnhancedCustomShapeParameterPair(aToken);
215 "lcl_parseEnhancedCustomShapeTextFrame: unexpected token: " << aToken);
216 nStart =
i + strlen(
", ");
220 std::string_view aToken = rValue.substr(nStart);
221 static const char aExpectedPrefix[]
222 =
"BottomRight = (com.sun.star.drawing.EnhancedCustomShapeParameterPair) { ";
225 aToken = aToken.substr(strlen(aExpectedPrefix),
226 aToken.size() - strlen(aExpectedPrefix) - strlen(
" }"));
227 aTextFrame.BottomRight = lcl_parseEnhancedCustomShapeParameterPair(aToken);
231 "lcl_parseEnhancedCustomShapeTextFrame: unexpected token at the end: " << aToken);
238void lcl_parseHandlePosition(std::vector<beans::PropertyValue>& rHandle, std::string_view rValue)
240 sal_Int32 nLevel = 0;
241 bool bIgnore =
false;
242 sal_Int32 nStart = 0;
243 for (
size_t i = 0;
i < rValue.size(); ++
i)
245 if (rValue[
i] ==
'{')
251 else if (rValue[
i] ==
'}')
257 else if (rValue[
i] ==
',' && !bIgnore)
259 std::string_view aToken = rValue.substr(nStart,
i - nStart);
260 static const char aExpectedPrefix[]
261 =
"Value = (any) { (com.sun.star.drawing.EnhancedCustomShapeParameterPair) { ";
264 aToken = aToken.substr(strlen(aExpectedPrefix),
265 aToken.size() - strlen(aExpectedPrefix) - strlen(
" } }"));
267 beans::PropertyValue aPropertyValue;
268 aPropertyValue.Name =
"Position";
269 aPropertyValue.Value <<= lcl_parseEnhancedCustomShapeParameterPair(aToken);
270 rHandle.push_back(aPropertyValue);
273 SAL_WARN(
"oox",
"lcl_parseHandlePosition: unexpected token: " << aToken);
274 nStart =
i + strlen(
", ");
281void lcl_parseHandleRange(std::vector<beans::PropertyValue>& rHandle, std::string_view rValue,
282 const OUString& rName)
284 sal_Int32 nLevel = 0;
285 bool bIgnore =
false;
286 sal_Int32 nStart = 0;
287 for (
size_t i = 0;
i < rValue.size(); ++
i)
289 if (rValue[
i] ==
'{')
295 else if (rValue[
i] ==
'}')
301 else if (rValue[
i] ==
',' && !bIgnore)
303 static const char aExpectedPrefix[]
304 =
"Value = (any) { (com.sun.star.drawing.EnhancedCustomShapeParameter) { ";
307 drawing::EnhancedCustomShapeParameter aParameter;
308 sal_Int32
nIndex{ nStart +
static_cast<sal_Int32
>(strlen(aExpectedPrefix)) };
310 static const char aExpectedVPrefix[] =
"Value = (any) { (long) ";
312 nIndex += strlen(aExpectedVPrefix);
315 static const char aExpectedTPrefix[] =
", Type = (short) ";
316 assert(nIndex >= 0 &&
o3tl::starts_with(rValue.substr(nIndex), aExpectedTPrefix));
317 nIndex += strlen(aExpectedTPrefix);
321 beans::PropertyValue aPropertyValue;
322 aPropertyValue.Name = rName;
323 aPropertyValue.Value <<= aParameter;
324 rHandle.push_back(aPropertyValue);
328 SAL_WARN(
"oox",
"lcl_parseHandleRange: unexpected token: "
329 << rValue.substr(nStart,
i - nStart));
330 nStart =
i + strlen(
", ");
336void lcl_parseHandleRef(std::vector<beans::PropertyValue>& rHandle, std::string_view rValue,
337 const OUString& rName)
339 static constexpr std::string_view aPrefix =
"\", Handle = (long) 0, Value = (any) { (long) ";
340 const sal_Int32 nStart =
SAL_N_ELEMENTS(
"Name = \"") - 1 + rName.getLength();
342 if (rValue.substr(nStart, aPrefix.size()) == aPrefix)
344 sal_Int32
nIndex = nStart + aPrefix.size();
345 beans::PropertyValue aPropertyValue;
346 aPropertyValue.Name = rName;
349 rHandle.push_back(aPropertyValue);
352 SAL_WARN(
"oox",
"lcl_parseHandleRef: unexpected value: " << rValue);
355uno::Sequence<beans::PropertyValue> lcl_parseHandle(std::string_view rValue)
357 std::vector<beans::PropertyValue> aRet;
358 sal_Int32 nLevel = 0;
359 sal_Int32 nStart = 0;
360 for (
size_t i = 0;
i < rValue.size(); ++
i)
362 if (rValue[
i] ==
'{')
368 else if (rValue[
i] ==
'}')
373 std::string_view aToken
374 = rValue.substr(nStart + strlen(
"{ "),
i - nStart - strlen(
" },"));
376 lcl_parseHandlePosition(aRet, aToken);
378 lcl_parseHandleRange(aRet, aToken,
"RangeXMaximum");
380 lcl_parseHandleRange(aRet, aToken,
"RangeXMinimum");
382 lcl_parseHandleRange(aRet, aToken,
"RangeYMaximum");
384 lcl_parseHandleRange(aRet, aToken,
"RangeYMinimum");
386 lcl_parseHandleRange(aRet, aToken,
"RadiusRangeMaximum");
388 lcl_parseHandleRange(aRet, aToken,
"RadiusRangeMinimum");
390 lcl_parseHandleRef(aRet, aToken,
"RefX");
392 lcl_parseHandleRef(aRet, aToken,
"RefY");
394 lcl_parseHandleRef(aRet, aToken,
"RefR");
396 lcl_parseHandleRef(aRet, aToken,
"RefAngle");
398 SAL_WARN(
"oox",
"lcl_parseHandle: unexpected token: " << aToken);
405void lcl_parseHandles(std::vector<uno::Sequence<beans::PropertyValue>>& rHandles,
406 std::string_view rValue)
408 sal_Int32 nLevel = 0;
409 sal_Int32 nStart = 0;
410 for (
size_t i = 0;
i < rValue.size(); ++
i)
412 if (rValue[
i] ==
'{')
418 else if (rValue[
i] ==
'}')
423 uno::Sequence<beans::PropertyValue> aHandle = lcl_parseHandle(
424 rValue.substr(nStart + strlen(
"{ "),
i - nStart - strlen(
" },")));
425 rHandles.push_back(aHandle);
431void lcl_parseEquations(std::vector<OUString>& rEquations, std::string_view rValue)
433 bool bInString =
false;
434 sal_Int32 nStart = 0;
435 for (
size_t i = 0;
i < rValue.size(); ++
i)
437 if (rValue[
i] ==
'"' && !bInString)
442 else if (rValue[
i] ==
'"' && bInString)
445 rEquations.push_back(OUString::fromUtf8(
446 rValue.substr(nStart + strlen(
"\""),
i - nStart - strlen(
"\""))));
451void lcl_parsePathCoordinateValues(std::vector<beans::PropertyValue>& rPath,
452 std::string_view rValue)
454 std::vector<drawing::EnhancedCustomShapeParameterPair> aPairs;
455 sal_Int32 nLevel = 0;
456 sal_Int32 nStart = 0;
457 for (
size_t i = 0;
i < rValue.size(); ++
i)
459 if (rValue[
i] ==
'{')
465 else if (rValue[
i] ==
'}')
469 aPairs.push_back(lcl_parseEnhancedCustomShapeParameterPair(
470 rValue.substr(nStart + strlen(
"{ "),
i - nStart - strlen(
" },"))));
474 beans::PropertyValue aPropertyValue;
475 aPropertyValue.Name =
"Coordinates";
477 rPath.push_back(aPropertyValue);
482void lcl_parsePathCoordinates(std::vector<beans::PropertyValue>& rPath, std::string_view rValue)
484 sal_Int32 nLevel = 0;
485 bool bIgnore =
false;
486 sal_Int32 nStart = 0;
487 for (
size_t i = 0;
i < rValue.size(); ++
i)
489 if (rValue[
i] ==
'{')
495 else if (rValue[
i] ==
'}')
501 else if (rValue[
i] ==
',' && !bIgnore)
503 std::string_view aToken = rValue.substr(nStart,
i - nStart);
504 static const char aExpectedPrefix[]
505 =
"Value = (any) { ([]com.sun.star.drawing.EnhancedCustomShapeParameterPair) { ";
508 aToken = aToken.substr(strlen(aExpectedPrefix),
509 aToken.size() - strlen(aExpectedPrefix) - strlen(
" } }"));
510 lcl_parsePathCoordinateValues(rPath, aToken);
513 SAL_WARN(
"oox",
"lcl_parsePathCoordinates: unexpected token: " << aToken);
514 nStart =
i + strlen(
", ");
519void lcl_parsePathGluePointsValues(std::vector<beans::PropertyValue>& rPath,
520 std::string_view rValue)
522 std::vector<drawing::EnhancedCustomShapeParameterPair> aPairs;
523 sal_Int32 nLevel = 0;
524 sal_Int32 nStart = 0;
525 for (
size_t i = 0;
i < rValue.size(); ++
i)
527 if (rValue[
i] ==
'{')
533 else if (rValue[
i] ==
'}')
537 aPairs.push_back(lcl_parseEnhancedCustomShapeParameterPair(
538 rValue.substr(nStart + strlen(
"{ "),
i - nStart - strlen(
" },"))));
542 beans::PropertyValue aPropertyValue;
543 aPropertyValue.Name =
"GluePoints";
545 rPath.push_back(aPropertyValue);
548void lcl_parsePathGluePoints(std::vector<beans::PropertyValue>& rPath, std::string_view rValue)
550 sal_Int32 nLevel = 0;
551 bool bIgnore =
false;
552 sal_Int32 nStart = 0;
553 for (
size_t i = 0;
i < rValue.size(); ++
i)
555 if (rValue[
i] ==
'{')
561 else if (rValue[
i] ==
'}')
567 else if (rValue[
i] ==
',' && !bIgnore)
569 std::string_view aToken = rValue.substr(nStart,
i - nStart);
570 static const char aExpectedPrefix[]
571 =
"Value = (any) { ([]com.sun.star.drawing.EnhancedCustomShapeParameterPair) { ";
574 aToken = aToken.substr(strlen(aExpectedPrefix),
575 aToken.size() - strlen(aExpectedPrefix) - strlen(
" } }"));
576 lcl_parsePathGluePointsValues(rPath, aToken);
579 SAL_WARN(
"oox",
"lcl_parsePathGluePoints: unexpected token: " << aToken);
580 nStart =
i + strlen(
", ");
585void lcl_parsePathSegmentValues(std::vector<beans::PropertyValue>& rPath, std::string_view rValue)
587 std::vector<drawing::EnhancedCustomShapeSegment>
aSegments;
588 sal_Int32 nLevel = 0;
589 sal_Int32 nStart = 0;
590 for (
size_t i = 0;
i < rValue.size(); ++
i)
592 if (rValue[
i] ==
'{')
598 else if (rValue[
i] ==
'}')
602 aSegments.push_back(lcl_parseEnhancedCustomShapeSegment(
603 rValue.substr(nStart + strlen(
"{ "),
i - nStart - strlen(
" },"))));
607 beans::PropertyValue aPropertyValue;
608 aPropertyValue.Name =
"Segments";
610 rPath.push_back(aPropertyValue);
615void lcl_parsePathSegments(std::vector<beans::PropertyValue>& rPath, std::string_view rValue)
617 sal_Int32 nLevel = 0;
618 bool bIgnore =
false;
619 sal_Int32 nStart = 0;
620 for (
size_t i = 0;
i < rValue.size(); ++
i)
622 if (rValue[
i] ==
'{')
628 else if (rValue[
i] ==
'}')
634 else if (rValue[
i] ==
',' && !bIgnore)
636 std::string_view aToken = rValue.substr(nStart,
i - nStart);
637 static const char aExpectedPrefix[]
638 =
"Value = (any) { ([]com.sun.star.drawing.EnhancedCustomShapeSegment) { ";
641 aToken = aToken.substr(strlen(aExpectedPrefix),
642 aToken.size() - strlen(aExpectedPrefix) - strlen(
" } }"));
643 lcl_parsePathSegmentValues(rPath, aToken);
646 SAL_WARN(
"oox",
"lcl_parsePathSegments: unexpected token: " << aToken);
647 nStart =
i + strlen(
", ");
652void lcl_parsePathTextFrameValues(std::vector<beans::PropertyValue>& rPath, std::string_view rValue)
654 std::vector<drawing::EnhancedCustomShapeTextFrame> aTextFrames;
655 sal_Int32 nLevel = 0;
656 sal_Int32 nStart = 0;
657 for (
size_t i = 0;
i < rValue.size(); ++
i)
659 if (rValue[
i] ==
'{')
665 else if (rValue[
i] ==
'}')
669 aTextFrames.push_back(lcl_parseEnhancedCustomShapeTextFrame(
670 rValue.substr(nStart + strlen(
"{ "),
i - nStart - strlen(
" },"))));
674 beans::PropertyValue aPropertyValue;
675 aPropertyValue.Name =
"TextFrames";
677 rPath.push_back(aPropertyValue);
682void lcl_parsePathTextFrames(std::vector<beans::PropertyValue>& rPath, std::string_view rValue)
684 sal_Int32 nLevel = 0;
685 bool bIgnore =
false;
686 sal_Int32 nStart = 0;
687 for (
size_t i = 0;
i < rValue.size(); ++
i)
689 if (rValue[
i] ==
'{')
695 else if (rValue[
i] ==
'}')
701 else if (rValue[
i] ==
',' && !bIgnore)
703 std::string_view aToken = rValue.substr(nStart,
i - nStart);
704 static const char aExpectedPrefix[]
705 =
"Value = (any) { ([]com.sun.star.drawing.EnhancedCustomShapeTextFrame) { ";
708 aToken = aToken.substr(strlen(aExpectedPrefix),
709 aToken.size() - strlen(aExpectedPrefix) - strlen(
" } }"));
710 lcl_parsePathTextFrameValues(rPath, aToken);
713 SAL_WARN(
"oox",
"lcl_parsePathTextFrames: unexpected token: " << aToken);
714 nStart =
i + strlen(
", ");
719void lcl_parsePathSubViewSizeValues(std::vector<beans::PropertyValue>& rPath,
720 std::string_view rValue)
722 std::vector<awt::Size> aSizes;
723 sal_Int32 nLevel = 0;
724 sal_Int32 nStart = 0;
725 for (
size_t i = 0;
i < rValue.size(); ++
i)
727 if (rValue[
i] ==
'{')
733 else if (rValue[
i] ==
'}')
737 aSizes.push_back(lcl_parseSize(
738 rValue.substr(nStart + strlen(
"{ "),
i - nStart - strlen(
" },"))));
742 beans::PropertyValue aPropertyValue;
743 aPropertyValue.Name =
"SubViewSize";
745 rPath.push_back(aPropertyValue);
748void lcl_parsePathSubViewSize(std::vector<beans::PropertyValue>& rPath, std::string_view rValue)
750 sal_Int32 nLevel = 0;
751 bool bIgnore =
false;
752 sal_Int32 nStart = 0;
753 for (
size_t i = 0;
i < rValue.size(); ++
i)
755 if (rValue[
i] ==
'{')
761 else if (rValue[
i] ==
'}')
767 else if (rValue[
i] ==
',' && !bIgnore)
769 std::string_view aToken = rValue.substr(nStart,
i - nStart);
770 static const char aExpectedPrefix[] =
"Value = (any) { ([]com.sun.star.awt.Size) { ";
773 aToken = aToken.substr(strlen(aExpectedPrefix),
774 aToken.size() - strlen(aExpectedPrefix) - strlen(
" } }"));
775 lcl_parsePathSubViewSizeValues(rPath, aToken);
778 SAL_WARN(
"oox",
"lcl_parsePathSubViewSize: unexpected token: " << aToken);
779 nStart =
i + strlen(
", ");
784void lcl_parsePath(std::vector<beans::PropertyValue>& rPath, std::string_view rValue)
786 sal_Int32 nLevel = 0;
787 sal_Int32 nStart = 0;
788 for (
size_t i = 0;
i < rValue.size(); ++
i)
790 if (rValue[
i] ==
'{')
796 else if (rValue[
i] ==
'}')
801 std::string_view aToken
802 = rValue.substr(nStart + strlen(
"{ "),
i - nStart - strlen(
" },"));
804 lcl_parsePathCoordinates(rPath, aToken);
806 lcl_parsePathGluePoints(rPath, aToken);
808 lcl_parsePathSegments(rPath, aToken);
810 lcl_parsePathTextFrames(rPath, aToken);
812 lcl_parsePathSubViewSize(rPath, aToken);
814 SAL_WARN(
"oox",
"lcl_parsePath: unexpected token: " << aToken);
825 OUString aPath(
"$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER
"/filter/oox-drawingml-cs-presets");
826 rtl::Bootstrap::expandMacros(aPath);
829 SAL_WARN(
"oox",
"failed to open oox-drawingml-cs-presets");
832 bool bNotDone = aStream.
ReadLine(aLine);
837 static const char aCommentPrefix[] =
"/* ";
844 aName = OUString::fromUtf8(std::string_view(aLine).substr(
845 strlen(aCommentPrefix),
846 aLine.getLength() - strlen(aCommentPrefix) - strlen(
" */")));
850 if (std::string_view(aLine) ==
"AdjustmentValues")
853 if (std::string_view(aLine)
854 !=
"([]com.sun.star.drawing.EnhancedCustomShapeAdjustmentValue) {}")
856 std::vector<drawing::EnhancedCustomShapeAdjustmentValue> aAdjustmentValues;
857 static constexpr std::string_view aExpectedPrefix(
858 "([]com.sun.star.drawing.EnhancedCustomShapeAdjustmentValue) { ");
861 std::string_view aValue = std::string_view(aLine).substr(
862 aExpectedPrefix.size(),
863 aLine.getLength() - aExpectedPrefix.size() - strlen(
" }"));
864 lcl_parseAdjustmentValues(aAdjustmentValues, aValue);
869 aPropertyMap.
setProperty(PROP_AdjustmentValues, uno::Sequence<OUString>(0));
871 else if (std::string_view(aLine) ==
"Equations")
874 if (std::string_view(aLine) !=
"([]string) {}")
876 std::vector<OUString> aEquations;
877 static constexpr std::string_view aExpectedPrefix(
"([]string) { ");
880 std::string_view aValue = std::string_view(aLine).substr(
881 aExpectedPrefix.size(),
882 aLine.getLength() - aExpectedPrefix.size() - strlen(
" }"));
883 lcl_parseEquations(aEquations, aValue);
888 aPropertyMap.
setProperty(PROP_Equations, uno::Sequence<OUString>(0));
890 else if (std::string_view(aLine) ==
"Handles")
893 if (std::string_view(aLine) !=
"([][]com.sun.star.beans.PropertyValue) {}")
895 std::vector<uno::Sequence<beans::PropertyValue>> aHandles;
896 static constexpr std::string_view aExpectedPrefix(
897 "([][]com.sun.star.beans.PropertyValue) { ");
900 std::string_view aValue = std::string_view(aLine).substr(
901 aExpectedPrefix.size(),
902 aLine.getLength() - aExpectedPrefix.size() - strlen(
" }"));
903 lcl_parseHandles(aHandles, aValue);
908 aPropertyMap.
setProperty(PROP_Handles, uno::Sequence<OUString>(0));
910 else if (std::string_view(aLine) ==
"MirroredX")
913 if (std::string_view(aLine) ==
"true" || std::string_view(aLine) ==
"false")
915 aPropertyMap.
setProperty(PROP_MirroredX, std::string_view(aLine) ==
"true");
918 SAL_WARN(
"oox",
"CustomShapeProperties::initializePresetDataMap: unexpected "
919 "MirroredX parameter");
921 else if (std::string_view(aLine) ==
"MirroredY")
924 if (std::string_view(aLine) ==
"true" || std::string_view(aLine) ==
"false")
926 aPropertyMap.
setProperty(PROP_MirroredY, std::string_view(aLine) ==
"true");
929 SAL_WARN(
"oox",
"CustomShapeProperties::initializePresetDataMap: unexpected "
930 "MirroredY parameter");
932 else if (std::string_view(aLine) ==
"Path")
935 static constexpr std::string_view aExpectedPrefix(
936 "([]com.sun.star.beans.PropertyValue) { ");
939 std::vector<beans::PropertyValue> aPathValue;
940 std::string_view aValue = std::string_view(aLine).substr(
941 aExpectedPrefix.size(),
942 aLine.getLength() - aExpectedPrefix.size() - strlen(
" }"));
943 lcl_parsePath(aPathValue, aValue);
946 else if (std::string_view(aLine) ==
"Type")
952 else if (std::string_view(aLine) ==
"ViewBox")
955 static constexpr std::string_view aExpectedPrefix(
956 "(com.sun.star.awt.Rectangle) { ");
959 std::string_view aValue = std::string_view(aLine).substr(
960 aExpectedPrefix.size(),
961 aLine.getLength() - aExpectedPrefix.size() - strlen(
" }"));
962 aPropertyMap.
setProperty(PROP_ViewBox, lcl_parseRectangle(aValue));
965 SAL_WARN(
"oox",
"CustomShapeProperties::initializePresetDataMap: unhandled line: "
966 << std::string_view(aLine));
bool ReadLine(OStringBuffer &rStr, sal_Int32 nMaxBytesToRead=0xFFFE)
A helper that maps property identifiers to property values.
bool setProperty(sal_Int32 nPropId, Type &&rValue)
Sets the specified property to the passed value.
static sal_Int32 getTokenFromUnicode(std::u16string_view rUnicodeName)
Returns the token identifier for the passed Unicode token name.
static void initializePresetDataMap()
static PresetDataMap maPresetDataMap
#define SAL_WARN(area, stream)
#define SAL_N_ELEMENTS(arr)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
std::vector< ISegmentProgressBarRef > aSegments