[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sc/qa sc/source
Attila Szűcs (via logerrit)
logerrit at kemper.freedesktop.org
Thu Feb 18 14:16:27 UTC 2021
sc/qa/unit/copy_paste_test.cxx | 73 ++++++++++++++++++++
sc/qa/unit/data/ods/tdf53431_autofilterFilldown.ods |binary
sc/source/core/data/documen3.cxx | 5 +
sc/source/ui/inc/viewfunc.hxx | 3
4 files changed, 80 insertions(+), 1 deletion(-)
New commits:
commit 1c914b4b2d9ab2bbdde1c9c309b90832ca806d0d
Author: Attila Szűcs <szucs.attila3 at nisz.hu>
AuthorDate: Mon Sep 7 14:36:25 2020 +0200
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Thu Feb 18 15:15:48 2021 +0100
tdf#53431 tdf#136535 sc: fix Fill Cells with Autofilter
Sheet->Fill Cells on a selected range duplicated or
removed the AutoFilter button, when the range contained
that, by copying cell properties. Apply RefreshAutoFilter()
after the fill to repair this.
Note: this refresh is not slow, because it depends only on
the number of columns, see ATTR_MERGE_FLAG attribute of the
columns.
Co-authored-by: Tibor Nagy (NISZ)
Change-Id: I95d394c5432d22805a761b76219f656fad3feae1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102173
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 789abce00bbb1139eb4005f78b82478a17342048)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111139
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
diff --git a/sc/qa/unit/copy_paste_test.cxx b/sc/qa/unit/copy_paste_test.cxx
index 71adbe5c8c8d..69557ea982c9 100644
--- a/sc/qa/unit/copy_paste_test.cxx
+++ b/sc/qa/unit/copy_paste_test.cxx
@@ -14,6 +14,9 @@
#include <docsh.hxx>
#include <tabvwsh.hxx>
#include <impex.hxx>
+#include <viewfunc.hxx>
+#include <scitems.hxx>
+#include <attrib.hxx>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XModel2.hpp>
@@ -36,6 +39,7 @@ public:
void testTdf124565();
void testTdf126421();
void testTdf107394();
+ void testTdf53431_fillOnAutofilter();
CPPUNIT_TEST_SUITE(ScCopyPasteTest);
CPPUNIT_TEST(testCopyPasteXLS);
@@ -43,6 +47,7 @@ public:
CPPUNIT_TEST(testTdf124565);
CPPUNIT_TEST(testTdf126421);
CPPUNIT_TEST(testTdf107394);
+ CPPUNIT_TEST(testTdf53431_fillOnAutofilter);
CPPUNIT_TEST_SUITE_END();
private:
@@ -421,6 +426,74 @@ void ScCopyPasteTest::testTdf107394()
xComponent->dispose();
}
+static ScMF lcl_getMergeFlagOfCell(const ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab)
+{
+ const SfxPoolItem& rPoolItem = rDoc.GetPattern(nCol, nRow, nTab)->GetItem(ATTR_MERGE_FLAG);
+ const ScMergeFlagAttr& rMergeFlag = static_cast<const ScMergeFlagAttr&>(rPoolItem);
+ return rMergeFlag.GetValue();
+}
+
+void ScCopyPasteTest::testTdf53431_fillOnAutofilter()
+{
+ uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(::comphelper::getProcessComponentContext());
+ CPPUNIT_ASSERT(xDesktop.is());
+
+ // create a frame
+ Reference< frame::XFrame > xTargetFrame = xDesktop->findFrame("_blank", 0);
+ CPPUNIT_ASSERT(xTargetFrame.is());
+
+ // 1. Open the document
+ ScDocShellRef xDocSh = loadDoc("tdf53431_autofilterFilldown.", FORMAT_ODS, true);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load tdf53431_autofilterFilldown.ods.", xDocSh.is());
+
+ uno::Reference< frame::XModel2 > xModel2(xDocSh->GetModel(), UNO_QUERY);
+ CPPUNIT_ASSERT(xModel2.is());
+
+ Reference< frame::XController2 > xController = xModel2->createDefaultViewController(xTargetFrame);
+ CPPUNIT_ASSERT(xController.is());
+
+ // introduce model/view/controller to each other
+ xController->attachModel(xModel2.get());
+ xModel2->connectController(xController.get());
+ xTargetFrame->setComponent(xController->getComponentWindow(), xController.get());
+ xController->attachFrame(xTargetFrame);
+ xModel2->setCurrentController(xController.get());
+
+ ScDocument& rDoc = xDocSh->GetDocument();
+
+ // Get the document controller
+ ScTabViewShell* pView = xDocSh->GetBestViewShell(false);
+ CPPUNIT_ASSERT(pView != nullptr);
+
+ //Fill should not clone Autofilter button
+ ScDocShell::GetViewData()->GetMarkData().SetMarkArea(ScRange(1, 1, 0, 2, 4, 0));
+ pView->FillSimple(FILL_TO_BOTTOM);
+ CPPUNIT_ASSERT((lcl_getMergeFlagOfCell(rDoc, 1, 1, 0) & ScMF::Auto));
+ CPPUNIT_ASSERT((lcl_getMergeFlagOfCell(rDoc, 2, 1, 0) & ScMF::Auto));
+ CPPUNIT_ASSERT(!(lcl_getMergeFlagOfCell(rDoc, 1, 4, 0) & ScMF::Auto));
+
+ ScDocShell::GetViewData()->GetMarkData().SetMarkArea(ScRange(1, 1, 0, 4, 4, 0));
+ pView->FillSimple(FILL_TO_RIGHT);
+ CPPUNIT_ASSERT((lcl_getMergeFlagOfCell(rDoc, 1, 1, 0) & ScMF::Auto));
+ CPPUNIT_ASSERT((lcl_getMergeFlagOfCell(rDoc, 2, 1, 0) & ScMF::Auto));
+ CPPUNIT_ASSERT(!(lcl_getMergeFlagOfCell(rDoc, 4, 1, 0) & ScMF::Auto));
+ CPPUNIT_ASSERT(!(lcl_getMergeFlagOfCell(rDoc, 1, 4, 0) & ScMF::Auto));
+ CPPUNIT_ASSERT(!(lcl_getMergeFlagOfCell(rDoc, 4, 4, 0) & ScMF::Auto));
+
+ //Fill should not delete Autofilter buttons
+ ScDocShell::GetViewData()->GetMarkData().SetMarkArea(ScRange(0, 0, 0, 2, 4, 0));
+ pView->FillSimple(FILL_TO_TOP);
+ CPPUNIT_ASSERT((lcl_getMergeFlagOfCell(rDoc, 1, 1, 0) & ScMF::Auto));
+ CPPUNIT_ASSERT((lcl_getMergeFlagOfCell(rDoc, 2, 1, 0) & ScMF::Auto));
+ CPPUNIT_ASSERT(!(lcl_getMergeFlagOfCell(rDoc, 1, 0, 0) & ScMF::Auto));
+
+ ScDocShell::GetViewData()->GetMarkData().SetMarkArea(ScRange(0, 0, 0, 4, 4, 0));
+ pView->FillSimple(FILL_TO_LEFT);
+ CPPUNIT_ASSERT((lcl_getMergeFlagOfCell(rDoc, 1, 1, 0) & ScMF::Auto));
+ CPPUNIT_ASSERT((lcl_getMergeFlagOfCell(rDoc, 2, 1, 0) & ScMF::Auto));
+ CPPUNIT_ASSERT(!(lcl_getMergeFlagOfCell(rDoc, 0, 1, 0) & ScMF::Auto));
+}
+
ScCopyPasteTest::ScCopyPasteTest()
: ScBootstrapFixture( "sc/qa/unit/data" )
{
diff --git a/sc/qa/unit/data/ods/tdf53431_autofilterFilldown.ods b/sc/qa/unit/data/ods/tdf53431_autofilterFilldown.ods
new file mode 100644
index 000000000000..770d38547373
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf53431_autofilterFilldown.ods differ
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index f34389e9fe35..25cf69d0d55d 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1152,15 +1152,20 @@ void ScDocument::Fill(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScProg
{
PutInOrder( nCol1, nCol2 );
PutInOrder( nRow1, nRow2 );
+ ScRange rRange;
+ rMark.GetMarkArea(rRange);
SCTAB nMax = maTabs.size();
for (const auto& rTab : rMark)
{
if (rTab >= nMax)
break;
if (maTabs[rTab])
+ {
maTabs[rTab]->Fill(nCol1, nRow1, nCol2, nRow2,
nFillCount, eFillDir, eFillCmd, eFillDateCmd,
nStepValue, nMaxValue, pProgress);
+ RefreshAutoFilter(rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row(), rTab);
+ }
}
}
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index a8d4a25985c6..9bfc2e270c90 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -238,7 +238,8 @@ public:
bool MergeCells( bool bApi, bool& rDoContents, bool bCenter );
bool RemoveMerge();
- void FillSimple( FillDir eDir );
+ SC_DLLPUBLIC void
+ FillSimple( FillDir eDir );
void FillSeries( FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd,
double fStart, double fStep, double fMax );
void FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow,
More information about the Libreoffice-commits
mailing list