1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bastype2.hxx,v $
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 ************************************************************************/
33 #include "doceventnotifier.hxx"
36 #include "tools/solar.h"
39 #include <svtools/svtreebx.hxx>
40 #include <svtools/lstner.hxx>
41 #include <basic/sbstar.hxx>
42 #include <sbxitem.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
62 BasicEntryType m_eType
;
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
75 ScriptDocument m_aDocument
;
76 LibraryLocation m_eLocation
;
79 BasicDocumentEntry( const ScriptDocument
& rDocument
, LibraryLocation eLocation
, BasicEntryType eType
= OBJ_TYPE_DOCUMENT
);
80 virtual ~BasicDocumentEntry();
83 GetDocument() const { return m_aDocument
; }
84 LibraryLocation
GetLocation() const { return m_eLocation
; }
87 class BasicLibEntry
: public BasicDocumentEntry
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
;
104 String m_aLibSubName
; // for vba entry: Document Objects, Class Modules, Forms and Normal Modules
106 String m_aMethodName
;
107 BasicEntryType m_eType
;
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
159 ::basctl::DocumentEventNotifier m_aNotifier
;
161 void SetEntryBitmaps( SvLBoxEntry
* pEntry
, const Image
& rImage
, const Image
& rImageHC
);
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
);
187 BasicTreeListBox( Window
* pParent
, const ResId
& rRes
);
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
);
219 LibraryType
GetLibraryType() const;
222 #endif // _BASTYPE2_HXX