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 "drawingml/shapepropertiescontext.hxx"
22 #include <com/sun/star/xml/sax/FastToken.hpp>
23 #include <com/sun/star/drawing/LineStyle.hpp>
24 #include <com/sun/star/beans/XMultiPropertySet.hpp>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <com/sun/star/container/XNamed.hpp>
28 #include "drawingml/scene3dcontext.hxx"
29 #include "drawingml/linepropertiescontext.hxx"
30 #include "drawingml/misccontexts.hxx"
31 #include "drawingml/transform2dcontext.hxx"
32 #include "drawingml/customshapegeometry.hxx"
33 #include "effectpropertiescontext.hxx"
34 #include <oox/helper/attributelist.hxx>
35 #include <oox/token/namespaces.hxx>
36 #include <oox/token/tokens.hxx>
38 using namespace oox::core
;
39 using namespace ::com::sun::star
;
40 using namespace ::com::sun::star::uno
;
41 using namespace ::com::sun::star::drawing
;
42 using namespace ::com::sun::star::beans
;
43 using namespace ::com::sun::star::xml::sax
;
45 namespace oox
{ namespace drawingml
{
48 ShapePropertiesContext::ShapePropertiesContext( ContextHandler2Helper
& rParent
, Shape
& rShape
)
49 : ContextHandler2( rParent
)
54 ContextHandlerRef
ShapePropertiesContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
56 switch( aElementToken
)
60 return new Transform2DContext( *this, rAttribs
, mrShape
);
63 case A_TOKEN( custGeom
): // custom geometry "CT_CustomGeometry2D"
64 return new CustomShapeGeometryContext( *this, *mrShape
.getCustomShapeProperties() );
66 case A_TOKEN( prstGeom
): // preset geometry "CT_PresetGeometry2D"
68 sal_Int32 nToken
= rAttribs
.getToken( XML_prst
, 0 );
69 // TODO: Move the following checks to a separate place or as a separate function
70 if ( nToken
== XML_line
)
72 mrShape
.getServiceName() = "com.sun.star.drawing.LineShape";
74 if( ( nToken
>= XML_bentConnector2
&& nToken
<= XML_bentConnector5
) ||
75 ( nToken
>= XML_curvedConnector2
&& nToken
<= XML_curvedConnector5
) ||
76 nToken
== XML_straightConnector1
)
78 mrShape
.getServiceName() = "com.sun.star.drawing.CustomShape";
80 return new PresetShapeGeometryContext( *this, rAttribs
, *(mrShape
.getCustomShapeProperties()) );
83 case A_TOKEN( prstTxWarp
):
84 return new PresetTextShapeContext( *this, rAttribs
, *(mrShape
.getCustomShapeProperties()) );
88 return new LinePropertiesContext( *this, rAttribs
, mrShape
.getLineProperties() );
90 // EffectPropertiesGroup
91 // todo not supported by core
92 case A_TOKEN( effectLst
): // CT_EffectList
93 case A_TOKEN( effectDag
): // CT_EffectContainer
94 return new EffectPropertiesContext( *this, mrShape
.getEffectProperties() );
96 // todo not supported by core, only for preservation via grab bags
97 case A_TOKEN( scene3d
): // CT_Scene3D
98 return new Scene3DPropertiesContext( *this, mrShape
.get3DProperties() );
101 // todo not supported by core, only for preservation via grab bags
102 case A_TOKEN( sp3d
): // CT_Shape3D
103 return new Shape3DPropertiesContext( *this, rAttribs
, mrShape
.get3DProperties() );
107 return FillPropertiesContext::createFillContext( *this, aElementToken
, rAttribs
, mrShape
.getFillProperties() );
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */