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 *************************************************************************/
45 /******************** class SvIdlError ***********************************/
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
)
63 nColumn
= rRef
.nColumn
;
69 /******************** class SvIdlDataBase ********************************/
75 sal_uInt32 nVerbosity
;
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
91 ByteString aModulePrefix
;
92 SvMetaObjectMemberStack aContextStack
;
102 explicit SvIdlDataBase( const SvCommand
& rCmd
);
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
;
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
)
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
)
148 rInStm
.Seek( nTokPos
);
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
);
168 class SvIdlWorkingBase
: public SvIdlDataBase
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
& );
184 #endif // _DATABASE_HXX