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
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 87fb59e..33e529d 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 0858487..aa65019 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