summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-07-04 14:04:26 +0200
committerEike Rathke <erack@redhat.com>2017-07-04 14:04:56 +0200
commit3054a8c1c148aee9cb3feaa4e7b5edee010deead (patch)
treeacaa7cec377fddd9d1385509e7e864e795f10a87
parentxmloff: prefix members of XMLTextStyleContext (diff)
downloadcore-3054a8c1c148aee9cb3feaa4e7b5edee010deead.tar.gz
core-3054a8c1c148aee9cb3feaa4e7b5edee010deead.zip
Prepare for change of VAR_ARGS value
Change-Id: I0b1955bb660b5e19587799de657c63634705b99c
-rw-r--r--include/formula/funcvarargs.h3
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/StarFunctionDescription.java1
-rw-r--r--reportdesign/source/ui/misc/FunctionHelper.cxx18
3 files changed, 16 insertions, 6 deletions
diff --git a/include/formula/funcvarargs.h b/include/formula/funcvarargs.h
index c0836a55a1e4..1be68692fe41 100644
--- a/include/formula/funcvarargs.h
+++ b/include/formula/funcvarargs.h
@@ -22,6 +22,9 @@
reportdesign/source/ui/misc/FunctionHelper.cxx
FunctionDescription::getVarArgsStart() has to provide some backward
compatibility for implicit API stability.
+ The new VAR_ARGS value must be significantly greater than the old
+ PAIRED_VAR_ARGS (2*VAR_ARGS) value, in fact greater than any used number of
+ fixed parameters followed by optional paired parameters.
@NOTE: also
reportbuilder/java/org/libreoffice/report/pentaho/StarFunctionDescription.java
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/StarFunctionDescription.java b/reportbuilder/java/org/libreoffice/report/pentaho/StarFunctionDescription.java
index b743ae08e4a1..96c4346e9989 100644
--- a/reportbuilder/java/org/libreoffice/report/pentaho/StarFunctionDescription.java
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/StarFunctionDescription.java
@@ -152,6 +152,7 @@ public final class StarFunctionDescription extends WeakBase
final boolean infinite = functionDescription.isInfiniteParameterCount();
if (infinite)
{
+ // Identical value as VAR_ARGS from formula/funcvarargs.h
count = 30;
}
final FunctionArgument[] args = new FunctionArgument[count];
diff --git a/reportdesign/source/ui/misc/FunctionHelper.cxx b/reportdesign/source/ui/misc/FunctionHelper.cxx
index 584a0288e4aa..349bc8d48061 100644
--- a/reportdesign/source/ui/misc/FunctionHelper.cxx
+++ b/reportdesign/source/ui/misc/FunctionHelper.cxx
@@ -20,6 +20,7 @@
#include "FunctionHelper.hxx"
#include <osl/diagnose.h>
+#include <formula/funcvarargs.h>
namespace rptui
@@ -211,13 +212,18 @@ sal_uInt32 FunctionDescription::getVarArgsStart() const
// Don't use defines/constants that could change in future, parameter count
// could be part of an implicit stable API.
// offapi/com/sun/star/report/meta/XFunctionDescription.idl doesn't tell.
- const sal_uInt32 nVarArgs = 30; // ugly hard coded VAR_ARGS of formula::ParaWin
- const sal_uInt32 nPairedVarArgs = 60; // ugly hard coded PAIRED_VAR_ARGS of formula::ParaWin
+ const sal_uInt32 nVarArgs30 = 30; // ugly hard coded VAR_ARGS of formula::ParaWin
+ const sal_uInt32 nPairedVarArgs60 = 60; // ugly hard coded PAIRED_VAR_ARGS of formula::ParaWin
sal_uInt32 nLen = m_aParameter.getLength();
- if (nLen >= nPairedVarArgs)
- nLen -= nPairedVarArgs;
- else if (nLen >= nVarArgs)
- nLen -= nVarArgs;
+ // If the value of VAR_ARGS changes then adapt *and* maintain implicit API
+ // stability, ie. old code using the old VAR_ARGS and PAIRED_VAR_ARGS
+ // values must still be handled. It is *not* sufficient to simply change
+ // the values here.
+ static_assert(nVarArgs30 == VAR_ARGS && nPairedVarArgs60 == PAIRED_VAR_ARGS);
+ if (nLen >= nPairedVarArgs60)
+ nLen -= nPairedVarArgs60;
+ else if (nLen >= nVarArgs30)
+ nLen -= nVarArgs30;
return nLen ? nLen - 1 : 0;
}