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: database.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 ************************************************************************/
37 #include <tools/pstm.hxx>
39 /*************************************************************************
40 *************************************************************************/
43 /******************** class SvIdlError ***********************************/
48 UINT32 nLine
, nColumn
;
50 SvIdlError() : nLine(0), nColumn(0) {}
51 SvIdlError( UINT32 nL
, UINT32 nC
)
52 : nLine(nL
), nColumn(nC
) {}
54 const ByteString
& GetText() const { return aText
; }
55 void SetText( const ByteString
& rT
) { aText
= rT
; }
56 BOOL
IsError() const { return nLine
!= 0; }
57 void Clear() { nLine
= nColumn
= 0; }
58 SvIdlError
& operator = ( const SvIdlError
& rRef
)
61 nColumn
= rRef
.nColumn
;
67 /******************** class SvIdlDataBase ********************************/
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
88 ByteString aModulePrefix
;
89 SvMetaObjectMemberStack aContextStack
;
101 static BOOL
IsBinaryFormat( SvStream
& rInStm
);
103 void Load( SvStream
& rInStm
);
104 void Save( SvStream
& rInStm
, 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
;
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
)
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 ULONG nRow
= 0, ULONG nColumn
= 0 ) const;
136 void WriteError( SvTokenStream
& rInStm
);
137 void SetError( const ByteString
& rError
, SvToken
* pTok
);
138 void Push( SvMetaObject
* pObj
);
139 BOOL
Pop( BOOL bOk
, SvTokenStream
& rInStm
, UINT32 nTokPos
)
145 rInStm
.Seek( nTokPos
);
148 sal_uInt32
GetUniqueId() { return ++nUniqueId
; }
149 BOOL
FindId( const ByteString
& rIdName
, ULONG
* pVal
);
150 BOOL
InsertId( const ByteString
& rIdName
, ULONG nVal
);
151 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
);
165 class SvIdlWorkingBase
: public SvIdlDataBase
170 BOOL
ReadSvIdl( SvTokenStream
&, BOOL bImported
, const String
& rPath
);
171 BOOL
WriteSvIdl( SvStream
& );
173 BOOL
WriteSfx( SvStream
& );
174 BOOL
WriteHelpIds( SvStream
& );
175 BOOL
WriteSfxItem( SvStream
& );
176 BOOL
WriteCSV( SvStream
& );
177 BOOL
WriteDocumentation( SvStream
& );
181 #endif // _DATABASE_HXX