Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / oox / source / drawingml / shapecontext.cxx
blob60feae99f656fd247c04828e55c2cab470c2c692
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>
39 #include <sal/log.hxx>
41 using namespace oox::core;
42 using namespace ::com::sun::star;
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::drawing;
45 using namespace ::com::sun::star::beans;
46 using namespace ::com::sun::star::text;
47 using namespace ::com::sun::star::xml::sax;
49 namespace oox { namespace drawingml {
51 // CT_Shape
52 ShapeContext::ShapeContext( ContextHandler2Helper const & rParent, ShapePtr const & pMasterShapePtr, ShapePtr const & pShapePtr )
53 : ContextHandler2( rParent )
54 , mpMasterShapePtr( pMasterShapePtr )
55 , mpShapePtr( pShapePtr )
57 if( mpMasterShapePtr.get() && mpShapePtr.get() )
58 mpMasterShapePtr->addChild( mpShapePtr );
61 ShapeContext::~ShapeContext()
65 ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
67 switch( getBaseToken( aElementToken ) )
69 // nvSpPr CT_ShapeNonVisual begin
70 // case XML_drElemPr:
71 // break;
72 case XML_cNvPr:
74 mpShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
75 mpShapePtr->setId( rAttribs.getString( XML_id ).get() );
76 mpShapePtr->setName( rAttribs.getString( XML_name ).get() );
77 mpShapePtr->setDescription( rAttribs.getString( XML_descr ).get() );
78 break;
80 case XML_hlinkMouseOver:
81 case XML_hlinkClick:
82 return new HyperLinkContext( *this, rAttribs, getShape()->getShapeProperties() );
83 case XML_ph:
84 mpShapePtr->setSubType( rAttribs.getToken( XML_type, XML_obj ) );
85 if( rAttribs.hasAttribute( XML_idx ) )
86 mpShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).get().toInt32() );
87 break;
88 // nvSpPr CT_ShapeNonVisual end
90 case XML_spPr:
91 return new ShapePropertiesContext( *this, *mpShapePtr );
93 case XML_style:
94 return new ShapeStyleContext( *this, *mpShapePtr );
96 case XML_txBody:
97 case XML_txbxContent:
99 if (!mpShapePtr->getTextBody())
100 mpShapePtr->setTextBody( std::make_shared<TextBody>() );
101 return new TextBodyContext( *this, mpShapePtr );
103 case XML_txXfrm:
105 const TextBodyPtr& rShapePtr = mpShapePtr->getTextBody();
106 if (rShapePtr)
107 rShapePtr->getTextProperties().moRotation = rAttribs.getInteger( XML_rot );
108 return nullptr;
110 case XML_cNvSpPr:
111 break;
112 case XML_spLocks:
113 break;
114 case XML_bodyPr:
115 if (!mpShapePtr->getTextBody())
116 mpShapePtr->setTextBody( std::make_shared<TextBody>() );
117 return new TextBodyPropertiesContext( *this, rAttribs, mpShapePtr );
118 break;
119 case XML_txbx:
120 break;
121 case XML_cNvPicPr:
122 break;
123 case XML_nvPicPr:
124 break;
125 case XML_relIds:
126 break;
127 case XML_nvSpPr:
128 break;
129 default:
130 SAL_WARN("oox", "ShapeContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
131 break;
134 return this;
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */