1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
24 #include <tools/debug.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
)
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 );
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 );
70 bool SvMetaObject::ReadSvIdl( SvIdlDataBase
&, SvTokenStream
& )
75 TYPEINIT1( SvMetaName
, SvMetaObject
);
76 SvMetaName::SvMetaName()
80 bool SvMetaName::SetName( const OString
& rName
, SvIdlDataBase
* )
82 aName
.setString(rName
);
86 bool SvMetaName::ReadNameSvIdl( SvIdlDataBase
& rBase
,
87 SvTokenStream
& rInStm
)
89 sal_uInt32 nTokPos
= rInStm
.Tell();
90 SvToken
* pTok
= rInStm
.GetToken_Next();
93 if( pTok
->IsIdentifier() )
94 if( SetName( pTok
->GetString(), &rBase
) )
97 rInStm
.Seek( nTokPos
);
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
);
126 rInStm
.ReadDelemiter();
128 (void)rInStm
.Read( cDel
);
132 void SvMetaName::ReadContextSvIdl( SvIdlDataBase
&, SvTokenStream
& )
136 bool SvMetaName::Test( SvIdlDataBase
&, SvTokenStream
& )
141 bool SvMetaName::ReadSvIdl( SvIdlDataBase
& rBase
, SvTokenStream
& rInStm
)
143 sal_uInt32 nTokPos
= rInStm
.Tell();
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( ']' );
159 if( rInStm
.Read( '{' ) )
161 DoReadContextSvIdl( rBase
, rInStm
);
162 bOk
= rInStm
.Read( '}' );
167 rInStm
.Seek( nTokPos
);
171 TYPEINIT1( SvMetaReference
, SvMetaName
);
173 SvMetaReference::SvMetaReference()
177 TYPEINIT1( SvMetaExtern
, SvMetaReference
);
179 SvMetaExtern::SvMetaExtern()
182 , bReadVersion( false )
186 SvMetaModule
* SvMetaExtern::GetModule() const
188 DBG_ASSERT( pModule
!= NULL
, "module not set" );
192 const SvGlobalName
& SvMetaExtern::GetUUId() const
194 if( aUUId
== SvGlobalName() )
195 GetModule()->FillNextName( &const_cast<SvMetaExtern
*>(this)->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
) )
210 if( aVersion
.ReadSvIdl( rInStm
) )
214 bool SvMetaExtern::ReadSvIdl( SvIdlDataBase
& rBase
, SvTokenStream
& rInStm
)
217 GetUUId(); // id gets created
218 return SvMetaReference::ReadSvIdl( rBase
, rInStm
);
221 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */