LCOV - code coverage report
Current view: top level - svx/source/stbctrls - insctrl.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 20 38 52.6 %
Date: 2014-11-03 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 <vcl/status.hxx>
      21             : #include <svl/eitem.hxx>
      22             : #include <sfx2/app.hxx>
      23             : #include <sfx2/dispatch.hxx>
      24             : 
      25             : #include <svx/dialogs.hrc>
      26             : 
      27             : #include "svx/insctrl.hxx"
      28             : #include <svx/dialmgr.hxx>
      29             : 
      30        1398 : SFX_IMPL_STATUSBAR_CONTROL(SvxInsertStatusBarControl, SfxBoolItem);
      31             : 
      32        1234 : SvxInsertStatusBarControl::SvxInsertStatusBarControl( sal_uInt16 _nSlotId,
      33             :                                                       sal_uInt16 _nId,
      34             :                                                       StatusBar& rStb ) :
      35             : 
      36             :     SfxStatusBarControl( _nSlotId, _nId, rStb ),
      37        1234 :     bInsert( true )
      38             : {
      39        1234 : }
      40             : 
      41             : 
      42             : 
      43        2468 : SvxInsertStatusBarControl::~SvxInsertStatusBarControl()
      44             : {
      45        2468 : }
      46             : 
      47             : 
      48             : 
      49        1439 : void SvxInsertStatusBarControl::StateChanged( sal_uInt16 , SfxItemState eState,
      50             :                                               const SfxPoolItem* pState )
      51             : {
      52        1439 :     if ( SfxItemState::DEFAULT != eState )
      53         405 :         GetStatusBar().SetItemText( GetId(), "" );
      54             :     else
      55             :     {
      56             :         DBG_ASSERT( pState->ISA( SfxBoolItem ), "invalid item type" );
      57        1034 :         const SfxBoolItem* pItem = static_cast<const SfxBoolItem*>(pState);
      58        1034 :         bInsert = pItem->GetValue();
      59             : 
      60        1034 :         if ( bInsert )
      61        1034 :             GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( RID_SVXSTR_INSERT_HELPTEXT ) );
      62             :         else
      63           0 :             GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( RID_SVXSTR_OVERWRITE_HELPTEXT ) );
      64             : 
      65        1034 :         DrawItemText_Impl();
      66             :     }
      67        1439 : }
      68             : 
      69             : 
      70             : 
      71           0 : void SvxInsertStatusBarControl::Click()
      72             : {
      73           0 :     if ( GetStatusBar().GetItemText( GetId() ).isEmpty() )
      74           0 :         return;
      75           0 :     bInsert = !bInsert;
      76           0 :     SfxBoolItem aIns( GetSlotId(), bInsert );
      77             : 
      78           0 :     ::com::sun::star::uno::Any a;
      79           0 :     bool bHasValue = aIns.QueryValue( a );
      80           0 :     if (!bHasValue)
      81           0 :         return;
      82             : 
      83           0 :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
      84           0 :     aArgs[0].Name = "InsertMode";
      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        1034 : void SvxInsertStatusBarControl::DrawItemText_Impl()
     100             : {
     101        1034 :     OUString aText;
     102        1034 :     if ( !bInsert )
     103           0 :         aText = SVX_RESSTR( RID_SVXSTR_OVERWRITE_TEXT );
     104             : 
     105        1034 :     GetStatusBar().SetItemText( GetId(), aText );
     106        1628 : }
     107             : 
     108             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10