summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-02-21 18:25:37 +0100
committerMiklos Vajna <vmiklos@suse.cz>2012-02-21 18:44:35 +0100
commit2cd5042eb83ade5f883f5f6ea986bcdbd1e8f620 (patch)
tree7e52c7bcef8c71628fe375092d27473e36536bbe /sw
parent43eefa11eb1d025b7967e75574f07603f6ac8a96 (diff)
testcase for RTF import of drawing objects
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtftok/data/n695479.rtf1
-rw-r--r--sw/qa/extras/rtftok/rtftok.cxx40
2 files changed, 34 insertions, 7 deletions
diff --git a/sw/qa/extras/rtftok/data/n695479.rtf b/sw/qa/extras/rtftok/data/n695479.rtf
index f72c8b0f76d0..213f868d5d7c 100644
--- a/sw/qa/extras/rtftok/data/n695479.rtf
+++ b/sw/qa/extras/rtftok/data/n695479.rtf
@@ -8,5 +8,6 @@
\pard \ltrpar\ql \li0\ri0\nowidctlpar\pvpg\posx5562\posy5417\absh-226\absw5946\overlay\faauto\rin0\lin0\itap0\pararsid15926738
{\rtlch\fcs1 \ab\af0 \ltrch\fcs0 \cf1\lang1038\langfe1038\langnp1038\insrsid10974703
second\par }
+{\*\do\dobxmargin\dobypage\dodhgt0\dpline\dpx81\dpy4923\dpxsize11438\dpysize1\dplinecor0\dplinecog0\dplinecob0}
\pard plain\par
}
diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx
index 2787d1597ab1..a1f6521ce94f 100644
--- a/sw/qa/extras/rtftok/rtftok.cxx
+++ b/sw/qa/extras/rtftok/rtftok.cxx
@@ -25,10 +25,12 @@
* instead of those above.
*/
-#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/text/RelOrientation.hpp>
#include <com/sun/star/text/SizeType.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
#include <com/sun/star/text/XTextFramesSupplier.hpp>
@@ -182,14 +184,38 @@ void RtfModelTest::testN695479()
aValue >>= nHeight;
CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(300)), nHeight);
- // Both frames should be anchored to the first paragraph.
- for (int i = 0; i < 2; ++i)
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ bool bFrameFound = false, bDrawFound = false;
+ for (int i = 0; i < xDraws->getCount(); ++i)
{
- uno::Reference<text::XTextContent> xTextContent(xIndexAccess->getByIndex(i), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY);
- uno::Reference<text::XText> xText(xRange->getText(), uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(OUString(RTL_CONSTASCII_USTRINGPARAM("plain")), xText->getString());
+ uno::Reference<lang::XServiceInfo> xServiceInfo(xDraws->getByIndex(i), uno::UNO_QUERY);
+ if (xServiceInfo->supportsService(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))))
+ {
+ // Both frames should be anchored to the first paragraph.
+ bFrameFound = true;
+ uno::Reference<text::XTextContent> xTextContent(xServiceInfo, uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XText> xText(xRange->getText(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString(RTL_CONSTASCII_USTRINGPARAM("plain")), xText->getString());
+ }
+ else if (xServiceInfo->supportsService(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.LineShape"))))
+ {
+ // The older "drawing objects" syntax should be recognized.
+ bDrawFound = true;
+ xPropertySet.set(xServiceInfo, uno::UNO_QUERY);
+ sal_Int16 nHori = 0;
+ aValue = xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientRelation")));
+ aValue >>= nHori;
+ CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, nHori);
+ sal_Int16 nVert = 0;
+ aValue = xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientRelation")));
+ aValue >>= nVert;
+ CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, nVert);
+ }
}
+ CPPUNIT_ASSERT(bFrameFound);
+ CPPUNIT_ASSERT(bDrawFound);
}
CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest);