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