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