officecfg/registry/schema/org/openoffice/Office/Calc.xcs |    7 +++
 sc/source/ui/view/cellsh3.cxx                            |   27 ++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)

New commits:
commit 4d62c692d9106c9c2fc0d3dc9efb1cd57a8a12d3
Author:     Heiko Tietze <[email protected]>
AuthorDate: Thu Jun 20 15:12:05 2024 +0200
Commit:     Thorsten Behrens <[email protected]>
CommitDate: Mon Jul 15 11:33:18 2024 +0200

    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 <[email protected]>
    Reviewed-by: Heiko Tietze <[email protected]>

diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index a8830ab1ba19..c5cc5d3f4d85 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -739,6 +739,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/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index e6c89b6a2b9c..ebe5368d57c7 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>
 
@@ -658,7 +659,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;

Reply via email to