Update ooo320-m1
[ooovba.git] / basctl / source / basicide / bastype2.hxx
blob70799063f2ee3d44e14fc4321eb462b6e31860af
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bastype2.hxx,v $
10 * $Revision: 1.15 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _BASTYPE2_HXX
31 #define _BASTYPE2_HXX
33 #include "doceventnotifier.hxx"
35 #include <memory>
36 #include "tools/solar.h"
38 #define _SVICNVW_HXX
39 #include <svtools/svtreebx.hxx>
40 #include <svtools/lstner.hxx>
41 #include <basic/sbstar.hxx>
42 #include <sbxitem.hxx>
43 #include "basobj.hxx"
45 enum BasicEntryType { OBJ_TYPE_UNKNOWN, OBJ_TYPE_DOCUMENT, OBJ_TYPE_LIBRARY, OBJ_TYPE_MODULE, OBJ_TYPE_DIALOG, OBJ_TYPE_METHOD, OBJ_TYPE_DOCUMENT_OBJECTS, OBJ_TYPE_USERFORMS, OBJ_TYPE_NORMAL_MODULES, OBJ_TYPE_CLASS_MODULES };
47 #define BROWSEMODE_MODULES 0x01
48 #define BROWSEMODE_SUBS 0x02
49 #define BROWSEMODE_DIALOGS 0x04
51 class SbMethod;
52 class SbxObject;
53 class SbModule;
54 class SvLBoxEntry;
55 class SbxVariable;
56 class String;
59 class BasicEntry
61 private:
62 BasicEntryType m_eType;
64 public:
65 BasicEntry( BasicEntryType eType ) { m_eType = eType; }
66 BasicEntry( const BasicEntry& r ) { m_eType = r.m_eType; }
67 virtual ~BasicEntry();
69 BasicEntryType GetType() const { return m_eType; }
72 class BasicDocumentEntry : public BasicEntry
74 private:
75 ScriptDocument m_aDocument;
76 LibraryLocation m_eLocation;
78 public:
79 BasicDocumentEntry( const ScriptDocument& rDocument, LibraryLocation eLocation, BasicEntryType eType = OBJ_TYPE_DOCUMENT );
80 virtual ~BasicDocumentEntry();
82 const ScriptDocument&
83 GetDocument() const { return m_aDocument; }
84 LibraryLocation GetLocation() const { return m_eLocation; }
87 class BasicLibEntry : public BasicDocumentEntry
89 private:
90 String m_aLibName;
92 public:
93 BasicLibEntry( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, BasicEntryType eType = OBJ_TYPE_LIBRARY );
94 virtual ~BasicLibEntry();
96 const String& GetLibName() const { return m_aLibName; }
99 class BasicEntryDescriptor
101 ScriptDocument m_aDocument;
102 LibraryLocation m_eLocation;
103 String m_aLibName;
104 String m_aLibSubName; // for vba entry: Document Objects, Class Modules, Forms and Normal Modules
105 String m_aName;
106 String m_aMethodName;
107 BasicEntryType m_eType;
109 public:
110 BasicEntryDescriptor();
111 BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, BasicEntryType eType );
112 BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, const String& rMethodName, BasicEntryType eType );
113 virtual ~BasicEntryDescriptor();
115 BasicEntryDescriptor( const BasicEntryDescriptor& rDesc );
116 BasicEntryDescriptor& operator=( const BasicEntryDescriptor& rDesc );
117 bool operator==( const BasicEntryDescriptor& rDesc ) const;
119 const ScriptDocument&
120 GetDocument() const { return m_aDocument; }
121 void SetDocument( const ScriptDocument& rDocument ) { m_aDocument = rDocument; }
123 LibraryLocation GetLocation() const { return m_eLocation; }
124 void SetLocation( LibraryLocation eLocation ) { m_eLocation = eLocation; }
126 const String& GetLibName() const { return m_aLibName; }
127 void SetLibName( const String& aLibName ) { m_aLibName = aLibName; }
129 const String& GetLibSubName() const { return m_aLibSubName; }
130 void SetLibSubName( const String& aLibSubName ) { m_aLibSubName = aLibSubName; }
132 const String& GetName() const { return m_aName; }
133 void SetName( const String& aName ) { m_aName = aName; }
135 const String& GetMethodName() const { return m_aMethodName; }
136 void SetMethodName( const String& aMethodName ) { m_aMethodName = aMethodName; }
138 BasicEntryType GetType() const { return m_eType; }
139 void SetType( BasicEntryType eType ) { m_eType = eType; }
143 /****************************************
144 Zuordnung von Typen und Pointern in BasicEntrys:
146 OBJ_TYPE_DOCUMENT BasicDocumentEntry
147 OBJ_TYPE_LIBRARY BasicEntry
148 OBJ_TYPE_MODULE BasicEntry
149 OBJ_TYPE_DIALOG BasicEntry
150 OBJ_TYPE_METHOD BasicEntry
152 ******************************************/
154 class BasicTreeListBox :public SvTreeListBox
155 ,public ::basctl::DocumentEventListener
157 private:
158 USHORT nMode;
159 ::basctl::DocumentEventNotifier m_aNotifier;
161 void SetEntryBitmaps( SvLBoxEntry * pEntry, const Image& rImage, const Image& rImageHC );
163 protected:
164 virtual void RequestingChilds( SvLBoxEntry* pParent );
165 virtual void ExpandedHdl();
166 virtual SvLBoxEntry* CloneEntry( SvLBoxEntry* pSource );
167 virtual long ExpandingHdl();
169 void ImpCreateLibEntries( SvLBoxEntry* pShellRootEntry, const ScriptDocument& rDocument, LibraryLocation eLocation );
170 void ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName );
171 void ImpCreateLibSubEntriesInVBAMode( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName );
172 void ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubRootEntry, const ScriptDocument& rDocument, const String& rLibName );
173 SvLBoxEntry* ImpFindEntry( SvLBoxEntry* pParent, const String& rText );
175 // DocumentEventListener
176 virtual void onDocumentCreated( const ScriptDocument& _rDocument );
177 virtual void onDocumentOpened( const ScriptDocument& _rDocument );
178 virtual void onDocumentSave( const ScriptDocument& _rDocument );
179 virtual void onDocumentSaveDone( const ScriptDocument& _rDocument );
180 virtual void onDocumentSaveAs( const ScriptDocument& _rDocument );
181 virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument );
182 virtual void onDocumentClosed( const ScriptDocument& _rDocument );
183 virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument );
184 virtual void onDocumentModeChanged( const ScriptDocument& _rDocument );
186 public:
187 BasicTreeListBox( Window* pParent, const ResId& rRes );
188 ~BasicTreeListBox();
190 void ScanEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
191 void ScanAllEntries();
192 void UpdateEntries();
194 BOOL IsEntryProtected( SvLBoxEntry* pEntry );
196 void SetMode( USHORT nM ) { nMode = nM; }
197 USHORT GetMode() const { return nMode; }
199 SbModule* FindModule( SvLBoxEntry* pEntry );
200 SbxVariable* FindVariable( SvLBoxEntry* pEntry );
201 SvLBoxEntry* FindRootEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
202 SvLBoxEntry* FindEntry( SvLBoxEntry* pParent, const String& rText, BasicEntryType eType );
204 BasicEntryDescriptor GetEntryDescriptor( SvLBoxEntry* pEntry );
206 USHORT ConvertType( BasicEntryType eType );
207 bool IsValidEntry( SvLBoxEntry* pEntry );
209 SvLBoxEntry* AddEntry( const String& rText, const Image& rImage, const Image& rImageHC,
210 SvLBoxEntry* pParent, bool bChildrenOnDemand,
211 std::auto_ptr< BasicEntry > aUserData );
213 String GetRootEntryName( const ScriptDocument& rDocument, LibraryLocation eLocation ) const;
214 void GetRootEntryBitmaps( const ScriptDocument& rDocument, Image& rImage, Image& rImageHC );
216 void SetCurrentEntry( BasicEntryDescriptor& rDesc );
218 private:
219 LibraryType GetLibraryType() const;
222 #endif // _BASTYPE2_HXX