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