summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorTor Lillqvist <tlillqvist@suse.com>2012-11-15 17:55:05 +0200
committerTor Lillqvist <tlillqvist@suse.com>2012-11-15 18:33:09 +0200
commitd8edf07ed9e7a3e2f2ab43ffd2935b93326f2caa (patch)
treefcc91844900827238324f8ad93f1dbf64306b13b /shell
parent42782fddff98eeab5c8249918e9ba000f08c22e8 (diff)
Bin use of UTF-16 expat variant in the Windows shell extension
Thus we can drop that variant completely. Change-Id: I11a8e40436921219bd6dd4afad4c7907ccb6b84c
Diffstat (limited to 'shell')
-rw-r--r--shell/Library_ooofilt.mk2
-rw-r--r--shell/Library_ooofilt_x64.mk2
-rw-r--r--shell/Library_propertyhdl.mk2
-rw-r--r--shell/Library_propertyhdl_x64.mk2
-rwxr-xr-x[-rw-r--r--]shell/Library_recentfile.mk8
-rw-r--r--shell/Library_shlxthdl.mk2
-rw-r--r--shell/Library_shlxthdl_x64.mk2
-rw-r--r--shell/StaticLibrary_shlxthandler_common.mk2
-rw-r--r--shell/StaticLibrary_shlxthandler_common_x64.mk2
-rw-r--r--shell/StaticLibrary_xmlparser.mk8
-rw-r--r--shell/StaticLibrary_xmlparser_x64.mk2
-rw-r--r--shell/inc/internal/i_xml_parser_event_handler.hxx2
-rw-r--r--shell/inc/internal/utilities.hxx6
-rw-r--r--shell/source/all/xml_parser.cxx40
-rw-r--r--shell/source/win32/shlxthandler/util/utilities.cxx42
15 files changed, 80 insertions, 44 deletions
diff --git a/shell/Library_ooofilt.mk b/shell/Library_ooofilt.mk
index 8688d7ca8cfe..b018f20ef32e 100644
--- a/shell/Library_ooofilt.mk
+++ b/shell/Library_ooofilt.mk
@@ -48,7 +48,7 @@ $(eval $(call gb_Library_add_defs,ooofilt,\
))
$(eval $(call gb_Library_use_externals,ooofilt,\
- expat_utf16 \
+ expat_utf8 \
zlib \
))
diff --git a/shell/Library_ooofilt_x64.mk b/shell/Library_ooofilt_x64.mk
index e3baee3faced..68fada47ac90 100644
--- a/shell/Library_ooofilt_x64.mk
+++ b/shell/Library_ooofilt_x64.mk
@@ -54,7 +54,7 @@ $(eval $(call gb_Library_add_defs,ooofilt_x64,\
))
$(eval $(call gb_Library_use_externals,ooofilt_x64,\
- expat_utf16_x64 \
+ expat_utf8_x64 \
zlib_x64 \
))
diff --git a/shell/Library_propertyhdl.mk b/shell/Library_propertyhdl.mk
index 18af60fb676a..93d39823d531 100644
--- a/shell/Library_propertyhdl.mk
+++ b/shell/Library_propertyhdl.mk
@@ -48,7 +48,7 @@ $(eval $(call gb_Library_add_defs,propertyhdl,\
))
$(eval $(call gb_Library_use_externals,propertyhdl,\
- expat_utf16 \
+ expat_utf8 \
zlib \
))
diff --git a/shell/Library_propertyhdl_x64.mk b/shell/Library_propertyhdl_x64.mk
index e6e9c591e44f..41aa8eb5fe61 100644
--- a/shell/Library_propertyhdl_x64.mk
+++ b/shell/Library_propertyhdl_x64.mk
@@ -54,7 +54,7 @@ $(eval $(call gb_Library_add_defs,propertyhdl_x64,\
))
$(eval $(call gb_Library_use_externals,propertyhdl_x64,\
- expat_utf16_x64 \
+ expat_utf8_x64 \
zlib_x64 \
))
diff --git a/shell/Library_recentfile.mk b/shell/Library_recentfile.mk
index cd27d3f48cd2..70f57a1e8790 100644..100755
--- a/shell/Library_recentfile.mk
+++ b/shell/Library_recentfile.mk
@@ -32,18 +32,10 @@ $(eval $(call gb_Library_set_include,recentfile,\
$$(INCLUDE) \
))
-ifeq ($(GUI),WNT)
-$(eval $(call gb_Library_use_externals,recentfile,\
- expat_utf16 \
-))
-
-else
$(eval $(call gb_Library_use_externals,recentfile,\
expat_utf8 \
))
-endif
-
$(eval $(call gb_Library_use_libraries,recentfile,\
sal \
$(gb_UWINAPI) \
diff --git a/shell/Library_shlxthdl.mk b/shell/Library_shlxthdl.mk
index 7881f5f33dce..07aa300fe9db 100644
--- a/shell/Library_shlxthdl.mk
+++ b/shell/Library_shlxthdl.mk
@@ -48,7 +48,7 @@ $(eval $(call gb_Library_add_defs,shlxthdl,\
))
$(eval $(call gb_Library_use_externals,shlxthdl,\
- expat_utf16 \
+ expat_utf8 \
zlib \
))
diff --git a/shell/Library_shlxthdl_x64.mk b/shell/Library_shlxthdl_x64.mk
index 33656b49ae8d..e41bbb72af28 100644
--- a/shell/Library_shlxthdl_x64.mk
+++ b/shell/Library_shlxthdl_x64.mk
@@ -54,7 +54,7 @@ $(eval $(call gb_Library_add_defs,shlxthdl_x64,\
))
$(eval $(call gb_Library_use_externals,shlxthdl_x64,\
- expat_utf16_x64 \
+ expat_utf8_x64 \
zlib_x64 \
))
diff --git a/shell/StaticLibrary_shlxthandler_common.mk b/shell/StaticLibrary_shlxthandler_common.mk
index 65a0725860ea..5d5f7bd89226 100644
--- a/shell/StaticLibrary_shlxthandler_common.mk
+++ b/shell/StaticLibrary_shlxthandler_common.mk
@@ -47,7 +47,7 @@ $(eval $(call gb_StaticLibrary_add_defs,shlxthandler_common,\
))
$(eval $(call gb_StaticLibrary_use_externals,shlxthandler_common,\
- expat_utf16 \
+ expat_utf8 \
zlib \
))
diff --git a/shell/StaticLibrary_shlxthandler_common_x64.mk b/shell/StaticLibrary_shlxthandler_common_x64.mk
index 41b1ae623184..427de020caa9 100644
--- a/shell/StaticLibrary_shlxthandler_common_x64.mk
+++ b/shell/StaticLibrary_shlxthandler_common_x64.mk
@@ -53,7 +53,7 @@ $(eval $(call gb_StaticLibrary_add_defs,shlxthandler_common_x64,\
))
$(eval $(call gb_StaticLibrary_use_externals,shlxthandler_common_x64,\
- expat_utf16_x64 \
+ expat_utf8_x64 \
zlib_x64 \
))
diff --git a/shell/StaticLibrary_xmlparser.mk b/shell/StaticLibrary_xmlparser.mk
index c86bb75937fb..d329c005aaaa 100644
--- a/shell/StaticLibrary_xmlparser.mk
+++ b/shell/StaticLibrary_xmlparser.mk
@@ -32,18 +32,10 @@ $(eval $(call gb_StaticLibrary_set_include,shell_xmlparser,\
$$(INCLUDE) \
))
-ifeq ($(GUI),WNT)
-$(eval $(call gb_StaticLibrary_use_externals,shell_xmlparser,\
- expat_utf16 \
-))
-
-else
$(eval $(call gb_StaticLibrary_use_externals,shell_xmlparser,\
expat_utf8 \
))
-endif
-
$(eval $(call gb_StaticLibrary_add_exception_objects,shell_xmlparser,\
shell/source/all/xml_parser \
))
diff --git a/shell/StaticLibrary_xmlparser_x64.mk b/shell/StaticLibrary_xmlparser_x64.mk
index bbf7a4a40207..244c310ffdf1 100644
--- a/shell/StaticLibrary_xmlparser_x64.mk
+++ b/shell/StaticLibrary_xmlparser_x64.mk
@@ -35,7 +35,7 @@ $(eval $(call gb_StaticLibrary_set_include,shell_xmlparser_x64,\
))
$(eval $(call gb_StaticLibrary_use_externals,shell_xmlparser_x64,\
- expat_utf16_x64 \
+ expat_utf8_x64 \
))
$(eval $(call gb_StaticLibrary_add_x64_generated_exception_objects,shell_xmlparser_x64,\
diff --git a/shell/inc/internal/i_xml_parser_event_handler.hxx b/shell/inc/internal/i_xml_parser_event_handler.hxx
index 2f2d7d81aa2a..356c92130277 100644
--- a/shell/inc/internal/i_xml_parser_event_handler.hxx
+++ b/shell/inc/internal/i_xml_parser_event_handler.hxx
@@ -23,7 +23,7 @@
#include <string>
#include <map>
-#if defined(XML_UNICODE) || defined(XML_UNICODE_WCHAR_T)
+#ifdef _WIN32
typedef std::wstring string_t;
typedef wchar_t char_t;
#else
diff --git a/shell/inc/internal/utilities.hxx b/shell/inc/internal/utilities.hxx
index 157859a8e7f7..8921671fb4e7 100644
--- a/shell/inc/internal/utilities.hxx
+++ b/shell/inc/internal/utilities.hxx
@@ -73,6 +73,12 @@ std::wstring StringToWString(const std::string& String);
std::string WStringToString(const std::wstring& String);
//---------------------------------
+/** Convert a string to a wstring
+ using CP_UTF8
+*/
+std::wstring UTF8ToWString(const std::string& String);
+
+//---------------------------------
/** Retrieve a string from the
resources of this module
*/
diff --git a/shell/source/all/xml_parser.cxx b/shell/source/all/xml_parser.cxx
index 54e1cffa5f41..23e43d5f8d6e 100644
--- a/shell/source/all/xml_parser.cxx
+++ b/shell/source/all/xml_parser.cxx
@@ -21,6 +21,12 @@
#include "internal/xml_parser.hxx"
#include "internal/i_xml_parser_event_handler.hxx"
+#ifdef _WIN32
+#include "internal/utilities.hxx"
+#else
+#define UTF8ToWString(s) s
+#endif
+
#include <assert.h>
namespace /* private */
@@ -96,12 +102,12 @@ static void xml_start_element_handler(void* UserData, const XML_Char* name, cons
while(atts[i])
{
- attributes[reinterpret_cast<const char_t*>(get_local_name(atts[i]))] = reinterpret_cast<const char_t*>(atts[i+1]);
+ attributes[UTF8ToWString(reinterpret_cast<const char*>(get_local_name(atts[i])))] = UTF8ToWString(reinterpret_cast<const char*>(atts[i+1]));
i += 2; // skip to next pair
}
pDocHdl->start_element(
- reinterpret_cast<const char_t*>(name), reinterpret_cast<const char_t*>(get_local_name(name)), attributes);
+ UTF8ToWString(reinterpret_cast<const char*>(name)), UTF8ToWString(reinterpret_cast<const char*>(get_local_name(name))), attributes);
}
}
@@ -112,11 +118,13 @@ static void xml_end_element_handler(void* UserData, const XML_Char* name)
xml_parser* pImpl = get_parser_instance(UserData);
i_xml_parser_event_handler* pDocHdl = pImpl->get_document_handler();
if (pDocHdl)
- pDocHdl->end_element(reinterpret_cast<const char_t*>(name), reinterpret_cast<const char_t*>(get_local_name(name)));
+ pDocHdl->end_element(UTF8ToWString(reinterpret_cast<const char*>(name)), UTF8ToWString(reinterpret_cast<const char*>(get_local_name(name))));
}
static void xml_character_data_handler(void* UserData, const XML_Char* s, int len)
{
+ static int count = 0;
+
assert(UserData);
xml_parser* pImpl = get_parser_instance(UserData);
@@ -124,10 +132,30 @@ static void xml_character_data_handler(void* UserData, const XML_Char* s, int le
if (pDocHdl)
{
if (has_only_whitespaces(s,len))
- pDocHdl->ignore_whitespace(string_t(reinterpret_cast<const char_t*>(s), len));
+ pDocHdl->ignore_whitespace(UTF8ToWString(std::string(reinterpret_cast<const char*>(s), len)));
else
- pDocHdl->characters(string_t(reinterpret_cast<const char_t*>(s), len));
+ pDocHdl->characters(UTF8ToWString(std::string(reinterpret_cast<const char*>(s), len)));
+ }
+#if 0
+ if (count < 5) {
+ char buf[1000];
+ sprintf(buf,
+ "%s: len=%d\n"
+ "s=%.10s\n"
+ "pDocHdl=%p has_only_whitespaces()=%d\n"
+ "string=%S",
+ "xml_character_data_handler",
+ len,
+ s,
+ pDocHdl,
+ has_only_whitespaces(s,len),
+ UTF8ToWString(std::string(reinterpret_cast<const char*>(s), len)).c_str()
+ );
+
+ MessageBoxA(NULL, buf, "xml_character_data_handler", MB_OK);
+ count++;
}
+#endif
}
static void xml_comment_handler(void* UserData, const XML_Char* Data)
@@ -137,7 +165,7 @@ static void xml_comment_handler(void* UserData, const XML_Char* Data)
xml_parser* pImpl = get_parser_instance(UserData);
i_xml_parser_event_handler* pDocHdl = pImpl->get_document_handler();
if (pDocHdl)
- pDocHdl->comment(reinterpret_cast<const char_t*>(Data));
+ pDocHdl->comment(UTF8ToWString(reinterpret_cast<const char*>(Data)));
}
} // extern "C"
diff --git a/shell/source/win32/shlxthandler/util/utilities.cxx b/shell/source/win32/shlxthandler/util/utilities.cxx
index a92a69cce8aa..c62ec833b4fc 100644
--- a/shell/source/win32/shlxthandler/util/utilities.cxx
+++ b/shell/source/win32/shlxthandler/util/utilities.cxx
@@ -32,36 +32,30 @@
const size_t MAX_RES_STRING = 1024;
const wchar_t SPACE_CHAR = _T(' ');
-//---------------------------------
-/**
-*/
-std::wstring StringToWString(const std::string& String)
+static std::wstring StringToWString(const std::string& String, int codepage)
{
int len = MultiByteToWideChar(
- CP_ACP, 0, String.c_str(), -1, 0, 0);
+ codepage, 0, String.c_str(), -1, 0, 0);
wchar_t* buff = reinterpret_cast<wchar_t*>(
_alloca(len * sizeof(wchar_t)));
MultiByteToWideChar(
- CP_ACP, 0, String.c_str(), -1, buff, len);
+ codepage, 0, String.c_str(), -1, buff, len);
return std::wstring(buff);
}
-//---------------------------------
-/**
-*/
-std::string WStringToString(const std::wstring& String)
+static std::string WStringToString(const std::wstring& String, int codepage)
{
int len = WideCharToMultiByte(
- CP_ACP, 0, String.c_str(), -1, 0, 0, 0, 0);
+ codepage, 0, String.c_str(), -1, 0, 0, 0, 0);
char* buff = reinterpret_cast<char*>(
_alloca(len * sizeof(char)));
WideCharToMultiByte(
- CP_ACP, 0, String.c_str(), -1, buff, len, 0, 0);
+ codepage, 0, String.c_str(), -1, buff, len, 0, 0);
return std::string(buff);
}
@@ -69,6 +63,30 @@ std::string WStringToString(const std::wstring& String)
//---------------------------------
/**
*/
+std::wstring StringToWString(const std::string& String)
+{
+ return StringToWString(String, CP_ACP);
+}
+
+//---------------------------------
+/**
+*/
+std::string WStringToString(const std::wstring& String)
+{
+ return WStringToString(String, CP_ACP);
+}
+
+//---------------------------------
+/**
+*/
+std::wstring UTF8ToWString(const std::string& String)
+{
+ return StringToWString(String, CP_UTF8);
+}
+
+//---------------------------------
+/**
+*/
std::wstring GetResString(int ResId)
{
wchar_t szResStr[MAX_RES_STRING];