bump product version to 5.0.4.1
[LibreOffice.git] / cui / source / inc / selector.hxx
blob898314dd2c66b6603b08c82909f47a1594dc229e
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 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
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 bool bWasOpened;
50 SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr )
51 :nKind( n )
52 ,nOrd( nr )
53 ,xBrowseNode()
54 ,sURL()
55 ,sHelpText()
56 ,bWasOpened(false)
60 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 ,bWasOpened(false)
70 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 ,bWasOpened(false)
81 typedef boost::ptr_vector<SvxGroupInfo_Impl> SvxGroupInfoArr_Impl;
83 class ImageProvider
85 public:
86 virtual ~ImageProvider() {}
88 virtual Image GetImage( const OUString& rCommandURL ) = 0;
91 class SvxConfigFunctionListBox : public SvTreeListBox
93 friend class SvxConfigGroupListBox;
94 Timer aTimer;
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;
102 public:
103 SvxConfigFunctionListBox(vcl::Window* pParent, WinBits nStyle);
104 virtual ~SvxConfigFunctionListBox();
105 virtual void dispose() SAL_OVERRIDE;
106 void ClearAll();
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;
124 bool m_bShowSlots;
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;
135 Image m_hdImage;
136 Image m_libImage;
137 Image m_macImage;
138 Image m_docImage;
139 OUString m_sMyMacros;
140 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 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getDocumentModel(
148 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xCtx,
149 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) SAL_OVERRIDE;
161 virtual bool Expand( SvTreeListEntry* pParent ) SAL_OVERRIDE;
163 public:
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 );
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 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;
191 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 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();
221 void SetRunLabel();
222 void SetDialogDescription(const OUString& rDescription);
225 #endif
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */