summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorTibor Nagy <nagy.tibor2@nisz.hu>2020-10-05 20:47:14 +0200
committerLászló Németh <nemeth@numbertext.org>2020-10-08 16:28:20 +0200
commit9971b1602d2a526dd8f2cc8255794515bb4e2168 (patch)
tree748558dea4a2c3348a8bccf59e7987591c58ec74 /sc/source
parent32af6bcd0c3634f860fc529acb17648e73051c73 (diff)
tdf#125462 sc: remove red (invalid data) circle
around the cell after typing valid data in it. This mark wasn't removed when correct data is entered in the cell, giving the impression that the entered value is incorrect. Note: This fixes only the directly modified cell, not the other cells with red circles which refer the modified cell. Testing: Tools->Detective->Mark Invalid Data adds these red circles around the cells with invalid content, according to their validation added by Data->Validity... Co-authored-by: Attila Szűcs (NISZ) Change-Id: Ib7ca3c453a930669a7c58e89b91654de36b8bb3b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103995 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/tool/detfunc.cxx55
-rw-r--r--sc/source/ui/docshell/docfunc.cxx10
2 files changed, 65 insertions, 0 deletions
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index d4c1ab66ec2e..813345b5e46d 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -1238,6 +1238,61 @@ bool ScDetectiveFunc::DeletePred( SCCOL nCol, SCROW nRow )
return ( nLevelCount != 0 );
}
+bool ScDetectiveFunc::DeleteCirclesAt( SCCOL nCol, SCROW nRow )
+{
+ tools::Rectangle aRect = GetDrawRect(nCol, nRow);
+ aRect.AdjustLeft(-250);
+ aRect.AdjustRight(250);
+ aRect.AdjustTop(-70);
+ aRect.AdjustBottom(70);
+
+ Point aStartCorner = aRect.TopLeft();
+ Point aEndCorner = aRect.BottomRight();
+
+ ScDrawLayer* pModel = rDoc.GetDrawLayer();
+ if (!pModel)
+ return false;
+
+ SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nTab));
+ OSL_ENSURE(pPage, "Page ?");
+
+ pPage->RecalcObjOrdNums();
+
+ const size_t nObjCount = pPage->GetObjCount();
+ size_t nDelCount = 0;
+ if (nObjCount)
+ {
+ std::unique_ptr<SdrObject*[]> ppObj(new SdrObject*[nObjCount]);
+
+ SdrObjListIter aIter(pPage, SdrIterMode::Flat);
+ SdrObject* pObject = aIter.Next();
+ while (pObject)
+ {
+ if (pObject->GetLayer() == SC_LAYER_INTERN
+ && dynamic_cast<const SdrCircObj*>(pObject) != nullptr)
+ {
+ tools::Rectangle aObjRect = static_cast<SdrCircObj*>(pObject)->GetLogicRect();
+ if (RectIsPoints(aObjRect, aStartCorner, aEndCorner))
+ ppObj[nDelCount++] = pObject;
+ }
+
+ pObject = aIter.Next();
+ }
+
+ for (size_t i = 1; i <= nDelCount; ++i)
+ pModel->AddCalcUndo(std::make_unique<SdrUndoRemoveObj>(*ppObj[nDelCount - i]));
+
+ for (size_t i = 1; i <= nDelCount; ++i)
+ pPage->RemoveObject(ppObj[nDelCount - i]->GetOrdNum());
+
+ ppObj.reset();
+
+ Modified();
+ }
+
+ return (nDelCount != 0);
+}
+
bool ScDetectiveFunc::DeleteAll( ScDetectiveDelete eWhat )
{
ScDrawLayer* pModel = rDoc.GetDrawLayer();
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index b0229c4c20f6..358fb135d17c 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -92,6 +92,7 @@
#include <sheetevents.hxx>
#include <conditio.hxx>
#include <columnspanset.hxx>
+#include <validat.hxx>
#include <memory>
#include <utility>
@@ -839,6 +840,15 @@ bool ScDocFunc::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, con
if (bApi)
NotifyInputHandler( rPos );
+ const SfxUInt32Item* pItem = rDoc.GetAttr(rPos, ATTR_VALIDDATA);
+ const ScValidationData* pData = rDoc.GetValidationEntry(pItem->GetValue());
+ if (pData)
+ {
+ ScRefCellValue aCell(rDoc, rPos);
+ if (pData->IsDataValid(aCell, rPos))
+ ScDetectiveFunc(rDoc, rPos.Tab()).DeleteCirclesAt(rPos.Col(), rPos.Row());
+ }
+
return true;
}