summaryrefslogtreecommitdiff
path: root/sw/qa/extras/rtfexport
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2020-05-14 15:42:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-05-15 08:42:04 +0200
commit36e62098c8c541c4a3fb63eced591cf29ac56e4a (patch)
tree2a8b87b9049338819e0cef1997d00fac3b56d135 /sw/qa/extras/rtfexport
parent44006d2fdc67c1b2ff68407b16b4b4939012282c (diff)
CppUnittest: sw: simplify code. use getShapes and getShape
Change-Id: I494349b99a122f67ed1f2881faf1a37e4358c55b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94214 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/qa/extras/rtfexport')
-rw-r--r--sw/qa/extras/rtfexport/rtfexport2.cxx43
-rw-r--r--sw/qa/extras/rtfexport/rtfexport5.cxx28
2 files changed, 24 insertions, 47 deletions
diff --git a/sw/qa/extras/rtfexport/rtfexport2.cxx b/sw/qa/extras/rtfexport/rtfexport2.cxx
index e696539c0b1b..d20b46873dd9 100644
--- a/sw/qa/extras/rtfexport/rtfexport2.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport2.cxx
@@ -130,21 +130,17 @@ DECLARE_RTFEXPORT_TEST(testFdo42465, "fdo42465.rtf") { CPPUNIT_ASSERT_EQUAL(3, g
DECLARE_RTFEXPORT_TEST(testFdo45187, "fdo45187.rtf")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
// There should be two shapes.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(2, getShapes());
// They should be anchored to different paragraphs.
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XTextRangeCompare> xTextRangeCompare(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<text::XTextRange> xAnchor0
- = uno::Reference<text::XTextContent>(xDraws->getByIndex(0), uno::UNO_QUERY_THROW)
- ->getAnchor();
+ = uno::Reference<text::XTextContent>(getShape(1), uno::UNO_QUERY_THROW)->getAnchor();
uno::Reference<text::XTextRange> xAnchor1
- = uno::Reference<text::XTextContent>(xDraws->getByIndex(1), uno::UNO_QUERY_THROW)
- ->getAnchor();
+ = uno::Reference<text::XTextContent>(getShape(2), uno::UNO_QUERY_THROW)->getAnchor();
// Was 0 ("starts at the same position"), should be 1 ("starts before")
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xTextRangeCompare->compareRegionStarts(xAnchor0, xAnchor1));
}
@@ -299,11 +295,11 @@ DECLARE_RTFEXPORT_TEST(testFdo44176, "fdo44176.rtf")
DECLARE_RTFEXPORT_TEST(testFdo39053, "fdo39053.rtf")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
+ int nShapes = getShapes();
+ CPPUNIT_ASSERT_EQUAL(1, nShapes);
int nAsCharacter = 0;
- for (int i = 0; i < xDraws->getCount(); ++i)
- if (getProperty<text::TextContentAnchorType>(xDraws->getByIndex(i), "AnchorType")
+ for (int i = 0; i < nShapes; ++i)
+ if (getProperty<text::TextContentAnchorType>(getShape(i + 1), "AnchorType")
== text::TextContentAnchorType_AS_CHARACTER)
nAsCharacter++;
// The image in binary format was ignored.
@@ -698,20 +694,17 @@ DECLARE_RTFEXPORT_TEST(testShptxtPard, "shptxt-pard.rtf")
DECLARE_RTFEXPORT_TEST(testDoDhgt, "do-dhgt.rtf")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
- for (int i = 0; i < xDraws->getCount(); ++i)
+ int nShapes = getShapes();
+ CPPUNIT_ASSERT_EQUAL(3, nShapes);
+ for (int i = 0; i < nShapes; ++i)
{
- sal_Int32 nFillColor = getProperty<sal_Int32>(xDraws->getByIndex(i), "FillColor");
+ sal_Int32 nFillColor = getProperty<sal_Int32>(getShape(i + 1), "FillColor");
if (nFillColor == 0xc0504d) // red
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
- getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getShape(i + 1), "ZOrder"));
else if (nFillColor == 0x9bbb59) // green
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1),
- getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(getShape(i + 1), "ZOrder"));
else if (nFillColor == 0x4f81bd) // blue
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2),
- getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<sal_Int32>(getShape(i + 1), "ZOrder"));
}
}
@@ -733,9 +726,7 @@ DECLARE_RTFEXPORT_TEST(testLeftmarginDefault, "leftmargin-default.rtf")
DECLARE_RTFEXPORT_TEST(testDppolyline, "dppolyline.rtf")
{
// This was completely ignored, for now, just make sure we have all 4 lines.
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(4, getShapes());
}
DECLARE_RTFEXPORT_TEST(testFdo56512, "fdo56512.rtf")
@@ -805,9 +796,7 @@ DECLARE_RTFEXPORT_TEST(testFdo57678, "fdo57678.rtf")
DECLARE_RTFEXPORT_TEST(testFdo54612, "fdo54612.rtf")
{
// \dpptx without a \dppolycount caused a crash.
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(8, getShapes());
}
DECLARE_RTFEXPORT_TEST(testFdo58933, "fdo58933.rtf")
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx
index af317a4980c0..299cea3bcc90 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -213,13 +213,11 @@ CPPUNIT_TEST_FIXTURE(Test, testParaStyleBottomMargin2)
DECLARE_RTFEXPORT_TEST(testFdo66040, "fdo66040.rtf")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
// This was 0 (no shapes were imported), we want two textframes.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(2, getShapes());
// The second paragraph of the first shape should be actually a table, with "A" in its A1 cell.
- uno::Reference<text::XTextRange> xTextRange(xDraws->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xTextRange(getShape(1), uno::UNO_QUERY);
uno::Reference<text::XText> xText = xTextRange->getText();
uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>(
@@ -227,7 +225,7 @@ DECLARE_RTFEXPORT_TEST(testFdo66040, "fdo66040.rtf")
->getString());
// Make sure the second shape has the correct position and size.
- uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(1), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape(getShape(2), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(14420), getProperty<sal_Int32>(xShape, "HoriOrientPosition"));
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1032), getProperty<sal_Int32>(xShape, "VertOrientPosition"));
CPPUNIT_ASSERT_EQUAL(sal_Int32(14000), xShape->getSize().Width);
@@ -262,10 +260,8 @@ DECLARE_RTFEXPORT_TEST(testFdo77996, "fdo77996.rtf")
DECLARE_RTFEXPORT_TEST(testFdo47802, "fdo47802.rtf")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
// Shape inside table was ignored.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
}
DECLARE_RTFEXPORT_TEST(testFdo39001, "fdo39001.rtf")
@@ -331,10 +327,8 @@ DECLARE_RTFEXPORT_TEST(testFdo68076, "fdo68076.rtf")
DECLARE_RTFEXPORT_TEST(testFdo70221, "fdo70221.rtf")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
// The picture was imported twice.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
}
DECLARE_RTFEXPORT_TEST(testCp1000018, "cp1000018.rtf")
@@ -353,10 +347,8 @@ DECLARE_RTFEXPORT_TEST(testCp1000018, "cp1000018.rtf")
DECLARE_RTFEXPORT_TEST(testFdo94835, "fdo94835.rtf")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
// The picture was imported twice.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(19), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(19, getShapes());
}
DECLARE_RTFEXPORT_TEST(testNestedTable, "rhbz1065629.rtf")
{
@@ -770,9 +762,7 @@ DECLARE_RTFEXPORT_TEST(testFdo86750, "fdo86750.rtf")
DECLARE_RTFEXPORT_TEST(testTdf88811, "tdf88811.rtf")
{
// The problem was that shapes anchored to the paragraph that is moved into a textframe were lost, so this was 2.
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(4, getShapes());
}
DECLARE_RTFEXPORT_TEST(testFdo49893_2, "fdo49893-2.rtf")
@@ -1059,9 +1049,7 @@ DECLARE_RTFEXPORT_TEST(testTdf90697, "tdf90697.rtf")
DECLARE_RTFEXPORT_TEST(testTdf104317, "tdf104317.rtf")
{
// This failed to load, we tried to set CustomShapeGeometry on a line shape.
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
}
DECLARE_RTFEXPORT_TEST(testTdf104744, "tdf104744.rtf")