Commit Graph

165 Commits

Author SHA1 Message Date
de0ea66610 Improved loplugin:redundantcast, static_cast on arithmetic types: sal
Change-Id: I7caadbc06b2266800666151de75d799c42148aca
2017-04-06 18:31:59 +02:00
9ac98e6e34 Finally switch MSVC to sal_Unicode = char16_t, too
There is lots of (Windows-only) code that relied on sal_Unicode being the same
as wchar_t, and the best change may be different in each case (and doing the
changes may be somewhat error prone).  So for now add SAL_U/SAL_W scaffolding
functions to sal/types.h, remove their uses one by one again, and finally drop
those functions again.

Change-Id: I2cc791bd941d089901abb5f6fc2f05fbc49e65ea
Reviewed-on: https://gerrit.libreoffice.org/36077
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-04-04 16:12:11 +00:00
da56de9ac4 remove type decorations on char literals
they are only needed where type deduction fails.
left them in defines for now.

Change-Id: I7f002dd6bc7acc083c73b6c64076de6dd28d0b09
Reviewed-on: https://gerrit.libreoffice.org/35893
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-03-30 12:21:40 +00:00
86781bcfc8 Fix typos
Change-Id: I998e9b2ad8ebdcc983239192cb61f6689e378ad9
Reviewed-on: https://gerrit.libreoffice.org/35633
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2017-03-25 10:49:09 +00:00
f9bf486e25 Better check for 'defined LIBO_INTERNAL_ONLY'
(to avoid warnings about undefined macros in external code)

Change-Id: Ie1007207b22c19a3d9d96f0f94070c32d417595a
2017-03-24 16:35:32 +01:00
f5c93d4149 Use rtl::isAscii* instead of ctype.h is* (and fix passing plain char)
and add rtl::isAsciiWhiteSpace

Change-Id: Iac71975f718b9360ea9dc94485c069c5e7cb91c7
2017-03-22 21:31:00 +01:00
7778d9f51b Prevent calls to rtl/character.hxx functions with (signed) char arguments
...that would implicitly be sign extended (for plain char only if it is signed),
so non-ASCII char values would trigger the isUnicodeCodePoint assert.

Change-Id: Iaf8024ad509e64525558e882fe3fd078cfb4ea91
Reviewed-on: https://gerrit.libreoffice.org/35523
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-03-22 09:00:57 +00:00
46b8d2b78a Mark rtl_locale_get/setDefault as deprecated
unused in LO itself since 73bda5058bcef6be9a3185aa46375c7b147ffa22 "ditched
rtl::OLocale"

Change-Id: I6fd713f4771d7a7a397ef08002d1b9d754417f67
2017-03-21 16:31:33 +01:00
e6ce64b1d7 Only need an OStringBuffer in number2PolyPolygon
...so that later passing the OStringBuffer's aNum[i] to
createSevenSegmentPolyPolygon (taking a first parameter of type char) doesn't
need to implicitly convert from sal_Unicode to char.

Requires addition of some missing OStringBuffer-related function variants in
rtl/math.hxx and rtl/strbuf.hxx.

Change-Id: I79e6b2a791abc62b6556a6668e4411cced490c11
2017-03-21 08:54:05 +01:00
6cb9e6dad7 Remove redundant 'inline' keyword
...from function definitions occurring within class definitions.  Done with
a rewriting Clang plugin (to be pushed later).

Change-Id: I9c6f2818a57ccdb361548895a7743107cbacdff8
Reviewed-on: https://gerrit.libreoffice.org/34874
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-03-03 20:55:50 +00:00
bcb402298f Fix typos
Change-Id: I5e3c9683741ddc66283008c20794be5c2b2bc53f
Reviewed-on: https://gerrit.libreoffice.org/34804
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-03-03 06:56:42 +00:00
ba42357925 Remove uses of SAL_CONSTEXPR in LIBO_INTERNAL_ONLY
Change-Id: I9a7dc7c83302b3361f056fcf6636bbba7672f15f
Reviewed-on: https://gerrit.libreoffice.org/34840
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-03-03 06:47:35 +00:00
8646ab97dc Remove MinGW support
In OOo times, there'd originally been efforts to allow building on Windows with
MinGW.  Later, in LO times, this has been shifted to an attempt of cross-
compiling for Windows on Linux.  That attempt can be considered abandoned, and
the relevant code rotting.

Due to this heritage, there are now three kinds of MinGW-specific code in LO:

* Code from the original OOo native Windows effort that is no longer relevant
  for the LO cross-compilation effort, but has never been removed properly.

* Code from the original OOo native Windows effort that is re-purposed for the
  LO cross-compilation effort.

* Code that has been added specifially for the LO cross-compilation effort.

All three kinds of code are removed.

(An unrelated, remaining use of MinGW is for --enable-build-unowinreg, utilizing
--with-mingw-cross-compiler, MINGWCXX, and MINGWSTRIP.)

Change-Id: I49daad8669b4cbe49fa923050c4a4a6ff7dda568
Reviewed-on: https://gerrit.libreoffice.org/34127
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-02-10 18:01:27 +00:00
1480a2d05a add 'explicit operator bool' to our reference classes
Change-Id: I91cfbe2646dcc55b98d2b809c49c9ea073f54f58
Reviewed-on: https://gerrit.libreoffice.org/33517
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-01-26 06:11:42 +00:00
387a035d74 New loplugin:externvar: sal
Change-Id: Iefc33784f21e7a0b88c8d6308618926e38ab8554
2017-01-09 15:41:25 +01:00
e497d4d490 coverity#1371227 Missing move assignment operator
Change-Id: I2de6b5e2910ff570c08e662769d5e6ee188825a7
Reviewed-on: https://gerrit.libreoffice.org/32843
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-01-09 09:05:41 +00:00
c03d803a72 Replace side-effect--only uses of makeStringAndClear() with setLength(0)
Change-Id: Iaf8011f1bd6a10b324653899b7f51458f7d0b68a
2017-01-05 13:52:17 +01:00
87707670c9 Make OUStringLiteral more useful
...by:

* making the OUStringLiteral ctor non-explicit (to be exploited in a follow-up
  commit)

* adding (LIBO_INTERNAL_ONLY) overloads to OUString/OUStringBuffer functions
  that can now take OUStringLiteral in addition to taking "real" string literals

(Keeping the number of overloads smaller by replacing the ConstCharArrayDetector
overloads with ones taking OUStringLiteral (for LIBO_INTERNAL_ONLY, at least)
and relying on the now-implicit conversion from "real" string literals to
OUStringLiteral unfortunately would not work:  Both OUString and OUStringLiteral
argubably need implicit conversions from "real" string literals, so any function
overloaded for OUString and OUStringLiteral would be ambinguous when called with
a "real" string literal.  And removing the OUString ctor taking a "real" string
literal and relying on an implicit conversion chain from "real" string literal
to OUStringLiteral to OUString doesn't work because it would involve two user-
provided conversions.)

Change-Id: I14433fc1605b048807f60b3a3e14f92221d3a226
Reviewed-on: https://gerrit.libreoffice.org/32097
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2016-12-17 16:11:10 +00:00
0dc19268d2 Typo in meant-to-be-overloading function name
Change-Id: I65ab9176b39a436afce23e6bd4423ebf76219166
2016-12-16 12:57:53 +01:00
40633e32f3 Revert "Revert "Prevent nonsensical comparations between OUString and nullptr_t""
This reverts commit e559c0c9cbfd819f22ef695a9823bb71f4385b58; just turn the
deleted overloads into non-friend functions (and rely on any other overloads to
be still found via ADL).

