summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-07-29 08:48:22 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-03 09:49:02 +0000
commit3c5faa04ab204d39b91f43add0cffcc9ee90a94b (patch)
tree3bde3a81d7d91b8701e6c9b803f25af1120ecd6c /writerfilter
parent0b21f434b45c350cd9cc5b820226245d6824bf86 (diff)
fftester: null DestinationText
Change-Id: Icdd71733c4e9f4b36e6e957e4dea772087890faa (cherry picked from commit 0dd22165346f4296718656d17ae98ebbfe563719) Reviewed-on: https://gerrit.libreoffice.org/27666 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/qa/cppunittests/rtftok/data/fail/destinationtest-1.rtfbin0 -> 196 bytes
-rw-r--r--writerfilter/qa/cppunittests/rtftok/data/fail/destinationtest-2.rtfbin0 -> 155 bytes
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx45
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx6
4 files changed, 29 insertions, 22 deletions
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 000000000000..63465b073627
--- /dev/null
+++ b/writerfilter/qa/cppunittests/rtftok/data/fail/destinationtest-1.rtf
Binary files 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 000000000000..f0152b0fab36
--- /dev/null
+++ b/writerfilter/qa/cppunittests/rtftok/data/fail/destinationtest-2.rtf
Binary files differ
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 761cf2057d03..9dc5f7915414 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -189,26 +189,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())
+ if (!pDestinationText)
+ return;
+ OUString aStr = pDestinationText->makeStringAndClear();
+ if (aStr.isEmpty())
+ return;
+ rMathBuffer.appendOpeningTag(M_TOKEN(r));
+ if (rMathNor)
{
- 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));
+ 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,
@@ -1212,7 +1213,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
@@ -1318,7 +1319,7 @@ void RTFDocumentImpl::text(OUString& rString)
case Destination::TOCENTRY:
case Destination::PROPNAME:
case Destination::STATICVAL:
- m_aStates.top().pDestinationText->append(rString);
+ m_aStates.top().appendDestinationText(rString);
break;
default:
bRet = false;
@@ -1347,7 +1348,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;
}
@@ -1765,7 +1766,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!
@@ -2460,7 +2461,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 d31b36947a7e..8f20e6b46955 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -281,6 +281,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.