1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ximpcustomshape.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "ximpcustomshape.hxx"
34 #include "ximpshap.hxx"
35 #include "xmlehelp.hxx"
36 #include <rtl/math.hxx>
37 #include <rtl/ustrbuf.hxx>
38 #include <rtl/ustring.hxx>
39 #include <com/sun/star/uno/Reference.h>
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #include <com/sun/star/xml/sax/XAttributeList.hpp>
42 #include <com/sun/star/container/XIndexContainer.hpp>
43 #include <xmloff/xmltoken.hxx>
44 #include "EnhancedCustomShapeToken.hxx"
45 #include <xmloff/xmlimp.hxx>
46 #include <xmloff/xmltkmap.hxx>
47 #include "xmlnmspe.hxx"
48 #include <xmloff/nmspmap.hxx>
49 #include <xmloff/xmluconv.hxx>
50 #include "xexptran.hxx"
51 #include "xmlerror.hxx"
52 #include <tools/debug.hxx>
53 #include <com/sun/star/drawing/Direction3D.hpp>
54 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
55 #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
56 #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
57 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
58 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
59 #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
60 #include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
61 #include <com/sun/star/drawing/ProjectionMode.hpp>
64 using namespace ::com::sun::star
;
65 using namespace ::xmloff::token
;
66 using namespace ::xmloff::EnhancedCustomShapeToken
;
68 TYPEINIT1( XMLEnhancedCustomShapeContext
, SvXMLImportContext
);
70 XMLEnhancedCustomShapeContext::XMLEnhancedCustomShapeContext( SvXMLImport
& rImport
,
71 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>& rxShape
,
72 sal_uInt16 nPrefix
, const rtl::OUString
& rLocalName
,
73 std::vector
< com::sun::star::beans::PropertyValue
>& rCustomShapeGeometry
) :
74 SvXMLImportContext( rImport
, nPrefix
, rLocalName
),
75 mrUnitConverter( rImport
.GetMM100UnitConverter() ),
77 mrCustomShapeGeometry( rCustomShapeGeometry
)
81 const SvXMLEnumMapEntry aXML_GluePointEnumMap
[] =
87 { XML_TOKEN_INVALID
, 0 }
89 void GetBool( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
,
90 const rtl::OUString
& rValue
, const EnhancedCustomShapeTokenEnum eDestProp
)
93 if ( SvXMLUnitConverter::convertBool( bAttrBool
, rValue
) )
95 beans::PropertyValue aProp
;
96 aProp
.Name
= EASGet( eDestProp
);
97 aProp
.Value
<<= bAttrBool
;
98 rDest
.push_back( aProp
);
102 void GetInt32( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
,
103 const rtl::OUString
& rValue
, const EnhancedCustomShapeTokenEnum eDestProp
)
105 sal_Int32 nAttrNumber
;
106 if ( SvXMLUnitConverter::convertNumber( nAttrNumber
, rValue
) )
108 beans::PropertyValue aProp
;
109 aProp
.Name
= EASGet( eDestProp
);
110 aProp
.Value
<<= nAttrNumber
;
111 rDest
.push_back( aProp
);
115 void GetDouble( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
,
116 const rtl::OUString
& rValue
, const EnhancedCustomShapeTokenEnum eDestProp
)
119 if ( SvXMLUnitConverter::convertDouble( fAttrDouble
, rValue
) )
121 beans::PropertyValue aProp
;
122 aProp
.Name
= EASGet( eDestProp
);
123 aProp
.Value
<<= fAttrDouble
;
124 rDest
.push_back( aProp
);
128 void GetDistance( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
,
129 const rtl::OUString
& rValue
, const EnhancedCustomShapeTokenEnum eDestProp
)
132 MapUnit
eSrcUnit( SvXMLExportHelper::GetUnitFromString( rValue
, MAP_100TH_MM
) );
133 if ( SvXMLUnitConverter::convertDouble( fAttrDouble
, rValue
, eSrcUnit
, MAP_100TH_MM
) )
135 beans::PropertyValue aProp
;
136 aProp
.Name
= EASGet( eDestProp
);
137 aProp
.Value
<<= fAttrDouble
;
138 rDest
.push_back( aProp
);
142 void GetString( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
,
143 const rtl::OUString
& rValue
, const EnhancedCustomShapeTokenEnum eDestProp
)
145 beans::PropertyValue aProp
;
146 aProp
.Name
= EASGet( eDestProp
);
147 aProp
.Value
<<= rValue
;
148 rDest
.push_back( aProp
);
151 void GetEnum( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
,
152 const rtl::OUString
& rValue
, const EnhancedCustomShapeTokenEnum eDestProp
,
153 const SvXMLEnumMapEntry
& rMap
)
156 if( SvXMLUnitConverter::convertEnum( eKind
, rValue
, &rMap
) )
158 sal_Int16 nEnum
= (sal_Int16
)eKind
;
159 beans::PropertyValue aProp
;
160 aProp
.Name
= EASGet( eDestProp
);
161 aProp
.Value
<<= nEnum
;
162 rDest
.push_back( aProp
);
166 void GetDoublePercentage( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
,
167 const rtl::OUString
& rValue
, const EnhancedCustomShapeTokenEnum eDestProp
)
169 MapUnit eSrcUnit
= SvXMLExportHelper::GetUnitFromString( rValue
, MAP_100TH_MM
);
170 if ( eSrcUnit
== MAP_RELATIVE
)
172 rtl_math_ConversionStatus eStatus
;
173 double fAttrDouble
= ::rtl::math::stringToDouble( rValue
,
174 (sal_Unicode
)('.'), (sal_Unicode
)(','), &eStatus
, NULL
);
175 if ( eStatus
== rtl_math_ConversionStatus_Ok
)
177 beans::PropertyValue aProp
;
178 aProp
.Name
= EASGet( eDestProp
);
179 aProp
.Value
<<= fAttrDouble
;
180 rDest
.push_back( aProp
);
185 void GetB3DVector( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
,
186 const rtl::OUString
& rValue
, const EnhancedCustomShapeTokenEnum eDestProp
)
188 ::basegfx::B3DVector aB3DVector
;
189 if ( SvXMLUnitConverter::convertB3DVector( aB3DVector
, rValue
) )
191 drawing::Direction3D
aDirection3D( aB3DVector
.getX(), aB3DVector
.getY(), aB3DVector
.getZ() );
192 beans::PropertyValue aProp
;
193 aProp
.Name
= EASGet( eDestProp
);
194 aProp
.Value
<<= aDirection3D
;
195 rDest
.push_back( aProp
);
199 sal_Bool
GetEquationName( const rtl::OUString
& rEquation
, const sal_Int32 nStart
, rtl::OUString
& rEquationName
)
201 sal_Int32 nIndex
= nStart
;
202 while( nIndex
< rEquation
.getLength() )
204 sal_Unicode nChar
= rEquation
[ nIndex
];
206 ( ( nChar
>= 'a' ) && ( nChar
<= 'z' ) )
207 || ( ( nChar
>= 'A' ) && ( nChar
<= 'Z' ) )
208 || ( ( nChar
>= '0' ) && ( nChar
<= '9' ) )
216 sal_Bool bValid
= ( nIndex
- nStart
) != 0;
218 rEquationName
= rEquation
.copy( nStart
, nIndex
- nStart
);
222 sal_Bool
GetNextParameter( com::sun::star::drawing::EnhancedCustomShapeParameter
& rParameter
, sal_Int32
& nIndex
, const rtl::OUString
& rParaString
)
224 if ( nIndex
>= rParaString
.getLength() )
227 sal_Bool bValid
= sal_True
;
228 sal_Bool bNumberRequired
= sal_True
;
229 sal_Bool bMustBePositiveWholeNumbered
= sal_False
;
231 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::NORMAL
;
232 if ( rParaString
[ nIndex
] == (sal_Unicode
)'$' )
234 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::ADJUSTMENT
;
235 bMustBePositiveWholeNumbered
= sal_True
;
238 else if ( rParaString
[ nIndex
] == (sal_Unicode
)'?' )
241 bNumberRequired
= sal_False
;
242 rtl::OUString aEquationName
;
243 bValid
= GetEquationName( rParaString
, nIndex
, aEquationName
);
246 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::EQUATION
;
247 rParameter
.Value
<<= aEquationName
;
248 nIndex
+= aEquationName
.getLength();
251 else if ( rParaString
[ nIndex
] > (sal_Unicode
)'9' )
253 bNumberRequired
= sal_False
;
254 if ( rParaString
.matchIgnoreAsciiCaseAsciiL( "left", 4, nIndex
) )
256 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::LEFT
;
259 else if ( rParaString
.matchIgnoreAsciiCaseAsciiL( "top", 3, nIndex
) )
261 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::TOP
;
264 else if ( rParaString
.matchIgnoreAsciiCaseAsciiL( "right", 5, nIndex
) )
266 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::RIGHT
;
269 else if ( rParaString
.matchIgnoreAsciiCaseAsciiL( "bottom", 6, nIndex
) )
271 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::BOTTOM
;
274 else if ( rParaString
.matchIgnoreAsciiCaseAsciiL( "xstretch", 8, nIndex
) )
276 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::XSTRETCH
;
279 else if ( rParaString
.matchIgnoreAsciiCaseAsciiL( "ystretch", 8, nIndex
) )
281 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::YSTRETCH
;
284 else if ( rParaString
.matchIgnoreAsciiCaseAsciiL( "hasstroke", 9, nIndex
) )
286 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::HASSTROKE
;
289 else if ( rParaString
.matchIgnoreAsciiCaseAsciiL( "hasfill", 7, nIndex
) )
291 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::HASFILL
;
294 else if ( rParaString
.matchIgnoreAsciiCaseAsciiL( "width", 5, nIndex
) )
296 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::WIDTH
;
299 else if ( rParaString
.matchIgnoreAsciiCaseAsciiL( "height", 6, nIndex
) )
301 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::HEIGHT
;
304 else if ( rParaString
.matchIgnoreAsciiCaseAsciiL( "logwidth", 8, nIndex
) )
306 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::LOGWIDTH
;
309 else if ( rParaString
.matchIgnoreAsciiCaseAsciiL( "logheight", 9, nIndex
) )
311 rParameter
.Type
= com::sun::star::drawing::EnhancedCustomShapeParameterType::LOGHEIGHT
;
319 if ( bNumberRequired
)
321 sal_Int32 nStartIndex
= nIndex
;
323 sal_Bool bM
= sal_False
; // set if the value is negative
324 sal_Bool bE
= sal_False
; // set if a double is including a "E" statement
325 sal_Bool bEM
= sal_False
; // set if a double is including a "E-"statement
326 sal_Bool bDot
= sal_False
; // set if there is a dot included
327 sal_Bool bEnd
= sal_False
; // set for each value that can not be part of a double/integer
329 while( ( nIndex
< rParaString
.getLength() ) && bValid
)
331 switch( rParaString
[ nIndex
] )
335 if ( bMustBePositiveWholeNumbered
)
348 if ( bMustBePositiveWholeNumbered
)
352 if ( nStartIndex
== nIndex
)
365 if ( bMustBePositiveWholeNumbered
)
395 if ( nIndex
== nStartIndex
)
399 rtl::OUString
aNumber( rParaString
.copy( nStartIndex
, nIndex
- nStartIndex
) );
403 if ( SvXMLUnitConverter::convertDouble( fAttrDouble
, aNumber
) )
404 rParameter
.Value
<<= fAttrDouble
;
411 if ( SvXMLUnitConverter::convertNumber( nValue
, aNumber
) )
412 rParameter
.Value
<<= nValue
;
420 { // skipping white spaces
421 while( ( nIndex
< rParaString
.getLength() ) && rParaString
[ nIndex
] == (sal_Unicode
)' ' )
427 void GetPosition3D( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
, // e.g. draw:extrusion-viewpoint
428 const rtl::OUString
& rValue
, const EnhancedCustomShapeTokenEnum eDestProp
,
429 SvXMLUnitConverter
& rUnitConverter
)
431 drawing::Position3D aPosition3D
;
432 if ( rUnitConverter
.convertPosition3D( aPosition3D
, rValue
) )
434 beans::PropertyValue aProp
;
435 aProp
.Name
= EASGet( eDestProp
);
436 aProp
.Value
<<= aPosition3D
;
437 rDest
.push_back( aProp
);
441 void GetDoubleSequence( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
, // e.g. draw:glue-point-leaving-directions
442 const rtl::OUString
& rValue
, const EnhancedCustomShapeTokenEnum eDestProp
)
444 std::vector
< double > vDirection
;
445 sal_Int32 nIndex
= 0;
449 rtl::OUString
aToken( rValue
.getToken( 0, ',', nIndex
) );
450 if ( !SvXMLUnitConverter::convertDouble( fAttrDouble
, aToken
) )
453 vDirection
.push_back( fAttrDouble
);
455 while ( nIndex
>= 0 );
457 if ( !vDirection
.empty() )
459 uno::Sequence
< double > aDirectionsSeq( vDirection
.size() );
460 std::vector
< double >::const_iterator aIter
= vDirection
.begin();
461 std::vector
< double >::const_iterator aEnd
= vDirection
.end();
462 double* pValues
= aDirectionsSeq
.getArray();
464 while ( aIter
!= aEnd
)
465 *pValues
++ = *aIter
++;
467 beans::PropertyValue aProp
;
468 aProp
.Name
= EASGet( eDestProp
);
469 aProp
.Value
<<= aDirectionsSeq
;
470 rDest
.push_back( aProp
);
474 void GetEnhancedParameter( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
, // e.g. draw:handle-position
475 const rtl::OUString
& rValue
, const EnhancedCustomShapeTokenEnum eDestProp
)
477 sal_Int32 nIndex
= 0;
478 com::sun::star::drawing::EnhancedCustomShapeParameter aParameter
;
479 if ( GetNextParameter( aParameter
, nIndex
, rValue
) )
481 beans::PropertyValue aProp
;
482 aProp
.Name
= EASGet( eDestProp
);
483 aProp
.Value
<<= aParameter
;
484 rDest
.push_back( aProp
);
488 void GetEnhancedParameterPair( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
, // e.g. draw:handle-position
489 const rtl::OUString
& rValue
, const EnhancedCustomShapeTokenEnum eDestProp
)
491 sal_Int32 nIndex
= 0;
492 com::sun::star::drawing::EnhancedCustomShapeParameterPair aParameterPair
;
493 if ( GetNextParameter( aParameterPair
.First
, nIndex
, rValue
)
494 && GetNextParameter( aParameterPair
.Second
, nIndex
, rValue
) )
496 beans::PropertyValue aProp
;
497 aProp
.Name
= EASGet( eDestProp
);
498 aProp
.Value
<<= aParameterPair
;
499 rDest
.push_back( aProp
);
503 sal_Int32
GetEnhancedParameterPairSequence( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
, // e.g. draw:glue-points
504 const rtl::OUString
& rValue
, const EnhancedCustomShapeTokenEnum eDestProp
)
506 std::vector
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
> vParameter
;
507 com::sun::star::drawing::EnhancedCustomShapeParameterPair aParameter
;
509 sal_Int32 nIndex
= 0;
510 while ( GetNextParameter( aParameter
.First
, nIndex
, rValue
)
511 && GetNextParameter( aParameter
.Second
, nIndex
, rValue
) )
513 vParameter
.push_back( aParameter
);
515 if ( !vParameter
.empty() )
517 uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
> aParameterSeq( vParameter
.size() );
518 std::vector
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
>::const_iterator aIter
= vParameter
.begin();
519 std::vector
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
>::const_iterator aEnd
= vParameter
.end();
520 com::sun::star::drawing::EnhancedCustomShapeParameterPair
* pValues
= aParameterSeq
.getArray();
522 while ( aIter
!= aEnd
)
523 *pValues
++ = *aIter
++;
525 beans::PropertyValue aProp
;
526 aProp
.Name
= EASGet( eDestProp
);
527 aProp
.Value
<<= aParameterSeq
;
528 rDest
.push_back( aProp
);
530 return vParameter
.size();
533 void GetEnhancedRectangleSequence( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
, // e.g. draw:text-areas
534 const rtl::OUString
& rValue
, const EnhancedCustomShapeTokenEnum eDestProp
)
536 std::vector
< com::sun::star::drawing::EnhancedCustomShapeTextFrame
> vTextFrame
;
537 com::sun::star::drawing::EnhancedCustomShapeTextFrame aParameter
;
539 sal_Int32 nIndex
= 0;
541 while ( GetNextParameter( aParameter
.TopLeft
.First
, nIndex
, rValue
)
542 && GetNextParameter( aParameter
.TopLeft
.Second
, nIndex
, rValue
)
543 && GetNextParameter( aParameter
.BottomRight
.First
, nIndex
, rValue
)
544 && GetNextParameter( aParameter
.BottomRight
.Second
, nIndex
, rValue
) )
546 vTextFrame
.push_back( aParameter
);
548 if ( !vTextFrame
.empty() )
550 uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeTextFrame
> aTextFrameSeq( vTextFrame
.size() );
551 std::vector
< com::sun::star::drawing::EnhancedCustomShapeTextFrame
>::const_iterator aIter
= vTextFrame
.begin();
552 std::vector
< com::sun::star::drawing::EnhancedCustomShapeTextFrame
>::const_iterator aEnd
= vTextFrame
.end();
553 com::sun::star::drawing::EnhancedCustomShapeTextFrame
* pValues
= aTextFrameSeq
.getArray();
555 while ( aIter
!= aEnd
)
556 *pValues
++ = *aIter
++;
558 beans::PropertyValue aProp
;
559 aProp
.Name
= EASGet( eDestProp
);
560 aProp
.Value
<<= aTextFrameSeq
;
561 rDest
.push_back( aProp
);
565 void GetEnhancedPath( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
, // e.g. draw:enhanced-path
566 const rtl::OUString
& rValue
)
568 std::vector
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
> vCoordinates
;
569 std::vector
< com::sun::star::drawing::EnhancedCustomShapeSegment
> vSegments
;
571 sal_Int32 nIndex
= 0;
572 sal_Int32 nParameterCount
= 0;
574 sal_Int32 nParametersNeeded
= 1;
575 sal_Int16 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::MOVETO
;
577 sal_Bool bValid
= sal_True
;
579 while( bValid
&& ( nIndex
< rValue
.getLength() ) )
581 switch( rValue
[ nIndex
] )
585 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::MOVETO
;
586 nParametersNeeded
= 1;
592 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LINETO
;
593 nParametersNeeded
= 1;
599 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CURVETO
;
600 nParametersNeeded
= 3;
606 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOSESUBPATH
;
607 nParametersNeeded
= 0;
613 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ENDSUBPATH
;
614 nParametersNeeded
= 0;
620 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::NOFILL
;
621 nParametersNeeded
= 0;
627 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::NOSTROKE
;
628 nParametersNeeded
= 0;
634 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO
;
635 nParametersNeeded
= 3;
641 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE
;
642 nParametersNeeded
= 3;
648 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARCTO
;
649 nParametersNeeded
= 4;
655 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARC
;
656 nParametersNeeded
= 4;
662 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO
;
663 nParametersNeeded
= 4;
669 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARC
;
670 nParametersNeeded
= 4;
676 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX
;
677 nParametersNeeded
= 1;
683 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY
;
684 nParametersNeeded
= 1;
690 nLatestSegmentCommand
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO
;
691 nParametersNeeded
= 2;
715 com::sun::star::drawing::EnhancedCustomShapeParameterPair aPair
;
716 if ( GetNextParameter( aPair
.First
, nIndex
, rValue
) &&
717 GetNextParameter( aPair
.Second
, nIndex
, rValue
) )
719 vCoordinates
.push_back( aPair
);
730 if ( !nParameterCount
&& !nParametersNeeded
)
732 com::sun::star::drawing::EnhancedCustomShapeSegment aSegment
;
733 aSegment
.Command
= nLatestSegmentCommand
;
735 vSegments
.push_back( aSegment
);
736 nParametersNeeded
= 0x7fffffff;
738 else if ( nParameterCount
>= nParametersNeeded
)
740 // check if the last command is identical,
741 // if so, we just need to increment the count
742 if ( !vSegments
.empty() && ( vSegments
[ vSegments
.size() - 1 ].Command
== nLatestSegmentCommand
) )
743 vSegments
[ vSegments
.size() -1 ].Count
++;
746 com::sun::star::drawing::EnhancedCustomShapeSegment aSegment
;
747 aSegment
.Command
= nLatestSegmentCommand
;
749 vSegments
.push_back( aSegment
);
754 // adding the Coordinates property
755 uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
> seqCoordinates( vCoordinates
.size() );
756 std::vector
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
>::const_iterator aCoordinatesIter
= vCoordinates
.begin();
757 std::vector
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
>::const_iterator aCoordinatesEnd
= vCoordinates
.end();
758 com::sun::star::drawing::EnhancedCustomShapeParameterPair
* pCoordinateValues
= seqCoordinates
.getArray();
760 while ( aCoordinatesIter
!= aCoordinatesEnd
)
761 *pCoordinateValues
++ = *aCoordinatesIter
++;
763 beans::PropertyValue aProp
;
764 aProp
.Name
= EASGet( EAS_Coordinates
);
765 aProp
.Value
<<= seqCoordinates
;
766 rDest
.push_back( aProp
);
769 // adding the Segments property
770 uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeSegment
> seqSegments( vSegments
.size() );
771 std::vector
< com::sun::star::drawing::EnhancedCustomShapeSegment
>::const_iterator aSegmentsIter
= vSegments
.begin();
772 std::vector
< com::sun::star::drawing::EnhancedCustomShapeSegment
>::const_iterator aSegmentsEnd
= vSegments
.end();
773 com::sun::star::drawing::EnhancedCustomShapeSegment
* pSegmentValues
= seqSegments
.getArray();
775 while ( aSegmentsIter
!= aSegmentsEnd
)
776 *pSegmentValues
++ = *aSegmentsIter
++;
778 aProp
.Name
= EASGet( EAS_Segments
);
779 aProp
.Value
<<= seqSegments
;
780 rDest
.push_back( aProp
);
783 void GetAdjustmentValues( std::vector
< com::sun::star::beans::PropertyValue
>& rDest
, // draw:adjustments
784 const rtl::OUString
& rValue
)
786 std::vector
< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue
> vAdjustmentValue
;
787 com::sun::star::drawing::EnhancedCustomShapeParameter aParameter
;
788 sal_Int32 nIndex
= 0;
789 while ( GetNextParameter( aParameter
, nIndex
, rValue
) )
791 com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue aAdj
;
792 if ( aParameter
.Type
== com::sun::star::drawing::EnhancedCustomShapeParameterType::NORMAL
)
794 aAdj
.Value
<<= aParameter
.Value
;
795 aAdj
.State
= beans::PropertyState_DIRECT_VALUE
;
798 aAdj
.State
= beans::PropertyState_DEFAULT_VALUE
; // this should not be, but better than setting nothing
800 vAdjustmentValue
.push_back( aAdj
);
803 sal_Int32 nAdjustmentValues
= vAdjustmentValue
.size();
804 if ( nAdjustmentValues
)
806 uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue
> aAdjustmentValues( nAdjustmentValues
);
807 std::vector
< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue
>::const_iterator aIter
= vAdjustmentValue
.begin();
808 std::vector
< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue
>::const_iterator aEnd
= vAdjustmentValue
.end();
809 com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue
* pValues
= aAdjustmentValues
.getArray();
811 while ( aIter
!= aEnd
)
812 *pValues
++ = *aIter
++;
814 beans::PropertyValue aProp
;
815 aProp
.Name
= EASGet( EAS_AdjustmentValues
);
816 aProp
.Value
<<= aAdjustmentValues
;
817 rDest
.push_back( aProp
);
821 void XMLEnhancedCustomShapeContext::StartElement( const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
823 sal_Int16 nLength
= xAttrList
->getLength();
826 sal_Int32 nAttrNumber
;
827 for( sal_Int16 nAttr
= 0; nAttr
< nLength
; nAttr
++ )
829 rtl::OUString aLocalName
;
830 const rtl::OUString
& rValue
= xAttrList
->getValueByIndex( nAttr
);
831 /* sven fixme, this must be checked! sal_uInt16 nPrefix = */ GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList
->getNameByIndex( nAttr
), &aLocalName
);
833 switch( EASGet( aLocalName
) )
836 GetString( mrCustomShapeGeometry
, rValue
, EAS_Type
);
838 case EAS_mirror_horizontal
:
839 GetBool( mrCustomShapeGeometry
, rValue
, EAS_MirroredX
);
841 case EAS_mirror_vertical
:
842 GetBool( mrCustomShapeGeometry
, rValue
, EAS_MirroredY
);
846 SdXMLImExViewBox
aViewBox( rValue
, GetImport().GetMM100UnitConverter() );
847 awt::Rectangle
aRect( aViewBox
.GetX(), aViewBox
.GetY(), aViewBox
.GetWidth(), aViewBox
.GetHeight() );
848 beans::PropertyValue aProp
;
849 aProp
.Name
= EASGet( EAS_ViewBox
);
850 aProp
.Value
<<= aRect
;
851 mrCustomShapeGeometry
.push_back( aProp
);
854 case EAS_text_rotate_angle
:
855 GetDouble( mrCustomShapeGeometry
, rValue
, EAS_TextRotateAngle
);
857 case EAS_extrusion_allowed
:
858 GetBool( maPath
, rValue
, EAS_ExtrusionAllowed
);
860 case EAS_text_path_allowed
:
861 GetBool( maPath
, rValue
, EAS_TextPathAllowed
);
863 case EAS_concentric_gradient_fill_allowed
:
864 GetBool( maPath
, rValue
, EAS_ConcentricGradientFillAllowed
);
867 GetBool( maExtrusion
, rValue
, EAS_Extrusion
);
869 case EAS_extrusion_brightness
:
870 GetDoublePercentage( maExtrusion
, rValue
, EAS_Brightness
);
872 case EAS_extrusion_depth
:
874 sal_Int32 nIndex
= 0;
875 com::sun::star::drawing::EnhancedCustomShapeParameterPair aParameterPair
;
876 com::sun::star::drawing::EnhancedCustomShapeParameter
& rDepth
= aParameterPair
.First
;
877 com::sun::star::drawing::EnhancedCustomShapeParameter
& rFraction
= aParameterPair
.Second
;
878 if ( GetNextParameter( rDepth
, nIndex
, rValue
) )
880 // try to catch the unit for the depth
881 MapUnit
eSrcUnit( SvXMLExportHelper::GetUnitFromString( rValue
, MAP_100TH_MM
) );
883 rtl::OUStringBuffer aUnitStr
;
884 double fFactor
= SvXMLExportHelper::GetConversionFactor( aUnitStr
, MAP_100TH_MM
, eSrcUnit
);
885 if ( ( fFactor
!= 1.0 ) && ( fFactor
!= 0.0 ) )
888 if ( rDepth
.Value
>>= fDepth
)
891 rDepth
.Value
<<= fDepth
;
894 if ( rValue
.matchIgnoreAsciiCase( rtl::OUString( aUnitStr
), nIndex
) )
895 nIndex
+= aUnitStr
.getLength();
897 // skipping white spaces
898 while( ( nIndex
< rValue
.getLength() ) && rValue
[ nIndex
] == (sal_Unicode
)' ' )
901 if ( GetNextParameter( rFraction
, nIndex
, rValue
) )
903 beans::PropertyValue aProp
;
904 aProp
.Name
= EASGet( EAS_Depth
);
905 aProp
.Value
<<= aParameterPair
;
906 maExtrusion
.push_back( aProp
);
911 case EAS_extrusion_diffusion
:
912 GetDoublePercentage( maExtrusion
, rValue
, EAS_Diffusion
);
914 case EAS_extrusion_number_of_line_segments
:
915 GetInt32( maExtrusion
, rValue
, EAS_NumberOfLineSegments
);
917 case EAS_extrusion_light_face
:
918 GetBool( maExtrusion
, rValue
, EAS_LightFace
);
920 case EAS_extrusion_first_light_harsh
:
921 GetBool( maExtrusion
, rValue
, EAS_FirstLightHarsh
);
923 case EAS_extrusion_second_light_harsh
:
924 GetBool( maExtrusion
, rValue
, EAS_SecondLightHarsh
);
926 case EAS_extrusion_first_light_level
:
927 GetDoublePercentage( maExtrusion
, rValue
, EAS_FirstLightLevel
);
929 case EAS_extrusion_second_light_level
:
930 GetDoublePercentage( maExtrusion
, rValue
, EAS_SecondLightLevel
);
932 case EAS_extrusion_first_light_direction
:
933 GetB3DVector( maExtrusion
, rValue
, EAS_FirstLightDirection
);
935 case EAS_extrusion_second_light_direction
:
936 GetB3DVector( maExtrusion
, rValue
, EAS_SecondLightDirection
);
938 case EAS_extrusion_metal
:
939 GetBool( maExtrusion
, rValue
, EAS_Metal
);
941 case EAS_shade_mode
:
943 drawing::ShadeMode
eShadeMode( drawing::ShadeMode_FLAT
);
944 if( IsXMLToken( rValue
, XML_PHONG
) )
945 eShadeMode
= drawing::ShadeMode_PHONG
;
946 else if ( IsXMLToken( rValue
, XML_GOURAUD
) )
947 eShadeMode
= drawing::ShadeMode_SMOOTH
;
948 else if ( IsXMLToken( rValue
, XML_DRAFT
) )
949 eShadeMode
= drawing::ShadeMode_DRAFT
;
951 beans::PropertyValue aProp
;
952 aProp
.Name
= EASGet( EAS_ShadeMode
);
953 aProp
.Value
<<= eShadeMode
;
954 maExtrusion
.push_back( aProp
);
957 case EAS_extrusion_rotation_angle
:
958 GetEnhancedParameterPair( maExtrusion
, rValue
, EAS_RotateAngle
);
960 case EAS_extrusion_rotation_center
:
961 GetB3DVector( maExtrusion
, rValue
, EAS_RotationCenter
);
963 case EAS_extrusion_shininess
:
964 GetDoublePercentage( maExtrusion
, rValue
, EAS_Shininess
);
966 case EAS_extrusion_skew
:
967 GetEnhancedParameterPair( maExtrusion
, rValue
, EAS_Skew
);
969 case EAS_extrusion_specularity
:
970 GetDoublePercentage( maExtrusion
, rValue
, EAS_Specularity
);
972 case EAS_projection
:
974 drawing::ProjectionMode
eProjectionMode( drawing::ProjectionMode_PERSPECTIVE
);
975 if( IsXMLToken( rValue
, XML_PARALLEL
) )
976 eProjectionMode
= drawing::ProjectionMode_PARALLEL
;
978 beans::PropertyValue aProp
;
979 aProp
.Name
= EASGet( EAS_ProjectionMode
);
980 aProp
.Value
<<= eProjectionMode
;
981 maExtrusion
.push_back( aProp
);
984 case EAS_extrusion_viewpoint
:
985 GetPosition3D( maExtrusion
, rValue
, EAS_ViewPoint
, mrUnitConverter
);
987 case EAS_extrusion_origin
:
988 GetEnhancedParameterPair( maExtrusion
, rValue
, EAS_Origin
);
990 case EAS_extrusion_color
:
991 GetBool( maExtrusion
, rValue
, EAS_Color
);
993 case EAS_enhanced_path
:
994 GetEnhancedPath( maPath
, rValue
);
996 case EAS_path_stretchpoint_x
:
998 if ( SvXMLUnitConverter::convertNumber( nAttrNumber
, rValue
) )
1000 beans::PropertyValue aProp
;
1001 aProp
.Name
= EASGet( EAS_StretchX
);
1002 aProp
.Value
<<= nAttrNumber
;
1003 maPath
.push_back( aProp
);
1007 case EAS_path_stretchpoint_y
:
1009 if ( SvXMLUnitConverter::convertNumber( nAttrNumber
, rValue
) )
1011 beans::PropertyValue aProp
;
1012 aProp
.Name
= EASGet( EAS_StretchY
);
1013 aProp
.Value
<<= nAttrNumber
;
1014 maPath
.push_back( aProp
);
1018 case EAS_text_areas
:
1019 GetEnhancedRectangleSequence( maPath
, rValue
, EAS_TextFrames
);
1021 case EAS_glue_points
:
1023 sal_Int32 i
, nPairs
= GetEnhancedParameterPairSequence( maPath
, rValue
, EAS_GluePoints
);
1024 GetImport().GetShapeImport()->moveGluePointMapping( mrxShape
, nPairs
);
1025 for ( i
= 0; i
< nPairs
; i
++ )
1026 GetImport().GetShapeImport()->addGluePointMapping( mrxShape
, i
+ 4, i
+ 4 );
1029 case EAS_glue_point_type
:
1030 GetEnum( maPath
, rValue
, EAS_GluePointType
, *aXML_GluePointEnumMap
);
1032 case EAS_glue_point_leaving_directions
:
1033 GetDoubleSequence( maPath
, rValue
, EAS_GluePointLeavingDirections
);
1035 case EAS_text_path
:
1036 GetBool( maTextPath
, rValue
, EAS_TextPath
);
1038 case EAS_text_path_mode
:
1040 com::sun::star::drawing::EnhancedCustomShapeTextPathMode
eTextPathMode( com::sun::star::drawing::EnhancedCustomShapeTextPathMode_NORMAL
);
1041 if( IsXMLToken( rValue
, XML_PATH
) )
1042 eTextPathMode
= com::sun::star::drawing::EnhancedCustomShapeTextPathMode_PATH
;
1043 else if ( IsXMLToken( rValue
, XML_SHAPE
) )
1044 eTextPathMode
= com::sun::star::drawing::EnhancedCustomShapeTextPathMode_SHAPE
;
1046 beans::PropertyValue aProp
;
1047 aProp
.Name
= EASGet( EAS_TextPathMode
);
1048 aProp
.Value
<<= eTextPathMode
;
1049 maTextPath
.push_back( aProp
);
1052 case EAS_text_path_scale
:
1054 sal_Bool bScaleX
= IsXMLToken( rValue
, XML_SHAPE
);
1055 beans::PropertyValue aProp
;
1056 aProp
.Name
= EASGet( EAS_ScaleX
);
1057 aProp
.Value
<<= bScaleX
;
1058 maTextPath
.push_back( aProp
);
1061 case EAS_text_path_same_letter_heights
:
1062 GetBool( maTextPath
, rValue
, EAS_SameLetterHeights
);
1064 case EAS_modifiers
:
1065 GetAdjustmentValues( mrCustomShapeGeometry
, rValue
);
1074 void SdXMLCustomShapePropertyMerge( std::vector
< com::sun::star::beans::PropertyValue
>& rPropVec
,
1075 const std::vector
< beans::PropertyValues
>& rElement
,
1076 const rtl::OUString
& rElementName
)
1078 if ( !rElement
.empty() )
1080 uno::Sequence
< beans::PropertyValues
> aPropSeq( rElement
.size() );
1081 std::vector
< beans::PropertyValues
>::const_iterator aIter
= rElement
.begin();
1082 std::vector
< beans::PropertyValues
>::const_iterator aEnd
= rElement
.end();
1083 beans::PropertyValues
* pValues
= aPropSeq
.getArray();
1085 while ( aIter
!= aEnd
)
1086 *pValues
++ = *aIter
++;
1088 beans::PropertyValue aProp
;
1089 aProp
.Name
= rElementName
;
1090 aProp
.Value
<<= aPropSeq
;
1091 rPropVec
.push_back( aProp
);
1095 void SdXMLCustomShapePropertyMerge( std::vector
< com::sun::star::beans::PropertyValue
>& rPropVec
,
1096 const std::vector
< rtl::OUString
>& rElement
,
1097 const rtl::OUString
& rElementName
)
1099 if ( !rElement
.empty() )
1101 uno::Sequence
< rtl::OUString
> aPropSeq( rElement
.size() );
1102 std::vector
< rtl::OUString
>::const_iterator aIter
= rElement
.begin();
1103 std::vector
< rtl::OUString
>::const_iterator aEnd
= rElement
.end();
1104 rtl::OUString
* pValues
= aPropSeq
.getArray();
1106 while ( aIter
!= aEnd
)
1107 *pValues
++ = *aIter
++;
1109 beans::PropertyValue aProp
;
1110 aProp
.Name
= rElementName
;
1111 aProp
.Value
<<= aPropSeq
;
1112 rPropVec
.push_back( aProp
);
1116 void SdXMLCustomShapePropertyMerge( std::vector
< com::sun::star::beans::PropertyValue
>& rPropVec
,
1117 const std::vector
< com::sun::star::beans::PropertyValue
>& rElement
,
1118 const rtl::OUString
& rElementName
)
1120 if ( !rElement
.empty() )
1122 uno::Sequence
< beans::PropertyValue
> aPropSeq( rElement
.size() );
1123 std::vector
< beans::PropertyValue
>::const_iterator aIter
= rElement
.begin();
1124 std::vector
< beans::PropertyValue
>::const_iterator aEnd
= rElement
.end();
1125 beans::PropertyValue
* pValues
= aPropSeq
.getArray();
1127 while ( aIter
!= aEnd
)
1128 *pValues
++ = *aIter
++;
1130 beans::PropertyValue aProp
;
1131 aProp
.Name
= rElementName
;
1132 aProp
.Value
<<= aPropSeq
;
1133 rPropVec
.push_back( aProp
);
1137 typedef std::hash_map
< rtl::OUString
, sal_Int32
, rtl::OUStringHash
, OUStringEqFunc
> EquationHashMap
;
1139 /* if rPara.Type is from type EnhancedCustomShapeParameterType::EQUATION, the name of the equation
1140 will be converted from rtl::OUString to index */
1141 void CheckAndResolveEquationParameter( com::sun::star::drawing::EnhancedCustomShapeParameter
& rPara
, EquationHashMap
* pH
)
1143 if ( rPara
.Type
== com::sun::star::drawing::EnhancedCustomShapeParameterType::EQUATION
)
1145 rtl::OUString aEquationName
;
1146 if ( rPara
.Value
>>= aEquationName
)
1148 sal_Int32 nIndex
= 0;
1149 EquationHashMap::iterator
aHashIter( pH
->find( aEquationName
) );
1150 if ( aHashIter
!= pH
->end() )
1151 nIndex
= (*aHashIter
).second
;
1152 rPara
.Value
<<= nIndex
;
1157 void XMLEnhancedCustomShapeContext::EndElement()
1159 // resolve properties that are indexing a Equation
1160 if ( !maEquations
.empty() )
1162 // creating hash map containing the name and index of each equation
1163 EquationHashMap
* pH
= new EquationHashMap
;
1164 std::vector
< rtl::OUString
>::iterator aEquationNameIter
= maEquationNames
.begin();
1165 std::vector
< rtl::OUString
>::iterator aEquationNameEnd
= maEquationNames
.end();
1166 while( aEquationNameIter
!= aEquationNameEnd
)
1168 (*pH
)[ *aEquationNameIter
] = (sal_Int32
)( aEquationNameIter
- maEquationNames
.begin() );
1169 aEquationNameIter
++;
1173 std::vector
< rtl::OUString
>::iterator aEquationIter
= maEquations
.begin();
1174 std::vector
< rtl::OUString
>::iterator aEquationEnd
= maEquations
.end();
1175 while( aEquationIter
!= aEquationEnd
)
1177 sal_Int32 nIndexOf
= 0;
1180 nIndexOf
= aEquationIter
->indexOf( '?', nIndexOf
);
1181 if ( nIndexOf
!= -1 )
1183 rtl::OUString aEquationName
;
1184 if ( GetEquationName( *aEquationIter
, nIndexOf
+ 1, aEquationName
) )
1186 // copying first characters inclusive '?'
1187 rtl::OUString
aNew( aEquationIter
->copy( 0, nIndexOf
+ 1 ) );
1188 sal_Int32 nIndex
= 0;
1189 EquationHashMap::iterator
aHashIter( pH
->find( aEquationName
) );
1190 if ( aHashIter
!= pH
->end() )
1191 nIndex
= (*aHashIter
).second
;
1192 aNew
+= rtl::OUString::valueOf( nIndex
);
1193 aNew
+= aEquationIter
->copy( nIndexOf
+ aEquationName
.getLength() + 1 );
1194 *aEquationIter
= aNew
;
1199 while( nIndexOf
!= -1 );
1205 std::vector
< beans::PropertyValue
>::iterator aPathIter
= maPath
.begin();
1206 std::vector
< beans::PropertyValue
>::iterator aPathEnd
= maPath
.end();
1207 while ( aPathIter
!= aPathEnd
)
1209 switch( EASGet( aPathIter
->Name
) )
1211 case EAS_Coordinates
:
1212 case EAS_GluePoints
:
1214 uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
>& rSeq
=
1215 *((uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
>*)
1216 aPathIter
->Value
.getValue());
1217 for ( i
= 0; i
< rSeq
.getLength(); i
++ )
1219 CheckAndResolveEquationParameter( rSeq
[ i
].First
, pH
);
1220 CheckAndResolveEquationParameter( rSeq
[ i
].Second
, pH
);
1224 case EAS_TextFrames
:
1226 uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeTextFrame
>& rSeq
=
1227 *((uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeTextFrame
>*)
1228 aPathIter
->Value
.getValue());
1229 for ( i
= 0; i
< rSeq
.getLength(); i
++ )
1231 CheckAndResolveEquationParameter( rSeq
[ i
].TopLeft
.First
, pH
);
1232 CheckAndResolveEquationParameter( rSeq
[ i
].TopLeft
.Second
, pH
);
1233 CheckAndResolveEquationParameter( rSeq
[ i
].BottomRight
.First
, pH
);
1234 CheckAndResolveEquationParameter( rSeq
[ i
].BottomRight
.Second
, pH
);
1243 std::vector
< beans::PropertyValues
>::iterator aHandleIter
= maHandles
.begin();
1244 std::vector
< beans::PropertyValues
>::iterator aHandleEnd
= maHandles
.end();
1245 while ( aHandleIter
!= aHandleEnd
)
1247 beans::PropertyValue
* pValues
= aHandleIter
->getArray();
1248 for ( i
= 0; i
< aHandleIter
->getLength(); i
++ )
1250 switch( EASGet( pValues
->Name
) )
1253 case EAS_RangeYMinimum
:
1254 case EAS_RangeYMaximum
:
1255 case EAS_RangeXMinimum
:
1256 case EAS_RangeXMaximum
:
1257 case EAS_RadiusRangeMinimum
:
1258 case EAS_RadiusRangeMaximum
:
1260 CheckAndResolveEquationParameter( *((com::sun::star::drawing::EnhancedCustomShapeParameter
*)
1261 pValues
->Value
.getValue()), pH
);
1266 CheckAndResolveEquationParameter( (*((com::sun::star::drawing::EnhancedCustomShapeParameterPair
*)
1267 pValues
->Value
.getValue())).First
, pH
);
1268 CheckAndResolveEquationParameter( (*((com::sun::star::drawing::EnhancedCustomShapeParameterPair
*)
1269 pValues
->Value
.getValue())).Second
, pH
);
1282 SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry
, maExtrusion
, EASGet( EAS_Extrusion
) );
1283 SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry
, maPath
, EASGet( EAS_Path
) );
1284 SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry
, maTextPath
, EASGet( EAS_TextPath
) );
1285 SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry
, maEquations
, EASGet( EAS_Equations
) );
1286 if ( !maHandles
.empty() )
1287 SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry
, maHandles
, EASGet( EAS_Handles
) );
1290 SvXMLImportContext
* XMLEnhancedCustomShapeContext::CreateChildContext( USHORT nPrefix
,const rtl::OUString
& rLocalName
,
1291 const uno::Reference
< xml::sax::XAttributeList
> & xAttrList
)
1293 EnhancedCustomShapeTokenEnum aTokenEnum
= EASGet( rLocalName
);
1294 if ( aTokenEnum
== EAS_equation
)
1296 sal_Int16 nLength
= xAttrList
->getLength();
1299 rtl::OUString aFormula
;
1300 rtl::OUString aFormulaName
;
1301 for( sal_Int16 nAttr
= 0; nAttr
< nLength
; nAttr
++ )
1303 rtl::OUString aLocalName
;
1304 const rtl::OUString
& rValue
= xAttrList
->getValueByIndex( nAttr
);
1305 /* fixme sven, this needs to be chekced! sal_uInt16 nPrefix = */ GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList
->getNameByIndex( nAttr
), &aLocalName
);
1307 switch( EASGet( aLocalName
) )
1313 aFormulaName
= rValue
;
1319 if ( aFormulaName
.getLength() || aFormula
.getLength() )
1321 maEquations
.push_back( aFormula
);
1322 maEquationNames
.push_back( aFormulaName
);
1326 else if ( aTokenEnum
== EAS_handle
)
1328 std::vector
< com::sun::star::beans::PropertyValue
> aHandle
;
1329 const sal_Int16 nLength
= xAttrList
->getLength();
1330 for( sal_Int16 nAttr
= 0; nAttr
< nLength
; nAttr
++ )
1332 rtl::OUString aLocalName
;
1333 const rtl::OUString
& rValue
= xAttrList
->getValueByIndex( nAttr
);
1334 /* fixme sven, this needs to be chekced! sal_uInt16 nPrefix = */ GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList
->getNameByIndex( nAttr
), &aLocalName
);
1335 switch( EASGet( aLocalName
) )
1337 case EAS_handle_mirror_vertical
:
1338 GetBool( aHandle
, rValue
, EAS_MirroredY
);
1340 case EAS_handle_mirror_horizontal
:
1341 GetBool( aHandle
, rValue
, EAS_MirroredX
);
1343 case EAS_handle_switched
:
1344 GetBool( aHandle
, rValue
, EAS_Switched
);
1346 case EAS_handle_position
:
1347 GetEnhancedParameterPair( aHandle
, rValue
, EAS_Position
);
1349 case EAS_handle_range_x_minimum
:
1350 GetEnhancedParameter( aHandle
, rValue
, EAS_RangeXMinimum
);
1352 case EAS_handle_range_x_maximum
:
1353 GetEnhancedParameter( aHandle
, rValue
, EAS_RangeXMaximum
);
1355 case EAS_handle_range_y_minimum
:
1356 GetEnhancedParameter( aHandle
, rValue
, EAS_RangeYMinimum
);
1358 case EAS_handle_range_y_maximum
:
1359 GetEnhancedParameter( aHandle
, rValue
, EAS_RangeYMaximum
);
1361 case EAS_handle_polar
:
1362 GetEnhancedParameterPair( aHandle
, rValue
, EAS_Polar
);
1364 case EAS_handle_radius_range_minimum
:
1365 GetEnhancedParameter( aHandle
, rValue
, EAS_RadiusRangeMinimum
);
1367 case EAS_handle_radius_range_maximum
:
1368 GetEnhancedParameter( aHandle
, rValue
, EAS_RadiusRangeMaximum
);
1374 beans::PropertyValues
aPropSeq( aHandle
.size() );
1375 std::vector
< beans::PropertyValue
>::const_iterator aIter
= aHandle
.begin();
1376 std::vector
< beans::PropertyValue
>::const_iterator aEnd
= aHandle
.end();
1377 beans::PropertyValue
* pValues
= aPropSeq
.getArray();
1379 while ( aIter
!= aEnd
)
1380 *pValues
++ = *aIter
++;
1382 maHandles
.push_back( aPropSeq
);
1384 return SvXMLImportContext::CreateChildContext( nPrefix
, rLocalName
, xAttrList
);