LibreOffice Module svx (master)  1
insctrl.cxx
Go to the documentation of this file.
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 #include <tools/debug.hxx>
25 
26 #include <svx/strings.hrc>
27 
28 #include <svx/insctrl.hxx>
29 #include <svx/dialmgr.hxx>
30 
32 
34  sal_uInt16 _nId,
35  StatusBar& rStb ) :
36 
37  SfxStatusBarControl( _nSlotId, _nId, rStb ),
38  bInsert( true )
39 {
40 }
41 
43 {
44 }
45 
47  const SfxPoolItem* pState )
48 {
49  if ( SfxItemState::DEFAULT != eState )
50  GetStatusBar().SetItemText( GetId(), "" );
51  else
52  {
53  DBG_ASSERT( dynamic_cast<const SfxBoolItem*>( pState) != nullptr, "invalid item type" );
54  const SfxBoolItem* pItem = static_cast<const SfxBoolItem*>(pState);
55  bInsert = pItem->GetValue();
56 
57  if ( bInsert )
58  GetStatusBar().SetQuickHelpText( GetId(), SvxResId( RID_SVXSTR_INSERT_HELPTEXT ) );
59  else
60  GetStatusBar().SetQuickHelpText( GetId(), SvxResId( RID_SVXSTR_OVERWRITE_HELPTEXT ) );
61 
63  }
64 }
65 
67 {
68 }
69 
71 {
72  OUString aText = "";
73  // tdf#107918 on macOS without an Insert key it's hard to figure out how to switch modes
74  // so we show both Insert and Overwrite
75 #ifdef MACOSX
76  if ( bInsert )
77  aText = SvxResId( RID_SVXSTR_INSERT_TEXT );
78 #endif
79  if ( !bInsert )
80  aText = SvxResId( RID_SVXSTR_OVERWRITE_TEXT );
81 
82  GetStatusBar().SetItemText( GetId(), aText );
83 }
84 
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetValue() const
SFX_IMPL_STATUSBAR_CONTROL(SvxInsertStatusBarControl, SfxBoolItem)
void SetItemText(sal_uInt16 nItemId, const OUString &rText, int nCharsWidth=-1)
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
virtual void Paint(const UserDrawEvent &rEvt) override
Definition: insctrl.cxx:66
virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: insctrl.cxx:46
sal_uInt16 GetId() const
#define DBG_ASSERT(sCon, aError)
void SetQuickHelpText(sal_uInt16 nItemId, const OUString &rText)
virtual ~SvxInsertStatusBarControl() override
Definition: insctrl.cxx:42
SfxItemState
StatusBar & GetStatusBar() const
SvxInsertStatusBarControl(sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb)
Definition: insctrl.cxx:33
SVX_DLLPRIVATE void DrawItemText_Impl()
Definition: insctrl.cxx:70