Change-Id: I2af834162cab2e71ed9e32ae6903bc9f86d77ba2
Reviewed-on: https://gerrit.libreoffice.org/30441
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2016-10-31 15:29:17 +00:00
e559c0c9cb Revert "Prevent nonsensical comparations between OUString and nullptr_t"
This reverts commit 2e3f5c8dd3b21efe83269f603e26ac20f3adde64, some GCC
have trouble with deleted friend functions; need to fix that properly.
2016-10-31 13:37:17 +01:00
2e3f5c8dd3 Prevent nonsensical comparations between OUString and nullptr_t
...now that

1b98f38 css.xml.sax.XAttributeList is broken by design
074defe Strange OUString null check
a24105a Nonsensical OUString null check
9799fe3 Nonsensical OUString null check
d6b9fea Nonsensical OUString null check
f2de7d0 This apparently always wanted to check that _rChars.trim() is non-empty
a8cfc97 SvxBrushItem::GetGraphicLink no longer returns a pointer

are fixed.  (OString didn't have this problem with overloaded operator ==/!=,
but had a similar issue with nullptr_t that OUString in turn didn't have,
f20162304d73bc01955e9ef6506c3bd1c7016c48 "Rule out OString(std::nullptr_t)".)

Change-Id: I4ca0e1f5a911448e7bc9b8c5dddff5993d61ef18
2016-10-31 13:23:34 +01:00
802f2a4208 Don't allow O[U]StringBuffer in string concatenation
...as

  OStringBuffer b("foo"); b = "bar" + b;

doesn't work as one might expect (see the mail thread starting at
<https://lists.freedesktop.org/archives/libreoffice/2016-October/075464.html>
"concat of OUStringBuffer".  That feature was LIBO_INTERNAL_ONLY, anyway.  And
of the affected places, MethodDescriptor::getSignature
(codemaker/source/javamaker/javatype.cxx) was the only one that would actually
have benefitted.

Change-Id: Ib84266f43e40c42c2e428f0c0616db8cfa90adff
2016-10-12 16:05:32 +02:00
5c2894222b New rtl::splitSurrogates, remove code duplication
Change-Id: Ic96b64244f817196ccdfe06b97f7f31291adf372
2016-10-07 18:12:26 +02:00
2c3ebb202f @since tag; sorting
follow-up to 2135eae2a97c17d89cb47a2074830fd2d7b2226f "let approxEqual() not
scale too early for large representable integer values"

Change-Id: I628e01297fea08915d0ca1c95f3ba13f7ce15db8
2016-10-04 14:08:24 +02:00
2135eae2a9 let approxEqual() not scale too early for large representable integer values
And since this is now too much code for inline move implementation to math.cxx
Which again made it necessary to give libreofficekit lokdocview.cxx its own
implementation that doesn't even claim to build against sal ...

Change-Id: I0f80be9d9172ee20693b9babde715206f2c3d8c1
Reviewed-on: https://gerrit.libreoffice.org/29428
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins <ci@libreoffice.org>
2016-10-01 22:55:57 +00:00
e1954f5ba5 Related cid#1371287: Work around missing OStringBuffer move semantics
...by adding more assign op overloads instead

Change-Id: I3686d6c29adc47b1a8c48be4260614fd53589c8b
2016-09-20 11:36:24 +02:00
95ee4cab86 Related cid#1371289: Work around missing OUStringBuffer move semantics
...by adding more assign op overloads instead

Change-Id: I2d2e1b7f19d1b57528707ed5a5cce94b5fa5c2d0
2016-09-20 11:34:35 +02:00
5536aea822 Let OUStringLiteral1 take its arg as ctor arg, not template arg
...which makes it more flexible, can now also be used on non-const arguments.
The drawback of the argument no longer being a compile-time constant is remedied
by making the ctor constexpr.

Change-Id: Ia4903a2cc86791fece92eac0cb8406b6659dd19d
2016-08-30 07:43:52 +02:00
20f6a6b159 tdf#99402: fix Metafile Font handling
1. For DEFAULT_CHARSET/OEM_CHARSET, use correct encoding
based on LibreOffice Default Language for Documents setting
(Tools->Options...->Language Settings->Languages).
For that, two functions added to tencinfo.h, that map language
names to corresponding Windows ANSI/OEM encodings.
2. If charset is DEFAULT_CHARSET/OEM_CHARSET for Symbol font,
then always use RTL_TEXTENCODING_SYMBOL.

Unit test is included.

Change-Id: Ibff63e7a03dec42a9d2a74399936d6bc04f2ff1a
Reviewed-on: https://gerrit.libreoffice.org/28322
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-08-30 05:40:43 +00:00
2c10714426 Make OUStringLiteral1 a wrapper around UTF-16 instead of just ASCII
...not merely an ASCII character

Change-Id: Id2b381b35fe3a15574728ed973d60263dfef7249
Reviewed-on: https://gerrit.libreoffice.org/28446
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-08-29 11:44:31 +00:00
0c8fa58a2d Support ConstCharArrayDetector also for UTF-16 arrays
The long-term benefit will be support of C++11 char16_t string literals (for
cases of string literals with non-ASCII content) once we drop any compilers that
don't support those yet.  The short-term benefit is support for an improved
OUStringLiteral1 that accepts any sal_Unicode value, not just ASCII ones (see
next commit).

Change-Id: I3f8f6697d7eb62b5176b7e812b5a5113c53b83a4
Reviewed-on: https://gerrit.libreoffice.org/28445
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-08-29 11:44:19 +00:00
c399004b42 OUString construction from OUStringLiteral1 must not be overruled by...
...Except[Const]CharArrayDetector, under RTL_STRING_UNITTEST

Change-Id: Ib185fb8406c4afcff1c854a2b74dae02a0ee2b3f
Reviewed-on: https://gerrit.libreoffice.org/28444
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-08-29 11:43:55 +00:00
5f5b740761 sal: rename O[U]String parameter
Callgrind tinderbox complains that "string" shadows some global, so
let's try "rString" instead.

Change-Id: I3973f23ef6e8ebf861d66012fede84cb8a685be8
2016-06-14 16:07:50 +02:00
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
d2f9f27774 loplugin:nullptr: Find some more cases in templates
Change-Id: I1f127d56e40b04f2b4df85c0afbcfd424d68a8cc
2016-03-30 18:59:54 +02:00
a7258efa96 Typo: namesapce(s)->namespace(s)
Change-Id: Ic7c14c2e39a5ade1f5622a8350f9197d84cf9cc8
2016-02-17 21:18:10 +01:00
3210bc85ae Rename rtl::isValidCodePoint -> rtl::isUnicodeCodePoint
...and fix its documentation, and use it throughout the code base.

Change-Id: I349bc2009b1b0aa7115ea90bc6ecd0a812f63698
2016-02-15 12:36:11 +01:00
4647e77899 tdf#81129 Support reading non-BMP characters in HTML documents.
1. Allow character entity ( &#nnnn; ) to exceed 0xffff in HTMLParser::ScanText()
2. Return a character as sal_uInt32 ( utf32 ) instead of sal_Unicode ( utf16 )
   from SvParser::GetNextChar().

Conflicts:
	sw/qa/extras/htmlexport/htmlexport.cxx

Change-Id: Ida455040970fae800f0f11471b27f53461fb78e4
Reviewed-on: https://gerrit.libreoffice.org/21152
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mark Hung <marklh9@gmail.com>
2016-02-13 08:05:09 +00:00
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
e75406e54c tdf#39631 - branch hints: comment, and tweak variously, also use.
Find a few million mis-predicted branches (according to callgrind)
and annotate them. Mark string acquire/release as hot, and a number of
deprecated methods as cold.

Change-Id: I678b3981794221c97f9ebb70fd0161c0fda5dceb
2016-01-06 09:38:16 +00:00
72434f7ff1 sal: make OString/OUString immovable for MSVC
Odd problem, with MSVC 2013 in CppunitTest_smoketest in
sal/osl/w32/procimpl.cxx the read_environment calls std::stable_sort,
which turns about 89 elements into the empty string since commit
c9f6e12e7eb6a49389360626d206191147a174fb.

No idea what the problem is but let's disable the move for now.

Change-Id: I2912cd54a339bb6ab39922be516ea368a430f7c9
Reviewed-on: https://gerrit.libreoffice.org/20834
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
2015-12-20 06:40:18 +00:00
c9f6e12e7e OString/OUString: move constructors and operator=
Change-Id: Icdc5f7137cca8360f116d5d4c7b0bf4a4c526e1d
Reviewed-on: https://gerrit.libreoffice.org/20712
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
2015-12-17 06:59:50 +00:00
4a1edf626a More loplugin:nullptr automatic rewrite (within templates)
Change-Id: I9bc06cfb5eeb38fd7ae7fb25f876ea9f96e4a65a
2015-12-10 17:34:31 +01:00
0475ab7208 Adapt to true wchar_t in clang-cl
Change-Id: I14c2dc0be12151b5d4ea2ba3b65030f6f4494905
2015-11-28 08:44:52 +01:00
0b07406f71 Use C++11 char16_t for sal_Unicode
...in LIBO_INTERNAL_ONLY, __cplusplus, non-MSVC case.

It turns out that sal_Unicode happens to not be mangled into any symbols that
make up the stable URE interface, so (for LIBO_INTERNAL_ONLY, at least) we are
free to replace the typedef to sal_uInt16 with a typedef to any integral type
layout-compatible with that.  (sal_Unicode does appear in some symbols in sal's
PRIVATE_textenc.1 section, but that is private between the sal and sal_textenc
libraries, so changing those symbols does not require a change of SONAME.)
C++11 chart16_t is the obvious choice (and will ultimately allow using u"..."
to write literals of type array-of-sal_Unicode).  Reportedly, char16_t is
supported since GCC 4.4 and Clang 2.9 but will only be available in MSVC 2015.

For plain C, we continue to use sal_uInt16.  We could theoretically use C11
char16_t from <uchar.h>, but at least the Mac OS X 10.11 SDK still does not
offer that C11 header.

For MSVC, we continue to use wchar_t (which is actually unsigned short, due to
/Zc:wchar_t-) for now.  Potential options there include dropping /Zc:wchar_t-
and using true wchar_t, or using C++11 char16_t once support for MSVC 2013 is
dropped.

Some code needed to be adapted that was written in a way assuming that
sal_Unicode is unsigned short (which indicates that changing sal_Unicode for
non-LIBO_INTERNAL_ONLY would be an ABI change).  OUStringBuffer::append can now
differentiate between being called with sal_Unicode (to append a single
character) and erroneously being called with sal_uInt16 (intending to append a
number's textual representation, for which the sal_Int32 overload must be used
instead).  Bugs found are 379fe0409e7973b36210cffa3dd1dfd4032f0ecc "Assume that
this code wants to append a number, not a character" and
dc148335a6a438848325f24c49198fba81043279 "Assume this wants to append the
numerical representation."

The GDB support for pretty-printing of sal_Unicode-related data in
solenv/gdb/libreoffice/sal.py can presumably be simplified now.

Change-Id: I445b3a80e65b7cb004d9e08b38bdc9ee93bc9401
Reviewed-on: https://gerrit.libreoffice.org/20036
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2015-11-18 15:20:43 +00:00
5d201bc490 Adapt to clang-cl
Change-Id: I2f79e52da2aa0ad3a37aac07a36dbe14dfe401a9
2015-11-13 10:29:04 +01:00
2083761d19 -Werror,-Wmicrosoft-enum-value
Change-Id: Iafd6e5f899835303e421be923f70d1e3f42bf65e
2015-11-13 10:29:03 +01:00
0813839682 Missing includes (for NULL)
Change-Id: Id2359f6ff4bddb2afbc0b346e17cd858f00179e3
2015-11-10 13:14:21 +01:00
26f05d59bc loplugin:nullptr (automatic rewrite)
Change-Id: I1bc6c87fcd6e5e96362623be94c59be216a3b2b8
2015-11-10 10:31:35 +01:00