Bump for 3.6-28
[LibreOffice.git] / chart2 / source / controller / dialogs / tp_AxisLabel.cxx
blobe0892c3837bf1804a93595200d5e0f9018396845
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "tp_AxisLabel.hxx"
31 #include "ResId.hxx"
32 #include "TabPages.hrc"
33 #include "chartview/ChartSfxItemIds.hxx"
34 #include "NoWarningThisInCTOR.hxx"
36 // header for SvxChartTextOrientItem / SvxChartTextOrderItem
37 #include <svx/chrtitem.hxx>
39 // header for SfxInt32Item
40 #include <svl/intitem.hxx>
41 #include <editeng/eeitem.hxx>
42 #include <editeng/frmdiritem.hxx>
44 //.............................................................................
45 namespace chart
47 //.............................................................................
49 SchAxisLabelTabPage::SchAxisLabelTabPage( Window* pParent, const SfxItemSet& rInAttrs ) :
50 SfxTabPage( pParent, SchResId( TP_AXIS_LABEL ), rInAttrs ),
52 aCbShowDescription( this, SchResId( CB_AXIS_LABEL_SCHOW_DESCR ) ),
54 aFlOrder( this, SchResId( FL_AXIS_LABEL_ORDER ) ),
55 aRbSideBySide( this, SchResId( RB_AXIS_LABEL_SIDEBYSIDE ) ),
56 aRbUpDown( this, SchResId( RB_AXIS_LABEL_UPDOWN ) ),
57 aRbDownUp( this, SchResId( RB_AXIS_LABEL_DOWNUP ) ),
58 aRbAuto( this, SchResId( RB_AXIS_LABEL_AUTOORDER ) ),
60 aFlSeparator( this, SchResId( FL_SEPARATOR ) ),
61 aFlTextFlow( this, SchResId( FL_AXIS_LABEL_TEXTFLOW ) ),
62 aCbTextOverlap( this, SchResId( CB_AXIS_LABEL_TEXTOVERLAP ) ),
63 aCbTextBreak( this, SchResId( CB_AXIS_LABEL_TEXTBREAK ) ),
65 aFlOrient( this, SchResId( FL_AXIS_LABEL_ORIENTATION ) ),
66 aCtrlDial( this, SchResId( CT_AXIS_LABEL_DIAL ) ),
67 aFtRotate( this, SchResId( FT_AXIS_LABEL_DEGREES ) ),
68 aNfRotate( this, SchResId( NF_AXIS_LABEL_ORIENT ) ),
69 aCbStacked( this, SchResId( PB_AXIS_LABEL_TEXTSTACKED ) ),
70 aOrientHlp( aCtrlDial, aNfRotate, aCbStacked ),
72 m_aFtTextDirection( this, SchResId( FT_AXIS_TEXTDIR ) ),
73 m_aLbTextDirection( this, SchResId( LB_AXIS_TEXTDIR ), &m_aFtTextDirection ),
75 m_bShowStaggeringControls( true ),
77 m_nInitialDegrees( 0 ),
78 m_bHasInitialDegrees( true ),
79 m_bInitialStacking( false ),
80 m_bHasInitialStacking( true ),
81 m_bComplexCategories( false )
83 FreeResource();
85 aCbStacked.EnableTriState( sal_False );
86 aOrientHlp.AddDependentWindow( aFlOrient );
87 aOrientHlp.AddDependentWindow( aFtRotate, STATE_CHECK );
89 aCbShowDescription.SetClickHdl( LINK( this, SchAxisLabelTabPage, ToggleShowLabel ) );
91 // Make the fixed line separator vertical.
92 aFlSeparator.SetStyle (aFlSeparator.GetStyle() | WB_VERT);
94 Construct();
97 SchAxisLabelTabPage::~SchAxisLabelTabPage()
100 void SchAxisLabelTabPage::Construct()
105 SfxTabPage* SchAxisLabelTabPage::Create( Window* pParent, const SfxItemSet& rAttrs )
107 return new SchAxisLabelTabPage( pParent, rAttrs );
110 sal_Bool SchAxisLabelTabPage::FillItemSet( SfxItemSet& rOutAttrs )
112 bool bStacked = false;
113 if( aOrientHlp.GetStackedState() != STATE_DONTKNOW )
115 bStacked = aOrientHlp.GetStackedState() == STATE_CHECK;
116 if( !m_bHasInitialStacking || (bStacked != m_bInitialStacking) )
117 rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXT_STACKED, bStacked ) );
120 if( aCtrlDial.HasRotation() )
122 sal_Int32 nDegrees = bStacked ? 0 : aCtrlDial.GetRotation();
123 if( !m_bHasInitialDegrees || (nDegrees != m_nInitialDegrees) )
124 rOutAttrs.Put( SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) );
127 if( m_bShowStaggeringControls )
129 SvxChartTextOrder eOrder = CHTXTORDER_SIDEBYSIDE;
130 bool bRadioButtonChecked = true;
132 if( aRbUpDown.IsChecked())
133 eOrder = CHTXTORDER_UPDOWN;
134 else if( aRbDownUp.IsChecked())
135 eOrder = CHTXTORDER_DOWNUP;
136 else if( aRbAuto.IsChecked())
137 eOrder = CHTXTORDER_AUTO;
138 else if( aRbSideBySide.IsChecked())
139 eOrder = CHTXTORDER_SIDEBYSIDE;
140 else
141 bRadioButtonChecked = false;
143 if( bRadioButtonChecked )
144 rOutAttrs.Put( SvxChartTextOrderItem( eOrder, SCHATTR_AXIS_LABEL_ORDER ));
147 if( aCbTextOverlap.GetState() != STATE_DONTKNOW )
148 rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_LABEL_OVERLAP, aCbTextOverlap.IsChecked() ) );
149 if( aCbTextBreak.GetState() != STATE_DONTKNOW )
150 rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_LABEL_BREAK, aCbTextBreak.IsChecked() ) );
151 if( aCbShowDescription.GetState() != STATE_DONTKNOW )
152 rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR, aCbShowDescription.IsChecked() ) );
154 if( m_aLbTextDirection.GetSelectEntryCount() > 0 )
155 rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, m_aLbTextDirection.GetSelectEntryValue() ) );
157 return sal_True;
160 void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs )
162 const SfxPoolItem* pPoolItem = NULL;
163 SfxItemState aState = SFX_ITEM_UNKNOWN;
165 // show description ----------
166 aState = rInAttrs.GetItemState( SCHATTR_AXIS_SHOWDESCR, sal_False, &pPoolItem );
167 if( aState == SFX_ITEM_DONTCARE )
169 aCbShowDescription.EnableTriState( sal_True );
170 aCbShowDescription.SetState( STATE_DONTKNOW );
172 else
174 aCbShowDescription.EnableTriState( sal_False );
175 sal_Bool bCheck = sal_False;
176 if( aState == SFX_ITEM_SET )
177 bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
178 aCbShowDescription.Check( bCheck );
180 if( ( aState & SFX_ITEM_DEFAULT ) == 0 )
181 aCbShowDescription.Hide();
184 // Rotation as orient item or in degrees ----------
186 // check new degree item
187 m_nInitialDegrees = 0;
188 aState = rInAttrs.GetItemState( SCHATTR_TEXT_DEGREES, sal_False, &pPoolItem );
189 if( aState == SFX_ITEM_SET )
190 m_nInitialDegrees = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
192 m_bHasInitialDegrees = aState != SFX_ITEM_DONTCARE;
193 if( m_bHasInitialDegrees )
194 aCtrlDial.SetRotation( m_nInitialDegrees );
195 else
196 aCtrlDial.SetNoRotation();
198 // check stacked item
199 m_bInitialStacking = false;
200 aState = rInAttrs.GetItemState( SCHATTR_TEXT_STACKED, sal_False, &pPoolItem );
201 if( aState == SFX_ITEM_SET )
202 m_bInitialStacking = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
204 m_bHasInitialStacking = aState != SFX_ITEM_DONTCARE;
205 if( m_bHasInitialDegrees )
206 aOrientHlp.SetStackedState( m_bInitialStacking ? STATE_CHECK : STATE_NOCHECK );
207 else
208 aOrientHlp.SetStackedState( STATE_DONTKNOW );
210 if( rInAttrs.GetItemState( EE_PARA_WRITINGDIR, sal_True, &pPoolItem ) == SFX_ITEM_SET )
211 m_aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) );
213 // Text overlap ----------
214 aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_OVERLAP, sal_False, &pPoolItem );
215 if( aState == SFX_ITEM_DONTCARE )
217 aCbTextOverlap.EnableTriState( sal_True );
218 aCbTextOverlap.SetState( STATE_DONTKNOW );
220 else
222 aCbTextOverlap.EnableTriState( sal_False );
223 sal_Bool bCheck = sal_False;
224 if( aState == SFX_ITEM_SET )
225 bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
226 aCbTextOverlap.Check( bCheck );
228 if( ( aState & SFX_ITEM_DEFAULT ) == 0 )
229 aCbTextOverlap.Hide();
232 // text break ----------
233 aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_BREAK, sal_False, &pPoolItem );
234 if( aState == SFX_ITEM_DONTCARE )
236 aCbTextBreak.EnableTriState( sal_True );
237 aCbTextBreak.SetState( STATE_DONTKNOW );
239 else
241 aCbTextBreak.EnableTriState( sal_False );
242 sal_Bool bCheck = sal_False;
243 if( aState == SFX_ITEM_SET )
244 bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
245 aCbTextBreak.Check( bCheck );
247 if( ( aState & SFX_ITEM_DEFAULT ) == 0 )
249 aCbTextBreak.Hide();
250 if( ! aCbTextOverlap.IsVisible() )
251 aFlTextFlow.Hide();
255 // text order ----------
256 if( m_bShowStaggeringControls )
258 aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_ORDER, sal_False, &pPoolItem );
259 if( aState == SFX_ITEM_SET )
261 SvxChartTextOrder eOrder = static_cast< const SvxChartTextOrderItem * >( pPoolItem )->GetValue();
263 switch( eOrder )
265 case CHTXTORDER_SIDEBYSIDE:
266 aRbSideBySide.Check();
267 break;
268 case CHTXTORDER_UPDOWN:
269 aRbUpDown.Check();
270 break;
271 case CHTXTORDER_DOWNUP:
272 aRbDownUp.Check();
273 break;
274 case CHTXTORDER_AUTO:
275 aRbAuto.Check();
276 break;
281 ToggleShowLabel( (void*)0 );
284 void SchAxisLabelTabPage::ShowStaggeringControls( sal_Bool bShowStaggeringControls )
286 m_bShowStaggeringControls = bShowStaggeringControls;
288 if( !m_bShowStaggeringControls )
290 aRbSideBySide.Hide();
291 aRbUpDown.Hide();
292 aRbDownUp.Hide();
293 aRbAuto.Hide();
294 aFlOrder.Hide();
298 void SchAxisLabelTabPage::SetComplexCategories( bool bComplexCategories )
300 m_bComplexCategories = bComplexCategories;
303 // event handling routines
304 // -----------------------
306 IMPL_LINK_NOARG(SchAxisLabelTabPage, ToggleShowLabel)
308 sal_Bool bEnable = ( aCbShowDescription.GetState() != STATE_NOCHECK );
310 aOrientHlp.Enable( bEnable );
311 aFlOrder.Enable( bEnable );
312 aRbSideBySide.Enable( bEnable );
313 aRbUpDown.Enable( bEnable );
314 aRbDownUp.Enable( bEnable );
315 aRbAuto.Enable( bEnable );
317 aFlTextFlow.Enable( bEnable );
318 aCbTextOverlap.Enable( bEnable && !m_bComplexCategories );
319 aCbTextBreak.Enable( bEnable );
321 m_aFtTextDirection.Enable( bEnable );
322 m_aLbTextDirection.Enable( bEnable );
324 return 0L;
326 //.............................................................................
327 } //namespace chart
328 //.............................................................................
330 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */