456 Commits
Author SHA1 Message Date
Andrea Gelmini e330ca20a7 Fix typos
Change-Id: I351603ac840304c7697d269e216b8227fae40f75
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210445
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2026-09-03 09:00:23 +02:00
Andrea Gelmini 37e1aec4ed Fix typos
Change-Id: I121af263271437cf4013ef006d401a06ba3507b0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210444
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2026-09-03 08:54:54 +02:00
Andrea Gelmini 4f86cfa577 Fix typos
Change-Id: Ic09e8f2877a7106eb074586662d1733828d85197
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209422
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
2026-08-21 14:19:46 +02:00
Xisco Fauli e1f9e8beb4 Revert "sal: remove MD2, SHA, HMAC_MD5 digests"
it breaks the published API

This reverts commit e4892750c3.

Change-Id: Id072882efc432cdbc3c20a6bcece1369f9a78bf4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209385
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-08-20 15:43:22 +02:00
Xisco Fauli aac090211d Revert "sal: remove rtl_createNamedUuid"
it breaks the published API

This reverts commit 3bad9e2daa.

Change-Id: If6f0b7f8d4a52415bd9fdacde20d9ec1643f590e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209384
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-08-20 15:43:08 +02:00
Michael Stahl e4892750c3 sal: remove MD2, SHA, HMAC_MD5 digests
These are all obsolete and unused:
`rtl_Digest_AlgorithmMD2`
`rtl_Digest_AlgorithmSHA`
`rtl_Digest_AlgorithmHMAC_MD5`

Adapt `rtl_digest.cxx` to use some random other digest instead.

Signed-off-by: Michael Stahl <michael.stahl@collabora.com>
Change-Id: I886297bec6fafbc56afabd212517a8f4478f3253
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/4669
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
(cherry picked from commit 2e0c87ff340d7ea99afd638ebb9bd7bb36e53afc)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207148
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-06-23 13:16:38 +02:00
Michael Stahl 3bad9e2daa sal: remove rtl_createNamedUuid
This has never been called in the git history, other than by its test.

Signed-off-by: Michael Stahl <michael.stahl@collabora.com>
Change-Id: Ic233632a3656fe125f71a944afdedb8687627e78
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/4670
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
(cherry picked from commit fbf2894e11b2411c3fd9c06fa0cc490c6570bdc7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207149
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-06-23 11:22:49 +02:00
Noel Grandin 3a46865a64 simplify MSC_VER conditionals
we require _MSC_VER >= 1930 now

Change-Id: I493a3fe4267c8ea148d411535b9de24666154722
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/2887
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit adb5dce15a169d0142f40eb8efff94c6822c7dbc)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206640
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-06-16 01:20:43 +02:00
Neil Roberts 745c5a1fa4 string: Fix documentation for char versions of endsWith/startsWith
Some of the methods added in the commit below had the wrong name for the
character parameter in the documention.

commit ab871d3af9
Author: Neil Roberts <nroberts@libreoffice.org>
Date:   Sun Apr 26 12:00:28 2026 +0200

    [API CHANGE] rtl/string: Add startsWith/endsWith for a single character

Change-Id: I47eec8a7a6aca75f5735e3158125efc4cb44c734
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205716
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-05-26 17:40:25 +02:00
Neil Roberts ab871d3af9 [API CHANGE] rtl/string: Add startsWith/endsWith for a single character
A lot of places in the code are calling OUString::endsWith with a string
containing a single character. Similar to lastIndexOf, this patch
provides overloads to the two methods to have an optimised version for
the case when there is only one character.

It would be kind of nice if the compiler could handle this optimisation
itself, but it’s unlikely to work because the string version of endsWith
ends up calling rtl_ustr_shortenedCompare_WithLength which isn’t inline
and is defined outside of a header.

The main incentive to do this is to make it easier to change calls to
lastIndexOf that should really be endsWith, as in tdf#171853.

Change-Id: Iaba5a7db3211eb12b0a83f441c0a81e664da6eea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204363
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-04-30 06:33:28 +02:00
Swarnadeep Paul 560efd29ea tdf#146619 Cleanup/Removal of headerfiles
Change-Id: Ic5b44d5d9e1f9b099f8dafac0ce90db3e510fb87
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203518
Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
Tested-by: Jenkins
2026-04-15 17:31:51 +02:00
Jakub Trzebiatowski 0430226229 tdf#129606 move approxDiff to rtl::math and fix ARM64 rounding errors
Move the approxDiff heuristic from the sc unnamed namespace to rtl::math and
disable floating-point contraction (FMA) for this function.

On ARM64 (Apple Silicon), the use of Fused Multiply-Add (FMA) results in
higher intermediate precision during floating-point operations. While
mathematically more accurate, this prevents legacy rounding heuristics in
approxDiff and approxValue from detecting and cleaning rounding artifacts
in series generation (e.g., 1.1 - 1.0).

Disabling fp-contract forces intermediate rounding to 64-bit IEEE 754
limits. This ensures the noise expected by the approximation logic is
present, restoring consistency with x86-64 behavior and fixing issues where
values like 6.0 are incorrectly rendered as 6.00000000000001.

Change-Id: I54a0f748be6cf817db1f3bdcfd2b355320c3a617
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203233
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
2026-04-08 20:37:27 +02:00
Stephan Bergmann 8fb5be18f8 Use OStringBuffer as a pad for the mutable string passed to mkstemp
...by introducing OStringBuffer::getMutableStr and (for consistency)
OUStringBuffer::getMutableStr

Change-Id: I4dfc3b8d8ffb49b8b3742600081d075536b312e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197605
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Tested-by: Jenkins
2026-01-20 07:33:22 +01:00
Mike Kaganski d1fc7efb90 Introduce Repeated(U)Char for concatenation of N repeated characters
... and use in sw.

Should replace padToLength, where the number of added characters is
known in advance. Avoids creation of a string buffer for the task.

Change-Id: I90450e37926335d74421c6e38385e4c441e535d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190341
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-08-29 01:00:26 +02:00
Caolán McNamara 29063bb3ca cid#1438474 resilence Logically dead code
Change-Id: I3af124e65e3902e3759e1311f155cba557338df6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189400
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2025-08-12 12:06:59 +02:00
Caolán McNamara d752e23e41 drop coverity workarounds that no longer seem needed
since version 2024

Change-Id: I81b3c04087f0f9db181311cbfdd95a04b229b1be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189276
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2025-08-10 11:51:43 +02:00
Caolán McNamara 86030d8b00 cid#1438474 Still needed for coverity 2024
Change-Id: Ifc1c2999b00f13d164c3a467229f1c7cbdaea395
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188510
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2025-07-29 00:23:01 +02:00
Stephan Bergmann 37db2eaa1d Make O[U]String default ctors constexpr
(with the same caveats for MSVC /clr code as discussed in
5a40abc86b "Drop some newly obsolete __cplusplus
version checks")

Change-Id: I080a37029479155ec4135732c4d5dd0caba4f5dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188236
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-07-24 17:13:37 +02:00
Mike Kaganski d1ed511e42 Fix ToStringHelper<sal_Unicode[ N ]>
It must only add characters up to terminating null, as its counterpart
ToStringHelper< char[ N ] > does, and as its own length implies.

Was this way ever since commit f1769094af
(round out StringConcat helpers with sal_Unicode* overloads, 2019-10-11).

Change-Id: I3e267789333dac23754e67b19ff596ad359868aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187791
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-07-13 14:12:52 +02:00
19e5551130 sal: osl::File sand-boxing for Unix
This is a combined cherry-pick of the 10 commits
34f1a750a128e02aa3191e36a2c0b28371e96287 "sal: initial osl::File sand-boxing
commit for Unix.", 55243a397add76fcff8c67284ba57205a1512ca5 "lok: import allowed
paths from the SAL_ALLOWED_PATHS.", 148915ef6d4bfc38deb6d98fb14429d7e6e27129
"sal: osl::File allow to create files in sandbox",
479e2f5cb69ceef2ef6832630a342d7673d6782a "unconditionally include vector",
f04d38d5a88f422b80d2a37d1a1252ce59c4f892 "Fix SDK build",
52e0838a8f35837a92e7b0277544995e477fe8b6 "sal: fix various clang loplugin
warnings", 3ed325340d14cb28602fb03eb6a46b37cdb8bb99 "[loplugin:unreffun]",
242ccc31d5a2c8be900828523de145e173900514 "Avoid extending the sal UNO API",
3c633a88c5212d8dd665d7bcb9678fa1eac1464f "Stick to sal_uInt32 for
osl_File_OpenFlags", and f4d48ac9cdb822e2c2d3fc1f239fe0958f608cc2 "Fix linking
new CppunitTest_sal_osl_file_details on macOS/Windows".

Co-authored-by: Andras Timar <andras.timar@collabora.com>
Co-authored-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Co-authored-by: Michael Meeks <michael.meeks@collabora.com>
Co-authored-by: Mike Kaganski <mike.kaganski@collabora.com>
Co-authored-by: Miklos Vajna <vmiklos@collabora.com>
Co-authored-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I5220bef367350d8fac8c25d7f40988664b9a8bd5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187411
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-07-07 15:37:55 +02:00
Mike Kaganski 516257d52f Simplify a bit
Change-Id: I62306fe572717c807b68b8329e9c5b04c9935583
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186158
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-06-07 08:14:34 +02:00
Mike Kaganski d57d001e27 Simplify ToStringHelper a bit
This helped me to workaround a very mysterious problem, that appeared
in non-debug build (using VS2022 17.14.0 preview 2.0), where a concat
in cppuhelper::ServiceManager::addSingletonContextEntries looking like
"/singletons/" + u"com.sun.star.configuration.theDefaultProvider"_ustr
gave "/single/sincom.sun.star.configuration.theDefaultProvider". The
problem has survived three 'make clean' and rebuild. No idea what was
the reason: maybe a specific VS (preview) version's optimization bug?
Or do we do some spooky memory rewrite somewhere, which happened to
surface in this case? The workaround helping me is obviously because
of some code reorganization in the compiler, not caused by functional
change. (Just for completeness: another workaround was to replace the
literal "/singletons/" with u"/singletons/", which also helped.)

Change-Id: If01823ccafb6b4c44f99f9a39d849d7c425cc069
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183195
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-03-21 14:02:36 +01:00
Julien Nabet b3dd1e92af Revert "tdf#152299 - Remove unused define(s) from C/C++ files"
This reverts commit 16a5ae7c90.

It seems to break public API.

Change-Id: I0ef2c6e975b4cf20b9894ddf33f36444e2230ca4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177168
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2024-11-24 09:55:40 +01:00
Bogdan Buzea 16a5ae7c90 tdf#152299 - Remove unused define(s) from C/C++ files
Change-Id: Iac23bad883f54bd980d051fe74474efdcd2572a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177063
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
2024-11-23 09:47:34 +01:00
Noel Grandin bd8539dfd1 add an EMPTY_OUSTRING in OUString header
we already declare the same thing in various places,
and I intend to be using this some more, so it makes
sense to only declare it in one place

Change-Id: Ifea6b589e992dd9f6cd8f2301f837e71397481c8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176046
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-11-06 09:25:10 +01:00
Caolán McNamara 3ef8075040 version COVERITY conditionals
so there's a recheck on each major if they are still needed

Change-Id: I351f731fe4eaec0ebf735147a9a168cccba3bca5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174883
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-10-14 13:07:37 +02:00
Gabriel Masei 565b619d57 tdf#160582 Preserve settings saving in csv import dialog
Also, improve detection algorithm by replacing the limit
of 20 lines with a time limit of 500ms.

Change-Id: Iac519b6ebe675b91ce84b900646d9d320ea9ddc1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165905
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Jenkins
2024-10-09 14:49:11 +02:00
Noel Grandin 59915ec921 in OUString find functions, assert that fromIndex >= 0
otherwise, the pointer calculations mean that we will start searching
inside data that does not belong to the character array.

which flushes out a couple of problem cases

Change-Id: Ide9edf23900289343077c406d95614057c1d1a6c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173807
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-09-24 12:09:41 +02:00
Caolán McNamara 3231db0341 cid#1618764 Operands don't affect result
Change-Id: I4faf81b030f3f7b704b25e4817f0ec6c07be4e79
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172977
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-09-08 21:58:11 +02:00
Mike Kaganski 30e52b155c Simplify a bit
Change-Id: Icaf2e821984d9cdb16dbc4910b65b9b2b824435a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172583
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2024-08-30 20:59:16 +02:00
Noel Grandin e67e515570 fix @since tags
after
    commit 1bbcc3fdf3
    Author: Noel Grandin <noel.grandin@collabora.co.uk>
    Date:   Tue May 14 14:56:47 2024 +0200
    O[U]String overloads that return view for rest parameter

Change-Id: Ie1d844f4286a14aa9d7cbb3831460c17103582c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171477
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-08-05 19:29:48 +02:00
Mike Kaganski 550ef55881 Reintroduce OUString::replaceAt taking an OUString to LIBO_INTERNAL_ONLY
This allows optimizations when 'this' is empty, avoiding allocations, and
making it possible to not special-case it in other places, as was done in
ContentNode::Insert in commit 8ab44b114c
(tdf#161846 avoid allocation in ContentNode::Insert, 2024-07-30).

A couple of disambiguation templated overloads was introduced.

Change-Id: I2b5e94c2175379b2696c34e600393d32731f0ab6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171271
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-07-31 12:15:38 +02:00
Mike Kaganski 18ed2be7f1 Prevent rtl::Reference -> css::uno::Reference -> rtl::Reference implicit path
Replace up-casting conversion constructor with respective conversion operator,
similar to existing css::uno::Reference conversion operator. Thic change will
not allow code like

  rtl::Reference<Foo> foo;
  rtl::Reference<Foo> bar(foo, uno::UNO_QUERY_THROW);

which was possible because compiler could use temporary css::uno::Reference.

Change-Id: I54b79af3e2508b26e9cd59f2cc7e2ae92f6efbbf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171166
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-07-29 15:21:39 +02:00
Mike Kaganski a79f9a7932 Delegate match to main internal starts/endsWith*
This simplifies and deduplicates the code, and even where it was simple,
it has an advantage that if a change in algorithm is decided, it is done
in a single place.

Change-Id: I9ec55a29c5f2b2c972ac81bf07c20fc0a52a2a8b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171033
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2024-07-26 11:52:55 +02:00
Noel Grandin 1bbcc3fdf3 O[U]String overloads that return view for rest parameter
Add new overloads to OUString methods that have a
"OUString* rest" style parameter.

Instead return a view, which does not require allocation.

To avoid overload ambiguity, split the methods into
different variants that do not use default parameters.

Change-Id: I1aa366115750f1f7ea4fe665804195f59f7c4b69
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167632
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2024-07-25 13:29:11 +02:00
Andrea Gelmini cdcc76802d Fix typo
Change-Id: I30c31ea6c17bd4a27109d2dfb641b9cb5d6922a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169240
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-06-19 22:52:59 +02:00
Caolán McNamara e5aa87aeeb drop requirement for rtl_random_getBytes to have "Pool" arg
Seeing as since:

commit e9531b792d
Date:   Tue Feb 6 14:39:47 2024 +0100

    sal: rtlRandomPool: require OS random device, abort if not present

    Both rtl_random_createPool() and rtl_random_getBytes() first try to get
    random data from the OS, via /dev/urandom or rand_s() (documented to
    call RtlGenRandom(), see [1]).

we don't use the initial arg to rtl_random_getBytes anymore, drop the
requirement to have one. Then simplify our usages of that, and
addtionally deprecate rtl_random_createPool and rtl_random_destroyPool.

Change-Id: I13dcc067714a8a741a4e8f2bfcf2006373f832c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167067
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-05-08 11:29:54 +02:00
Caolán McNamara 5354d8fb17 WaE: C6326: Potential comparison of a constant with another constant
if msvc -analyze is used

Change-Id: I5905447a79e8e50d70281e0c230d1ce3b13fc475
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166704
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-04-29 09:29:50 +02:00
Noel Grandin e8b9bcf021 map SAL_DLLPUBLIC_RTTI to visibility:default for gcc
Because I want to make more symbols private, but that runs into a
problem with the special symbol "typeinfo for Foo" which is required for
dynamic_cast.

For clang, we can use SAL_DLLPUBLIC_RTTI to make just that magic
"typeinfo for Foo" symbol visible.

But for gcc, we are left with no option but to make the whole class
visible via <MODULE>_DLLPUBLIC.
(I have a feature request logged against gcc to support something like
that at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113958)

But I also don't want to use <MODULE>_DLLPUBLIC, since that blocks
progress of reducing symbol visibility for platforms other than gcc.

So map SAL_DLLPUBLIC_RTTI to visiblity:default for gcc, which means that
only gcc suffers the negative affects of not having that annotation.

However, that runs into the problem that gcc does not like
visibility:default in a couple of places, so I have to introduce some
extra preprocessor stuff.

Change-Id: Ib4fc5c1d2a1f8cf87d5159a4b5684137ec061605
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164356
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-03-05 14:39:06 +01:00
Mike Kaganski 40336ee0b4 Simplify a bit
Change-Id: I9fbc43916fe0d7af87001e48854a87636115a1f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164133
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-29 07:24:00 +01:00
Stephan Bergmann 8b53fa726e Introduce a fundamental.override.ini for bootstrap variables
...that is looked for next to the application and, when present, overrides all
the other ways of setting bootstrap variables.  LibreOffice itself does not
bring along such a fundamental.override.ini, but it can be convenient for an
administrator to place one in the installation (which can then not be modified
or overridden by end users).

(For convenience, the naming of this ini-file starts to deviate from the old and
rather pointless tradition of naming our ini-files *rc vs. *.ini on different
platforms.)

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162187
Tested-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
(cherry picked from commit f4d376e9a10a8c66f7f6ecfe6a1f4763c1927b52)
Conflicts:
	sal/rtl/bootstrap.cxx

Change-Id: I057cc67b1af1d806587c3a4dc0bc31c28e79d22b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163251
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-02-12 19:02:13 +01:00
Michael Stahl e9531b792d sal: rtlRandomPool: require OS random device, abort if not present
Both rtl_random_createPool() and rtl_random_getBytes() first try to get
random data from the OS, via /dev/urandom or rand_s() (documented to
call RtlGenRandom(), see [1]).

In case this does not succeed, there is a fallback to a custom
implementation of a PRNG of unknown design that has never been
substantially changed since initial CVS import, and is presumably not
what would be considered state of the art today, particularly if there's
no actual entropy available to seed it.

Except for a few miscellaneous usages in URE (presumably to avoid
dependencies on non-URE libs), rtlRandomPool is almost always used to
generate material for encryption of documents, which is demanding and
probably beyond what a pure user-space PRNG implementation without
entropy from the OS can provide.

So remove the custom PRNG and instead abort() if reading from the OS
random device fails for whatever reason.

rtl_random_addBytes() becomes a no-op and is therefore deprecated.

Presumably the only kind of environment where random device would be
unavailable in practice is running in some sort of chroot or container
that is missing the device or has incorrect permissions on it; better to
fail hard than to produce encrypted documents of questionable security.

[1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/rand-s?view=msvc-170

Change-Id: I3f020c2d11570f8351381d70188ce59bfec9f720
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163056
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2024-02-07 11:15:47 +01:00
Caolán McNamara 5950db59fc suppress COPY_INSTEAD_OF_MOVE suggestions for rtl::O[U]String
where we have implemented move assignment to take let the compiler take
advantage of any little optimization possibilities that it can take but
where the potential optimization probably doesn't outweigh enforcing
dusting error-prone std::move all over every case where the compiler
doesn't/can't use the move assignment but could.

so convert the myriad of micro optimization warnings into a single
missing move assignment warning which can be then suppressed.

Change-Id: I664193f9a2ac5014cf8d5134105ebd3a36857830
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162494
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-01-24 14:32:41 +01:00
Caolán McNamara db44ffd219 suppress COPY_INSTEAD_OF_MOVE suggestions for uno::Reference
rtl::Reference, uno::Any and rtl::O[U]String

where we have implemented move ctors to take let the compiler take
advantage of any little optimization possibility that it can take
but where the potential optimization probably doesn't outweigh
enforcing dusting error-prone std::move all over every case where
the compiler doesn't/can't use the move ctor but could.

Change-Id: Icf184d96d3278a1740a76c7eb1150e60392351ab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162337
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-01-20 20:54:42 +01:00
Mike Kaganski 4eeb6178fb tdf#159018: make 64-bit hash algorithm similar to 32-bit one
The magic of choosing a substitution font depends on the order of
fontfaces returned from PhysicalFontCollection::GetFontFaceCollection
(called from WinGlyphFallbackSubstititution::FindFontSubstitute).
Since commit db04b3e154 (return 64-bit
hash for O[U]String, 2022-08-22), the order has changed, which
resulted in different fallbacks in some documents (which aren't
well-formed in respect to their formatting, so when they work,
it's just luck).

The difference was because the 64-bit hash implementation was
modelled after Java one. This patch makes the code follow the
algorithm in rtl::str::hashCode_WithLength, used in 32-bit hash,
which restores the order (at least for my system). Not reliable,
just "why not".

Change-Id: I3c482e86bee79d6c9c6981300518c4ff6b7f29d5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161706
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-01-07 14:50:10 +01:00
Stephan Bergmann 312efd56ea At least VS 2022 Preview 17.9.0 Preview 1.1 needs the fix too
...from 3c6de7e20e "Fix build against VS 2022
17.7.5"

Change-Id: I765db22aba2823e6d9a38282ac53e9ba5bcff092
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160309
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2023-12-04 15:16:23 +01:00
Stephan Bergmann cef555e9a4 Make ExternalReferenceUriTranslator more robust against broken UTF-8
<https://lists.freedesktop.org/archives/libreoffice/2023-November/091151.html>
"CppunitTest_stoc_uriproc failed on Windows" reports that
translateToExternal("file:///abc/%feef") produces an empty string (indicating
failure) instead of "file:///abc/%FEef" (as expected in
stoc/test/uriproc/test_uriproc.cxx) when osl_getThreadTextEncoding() is Shift
JIS.

This was due to how the call to rtl::Uri::encode in
Translator::translateToExternal (in
stoc/source/uriproc/ExternalUriReferenceTranslator.cxx) behaved:  It internally
interpreted its input "%FE" as the single-byte Shift JIS character 0xFE.  Which
gets mapped to U+2122 as an extension (see "APPLE additions over SJIS, we
convert this like Apple, because I think, this gives better result, then [sic]
we take a replacement char" in sal/textenc/tcvtjp6.tab) in readUcs4, but which
in turn doesn't get mapped back to any Shift JIS character in writeEscapeChar.

Translator::translateToExternal is the only user of
rtl_UriEncodeStrictKeepEscapes, as introduced by
6ff5d3341d "INTEGRATION: CWS c07v013_SRC680
(1.4.40); FILE MERGED: 2007/06/21 13:00:56 sb 1.4.40.1: #b6550116# Made
XExternalUriReferenceTranslator.translateToExternal more robust when the input
URL contains spurious non--UTF-8 octets like %FE (which are now copied verbatim,
instead of signalling error)."

To make the claim true that such "spurious non--UTF-8 octets like %FE" are
always "copied verbatim", regardless of text encoding being used, repurpose
rtl_UriEncodeStrictKeepEscapes to always treat any escape sequences that are
present as (potentially broken) UTF-8.

Change-Id: I0fa0b14d3e3d44e4b5514e1b73c84c407a947ce9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158888
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-11-03 17:26:58 +01:00
Stephan Bergmann 30027d95f9 Step 2 of removing cargo-cult pragma pack around rtl_[u]String
see 8ae3ae4bf7 "Step 1 of removing cargo-cult
pragma pack around rtl_[u]String"

Change-Id: Ie9140b92da8895c4991a7f449359bb1747fdb23d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158553
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-27 15:50:09 +02:00
Stephan Bergmann e6ca379bcb Clean up some C++20 TODOs
Change-Id: I8baece4349683c7a83a283b85e24f33874b47ba3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158177
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-19 17:16:29 +02:00
Stephan Bergmann ca58f64919 Extend /clr /std:c++20 char8_t workaround to old versions of VS 2022
On IRC, pppregin now reported that she ran into the issue addressed by
3c6de7e20e "Fix build against VS 2022 17.7.5" when
using (a presumably old version of) VS 2022.  And
<https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering>
suggests that older versions of VS 2022 used _MSV_VER values 1930...1936, so
cover those too here.

Change-Id: Ifee80114c5cd39aeabc31907adafb03eb2f388e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158122
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-18 19:33:52 +02:00