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 <tools/shl.hxx>
30 : : #include <vcl/status.hxx>
31 : : #include <svl/eitem.hxx>
32 : : #include <sfx2/app.hxx>
33 : : #include <sfx2/dispatch.hxx>
34 : :
35 : : #define _SVX_INSCTRL_CXX
36 : :
37 : : #include <svx/dialogs.hrc>
38 : :
39 : : #include "svx/insctrl.hxx"
40 : : #include <svx/dialmgr.hxx>
41 : :
42 [ + - ]: 1103 : SFX_IMPL_STATUSBAR_CONTROL(SvxInsertStatusBarControl, SfxBoolItem);
43 : :
44 : : // class SvxInsertStatusBarControl ---------------------------------------
45 : :
46 : 979 : SvxInsertStatusBarControl::SvxInsertStatusBarControl( sal_uInt16 _nSlotId,
47 : : sal_uInt16 _nId,
48 : : StatusBar& rStb ) :
49 : :
50 : : SfxStatusBarControl( _nSlotId, _nId, rStb ),
51 : 979 : bInsert( sal_True )
52 : : {
53 : 979 : }
54 : :
55 : : // -----------------------------------------------------------------------
56 : :
57 : 979 : SvxInsertStatusBarControl::~SvxInsertStatusBarControl()
58 : : {
59 [ - + ]: 1958 : }
60 : :
61 : : // -----------------------------------------------------------------------
62 : :
63 : 1535 : void SvxInsertStatusBarControl::StateChanged( sal_uInt16 , SfxItemState eState,
64 : : const SfxPoolItem* pState )
65 : : {
66 [ + + ]: 1535 : if ( SFX_ITEM_AVAILABLE != eState )
67 [ + - ]: 297 : GetStatusBar().SetItemText( GetId(), String() );
68 : : else
69 : : {
70 : : DBG_ASSERT( pState->ISA( SfxBoolItem ), "invalid item type" );
71 : 1238 : SfxBoolItem* pItem = (SfxBoolItem*)pState;
72 : 1238 : bInsert = pItem->GetValue();
73 : :
74 [ + - ]: 1238 : if ( bInsert )
75 [ + - ][ + - ]: 1238 : GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( RID_SVXSTR_INSERT_HELPTEXT ) );
[ + - ][ + - ]
76 : : else
77 [ # # ][ # # ]: 0 : GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( RID_SVXSTR_OVERWRITE_HELPTEXT ) );
[ # # ][ # # ]
78 : :
79 : 1238 : DrawItemText_Impl();
80 : : }
81 : 1535 : }
82 : :
83 : : // -----------------------------------------------------------------------
84 : :
85 : 0 : void SvxInsertStatusBarControl::Click()
86 : : {
87 [ # # ][ # # ]: 0 : if ( !GetStatusBar().GetItemText( GetId() ).Len() )
88 : 0 : return;
89 : 0 : bInsert = !bInsert;
90 [ # # ]: 0 : SfxBoolItem aIns( GetSlotId(), bInsert );
91 : :
92 : 0 : ::com::sun::star::uno::Any a;
93 [ # # ]: 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
94 [ # # ][ # # ]: 0 : aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InsertMode" ));
95 [ # # ]: 0 : aIns.QueryValue( a );
96 [ # # ]: 0 : aArgs[0].Value = a;
97 : :
98 [ # # ][ # # ]: 0 : execute( aArgs );
[ # # ]
99 : : }
100 : :
101 : : // -----------------------------------------------------------------------
102 : :
103 : 0 : void SvxInsertStatusBarControl::Paint( const UserDrawEvent& )
104 : : {
105 : 0 : DrawItemText_Impl();
106 : 0 : }
107 : :
108 : : // -----------------------------------------------------------------------
109 : :
110 : 1238 : void SvxInsertStatusBarControl::DrawItemText_Impl()
111 : : {
112 [ + - ]: 1238 : String aText;
113 [ - + ]: 1238 : if ( !bInsert )
114 [ # # ][ # # ]: 0 : aText = SVX_RESSTR( RID_SVXSTR_OVERWRITE_TEXT );
[ # # ]
115 : :
116 [ + - ][ + - ]: 1238 : GetStatusBar().SetItemText( GetId(), aText );
117 : 1238 : }
118 : :
119 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|