[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - desktop/source vcl/source
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Mon May 18 13:55:25 UTC 2020
desktop/source/lib/init.cxx | 2 +-
vcl/source/control/field.cxx | 25 ++++++++++++++++++++++++-
2 files changed, 25 insertions(+), 2 deletions(-)
New commits:
commit 432dd816c7bbf69542f07cb6c98b9a2cd225e95b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Jun 17 23:32:04 2019 -0400
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon May 18 15:45:48 2020 +0200
vcl: better decimal handling in NumericFormatter
When the user deletes the decimal point from
MetricBox, it ends up with the number
with the fractional portion (to the right of
the decimal point) appended to it, which is
(with two decimal points) a 100x larger value.
This makes such editing smarter. In the case
that we detect that the user deleted the
decimal point (which we know should've been
there, because we have a configured fixed
number of decimal points,) we restore it.
This makes it more intuitive, since when
the user enters digits, they get the correct
and expected result, but when they delete the
decimal point, they almost always didn't mean
to grow the number 100x. If that was the goal,
they could enter two extra digits before
the decimal point.
In addition, we set the default maximum to
a more user-friendly value of a million,
instead of int-max, which seems like a
random number to the uninitiated.
Change-Id: Ib535f06e4f111d20f35c4209ad65969dca5928e8
Reviewed-on: https://gerrit.libreoffice.org/75511
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
(cherry picked from commit 42761c688053155ae87628e69eb4d2a28e6c78e6)
Reviewed-on: https://gerrit.libreoffice.org/78453
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
(cherry picked from commit e9a48869fe1f1e90c03d299ae419ea5b1f43de50)
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index 6307b9ae49d7..6d518486fe84 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -201,6 +201,29 @@ bool ImplNumericGetValue( const OUString& rStr, sal_Int64& rValue,
aStr1.append(std::u16string_view(aStr).substr(0, nDecPos));
aStr2.append(std::u16string_view(aStr).substr(nDecPos+1));
}
+ else if (nDecDigits > 0 && aStr.getLength() > nDecDigits)
+ {
+ // We expect a decimal point and a certain number of decimal digits,
+ // but seems the user has deleted the decimal point, so we restore it.
+ // Otherwise, they end up with unexpectedly (to them) large numbers.
+
+ // Find the first digit from the right.
+ sal_Int32 nVirtualDecPos = aStr.getLength();
+ while (--nVirtualDecPos > 0)
+ {
+ if ((aStr[nVirtualDecPos] >= '0') && (aStr[nVirtualDecPos] <= '9'))
+ break;
+ }
+
+ if (nVirtualDecPos >= nDecDigits)
+ {
+ nVirtualDecPos -= nDecDigits - 1; // nVirtualDecPos is already on a digit (so discount it).
+ aStr1.append(aStr.getStr(), nVirtualDecPos);
+ aStr2.append(aStr.getStr() + nVirtualDecPos);
+ }
+ else
+ aStr1 = aStr;
+ }
else
aStr1 = aStr;
@@ -540,7 +563,7 @@ void NumericFormatter::ImplInit()
mnFieldValue = 0;
mnLastValue = 0;
mnMin = 0;
- mnMax = SAL_MAX_INT32;
+ mnMax = 100000000; // A user-friendly round number.
// a "large" value substantially smaller than SAL_MAX_INT64, to avoid
// overflow in computations using this "dummy" value
mnDecimalDigits = 2;
commit c2f5b4fc0a67118dd89ef86a40bc854b80b54a1a
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Mar 10 12:21:33 2019 -0400
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon May 18 15:44:52 2020 +0200
LOK: don't segfault when reporting error
Change-Id: Ia6d614eb15b15f43ddd3e0b5742b888060dfd581
Reviewed-on: https://gerrit.libreoffice.org/69069
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
(cherry picked from commit 9fa568dced78011072390320f64eae28dd06d2b9)
Reviewed-on: https://gerrit.libreoffice.org/78443
(cherry picked from commit fa18cdce824525ebd76b542a44741a35062741ce)
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 505ce91e8da5..c86b2eb72dd4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3824,7 +3824,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
else
bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector));
- if (!bResult)
+ if (!bResult && gImpl)
{
SetLastExceptionMsg("Failed to dispatch " + aCommand);
}
More information about the Libreoffice-commits
mailing list