Bump for 3.6-28
[LibreOffice.git] / idl / inc / database.hxx
bloba6f8bc77a6ea2289a7e630b07f3bb782c35c9f3f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _DATABASE_HXX
30 #define _DATABASE_HXX
32 #include <module.hxx>
33 #include <hash.hxx>
34 #include <lex.hxx>
35 #include <rtl/string.hxx>
36 #include <tools/pstm.hxx>
38 #include <rtl/ustring.hxx>
39 #include <set>
41 class SvCommand;
43 class SvIdlError
45 rtl::OString 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 rtl::OString& GetText() const { return aText; }
54 void SetText( const rtl::OString& 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;
65 class SvIdlDataBase
67 sal_Bool bExport;
68 String aExportFile;
69 sal_uInt32 nUniqueId;
70 sal_uInt32 nVerbosity;
71 String aDataBaseFile;
72 SvFileStream * pStm;
73 sal_Bool bIsModified;
74 SvPersistStream aPersStream;
75 StringList aIdFileList;
76 SvStringHashTable * pIdTable;
78 SvMetaTypeMemberList aTypeList;
79 SvMetaClassMemberList aClassList;
80 SvMetaModuleMemberList aModuleList;
81 SvMetaAttributeMemberList aAttrList;
82 SvMetaTypeMemberList aTmpTypeList; // not persistent
84 protected:
85 ::std::set< ::rtl::OUString > m_DepFiles;
86 SvMetaObjectMemberStack aContextStack;
87 String aPath;
88 SvIdlError aError;
89 void WriteReset()
91 aUsedTypes.Clear();
92 aIFaceName = rtl::OString();
94 public:
95 explicit SvIdlDataBase( const SvCommand& rCmd );
96 ~SvIdlDataBase();
97 static sal_Bool IsBinaryFormat( SvStream & rInStm );
99 void Load( SvStream & rInStm );
100 void Save( SvStream & rInStm, sal_uInt32 nContextFlags );
102 SvMetaAttributeMemberList& GetAttrList() { return aAttrList; }
103 SvStringHashTable * GetIdTable() { return pIdTable; }
104 SvMetaTypeMemberList & GetTypeList();
105 SvMetaClassMemberList & GetClassList() { return aClassList; }
106 SvMetaModuleMemberList & GetModuleList() { return aModuleList; }
107 SvMetaModule * GetModule( const rtl::OString& rName );
109 // list of used types while writing
110 SvMetaTypeMemberList aUsedTypes;
111 rtl::OString aIFaceName;
112 SvNumberIdentifier aStructSlotId;
114 void StartNewFile( const String& rName );
115 void SetExportFile( const String& rName )
116 { aExportFile = rName; }
117 void AppendAttr( SvMetaAttribute *pSlot );
118 const SvIdlError & GetError() const { return aError; }
119 void SetError( const SvIdlError & r )
120 { aError = r; }
122 const String & GetPath() const { return aPath; }
123 SvMetaObjectMemberStack & GetStack() { return aContextStack; }
125 void Write(const rtl::OString& rText);
126 void WriteError(const rtl::OString& rErrWrn,
127 const rtl::OString& rFileName,
128 const rtl::OString& rErrorText,
129 sal_uLong nRow = 0, sal_uLong nColumn = 0 ) const;
130 void WriteError( SvTokenStream & rInStm );
131 void SetError( const rtl::OString& rError, SvToken * pTok );
132 void Push( SvMetaObject * pObj );
133 sal_Bool Pop( sal_Bool bOk, SvTokenStream & rInStm, sal_uInt32 nTokPos )
135 GetStack().Pop();
136 if( bOk )
137 aError.Clear();
138 else
139 rInStm.Seek( nTokPos );
140 return bOk;
142 sal_uInt32 GetUniqueId() { return ++nUniqueId; }
143 sal_Bool FindId( const rtl::OString& rIdName, sal_uLong * pVal );
144 sal_Bool InsertId( const rtl::OString& rIdName, sal_uLong nVal );
145 sal_Bool ReadIdFile( const String & rFileName );
147 SvMetaType * FindType( const rtl::OString& rName );
148 static SvMetaType * FindType( const SvMetaType *, SvMetaTypeMemberList & );
150 SvMetaType * ReadKnownType( SvTokenStream & rInStm );
151 SvMetaAttribute * ReadKnownAttr( SvTokenStream & rInStm,
152 SvMetaType * pType = NULL );
153 SvMetaAttribute * SearchKnownAttr( const SvNumberIdentifier& );
154 SvMetaClass * ReadKnownClass( SvTokenStream & rInStm );
155 void AddDepFile(String const& rFileName);
156 bool WriteDepFile(SvFileStream & rStream, ::rtl::OUString const& rTarget);
159 class SvIdlWorkingBase : public SvIdlDataBase
161 public:
162 explicit SvIdlWorkingBase( const SvCommand& rCmd );
164 sal_Bool ReadSvIdl( SvTokenStream &, sal_Bool bImported, const String & rPath );
165 sal_Bool WriteSvIdl( SvStream & );
167 sal_Bool WriteSfx( SvStream & );
168 sal_Bool WriteHelpIds( SvStream & );
169 sal_Bool WriteSfxItem( SvStream & );
170 sal_Bool WriteCSV( SvStream& );
171 sal_Bool WriteDocumentation( SvStream& );
174 #endif // _DATABASE_HXX
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */