88 Commits

Author SHA1 Message Date
Noel Grandin
e2e76df7e4 create strong_int template and use it in tools::UniqueIndex
an experiment to see how useful a strong_int template works out

Change-Id: Ib77700350f0fa3b018a1926233adf7a40d728d16
Reviewed-on: https://gerrit.libreoffice.org/34072
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-02-13 09:38:13 +00:00
Stephan Bergmann
d689ad29c2 New o3tl::runtimeToOUString to convert from C++ runtime NTBS to OUString
Change-Id: I613bb70b6828f615fd45af38b2d873ece55ace60
2016-11-23 23:11:02 +01:00
Caolán McNamara
5d2210d5f3 might as well go back to a std::stack now
after...

commit 8daf6707ef203b26a744140f74d7cd231a25f0dd
Author: Michael Stahl <mstahl@redhat.com>
Date:   Thu Oct 6 23:37:51 2016 +0200

    xmloff: fix crash in ~XMLParaContext on fdo72541-1.fodt

Change-Id: I57f10e60a2f76dde048a594d8391bb5b246dfc63
2016-10-07 08:58:57 +01:00
Caolán McNamara
fd79f88272 crashtesting: use a stack with the expected dtor order for its elements
contains test document which crashes if it doesn't

Change-Id: Ieeee6cc7007a90d37225fffd636c9648289f04d7
2016-10-04 12:14:09 +01:00
Michael Stahl
14bcb68cbb o3tl: replace yet another sal_Size with std::size_t
Change-Id: I3f6a401d6d5ed7b44a71dc8bda559dcc4d57ee32
2016-09-20 14:30:17 +02:00
Thorsten Behrens
5a7dbe1ec1 o3tl: refcounts should be native platform int width
Change-Id: I19854d85b680612733557c42ee58b35adb5ea4c3
Reviewed-on: https://gerrit.libreoffice.org/29002
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2016-09-19 08:06:14 +00:00
Jochen Nitschke
2aa61f07ec fix warning in windows debug build
> o3tl/typed_flags_set.hxx(82) : warning C4309: ´static_cast´ :
>                                truncation of constant value



Change-Id: I396b68e47d682ffe90ba3afb2ebf846cf100e20c
Reviewed-on: https://gerrit.libreoffice.org/28977
Reviewed-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
Tested-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
2016-09-17 15:01:03 +00:00
Stephan Bergmann
43d633d789 Try silence cid#1371124 ("Operands don't affect result")
...where Coverity doesn't reveal which instantiation of the templated code it is
complaining about, but it must be ScRefFlags (sc/inc/address.hxx), which has
underlying type sal_uInt16 and a mask of 0xFFFF.

Change-Id: If0abd195885acdffb3c61cdab88d7a2c87c00c4f
2016-09-16 17:55:15 +02:00
Stephan Bergmann
8132d7f9d7 o3tl::tryGet on a temporary is dangerous
...so rename to o3tl::tryAccess to make it more obvious that the returned
proxy points into the internals of the given Any, and forbid calling
o3tl::tryAccess on a temporary

Change-Id: Ia412c6b2b06693811b9b7f0076a08bbf97142df9
2016-06-10 15:52:05 +02:00
Stephan Bergmann
a411e3c9a3 Const correctness in o3tl/any.hxx
Change-Id: Ife6ce05430c99cd5452166c942320a3a301578ff
2016-06-10 12:58:05 +02:00
Stephan Bergmann
e5d45064fc Improve o3tl/any.hxx
* Ensure tryGet<XFoo> (instead of tryGet<css::uno::Reference<XFoo>>) doesn't
  compile.

* Add forceGet (as discussed at 0d7c5823124696f80583ac2a5f0e28f329f6f786 "New
  o3tl::try/doGet to obtain value from Any", to be used momentarily).

Change-Id: I57eb6ef18a6ab0d52bb26df7eb4e51b485fc83ed
2016-06-06 09:47:32 +02:00
Stephan Bergmann
0d7c582312 New o3tl::try/doGet to obtain value from Any
...in an attempt to reduce usage of type-unsafe

  void const * css::uno::Any::getValue()

These new functions are often more convenient to use than the existing ">>=" and
Any::get<T>.  Note how they are careful to provide a pointer directly into the
given Any, instead of creating temporaries.

As an example, replaced most calls of getValue across xmloff:

* Cases that first check for a specific type (via getValueType etc.) and then
  call getValue can instead call tryGet.  (But beware that tryGet supports some
  conversions, which a check for a specific type may have missed---either
  intentionally or by accident.  Also beware the somewhat common idiom of
  checking for TypeClass_ENUM and then using getValue to obtain a sal_Int32;
  this cannot be replaced with a call to tryGet.)

* Cases that seem confident that the Any is of the correct type when calling
  getValue (but apparently are confident due to some higher-layer protocol, as
  the surrounding code does not do any checking via getValueType or similar) can
  instead call doGet.  It throws an exception if it turns out the confidence
  wasn't warranted.  (Many of the existing calls that directly dereferenced the
  return value of getValue as sal_Bool look suspicious, in that the author might
  have thought the given code would also cover a VOID Any---which technically it
  even would have happened to do.  If any RuntimeExceptions thrown from these
  doGet calls start to crop up, these changes need to be revisited.  Some may
  even be rewritten as uses of ">>=".  But at least "make check" did not show
  any such problems.  Also note that casting the value obtained from getValue to
  any css::uno::Reference<X> with X being anything but the base
  css::uno::XInterface was always prone to producing a bad pointer, in case the
  interface actually stored in the Any derived from X via multiple inheritance.)

* Should there ever be cases where an Any is known to be of the requested type,
  some additional forceGet could be introduced (which would assert instead of
  throwing an exception).

Change-Id: I2d8739e86314eff73abfcafe01d806f5bc5c34db
2016-06-02 15:33:59 +02:00
Noel Grandin
fe0bba96ac Convert VclPackType to scoped enum
Change-Id: I5bcc4f8686c1ce5bf7def948ce50837fa542786f
Reviewed-on: https://gerrit.libreoffice.org/25394
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-05-24 13:07:03 +00:00
Michael Stahl
efc05c0a1e remove various crutches for boost::bind/boost::mem_fn
These aren't used any more, and the C++11 std equivalents don't use
get_pointer() overloads.

Change-Id: Ib97a6a595863e21a1621c63709ea2b28f6550fde
Reviewed-on: https://gerrit.libreoffice.org/24982
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
2016-05-13 21:51:08 +00:00
Noel Grandin
b14224fe97 loplugin:unusedmethods
using an idea from dtardon:

<dtardon> noelgrandin, hi. could you try to run the unusedmethods clang
plugin with "make build-nocheck"? that would catch functions that are
only used in tests. e.g., i just removed the whole o3tl::range class,
which has not been used in many years, but htere was a test for it...
<noelgrandin> dtardon, interesting idea! Sure, I can do that.

Change-Id: I5653953a426a2186a1e43017212d87ffce520387
Reviewed-on: https://gerrit.libreoffice.org/22041
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
2016-02-08 06:08:14 +00:00
David Tardon
da45a16860 remove unused o3tl::range
Change-Id: I080f4f2cb15d25ecf5545300da422957f24e3f9b
2016-01-29 14:11:25 +01:00
David Tardon
de26372420 remove unneeded sal/config.h
Change-Id: I7c8f06574053706f925df773aefc32407312c4dd
2016-01-29 14:11:25 +01:00
Michael Stahl
bde86f8074 vcl: replace boost::shared_array with std::shared_ptr
Add o3tl::make_shared_array() to create the shared_ptr with the right
deleter.

The main difference then is that shared_array has operator[], but this
code didn't even use it.

Change-Id: I500ffc2f92b99c2a3924c0cdcdaa101956b69add
2016-01-26 17:51:29 +01:00
Stephan Bergmann
96fea1a05d Make enumarray_iterator adhere to iterator requirements
...or else using it with GCC 6 libstdc++ std::find causes compilation failures

