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