1*63bba73cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*63bba73cSAndrew Rist * distributed with this work for additional information 6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance 9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*63bba73cSAndrew Rist * software distributed under the License is distributed on an 15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the 17*63bba73cSAndrew Rist * specific language governing permissions and limitations 18*63bba73cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*63bba73cSAndrew Rist *************************************************************/ 21*63bba73cSAndrew Rist 22*63bba73cSAndrew 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 ) 413cdf0e10cSrcweir { // skipping white spaces 414cdf0e10cSrcweir while( ( nIndex < rParaString.getLength() ) && rParaString[ nIndex ] == (sal_Unicode)' ' ) 415cdf0e10cSrcweir nIndex++; 416cdf0e10cSrcweir } 417cdf0e10cSrcweir return bValid; 418cdf0e10cSrcweir } 419cdf0e10cSrcweir 420cdf0e10cSrcweir void GetPosition3D( std::vector< com::sun::star::beans::PropertyValue >& rDest, // e.g. draw:extrusion-viewpoint 421cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp, 422cdf0e10cSrcweir SvXMLUnitConverter& rUnitConverter ) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir drawing::Position3D aPosition3D; 425cdf0e10cSrcweir if ( rUnitConverter.convertPosition3D( aPosition3D, rValue ) ) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir beans::PropertyValue aProp; 428cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 429cdf0e10cSrcweir aProp.Value <<= aPosition3D; 430cdf0e10cSrcweir rDest.push_back( aProp ); 431cdf0e10cSrcweir } 432cdf0e10cSrcweir } 433cdf0e10cSrcweir 434cdf0e10cSrcweir void GetDoubleSequence( std::vector< com::sun::star::beans::PropertyValue >& rDest, // e.g. draw:glue-point-leaving-directions 435cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 436cdf0e10cSrcweir { 437cdf0e10cSrcweir std::vector< double > vDirection; 438cdf0e10cSrcweir sal_Int32 nIndex = 0; 439cdf0e10cSrcweir do 440cdf0e10cSrcweir { 441cdf0e10cSrcweir double fAttrDouble; 442cdf0e10cSrcweir rtl::OUString aToken( rValue.getToken( 0, ',', nIndex ) ); 443cdf0e10cSrcweir if ( !SvXMLUnitConverter::convertDouble( fAttrDouble, aToken ) ) 444cdf0e10cSrcweir break; 445cdf0e10cSrcweir else 446cdf0e10cSrcweir vDirection.push_back( fAttrDouble ); 447cdf0e10cSrcweir } 448cdf0e10cSrcweir while ( nIndex >= 0 ); 449cdf0e10cSrcweir 450cdf0e10cSrcweir if ( !vDirection.empty() ) 451cdf0e10cSrcweir { 452cdf0e10cSrcweir uno::Sequence< double > aDirectionsSeq( vDirection.size() ); 453cdf0e10cSrcweir std::vector< double >::const_iterator aIter = vDirection.begin(); 454cdf0e10cSrcweir std::vector< double >::const_iterator aEnd = vDirection.end(); 455cdf0e10cSrcweir double* pValues = aDirectionsSeq.getArray(); 456cdf0e10cSrcweir 457cdf0e10cSrcweir while ( aIter != aEnd ) 458cdf0e10cSrcweir *pValues++ = *aIter++; 459cdf0e10cSrcweir 460cdf0e10cSrcweir beans::PropertyValue aProp; 461cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 462cdf0e10cSrcweir aProp.Value <<= aDirectionsSeq; 463cdf0e10cSrcweir rDest.push_back( aProp ); 464cdf0e10cSrcweir } 465cdf0e10cSrcweir } 466cdf0e10cSrcweir 467cdf0e10cSrcweir void GetEnhancedParameter( std::vector< com::sun::star::beans::PropertyValue >& rDest, // e.g. draw:handle-position 468cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 469cdf0e10cSrcweir { 470cdf0e10cSrcweir sal_Int32 nIndex = 0; 471cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameter aParameter; 472cdf0e10cSrcweir if ( GetNextParameter( aParameter, nIndex, rValue ) ) 473cdf0e10cSrcweir { 474cdf0e10cSrcweir beans::PropertyValue aProp; 475cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 476cdf0e10cSrcweir aProp.Value <<= aParameter; 477cdf0e10cSrcweir rDest.push_back( aProp ); 478cdf0e10cSrcweir } 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir void GetEnhancedParameterPair( std::vector< com::sun::star::beans::PropertyValue >& rDest, // e.g. draw:handle-position 482cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 483cdf0e10cSrcweir { 484cdf0e10cSrcweir sal_Int32 nIndex = 0; 485cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameterPair aParameterPair; 486cdf0e10cSrcweir if ( GetNextParameter( aParameterPair.First, nIndex, rValue ) 487cdf0e10cSrcweir && GetNextParameter( aParameterPair.Second, nIndex, rValue ) ) 488cdf0e10cSrcweir { 489cdf0e10cSrcweir beans::PropertyValue aProp; 490cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 491cdf0e10cSrcweir aProp.Value <<= aParameterPair; 492cdf0e10cSrcweir rDest.push_back( aProp ); 493cdf0e10cSrcweir } 494cdf0e10cSrcweir } 495cdf0e10cSrcweir 496cdf0e10cSrcweir sal_Int32 GetEnhancedParameterPairSequence( std::vector< com::sun::star::beans::PropertyValue >& rDest, // e.g. draw:glue-points 497cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 498cdf0e10cSrcweir { 499cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair > vParameter; 500cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameterPair aParameter; 501cdf0e10cSrcweir 502cdf0e10cSrcweir sal_Int32 nIndex = 0; 503cdf0e10cSrcweir while ( GetNextParameter( aParameter.First, nIndex, rValue ) 504cdf0e10cSrcweir && GetNextParameter( aParameter.Second, nIndex, rValue ) ) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir vParameter.push_back( aParameter ); 507cdf0e10cSrcweir } 508cdf0e10cSrcweir if ( !vParameter.empty() ) 509cdf0e10cSrcweir { 510cdf0e10cSrcweir uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair > aParameterSeq( vParameter.size() ); 511cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair >::const_iterator aIter = vParameter.begin(); 512cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair >::const_iterator aEnd = vParameter.end(); 513cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameterPair* pValues = aParameterSeq.getArray(); 514cdf0e10cSrcweir 515cdf0e10cSrcweir while ( aIter != aEnd ) 516cdf0e10cSrcweir *pValues++ = *aIter++; 517cdf0e10cSrcweir 518cdf0e10cSrcweir beans::PropertyValue aProp; 519cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 520cdf0e10cSrcweir aProp.Value <<= aParameterSeq; 521cdf0e10cSrcweir rDest.push_back( aProp ); 522cdf0e10cSrcweir } 523cdf0e10cSrcweir return vParameter.size(); 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir void GetEnhancedRectangleSequence( std::vector< com::sun::star::beans::PropertyValue >& rDest, // e.g. draw:text-areas 527cdf0e10cSrcweir const rtl::OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) 528cdf0e10cSrcweir { 529cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeTextFrame > vTextFrame; 530cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeTextFrame aParameter; 531cdf0e10cSrcweir 532cdf0e10cSrcweir sal_Int32 nIndex = 0; 533cdf0e10cSrcweir 534cdf0e10cSrcweir while ( GetNextParameter( aParameter.TopLeft.First, nIndex, rValue ) 535cdf0e10cSrcweir && GetNextParameter( aParameter.TopLeft.Second, nIndex, rValue ) 536cdf0e10cSrcweir && GetNextParameter( aParameter.BottomRight.First, nIndex, rValue ) 537cdf0e10cSrcweir && GetNextParameter( aParameter.BottomRight.Second, nIndex, rValue ) ) 538cdf0e10cSrcweir { 539cdf0e10cSrcweir vTextFrame.push_back( aParameter ); 540cdf0e10cSrcweir } 541cdf0e10cSrcweir if ( !vTextFrame.empty() ) 542cdf0e10cSrcweir { 543cdf0e10cSrcweir uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > aTextFrameSeq( vTextFrame.size() ); 544cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeTextFrame >::const_iterator aIter = vTextFrame.begin(); 545cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeTextFrame >::const_iterator aEnd = vTextFrame.end(); 546cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeTextFrame* pValues = aTextFrameSeq.getArray(); 547cdf0e10cSrcweir 548cdf0e10cSrcweir while ( aIter != aEnd ) 549cdf0e10cSrcweir *pValues++ = *aIter++; 550cdf0e10cSrcweir 551cdf0e10cSrcweir beans::PropertyValue aProp; 552cdf0e10cSrcweir aProp.Name = EASGet( eDestProp ); 553cdf0e10cSrcweir aProp.Value <<= aTextFrameSeq; 554cdf0e10cSrcweir rDest.push_back( aProp ); 555cdf0e10cSrcweir } 556cdf0e10cSrcweir } 557cdf0e10cSrcweir 558cdf0e10cSrcweir void GetEnhancedPath( std::vector< com::sun::star::beans::PropertyValue >& rDest, // e.g. draw:enhanced-path 559cdf0e10cSrcweir const rtl::OUString& rValue ) 560cdf0e10cSrcweir { 561cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair > vCoordinates; 562cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment > vSegments; 563cdf0e10cSrcweir 564cdf0e10cSrcweir sal_Int32 nIndex = 0; 565cdf0e10cSrcweir sal_Int32 nParameterCount = 0; 566cdf0e10cSrcweir 567cdf0e10cSrcweir sal_Int32 nParametersNeeded = 1; 568cdf0e10cSrcweir sal_Int16 nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::MOVETO; 569cdf0e10cSrcweir 570cdf0e10cSrcweir sal_Bool bValid = sal_True; 571cdf0e10cSrcweir 572cdf0e10cSrcweir while( bValid && ( nIndex < rValue.getLength() ) ) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir switch( rValue[ nIndex ] ) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir case 'M' : 577cdf0e10cSrcweir { 578cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::MOVETO; 579cdf0e10cSrcweir nParametersNeeded = 1; 580cdf0e10cSrcweir nIndex++; 581cdf0e10cSrcweir } 582cdf0e10cSrcweir break; 583cdf0e10cSrcweir case 'L' : 584cdf0e10cSrcweir { 585cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LINETO; 586cdf0e10cSrcweir nParametersNeeded = 1; 587cdf0e10cSrcweir nIndex++; 588cdf0e10cSrcweir } 589cdf0e10cSrcweir break; 590cdf0e10cSrcweir case 'C' : 591cdf0e10cSrcweir { 592cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CURVETO; 593cdf0e10cSrcweir nParametersNeeded = 3; 594cdf0e10cSrcweir nIndex++; 595cdf0e10cSrcweir } 596cdf0e10cSrcweir break; 597cdf0e10cSrcweir case 'Z' : 598cdf0e10cSrcweir { 599cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOSESUBPATH; 600cdf0e10cSrcweir nParametersNeeded = 0; 601cdf0e10cSrcweir nIndex++; 602cdf0e10cSrcweir } 603cdf0e10cSrcweir break; 604cdf0e10cSrcweir case 'N' : 605cdf0e10cSrcweir { 606cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ENDSUBPATH; 607cdf0e10cSrcweir nParametersNeeded = 0; 608cdf0e10cSrcweir nIndex++; 609cdf0e10cSrcweir } 610cdf0e10cSrcweir break; 611cdf0e10cSrcweir case 'F' : 612cdf0e10cSrcweir { 613cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::NOFILL; 614cdf0e10cSrcweir nParametersNeeded = 0; 615cdf0e10cSrcweir nIndex++; 616cdf0e10cSrcweir } 617cdf0e10cSrcweir break; 618cdf0e10cSrcweir case 'S' : 619cdf0e10cSrcweir { 620cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::NOSTROKE; 621cdf0e10cSrcweir nParametersNeeded = 0; 622cdf0e10cSrcweir nIndex++; 623cdf0e10cSrcweir } 624cdf0e10cSrcweir break; 625cdf0e10cSrcweir case 'T' : 626cdf0e10cSrcweir { 627cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO; 628cdf0e10cSrcweir nParametersNeeded = 3; 629cdf0e10cSrcweir nIndex++; 630cdf0e10cSrcweir } 631cdf0e10cSrcweir break; 632cdf0e10cSrcweir case 'U' : 633cdf0e10cSrcweir { 634cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE; 635cdf0e10cSrcweir nParametersNeeded = 3; 636cdf0e10cSrcweir nIndex++; 637cdf0e10cSrcweir } 638cdf0e10cSrcweir break; 639cdf0e10cSrcweir case 'A' : 640cdf0e10cSrcweir { 641cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARCTO; 642cdf0e10cSrcweir nParametersNeeded = 4; 643cdf0e10cSrcweir nIndex++; 644cdf0e10cSrcweir } 645cdf0e10cSrcweir break; 646cdf0e10cSrcweir case 'B' : 647cdf0e10cSrcweir { 648cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARC; 649cdf0e10cSrcweir nParametersNeeded = 4; 650cdf0e10cSrcweir nIndex++; 651cdf0e10cSrcweir } 652cdf0e10cSrcweir break; 653cdf0e10cSrcweir case 'W' : 654cdf0e10cSrcweir { 655cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO; 656cdf0e10cSrcweir nParametersNeeded = 4; 657cdf0e10cSrcweir nIndex++; 658cdf0e10cSrcweir } 659cdf0e10cSrcweir break; 660cdf0e10cSrcweir case 'V' : 661cdf0e10cSrcweir { 662cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARC; 663cdf0e10cSrcweir nParametersNeeded = 4; 664cdf0e10cSrcweir nIndex++; 665cdf0e10cSrcweir } 666cdf0e10cSrcweir break; 667cdf0e10cSrcweir case 'X' : 668cdf0e10cSrcweir { 669cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX; 670cdf0e10cSrcweir nParametersNeeded = 1; 671cdf0e10cSrcweir nIndex++; 672cdf0e10cSrcweir } 673cdf0e10cSrcweir break; 674cdf0e10cSrcweir case 'Y' : 675cdf0e10cSrcweir { 676cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY; 677cdf0e10cSrcweir nParametersNeeded = 1; 678cdf0e10cSrcweir nIndex++; 679cdf0e10cSrcweir } 680cdf0e10cSrcweir break; 681cdf0e10cSrcweir case 'Q' : 682cdf0e10cSrcweir { 683cdf0e10cSrcweir nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO; 684cdf0e10cSrcweir nParametersNeeded = 2; 685cdf0e10cSrcweir nIndex++; 686cdf0e10cSrcweir } 687cdf0e10cSrcweir break; 688cdf0e10cSrcweir case ' ' : 689cdf0e10cSrcweir { 690cdf0e10cSrcweir nIndex++; 691cdf0e10cSrcweir } 692cdf0e10cSrcweir break; 693cdf0e10cSrcweir 694cdf0e10cSrcweir case '$' : 695cdf0e10cSrcweir case '?' : 696cdf0e10cSrcweir case '0' : 697cdf0e10cSrcweir case '1' : 698cdf0e10cSrcweir case '2' : 699cdf0e10cSrcweir case '3' : 700cdf0e10cSrcweir case '4' : 701cdf0e10cSrcweir case '5' : 702cdf0e10cSrcweir case '6' : 703cdf0e10cSrcweir case '7' : 704cdf0e10cSrcweir case '8' : 705cdf0e10cSrcweir case '9' : 706cdf0e10cSrcweir case '.' : 707cdf0e10cSrcweir case '-' : 708cdf0e10cSrcweir { 709cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameterPair aPair; 710cdf0e10cSrcweir if ( GetNextParameter( aPair.First, nIndex, rValue ) && 711cdf0e10cSrcweir GetNextParameter( aPair.Second, nIndex, rValue ) ) 712cdf0e10cSrcweir { 713cdf0e10cSrcweir vCoordinates.push_back( aPair ); 714cdf0e10cSrcweir nParameterCount++; 715cdf0e10cSrcweir } 716cdf0e10cSrcweir else 717cdf0e10cSrcweir bValid = sal_False; 718cdf0e10cSrcweir } 719cdf0e10cSrcweir break; 720cdf0e10cSrcweir default: 721cdf0e10cSrcweir nIndex++; 722cdf0e10cSrcweir break; 723cdf0e10cSrcweir } 724cdf0e10cSrcweir if ( !nParameterCount && !nParametersNeeded ) 725cdf0e10cSrcweir { 726cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeSegment aSegment; 727cdf0e10cSrcweir aSegment.Command = nLatestSegmentCommand; 728cdf0e10cSrcweir aSegment.Count = 0; 729cdf0e10cSrcweir vSegments.push_back( aSegment ); 730cdf0e10cSrcweir nParametersNeeded = 0x7fffffff; 731cdf0e10cSrcweir } 732cdf0e10cSrcweir else if ( nParameterCount >= nParametersNeeded ) 733cdf0e10cSrcweir { 734cdf0e10cSrcweir // check if the last command is identical, 735cdf0e10cSrcweir // if so, we just need to increment the count 736cdf0e10cSrcweir if ( !vSegments.empty() && ( vSegments[ vSegments.size() - 1 ].Command == nLatestSegmentCommand ) ) 737cdf0e10cSrcweir vSegments[ vSegments.size() -1 ].Count++; 738cdf0e10cSrcweir else 739cdf0e10cSrcweir { 740cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeSegment aSegment; 741cdf0e10cSrcweir aSegment.Command = nLatestSegmentCommand; 742cdf0e10cSrcweir aSegment.Count = 1; 743cdf0e10cSrcweir vSegments.push_back( aSegment ); 744cdf0e10cSrcweir } 745cdf0e10cSrcweir nParameterCount = 0; 746cdf0e10cSrcweir } 747cdf0e10cSrcweir } 748cdf0e10cSrcweir // adding the Coordinates property 749cdf0e10cSrcweir uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair > seqCoordinates( vCoordinates.size() ); 750cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair >::const_iterator aCoordinatesIter = vCoordinates.begin(); 751cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair >::const_iterator aCoordinatesEnd = vCoordinates.end(); 752cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameterPair* pCoordinateValues = seqCoordinates.getArray(); 753cdf0e10cSrcweir 754cdf0e10cSrcweir while ( aCoordinatesIter != aCoordinatesEnd ) 755cdf0e10cSrcweir *pCoordinateValues++ = *aCoordinatesIter++; 756cdf0e10cSrcweir 757cdf0e10cSrcweir beans::PropertyValue aProp; 758cdf0e10cSrcweir aProp.Name = EASGet( EAS_Coordinates ); 759cdf0e10cSrcweir aProp.Value <<= seqCoordinates; 760cdf0e10cSrcweir rDest.push_back( aProp ); 761cdf0e10cSrcweir 762cdf0e10cSrcweir 763cdf0e10cSrcweir // adding the Segments property 764cdf0e10cSrcweir uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments( vSegments.size() ); 765cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >::const_iterator aSegmentsIter = vSegments.begin(); 766cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >::const_iterator aSegmentsEnd = vSegments.end(); 767cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeSegment* pSegmentValues = seqSegments.getArray(); 768cdf0e10cSrcweir 769cdf0e10cSrcweir while ( aSegmentsIter != aSegmentsEnd ) 770cdf0e10cSrcweir *pSegmentValues++ = *aSegmentsIter++; 771cdf0e10cSrcweir 772cdf0e10cSrcweir aProp.Name = EASGet( EAS_Segments ); 773cdf0e10cSrcweir aProp.Value <<= seqSegments; 774cdf0e10cSrcweir rDest.push_back( aProp ); 775cdf0e10cSrcweir } 776cdf0e10cSrcweir 777cdf0e10cSrcweir void GetAdjustmentValues( std::vector< com::sun::star::beans::PropertyValue >& rDest, // draw:adjustments 778cdf0e10cSrcweir const rtl::OUString& rValue ) 779cdf0e10cSrcweir { 780cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > vAdjustmentValue; 781cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameter aParameter; 782cdf0e10cSrcweir sal_Int32 nIndex = 0; 783cdf0e10cSrcweir while ( GetNextParameter( aParameter, nIndex, rValue ) ) 784cdf0e10cSrcweir { 785cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue aAdj; 786cdf0e10cSrcweir if ( aParameter.Type == com::sun::star::drawing::EnhancedCustomShapeParameterType::NORMAL ) 787cdf0e10cSrcweir { 788cdf0e10cSrcweir aAdj.Value <<= aParameter.Value; 789cdf0e10cSrcweir aAdj.State = beans::PropertyState_DIRECT_VALUE; 790cdf0e10cSrcweir } 791cdf0e10cSrcweir else 792cdf0e10cSrcweir aAdj.State = beans::PropertyState_DEFAULT_VALUE; // this should not be, but better than setting nothing 793cdf0e10cSrcweir 794cdf0e10cSrcweir vAdjustmentValue.push_back( aAdj ); 795cdf0e10cSrcweir } 796cdf0e10cSrcweir 797cdf0e10cSrcweir sal_Int32 nAdjustmentValues = vAdjustmentValue.size(); 798cdf0e10cSrcweir if ( nAdjustmentValues ) 799cdf0e10cSrcweir { 800cdf0e10cSrcweir uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentValues( nAdjustmentValues ); 801cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue >::const_iterator aIter = vAdjustmentValue.begin(); 802cdf0e10cSrcweir std::vector< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue >::const_iterator aEnd = vAdjustmentValue.end(); 803cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue* pValues = aAdjustmentValues.getArray(); 804cdf0e10cSrcweir 805cdf0e10cSrcweir while ( aIter != aEnd ) 806cdf0e10cSrcweir *pValues++ = *aIter++; 807cdf0e10cSrcweir 808cdf0e10cSrcweir beans::PropertyValue aProp; 809cdf0e10cSrcweir aProp.Name = EASGet( EAS_AdjustmentValues ); 810cdf0e10cSrcweir aProp.Value <<= aAdjustmentValues; 811cdf0e10cSrcweir rDest.push_back( aProp ); 812cdf0e10cSrcweir } 813cdf0e10cSrcweir } 814cdf0e10cSrcweir 815cdf0e10cSrcweir void XMLEnhancedCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList ) 816cdf0e10cSrcweir { 817cdf0e10cSrcweir sal_Int16 nLength = xAttrList->getLength(); 818cdf0e10cSrcweir if ( nLength ) 819cdf0e10cSrcweir { 820cdf0e10cSrcweir sal_Int32 nAttrNumber; 821cdf0e10cSrcweir for( sal_Int16 nAttr = 0; nAttr < nLength; nAttr++ ) 822cdf0e10cSrcweir { 823cdf0e10cSrcweir rtl::OUString aLocalName; 824cdf0e10cSrcweir const rtl::OUString& rValue = xAttrList->getValueByIndex( nAttr ); 825cdf0e10cSrcweir /* sven fixme, this must be checked! sal_uInt16 nPrefix = */ GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( nAttr ), &aLocalName ); 826cdf0e10cSrcweir 827cdf0e10cSrcweir switch( EASGet( aLocalName ) ) 828cdf0e10cSrcweir { 829cdf0e10cSrcweir case EAS_type : 830cdf0e10cSrcweir GetString( mrCustomShapeGeometry, rValue, EAS_Type ); 831cdf0e10cSrcweir break; 832cdf0e10cSrcweir case EAS_mirror_horizontal : 833cdf0e10cSrcweir GetBool( mrCustomShapeGeometry, rValue, EAS_MirroredX ); 834cdf0e10cSrcweir break; 835cdf0e10cSrcweir case EAS_mirror_vertical : 836cdf0e10cSrcweir GetBool( mrCustomShapeGeometry, rValue, EAS_MirroredY ); 837cdf0e10cSrcweir break; 838cdf0e10cSrcweir case EAS_viewBox : 839cdf0e10cSrcweir { 840cdf0e10cSrcweir SdXMLImExViewBox aViewBox( rValue, GetImport().GetMM100UnitConverter() ); 841cdf0e10cSrcweir awt::Rectangle aRect( aViewBox.GetX(), aViewBox.GetY(), aViewBox.GetWidth(), aViewBox.GetHeight() ); 842cdf0e10cSrcweir beans::PropertyValue aProp; 843cdf0e10cSrcweir aProp.Name = EASGet( EAS_ViewBox ); 844cdf0e10cSrcweir aProp.Value <<= aRect; 845cdf0e10cSrcweir mrCustomShapeGeometry.push_back( aProp ); 846cdf0e10cSrcweir } 847cdf0e10cSrcweir break; 848cdf0e10cSrcweir case EAS_text_rotate_angle : 849cdf0e10cSrcweir GetDouble( mrCustomShapeGeometry, rValue, EAS_TextRotateAngle ); 850cdf0e10cSrcweir break; 851cdf0e10cSrcweir case EAS_extrusion_allowed : 852cdf0e10cSrcweir GetBool( maPath, rValue, EAS_ExtrusionAllowed ); 853cdf0e10cSrcweir break; 854cdf0e10cSrcweir case EAS_text_path_allowed : 855cdf0e10cSrcweir GetBool( maPath, rValue, EAS_TextPathAllowed ); 856cdf0e10cSrcweir break; 857cdf0e10cSrcweir case EAS_concentric_gradient_fill_allowed : 858cdf0e10cSrcweir GetBool( maPath, rValue, EAS_ConcentricGradientFillAllowed ); 859cdf0e10cSrcweir break; 860cdf0e10cSrcweir case EAS_extrusion : 861cdf0e10cSrcweir GetBool( maExtrusion, rValue, EAS_Extrusion ); 862cdf0e10cSrcweir break; 863cdf0e10cSrcweir case EAS_extrusion_brightness : 864cdf0e10cSrcweir GetDoublePercentage( maExtrusion, rValue, EAS_Brightness ); 865cdf0e10cSrcweir break; 866cdf0e10cSrcweir case EAS_extrusion_depth : 867cdf0e10cSrcweir { 868cdf0e10cSrcweir sal_Int32 nIndex = 0; 869cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameterPair aParameterPair; 870cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameter& rDepth = aParameterPair.First; 871cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeParameter& rFraction = aParameterPair.Second; 872cdf0e10cSrcweir if ( GetNextParameter( rDepth, nIndex, rValue ) ) 873cdf0e10cSrcweir { 874cdf0e10cSrcweir // try to catch the unit for the depth 875cdf0e10cSrcweir MapUnit eSrcUnit( SvXMLExportHelper::GetUnitFromString( rValue, MAP_100TH_MM ) ); 876cdf0e10cSrcweir 877cdf0e10cSrcweir rtl::OUStringBuffer aUnitStr; 878cdf0e10cSrcweir double fFactor = SvXMLExportHelper::GetConversionFactor( aUnitStr, MAP_100TH_MM, eSrcUnit ); 879cdf0e10cSrcweir if ( ( fFactor != 1.0 ) && ( fFactor != 0.0 ) ) 880cdf0e10cSrcweir { 881cdf0e10cSrcweir double fDepth; 882cdf0e10cSrcweir if ( rDepth.Value >>= fDepth ) 883cdf0e10cSrcweir { 884cdf0e10cSrcweir fDepth /= fFactor; 885cdf0e10cSrcweir rDepth.Value <<= fDepth; 886cdf0e10cSrcweir } 887cdf0e10cSrcweir } 888cdf0e10cSrcweir if ( rValue.matchIgnoreAsciiCase( rtl::OUString( aUnitStr ), nIndex ) ) 889cdf0e10cSrcweir nIndex += aUnitStr.getLength(); 890cdf0e10cSrcweir 891cdf0e10cSrcweir // skipping white spaces 892cdf0e10cSrcweir while( ( nIndex < rValue.getLength() ) && rValue[ nIndex ] == (sal_Unicode)' ' ) 893cdf0e10cSrcweir nIndex++; 894cdf0e10cSrcweir 895cdf0e10cSrcweir if ( GetNextParameter( rFraction, nIndex, rValue ) ) 896cdf0e10cSrcweir { 897cdf0e10cSrcweir beans::PropertyValue aProp; 898cdf0e10cSrcweir aProp.Name = EASGet( EAS_Depth ); 899cdf0e10cSrcweir aProp.Value <<= aParameterPair; 900cdf0e10cSrcweir maExtrusion.push_back( aProp ); 901cdf0e10cSrcweir } 902cdf0e10cSrcweir } 903cdf0e10cSrcweir } 904cdf0e10cSrcweir break; 905cdf0e10cSrcweir case EAS_extrusion_diffusion : 906cdf0e10cSrcweir GetDoublePercentage( maExtrusion, rValue, EAS_Diffusion ); 907cdf0e10cSrcweir break; 908cdf0e10cSrcweir case EAS_extrusion_number_of_line_segments : 909cdf0e10cSrcweir GetInt32( maExtrusion, rValue, EAS_NumberOfLineSegments ); 910cdf0e10cSrcweir break; 911cdf0e10cSrcweir case EAS_extrusion_light_face : 912cdf0e10cSrcweir GetBool( maExtrusion, rValue, EAS_LightFace ); 913cdf0e10cSrcweir break; 914cdf0e10cSrcweir case EAS_extrusion_first_light_harsh : 915cdf0e10cSrcweir GetBool( maExtrusion, rValue, EAS_FirstLightHarsh ); 916cdf0e10cSrcweir break; 917cdf0e10cSrcweir case EAS_extrusion_second_light_harsh : 918cdf0e10cSrcweir GetBool( maExtrusion, rValue, EAS_SecondLightHarsh ); 919cdf0e10cSrcweir break; 920cdf0e10cSrcweir case EAS_extrusion_first_light_level : 921cdf0e10cSrcweir GetDoublePercentage( maExtrusion, rValue, EAS_FirstLightLevel ); 922cdf0e10cSrcweir break; 923cdf0e10cSrcweir case EAS_extrusion_second_light_level : 924cdf0e10cSrcweir GetDoublePercentage( maExtrusion, rValue, EAS_SecondLightLevel ); 925cdf0e10cSrcweir break; 926cdf0e10cSrcweir case EAS_extrusion_first_light_direction : 927cdf0e10cSrcweir GetB3DVector( maExtrusion, rValue, EAS_FirstLightDirection ); 928cdf0e10cSrcweir break; 929cdf0e10cSrcweir case EAS_extrusion_second_light_direction : 930cdf0e10cSrcweir GetB3DVector( maExtrusion, rValue, EAS_SecondLightDirection ); 931cdf0e10cSrcweir break; 932cdf0e10cSrcweir case EAS_extrusion_metal : 933cdf0e10cSrcweir GetBool( maExtrusion, rValue, EAS_Metal ); 934cdf0e10cSrcweir break; 935cdf0e10cSrcweir case EAS_shade_mode : 936cdf0e10cSrcweir { 937cdf0e10cSrcweir drawing::ShadeMode eShadeMode( drawing::ShadeMode_FLAT ); 938cdf0e10cSrcweir if( IsXMLToken( rValue, XML_PHONG ) ) 939cdf0e10cSrcweir eShadeMode = drawing::ShadeMode_PHONG; 940cdf0e10cSrcweir else if ( IsXMLToken( rValue, XML_GOURAUD ) ) 941cdf0e10cSrcweir eShadeMode = drawing::ShadeMode_SMOOTH; 942cdf0e10cSrcweir else if ( IsXMLToken( rValue, XML_DRAFT ) ) 943cdf0e10cSrcweir eShadeMode = drawing::ShadeMode_DRAFT; 944cdf0e10cSrcweir 945cdf0e10cSrcweir beans::PropertyValue aProp; 946cdf0e10cSrcweir aProp.Name = EASGet( EAS_ShadeMode ); 947cdf0e10cSrcweir aProp.Value <<= eShadeMode; 948cdf0e10cSrcweir maExtrusion.push_back( aProp ); 949cdf0e10cSrcweir } 950cdf0e10cSrcweir break; 951cdf0e10cSrcweir case EAS_extrusion_rotation_angle : 952cdf0e10cSrcweir GetEnhancedParameterPair( maExtrusion, rValue, EAS_RotateAngle ); 953cdf0e10cSrcweir break; 954cdf0e10cSrcweir case EAS_extrusion_rotation_center : 955cdf0e10cSrcweir GetB3DVector( maExtrusion, rValue, EAS_RotationCenter ); 956cdf0e10cSrcweir break; 957cdf0e10cSrcweir case EAS_extrusion_shininess : 958cdf0e10cSrcweir GetDoublePercentage( maExtrusion, rValue, EAS_Shininess ); 959cdf0e10cSrcweir break; 960cdf0e10cSrcweir case EAS_extrusion_skew : 961cdf0e10cSrcweir GetEnhancedParameterPair( maExtrusion, rValue, EAS_Skew ); 962cdf0e10cSrcweir break; 963cdf0e10cSrcweir case EAS_extrusion_specularity : 964cdf0e10cSrcweir GetDoublePercentage( maExtrusion, rValue, EAS_Specularity ); 965cdf0e10cSrcweir break; 966cdf0e10cSrcweir case EAS_projection : 967cdf0e10cSrcweir { 968cdf0e10cSrcweir drawing::ProjectionMode eProjectionMode( drawing::ProjectionMode_PERSPECTIVE ); 969cdf0e10cSrcweir if( IsXMLToken( rValue, XML_PARALLEL ) ) 970cdf0e10cSrcweir eProjectionMode = drawing::ProjectionMode_PARALLEL; 971cdf0e10cSrcweir 972cdf0e10cSrcweir beans::PropertyValue aProp; 973cdf0e10cSrcweir aProp.Name = EASGet( EAS_ProjectionMode ); 974cdf0e10cSrcweir aProp.Value <<= eProjectionMode; 975cdf0e10cSrcweir maExtrusion.push_back( aProp ); 976cdf0e10cSrcweir } 977cdf0e10cSrcweir break; 978cdf0e10cSrcweir case EAS_extrusion_viewpoint : 979cdf0e10cSrcweir GetPosition3D( maExtrusion, rValue, EAS_ViewPoint, mrUnitConverter ); 980cdf0e10cSrcweir break; 981cdf0e10cSrcweir case EAS_extrusion_origin : 982cdf0e10cSrcweir GetEnhancedParameterPair( maExtrusion, rValue, EAS_Origin ); 983cdf0e10cSrcweir break; 984cdf0e10cSrcweir case EAS_extrusion_color : 985cdf0e10cSrcweir GetBool( maExtrusion, rValue, EAS_Color ); 986cdf0e10cSrcweir break; 987cdf0e10cSrcweir case EAS_enhanced_path : 988cdf0e10cSrcweir GetEnhancedPath( maPath, rValue ); 989cdf0e10cSrcweir break; 990cdf0e10cSrcweir case EAS_path_stretchpoint_x : 991cdf0e10cSrcweir { 992cdf0e10cSrcweir if ( SvXMLUnitConverter::convertNumber( nAttrNumber, rValue ) ) 993cdf0e10cSrcweir { 994cdf0e10cSrcweir beans::PropertyValue aProp; 995cdf0e10cSrcweir aProp.Name = EASGet( EAS_StretchX ); 996cdf0e10cSrcweir aProp.Value <<= nAttrNumber; 997cdf0e10cSrcweir maPath.push_back( aProp ); 998cdf0e10cSrcweir } 999cdf0e10cSrcweir } 1000cdf0e10cSrcweir break; 1001cdf0e10cSrcweir case EAS_path_stretchpoint_y : 1002cdf0e10cSrcweir { 1003cdf0e10cSrcweir if ( SvXMLUnitConverter::convertNumber( nAttrNumber, rValue ) ) 1004cdf0e10cSrcweir { 1005cdf0e10cSrcweir beans::PropertyValue aProp; 1006cdf0e10cSrcweir aProp.Name = EASGet( EAS_StretchY ); 1007cdf0e10cSrcweir aProp.Value <<= nAttrNumber; 1008cdf0e10cSrcweir maPath.push_back( aProp ); 1009cdf0e10cSrcweir } 1010cdf0e10cSrcweir } 1011cdf0e10cSrcweir break; 1012cdf0e10cSrcweir case EAS_text_areas : 1013cdf0e10cSrcweir GetEnhancedRectangleSequence( maPath, rValue, EAS_TextFrames ); 1014cdf0e10cSrcweir break; 1015cdf0e10cSrcweir case EAS_glue_points : 1016cdf0e10cSrcweir { 1017cdf0e10cSrcweir sal_Int32 i, nPairs = GetEnhancedParameterPairSequence( maPath, rValue, EAS_GluePoints ); 1018cdf0e10cSrcweir GetImport().GetShapeImport()->moveGluePointMapping( mrxShape, nPairs ); 1019cdf0e10cSrcweir for ( i = 0; i < nPairs; i++ ) 1020cdf0e10cSrcweir GetImport().GetShapeImport()->addGluePointMapping( mrxShape, i + 4, i + 4 ); 1021cdf0e10cSrcweir } 1022cdf0e10cSrcweir break; 1023cdf0e10cSrcweir case EAS_glue_point_type : 1024cdf0e10cSrcweir GetEnum( maPath, rValue, EAS_GluePointType, *aXML_GluePointEnumMap ); 1025cdf0e10cSrcweir break; 1026cdf0e10cSrcweir case EAS_glue_point_leaving_directions : 1027cdf0e10cSrcweir GetDoubleSequence( maPath, rValue, EAS_GluePointLeavingDirections ); 1028cdf0e10cSrcweir break; 1029cdf0e10cSrcweir case EAS_text_path : 1030cdf0e10cSrcweir GetBool( maTextPath, rValue, EAS_TextPath ); 1031cdf0e10cSrcweir break; 1032cdf0e10cSrcweir case EAS_text_path_mode : 1033cdf0e10cSrcweir { 1034cdf0e10cSrcweir com::sun::star::drawing::EnhancedCustomShapeTextPathMode eTextPathMode( com::sun::star::drawing::EnhancedCustomShapeTextPathMode_NORMAL ); 1035cdf0e10cSrcweir if( IsXMLToken( rValue, XML_PATH ) ) 1036cdf0e10cSrcweir eTextPathMode = com::sun::star::drawing::EnhancedCustomShapeTextPathMode_PATH; 1037cdf0e10cSrcweir else if ( IsXMLToken( rValue, XML_SHAPE ) ) 1038cdf0e10cSrcweir eTextPathMode = com::sun::star::drawing::EnhancedCustomShapeTextPathMode_SHAPE; 1039cdf0e10cSrcweir 1040cdf0e10cSrcweir beans::PropertyValue aProp; 1041cdf0e10cSrcweir aProp.Name = EASGet( EAS_TextPathMode ); 1042cdf0e10cSrcweir aProp.Value <<= eTextPathMode; 1043cdf0e10cSrcweir maTextPath.push_back( aProp ); 1044cdf0e10cSrcweir } 1045cdf0e10cSrcweir break; 1046cdf0e10cSrcweir case EAS_text_path_scale : 1047cdf0e10cSrcweir { 1048cdf0e10cSrcweir sal_Bool bScaleX = IsXMLToken( rValue, XML_SHAPE ); 1049cdf0e10cSrcweir beans::PropertyValue aProp; 1050cdf0e10cSrcweir aProp.Name = EASGet( EAS_ScaleX ); 1051cdf0e10cSrcweir aProp.Value <<= bScaleX; 1052cdf0e10cSrcweir maTextPath.push_back( aProp ); 1053cdf0e10cSrcweir } 1054cdf0e10cSrcweir break; 1055cdf0e10cSrcweir case EAS_text_path_same_letter_heights : 1056cdf0e10cSrcweir GetBool( maTextPath, rValue, EAS_SameLetterHeights ); 1057cdf0e10cSrcweir break; 1058cdf0e10cSrcweir case EAS_modifiers : 1059cdf0e10cSrcweir GetAdjustmentValues( mrCustomShapeGeometry, rValue ); 1060cdf0e10cSrcweir break; 1061cdf0e10cSrcweir default: 1062cdf0e10cSrcweir break; 1063cdf0e10cSrcweir } 1064cdf0e10cSrcweir } 1065cdf0e10cSrcweir } 1066cdf0e10cSrcweir } 1067cdf0e10cSrcweir 1068cdf0e10cSrcweir void SdXMLCustomShapePropertyMerge( std::vector< com::sun::star::beans::PropertyValue >& rPropVec, 1069cdf0e10cSrcweir const std::vector< beans::PropertyValues >& rElement, 1070cdf0e10cSrcweir const rtl::OUString& rElementName ) 1071cdf0e10cSrcweir { 1072cdf0e10cSrcweir if ( !rElement.empty() ) 1073cdf0e10cSrcweir { 1074cdf0e10cSrcweir uno::Sequence< beans::PropertyValues > aPropSeq( rElement.size() ); 1075cdf0e10cSrcweir std::vector< beans::PropertyValues >::const_iterator aIter = rElement.begin(); 1076cdf0e10cSrcweir std::vector< beans::PropertyValues >::const_iterator aEnd = rElement.end(); 1077cdf0e10cSrcweir beans::PropertyValues* pValues = aPropSeq.getArray(); 1078cdf0e10cSrcweir 1079cdf0e10cSrcweir while ( aIter != aEnd ) 1080cdf0e10cSrcweir *pValues++ = *aIter++; 1081cdf0e10cSrcweir 1082cdf0e10cSrcweir beans::PropertyValue aProp; 1083cdf0e10cSrcweir aProp.Name = rElementName; 1084cdf0e10cSrcweir aProp.Value <<= aPropSeq; 1085cdf0e10cSrcweir rPropVec.push_back( aProp ); 1086cdf0e10cSrcweir } 1087cdf0e10cSrcweir } 1088cdf0e10cSrcweir 1089cdf0e10cSrcweir void SdXMLCustomShapePropertyMerge( std::vector< com::sun::star::beans::PropertyValue >& rPropVec, 1090cdf0e10cSrcweir const std::vector< rtl::OUString >& rElement, 1091cdf0e10cSrcweir const rtl::OUString& rElementName ) 1092cdf0e10cSrcweir { 1093cdf0e10cSrcweir if ( !rElement.empty() ) 1094cdf0e10cSrcweir { 1095cdf0e10cSrcweir uno::Sequence< rtl::OUString > aPropSeq( rElement.size() ); 1096cdf0e10cSrcweir std::vector< rtl::OUString >::const_iterator aIter = rElement.begin(); 1097cdf0e10cSrcweir std::vector< rtl::OUString >::const_iterator aEnd = rElement.end(); 1098cdf0e10cSrcweir rtl::OUString* pValues = aPropSeq.getArray(); 1099cdf0e10cSrcweir 1100cdf0e10cSrcweir while ( aIter != aEnd ) 1101cdf0e10cSrcweir *pValues++ = *aIter++; 1102cdf0e10cSrcweir 1103cdf0e10cSrcweir beans::PropertyValue aProp; 1104cdf0e10cSrcweir aProp.Name = rElementName; 1105cdf0e10cSrcweir aProp.Value <<= aPropSeq; 1106cdf0e10cSrcweir rPropVec.push_back( aProp ); 1107cdf0e10cSrcweir } 1108cdf0e10cSrcweir } 1109cdf0e10cSrcweir 1110cdf0e10cSrcweir void SdXMLCustomShapePropertyMerge( std::vector< com::sun::star::beans::PropertyValue >& rPropVec, 1111cdf0e10cSrcweir const std::vector< com::sun::star::beans::PropertyValue >& rElement, 1112cdf0e10cSrcweir const rtl::OUString& rElementName ) 1113cdf0e10cSrcweir { 1114cdf0e10cSrcweir if ( !rElement.empty() ) 1115cdf0e10cSrcweir { 1116cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aPropSeq( rElement.size() ); 1117cdf0e10cSrcweir std::vector< beans::PropertyValue >::const_iterator aIter = rElement.begin(); 1118cdf0e10cSrcweir std::vector< beans::PropertyValue >::const_iterator aEnd = rElement.end(); 1119cdf0e10cSrcweir beans::PropertyValue* pValues = aPropSeq.getArray(); 1120cdf0e10cSrcweir 1121cdf0e10cSrcweir while ( aIter != aEnd ) 1122cdf0e10cSrcweir *pValues++ = *aIter++; 1123cdf0e10cSrcweir 1124cdf0e10cSrcweir beans::PropertyValue aProp; 1125cdf0e10cSrcweir aProp.Name = rElementName; 1126cdf0e10cSrcweir aProp.Value <<= aPropSeq; 1127cdf0e10cSrcweir rPropVec.push_back( aProp ); 1128cdf0e10cSrcweir } 1129cdf0e10cSrcweir } 1130cdf0e10cSrcweir 1131cdf0e10cSrcweir typedef std::hash_map< rtl::OUString, sal_Int32, rtl::OUStringHash, OUStringEqFunc> EquationHashMap; 1132cdf0e10cSrcweir 1133cdf0e10cSrcweir /* if rPara.Type is from type EnhancedCustomShapeParameterType::EQUATION, the name of the equation 1134cdf0e10cSrcweir will be converted from rtl::OUString to index */ 1135cdf0e10cSrcweir void CheckAndResolveEquationParameter( com::sun::star::drawing::EnhancedCustomShapeParameter& rPara, EquationHashMap* pH ) 1136cdf0e10cSrcweir { 1137cdf0e10cSrcweir if ( rPara.Type == com::sun::star::drawing::EnhancedCustomShapeParameterType::EQUATION ) 1138cdf0e10cSrcweir { 1139cdf0e10cSrcweir rtl::OUString aEquationName; 1140cdf0e10cSrcweir if ( rPara.Value >>= aEquationName ) 1141cdf0e10cSrcweir { 1142cdf0e10cSrcweir sal_Int32 nIndex = 0; 1143cdf0e10cSrcweir EquationHashMap::iterator aHashIter( pH->find( aEquationName ) ); 1144cdf0e10cSrcweir if ( aHashIter != pH->end() ) 1145cdf0e10cSrcweir nIndex = (*aHashIter).second; 1146cdf0e10cSrcweir rPara.Value <<= nIndex; 1147cdf0e10cSrcweir } 1148cdf0e10cSrcweir } 1149cdf0e10cSrcweir } 1150cdf0e10cSrcweir 1151cdf0e10cSrcweir void XMLEnhancedCustomShapeContext::EndElement() 1152cdf0e10cSrcweir { 1153cdf0e10cSrcweir // resolve properties that are indexing a Equation 1154cdf0e10cSrcweir if ( !maEquations.empty() ) 1155cdf0e10cSrcweir { 1156cdf0e10cSrcweir // creating hash map containing the name and index of each equation 1157cdf0e10cSrcweir EquationHashMap* pH = new EquationHashMap; 1158cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aEquationNameIter = maEquationNames.begin(); 1159cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aEquationNameEnd = maEquationNames.end(); 1160cdf0e10cSrcweir while( aEquationNameIter != aEquationNameEnd ) 1161cdf0e10cSrcweir { 1162cdf0e10cSrcweir (*pH)[ *aEquationNameIter ] = (sal_Int32)( aEquationNameIter - maEquationNames.begin() ); 1163cdf0e10cSrcweir aEquationNameIter++; 1164cdf0e10cSrcweir } 1165cdf0e10cSrcweir 1166cdf0e10cSrcweir // resolve equation 1167cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aEquationIter = maEquations.begin(); 1168cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aEquationEnd = maEquations.end(); 1169cdf0e10cSrcweir while( aEquationIter != aEquationEnd ) 1170cdf0e10cSrcweir { 1171cdf0e10cSrcweir sal_Int32 nIndexOf = 0; 1172cdf0e10cSrcweir do 1173cdf0e10cSrcweir { 1174cdf0e10cSrcweir nIndexOf = aEquationIter->indexOf( '?', nIndexOf ); 1175cdf0e10cSrcweir if ( nIndexOf != -1 ) 1176cdf0e10cSrcweir { 1177cdf0e10cSrcweir rtl::OUString aEquationName; 1178cdf0e10cSrcweir if ( GetEquationName( *aEquationIter, nIndexOf + 1, aEquationName ) ) 1179cdf0e10cSrcweir { 1180cdf0e10cSrcweir // copying first characters inclusive '?' 1181cdf0e10cSrcweir rtl::OUString aNew( aEquationIter->copy( 0, nIndexOf + 1 ) ); 1182cdf0e10cSrcweir sal_Int32 nIndex = 0; 1183cdf0e10cSrcweir EquationHashMap::iterator aHashIter( pH->find( aEquationName ) ); 1184cdf0e10cSrcweir if ( aHashIter != pH->end() ) 1185cdf0e10cSrcweir nIndex = (*aHashIter).second; 1186cdf0e10cSrcweir aNew += rtl::OUString::valueOf( nIndex ); 1187cdf0e10cSrcweir aNew += aEquationIter->copy( nIndexOf + aEquationName.getLength() + 1 ); 1188cdf0e10cSrcweir *aEquationIter = aNew; 1189cdf0e10cSrcweir } 1190cdf0e10cSrcweir nIndexOf++; 1191cdf0e10cSrcweir } 1192cdf0e10cSrcweir } 1193cdf0e10cSrcweir while( nIndexOf != -1 ); 1194cdf0e10cSrcweir aEquationIter++; 1195cdf0e10cSrcweir } 1196cdf0e10cSrcweir 1197cdf0e10cSrcweir // Path 1198cdf0e10cSrcweir sal_Int32 i; 1199cdf0e10cSrcweir std::vector< beans::PropertyValue >::iterator aPathIter = maPath.begin(); 1200cdf0e10cSrcweir std::vector< beans::PropertyValue >::iterator aPathEnd = maPath.end(); 1201cdf0e10cSrcweir while ( aPathIter != aPathEnd ) 1202cdf0e10cSrcweir { 1203cdf0e10cSrcweir switch( EASGet( aPathIter->Name ) ) 1204cdf0e10cSrcweir { 1205cdf0e10cSrcweir case EAS_Coordinates : 1206cdf0e10cSrcweir case EAS_GluePoints : 1207cdf0e10cSrcweir { 1208cdf0e10cSrcweir uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair >& rSeq = 1209cdf0e10cSrcweir *((uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair >*) 1210cdf0e10cSrcweir aPathIter->Value.getValue()); 1211cdf0e10cSrcweir for ( i = 0; i < rSeq.getLength(); i++ ) 1212cdf0e10cSrcweir { 1213cdf0e10cSrcweir CheckAndResolveEquationParameter( rSeq[ i ].First, pH ); 1214cdf0e10cSrcweir CheckAndResolveEquationParameter( rSeq[ i ].Second, pH ); 1215cdf0e10cSrcweir } 1216cdf0e10cSrcweir } 1217cdf0e10cSrcweir break; 1218cdf0e10cSrcweir case EAS_TextFrames : 1219cdf0e10cSrcweir { 1220cdf0e10cSrcweir uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame >& rSeq = 1221cdf0e10cSrcweir *((uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame >*) 1222cdf0e10cSrcweir aPathIter->Value.getValue()); 1223cdf0e10cSrcweir for ( i = 0; i < rSeq.getLength(); i++ ) 1224cdf0e10cSrcweir { 1225cdf0e10cSrcweir CheckAndResolveEquationParameter( rSeq[ i ].TopLeft.First, pH ); 1226cdf0e10cSrcweir CheckAndResolveEquationParameter( rSeq[ i ].TopLeft.Second, pH ); 1227cdf0e10cSrcweir CheckAndResolveEquationParameter( rSeq[ i ].BottomRight.First, pH ); 1228cdf0e10cSrcweir CheckAndResolveEquationParameter( rSeq[ i ].BottomRight.Second, pH ); 1229cdf0e10cSrcweir } 1230cdf0e10cSrcweir } 1231cdf0e10cSrcweir break; 1232cdf0e10cSrcweir default: 1233cdf0e10cSrcweir break; 1234cdf0e10cSrcweir } 1235cdf0e10cSrcweir aPathIter++; 1236cdf0e10cSrcweir } 1237cdf0e10cSrcweir std::vector< beans::PropertyValues >::iterator aHandleIter = maHandles.begin(); 1238cdf0e10cSrcweir std::vector< beans::PropertyValues >::iterator aHandleEnd = maHandles.end(); 1239cdf0e10cSrcweir while ( aHandleIter != aHandleEnd ) 1240cdf0e10cSrcweir { 1241cdf0e10cSrcweir beans::PropertyValue* pValues = aHandleIter->getArray(); 1242cdf0e10cSrcweir for ( i = 0; i < aHandleIter->getLength(); i++ ) 1243cdf0e10cSrcweir { 1244cdf0e10cSrcweir switch( EASGet( pValues->Name ) ) 1245cdf0e10cSrcweir { 1246cdf0e10cSrcweir case EAS_RangeYMinimum : 1247cdf0e10cSrcweir case EAS_RangeYMaximum : 1248cdf0e10cSrcweir case EAS_RangeXMinimum : 1249cdf0e10cSrcweir case EAS_RangeXMaximum : 1250cdf0e10cSrcweir case EAS_RadiusRangeMinimum : 1251cdf0e10cSrcweir case EAS_RadiusRangeMaximum : 1252cdf0e10cSrcweir { 1253cdf0e10cSrcweir CheckAndResolveEquationParameter( *((com::sun::star::drawing::EnhancedCustomShapeParameter*) 1254cdf0e10cSrcweir pValues->Value.getValue()), pH ); 1255cdf0e10cSrcweir } 1256cdf0e10cSrcweir break; 1257cdf0e10cSrcweir 1258cdf0e10cSrcweir case EAS_Position : 1259cdf0e10cSrcweir case EAS_Polar : 1260cdf0e10cSrcweir { 1261cdf0e10cSrcweir CheckAndResolveEquationParameter( (*((com::sun::star::drawing::EnhancedCustomShapeParameterPair*) 1262cdf0e10cSrcweir pValues->Value.getValue())).First, pH ); 1263cdf0e10cSrcweir CheckAndResolveEquationParameter( (*((com::sun::star::drawing::EnhancedCustomShapeParameterPair*) 1264cdf0e10cSrcweir pValues->Value.getValue())).Second, pH ); 1265cdf0e10cSrcweir } 1266cdf0e10cSrcweir break; 1267cdf0e10cSrcweir default: 1268cdf0e10cSrcweir break; 1269cdf0e10cSrcweir } 1270cdf0e10cSrcweir pValues++; 1271cdf0e10cSrcweir } 1272cdf0e10cSrcweir aHandleIter++; 1273cdf0e10cSrcweir } 1274cdf0e10cSrcweir delete pH; 1275cdf0e10cSrcweir } 1276cdf0e10cSrcweir 1277cdf0e10cSrcweir SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maExtrusion, EASGet( EAS_Extrusion ) ); 1278cdf0e10cSrcweir SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maPath, EASGet( EAS_Path ) ); 1279cdf0e10cSrcweir SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maTextPath, EASGet( EAS_TextPath ) ); 1280cdf0e10cSrcweir SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maEquations, EASGet( EAS_Equations ) ); 1281cdf0e10cSrcweir if ( !maHandles.empty() ) 1282cdf0e10cSrcweir SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maHandles, EASGet( EAS_Handles ) ); 1283cdf0e10cSrcweir } 1284cdf0e10cSrcweir 1285cdf0e10cSrcweir SvXMLImportContext* XMLEnhancedCustomShapeContext::CreateChildContext( sal_uInt16 nPrefix,const rtl::OUString& rLocalName, 1286cdf0e10cSrcweir const uno::Reference< xml::sax::XAttributeList> & xAttrList ) 1287cdf0e10cSrcweir { 1288cdf0e10cSrcweir EnhancedCustomShapeTokenEnum aTokenEnum = EASGet( rLocalName ); 1289cdf0e10cSrcweir if ( aTokenEnum == EAS_equation ) 1290cdf0e10cSrcweir { 1291cdf0e10cSrcweir sal_Int16 nLength = xAttrList->getLength(); 1292cdf0e10cSrcweir if ( nLength ) 1293cdf0e10cSrcweir { 1294cdf0e10cSrcweir rtl::OUString aFormula; 1295cdf0e10cSrcweir rtl::OUString aFormulaName; 1296cdf0e10cSrcweir for( sal_Int16 nAttr = 0; nAttr < nLength; nAttr++ ) 1297cdf0e10cSrcweir { 1298cdf0e10cSrcweir rtl::OUString aLocalName; 1299cdf0e10cSrcweir const rtl::OUString& rValue = xAttrList->getValueByIndex( nAttr ); 1300cdf0e10cSrcweir /* fixme sven, this needs to be chekced! sal_uInt16 nPrefix = */ GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( nAttr ), &aLocalName ); 1301cdf0e10cSrcweir 1302cdf0e10cSrcweir switch( EASGet( aLocalName ) ) 1303cdf0e10cSrcweir { 1304cdf0e10cSrcweir case EAS_formula : 1305cdf0e10cSrcweir aFormula = rValue; 1306cdf0e10cSrcweir break; 1307cdf0e10cSrcweir case EAS_name : 1308cdf0e10cSrcweir aFormulaName = rValue; 1309cdf0e10cSrcweir break; 1310cdf0e10cSrcweir default: 1311cdf0e10cSrcweir break; 1312cdf0e10cSrcweir } 1313cdf0e10cSrcweir } 1314cdf0e10cSrcweir if ( aFormulaName.getLength() || aFormula.getLength() ) 1315cdf0e10cSrcweir { 1316cdf0e10cSrcweir maEquations.push_back( aFormula ); 1317cdf0e10cSrcweir maEquationNames.push_back( aFormulaName ); 1318cdf0e10cSrcweir } 1319cdf0e10cSrcweir } 1320cdf0e10cSrcweir } 1321cdf0e10cSrcweir else if ( aTokenEnum == EAS_handle ) 1322cdf0e10cSrcweir { 1323cdf0e10cSrcweir std::vector< com::sun::star::beans::PropertyValue > aHandle; 1324cdf0e10cSrcweir const sal_Int16 nLength = xAttrList->getLength(); 1325cdf0e10cSrcweir for( sal_Int16 nAttr = 0; nAttr < nLength; nAttr++ ) 1326cdf0e10cSrcweir { 1327cdf0e10cSrcweir rtl::OUString aLocalName; 1328cdf0e10cSrcweir const rtl::OUString& rValue = xAttrList->getValueByIndex( nAttr ); 1329cdf0e10cSrcweir /* fixme sven, this needs to be chekced! sal_uInt16 nPrefix = */ GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( nAttr ), &aLocalName ); 1330cdf0e10cSrcweir switch( EASGet( aLocalName ) ) 1331cdf0e10cSrcweir { 1332cdf0e10cSrcweir case EAS_handle_mirror_vertical : 1333cdf0e10cSrcweir GetBool( aHandle, rValue, EAS_MirroredY ); 1334cdf0e10cSrcweir break; 1335cdf0e10cSrcweir case EAS_handle_mirror_horizontal : 1336cdf0e10cSrcweir GetBool( aHandle, rValue, EAS_MirroredX ); 1337cdf0e10cSrcweir break; 1338cdf0e10cSrcweir case EAS_handle_switched : 1339cdf0e10cSrcweir GetBool( aHandle, rValue, EAS_Switched ); 1340cdf0e10cSrcweir break; 1341cdf0e10cSrcweir case EAS_handle_position : 1342cdf0e10cSrcweir GetEnhancedParameterPair( aHandle, rValue, EAS_Position ); 1343cdf0e10cSrcweir break; 1344cdf0e10cSrcweir case EAS_handle_range_x_minimum : 1345cdf0e10cSrcweir GetEnhancedParameter( aHandle, rValue, EAS_RangeXMinimum ); 1346cdf0e10cSrcweir break; 1347cdf0e10cSrcweir case EAS_handle_range_x_maximum : 1348cdf0e10cSrcweir GetEnhancedParameter( aHandle, rValue, EAS_RangeXMaximum ); 1349cdf0e10cSrcweir break; 1350cdf0e10cSrcweir case EAS_handle_range_y_minimum : 1351cdf0e10cSrcweir GetEnhancedParameter( aHandle, rValue, EAS_RangeYMinimum ); 1352cdf0e10cSrcweir break; 1353cdf0e10cSrcweir case EAS_handle_range_y_maximum : 1354cdf0e10cSrcweir GetEnhancedParameter( aHandle, rValue, EAS_RangeYMaximum ); 1355cdf0e10cSrcweir break; 1356cdf0e10cSrcweir case EAS_handle_polar : 1357cdf0e10cSrcweir GetEnhancedParameterPair( aHandle, rValue, EAS_Polar ); 1358cdf0e10cSrcweir break; 1359cdf0e10cSrcweir case EAS_handle_radius_range_minimum : 1360cdf0e10cSrcweir GetEnhancedParameter( aHandle, rValue, EAS_RadiusRangeMinimum ); 1361cdf0e10cSrcweir break; 1362cdf0e10cSrcweir case EAS_handle_radius_range_maximum : 1363cdf0e10cSrcweir GetEnhancedParameter( aHandle, rValue, EAS_RadiusRangeMaximum ); 1364cdf0e10cSrcweir break; 1365cdf0e10cSrcweir default: 1366cdf0e10cSrcweir break; 1367cdf0e10cSrcweir } 1368cdf0e10cSrcweir } 1369cdf0e10cSrcweir beans::PropertyValues aPropSeq( aHandle.size() ); 1370cdf0e10cSrcweir std::vector< beans::PropertyValue >::const_iterator aIter = aHandle.begin(); 1371cdf0e10cSrcweir std::vector< beans::PropertyValue >::const_iterator aEnd = aHandle.end(); 1372cdf0e10cSrcweir beans::PropertyValue* pValues = aPropSeq.getArray(); 1373cdf0e10cSrcweir 1374cdf0e10cSrcweir while ( aIter != aEnd ) 1375cdf0e10cSrcweir *pValues++ = *aIter++; 1376cdf0e10cSrcweir 1377cdf0e10cSrcweir maHandles.push_back( aPropSeq ); 1378cdf0e10cSrcweir } 1379cdf0e10cSrcweir return SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList ); 1380cdf0e10cSrcweir } 1381