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 "ximpcustomshape.hxx" 27cdf0e10cSrcweir #include "ximpshap.hxx" 28cdf0e10cSrcweir #include "xmlehelp.hxx" 29cdf0e10cSrcweir #include <rtl/math.hxx> 30cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 31cdf0e10cSrcweir #include <rtl/ustring.hxx> 32cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 33cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 34cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp> 35cdf0e10cSrcweir #include <com/sun/star/container/XIndexContainer.hpp> 36cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 37cdf0e10cSrcweir #include "EnhancedCustomShapeToken.hxx" 38cdf0e10cSrcweir #include <xmloff/xmlimp.hxx> 39cdf0e10cSrcweir #include <xmloff/xmltkmap.hxx> 40cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 41cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 42cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 43cdf0e10cSrcweir #include "xexptran.hxx" 44cdf0e10cSrcweir #include "xmloff/xmlerror.hxx" 45cdf0e10cSrcweir #include <tools/debug.hxx> 46cdf0e10cSrcweir #include <com/sun/star/drawing/Direction3D.hpp> 47cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> 48cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp> 49cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp> 50cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> 51cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> 52cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp> 53cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp> 54cdf0e10cSrcweir #include <com/sun/star/drawing/ProjectionMode.hpp> 55cdf0e10cSrcweir #include <hash_map> 56cdf0e10cSrcweir 57cdf0e10cSrcweir using namespace ::com::sun::star; 58cdf0e10cSrcweir using namespace ::xmloff::token; 59cdf0e10cSrcweir using namespace ::xmloff::EnhancedCustomShapeToken; 60cdf0e10cSrcweir 61cdf0e10cSrcweir TYPEINIT1( XMLEnhancedCustomShapeContext, SvXMLImportContext ); 62cdf0e10cSrcweir 63cdf0e10cSrcweir XMLEnhancedCustomShapeContext::XMLEnhancedCustomShapeContext( SvXMLImport& rImport, 64cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape, 65cdf0e10cSrcweir sal_uInt16 nPrefix, const rtl::OUString& rLocalName, 66cdf0e10cSrcweir std::vector< com::sun::star::beans::PropertyValue >& rCustomShapeGeometry ) : 67cdf0e10cSrcweir SvXMLImportContext( rImport, nPrefix, rLocalName ), 68cdf0e10cSrcweir mrUnitConverter( rImport.GetMM100UnitConverter() ), 69cdf0e10cSrcweir mrxShape( rxShape ), 70cdf0e10cSrcweir mrCustomShapeGeometry( rCustomShapeGeometry ) 71cdf0e10cSrcweir { 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir const SvXMLEnumMapEntry aXML_GluePointEnumMap[] = 75cdf0e10cSrcweir { 76cdf0e10cSrcweir { XML_NONE, 0 }, 77cdf0e10cSrcweir { XML_SEGMENTS, 1 }, 78cdf0e10cSrcweir { XML_NONE, 2 }, 79cdf0e10cSrcweir { XML_RECTANGLE, 3 }, 80cdf0e10cSrcweir { XML_TOKEN_INVALID, 0 } 81cdf0e10cSrcweir }; 82cdf0e10cSrcweir void GetBool( std::vector< com::sun::star::beans::PropertyValue >& rDest, 83cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir sal_Bool bAttrBool; 86cdf0e10cSrcweir if ( SvXMLUnitConverter::convertBool( bAttrBool, rValue ) ) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir beans::PropertyValue aProp; 89cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 90cdf0e10cSrcweir aProp.Value <<= bAttrBool; 91cdf0e10cSrcweir rDest.push_back( aProp ); 92cdf0e10cSrcweir } 93cdf0e10cSrcweir } 94cdf0e10cSrcweir 95cdf0e10cSrcweir void GetInt32( std::vector< com::sun::star::beans::PropertyValue >& rDest, 96cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir sal_Int32 nAttrNumber; 99cdf0e10cSrcweir if ( SvXMLUnitConverter::convertNumber( nAttrNumber, rValue ) ) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir beans::PropertyValue aProp; 102cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 103cdf0e10cSrcweir aProp.Value <<= nAttrNumber; 104cdf0e10cSrcweir rDest.push_back( aProp ); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir void GetDouble( std::vector< com::sun::star::beans::PropertyValue >& rDest, 109cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir double fAttrDouble; 112cdf0e10cSrcweir if ( SvXMLUnitConverter::convertDouble( fAttrDouble, rValue ) ) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir beans::PropertyValue aProp; 115cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 116cdf0e10cSrcweir aProp.Value <<= fAttrDouble; 117cdf0e10cSrcweir rDest.push_back( aProp ); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir void GetDistance( std::vector< com::sun::star::beans::PropertyValue >& rDest, 122cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir double fAttrDouble; 125cdf0e10cSrcweir MapUnit eSrcUnit( SvXMLExportHelper::GetUnitFromString( rValue, MAP_100TH_MM ) ); 126cdf0e10cSrcweir if ( SvXMLUnitConverter::convertDouble( fAttrDouble, rValue, eSrcUnit, MAP_100TH_MM ) ) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir beans::PropertyValue aProp; 129cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 130cdf0e10cSrcweir aProp.Value <<= fAttrDouble; 131cdf0e10cSrcweir rDest.push_back( aProp ); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir void GetString( std::vector< com::sun::star::beans::PropertyValue >& rDest, 136cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir beans::PropertyValue aProp; 139cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 140cdf0e10cSrcweir aProp.Value <<= rValue; 141cdf0e10cSrcweir rDest.push_back( aProp ); 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir void GetEnum( std::vector< com::sun::star::beans::PropertyValue >& rDest, 145cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp, 146cdf0e10cSrcweir const SvXMLEnumMapEntry& rMap ) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir sal_uInt16 eKind; 149cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( eKind, rValue, &rMap ) ) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir sal_Int16 nEnum = (sal_Int16)eKind; 152cdf0e10cSrcweir beans::PropertyValue aProp; 153cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 154cdf0e10cSrcweir aProp.Value <<= nEnum; 155cdf0e10cSrcweir rDest.push_back( aProp ); 156cdf0e10cSrcweir } 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir void GetDoublePercentage( std::vector< com::sun::star::beans::PropertyValue >& rDest, 160cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 161cdf0e10cSrcweir { 162cdf0e10cSrcweir MapUnit eSrcUnit = SvXMLExportHelper::GetUnitFromString( rValue, MAP_100TH_MM ); 163cdf0e10cSrcweir if ( eSrcUnit == MAP_RELATIVE ) 164cdf0e10cSrcweir { 165cdf0e10cSrcweir rtl_math_ConversionStatus eStatus; 166cdf0e10cSrcweir double fAttrDouble = ::rtl::math::stringToDouble( rValue, 167cdf0e10cSrcweir (sal_Unicode)('.'), (sal_Unicode)(','), &eStatus, NULL ); 168cdf0e10cSrcweir if ( eStatus == rtl_math_ConversionStatus_Ok ) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir beans::PropertyValue aProp; 171cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 172cdf0e10cSrcweir aProp.Value <<= fAttrDouble; 173cdf0e10cSrcweir rDest.push_back( aProp ); 174cdf0e10cSrcweir } 175cdf0e10cSrcweir } 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir void GetB3DVector( std::vector< com::sun::star::beans::PropertyValue >& rDest, 179cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir ::basegfx::B3DVector aB3DVector; 182cdf0e10cSrcweir if ( SvXMLUnitConverter::convertB3DVector( aB3DVector, rValue ) ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir drawing::Direction3D aDirection3D( aB3DVector.getX(), aB3DVector.getY(), aB3DVector.getZ() ); 185cdf0e10cSrcweir beans::PropertyValue aProp; 186cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 187cdf0e10cSrcweir aProp.Value <<= aDirection3D; 188cdf0e10cSrcweir rDest.push_back( aProp ); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir } 191cdf0e10cSrcweir 192cdf0e10cSrcweir sal_Bool GetEquationName( const rtl::OUString& rEquation, const sal_Int32 nStart, rtl::OUString& rEquationName ) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir sal_Int32 nIndex = nStart; 195cdf0e10cSrcweir while( nIndex < rEquation.getLength() ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir sal_Unicode nChar = rEquation[ nIndex ]; 198cdf0e10cSrcweir if ( 199cdf0e10cSrcweir ( ( nChar >= 'a' ) && ( nChar <= 'z' ) ) 200cdf0e10cSrcweir || ( ( nChar >= 'A' ) && ( nChar <= 'Z' ) ) 201cdf0e10cSrcweir || ( ( nChar >= '0' ) && ( nChar <= '9' ) ) 202cdf0e10cSrcweir ) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir nIndex++; 205cdf0e10cSrcweir } 206cdf0e10cSrcweir else 207cdf0e10cSrcweir break; 208cdf0e10cSrcweir } 209cdf0e10cSrcweir sal_Bool bValid = ( nIndex - nStart ) != 0; 210cdf0e10cSrcweir if ( bValid ) 211cdf0e10cSrcweir rEquationName = rEquation.copy( nStart, nIndex - nStart ); 212cdf0e10cSrcweir return bValid; 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir sal_Bool GetNextParameter( com::sun::star::drawing::EnhancedCustomShapeParameter& rParameter, sal_Int32& nIndex, const rtl::OUString& rParaString ) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir if ( nIndex >= rParaString.getLength() ) 218cdf0e10cSrcweir return sal_False; 219cdf0e10cSrcweir 220cdf0e10cSrcweir sal_Bool bValid = sal_True; 221cdf0e10cSrcweir sal_Bool bNumberRequired = sal_True; 222cdf0e10cSrcweir sal_Bool bMustBePositiveWholeNumbered = sal_False; 223cdf0e10cSrcweir 224cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::NORMAL; 225cdf0e10cSrcweir if ( rParaString[ nIndex ] == (sal_Unicode)'$' ) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::ADJUSTMENT; 228cdf0e10cSrcweir bMustBePositiveWholeNumbered = sal_True; 229cdf0e10cSrcweir nIndex++; 230cdf0e10cSrcweir } 231cdf0e10cSrcweir else if ( rParaString[ nIndex ] == (sal_Unicode)'?' ) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir nIndex++; 234cdf0e10cSrcweir bNumberRequired = sal_False; 235cdf0e10cSrcweir rtl::OUString aEquationName; 236cdf0e10cSrcweir bValid = GetEquationName( rParaString, nIndex, aEquationName ); 237cdf0e10cSrcweir if ( bValid ) 238cdf0e10cSrcweir { 239cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::EQUATION; 240cdf0e10cSrcweir rParameter.Value <<= aEquationName; 241cdf0e10cSrcweir nIndex += aEquationName.getLength(); 242cdf0e10cSrcweir } 243cdf0e10cSrcweir } 244cdf0e10cSrcweir else if ( rParaString[ nIndex ] > (sal_Unicode)'9' ) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir bNumberRequired = sal_False; 247cdf0e10cSrcweir if ( rParaString.matchIgnoreAsciiCaseAsciiL( "left", 4, nIndex ) ) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::LEFT; 250cdf0e10cSrcweir nIndex += 4; 251cdf0e10cSrcweir } 252cdf0e10cSrcweir else if ( rParaString.matchIgnoreAsciiCaseAsciiL( "top", 3, nIndex ) ) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::TOP; 255cdf0e10cSrcweir nIndex += 3; 256cdf0e10cSrcweir } 257cdf0e10cSrcweir else if ( rParaString.matchIgnoreAsciiCaseAsciiL( "right", 5, nIndex ) ) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::RIGHT; 260cdf0e10cSrcweir nIndex += 5; 261cdf0e10cSrcweir } 262cdf0e10cSrcweir else if ( rParaString.matchIgnoreAsciiCaseAsciiL( "bottom", 6, nIndex ) ) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::BOTTOM; 265cdf0e10cSrcweir nIndex += 6; 266cdf0e10cSrcweir } 267cdf0e10cSrcweir else if ( rParaString.matchIgnoreAsciiCaseAsciiL( "xstretch", 8, nIndex ) ) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::XSTRETCH; 270cdf0e10cSrcweir nIndex += 8; 271cdf0e10cSrcweir } 272cdf0e10cSrcweir else if ( rParaString.matchIgnoreAsciiCaseAsciiL( "ystretch", 8, nIndex ) ) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::YSTRETCH; 275cdf0e10cSrcweir nIndex += 8; 276cdf0e10cSrcweir } 277cdf0e10cSrcweir else if ( rParaString.matchIgnoreAsciiCaseAsciiL( "hasstroke", 9, nIndex ) ) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::HASSTROKE; 280cdf0e10cSrcweir nIndex += 9; 281cdf0e10cSrcweir } 282cdf0e10cSrcweir else if ( rParaString.matchIgnoreAsciiCaseAsciiL( "hasfill", 7, nIndex ) ) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::HASFILL; 285cdf0e10cSrcweir nIndex += 7; 286cdf0e10cSrcweir } 287cdf0e10cSrcweir else if ( rParaString.matchIgnoreAsciiCaseAsciiL( "width", 5, nIndex ) ) 288cdf0e10cSrcweir { 289cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::WIDTH; 290cdf0e10cSrcweir nIndex += 5; 291cdf0e10cSrcweir } 292cdf0e10cSrcweir else if ( rParaString.matchIgnoreAsciiCaseAsciiL( "height", 6, nIndex ) ) 293cdf0e10cSrcweir { 294cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::HEIGHT; 295cdf0e10cSrcweir nIndex += 6; 296cdf0e10cSrcweir } 297cdf0e10cSrcweir else if ( rParaString.matchIgnoreAsciiCaseAsciiL( "logwidth", 8, nIndex ) ) 298cdf0e10cSrcweir { 299cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::LOGWIDTH; 300cdf0e10cSrcweir nIndex += 8; 301cdf0e10cSrcweir } 302cdf0e10cSrcweir else if ( rParaString.matchIgnoreAsciiCaseAsciiL( "logheight", 9, nIndex ) ) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir rParameter.Type = com::sun::star::drawing::EnhancedCustomShapeParameterType::LOGHEIGHT; 305cdf0e10cSrcweir nIndex += 9; 306cdf0e10cSrcweir } 307cdf0e10cSrcweir else 308cdf0e10cSrcweir bValid = sal_False; 309cdf0e10cSrcweir } 310cdf0e10cSrcweir if ( bValid ) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir if ( bNumberRequired ) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir sal_Int32 nStartIndex = nIndex; 315cdf0e10cSrcweir 316cdf0e10cSrcweir sal_Bool bM = sal_False; // set if the value is negative 317cdf0e10cSrcweir sal_Bool bE = sal_False; // set if a double is including a "E" statement 318cdf0e10cSrcweir sal_Bool bEM = sal_False; // set if a double is including a "E-"statement 319cdf0e10cSrcweir sal_Bool bDot = sal_False; // set if there is a dot included 320cdf0e10cSrcweir sal_Bool bEnd = sal_False; // set for each value that can not be part of a double/integer 321cdf0e10cSrcweir 322cdf0e10cSrcweir while( ( nIndex < rParaString.getLength() ) && bValid ) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir switch( rParaString[ nIndex ] ) 325cdf0e10cSrcweir { 326cdf0e10cSrcweir case '.' : 327cdf0e10cSrcweir { 328cdf0e10cSrcweir if ( bMustBePositiveWholeNumbered ) 329cdf0e10cSrcweir bValid = sal_False; 330cdf0e10cSrcweir else 331cdf0e10cSrcweir { 332cdf0e10cSrcweir if ( bDot ) 333cdf0e10cSrcweir bValid = sal_False; 334cdf0e10cSrcweir else 335cdf0e10cSrcweir bDot = sal_True; 336cdf0e10cSrcweir } 337cdf0e10cSrcweir } 338cdf0e10cSrcweir break; 339cdf0e10cSrcweir case '-' : 340cdf0e10cSrcweir { 341cdf0e10cSrcweir if ( bMustBePositiveWholeNumbered ) 342cdf0e10cSrcweir bValid = sal_False; 343cdf0e10cSrcweir else 344cdf0e10cSrcweir { 345cdf0e10cSrcweir if ( nStartIndex == nIndex ) 346cdf0e10cSrcweir bM = sal_True; 347cdf0e10cSrcweir else if ( bE ) 348cdf0e10cSrcweir bEM = sal_True; 349cdf0e10cSrcweir else 350cdf0e10cSrcweir bValid = sal_False; 351cdf0e10cSrcweir } 352cdf0e10cSrcweir } 353cdf0e10cSrcweir break; 354cdf0e10cSrcweir 355cdf0e10cSrcweir case 'e' : 356cdf0e10cSrcweir case 'E' : 357cdf0e10cSrcweir { 358cdf0e10cSrcweir if ( bMustBePositiveWholeNumbered ) 359cdf0e10cSrcweir bEnd = sal_True; 360cdf0e10cSrcweir else 361cdf0e10cSrcweir { 362cdf0e10cSrcweir if ( !bE ) 363cdf0e10cSrcweir bE = sal_True; 364cdf0e10cSrcweir else 365cdf0e10cSrcweir bEnd = sal_True; 366cdf0e10cSrcweir } 367cdf0e10cSrcweir } 368cdf0e10cSrcweir break; 369cdf0e10cSrcweir case '0' : 370cdf0e10cSrcweir case '1' : 371cdf0e10cSrcweir case '2' : 372cdf0e10cSrcweir case '3' : 373cdf0e10cSrcweir case '4' : 374cdf0e10cSrcweir case '5' : 375cdf0e10cSrcweir case '6' : 376cdf0e10cSrcweir case '7' : 377cdf0e10cSrcweir case '8' : 378cdf0e10cSrcweir case '9' : 379cdf0e10cSrcweir break; 380cdf0e10cSrcweir default: 381cdf0e10cSrcweir bEnd = sal_True; 382cdf0e10cSrcweir } 383cdf0e10cSrcweir if ( !bEnd ) 384cdf0e10cSrcweir nIndex++; 385cdf0e10cSrcweir else 386cdf0e10cSrcweir break; 387cdf0e10cSrcweir } 388cdf0e10cSrcweir if ( nIndex == nStartIndex ) 389cdf0e10cSrcweir bValid = sal_False; 390cdf0e10cSrcweir if ( bValid ) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir rtl::OUString aNumber( rParaString.copy( nStartIndex, nIndex - nStartIndex ) ); 393cdf0e10cSrcweir if ( bE || bDot ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir double fAttrDouble; 396cdf0e10cSrcweir if ( SvXMLUnitConverter::convertDouble( fAttrDouble, aNumber ) ) 397cdf0e10cSrcweir rParameter.Value <<= fAttrDouble; 398cdf0e10cSrcweir else 399cdf0e10cSrcweir bValid = sal_False; 400cdf0e10cSrcweir } 401cdf0e10cSrcweir else 402cdf0e10cSrcweir { 403cdf0e10cSrcweir sal_Int32 nValue; 404cdf0e10cSrcweir if ( SvXMLUnitConverter::convertNumber( nValue, aNumber ) ) 405cdf0e10cSrcweir rParameter.Value <<= nValue; 406cdf0e10cSrcweir else 407cdf0e10cSrcweir bValid = sal_False; 408cdf0e10cSrcweir } 409cdf0e10cSrcweir } 410cdf0e10cSrcweir } 411cdf0e10cSrcweir } 412cdf0e10cSrcweir if ( bValid ) 413*2b71a0a5SArmin Le Grand { 414*2b71a0a5SArmin Le Grand // skipping white spaces and commatas (#121507#) 415*2b71a0a5SArmin Le Grand const sal_Unicode aSpace(sal_Unicode(' ')); 416*2b71a0a5SArmin Le Grand const sal_Unicode aCommata(sal_Unicode(',')); 417*2b71a0a5SArmin Le Grand 418*2b71a0a5SArmin Le Grand while(nIndex < rParaString.getLength()) 419*2b71a0a5SArmin Le Grand { 420*2b71a0a5SArmin Le Grand const sal_Unicode aCandidate(rParaString[nIndex]); 421*2b71a0a5SArmin Le Grand 422*2b71a0a5SArmin Le Grand if(aSpace == aCandidate || aCommata == aCandidate) 423*2b71a0a5SArmin Le Grand { 424cdf0e10cSrcweir nIndex++; 425cdf0e10cSrcweir } 426*2b71a0a5SArmin Le Grand else 427*2b71a0a5SArmin Le Grand { 428*2b71a0a5SArmin Le Grand break; 429*2b71a0a5SArmin Le Grand } 430*2b71a0a5SArmin Le Grand } 431*2b71a0a5SArmin Le Grand } 432cdf0e10cSrcweir return bValid; 433cdf0e10cSrcweir } 434cdf0e10cSrcweir 435cdf0e10cSrcweir void GetPosition3D( std::vector< com::sun::star::beans::PropertyValue >& rDest, // e.g. draw:extrusion-viewpoint 436cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp, 437cdf0e10cSrcweir SvXMLUnitConverter& rUnitConverter ) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir drawing::Position3D aPosition3D; 440cdf0e10cSrcweir if ( rUnitConverter.convertPosition3D( aPosition3D, rValue ) ) 441cdf0e10cSrcweir { 442cdf0e10cSrcweir beans::PropertyValue aProp; 443cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 444cdf0e10cSrcweir aProp.Value <<= aPosition3D; 445cdf0e10cSrcweir rDest.push_back( aProp ); 446cdf0e10cSrcweir } 447cdf0e10cSrcweir } 448cdf0e10cSrcweir 449cdf0e10cSrcweir void GetDoubleSequence( std::vector< com::sun::star::beans::PropertyValue >& rDest, // e.g. draw:glue-point-leaving-directions 450cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 451cdf0e10cSrcweir { 452cdf0e10cSrcweir std::vector< double > vDirection; 453cdf0e10cSrcweir sal_Int32 nIndex = 0; 454cdf0e10cSrcweir do 455cdf0e10cSrcweir { 456cdf0e10cSrcweir double fAttrDouble; 457cdf0e10cSrcweir rtl::OUString aToken( rValue.getToken( 0, ',', nIndex ) ); 458cdf0e10cSrcweir if ( !SvXMLUnitConverter::convertDouble( fAttrDouble, aToken ) ) 459cdf0e10cSrcweir break; 460cdf0e10cSrcweir else 461cdf0e10cSrcweir vDirection.push_back( fAttrDouble ); 462cdf0e10cSrcweir } 463cdf0e10cSrcweir while ( nIndex >= 0 ); 464cdf0e10cSrcweir 465cdf0e10cSrcweir if ( !vDirection.empty() ) 466cdf0e10cSrcweir { 467cdf0e10cSrcweir uno::Sequence< double > aDirectionsSeq( vDirection.size() ); 468cdf0e10cSrcweir std::vector< double >::const_iterator aIter = vDirection.begin(); 469cdf0e10cSrcweir std::vector< double >::const_iterator aEnd = vDirection.end(); 470cdf0e10cSrcweir double* pValues = aDirectionsSeq.getArray(); 471cdf0e10cSrcweir 472cdf0e10cSrcweir while ( aIter != aEnd ) 473cdf0e10cSrcweir *pValues++ = *aIter++; 474cdf0e10cSrcweir 475cdf0e10cSrcweir beans::PropertyValue aProp; 476cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 477cdf0e10cSrcweir aProp.Value <<= aDirectionsSeq; 478cdf0e10cSrcweir rDest.push_back( aProp ); 479cdf0e10cSrcweir } 480cdf0e10cSrcweir } 481cdf0e10cSrcweir 482cdf0e10cSrcweir void GetEnhancedParameter( std::vector< com::sun::star::beans::PropertyValue >& rDest, // e.g. draw:handle-position 483cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 484cdf0e10cSrcweir { 485cdf0e10cSrcweir sal_Int32 nIndex = 0; 486cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameter aParameter; 487cdf0e10cSrcweir if ( GetNextParameter( aParameter, nIndex, rValue ) ) 488cdf0e10cSrcweir { 489cdf0e10cSrcweir beans::PropertyValue aProp; 490cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 491cdf0e10cSrcweir aProp.Value <<= aParameter; 492cdf0e10cSrcweir rDest.push_back( aProp ); 493cdf0e10cSrcweir } 494cdf0e10cSrcweir } 495cdf0e10cSrcweir 496cdf0e10cSrcweir void GetEnhancedParameterPair( std::vector< com::sun::star::beans::PropertyValue >& rDest, // e.g. draw:handle-position 497cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 498cdf0e10cSrcweir { 499cdf0e10cSrcweir sal_Int32 nIndex = 0; 500cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameterPair aParameterPair; 501cdf0e10cSrcweir if ( GetNextParameter( aParameterPair.First, nIndex, rValue ) 502cdf0e10cSrcweir && GetNextParameter( aParameterPair.Second, nIndex, rValue ) ) 503cdf0e10cSrcweir { 504cdf0e10cSrcweir beans::PropertyValue aProp; 505cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 506cdf0e10cSrcweir aProp.Value <<= aParameterPair; 507cdf0e10cSrcweir rDest.push_back( aProp ); 508cdf0e10cSrcweir } 509cdf0e10cSrcweir } 510cdf0e10cSrcweir 511cdf0e10cSrcweir sal_Int32 GetEnhancedParameterPairSequence( std::vector< com::sun::star::beans::PropertyValue >& rDest, // e.g. draw:glue-points 512cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 513cdf0e10cSrcweir { 514cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair > vParameter; 515cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameterPair aParameter; 516cdf0e10cSrcweir 517cdf0e10cSrcweir sal_Int32 nIndex = 0; 518cdf0e10cSrcweir while ( GetNextParameter( aParameter.First, nIndex, rValue ) 519cdf0e10cSrcweir && GetNextParameter( aParameter.Second, nIndex, rValue ) ) 520cdf0e10cSrcweir { 521cdf0e10cSrcweir vParameter.push_back( aParameter ); 522cdf0e10cSrcweir } 523cdf0e10cSrcweir if ( !vParameter.empty() ) 524cdf0e10cSrcweir { 525cdf0e10cSrcweir uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair > aParameterSeq( vParameter.size() ); 526cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair >::const_iterator aIter = vParameter.begin(); 527cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair >::const_iterator aEnd = vParameter.end(); 528cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameterPair* pValues = aParameterSeq.getArray(); 529cdf0e10cSrcweir 530cdf0e10cSrcweir while ( aIter != aEnd ) 531cdf0e10cSrcweir *pValues++ = *aIter++; 532cdf0e10cSrcweir 533cdf0e10cSrcweir beans::PropertyValue aProp; 534cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 535cdf0e10cSrcweir aProp.Value <<= aParameterSeq; 536cdf0e10cSrcweir rDest.push_back( aProp ); 537cdf0e10cSrcweir } 538cdf0e10cSrcweir return vParameter.size(); 539cdf0e10cSrcweir } 540cdf0e10cSrcweir 541cdf0e10cSrcweir void GetEnhancedRectangleSequence( std::vector< com::sun::star::beans::PropertyValue >& rDest, // e.g. draw:text-areas 542cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 543cdf0e10cSrcweir { 544cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeTextFrame > vTextFrame; 545cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeTextFrame aParameter; 546cdf0e10cSrcweir 547cdf0e10cSrcweir sal_Int32 nIndex = 0; 548cdf0e10cSrcweir 549cdf0e10cSrcweir while ( GetNextParameter( aParameter.TopLeft.First, nIndex, rValue ) 550cdf0e10cSrcweir && GetNextParameter( aParameter.TopLeft.Second, nIndex, rValue ) 551cdf0e10cSrcweir && GetNextParameter( aParameter.BottomRight.First, nIndex, rValue ) 552cdf0e10cSrcweir && GetNextParameter( aParameter.BottomRight.Second, nIndex, rValue ) ) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir vTextFrame.push_back( aParameter ); 555cdf0e10cSrcweir } 556cdf0e10cSrcweir if ( !vTextFrame.empty() ) 557cdf0e10cSrcweir { 558cdf0e10cSrcweir uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > aTextFrameSeq( vTextFrame.size() ); 559cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeTextFrame >::const_iterator aIter = vTextFrame.begin(); 560cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeTextFrame >::const_iterator aEnd = vTextFrame.end(); 561cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeTextFrame* pValues = aTextFrameSeq.getArray(); 562cdf0e10cSrcweir 563cdf0e10cSrcweir while ( aIter != aEnd ) 564cdf0e10cSrcweir *pValues++ = *aIter++; 565cdf0e10cSrcweir 566cdf0e10cSrcweir beans::PropertyValue aProp; 567cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 568cdf0e10cSrcweir aProp.Value <<= aTextFrameSeq; 569cdf0e10cSrcweir rDest.push_back( aProp ); 570cdf0e10cSrcweir } 571cdf0e10cSrcweir } 572cdf0e10cSrcweir 573cdf0e10cSrcweir void GetEnhancedPath( std::vector< com::sun::star::beans::PropertyValue >& rDest, // e.g. draw:enhanced-path 574cdf0e10cSrcweir const rtl::OUString& rValue ) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair > vCoordinates; 577cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment > vSegments; 578cdf0e10cSrcweir 579cdf0e10cSrcweir sal_Int32 nIndex = 0; 580cdf0e10cSrcweir sal_Int32 nParameterCount = 0; 581cdf0e10cSrcweir 582cdf0e10cSrcweir sal_Int32 nParametersNeeded = 1; 583cdf0e10cSrcweir sal_Int16 nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::MOVETO; 584cdf0e10cSrcweir 585cdf0e10cSrcweir sal_Bool bValid = sal_True; 586cdf0e10cSrcweir 587cdf0e10cSrcweir while( bValid && ( nIndex < rValue.getLength() ) ) 588cdf0e10cSrcweir { 589cdf0e10cSrcweir switch( rValue[ nIndex ] ) 590cdf0e10cSrcweir { 591cdf0e10cSrcweir case 'M' : 592cdf0e10cSrcweir { 593cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::MOVETO; 594cdf0e10cSrcweir nParametersNeeded = 1; 595cdf0e10cSrcweir nIndex++; 596cdf0e10cSrcweir } 597cdf0e10cSrcweir break; 598cdf0e10cSrcweir case 'L' : 599cdf0e10cSrcweir { 600cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LINETO; 601cdf0e10cSrcweir nParametersNeeded = 1; 602cdf0e10cSrcweir nIndex++; 603cdf0e10cSrcweir } 604cdf0e10cSrcweir break; 605cdf0e10cSrcweir case 'C' : 606cdf0e10cSrcweir { 607cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CURVETO; 608cdf0e10cSrcweir nParametersNeeded = 3; 609cdf0e10cSrcweir nIndex++; 610cdf0e10cSrcweir } 611cdf0e10cSrcweir break; 612cdf0e10cSrcweir case 'Z' : 613cdf0e10cSrcweir { 614cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOSESUBPATH; 615cdf0e10cSrcweir nParametersNeeded = 0; 616cdf0e10cSrcweir nIndex++; 617cdf0e10cSrcweir } 618cdf0e10cSrcweir break; 619cdf0e10cSrcweir case 'N' : 620cdf0e10cSrcweir { 621cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ENDSUBPATH; 622cdf0e10cSrcweir nParametersNeeded = 0; 623cdf0e10cSrcweir nIndex++; 624cdf0e10cSrcweir } 625cdf0e10cSrcweir break; 626cdf0e10cSrcweir case 'F' : 627cdf0e10cSrcweir { 628cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::NOFILL; 629cdf0e10cSrcweir nParametersNeeded = 0; 630cdf0e10cSrcweir nIndex++; 631cdf0e10cSrcweir } 632cdf0e10cSrcweir break; 633cdf0e10cSrcweir case 'S' : 634cdf0e10cSrcweir { 635cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::NOSTROKE; 636cdf0e10cSrcweir nParametersNeeded = 0; 637cdf0e10cSrcweir nIndex++; 638cdf0e10cSrcweir } 639cdf0e10cSrcweir break; 640cdf0e10cSrcweir case 'T' : 641cdf0e10cSrcweir { 642cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO; 643cdf0e10cSrcweir nParametersNeeded = 3; 644cdf0e10cSrcweir nIndex++; 645cdf0e10cSrcweir } 646cdf0e10cSrcweir break; 647cdf0e10cSrcweir case 'U' : 648cdf0e10cSrcweir { 649cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE; 650cdf0e10cSrcweir nParametersNeeded = 3; 651cdf0e10cSrcweir nIndex++; 652cdf0e10cSrcweir } 653cdf0e10cSrcweir break; 654cdf0e10cSrcweir case 'A' : 655cdf0e10cSrcweir { 656cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARCTO; 657cdf0e10cSrcweir nParametersNeeded = 4; 658cdf0e10cSrcweir nIndex++; 659cdf0e10cSrcweir } 660cdf0e10cSrcweir break; 661cdf0e10cSrcweir case 'B' : 662cdf0e10cSrcweir { 663cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARC; 664cdf0e10cSrcweir nParametersNeeded = 4; 665cdf0e10cSrcweir nIndex++; 666cdf0e10cSrcweir } 667cdf0e10cSrcweir break; 668cdf0e10cSrcweir case 'W' : 669cdf0e10cSrcweir { 670cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO; 671cdf0e10cSrcweir nParametersNeeded = 4; 672cdf0e10cSrcweir nIndex++; 673cdf0e10cSrcweir } 674cdf0e10cSrcweir break; 675cdf0e10cSrcweir case 'V' : 676cdf0e10cSrcweir { 677cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARC; 678cdf0e10cSrcweir nParametersNeeded = 4; 679cdf0e10cSrcweir nIndex++; 680cdf0e10cSrcweir } 681cdf0e10cSrcweir break; 682cdf0e10cSrcweir case 'X' : 683cdf0e10cSrcweir { 684cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX; 685cdf0e10cSrcweir nParametersNeeded = 1; 686cdf0e10cSrcweir nIndex++; 687cdf0e10cSrcweir } 688cdf0e10cSrcweir break; 689cdf0e10cSrcweir case 'Y' : 690cdf0e10cSrcweir { 691cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY; 692cdf0e10cSrcweir nParametersNeeded = 1; 693cdf0e10cSrcweir nIndex++; 694cdf0e10cSrcweir } 695cdf0e10cSrcweir break; 696cdf0e10cSrcweir case 'Q' : 697cdf0e10cSrcweir { 698cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO; 699cdf0e10cSrcweir nParametersNeeded = 2; 700cdf0e10cSrcweir nIndex++; 701cdf0e10cSrcweir } 702cdf0e10cSrcweir break; 703cdf0e10cSrcweir case ' ' : 704cdf0e10cSrcweir { 705cdf0e10cSrcweir nIndex++; 706cdf0e10cSrcweir } 707cdf0e10cSrcweir break; 708cdf0e10cSrcweir 709cdf0e10cSrcweir case '$' : 710cdf0e10cSrcweir case '?' : 711cdf0e10cSrcweir case '0' : 712cdf0e10cSrcweir case '1' : 713cdf0e10cSrcweir case '2' : 714cdf0e10cSrcweir case '3' : 715cdf0e10cSrcweir case '4' : 716cdf0e10cSrcweir case '5' : 717cdf0e10cSrcweir case '6' : 718cdf0e10cSrcweir case '7' : 719cdf0e10cSrcweir case '8' : 720cdf0e10cSrcweir case '9' : 721cdf0e10cSrcweir case '.' : 722cdf0e10cSrcweir case '-' : 723cdf0e10cSrcweir { 724cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameterPair aPair; 725cdf0e10cSrcweir if ( GetNextParameter( aPair.First, nIndex, rValue ) && 726cdf0e10cSrcweir GetNextParameter( aPair.Second, nIndex, rValue ) ) 727cdf0e10cSrcweir { 728cdf0e10cSrcweir vCoordinates.push_back( aPair ); 729cdf0e10cSrcweir nParameterCount++; 730cdf0e10cSrcweir } 731cdf0e10cSrcweir else 732cdf0e10cSrcweir bValid = sal_False; 733cdf0e10cSrcweir } 734cdf0e10cSrcweir break; 735cdf0e10cSrcweir default: 736cdf0e10cSrcweir nIndex++; 737cdf0e10cSrcweir break; 738cdf0e10cSrcweir } 739cdf0e10cSrcweir if ( !nParameterCount && !nParametersNeeded ) 740cdf0e10cSrcweir { 741cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeSegment aSegment; 742cdf0e10cSrcweir aSegment.Command = nLatestSegmentCommand; 743cdf0e10cSrcweir aSegment.Count = 0; 744cdf0e10cSrcweir vSegments.push_back( aSegment ); 745cdf0e10cSrcweir nParametersNeeded = 0x7fffffff; 746cdf0e10cSrcweir } 747cdf0e10cSrcweir else if ( nParameterCount >= nParametersNeeded ) 748cdf0e10cSrcweir { 749cdf0e10cSrcweir // check if the last command is identical, 750cdf0e10cSrcweir // if so, we just need to increment the count 751cdf0e10cSrcweir if ( !vSegments.empty() && ( vSegments[ vSegments.size() - 1 ].Command == nLatestSegmentCommand ) ) 752cdf0e10cSrcweir vSegments[ vSegments.size() -1 ].Count++; 753cdf0e10cSrcweir else 754cdf0e10cSrcweir { 755cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeSegment aSegment; 756cdf0e10cSrcweir aSegment.Command = nLatestSegmentCommand; 757cdf0e10cSrcweir aSegment.Count = 1; 758cdf0e10cSrcweir vSegments.push_back( aSegment ); 759cdf0e10cSrcweir } 760cdf0e10cSrcweir nParameterCount = 0; 761cdf0e10cSrcweir } 762cdf0e10cSrcweir } 763cdf0e10cSrcweir // adding the Coordinates property 764cdf0e10cSrcweir uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair > seqCoordinates( vCoordinates.size() ); 765cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair >::const_iterator aCoordinatesIter = vCoordinates.begin(); 766cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair >::const_iterator aCoordinatesEnd = vCoordinates.end(); 767cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameterPair* pCoordinateValues = seqCoordinates.getArray(); 768cdf0e10cSrcweir 769cdf0e10cSrcweir while ( aCoordinatesIter != aCoordinatesEnd ) 770cdf0e10cSrcweir *pCoordinateValues++ = *aCoordinatesIter++; 771cdf0e10cSrcweir 772cdf0e10cSrcweir beans::PropertyValue aProp; 773cdf0e10cSrcweir aProp.Name = EASGet( EAS_Coordinates ); 774cdf0e10cSrcweir aProp.Value <<= seqCoordinates; 775cdf0e10cSrcweir rDest.push_back( aProp ); 776cdf0e10cSrcweir 777cdf0e10cSrcweir 778cdf0e10cSrcweir // adding the Segments property 779cdf0e10cSrcweir uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments( vSegments.size() ); 780cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >::const_iterator aSegmentsIter = vSegments.begin(); 781cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >::const_iterator aSegmentsEnd = vSegments.end(); 782cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeSegment* pSegmentValues = seqSegments.getArray(); 783cdf0e10cSrcweir 784cdf0e10cSrcweir while ( aSegmentsIter != aSegmentsEnd ) 785cdf0e10cSrcweir *pSegmentValues++ = *aSegmentsIter++; 786cdf0e10cSrcweir 787cdf0e10cSrcweir aProp.Name = EASGet( EAS_Segments ); 788cdf0e10cSrcweir aProp.Value <<= seqSegments; 789cdf0e10cSrcweir rDest.push_back( aProp ); 790cdf0e10cSrcweir } 791cdf0e10cSrcweir 792cdf0e10cSrcweir void GetAdjustmentValues( std::vector< com::sun::star::beans::PropertyValue >& rDest, // draw:adjustments 793cdf0e10cSrcweir const rtl::OUString& rValue ) 794cdf0e10cSrcweir { 795cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > vAdjustmentValue; 796cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameter aParameter; 797cdf0e10cSrcweir sal_Int32 nIndex = 0; 798cdf0e10cSrcweir while ( GetNextParameter( aParameter, nIndex, rValue ) ) 799cdf0e10cSrcweir { 800cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue aAdj; 801cdf0e10cSrcweir if ( aParameter.Type == com::sun::star::drawing::EnhancedCustomShapeParameterType::NORMAL ) 802cdf0e10cSrcweir { 803cdf0e10cSrcweir aAdj.Value <<= aParameter.Value; 804cdf0e10cSrcweir aAdj.State = beans::PropertyState_DIRECT_VALUE; 805cdf0e10cSrcweir } 806cdf0e10cSrcweir else 807cdf0e10cSrcweir aAdj.State = beans::PropertyState_DEFAULT_VALUE; // this should not be, but better than setting nothing 808cdf0e10cSrcweir 809cdf0e10cSrcweir vAdjustmentValue.push_back( aAdj ); 810cdf0e10cSrcweir } 811cdf0e10cSrcweir 812cdf0e10cSrcweir sal_Int32 nAdjustmentValues = vAdjustmentValue.size(); 813cdf0e10cSrcweir if ( nAdjustmentValues ) 814cdf0e10cSrcweir { 815cdf0e10cSrcweir uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentValues( nAdjustmentValues ); 816cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue >::const_iterator aIter = vAdjustmentValue.begin(); 817cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue >::const_iterator aEnd = vAdjustmentValue.end(); 818cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue* pValues = aAdjustmentValues.getArray(); 819cdf0e10cSrcweir 820cdf0e10cSrcweir while ( aIter != aEnd ) 821cdf0e10cSrcweir *pValues++ = *aIter++; 822cdf0e10cSrcweir 823cdf0e10cSrcweir beans::PropertyValue aProp; 824cdf0e10cSrcweir aProp.Name = EASGet( EAS_AdjustmentValues ); 825cdf0e10cSrcweir aProp.Value <<= aAdjustmentValues; 826cdf0e10cSrcweir rDest.push_back( aProp ); 827cdf0e10cSrcweir } 828cdf0e10cSrcweir } 829cdf0e10cSrcweir 830cdf0e10cSrcweir void XMLEnhancedCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList ) 831cdf0e10cSrcweir { 832cdf0e10cSrcweir sal_Int16 nLength = xAttrList->getLength(); 833cdf0e10cSrcweir if ( nLength ) 834cdf0e10cSrcweir { 835cdf0e10cSrcweir sal_Int32 nAttrNumber; 836cdf0e10cSrcweir for( sal_Int16 nAttr = 0; nAttr < nLength; nAttr++ ) 837cdf0e10cSrcweir { 838cdf0e10cSrcweir rtl::OUString aLocalName; 839cdf0e10cSrcweir const rtl::OUString& rValue = xAttrList->getValueByIndex( nAttr ); 840cdf0e10cSrcweir /* sven fixme, this must be checked! sal_uInt16 nPrefix = */ GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( nAttr ), &aLocalName ); 841cdf0e10cSrcweir 842cdf0e10cSrcweir switch( EASGet( aLocalName ) ) 843cdf0e10cSrcweir { 844cdf0e10cSrcweir case EAS_type : 845cdf0e10cSrcweir GetString( mrCustomShapeGeometry, rValue, EAS_Type ); 846cdf0e10cSrcweir break; 847cdf0e10cSrcweir case EAS_mirror_horizontal : 848cdf0e10cSrcweir GetBool( mrCustomShapeGeometry, rValue, EAS_MirroredX ); 849cdf0e10cSrcweir break; 850cdf0e10cSrcweir case EAS_mirror_vertical : 851cdf0e10cSrcweir GetBool( mrCustomShapeGeometry, rValue, EAS_MirroredY ); 852cdf0e10cSrcweir break; 853cdf0e10cSrcweir case EAS_viewBox : 854cdf0e10cSrcweir { 855cdf0e10cSrcweir SdXMLImExViewBox aViewBox( rValue, GetImport().GetMM100UnitConverter() ); 856cdf0e10cSrcweir awt::Rectangle aRect( aViewBox.GetX(), aViewBox.GetY(), aViewBox.GetWidth(), aViewBox.GetHeight() ); 857cdf0e10cSrcweir beans::PropertyValue aProp; 858cdf0e10cSrcweir aProp.Name = EASGet( EAS_ViewBox ); 859cdf0e10cSrcweir aProp.Value <<= aRect; 860cdf0e10cSrcweir mrCustomShapeGeometry.push_back( aProp ); 861cdf0e10cSrcweir } 862cdf0e10cSrcweir break; 863cdf0e10cSrcweir case EAS_text_rotate_angle : 864cdf0e10cSrcweir GetDouble( mrCustomShapeGeometry, rValue, EAS_TextRotateAngle ); 865cdf0e10cSrcweir break; 866cdf0e10cSrcweir case EAS_extrusion_allowed : 867cdf0e10cSrcweir GetBool( maPath, rValue, EAS_ExtrusionAllowed ); 868cdf0e10cSrcweir break; 869cdf0e10cSrcweir case EAS_text_path_allowed : 870cdf0e10cSrcweir GetBool( maPath, rValue, EAS_TextPathAllowed ); 871cdf0e10cSrcweir break; 872cdf0e10cSrcweir case EAS_concentric_gradient_fill_allowed : 873cdf0e10cSrcweir GetBool( maPath, rValue, EAS_ConcentricGradientFillAllowed ); 874cdf0e10cSrcweir break; 875cdf0e10cSrcweir case EAS_extrusion : 876cdf0e10cSrcweir GetBool( maExtrusion, rValue, EAS_Extrusion ); 877cdf0e10cSrcweir break; 878cdf0e10cSrcweir case EAS_extrusion_brightness : 879cdf0e10cSrcweir GetDoublePercentage( maExtrusion, rValue, EAS_Brightness ); 880cdf0e10cSrcweir break; 881cdf0e10cSrcweir case EAS_extrusion_depth : 882cdf0e10cSrcweir { 883cdf0e10cSrcweir sal_Int32 nIndex = 0; 884cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameterPair aParameterPair; 885cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameter& rDepth = aParameterPair.First; 886cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameter& rFraction = aParameterPair.Second; 887cdf0e10cSrcweir if ( GetNextParameter( rDepth, nIndex, rValue ) ) 888cdf0e10cSrcweir { 889cdf0e10cSrcweir // try to catch the unit for the depth 890cdf0e10cSrcweir MapUnit eSrcUnit( SvXMLExportHelper::GetUnitFromString( rValue, MAP_100TH_MM ) ); 891cdf0e10cSrcweir 892cdf0e10cSrcweir rtl::OUStringBuffer aUnitStr; 893cdf0e10cSrcweir double fFactor = SvXMLExportHelper::GetConversionFactor( aUnitStr, MAP_100TH_MM, eSrcUnit ); 894cdf0e10cSrcweir if ( ( fFactor != 1.0 ) && ( fFactor != 0.0 ) ) 895cdf0e10cSrcweir { 896cdf0e10cSrcweir double fDepth; 897cdf0e10cSrcweir if ( rDepth.Value >>= fDepth ) 898cdf0e10cSrcweir { 899cdf0e10cSrcweir fDepth /= fFactor; 900cdf0e10cSrcweir rDepth.Value <<= fDepth; 901cdf0e10cSrcweir } 902cdf0e10cSrcweir } 903cdf0e10cSrcweir if ( rValue.matchIgnoreAsciiCase( rtl::OUString( aUnitStr ), nIndex ) ) 904cdf0e10cSrcweir nIndex += aUnitStr.getLength(); 905cdf0e10cSrcweir 906cdf0e10cSrcweir // skipping white spaces 907cdf0e10cSrcweir while( ( nIndex < rValue.getLength() ) && rValue[ nIndex ] == (sal_Unicode)' ' ) 908cdf0e10cSrcweir nIndex++; 909cdf0e10cSrcweir 910cdf0e10cSrcweir if ( GetNextParameter( rFraction, nIndex, rValue ) ) 911cdf0e10cSrcweir { 912cdf0e10cSrcweir beans::PropertyValue aProp; 913cdf0e10cSrcweir aProp.Name = EASGet( EAS_Depth ); 914cdf0e10cSrcweir aProp.Value <<= aParameterPair; 915cdf0e10cSrcweir maExtrusion.push_back( aProp ); 916cdf0e10cSrcweir } 917cdf0e10cSrcweir } 918cdf0e10cSrcweir } 919cdf0e10cSrcweir break; 920cdf0e10cSrcweir case EAS_extrusion_diffusion : 921cdf0e10cSrcweir GetDoublePercentage( maExtrusion, rValue, EAS_Diffusion ); 922cdf0e10cSrcweir break; 923cdf0e10cSrcweir case EAS_extrusion_number_of_line_segments : 924cdf0e10cSrcweir GetInt32( maExtrusion, rValue, EAS_NumberOfLineSegments ); 925cdf0e10cSrcweir break; 926cdf0e10cSrcweir case EAS_extrusion_light_face : 927cdf0e10cSrcweir GetBool( maExtrusion, rValue, EAS_LightFace ); 928cdf0e10cSrcweir break; 929cdf0e10cSrcweir case EAS_extrusion_first_light_harsh : 930cdf0e10cSrcweir GetBool( maExtrusion, rValue, EAS_FirstLightHarsh ); 931cdf0e10cSrcweir break; 932cdf0e10cSrcweir case EAS_extrusion_second_light_harsh : 933cdf0e10cSrcweir GetBool( maExtrusion, rValue, EAS_SecondLightHarsh ); 934cdf0e10cSrcweir break; 935cdf0e10cSrcweir case EAS_extrusion_first_light_level : 936cdf0e10cSrcweir GetDoublePercentage( maExtrusion, rValue, EAS_FirstLightLevel ); 937cdf0e10cSrcweir break; 938cdf0e10cSrcweir case EAS_extrusion_second_light_level : 939cdf0e10cSrcweir GetDoublePercentage( maExtrusion, rValue, EAS_SecondLightLevel ); 940cdf0e10cSrcweir break; 941cdf0e10cSrcweir case EAS_extrusion_first_light_direction : 942cdf0e10cSrcweir GetB3DVector( maExtrusion, rValue, EAS_FirstLightDirection ); 943cdf0e10cSrcweir break; 944cdf0e10cSrcweir case EAS_extrusion_second_light_direction : 945cdf0e10cSrcweir GetB3DVector( maExtrusion, rValue, EAS_SecondLightDirection ); 946cdf0e10cSrcweir break; 947cdf0e10cSrcweir case EAS_extrusion_metal : 948cdf0e10cSrcweir GetBool( maExtrusion, rValue, EAS_Metal ); 949cdf0e10cSrcweir break; 950cdf0e10cSrcweir case EAS_shade_mode : 951cdf0e10cSrcweir { 952cdf0e10cSrcweir drawing::ShadeMode eShadeMode( drawing::ShadeMode_FLAT ); 953cdf0e10cSrcweir if( IsXMLToken( rValue, XML_PHONG ) ) 954cdf0e10cSrcweir eShadeMode = drawing::ShadeMode_PHONG; 955cdf0e10cSrcweir else if ( IsXMLToken( rValue, XML_GOURAUD ) ) 956cdf0e10cSrcweir eShadeMode = drawing::ShadeMode_SMOOTH; 957cdf0e10cSrcweir else if ( IsXMLToken( rValue, XML_DRAFT ) ) 958cdf0e10cSrcweir eShadeMode = drawing::ShadeMode_DRAFT; 959cdf0e10cSrcweir 960cdf0e10cSrcweir beans::PropertyValue aProp; 961cdf0e10cSrcweir aProp.Name = EASGet( EAS_ShadeMode ); 962cdf0e10cSrcweir aProp.Value <<= eShadeMode; 963cdf0e10cSrcweir maExtrusion.push_back( aProp ); 964cdf0e10cSrcweir } 965cdf0e10cSrcweir break; 966cdf0e10cSrcweir case EAS_extrusion_rotation_angle : 967cdf0e10cSrcweir GetEnhancedParameterPair( maExtrusion, rValue, EAS_RotateAngle ); 968cdf0e10cSrcweir break; 969cdf0e10cSrcweir case EAS_extrusion_rotation_center : 970cdf0e10cSrcweir GetB3DVector( maExtrusion, rValue, EAS_RotationCenter ); 971cdf0e10cSrcweir break; 972cdf0e10cSrcweir case EAS_extrusion_shininess : 973cdf0e10cSrcweir GetDoublePercentage( maExtrusion, rValue, EAS_Shininess ); 974cdf0e10cSrcweir break; 975cdf0e10cSrcweir case EAS_extrusion_skew : 976cdf0e10cSrcweir GetEnhancedParameterPair( maExtrusion, rValue, EAS_Skew ); 977cdf0e10cSrcweir break; 978cdf0e10cSrcweir case EAS_extrusion_specularity : 979cdf0e10cSrcweir GetDoublePercentage( maExtrusion, rValue, EAS_Specularity ); 980cdf0e10cSrcweir break; 981cdf0e10cSrcweir case EAS_projection : 982cdf0e10cSrcweir { 983cdf0e10cSrcweir drawing::ProjectionMode eProjectionMode( drawing::ProjectionMode_PERSPECTIVE ); 984cdf0e10cSrcweir if( IsXMLToken( rValue, XML_PARALLEL ) ) 985cdf0e10cSrcweir eProjectionMode = drawing::ProjectionMode_PARALLEL; 986cdf0e10cSrcweir 987cdf0e10cSrcweir beans::PropertyValue aProp; 988cdf0e10cSrcweir aProp.Name = EASGet( EAS_ProjectionMode ); 989cdf0e10cSrcweir aProp.Value <<= eProjectionMode; 990cdf0e10cSrcweir maExtrusion.push_back( aProp ); 991cdf0e10cSrcweir } 992cdf0e10cSrcweir break; 993cdf0e10cSrcweir case EAS_extrusion_viewpoint : 994cdf0e10cSrcweir GetPosition3D( maExtrusion, rValue, EAS_ViewPoint, mrUnitConverter ); 995cdf0e10cSrcweir break; 996cdf0e10cSrcweir case EAS_extrusion_origin : 997cdf0e10cSrcweir GetEnhancedParameterPair( maExtrusion, rValue, EAS_Origin ); 998cdf0e10cSrcweir break; 999cdf0e10cSrcweir case EAS_extrusion_color : 1000cdf0e10cSrcweir GetBool( maExtrusion, rValue, EAS_Color ); 1001cdf0e10cSrcweir break; 1002cdf0e10cSrcweir case EAS_enhanced_path : 1003cdf0e10cSrcweir GetEnhancedPath( maPath, rValue ); 1004cdf0e10cSrcweir break; 1005cdf0e10cSrcweir case EAS_path_stretchpoint_x : 1006cdf0e10cSrcweir { 1007cdf0e10cSrcweir if ( SvXMLUnitConverter::convertNumber( nAttrNumber, rValue ) ) 1008cdf0e10cSrcweir { 1009cdf0e10cSrcweir beans::PropertyValue aProp; 1010cdf0e10cSrcweir aProp.Name = EASGet( EAS_StretchX ); 1011cdf0e10cSrcweir aProp.Value <<= nAttrNumber; 1012cdf0e10cSrcweir maPath.push_back( aProp ); 1013cdf0e10cSrcweir } 1014cdf0e10cSrcweir } 1015cdf0e10cSrcweir break; 1016cdf0e10cSrcweir case EAS_path_stretchpoint_y : 1017cdf0e10cSrcweir { 1018cdf0e10cSrcweir if ( SvXMLUnitConverter::convertNumber( nAttrNumber, rValue ) ) 1019cdf0e10cSrcweir { 1020cdf0e10cSrcweir beans::PropertyValue aProp; 1021cdf0e10cSrcweir aProp.Name = EASGet( EAS_StretchY ); 1022cdf0e10cSrcweir aProp.Value <<= nAttrNumber; 1023cdf0e10cSrcweir maPath.push_back( aProp ); 1024cdf0e10cSrcweir } 1025cdf0e10cSrcweir } 1026cdf0e10cSrcweir break; 1027cdf0e10cSrcweir case EAS_text_areas : 1028cdf0e10cSrcweir GetEnhancedRectangleSequence( maPath, rValue, EAS_TextFrames ); 1029cdf0e10cSrcweir break; 1030cdf0e10cSrcweir case EAS_glue_points : 1031cdf0e10cSrcweir { 1032cdf0e10cSrcweir sal_Int32 i, nPairs = GetEnhancedParameterPairSequence( maPath, rValue, EAS_GluePoints ); 1033cdf0e10cSrcweir GetImport().GetShapeImport()->moveGluePointMapping( mrxShape, nPairs ); 1034cdf0e10cSrcweir for ( i = 0; i < nPairs; i++ ) 1035cdf0e10cSrcweir GetImport().GetShapeImport()->addGluePointMapping( mrxShape, i + 4, i + 4 ); 1036cdf0e10cSrcweir } 1037cdf0e10cSrcweir break; 1038cdf0e10cSrcweir case EAS_glue_point_type : 1039cdf0e10cSrcweir GetEnum( maPath, rValue, EAS_GluePointType, *aXML_GluePointEnumMap ); 1040cdf0e10cSrcweir break; 1041cdf0e10cSrcweir case EAS_glue_point_leaving_directions : 1042cdf0e10cSrcweir GetDoubleSequence( maPath, rValue, EAS_GluePointLeavingDirections ); 1043cdf0e10cSrcweir break; 1044cdf0e10cSrcweir case EAS_text_path : 1045cdf0e10cSrcweir GetBool( maTextPath, rValue, EAS_TextPath ); 1046cdf0e10cSrcweir break; 1047cdf0e10cSrcweir case EAS_text_path_mode : 1048cdf0e10cSrcweir { 1049cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeTextPathMode eTextPathMode( com::sun::star::drawing::EnhancedCustomShapeTextPathMode_NORMAL ); 1050cdf0e10cSrcweir if( IsXMLToken( rValue, XML_PATH ) ) 1051cdf0e10cSrcweir eTextPathMode = com::sun::star::drawing::EnhancedCustomShapeTextPathMode_PATH; 1052cdf0e10cSrcweir else if ( IsXMLToken( rValue, XML_SHAPE ) ) 1053cdf0e10cSrcweir eTextPathMode = com::sun::star::drawing::EnhancedCustomShapeTextPathMode_SHAPE; 1054cdf0e10cSrcweir 1055cdf0e10cSrcweir beans::PropertyValue aProp; 1056cdf0e10cSrcweir aProp.Name = EASGet( EAS_TextPathMode ); 1057cdf0e10cSrcweir aProp.Value <<= eTextPathMode; 1058cdf0e10cSrcweir maTextPath.push_back( aProp ); 1059cdf0e10cSrcweir } 1060cdf0e10cSrcweir break; 1061cdf0e10cSrcweir case EAS_text_path_scale : 1062cdf0e10cSrcweir { 1063cdf0e10cSrcweir sal_Bool bScaleX = IsXMLToken( rValue, XML_SHAPE ); 1064cdf0e10cSrcweir beans::PropertyValue aProp; 1065cdf0e10cSrcweir aProp.Name = EASGet( EAS_ScaleX ); 1066cdf0e10cSrcweir aProp.Value <<= bScaleX; 1067cdf0e10cSrcweir maTextPath.push_back( aProp ); 1068cdf0e10cSrcweir } 1069cdf0e10cSrcweir break; 1070cdf0e10cSrcweir case EAS_text_path_same_letter_heights : 1071cdf0e10cSrcweir GetBool( maTextPath, rValue, EAS_SameLetterHeights ); 1072cdf0e10cSrcweir break; 1073cdf0e10cSrcweir case EAS_modifiers : 1074cdf0e10cSrcweir GetAdjustmentValues( mrCustomShapeGeometry, rValue ); 1075cdf0e10cSrcweir break; 1076cdf0e10cSrcweir default: 1077cdf0e10cSrcweir break; 1078cdf0e10cSrcweir } 1079cdf0e10cSrcweir } 1080cdf0e10cSrcweir } 1081cdf0e10cSrcweir } 1082cdf0e10cSrcweir 1083cdf0e10cSrcweir void SdXMLCustomShapePropertyMerge( std::vector< com::sun::star::beans::PropertyValue >& rPropVec, 1084cdf0e10cSrcweir const std::vector< beans::PropertyValues >& rElement, 1085cdf0e10cSrcweir const rtl::OUString& rElementName ) 1086cdf0e10cSrcweir { 1087cdf0e10cSrcweir if ( !rElement.empty() ) 1088cdf0e10cSrcweir { 1089cdf0e10cSrcweir uno::Sequence< beans::PropertyValues > aPropSeq( rElement.size() ); 1090cdf0e10cSrcweir std::vector< beans::PropertyValues >::const_iterator aIter = rElement.begin(); 1091cdf0e10cSrcweir std::vector< beans::PropertyValues >::const_iterator aEnd = rElement.end(); 1092cdf0e10cSrcweir beans::PropertyValues* pValues = aPropSeq.getArray(); 1093cdf0e10cSrcweir 1094cdf0e10cSrcweir while ( aIter != aEnd ) 1095cdf0e10cSrcweir *pValues++ = *aIter++; 1096cdf0e10cSrcweir 1097cdf0e10cSrcweir beans::PropertyValue aProp; 1098cdf0e10cSrcweir aProp.Name = rElementName; 1099cdf0e10cSrcweir aProp.Value <<= aPropSeq; 1100cdf0e10cSrcweir rPropVec.push_back( aProp ); 1101cdf0e10cSrcweir } 1102cdf0e10cSrcweir } 1103cdf0e10cSrcweir 1104cdf0e10cSrcweir void SdXMLCustomShapePropertyMerge( std::vector< com::sun::star::beans::PropertyValue >& rPropVec, 1105cdf0e10cSrcweir const std::vector< rtl::OUString >& rElement, 1106cdf0e10cSrcweir const rtl::OUString& rElementName ) 1107cdf0e10cSrcweir { 1108cdf0e10cSrcweir if ( !rElement.empty() ) 1109cdf0e10cSrcweir { 1110cdf0e10cSrcweir uno::Sequence< rtl::OUString > aPropSeq( rElement.size() ); 1111cdf0e10cSrcweir std::vector< rtl::OUString >::const_iterator aIter = rElement.begin(); 1112cdf0e10cSrcweir std::vector< rtl::OUString >::const_iterator aEnd = rElement.end(); 1113cdf0e10cSrcweir rtl::OUString* pValues = aPropSeq.getArray(); 1114cdf0e10cSrcweir 1115cdf0e10cSrcweir while ( aIter != aEnd ) 1116cdf0e10cSrcweir *pValues++ = *aIter++; 1117cdf0e10cSrcweir 1118cdf0e10cSrcweir beans::PropertyValue aProp; 1119cdf0e10cSrcweir aProp.Name = rElementName; 1120cdf0e10cSrcweir aProp.Value <<= aPropSeq; 1121cdf0e10cSrcweir rPropVec.push_back( aProp ); 1122cdf0e10cSrcweir } 1123cdf0e10cSrcweir } 1124cdf0e10cSrcweir 1125cdf0e10cSrcweir void SdXMLCustomShapePropertyMerge( std::vector< com::sun::star::beans::PropertyValue >& rPropVec, 1126cdf0e10cSrcweir const std::vector< com::sun::star::beans::PropertyValue >& rElement, 1127cdf0e10cSrcweir const rtl::OUString& rElementName ) 1128cdf0e10cSrcweir { 1129cdf0e10cSrcweir if ( !rElement.empty() ) 1130cdf0e10cSrcweir { 1131cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aPropSeq( rElement.size() ); 1132cdf0e10cSrcweir std::vector< beans::PropertyValue >::const_iterator aIter = rElement.begin(); 1133cdf0e10cSrcweir std::vector< beans::PropertyValue >::const_iterator aEnd = rElement.end(); 1134cdf0e10cSrcweir beans::PropertyValue* pValues = aPropSeq.getArray(); 1135cdf0e10cSrcweir 1136cdf0e10cSrcweir while ( aIter != aEnd ) 1137cdf0e10cSrcweir *pValues++ = *aIter++; 1138cdf0e10cSrcweir 1139cdf0e10cSrcweir beans::PropertyValue aProp; 1140cdf0e10cSrcweir aProp.Name = rElementName; 1141cdf0e10cSrcweir aProp.Value <<= aPropSeq; 1142cdf0e10cSrcweir rPropVec.push_back( aProp ); 1143cdf0e10cSrcweir } 1144cdf0e10cSrcweir } 1145cdf0e10cSrcweir 1146cdf0e10cSrcweir typedef std::hash_map< rtl::OUString, sal_Int32, rtl::OUStringHash, OUStringEqFunc> EquationHashMap; 1147cdf0e10cSrcweir 1148cdf0e10cSrcweir /* if rPara.Type is from type EnhancedCustomShapeParameterType::EQUATION, the name of the equation 1149cdf0e10cSrcweir will be converted from rtl::OUString to index */ 1150cdf0e10cSrcweir void CheckAndResolveEquationParameter( com::sun::star::drawing::EnhancedCustomShapeParameter& rPara, EquationHashMap* pH ) 1151cdf0e10cSrcweir { 1152cdf0e10cSrcweir if ( rPara.Type == com::sun::star::drawing::EnhancedCustomShapeParameterType::EQUATION ) 1153cdf0e10cSrcweir { 1154cdf0e10cSrcweir rtl::OUString aEquationName; 1155cdf0e10cSrcweir if ( rPara.Value >>= aEquationName ) 1156cdf0e10cSrcweir { 1157cdf0e10cSrcweir sal_Int32 nIndex = 0; 1158cdf0e10cSrcweir EquationHashMap::iterator aHashIter( pH->find( aEquationName ) ); 1159cdf0e10cSrcweir if ( aHashIter != pH->end() ) 1160cdf0e10cSrcweir nIndex = (*aHashIter).second; 1161cdf0e10cSrcweir rPara.Value <<= nIndex; 1162cdf0e10cSrcweir } 1163cdf0e10cSrcweir } 1164cdf0e10cSrcweir } 1165cdf0e10cSrcweir 1166cdf0e10cSrcweir void XMLEnhancedCustomShapeContext::EndElement() 1167cdf0e10cSrcweir { 1168cdf0e10cSrcweir // resolve properties that are indexing a Equation 1169cdf0e10cSrcweir if ( !maEquations.empty() ) 1170cdf0e10cSrcweir { 1171cdf0e10cSrcweir // creating hash map containing the name and index of each equation 1172cdf0e10cSrcweir EquationHashMap* pH = new EquationHashMap; 1173cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aEquationNameIter = maEquationNames.begin(); 1174cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aEquationNameEnd = maEquationNames.end(); 1175cdf0e10cSrcweir while( aEquationNameIter != aEquationNameEnd ) 1176cdf0e10cSrcweir { 1177cdf0e10cSrcweir (*pH)[ *aEquationNameIter ] = (sal_Int32)( aEquationNameIter - maEquationNames.begin() ); 1178cdf0e10cSrcweir aEquationNameIter++; 1179cdf0e10cSrcweir } 1180cdf0e10cSrcweir 1181cdf0e10cSrcweir // resolve equation 1182cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aEquationIter = maEquations.begin(); 1183cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aEquationEnd = maEquations.end(); 1184cdf0e10cSrcweir while( aEquationIter != aEquationEnd ) 1185cdf0e10cSrcweir { 1186cdf0e10cSrcweir sal_Int32 nIndexOf = 0; 1187cdf0e10cSrcweir do 1188cdf0e10cSrcweir { 1189cdf0e10cSrcweir nIndexOf = aEquationIter->indexOf( '?', nIndexOf ); 1190cdf0e10cSrcweir if ( nIndexOf != -1 ) 1191cdf0e10cSrcweir { 1192cdf0e10cSrcweir rtl::OUString aEquationName; 1193cdf0e10cSrcweir if ( GetEquationName( *aEquationIter, nIndexOf + 1, aEquationName ) ) 1194cdf0e10cSrcweir { 1195cdf0e10cSrcweir // copying first characters inclusive '?' 1196cdf0e10cSrcweir rtl::OUString aNew( aEquationIter->copy( 0, nIndexOf + 1 ) ); 1197cdf0e10cSrcweir sal_Int32 nIndex = 0; 1198cdf0e10cSrcweir EquationHashMap::iterator aHashIter( pH->find( aEquationName ) ); 1199cdf0e10cSrcweir if ( aHashIter != pH->end() ) 1200cdf0e10cSrcweir nIndex = (*aHashIter).second; 1201cdf0e10cSrcweir aNew += rtl::OUString::valueOf( nIndex ); 1202cdf0e10cSrcweir aNew += aEquationIter->copy( nIndexOf + aEquationName.getLength() + 1 ); 1203cdf0e10cSrcweir *aEquationIter = aNew; 1204cdf0e10cSrcweir } 1205cdf0e10cSrcweir nIndexOf++; 1206cdf0e10cSrcweir } 1207cdf0e10cSrcweir } 1208cdf0e10cSrcweir while( nIndexOf != -1 ); 1209cdf0e10cSrcweir aEquationIter++; 1210cdf0e10cSrcweir } 1211cdf0e10cSrcweir 1212cdf0e10cSrcweir // Path 1213cdf0e10cSrcweir sal_Int32 i; 1214cdf0e10cSrcweir std::vector< beans::PropertyValue >::iterator aPathIter = maPath.begin(); 1215cdf0e10cSrcweir std::vector< beans::PropertyValue >::iterator aPathEnd = maPath.end(); 1216cdf0e10cSrcweir while ( aPathIter != aPathEnd ) 1217cdf0e10cSrcweir { 1218cdf0e10cSrcweir switch( EASGet( aPathIter->Name ) ) 1219cdf0e10cSrcweir { 1220cdf0e10cSrcweir case EAS_Coordinates : 1221cdf0e10cSrcweir case EAS_GluePoints : 1222cdf0e10cSrcweir { 1223cdf0e10cSrcweir uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair >& rSeq = 1224cdf0e10cSrcweir *((uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair >*) 1225cdf0e10cSrcweir aPathIter->Value.getValue()); 1226cdf0e10cSrcweir for ( i = 0; i < rSeq.getLength(); i++ ) 1227cdf0e10cSrcweir { 1228cdf0e10cSrcweir CheckAndResolveEquationParameter( rSeq[ i ].First, pH ); 1229cdf0e10cSrcweir CheckAndResolveEquationParameter( rSeq[ i ].Second, pH ); 1230cdf0e10cSrcweir } 1231cdf0e10cSrcweir } 1232cdf0e10cSrcweir break; 1233cdf0e10cSrcweir case EAS_TextFrames : 1234cdf0e10cSrcweir { 1235cdf0e10cSrcweir uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame >& rSeq = 1236cdf0e10cSrcweir *((uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame >*) 1237cdf0e10cSrcweir aPathIter->Value.getValue()); 1238cdf0e10cSrcweir for ( i = 0; i < rSeq.getLength(); i++ ) 1239cdf0e10cSrcweir { 1240cdf0e10cSrcweir CheckAndResolveEquationParameter( rSeq[ i ].TopLeft.First, pH ); 1241cdf0e10cSrcweir CheckAndResolveEquationParameter( rSeq[ i ].TopLeft.Second, pH ); 1242cdf0e10cSrcweir CheckAndResolveEquationParameter( rSeq[ i ].BottomRight.First, pH ); 1243cdf0e10cSrcweir CheckAndResolveEquationParameter( rSeq[ i ].BottomRight.Second, pH ); 1244cdf0e10cSrcweir } 1245cdf0e10cSrcweir } 1246cdf0e10cSrcweir break; 1247cdf0e10cSrcweir default: 1248cdf0e10cSrcweir break; 1249cdf0e10cSrcweir } 1250cdf0e10cSrcweir aPathIter++; 1251cdf0e10cSrcweir } 1252cdf0e10cSrcweir std::vector< beans::PropertyValues >::iterator aHandleIter = maHandles.begin(); 1253cdf0e10cSrcweir std::vector< beans::PropertyValues >::iterator aHandleEnd = maHandles.end(); 1254cdf0e10cSrcweir while ( aHandleIter != aHandleEnd ) 1255cdf0e10cSrcweir { 1256cdf0e10cSrcweir beans::PropertyValue* pValues = aHandleIter->getArray(); 1257cdf0e10cSrcweir for ( i = 0; i < aHandleIter->getLength(); i++ ) 1258cdf0e10cSrcweir { 1259cdf0e10cSrcweir switch( EASGet( pValues->Name ) ) 1260cdf0e10cSrcweir { 1261cdf0e10cSrcweir case EAS_RangeYMinimum : 1262cdf0e10cSrcweir case EAS_RangeYMaximum : 1263cdf0e10cSrcweir case EAS_RangeXMinimum : 1264cdf0e10cSrcweir case EAS_RangeXMaximum : 1265cdf0e10cSrcweir case EAS_RadiusRangeMinimum : 1266cdf0e10cSrcweir case EAS_RadiusRangeMaximum : 1267cdf0e10cSrcweir { 1268cdf0e10cSrcweir CheckAndResolveEquationParameter( *((com::sun::star::drawing::EnhancedCustomShapeParameter*) 1269cdf0e10cSrcweir pValues->Value.getValue()), pH ); 1270cdf0e10cSrcweir } 1271cdf0e10cSrcweir break; 1272cdf0e10cSrcweir 1273cdf0e10cSrcweir case EAS_Position : 1274cdf0e10cSrcweir case EAS_Polar : 1275cdf0e10cSrcweir { 1276cdf0e10cSrcweir CheckAndResolveEquationParameter( (*((com::sun::star::drawing::EnhancedCustomShapeParameterPair*) 1277cdf0e10cSrcweir pValues->Value.getValue())).First, pH ); 1278cdf0e10cSrcweir CheckAndResolveEquationParameter( (*((com::sun::star::drawing::EnhancedCustomShapeParameterPair*) 1279cdf0e10cSrcweir pValues->Value.getValue())).Second, pH ); 1280cdf0e10cSrcweir } 1281cdf0e10cSrcweir break; 1282cdf0e10cSrcweir default: 1283cdf0e10cSrcweir break; 1284cdf0e10cSrcweir } 1285cdf0e10cSrcweir pValues++; 1286cdf0e10cSrcweir } 1287cdf0e10cSrcweir aHandleIter++; 1288cdf0e10cSrcweir } 1289cdf0e10cSrcweir delete pH; 1290cdf0e10cSrcweir } 1291cdf0e10cSrcweir 1292cdf0e10cSrcweir SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maExtrusion, EASGet( EAS_Extrusion ) ); 1293cdf0e10cSrcweir SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maPath, EASGet( EAS_Path ) ); 1294cdf0e10cSrcweir SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maTextPath, EASGet( EAS_TextPath ) ); 1295cdf0e10cSrcweir SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maEquations, EASGet( EAS_Equations ) ); 1296cdf0e10cSrcweir if ( !maHandles.empty() ) 1297cdf0e10cSrcweir SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maHandles, EASGet( EAS_Handles ) ); 1298cdf0e10cSrcweir } 1299cdf0e10cSrcweir 1300cdf0e10cSrcweir SvXMLImportContext* XMLEnhancedCustomShapeContext::CreateChildContext( sal_uInt16 nPrefix,const rtl::OUString& rLocalName, 1301cdf0e10cSrcweir const uno::Reference< xml::sax::XAttributeList> & xAttrList ) 1302cdf0e10cSrcweir { 1303cdf0e10cSrcweir EnhancedCustomShapeTokenEnum aTokenEnum = EASGet( rLocalName ); 1304cdf0e10cSrcweir if ( aTokenEnum == EAS_equation ) 1305cdf0e10cSrcweir { 1306cdf0e10cSrcweir sal_Int16 nLength = xAttrList->getLength(); 1307cdf0e10cSrcweir if ( nLength ) 1308cdf0e10cSrcweir { 1309cdf0e10cSrcweir rtl::OUString aFormula; 1310cdf0e10cSrcweir rtl::OUString aFormulaName; 1311cdf0e10cSrcweir for( sal_Int16 nAttr = 0; nAttr < nLength; nAttr++ ) 1312cdf0e10cSrcweir { 1313cdf0e10cSrcweir rtl::OUString aLocalName; 1314cdf0e10cSrcweir const rtl::OUString& rValue = xAttrList->getValueByIndex( nAttr ); 1315cdf0e10cSrcweir /* fixme sven, this needs to be chekced! sal_uInt16 nPrefix = */ GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( nAttr ), &aLocalName ); 1316cdf0e10cSrcweir 1317cdf0e10cSrcweir switch( EASGet( aLocalName ) ) 1318cdf0e10cSrcweir { 1319cdf0e10cSrcweir case EAS_formula : 1320cdf0e10cSrcweir aFormula = rValue; 1321cdf0e10cSrcweir break; 1322cdf0e10cSrcweir case EAS_name : 1323cdf0e10cSrcweir aFormulaName = rValue; 1324cdf0e10cSrcweir break; 1325cdf0e10cSrcweir default: 1326cdf0e10cSrcweir break; 1327cdf0e10cSrcweir } 1328cdf0e10cSrcweir } 1329cdf0e10cSrcweir if ( aFormulaName.getLength() || aFormula.getLength() ) 1330cdf0e10cSrcweir { 1331cdf0e10cSrcweir maEquations.push_back( aFormula ); 1332cdf0e10cSrcweir maEquationNames.push_back( aFormulaName ); 1333cdf0e10cSrcweir } 1334cdf0e10cSrcweir } 1335cdf0e10cSrcweir } 1336cdf0e10cSrcweir else if ( aTokenEnum == EAS_handle ) 1337cdf0e10cSrcweir { 1338cdf0e10cSrcweir std::vector< com::sun::star::beans::PropertyValue > aHandle; 1339cdf0e10cSrcweir const sal_Int16 nLength = xAttrList->getLength(); 1340cdf0e10cSrcweir for( sal_Int16 nAttr = 0; nAttr < nLength; nAttr++ ) 1341cdf0e10cSrcweir { 1342cdf0e10cSrcweir rtl::OUString aLocalName; 1343cdf0e10cSrcweir const rtl::OUString& rValue = xAttrList->getValueByIndex( nAttr ); 1344cdf0e10cSrcweir /* fixme sven, this needs to be chekced! sal_uInt16 nPrefix = */ GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( nAttr ), &aLocalName ); 1345cdf0e10cSrcweir switch( EASGet( aLocalName ) ) 1346cdf0e10cSrcweir { 1347cdf0e10cSrcweir case EAS_handle_mirror_vertical : 1348cdf0e10cSrcweir GetBool( aHandle, rValue, EAS_MirroredY ); 1349cdf0e10cSrcweir break; 1350cdf0e10cSrcweir case EAS_handle_mirror_horizontal : 1351cdf0e10cSrcweir GetBool( aHandle, rValue, EAS_MirroredX ); 1352cdf0e10cSrcweir break; 1353cdf0e10cSrcweir case EAS_handle_switched : 1354cdf0e10cSrcweir GetBool( aHandle, rValue, EAS_Switched ); 1355cdf0e10cSrcweir break; 1356cdf0e10cSrcweir case EAS_handle_position : 1357cdf0e10cSrcweir GetEnhancedParameterPair( aHandle, rValue, EAS_Position ); 1358cdf0e10cSrcweir break; 1359cdf0e10cSrcweir case EAS_handle_range_x_minimum : 1360cdf0e10cSrcweir GetEnhancedParameter( aHandle, rValue, EAS_RangeXMinimum ); 1361cdf0e10cSrcweir break; 1362cdf0e10cSrcweir case EAS_handle_range_x_maximum : 1363cdf0e10cSrcweir GetEnhancedParameter( aHandle, rValue, EAS_RangeXMaximum ); 1364cdf0e10cSrcweir break; 1365cdf0e10cSrcweir case EAS_handle_range_y_minimum : 1366cdf0e10cSrcweir GetEnhancedParameter( aHandle, rValue, EAS_RangeYMinimum ); 1367cdf0e10cSrcweir break; 1368cdf0e10cSrcweir case EAS_handle_range_y_maximum : 1369cdf0e10cSrcweir GetEnhancedParameter( aHandle, rValue, EAS_RangeYMaximum ); 1370cdf0e10cSrcweir break; 1371cdf0e10cSrcweir case EAS_handle_polar : 1372cdf0e10cSrcweir GetEnhancedParameterPair( aHandle, rValue, EAS_Polar ); 1373cdf0e10cSrcweir break; 1374cdf0e10cSrcweir case EAS_handle_radius_range_minimum : 1375cdf0e10cSrcweir GetEnhancedParameter( aHandle, rValue, EAS_RadiusRangeMinimum ); 1376cdf0e10cSrcweir break; 1377cdf0e10cSrcweir case EAS_handle_radius_range_maximum : 1378cdf0e10cSrcweir GetEnhancedParameter( aHandle, rValue, EAS_RadiusRangeMaximum ); 1379cdf0e10cSrcweir break; 1380cdf0e10cSrcweir default: 1381cdf0e10cSrcweir break; 1382cdf0e10cSrcweir } 1383cdf0e10cSrcweir } 1384cdf0e10cSrcweir beans::PropertyValues aPropSeq( aHandle.size() ); 1385cdf0e10cSrcweir std::vector< beans::PropertyValue >::const_iterator aIter = aHandle.begin(); 1386cdf0e10cSrcweir std::vector< beans::PropertyValue >::const_iterator aEnd = aHandle.end(); 1387cdf0e10cSrcweir beans::PropertyValue* pValues = aPropSeq.getArray(); 1388cdf0e10cSrcweir 1389cdf0e10cSrcweir while ( aIter != aEnd ) 1390cdf0e10cSrcweir *pValues++ = *aIter++; 1391cdf0e10cSrcweir 1392cdf0e10cSrcweir maHandles.push_back( aPropSeq ); 1393cdf0e10cSrcweir } 1394cdf0e10cSrcweir return SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList ); 1395cdf0e10cSrcweir } 1396