Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / basctl / source / basicide / moduldlg.hxx
blobadb1e661cd0a7d85500e48eec46c479c1265dbd9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_BASCTL_SOURCE_BASICIDE_MODULDLG_HXX
21 #define INCLUDED_BASCTL_SOURCE_BASICIDE_MODULDLG_HXX
23 #include <bastype2.hxx>
24 #include <svtools/svtabbx.hxx>
25 #include <vcl/layout.hxx>
26 #include <vcl/lstbox.hxx>
27 #include <vcl/tabctrl.hxx>
28 #include <vcl/tabdlg.hxx>
29 #include <vcl/tabpage.hxx>
30 #include <vcl/weld.hxx>
31 #include <com/sun/star/task/XInteractionHandler.hpp>
33 class SvxPasswordDialog;
35 namespace basctl
38 enum class ObjectMode
40 Library = 1,
41 Module = 2,
42 Dialog = 3,
45 class NewObjectDialog : public weld::GenericDialogController
47 private:
48 std::unique_ptr<weld::Entry> m_xEdit;
49 std::unique_ptr<weld::Button> m_xOKButton;
50 bool m_bCheckName;
52 DECL_LINK(OkButtonHandler, weld::Button&, void);
53 public:
54 NewObjectDialog(weld::Window* pParent, ObjectMode, bool bCheckName = false);
55 OUString GetObjectName() const { return m_xEdit->get_text(); }
56 void SetObjectName(const OUString& rName)
58 m_xEdit->set_text(rName);
59 m_xEdit->select_region(0, -1);
63 class GotoLineDialog : public weld::GenericDialogController
65 std::unique_ptr<weld::Entry> m_xEdit;
66 std::unique_ptr<weld::Button> m_xOKButton;
67 DECL_LINK(OkButtonHandler, weld::Button&, void);
68 public:
69 explicit GotoLineDialog(weld::Window* pParent);
70 virtual ~GotoLineDialog() override;
71 sal_Int32 GetLineNumber() const;
74 class ExportDialog : public weld::GenericDialogController
76 private:
77 bool m_bExportAsPackage;
79 std::unique_ptr<weld::RadioButton> m_xExportAsPackageButton;
80 std::unique_ptr<weld::Button> m_xOKButton;
82 DECL_LINK(OkButtonHandler, weld::Button&, void);
84 public:
85 explicit ExportDialog(weld::Window * pParent);
86 virtual ~ExportDialog() override;
88 bool isExportAsPackage () const { return m_bExportAsPackage; }
91 class ExtTreeListBox final : public TreeListBox
93 virtual bool EditingEntry( SvTreeListEntry* pEntry, Selection& rSel ) override;
94 virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ) override;
96 virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData, SvTreeListEntry* pEntry ) override;
97 virtual bool NotifyAcceptDrop( SvTreeListEntry* pEntry ) override;
99 virtual TriState NotifyMoving( SvTreeListEntry* pTarget, SvTreeListEntry* pEntry,
100 SvTreeListEntry*& rpNewParent, sal_uLong& rNewChildPos ) override;
101 virtual TriState NotifyCopying( SvTreeListEntry* pTarget, SvTreeListEntry* pEntry,
102 SvTreeListEntry*& rpNewParent, sal_uLong& rNewChildPos ) override;
103 TriState NotifyCopyingMoving( SvTreeListEntry* pTarget, SvTreeListEntry const * pEntry,
104 SvTreeListEntry*& rpNewParent, sal_uLong& rNewChildPos, bool bMove );
106 public:
107 ExtTreeListBox(vcl::Window* pParent, WinBits nStyle);
110 class CheckBox : public SvTabListBox
112 private:
113 ObjectMode eMode;
114 SvLBoxButtonData* pCheckButton;
115 ScriptDocument m_aDocument;
116 void Init();
118 public:
119 CheckBox(vcl::Window* pParent, WinBits nStyle);
120 virtual ~CheckBox() override;
121 virtual void dispose() override;
123 SvTreeListEntry* DoInsertEntry( const OUString& rStr, sal_uLong nPos = LISTBOX_APPEND );
124 SvTreeListEntry* FindEntry( const OUString& rName );
126 void CheckEntryPos( sal_uLong nPos );
127 bool IsChecked( sal_uLong nPos ) const;
129 virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&, SvLBoxButtonKind eButtonKind) override;
130 virtual bool EditingEntry( SvTreeListEntry* pEntry, Selection& rSel ) override;
131 virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ) override;
133 void SetDocument( const ScriptDocument& rDocument ) { m_aDocument = rDocument; }
135 void SetMode(ObjectMode);
138 class LibDialog: public ModalDialog
140 private:
141 VclPtr<VclFrame> m_pStorageFrame;
142 VclPtr<CheckBox> m_pLibBox;
143 VclPtr< ::CheckBox> m_pReferenceBox;
144 VclPtr< ::CheckBox> m_pReplaceBox;
146 public:
147 explicit LibDialog(vcl::Window* pParent);
148 virtual ~LibDialog() override;
149 virtual void dispose() override;
151 void SetStorageName( const OUString& rName );
153 CheckBox& GetLibBox() { return *m_pLibBox; }
154 bool IsReference() const { return m_pReferenceBox->IsChecked(); }
155 bool IsReplace() const { return m_pReplaceBox->IsChecked(); }
157 void EnableReference (bool b) { m_pReferenceBox->Enable(b); }
160 class OrganizeDialog : public TabDialog
162 private:
163 VclPtr<TabControl> m_pTabCtrl;
164 EntryDescriptor m_aCurEntry;
166 public:
167 OrganizeDialog( vcl::Window* pParent, sal_Int16 tabId, EntryDescriptor const & rDesc );
168 virtual ~OrganizeDialog() override;
169 virtual void dispose() override;
171 DECL_LINK( ActivatePageHdl, TabControl*, void );
174 class ObjectPage final : public TabPage
176 VclPtr<ExtTreeListBox> m_pBasicBox;
177 VclPtr<PushButton> m_pEditButton;
178 VclPtr<PushButton> m_pNewModButton;
179 VclPtr<PushButton> m_pNewDlgButton;
180 VclPtr<PushButton> m_pDelButton;
182 DECL_LINK( BasicBoxHighlightHdl, SvTreeListBox*, void );
183 DECL_LINK( ButtonHdl, Button *, void );
184 void CheckButtons();
185 bool GetSelection( ScriptDocument& rDocument, OUString& rLibName );
186 void DeleteCurrent();
187 void NewModule();
188 void NewDialog();
189 void EndTabDialog();
191 VclPtr<TabDialog> pTabDlg;
193 virtual void ActivatePage() override;
194 virtual void DeactivatePage() override;
196 public:
197 ObjectPage(vcl::Window* pParent, const OString& rName, BrowseMode nMode);
198 virtual ~ObjectPage() override;
199 virtual void dispose() override;
201 void SetCurrentEntry( EntryDescriptor const & rDesc );
202 void SetTabDlg( TabDialog* p ) { pTabDlg = p;}
206 class LibPage final : public TabPage
208 VclPtr<ListBox> m_pBasicsBox;
209 VclPtr<CheckBox> m_pLibBox;
210 VclPtr<PushButton> m_pEditButton;
211 VclPtr<PushButton> m_pPasswordButton;
212 VclPtr<PushButton> m_pNewLibButton;
213 VclPtr<PushButton> m_pInsertLibButton;
214 VclPtr<PushButton> m_pExportButton;
215 VclPtr<PushButton> m_pDelButton;
217 ScriptDocument m_aCurDocument;
218 LibraryLocation m_eCurLocation;
220 DECL_LINK( TreeListHighlightHdl, SvTreeListBox *, void );
221 DECL_LINK( BasicSelectHdl, ListBox&, void );
222 DECL_LINK( ButtonHdl, Button *, void );
223 DECL_LINK( CheckPasswordHdl, SvxPasswordDialog *, bool );
224 void CheckButtons();
225 void DeleteCurrent();
226 void NewLib();
227 void InsertLib();
228 void implExportLib( const OUString& aLibName, const OUString& aTargetURL,
229 const css::uno::Reference< css::task::XInteractionHandler >& Handler );
230 void Export();
231 void ExportAsPackage( const OUString& aLibName );
232 void ExportAsBasic( const OUString& aLibName );
233 void EndTabDialog();
234 void FillListBox();
235 void InsertListBoxEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
236 void SetCurLib();
237 SvTreeListEntry* ImpInsertLibEntry( const OUString& rLibName, sal_uLong nPos );
238 virtual void ActivatePage() override;
239 virtual void DeactivatePage() override;
241 VclPtr<TabDialog> pTabDlg;
243 public:
244 explicit LibPage(vcl::Window* pParent);
245 virtual ~LibPage() override;
246 virtual void dispose() override;
248 void SetTabDlg( TabDialog* p ) { pTabDlg = p;}
251 // Helper functions
252 SbModule* createModImpl(weld::Window* pWin, const ScriptDocument& rDocument,
253 TreeListBox& rBasicBox, const OUString& rLibName, const OUString& aModName, bool bMain);
254 void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
255 CheckBox* pLibBox, TreeListBox* pBasicBox);
257 } // namespace basctl
259 #endif // INCLUDED_BASCTL_SOURCE_BASICIDE_MODULDLG_HXX
261 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */