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>
25 #include <database.hxx>
26 #include <globals.hxx>
27 #include <rtl/strbuf.hxx>
28 #include <osl/file.hxx>
30 SvIdlDataBase::SvIdlDataBase( const SvCommand
& rCmd
)
31 : bExport( sal_False
)
33 , nVerbosity( rCmd
.nVerbosity
)
34 , aPersStream( *IDLAPP
->pClassMgr
, NULL
)
39 SvIdlDataBase::~SvIdlDataBase()
41 for ( size_t i
= 0, n
= aIdFileList
.size(); i
< n
; ++i
)
42 delete aIdFileList
[ i
];
48 #define ADD_TYPE( Name, OdlName, ParserChar, CName, BasName, BasPost ) \
49 aTypeList.push_back( new SvMetaType( SvHash_##Name()->GetName(), \
50 BasName, OdlName, ParserChar, CName, BasName, BasPost ) );
52 SvMetaTypeMemberList
& SvIdlDataBase::GetTypeList()
54 if( aTypeList
.empty() )
56 aTypeList
.push_back( new SvMetaTypeString() );
57 aTypeList
.push_back( new SvMetaTypevoid() );
59 // MI: IDispatch::Invoke can not unsigned
60 ADD_TYPE( UINT16
, "long", 'h', "unsigned short", "Long", "&" );
61 ADD_TYPE( INT16
, "short", 'h', "short", "Integer", "%" );
62 ADD_TYPE( UINT32
, "long", 'l', "unsigned long", "Long", "&" );
63 ADD_TYPE( INT32
, "long", 'l', "long", "Long", "&" );
64 ADD_TYPE( int, "int", 'i', "int", "Integer", "%" );
65 ADD_TYPE( BOOL
, "boolean", 'b', "unsigned char", "Boolean", "" );
66 ADD_TYPE( char, "char", 'c', "char", "Integer", "%" );
67 ADD_TYPE( BYTE
, "char", 'c', "unsigned char", "Integer", "%" );
68 ADD_TYPE( float, "float", 'f', "float", "Single", "!" );
69 ADD_TYPE( double, "double", 'F', "double", "Double", "#" );
70 ADD_TYPE( SbxObject
, "VARIANT", 'o', "C_Object", "Object", "" );
72 // Attention! When adding types all binary data bases get incompatible
78 SvMetaModule
* SvIdlDataBase::GetModule( const OString
& rName
)
80 for( sal_uLong n
= 0; n
< aModuleList
.size(); n
++ )
81 if( aModuleList
[n
]->GetName().getString().equals(rName
) )
82 return aModuleList
[n
];
86 #define DATABASE_SIGNATURE (sal_uInt32)0x13B799F2
87 #define DATABASE_VER 0x0006
88 sal_Bool
SvIdlDataBase::IsBinaryFormat( SvStream
& rStm
)
91 sal_uLong nPos
= rStm
.Tell();
95 return nSig
== DATABASE_SIGNATURE
;
98 void SvIdlDataBase::Load( SvStream
& rStm
)
100 DBG_ASSERT( aTypeList
.empty(), "type list already initialized" );
101 SvPersistStream
aPStm( *IDLAPP
->pClassMgr
, &rStm
);
103 sal_uInt16 nVersion
= 0;
108 if( nSig
!= DATABASE_SIGNATURE
)
110 aPStm
.SetError( SVSTREAM_FILEFORMAT_ERROR
);
113 if( nVersion
!= DATABASE_VER
)
115 aPStm
.SetError( SVSTREAM_WRONGVERSION
);
121 aPStm
>> aModuleList
;
125 aPStm
.SetError( SVSTREAM_GENERALERROR
);
128 void SvIdlDataBase::Save( SvStream
& rStm
, sal_uInt32 nFlags
)
130 SvPersistStream
aPStm( *IDLAPP
->pClassMgr
, &rStm
);
131 aPStm
.SetContextFlags( nFlags
);
133 aPStm
<< (sal_uInt32
)DATABASE_SIGNATURE
;
134 aPStm
<< (sal_uInt16
)DATABASE_VER
;
136 sal_Bool bOnlyStreamedObjs
= sal_False
;
137 if( nFlags
& IDL_WRITE_CALLING
)
138 bOnlyStreamedObjs
= sal_True
;
140 if( bOnlyStreamedObjs
)
142 SvMetaClassMemberList aList
;
143 for( sal_uLong n
= 0; n
< GetModuleList().size(); n
++ )
145 SvMetaModule
* pModule
= GetModuleList()[n
];
146 if( !pModule
->IsImported() )
147 aList
.insert( pModule
->GetClassList() );
154 aTypeList
.WriteObjects( aPStm
, bOnlyStreamedObjs
);
155 aAttrList
.WriteObjects( aPStm
, bOnlyStreamedObjs
);
156 aModuleList
.WriteObjects( aPStm
, bOnlyStreamedObjs
);
160 void SvIdlDataBase::SetError( const OString
& rError
, SvToken
* pTok
)
162 if( pTok
->GetLine() > 10000 )
163 aError
.SetText( "line count overflow" );
165 if( aError
.nLine
< pTok
->GetLine()
166 || (aError
.nLine
== pTok
->GetLine() && aError
.nColumn
< pTok
->GetColumn()) )
168 aError
= SvIdlError( pTok
->GetLine(), pTok
->GetColumn() );
169 aError
.SetText( rError
);
173 void SvIdlDataBase::Push( SvMetaObject
* pObj
)
175 GetStack().Push( pObj
);
178 sal_Bool
SvIdlDataBase::FindId( const OString
& rIdName
, sal_uLong
* pVal
)
183 if( pIdTable
->Test( rIdName
, &nHash
) )
185 *pVal
= pIdTable
->Get( nHash
)->GetValue();
192 sal_Bool
SvIdlDataBase::InsertId( const OString
& rIdName
, sal_uLong nVal
)
195 pIdTable
= new SvStringHashTable( 20003 );
198 if( pIdTable
->Insert( rIdName
, &nHash
) )
200 pIdTable
->Get( nHash
)->SetValue( nVal
);
206 sal_Bool
SvIdlDataBase::ReadIdFile( const String
& rFileName
)
209 osl::File::searchFileURL( rFileName
, GetPath(), aFullName
);
210 osl::FileBase::getSystemPathFromFileURL( aFullName
, aFullName
);
212 for ( size_t i
= 0, n
= aIdFileList
.size(); i
< n
; ++i
)
213 if ( *aIdFileList
[ i
] == rFileName
)
216 aIdFileList
.push_back( new String( rFileName
) );
217 this->AddDepFile( aFullName
);
218 SvTokenStream
aTokStm( aFullName
);
219 if( aTokStm
.GetStream().GetError() == SVSTREAM_OK
)
221 SvToken
* pTok
= aTokStm
.GetToken_Next();
223 while( !pTok
->IsEof() )
225 if( pTok
->IsChar() && pTok
->GetChar() == '#' )
227 pTok
= aTokStm
.GetToken_Next();
228 if( pTok
->Is( SvHash_define() ) )
230 pTok
= aTokStm
.GetToken_Next();
232 if( pTok
->IsIdentifier() )
233 aDefName
= pTok
->GetString();
236 OString
aStr(RTL_CONSTASCII_STRINGPARAM(
237 "unexpected token after define"));
239 SetError( aStr
, pTok
);
240 WriteError( aTokStm
);
245 sal_Bool bOk
= sal_True
;
248 pTok
= aTokStm
.GetToken_Next();
249 if( pTok
->IsIdentifier() )
252 if( FindId( pTok
->GetString(), &n
) )
257 else if( pTok
->IsChar() )
259 if( pTok
->GetChar() == '-'
260 || pTok
->GetChar() == '/'
261 || pTok
->GetChar() == '*'
262 || pTok
->GetChar() == '&'
263 || pTok
->GetChar() == '|'
264 || pTok
->GetChar() == '^'
265 || pTok
->GetChar() == '~' )
267 OStringBuffer
aStr("unknown operator '");
268 aStr
.append(pTok
->GetChar());
269 aStr
.append("'in define");
271 SetError( aStr
.makeStringAndClear(), pTok
);
272 WriteError( aTokStm
);
275 if( pTok
->GetChar() != '+'
276 && pTok
->GetChar() != '('
277 && pTok
->GetChar() != ')' )
278 // only + is allowed, parentheses are immaterial
279 // because + is commutative
282 else if( pTok
->IsInteger() )
284 nVal
+= pTok
->GetNumber();
291 if( !InsertId( aDefName
, nVal
) )
293 OString
aStr(RTL_CONSTASCII_STRINGPARAM("hash table overflow: "));
294 SetError( aStr
, pTok
);
295 WriteError( aTokStm
);
300 else if( pTok
->Is( SvHash_include() ) )
302 pTok
= aTokStm
.GetToken_Next();
304 if( pTok
->IsString() )
305 aName
.append(pTok
->GetString());
306 else if( pTok
->IsChar() && pTok
->GetChar() == '<' )
308 pTok
= aTokStm
.GetToken_Next();
309 while( !pTok
->IsEof()
310 && !(pTok
->IsChar() && pTok
->GetChar() == '>') )
312 aName
.append(pTok
->GetTokenAsString());
313 pTok
= aTokStm
.GetToken_Next();
317 OString
aStr(RTL_CONSTASCII_STRINGPARAM(
318 "unexpected eof in #include"));
320 SetError(aStr
, pTok
);
321 WriteError( aTokStm
);
325 if (!ReadIdFile(OStringToOUString(aName
.toString(),
326 RTL_TEXTENCODING_ASCII_US
)))
328 OStringBuffer
aStr(RTL_CONSTASCII_STRINGPARAM(
329 "cannot read file: "));
330 aStr
.append(aName
.makeStringAndClear());
331 SetError(aStr
.makeStringAndClear(), pTok
);
332 WriteError( aTokStm
);
338 pTok
= aTokStm
.GetToken_Next();
346 SvMetaType
* SvIdlDataBase::FindType( const SvMetaType
* pPType
,
347 SvMetaTypeMemberList
& rList
)
349 for( SvMetaTypeMemberList::const_iterator it
= rList
.begin(); it
!= rList
.end(); ++it
)
355 SvMetaType
* SvIdlDataBase::FindType( const OString
& rName
)
357 for( SvMetaTypeMemberList::const_iterator it
= aTypeList
.begin(); it
!= aTypeList
.end(); ++it
)
358 if( rName
.equals((*it
)->GetName().getString()) )
363 SvMetaType
* SvIdlDataBase::ReadKnownType( SvTokenStream
& rInStm
)
365 sal_Bool bIn
= sal_False
;
366 sal_Bool bOut
= sal_False
;
367 int nCall0
= CALL_VALUE
;
368 int nCall1
= CALL_VALUE
;
369 sal_Bool bSet
= sal_False
; // any attribute set
371 sal_uInt32 nTokPos
= rInStm
.Tell();
372 SvToken
* pTok
= rInStm
.GetToken_Next();
374 if( pTok
->HasHash() )
376 sal_uInt32 nBeginPos
= 0; // can not happen with Tell
377 while( nBeginPos
!= rInStm
.Tell() )
379 nBeginPos
= rInStm
.Tell();
380 if( pTok
->Is( SvHash_in() ) )
383 pTok
= rInStm
.GetToken_Next();
386 if( pTok
->Is( SvHash_out() ) )
389 pTok
= rInStm
.GetToken_Next();
392 if( pTok
->Is( SvHash_inout() ) )
396 pTok
= rInStm
.GetToken_Next();
402 if( pTok
->IsIdentifier() )
404 OString aName
= pTok
->GetString();
405 SvMetaTypeMemberList
& rList
= GetTypeList();
406 SvMetaTypeMemberList::const_iterator it
= rList
.begin();
407 SvMetaType
* pType
= NULL
;
408 while( it
!= rList
.end() )
410 if( (*it
)->GetName().getString().equals(aName
) )
419 pTok
= rInStm
.GetToken();
422 if( pTok
->GetChar() == '&' || pTok
->GetChar() == '*' )
424 nCall0
= (pTok
->GetChar() == '&') ? CALL_REFERENCE
:
426 rInStm
.GetToken_Next();
427 pTok
= rInStm
.GetToken();
428 if( pTok
->GetChar() == '&' || pTok
->GetChar() == '*' )
430 nCall1
= (pTok
->GetChar() == '&') ? CALL_REFERENCE
:
432 rInStm
.GetToken_Next();
439 // is exactly this type
442 DBG_ASSERT( aTmpTypeList
.front(), "mindestens ein Element" );
443 SvMetaTypeRef xType
= new SvMetaType( pType
->GetName().getString(), 'h', "dummy" );
444 xType
->SetRef( pType
);
446 xType
->SetOut( bOut
);
447 xType
->SetCall0( nCall0
);
448 xType
->SetCall1( nCall1
);
450 aTmpTypeList
.push_back( xType
);
454 rInStm
.Seek( nTokPos
);
458 SvMetaAttribute
* SvIdlDataBase::ReadKnownAttr
460 SvTokenStream
& rInStm
,
461 SvMetaType
* pType
/* If pType == NULL, then the type has
465 sal_uInt32 nTokPos
= rInStm
.Tell();
468 pType
= ReadKnownType( rInStm
);
473 SvToken
* pTok
= rInStm
.GetToken_Next();
474 if( pTok
->IsIdentifier() )
477 if( FindId( pTok
->GetString(), &n
) )
479 for( sal_uLong i
= 0; i
< aAttrList
.size(); i
++ )
481 SvMetaAttribute
* pAttr
= aAttrList
[i
];
482 if( pAttr
->GetSlotId().getString().equals(pTok
->GetString()) )
487 OStringBuffer
aStr("Nicht gefunden : ");
488 aStr
.append(pTok
->GetString());
489 OSL_FAIL(aStr
.getStr());
493 rInStm
.Seek( nTokPos
);
497 SvMetaAttribute
* SvIdlDataBase::SearchKnownAttr
499 const SvNumberIdentifier
& rId
503 if( FindId( rId
.getString(), &n
) )
505 for( sal_uLong i
= 0; i
< aAttrList
.size(); i
++ )
507 SvMetaAttribute
* pAttr
= aAttrList
[i
];
508 if( pAttr
->GetSlotId().getString() == rId
.getString() )
516 SvMetaClass
* SvIdlDataBase::ReadKnownClass( SvTokenStream
& rInStm
)
518 sal_uInt32 nTokPos
= rInStm
.Tell();
519 SvToken
* pTok
= rInStm
.GetToken_Next();
521 if( pTok
->IsIdentifier() )
522 for( sal_uLong n
= 0; n
< aClassList
.size(); n
++ )
524 SvMetaClass
* pClass
= aClassList
[n
];
525 if( pClass
->GetName().getString().equals(pTok
->GetString()) )
529 rInStm
.Seek( nTokPos
);
533 void SvIdlDataBase::Write(const OString
& rText
)
535 if( nVerbosity
!= 0 )
536 fprintf( stdout
, "%s", rText
.getStr() );
539 void SvIdlDataBase::WriteError( const OString
& rErrWrn
,
540 const OString
& rFileName
,
541 const OString
& rErrorText
,
542 sal_uLong nRow
, sal_uLong nColumn
) const
545 fprintf( stderr
, "\n%s --- %s: ( %ld, %ld )\n",
546 rFileName
.getStr(), rErrWrn
.getStr(), nRow
, nColumn
);
548 if( !rErrorText
.isEmpty() )
550 fprintf( stderr
, "\t%s\n", rErrorText
.getStr() );
554 void SvIdlDataBase::WriteError( SvTokenStream
& rInStm
)
557 String
aFileName( rInStm
.GetFileName() );
558 OStringBuffer aErrorText
;
559 sal_uLong nRow
= 0, nColumn
= 0;
562 SvToken
*pTok
= rInStm
.GetToken();
565 nRow
= pTok
->GetLine();
566 nColumn
= pTok
->GetColumn();
568 if( aError
.IsError() )
570 // search error token
572 if( !aError
.GetText().isEmpty() )
574 aErrorText
.append(RTL_CONSTASCII_STRINGPARAM("may be <"));
575 aErrorText
.append(aError
.GetText());
577 SvToken
* pPrevTok
= NULL
;
578 while( pTok
!= pPrevTok
)
581 if( pTok
->GetLine() == aError
.nLine
582 && pTok
->GetColumn() == aError
.nColumn
)
584 pTok
= rInStm
.GetToken_PrevAll();
588 aErrorText
.append(RTL_CONSTASCII_STRINGPARAM("> at ( "));
589 aErrorText
.append(static_cast<sal_Int64
>(aError
.nLine
));
590 aErrorText
.append(RTL_CONSTASCII_STRINGPARAM(", "));
591 aErrorText
.append(static_cast<sal_Int64
>(aError
.nColumn
));
592 aErrorText
.append(RTL_CONSTASCII_STRINGPARAM(" )"));
595 aError
= SvIdlError();
598 WriteError("error", OUStringToOString(aFileName
,
599 RTL_TEXTENCODING_UTF8
), aErrorText
.makeStringAndClear(), nRow
, nColumn
);
601 DBG_ASSERT( pTok
, "token must be found" );
605 // look for identifier close by
606 if( !pTok
->IsIdentifier() )
608 rInStm
.GetToken_PrevAll();
609 pTok
= rInStm
.GetToken();
611 if( pTok
&& pTok
->IsIdentifier() )
613 OString aN
= IDLAPP
->pHashTable
->GetNearString( pTok
->GetString() );
615 fprintf( stderr
, "%s versus %s\n", pTok
->GetString().getStr(), aN
.getStr() );
619 SvIdlWorkingBase::SvIdlWorkingBase(const SvCommand
& rCmd
) : SvIdlDataBase(rCmd
)
623 sal_Bool
SvIdlWorkingBase::ReadSvIdl( SvTokenStream
& rInStm
, sal_Bool bImported
, const String
& rPath
)
625 aPath
= rPath
; // only valid for this iteration
627 sal_Bool bOk
= sal_True
;
628 pTok
= rInStm
.GetToken();
629 // only one import at the very beginning
630 if( pTok
->Is( SvHash_import() ) )
632 rInStm
.GetToken_Next();
633 rInStm
.Read( '(' ); // optional
634 pTok
= rInStm
.GetToken_Next();
635 if( pTok
->IsString() )
638 if( osl::FileBase::E_None
== osl::File::searchFileURL(
639 OStringToOUString(pTok
->GetString(), RTL_TEXTENCODING_ASCII_US
),
643 osl::FileBase::getSystemPathFromFileURL( aFullName
, aFullName
);
644 this->AddDepFile(aFullName
);
645 SvFileStream
aStm( aFullName
, STREAM_STD_READ
| STREAM_NOCREATE
);
647 if( aStm
.GetError() != SVSTREAM_OK
)
649 if( aStm
.GetError() == SVSTREAM_WRONGVERSION
)
651 OStringBuffer
aStr("wrong version, file ");
652 aStr
.append(OUStringToOString( aFullName
, RTL_TEXTENCODING_UTF8
));
653 SetError(aStr
.makeStringAndClear(), pTok
);
654 WriteError( rInStm
);
661 SvTokenStream
aTokStm( aStm
, aFullName
);
662 bOk
= ReadSvIdl( aTokStm
, sal_True
, rPath
);
673 sal_uInt32 nBeginPos
= 0xFFFFFFFF; // can not happen with Tell
675 while( bOk
&& nBeginPos
!= rInStm
.Tell() )
677 nBeginPos
= rInStm
.Tell();
678 pTok
= rInStm
.GetToken();
681 if( pTok
->IsEmpty() )
684 // only one import at the very beginning
685 if( pTok
->Is( SvHash_module() ) )
687 SvMetaModuleRef aModule
= new SvMetaModule( rInStm
.GetFileName(), bImported
);
688 if( aModule
->ReadSvIdl( *this, rInStm
) )
689 GetModuleList().push_back( aModule
);
696 if( !bOk
|| !pTok
->IsEof() )
699 WriteError( rInStm
);
705 sal_Bool
SvIdlWorkingBase::WriteSvIdl( SvStream
& rOutStm
)
707 if( rOutStm
.GetError() != SVSTREAM_OK
)
710 SvStringHashList aList
;
713 GetIdTable()->FillHashList( &aList
);
714 for ( size_t i
= 0, n
= aList
.size(); i
< n
; ++i
)
716 SvStringHashEntry
* pEntry
= aList
[ i
];
717 rOutStm
<< "#define " << pEntry
->GetName().getStr()
719 << OString::valueOf(static_cast<sal_Int64
>(
720 pEntry
->GetValue())).getStr()
725 for( sal_uLong n
= 0; n
< GetModuleList().size(); n
++ )
727 SvMetaModule
* pModule
= GetModuleList()[n
];
728 pModule
->WriteSvIdl( *this, rOutStm
, 0 );
733 sal_Bool
SvIdlWorkingBase::WriteSfx( SvStream
& rOutStm
)
735 if( rOutStm
.GetError() != SVSTREAM_OK
)
738 // reset all tmp variables for writing
740 SvMemoryStream
aTmpStm( 256000, 256000 );
742 for( n
= 0; n
< GetModuleList().size(); n
++ )
744 SvMetaModule
* pModule
= GetModuleList()[n
];
745 if( !pModule
->IsImported() )
746 pModule
->WriteSfx( *this, aTmpStm
);
749 for( n
= 0; n
< aUsedTypes
.size(); n
++ )
751 SvMetaType
* pType
= aUsedTypes
[n
];
752 pType
->WriteSfx( *this, rOutStm
);
759 sal_Bool
SvIdlWorkingBase::WriteHelpIds( SvStream
& rOutStm
)
761 if( rOutStm
.GetError() != SVSTREAM_OK
)
764 HelpIdTable aIdTable
;
766 for( n
= 0; n
< GetModuleList().size(); n
++ )
768 SvMetaModule
* pModule
= GetModuleList()[n
];
769 pModule
->WriteHelpIds( *this, rOutStm
, aIdTable
);
772 const SvMetaAttributeMemberList
& rAttrList
= GetAttrList();
773 for( n
= 0; n
< rAttrList
.size(); n
++ )
775 SvMetaAttribute
* pAttr
= rAttrList
[n
];
776 pAttr
->WriteHelpId( *this, rOutStm
, aIdTable
);
782 sal_Bool
SvIdlWorkingBase::WriteSfxItem( SvStream
& )
787 void SvIdlDataBase::StartNewFile( const String
& rName
)
789 bExport
= ( aExportFile
.EqualsIgnoreCaseAscii( rName
) );
792 void SvIdlDataBase::AppendAttr( SvMetaAttribute
*pAttr
)
794 aAttrList
.push_back( pAttr
);
796 pAttr
->SetNewAttribute( sal_True
);
799 sal_Bool
SvIdlWorkingBase::WriteCSV( SvStream
& rStrm
)
801 SvMetaAttributeMemberList
&rList
= GetAttrList();
802 sal_uLong nCount
= rList
.size();
803 for ( sal_uLong n
=0; n
<nCount
; n
++ )
805 if ( rList
[n
]->IsNewAttribute() )
807 rList
[n
]->WriteCSV( *this, rStrm
);
811 if ( rStrm
.GetError() != SVSTREAM_OK
)
817 sal_Bool
SvIdlWorkingBase::WriteDocumentation( SvStream
& rOutStm
)
819 if( rOutStm
.GetError() != SVSTREAM_OK
)
822 for( sal_uLong n
= 0; n
< GetModuleList().size(); n
++ )
824 SvMetaModule
* pModule
= GetModuleList()[n
];
825 if( !pModule
->IsImported() )
826 pModule
->Write( *this, rOutStm
, 0, WRITE_DOCU
);
831 void SvIdlDataBase::AddDepFile(String
const& rFileName
)
833 m_DepFiles
.insert(rFileName
);
838 SvFileStream
& m_rStream
;
839 explicit WriteDep(SvFileStream
& rStream
) : m_rStream(rStream
) { }
840 void operator() (OUString
const& rItem
)
842 m_rStream
<< " \\\n ";
843 m_rStream
<< OUStringToOString(rItem
, RTL_TEXTENCODING_UTF8
).getStr();
847 // write a dummy target for one included file, so the incremental build does
848 // not break with "No rule to make target" if the included file is removed
851 SvFileStream
& m_rStream
;
852 explicit WriteDummy(SvFileStream
& rStream
) : m_rStream(rStream
) { }
853 void operator() (OUString
const& rItem
)
855 m_rStream
<< OUStringToOString(rItem
, RTL_TEXTENCODING_UTF8
).getStr();
856 m_rStream
<< " :\n\n";
860 bool SvIdlDataBase::WriteDepFile(
861 SvFileStream
& rStream
, OUString
const& rTarget
)
863 rStream
<< OUStringToOString(rTarget
, RTL_TEXTENCODING_UTF8
).getStr();
865 ::std::for_each(m_DepFiles
.begin(), m_DepFiles
.end(), WriteDep(rStream
));
867 ::std::for_each(m_DepFiles
.begin(), m_DepFiles
.end(), WriteDummy(rStream
));
868 return rStream
.GetError() == SVSTREAM_OK
;
871 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */