[Libreoffice-commits] .: sw/qa
Miklos Vajna
vmiklos at kemper.freedesktop.org
Tue Feb 21 09:45:01 PST 2012
sw/qa/extras/rtftok/data/n695479.rtf | 1
sw/qa/extras/rtftok/rtftok.cxx | 40 ++++++++++++++++++++++++++++-------
2 files changed, 34 insertions(+), 7 deletions(-)
New commits:
commit 2cd5042eb83ade5f883f5f6ea986bcdbd1e8f620
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Feb 21 18:25:37 2012 +0100
testcase for RTF import of drawing objects
diff --git a/sw/qa/extras/rtftok/data/n695479.rtf b/sw/qa/extras/rtftok/data/n695479.rtf
index f72c8b0..213f868 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 2787d15..a1f6521 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);
More information about the Libreoffice-commits
mailing list