xref: /AOO41X/main/cui/source/inc/selector.hxx (revision c4eee24dc018e70cce741d2c2ecfc43b06c69c41)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SVXSELECTOR_HXX
24 #define _SVXSELECTOR_HXX
25 
26 #include <vcl/lstbox.hxx>
27 #include <vcl/fixed.hxx>
28 #include <vcl/group.hxx>
29 #include <vcl/menubtn.hxx>
30 #include <svtools/svtreebx.hxx>
31 
32 #include <com/sun/star/uno/XComponentContext.hpp>
33 #include <com/sun/star/frame/XFrame.hpp>
34 #include <com/sun/star/container/XNameAccess.hpp>
35 #include <com/sun/star/script/browse/XBrowseNode.hpp>
36 
37 #define _SVSTDARR_USHORTS
38 #define _SVSTDARR_STRINGSDTOR
39 #include <svl/svstdarr.hxx>     // SvUShorts
40 #include <sfx2/minarray.hxx>
41 
42 #define SVX_CFGGROUP_FUNCTION 1
43 #define SVX_CFGFUNCTION_SLOT  2
44 #define SVX_CFGGROUP_SCRIPTCONTAINER  3
45 #define SVX_CFGFUNCTION_SCRIPT 4
46 
47 struct SvxGroupInfo_Impl
48 {
49     sal_uInt16          nKind;
50     sal_uInt16          nOrd;
51     ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >
52                     xBrowseNode;
53     ::rtl::OUString sURL;
54     ::rtl::OUString sHelpText;
55     sal_Bool            bWasOpened;
56 
SvxGroupInfo_ImplSvxGroupInfo_Impl57     SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr )
58         :nKind( n )
59         ,nOrd( nr )
60         ,xBrowseNode()
61         ,sURL()
62         ,sHelpText()
63         ,bWasOpened(sal_False)
64     {
65     }
66 
SvxGroupInfo_ImplSvxGroupInfo_Impl67     SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& _rxNode )
68         :nKind( n )
69         ,nOrd( nr )
70         ,xBrowseNode( _rxNode )
71         ,sURL()
72         ,sHelpText()
73         ,bWasOpened(sal_False)
74     {
75     }
76 
SvxGroupInfo_ImplSvxGroupInfo_Impl77     SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, const ::rtl::OUString& _rURL, const ::rtl::OUString& _rHelpText )
78         :nKind( n )
79         ,nOrd( nr )
80         ,xBrowseNode()
81         ,sURL( _rURL )
82         ,sHelpText( _rHelpText )
83         ,bWasOpened(sal_False)
84     {
85     }
86 };
87 
88 typedef SvxGroupInfo_Impl* SvxGroupInfoPtr;
89 SV_DECL_PTRARR_DEL(SvxGroupInfoArr_Impl, SvxGroupInfoPtr, 5, 5)
90 
91 class ImageProvider
92 {
93 public:
~ImageProvider()94     virtual ~ImageProvider() {}
95 
96     virtual Image GetImage( const rtl::OUString& rCommandURL ) = 0;
97 };
98 
99 class SvxConfigFunctionListBox_Impl : public SvTreeListBox
100 {
101 friend class SvxConfigGroupListBox_Impl;
102     Timer                           aTimer;
103     SvLBoxEntry*                    pCurEntry;
104     SvxGroupInfoArr_Impl            aArr;
105     SvLBoxEntry*                    m_pDraggingEntry;
106 
107     DECL_LINK(                      TimerHdl, Timer* );
108     virtual void                    MouseMove( const MouseEvent& rMEvt );
109 
110 public:
111                                     SvxConfigFunctionListBox_Impl( Window*, const ResId& );
112                                     ~SvxConfigFunctionListBox_Impl();
113     void                            ClearAll();
114     String                          GetHelpText( SvLBoxEntry *pEntry );
115     using Window::GetHelpText;
116     SvLBoxEntry*                    GetLastSelectedEntry();
117     void                            FunctionSelected();
118 
119     // drag n drop methods
120     virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt );
121 
122     virtual DragDropMode    NotifyStartDrag(
123         TransferDataContainer&, SvLBoxEntry* );
124 
125     virtual void        DragFinished( sal_Int8 );
126 };
127 
128 class SvxConfigGroupListBox_Impl : public SvTreeListBox
129 {
130     SvxGroupInfoArr_Impl            aArr;
131     bool                            m_bShowSlots;
132 
133     SvxConfigFunctionListBox_Impl*  pFunctionListBox;
134     ImageProvider*                  m_pImageProvider;
135 
136     ::com::sun::star::uno::Reference
137         < ::com::sun::star::frame::XFrame > m_xFrame;
138 
139     ::com::sun::star::uno::Reference
140         < ::com::sun::star::container::XNameAccess > m_xModuleCommands;
141 
142     Image m_hdImage;
143     Image m_hdImage_hc;
144     Image m_libImage;
145     Image m_libImage_hc;
146     Image m_macImage;
147     Image m_macImage_hc;
148     Image m_docImage;
149     Image m_docImage_hc;
150     ::rtl::OUString m_sMyMacros;
151     ::rtl::OUString m_sProdMacros;
152     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 );
153     ::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 );
154 
155 private:
156     void    fillScriptList(
157         const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& _rxRootNode,
158         SvLBoxEntry* _pParentEntry,
159         bool _bCheapChildsOnDemand
160     );
161 
162 protected:
163     virtual void    RequestingChilds( SvLBoxEntry *pEntry);
164     virtual sal_Bool    Expand( SvLBoxEntry* pParent );
165     using SvListView::Expand;
166 
167 public:
168             SvxConfigGroupListBox_Impl (
169                 Window* pParent, const ResId&,
170                 bool _bShowSlots,
171                 const ::com::sun::star::uno::Reference
172                     < ::com::sun::star::frame::XFrame >& xFrame
173             );
174 
175             ~SvxConfigGroupListBox_Impl();
176 
177     void    Init();
178     void    Open( SvLBoxEntry*, sal_Bool );
179     void    ClearAll();
180     void    GroupSelected();
181 
SetFunctionListBox(SvxConfigFunctionListBox_Impl * pBox)182     void    SetFunctionListBox( SvxConfigFunctionListBox_Impl *pBox )
183         { pFunctionListBox = pBox; }
184 
SetImageProvider(ImageProvider * provider)185     void    SetImageProvider( ImageProvider* provider )
186         { m_pImageProvider = provider; }
187 };
188 
189 class SvxScriptSelectorDialog : public ModelessDialog
190 {
191     FixedText                       aDialogDescription;
192     FixedText                       aGroupText;
193     SvxConfigGroupListBox_Impl      aCategories;
194     FixedText                       aFunctionText;
195     SvxConfigFunctionListBox_Impl   aCommands;
196     OKButton                        aOKButton;
197     CancelButton                    aCancelButton;
198     HelpButton                      aHelpButton;
199     FixedLine                       aDescription;
200     FixedText                       aDescriptionText;
201 
202     sal_Bool                            m_bShowSlots;
203     Link                            m_aAddHdl;
204 
205     DECL_LINK( ClickHdl, Button * );
206     DECL_LINK( SelectHdl, Control* );
207     DECL_LINK( FunctionDoubleClickHdl, Control* );
208 
209     void                                UpdateUI();
210     void                                ResizeControls();
211 
212 public:
213 
214     SvxScriptSelectorDialog (
215         Window* pParent = NULL,
216         sal_Bool bShowSlots = sal_False,
217         const ::com::sun::star::uno::Reference
218             < ::com::sun::star::frame::XFrame >& xFrame = 0
219     );
220 
221     ~SvxScriptSelectorDialog ( );
222 
SetAddHdl(const Link & rLink)223     void        SetAddHdl( const Link& rLink ) { m_aAddHdl = rLink; }
GetAddHdl() const224     const Link& GetAddHdl() const { return m_aAddHdl; }
225 
SetImageProvider(ImageProvider * provider)226     void        SetImageProvider( ImageProvider* provider )
227         { aCategories.SetImageProvider( provider ); }
228 
229     String      GetScriptURL() const;
230     String      GetSelectedDisplayName();
231     String      GetSelectedHelpText();
232     void        SetRunLabel();
233     void        SetDialogDescription(const String& rDescription);
234 };
235 
236 #endif
237