bump product version to 5.0.4.1
[LibreOffice.git] / idl / source / objects / basobj.cxx
blobbde7d8a1dd03c262e021b8033619a4e37dfce93e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <ctype.h>
22 #include <stdio.h>
24 #include <tools/debug.hxx>
26 #include <basobj.hxx>
27 #include <module.hxx>
28 #include <globals.hxx>
29 #include <database.hxx>
31 TYPEINIT1( SvMetaObject, SvRttiBase )
32 SvMetaObject::SvMetaObject()
36 void SvMetaObject::WriteTab( SvStream & rOutStm, sal_uInt16 nTab )
38 while( nTab-- )
39 rOutStm.WriteCharPtr( " " );
42 void SvMetaObject::WriteStars( SvStream & rOutStm )
44 rOutStm.WriteChar( '/' );
45 for( int i = 6; i > 0; i-- )
46 rOutStm.WriteCharPtr( "**********" );
47 rOutStm.WriteChar( '/' ) << endl;
50 void SvMetaObject::Back2Delemitter( SvStream & rOutStm )
52 // write no empty brackets
53 sal_uLong nPos = rOutStm.Tell();
54 rOutStm.SeekRel( -1 );
55 char c = 0;
56 rOutStm.ReadChar( c );
58 while( isspace( c ) && rOutStm.Tell() != 1 )
60 rOutStm.SeekRel( -2 );
61 rOutStm.ReadChar( c );
64 if( c == ';' || c == ',' )
65 rOutStm.SeekRel( -1 );
66 else
67 rOutStm.Seek( nPos );
70 bool SvMetaObject::ReadSvIdl( SvIdlDataBase &, SvTokenStream & )
72 return false;
75 TYPEINIT1( SvMetaName, SvMetaObject );
76 SvMetaName::SvMetaName()
80 bool SvMetaName::SetName( const OString& rName, SvIdlDataBase * )
82 aName.setString(rName);
83 return true;
86 bool SvMetaName::ReadNameSvIdl( SvIdlDataBase & rBase,
87 SvTokenStream & rInStm )
89 sal_uInt32 nTokPos = rInStm.Tell();
90 SvToken * pTok = rInStm.GetToken_Next();
92 // read module name
93 if( pTok->IsIdentifier() )
94 if( SetName( pTok->GetString(), &rBase ) )
95 return true;
97 rInStm.Seek( nTokPos );
98 return false;
101 void SvMetaName::ReadAttributesSvIdl( SvIdlDataBase & rBase,
102 SvTokenStream & rInStm )
104 sal_uInt32 nTokPos = rInStm.Tell();
105 if( aName.ReadSvIdl( SvHash_Name(), rInStm ) )
107 if( !SetName( aName.getString(), &rBase ) )
108 rInStm.Seek( nTokPos );
111 aHelpContext.ReadSvIdl( rBase, SvHash_HelpContext(), rInStm );
112 aHelpText.ReadSvIdl( rBase, rInStm );
113 aConfigName.ReadSvIdl( SvHash_ConfigName(), rInStm );
114 aDescription.ReadSvIdl( SvHash_Description(), rInStm );
117 void SvMetaName::DoReadContextSvIdl( SvIdlDataBase & rBase,
118 SvTokenStream & rInStm, char cDel )
120 sal_uInt32 nBeginPos = 0; // can not happen with Tell
121 while( nBeginPos != rInStm.Tell() )
123 nBeginPos = rInStm.Tell();
124 ReadContextSvIdl( rBase, rInStm );
125 if( cDel == '\0' )
126 rInStm.ReadDelemiter();
127 else
128 (void)rInStm.Read( cDel );
132 void SvMetaName::ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & )
136 bool SvMetaName::Test( SvIdlDataBase &, SvTokenStream & )
138 return true;
141 bool SvMetaName::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm )
143 sal_uInt32 nTokPos = rInStm.Tell();
144 bool bOk = true;
145 if( rInStm.Read( '[' ) )
147 sal_uInt32 nBeginPos = 0; // can not happen with Tell
148 while( nBeginPos != rInStm.Tell() )
150 nBeginPos = rInStm.Tell();
151 ReadAttributesSvIdl( rBase, rInStm );
152 rInStm.ReadDelemiter();
154 bOk = rInStm.Read( ']' );
157 if( bOk )
159 if( rInStm.Read( '{' ) )
161 DoReadContextSvIdl( rBase, rInStm );
162 bOk = rInStm.Read( '}' );
166 if( !bOk )
167 rInStm.Seek( nTokPos );
168 return bOk;
171 TYPEINIT1( SvMetaReference, SvMetaName );
173 SvMetaReference::SvMetaReference()
177 TYPEINIT1( SvMetaExtern, SvMetaReference );
179 SvMetaExtern::SvMetaExtern()
180 : pModule( NULL )
181 , bReadUUId( false )
182 , bReadVersion( false )
186 SvMetaModule * SvMetaExtern::GetModule() const
188 DBG_ASSERT( pModule != NULL, "module not set" );
189 return pModule;
192 const SvGlobalName & SvMetaExtern::GetUUId() const
194 if( aUUId == SvGlobalName() )
195 GetModule()->FillNextName( &const_cast<SvMetaExtern *>(this)->aUUId );
196 return aUUId;
199 void SvMetaExtern::SetModule( SvIdlDataBase & rBase )
201 pModule = static_cast<SvMetaModule *>(rBase.GetStack().Get( TYPE( SvMetaModule ) ));
204 void SvMetaExtern::ReadAttributesSvIdl( SvIdlDataBase & rBase,
205 SvTokenStream & rInStm )
207 SvMetaReference::ReadAttributesSvIdl( rBase, rInStm );
208 if( aUUId.ReadSvIdl( rBase, rInStm ) )
209 bReadUUId = true;
210 if( aVersion.ReadSvIdl( rInStm ) )
211 bReadVersion = true;
214 bool SvMetaExtern::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm )
216 SetModule( rBase );
217 GetUUId(); // id gets created
218 return SvMetaReference::ReadSvIdl( rBase, rInStm );
221 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */