[Libreoffice-commits] core.git: sw/CppunitTest_sw_ooxmlexport12.mk sw/Module_sw.mk sw/qa

Mark Hung marklh9 at gmail.com
Sat Mar 31 09:06:15 UTC 2018


 sw/CppunitTest_sw_ooxmlexport12.mk         |   14 
 sw/Module_sw.mk                            |    1 
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx |  605 -----------------------
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx |  762 +++++++++++++++++++++++++++++
 4 files changed, 777 insertions(+), 605 deletions(-)

New commits:
commit 457208b260cbcc0b3aa1f045702d18a31d6dc671
Author: Mark Hung <marklh9 at gmail.com>
Date:   Thu Mar 29 21:35:42 2018 +0800

    Split ooxmlexport10 into two unit test modules.
    
    Change-Id: Ibd714f81f76717ac159897f6ee9f907a8098cabe
    Reviewed-on: https://gerrit.libreoffice.org/52153
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/CppunitTest_sw_ooxmlexport12.mk b/sw/CppunitTest_sw_ooxmlexport12.mk
new file mode 100644
index 000000000000..241c642ba1fc
--- /dev/null
+++ b/sw/CppunitTest_sw_ooxmlexport12.mk
@@ -0,0 +1,14 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call sw_ooxmlexport_test,12))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 4ef524d1fd94..79b6f566d3f2 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -71,6 +71,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
     CppunitTest_sw_ooxmlexport9 \
     CppunitTest_sw_ooxmlexport10 \
     CppunitTest_sw_ooxmlexport11 \
+    CppunitTest_sw_ooxmlexport12 \
     CppunitTest_sw_ooxmlfieldexport \
     CppunitTest_sw_ooxmllinks \
     CppunitTest_sw_ooxmlw14export \
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 624155cc9f27..fac212c3cfe9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -1197,611 +1197,6 @@ DECLARE_OOXMLEXPORT_TEST( testTdf107359, "tdf107359-char-pitch.docx" )
     CPPUNIT_ASSERT_EQUAL( sal_Int32(convertTwipToMm100(24 * 20)), nBaseWidth );
 }
 
-DECLARE_OOXMLEXPORT_TEST( testTableCrossReference, "table_cross_reference.odt" )
-{
-    // tdf#42346: Cross references to tables were not saved
-    // MSO uses simple bookmarks for referencing table caption, so we do the same by export
-    if (!mbExported)
-        return;
-
-    // Check whether we have all the necessary bookmarks exported and imported back
-    uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
-    uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xBookmarksByIdx->getCount());
-    uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_full"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_label_and_number"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_caption_only"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_number_only"));
-
-    // Check bookmark text ranges
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_full"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Table 1: Table caption"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_label_and_number"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Table 1"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_caption_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_number_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
-    }
-
-    // Check reference fields
-    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
-    uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
-    uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
-    CPPUNIT_ASSERT(xFields->hasMoreElements());
-
-    sal_uInt16 nIndex = 0;
-    while (xFields->hasMoreElements())
-    {
-        uno::Reference<lang::XServiceInfo> xServiceInfo(xFields->nextElement(), uno::UNO_QUERY);
-        uno::Reference<beans::XPropertySet> xPropertySet(xServiceInfo, uno::UNO_QUERY);
-        switch (nIndex)
-        {
-            // Full reference to table caption
-            case 0:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                sal_Int16 nValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Table 1: Table caption"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_full"), sValue);
-                xPropertySet->getPropertyValue("SequenceNumber") >>= nValue;
-                CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
-                break;
-            }
-            // Page style reference / exported as simple page reference
-            case 1:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                sal_Int16 nValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_full"), sValue);
-                xPropertySet->getPropertyValue("SequenceNumber") >>= nValue;
-                CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
-                break;
-            }
-            // Reference to table number
-            case 2:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                sal_Int16 nValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_number_only"), sValue);
-                xPropertySet->getPropertyValue("SequenceNumber") >>= nValue;
-                CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
-                break;
-            }
-            // Reference to caption only
-            case 3:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                sal_Int16 nValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_caption_only"), sValue);
-                xPropertySet->getPropertyValue("SequenceNumber") >>= nValue;
-                CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
-                break;
-            }
-            // Reference to category and number
-            case 4:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                sal_Int16 nValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Table 1"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_label_and_number"), sValue);
-                xPropertySet->getPropertyValue("SequenceNumber") >>= nValue;
-                CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
-                break;
-            }
-            // Reference to page of the table
-            case 5:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                sal_Int16 nValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_full"), sValue);
-                xPropertySet->getPropertyValue("SequenceNumber") >>= nValue;
-                CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
-                break;
-            }
-            // Above / below reference
-            case 6:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                sal_Int16 nValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("above"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_full"), sValue);
-                xPropertySet->getPropertyValue("SequenceNumber") >>= nValue;
-                CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
-                break;
-            }
-            default:
-                break;
-        }
-        ++nIndex;
-    }
-
-    CPPUNIT_ASSERT_EQUAL(sal_uInt16(8), nIndex);
-}
-
-DECLARE_OOXMLEXPORT_TEST( testTableCrossReferenceCustomFormat, "table_cross_reference_custom_format.odt" )
-{
-    // tdf#42346: Cross references to tables were not saved
-    // Check also captions with custom formatting
-    if (!mbExported)
-        return;
-
-    // Check whether we have all the necessary bookmarks exported and imported back
-    uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
-    uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(16), xBookmarksByIdx->getCount());
-    uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_full"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_label_and_number"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_caption_only"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_number_only"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table1_full"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table1_label_and_number"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table1_caption_only"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table1_number_only"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table2_full"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table2_label_and_number"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table2_caption_only"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table2_number_only"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table3_full"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table3_label_and_number"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table3_caption_only"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table3_number_only"));
-
-    // Check bookmark text ranges
-    // First table's caption
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_full"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("1. Table: Table caption"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_label_and_number"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("1. Table"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_caption_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_number_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
-    }
-    // Second table's caption
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table1_full"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("2. TableTable caption"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table1_label_and_number"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("2. Table"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table1_caption_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table1_number_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("2"), xRange->getString());
-    }
-    // Third table's caption
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table2_full"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("3) Table Table caption"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table2_label_and_number"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("3) Table"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table2_caption_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table2_number_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("3"), xRange->getString());
-    }
-    // Fourth table's caption
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table3_full"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Table 4- Table caption"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table3_label_and_number"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Table 4"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table3_caption_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table3_number_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("4"), xRange->getString());
-    }
-}
-
-DECLARE_OOXMLEXPORT_TEST( testObjectCrossReference, "object_cross_reference.odt" )
-{
-    // tdf#42346: Cross references to objects were not saved
-    // MSO uses simple bookmarks for referencing table caption, so we do the same by export
-    if (!mbExported)
-        return;
-
-    // Check whether we have all the necessary bookmarks exported and imported back
-    uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
-    uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(15), xBookmarksByIdx->getCount());
-    uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing0_full"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing0_label_and_number"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing0_caption_only"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing0_number_only"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing1_full"));
-
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Illustration0_full"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Illustration0_label_and_number"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Illustration0_caption_only"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Illustration0_number_only"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Illustration1_caption_only"));
-
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Text0_full"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Text0_label_and_number"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Text0_caption_only"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Text0_number_only"));
-    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Text1_label_and_number"));
-
-    // Check bookmark text ranges
-    // Cross references to shapes
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Drawing0_full"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1: A rectangle"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Drawing0_label_and_number"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Drawing0_caption_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("A rectangle"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Drawing0_number_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Drawing1_full"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Drawing 2: a circle"), xRange->getString());
-    }
-
-    // Cross references to pictures
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Illustration0_full"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1: A picture"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Illustration0_label_and_number"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Illustration0_caption_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("A picture"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Illustration0_number_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Illustration1_caption_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("an other image"), xRange->getString());
-    }
-
-    // Cross references to text frames
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Text0_full"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Text 1: A frame"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Text0_label_and_number"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Text 1"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Text0_caption_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("A frame"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Text0_number_only"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
-    }
-    {
-        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Text1_label_and_number"), uno::UNO_QUERY);
-        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
-        CPPUNIT_ASSERT_EQUAL(OUString("Text 2"), xRange->getString());
-    }
-
-    // Check reference fields
-    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
-    uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
-    uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
-    CPPUNIT_ASSERT(xFields->hasMoreElements());
-
-    sal_uInt16 nIndex = 0;
-    while (xFields->hasMoreElements())
-    {
-        uno::Reference<lang::XServiceInfo> xServiceInfo(xFields->nextElement(), uno::UNO_QUERY);
-        uno::Reference<beans::XPropertySet> xPropertySet(xServiceInfo, uno::UNO_QUERY);
-        switch (nIndex)
-        {
-            // Reference to image number
-            case 0:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration0_number_only"), sValue);
-                break;
-            }
-            // Full reference to the circle shape
-            case 1:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Drawing 2: a circle"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing1_full"), sValue);
-                break;
-            }
-            // Caption only reference to the second picture
-            case 2:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("an other image"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration1_caption_only"), sValue);
-                break;
-            }
-            // Category and number reference to second text frame
-            case 3:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Text 2"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text1_label_and_number"), sValue);
-                break;
-            }
-            // Full reference to rectangle shape
-            case 4:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1: A rectangle"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing0_full"), sValue);
-                break;
-            }
-            // Caption only reference to rectangle shape
-            case 5:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("A rectangle"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing0_caption_only"), sValue);
-                break;
-            }
-            // Category and number reference to rectangle shape
-            case 6:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing0_label_and_number"), sValue);
-                break;
-            }
-            // Reference to rectangle shape's number
-            case 7:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing0_number_only"), sValue);
-                break;
-            }
-            // Full reference to first text frame
-            case 8:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Text 1: A frame"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text0_full"), sValue);
-                break;
-            }
-            // Caption only reference to first text frame
-            case 9:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("A frame"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text0_caption_only"), sValue);
-                break;
-            }
-            // Category and number reference to first text frame
-            case 10:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Text 1"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text0_label_and_number"), sValue);
-                break;
-            }
-            // Number only reference to first text frame
-            case 11:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text0_number_only"), sValue);
-                break;
-            }
-            // Full reference to first picture
-            case 12:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1: A picture"), sValue.trim()); // failes on MAC without trim
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration0_full"), sValue);
-                break;
-            }
-            // Reference to first picture' caption
-            case 13:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("A picture"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration0_caption_only"), sValue);
-                break;
-            }
-            // Category and number reference to first picture
-            case 14:
-            {
-                CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
-                OUString sValue;
-                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1"), sValue);
-                xPropertySet->getPropertyValue("SourceName") >>= sValue;
-                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration0_label_and_number"), sValue);
-                break;
-            }
-            default:
-                break;
-        }
-        ++nIndex;
-    }
-
-    CPPUNIT_ASSERT_EQUAL(sal_uInt16(21), nIndex);
-}
-
-DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark.docx")
-{
-    uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
-    uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
-
-    sal_Int32 nHeight = xShape->getSize().Height;
-
-    // Rounding errors
-    sal_Int32 nDifference = 5150 - nHeight;
-    std::stringstream ss;
-    ss << "Difference: " << nDifference << " TotalHeight: " << nHeight;
-#ifndef _WIN32
-    // FIXME why does this sometimes fail?
-    CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference <= 4);
-    CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference >= -4);
-#endif
-}
-
-DECLARE_OOXMLEXPORT_TEST(testWatermarkTrim, "tdf114308.docx")
-{
-    uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
-
-    // Rounding errors
-    sal_Int32 nHeight = xShape->getSize().Height;
-    sal_Int32 nDifference = 8729 - nHeight;
-    std::stringstream ss;
-    ss << "Difference: " << nDifference << " TotalHeight: " << nHeight;
-    CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference <= 4);
-    CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference >= -4);
-}
-
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
new file mode 100644
index 000000000000..eefb014e3501
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -0,0 +1,762 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <memory>
+#include <sstream>
+#include <config_test.h>
+
+#include <swmodeltestbase.hxx>
+
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/RelOrientation.hpp>
+#include <com/sun/star/text/TableColumnSeparator.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/text/VertOrientation.hpp>
+#include <com/sun/star/text/WrapTextMode.hpp>
+#include <com/sun/star/text/WritingMode2.hpp>
+#include <com/sun/star/text/XBookmarksSupplier.hpp>
+#include <com/sun/star/text/XFootnote.hpp>
+#include <com/sun/star/text/XPageCursor.hpp>
+#include <com/sun/star/text/XTextColumns.hpp>
+#include <com/sun/star/text/XTextFrame.hpp>
+#include <com/sun/star/text/XTextField.hpp>
+#include <com/sun/star/text/XTextFramesSupplier.hpp>
+#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
+#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <com/sun/star/style/BreakType.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <com/sun/star/table/ShadowFormat.hpp>
+#include <com/sun/star/view/XFormLayerAccess.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/table/BorderLine2.hpp>
+#include <com/sun/star/table/TableBorder2.hpp>
+#include <com/sun/star/text/SizeType.hpp>
+#include <com/sun/star/xml/dom/XDocument.hpp>
+#include <com/sun/star/text/XDocumentIndex.hpp>
+#include <com/sun/star/style/CaseMap.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <vcl/bitmapaccess.hxx>
+#include <unotest/assertion_traits.hxx>
+#include <unotools/fltrcfg.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <swtypes.hxx>
+#include <drawdoc.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <unotools/streamwrap.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <svx/svdpage.hxx>
+#include <editeng/unoprnms.hxx>
+
+#include <bordertest.hxx>
+
+class Test : public SwModelTestBase
+{
+public:
+    Test()
+        : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text")
+    {
+    }
+
+protected:
+    /**
+     * Blacklist handling
+     */
+    bool mustTestImportOf(const char* filename) const override
+    {
+        // If the testcase is stored in some other format, it's pointless to test.
+        return OString(filename).endsWith(".docx");
+    }
+};
+
+DECLARE_OOXMLEXPORT_TEST(testTableCrossReference, "table_cross_reference.odt")
+{
+    // tdf#42346: Cross references to tables were not saved
+    // MSO uses simple bookmarks for referencing table caption, so we do the same by export
+    if (!mbExported)
+        return;
+
+    // Check whether we have all the necessary bookmarks exported and imported back
+    uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(),
+                                                            uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xBookmarksByIdx->getCount());
+    uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(),
+                                                            uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_full"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_label_and_number"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_caption_only"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_number_only"));
+
+    // Check bookmark text ranges
+    {
+        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_full"),
+                                                    uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Table 1: Table caption"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table0_label_and_number"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Table 1"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table0_caption_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table0_number_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
+    }
+
+    // Check reference fields
+    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> xFieldsAccess(
+        xTextFieldsSupplier->getTextFields());
+    uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+    CPPUNIT_ASSERT(xFields->hasMoreElements());
+
+    sal_uInt16 nIndex = 0;
+    while (xFields->hasMoreElements())
+    {
+        uno::Reference<lang::XServiceInfo> xServiceInfo(xFields->nextElement(), uno::UNO_QUERY);
+        uno::Reference<beans::XPropertySet> xPropertySet(xServiceInfo, uno::UNO_QUERY);
+        switch (nIndex)
+        {
+            // Full reference to table caption
+            case 0:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                sal_Int16 nValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Table 1: Table caption"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_full"), sValue);
+                xPropertySet->getPropertyValue("SequenceNumber") >>= nValue;
+                CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
+                break;
+            }
+            // Page style reference / exported as simple page reference
+            case 1:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                sal_Int16 nValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_full"), sValue);
+                xPropertySet->getPropertyValue("SequenceNumber") >>= nValue;
+                CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
+                break;
+            }
+            // Reference to table number
+            case 2:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                sal_Int16 nValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_number_only"), sValue);
+                xPropertySet->getPropertyValue("SequenceNumber") >>= nValue;
+                CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
+                break;
+            }
+            // Reference to caption only
+            case 3:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                sal_Int16 nValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_caption_only"), sValue);
+                xPropertySet->getPropertyValue("SequenceNumber") >>= nValue;
+                CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
+                break;
+            }
+            // Reference to category and number
+            case 4:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                sal_Int16 nValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Table 1"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_label_and_number"), sValue);
+                xPropertySet->getPropertyValue("SequenceNumber") >>= nValue;
+                CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
+                break;
+            }
+            // Reference to page of the table
+            case 5:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                sal_Int16 nValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_full"), sValue);
+                xPropertySet->getPropertyValue("SequenceNumber") >>= nValue;
+                CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
+                break;
+            }
+            // Above / below reference
+            case 6:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                sal_Int16 nValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("above"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_full"), sValue);
+                xPropertySet->getPropertyValue("SequenceNumber") >>= nValue;
+                CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
+                break;
+            }
+            default:
+                break;
+        }
+        ++nIndex;
+    }
+
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(8), nIndex);
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTableCrossReferenceCustomFormat,
+                         "table_cross_reference_custom_format.odt")
+{
+    // tdf#42346: Cross references to tables were not saved
+    // Check also captions with custom formatting
+    if (!mbExported)
+        return;
+
+    // Check whether we have all the necessary bookmarks exported and imported back
+    uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(),
+                                                            uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(16), xBookmarksByIdx->getCount());
+    uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(),
+                                                            uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_full"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_label_and_number"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_caption_only"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_number_only"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table1_full"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table1_label_and_number"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table1_caption_only"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table1_number_only"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table2_full"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table2_label_and_number"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table2_caption_only"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table2_number_only"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table3_full"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table3_label_and_number"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table3_caption_only"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table3_number_only"));
+
+    // Check bookmark text ranges
+    // First table's caption
+    {
+        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_full"),
+                                                    uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("1. Table: Table caption"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table0_label_and_number"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("1. Table"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table0_caption_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table0_number_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
+    }
+    // Second table's caption
+    {
+        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table1_full"),
+                                                    uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("2. TableTable caption"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table1_label_and_number"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("2. Table"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table1_caption_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table1_number_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("2"), xRange->getString());
+    }
+    // Third table's caption
+    {
+        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table2_full"),
+                                                    uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("3) Table Table caption"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table2_label_and_number"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("3) Table"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table2_caption_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table2_number_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("3"), xRange->getString());
+    }
+    // Fourth table's caption
+    {
+        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table3_full"),
+                                                    uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Table 4- Table caption"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table3_label_and_number"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Table 4"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table3_caption_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Table3_number_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("4"), xRange->getString());
+    }
+}
+
+DECLARE_OOXMLEXPORT_TEST(testObjectCrossReference, "object_cross_reference.odt")
+{
+    // tdf#42346: Cross references to objects were not saved
+    // MSO uses simple bookmarks for referencing table caption, so we do the same by export
+    if (!mbExported)
+        return;
+
+    // Check whether we have all the necessary bookmarks exported and imported back
+    uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(),
+                                                            uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(15), xBookmarksByIdx->getCount());
+    uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(),
+                                                            uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing0_full"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing0_label_and_number"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing0_caption_only"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing0_number_only"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing1_full"));
+
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Illustration0_full"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Illustration0_label_and_number"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Illustration0_caption_only"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Illustration0_number_only"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Illustration1_caption_only"));
+
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Text0_full"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Text0_label_and_number"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Text0_caption_only"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Text0_number_only"));
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Text1_label_and_number"));
+
+    // Check bookmark text ranges
+    // Cross references to shapes
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Drawing0_full"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1: A rectangle"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Drawing0_label_and_number"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Drawing0_caption_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("A rectangle"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Drawing0_number_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Drawing1_full"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Drawing 2: a circle"), xRange->getString());
+    }
+
+    // Cross references to pictures
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Illustration0_full"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1: A picture"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Illustration0_label_and_number"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Illustration0_caption_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("A picture"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Illustration0_number_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Illustration1_caption_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("an other image"), xRange->getString());
+    }
+
+    // Cross references to text frames
+    {
+        uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Text0_full"),
+                                                    uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Text 1: A frame"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Text0_label_and_number"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Text 1"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Text0_caption_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("A frame"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Text0_number_only"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
+    }
+    {
+        uno::Reference<text::XTextContent> xContent(
+            xBookmarksByName->getByName("Ref_Text1_label_and_number"), uno::UNO_QUERY);
+        uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("Text 2"), xRange->getString());
+    }
+
+    // Check reference fields
+    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> xFieldsAccess(
+        xTextFieldsSupplier->getTextFields());
+    uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+    CPPUNIT_ASSERT(xFields->hasMoreElements());
+
+    sal_uInt16 nIndex = 0;
+    while (xFields->hasMoreElements())
+    {
+        uno::Reference<lang::XServiceInfo> xServiceInfo(xFields->nextElement(), uno::UNO_QUERY);
+        uno::Reference<beans::XPropertySet> xPropertySet(xServiceInfo, uno::UNO_QUERY);
+        switch (nIndex)
+        {
+            // Reference to image number
+            case 0:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration0_number_only"), sValue);
+                break;
+            }
+            // Full reference to the circle shape
+            case 1:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Drawing 2: a circle"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing1_full"), sValue);
+                break;
+            }
+            // Caption only reference to the second picture
+            case 2:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("an other image"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration1_caption_only"), sValue);
+                break;
+            }
+            // Category and number reference to second text frame
+            case 3:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Text 2"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text1_label_and_number"), sValue);
+                break;
+            }
+            // Full reference to rectangle shape
+            case 4:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1: A rectangle"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing0_full"), sValue);
+                break;
+            }
+            // Caption only reference to rectangle shape
+            case 5:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("A rectangle"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing0_caption_only"), sValue);
+                break;
+            }
+            // Category and number reference to rectangle shape
+            case 6:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing0_label_and_number"), sValue);
+                break;
+            }
+            // Reference to rectangle shape's number
+            case 7:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing0_number_only"), sValue);
+                break;
+            }
+            // Full reference to first text frame
+            case 8:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Text 1: A frame"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text0_full"), sValue);
+                break;
+            }
+            // Caption only reference to first text frame
+            case 9:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("A frame"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text0_caption_only"), sValue);
+                break;
+            }
+            // Category and number reference to first text frame
+            case 10:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Text 1"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text0_label_and_number"), sValue);
+                break;
+            }
+            // Number only reference to first text frame
+            case 11:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text0_number_only"), sValue);
+                break;
+            }
+            // Full reference to first picture
+            case 12:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1: A picture"),
+                                     sValue.trim()); // failes on MAC without trim
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration0_full"), sValue);
+                break;
+            }
+            // Reference to first picture' caption
+            case 13:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("A picture"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration0_caption_only"), sValue);
+                break;
+            }
+            // Category and number reference to first picture
+            case 14:
+            {
+                CPPUNIT_ASSERT(
+                    xServiceInfo->supportsService("com.sun.star.text.TextField.GetReference"));
+                OUString sValue;
+                xPropertySet->getPropertyValue("CurrentPresentation") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1"), sValue);
+                xPropertySet->getPropertyValue("SourceName") >>= sValue;
+                CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration0_label_and_number"), sValue);
+                break;
+            }
+            default:
+                break;
+        }
+        ++nIndex;
+    }
+
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(21), nIndex);
+}
+
+DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark.docx")
+{
+    uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
+
+    sal_Int32 nHeight = xShape->getSize().Height;
+
+    // Rounding errors
+    sal_Int32 nDifference = 5150 - nHeight;
+    std::stringstream ss;
+    ss << "Difference: " << nDifference << " TotalHeight: " << nHeight;
+#ifndef _WIN32
+    // FIXME why does this sometimes fail?
+    CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference <= 4);
+    CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference >= -4);
+#endif
+}
+
+DECLARE_OOXMLEXPORT_TEST(testWatermarkTrim, "tdf114308.docx")
+{
+    uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
+
+    // Rounding errors
+    sal_Int32 nHeight = xShape->getSize().Height;
+    sal_Int32 nDifference = 8729 - nHeight;
+    std::stringstream ss;
+    ss << "Difference: " << nDifference << " TotalHeight: " << nHeight;
+    CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference <= 4);
+    CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference >= -4);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list