1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <svx/svxids.hrc>
22 #include "idetemp.hxx"
25 #include <sfx2/dispatch.hxx>
26 #include <sfx2/imagemgr.hxx>
27 #include <sfx2/viewfrm.hxx>
28 #include <svl/aeitem.hxx>
29 #include <vcl/toolbox.hxx>
34 using namespace ::com::sun::star::uno
;
38 OUString
aSubToolBarResName( "private:resource/toolbar/insertcontrolsbar" );
41 SFX_IMPL_TOOLBOX_CONTROL( TbxControls
, SfxAllEnumItem
)
43 /*************************************************************************
47 \************************************************************************/
49 TbxControls::TbxControls( sal_uInt16 nSlotId
, sal_uInt16 nId
, ToolBox
& rTbx
) :
50 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
52 nLastSlot
= USHRT_MAX
;
54 rTbx
.SetItemBits( nId
, ToolBoxItemBits::DROPDOWN
| rTbx
.GetItemBits( nId
) );
58 /*************************************************************************
60 |* If you want to create a pop-up window
62 \************************************************************************/
63 SfxPopupWindowType
TbxControls::GetPopupWindowType() const
65 if( nLastSlot
== USHRT_MAX
)
66 return SfxPopupWindowType::ONCLICK
;
67 return SfxPopupWindowType::ONTIMEOUT
;
70 void TbxControls::StateChanged( sal_uInt16 nSID
, SfxItemState eState
,
71 const SfxPoolItem
* pState
)
75 if (SfxAllEnumItem
const* pItem
= dynamic_cast<SfxAllEnumItem
const*>(pState
))
78 sal_uInt16 nLastEnum
= pItem
->GetValue();
81 case SVX_SNAP_PUSHBUTTON
: nTemp
= SID_INSERT_PUSHBUTTON
; break;
82 case SVX_SNAP_CHECKBOX
: nTemp
= SID_INSERT_CHECKBOX
; break;
83 case SVX_SNAP_RADIOBUTTON
: nTemp
= SID_INSERT_RADIOBUTTON
; break;
84 case SVX_SNAP_SPINBUTTON
: nTemp
= SID_INSERT_SPINBUTTON
; break;
85 case SVX_SNAP_FIXEDTEXT
: nTemp
= SID_INSERT_FIXEDTEXT
; break;
86 case SVX_SNAP_GROUPBOX
: nTemp
= SID_INSERT_GROUPBOX
; break;
87 case SVX_SNAP_LISTBOX
: nTemp
= SID_INSERT_LISTBOX
; break;
88 case SVX_SNAP_COMBOBOX
: nTemp
= SID_INSERT_COMBOBOX
; break;
89 case SVX_SNAP_EDIT
: nTemp
= SID_INSERT_EDIT
; break;
90 case SVX_SNAP_HSCROLLBAR
: nTemp
= SID_INSERT_HSCROLLBAR
; break;
91 case SVX_SNAP_VSCROLLBAR
: nTemp
= SID_INSERT_VSCROLLBAR
; break;
92 case SVX_SNAP_PREVIEW
: nTemp
= SID_INSERT_PREVIEW
; break;
93 case SVX_SNAP_URLBUTTON
: nTemp
= SID_INSERT_URLBUTTON
; break;
94 case SVX_SNAP_IMAGECONTROL
: nTemp
= SID_INSERT_IMAGECONTROL
; break;
95 case SVX_SNAP_PROGRESSBAR
: nTemp
= SID_INSERT_PROGRESSBAR
; break;
96 case SVX_SNAP_HFIXEDLINE
: nTemp
= SID_INSERT_HFIXEDLINE
; break;
97 case SVX_SNAP_VFIXEDLINE
: nTemp
= SID_INSERT_VFIXEDLINE
; break;
98 case SVX_SNAP_DATEFIELD
: nTemp
= SID_INSERT_DATEFIELD
; break;
99 case SVX_SNAP_TIMEFIELD
: nTemp
= SID_INSERT_TIMEFIELD
; break;
100 case SVX_SNAP_NUMERICFIELD
: nTemp
= SID_INSERT_NUMERICFIELD
; break;
101 case SVX_SNAP_CURRENCYFIELD
: nTemp
= SID_INSERT_CURRENCYFIELD
; break;
102 case SVX_SNAP_FORMATTEDFIELD
: nTemp
= SID_INSERT_FORMATTEDFIELD
; break;
103 case SVX_SNAP_PATTERNFIELD
: nTemp
= SID_INSERT_PATTERNFIELD
; break;
104 case SVX_SNAP_FILECONTROL
: nTemp
= SID_INSERT_FILECONTROL
; break;
105 case SVX_SNAP_TREECONTROL
: nTemp
= SID_INSERT_TREECONTROL
; break;
109 OUString
aSlotURL( "slot:" );
110 aSlotURL
+= OUString::number( nTemp
);
111 Image aImage
= GetImage( m_xFrame
,
115 ToolBox
& rBox
= GetToolBox();
116 rBox
.SetItemImage(GetId(), aImage
);
117 nLastSlot
= nLastEnum
;
121 SfxToolBoxControl::StateChanged( nSID
, eState
,pState
);
124 void TbxControls::Select( sal_uInt16 nModifier
)
127 SfxAllEnumItem
aItem( SID_CHOOSE_CONTROLS
, nLastSlot
);
128 SfxViewFrame
* pCurFrame
= SfxViewFrame::Current();
129 DBG_ASSERT( pCurFrame
!= NULL
, "No current view frame!" );
130 SfxDispatcher
* pDispatcher
= pCurFrame
? pCurFrame
->GetDispatcher() : NULL
;
133 pDispatcher
->Execute( SID_CHOOSE_CONTROLS
, SfxCallMode::SYNCHRON
, &aItem
, 0L );
137 /*************************************************************************
139 |* the window is created here
140 |* position of the toolbox can be requested with GetToolBox()
141 |* rItemRect are the screen coordinates
143 \************************************************************************/
144 VclPtr
<SfxPopupWindow
> TbxControls::CreatePopupWindow()
146 if ( GetSlotId() == SID_CHOOSE_CONTROLS
)
147 createAndPositionSubToolBar( aSubToolBarResName
);
153 } // namespace basctl
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */