update dev300-m58
[ooovba.git] / svx / source / cui / selector.hxx
blobf06c26e03ff4c5c6cff471cc340da36e7b92d2c9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: selector.hxx,v $
10 * $Revision: 1.15 $
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
56 USHORT nKind;
57 USHORT nOrd;
58 ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >
59 xBrowseNode;
60 ::rtl::OUString sURL;
61 ::rtl::OUString sHelpText;
62 BOOL bWasOpened;
64 SvxGroupInfo_Impl( USHORT n, USHORT nr )
65 :nKind( n )
66 ,nOrd( nr )
67 ,xBrowseNode()
68 ,sURL()
69 ,sHelpText()
70 ,bWasOpened(FALSE)
74 SvxGroupInfo_Impl( USHORT n, USHORT nr, const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& _rxNode )
75 :nKind( n )
76 ,nOrd( nr )
77 ,xBrowseNode( _rxNode )
78 ,sURL()
79 ,sHelpText()
80 ,bWasOpened(FALSE)
84 SvxGroupInfo_Impl( USHORT n, USHORT nr, const ::rtl::OUString& _rURL, const ::rtl::OUString& _rHelpText )
85 :nKind( n )
86 ,nOrd( nr )
87 ,xBrowseNode()
88 ,sURL( _rURL )
89 ,sHelpText( _rHelpText )
90 ,bWasOpened(FALSE)
95 typedef SvxGroupInfo_Impl* SvxGroupInfoPtr;
96 SV_DECL_PTRARR_DEL(SvxGroupInfoArr_Impl, SvxGroupInfoPtr, 5, 5)
98 class ImageProvider
100 public:
101 virtual ~ImageProvider() {}
103 virtual Image GetImage( const rtl::OUString& rCommandURL ) = 0;
106 class SvxConfigFunctionListBox_Impl : public SvTreeListBox
108 friend class SvxConfigGroupListBox_Impl;
109 Timer aTimer;
110 SvLBoxEntry* pCurEntry;
111 SvxGroupInfoArr_Impl aArr;
112 SvLBoxEntry* m_pDraggingEntry;
114 DECL_LINK( TimerHdl, Timer* );
115 virtual void MouseMove( const MouseEvent& rMEvt );
117 public:
118 SvxConfigFunctionListBox_Impl( Window*, const ResId& );
119 ~SvxConfigFunctionListBox_Impl();
120 void ClearAll();
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;
126 USHORT GetCurId()
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;
143 bool m_bShowSlots;
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;
154 Image m_hdImage;
155 Image m_hdImage_hc;
156 Image m_libImage;
157 Image m_libImage_hc;
158 Image m_macImage;
159 Image m_macImage_hc;
160 Image m_docImage;
161 Image m_docImage_hc;
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 );
167 private:
168 void fillScriptList(
169 const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& _rxRootNode,
170 SvLBoxEntry* _pParentEntry,
171 bool _bCheapChildsOnDemand
174 protected:
175 virtual void RequestingChilds( SvLBoxEntry *pEntry);
176 virtual BOOL Expand( SvLBoxEntry* pParent );
177 using SvListView::Expand;
179 public:
180 SvxConfigGroupListBox_Impl (
181 Window* pParent, const ResId&,
182 bool _bShowSlots,
183 const ::com::sun::star::uno::Reference
184 < ::com::sun::star::frame::XFrame >& xFrame
187 ~SvxConfigGroupListBox_Impl();
189 void Init();
190 void Open( SvLBoxEntry*, BOOL );
191 void ClearAll();
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;
208 OKButton aOKButton;
209 CancelButton aCancelButton;
210 HelpButton aHelpButton;
211 FixedLine aDescription;
212 FixedText aDescriptionText;
214 BOOL m_bShowSlots;
215 Link m_aAddHdl;
217 DECL_LINK( ClickHdl, Button * );
218 DECL_LINK( SelectHdl, Control* );
220 void UpdateUI();
221 void ResizeControls();
223 public:
225 SvxScriptSelectorDialog (
226 Window* pParent = NULL,
227 BOOL bShowSlots = FALSE,
228 const ::com::sun::star::uno::Reference
229 < ::com::sun::star::frame::XFrame >& xFrame = 0
232 ~SvxScriptSelectorDialog ( );
234 void SetAddHdl( const Link& rLink ) { m_aAddHdl = rLink; }
235 const Link& GetAddHdl() const { return m_aAddHdl; }
237 void SetImageProvider( ImageProvider* provider )
238 { aCategories.SetImageProvider( provider ); }
240 USHORT GetSelectedId();
241 String GetScriptURL() const;
242 String GetSelectedDisplayName();
243 String GetSelectedHelpText();
244 void SetRunLabel();
245 void SetDialogDescription(const String& rDescription);
248 #endif