Change-Id: I95e674922348f72fab6da8f049b2b4fcbdc74d07
2016-01-19 10:46:13 +01:00
Michael Stahl
7984e90d52 remove unused o3tl/ptr_container.hxx
Change-Id: I8132958b979add35bdd7aea52ce8788f3cdcbe51
2016-01-13 17:53:14 +01:00
Andrea Gelmini
64d624b651 Fix typos
Change-Id: I9a5940027423ff0791fa7da0b79b617412ce6b86
Reviewed-on: https://gerrit.libreoffice.org/21209
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-10 14:17:20 +00:00
Stephan Bergmann
3a459b52c5 std::swap is in <utility>, not <algorithm>
Change-Id: I8b93f053276ff273f2f79ed29d7605d976f7d866
2016-01-06 07:53:23 +01:00
Noel Grandin
deb5bae091 BOOST_ASSERT->assert
Change-Id: Ifbb80c90f8530ebf4660493447c2c076587bebd6
Reviewed-on: https://gerrit.libreoffice.org/19795
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2015-11-05 07:23:19 +00:00
Stephan Bergmann
ba45d25420 Replace "SAL_FINAL" with "final" in LIBO_INTERNAL_ONLY code
Change-Id: Ifa5ba21308e32df44571fa2941370f2f11179580
2015-10-12 17:52:30 +02:00
Andrea Gelmini
d344d2b1f5 Fix typos
Change-Id: I6dfb5fb468c1305a8f248bf5788c5760135fd835
Reviewed-on: https://gerrit.libreoffice.org/18955
Reviewed-by: Oliver Specht <oliver.specht@cib.de>
Tested-by: Oliver Specht <oliver.specht@cib.de>
2015-09-30 12:38:10 +00:00
Stephan Bergmann
e261881452 Avoid unhelpful -Wunused-variable
...at least from "g++ (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4)" with
--disable-debug, when a namespace-scope const variable with a "complex"
initializer declared in an include file remains unused.

Avoid that warning via SAL_CONSTEXPR, which in turn requires large parts of
o3tl::is_typed_flags to be SAL_CONSTEXPR, which in turn requires a new
HAVE_CXX14_CONSTEXPR to allow assert in constexpr functions, which in turn
requires using -std=c++14 instead of -std=c++11 where available, which in turn
(a) requires to /not/ use -std=c++14 if it would run into a bug between Clang
and libstdc++ discussed at <https://llvm.org/bugs/show_bug.cgi?id=24115>
"llvm-nm fails to build with gcc 5.1's libstdc++" (and which hits us in
sfx2/source/control/thumbnailview.cxx), and (b) requires a new
HAVE_CXX14_SIZED_DEALLOCATION to work around GCC 5.1 -Werror=sized-deallocation
(where Clang >= 3.7 only supports C++14 sized deallocation when explictly
enabled via -fsized-deallocation, btw).

This effectively reverts ff6462e6307e6924dc6c8178043ae9032f4b4152 "avoid unused
variable warning:" again.

Change-Id: I424e3561452a3e6d8c8a9604d6c737cab49840c4
Reviewed-on: https://gerrit.libreoffice.org/18918
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2015-09-30 11:06:14 +00:00
Stephan Bergmann
8f4c632b87 Remove unnecessary typedef from previous attempt again
Change-Id: Ic3e5c4aef4235124069035daadfb53ff3a1368a5
2015-09-16 08:03:28 +02:00
Stephan Bergmann
fed145be52 Fix binary ops with two o3tl::type_flags<E>::Wrap params
(the original ones would never have been picked due to how template argument
deduction works)

Change-Id: I5a08c763d721d8e11b5a10af2344a6a24bb0b9b2
Reviewed-on: https://gerrit.libreoffice.org/18583
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2015-09-15 12:31:50 +00:00
Stephan Bergmann
78e95e46bb loplugin:simplifybool
Change-Id: I5bfc2a84cef68421757e9aa8f5e4bcb1d6caf7bf
2015-08-30 19:37:34 +02:00
Daniel Robertson
6900bf41e2 o3tl/cow_wrapper: remove boost dependency
Remove boost dependencies from ::o3tl::cow_wrapper, and add
the necessary includes to files including checked_delete and
noncopyable that do not already include the necessary files.

