Commit Graph
119 Commits
Author SHA1 Message Date
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
Tor Lillqvist b28a46aa50 Make sure that <tools/UnixWrappers.h> stays compilable as C
We don't use it yet from any C source file, but the plan is to do
that. Mainly from freetype, fontconfig, and cairo, when these are
built for Windows when the --enable-headless options is used (for the
new Collabora Office).

Also some cleanups, sorting #include lines, avoiding warnings, etc.

Change-Id: Ifef3588d06fdcceaeaeb3482399737faaf558d7d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195602
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2025-12-15 07:31:21 +01:00
Noel Grandin 66b698e64e convert volatile bool to std::atomic<bool> in DeleteOnDeinitBase
volatile does not mean thread-safe in C++

Change-Id: I80886c24af0f29d644368bb8b922d75a874d4009
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183394
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2025-03-27 17:36:15 +01:00
Noel Grandin fecf7a6424 DeleteOnDeinitBase::gShutdown should be volatile
because we are touching it from multiple threads

Change-Id: I48f5f9c0dc5bb5365e8821259839eb88f8ba0887
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183319
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2025-03-26 14:34:27 +01:00
Caolán McNamara 15eb26d0f2 ofz: Undefined-shift
Change-Id: Ibb42de616566aabdf6596b7c45d0afab90118bc9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175877
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-10-31 18:18:48 +01:00
Stephan Bergmann b0195d40f3 Avoid signed integer overflow
...as seen at

> /tools/source/misc/fix16.cxx:79:53: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
>     #0 0x7fc2f9f50a60 in mask(int) /tools/source/misc/fix16.cxx:79:53
>     #1 0x7fc2f9f505fd in fix16_div(int, int) /tools/source/misc/fix16.cxx:122:34
>     #2 0x7fc2f00d12e0 in vcl::fixedDiv(int, int) /vcl/source/fontsubset/sft.cxx:127:12
>     #3 0x7fc2f00d11c1 in vcl::fixedMulDiv(int, int, int) /vcl/source/fontsubset/sft.cxx:135:12
>     #4 0x7fc2f00d0851 in vcl::GetCompoundTTOutline(vcl::AbstractTrueTypeFont*, unsigned int, std::__debug::vector<vcl::ControlPoint, std::allocator<vcl::ControlPoint> >&, vcl::(anonymous namespace)::TTGlyphMetrics*, std::__debug::vector<unsigned int, std::allocator<unsigned int> >&) /vcl/source/fontsubset/sft.cxx:544:91
>     #5 0x7fc2f00af5f1 in vcl::GetTTGlyphOutline(vcl::AbstractTrueTypeFont*, unsigned int, std::__debug::vector<vcl::ControlPoint, std::allocator<vcl::ControlPoint> >&, vcl::(anonymous namespace)::TTGlyphMetrics*, std::__debug::vector<unsigned int, std::allocator<unsigned int> >*) /vcl/source/fontsubset/sft.cxx:621:15
>     #6 0x7fc2f00aea34 in vcl::GetTTGlyphPoints(vcl::AbstractTrueTypeFont*, unsigned int, std::__debug::vector<vcl::ControlPoint, std::allocator<vcl::ControlPoint> >&) /vcl/source/fontsubset/sft.cxx:1239:12
>     #7 0x7fc2f00b92de in vcl::GetTTRawGlyphData(vcl::AbstractTrueTypeFont*, unsigned int) /vcl/source/fontsubset/sft.cxx:1667:9
>     #8 0x7fc2f00b23ed in vcl::CreateTTFromTTGlyphs(vcl::AbstractTrueTypeFont*, std::__debug::vector<unsigned char, std::allocator<unsigned char> >&, unsigned short const*, unsigned char const*, int) /vcl/source/fontsubset/sft.cxx:1374:32
>     #9 0x7fc2f00bc71a in vcl::CreateTTFfontSubset(vcl::AbstractTrueTypeFont&, std::__debug::vector<unsigned char, std::allocator<unsigned char> >&, unsigned int const*, unsigned char const*, int, FontSubsetInfo&) /vcl/source/fontsubset/sft.cxx:1549:13
>     #10 0x7fc2eff57836 in vcl::font::PhysicalFontFace::CreateFontSubset(std::__debug::vector<unsigned char, std::allocator<unsigned char> >&, unsigned int const*, unsigned char const*, int, FontSubsetInfo&) const /vcl/source/font/PhysicalFontFace.cxx:367:12
>     #11 0x7fc2ee4e0472 in vcl::PDFWriterImpl::emitFonts() /vcl/source/gdi/pdfwriter_impl.cxx:3152:24
>     #12 0x7fc2ee4e9cb9 in vcl::PDFWriterImpl::emitResources() /vcl/source/gdi/pdfwriter_impl.cxx:3363:10
>     #13 0x7fc2ee53f91d in vcl::PDFWriterImpl::emitCatalog() /vcl/source/gdi/pdfwriter_impl.cxx:5288:10
>     #14 0x7fc2ee567ae3 in vcl::PDFWriterImpl::emit() /vcl/source/gdi/pdfwriter_impl.cxx:6341:10
>     #15 0x7fc2ee3d3f2a in vcl::PDFWriter::Emit() /vcl/source/gdi/pdfwriter.cxx:53:29
>     #16 0x7fc249b4b82a in PDFExport::Export(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /filter/source/pdf/pdfexport.cxx:1127:39
>     #17 0x7fc249bb2782 in PDFFilter::implExport(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /filter/source/pdf/pdffilter.cxx:182:24
>     #18 0x7fc249bb342b in PDFFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /filter/source/pdf/pdffilter.cxx:247:23
>     #19 0x7fc2a51ebec6 in SfxObjectShell::ExportTo(SfxMedium&) /sfx2/source/doc/objstor.cxx:2945:25
>     #20 0x7fc2a51d7bec in SfxObjectShell::SaveTo_Impl(SfxMedium&, SfxItemSet const*) /sfx2/source/doc/objstor.cxx:1943:19
>     #21 0x7fc2a5213f83 in SfxObjectShell::PreDoSaveAs_Impl(rtl::OUString const&, rtl::OUString const&, SfxItemSet const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /sfx2/source/doc/objstor.cxx:3459:39
>     #22 0x7fc2a520b709 in SfxObjectShell::CommonSaveAs_Impl(INetURLObject const&, rtl::OUString const&, SfxItemSet&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /sfx2/source/doc/objstor.cxx:3249:9
>     #23 0x7fc2a5147a8b in SfxObjectShell::APISaveAs_Impl(std::basic_string_view<char16_t, std::char_traits<char16_t> >, SfxItemSet&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /sfx2/source/doc/objserv.cxx:320:19
>     #24 0x7fc2a543024c in SfxBaseModel::impl_store(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, bool) /sfx2/source/doc/sfxbasemodel.cxx:3231:42
>     #25 0x7fc2a54374f4 in SfxBaseModel::storeToURL(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /sfx2/source/doc/sfxbasemodel.cxx:1813:13
>     #26 0x7fc2c74053ae in ScPDFExportTest::exportToPDF(com::sun::star::uno::Reference<com::sun::star::frame::XModel> const&, ScRange const&) /sc/qa/extras/scpdfexport.cxx:179:16
>     #27 0x7fc2c7437e0f in ScPDFExportTest::testForcepoint97() /sc/qa/extras/scpdfexport.cxx:915:5

during CppunitTest_sc_pdf_export
(<https://ci.libreoffice.org/job/lo_ubsan/3346/>)

Change-Id: I3074479ea3267417a73ecafa81b4a9898f19d1a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175469
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
2024-10-23 12:10:21 +02:00
Caolán McNamara 746f66f4b1 cid#1607748 Overflowed constant
Change-Id: Id077fdc914f461a3631c42c37b2d5be37632e0e2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175374
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-10-22 20:37:17 +02:00
Noel Grandin 19bc8856c4 move vcl::DeleteOnDeinit to tools
so we can fix a shutdown use-after-free in sot.

Change-Id: I32f83bd94627d72d7bee7ea2ebd6ab77a7f78435
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175335
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-10-22 08:01:19 +02:00
Caolán McNamara c8b5ac2a54 cid#1607586 Overflowed return value
and

cid#1608074 Overflowed return value
cid#1607598 Overflowed return value

Change-Id: Ib884c10083c01578a7a0926d5f2f3c2d1f7501c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173833
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-09-24 13:27:26 +02:00
Caolán McNamara 2a9ae69483 tools#1608074 silence Overflowed return value
Change-Id: Id1db2d006a82e08e6e011be5c5fcfa515381ad44
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171060
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-07-26 10:42:00 +02:00
Tomaž Vajngerl 02c91f82c2 move UniqueID to tools and rework to increase counter in constructor
In the tools module it can be used in more other modules.

Changed the instantiation to increase the counter already in the
constructor, so no need to check if the ID is 0.

Also test for UniqueID

Change-Id: I77c80461875c69496a7e218534d16d6550c168c2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170061
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2024-07-07 09:41:02 +02:00
Noel Grandin 45f9627659 loplugin:ostr in tools
Change-Id: I0e601100b034eaa99b08c7cbf09e5f817e69b507
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167736
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2024-05-16 14:49:58 +02:00
Noel Grandin 144dd13818 loplugin:unusedmethods
Change-Id: Ib0a72355972662c6b902bca9a527be91fb3e1d17
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164930
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-03-17 13:06:48 +01:00
Caolán McNamara 17dc98b0f0 Document Colors do not show any color in the Palette
same is true for "Theme Colors", a problem since:

commit 4ccc2f0e3f45c9d78f74b1848851bedf71f7382d
Date:   Fri Mar 1 22:11:14 2024 +0200

    cool#8327 use tools::JsonWriter for theme colors

Change-Id: Ibaab5df197bd8005037e066181e8a50bdda5ceda
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164658
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164669
Tested-by: Jenkins
2024-03-11 18:47:41 +01:00
Stephan Bergmann 3ba85b7786 Support o3tl::iterateCodePoints with both sal_Int32 and std::size_t
...and clean up the most gross casting offenses

Change-Id: If0d646fb3e73e71a9a2735569395034973563a1f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164602
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-03-09 19:19:04 +01:00
Noel Grandin 06daf1719e avoid a memcpy when constructing output of tools::JsonWriter
we can store the data in an rtl::OString object and then return
that directly

Change-Id: I65af6820bfd3135b38d437cf9736fffff8924e88
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164291
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-03-02 20:11:07 +01:00
Mike Kaganski 18a5df4993 Restore a comment
Mistakenly removed in commit c2dca161c0
(Use <bit> instead of platform-specific intrinsics, 2024-02-29)

Change-Id: I6091a767aebcbb2543656cee2c27330fb6f9d16b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164141
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-29 12:50:12 +01:00
Mike Kaganski c2dca161c0 Use <bit> instead of platform-specific intrinsics
Change-Id: I79636ff9c3b2fe601b0b3c94a111b36af0011775
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164131
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-29 04:01:48 +01:00
Mike Kaganski 3234c4e35f Avoid MAX_PATH limitation in launcher
... and drop some manual memory management.

Change-Id: I4c60ce559ff185d4685a6b9799a97651438115b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162502
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-25 07:29:40 +01:00
Noel Grandin 4603aa2888 use more string_view in tools::JsonWriter
Change-Id: Ia3ac54a1164b99a806298a47115ea3bc570f3b0c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163810
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-02-23 16:50:33 +01:00
Mike Kaganski 76fad8c981 Simplify a bit
And make sure to write newline, tab, etc. as short \n, \t, etc.

Change-Id: I6a8ae36ff2856fce2f756c643c6266debe79f1ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161813
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-01-09 13:31:33 +01:00
Mike Kaganski 7413b4ad50 Simplify JsonWriter a bit
Change-Id: Ifa4278cfd62df4179dd3ae627369c077e31dbd00
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161780
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-01-08 13:05:31 +01:00
Julien Nabet 5ae47ac0a7 cid#1537992 deadcode
since 16b0da3851
jsdialog: encode properly control characters

Change-Id: Ic447a819d3d0b3f9ff66e00f0b05a037ec53a9cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154488
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2023-07-16 12:07:17 +02:00
Szymon Kłos 6086d89618 linking: api: use JsonWriter
Change-Id: If5bf1897f1aef8db1672789cbee14b90cb96dc08
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151959
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154378
Tested-by: Jenkins
2023-07-13 12:17:36 +02:00
Szymon Kłos 16b0da3851 jsdialog: encode properly control characters
according to https://www.rfc-editor.org/rfc/rfc7159#section-7
strings in JSON should contain control characters (0x00-0x1f)
encoded as \uXXXX

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I1f828f64e57328b5fa2dcf5853afe0d6ea643081
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152262
Reviewed-by: Attila Szűcs <attila.szucs@collabora.com>
Tested-by: Attila Szűcs <attila.szucs@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153946
Tested-by: Jenkins
2023-07-04 20:46:50 +02:00
Jaume Pujantell 2fe581d916 fix bug in json_writer
Ruler stores null-terminated strings in fixed length char arrays, so when creating a JSON
a string might end earlier that it's size sugsests.

Change-Id: Icdcaf35f9ce54c24dcd36368dc49bb688a2a65ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150542
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins
2023-04-27 12:13:37 +02:00
Noel Grandin e57d5daaea fix leaks when using tools::JsonWriter
Specifically in sd/source/core/annotations/Annotation.cxx

We seem to end up fixing leaks here often.
The current tools::JsonWriter API is just very hard to use correctly.

So rather return an OString, which is cheap to copy,
and push that down into the LOK code.

AFAIK that seems to end up requiring less code and less adhoc copying
of data (specifically the queueing code in init.cxx was creating
copies when converting to std::string).

Ideally, we could have some special API to avoid the new strdup()
calls in init.cxx, but not sure how to prevent other people
from accidentally using that.

Change-Id: Ia33437c1bfd9cc2d54dfb99914d1b72db20335f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149963
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-04-05 17:02:46 +02:00
Mike Kaganski e8e244d93c Simplify JsonWriter a bit
Change-Id: I0ca4a0fcf4f19bc26ae931bae0b2ee53db47f12c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149951
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-04-03 15:25:23 +02:00
Tor Lillqvist af560f84ef I get "warning: unsupported syscall: __sys_prlimit64" in WASM so avoid that
Change-Id: I8a9a19d3c7757e1b7e1d194c439280a9d4824c3a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144876
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2022-12-30 12:15:06 +00:00
Stephan Bergmann 4280a32579 -Werror,-Wdeprecated-declarations (sprintf, macOS 13 SDK): tools
(The "clang-format off" in tools/source/misc/json_writer.cxx is necessary
because otherwise the code between the SAL_WNODEPRECATED_DECLARATIONS_PUSH/POP
macros would be ill-formatted in a way that would trigger loplugin:indentation.)

Change-Id: Ic96787865d4c96be07c41f4939893420dfa04046
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142339
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-06 01:13:45 +01:00
Gabor Kelemen 52ef78f492 Recheck modules t* with IWYU
See tdf#42949 for motivation

Change-Id: I109fa07d52721fd10354de07a2ed995ffa2f27c5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132369
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
2022-04-02 23:32:08 +02:00
Caolán McNamara 59a7c40255 reduce down to the part and config we are using and move to tools
Change-Id: Ifaddc59c3c7834808d368c138a5ec7c0b80db14c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131850
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-03-19 22:56:05 +01:00
Szymon Kłos 496fcccfa6 jsonwriter: ensure correct number of bytes is available
In some functions author forgot that addCommaBeforeField()
can add additional two characters.

I didn't change cases where more bytes than needed are requested.

Additional change is that in debug mode there is a marker at the
end of allocated buffer - we check that after every write to
detect overflow. No need to request more space for a marker as
we always allocate "needed size * 2".

Change-Id: I28066797b0ba833e408b0a731abc01b7fd989da3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126535
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129163
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2022-01-31 17:01:33 +01:00
Mike Kaganski 02d225f2a4 Simplify JsonWriter a bit
Move ensureSpace code to json_writer.cxx, and merge with reallocBuffer.
The methods are private, and are only used in methods in the same .CXX,
so the code will get inlined as compiler decides anyway, but becomes
simpler.

Make extractDataAs* to consider the known size of the data, to avoid
calculating null-terminated size. To do that, the code is moved from
extractData to private extractDataImpl, which returns both pointer
and size.

Change-Id: I7c0e425b5c584089c6e866c31d4cfdb5e242d66b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123568
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-10-14 07:40:52 +02:00
Mike Kaganski aff3ce8837 Improve JsonWriter's escapement code
It should now be conformant to JSON spec; and additionally,
it escapes two characters that are valid in JSON, but invalid
in JavaScript (as described in [1]).

[1] http://web.archive.org/web/20201203234157/http://timelessrepo.com/json-isnt-a-javascript-subset

Change-Id: I1081ade89a57fefefde672f2b8fa08e97627fc50
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123510
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-10-13 19:34:13 +02:00
Mike Kaganski 03c474c640 Unify JsonWriter::put and putRaw a bit
In the process, it turned out that there was unnecessary conversion
of OStringBuffer to OString and back to OStringBuffer when using
putRaw, which is avoided now.

Change-Id: I1e3ee685679df0b025bee8f4430624ee5bc9ccb3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123547
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-10-13 17:39:32 +02:00
Noel Grandin 9946a2fef0 fix buffer overruns in JsonWriter::put with UTF-8 values
Change-Id: I694585a1a540bfefc0e59bd58d8033a96ca35acb
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122996
Tested-by: Jenkins
2021-10-02 22:36:17 +02:00
Noel Grandin 897192f07c simplify JsonWriter::reallocBuffer by using realloc
instead of malloc and copy.

spotted by mmeeks

Change-Id: Ibac83be597cfaf61f783a265562c5102bbaf29d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122995
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-10-02 19:15:00 +02:00
Noel Grandin 9490588c24 clang:optin.performance.Padding in tools
Excessive padding in 'class tools::JsonWriter' (15 padding bytes, where
7 is optimal).

Change-Id: I7e37eec095d935a344b2e5fea7bb108ee878472a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121920
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-09-10 21:19:24 +02:00
dante 5b9cf5881e tdf#142307 - Upgrade SSE2 sum to AVX512 sum with Neumaier 1
This part focuses on allowing it on replacing arrayfunctor
By thefault it will try AVX512F (1,17%)
If not available will use AVX (94,77%)
Use of AVX2 (82,28%) has been avoided even if the code could been more compact
Source of hardware statistics: https://store.steampowered.com/hwsurvey

Change-Id: Iae737a565379e82c5f84f3fdee6321ac74f59d40
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115675
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-08-26 08:48:35 +02:00
Tor Lillqvist 5aee16cf09 Make JsonWriter::writeEscapedOUString() handle surrogate pairs properly
It is wrong to iterate over UTF-16 code units one by one. We have
OUString::iterateCodePoints() to iterate over Unicode code points.

The two UTF-16 code units of a surrogate pair (for a non-BMP code
point) should not be encoded separately to UTF-8 bytes. It is the code
point that should be encoded (to four bytes).

Change-Id: Ica4341308deb6618c9c2da8dcee8a11ef4e8238d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109318
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2021-01-15 08:54:12 +01:00
Henry Castro 6002ff0354 tools: json: fix missing escaped chars
When client side tries to show the "Macro Security Warning"
message dialog, it fails to parse the JSON objects

Change-Id: Id73c291ddd9cf739d63d69f06094eacb7b43a2f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108287
Tested-by: Jenkins
Reviewed-by: Henry Castro <hcastro@collabora.com>
2020-12-28 13:26:46 +01:00
Szymon Kłos 913fa080fa jsdialog: send close on dialog response
Change-Id: I730d99cc9aa519f07d6b1c436d749f2c0b044bfd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107151
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107349
Tested-by: Szymon Kłos <szymon.klos@collabora.com>
2020-12-08 11:22:31 +01:00
Szymon Kłos 7fc2fe5c61 jsdialog: fix arrays in JsonWriter output
Change-Id: I5638b1b02afcdd57b16b60d83d3d15da45866060
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107066
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
2020-12-03 08:45:24 +01:00
Philipp Hofer 1582d9a2c5 tdf#123936 Formatting files in module tools with clang-format
Change-Id: I0f66d02e67388cc4d21c5e96bf84b6848e8de63a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105721
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
2020-11-18 12:04:58 +01:00
Jan-Marek Glogowski 8babcdb9c9 osl+tools: fix Windows Arm64 build
Change-Id: I17cbc1c8474880024921f476aa602d61978da868
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102851
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2020-09-17 06:38:23 +02:00
Andrea Gelmini b866b71e24 Fix typo in code
It passed "make check" on Linux

Change-Id: I4db1681869907f050ea224ed24dcb7469a50eb20
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101792
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2020-09-01 08:49:07 +02:00
Stephan Bergmann 4ad4468675 Missing include (std::max; Windows --disable-pch)
Change-Id: I31d44c0a1791c58c0fc348fb2ec42fe2e2ec4323
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100003
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-08-03 17:11:42 +02:00
Miklos Vajna 51a4c85bf9 tools: fix 32bit Android build
tools/source/misc/json_writer.cxx:289:34: error: format specifies type 'long' but the argument has type 'sal_Int64' (aka 'long long') [-Werror,-Wformat]
    mPos += sprintf(mPos, "%ld", nPropVal);
                           ~~~   ^~~~~~~~
                           %lld
1 error generated.

Change-Id: Ieacf2f521f77292d61fa714bf584c9e2045c2e1b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97367
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2020-06-29 12:31:52 +02:00
Noel Grandin 01e37e3e56 use tools::JsonWriter for dumping property tree
Change-Id: I8f55af19ba10b71bd621e69b27000ab7cb565309
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96677
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-06-25 10:16:37 +02:00