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/beans/XMultiPropertySet.hpp> 30 #include <com/sun/star/container/XNamed.hpp> 31 32 #include "oox/helper/attributelist.hxx" 33 #include "oox/drawingml/shapegroupcontext.hxx" 34 #include "oox/drawingml/connectorshapecontext.hxx" 35 #include "oox/drawingml/graphicshapecontext.hxx" 36 #include "oox/drawingml/lineproperties.hxx" 37 #include "oox/drawingml/drawingmltypes.hxx" 38 #include "oox/drawingml/customshapegeometry.hxx" 39 #include "oox/drawingml/textbodycontext.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::text; 48 using namespace ::com::sun::star::xml::sax; 49 50 namespace oox { namespace drawingml { 51 52 ShapeGroupContext::ShapeGroupContext( ContextHandler& rParent, ShapePtr pMasterShapePtr, ShapePtr pGroupShapePtr ) 53 : ContextHandler( rParent ) 54 , mpGroupShapePtr( pGroupShapePtr ) 55 , mpMasterShapePtr( pMasterShapePtr ) 56 { 57 } 58 59 ShapeGroupContext::~ShapeGroupContext() 60 { 61 if ( mpMasterShapePtr.get() && mpGroupShapePtr.get() ) 62 mpMasterShapePtr->addChild( mpGroupShapePtr ); 63 } 64 65 Reference< XFastContextHandler > ShapeGroupContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) 66 { 67 Reference< XFastContextHandler > xRet; 68 69 switch( getBaseToken( aElementToken ) ) 70 { 71 case XML_cNvPr: 72 { 73 AttributeList aAttribs( xAttribs ); 74 mpGroupShapePtr->setHidden( aAttribs.getBool( XML_hidden, false ) ); 75 mpGroupShapePtr->setId( xAttribs->getOptionalValue( XML_id ) ); 76 mpGroupShapePtr->setName( xAttribs->getOptionalValue( XML_name ) ); 77 break; 78 } 79 case XML_ph: 80 mpGroupShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, FastToken::DONTKNOW ) ); 81 mpGroupShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); 82 break; 83 // nvSpPr CT_ShapeNonVisual end 84 85 case XML_grpSpPr: 86 xRet = new ShapePropertiesContext( *this, *mpGroupShapePtr ); 87 break; 88 case XML_spPr: 89 xRet = new ShapePropertiesContext( *this, *mpGroupShapePtr ); 90 break; 91 /* 92 case XML_style: 93 xRet = new ShapeStyleContext( getParser() ); 94 break; 95 */ 96 case XML_cxnSp: // connector shape 97 xRet.set( new ConnectorShapeContext( *this, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.ConnectorShape" ) ) ) ); 98 break; 99 case XML_grpSp: // group shape 100 xRet.set( new ShapeGroupContext( *this, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.GroupShape" ) ) ) ); 101 break; 102 case XML_sp: // shape 103 xRet.set( new ShapeContext( *this, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.CustomShape" ) ) ) ); 104 break; 105 case XML_pic: // CT_Picture 106 xRet.set( new GraphicShapeContext( *this, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.GraphicObjectShape" ) ) ) ); 107 break; 108 case XML_graphicFrame: // CT_GraphicalObjectFrame 109 xRet.set( new GraphicalObjectFrameContext( *this, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.GraphicObjectShape" ) ), true ) ); 110 break; 111 } 112 if( !xRet.is() ) 113 xRet.set( this ); 114 115 116 return xRet; 117 } 118 119 } } 120