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 101 : ShapePropertiesContext::ShapePropertiesContext( ContextHandler& rParent, Shape& rShape )
48 : : ContextHandler( rParent )
49 101 : , mrShape( rShape )
50 : {
51 101 : }
52 :
53 : // --------------------------------------------------------------------
54 :
55 174 : Reference< XFastContextHandler > ShapePropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
56 : {
57 174 : Reference< XFastContextHandler > xRet;
58 :
59 174 : switch( aElementToken )
60 : {
61 : // CT_Transform2D
62 : case A_TOKEN( xfrm ):
63 72 : xRet.set( new Transform2DContext( *this, xAttribs, mrShape ) );
64 72 : break;
65 :
66 : // GeometryGroup
67 : case A_TOKEN( custGeom ): // custom geometry "CT_CustomGeometry2D"
68 2 : xRet.set( new CustomShapeGeometryContext( *this, xAttribs, *(mrShape.getCustomShapeProperties()) ) );
69 2 : break;
70 :
71 :
72 : case A_TOKEN( prstGeom ): // preset geometry "CT_PresetGeometry2D"
73 : {
74 50 : sal_Int32 nToken = xAttribs->getOptionalValueToken( XML_prst, 0 );
75 : // TODO: Move the following checks to a separate place or as a separate function
76 50 : if ( nToken == XML_line )
77 : {
78 0 : mrShape.getServiceName() = "com.sun.star.drawing.LineShape";
79 : }
80 50 : if( ( nToken >= XML_bentConnector2 && nToken <= XML_bentConnector5 ) ||
81 : ( nToken >= XML_curvedConnector2 && nToken <= XML_curvedConnector5 ) ||
82 : nToken == XML_straightConnector1 )
83 : {
84 4 : mrShape.getServiceName() = "com.sun.star.drawing.CustomShape";
85 : }
86 50 : xRet.set( new PresetShapeGeometryContext( *this, xAttribs, *(mrShape.getCustomShapeProperties()) ) );
87 : }
88 50 : break;
89 :
90 : case A_TOKEN( prstTxWarp ):
91 0 : xRet.set( new PresetTextShapeContext( *this, xAttribs, *(mrShape.getCustomShapeProperties()) ) );
92 0 : break;
93 :
94 : // CT_LineProperties
95 : case A_TOKEN( ln ):
96 19 : xRet.set( new LinePropertiesContext( *this, xAttribs, mrShape.getLineProperties() ) );
97 19 : break;
98 :
99 : // EffectPropertiesGroup
100 : // todo not supported by core
101 : case A_TOKEN( effectLst ): // CT_EffectList
102 : case A_TOKEN( effectDag ): // CT_EffectContainer
103 14 : xRet.set( new EffectPropertiesContext( *this, mrShape.getEffectProperties() ) );
104 14 : break;
105 :
106 : // todo
107 : case A_TOKEN( scene3d ): // CT_Scene3D
108 : // xRet.set( new Scene3DContext( *this, xAttribs, *(mrShape.get3DShapeProperties()) ) );
109 0 : break;
110 :
111 : // todo
112 : case A_TOKEN( sp3d ): // CT_Shape3D
113 0 : break;
114 : }
115 :
116 : // FillPropertiesGroupContext
117 174 : if( !xRet.is() )
118 17 : xRet.set( FillPropertiesContext::createFillContext( *this, aElementToken, xAttribs, mrShape.getFillProperties() ) );
119 :
120 174 : return xRet;
121 : }
122 :
123 51 : } }
124 :
125 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|