LibreOffice Module basctl (master) 1
bastype2.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <memory>
25
26#include "doceventnotifier.hxx"
27
28#include <vcl/weld.hxx>
29#include "sbxitem.hxx"
31
32class SbModule;
33class SbxVariable;
34
35enum class BrowseMode
36{
37 Modules = 0x01,
38 Subs = 0x02,
39 Dialogs = 0x04,
40 All = Modules | Subs | Dialogs,
41};
42namespace o3tl {
43 template<> struct typed_flags<BrowseMode> : is_typed_flags<BrowseMode, 0x7> {};
44}
45
46namespace basctl
47{
48using namespace ::com::sun::star::uno;
49
51{
62};
63
64class Entry
65{
66private:
68
69public:
70 explicit Entry(EntryType eType)
71 : m_eType(eType)
72 {
73 }
74
75 virtual ~Entry();
76
77 Entry(Entry const &) = default;
78 Entry(Entry &&) = default;
79 Entry & operator =(Entry const &) = default;
80 Entry & operator =(Entry &&) = default;
81
82 EntryType GetType () const { return m_eType; }
83};
84
85class DocumentEntry : public Entry
86{
87private:
90
91public:
94 LibraryLocation eLocation,
96 );
97 virtual ~DocumentEntry () override;
98
99 ScriptDocument const& GetDocument() const { return m_aDocument; }
101};
102
104{
105private:
106 OUString m_aLibName;
107
108public:
109 LibEntry (
110 ScriptDocument const& rDocument,
111 LibraryLocation eLocation,
112 OUString aLibName
113 );
114 virtual ~LibEntry () override;
115
116 OUString const& GetLibName () const { return m_aLibName; }
117};
118
120{
123 OUString m_aLibName;
124 OUString m_aLibSubName; // for vba entry: Document Objects, Class Modules, Forms and Normal Modules
125 OUString m_aName;
128
129public:
133 LibraryLocation eLocation,
134 OUString aLibName,
135 OUString aLibSubName,
136 OUString aName,
137 EntryType eType
138 );
141 LibraryLocation eLocation,
142 OUString aLibName,
143 OUString aLibSubName,
144 OUString aName,
145 OUString aMethodName,
146 EntryType eType
147 );
148
149 ScriptDocument const& GetDocument() const { return m_aDocument; }
151
152 const OUString& GetLibName() const { return m_aLibName; }
153 const OUString& GetLibSubName() const { return m_aLibSubName; }
154 const OUString& GetName() const { return m_aName; }
155 const OUString& GetMethodName() const { return m_aMethodName; }
156 void SetMethodName( const OUString& aMethodName ) { m_aMethodName = aMethodName; }
157
158 EntryType GetType() const { return m_eType; }
159 void SetType( EntryType eType ) { m_eType = eType; }
160};
161
162
163/*
164 Classification of types and pointers in the Entries:
165
166 OBJ_TYPE_DOCUMENT DocumentEntry
167 OBJ_TYPE_LIBRARY Entry
168 OBJ_TYPE_MODULE Entry
169 OBJ_TYPE_DIALOG Entry
170 OBJ_TYPE_METHOD Entry
171
172*/
173
175{
176private:
177 std::unique_ptr<weld::TreeView> m_xControl;
178 std::unique_ptr<weld::TreeIter> m_xScratchIter;
183 void SetEntryBitmaps(const weld::TreeIter& rIter, const OUString& rImage);
184
185protected:
186 DECL_LINK(RequestingChildrenHdl, const weld::TreeIter&, bool);
187 DECL_LINK(OpenCurrentHdl, weld::TreeView&, bool);
188 void ImpCreateLibEntries(const weld::TreeIter& rShellRootEntry, const ScriptDocument& rDocument, LibraryLocation eLocation);
189 void ImpCreateLibSubEntries(const weld::TreeIter& rLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName);
190 void ImpCreateLibSubEntriesInVBAMode(const weld::TreeIter& rLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName );
191 void ImpCreateLibSubSubEntriesInVBAMode(const weld::TreeIter& rLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName);
192 bool ImpFindEntry(weld::TreeIter& rIter, std::u16string_view rText);
193
194 // DocumentEventListener
195 virtual void onDocumentCreated( const ScriptDocument& _rDocument ) override;
196 virtual void onDocumentOpened( const ScriptDocument& _rDocument ) override;
197 virtual void onDocumentSave( const ScriptDocument& _rDocument ) override;
198 virtual void onDocumentSaveDone( const ScriptDocument& _rDocument ) override;
199 virtual void onDocumentSaveAs( const ScriptDocument& _rDocument ) override;
200 virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument ) override;
201 virtual void onDocumentClosed( const ScriptDocument& _rDocument ) override;
202 virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument ) override;
203 virtual void onDocumentModeChanged( const ScriptDocument& _rDocument ) override;
204
205public:
206 SbTreeListBox(std::unique_ptr<weld::TreeView> xControl, weld::Window* pTopLevel);
207 virtual ~SbTreeListBox() override;
208
209 void ScanEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
210 void ScanAllEntries();
211 void UpdateEntries();
212
213 bool IsEntryProtected(const weld::TreeIter* pEntry);
214
215 void SetMode( BrowseMode nM ) { nMode = nM; }
216 BrowseMode GetMode() const { return nMode; }
217
218 SbModule* FindModule(const weld::TreeIter* pEntry);
220 bool FindRootEntry(const ScriptDocument& rDocument, LibraryLocation eLocation, weld::TreeIter& rIter);
221 bool FindEntry(std::u16string_view rText, EntryType eType, weld::TreeIter& rIter);
223
224 static ItemType ConvertType (EntryType eType);
225 bool IsValidEntry(const weld::TreeIter& rEntry);
226 void AddEntry(const OUString& rText, const OUString& rImage,
227 const weld::TreeIter* pParent, bool bChildrenOnDemand,
228 std::unique_ptr<Entry>&& rUserData,
229 weld::TreeIter* pRet = nullptr);
230
231 void connect_changed(const Link<weld::TreeView&, void>& rLink) { m_xControl->connect_changed(rLink); }
232 std::unique_ptr<weld::TreeIter> make_iterator(const weld::TreeIter* pIter = nullptr) const { return m_xControl->make_iterator(pIter); }
233 void copy_iterator(const weld::TreeIter& rSource, weld::TreeIter& rDest) const { m_xControl->copy_iterator(rSource, rDest); }
234 bool get_selected(weld::TreeIter* pIter) const { return m_xControl->get_selected(pIter); }
235 void select(const weld::TreeIter& rIter) { m_xControl->select(rIter); }
236 void unselect(const weld::TreeIter& rIter) { m_xControl->unselect(rIter); }
237 void remove(const weld::TreeIter& rIter) { m_xControl->remove(rIter); }
238 bool get_cursor(weld::TreeIter* pIter) const { return m_xControl->get_cursor(pIter); }
239 void set_cursor(const weld::TreeIter& rIter) { m_xControl->set_cursor(rIter); }
240 OUString get_text(const weld::TreeIter& rIter) const { return m_xControl->get_text(rIter); }
241 void set_text(const weld::TreeIter& rIter, const OUString& rText) { m_xControl->set_text(rIter, rText); }
242 OUString get_id(const weld::TreeIter& rIter) const { return m_xControl->get_id(rIter); }
243 bool get_iter_first(weld::TreeIter& rIter) const { return m_xControl->get_iter_first(rIter); }
244 bool iter_next_sibling(weld::TreeIter& rIter) const { return m_xControl->iter_next_sibling(rIter); }
245 bool iter_children(weld::TreeIter& rIter) const { return m_xControl->iter_children(rIter); }
246 bool iter_parent(weld::TreeIter& rIter) const { return m_xControl->iter_parent(rIter); }
247 int get_iter_depth(const weld::TreeIter& rIter) const { return m_xControl->get_iter_depth(rIter); }
248 bool get_row_expanded(const weld::TreeIter& rIter) const { return m_xControl->get_row_expanded(rIter); }
249 void expand_row(const weld::TreeIter& rIter) { m_xControl->expand_row(rIter); }
250 void set_size_request(int nWidth, int nHeight) { m_xControl->set_size_request(nWidth, nHeight); }
251 float get_approximate_digit_width() const { return m_xControl->get_approximate_digit_width(); }
252 int get_height_rows(int nRows) const { return m_xControl->get_height_rows(nRows); }
253 int get_iter_index_in_parent(const weld::TreeIter& rIter) const { return m_xControl->get_iter_index_in_parent(rIter); }
255 const Link<const std::pair<const weld::TreeIter&, OUString>&, bool>& rEndLink)
256 {
257 m_xControl->connect_editing(rStartLink, rEndLink);
258 }
259
260 void make_sorted() { m_xControl->make_sorted(); };
261
262 void RemoveEntry(const weld::TreeIter& rIter);
263 void RemoveEntry(const ScriptDocument&);
264
265 OUString GetRootEntryName(const ScriptDocument& rDocument, LibraryLocation eLocation) const;
266 static OUString GetRootEntryBitmaps(const ScriptDocument& rDocument);
267
268 void SetCurrentEntry (EntryDescriptor const &);
269
271
272private:
274};
275
276} // namespace basctl
277
278/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScriptDocument aDocument
Definition: basobj2.cxx:194
BrowseMode
Definition: bastype2.hxx:36
LibraryLocation m_eLocation
Definition: bastype2.hxx:89
virtual ~DocumentEntry() override
Definition: bastype2.cxx:102
LibraryLocation GetLocation() const
Definition: bastype2.hxx:100
DocumentEntry(ScriptDocument aDocument, LibraryLocation eLocation, EntryType eType=OBJ_TYPE_DOCUMENT)
Definition: bastype2.cxx:90
ScriptDocument const & GetDocument() const
Definition: bastype2.hxx:99
ScriptDocument m_aDocument
Definition: bastype2.hxx:88
allows registering at theGlobalEventBroadcaster for global document events
const OUString & GetMethodName() const
Definition: bastype2.hxx:155
ScriptDocument m_aDocument
Definition: bastype2.hxx:121
LibraryLocation GetLocation() const
Definition: bastype2.hxx:150
ScriptDocument const & GetDocument() const
Definition: bastype2.hxx:149
void SetType(EntryType eType)
Definition: bastype2.hxx:159
void SetMethodName(const OUString &aMethodName)
Definition: bastype2.hxx:156
EntryType GetType() const
Definition: bastype2.hxx:158
const OUString & GetLibName() const
Definition: bastype2.hxx:152
const OUString & GetName() const
Definition: bastype2.hxx:154
const OUString & GetLibSubName() const
Definition: bastype2.hxx:153
LibraryLocation m_eLocation
Definition: bastype2.hxx:122
EntryType m_eType
Definition: bastype2.hxx:67
EntryType GetType() const
Definition: bastype2.hxx:82
Entry(EntryType eType)
Definition: bastype2.hxx:70
Entry & operator=(Entry const &)=default
Entry(Entry &&)=default
Entry(Entry const &)=default
virtual ~Entry()
Definition: bastype2.cxx:87
OUString m_aLibName
Definition: bastype2.hxx:106
OUString const & GetLibName() const
Definition: bastype2.hxx:116
LibEntry(ScriptDocument const &rDocument, LibraryLocation eLocation, OUString aLibName)
Definition: bastype2.cxx:105
virtual ~LibEntry() override
Definition: bastype2.cxx:114
void set_size_request(int nWidth, int nHeight)
Definition: bastype2.hxx:250
LibraryType GetLibraryType() const
Definition: bastype2.cxx:668
EntryDescriptor GetEntryDescriptor(const weld::TreeIter *pEntry)
Definition: bastype3.cxx:240
bool FindRootEntry(const ScriptDocument &rDocument, LibraryLocation eLocation, weld::TreeIter &rIter)
Definition: bastype3.cxx:418
void SetMode(BrowseMode nM)
Definition: bastype2.hxx:215
int get_height_rows(int nRows) const
Definition: bastype2.hxx:252
OUString get_text(const weld::TreeIter &rIter) const
Definition: bastype2.hxx:240
bool iter_next_sibling(weld::TreeIter &rIter) const
Definition: bastype2.hxx:244
virtual void onDocumentSaveAs(const ScriptDocument &_rDocument) override
Definition: bastype2.cxx:511
OUString GetRootEntryName(const ScriptDocument &rDocument, LibraryLocation eLocation) const
Definition: bastype2.cxx:678
DECL_LINK(RequestingChildrenHdl, const weld::TreeIter &, bool)
std::unique_ptr< weld::TreeView > m_xControl
Definition: bastype2.hxx:177
virtual void onDocumentSave(const ScriptDocument &_rDocument) override
Definition: bastype2.cxx:501
bool get_cursor(weld::TreeIter *pIter) const
Definition: bastype2.hxx:238
virtual void onDocumentClosed(const ScriptDocument &_rDocument) override
Definition: bastype2.cxx:521
OUString get_id(const weld::TreeIter &rIter) const
Definition: bastype2.hxx:242
int get_iter_index_in_parent(const weld::TreeIter &rIter) const
Definition: bastype2.hxx:253
void RemoveEntry(const weld::TreeIter &rIter)
Definition: bastype2.cxx:572
bool get_selected(weld::TreeIter *pIter) const
Definition: bastype2.hxx:234
void set_cursor(const weld::TreeIter &rIter)
Definition: bastype2.hxx:239
SbxVariable * FindVariable(const weld::TreeIter *pEntry)
Definition: bastype3.cxx:147
bool get_row_expanded(const weld::TreeIter &rIter) const
Definition: bastype2.hxx:248
bool IsValidEntry(const weld::TreeIter &rEntry)
Definition: bastype3.cxx:358
DECL_LINK(OpenCurrentHdl, weld::TreeView &, bool)
void ImpCreateLibSubEntries(const weld::TreeIter &rLibRootEntry, const ScriptDocument &rDocument, const OUString &rLibName)
Definition: bastype2.cxx:268
void connect_changed(const Link< weld::TreeView &, void > &rLink)
Definition: bastype2.hxx:231
void remove(const weld::TreeIter &rIter)
Definition: bastype2.hxx:237
std::unique_ptr< weld::TreeIter > make_iterator(const weld::TreeIter *pIter=nullptr) const
Definition: bastype2.hxx:232
static OUString GetRootEntryBitmaps(const ScriptDocument &rDocument)
Definition: bastype2.cxx:683
void SetCurrentEntry(EntryDescriptor const &)
Definition: bastype2.cxx:728
void ImpCreateLibSubEntriesInVBAMode(const weld::TreeIter &rLibRootEntry, const ScriptDocument &rDocument, const OUString &rLibName)
Definition: bastype2.cxx:367
void select(const weld::TreeIter &rIter)
Definition: bastype2.hxx:235
bool IsEntryProtected(const weld::TreeIter *pEntry)
Definition: bastype2.cxx:617
virtual void onDocumentModeChanged(const ScriptDocument &_rDocument) override
Definition: bastype2.cxx:534
weld::TreeView & get_widget()
Definition: bastype2.hxx:270
void AddEntry(const OUString &rText, const OUString &rImage, const weld::TreeIter *pParent, bool bChildrenOnDemand, std::unique_ptr< Entry > &&rUserData, weld::TreeIter *pRet=nullptr)
Definition: bastype2.cxx:642
weld::Window * m_pTopLevel
Definition: bastype2.hxx:179
DocumentEventNotifier m_aNotifier
Definition: bastype2.hxx:182
void ScanEntry(const ScriptDocument &rDocument, LibraryLocation eLocation)
Definition: bastype2.cxx:186
virtual void onDocumentSaveAsDone(const ScriptDocument &_rDocument) override
Definition: bastype2.cxx:516
SbModule * FindModule(const weld::TreeIter *pEntry)
Definition: bastype3.cxx:413
bool FindEntry(std::u16string_view rText, EntryType eType, weld::TreeIter &rIter)
Definition: bastype2.cxx:603
virtual void onDocumentSaveDone(const ScriptDocument &_rDocument) override
Definition: bastype2.cxx:506
float get_approximate_digit_width() const
Definition: bastype2.hxx:251
bool ImpFindEntry(weld::TreeIter &rIter, std::u16string_view rText)
Definition: bastype2.cxx:479
virtual void onDocumentOpened(const ScriptDocument &_rDocument) override
Definition: bastype2.cxx:496
void SetEntryBitmaps(const weld::TreeIter &rIter, const OUString &rImage)
Definition: bastype2.cxx:663
void connect_editing(const Link< const weld::TreeIter &, bool > &rStartLink, const Link< const std::pair< const weld::TreeIter &, OUString > &, bool > &rEndLink)
Definition: bastype2.hxx:254
static ItemType ConvertType(EntryType eType)
Definition: bastype3.cxx:344
SbTreeListBox(std::unique_ptr< weld::TreeView > xControl, weld::Window *pTopLevel)
Definition: bastype2.cxx:161
virtual void onDocumentTitleChanged(const ScriptDocument &_rDocument) override
Definition: bastype2.cxx:529
virtual ~SbTreeListBox() override
Definition: bastype2.cxx:173
void set_text(const weld::TreeIter &rIter, const OUString &rText)
Definition: bastype2.hxx:241
virtual void onDocumentCreated(const ScriptDocument &_rDocument) override
Definition: bastype2.cxx:491
void unselect(const weld::TreeIter &rIter)
Definition: bastype2.hxx:236
int get_iter_depth(const weld::TreeIter &rIter) const
Definition: bastype2.hxx:247
void ImpCreateLibSubSubEntriesInVBAMode(const weld::TreeIter &rLibRootEntry, const ScriptDocument &rDocument, const OUString &rLibName)
Definition: bastype2.cxx:394
bool get_iter_first(weld::TreeIter &rIter) const
Definition: bastype2.hxx:243
BrowseMode GetMode() const
Definition: bastype2.hxx:216
void expand_row(const weld::TreeIter &rIter)
Definition: bastype2.hxx:249
bool iter_children(weld::TreeIter &rIter) const
Definition: bastype2.hxx:245
std::unique_ptr< weld::TreeIter > m_xScratchIter
Definition: bastype2.hxx:178
bool iter_parent(weld::TreeIter &rIter) const
Definition: bastype2.hxx:246
void copy_iterator(const weld::TreeIter &rSource, weld::TreeIter &rDest) const
Definition: bastype2.hxx:233
void ImpCreateLibEntries(const weld::TreeIter &rShellRootEntry, const ScriptDocument &rDocument, LibraryLocation eLocation)
Definition: bastype2.cxx:207
encapsulates a document which contains Basic scripts and dialogs
DocumentType eType
@ OBJ_TYPE_UNKNOWN
Definition: bastype2.hxx:52
@ OBJ_TYPE_USERFORMS
Definition: bastype2.hxx:59
@ OBJ_TYPE_LIBRARY
Definition: bastype2.hxx:54
@ OBJ_TYPE_NORMAL_MODULES
Definition: bastype2.hxx:60
@ OBJ_TYPE_DIALOG
Definition: bastype2.hxx:56
@ OBJ_TYPE_CLASS_MODULES
Definition: bastype2.hxx:61
@ OBJ_TYPE_DOCUMENT
Definition: bastype2.hxx:53
@ OBJ_TYPE_MODULE
Definition: bastype2.hxx:55
@ OBJ_TYPE_METHOD
Definition: bastype2.hxx:57
@ OBJ_TYPE_DOCUMENT_OBJECTS
Definition: bastype2.hxx:58
ItemType
Definition: sbxitem.hxx:28