diff options
author | Justin Luth <justin_luth@sil.org> | 2015-01-22 14:29:59 +0300 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-01-23 11:50:52 +0000 |
commit | 7aa6bf5a7c89c8d114c84eb24e3056568fb7c9df (patch) | |
tree | ba96f9384543544cb8910629f50b4277e783894a | |
parent | d1f6db02338a723dbce77293398475ae44bc8f58 (diff) |
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 <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/qa/extras/ww8import/data/fdo68963.doc | bin | 0 -> 16384 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8import/ww8import.cxx | 7 | ||||
-rw-r--r-- | sw/source/filter/basflt/fltshell.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par5.cxx | 25 |
4 files changed, 24 insertions, 10 deletions
diff --git a/sw/qa/extras/ww8import/data/fdo68963.doc b/sw/qa/extras/ww8import/data/fdo68963.doc Binary files differnew file mode 100644 index 000000000000..4b331f03f9d0 --- /dev/null +++ b/sw/qa/extras/ww8import/data/fdo68963.doc diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index 5f4e0bc059f7..edb07aaf9428 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 d30a6dbefaf2..53a9b662306c 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 1d46adb3df6f..246d3f6b9c93 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 ); } |