Change-Id: Iedae4232002792724226829a5d5cf9d16ffd0686
Reviewed-on: https://gerrit.libreoffice.org/18125
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2015-08-29 22:51:36 +00:00
Daniel Robertson
311e77440f o3tl: add another unit test to cow_wrapper
Add unit tests to cow_wrapper for the move ctor and move assignment.

Change-Id: I82a5886ca7ae110985c7202125699cf95b6466d8
Reviewed-on: https://gerrit.libreoffice.org/18108
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2015-08-29 22:47:38 +00:00
Noel Grandin
a05d6ac2a2 Revert "create a macro to tidy up the declaration sites of o3tl::typed_flags_set"
sberg did not like this macro, let's see if I can find a better
solution.

This reverts commit e51fa143587d018b75db08e60cf27ff932b1cf8d.
2015-08-26 08:26:51 +02:00
Daniel Robertson
6038ba92be o3tl: cow_wrapper add move constructor/assignment
Add a move constructor and move assignment operator for
o3tl::cow_wrapper. Insubstantial gains for UnsafeRefCountingPolicy, no
atomic increment needed for ThreadSafeRefCountingPolicy's move-ctor.

Change-Id: Ia2de1ca78b1e0e5a0f30535e752f1dd858fdfef0
Reviewed-on: https://gerrit.libreoffice.org/17848
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2015-08-19 21:25:29 +00:00
Thorsten Behrens
ad1f0d1f1a o3tl: rename compat_functional header
After the cleanup, the stuff there really stands on its own (and the
remaining usage of select1st/2nd is more descriptive than lambdas).

Change-Id: I0aba131d5dc550189f8130d167dc94167e404540
Reviewed-on: https://gerrit.libreoffice.org/17806
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2015-08-17 16:38:30 +00:00
Thorsten Behrens
9c4d75bea5 o3tl: remove unused code
Change-Id: Ia7bcb590ab5b535af8cacead1e8afd735c463aaf
Reviewed-on: https://gerrit.libreoffice.org/17805
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2015-08-17 16:34:24 +00:00
Daniel Robertson
3babca3e84 tdf#92459 basebmp: replace project2nd
Replace the use of project2nd in basebmp with a specialized functor
similar to what is seen in paletteformats.hxx and
pixelformatadapters.hxx. There should be no side effects due to this
change.

Change-Id: I1bbd723931e41986542e92bac773bbea68cfe5bd
Reviewed-on: https://gerrit.libreoffice.org/17660
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
2015-08-13 05:34:33 +00:00
Daniel Robertson
ae6afadbc0 tdf#92459 o3tl: remove unary_function
Clean up o3tl/compat_functional.hxx select1st/select2nd. Remove the
structs inheritance from the now deprecated unary_function. Remove
project1st, as it is not used.

Change-Id: I60c0f30c4b87417a331a4b38f62993cc3d1c9a51
Reviewed-on: https://gerrit.libreoffice.org/17625
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2015-08-11 22:23:48 +00:00
Noel Grandin
cebfe56ae5 add assert for valid value in o3tl::typed_flags_set
, fixing a couple of bugs in the process

Change-Id: I40f932deecbcc99dff9aa13dd1882c7487e7fa8e
Reviewed-on: https://gerrit.libreoffice.org/17411
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2015-07-30 07:15:39 +00:00
Tomaž Vajngerl
80a9213480 LRU map (cache) implementation to o3tl + tests
Change-Id: I6b1a39918e6c8c67712be2c8e9907266dcfefedb
2015-07-24 19:15:00 +09:00
Noel Grandin
e51fa14358 create a macro to tidy up the declaration sites of o3tl::typed_flags_set
Change-Id: Ifb8fd4fd5128188420f1dfda6b6f695160d5e77a
Reviewed-on: https://gerrit.libreoffice.org/15865
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2015-07-15 23:40:19 +00:00
Michael Stahl
7aa9f04538 do not include boost/utility.hpp
It just includes a bunch of other boost headers; mostly we need
boost/noncopyable.hpp so include that directly.

