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 .
19 #ifndef _SVXSELECTOR_HXX
20 #define _SVXSELECTOR_HXX
22 #include <vcl/lstbox.hxx>
23 #include <vcl/fixed.hxx>
24 #include <vcl/group.hxx>
25 #include <vcl/menubtn.hxx>
26 #include <svtools/treelistbox.hxx>
28 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <com/sun/star/frame/XFrame.hpp>
30 #include <com/sun/star/container/XNameAccess.hpp>
31 #include <com/sun/star/script/browse/XBrowseNode.hpp>
33 #include <sfx2/minarray.hxx>
34 #include <boost/ptr_container/ptr_vector.hpp>
36 #define SVX_CFGGROUP_FUNCTION 1
37 #define SVX_CFGFUNCTION_SLOT 2
38 #define SVX_CFGGROUP_SCRIPTCONTAINER 3
39 #define SVX_CFGFUNCTION_SCRIPT 4
41 struct SvxGroupInfo_Impl
45 ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
>
48 ::rtl::OUString sHelpText
;
51 SvxGroupInfo_Impl( sal_uInt16 n
, sal_uInt16 nr
)
57 ,bWasOpened(sal_False
)
61 SvxGroupInfo_Impl( sal_uInt16 n
, sal_uInt16 nr
, const ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
>& _rxNode
)
64 ,xBrowseNode( _rxNode
)
67 ,bWasOpened(sal_False
)
71 SvxGroupInfo_Impl( sal_uInt16 n
, sal_uInt16 nr
, const ::rtl::OUString
& _rURL
, const ::rtl::OUString
& _rHelpText
)
76 ,sHelpText( _rHelpText
)
77 ,bWasOpened(sal_False
)
82 typedef boost::ptr_vector
<SvxGroupInfo_Impl
> SvxGroupInfoArr_Impl
;
87 virtual ~ImageProvider() {}
89 virtual Image
GetImage( const rtl::OUString
& rCommandURL
) = 0;
92 class SvxConfigFunctionListBox
: public SvTreeListBox
94 friend class SvxConfigGroupListBox
;
96 SvTreeListEntry
* pCurEntry
;
97 SvxGroupInfoArr_Impl aArr
;
98 SvTreeListEntry
* m_pDraggingEntry
;
100 DECL_LINK(TimerHdl
, void *);
101 virtual void MouseMove( const MouseEvent
& rMEvt
);
104 SvxConfigFunctionListBox(Window
* pParent
);
105 ~SvxConfigFunctionListBox();
107 String
GetHelpText( SvTreeListEntry
*pEntry
);
108 using Window::GetHelpText
;
109 SvTreeListEntry
* GetLastSelectedEntry();
110 void FunctionSelected();
112 // drag n drop methods
113 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
115 virtual DragDropMode
NotifyStartDrag(
116 TransferDataContainer
&, SvTreeListEntry
* );
118 virtual void DragFinished( sal_Int8
);
121 class SvxConfigGroupListBox
: public SvTreeListBox
123 SvxGroupInfoArr_Impl aArr
;
126 SvxConfigFunctionListBox
* pFunctionListBox
;
127 ImageProvider
* m_pImageProvider
;
129 ::com::sun::star::uno::Reference
130 < ::com::sun::star::frame::XFrame
> m_xFrame
;
132 ::com::sun::star::uno::Reference
133 < ::com::sun::star::container::XNameAccess
> m_xModuleCommands
;
139 ::rtl::OUString m_sMyMacros
;
140 ::rtl::OUString m_sProdMacros
;
142 ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
> node
,
143 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> xCtx
,
147 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getDocumentModel(
148 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xCtx
,
149 ::rtl::OUString
& docName
154 const ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
>& _rxRootNode
,
155 SvTreeListEntry
* _pParentEntry
,
156 bool _bCheapChildrenOnDemand
160 virtual void RequestingChildren( SvTreeListEntry
*pEntry
);
161 virtual sal_Bool
Expand( SvTreeListEntry
* pParent
);
162 using SvListView::Expand
;
165 SvxConfigGroupListBox(Window
* pParent
);
166 ~SvxConfigGroupListBox();
168 void Init(bool bShowSlots
, const ::com::sun::star::uno::Reference
169 < ::com::sun::star::frame::XFrame
>& xFrame
);
171 void Open( SvTreeListEntry
*, sal_Bool
);
173 void GroupSelected();
175 void SetFunctionListBox( SvxConfigFunctionListBox
*pBox
)
176 { pFunctionListBox
= pBox
; }
178 void SetImageProvider( ImageProvider
* provider
)
179 { m_pImageProvider
= provider
; }
182 class SvxScriptSelectorDialog
: public ModelessDialog
184 FixedText
* m_pDialogDescription
;
185 SvxConfigGroupListBox
* m_pCategories
;
186 SvxConfigFunctionListBox
* m_pCommands
;
187 PushButton
* m_pOKButton
;
188 PushButton
* m_pCancelButton
;
189 VclMultiLineEdit
* m_pDescriptionText
;
190 OUString m_sDefaultDesc
;
191 sal_Bool m_bShowSlots
;
194 DECL_LINK( ClickHdl
, Button
* );
195 DECL_LINK( SelectHdl
, Control
* );
196 DECL_LINK( FunctionDoubleClickHdl
, Control
* );
202 SvxScriptSelectorDialog (
203 Window
* pParent
= NULL
,
204 sal_Bool bShowSlots
= sal_False
,
205 const ::com::sun::star::uno::Reference
206 < ::com::sun::star::frame::XFrame
>& xFrame
= 0
209 ~SvxScriptSelectorDialog ( );
211 void SetAddHdl( const Link
& rLink
) { m_aAddHdl
= rLink
; }
212 const Link
& GetAddHdl() const { return m_aAddHdl
; }
214 void SetImageProvider(ImageProvider
* provider
)
216 m_pCategories
->SetImageProvider(provider
);
219 String
GetScriptURL() const;
220 String
GetSelectedDisplayName();
221 String
GetSelectedHelpText();
223 void SetDialogDescription(const String
& rDescription
);
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */