LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/controller/dialogs - tp_AxisLabel.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 146 0.7 %
Date: 2012-12-27 Functions: 2 13 15.4 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10