sw/source/filter/ww1/fltshell.cxx | 2 +- sw/source/filter/ww8/ww8par5.cxx | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-)
New commits: commit 789ee5c2c6f3ed8bcee94d2596a9673055da6ebe Author: Justin Luth <[email protected]> Date: Fri Jan 23 08:54:08 2015 +0300 fdo#68963 recognize __RefHeading__ bookmarks as TOC LibreOffice recognizes MS Office TOC, but LO files saved as .doc format had no text showing. Now bookmarks using the LO naming convention are also imported as TOC bookmarks. Change-Id: Id2a186437fe4634a8ca85c2324c089f9387e437b Reviewed-on: https://gerrit.libreoffice.org/14124 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx index 5eca85e..d0eee9c 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/ww1/fltshell.cxx @@ -937,7 +937,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 aba9ee4..e4f9a6f 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -100,7 +100,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; } } @@ -214,7 +225,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; } @@ -2052,8 +2063,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 ); } @@ -2079,8 +2089,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 ); } @@ -3403,9 +3412,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 ); }
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
