695 Commits

Author SHA1 Message Date
Noel Grandin
cb9bcae7ba clang-tidy performance-unnecessary-value-param in formula
Change-Id: I9f90c55f74216c2f3452e5b30d85b304668330b3
2016-04-11 11:38:58 +02:00
Winfried Donkers
62967a0afc get rid of a TODO comment
Checked if the < is correct. It is.
Calc function Choose has 1 index argument plus up to 30 value-arguments,
so the maximum argument count is 31.
FORMULA_MAXJUMPCOUNT is 32.

Change-Id: I0bc8cc122902848dadfc92d56b6f06fbec43e4be
Reviewed-on: https://gerrit.libreoffice.org/23794
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: jan iversen <jani@documentfoundation.org>
2016-04-04 07:25:56 +00:00
Noel Grandin
6439005484 use SAL_N_ELEMENTS more widely
found using
   git grep -n 'sizeof.*/.*sizeof.*[0]'

Change-Id: Icd4a6cc1ca8ec8ebd68e1701a02789c74cf0eb2a
2016-03-31 11:30:36 +02:00
Markus Mohrhard
d8a15e74da missing nullptr check, tdf#98427
Change-Id: I657dc0c84eab6ff5b31976fac3317adc0a99dd51
2016-03-23 00:13:41 +01:00
Eike Rathke
64e5424138 Resolves: tdf#96915 implement other-sheet-local named expressions
Change-Id: I0d62536caa6eb455473a755067abc585662cd9a5
2016-03-18 10:37:40 +01:00
Noel Grandin
9704207c38 loplugin:constantparam in formula
Change-Id: I3adeed435b62ae60b5d0d4b763dceced5675cd85
Reviewed-on: https://gerrit.libreoffice.org/23330
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-03-18 06:01:25 +00:00
Eike Rathke
0aa29f32f9 prefix domain namespace to FORECAST.* functions for ODFF, tdf#94635 follow-up
Change-Id: If875b538f2143eb572371dfcc086145c2f6e80f5
2016-03-14 15:45:53 +01:00
Noel Grandin
f803aae0f3 loplugin:constantparam in formula
Change-Id: I18246d34d27f1b12dfd107166b31ef16d9632462
2016-03-10 10:09:58 +02:00
Winfried Donkers
f336f63da9 tdf#94635 Add FORECAST.ETS functions to Calc
Change-Id: Ifbfff1c27fb3960a06f467630da0fa39665f0ce4
Reviewed-on: https://gerrit.libreoffice.org/20073
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
2016-03-03 16:28:59 +00:00
Noel Grandin
2437ccd3e9 loplugin:unuseddefaultparams in formula
Change-Id: I7f0baa2709db24e8299f0e1c19c0703aee1cbf4f
2016-03-03 11:15:52 +02:00
Noel Grandin
c45d3badc9 new loplugin: commaoperator
Change-Id: I03f24e61f696b7619855e3c7010aa0d874e5a4ff
2016-02-23 08:08:56 +02:00
aybuke
05d2684840 tdf#43157 Cleanup DBG_ASSERT for formula module.
Change-Id: I1be9332b4408b3c28aacfa872d63fce67adcb1fe
Reviewed-on: https://gerrit.libreoffice.org/21958
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
2016-02-18 19:52:14 +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
Chris Sherlock
697d445ed0 vcl: take into account the font width is the average font width
I'm changing the Font class function names:

- SetSize       -> SetFontSize
- GetSize       -> GetFontSize
- SetHeight     -> SetFontHeight
- GetHeight     -> GetFontHeight
- SetWidth      -> SetAverageFontWidth
- GetWidth      -> GetAverageFontWidth

That's because it really makes no sense to say that there is a
single constant font width because obviously proportional fonts
don't have one - the best we can do is an average font width,
which is what folks like Microsoft sort of do already. On a fixed
font, the average is still accurate, for obvious reasons :-)

I'm also not a fan of GetSize/SetSize as I find it a might too
generic.

Change-Id: Ib80a604ba62d6883fd6cbc7994da763976be5c70
Reviewed-on: https://gerrit.libreoffice.org/22069
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
2016-02-04 03:17:26 +00:00
Noel Grandin
4ff5a55584 loplugin:unusedmethods
Change-Id: Ib2dc804f55d1a96ae01f2cf31b7d55956040a72e
Reviewed-on: https://gerrit.libreoffice.org/21603
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-01-20 08:13:51 +00:00
Noel Grandin
0078512eda loplugin:unusedmethods unused return value in include/formula
Change-Id: Ic5d6c11d955ef5ef53dea0bb4e5bec8167874a91
2016-01-12 10:37:20 +02: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
Eike Rathke
f6f73d2e40 Function Wizard: exclude functions with hidden flag from lists
Change-Id: Ia209bb44cef5969e5c9cd360aa5725708d6bdec5
2016-01-09 13:33:32 +01:00
Eike Rathke
8aee44c94f Function Wizard: don't overwrite an unlisted function
* in a spreadsheet cell enter =LOG(foobar(SIN(1)))
* invoke Function Wizard on that cell (Ctrl+F2)
  LOG(foobar(SIN(1))) is marked in Formula edit field
* activate Functions page
  LOG(foobar(SIN(1))) is marked in Formula edit field
  Function LOG is selected
* click Next button
  foobar(SIN(1)) is marked in Formula edit field
  Function ABS is selected
* click Next button
  foobar(SIN(1)) is overwritten with ABS( )
* only Cancel solves the problem

foobar() could be any user defined or macro function that have no
function description in the Formula Wizard.

Change-Id: I1cb69a9e38c0b8f251d783bd0f67b4b24ade50d0
2016-01-09 13:33:31 +01:00
Eike Rathke
077cc9fbaa prepare for hidden flag in function description for Function Wizard
Change-Id: Ic018ea5b962a66b6543e57d9cc1d44711e51de6e
2016-01-09 13:33:30 +01:00
Eike Rathke
7994b77819 tdf#96198 postpone conversion from WEEKNUM to ISOWEEKNUM, tdf#50950 follow-up
Have two releases be able to read ISOWEEKNUM first.

Change-Id: I7ea8141043d18076a65396374dec40a806c8ab6a
2016-01-07 19:37:09 +01:00
Eike Rathke
4ae7b66286 use new'ed FormulaToken and FormulaTokenArray::Add()
... instead of a temporary instance and AddToken() that just clones it
again.

Add function comment describing the difference.

Change-Id: I3f089965d394b33d7bbbb9a1c3f69dc1c4182fd2
2016-01-05 23:42:07 +01:00
Eike Rathke
c3d2313eca for new'ed FormulaToken use FormulaTokenArray::Add()
... instead of AddToken() that just clones it again.

Change-Id: I99b02b0924d0a0c070435501f8ecd45f030e9c2c
2016-01-05 22:18:24 +01:00
Eike Rathke
902c593196 tdf#96198 add WEEKNUM_OOO compatibility function, tdf#50950 follow-up
The remaining cases when loading old and wrong ISOWEEKNUM that can't be
mapped to either new WEEKNUM or ISOWEEKNUM now are mapped to
WEEKNUM_OOO(date,mode) with calculations identical to the old and wrong
OOo WEEKNUM.

These WEEKNUM_OOO cases are still wrongly saved as ISOWEEKNUM so can be
read by 5.0 or earlier versions as the old WEEKNUM, which should be
changed for 5.3 or later.

WEEKNUM_OOO is not offered in the Function Wizard to prevent deliberate
usage.

Also reverts the interim unit test change to
sc/qa/unit/data/contentCSV/date-time-functions.csv
that was necessary to catch the error generated by ISOWEEKNUM with two
arguments.

Change-Id: I874c4c7225900f03b879f2947512ae02270cbd4f
2016-01-05 19:29:17 +01:00
Michael Meeks
15494f0f99 formula: add missing algorithm include for std::min.
Change-Id: Ica344a8f1351826e53c109ef49f80e4b022a0364
2016-01-05 12:44:41 +00:00
Eike Rathke
2f79244cb3 tdf#96198 detect old ISO/WEEKNUM usage with two arguments, tdf#50950 follow-up
5.0 and earlier implemented WEEKNUM(date,mode) with mode!=1 such that
effectively an ISO 8601 week number was calculated. WEEKNUM was wrongly
saved as ISOWEEKNUM (even with two parameters though it is defined to
have only one) so that when reading it we can try to detect a literal
double argument for mode and if it is not 1 remove it to keep
ISOWEEKNUM(date) instead of calling WEEKNUM(date,mode) which wouldn't
match.

