xref: /trunk/main/xmloff/source/draw/xexptran.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
163bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
363bba73cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
463bba73cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
563bba73cSAndrew Rist  * distributed with this work for additional information
663bba73cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
763bba73cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
863bba73cSAndrew Rist  * "License"); you may not use this file except in compliance
963bba73cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
1163bba73cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
1363bba73cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1463bba73cSAndrew Rist  * software distributed under the License is distributed on an
1563bba73cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1663bba73cSAndrew Rist  * KIND, either express or implied.  See the License for the
1763bba73cSAndrew Rist  * specific language governing permissions and limitations
1863bba73cSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
2063bba73cSAndrew Rist  *************************************************************/
2163bba73cSAndrew Rist 
2263bba73cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir #include "xexptran.hxx"
27cdf0e10cSrcweir #include <tools/debug.hxx>
28cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
29cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
30cdf0e10cSrcweir #include <tools/gen.hxx>
31cdf0e10cSrcweir #include <basegfx/vector/b2dvector.hxx>
32cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
33cdf0e10cSrcweir #include <basegfx/tuple/b3dtuple.hxx>
34cdf0e10cSrcweir #include <basegfx/matrix/b3dhommatrix.hxx>
35*a8265799SRegina Henschel #include <basegfx/numeric/ftools.hxx>
36cdf0e10cSrcweir #include <tools/string.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir using ::rtl::OUString;
39cdf0e10cSrcweir using ::rtl::OUStringBuffer;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir using namespace ::com::sun::star;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
44cdf0e10cSrcweir // Defines
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #define BORDER_INTEGERS_ARE_EQUAL       (4)
47cdf0e10cSrcweir 
48cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
49cdf0e10cSrcweir // Predeclarations
50cdf0e10cSrcweir 
51cdf0e10cSrcweir void Imp_SkipDouble(const OUString& rStr, sal_Int32& rPos, const sal_Int32 nLen);
52cdf0e10cSrcweir void Imp_CalcVectorValues(::basegfx::B2DVector& aVec1, ::basegfx::B2DVector& aVec2, bool& bSameLength, bool& bSameDirection);
53cdf0e10cSrcweir 
54cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
55cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
56cdf0e10cSrcweir // parsing help functions for simple chars
Imp_SkipSpaces(const OUString & rStr,sal_Int32 & rPos,const sal_Int32 nLen)57cdf0e10cSrcweir void Imp_SkipSpaces(const OUString& rStr, sal_Int32& rPos, const sal_Int32 nLen)
58cdf0e10cSrcweir {
59cdf0e10cSrcweir     while(rPos < nLen
60cdf0e10cSrcweir         && sal_Unicode(' ') == rStr[rPos])
61cdf0e10cSrcweir         rPos++;
62cdf0e10cSrcweir }
63cdf0e10cSrcweir 
Imp_SkipSpacesAndOpeningBraces(const OUString & rStr,sal_Int32 & rPos,const sal_Int32 nLen)64cdf0e10cSrcweir void Imp_SkipSpacesAndOpeningBraces(const OUString& rStr, sal_Int32& rPos, const sal_Int32 nLen)
65cdf0e10cSrcweir {
66cdf0e10cSrcweir     while(rPos < nLen
67cdf0e10cSrcweir         && (sal_Unicode(' ') == rStr[rPos] || sal_Unicode('(') == rStr[rPos]))
68cdf0e10cSrcweir         rPos++;
69cdf0e10cSrcweir }
70cdf0e10cSrcweir 
Imp_SkipSpacesAndCommas(const OUString & rStr,sal_Int32 & rPos,const sal_Int32 nLen)71cdf0e10cSrcweir void Imp_SkipSpacesAndCommas(const OUString& rStr, sal_Int32& rPos, const sal_Int32 nLen)
72cdf0e10cSrcweir {
73cdf0e10cSrcweir     while(rPos < nLen
74cdf0e10cSrcweir         && (sal_Unicode(' ') == rStr[rPos] || sal_Unicode(',') == rStr[rPos]))
75cdf0e10cSrcweir         rPos++;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
Imp_SkipSpacesAndClosingBraces(const OUString & rStr,sal_Int32 & rPos,const sal_Int32 nLen)78cdf0e10cSrcweir void Imp_SkipSpacesAndClosingBraces(const OUString& rStr, sal_Int32& rPos, const sal_Int32 nLen)
79cdf0e10cSrcweir {
80cdf0e10cSrcweir     while(rPos < nLen
81cdf0e10cSrcweir         && (sal_Unicode(' ') == rStr[rPos] || sal_Unicode(')') == rStr[rPos]))
82cdf0e10cSrcweir         rPos++;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
86cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
87cdf0e10cSrcweir // parsing help functions for integer numbers
88cdf0e10cSrcweir 
Imp_IsOnNumberChar(const OUString & rStr,const sal_Int32 nPos,bool bSignAllowed=true)89cdf0e10cSrcweir bool Imp_IsOnNumberChar(const OUString& rStr, const sal_Int32 nPos, bool bSignAllowed = true)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir     sal_Unicode aChar(rStr[nPos]);
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     if((sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
94cdf0e10cSrcweir         || (bSignAllowed && sal_Unicode('+') == aChar)
95cdf0e10cSrcweir         || (bSignAllowed && sal_Unicode('-') == aChar)
96cdf0e10cSrcweir     )
97cdf0e10cSrcweir         return true;
98cdf0e10cSrcweir     return false;
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
Imp_IsOnUnitChar(const OUString & rStr,const sal_Int32 nPos)101cdf0e10cSrcweir bool Imp_IsOnUnitChar(const OUString& rStr, const sal_Int32 nPos)
102cdf0e10cSrcweir {
103cdf0e10cSrcweir     sal_Unicode aChar(rStr[nPos]);
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     if((sal_Unicode('a') <= aChar && sal_Unicode('z') >= aChar)
106cdf0e10cSrcweir         || (sal_Unicode('A') <= aChar && sal_Unicode('Z') >= aChar)
107cdf0e10cSrcweir         || sal_Unicode('%') == aChar
108cdf0e10cSrcweir     )
109cdf0e10cSrcweir         return true;
110cdf0e10cSrcweir     return false;
111cdf0e10cSrcweir }
112cdf0e10cSrcweir 
Imp_SkipNumber(const OUString & rStr,sal_Int32 & rPos,const sal_Int32 nLen)113cdf0e10cSrcweir void Imp_SkipNumber(const OUString& rStr, sal_Int32& rPos, const sal_Int32 nLen)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir     bool bSignAllowed(true);
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     while(rPos < nLen && Imp_IsOnNumberChar(rStr, rPos, bSignAllowed))
118cdf0e10cSrcweir     {
119cdf0e10cSrcweir         bSignAllowed = false;
120cdf0e10cSrcweir         rPos++;
121cdf0e10cSrcweir     }
122cdf0e10cSrcweir }
123cdf0e10cSrcweir 
Imp_SkipNumberAndSpacesAndCommas(const OUString & rStr,sal_Int32 & rPos,const sal_Int32 nLen)124cdf0e10cSrcweir void Imp_SkipNumberAndSpacesAndCommas(const OUString& rStr, sal_Int32& rPos,
125cdf0e10cSrcweir     const sal_Int32 nLen)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     Imp_SkipNumber(rStr, rPos, nLen);
128cdf0e10cSrcweir     Imp_SkipSpacesAndCommas(rStr, rPos, nLen);
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir // #100617# Allow to skip doubles, too.
Imp_SkipDoubleAndSpacesAndCommas(const OUString & rStr,sal_Int32 & rPos,const sal_Int32 nLen)132cdf0e10cSrcweir void Imp_SkipDoubleAndSpacesAndCommas(const OUString& rStr, sal_Int32& rPos,
133cdf0e10cSrcweir     const sal_Int32 nLen)
134cdf0e10cSrcweir {
135cdf0e10cSrcweir     Imp_SkipDouble(rStr, rPos, nLen);
136cdf0e10cSrcweir     Imp_SkipSpacesAndCommas(rStr, rPos, nLen);
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
Imp_PutNumberChar(OUString & rStr,sal_Int32 nValue)139cdf0e10cSrcweir void Imp_PutNumberChar(OUString& rStr, sal_Int32 nValue)
140cdf0e10cSrcweir {
141cdf0e10cSrcweir     OUStringBuffer sStringBuffer;
142cdf0e10cSrcweir     SvXMLUnitConverter::convertNumber(sStringBuffer, nValue);
143cdf0e10cSrcweir     rStr += OUString(sStringBuffer.makeStringAndClear());
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
Imp_PutNumberCharWithSpace(OUString & rStr,sal_Int32 nValue)146cdf0e10cSrcweir void Imp_PutNumberCharWithSpace(OUString& rStr, sal_Int32 nValue)
147cdf0e10cSrcweir {
148cdf0e10cSrcweir     const sal_Int32 aLen(rStr.getLength());
149cdf0e10cSrcweir     if(aLen)
150cdf0e10cSrcweir         if(Imp_IsOnNumberChar(rStr, aLen - 1, false) && nValue >= 0)
151cdf0e10cSrcweir             rStr += String(sal_Unicode(' '));
152cdf0e10cSrcweir     Imp_PutNumberChar(rStr, nValue);
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
155cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
156cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
157cdf0e10cSrcweir // parsing help functions for double numbers
158cdf0e10cSrcweir 
Imp_SkipDouble(const OUString & rStr,sal_Int32 & rPos,const sal_Int32)159cdf0e10cSrcweir void Imp_SkipDouble(const OUString& rStr, sal_Int32& rPos, const sal_Int32)
160cdf0e10cSrcweir {
161cdf0e10cSrcweir     sal_Unicode aChar(rStr[rPos]);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar)
164cdf0e10cSrcweir         aChar = rStr[++rPos];
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     while((sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
167cdf0e10cSrcweir         || sal_Unicode('.') == aChar)
168cdf0e10cSrcweir     {
169cdf0e10cSrcweir         aChar = rStr[++rPos];
170cdf0e10cSrcweir     }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir     if(sal_Unicode('e') == aChar || sal_Unicode('E') == aChar)
173cdf0e10cSrcweir     {
174cdf0e10cSrcweir         aChar = rStr[++rPos];
175cdf0e10cSrcweir 
176cdf0e10cSrcweir         if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar)
177cdf0e10cSrcweir             aChar = rStr[++rPos];
178cdf0e10cSrcweir 
179cdf0e10cSrcweir         while(sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
180cdf0e10cSrcweir         {
181cdf0e10cSrcweir             aChar = rStr[++rPos];
182cdf0e10cSrcweir         }
183cdf0e10cSrcweir     }
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
Imp_GetDoubleChar(const OUString & rStr,sal_Int32 & rPos,const sal_Int32 nLen,const SvXMLUnitConverter & rConv,double fRetval,bool bLookForUnits=false)186cdf0e10cSrcweir double Imp_GetDoubleChar(const OUString& rStr, sal_Int32& rPos, const sal_Int32 nLen,
187cdf0e10cSrcweir     const SvXMLUnitConverter& rConv, double fRetval, bool bLookForUnits = false)
188cdf0e10cSrcweir {
189cdf0e10cSrcweir     sal_Unicode aChar(rStr[rPos]);
190cdf0e10cSrcweir     OUStringBuffer sNumberString;
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar)
193cdf0e10cSrcweir     {
194cdf0e10cSrcweir         sNumberString.append(rStr[rPos]);
195cdf0e10cSrcweir         aChar = rStr[++rPos];
196cdf0e10cSrcweir     }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     while((sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
199cdf0e10cSrcweir         || sal_Unicode('.') == aChar)
200cdf0e10cSrcweir     {
201cdf0e10cSrcweir         sNumberString.append(rStr[rPos]);
202cdf0e10cSrcweir         aChar = rStr[++rPos];
203cdf0e10cSrcweir     }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     if(sal_Unicode('e') == aChar || sal_Unicode('E') == aChar)
206cdf0e10cSrcweir     {
207cdf0e10cSrcweir         sNumberString.append(rStr[rPos]);
208cdf0e10cSrcweir         aChar = rStr[++rPos];
209cdf0e10cSrcweir 
210cdf0e10cSrcweir         if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar)
211cdf0e10cSrcweir         {
212cdf0e10cSrcweir             sNumberString.append(rStr[rPos]);
213cdf0e10cSrcweir             aChar = rStr[++rPos];
214cdf0e10cSrcweir         }
215cdf0e10cSrcweir 
216cdf0e10cSrcweir         while(sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
217cdf0e10cSrcweir         {
218cdf0e10cSrcweir             sNumberString.append(rStr[rPos]);
219cdf0e10cSrcweir             aChar = rStr[++rPos];
220cdf0e10cSrcweir         }
221cdf0e10cSrcweir     }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir     if(bLookForUnits)
224cdf0e10cSrcweir     {
225cdf0e10cSrcweir         Imp_SkipSpaces(rStr, rPos, nLen);
226cdf0e10cSrcweir         while(rPos < nLen && Imp_IsOnUnitChar(rStr, rPos))
227cdf0e10cSrcweir             sNumberString.append(rStr[rPos++]);
228cdf0e10cSrcweir     }
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     if(sNumberString.getLength())
231cdf0e10cSrcweir     {
232cdf0e10cSrcweir         if(bLookForUnits)
233cdf0e10cSrcweir             rConv.convertDouble(fRetval, sNumberString.makeStringAndClear(), true);
234cdf0e10cSrcweir         else
235cdf0e10cSrcweir             rConv.convertDouble(fRetval, sNumberString.makeStringAndClear());
236cdf0e10cSrcweir     }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir     return fRetval;
239cdf0e10cSrcweir }
240cdf0e10cSrcweir 
Imp_PutDoubleChar(OUString & rStr,double fValue)2411f882ec4SArmin Le Grand void Imp_PutDoubleChar(OUString& rStr, double fValue)
2421f882ec4SArmin Le Grand {
2431f882ec4SArmin Le Grand     OUStringBuffer sStringBuffer;
2441f882ec4SArmin Le Grand     SvXMLUnitConverter::convertDouble(sStringBuffer, fValue);
2451f882ec4SArmin Le Grand     rStr += OUString(sStringBuffer.makeStringAndClear());
2461f882ec4SArmin Le Grand }
2471f882ec4SArmin Le Grand 
Imp_PutDoubleChar(OUString & rStr,const SvXMLUnitConverter & rConv,double fValue,bool bConvertUnits=false)248cdf0e10cSrcweir void Imp_PutDoubleChar(OUString& rStr, const SvXMLUnitConverter& rConv, double fValue,
249cdf0e10cSrcweir     bool bConvertUnits = false)
250cdf0e10cSrcweir {
251cdf0e10cSrcweir     OUStringBuffer sStringBuffer;
252cdf0e10cSrcweir 
253cdf0e10cSrcweir     if(bConvertUnits)
254cdf0e10cSrcweir         rConv.convertDouble(sStringBuffer, fValue, true);
255cdf0e10cSrcweir     else
256cdf0e10cSrcweir         rConv.convertDouble(sStringBuffer, fValue);
257cdf0e10cSrcweir 
258cdf0e10cSrcweir     rStr += OUString(sStringBuffer.makeStringAndClear());
259cdf0e10cSrcweir }
260cdf0e10cSrcweir 
261cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
262cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
263cdf0e10cSrcweir // base class of all 2D transform objects
264cdf0e10cSrcweir 
265cdf0e10cSrcweir struct ImpSdXMLExpTransObj2DBase
266cdf0e10cSrcweir {
267cdf0e10cSrcweir     sal_uInt16                  mnType;
ImpSdXMLExpTransObj2DBaseImpSdXMLExpTransObj2DBase268cdf0e10cSrcweir     ImpSdXMLExpTransObj2DBase(sal_uInt16 nType)
269cdf0e10cSrcweir     :   mnType(nType) {}
270cdf0e10cSrcweir };
271cdf0e10cSrcweir 
272cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
273cdf0e10cSrcweir // possible object types for 2D
274cdf0e10cSrcweir 
275cdf0e10cSrcweir #define IMP_SDXMLEXP_TRANSOBJ2D_ROTATE          0x0000
276cdf0e10cSrcweir #define IMP_SDXMLEXP_TRANSOBJ2D_SCALE           0x0001
277cdf0e10cSrcweir #define IMP_SDXMLEXP_TRANSOBJ2D_TRANSLATE       0x0002
278cdf0e10cSrcweir #define IMP_SDXMLEXP_TRANSOBJ2D_SKEWX           0x0003
279cdf0e10cSrcweir #define IMP_SDXMLEXP_TRANSOBJ2D_SKEWY           0x0004
280cdf0e10cSrcweir #define IMP_SDXMLEXP_TRANSOBJ2D_MATRIX          0x0005
281cdf0e10cSrcweir 
282cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
283cdf0e10cSrcweir // classes of objects, different sizes
284cdf0e10cSrcweir 
285cdf0e10cSrcweir struct ImpSdXMLExpTransObj2DRotate : public ImpSdXMLExpTransObj2DBase
286cdf0e10cSrcweir {
287cdf0e10cSrcweir     double                      mfRotate;
ImpSdXMLExpTransObj2DRotateImpSdXMLExpTransObj2DRotate288cdf0e10cSrcweir     ImpSdXMLExpTransObj2DRotate(double fVal)
289cdf0e10cSrcweir     :   ImpSdXMLExpTransObj2DBase(IMP_SDXMLEXP_TRANSOBJ2D_ROTATE), mfRotate(fVal) {}
290cdf0e10cSrcweir };
291cdf0e10cSrcweir struct ImpSdXMLExpTransObj2DScale : public ImpSdXMLExpTransObj2DBase
292cdf0e10cSrcweir {
293cdf0e10cSrcweir     ::basegfx::B2DTuple         maScale;
ImpSdXMLExpTransObj2DScaleImpSdXMLExpTransObj2DScale294cdf0e10cSrcweir     ImpSdXMLExpTransObj2DScale(const ::basegfx::B2DTuple& rNew)
295cdf0e10cSrcweir     :   ImpSdXMLExpTransObj2DBase(IMP_SDXMLEXP_TRANSOBJ2D_SCALE), maScale(rNew) {}
296cdf0e10cSrcweir };
297cdf0e10cSrcweir struct ImpSdXMLExpTransObj2DTranslate : public ImpSdXMLExpTransObj2DBase
298cdf0e10cSrcweir {
299cdf0e10cSrcweir     ::basegfx::B2DTuple         maTranslate;
ImpSdXMLExpTransObj2DTranslateImpSdXMLExpTransObj2DTranslate300cdf0e10cSrcweir     ImpSdXMLExpTransObj2DTranslate(const ::basegfx::B2DTuple& rNew)
301cdf0e10cSrcweir     :   ImpSdXMLExpTransObj2DBase(IMP_SDXMLEXP_TRANSOBJ2D_TRANSLATE), maTranslate(rNew) {}
302cdf0e10cSrcweir };
303cdf0e10cSrcweir struct ImpSdXMLExpTransObj2DSkewX : public ImpSdXMLExpTransObj2DBase
304cdf0e10cSrcweir {
305cdf0e10cSrcweir     double                      mfSkewX;
ImpSdXMLExpTransObj2DSkewXImpSdXMLExpTransObj2DSkewX306cdf0e10cSrcweir     ImpSdXMLExpTransObj2DSkewX(double fVal)
307cdf0e10cSrcweir     :   ImpSdXMLExpTransObj2DBase(IMP_SDXMLEXP_TRANSOBJ2D_SKEWX), mfSkewX(fVal) {}
308cdf0e10cSrcweir };
309cdf0e10cSrcweir struct ImpSdXMLExpTransObj2DSkewY : public ImpSdXMLExpTransObj2DBase
310cdf0e10cSrcweir {
311cdf0e10cSrcweir     double                      mfSkewY;
ImpSdXMLExpTransObj2DSkewYImpSdXMLExpTransObj2DSkewY312cdf0e10cSrcweir     ImpSdXMLExpTransObj2DSkewY(double fVal)
313cdf0e10cSrcweir     :   ImpSdXMLExpTransObj2DBase(IMP_SDXMLEXP_TRANSOBJ2D_SKEWY), mfSkewY(fVal) {}
314cdf0e10cSrcweir };
315cdf0e10cSrcweir struct ImpSdXMLExpTransObj2DMatrix : public ImpSdXMLExpTransObj2DBase
316cdf0e10cSrcweir {
317cdf0e10cSrcweir     ::basegfx::B2DHomMatrix     maMatrix;
ImpSdXMLExpTransObj2DMatrixImpSdXMLExpTransObj2DMatrix318cdf0e10cSrcweir     ImpSdXMLExpTransObj2DMatrix(const ::basegfx::B2DHomMatrix& rNew)
319cdf0e10cSrcweir     :   ImpSdXMLExpTransObj2DBase(IMP_SDXMLEXP_TRANSOBJ2D_MATRIX), maMatrix(rNew) {}
320cdf0e10cSrcweir };
321cdf0e10cSrcweir 
322cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
323cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
324cdf0e10cSrcweir // delete all entries in list
325cdf0e10cSrcweir 
EmptyList()326cdf0e10cSrcweir void SdXMLImExTransform2D::EmptyList()
327cdf0e10cSrcweir {
328cdf0e10cSrcweir     const sal_uInt32 nCount = maList.size();
329cdf0e10cSrcweir     for(sal_uInt32 a(0L); a < nCount; a++)
330cdf0e10cSrcweir     {
331cdf0e10cSrcweir         ImpSdXMLExpTransObj2DBase* pObj = maList[a];
332cdf0e10cSrcweir 
333cdf0e10cSrcweir         switch(pObj->mnType)
334cdf0e10cSrcweir         {
335cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_ROTATE     :
336cdf0e10cSrcweir             {
337cdf0e10cSrcweir                 delete (ImpSdXMLExpTransObj2DRotate*)pObj;
338cdf0e10cSrcweir                 break;
339cdf0e10cSrcweir             }
340cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_SCALE      :
341cdf0e10cSrcweir             {
342cdf0e10cSrcweir                 delete (ImpSdXMLExpTransObj2DScale*)pObj;
343cdf0e10cSrcweir                 break;
344cdf0e10cSrcweir             }
345cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_TRANSLATE  :
346cdf0e10cSrcweir             {
347cdf0e10cSrcweir                 delete (ImpSdXMLExpTransObj2DTranslate*)pObj;
348cdf0e10cSrcweir                 break;
349cdf0e10cSrcweir             }
350cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_SKEWX      :
351cdf0e10cSrcweir             {
352cdf0e10cSrcweir                 delete (ImpSdXMLExpTransObj2DSkewX*)pObj;
353cdf0e10cSrcweir                 break;
354cdf0e10cSrcweir             }
355cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_SKEWY      :
356cdf0e10cSrcweir             {
357cdf0e10cSrcweir                 delete (ImpSdXMLExpTransObj2DSkewY*)pObj;
358cdf0e10cSrcweir                 break;
359cdf0e10cSrcweir             }
360cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_MATRIX     :
361cdf0e10cSrcweir             {
362cdf0e10cSrcweir                 delete (ImpSdXMLExpTransObj2DMatrix*)pObj;
363cdf0e10cSrcweir                 break;
364cdf0e10cSrcweir             }
365cdf0e10cSrcweir             default :
366cdf0e10cSrcweir             {
367cdf0e10cSrcweir                 DBG_ERROR("SdXMLImExTransform2D: impossible entry!");
368cdf0e10cSrcweir                 break;
369cdf0e10cSrcweir             }
370cdf0e10cSrcweir         }
371cdf0e10cSrcweir     }
372cdf0e10cSrcweir 
373cdf0e10cSrcweir     maList.clear();
374cdf0e10cSrcweir }
375cdf0e10cSrcweir 
376cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
377cdf0e10cSrcweir // add members
378cdf0e10cSrcweir 
AddRotate(double fNew)379cdf0e10cSrcweir void SdXMLImExTransform2D::AddRotate(double fNew)
380cdf0e10cSrcweir {
381cdf0e10cSrcweir     if(fNew != 0.0)
382cdf0e10cSrcweir         maList.push_back(new ImpSdXMLExpTransObj2DRotate(fNew));
383cdf0e10cSrcweir }
384cdf0e10cSrcweir 
AddScale(const::basegfx::B2DTuple & rNew)385cdf0e10cSrcweir void SdXMLImExTransform2D::AddScale(const ::basegfx::B2DTuple& rNew)
386cdf0e10cSrcweir {
387cdf0e10cSrcweir     if(1.0 != rNew.getX() || 1.0 != rNew.getY())
388cdf0e10cSrcweir         maList.push_back(new ImpSdXMLExpTransObj2DScale(rNew));
389cdf0e10cSrcweir }
390cdf0e10cSrcweir 
AddTranslate(const::basegfx::B2DTuple & rNew)391cdf0e10cSrcweir void SdXMLImExTransform2D::AddTranslate(const ::basegfx::B2DTuple& rNew)
392cdf0e10cSrcweir {
393cdf0e10cSrcweir     if(!rNew.equalZero())
394cdf0e10cSrcweir         maList.push_back(new ImpSdXMLExpTransObj2DTranslate(rNew));
395cdf0e10cSrcweir }
396cdf0e10cSrcweir 
AddSkewX(double fNew)397cdf0e10cSrcweir void SdXMLImExTransform2D::AddSkewX(double fNew)
398cdf0e10cSrcweir {
399cdf0e10cSrcweir     if(fNew != 0.0)
400cdf0e10cSrcweir         maList.push_back(new ImpSdXMLExpTransObj2DSkewX(fNew));
401cdf0e10cSrcweir }
402cdf0e10cSrcweir 
AddSkewY(double fNew)403cdf0e10cSrcweir void SdXMLImExTransform2D::AddSkewY(double fNew)
404cdf0e10cSrcweir {
405cdf0e10cSrcweir     if(fNew != 0.0)
406cdf0e10cSrcweir         maList.push_back(new ImpSdXMLExpTransObj2DSkewY(fNew));
407cdf0e10cSrcweir }
408cdf0e10cSrcweir 
AddMatrix(const::basegfx::B2DHomMatrix & rNew)409cdf0e10cSrcweir void SdXMLImExTransform2D::AddMatrix(const ::basegfx::B2DHomMatrix& rNew)
410cdf0e10cSrcweir {
411cdf0e10cSrcweir     if(!rNew.isIdentity())
412cdf0e10cSrcweir         maList.push_back(new ImpSdXMLExpTransObj2DMatrix(rNew));
413cdf0e10cSrcweir }
414cdf0e10cSrcweir 
415cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
416cdf0e10cSrcweir // gen string for export
GetExportString(const SvXMLUnitConverter & rConv)417cdf0e10cSrcweir const OUString& SdXMLImExTransform2D::GetExportString(const SvXMLUnitConverter& rConv)
418cdf0e10cSrcweir {
419cdf0e10cSrcweir     OUString aNewString;
420cdf0e10cSrcweir     OUString aClosingBrace(sal_Unicode(')'));
421cdf0e10cSrcweir     OUString aEmptySpace(sal_Unicode(' '));
422cdf0e10cSrcweir 
423cdf0e10cSrcweir     const sal_uInt32 nCount = maList.size();
424cdf0e10cSrcweir     for(sal_uInt32 a(0L); a < nCount; a++)
425cdf0e10cSrcweir     {
426cdf0e10cSrcweir         ImpSdXMLExpTransObj2DBase* pObj = maList[a];
427cdf0e10cSrcweir         switch(pObj->mnType)
428cdf0e10cSrcweir         {
429cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_ROTATE :
430cdf0e10cSrcweir             {
431cdf0e10cSrcweir                 aNewString += OUString::createFromAscii("rotate (");
432cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj2DRotate*)pObj)->mfRotate);
433cdf0e10cSrcweir                 aNewString += aClosingBrace;
434cdf0e10cSrcweir                 break;
435cdf0e10cSrcweir             }
436cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_SCALE      :
437cdf0e10cSrcweir             {
438cdf0e10cSrcweir                 aNewString += OUString::createFromAscii("scale (");
439cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj2DScale*)pObj)->maScale.getX());
440cdf0e10cSrcweir                 aNewString += aEmptySpace;
441cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj2DScale*)pObj)->maScale.getY());
442cdf0e10cSrcweir                 aNewString += aClosingBrace;
443cdf0e10cSrcweir                 break;
444cdf0e10cSrcweir             }
445cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_TRANSLATE  :
446cdf0e10cSrcweir             {
447cdf0e10cSrcweir                 aNewString += OUString::createFromAscii("translate (");
448cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj2DTranslate*)pObj)->maTranslate.getX(), true);
449cdf0e10cSrcweir                 aNewString += aEmptySpace;
450cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj2DTranslate*)pObj)->maTranslate.getY(), true);
451cdf0e10cSrcweir                 aNewString += aClosingBrace;
452cdf0e10cSrcweir                 break;
453cdf0e10cSrcweir             }
454cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_SKEWX      :
455cdf0e10cSrcweir             {
456cdf0e10cSrcweir                 aNewString += OUString::createFromAscii("skewX (");
457cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj2DSkewX*)pObj)->mfSkewX);
458cdf0e10cSrcweir                 aNewString += aClosingBrace;
459cdf0e10cSrcweir                 break;
460cdf0e10cSrcweir             }
461cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_SKEWY      :
462cdf0e10cSrcweir             {
463cdf0e10cSrcweir                 aNewString += OUString::createFromAscii("skewY (");
464cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj2DSkewY*)pObj)->mfSkewY);
465cdf0e10cSrcweir                 aNewString += aClosingBrace;
466cdf0e10cSrcweir                 break;
467cdf0e10cSrcweir             }
468cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_MATRIX :
469cdf0e10cSrcweir             {
470cdf0e10cSrcweir                 aNewString += OUString::createFromAscii("matrix (");
471cdf0e10cSrcweir 
472cdf0e10cSrcweir                 // a
473cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj2DMatrix*)pObj)->maMatrix.get(0, 0));
474cdf0e10cSrcweir                 aNewString += aEmptySpace;
475cdf0e10cSrcweir 
476cdf0e10cSrcweir                 // b
477cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj2DMatrix*)pObj)->maMatrix.get(1, 0));
478cdf0e10cSrcweir                 aNewString += aEmptySpace;
479cdf0e10cSrcweir 
480cdf0e10cSrcweir                 // c
481cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj2DMatrix*)pObj)->maMatrix.get(0, 1));
482cdf0e10cSrcweir                 aNewString += aEmptySpace;
483cdf0e10cSrcweir 
484cdf0e10cSrcweir                 // d
485cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj2DMatrix*)pObj)->maMatrix.get(1, 1));
486cdf0e10cSrcweir                 aNewString += aEmptySpace;
487cdf0e10cSrcweir 
488cdf0e10cSrcweir                 // e
489cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj2DMatrix*)pObj)->maMatrix.get(0, 2), true);
490cdf0e10cSrcweir                 aNewString += aEmptySpace;
491cdf0e10cSrcweir 
492cdf0e10cSrcweir                 // f
493cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj2DMatrix*)pObj)->maMatrix.get(1, 2), true);
494cdf0e10cSrcweir 
495cdf0e10cSrcweir                 aNewString += aClosingBrace;
496cdf0e10cSrcweir                 break;
497cdf0e10cSrcweir             }
498cdf0e10cSrcweir             default :
499cdf0e10cSrcweir             {
500cdf0e10cSrcweir                 DBG_ERROR("SdXMLImExTransform2D: impossible entry!");
501cdf0e10cSrcweir                 break;
502cdf0e10cSrcweir             }
503cdf0e10cSrcweir         }
504cdf0e10cSrcweir 
505cdf0e10cSrcweir         // if not the last entry, add one space to next tag
506cdf0e10cSrcweir         if(a + 1UL != maList.size())
507cdf0e10cSrcweir         {
508cdf0e10cSrcweir             aNewString += aEmptySpace;
509cdf0e10cSrcweir         }
510cdf0e10cSrcweir     }
511cdf0e10cSrcweir 
512cdf0e10cSrcweir     // fill string form OUString
513cdf0e10cSrcweir     msString = aNewString;
514cdf0e10cSrcweir 
515cdf0e10cSrcweir     return msString;
516cdf0e10cSrcweir }
517cdf0e10cSrcweir 
518cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
519cdf0e10cSrcweir // for Import: constructor with string, parses it and generates entries
SdXMLImExTransform2D(const OUString & rNew,const SvXMLUnitConverter & rConv)520cdf0e10cSrcweir SdXMLImExTransform2D::SdXMLImExTransform2D(const OUString& rNew, const SvXMLUnitConverter& rConv)
521cdf0e10cSrcweir {
522cdf0e10cSrcweir     SetString(rNew, rConv);
523cdf0e10cSrcweir }
524cdf0e10cSrcweir 
525cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
526cdf0e10cSrcweir // sets new string, parses it and generates entries
SetString(const OUString & rNew,const SvXMLUnitConverter & rConv)527cdf0e10cSrcweir void SdXMLImExTransform2D::SetString(const OUString& rNew, const SvXMLUnitConverter& rConv)
528cdf0e10cSrcweir {
529cdf0e10cSrcweir     msString = rNew;
530cdf0e10cSrcweir     EmptyList();
531cdf0e10cSrcweir 
532cdf0e10cSrcweir     if(msString.getLength())
533cdf0e10cSrcweir     {
534cdf0e10cSrcweir         const OUString aStr(msString.getStr(), (sal_uInt16)msString.getLength());
535cdf0e10cSrcweir         const sal_Int32 nLen(aStr.getLength());
536cdf0e10cSrcweir 
537cdf0e10cSrcweir         const OUString aString_rotate(OUString::createFromAscii("rotate"));
538cdf0e10cSrcweir         const OUString aString_scale(OUString::createFromAscii("scale"));
539cdf0e10cSrcweir         const OUString aString_translate(OUString::createFromAscii("translate"));
540cdf0e10cSrcweir         const OUString aString_skewX(OUString::createFromAscii("skewX"));
541cdf0e10cSrcweir         const OUString aString_skewY(OUString::createFromAscii("skewY"));
542cdf0e10cSrcweir         const OUString aString_matrix(OUString::createFromAscii("matrix"));
543cdf0e10cSrcweir 
544cdf0e10cSrcweir         sal_Int32 nPos(0);
545cdf0e10cSrcweir 
546cdf0e10cSrcweir         while(nPos < nLen)
547cdf0e10cSrcweir         {
548cdf0e10cSrcweir             // skip spaces
549cdf0e10cSrcweir             Imp_SkipSpaces(aStr, nPos, nLen);
550cdf0e10cSrcweir 
551cdf0e10cSrcweir             // look for tag
552cdf0e10cSrcweir             if(nPos < nLen)
553cdf0e10cSrcweir             {
554cdf0e10cSrcweir                 if(nPos == aStr.indexOf(aString_rotate, nPos))
555cdf0e10cSrcweir                 {
556cdf0e10cSrcweir                     double fValue(0.0);
557cdf0e10cSrcweir                     nPos += 6;
558cdf0e10cSrcweir                     Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
559cdf0e10cSrcweir                     fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue);
560cdf0e10cSrcweir                     if(fValue != 0.0)
561cdf0e10cSrcweir                         maList.push_back(new ImpSdXMLExpTransObj2DRotate(fValue));
562cdf0e10cSrcweir 
563cdf0e10cSrcweir                     Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
564cdf0e10cSrcweir                 }
565cdf0e10cSrcweir                 else if(nPos == aStr.indexOf(aString_scale, nPos))
566cdf0e10cSrcweir                 {
567cdf0e10cSrcweir                     ::basegfx::B2DTuple aValue(1.0, 1.0);
568cdf0e10cSrcweir                     nPos += 5;
569cdf0e10cSrcweir                     Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
570cdf0e10cSrcweir                     aValue.setX(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getX()));
571cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
572cdf0e10cSrcweir                     aValue.setY(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getY()));
573cdf0e10cSrcweir 
574cdf0e10cSrcweir                     if(aValue.getX() != 1.0 || aValue.getY() != 1.0)
575cdf0e10cSrcweir                         maList.push_back(new ImpSdXMLExpTransObj2DScale(aValue));
576cdf0e10cSrcweir 
577cdf0e10cSrcweir                     Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
578cdf0e10cSrcweir                 }
579cdf0e10cSrcweir                 else if(nPos == aStr.indexOf(aString_translate, nPos))
580cdf0e10cSrcweir                 {
581cdf0e10cSrcweir                     ::basegfx::B2DTuple aValue;
582cdf0e10cSrcweir                     nPos += 9;
583cdf0e10cSrcweir                     Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
584cdf0e10cSrcweir                     aValue.setX(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getX(), true));
585cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
586cdf0e10cSrcweir                     aValue.setY(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getY(), true));
587cdf0e10cSrcweir 
588cdf0e10cSrcweir                     if(!aValue.equalZero())
589cdf0e10cSrcweir                         maList.push_back(new ImpSdXMLExpTransObj2DTranslate(aValue));
590cdf0e10cSrcweir 
591cdf0e10cSrcweir                     Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
592cdf0e10cSrcweir                 }
593cdf0e10cSrcweir                 else if(nPos == aStr.indexOf(aString_skewX, nPos))
594cdf0e10cSrcweir                 {
595cdf0e10cSrcweir                     double fValue(0.0);
596cdf0e10cSrcweir                     nPos += 5;
597cdf0e10cSrcweir                     Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
598cdf0e10cSrcweir                     fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue);
599cdf0e10cSrcweir                     if(fValue != 0.0)
600cdf0e10cSrcweir                         maList.push_back(new ImpSdXMLExpTransObj2DSkewX(fValue));
601cdf0e10cSrcweir 
602cdf0e10cSrcweir                     Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
603cdf0e10cSrcweir                 }
604cdf0e10cSrcweir                 else if(nPos == aStr.indexOf(aString_skewY, nPos))
605cdf0e10cSrcweir                 {
606cdf0e10cSrcweir                     double fValue(0.0);
607cdf0e10cSrcweir                     nPos += 5;
608cdf0e10cSrcweir                     Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
609cdf0e10cSrcweir                     fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue);
610cdf0e10cSrcweir                     if(fValue != 0.0)
611cdf0e10cSrcweir                         maList.push_back(new ImpSdXMLExpTransObj2DSkewY(fValue));
612cdf0e10cSrcweir 
613cdf0e10cSrcweir                     Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
614cdf0e10cSrcweir                 }
615cdf0e10cSrcweir                 else if(nPos == aStr.indexOf(aString_matrix, nPos))
616cdf0e10cSrcweir                 {
617cdf0e10cSrcweir                     ::basegfx::B2DHomMatrix aValue;
618cdf0e10cSrcweir 
619cdf0e10cSrcweir                     nPos += 6;
620cdf0e10cSrcweir                     Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
621cdf0e10cSrcweir 
622cdf0e10cSrcweir                     // a
623cdf0e10cSrcweir                     aValue.set(0, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 0)));
624cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
625cdf0e10cSrcweir 
626cdf0e10cSrcweir                     // b
627cdf0e10cSrcweir                     aValue.set(1, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 0)));
628cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
629cdf0e10cSrcweir 
630cdf0e10cSrcweir                     // c
631cdf0e10cSrcweir                     aValue.set(0, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 1)));
632cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
633cdf0e10cSrcweir 
634cdf0e10cSrcweir                     // d
635cdf0e10cSrcweir                     aValue.set(1, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 1)));
636cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
637cdf0e10cSrcweir 
638cdf0e10cSrcweir                     // e
639cdf0e10cSrcweir                     aValue.set(0, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 2), true));
640cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
641cdf0e10cSrcweir 
642cdf0e10cSrcweir                     // f
643cdf0e10cSrcweir                     aValue.set(1, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 2), true));
644cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
645cdf0e10cSrcweir 
646cdf0e10cSrcweir                     if(!aValue.isIdentity())
647cdf0e10cSrcweir                         maList.push_back(new ImpSdXMLExpTransObj2DMatrix(aValue));
648cdf0e10cSrcweir 
649cdf0e10cSrcweir                     Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
650cdf0e10cSrcweir                 }
651cdf0e10cSrcweir                 else
652cdf0e10cSrcweir                 {
653cdf0e10cSrcweir                     nPos++;
654cdf0e10cSrcweir                 }
655cdf0e10cSrcweir             }
656cdf0e10cSrcweir         }
657cdf0e10cSrcweir     }
658cdf0e10cSrcweir }
659cdf0e10cSrcweir 
GetFullTransform(::basegfx::B2DHomMatrix & rFullTrans)660cdf0e10cSrcweir void SdXMLImExTransform2D::GetFullTransform(::basegfx::B2DHomMatrix& rFullTrans)
661cdf0e10cSrcweir {
662cdf0e10cSrcweir     rFullTrans.identity();
663cdf0e10cSrcweir 
664cdf0e10cSrcweir     const sal_uInt32 nCount = maList.size();
665cdf0e10cSrcweir     for(sal_uInt32 a(0L); a < nCount; a++)
666cdf0e10cSrcweir     {
667cdf0e10cSrcweir         ImpSdXMLExpTransObj2DBase* pObj = maList[a];
668cdf0e10cSrcweir         switch(pObj->mnType)
669cdf0e10cSrcweir         {
670cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_ROTATE     :
671cdf0e10cSrcweir             {
672cdf0e10cSrcweir                 // #i78696#
673cdf0e10cSrcweir                 // mfRotate is mathematically wrong oriented since we export/import the angle
674cdf0e10cSrcweir                 // values mirrored. This error is fixed in the API, but not yet in the FileFormat.
675cdf0e10cSrcweir                 // For the FileFormat there is a follow-up task (#i78698#) to fix this in the next
676cdf0e10cSrcweir                 // ODF FileFormat version. For now - to emulate the old behaviour - it is necessary
677cdf0e10cSrcweir                 // to mirror the value here
678cdf0e10cSrcweir                 rFullTrans.rotate(((ImpSdXMLExpTransObj2DRotate*)pObj)->mfRotate * -1.0);
679cdf0e10cSrcweir                 break;
680cdf0e10cSrcweir             }
681cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_SCALE      :
682cdf0e10cSrcweir             {
683cdf0e10cSrcweir                 const ::basegfx::B2DTuple& rScale = ((ImpSdXMLExpTransObj2DScale*)pObj)->maScale;
684cdf0e10cSrcweir                 rFullTrans.scale(rScale.getX(), rScale.getY());
685cdf0e10cSrcweir                 break;
686cdf0e10cSrcweir             }
687cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_TRANSLATE  :
688cdf0e10cSrcweir             {
689cdf0e10cSrcweir                 const ::basegfx::B2DTuple& rTranslate = ((ImpSdXMLExpTransObj2DTranslate*)pObj)->maTranslate;
690cdf0e10cSrcweir                 rFullTrans.translate(rTranslate.getX(), rTranslate.getY());
691cdf0e10cSrcweir                 break;
692cdf0e10cSrcweir             }
693cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_SKEWX      :
694cdf0e10cSrcweir             {
695cdf0e10cSrcweir                 rFullTrans.shearX(tan(((ImpSdXMLExpTransObj2DSkewX*)pObj)->mfSkewX));
696cdf0e10cSrcweir                 break;
697cdf0e10cSrcweir             }
698cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_SKEWY      :
699cdf0e10cSrcweir             {
700cdf0e10cSrcweir                 rFullTrans.shearY(tan(((ImpSdXMLExpTransObj2DSkewY*)pObj)->mfSkewY));
701cdf0e10cSrcweir                 break;
702cdf0e10cSrcweir             }
703cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ2D_MATRIX     :
704cdf0e10cSrcweir             {
705cdf0e10cSrcweir                 rFullTrans *= ((ImpSdXMLExpTransObj2DMatrix*)pObj)->maMatrix;
706cdf0e10cSrcweir                 break;
707cdf0e10cSrcweir             }
708cdf0e10cSrcweir             default :
709cdf0e10cSrcweir             {
710cdf0e10cSrcweir                 DBG_ERROR("SdXMLImExTransform2D: impossible entry!");
711cdf0e10cSrcweir                 break;
712cdf0e10cSrcweir             }
713cdf0e10cSrcweir         }
714cdf0e10cSrcweir     }
715cdf0e10cSrcweir }
716cdf0e10cSrcweir 
717cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
718cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
719cdf0e10cSrcweir // base class of all 3D transform objects
720cdf0e10cSrcweir 
721cdf0e10cSrcweir struct ImpSdXMLExpTransObj3DBase
722cdf0e10cSrcweir {
723cdf0e10cSrcweir     sal_uInt16                  mnType;
ImpSdXMLExpTransObj3DBaseImpSdXMLExpTransObj3DBase724cdf0e10cSrcweir     ImpSdXMLExpTransObj3DBase(sal_uInt16 nType)
725cdf0e10cSrcweir     :   mnType(nType) {}
726cdf0e10cSrcweir };
727cdf0e10cSrcweir 
728cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
729cdf0e10cSrcweir // possible object types for 3D
730cdf0e10cSrcweir 
731cdf0e10cSrcweir #define IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_X        0x0000
732cdf0e10cSrcweir #define IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Y        0x0001
733cdf0e10cSrcweir #define IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Z        0x0002
734cdf0e10cSrcweir #define IMP_SDXMLEXP_TRANSOBJ3D_SCALE           0x0003
735cdf0e10cSrcweir #define IMP_SDXMLEXP_TRANSOBJ3D_TRANSLATE       0x0004
736cdf0e10cSrcweir #define IMP_SDXMLEXP_TRANSOBJ3D_MATRIX          0x0005
737cdf0e10cSrcweir 
738cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
739cdf0e10cSrcweir // classes of objects, different sizes
740cdf0e10cSrcweir 
741cdf0e10cSrcweir struct ImpSdXMLExpTransObj3DRotateX : public ImpSdXMLExpTransObj3DBase
742cdf0e10cSrcweir {
743cdf0e10cSrcweir     double                      mfRotateX;
ImpSdXMLExpTransObj3DRotateXImpSdXMLExpTransObj3DRotateX744cdf0e10cSrcweir     ImpSdXMLExpTransObj3DRotateX(double fVal)
745cdf0e10cSrcweir     :   ImpSdXMLExpTransObj3DBase(IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_X), mfRotateX(fVal) {}
746cdf0e10cSrcweir };
747cdf0e10cSrcweir struct ImpSdXMLExpTransObj3DRotateY : public ImpSdXMLExpTransObj3DBase
748cdf0e10cSrcweir {
749cdf0e10cSrcweir     double                      mfRotateY;
ImpSdXMLExpTransObj3DRotateYImpSdXMLExpTransObj3DRotateY750cdf0e10cSrcweir     ImpSdXMLExpTransObj3DRotateY(double fVal)
751cdf0e10cSrcweir     :   ImpSdXMLExpTransObj3DBase(IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Y), mfRotateY(fVal) {}
752cdf0e10cSrcweir };
753cdf0e10cSrcweir struct ImpSdXMLExpTransObj3DRotateZ : public ImpSdXMLExpTransObj3DBase
754cdf0e10cSrcweir {
755cdf0e10cSrcweir     double                      mfRotateZ;
ImpSdXMLExpTransObj3DRotateZImpSdXMLExpTransObj3DRotateZ756cdf0e10cSrcweir     ImpSdXMLExpTransObj3DRotateZ(double fVal)
757cdf0e10cSrcweir     :   ImpSdXMLExpTransObj3DBase(IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Z), mfRotateZ(fVal) {}
758cdf0e10cSrcweir };
759cdf0e10cSrcweir struct ImpSdXMLExpTransObj3DScale : public ImpSdXMLExpTransObj3DBase
760cdf0e10cSrcweir {
761cdf0e10cSrcweir     ::basegfx::B3DTuple         maScale;
ImpSdXMLExpTransObj3DScaleImpSdXMLExpTransObj3DScale762cdf0e10cSrcweir     ImpSdXMLExpTransObj3DScale(const ::basegfx::B3DTuple& rNew)
763cdf0e10cSrcweir     :   ImpSdXMLExpTransObj3DBase(IMP_SDXMLEXP_TRANSOBJ3D_SCALE), maScale(rNew) {}
764cdf0e10cSrcweir };
765cdf0e10cSrcweir struct ImpSdXMLExpTransObj3DTranslate : public ImpSdXMLExpTransObj3DBase
766cdf0e10cSrcweir {
767cdf0e10cSrcweir     ::basegfx::B3DTuple         maTranslate;
ImpSdXMLExpTransObj3DTranslateImpSdXMLExpTransObj3DTranslate768cdf0e10cSrcweir     ImpSdXMLExpTransObj3DTranslate(const ::basegfx::B3DTuple& rNew)
769cdf0e10cSrcweir     :   ImpSdXMLExpTransObj3DBase(IMP_SDXMLEXP_TRANSOBJ3D_TRANSLATE), maTranslate(rNew) {}
770cdf0e10cSrcweir };
771cdf0e10cSrcweir struct ImpSdXMLExpTransObj3DMatrix : public ImpSdXMLExpTransObj3DBase
772cdf0e10cSrcweir {
773cdf0e10cSrcweir     ::basegfx::B3DHomMatrix     maMatrix;
ImpSdXMLExpTransObj3DMatrixImpSdXMLExpTransObj3DMatrix774cdf0e10cSrcweir     ImpSdXMLExpTransObj3DMatrix(const ::basegfx::B3DHomMatrix& rNew)
775cdf0e10cSrcweir     :   ImpSdXMLExpTransObj3DBase(IMP_SDXMLEXP_TRANSOBJ3D_MATRIX), maMatrix(rNew) {}
776cdf0e10cSrcweir };
777cdf0e10cSrcweir 
778cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
779cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
780cdf0e10cSrcweir // delete all entries in list
781cdf0e10cSrcweir 
EmptyList()782cdf0e10cSrcweir void SdXMLImExTransform3D::EmptyList()
783cdf0e10cSrcweir {
784cdf0e10cSrcweir     const sal_uInt32 nCount = maList.size();
785cdf0e10cSrcweir     for(sal_uInt32 a(0L); a < nCount; a++)
786cdf0e10cSrcweir     {
787cdf0e10cSrcweir         ImpSdXMLExpTransObj3DBase* pObj = maList[a];
788cdf0e10cSrcweir 
789cdf0e10cSrcweir         switch(pObj->mnType)
790cdf0e10cSrcweir         {
791cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_X   :
792cdf0e10cSrcweir             {
793cdf0e10cSrcweir                 delete (ImpSdXMLExpTransObj3DRotateX*)pObj;
794cdf0e10cSrcweir                 break;
795cdf0e10cSrcweir             }
796cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Y   :
797cdf0e10cSrcweir             {
798cdf0e10cSrcweir                 delete (ImpSdXMLExpTransObj3DRotateY*)pObj;
799cdf0e10cSrcweir                 break;
800cdf0e10cSrcweir             }
801cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Z   :
802cdf0e10cSrcweir             {
803cdf0e10cSrcweir                 delete (ImpSdXMLExpTransObj3DRotateZ*)pObj;
804cdf0e10cSrcweir                 break;
805cdf0e10cSrcweir             }
806cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_SCALE      :
807cdf0e10cSrcweir             {
808cdf0e10cSrcweir                 delete (ImpSdXMLExpTransObj3DScale*)pObj;
809cdf0e10cSrcweir                 break;
810cdf0e10cSrcweir             }
811cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_TRANSLATE  :
812cdf0e10cSrcweir             {
813cdf0e10cSrcweir                 delete (ImpSdXMLExpTransObj3DTranslate*)pObj;
814cdf0e10cSrcweir                 break;
815cdf0e10cSrcweir             }
816cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_MATRIX     :
817cdf0e10cSrcweir             {
818cdf0e10cSrcweir                 delete (ImpSdXMLExpTransObj3DMatrix*)pObj;
819cdf0e10cSrcweir                 break;
820cdf0e10cSrcweir             }
821cdf0e10cSrcweir             default :
822cdf0e10cSrcweir             {
823cdf0e10cSrcweir                 DBG_ERROR("SdXMLImExTransform3D: impossible entry!");
824cdf0e10cSrcweir                 break;
825cdf0e10cSrcweir             }
826cdf0e10cSrcweir         }
827cdf0e10cSrcweir     }
828cdf0e10cSrcweir 
829cdf0e10cSrcweir     maList.clear();
830cdf0e10cSrcweir }
831cdf0e10cSrcweir 
832cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
833cdf0e10cSrcweir // add members
834cdf0e10cSrcweir 
AddRotateX(double fNew)835cdf0e10cSrcweir void SdXMLImExTransform3D::AddRotateX(double fNew)
836cdf0e10cSrcweir {
837cdf0e10cSrcweir     if(fNew != 0.0)
838cdf0e10cSrcweir         maList.push_back(new ImpSdXMLExpTransObj3DRotateX(fNew));
839cdf0e10cSrcweir }
840cdf0e10cSrcweir 
AddRotateY(double fNew)841cdf0e10cSrcweir void SdXMLImExTransform3D::AddRotateY(double fNew)
842cdf0e10cSrcweir {
843cdf0e10cSrcweir     if(fNew != 0.0)
844cdf0e10cSrcweir         maList.push_back(new ImpSdXMLExpTransObj3DRotateY(fNew));
845cdf0e10cSrcweir }
846cdf0e10cSrcweir 
AddRotateZ(double fNew)847cdf0e10cSrcweir void SdXMLImExTransform3D::AddRotateZ(double fNew)
848cdf0e10cSrcweir {
849cdf0e10cSrcweir     if(fNew != 0.0)
850cdf0e10cSrcweir         maList.push_back(new ImpSdXMLExpTransObj3DRotateZ(fNew));
851cdf0e10cSrcweir }
852cdf0e10cSrcweir 
AddScale(const::basegfx::B3DTuple & rNew)853cdf0e10cSrcweir void SdXMLImExTransform3D::AddScale(const ::basegfx::B3DTuple& rNew)
854cdf0e10cSrcweir {
855cdf0e10cSrcweir     if(1.0 != rNew.getX() || 1.0 != rNew.getY() || 1.0 != rNew.getZ())
856cdf0e10cSrcweir         maList.push_back(new ImpSdXMLExpTransObj3DScale(rNew));
857cdf0e10cSrcweir }
858cdf0e10cSrcweir 
AddTranslate(const::basegfx::B3DTuple & rNew)859cdf0e10cSrcweir void SdXMLImExTransform3D::AddTranslate(const ::basegfx::B3DTuple& rNew)
860cdf0e10cSrcweir {
861cdf0e10cSrcweir     if(!rNew.equalZero())
862cdf0e10cSrcweir         maList.push_back(new ImpSdXMLExpTransObj3DTranslate(rNew));
863cdf0e10cSrcweir }
864cdf0e10cSrcweir 
AddMatrix(const::basegfx::B3DHomMatrix & rNew)865cdf0e10cSrcweir void SdXMLImExTransform3D::AddMatrix(const ::basegfx::B3DHomMatrix& rNew)
866cdf0e10cSrcweir {
867cdf0e10cSrcweir     if(!rNew.isIdentity())
868cdf0e10cSrcweir         maList.push_back(new ImpSdXMLExpTransObj3DMatrix(rNew));
869cdf0e10cSrcweir }
870cdf0e10cSrcweir 
AddHomogenMatrix(const drawing::HomogenMatrix & xHomMat)871cdf0e10cSrcweir void SdXMLImExTransform3D::AddHomogenMatrix(const drawing::HomogenMatrix& xHomMat)
872cdf0e10cSrcweir {
873cdf0e10cSrcweir     ::basegfx::B3DHomMatrix aExportMatrix;
874cdf0e10cSrcweir 
875cdf0e10cSrcweir     aExportMatrix.set(0, 0, xHomMat.Line1.Column1);
876cdf0e10cSrcweir     aExportMatrix.set(0, 1, xHomMat.Line1.Column2);
877cdf0e10cSrcweir     aExportMatrix.set(0, 2, xHomMat.Line1.Column3);
878cdf0e10cSrcweir     aExportMatrix.set(0, 3, xHomMat.Line1.Column4);
879cdf0e10cSrcweir     aExportMatrix.set(1, 0, xHomMat.Line2.Column1);
880cdf0e10cSrcweir     aExportMatrix.set(1, 1, xHomMat.Line2.Column2);
881cdf0e10cSrcweir     aExportMatrix.set(1, 2, xHomMat.Line2.Column3);
882cdf0e10cSrcweir     aExportMatrix.set(1, 3, xHomMat.Line2.Column4);
883cdf0e10cSrcweir     aExportMatrix.set(2, 0, xHomMat.Line3.Column1);
884cdf0e10cSrcweir     aExportMatrix.set(2, 1, xHomMat.Line3.Column2);
885cdf0e10cSrcweir     aExportMatrix.set(2, 2, xHomMat.Line3.Column3);
886cdf0e10cSrcweir     aExportMatrix.set(2, 3, xHomMat.Line3.Column4);
887cdf0e10cSrcweir 
888cdf0e10cSrcweir     AddMatrix(aExportMatrix);
889cdf0e10cSrcweir }
890cdf0e10cSrcweir 
891cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
892cdf0e10cSrcweir // gen string for export
GetExportString(const SvXMLUnitConverter & rConv)893cdf0e10cSrcweir const OUString& SdXMLImExTransform3D::GetExportString(const SvXMLUnitConverter& rConv)
894cdf0e10cSrcweir {
895cdf0e10cSrcweir     OUString aNewString;
896cdf0e10cSrcweir     OUString aClosingBrace(sal_Unicode(')'));
897cdf0e10cSrcweir     OUString aEmptySpace(sal_Unicode(' '));
898cdf0e10cSrcweir 
899cdf0e10cSrcweir     const sal_uInt32 nCount = maList.size();
900cdf0e10cSrcweir     for(sal_uInt32 a(0L); a < nCount; a++)
901cdf0e10cSrcweir     {
902cdf0e10cSrcweir         ImpSdXMLExpTransObj3DBase* pObj = maList[a];
903cdf0e10cSrcweir         switch(pObj->mnType)
904cdf0e10cSrcweir         {
905cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_X   :
906cdf0e10cSrcweir             {
907cdf0e10cSrcweir                 aNewString += OUString::createFromAscii("rotatex (");
908*a8265799SRegina Henschel                 Imp_PutDoubleChar(aNewString, rConv, basegfx::rad2deg( ((ImpSdXMLExpTransObj3DRotateX*)pObj)->mfRotateX) );
909cdf0e10cSrcweir                 aNewString += aClosingBrace;
910cdf0e10cSrcweir                 break;
911cdf0e10cSrcweir             }
912cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Y   :
913cdf0e10cSrcweir             {
914cdf0e10cSrcweir                 aNewString += OUString::createFromAscii("rotatey (");
915*a8265799SRegina Henschel                 Imp_PutDoubleChar(aNewString, rConv, basegfx::rad2deg( ((ImpSdXMLExpTransObj3DRotateY*)pObj)->mfRotateY) );
916cdf0e10cSrcweir                 aNewString += aClosingBrace;
917cdf0e10cSrcweir                 break;
918cdf0e10cSrcweir             }
919cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Z   :
920cdf0e10cSrcweir             {
921cdf0e10cSrcweir                 aNewString += OUString::createFromAscii("rotatez (");
922*a8265799SRegina Henschel                 Imp_PutDoubleChar(aNewString, rConv, basegfx::rad2deg( ((ImpSdXMLExpTransObj3DRotateZ*)pObj)->mfRotateZ) );
923cdf0e10cSrcweir                 aNewString += aClosingBrace;
924cdf0e10cSrcweir                 break;
925cdf0e10cSrcweir             }
926cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_SCALE      :
927cdf0e10cSrcweir             {
928cdf0e10cSrcweir                 aNewString += OUString::createFromAscii("scale (");
929cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DScale*)pObj)->maScale.getX());
930cdf0e10cSrcweir                 aNewString += aEmptySpace;
931cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DScale*)pObj)->maScale.getY());
932cdf0e10cSrcweir                 aNewString += aEmptySpace;
933cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DScale*)pObj)->maScale.getZ());
934cdf0e10cSrcweir                 aNewString += aClosingBrace;
935cdf0e10cSrcweir                 break;
936cdf0e10cSrcweir             }
937cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_TRANSLATE  :
938cdf0e10cSrcweir             {
939cdf0e10cSrcweir                 aNewString += OUString::createFromAscii("translate (");
940cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DTranslate*)pObj)->maTranslate.getX(), true);
941cdf0e10cSrcweir                 aNewString += aEmptySpace;
942cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DTranslate*)pObj)->maTranslate.getY(), true);
943cdf0e10cSrcweir                 aNewString += aEmptySpace;
944cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DTranslate*)pObj)->maTranslate.getZ(), true);
945cdf0e10cSrcweir                 aNewString += aClosingBrace;
946cdf0e10cSrcweir                 break;
947cdf0e10cSrcweir             }
948cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_MATRIX :
949cdf0e10cSrcweir             {
950cdf0e10cSrcweir                 aNewString += OUString::createFromAscii("matrix (");
951cdf0e10cSrcweir 
952cdf0e10cSrcweir                 // a
953cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DMatrix*)pObj)->maMatrix.get(0, 0));
954cdf0e10cSrcweir                 aNewString += aEmptySpace;
955cdf0e10cSrcweir 
956cdf0e10cSrcweir                 // b
957cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DMatrix*)pObj)->maMatrix.get(1, 0));
958cdf0e10cSrcweir                 aNewString += aEmptySpace;
959cdf0e10cSrcweir 
960cdf0e10cSrcweir                 // c
961cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DMatrix*)pObj)->maMatrix.get(2, 0));
962cdf0e10cSrcweir                 aNewString += aEmptySpace;
963cdf0e10cSrcweir 
964cdf0e10cSrcweir                 // d
965cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DMatrix*)pObj)->maMatrix.get(0, 1));
966cdf0e10cSrcweir                 aNewString += aEmptySpace;
967cdf0e10cSrcweir 
968cdf0e10cSrcweir                 // e
969cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DMatrix*)pObj)->maMatrix.get(1, 1));
970cdf0e10cSrcweir                 aNewString += aEmptySpace;
971cdf0e10cSrcweir 
972cdf0e10cSrcweir                 // f
973cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DMatrix*)pObj)->maMatrix.get(2, 1));
974cdf0e10cSrcweir                 aNewString += aEmptySpace;
975cdf0e10cSrcweir 
976cdf0e10cSrcweir                 // g
977cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DMatrix*)pObj)->maMatrix.get(0, 2));
978cdf0e10cSrcweir                 aNewString += aEmptySpace;
979cdf0e10cSrcweir 
980cdf0e10cSrcweir                 // h
981cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DMatrix*)pObj)->maMatrix.get(1, 2));
982cdf0e10cSrcweir                 aNewString += aEmptySpace;
983cdf0e10cSrcweir 
984cdf0e10cSrcweir                 // i
985cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DMatrix*)pObj)->maMatrix.get(2, 2));
986cdf0e10cSrcweir                 aNewString += aEmptySpace;
987cdf0e10cSrcweir 
988cdf0e10cSrcweir                 // j
989cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DMatrix*)pObj)->maMatrix.get(0, 3), true);
990cdf0e10cSrcweir                 aNewString += aEmptySpace;
991cdf0e10cSrcweir 
992cdf0e10cSrcweir                 // k
993cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DMatrix*)pObj)->maMatrix.get(1, 3), true);
994cdf0e10cSrcweir                 aNewString += aEmptySpace;
995cdf0e10cSrcweir 
996cdf0e10cSrcweir                 // l
997cdf0e10cSrcweir                 Imp_PutDoubleChar(aNewString, rConv, ((ImpSdXMLExpTransObj3DMatrix*)pObj)->maMatrix.get(2, 3), true);
998cdf0e10cSrcweir 
999cdf0e10cSrcweir                 aNewString += aClosingBrace;
1000cdf0e10cSrcweir                 break;
1001cdf0e10cSrcweir             }
1002cdf0e10cSrcweir             default :
1003cdf0e10cSrcweir             {
1004cdf0e10cSrcweir                 DBG_ERROR("SdXMLImExTransform3D: impossible entry!");
1005cdf0e10cSrcweir                 break;
1006cdf0e10cSrcweir             }
1007cdf0e10cSrcweir         }
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir         // if not the last entry, add one space to next tag
1010cdf0e10cSrcweir         if(a + 1UL != maList.size())
1011cdf0e10cSrcweir         {
1012cdf0e10cSrcweir             aNewString += aEmptySpace;
1013cdf0e10cSrcweir         }
1014cdf0e10cSrcweir     }
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir     // fill string form OUString
1017cdf0e10cSrcweir     msString = aNewString;
1018cdf0e10cSrcweir 
1019cdf0e10cSrcweir     return msString;
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir 
1022cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1023cdf0e10cSrcweir // for Import: constructor with string, parses it and generates entries
SdXMLImExTransform3D(const OUString & rNew,const SvXMLUnitConverter & rConv)1024cdf0e10cSrcweir SdXMLImExTransform3D::SdXMLImExTransform3D(const OUString& rNew, const SvXMLUnitConverter& rConv)
1025cdf0e10cSrcweir {
1026cdf0e10cSrcweir     SetString(rNew, rConv);
1027cdf0e10cSrcweir }
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1030cdf0e10cSrcweir // sets new string, parses it and generates entries
SetString(const OUString & rNew,const SvXMLUnitConverter & rConv)1031cdf0e10cSrcweir void SdXMLImExTransform3D::SetString(const OUString& rNew, const SvXMLUnitConverter& rConv)
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir     msString = rNew;
1034cdf0e10cSrcweir     EmptyList();
1035cdf0e10cSrcweir 
1036cdf0e10cSrcweir     if(msString.getLength())
1037cdf0e10cSrcweir     {
1038cdf0e10cSrcweir         const OUString aStr(msString.getStr(), (sal_uInt16)msString.getLength());
1039cdf0e10cSrcweir         const sal_Int32 nLen(aStr.getLength());
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir         const OUString aString_rotatex(OUString::createFromAscii("rotatex"));
1042cdf0e10cSrcweir         const OUString aString_rotatey(OUString::createFromAscii("rotatey"));
1043cdf0e10cSrcweir         const OUString aString_rotatez(OUString::createFromAscii("rotatez"));
1044cdf0e10cSrcweir         const OUString aString_scale(OUString::createFromAscii("scale"));
1045cdf0e10cSrcweir         const OUString aString_translate(OUString::createFromAscii("translate"));
1046cdf0e10cSrcweir         const OUString aString_matrix(OUString::createFromAscii("matrix"));
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir         sal_Int32 nPos(0);
1049cdf0e10cSrcweir 
1050cdf0e10cSrcweir         while(nPos < nLen)
1051cdf0e10cSrcweir         {
1052cdf0e10cSrcweir             // skip spaces
1053cdf0e10cSrcweir             Imp_SkipSpaces(aStr, nPos, nLen);
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir             // look for tag
1056cdf0e10cSrcweir             if(nPos < nLen)
1057cdf0e10cSrcweir             {
1058cdf0e10cSrcweir                 if(nPos == aStr.indexOf(aString_rotatex, nPos))
1059cdf0e10cSrcweir                 {
1060cdf0e10cSrcweir                     double fValue(0.0);
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir                     nPos += 7;
1063cdf0e10cSrcweir                     Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
1064cdf0e10cSrcweir                     fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue);
1065cdf0e10cSrcweir                     if(fValue != 0.0)
1066*a8265799SRegina Henschel                         maList.push_back(new ImpSdXMLExpTransObj3DRotateX(basegfx::deg2rad(fValue)));
1067cdf0e10cSrcweir 
1068cdf0e10cSrcweir                     Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
1069cdf0e10cSrcweir                 }
1070cdf0e10cSrcweir                 else if(nPos == aStr.indexOf(aString_rotatey, nPos))
1071cdf0e10cSrcweir                 {
1072cdf0e10cSrcweir                     double fValue(0.0);
1073cdf0e10cSrcweir 
1074cdf0e10cSrcweir                     nPos += 7;
1075cdf0e10cSrcweir                     Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
1076cdf0e10cSrcweir                     fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue);
1077cdf0e10cSrcweir                     if(fValue != 0.0)
1078*a8265799SRegina Henschel                         maList.push_back(new ImpSdXMLExpTransObj3DRotateY(basegfx::deg2rad(fValue)));
1079cdf0e10cSrcweir 
1080cdf0e10cSrcweir                     Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
1081cdf0e10cSrcweir                 }
1082cdf0e10cSrcweir                 else if(nPos == aStr.indexOf(aString_rotatez, nPos))
1083cdf0e10cSrcweir                 {
1084cdf0e10cSrcweir                     double fValue(0.0);
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir                     nPos += 7;
1087cdf0e10cSrcweir                     Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
1088cdf0e10cSrcweir                     fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue);
1089cdf0e10cSrcweir                     if(fValue != 0.0)
1090*a8265799SRegina Henschel                         maList.push_back(new ImpSdXMLExpTransObj3DRotateZ(basegfx::deg2rad(fValue)));
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir                     Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
1093cdf0e10cSrcweir                 }
1094cdf0e10cSrcweir                 else if(nPos == aStr.indexOf(aString_scale, nPos))
1095cdf0e10cSrcweir                 {
1096cdf0e10cSrcweir                     ::basegfx::B3DTuple aValue(1.0, 1.0, 1.0);
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir                     nPos += 5;
1099cdf0e10cSrcweir                     Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
1100cdf0e10cSrcweir                     aValue.setX(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getX()));
1101cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1102cdf0e10cSrcweir                     aValue.setY(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getY()));
1103cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1104cdf0e10cSrcweir                     aValue.setZ(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getZ()));
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir                     if(1.0 != aValue.getX() || 1.0 != aValue.getY() || 1.0 != aValue.getZ())
1107cdf0e10cSrcweir                         maList.push_back(new ImpSdXMLExpTransObj3DScale(aValue));
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir                     Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
1110cdf0e10cSrcweir                 }
1111cdf0e10cSrcweir                 else if(nPos == aStr.indexOf(aString_translate, nPos))
1112cdf0e10cSrcweir                 {
1113cdf0e10cSrcweir                     ::basegfx::B3DTuple aValue;
1114cdf0e10cSrcweir 
1115cdf0e10cSrcweir                     nPos += 9;
1116cdf0e10cSrcweir                     Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
1117cdf0e10cSrcweir                     aValue.setX(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getX(), true));
1118cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1119cdf0e10cSrcweir                     aValue.setY(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getY(), true));
1120cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1121cdf0e10cSrcweir                     aValue.setZ(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getZ(), true));
1122cdf0e10cSrcweir 
1123cdf0e10cSrcweir                     if(!aValue.equalZero())
1124cdf0e10cSrcweir                         maList.push_back(new ImpSdXMLExpTransObj3DTranslate(aValue));
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir                     Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
1127cdf0e10cSrcweir                 }
1128cdf0e10cSrcweir                 else if(nPos == aStr.indexOf(aString_matrix, nPos))
1129cdf0e10cSrcweir                 {
1130cdf0e10cSrcweir                     ::basegfx::B3DHomMatrix aValue;
1131cdf0e10cSrcweir 
1132cdf0e10cSrcweir                     nPos += 6;
1133cdf0e10cSrcweir                     Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir                     // a
1136cdf0e10cSrcweir                     aValue.set(0, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 0)));
1137cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir                     // b
1140cdf0e10cSrcweir                     aValue.set(1, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 0)));
1141cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir                     // c
1144cdf0e10cSrcweir                     aValue.set(2, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(2, 0)));
1145cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1146cdf0e10cSrcweir 
1147cdf0e10cSrcweir                     // d
1148cdf0e10cSrcweir                     aValue.set(0, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 1)));
1149cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1150cdf0e10cSrcweir 
1151cdf0e10cSrcweir                     // e
1152cdf0e10cSrcweir                     aValue.set(1, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 1)));
1153cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1154cdf0e10cSrcweir 
1155cdf0e10cSrcweir                     // f
1156cdf0e10cSrcweir                     aValue.set(2, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(2, 1)));
1157cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir                     // g
1160cdf0e10cSrcweir                     aValue.set(0, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 2)));
1161cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1162cdf0e10cSrcweir 
1163cdf0e10cSrcweir                     // h
1164cdf0e10cSrcweir                     aValue.set(1, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 2)));
1165cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir                     // i
1168cdf0e10cSrcweir                     aValue.set(2, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(2, 2)));
1169cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir                     // j
1172cdf0e10cSrcweir                     aValue.set(0, 3, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 3), true));
1173cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1174cdf0e10cSrcweir 
1175cdf0e10cSrcweir                     // k
1176cdf0e10cSrcweir                     aValue.set(1, 3, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 3), true));
1177cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir                     // l
1180cdf0e10cSrcweir                     aValue.set(2, 3, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(2, 3), true));
1181cdf0e10cSrcweir                     Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1182cdf0e10cSrcweir 
1183cdf0e10cSrcweir                     if(!aValue.isIdentity())
1184cdf0e10cSrcweir                         maList.push_back(new ImpSdXMLExpTransObj3DMatrix(aValue));
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir                     Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
1187cdf0e10cSrcweir                 }
1188cdf0e10cSrcweir                 else
1189cdf0e10cSrcweir                 {
1190cdf0e10cSrcweir                     nPos++;
1191cdf0e10cSrcweir                 }
1192cdf0e10cSrcweir             }
1193cdf0e10cSrcweir         }
1194cdf0e10cSrcweir     }
1195cdf0e10cSrcweir }
1196cdf0e10cSrcweir 
GetFullHomogenTransform(com::sun::star::drawing::HomogenMatrix & xHomMat)1197cdf0e10cSrcweir bool SdXMLImExTransform3D::GetFullHomogenTransform(com::sun::star::drawing::HomogenMatrix& xHomMat)
1198cdf0e10cSrcweir {
1199cdf0e10cSrcweir     ::basegfx::B3DHomMatrix aFullTransform;
1200cdf0e10cSrcweir     GetFullTransform(aFullTransform);
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir     if(!aFullTransform.isIdentity())
1203cdf0e10cSrcweir     {
1204cdf0e10cSrcweir         xHomMat.Line1.Column1 = aFullTransform.get(0, 0);
1205cdf0e10cSrcweir         xHomMat.Line1.Column2 = aFullTransform.get(0, 1);
1206cdf0e10cSrcweir         xHomMat.Line1.Column3 = aFullTransform.get(0, 2);
1207cdf0e10cSrcweir         xHomMat.Line1.Column4 = aFullTransform.get(0, 3);
1208cdf0e10cSrcweir 
1209cdf0e10cSrcweir         xHomMat.Line2.Column1 = aFullTransform.get(1, 0);
1210cdf0e10cSrcweir         xHomMat.Line2.Column2 = aFullTransform.get(1, 1);
1211cdf0e10cSrcweir         xHomMat.Line2.Column3 = aFullTransform.get(1, 2);
1212cdf0e10cSrcweir         xHomMat.Line2.Column4 = aFullTransform.get(1, 3);
1213cdf0e10cSrcweir 
1214cdf0e10cSrcweir         xHomMat.Line3.Column1 = aFullTransform.get(2, 0);
1215cdf0e10cSrcweir         xHomMat.Line3.Column2 = aFullTransform.get(2, 1);
1216cdf0e10cSrcweir         xHomMat.Line3.Column3 = aFullTransform.get(2, 2);
1217cdf0e10cSrcweir         xHomMat.Line3.Column4 = aFullTransform.get(2, 3);
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir         xHomMat.Line4.Column1 = aFullTransform.get(3, 0);
1220cdf0e10cSrcweir         xHomMat.Line4.Column2 = aFullTransform.get(3, 1);
1221cdf0e10cSrcweir         xHomMat.Line4.Column3 = aFullTransform.get(3, 2);
1222cdf0e10cSrcweir         xHomMat.Line4.Column4 = aFullTransform.get(3, 3);
1223cdf0e10cSrcweir 
1224cdf0e10cSrcweir         return true;
1225cdf0e10cSrcweir     }
1226cdf0e10cSrcweir 
1227cdf0e10cSrcweir     return false;
1228cdf0e10cSrcweir }
1229cdf0e10cSrcweir 
GetFullTransform(::basegfx::B3DHomMatrix & rFullTrans)1230cdf0e10cSrcweir void SdXMLImExTransform3D::GetFullTransform(::basegfx::B3DHomMatrix& rFullTrans)
1231cdf0e10cSrcweir {
1232cdf0e10cSrcweir     rFullTrans.identity();
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir     const sal_uInt32 nCount = maList.size();
1235cdf0e10cSrcweir     for(sal_uInt32 a(0L); a < nCount; a++)
1236cdf0e10cSrcweir     {
1237cdf0e10cSrcweir         ImpSdXMLExpTransObj3DBase* pObj = maList[a];
1238cdf0e10cSrcweir         switch(pObj->mnType)
1239cdf0e10cSrcweir         {
1240cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_X   :
1241cdf0e10cSrcweir             {
1242cdf0e10cSrcweir                 rFullTrans.rotate(((ImpSdXMLExpTransObj3DRotateX*)pObj)->mfRotateX, 0.0, 0.0);
1243cdf0e10cSrcweir                 break;
1244cdf0e10cSrcweir             }
1245cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Y   :
1246cdf0e10cSrcweir             {
1247cdf0e10cSrcweir                 rFullTrans.rotate(0.0, ((ImpSdXMLExpTransObj3DRotateY*)pObj)->mfRotateY, 0.0);
1248cdf0e10cSrcweir                 break;
1249cdf0e10cSrcweir             }
1250cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Z   :
1251cdf0e10cSrcweir             {
1252cdf0e10cSrcweir                 rFullTrans.rotate(0.0, 0.0, ((ImpSdXMLExpTransObj3DRotateZ*)pObj)->mfRotateZ);
1253cdf0e10cSrcweir                 break;
1254cdf0e10cSrcweir             }
1255cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_SCALE      :
1256cdf0e10cSrcweir             {
1257cdf0e10cSrcweir                 const ::basegfx::B3DTuple& rScale = ((ImpSdXMLExpTransObj3DScale*)pObj)->maScale;
1258cdf0e10cSrcweir                 rFullTrans.scale(rScale.getX(), rScale.getY(), rScale.getZ());
1259cdf0e10cSrcweir                 break;
1260cdf0e10cSrcweir             }
1261cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_TRANSLATE  :
1262cdf0e10cSrcweir             {
1263cdf0e10cSrcweir                 const ::basegfx::B3DTuple& rTranslate = ((ImpSdXMLExpTransObj3DTranslate*)pObj)->maTranslate;
1264cdf0e10cSrcweir                 rFullTrans.translate(rTranslate.getX(), rTranslate.getY(), rTranslate.getZ());
1265cdf0e10cSrcweir                 break;
1266cdf0e10cSrcweir             }
1267cdf0e10cSrcweir             case IMP_SDXMLEXP_TRANSOBJ3D_MATRIX     :
1268cdf0e10cSrcweir             {
1269cdf0e10cSrcweir                 rFullTrans *= ((ImpSdXMLExpTransObj3DMatrix*)pObj)->maMatrix;
1270cdf0e10cSrcweir                 break;
1271cdf0e10cSrcweir             }
1272cdf0e10cSrcweir             default :
1273cdf0e10cSrcweir             {
1274cdf0e10cSrcweir                 DBG_ERROR("SdXMLImExTransform3D: impossible entry!");
1275cdf0e10cSrcweir                 break;
1276cdf0e10cSrcweir             }
1277cdf0e10cSrcweir         }
1278cdf0e10cSrcweir     }
1279cdf0e10cSrcweir }
1280cdf0e10cSrcweir 
1281cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1282cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1283cdf0e10cSrcweir 
SdXMLImExViewBox(double fX,double fY,double fW,double fH)12841f882ec4SArmin Le Grand SdXMLImExViewBox::SdXMLImExViewBox(double fX, double fY, double fW, double fH)
12851f882ec4SArmin Le Grand :   mfX( fX ),
12861f882ec4SArmin Le Grand     mfY( fY ),
12871f882ec4SArmin Le Grand     mfW( fW ),
12881f882ec4SArmin Le Grand     mfH( fH )
1289cdf0e10cSrcweir {
1290cdf0e10cSrcweir }
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir // #100617# Asked vincent hardy: svg:viewBox values may be double precision.
SdXMLImExViewBox(const OUString & rNew,const SvXMLUnitConverter & rConv)1293cdf0e10cSrcweir SdXMLImExViewBox::SdXMLImExViewBox(const OUString& rNew, const SvXMLUnitConverter& rConv)
1294cdf0e10cSrcweir :   msString(rNew),
12951f882ec4SArmin Le Grand     mfX( 0.0 ),
12961f882ec4SArmin Le Grand     mfY( 0.0 ),
12971f882ec4SArmin Le Grand     mfW( 1000.0 ),
12981f882ec4SArmin Le Grand     mfH( 1000.0 )
1299cdf0e10cSrcweir {
1300cdf0e10cSrcweir     if(msString.getLength())
1301cdf0e10cSrcweir     {
1302cdf0e10cSrcweir         const OUString aStr(msString.getStr(), (sal_uInt16)msString.getLength());
1303cdf0e10cSrcweir         const sal_Int32 nLen(aStr.getLength());
1304cdf0e10cSrcweir         sal_Int32 nPos(0);
1305cdf0e10cSrcweir 
1306cdf0e10cSrcweir         // skip starting spaces
1307cdf0e10cSrcweir         Imp_SkipSpaces(aStr, nPos, nLen);
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir         // get mX, #100617# be prepared for doubles
13101f882ec4SArmin Le Grand         mfX = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, mfX);
1311cdf0e10cSrcweir 
1312cdf0e10cSrcweir         // skip spaces and commas
1313cdf0e10cSrcweir         Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1314cdf0e10cSrcweir 
1315cdf0e10cSrcweir         // get mY, #100617# be prepared for doubles
13161f882ec4SArmin Le Grand         mfY = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, mfY);
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir         // skip spaces and commas
1319cdf0e10cSrcweir         Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1320cdf0e10cSrcweir 
1321cdf0e10cSrcweir         // get mW, #100617# be prepared for doubles
13221f882ec4SArmin Le Grand         mfW = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, mfW);
1323cdf0e10cSrcweir 
1324cdf0e10cSrcweir         // skip spaces and commas
1325cdf0e10cSrcweir         Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir         // get mH, #100617# be prepared for doubles
13281f882ec4SArmin Le Grand         mfH = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, mfH);
1329cdf0e10cSrcweir     }
1330cdf0e10cSrcweir }
1331cdf0e10cSrcweir 
GetExportString()1332cdf0e10cSrcweir const OUString& SdXMLImExViewBox::GetExportString()
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir     OUString aNewString;
1335cdf0e10cSrcweir     OUString aEmptySpace(sal_Unicode(' '));
1336cdf0e10cSrcweir 
13371f882ec4SArmin Le Grand     Imp_PutDoubleChar(aNewString, mfX);
1338cdf0e10cSrcweir     aNewString += aEmptySpace;
1339cdf0e10cSrcweir 
13401f882ec4SArmin Le Grand     Imp_PutDoubleChar(aNewString, mfY);
1341cdf0e10cSrcweir     aNewString += aEmptySpace;
1342cdf0e10cSrcweir 
13431f882ec4SArmin Le Grand     Imp_PutDoubleChar(aNewString, mfW);
1344cdf0e10cSrcweir     aNewString += aEmptySpace;
1345cdf0e10cSrcweir 
13461f882ec4SArmin Le Grand     Imp_PutDoubleChar(aNewString, mfH);
1347cdf0e10cSrcweir 
1348cdf0e10cSrcweir     // set new string
1349cdf0e10cSrcweir     msString = aNewString;
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir     return msString;
1352cdf0e10cSrcweir }
1353cdf0e10cSrcweir 
1354cdf0e10cSrcweir // eof
1355