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