Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #ifndef _MODULDLG_HXX
21 : : #define _MODULDLG_HXX
22 : :
23 : : #include <svheader.hxx>
24 : :
25 : : #include <bastype2.hxx>
26 : : #include <vcl/dialog.hxx>
27 : :
28 : : #include <vcl/button.hxx>
29 : : #include <vcl/fixed.hxx>
30 : : #include <svtools/svtabbx.hxx>
31 : : #include <vcl/tabdlg.hxx>
32 : : #include <vcl/tabpage.hxx>
33 : : #include "com/sun/star/task/XInteractionHandler.hpp"
34 : :
35 : : #include <vcl/tabctrl.hxx>
36 : : #include <vcl/lstbox.hxx>
37 : :
38 : : enum NewObjectMode
39 : : {
40 : : NEWOBJECTMODE_LIB = 1,
41 : : NEWOBJECTMODE_MOD = 2,
42 : : NEWOBJECTMODE_DLG = 3,
43 : : NEWOBJECTMODE_METH = 4
44 : : };
45 : :
46 : : class NewObjectDialog : public ModalDialog
47 : : {
48 : : private:
49 : : FixedText aText;
50 : : Edit aEdit;
51 : : OKButton aOKButton;
52 : : CancelButton aCancelButton;
53 : :
54 : : DECL_LINK(OkButtonHandler, void *);
55 : :
56 : : public:
57 : : NewObjectDialog(Window * pParent, NewObjectMode nMode, bool bCheckName = false);
58 : : ~NewObjectDialog();
59 : :
60 : 0 : String GetObjectName() const { return aEdit.GetText(); }
61 : 0 : void SetObjectName( const String& rName ) { aEdit.SetText( rName ); aEdit.SetSelection( Selection( 0, rName.Len() ) );}
62 : : };
63 : :
64 : 0 : class GotoLineDialog : public ModalDialog
65 : : {
66 : : FixedText aText;
67 : : Edit aEdit;
68 : : OKButton aOKButton;
69 : : CancelButton aCancelButton;
70 : : DECL_LINK(OkButtonHandler, void *);
71 : : public:
72 : : GotoLineDialog( Window * pParent );
73 : : sal_Int32 GetLineNumber();
74 : : };
75 : :
76 : : class ExportDialog : public ModalDialog
77 : : {
78 : : private:
79 : : RadioButton maExportAsPackageButton;
80 : : RadioButton maExportAsBasicButton;
81 : : OKButton maOKButton;
82 : : CancelButton maCancelButton;
83 : :
84 : : bool mbExportAsPackage;
85 : :
86 : : DECL_LINK(OkButtonHandler, void *);
87 : :
88 : : public:
89 : : ExportDialog( Window * pParent );
90 : : ~ExportDialog();
91 : :
92 : 0 : bool isExportAsPackage () { return mbExportAsPackage; }
93 : : };
94 : :
95 : :
96 : : class ExtBasicTreeListBox : public BasicTreeListBox
97 : : {
98 : : protected:
99 : : virtual sal_Bool EditingEntry( SvLBoxEntry* pEntry, Selection& rSel );
100 : : virtual sal_Bool EditedEntry( SvLBoxEntry* pEntry, const rtl::OUString& rNewText );
101 : :
102 : : virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData, SvLBoxEntry* pEntry );
103 : : virtual sal_Bool NotifyAcceptDrop( SvLBoxEntry* pEntry );
104 : :
105 : : virtual sal_Bool NotifyMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
106 : : SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos );
107 : : virtual sal_Bool NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
108 : : SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos );
109 : : sal_Bool NotifyCopyingMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
110 : : SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos, sal_Bool bMove );
111 : :
112 : : public:
113 : : ExtBasicTreeListBox( Window* pParent, const ResId& rRes );
114 : : ~ExtBasicTreeListBox();
115 : : };
116 : :
117 : : #define LIBMODE_CHOOSER 1
118 : : #define LIBMODE_MANAGER 2
119 : :
120 : : class BasicCheckBox : public SvTabListBox
121 : : {
122 : : private:
123 : : NewObjectMode nMode;
124 : : SvLBoxButtonData* pCheckButton;
125 : : ScriptDocument m_aDocument;
126 : : void Init();
127 : :
128 : : public:
129 : : BasicCheckBox( Window* pParent, const ResId& rResId );
130 : : ~BasicCheckBox();
131 : :
132 : : SvLBoxEntry* DoInsertEntry( const String& rStr, sal_uLong nPos = LISTBOX_APPEND );
133 : : SvLBoxEntry* FindEntry( const String& rName );
134 : :
135 : : void CheckEntryPos( sal_uLong nPos );
136 : : bool IsChecked( sal_uLong nPos ) const;
137 : :
138 : : virtual void InitEntry( SvLBoxEntry*, const XubString&, const Image&, const Image&, SvLBoxButtonKind eButtonKind );
139 : : virtual sal_Bool EditingEntry( SvLBoxEntry* pEntry, Selection& rSel );
140 : : virtual sal_Bool EditedEntry( SvLBoxEntry* pEntry, const rtl::OUString& rNewText );
141 : :
142 : 0 : void SetDocument( const ScriptDocument& rDocument ) { m_aDocument = rDocument; }
143 : :
144 : : void SetMode( NewObjectMode n );
145 : : NewObjectMode GetMode() const { return nMode; }
146 : : };
147 : :
148 : : class LibDialog: public ModalDialog
149 : : {
150 : : private:
151 : : OKButton aOKButton;
152 : : CancelButton aCancelButton;
153 : : FixedText aStorageName;
154 : : BasicCheckBox aLibBox;
155 : : FixedLine aFixedLine;
156 : : CheckBox aReferenceBox;
157 : : CheckBox aReplaceBox;
158 : :
159 : : public:
160 : : LibDialog( Window* pParent );
161 : : ~LibDialog();
162 : :
163 : : void SetStorageName( const ::rtl::OUString& rName );
164 : :
165 : 0 : BasicCheckBox& GetLibBox() { return aLibBox; }
166 : 0 : bool IsReference() const { return aReferenceBox.IsChecked(); }
167 : 0 : bool IsReplace() const { return aReplaceBox.IsChecked(); }
168 : :
169 : 0 : void EnableReference (bool b) { aReferenceBox.Enable(b); }
170 : : void EnableReplace (bool b) { aReplaceBox.Enable(b); }
171 : : };
172 : :
173 : :
174 : : class OrganizeDialog : public TabDialog
175 : : {
176 : : private:
177 : : TabControl aTabCtrl;
178 : : BasicEntryDescriptor m_aCurEntry;
179 : :
180 : : public:
181 : : OrganizeDialog( Window* pParent, sal_Int16 tabId, BasicEntryDescriptor& rDesc );
182 : : ~OrganizeDialog();
183 : :
184 : : virtual short Execute();
185 : :
186 : : DECL_LINK( ActivatePageHdl, TabControl * );
187 : : };
188 : :
189 : 0 : class ObjectPage: public TabPage
190 : : {
191 : : protected:
192 : : FixedText aLibText;
193 : : ExtBasicTreeListBox aBasicBox;
194 : : PushButton aEditButton;
195 : : CancelButton aCloseButton;
196 : : PushButton aNewModButton;
197 : : PushButton aNewDlgButton;
198 : : PushButton aDelButton;
199 : :
200 : : DECL_LINK( BasicBoxHighlightHdl, BasicTreeListBox * );
201 : : DECL_LINK( ButtonHdl, Button * );
202 : : void CheckButtons();
203 : : bool GetSelection( ScriptDocument& rDocument, ::rtl::OUString& rLibName );
204 : : void DeleteCurrent();
205 : : void NewModule();
206 : : void NewDialog();
207 : : void EndTabDialog( sal_uInt16 nRet );
208 : :
209 : : TabDialog* pTabDlg;
210 : :
211 : : virtual void ActivatePage();
212 : : virtual void DeactivatePage();
213 : :
214 : : public:
215 : : ObjectPage( Window* pParent, const ResId& rResId, sal_uInt16 nMode );
216 : :
217 : : void SetCurrentEntry( BasicEntryDescriptor& rDesc );
218 : 0 : void SetTabDlg( TabDialog* p ) { pTabDlg = p;}
219 : : };
220 : :
221 : :
222 : : class SvxPasswordDialog;
223 : :
224 : : class LibPage: public TabPage
225 : : {
226 : : protected:
227 : : FixedText aBasicsText;
228 : : ListBox aBasicsBox;
229 : : FixedText aLibText;
230 : : BasicCheckBox aLibBox;
231 : : PushButton aEditButton;
232 : : CancelButton aCloseButton;
233 : : PushButton aPasswordButton;
234 : : PushButton aNewLibButton;
235 : : PushButton aInsertLibButton;
236 : : PushButton aExportButton;
237 : : PushButton aDelButton;
238 : :
239 : : ScriptDocument m_aCurDocument;
240 : : LibraryLocation m_eCurLocation;
241 : :
242 : : DECL_LINK( TreeListHighlightHdl, SvTreeListBox * );
243 : : DECL_LINK( BasicSelectHdl, ListBox * );
244 : : DECL_LINK( ButtonHdl, Button * );
245 : : DECL_LINK( CheckPasswordHdl, SvxPasswordDialog * );
246 : : void CheckButtons();
247 : : void DeleteCurrent();
248 : : void NewLib();
249 : : void InsertLib();
250 : : void implExportLib( const String& aLibName, const String& aTargetURL,
251 : : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler );
252 : : void Export();
253 : : void ExportAsPackage( const String& aLibName );
254 : : void ExportAsBasic( const String& aLibName );
255 : : void EndTabDialog( sal_uInt16 nRet );
256 : : void FillListBox();
257 : : void InsertListBoxEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
258 : : void SetCurLib();
259 : : SvLBoxEntry* ImpInsertLibEntry( const String& rLibName, sal_uLong nPos );
260 : : virtual void ActivatePage();
261 : : virtual void DeactivatePage();
262 : :
263 : : TabDialog* pTabDlg;
264 : :
265 : : public:
266 : : LibPage( Window* pParent );
267 : : virtual ~LibPage();
268 : :
269 : 0 : void SetTabDlg( TabDialog* p ) { pTabDlg = p;}
270 : : };
271 : :
272 : : // Helper functions
273 : : SbModule* createModImpl( Window* pWin, const ScriptDocument& rDocument,
274 : : BasicTreeListBox& rBasicBox, const ::rtl::OUString& rLibName, ::rtl::OUString aModName, bool bMain = false );
275 : : void createLibImpl( Window* pWin, const ScriptDocument& rDocument,
276 : : BasicCheckBox* pLibBox, BasicTreeListBox* pBasicBox );
277 : :
278 : : #endif // _MODULDLG_HXX
279 : :
280 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|