/src/libreoffice/oox/source/drawingml/scene3dcontext.cxx
Line | Count | Source (jump to first uncovered line) |
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 <drawingml/scene3dcontext.hxx> |
21 | | #include <drawingml/colorchoicecontext.hxx> |
22 | | #include <oox/helper/attributelist.hxx> |
23 | | #include <oox/token/namespaces.hxx> |
24 | | #include <oox/token/tokens.hxx> |
25 | | |
26 | | using namespace ::oox::core; |
27 | | using namespace ::com::sun::star; |
28 | | |
29 | | namespace oox::drawingml { |
30 | | |
31 | | Scene3DPropertiesContext::Scene3DPropertiesContext( ContextHandler2Helper const & rParent, Shape3DProperties& r3DProperties ) noexcept |
32 | 26 | : ContextHandler2( rParent ) |
33 | 26 | , mr3DProperties( r3DProperties ) |
34 | 26 | { |
35 | 26 | } |
36 | | |
37 | | ContextHandlerRef Scene3DPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) |
38 | 52 | { |
39 | 52 | switch( aElementToken ) |
40 | 52 | { |
41 | 26 | case A_TOKEN( camera ): |
42 | 26 | if( rAttribs.hasAttribute( XML_fov ) ) |
43 | 0 | mr3DProperties.mfFieldOfVision = rAttribs.getInteger( XML_fov, 0 ) / 60000.0; // 60000ths of degree |
44 | 26 | if( rAttribs.hasAttribute( XML_zoom ) ) |
45 | 0 | mr3DProperties.mfZoom = rAttribs.getInteger( XML_zoom, 100000 ) / 100000.0; |
46 | 26 | if( rAttribs.hasAttribute( XML_prst ) ) |
47 | 26 | mr3DProperties.mnPreset = rAttribs.getToken( XML_prst, XML_none ); |
48 | | |
49 | 26 | return new Scene3DRotationPropertiesContext( *this, mr3DProperties.maCameraRotation ); |
50 | | |
51 | 26 | case A_TOKEN( lightRig ): |
52 | 26 | mr3DProperties.mnLightRigDirection = rAttribs.getToken( XML_dir, XML_none ); |
53 | 26 | mr3DProperties.mnLightRigType = rAttribs.getToken( XML_rig, XML_none ); |
54 | | |
55 | 26 | return new Scene3DRotationPropertiesContext( *this, mr3DProperties.maLightRigRotation ); |
56 | | |
57 | 0 | case A_TOKEN( backdrop ): |
58 | 0 | case A_TOKEN( extLst ): |
59 | 0 | return nullptr; // TODO: later (backdrop is not supported by core anyway) |
60 | 52 | } |
61 | 0 | return nullptr; |
62 | 52 | } |
63 | | |
64 | | SceneText3DPropertiesContext::SceneText3DPropertiesContext( ContextHandler2Helper const & rParent, Text3DProperties& r3DProperties ) noexcept |
65 | 0 | : ContextHandler2( rParent ) |
66 | 0 | , mr3DProperties( r3DProperties ) |
67 | 0 | { |
68 | 0 | } |
69 | | |
70 | | ContextHandlerRef SceneText3DPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) |
71 | 0 | { |
72 | 0 | switch( aElementToken ) |
73 | 0 | { |
74 | 0 | case A_TOKEN( camera ): |
75 | 0 | if( rAttribs.hasAttribute( XML_fov ) ) |
76 | 0 | mr3DProperties.mfFieldOfVision = rAttribs.getInteger( XML_fov, 0 ) / 60000.0; // 60000ths of degree |
77 | 0 | if( rAttribs.hasAttribute( XML_zoom ) ) |
78 | 0 | mr3DProperties.mfZoom = rAttribs.getInteger( XML_zoom, 100000 ) / 100000.0; |
79 | 0 | if( rAttribs.hasAttribute( XML_prst ) ) |
80 | 0 | mr3DProperties.mnPreset = rAttribs.getToken( XML_prst, XML_none ); |
81 | |
|
82 | 0 | return new Scene3DRotationPropertiesContext( *this, mr3DProperties.maCameraRotation ); |
83 | | |
84 | 0 | case A_TOKEN( lightRig ): |
85 | 0 | mr3DProperties.mnLightRigDirection = rAttribs.getToken( XML_dir, XML_none ); |
86 | 0 | mr3DProperties.mnLightRigType = rAttribs.getToken( XML_rig, XML_none ); |
87 | |
|
88 | 0 | return new Scene3DRotationPropertiesContext( *this, mr3DProperties.maLightRigRotation ); |
89 | | |
90 | 0 | case A_TOKEN( backdrop ): |
91 | 0 | case A_TOKEN( extLst ): |
92 | 0 | return nullptr; // TODO: later (backdrop is not supported by core anyway) |
93 | | |
94 | 0 | case A_TOKEN( bevelT ): |
95 | 0 | case A_TOKEN( bevelB ): |
96 | 0 | { |
97 | 0 | BevelProperties aProps; |
98 | 0 | if( rAttribs.hasAttribute( XML_w ) ) |
99 | 0 | aProps.mnWidth = rAttribs.getInteger( XML_w, 0 ); |
100 | 0 | if( rAttribs.hasAttribute( XML_h ) ) |
101 | 0 | aProps.mnHeight = rAttribs.getInteger( XML_h, 0 ); |
102 | 0 | if( rAttribs.hasAttribute( XML_prst ) ) |
103 | 0 | aProps.mnPreset = rAttribs.getToken( XML_prst, XML_none ); |
104 | |
|
105 | 0 | if( aElementToken == A_TOKEN( bevelT ) ) |
106 | 0 | mr3DProperties.maTopBevelProperties = aProps; |
107 | 0 | else |
108 | 0 | mr3DProperties.maBottomBevelProperties = aProps; |
109 | 0 | break; |
110 | 0 | } |
111 | | |
112 | 0 | case A_TOKEN( extrusionClr ): |
113 | 0 | return new ColorContext( *this, mr3DProperties.maExtrusionColor ); |
114 | | |
115 | 0 | case A_TOKEN( contourClr ): |
116 | 0 | return new ColorContext( *this, mr3DProperties.maContourColor ); |
117 | 0 | } |
118 | 0 | return nullptr; |
119 | 0 | } |
120 | | |
121 | | Shape3DPropertiesContext::Shape3DPropertiesContext( ContextHandler2Helper const & rParent, const AttributeList& rAttribs, Shape3DProperties& r3DProperties ) noexcept |
122 | 3 | : ContextHandler2( rParent ) |
123 | 3 | , mr3DProperties( r3DProperties ) |
124 | 3 | { |
125 | 3 | if( rAttribs.hasAttribute( XML_extrusionH ) ) |
126 | 3 | mr3DProperties.mnExtrusionH = rAttribs.getInteger( XML_extrusionH, 0 ); |
127 | 3 | if( rAttribs.hasAttribute( XML_contourW ) ) |
128 | 3 | mr3DProperties.mnContourW = rAttribs.getInteger( XML_contourW, 0 ); |
129 | 3 | if( rAttribs.hasAttribute( XML_z ) ) |
130 | 0 | mr3DProperties.mnShapeZ = rAttribs.getInteger( XML_z, 0 ); |
131 | 3 | if( rAttribs.hasAttribute( XML_prstMaterial ) ) |
132 | 3 | mr3DProperties.mnMaterial = rAttribs.getToken( XML_prstMaterial, XML_none ); |
133 | 3 | } |
134 | | |
135 | | ContextHandlerRef Shape3DPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) |
136 | 3 | { |
137 | 3 | switch( aElementToken ) |
138 | 3 | { |
139 | 0 | case A_TOKEN( bevelT ): |
140 | 0 | case A_TOKEN( bevelB ): |
141 | 0 | { |
142 | 0 | BevelProperties aProps; |
143 | 0 | if( rAttribs.hasAttribute( XML_w ) ) |
144 | 0 | aProps.mnWidth = rAttribs.getInteger( XML_w, 0 ); |
145 | 0 | if( rAttribs.hasAttribute( XML_h ) ) |
146 | 0 | aProps.mnHeight = rAttribs.getInteger( XML_h, 0 ); |
147 | 0 | if( rAttribs.hasAttribute( XML_prst ) ) |
148 | 0 | aProps.mnPreset = rAttribs.getToken( XML_prst, XML_none ); |
149 | |
|
150 | 0 | if( aElementToken == A_TOKEN( bevelT ) ) |
151 | 0 | mr3DProperties.maTopBevelProperties = aProps; |
152 | 0 | else |
153 | 0 | mr3DProperties.maBottomBevelProperties = aProps; |
154 | |
|
155 | 0 | break; |
156 | 0 | } |
157 | 3 | case A_TOKEN( extrusionClr ): |
158 | 3 | return new ColorContext( *this, mr3DProperties.maExtrusionColor ); |
159 | | |
160 | 0 | case A_TOKEN( contourClr ): |
161 | 0 | return new ColorContext( *this, mr3DProperties.maContourColor ); |
162 | 3 | } |
163 | 0 | return nullptr; |
164 | 3 | } |
165 | | |
166 | | Scene3DRotationPropertiesContext::Scene3DRotationPropertiesContext( ContextHandler2Helper const & rParent, RotationProperties& rRotationProperties ) noexcept |
167 | 52 | : ContextHandler2( rParent ) |
168 | 52 | , mrRotationProperties( rRotationProperties ) |
169 | 52 | { |
170 | 52 | } |
171 | | |
172 | | ContextHandlerRef Scene3DRotationPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) |
173 | 23 | { |
174 | 23 | switch( aElementToken ) |
175 | 23 | { |
176 | 23 | case A_TOKEN( rot ): |
177 | 23 | mrRotationProperties.mnLatitude = rAttribs.getInteger( XML_lat, 0 ); |
178 | 23 | mrRotationProperties.mnLongitude = rAttribs.getInteger( XML_lon, 0 ); |
179 | 23 | mrRotationProperties.mnRevolution = rAttribs.getInteger( XML_rev, 0 ); |
180 | 23 | break; |
181 | 23 | } |
182 | 23 | return nullptr; |
183 | 23 | } |
184 | | |
185 | | } |
186 | | |
187 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |