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 7aa6bf5a7c89c8d114c84eb24e3056568fb7c9df Author: Justin Luth <justin_l...@sil.org> Date: Thu Jan 22 14:29:59 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. testcase included Change-Id: I9b2855e9d00f4d103c3be22b1b1185c557865d87 Reviewed-on: https://gerrit.libreoffice.org/14099 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> 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 5f4e0bc..edb07aa 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -515,6 +515,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 d30a6db..53a9b66 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 1d46adb..246d3f6 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