summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorWinfried Donkers <winfrieddonkers@libreoffice.org>2017-07-05 17:07:08 +0200
committerEike Rathke <erack@redhat.com>2017-07-10 15:13:37 +0200
commitc9f6bd6a714b634c1f366a525cc3571116c3f9f5 (patch)
tree297523f184425a522d7bf37904356cfe0c846bdf /sc/source
parent963a49a4684d1f012c547bb7a626c394abc27dcc (diff)
tdf#107135, add missing ODFF function REPLACEB.
Change-Id: I8d782b109eb390838b6c4f3a85e9b344ecef87ec Reviewed-on: https://gerrit.libreoffice.org/39606 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/funcdesc.cxx3
-rw-r--r--sc/source/core/inc/interpre.hxx1
-rw-r--r--sc/source/core/tool/interpr1.cxx23
-rw-r--r--sc/source/core/tool/interpr4.cxx1
-rw-r--r--sc/source/filter/excel/xlformula.cxx1
-rw-r--r--sc/source/filter/oox/formulabase.cxx2
-rw-r--r--sc/source/ui/src/scfuncs.src15
7 files changed, 44 insertions, 2 deletions
diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx
index 916264fd9fd9..34898e116c9e 100644
--- a/sc/source/core/data/funcdesc.cxx
+++ b/sc/source/core/data/funcdesc.cxx
@@ -798,7 +798,8 @@ ScFunctionList::ScFunctionList()
{ SC_OPCODE_SWITCH_MS, 0, ID_FUNCTION_GRP_LOGIC, HID_FUNC_SWITCH_MS, PAIRED_VAR_ARGS + 1, { 0, 0, 0 } },
{ SC_OPCODE_MINIFS_MS, 0, ID_FUNCTION_GRP_STATISTIC, HID_FUNC_MINIFS_MS, PAIRED_VAR_ARGS + 1, { 0, 0, 0 } },
{ SC_OPCODE_MAXIFS_MS, 0, ID_FUNCTION_GRP_STATISTIC, HID_FUNC_MAXIFS_MS, PAIRED_VAR_ARGS + 1, { 0, 0, 0 } },
- { SC_OPCODE_ROUNDSIG, 0, ID_FUNCTION_GRP_MATH, HID_FUNC_ROUNDSIG, 2, { 0, 0 } }
+ { SC_OPCODE_ROUNDSIG, 0, ID_FUNCTION_GRP_MATH, HID_FUNC_ROUNDSIG, 2, { 0, 0 } },
+ { SC_OPCODE_REPLACEB, 0, ID_FUNCTION_GRP_TEXT, HID_FUNC_REPLACEB, 4, { 0, 0, 0, 0 } }
};
ScFuncDesc* pDesc = nullptr;
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index d44d1141d73b..0e038094d5dc 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -949,6 +949,7 @@ void ScLenB();
void ScRightB();
void ScLeftB();
void ScMidB();
+void ScReplaceB();
void ScFilterXML();
void ScWebservice();
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 35665811c462..5209f40479b1 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8737,6 +8737,29 @@ void ScInterpreter::ScMidB()
}
}
+void ScInterpreter::ScReplaceB()
+{
+ if ( MustHaveParamCount( GetByte(), 4 ) )
+ {
+ OUString aNewStr = GetString().getString();
+ double fCount = GetStringPositionArgument();
+ double fPos = GetStringPositionArgument();
+ OUString aOldStr = GetString().getString();
+ int nLen = getLengthB( aOldStr );
+ if ( fPos < 1.0 || fPos > nLen || fCount < 0.0 || fPos + fCount -1 > nLen )
+ PushIllegalArgument();
+ else
+ {
+ // REPLACEB(aOldStr;fPos;fCount;aNewStr) is the same as
+ // LEFTB(aOldStr;fPos-1) & aNewStr & RIGHT(aOldStr;LENB(aOldStr)-(fPos - 1)-fCount)
+ OUString aStr1 = lcl_LeftB( aOldStr, fPos - 1 );
+ OUString aStr3 = lcl_RightB( aOldStr, nLen - fPos - fCount + 1);
+
+ PushString( aStr1 + aNewStr + aStr3 );
+ }
+ }
+}
+
void ScInterpreter::ScRight()
{
sal_uInt8 nParamCount = GetByte();
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 9ee855897f2a..53eeb96b4d0e 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4419,6 +4419,7 @@ StackVar ScInterpreter::Interpret()
case ocRightB : ScRightB(); break;
case ocLeftB : ScLeftB(); break;
case ocMidB : ScMidB(); break;
+ case ocReplaceB : ScReplaceB(); break;
case ocUnicode : ScUnicode(); break;
case ocUnichar : ScUnichar(); break;
case ocBitAnd : ScBitAnd(); break;
diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx
index 0978c24e4864..efc246c57796 100644
--- a/sc/source/filter/excel/xlformula.cxx
+++ b/sc/source/filter/excel/xlformula.cxx
@@ -213,6 +213,7 @@ static const XclFunctionInfo saFuncTable_2[] =
{ ocIsLogical, 198, 1, 1, V, { VR }, 0, nullptr },
{ ocDBCount2, 199, 3, 3, V, { RO, RR }, 0, nullptr },
{ ocCurrency, 204, 1, 2, V, { VR }, EXC_FUNCFLAG_IMPORTONLY, nullptr },
+ { ocReplaceB, 207, 4, 4, V, { VR }, 0, nullptr },
{ ocLeftB, 208, 1, 2, V, { VR }, 0, nullptr },
{ ocRightB, 209, 1, 2, V, { VR }, 0, nullptr },
{ ocMidB, 210, 3, 3, V, { VR }, 0, nullptr },
diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx
index 1887efcd99ed..a26dd6884af8 100644
--- a/sc/source/filter/oox/formulabase.cxx
+++ b/sc/source/filter/oox/formulabase.cxx
@@ -389,7 +389,7 @@ static const FunctionData saFuncTableBiff3[] =
{ "DOLLAR", "USDOLLAR", 204, 204, 1, 2, V, { VR }, FuncFlags::IMPORTONLY },
{ nullptr/*"FIND"*/, "FINDB", 205, 205, 2, 3, V, { VR }, FuncFlags::NONE },
{ nullptr/*"SEARCH"*/, "SEARCHB", 206, 206, 2, 3, V, { VR }, FuncFlags::NONE },
- { nullptr/*"REPLACE"*/, "REPLACEB", 207, 207, 4, 4, V, { VR }, FuncFlags::NONE },
+ { "REPLACEB", "REPLACEB", 207, 207, 4, 4, V, { VR }, FuncFlags::NONE },
{ "LEFTB", "LEFTB", 208, 208, 1, 2, V, { VR }, FuncFlags::NONE },
{ "RIGHTB", "RIGHTB", 209, 209, 1, 2, V, { VR }, FuncFlags::NONE },
{ "MIDB", "MIDB", 210, 210, 3, 3, V, { VR }, FuncFlags::NONE },
diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src
index 645c377c635b..6f472189a94a 100644
--- a/sc/source/ui/src/scfuncs.src
+++ b/sc/source/ui/src/scfuncs.src
@@ -4856,5 +4856,20 @@ StringArray SC_OPCODE_ROUNDSIG+RID_SC_FUNC_DESCRIPTIONS_START
< "The number of significant digits to which value is to be rounded." ; >;
};
};
+StringArray SC_OPCODE_REPLACEB+RID_SC_FUNC_DESCRIPTIONS_START
+{
+ ItemList [ en-US ] =
+ {
+ < "Replaces characters within a text string with a different text string, with DBCS." ; >;
+ < "Text" ; >;
+ < "The text in which some characters are to be replaced." ; >;
+ < "position" ; >;
+ < "The character position from which text is to be replaced." ; >;
+ < "length" ; >;
+ < "The number of characters to be replaced." ; >;
+ < "new text" ; >;
+ < "The text to be inserted." ; >;
+ };
+};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */