LCOV - code coverage report
Current view: top level - svx/source/dialog - orienthelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 73 0.0 %
Date: 2012-08-25 Functions: 0 22 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 63 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "svx/orienthelper.hxx"
      30                 :            : 
      31                 :            : #include <vector>
      32                 :            : #include <utility>
      33                 :            : 
      34                 :            : #include <vcl/button.hxx>
      35                 :            : #include "svx/dialcontrol.hxx"
      36                 :            : 
      37                 :            : namespace svx {
      38                 :            : 
      39                 :            : // ============================================================================
      40                 :            : 
      41                 :          0 : struct OrientationHelper_Impl
      42                 :            : {
      43                 :            :     typedef std::pair< Window*, TriState >  WindowPair;
      44                 :            :     typedef std::vector< WindowPair >       WindowVec;
      45                 :            : 
      46                 :            :     DialControl&        mrCtrlDial;
      47                 :            :     CheckBox&           mrCbStacked;
      48                 :            :     WindowVec           maWinVec;
      49                 :            :     bool                mbEnabled;
      50                 :            :     bool                mbVisible;
      51                 :            : 
      52                 :            :     explicit            OrientationHelper_Impl( DialControl& rCtrlDial, CheckBox& rCbStacked );
      53                 :            : 
      54                 :            :     void                AddDependentWindow( Window& rWindow, TriState eDisableIfStacked );
      55                 :            : 
      56                 :            :     void                EnableDependentWindows();
      57                 :            :     void                EnableWindow( Window& rWindow, TriState eDisableIfStacked );
      58                 :            : 
      59                 :            :     void                ShowDependentWindows();
      60                 :            : 
      61                 :            :     DECL_LINK( ClickHdl, void* );
      62                 :            : };
      63                 :            : 
      64                 :            : // ----------------------------------------------------------------------------
      65                 :            : 
      66                 :          0 : OrientationHelper_Impl::OrientationHelper_Impl( DialControl& rCtrlDial, CheckBox& rCbStacked ) :
      67                 :            :     mrCtrlDial( rCtrlDial ),
      68                 :            :     mrCbStacked( rCbStacked ),
      69         [ #  # ]:          0 :     mbEnabled( rCtrlDial.IsEnabled() ),
      70         [ #  # ]:          0 :     mbVisible( rCtrlDial.IsVisible() )
      71                 :            : {
      72 [ #  # ][ #  # ]:          0 :     maWinVec.push_back( WindowPair( &mrCtrlDial, STATE_CHECK ) );
      73 [ #  # ][ #  # ]:          0 :     maWinVec.push_back( WindowPair( &mrCbStacked, STATE_DONTKNOW ) );
      74         [ #  # ]:          0 :     mrCbStacked.SetClickHdl( LINK( this, OrientationHelper_Impl, ClickHdl ) );
      75                 :          0 : }
      76                 :            : 
      77                 :          0 : void OrientationHelper_Impl::AddDependentWindow( Window& rWindow, TriState eDisableIfStacked )
      78                 :            : {
      79 [ #  # ][ #  # ]:          0 :     maWinVec.push_back( std::make_pair( &rWindow, eDisableIfStacked ) );
      80                 :          0 :     EnableWindow( rWindow, eDisableIfStacked );
      81                 :          0 : }
      82                 :            : 
      83                 :          0 : void OrientationHelper_Impl::EnableDependentWindows()
      84                 :            : {
      85 [ #  # ][ #  # ]:          0 :     for( WindowVec::iterator aIt = maWinVec.begin(), aEnd = maWinVec.end(); aIt != aEnd; ++aIt )
                 [ #  # ]
      86 [ #  # ][ #  # ]:          0 :         EnableWindow( *aIt->first, aIt->second );
                 [ #  # ]
      87                 :          0 : }
      88                 :            : 
      89                 :          0 : void OrientationHelper_Impl::EnableWindow( Window& rWindow, TriState eDisableIfStacked )
      90                 :            : {
      91                 :          0 :     bool bDisableOnStacked = false;
      92      [ #  #  # ]:          0 :     switch( eDisableIfStacked )
      93                 :            :     {
      94                 :            :         // STATE_CHECK: Disable window, if stacked text is turned on or "don't know".
      95                 :          0 :         case STATE_CHECK:   bDisableOnStacked = (mrCbStacked.GetState() != STATE_NOCHECK);  break;
      96                 :            :         // STATE_NOCHECK: Disable window, if stacked text is turned off or "don't know".
      97                 :          0 :         case STATE_NOCHECK: bDisableOnStacked = (mrCbStacked.GetState() != STATE_CHECK);    break;
      98                 :            :         default: ;//prevent warning
      99                 :            :     }
     100 [ #  # ][ #  # ]:          0 :     rWindow.Enable( mbEnabled && !bDisableOnStacked );
     101                 :          0 : }
     102                 :            : 
     103                 :          0 : void OrientationHelper_Impl::ShowDependentWindows()
     104                 :            : {
     105 [ #  # ][ #  # ]:          0 :     for( WindowVec::iterator aIt = maWinVec.begin(), aEnd = maWinVec.end(); aIt != aEnd; ++aIt )
                 [ #  # ]
     106 [ #  # ][ #  # ]:          0 :         aIt->first->Show( mbVisible );
     107                 :          0 : }
     108                 :            : 
     109                 :          0 : IMPL_LINK_NOARG(OrientationHelper_Impl, ClickHdl)
     110                 :            : {
     111                 :          0 :     EnableDependentWindows();
     112                 :          0 :     return 0L;
     113                 :            : }
     114                 :            : 
     115                 :            : // ============================================================================
     116                 :            : 
     117                 :          0 : OrientationHelper::OrientationHelper( DialControl& rCtrlDial, NumericField& rNfRotation, CheckBox& rCbStacked ) :
     118         [ #  # ]:          0 :     mpImpl( new OrientationHelper_Impl( rCtrlDial, rCbStacked ) )
     119                 :            : {
     120         [ #  # ]:          0 :     rCtrlDial.SetLinkedField( &rNfRotation );
     121         [ #  # ]:          0 :     mpImpl->EnableDependentWindows();
     122         [ #  # ]:          0 :     mpImpl->ShowDependentWindows();
     123                 :          0 : }
     124                 :            : 
     125                 :          0 : OrientationHelper::~OrientationHelper()
     126                 :            : {
     127         [ #  # ]:          0 : }
     128                 :            : 
     129                 :          0 : void OrientationHelper::AddDependentWindow( Window& rWindow, TriState eDisableIfStacked )
     130                 :            : {
     131                 :          0 :     mpImpl->AddDependentWindow( rWindow, eDisableIfStacked );
     132                 :          0 : }
     133                 :            : 
     134                 :          0 : void OrientationHelper::Enable( bool bEnable )
     135                 :            : {
     136                 :          0 :     mpImpl->mbEnabled = bEnable;
     137                 :          0 :     mpImpl->EnableDependentWindows();
     138                 :          0 : }
     139                 :            : 
     140                 :          0 : void OrientationHelper::Show( bool bShow )
     141                 :            : {
     142                 :          0 :     mpImpl->mbVisible = bShow;
     143                 :          0 :     mpImpl->ShowDependentWindows();
     144                 :          0 : }
     145                 :            : 
     146                 :          0 : void OrientationHelper::SetStackedState( TriState eState )
     147                 :            : {
     148         [ #  # ]:          0 :     if( eState != GetStackedState() )
     149                 :            :     {
     150                 :          0 :         mpImpl->mrCbStacked.SetState( eState );
     151                 :          0 :         mpImpl->EnableDependentWindows();
     152                 :            :     }
     153                 :          0 : }
     154                 :            : 
     155                 :          0 : TriState OrientationHelper::GetStackedState() const
     156                 :            : {
     157                 :          0 :     return mpImpl->mrCbStacked.GetState();
     158                 :            : }
     159                 :            : 
     160                 :          0 : void OrientationHelper::EnableStackedTriState( bool bEnable )
     161                 :            : {
     162                 :          0 :     mpImpl->mrCbStacked.EnableTriState( bEnable );
     163                 :          0 : }
     164                 :            : 
     165                 :            : // ============================================================================
     166                 :            : 
     167                 :          0 : OrientStackedWrapper::OrientStackedWrapper( OrientationHelper& rOrientHlp ) :
     168                 :          0 :     SingleControlWrapperType( rOrientHlp )
     169                 :            : {
     170                 :          0 : }
     171                 :            : 
     172                 :          0 : bool OrientStackedWrapper::IsControlDontKnow() const
     173                 :            : {
     174                 :          0 :     return GetControl().GetStackedState() == STATE_DONTKNOW;
     175                 :            : }
     176                 :            : 
     177                 :          0 : void OrientStackedWrapper::SetControlDontKnow( bool bSet )
     178                 :            : {
     179                 :          0 :     GetControl().EnableStackedTriState( bSet );
     180         [ #  # ]:          0 :     GetControl().SetStackedState( bSet ? STATE_DONTKNOW : STATE_NOCHECK );
     181                 :          0 : }
     182                 :            : 
     183                 :          0 : bool OrientStackedWrapper::GetControlValue() const
     184                 :            : {
     185                 :          0 :     return GetControl().GetStackedState() == STATE_CHECK;
     186                 :            : }
     187                 :            : 
     188                 :          0 : void OrientStackedWrapper::SetControlValue( bool bValue )
     189                 :            : {
     190         [ #  # ]:          0 :     GetControl().SetStackedState( bValue ? STATE_CHECK : STATE_NOCHECK );
     191                 :          0 : }
     192                 :            : 
     193                 :            : // ============================================================================
     194                 :            : 
     195                 :            : } // namespace svx
     196                 :            : 
     197                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10