formula/source/core/resource/core_resource.src | 7 ++++ include/formula/compiler.hrc | 3 + include/formula/opcode.hxx | 1 sc/inc/helpids.h | 1 sc/qa/unit/ucalc.cxx | 1 sc/source/core/inc/interpre.hxx | 1 sc/source/core/tool/interpr4.cxx | 1 sc/source/core/tool/interpr7.cxx | 38 +++++++++++++++++++++++++ sc/source/filter/excel/xlformula.cxx | 2 - sc/source/filter/oox/formulabase.cxx | 2 - sc/source/ui/src/scfuncs.src | 23 +++++++++++++++ 11 files changed, 77 insertions(+), 3 deletions(-)
New commits: commit 25434372bf56e0ebdb7e7d47ab3c14c68211509f Author: Winfried Donkers <winfrieddonk...@libreoffice.org> Date: Mon Dec 15 09:45:26 2014 +0100 fdo#76870 Add support for Excel2013 function ENCODEURL Change-Id: I369bcd58055364757b6a098fc3aa0c0065c79b67 Reviewed-on: https://gerrit.libreoffice.org/13478 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src index 1e9c312..2f3f2bc 100644 --- a/formula/source/core/resource/core_resource.src +++ b/formula/source/core/resource/core_resource.src @@ -427,6 +427,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF String SC_OPCODE_COLOR { Text = "ORG.LIBREOFFICE.COLOR"; }; String SC_OPCODE_ERF_MS { Text = "COM.MICROSOFT.ERF.PRECISE" ; }; String SC_OPCODE_ERFC_MS { Text = "COM.MICROSOFT.ERFC.PRECISE" ; }; + String SC_OPCODE_ENCODEURL { Text = "COM.MICROSOFT.ENCODEURL"; }; }; /** These function names are used only in the XLSX import. */ @@ -835,6 +836,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML String SC_OPCODE_COLOR { Text = "_xlfn.ORG.LIBREOFFICE.COLOR"; }; String SC_OPCODE_ERF_MS { Text = "_xlfn.ERF.PRECISE" ; }; String SC_OPCODE_ERFC_MS { Text = "_xlfn.ERFC.PRECISE" ; }; + String SC_OPCODE_ENCODEURL { Text = "_xlfn.ENCODEURL"; }; }; // DO NOT CHANGE NAMES! Only add functions. @@ -1245,6 +1247,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH String SC_OPCODE_COLOR { Text = "COLOR"; }; String SC_OPCODE_ERF_MS { Text = "ERF.PRECISE" ; }; String SC_OPCODE_ERFC_MS { Text = "ERFC.PRECISE" ; }; + String SC_OPCODE_ENCODEURL { Text = "ENCODEURL"; }; }; Resource RID_STRLIST_FUNCTION_NAMES @@ -2793,6 +2796,10 @@ Resource RID_STRLIST_FUNCTION_NAMES { Text [en-US ] = "ERFC.PRECISE" ; }; + String SC_OPCODE_ENCODEURL + { + Text [ en-US ] = "ENCODEURL"; + }; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/formula/compiler.hrc b/include/formula/compiler.hrc index 2d2dd36..dbbea90 100644 --- a/include/formula/compiler.hrc +++ b/include/formula/compiler.hrc @@ -195,7 +195,8 @@ #define SC_OPCODE_ERF_MS 163 #define SC_OPCODE_ERFC_MS 164 #define SC_OPCODE_ERROR_TYPE_ODF 165 -#define SC_OPCODE_STOP_1_PAR 166 +#define SC_OPCODE_ENCODEURL 166 +#define SC_OPCODE_STOP_1_PAR 167 /*** Functions with more than one parameters ***/ #define SC_OPCODE_START_2_PAR 201 diff --git a/include/formula/opcode.hxx b/include/formula/opcode.hxx index a282dae..3a2af3a 100644 --- a/include/formula/opcode.hxx +++ b/include/formula/opcode.hxx @@ -465,6 +465,7 @@ enum OpCode : sal_uInt16 ocColor = SC_OPCODE_COLOR, ocErf_MS = SC_OPCODE_ERF_MS, ocErfc_MS = SC_OPCODE_ERFC_MS, + ocEncodeURL = SC_OPCODE_ENCODEURL, // internal stuff ocInternalBegin = SC_OPCODE_INTERNAL_BEGIN, ocTTT = SC_OPCODE_TTT, diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h index 9768806..574afb0 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 eb4454f..b839816 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 7f8d134..50864c3 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 28f8e03..81ec490 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 c5e9b74..a4a8f60 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 6908344..ec31fad 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 2936189..690231b 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 2e5e960..fcff272 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 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits