LCOV - code coverage report
Current view: top level - chart2/source/controller/dialogs - tp_AxisLabel.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1 164 0.6 %
Date: 2014-04-11 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             : 
      26             : // header for SvxChartTextOrientItem / SvxChartTextOrderItem
      27             : #include <svx/chrtitem.hxx>
      28             : 
      29             : // header for SfxInt32Item
      30             : #include <svl/intitem.hxx>
      31             : #include <editeng/eeitem.hxx>
      32             : #include <editeng/frmdiritem.hxx>
      33             : 
      34             : namespace chart
      35             : {
      36             : 
      37           0 : SchAxisLabelTabPage::SchAxisLabelTabPage( Window* pParent, const SfxItemSet& rInAttrs ) :
      38             :         SfxTabPage( pParent, "AxisLabelTabPage","modules/schart/ui/tp_axisLabel.ui", rInAttrs ),
      39             : 
      40             :         m_bShowStaggeringControls( true ),
      41             : 
      42             :         m_nInitialDegrees( 0 ),
      43             :         m_bHasInitialDegrees( true ),
      44             :         m_bInitialStacking( false ),
      45             :         m_bHasInitialStacking( true ),
      46           0 :         m_bComplexCategories( false )
      47             : {
      48           0 :     get(m_pCbShowDescription, "showlabelsCB");
      49           0 :     get(m_pFlOrder, "orderL");
      50           0 :     get(m_pRbSideBySide, "tile");
      51           0 :     get(m_pRbUpDown, "odd");
      52           0 :     get(m_pRbDownUp, "even");
      53           0 :     get(m_pRbAuto, "auto");
      54           0 :     get(m_pFlTextFlow, "textflowL");
      55           0 :     get(m_pCbTextOverlap, "overlapCB");
      56           0 :     get(m_pCbTextBreak, "breakCB");
      57           0 :     get(m_pFlOrient, "labelTextOrient");
      58           0 :     get(m_pCtrlDial,"dialCtrl");
      59           0 :     get(m_pFtRotate,"degreeL");
      60           0 :     get(m_pNfRotate,"OrientDegree");
      61           0 :     get(m_pCbStacked,"stackedCB");
      62           0 :     get(m_pFtTextDirection,"textdirL");
      63           0 :     get(m_pLbTextDirection,"textdirLB");
      64           0 :     get(m_pFtABCD,"labelABCD");
      65           0 :     m_pCtrlDial->SetText(m_pFtABCD->GetText());
      66           0 :     m_pOrientHlp = new svx::OrientationHelper(*m_pCtrlDial, *m_pNfRotate, *m_pCbStacked);
      67           0 :     m_pOrientHlp->Enable( true );
      68             : 
      69             : 
      70           0 :     m_pCbStacked->EnableTriState( false );
      71           0 :     m_pOrientHlp->AddDependentWindow( *m_pFlOrient );
      72           0 :     m_pOrientHlp->AddDependentWindow( *m_pFtRotate, TRISTATE_TRUE );
      73             : 
      74           0 :     m_pCbShowDescription->SetClickHdl( LINK( this, SchAxisLabelTabPage, ToggleShowLabel ) );
      75             : 
      76           0 :     Construct();
      77           0 : }
      78             : 
      79           0 : SchAxisLabelTabPage::~SchAxisLabelTabPage()
      80           0 : {delete m_pOrientHlp;}
      81             : 
      82           0 : void SchAxisLabelTabPage::Construct()
      83             : {
      84           0 : }
      85             : 
      86           0 : SfxTabPage* SchAxisLabelTabPage::Create( Window* pParent, const SfxItemSet& rAttrs )
      87             : {
      88           0 :     return new SchAxisLabelTabPage( pParent, rAttrs );
      89             : }
      90             : 
      91           0 : bool SchAxisLabelTabPage::FillItemSet( SfxItemSet& rOutAttrs )
      92             : {
      93           0 :     bool bStacked = false;
      94           0 :     if( m_pOrientHlp->GetStackedState() != TRISTATE_INDET )
      95             :     {
      96           0 :         bStacked = m_pOrientHlp->GetStackedState() == TRISTATE_TRUE;
      97           0 :         if( !m_bHasInitialStacking || (bStacked != m_bInitialStacking) )
      98           0 :             rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXT_STACKED, bStacked ) );
      99             :     }
     100             : 
     101           0 :     if( m_pCtrlDial->HasRotation() )
     102             :     {
     103           0 :         sal_Int32 nDegrees = bStacked ? 0 : m_pCtrlDial->GetRotation();
     104           0 :         if( !m_bHasInitialDegrees || (nDegrees != m_nInitialDegrees) )
     105           0 :             rOutAttrs.Put( SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) );
     106             :     }
     107             : 
     108           0 :     if( m_bShowStaggeringControls )
     109             :     {
     110           0 :         SvxChartTextOrder eOrder = CHTXTORDER_SIDEBYSIDE;
     111           0 :         bool bRadioButtonChecked = true;
     112             : 
     113           0 :         if( m_pRbUpDown->IsChecked())
     114           0 :             eOrder = CHTXTORDER_UPDOWN;
     115           0 :         else if( m_pRbDownUp->IsChecked())
     116           0 :             eOrder = CHTXTORDER_DOWNUP;
     117           0 :         else if( m_pRbAuto->IsChecked())
     118           0 :             eOrder = CHTXTORDER_AUTO;
     119           0 :         else if( m_pRbSideBySide->IsChecked())
     120           0 :             eOrder = CHTXTORDER_SIDEBYSIDE;
     121             :         else
     122           0 :             bRadioButtonChecked = false;
     123             : 
     124           0 :         if( bRadioButtonChecked )
     125           0 :             rOutAttrs.Put( SvxChartTextOrderItem( eOrder, SCHATTR_AXIS_LABEL_ORDER ));
     126             :     }
     127             : 
     128           0 :     if( m_pCbTextOverlap->GetState() != TRISTATE_INDET )
     129           0 :         rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_LABEL_OVERLAP, m_pCbTextOverlap->IsChecked() ) );
     130           0 :     if( m_pCbTextBreak->GetState() != TRISTATE_INDET )
     131           0 :         rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_LABEL_BREAK, m_pCbTextBreak->IsChecked() ) );
     132           0 :     if( m_pCbShowDescription->GetState() != TRISTATE_INDET )
     133           0 :         rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR, m_pCbShowDescription->IsChecked() ) );
     134             : 
     135           0 :     if( m_pLbTextDirection->GetSelectEntryCount() > 0 )
     136           0 :         rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, m_pLbTextDirection->GetSelectEntryValue() ) );
     137             : 
     138           0 :     return true;
     139             : }
     140             : 
     141           0 : void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs )
     142             : {
     143           0 :    const SfxPoolItem* pPoolItem = NULL;
     144             : 
     145             :     // show description
     146           0 :     SfxItemState aState = rInAttrs.GetItemState( SCHATTR_AXIS_SHOWDESCR, false, &pPoolItem );
     147           0 :     if( aState == SFX_ITEM_DONTCARE )
     148             :     {
     149           0 :         m_pCbShowDescription->EnableTriState( true );
     150           0 :         m_pCbShowDescription->SetState( TRISTATE_INDET );
     151             :     }
     152             :     else
     153             :     {
     154           0 :         m_pCbShowDescription->EnableTriState( false );
     155           0 :         sal_Bool bCheck = sal_False;
     156           0 :         if( aState == SFX_ITEM_SET )
     157           0 :             bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
     158           0 :         m_pCbShowDescription->Check( bCheck );
     159             : 
     160           0 :         if( ( aState & SFX_ITEM_DEFAULT ) == 0 )
     161           0 :             m_pCbShowDescription->Hide();
     162             :     }
     163             : 
     164             :     // Rotation as orient item or in degrees ----------
     165             : 
     166             :     // check new degree item
     167           0 :     m_nInitialDegrees = 0;
     168           0 :     aState = rInAttrs.GetItemState( SCHATTR_TEXT_DEGREES, false, &pPoolItem );
     169           0 :     if( aState == SFX_ITEM_SET )
     170           0 :         m_nInitialDegrees = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
     171             : 
     172           0 :     m_bHasInitialDegrees = aState != SFX_ITEM_DONTCARE;
     173           0 :     if( m_bHasInitialDegrees )
     174           0 :         m_pCtrlDial->SetRotation( m_nInitialDegrees );
     175             :     else
     176           0 :         m_pCtrlDial->SetNoRotation();
     177             : 
     178             :     // check stacked item
     179           0 :     m_bInitialStacking = false;
     180           0 :     aState = rInAttrs.GetItemState( SCHATTR_TEXT_STACKED, false, &pPoolItem );
     181           0 :     if( aState == SFX_ITEM_SET )
     182           0 :         m_bInitialStacking = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
     183             : 
     184           0 :     m_bHasInitialStacking = aState != SFX_ITEM_DONTCARE;
     185           0 :     if( m_bHasInitialDegrees )
     186           0 :         m_pOrientHlp->SetStackedState( m_bInitialStacking ? TRISTATE_TRUE : TRISTATE_FALSE );
     187             :     else
     188           0 :         m_pOrientHlp->SetStackedState( TRISTATE_INDET );
     189             : 
     190           0 :     if( rInAttrs.GetItemState( EE_PARA_WRITINGDIR, true, &pPoolItem ) == SFX_ITEM_SET )
     191           0 :         m_pLbTextDirection->SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) );
     192             : 
     193             :     // Text overlap ----------
     194           0 :     aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_OVERLAP, false, &pPoolItem );
     195           0 :     if( aState == SFX_ITEM_DONTCARE )
     196             :     {
     197           0 :         m_pCbTextOverlap->EnableTriState( true );
     198           0 :         m_pCbTextOverlap->SetState( TRISTATE_INDET );
     199             :     }
     200             :     else
     201             :     {
     202           0 :         m_pCbTextOverlap->EnableTriState( false );
     203           0 :         sal_Bool bCheck = sal_False;
     204           0 :         if( aState == SFX_ITEM_SET )
     205           0 :             bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
     206           0 :         m_pCbTextOverlap->Check( bCheck );
     207             : 
     208           0 :         if( ( aState & SFX_ITEM_DEFAULT ) == 0 )
     209           0 :             m_pCbTextOverlap->Hide();
     210             :     }
     211             : 
     212             :     // text break ----------
     213           0 :     aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_BREAK, false, &pPoolItem );
     214           0 :     if( aState == SFX_ITEM_DONTCARE )
     215             :     {
     216           0 :         m_pCbTextBreak->EnableTriState( true );
     217           0 :         m_pCbTextBreak->SetState( TRISTATE_INDET );
     218             :     }
     219             :     else
     220             :     {
     221           0 :         m_pCbTextBreak->EnableTriState( false );
     222           0 :         sal_Bool bCheck = sal_False;
     223           0 :         if( aState == SFX_ITEM_SET )
     224           0 :             bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
     225           0 :         m_pCbTextBreak->Check( bCheck );
     226             : 
     227           0 :         if( ( aState & SFX_ITEM_DEFAULT ) == 0 )
     228             :         {
     229           0 :             m_pCbTextBreak->Hide();
     230           0 :             if( ! m_pCbTextOverlap->IsVisible() )
     231           0 :                 m_pFlTextFlow->Hide();
     232             :         }
     233             :     }
     234             : 
     235             :     // text order ----------
     236           0 :     if( m_bShowStaggeringControls )
     237             :     {
     238           0 :         aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_ORDER, false, &pPoolItem );
     239           0 :         if( aState == SFX_ITEM_SET )
     240             :         {
     241           0 :             SvxChartTextOrder eOrder = static_cast< const SvxChartTextOrderItem * >( pPoolItem )->GetValue();
     242             : 
     243           0 :             switch( eOrder )
     244             :             {
     245             :                 case CHTXTORDER_SIDEBYSIDE:
     246           0 :                     m_pRbSideBySide->Check();
     247           0 :                     break;
     248             :                 case CHTXTORDER_UPDOWN:
     249           0 :                     m_pRbUpDown->Check();
     250           0 :                     break;
     251             :                 case CHTXTORDER_DOWNUP:
     252           0 :                     m_pRbDownUp->Check();
     253           0 :                     break;
     254             :                 case CHTXTORDER_AUTO:
     255           0 :                     m_pRbAuto->Check();
     256           0 :                     break;
     257             :             }
     258             :         }
     259             :     }
     260             : 
     261           0 :     ToggleShowLabel( (void*)0 );
     262           0 : }
     263             : 
     264           0 : void SchAxisLabelTabPage::ShowStaggeringControls( sal_Bool bShowStaggeringControls )
     265             : {
     266           0 :     m_bShowStaggeringControls = bShowStaggeringControls;
     267             : 
     268           0 :     if( !m_bShowStaggeringControls )
     269             :     {
     270           0 :         m_pRbSideBySide->Hide();
     271           0 :         m_pRbUpDown->Hide();
     272           0 :         m_pRbDownUp->Hide();
     273           0 :         m_pRbAuto->Hide();
     274           0 :         m_pFlOrder->Hide();
     275             :     }
     276           0 : }
     277             : 
     278           0 : void SchAxisLabelTabPage::SetComplexCategories( bool bComplexCategories )
     279             : {
     280           0 :     m_bComplexCategories = bComplexCategories;
     281           0 : }
     282             : 
     283             : // event handling routines
     284             : 
     285           0 : IMPL_LINK_NOARG(SchAxisLabelTabPage, ToggleShowLabel)
     286             : {
     287           0 :     sal_Bool bEnable = ( m_pCbShowDescription->GetState() != TRISTATE_FALSE );
     288             : 
     289           0 :     m_pOrientHlp->Enable( bEnable );
     290           0 :     m_pFlOrder->Enable( bEnable );
     291           0 :     m_pRbSideBySide->Enable( bEnable );
     292           0 :     m_pRbUpDown->Enable( bEnable );
     293           0 :     m_pRbDownUp->Enable( bEnable );
     294           0 :     m_pRbAuto->Enable( bEnable );
     295             : 
     296           0 :     m_pFlTextFlow->Enable( bEnable );
     297           0 :     m_pCbTextOverlap->Enable( bEnable && !m_bComplexCategories );
     298           0 :     m_pCbTextBreak->Enable( bEnable );
     299             : 
     300           0 :     m_pFtTextDirection->Enable( bEnable );
     301           0 :     m_pLbTextDirection->Enable( bEnable );
     302             : 
     303           0 :     return 0L;
     304             : }
     305          45 : } //namespace chart
     306             : 
     307             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10