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