1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include "oox/drawingml/shapepropertiescontext.hxx" 25 26 #include <com/sun/star/xml/sax/FastToken.hpp> 27 #include <com/sun/star/drawing/LineStyle.hpp> 28 #include <com/sun/star/beans/XMultiPropertySet.hpp> 29 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 30 #include <com/sun/star/container/XNamed.hpp> 31 32 #include "oox/drawingml/linepropertiescontext.hxx" 33 #include "oox/drawingml/fillpropertiesgroupcontext.hxx" 34 #include "oox/drawingml/transform2dcontext.hxx" 35 #include "oox/drawingml/customshapegeometry.hxx" 36 37 using rtl::OUString; 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; 44 45 namespace oox { namespace drawingml { 46 47 // ==================================================================== 48 49 // CT_ShapeProperties 50 ShapePropertiesContext::ShapePropertiesContext( ContextHandler& rParent, Shape& rShape ) 51 : ContextHandler( rParent ) 52 , mrShape( rShape ) 53 { 54 } 55 56 // -------------------------------------------------------------------- 57 58 Reference< XFastContextHandler > ShapePropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) 59 { 60 Reference< XFastContextHandler > xRet; 61 62 switch( aElementToken ) 63 { 64 // CT_Transform2D 65 case A_TOKEN( xfrm ): 66 xRet.set( new Transform2DContext( *this, xAttribs, mrShape ) ); 67 break; 68 69 // GeometryGroup 70 case A_TOKEN( custGeom ): // custom geometry "CT_CustomGeometry2D" 71 xRet.set( new CustomShapeGeometryContext( *this, xAttribs, *(mrShape.getCustomShapeProperties()) ) ); 72 break; 73 74 75 case A_TOKEN( prstGeom ): // preset geometry "CT_PresetGeometry2D" 76 { 77 sal_Int32 nToken = xAttribs->getOptionalValueToken( XML_prst, 0 ); 78 if ( nToken == XML_line ) 79 { 80 static const OUString sLineShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.LineShape" ) ); 81 mrShape.getServiceName() = sLineShape; 82 } 83 xRet.set( new PresetShapeGeometryContext( *this, xAttribs, *(mrShape.getCustomShapeProperties()) ) ); 84 } 85 break; 86 87 case A_TOKEN( prstTxWarp ): 88 xRet.set( new PresetTextShapeContext( *this, xAttribs, *(mrShape.getCustomShapeProperties()) ) ); 89 break; 90 91 // CT_LineProperties 92 case A_TOKEN( ln ): 93 xRet.set( new LinePropertiesContext( *this, xAttribs, mrShape.getLineProperties() ) ); 94 break; 95 96 // EffectPropertiesGroup 97 // todo not supported by core 98 case A_TOKEN( effectLst ): // CT_EffectList 99 case A_TOKEN( effectDag ): // CT_EffectContainer 100 break; 101 102 // todo 103 case A_TOKEN( scene3d ): // CT_Scene3D 104 case A_TOKEN( sp3d ): // CT_Shape3D 105 break; 106 } 107 108 // FillPropertiesGroupContext 109 if( !xRet.is() ) 110 xRet.set( FillPropertiesContext::createFillContext( *this, aElementToken, xAttribs, mrShape.getFillProperties() ) ); 111 112 return xRet; 113 } 114 115 } } 116