summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2022-01-30 23:36:53 +0100
committerEike Rathke <erack@redhat.com>2022-01-31 00:30:50 +0100
commit61cb699e88b3680becf78dc7b8bd514b2b7318a4 (patch)
tree7772ab55171ea6dda870f1619a5d090f61866123 /sc/source
parent12c6bff0e43b81b9017050f644bd87e865bbbf9e (diff)
Resolves: tdf#146722 Force row label for single text with numeric to the right
Note this *might* break other uses of the non-deterministic automatic labels where exactly this constellation previously lead to a column label. For which expecting a column label though makes less sense.. Change-Id: Id85df7485f9b71620d8cbc404a981852d1567a54 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129187 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/tool/compiler.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 0858487b2836..aa65019434ea 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3889,10 +3889,18 @@ bool ScCompiler::IsColRowName( const OUString& rName )
else
aAdr = aOne;
aRef.InitAddress( aAdr );
- if ( (aAdr.Row() != rDoc.MaxRow() && rDoc.HasStringData(
- aAdr.Col(), aAdr.Row() + 1, aAdr.Tab()))
- || (aAdr.Row() != 0 && rDoc.HasStringData(
- aAdr.Col(), aAdr.Row() - 1, aAdr.Tab())))
+ // Prioritize on column label; row label only if the next cell
+ // above/below the found label cell is text, or if both are not and
+ // the cell below is empty and the next cell to the right is
+ // numeric.
+ if ((aAdr.Row() < rDoc.MaxRow() && rDoc.HasStringData(
+ aAdr.Col(), aAdr.Row() + 1, aAdr.Tab()))
+ || (aAdr.Row() > 0 && rDoc.HasStringData(
+ aAdr.Col(), aAdr.Row() - 1, aAdr.Tab()))
+ || (aAdr.Row() < rDoc.MaxRow() && rDoc.GetRefCellValue(
+ ScAddress( aAdr.Col(), aAdr.Row() + 1, aAdr.Tab())).isEmpty()
+ && aAdr.Col() < rDoc.MaxCol() && rDoc.GetRefCellValue(
+ ScAddress( aAdr.Col() + 1, aAdr.Row(), aAdr.Tab())).hasNumeric()))
aRef.SetRowRel( true ); // RowName
else
aRef.SetColRel( true ); // ColName