This eliminates 831 MB(!) of boost/preprocessor/seq/fold_left.hpp
completely, which is the 2nd biggest header after ustring.hxx.

Change-Id: I3df55770adcb46e56f389af828e8ba80da2dc1f2
2015-07-10 23:25:22 +02:00
Stephan Bergmann
3a68a7dcf4 Remove workarounds for no longer supported GCC 4.6
In bridges/source/cpp_uno/gcc3_macosx_x86-64/share.hxx, the #if also covered
Clang, which actually needs these declarations (for now; the right fix will
probably be to #include <cxxabi.h>).

Change-Id: I1eebd59e2371f3498d740ab78244927358c4f23f
2015-06-26 17:31:14 +02:00
Miklos Vajna
821b72886f o3tl: add make_unique template till we can't use std::make_unique
Change-Id: I48b26f0199e339badf7a0e2bed322ca701689d13
Reviewed-on: https://gerrit.libreoffice.org/15846
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2015-05-21 18:31:42 +00:00
Thorsten Behrens
0aa2fd972f Fix ICEs in gcc 4.6.3 for small-int typed_flags.
Subtle failures in nested template instantiations there, for
sal_{u}Int8 and sal_{u}Int16 - use wide-int fallback to do bitmask
ops. Type is not used to store any dynamic values.

This partially reverts a1ecce3ad7df6a82191c4956cec986dc50503dde

Change-Id: Ifa7070c1c3830fd70d7ced082d651411ff523444
2015-05-09 10:42:27 +02:00
Thorsten Behrens
973d038193 Revert "improve fallback behaviour of underlying_type for old gcc"
This reverts commit 7ad4e562b462af22a1c29c955293238cdb30267b, which
was causing ICEs on precisely the compiler versions it was targetted
at.

Change-Id: I996792d723a8bd0d7edd5f248d74217322b5ce3f
2015-05-09 10:41:40 +02:00
Christoph Lutz
7ad4e562b4 improve fallback behaviour of underlying_type for old gcc
The fix fbd85c25b is not sufficient to build with an old GCC 4.6.
The problem was, that underlying_type returned an int as default
value for GCC 4.6 and int allows negative values that are forbidden
in typed_flags_set.

Changed it to alternative solution suggested in
http://stackoverflow.com/questions/26148192/underlying-type-of-a-c-enum-in-c03

Change-Id: I20f44b8cef9c692efb583971bd251f1c34c289ab
Reviewed-on: https://gerrit.libreoffice.org/15663
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Tested-by: Katarina Behrens <Katarina.Behrens@cib.de>
2015-05-07 14:10:51 +00:00
Stephan Bergmann
d01810b745 enumarray_iterator should not have a deleted copy assignment op
Change-Id: I1e5f8dcfe0801eca10622eefab43b674b6b3e956
2015-04-29 11:15:11 +02:00
Noel Grandin
6bb742b9cb convert STR_EVENT constants to scoped enum
- also add needed infrastructure to o3tl::enumarray so we can use
std::find on it
- move the Impl inside the .cxx file, no need to expose it in the header

Change-Id: I7758a6175849f46723d97b1e657f846524c3b7cd
2015-04-29 10:41:40 +02:00
Stephan Bergmann
1f7825a829 loplugin:simplifybool
Change-Id: I981d5a77cfe74ef81b235963820151cbea55370c
2015-04-24 12:36:24 +02:00
Stephan Bergmann
6bee77922c Get rid of false GCC 4.7 -Werror=type-limits in template code
Change-Id: I4b13d3b7d74690401234dfa30c8c1b6647820b6a
Reviewed-on: https://gerrit.libreoffice.org/15216
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2015-04-10 07:53:41 +00:00