Kaydet (Commit) 55728c04 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Andras Timar

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: 's avatarJustin Luth <justin_luth@sil.org>
(cherry picked from commit 579c0749)

Change-Id: I1e11980e52dc523393fd6d621191228d676e9a17
üst 9c20b037
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment