sw/qa/extras/ww8import/data/fdo68963.doc |binary sw/qa/extras/ww8import/ww8import.cxx | 7 +++++++ sw/source/filter/basflt/fltshell.cxx | 2 +- sw/source/filter/ww8/ww8par5.cxx | 25 ++++++++++++++++--------- 4 files changed, 24 insertions(+), 10 deletions(-)
New commits: commit aa852c88c8312512e3595accefb9bc4d234a26a3 Author: Justin Luth <justin_l...@sil.org> Date: Mon Jan 19 19:05:09 2015 +0300 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 <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/sw/qa/extras/ww8import/data/fdo68963.doc b/sw/qa/extras/ww8import/data/fdo68963.doc new file mode 100644 index 0000000..4b331f0 Binary files /dev/null and b/sw/qa/extras/ww8import/data/fdo68963.doc differ diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index b40ef14..97e3d4b 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -516,6 +516,13 @@ DECLARE_WW8IMPORT_TEST(testLayoutHanging, "fdo68967.doc") // This must not hang in layout } +DECLARE_WW8IMPORT_TEST(testfdo68963, "fdo68963.doc") +{ + // The problem was that the text was not displayed. + CPPUNIT_ASSERT ( OUString("") != parseDump("/root/page/body/tab/row[2]/cell[1]/txt/Special", "rText") ); + CPPUNIT_ASSERT_EQUAL( OUString("Topic 1"), parseDump("/root/page/body/tab/row[2]/cell[1]/txt/Special", "rText") ); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx index 5692dcd..7c69f35 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 44d9d11..97b0ed5 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 ); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits