sw/source/uibase/wrtsh/wrtsh1.cxx |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit 0db2cd321fef8db7c17c6c588b6593c7d59a9688
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Mon May 9 11:19:48 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon May 9 12:27:54 2022 +0200

    sw content controls: only try to insert placeholders if there is no 
selection
    
    The logic is that in case there is no selection, we insert a placeholder
    like "type here", but if there is a selection, that can be a custom
    placeholder.
    
    Without this fix, we would hit an assertion failure on inserting content
    control when there is a selection, as the placeholder is empty and
    operator[](0) is not allowed for empty OUStrings.
    
    Change-Id: I8370b8d74415faf0e76dccb574aa29bea1947bb8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134041
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx 
b/sw/source/uibase/wrtsh/wrtsh1.cxx
index ca1c55c0f8c7..f0c1b47b95d1 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -1050,9 +1050,12 @@ void 
SwWrtShell::InsertContentControl(SwContentControlType eType)
             break;
         }
     }
-    Insert(aPlaceholder);
-    Left(CRSR_SKIP_CHARS, /*bSelect=*/true, aPlaceholder.getLength(),
-            /*bBasicCall=*/false);
+    if (aPlaceholder.getLength())
+    {
+        Insert(aPlaceholder);
+        Left(CRSR_SKIP_CHARS, /*bSelect=*/true, aPlaceholder.getLength(),
+                /*bBasicCall=*/false);
+    }
     SwFormatContentControl aContentControl(pContentControl, 
RES_TXTATR_CONTENTCONTROL);
     SetAttrItem(aContentControl);
 }

Reply via email to