From e45ca13634ba51a6133a231f74db76be06bb4d95 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 22 Jan 2018 22:12:04 +0100 Subject: tdf#114460 vcl: handle nested parentheses in PDF roundtrip The roundtrip of the pdf image failed due to this. (cherry picked from commit f58a16d5987c8e8c16580c514ce0c7b0895b4105) Change-Id: I88a9657e242dd2659f9bf06233e5fcbfeb43ceb5 Reviewed-on: https://gerrit.libreoffice.org/48378 Tested-by: Jenkins Reviewed-by: Michael Stahl --- vcl/source/filter/ipdf/pdfdocument.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'vcl/source/filter') diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index 56e90cf7adf3..11c4519e44cf 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -2021,11 +2021,20 @@ bool PDFLiteralStringElement::Read(SvStream& rStream) nPrevCh = ch; rStream.ReadChar(ch); + // Start with 1 nesting level as we read a '(' above already. + int nDepth = 1; OStringBuffer aBuf; while (!rStream.eof()) { + if (ch == '(' && nPrevCh != '\\') + ++nDepth; + if (ch == ')' && nPrevCh != '\\') + --nDepth; + + if (nDepth == 0) { + // ')' of the outermost '(' is reached. m_aValue = aBuf.makeStringAndClear(); SAL_INFO("vcl.filter", "PDFLiteralStringElement::Read: m_aValue is '" << m_aValue << "'"); return true; -- cgit v1.2.3