summaryrefslogtreecommitdiff
path: root/sd/qa
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2015-11-11 14:06:31 +0100
committerKatarina Behrens <Katarina.Behrens@cib.de>2015-11-17 10:30:08 +0000
commit927019f5d253a12d285f68a5f0240548d2048def (patch)
treeecda7a7209f3bf4ea33254ab06e46af20b49213e /sd/qa
parent6c217cfe6ebba1f6cd62f47693210075e0dadf58 (diff)
tdf#94272: Reduce copy'n'pasta code in sd unit tests
Change-Id: Id1a1180e00a1c1ce7020df52f246b0c135ba03f2 Reviewed-on: https://gerrit.libreoffice.org/19912 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'sd/qa')
-rw-r--r--sd/qa/unit/export-tests.cxx252
-rw-r--r--sd/qa/unit/import-tests.cxx222
-rw-r--r--sd/qa/unit/sdmodeltestbase.hxx74
3 files changed, 162 insertions, 386 deletions
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index ba6c3092d3f7..02e42e710a25 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -194,8 +194,7 @@ void SdExportTest::testN821567()
uno::Reference< drawing::XDrawPagesSupplier > xDoc(
xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
CPPUNIT_ASSERT_MESSAGE( "not exactly one page", xDoc->getDrawPages()->getCount() == 1 );
- uno::Reference< drawing::XDrawPage > xPage(
- xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XDrawPage > xPage( getPage( 0, xDocShRef ) );
uno::Reference< beans::XPropertySet > xPropSet( xPage, uno::UNO_QUERY );
uno::Any aAny = xPropSet->getPropertyValue( "Background" );
@@ -237,10 +236,7 @@ void SdExportTest::testBnc870233_1()
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_1.pptx"), PPTX);
xDocShRef = saveAndReload( xDocShRef, PPTX );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage (1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
// The problem was all shapes had the same font (the last parsed font attribues overwrote all previous ones)
@@ -266,10 +262,7 @@ void SdExportTest::testBnc870233_2()
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_2.pptx"), PPTX);
xDocShRef = saveAndReload( xDocShRef, PPTX );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage (1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
// The problem was in some SmartArts font color was wrong
@@ -301,10 +294,7 @@ void SdExportTest::testN828390_4()
xDocShRef = saveAndReload( xDocShRef, PPTX );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
{
std::vector<EECharAttrib> rLst;
SdrObject *pObj = pPage->GetObj(0);
@@ -339,10 +329,7 @@ void SdExportTest::testN828390_5()
xDocShRef = saveAndReload( xDocShRef, PPTX );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
{
SdrObject *pObj = pPage->GetObj(0);
SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
@@ -361,10 +348,7 @@ void SdExportTest::testTransparentBackground()
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/transparent_background.odp"), ODP);
xDocShRef = saveAndReload( xDocShRef, ODP );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage (1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
const SdrTextObj *pObj1 = dynamic_cast<SdrTextObj *>( pPage->GetObj( 0 ) );
checkFontAttributes<Color, SvxBackgroundColorItem>( pObj1, Color(COL_TRANSPARENT) );
@@ -381,10 +365,7 @@ void SdExportTest::testMediaEmbedding()
xDocShRef = saveAndReload( xDocShRef, ODP );
#endif
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage (1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
#if HAVE_FEATURE_GLTF
// First object is a glTF model
@@ -414,10 +395,7 @@ void SdExportTest::testFdo84043()
xDocShRef = saveAndReload( xDocShRef, ODP );
// the bug was duplicate attributes, causing crash in a build with asserts
- SdDrawDocument const* pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE("no document", pDoc != nullptr);
- SdrPage const* pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE("no page", pPage != nullptr);
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
SdrObject const* pShape = pPage->GetObj(1);
CPPUNIT_ASSERT_MESSAGE("no shape", pShape != nullptr);
}
@@ -427,11 +405,7 @@ void SdExportTest::testFdo71961()
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo71961.odp"), ODP);
xDocShRef = saveAndReload( xDocShRef, PPTX );
-
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage (1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
// Export to .pptx changes all text frames to custom shape objects, which obey TextWordWrap property
// (which is false for text frames otherwise and is ignored). Check that frames that should wrap still do.
@@ -460,10 +434,7 @@ void SdExportTest::testN828390()
xDocShRef = saveAndReload( xDocShRef, PPTX );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
{
std::vector<EECharAttrib> rLst;
// Get the object
@@ -495,10 +466,7 @@ void SdExportTest::testBnc880763()
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc880763.pptx"), PPTX);
xDocShRef = saveAndReload( xDocShRef, PPTX );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage (1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
// Check z-order of the two shapes, use background color to identify them
// First object in the background has blue background color
@@ -519,10 +487,7 @@ void SdExportTest::testBnc862510_5()
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_5.pptx"), PPTX);
xDocShRef = saveAndReload( xDocShRef, PPTX );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage (1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
// Same as testBnc870237, but here we check the horizontal spacing
const SdrObject* pObj = dynamic_cast<SdrObject*>( pPage->GetObj( 1 ) );
@@ -572,16 +537,7 @@ void SdExportTest::testFdo90607()
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo90607.pptx"), PPTX);
xDocShRef = saveAndReload(xDocShRef, PPTX);
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(
- xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
-
- uno::Reference< drawing::XDrawPage > xPage(
- xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
-
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(1) );
CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
OutlinerParaObject* pOutlinerParagraphObject = pTxtObj->GetOutlinerParaObject();
@@ -860,10 +816,7 @@ void SdExportTest::testTableCellFillProperties()
xComponent->dispose();
xDocShRef = loadURL(aTempFile.GetURL(), PPTX);
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
CPPUNIT_ASSERT( pTableObj );
@@ -895,16 +848,7 @@ void SdExportTest::testBulletStartNumber()
::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n90255.pptx"), PPTX );
xDocShRef = saveAndReload( xDocShRef, PPTX );
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(
- xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
-
- uno::Reference< drawing::XDrawPage > xPage(
- xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
-
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(0) );
CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
@@ -919,10 +863,7 @@ void SdExportTest::testLineStyle()
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("sd/qa/unit/data/pptx/lineStyle.pptx"), PPTX);
xDocShRef = saveAndReload( xDocShRef, PPTX );
- SdDrawDocument const* pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE("no document", pDoc != nullptr);
- SdrPage const* pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE("no page", pPage != nullptr);
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
SdrObject const* pShape = pPage->GetObj(0);
CPPUNIT_ASSERT_MESSAGE("no shape", pShape != nullptr);
@@ -935,28 +876,13 @@ void SdExportTest::testLineStyle()
void SdExportTest::testRightToLeftParaghraph()
{
- ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/rightToLeftParagraph.pptx"), PPTX);
+ ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/rightToLeftParagraph.pptx"), PPTX);
xDocShRef = saveAndReload( xDocShRef, PPTX );
-
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(
- xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
-
- uno::Reference< drawing::XDrawPage > xPage(
- xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
-
- uno::Reference< beans::XPropertySet > xShape(
- xPage->getByIndex(0), uno::UNO_QUERY );
- CPPUNIT_ASSERT_MESSAGE( "no shape", xShape.is() );
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
// Get first paragraph
- uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
- CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
- uno::Reference<container::XEnumerationAccess> paraEnumAccess;
- paraEnumAccess.set(xText, uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
- uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(),
- uno::UNO_QUERY_THROW);
+ uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
sal_Int16 nWritingMode = 0;
@@ -971,31 +897,13 @@ void SdExportTest::testTextboxWithHyperlink()
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/hyperlinktest.pptx"), PPTX);
xDocShRef = saveAndReload( xDocShRef, PPTX );
-
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(
- xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
-
- uno::Reference< drawing::XDrawPage > xPage(
- xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
-
- uno::Reference< beans::XPropertySet > xShape(
- xPage->getByIndex(0), uno::UNO_QUERY );
- CPPUNIT_ASSERT_MESSAGE( "no shape", xShape.is() );
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
// Get first paragraph
- uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
- CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
- uno::Reference<container::XEnumerationAccess> paraEnumAccess;
- paraEnumAccess.set(xText, uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
- uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(),
- uno::UNO_QUERY_THROW);
+ uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
// first chunk of text
- // FIXME: those should really be some convenience function (getShape, getParagraph, getRun etc.)
- uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
- uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRun( getRunFromParagraph( 0, xParagraph ) );
uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
uno::Reference<text::XTextField> xField;
@@ -1016,16 +924,7 @@ void SdExportTest::testBulletColor()
xDocShRef = saveAndReload( xDocShRef, PPTX );
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(
- xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
-
- uno::Reference< drawing::XDrawPage > xPage(
- xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
-
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(0) );
CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
@@ -1039,11 +938,12 @@ void SdExportTest::testBulletColor()
void SdExportTest::testTdf62176()
{
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/Tdf62176.odp"), ODP);
- uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
- uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xPage( getPage( 0, xDocShRef ) );
+
//there should be only *one* shape
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xPage->getCount());
- uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY);
+
+ uno::Reference<beans::XPropertySet> xShape( getShape( 0, xPage ) );
//checking Paragraph's Left Margin with expected value
sal_Int32 nParaLeftMargin = 0;
xShape->getPropertyValue("ParaLeftMargin") >>= nParaLeftMargin;
@@ -1052,19 +952,18 @@ void SdExportTest::testTdf62176()
sal_Int32 nParaFirstLineIndent = 0;
xShape->getPropertyValue("ParaFirstLineIndent") >>= nParaFirstLineIndent;
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1300), nParaFirstLineIndent);
+
//Checking the *Text* in TextBox
- uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
- uno::Reference<container::XEnumerationAccess> paraEnumAccess(xText, uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> paraEnum(paraEnumAccess->createEnumeration());
- uno::Reference<text::XTextRange> xParagraph(paraEnum->nextElement(), uno::UNO_QUERY_THROW);
+ uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) );
CPPUNIT_ASSERT_EQUAL(OUString("Hello World"), xParagraph->getString());
+
//Saving and Reloading the file
xDocShRef = saveAndReload(xDocShRef, ODP);
- uno::Reference<drawing::XDrawPagesSupplier> xDoc2(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
- uno::Reference<drawing::XDrawPage> xPage2(xDoc2->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xPage2( getPage(0, xDocShRef ) );
//there should be only *one* shape
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xPage2->getCount());
- uno::Reference<beans::XPropertySet> xShape2(xPage2->getByIndex(0), uno::UNO_QUERY);
+
+ uno::Reference<beans::XPropertySet> xShape2( getShape( 0, xPage2 ) );
//checking Paragraph's Left Margin with expected value
sal_Int32 nParaLeftMargin2 = 0;
xShape2->getPropertyValue("ParaLeftMargin") >>= nParaLeftMargin2;
@@ -1073,26 +972,21 @@ void SdExportTest::testTdf62176()
sal_Int32 nParaFirstLineIndent2 = 0;
xShape2->getPropertyValue("ParaFirstLineIndent") >>= nParaFirstLineIndent2;
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1300), nParaFirstLineIndent2);
+
//Checking the *Text* in TextBox
- uno::Reference<text::XText> xText2 = uno::Reference<text::XTextRange>(xShape2, uno::UNO_QUERY)->getText();
- uno::Reference<container::XEnumerationAccess> paraEnumAccess2(xText2, uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> paraEnum2(paraEnumAccess2->createEnumeration());
- uno::Reference<text::XTextRange> xParagraph2(paraEnum2->nextElement(), uno::UNO_QUERY_THROW);
+ uno::Reference<text::XTextRange> xParagraph2( getParagraphFromShape( 0, xShape2 ) );
CPPUNIT_ASSERT_EQUAL(OUString("Hello World"), xParagraph2->getString());
}
+
void SdExportTest::testBulletCharAndFont()
{
::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/odp/bulletCharAndFont.odp"), ODP);
xDocShRef = saveAndReload( xDocShRef, PPTX );
- uno::Reference< drawing::XDrawPagesSupplier > xDoc( xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
- uno::Reference< drawing::XDrawPage > xPage( xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
- uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY);
- uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
- uno::Reference<container::XEnumerationAccess> paraEnumAccess;
- paraEnumAccess.set(xText, uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
- uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(), uno::UNO_QUERY_THROW);
+
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
+ uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
+
uno::Reference<container::XIndexAccess> xLevels(xPropSet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
uno::Sequence<beans::PropertyValue> aProps;
xLevels->getByIndex(0) >>= aProps; // 1st level
@@ -1142,10 +1036,7 @@ void SdExportTest::testBnc822341()
// Export an LO specific ole object (imported from an ODP document)
{
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
const SdrObject* pObj = dynamic_cast<SdrObject*>( pPage->GetObj(0) );
CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr);
@@ -1174,18 +1065,9 @@ void SdExportTest::testBnc822341()
void SdExportTest::testBulletMarginAndIndentation()
{
::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/bulletMarginAndIndent.pptx"), PPTX );
-
xDocShRef = saveAndReload( xDocShRef, PPTX );
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(
- xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
- uno::Reference< drawing::XDrawPage > xPage(
- xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
-
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(0) );
CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
@@ -1203,25 +1085,10 @@ void SdExportTest::testParaMarginAndindentation()
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/paraMarginAndIndentation.pptx"), PPTX);
xDocShRef = saveAndReload( xDocShRef, PPTX );
-
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(
- xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
-
- uno::Reference< drawing::XDrawPage > xPage(
- xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
-
- uno::Reference< beans::XPropertySet > xShape(
- xPage->getByIndex(0), uno::UNO_QUERY );
- CPPUNIT_ASSERT_MESSAGE( "no shape", xShape.is() );
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
// Get first paragraph
- uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
- CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
- uno::Reference<container::XEnumerationAccess> paraEnumAccess;
- paraEnumAccess.set(xText, uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
- uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(),
- uno::UNO_QUERY_THROW);
+ uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
sal_Int32 nParaLeftMargin = 0;
@@ -1241,15 +1108,7 @@ void SdExportTest::testCellLeftAndRightMargin()
xDocShRef = saveAndReload( xDocShRef, PPTX );
sal_Int32 nLeftMargin, nRightMargin;
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(
- xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
-
- uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
-
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
CPPUNIT_ASSERT( pTableObj );
@@ -1279,14 +1138,7 @@ void SdExportTest::testTableCellBorder()
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("sd/qa/unit/data/pptx/n90190.pptx"), PPTX);
xDocShRef = saveAndReload( xDocShRef, PPTX );
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
-
- uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
-
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
CPPUNIT_ASSERT( pTableObj );
@@ -1335,15 +1187,11 @@ void SdExportTest::testTdf80224()
{
::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/odp/tdf80224.odp"), ODP);
xDocShRef = saveAndReload( xDocShRef, PPTX );
- uno::Reference< drawing::XDrawPagesSupplier > xDoc( xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
- uno::Reference< drawing::XDrawPage > xPage( xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
- uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY);
- uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
- uno::Reference<container::XEnumerationAccess> paraEnumAccess;
- paraEnumAccess.set(xText, uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
- uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(), uno::UNO_QUERY_THROW);
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
+
+ uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
uno::Reference< beans::XPropertySet > xPropSet( xParagraph->getStart(), uno::UNO_QUERY_THROW );
+
sal_Int32 nCharColor;
xPropSet->getPropertyValue("CharColor") >>= nCharColor;
CPPUNIT_ASSERT_EQUAL(sal_Int32(6644396), nCharColor);
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index e1e7262e9537..c7f0ff502622 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -247,10 +247,7 @@ void SdImportTest::testN759180()
{
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/n759180.pptx"), PPTX);
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage (1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
//sal_uIntPtr nObjs = pPage->GetObjCount();
//for (sal_uIntPtr i = 0; i < nObjs; i++)
@@ -285,10 +282,7 @@ void SdImportTest::testN862510_1()
{
sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_1.pptx"), PPTX );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
{
std::vector<EECharAttrib> rLst;
SdrObject *pObj = pPage->GetObj( 0 );
@@ -310,10 +304,7 @@ void SdImportTest::testN862510_2()
{
sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_2.pptx"), PPTX );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
{
SdrObjGroup *pGrpObj = dynamic_cast<SdrObjGroup *>( pPage->GetObj( 0 ) );
CPPUNIT_ASSERT( pGrpObj );
@@ -329,10 +320,7 @@ void SdImportTest::testN862510_4()
{
sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_4.pptx"), PPTX );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage( 1 );
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
{
std::vector<EECharAttrib> rLst;
SdrObject *pObj = pPage->GetObj( 0 );
@@ -353,11 +341,7 @@ void SdImportTest::testN862510_4()
void SdImportTest::testN828390_2()
{
sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390_2.pptx"), PPTX );
-
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
SdrObject *pObj = pPage->GetObj(0);
SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
@@ -373,11 +357,7 @@ void SdImportTest::testN828390_3()
{
bool bPassed = true;
sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390_3.pptx"), PPTX );
-
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
SdrObject *pObj = pPage->GetObj(0);
SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
@@ -405,11 +385,8 @@ void SdImportTest::testN828390_3()
void SdImportTest::testMasterPageStyleParent()
{
sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/odp/masterpage_style_parent.odp"), ODP );
-
SdDrawDocument *pDoc = xDocShRef->GetDoc();
CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
SdStyleSheetPool *const pPool(pDoc->GetSdStyleSheetPool());
@@ -501,10 +478,7 @@ void SdImportTest::testN778859()
{
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/n778859.pptx"), PPTX);
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
{
// Get the object
SdrObject *pObj = pPage->GetObj(1);
@@ -520,10 +494,7 @@ void SdImportTest::testFdo68594()
{
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/ppt/fdo68594.ppt"), PPT);
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = &(pDoc->GetPage (1)->TRG_GetMasterPage());
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = &(GetPage( 1, xDocShRef )->TRG_GetMasterPage());
SdrObject *pObj = pPage->GetObj(1);
SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
@@ -539,10 +510,7 @@ void SdImportTest::testFdo72998()
{
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/cshapes.pptx"), PPTX);
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
{
SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>(pPage->GetObj(2));
CPPUNIT_ASSERT( pObj );
@@ -569,10 +537,7 @@ void SdImportTest::testFdo77027()
{
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/fdo77027.odp"), ODP);
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
{
SdrOle2Obj *const pObj = dynamic_cast<SdrOle2Obj*>(pPage->GetObj(0));
CPPUNIT_ASSERT(pObj);
@@ -638,16 +603,9 @@ void SdImportTest::testFdo71075()
css::uno::Any aAny;
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo71075.odp"), ODP);
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
- uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
- uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
- CPPUNIT_ASSERT_MESSAGE( "failed to load shape", xShape.is() );
-
- uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
- aAny = xPropSet->getPropertyValue( "Model" );
- CPPUNIT_ASSERT_MESSAGE( "failed to load shape", aAny.hasValue() );
+ uno::Reference< beans::XPropertySet > xPropSet( getShapeFromPage( 0, 0, xDocShRef ) );
+ aAny = xPropSet->getPropertyValue( OUString("Model") );
+ CPPUNIT_ASSERT_MESSAGE( "The shape doesn't have the property", aAny.hasValue() );
uno::Reference< chart::XChartDocument > xChartDoc;
aAny >>= xChartDoc;
@@ -682,10 +640,7 @@ void SdImportTest::testStrictOOXML()
SdDrawDocument *pDoc = xDocShRef->GetDoc();
CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
- uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
- uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
- CPPUNIT_ASSERT_MESSAGE( "failed to load shape", xShape.is() );
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
xDocShRef->DoClose();
}
@@ -693,11 +648,7 @@ void SdImportTest::testStrictOOXML()
void SdImportTest::testBnc870237()
{
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870237.pptx"), PPTX);
-
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage (1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
// Simulate a:ext inside dsp:txXfrm with changing the lower distance
const SdrObjGroup* pObj = dynamic_cast<SdrObjGroup*>( pPage->GetObj( 0 ) );
@@ -729,10 +680,7 @@ void SdImportTest::testBnc887225()
// In the document, lastRow and lastCol table properties are used.
// Make sure styles are set properly for individual cells.
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(2));
CPPUNIT_ASSERT( pTableObj );
@@ -780,10 +728,7 @@ void SdImportTest::testBnc480256()
// TODO: If you are working on improving table background support, expect
// this unit test to fail. In that case, feel free to change the numbers.
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
sdr::table::SdrTableObj *pTableObj;
uno::Reference< table::XCellRange > xTable;
@@ -834,10 +779,7 @@ void SdImportTest::testBnc584721_1()
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_1_2.pptx"), PPTX);
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = &(pDoc->GetPage (1)->TRG_GetMasterPage());
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = &(GetPage( 1, xDocShRef )->TRG_GetMasterPage());
SdrObject *pObj = pPage->GetObj(0);
SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
@@ -852,10 +794,7 @@ void SdImportTest::testBnc584721_2()
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_1_2.pptx"), PPTX);
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = &(pDoc->GetPage(1)->TRG_GetMasterPage());
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = &(GetPage( 1, xDocShRef )->TRG_GetMasterPage());
CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount());
xDocShRef->DoClose();
@@ -868,10 +807,7 @@ void SdImportTest::testBnc584721_3()
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_3.pptx"), PPTX);
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = &(pDoc->GetPage(1)->TRG_GetMasterPage());
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = &(GetPage( 1, xDocShRef )->TRG_GetMasterPage());
SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(1) );
CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
@@ -900,8 +836,8 @@ void SdImportTest::testBnc591147()
xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
CPPUNIT_ASSERT_EQUAL( sal_Int32(1), xPage->getCount() );
- uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
- uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY_THROW );
+ //uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xPropSet( getShape( 0, xPage ) );
OUString sVideoURL("emptyURL");
bool bSucess = xPropSet->getPropertyValue("MediaURL") >>= sVideoURL;
CPPUNIT_ASSERT_MESSAGE( "MediaURL property is not set", bSucess );
@@ -911,8 +847,7 @@ void SdImportTest::testBnc591147()
xPage.set( xDoc->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW );
CPPUNIT_ASSERT_EQUAL( sal_Int32(1), xPage->getCount() );
- xShape.set( xPage->getByIndex(0), uno::UNO_QUERY_THROW );
- xPropSet.set( xShape, uno::UNO_QUERY_THROW );
+ xPropSet.set( getShape( 0, xPage ) );
OUString sAudioURL("emptyURL");
bSucess = xPropSet->getPropertyValue("MediaURL") >>= sAudioURL;
CPPUNIT_ASSERT_MESSAGE( "MediaURL property is not set", bSucess );
@@ -928,30 +863,13 @@ void SdImportTest::testBnc584721_4()
// Black text was imported as white because of wrong caching mechanism
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_4.pptx"), PPTX);
-
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(
- xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
-
- uno::Reference< drawing::XDrawPage > xPage(
- xDoc->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW );
-
- uno::Reference< beans::XPropertySet > xShape(
- xPage->getByIndex(1), uno::UNO_QUERY );
- CPPUNIT_ASSERT_MESSAGE( "no text shape", xShape.is() );
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 1, 1, xDocShRef ) );
// Get first paragraph of the text
- uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
- CPPUNIT_ASSERT_MESSAGE( "no text shape", xText.is() );
- uno::Reference<container::XEnumerationAccess> paraEnumAccess;
- paraEnumAccess.set(xText, uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
- uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(),
- uno::UNO_QUERY_THROW);
+ uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
// Get first run of the paragraph
- uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
- uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRun( getRunFromParagraph (0, xParagraph ) );
uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
sal_Int32 nCharColor;
xPropSet->getPropertyValue( "CharColor" ) >>= nCharColor;
@@ -968,11 +886,7 @@ void SdImportTest::testBnc904423()
// Right order: 1) master slide fill style, 2) theme, 3) direct formatting
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("sd/qa/unit/data/pptx/bnc904423.pptx"), PPTX);
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
-
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
// First shape's background color is defined on master slide
{
SdrObject *const pObj = pPage->GetObj(0);
@@ -1021,11 +935,7 @@ void SdImportTest::testShapeLineStyle()
// Right order: 1) master slide line style, 2) theme, 3) direct formatting
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("sd/qa/unit/data/pptx/ShapeLineProperties.pptx"), PPTX);
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
-
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
// First shape's line style is defined on master slide
{
SdrObject *const pObj = pPage->GetObj(0);
@@ -1087,30 +997,13 @@ void SdImportTest::testBnc862510_6()
{
// Black text was imported instead of gray
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_6.pptx"), PPTX);
-
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(
- xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
-
- uno::Reference< drawing::XDrawPage > xPage(
- xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
-
- uno::Reference< beans::XPropertySet > xShape(
- xPage->getByIndex(0), uno::UNO_QUERY );
- CPPUNIT_ASSERT_MESSAGE( "no shape", xShape.is() );
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
// Get first paragraph of the text
- uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
- CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
- uno::Reference<container::XEnumerationAccess> paraEnumAccess;
- paraEnumAccess.set(xText, uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
- uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(),
- uno::UNO_QUERY_THROW);
+ uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
// Get first run of the paragraph
- uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
- uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRun( getRunFromParagraph( 0, xParagraph ) );
uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
sal_Int32 nCharColor;
xPropSet->getPropertyValue( "CharColor" ) >>= nCharColor;
@@ -1125,25 +1018,10 @@ void SdImportTest::testBnc862510_7()
{
// Title shape's text was aligned to left instead of center.
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_7.pptx"), PPTX);
-
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(
- xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
-
- uno::Reference< drawing::XDrawPage > xPage(
- xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
-
- uno::Reference< beans::XPropertySet > xShape(
- xPage->getByIndex(0), uno::UNO_QUERY );
- CPPUNIT_ASSERT_MESSAGE( "no shape", xShape.is() );
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
// Get first paragraph
- uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
- CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
- uno::Reference<container::XEnumerationAccess> paraEnumAccess;
- paraEnumAccess.set(xText, uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
- uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(),
- uno::UNO_QUERY_THROW);
+ uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
sal_Int16 nParaAdjust = 0;
@@ -1164,8 +1042,7 @@ void SdImportTest::testPDFImport()
uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
CPPUNIT_ASSERT_MESSAGE( "no exactly two shapes", xPage->getCount() == 2 );
- uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
- CPPUNIT_ASSERT_MESSAGE( "failed to load shape", xShape.is() );
+ uno::Reference< beans::XPropertySet > xShape( getShape( 0, xPage ) );
uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
@@ -1198,17 +1075,8 @@ void SdImportTest::testBulletSuffix()
{
sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n83889.pptx"), PPTX );
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(
- xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
-
- uno::Reference< drawing::XDrawPage > xPage(
- xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
-
// check suffix of the char bullet
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(0) );
CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
@@ -1222,11 +1090,7 @@ void SdImportTest::testBnc910045()
{
// Problem with table style which defines cell color with fill style
sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/bnc910045.pptx"), PPTX );
-
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
CPPUNIT_ASSERT( pTableObj );
@@ -1242,12 +1106,7 @@ void SdImportTest::testBnc910045()
void SdImportTest::testRowHeight()
{
sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n80340.pptx"), PPTX );
-
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
-
- const SdrPage *pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
CPPUNIT_ASSERT( pTableObj );
@@ -1265,12 +1124,7 @@ void SdImportTest::testTdf93830()
{
// Text shape offset was ignored
sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/tdf93830.pptx"), PPTX);
-
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(
- xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
-
- uno::Reference< drawing::XDrawPage > xPage(
- xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XDrawPage > xPage( getPage( 0, xDocShRef ) );
// Get the first text box from group shape
uno::Reference< container::XIndexAccess > xShape( xPage->getByIndex(0), uno::UNO_QUERY );
diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index 3bcd261f9c2f..d70f34b5d03a 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -247,6 +247,80 @@ protected:
}
xDocShRef->DoClose();
}
+
+ uno::Reference< drawing::XDrawPagesSupplier > getDoc( sd::DrawDocShellRef xDocShRef )
+ {
+ uno::Reference< drawing::XDrawPagesSupplier > xDoc (
+ xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
+ CPPUNIT_ASSERT_MESSAGE( "no document", xDoc.is() );
+ return xDoc;
+ }
+
+ uno::Reference< drawing::XDrawPage > getPage( int nPage, sd::DrawDocShellRef xDocShRef )
+ {
+ uno::Reference< drawing::XDrawPagesSupplier > xDoc( getDoc( xDocShRef ) );
+ uno::Reference< drawing::XDrawPage > xPage( xDoc->getDrawPages()->getByIndex( nPage ), uno::UNO_QUERY_THROW );
+ CPPUNIT_ASSERT_MESSAGE( "no page", xPage.is() );
+ return xPage;
+ }
+
+ // very confusing ... UNO index-based access to pages is 0-based. This one is 1-based
+ const SdrPage* GetPage( int nPage, sd::DrawDocShellRef xDocShRef )
+ {
+ SdDrawDocument* pDoc = xDocShRef->GetDoc() ;
+ CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+
+ const SdrPage* pPage = pDoc->GetPage( nPage );
+ CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
+ return pPage;
+ }
+
+ uno::Reference< beans::XPropertySet > getShape( int nShape, uno::Reference< drawing::XDrawPage > xPage )
+ {
+ uno::Reference< beans::XPropertySet > xShape( xPage->getByIndex( nShape ), uno::UNO_QUERY );
+ CPPUNIT_ASSERT_MESSAGE( "Failed to load shape", xShape.is() );
+ return xShape;
+ }
+
+ // Nth shape on Mth page
+ uno::Reference< beans::XPropertySet > getShapeFromPage( int nShape, int nPage, sd::DrawDocShellRef xDocShRef )
+ {
+ uno::Reference< drawing::XDrawPage > xPage ( getPage( nPage, xDocShRef ) );
+ uno::Reference< beans::XPropertySet > xShape( getShape( nShape, xPage ) );
+ CPPUNIT_ASSERT_MESSAGE( "Failed to load shape", xShape.is() );
+
+ return xShape;
+ }
+
+ // Nth paragraph of text in given text shape
+ uno::Reference< text::XTextRange > getParagraphFromShape( int nPara, uno::Reference< beans::XPropertySet > xShape )
+ {
+ uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>( xShape, uno::UNO_QUERY )->getText();
+ CPPUNIT_ASSERT_MESSAGE( "Not a text shape", xText.is() );
+
+ uno::Reference< container::XEnumerationAccess > paraEnumAccess( xText, uno::UNO_QUERY );
+ uno::Reference< container::XEnumeration > paraEnum( paraEnumAccess->createEnumeration() );
+
+ for ( int i = 0; i < nPara; ++i )
+ paraEnum->nextElement();
+
+ uno::Reference< text::XTextRange > xParagraph( paraEnum->nextElement(), uno::UNO_QUERY_THROW );
+
+ return xParagraph;
+ }
+
+ uno::Reference< text::XTextRange > getRunFromParagraph( int nRun, uno::Reference< text::XTextRange > xParagraph )
+ {
+ uno::Reference< container::XEnumerationAccess > runEnumAccess(xParagraph, uno::UNO_QUERY);
+ uno::Reference< container::XEnumeration > runEnum = runEnumAccess->createEnumeration();
+
+ for ( int i = 0; i < nRun; ++i )
+ runEnum->nextElement();
+
+ uno::Reference< text::XTextRange > xRun( runEnum->nextElement(), uno::UNO_QUERY);
+
+ return xRun;
+ }
};
#endif