Line data Source code
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 : #ifndef INCLUDED_BASCTL_SOURCE_BASICIDE_BASTYPE2_HXX
20 : #define INCLUDED_BASCTL_SOURCE_BASICIDE_BASTYPE2_HXX
21 :
22 : #include <sal/config.h>
23 :
24 : #include <memory>
25 :
26 : #include "doceventnotifier.hxx"
27 :
28 : #include <svtools/treelistbox.hxx>
29 : #include <svl/lstner.hxx>
30 : #include <basic/sbstar.hxx>
31 : #include <sbxitem.hxx>
32 : #include "basobj.hxx"
33 :
34 : class SbModule;
35 : class SvTreeListEntry;
36 : class SbxVariable;
37 :
38 : namespace basctl
39 : {
40 :
41 : enum EntryType
42 : {
43 : OBJ_TYPE_UNKNOWN,
44 : OBJ_TYPE_DOCUMENT,
45 : OBJ_TYPE_LIBRARY,
46 : OBJ_TYPE_MODULE,
47 : OBJ_TYPE_DIALOG,
48 : OBJ_TYPE_METHOD,
49 : OBJ_TYPE_DOCUMENT_OBJECTS,
50 : OBJ_TYPE_USERFORMS,
51 : OBJ_TYPE_NORMAL_MODULES,
52 : OBJ_TYPE_CLASS_MODULES
53 : };
54 :
55 : enum
56 : {
57 : BROWSEMODE_MODULES = 0x01,
58 : BROWSEMODE_SUBS = 0x02,
59 : BROWSEMODE_DIALOGS = 0x04,
60 : };
61 :
62 0 : class Entry
63 : {
64 : private:
65 : EntryType m_eType;
66 :
67 : public:
68 0 : Entry (EntryType eType) : m_eType(eType) { }
69 : virtual ~Entry ();
70 :
71 0 : EntryType GetType () const { return m_eType; }
72 : };
73 :
74 : class DocumentEntry : public Entry
75 : {
76 : private:
77 : ScriptDocument m_aDocument;
78 : LibraryLocation m_eLocation;
79 :
80 : public:
81 : DocumentEntry (
82 : ScriptDocument const& rDocument,
83 : LibraryLocation eLocation,
84 : EntryType eType = OBJ_TYPE_DOCUMENT
85 : );
86 : virtual ~DocumentEntry ();
87 :
88 0 : ScriptDocument const& GetDocument() const { return m_aDocument; }
89 0 : LibraryLocation GetLocation() const { return m_eLocation; }
90 : };
91 :
92 : class LibEntry : public DocumentEntry
93 : {
94 : private:
95 : OUString m_aLibName;
96 :
97 : public:
98 : LibEntry (
99 : ScriptDocument const& rDocument,
100 : LibraryLocation eLocation,
101 : OUString const& rLibName,
102 : EntryType eType = OBJ_TYPE_LIBRARY
103 : );
104 : virtual ~LibEntry ();
105 :
106 0 : OUString const& GetLibName () const { return m_aLibName; }
107 : };
108 :
109 0 : class EntryDescriptor
110 : {
111 : ScriptDocument m_aDocument;
112 : LibraryLocation m_eLocation;
113 : OUString m_aLibName;
114 : OUString m_aLibSubName; // for vba entry: Document Objects, Class Modules, Forms and Normal Modules
115 : OUString m_aName;
116 : OUString m_aMethodName;
117 : EntryType m_eType;
118 :
119 : public:
120 : EntryDescriptor ();
121 : EntryDescriptor (
122 : ScriptDocument const& rDocument,
123 : LibraryLocation eLocation,
124 : OUString const& rLibName,
125 : OUString const& rLibSubName,
126 : OUString const& rName,
127 : EntryType eType
128 : );
129 : EntryDescriptor (
130 : ScriptDocument const& rDocument,
131 : LibraryLocation eLocation,
132 : OUString const& rLibName,
133 : OUString const& rLibSubName,
134 : OUString const& rName,
135 : OUString const& rMethodName,
136 : EntryType eType
137 : );
138 : virtual ~EntryDescriptor ();
139 :
140 : bool operator == (EntryDescriptor const& rDesc) const;
141 :
142 0 : ScriptDocument const& GetDocument() const { return m_aDocument; }
143 : void SetDocument( const ScriptDocument& rDocument ) { m_aDocument = rDocument; }
144 :
145 0 : LibraryLocation GetLocation() const { return m_eLocation; }
146 : void SetLocation( LibraryLocation eLocation ) { m_eLocation = eLocation; }
147 :
148 0 : const OUString& GetLibName() const { return m_aLibName; }
149 : void SetLibName( const OUString& aLibName ) { m_aLibName = aLibName; }
150 :
151 0 : const OUString& GetLibSubName() const { return m_aLibSubName; }
152 : void SetLibSubName( const OUString& aLibSubName ) { m_aLibSubName = aLibSubName; }
153 :
154 0 : const OUString& GetName() const { return m_aName; }
155 : void SetName( const OUString& aName ) { m_aName = aName; }
156 :
157 0 : const OUString& GetMethodName() const { return m_aMethodName; }
158 0 : void SetMethodName( const OUString& aMethodName ) { m_aMethodName = aMethodName; }
159 :
160 0 : EntryType GetType() const { return m_eType; }
161 0 : void SetType( EntryType eType ) { m_eType = eType; }
162 : };
163 :
164 :
165 : /*
166 : Classification of types and pointers in the Entries:
167 :
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
173 :
174 : */
175 :
176 : class TreeListBox : public SvTreeListBox, public DocumentEventListener
177 : {
178 : private:
179 : sal_uInt16 nMode;
180 : DocumentEventNotifier m_aNotifier;
181 : void Init();
182 : void SetEntryBitmaps( SvTreeListEntry * pEntry, const Image& rImage );
183 : virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
184 :
185 : protected:
186 : virtual void RequestingChildren( SvTreeListEntry* pParent ) SAL_OVERRIDE;
187 : virtual void ExpandedHdl() SAL_OVERRIDE;
188 : virtual SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource ) SAL_OVERRIDE;
189 : virtual bool ExpandingHdl() SAL_OVERRIDE;
190 : virtual void KeyInput( const KeyEvent& rEvt ) SAL_OVERRIDE;
191 :
192 : bool OpenCurrent();
193 : void ImpCreateLibEntries( SvTreeListEntry* pShellRootEntry, const ScriptDocument& rDocument, LibraryLocation eLocation );
194 : void ImpCreateLibSubEntries( SvTreeListEntry* pLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName );
195 : void ImpCreateLibSubEntriesInVBAMode( SvTreeListEntry* pLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName );
196 : void ImpCreateLibSubSubEntriesInVBAMode( SvTreeListEntry* pLibSubRootEntry, const ScriptDocument& rDocument, const OUString& rLibName );
197 : SvTreeListEntry* ImpFindEntry( SvTreeListEntry* pParent, const OUString& rText );
198 :
199 : // DocumentEventListener
200 : virtual void onDocumentCreated( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
201 : virtual void onDocumentOpened( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
202 : virtual void onDocumentSave( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
203 : virtual void onDocumentSaveDone( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
204 : virtual void onDocumentSaveAs( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
205 : virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
206 : virtual void onDocumentClosed( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
207 : virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
208 : virtual void onDocumentModeChanged( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
209 :
210 : public:
211 : TreeListBox(vcl::Window* pParent, const ResId& rRes);
212 : TreeListBox(vcl::Window* pParent, WinBits nStyle);
213 : virtual ~TreeListBox();
214 :
215 : void ScanEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
216 : void ScanAllEntries();
217 : void UpdateEntries();
218 :
219 : bool IsEntryProtected( SvTreeListEntry* pEntry );
220 :
221 0 : void SetMode( sal_uInt16 nM ) { nMode = nM; }
222 0 : sal_uInt16 GetMode() const { return nMode; }
223 :
224 : SbModule* FindModule( SvTreeListEntry* pEntry );
225 : SbxVariable* FindVariable( SvTreeListEntry* pEntry );
226 : SvTreeListEntry* FindRootEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
227 : SvTreeListEntry* FindEntry( SvTreeListEntry* pParent, const OUString& rText, EntryType eType );
228 :
229 : EntryDescriptor GetEntryDescriptor( SvTreeListEntry* pEntry );
230 :
231 : ItemType ConvertType (EntryType eType);
232 : bool IsValidEntry( SvTreeListEntry* pEntry );
233 :
234 : SvTreeListEntry* AddEntry(
235 : const OUString& rText, const Image& rImage,
236 : SvTreeListEntry* pParent, bool bChildrenOnDemand,
237 : std::unique_ptr<Entry> * aUserData
238 : );
239 : void RemoveEntry (SvTreeListEntry*);
240 : void RemoveEntry (ScriptDocument const&);
241 :
242 : OUString GetRootEntryName( const ScriptDocument& rDocument, LibraryLocation eLocation ) const;
243 : void GetRootEntryBitmaps( const ScriptDocument& rDocument, Image& rImage );
244 :
245 : void SetCurrentEntry (EntryDescriptor&);
246 :
247 : private:
248 : LibraryType GetLibraryType() const;
249 : };
250 :
251 : } // namespace basctl
252 :
253 : #endif // INCLUDED_BASCTL_SOURCE_BASICIDE_BASTYPE2_HXX
254 :
255 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|