From 74e3f47723471f3ed4dc2dbffc95085bb04d9504 Mon Sep 17 00:00:00 2001 From: Heiko Tietze Date: Tue, 17 Sep 2024 11:54:10 +0200 Subject: [PATCH] Resolves tdf#162979 - Avoid oversized online update options Don't wrap at every semicolon but only after 50 chars Change-Id: I91993d503c574a9c60d390afde159ade73567861 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173552 Reviewed-by: Heiko Tietze Tested-by: Jenkins --- cui/source/options/optupdt.cxx | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/cui/source/options/optupdt.cxx b/cui/source/options/optupdt.cxx index 71433ab2258f..71bd03a4e670 100644 --- a/cui/source/options/optupdt.cxx +++ b/cui/source/options/optupdt.cxx @@ -190,6 +190,25 @@ void SvxOnlineUpdateTabPage::UpdateLastCheckedText() m_xLastChecked->set_label(aText); } +static inline OUString WrapString(const OUString& aStr) +{ + OUString sResult; + OUString sPos; + int nPos = 0; + for (int i = 0; i < aStr.getLength(); i++) + { + sPos = aStr.subView(i, 1); + sResult += sPos; + if ((nPos > 50) && (sPos == ";")) + { + sResult += "/n"; + nPos = 0; + } + nPos++; + } + return sResult; +} + void SvxOnlineUpdateTabPage::UpdateUserAgent() { try { @@ -209,9 +228,7 @@ void SvxOnlineUpdateTabPage::UpdateUserAgent() if ( aHeader.First == "User-Agent" ) { OUString aText = aHeader.Second; - aText = aText.replaceAll(";", ";\n"); - aText = aText.replaceAll("(", "\n("); - m_xUserAgentLabel->set_label(aText); + m_xUserAgentLabel->set_label(WrapString(aText)); break; } }