tdf#171370: a char must stringify to itself

Regression after commit 2143c0a694
(Simplify getter/setter implementations, 2025-06-03): sal_Unicode is
std::integral, and took the generic numeric path.

Co-authored-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Signed-off-by: Mike Kaganski <mike.kaganski@collabora.com>
Change-Id: I0c12590c06536f4d2efefcbe09657fff454ed2a4
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/8798
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit e725c25d6cb8c9cd1af08f70f6fea541df121b1d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209264
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Mike Kaganski
2026-08-19 08:36:23 +02:00
committed by Xisco Fauli
parent 1888a96efb
commit e59e33f064
2 changed files with 34 additions and 0 deletions
@@ -0,0 +1,32 @@
'
' This file is part of the LibreOffice project.
'
' This Source Code Form is subject to the terms of the Mozilla Public
' License, v. 2.0. If a copy of the MPL was not distributed with this
' file, You can obtain one at http://mozilla.org/MPL/2.0/.
'
Option Explicit
Function doUnitTest() As String
TestUtil.TestInit
verify_tdf171370
doUnitTest = TestUtil.GetResult()
End Function
Sub verify_tdf171370()
On Error GoTo errorHandler
Dim aEvent As New com.sun.star.awt.KeyEvent ' KeyChar is a UNO char
aEvent.KeyChar = 87
TestUtil.AssertEqual(TypeName(aEvent.KeyChar), "Char", "TypeName(aEvent.KeyChar)")
TestUtil.AssertEqual(CStr(aEvent.KeyChar), "W", "CStr(aEvent.KeyChar)")
TestUtil.AssertEqual("" & aEvent.KeyChar, "W", "concatenated aEvent.KeyChar")
TestUtil.AssertEqual(Len(aEvent.KeyChar), 1, "Len(aEvent.KeyChar)")
TestUtil.AssertEqual(Asc(aEvent.KeyChar), 87, "Asc(aEvent.KeyChar)")
Exit Sub
errorHandler:
TestUtil.ReportErrorHandler("verify_tdf171370", Err, Error$, Erl)
End Sub
+2
View File
@@ -136,6 +136,8 @@ template <> void assignTo<double>(SbxDecimal& dest, double n) { dest.setWithOver
template <> void assignTo<float>(SbxDecimal& dest, float n) { dest.setWithOverflow(n); }
template <std::integral I> void assignTo(OUString& dest, I n, bool) { dest = OUString::number(n); }
// tdf#171370: a character stringifies to itself, not to its numeric code
void assignTo(OUString& dest, sal_Unicode n, bool) { dest = OUString(n); }
void assignTo(OUString& dest, double n, bool bCoreString)
{
// tdf#107953 - show 17 significant digits