sw/source/uibase/docvw/edtwin.cxx | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)
New commits: commit 267d2d721c7e89a7b5f28ce0a4fee87d37ee2c61 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun Jan 19 11:42:23 2020 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Mon Jan 20 05:42:01 2020 +0100 Simplify getting ISO 8601 date string Change-Id: If381276990199e4459787ffea090f342241237f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87037 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index c802664c8aeb..1a81d0851182 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -58,6 +58,7 @@ #include <editeng/flditem.hxx> #include <editeng/colritem.hxx> #include <unotools/charclass.hxx> +#include <unotools/datetime.hxx> #include <comphelper/lok.hxx> #include <sfx2/lokhelper.hxx> @@ -5986,24 +5987,13 @@ void QuickHelpData::FillStrArr( SwWrtShell const & rSh, const OUString& rWord ) // Add matching current date in ISO 8601 format, for example 2016-01-30 OUString rStrToday; - if (rWord[0] == '2') - { - (*pCalendar)->setGregorianDateTime(Date(Date::SYSTEM)); // tdf#130066: reset today - OUStringBuffer rStr(""); - rStr.append(sal::static_int_cast< sal_Int32 >((*pCalendar)->getValue(i18n::CalendarFieldIndex::YEAR))).append("-"); - sal_Int32 nMonth = sal::static_int_cast< sal_Int32 >((*pCalendar)->getValue(i18n::CalendarFieldIndex::MONTH)+1); - sal_Int32 nDay = sal::static_int_cast< sal_Int32 > ((*pCalendar)->getValue(i18n::CalendarFieldIndex::DAY_OF_MONTH)); - if (nMonth < 10) - rStr.append("0"); - rStr.append(nMonth).append("-"); - if (nDay < 10) - rStr.append("0"); - rStrToday = rStr.append(nDay).toString(); - - // do not suggest for single years, for example for "2016", - // only for "201" or "2016-..." (to avoid unintentional text - // insertion at line ending, for example typing "30 January 2016") - if (rWord.getLength() != 4 && rStrToday.startsWith(rWord)) + // do not suggest for single years, for example for "2016", + // only for "201" or "2016-..." (to avoid unintentional text + // insertion at line ending, for example typing "30 January 2016") + if (!rWord.isEmpty() && rWord.getLength() != 4 && rWord[0] == '2') + { + rStrToday = utl::toISO8601(DateTime(Date(Date::SYSTEM)).GetUNODateTime()); + if (rStrToday.startsWith(rWord)) m_aHelpStrings.emplace_back(rStrToday, rWord.getLength()); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits