1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: insctrl.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 // include ---------------------------------------------------------------
35 #include <tools/shl.hxx>
36 #ifndef _STATUS_HXX //autogen
37 #include <vcl/status.hxx>
39 #include <svtools/eitem.hxx>
40 #include <sfx2/app.hxx>
41 #include <sfx2/dispatch.hxx>
43 #define _SVX_INSCTRL_CXX
45 #include <svx/dialogs.hrc>
47 #include "insctrl.hxx"
48 #include <svx/dialmgr.hxx>
50 #define PAINT_OFFSET 5
52 SFX_IMPL_STATUSBAR_CONTROL(SvxInsertStatusBarControl
, SfxBoolItem
);
54 // class SvxInsertStatusBarControl ---------------------------------------
56 SvxInsertStatusBarControl::SvxInsertStatusBarControl( USHORT _nSlotId
,
60 SfxStatusBarControl( _nSlotId
, _nId
, rStb
),
63 rStb
.SetHelpId( _nId
, _nSlotId
);
66 // -----------------------------------------------------------------------
68 SvxInsertStatusBarControl::~SvxInsertStatusBarControl()
72 // -----------------------------------------------------------------------
74 void SvxInsertStatusBarControl::StateChanged( USHORT
, SfxItemState eState
,
75 const SfxPoolItem
* pState
)
77 if ( SFX_ITEM_AVAILABLE
!= eState
)
78 GetStatusBar().SetItemText( GetId(), String() );
81 DBG_ASSERT( pState
->ISA( SfxBoolItem
), "invalid item type" );
82 SfxBoolItem
* pItem
= (SfxBoolItem
*)pState
;
83 bInsert
= pItem
->GetValue();
88 // -----------------------------------------------------------------------
90 void SvxInsertStatusBarControl::Click()
92 if ( !GetStatusBar().GetItemText( GetId() ).Len() )
95 SfxBoolItem
aIns( GetSlotId(), bInsert
);
97 ::com::sun::star::uno::Any a
;
98 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> aArgs( 1 );
99 aArgs
[0].Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InsertMode" ));
100 aIns
.QueryValue( a
);
106 // -----------------------------------------------------------------------
108 void SvxInsertStatusBarControl::Paint( const UserDrawEvent
& )
113 // -----------------------------------------------------------------------
115 void SvxInsertStatusBarControl::DrawItemText_Impl()
117 USHORT _nId
= RID_SVXSTR_OVERWRITE_TEXT
;
120 _nId
= RID_SVXSTR_INSERT_TEXT
;
121 GetStatusBar().SetItemText( GetId(), SVX_RESSTR( _nId
) );
124 ULONG
SvxInsertStatusBarControl::GetDefItemWidth(const StatusBar
& rStb
)
126 long nWidth1
= rStb
.GetTextWidth(SVX_RESSTR(RID_SVXSTR_OVERWRITE_TEXT
));
127 long nWidth2
= rStb
.GetTextWidth(SVX_RESSTR(RID_SVXSTR_INSERT_TEXT
));
132 return nWidth1
+PAINT_OFFSET
;