merge the formfield patch from ooo-build
[ooovba.git] / chart2 / source / controller / dialogs / tp_AxisLabel.cxx
blob8ae1e8c200d7193947d78307acf0a4e33e996d49
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tp_AxisLabel.cxx,v $
10 * $Revision: 1.10.72.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
33 #include "tp_AxisLabel.hxx"
35 #include "ResId.hxx"
36 #include "TabPages.hrc"
37 #include "chartview/ChartSfxItemIds.hxx"
38 #include "NoWarningThisInCTOR.hxx"
40 // header for SvxChartTextOrientItem / SvxChartTextOrderItem
41 #include <svx/chrtitem.hxx>
43 // header for SfxInt32Item
44 #include <svtools/intitem.hxx>
45 #include <svx/eeitem.hxx>
46 #include <svx/frmdiritem.hxx>
48 //.............................................................................
49 namespace chart
51 //.............................................................................
53 SchAxisLabelTabPage::SchAxisLabelTabPage( Window* pParent, const SfxItemSet& rInAttrs ) :
54 SfxTabPage( pParent, SchResId( TP_AXIS_LABEL ), rInAttrs ),
56 aCbShowDescription( this, SchResId( CB_AXIS_LABEL_SCHOW_DESCR ) ),
58 aFlOrder( this, SchResId( FL_AXIS_LABEL_ORDER ) ),
59 aRbSideBySide( this, SchResId( RB_AXIS_LABEL_SIDEBYSIDE ) ),
60 aRbUpDown( this, SchResId( RB_AXIS_LABEL_UPDOWN ) ),
61 aRbDownUp( this, SchResId( RB_AXIS_LABEL_DOWNUP ) ),
62 aRbAuto( this, SchResId( RB_AXIS_LABEL_AUTOORDER ) ),
64 aFlSeparator( this, SchResId( FL_SEPARATOR ) ),
65 aFlTextFlow( this, SchResId( FL_AXIS_LABEL_TEXTFLOW ) ),
66 aCbTextOverlap( this, SchResId( CB_AXIS_LABEL_TEXTOVERLAP ) ),
67 aCbTextBreak( this, SchResId( CB_AXIS_LABEL_TEXTBREAK ) ),
69 aFlOrient( this, SchResId( FL_AXIS_LABEL_ORIENTATION ) ),
70 aCtrlDial( this, SchResId( CT_AXIS_LABEL_DIAL ) ),
71 aFtRotate( this, SchResId( FT_AXIS_LABEL_DEGREES ) ),
72 aNfRotate( this, SchResId( NF_AXIS_LABEL_ORIENT ) ),
73 aCbStacked( this, SchResId( PB_AXIS_LABEL_TEXTSTACKED ) ),
74 aOrientHlp( aCtrlDial, aNfRotate, aCbStacked ),
76 m_aFtTextDirection( this, SchResId( FT_AXIS_TEXTDIR ) ),
77 m_aLbTextDirection( this, SchResId( LB_AXIS_TEXTDIR ), &m_aFtTextDirection ),
79 m_bShowStaggeringControls( true ),
81 m_nInitialDegrees( 0 ),
82 m_bHasInitialDegrees( true ),
83 m_bInitialStacking( false ),
84 m_bHasInitialStacking( true )
86 FreeResource();
88 aCbStacked.EnableTriState( FALSE );
89 aOrientHlp.AddDependentWindow( aFlOrient );
90 aOrientHlp.AddDependentWindow( aFtRotate, STATE_CHECK );
92 aCbShowDescription.SetClickHdl( LINK( this, SchAxisLabelTabPage, ToggleShowLabel ) );
94 // Make the fixed line separator vertical.
95 aFlSeparator.SetStyle (aFlSeparator.GetStyle() | WB_VERT);
97 Construct();
100 SchAxisLabelTabPage::~SchAxisLabelTabPage()
103 void SchAxisLabelTabPage::Construct()
108 SfxTabPage* SchAxisLabelTabPage::Create( Window* pParent, const SfxItemSet& rAttrs )
110 return new SchAxisLabelTabPage( pParent, rAttrs );
113 BOOL SchAxisLabelTabPage::FillItemSet( SfxItemSet& rOutAttrs )
115 bool bStacked = false;
116 if( aOrientHlp.GetStackedState() != STATE_DONTKNOW )
118 bStacked = aOrientHlp.GetStackedState() == STATE_CHECK;
119 if( !m_bHasInitialStacking || (bStacked != m_bInitialStacking) )
120 rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXT_STACKED, bStacked ) );
123 if( aCtrlDial.HasRotation() )
125 sal_Int32 nDegrees = bStacked ? 0 : aCtrlDial.GetRotation();
126 if( !m_bHasInitialDegrees || (nDegrees != m_nInitialDegrees) )
127 rOutAttrs.Put( SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) );
130 if( m_bShowStaggeringControls )
132 SvxChartTextOrder eOrder = CHTXTORDER_SIDEBYSIDE;
133 bool bRadioButtonChecked = true;
135 if( aRbUpDown.IsChecked())
136 eOrder = CHTXTORDER_UPDOWN;
137 else if( aRbDownUp.IsChecked())
138 eOrder = CHTXTORDER_DOWNUP;
139 else if( aRbAuto.IsChecked())
140 eOrder = CHTXTORDER_AUTO;
141 else if( aRbSideBySide.IsChecked())
142 eOrder = CHTXTORDER_SIDEBYSIDE;
143 else
144 bRadioButtonChecked = false;
146 if( bRadioButtonChecked )
147 rOutAttrs.Put( SvxChartTextOrderItem( eOrder, SCHATTR_TEXT_ORDER ));
150 if( aCbTextOverlap.GetState() != STATE_DONTKNOW )
151 rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXT_OVERLAP, aCbTextOverlap.IsChecked() ) );
152 if( aCbTextBreak.GetState() != STATE_DONTKNOW )
153 rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXTBREAK, aCbTextBreak.IsChecked() ) );
154 if( aCbShowDescription.GetState() != STATE_DONTKNOW )
155 rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR, aCbShowDescription.IsChecked() ) );
157 if( m_aLbTextDirection.GetSelectEntryCount() > 0 )
158 rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, m_aLbTextDirection.GetSelectEntryValue() ) );
160 return TRUE;
163 void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs )
165 const SfxPoolItem* pPoolItem = NULL;
166 SfxItemState aState = SFX_ITEM_UNKNOWN;
168 // show description ----------
169 aState = rInAttrs.GetItemState( SCHATTR_AXIS_SHOWDESCR, FALSE, &pPoolItem );
170 if( aState == SFX_ITEM_DONTCARE )
172 aCbShowDescription.EnableTriState( TRUE );
173 aCbShowDescription.SetState( STATE_DONTKNOW );
175 else
177 aCbShowDescription.EnableTriState( FALSE );
178 BOOL bCheck = FALSE;
179 if( aState == SFX_ITEM_SET )
180 bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
181 aCbShowDescription.Check( bCheck );
183 if( ( aState & SFX_ITEM_DEFAULT ) == 0 )
184 aCbShowDescription.Hide();
187 // Rotation as orient item or in degrees ----------
189 // check new degree item
190 m_nInitialDegrees = 0;
191 aState = rInAttrs.GetItemState( SCHATTR_TEXT_DEGREES, FALSE, &pPoolItem );
192 if( aState == SFX_ITEM_SET )
193 m_nInitialDegrees = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
195 m_bHasInitialDegrees = aState != SFX_ITEM_DONTCARE;
196 if( m_bHasInitialDegrees )
197 aCtrlDial.SetRotation( m_nInitialDegrees );
198 else
199 aCtrlDial.SetNoRotation();
201 // check stacked item
202 m_bInitialStacking = false;
203 aState = rInAttrs.GetItemState( SCHATTR_TEXT_STACKED, FALSE, &pPoolItem );
204 if( aState == SFX_ITEM_SET )
205 m_bInitialStacking = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
207 m_bHasInitialStacking = aState != SFX_ITEM_DONTCARE;
208 if( m_bHasInitialDegrees )
209 aOrientHlp.SetStackedState( m_bInitialStacking ? STATE_CHECK : STATE_NOCHECK );
210 else
211 aOrientHlp.SetStackedState( STATE_DONTKNOW );
213 if( rInAttrs.GetItemState( EE_PARA_WRITINGDIR, TRUE, &pPoolItem ) == SFX_ITEM_SET )
214 m_aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) );
216 // Text overlap ----------
217 aState = rInAttrs.GetItemState( SCHATTR_TEXT_OVERLAP, FALSE, &pPoolItem );
218 if( aState == SFX_ITEM_DONTCARE )
220 aCbTextOverlap.EnableTriState( TRUE );
221 aCbTextOverlap.SetState( STATE_DONTKNOW );
223 else
225 aCbTextOverlap.EnableTriState( FALSE );
226 BOOL bCheck = FALSE;
227 if( aState == SFX_ITEM_SET )
228 bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
229 aCbTextOverlap.Check( bCheck );
231 if( ( aState & SFX_ITEM_DEFAULT ) == 0 )
232 aCbTextOverlap.Hide();
235 // text break ----------
236 aState = rInAttrs.GetItemState( SCHATTR_TEXTBREAK, FALSE, &pPoolItem );
237 if( aState == SFX_ITEM_DONTCARE )
239 aCbTextBreak.EnableTriState( TRUE );
240 aCbTextBreak.SetState( STATE_DONTKNOW );
242 else
244 aCbTextBreak.EnableTriState( FALSE );
245 BOOL bCheck = FALSE;
246 if( aState == SFX_ITEM_SET )
247 bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
248 aCbTextBreak.Check( bCheck );
250 if( ( aState & SFX_ITEM_DEFAULT ) == 0 )
252 aCbTextBreak.Hide();
253 if( ! aCbTextOverlap.IsVisible() )
254 aFlTextFlow.Hide();
258 // text order ----------
259 if( m_bShowStaggeringControls )
261 aState = rInAttrs.GetItemState( SCHATTR_TEXT_ORDER, FALSE, &pPoolItem );
262 if( aState == SFX_ITEM_SET )
264 SvxChartTextOrder eOrder = static_cast< const SvxChartTextOrderItem * >( pPoolItem )->GetValue();
266 switch( eOrder )
268 case CHTXTORDER_SIDEBYSIDE:
269 aRbSideBySide.Check();
270 break;
271 case CHTXTORDER_UPDOWN:
272 aRbUpDown.Check();
273 break;
274 case CHTXTORDER_DOWNUP:
275 aRbDownUp.Check();
276 break;
277 case CHTXTORDER_AUTO:
278 aRbAuto.Check();
279 break;
284 ToggleShowLabel( (void*)0 );
287 void SchAxisLabelTabPage::ShowStaggeringControls( BOOL bShowStaggeringControls )
289 m_bShowStaggeringControls = bShowStaggeringControls;
291 if( !m_bShowStaggeringControls )
293 aRbSideBySide.Hide();
294 aRbUpDown.Hide();
295 aRbDownUp.Hide();
296 aRbAuto.Hide();
297 aFlOrder.Hide();
301 // event handling routines
302 // -----------------------
304 IMPL_LINK ( SchAxisLabelTabPage, ToggleShowLabel, void *, EMPTYARG )
306 BOOL bEnable = ( aCbShowDescription.GetState() != STATE_NOCHECK );
308 aOrientHlp.Enable( bEnable );
309 aFlOrder.Enable( bEnable );
310 aRbSideBySide.Enable( bEnable );
311 aRbUpDown.Enable( bEnable );
312 aRbDownUp.Enable( bEnable );
313 aRbAuto.Enable( bEnable );
315 aFlTextFlow.Enable( bEnable );
316 aCbTextOverlap.Enable( bEnable );
317 aCbTextBreak.Enable( bEnable );
319 m_aFtTextDirection.Enable( bEnable );
320 m_aLbTextDirection.Enable( bEnable );
322 return 0L;
324 //.............................................................................
325 } //namespace chart
326 //.............................................................................