fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svx / source / stbctrls / insctrl.cxx
blobf992882b8168911c61a89eb999169f43a3c4bc60
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
26 #include <svx/dialogs.hrc>
28 #include "svx/insctrl.hxx"
29 #include <svx/dialmgr.hxx>
31 SFX_IMPL_STATUSBAR_CONTROL(SvxInsertStatusBarControl, SfxBoolItem);
33 // class SvxInsertStatusBarControl ---------------------------------------
35 SvxInsertStatusBarControl::SvxInsertStatusBarControl( sal_uInt16 _nSlotId,
36 sal_uInt16 _nId,
37 StatusBar& rStb ) :
39 SfxStatusBarControl( _nSlotId, _nId, rStb ),
40 bInsert( sal_True )
44 // -----------------------------------------------------------------------
46 SvxInsertStatusBarControl::~SvxInsertStatusBarControl()
50 // -----------------------------------------------------------------------
52 void SvxInsertStatusBarControl::StateChanged( sal_uInt16 , SfxItemState eState,
53 const SfxPoolItem* pState )
55 if ( SFX_ITEM_AVAILABLE != eState )
56 GetStatusBar().SetItemText( GetId(), String() );
57 else
59 DBG_ASSERT( pState->ISA( SfxBoolItem ), "invalid item type" );
60 SfxBoolItem* pItem = (SfxBoolItem*)pState;
61 bInsert = pItem->GetValue();
63 if ( bInsert )
64 GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( RID_SVXSTR_INSERT_HELPTEXT ) );
65 else
66 GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( RID_SVXSTR_OVERWRITE_HELPTEXT ) );
68 DrawItemText_Impl();
72 // -----------------------------------------------------------------------
74 void SvxInsertStatusBarControl::Click()
76 if ( !GetStatusBar().GetItemText( GetId() ).Len() )
77 return;
78 bInsert = !bInsert;
79 SfxBoolItem aIns( GetSlotId(), bInsert );
81 ::com::sun::star::uno::Any a;
82 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
83 aArgs[0].Name = OUString( "InsertMode" );
84 aIns.QueryValue( a );
85 aArgs[0].Value = a;
87 execute( aArgs );
90 // -----------------------------------------------------------------------
92 void SvxInsertStatusBarControl::Paint( const UserDrawEvent& )
94 DrawItemText_Impl();
97 // -----------------------------------------------------------------------
99 void SvxInsertStatusBarControl::DrawItemText_Impl()
101 String aText;
102 if ( !bInsert )
103 aText = SVX_RESSTR( RID_SVXSTR_OVERWRITE_TEXT );
105 GetStatusBar().SetItemText( GetId(), aText );
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */