summaryrefslogtreecommitdiff
path: root/uui
diff options
context:
space:
mode:
authorThomas Arnhold <thomas@arnhold.org>2014-08-18 01:38:24 +0200
committerThomas Arnhold <thomas@arnhold.org>2014-08-18 01:45:15 +0200
commitfbb3617a9bfb0742990a3711d5e0d3fa5adf3962 (patch)
treebf3923ef1f5baee52a031e44aa3aed60f69abeb9 /uui
parentdc053144e63264d144f15409bf5ed6d6cb7420c9 (diff)
iahndl: do lazy replacement
There's no need for such a bloat method to replace just two vars. Change-Id: I235d092b89160c2599a41e1046a15475b8ba433c
Diffstat (limited to 'uui')
-rw-r--r--uui/source/iahndl.cxx33
1 files changed, 6 insertions, 27 deletions
diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx
index 1ec234443ade..ffe9bc85a9cc 100644
--- a/uui/source/iahndl.cxx
+++ b/uui/source/iahndl.cxx
@@ -249,33 +249,12 @@ UUIInteractionHelper::replaceMessageWithArguments(
std::vector< OUString > const & rArguments )
{
OUString aMessage = _aMessage;
- for (sal_Int32 i = 0;;)
- {
- i = aMessage.indexOf("$(ARG", i);
- if (i == -1)
- break;
- if (aMessage.getLength() - i >= RTL_CONSTASCII_LENGTH("$(ARGx)")
- && aMessage[i + RTL_CONSTASCII_LENGTH("$(ARGx")] == ')')
- {
- sal_Unicode c = aMessage[i + RTL_CONSTASCII_LENGTH("$(ARG")];
- if (c >= '1' && c <= '2')
- {
- std::vector< OUString >::size_type nIndex
- = static_cast< std::vector< OUString >::size_type >(
- c - '1');
- if (nIndex < rArguments.size())
- {
- aMessage
- = aMessage.replaceAt(i,
- RTL_CONSTASCII_LENGTH("$(ARGx)"),
- rArguments[nIndex]);
- i += rArguments[nIndex].getLength();
- continue;
- }
- }
- }
- ++i;
- }
+
+ SAL_WARN_IF(rArguments.size() == 0, "uui", "replaceMessageWithArguments: No arguments passed!");
+ if (rArguments.size() > 0)
+ aMessage = aMessage.replaceAll("$(ARG1)", rArguments[0]);
+ if (rArguments.size() > 1)
+ aMessage = aMessage.replaceAll("$(ARG2)", rArguments[1]);
return aMessage;
}