diff options
author | Czeber László Ádám <czeber.laszloadam@nisz.hu> | 2023-03-09 10:35:10 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2023-03-29 14:58:04 +0000 |
commit | 8bf897186de81b39064340c44a54db344d6878f6 (patch) | |
tree | ad6f01a7789020ef8f9931220ad5fa3148901c4d /writerfilter/source/dmapper/DomainMapper_Impl.cxx | |
parent | 6213787202570f783458a2d00351851ad46150d7 (diff) |
tdf#124472 DOCX import: fix broken field command by skipping delInstrText
Process only inserted and not tracked parts of the (partially)
tracked field commands to avoid of broken fields, e.g. hyperlinks
with bad URLs.
For example, instead of the previous bad URL
'https://www.libreoffice.org/"HYPERLINK https://bugs.libreoffice.org/',
now the hypertext field of the test document imported with the
correct URL 'https://www.libreoffice.org/'.
Field commands have change tracking in OOXML, but not in ODF/Writer.
OOXML delInstrText, i.e. deleted part of the field commands was imported
as part of the actual command, resulting broken fields, e.g. hyperlinks.
FieldCommand was splitted into two parts, deleted and non-deleted
elements. This way the commands do not get mixed up if the order
is changed and no fragmentation of deleted items occurs (otherwise
it could fail on the test of tdf#150086).
Change-Id: I97d22e5ee1fe647715206f86c4160ebcc4b9cca0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148528
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'writerfilter/source/dmapper/DomainMapper_Impl.cxx')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 3f402c50b3ee..45128e43565c 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -349,6 +349,7 @@ DomainMapper_Impl::DomainMapper_Impl( m_bStartBibliography(false), m_nStartGenericField(0), m_bTextInserted(false), + m_bTextDeleted(false), m_sCurrentPermId(0), m_bFrameDirectionSet(false), m_bInDocDefaultsImport(false), @@ -5350,6 +5351,7 @@ FieldContext::FieldContext(uno::Reference< text::XTextRange > xStart) : m_bFieldCommandCompleted(false) , m_xStartRange(std::move( xStart )) , m_bFieldLocked( false ) + , m_bCommandType(false) { m_pProperties = new PropertyMap(); } @@ -5381,7 +5383,7 @@ void FieldContext::CacheVariableValue(const uno::Any& rAny) void FieldContext::AppendCommand(std::u16string_view rPart) { - m_sCommand += rPart; + m_sCommand[m_bCommandType] += rPart; } ::std::vector<OUString> FieldContext::GetCommandParts() const @@ -5450,6 +5452,8 @@ void DomainMapper_Impl::AppendFieldCommand(OUString const & rPartOfCommand) OSL_ENSURE( pContext, "no field context available"); if( pContext ) { + // Set command line type: normal or deleted + pContext->SetCommandType(m_bTextDeleted); pContext->AppendCommand( rPartOfCommand ); } } @@ -6730,6 +6734,11 @@ void DomainMapper_Impl::CloseFieldCommand() m_bSetUserFieldContent = false; m_bSetCitation = false; m_bSetDateValue = false; + // tdf#124472: If the normal command line is not empty, use it, + // otherwise, the last active row is evaluated. + if (!pContext->GetCommandIsEmpty(false)) + pContext->SetCommandType(false); + const FieldConversionMap_t& aFieldConversionMap = lcl_GetFieldConversion(); try |