[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sc/qa sc/source
Tibor Nagy (via logerrit)
logerrit at kemper.freedesktop.org
Mon Mar 1 14:55:49 UTC 2021
sc/qa/unit/data/ods/updateCircleInMergedCell.ods |binary
sc/qa/unit/subsequent_filters-test.cxx | 35 +++++++++++++++++++++++
sc/source/core/tool/detfunc.cxx | 9 +++--
sc/source/ui/docshell/docfunc.cxx | 8 +++++
sc/source/ui/inc/docfunc.hxx | 3 +
5 files changed, 51 insertions(+), 4 deletions(-)
New commits:
commit 7afe5cc58143114ce60d22be63bf1663b779b50c
Author: Tibor Nagy <nagy.tibor2 at nisz.hu>
AuthorDate: Thu Nov 26 14:20:14 2020 +0100
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Mon Mar 1 15:55:13 2021 +0100
tdf#138483 sc: update red circles after merging cells
If there are detective circles on the cells and these cells are merged,
the merged cell keeps all red circles instead of removed them except
the circle of merged cell.
Co-authored-by: Attila Szűcs (NISZ)
Change-Id: I39c76cbb7c41affb0a18e5e82923945a2d41795d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106698
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 3741b90abe478fb04db88207b496a5238df35bb8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106827
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
(cherry picked from commit df36ac613e43934e49edd3f087d78c7c54ac92ee)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111709
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
diff --git a/sc/qa/unit/data/ods/updateCircleInMergedCell.ods b/sc/qa/unit/data/ods/updateCircleInMergedCell.ods
new file mode 100644
index 000000000000..93be82487e22
Binary files /dev/null and b/sc/qa/unit/data/ods/updateCircleInMergedCell.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index f7171a4d567d..31fce53b67bd 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -66,6 +66,8 @@
#include <stlpool.hxx>
#include <hints.hxx>
#include <detfunc.hxx>
+#include <cellmergeoption.hxx>
+#include <undoblk.hxx>
#include <orcusfilters.hxx>
#include <filter.hxx>
@@ -104,6 +106,7 @@ public:
virtual void tearDown() override;
//ods, xls, xlsx filter tests
+ void testUpdateCircleInMergedCellODS();
void testDeleteCircleInMergedCellODS();
void testBooleanFormatXLSX();
void testBasicCellContentODS();
@@ -272,6 +275,7 @@ public:
void testDeleteCirclesInRowAndCol();
CPPUNIT_TEST_SUITE(ScFiltersTest);
+ CPPUNIT_TEST(testUpdateCircleInMergedCellODS);
CPPUNIT_TEST(testDeleteCircleInMergedCellODS);
CPPUNIT_TEST(testBooleanFormatXLSX);
CPPUNIT_TEST(testBasicCellContentODS);
@@ -484,6 +488,37 @@ void testRangeNameImpl(const ScDocument& rDoc)
}
+void ScFiltersTest::testUpdateCircleInMergedCellODS()
+{
+ ScDocShellRef xDocSh = loadDoc("updateCircleInMergedCell.", FORMAT_ODS);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load updateCircleInMergedCell.ods", xDocSh.is());
+
+ ScDocument& rDoc = xDocSh->GetDocument();
+ rDoc.EnableChangeReadOnly(true);
+
+ ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
+ SdrPage* pPage = pDrawLayer->GetPage(0);
+ CPPUNIT_ASSERT_MESSAGE("draw page for sheet 1 should exist.", pPage);
+
+ // There should be four circle objects!
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), pPage->GetObjCount());
+
+ ScCellMergeOption aCellMergeOption(0,0,1,1); // A1:B2
+ aCellMergeOption.maTabs.insert(0);
+ xDocSh->GetDocFunc().MergeCells(aCellMergeOption, false, true, true, false);
+
+ // There should be a circle object!
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pPage->GetObjCount());
+
+ std::unique_ptr<ScUndoRemoveMerge> pUndoRemoveMerge;
+ xDocSh->GetDocFunc().UnmergeCells(aCellMergeOption, true, pUndoRemoveMerge.get());
+
+ // There should be four circle objects!
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), pPage->GetObjCount());
+
+ xDocSh->DoClose();
+}
+
void ScFiltersTest::testDeleteCircleInMergedCellODS()
{
ScDocShellRef xDocSh = loadDoc("deleteCircleInMergedCell.", FORMAT_ODS);
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index 5e5b538a80e6..f30d36d11e70 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -1388,13 +1388,15 @@ bool ScDetectiveFunc::MarkInvalid(bool& rOverflow)
if ( bMarkEmpty )
for ( nRow = nNextRow; nRow < nCellRow && nInsCount < SC_DET_MAXCIRCLE; nRow++ )
{
- DrawCircle( nCol, nRow, aData );
+ if(!pPattern->GetItem(ATTR_MERGE_FLAG).IsOverlapped())
+ DrawCircle( nCol, nRow, aData );
++nInsCount;
}
ScRefCellValue aCell = aCellIter.getRefCellValue();
if (!pData->IsDataValid(aCell, aCellIter.GetPos()))
{
- DrawCircle( nCol, nCellRow, aData );
+ if(!pPattern->GetItem(ATTR_MERGE_FLAG).IsOverlapped())
+ DrawCircle( nCol, nCellRow, aData );
++nInsCount;
}
nNextRow = nCellRow + 1;
@@ -1402,7 +1404,8 @@ bool ScDetectiveFunc::MarkInvalid(bool& rOverflow)
if ( bMarkEmpty )
for ( nRow = nNextRow; nRow <= nRow2 && nInsCount < SC_DET_MAXCIRCLE; nRow++ )
{
- DrawCircle( nCol, nRow, aData );
+ if(!pPattern->GetItem(ATTR_MERGE_FLAG).IsOverlapped())
+ DrawCircle(nCol, nRow, aData);
++nInsCount;
}
}
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index c0a205532ca2..88225de10abf 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5007,6 +5007,10 @@ bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, bool bContents, bo
rDoc.SetDirty(aRange, true);
}
+ bool bDone = ScDetectiveFunc(&rDoc, nTab).DeleteAll( ScDetectiveDelete::Circles );
+ if(bDone)
+ DetectiveMarkInvalid(nTab);
+
bNeedContentsUndo |= bNeedContents;
}
@@ -5092,6 +5096,10 @@ bool ScDocFunc::UnmergeCells( const ScCellMergeOption& rOption, bool bRecord, Sc
if ( !AdjustRowHeight( aExtended ) )
rDocShell.PostPaint( aExtended, PaintPartFlags::Grid );
+
+ bool bDone = ScDetectiveFunc(&rDoc, nTab).DeleteAll( ScDetectiveDelete::Circles );
+ if(bDone)
+ DetectiveMarkInvalid(nTab);
}
if (bRecord)
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index 1984c0da440a..f7b518ef7f35 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -195,7 +195,8 @@ public:
MergeCells( const ScCellMergeOption& rOption, bool bContents,
bool bRecord, bool bApi, bool bEmptyMergedCells = false );
bool UnmergeCells( const ScRange& rRange, bool bRecord, ScUndoRemoveMerge* pUndoRemoveMerge );
- bool UnmergeCells( const ScCellMergeOption& rOption, bool bRecord, ScUndoRemoveMerge* pUndoRemoveMerge );
+ SC_DLLPUBLIC bool
+ UnmergeCells( const ScCellMergeOption& rOption, bool bRecord, ScUndoRemoveMerge* pUndoRemoveMerge );
// takes ownership of pNewRanges, nTab = -1 for local range names
void SetNewRangeNames( std::unique_ptr<ScRangeName> pNewRanges, bool bModifyDoc, SCTAB nTab );
More information about the Libreoffice-commits
mailing list