Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / svx / source / stbctrls / insctrl.cxx
blob96e3c7acbe7f5b3cc296bdecc314cebd0ae835b8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
30 // include ---------------------------------------------------------------
31 #include <tools/shl.hxx>
32 #include <vcl/status.hxx>
33 #include <svl/eitem.hxx>
34 #include <sfx2/app.hxx>
35 #include <sfx2/dispatch.hxx>
37 #define _SVX_INSCTRL_CXX
39 #include <svx/dialogs.hrc>
41 #include "svx/insctrl.hxx"
42 #include <svx/dialmgr.hxx>
44 SFX_IMPL_STATUSBAR_CONTROL(SvxInsertStatusBarControl, SfxBoolItem);
46 // class SvxInsertStatusBarControl ---------------------------------------
48 SvxInsertStatusBarControl::SvxInsertStatusBarControl( sal_uInt16 _nSlotId,
49 sal_uInt16 _nId,
50 StatusBar& rStb ) :
52 SfxStatusBarControl( _nSlotId, _nId, rStb ),
53 bInsert( sal_True )
57 // -----------------------------------------------------------------------
59 SvxInsertStatusBarControl::~SvxInsertStatusBarControl()
63 // -----------------------------------------------------------------------
65 void SvxInsertStatusBarControl::StateChanged( sal_uInt16 , SfxItemState eState,
66 const SfxPoolItem* pState )
68 if ( SFX_ITEM_AVAILABLE != eState )
69 GetStatusBar().SetItemText( GetId(), String() );
70 else
72 DBG_ASSERT( pState->ISA( SfxBoolItem ), "invalid item type" );
73 SfxBoolItem* pItem = (SfxBoolItem*)pState;
74 bInsert = pItem->GetValue();
76 if ( bInsert )
77 GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( RID_SVXSTR_INSERT_HELPTEXT ) );
78 else
79 GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( RID_SVXSTR_OVERWRITE_HELPTEXT ) );
81 DrawItemText_Impl();
85 // -----------------------------------------------------------------------
87 void SvxInsertStatusBarControl::Click()
89 if ( !GetStatusBar().GetItemText( GetId() ).Len() )
90 return;
91 bInsert = !bInsert;
92 SfxBoolItem aIns( GetSlotId(), bInsert );
94 ::com::sun::star::uno::Any a;
95 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
96 aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InsertMode" ));
97 aIns.QueryValue( a );
98 aArgs[0].Value = a;
100 execute( aArgs );
103 // -----------------------------------------------------------------------
105 void SvxInsertStatusBarControl::Paint( const UserDrawEvent& )
107 DrawItemText_Impl();
110 // -----------------------------------------------------------------------
112 void SvxInsertStatusBarControl::DrawItemText_Impl()
114 String aText;
115 if ( !bInsert )
116 aText = SVX_RESSTR( RID_SVXSTR_OVERWRITE_TEXT );
118 GetStatusBar().SetItemText( GetId(), aText );
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */