Resolves tdf#161641 - Select data area before select all
Advanced option SelectRangeBeforeAll to restore original behavior
Change-Id: Iab4b4e61dffc1ecf2ffed01a994c9894c84ab74d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169276
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index 7303d1b..b9f74d9 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -763,6 +763,13 @@
</info>
<value>true</value>
</prop>
<prop oor:name="SelectRangeBeforeAll" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Disable to always select all</desc>
<label>Select range before all</label>
</info>
<value>true</value>
</prop>
</group>
<group oor:name="Grid">
<info>
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 08a1eeb..ae1edf3 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -2121,6 +2121,8 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf108654)
ScDocument* pDoc = getScDoc();
dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {});
// first .uno:SelectAll selects the range, second all (tdf#161641)
dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {});
dispatchCommand(mxComponent, u".uno:Copy"_ustr, {});
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index c62500c..dfb7b4d 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -49,6 +49,7 @@
#include <comphelper/lok.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <inputwin.hxx>
#include <officecfg/Office/Calc.hxx>
#include <memory>
@@ -657,7 +658,31 @@ void ScCellShell::Execute( SfxRequest& rReq )
case SID_SELECTALL:
{
pTabViewShell->SelectAll();
SCTAB nTab = GetViewData().GetTabNo();
SCCOL nStartCol = GetViewData().GetCurX();
SCROW nStartRow = GetViewData().GetCurY();
SCCOL nEndCol = nStartCol;
SCROW nEndRow = nStartRow;
bool bCanMark = false;
ScMarkData& rMarkdata = GetViewData().GetMarkData();
const bool bSelectFirst(officecfg::Office::Calc::Input::SelectRangeBeforeAll::get());
if (bSelectFirst && !rMarkdata.IsMarked())
{
const ScDocument& rDoc = GetViewData().GetDocument();
rDoc.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, true, false );
bCanMark = nStartCol != nEndCol || nStartRow != nEndRow;
}
if (bCanMark)
{
const ScRange aRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab);
pTabViewShell->MarkRange(aRange, false);
}
else
pTabViewShell->SelectAll();
rReq.Done();
}
break;