4098 Commits
Author SHA1 Message Date
elioperdreau b2554fe7f0 Merge upstream LibreOffice master into ODFStudio main 2026-10-08 12:56:19 +02:00
Mike Kaganski 67346d08e9 tools: keep the input deflate could not take in one pass
ZCodec::Compress read a fresh chunk over whatever deflate had left unconsumed.
deflate stops as soon as its output buffer is full, and the write-back that
frees that buffer only ran at the top of the next iteration, by which time the
tail of the previous chunk was gone.

Nothing said so. EndCompression answers with the number of bytes taken and no
caller compared it, so the result was a shorter document than the one handed
in, compressed perfectly well. Passing 100000 bytes through a 64 byte output
buffer took 49152 of them.

Signed-off-by: Mike Kaganski <mike.kaganski@collabora.com>
Change-Id: I1044a46aa1d1f424e7d699a927e01a8427768919
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/13208
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit 23e2e9c2136d8b5c9fd6d9604bccd35e9b657571)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211555
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-09-29 15:58:29 +02:00
elioperdreau b2c7e472fd Merge remote-tracking branch 'upstream/master' into experiment/upstream-sync
Change-Id: I77c2bb8abdef222cf0fc2f7016e34da1554653cb
2026-09-28 18:32:53 +02:00
Caolán McNamara aa74bed8ff consider javascript an exotic protocol
no document feature needs javascript: urls, it defaulted into the
list with the rest in:

commit 7e5feed961ef2344d580d63a5752e9d6e2c0797e
Date:   Fri Aug 21 10:12:08 2026 +0200

    switch INetURLObject::IsExoticProtocol to default-deny

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I6546e08af67f00c9783c96dca9c3a736205033ef
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/13501
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
(cherry picked from commit 6c66678f8ba35fc9b7758a88fa0294fdb871cf1b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211457
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-09-25 15:54:51 +02:00
Caolán McNamara 5b42ac7163 ReadLine and ReadUniStringLine: stop at the limit in the loop
the two have drifted apart, so check the limit as each character is
read instead of correcting the count afterwards

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Idad62990843d58dfa13a69667295285ba4c7227f
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/12715
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit bbb65e562218787fcc6527aa1e3683017f962eca)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211278
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-09-21 13:02:57 +02:00
elioperdreau 4d0ef4a077 odfstudio: synchronize with LibreOffice upstream 2026-09-16 22:00:48 +02:00
elioperdreau c2b5ab6b2e odfstudio: add upstream maintenance tools
Change-Id: I352b0b0bf55ba845afd6289250060b7af44a26ee
2026-09-16 21:28:39 +02:00
Caolán McNamara 5c7c41ef9e valgrind: ZCodec::InitDecompress uninitialised values on a short gzip header
Conditional jump or move depends on uninitialised value(s)
   at ZCodec::InitDecompress(SvStream&) (zcodec.cxx:353)
   by ZCodec::AttemptDecompression(SvStream&, SvStream&) (zcodec.cxx:384)
   by PlainTextFilterDetect::detect(...) (filterdetect.cxx:184)
   by filter::config::TypeDetection::impl_askDetectService(...) (typedetection.cxx:1139)
   by filter::config::TypeDetection::impl_detectTypeFlatAndDeep(...) (typedetection.cxx:1044)
   by filter::config::TypeDetection::queryTypeByDescriptor(...) (typedetection.cxx:439)
   by framework::LoadEnv::impl_detectTypeAndFilter() (loadenv.cxx:771)

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I952005ee74189a46d5faf39c8e7fef3ffda2082b
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/9153
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit a2cf813f1298301d2b95a58e77fe21714beafa32)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209314
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-09-05 12:46:12 +02:00
Andrea Gelmini dcc4abb880 Fix typos
Change-Id: Ie4170e9a8268508196ffd415e6cc5b9daef466f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210209
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2026-08-29 16:44:29 +02:00
Noel Grandin 8be85cad83 switch INetURLObject::IsExoticProtocol to default-deny
and whitelist known-good stuff, rather than playing
whack-a-mole with bad protocols.

Change-Id: I8ea95a2af57b826f16f3d97daffac15659a4ad9c
Signed-off-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/9687
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit 7e5feed961ef2344d580d63a5752e9d6e2c0797e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210126
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-08-27 15:46:41 +02:00
Andrea Gelmini 7ad4b1da80 Fix typos
Change-Id: I08d677970591e303d076ecff87af78c5eed1d6ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210060
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2026-08-27 15:01:44 +02:00
Andrea Gelmini 9f970f8cf6 Fix typo in code
Change-Id: Id22fea4a07aa6fee9783565cd4d7f14ecdff1d17
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210041
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
2026-08-27 10:41:40 +02:00
Andrea Gelmini c455a75578 Fix typos
Change-Id: I620dbd48232d8d2c7e99586d3445654880699cae

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209806
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
2026-08-25 15:46:10 +02:00
Caolán McNamara 3329b7d5cf extend exotic protocol list
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I3d198119f6076278041d27f9f8b8fa62607d37ff
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/9652
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
(cherry picked from commit aff5d73c5433f79228a3a79d26a501ba46ffbfbb)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209524
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-08-23 13:26:26 +02:00
Andrea Gelmini 467e3b4f49 Fix typos
Change-Id: I8000ee277d51b91e8e04c99afa4327a4245e435f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209475
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2026-08-22 10:26:48 +02:00
Julien Nabet 1e0180a814 Revert "tdf#166299 tdf#172587: try to improve encoding detection"
This reverts commit d71b9934b3.

Reason for revert: don't try to tweak too much ICU results

Change-Id: I9f35294376faa5b82729c0072cf66b5fe5f79a7a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209285
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2026-08-18 16:55:37 +02:00
Julien Nabet d71b9934b3 tdf#166299 tdf#172587: try to improve encoding detection
Instead of selecting the first encoding returned by ucsdet_detectAll
(except the 5 CJK when they have confidence of 10), recalculate
confidence by removing 10 only when one of the 5 CJK encodings then
check each encoding returned by ucsdet_detectAll and select the one with
the max confidence with this new rule.

I also tested this again on tdf#172905, no regression.

Change-Id: I6a8e2b30e8467fefd53c02296484e48ca467c662
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209143
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2026-08-16 14:38:56 +02:00
Julien Nabet fb4626933e Related tdf#172905: avoid magic number
Change-Id: I60c22d076f0c2435a07bfc12497499092dfb9d7d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208977
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
2026-08-06 14:56:58 +02:00
Julien Nabet aac1744361 tdf#172905: for some CJK character sets, 10 is the starting point
whereas 0 is the starting point (eg for iso-8859-*)
So don't retain the CJK character sets if they're just at 10
and there's no other character sets

+ add some debug traces to track charsets detected by libicu
and their associated confidence

Change-Id: I7d89d06ffb963143276aff749e7d1a6f7a531cca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208899
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2026-08-01 23:14:48 +02:00
Julien Nabet f21643c5fe tdf#171097: add ISO-8859-8-I in encodings map detection
Change-Id: Ib84bd5de4bb3495a0f3339afa0537fd8003d1dc8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208971
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
2026-08-01 13:38:07 +02:00
Michael Weghorn bc8317496c tools: Drop claim in README tools "will be removed in the near future"
This sentence was added in

    commit cf9bc834a4
    Date:   Mon Apr 8 15:34:25 2013 +0200

        update documentation

and the two tickets it references are both marked
RESOLVED FIXED as they were both about
porting code using a specific subset of the tools
module to something else, not about dropping
the tools module altogether.
(At least that's what was agreed on in the end
for the scope of those tickets, see discussion
in these tickets.)

Change-Id: Iea3fcb2b3e7a98d0a63382ef8ca6dc4177fac857
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208127
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-07-15 14:46:14 +02:00
Caolán McNamara 4ba5567cc4 match the package content provider when checking a vnd.sun.star.pkg url
IsExoticProtocol used GetHost() to recover the nested package url of a
vnd.sun.star.pkg url, but the package content provider in
ucb/source/ucp/package/pkguri.cxx uses the whole authority between "://"
and the next '/', which GetHost() truncates at '@'. Check the same
substring the provider does.

The vnd.sun.star.zip branch below already did the equivalent extraction,
so pull the shared parts into a helper that both branches call.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I27be6a839108f2e58d62baefc1a71dcbfc9a4568
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/4410
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
(cherry picked from commit ce436efb34d2e0e90ee2cdb450da285530c562f7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206681
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-06-16 16:14:58 +02:00
Xisco Fauli fb28678005 loplugin:unusedmethods
Change-Id: If3dae53e3cf16df2d0c505a898138dfa6fe6c0f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205442
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-05-22 09:32:38 +02:00
Stephan Bergmann 811769f009 Consistently use __EMSCRIPTEN__ instead of EMSCRIPTEN macro
...as emsdk 5.0.3 deprecated the predefined EMSCRIPTEN macro (see
<https://github.com/emscripten-core/emscripten/commit/506052bd8b4e23ded7f2351c62ca3b24d40c8cf3>
"Warn about usage of deprecated EMSCRIPTEN macro. NFC (#26381)"), causing
failures like

> In file included from static/source/unoembindhelpers/PrimaryBindings.cxx:29:
> In file included from include/sfx2/viewsh.hxx:35:
> In file included from include/editeng/outliner.hxx:32:
> In file included from include/tools/color.hxx:26:
> include/osl/endian.h:66:15: error: macro 'EMSCRIPTEN' has been marked as deprecated: use __EMSCRIPTEN__ instead [-Werror,-Wdeprecated-pragma]
>    66 | #elif defined EMSCRIPTEN
>       |               ^
> /home/sberg/emsdk/5.0.4/emsdk/emscripten/main/cache/sysroot/include/emscripten/emscripten.h:35:66: note: macro marked 'deprecated' here
>    35 | #pragma clang deprecated(EMSCRIPTEN, "use __EMSCRIPTEN__ instead")
>       |                                                                  ^

To avoid confusion, also suppress the -D$(OS) in
solenv/gbuild/platform/unxgcc.mk that would unnecessarily keep defining
EMSCRIPTEN.

Change-Id: Ic1f187cf1c6417cd95d4092e9cea01a665bd1b2f
Reviewed-on: https://gerrit.collaboraoffice.com/c/core/+/34
Reviewed-by: Michael Stahl <michael.stahl@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit 50291c2ed83bdb49bb827a4a12905d94b8c42035)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205167
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-05-14 10:11:38 +02:00
Muhammad Naeem 5c812142b2 tdf#143148: Use pragma once instead of include guards
- Convert include guards to #pragma once in salhelper, starmath, tools, ucb, and o3tl.
- Kept changes minimal to a small cross-module batch as requested by the easyHack guidance.
- Verified with: container=1 make -j4 o3tl.build salhelper.build starmath.build tools.build ucb.build

Change-Id: Ic047061433985e12be41bdb6463ac4c8e8969ddd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204555
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
2026-05-02 13:12:13 +02:00
Xisco Fauli cfd3309a5d loplugin:unusedmethods
Check existing ones that can be removed

Change-Id: I6ee6fc1772c620ac5d12fea915681b094b7c3bfd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204583
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-04-30 08:54:45 +02:00
Mehul Sharma 32ccbf31d3 tdf#145538 Use range based for loops in uiwriter11.cxx and poly2.cxx
Convert traditional for loops to range based for loops without
changing the existing behaviour of the code.

Change-Id: I118b12572ea1074e5a9aba329cc1acdd06d61666
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202618
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Tested-by: Jenkins
2026-04-03 14:18:50 +02:00
Noel Grandin ca82a93896 Fraction->double in SfxPoolItem
Change-Id: Ie5fe5f9367c6e657cee20c877a12d4c290aaec94
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202588
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2026-03-24 14:07:52 +01:00
Shoaib Samim bd0d3ea8f0 tdf#168771 Convert enum to enum class in urlobj.cxx
Change-Id: Ia274fa4ef073281f7ef3047f8a2304b8c88d6ccb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202393
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Tested-by: Jenkins
2026-03-24 06:50:05 +01:00
Noel Grandin 6993d54041 std::lround is unnecessary here
because we are then casting to a type <=32 bits

Change-Id: Ief4a93724ccbae8d697edbd40e4085389d74473f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202156
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-03-19 15:27:43 +01:00
Noel Grandin 8459f0be51 XmlWriter::attribute(double) should actually write a double value
And not truncate it to an integer value.

Add additional overload for attribute that takes an enumerated type, otherwise
the compiler will complain about ambiguous conversion because it cannot
choose between the attribute that takes a integral value and the one that
takes a double value.

Change-Id: I9eae22817ec3b26da7b9468d1c8b5e6f3e900538
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201193
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Jenkins
2026-03-10 15:49:17 +01:00
Rene Engelhard edfb978cf6 fix build with older boosts (e.g. 1.83)
after af82f165ca

Change-Id: I2ca4757695b1d01a287d7a4e8d48d22455431d12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200864
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Tested-by: Jenkins
2026-03-03 22:31:17 +01:00
Mike Kaganski 35871de09d Set encoding in StartReadingUnicodeText
Simplifies some code. It doesn't make sense to set endianness, but
avoid setting encoding.

Change-Id: I3a09fea7381b6c113075b9800b06b307cdaa6d45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200668
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2026-02-28 09:49:55 +01:00
Noel Grandin 98174967db SvStream::WriteUniOrByteString should not need to specify encoding
Instead, rely on the stream being set into the correct encoding
during stream initialisation.

Change-Id: If141ba09afe1b04f5d836024975f00e8b20d1447
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200462
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-02-27 07:49:07 +01:00
Noel Grandin d235ca3589 SvStream::ReadUniOrByteString should not need to specify encoding
Instead, rely on the stream being set into the correct encoding
during stream initialisation.

Change-Id: I5b015f12f141a89b176c5a22aeecc4336f0b8f13
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200460
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-02-27 07:48:47 +01:00
Noel Grandin 5ad9d928c7 SvStream::WriteUniOrByteChar should not need to specify encoding
Instead, rely on the stream being set into the correct encoding
during stream initialisation.

Change-Id: Ie019e9f7a668b943e418126b14b8bf852a4fa966
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200459
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-02-27 07:48:36 +01:00
Noel Grandin 4e6f8e76bf SvStream::ReadByteStringLine should not need to specify encoding
Instead, rely on the stream being set into the correct encoding
during stream initialisation.

Change-Id: Icceb067e600140589c329429d12add2ef3d471c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200458
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2026-02-26 20:19:02 +01:00
Noel Grandin 3c5f8e3dea SvFileStream::ReadUniOrByteStringLine should not need to specify encoding
Instead, rely on the stream being set into the correct encoding
during stream initialisation.

Change-Id: I96b6818dd07cf4b83959884bcbe3be2cbf90b476
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200457
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2026-02-26 20:18:50 +01:00
Stephan Bergmann af82f165ca Avoid unspecified behavior when checking for "pointer in range"
...which can easily cause wrong behavior.

(Maybe we can eventually replace the use of Boost here with Standard C++, if
something like
<https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3234r1.html> "Utility
to check if a pointer is in a given range" ever gets in.)

Change-Id: I9122efdd3272613b27c33a0d7dbc04ad2d6e39e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200454
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Tested-by: Jenkins
2026-02-26 19:44:18 +01:00
Stephan Bergmann 9b4077998d Add test
...for 0468b71c3f284ad6f7826aee79b8adb1998fc018 "fix asan heap-use-after-free"

Change-Id: I4045a2a3635d628d7f681406bd6a8b9f26fa23d3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200351
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Tested-by: Jenkins
2026-02-26 17:45:50 +01:00
Mike Kaganski 6c89e5a2d2 Use SvStream::DetectEncoding in GetNextChar
... instead of direct use of ucsdet_detect.

Change-Id: If1c523b3b6fd19c2817dfe2cd09e6aa7148de634
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200377
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2026-02-26 16:58:03 +01:00
Noel Grandin a9503c4cf8 SvFileStream should not need to specify encoding on per-call basis
Starts a process of converting the call-sites of SvFileStream
to just write data, relying on the stream being set
into the correct encoding somewhere during initialisation.

In this commit, I change WriteByteStringLine to do that.
For most of the call sites, they either:
(a) use the stream encoding explicitly
(b) already set the stream to the encoding being used at the call-site

Only in buildFontMenuName did I need to make the stream explicitly
set the stream encoding.

Also add a utility constructor to SvFileStream to make it easy
to set the stream in the correct mode at open-time.
Ideally a stream should be set into the correct encoding
at open time and never changed.

Change-Id: I57afa74807e15320a176a05d43c94c377dad4561
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200289
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-02-26 16:57:00 +01:00
Noel Grandin 9ff0df208b fix pointer arithmetic in SvMemoryStream::PutData
after
  commit fa002b6244
  Author: Noel Grandin <noelgrandin@gmail.com>
  Date:   Sat Feb 21 21:00:32 2026 +0200
  fix asan heap-use-after-free

Change-Id: I2ed04d2957089f2e6968ac63b14639e27709295c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200400
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-02-26 13:50:59 +01:00
Mike Kaganski 55b9d8607b "CharSet" -> "Encoding" in SvStream
Use the correct term. E.g., Unicode charset has different encodings
like UTF-8 and UTF-16, and we mean encoding here.

Change-Id: I65e90b31cda6e39fdb1584b492e6e0b9821865a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200285
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2026-02-25 10:33:55 +01:00
Mike Kaganski 610168656a Move encoding detection to SvStream
Allows to avoid similar code in SwIoSystem and SfxObjectShell, and
unifies the code.

Change-Id: I16817f2aea5bdabb9bf3505f2f3c2f697e3106e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200284
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2026-02-25 10:33:49 +01:00
Noel Grandin fa002b6244 fix asan heap-use-after-free
Seems like recent font/pdf related changes have exposed a latent
bug(?) in the SvMemoryStream class. Specifically, writing to
SvMemoryStream using a source pointer that points inside the SvMemoryStream
data buffer causes trouble when the buffer is re-allocated.

Make SvMemoryStream tolerant of this, although it is a rather
dodgy use-case.

READ of size 177 at 0x531000155fe7 thread T0
  SvMemoryStream::PutData(void const*, unsigned long) /tools/source/stream/stream.cxx:1578:5
  SvStream::WriteBytes(void const*, unsigned long) /tools/source/stream/stream.cxx:1195:26
  vcl::filter::PDFDocument::WriteCatalogObject(int, vcl::filter::PDFReferenceElement*&) /vcl/source/filter/ipdf/pdfdocument.cxx:577:27

freed by thread T0 here:
  in SvMemoryStream::FreeMemory() /tools/source/stream/stream.cxx:1694:9
  in SvMemoryStream::ReAllocateMemory(long) /tools/source/stream/stream.cxx:1671:9
  in SvMemoryStream::PutData(void const*, unsigned long) /tools/source/stream/stream.cxx:1569:22
  in SvStream::WriteBytes(void const*, unsigned long) /tools/source/stream/stream.cxx:1195:26
  in vcl::filter::PDFDocument::WriteCatalogObject(int, vcl::filter::PDFReferenceElement*&) /vcl/source/filter/ipdf/pdfdocument.cxx:577:27

Change-Id: I2613ed66cec600b7f44e575a56f6a97c0ff3053d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199959
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-02-25 09:12:11 +01:00
Caolán McNamara b1d0997162 extend exotic protocol list
Change-Id: Ie6df4dd171118ff53596bfc058223ea1f15c9e27
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199048
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@collabora.com>
2026-02-11 18:28:36 +01:00
Stephan Bergmann 0c54c3f77a Point appears to be required to be a complete type here
...contrary to what c511c65434 "tdf#146619 Use
more forward declarations in include/tools" apparently assumed, as seen at least
with recent Clang 23 trunk against recent libstdc++ 16 trunk,

> In file included from tools/source/generic/poly2.cxx:22:
> In file included from tools/inc/poly.h:22:
> In file included from ~/gcc/inst/lib/gcc/x86_64-pc-linux-gnu/16.0.1/../../../../include/c++/16.0.1/memory:80:
> ~/gcc/inst/lib/gcc/x86_64-pc-linux-gnu/16.0.1/../../../../include/c++/16.0.1/bits/unique_ptr.h:131:18: error: invalid application of 'sizeof' to an incomplete type 'Point'
>   131 |           static_assert(sizeof(_Tp)>0,
>       |                         ^~~~~~~~~~~
> ~/gcc/inst/lib/gcc/x86_64-pc-linux-gnu/16.0.1/../../../../include/c++/16.0.1/bits/unique_ptr.h:684:4: note: in instantiation of function template specialization 'std::default_delete<Point[]>::operator()<Point>' requested here
>   684 |           get_deleter()(__ptr);
>       |           ^
> tools/inc/poly.h:33:21: note: in instantiation of member function 'std::unique_ptr<Point[]>::~unique_ptr' requested here
>    33 |                     ImplPolygon() : mnPoints(0) {}
>       |                     ^
> include/tools/poly.hxx:60:7: note: forward declaration of 'Point'
>    60 | class Point;
>       |       ^

Change-Id: I0b96222dcec7e98b974151004248a91ba1854e60
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198573
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2026-02-02 22:31:40 +01:00
Gabor Kelemen c511c65434 tdf#146619 Use more forward declarations in include/tools
Change-Id: Iab2938f82a9fd7ef3334d69c4fd07a9d963a9e24
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198237
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen@collabora.com>
2026-02-01 09:23:01 +01:00
Stephan Bergmann e3ea377f2d Make a virtual function non-inline
...which helps avoid some supposedly spurious -Werror=free-nonheap-object seen
at least with recent GCC 16 trunk,

> In destructor ‘virtual SvLockBytes::~SvLockBytes()’,
>     inlined from ‘void SvRefBase::ReleaseRef()’ at include/tools/ref.hxx:160:36,
>     inlined from ‘tools::SvRef<T>::~SvRef() [with T = writerfilter::rtftok::RTFTokenizer]’ at include/tools/ref.hxx:56:46,
>     inlined from ‘writerfilter::rtftok::RTFLookahead::~RTFLookahead()’ at sw/source/writerfilter/rtftok/rtflookahead.cxx:37:1:
> include/tools/stream.hxx:115:48: error: ‘void operator delete(void*, std::size_t)’ called on pointer ‘((tools::SvRef<writerfilter::rtftok::RTFTokenizer>*)this)[1].tools::SvRef<writerfilter::rtftok::RTFTokenizer>::pObj’ with nonzero offset 56 [-Werror=free-nonheap-object]
>   115 |     virtual ~SvLockBytes() override { close(); }
>       |                                                ^

etc.

Change-Id: I26a599f0e3258e6bf6a4d6e63e559b41029862db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197842
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2026-01-23 08:04:24 +01:00