Commit Graph

216 Commits

Author SHA1 Message Date
Noel Grandin
48314f2524 improve function-local statics in basic..cui
Change-Id: If737e8478f6f1c8fffb060ce132d80e0f07ef8ee
Reviewed-on: https://gerrit.libreoffice.org/63701
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-21 12:28:23 +01:00
Mike Kaganski
0a060db0c2 Fix a copypaste error
Has been like this since commit 2d1ef8aa24

Change-Id: Idf0e05246f625befb4872e743b490a5594d24f8f
Reviewed-on: https://gerrit.libreoffice.org/63548
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2018-11-20 21:15:58 +01:00
Noel Grandin
44688e498c clang-tidy performance-unnecessary-copy-initialization in
basctl..basic

Change-Id: I4009282869cd8a2f269093564bd4fafccab80ec3
Reviewed-on: https://gerrit.libreoffice.org/62212
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-23 08:39:10 +02:00
Stephan Bergmann
7ceee0f1ec Extend loplugin:redundantinline to catch inline functions w/o external linkage
...where "inline" (in its meaning of "this function can be defined in multiple
translation units") thus doesn't make much sense.  (As discussed in
compilerplugins/clang/redundantinline.cxx, exempt such "static inline" functions
in include files for now.)

All the rewriting has been done automatically by the plugin, except for one
instance in sw/source/ui/frmdlg/column.cxx that used to involve an #if), plus
some subsequent solenv/clang-format/reformat-formatted-files.

Change-Id: Ib8b996b651aeafc03bbdc8890faa05ed50517224
Reviewed-on: https://gerrit.libreoffice.org/61573
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-10-09 14:47:17 +02:00
Stephan Bergmann
206b5b2661 New loplugin:external
...warning about (for now only) functions and variables with external linkage
that likely don't need it.

The problems with moving entities into unnamed namespacs and breaking ADL
(as alluded to in comments in compilerplugins/clang/external.cxx) are
illustrated by the fact that while

  struct S1 { int f() { return 0; } };
  int f(S1 s) { return s.f(); }
  namespace N {
    struct S2: S1 { int f() { return 1; } };
    int f(S2 s) { return s.f(); }
  }
  int main() { return f(N::S2()); }

returns 1, both moving just the struct S2 into an nunnamed namespace,

  struct S1 { int f() { return 0; } };
  int f(S1 s) { return s.f(); }
  namespace N {
    namespace { struct S2: S1 { int f() { return 1; } }; }
    int f(S2 s) { return s.f(); }
  }
  int main() { return f(N::S2()); }

as well as moving just the function f overload into an unnamed namespace,

  struct S1 { int f() { return 0; } };
  int f(S1 s) { return s.f(); }
  namespace N {
    struct S2: S1 { int f() { return 1; } };
    namespace { int f(S2 s) { return s.f(); } }
  }
  int main() { return f(N::S2()); }

would each change the program to return 0 instead.

Change-Id: I4d09f7ac5e8f9bcd6e6bde4712608444b642265c
Reviewed-on: https://gerrit.libreoffice.org/60539
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-09-17 09:05:38 +02:00
Noel Grandin
d977e02ec6 unnecessary null check before dynamic_cast, in various
Change-Id: I76ad0b3152030c29ee28f6a6cc80d0832188d02b
Reviewed-on: https://gerrit.libreoffice.org/58774
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-08-10 08:21:55 +02:00
Noel Grandin
b83cc2b010 loplugin:stringloop in basic, framework, sax, svtools
Change-Id: I2bad74a8f103e9dc68c8e0d0e6315697068d2f6d
Reviewed-on: https://gerrit.libreoffice.org/58135
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-07-27 11:35:24 +02:00
Stephan Bergmann
649313625b New o3tl::temporary to simplify calls of std::modf
...that ignore the out-parameter integral part

Change-Id: I05f07c1a8909023232f8aecf75ea5541d4eb81ca
Reviewed-on: https://gerrit.libreoffice.org/54474
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2018-05-17 21:03:12 +02:00
Eike Rathke
40c9a129e5 Resolves: tdf#117612 truncate DateAdd("m",...) to last day of month
... instead of resulting in error because of roll-over not being set.

Fallout from

    commit 6d424f0770
    CommitDate: Tue May 2 23:12:34 2017 +0200

        Replace mouth-painted "inaccurate around leap year" rollover algorithm

that does stricter checking but DateAdd() needs a lax checking
with truncate to last day of month.

Change-Id: I9d6f95ad3ac38257d492019bd621070491e98e76
2018-05-16 11:38:53 +02:00
Stephan Bergmann
3a40d3de89 More loplugin:cstylecast: basic
Change-Id: I0bb219632da384ab047a2b1fc3f2b041dacaf2cb
2018-01-15 09:07:14 +01:00
Stephan Bergmann
6070aaa47d More loplugin:cstylecast: basic
auto-rewrite with <https://gerrit.libreoffice.org/#/c/47798/> "Enable
loplugin:cstylecast for some more cases" plus
solenv/clang-format/reformat-formatted-files

Change-Id: I20b38196ee1b6a34384dc46d9de1b6e1b44947ae
2018-01-12 20:29:14 +01:00
Eike Rathke
4b98e352e5 Make the SbiInstance SvNumberFormatter shared_ptr
In preparation to get rid of the per call locally created
SvNumberFormatter instances..

Change-Id: Ic7db3bbb655aa18e939f5722964655a20f2eadf2
Reviewed-on: https://gerrit.libreoffice.org/45227
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
2017-11-24 21:30:02 +01:00
Eike Rathke
db080dad6c tdf#114011 limit/truncate date, not only year
Change-Id: I479040f411fb8b5975c0aa1aa24f95c957cf80cf
2017-11-23 18:44:48 +01:00
Caolán McNamara
2161d04688 drop duplicate method
Change-Id: Idadd0a64e41cd02f5167b275081c3576a6224b12
Reviewed-on: https://gerrit.libreoffice.org/45075
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
2017-11-22 13:33:25 +01:00
Mike Kaganski
daf7c3e732 basic: consistently use "" and <> in include directives
Change-Id: I147c0e9b9b1e09af593f54799e45e1348cd40716
Reviewed-on: https://gerrit.libreoffice.org/43298
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2017-10-10 07:43:46 +02:00
Eike Rathke
fcd0361d6b Eliminate Date::operator+=() and -=() and replace with Date::AddDays()
Clarifies code and gets rid of explicitly casting the operand to sal_Int32.

Also in preparation of removing DateTime::operator+=(sal_Int32) that is
confusingly similar to DateTime::operator+=(double) and just depends on type.

Change-Id: I83422e2940fbb017978db9b5734b4966228af3de
Reviewed-on: https://gerrit.libreoffice.org/40248
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
2017-07-21 12:24:27 +02:00
Stephan Bergmann
56dcc7b65f loplugin:casttovoid in RTLFUNC
Change-Id: I810278640936e9b3c73f56a37e8c4786fd2790e3
2017-07-04 08:15:07 +02:00
Stephan Bergmann
c8fd385d61 loplugin:casttovoid: basic
Change-Id: I4e70accf67d4d812b8998b0baa07cd04c27216ad
2017-07-02 22:35:38 +02:00
Noel Grandin
14c763e793 s/ERRCODE_SBX_OK/ERRCODE_NONE
adds no value

Change-Id: Iedf7a6a7be28fed4059b576312890be8cbb980d7
Reviewed-on: https://gerrit.libreoffice.org/39056
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-06-21 20:58:36 +02:00
Noel Grandin
6ee9f2c188 loplugin:oncevar accessibility..basic
Change-Id: I8fb41b658ef0f6ad1774ea897eace3dc9bb12de6
Reviewed-on: https://gerrit.libreoffice.org/38969
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-06-20 07:50:06 +02:00
Noel Grandin
3059ede409 drop SbError typedef
in favour of ErrCode.
Part of a larger patch to convert ErrCode to strong_int

Change-Id: Ia846bfc93c58c85c6a6cec79e9d19b9ecbd1c05f
Reviewed-on: https://gerrit.libreoffice.org/38783
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-06-15 08:25:22 +02:00
Noel Grandin
a6aa57ff59 use ERRCODE_NONE instead of 0
peeling off a small chunk of my ErrCode strong_int conversion

Change-Id: Idc89e8496083beed7608cba705cd981139eb7111
Reviewed-on: https://gerrit.libreoffice.org/38777
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-06-14 15:42:31 +02:00
Noel Grandin
2e51afc77c loplugin:comparisonwithconstant in basic
Change-Id: Ie34a17d2fb465ffbe675ba4e99917d23959f1fb5
Reviewed-on: https://gerrit.libreoffice.org/37809
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-05-19 12:53:34 +02:00
Eike Rathke
6d424f0770 Replace mouth-painted "inaccurate around leap year" rollover algorithm
... with proper tools::Date methods Normalize() and AddMonths().

Also prepare functionality to easily switch on rollover for StarBASIC as well,
i.e. when called by DateSerial() runtime function.

For StarBASIC, invalid date for day > daysinmonthofyear is now (or better since
a previous commit 94bb96ada421b423e9ed30526fe5a6aac95f00b9 from today) properly
detected, not just dumb 1<=day<=31.

Change-Id: Ibb44f7247726f1e1168f0e66c5ae18e073d19f08
2017-05-02 23:12:34 +02:00
Eike Rathke
1b13548f33 BASIC: handle the full tools::Date range from -32768-01-01 to 32767-12-31
* Input of two-digit years only possible through CDateFromIso() though to
  maintain compatibility with previous behavior and also VBA mode.
* VBA mode restricted to years 1..9999

Change-Id: Ia9574c3bf136619b4831b349d263c96b162d1ed4
2017-05-02 15:56:20 +02:00
Noel Grandin
7662e92c64 loplugin:redundantcast find cstyle double casts
Change-Id: I5507be190dac781e5cdb545a60acf3d50056c9f8
Reviewed-on: https://gerrit.libreoffice.org/36187
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-04-06 07:47:30 +00:00
Noel Grandin
93bde31562 Revert "[API CHANGE] return sal_uInt64 from GetSystemTicks in basic"
This reverts commit fce604c8ae,
and fixes
  tdf#105735 - xray ThisComponent no longer works
in the process.

It turns out Basic doesn't support sal_uInt64 very well, so lets rather
have a small possibility of bad timestamps instead of broken scripts.

Change-Id: Ic00485bd517a4fc61e05632001c9a5f92e05ddd6
Reviewed-on: https://gerrit.libreoffice.org/33972
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-02-07 06:02:23 +00:00
Noel Grandin
83721f4365 makeAny->Any in basctl..chart2
Change-Id: Ief1cdffbfc59ab4e35ac945d020772ff84c50d61
Reviewed-on: https://gerrit.libreoffice.org/33867
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-02-03 08:50:50 +00:00
Noel Grandin
4978328534 convert method names in tools::SvRef to be more like our other..
reference classes, uno::Reference and rtl::Reference.

Specifically rename Is()->is() and Clear()->clear().

Change-Id: Icb7e05e2d09cb9977121508b837ba0961dabb4ae
Reviewed-on: https://gerrit.libreoffice.org/33576
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-02-02 08:02:54 +00:00
Caolán McNamara
545c6e9d4f clear ARRAY_VS_SINGLETON coverity warnings
experiment to see if this clears them

Change-Id: I91a74e06f621d3012b564cad87586ba74b0367ca
2017-01-19 15:16:15 +00:00
Noel Grandin
fce604c8ae [API CHANGE] return unsigned 64-bit value from GetSystemTicks in basic code
instead of 32-bit value.

looks like this has been incorrect since

   commit 9f2104e1f3
   Author: Jens-Heiner Rechtien <hr@openoffice.org>
   Date:   Mon Jun 19 16:46:13 2006 +0000
   INTEGRATION: CWS warnings01 (1.23.26); FILE MERGED

but nobody cared, since the values would previously fit into a 32-bit
number.

Change-Id: I4c121085977b5e7ff3e33c8ad57749b925ad31b9
Reviewed-on: https://gerrit.libreoffice.org/32879
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-01-09 11:18:50 +00:00
Noel Grandin
bfde4866e0 convert DecodeMechanism to scoped enum
Change-Id: I5c56634b1bca8e37fa73d02d2428645301b6c547
2016-12-05 12:49:02 +02:00
Jochen Nitschke
d1ea6ecda6 replace <<= with assign for <<= with rhs Any
found by deleting specialization of '<<=' template

Change-Id: I253f15177ab20fd3ef9baf4158da8c662cb47e6c
Reviewed-on: https://gerrit.libreoffice.org/29956
Reviewed-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
Tested-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
2016-10-18 19:16:44 +00:00
Jochen Nitschke
9ac8a57e52 replace <<= with assign for <<= with rhs Any
makeAny and Any ctor return an Any

Change-Id: Iaa361bc315d785f80153acf1009bf47d109728ec
Reviewed-on: https://gerrit.libreoffice.org/29914
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
2016-10-17 15:39:13 +00:00
Stephan Bergmann
233e5d5f85 clang-cl loplugin: basic
Change-Id: Ibb324ac81343d56038d18a4ee9b27b486df6e520
Reviewed-on: https://gerrit.libreoffice.org/29881
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-10-16 14:19:33 +00:00
Hieronymous
01dc6d098d tdf#96099 Reduce no. of useless typedefs for trivial containers.
Reduced vector< OUString > typedefs in sbintern module.

Change-Id: I5b2fd6f0b5fe0ae538a12ac028a08458c6eb4714
Reviewed-on: https://gerrit.libreoffice.org/29916
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-10-16 10:41:20 +00:00
Jacek Fraczek
f004aa9951 tdf#89307: Removed SvRef::operator T*()
Conditional statements are using SvRef::Is() method.
Changed static_cast<T*>(svRef<T>) occurances to svRef.get().
Added operator == and != to SvRef.

SbxObject::Execute is using SbxVariableRef internally.
SbxObject::FindQualified is using SbxVariableRef internally.

Change-Id: I45b553e35d8fca9bf71163e6eefc60802a066395
Reviewed-on: https://gerrit.libreoffice.org/29621
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-10-10 08:48:30 +00:00
Noel Grandin
954f752cf1 convert MapUnit to scoped enum
I left a prefix on the names "Map" so that I would not have to re-arrange
each name too much, since I can't start identifiers with digits like "100thMM"

And remove RSC_EXTRAMAPUNIT, which doesn't seem to be doing anything anymore.

Change-Id: I5187824aa87e30caf5357b51b5384b5ab919d224
Reviewed-on: https://gerrit.libreoffice.org/29096
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-10-05 06:51:20 +00:00
Michael Stahl
b647996a9b replace sal_Size with std::size_t (or sal_uInt64 for SvStream pos)
... except in include/rtl, include/sal, include/uno, where sal_Size is
retained for compatibility, and where callers of rtl functions pass in
pointers that are incompatible on MSVC.

Change-Id: I8344453780689f5120ba0870e44965b6d292450c
2016-09-15 12:01:11 +02:00
Noel Grandin
508c95f1b6 improve passstuffbyref return analysis
Change-Id: I4258bcc97273d8bb7a8c4879fac02a427f76e18c
Reviewed-on: https://gerrit.libreoffice.org/27317
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-07-27 06:48:25 +00:00
Caolán McNamara
9f0997eb16 Resolves: tdf#59222 Crash in Basic with an array of values...
from a range address

trying to make all SbxVariables reference count their parents
is ludiciously hard, so just reference count this one known
crashing case

Change-Id: Ie1fa6624e8184146dd00d766cdbacef674153ef6
Reviewed-on: https://gerrit.libreoffice.org/26272
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
2016-06-14 19:54:26 +00:00
Caolán McNamara
4e596d1cb1 drop dramatic distracting comment
Change-Id: Ic4b5537075e7ea9a713409982bb21e12f6b53e3f
Reviewed-on: https://gerrit.libreoffice.org/26271
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
2016-06-14 14:53:44 +00:00
Noel Grandin
f107d45381 Convert SbxClassType to scoped enum
Change-Id: I48afcdd9924d22b52a8db21aa253061e4d38c85b
Reviewed-on: https://gerrit.libreoffice.org/25259
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-05-23 11:49:32 +00:00
Noel Grandin
2087484c65 use consistent #define checks for the Windows platform
stage 2 of replacing usage of various checks for the windows platform
with the compiler-defined '_WIN32' macro

In this stage we focus on replacing usage of the WIN macro

Change-Id: Ie8a4a63198a6de96bd158ecd707dadafb9c8ea84
Reviewed-on: https://gerrit.libreoffice.org/22393
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-02-17 11:33:57 +00:00
Chris Sherlock
a238b1f8d3 Remove excess newlines
A ridiculously fast way of doing this is:

for i in $(pcregrep -l -M -r --include='.*[hc]xx$' \
  --exclude-dir=workdir --exclude-dir=instdir '^
{3,}' .)
do
    perl -0777 -i -pe 's/^
{3,}/

/gm' $i
done

Change-Id: Iebb93eccbee9e4fc5c4380474ba595858a27ac2c
Reviewed-on: https://gerrit.libreoffice.org/22224
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
2016-02-09 08:18:05 +00:00
Andrea Gelmini
92e60e1b80 Fix typos
Change-Id: I1b79005d9c4e32325b8dadcc4f805975d6bf2727
Reviewed-on: https://gerrit.libreoffice.org/21103
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2016-01-05 07:32:28 +00:00
Matteo Casalin
7d8919d2d5 sal_uLong/sal_uIntPtr for ScNumFormatAbbrev
Change-Id: I45f2a43fe4295e44691ab00c93af3fca41b1dcfa
2015-12-27 16:51:26 +01:00
Stephan Bergmann
c4c059beb3 DBG_TRACE_BASIC/PROFILING had been rotting for quite some time now
...e.g., it still used the long-gone tools String class

Change-Id: I9d1930c72fbae3208a0f3da14c6991f30d89a9bc
2015-12-10 08:18:15 +01:00
Stephan Bergmann
08e49fa337 loplugin:nullptr (automatic rewrite)
Change-Id: I1ec9a671fe3ac838feb36297915e3cdf8749d944
2015-11-10 10:31:17 +01:00
Benjamin Ni
be729e7721 tdf#94269: Replace "n" prefix for bool variables with "b"
Change-Id: I178545792c7354a362658ac7ef8b1d4cf0865797
Signed-off-by: Michael Stahl <mstahl@redhat.com>
2015-11-02 23:40:57 +01:00