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

Generated by: LCOV version 1.11