summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-09-05 09:07:48 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-09-05 14:30:14 +0200
commit4cde2a01be75552a0b7d37f65cc4134cb48fea26 (patch)
tree7ec8a538684f285503bad5691aa712dae87c162e /sw/qa/extras
parent1f66a258f2371d516b6a031a46ab4ef5d973796b (diff)
tdf#104936 RTF export: implement ZOrder of TextFrames / shapes
This used to work by accident for the particular textbox, but broke with commit 38f2b8b3b16aab19a2564ec699d253d3dccecc3c (tdf#88811 SwXText::convertToTextFrame: handle shapes anchored to us, 2015-02-03), so write ZOrder explicitly, like other filters already do. Change-Id: Ie8f11f4ec77707fb5aec7a597544d589a99bf6ca Reviewed-on: https://gerrit.libreoffice.org/41921 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/globalfilter/globalfilter.cxx27
-rw-r--r--sw/qa/extras/rtfexport/data/tdf104936.rtf20
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx11
3 files changed, 56 insertions, 2 deletions
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index 51f021c5c83a..a81be11690c2 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -284,6 +284,29 @@ void Test::testImageWithSpecialID()
}
}
+/// Gives the first embedded or linked image in a document.
+uno::Reference<drawing::XShape> lcl_getShape(const uno::Reference<lang::XComponent>& xComponent, bool bEmbedded)
+{
+ uno::Reference<drawing::XShape> xRet;
+
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xComponent, uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+ for (sal_Int32 i = 0; i < xDrawPage->getCount(); ++i)
+ {
+ uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(i), uno::UNO_QUERY);
+ OUString sURL;
+ xShape->getPropertyValue("GraphicURL") >>= sURL;
+ // Linked image: working starts with file://, broken is e.g. 'vnd.sun.star.GraphicObject:3000000000000000000000000000000000000000'.
+ if ((sURL.startsWith("file://") || sURL.endsWith("0000000000000000")) != bEmbedded)
+ {
+ xRet.set(xShape, uno::UNO_QUERY);
+ break;
+ }
+ }
+
+ return xRet;
+}
+
void Test::testGraphicShape()
{
// There are two kind of images in Writer: 1) Writer specific handled by SwGrfNode and
@@ -327,7 +350,7 @@ void Test::testGraphicShape()
const OString sFailedMessage = OString("Failed on filter: ") + aFilterNames[nFilter];
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), xDraws->getCount());
- uno::Reference<drawing::XShape> xImage = getShape(1);
+ uno::Reference<drawing::XShape> xImage = lcl_getShape(mxComponent, true);
uno::Reference< beans::XPropertySet > XPropSet( xImage, uno::UNO_QUERY_THROW );
// First image is embedded
// Check URL
@@ -351,7 +374,7 @@ void Test::testGraphicShape()
return;
// Second image is a linked one
- xImage = getShape(2);
+ xImage = lcl_getShape(mxComponent, false);
XPropSet.set( xImage, uno::UNO_QUERY_THROW );
// Check URL
{
diff --git a/sw/qa/extras/rtfexport/data/tdf104936.rtf b/sw/qa/extras/rtfexport/data/tdf104936.rtf
new file mode 100644
index 000000000000..3f854b642500
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf104936.rtf
@@ -0,0 +1,20 @@
+{\rtf\ansi\ansicpg1251
+{\fonttbl
+{\f1\fcharset204 Arial}
+{\f2\fcharset204 Courier New}
+}
+{\colortbl;\red0\green0\blue0;}
+\viewkind1\paperw11340\paperh16840\margl0\margr0\margt460\margb1240
+\viewkind1\paperw11340\paperh16840\margl0\margr0\margt460\margb1240
+\viewkind1\paperw11340\paperh16840\margl0\margr0\margt460\margb1240
+\viewkind1\paperw11340\paperh16840\margl0\margr0\margt460\margb1240
+{\do\dobxpage\dobypage\dprect
+\dpx0\dpy450\dpxsize11160\dpysize1943
+\dpfillfgcr255\dpfillfgcg255\dpfillfgcb255
+\dpfillbgcr255\dpfillbgcg255\dpfillbgcb255\dpfillpat1
+\dplinew0 \dplinehollow
+}
+{\pard \qc \pvpg\phpg\posx2786\posy1218\absw1080 \absh-235
+{\f2\fs20 \cf1 \b Hello\par}
+}
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 4d46f82819df..7b9107819005 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -867,6 +867,17 @@ DECLARE_RTFEXPORT_TEST(testCjklist38, "cjklist38.rtf")
CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH, numFormat);
}
+DECLARE_RTFEXPORT_TEST(testTdf104936, "tdf104936.rtf")
+{
+ uno::Reference<text::XTextRange> xShape1(getShape(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(xShape1, "ZOrder"));
+ // This failed, the shape without text covered the shape with text.
+ CPPUNIT_ASSERT(xShape1->getString().isEmpty());
+ uno::Reference<text::XTextRange> xShape2(getShape(2), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), getProperty<sal_Int32>(xShape2, "ZOrder"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xShape2->getString());
+}
+
DECLARE_RTFEXPORT_TEST(testTableRtl, "table-rtl.rtf")
{
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);