[Libreoffice-commits] core.git: sc/qa

Samuel Mehrbrodt Samuel.Mehrbrodt at cib.de
Tue Mar 6 14:49:33 UTC 2018


 sc/qa/extras/anchor.cxx              |   46 +++++++++++++++++++++++++++++++++++
 sc/qa/unit/data/ods/3AnchorTypes.ods |binary
 2 files changed, 46 insertions(+)

New commits:
commit 782d504649ccb2dbe1a55d7abdf5c532b62f5c39
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Mon Feb 12 15:32:15 2018 +0100

    tdf#114552 Add unit test for ODF Import of anchor types
    
    Change-Id: I7b6e013de5b37c8da0adf5be8e66472e76d81375
    Reviewed-on: https://gerrit.libreoffice.org/49602
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/sc/qa/extras/anchor.cxx b/sc/qa/extras/anchor.cxx
index 5d79caad7df9..dc0a8942b9dd 100644
--- a/sc/qa/extras/anchor.cxx
+++ b/sc/qa/extras/anchor.cxx
@@ -38,10 +38,12 @@ public:
 
     void testUndoAnchor();
     void testTdf76183();
+    void testODFAnchorTypes();
 
     CPPUNIT_TEST_SUITE(ScAnchorTest);
     CPPUNIT_TEST(testUndoAnchor);
     CPPUNIT_TEST(testTdf76183);
+    CPPUNIT_TEST(testODFAnchorTypes);
     CPPUNIT_TEST_SUITE_END();
 private:
 
@@ -187,6 +189,50 @@ void ScAnchorTest::testTdf76183()
     pDocSh->DoClose();
 }
 
+void ScAnchorTest::testODFAnchorTypes()
+{
+    OUString aFileURL;
+    createFileURL("3AnchorTypes.ods", aFileURL);
+    // open the document with graphic included
+    uno::Reference< css::lang::XComponent > xComponent = loadFromDesktop(aFileURL);
+    CPPUNIT_ASSERT(xComponent.is());
+
+    // Get the document model
+    SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
+    CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
+
+    ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
+    CPPUNIT_ASSERT(pDocSh);
+
+    // Check whether graphic imported well
+    ScDocument& rDoc = pDocSh->GetDocument();
+    ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
+    CPPUNIT_ASSERT(pDrawLayer);
+
+    const SdrPage *pPage = pDrawLayer->GetPage(0);
+    CPPUNIT_ASSERT(pPage);
+
+    // Check 1st object: Page anchored
+    SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(0));
+    CPPUNIT_ASSERT(pObject);
+    ScAnchorType anchorType = ScDrawLayer::GetAnchorType(*pObject);
+    CPPUNIT_ASSERT_EQUAL(SCA_PAGE, anchorType);
+
+    // Check 2nd object: Cell anchored, resize with cell
+    pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(1));
+    CPPUNIT_ASSERT(pObject);
+    anchorType = ScDrawLayer::GetAnchorType(*pObject);
+    CPPUNIT_ASSERT_EQUAL(SCA_CELL_RESIZE, anchorType);
+
+     // Check 3rd object: Cell anchored
+    pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2));
+    CPPUNIT_ASSERT(pObject);
+    anchorType = ScDrawLayer::GetAnchorType(*pObject);
+    CPPUNIT_ASSERT_EQUAL(SCA_CELL, anchorType);
+
+    pDocSh->DoClose();
+}
+
 void ScAnchorTest::tearDown()
 {
     if (mxComponent.is())
diff --git a/sc/qa/unit/data/ods/3AnchorTypes.ods b/sc/qa/unit/data/ods/3AnchorTypes.ods
new file mode 100644
index 000000000000..a68c36271595
Binary files /dev/null and b/sc/qa/unit/data/ods/3AnchorTypes.ods differ


More information about the Libreoffice-commits mailing list