26#include <rtl/ustrbuf.hxx>
27#include <osl/diagnose.h>
40static void Imp_SkipSpaces(std::u16string_view rStr, sal_Int32& rPos,
const sal_Int32 nLen)
50 && (
' ' == rStr[rPos] ||
'(' == rStr[rPos]))
57 && (
' ' == rStr[rPos] ||
',' == rStr[rPos]))
64 && (
' ' == rStr[rPos] ||
')' == rStr[rPos]))
74 return (
'a' <= aChar &&
'z' >= aChar)
75 || (
'A' <= aChar &&
'Z' >= aChar)
79static double Imp_GetDoubleChar(std::u16string_view rStr, sal_Int32& rPos,
const sal_Int32 nLen,
83 OUStringBuffer sNumberString(32);
85 if(
'+' == aChar ||
'-' == aChar)
87 sNumberString.append(rStr[rPos]);
89 aChar = rPos >= nLen ? 0 : rStr[rPos];
92 while((
'0' <= aChar &&
'9' >= aChar)
95 sNumberString.append(rStr[rPos]);
97 aChar = rPos >= nLen ? 0 : rStr[rPos];
100 if(
'e' == aChar ||
'E' == aChar)
102 sNumberString.append(rStr[rPos]);
104 aChar = rPos >= nLen ? 0 : rStr[rPos];
106 if(
'+' == aChar ||
'-' == aChar)
108 sNumberString.append(rStr[rPos]);
110 aChar = rPos >= nLen ? 0 : rStr[rPos];
113 while(
'0' <= aChar &&
'9' >= aChar)
115 sNumberString.append(rStr[rPos]);
117 aChar = rPos >= nLen ? 0 : rStr[rPos];
125 sNumberString.append(rStr[rPos++]);
128 if(!sNumberString.isEmpty())
143 OUStringBuffer sStringBuffer;
145 rStr += sStringBuffer;
149 bool bConvertUnits =
false)
151 OUStringBuffer sStringBuffer;
160 rStr.append(sStringBuffer);
174#define IMP_SDXMLEXP_TRANSOBJ2D_ROTATE 0x0000
175#define IMP_SDXMLEXP_TRANSOBJ2D_SCALE 0x0001
176#define IMP_SDXMLEXP_TRANSOBJ2D_TRANSLATE 0x0002
177#define IMP_SDXMLEXP_TRANSOBJ2D_SKEWX 0x0003
178#define IMP_SDXMLEXP_TRANSOBJ2D_SKEWY 0x0004
179#define IMP_SDXMLEXP_TRANSOBJ2D_MATRIX 0x0005
188 explicit ImpSdXMLExpTransObj2DRotate(
double fVal)
194 explicit ImpSdXMLExpTransObj2DScale(const ::basegfx::B2DTuple& rNew)
200 explicit ImpSdXMLExpTransObj2DTranslate(const ::basegfx::B2DTuple& rNew)
206 explicit ImpSdXMLExpTransObj2DSkewX(
double fVal)
212 explicit ImpSdXMLExpTransObj2DSkewY(
double fVal)
229 maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DRotate>(fNew));
234 if(!rNew.equalZero())
235 maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DTranslate>(rNew));
241 maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DSkewX>(fNew));
247 OUStringBuffer aNewString;
248 OUString aClosingBrace(
")");
249 OUString aEmptySpace(
" ");
259 aNewString.append(
"rotate (");
260 Imp_PutDoubleChar(aNewString, rConv,
static_cast<ImpSdXMLExpTransObj2DRotate*
>(pObj)->mfRotate);
261 aNewString.append(aClosingBrace);
266 aNewString.append(
"scale (");
267 Imp_PutDoubleChar(aNewString, rConv,
static_cast<ImpSdXMLExpTransObj2DScale*
>(pObj)->maScale.getX());
268 aNewString.append(aEmptySpace);
269 Imp_PutDoubleChar(aNewString, rConv,
static_cast<ImpSdXMLExpTransObj2DScale*
>(pObj)->maScale.getY());
270 aNewString.append(aClosingBrace);
275 aNewString.append(
"translate (");
276 Imp_PutDoubleChar(aNewString, rConv,
static_cast<ImpSdXMLExpTransObj2DTranslate*
>(pObj)->maTranslate.getX(),
true);
277 aNewString.append(aEmptySpace);
278 Imp_PutDoubleChar(aNewString, rConv,
static_cast<ImpSdXMLExpTransObj2DTranslate*
>(pObj)->maTranslate.getY(),
true);
279 aNewString.append(aClosingBrace);
284 aNewString.append(
"skewX (");
285 Imp_PutDoubleChar(aNewString, rConv,
static_cast<ImpSdXMLExpTransObj2DSkewX*
>(pObj)->mfSkewX);
286 aNewString.append(aClosingBrace);
291 aNewString.append(
"skewY (");
292 Imp_PutDoubleChar(aNewString, rConv,
static_cast<ImpSdXMLExpTransObj2DSkewY*
>(pObj)->mfSkewY);
293 aNewString.append(aClosingBrace);
298 aNewString.append(
"matrix (");
302 aNewString.append(aEmptySpace);
306 aNewString.append(aEmptySpace);
310 aNewString.append(aEmptySpace);
314 aNewString.append(aEmptySpace);
318 aNewString.append(aEmptySpace);
323 aNewString.append(aClosingBrace);
328 OSL_FAIL(
"SdXMLImExTransform2D: impossible entry!");
336 aNewString.append(aEmptySpace);
341 msString = aNewString.makeStringAndClear();
356 const sal_Int32 nLen(
aStr.getLength());
358 static constexpr OUStringLiteral aString_rotate(
u"rotate" );
359 static constexpr OUStringLiteral aString_scale(
u"scale" );
360 static constexpr OUStringLiteral aString_translate(
u"translate" );
361 static constexpr OUStringLiteral aString_skewX(
u"skewX" );
362 static constexpr OUStringLiteral aString_skewY(
u"skewY" );
363 static constexpr OUStringLiteral aString_matrix(
u"matrix" );
382 maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DRotate>(fValue));
395 if(aValue.
getX() != 1.0 || aValue.
getY() != 1.0)
396 maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DScale>(aValue));
410 maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DTranslate>(aValue));
421 maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DSkewX>(fValue));
432 maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DSkewY>(fValue));
468 maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DMatrix>(aValue));
498 rFullTrans.
rotate(
static_cast<ImpSdXMLExpTransObj2DRotate*
>(pObj)->mfRotate * -1.0);
503 const ::basegfx::B2DTuple& rScale =
static_cast<ImpSdXMLExpTransObj2DScale*
>(pObj)->maScale;
504 rFullTrans.
scale(rScale.getX(), rScale.getY());
509 const ::basegfx::B2DTuple& rTranslate =
static_cast<ImpSdXMLExpTransObj2DTranslate*
>(pObj)->maTranslate;
510 rFullTrans.
translate(rTranslate.getX(), rTranslate.getY());
517 rFullTrans.
shearX(-tan(
static_cast<ImpSdXMLExpTransObj2DSkewX*
>(pObj)->mfSkewX));
526 rFullTrans.
shearY(-tan(
static_cast<ImpSdXMLExpTransObj2DSkewY*
>(pObj)->mfSkewY));
531 rFullTrans *=
static_cast<ImpSdXMLExpTransObj2DMatrix*
>(pObj)->
maMatrix;
536 OSL_FAIL(
"SdXMLImExTransform2D: impossible entry!");
554#define IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_X 0x0000
555#define IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Y 0x0001
556#define IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Z 0x0002
557#define IMP_SDXMLEXP_TRANSOBJ3D_SCALE 0x0003
558#define IMP_SDXMLEXP_TRANSOBJ3D_TRANSLATE 0x0004
559#define IMP_SDXMLEXP_TRANSOBJ3D_MATRIX 0x0005
568 explicit ImpSdXMLExpTransObj3DRotateX(
double fVal)
574 explicit ImpSdXMLExpTransObj3DRotateY(
double fVal)
580 explicit ImpSdXMLExpTransObj3DRotateZ(
double fVal)
586 explicit ImpSdXMLExpTransObj3DScale(const ::basegfx::B3DTuple& rNew)
592 explicit ImpSdXMLExpTransObj3DTranslate(const ::basegfx::B3DTuple& rNew)
608 if(!rNew.isIdentity())
609 maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DMatrix>(rNew));
620 OUStringBuffer aNewString;
621 OUString aClosingBrace(
")");
622 OUString aEmptySpace(
" ");
632 aNewString.append(
"rotatex (");
634 aNewString.append(aClosingBrace);
639 aNewString.append(
"rotatey (");
641 aNewString.append(aClosingBrace);
646 aNewString.append(
"rotatez (");
648 aNewString.append(aClosingBrace);
653 aNewString.append(
"scale (");
654 Imp_PutDoubleChar(aNewString, rConv,
static_cast<ImpSdXMLExpTransObj3DScale*
>(pObj)->maScale.getX());
655 aNewString.append(aEmptySpace);
656 Imp_PutDoubleChar(aNewString, rConv,
static_cast<ImpSdXMLExpTransObj3DScale*
>(pObj)->maScale.getY());
657 aNewString.append(aEmptySpace);
658 Imp_PutDoubleChar(aNewString, rConv,
static_cast<ImpSdXMLExpTransObj3DScale*
>(pObj)->maScale.getZ());
659 aNewString.append(aClosingBrace);
664 aNewString.append(
"translate (");
665 Imp_PutDoubleChar(aNewString, rConv,
static_cast<ImpSdXMLExpTransObj3DTranslate*
>(pObj)->maTranslate.getX(),
true);
666 aNewString.append(aEmptySpace);
667 Imp_PutDoubleChar(aNewString, rConv,
static_cast<ImpSdXMLExpTransObj3DTranslate*
>(pObj)->maTranslate.getY(),
true);
668 aNewString.append(aEmptySpace);
669 Imp_PutDoubleChar(aNewString, rConv,
static_cast<ImpSdXMLExpTransObj3DTranslate*
>(pObj)->maTranslate.getZ(),
true);
670 aNewString.append(aClosingBrace);
675 aNewString.append(
"matrix (");
679 aNewString.append(aEmptySpace);
683 aNewString.append(aEmptySpace);
687 aNewString.append(aEmptySpace);
691 aNewString.append(aEmptySpace);
695 aNewString.append(aEmptySpace);
699 aNewString.append(aEmptySpace);
703 aNewString.append(aEmptySpace);
707 aNewString.append(aEmptySpace);
711 aNewString.append(aEmptySpace);
715 aNewString.append(aEmptySpace);
719 aNewString.append(aEmptySpace);
724 aNewString.append(aClosingBrace);
729 OSL_FAIL(
"SdXMLImExTransform3D: impossible entry!");
737 aNewString.append(aEmptySpace);
742 msString = aNewString.makeStringAndClear();
763 const sal_Int32 nLen(
aStr.getLength());
765 static constexpr OUStringLiteral aString_rotatex(
u"rotatex" );
766 static constexpr OUStringLiteral aString_rotatey(
u"rotatey" );
767 static constexpr OUStringLiteral aString_rotatez(
u"rotatez" );
768 static constexpr OUStringLiteral aString_scale(
u"scale" );
769 static constexpr OUStringLiteral aString_translate(
u"translate" );
770 static constexpr OUStringLiteral aString_matrix(
u"matrix" );
830 if(1.0 != aValue.
getX() || 1.0 != aValue.
getY() || 1.0 != aValue.
getZ())
831 maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DScale>(aValue));
848 maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DTranslate>(aValue));
908 maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DMatrix>(aValue));
946 rFullTrans.
rotate(
static_cast<ImpSdXMLExpTransObj3DRotateX*
>(pObj)->mfRotateX, 0.0, 0.0);
951 rFullTrans.
rotate(0.0,
static_cast<ImpSdXMLExpTransObj3DRotateY*
>(pObj)->mfRotateY, 0.0);
956 rFullTrans.
rotate(0.0, 0.0,
static_cast<ImpSdXMLExpTransObj3DRotateZ*
>(pObj)->mfRotateZ);
961 const ::basegfx::B3DTuple& rScale =
static_cast<ImpSdXMLExpTransObj3DScale*
>(pObj)->maScale;
962 rFullTrans.
scale(rScale.getX(), rScale.getY(), rScale.getZ());
967 const ::basegfx::B3DTuple& rTranslate =
static_cast<ImpSdXMLExpTransObj3DTranslate*
>(pObj)->maTranslate;
968 rFullTrans.
translate(rTranslate.getX(), rTranslate.getY(), rTranslate.getZ());
973 rFullTrans *=
static_cast<ImpSdXMLExpTransObj3DMatrix*
>(pObj)->
maMatrix;
978 OSL_FAIL(
"SdXMLImExTransform3D: impossible entry!");
995: msString(
std::move(aNew)),
1005 const sal_Int32 nLen(
aStr.getLength());
1036 OUString aNewString;
1037 OUString aEmptySpace(
" ");
1040 aNewString += aEmptySpace;
1043 aNewString += aEmptySpace;
1046 aNewString += aEmptySpace;
::basegfx::B2DHomMatrix maMatrix
const OUString & GetExportString()
SdXMLImExViewBox(double fX, double fY, double fW, double fH)
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
void convertDouble(OUStringBuffer &rBuffer, double fNumber) const
convert double number to string (using ::rtl::math) and DO convert to export MapUnit using meCoreMeas...
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
void rotate(double fRadiant)
void translate(double fX, double fY)
double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
void scale(double fX, double fY)
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
void rotate(double fAngleX, double fAngleY, double fAngleZ)
void translate(double fX, double fY, double fZ)
void scale(double fX, double fY, double fZ)
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
void B3DHomMatrixToUnoHomogenMatrix(const B3DHomMatrix &rMatrixIn, com::sun::star::drawing::HomogenMatrix &rMatrixOut)
B3DHomMatrix UnoHomogenMatrixToB3DHomMatrix(const com::sun::star::drawing::HomogenMatrix &rMatrixIn)
constexpr double rad2deg(double v)
constexpr double deg2rad(double v)
ImpSdXMLExpTransObj2DBase(sal_uInt16 nType)
ImpSdXMLExpTransObj3DBase(sal_uInt16 nType)
static void Imp_PutDoubleChar(OUString &rStr, double fValue)
static double Imp_GetDoubleChar(std::u16string_view rStr, sal_Int32 &rPos, const sal_Int32 nLen, const SvXMLUnitConverter &rConv, double fRetval, bool bLookForUnits=false)
#define IMP_SDXMLEXP_TRANSOBJ2D_ROTATE
static bool Imp_IsOnUnitChar(std::u16string_view rStr, const sal_Int32 nPos)
#define IMP_SDXMLEXP_TRANSOBJ2D_MATRIX
#define IMP_SDXMLEXP_TRANSOBJ2D_SKEWY
static void Imp_SkipSpacesAndOpeningBraces(std::u16string_view rStr, sal_Int32 &rPos, const sal_Int32 nLen)
static void Imp_SkipSpacesAndClosingBraces(std::u16string_view rStr, sal_Int32 &rPos, const sal_Int32 nLen)
#define IMP_SDXMLEXP_TRANSOBJ2D_SKEWX
#define IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Z
#define IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_X
#define IMP_SDXMLEXP_TRANSOBJ2D_TRANSLATE
static void Imp_SkipSpacesAndCommas(std::u16string_view rStr, sal_Int32 &rPos, const sal_Int32 nLen)
static void Imp_SkipSpaces(std::u16string_view rStr, sal_Int32 &rPos, const sal_Int32 nLen)
#define IMP_SDXMLEXP_TRANSOBJ2D_SCALE
#define IMP_SDXMLEXP_TRANSOBJ3D_MATRIX
#define IMP_SDXMLEXP_TRANSOBJ3D_TRANSLATE
#define IMP_SDXMLEXP_TRANSOBJ3D_SCALE
#define IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Y