Fix GNU C++ version check
[LibreOffice.git] / basctl / source / basicide / moduldlg.hxx
blob4491a4709371cbb11d67f68c6f32da89deaa1bc8
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 #pragma once
22 #include <sal/config.h>
24 #include <string_view>
26 #include <bastype2.hxx>
27 #include <vcl/weld.hxx>
28 #include <com/sun/star/task/XInteractionHandler.hpp>
30 #include <basctl/basctldllpublic.hxx>
32 class SvxPasswordDialog;
34 namespace basctl
37 enum class ObjectMode
39 Library = 1,
40 Module = 2,
41 Dialog = 3,
44 class NewObjectDialog : public weld::GenericDialogController
46 private:
47 std::unique_ptr<weld::Entry> m_xEdit;
48 std::unique_ptr<weld::Button> m_xOKButton;
49 bool m_bCheckName;
51 DECL_LINK(OkButtonHandler, weld::Button&, void);
52 public:
53 NewObjectDialog(weld::Window* pParent, ObjectMode, bool bCheckName = false);
54 OUString GetObjectName() const { return m_xEdit->get_text(); }
55 void SetObjectName(const OUString& rName)
57 m_xEdit->set_text(rName);
58 m_xEdit->select_region(0, -1);
62 class GotoLineDialog : public weld::GenericDialogController
64 std::unique_ptr<weld::SpinButton> m_xSpinButton;
65 std::unique_ptr<weld::Label> m_xLineCount;
66 std::unique_ptr<weld::Button> m_xOKButton;
67 sal_uInt32 m_nCurLine;
68 sal_uInt32 m_nLineCount;
70 DECL_LINK(OkButtonHandler, weld::Button&, void);
71 public:
72 explicit GotoLineDialog(weld::Window* pParent, sal_uInt32 nCurLine, sal_uInt32 nLineCount);
73 virtual ~GotoLineDialog() override;
74 sal_Int32 GetLineNumber() const;
77 class ExportDialog : public weld::GenericDialogController
79 private:
80 bool m_bExportAsPackage;
82 std::unique_ptr<weld::RadioButton> m_xExportAsPackageButton;
83 std::unique_ptr<weld::Button> m_xOKButton;
85 DECL_LINK(OkButtonHandler, weld::Button&, void);
87 public:
88 explicit ExportDialog(weld::Window * pParent);
89 virtual ~ExportDialog() override;
91 bool isExportAsPackage () const { return m_bExportAsPackage; }
94 class LibDialog : public weld::GenericDialogController
96 private:
97 std::unique_ptr<weld::Frame> m_xStorageFrame;
98 std::unique_ptr<weld::TreeView> m_xLibBox;
99 std::unique_ptr<weld::CheckButton> m_xReferenceBox;
100 std::unique_ptr<weld::CheckButton> m_xReplaceBox;
102 public:
103 explicit LibDialog(weld::Window* pParent);
104 virtual ~LibDialog() override;
106 void SetStorageName( std::u16string_view rName );
108 weld::TreeView& GetLibBox() { return *m_xLibBox; }
109 bool IsReference() const { return m_xReferenceBox->get_active(); }
110 bool IsReplace() const { return m_xReplaceBox->get_active(); }
112 void EnableReference (bool b) { m_xReferenceBox->set_sensitive(b); }
115 class OrganizeDialog;
117 class OrganizePage
119 protected:
120 OrganizeDialog* m_pDialog;
121 std::unique_ptr<weld::Builder> m_xBuilder;
122 std::unique_ptr<weld::Container> m_xContainer;
124 OrganizePage(weld::Container* pParent, const OUString& rUIFile, const OUString &rName, OrganizeDialog* pDialog);
125 virtual ~OrganizePage();
127 public:
128 virtual void ActivatePage() = 0;
131 class SbTreeListBoxDropTarget;
133 class ObjectPage final : public OrganizePage
135 std::unique_ptr<SbTreeListBox> m_xBasicBox;
136 std::unique_ptr<weld::Button> m_xEditButton;
137 std::unique_ptr<weld::Button> m_xNewModButton;
138 std::unique_ptr<weld::Button> m_xNewDlgButton;
139 std::unique_ptr<weld::Button> m_xDelButton;
140 std::unique_ptr<SbTreeListBoxDropTarget> m_xDropTarget;
142 DECL_LINK( BasicBoxHighlightHdl, weld::TreeView&, void );
143 DECL_LINK( ButtonHdl, weld::Button&, void );
144 DECL_LINK( EditingEntryHdl, const weld::TreeIter&, bool );
145 typedef std::pair<const weld::TreeIter&, OUString> IterString;
146 DECL_LINK( EditedEntryHdl, const IterString&, bool );
148 void CheckButtons();
149 bool GetSelection( ScriptDocument& rDocument, OUString& rLibName );
150 void DeleteCurrent();
151 void NewModule();
152 void NewDialog();
153 void EndTabDialog();
155 public:
156 ObjectPage(weld::Container* pParent, const OUString& rName, BrowseMode nMode, OrganizeDialog* pDialog);
157 virtual ~ObjectPage() override;
159 void SetCurrentEntry(const EntryDescriptor& rDesc) { m_xBasicBox->SetCurrentEntry(rDesc); }
161 virtual void ActivatePage() override;
164 class LibPage final : public OrganizePage
166 std::unique_ptr<weld::ComboBox> m_xBasicsBox;
167 std::unique_ptr<weld::TreeView> m_xLibBox;
168 std::unique_ptr<weld::Button> m_xEditButton;
169 std::unique_ptr<weld::Button> m_xPasswordButton;
170 std::unique_ptr<weld::Button> m_xNewLibButton;
171 std::unique_ptr<weld::Button> m_xInsertLibButton;
172 std::unique_ptr<weld::Button> m_xExportButton;
173 std::unique_ptr<weld::Button> m_xDelButton;
175 ScriptDocument m_aCurDocument;
176 LibraryLocation m_eCurLocation;
178 DECL_LINK( TreeListHighlightHdl, weld::TreeView&, void );
179 DECL_LINK( BasicSelectHdl, weld::ComboBox&, void );
180 DECL_LINK( ButtonHdl, weld::Button&, void );
181 DECL_LINK( CheckPasswordHdl, SvxPasswordDialog *, bool );
182 DECL_LINK( EditingEntryHdl, const weld::TreeIter&, bool );
183 typedef std::pair<const weld::TreeIter&, OUString> IterString;
184 DECL_LINK( EditedEntryHdl, const IterString&, bool );
186 void CheckButtons();
187 void DeleteCurrent();
188 void NewLib();
189 void InsertLib();
190 void EndTabDialog();
191 void FillListBox();
192 void InsertListBoxEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
193 void SetCurLib();
194 void ImpInsertLibEntry( const OUString& rLibName, int nPos );
196 public:
197 explicit LibPage(weld::Container* pParent, OrganizeDialog* pDialog);
198 virtual ~LibPage() override;
199 virtual void ActivatePage() override;
202 void implExportLib(const ScriptDocument& rScriptDocument, const OUString& aLibName,
203 const OUString& aTargetURL,
204 const css::uno::Reference<css::task::XInteractionHandler>& Handler);
205 void ExportAsPackage(const ScriptDocument& rScriptDocument, const OUString& aLibName,
206 weld::Dialog* pDialog);
207 void ExportAsBasic(const ScriptDocument& rScriptDocument, const OUString& aLibName,
208 weld::Dialog* pDialog);
210 class OrganizeDialog : public weld::GenericDialogController
212 private:
213 std::unique_ptr<weld::Notebook> m_xTabCtrl;
214 std::unique_ptr<ObjectPage> m_xModulePage;
215 std::unique_ptr<ObjectPage> m_xDialogPage;
216 std::unique_ptr<LibPage> m_xLibPage;
218 DECL_LINK(ActivatePageHdl, const OUString&, void);
220 void SetCurrentEntry(const css::uno::Reference<css::frame::XFrame>& xDocFrame);
222 public:
223 OrganizeDialog(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 tabId);
224 virtual ~OrganizeDialog() override;
227 // Helper functions
228 SbModule* createModImpl(weld::Window* pWin, const ScriptDocument& rDocument,
229 SbTreeListBox& rBasicBox, const OUString& rLibName, const OUString& aModName, bool bMain);
230 void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
231 weld::TreeView* pLibBox, SbTreeListBox* pBasicBox);
233 } // namespace basctl
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */