tdf#117436 - Set text cell to accommodate potential multiline cells

Set text cell to accommodate potential multline cells during the copy
and paste process of a table from Base to Calc.

Change-Id: I8032627aee8190b0956be80d64144dc4d7fb07e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185092
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
This commit is contained in:
Andreas Heinisch 2025-05-09 14:00:41 +02:00
parent 9bc5b89c14
commit e695245b62
3 changed files with 16 additions and 11 deletions

View File

@ -1212,7 +1212,9 @@ public:
* Call this if you are not sure whether to put this as an edit text or a
* simple text.
*/
SC_DLLPUBLIC void SetTextCell( const ScAddress& rPos, const OUString& rStr );
SC_DLLPUBLIC void SetTextCell(const ScAddress& rPos, const OUString& rStr,
const ScSetStringParam* pParam = nullptr);
void SetEmptyCell( const ScAddress& rPos );
SC_DLLPUBLIC void SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal );
SC_DLLPUBLIC void SetValue( const ScAddress& rPos, double fVal );

View File

@ -3502,7 +3502,9 @@ SCROW ScDocument::GetFirstEditTextRow( const ScRange& rRange ) const
return -1;
}
void ScDocument::SetTextCell( const ScAddress& rPos, const OUString& rStr )
void ScDocument::SetTextCell(const ScAddress& rPos, const OUString& rStr,
const ScSetStringParam* pParam)
{
if (ScTable* pTable = FetchTable(rPos.Tab()))
{
@ -3514,9 +3516,14 @@ void ScDocument::SetTextCell( const ScAddress& rPos, const OUString& rStr )
}
else
{
ScSetStringParam aParam;
aParam.setTextInput();
pTable->SetString(rPos.Col(), rPos.Row(), rPos.Tab(), rStr, &aParam);
if (pParam)
pTable->SetString(rPos.Col(), rPos.Row(), rPos.Tab(), rStr, pParam);
else
{
ScSetStringParam aParam;
aParam.setTextInput();
pTable->SetString(rPos.Col(), rPos.Row(), rPos.Tab(), rStr, &aParam);
}
}
}
}

View File

@ -397,11 +397,6 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu
pFormatter->ChangeIntl( LANGUAGE_SYSTEM);
}
// #105460#, #i4180# String cells can't contain tabs or linebreaks
// -> replace with spaces
aStr = aStr.replaceAll( "\t", " " );
aStr = aStr.replaceAll( "\n", " " );
if (bTextFormat)
{
aParam.mbDetectNumberFormat = false;
@ -414,7 +409,8 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu
aParam.mbDetectScientificNumberFormat = bConvertScientific;
}
mpDoc->SetString(nCol, nRow, nTab, aStr, &aParam);
// tdf#117436 - set text cell to accommodate potential multiline cells
mpDoc->SetTextCell(ScAddress(nCol, nRow, nTab), aStr, &aParam);
}
}
else if (std::unique_ptr<EditTextObject> pTextObject = IsValidSel(*mpEngine, pE->aSel) ? mpEngine->CreateTextObject(pE->aSel) : nullptr)