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 INCLUDED_CUI_SOURCE_INC_SELECTOR_HXX
20 #define INCLUDED_CUI_SOURCE_INC_SELECTOR_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 <boost/ptr_container/ptr_vector.hpp>
35 #define SVX_CFGGROUP_FUNCTION 1
36 #define SVX_CFGFUNCTION_SLOT 2
37 #define SVX_CFGGROUP_SCRIPTCONTAINER 3
38 #define SVX_CFGFUNCTION_SCRIPT 4
40 struct SvxGroupInfo_Impl
44 ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
>
50 SvxGroupInfo_Impl( sal_uInt16 n
, sal_uInt16 nr
)
60 SvxGroupInfo_Impl( sal_uInt16 n
, sal_uInt16 nr
, const ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
>& _rxNode
)
63 ,xBrowseNode( _rxNode
)
70 SvxGroupInfo_Impl( sal_uInt16 n
, sal_uInt16 nr
, const OUString
& _rURL
, const OUString
& _rHelpText
)
75 ,sHelpText( _rHelpText
)
81 typedef boost::ptr_vector
<SvxGroupInfo_Impl
> SvxGroupInfoArr_Impl
;
86 virtual ~ImageProvider() {}
88 virtual Image
GetImage( const OUString
& rCommandURL
) = 0;
91 class SvxConfigFunctionListBox
: public SvTreeListBox
93 friend class SvxConfigGroupListBox
;
95 SvTreeListEntry
* pCurEntry
;
96 SvxGroupInfoArr_Impl aArr
;
97 SvTreeListEntry
* m_pDraggingEntry
;
99 DECL_LINK_TYPED(TimerHdl
, Timer
*, void);
100 virtual void MouseMove( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
103 SvxConfigFunctionListBox(vcl::Window
* pParent
, WinBits nStyle
);
104 virtual ~SvxConfigFunctionListBox();
105 virtual void dispose() SAL_OVERRIDE
;
107 OUString
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
) SAL_OVERRIDE
;
115 virtual DragDropMode
NotifyStartDrag(
116 TransferDataContainer
&, SvTreeListEntry
* ) SAL_OVERRIDE
;
118 virtual void DragFinished( sal_Int8
) SAL_OVERRIDE
;
121 class SvxConfigGroupListBox
: public SvTreeListBox
123 SvxGroupInfoArr_Impl aArr
;
126 VclPtr
<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 OUString m_sMyMacros
;
140 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 static ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getDocumentModel(
148 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xCtx
,
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
) SAL_OVERRIDE
;
161 virtual bool Expand( SvTreeListEntry
* pParent
) SAL_OVERRIDE
;
164 SvxConfigGroupListBox(vcl::Window
* pParent
, WinBits nStyle
);
165 virtual ~SvxConfigGroupListBox();
166 virtual void dispose() SAL_OVERRIDE
;
168 void Init(bool bShowSlots
, const ::com::sun::star::uno::Reference
169 < ::com::sun::star::frame::XFrame
>& xFrame
);
171 void Open( SvTreeListEntry
*, 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 VclPtr
<FixedText
> m_pDialogDescription
;
185 VclPtr
<SvxConfigGroupListBox
> m_pCategories
;
186 VclPtr
<SvxConfigFunctionListBox
> m_pCommands
;
187 VclPtr
<PushButton
> m_pOKButton
;
188 VclPtr
<PushButton
> m_pCancelButton
;
189 VclPtr
<VclMultiLineEdit
> m_pDescriptionText
;
190 OUString m_sDefaultDesc
;
194 DECL_LINK( ClickHdl
, Button
* );
195 DECL_LINK( SelectHdl
, Control
* );
196 DECL_LINK( FunctionDoubleClickHdl
, Control
* );
202 SvxScriptSelectorDialog (
203 vcl::Window
* pParent
= NULL
,
204 bool bShowSlots
= false,
205 const ::com::sun::star::uno::Reference
206 < ::com::sun::star::frame::XFrame
>& xFrame
= 0
208 virtual ~SvxScriptSelectorDialog();
209 virtual void dispose() SAL_OVERRIDE
;
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 OUString
GetScriptURL() const;
220 OUString
GetSelectedDisplayName();
222 void SetDialogDescription(const OUString
& rDescription
);
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */