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 <com/sun/star/xml/sax/FastToken.hpp> 29 #include <com/sun/star/drawing/LineStyle.hpp> 30 #include <com/sun/star/beans/XMultiPropertySet.hpp> 31 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 32 #include <com/sun/star/container/XNamed.hpp> 33 34 #include "oox/helper/attributelist.hxx" 35 #include "oox/drawingml/shapecontext.hxx" 36 #include "oox/drawingml/shapestylecontext.hxx" 37 #include "oox/drawingml/fillpropertiesgroupcontext.hxx" 38 #include "oox/drawingml/lineproperties.hxx" 39 #include "oox/drawingml/drawingmltypes.hxx" 40 #include "oox/drawingml/customshapegeometry.hxx" 41 #include "oox/drawingml/textbodycontext.hxx" 42 43 using rtl::OUString; 44 using namespace oox::core; 45 using namespace ::com::sun::star; 46 using namespace ::com::sun::star::uno; 47 using namespace ::com::sun::star::drawing; 48 using namespace ::com::sun::star::beans; 49 using namespace ::com::sun::star::text; 50 using namespace ::com::sun::star::xml::sax; 51 52 namespace oox { namespace drawingml { 53 54 // CT_Shape 55 ShapeContext::ShapeContext( ContextHandler& rParent, ShapePtr pMasterShapePtr, ShapePtr pShapePtr ) 56 : ContextHandler( rParent ) 57 , mpMasterShapePtr( pMasterShapePtr ) 58 , mpShapePtr( pShapePtr ) 59 { 60 } 61 62 ShapeContext::~ShapeContext() 63 { 64 if ( mpMasterShapePtr.get() && mpShapePtr.get() ) 65 mpMasterShapePtr->addChild( mpShapePtr ); 66 } 67 68 ShapePtr ShapeContext::getShape() 69 { 70 return mpShapePtr; 71 } 72 73 void ShapeContext::endFastElement( sal_Int32 /* aElementToken */ ) throw( SAXException, RuntimeException ) 74 { 75 } 76 77 Reference< XFastContextHandler > ShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) 78 { 79 Reference< XFastContextHandler > xRet; 80 81 switch( getBaseToken( aElementToken ) ) 82 { 83 // nvSpPr CT_ShapeNonVisual begin 84 // case XML_drElemPr: 85 // break; 86 case XML_cNvPr: 87 { 88 AttributeList aAttribs( xAttribs ); 89 mpShapePtr->setHidden( aAttribs.getBool( XML_hidden, false ) ); 90 mpShapePtr->setId( xAttribs->getOptionalValue( XML_id ) ); 91 mpShapePtr->setName( xAttribs->getOptionalValue( XML_name ) ); 92 break; 93 } 94 case XML_ph: 95 mpShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) ); 96 mpShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); 97 break; 98 // nvSpPr CT_ShapeNonVisual end 99 100 case XML_spPr: 101 xRet = new ShapePropertiesContext( *this, *mpShapePtr ); 102 break; 103 104 case XML_style: 105 xRet = new ShapeStyleContext( *this, *mpShapePtr ); 106 break; 107 108 case XML_txBody: 109 { 110 TextBodyPtr xTextBody( new TextBody ); 111 mpShapePtr->setTextBody( xTextBody ); 112 xRet = new TextBodyContext( *this, *xTextBody ); 113 break; 114 } 115 } 116 117 if( !xRet.is() ) 118 { 119 uno::Reference<XFastContextHandler> xTmp(this); 120 xRet.set( xTmp ); 121 } 122 123 return xRet; 124 } 125 126 127 } } 128