The bool return value of weld::TextWidget::get_selection_bounds
indicates whether a text selection actually exists.
Only use the start and end indices from the out params
if that is the case and otherwise return a default-constructed
Selection object (i.e. one using start and end indices of 0).
Otherwise, this would result in an assertion due to the use of
invalid string indices as seen with the qt6 vcl plugin and native
widgets enabled (SAL_VCL_QT_USE_WELDED_WIDGETS=1) for the following
scenario with upcoming commit
Change-Id: I10fcd9c326a047cf4abd34369f02be1847d77ae1
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Wed Jul 22 14:20:53 2026 +0200
tdf#130857 qt weld: Support Calc "Edit Print Ranges" dialog
in place:
* start Calc
* "Format" -> "Print Ranges" -> "Edit..."
* click on the "Shrink" button in the "Print Range" section
* click anywhere in the sheet
Assertion:
soffice.bin: /home/michi/development/git/libreoffice/sal/rtl/strtmpl.hxx:1059: void rtl::str::newReplaceStrAt(rtl_tString **, rtl_tString *, sal_Int32, sal_Int32, rtl_tString *) [rtl_tString = _rtl_uString]: Assertion `nIndex >= 0 && nIndex <= pStr->length' failed.
This is because QtInstanceEntry::get_selection_bounds
sets the indices to -1 if no selection exists.
Change-Id: Ifc8fd6f6a6d676fe26364da9077cb10acb439a5a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208474
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>