diff options
author | Justin Luth <justin.luth@collabora.com> | 2018-10-09 14:03:37 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2018-10-12 05:56:01 +0200 |
commit | 579c0749bef8c980507229439715e72060c1b077 (patch) | |
tree | 3e0f842e4be9066c666f8dac944f2008551503e1 /writerfilter | |
parent | 3fa8f934195cabb9c6fa9cd09ee0a05c7ded46ab (diff) |
tdf120224 writerfilter: consume excess bookmark from fields
Although this follows a very different code path, copy the ww8
import idea of "consuming" the bookmark of a BOOK_FIELD.
This is particularly important for textcontrols, especially
since LO keeps duplicating bookmarks as it adds another
bookmark for the field name at each save.
Existing unit tests that this matches are fdo53985.docx and
tdf111964.docx. I expected more, but apparently most fields
don't contain or represent any bookmarks.
This patch is for import only. A followup patch stops
the creation of duplicate bookmarks during export.
Change-Id: I1e11980e52dc523393fd6d621191228d676e9a17
Reviewed-on: https://gerrit.libreoffice.org/61615
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 5c1251f4d1d9..ced0cda06778 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -5101,7 +5101,22 @@ void DomainMapper_Impl::SetBookmarkName( const OUString& rBookmarkName ) { BookmarkMap_t::iterator aBookmarkIter = m_aBookmarkMap.find( m_sCurrentBkmkId ); if( aBookmarkIter != m_aBookmarkMap.end() ) + { + // fields are internal bookmarks: consume redundant "normal" bookmark + if ( IsOpenField() ) + { + FFDataHandler::Pointer_t pFFDataHandler(GetTopFieldContext()->getFFDataHandler()); + if ( IsOpenFieldCommand() || (pFFDataHandler && pFFDataHandler->getName() == rBookmarkName) ) + { + // HACK: At the END marker, StartOrEndBookmark will START + // a bookmark which will eventually be abandoned, not created. + m_aBookmarkMap.erase(aBookmarkIter); + return; + } + } + aBookmarkIter->second.m_sBookmarkName = rBookmarkName; + } else m_sCurrentBkmkName = rBookmarkName; } |