merge the formfield patch from ooo-build
[ooovba.git] / idl / inc / database.hxx
blob4daa5b9f52fd73c5d838cfcb432ad13ba3bba48f
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: database.hxx,v $
10 * $Revision: 1.6 $
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 ************************************************************************/
31 #ifndef _DATABASE_HXX
32 #define _DATABASE_HXX
34 #include <module.hxx>
35 #include <hash.hxx>
36 #include <lex.hxx>
37 #include <tools/pstm.hxx>
39 /*************************************************************************
40 *************************************************************************/
42 class SvCommand;
44 #ifdef IDL_COMPILER
45 /******************** class SvIdlError ***********************************/
46 class SvIdlError
48 ByteString aText;
49 public:
50 UINT32 nLine, nColumn;
52 SvIdlError() : nLine(0), nColumn(0) {}
53 SvIdlError( UINT32 nL, UINT32 nC )
54 : nLine(nL), nColumn(nC) {}
56 const ByteString & GetText() const { return aText; }
57 void SetText( const ByteString & rT ) { aText = rT; }
58 BOOL IsError() const { return nLine != 0; }
59 void Clear() { nLine = nColumn = 0; }
60 SvIdlError & operator = ( const SvIdlError & rRef )
61 { aText = rRef.aText;
62 nLine = rRef.nLine;
63 nColumn = rRef.nColumn;
64 return *this;
67 #endif
69 /******************** class SvIdlDataBase ********************************/
70 class SvIdlDataBase
72 BOOL bExport;
73 String aExportFile;
74 sal_uInt32 nUniqueId;
75 sal_uInt32 nVerbosity;
76 String aDataBaseFile;
77 SvFileStream * pStm;
78 BOOL bIsModified;
79 SvPersistStream aPersStream;
80 StringList aIdFileList;
81 SvStringHashTable * pIdTable;
83 SvMetaTypeMemberList aTypeList;
84 SvMetaClassMemberList aClassList;
85 SvMetaModuleMemberList aModuleList;
86 SvMetaAttributeMemberList aAttrList;
87 SvMetaTypeMemberList aTmpTypeList; // nicht Persistent
89 protected:
90 #ifdef IDL_COMPILER
91 ByteString aModulePrefix;
92 SvMetaObjectMemberStack aContextStack;
93 String aPath;
94 SvIdlError aError;
95 void WriteReset()
97 aUsedTypes.Clear();
98 aIFaceName.Erase();
100 #endif
101 public:
102 explicit SvIdlDataBase( const SvCommand& rCmd );
103 ~SvIdlDataBase();
104 static BOOL IsBinaryFormat( SvStream & rInStm );
106 void Load( SvStream & rInStm );
107 void Save( SvStream & rInStm, UINT32 nContextFlags );
109 SvMetaAttributeMemberList& GetAttrList() { return aAttrList; }
110 SvStringHashTable * GetIdTable() { return pIdTable; }
111 SvMetaTypeMemberList & GetTypeList();
112 SvMetaClassMemberList & GetClassList() { return aClassList; }
113 SvMetaModuleMemberList & GetModuleList() { return aModuleList; }
114 SvMetaModule * GetModule( const ByteString & rName );
116 // Liste der benutzten Typen beim Schreiben
117 SvMetaTypeMemberList aUsedTypes;
118 ByteString aIFaceName;
119 SvNumberIdentifier aStructSlotId;
121 #ifdef IDL_COMPILER
122 void StartNewFile( const String& rName );
123 void SetExportFile( const String& rName )
124 { aExportFile = rName; }
125 void AppendAttr( SvMetaAttribute *pSlot );
126 const ByteString& GetActModulePrefix() const { return aModulePrefix; }
127 const SvIdlError & GetError() const { return aError; }
128 void SetError( const SvIdlError & r )
129 { aError = r; }
131 const String & GetPath() const { return aPath; }
132 SvMetaObjectMemberStack & GetStack() { return aContextStack; }
134 void Write( const ByteString & rText );
135 void WriteError( const ByteString & rErrWrn,
136 const ByteString & rFileName,
137 const ByteString & rErrorText,
138 ULONG nRow = 0, ULONG nColumn = 0 ) const;
139 void WriteError( SvTokenStream & rInStm );
140 void SetError( const ByteString & rError, SvToken * pTok );
141 void Push( SvMetaObject * pObj );
142 BOOL Pop( BOOL bOk, SvTokenStream & rInStm, UINT32 nTokPos )
144 GetStack().Pop();
145 if( bOk )
146 aError.Clear();
147 else
148 rInStm.Seek( nTokPos );
149 return bOk;
151 sal_uInt32 GetUniqueId() { return ++nUniqueId; }
152 BOOL FindId( const ByteString & rIdName, ULONG * pVal );
153 BOOL InsertId( const ByteString & rIdName, ULONG nVal );
154 BOOL ReadIdFile( const String & rFileName );
156 SvMetaType * FindType( const ByteString & rName );
157 static SvMetaType * FindType( const SvMetaType *, SvMetaTypeMemberList & );
159 SvMetaType * ReadKnownType( SvTokenStream & rInStm );
160 SvMetaAttribute * ReadKnownAttr( SvTokenStream & rInStm,
161 SvMetaType * pType = NULL );
162 SvMetaAttribute * SearchKnownAttr( const SvNumberIdentifier& );
163 SvMetaClass * ReadKnownClass( SvTokenStream & rInStm );
164 #endif
167 #ifdef IDL_COMPILER
168 class SvIdlWorkingBase : public SvIdlDataBase
170 public:
171 explicit SvIdlWorkingBase( const SvCommand& rCmd );
173 BOOL ReadSvIdl( SvTokenStream &, BOOL bImported, const String & rPath );
174 BOOL WriteSvIdl( SvStream & );
176 BOOL WriteSfx( SvStream & );
177 BOOL WriteHelpIds( SvStream & );
178 BOOL WriteSfxItem( SvStream & );
179 BOOL WriteCSV( SvStream& );
180 BOOL WriteDocumentation( SvStream& );
182 #endif
184 #endif // _DATABASE_HXX