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