1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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 class SvxPasswordDialog
;
42 class NewObjectDialog
: public weld::GenericDialogController
45 std::unique_ptr
<weld::Entry
> m_xEdit
;
46 std::unique_ptr
<weld::Button
> m_xOKButton
;
49 DECL_LINK(OkButtonHandler
, weld::Button
&, void);
51 NewObjectDialog(weld::Window
* pParent
, ObjectMode
, bool bCheckName
= false);
52 OUString
GetObjectName() const { return m_xEdit
->get_text(); }
53 void SetObjectName(const OUString
& rName
)
55 m_xEdit
->set_text(rName
);
56 m_xEdit
->select_region(0, -1);
60 class GotoLineDialog
: public weld::GenericDialogController
62 std::unique_ptr
<weld::Entry
> m_xEdit
;
63 std::unique_ptr
<weld::Button
> m_xOKButton
;
64 DECL_LINK(OkButtonHandler
, weld::Button
&, void);
66 explicit GotoLineDialog(weld::Window
* pParent
);
67 virtual ~GotoLineDialog() override
;
68 sal_Int32
GetLineNumber() const;
71 class ExportDialog
: public weld::GenericDialogController
74 bool m_bExportAsPackage
;
76 std::unique_ptr
<weld::RadioButton
> m_xExportAsPackageButton
;
77 std::unique_ptr
<weld::Button
> m_xOKButton
;
79 DECL_LINK(OkButtonHandler
, weld::Button
&, void);
82 explicit ExportDialog(weld::Window
* pParent
);
83 virtual ~ExportDialog() override
;
85 bool isExportAsPackage () const { return m_bExportAsPackage
; }
88 class LibDialog
: public weld::GenericDialogController
91 std::unique_ptr
<weld::Frame
> m_xStorageFrame
;
92 std::unique_ptr
<weld::TreeView
> m_xLibBox
;
93 std::unique_ptr
<weld::CheckButton
> m_xReferenceBox
;
94 std::unique_ptr
<weld::CheckButton
> m_xReplaceBox
;
97 explicit LibDialog(weld::Window
* pParent
);
98 virtual ~LibDialog() override
;
100 void SetStorageName( std::u16string_view rName
);
102 weld::TreeView
& GetLibBox() { return *m_xLibBox
; }
103 bool IsReference() const { return m_xReferenceBox
->get_active(); }
104 bool IsReplace() const { return m_xReplaceBox
->get_active(); }
106 void EnableReference (bool b
) { m_xReferenceBox
->set_sensitive(b
); }
109 class OrganizeDialog
;
114 OrganizeDialog
* m_pDialog
;
115 std::unique_ptr
<weld::Builder
> m_xBuilder
;
116 std::unique_ptr
<weld::Container
> m_xContainer
;
118 OrganizePage(weld::Container
* pParent
, const OUString
& rUIFile
, const OUString
&rName
, OrganizeDialog
* pDialog
);
119 virtual ~OrganizePage();
122 virtual void ActivatePage() = 0;
125 class SbTreeListBoxDropTarget
;
127 class ObjectPage final
: public OrganizePage
129 std::unique_ptr
<SbTreeListBox
> m_xBasicBox
;
130 std::unique_ptr
<weld::Button
> m_xEditButton
;
131 std::unique_ptr
<weld::Button
> m_xNewModButton
;
132 std::unique_ptr
<weld::Button
> m_xNewDlgButton
;
133 std::unique_ptr
<weld::Button
> m_xDelButton
;
134 std::unique_ptr
<SbTreeListBoxDropTarget
> m_xDropTarget
;
136 DECL_LINK( BasicBoxHighlightHdl
, weld::TreeView
&, void );
137 DECL_LINK( ButtonHdl
, weld::Button
&, void );
138 DECL_LINK( EditingEntryHdl
, const weld::TreeIter
&, bool );
139 typedef std::pair
<const weld::TreeIter
&, OUString
> IterString
;
140 DECL_LINK( EditedEntryHdl
, const IterString
&, bool );
143 bool GetSelection( ScriptDocument
& rDocument
, OUString
& rLibName
);
144 void DeleteCurrent();
150 ObjectPage(weld::Container
* pParent
, const OUString
& rName
, BrowseMode nMode
, OrganizeDialog
* pDialog
);
151 virtual ~ObjectPage() override
;
153 void SetCurrentEntry(const EntryDescriptor
& rDesc
) { m_xBasicBox
->SetCurrentEntry(rDesc
); }
155 virtual void ActivatePage() override
;
158 class LibPage final
: public OrganizePage
160 std::unique_ptr
<weld::ComboBox
> m_xBasicsBox
;
161 std::unique_ptr
<weld::TreeView
> m_xLibBox
;
162 std::unique_ptr
<weld::Button
> m_xEditButton
;
163 std::unique_ptr
<weld::Button
> m_xPasswordButton
;
164 std::unique_ptr
<weld::Button
> m_xNewLibButton
;
165 std::unique_ptr
<weld::Button
> m_xInsertLibButton
;
166 std::unique_ptr
<weld::Button
> m_xExportButton
;
167 std::unique_ptr
<weld::Button
> m_xDelButton
;
169 ScriptDocument m_aCurDocument
;
170 LibraryLocation m_eCurLocation
;
172 DECL_LINK( TreeListHighlightHdl
, weld::TreeView
&, void );
173 DECL_LINK( BasicSelectHdl
, weld::ComboBox
&, void );
174 DECL_LINK( ButtonHdl
, weld::Button
&, void );
175 DECL_LINK( CheckPasswordHdl
, SvxPasswordDialog
*, bool );
176 DECL_LINK( EditingEntryHdl
, const weld::TreeIter
&, bool );
177 typedef std::pair
<const weld::TreeIter
&, OUString
> IterString
;
178 DECL_LINK( EditedEntryHdl
, const IterString
&, bool );
181 void DeleteCurrent();
184 void implExportLib( const OUString
& aLibName
, const OUString
& aTargetURL
,
185 const css::uno::Reference
< css::task::XInteractionHandler
>& Handler
);
187 void ExportAsPackage( const OUString
& aLibName
);
188 void ExportAsBasic( const OUString
& aLibName
);
191 void InsertListBoxEntry( const ScriptDocument
& rDocument
, LibraryLocation eLocation
);
193 void ImpInsertLibEntry( const OUString
& rLibName
, int nPos
);
196 explicit LibPage(weld::Container
* pParent
, OrganizeDialog
* pDialog
);
197 virtual ~LibPage() override
;
198 virtual void ActivatePage() override
;
201 class OrganizeDialog
: public weld::GenericDialogController
204 std::unique_ptr
<weld::Notebook
> m_xTabCtrl
;
205 std::unique_ptr
<ObjectPage
> m_xModulePage
;
206 std::unique_ptr
<ObjectPage
> m_xDialogPage
;
207 std::unique_ptr
<LibPage
> m_xLibPage
;
209 DECL_LINK(ActivatePageHdl
, const OUString
&, void);
211 void SetCurrentEntry(const css::uno::Reference
<css::frame::XFrame
>& xDocFrame
);
214 OrganizeDialog(weld::Window
* pParent
, const css::uno::Reference
<css::frame::XFrame
>& xDocFrame
, sal_Int16 tabId
);
215 virtual ~OrganizeDialog() override
;
219 SbModule
* createModImpl(weld::Window
* pWin
, const ScriptDocument
& rDocument
,
220 SbTreeListBox
& rBasicBox
, const OUString
& rLibName
, const OUString
& aModName
, bool bMain
);
221 void createLibImpl(weld::Window
* pWin
, const ScriptDocument
& rDocument
,
222 weld::TreeView
* pLibBox
, SbTreeListBox
* pBasicBox
);
224 } // namespace basctl
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */