diff options
-rw-r--r-- | RepositoryExternal.mk | 14 | ||||
-rw-r--r-- | expat/Module_expat.mk | 4 | ||||
-rw-r--r-- | expat/README | 36 | ||||
-rw-r--r-- | expat/StaticLibrary_expat_utf16.mk | 55 | ||||
-rw-r--r-- | expat/StaticLibrary_expat_x64.mk | 1 | ||||
-rw-r--r-- | expat/UnpackedTarball_expat.mk | 17 | ||||
-rw-r--r-- | shell/Library_ooofilt.mk | 2 | ||||
-rw-r--r-- | shell/Library_ooofilt_x64.mk | 2 | ||||
-rw-r--r-- | shell/Library_propertyhdl.mk | 2 | ||||
-rw-r--r-- | shell/Library_propertyhdl_x64.mk | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | shell/Library_recentfile.mk | 8 | ||||
-rw-r--r-- | shell/Library_shlxthdl.mk | 2 | ||||
-rw-r--r-- | shell/Library_shlxthdl_x64.mk | 2 | ||||
-rw-r--r-- | shell/StaticLibrary_shlxthandler_common.mk | 2 | ||||
-rw-r--r-- | shell/StaticLibrary_shlxthandler_common_x64.mk | 2 | ||||
-rw-r--r-- | shell/StaticLibrary_xmlparser.mk | 8 | ||||
-rw-r--r-- | shell/StaticLibrary_xmlparser_x64.mk | 2 | ||||
-rw-r--r-- | shell/inc/internal/i_xml_parser_event_handler.hxx | 2 | ||||
-rw-r--r-- | shell/inc/internal/utilities.hxx | 6 | ||||
-rw-r--r-- | shell/source/all/xml_parser.cxx | 40 | ||||
-rw-r--r-- | shell/source/win32/shlxthandler/util/utilities.cxx | 42 |
21 files changed, 88 insertions, 163 deletions
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk index 6712055d26b7..d4281c91ec02 100644 --- a/RepositoryExternal.mk +++ b/RepositoryExternal.mk @@ -287,7 +287,6 @@ else # !SYSTEM_EXPAT $(eval $(call gb_Helper_register_static_libraries,PLAINLIBS, \ expat \ - expat_utf16 \ expat_x64 \ )) @@ -299,11 +298,6 @@ $(call gb_LinkTarget_set_include,$(1),\ $$(INCLUDE) \ ) -$(if $(filter expat_utf16,$(2)),\ - $(call gb_LinkTarget_add_defs,$(1),\ - -DXML_UNICODE \ -)) - $(call gb_LinkTarget_use_static_libraries,$(1),\ $(2) \ ) @@ -312,18 +306,12 @@ endef endif # SYSTEM_EXPAT -# now define 2 wrappers that select which internal static library to use... define gb_LinkTarget__use_expat_utf8 $(call gb_LinkTarget__use_expat,$(1),expat) endef -define gb_LinkTarget__use_expat_utf16 -$(call gb_LinkTarget__use_expat,$(1),expat_utf16) - -endef - -define gb_LinkTarget__use_expat_utf16_x64 +define gb_LinkTarget__use_expat_utf8_x64 $(call gb_LinkTarget__use_expat,$(1),expat_x64) endef diff --git a/expat/Module_expat.mk b/expat/Module_expat.mk index 9366538cf052..8c7d8d020b91 100644 --- a/expat/Module_expat.mk +++ b/expat/Module_expat.mk @@ -15,7 +15,6 @@ $(eval $(call gb_Module_add_targets,expat,\ ExternalPackage_expat \ UnpackedTarball_expat \ StaticLibrary_expat \ - StaticLibrary_expat_utf16 \ )) # Actually it wasn't that clear if we should @@ -32,9 +31,6 @@ $(eval $(call gb_Module_add_targets,expat,\ endif # ---------------- X64 stuff special --------------------- -# use UNICODE only because shell/shlxthandler -# doesn't link against ascii_expat_xmlparse -#--------------------------------------------------------- ifeq ($(BUILD_X64),TRUE) $(eval $(call gb_Module_add_targets,expat,\ StaticLibrary_expat_x64 \ diff --git a/expat/README b/expat/README index d7ce6824d686..579d3d3d6bd5 100644 --- a/expat/README +++ b/expat/README @@ -1,40 +1,4 @@ Simple SAX parser library with added UTF-16 support. -When we build expat internally ("bundled"), we build two variants: One -that has an "ASCII" (actually UTF-8) API, another that has a "Unicode" -(meaning UTF-16) API. Additionally, expat is split into two parts, -expat_xmlparse and expat_xmltok. It's the former which has the two -variants, ascii_expat_xmlparse (UTF-8) and expat_xmlparse (UTF-16). - -Code that uses expat then declares in its .mk file which one it wants -to use. See the magic in ../RepositoryExternal.mk, where in the -expat_utf16 case -DXML_UNICODE is passed when compiling source code -that wants to use the UTF-16 variant. - -Now, this sounds fairly clear so far. - -But wait. LO can also be conigured to use a *system* expat -library. The System expat library is only available as one variant, -the "ASCII" one. (But the library is still called just "libexpat", no -"ascii" in the name, that is just LO/OO's convention.) So how does -this work then, how can the code that wants to use the UTF-16 expat -API then actually use the "ASCII" (UTF-8) expat API? Well, in the -SYSTEM_EXPAT case no -DXML_UNICODE is used, so the code needs to check -that and adapt. So in the system libexpat case, mentioning expat_utf16 -in a .mk file doesn't mean any UTF-16-using libexpat would actually be -used. - -Yeah, this is silly, confusing, etc. - -Furthermore, at least Debian actually *does* have also a "Unicode" -expat library, called libexpatw. Debian's LO does not use that, -though. (Using it would require modifications to the LO build -machinery.) - -Now, if LO manages just fine with just the UTF-8 (or, "ASCII") system -libexpat in builds where that is used, why is a separate Unicode one -needed when an internal expat is used? Good question. Next -question. Patches welcome. - From: [http://expat.sourceforge.net/] diff --git a/expat/StaticLibrary_expat_utf16.mk b/expat/StaticLibrary_expat_utf16.mk deleted file mode 100644 index 0ab3d1f25e61..000000000000 --- a/expat/StaticLibrary_expat_utf16.mk +++ /dev/null @@ -1,55 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_StaticLibrary_StaticLibrary,expat_utf16)) - -$(eval $(call gb_StaticLibrary_set_warnings_not_errors,expat_utf16)) - -$(eval $(call gb_StaticLibrary_use_unpacked,expat_utf16,expat)) - -# no configure step on windows, no dependency -ifneq ($(OS)$(COM),WNTMSC) -$(eval $(call gb_StaticLibrary_use_external_project,expat_utf16,expat)) -endif - -$(eval $(call gb_StaticLibrary_add_defs,expat_utf16,\ - -DXML_UNICODE \ -)) - -$(eval $(call gb_StaticLibrary_set_include,expat_utf16,\ - -I$(call gb_UnpackedTarball_get_dir,expat) \ - $$(INCLUDE) \ -)) - -ifeq ($(OS),MACOSX) -ifneq ($(strip $(SYSBASE)),) -$(eval $(call gb_StaticLibrary_add_defs,expat_utf16,\ - -DHAVE_MEMMOVE \ - -DHAVE_BCOPY \ -)) -endif -endif - -ifeq ($(OS),WNT) -$(eval $(call gb_StaticLibrary_add_defs,expat_utf16,\ - -DCOMPILED_FROM_DSP \ -)) -else -$(eval $(call gb_StaticLibrary_add_defs,expat_utf16,\ - -DHAVE_EXPAT_CONFIG_H \ -)) -endif - -$(eval $(call gb_StaticLibrary_add_generated_cobjects,expat_utf16,\ - UnpackedTarball/expat/lib/unicode_xmlparse \ - UnpackedTarball/expat/lib/unicode_xmlrole \ - UnpackedTarball/expat/lib/unicode_xmltok \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/expat/StaticLibrary_expat_x64.mk b/expat/StaticLibrary_expat_x64.mk index bc5b641e18fb..a38ba28c80dd 100644 --- a/expat/StaticLibrary_expat_x64.mk +++ b/expat/StaticLibrary_expat_x64.mk @@ -21,7 +21,6 @@ $(eval $(call gb_StaticLibrary_set_include,expat_x64,\ )) $(eval $(call gb_StaticLibrary_add_defs,expat_x64,\ - -DXML_UNICODE \ -DCOMPILED_FROM_DSP \ )) diff --git a/expat/UnpackedTarball_expat.mk b/expat/UnpackedTarball_expat.mk index a4daa51ea173..660271aa8300 100644 --- a/expat/UnpackedTarball_expat.mk +++ b/expat/UnpackedTarball_expat.mk @@ -15,18 +15,15 @@ $(eval $(call gb_UnpackedTarball_add_patches,expat,\ expat/expat-2.1.0.patch \ )) -# This is a bit hackish -# we need to compile it twice: -# with -DXML_UNICODE and without. +# This is a bit hackish. + +# When building for Windows (as 32-bit) we need to build it twice: as +# 32- and 64-bit code, to be able to produce a 64-bit Explorer +# ("shell") extension that is used when the 32-bit LibreOffice is +# installed on a 64-bit OS. -# This is a bit hackish too ;-) -# on windows 64 bit platform we need to link it twice: -# with $(LINK_X64_BINARY) and with $(gb_LINK). $(eval $(call gb_UnpackedTarball_set_post_action,expat,\ - cp lib/xmltok.c lib/unicode_xmltok.c && \ - cp lib/xmlrole.c lib/unicode_xmlrole.c && \ - cp lib/xmlparse.c lib/unicode_xmlparse.c \ - $(if $(filter $(BUILD_X64),TRUE), && \ + $(if $(filter $(BUILD_X64),TRUE), \ cp lib/xmlparse.c lib/xmlparse_x64.c && \ cp lib/xmltok.c lib/xmltok_x64.c && \ cp lib/xmlrole.c lib/xmlrole_x64.c) \ 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]; |