sc/source/ui/app/inputhdl.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+)
New commits: commit 17e362e56f9e15d0214c441e632c91d22e58519d Author: offtkp <parisop...@gmail.com> AuthorDate: Wed Nov 22 17:00:53 2023 +0200 Commit: Paris Oplopoios <parisop...@gmail.com> CommitDate: Thu Nov 23 16:13:39 2023 +0100 tdf#158252 sc: Enable text wrapping when inputting line breaks in cell In Excel, when typing new lines in a cell or pasting text with new lines and then clicking out of the cell, wrap text is enabled, which actually shows the contents on the new line instead of on the same line Change-Id: I113aceab33380a5deb536f57969c3fc90825146b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159758 Tested-by: Paris Oplopoios <parisop...@gmail.com> Reviewed-by: Paris Oplopoios <parisop...@gmail.com> diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 344651136876..809ba8520e33 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -47,6 +47,7 @@ #include <sfx2/printer.hxx> #include <svl/numformat.hxx> #include <svl/zforlist.hxx> +#include <svx/svxids.hrc> #include <unotools/localedatawrapper.hxx> #include <unotools/charclass.hxx> #include <utility> @@ -3142,6 +3143,17 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInL lcl_RemoveTabs(aString); lcl_RemoveTabs(aPreAutoCorrectString); + if (aString.indexOf('\n') != -1) + { + // Cell contains line breaks, enable wrapping + ScLineBreakCell aBreakItem(true); + pActiveViewSh->ApplyAttr(aBreakItem); + + SfxViewFrame* pViewFrm = SfxViewFrame::Current(); + if (pViewFrm) + pViewFrm->GetBindings().Invalidate(SID_ATTR_ALIGN_LINEBREAK); + } + // Test if valid (always with simple string) if (bModified && nValidation) {