Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "oox/drawingml/shapepropertiescontext.hxx"
21 :
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>
27 :
28 : #include "oox/drawingml/scene3dcontext.hxx"
29 : #include "oox/drawingml/linepropertiescontext.hxx"
30 : #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
31 : #include "oox/drawingml/transform2dcontext.hxx"
32 : #include "oox/drawingml/customshapegeometry.hxx"
33 : #include "oox/drawingml/effectpropertiescontext.hxx"
34 :
35 : using namespace oox::core;
36 : using namespace ::com::sun::star;
37 : using namespace ::com::sun::star::uno;
38 : using namespace ::com::sun::star::drawing;
39 : using namespace ::com::sun::star::beans;
40 : using namespace ::com::sun::star::xml::sax;
41 :
42 : namespace oox { namespace drawingml {
43 :
44 :
45 :
46 : // CT_ShapeProperties
47 0 : ShapePropertiesContext::ShapePropertiesContext( ContextHandler2Helper& rParent, Shape& rShape )
48 : : ContextHandler2( rParent )
49 0 : , mrShape( rShape )
50 : {
51 0 : }
52 :
53 :
54 :
55 0 : ContextHandlerRef ShapePropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
56 : {
57 0 : switch( aElementToken )
58 : {
59 : // CT_Transform2D
60 : case A_TOKEN( xfrm ):
61 0 : return new Transform2DContext( *this, rAttribs, mrShape );
62 :
63 : // GeometryGroup
64 : case A_TOKEN( custGeom ): // custom geometry "CT_CustomGeometry2D"
65 0 : return new CustomShapeGeometryContext( *this, rAttribs, *(mrShape.getCustomShapeProperties()) );
66 :
67 : case A_TOKEN( prstGeom ): // preset geometry "CT_PresetGeometry2D"
68 : {
69 0 : sal_Int32 nToken = rAttribs.getToken( XML_prst, 0 );
70 : // TODO: Move the following checks to a separate place or as a separate function
71 0 : if ( nToken == XML_line )
72 : {
73 0 : mrShape.getServiceName() = "com.sun.star.drawing.LineShape";
74 : }
75 0 : if( ( nToken >= XML_bentConnector2 && nToken <= XML_bentConnector5 ) ||
76 0 : ( nToken >= XML_curvedConnector2 && nToken <= XML_curvedConnector5 ) ||
77 : nToken == XML_straightConnector1 )
78 : {
79 0 : mrShape.getServiceName() = "com.sun.star.drawing.CustomShape";
80 : }
81 0 : return new PresetShapeGeometryContext( *this, rAttribs, *(mrShape.getCustomShapeProperties()) );
82 : }
83 :
84 : case A_TOKEN( prstTxWarp ):
85 0 : return new PresetTextShapeContext( *this, rAttribs, *(mrShape.getCustomShapeProperties()) );
86 :
87 : // CT_LineProperties
88 : case A_TOKEN( ln ):
89 0 : return new LinePropertiesContext( *this, rAttribs, mrShape.getLineProperties() );
90 :
91 : // EffectPropertiesGroup
92 : // todo not supported by core
93 : case A_TOKEN( effectLst ): // CT_EffectList
94 : case A_TOKEN( effectDag ): // CT_EffectContainer
95 0 : return new EffectPropertiesContext( *this, mrShape.getEffectProperties() );
96 :
97 : // todo
98 : case A_TOKEN( scene3d ): // CT_Scene3D
99 : // return new Scene3DContext( *this, rAttribs, *(mrShape.get3DShapeProperties()) );
100 0 : break;
101 :
102 : // todo
103 : case A_TOKEN( sp3d ): // CT_Shape3D
104 0 : break;
105 : }
106 :
107 : // FillPropertiesGroupContext
108 0 : return FillPropertiesContext::createFillContext( *this, aElementToken, rAttribs, mrShape.getFillProperties() );
109 : }
110 :
111 0 : } }
112 :
113 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|