sc/CppunitTest_sc_uicalc.mk | 2 + sc/qa/unit/uicalc/data/tdf130614.ods |binary sc/qa/unit/uicalc/uicalc.cxx | 46 +++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+)
New commits: commit 6bda2e11c553b4032a33b95dd89e762db23e60f3 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri Jan 22 14:13:04 2021 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Fri Jan 22 17:54:00 2021 +0100 tdf#130614, tdf#108887: sc_uicalc: Add unittest Change-Id: Ib0e7e1656dfb631e6cc8a897d376c783455483d6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109817 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/CppunitTest_sc_uicalc.mk b/sc/CppunitTest_sc_uicalc.mk index 15ab85a47dcd..4c1f99d87ddd 100644 --- a/sc/CppunitTest_sc_uicalc.mk +++ b/sc/CppunitTest_sc_uicalc.mk @@ -22,6 +22,8 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_uicalc, \ sal \ sc \ sfx \ + svx \ + svxcore \ test \ tl \ unotest \ diff --git a/sc/qa/unit/uicalc/data/tdf130614.ods b/sc/qa/unit/uicalc/data/tdf130614.ods new file mode 100644 index 000000000000..7f66dff55b98 Binary files /dev/null and b/sc/qa/unit/uicalc/data/tdf130614.ods differ diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 3b93128415ab..0c067c5d7e99 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -10,6 +10,7 @@ #include <test/bootstrapfixture.hxx> #include <unotest/macros_test.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <svx/svdpage.hxx> #include <vcl/keycodes.hxx> #include <vcl/scheduler.hxx> @@ -20,9 +21,11 @@ #include <document.hxx> #include <docuno.hxx> #include <docsh.hxx> +#include <drwlayer.hxx> #include <inputopt.hxx> #include <rangeutl.hxx> #include <scmod.hxx> +#include <tabvwsh.hxx> #include <viewdata.hxx> using namespace ::com::sun::star; @@ -71,6 +74,19 @@ static void lcl_SelectRangeFromString(const ScDocument& rDoc, const OUString& rS ScDocShell::GetViewData()->GetMarkData().SetMarkArea(aRange); } +static void lcl_SelectObjectByName(std::u16string_view rObjName) +{ + ScTabViewShell* pViewShell = ScDocShell::GetViewData()->GetViewShell(); + CPPUNIT_ASSERT(pViewShell); + + bool bFound = pViewShell->SelectObject(rObjName); + CPPUNIT_ASSERT_MESSAGE( + OString(OUStringToOString(rObjName, RTL_TEXTENCODING_UTF8) + " not found.").getStr(), + bFound); + + CPPUNIT_ASSERT(ScDocShell::GetViewData()->GetScDrawView()->AreObjectsMarked()); +} + constexpr OUStringLiteral DATA_DIRECTORY = u"/sc/qa/unit/uicalc/data/"; ScModelObj* ScUiCalcTest::createDoc(const char* pName) @@ -613,6 +629,36 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf138428) CPPUNIT_ASSERT_MESSAGE("There should be a note on B1", pDoc->HasNote(ScAddress(1, 0, 0))); } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf130614) +{ + ScModelObj* pModelObj = createDoc("tdf130614.ods"); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + lcl_SelectObjectByName(u"Object 1"); + + // FIXME: The OLE object is not copied/pasted if using CopyToClip/PasteToClip + dispatchCommand(mxComponent, ".uno:Copy", {}); + Scheduler::ProcessEventsToIdle(); + + mxComponent->dispose(); + + // Open a new document + mxComponent = loadFromDesktop("private:factory/scalc"); + pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + // Without the fix in place, this test would have crashed here + dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + + ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); + SdrPage* pPage = pDrawLayer->GetPage(0); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pPage->GetObjCount()); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf133342) { ScModelObj* pModelObj = createDoc("tdf133342.ods"); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits