summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2023-03-13 08:49:27 +0100
committerAndreas Heinisch <andreas.heinisch@yahoo.de>2023-04-03 08:43:06 +0200
commit56ae7d01505fdae421109cfc78449230ba589d79 (patch)
treed4bde0406a42efeb74e55580e425b1cd2813d1da /sc/source/core
parentd36145d7cf6ca4d6072d4ab0a709bb8fe866336c (diff)
tdf#89920 - Handle embedded newline in Calc's search cell
If the replaced string contains a newline after find and replace, insert an edit cell in order to handle an embedded line correctly regardless of the content in the source cell. Change-Id: Ic8a5fc80b85546897572a228511b319cd5a8b9aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148752 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/data/table6.cxx15
1 files changed, 4 insertions, 11 deletions
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index 1f0fc1efbf3d..1ea4a5ace99d 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -35,14 +35,11 @@
namespace {
-bool lcl_GetTextWithBreaks( const EditTextObject& rData, ScDocument* pDoc, OUString& rVal )
+void lcl_GetTextWithBreaks( const EditTextObject& rData, ScDocument* pDoc, OUString& rVal )
{
- // true = more than 1 paragraph
-
EditEngine& rEngine = pDoc->GetEditEngine();
rEngine.SetText(rData);
rVal = rEngine.GetText();
- return ( rEngine.GetParagraphCount() > 1 );
}
}
@@ -81,7 +78,6 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, sc::Colum
pNote = nullptr;
}
- bool bMultiLine = false;
CellType eCellType = aCell.getType();
switch (rSearchItem.GetCellType())
{
@@ -90,7 +86,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, sc::Colum
if ( eCellType == CELLTYPE_FORMULA )
aString = aCell.getFormula()->GetFormula(rDocument.GetGrammar());
else if ( eCellType == CELLTYPE_EDIT )
- bMultiLine = lcl_GetTextWithBreaks(*aCell.getEditText(), &rDocument, aString);
+ lcl_GetTextWithBreaks(*aCell.getEditText(), &rDocument, aString);
else
{
if( !bSearchFormatted )
@@ -102,7 +98,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, sc::Colum
}
case SvxSearchCellType::VALUE:
if ( eCellType == CELLTYPE_EDIT )
- bMultiLine = lcl_GetTextWithBreaks(*aCell.getEditText(), &rDocument, aString);
+ lcl_GetTextWithBreaks(*aCell.getEditText(), &rDocument, aString);
else
{
if( !bSearchFormatted )
@@ -114,10 +110,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, sc::Colum
case SvxSearchCellType::NOTE:
{
if (pNote)
- {
aString = pNote->GetText();
- bMultiLine = pNote->HasMultiLineText();
- }
break;
}
default:
@@ -264,7 +257,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, sc::Colum
pFCell->SetMatColsRows( nMatCols, nMatRows );
aCol[nCol].SetFormulaCell(nRow, pFCell);
}
- else if ( bMultiLine && aString.indexOf('\n') != -1 )
+ else if (aString.indexOf('\n') != -1 && eCellType != CELLTYPE_FORMULA)
{
ScFieldEditEngine& rEngine = rDocument.GetEditEngine();
rEngine.SetTextCurrentDefaults(aString);