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/drawing/LineStyle.hpp>
22 #include <com/sun/star/beans/XMultiPropertySet.hpp>
23 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 #include <com/sun/star/container/XNamed.hpp>
26 #include "oox/helper/attributelist.hxx"
27 #include "oox/drawingml/shapecontext.hxx"
28 #include <drawingml/shapepropertiescontext.hxx>
29 #include "drawingml/shapestylecontext.hxx"
30 #include "drawingml/misccontexts.hxx"
31 #include "drawingml/lineproperties.hxx"
32 #include "oox/drawingml/drawingmltypes.hxx"
33 #include "drawingml/customshapegeometry.hxx"
34 #include "drawingml/textbodycontext.hxx"
35 #include "drawingml/textbodypropertiescontext.hxx"
36 #include "hyperlinkcontext.hxx"
37 #include <oox/token/namespaces.hxx>
38 #include <oox/token/tokens.hxx>
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
;
48 namespace oox
{ namespace drawingml
{
51 ShapeContext::ShapeContext( ContextHandler2Helper
& rParent
, ShapePtr
const & pMasterShapePtr
, ShapePtr
const & pShapePtr
)
52 : ContextHandler2( rParent
)
53 , mpMasterShapePtr( pMasterShapePtr
)
54 , mpShapePtr( pShapePtr
)
58 ShapeContext::~ShapeContext()
60 if ( mpMasterShapePtr
.get() && mpShapePtr
.get() )
61 mpMasterShapePtr
->addChild( mpShapePtr
);
64 ContextHandlerRef
ShapeContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
66 switch( getBaseToken( aElementToken
) )
68 // nvSpPr CT_ShapeNonVisual begin
73 mpShapePtr
->setHidden( rAttribs
.getBool( XML_hidden
, false ) );
74 mpShapePtr
->setId( rAttribs
.getString( XML_id
).get() );
75 mpShapePtr
->setName( rAttribs
.getString( XML_name
).get() );
78 case XML_hlinkMouseOver
:
80 return new HyperLinkContext( *this, rAttribs
, getShape()->getShapeProperties() );
82 mpShapePtr
->setSubType( rAttribs
.getToken( XML_type
, XML_obj
) );
83 if( rAttribs
.hasAttribute( XML_idx
) )
84 mpShapePtr
->setSubTypeIndex( rAttribs
.getString( XML_idx
).get().toInt32() );
86 // nvSpPr CT_ShapeNonVisual end
89 return new ShapePropertiesContext( *this, *mpShapePtr
);
92 return new ShapeStyleContext( *this, *mpShapePtr
);
97 if (!mpShapePtr
->getTextBody())
98 mpShapePtr
->setTextBody( std::make_shared
<TextBody
>() );
99 return new TextBodyContext( *this, *mpShapePtr
->getTextBody() );
103 mpShapePtr
->getTextBody()->getTextProperties().moRotation
= rAttribs
.getInteger( XML_rot
);
111 if (!mpShapePtr
->getTextBody())
112 mpShapePtr
->setTextBody( std::make_shared
<TextBody
>() );
113 return new TextBodyPropertiesContext( *this, rAttribs
, mpShapePtr
->getTextBody()->getTextProperties() );
126 SAL_WARN("oox", "ShapeContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken
));
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */