sw/source/uibase/wrtsh/wrtsh1.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
New commits: commit 6d382506d2c82b3e07c5c33a0ca615a3a869dd11 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon May 9 11:19:48 2022 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed May 11 16:43:38 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. (cherry picked from commit 0db2cd321fef8db7c17c6c588b6593c7d59a9688) Change-Id: I8370b8d74415faf0e76dccb574aa29bea1947bb8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134146 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index a009416f1d24..576ffdec5b5d 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -1045,9 +1045,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); }