1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <ChartResourceGroups.hxx>
21 #include <ChartResourceGroupDlgs.hxx>
23 #include <strings.hrc>
28 using namespace ::com::sun::star
;
29 using namespace ::com::sun::star::chart2
;
31 Dim3DLookResourceGroup::Dim3DLookResourceGroup(weld::Builder
* pBuilder
)
32 : m_xCB_3DLook(pBuilder
->weld_check_button(u
"3dlook"_ustr
))
33 , m_xLB_Scheme(pBuilder
->weld_combo_box(u
"3dscheme"_ustr
))
35 m_xCB_3DLook
->connect_toggled(LINK(this, Dim3DLookResourceGroup
, Dim3DLookCheckHdl
));
36 m_xLB_Scheme
->connect_changed(LINK(this, Dim3DLookResourceGroup
, SelectSchemeHdl
));
39 void Dim3DLookResourceGroup::showControls(bool bShow
)
41 m_xCB_3DLook
->set_visible(bShow
);
42 m_xLB_Scheme
->set_visible(bShow
);
45 void Dim3DLookResourceGroup::fillControls(const ChartTypeParameter
& rParameter
)
47 m_xCB_3DLook
->set_active(rParameter
.b3DLook
);
48 m_xLB_Scheme
->set_sensitive(rParameter
.b3DLook
);
50 // tdf#124295 - select always a 3D scheme
51 switch (rParameter
.eThreeDLookScheme
)
53 case ThreeDLookScheme::ThreeDLookScheme_Simple
:
54 m_xLB_Scheme
->set_active(POS_3DSCHEME_SIMPLE
);
56 case ThreeDLookScheme::ThreeDLookScheme_Realistic
:
57 case ThreeDLookScheme::ThreeDLookScheme_Unknown
:
58 m_xLB_Scheme
->set_active(POS_3DSCHEME_REALISTIC
);
63 void Dim3DLookResourceGroup::fillParameter(ChartTypeParameter
& rParameter
)
65 rParameter
.b3DLook
= m_xCB_3DLook
->get_active();
66 // tdf#124295 - select always a 3D scheme
67 switch (m_xLB_Scheme
->get_active())
69 case POS_3DSCHEME_SIMPLE
:
70 rParameter
.eThreeDLookScheme
= ThreeDLookScheme::ThreeDLookScheme_Simple
;
73 rParameter
.eThreeDLookScheme
= ThreeDLookScheme::ThreeDLookScheme_Realistic
;
77 IMPL_LINK_NOARG(Dim3DLookResourceGroup
, Dim3DLookCheckHdl
, weld::Toggleable
&, void)
79 if (m_pChangeListener
)
80 m_pChangeListener
->stateChanged();
83 IMPL_LINK_NOARG(Dim3DLookResourceGroup
, SelectSchemeHdl
, weld::ComboBox
&, void)
85 if (m_pChangeListener
)
86 m_pChangeListener
->stateChanged();
89 SortByXValuesResourceGroup::SortByXValuesResourceGroup(weld::Builder
* pBuilder
)
90 : m_xCB_XValueSorting(pBuilder
->weld_check_button(u
"sort"_ustr
))
92 m_xCB_XValueSorting
->connect_toggled(
93 LINK(this, SortByXValuesResourceGroup
, SortByXValuesCheckHdl
));
96 void SortByXValuesResourceGroup::showControls(bool bShow
)
98 m_xCB_XValueSorting
->set_visible(bShow
);
101 void SortByXValuesResourceGroup::fillControls(const ChartTypeParameter
& rParameter
)
103 m_xCB_XValueSorting
->set_active(rParameter
.bSortByXValues
);
106 void SortByXValuesResourceGroup::fillParameter(ChartTypeParameter
& rParameter
)
108 rParameter
.bSortByXValues
= m_xCB_XValueSorting
->get_active();
111 IMPL_LINK_NOARG(SortByXValuesResourceGroup
, SortByXValuesCheckHdl
, weld::Toggleable
&, void)
113 if (m_pChangeListener
)
114 m_pChangeListener
->stateChanged();
117 StackingResourceGroup::StackingResourceGroup(weld::Builder
* pBuilder
)
118 : m_xCB_Stacked(pBuilder
->weld_check_button(u
"stack"_ustr
))
119 , m_xRB_Stack_Y(pBuilder
->weld_radio_button(u
"ontop"_ustr
))
120 , m_xRB_Stack_Y_Percent(pBuilder
->weld_radio_button(u
"percent"_ustr
))
121 , m_xRB_Stack_Z(pBuilder
->weld_radio_button(u
"deep"_ustr
))
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
));
129 void StackingResourceGroup::showControls(bool bShow
)
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);
137 void StackingResourceGroup::fillControls(const ChartTypeParameter
& rParameter
)
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
)
145 case GlobalStackMode_STACK_Y_PERCENT
:
146 m_xRB_Stack_Y_Percent
->set_active(true);
148 case GlobalStackMode_STACK_Z
:
149 //todo uncomment this condition if z stacking radio button is really used
151 if( rParameter.b3DLook )
152 m_xRB_Stack_Z->set_active(true);
155 m_xRB_Stack_Y
->set_active(true);
157 case GlobalStackMode_STACK_Y
:
159 m_xRB_Stack_Y
->set_active(true);
163 m_xCB_Stacked
->set_sensitive(!rParameter
.bXAxisWithValues
);
164 m_xRB_Stack_Y
->set_sensitive(m_xCB_Stacked
->get_active() && !rParameter
.bXAxisWithValues
);
165 m_xRB_Stack_Y_Percent
->set_sensitive(m_xCB_Stacked
->get_active()
166 && !rParameter
.bXAxisWithValues
);
167 m_xRB_Stack_Z
->set_sensitive(m_xCB_Stacked
->get_active() && rParameter
.b3DLook
);
170 void StackingResourceGroup::fillParameter(ChartTypeParameter
& rParameter
)
172 if (!m_xCB_Stacked
->get_active())
173 rParameter
.eStackMode
= GlobalStackMode_NONE
;
174 else if (m_xRB_Stack_Y
->get_active())
175 rParameter
.eStackMode
= GlobalStackMode_STACK_Y
;
176 else if (m_xRB_Stack_Y_Percent
->get_active())
177 rParameter
.eStackMode
= GlobalStackMode_STACK_Y_PERCENT
;
178 else if (m_xRB_Stack_Z
->get_active())
179 rParameter
.eStackMode
= GlobalStackMode_STACK_Z
;
182 IMPL_LINK(StackingResourceGroup
, StackingChangeHdl
, weld::Toggleable
&, rRadio
, void)
184 //for each radio click there are coming two change events
185 //first uncheck of previous button -> ignore that call
186 //the second call gives the check of the new button
187 if (m_pChangeListener
&& rRadio
.get_active())
188 m_pChangeListener
->stateChanged();
191 IMPL_LINK_NOARG(StackingResourceGroup
, StackingEnableHdl
, weld::Toggleable
&, void)
193 if (m_pChangeListener
)
194 m_pChangeListener
->stateChanged();
197 SplineResourceGroup::SplineResourceGroup(weld::Builder
* pBuilder
, weld::Window
* pParent
)
199 , m_xFT_LineType(pBuilder
->weld_label(u
"linetypeft"_ustr
))
200 , m_xLB_LineType(pBuilder
->weld_combo_box(u
"linetype"_ustr
))
201 , m_xPB_DetailsDialog(pBuilder
->weld_button(u
"properties"_ustr
))
203 m_xLB_LineType
->connect_changed(LINK(this, SplineResourceGroup
, LineTypeChangeHdl
));
206 const std::shared_ptr
<SplinePropertiesDialog
>& SplineResourceGroup::getSplinePropertiesDialog()
208 if (!m_xSplinePropertiesDialog
)
210 m_xSplinePropertiesDialog
.reset(new SplinePropertiesDialog(m_pParent
));
212 return m_xSplinePropertiesDialog
;
215 const std::shared_ptr
<SteppedPropertiesDialog
>& SplineResourceGroup::getSteppedPropertiesDialog()
217 if (!m_xSteppedPropertiesDialog
)
219 m_xSteppedPropertiesDialog
.reset(new SteppedPropertiesDialog(m_pParent
));
221 return m_xSteppedPropertiesDialog
;
224 void SplineResourceGroup::showControls(bool bShow
)
226 m_xFT_LineType
->set_visible(bShow
);
227 m_xLB_LineType
->set_visible(bShow
);
228 m_xPB_DetailsDialog
->set_visible(bShow
);
231 void SplineResourceGroup::fillControls(const ChartTypeParameter
& rParameter
)
233 switch (rParameter
.eCurveStyle
)
235 case CurveStyle_LINES
:
236 m_xLB_LineType
->set_active(POS_LINETYPE_STRAIGHT
);
237 m_xPB_DetailsDialog
->set_sensitive(false);
239 case CurveStyle_CUBIC_SPLINES
:
240 case CurveStyle_B_SPLINES
:
241 m_xLB_LineType
->set_active(POS_LINETYPE_SMOOTH
);
242 m_xPB_DetailsDialog
->set_sensitive(true);
243 m_xPB_DetailsDialog
->connect_clicked(
244 LINK(this, SplineResourceGroup
, SplineDetailsDialogHdl
));
245 m_xPB_DetailsDialog
->set_tooltip_text(SchResId(STR_DLG_SMOOTH_LINE_PROPERTIES
));
246 getSplinePropertiesDialog()->fillControls(rParameter
);
248 case CurveStyle_STEP_START
:
249 case CurveStyle_STEP_END
:
250 case CurveStyle_STEP_CENTER_X
:
251 case CurveStyle_STEP_CENTER_Y
:
252 m_xLB_LineType
->set_active(POS_LINETYPE_STEPPED
);
253 m_xPB_DetailsDialog
->set_sensitive(true);
254 m_xPB_DetailsDialog
->connect_clicked(
255 LINK(this, SplineResourceGroup
, SteppedDetailsDialogHdl
));
256 m_xPB_DetailsDialog
->set_tooltip_text(SchResId(STR_DLG_STEPPED_LINE_PROPERTIES
));
257 getSteppedPropertiesDialog()->fillControls(rParameter
);
260 m_xLB_LineType
->set_active(-1);
261 m_xPB_DetailsDialog
->set_sensitive(false);
264 void SplineResourceGroup::fillParameter(ChartTypeParameter
& rParameter
)
266 switch (m_xLB_LineType
->get_active())
268 case POS_LINETYPE_SMOOTH
:
269 getSplinePropertiesDialog()->fillParameter(rParameter
, true);
271 case POS_LINETYPE_STEPPED
:
272 getSteppedPropertiesDialog()->fillParameter(rParameter
, true);
274 default: // includes POS_LINETYPE_STRAIGHT
275 rParameter
.eCurveStyle
= CurveStyle_LINES
;
280 IMPL_LINK_NOARG(SplineResourceGroup
, LineTypeChangeHdl
, weld::ComboBox
&, void)
282 if (m_pChangeListener
)
283 m_pChangeListener
->stateChanged();
286 IMPL_LINK_NOARG(SplineResourceGroup
, SplineDetailsDialogHdl
, weld::Button
&, void)
288 ChartTypeParameter aOldParameter
;
289 std::shared_ptr
<SplinePropertiesDialog
> xDlg
= getSplinePropertiesDialog();
290 xDlg
->fillParameter(aOldParameter
, m_xLB_LineType
->get_active() == POS_LINETYPE_SMOOTH
);
292 const sal_Int32 iOldLineTypePos
= m_xLB_LineType
->get_active();
293 m_xLB_LineType
->set_active(POS_LINETYPE_SMOOTH
);
294 weld::GenericDialogController::runAsync(xDlg
, [this, xDlg
, aOldParameter
,
295 iOldLineTypePos
](sal_Int32 nResult
) {
296 m_xSplinePropertiesDialog
= nullptr;
297 auto xNewDlg
= getSplinePropertiesDialog();
299 if (nResult
== RET_OK
)
301 ChartTypeParameter aNewParameter
;
302 xDlg
->fillParameter(aNewParameter
, m_xLB_LineType
->get_active() == POS_LINETYPE_SMOOTH
);
303 xNewDlg
->fillControls(aNewParameter
);
305 if (m_pChangeListener
)
306 m_pChangeListener
->stateChanged();
311 m_xLB_LineType
->set_active(iOldLineTypePos
);
312 xNewDlg
->fillControls(aOldParameter
);
317 IMPL_LINK_NOARG(SplineResourceGroup
, SteppedDetailsDialogHdl
, weld::Button
&, void)
319 ChartTypeParameter aOldParameter
;
320 std::shared_ptr
<SteppedPropertiesDialog
> xDlg
= getSteppedPropertiesDialog();
321 xDlg
->fillParameter(aOldParameter
, m_xLB_LineType
->get_active() == POS_LINETYPE_STEPPED
);
323 const sal_Int32 iOldLineTypePos
= m_xLB_LineType
->get_active();
324 m_xLB_LineType
->set_active(POS_LINETYPE_STEPPED
);
326 weld::GenericDialogController::runAsync(
327 xDlg
, [this, xDlg
, aOldParameter
, iOldLineTypePos
](sal_Int32 nResult
) {
328 m_xSteppedPropertiesDialog
= nullptr;
329 auto xNewDlg
= getSteppedPropertiesDialog();
331 if (nResult
== RET_OK
)
333 ChartTypeParameter aNewParameter
;
334 xDlg
->fillParameter(aNewParameter
,
335 m_xLB_LineType
->get_active() == POS_LINETYPE_STEPPED
);
336 xNewDlg
->fillControls(aNewParameter
);
338 if (m_pChangeListener
)
339 m_pChangeListener
->stateChanged();
344 m_xLB_LineType
->set_active(iOldLineTypePos
);
345 xDlg
->fillControls(aOldParameter
);
350 GeometryResourceGroup::GeometryResourceGroup(weld::Builder
* pBuilder
)
351 : m_aGeometryResources(pBuilder
)
353 m_aGeometryResources
.connect_changed(LINK(this, GeometryResourceGroup
, GeometryChangeHdl
));
356 void GeometryResourceGroup::showControls(bool bShow
) { m_aGeometryResources
.set_visible(bShow
); }
358 void GeometryResourceGroup::fillControls(const ChartTypeParameter
& rParameter
)
360 sal_uInt16 nGeometry3D
= static_cast<sal_uInt16
>(rParameter
.nGeometry3D
);
361 m_aGeometryResources
.select(nGeometry3D
);
362 m_aGeometryResources
.set_sensitive(rParameter
.b3DLook
);
365 void GeometryResourceGroup::fillParameter(ChartTypeParameter
& rParameter
)
367 rParameter
.nGeometry3D
= 1;
368 int nSelected
= m_aGeometryResources
.get_selected_index();
370 rParameter
.nGeometry3D
= nSelected
;
373 IMPL_LINK_NOARG(GeometryResourceGroup
, GeometryChangeHdl
, weld::TreeView
&, void)
375 if (m_pChangeListener
)
376 m_pChangeListener
->stateChanged();
381 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */