diff options
author | Eike Rathke <erack@redhat.com> | 2022-01-30 23:36:53 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2022-01-31 00:30:50 +0100 |
commit | 61cb699e88b3680becf78dc7b8bd514b2b7318a4 (patch) | |
tree | 7772ab55171ea6dda870f1619a5d090f61866123 /sc | |
parent | 12c6bff0e43b81b9017050f644bd87e865bbbf9e (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')
-rw-r--r-- | sc/inc/document.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/compiler.cxx | 16 |
2 files changed, 14 insertions, 4 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 87fb59e8980d..33e529d0b426 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -2610,7 +2610,9 @@ private: bool HasPartOfMerged( const ScRange& rRange ); +public: ScRefCellValue GetRefCellValue( const ScAddress& rPos ); +private: ScRefCellValue GetRefCellValue( const ScAddress& rPos, sc::ColumnBlockPosition& rBlockPos ); std::map< SCTAB, ScSortParam > mSheetSortParams; 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 |