Update ooo320-m1
[ooovba.git] / oox / source / drawingml / shapegroupcontext.cxx
blobacd6c10eb93ec54024e865a1486cd683a45f704d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: shapegroupcontext.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <com/sun/star/xml/sax/FastToken.hpp>
32 #include <com/sun/star/beans/XMultiPropertySet.hpp>
33 #include <com/sun/star/container/XNamed.hpp>
35 #include "oox/drawingml/shapegroupcontext.hxx"
36 #include "oox/drawingml/connectorshapecontext.hxx"
37 #include "oox/drawingml/graphicshapecontext.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 #include "oox/core/namespaces.hxx"
43 #include "tokens.hxx"
45 using rtl::OUString;
46 using namespace oox::core;
47 using namespace ::com::sun::star;
48 using namespace ::com::sun::star::uno;
49 using namespace ::com::sun::star::drawing;
50 using namespace ::com::sun::star::beans;
51 using namespace ::com::sun::star::text;
52 using namespace ::com::sun::star::xml::sax;
54 namespace oox { namespace drawingml {
56 ShapeGroupContext::ShapeGroupContext( ContextHandler& rParent, ShapePtr pMasterShapePtr, ShapePtr pGroupShapePtr )
57 : ContextHandler( rParent )
58 , mpGroupShapePtr( pGroupShapePtr )
59 , mpMasterShapePtr( pMasterShapePtr )
63 ShapeGroupContext::~ShapeGroupContext()
65 if ( mpMasterShapePtr.get() && mpGroupShapePtr.get() )
66 mpMasterShapePtr->addChild( mpGroupShapePtr );
69 Reference< XFastContextHandler > ShapeGroupContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
71 Reference< XFastContextHandler > xRet;
73 switch( getToken( aElementToken ) )
75 case XML_cNvPr:
76 mpGroupShapePtr->setId( xAttribs->getOptionalValue( XML_id ) );
77 mpGroupShapePtr->setName( xAttribs->getOptionalValue( XML_name ) );
78 break;
79 case XML_ph:
80 mpGroupShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, FastToken::DONTKNOW ) );
81 mpGroupShapePtr->setIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() );
82 break;
83 // nvSpPr CT_ShapeNonVisual end
85 case XML_grpSpPr:
86 xRet = new ShapePropertiesContext( *this, *mpGroupShapePtr );
87 break;
88 case XML_spPr:
89 xRet = new ShapePropertiesContext( *this, *mpGroupShapePtr );
90 break;
92 case XML_style:
93 xRet = new ShapeStyleContext( getParser() );
94 break;
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.OLE2Shape" ) ) ) );
110 break;
112 if( !xRet.is() )
113 xRet.set( this );
116 return xRet;