1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
$NetBSD: patch-as,v 1.1.1.1 2002/02/13 18:09:22 mrauch Exp $
--- ../connectivity/source/drivers/mozab/mozillasrc/nortti/MTypeConverter.cxx.orig Sun Jan 6 11:44:27 2002
+++ ../connectivity/source/drivers/mozab/mozillasrc/nortti/MTypeConverter.cxx
@@ -0,0 +1,112 @@
+
+#include <MNSInclude.hxx>
+
+#ifndef _CONNECTIVITY_MAB_TYPECONVERTER_HXX_
+#include "MTypeConverter.hxx"
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+
+using namespace connectivity::mozab;
+
+// -------------------------------------------------------------------------
+void MTypeConverter::ouStringToNsString(::rtl::OUString const &ous, nsString &nss)
+{
+ OSL_TRACE( "IN MTypeConverter::OUStringToNsString()\n" );
+
+ // Convert to ::rtl::OString (utf-8 encoding).
+ ::rtl::OString os(ous,ous.getLength(), RTL_TEXTENCODING_UTF8);
+
+ const char *cs = os.getStr();
+ PRUint32 csLen = os.getLength();
+
+ NS_ConvertUTF8toUCS2 mozString(cs, csLen);
+ //const PRUnichar* uniMozString = (const PRUnichar*) mozString;
+ nss = mozString; // temp.
+
+ OSL_TRACE( "\tOUT MTypeConverter::OUStringToNsString()\n" );
+}
+// -------------------------------------------------------------------------
+void MTypeConverter::nsStringToOUString(nsString const &nss, ::rtl::OUString &ous)
+{
+ OSL_TRACE( "IN MTypeConverter::nsStringToOUString()\n" );
+
+ // Get clone of buffer.
+ PRUnichar *uc = nss.ToNewUnicode();
+ sal_Int32 nssLen = nss.Length();
+
+ // TODO check if this is ok.
+ ::rtl::OUString _ous(uc, nssLen);
+ ous = _ous;
+
+ nsMemory::Free(uc);
+
+ OSL_TRACE( "\tOUT MTypeConverter::nsStringToOUString()\n" );
+}
+// -------------------------------------------------------------------------
+void MTypeConverter::prUnicharToOUString(PRUnichar const *pru, ::rtl::OUString &ous)
+{
+ OSL_TRACE( "IN MTypeConverter::prUniCharToOUString()\n" );
+
+ // TODO, specify length.
+ ::rtl::OUString _ous(pru);
+ ous = _ous;
+
+ OSL_TRACE( "\tOUT MTypeConverter::prUniCharToOUString()\n" );
+}
+// -------------------------------------------------------------------------
+char *MTypeConverter::ouStringToCCharStringUtf8(::rtl::OUString const &ous)
+{
+ OSL_TRACE( "IN MTypeConverter::OUStringToCCharStringUtf8()\n" );
+
+ // Convert to ::rtl::OString,
+ ::rtl::OString os(ous,ous.getLength(), RTL_TEXTENCODING_UTF8);
+
+ const char *cs = os.getStr();
+
+ OSL_TRACE( "\tOUT MTypeConverter::OUStringToCCharStringUtf8()\n" );
+ return(strdup(cs));
+}
+// -------------------------------------------------------------------------
+char *MTypeConverter::ouStringToCCharStringAscii(::rtl::OUString const &ous)
+{
+ OSL_TRACE( "IN MTypeConverter::OUStringToCCharStringAscii()\n" );
+
+ // Convert ::rtl::OUString to ::rtl::OString,
+ ::rtl::OString os(ous,ous.getLength(), RTL_TEXTENCODING_ASCII_US);
+
+ OSL_TRACE( "\tOUT MTypeConverter::OUStringToCCharStringAscii()\n" );
+ return(strdup(os.getStr()));
+}
+// -------------------------------------------------------------------------
+char *MTypeConverter::nsStringToCCharStringAscii(nsString const &nss)
+{
+ OSL_TRACE( "IN MTypeConverter::nsStringToCCharStringAscii()\n" );
+
+ char cs[1024];
+ nss.ToCString(cs, 1024);
+
+ OSL_TRACE( "\tOUT MTypeConverter::nsStringToCCharStringAscii()\n" );
+ return(strdup(cs));
+}
+// -------------------------------------------------------------------------
+::std::string MTypeConverter::ouStringToStlString(::rtl::OUString const &ous)
+{
+ OSL_TRACE( "IN MTypeConverter::ouStringToStlString()\n" );
+
+ // Convert ::rtl::OUString to ::rtl::OString.
+ ::rtl::OString os(ous,ous.getLength(),RTL_TEXTENCODING_ASCII_US);
+
+ OSL_TRACE( "\tOUT MTypeConverter::ouStringToStlString()\n" );
+ return( ::std::string(os.getStr()));
+}
+// -------------------------------------------------------------------------
+::std::string MTypeConverter::nsStringToStlString(nsString const &nss)
+{
+ OSL_TRACE( "IN MTypeConverter::nsStringToStlString()\n" );
+
+ OSL_TRACE( "\tOUT MTypeConverter::nsStringToStlString()\n" );
+ return( ::std::string(nss.GetBuffer()));
+}
+// -------------------------------------------------------------------------
|