A further change to 5.0 to accept also only one parameter in
WEEKNUM(date) and for this default the mode to not 1 for ISO week will
yield forward compatibility.

Change-Id: I88de7dd809d69b6826a190505d2a1dd3fe79c90b
2016-01-05 12:10:02 +01:00
Eike Rathke
dc89367a56 Formula Wizard: evaluating expressions always in matrix context is wrong
Change-Id: I276f7bbf2bd6fa7c67d8691634ad9d79e4a08b1c
2015-12-18 23:28:14 +01:00
Eike Rathke
9d1ee5a5b4 Resolves: tdf#96366 replace Edit...() calls with actually working code
... and way less overhead, geez..

Change-Id: Id9277301fbe69bc9a83ca39a907032b0b86b1c81
2015-12-18 15:43:45 +01:00
Eike Rathke
8217ddbfc8 tdf#96366 disable treeview results until fix available
Since f82d89f35207fc1cfc00ad5cd914b74c55c3e3d2 EditThisFunc() and
EditNextFunc() are used to iterate through the formula to obtain
expression results to display in the treeview. Calling the Edit...()
functions spoils about everything as it messes around with the edit
state. As the name suggests..

Change-Id: I8b35d85b7bbf8821b5a995e84f9dd88a0f6f00b9
2015-12-18 12:39:52 +01:00
Eike Rathke
88f3c8f995 Function Wizard shoots itself in the foot
Currently the Function Wizard is broken in that editing a function call
as argument within another function's parameter leads to selections
being reset and mismatching argument/function information being
evaluated. Not sure yet what's going on there, but at least don't access
vectors out-of-bounds or crash.

Change-Id: I633c775556a0b90278d22d0f74d2975c20a08a5d
2015-12-18 01:53:10 +01:00
Eike Rathke
5b404cc2ad out-of-bounds arg mapping access, this was always wrong but never hit it seems
Change-Id: I15843b320ac8ddcefce8094da7aa7c6b81b42e4f
2015-12-17 15:44:34 +01:00
Eike Rathke
4eea9f2146 handle varargs with first required and subsequent optional, tdf#71459 related
Change-Id: I56c66f516ba2a2e12cab4848c8c352315f27b3bb
2015-12-17 15:14:43 +01:00
Eike Rathke
db1e34aecd add RAWSUBTRACT spreadsheet function, tdf#71459
Change-Id: I2ae13771c85044b771e253a8189a30cb4aecb30f
2015-12-17 15:14:43 +01:00
Eike Rathke
dad412e07f Resolves: tdf#95440 SharedString are interned per document, re-intern
... if literal strings are copied with formula expression tokens.

Change-Id: I13526907bb6c2c605c6ed9584fa6e3f2b18623b8
2015-12-15 17:50:21 +01:00
Noel Grandin
fafac0d248 loplugin:unusedfields forms,formula,fpicker,framework
Change-Id: Ic7af56ac801c1e5b3fcf3c4e8413656e96220279
2015-11-20 15:07:05 +02:00
Eike Rathke
eedcc2c45c cosmetics
Change-Id: Ic06bef4c80426b97a2613fe296ae0aa0ee55a215
2015-11-18 21:02:07 +01:00
Eike Rathke
270f8ea48b rename FormulaToken HasForceArray to IsInForceArray
... to name it was it does and to distinguish from
ScParameterClassification::HasForceArray(OpCode) which IS about a
function having ForceArray parameters.

Change-Id: I8af4e1d0353cdb5ad0a9b837ae0763dc77242734
2015-11-18 21:02:06 +01:00
Eike Rathke
b31b17e52b prevent ForceArray propagation on the same token, tdf#95670 follow-up
This may happen if the last RPN token is put and the function has a
ForceArray parameter but now again would be wrong if not all parameters
are ForceArray.

Change-Id: I890fb6b5b88337033cfcf2e8189371ee39461205
2015-11-16 13:46:39 +01:00
Eike Rathke
49257e1da7 Resolves: tdf#95670 propagate ForceArray per parameter
Regression of b5cd11b4b02a85a83db77ba9d8d1763f0cd88cb1

