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"
23 #include "ResourceIds.hrc"
24 #include "chartview/ChartSfxItemIds.hxx"
26 #include <svx/chrtitem.hxx>
27 #include <svl/intitem.hxx>
28 #include <editeng/eeitem.hxx>
29 #include <editeng/frmdiritem.hxx>
34 SchAxisLabelTabPage::SchAxisLabelTabPage( vcl::Window
* pParent
, const SfxItemSet
& rInAttrs
) :
35 SfxTabPage( pParent
, "AxisLabelTabPage","modules/schart/ui/tp_axisLabel.ui", &rInAttrs
),
37 m_bShowStaggeringControls( true ),
39 m_nInitialDegrees( 0 ),
40 m_bHasInitialDegrees( true ),
41 m_bInitialStacking( false ),
42 m_bHasInitialStacking( true ),
43 m_bComplexCategories( false )
45 get(m_pCbShowDescription
, "showlabelsCB");
46 get(m_pFlOrder
, "orderL");
47 get(m_pRbSideBySide
, "tile");
48 get(m_pRbUpDown
, "odd");
49 get(m_pRbDownUp
, "even");
50 get(m_pRbAuto
, "auto");
51 get(m_pFlTextFlow
, "textflowL");
52 get(m_pCbTextOverlap
, "overlapCB");
53 get(m_pCbTextBreak
, "breakCB");
54 get(m_pFlOrient
, "labelTextOrient");
55 get(m_pCtrlDial
,"dialCtrl");
56 get(m_pFtRotate
,"degreeL");
57 get(m_pNfRotate
,"OrientDegree");
58 get(m_pCbStacked
,"stackedCB");
59 get(m_pFtTextDirection
,"textdirL");
60 get(m_pLbTextDirection
,"textdirLB");
61 get(m_pFtABCD
,"labelABCD");
62 m_pCtrlDial
->SetText(m_pFtABCD
->GetText());
63 m_pOrientHlp
= new svx::OrientationHelper(*m_pCtrlDial
, *m_pNfRotate
, *m_pCbStacked
);
64 m_pOrientHlp
->Enable( true );
66 m_pCbStacked
->EnableTriState( false );
67 m_pOrientHlp
->AddDependentWindow( *m_pFlOrient
);
68 m_pOrientHlp
->AddDependentWindow( *m_pFtRotate
, TRISTATE_TRUE
);
70 m_pCbShowDescription
->SetClickHdl( LINK( this, SchAxisLabelTabPage
, ToggleShowLabel
) );
73 SchAxisLabelTabPage::~SchAxisLabelTabPage()
78 void SchAxisLabelTabPage::dispose()
82 m_pCbShowDescription
.clear();
84 m_pRbSideBySide
.clear();
88 m_pFlTextFlow
.clear();
89 m_pCbTextOverlap
.clear();
90 m_pCbTextBreak
.clear();
97 m_pFtTextDirection
.clear();
98 m_pLbTextDirection
.clear();
99 SfxTabPage::dispose();
102 VclPtr
<SfxTabPage
> SchAxisLabelTabPage::Create( vcl::Window
* pParent
, const SfxItemSet
* rAttrs
)
104 return VclPtr
<SchAxisLabelTabPage
>::Create( pParent
, *rAttrs
);
107 bool SchAxisLabelTabPage::FillItemSet( SfxItemSet
* rOutAttrs
)
109 bool bStacked
= false;
110 if( m_pOrientHlp
->GetStackedState() != TRISTATE_INDET
)
112 bStacked
= m_pOrientHlp
->GetStackedState() == TRISTATE_TRUE
;
113 if( !m_bHasInitialStacking
|| (bStacked
!= m_bInitialStacking
) )
114 rOutAttrs
->Put( SfxBoolItem( SCHATTR_TEXT_STACKED
, bStacked
) );
117 if( m_pCtrlDial
->HasRotation() )
119 sal_Int32 nDegrees
= bStacked
? 0 : m_pCtrlDial
->GetRotation();
120 if( !m_bHasInitialDegrees
|| (nDegrees
!= m_nInitialDegrees
) )
121 rOutAttrs
->Put( SfxInt32Item( SCHATTR_TEXT_DEGREES
, nDegrees
) );
124 if( m_bShowStaggeringControls
)
126 SvxChartTextOrder eOrder
= CHTXTORDER_SIDEBYSIDE
;
127 bool bRadioButtonChecked
= true;
129 if( m_pRbUpDown
->IsChecked())
130 eOrder
= CHTXTORDER_UPDOWN
;
131 else if( m_pRbDownUp
->IsChecked())
132 eOrder
= CHTXTORDER_DOWNUP
;
133 else if( m_pRbAuto
->IsChecked())
134 eOrder
= CHTXTORDER_AUTO
;
135 else if( m_pRbSideBySide
->IsChecked())
136 eOrder
= CHTXTORDER_SIDEBYSIDE
;
138 bRadioButtonChecked
= false;
140 if( bRadioButtonChecked
)
141 rOutAttrs
->Put( SvxChartTextOrderItem( eOrder
, SCHATTR_AXIS_LABEL_ORDER
));
144 if( m_pCbTextOverlap
->GetState() != TRISTATE_INDET
)
145 rOutAttrs
->Put( SfxBoolItem( SCHATTR_AXIS_LABEL_OVERLAP
, m_pCbTextOverlap
->IsChecked() ) );
146 if( m_pCbTextBreak
->GetState() != TRISTATE_INDET
)
147 rOutAttrs
->Put( SfxBoolItem( SCHATTR_AXIS_LABEL_BREAK
, m_pCbTextBreak
->IsChecked() ) );
148 if( m_pCbShowDescription
->GetState() != TRISTATE_INDET
)
149 rOutAttrs
->Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR
, m_pCbShowDescription
->IsChecked() ) );
151 if( m_pLbTextDirection
->GetSelectEntryCount() > 0 )
152 rOutAttrs
->Put( SvxFrameDirectionItem( m_pLbTextDirection
->GetSelectEntryValue(), EE_PARA_WRITINGDIR
) );
157 void SchAxisLabelTabPage::Reset( const SfxItemSet
* rInAttrs
)
159 const SfxPoolItem
* pPoolItem
= NULL
;
162 SfxItemState aState
= rInAttrs
->GetItemState( SCHATTR_AXIS_SHOWDESCR
, false, &pPoolItem
);
163 if( aState
== SfxItemState::DONTCARE
)
165 m_pCbShowDescription
->EnableTriState( true );
166 m_pCbShowDescription
->SetState( TRISTATE_INDET
);
170 m_pCbShowDescription
->EnableTriState( false );
172 if( aState
== SfxItemState::SET
)
173 bCheck
= static_cast< const SfxBoolItem
* >( pPoolItem
)->GetValue();
174 m_pCbShowDescription
->Check( bCheck
);
176 if( aState
!= SfxItemState::DEFAULT
&& aState
!= SfxItemState::SET
)
177 m_pCbShowDescription
->Hide();
180 // Rotation as orient item or in degrees ----------
182 // check new degree item
183 m_nInitialDegrees
= 0;
184 aState
= rInAttrs
->GetItemState( SCHATTR_TEXT_DEGREES
, false, &pPoolItem
);
185 if( aState
== SfxItemState::SET
)
186 m_nInitialDegrees
= static_cast< const SfxInt32Item
* >( pPoolItem
)->GetValue();
188 m_bHasInitialDegrees
= aState
!= SfxItemState::DONTCARE
;
189 if( m_bHasInitialDegrees
)
190 m_pCtrlDial
->SetRotation( m_nInitialDegrees
);
192 m_pCtrlDial
->SetNoRotation();
194 // check stacked item
195 m_bInitialStacking
= false;
196 aState
= rInAttrs
->GetItemState( SCHATTR_TEXT_STACKED
, false, &pPoolItem
);
197 if( aState
== SfxItemState::SET
)
198 m_bInitialStacking
= static_cast< const SfxBoolItem
* >( pPoolItem
)->GetValue();
200 m_bHasInitialStacking
= aState
!= SfxItemState::DONTCARE
;
201 if( m_bHasInitialDegrees
)
202 m_pOrientHlp
->SetStackedState( m_bInitialStacking
? TRISTATE_TRUE
: TRISTATE_FALSE
);
204 m_pOrientHlp
->SetStackedState( TRISTATE_INDET
);
206 if( rInAttrs
->GetItemState( EE_PARA_WRITINGDIR
, true, &pPoolItem
) == SfxItemState::SET
)
207 m_pLbTextDirection
->SelectEntryValue( SvxFrameDirection(static_cast<const SvxFrameDirectionItem
*>(pPoolItem
)->GetValue()) );
209 // Text overlap ----------
210 aState
= rInAttrs
->GetItemState( SCHATTR_AXIS_LABEL_OVERLAP
, false, &pPoolItem
);
211 if( aState
== SfxItemState::DONTCARE
)
213 m_pCbTextOverlap
->EnableTriState( true );
214 m_pCbTextOverlap
->SetState( TRISTATE_INDET
);
218 m_pCbTextOverlap
->EnableTriState( false );
220 if( aState
== SfxItemState::SET
)
221 bCheck
= static_cast< const SfxBoolItem
* >( pPoolItem
)->GetValue();
222 m_pCbTextOverlap
->Check( bCheck
);
224 if( aState
!= SfxItemState::DEFAULT
&& aState
!= SfxItemState::SET
)
225 m_pCbTextOverlap
->Hide();
228 // text break ----------
229 aState
= rInAttrs
->GetItemState( SCHATTR_AXIS_LABEL_BREAK
, false, &pPoolItem
);
230 if( aState
== SfxItemState::DONTCARE
)
232 m_pCbTextBreak
->EnableTriState( true );
233 m_pCbTextBreak
->SetState( TRISTATE_INDET
);
237 m_pCbTextBreak
->EnableTriState( false );
239 if( aState
== SfxItemState::SET
)
240 bCheck
= static_cast< const SfxBoolItem
* >( pPoolItem
)->GetValue();
241 m_pCbTextBreak
->Check( bCheck
);
243 if( aState
!= SfxItemState::DEFAULT
&& aState
!= SfxItemState::SET
)
245 m_pCbTextBreak
->Hide();
246 if( ! m_pCbTextOverlap
->IsVisible() )
247 m_pFlTextFlow
->Hide();
251 // text order ----------
252 if( m_bShowStaggeringControls
)
254 aState
= rInAttrs
->GetItemState( SCHATTR_AXIS_LABEL_ORDER
, false, &pPoolItem
);
255 if( aState
== SfxItemState::SET
)
257 SvxChartTextOrder eOrder
= static_cast< const SvxChartTextOrderItem
* >( pPoolItem
)->GetValue();
261 case CHTXTORDER_SIDEBYSIDE
:
262 m_pRbSideBySide
->Check();
264 case CHTXTORDER_UPDOWN
:
265 m_pRbUpDown
->Check();
267 case CHTXTORDER_DOWNUP
:
268 m_pRbDownUp
->Check();
270 case CHTXTORDER_AUTO
:
277 ToggleShowLabel( (void*)0 );
280 void SchAxisLabelTabPage::ShowStaggeringControls( bool bShowStaggeringControls
)
282 m_bShowStaggeringControls
= bShowStaggeringControls
;
284 if( !m_bShowStaggeringControls
)
286 m_pRbSideBySide
->Hide();
294 void SchAxisLabelTabPage::SetComplexCategories( bool bComplexCategories
)
296 m_bComplexCategories
= bComplexCategories
;
299 // event handling routines
301 IMPL_LINK_NOARG(SchAxisLabelTabPage
, ToggleShowLabel
)
303 bool bEnable
= ( m_pCbShowDescription
->GetState() != TRISTATE_FALSE
);
305 m_pOrientHlp
->Enable( bEnable
);
306 m_pFlOrder
->Enable( bEnable
);
307 m_pRbSideBySide
->Enable( bEnable
);
308 m_pRbUpDown
->Enable( bEnable
);
309 m_pRbDownUp
->Enable( bEnable
);
310 m_pRbAuto
->Enable( bEnable
);
312 m_pFlTextFlow
->Enable( bEnable
);
313 m_pCbTextOverlap
->Enable( bEnable
&& !m_bComplexCategories
);
314 m_pCbTextBreak
->Enable( bEnable
);
316 m_pFtTextDirection
->Enable( bEnable
);
317 m_pLbTextDirection
->Enable( bEnable
);
323 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */