diff options
author | Nils Fuhrmann <nf@openoffice.org> | 2001-05-07 13:31:30 +0000 |
---|---|---|
committer | Nils Fuhrmann <nf@openoffice.org> | 2001-05-07 13:31:30 +0000 |
commit | b05572f20d0bd7a75eb996e99235a2e374fbae60 (patch) | |
tree | fcc463357912f62a87cf45c001418038df945d55 /tools/source/communi | |
parent | 31e7bf137c3d7c1e931b0192be54e7dbaf135402 (diff) |
New: Comments in GenericInformationList
Diffstat (limited to 'tools/source/communi')
-rw-r--r-- | tools/source/communi/parser.cxx | 69 |
1 files changed, 46 insertions, 23 deletions
diff --git a/tools/source/communi/parser.cxx b/tools/source/communi/parser.cxx index 193f8d574af5..12728443b6d0 100644 --- a/tools/source/communi/parser.cxx +++ b/tools/source/communi/parser.cxx @@ -2,9 +2,9 @@ * * $RCSfile: parser.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: nf $ $Date: 2001-04-23 13:58:39 $ + * last change: $Author: nf $ $Date: 2001-05-07 14:31:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -102,27 +102,38 @@ ByteString &InformationParser::ReadLine() /*****************************************************************************/ { ByteString sLine; + if ( bRecover ) { bRecover = FALSE; } else { - pActStream->ReadLine( sLine ); - - ULONG nLen; - do { - nLen = sLine.Len(); - sLine.EraseLeadingChars( 0x09 ); - sLine.EraseLeadingChars( ' ' ); - } while ( sLine.Len() < nLen ); - do { - nLen = sLine.Len(); - sLine.EraseTrailingChars( 0x09 ); - sLine.EraseTrailingChars( ' ' ); - } while ( sLine.Len() < nLen ); - - if ( bReplaceVariables ) { - while( sLine.SearchAndReplace( "%UPD", sUPD ) != (USHORT)-1 ); - while( sLine.SearchAndReplace( "%VERSION", sVersion ) != (USHORT)-1 ); + if ( !pActStream->IsEof()) { + pActStream->ReadLine( sLine ); + ULONG nLen; + do { + nLen = sLine.Len(); + sLine.EraseLeadingChars( 0x09 ); + sLine.EraseLeadingChars( ' ' ); + } while ( nLen != sLine.Len()); + + do { + nLen = sLine.Len(); + sLine.EraseTrailingChars( 0x09 ); + sLine.EraseTrailingChars( ' ' ); + } while ( nLen != sLine.Len()); + + if (( sLine.Search( "#" ) == 0 ) || ( !sLine.Len())) { + if ( sCurrentComment.Len()) + sCurrentComment += "\n"; + sCurrentComment += sLine; + return ReadLine(); + } + else { + if ( bReplaceVariables ) { + while( sLine.SearchAndReplace( "%UPD", sUPD ) != (USHORT)-1 ); + while( sLine.SearchAndReplace( "%VERSION", sVersion ) != (USHORT)-1 ); + } + } } sOldLine = sLine; @@ -163,8 +174,10 @@ GenericInformation *InformationParser::ReadKey( GenericInformation *pInfo = NULL; ByteString sLine( ReadLine()); - ByteString sKey( "" ); - ByteString sValue( "" ); + ByteString sKey; + ByteString sValue; + ByteString sComment( sCurrentComment ); + sCurrentComment = ""; // key separated from value by tab? USHORT nWSPos = sLine.Search( ' ' ); @@ -198,10 +211,12 @@ GenericInformation *InformationParser::ReadKey( nLevel--; pInfo = new GenericInformation( sKey, sValue, pExistingList, pSubList ); + pInfo->SetComment( sComment ); } else { Recover(); pInfo = new GenericInformation( sKey, sValue, pExistingList ); + pInfo->SetComment( sComment ); } return pInfo; @@ -230,8 +245,16 @@ BOOL InformationParser::Save( SvStream &rOutStream, // Key-Value Paare schreiben pGenericInfo = pSaveList->GetObject( nInfoListCount ); sTmpStr = ""; - for( i=0; i<nLevel; i++) - sTmpStr += cKeyLevelChars; + for( ULONG j=0; j<nLevel; j++) + sTmpStr += cKeyLevelChars; + + for ( i = 0; i < pGenericInfo->GetComment().GetTokenCount( '\n' ); i++ ) { + sTmpStr += pGenericInfo->GetComment().GetToken( i, '\n' ); + sTmpStr += "\n"; + for( ULONG j=0; j<nLevel; j++) + sTmpStr += cKeyLevelChars; + } + sTmpStr += pGenericInfo->GetBuffer(); sTmpStr += ' '; sTmpStr += pGenericInfo->GetValue(); |