Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / cui / source / inc / selector.hxx
blob508ca7c76387ceedfb07eb6a6817ccbc6ad02796
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
43 sal_uInt16 nKind;
44 sal_uInt16 nOrd;
45 ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >
46 xBrowseNode;
47 ::rtl::OUString sURL;
48 ::rtl::OUString sHelpText;
49 sal_Bool bWasOpened;
51 SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr )
52 :nKind( n )
53 ,nOrd( nr )
54 ,xBrowseNode()
55 ,sURL()
56 ,sHelpText()
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 )
62 :nKind( n )
63 ,nOrd( nr )
64 ,xBrowseNode( _rxNode )
65 ,sURL()
66 ,sHelpText()
67 ,bWasOpened(sal_False)
71 SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, const ::rtl::OUString& _rURL, const ::rtl::OUString& _rHelpText )
72 :nKind( n )
73 ,nOrd( nr )
74 ,xBrowseNode()
75 ,sURL( _rURL )
76 ,sHelpText( _rHelpText )
77 ,bWasOpened(sal_False)
82 typedef boost::ptr_vector<SvxGroupInfo_Impl> SvxGroupInfoArr_Impl;
84 class ImageProvider
86 public:
87 virtual ~ImageProvider() {}
89 virtual Image GetImage( const rtl::OUString& rCommandURL ) = 0;
92 class SvxConfigFunctionListBox : public SvTreeListBox
94 friend class SvxConfigGroupListBox;
95 Timer aTimer;
96 SvTreeListEntry* pCurEntry;
97 SvxGroupInfoArr_Impl aArr;
98 SvTreeListEntry* m_pDraggingEntry;
100 DECL_LINK(TimerHdl, void *);
101 virtual void MouseMove( const MouseEvent& rMEvt );
103 public:
104 SvxConfigFunctionListBox(Window* pParent);
105 ~SvxConfigFunctionListBox();
106 void ClearAll();
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;
124 bool m_bShowSlots;
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;
135 Image m_hdImage;
136 Image m_libImage;
137 Image m_macImage;
138 Image m_docImage;
139 ::rtl::OUString m_sMyMacros;
140 ::rtl::OUString m_sProdMacros;
141 Image GetImage(
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,
144 bool bIsRootNode
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
152 private:
153 void fillScriptList(
154 const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& _rxRootNode,
155 SvTreeListEntry* _pParentEntry,
156 bool _bCheapChildrenOnDemand
159 protected:
160 virtual void RequestingChildren( SvTreeListEntry *pEntry);
161 virtual sal_Bool Expand( SvTreeListEntry* pParent );
162 using SvListView::Expand;
164 public:
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 );
172 void ClearAll();
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;
192 Link m_aAddHdl;
194 DECL_LINK( ClickHdl, Button * );
195 DECL_LINK( SelectHdl, Control* );
196 DECL_LINK( FunctionDoubleClickHdl, Control* );
198 void UpdateUI();
200 public:
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();
222 void SetRunLabel();
223 void SetDialogDescription(const String& rDescription);
226 #endif
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */