/src/libreoffice/oox/source/drawingml/shapecontext.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
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 | | |
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> |
37 | | |
38 | | using namespace oox::core; |
39 | | using namespace ::com::sun::star; |
40 | | using namespace ::com::sun::star::uno; |
41 | | |
42 | | namespace oox::drawingml { |
43 | | |
44 | | // CT_Shape |
45 | | ShapeContext::ShapeContext( ContextHandler2Helper const & rParent, ShapePtr pMasterShapePtr, ShapePtr pShapePtr ) |
46 | 106k | : ContextHandler2( rParent ) |
47 | 106k | , mpMasterShapePtr(std::move( pMasterShapePtr )) |
48 | 106k | , mpShapePtr(std::move( pShapePtr )) |
49 | 106k | { |
50 | 106k | if( mpMasterShapePtr && mpShapePtr ) |
51 | 97.1k | mpMasterShapePtr->addChild( mpShapePtr ); |
52 | 106k | } |
53 | | |
54 | | ShapeContext::~ShapeContext() |
55 | 106k | { |
56 | 106k | } |
57 | | |
58 | | ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) |
59 | 572k | { |
60 | 572k | switch( getBaseToken( aElementToken ) ) |
61 | 572k | { |
62 | | // nvSpPr CT_ShapeNonVisual begin |
63 | | // case XML_drElemPr: |
64 | | // break; |
65 | 59 | case XML_extLst: |
66 | 118 | case XML_ext: |
67 | 118 | break; |
68 | 0 | case XML_decorative: |
69 | 0 | { |
70 | 0 | mpShapePtr->setDecorative(rAttribs.getBool(XML_val, false)); |
71 | 0 | } |
72 | 0 | break; |
73 | 100k | case XML_cNvPr: |
74 | 100k | { |
75 | | // If Shape ID is already assigned don't reassign it |
76 | 100k | if (mpShapePtr->getId().isEmpty()) |
77 | 6.67k | mpShapePtr->setId(rAttribs.getStringDefaulted(XML_id)); |
78 | | |
79 | 100k | mpShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) ); |
80 | 100k | mpShapePtr->setName( rAttribs.getStringDefaulted( XML_name ) ); |
81 | 100k | mpShapePtr->setDescription( rAttribs.getStringDefaulted( XML_descr ) ); |
82 | 100k | mpShapePtr->setTitle(rAttribs.getStringDefaulted(XML_title)); |
83 | 100k | break; |
84 | 59 | } |
85 | 0 | case XML_hlinkMouseOver: |
86 | 56 | case XML_hlinkClick: |
87 | 56 | return new HyperLinkContext( *this, rAttribs, getShape()->getShapeProperties() ); |
88 | 77.2k | case XML_ph: |
89 | 77.2k | mpShapePtr->setSubType( rAttribs.getToken( XML_type, XML_obj ) ); |
90 | 77.2k | if( rAttribs.hasAttribute( XML_idx ) ) |
91 | 36.9k | mpShapePtr->setSubTypeIndex( rAttribs.getInteger( XML_idx, 0 ) ); |
92 | 77.2k | if( rAttribs.hasAttribute( XML_hasCustomPrompt ) ) |
93 | 0 | mpShapePtr->setCustomPrompt( rAttribs.getBool( XML_hasCustomPrompt, false ) ); |
94 | 77.2k | break; |
95 | | // nvSpPr CT_ShapeNonVisual end |
96 | | |
97 | 8.35k | case XML_spPr: |
98 | 8.35k | return new ShapePropertiesContext( *this, *mpShapePtr ); |
99 | | |
100 | 2.94k | case XML_style: |
101 | 2.94k | return new ShapeStyleContext( *this, *mpShapePtr ); |
102 | | |
103 | 2.29k | case XML_txBody: |
104 | 2.29k | case XML_txbxContent: |
105 | 2.29k | { |
106 | 2.29k | if (!mpShapePtr->getTextBody()) |
107 | 2.29k | mpShapePtr->setTextBody( std::make_shared<TextBody>() ); |
108 | 2.29k | return new TextBodyContext( *this, mpShapePtr ); |
109 | 2.29k | } |
110 | 280 | case XML_txXfrm: // diagram shape. [MS-ODRAWXML] |
111 | 280 | { |
112 | 280 | const TextBodyPtr& rShapePtr = mpShapePtr->getTextBody(); |
113 | 280 | if (rShapePtr) |
114 | 280 | return new oox::drawingml::Transform2DContext( *this, rAttribs, *mpShapePtr, true ); |
115 | 280 | } |
116 | 0 | break; |
117 | 96.7k | case XML_cNvSpPr: |
118 | 96.7k | break; |
119 | 78.0k | case XML_spLocks: |
120 | 78.0k | break; |
121 | 0 | case XML_bodyPr: |
122 | 0 | if (!mpShapePtr->getTextBody()) |
123 | 0 | mpShapePtr->setTextBody( std::make_shared<TextBody>() ); |
124 | 0 | return new TextBodyPropertiesContext( *this, rAttribs, mpShapePtr ); |
125 | 0 | case XML_txbx: |
126 | 0 | break; |
127 | 3.72k | case XML_cNvPicPr: |
128 | 3.72k | break; |
129 | 3.73k | case XML_nvPicPr: |
130 | 5.93k | case XML_picLocks: |
131 | 5.93k | break; |
132 | 141 | case XML_relIds: |
133 | 141 | break; |
134 | 95.9k | case XML_nvSpPr: |
135 | 95.9k | break; |
136 | 100k | default: |
137 | 100k | SAL_INFO("oox", "ShapeContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken)); |
138 | 100k | break; |
139 | 572k | } |
140 | | |
141 | 558k | return this; |
142 | 572k | } |
143 | | |
144 | | } |
145 | | |
146 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |