diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-11-08 19:25:30 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-11-09 17:22:31 +0100 |
commit | cbaa72d6e963847a4b98526430cd928bc7928fdd (patch) | |
tree | d62372734ce37855ea88bf285e3a77028fd2d5f7 /sw/qa/extras | |
parent | fc59087c9d84b563733ac13c4eda7930e159c1e8 (diff) |
tdf#42346: DOC export of cross-references to objects
Same solution which was used for DOCX export:
98bc7215935f1eb2e0dc6f1db826d8e729430c13
Change-Id: I8af46db003a6192c6adaae1a35dff58744919eee
Reviewed-on: https://gerrit.libreoffice.org/44502
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sw/qa/extras')
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 4 | ||||
-rwxr-xr-x | sw/qa/extras/ww8export/data/object_cross_reference.odt | bin | 0 -> 35667 bytes | |||
-rwxr-xr-x | sw/qa/extras/ww8export/data/table_cross_reference.odt | bin | 0 -> 10251 bytes | |||
-rwxr-xr-x | sw/qa/extras/ww8export/data/table_cross_reference_custom_format.odt | bin | 0 -> 12087 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export2.cxx | 387 |
5 files changed, 391 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index 913b09b6257f..7c8d3be8acda 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -1295,6 +1295,8 @@ DECLARE_OOXMLEXPORT_TEST( testTableCrossReference, "table_cross_reference.odt" ) } ++nIndex; } + + CPPUNIT_ASSERT_EQUAL(sal_uInt16(8), nIndex); } DECLARE_OOXMLEXPORT_TEST( testTableCrossReferenceCustomFormat, "table_cross_reference_custom_format.odt" ) @@ -1708,6 +1710,8 @@ DECLARE_OOXMLEXPORT_TEST( testObjectCrossReference, "object_cross_reference.odt" } ++nIndex; } + + CPPUNIT_ASSERT_EQUAL(sal_uInt16(21), nIndex); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/ww8export/data/object_cross_reference.odt b/sw/qa/extras/ww8export/data/object_cross_reference.odt Binary files differnew file mode 100755 index 000000000000..9eaca352b68c --- /dev/null +++ b/sw/qa/extras/ww8export/data/object_cross_reference.odt diff --git a/sw/qa/extras/ww8export/data/table_cross_reference.odt b/sw/qa/extras/ww8export/data/table_cross_reference.odt Binary files differnew file mode 100755 index 000000000000..95f33139c522 --- /dev/null +++ b/sw/qa/extras/ww8export/data/table_cross_reference.odt diff --git a/sw/qa/extras/ww8export/data/table_cross_reference_custom_format.odt b/sw/qa/extras/ww8export/data/table_cross_reference_custom_format.odt Binary files differnew file mode 100755 index 000000000000..1c41e364c6e5 --- /dev/null +++ b/sw/qa/extras/ww8export/data/table_cross_reference_custom_format.odt diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx index 1c180173f11b..0a3179d853c3 100644 --- a/sw/qa/extras/ww8export/ww8export2.cxx +++ b/sw/qa/extras/ww8export/ww8export2.cxx @@ -323,6 +323,393 @@ DECLARE_WW8EXPORT_TEST( testActiveXCheckbox, "checkbox_control.odt" ) CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER,getProperty<text::TextContentAnchorType>(xPropertySet2,"AnchorType")); } +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 neccessary 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; + } + // Reference to table number + 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_number_only"), sValue); + xPropertySet->getPropertyValue("SequenceNumber") >>= nValue; + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue); + break; + } + // Reference to caption only + 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("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 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 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 4: + { + 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; + } + // Page style reference / exported as simple page reference + 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 / bellow 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 neccessary 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 neccessary 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()); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |