1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "oox/drawingml/customshapegeometry.hxx"
22 #include <com/sun/star/xml/sax/FastToken.hpp>
23 #include <comphelper/stl_types.hxx>
24 #include <boost/unordered_map.hpp>
25 #include "oox/helper/helper.hxx"
26 #include "oox/helper/attributelist.hxx"
27 #include "oox/helper/propertymap.hxx"
29 using namespace ::oox::core
;
30 using namespace ::com::sun::star::uno
;
31 using namespace ::com::sun::star::beans
;
32 using namespace ::com::sun::star::drawing
;
33 using namespace ::com::sun::star::xml::sax
;
35 namespace oox
{ namespace drawingml
{
59 struct FormularCommandNameTable
64 static FormularCommandNameTable pFormularCommandNameTable
[] =
67 { "+-", FC_PLUSMINUS
},
69 { "ifelse", FC_IFELSE
},
86 typedef boost::unordered_map
< OUString
, FormularCommand
, OUStringHash
, comphelper::UStringEqual
> FormulaCommandHMap
;
88 static const FormulaCommandHMap
* pCommandHashMap
;
91 OUString
GetFormulaParameter( const EnhancedCustomShapeParameter
& rParameter
)
94 switch( rParameter
.Type
)
96 case EnhancedCustomShapeParameterType::NORMAL
:
98 if ( rParameter
.Value
.getValueTypeClass() == TypeClass_DOUBLE
)
101 if ( rParameter
.Value
>>= fValue
)
102 aRet
= OUString::valueOf( fValue
);
106 sal_Int32 nValue
= 0;
107 if ( rParameter
.Value
>>= nValue
)
108 aRet
= OUString::valueOf( nValue
);
112 case EnhancedCustomShapeParameterType::EQUATION
:
114 if ( rParameter
.Value
.getValueTypeClass() == TypeClass_LONG
)
116 sal_Int32 nFormulaIndex
;
117 if ( rParameter
.Value
>>= nFormulaIndex
)
120 + OUString::valueOf( nFormulaIndex
)
126 // ups... we should have an index here and not the formula name
130 case EnhancedCustomShapeParameterType::ADJUSTMENT
:
132 if ( rParameter
.Value
.getValueTypeClass() == TypeClass_LONG
)
134 sal_Int32 nAdjustmentIndex
;
135 if ( rParameter
.Value
>>= nAdjustmentIndex
)
138 + OUString::valueOf( nAdjustmentIndex
)
144 // ups... we should have an index here and not the formula name
148 case EnhancedCustomShapeParameterType::LEFT
:
150 const OUString
sLeft( "left" );
154 case EnhancedCustomShapeParameterType::TOP
:
156 const OUString
sTop( "top" );
160 case EnhancedCustomShapeParameterType::RIGHT
:
162 const OUString
sRight( "right" );
166 case EnhancedCustomShapeParameterType::BOTTOM
:
168 const OUString
sBottom( "bottom" );
172 case EnhancedCustomShapeParameterType::XSTRETCH
:
174 const OUString
sXStretch( "xstretch" );
178 case EnhancedCustomShapeParameterType::YSTRETCH
:
180 const OUString
sYStretch( "ystretch" );
184 case EnhancedCustomShapeParameterType::HASSTROKE
:
186 const OUString
sHasStroke( "hasstroke" );
190 case EnhancedCustomShapeParameterType::HASFILL
:
192 const OUString
sHasFill( "hasfill" );
196 case EnhancedCustomShapeParameterType::WIDTH
:
198 const OUString
sWidth( "width" );
202 case EnhancedCustomShapeParameterType::HEIGHT
:
204 const OUString
sHeight( "height" );
208 case EnhancedCustomShapeParameterType::LOGWIDTH
:
210 const OUString
sLogWidth( "logwidth" );
214 case EnhancedCustomShapeParameterType::LOGHEIGHT
:
216 const OUString
sLogHeight( "logheight" );
224 // ---------------------------------------------------------------------
226 static EnhancedCustomShapeParameter
GetAdjCoordinate( CustomShapeProperties
& rCustomShapeProperties
, const OUString
& rValue
, sal_Bool bNoSymbols
= sal_True
)
228 com::sun::star::drawing::EnhancedCustomShapeParameter aRet
;
229 if ( !rValue
.isEmpty() )
231 sal_Bool bConstant
= sal_True
;
232 sal_Int32 nConstant
= -1;
233 sal_Int32 nIntVal
= 0;
235 // first check if its a constant value
236 switch( AttributeConversion::decodeToken( rValue
) )
238 case XML_3cd4
: nConstant
= 270 * 60000; break;
239 case XML_3cd8
: nConstant
= 135 * 60000; break;
240 case XML_5cd8
: nConstant
= 225 * 60000; break;
241 case XML_7cd8
: nConstant
= 315 * 60000; break;
242 case XML_cd2
: nConstant
= 180 * 60000; break;
243 case XML_cd3
: nConstant
= 120 * 60000; break;
244 case XML_cd4
: nConstant
= 90 * 60000; break;
245 case XML_cd8
: nConstant
= 45 * 60000; break;
247 case XML_b
: // variable height of the shape defined in spPr
252 CustomShapeGuide aGuide
;
253 aGuide
.maName
= rValue
;
254 aGuide
.maFormula
= "logheight" ;
256 aRet
.Value
= Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties
.getGuideList(), aGuide
) );
257 aRet
.Type
= EnhancedCustomShapeParameterType::EQUATION
;
260 aRet
.Type
= EnhancedCustomShapeParameterType::LOGHEIGHT
; // TODO: HEIGHT needs to be implemented
265 case XML_hd10
: // !!PASSTHROUGH INTENDED
266 nIntVal
+= 2; // */ h 1.0 10.0
267 case XML_hd8
: // */ h 1.0 8.0
269 case XML_hd6
: // */ h 1.0 6.0
271 case XML_hd5
: // */ h 1.0 5.0
273 case XML_hd4
: // */ h 1.0 4.0
275 case XML_hd3
: // */ h 1.0 3.0
277 case XML_hd2
: // */ h 1.0 2.0
278 case XML_vc
: // */ h 1.0 2.0
282 CustomShapeGuide aGuide
;
283 aGuide
.maName
= rValue
;
284 aGuide
.maFormula
= "logheight/" + OUString::valueOf( nIntVal
);
286 aRet
.Value
= Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties
.getGuideList(), aGuide
) );
287 aRet
.Type
= EnhancedCustomShapeParameterType::EQUATION
;
295 aRet
.Type
= EnhancedCustomShapeParameterType::NORMAL
;
299 case XML_ls
: // longest side: max w h
301 CustomShapeGuide aGuide
;
302 aGuide
.maName
= rValue
;
303 aGuide
.maFormula
= "max(logwidth,logheight)";
305 aRet
.Value
= Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties
.getGuideList(), aGuide
) );
306 aRet
.Type
= EnhancedCustomShapeParameterType::EQUATION
;
309 case XML_ss
: // shortest side: min w h
311 CustomShapeGuide aGuide
;
312 aGuide
.maName
= rValue
;
313 aGuide
.maFormula
= "min(logwidth,logheight)";
315 aRet
.Value
= Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties
.getGuideList(), aGuide
) );
316 aRet
.Type
= EnhancedCustomShapeParameterType::EQUATION
;
319 case XML_ssd32
: // */ ss 1.0 32.0
321 case XML_ssd16
: // */ ss 1.0 16.0
323 case XML_ssd8
: // */ ss 1.0 8.0
325 case XML_ssd6
: // */ ss 1.0 6.0
327 case XML_ssd4
: // */ ss 1.0 4.0
329 case XML_ssd2
: // */ ss 1.0 2.0
333 CustomShapeGuide aGuide
;
334 aGuide
.maName
= rValue
;
335 aGuide
.maFormula
= "min(logwidth,logheight)/" + OUString::valueOf( nIntVal
);
337 aRet
.Value
= Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties
.getGuideList(), aGuide
) );
338 aRet
.Type
= EnhancedCustomShapeParameterType::EQUATION
;
342 case XML_r
: // variable width of the shape defined in spPr
347 CustomShapeGuide aGuide
;
348 aGuide
.maName
= rValue
;
349 aGuide
.maFormula
= "logwidth" ;
351 aRet
.Value
= Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties
.getGuideList(), aGuide
) );
352 aRet
.Type
= EnhancedCustomShapeParameterType::EQUATION
;
355 aRet
.Type
= EnhancedCustomShapeParameterType::LOGWIDTH
;
359 case XML_wd32
: // */ w 1.0 32.0
361 case XML_wd12
: // */ w 1.0 12.0
363 case XML_wd10
: // */ w 1.0 10.0
365 case XML_wd8
: // */ w 1.0 8.0
367 case XML_wd6
: // */ w 1.0 6.0
369 case XML_wd5
: // */ w 1.0 5.0
371 case XML_wd4
: // */ w 1.0 4.0
373 case XML_wd3
: // */ w 1.0 3.0
375 case XML_hc
: // */ w 1.0 2.0
376 case XML_wd2
: // */ w 1.0 2.0
380 CustomShapeGuide aGuide
;
381 aGuide
.maName
= rValue
;
382 aGuide
.maFormula
= "logwidth/" + OUString::valueOf( nIntVal
);
384 aRet
.Value
= Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties
.getGuideList(), aGuide
) );
385 aRet
.Type
= EnhancedCustomShapeParameterType::EQUATION
;
390 bConstant
= sal_False
;
395 if (nConstant
!= -1) {
396 aRet
.Value
= Any( nConstant
);
397 aRet
.Type
= EnhancedCustomShapeParameterType::NORMAL
;
402 sal_Unicode n
= rValue
[ 0 ];
403 if ( ( n
== '+' ) || ( n
== '-' ) )
405 if ( rValue
.getLength() > 1 )
408 if ( ( n
>= '0' ) && ( n
<= '9' ) )
409 { // seems to be a ST_Coordinate
410 aRet
.Value
= Any( (sal_Int32
)(rValue
.toInt32() ) );
411 aRet
.Type
= EnhancedCustomShapeParameterType::NORMAL
;
415 sal_Int32 nGuideIndex
= CustomShapeProperties::GetCustomShapeGuideValue( rCustomShapeProperties
.getAdjustmentGuideList(), rValue
);
416 if ( nGuideIndex
>= 0 )
418 aRet
.Value
= Any( nGuideIndex
);
419 aRet
.Type
= EnhancedCustomShapeParameterType::ADJUSTMENT
;
423 nGuideIndex
= CustomShapeProperties::GetCustomShapeGuideValue( rCustomShapeProperties
.getGuideList(), rValue
);
424 if ( nGuideIndex
>= 0 )
426 aRet
.Value
= Any( nGuideIndex
);
427 aRet
.Type
= EnhancedCustomShapeParameterType::EQUATION
;
431 OSL_TRACE("error: unhandled value '%s'", OUStringToOString( rValue
, RTL_TEXTENCODING_ASCII_US
).getStr());
432 aRet
.Value
= Any( rValue
);
441 // ---------------------------------------------------------------------
443 class GeomGuideListContext
: public ContextHandler
446 GeomGuideListContext( ContextHandler
& rParent
, CustomShapeProperties
& rCustomShapeProperties
, std::vector
< CustomShapeGuide
>& rGuideList
);
447 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 aElementToken
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& xAttribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
450 std::vector
< CustomShapeGuide
>& mrGuideList
;
451 CustomShapeProperties
& mrCustomShapeProperties
;
454 GeomGuideListContext::GeomGuideListContext( ContextHandler
& rParent
, CustomShapeProperties
& rCustomShapeProperties
, std::vector
< CustomShapeGuide
>& rGuideList
)
455 : ContextHandler( rParent
)
456 , mrGuideList( rGuideList
)
457 , mrCustomShapeProperties( rCustomShapeProperties
)
461 static OUString
convertToOOEquation( CustomShapeProperties
& rCustomShapeProperties
, const OUString
& rSource
)
463 if ( !pCommandHashMap
)
465 FormulaCommandHMap
* pHM
= new FormulaCommandHMap();
466 for( sal_Int32 i
= 0; i
< FC_LAST
; i
++ )
467 (*pHM
)[ OUString::createFromAscii( pFormularCommandNameTable
[ i
].pS
) ] = pFormularCommandNameTable
[ i
].pE
;
468 pCommandHashMap
= pHM
;
471 std::vector
< OUString
> aTokens
;
472 sal_Int32 nIndex
= 0;
475 OUString
aToken( rSource
.getToken( 0, ' ', nIndex
) );
476 if ( !aToken
.isEmpty() )
477 aTokens
.push_back( aToken
);
479 while ( nIndex
>= 0 );
482 if ( !aTokens
.empty() )
484 sal_Int32 i
, nParameters
= aTokens
.size() - 1;
485 if ( nParameters
> 3 )
488 OUString sParameters
[ 3 ];
490 for ( i
= 0; i
< nParameters
; i
++ )
491 sParameters
[ i
] = GetFormulaParameter( GetAdjCoordinate( rCustomShapeProperties
, aTokens
[ i
+ 1 ], sal_False
) );
493 const FormulaCommandHMap::const_iterator
aIter( pCommandHashMap
->find( aTokens
[ 0 ] ) );
494 if ( aIter
!= pCommandHashMap
->end() )
496 switch( aIter
->second
)
500 if ( nParameters
== 3 )
501 aEquation
= sParameters
[ 0 ] + "*" + sParameters
[ 1 ]
502 + "/" + sParameters
[ 2 ];
507 if ( nParameters
== 3 )
508 aEquation
= sParameters
[ 0 ] + "+" + sParameters
[ 1 ]
509 + "-" + sParameters
[ 2 ];
514 if ( nParameters
== 3 )
515 aEquation
= "(" + sParameters
[ 0 ] + "+"
516 + sParameters
[ 1 ] + ")/" + sParameters
[ 2 ];
522 if ( nParameters
== 3 )
523 aEquation
= "if(" + sParameters
[ 0 ] + ","
524 + sParameters
[ 1 ] + "," + sParameters
[ 2 ] + ")";
529 if ( nParameters
== 1 )
530 aEquation
= "abs(" + sParameters
[ 0 ] + ")";
535 if ( nParameters
== 2 )
536 aEquation
= "(10800000*atan2(" + sParameters
[ 1 ] + ","
537 + sParameters
[ 0 ] + "))/pi";
542 if ( nParameters
== 3 )
543 aEquation
= sParameters
[ 0 ] + "*(cos(atan2(" +
544 sParameters
[ 2 ] + "," + sParameters
[ 1 ] + ")))";
549 if ( nParameters
== 2 )
550 aEquation
= sParameters
[ 0 ] + "*cos(pi*(" +
551 sParameters
[ 1 ] + ")/10800000)";
556 if ( nParameters
== 2 )
557 aEquation
= "max(" + sParameters
[ 0 ] + "," +
558 sParameters
[ 1 ] + ")";
563 if ( nParameters
== 2 )
564 aEquation
= "min(" + sParameters
[ 0 ] + "," +
565 sParameters
[ 1 ] + ")";
570 if ( nParameters
== 3 )
572 + sParameters
[ 0 ] + "*" + sParameters
[ 0 ] + "+"
573 + sParameters
[ 1 ] + "*" + sParameters
[ 1 ] + "+"
574 + sParameters
[ 2 ] + "*" + sParameters
[ 2 ] + ")";
579 if ( nParameters
== 3 ) // if(x-y,x,if(y-z,z,y))
580 aEquation
= "if(" + sParameters
[ 0 ] + "-" + sParameters
[ 1 ]
581 + "," + sParameters
[ 0 ] + ",if(" + sParameters
[ 2 ]
582 + "-" + sParameters
[ 1 ] + "," + sParameters
[ 1 ]
583 + "," + sParameters
[ 2 ] + "))";
588 if ( nParameters
== 3 )
589 aEquation
= sParameters
[ 0 ] + "*(sin(atan2(" +
590 sParameters
[ 2 ] + "," + sParameters
[ 1 ] + ")))";
595 if ( nParameters
== 2 )
596 aEquation
= sParameters
[ 0 ] + "*sin(pi*(" +
597 sParameters
[ 1 ] + ")/10800000)";
602 if ( nParameters
== 1 )
603 aEquation
= "sqrt(" + sParameters
[ 0 ] + ")";
608 if ( nParameters
== 2 )
609 aEquation
= sParameters
[ 0 ] + "*tan(pi*(" +
610 sParameters
[ 1 ] + ")/10800000)";
615 if ( nParameters
== 1 )
616 aEquation
= sParameters
[ 0 ];
627 Reference
< XFastContextHandler
> GeomGuideListContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
629 if ( aElementToken
== A_TOKEN( gd
) ) // CT_GeomGuide
631 CustomShapeGuide aGuide
;
632 aGuide
.maName
= xAttribs
->getOptionalValue( XML_name
);
633 aGuide
.maFormula
= convertToOOEquation( mrCustomShapeProperties
, xAttribs
->getOptionalValue( XML_fmla
) );
634 mrGuideList
.push_back( aGuide
);
639 // ---------------------------------------------------------------------
641 static const OUString
GetGeomGuideName( const OUString
& rValue
)
646 // ---------------------------------------------------------------------
648 class AdjPoint2DContext
: public ContextHandler
651 AdjPoint2DContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
, CustomShapeProperties
& rCustomShapeProperties
, EnhancedCustomShapeParameterPair
& rAdjPoint2D
);
654 AdjPoint2DContext::AdjPoint2DContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
, CustomShapeProperties
& rCustomShapeProperties
, EnhancedCustomShapeParameterPair
& rAdjPoint2D
)
655 : ContextHandler( rParent
)
657 rAdjPoint2D
.First
= GetAdjCoordinate( rCustomShapeProperties
, xAttribs
->getOptionalValue( XML_x
), sal_True
);
658 rAdjPoint2D
.Second
= GetAdjCoordinate( rCustomShapeProperties
, xAttribs
->getOptionalValue( XML_y
), sal_True
);
661 // ---------------------------------------------------------------------
663 class XYAdjustHandleContext
: public ContextHandler
666 XYAdjustHandleContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
, CustomShapeProperties
& rCustomShapeProperties
, AdjustHandle
& rAdjustHandle
);
667 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 aElementToken
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& xAttribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
670 AdjustHandle
& mrAdjustHandle
;
671 CustomShapeProperties
& mrCustomShapeProperties
;
674 XYAdjustHandleContext::XYAdjustHandleContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
, CustomShapeProperties
& rCustomShapeProperties
, AdjustHandle
& rAdjustHandle
)
675 : ContextHandler( rParent
)
676 , mrAdjustHandle( rAdjustHandle
)
677 , mrCustomShapeProperties( rCustomShapeProperties
)
679 const OUString aEmptyDefault
;
680 AttributeList
aAttribs( xAttribs
);
681 if ( aAttribs
.hasAttribute( XML_gdRefX
) )
683 mrAdjustHandle
.gdRef1
= GetGeomGuideName( aAttribs
.getString( XML_gdRefX
, aEmptyDefault
) );
685 if ( aAttribs
.hasAttribute( XML_minX
) )
687 mrAdjustHandle
.min1
= GetAdjCoordinate( mrCustomShapeProperties
, aAttribs
.getString( XML_minX
, aEmptyDefault
), sal_True
);
689 if ( aAttribs
.hasAttribute( XML_maxX
) )
691 mrAdjustHandle
.max1
= GetAdjCoordinate( mrCustomShapeProperties
, aAttribs
.getString( XML_maxX
, aEmptyDefault
), sal_True
);
693 if ( aAttribs
.hasAttribute( XML_gdRefY
) )
695 mrAdjustHandle
.gdRef2
= GetGeomGuideName( aAttribs
.getString( XML_gdRefY
, aEmptyDefault
) );
697 if ( aAttribs
.hasAttribute( XML_minY
) )
699 mrAdjustHandle
.min2
= GetAdjCoordinate( mrCustomShapeProperties
, aAttribs
.getString( XML_minY
, aEmptyDefault
), sal_True
);
701 if ( aAttribs
.hasAttribute( XML_maxY
) )
703 mrAdjustHandle
.max2
= GetAdjCoordinate( mrCustomShapeProperties
, aAttribs
.getString( XML_maxY
, aEmptyDefault
), sal_True
);
707 Reference
< XFastContextHandler
> XYAdjustHandleContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
709 Reference
< XFastContextHandler
> xContext
;
710 if ( aElementToken
== A_TOKEN( pos
) )
711 xContext
= new AdjPoint2DContext( *this, xAttribs
, mrCustomShapeProperties
, mrAdjustHandle
.pos
); // CT_AdjPoint2D
715 // ---------------------------------------------------------------------
716 // CT_PolarAdjustHandle
717 class PolarAdjustHandleContext
: public ContextHandler
720 PolarAdjustHandleContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
, CustomShapeProperties
& rCustomShapeProperties
, AdjustHandle
& rAdjustHandle
);
721 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 aElementToken
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& xAttribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
724 AdjustHandle
& mrAdjustHandle
;
725 CustomShapeProperties
& mrCustomShapeProperties
;
728 PolarAdjustHandleContext::PolarAdjustHandleContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
, CustomShapeProperties
& rCustomShapeProperties
, AdjustHandle
& rAdjustHandle
)
729 : ContextHandler( rParent
)
730 , mrAdjustHandle( rAdjustHandle
)
731 , mrCustomShapeProperties( rCustomShapeProperties
)
733 const OUString aEmptyDefault
;
734 AttributeList
aAttribs( xAttribs
);
735 if ( aAttribs
.hasAttribute( XML_gdRefR
) )
737 mrAdjustHandle
.gdRef1
= GetGeomGuideName( aAttribs
.getString( XML_gdRefR
, aEmptyDefault
) );
739 if ( aAttribs
.hasAttribute( XML_minR
) )
741 mrAdjustHandle
.min1
= GetAdjCoordinate( mrCustomShapeProperties
, aAttribs
.getString( XML_minR
, aEmptyDefault
), sal_True
);
743 if ( aAttribs
.hasAttribute( XML_maxR
) )
745 mrAdjustHandle
.max1
= GetAdjCoordinate( mrCustomShapeProperties
, aAttribs
.getString( XML_maxR
, aEmptyDefault
), sal_True
);
747 if ( aAttribs
.hasAttribute( XML_gdRefAng
) )
749 mrAdjustHandle
.gdRef2
= GetGeomGuideName( aAttribs
.getString( XML_gdRefAng
, aEmptyDefault
) );
751 if ( aAttribs
.hasAttribute( XML_minAng
) )
753 mrAdjustHandle
.min2
= GetAdjCoordinate( mrCustomShapeProperties
, aAttribs
.getString( XML_minAng
, aEmptyDefault
) );
755 if ( aAttribs
.hasAttribute( XML_maxAng
) )
757 mrAdjustHandle
.max2
= GetAdjCoordinate( mrCustomShapeProperties
, aAttribs
.getString( XML_maxAng
, aEmptyDefault
) );
761 Reference
< XFastContextHandler
> PolarAdjustHandleContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
763 Reference
< XFastContextHandler
> xContext
;
764 if ( aElementToken
== A_TOKEN( pos
) )
765 xContext
= new AdjPoint2DContext( *this, xAttribs
, mrCustomShapeProperties
, mrAdjustHandle
.pos
); // CT_AdjPoint2D
769 // ---------------------------------------------------------------------
770 // CT_AdjustHandleList
771 class AdjustHandleListContext
: public ContextHandler
774 AdjustHandleListContext( ContextHandler
& rParent
, CustomShapeProperties
& rCustomShapeProperties
, std::vector
< AdjustHandle
>& rAdjustHandleList
);
775 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 aElementToken
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& xAttribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
778 std::vector
< AdjustHandle
>& mrAdjustHandleList
;
779 CustomShapeProperties
& mrCustomShapeProperties
;
782 AdjustHandleListContext::AdjustHandleListContext( ContextHandler
& rParent
, CustomShapeProperties
& rCustomShapeProperties
, std::vector
< AdjustHandle
>& rAdjustHandleList
)
783 : ContextHandler( rParent
)
784 , mrAdjustHandleList( rAdjustHandleList
)
785 , mrCustomShapeProperties( rCustomShapeProperties
)
789 Reference
< XFastContextHandler
> AdjustHandleListContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
791 Reference
< XFastContextHandler
> xContext
;
792 if ( aElementToken
== A_TOKEN( ahXY
) ) // CT_XYAdjustHandle
794 AdjustHandle
aAdjustHandle( sal_False
);
795 mrAdjustHandleList
.push_back( aAdjustHandle
);
796 xContext
= new XYAdjustHandleContext( *this, xAttribs
, mrCustomShapeProperties
, mrAdjustHandleList
.back() );
798 else if ( aElementToken
== A_TOKEN( ahPolar
) ) // CT_PolarAdjustHandle
800 AdjustHandle
aAdjustHandle( sal_True
);
801 mrAdjustHandleList
.push_back( aAdjustHandle
);
802 xContext
= new PolarAdjustHandleContext( *this, xAttribs
, mrCustomShapeProperties
, mrAdjustHandleList
.back() );
807 // ---------------------------------------------------------------------
809 class ConnectionSiteContext
: public ContextHandler
812 ConnectionSiteContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
, CustomShapeProperties
& rCustomShapeProperties
, ConnectionSite
& rConnectionSite
);
813 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 aElementToken
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& xAttribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
816 ConnectionSite
& mrConnectionSite
;
817 CustomShapeProperties
& mrCustomShapeProperties
;
820 ConnectionSiteContext::ConnectionSiteContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
, CustomShapeProperties
& rCustomShapeProperties
, ConnectionSite
& rConnectionSite
)
821 : ContextHandler( rParent
)
822 , mrConnectionSite( rConnectionSite
)
823 , mrCustomShapeProperties( rCustomShapeProperties
)
825 mrConnectionSite
.ang
= GetAdjCoordinate( mrCustomShapeProperties
, xAttribs
->getOptionalValue( XML_ang
) );
828 Reference
< XFastContextHandler
> ConnectionSiteContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
830 Reference
< XFastContextHandler
> xContext
;
831 if ( aElementToken
== A_TOKEN( pos
) )
832 xContext
= new AdjPoint2DContext( *this, xAttribs
, mrCustomShapeProperties
, mrConnectionSite
.pos
); // CT_AdjPoint2D
836 // ---------------------------------------------------------------------
838 class Path2DMoveToContext
: public ContextHandler
841 Path2DMoveToContext( ContextHandler
& rParent
, CustomShapeProperties
& rCustomShapeProperties
, EnhancedCustomShapeParameterPair
& rAdjPoint2D
);
842 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 aElementToken
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& xAttribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
845 EnhancedCustomShapeParameterPair
& mrAdjPoint2D
;
846 CustomShapeProperties
& mrCustomShapeProperties
;
849 Path2DMoveToContext::Path2DMoveToContext( ContextHandler
& rParent
, CustomShapeProperties
& rCustomShapeProperties
, EnhancedCustomShapeParameterPair
& rAdjPoint2D
)
850 : ContextHandler( rParent
)
851 , mrAdjPoint2D( rAdjPoint2D
)
852 , mrCustomShapeProperties( rCustomShapeProperties
)
856 Reference
< XFastContextHandler
> Path2DMoveToContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
858 Reference
< XFastContextHandler
> xContext
;
859 if ( aElementToken
== A_TOKEN( pt
) )
860 xContext
= new AdjPoint2DContext( *this, xAttribs
, mrCustomShapeProperties
, mrAdjPoint2D
); // CT_AdjPoint2D
864 // ---------------------------------------------------------------------
866 class Path2DLineToContext
: public ContextHandler
869 Path2DLineToContext( ContextHandler
& rParent
, CustomShapeProperties
& rCustomShapeProperties
, EnhancedCustomShapeParameterPair
& rAdjPoint2D
);
870 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 aElementToken
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& xAttribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
873 EnhancedCustomShapeParameterPair
& mrAdjPoint2D
;
874 CustomShapeProperties
& mrCustomShapeProperties
;
877 Path2DLineToContext::Path2DLineToContext( ContextHandler
& rParent
, CustomShapeProperties
& rCustomShapeProperties
, EnhancedCustomShapeParameterPair
& rAdjPoint2D
)
878 : ContextHandler( rParent
)
879 , mrAdjPoint2D( rAdjPoint2D
)
880 , mrCustomShapeProperties( rCustomShapeProperties
)
884 Reference
< XFastContextHandler
> Path2DLineToContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
886 Reference
< XFastContextHandler
> xContext
;
887 if ( aElementToken
== A_TOKEN( pt
) )
888 xContext
= new AdjPoint2DContext( *this, xAttribs
, mrCustomShapeProperties
, mrAdjPoint2D
); // CT_AdjPoint2D
892 // ---------------------------------------------------------------------
893 // CT_Path2DQuadBezierTo
894 class Path2DQuadBezierToContext
: public ContextHandler
897 Path2DQuadBezierToContext( ContextHandler
& rParent
, CustomShapeProperties
& rCustomShapeProperties
, EnhancedCustomShapeParameterPair
& rPt1
, EnhancedCustomShapeParameterPair
& rPt2
);
898 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 aElementToken
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& xAttribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
901 EnhancedCustomShapeParameterPair
& mrPt1
;
902 EnhancedCustomShapeParameterPair
& mrPt2
;
904 CustomShapeProperties
& mrCustomShapeProperties
;
907 Path2DQuadBezierToContext::Path2DQuadBezierToContext( ContextHandler
& rParent
,
908 CustomShapeProperties
& rCustomShapeProperties
,
909 EnhancedCustomShapeParameterPair
& rPt1
,
910 EnhancedCustomShapeParameterPair
& rPt2
)
911 : ContextHandler( rParent
)
915 , mrCustomShapeProperties( rCustomShapeProperties
)
919 Reference
< XFastContextHandler
> Path2DQuadBezierToContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
921 Reference
< XFastContextHandler
> xContext
;
922 if ( aElementToken
== A_TOKEN( pt
) )
923 xContext
= new AdjPoint2DContext( *this, xAttribs
, mrCustomShapeProperties
, nCount
++ ? mrPt2
: mrPt1
); // CT_AdjPoint2D
927 // ---------------------------------------------------------------------
928 // CT_Path2DCubicBezierTo
929 class Path2DCubicBezierToContext
: public ContextHandler
932 Path2DCubicBezierToContext( ContextHandler
& rParent
, CustomShapeProperties
& rCustomShapeProperties
,
933 EnhancedCustomShapeParameterPair
&, EnhancedCustomShapeParameterPair
&, EnhancedCustomShapeParameterPair
& );
934 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 aElementToken
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& xAttribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
937 CustomShapeProperties
& mrCustomShapeProperties
;
938 EnhancedCustomShapeParameterPair
& mrControlPt1
;
939 EnhancedCustomShapeParameterPair
& mrControlPt2
;
940 EnhancedCustomShapeParameterPair
& mrEndPt
;
944 Path2DCubicBezierToContext::Path2DCubicBezierToContext( ContextHandler
& rParent
, CustomShapeProperties
& rCustomShapeProperties
,
945 EnhancedCustomShapeParameterPair
& rControlPt1
,
946 EnhancedCustomShapeParameterPair
& rControlPt2
,
947 EnhancedCustomShapeParameterPair
& rEndPt
)
948 : ContextHandler( rParent
)
949 , mrCustomShapeProperties( rCustomShapeProperties
)
950 , mrControlPt1( rControlPt1
)
951 , mrControlPt2( rControlPt2
)
957 Reference
< XFastContextHandler
> Path2DCubicBezierToContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
959 Reference
< XFastContextHandler
> xContext
;
960 if ( aElementToken
== A_TOKEN( pt
) )
961 xContext
= new AdjPoint2DContext( *this, xAttribs
, mrCustomShapeProperties
,
962 nCount
++ ? nCount
== 2 ? mrControlPt2
: mrEndPt
: mrControlPt1
); // CT_AdjPoint2D
966 // ---------------------------------------------------------------------
968 class Path2DContext
: public ContextHandler
971 Path2DContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
, CustomShapeProperties
& rCustomShapeProperties
, std::vector
< com::sun::star::drawing::EnhancedCustomShapeSegment
>& rSegments
, Path2D
& rPath2D
);
972 virtual ~Path2DContext();
973 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
> SAL_CALL
974 createFastChildContext( sal_Int32 aElementToken
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& xAttribs
)
975 throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
979 std::vector
< com::sun::star::drawing::EnhancedCustomShapeSegment
>& mrSegments
;
980 CustomShapeProperties
& mrCustomShapeProperties
;
983 Path2DContext::Path2DContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
, CustomShapeProperties
& rCustomShapeProperties
, std::vector
< com::sun::star::drawing::EnhancedCustomShapeSegment
>& rSegments
, Path2D
& rPath2D
)
984 : ContextHandler( rParent
)
985 , mrPath2D( rPath2D
)
986 , mrSegments( rSegments
)
987 , mrCustomShapeProperties( rCustomShapeProperties
)
989 const OUString aEmptyString
;
991 AttributeList
aAttribs( xAttribs
);
992 rPath2D
.w
= aAttribs
.getString( XML_w
, aEmptyString
).toInt64();
993 rPath2D
.h
= aAttribs
.getString( XML_h
, aEmptyString
).toInt64();
994 rPath2D
.fill
= aAttribs
.getToken( XML_fill
, XML_norm
);
995 rPath2D
.stroke
= aAttribs
.getBool( XML_stroke
, sal_True
);
996 rPath2D
.extrusionOk
= aAttribs
.getBool( XML_extrusionOk
, sal_True
);
999 Path2DContext::~Path2DContext()
1001 EnhancedCustomShapeSegment aNewSegment
;
1002 switch ( mrPath2D
.fill
)
1005 aNewSegment
.Command
= EnhancedCustomShapeSegmentCommand::NOFILL
;
1008 aNewSegment
.Command
= EnhancedCustomShapeSegmentCommand::DARKEN
;
1010 case XML_darkenLess
:
1011 aNewSegment
.Command
= EnhancedCustomShapeSegmentCommand::DARKENLESS
;
1014 aNewSegment
.Command
= EnhancedCustomShapeSegmentCommand::LIGHTEN
;
1016 case XML_lightenLess
:
1017 aNewSegment
.Command
= EnhancedCustomShapeSegmentCommand::LIGHTENLESS
;
1020 if (mrPath2D
.fill
!= XML_norm
) {
1021 aNewSegment
.Count
= 0;
1022 mrSegments
.push_back( aNewSegment
);
1024 if ( !mrPath2D
.stroke
)
1026 aNewSegment
.Command
= EnhancedCustomShapeSegmentCommand::NOSTROKE
;
1027 aNewSegment
.Count
= 0;
1028 mrSegments
.push_back( aNewSegment
);
1030 aNewSegment
.Command
= EnhancedCustomShapeSegmentCommand::ENDSUBPATH
;
1031 aNewSegment
.Count
= 0;
1032 mrSegments
.push_back( aNewSegment
);
1035 Reference
< XFastContextHandler
> Path2DContext::createFastChildContext( sal_Int32 aElementToken
,
1036 const Reference
< XFastAttributeList
>& xAttribs
) throw ( SAXException
, RuntimeException
)
1038 Reference
< XFastContextHandler
> xContext
;
1039 switch( aElementToken
)
1041 case A_TOKEN( close
) :
1043 // ignore close after move to (ppt does seems to do the same, see accentCallout2 preset for example)
1044 if ( mrSegments
.empty() || ( mrSegments
.back().Command
!= EnhancedCustomShapeSegmentCommand::MOVETO
) ) {
1045 EnhancedCustomShapeSegment aNewSegment
;
1046 aNewSegment
.Command
= EnhancedCustomShapeSegmentCommand::CLOSESUBPATH
;
1047 aNewSegment
.Count
= 0;
1048 mrSegments
.push_back( aNewSegment
);
1052 case A_TOKEN( moveTo
) :
1054 EnhancedCustomShapeSegment aNewSegment
;
1055 aNewSegment
.Command
= EnhancedCustomShapeSegmentCommand::MOVETO
;
1056 aNewSegment
.Count
= 1;
1057 mrSegments
.push_back( aNewSegment
);
1059 EnhancedCustomShapeParameterPair aAdjPoint2D
;
1060 mrPath2D
.parameter
.push_back( aAdjPoint2D
);
1061 xContext
= new Path2DMoveToContext( *this, mrCustomShapeProperties
, mrPath2D
.parameter
.back() );
1064 case A_TOKEN( lnTo
) :
1066 if ( !mrSegments
.empty() && ( mrSegments
.back().Command
== EnhancedCustomShapeSegmentCommand::LINETO
) )
1067 mrSegments
.back().Count
++;
1070 EnhancedCustomShapeSegment aSegment
;
1071 aSegment
.Command
= EnhancedCustomShapeSegmentCommand::LINETO
;
1073 mrSegments
.push_back( aSegment
);
1075 EnhancedCustomShapeParameterPair aAdjPoint2D
;
1076 mrPath2D
.parameter
.push_back( aAdjPoint2D
);
1077 xContext
= new Path2DLineToContext( *this, mrCustomShapeProperties
, mrPath2D
.parameter
.back() );
1080 case A_TOKEN( arcTo
) : // CT_Path2DArcTo
1082 if ( !mrSegments
.empty() && ( mrSegments
.back().Command
== EnhancedCustomShapeSegmentCommand::ARCANGLETO
) )
1083 mrSegments
.back().Count
++;
1086 EnhancedCustomShapeSegment aSegment
;
1087 aSegment
.Command
= EnhancedCustomShapeSegmentCommand::ARCANGLETO
;
1089 mrSegments
.push_back( aSegment
);
1092 EnhancedCustomShapeParameterPair aScale
;
1093 EnhancedCustomShapeParameterPair aAngles
;
1095 aScale
.First
= GetAdjCoordinate( mrCustomShapeProperties
, xAttribs
->getOptionalValue( XML_wR
), sal_True
);
1096 aScale
.Second
= GetAdjCoordinate( mrCustomShapeProperties
, xAttribs
->getOptionalValue( XML_hR
), sal_True
);
1098 CustomShapeGuide aGuide
;
1099 sal_Int32 nArcNum
= mrCustomShapeProperties
.getArcNum();
1102 aGuide
.maName
= "arctosa" + OUString::valueOf( nArcNum
);
1103 aGuide
.maFormula
= "("
1104 + GetFormulaParameter( GetAdjCoordinate( mrCustomShapeProperties
, xAttribs
->getOptionalValue( XML_stAng
) ) )
1106 aAngles
.First
.Value
= Any( CustomShapeProperties::SetCustomShapeGuideValue( mrCustomShapeProperties
.getGuideList(), aGuide
) );
1107 aAngles
.First
.Type
= EnhancedCustomShapeParameterType::EQUATION
;
1110 aGuide
.maName
= "arctosw" + OUString::valueOf( nArcNum
);
1111 aGuide
.maFormula
= "("
1112 + GetFormulaParameter( GetAdjCoordinate( mrCustomShapeProperties
, xAttribs
->getOptionalValue( XML_swAng
) ) )
1114 aAngles
.Second
.Value
= Any( CustomShapeProperties::SetCustomShapeGuideValue( mrCustomShapeProperties
.getGuideList(), aGuide
) );
1115 aAngles
.Second
.Type
= EnhancedCustomShapeParameterType::EQUATION
;
1117 mrPath2D
.parameter
.push_back( aScale
);
1118 mrPath2D
.parameter
.push_back( aAngles
);
1121 case A_TOKEN( quadBezTo
) :
1123 if ( !mrSegments
.empty() && ( mrSegments
.back().Command
== EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO
) )
1124 mrSegments
.back().Count
++;
1127 EnhancedCustomShapeSegment aSegment
;
1128 aSegment
.Command
= EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO
;
1130 mrSegments
.push_back( aSegment
);
1132 EnhancedCustomShapeParameterPair aPt1
;
1133 EnhancedCustomShapeParameterPair aPt2
;
1134 mrPath2D
.parameter
.push_back( aPt1
);
1135 mrPath2D
.parameter
.push_back( aPt2
);
1136 xContext
= new Path2DQuadBezierToContext( *this, mrCustomShapeProperties
,
1137 mrPath2D
.parameter
[ mrPath2D
.parameter
.size() - 2 ],
1138 mrPath2D
.parameter
.back() );
1141 case A_TOKEN( cubicBezTo
) :
1143 if ( !mrSegments
.empty() && ( mrSegments
.back().Command
== EnhancedCustomShapeSegmentCommand::CURVETO
) )
1144 mrSegments
.back().Count
++;
1147 EnhancedCustomShapeSegment aSegment
;
1148 aSegment
.Command
= EnhancedCustomShapeSegmentCommand::CURVETO
;
1150 mrSegments
.push_back( aSegment
);
1152 EnhancedCustomShapeParameterPair aControlPt1
;
1153 EnhancedCustomShapeParameterPair aControlPt2
;
1154 EnhancedCustomShapeParameterPair aEndPt
;
1155 mrPath2D
.parameter
.push_back( aControlPt1
);
1156 mrPath2D
.parameter
.push_back( aControlPt2
);
1157 mrPath2D
.parameter
.push_back( aEndPt
);
1158 xContext
= new Path2DCubicBezierToContext( *this, mrCustomShapeProperties
,
1159 mrPath2D
.parameter
[ mrPath2D
.parameter
.size() - 3 ],
1160 mrPath2D
.parameter
[ mrPath2D
.parameter
.size() - 2 ],
1161 mrPath2D
.parameter
.back() );
1168 // ---------------------------------------------------------------------
1170 class Path2DListContext
: public ContextHandler
1173 Path2DListContext( ContextHandler
& rParent
, CustomShapeProperties
& rCustomShapeProperties
, std::vector
< EnhancedCustomShapeSegment
>& rSegments
,
1174 std::vector
< Path2D
>& rPath2DList
);
1176 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 aElementToken
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& xAttribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
1180 CustomShapeProperties
& mrCustomShapeProperties
;
1181 std::vector
< com::sun::star::drawing::EnhancedCustomShapeSegment
>& mrSegments
;
1182 std::vector
< Path2D
>& mrPath2DList
;
1185 Path2DListContext::Path2DListContext( ContextHandler
& rParent
, CustomShapeProperties
& rCustomShapeProperties
, std::vector
< EnhancedCustomShapeSegment
>& rSegments
,
1186 std::vector
< Path2D
>& rPath2DList
)
1187 : ContextHandler( rParent
)
1188 , mrCustomShapeProperties( rCustomShapeProperties
)
1189 , mrSegments( rSegments
)
1190 , mrPath2DList( rPath2DList
)
1194 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
> SAL_CALL
Path2DListContext::createFastChildContext( sal_Int32 aElementToken
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& xAttribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
)
1196 Reference
< XFastContextHandler
> xContext
;
1197 if ( aElementToken
== A_TOKEN( path
) )
1200 mrPath2DList
.push_back( aPath2D
);
1201 xContext
= new Path2DContext( *this, xAttribs
, mrCustomShapeProperties
, mrSegments
, mrPath2DList
.back() );
1206 // ---------------------------------------------------------------------
1207 // CT_CustomGeometry2D
1208 CustomShapeGeometryContext::CustomShapeGeometryContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& /* xAttribs */, CustomShapeProperties
& rCustomShapeProperties
)
1209 : ContextHandler( rParent
)
1210 , mrCustomShapeProperties( rCustomShapeProperties
)
1214 Reference
< XFastContextHandler
> CustomShapeGeometryContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
1216 Reference
< XFastContextHandler
> xContext
;
1217 switch( aElementToken
)
1219 case A_TOKEN( avLst
): // CT_GeomGuideList adjust value list
1220 xContext
= new GeomGuideListContext( *this, mrCustomShapeProperties
, mrCustomShapeProperties
.getAdjustmentGuideList() );
1222 case A_TOKEN( gdLst
): // CT_GeomGuideList guide list
1223 xContext
= new GeomGuideListContext( *this, mrCustomShapeProperties
, mrCustomShapeProperties
.getGuideList() );
1225 case A_TOKEN( ahLst
): // CT_AdjustHandleList adjust handle list
1226 xContext
= new AdjustHandleListContext( *this, mrCustomShapeProperties
, mrCustomShapeProperties
.getAdjustHandleList() );
1228 case A_TOKEN( cxnLst
): // CT_ConnectionSiteList connection site list
1231 case A_TOKEN( rect
): // CT_GeomRectList geometry rect list
1234 aGeomRect
.l
= GetAdjCoordinate( mrCustomShapeProperties
, xAttribs
->getOptionalValue( XML_l
), sal_True
);
1235 aGeomRect
.t
= GetAdjCoordinate( mrCustomShapeProperties
, xAttribs
->getOptionalValue( XML_t
), sal_True
);
1236 aGeomRect
.r
= GetAdjCoordinate( mrCustomShapeProperties
, xAttribs
->getOptionalValue( XML_r
), sal_True
);
1237 aGeomRect
.b
= GetAdjCoordinate( mrCustomShapeProperties
, xAttribs
->getOptionalValue( XML_b
), sal_True
);
1238 mrCustomShapeProperties
.getTextRect() = aGeomRect
;
1241 case A_TOKEN( pathLst
): // CT_Path2DList 2d path list
1242 xContext
= new Path2DListContext( *this, mrCustomShapeProperties
, mrCustomShapeProperties
.getSegments(), mrCustomShapeProperties
.getPath2DList() );
1246 case A_TOKEN( cxn
): // CT_ConnectionSite
1248 ConnectionSite aConnectionSite
;
1249 mrCustomShapeProperties
.getConnectionSiteList().push_back( aConnectionSite
);
1250 xContext
= new ConnectionSiteContext( *this, xAttribs
, mrCustomShapeProperties
, mrCustomShapeProperties
.getConnectionSiteList().back() );
1257 // ---------------------------------------------------------------------
1258 // CT_PresetGeometry2D
1259 PresetShapeGeometryContext::PresetShapeGeometryContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
, CustomShapeProperties
& rCustomShapeProperties
)
1260 : ContextHandler( rParent
)
1261 , mrCustomShapeProperties( rCustomShapeProperties
)
1263 sal_Int32 nShapeType
= xAttribs
->getOptionalValueToken( XML_prst
, FastToken::DONTKNOW
);
1264 OSL_ENSURE( nShapeType
!= FastToken::DONTKNOW
, "oox::drawingml::CustomShapeCustomGeometryContext::CustomShapeCustomGeometryContext(), unknown shape type" );
1265 mrCustomShapeProperties
.setShapePresetType( nShapeType
);
1268 Reference
< XFastContextHandler
> PresetShapeGeometryContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& ) throw (SAXException
, RuntimeException
)
1270 if ( aElementToken
== A_TOKEN( avLst
) )
1271 return new GeomGuideListContext( *this, mrCustomShapeProperties
, mrCustomShapeProperties
.getAdjustmentGuideList() );
1276 // ---------------------------------------------------------------------
1277 // CT_PresetTextShape
1278 PresetTextShapeContext::PresetTextShapeContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
, CustomShapeProperties
& rCustomShapeProperties
)
1279 : ContextHandler( rParent
)
1280 , mrCustomShapeProperties( rCustomShapeProperties
)
1282 sal_Int32 nShapeType
= xAttribs
->getOptionalValueToken( XML_prst
, FastToken::DONTKNOW
);
1283 OSL_ENSURE( nShapeType
!= FastToken::DONTKNOW
, "oox::drawingml::CustomShapeCustomGeometryContext::CustomShapeCustomGeometryContext(), unknown shape type" );
1284 mrCustomShapeProperties
.setShapePresetType( nShapeType
);
1287 Reference
< XFastContextHandler
> PresetTextShapeContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& ) throw (SAXException
, RuntimeException
)
1289 if ( aElementToken
== A_TOKEN( avLst
) )
1290 return new GeomGuideListContext( *this, mrCustomShapeProperties
, mrCustomShapeProperties
.getAdjustmentGuideList() );
1297 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */