LCOV - code coverage report
Current view: top level - forms/source/solar/control - navtoolbar.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 235 299 78.6 %
Date: 2012-08-25 Functions: 32 43 74.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 204 395 51.6 %

           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                 :            : 
      30                 :            : #include "navtoolbar.hxx"
      31                 :            : #include "frm_resource.hxx"
      32                 :            : #include "featuredispatcher.hxx"
      33                 :            : #include "frm_resource.hrc"
      34                 :            : #include "commandimageprovider.hxx"
      35                 :            : #include "commanddescriptionprovider.hxx"
      36                 :            : 
      37                 :            : #include <com/sun/star/uno/Any.hxx>
      38                 :            : #include <com/sun/star/form/runtime/FormFeature.hpp>
      39                 :            : 
      40                 :            : #include <sfx2/imgmgr.hxx>
      41                 :            : #include <vcl/fixed.hxx>
      42                 :            : 
      43                 :            : #include <memory>
      44                 :            : #include <sal/macros.h>
      45                 :            : 
      46                 :            : #define LID_RECORD_LABEL    1000
      47                 :            : #define LID_RECORD_FILLER   1001
      48                 :            : 
      49                 :            : //.........................................................................
      50                 :            : namespace frm
      51                 :            : {
      52                 :            : //.........................................................................
      53                 :            : 
      54                 :            :     using ::com::sun::star::uno::makeAny;
      55                 :            :     namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
      56                 :            : 
      57                 :            :     //=====================================================================
      58                 :            :     //.....................................................................
      59                 :            :     namespace
      60                 :            :     {
      61                 :       2646 :         static bool isArtificialItem( sal_Int16 _nFeatureId )
      62                 :            :         {
      63                 :            :             return ( _nFeatureId == LID_RECORD_LABEL )
      64 [ +  + ][ +  + ]:       2646 :                 || ( _nFeatureId == LID_RECORD_FILLER );
      65                 :            :         }
      66                 :            : 
      67                 :        338 :         static String getLabelString( sal_uInt16 _nResId )
      68                 :            :         {
      69         [ +  - ]:        338 :             String sLabel = rtl::OUString( " " );
      70 [ +  - ][ +  - ]:        338 :             sLabel += String( FRM_RES_STRING( _nResId ) );
         [ +  - ][ +  - ]
      71         [ +  - ]:        338 :             sLabel += rtl::OUString( " " );
      72                 :        338 :             return sLabel;
      73                 :            :         }
      74                 :            : 
      75                 :       2394 :         ::rtl::OUString lcl_getCommandURL( const sal_Int16 _nFormFeature )
      76                 :            :         {
      77                 :       2394 :             const sal_Char* pAsciiCommandName = NULL;
      78   [ +  +  +  +  :       2394 :             switch ( _nFormFeature )
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
                      - ]
      79                 :            :             {
      80                 :        126 :                 case FormFeature::MoveAbsolute          : pAsciiCommandName = "AbsoluteRecord";     break;
      81                 :        126 :                 case FormFeature::TotalRecords          : pAsciiCommandName = "RecTotal";           break;
      82                 :        126 :                 case FormFeature::MoveToFirst           : pAsciiCommandName = "FirstRecord";        break;
      83                 :        126 :                 case FormFeature::MoveToPrevious        : pAsciiCommandName = "PrevRecord";         break;
      84                 :        126 :                 case FormFeature::MoveToNext            : pAsciiCommandName = "NextRecord";         break;
      85                 :        126 :                 case FormFeature::MoveToLast            : pAsciiCommandName = "LastRecord";         break;
      86                 :        126 :                 case FormFeature::SaveRecordChanges     : pAsciiCommandName = "RecSave";            break;
      87                 :        126 :                 case FormFeature::UndoRecordChanges     : pAsciiCommandName = "RecUndo";            break;
      88                 :        126 :                 case FormFeature::MoveToInsertRow       : pAsciiCommandName = "NewRecord";          break;
      89                 :        126 :                 case FormFeature::DeleteRecord          : pAsciiCommandName = "DeleteRecord";       break;
      90                 :        126 :                 case FormFeature::ReloadForm            : pAsciiCommandName = "Refresh";            break;
      91                 :        126 :                 case FormFeature::RefreshCurrentControl : pAsciiCommandName = "RefreshFormControl"; break;
      92                 :        126 :                 case FormFeature::SortAscending         : pAsciiCommandName = "Sortup";             break;
      93                 :        126 :                 case FormFeature::SortDescending        : pAsciiCommandName = "SortDown";           break;
      94                 :        126 :                 case FormFeature::InteractiveSort       : pAsciiCommandName = "OrderCrit";          break;
      95                 :        126 :                 case FormFeature::AutoFilter            : pAsciiCommandName = "AutoFilter";         break;
      96                 :        126 :                 case FormFeature::InteractiveFilter     : pAsciiCommandName = "FilterCrit";         break;
      97                 :        126 :                 case FormFeature::ToggleApplyFilter     : pAsciiCommandName = "FormFiltered";       break;
      98                 :        126 :                 case FormFeature::RemoveFilterAndSort   : pAsciiCommandName = "RemoveFilterSort";   break;
      99                 :            :             }
     100         [ +  - ]:       2394 :             if ( pAsciiCommandName != NULL )
     101         [ +  - ]:       2394 :                 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ) ) + ::rtl::OUString::createFromAscii( pAsciiCommandName );
     102                 :            : 
     103                 :            :             OSL_FAIL( "lcl_getCommandURL: unknown FormFeature!" );
     104                 :       2394 :             return ::rtl::OUString();
     105                 :            :         }
     106                 :            :     }
     107                 :            : 
     108                 :            :     //=====================================================================
     109                 :            :     //= ImplNavToolBar
     110                 :            :     //=====================================================================
     111         [ -  + ]:         72 :     class ImplNavToolBar : public ToolBox
     112                 :            :     {
     113                 :            :     protected:
     114                 :            :         const IFeatureDispatcher*   m_pDispatcher;
     115                 :            : 
     116                 :            :     public:
     117                 :         36 :         ImplNavToolBar( Window* _pParent )
     118                 :            :             :ToolBox( _pParent, WB_3DLOOK )
     119                 :         36 :             ,m_pDispatcher( NULL )
     120                 :            :         {
     121                 :         36 :         }
     122                 :            : 
     123                 :        380 :         void setDispatcher( const IFeatureDispatcher* _pDispatcher )
     124                 :            :         {
     125                 :        380 :             m_pDispatcher = _pDispatcher;
     126                 :        380 :         }
     127                 :            : 
     128                 :            :     protected:
     129                 :            :         // ToolBox overridables
     130                 :            :         virtual void        Select();
     131                 :            : 
     132                 :            :     };
     133                 :            : 
     134                 :            :     //---------------------------------------------------------------------
     135                 :          0 :     void ImplNavToolBar::Select()
     136                 :            :     {
     137         [ #  # ]:          0 :         if ( m_pDispatcher )
     138                 :            :         {
     139         [ #  # ]:          0 :             if ( !m_pDispatcher->isEnabled( GetCurItemId() ) )
     140                 :            :                 // the toolbox is a little bit buggy: With TIB_REPEAT, it sometimes
     141                 :            :                 // happens that a select is reported, even though the respective
     142                 :            :                 // item has just been disabled.
     143                 :          0 :                 return;
     144                 :          0 :             m_pDispatcher->dispatch( GetCurItemId() );
     145                 :            :         }
     146                 :            :     }
     147                 :            : 
     148                 :            :     //=====================================================================
     149                 :            :     //= NavigationToolBar
     150                 :            :     //=====================================================================
     151                 :            :     DBG_NAME( NavigationToolBar )
     152                 :            :     //---------------------------------------------------------------------
     153                 :         36 :     NavigationToolBar::NavigationToolBar( Window* _pParent, WinBits _nStyle, const PCommandImageProvider& _pImageProvider,
     154                 :            :             const PCommandDescriptionProvider& _pDescriptionProvider )
     155                 :            :         :Window( _pParent, _nStyle )
     156                 :            :         ,m_pDispatcher( NULL )
     157                 :            :         ,m_pImageProvider( _pImageProvider )
     158                 :            :         ,m_pDescriptionProvider( _pDescriptionProvider )
     159                 :            :         ,m_eImageSize( eSmall )
     160 [ +  - ][ +  - ]:         36 :         ,m_pToolbar( NULL )
                 [ +  - ]
     161                 :            :     {
     162                 :            :         DBG_CTOR( NavigationToolBar, NULL );
     163         [ +  - ]:         36 :         implInit( );
     164                 :         36 :     }
     165                 :            : 
     166                 :            :     //---------------------------------------------------------------------
     167 [ +  - ][ +  - ]:         36 :     NavigationToolBar::~NavigationToolBar( )
     168                 :            :     {
     169   [ +  -  +  - ]:        360 :         for (   ::std::vector< Window* >::iterator loopChildWins = m_aChildWins.begin();
                 [ +  + ]
     170                 :        180 :                 loopChildWins != m_aChildWins.end();
     171                 :            :                 ++loopChildWins
     172                 :            :             )
     173                 :            :         {
     174 [ +  - ][ +  - ]:        144 :             delete *loopChildWins;
                 [ +  - ]
     175                 :            :         }
     176 [ +  - ][ +  - ]:         36 :         delete m_pToolbar;
     177                 :            :         DBG_DTOR( NavigationToolBar, NULL );
     178         [ -  + ]:         72 :     }
     179                 :            : 
     180                 :            :     //---------------------------------------------------------------------
     181                 :        380 :     void NavigationToolBar::setDispatcher( const IFeatureDispatcher* _pDispatcher )
     182                 :            :     {
     183                 :        380 :         m_pDispatcher = _pDispatcher;
     184                 :            : 
     185                 :        380 :         m_pToolbar->setDispatcher( _pDispatcher );
     186                 :            : 
     187                 :        380 :         RecordPositionInput* pPositionWindow = static_cast< RecordPositionInput* >( m_pToolbar->GetItemWindow( FormFeature::MoveAbsolute ) );
     188                 :            :         OSL_ENSURE( pPositionWindow, "NavigationToolBar::setDispatcher: can't forward the dispatcher to the position window!" );
     189         [ +  - ]:        380 :         if ( pPositionWindow )
     190                 :        380 :             pPositionWindow->setDispatcher( _pDispatcher );
     191                 :            : 
     192                 :        380 :         updateFeatureStates( );
     193                 :        380 :     }
     194                 :            : 
     195                 :            :     //---------------------------------------------------------------------
     196                 :        380 :     void NavigationToolBar::updateFeatureStates( )
     197                 :            :     {
     198         [ +  + ]:       9120 :         for ( sal_uInt16 nPos = 0; nPos < m_pToolbar->GetItemCount(); ++nPos )
     199                 :            :         {
     200                 :       8740 :             sal_uInt16 nItemId = m_pToolbar->GetItemId( nPos );
     201                 :            : 
     202 [ +  + ][ +  + ]:       8740 :             if ( ( nItemId == LID_RECORD_LABEL ) || ( nItemId == LID_RECORD_FILLER ) )
     203                 :        760 :                 continue;
     204                 :            : 
     205                 :            :             // is this item enabled?
     206         [ +  - ]:       7980 :             bool bEnabled = m_pDispatcher ? m_pDispatcher->isEnabled( nItemId ) : false;
     207                 :       7980 :             implEnableItem( nItemId, bEnabled );
     208                 :            :         }
     209                 :        380 :     }
     210                 :            : 
     211                 :            :     //---------------------------------------------------------------------
     212                 :       7980 :     void NavigationToolBar::implEnableItem( sal_uInt16 _nItemId, bool _bEnabled )
     213                 :            :     {
     214                 :       7980 :         m_pToolbar->EnableItem( _nItemId, _bEnabled );
     215                 :            : 
     216         [ +  + ]:       7980 :         if ( _nItemId == FormFeature::MoveAbsolute )
     217                 :        380 :             m_pToolbar->EnableItem( LID_RECORD_LABEL, _bEnabled );
     218                 :            : 
     219         [ +  + ]:       7980 :         if ( _nItemId == FormFeature::TotalRecords )
     220                 :        380 :             m_pToolbar->EnableItem( LID_RECORD_FILLER, _bEnabled );
     221                 :       7980 :     }
     222                 :            : 
     223                 :            :     //---------------------------------------------------------------------
     224                 :          0 :     void NavigationToolBar::enableFeature( sal_Int16 _nFeatureId, bool _bEnabled )
     225                 :            :     {
     226                 :            :         DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
     227                 :            :             "NavigationToolBar::enableFeature: invalid id!" );
     228                 :            : 
     229                 :          0 :         implEnableItem( (sal_uInt16)_nFeatureId, _bEnabled );
     230                 :          0 :     }
     231                 :            : 
     232                 :            :     //---------------------------------------------------------------------
     233                 :          0 :     void NavigationToolBar::checkFeature( sal_Int16 _nFeatureId, bool _bEnabled )
     234                 :            :     {
     235                 :            :         DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
     236                 :            :             "NavigationToolBar::checkFeature: invalid id!" );
     237                 :            : 
     238                 :          0 :         m_pToolbar->CheckItem( (sal_uInt16)_nFeatureId, _bEnabled );
     239                 :          0 :     }
     240                 :            : 
     241                 :            :     //---------------------------------------------------------------------
     242                 :          0 :     void NavigationToolBar::setFeatureText( sal_Int16 _nFeatureId, const ::rtl::OUString& _rText )
     243                 :            :     {
     244                 :            :         DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
     245                 :            :             "NavigationToolBar::checkFeature: invalid id!" );
     246                 :            : 
     247                 :          0 :         Window* pItemWindow = m_pToolbar->GetItemWindow( (sal_uInt16)_nFeatureId );
     248         [ #  # ]:          0 :         if ( pItemWindow )
     249         [ #  # ]:          0 :             pItemWindow->SetText( _rText );
     250                 :            :         else
     251         [ #  # ]:          0 :             m_pToolbar->SetItemText( (sal_uInt16)_nFeatureId, _rText );
     252                 :          0 :     }
     253                 :            : 
     254                 :            :     //---------------------------------------------------------------------
     255                 :         36 :     void NavigationToolBar::implInit( )
     256                 :            :     {
     257 [ +  - ][ +  - ]:         36 :         m_pToolbar = new ImplNavToolBar( this );
     258         [ +  - ]:         36 :         m_pToolbar->SetOutStyle( TOOLBOX_STYLE_FLAT );
     259         [ +  - ]:         36 :         m_pToolbar->Show();
     260                 :            : 
     261                 :            :         // need the SfxApplication for retrieving informations about our
     262                 :            :         // items. We could duplicate all the information here in our lib
     263                 :            :         // (such as the item text and the image), but why should we?
     264                 :            : 
     265                 :            :         struct FeatureDescription
     266                 :            :         {
     267                 :            :             sal_uInt16      nId;
     268                 :            :             bool        bRepeat;
     269                 :            :             bool        bItemWindow;
     270                 :            :         } aSupportedFeatures[] =
     271                 :            :         {
     272                 :            :             { LID_RECORD_LABEL,                     false, true },
     273                 :            :             { FormFeature::MoveAbsolute,            false, true },
     274                 :            :             { LID_RECORD_FILLER,                    false, true },
     275                 :            :             { FormFeature::TotalRecords,            false, true },
     276                 :            :             { FormFeature::MoveToFirst,             true,  false },
     277                 :            :             { FormFeature::MoveToPrevious,          true,  false },
     278                 :            :             { FormFeature::MoveToNext,              true,  false },
     279                 :            :             { FormFeature::MoveToLast,              true,  false },
     280                 :            :             { FormFeature::MoveToInsertRow,         false, false },
     281                 :            :             { 0, false, false },
     282                 :            :             { FormFeature::SaveRecordChanges,       false, false },
     283                 :            :             { FormFeature::UndoRecordChanges,       false, false },
     284                 :            :             { FormFeature::DeleteRecord,            false, false },
     285                 :            :             { FormFeature::ReloadForm,              false, false },
     286                 :            :             { FormFeature::RefreshCurrentControl,   false, false },
     287                 :            :             { 0, false, false },
     288                 :            :             { FormFeature::SortAscending,           false, false },
     289                 :            :             { FormFeature::SortDescending,          false, false },
     290                 :            :             { FormFeature::InteractiveSort,         false, false },
     291                 :            :             { FormFeature::AutoFilter,              false, false },
     292                 :            :             { FormFeature::InteractiveFilter,       false, false },
     293                 :            :             { FormFeature::ToggleApplyFilter,       false, false },
     294                 :            :             { FormFeature::RemoveFilterAndSort,     false, false },
     295                 :         36 :         };
     296                 :            : 
     297                 :         36 :         size_t nSupportedFeatures = SAL_N_ELEMENTS( aSupportedFeatures );
     298                 :         36 :         FeatureDescription* pSupportedFeatures = aSupportedFeatures;
     299                 :         36 :         FeatureDescription* pSupportedFeaturesEnd = aSupportedFeatures + nSupportedFeatures;
     300         [ +  + ]:        864 :         for ( ; pSupportedFeatures < pSupportedFeaturesEnd; ++pSupportedFeatures )
     301                 :            :         {
     302         [ +  + ]:        828 :             if ( pSupportedFeatures->nId )
     303                 :            :             {   // it's _not_ a separator
     304                 :            : 
     305                 :            :                 // insert the entry
     306 [ +  + ][ +  - ]:        756 :                 m_pToolbar->InsertItem( pSupportedFeatures->nId, String(), pSupportedFeatures->bRepeat ? TIB_REPEAT : 0 );
         [ +  - ][ +  - ]
     307 [ +  - ][ +  - ]:        756 :                 m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, String() );  // TODO
                 [ +  - ]
     308                 :            : 
     309         [ +  + ]:        756 :                 if ( !isArtificialItem( pSupportedFeatures->nId ) )
     310                 :            :                 {
     311         [ +  - ]:        684 :                     ::rtl::OUString sCommandURL( lcl_getCommandURL( pSupportedFeatures->nId ) );
     312 [ +  - ][ +  - ]:        684 :                     m_pToolbar->SetItemCommand( pSupportedFeatures->nId, sCommandURL );
                 [ +  - ]
     313         [ +  - ]:        684 :                     if ( m_pDescriptionProvider )
     314 [ +  - ][ +  - ]:        684 :                         m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, m_pDescriptionProvider->getCommandDescription( sCommandURL ) );
         [ +  - ][ +  - ]
     315                 :            :                 }
     316                 :            : 
     317         [ +  + ]:        756 :                 if ( pSupportedFeatures->bItemWindow )
     318                 :            :                 {
     319                 :        144 :                     Window* pItemWindow = NULL;
     320         [ +  + ]:        144 :                     if ( FormFeature::MoveAbsolute == pSupportedFeatures->nId )
     321                 :            :                     {
     322 [ +  - ][ +  - ]:         36 :                         pItemWindow = new RecordPositionInput( m_pToolbar );
     323                 :         36 :                         static_cast< RecordPositionInput* >( pItemWindow )->setDispatcher( m_pDispatcher );
     324                 :            :                     }
     325         [ +  + ]:        108 :                     else if ( LID_RECORD_FILLER == pSupportedFeatures->nId )
     326                 :            :                     {
     327 [ +  - ][ +  - ]:         36 :                         pItemWindow = new FixedText( m_pToolbar, WB_CENTER | WB_VCENTER );
     328 [ +  - ][ +  - ]:         36 :                         pItemWindow->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
                 [ +  - ]
     329                 :            :                     }
     330                 :            :                     else
     331                 :            :                     {
     332 [ +  - ][ +  - ]:         72 :                         pItemWindow = new FixedText( m_pToolbar, WB_VCENTER );
     333         [ +  - ]:         72 :                         pItemWindow->SetBackground();
     334         [ +  - ]:         72 :                         pItemWindow->SetPaintTransparent(sal_True);
     335                 :            :                     }
     336         [ +  - ]:        144 :                     m_aChildWins.push_back( pItemWindow );
     337                 :            : 
     338      [ +  +  + ]:        144 :                     switch ( pSupportedFeatures->nId )
     339                 :            :                     {
     340                 :            :                     case LID_RECORD_LABEL:
     341 [ +  - ][ +  - ]:         36 :                         pItemWindow->SetText( getLabelString( RID_STR_LABEL_RECORD ) );
                 [ +  - ]
     342                 :         36 :                         break;
     343                 :            : 
     344                 :            :                     case LID_RECORD_FILLER:
     345 [ +  - ][ +  - ]:         36 :                         pItemWindow->SetText( getLabelString( RID_STR_LABEL_OF ) );
                 [ +  - ]
     346                 :         36 :                         break;
     347                 :            :                     }
     348                 :            : 
     349         [ +  - ]:        144 :                     m_pToolbar->SetItemWindow( pSupportedFeatures->nId, pItemWindow );
     350                 :            :                 }
     351                 :            :             }
     352                 :            :             else
     353                 :            :             {   // a separator
     354         [ +  - ]:         72 :                 m_pToolbar->InsertSeparator( );
     355                 :            :             }
     356                 :            :         }
     357                 :            : 
     358         [ +  - ]:         36 :         forEachItemWindow( &NavigationToolBar::adjustItemWindowWidth, NULL );
     359                 :            : 
     360         [ +  - ]:         36 :         implUpdateImages();
     361                 :         36 :     }
     362                 :            : 
     363                 :            :     //---------------------------------------------------------------------
     364                 :         90 :     void NavigationToolBar::implUpdateImages()
     365                 :            :     {
     366                 :            :         OSL_ENSURE( m_pImageProvider, "NavigationToolBar::implUpdateImages: no image provider => no images!" );
     367         [ +  - ]:         90 :         if ( !m_pImageProvider )
     368                 :         90 :             return;
     369                 :            : 
     370         [ +  - ]:         90 :         const sal_uInt16 nItemCount = m_pToolbar->GetItemCount();
     371                 :            : 
     372                 :            :         // collect the FormFeatures in the toolbar
     373                 :            :         typedef ::std::vector< sal_Int16 >  FormFeatures;
     374         [ +  - ]:         90 :         FormFeatures aFormFeatures;
     375         [ +  - ]:         90 :         aFormFeatures.reserve( nItemCount );
     376                 :            : 
     377         [ +  + ]:       2160 :         for ( sal_uInt16 i=0; i<nItemCount; ++i )
     378                 :            :         {
     379         [ +  - ]:       2070 :             sal_uInt16 nId = m_pToolbar->GetItemId( i );
     380 [ +  - ][ +  + ]:       2070 :             if ( ( TOOLBOXITEM_BUTTON == m_pToolbar->GetItemType( i ) ) && !isArtificialItem( nId ) )
         [ +  + ][ +  + ]
     381         [ +  - ]:       1710 :                 aFormFeatures.push_back( nId );
     382                 :            :         }
     383                 :            : 
     384                 :            :         // translate them into command URLs
     385         [ +  - ]:         90 :         CommandURLs aCommandURLs( aFormFeatures.size() );
     386         [ +  - ]:       3600 :         for (   FormFeatures::const_iterator formFeature = aFormFeatures.begin();
           [ +  -  +  - ]
                 [ +  + ]
     387                 :       1800 :                 formFeature != aFormFeatures.end();
     388                 :            :                 ++formFeature
     389                 :            :             )
     390                 :            :         {
     391 [ +  - ][ +  - ]:       1710 :             aCommandURLs[ formFeature - aFormFeatures.begin() ] = lcl_getCommandURL( *formFeature );
         [ +  - ][ +  - ]
     392                 :            :         }
     393                 :            : 
     394                 :            :         // retrieve the images for the command URLs
     395         [ +  - ]:         90 :         CommandImages aCommandImages = m_pImageProvider->getCommandImages( aCommandURLs, m_eImageSize == eLarge );
     396                 :            : 
     397                 :            :         // and set them at the toolbar
     398         [ +  - ]:         90 :         CommandImages::const_iterator commandImage = aCommandImages.begin();
     399 [ +  - ][ +  - ]:       3600 :         for (   FormFeatures::const_iterator formFeature = aFormFeatures.begin();
           [ +  -  +  - ]
                 [ +  + ]
     400                 :       1800 :                 formFeature != aFormFeatures.end();
     401                 :            :                 ++formFeature, ++commandImage
     402                 :            :             )
     403                 :            :         {
     404 [ +  - ][ +  - ]:       1710 :             m_pToolbar->SetItemImage( *formFeature, *commandImage );
                 [ +  - ]
     405                 :            :         }
     406                 :            : 
     407                 :            :         // parts of our layout is dependent on the size of our icons
     408 [ +  - ][ +  - ]:         90 :         Resize();
     409                 :            :     }
     410                 :            : 
     411                 :            :     //---------------------------------------------------------------------
     412                 :         52 :     void NavigationToolBar::implSetImageSize( ImageSize _eSize )
     413                 :            :     {
     414         [ +  + ]:         52 :         if ( _eSize != m_eImageSize )
     415                 :            :         {
     416                 :         18 :             m_eImageSize = _eSize;
     417                 :         18 :             implUpdateImages();
     418                 :            :         }
     419                 :         52 :     }
     420                 :            : 
     421                 :            :     //---------------------------------------------------------------------
     422                 :         52 :     void NavigationToolBar::SetImageSize( ImageSize _eSize )
     423                 :            :     {
     424                 :         52 :         implSetImageSize( _eSize );
     425                 :         52 :     }
     426                 :            : 
     427                 :            :     //---------------------------------------------------------------------
     428                 :        208 :     void NavigationToolBar::ShowFunctionGroup( FunctionGroup _eGroup, bool _bShow )
     429                 :            :     {
     430                 :        208 :         const sal_uInt16* pGroupIds = NULL;
     431                 :            : 
     432   [ +  +  +  +  :        208 :         switch ( _eGroup )
                      - ]
     433                 :            :         {
     434                 :            :         case ePosition:
     435                 :            :         {
     436                 :            :             static const sal_uInt16 aPositionIds[] = {
     437                 :            :                 LID_RECORD_LABEL, FormFeature::MoveAbsolute, LID_RECORD_FILLER, FormFeature::TotalRecords, 0
     438                 :            :             };
     439                 :         52 :             pGroupIds = aPositionIds;
     440                 :            :         }
     441                 :         52 :         break;
     442                 :            :         case eNavigation:
     443                 :            :         {
     444                 :            :             static const sal_uInt16 aNavigationIds[] = {
     445                 :            :                 FormFeature::MoveToFirst, FormFeature::MoveToPrevious, FormFeature::MoveToNext, FormFeature::MoveToLast, FormFeature::MoveToInsertRow, 0
     446                 :            :             };
     447                 :         52 :             pGroupIds = aNavigationIds;
     448                 :            :         }
     449                 :         52 :         break;
     450                 :            :         case eRecordActions:
     451                 :            :         {
     452                 :            :             static const sal_uInt16 aActionIds[] = {
     453                 :            :                 FormFeature::SaveRecordChanges, FormFeature::UndoRecordChanges, FormFeature::DeleteRecord, FormFeature::ReloadForm, FormFeature::RefreshCurrentControl, 0
     454                 :            :             };
     455                 :         52 :             pGroupIds = aActionIds;
     456                 :            :         }
     457                 :         52 :         break;
     458                 :            :         case eFilterSort:
     459                 :            :         {
     460                 :            :             static const sal_uInt16 aFilterSortIds[] = {
     461                 :            :                 FormFeature::SortAscending, FormFeature::SortDescending, FormFeature::InteractiveSort, FormFeature::AutoFilter, FormFeature::InteractiveFilter, FormFeature::ToggleApplyFilter, FormFeature::RemoveFilterAndSort, 0
     462                 :            :             };
     463                 :         52 :             pGroupIds = aFilterSortIds;
     464                 :            :         }
     465                 :         52 :         break;
     466                 :            :         default:
     467                 :            :             OSL_FAIL( "NavigationToolBar::ShowFunctionGroup: invalid group id!" );
     468                 :            :         }
     469                 :            : 
     470         [ +  - ]:        208 :         if ( pGroupIds )
     471         [ +  + ]:       1300 :             while ( *pGroupIds )
     472                 :       1092 :                 m_pToolbar->ShowItem( *pGroupIds++, _bShow );
     473                 :        208 :     }
     474                 :            : 
     475                 :            :     //---------------------------------------------------------------------
     476                 :          0 :     bool NavigationToolBar::IsFunctionGroupVisible( FunctionGroup _eGroup )
     477                 :            :     {
     478                 :          0 :         sal_uInt16 nIndicatorItem = 0;
     479   [ #  #  #  #  :          0 :         switch ( _eGroup )
                      # ]
     480                 :            :         {
     481                 :          0 :         case ePosition      : nIndicatorItem = LID_RECORD_LABEL;    break;
     482                 :          0 :         case eNavigation    : nIndicatorItem = FormFeature::MoveToFirst; break;
     483                 :          0 :         case eRecordActions : nIndicatorItem = FormFeature::SaveRecordChanges;  break;
     484                 :          0 :         case eFilterSort    : nIndicatorItem = FormFeature::SortAscending;       break;
     485                 :            :         default:
     486                 :            :             OSL_FAIL( "NavigationToolBar::IsFunctionGroupVisible: invalid group id!" );
     487                 :            :         }
     488                 :            : 
     489                 :          0 :         return m_pToolbar->IsItemVisible( nIndicatorItem );
     490                 :            :     }
     491                 :            : 
     492                 :            :     //------------------------------------------------------------------------------
     493                 :        829 :     void NavigationToolBar::StateChanged( StateChangedType nType )
     494                 :            :     {
     495                 :        829 :         Window::StateChanged( nType );
     496                 :            : 
     497   [ -  +  -  +  :        829 :         switch ( nType )
                      + ]
     498                 :            :         {
     499                 :            :             case STATE_CHANGE_ZOOM:
     500                 :            : //                m_pToolbar->SetZoom( GetZoom() );
     501                 :            : //                forEachItemWindow( setItemWindowZoom, NULL );
     502                 :            :                 // the ToolBox class is not zoomable at the moment, so
     503                 :            :                 // we better have no zoom at all instead of only half a zoom ...
     504                 :          0 :                 break;
     505                 :            : 
     506                 :            :             case STATE_CHANGE_CONTROLFONT:
     507                 :         97 :                 forEachItemWindow( &NavigationToolBar::setItemControlFont, NULL );
     508                 :         97 :                 forEachItemWindow( &NavigationToolBar::adjustItemWindowWidth, NULL );
     509                 :         97 :                 break;
     510                 :            : 
     511                 :            :             case STATE_CHANGE_CONTROLFOREGROUND:
     512                 :          0 :                 forEachItemWindow( &NavigationToolBar::setItemControlForeground, NULL );
     513                 :          0 :                 break;
     514                 :            : 
     515                 :            :             case STATE_CHANGE_MIRRORING:
     516                 :            :             {
     517                 :         90 :                 sal_Bool bIsRTLEnabled( IsRTLEnabled() );
     518         [ +  - ]:         90 :                 m_pToolbar->EnableRTL( bIsRTLEnabled );
     519         [ +  - ]:         90 :                 forEachItemWindow( &NavigationToolBar::enableItemRTL, &bIsRTLEnabled );
     520         [ +  - ]:         90 :                 Resize();
     521                 :            :             }
     522                 :         90 :             break;
     523                 :            :         }
     524                 :        829 :     }
     525                 :            : 
     526                 :            :     //---------------------------------------------------------------------
     527                 :        218 :     void NavigationToolBar::Resize()
     528                 :            :     {
     529                 :            :         // resize/position the toolbox as a whole
     530                 :        218 :         sal_Int32 nToolbarHeight = m_pToolbar->CalcWindowSizePixel().Height();
     531                 :            : 
     532                 :        218 :         sal_Int32 nMyHeight = GetOutputSizePixel().Height();
     533                 :            :         m_pToolbar->SetPosSizePixel( Point( 0, ( nMyHeight - nToolbarHeight ) / 2 ),
     534         [ +  - ]:        218 :                                      Size( GetSizePixel().Width(), nToolbarHeight ) );
     535                 :            : 
     536                 :        218 :         Window::Resize();
     537                 :        218 :     }
     538                 :            : 
     539                 :            :     //---------------------------------------------------------------------
     540                 :         36 :     void NavigationToolBar::SetControlBackground()
     541                 :            :     {
     542                 :         36 :         Window::SetControlBackground();
     543                 :         36 :         m_pToolbar->SetControlBackground();
     544                 :         36 :         forEachItemWindow( &NavigationToolBar::setItemBackground, NULL );
     545                 :            : 
     546                 :         36 :         implUpdateImages();
     547                 :         36 :     }
     548                 :            : 
     549                 :            :     //---------------------------------------------------------------------
     550                 :          0 :     void NavigationToolBar::SetControlBackground( const Color& _rColor )
     551                 :            :     {
     552                 :          0 :         Window::SetControlBackground( _rColor );
     553                 :          0 :         m_pToolbar->SetControlBackground( _rColor );
     554                 :          0 :         forEachItemWindow( &NavigationToolBar::setItemBackground, &_rColor );
     555                 :            : 
     556                 :          0 :         implUpdateImages();
     557                 :          0 :     }
     558                 :            : 
     559                 :            :     //---------------------------------------------------------------------
     560                 :         36 :     void NavigationToolBar::SetTextLineColor( )
     561                 :            :     {
     562                 :         36 :         Window::SetTextLineColor( );
     563                 :         36 :         m_pToolbar->SetTextLineColor( );
     564                 :         36 :         forEachItemWindow( &NavigationToolBar::setTextLineColor, NULL );
     565                 :         36 :     }
     566                 :            : 
     567                 :            :     //---------------------------------------------------------------------
     568                 :          0 :     void NavigationToolBar::SetTextLineColor( const Color& _rColor )
     569                 :            :     {
     570                 :          0 :         Window::SetTextLineColor( _rColor );
     571                 :          0 :         m_pToolbar->SetTextLineColor( _rColor );
     572                 :          0 :         forEachItemWindow( &NavigationToolBar::setTextLineColor, &_rColor );
     573                 :          0 :     }
     574                 :            : 
     575                 :            :     //---------------------------------------------------------------------
     576                 :        392 :     void NavigationToolBar::forEachItemWindow( ItemWindowHandler _handler, const void* _pParam )
     577                 :            :     {
     578         [ +  + ]:       9408 :         for ( sal_uInt16 item = 0; item < m_pToolbar->GetItemCount(); ++item )
     579                 :            :         {
     580                 :       9016 :             sal_uInt16 nItemId = m_pToolbar->GetItemId( item );
     581                 :       9016 :             Window* pItemWindow = m_pToolbar->GetItemWindow( nItemId );
     582         [ +  + ]:       9016 :             if ( pItemWindow )
     583         [ +  - ]:       1568 :                 (this->*_handler)( nItemId, pItemWindow, _pParam );
     584                 :            :         }
     585                 :        392 :     }
     586                 :            : 
     587                 :            :     //---------------------------------------------------------------------
     588                 :        144 :     void NavigationToolBar::setItemBackground( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* _pColor ) const
     589                 :            :     {
     590         [ -  + ]:        144 :         if ( _pColor )
     591                 :          0 :             _pItemWindow->SetControlBackground( *static_cast< const Color* >( _pColor ) );
     592                 :            :         else
     593                 :        144 :             _pItemWindow->SetControlBackground();
     594                 :        144 :     }
     595                 :            : 
     596                 :            :     //---------------------------------------------------------------------
     597                 :        144 :     void NavigationToolBar::setTextLineColor( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* _pColor ) const
     598                 :            :     {
     599         [ -  + ]:        144 :         if ( _pColor )
     600                 :          0 :             _pItemWindow->SetTextLineColor( *static_cast< const Color* >( _pColor ) );
     601                 :            :         else
     602                 :        144 :             _pItemWindow->SetTextLineColor();
     603                 :        144 :     }
     604                 :            : #if 0
     605                 :            :     //---------------------------------------------------------------------
     606                 :            :     void NavigationToolBar::setItemWindowZoom( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const
     607                 :            :     {
     608                 :            :         _pItemWindow->SetZoom( GetZoom() );
     609                 :            :         _pItemWindow->SetZoomedPointFont( IsControlFont() ? GetControlFont() : GetPointFont() );
     610                 :            :     }
     611                 :            : #endif
     612                 :            :     //---------------------------------------------------------------------
     613                 :        388 :     void NavigationToolBar::setItemControlFont( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const
     614                 :            :     {
     615         [ +  - ]:        388 :         if ( IsControlFont() )
     616         [ +  - ]:        388 :             _pItemWindow->SetControlFont( GetControlFont() );
     617                 :            :         else
     618                 :          0 :             _pItemWindow->SetControlFont( );
     619                 :        388 :     }
     620                 :            : 
     621                 :            :     //---------------------------------------------------------------------
     622                 :          0 :     void NavigationToolBar::setItemControlForeground( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const
     623                 :            :     {
     624         [ #  # ]:          0 :         if ( IsControlForeground() )
     625         [ #  # ]:          0 :             _pItemWindow->SetControlForeground( GetControlForeground() );
     626                 :            :         else
     627                 :          0 :             _pItemWindow->SetControlForeground( );
     628                 :          0 :         _pItemWindow->SetTextColor( GetTextColor() );
     629                 :          0 :     }
     630                 :            : 
     631                 :            :     //---------------------------------------------------------------------
     632                 :        532 :     void NavigationToolBar::adjustItemWindowWidth( sal_uInt16 _nItemId, Window* _pItemWindow, const void* /* _pParam */ ) const
     633                 :            :     {
     634         [ +  - ]:        532 :         String sItemText;
     635   [ +  +  +  +  :        532 :         switch ( _nItemId )
                      - ]
     636                 :            :         {
     637                 :            :         case LID_RECORD_LABEL:
     638 [ +  - ][ +  - ]:        133 :             sItemText = getLabelString( RID_STR_LABEL_RECORD );
                 [ +  - ]
     639                 :        133 :             break;
     640                 :            : 
     641                 :            :         case LID_RECORD_FILLER:
     642 [ +  - ][ +  - ]:        133 :             sItemText = getLabelString( RID_STR_LABEL_OF );
                 [ +  - ]
     643                 :        133 :             break;
     644                 :            : 
     645                 :            :         case FormFeature::MoveAbsolute:
     646         [ +  - ]:        133 :             sItemText = rtl::OUString( "12345678" );
     647                 :        133 :             break;
     648                 :            : 
     649                 :            :         case FormFeature::TotalRecords:
     650         [ +  - ]:        133 :             sItemText = rtl::OUString( "123456" );
     651                 :        133 :             break;
     652                 :            :         }
     653                 :            : 
     654 [ +  - ][ +  - ]:        532 :         Size aSize( _pItemWindow->GetTextWidth( sItemText ), /* _pItemWindow->GetSizePixel( ).Height() */ _pItemWindow->GetTextHeight() + 4 );
     655                 :        532 :         aSize.Width() += 6;
     656         [ +  - ]:        532 :         _pItemWindow->SetSizePixel( aSize );
     657                 :            : 
     658 [ +  - ][ +  - ]:        532 :         m_pToolbar->SetItemWindow( _nItemId, _pItemWindow );
     659                 :        532 :     }
     660                 :            : 
     661                 :            :     //---------------------------------------------------------------------
     662                 :        360 :     void NavigationToolBar::enableItemRTL( sal_uInt16 /*_nItemId*/, Window* _pItemWindow, const void* _pIsRTLEnabled ) const
     663                 :            :     {
     664                 :        360 :         _pItemWindow->EnableRTL( *static_cast< const sal_Bool* >( _pIsRTLEnabled ) );
     665                 :        360 :     }
     666                 :            : 
     667                 :            :     //=====================================================================
     668                 :            :     //= RecordPositionInput
     669                 :            :     //=====================================================================
     670                 :            :     //---------------------------------------------------------------------
     671                 :         36 :     RecordPositionInput::RecordPositionInput( Window* _pParent )
     672                 :            :         :NumericField( _pParent, WB_BORDER | WB_VCENTER )
     673                 :         36 :         ,m_pDispatcher( NULL )
     674                 :            :     {
     675         [ +  - ]:         36 :         SetMin( 1 );
     676                 :         36 :         SetFirst( 1 );
     677                 :         36 :         SetSpinSize( 1 );
     678         [ +  - ]:         36 :         SetDecimalDigits( 0 );
     679         [ +  - ]:         36 :         SetStrictFormat( sal_True );
     680         [ +  - ]:         36 :         SetBorderStyle( WINDOW_BORDER_MONO );
     681                 :         36 :     }
     682                 :            : 
     683                 :            :     //---------------------------------------------------------------------
     684                 :         36 :     RecordPositionInput::~RecordPositionInput()
     685                 :            :     {
     686         [ -  + ]:         72 :     }
     687                 :            : 
     688                 :            :     //---------------------------------------------------------------------
     689                 :        416 :     void RecordPositionInput::setDispatcher( const IFeatureDispatcher* _pDispatcher )
     690                 :            :     {
     691                 :        416 :         m_pDispatcher = _pDispatcher;
     692                 :        416 :     }
     693                 :            : 
     694                 :            :     //---------------------------------------------------------------------
     695                 :          0 :     void RecordPositionInput::FirePosition( sal_Bool _bForce )
     696                 :            :     {
     697 [ #  # ][ #  # ]:          0 :         if ( _bForce || ( GetText() != GetSavedValue() ) )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     698                 :            :         {
     699                 :          0 :             sal_Int64 nRecord = GetValue();
     700 [ #  # ][ #  # ]:          0 :             if ( nRecord < GetMin() || nRecord > GetMax() )
                 [ #  # ]
     701                 :          0 :                 return;
     702                 :            : 
     703         [ #  # ]:          0 :             if ( m_pDispatcher )
     704 [ #  # ][ #  # ]:          0 :                 m_pDispatcher->dispatchWithArgument( FormFeature::MoveAbsolute, "Position", makeAny( (sal_Int32)nRecord ) );
     705                 :            : 
     706                 :          0 :             SaveValue();
     707                 :            :         }
     708                 :            :     }
     709                 :            : 
     710                 :            :     //---------------------------------------------------------------------
     711                 :          0 :     void RecordPositionInput::LoseFocus()
     712                 :            :     {
     713                 :          0 :         FirePosition( sal_False );
     714                 :          0 :     }
     715                 :            : 
     716                 :            :     //---------------------------------------------------------------------
     717                 :          0 :     void RecordPositionInput::KeyInput( const KeyEvent& rKeyEvent )
     718                 :            :     {
     719 [ #  # ][ #  # ]:          0 :         if( rKeyEvent.GetKeyCode() == KEY_RETURN && GetText().Len() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
     720                 :          0 :             FirePosition( sal_True );
     721                 :            :         else
     722                 :          0 :             NumericField::KeyInput( rKeyEvent );
     723                 :          0 :     }
     724                 :            : 
     725                 :            : 
     726                 :            : //.........................................................................
     727                 :            : }   // namespace frm
     728                 :            : //.........................................................................
     729                 :            : 
     730                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10