summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2015-03-10 10:15:44 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-03-14 10:45:13 +0000
commit2ad285eacda91bb95ec2fbb44ce6fa0b4d50f817 (patch)
tree9ff3f9062057cdc303414cd95d54b50097377760
parent7196df7ac616be39689f21d8784fd78030868586 (diff)
tdf#89482 fix __refheading__ regression, set only CrossRefs as TOC.
bugfix tdf#68963 marked all __refheading__ bookmarks at TOC, but those crossreferences were deleted if they are not recorded in aReferencedTOCBookmarks. Redesigned the fix to include _Toc in the crossreference name that is auto-generated, which is how MSWord differentiates the markers. Updated the test document to include even more combinations of cross-references and numbered heading references. Change-Id: I3d60d2b528ebfa1ffb108bbfc9e7db2c604af49b Reviewed-on: https://gerrit.libreoffice.org/14822 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ww8import/data/fdo68963.docbin16384 -> 22528 bytes
-rw-r--r--sw/qa/extras/ww8import/ww8import.cxx2
-rw-r--r--sw/source/core/crsr/crossrefbookmark.cxx2
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx11
4 files changed, 13 insertions, 2 deletions
diff --git a/sw/qa/extras/ww8import/data/fdo68963.doc b/sw/qa/extras/ww8import/data/fdo68963.doc
index 4b331f03f9d0..b31741f7c545 100644
--- a/sw/qa/extras/ww8import/data/fdo68963.doc
+++ b/sw/qa/extras/ww8import/data/fdo68963.doc
Binary files differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 8ba9466d462e..0c0da881233a 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -521,6 +521,8 @@ DECLARE_WW8IMPORT_TEST(testfdo68963, "fdo68963.doc")
// The problem was that the text was not displayed.
CPPUNIT_ASSERT ( !parseDump("/root/page/body/tab/row[2]/cell[1]/txt/Special", "rText").isEmpty() );
CPPUNIT_ASSERT_EQUAL( OUString("Topic 1"), parseDump("/root/page/body/tab/row[2]/cell[1]/txt/Special", "rText") );
+ // all crossreference bookmarks should have a target. Shouldn't be any "Reference source not found" in the xml
+ CPPUNIT_ASSERT ( -1 == parseDump("/root/page/body/txt[24]/Special[2]","rText").indexOf("Reference source not found"));
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/crsr/crossrefbookmark.cxx b/sw/source/core/crsr/crossrefbookmark.cxx
index 700a3f217c12..67a25d07520c 100644
--- a/sw/source/core/crsr/crossrefbookmark.cxx
+++ b/sw/source/core/crsr/crossrefbookmark.cxx
@@ -72,7 +72,7 @@ namespace sw { namespace mark
const vcl::KeyCode& rCode,
const OUString& rName,
const OUString& rShortName)
- : CrossRefBookmark(rPaM, rCode, rName, rShortName, IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix())
+ : CrossRefBookmark(rPaM, rCode, rName, rShortName, IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix()+"_Toc")
{ }
bool CrossRefHeadingBookmark::IsLegalName(const OUString& rName)
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 555413ab983b..5e485405897d 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -101,7 +101,7 @@ namespace
// #120879# - helper method to identify a bookmark name to match the internal TOC bookmark naming convention
bool IsTOCBookmarkName(const OUString& rName)
{
- return rName.startsWith("_Toc") || rName.startsWith(IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix());
+ return rName.startsWith("_Toc") || rName.startsWith(IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix()+"_Toc");
}
OUString EnsureTOCBookmarkName(const OUString& rName)
@@ -1969,6 +1969,15 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, OUString& rStr )
OUString sBkmName(GetMappedBookmark(sOrigBkmName));
+ // #i120879# add cross reference bookmark name prefix, if it
+ // matches internal TOC bookmark naming convention
+ if ( IsTOCBookmarkName( sBkmName ) )
+ {
+ sBkmName = EnsureTOCBookmarkName(sBkmName);
+ // track <sBookmarkName> as referenced TOC bookmark.
+ pReffedStck->aReferencedTOCBookmarks.insert( sBkmName );
+ }
+
SwGetRefField aFld(
static_cast<SwGetRefFieldType*>(rDoc.getIDocumentFieldsAccess().GetSysFldType( RES_GETREFFLD )),
sBkmName,REF_BOOKMARK,0,eFormat);