writerfilter/source/rtftok/rtfdocumentimpl.cxx | 101 ++++++++++++------------- 1 file changed, 52 insertions(+), 49 deletions(-)
New commits: commit 0cbdbb4a41c2fda7cb196299f151f1396b3354c0 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Mon Jun 19 09:40:42 2017 +0200 fix lost read of m_bFormField field in commit 42922c40362f414ee06e65636f61798ef28cdcde "RTFDocumentImpl::popState: use switch here" found while running the unusedfields plugin Change-Id: I4be41dba976a13dc6d39155fb2a04d039dc0443a Reviewed-on: https://gerrit.libreoffice.org/38950 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 5fc97ab5053f..f9a4983dcf67 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -2194,60 +2194,63 @@ RTFError RTFDocumentImpl::popState() break; case Destination::DATAFIELD: { - if (&m_aStates.top().aDestinationText != m_aStates.top().pDestinationText) - break; // not for nested group - OString aStr = OUStringToOString(m_aStates.top().pDestinationText->makeStringAndClear(), aState.nCurrentEncoding); - // decode hex dump - OStringBuffer aBuf; - int b = 0, count = 2; - for (int i = 0; i < aStr.getLength(); ++i) - { - char ch = aStr[i]; - if (ch != 0x0d && ch != 0x0a) + if (m_bFormField) + { + if (&m_aStates.top().aDestinationText != m_aStates.top().pDestinationText) + break; // not for nested group + OString aStr = OUStringToOString(m_aStates.top().pDestinationText->makeStringAndClear(), aState.nCurrentEncoding); + // decode hex dump + OStringBuffer aBuf; + int b = 0, count = 2; + for (int i = 0; i < aStr.getLength(); ++i) { - b = b << 4; - sal_Int8 parsed = RTFTokenizer::asHex(ch); - if (parsed == -1) - return RTFError::HEX_INVALID; - b += parsed; - count--; - if (!count) + char ch = aStr[i]; + if (ch != 0x0d && ch != 0x0a) { - aBuf.append((char)b); - count = 2; - b = 0; + b = b << 4; + sal_Int8 parsed = RTFTokenizer::asHex(ch); + if (parsed == -1) + return RTFError::HEX_INVALID; + b += parsed; + count--; + if (!count) + { + aBuf.append((char)b); + count = 2; + b = 0; + } } } - } - aStr = aBuf.makeStringAndClear(); - - // ignore the first bytes - if (aStr.getLength() > 8) - aStr = aStr.copy(8); - // extract name - sal_Int32 nLength = aStr.toChar(); - if (!aStr.isEmpty()) - aStr = aStr.copy(1); - nLength = std::min(nLength, aStr.getLength()); - OString aName = aStr.copy(0, nLength); - if (aStr.getLength() > nLength) - aStr = aStr.copy(nLength+1); // zero-terminated string - else - aStr.clear(); - // extract default text - nLength = aStr.toChar(); - if (!aStr.isEmpty()) - aStr = aStr.copy(1); - auto pNValue = std::make_shared<RTFValue>(OStringToOUString(aName, aState.nCurrentEncoding)); - m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFData_name, pNValue); - if (nLength > 0) - { - OString aDefaultText = aStr.copy(0, std::min(nLength, aStr.getLength())); - auto pDValue = std::make_shared<RTFValue>(OStringToOUString(aDefaultText, aState.nCurrentEncoding)); - m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFTextInput_default, pDValue); - } + aStr = aBuf.makeStringAndClear(); + + // ignore the first bytes + if (aStr.getLength() > 8) + aStr = aStr.copy(8); + // extract name + sal_Int32 nLength = aStr.toChar(); + if (!aStr.isEmpty()) + aStr = aStr.copy(1); + nLength = std::min(nLength, aStr.getLength()); + OString aName = aStr.copy(0, nLength); + if (aStr.getLength() > nLength) + aStr = aStr.copy(nLength+1); // zero-terminated string + else + aStr.clear(); + // extract default text + nLength = aStr.toChar(); + if (!aStr.isEmpty()) + aStr = aStr.copy(1); + auto pNValue = std::make_shared<RTFValue>(OStringToOUString(aName, aState.nCurrentEncoding)); + m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFData_name, pNValue); + if (nLength > 0) + { + OString aDefaultText = aStr.copy(0, std::min(nLength, aStr.getLength())); + auto pDValue = std::make_shared<RTFValue>(OStringToOUString(aDefaultText, aState.nCurrentEncoding)); + m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFTextInput_default, pDValue); + } - m_bFormField = false; + m_bFormField = false; + } } break; case Destination::CREATIONTIME: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits