summaryrefslogtreecommitdiff
path: root/sw/qa
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
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')
-rw-r--r--sw/qa/extras/globalfilter/globalfilter.cxx25
-rw-r--r--sw/qa/extras/mailmerge/mailmerge.cxx4
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx4
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx4
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport10.cxx22
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport2.cxx16
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport3.cxx24
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport4.cxx15
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport8.cxx22
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx12
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx24
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport2.cxx8
-rw-r--r--sw/qa/extras/rtfexport/rtfexport2.cxx43
-rw-r--r--sw/qa/extras/rtfexport/rtfexport5.cxx28
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx61
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx12
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx8
-rw-r--r--sw/qa/extras/uiwriter/uiwriter3.cxx28
-rw-r--r--sw/qa/extras/unowriter/unowriter.cxx10
-rw-r--r--sw/qa/extras/ww8export/ww8export2.cxx4
-rw-r--r--sw/qa/extras/ww8import/ww8import.cxx8
-rw-r--r--sw/qa/inc/swmodeltestbase.hxx8
22 files changed, 133 insertions, 257 deletions
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index 557fec699ce0..f223e95e2461 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -113,14 +113,11 @@ void Test::testEmbeddedGraphicRoundtrip()
mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument");
// Check whether graphic exported well after it was swapped out
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
-
const OString sFailedMessage = OStringLiteral("Failed on filter: ") + rFilterName.toUtf8();
- CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 2, getShapes());
// First image
- uno::Reference<drawing::XShape> xImage(xDraws->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xImage(getShape(1), uno::UNO_QUERY);
uno::Reference< beans::XPropertySet > XPropSet( xImage, uno::UNO_QUERY_THROW );
// Check graphic, size
@@ -136,7 +133,7 @@ void Test::testEmbeddedGraphicRoundtrip()
}
// Second Image
- xImage.set(xDraws->getByIndex(1), uno::UNO_QUERY);
+ xImage.set(getShape(2), uno::UNO_QUERY);
XPropSet.set( xImage, uno::UNO_QUERY_THROW );
// Check graphic, size
@@ -250,11 +247,8 @@ void Test::testImageWithSpecialID()
mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument");
// Check whether graphic exported well
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
-
const OString sFailedMessage = OStringLiteral("Failed on filter: ") + rFilterName.toUtf8();
- CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 2, getShapes());
uno::Reference<drawing::XShape> xImage = getShape(1);
uno::Reference< beans::XPropertySet > XPropSet( xImage, uno::UNO_QUERY_THROW );
@@ -272,7 +266,7 @@ void Test::testImageWithSpecialID()
}
// Second Image
- xImage.set(xDraws->getByIndex(1), uno::UNO_QUERY);
+ xImage.set(getShape(2), uno::UNO_QUERY);
XPropSet.set( xImage, uno::UNO_QUERY_THROW );
// Check graphic, size
@@ -348,11 +342,8 @@ void Test::testGraphicShape()
mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument");
// Check whether graphic exported well
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
-
const OString sFailedMessage = OStringLiteral("Failed on filter: ") + rFilterName.toUtf8();
- CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 2, getShapes());
uno::Reference<drawing::XShape> xImage = lcl_getShape(mxComponent, true);
CPPUNIT_ASSERT_MESSAGE("Couldn't load the shape/image", xImage.is());
@@ -805,8 +796,6 @@ void Test::testSkipImages()
}
// Check shapes (images, textboxes, custom shapes)
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
uno::Reference<drawing::XShape> xShape;
uno::Reference<graphic::XGraphic> xGraphic;
uno::Reference< beans::XPropertySet > XPropSet;
@@ -816,7 +805,7 @@ void Test::testSkipImages()
bool bHasCustomShapeText = false;
sal_Int32 nImageCount = 0;
- for (int i = 1; i<= xDraws->getCount(); i++)
+ for (int i = 1; i<= getShapes(); i++)
{
xShape = getShape(i);
XPropSet.set( xShape, uno::UNO_QUERY_THROW );
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index 223646303cb3..a4f5e0bbeffa 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -392,9 +392,7 @@ DECLARE_FILE_MAILMERGE_TEST(testMissingDefaultLineColor, "missing-default-line-c
executeMailMerge();
// The document was created by LO version which didn't write out the default value for line color
// (see XMLGraphicsDefaultStyle::SetDefaults()).
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
- uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
// Lines do not have a line color.
CPPUNIT_ASSERT( !xPropertySet->getPropertySetInfo()->hasPropertyByName( "LineColor" ));
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 967932f4e4f4..7648af492ced 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -1575,9 +1575,7 @@ DECLARE_ODFEXPORT_TEST(testFdo86963, "fdo86963.odt")
{
CPPUNIT_ASSERT_EQUAL(1, getPages());
// Export of this document failed with beans::UnknownPropertyException.
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
}
// Check for correct header/footer with special first page with TOC inside:
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 8d5fee8748f1..5f521b8067c4 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -873,10 +873,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf91261, "tdf91261.docx")
DECLARE_OOXMLEXPORT_TEST(testTdf79639, "tdf79639.docx")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
// This was 0, floating table in header wasn't converted to a TextFrame.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
}
DECLARE_OOXMLEXPORT_TEST(testTdf89890, "tdf89890.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 422e374c3280..f4c29f271bcd 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -102,9 +102,7 @@ protected:
DECLARE_OOXMLEXPORT_TEST(testSmartart, "smartart.docx")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xGroup->getCount()); // background, 3 rectangles and an arrow in the group
@@ -271,9 +269,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo70457, "fdo70457.docx")
// It must be imported as a XShape object with the proper rotation value
// Check: there is one shape in the doc
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
// Check: the angle of the shape is 45º
CPPUNIT_ASSERT_EQUAL(sal_Int32(4500), getProperty<sal_Int32>(getShape(1), "RotateAngle"));
@@ -567,9 +563,7 @@ DECLARE_OOXMLIMPORT_TEST(testFdo38414, "fdo38414.docx" )
DECLARE_OOXMLEXPORT_TEST(test_extra_image, "test_extra_image.docx" )
{
// fdo#74652 Check there is no shape added to the doc during import
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(0, getShapes());
}
DECLARE_OOXMLEXPORT_TEST(testFdo74401, "fdo74401.docx")
@@ -878,11 +872,8 @@ DECLARE_OOXMLEXPORT_TEST(mathtype, "mathtype.docx")
DECLARE_OOXMLEXPORT_TEST(testTdf8255, "tdf8255.docx")
{
- uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xTextDocument, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
// This was 1: a full-page-wide multi-page floating table was imported as a TextFrame.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(0, getShapes());
}
DECLARE_OOXMLEXPORT_TEST(testTdf87460, "tdf87460.docx")
@@ -1157,11 +1148,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf97371, "tdf97371.docx")
DECLARE_OOXMLEXPORT_TEST(testTdf99140, "tdf99140.docx")
{
- uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xTextDocument, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
// This was 1: a multi-page floating table was imported as a TextFrame.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(0, getShapes());
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index f9541a29678a..c622c6999c9b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -450,9 +450,7 @@ DECLARE_OOXMLEXPORT_TEST(testTextFrames, "textframes.odt")
{
CPPUNIT_ASSERT_EQUAL(1, getPages());
// The frames were simply missing, so let's check if all 3 frames were imported back.
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xIndexAccess = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xIndexAccess->getCount());
+ CPPUNIT_ASSERT_EQUAL(3, getShapes());
}
DECLARE_OOXMLEXPORT_TEST(testTextFrameBorders, "textframe-borders.docx")
@@ -491,18 +489,16 @@ DECLARE_OOXMLEXPORT_TEST(testTextFrameBorders, "textframe-borders.docx")
DECLARE_OOXMLEXPORT_TEST(testTextframeGradient, "textframe-gradient.docx")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xIndexAccess = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
+ CPPUNIT_ASSERT_EQUAL(2, getShapes());
- uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
awt::Gradient aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aGradient.StartColor);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), aGradient.EndColor);
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
- xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
+ xFrame.set(getShape(2), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), aGradient.StartColor);
@@ -825,9 +821,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo58577, "fdo58577.odt")
{
CPPUNIT_ASSERT_EQUAL(1, getPages());
// The second frame was simply missing, so let's check if both frames were imported back.
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xIndexAccess = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
+ CPPUNIT_ASSERT_EQUAL(2, getShapes());
}
DECLARE_OOXMLEXPORT_TEST(testBnc581614, "bnc581614.doc")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index 5b4db5f10a86..db1fa7520d33 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -432,9 +432,7 @@ DECLARE_OOXMLEXPORT_TEST(testSmartart, "smartart.docx")
}
CPPUNIT_ASSERT(bTheme); // Grab Bag has all the expected elements
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc
+ CPPUNIT_ASSERT_EQUAL(1, getShapes()); // One groupshape in the doc
uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xGroup->getCount()); // 1 rendered bitmap from the original shapes
@@ -634,54 +632,52 @@ DECLARE_OOXMLEXPORT_TEST(testLineSpacingexport, "test_line_spacing.docx")
DECLARE_OOXMLEXPORT_TEST(testTextBoxGradientAngle, "fdo65295.docx")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xIndexAccess = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xIndexAccess->getCount());
+ CPPUNIT_ASSERT_EQUAL(8, getShapes());
// Angle of frame#1 is 135 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
- uno::Reference<beans::XPropertySet> xFrame1(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xFrame1(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame1, "FillStyle"));
awt::Gradient aGradient1 = getProperty<awt::Gradient>(xFrame1, "FillGradient");
CPPUNIT_ASSERT_EQUAL(sal_Int16(135 * 10), aGradient1.Angle);
// Angle of frame#2 is 180 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
- uno::Reference<beans::XPropertySet> xFrame2(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xFrame2(getShape(2), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame2, "FillStyle"));
awt::Gradient aGradient2 = getProperty<awt::Gradient>(xFrame2, "FillGradient");
CPPUNIT_ASSERT_EQUAL(sal_Int16(180 * 10), aGradient2.Angle);
// Angle of frame#3 is 90 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
- uno::Reference<beans::XPropertySet> xFrame3(xIndexAccess->getByIndex(2), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xFrame3(getShape(3), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame3, "FillStyle"));
awt::Gradient aGradient3 = getProperty<awt::Gradient>(xFrame3, "FillGradient");
CPPUNIT_ASSERT_EQUAL(sal_Int16( 90 * 10), aGradient3.Angle);
// Angle of frame#4 is 225 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
- uno::Reference<beans::XPropertySet> xFrame4(xIndexAccess->getByIndex(3), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xFrame4(getShape(4), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame4, "FillStyle"));
awt::Gradient aGradient4 = getProperty<awt::Gradient>(xFrame4, "FillGradient");
CPPUNIT_ASSERT_EQUAL(sal_Int16(225 * 10), aGradient4.Angle);
// Angle of frame#5 is 270 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
- uno::Reference<beans::XPropertySet> xFrame5(xIndexAccess->getByIndex(4), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xFrame5(getShape(5), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame5, "FillStyle"));
awt::Gradient aGradient5 = getProperty<awt::Gradient>(xFrame5, "FillGradient");
CPPUNIT_ASSERT_EQUAL(sal_Int16(270 * 10), aGradient5.Angle);
// Angle of frame#6 is 315 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
- uno::Reference<beans::XPropertySet> xFrame6(xIndexAccess->getByIndex(5), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xFrame6(getShape(6), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame6, "FillStyle"));
awt::Gradient aGradient6 = getProperty<awt::Gradient>(xFrame6, "FillGradient");
CPPUNIT_ASSERT_EQUAL(sal_Int16(315 * 10), aGradient6.Angle);
// Angle of frame#7 is 0 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
- uno::Reference<beans::XPropertySet> xFrame7(xIndexAccess->getByIndex(6), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xFrame7(getShape(7), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame7, "FillStyle"));
awt::Gradient aGradient7 = getProperty<awt::Gradient>(xFrame7, "FillGradient");
CPPUNIT_ASSERT_EQUAL(sal_Int16( 0 * 10), aGradient7.Angle);
// Angle of frame#8 is 45 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
- uno::Reference<beans::XPropertySet> xFrame8(xIndexAccess->getByIndex(7), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xFrame8(getShape(8), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame8, "FillStyle"));
awt::Gradient aGradient8 = getProperty<awt::Gradient>(xFrame8, "FillGradient");
CPPUNIT_ASSERT_EQUAL(sal_Int16( 45 * 10), aGradient8.Angle);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index f90bc6d357d7..00976d2c3022 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -68,10 +68,8 @@ DECLARE_OOXMLEXPORT_TEST(testRelorientation, "relorientation.docx")
DECLARE_OOXMLEXPORT_TEST(testBezier, "bezier.odt")
{
CPPUNIT_ASSERT_EQUAL(1, getPages());
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
// Check that no shape got lost: a bezier, a line and a text shape.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(3, getShapes());
}
DECLARE_OOXMLEXPORT_TEST(testGroupshapeTextbox, "groupshape-textbox.docx")
@@ -406,12 +404,7 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testChartInFooter, "chart-in-footer.docx")
"rId1");
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- if (xDrawPageSupplier.is())
- {
- // If xDrawPage->getCount()==1, then document contains one shape.
- uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount()); // One shape in the doc
- }
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
}
DECLARE_OOXMLEXPORT_TEST(testNestedTextFrames, "nested-text-frames.odt")
@@ -461,9 +454,7 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testAbi11739, "abi11739.docx")
DECLARE_OOXMLEXPORT_TEST(testEmbeddedXlsx, "embedded-xlsx.docx")
{
// check there are two objects and they are FrameShapes
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(2, getShapes());
CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), getShape(1)->getShapeType());
CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), getShape(2)->getShapeType());
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
index 526e8b6372c9..f31bf3e4b31f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
@@ -179,9 +179,7 @@ xray graphic.Size
xray image.AnchorType
*/
uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPageSupplier> drawPageSupplier(textDocument, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> drawPage = drawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL( sal_Int32( 1 ), drawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
uno::Reference<drawing::XShapes> shapes(getShape(1), uno::UNO_QUERY);
uno::Reference<drawing::XShape> image;
shapes->getByIndex(0) >>= image;
@@ -511,10 +509,8 @@ DECLARE_OOXMLEXPORT_TEST(testTDF91260, "tdf91260.docx")
DECLARE_OOXMLEXPORT_TEST(testFdo74357, "fdo74357.docx")
{
// Floating table wasn't converted to a textframe.
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
// This was 0.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
// Bottom margin of the first paragraph was too large, causing a layout problem.
// This was 494.
@@ -677,11 +673,9 @@ DECLARE_OOXMLEXPORT_TEST(testN792778, "n792778.docx")
* xray ThisComponent.DrawPage(0).getByIndex(0).getByIndex(0).Position.Y ' 11684, the vertical position of the shapes were also wrong
* xray ThisComponent.DrawPage(0).getByIndex(1).getByIndex(0).Position.Y ' 11684
*/
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
- uno::Reference<drawing::XShapes> xGroupShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<drawing::XShapes> xGroupShape(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupShape->getCount());
uno::Reference<drawing::XShapes> xInnerGroupShape(xGroupShape->getByIndex(0), uno::UNO_QUERY);
@@ -828,9 +822,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo61343, "fdo61343.docx")
{
// The problem was that there were a groupshape in the doc, followed by an
// OLE object, and this lead to a crash.
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
}
DECLARE_OOXMLEXPORT_TEST(testToolsLineNumbering, "tools-line-numbering.docx")
@@ -1143,9 +1135,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo69636, "fdo69636.docx")
DECLARE_OOXMLEXPORT_TEST(testChartProp, "chart-prop.docx")
{
// The problem was that chart was not getting parsed in writer module.
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(15240), getProperty<sal_Int32>(xPropertySet, "Width"));
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 37c76c477f6f..7f9015c0bc84 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -128,10 +128,8 @@ DECLARE_SW_ROUNDTRIP_TEST(testBadDocm, "bad.docm", nullptr, DocmTest)
DECLARE_OOXMLEXPORT_TEST(testTdf109063, "tdf109063.docx")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
// This was 1, near-page-width table was imported as a TextFrame.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(0, getShapes());
}
DECLARE_SW_ROUNDTRIP_TEST(testTdf108269, "tdf108269.docm", nullptr, DocmTest)
@@ -726,9 +724,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf84678, "tdf84678.docx")
DECLARE_OOXMLEXPORT_TEST(testTdf103544, "tdf103544.docx")
{
// We have two shapes: a frame and an image
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(2, getShapes());
// Image was lost because of the frame export
uno::Reference<beans::XPropertySet> xImage(getShape(1), uno::UNO_QUERY);
@@ -1104,10 +1100,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf107033, "tdf107033.docx")
#if HAVE_MORE_FONTS
DECLARE_OOXMLEXPORT_TEST(testTdf107889, "tdf107889.docx")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
// This was 1, multi-page table was imported as a floating one.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(0, getShapes());
}
#endif
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 5cf893bb0937..e08fadcc6b70 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -503,10 +503,7 @@ DECLARE_OOXMLIMPORT_TEST(testN779627, "n779627.docx")
* Another problem tested with this document is the unnecessary loading of the shapes
* anchored to a discarded header or footer
*/
- uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPageSupplier> drawPageSupplier(textDocument, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> drawPage = drawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), drawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(0, getShapes());
}
DECLARE_OOXMLIMPORT_TEST(testN779627b, "n779627b.docx")
@@ -566,12 +563,9 @@ DECLARE_OOXMLIMPORT_TEST(testWordArtResizing, "WordArt.docx")
/* The Word-Arts and watermarks were getting resized automatically, It was as if they were
getting glued to the fallback geometry(the sdrObj) and were getting bound to the font size.
The test-case ensures the original height and width of the word-art is not changed while importing*/
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
-
- uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(10105), xShape->getSize().Width);
CPPUNIT_ASSERT_EQUAL(sal_Int32(4755), xShape->getSize().Height);
}
@@ -589,17 +583,15 @@ DECLARE_OOXMLIMPORT_TEST(testGroupshapeLine, "groupshape-line.docx")
* xray ThisComponent.DrawPage(1).getByIndex(0).Position 'x: 1272, y: 2286
* xray ThisComponent.DrawPage(1).getByIndex(0).Size 'width: 10160, height: 0
*/
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(2, getShapes());
- uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(2656), xShape->getPosition().X);
CPPUNIT_ASSERT_EQUAL(sal_Int32(339), xShape->getPosition().Y);
CPPUNIT_ASSERT_EQUAL(sal_Int32(3270), xShape->getSize().Width);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1392), xShape->getSize().Height);
- uno::Reference<drawing::XShapes> xGroupShape(xDrawPage->getByIndex(1), uno::UNO_QUERY);
+ uno::Reference<drawing::XShapes> xGroupShape(getShape(2), uno::UNO_QUERY);
xShape.set(xGroupShape->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1272), xShape->getPosition().X);
CPPUNIT_ASSERT_EQUAL(sal_Int32(2286), xShape->getPosition().Y);
@@ -811,9 +803,7 @@ DECLARE_OOXMLIMPORT_TEST(testTdf75573_lostTable, "tdf75573_lostTable.docx")
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL_MESSAGE("# of tables", sal_Int32(1), xTables->getCount() );
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL_MESSAGE("# of frames/shapes", sal_Int32(0), xDraws->getCount() );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("# of frames/shapes", 0, getShapes() );
CPPUNIT_ASSERT_EQUAL_MESSAGE("# of pages", 3, getPages() );
}
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 6047a97f7c8c..be99a8b9c47a 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -414,10 +414,8 @@ DECLARE_OOXMLIMPORT_TEST(testTdf121804, "tdf121804.docx")
DECLARE_OOXMLIMPORT_TEST(testTdf114217, "tdf114217.docx")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
// This was 1, multi-page table was imported as a floating one.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(0, getShapes());
}
DECLARE_OOXMLIMPORT_TEST(testTdf116486, "tdf116486.docx")
@@ -443,9 +441,7 @@ DECLARE_OOXMLIMPORT_TEST(testTdf115094, "tdf115094.docx")
{
// anchor of graphic has to be the text in the text frame
// xray ThisComponent.DrawPage(1).Anchor.Text
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
- uno::Reference<text::XTextContent> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY);
+ uno::Reference<text::XTextContent> xShape(getShape(2), uno::UNO_QUERY);
uno::Reference<text::XTextRange> xText1 = xShape->getAnchor()->getText();
// xray ThisComponent.TextTables(0).getCellByName("A1")
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")
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 08d7d647c167..085a71aedc86 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -73,12 +73,13 @@ CPPUNIT_TEST_FIXTURE(Test, testN695479)
CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(300)),
getProperty<sal_Int32>(xPropertySet, "Height"));
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
+ int nShapes = getShapes();
+ CPPUNIT_ASSERT_EQUAL(3, nShapes);
+
bool bFrameFound = false, bDrawFound = false;
- for (int i = 0; i < xDraws->getCount(); ++i)
+ for (int i = 0; i < nShapes; ++i)
{
- uno::Reference<lang::XServiceInfo> xServiceInfo(xDraws->getByIndex(i), uno::UNO_QUERY);
+ uno::Reference<lang::XServiceInfo> xServiceInfo(getShape(i + 1), uno::UNO_QUERY);
if (xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
{
// Both frames should be anchored to the first paragraph.
@@ -231,12 +232,13 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf108951)
CPPUNIT_TEST_FIXTURE(Test, testFdo47036)
{
load(mpTestDocumentPath, "fdo47036.rtf");
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
+
+ int nShapes = getShapes();
+ CPPUNIT_ASSERT_EQUAL(3, nShapes);
int nAtCharacter = 0;
- for (int i = 0; i < xDraws->getCount(); ++i)
+ for (int i = 0; i < nShapes; ++i)
{
- if (getProperty<text::TextContentAnchorType>(xDraws->getByIndex(i), "AnchorType")
+ if (getProperty<text::TextContentAnchorType>(getShape(i + 1), "AnchorType")
== text::TextContentAnchorType_AT_CHARACTER)
nAtCharacter++;
}
@@ -401,28 +403,23 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf122430)
CPPUNIT_TEST_FIXTURE(Test, testFdo49892)
{
load(mpTestDocumentPath, "fdo49892.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(5, nShapes);
+ for (int i = 0; i < nShapes; ++i)
{
- OUString aDescription = getProperty<OUString>(xDraws->getByIndex(i), "Description");
+ OUString aDescription = getProperty<OUString>(getShape(i + 1), "Description");
if (aDescription == "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 (aDescription == "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 (aDescription == "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"));
else if (aDescription == "rect")
{
- CPPUNIT_ASSERT_EQUAL(
- text::RelOrientation::PAGE_FRAME,
- getProperty<sal_Int16>(xDraws->getByIndex(i), "HoriOrientRelation"));
- CPPUNIT_ASSERT_EQUAL(
- text::RelOrientation::PAGE_FRAME,
- getProperty<sal_Int16>(xDraws->getByIndex(i), "VertOrientRelation"));
+ CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME,
+ getProperty<sal_Int16>(getShape(i + 1), "HoriOrientRelation"));
+ CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME,
+ getProperty<sal_Int16>(getShape(i + 1), "VertOrientRelation"));
}
}
}
@@ -512,10 +509,8 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo57708)
load(mpTestDocumentPath, "fdo57708.rtf");
// There were two issues: the doc was of 2 pages and the picture was missing.
CPPUNIT_ASSERT_EQUAL(1, getPages());
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
// Two objects: a picture and a textframe.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(2, getShapes());
}
CPPUNIT_TEST_FIXTURE(Test, testFdo45183)
@@ -687,22 +682,18 @@ CPPUNIT_TEST_FIXTURE(Test, testN823675)
CPPUNIT_TEST_FIXTURE(Test, testGroupshape)
{
load(mpTestDocumentPath, "groupshape.rtf");
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
// There should be a single groupshape with 2 children.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
- uno::Reference<drawing::XShapes> xGroupshape(xDraws->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
+ uno::Reference<drawing::XShapes> xGroupshape(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape->getCount());
}
CPPUNIT_TEST_FIXTURE(Test, testGroupshape_notext)
{
load(mpTestDocumentPath, "groupshape-notext.rtf");
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
// There should be a single groupshape with 2 children.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
- uno::Reference<drawing::XShapes> xGroupshape(xDraws->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
+ uno::Reference<drawing::XShapes> xGroupshape(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape->getCount());
}
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index f5c4344a1e8f..cfbc9a5ebe3f 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -665,10 +665,8 @@ void SwUiWriterTest::testRedlineFrame(char const*const file)
SwDoc * pDoc(createDoc(file));
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
// there is exactly one frame
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
RedlineFlags nMode = pWrtShell->GetRedlineFlags();
CPPUNIT_ASSERT(nMode & RedlineFlags::ShowDelete);
@@ -677,12 +675,12 @@ void SwUiWriterTest::testRedlineFrame(char const*const file)
pWrtShell->SetRedlineFlags(nMode & ~RedlineFlags::ShowDelete);
// there is still exactly one frame
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
pWrtShell->SetRedlineFlags(nMode); // show again
// there is still exactly one frame
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
}
void SwUiWriterTest::testRedlineFrameAtCharStartOutside0()
@@ -1573,10 +1571,8 @@ void SwUiWriterTest::testFdo85554()
// Save it and load it back.
reload("writer8", "fdo85554.odt");
- xDrawPageSupplier.set(mxComponent, uno::UNO_QUERY);
- xDrawPage = xDrawPageSupplier->getDrawPage();
// This was 1, we lost a shape on export.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(2, getShapes());
}
void SwUiWriterTest::testAutoCorr()
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 086a9122ba98..13e53234b445 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -1596,9 +1596,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testDocxAttributeTableExport)
// get the table frame, set new values and dismiss the references
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
- uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY);
// change the properties
// 8133 -> 8000
@@ -1613,9 +1611,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testDocxAttributeTableExport)
// save it to docx
reload("Office Open XML Text", "floating-table-position.docx");
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
- uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY);
// test the new values
sal_Int32 nValue = getProperty<sal_Int32>(xShape, "VertOrientPosition");
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index c60d5f9db739..ec33238f407e 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -33,25 +33,22 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf129382)
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pTextDoc);
- 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());
CPPUNIT_ASSERT_EQUAL(2, getPages());
dispatchCommand(mxComponent, ".uno:SelectAll", {});
dispatchCommand(mxComponent, ".uno:Cut", {});
- CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(3, getShapes());
CPPUNIT_ASSERT_EQUAL(1, getPages());
dispatchCommand(mxComponent, ".uno:Paste", {});
- CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(8, getShapes());
CPPUNIT_ASSERT_EQUAL(2, getPages());
dispatchCommand(mxComponent, ".uno:Undo", {});
- CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(3, getShapes());
CPPUNIT_ASSERT_EQUAL(1, getPages());
// without the fix, it crashes
dispatchCommand(mxComponent, ".uno:Undo", {});
- CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(8, getShapes());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf126626)
@@ -61,23 +58,20 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf126626)
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pTextDoc);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
-
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(2, getShapes());
dispatchCommand(mxComponent, ".uno:SelectAll", {});
dispatchCommand(mxComponent, ".uno:Copy", {});
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(2, getShapes());
dispatchCommand(mxComponent, ".uno:Paste", {});
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(2, getShapes());
dispatchCommand(mxComponent, ".uno:Paste", {});
- CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(4, getShapes());
dispatchCommand(mxComponent, ".uno:Undo", {});
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(2, getShapes());
// without the fix, it crashes
dispatchCommand(mxComponent, ".uno:Paste", {});
- CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(4, getShapes());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132187)
diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx
index 6e67892a027f..691d385d6de7 100644
--- a/sw/qa/extras/unowriter/unowriter.cxx
+++ b/sw/qa/extras/unowriter/unowriter.cxx
@@ -478,10 +478,8 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testDeleteFlyAtCharAtStart)
CPPUNIT_ASSERT(rIDCO.InsertGraphicObject(*pWrtShell->GetCursor(), grf, &frameSet, &grfSet));
// check fly
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
- uno::Reference<text::XTextContent> const xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
+ uno::Reference<text::XTextContent> const xShape(getShape(1), uno::UNO_QUERY);
// anchored at start of body text?
uno::Reference<text::XText> const xText(pTextDoc->getText());
uno::Reference<text::XTextRangeCompare> const xTextRC(xText, uno::UNO_QUERY);
@@ -494,7 +492,7 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testDeleteFlyAtCharAtStart)
xCursor->setString("");
// there is exactly one fly
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
// select entire body text
xCursor->gotoStart(true);
@@ -502,7 +500,7 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testDeleteFlyAtCharAtStart)
xCursor->setString("");
// there is no fly
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(0, getShapes());
}
CPPUNIT_TEST_FIXTURE(SwUnoWriter, testSelectionInTableEnum)
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index 3324061edb5c..bc4819c15ddb 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -309,10 +309,8 @@ DECLARE_WW8EXPORT_TEST(testTdf99197_defaultLTR, "tdf99197_defaultLTR.doc")
DECLARE_WW8EXPORT_TEST(testTdf107773, "tdf107773.doc")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
// This was 1, multi-page table was imported as a floating one.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(0, getShapes());
// tdf#80635 - transfer the float orientation to the table.
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 1313eff345aa..dfbd496a31df 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -211,10 +211,8 @@ DECLARE_WW8IMPORT_TEST(testTdf106799, "tdf106799.doc")
DECLARE_WW8IMPORT_TEST(testTdf112346, "tdf112346.doc")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
// This was 1, multi-page table was imported as a floating one.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(0, getShapes());
}
DECLARE_WW8IMPORT_TEST(testTdf121734, "tdf121734.doc")
@@ -326,13 +324,11 @@ DECLARE_WW8IMPORT_TEST(testTdf122425_1, "tdf122425_1.doc")
DECLARE_WW8IMPORT_TEST(testTdf79639, "tdf79639.doc")
{
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 1
// - Actual : 0
// as the floating table in the header wasn't converted to a TextFrame.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xDrawPage->getCount());
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
}
DECLARE_WW8IMPORT_TEST(testTdf122425_2, "tdf122425_2.doc")
diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx
index a7be42da2bd4..c6cbf9f83afe 100644
--- a/sw/qa/inc/swmodeltestbase.hxx
+++ b/sw/qa/inc/swmodeltestbase.hxx
@@ -912,6 +912,14 @@ protected:
return xCursor->getPage();
}
+ /// Get shape count.
+ int getShapes() const
+ {
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
+ return xDraws->getCount();
+ }
+
/**
* Given that some problem doesn't affect the result in the importer, we
* test the resulting file directly, by opening the zip file, parsing an