LibreOffice Module chart2 (master) 1
tp_3D_SceneAppearance.cxx
Go to the documentation of this file.
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
21#include <ChartModelHelper.hxx>
22#include <ChartModel.hxx>
23#include <ThreeDHelper.hxx>
25#include <Diagram.hxx>
26#include <com/sun/star/drawing/ShadeMode.hpp>
28#include <utility>
29#include <vcl/svapp.hxx>
30
31using namespace ::com::sun::star;
32
33namespace
34{
35
36struct lcl_ModelProperties
37{
38 drawing::ShadeMode m_aShadeMode;
39 sal_Int32 m_nRoundedEdges;
40 sal_Int32 m_nObjectLines;
42
43 lcl_ModelProperties()
44 : m_aShadeMode(drawing::ShadeMode_FLAT)
45 , m_nRoundedEdges(-1)
46 , m_nObjectLines(-1)
48 {}
49};
50
51lcl_ModelProperties lcl_getPropertiesFromModel( rtl::Reference<::chart::ChartModel> const & xModel )
52{
53 lcl_ModelProperties aProps;
54 try
55 {
56 rtl::Reference< ::chart::Diagram > xDiagram( xModel->getFirstChartDiagram() );
57 xDiagram->getPropertyValue( "D3DSceneShadeMode" ) >>= aProps.m_aShadeMode;
58 ::chart::ThreeDHelper::getRoundedEdgesAndObjectLines( xDiagram, aProps.m_nRoundedEdges, aProps.m_nObjectLines );
59 aProps.m_eScheme = xDiagram->detectScheme();
60 }
61 catch( const uno::Exception & )
62 {
64 }
65 return aProps;
66}
67
68void lcl_setShadeModeAtModel( rtl::Reference<::chart::ChartModel> const & xModel, drawing::ShadeMode aShadeMode )
69{
70 try
71 {
72 rtl::Reference< ::chart::Diagram > xDiaProp = xModel->getFirstChartDiagram();
73 xDiaProp->setPropertyValue( "D3DSceneShadeMode" , uno::Any( aShadeMode ));
74 }
75 catch( const uno::Exception & )
76 {
78 }
79}
80
81} // anonymous namespace
82
83namespace chart
84{
85
86#define POS_3DSCHEME_SIMPLE 0
87#define POS_3DSCHEME_REALISTIC 1
88#define POS_3DSCHEME_CUSTOM 2
89
92 ControllerLockHelper& rControllerLockHelper)
93 : m_xChartModel(std::move(xChartModel))
94 , m_bUpdateOtherControls(true)
95 , m_bCommitToModel(true)
96 , m_rControllerLockHelper(rControllerLockHelper)
97 , m_xBuilder(Application::CreateBuilder(pParent, "modules/schart/ui/tp_3D_SceneAppearance.ui"))
98 , m_xContainer(m_xBuilder->weld_container("tp_3D_SceneAppearance"))
99 , m_xLB_Scheme(m_xBuilder->weld_combo_box("LB_SCHEME"))
100 , m_xCB_Shading(m_xBuilder->weld_check_button("CB_SHADING"))
101 , m_xCB_ObjectLines(m_xBuilder->weld_check_button("CB_OBJECTLINES"))
102 , m_xCB_RoundedEdge(m_xBuilder->weld_check_button("CB_ROUNDEDEDGE"))
103{
106
107 m_xLB_Scheme->connect_changed( LINK( this, ThreeD_SceneAppearance_TabPage, SelectSchemeHdl ) );
108
109 m_xCB_RoundedEdge->connect_toggled( LINK( this, ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines ) );
110 m_xCB_Shading->connect_toggled( LINK( this, ThreeD_SceneAppearance_TabPage, SelectShading ) );
111 m_xCB_ObjectLines->connect_toggled( LINK( this, ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines ) );
112
114}
115
117{
118}
119
121{
122 updateScheme();
123}
124
126{
128 return;
129
130 sal_Int32 nObjectLines = -1;
131
132 switch( m_xCB_ObjectLines->get_state())
133 {
134 case TRISTATE_FALSE:
135 nObjectLines = 0;
136 break;
137 case TRISTATE_TRUE:
138 nObjectLines = 1;
139 break;
140 case TRISTATE_INDET:
141 nObjectLines = -1;
142 break;
143 }
144
145 sal_Int32 nCurrentRoundedEdges = -1;
146 switch( m_xCB_RoundedEdge->get_state() )
147 {
148 case TRISTATE_FALSE:
149 nCurrentRoundedEdges = 0;
150 break;
151 case TRISTATE_TRUE:
152 nCurrentRoundedEdges = 5;
153 break;
154 case TRISTATE_INDET:
155 nCurrentRoundedEdges = -1;
156 break;
157 }
158
159 // locked controllers
162 m_xChartModel->getFirstChartDiagram(), nCurrentRoundedEdges, nObjectLines );
163}
164
166{
168 return;
169
170 drawing::ShadeMode aShadeMode = drawing::ShadeMode_PHONG;
171
172 switch( m_xCB_Shading->get_state())
173 {
174 case TRISTATE_FALSE:
175 aShadeMode = drawing::ShadeMode_FLAT;
176 break;
177 case TRISTATE_TRUE:
178 aShadeMode = drawing::ShadeMode_SMOOTH;
179 break;
180 case TRISTATE_INDET:
181 // nothing
182 break;
183 }
184
185 lcl_setShadeModeAtModel( m_xChartModel, aShadeMode );
186}
187
189{
190 m_bCommitToModel = false;
192
193 lcl_ModelProperties aProps( lcl_getPropertiesFromModel( m_xChartModel ));
194
195 if(aProps.m_aShadeMode == drawing::ShadeMode_FLAT)
196 {
197 m_xCB_Shading->set_active(false);
198 }
199 else if(aProps.m_aShadeMode == drawing::ShadeMode_SMOOTH)
200 {
201 m_xCB_Shading->set_active(true);
202 }
203 else
204 {
205 m_xCB_Shading->set_state(TRISTATE_INDET);
206 }
207
208 if(aProps.m_nObjectLines == 0)
209 {
210 m_xCB_ObjectLines->set_active(false);
211 }
212 else if(aProps.m_nObjectLines==1)
213 {
214 m_xCB_ObjectLines->set_active(true);
215 }
216 else
217 {
219 }
220
221 if(aProps.m_nRoundedEdges >= 5)
222 {
223 m_xCB_RoundedEdge->set_active(true);
224 }
225 else if(aProps.m_nRoundedEdges<0)
226 {
228 }
229 else
230 {
231 m_xCB_RoundedEdge->set_active(false);
232 }
233 m_xCB_RoundedEdge->set_sensitive( !m_xCB_ObjectLines->get_active() );
234
235 updateScheme();
236
237 m_bCommitToModel = true;
239}
240
242{
243 lcl_ModelProperties aProps( lcl_getPropertiesFromModel( m_xChartModel ));
244
245 if (m_xLB_Scheme->get_count() == (POS_3DSCHEME_CUSTOM+1))
247 switch( aProps.m_eScheme )
248 {
250 m_xLB_Scheme->set_active( POS_3DSCHEME_SIMPLE );
251 break;
254 break;
256 {
259 }
260 break;
261 }
262}
263
265{
266 if( !m_bUpdateOtherControls )
267 return;
268
269 {
270 // locked controllers
271 ControllerLockHelperGuard aGuard( m_rControllerLockHelper );
272
273 rtl::Reference< Diagram > xDiagram = m_xChartModel->getFirstChartDiagram();
274
275 if( m_xLB_Scheme->get_active() == POS_3DSCHEME_REALISTIC )
277 else if( m_xLB_Scheme->get_active() == POS_3DSCHEME_SIMPLE )
278 xDiagram->setScheme( ThreeDLookScheme::ThreeDLookScheme_Simple );
279 else
280 {
281 OSL_FAIL( "Invalid Entry selected" );
282 }
283 }
284
285 // update other controls
286 initControlsFromModel();
287}
288
290{
291 if( !m_bUpdateOtherControls )
292 return;
293
294 applyShadeModeToModel();
295 updateScheme();
296}
297
298IMPL_LINK(ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines, weld::Toggleable&, rCheckBox, void)
299{
300 if( !m_bUpdateOtherControls )
301 return;
302
303 if (&rCheckBox == m_xCB_ObjectLines.get())
304 {
305 m_bUpdateOtherControls = false;
306 m_xCB_RoundedEdge->set_sensitive( !m_xCB_ObjectLines->get_active() );
307 if(!m_xCB_RoundedEdge->get_sensitive())
308 m_xCB_RoundedEdge->set_active(false);
309 m_bUpdateOtherControls = true;
310 }
311
312 applyRoundedEdgeAndObjectLinesToModel();
313 updateScheme();
314}
315
316} //namespace chart
317
318/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This guard calls lockControllers at the given ControllerLockHelper in the CTOR and unlockControllers ...
This helper class can be used to pass a locking mechanism to other objects without exposing the full ...
static void setRoundedEdgesAndObjectLines(const rtl::Reference< ::chart::Diagram > &xDiagram, sal_Int32 nRoundedEdges, sal_Int32 nObjectLines)
static void getRoundedEdgesAndObjectLines(const rtl::Reference< ::chart::Diagram > &xDiagram, sal_Int32 &rnRoundedEdges, sal_Int32 &rnObjectLines)
ThreeD_SceneAppearance_TabPage(weld::Container *pParent, rtl::Reference<::chart::ChartModel > xChartModel, ControllerLockHelper &rControllerLockHelper)
rtl::Reference<::chart::ChartModel > m_xChartModel
std::unique_ptr< weld::CheckButton > m_xCB_RoundedEdge
std::unique_ptr< weld::CheckButton > m_xCB_Shading
std::unique_ptr< weld::ComboBox > m_xLB_Scheme
std::unique_ptr< weld::CheckButton > m_xCB_ObjectLines
#define DBG_UNHANDLED_EXCEPTION(...)
TRISTATE_FALSE
TRISTATE_INDET
TRISTATE_TRUE
ThreeDLookScheme
IMPL_LINK(StackingResourceGroup, StackingChangeHdl, weld::Toggleable &, rRadio, void)
IMPL_LINK_NOARG(SplinePropertiesDialog, SplineTypeListBoxHdl, weld::ComboBox &, void)
Reference< XNameAccess > m_xContainer
Reference< XModel > xModel
#define POS_3DSCHEME_CUSTOM