1*cde9e8dcSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*cde9e8dcSAndrew Rist * distributed with this work for additional information 6*cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance 9*cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*cde9e8dcSAndrew Rist * software distributed under the License is distributed on an 15*cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the 17*cde9e8dcSAndrew Rist * specific language governing permissions and limitations 18*cde9e8dcSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*cde9e8dcSAndrew Rist *************************************************************/ 21*cde9e8dcSAndrew Rist 22*cde9e8dcSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_chart2.hxx" 26cdf0e10cSrcweir #include "tp_AxisLabel.hxx" 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include "ResId.hxx" 29cdf0e10cSrcweir #include "TabPages.hrc" 30cdf0e10cSrcweir #include "chartview/ChartSfxItemIds.hxx" 31cdf0e10cSrcweir #include "NoWarningThisInCTOR.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir // header for SvxChartTextOrientItem / SvxChartTextOrderItem 34cdf0e10cSrcweir #include <svx/chrtitem.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir // header for SfxInt32Item 37cdf0e10cSrcweir #include <svl/intitem.hxx> 38cdf0e10cSrcweir #include <editeng/eeitem.hxx> 39cdf0e10cSrcweir #include <editeng/frmdiritem.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir //............................................................................. 42cdf0e10cSrcweir namespace chart 43cdf0e10cSrcweir { 44cdf0e10cSrcweir //............................................................................. 45cdf0e10cSrcweir 46cdf0e10cSrcweir SchAxisLabelTabPage::SchAxisLabelTabPage( Window* pParent, const SfxItemSet& rInAttrs ) : 47cdf0e10cSrcweir SfxTabPage( pParent, SchResId( TP_AXIS_LABEL ), rInAttrs ), 48cdf0e10cSrcweir 49cdf0e10cSrcweir aCbShowDescription( this, SchResId( CB_AXIS_LABEL_SCHOW_DESCR ) ), 50cdf0e10cSrcweir 51cdf0e10cSrcweir aFlOrder( this, SchResId( FL_AXIS_LABEL_ORDER ) ), 52cdf0e10cSrcweir aRbSideBySide( this, SchResId( RB_AXIS_LABEL_SIDEBYSIDE ) ), 53cdf0e10cSrcweir aRbUpDown( this, SchResId( RB_AXIS_LABEL_UPDOWN ) ), 54cdf0e10cSrcweir aRbDownUp( this, SchResId( RB_AXIS_LABEL_DOWNUP ) ), 55cdf0e10cSrcweir aRbAuto( this, SchResId( RB_AXIS_LABEL_AUTOORDER ) ), 56cdf0e10cSrcweir 57cdf0e10cSrcweir aFlSeparator( this, SchResId( FL_SEPARATOR ) ), 58cdf0e10cSrcweir aFlTextFlow( this, SchResId( FL_AXIS_LABEL_TEXTFLOW ) ), 59cdf0e10cSrcweir aCbTextOverlap( this, SchResId( CB_AXIS_LABEL_TEXTOVERLAP ) ), 60cdf0e10cSrcweir aCbTextBreak( this, SchResId( CB_AXIS_LABEL_TEXTBREAK ) ), 61cdf0e10cSrcweir 62cdf0e10cSrcweir aFlOrient( this, SchResId( FL_AXIS_LABEL_ORIENTATION ) ), 63cdf0e10cSrcweir aCtrlDial( this, SchResId( CT_AXIS_LABEL_DIAL ) ), 64cdf0e10cSrcweir aFtRotate( this, SchResId( FT_AXIS_LABEL_DEGREES ) ), 65cdf0e10cSrcweir aNfRotate( this, SchResId( NF_AXIS_LABEL_ORIENT ) ), 66cdf0e10cSrcweir aCbStacked( this, SchResId( PB_AXIS_LABEL_TEXTSTACKED ) ), 67cdf0e10cSrcweir aOrientHlp( aCtrlDial, aNfRotate, aCbStacked ), 68cdf0e10cSrcweir 69cdf0e10cSrcweir m_aFtTextDirection( this, SchResId( FT_AXIS_TEXTDIR ) ), 70cdf0e10cSrcweir m_aLbTextDirection( this, SchResId( LB_AXIS_TEXTDIR ), &m_aFtTextDirection ), 71cdf0e10cSrcweir 72cdf0e10cSrcweir m_bShowStaggeringControls( true ), 73cdf0e10cSrcweir 74cdf0e10cSrcweir m_nInitialDegrees( 0 ), 75cdf0e10cSrcweir m_bHasInitialDegrees( true ), 76cdf0e10cSrcweir m_bInitialStacking( false ), 77cdf0e10cSrcweir m_bHasInitialStacking( true ), 78cdf0e10cSrcweir m_bComplexCategories( false ) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir FreeResource(); 81cdf0e10cSrcweir 82cdf0e10cSrcweir aCbStacked.EnableTriState( sal_False ); 83cdf0e10cSrcweir aOrientHlp.AddDependentWindow( aFlOrient ); 84cdf0e10cSrcweir aOrientHlp.AddDependentWindow( aFtRotate, STATE_CHECK ); 85cdf0e10cSrcweir 86cdf0e10cSrcweir aCbShowDescription.SetClickHdl( LINK( this, SchAxisLabelTabPage, ToggleShowLabel ) ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir // Make the fixed line separator vertical. 89cdf0e10cSrcweir aFlSeparator.SetStyle (aFlSeparator.GetStyle() | WB_VERT); 90cdf0e10cSrcweir 91cdf0e10cSrcweir Construct(); 92cdf0e10cSrcweir } 93cdf0e10cSrcweir 94cdf0e10cSrcweir SchAxisLabelTabPage::~SchAxisLabelTabPage() 95cdf0e10cSrcweir {} 96cdf0e10cSrcweir 97cdf0e10cSrcweir void SchAxisLabelTabPage::Construct() 98cdf0e10cSrcweir { 99cdf0e10cSrcweir } 100cdf0e10cSrcweir 101cdf0e10cSrcweir 102cdf0e10cSrcweir SfxTabPage* SchAxisLabelTabPage::Create( Window* pParent, const SfxItemSet& rAttrs ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir return new SchAxisLabelTabPage( pParent, rAttrs ); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir sal_Bool SchAxisLabelTabPage::FillItemSet( SfxItemSet& rOutAttrs ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir bool bStacked = false; 110cdf0e10cSrcweir if( aOrientHlp.GetStackedState() != STATE_DONTKNOW ) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir bStacked = aOrientHlp.GetStackedState() == STATE_CHECK; 113cdf0e10cSrcweir if( !m_bHasInitialStacking || (bStacked != m_bInitialStacking) ) 114cdf0e10cSrcweir rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXT_STACKED, bStacked ) ); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir if( aCtrlDial.HasRotation() ) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir sal_Int32 nDegrees = bStacked ? 0 : aCtrlDial.GetRotation(); 120cdf0e10cSrcweir if( !m_bHasInitialDegrees || (nDegrees != m_nInitialDegrees) ) 121cdf0e10cSrcweir rOutAttrs.Put( SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) ); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir if( m_bShowStaggeringControls ) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir SvxChartTextOrder eOrder = CHTXTORDER_SIDEBYSIDE; 127cdf0e10cSrcweir bool bRadioButtonChecked = true; 128cdf0e10cSrcweir 129cdf0e10cSrcweir if( aRbUpDown.IsChecked()) 130cdf0e10cSrcweir eOrder = CHTXTORDER_UPDOWN; 131cdf0e10cSrcweir else if( aRbDownUp.IsChecked()) 132cdf0e10cSrcweir eOrder = CHTXTORDER_DOWNUP; 133cdf0e10cSrcweir else if( aRbAuto.IsChecked()) 134cdf0e10cSrcweir eOrder = CHTXTORDER_AUTO; 135cdf0e10cSrcweir else if( aRbSideBySide.IsChecked()) 136cdf0e10cSrcweir eOrder = CHTXTORDER_SIDEBYSIDE; 137cdf0e10cSrcweir else 138cdf0e10cSrcweir bRadioButtonChecked = false; 139cdf0e10cSrcweir 140cdf0e10cSrcweir if( bRadioButtonChecked ) 141cdf0e10cSrcweir rOutAttrs.Put( SvxChartTextOrderItem( eOrder, SCHATTR_AXIS_LABEL_ORDER )); 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir if( aCbTextOverlap.GetState() != STATE_DONTKNOW ) 145cdf0e10cSrcweir rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_LABEL_OVERLAP, aCbTextOverlap.IsChecked() ) ); 146cdf0e10cSrcweir if( aCbTextBreak.GetState() != STATE_DONTKNOW ) 147cdf0e10cSrcweir rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_LABEL_BREAK, aCbTextBreak.IsChecked() ) ); 148cdf0e10cSrcweir if( aCbShowDescription.GetState() != STATE_DONTKNOW ) 149cdf0e10cSrcweir rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR, aCbShowDescription.IsChecked() ) ); 150cdf0e10cSrcweir 151cdf0e10cSrcweir if( m_aLbTextDirection.GetSelectEntryCount() > 0 ) 152cdf0e10cSrcweir rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, m_aLbTextDirection.GetSelectEntryValue() ) ); 153cdf0e10cSrcweir 154cdf0e10cSrcweir return sal_True; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir const SfxPoolItem* pPoolItem = NULL; 160cdf0e10cSrcweir SfxItemState aState = SFX_ITEM_UNKNOWN; 161cdf0e10cSrcweir 162cdf0e10cSrcweir // show description ---------- 163cdf0e10cSrcweir aState = rInAttrs.GetItemState( SCHATTR_AXIS_SHOWDESCR, sal_False, &pPoolItem ); 164cdf0e10cSrcweir if( aState == SFX_ITEM_DONTCARE ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir aCbShowDescription.EnableTriState( sal_True ); 167cdf0e10cSrcweir aCbShowDescription.SetState( STATE_DONTKNOW ); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir else 170cdf0e10cSrcweir { 171cdf0e10cSrcweir aCbShowDescription.EnableTriState( sal_False ); 172cdf0e10cSrcweir sal_Bool bCheck = sal_False; 173cdf0e10cSrcweir if( aState == SFX_ITEM_SET ) 174cdf0e10cSrcweir bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); 175cdf0e10cSrcweir aCbShowDescription.Check( bCheck ); 176cdf0e10cSrcweir 177cdf0e10cSrcweir if( ( aState & SFX_ITEM_DEFAULT ) == 0 ) 178cdf0e10cSrcweir aCbShowDescription.Hide(); 179cdf0e10cSrcweir } 180cdf0e10cSrcweir 181cdf0e10cSrcweir // Rotation as orient item or in degrees ---------- 182cdf0e10cSrcweir 183cdf0e10cSrcweir // check new degree item 184cdf0e10cSrcweir m_nInitialDegrees = 0; 185cdf0e10cSrcweir aState = rInAttrs.GetItemState( SCHATTR_TEXT_DEGREES, sal_False, &pPoolItem ); 186cdf0e10cSrcweir if( aState == SFX_ITEM_SET ) 187cdf0e10cSrcweir m_nInitialDegrees = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); 188cdf0e10cSrcweir 189cdf0e10cSrcweir m_bHasInitialDegrees = aState != SFX_ITEM_DONTCARE; 190cdf0e10cSrcweir if( m_bHasInitialDegrees ) 191cdf0e10cSrcweir aCtrlDial.SetRotation( m_nInitialDegrees ); 192cdf0e10cSrcweir else 193cdf0e10cSrcweir aCtrlDial.SetNoRotation(); 194cdf0e10cSrcweir 195cdf0e10cSrcweir // check stacked item 196cdf0e10cSrcweir m_bInitialStacking = false; 197cdf0e10cSrcweir aState = rInAttrs.GetItemState( SCHATTR_TEXT_STACKED, sal_False, &pPoolItem ); 198cdf0e10cSrcweir if( aState == SFX_ITEM_SET ) 199cdf0e10cSrcweir m_bInitialStacking = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); 200cdf0e10cSrcweir 201cdf0e10cSrcweir m_bHasInitialStacking = aState != SFX_ITEM_DONTCARE; 202cdf0e10cSrcweir if( m_bHasInitialDegrees ) 203cdf0e10cSrcweir aOrientHlp.SetStackedState( m_bInitialStacking ? STATE_CHECK : STATE_NOCHECK ); 204cdf0e10cSrcweir else 205cdf0e10cSrcweir aOrientHlp.SetStackedState( STATE_DONTKNOW ); 206cdf0e10cSrcweir 207cdf0e10cSrcweir if( rInAttrs.GetItemState( EE_PARA_WRITINGDIR, sal_True, &pPoolItem ) == SFX_ITEM_SET ) 208cdf0e10cSrcweir m_aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) ); 209cdf0e10cSrcweir 210cdf0e10cSrcweir // Text overlap ---------- 211cdf0e10cSrcweir aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_OVERLAP, sal_False, &pPoolItem ); 212cdf0e10cSrcweir if( aState == SFX_ITEM_DONTCARE ) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir aCbTextOverlap.EnableTriState( sal_True ); 215cdf0e10cSrcweir aCbTextOverlap.SetState( STATE_DONTKNOW ); 216cdf0e10cSrcweir } 217cdf0e10cSrcweir else 218cdf0e10cSrcweir { 219cdf0e10cSrcweir aCbTextOverlap.EnableTriState( sal_False ); 220cdf0e10cSrcweir sal_Bool bCheck = sal_False; 221cdf0e10cSrcweir if( aState == SFX_ITEM_SET ) 222cdf0e10cSrcweir bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); 223cdf0e10cSrcweir aCbTextOverlap.Check( bCheck ); 224cdf0e10cSrcweir 225cdf0e10cSrcweir if( ( aState & SFX_ITEM_DEFAULT ) == 0 ) 226cdf0e10cSrcweir aCbTextOverlap.Hide(); 227cdf0e10cSrcweir } 228cdf0e10cSrcweir 229cdf0e10cSrcweir // text break ---------- 230cdf0e10cSrcweir aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_BREAK, sal_False, &pPoolItem ); 231cdf0e10cSrcweir if( aState == SFX_ITEM_DONTCARE ) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir aCbTextBreak.EnableTriState( sal_True ); 234cdf0e10cSrcweir aCbTextBreak.SetState( STATE_DONTKNOW ); 235cdf0e10cSrcweir } 236cdf0e10cSrcweir else 237cdf0e10cSrcweir { 238cdf0e10cSrcweir aCbTextBreak.EnableTriState( sal_False ); 239cdf0e10cSrcweir sal_Bool bCheck = sal_False; 240cdf0e10cSrcweir if( aState == SFX_ITEM_SET ) 241cdf0e10cSrcweir bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); 242cdf0e10cSrcweir aCbTextBreak.Check( bCheck ); 243cdf0e10cSrcweir 244cdf0e10cSrcweir if( ( aState & SFX_ITEM_DEFAULT ) == 0 ) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir aCbTextBreak.Hide(); 247cdf0e10cSrcweir if( ! aCbTextOverlap.IsVisible() ) 248cdf0e10cSrcweir aFlTextFlow.Hide(); 249cdf0e10cSrcweir } 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir // text order ---------- 253cdf0e10cSrcweir if( m_bShowStaggeringControls ) 254cdf0e10cSrcweir { 255cdf0e10cSrcweir aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_ORDER, sal_False, &pPoolItem ); 256cdf0e10cSrcweir if( aState == SFX_ITEM_SET ) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir SvxChartTextOrder eOrder = static_cast< const SvxChartTextOrderItem * >( pPoolItem )->GetValue(); 259cdf0e10cSrcweir 260cdf0e10cSrcweir switch( eOrder ) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir case CHTXTORDER_SIDEBYSIDE: 263cdf0e10cSrcweir aRbSideBySide.Check(); 264cdf0e10cSrcweir break; 265cdf0e10cSrcweir case CHTXTORDER_UPDOWN: 266cdf0e10cSrcweir aRbUpDown.Check(); 267cdf0e10cSrcweir break; 268cdf0e10cSrcweir case CHTXTORDER_DOWNUP: 269cdf0e10cSrcweir aRbDownUp.Check(); 270cdf0e10cSrcweir break; 271cdf0e10cSrcweir case CHTXTORDER_AUTO: 272cdf0e10cSrcweir aRbAuto.Check(); 273cdf0e10cSrcweir break; 274cdf0e10cSrcweir } 275cdf0e10cSrcweir } 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir ToggleShowLabel( (void*)0 ); 279cdf0e10cSrcweir } 280cdf0e10cSrcweir 281cdf0e10cSrcweir void SchAxisLabelTabPage::ShowStaggeringControls( sal_Bool bShowStaggeringControls ) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir m_bShowStaggeringControls = bShowStaggeringControls; 284cdf0e10cSrcweir 285cdf0e10cSrcweir if( !m_bShowStaggeringControls ) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir aRbSideBySide.Hide(); 288cdf0e10cSrcweir aRbUpDown.Hide(); 289cdf0e10cSrcweir aRbDownUp.Hide(); 290cdf0e10cSrcweir aRbAuto.Hide(); 291cdf0e10cSrcweir aFlOrder.Hide(); 292cdf0e10cSrcweir } 293cdf0e10cSrcweir } 294cdf0e10cSrcweir 295cdf0e10cSrcweir void SchAxisLabelTabPage::SetComplexCategories( bool bComplexCategories ) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir m_bComplexCategories = bComplexCategories; 298cdf0e10cSrcweir } 299cdf0e10cSrcweir 300cdf0e10cSrcweir // event handling routines 301cdf0e10cSrcweir // ----------------------- 302cdf0e10cSrcweir 303cdf0e10cSrcweir IMPL_LINK ( SchAxisLabelTabPage, ToggleShowLabel, void *, EMPTYARG ) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir sal_Bool bEnable = ( aCbShowDescription.GetState() != STATE_NOCHECK ); 306cdf0e10cSrcweir 307cdf0e10cSrcweir aOrientHlp.Enable( bEnable ); 308cdf0e10cSrcweir aFlOrder.Enable( bEnable ); 309cdf0e10cSrcweir aRbSideBySide.Enable( bEnable ); 310cdf0e10cSrcweir aRbUpDown.Enable( bEnable ); 311cdf0e10cSrcweir aRbDownUp.Enable( bEnable ); 312cdf0e10cSrcweir aRbAuto.Enable( bEnable ); 313cdf0e10cSrcweir 314cdf0e10cSrcweir aFlTextFlow.Enable( bEnable ); 315cdf0e10cSrcweir aCbTextOverlap.Enable( bEnable && !m_bComplexCategories ); 316cdf0e10cSrcweir aCbTextBreak.Enable( bEnable ); 317cdf0e10cSrcweir 318cdf0e10cSrcweir m_aFtTextDirection.Enable( bEnable ); 319cdf0e10cSrcweir m_aLbTextDirection.Enable( bEnable ); 320cdf0e10cSrcweir 321cdf0e10cSrcweir return 0L; 322cdf0e10cSrcweir } 323cdf0e10cSrcweir //............................................................................. 324cdf0e10cSrcweir } //namespace chart 325cdf0e10cSrcweir //............................................................................. 326