diff options
author | Justin Luth <justin_luth@sil.org> | 2015-01-19 19:05:09 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-01-22 09:18:25 +0000 |
commit | aa852c88c8312512e3595accefb9bc4d234a26a3 (patch) | |
tree | 9b35342d834fd02ce7d43c2dc8a396c0ef580af0 /sw/source | |
parent | b4f6b26b5a1a78fecfa95ec2eb7ac8b80495d8aa (diff) |
fdo#68963 recognize __RefHeading__ bookmarks as TOC in .doc files
LibreOffice recognizes MS Office Table Of Contents, but LO files
saved as .doc didn't show the Cross-Refence heading - it was blank.
Now bookmarks using the LO naming convention are also imported
as TOC bookmarks from .doc files.
Testcase included.
Change-Id: Icae5c0de31856ccc75ede9a97c0ea046dd97325f
Reviewed-on: https://gerrit.libreoffice.org/14018
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/filter/basflt/fltshell.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par5.cxx | 25 |
2 files changed, 17 insertions, 10 deletions
diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx index 5692dcdba7fd..7c69f35243fd 100644 --- a/sw/source/filter/basflt/fltshell.cxx +++ b/sw/source/filter/basflt/fltshell.cxx @@ -917,7 +917,7 @@ SwFltBookmark::SwFltBookmark( const OUString& rNa, const OUString& rVa, // otherwise: Src Charset from argument for aName // Src Charset from filter for aVal ( Text ) - if ( IsTOCBookmark() ) + if ( IsTOCBookmark() && ! rNa.startsWith(IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix()) ) { maName = IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix(); maName += rNa; diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 44d9d11ff0d7..97b0ed55a967 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -102,7 +102,18 @@ namespace // #120879# - helper method to identify a bookmark name to match the internal TOC bookmark naming convention bool IsTOCBookmarkName( const ::rtl::OUString& rName ) { - return rName.startsWith("_Toc"); + return rName.startsWith("_Toc") || rName.startsWith(IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix()); + } + + ::rtl::OUString EnsureTOCBookmarkName( const ::rtl::OUString& rName ) + { + OUString sTmp = rName; + if ( IsTOCBookmarkName ( rName ) ) + { + if ( ! rName.startsWith(IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix()) ) + sTmp = IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix() + rName; + } + return sTmp; } } @@ -216,7 +227,7 @@ long SwWW8ImplReader::Read_Book(WW8PLCFManResult*) const OUString sOrigName = BookmarkToWriter(*pName); pReffedStck->NewAttr( aStart, - SwFltBookmark( sOrigName, aVal, pB->GetHandle(), IsTOCBookmarkName( sOrigName ) )); + SwFltBookmark( EnsureTOCBookmarkName( sOrigName ), aVal, pB->GetHandle(), IsTOCBookmarkName( sOrigName ) )); return 0; } @@ -2062,8 +2073,7 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, OUString& rStr ) OUString sBookmarkName; if ( IsTOCBookmarkName( sName ) ) { - sBookmarkName = IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix(); - sBookmarkName += sName; + sBookmarkName = EnsureTOCBookmarkName(sName); // track <sBookmarkName> as referenced TOC bookmark. pReffedStck->aReferencedTOCBookmarks.insert( sBookmarkName ); } @@ -2089,8 +2099,7 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, OUString& rStr ) OUString sPageRefBookmarkName; if ( IsTOCBookmarkName( sName ) ) { - sPageRefBookmarkName = IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix(); - sPageRefBookmarkName += sName; + sPageRefBookmarkName = EnsureTOCBookmarkName(sName); // track <sPageRefBookmarkName> as referenced TOC bookmark. pReffedStck->aReferencedTOCBookmarks.insert( sPageRefBookmarkName ); } @@ -3388,9 +3397,7 @@ eF_ResT SwWW8ImplReader::Read_F_Hyperlink( WW8FieldDesc* /*pF*/, OUString& rStr // #120879# add cross reference bookmark name prefix, if it matches internal TOC bookmark naming convention if ( IsTOCBookmarkName( sMark ) ) { - OUString sTmp = IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix(); - sTmp += sMark; - sMark = sTmp; + sMark = EnsureTOCBookmarkName(sMark); // track <sMark> as referenced TOC bookmark. pReffedStck->aReferencedTOCBookmarks.insert( sMark ); } |