merged tag ooo/DEV300_m102
[LibreOffice.git] / idl / inc / database.hxx
blobb3f9ca5b154fbb78c940734488da4d91e6e71031
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _DATABASE_HXX
29 #define _DATABASE_HXX
31 #include <module.hxx>
32 #include <hash.hxx>
33 #include <lex.hxx>
34 #include <tools/pstm.hxx>
36 /*************************************************************************
37 *************************************************************************/
39 class SvCommand;
41 #ifdef IDL_COMPILER
42 /******************** class SvIdlError ***********************************/
43 class SvIdlError
45 ByteString aText;
46 public:
47 sal_uInt32 nLine, nColumn;
49 SvIdlError() : nLine(0), nColumn(0) {}
50 SvIdlError( sal_uInt32 nL, sal_uInt32 nC )
51 : nLine(nL), nColumn(nC) {}
53 const ByteString & GetText() const { return aText; }
54 void SetText( const ByteString & rT ) { aText = rT; }
55 sal_Bool IsError() const { return nLine != 0; }
56 void Clear() { nLine = nColumn = 0; }
57 SvIdlError & operator = ( const SvIdlError & rRef )
58 { aText = rRef.aText;
59 nLine = rRef.nLine;
60 nColumn = rRef.nColumn;
61 return *this;
64 #endif
66 /******************** class SvIdlDataBase ********************************/
67 class SvIdlDataBase
69 sal_Bool bExport;
70 String aExportFile;
71 sal_uInt32 nUniqueId;
72 sal_uInt32 nVerbosity;
73 String aDataBaseFile;
74 SvFileStream * pStm;
75 sal_Bool bIsModified;
76 SvPersistStream aPersStream;
77 StringList aIdFileList;
78 SvStringHashTable * pIdTable;
80 SvMetaTypeMemberList aTypeList;
81 SvMetaClassMemberList aClassList;
82 SvMetaModuleMemberList aModuleList;
83 SvMetaAttributeMemberList aAttrList;
84 SvMetaTypeMemberList aTmpTypeList; // nicht Persistent
86 protected:
87 #ifdef IDL_COMPILER
88 ByteString aModulePrefix;
89 SvMetaObjectMemberStack aContextStack;
90 String aPath;
91 SvIdlError aError;
92 void WriteReset()
94 aUsedTypes.Clear();
95 aIFaceName.Erase();
97 #endif
98 public:
99 explicit SvIdlDataBase( const SvCommand& rCmd );
100 ~SvIdlDataBase();
101 static sal_Bool IsBinaryFormat( SvStream & rInStm );
103 void Load( SvStream & rInStm );
104 void Save( SvStream & rInStm, sal_uInt32 nContextFlags );
106 SvMetaAttributeMemberList& GetAttrList() { return aAttrList; }
107 SvStringHashTable * GetIdTable() { return pIdTable; }
108 SvMetaTypeMemberList & GetTypeList();
109 SvMetaClassMemberList & GetClassList() { return aClassList; }
110 SvMetaModuleMemberList & GetModuleList() { return aModuleList; }
111 SvMetaModule * GetModule( const ByteString & rName );
113 // Liste der benutzten Typen beim Schreiben
114 SvMetaTypeMemberList aUsedTypes;
115 ByteString aIFaceName;
116 SvNumberIdentifier aStructSlotId;
118 #ifdef IDL_COMPILER
119 void StartNewFile( const String& rName );
120 void SetExportFile( const String& rName )
121 { aExportFile = rName; }
122 void AppendAttr( SvMetaAttribute *pSlot );
123 const ByteString& GetActModulePrefix() const { return aModulePrefix; }
124 const SvIdlError & GetError() const { return aError; }
125 void SetError( const SvIdlError & r )
126 { aError = r; }
128 const String & GetPath() const { return aPath; }
129 SvMetaObjectMemberStack & GetStack() { return aContextStack; }
131 void Write( const ByteString & rText );
132 void WriteError( const ByteString & rErrWrn,
133 const ByteString & rFileName,
134 const ByteString & rErrorText,
135 sal_uLong nRow = 0, sal_uLong nColumn = 0 ) const;
136 void WriteError( SvTokenStream & rInStm );
137 void SetError( const ByteString & rError, SvToken * pTok );
138 void Push( SvMetaObject * pObj );
139 sal_Bool Pop( sal_Bool bOk, SvTokenStream & rInStm, sal_uInt32 nTokPos )
141 GetStack().Pop();
142 if( bOk )
143 aError.Clear();
144 else
145 rInStm.Seek( nTokPos );
146 return bOk;
148 sal_uInt32 GetUniqueId() { return ++nUniqueId; }
149 sal_Bool FindId( const ByteString & rIdName, sal_uLong * pVal );
150 sal_Bool InsertId( const ByteString & rIdName, sal_uLong nVal );
151 sal_Bool ReadIdFile( const String & rFileName );
153 SvMetaType * FindType( const ByteString & rName );
154 static SvMetaType * FindType( const SvMetaType *, SvMetaTypeMemberList & );
156 SvMetaType * ReadKnownType( SvTokenStream & rInStm );
157 SvMetaAttribute * ReadKnownAttr( SvTokenStream & rInStm,
158 SvMetaType * pType = NULL );
159 SvMetaAttribute * SearchKnownAttr( const SvNumberIdentifier& );
160 SvMetaClass * ReadKnownClass( SvTokenStream & rInStm );
161 #endif
164 #ifdef IDL_COMPILER
165 class SvIdlWorkingBase : public SvIdlDataBase
167 public:
168 explicit SvIdlWorkingBase( const SvCommand& rCmd );
170 sal_Bool ReadSvIdl( SvTokenStream &, sal_Bool bImported, const String & rPath );
171 sal_Bool WriteSvIdl( SvStream & );
173 sal_Bool WriteSfx( SvStream & );
174 sal_Bool WriteHelpIds( SvStream & );
175 sal_Bool WriteSfxItem( SvStream & );
176 sal_Bool WriteCSV( SvStream& );
177 sal_Bool WriteDocumentation( SvStream& );
179 #endif
181 #endif // _DATABASE_HXX