Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include <com/sun/star/xml/sax/FastToken.hpp>
21 : : #include <com/sun/star/beans/XMultiPropertySet.hpp>
22 : : #include <com/sun/star/container/XNamed.hpp>
23 : :
24 : : #include "oox/helper/attributelist.hxx"
25 : : #include "oox/ppt/pptshape.hxx"
26 : : #include "oox/ppt/pptgraphicshapecontext.hxx"
27 : : #include "oox/ppt/pptshapecontext.hxx"
28 : : #include "oox/ppt/pptshapegroupcontext.hxx"
29 : : #include "oox/drawingml/graphicshapecontext.hxx"
30 : : #include "oox/drawingml/lineproperties.hxx"
31 : : #include "oox/drawingml/drawingmltypes.hxx"
32 : : #include "oox/drawingml/customshapegeometry.hxx"
33 : : #include "oox/drawingml/textbodycontext.hxx"
34 : : #include "oox/drawingml/connectorshapecontext.hxx"
35 : : #include "oox/drawingml/fillproperties.hxx"
36 : : #include "extdrawingfragmenthandler.hxx"
37 : :
38 : : using rtl::OUString;
39 : : using namespace oox::core;
40 : : using namespace ::com::sun::star;
41 : : using namespace ::com::sun::star::uno;
42 : : using namespace ::com::sun::star::drawing;
43 : : using namespace ::com::sun::star::beans;
44 : : using namespace ::com::sun::star::text;
45 : : using namespace ::com::sun::star::xml::sax;
46 : :
47 : : namespace oox { namespace ppt {
48 : :
49 : 33 : PPTShapeGroupContext::PPTShapeGroupContext(
50 : : ContextHandler& rParent,
51 : : const oox::ppt::SlidePersistPtr pSlidePersistPtr,
52 : : const ShapeLocation eShapeLocation,
53 : : oox::drawingml::ShapePtr pMasterShapePtr,
54 : : oox::drawingml::ShapePtr pGroupShapePtr )
55 : : : ShapeGroupContext( rParent, pMasterShapePtr, pGroupShapePtr )
56 : : , mpSlidePersistPtr( pSlidePersistPtr )
57 : : , meShapeLocation( eShapeLocation )
58 [ + - ][ + - ]: 33 : , pGraphicShape( (PPTShape *)NULL )
[ + - ][ + - ]
[ + - ]
59 : : {
60 : 33 : }
61 : :
62 : 291 : Reference< XFastContextHandler > PPTShapeGroupContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
63 : : {
64 : 291 : Reference< XFastContextHandler > xRet;
65 [ - + ]: 291 : if( getNamespace( aElementToken ) == NMSP_dsp )
66 : 0 : aElementToken = NMSP_ppt | getBaseToken( aElementToken );
67 : :
68 [ + - + - : 291 : switch( aElementToken )
+ - + + -
+ ]
69 : : {
70 : : case PPT_TOKEN( cNvPr ):
71 : : {
72 [ + - ]: 33 : AttributeList aAttribs( xAttribs );
73 [ + - ]: 33 : mpGroupShapePtr->setHidden( aAttribs.getBool( XML_hidden, false ) );
74 [ + - ][ + - ]: 33 : mpGroupShapePtr->setId( xAttribs->getOptionalValue( XML_id ) );
75 [ + - ][ + - ]: 33 : mpGroupShapePtr->setName( xAttribs->getOptionalValue( XML_name ) );
76 [ + - ]: 33 : break;
77 : : }
78 : : case PPT_TOKEN( ph ):
79 [ # # ][ # # ]: 0 : mpGroupShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, FastToken::DONTKNOW ) );
80 [ # # ][ # # ]: 0 : if( xAttribs->hasAttribute( XML_idx ) )
[ # # ]
81 [ # # ][ # # ]: 0 : mpGroupShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() );
[ # # ]
82 : 0 : break;
83 : : // nvSpPr CT_ShapeNonVisual end
84 : :
85 : : case PPT_TOKEN( grpSpPr ):
86 [ + - ][ + - ]: 33 : xRet = new oox::drawingml::ShapePropertiesContext( *this, *mpGroupShapePtr );
[ + - ]
87 : 33 : break;
88 : : case PPT_TOKEN( spPr ):
89 [ # # ][ # # ]: 0 : xRet = new oox::drawingml::ShapePropertiesContext( *this, *mpGroupShapePtr );
[ # # ]
90 : 0 : break;
91 : : /*
92 : : case PPT_TOKEN( style ):
93 : : xRet = new ShapeStyleContext( getParser() );
94 : : break;
95 : : */
96 : : case PPT_TOKEN( cxnSp ): // connector shape
97 [ + - ][ + - ]: 12 : xRet.set( new oox::drawingml::ConnectorShapeContext( *this, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.ConnectorShape" ) ) ) );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
98 : 12 : break;
99 : : case PPT_TOKEN( grpSp ): // group shape
100 [ # # ][ # # ]: 0 : xRet.set( new PPTShapeGroupContext( *this, mpSlidePersistPtr, meShapeLocation, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GroupShape" ) ) ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
101 : 0 : break;
102 : : case PPT_TOKEN( sp ): // Shape
103 : : {
104 [ + - ]: 111 : AttributeList aAttribs( xAttribs );
105 [ + - ][ + - ]: 111 : oox::drawingml::ShapePtr pShape = oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.CustomShape" ) );
[ + - ]
106 [ + - ][ - + ]: 111 : if( aAttribs.getBool( XML_useBgFill, false ) )
107 : : {
108 [ # # ]: 0 : ::oox::drawingml::FillProperties &aFill = pShape->getFillProperties();
109 [ # # ]: 0 : aFill.moFillType = XML_solidFill;
110 : : // This is supposed to fill with slide (background) color, but
111 : : // TODO: We are using white here, because thats the closest we can assume (?)
112 [ # # ]: 0 : aFill.maFillColor.setSrgbClr( API_RGB_WHITE );
113 : : }
114 [ + - ][ + - ]: 111 : xRet.set( new PPTShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, pShape ) );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
115 : : }
116 : 111 : break;
117 : : case PPT_TOKEN( pic ): // CT_Picture
118 [ + - ][ + - ]: 3 : xRet.set( new PPTGraphicShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GraphicObjectShape" ) ) ) );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
119 : 3 : break;
120 : : case PPT_TOKEN( graphicFrame ): // CT_GraphicalObjectFrame
121 : : {
122 [ # # ]: 0 : if( pGraphicShape )
123 [ # # ]: 0 : importExtDrawings();
124 [ # # ][ # # ]: 0 : pGraphicShape = oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.OLE2Shape" ) );
[ # # ][ # # ]
[ # # ]
125 [ # # ][ # # ]: 0 : xRet.set( new oox::drawingml::GraphicalObjectFrameContext( *this, mpGroupShapePtr, pGraphicShape, true ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
126 : : }
127 : 0 : break;
128 : :
129 : : }
130 [ + + ]: 291 : if( !xRet.is() )
131 [ + - ]: 132 : xRet.set( this );
132 : :
133 : :
134 : 291 : return xRet;
135 : : }
136 : :
137 : 165 : void PPTShapeGroupContext::importExtDrawings( )
138 : : {
139 [ - + ]: 165 : if( pGraphicShape )
140 : : {
141 [ # # ][ # # ]: 0 : for( ::std::vector<OUString>::const_iterator aIt = pGraphicShape->getExtDrawings().begin(), aEnd = pGraphicShape->getExtDrawings().end();
142 : : aIt != aEnd; ++aIt )
143 : : {
144 [ # # ]: 0 : getFilter().importFragment( new ExtDrawingFragmentHandler( getFilter(), getFragmentPathFromRelId( *aIt ),
145 : : mpSlidePersistPtr,
146 : : meShapeLocation,
147 : : mpMasterShapePtr,
148 : : mpGroupShapePtr,
149 [ # # # # ]: 0 : pGraphicShape ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
150 : : }
151 [ # # ]: 0 : pGraphicShape = oox::drawingml::ShapePtr( (PPTShape *)NULL );
152 : : }
153 : 165 : }
154 : :
155 : 165 : void PPTShapeGroupContext::endFastElement( sal_Int32 /*nElement*/ ) throw (SAXException, RuntimeException)
156 : : {
157 : 165 : importExtDrawings();
158 : 165 : }
159 : :
160 [ + - ][ + - ]: 285 : } }
161 : :
162 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|