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: selctrl.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/intitem.hxx>
40 #include <sfx2/dispatch.hxx>
41 #include <tools/urlobj.hxx>
43 #define _SVX_SELCTRL_CXX
45 #include "selctrl.hxx"
46 #include <svx/dialmgr.hxx>
48 #include <svx/dialogs.hrc>
50 #define PAINT_OFFSET 5
52 SFX_IMPL_STATUSBAR_CONTROL(SvxSelectionModeControl
, SfxUInt16Item
);
54 // class SvxSelectionModeControl -----------------------------------------
56 SvxSelectionModeControl::SvxSelectionModeControl( USHORT _nSlotId
,
59 SfxStatusBarControl( _nSlotId
, _nId
, rStb
),
64 // -----------------------------------------------------------------------
66 void SvxSelectionModeControl::StateChanged( USHORT
, SfxItemState eState
,
67 const SfxPoolItem
* pState
)
69 if ( SFX_ITEM_AVAILABLE
!= eState
)
70 GetStatusBar().SetItemText( GetId(), String() );
73 DBG_ASSERT( pState
->ISA( SfxUInt16Item
), "invalid item type" );
74 SfxUInt16Item
* pItem
= (SfxUInt16Item
*)pState
;
75 nState
= pItem
->GetValue();
80 // -----------------------------------------------------------------------
82 void SvxSelectionModeControl::Click()
84 if ( !GetStatusBar().GetItemText( GetId() ).Len() )
90 ::com::sun::star::uno::Any a
;
91 SfxUInt16Item
aState( GetSlotId(), nState
);
92 INetURLObject
aObj( m_aCommandURL
);
94 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> aArgs( 1 );
95 aArgs
[0].Name
= aObj
.GetURLPath();
96 aState
.QueryValue( a
);
102 // -----------------------------------------------------------------------
104 void SvxSelectionModeControl::Paint( const UserDrawEvent
& )
109 // -----------------------------------------------------------------------
111 void SvxSelectionModeControl::DrawItemText_Impl()
119 _nId
= RID_SVXSTR_SELMODE_STD
;
122 _nId
= RID_SVXSTR_SELMODE_ER
;
125 _nId
= RID_SVXSTR_SELMODE_ERG
;
128 _nId
= RID_SVXSTR_SELMODE_BLK
;
130 default: DBG_ERROR( "invalid selection mode!" );
134 sTxt
= SVX_RESSTR( _nId
);
135 GetStatusBar().SetItemText( GetId(), sTxt
);
138 ULONG
SvxSelectionModeControl::GetDefItemWidth(const StatusBar
& rStb
)
140 long nWidth1
= rStb
.GetTextWidth(SVX_RESSTR(RID_SVXSTR_SELMODE_STD
));
141 long nWidth2
= rStb
.GetTextWidth(SVX_RESSTR(RID_SVXSTR_SELMODE_ER
));
142 long nWidth3
= rStb
.GetTextWidth(SVX_RESSTR(RID_SVXSTR_SELMODE_ERG
));
143 long nWidth4
= rStb
.GetTextWidth(SVX_RESSTR(RID_SVXSTR_SELMODE_BLK
));
154 return nWidth1
+PAINT_OFFSET
;