From ae40b2f223ad27562161008c7c1b718136a6480f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Sun, 1 Sep 2024 18:10:44 +0700 Subject: [PATCH] libreoffice: fix build on 32 bit platform --- ...explicit-std-max-template-specializa.patch | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 srcpkgs/libreoffice/patches/0001-gtk4-a11y-Avoid-explicit-std-max-template-specializa.patch diff --git a/srcpkgs/libreoffice/patches/0001-gtk4-a11y-Avoid-explicit-std-max-template-specializa.patch b/srcpkgs/libreoffice/patches/0001-gtk4-a11y-Avoid-explicit-std-max-template-specializa.patch new file mode 100644 index 00000000000..95f71bbc5c4 --- /dev/null +++ b/srcpkgs/libreoffice/patches/0001-gtk4-a11y-Avoid-explicit-std-max-template-specializa.patch @@ -0,0 +1,53 @@ +From 82b648edd78ade6051d35657ac8e143946ce1254 Mon Sep 17 00:00:00 2001 +Message-ID: <82b648edd78ade6051d35657ac8e143946ce1254.1725189001.git.congdanhqx@gmail.com> +From: Michael Weghorn +Date: Mon, 12 Aug 2024 07:01:29 +0200 +Subject: [PATCH] gtk4 a11y: Avoid explicit std::max template specialization + +Thanks to Mike Kaganski for pointing out this is the better +way to do it in [1]: + +> In these cases, it's best to avoid the explicit template specialization, +> but instead, do something like +> +> std::max(sal_Int32(0), xText->getCaretPosition()) +> +> because this latter form makes sure that it will not create problems +> later at some unknown point in time, when we decide to change the +> type of the returned value of the function. When that happens, your +> form would silently continue to cast both its parameters to +> sal_Int32, maybe overflowing. In the proposed form, this max would +> break again, because the sal_Int32(0) would now not match the type +> of getCaretPosition, and require us to revisit this code, and make +> correct changes. +> +> It is indeed ~impossible in the specific case of the UNO API method; +> but the best practice is that, and having inconsistency in the +> codebase is sub-optimal ;-) + +[1] https://gerrit.libreoffice.org/c/core/+/171687/comment/35580611_5d9dfe85/ + +Change-Id: I489bf4fe5ca12833bc17849434822b984a8586a2 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171744 +Reviewed-by: Michael Weghorn +Tested-by: Jenkins +--- + vcl/unx/gtk4/gtkaccessibletext.cxx | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/vcl/unx/gtk4/gtkaccessibletext.cxx b/vcl/unx/gtk4/gtkaccessibletext.cxx +index 6925b7ba6d56..66934708e529 100644 +--- a/vcl/unx/gtk4/gtkaccessibletext.cxx ++++ b/vcl/unx/gtk4/gtkaccessibletext.cxx +@@ -102,7 +102,7 @@ static unsigned int lo_accessible_text_get_caret_position(GtkAccessibleText* sel + if (!xText.is()) + return 0; + +- return std::max(0, xText->getCaretPosition()); ++ return std::max(sal_Int32(0), xText->getCaretPosition()); + } + + static gboolean lo_accessible_text_get_selection(GtkAccessibleText* self, gsize* n_ranges, +-- +2.46.0.rc2 +