LibreOffice Module chart2 (master) 1
tp_AxisLabel.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
20#include "tp_AxisLabel.hxx"
21
24
25#include <svx/chrtitem.hxx>
26#include <svx/sdangitm.hxx>
27#include <editeng/eeitem.hxx>
29
30namespace chart
31{
32
34 : SfxTabPage(pPage, pController, "modules/schart/ui/tp_axisLabel.ui", "AxisLabelTabPage", &rInAttrs)
35 , m_bShowStaggeringControls( true )
36 , m_nInitialDegrees( 0 )
37 , m_bHasInitialDegrees( true )
38 , m_bInitialStacking( false )
39 , m_bHasInitialStacking( true )
40 , m_bComplexCategories( false )
41 , m_xCbShowDescription(m_xBuilder->weld_check_button("showlabelsCB"))
42 , m_xFlOrder(m_xBuilder->weld_label("orderL"))
43 , m_xRbSideBySide(m_xBuilder->weld_radio_button("tile"))
44 , m_xRbUpDown(m_xBuilder->weld_radio_button("odd"))
45 , m_xRbDownUp(m_xBuilder->weld_radio_button("even"))
46 , m_xRbAuto(m_xBuilder->weld_radio_button("auto"))
47 , m_xFlTextFlow(m_xBuilder->weld_label("textflowL"))
48 , m_xCbTextOverlap(m_xBuilder->weld_check_button("overlapCB"))
49 , m_xCbTextBreak(m_xBuilder->weld_check_button("breakCB"))
50 , m_xFtABCD(m_xBuilder->weld_label("labelABCD"))
51 , m_xFtRotate(m_xBuilder->weld_label("degreeL"))
52 , m_xNfRotate(m_xBuilder->weld_metric_spin_button("OrientDegree", FieldUnit::DEGREE))
53 , m_xCbStacked(m_xBuilder->weld_check_button("stackedCB"))
54 , m_xFtTextDirection(m_xBuilder->weld_label("textdirL"))
55 , m_aLbTextDirection(m_xBuilder->weld_combo_box("textdirLB"))
56 , m_xCtrlDial(new svx::DialControl)
57 , m_xCtrlDialWin(new weld::CustomWeld(*m_xBuilder, "dialCtrl", *m_xCtrlDial))
58{
59 m_xCtrlDial->SetText(m_xFtABCD->get_label());
60 m_xCtrlDial->SetLinkedField(m_xNfRotate.get());
61 m_xCtrlDialWin->set_sensitive(true);
62 m_xNfRotate->set_sensitive(true);
63 m_xCbStacked->set_sensitive(true);
64 m_xFtRotate->set_sensitive(true);
65
66 m_xCbStacked->connect_toggled(LINK(this, SchAxisLabelTabPage, StackedToggleHdl));
67 m_xCbShowDescription->connect_toggled(LINK(this, SchAxisLabelTabPage, ToggleShowLabel));
68}
69
71{
72 m_xCtrlDialWin.reset();
73 m_xCtrlDial.reset();
74}
75
76std::unique_ptr<SfxTabPage> SchAxisLabelTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrs)
77{
78 return std::make_unique<SchAxisLabelTabPage>(pPage, pController, *rAttrs);
79}
80
82{
83 bool bStacked = false;
84 if (m_xCbStacked->get_state() != TRISTATE_INDET )
85 {
86 bStacked = m_xCbStacked->get_state() == TRISTATE_TRUE;
87 if( !m_bHasInitialStacking || (bStacked != m_bInitialStacking) )
88 rOutAttrs->Put( SfxBoolItem( SCHATTR_TEXT_STACKED, bStacked ) );
89 }
90
91 if( m_xCtrlDial->HasRotation() )
92 {
93 Degree100 nDegrees = bStacked ? 0_deg100 : m_xCtrlDial->GetRotation();
94 if( !m_bHasInitialDegrees || (nDegrees != m_nInitialDegrees) )
95 rOutAttrs->Put( SdrAngleItem( SCHATTR_TEXT_DEGREES, nDegrees ) );
96 }
97
99 {
100 SvxChartTextOrder eOrder = SvxChartTextOrder::SideBySide;
101 bool bRadioButtonChecked = true;
102
103 if( m_xRbUpDown->get_active())
104 eOrder = SvxChartTextOrder::UpDown;
105 else if( m_xRbDownUp->get_active())
106 eOrder = SvxChartTextOrder::DownUp;
107 else if( m_xRbAuto->get_active())
108 eOrder = SvxChartTextOrder::Auto;
109 else if( m_xRbSideBySide->get_active())
110 eOrder = SvxChartTextOrder::SideBySide;
111 else
112 bRadioButtonChecked = false;
113
114 if( bRadioButtonChecked )
115 rOutAttrs->Put( SvxChartTextOrderItem( eOrder, SCHATTR_AXIS_LABEL_ORDER ));
116 }
117
118 if( m_xCbTextOverlap->get_state() != TRISTATE_INDET )
119 rOutAttrs->Put( SfxBoolItem( SCHATTR_AXIS_LABEL_OVERLAP, m_xCbTextOverlap->get_active() ) );
120 if( m_xCbTextBreak->get_state() != TRISTATE_INDET )
121 rOutAttrs->Put( SfxBoolItem( SCHATTR_AXIS_LABEL_BREAK, m_xCbTextBreak->get_active() ) );
122 if( m_xCbShowDescription->get_state() != TRISTATE_INDET )
123 rOutAttrs->Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR, m_xCbShowDescription->get_active() ) );
124
125 if (m_aLbTextDirection.get_active() != -1)
127
128 return true;
129}
130
132{
133 const SfxPoolItem* pPoolItem = nullptr;
134
135 // show description
136 SfxItemState aState = rInAttrs->GetItemState( SCHATTR_AXIS_SHOWDESCR, false, &pPoolItem );
137 if( aState == SfxItemState::DONTCARE )
138 {
140 }
141 else
142 {
143 bool bCheck = false;
144 if( aState == SfxItemState::SET )
145 bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
146 m_xCbShowDescription->set_active( bCheck );
147
148 if( aState != SfxItemState::DEFAULT && aState != SfxItemState::SET )
149 m_xCbShowDescription->hide();
150 }
151
152 // Rotation as orient item or in degrees ----------
153
154 // check new degree item
155 m_nInitialDegrees = 0_deg100;
156 aState = rInAttrs->GetItemState( SCHATTR_TEXT_DEGREES, false, &pPoolItem );
157 if( aState == SfxItemState::SET )
158 m_nInitialDegrees = static_cast< const SdrAngleItem * >( pPoolItem )->GetValue();
159
160 m_bHasInitialDegrees = aState != SfxItemState::DONTCARE;
162 m_xCtrlDial->SetRotation( m_nInitialDegrees );
163 else
164 m_xCtrlDial->SetNoRotation();
165
166 // check stacked item
167 m_bInitialStacking = false;
168 aState = rInAttrs->GetItemState( SCHATTR_TEXT_STACKED, false, &pPoolItem );
169 if( aState == SfxItemState::SET )
170 m_bInitialStacking = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
171
172 m_bHasInitialStacking = aState != SfxItemState::DONTCARE;
175 else
176 m_xCbStacked->set_state(TRISTATE_INDET);
177 StackedToggleHdl(*m_xCbStacked);
178
179 if( const SvxFrameDirectionItem* pDirectionItem = rInAttrs->GetItemIfSet( EE_PARA_WRITINGDIR ) )
180 m_aLbTextDirection.set_active_id( pDirectionItem->GetValue() );
181
182 // Text overlap ----------
183 aState = rInAttrs->GetItemState( SCHATTR_AXIS_LABEL_OVERLAP, false, &pPoolItem );
184 if( aState == SfxItemState::DONTCARE )
185 {
186 m_xCbTextOverlap->set_state( TRISTATE_INDET );
187 }
188 else
189 {
190 bool bCheck = false;
191 if( aState == SfxItemState::SET )
192 bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
193 m_xCbTextOverlap->set_active( bCheck );
194
195 if( aState != SfxItemState::DEFAULT && aState != SfxItemState::SET )
196 m_xCbTextOverlap->hide();
197 }
198
199 // text break ----------
200 aState = rInAttrs->GetItemState( SCHATTR_AXIS_LABEL_BREAK, false, &pPoolItem );
201 if( aState == SfxItemState::DONTCARE )
202 {
203 m_xCbTextBreak->set_state( TRISTATE_INDET );
204 }
205 else
206 {
207 bool bCheck = false;
208 if( aState == SfxItemState::SET )
209 bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
210 m_xCbTextBreak->set_active( bCheck );
211
212 if( aState != SfxItemState::DEFAULT && aState != SfxItemState::SET )
213 {
214 m_xCbTextBreak->hide();
215 if( ! m_xCbTextOverlap->get_visible() )
216 m_xFlTextFlow->hide();
217 }
218 }
219
220 // text order ----------
222 {
223 if( const SvxChartTextOrderItem* pOrderItem = rInAttrs->GetItemIfSet( SCHATTR_AXIS_LABEL_ORDER, false ) )
224 {
225 SvxChartTextOrder eOrder = pOrderItem->GetValue();
226
227 switch( eOrder )
228 {
229 case SvxChartTextOrder::SideBySide:
230 m_xRbSideBySide->set_active(true);
231 break;
232 case SvxChartTextOrder::UpDown:
233 m_xRbUpDown->set_active(true);
234 break;
235 case SvxChartTextOrder::DownUp:
236 m_xRbDownUp->set_active(true);
237 break;
238 case SvxChartTextOrder::Auto:
239 m_xRbAuto->set_active(true);
240 break;
241 }
242 }
243 }
244
245 ToggleShowLabel(*m_xCbShowDescription);
246}
247
248void SchAxisLabelTabPage::ShowStaggeringControls( bool bShowStaggeringControls )
249{
250 m_bShowStaggeringControls = bShowStaggeringControls;
251
253 {
254 m_xRbSideBySide->hide();
255 m_xRbUpDown->hide();
256 m_xRbDownUp->hide();
257 m_xRbAuto->hide();
258 m_xFlOrder->hide();
259 }
260}
261
262void SchAxisLabelTabPage::SetComplexCategories( bool bComplexCategories )
263{
264 m_bComplexCategories = bComplexCategories;
265}
266
267// event handling routines
268
270{
271 bool bActive = m_xCbStacked->get_active() && m_xCbStacked->get_sensitive();
272 m_xNfRotate->set_sensitive(!bActive);
273 m_xCtrlDialWin->set_sensitive(!bActive);
274 m_xCtrlDial->StyleUpdated();
275 m_xFtRotate->set_sensitive(!bActive);
276}
277
279{
280 bool bEnable = ( m_xCbShowDescription->get_state() != TRISTATE_FALSE );
281
282 m_xCbStacked->set_sensitive(bEnable);
283 StackedToggleHdl(*m_xCbStacked);
284
285 m_xFlOrder->set_sensitive( bEnable );
286 m_xRbSideBySide->set_sensitive( bEnable );
287 m_xRbUpDown->set_sensitive( bEnable );
288 m_xRbDownUp->set_sensitive( bEnable );
289 m_xRbAuto->set_sensitive( bEnable );
290
291 m_xFlTextFlow->set_sensitive( bEnable );
292 m_xCbTextOverlap->set_sensitive( bEnable && !m_bComplexCategories );
293 m_xCbTextBreak->set_sensitive( bEnable );
294
295 m_xFtTextDirection->set_sensitive( bEnable );
296 m_aLbTextDirection.set_sensitive( bEnable );
297}
298} //namespace chart
299
300/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr TypedWhichId< SfxBoolItem > SCHATTR_AXIS_LABEL_BREAK(SCHATTR_AXIS_LABEL_START+3)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_AXIS_LABEL_OVERLAP(SCHATTR_AXIS_LABEL_START+2)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_TEXT_STACKED(SCHATTR_TEXT_START+1)
constexpr TypedWhichId< SvxChartTextOrderItem > SCHATTR_AXIS_LABEL_ORDER(SCHATTR_AXIS_LABEL_START+1)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_AXIS_SHOWDESCR(SCHATTR_AXIS_LABEL_START)
constexpr TypedWhichId< SdrAngleItem > SCHATTR_TEXT_DEGREES(SCHATTR_TEXT_START)
SvxChartTextOrder
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual void Reset(const SfxItemSet *rInAttrs) override
bool m_bInitialStacking
false = DialControl in tristate
bool m_bComplexCategories
false = checkbox in tristate
std::unique_ptr< weld::Label > m_xFtRotate
SchAxisLabelTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs)
std::unique_ptr< weld::Label > m_xFlOrder
std::unique_ptr< weld::RadioButton > m_xRbDownUp
std::unique_ptr< weld::RadioButton > m_xRbUpDown
std::unique_ptr< weld::CheckButton > m_xCbStacked
void ShowStaggeringControls(bool bShowStaggeringControls)
TextDirectionListBox m_aLbTextDirection
std::unique_ptr< weld::CheckButton > m_xCbShowDescription
std::unique_ptr< weld::CustomWeld > m_xCtrlDialWin
virtual ~SchAxisLabelTabPage() override
std::unique_ptr< weld::MetricSpinButton > m_xNfRotate
std::unique_ptr< weld::RadioButton > m_xRbSideBySide
virtual bool FillItemSet(SfxItemSet *rOutAttrs) override
std::unique_ptr< svx::DialControl > m_xCtrlDial
std::unique_ptr< weld::Label > m_xFlTextFlow
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rInAttrs)
std::unique_ptr< weld::Label > m_xFtABCD
void SetComplexCategories(bool bComplexCategories)
std::unique_ptr< weld::CheckButton > m_xCbTextBreak
std::unique_ptr< weld::RadioButton > m_xRbAuto
std::unique_ptr< weld::CheckButton > m_xCbTextOverlap
SvxFrameDirection get_active_id() const
void set_active_id(SvxFrameDirection eDir)
constexpr TypedWhichId< SvxFrameDirectionItem > EE_PARA_WRITINGDIR(EE_PARA_START+0)
FieldUnit
TRISTATE_FALSE
TRISTATE_INDET
TRISTATE_TRUE
IMPL_LINK_NOARG(SplinePropertiesDialog, SplineTypeListBoxHdl, weld::ComboBox &, void)
const char GetValue[]
SfxItemState