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 .
19 #ifndef INCLUDED_BASCTL_SOURCE_BASICIDE_BASTYPE2_HXX
20 #define INCLUDED_BASCTL_SOURCE_BASICIDE_BASTYPE2_HXX
24 #include "doceventnotifier.hxx"
26 #include <svtools/treelistbox.hxx>
27 #include <basic/sbstar.hxx>
28 #include <sbxitem.hxx>
32 class SvTreeListEntry
;
46 OBJ_TYPE_DOCUMENT_OBJECTS
,
48 OBJ_TYPE_NORMAL_MODULES
,
49 OBJ_TYPE_CLASS_MODULES
54 BROWSEMODE_MODULES
= 0x01,
55 BROWSEMODE_SUBS
= 0x02,
56 BROWSEMODE_DIALOGS
= 0x04,
65 explicit Entry(EntryType eType
)
72 EntryType
GetType () const { return m_eType
; }
75 class DocumentEntry
: public Entry
78 ScriptDocument m_aDocument
;
79 LibraryLocation m_eLocation
;
83 ScriptDocument
const& rDocument
,
84 LibraryLocation eLocation
,
85 EntryType eType
= OBJ_TYPE_DOCUMENT
87 virtual ~DocumentEntry ();
89 ScriptDocument
const& GetDocument() const { return m_aDocument
; }
90 LibraryLocation
GetLocation() const { return m_eLocation
; }
93 class LibEntry
: public DocumentEntry
100 ScriptDocument
const& rDocument
,
101 LibraryLocation eLocation
,
102 OUString
const& rLibName
,
103 EntryType eType
= OBJ_TYPE_LIBRARY
105 virtual ~LibEntry ();
107 OUString
const& GetLibName () const { return m_aLibName
; }
110 class EntryDescriptor
112 ScriptDocument m_aDocument
;
113 LibraryLocation m_eLocation
;
115 OUString m_aLibSubName
; // for vba entry: Document Objects, Class Modules, Forms and Normal Modules
117 OUString m_aMethodName
;
123 ScriptDocument
const& rDocument
,
124 LibraryLocation eLocation
,
125 OUString
const& rLibName
,
126 OUString
const& rLibSubName
,
127 OUString
const& rName
,
131 ScriptDocument
const& rDocument
,
132 LibraryLocation eLocation
,
133 OUString
const& rLibName
,
134 OUString
const& rLibSubName
,
135 OUString
const& rName
,
136 OUString
const& rMethodName
,
139 virtual ~EntryDescriptor ();
141 bool operator == (EntryDescriptor
const& rDesc
) const;
143 ScriptDocument
const& GetDocument() const { return m_aDocument
; }
144 void SetDocument( const ScriptDocument
& rDocument
) { m_aDocument
= rDocument
; }
146 LibraryLocation
GetLocation() const { return m_eLocation
; }
147 void SetLocation( LibraryLocation eLocation
) { m_eLocation
= eLocation
; }
149 const OUString
& GetLibName() const { return m_aLibName
; }
150 void SetLibName( const OUString
& aLibName
) { m_aLibName
= aLibName
; }
152 const OUString
& GetLibSubName() const { return m_aLibSubName
; }
153 void SetLibSubName( const OUString
& aLibSubName
) { m_aLibSubName
= aLibSubName
; }
155 const OUString
& GetName() const { return m_aName
; }
156 void SetName( const OUString
& aName
) { m_aName
= aName
; }
158 const OUString
& GetMethodName() const { return m_aMethodName
; }
159 void SetMethodName( const OUString
& aMethodName
) { m_aMethodName
= aMethodName
; }
161 EntryType
GetType() const { return m_eType
; }
162 void SetType( EntryType eType
) { m_eType
= eType
; }
167 Classification of types and pointers in the Entries:
169 OBJ_TYPE_DOCUMENT DocumentEntry
170 OBJ_TYPE_LIBRARY Entry
171 OBJ_TYPE_MODULE Entry
172 OBJ_TYPE_DIALOG Entry
173 OBJ_TYPE_METHOD Entry
177 class TreeListBox
: public SvTreeListBox
, public DocumentEventListener
181 DocumentEventNotifier m_aNotifier
;
183 void SetEntryBitmaps( SvTreeListEntry
* pEntry
, const Image
& rImage
);
184 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
187 virtual void RequestingChildren( SvTreeListEntry
* pParent
) SAL_OVERRIDE
;
188 virtual void ExpandedHdl() SAL_OVERRIDE
;
189 virtual SvTreeListEntry
* CloneEntry( SvTreeListEntry
* pSource
) SAL_OVERRIDE
;
190 virtual bool ExpandingHdl() SAL_OVERRIDE
;
191 virtual void KeyInput( const KeyEvent
& rEvt
) SAL_OVERRIDE
;
194 void ImpCreateLibEntries( SvTreeListEntry
* pShellRootEntry
, const ScriptDocument
& rDocument
, LibraryLocation eLocation
);
195 void ImpCreateLibSubEntries( SvTreeListEntry
* pLibRootEntry
, const ScriptDocument
& rDocument
, const OUString
& rLibName
);
196 void ImpCreateLibSubEntriesInVBAMode( SvTreeListEntry
* pLibRootEntry
, const ScriptDocument
& rDocument
, const OUString
& rLibName
);
197 void ImpCreateLibSubSubEntriesInVBAMode( SvTreeListEntry
* pLibSubRootEntry
, const ScriptDocument
& rDocument
, const OUString
& rLibName
);
198 SvTreeListEntry
* ImpFindEntry( SvTreeListEntry
* pParent
, const OUString
& rText
);
200 // DocumentEventListener
201 virtual void onDocumentCreated( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
202 virtual void onDocumentOpened( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
203 virtual void onDocumentSave( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
204 virtual void onDocumentSaveDone( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
205 virtual void onDocumentSaveAs( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
206 virtual void onDocumentSaveAsDone( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
207 virtual void onDocumentClosed( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
208 virtual void onDocumentTitleChanged( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
209 virtual void onDocumentModeChanged( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
212 TreeListBox(vcl::Window
* pParent
, const ResId
& rRes
);
213 TreeListBox(vcl::Window
* pParent
, WinBits nStyle
);
214 virtual ~TreeListBox();
215 virtual void dispose() SAL_OVERRIDE
;
217 void ScanEntry( const ScriptDocument
& rDocument
, LibraryLocation eLocation
);
218 void ScanAllEntries();
219 void UpdateEntries();
221 bool IsEntryProtected( SvTreeListEntry
* pEntry
);
223 void SetMode( sal_uInt16 nM
) { nMode
= nM
; }
224 sal_uInt16
GetMode() const { return nMode
; }
226 SbModule
* FindModule( SvTreeListEntry
* pEntry
);
227 SbxVariable
* FindVariable( SvTreeListEntry
* pEntry
);
228 SvTreeListEntry
* FindRootEntry( const ScriptDocument
& rDocument
, LibraryLocation eLocation
);
229 SvTreeListEntry
* FindEntry( SvTreeListEntry
* pParent
, const OUString
& rText
, EntryType eType
);
231 EntryDescriptor
GetEntryDescriptor( SvTreeListEntry
* pEntry
);
233 static ItemType
ConvertType (EntryType eType
);
234 bool IsValidEntry( SvTreeListEntry
* pEntry
);
236 SvTreeListEntry
* AddEntry(
237 const OUString
& rText
, const Image
& rImage
,
238 SvTreeListEntry
* pParent
, bool bChildrenOnDemand
,
239 std::unique_ptr
<Entry
> * aUserData
241 void RemoveEntry (SvTreeListEntry
*);
242 void RemoveEntry (ScriptDocument
const&);
244 OUString
GetRootEntryName( const ScriptDocument
& rDocument
, LibraryLocation eLocation
) const;
245 static void GetRootEntryBitmaps( const ScriptDocument
& rDocument
, Image
& rImage
);
247 void SetCurrentEntry (EntryDescriptor
&);
250 LibraryType
GetLibraryType() const;
253 } // namespace basctl
255 #endif // INCLUDED_BASCTL_SOURCE_BASICIDE_BASTYPE2_HXX
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */