summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorWinfried Donkers <winfrieddonkers@libreoffice.org>2014-12-15 09:45:26 +0100
committerEike Rathke <erack@redhat.com>2015-01-26 22:16:06 +0000
commit25434372bf56e0ebdb7e7d47ab3c14c68211509f (patch)
tree52d7afa7523af68d9181770a0ac7c3ec3d58bb49 /sc
parent6744fe62973edbc2a4108905192fce4b2854ac39 (diff)
fdo#76870 Add support for Excel2013 function ENCODEURL
Change-Id: I369bcd58055364757b6a098fc3aa0c0065c79b67 Reviewed-on: https://gerrit.libreoffice.org/13478 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/helpids.h1
-rw-r--r--sc/qa/unit/ucalc.cxx1
-rw-r--r--sc/source/core/inc/interpre.hxx1
-rw-r--r--sc/source/core/tool/interpr4.cxx1
-rw-r--r--sc/source/core/tool/interpr7.cxx38
-rw-r--r--sc/source/filter/excel/xlformula.cxx2
-rw-r--r--sc/source/filter/oox/formulabase.cxx2
-rw-r--r--sc/source/ui/src/scfuncs.src23
8 files changed, 67 insertions, 2 deletions
diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h
index 9768806cdf7a..574afb0e6fc3 100644
--- a/sc/inc/helpids.h
+++ b/sc/inc/helpids.h
@@ -563,6 +563,7 @@
#define HID_FUNC_BITRSHIFT "SC_HID_FUNC_BITRSHIFT"
#define HID_FUNC_FILTERXML "SC_HID_FUNC_FILTERXML"
#define HID_FUNC_WEBSERVICE "SC_HID_FUNC_WEBSERVICE"
+#define HID_FUNC_ENCODEURL "SC_HID_FUNC_ENCODEURL"
#define HID_FUNC_COLOR "SC_HID_FUNC_COLOR"
#define HID_FUNC_COVARIANCE_P "SC_HID_FUNC_COVARIANCE_P"
#define HID_FUNC_COVARIANCE_S "SC_HID_FUNC_COVARIANCE_S"
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index eb4454f33f34..b839816dae1c 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2669,6 +2669,7 @@ void Test::testFunctionLists()
"CONCATENATE",
"DECIMAL",
"DOLLAR",
+ "ENCODEURL",
"EXACT",
"FILTERXML",
"FIND",
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 7f8d13458525..50864c3a3ade 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -852,6 +852,7 @@ void ScMidB();
void ScFilterXML();
void ScWebservice();
+void ScEncodeURL();
void ScColor();
void ScErf();
void ScErfc();
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 28f8e0391340..81ec490ce8cb 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4044,6 +4044,7 @@ StackVar ScInterpreter::Interpret()
case ocRate : ScRate(); break;
case ocFilterXML : ScFilterXML(); break;
case ocWebservice : ScWebservice(); break;
+ case ocEncodeURL : ScEncodeURL(); break;
case ocColor : ScColor(); break;
case ocErf_MS : ScErf(); break;
case ocErfc_MS : ScErfc(); break;
diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx
index c5e9b7414a36..a4a8f60aebe0 100644
--- a/sc/source/core/tool/interpr7.cxx
+++ b/sc/source/core/tool/interpr7.cxx
@@ -203,6 +203,44 @@ void ScInterpreter::ScWebservice()
}
}
+/**
+ Returns a string in which all non-alphanumeric characters except stroke and
+ underscore (-_) have been replaced with a percent (%) sign
+ followed by hex digits.
+ It is encoded the same way that the posted data from a WWW form is encoded,
+ that is the same way as in application/x-www-form-urlencoded media type and
+ as pwer RFC 3986.
+
+ @see fdo#76870
+*/
+void ScInterpreter::ScEncodeURL()
+{
+ sal_uInt8 nParamCount = GetByte();
+ if ( MustHaveParamCount( nParamCount, 1 ) )
+ {
+ OUString aStr = GetString().getString();
+ if ( aStr.isEmpty() )
+ {
+ PushError( errNoValue );
+ return;
+ }
+
+ OStringBuffer aUrlBuf;
+ for ( int i = 0; i < aStr.getLength(); i++ )
+ {
+ sal_Unicode c = aStr[ i ];
+ if ( rtl::isAsciiAlphanumeric( c ) || c == '-' || c == '_' )
+ aUrlBuf.append( static_cast<sal_Char>( c ) );
+ else
+ {
+ aUrlBuf.append( '%' );
+ aUrlBuf.append( OString::number( static_cast<sal_Int32>( c ), 16 ).toAsciiUpperCase() );
+ }
+ }
+ PushString( OUString::fromUtf8( aUrlBuf.makeStringAndClear() ) );
+ }
+}
+
void ScInterpreter::ScDebugVar()
{
// This is to be used by developers only! Never document this for end
diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx
index 690834417fca..ec31fad5509a 100644
--- a/sc/source/filter/excel/xlformula.cxx
+++ b/sc/source/filter/excel/xlformula.cxx
@@ -534,7 +534,7 @@ static const XclFunctionInfo saFuncTable_2013[] =
EXC_FUNCENTRY_V_VR_IMPORT( ocCosecantHyp, 1, 1, 0, "CSCH" ),
EXC_FUNCENTRY_V_VR( ocGetDiffDate, 2, 2, 0, "DAYS" ),
EXC_FUNCENTRY_V_VR( ocDecimal, 2, 2, 0, "DECIMAL" ),
- EXC_FUNCENTRY_V_VR( ocNoName, 1, 1, 0, "ENCODEURL" ),
+ EXC_FUNCENTRY_V_VR( ocEncodeURL, 1, 1, 0, "ENCODEURL" ),
// NOTE: this FDIST is not our LEGACY.FDIST
EXC_FUNCENTRY_V_VR( ocNoName, 3, 4, 0, "FDIST" ),
// NOTE: this FINV is not our LEGACY.FINV
diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx
index 29361899e940..690231b24928 100644
--- a/sc/source/filter/oox/formulabase.cxx
+++ b/sc/source/filter/oox/formulabase.cxx
@@ -857,7 +857,7 @@ static const FunctionData saFuncTable2013[] =
{ "CSCH", "CSCH", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW },
{ "DAYS", "DAYS", NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALL_NEW },
{ "DECIMAL", "DECIMAL", NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALL_NEW },
- { 0, "ENCODEURL", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW },
+ { "COM.MICROSOFT.ENCODEURL","ENCODEURL", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW },
{ "COM.MICROSOFT.FILTERXML","FILTERXML", NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALL_NEW },
/* FIXME: FLOOR.MATH is our/ODFF FLOOR, but we have special handling for
* the weird Excel FLOOR behavior, check that and unify or diversify. */
diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src
index 2e5e960877bd..fcff2727a12f 100644
--- a/sc/source/ui/src/scfuncs.src
+++ b/sc/source/ui/src/scfuncs.src
@@ -12091,6 +12091,29 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
Text [ en-US ] = "URI of the webservice";
};
};
+ Resource SC_OPCODE_ENCODEURL
+ {
+ String 1 // Description
+ {
+ Text [ en-US] = "Return a URL-encoded string.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_ENCODEURL );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Text";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "A string to be URL encoded";
+ };
+ };
Resource SC_OPCODE_ERF_MS
{
String 1 // Description