tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / oox / source / drawingml / shapecontext.cxx
blob1cd22c7cd4227b31d23de2e22971d2fbd6ba2b4e
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>
24 #include <oox/helper/attributelist.hxx>
25 #include <oox/drawingml/shapecontext.hxx>
26 #include <drawingml/shapepropertiescontext.hxx>
27 #include <drawingml/shapestylecontext.hxx>
28 #include <oox/drawingml/drawingmltypes.hxx>
29 #include <drawingml/textbodycontext.hxx>
30 #include <drawingml/textbodypropertiescontext.hxx>
31 #include "hyperlinkcontext.hxx"
32 #include <oox/token/namespaces.hxx>
33 #include <oox/token/tokens.hxx>
34 #include <sal/log.hxx>
35 #include <drawingml/transform2dcontext.hxx>
36 #include <utility>
38 using namespace oox::core;
39 using namespace ::com::sun::star;
40 using namespace ::com::sun::star::uno;
42 namespace oox::drawingml {
44 // CT_Shape
45 ShapeContext::ShapeContext( ContextHandler2Helper const & rParent, ShapePtr pMasterShapePtr, ShapePtr pShapePtr )
46 : ContextHandler2( rParent )
47 , mpMasterShapePtr(std::move( pMasterShapePtr ))
48 , mpShapePtr(std::move( pShapePtr ))
50 if( mpMasterShapePtr && mpShapePtr )
51 mpMasterShapePtr->addChild( mpShapePtr );
54 ShapeContext::~ShapeContext()
58 ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
60 switch( getBaseToken( aElementToken ) )
62 // nvSpPr CT_ShapeNonVisual begin
63 // case XML_drElemPr:
64 // break;
65 case XML_extLst:
66 case XML_ext:
67 break;
68 case XML_decorative:
70 mpShapePtr->setDecorative(rAttribs.getBool(XML_val, false));
72 break;
73 case XML_cNvPr:
75 mpShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
76 mpShapePtr->setId( rAttribs.getStringDefaulted( XML_id ) );
77 mpShapePtr->setName( rAttribs.getStringDefaulted( XML_name ) );
78 mpShapePtr->setDescription( rAttribs.getStringDefaulted( XML_descr ) );
79 mpShapePtr->setTitle(rAttribs.getStringDefaulted(XML_title));
80 break;
82 case XML_hlinkMouseOver:
83 case XML_hlinkClick:
84 return new HyperLinkContext( *this, rAttribs, getShape()->getShapeProperties() );
85 case XML_ph:
86 mpShapePtr->setSubType( rAttribs.getToken( XML_type, XML_obj ) );
87 if( rAttribs.hasAttribute( XML_idx ) )
88 mpShapePtr->setSubTypeIndex( rAttribs.getInteger( XML_idx, 0 ) );
89 break;
90 // nvSpPr CT_ShapeNonVisual end
92 case XML_spPr:
93 return new ShapePropertiesContext( *this, *mpShapePtr );
95 case XML_style:
96 return new ShapeStyleContext( *this, *mpShapePtr );
98 case XML_txBody:
99 case XML_txbxContent:
101 if (!mpShapePtr->getTextBody())
102 mpShapePtr->setTextBody( std::make_shared<TextBody>() );
103 return new TextBodyContext( *this, mpShapePtr );
105 case XML_txXfrm: // diagram shape. [MS-ODRAWXML]
107 const TextBodyPtr& rShapePtr = mpShapePtr->getTextBody();
108 if (rShapePtr)
109 return new oox::drawingml::Transform2DContext( *this, rAttribs, *mpShapePtr, true );
111 break;
112 case XML_cNvSpPr:
113 break;
114 case XML_spLocks:
115 break;
116 case XML_bodyPr:
117 if (!mpShapePtr->getTextBody())
118 mpShapePtr->setTextBody( std::make_shared<TextBody>() );
119 return new TextBodyPropertiesContext( *this, rAttribs, mpShapePtr );
120 case XML_txbx:
121 break;
122 case XML_cNvPicPr:
123 break;
124 case XML_nvPicPr:
125 case XML_picLocks:
126 break;
127 case XML_relIds:
128 break;
129 case XML_nvSpPr:
130 break;
131 default:
132 SAL_INFO("oox", "ShapeContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
133 break;
136 return this;
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */