summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2018-10-09 14:03:37 +0300
committerAndras Timar <andras.timar@collabora.com>2018-10-13 20:43:47 +0200
commit55728c04006b791a5380e9a4145c593287ec33ca (patch)
treece198603d6f299ebc8539b1c76eda7bbde1d1c25 /writerfilter
parent9c20b03783ae07f40891422c1e8a943384b6f96d (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. Reviewed-on: https://gerrit.libreoffice.org/61615 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> (cherry picked from commit 579c0749bef8c980507229439715e72060c1b077) Change-Id: I1e11980e52dc523393fd6d621191228d676e9a17
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx15
1 files changed, 15 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f65d2166cc01..1ea53b810609 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4827,7 +4827,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;
}