summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2014-12-07 17:32:09 +0100
committerTor Lillqvist <tml@collabora.com>2014-12-15 13:55:47 +0200
commit4b485c870aa708d589aa1ae2491c7c72e6c8f7b1 (patch)
tree9cdfdd64e333a1e002abfd1f373b34f204acdf3d
parent459e5033dc80285bfc807776d59ee3a3095b90ec (diff)
add ReorderParam.mbHasHeaders to include in Undo range mark
Undo Sort did not select/mark the original range if it included header row/column. (cherry picked from commit ec1b1af8af7ead149f96c09e16402e66e0973372) Backported with merge conflicts. umm.. row is row and col is col (cherry picked from commit 413a0655adec3e9364bc94afff638a5a9f88560c) 26c62fa1fc97aa0dd4eda1102422e5f012a126eb Change-Id: Ie4c800e7a44fd910c871731673093400c6400e4a Reviewed-on: https://gerrit.libreoffice.org/13379 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--sc/inc/sortparam.hxx1
-rw-r--r--sc/source/core/data/table3.cxx1
-rw-r--r--sc/source/ui/undo/undosort.cxx20
3 files changed, 21 insertions, 1 deletions
diff --git a/sc/inc/sortparam.hxx b/sc/inc/sortparam.hxx
index 6f6364ad641f..6735a1387839 100644
--- a/sc/inc/sortparam.hxx
+++ b/sc/inc/sortparam.hxx
@@ -98,6 +98,7 @@ struct SC_DLLPUBLIC ReorderParam
bool mbPattern;
bool mbHiddenFiltered;
bool mbUpdateRefs;
+ bool mbHasHeaders;
/**
* Reorder the position indices such that it can be used to undo the
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index b226c62b123d..6a1a305e2c80 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1416,6 +1416,7 @@ void ScTable::Sort(
pUndo->mbPattern = rSortParam.bIncludePattern;
pUndo->mbHiddenFiltered = bKeepQuery;
pUndo->mbUpdateRefs = bUpdateRefs;
+ pUndo->mbHasHeaders = rSortParam.bHasHeader;
}
if (rSortParam.bByRow)
diff --git a/sc/source/ui/undo/undosort.cxx b/sc/source/ui/undo/undosort.cxx
index f86bdc2b01d7..ea847cc2dc06 100644
--- a/sc/source/ui/undo/undosort.cxx
+++ b/sc/source/ui/undo/undosort.cxx
@@ -44,7 +44,25 @@ void UndoSort::Execute( bool bUndo )
aParam.reverse();
rDoc.Reorder(aParam, NULL);
- ScUndoUtil::MarkSimpleBlock(pDocShell, maParam.maSortRange);
+ if (maParam.mbHasHeaders)
+ {
+ ScRange aMarkRange( maParam.maSortRange);
+ if (maParam.mbByRow)
+ {
+ if (aMarkRange.aStart.Row() > 0)
+ aMarkRange.aStart.IncRow(-1);
+ }
+ else
+ {
+ if (aMarkRange.aStart.Col() > 0)
+ aMarkRange.aStart.IncCol(-1);
+ }
+ ScUndoUtil::MarkSimpleBlock(pDocShell, aMarkRange);
+ }
+ else
+ {
+ ScUndoUtil::MarkSimpleBlock(pDocShell, maParam.maSortRange);
+ }
rDoc.SetDirty(maParam.maSortRange);
if (!aParam.mbUpdateRefs)