It was always wrong to propagate ForceArray already if a function had a
ForceArray parameter *somewhere*, we need to do this per parameter
instead.

Change-Id: If188d45366279d9a7bf641edc7e4dd7095d6d035
2015-11-16 13:25:49 +01:00
Julien Nabet
44aa71792b tdf#95798: CRASH: when finish Function wizard on Report builder
Following http://cgit.freedesktop.org/libreoffice/core/commit/?id=844b7287a4ccd8e3d5e458bb1dc6c52e71322b01

Change-Id: Ia5a2cd39cf3fdf87619f55710a188545830b4088
Reviewed-on: https://gerrit.libreoffice.org/19970
Reviewed-by: Lionel Elie Mamane <lionel@mamane.lu>
Tested-by: Jenkins <ci@libreoffice.org>
2015-11-15 15:46:21 +00:00
Noel Grandin
25aec383f9 use initialiser for Sequence<OUString>
replaced using:
git grep -lP 'Sequence.*OUString.*\(\s*1\s*\)'
| xargs perl -0777 -pi -e
"s/Sequence<\s*OUString\s*> (\w+)\(\s*1\s*\);
.*\[0\] = (\S+);/Sequence<OUString> \1 { \2 };/g"

Change-Id: I20ad0489da887a9712982531c3b127339bb8b3b9
Reviewed-on: https://gerrit.libreoffice.org/19969
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2015-11-15 12:18:55 +00:00
Caolán McNamara
8325fcb56d cppcheck: noExplicitConstructor
Change-Id: Ife26f55c28c4631aec4ba4105225bfca72da8bff
2015-11-13 10:17:26 +00:00
Stephan Bergmann
e5b721a14c loplugin:nullptr (automatic rewrite)
Change-Id: Ib336ce9bc95f5c84dd6412ff3c098e68c5b0f4ff
2015-11-10 10:31:26 +01:00
Mario J. Rugiero
357a6f6ba2 Replace a local functor and bind2nd by a lambda in formula.
Change-Id: Ied06b3f167c566d754d32708eaec4a354f7ee663
Reviewed-on: https://gerrit.libreoffice.org/19848
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2015-11-09 06:09:05 +00:00
Eike Rathke
068178adf5 Revert "tdf#90695: In function Wizard Array box cannot be unchecked"
This reverts commit bebc20c62be2df2cf2741fb82945ce6b631d2fe5.

Removing the disabling is plain wrong. Please see the code for when the button is disabled, when it is enabled, and what consequences it has when changing the state from checked to unchecked. Unchecking will result in the formula not being applied as array formula anymore, which it was before editing.

Actually tdf#90695 is not even a bug. The checked but disabled Array button is meant as an indicator that the formula IS an array/matrix formula.

Change-Id: Ic7f9f7010ce208171ef614e0885474f2deae4ac9
Reviewed-on: https://gerrit.libreoffice.org/19602
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
2015-10-26 13:26:49 +00:00
Julien Nabet
bebc20c62b tdf#90695: In function Wizard Array box cannot be unchecked
Just remove the disabling

Change-Id: Ia03591610ba1b60a66d9962169383c4ab85288ca
Reviewed-on: https://gerrit.libreoffice.org/19590
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
2015-10-26 05:13:33 +00:00
Stephan Bergmann
4cf1a6ba95 loplugin:defaultparams
Change-Id: I4cb8e39dfe7efcb7ac75ebf41e3d76b8f12750f2
2015-10-19 17:50:12 +02:00
Noel Grandin
6f1313b3d4 convert Link<> to typed
Change-Id: Icbba339dac0be31e30dff021bba06a219f8aecd6
Reviewed-on: https://gerrit.libreoffice.org/19405
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2015-10-16 09:11:29 +00:00
Noel Grandin
ba974ccc8c com::sun::star->css in fpicker/
Change-Id: I211687bfeaf456e0f9639567bff401083011cd74
Reviewed-on: https://gerrit.libreoffice.org/19353
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2015-10-14 06:36:34 +00:00
Eike Rathke
01a93d348b do not use white text on white background in control
... setting a control's background color has no effect (until input
field text is changed?)

Could be observed in the pivot table dialog's source range edit when an
invalid range was entered.

Change-Id: Iafb2a9016ac6bd4c020273911d62dd7423ee0458
2015-10-13 15:29:21 +02:00