LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/stbctrls - insctrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 20 36 55.6 %
Date: 2013-07-09 Functions: 9 11 81.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <tools/shl.hxx>
      21             : #include <vcl/status.hxx>
      22             : #include <svl/eitem.hxx>
      23             : #include <sfx2/app.hxx>
      24             : #include <sfx2/dispatch.hxx>
      25             : 
      26             : #include <svx/dialogs.hrc>
      27             : 
      28             : #include "svx/insctrl.hxx"
      29             : #include <svx/dialmgr.hxx>
      30             : 
      31         605 : SFX_IMPL_STATUSBAR_CONTROL(SvxInsertStatusBarControl, SfxBoolItem);
      32             : 
      33             : // class SvxInsertStatusBarControl ---------------------------------------
      34             : 
      35         541 : SvxInsertStatusBarControl::SvxInsertStatusBarControl( sal_uInt16 _nSlotId,
      36             :                                                       sal_uInt16 _nId,
      37             :                                                       StatusBar& rStb ) :
      38             : 
      39             :     SfxStatusBarControl( _nSlotId, _nId, rStb ),
      40         541 :     bInsert( sal_True )
      41             : {
      42         541 : }
      43             : 
      44             : // -----------------------------------------------------------------------
      45             : 
      46        1082 : SvxInsertStatusBarControl::~SvxInsertStatusBarControl()
      47             : {
      48        1082 : }
      49             : 
      50             : // -----------------------------------------------------------------------
      51             : 
      52         808 : void SvxInsertStatusBarControl::StateChanged( sal_uInt16 , SfxItemState eState,
      53             :                                               const SfxPoolItem* pState )
      54             : {
      55         808 :     if ( SFX_ITEM_AVAILABLE != eState )
      56         203 :         GetStatusBar().SetItemText( GetId(), String() );
      57             :     else
      58             :     {
      59             :         DBG_ASSERT( pState->ISA( SfxBoolItem ), "invalid item type" );
      60         605 :         SfxBoolItem* pItem = (SfxBoolItem*)pState;
      61         605 :         bInsert = pItem->GetValue();
      62             : 
      63         605 :         if ( bInsert )
      64         605 :             GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( RID_SVXSTR_INSERT_HELPTEXT ) );
      65             :         else
      66           0 :             GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( RID_SVXSTR_OVERWRITE_HELPTEXT ) );
      67             : 
      68         605 :         DrawItemText_Impl();
      69             :     }
      70         808 : }
      71             : 
      72             : // -----------------------------------------------------------------------
      73             : 
      74           0 : void SvxInsertStatusBarControl::Click()
      75             : {
      76           0 :     if ( !GetStatusBar().GetItemText( GetId() ).Len() )
      77           0 :         return;
      78           0 :     bInsert = !bInsert;
      79           0 :     SfxBoolItem aIns( GetSlotId(), bInsert );
      80             : 
      81           0 :     ::com::sun::star::uno::Any a;
      82           0 :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
      83           0 :     aArgs[0].Name = OUString( "InsertMode" );
      84           0 :     aIns.QueryValue( a );
      85           0 :     aArgs[0].Value = a;
      86             : 
      87           0 :     execute( aArgs );
      88             : }
      89             : 
      90             : // -----------------------------------------------------------------------
      91             : 
      92           0 : void SvxInsertStatusBarControl::Paint( const UserDrawEvent& )
      93             : {
      94           0 :     DrawItemText_Impl();
      95           0 : }
      96             : 
      97             : // -----------------------------------------------------------------------
      98             : 
      99         605 : void SvxInsertStatusBarControl::DrawItemText_Impl()
     100             : {
     101         605 :     String aText;
     102         605 :     if ( !bInsert )
     103           0 :         aText = SVX_RESSTR( RID_SVXSTR_OVERWRITE_TEXT );
     104             : 
     105         605 :     GetStatusBar().SetItemText( GetId(), aText );
     106         821 : }
     107             : 
     108             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10