1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: shapegroupcontext.cxx,v $
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"
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
) )
76 mpGroupShapePtr
->setId( xAttribs
->getOptionalValue( XML_id
) );
77 mpGroupShapePtr
->setName( xAttribs
->getOptionalValue( XML_name
) );
80 mpGroupShapePtr
->setSubType( xAttribs
->getOptionalValueToken( XML_type
, FastToken::DONTKNOW
) );
81 mpGroupShapePtr
->setIndex( xAttribs
->getOptionalValue( XML_idx
).toInt32() );
83 // nvSpPr CT_ShapeNonVisual end
86 xRet
= new ShapePropertiesContext( *this, *mpGroupShapePtr
);
89 xRet
= new ShapePropertiesContext( *this, *mpGroupShapePtr
);
93 xRet = new ShapeStyleContext( getParser() );
96 case XML_cxnSp
: // connector shape
97 xRet
.set( new ConnectorShapeContext( *this, mpGroupShapePtr
, ShapePtr( new Shape( "com.sun.star.drawing.ConnectorShape" ) ) ) );
99 case XML_grpSp
: // group shape
100 xRet
.set( new ShapeGroupContext( *this, mpGroupShapePtr
, ShapePtr( new Shape( "com.sun.star.drawing.GroupShape" ) ) ) );
102 case XML_sp
: // shape
103 xRet
.set( new ShapeContext( *this, mpGroupShapePtr
, ShapePtr( new Shape( "com.sun.star.drawing.CustomShape" ) ) ) );
105 case XML_pic
: // CT_Picture
106 xRet
.set( new GraphicShapeContext( *this, mpGroupShapePtr
, ShapePtr( new Shape( "com.sun.star.drawing.GraphicObjectShape" ) ) ) );
108 case XML_graphicFrame
: // CT_GraphicalObjectFrame
109 xRet
.set( new GraphicalObjectFrameContext( *this, mpGroupShapePtr
, ShapePtr( new Shape( "com.sun.star.drawing.OLE2Shape" ) ) ) );