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