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 <tools/solar.h>
28 #include <vcl/weld.hxx>
29 #include <com/sun/star/task/XInteractionHandler.hpp>
31 class SvxPasswordDialog
;
43 class NewObjectDialog
: public weld::GenericDialogController
46 std::unique_ptr
<weld::Entry
> m_xEdit
;
47 std::unique_ptr
<weld::Button
> m_xOKButton
;
50 DECL_LINK(OkButtonHandler
, weld::Button
&, void);
52 NewObjectDialog(weld::Window
* pParent
, ObjectMode
, bool bCheckName
= false);
53 OUString
GetObjectName() const { return m_xEdit
->get_text(); }
54 void SetObjectName(const OUString
& rName
)
56 m_xEdit
->set_text(rName
);
57 m_xEdit
->select_region(0, -1);
61 class GotoLineDialog
: public weld::GenericDialogController
63 std::unique_ptr
<weld::Entry
> m_xEdit
;
64 std::unique_ptr
<weld::Button
> m_xOKButton
;
65 DECL_LINK(OkButtonHandler
, weld::Button
&, void);
67 explicit GotoLineDialog(weld::Window
* pParent
);
68 virtual ~GotoLineDialog() override
;
69 sal_Int32
GetLineNumber() const;
72 class ExportDialog
: public weld::GenericDialogController
75 bool m_bExportAsPackage
;
77 std::unique_ptr
<weld::RadioButton
> m_xExportAsPackageButton
;
78 std::unique_ptr
<weld::Button
> m_xOKButton
;
80 DECL_LINK(OkButtonHandler
, weld::Button
&, void);
83 explicit ExportDialog(weld::Window
* pParent
);
84 virtual ~ExportDialog() override
;
86 bool isExportAsPackage () const { return m_bExportAsPackage
; }
89 class LibDialog
: public weld::GenericDialogController
92 std::unique_ptr
<weld::Frame
> m_xStorageFrame
;
93 std::unique_ptr
<weld::TreeView
> m_xLibBox
;
94 std::unique_ptr
<weld::CheckButton
> m_xReferenceBox
;
95 std::unique_ptr
<weld::CheckButton
> m_xReplaceBox
;
98 explicit LibDialog(weld::Window
* pParent
);
99 virtual ~LibDialog() override
;
101 void SetStorageName( std::u16string_view rName
);
103 weld::TreeView
& GetLibBox() { return *m_xLibBox
; }
104 bool IsReference() const { return m_xReferenceBox
->get_active(); }
105 bool IsReplace() const { return m_xReplaceBox
->get_active(); }
107 void EnableReference (bool b
) { m_xReferenceBox
->set_sensitive(b
); }
110 class OrganizeDialog
;
115 OrganizeDialog
* m_pDialog
;
116 std::unique_ptr
<weld::Builder
> m_xBuilder
;
117 std::unique_ptr
<weld::Container
> m_xContainer
;
119 OrganizePage(weld::Container
* pParent
, const OUString
& rUIFile
, const OString
&rName
, OrganizeDialog
* pDialog
);
120 virtual ~OrganizePage();
123 virtual void ActivatePage() = 0;
126 class SbTreeListBoxDropTarget
;
128 class ObjectPage final
: public OrganizePage
130 std::unique_ptr
<SbTreeListBox
> m_xBasicBox
;
131 std::unique_ptr
<weld::Button
> m_xEditButton
;
132 std::unique_ptr
<weld::Button
> m_xNewModButton
;
133 std::unique_ptr
<weld::Button
> m_xNewDlgButton
;
134 std::unique_ptr
<weld::Button
> m_xDelButton
;
135 std::unique_ptr
<SbTreeListBoxDropTarget
> m_xDropTarget
;
137 DECL_LINK( BasicBoxHighlightHdl
, weld::TreeView
&, void );
138 DECL_LINK( ButtonHdl
, weld::Button
&, void );
139 DECL_LINK( EditingEntryHdl
, const weld::TreeIter
&, bool );
140 typedef std::pair
<const weld::TreeIter
&, OUString
> IterString
;
141 DECL_LINK( EditedEntryHdl
, const IterString
&, bool );
144 bool GetSelection( ScriptDocument
& rDocument
, OUString
& rLibName
);
145 void DeleteCurrent();
151 ObjectPage(weld::Container
* pParent
, const OString
& rName
, BrowseMode nMode
, OrganizeDialog
* pDialog
);
152 virtual ~ObjectPage() override
;
154 virtual void ActivatePage() override
;
157 class LibPage final
: public OrganizePage
159 std::unique_ptr
<weld::ComboBox
> m_xBasicsBox
;
160 std::unique_ptr
<weld::TreeView
> m_xLibBox
;
161 std::unique_ptr
<weld::Button
> m_xEditButton
;
162 std::unique_ptr
<weld::Button
> m_xPasswordButton
;
163 std::unique_ptr
<weld::Button
> m_xNewLibButton
;
164 std::unique_ptr
<weld::Button
> m_xInsertLibButton
;
165 std::unique_ptr
<weld::Button
> m_xExportButton
;
166 std::unique_ptr
<weld::Button
> m_xDelButton
;
168 ScriptDocument m_aCurDocument
;
169 LibraryLocation m_eCurLocation
;
171 DECL_LINK( TreeListHighlightHdl
, weld::TreeView
&, void );
172 DECL_LINK( BasicSelectHdl
, weld::ComboBox
&, void );
173 DECL_LINK( ButtonHdl
, weld::Button
&, void );
174 DECL_LINK( CheckPasswordHdl
, SvxPasswordDialog
*, bool );
175 DECL_LINK( EditingEntryHdl
, const weld::TreeIter
&, bool );
176 typedef std::pair
<const weld::TreeIter
&, OUString
> IterString
;
177 DECL_LINK( EditedEntryHdl
, const IterString
&, bool );
180 void DeleteCurrent();
183 void implExportLib( const OUString
& aLibName
, const OUString
& aTargetURL
,
184 const css::uno::Reference
< css::task::XInteractionHandler
>& Handler
);
186 void ExportAsPackage( const OUString
& aLibName
);
187 void ExportAsBasic( const OUString
& aLibName
);
190 void InsertListBoxEntry( const ScriptDocument
& rDocument
, LibraryLocation eLocation
);
192 void ImpInsertLibEntry( const OUString
& rLibName
, int nPos
);
195 explicit LibPage(weld::Container
* pParent
, OrganizeDialog
* pDialog
);
196 virtual ~LibPage() override
;
197 virtual void ActivatePage() override
;
200 class OrganizeDialog
: public weld::GenericDialogController
203 std::unique_ptr
<weld::Notebook
> m_xTabCtrl
;
204 std::unique_ptr
<ObjectPage
> m_xModulePage
;
205 std::unique_ptr
<ObjectPage
> m_xDialogPage
;
206 std::unique_ptr
<LibPage
> m_xLibPage
;
208 DECL_LINK(ActivatePageHdl
, const OString
&, void);
211 OrganizeDialog(weld::Window
* pParent
, sal_Int16 tabId
);
212 virtual ~OrganizeDialog() override
;
216 SbModule
* createModImpl(weld::Window
* pWin
, const ScriptDocument
& rDocument
,
217 SbTreeListBox
& rBasicBox
, const OUString
& rLibName
, const OUString
& aModName
, bool bMain
);
218 void createLibImpl(weld::Window
* pWin
, const ScriptDocument
& rDocument
,
219 weld::TreeView
* pLibBox
, SbTreeListBox
* pBasicBox
);
221 } // namespace basctl
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */