LCOV - code coverage report
Current view: top level - svtools/source/misc - dialogcontrolling.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 94 0.0 %
Date: 2012-08-25 Functions: 0 28 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 142 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 <svtools/dialogcontrolling.hxx>
      30                 :            : #include <vcl/window.hxx>
      31                 :            : 
      32                 :            : #include <algorithm>
      33                 :            : #include <functional>
      34                 :            : 
      35                 :            : //........................................................................
      36                 :            : namespace svt
      37                 :            : {
      38                 :            : //........................................................................
      39                 :            : 
      40                 :            :     //=====================================================================
      41                 :            :     //= IWindowOperator
      42                 :            :     //=====================================================================
      43                 :            :     //---------------------------------------------------------------------
      44                 :          0 :     IWindowOperator::~IWindowOperator()
      45                 :            :     {
      46         [ #  # ]:          0 :     }
      47                 :            : 
      48                 :            :     //=====================================================================
      49                 :            :     //= IWindowEventFilter
      50                 :            :     //=====================================================================
      51                 :            :     //---------------------------------------------------------------------
      52                 :          0 :     IWindowEventFilter::~IWindowEventFilter()
      53                 :            :     {
      54         [ #  # ]:          0 :     }
      55                 :            : 
      56                 :            :     //=====================================================================
      57                 :            :     //= DialogController_Data
      58                 :            :     //=====================================================================
      59 [ #  # ][ #  # ]:          0 :     struct DialogController_Data
      60                 :            :     {
      61                 :            :         Window&                     rInstigator;
      62                 :            :         ::std::vector< Window* >    aConcernedWindows;
      63                 :            :         PWindowEventFilter          pEventFilter;
      64                 :            :         PWindowOperator             pOperator;
      65                 :            : 
      66                 :          0 :         DialogController_Data( Window& _rInstigator, const PWindowEventFilter _pEventFilter, const PWindowOperator _pOperator )
      67                 :            :             :rInstigator( _rInstigator )
      68                 :            :             ,pEventFilter( _pEventFilter )
      69 [ #  # ][ #  # ]:          0 :             ,pOperator( _pOperator )
      70                 :            :         {
      71                 :          0 :         }
      72                 :            :     };
      73                 :            : 
      74                 :            :     //=====================================================================
      75                 :            :     //= DialogController
      76                 :            :     //=====================================================================
      77                 :            :     //---------------------------------------------------------------------
      78                 :          0 :     DialogController::DialogController( Window& _rInstigator, const PWindowEventFilter& _pEventFilter,
      79                 :            :             const PWindowOperator& _pOperator )
      80 [ #  # ][ #  # ]:          0 :         :m_pImpl( new DialogController_Data( _rInstigator, _pEventFilter, _pOperator ) )
         [ #  # ][ #  # ]
      81                 :            :     {
      82                 :            :         DBG_ASSERT( m_pImpl->pEventFilter.get() && m_pImpl->pOperator.get(),
      83                 :            :             "DialogController::DialogController: invalid filter and/or operator!" );
      84                 :            : 
      85 [ #  # ][ #  # ]:          0 :         m_pImpl->rInstigator.AddEventListener( LINK( this, DialogController, OnWindowEvent ) );
      86                 :          0 :     }
      87                 :            : 
      88                 :            :     //---------------------------------------------------------------------
      89                 :          0 :     DialogController::~DialogController()
      90                 :            :     {
      91         [ #  # ]:          0 :         reset();
      92         [ #  # ]:          0 :     }
      93                 :            : 
      94                 :            :     //---------------------------------------------------------------------
      95                 :          0 :     void DialogController::reset()
      96                 :            :     {
      97         [ #  # ]:          0 :         m_pImpl->rInstigator.RemoveEventListener( LINK( this, DialogController, OnWindowEvent ) );
      98                 :          0 :         m_pImpl->aConcernedWindows.clear();
      99                 :          0 :         m_pImpl->pEventFilter.reset();
     100                 :          0 :         m_pImpl->pOperator.reset();
     101                 :          0 :     }
     102                 :            : 
     103                 :            :     //---------------------------------------------------------------------
     104                 :          0 :     void DialogController::addDependentWindow( Window& _rWindow )
     105                 :            :     {
     106         [ #  # ]:          0 :         m_pImpl->aConcernedWindows.push_back( &_rWindow );
     107                 :            : 
     108                 :          0 :         VclWindowEvent aEvent( &_rWindow, 0, NULL );
     109         [ #  # ]:          0 :         impl_update( aEvent, _rWindow );
     110                 :          0 :     }
     111                 :            : 
     112                 :            :     //---------------------------------------------------------------------
     113                 :          0 :     IMPL_LINK( DialogController, OnWindowEvent, const VclWindowEvent*, _pEvent )
     114                 :            :     {
     115         [ #  # ]:          0 :         if ( m_pImpl->pEventFilter->payAttentionTo( *_pEvent ) )
     116                 :          0 :             impl_updateAll( *_pEvent );
     117                 :          0 :         return 0L;
     118                 :            :     }
     119                 :            : 
     120                 :            :     //---------------------------------------------------------------------
     121                 :          0 :     void DialogController::impl_updateAll( const VclWindowEvent& _rTriggerEvent )
     122                 :            :     {
     123   [ #  #  #  # ]:          0 :         for ( ::std::vector< Window* >::iterator loop = m_pImpl->aConcernedWindows.begin();
                 [ #  # ]
     124                 :          0 :                 loop != m_pImpl->aConcernedWindows.end();
     125                 :            :                 ++loop
     126                 :            :             )
     127 [ #  # ][ #  # ]:          0 :             impl_update( _rTriggerEvent, *(*loop) );
     128                 :          0 :     }
     129                 :            : 
     130                 :            :     //---------------------------------------------------------------------
     131                 :          0 :     void DialogController::impl_update( const VclWindowEvent& _rTriggerEvent, Window& _rWindow )
     132                 :            :     {
     133                 :          0 :         m_pImpl->pOperator->operateOn( _rTriggerEvent, _rWindow );
     134                 :          0 :     }
     135                 :            : 
     136                 :            :     //=====================================================================
     137                 :            :     //= ControlDependencyManager_Data
     138                 :            :     //=====================================================================
     139                 :          0 :     struct ControlDependencyManager_Data
     140                 :            :     {
     141                 :            :         ::std::vector< PDialogController >  aControllers;
     142                 :            :     };
     143                 :            : 
     144                 :            :     //=====================================================================
     145                 :            :     //= ControlDependencyManager
     146                 :            :     //=====================================================================
     147                 :            :     //---------------------------------------------------------------------
     148                 :          0 :     ControlDependencyManager::ControlDependencyManager()
     149         [ #  # ]:          0 :         :m_pImpl( new ControlDependencyManager_Data )
     150                 :            :     {
     151                 :          0 :     }
     152                 :            : 
     153                 :            :     //---------------------------------------------------------------------
     154                 :          0 :     ControlDependencyManager::~ControlDependencyManager()
     155                 :            :     {
     156                 :          0 :     }
     157                 :            : 
     158                 :            :     //---------------------------------------------------------------------
     159                 :            :     namespace
     160                 :            :     {
     161                 :            :         struct ResetDialogController : public ::std::unary_function< const PDialogController&, void >
     162                 :            :         {
     163                 :          0 :             void operator()( const PDialogController& _pController )
     164                 :            :             {
     165                 :          0 :                 _pController->reset();
     166                 :          0 :             }
     167                 :            :         };
     168                 :            :     }
     169                 :            : 
     170                 :            :     //---------------------------------------------------------------------
     171                 :          0 :     void ControlDependencyManager::clear()
     172                 :            :     {
     173         [ #  # ]:          0 :         ::std::for_each( m_pImpl->aControllers.begin(), m_pImpl->aControllers.end(), ResetDialogController() );
     174                 :          0 :         m_pImpl->aControllers.clear();
     175                 :          0 :     }
     176                 :            : 
     177                 :            :     //---------------------------------------------------------------------
     178                 :          0 :     void ControlDependencyManager::addController( const PDialogController& _pController )
     179                 :            :     {
     180                 :            :         OSL_ENSURE( _pController.get() != NULL, "ControlDependencyManager::addController: invalid controller, this will crash, sooner or later!" );
     181                 :          0 :         m_pImpl->aControllers.push_back( _pController );
     182                 :          0 :     }
     183                 :            : 
     184                 :            :     //---------------------------------------------------------------------
     185                 :          0 :     void ControlDependencyManager::enableOnRadioCheck( RadioButton& _rRadio, Window& _rDependentWindow )
     186                 :            :     {
     187 [ #  # ][ #  # ]:          0 :         PDialogController pController( new RadioDependentEnabler( _rRadio ) );
                 [ #  # ]
     188         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow );
     189 [ #  # ][ #  # ]:          0 :         m_pImpl->aControllers.push_back( pController );
     190                 :          0 :     }
     191                 :            : 
     192                 :            :     //---------------------------------------------------------------------
     193                 :          0 :     void ControlDependencyManager::enableOnRadioCheck( RadioButton& _rRadio, Window& _rDependentWindow1, Window& _rDependentWindow2, Window& _rDependentWindow3 )
     194                 :            :     {
     195 [ #  # ][ #  # ]:          0 :         PDialogController pController( new RadioDependentEnabler( _rRadio ) );
                 [ #  # ]
     196         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow1 );
     197         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow2 );
     198         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow3 );
     199 [ #  # ][ #  # ]:          0 :         m_pImpl->aControllers.push_back( pController );
     200                 :          0 :     }
     201                 :            : 
     202                 :            :     //---------------------------------------------------------------------
     203                 :          0 :     void ControlDependencyManager::enableOnRadioCheck( RadioButton& _rRadio, Window& _rDependentWindow1, Window& _rDependentWindow2, Window& _rDependentWindow3, Window& _rDependentWindow4, Window& _rDependentWindow5 )
     204                 :            :     {
     205 [ #  # ][ #  # ]:          0 :         PDialogController pController( new RadioDependentEnabler( _rRadio ) );
                 [ #  # ]
     206         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow1 );
     207         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow2 );
     208         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow3 );
     209         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow4 );
     210         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow5 );
     211 [ #  # ][ #  # ]:          0 :         m_pImpl->aControllers.push_back( pController );
     212                 :          0 :     }
     213                 :            : 
     214                 :            :     //---------------------------------------------------------------------
     215                 :          0 :     void ControlDependencyManager::enableOnCheckMark( CheckBox& _rBox, Window& _rDependentWindow )
     216                 :            :     {
     217 [ #  # ][ #  # ]:          0 :         PDialogController pController( new RadioDependentEnabler( _rBox ) );
                 [ #  # ]
     218         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow );
     219 [ #  # ][ #  # ]:          0 :         m_pImpl->aControllers.push_back( pController );
     220                 :          0 :     }
     221                 :            : 
     222                 :            :     //---------------------------------------------------------------------
     223                 :          0 :     void ControlDependencyManager::enableOnCheckMark( CheckBox& _rBox, Window& _rDependentWindow1, Window& _rDependentWindow2 )
     224                 :            :     {
     225 [ #  # ][ #  # ]:          0 :         PDialogController pController( new RadioDependentEnabler( _rBox ) );
                 [ #  # ]
     226         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow1 );
     227         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow2 );
     228 [ #  # ][ #  # ]:          0 :         m_pImpl->aControllers.push_back( pController );
     229                 :          0 :     }
     230                 :            : 
     231                 :            :     //---------------------------------------------------------------------
     232                 :          0 :     void ControlDependencyManager::enableOnCheckMark( CheckBox& _rBox, Window& _rDependentWindow1, Window& _rDependentWindow2, Window& _rDependentWindow3, Window& _rDependentWindow4 )
     233                 :            :     {
     234 [ #  # ][ #  # ]:          0 :         PDialogController pController( new RadioDependentEnabler( _rBox ) );
                 [ #  # ]
     235         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow1 );
     236         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow2 );
     237         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow3 );
     238         [ #  # ]:          0 :         pController->addDependentWindow( _rDependentWindow4 );
     239 [ #  # ][ #  # ]:          0 :         m_pImpl->aControllers.push_back( pController );
     240                 :          0 :     }
     241                 :            : 
     242                 :            : //........................................................................
     243                 :            : } // namespace svt
     244                 :            : //........................................................................
     245                 :            : 
     246                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10