tdf#160781 sc SearchStyle: byRow and byCol were switched around

This code is basically untouched since initial import.

For some reason, searching for patterns handled by Row
as if it was by Column - the opposite of text searching.

This patch fixes that.

Thanks to Julien Nabet who gave an initial try
and identified that looping again didn't work.

Change-Id: Ie6daa67e7d94bb1a5b8cd58158d20f1a383a7d77
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208200
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
This commit is contained in:
Justin Luth
2026-07-20 23:20:26 +02:00
parent 6398132373
commit 1bfad0e536
2 changed files with 18 additions and 58 deletions
+16 -56
View File
@@ -1249,78 +1249,38 @@ void ScDocument::GetSearchAndReplaceStart( const SvxSearchItem& rSearchItem,
{
if ( rSearchItem.GetRowDirection() )
{
if ( rSearchItem.GetPattern() )
{
rRow = MaxRow();
if (!bReplace || rSearchItem.GetPattern())
rCol = MaxCol() + 1;
else // bReplace
rCol = MaxCol();
rRow = MaxRow()+1;
}
else if ( bReplace )
{
rCol = MaxCol();
rRow = MaxRow();
}
else
{
rCol = MaxCol()+1;
rRow = MaxRow();
}
}
else
{
if ( rSearchItem.GetPattern() )
{
rCol = MaxCol()+1;
rCol = MaxCol();
if (!bReplace || rSearchItem.GetPattern())
rRow = MaxRow() + 1;
else // bReplace
rRow = MaxRow();
}
else if ( bReplace )
{
rCol = MaxCol();
rRow = MaxRow();
}
else
{
rCol = MaxCol();
rRow = MaxRow()+1;
}
}
}
else
{
if ( rSearchItem.GetRowDirection() )
{
if ( rSearchItem.GetPattern() )
{
rCol = 0;
rRow = SCROW(-1);
}
else if ( bReplace )
{
rCol = 0;
rRow = 0;
}
else
{
rRow = 0;
if (!bReplace || rSearchItem.GetPattern())
rCol = SCCOL(-1);
rRow = 0;
}
else // bReplace
rCol = 0;
}
else
{
if ( rSearchItem.GetPattern() )
{
rCol = SCCOL(-1);
rRow = 0;
}
else if ( bReplace )
{
rCol = 0;
rRow = 0;
}
else
{
rCol = 0;
rCol = 0;
if (!bReplace || rSearchItem.GetPattern())
rRow = SCROW(-1);
}
else // bReplace
rRow = 0;
}
}
}
+2 -2
View File
@@ -639,7 +639,7 @@ bool ScTable::SearchStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW&
bool bBack = rSearchItem.GetBackward();
short nAdd = bBack ? -1 : 1;
if (bRows) // by row
if (!bRows) // by column
{
if ( !IsColValid( nCol ) )
{
@@ -663,7 +663,7 @@ bool ScTable::SearchStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW&
}
while ( !bFound && IsColValid( nCol ) );
}
else // by column
else // by row
{
SCCOL aColSize = aCol.size();
std::vector< SCROW > nNextRows ( aColSize );