1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
24 #include "oox/helper/attributelist.hxx"
25 #include "oox/drawingml/shapegroupcontext.hxx"
26 #include "oox/drawingml/connectorshapecontext.hxx"
27 #include "oox/drawingml/graphicshapecontext.hxx"
28 #include "drawingml/lineproperties.hxx"
29 #include "oox/drawingml/drawingmltypes.hxx"
30 #include "drawingml/customshapegeometry.hxx"
31 #include <drawingml/shapepropertiescontext.hxx>
32 #include "drawingml/textbodycontext.hxx"
33 #include <oox/token/namespaces.hxx>
34 #include <oox/token/tokens.hxx>
36 using namespace oox::core
;
37 using namespace ::com::sun::star
;
38 using namespace ::com::sun::star::uno
;
39 using namespace ::com::sun::star::drawing
;
40 using namespace ::com::sun::star::beans
;
41 using namespace ::com::sun::star::text
;
42 using namespace ::com::sun::star::xml::sax
;
44 namespace oox
{ namespace drawingml
{
46 ShapeGroupContext::ShapeGroupContext( ContextHandler2Helper
& rParent
, ShapePtr
const & pMasterShapePtr
, ShapePtr
const & pGroupShapePtr
)
47 : ContextHandler2( rParent
)
48 , mpGroupShapePtr( pGroupShapePtr
)
49 , mpMasterShapePtr( pMasterShapePtr
)
52 mpGroupShapePtr
->setWps(pMasterShapePtr
->getWps());
55 ShapeGroupContext::~ShapeGroupContext()
57 if ( mpMasterShapePtr
.get() && mpGroupShapePtr
.get() )
58 mpMasterShapePtr
->addChild( mpGroupShapePtr
);
61 ContextHandlerRef
ShapeGroupContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
63 switch( getBaseToken( aElementToken
) )
67 mpGroupShapePtr
->setHidden( rAttribs
.getBool( XML_hidden
, false ) );
68 mpGroupShapePtr
->setId( rAttribs
.getString( XML_id
).get() );
69 mpGroupShapePtr
->setName( rAttribs
.getString( XML_name
).get() );
73 mpGroupShapePtr
->setSubType( rAttribs
.getToken( XML_type
, FastToken::DONTKNOW
) );
74 if( rAttribs
.hasAttribute( XML_idx
) )
75 mpGroupShapePtr
->setSubTypeIndex( rAttribs
.getString( XML_idx
).get().toInt32() );
77 // nvSpPr CT_ShapeNonVisual end
80 return new ShapePropertiesContext( *this, *mpGroupShapePtr
);
84 return new ShapePropertiesContext( *this, *mpGroupShapePtr
);
87 return new ShapeStyleContext( getParser() );
89 case XML_cxnSp
: // connector shape
91 ShapePtr
pShape(new Shape("com.sun.star.drawing.ConnectorShape"));
92 pShape
->setLockedCanvas(mpGroupShapePtr
->getLockedCanvas());
93 return new ConnectorShapeContext( *this, mpGroupShapePtr
, pShape
);
95 case XML_grpSp
: // group shape
96 return new ShapeGroupContext( *this, mpGroupShapePtr
, std::make_shared
<Shape
>( "com.sun.star.drawing.GroupShape" ) );
99 // Don't set default character height for WPS shapes, Writer has its
100 // own way to set the default, and if we don't set it here, editing
101 // properly inherits it.
102 return new ShapeContext( *this, mpGroupShapePtr
, std::make_shared
<Shape
>( "com.sun.star.drawing.CustomShape", getBaseToken(aElementToken
) == XML_sp
) );
103 case XML_pic
: // CT_Picture
104 return new GraphicShapeContext( *this, mpGroupShapePtr
, std::make_shared
<Shape
>( "com.sun.star.drawing.GraphicObjectShape" ) );
105 case XML_graphicFrame
: // CT_GraphicalObjectFrame
106 return new GraphicalObjectFrameContext( *this, mpGroupShapePtr
, std::make_shared
<Shape
>( "com.sun.star.drawing.GraphicObjectShape" ), true );
112 SAL_WARN("oox", "ShapeGroupContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken
));
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */