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/ppt/pptshape.hxx"
30 #include "oox/ppt/pptshapecontext.hxx"
31 #include "oox/ppt/pptshapegroupcontext.hxx"
32 #include "oox/drawingml/graphicshapecontext.hxx"
33 #include "oox/drawingml/lineproperties.hxx"
34 #include "oox/drawingml/drawingmltypes.hxx"
35 #include "oox/drawingml/customshapegeometry.hxx"
36 #include "oox/drawingml/textbodycontext.hxx"
37 #include "oox/drawingml/connectorshapecontext.hxx"
38 
39 using rtl::OUString;
40 using namespace oox::core;
41 using namespace ::com::sun::star;
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::drawing;
44 using namespace ::com::sun::star::beans;
45 using namespace ::com::sun::star::text;
46 using namespace ::com::sun::star::xml::sax;
47 
48 namespace oox { namespace ppt {
49 
PPTShapeGroupContext(ContextHandler & rParent,const oox::ppt::SlidePersistPtr pSlidePersistPtr,const ShapeLocation eShapeLocation,oox::drawingml::ShapePtr pMasterShapePtr,oox::drawingml::ShapePtr pGroupShapePtr)50 PPTShapeGroupContext::PPTShapeGroupContext(
51         ContextHandler& rParent,
52         const oox::ppt::SlidePersistPtr pSlidePersistPtr,
53         const ShapeLocation eShapeLocation,
54         oox::drawingml::ShapePtr pMasterShapePtr,
55         oox::drawingml::ShapePtr pGroupShapePtr )
56 : ShapeGroupContext( rParent, pMasterShapePtr, pGroupShapePtr )
57 , mpSlidePersistPtr( pSlidePersistPtr )
58 , meShapeLocation( eShapeLocation )
59 {
60 }
61 
createFastChildContext(sal_Int32 aElementToken,const Reference<XFastAttributeList> & xAttribs)62 Reference< XFastContextHandler > PPTShapeGroupContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
63 {
64 	Reference< XFastContextHandler > xRet;
65 
66 	switch( aElementToken )
67 	{
68 	case PPT_TOKEN( cNvPr ):
69 	{
70 		AttributeList aAttribs( xAttribs );
71 		mpGroupShapePtr->setHidden( aAttribs.getBool( XML_hidden, false ) );
72 		mpGroupShapePtr->setId( xAttribs->getOptionalValue( XML_id ) );
73 		mpGroupShapePtr->setName( xAttribs->getOptionalValue( XML_name ) );
74 		break;
75 	}
76 	case PPT_TOKEN( ph ):
77 		mpGroupShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, FastToken::DONTKNOW ) );
78 		mpGroupShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() );
79 		break;
80 	// nvSpPr CT_ShapeNonVisual end
81 
82 	case PPT_TOKEN( grpSpPr ):
83         xRet = new oox::drawingml::ShapePropertiesContext( *this, *mpGroupShapePtr );
84 		break;
85 	case PPT_TOKEN( spPr ):
86         xRet = new oox::drawingml::ShapePropertiesContext( *this, *mpGroupShapePtr );
87 		break;
88 /*
89 	case PPT_TOKEN( style ):
90 		xRet = new ShapeStyleContext( getParser() );
91 		break;
92 */
93 	case PPT_TOKEN( cxnSp ):		// connector shape
94         xRet.set( new oox::drawingml::ConnectorShapeContext( *this, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.ConnectorShape" ) ) ) );
95 		break;
96 	case PPT_TOKEN( grpSp ):		// group shape
97         xRet.set( new PPTShapeGroupContext( *this, mpSlidePersistPtr, meShapeLocation, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GroupShape" ) ) ) );
98 		break;
99 	case PPT_TOKEN( sp ):			// Shape
100         xRet.set( new PPTShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.CustomShape" ) ) ) );
101 		break;
102 	case PPT_TOKEN( pic ):			// CT_Picture
103         xRet.set( new oox::drawingml::GraphicShapeContext( *this, mpGroupShapePtr,  oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GraphicObjectShape" ) ) ) );
104 		break;
105 	case PPT_TOKEN( graphicFrame ):	// CT_GraphicalObjectFrame
106         xRet.set( new oox::drawingml::GraphicalObjectFrameContext( *this, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.OLE2Shape" ) ), true ) );
107 		break;
108 
109 	}
110 	if( !xRet.is() )
111 		xRet.set( this );
112 
113 
114 	return xRet;
115 }
116 
117 } }
118