summaryrefslogtreecommitdiff
path: root/comphelper
AgeCommit message (Collapse)Author
2022-06-02Reuse o3tl::getTokenStephan Bergmann
Change-Id: Ib8d3b3d02febc03922104a954531db6057d06783 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135318 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-06-02Use more appropriate return type for ThreadPool::getPreferredConcurrencyStephan Bergmann
All call sites already effectively asked for an unsigned return type, including: * The ThreadPool ctor took an nWorkers argument of type sal_Int32, but internally stores that as std::size_t mnMaxWorkers. * ZipOutputStream::reduceScheduledThreadTasksToGivenNumberOrLess apparently benefits from an unsigned nThreadTasks parameter, getting rid of various casts in its implementation that were necessary to silence signed vs. unsigned comparison warnings. The only drawback is that comphelper::ThreadPool::getPreferredConcurrency() * 4 in package/source/zippackage/ZipPackageStream.cxx would now silently wrap around instead of causing UB on overflow (which could be detected with appropriate tools). Ideally, it would use some o3tl::saturating_mul if we had that, so add a TODO comment for now. While std::thread::hardware_concurrency returns unsigned, it looked more natural to go with std::size_t here, as some call sites already used that (see above), so the implementation of ThreadPool::getPreferredConcurrency is a natural place to hide clamping std::thread::hardware_concurrency() to std::size_t (in the unlikely case that std::size_t is of smaller rank than unsigned). This required addition of o3tl::clamp_to_unsigned in o3tl/safeint.hxx. Change-Id: I0a04a8b32e63ebfeb39f924c4b38520455a6fb38 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135309 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-06-02There should be no need for a cast hereStephan Bergmann
...presumably added back in the day to avoid warnings about signed vs. unsigned comparisons with old compiler versions Change-Id: Id95e272949e48adf0e75883368cbcd421e289b33 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135292 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-06-01fix buildRene Engelhard
add #include <optional>, since: [build CXX] comphelper/source/property/ChainablePropertySetInfo.cxx /home/rene/LibreOffice/git/master/comphelper/source/property/ChainablePropertySet.cxx: In member function 'virtual void comphelper::ChainablePropertySet::setPropertyValue(const rtl::OUString&, const com::sun::star::uno::Any&)': /home/rene/LibreOffice/git/master/comphelper/source/property/ChainablePropertySet.cxx:54:10: error: 'optional' is not a member of 'std' 54 | std::optional< osl::Guard< comphelper::SolarMutex > > xMutexGuard; | ^~~~~~~~ /home/rene/LibreOffice/git/master/comphelper/source/property/ChainablePropertySet.cxx:23:1: note: 'std::optional' is defined in header '<optional>'; did you forget to '#include <optional>'? 22 | #include <comphelper/solarmutex.hxx> +++ |+#include <optional> 23 | happens since 49b9401465730b1151917bffcbc0ad1f0622fcee Change-Id: I643e7811f1ec7588ccde5453303cd57675c6165e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135252 Tested-by: Jenkins Tested-by: René Engelhard <rene@debian.org> Reviewed-by: René Engelhard <rene@debian.org>
2022-06-01no need to allocate guards on the heapNoel Grandin
Change-Id: I66491a057f082a970158504474b678dbb4decf50 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135228 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-31Use more appropriate type for comphelper::internal::OPropertyAccessor::nPosStephan Bergmann
Change-Id: Ia7055dcc3832002fd10ae23a35fd08df5a98ae40 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135177 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-05-30Use o3tl::make_unsigned, nCount is already asserted non-negative hereStephan Bergmann
Change-Id: I7213e9f2e3a5a4a785d44932900496a791b1964a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135146 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-05-30cid#1504574 Resource leakCaolán McNamara
make an owner for the PropertyMapEntries Change-Id: Ie915a8a312f2b24488566814ad67fdeef89b5941 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135123 Tested-by: Jenkins Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-05-29Drop now-redundant castStephan Bergmann
...that 3ca1a169e571a829598a00a2ffef6e1018d2cb18 "Use boost::noinit_adaptor" forgot to remove Change-Id: I82818c72e9178cda7b9698d8a30e1b8f3c3d87c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135099 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-05-29Fix mid-air collisionStephan Bergmann
...between d203e3f35dc4547bb46151637ba6054d13025d01 "use comphelper::ByteWriter in UNOMemoryStream" and 3ca1a169e571a829598a00a2ffef6e1018d2cb18 "Use boost::noinit_adaptor" Change-Id: Ie890288485f499505184a12b0797d5fc9b877922 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135098 Tested-by: Stephan Bergmann <sbergman@redhat.com> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-05-29Use boost::noinit_adaptorStephan Bergmann
Change-Id: Ide5f0394172548ed6a1ef4a6277ebf4752e685bb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135094 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-05-26clang-tidy modernize-pass-by-value in comphelperNoel Grandin
Change-Id: I29074d801eaef57f160ce14b943b21831b327ecf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134979 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-25directly instantiate IndexedPropertyValuesContainerNoel Grandin
without the overhead of the UNO service engine Change-Id: I4a02fda2b3c92a897634374bf72cfffee4f531f8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134923 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-25use comphelper::ByteWriter in UNOMemoryStreamNoel Grandin
to avoid a temporary buffer Change-Id: Ibe1d4ffb240993e14eaaddb219f9cde328f9afbe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134919 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-25allow comphelper::OEnumerationByName to use a vector too for namesNoel Grandin
so we can skip some allocation. Use a std::variant to preserve existing functionality Change-Id: If01ebb04f7895fd52fa3f5d90648868fd38dc39e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134929 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-24modernize and improve PropertySetInfoNoel Grandin
(*) use o3tl::span for the array param, which means we don't need a null entry to terminate the array (*) use std::unordered_map to speed things up (*) mark the array as static at a few more call sites Change-Id: I05b6cae7552f44459e183ec05cb94e60edb3bfe0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134832 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-23comphelper: -Werror=class-memaccessMichael Stahl
Change-Id: Ia38274fac70618902f562fec657ad9cccfcf8cb3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134735 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2022-05-22cid#1504544 deliberately Uninitialized scalar fieldCaolán McNamara
Change-Id: Idbc44ac01787f93fa5af1e5358a70590fa4cc64d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134722 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-05-20don't waste time on memset when we're just going to overwrite itNoel Grandin
Change-Id: Id01b056a28e23c55757b0b4e08a5901c76821b6b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134677 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-20elide temporary OUStringBuffer in INetURLObjectNoel Grandin
which requires a version of replaceAt for OUStringBuffer, which I'll put in comphelper::string:: for now Change-Id: I70b319b018e29a7dac26965dd92f6c4f9ea470ec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134679 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-20comphelper: fix natural string compare function + reorganize testsTomaž Vajngerl
Natural string compare function doesn't take into account that the string can start with a number and in this case it treats it like a conventional string compare. This change takes this case into account. This change also refactores the tests for NaturalStringSorter class. The previous tet used a mock XBreakIterator and XCollator implementations to test the functionallity. This is not needed as we can just use a real one instead, which makes the test more real as it actually uses a real implementation instead of a mock implementation, which could differ. This change removes the mock XCollator and XBreakIterator implementations and moves the test into a new file - NaturalStringSortTest.cxx The test is also extended with the new use case where the string starts with a number. Change-Id: I32ea055f914c2947e4d979093b32f56170a61102 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134540 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2022-05-19optimise NumberedCollection::impl_searchFreeNumber some moreNoel Grandin
Change-Id: I3740bb4f425020eb420fa6217b7c1373befa7e04 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134646 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-19add ByteWriter to reduce memory copying when writing dataNoel Grandin
similarly to ByteReader move both of them down to comphelper, since we want to use it from comphelper, and comphelper is "below" unotools in the module dependency graph Change-Id: Ic98fa2268e125fd8e4378fb899ad5f97de721713 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134645 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-15don't construct SequenceAsHashMap just to extract a couple of propertiesNoel Grandin
because construcing SequenceAsHashMap requires allocating a bunch of heap objects Change-Id: I2bb1d05b23613d8c8f8a475e006b313578c18c5d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134343 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-14tdf#121740 cache hashcode in SequenceAsHashMapNoel Grandin
shaves 2% off load time Change-Id: I5bd4eabf61205df21a27d2822acd2676a7732a3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134315 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-14use std::mutex in LocalProcessFactoryNoel Grandin
which much faster than osl_Mutex, and especially for this simple case Change-Id: I4e8ba221649587af76c7f7cac5f308821490980a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134300 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-14simplify constructionNoel Grandin
Change-Id: Ib8a28575fe813a909ce5429732a60ae77f92b6ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134269 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-13Remove need for two typedefsStephan Bergmann
Change-Id: I8e576f0b2b417ed78e6f38b745e51cbf8b666c68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134262 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-05-12speed up simple use of NamedValueCollectionNoel Grandin
where instantiating and allocating a whole map just to extract a single key is way inefficient Change-Id: I55248bc71a9e8826cab9b76fa6916bfa888efa0b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134226 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-12reserve space in vectorNoel Grandin
Change-Id: Ibdc882eff13b767076fc26f4c7cd7882bcb7f68d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134222 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-11use better default size for UNOMemoryStreamNoel Grandin
which means we don't need to re-allocate the buffer as often Change-Id: I81678af2ed4146b94eb200324459eef7016afd06 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134196 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-11reserve space for bulk operations in SequenceAsHashMapNoel Grandin
reduces the number of allocations we do Change-Id: If8e61c8b0dd1942278d7adc1fa87580734aeeb99 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134157 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-11cache the Sequence we return in comphelper::PropertySetInfo::getPropertiesNoel Grandin
Change-Id: If4e6e43be5d7380665e56bf95c446ff14e6a7213 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134155 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-11avoid some OUString construction on some hot pathsNoel Grandin
Change-Id: I098b017d22b7a4502998a0901ddcfca08a57ee43 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134115 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-10tdf#147590 update OLE object after document refreshJuergen Funk
Regression from b099da78a6f0b3e120f706714003b05d84d11e70 we didn't update linked OLE document after document reload Change-Id: I8e52f6430f454b276cb43449c6f7a3b0e07e909f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130692 Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> Tested-by: Jenkins
2022-05-09tdf#147021 Use std::size() instead of SAL_N_ELEMENTS() macroPragat Pandya
Change-Id: I54257e87da0cd66da59d820c7960c3e4b020fda3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134027 Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl> Tested-by: Jenkins
2022-05-07remove dead item cleanup from NumberedCollection::impl_searchFreeNumberNoel Grandin
which speeds it up a little, because WeakReferences are a little slow Change-Id: I76226b180ae4e11c4beb9e2f4ae12b05f980dcad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133960 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-07osl::Mutex->std::mutex in comphelper::GenericPropertySetNoel Grandin
Change-Id: Ifbb8e2f7e8923d7bdc333097d6f415f10670e0df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133970 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-06Only dereference iterators after checking themMike Kaganski
Was this way since commit edf11d28fafac50b6380c9372d0e6cf07a355616 Author Vladimir Glazounov <vg@openoffice.org> Date Thu Apr 24 16:27:52 2003 +0000 INTEGRATION: CWS uaa02 (1.3.44); FILE MERGED Surfaced after commit b1148c31ed2786396f0b018a988fce8288f1797d Author Noel Grandin <noel.grandin@collabora.co.uk> Date Wed Apr 27 16:47:53 2022 +0200 use more string_view in comphelper where the pointers were changed to iterators, which are checked in debug builds, failing an assertion. Change-Id: I87fce562aef8f50b94fb52ad6c2a79d2e84d6424 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133934 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-05-06tdf#128744 sw DOCX: unprotect change tracking with verificationLászló Németh
Unprotect change tracking only by password verification instead of 1) unprotecting without the password or 2) rejecting the correct password. I.e. now 1) clicking on Record changes icon of Track Changes toolbar or Edit->Track Changes->Record asks for a password, and 2) Unprotect Record changes on Security page of File->Properties... accepts the correct password with disabling record changes. Show also "Invalid password!" dialog disabling Record Changes by its icon or menu option, like Properties... dialog window does, if the password is invalid. Note: Still allow to unprotect OpenDocument export of a protected OOXML import document, because that doesn't contain the original password info, only a dummy RedlinePassword. (OpenDocument exports protect Track Changes with the simple RedlineProtectionKey configuration setting, so it's not possible to map the OOXML password info to OpenDocument without extending this.) Follow-up to commit d416250f4f1766e2d596ea3feef6a94b7adf29f4 "tdf#106843 DOCX: forbid disabling protected Record Changes". See also commit bfd7730f4cf002a79dc9c02c23286850fee3f12a "tdf#89383 DOCX import: fix permission for editing". Change-Id: Iafcf4a6b551a7e8485d4311aee889c2522526d71 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133894 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
2022-05-06comphelper: cleanup test_guards, add test for ValueRestorationGuardTomaž Vajngerl
Move each test case into its own test function. Also add the missing test for ValueRestorationGuard. Change-Id: I588ab67f82ba82ef67939dac3d22438e8799ce11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133917 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2022-05-06Remove duplicated includesAndrea Gelmini
Change-Id: I137707aaad44ffe42bb4b234a59ff69e4b2ecaa2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133884 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Jenkins
2022-05-05use more o3tl::getTokenNoel Grandin
found by inspecting call sites of OUString::getToken Change-Id: I4269c7476c7aa46fac39528227e350568f0eb34a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132644 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-05use more string_viewNoel Grandin
found by examining the call sites of OString::getToken which means I needed to add a new o3tl::equalsAscii function Change-Id: I7dc0ea1cf5ce8090a708d44f2cf7c938fa200c5f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133826 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-04Just use Any ctor instead of makeAny in comphelperStephan Bergmann
Change-Id: Ib3edbef27c2d25dae8bac07e0199af071131170e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133839 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-05-03Adapt Base64::decodeSomeChars to change from OUString to std::u16string_viewStephan Bergmann
...in 9c95415de877af1430ab5b7123e11dedd0ea622c "Let comphelper::Base64::decode* take std::u16string_view" Change-Id: I42b1552fba80568b422cb60ccc99a7ab8664f2d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133711 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-04-30split comphelper::string::strip functions into String and view versionNoel Grandin
which is more obvious, from the perspective of the caller, and lets us avoid creating a new String if nothing needs to be stripped Change-Id: I66a980eaf4aa818251bec49bdb16c2dddb0745e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133657 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-04-29Check iterator before dereferenceMike Kaganski
... since commit b1148c31ed2786396f0b018a988fce8288f1797d Author Noel Grandin <noel.grandin@collabora.co.uk> Date Wed Apr 27 16:47:53 2022 +0200 use more string_view in comphelper Change-Id: I182bc507b5693048350d6e54bb7b6176389e2241 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133596 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-04-28use more string_view in comphelperNoel Grandin
Change-Id: I1544da756d8da074787bc19a98d2740058e36479 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133520 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-04-26add o3tl::toUInt32Noel Grandin
Change-Id: I07f11bf12fbe1d1c2d812fa0965d6e632e1e1aba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133437 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>