summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-09-23 16:04:18 +0200
committerCaolán McNamara <caolanm@redhat.com>2022-09-23 21:34:59 +0200
commita0a529a131c61588cf865143d47cdc23961fd596 (patch)
tree8568de3b426636e0ab237cdd0c933a16ad9a493f
parent8cadfec386d0fb906dbe9b8ea8f918e61927e622 (diff)
xmloff: ODF import: fix crash on fdo34997-1.odt
Clean up the redundant checks too, these are all called after first checking hasCurrentFieldCtx(). (regression from 463178fef5c22f1a04d10e54491852d56e2038b0) Change-Id: Ieec848944ef576caf319d5da7dc11139a4d26c58 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140514 Tested-by: Jenkins Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--xmloff/source/text/XMLTextMarkImportContext.cxx2
-rw-r--r--xmloff/source/text/txtimp.cxx35
2 files changed, 7 insertions, 30 deletions
diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx
index 4e42899e709c..4a71194df23c 100644
--- a/xmloff/source/text/XMLTextMarkImportContext.cxx
+++ b/xmloff/source/text/XMLTextMarkImportContext.cxx
@@ -436,7 +436,7 @@ void XMLTextMarkImportContext::endFastElement(sal_Int32 nElement)
}
case TypeFieldmarkEnd:
{
- if (!m_rHelper.hasCurrentFieldSeparator())
+ if (m_rHelper.hasCurrentFieldCtx() && !m_rHelper.hasCurrentFieldSeparator())
{ // backward compat for old files without separator
InsertFieldmark(GetImport(), m_rHelper, true);
}
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index 288ccf45dc9b..87fd2b91283a 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -2127,49 +2127,26 @@ XMLTextImportHelper::popFieldCtx()
void XMLTextImportHelper::addFieldParam( const OUString& name, const OUString& value )
{
assert(!m_xImpl->m_FieldStack.empty());
- if (!m_xImpl->m_FieldStack.empty()) {
- Impl::field_stack_item_t & FieldStackItem(m_xImpl->m_FieldStack.top());
- std::get<1>(FieldStackItem).emplace_back( name, value );
- }
+ Impl::field_stack_item_t & FieldStackItem(m_xImpl->m_FieldStack.top());
+ std::get<1>(FieldStackItem).emplace_back( name, value );
}
::std::pair<OUString, OUString> XMLTextImportHelper::getCurrentFieldType() const
{
assert(!m_xImpl->m_FieldStack.empty());
- if (!m_xImpl->m_FieldStack.empty())
- {
- return std::get<0>(m_xImpl->m_FieldStack.top());
- }
- else
- {
- return {};
- }
+ return std::get<0>(m_xImpl->m_FieldStack.top());
}
uno::Reference<text::XTextRange> XMLTextImportHelper::getCurrentFieldStart() const
{
assert(!m_xImpl->m_FieldStack.empty());
- if (!m_xImpl->m_FieldStack.empty())
- {
- return std::get<3>(m_xImpl->m_FieldStack.top());
- }
- else
- {
- return {};
- }
+ return std::get<3>(m_xImpl->m_FieldStack.top());
}
bool XMLTextImportHelper::hasCurrentFieldSeparator() const
{
assert(!m_xImpl->m_FieldStack.empty());
- if (!m_xImpl->m_FieldStack.empty())
- {
- return std::get<2>(m_xImpl->m_FieldStack.top()).is();
- }
- else
- {
- return {};
- }
+ return std::get<2>(m_xImpl->m_FieldStack.top()).is();
}
bool XMLTextImportHelper::hasCurrentFieldCtx() const
@@ -2180,7 +2157,7 @@ bool XMLTextImportHelper::hasCurrentFieldCtx() const
void XMLTextImportHelper::setCurrentFieldParamsTo(css::uno::Reference< css::text::XFormField> const &xFormField)
{
assert(!m_xImpl->m_FieldStack.empty());
- if (!m_xImpl->m_FieldStack.empty() && xFormField.is())
+ if (xFormField.is())
{
FieldParamImporter(&std::get<1>(m_xImpl->m_FieldStack.top()),
xFormField->getParameters()).Import();