diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2018-02-12 15:32:15 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2018-03-06 15:49:10 +0100 |
commit | 782d504649ccb2dbe1a55d7abdf5c532b62f5c39 (patch) | |
tree | df359cb23198a6c3f6afd3b3e861355af06caa0f /sc | |
parent | acf0bad4e2b8c3c43aaaee8312c8a61d3552fcc2 (diff) |
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@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/extras/anchor.cxx | 46 | ||||
-rw-r--r-- | sc/qa/unit/data/ods/3AnchorTypes.ods | bin | 0 -> 79920 bytes |
2 files changed, 46 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 000000000000..a68c36271595 --- /dev/null +++ b/sc/qa/unit/data/ods/3AnchorTypes.ods |