[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - writerfilter/qa writerfilter/source
Caolán McNamara
caolanm at redhat.com
Thu Aug 4 14:52:00 UTC 2016
writerfilter/qa/cppunittests/rtftok/data/fail/destinationtest-1.rtf |binary
writerfilter/qa/cppunittests/rtftok/data/fail/destinationtest-2.rtf |binary
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 49 +++++-----
writerfilter/source/rtftok/rtfdocumentimpl.hxx | 6 +
4 files changed, 31 insertions(+), 24 deletions(-)
New commits:
commit 51ea0875a7d3c6cd794cdec885b610efe635544c
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jul 29 08:48:22 2016 +0100
fftester: null DestinationText
(cherry picked from commit 0dd22165346f4296718656d17ae98ebbfe563719)
Change-Id: Icdd71733c4e9f4b36e6e957e4dea772087890faa
Reviewed-on: https://gerrit.libreoffice.org/27670
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/writerfilter/qa/cppunittests/rtftok/data/fail/destinationtest-1.rtf b/writerfilter/qa/cppunittests/rtftok/data/fail/destinationtest-1.rtf
new file mode 100644
index 0000000..63465b0
Binary files /dev/null and b/writerfilter/qa/cppunittests/rtftok/data/fail/destinationtest-1.rtf differ
diff --git a/writerfilter/qa/cppunittests/rtftok/data/fail/destinationtest-2.rtf b/writerfilter/qa/cppunittests/rtftok/data/fail/destinationtest-2.rtf
new file mode 100644
index 0000000..f0152b0
Binary files /dev/null and b/writerfilter/qa/cppunittests/rtftok/data/fail/destinationtest-2.rtf differ
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index d51dd1d..8b2efd6 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -186,26 +186,27 @@ static util::DateTime lcl_getDateTime(RTFParserState& aState)
aState.nDay, aState.nMonth, aState.nYear, false);
}
-static void lcl_DestinationToMath(OUStringBuffer& rDestinationText, oox::formulaimport::XmlStreamBuilder& rMathBuffer, bool& rMathNor)
+static void lcl_DestinationToMath(OUStringBuffer* pDestinationText, oox::formulaimport::XmlStreamBuilder& rMathBuffer, bool& rMathNor)
{
- OUString aStr = rDestinationText.makeStringAndClear();
- if (!aStr.isEmpty())
- {
- rMathBuffer.appendOpeningTag(M_TOKEN(r));
- if (rMathNor)
- {
- rMathBuffer.appendOpeningTag(M_TOKEN(rPr));
- // Same as M_TOKEN(lit)
- rMathBuffer.appendOpeningTag(M_TOKEN(nor));
- rMathBuffer.appendClosingTag(M_TOKEN(nor));
- rMathBuffer.appendClosingTag(M_TOKEN(rPr));
- rMathNor = false;
- }
- rMathBuffer.appendOpeningTag(M_TOKEN(t));
- rMathBuffer.appendCharacters(aStr);
- rMathBuffer.appendClosingTag(M_TOKEN(t));
- rMathBuffer.appendClosingTag(M_TOKEN(r));
- }
+ if (!pDestinationText)
+ return;
+ OUString aStr = pDestinationText->makeStringAndClear();
+ if (aStr.isEmpty())
+ return;
+ rMathBuffer.appendOpeningTag(M_TOKEN(r));
+ if (rMathNor)
+ {
+ rMathBuffer.appendOpeningTag(M_TOKEN(rPr));
+ // Same as M_TOKEN(lit)
+ rMathBuffer.appendOpeningTag(M_TOKEN(nor));
+ rMathBuffer.appendClosingTag(M_TOKEN(nor));
+ rMathBuffer.appendClosingTag(M_TOKEN(rPr));
+ rMathNor = false;
+ }
+ rMathBuffer.appendOpeningTag(M_TOKEN(t));
+ rMathBuffer.appendCharacters(aStr);
+ rMathBuffer.appendClosingTag(M_TOKEN(t));
+ rMathBuffer.appendClosingTag(M_TOKEN(r));
}
RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& xContext,
@@ -1210,7 +1211,7 @@ void RTFDocumentImpl::text(OUString& rString)
rString = rString.copy(0, rString.getLength() - 1);
bEnd = true;
}
- m_aStates.top().pDestinationText->append(rString);
+ m_aStates.top().appendDestinationText(rString);
if (bEnd)
{
// always clear, necessary in case of group-less fonttable
@@ -1314,7 +1315,7 @@ void RTFDocumentImpl::text(OUString& rString)
case Destination::MGROW:
case Destination::INDEXENTRY:
case Destination::TOCENTRY:
- m_aStates.top().pDestinationText->append(rString);
+ m_aStates.top().appendDestinationText(rString);
break;
default:
bRet = false;
@@ -1343,7 +1344,7 @@ void RTFDocumentImpl::text(OUString& rString)
// Don't return earlier, a bookmark start has to be in a paragraph group.
if (m_aStates.top().eDestination == Destination::BOOKMARKSTART)
{
- m_aStates.top().pDestinationText->append(rString);
+ m_aStates.top().appendDestinationText(rString);
return;
}
@@ -5111,7 +5112,7 @@ RTFError RTFDocumentImpl::pushState()
m_aStates.top().eRunType = RTFParserState::LOCH;
if (m_aStates.top().eDestination == Destination::MR)
- lcl_DestinationToMath(*m_aStates.top().pDestinationText, m_aMathBuffer, m_bMathNor);
+ lcl_DestinationToMath(m_aStates.top().pDestinationText, m_aMathBuffer, m_bMathNor);
m_aStates.push(m_aStates.top());
}
m_aStates.top().aDestinationText.setLength(0); // was copied: always reset!
@@ -5798,7 +5799,7 @@ RTFError RTFDocumentImpl::popState()
}
break;
case Destination::MR:
- lcl_DestinationToMath(*m_aStates.top().pDestinationText, m_aMathBuffer, m_bMathNor);
+ lcl_DestinationToMath(m_aStates.top().pDestinationText, m_aMathBuffer, m_bMathNor);
break;
case Destination::MF:
m_aMathBuffer.appendClosingTag(M_TOKEN(f));
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index f651628..500b7bb 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -283,6 +283,12 @@ public:
/// point to the buffer of the current destination
OUStringBuffer* pDestinationText;
+ void appendDestinationText(const OUString &rString)
+ {
+ if (pDestinationText)
+ pDestinationText->append(rString);
+ }
+
/// Index of the current style.
int nCurrentStyleIndex;
/// Index of the current character style.
More information about the Libreoffice-commits
mailing list