diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2015-08-26 18:05:08 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-09-14 16:52:47 +0000 |
commit | 2b2a812b89d0d1df08c5d771bfe9bc5eaa3a040c (patch) | |
tree | 5c8640a85135e446cf887510b8b8a913b87fd8f5 /sd | |
parent | 97ad6393525a928b5dfe2a6562d7604446da7af0 (diff) |
tdf#91293: Preserve hyperlink on URL field OOXML export
The fix is twofold:
1.Get URL property from the underlying text field, not from the
text run -- put text field properties into rXPropSet (that's
what GETA macro later queries), not into rRun
6a043e9c0acff20e1618ca8ec15c21d5d0fd0d37 does s/rXPropSet/rRun/
afaics for no good reason
2. Retrieve string content from URL field early, so that the test
for empty text content doesn't fire
Change-Id: I4317e4a2f6f2e6f15c30932adc80f1227e010af0
Reviewed-on: https://gerrit.libreoffice.org/18031
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/data/pptx/hyperlinktest.pptx | bin | 0 -> 33633 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests.cxx | 47 |
2 files changed, 47 insertions, 0 deletions
diff --git a/sd/qa/unit/data/pptx/hyperlinktest.pptx b/sd/qa/unit/data/pptx/hyperlinktest.pptx Binary files differnew file mode 100644 index 000000000000..dac61c023dd3 --- /dev/null +++ b/sd/qa/unit/data/pptx/hyperlinktest.pptx diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 375ed3eb8153..ee6a4167a811 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -60,6 +60,7 @@ #include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/text/XTextField.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/table/BorderLine2.hpp> @@ -118,6 +119,7 @@ public: void testLineStyle(); void testCellLeftAndRightMargin(); void testRightToLeftParaghraph(); + void testTextboxWithHyperlink(); void testTableCellBorder(); void testBulletColor(); void testTdf62176(); @@ -158,6 +160,7 @@ public: CPPUNIT_TEST(testLineStyle); CPPUNIT_TEST(testCellLeftAndRightMargin); CPPUNIT_TEST(testRightToLeftParaghraph); + CPPUNIT_TEST(testTextboxWithHyperlink); CPPUNIT_TEST(testTableCellBorder); CPPUNIT_TEST(testBulletColor); CPPUNIT_TEST(testTdf62176); @@ -955,6 +958,50 @@ void SdExportTest::testRightToLeftParaghraph() xDocShRef->DoClose(); } +void SdExportTest::testTextboxWithHyperlink() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/hyperlinktest.pptx"), PPTX); + + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + uno::Reference< drawing::XDrawPagesSupplier > xDoc( + xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW ); + + uno::Reference< drawing::XDrawPage > xPage( + xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW ); + + uno::Reference< beans::XPropertySet > xShape( + xPage->getByIndex(0), uno::UNO_QUERY ); + CPPUNIT_ASSERT_MESSAGE( "no shape", xShape.is() ); + + // Get first paragraph + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText(); + CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() ); + uno::Reference<container::XEnumerationAccess> paraEnumAccess; + paraEnumAccess.set(xText, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration(); + uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(), + uno::UNO_QUERY_THROW); + + // first chunk of text + // FIXME: those should really be some convenience function (getShape, getParagraph, getRun etc.) + uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); + uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW ); + + uno::Reference<text::XTextField> xField; + xPropSet->getPropertyValue("TextField") >>= xField; + CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() ); + + xPropSet.set(xField, uno::UNO_QUERY); + OUString aURL; + xPropSet->getPropertyValue("URL") >>= aURL; + CPPUNIT_ASSERT_EQUAL_MESSAGE("URLs don't match", OUString("http://www.xkcd.com/"), aURL); + + xDocShRef->DoClose(); +} + void SdExportTest::testBulletColor() { ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/bulletColor.pptx"), PPTX ); |