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 "tp_AxisLabel.hxx"
22 #include "TabPageIds.h"
23 #include <chartview/ChartSfxItemIds.hxx>
25 #include <svx/chrtitem.hxx>
26 #include <svl/intitem.hxx>
27 #include <editeng/eeitem.hxx>
28 #include <editeng/frmdiritem.hxx>
33 SchAxisLabelTabPage::SchAxisLabelTabPage( vcl::Window
* pParent
, const SfxItemSet
& rInAttrs
) :
34 SfxTabPage( pParent
, "AxisLabelTabPage","modules/schart/ui/tp_axisLabel.ui", &rInAttrs
),
36 m_bShowStaggeringControls( true ),
38 m_nInitialDegrees( 0 ),
39 m_bHasInitialDegrees( true ),
40 m_bInitialStacking( false ),
41 m_bHasInitialStacking( true ),
42 m_bComplexCategories( false )
44 get(m_pCbShowDescription
, "showlabelsCB");
45 get(m_pFlOrder
, "orderL");
46 get(m_pRbSideBySide
, "tile");
47 get(m_pRbUpDown
, "odd");
48 get(m_pRbDownUp
, "even");
49 get(m_pRbAuto
, "auto");
50 get(m_pFlTextFlow
, "textflowL");
51 get(m_pCbTextOverlap
, "overlapCB");
52 get(m_pCbTextBreak
, "breakCB");
53 get(m_pFlOrient
, "labelTextOrient");
54 get(m_pCtrlDial
,"dialCtrl");
55 get(m_pFtRotate
,"degreeL");
56 get(m_pNfRotate
,"OrientDegree");
57 get(m_pCbStacked
,"stackedCB");
58 get(m_pFtTextDirection
,"textdirL");
59 get(m_pLbTextDirection
,"textdirLB");
60 get(m_pFtABCD
,"labelABCD");
61 m_pCtrlDial
->SetText(m_pFtABCD
->GetText());
62 m_pOrientHlp
= new svx::OrientationHelper(*m_pCtrlDial
, *m_pNfRotate
, *m_pCbStacked
);
63 m_pOrientHlp
->Enable();
65 m_pCbStacked
->EnableTriState( false );
66 m_pOrientHlp
->AddDependentWindow( *m_pFlOrient
);
67 m_pOrientHlp
->AddDependentWindow( *m_pFtRotate
, TRISTATE_TRUE
);
69 m_pCbShowDescription
->SetClickHdl( LINK( this, SchAxisLabelTabPage
, ToggleShowLabel
) );
72 SchAxisLabelTabPage::~SchAxisLabelTabPage()
77 void SchAxisLabelTabPage::dispose()
80 m_pOrientHlp
= nullptr;
81 m_pCbShowDescription
.clear();
83 m_pRbSideBySide
.clear();
87 m_pFlTextFlow
.clear();
88 m_pCbTextOverlap
.clear();
89 m_pCbTextBreak
.clear();
96 m_pFtTextDirection
.clear();
97 m_pLbTextDirection
.clear();
98 SfxTabPage::dispose();
101 VclPtr
<SfxTabPage
> SchAxisLabelTabPage::Create( TabPageParent pParent
, const SfxItemSet
* rAttrs
)
103 return VclPtr
<SchAxisLabelTabPage
>::Create( pParent
.pParent
, *rAttrs
);
106 bool SchAxisLabelTabPage::FillItemSet( SfxItemSet
* rOutAttrs
)
108 bool bStacked
= false;
109 if( m_pOrientHlp
->GetStackedState() != TRISTATE_INDET
)
111 bStacked
= m_pOrientHlp
->GetStackedState() == TRISTATE_TRUE
;
112 if( !m_bHasInitialStacking
|| (bStacked
!= m_bInitialStacking
) )
113 rOutAttrs
->Put( SfxBoolItem( SCHATTR_TEXT_STACKED
, bStacked
) );
116 if( m_pCtrlDial
->HasRotation() )
118 sal_Int32 nDegrees
= bStacked
? 0 : m_pCtrlDial
->GetRotation();
119 if( !m_bHasInitialDegrees
|| (nDegrees
!= m_nInitialDegrees
) )
120 rOutAttrs
->Put( SfxInt32Item( SCHATTR_TEXT_DEGREES
, nDegrees
) );
123 if( m_bShowStaggeringControls
)
125 SvxChartTextOrder eOrder
= SvxChartTextOrder::SideBySide
;
126 bool bRadioButtonChecked
= true;
128 if( m_pRbUpDown
->IsChecked())
129 eOrder
= SvxChartTextOrder::UpDown
;
130 else if( m_pRbDownUp
->IsChecked())
131 eOrder
= SvxChartTextOrder::DownUp
;
132 else if( m_pRbAuto
->IsChecked())
133 eOrder
= SvxChartTextOrder::Auto
;
134 else if( m_pRbSideBySide
->IsChecked())
135 eOrder
= SvxChartTextOrder::SideBySide
;
137 bRadioButtonChecked
= false;
139 if( bRadioButtonChecked
)
140 rOutAttrs
->Put( SvxChartTextOrderItem( eOrder
, SCHATTR_AXIS_LABEL_ORDER
));
143 if( m_pCbTextOverlap
->GetState() != TRISTATE_INDET
)
144 rOutAttrs
->Put( SfxBoolItem( SCHATTR_AXIS_LABEL_OVERLAP
, m_pCbTextOverlap
->IsChecked() ) );
145 if( m_pCbTextBreak
->GetState() != TRISTATE_INDET
)
146 rOutAttrs
->Put( SfxBoolItem( SCHATTR_AXIS_LABEL_BREAK
, m_pCbTextBreak
->IsChecked() ) );
147 if( m_pCbShowDescription
->GetState() != TRISTATE_INDET
)
148 rOutAttrs
->Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR
, m_pCbShowDescription
->IsChecked() ) );
150 if( m_pLbTextDirection
->GetSelectedEntryCount() > 0 )
151 rOutAttrs
->Put( SvxFrameDirectionItem( m_pLbTextDirection
->GetSelectEntryValue(), EE_PARA_WRITINGDIR
) );
156 void SchAxisLabelTabPage::Reset( const SfxItemSet
* rInAttrs
)
158 const SfxPoolItem
* pPoolItem
= nullptr;
161 SfxItemState aState
= rInAttrs
->GetItemState( SCHATTR_AXIS_SHOWDESCR
, false, &pPoolItem
);
162 if( aState
== SfxItemState::DONTCARE
)
164 m_pCbShowDescription
->EnableTriState();
165 m_pCbShowDescription
->SetState( TRISTATE_INDET
);
169 m_pCbShowDescription
->EnableTriState( false );
171 if( aState
== SfxItemState::SET
)
172 bCheck
= static_cast< const SfxBoolItem
* >( pPoolItem
)->GetValue();
173 m_pCbShowDescription
->Check( bCheck
);
175 if( aState
!= SfxItemState::DEFAULT
&& aState
!= SfxItemState::SET
)
176 m_pCbShowDescription
->Hide();
179 // Rotation as orient item or in degrees ----------
181 // check new degree item
182 m_nInitialDegrees
= 0;
183 aState
= rInAttrs
->GetItemState( SCHATTR_TEXT_DEGREES
, false, &pPoolItem
);
184 if( aState
== SfxItemState::SET
)
185 m_nInitialDegrees
= static_cast< const SfxInt32Item
* >( pPoolItem
)->GetValue();
187 m_bHasInitialDegrees
= aState
!= SfxItemState::DONTCARE
;
188 if( m_bHasInitialDegrees
)
189 m_pCtrlDial
->SetRotation( m_nInitialDegrees
);
191 m_pCtrlDial
->SetNoRotation();
193 // check stacked item
194 m_bInitialStacking
= false;
195 aState
= rInAttrs
->GetItemState( SCHATTR_TEXT_STACKED
, false, &pPoolItem
);
196 if( aState
== SfxItemState::SET
)
197 m_bInitialStacking
= static_cast< const SfxBoolItem
* >( pPoolItem
)->GetValue();
199 m_bHasInitialStacking
= aState
!= SfxItemState::DONTCARE
;
200 if( m_bHasInitialDegrees
)
201 m_pOrientHlp
->SetStackedState( m_bInitialStacking
? TRISTATE_TRUE
: TRISTATE_FALSE
);
203 m_pOrientHlp
->SetStackedState( TRISTATE_INDET
);
205 if( rInAttrs
->GetItemState( EE_PARA_WRITINGDIR
, true, &pPoolItem
) == SfxItemState::SET
)
206 m_pLbTextDirection
->SelectEntryValue( static_cast<const SvxFrameDirectionItem
*>(pPoolItem
)->GetValue() );
208 // Text overlap ----------
209 aState
= rInAttrs
->GetItemState( SCHATTR_AXIS_LABEL_OVERLAP
, false, &pPoolItem
);
210 if( aState
== SfxItemState::DONTCARE
)
212 m_pCbTextOverlap
->EnableTriState();
213 m_pCbTextOverlap
->SetState( TRISTATE_INDET
);
217 m_pCbTextOverlap
->EnableTriState( false );
219 if( aState
== SfxItemState::SET
)
220 bCheck
= static_cast< const SfxBoolItem
* >( pPoolItem
)->GetValue();
221 m_pCbTextOverlap
->Check( bCheck
);
223 if( aState
!= SfxItemState::DEFAULT
&& aState
!= SfxItemState::SET
)
224 m_pCbTextOverlap
->Hide();
227 // text break ----------
228 aState
= rInAttrs
->GetItemState( SCHATTR_AXIS_LABEL_BREAK
, false, &pPoolItem
);
229 if( aState
== SfxItemState::DONTCARE
)
231 m_pCbTextBreak
->EnableTriState();
232 m_pCbTextBreak
->SetState( TRISTATE_INDET
);
236 m_pCbTextBreak
->EnableTriState( false );
238 if( aState
== SfxItemState::SET
)
239 bCheck
= static_cast< const SfxBoolItem
* >( pPoolItem
)->GetValue();
240 m_pCbTextBreak
->Check( bCheck
);
242 if( aState
!= SfxItemState::DEFAULT
&& aState
!= SfxItemState::SET
)
244 m_pCbTextBreak
->Hide();
245 if( ! m_pCbTextOverlap
->IsVisible() )
246 m_pFlTextFlow
->Hide();
250 // text order ----------
251 if( m_bShowStaggeringControls
)
253 aState
= rInAttrs
->GetItemState( SCHATTR_AXIS_LABEL_ORDER
, false, &pPoolItem
);
254 if( aState
== SfxItemState::SET
)
256 SvxChartTextOrder eOrder
= static_cast< const SvxChartTextOrderItem
* >( pPoolItem
)->GetValue();
260 case SvxChartTextOrder::SideBySide
:
261 m_pRbSideBySide
->Check();
263 case SvxChartTextOrder::UpDown
:
264 m_pRbUpDown
->Check();
266 case SvxChartTextOrder::DownUp
:
267 m_pRbDownUp
->Check();
269 case SvxChartTextOrder::Auto
:
276 ToggleShowLabel( nullptr );
279 void SchAxisLabelTabPage::ShowStaggeringControls( bool bShowStaggeringControls
)
281 m_bShowStaggeringControls
= bShowStaggeringControls
;
283 if( !m_bShowStaggeringControls
)
285 m_pRbSideBySide
->Hide();
293 void SchAxisLabelTabPage::SetComplexCategories( bool bComplexCategories
)
295 m_bComplexCategories
= bComplexCategories
;
298 // event handling routines
300 IMPL_LINK_NOARG(SchAxisLabelTabPage
, ToggleShowLabel
, Button
*, void)
302 bool bEnable
= ( m_pCbShowDescription
->GetState() != TRISTATE_FALSE
);
304 m_pOrientHlp
->Enable( bEnable
);
305 m_pFlOrder
->Enable( bEnable
);
306 m_pRbSideBySide
->Enable( bEnable
);
307 m_pRbUpDown
->Enable( bEnable
);
308 m_pRbDownUp
->Enable( bEnable
);
309 m_pRbAuto
->Enable( bEnable
);
311 m_pFlTextFlow
->Enable( bEnable
);
312 m_pCbTextOverlap
->Enable( bEnable
&& !m_bComplexCategories
);
313 m_pCbTextBreak
->Enable( bEnable
);
315 m_pFtTextDirection
->Enable( bEnable
);
316 m_pLbTextDirection
->Enable( bEnable
);
320 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */