summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2008-02-26 14:14:25 +0000
committerOliver Bolte <obo@openoffice.org>2008-02-26 14:14:25 +0000
commita7b158bf1a373f104741debb106e69e07b539365 (patch)
treeddd6daf8a944cb875126a3fef8670e924707dcea
parent795637347a00c1a6074aa9629c8cbb6126cb9ec1 (diff)
INTEGRATION: CWS custommeta (1.2.18); FILE MERGED
2008/01/29 12:46:32 mst 1.2.18.1: - comphelper/inc/comphelper/string.hxx, comphelper/source/misc/string.cxx: + add two functions convertCommaSeparated
-rw-r--r--comphelper/source/misc/string.cxx39
1 files changed, 37 insertions, 2 deletions
diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx
index 1a109056cb24..822dd0057ff3 100644
--- a/comphelper/source/misc/string.cxx
+++ b/comphelper/source/misc/string.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: string.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: ihi $ $Date: 2007-11-23 13:15:28 $
+ * last change: $Author: obo $ $Date: 2008-02-26 15:14:25 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -37,11 +37,13 @@
#include "sal/config.h"
#include <cstddef>
+#include <vector>
#include "comphelper/string.hxx"
#include "rtl/ustring.hxx"
#include "sal/types.h"
+
namespace comphelper { namespace string {
rtl::OUString searchAndReplace(
@@ -55,4 +57,37 @@ rtl::OUString searchAndReplace(
return n == -1 ? source : source.replaceAt(n, fromLength, to);
}
+// convert between sequence of string and comma separated string
+
+::rtl::OUString convertCommaSeparated(
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > const& i_rSeq)
+{
+ ::rtl::OUString ret;
+ for (sal_Int32 i = 0; i < i_rSeq.getLength(); ++i) {
+ if (i != 0) ret += ::rtl::OUString::createFromAscii(", ");
+ ret += i_rSeq[i];
+ }
+ return ret;
+}
+
+::com::sun::star::uno::Sequence< ::rtl::OUString >
+ convertCommaSeparated( ::rtl::OUString const& i_rString )
+{
+ std::vector< ::rtl::OUString > vec;
+ sal_Int32 idx = 0;
+ do {
+ ::rtl::OUString kw =
+ i_rString.getToken(0, static_cast<sal_Unicode> (','), idx);
+ kw = kw.trim();
+ if (kw.getLength() > 0) {
+ vec.push_back(kw);
+ }
+ } while (idx >= 0);
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > kws(vec.size());
+ for (size_t i = 0; i < vec.size(); ++i) {
+ kws[i] = vec.at(i);
+ }
+ return kws;
+}
+
} }