summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-01-17 10:03:49 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-01-24 09:26:18 +0000
commit37fa60e6289b4c7ed88fd7b107af807211fd1ad9 (patch)
tree458ce4b7ce37cdb7859a2eadd79c2f4edc605399
parenttdf#105014: Disable related buttons when there is no menu to edit (diff)
downloadcore-37fa60e6289b4c7ed88fd7b107af807211fd1ad9.tar.gz
core-37fa60e6289b4c7ed88fd7b107af807211fd1ad9.zip
tdf#105212: BASIC sets Delimiter prop to integer value
LO's BASIC doesn't have first-class support for the UNO CHAR type, often uses integer values to represent such CHAR values (cf. <https://wiki.openoffice.org/ wiki/Documentation/DevGuide/ProUNO/Basic/Mapping_of_Simple_Types>). Since 0b07406f7147b9abbb2095d9e038b13293cb8b10 "Use C++11 char16_t for sal_Unicode" (for non-Windows, since LO 5.1) resp. e16fa715c43dcdf836ce8c400b6d54eae87b627d "Handle wchar_t as native C++11 type on windows" (for Windows, since LO 5.2), C++ css::uno::Any >>=, <<=, etc. with a sal_Unicode argument no longer silently treat the argument as sal_uInt16 instead. That means that BASIC code putting an integer value into a UNO ANY that shall hold a value of CHAR type may no longer work. (Arguably, such code only ever happened to work by coincidence. For example, if the ANY were processed by Java instead of C++ code, it would never have worked.) Luckily, the use of CHAR in the UNO API is rare (for a good reason, as a single UTF-16 code unit is hardly ever the right choice to represent "a character"). The only documented place I could find using a CHAR property is Delimiter in the css.text.TextSortDescriptor and css.text.TextSortDescriptor2 services. And the only processing of such a property that I could find across the LO code base is in the file modified here, which thus just takes a one-off special effort to take care of this problem. The direction from C++ to BASIC is left as-is. The value of the Delimiter property is now reported as a CHAR value (where in the past it was---arguably erroneously---reported as an UNSIGNED SHORT value), and BASIC is generally capable of handling such CHAR values it receives well. For example, in the BASIC code attached to tdf#105212, > MsgBox("Sort: " + SortDesc(1).Name + " = " + SortDesc(1).Value) SortDesc(1).Value will now print a (space) character instead of its numeric value (32). Also, any other uses of individual CHAR values in the UNO API apart from properties appear to already be handled well enough by BASIC, as the sample code > Sub Main > tk = createunoservice("com.sun.star.awt.Toolkit") > dev = tk.createScreenCompatibleDevice(100, 100) > descs = dev.getFontDescriptors() > msgbox("Font """ + descs(1).Name + """") > font = dev.getFont(descs(1)) > n = font.getCharWidth(97) ' 'a' > msgbox("Width 'a' = " + n) > met = font.getFontMetric() > msgbox("FirstChar = '" + met.FirstChar + "', LastChar = '" + met.LastChar + "'") > met.LastChar = 122 ' 'z' > msgbox("New LastChar = '" + met.LastChar + "'") > > trans = createunoservice("com.sun.star.i18n.Transliteration") > c1 = trans.transliterateChar2Char(97) ' 'a' > c2 = trans.transliterateChar2Char(c1) > msgbox("Transliterate, '" + c1 + "' '" + c2 + "'") > End Sub demonstrates. Change-Id: I2aec1ce374c024bfac61f6c832241dfeb561addc (cherry picked from commit 1b835cdb5ef4cebeae729b1edf2a773f4a582c0f) Reviewed-on: https://gerrit.libreoffice.org/33212 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit 1eadd137ade5e2c4361990cce3f153e46110a1e9) Reviewed-on: https://gerrit.libreoffice.org/33248 Reviewed-by: Eike Rathke <erack@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/source/core/unocore/unoobj.cxx7
1 files changed, 7 insertions, 0 deletions
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index c3b1300aa31c..9c9bb65e4a3f 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -2688,10 +2688,17 @@ bool SwUnoCursorHelper::ConvertSortProperties(
else if ( rPropName == "Delimiter" )
{
sal_Unicode uChar;
+ sal_uInt16 nChar;
if (aValue >>= uChar)
{
rSortOpt.cDeli = uChar;
}
+ else if (aValue >>= nChar)
+ {
+ // For compatibility with BASIC, also accept an ANY containing
+ // an UNSIGNED SHORT:
+ rSortOpt.cDeli = nChar;
+ }
else
{
bRet = false;