summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBayram Çiçek <bayram.cicek@collabora.com>2024-05-16 09:58:28 +0300
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-05-16 15:50:03 +0200
commit35c93c5f8e40dff4819849b240044cd9d99221a0 (patch)
tree790a9f0910012aa59b599f8c253fda73933b5909
parent6c4ed5685b6dc08c9734cfcfd37b294ac892ad7e (diff)
make AutoFill work for Copy cells and Fill series
FID_FILL_AUTO (.uno:AutoFill): - added new parameter: SfxBoolItem Copy FN_PARAM_1 - if the parameter is true, we use "Copy cells", otherwise use "Fill series" Signed-off-by: Bayram Çiçek <bayram.cicek@collabora.com> Change-Id: I639828021dcbba52f6bc21366f23faf7e38bb03e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167726 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> (cherry picked from commit 95575b8bd026e3ae4aaddf3a023488d7a5fa0976) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167677 Tested-by: Jenkins
-rw-r--r--sc/sdi/scalc.sdi2
-rw-r--r--sc/source/ui/view/cellsh1.cxx35
2 files changed, 32 insertions, 5 deletions
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 4240bb5ffc86..3591ca10f199 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -338,7 +338,7 @@ SfxBoolItem AutoComplete FID_AUTOCOMPLETE
SfxVoidItem AutoFill FID_FILL_AUTO
-(SfxStringItem EndCell FID_FILL_AUTO)
+(SfxStringItem EndCell FID_FILL_AUTO,SfxBoolItem Copy FN_PARAM_1)
[
AutoUpdate = FALSE,
FastCall = FALSE,
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index ae55a3312d25..3c59c4dfed9f 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -876,6 +876,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
SCROW nFillRow = GetViewData().GetRefEndY();
ScDocument& rDoc = GetViewData().GetDocument();
+ sal_uInt16 nOrigScFillModeMouseModifier = nScFillModeMouseModifier;
+ bool bUseSelection = true;
+
if( pReqArgs != nullptr )
{
if( const SfxStringItem* pItem = pReqArgs->GetItemIfSet( FID_FILL_AUTO ) )
@@ -888,13 +891,33 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
nFillRow = aScAddress.Row();
nFillCol = aScAddress.Col();
}
+
+ SCTAB nStartTab, nEndTab;
+ GetViewData().GetSimpleArea(nStartCol, nStartRow, nStartTab, nEndCol,
+ nEndRow, nEndTab);
+ bUseSelection = false;
}
- SCTAB nStartTab, nEndTab;
- GetViewData().GetSimpleArea( nStartCol,nStartRow,nStartTab,
- nEndCol,nEndRow,nEndTab );
+ const SfxPoolItem* pItem;
+ if (pReqArgs->HasItem(FN_PARAM_1, &pItem))
+ {
+ /*
+ nScFillModeMouseModifier controls if we "Copy cells" or "Fill series"
+ - if nScFillModeMouseModifier is set to "KEY_MOD1", use "Copy cells"
+ - otherwise use "Fill series"
+
+ This is also the same with auto fill by dragging mouse
+ - dragging with Ctrl key will set nScFillModeMouseModifier to KEY_MOD1, use "Copy cells"
+ - only dragging will use "Fill series" (no Ctrl key)
+ */
+ const bool bCopyCells = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ nScFillModeMouseModifier &= ~KEY_MOD1; // turn off, reset to 0
+
+ if (bCopyCells)
+ nScFillModeMouseModifier |= KEY_MOD1; // turn on
+ }
}
- else // call via mouse
+ if (bUseSelection) // call via mouse or if FN_PARAM_1 exists
{
// not in a merged cell
@@ -968,6 +991,10 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
OSL_FAIL( "Direction not unique for autofill" );
}
}
+
+ // reset nScFillModeMouseModifier to its original state
+ // otherwise, auto fill by dragging will not work as expected
+ nScFillModeMouseModifier = nOrigScFillModeMouseModifier;
}
break;
case FID_FILL_SINGLE_EDIT: