1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "oox/drawingml/shapepropertiescontext.hxx"
29 
30 #include <com/sun/star/xml/sax/FastToken.hpp>
31 #include <com/sun/star/drawing/LineStyle.hpp>
32 #include <com/sun/star/beans/XMultiPropertySet.hpp>
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #include <com/sun/star/container/XNamed.hpp>
35 
36 #include "oox/drawingml/linepropertiescontext.hxx"
37 #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
38 #include "oox/drawingml/transform2dcontext.hxx"
39 #include "oox/drawingml/customshapegeometry.hxx"
40 
41 using rtl::OUString;
42 using namespace oox::core;
43 using namespace ::com::sun::star;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::drawing;
46 using namespace ::com::sun::star::beans;
47 using namespace ::com::sun::star::xml::sax;
48 
49 namespace oox { namespace drawingml {
50 
51 // ====================================================================
52 
53 // CT_ShapeProperties
54 ShapePropertiesContext::ShapePropertiesContext( ContextHandler& rParent, Shape& rShape )
55 : ContextHandler( rParent )
56 , mrShape( rShape )
57 {
58 }
59 
60 // --------------------------------------------------------------------
61 
62 Reference< XFastContextHandler > ShapePropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
63 {
64 	Reference< XFastContextHandler > xRet;
65 
66 	switch( aElementToken )
67 	{
68 	// CT_Transform2D
69 	case A_TOKEN( xfrm ):
70         xRet.set( new Transform2DContext( *this, xAttribs, mrShape ) );
71 		break;
72 
73 	// GeometryGroup
74 	case A_TOKEN( custGeom ):	// custom geometry "CT_CustomGeometry2D"
75         xRet.set( new CustomShapeGeometryContext( *this, xAttribs, *(mrShape.getCustomShapeProperties()) ) );
76 		break;
77 
78 
79 	case A_TOKEN( prstGeom ):	// preset geometry "CT_PresetGeometry2D"
80 		{
81 			sal_Int32 nToken = xAttribs->getOptionalValueToken( XML_prst, 0 );
82 			if ( nToken == XML_line )
83 			{
84 				static const OUString sLineShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.LineShape" ) );
85 				mrShape.getServiceName() = sLineShape;
86 			}
87             xRet.set( new PresetShapeGeometryContext( *this, xAttribs, *(mrShape.getCustomShapeProperties()) ) );
88 		}
89 		break;
90 
91 	case A_TOKEN( prstTxWarp ):
92         xRet.set( new PresetTextShapeContext( *this, xAttribs, *(mrShape.getCustomShapeProperties()) ) );
93 		break;
94 
95 	// CT_LineProperties
96 	case A_TOKEN( ln ):
97         xRet.set( new LinePropertiesContext( *this, xAttribs, mrShape.getLineProperties() ) );
98 		break;
99 
100 	// EffectPropertiesGroup
101 	// todo not supported by core
102 	case A_TOKEN( effectLst ):	// CT_EffectList
103 	case A_TOKEN( effectDag ):	// CT_EffectContainer
104 		break;
105 
106 	// todo
107 	case A_TOKEN( scene3d ):	// CT_Scene3D
108 	case A_TOKEN( sp3d ):		// CT_Shape3D
109 		break;
110 	}
111 
112 	// FillPropertiesGroupContext
113 	if( !xRet.is() )
114         xRet.set( FillPropertiesContext::createFillContext( *this, aElementToken, xAttribs, mrShape.getFillProperties() ) );
115 
116 	return xRet;
117 }
118 
119 } }
120