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: selector.hxx,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 ************************************************************************/
30 #ifndef _SVXSELECTOR_HXX
31 #define _SVXSELECTOR_HXX
33 #include <vcl/lstbox.hxx>
34 #include <vcl/fixed.hxx>
35 #include <vcl/group.hxx>
36 #include <vcl/menubtn.hxx>
37 #include <svtools/svtreebx.hxx>
39 #include <com/sun/star/uno/XComponentContext.hpp>
40 #include <com/sun/star/frame/XFrame.hpp>
41 #include <com/sun/star/container/XNameAccess.hpp>
42 #include <com/sun/star/script/browse/XBrowseNode.hpp>
44 #define _SVSTDARR_USHORTS
45 #define _SVSTDARR_STRINGSDTOR
46 #include <svtools/svstdarr.hxx> // SvUShorts
47 #include <sfx2/minarray.hxx>
49 #define SVX_CFGGROUP_FUNCTION 1
50 #define SVX_CFGFUNCTION_SLOT 2
51 #define SVX_CFGGROUP_SCRIPTCONTAINER 3
52 #define SVX_CFGFUNCTION_SCRIPT 4
54 struct SvxGroupInfo_Impl
58 ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
>
61 ::rtl::OUString sHelpText
;
64 SvxGroupInfo_Impl( USHORT n
, USHORT nr
)
74 SvxGroupInfo_Impl( USHORT n
, USHORT nr
, const ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
>& _rxNode
)
77 ,xBrowseNode( _rxNode
)
84 SvxGroupInfo_Impl( USHORT n
, USHORT nr
, const ::rtl::OUString
& _rURL
, const ::rtl::OUString
& _rHelpText
)
89 ,sHelpText( _rHelpText
)
95 typedef SvxGroupInfo_Impl
* SvxGroupInfoPtr
;
96 SV_DECL_PTRARR_DEL(SvxGroupInfoArr_Impl
, SvxGroupInfoPtr
, 5, 5)
101 virtual ~ImageProvider() {}
103 virtual Image
GetImage( const rtl::OUString
& rCommandURL
) = 0;
106 class SvxConfigFunctionListBox_Impl
: public SvTreeListBox
108 friend class SvxConfigGroupListBox_Impl
;
110 SvLBoxEntry
* pCurEntry
;
111 SvxGroupInfoArr_Impl aArr
;
112 SvLBoxEntry
* m_pDraggingEntry
;
114 DECL_LINK( TimerHdl
, Timer
* );
115 virtual void MouseMove( const MouseEvent
& rMEvt
);
118 SvxConfigFunctionListBox_Impl( Window
*, const ResId
& );
119 ~SvxConfigFunctionListBox_Impl();
121 SvLBoxEntry
* GetEntry_Impl( USHORT nId
);
122 SvLBoxEntry
* GetEntry_Impl( const String
& );
123 USHORT
GetId( SvLBoxEntry
*pEntry
);
124 String
GetHelpText( SvLBoxEntry
*pEntry
);
125 using Window::GetHelpText
;
127 { return GetId( FirstSelected() ); }
128 SvLBoxEntry
* GetLastSelectedEntry();
129 void FunctionSelected();
131 // drag n drop methods
132 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
134 virtual DragDropMode
NotifyStartDrag(
135 TransferDataContainer
&, SvLBoxEntry
* );
137 virtual void DragFinished( sal_Int8
);
140 class SvxConfigGroupListBox_Impl
: public SvTreeListBox
142 SvxGroupInfoArr_Impl aArr
;
145 SvxConfigFunctionListBox_Impl
* pFunctionListBox
;
146 ImageProvider
* m_pImageProvider
;
148 ::com::sun::star::uno::Reference
149 < ::com::sun::star::frame::XFrame
> m_xFrame
;
151 ::com::sun::star::uno::Reference
152 < ::com::sun::star::container::XNameAccess
> m_xModuleCommands
;
162 ::rtl::OUString m_sMyMacros
;
163 ::rtl::OUString m_sProdMacros
;
164 Image
GetImage( ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
> node
, ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> xCtx
, bool bIsRootNode
, bool bHighContrast
);
165 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getDocumentModel( ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xCtx
, ::rtl::OUString
& docName
);
169 const ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
>& _rxRootNode
,
170 SvLBoxEntry
* _pParentEntry
,
171 bool _bCheapChildsOnDemand
175 virtual void RequestingChilds( SvLBoxEntry
*pEntry
);
176 virtual BOOL
Expand( SvLBoxEntry
* pParent
);
177 using SvListView::Expand
;
180 SvxConfigGroupListBox_Impl (
181 Window
* pParent
, const ResId
&,
183 const ::com::sun::star::uno::Reference
184 < ::com::sun::star::frame::XFrame
>& xFrame
187 ~SvxConfigGroupListBox_Impl();
190 void Open( SvLBoxEntry
*, BOOL
);
192 void GroupSelected();
194 void SetFunctionListBox( SvxConfigFunctionListBox_Impl
*pBox
)
195 { pFunctionListBox
= pBox
; }
197 void SetImageProvider( ImageProvider
* provider
)
198 { m_pImageProvider
= provider
; }
201 class SvxScriptSelectorDialog
: public ModelessDialog
203 FixedText aDialogDescription
;
204 FixedText aGroupText
;
205 SvxConfigGroupListBox_Impl aCategories
;
206 FixedText aFunctionText
;
207 SvxConfigFunctionListBox_Impl aCommands
;
209 CancelButton aCancelButton
;
210 HelpButton aHelpButton
;
211 FixedLine aDescription
;
212 FixedText aDescriptionText
;
217 DECL_LINK( ClickHdl
, Button
* );
218 DECL_LINK( SelectHdl
, Control
* );
219 DECL_LINK( FunctionDoubleClickHdl
, Control
* );
222 void ResizeControls();
226 SvxScriptSelectorDialog (
227 Window
* pParent
= NULL
,
228 BOOL bShowSlots
= FALSE
,
229 const ::com::sun::star::uno::Reference
230 < ::com::sun::star::frame::XFrame
>& xFrame
= 0
233 ~SvxScriptSelectorDialog ( );
235 void SetAddHdl( const Link
& rLink
) { m_aAddHdl
= rLink
; }
236 const Link
& GetAddHdl() const { return m_aAddHdl
; }
238 void SetImageProvider( ImageProvider
* provider
)
239 { aCategories
.SetImageProvider( provider
); }
241 USHORT
GetSelectedId();
242 String
GetScriptURL() const;
243 String
GetSelectedDisplayName();
244 String
GetSelectedHelpText();
246 void SetDialogDescription(const String
& rDescription
);