1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <ChartResourceGroups.hxx>
#include <ChartResourceGroupDlgs.hxx>
#include <strings.hrc>
#include <ResId.hxx>
namespace chart
{
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
Dim3DLookResourceGroup::Dim3DLookResourceGroup(weld::Builder* pBuilder)
: m_xCB_3DLook(pBuilder->weld_check_button("3dlook"))
, m_xLB_Scheme(pBuilder->weld_combo_box("3dscheme"))
{
m_xCB_3DLook->connect_toggled(LINK(this, Dim3DLookResourceGroup, Dim3DLookCheckHdl));
m_xLB_Scheme->connect_changed(LINK(this, Dim3DLookResourceGroup, SelectSchemeHdl));
}
void Dim3DLookResourceGroup::showControls(bool bShow)
{
m_xCB_3DLook->set_visible(bShow);
m_xLB_Scheme->set_visible(bShow);
}
void Dim3DLookResourceGroup::fillControls(const ChartTypeParameter& rParameter)
{
m_xCB_3DLook->set_active(rParameter.b3DLook);
m_xLB_Scheme->set_sensitive(rParameter.b3DLook);
// tdf#124295 - select always a 3D scheme
switch (rParameter.eThreeDLookScheme)
{
case ThreeDLookScheme::ThreeDLookScheme_Simple:
m_xLB_Scheme->set_active(POS_3DSCHEME_SIMPLE);
break;
case ThreeDLookScheme::ThreeDLookScheme_Realistic:
case ThreeDLookScheme::ThreeDLookScheme_Unknown:
m_xLB_Scheme->set_active(POS_3DSCHEME_REALISTIC);
break;
}
}
void Dim3DLookResourceGroup::fillParameter(ChartTypeParameter& rParameter)
{
rParameter.b3DLook = m_xCB_3DLook->get_active();
// tdf#124295 - select always a 3D scheme
switch (m_xLB_Scheme->get_active())
{
case POS_3DSCHEME_SIMPLE:
rParameter.eThreeDLookScheme = ThreeDLookScheme::ThreeDLookScheme_Simple;
break;
default:
rParameter.eThreeDLookScheme = ThreeDLookScheme::ThreeDLookScheme_Realistic;
}
}
IMPL_LINK_NOARG(Dim3DLookResourceGroup, Dim3DLookCheckHdl, weld::Toggleable&, void)
{
if (m_pChangeListener)
m_pChangeListener->stateChanged();
}
IMPL_LINK_NOARG(Dim3DLookResourceGroup, SelectSchemeHdl, weld::ComboBox&, void)
{
if (m_pChangeListener)
m_pChangeListener->stateChanged();
}
SortByXValuesResourceGroup::SortByXValuesResourceGroup(weld::Builder* pBuilder)
: m_xCB_XValueSorting(pBuilder->weld_check_button("sort"))
{
m_xCB_XValueSorting->connect_toggled(
LINK(this, SortByXValuesResourceGroup, SortByXValuesCheckHdl));
}
void SortByXValuesResourceGroup::showControls(bool bShow)
{
m_xCB_XValueSorting->set_visible(bShow);
}
void SortByXValuesResourceGroup::fillControls(const ChartTypeParameter& rParameter)
{
m_xCB_XValueSorting->set_active(rParameter.bSortByXValues);
}
void SortByXValuesResourceGroup::fillParameter(ChartTypeParameter& rParameter)
{
rParameter.bSortByXValues = m_xCB_XValueSorting->get_active();
}
IMPL_LINK_NOARG(SortByXValuesResourceGroup, SortByXValuesCheckHdl, weld::Toggleable&, void)
{
if (m_pChangeListener)
m_pChangeListener->stateChanged();
}
StackingResourceGroup::StackingResourceGroup(weld::Builder* pBuilder)
: m_xCB_Stacked(pBuilder->weld_check_button("stack"))
, m_xRB_Stack_Y(pBuilder->weld_radio_button("ontop"))
, m_xRB_Stack_Y_Percent(pBuilder->weld_radio_button("percent"))
, m_xRB_Stack_Z(pBuilder->weld_radio_button("deep"))
{
m_xCB_Stacked->connect_toggled(LINK(this, StackingResourceGroup, StackingEnableHdl));
m_xRB_Stack_Y->connect_toggled(LINK(this, StackingResourceGroup, StackingChangeHdl));
m_xRB_Stack_Y_Percent->connect_toggled(LINK(this, StackingResourceGroup, StackingChangeHdl));
m_xRB_Stack_Z->connect_toggled(LINK(this, StackingResourceGroup, StackingChangeHdl));
}
void StackingResourceGroup::showControls(bool bShow)
{
m_xCB_Stacked->set_visible(bShow);
m_xRB_Stack_Y->set_visible(bShow);
m_xRB_Stack_Y_Percent->set_visible(bShow);
m_xRB_Stack_Z->set_visible(false);
}
void StackingResourceGroup::fillControls(const ChartTypeParameter& rParameter)
{
m_xCB_Stacked->set_active(
rParameter.eStackMode != GlobalStackMode_NONE
&& rParameter.eStackMode
!= GlobalStackMode_STACK_Z); //todo remove this condition if z stacking radio button is really used
switch (rParameter.eStackMode)
{
case GlobalStackMode_STACK_Y:
m_xRB_Stack_Y->set_active(true);
break;
case GlobalStackMode_STACK_Y_PERCENT:
m_xRB_Stack_Y_Percent->set_active(true);
break;
case GlobalStackMode_STACK_Z:
//todo uncomment this condition if z stacking radio button is really used
/*
if( rParameter.b3DLook )
m_xRB_Stack_Z->set_active(true);
else
*/
m_xRB_Stack_Y->set_active(true);
break;
default:
m_xRB_Stack_Y->set_active(true);
break;
}
//dis/enabling
m_xCB_Stacked->set_sensitive(!rParameter.bXAxisWithValues);
m_xRB_Stack_Y->set_sensitive(m_xCB_Stacked->get_active() && !rParameter.bXAxisWithValues);
m_xRB_Stack_Y_Percent->set_sensitive(m_xCB_Stacked->get_active()
&& !rParameter.bXAxisWithValues);
m_xRB_Stack_Z->set_sensitive(m_xCB_Stacked->get_active() && rParameter.b3DLook);
}
void StackingResourceGroup::fillParameter(ChartTypeParameter& rParameter)
{
if (!m_xCB_Stacked->get_active())
rParameter.eStackMode = GlobalStackMode_NONE;
else if (m_xRB_Stack_Y->get_active())
rParameter.eStackMode = GlobalStackMode_STACK_Y;
else if (m_xRB_Stack_Y_Percent->get_active())
rParameter.eStackMode = GlobalStackMode_STACK_Y_PERCENT;
else if (m_xRB_Stack_Z->get_active())
rParameter.eStackMode = GlobalStackMode_STACK_Z;
}
IMPL_LINK(StackingResourceGroup, StackingChangeHdl, weld::Toggleable&, rRadio, void)
{
//for each radio click there are coming two change events
//first uncheck of previous button -> ignore that call
//the second call gives the check of the new button
if (m_pChangeListener && rRadio.get_active())
m_pChangeListener->stateChanged();
}
IMPL_LINK_NOARG(StackingResourceGroup, StackingEnableHdl, weld::Toggleable&, void)
{
if (m_pChangeListener)
m_pChangeListener->stateChanged();
}
SplineResourceGroup::SplineResourceGroup(weld::Builder* pBuilder, weld::Window* pParent)
: m_pParent(pParent)
, m_xFT_LineType(pBuilder->weld_label("linetypeft"))
, m_xLB_LineType(pBuilder->weld_combo_box("linetype"))
, m_xPB_DetailsDialog(pBuilder->weld_button("properties"))
{
m_xLB_LineType->connect_changed(LINK(this, SplineResourceGroup, LineTypeChangeHdl));
}
SplinePropertiesDialog& SplineResourceGroup::getSplinePropertiesDialog()
{
if (!m_xSplinePropertiesDialog)
{
m_xSplinePropertiesDialog.reset(new SplinePropertiesDialog(m_pParent));
}
return *m_xSplinePropertiesDialog;
}
SteppedPropertiesDialog& SplineResourceGroup::getSteppedPropertiesDialog()
{
if (!m_xSteppedPropertiesDialog)
{
m_xSteppedPropertiesDialog.reset(new SteppedPropertiesDialog(m_pParent));
}
return *m_xSteppedPropertiesDialog;
}
void SplineResourceGroup::showControls(bool bShow)
{
m_xFT_LineType->set_visible(bShow);
m_xLB_LineType->set_visible(bShow);
m_xPB_DetailsDialog->set_visible(bShow);
}
void SplineResourceGroup::fillControls(const ChartTypeParameter& rParameter)
{
switch (rParameter.eCurveStyle)
{
case CurveStyle_LINES:
m_xLB_LineType->set_active(POS_LINETYPE_STRAIGHT);
m_xPB_DetailsDialog->set_sensitive(false);
break;
case CurveStyle_CUBIC_SPLINES:
case CurveStyle_B_SPLINES:
m_xLB_LineType->set_active(POS_LINETYPE_SMOOTH);
m_xPB_DetailsDialog->set_sensitive(true);
m_xPB_DetailsDialog->connect_clicked(
LINK(this, SplineResourceGroup, SplineDetailsDialogHdl));
m_xPB_DetailsDialog->set_tooltip_text(SchResId(STR_DLG_SMOOTH_LINE_PROPERTIES));
getSplinePropertiesDialog().fillControls(rParameter);
break;
case CurveStyle_STEP_START:
case CurveStyle_STEP_END:
case CurveStyle_STEP_CENTER_X:
case CurveStyle_STEP_CENTER_Y:
m_xLB_LineType->set_active(POS_LINETYPE_STEPPED);
m_xPB_DetailsDialog->set_sensitive(true);
m_xPB_DetailsDialog->connect_clicked(
LINK(this, SplineResourceGroup, SteppedDetailsDialogHdl));
m_xPB_DetailsDialog->set_tooltip_text(SchResId(STR_DLG_STEPPED_LINE_PROPERTIES));
getSteppedPropertiesDialog().fillControls(rParameter);
break;
default:
m_xLB_LineType->set_active(-1);
m_xPB_DetailsDialog->set_sensitive(false);
}
}
void SplineResourceGroup::fillParameter(ChartTypeParameter& rParameter)
{
switch (m_xLB_LineType->get_active())
{
case POS_LINETYPE_SMOOTH:
getSplinePropertiesDialog().fillParameter(rParameter, true);
break;
case POS_LINETYPE_STEPPED:
getSteppedPropertiesDialog().fillParameter(rParameter, true);
break;
default: // includes POS_LINETYPE_STRAIGHT
rParameter.eCurveStyle = CurveStyle_LINES;
break;
}
}
IMPL_LINK_NOARG(SplineResourceGroup, LineTypeChangeHdl, weld::ComboBox&, void)
{
if (m_pChangeListener)
m_pChangeListener->stateChanged();
}
IMPL_LINK_NOARG(SplineResourceGroup, SplineDetailsDialogHdl, weld::Button&, void)
{
ChartTypeParameter aOldParameter;
getSplinePropertiesDialog().fillParameter(aOldParameter,
m_xLB_LineType->get_active() == POS_LINETYPE_SMOOTH);
const sal_Int32 iOldLineTypePos = m_xLB_LineType->get_active();
m_xLB_LineType->set_active(POS_LINETYPE_SMOOTH);
if (getSplinePropertiesDialog().run() == RET_OK)
{
if (m_pChangeListener)
m_pChangeListener->stateChanged();
}
else
{
//restore old state:
m_xLB_LineType->set_active(iOldLineTypePos);
getSplinePropertiesDialog().fillControls(aOldParameter);
}
}
IMPL_LINK_NOARG(SplineResourceGroup, SteppedDetailsDialogHdl, weld::Button&, void)
{
ChartTypeParameter aOldParameter;
getSteppedPropertiesDialog().fillParameter(aOldParameter, m_xLB_LineType->get_active()
== POS_LINETYPE_STEPPED);
const sal_Int32 iOldLineTypePos = m_xLB_LineType->get_active();
m_xLB_LineType->set_active(POS_LINETYPE_STEPPED);
if (getSteppedPropertiesDialog().run() == RET_OK)
{
if (m_pChangeListener)
m_pChangeListener->stateChanged();
}
else
{
//restore old state:
m_xLB_LineType->set_active(iOldLineTypePos);
getSteppedPropertiesDialog().fillControls(aOldParameter);
}
}
GeometryResourceGroup::GeometryResourceGroup(weld::Builder* pBuilder)
: m_aGeometryResources(pBuilder)
{
m_aGeometryResources.connect_changed(LINK(this, GeometryResourceGroup, GeometryChangeHdl));
}
void GeometryResourceGroup::showControls(bool bShow) { m_aGeometryResources.set_visible(bShow); }
void GeometryResourceGroup::fillControls(const ChartTypeParameter& rParameter)
{
sal_uInt16 nGeometry3D = static_cast<sal_uInt16>(rParameter.nGeometry3D);
m_aGeometryResources.select(nGeometry3D);
m_aGeometryResources.set_sensitive(rParameter.b3DLook);
}
void GeometryResourceGroup::fillParameter(ChartTypeParameter& rParameter)
{
rParameter.nGeometry3D = 1;
int nSelected = m_aGeometryResources.get_selected_index();
if (nSelected != -1)
rParameter.nGeometry3D = nSelected;
}
IMPL_LINK_NOARG(GeometryResourceGroup, GeometryChangeHdl, weld::TreeView&, void)
{
if (m_pChangeListener)
m_pChangeListener->stateChanged();
}
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|