Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / oox / source / drawingml / shapecontext.cxx
blob75db4852c2011c671d96811c620fa2bb659ca3c2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 {
50 // CT_Shape
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
69 // case XML_drElemPr:
70 // break;
71 case XML_cNvPr:
73 mpShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
74 mpShapePtr->setId( rAttribs.getString( XML_id ).get() );
75 mpShapePtr->setName( rAttribs.getString( XML_name ).get() );
76 break;
78 case XML_hlinkMouseOver:
79 case XML_hlinkClick:
80 return new HyperLinkContext( *this, rAttribs, getShape()->getShapeProperties() );
81 case XML_ph:
82 mpShapePtr->setSubType( rAttribs.getToken( XML_type, XML_obj ) );
83 if( rAttribs.hasAttribute( XML_idx ) )
84 mpShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).get().toInt32() );
85 break;
86 // nvSpPr CT_ShapeNonVisual end
88 case XML_spPr:
89 return new ShapePropertiesContext( *this, *mpShapePtr );
91 case XML_style:
92 return new ShapeStyleContext( *this, *mpShapePtr );
94 case XML_txBody:
95 case XML_txbxContent:
97 if (!mpShapePtr->getTextBody())
98 mpShapePtr->setTextBody( std::make_shared<TextBody>() );
99 return new TextBodyContext( *this, *mpShapePtr->getTextBody() );
101 case XML_txXfrm:
103 mpShapePtr->getTextBody()->getTextProperties().moRotation = rAttribs.getInteger( XML_rot );
104 return nullptr;
106 case XML_cNvSpPr:
107 break;
108 case XML_spLocks:
109 break;
110 case XML_bodyPr:
111 if (!mpShapePtr->getTextBody())
112 mpShapePtr->setTextBody( std::make_shared<TextBody>() );
113 return new TextBodyPropertiesContext( *this, rAttribs, mpShapePtr->getTextBody()->getTextProperties() );
114 break;
115 case XML_txbx:
116 break;
117 case XML_cNvPicPr:
118 break;
119 case XML_nvPicPr:
120 break;
121 case XML_relIds:
122 break;
123 case XML_nvSpPr:
124 break;
125 default:
126 SAL_WARN("oox", "ShapeContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
127 break;
130 return this;
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */