Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _SVXSELECTOR_HXX
29 : : #define _SVXSELECTOR_HXX
30 : :
31 : : #include <vcl/lstbox.hxx>
32 : : #include <vcl/fixed.hxx>
33 : : #include <vcl/group.hxx>
34 : : #include <vcl/menubtn.hxx>
35 : : #include <svtools/svtreebx.hxx>
36 : :
37 : : #include <com/sun/star/uno/XComponentContext.hpp>
38 : : #include <com/sun/star/frame/XFrame.hpp>
39 : : #include <com/sun/star/container/XNameAccess.hpp>
40 : : #include <com/sun/star/script/browse/XBrowseNode.hpp>
41 : :
42 : : #include <sfx2/minarray.hxx>
43 : : #include <boost/ptr_container/ptr_vector.hpp>
44 : :
45 : : #define SVX_CFGGROUP_FUNCTION 1
46 : : #define SVX_CFGFUNCTION_SLOT 2
47 : : #define SVX_CFGGROUP_SCRIPTCONTAINER 3
48 : : #define SVX_CFGFUNCTION_SCRIPT 4
49 : :
50 : 0 : struct SvxGroupInfo_Impl
51 : : {
52 : : sal_uInt16 nKind;
53 : : sal_uInt16 nOrd;
54 : : ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >
55 : : xBrowseNode;
56 : : ::rtl::OUString sURL;
57 : : ::rtl::OUString sHelpText;
58 : : sal_Bool bWasOpened;
59 : :
60 : 0 : SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr )
61 : : :nKind( n )
62 : : ,nOrd( nr )
63 : : ,xBrowseNode()
64 : : ,sURL()
65 : : ,sHelpText()
66 : 0 : ,bWasOpened(sal_False)
67 : : {
68 : 0 : }
69 : :
70 : 0 : SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& _rxNode )
71 : : :nKind( n )
72 : : ,nOrd( nr )
73 : : ,xBrowseNode( _rxNode )
74 : : ,sURL()
75 : : ,sHelpText()
76 : 0 : ,bWasOpened(sal_False)
77 : : {
78 : 0 : }
79 : :
80 : 0 : SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, const ::rtl::OUString& _rURL, const ::rtl::OUString& _rHelpText )
81 : : :nKind( n )
82 : : ,nOrd( nr )
83 : : ,xBrowseNode()
84 : : ,sURL( _rURL )
85 : : ,sHelpText( _rHelpText )
86 : 0 : ,bWasOpened(sal_False)
87 : : {
88 : 0 : }
89 : : };
90 : :
91 : : typedef boost::ptr_vector<SvxGroupInfo_Impl> SvxGroupInfoArr_Impl;
92 : :
93 : 0 : class ImageProvider
94 : : {
95 : : public:
96 [ # # ]: 0 : virtual ~ImageProvider() {}
97 : :
98 : : virtual Image GetImage( const rtl::OUString& rCommandURL ) = 0;
99 : : };
100 : :
101 : : class SvxConfigFunctionListBox_Impl : public SvTreeListBox
102 : : {
103 : : friend class SvxConfigGroupListBox_Impl;
104 : : Timer aTimer;
105 : : SvLBoxEntry* pCurEntry;
106 : : SvxGroupInfoArr_Impl aArr;
107 : : SvLBoxEntry* m_pDraggingEntry;
108 : :
109 : : DECL_LINK(TimerHdl, void *);
110 : : virtual void MouseMove( const MouseEvent& rMEvt );
111 : :
112 : : public:
113 : : SvxConfigFunctionListBox_Impl( Window*, const ResId& );
114 : : ~SvxConfigFunctionListBox_Impl();
115 : : void ClearAll();
116 : : String GetHelpText( SvLBoxEntry *pEntry );
117 : : using Window::GetHelpText;
118 : : SvLBoxEntry* GetLastSelectedEntry();
119 : : void FunctionSelected();
120 : :
121 : : // drag n drop methods
122 : : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
123 : :
124 : : virtual DragDropMode NotifyStartDrag(
125 : : TransferDataContainer&, SvLBoxEntry* );
126 : :
127 : : virtual void DragFinished( sal_Int8 );
128 : : };
129 : :
130 : : class SvxConfigGroupListBox_Impl : public SvTreeListBox
131 : : {
132 : : SvxGroupInfoArr_Impl aArr;
133 : : bool m_bShowSlots;
134 : :
135 : : SvxConfigFunctionListBox_Impl* pFunctionListBox;
136 : : ImageProvider* m_pImageProvider;
137 : :
138 : : ::com::sun::star::uno::Reference
139 : : < ::com::sun::star::frame::XFrame > m_xFrame;
140 : :
141 : : ::com::sun::star::uno::Reference
142 : : < ::com::sun::star::container::XNameAccess > m_xModuleCommands;
143 : :
144 : : Image m_hdImage;
145 : : Image m_libImage;
146 : : Image m_macImage;
147 : : Image m_docImage;
148 : : ::rtl::OUString m_sMyMacros;
149 : : ::rtl::OUString m_sProdMacros;
150 : : Image GetImage(
151 : : ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > node,
152 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xCtx,
153 : : bool bIsRootNode
154 : : );
155 : :
156 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getDocumentModel(
157 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xCtx,
158 : : ::rtl::OUString& docName
159 : : );
160 : :
161 : : private:
162 : : void fillScriptList(
163 : : const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& _rxRootNode,
164 : : SvLBoxEntry* _pParentEntry,
165 : : bool _bCheapChildrenOnDemand
166 : : );
167 : :
168 : : protected:
169 : : virtual void RequestingChildren( SvLBoxEntry *pEntry);
170 : : virtual sal_Bool Expand( SvLBoxEntry* pParent );
171 : : using SvListView::Expand;
172 : :
173 : : public:
174 : : SvxConfigGroupListBox_Impl (
175 : : Window* pParent, const ResId&,
176 : : bool _bShowSlots,
177 : : const ::com::sun::star::uno::Reference
178 : : < ::com::sun::star::frame::XFrame >& xFrame
179 : : );
180 : :
181 : : ~SvxConfigGroupListBox_Impl();
182 : :
183 : : void Init();
184 : : void Open( SvLBoxEntry*, sal_Bool );
185 : : void ClearAll();
186 : : void GroupSelected();
187 : :
188 : 0 : void SetFunctionListBox( SvxConfigFunctionListBox_Impl *pBox )
189 : 0 : { pFunctionListBox = pBox; }
190 : :
191 : 0 : void SetImageProvider( ImageProvider* provider )
192 : 0 : { m_pImageProvider = provider; }
193 : : };
194 : :
195 : : class SvxScriptSelectorDialog : public ModelessDialog
196 : : {
197 : : FixedText aDialogDescription;
198 : : FixedText aGroupText;
199 : : SvxConfigGroupListBox_Impl aCategories;
200 : : FixedText aFunctionText;
201 : : SvxConfigFunctionListBox_Impl aCommands;
202 : : OKButton aOKButton;
203 : : CancelButton aCancelButton;
204 : : HelpButton aHelpButton;
205 : : FixedLine aDescription;
206 : : FixedText aDescriptionText;
207 : :
208 : : sal_Bool m_bShowSlots;
209 : : Link m_aAddHdl;
210 : :
211 : : DECL_LINK( ClickHdl, Button * );
212 : : DECL_LINK( SelectHdl, Control* );
213 : : DECL_LINK( FunctionDoubleClickHdl, Control* );
214 : :
215 : : void UpdateUI();
216 : : void ResizeControls();
217 : :
218 : : public:
219 : :
220 : : SvxScriptSelectorDialog (
221 : : Window* pParent = NULL,
222 : : sal_Bool bShowSlots = sal_False,
223 : : const ::com::sun::star::uno::Reference
224 : : < ::com::sun::star::frame::XFrame >& xFrame = 0
225 : : );
226 : :
227 : : ~SvxScriptSelectorDialog ( );
228 : :
229 : 0 : void SetAddHdl( const Link& rLink ) { m_aAddHdl = rLink; }
230 : 0 : const Link& GetAddHdl() const { return m_aAddHdl; }
231 : :
232 : 0 : void SetImageProvider( ImageProvider* provider )
233 : 0 : { aCategories.SetImageProvider( provider ); }
234 : :
235 : : String GetScriptURL() const;
236 : : String GetSelectedDisplayName();
237 : : String GetSelectedHelpText();
238 : : void SetRunLabel();
239 : : void SetDialogDescription(const String& rDescription);
240 : : };
241 : :
242 : : #endif
243 : :
244 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|