summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2020-08-06 19:40:58 +0200
committerEike Rathke <erack@redhat.com>2020-08-09 21:46:00 +0200
commit3b5fccb308b9554d024e1d576abbf3ebec26b7a5 (patch)
tree4ea2f3f62d80c16e356b2d1339642e3b4ab00a2c /sc
parent72aeda11bd1acbe5d9224eae0d22265630ebb0b8 (diff)
Resolves: tdf#134876 Absolute range references when selecting in Wizard
Not doing the same for ScInputHandler::SetReference() now because selecting by keyboard is more likely to keep the existing behaviour and is easily edited to change. Change-Id: I368aa21c7f1099d175805493c92070da280cafa4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100267 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/formdlg/formula.cxx24
1 files changed, 22 insertions, 2 deletions
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index de2c41cfed0b..c21a8d859cbc 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -406,6 +406,16 @@ void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument& rRefDoc )
RefInputStart(GetActiveEdit());
}
+ // Pointer-selected => absolute range references for the non-single
+ // dimensions, so in the other dimension (if any) it's still
+ // copy-adjustable.
+ constexpr ScRefFlags eColFlags = ScRefFlags::COL_ABS | ScRefFlags::COL2_ABS;
+ constexpr ScRefFlags eRowFlags = ScRefFlags::ROW_ABS | ScRefFlags::ROW2_ABS;
+ ScRefFlags eRangeFlags = ScRefFlags::ZERO;
+ if (rRef.aStart.Col() != rRef.aEnd.Col())
+ eRangeFlags |= eColFlags;
+ if (rRef.aStart.Row() != rRef.aEnd.Row())
+ eRangeFlags |= eRowFlags;
OUString aRefStr;
bool bOtherDoc = (&rRefDoc != m_pDoc && rRefDoc.GetDocumentShell()->HasName());
if ( bOtherDoc )
@@ -414,8 +424,8 @@ void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument& rRefDoc )
OSL_ENSURE(rRef.aStart.Tab()==rRef.aEnd.Tab(), "nStartTab!=nEndTab");
- // Always 3D and absolute.
- OUString aTmp( rRef.Format(rRefDoc, ScRefFlags::VALID | ScRefFlags::TAB_ABS_3D));
+ // Sheet always 3D and absolute.
+ OUString aTmp( rRef.Format(rRefDoc, ScRefFlags::VALID | ScRefFlags::TAB_ABS_3D | eRangeFlags));
SfxObjectShell* pObjSh = rRefDoc.GetDocumentShell();
@@ -433,6 +443,16 @@ void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument& rRefDoc )
ScTokenArray aArray(&rRefDoc);
ScComplexRefData aRefData;
aRefData.InitRangeRel(&rRefDoc, rRef, m_CursorPos);
+ if ((eRangeFlags & eColFlags) == eColFlags)
+ {
+ aRefData.Ref1.SetAbsCol( rRef.aStart.Col() );
+ aRefData.Ref2.SetAbsCol( rRef.aEnd.Col() );
+ }
+ if ((eRangeFlags & eRowFlags) == eRowFlags)
+ {
+ aRefData.Ref1.SetAbsRow( rRef.aStart.Row() );
+ aRefData.Ref2.SetAbsRow( rRef.aEnd.Row() );
+ }
bool bSingle = aRefData.Ref1 == aRefData.Ref2;
if (m_CursorPos.Tab() != rRef.aStart.Tab())
{