Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef _SVXSELECTOR_HXX
20 : #define _SVXSELECTOR_HXX
21 :
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>
27 :
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>
32 :
33 : #include <boost/ptr_container/ptr_vector.hpp>
34 :
35 : #define SVX_CFGGROUP_FUNCTION 1
36 : #define SVX_CFGFUNCTION_SLOT 2
37 : #define SVX_CFGGROUP_SCRIPTCONTAINER 3
38 : #define SVX_CFGFUNCTION_SCRIPT 4
39 :
40 0 : struct SvxGroupInfo_Impl
41 : {
42 : sal_uInt16 nKind;
43 : sal_uInt16 nOrd;
44 : ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >
45 : xBrowseNode;
46 : OUString sURL;
47 : OUString sHelpText;
48 : sal_Bool bWasOpened;
49 :
50 0 : SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr )
51 : :nKind( n )
52 : ,nOrd( nr )
53 : ,xBrowseNode()
54 : ,sURL()
55 : ,sHelpText()
56 0 : ,bWasOpened(sal_False)
57 : {
58 0 : }
59 :
60 0 : SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& _rxNode )
61 : :nKind( n )
62 : ,nOrd( nr )
63 : ,xBrowseNode( _rxNode )
64 : ,sURL()
65 : ,sHelpText()
66 0 : ,bWasOpened(sal_False)
67 : {
68 0 : }
69 :
70 0 : SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, const OUString& _rURL, const OUString& _rHelpText )
71 : :nKind( n )
72 : ,nOrd( nr )
73 : ,xBrowseNode()
74 : ,sURL( _rURL )
75 : ,sHelpText( _rHelpText )
76 0 : ,bWasOpened(sal_False)
77 : {
78 0 : }
79 : };
80 :
81 : typedef boost::ptr_vector<SvxGroupInfo_Impl> SvxGroupInfoArr_Impl;
82 :
83 0 : class ImageProvider
84 : {
85 : public:
86 0 : virtual ~ImageProvider() {}
87 :
88 : virtual Image GetImage( const OUString& rCommandURL ) = 0;
89 : };
90 :
91 : class SvxConfigFunctionListBox : public SvTreeListBox
92 : {
93 : friend class SvxConfigGroupListBox;
94 : Timer aTimer;
95 : SvTreeListEntry* pCurEntry;
96 : SvxGroupInfoArr_Impl aArr;
97 : SvTreeListEntry* m_pDraggingEntry;
98 :
99 : DECL_LINK(TimerHdl, void *);
100 : virtual void MouseMove( const MouseEvent& rMEvt );
101 :
102 : public:
103 : SvxConfigFunctionListBox(Window* pParent);
104 : ~SvxConfigFunctionListBox();
105 : void ClearAll();
106 : String GetHelpText( SvTreeListEntry *pEntry );
107 : using Window::GetHelpText;
108 : SvTreeListEntry* GetLastSelectedEntry();
109 : void FunctionSelected();
110 :
111 : // drag n drop methods
112 : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
113 :
114 : virtual DragDropMode NotifyStartDrag(
115 : TransferDataContainer&, SvTreeListEntry* );
116 :
117 : virtual void DragFinished( sal_Int8 );
118 : };
119 :
120 : class SvxConfigGroupListBox : public SvTreeListBox
121 : {
122 : SvxGroupInfoArr_Impl aArr;
123 : bool m_bShowSlots;
124 :
125 : SvxConfigFunctionListBox* pFunctionListBox;
126 : ImageProvider* m_pImageProvider;
127 :
128 : ::com::sun::star::uno::Reference
129 : < ::com::sun::star::frame::XFrame > m_xFrame;
130 :
131 : ::com::sun::star::uno::Reference
132 : < ::com::sun::star::container::XNameAccess > m_xModuleCommands;
133 :
134 : Image m_hdImage;
135 : Image m_libImage;
136 : Image m_macImage;
137 : Image m_docImage;
138 : OUString m_sMyMacros;
139 : OUString m_sProdMacros;
140 : Image GetImage(
141 : ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > node,
142 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xCtx,
143 : bool bIsRootNode
144 : );
145 :
146 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getDocumentModel(
147 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xCtx,
148 : OUString& docName
149 : );
150 :
151 : private:
152 : void fillScriptList(
153 : const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& _rxRootNode,
154 : SvTreeListEntry* _pParentEntry,
155 : bool _bCheapChildrenOnDemand
156 : );
157 :
158 : protected:
159 : virtual void RequestingChildren( SvTreeListEntry *pEntry);
160 : virtual sal_Bool Expand( SvTreeListEntry* pParent );
161 : using SvListView::Expand;
162 :
163 : public:
164 : SvxConfigGroupListBox(Window* pParent);
165 : ~SvxConfigGroupListBox();
166 :
167 : void Init(bool bShowSlots, const ::com::sun::star::uno::Reference
168 : < ::com::sun::star::frame::XFrame >& xFrame);
169 :
170 : void Open( SvTreeListEntry*, sal_Bool );
171 : void ClearAll();
172 : void GroupSelected();
173 :
174 0 : void SetFunctionListBox( SvxConfigFunctionListBox *pBox )
175 0 : { pFunctionListBox = pBox; }
176 :
177 0 : void SetImageProvider( ImageProvider* provider )
178 0 : { m_pImageProvider = provider; }
179 : };
180 :
181 : class SvxScriptSelectorDialog : public ModelessDialog
182 : {
183 : FixedText* m_pDialogDescription;
184 : SvxConfigGroupListBox* m_pCategories;
185 : SvxConfigFunctionListBox* m_pCommands;
186 : PushButton* m_pOKButton;
187 : PushButton* m_pCancelButton;
188 : VclMultiLineEdit* m_pDescriptionText;
189 : OUString m_sDefaultDesc;
190 : sal_Bool m_bShowSlots;
191 : Link m_aAddHdl;
192 :
193 : DECL_LINK( ClickHdl, Button * );
194 : DECL_LINK( SelectHdl, Control* );
195 : DECL_LINK( FunctionDoubleClickHdl, Control* );
196 :
197 : void UpdateUI();
198 :
199 : public:
200 :
201 : SvxScriptSelectorDialog (
202 : Window* pParent = NULL,
203 : sal_Bool bShowSlots = sal_False,
204 : const ::com::sun::star::uno::Reference
205 : < ::com::sun::star::frame::XFrame >& xFrame = 0
206 : );
207 :
208 : ~SvxScriptSelectorDialog ( );
209 :
210 0 : void SetAddHdl( const Link& rLink ) { m_aAddHdl = rLink; }
211 0 : const Link& GetAddHdl() const { return m_aAddHdl; }
212 :
213 0 : void SetImageProvider(ImageProvider* provider)
214 : {
215 0 : m_pCategories->SetImageProvider(provider);
216 0 : }
217 :
218 : String GetScriptURL() const;
219 : String GetSelectedDisplayName();
220 : void SetRunLabel();
221 : void SetDialogDescription(const String& rDescription);
222 : };
223 :
224 : #endif
225 :
226 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|