LibreOffice Module chart2 (master) 1
ChartResourceGroups.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
22
23#include <strings.hrc>
24#include <ResId.hxx>
25
26namespace chart
27{
28using namespace ::com::sun::star;
29using namespace ::com::sun::star::chart2;
30
32 : m_xCB_3DLook(pBuilder->weld_check_button("3dlook"))
33 , m_xLB_Scheme(pBuilder->weld_combo_box("3dscheme"))
34{
35 m_xCB_3DLook->connect_toggled(LINK(this, Dim3DLookResourceGroup, Dim3DLookCheckHdl));
36 m_xLB_Scheme->connect_changed(LINK(this, Dim3DLookResourceGroup, SelectSchemeHdl));
37}
38
40{
41 m_xCB_3DLook->set_visible(bShow);
42 m_xLB_Scheme->set_visible(bShow);
43}
44
46{
47 m_xCB_3DLook->set_active(rParameter.b3DLook);
48 m_xLB_Scheme->set_sensitive(rParameter.b3DLook);
49
50 // tdf#124295 - select always a 3D scheme
51 switch (rParameter.eThreeDLookScheme)
52 {
55 break;
59 break;
60 }
61}
62
64{
65 rParameter.b3DLook = m_xCB_3DLook->get_active();
66 // tdf#124295 - select always a 3D scheme
67 switch (m_xLB_Scheme->get_active())
68 {
71 break;
72 default:
74 }
75}
76
78{
79 if (m_pChangeListener)
80 m_pChangeListener->stateChanged();
81}
82
84{
85 if (m_pChangeListener)
86 m_pChangeListener->stateChanged();
87}
88
90 : m_xCB_XValueSorting(pBuilder->weld_check_button("sort"))
91{
92 m_xCB_XValueSorting->connect_toggled(
93 LINK(this, SortByXValuesResourceGroup, SortByXValuesCheckHdl));
94}
95
97{
98 m_xCB_XValueSorting->set_visible(bShow);
99}
100
102{
103 m_xCB_XValueSorting->set_active(rParameter.bSortByXValues);
104}
105
107{
108 rParameter.bSortByXValues = m_xCB_XValueSorting->get_active();
109}
110
112{
113 if (m_pChangeListener)
114 m_pChangeListener->stateChanged();
115}
116
118 : m_xCB_Stacked(pBuilder->weld_check_button("stack"))
119 , m_xRB_Stack_Y(pBuilder->weld_radio_button("ontop"))
120 , m_xRB_Stack_Y_Percent(pBuilder->weld_radio_button("percent"))
121 , m_xRB_Stack_Z(pBuilder->weld_radio_button("deep"))
122{
123 m_xCB_Stacked->connect_toggled(LINK(this, StackingResourceGroup, StackingEnableHdl));
124 m_xRB_Stack_Y->connect_toggled(LINK(this, StackingResourceGroup, StackingChangeHdl));
125 m_xRB_Stack_Y_Percent->connect_toggled(LINK(this, StackingResourceGroup, StackingChangeHdl));
126 m_xRB_Stack_Z->connect_toggled(LINK(this, StackingResourceGroup, StackingChangeHdl));
127}
128
130{
131 m_xCB_Stacked->set_visible(bShow);
132 m_xRB_Stack_Y->set_visible(bShow);
133 m_xRB_Stack_Y_Percent->set_visible(bShow);
134 m_xRB_Stack_Z->set_visible(false);
135}
136
138{
139 m_xCB_Stacked->set_active(
140 rParameter.eStackMode != GlobalStackMode_NONE
141 && rParameter.eStackMode
142 != GlobalStackMode_STACK_Z); //todo remove this condition if z stacking radio button is really used
143 switch (rParameter.eStackMode)
144 {
146 m_xRB_Stack_Y->set_active(true);
147 break;
149 m_xRB_Stack_Y_Percent->set_active(true);
150 break;
152 //todo uncomment this condition if z stacking radio button is really used
153 /*
154 if( rParameter.b3DLook )
155 m_xRB_Stack_Z->set_active(true);
156 else
157 */
158 m_xRB_Stack_Y->set_active(true);
159 break;
160 default:
161 m_xRB_Stack_Y->set_active(true);
162 break;
163 }
164 //dis/enabling
165 m_xCB_Stacked->set_sensitive(!rParameter.bXAxisWithValues);
166 m_xRB_Stack_Y->set_sensitive(m_xCB_Stacked->get_active() && !rParameter.bXAxisWithValues);
167 m_xRB_Stack_Y_Percent->set_sensitive(m_xCB_Stacked->get_active()
168 && !rParameter.bXAxisWithValues);
169 m_xRB_Stack_Z->set_sensitive(m_xCB_Stacked->get_active() && rParameter.b3DLook);
170}
171
173{
174 if (!m_xCB_Stacked->get_active())
175 rParameter.eStackMode = GlobalStackMode_NONE;
176 else if (m_xRB_Stack_Y->get_active())
178 else if (m_xRB_Stack_Y_Percent->get_active())
180 else if (m_xRB_Stack_Z->get_active())
182}
183
184IMPL_LINK(StackingResourceGroup, StackingChangeHdl, weld::Toggleable&, rRadio, void)
185{
186 //for each radio click there are coming two change events
187 //first uncheck of previous button -> ignore that call
188 //the second call gives the check of the new button
189 if (m_pChangeListener && rRadio.get_active())
190 m_pChangeListener->stateChanged();
191}
192
194{
195 if (m_pChangeListener)
196 m_pChangeListener->stateChanged();
197}
198
200 : m_pParent(pParent)
201 , m_xFT_LineType(pBuilder->weld_label("linetypeft"))
202 , m_xLB_LineType(pBuilder->weld_combo_box("linetype"))
203 , m_xPB_DetailsDialog(pBuilder->weld_button("properties"))
204{
205 m_xLB_LineType->connect_changed(LINK(this, SplineResourceGroup, LineTypeChangeHdl));
206}
207
208std::shared_ptr<SplinePropertiesDialog> SplineResourceGroup::getSplinePropertiesDialog()
209{
211 {
213 }
215}
216
217std::shared_ptr<SteppedPropertiesDialog> SplineResourceGroup::getSteppedPropertiesDialog()
218{
220 {
222 }
224}
225
227{
228 m_xFT_LineType->set_visible(bShow);
229 m_xLB_LineType->set_visible(bShow);
230 m_xPB_DetailsDialog->set_visible(bShow);
231}
232
234{
235 switch (rParameter.eCurveStyle)
236 {
237 case CurveStyle_LINES:
239 m_xPB_DetailsDialog->set_sensitive(false);
240 break;
241 case CurveStyle_CUBIC_SPLINES:
242 case CurveStyle_B_SPLINES:
244 m_xPB_DetailsDialog->set_sensitive(true);
245 m_xPB_DetailsDialog->connect_clicked(
246 LINK(this, SplineResourceGroup, SplineDetailsDialogHdl));
247 m_xPB_DetailsDialog->set_tooltip_text(SchResId(STR_DLG_SMOOTH_LINE_PROPERTIES));
248 getSplinePropertiesDialog()->fillControls(rParameter);
249 break;
250 case CurveStyle_STEP_START:
251 case CurveStyle_STEP_END:
252 case CurveStyle_STEP_CENTER_X:
253 case CurveStyle_STEP_CENTER_Y:
255 m_xPB_DetailsDialog->set_sensitive(true);
256 m_xPB_DetailsDialog->connect_clicked(
257 LINK(this, SplineResourceGroup, SteppedDetailsDialogHdl));
258 m_xPB_DetailsDialog->set_tooltip_text(SchResId(STR_DLG_STEPPED_LINE_PROPERTIES));
259 getSteppedPropertiesDialog()->fillControls(rParameter);
260 break;
261 default:
262 m_xLB_LineType->set_active(-1);
263 m_xPB_DetailsDialog->set_sensitive(false);
264 }
265}
267{
268 switch (m_xLB_LineType->get_active())
269 {
271 getSplinePropertiesDialog()->fillParameter(rParameter, true);
272 break;
274 getSteppedPropertiesDialog()->fillParameter(rParameter, true);
275 break;
276 default: // includes POS_LINETYPE_STRAIGHT
277 rParameter.eCurveStyle = CurveStyle_LINES;
278 break;
279 }
280}
281
283{
284 if (m_pChangeListener)
285 m_pChangeListener->stateChanged();
286}
287
288IMPL_LINK_NOARG(SplineResourceGroup, SplineDetailsDialogHdl, weld::Button&, void)
289{
290 ChartTypeParameter aOldParameter;
291 std::shared_ptr<SplinePropertiesDialog> xDlg = getSplinePropertiesDialog();
292 xDlg->fillParameter(aOldParameter, m_xLB_LineType->get_active() == POS_LINETYPE_SMOOTH);
293
294 const sal_Int32 iOldLineTypePos = m_xLB_LineType->get_active();
295 m_xLB_LineType->set_active(POS_LINETYPE_SMOOTH);
296 weld::GenericDialogController::runAsync(xDlg, [this, xDlg, aOldParameter,
297 iOldLineTypePos](sal_Int32 nResult) {
298 m_xSplinePropertiesDialog = nullptr;
299 auto xNewDlg = getSplinePropertiesDialog();
300
301 if (nResult == RET_OK)
302 {
303 ChartTypeParameter aNewParameter;
304 xDlg->fillParameter(aNewParameter, m_xLB_LineType->get_active() == POS_LINETYPE_SMOOTH);
305 xNewDlg->fillControls(aNewParameter);
306
307 if (m_pChangeListener)
308 m_pChangeListener->stateChanged();
309 }
310 else
311 {
312 //restore old state:
313 m_xLB_LineType->set_active(iOldLineTypePos);
314 xNewDlg->fillControls(aOldParameter);
315 }
316 });
317}
318
319IMPL_LINK_NOARG(SplineResourceGroup, SteppedDetailsDialogHdl, weld::Button&, void)
320{
321 ChartTypeParameter aOldParameter;
322 std::shared_ptr<SteppedPropertiesDialog> xDlg = getSteppedPropertiesDialog();
323 xDlg->fillParameter(aOldParameter, m_xLB_LineType->get_active() == POS_LINETYPE_STEPPED);
324
325 const sal_Int32 iOldLineTypePos = m_xLB_LineType->get_active();
326 m_xLB_LineType->set_active(POS_LINETYPE_STEPPED);
327
329 xDlg, [this, xDlg, aOldParameter, iOldLineTypePos](sal_Int32 nResult) {
330 m_xSteppedPropertiesDialog = nullptr;
331 auto xNewDlg = getSplinePropertiesDialog();
332
333 if (nResult == RET_OK)
334 {
335 ChartTypeParameter aNewParameter;
336 xDlg->fillParameter(aNewParameter,
337 m_xLB_LineType->get_active() == POS_LINETYPE_STEPPED);
338 xNewDlg->fillControls(aNewParameter);
339
340 if (m_pChangeListener)
341 m_pChangeListener->stateChanged();
342 }
343 else
344 {
345 //restore old state:
346 m_xLB_LineType->set_active(iOldLineTypePos);
347 xDlg->fillControls(aOldParameter);
348 }
349 });
350}
351
353 : m_aGeometryResources(pBuilder)
354{
356}
357
359
361{
362 sal_uInt16 nGeometry3D = static_cast<sal_uInt16>(rParameter.nGeometry3D);
363 m_aGeometryResources.select(nGeometry3D);
365}
366
368{
369 rParameter.nGeometry3D = 1;
371 if (nSelected != -1)
372 rParameter.nGeometry3D = nSelected;
373}
374
376{
377 if (m_pChangeListener)
378 m_pChangeListener->stateChanged();
379}
380
381} //namespace chart
382
383/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define POS_LINETYPE_STRAIGHT
#define POS_LINETYPE_STEPPED
#define POS_LINETYPE_SMOOTH
void connect_changed(const Link< weld::TreeView &, void > &rLink)
void set_sensitive(bool bEnable)
void select(sal_Int32 nPos)
sal_Int32 get_selected_index() const
css::chart2::CurveStyle eCurveStyle
void fillControls(const ChartTypeParameter &rParameter)
Dim3DLookResourceGroup(weld::Builder *pBuilder)
std::unique_ptr< weld::ComboBox > m_xLB_Scheme
std::unique_ptr< weld::CheckButton > m_xCB_3DLook
void fillParameter(ChartTypeParameter &rParameter)
void fillControls(const ChartTypeParameter &rParameter)
BarGeometryResources m_aGeometryResources
void fillParameter(ChartTypeParameter &rParameter)
GeometryResourceGroup(weld::Builder *pBuilder)
SortByXValuesResourceGroup(weld::Builder *pBuilder)
std::unique_ptr< weld::CheckButton > m_xCB_XValueSorting
void fillParameter(ChartTypeParameter &rParameter)
void fillControls(const ChartTypeParameter &rParameter)
std::shared_ptr< SteppedPropertiesDialog > m_xSteppedPropertiesDialog
std::unique_ptr< weld::ComboBox > m_xLB_LineType
SplineResourceGroup(weld::Builder *pBuilder, weld::Window *pParent)
std::unique_ptr< weld::Label > m_xFT_LineType
void fillParameter(ChartTypeParameter &rParameter)
std::shared_ptr< SplinePropertiesDialog > m_xSplinePropertiesDialog
std::unique_ptr< weld::Button > m_xPB_DetailsDialog
std::shared_ptr< SplinePropertiesDialog > getSplinePropertiesDialog()
std::shared_ptr< SteppedPropertiesDialog > getSteppedPropertiesDialog()
void fillControls(const ChartTypeParameter &rParameter)
void fillControls(const ChartTypeParameter &rParameter)
std::unique_ptr< weld::RadioButton > m_xRB_Stack_Y
StackingResourceGroup(weld::Builder *pBuilder)
std::unique_ptr< weld::CheckButton > m_xCB_Stacked
std::unique_ptr< weld::RadioButton > m_xRB_Stack_Z
void fillParameter(ChartTypeParameter &rParameter)
std::unique_ptr< weld::RadioButton > m_xRB_Stack_Y_Percent
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
OUString OOO_DLLPUBLIC_CHARTTOOLS SchResId(TranslateId aId)
Definition: ResId.cxx:24
IMPL_LINK(StackingResourceGroup, StackingChangeHdl, weld::Toggleable &, rRadio, void)
IMPL_LINK_NOARG(SplinePropertiesDialog, SplineTypeListBoxHdl, weld::ComboBox &, void)
RET_OK