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 .
20 #ifndef INCLUDED_BASCTL_SOURCE_INC_BASTYPE2_HXX
21 #define INCLUDED_BASCTL_SOURCE_INC_BASTYPE2_HXX
23 #include <sal/config.h>
27 #include "doceventnotifier.hxx"
29 #include <svtools/treelistbox.hxx>
30 #include <basic/sbstar.hxx>
31 #include "sbxitem.hxx"
33 #include <o3tl/typed_flags_set.hxx>
36 class SvTreeListEntry
;
44 All
= Modules
| Subs
| Dialogs
,
47 template<> struct typed_flags
<BrowseMode
> : is_typed_flags
<BrowseMode
, 0x7> {};
61 OBJ_TYPE_DOCUMENT_OBJECTS
,
63 OBJ_TYPE_NORMAL_MODULES
,
64 OBJ_TYPE_CLASS_MODULES
73 explicit Entry(EntryType eType
)
80 EntryType
GetType () const { return m_eType
; }
83 class DocumentEntry
: public Entry
86 ScriptDocument m_aDocument
;
87 LibraryLocation m_eLocation
;
91 ScriptDocument
const& rDocument
,
92 LibraryLocation eLocation
,
93 EntryType eType
= OBJ_TYPE_DOCUMENT
95 virtual ~DocumentEntry () override
;
97 ScriptDocument
const& GetDocument() const { return m_aDocument
; }
98 LibraryLocation
GetLocation() const { return m_eLocation
; }
101 class LibEntry
: public DocumentEntry
108 ScriptDocument
const& rDocument
,
109 LibraryLocation eLocation
,
110 OUString
const& rLibName
112 virtual ~LibEntry () override
;
114 OUString
const& GetLibName () const { return m_aLibName
; }
117 class EntryDescriptor
119 ScriptDocument m_aDocument
;
120 LibraryLocation m_eLocation
;
122 OUString m_aLibSubName
; // for vba entry: Document Objects, Class Modules, Forms and Normal Modules
124 OUString m_aMethodName
;
130 ScriptDocument
const& rDocument
,
131 LibraryLocation eLocation
,
132 OUString
const& rLibName
,
133 OUString
const& rLibSubName
,
134 OUString
const& rName
,
138 ScriptDocument
const& rDocument
,
139 LibraryLocation eLocation
,
140 OUString
const& rLibName
,
141 OUString
const& rLibSubName
,
142 OUString
const& rName
,
143 OUString
const& rMethodName
,
147 ScriptDocument
const& GetDocument() const { return m_aDocument
; }
149 LibraryLocation
GetLocation() const { return m_eLocation
; }
151 const OUString
& GetLibName() const { return m_aLibName
; }
153 const OUString
& GetLibSubName() const { return m_aLibSubName
; }
155 const OUString
& GetName() const { return m_aName
; }
157 const OUString
& GetMethodName() const { return m_aMethodName
; }
158 void SetMethodName( const OUString
& aMethodName
) { m_aMethodName
= aMethodName
; }
160 EntryType
GetType() const { return m_eType
; }
161 void SetType( EntryType eType
) { m_eType
= eType
; }
166 Classification of types and pointers in the Entries:
168 OBJ_TYPE_DOCUMENT DocumentEntry
169 OBJ_TYPE_LIBRARY Entry
170 OBJ_TYPE_MODULE Entry
171 OBJ_TYPE_DIALOG Entry
172 OBJ_TYPE_METHOD Entry
176 class TreeListBox
: public SvTreeListBox
, public DocumentEventListener
180 DocumentEventNotifier m_aNotifier
;
181 void SetEntryBitmaps( SvTreeListEntry
* pEntry
, const Image
& rImage
);
182 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
185 virtual void RequestingChildren( SvTreeListEntry
* pParent
) override
;
186 virtual void ExpandedHdl() override
;
187 virtual SvTreeListEntry
* CloneEntry( SvTreeListEntry
* pSource
) override
;
188 virtual bool ExpandingHdl() override
;
189 virtual void KeyInput( const KeyEvent
& rEvt
) override
;
192 void ImpCreateLibEntries( SvTreeListEntry
* pShellRootEntry
, const ScriptDocument
& rDocument
, LibraryLocation eLocation
);
193 void ImpCreateLibSubEntries( SvTreeListEntry
* pLibRootEntry
, const ScriptDocument
& rDocument
, const OUString
& rLibName
);
194 void ImpCreateLibSubEntriesInVBAMode( SvTreeListEntry
* pLibRootEntry
, const ScriptDocument
& rDocument
, const OUString
& rLibName
);
195 void ImpCreateLibSubSubEntriesInVBAMode( SvTreeListEntry
* pLibSubRootEntry
, const ScriptDocument
& rDocument
, const OUString
& rLibName
);
196 SvTreeListEntry
* ImpFindEntry( SvTreeListEntry
* pParent
, const OUString
& rText
);
198 // DocumentEventListener
199 virtual void onDocumentCreated( const ScriptDocument
& _rDocument
) override
;
200 virtual void onDocumentOpened( const ScriptDocument
& _rDocument
) override
;
201 virtual void onDocumentSave( const ScriptDocument
& _rDocument
) override
;
202 virtual void onDocumentSaveDone( const ScriptDocument
& _rDocument
) override
;
203 virtual void onDocumentSaveAs( const ScriptDocument
& _rDocument
) override
;
204 virtual void onDocumentSaveAsDone( const ScriptDocument
& _rDocument
) override
;
205 virtual void onDocumentClosed( const ScriptDocument
& _rDocument
) override
;
206 virtual void onDocumentTitleChanged( const ScriptDocument
& _rDocument
) override
;
207 virtual void onDocumentModeChanged( const ScriptDocument
& _rDocument
) override
;
210 TreeListBox(vcl::Window
* pParent
, WinBits nStyle
);
211 virtual ~TreeListBox() override
;
212 virtual void dispose() override
;
214 void ScanEntry( const ScriptDocument
& rDocument
, LibraryLocation eLocation
);
215 void ScanAllEntries();
216 void UpdateEntries();
218 bool IsEntryProtected( SvTreeListEntry
* pEntry
);
220 void SetMode( BrowseMode nM
) { nMode
= nM
; }
221 BrowseMode
GetMode() const { return nMode
; }
223 SbModule
* FindModule( SvTreeListEntry
* pEntry
);
224 SbxVariable
* FindVariable( SvTreeListEntry
* pEntry
);
225 SvTreeListEntry
* FindRootEntry( const ScriptDocument
& rDocument
, LibraryLocation eLocation
);
226 SvTreeListEntry
* FindEntry( SvTreeListEntry
* pParent
, const OUString
& rText
, EntryType eType
);
228 EntryDescriptor
GetEntryDescriptor( SvTreeListEntry
* pEntry
);
230 static ItemType
ConvertType (EntryType eType
);
231 bool IsValidEntry( SvTreeListEntry
* pEntry
);
233 SvTreeListEntry
* AddEntry(
234 const OUString
& rText
, const Image
& rImage
,
235 SvTreeListEntry
* pParent
, bool bChildrenOnDemand
,
236 std::unique_ptr
<Entry
> && aUserData
238 void RemoveEntry (SvTreeListEntry
const *);
239 void RemoveEntry (ScriptDocument
const&);
241 OUString
GetRootEntryName( const ScriptDocument
& rDocument
, LibraryLocation eLocation
) const;
242 static void GetRootEntryBitmaps( const ScriptDocument
& rDocument
, Image
& rImage
);
244 void SetCurrentEntry (EntryDescriptor
const &);
247 LibraryType
GetLibraryType() const;
250 } // namespace basctl
252 #endif // INCLUDED_BASCTL_SOURCE_INC_BASTYPE2_HXX
254 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */