summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-05-09 11:19:48 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-05-09 12:27:54 +0200
commit0db2cd321fef8db7c17c6c588b6593c7d59a9688 (patch)
tree1751ce5aa84663207c7752fc22ea892098529cac /sw/source/uibase
parent0c87c0b87a3bbc2c57b2dd65ba2dd0aeb2f0b0c3 (diff)
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 <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx9
1 files changed, 6 insertions, 3 deletions
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);
}