diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-09-27 23:11:59 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-09-28 09:20:32 +0100 |
commit | 5eb475f3085a107bc817b3490e8d7ef8eec0c4d8 (patch) | |
tree | d10ba542da82e6584a891dd2b3aafbe21d4d06ea | |
parent | 84841b118ad93d5ef0cbbf293067a020c3382ff5 (diff) |
ByteString->rtl::OStringBuffer
-rw-r--r-- | vcl/unx/generic/printer/ppdparser.cxx | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index 74a335847e59..8b99f1addca8 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -923,6 +923,20 @@ String PPDParser::handleTranslation(const rtl::OString& i_rString, bool bIsGloba return OStringToOUString( aTrans.makeStringAndClear(), bIsGlobalized ? RTL_TEXTENCODING_UTF8 : m_aFileEncoding ); } +namespace +{ + bool oddDoubleQuoteCount(rtl::OStringBuffer &rBuffer) + { + bool bHasOddCount = false; + for (sal_Int32 i = 0; i < rBuffer.getLength(); ++i) + { + if (rBuffer[i] == '"') + bHasOddCount = !bHasOddCount; + } + return bHasOddCount; + } +} + void PPDParser::parse( ::std::list< rtl::OString >& rLines ) { std::list< rtl::OString >::iterator line = rLines.begin(); @@ -1020,16 +1034,16 @@ void PPDParser::parse( ::std::list< rtl::OString >& rLines ) aLine = aCurrentLine.Copy( nPos+1 ); if( aLine.Len() ) { - while( ! ( aLine.GetTokenCount( '"' ) & 1 ) && - line != rLines.end() ) - // while there is an even number of tokens; that means - // an odd number of doubleqoutes + //while( ! ( aLine.GetTokenCount( '"' ) & 1 ) && + rtl::OStringBuffer aBuffer(aLine); + while (line != rLines.end() && oddDoubleQuoteCount(aBuffer)) { // copy the newlines also - aLine += '\n'; - aLine += ByteString(*line); + aBuffer.append('\n'); + aBuffer.append(*line); ++line; } + aLine = aBuffer.makeStringAndClear(); } aLine = WhitespaceToSpace( aLine ); |