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 ************************************************************************/
33 #include <tools/fsys.hxx>
34 #include <tools/debug.hxx>
35 #include <database.hxx>
36 #include <globals.hxx>
37 #include <rtl/strbuf.hxx>
39 SvIdlDataBase::SvIdlDataBase( const SvCommand
& rCmd
)
40 : bExport( sal_False
)
42 , nVerbosity( rCmd
.nVerbosity
)
43 , bIsModified( sal_False
)
44 , aPersStream( *IDLAPP
->pClassMgr
, NULL
)
49 SvIdlDataBase::~SvIdlDataBase()
51 for ( size_t i
= 0, n
= aIdFileList
.size(); i
< n
; ++i
)
52 delete aIdFileList
[ i
];
58 #define ADD_TYPE( Name, OdlName, ParserChar, CName, BasName, BasPost ) \
59 aTypeList.Append( new SvMetaType( SvHash_##Name()->GetName(), \
60 BasName, OdlName, ParserChar, CName, BasName, BasPost ) );
62 SvMetaTypeMemberList
& SvIdlDataBase::GetTypeList()
64 if( aTypeList
.Count() == 0 )
66 aTypeList
.Append( new SvMetaTypeString() );
67 aTypeList
.Append( new SvMetaTypevoid() );
69 // MI: IDispatch::Invoke can not unsigned
70 ADD_TYPE( UINT16
, "long", 'h', "unsigned short", "Long", "&" );
71 ADD_TYPE( INT16
, "short", 'h', "short", "Integer", "%" );
72 ADD_TYPE( UINT32
, "long", 'l', "unsigned long", "Long", "&" );
73 ADD_TYPE( INT32
, "long", 'l', "long", "Long", "&" );
74 ADD_TYPE( int, "int", 'i', "int", "Integer", "%" );
75 ADD_TYPE( BOOL
, "boolean", 'b', "unsigned char", "Boolean", "" );
76 ADD_TYPE( char, "char", 'c', "char", "Integer", "%" );
77 ADD_TYPE( BYTE
, "char", 'c', "unsigned char", "Integer", "%" );
78 ADD_TYPE( float, "float", 'f', "float", "Single", "!" );
79 ADD_TYPE( double, "double", 'F', "double", "Double", "#" );
80 ADD_TYPE( SbxObject
, "VARIANT", 'o', "C_Object", "Object", "" );
82 // Attention! When adding types all binary data bases get incompatible
88 SvMetaModule
* SvIdlDataBase::GetModule( const rtl::OString
& rName
)
90 for( sal_uLong n
= 0; n
< aModuleList
.Count(); n
++ )
91 if( aModuleList
.GetObject( n
)->GetName().getString().equals(rName
) )
92 return aModuleList
.GetObject( n
);
96 #define DATABASE_SIGNATURE (sal_uInt32)0x13B799F2
97 #define DATABASE_VER 0x0006
98 sal_Bool
SvIdlDataBase::IsBinaryFormat( SvStream
& rStm
)
101 sal_uLong nPos
= rStm
.Tell();
105 return nSig
== DATABASE_SIGNATURE
;
108 void SvIdlDataBase::Load( SvStream
& rStm
)
110 DBG_ASSERT( aTypeList
.Count() == 0, "type list already initialized" );
111 SvPersistStream
aPStm( *IDLAPP
->pClassMgr
, &rStm
);
113 sal_uInt16 nVersion
= 0;
118 if( nSig
!= DATABASE_SIGNATURE
)
120 aPStm
.SetError( SVSTREAM_FILEFORMAT_ERROR
);
123 if( nVersion
!= DATABASE_VER
)
125 aPStm
.SetError( SVSTREAM_WRONGVERSION
);
131 aPStm
>> aModuleList
;
135 aPStm
.SetError( SVSTREAM_GENERALERROR
);
138 void SvIdlDataBase::Save( SvStream
& rStm
, sal_uInt32 nFlags
)
140 SvPersistStream
aPStm( *IDLAPP
->pClassMgr
, &rStm
);
141 aPStm
.SetContextFlags( nFlags
);
143 aPStm
<< (sal_uInt32
)DATABASE_SIGNATURE
;
144 aPStm
<< (sal_uInt16
)DATABASE_VER
;
146 sal_Bool bOnlyStreamedObjs
= sal_False
;
147 if( nFlags
& IDL_WRITE_CALLING
)
148 bOnlyStreamedObjs
= sal_True
;
150 if( bOnlyStreamedObjs
)
152 SvMetaClassMemberList aList
;
153 for( sal_uLong n
= 0; n
< GetModuleList().Count(); n
++ )
155 SvMetaModule
* pModule
= GetModuleList().GetObject( n
);
156 if( !pModule
->IsImported() )
157 aList
.Append( pModule
->GetClassList() );
164 aTypeList
.WriteObjects( aPStm
, bOnlyStreamedObjs
);
165 aAttrList
.WriteObjects( aPStm
, bOnlyStreamedObjs
);
166 aModuleList
.WriteObjects( aPStm
, bOnlyStreamedObjs
);
170 void SvIdlDataBase::SetError( const rtl::OString
& rError
, SvToken
* pTok
)
172 if( pTok
->GetLine() > 10000 )
173 aError
.SetText( "hgchcg" );
175 if( aError
.nLine
< pTok
->GetLine()
176 || (aError
.nLine
== pTok
->GetLine() && aError
.nColumn
< pTok
->GetColumn()) )
178 aError
= SvIdlError( pTok
->GetLine(), pTok
->GetColumn() );
179 aError
.SetText( rError
);
183 void SvIdlDataBase::Push( SvMetaObject
* pObj
)
185 GetStack().Push( pObj
);
188 sal_Bool
SvIdlDataBase::FindId( const rtl::OString
& rIdName
, sal_uLong
* pVal
)
193 if( pIdTable
->Test( rIdName
, &nHash
) )
195 *pVal
= pIdTable
->Get( nHash
)->GetValue();
202 sal_Bool
SvIdlDataBase::InsertId( const rtl::OString
& rIdName
, sal_uLong nVal
)
205 pIdTable
= new SvStringHashTable( 20003 );
208 if( pIdTable
->Insert( rIdName
, &nHash
) )
210 pIdTable
->Get( nHash
)->SetValue( nVal
);
216 sal_Bool
SvIdlDataBase::ReadIdFile( const String
& rFileName
)
218 DirEntry
aFullName( rFileName
);
219 aFullName
.Find( GetPath() );
221 for ( size_t i
= 0, n
= aIdFileList
.size(); i
< n
; ++i
)
222 if ( *aIdFileList
[ i
] == rFileName
)
225 aIdFileList
.push_back( new String( rFileName
) );
227 this->AddDepFile(aFullName
.GetFull());
228 SvTokenStream
aTokStm( aFullName
.GetFull() );
229 if( aTokStm
.GetStream().GetError() == SVSTREAM_OK
)
231 SvToken
* pTok
= aTokStm
.GetToken_Next();
233 while( !pTok
->IsEof() )
235 if( pTok
->IsChar() && pTok
->GetChar() == '#' )
237 pTok
= aTokStm
.GetToken_Next();
238 if( pTok
->Is( SvHash_define() ) )
240 pTok
= aTokStm
.GetToken_Next();
241 rtl::OString aDefName
;
242 if( pTok
->IsIdentifier() )
243 aDefName
= pTok
->GetString();
246 rtl::OString
aStr(RTL_CONSTASCII_STRINGPARAM(
247 "unexpected token after define"));
249 SetError( aStr
, pTok
);
250 WriteError( aTokStm
);
255 sal_Bool bOk
= sal_True
;
258 pTok
= aTokStm
.GetToken_Next();
259 if( pTok
->IsIdentifier() )
262 if( FindId( pTok
->GetString(), &n
) )
267 else if( pTok
->IsChar() )
269 if( pTok
->GetChar() == '-'
270 || pTok
->GetChar() == '/'
271 || pTok
->GetChar() == '*'
272 || pTok
->GetChar() == '&'
273 || pTok
->GetChar() == '|'
274 || pTok
->GetChar() == '^'
275 || pTok
->GetChar() == '~' )
277 rtl::OStringBuffer
aStr("unknown operator '");
278 aStr
.append(pTok
->GetChar());
279 aStr
.append("'in define");
281 SetError( aStr
.makeStringAndClear(), pTok
);
282 WriteError( aTokStm
);
285 if( pTok
->GetChar() != '+'
286 && pTok
->GetChar() != '('
287 && pTok
->GetChar() != ')' )
288 // only + is allowed, parentheses are immaterial
289 // because + is commutative
292 else if( pTok
->IsInteger() )
294 nVal
+= pTok
->GetNumber();
301 if( !InsertId( aDefName
, nVal
) )
303 rtl::OString
aStr(RTL_CONSTASCII_STRINGPARAM("hash table overflow: "));
304 SetError( aStr
, pTok
);
305 WriteError( aTokStm
);
310 else if( pTok
->Is( SvHash_include() ) )
312 pTok
= aTokStm
.GetToken_Next();
313 rtl::OStringBuffer aName
;
314 if( pTok
->IsString() )
315 aName
.append(pTok
->GetString());
316 else if( pTok
->IsChar() && pTok
->GetChar() == '<' )
318 pTok
= aTokStm
.GetToken_Next();
319 while( !pTok
->IsEof()
320 && !(pTok
->IsChar() && pTok
->GetChar() == '>') )
322 aName
.append(pTok
->GetTokenAsString());
323 pTok
= aTokStm
.GetToken_Next();
327 rtl::OString
aStr(RTL_CONSTASCII_STRINGPARAM(
328 "unexpected eof in #include"));
330 SetError(aStr
, pTok
);
331 WriteError( aTokStm
);
335 if (!ReadIdFile(rtl::OStringToOUString(aName
.toString(),
336 RTL_TEXTENCODING_ASCII_US
)))
338 rtl::OStringBuffer
aStr(RTL_CONSTASCII_STRINGPARAM(
339 "cannot read file: "));
340 aStr
.append(aName
.makeStringAndClear());
341 SetError(aStr
.makeStringAndClear(), pTok
);
342 WriteError( aTokStm
);
348 pTok
= aTokStm
.GetToken_Next();
356 SvMetaType
* SvIdlDataBase::FindType( const SvMetaType
* pPType
,
357 SvMetaTypeMemberList
& rList
)
359 SvMetaType
* pType
= rList
.First();
360 while( pType
&& pPType
!= pType
)
361 pType
= rList
.Next();
365 SvMetaType
* SvIdlDataBase::FindType( const rtl::OString
& rName
)
367 SvMetaType
* pType
= aTypeList
.First();
368 while( pType
&& !rName
.equals(pType
->GetName().getString()) )
369 pType
= aTypeList
.Next();
373 SvMetaType
* SvIdlDataBase::ReadKnownType( SvTokenStream
& rInStm
)
375 sal_Bool bIn
= sal_False
;
376 sal_Bool bOut
= sal_False
;
377 int nCall0
= CALL_VALUE
;
378 int nCall1
= CALL_VALUE
;
379 sal_Bool bSet
= sal_False
; // any attribute set
381 sal_uInt32 nTokPos
= rInStm
.Tell();
382 SvToken
* pTok
= rInStm
.GetToken_Next();
384 if( pTok
->HasHash() )
386 sal_uInt32 nBeginPos
= 0; // can not happen with Tell
387 while( nBeginPos
!= rInStm
.Tell() )
389 nBeginPos
= rInStm
.Tell();
390 if( pTok
->Is( SvHash_in() ) )
393 pTok
= rInStm
.GetToken_Next();
396 if( pTok
->Is( SvHash_out() ) )
399 pTok
= rInStm
.GetToken_Next();
402 if( pTok
->Is( SvHash_inout() ) )
406 pTok
= rInStm
.GetToken_Next();
412 if( pTok
->IsIdentifier() )
414 rtl::OString aName
= pTok
->GetString();
415 SvMetaTypeMemberList
& rList
= GetTypeList();
416 SvMetaType
* pType
= rList
.First();
419 if( pType
->GetName().getString().equals(aName
) )
421 pType
= rList
.Next();
425 pTok
= rInStm
.GetToken();
428 if( pTok
->GetChar() == '&' || pTok
->GetChar() == '*' )
430 nCall0
= (pTok
->GetChar() == '&') ? CALL_REFERENCE
:
432 rInStm
.GetToken_Next();
433 pTok
= rInStm
.GetToken();
434 if( pTok
->GetChar() == '&' || pTok
->GetChar() == '*' )
436 nCall1
= (pTok
->GetChar() == '&') ? CALL_REFERENCE
:
438 rInStm
.GetToken_Next();
445 // is exactly this type
448 DBG_ASSERT( aTmpTypeList
.First(), "mindestens ein Element" );
449 SvMetaTypeRef xType
= new SvMetaType( pType
->GetName().getString(), 'h', "dummy" );
450 xType
->SetRef( pType
);
452 xType
->SetOut( bOut
);
453 xType
->SetCall0( nCall0
);
454 xType
->SetCall1( nCall1
);
456 aTmpTypeList
.Append( xType
);
460 rInStm
.Seek( nTokPos
);
464 SvMetaAttribute
* SvIdlDataBase::ReadKnownAttr
466 SvTokenStream
& rInStm
,
467 SvMetaType
* pType
/* If pType == NULL, then the type has
471 sal_uInt32 nTokPos
= rInStm
.Tell();
474 pType
= ReadKnownType( rInStm
);
479 SvToken
* pTok
= rInStm
.GetToken_Next();
480 if( pTok
->IsIdentifier() )
483 if( FindId( pTok
->GetString(), &n
) )
485 for( sal_uLong i
= 0; i
< aAttrList
.Count(); i
++ )
487 SvMetaAttribute
* pAttr
= aAttrList
.GetObject( i
);
488 if( pAttr
->GetSlotId().getString().equals(pTok
->GetString()) )
493 rtl::OStringBuffer
aStr("Nicht gefunden : ");
494 aStr
.append(pTok
->GetString());
495 OSL_FAIL(aStr
.getStr());
499 rInStm
.Seek( nTokPos
);
503 SvMetaAttribute
* SvIdlDataBase::SearchKnownAttr
505 const SvNumberIdentifier
& rId
509 if( FindId( rId
.getString(), &n
) )
511 for( sal_uLong i
= 0; i
< aAttrList
.Count(); i
++ )
513 SvMetaAttribute
* pAttr
= aAttrList
.GetObject( i
);
514 if( pAttr
->GetSlotId().getString() == rId
.getString() )
522 SvMetaClass
* SvIdlDataBase::ReadKnownClass( SvTokenStream
& rInStm
)
524 sal_uInt32 nTokPos
= rInStm
.Tell();
525 SvToken
* pTok
= rInStm
.GetToken_Next();
527 if( pTok
->IsIdentifier() )
528 for( sal_uLong n
= 0; n
< aClassList
.Count(); n
++ )
530 SvMetaClass
* pClass
= aClassList
.GetObject( n
);
531 if( pClass
->GetName().getString().equals(pTok
->GetString()) )
535 rInStm
.Seek( nTokPos
);
539 void SvIdlDataBase::Write(const rtl::OString
& rText
)
541 if( nVerbosity
!= 0 )
542 fprintf( stdout
, "%s", rText
.getStr() );
545 void SvIdlDataBase::WriteError( const rtl::OString
& rErrWrn
,
546 const rtl::OString
& rFileName
,
547 const rtl::OString
& rErrorText
,
548 sal_uLong nRow
, sal_uLong nColumn
) const
551 fprintf( stderr
, "\n%s --- %s: ( %ld, %ld )\n",
552 rFileName
.getStr(), rErrWrn
.getStr(), nRow
, nColumn
);
554 if( !rErrorText
.isEmpty() )
556 fprintf( stderr
, "\t%s\n", rErrorText
.getStr() );
560 void SvIdlDataBase::WriteError( SvTokenStream
& rInStm
)
563 String
aFileName( rInStm
.GetFileName() );
564 rtl::OStringBuffer aErrorText
;
565 sal_uLong nRow
= 0, nColumn
= 0;
568 SvToken
*pTok
= rInStm
.GetToken();
571 nRow
= pTok
->GetLine();
572 nColumn
= pTok
->GetColumn();
574 if( aError
.IsError() )
576 // search error token
578 if( !aError
.GetText().isEmpty() )
580 aErrorText
.append(RTL_CONSTASCII_STRINGPARAM("may be <"));
581 aErrorText
.append(aError
.GetText());
583 SvToken
* pPrevTok
= NULL
;
584 while( pTok
!= pPrevTok
)
587 if( pTok
->GetLine() == aError
.nLine
588 && pTok
->GetColumn() == aError
.nColumn
)
590 pTok
= rInStm
.GetToken_PrevAll();
594 aErrorText
.append(RTL_CONSTASCII_STRINGPARAM("> at ( "));
595 aErrorText
.append(static_cast<sal_Int64
>(aError
.nLine
));
596 aErrorText
.append(RTL_CONSTASCII_STRINGPARAM(", "));
597 aErrorText
.append(static_cast<sal_Int64
>(aError
.nColumn
));
598 aErrorText
.append(RTL_CONSTASCII_STRINGPARAM(" )"));
601 aError
= SvIdlError();
604 WriteError("error", rtl::OUStringToOString(aFileName
,
605 RTL_TEXTENCODING_UTF8
), aErrorText
.makeStringAndClear(), nRow
, nColumn
);
607 DBG_ASSERT( pTok
, "token must be found" );
611 // look for identifier close by
612 if( !pTok
->IsIdentifier() )
614 rInStm
.GetToken_PrevAll();
615 pTok
= rInStm
.GetToken();
617 if( pTok
&& pTok
->IsIdentifier() )
619 rtl::OString aN
= IDLAPP
->pHashTable
->GetNearString( pTok
->GetString() );
621 fprintf( stderr
, "%s versus %s\n", pTok
->GetString().getStr(), aN
.getStr() );
625 SvIdlWorkingBase::SvIdlWorkingBase(const SvCommand
& rCmd
) : SvIdlDataBase(rCmd
)
629 sal_Bool
SvIdlWorkingBase::ReadSvIdl( SvTokenStream
& rInStm
, sal_Bool bImported
, const String
& rPath
)
631 aPath
= rPath
; // only valid for this iteration
633 sal_Bool bOk
= sal_True
;
634 pTok
= rInStm
.GetToken();
635 // only one import at the very beginning
636 if( pTok
->Is( SvHash_import() ) )
638 rInStm
.GetToken_Next();
639 rInStm
.Read( '(' ); // optional
640 pTok
= rInStm
.GetToken_Next();
641 if( pTok
->IsString() )
643 DirEntry
aFullName( String::CreateFromAscii( pTok
->GetString().getStr() ) );
644 if( aFullName
.Find( rPath
) )
646 this->AddDepFile(aFullName
.GetFull());
647 SvFileStream
aStm( aFullName
.GetFull(),
648 STREAM_STD_READ
| STREAM_NOCREATE
);
650 if( aStm
.GetError() != SVSTREAM_OK
)
652 if( aStm
.GetError() == SVSTREAM_WRONGVERSION
)
654 rtl::OStringBuffer
aStr("wrong version, file ");
655 aStr
.append(rtl::OUStringToOString(
656 aFullName
.GetFull(), RTL_TEXTENCODING_UTF8
));
657 SetError(aStr
.makeStringAndClear(), pTok
);
658 WriteError( rInStm
);
665 SvTokenStream
aTokStm( aStm
, aFullName
.GetFull() );
666 bOk
= ReadSvIdl( aTokStm
, sal_True
, rPath
);
677 sal_uInt32 nBeginPos
= 0xFFFFFFFF; // can not happen with Tell
679 while( bOk
&& nBeginPos
!= rInStm
.Tell() )
681 nBeginPos
= rInStm
.Tell();
682 pTok
= rInStm
.GetToken();
685 if( pTok
->IsEmpty() )
688 // only one import at the very beginning
689 if( pTok
->Is( SvHash_module() ) )
691 SvMetaModuleRef aModule
= new SvMetaModule( rInStm
.GetFileName(), bImported
);
692 if( aModule
->ReadSvIdl( *this, rInStm
) )
693 GetModuleList().Append( aModule
);
700 if( !bOk
|| !pTok
->IsEof() )
703 WriteError( rInStm
);
709 sal_Bool
SvIdlWorkingBase::WriteSvIdl( SvStream
& rOutStm
)
711 if( rOutStm
.GetError() != SVSTREAM_OK
)
714 SvStringHashList aList
;
717 GetIdTable()->FillHashList( &aList
);
718 for ( size_t i
= 0, n
= aList
.size(); i
< n
; ++i
)
720 SvStringHashEntry
* pEntry
= aList
[ i
];
721 rOutStm
<< "#define " << pEntry
->GetName().getStr()
723 << rtl::OString::valueOf(static_cast<sal_Int64
>(
724 pEntry
->GetValue())).getStr()
729 for( sal_uLong n
= 0; n
< GetModuleList().Count(); n
++ )
731 SvMetaModule
* pModule
= GetModuleList().GetObject( n
);
732 pModule
->WriteSvIdl( *this, rOutStm
, 0 );
737 sal_Bool
SvIdlWorkingBase::WriteSfx( SvStream
& rOutStm
)
739 if( rOutStm
.GetError() != SVSTREAM_OK
)
742 // reset all tmp variables for writing
744 SvMemoryStream
aTmpStm( 256000, 256000 );
746 for( n
= 0; n
< GetModuleList().Count(); n
++ )
748 SvMetaModule
* pModule
= GetModuleList().GetObject( n
);
749 if( !pModule
->IsImported() )
750 pModule
->WriteSfx( *this, aTmpStm
);
753 for( n
= 0; n
< aUsedTypes
.Count(); n
++ )
755 SvMetaType
* pType
= aUsedTypes
.GetObject( n
);
756 pType
->WriteSfx( *this, rOutStm
);
763 sal_Bool
SvIdlWorkingBase::WriteHelpIds( SvStream
& rOutStm
)
765 if( rOutStm
.GetError() != SVSTREAM_OK
)
768 HelpIdTable aIdTable
;
770 for( n
= 0; n
< GetModuleList().Count(); n
++ )
772 SvMetaModule
* pModule
= GetModuleList().GetObject( n
);
773 pModule
->WriteHelpIds( *this, rOutStm
, aIdTable
);
776 const SvMetaAttributeMemberList
& rAttrList
= GetAttrList();
777 for( n
= 0; n
< rAttrList
.Count(); n
++ )
779 SvMetaAttribute
* pAttr
= rAttrList
.GetObject( n
);
780 pAttr
->WriteHelpId( *this, rOutStm
, aIdTable
);
786 sal_Bool
SvIdlWorkingBase::WriteSfxItem( SvStream
& )
791 void SvIdlDataBase::StartNewFile( const String
& rName
)
793 bExport
= ( aExportFile
.EqualsIgnoreCaseAscii( rName
) );
796 void SvIdlDataBase::AppendAttr( SvMetaAttribute
*pAttr
)
798 aAttrList
.Append( pAttr
);
800 pAttr
->SetNewAttribute( sal_True
);
803 sal_Bool
SvIdlWorkingBase::WriteCSV( SvStream
& rStrm
)
805 SvMetaAttributeMemberList
&rList
= GetAttrList();
806 sal_uLong nCount
= rList
.Count();
807 for ( sal_uLong n
=0; n
<nCount
; n
++ )
809 if ( rList
.GetObject(n
)->IsNewAttribute() )
811 rList
.GetObject(n
)->WriteCSV( *this, rStrm
);
815 if ( rStrm
.GetError() != SVSTREAM_OK
)
821 sal_Bool
SvIdlWorkingBase::WriteDocumentation( SvStream
& rOutStm
)
823 if( rOutStm
.GetError() != SVSTREAM_OK
)
826 for( sal_uLong n
= 0; n
< GetModuleList().Count(); n
++ )
828 SvMetaModule
* pModule
= GetModuleList().GetObject( n
);
829 if( !pModule
->IsImported() )
830 pModule
->Write( *this, rOutStm
, 0, WRITE_DOCU
);
835 void SvIdlDataBase::AddDepFile(String
const& rFileName
)
837 m_DepFiles
.insert(rFileName
);
841 static ::rtl::OString
842 lcl_ConvertToCygwin(::rtl::OString
const& rString
)
845 sal_Int32
const len
= rString
.getLength();
846 ::rtl::OStringBuffer
buf(len
+ 16);
847 if ((2 <= len
) && (':' == rString
[1]))
849 buf
.append("/cygdrive/");
850 buf
.append(static_cast<sal_Char
>(tolower(rString
[0])));
855 sal_Char
const c(rString
[i
]);
869 return buf
.makeStringAndClear();
873 static ::rtl::OString
874 lcl_Convert(::rtl::OUString
const& rString
)
880 (::rtl::OUStringToOString(rString
, RTL_TEXTENCODING_UTF8
));
885 SvFileStream
& m_rStream
;
886 explicit WriteDep(SvFileStream
& rStream
) : m_rStream(rStream
) { }
887 void operator() (::rtl::OUString
const& rItem
)
889 m_rStream
<< " \\\n ";
890 m_rStream
<< lcl_Convert(rItem
).getStr();
894 bool SvIdlDataBase::WriteDepFile(
895 SvFileStream
& rStream
, ::rtl::OUString
const& rTarget
)
897 rStream
<< lcl_Convert(rTarget
).getStr();
899 ::std::for_each(m_DepFiles
.begin(), m_DepFiles
.end(), WriteDep(rStream
));
900 return rStream
.GetError() == SVSTREAM_OK
;
903 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */