sc/source/ui/app/inputhdl.cxx |   12 ++++++++++++
 1 file changed, 12 insertions(+)

New commits:
commit 14820000ae614645599bebedec7c0467333bd324
Author:     offtkp <parisop...@gmail.com>
AuthorDate: Wed Nov 22 17:00:53 2023 +0200
Commit:     Paris Oplopoios <parisop...@gmail.com>
CommitDate: Wed Nov 22 17:05:46 2023 +0100

    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/+/159821
    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 7aa1ebf218be..1153a7dc03d4 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>
@@ -3144,6 +3145,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 && pActiveViewSh)
     {

Reply via email to