[Libreoffice-commits] core.git: shell/inc shell/qa shell/source

Mike Kaganski mike.kaganski at collabora.com
Thu Sep 28 06:55:28 UTC 2017


 shell/inc/basereader.hxx                                          |    3 
 shell/inc/contentreader.hxx                                       |    3 
 shell/inc/fileextensions.hxx                                      |   12 -
 shell/inc/filepath.hxx                                            |   29 ++
 shell/inc/infotips.hxx                                            |    7 
 shell/inc/metainforeader.hxx                                      |    3 
 shell/inc/propsheets.hxx                                          |    3 
 shell/inc/registry.hxx                                            |   11 
 shell/inc/stream_helper.hxx                                       |    3 
 shell/inc/utilities.hxx                                           |   10 
 shell/inc/zipfile.hxx                                             |    8 
 shell/qa/zip/ziptest.cxx                                          |   10 
 shell/source/backends/localebe/localebackend.cxx                  |   10 
 shell/source/backends/wininetbe/wininetbackend.cxx                |   14 -
 shell/source/tools/regsvrex/regsvrex.cxx                          |   12 -
 shell/source/win32/SysShExec.cxx                                  |    4 
 shell/source/win32/ooofilereader/basereader.cxx                   |    2 
 shell/source/win32/ooofilereader/contentreader.cxx                |    2 
 shell/source/win32/ooofilereader/metainforeader.cxx               |    2 
 shell/source/win32/shlxthandler/columninfo/columninfo.cxx         |    4 
 shell/source/win32/shlxthandler/infotips/infotips.cxx             |   24 --
 shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx               |    4 
 shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx         |    4 
 shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx           |   36 +--
 shell/source/win32/shlxthandler/propsheets/document_statistic.cxx |   12 -
 shell/source/win32/shlxthandler/propsheets/document_statistic.hxx |   22 -
 shell/source/win32/shlxthandler/propsheets/propsheets.cxx         |   31 +-
 shell/source/win32/shlxthandler/shlxthdl.cxx                      |  115 ++++------
 shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx       |    8 
 shell/source/win32/shlxthandler/util/fileextensions.cxx           |   90 +++----
 shell/source/win32/shlxthandler/util/registry.cxx                 |   50 ++--
 shell/source/win32/shlxthandler/util/utilities.cxx                |    6 
 shell/source/win32/simplemail/simplemapi.cxx                      |    2 
 shell/source/win32/simplemail/smplmailsuppl.cxx                   |    2 
 shell/source/win32/zipfile/zipfile.cxx                            |    6 
 35 files changed, 300 insertions(+), 264 deletions(-)

New commits:
commit e80aef4e032f08ef0c4cfbb028bf83b81002f112
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Wed Sep 27 14:20:25 2017 +0300

    shell: use Unicode on Windows
    
    Change-Id: I9f7962db320f8832879ba327108425a7592b4b77
    Reviewed-on: https://gerrit.libreoffice.org/42885
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/shell/inc/basereader.hxx b/shell/inc/basereader.hxx
index 125f49d9773f..0acd5e9e615d 100644
--- a/shell/inc/basereader.hxx
+++ b/shell/inc/basereader.hxx
@@ -28,6 +28,7 @@
 
 #include "xml_parser.hxx"
 #include "zipfile.hxx"
+#include <filepath.hxx>
 
 class CBaseReader : public i_xml_parser_event_handler
 {
@@ -35,7 +36,7 @@ public:
     virtual ~CBaseReader() override;
 
 protected: // protected because its only an implementation relevant class
-    CBaseReader( const std::string& DocumentName );
+    CBaseReader( const Filepath_t& DocumentName );
 
     CBaseReader( StreamInterface *stream );
 
diff --git a/shell/inc/contentreader.hxx b/shell/inc/contentreader.hxx
index d73f4d093741..d2d943e5517d 100644
--- a/shell/inc/contentreader.hxx
+++ b/shell/inc/contentreader.hxx
@@ -22,6 +22,7 @@
 
 #include "basereader.hxx"
 #include <stack>
+#include <filepath.hxx>
 
 class ITag;
 class StreamInterface;
@@ -31,7 +32,7 @@ class CContentReader : public CBaseReader
 public:
     virtual ~CContentReader() override;
 
-    CContentReader( const std::string& DocumentName, LocaleSet_t const & DocumentLocale );
+    CContentReader( const Filepath_t& DocumentName, LocaleSet_t const & DocumentLocale );
 
     CContentReader( StreamInterface* stream, LocaleSet_t const & DocumentLocale );
 
diff --git a/shell/inc/fileextensions.hxx b/shell/inc/fileextensions.hxx
index 0c46a40dd1af..677a7b58a9ea 100644
--- a/shell/inc/fileextensions.hxx
+++ b/shell/inc/fileextensions.hxx
@@ -23,6 +23,7 @@
 #include "global.hxx"
 
 #include <string>
+#include <filepath.hxx>
 
 // A simple table with information about the currently used OO file extensions
 // for instance ".sxw" and information about windows registry keys which are
@@ -34,20 +35,19 @@
 */
 struct FileExtensionEntry
 {
-    const char*    ExtensionAnsi;         // e.g. ".sxw"
-    const wchar_t* ExtensionUnicode;      // e.g. L".sxw"
-    const char*    RegistryForwardKey;    // e.g. "soffice.StarWriterDocument.6"
+    const char*    ExtensionA;            // e.g. ".sxw"
+    const wchar_t* ExtensionU;            // e.g. L".sxw"
+    const wchar_t* RegistryForwardKey;    // e.g. "soffice.StarWriterDocument.6"
 };
 
 extern const FileExtensionEntry OOFileExtensionTable[];
 
 extern const size_t OOFileExtensionTableSize;
 
-
 /** Return the extension of a file
     name without the '.'
 */
-std::string get_file_name_extension(const std::string& file_name);
+Filepath_t get_file_name_extension(const Filepath_t& file_name);
 
 
 /** Return the type of a file
@@ -55,7 +55,7 @@ std::string get_file_name_extension(const std::string& file_name);
 
 enum File_Type_t { UNKNOWN, WRITER, CALC, DRAW, IMPRESS, MATH, WEB, DATABASE };
 
-File_Type_t get_file_type(const std::string& file_name);
+File_Type_t get_file_type(const Filepath_t& file_name);
 
 #endif
 
diff --git a/shell/inc/filepath.hxx b/shell/inc/filepath.hxx
new file mode 100644
index 000000000000..cc1d42a1ccef
--- /dev/null
+++ b/shell/inc/filepath.hxx
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#ifndef INCLUDED_SHELL_INC_INTERNAL_FILEPATH_HXX
+#define INCLUDED_SHELL_INC_INTERNAL_FILEPATH_HXX
+
+
+// typedefs to allow using Unicode paths on Windows
+
+
+#include <string>
+
+#if defined _WIN32
+typedef wchar_t Filepath_char_t;
+typedef std::wstring Filepath_t;
+#else
+typedef char Filepath_char_t;
+typedef std::string Filepath_t;
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/inc/infotips.hxx b/shell/inc/infotips.hxx
index df583614557c..a14569baf1c6 100644
--- a/shell/inc/infotips.hxx
+++ b/shell/inc/infotips.hxx
@@ -30,6 +30,7 @@
 #pragma warning(pop)
 #endif
 #include <string>
+#include <filepath.hxx>
 
 class CInfoTip : public IQueryInfo, public IPersistFile
 {
@@ -84,9 +85,9 @@ public:
             /* [out] */ LPOLESTR __RPC_FAR *ppszFileName) override;
 
 private:
-    long         m_RefCnt;
-    char         m_szFileName[MAX_PATH];
-    std::wstring m_FileNameOnly;
+    long            m_RefCnt;
+    Filepath_char_t m_szFileName[MAX_PATH];
+    std::wstring    m_FileNameOnly;
 };
 
 #endif
diff --git a/shell/inc/metainforeader.hxx b/shell/inc/metainforeader.hxx
index 3b82af374dd3..436a70f287d8 100644
--- a/shell/inc/metainforeader.hxx
+++ b/shell/inc/metainforeader.hxx
@@ -23,6 +23,7 @@
 #include "basereader.hxx"
 #include "types.hxx"
 #include <stack>
+#include <filepath.hxx>
 
 class ITag;
 class CKeywordsTag;
@@ -34,7 +35,7 @@ class CMetaInfoReader : public CBaseReader
 public:
     virtual ~CMetaInfoReader() override;
 
-    CMetaInfoReader( const std::string& DocumentName );
+    CMetaInfoReader( const Filepath_t& DocumentName );
 
     CMetaInfoReader( StreamInterface* stream );
 
diff --git a/shell/inc/propsheets.hxx b/shell/inc/propsheets.hxx
index 53423733c298..8bb77bac45bc 100644
--- a/shell/inc/propsheets.hxx
+++ b/shell/inc/propsheets.hxx
@@ -31,6 +31,7 @@
 #endif
 #include <string>
 #include <memory>
+#include <filepath.hxx>
 
 class CPropertySheet : public IShellExtInit, public IShellPropSheetExt
 {
@@ -80,7 +81,7 @@ private:
 
 private:
     long m_RefCnt;
-    char m_szFileName[MAX_PATH];
+    Filepath_char_t m_szFileName[MAX_PATH];
 };
 
 #endif
diff --git a/shell/inc/registry.hxx b/shell/inc/registry.hxx
index 5738064658e8..4a6d6c843c89 100644
--- a/shell/inc/registry.hxx
+++ b/shell/inc/registry.hxx
@@ -32,30 +32,31 @@
 #pragma warning(pop)
 #endif
 #include <string>
+#include <filepath.hxx>
 
 /** Sets a value of the specified registry key, an empty ValueName sets the default
     value
     Returns true on success
 */
-bool SetRegistryKey(HKEY RootKey, const char* KeyName, const char* ValueName, const char* Value);
+bool SetRegistryKey(HKEY RootKey, const Filepath_char_t* KeyName, const Filepath_char_t* ValueName, const Filepath_char_t* Value);
 
 /** Deletes the specified registry key and all of its subkeys
     Returns true on success
 */
-bool DeleteRegistryKey(HKEY RootKey, const char* KeyName);
+bool DeleteRegistryKey(HKEY RootKey, const Filepath_char_t* KeyName);
 
 /** May be used to determine if the specified registry key has subkeys
     The function returns true on success else if an error occurs false
 */
-bool HasSubkeysRegistryKey(HKEY RootKey, const char* KeyName, bool& bResult);
+bool HasSubkeysRegistryKey(HKEY RootKey, const Filepath_char_t* KeyName, bool& bResult);
 
 /** Converts a GUID to its string representation
 */
-std::string ClsidToString(const CLSID& clsid);
+Filepath_t ClsidToString(const CLSID& clsid);
 
 /** Get the content of a specific key.
 */
-bool QueryRegistryKey(HKEY RootKey, const char* KeyName, const char* ValueName, char *pszData, DWORD dwBufLen);
+bool QueryRegistryKey(HKEY RootKey, const Filepath_char_t* KeyName, const Filepath_char_t* ValueName, Filepath_char_t *pszData, DWORD dwBufLen);
 
 
 #endif
diff --git a/shell/inc/stream_helper.hxx b/shell/inc/stream_helper.hxx
index 2fad7bc88eca..65667d6fe6ce 100644
--- a/shell/inc/stream_helper.hxx
+++ b/shell/inc/stream_helper.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_SHELL_INC_INTERNAL_STREAM_HELPER_HXX
 
 #include "types.hxx"
+#include <filepath.hxx>
 
 struct IStream;
 
@@ -39,7 +40,7 @@ private:
 class FileStream : public StreamInterface
 {
 public:
-    FileStream(const char *filename);
+    FileStream(const Filepath_char_t *filename);
     ~FileStream() override;
     unsigned long sread (unsigned char *buf, unsigned long size) override;
     long stell () override;
diff --git a/shell/inc/utilities.hxx b/shell/inc/utilities.hxx
index d72f6b66fdd9..eb6c289d5023 100644
--- a/shell/inc/utilities.hxx
+++ b/shell/inc/utilities.hxx
@@ -92,18 +92,18 @@ LCID LocaleSetToLCID( const LocaleSet_t & Locale );
 
 
 #ifdef DEBUG
-inline void OutputDebugStringFormatA( LPCSTR pFormat, ... )
+inline void OutputDebugStringFormatW( LPCWSTR pFormat, ... )
 {
-    CHAR    buffer[1024];
+    WCHAR    buffer[1024];
     va_list args;
 
     va_start( args, pFormat );
-    StringCchVPrintfA( buffer, sizeof(buffer), pFormat, args );
+    StringCchVPrintfW( buffer, sizeof(buffer)/sizeof(*buffer), pFormat, args );
     va_end( args );
-    OutputDebugStringA( buffer );
+    OutputDebugStringW( buffer );
 }
 #else
-static inline void OutputDebugStringFormatA( LPCSTR, ... )
+static inline void OutputDebugStringFormatW( LPCWSTR, ... )
 {
 }
 #endif
diff --git a/shell/inc/zipfile.hxx b/shell/inc/zipfile.hxx
index 4f4b4c2331b1..4e31ca7ef246 100644
--- a/shell/inc/zipfile.hxx
+++ b/shell/inc/zipfile.hxx
@@ -25,6 +25,7 @@
 #include <string>
 #include <vector>
 #include <memory>
+#include <filepath.hxx>
 
 class StreamInterface;
 
@@ -34,7 +35,6 @@ class StreamInterface;
 class ZipFile
 {
 public:
-
     typedef std::vector<std::string>   Directory_t;
     typedef std::unique_ptr<Directory_t> DirectoryPtr_t;
     typedef std::vector<char>          ZipContentBuffer_t;
@@ -54,7 +54,7 @@ public:
             IOException if the specified file doesn't exist
             AccessViolationException if read access to the file is denied
     */
-    static bool IsZipFile(const std::string &FileName);
+    static bool IsZipFile(const Filepath_t &FileName);
 
     static bool IsZipFile(void *stream);
 
@@ -74,7 +74,7 @@ public:
             IOException if the specified file doesn't exist or is no zip file
             AccessViolationException if read access to the file is denied
     */
-    static bool IsValidZipFileVersionNumber(const std::string &FileName);
+    static bool IsValidZipFileVersionNumber(const Filepath_t &FileName);
 
     static bool IsValidZipFileVersionNumber(void *stream);
 
@@ -92,7 +92,7 @@ public:
             WrongZipVersionException if the zip file cannot be uncompressed
             with the used zlib version
     */
-    ZipFile(const std::string &FileName);
+    ZipFile(const Filepath_t &FileName);
 
     ZipFile(StreamInterface *stream);
 
diff --git a/shell/qa/zip/ziptest.cxx b/shell/qa/zip/ziptest.cxx
index 2bcfef30c84e..f554e6da71d0 100644
--- a/shell/qa/zip/ziptest.cxx
+++ b/shell/qa/zip/ziptest.cxx
@@ -42,7 +42,7 @@ using namespace std;
 class Test : public CppUnit::TestFixture
 {
 private:
-    string documentName;
+    wstring documentName;
     LPSTREAM pStream;
 public:
     Test();
@@ -66,16 +66,16 @@ CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 Test::Test() : documentName(), pStream(nullptr)
 {
-    const char* pSrcRoot = getenv( "SRC_ROOT" );
+    const wchar_t* pSrcRoot = _wgetenv(L"SRC_ROOT");
     if (pSrcRoot)
     {
         documentName.append(pSrcRoot);
-        documentName.append("/");
+        documentName.append(L"/");
     }
-    documentName.append("shell/qa/zip/simpledocument.odt");
+    documentName.append(L"shell/qa/zip/simpledocument.odt");
 
     // Create an IStream pointer from the file
-    HANDLE hFile = CreateFileA(documentName.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, 0, nullptr);
+    HANDLE hFile = CreateFileW(documentName.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, 0, nullptr);
 
     DWORD dwFileSize = GetFileSize(hFile, nullptr);
     HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
diff --git a/shell/source/backends/localebe/localebackend.cxx b/shell/source/backends/localebe/localebackend.cxx
index ff9b81b406b6..0b896a3fadc6 100644
--- a/shell/source/backends/localebe/localebackend.cxx
+++ b/shell/source/backends/localebe/localebackend.cxx
@@ -44,17 +44,17 @@
 
 css::beans::Optional<css::uno::Any> ImplGetLocale(LCID lcid)
 {
-    CHAR buffer[8];
-    PSTR cp = buffer;
+    WCHAR buffer[8];
+    PWSTR cp = buffer;
 
-    cp += GetLocaleInfoA( lcid, LOCALE_SISO639LANGNAME , buffer, 4 );
+    cp += GetLocaleInfoW( lcid, LOCALE_SISO639LANGNAME, buffer, 4 );
     if( cp > buffer )
     {
-        if( 0 < GetLocaleInfoA( lcid, LOCALE_SISO3166CTRYNAME, cp, buffer + 8 - cp) )
+        if( 0 < GetLocaleInfoW( lcid, LOCALE_SISO3166CTRYNAME, cp, buffer + 8 - cp) )
             // #i50822# minus character must be written before cp
             *(cp - 1) = '-';
 
-        return {true, css::uno::Any(OUString::createFromAscii(buffer))};
+        return {true, css::uno::Any(OUString(SAL_U(buffer)))};
     }
 
     return {false, {}};
diff --git a/shell/source/backends/wininetbe/wininetbackend.cxx b/shell/source/backends/wininetbe/wininetbackend.cxx
index 9f4f2d8f9556..56b85de4befc 100644
--- a/shell/source/backends/wininetbe/wininetbackend.cxx
+++ b/shell/source/backends/wininetbe/wininetbackend.cxx
@@ -35,7 +35,7 @@
 #pragma warning(pop)
 #endif
 
-#define WININET_DLL_NAME "wininet.dll"
+#define WININET_DLL_NAME L"wininet.dll"
 #define EQUAL_SIGN '='
 #define COLON      ':'
 #define SPACE      ' '
@@ -102,14 +102,14 @@ namespace
 
 WinInetBackend::WinInetBackend()
 {
-    Library hWinInetDll( LoadLibrary( WININET_DLL_NAME ) );
+    Library hWinInetDll( LoadLibraryW( WININET_DLL_NAME ) );
     if( hWinInetDll.module )
     {
         typedef BOOL ( WINAPI *InternetQueryOption_Proc_T )( HINTERNET, DWORD, LPVOID, LPDWORD );
 
         InternetQueryOption_Proc_T lpfnInternetQueryOption =
             reinterpret_cast< InternetQueryOption_Proc_T >(
-                GetProcAddress( hWinInetDll.module, "InternetQueryOptionA" ) );
+                GetProcAddress( hWinInetDll.module, "InternetQueryOptionW" ) );
         if (lpfnInternetQueryOption)
         {
             // Some Windows versions would fail the InternetQueryOption call
@@ -120,7 +120,7 @@ WinInetBackend::WinInetBackend()
             // reallocation:
             INTERNET_PROXY_INFO pi;
             LPINTERNET_PROXY_INFO lpi = π
-            DWORD dwLength = sizeof (INTERNET_PROXY_INFO);
+            DWORD dwLength = sizeof (pi);
             BOOL ok = lpfnInternetQueryOption(
                 nullptr,
                 INTERNET_OPTION_PROXY,
@@ -165,8 +165,10 @@ WinInetBackend::WinInetBackend()
             // an empty proxy list, so we don't have to check if
             // proxy is enabled or not
 
-            OUString aProxyList       = OUString::createFromAscii( lpi->lpszProxy );
-            OUString aProxyBypassList = OUString::createFromAscii( lpi->lpszProxyBypass );
+            // We use a W-version of InternetQueryOption; it returns struct with pointers to wide strings
+            // There's no INTERNET_PROXY_INFOW, so we simply cast returned struct's members
+            OUString aProxyList       = reinterpret_cast<const sal_Unicode*>( lpi->lpszProxy );
+            OUString aProxyBypassList = reinterpret_cast<const sal_Unicode*>( lpi->lpszProxyBypass );
 
             // override default for ProxyType, which is "0" meaning "No proxies".
             valueProxyType_.IsPresent = true;
diff --git a/shell/source/tools/regsvrex/regsvrex.cxx b/shell/source/tools/regsvrex/regsvrex.cxx
index 0add6ae1788e..032267f4dcfc 100644
--- a/shell/source/tools/regsvrex/regsvrex.cxx
+++ b/shell/source/tools/regsvrex/regsvrex.cxx
@@ -30,19 +30,19 @@
 typedef HRESULT (__stdcall *lpfnDllRegisterServer)();
 typedef HRESULT (__stdcall *lpfnDllUnregisterServer)();
 
-bool IsUnregisterParameter(const char* Param)
+bool IsUnregisterParameter(const wchar_t* Param)
 {
-    return ((0 == _stricmp(Param, "/u")) ||
-            (0 == _stricmp(Param, "-u")));
+    return ((0 == _wcsicmp(Param, L"/u")) ||
+            (0 == _wcsicmp(Param, L"-u")));
 }
 
-int main(int argc, char* argv[])
+int wmain(int argc, wchar_t* argv[])
 {
     HMODULE hmod;
 
     if (2 == argc)
     {
-        hmod = LoadLibraryA(argv[1]);
+        hmod = LoadLibraryW(argv[1]);
 
         if (hmod)
         {
@@ -57,7 +57,7 @@ int main(int argc, char* argv[])
     }
     else if (3 == argc && IsUnregisterParameter(argv[1]))
     {
-        hmod = LoadLibraryA(argv[2]);
+        hmod = LoadLibraryW(argv[2]);
 
         if (hmod)
         {
diff --git a/shell/source/win32/SysShExec.cxx b/shell/source/win32/SysShExec.cxx
index 15f063d0d23c..3b569ed7c7c1 100644
--- a/shell/source/win32/SysShExec.cxx
+++ b/shell/source/win32/SysShExec.cxx
@@ -297,8 +297,8 @@ void SAL_CALL CSysShExec::execute( const OUString& aCommand, const OUString& aPa
     ZeroMemory(&sei, sizeof( sei));
 
     sei.cbSize       = sizeof(sei);
-    sei.lpFile       = reinterpret_cast<LPCWSTR>(preprocessed_command.getStr());
-    sei.lpParameters = reinterpret_cast<LPCWSTR>(aParameter.getStr());
+    sei.lpFile       = SAL_W(preprocessed_command.getStr());
+    sei.lpParameters = SAL_W(aParameter.getStr());
     sei.nShow        = SW_SHOWNORMAL;
 
     if (NO_SYSTEM_ERROR_MESSAGE & nFlags)
diff --git a/shell/source/win32/ooofilereader/basereader.cxx b/shell/source/win32/ooofilereader/basereader.cxx
index 9b05cc5a7c99..e4a64e3384c0 100644
--- a/shell/source/win32/ooofilereader/basereader.cxx
+++ b/shell/source/win32/ooofilereader/basereader.cxx
@@ -26,7 +26,7 @@
 
 /**  constructor of CBaseReader.
 */
-CBaseReader::CBaseReader(const std::string& DocumentName):
+CBaseReader::CBaseReader(const std::wstring& DocumentName):
 m_ZipFile( DocumentName )
 {
 }
diff --git a/shell/source/win32/ooofilereader/contentreader.cxx b/shell/source/win32/ooofilereader/contentreader.cxx
index 1ecaf60a9c18..68781097dada 100644
--- a/shell/source/win32/ooofilereader/contentreader.cxx
+++ b/shell/source/win32/ooofilereader/contentreader.cxx
@@ -26,7 +26,7 @@
 
 /** constructor.
 */
-CContentReader::CContentReader( const std::string& DocumentName, LocaleSet_t const & DocumentLocale ):
+CContentReader::CContentReader( const std::wstring& DocumentName, LocaleSet_t const & DocumentLocale ):
 CBaseReader( DocumentName )
 {
     try
diff --git a/shell/source/win32/ooofilereader/metainforeader.cxx b/shell/source/win32/ooofilereader/metainforeader.cxx
index 2b523d6e9aaf..afdf3418fd07 100644
--- a/shell/source/win32/ooofilereader/metainforeader.cxx
+++ b/shell/source/win32/ooofilereader/metainforeader.cxx
@@ -26,7 +26,7 @@
 
 /** constructor.
 */
-CMetaInfoReader::CMetaInfoReader( const std::string& DocumentName ):
+CMetaInfoReader::CMetaInfoReader( const std::wstring& DocumentName ):
 CBaseReader( DocumentName )
 {
     try
diff --git a/shell/source/win32/shlxthandler/columninfo/columninfo.cxx b/shell/source/win32/shlxthandler/columninfo/columninfo.cxx
index 7f91a1f01c6f..933d695f98fe 100644
--- a/shell/source/win32/shlxthandler/columninfo/columninfo.cxx
+++ b/shell/source/win32/shlxthandler/columninfo/columninfo.cxx
@@ -45,7 +45,7 @@ bool IsOOFileExtension(wchar_t const * Extension)
 {
     for (size_t i = 0; i < OOFileExtensionTableSize; i++)
     {
-        if (0 == _wcsicmp(Extension, OOFileExtensionTable[i].ExtensionUnicode))
+        if (0 == _wcsicmp(Extension, OOFileExtensionTable[i].ExtensionU))
             return true;
     }
 
@@ -139,7 +139,7 @@ HRESULT STDMETHODCALLTYPE CColumnInfo::GetItemData(LPCSHCOLUMNID pscid, LPCSHCOL
         {
             std::wstring fname = getShortPathName( std::wstring( pscd->wszFile ) );
 
-            CMetaInfoReader meta_info_accessor(WStringToString(fname));
+            CMetaInfoReader meta_info_accessor(fname);
 
             VariantClear(pvarData);
 
diff --git a/shell/source/win32/shlxthandler/infotips/infotips.cxx b/shell/source/win32/shlxthandler/infotips/infotips.cxx
index 7985cb19bc25..c15f9723deb7 100644
--- a/shell/source/win32/shlxthandler/infotips/infotips.cxx
+++ b/shell/source/win32/shlxthandler/infotips/infotips.cxx
@@ -101,23 +101,23 @@ ULONG STDMETHODCALLTYPE CInfoTip::Release()
 
 /** get file type information from registry.
 */
-std::wstring getFileTypeInfo(const std::string& file_extension)
+std::wstring getFileTypeInfo(const std::wstring& file_extension)
 {
-    char extKeyValue[MAX_STRING];
-    char typeKeyValue[MAX_STRING];
-    ::std::string sDot(".");
-    if (QueryRegistryKey(HKEY_CLASSES_ROOT, (sDot.append(file_extension)).c_str(), "", extKeyValue, MAX_STRING))
-        if (QueryRegistryKey( HKEY_CLASSES_ROOT, extKeyValue, "",typeKeyValue, MAX_STRING))
-            return StringToWString(typeKeyValue);
+    wchar_t extKeyValue[MAX_STRING];
+    wchar_t typeKeyValue[MAX_STRING];
+    ::std::wstring sDot(L".");
+    if (QueryRegistryKey(HKEY_CLASSES_ROOT, (sDot.append(file_extension)).c_str(), L"", extKeyValue, MAX_STRING))
+        if (QueryRegistryKey( HKEY_CLASSES_ROOT, extKeyValue, L"",typeKeyValue, MAX_STRING))
+            return typeKeyValue;
 
     return EMPTY_STRING;
 }
 
 /** get file size.
 */
-DWORD getSizeOfFile( char const * FileName )
+DWORD getSizeOfFile( wchar_t const * FileName )
 {
-    HANDLE hFile = CreateFile(StringToWString(FileName).c_str(),            // open file
+    HANDLE hFile = CreateFileW(FileName,                                    // open file
                         GENERIC_READ,                                       // open for reading
                         FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, // share for all operations
                         nullptr,                                            // no security
@@ -178,7 +178,7 @@ std::wstring formatSizeOfFile( DWORD dwSize )
 
 /** get file size information.
 */
-std::wstring getFileSizeInfo(char const * FileName)
+std::wstring getFileSizeInfo(wchar_t const * FileName)
 {
     DWORD dwSize=getSizeOfFile(FileName);
     if (dwSize != INVALID_FILE_SIZE)
@@ -329,13 +329,11 @@ HRESULT STDMETHODCALLTYPE CInfoTip::Load(LPCOLESTR pszFileName, DWORD /*dwMode*/
 
     fname = getShortPathName( fname );
 
-    std::string fnameA = WStringToString(fname);
-
     // ZeroMemory because strncpy doesn't '\0'-terminates the destination
     // string; reserve the last place in the buffer for the final '\0'
     // that's why '(sizeof(m_szFileName) - 1)'
     ZeroMemory(m_szFileName, sizeof(m_szFileName));
-    strncpy(m_szFileName, fnameA.c_str(), (sizeof(m_szFileName) - 1));
+    wcsncpy(m_szFileName, fname.c_str(), (sizeof(m_szFileName)/sizeof(*m_szFileName) - 1));
 
     return S_OK;
 }
diff --git a/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx b/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx
index c1df310962cc..f74473b5e3f4 100644
--- a/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx
+++ b/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx
@@ -571,10 +571,10 @@ SCODE STDMETHODCALLTYPE COooFilter::Load(LPCWSTR pszFileName, DWORD /*dwMode*/)
     try
     {
         delete m_pMetaInfoReader;
-        m_pMetaInfoReader = new CMetaInfoReader(WStringToString(m_pwszFileName));
+        m_pMetaInfoReader = new CMetaInfoReader(m_pwszFileName);
 
         delete m_pContentReader;
-        m_pContentReader = new CContentReader(WStringToString(m_pwszFileName), m_pMetaInfoReader->getDefaultLocale());
+        m_pContentReader = new CContentReader(m_pwszFileName, m_pMetaInfoReader->getDefaultLocale());
     }
     catch (const std::exception&)
     {
diff --git a/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx b/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx
index 5d8e67c58b0f..133dcd1d8008 100644
--- a/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx
+++ b/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx
@@ -106,11 +106,11 @@ long BufferStream::sseek (long offset, int origin)
         return -1;
 }
 
-FileStream::FileStream(const char *filename) :
+FileStream::FileStream(const wchar_t *filename) :
     file(nullptr)
 {
     // fdo#67534: avoid locking to not interfere with soffice opening the file
-    file = _fsopen(filename, "rb", _SH_DENYNO);
+    file = _wfsopen(filename, L"rb", _SH_DENYNO);
 }
 
 FileStream::~FileStream()
diff --git a/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx
index 340985a0f239..41b100413f14 100644
--- a/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx
+++ b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx
@@ -63,7 +63,7 @@ CPropertyHdl::CPropertyHdl( long nRefCnt ) :
     m_RefCnt( nRefCnt ),
     m_pCache( nullptr )
 {
-    OutputDebugStringFormatA( "CPropertyHdl: CTOR\n" );
+    OutputDebugStringFormatW( L"CPropertyHdl: CTOR\n" );
     InterlockedIncrement( &g_DllRefCnt );
 }
 
@@ -87,7 +87,7 @@ HRESULT STDMETHODCALLTYPE CPropertyHdl::QueryInterface(REFIID riid, void __RPC_F
 
     if (IID_IUnknown == riid || IID_IPropertyStore == riid)
     {
-        OutputDebugStringFormatA( "CPropertyHdl: QueryInterface (IID_IPropertyStore)\n" );
+        OutputDebugStringFormatW( L"CPropertyHdl: QueryInterface (IID_IPropertyStore)\n" );
         IUnknown* pUnk = static_cast<IPropertyStore*>(this);
         pUnk->AddRef();
         *ppvObject = pUnk;
@@ -95,7 +95,7 @@ HRESULT STDMETHODCALLTYPE CPropertyHdl::QueryInterface(REFIID riid, void __RPC_F
     }
     else if (IID_IPropertyStoreCapabilities == riid)
     {
-        OutputDebugStringFormatA( "CPropertyHdl: QueryInterface (IID_IPropertyStoreCapabilities)\n" );
+        OutputDebugStringFormatW( L"CPropertyHdl: QueryInterface (IID_IPropertyStoreCapabilities)\n" );
         IUnknown* pUnk = static_cast<IPropertyStore*>(this);
         pUnk->AddRef();
         *ppvObject = pUnk;
@@ -103,13 +103,13 @@ HRESULT STDMETHODCALLTYPE CPropertyHdl::QueryInterface(REFIID riid, void __RPC_F
     }
     else if (IID_IInitializeWithStream == riid)
     {
-        OutputDebugStringFormatA( "CPropertyHdl: QueryInterface (IID_IInitializeWithStream)\n" );
+        OutputDebugStringFormatW( L"CPropertyHdl: QueryInterface (IID_IInitializeWithStream)\n" );
         IUnknown* pUnk = static_cast<IInitializeWithStream*>(this);
         pUnk->AddRef();
         *ppvObject = pUnk;
         return S_OK;
     }
-    OutputDebugStringFormatA( "CPropertyHdl: QueryInterface (something different)\n" );
+    OutputDebugStringFormatW( L"CPropertyHdl: QueryInterface (something different)\n" );
 
     return E_NOINTERFACE;
 }
@@ -208,7 +208,7 @@ HRESULT STDMETHODCALLTYPE CPropertyHdl::Initialize( IStream *pStream, DWORD grfM
     if ( !m_pCache )
     {
         if ( FAILED( PSCreateMemoryPropertyStore( IID_PPV_ARGS( &m_pCache ) ) ) )
-            OutputDebugStringFormatA( "CPropertyHdl::Initialize: PSCreateMemoryPropertyStore failed" );
+            OutputDebugStringFormatW( L"CPropertyHdl::Initialize: PSCreateMemoryPropertyStore failed" );
 
         BufferStream tmpStream(pStream);
 
@@ -222,7 +222,9 @@ HRESULT STDMETHODCALLTYPE CPropertyHdl::Initialize( IStream *pStream, DWORD grfM
         }
         catch (const std::exception& e)
         {
-            OutputDebugStringFormatA( "CPropertyHdl::Initialize: Caught exception [%s]", e.what() );
+            // To output 8-bit string using unicode version of formatting functions, use capital %S type
+            // see https://msdn.microsoft.com/en-us/library/hf4y5e3w
+            OutputDebugStringFormatW( L"CPropertyHdl::Initialize: Caught exception [%S]", e.what() );
             return E_FAIL;
         }
     }
@@ -238,37 +240,37 @@ HRESULT GetItemData( CMetaInfoReader *pMetaInfoReader, UINT nIndex, PROPVARIANT
     case 0: {
             pVarData->vt = VT_BSTR;
             pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_TITLE ).c_str() );
-            OutputDebugStringFormatA( "CPropertyHdl::GetItemData: Title=%S.\n", pMetaInfoReader->getTagData( META_INFO_TITLE ).c_str() );
+            OutputDebugStringFormatW( L"CPropertyHdl::GetItemData: Title=%s.\n", pMetaInfoReader->getTagData( META_INFO_TITLE ).c_str() );
             return S_OK;
     }
     case 1: {
             pVarData->vt = VT_BSTR;
             pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_AUTHOR ).c_str() );
-            OutputDebugStringFormatA( "CPropertyHdl::GetItemData: Author=%S.\n", pMetaInfoReader->getTagData( META_INFO_AUTHOR ).c_str() );
+            OutputDebugStringFormatW( L"CPropertyHdl::GetItemData: Author=%s.\n", pMetaInfoReader->getTagData( META_INFO_AUTHOR ).c_str() );
             return S_OK;
     }
     case 2: {
             pVarData->vt = VT_BSTR;
             pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_SUBJECT ).c_str() );
-            OutputDebugStringFormatA( "CPropertyHdl::GetItemData: Subject=%S.\n", pMetaInfoReader->getTagData( META_INFO_SUBJECT ).c_str() );
+            OutputDebugStringFormatW( L"CPropertyHdl::GetItemData: Subject=%s.\n", pMetaInfoReader->getTagData( META_INFO_SUBJECT ).c_str() );
             return S_OK;
     }
     case 3: {
             pVarData->vt = VT_BSTR;
             pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_KEYWORDS ).c_str() );
-            OutputDebugStringFormatA( "CPropertyHdl::GetItemData: Keywords=%S.\n", pMetaInfoReader->getTagData( META_INFO_KEYWORDS ).c_str() );
+            OutputDebugStringFormatW( L"CPropertyHdl::GetItemData: Keywords=%s.\n", pMetaInfoReader->getTagData( META_INFO_KEYWORDS ).c_str() );
             return S_OK;
     }
     case 4: {
             pVarData->vt = VT_BSTR;
             pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_DESCRIPTION ).c_str() );
-            OutputDebugStringFormatA( "CPropertyHdl::GetItemData: Description=%S.\n", pMetaInfoReader->getTagData( META_INFO_DESCRIPTION ).c_str() );
+            OutputDebugStringFormatW( L"CPropertyHdl::GetItemData: Description=%s.\n", pMetaInfoReader->getTagData( META_INFO_DESCRIPTION ).c_str() );
             return S_OK;
     }
     case 5: {
             pVarData->vt = VT_BSTR;
             pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagAttribute( META_INFO_DOCUMENT_STATISTIC, META_INFO_PAGES ).c_str() );
-            OutputDebugStringFormatA( "CPropertyHdl::GetItemData: Pages=%S.\n", pMetaInfoReader->getTagAttribute( META_INFO_DOCUMENT_STATISTIC, META_INFO_PAGES ).c_str() );
+            OutputDebugStringFormatW( L"CPropertyHdl::GetItemData: Pages=%s.\n", pMetaInfoReader->getTagAttribute( META_INFO_DOCUMENT_STATISTIC, META_INFO_PAGES ).c_str() );
             return S_OK;
     }
     }
@@ -280,7 +282,7 @@ HRESULT GetItemData( CMetaInfoReader *pMetaInfoReader, UINT nIndex, PROPVARIANT
 
 void CPropertyHdl::LoadProperties( CMetaInfoReader *pMetaInfoReader )
 {
-    OutputDebugStringFormatA( "CPropertyHdl: LoadProperties\n" );
+    OutputDebugStringFormatW( L"CPropertyHdl: LoadProperties\n" );
     PROPVARIANT propvarValues;
 
     for ( UINT i = 0; i < (UINT)gPropertyMapTableSize; ++i )
@@ -403,7 +405,7 @@ bool CClassFactory::IsLocked()
 
 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void** ppv)
 {
-    OutputDebugStringFormatA( "DllGetClassObject.\n" );
+    OutputDebugStringFormatW( L"DllGetClassObject.\n" );
     *ppv = nullptr;
 
     if ( rclsid != CLSID_PROPERTY_HANDLER )
@@ -420,7 +422,7 @@ STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void** ppv)
 
 STDAPI DllCanUnloadNow()
 {
-    OutputDebugStringFormatA( "DllCanUnloadNow.\n" );
+    OutputDebugStringFormatW( L"DllCanUnloadNow.\n" );
     if (CClassFactory::IsLocked() || g_DllRefCnt > 0)
         return S_FALSE;
 
@@ -430,7 +432,7 @@ STDAPI DllCanUnloadNow()
 
 BOOL WINAPI DllMain( HINSTANCE hInst, ULONG /*ul_reason_for_call*/, LPVOID /*lpReserved*/ )
 {
-    OutputDebugStringFormatA( "DllMain.\n" );
+    OutputDebugStringFormatW( L"DllMain.\n" );
     g_hModule = hInst;
     return TRUE;
 }
diff --git a/shell/source/win32/shlxthandler/propsheets/document_statistic.cxx b/shell/source/win32/shlxthandler/propsheets/document_statistic.cxx
index 668f253a757a..ce1b74565393 100644
--- a/shell/source/win32/shlxthandler/propsheets/document_statistic.cxx
+++ b/shell/source/win32/shlxthandler/propsheets/document_statistic.cxx
@@ -31,7 +31,7 @@
 
 const bool READONLY  = false;
 
-document_statistic_reader_ptr create_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor)
+document_statistic_reader_ptr create_document_statistic_reader(const std::wstring& document_name, CMetaInfoReader* meta_info_accessor)
 {
     File_Type_t file_type = get_file_type(document_name);
 
@@ -44,7 +44,7 @@ document_statistic_reader_ptr create_document_statistic_reader(const std::string
 }
 
 
-document_statistic_reader::document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
+document_statistic_reader::document_statistic_reader(const std::wstring& document_name, CMetaInfoReader* meta_info_accessor) :
     document_name_(document_name),
     meta_info_accessor_(meta_info_accessor)
 {}
@@ -59,7 +59,7 @@ void document_statistic_reader::read(statistic_group_list_t* group_list)
     fill_origin_section(meta_info_accessor_, group_list);
 }
 
-std::string document_statistic_reader::get_document_name() const
+std::wstring document_statistic_reader::get_document_name() const
 {
     return document_name_;
 }
@@ -81,7 +81,7 @@ void document_statistic_reader::fill_origin_section(CMetaInfoReader *meta_info_a
     group_list->push_back(statistic_group_t(GetResString(IDS_ORIGIN), il));
 }
 
-writer_document_statistic_reader::writer_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
+writer_document_statistic_reader::writer_document_statistic_reader(const std::wstring& document_name, CMetaInfoReader* meta_info_accessor) :
     document_statistic_reader(document_name, meta_info_accessor)
 {}
 
@@ -105,7 +105,7 @@ void writer_document_statistic_reader::fill_description_section(CMetaInfoReader
 }
 
 calc_document_statistic_reader::calc_document_statistic_reader(
-    const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
+    const std::wstring& document_name, CMetaInfoReader* meta_info_accessor) :
     document_statistic_reader(document_name, meta_info_accessor)
 {}
 
@@ -126,7 +126,7 @@ void calc_document_statistic_reader::fill_description_section(
 }
 
 draw_impress_math_document_statistic_reader::draw_impress_math_document_statistic_reader(
-    const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
+    const std::wstring& document_name, CMetaInfoReader* meta_info_accessor) :
     document_statistic_reader(document_name, meta_info_accessor)
 {}
 
diff --git a/shell/source/win32/shlxthandler/propsheets/document_statistic.hxx b/shell/source/win32/shlxthandler/propsheets/document_statistic.hxx
index 93967a253668..424dbe4c4649 100644
--- a/shell/source/win32/shlxthandler/propsheets/document_statistic.hxx
+++ b/shell/source/win32/shlxthandler/propsheets/document_statistic.hxx
@@ -54,7 +54,7 @@ typedef std::vector<statistic_group_t>                  statistic_group_list_t;
 class document_statistic_reader;
 typedef std::unique_ptr<document_statistic_reader> document_statistic_reader_ptr;
 
-document_statistic_reader_ptr create_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+document_statistic_reader_ptr create_document_statistic_reader(const std::wstring& document_name, CMetaInfoReader* meta_info_accessor);
 
 
 class document_statistic_reader
@@ -64,57 +64,57 @@ public:
 
     void read(statistic_group_list_t* group_list);
 
-    std::string get_document_name() const;
+    std::wstring get_document_name() const;
 
 protected:
-    document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+    document_statistic_reader(const std::wstring& document_name, CMetaInfoReader* meta_info_accessor);
 
     virtual void fill_description_section(CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list) = 0;
 
     virtual void fill_origin_section( CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list);
 
 private:
-    std::string document_name_;
+    std::wstring document_name_;
     CMetaInfoReader* meta_info_accessor_;
 
     friend document_statistic_reader_ptr create_document_statistic_reader(
-        const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+        const std::wstring& document_name, CMetaInfoReader* meta_info_accessor);
 };
 
 
 class writer_document_statistic_reader : public document_statistic_reader
 {
 protected:
-    writer_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+    writer_document_statistic_reader(const std::wstring& document_name, CMetaInfoReader* meta_info_accessor);
 
     virtual void fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list) override;
 
     friend document_statistic_reader_ptr create_document_statistic_reader(
-        const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+        const std::wstring& document_name, CMetaInfoReader* meta_info_accessor);
 };
 
 
 class calc_document_statistic_reader : public document_statistic_reader
 {
 protected:
-    calc_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+    calc_document_statistic_reader(const std::wstring& document_name, CMetaInfoReader* meta_info_accessor);
 
     virtual void fill_description_section( CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list) override;
 
     friend document_statistic_reader_ptr create_document_statistic_reader(
-        const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+        const std::wstring& document_name, CMetaInfoReader* meta_info_accessor);
 };
 
 
 class draw_impress_math_document_statistic_reader : public document_statistic_reader
 {
 protected:
-    draw_impress_math_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+    draw_impress_math_document_statistic_reader(const std::wstring& document_name, CMetaInfoReader* meta_info_accessor);
 
     virtual void fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list) override;
 
     friend document_statistic_reader_ptr create_document_statistic_reader(
-        const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+        const std::wstring& document_name, CMetaInfoReader* meta_info_accessor);
 };
 
 #endif
diff --git a/shell/source/win32/shlxthandler/propsheets/propsheets.cxx b/shell/source/win32/shlxthandler/propsheets/propsheets.cxx
index a6802ff787ad..4c9fff083d14 100644
--- a/shell/source/win32/shlxthandler/propsheets/propsheets.cxx
+++ b/shell/source/win32/shlxthandler/propsheets/propsheets.cxx
@@ -57,14 +57,14 @@
 CPropertySheet::CPropertySheet(long RefCnt) :
     m_RefCnt(RefCnt)
 {
-    OutputDebugStringFormatA("CPropertySheet::CTor [%d], [%d]", m_RefCnt, g_DllRefCnt );
+    OutputDebugStringFormatW(L"CPropertySheet::CTor [%d], [%d]", m_RefCnt, g_DllRefCnt );
     InterlockedIncrement(&g_DllRefCnt);
 }
 
 
 CPropertySheet::~CPropertySheet()
 {
-    OutputDebugStringFormatA("CPropertySheet::DTor [%d], [%d]", m_RefCnt, g_DllRefCnt );
+    OutputDebugStringFormatW(L"CPropertySheet::DTor [%d], [%d]", m_RefCnt, g_DllRefCnt );
     InterlockedDecrement(&g_DllRefCnt);
 }
 
@@ -99,14 +99,14 @@ HRESULT STDMETHODCALLTYPE CPropertySheet::QueryInterface(
 
 ULONG STDMETHODCALLTYPE CPropertySheet::AddRef()
 {
-    OutputDebugStringFormatA("CPropertySheet::AddRef [%d]", m_RefCnt );
+    OutputDebugStringFormatW(L"CPropertySheet::AddRef [%d]", m_RefCnt );
     return InterlockedIncrement(&m_RefCnt);
 }
 
 
 ULONG STDMETHODCALLTYPE CPropertySheet::Release()
 {
-    OutputDebugStringFormatA("CPropertySheet::Release [%d]", m_RefCnt );
+    OutputDebugStringFormatW(L"CPropertySheet::Release [%d]", m_RefCnt );
     long refcnt = InterlockedDecrement(&m_RefCnt);
 
     if (0 == refcnt)
@@ -131,7 +131,7 @@ HRESULT STDMETHODCALLTYPE CPropertySheet::Initialize(
 
     // save the file name
     if (SUCCEEDED(hr) &&
-        (1 == DragQueryFileA(
+        (1 == DragQueryFileW(
             static_cast<HDROP>(medium.hGlobal),
             0xFFFFFFFF,
             nullptr,
@@ -146,9 +146,8 @@ HRESULT STDMETHODCALLTYPE CPropertySheet::Initialize(
             if ( result_size != 0 )
             {
                 std::wstring fname = getShortPathName( buffer.get() );
-                std::string fnameA = WStringToString( fname );
                 ZeroMemory( m_szFileName, sizeof( m_szFileName ) );
-                strncpy( m_szFileName, fnameA.c_str(), ( sizeof( m_szFileName ) - 1 ) );
+                wcsncpy( m_szFileName, fname.c_str(), ( SAL_N_ELEMENTS( m_szFileName ) - 1 ) );
                 hr = S_OK;
             }
             else
@@ -176,11 +175,11 @@ HRESULT STDMETHODCALLTYPE CPropertySheet::AddPages(LPFNADDPROPSHEETPAGE lpfnAddP
     bool bIsVistaOrLater = IsWindowsVistaOrGreater();
 #else
     // Get OS version (we don't need the summary page on Windows Vista or later)
-    OSVERSIONINFO sInfoOS;
+    OSVERSIONINFOW sInfoOS;
 
-    ZeroMemory( &sInfoOS, sizeof(OSVERSIONINFO) );
-    sInfoOS.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
-    GetVersionEx( &sInfoOS );
+    ZeroMemory( &sInfoOS, sizeof(sInfoOS) );
+    sInfoOS.dwOSVersionInfoSize = sizeof( sInfoOS );
+    GetVersionExW( &sInfoOS );
     bool bIsVistaOrLater = (sInfoOS.dwMajorVersion >= 6);
 #endif
 
@@ -303,10 +302,10 @@ void CPropertySheet::InitPropPageSummary(HWND hwnd, LPPROPSHEETPAGE /*lppsp*/)
     {
         CMetaInfoReader metaInfo(m_szFileName);
 
-        SetWindowText(GetDlgItem(hwnd,IDC_TITLE),    metaInfo.getTagData( META_INFO_TITLE ).c_str() );
-        SetWindowText(GetDlgItem(hwnd,IDC_AUTHOR),   metaInfo.getTagData( META_INFO_AUTHOR ).c_str() );
-        SetWindowText(GetDlgItem(hwnd,IDC_SUBJECT),  metaInfo.getTagData( META_INFO_SUBJECT ).c_str() );
-        SetWindowText(GetDlgItem(hwnd,IDC_KEYWORDS), metaInfo.getTagData( META_INFO_KEYWORDS ).c_str() );
+        SetWindowTextW(GetDlgItem(hwnd,IDC_TITLE),    metaInfo.getTagData( META_INFO_TITLE ).c_str() );
+        SetWindowTextW(GetDlgItem(hwnd,IDC_AUTHOR),   metaInfo.getTagData( META_INFO_AUTHOR ).c_str() );
+        SetWindowTextW(GetDlgItem(hwnd,IDC_SUBJECT),  metaInfo.getTagData( META_INFO_SUBJECT ).c_str() );
+        SetWindowTextW(GetDlgItem(hwnd,IDC_KEYWORDS), metaInfo.getTagData( META_INFO_KEYWORDS ).c_str() );
 
         // comments read from meta.xml use "\n" for return, but this will not displayable in Edit control, add
         // "\r" before "\n" to form "\r\n" in order to display return in Edit control.
@@ -317,7 +316,7 @@ void CPropertySheet::InitPropPageSummary(HWND hwnd, LPPROPSHEETPAGE /*lppsp*/)
             tempStr.insert(itor, L"\r");
             itor = tempStr.find(L"\n", itor + 2);
         }
-        SetWindowText(GetDlgItem(hwnd,IDC_COMMENTS), tempStr.c_str());
+        SetWindowTextW(GetDlgItem(hwnd,IDC_COMMENTS), tempStr.c_str());
     }
     catch (const std::exception&)
     {
diff --git a/shell/source/win32/shlxthandler/shlxthdl.cxx b/shell/source/win32/shlxthandler/shlxthdl.cxx
index ff8b83670904..47d93d054c25 100644
--- a/shell/source/win32/shlxthandler/shlxthdl.cxx
+++ b/shell/source/win32/shlxthandler/shlxthdl.cxx
@@ -36,29 +36,29 @@ HINSTANCE g_hModule = nullptr;
 
 namespace /* private */
 {
-    const char* const GUID_PLACEHOLDER       = "{GUID}";
-    const char* const EXTENSION_PLACEHOLDER  = "{EXT}";
-    const char* const FORWARDKEY_PLACEHOLDER = "{FWDKEY}";
+    const wchar_t* const GUID_PLACEHOLDER       = L"{GUID}";
+    const wchar_t* const EXTENSION_PLACEHOLDER  = L"{EXT}";
+    const wchar_t* const FORWARDKEY_PLACEHOLDER = L"{FWDKEY}";
 
-    const char* const CLSID_ENTRY                         = "CLSID\\{GUID}\\InProcServer32";
-    const char* const SHELLEX_IID_ENTRY                   = "{EXT}\\shellex\\{GUID}";
-    const char* const SHELLEX_ENTRY                       = "{EXT}\\shellex";
-    const char* const FORWARD_PROPSHEET_MYPROPSHEET_ENTRY = "{FWDKEY}\\shellex\\PropertySheetHandlers\\MyPropSheet1";
-    const char* const FORWARD_PROPSHEET_ENTRY             = "{FWDKEY}\\shellex\\PropertySheetHandlers";
-    const char* const FORWARD_SHELLEX_ENTRY               = "{FWDKEY}\\shellex";
+    const wchar_t* const CLSID_ENTRY                         = L"CLSID\\{GUID}\\InProcServer32";
+    const wchar_t* const SHELLEX_IID_ENTRY                   = L"{EXT}\\shellex\\{GUID}";
+    const wchar_t* const SHELLEX_ENTRY                       = L"{EXT}\\shellex";
+    const wchar_t* const FORWARD_PROPSHEET_MYPROPSHEET_ENTRY = L"{FWDKEY}\\shellex\\PropertySheetHandlers\\MyPropSheet1";
+    const wchar_t* const FORWARD_PROPSHEET_ENTRY             = L"{FWDKEY}\\shellex\\PropertySheetHandlers";
+    const wchar_t* const FORWARD_SHELLEX_ENTRY               = L"{FWDKEY}\\shellex";
 
-    const char* const SHELL_EXTENSION_APPROVED_KEY_NAME   = "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved";
+    const wchar_t* const SHELL_EXTENSION_APPROVED_KEY_NAME   = L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved";
 
 
     // "String Placeholder" ->
     // "String Replacement"
 
-    void SubstitutePlaceholder(std::string& String, const std::string& Placeholder, const std::string& Replacement)
+    void SubstitutePlaceholder(std::wstring& String, const std::wstring& Placeholder, const std::wstring& Replacement)
     {
-        std::string::size_type idx = String.find(Placeholder);
-        std::string::size_type len = Placeholder.length();
+        std::wstring::size_type idx = String.find(Placeholder);
+        std::wstring::size_type len = Placeholder.length();
 
-        while (std::string::npos != idx)
+        while (std::wstring::npos != idx)
         {
             String.replace(idx, len, Replacement);
             idx = String.find(Placeholder);
@@ -70,15 +70,15 @@ namespace /* private */
             InProcServer32 = Path\shlxthdl.dll
                 ThreadingModel = Apartment
     */
-    HRESULT RegisterComComponent(const char* FilePath, const CLSID& Guid)
+    HRESULT RegisterComComponent(const wchar_t* FilePath, const CLSID& Guid)
     {
-        std::string ClsidEntry = CLSID_ENTRY;
+        std::wstring ClsidEntry = CLSID_ENTRY;
         SubstitutePlaceholder(ClsidEntry, GUID_PLACEHOLDER, ClsidToString(Guid));
 
-        if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry.c_str(), "", FilePath))
+        if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry.c_str(), L"", FilePath))
             return E_FAIL;
 
-        if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry.c_str(), "ThreadingModel", "Apartment"))
+        if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry.c_str(), L"ThreadingModel", L"Apartment"))
             return E_FAIL;
 
         return S_OK;
@@ -86,29 +86,29 @@ namespace /* private */
 
     HRESULT UnregisterComComponent(const CLSID& Guid)
     {
-        std::string tmp = "CLSID\\";
+        std::wstring tmp = L"CLSID\\";
         tmp += ClsidToString(Guid);
         return DeleteRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str()) ? S_OK : E_FAIL;
     }
 
-    HRESULT RegisterColumnHandler(const char* ModuleFileName)
+    HRESULT RegisterColumnHandler(const wchar_t* ModuleFileName)
     {
         if (FAILED(RegisterComComponent(ModuleFileName, CLSID_COLUMN_HANDLER)))
             return E_FAIL;
 
-        std::string tmp = "Folder\\shellex\\ColumnHandlers\\";
+        std::wstring tmp = L"Folder\\shellex\\ColumnHandlers\\";
         tmp += ClsidToString(CLSID_COLUMN_HANDLER);
 
         return SetRegistryKey(
             HKEY_CLASSES_ROOT,
             tmp.c_str(),
-            "",
-            WStringToString(COLUMN_HANDLER_DESCRIPTIVE_NAME).c_str()) ? S_OK : E_FAIL;
+            L"",
+            COLUMN_HANDLER_DESCRIPTIVE_NAME) ? S_OK : E_FAIL;
     }
 
     HRESULT UnregisterColumnHandler()
     {
-        std::string tmp = "Folder\\shellex\\ColumnHandlers\\";
+        std::wstring tmp = L"Folder\\shellex\\ColumnHandlers\\";
         tmp += ClsidToString(CLSID_COLUMN_HANDLER);
 
         if (!DeleteRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str()))
@@ -117,21 +117,21 @@ namespace /* private */
         return UnregisterComComponent(CLSID_COLUMN_HANDLER);
     }
 
-    HRESULT RegisterInfotipHandler(const char* ModuleFileName)
+    HRESULT RegisterInfotipHandler(const wchar_t* ModuleFileName)
     {
         if (FAILED(RegisterComComponent(ModuleFileName, CLSID_INFOTIP_HANDLER)))
             return E_FAIL;
 
-        std::string iid = ClsidToString(IID_IQueryInfo);
-        std::string tmp;
+        std::wstring iid = ClsidToString(IID_IQueryInfo);
+        std::wstring tmp;
 
         for(size_t i = 0; i < OOFileExtensionTableSize; i++)
         {
             tmp = SHELLEX_IID_ENTRY;
-            SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
+            SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionU);
             SubstitutePlaceholder(tmp, GUID_PLACEHOLDER, iid);
 
-            if (!SetRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str(), "", ClsidToString(CLSID_INFOTIP_HANDLER).c_str()))
+            if (!SetRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str(), L"", ClsidToString(CLSID_INFOTIP_HANDLER).c_str()))
                 return E_FAIL;
         }
         return S_OK;
@@ -139,14 +139,14 @@ namespace /* private */
 
     HRESULT UnregisterInfotipHandler()
     {
-        std::string iid = ClsidToString(IID_IQueryInfo);
-        std::string tmp;
+        std::wstring iid = ClsidToString(IID_IQueryInfo);
+        std::wstring tmp;
 
         for (size_t i = 0; i < OOFileExtensionTableSize; i++)
         {
             tmp = SHELLEX_IID_ENTRY;
 
-            SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
+            SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionU);
             SubstitutePlaceholder(tmp, GUID_PLACEHOLDER, iid);
 
             DeleteRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str());
@@ -154,7 +154,7 @@ namespace /* private */
             // if there are no further subkey below .ext\\shellex
             // delete the whole subkey
             tmp = SHELLEX_ENTRY;
-            SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
+            SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionU);
 
             bool HasSubKeys = true;
             if (HasSubkeysRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str(), HasSubKeys) && !HasSubKeys)
@@ -163,9 +163,9 @@ namespace /* private */
         return UnregisterComComponent(CLSID_INFOTIP_HANDLER);
     }
 
-    HRESULT RegisterPropSheetHandler(const char* ModuleFileName)
+    HRESULT RegisterPropSheetHandler(const wchar_t* ModuleFileName)
     {
-        std::string FwdKeyEntry;
+        std::wstring FwdKeyEntry;
 
         if (FAILED(RegisterComComponent(ModuleFileName, CLSID_PROPERTYSHEET_HANDLER)))
             return E_FAIL;
@@ -175,7 +175,7 @@ namespace /* private */
             FwdKeyEntry = FORWARD_PROPSHEET_MYPROPSHEET_ENTRY;
             SubstitutePlaceholder(FwdKeyEntry, FORWARDKEY_PLACEHOLDER, OOFileExtensionTable[i].RegistryForwardKey);
 
-            if (!SetRegistryKey(HKEY_CLASSES_ROOT, FwdKeyEntry.c_str(), "", ClsidToString(CLSID_PROPERTYSHEET_HANDLER).c_str()))
+            if (!SetRegistryKey(HKEY_CLASSES_ROOT, FwdKeyEntry.c_str(), L"", ClsidToString(CLSID_PROPERTYSHEET_HANDLER).c_str()))
                 return E_FAIL;
         }
         return S_OK;
@@ -183,7 +183,7 @@ namespace /* private */
 
     HRESULT UnregisterPropSheetHandler()
     {
-        std::string FwdKeyEntry;
+        std::wstring FwdKeyEntry;
 
         for (size_t i = 0; i < OOFileExtensionTableSize; i++)
         {
@@ -210,22 +210,22 @@ namespace /* private */
         return UnregisterComComponent(CLSID_PROPERTYSHEET_HANDLER);
     }
 
-    HRESULT RegisterThumbviewerHandler(const char* ModuleFileName)
+    HRESULT RegisterThumbviewerHandler(const wchar_t* ModuleFileName)
     {
         if (FAILED(RegisterComComponent(ModuleFileName, CLSID_THUMBVIEWER_HANDLER)))
             return E_FAIL;
 
-        std::string iid = ClsidToString(IID_IExtractImage);
-        std::string tmp;
+        std::wstring iid = ClsidToString(IID_IExtractImage);
+        std::wstring tmp;
 
         for(size_t i = 0; i < OOFileExtensionTableSize; i++)
         {
             tmp = SHELLEX_IID_ENTRY;
 
-            SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
+            SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionU);
             SubstitutePlaceholder(tmp, GUID_PLACEHOLDER, iid);
 
-            if (!SetRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str(), "", ClsidToString(CLSID_THUMBVIEWER_HANDLER).c_str()))
+            if (!SetRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str(), L"", ClsidToString(CLSID_THUMBVIEWER_HANDLER).c_str()))
                 return E_FAIL;
         }
         return S_OK;
@@ -233,14 +233,14 @@ namespace /* private */
 
     HRESULT UnregisterThumbviewerHandler()
     {
-        std::string iid = ClsidToString(IID_IExtractImage);
-        std::string tmp;
+        std::wstring iid = ClsidToString(IID_IExtractImage);
+        std::wstring tmp;
 
         for (size_t i = 0; i < OOFileExtensionTableSize; i++)
         {
             tmp = SHELLEX_IID_ENTRY;
 
-            SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
+            SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionU);
             SubstitutePlaceholder(tmp, GUID_PLACEHOLDER, iid);
 
             DeleteRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str());
@@ -248,7 +248,7 @@ namespace /* private */
             // if there are no further subkey below .ext\\shellex
             // delete the whole subkey
             tmp = SHELLEX_ENTRY;
-            SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
+            SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionU);
 
             bool HasSubKeys = true;
             if (HasSubkeysRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str(), HasSubKeys) && !HasSubKeys)
@@ -265,7 +265,7 @@ namespace /* private */
             HKEY_LOCAL_MACHINE,
             SHELL_EXTENSION_APPROVED_KEY_NAME,
             ClsidToString(clsid).c_str(),
-            WStringToString(Description).c_str());
+            Description.c_str());
 
         return bRet ? S_OK : E_FAIL;
     }
@@ -274,14 +274,14 @@ namespace /* private */
     {
         HKEY hkey;
 
-        LONG rc = RegOpenKeyA(
+        LONG rc = RegOpenKeyW(
             HKEY_LOCAL_MACHINE,
             SHELL_EXTENSION_APPROVED_KEY_NAME,
             &hkey);
 
         if (ERROR_SUCCESS == rc)
         {
-            rc = RegDeleteValueA(
+            rc = RegDeleteValueW(
                 hkey,
                 ClsidToString(Clsid).c_str());
 
@@ -306,25 +306,24 @@ STDAPI DllRegisterServer()
         ModuleFileName,
         sizeof(ModuleFileName)/sizeof(ModuleFileName[0]));
 
-    std::string module_path = WStringToString(ModuleFileName);
     HRESULT hr = S_OK;
 
-    if (SUCCEEDED(RegisterColumnHandler(module_path.c_str())))
+    if (SUCCEEDED(RegisterColumnHandler(ModuleFileName)))
         ApproveShellExtension(CLSID_COLUMN_HANDLER, COLUMN_HANDLER_DESCRIPTIVE_NAME);
     else
         hr = E_FAIL;
 
-    if (SUCCEEDED(RegisterInfotipHandler(module_path.c_str())))
+    if (SUCCEEDED(RegisterInfotipHandler(ModuleFileName)))
         ApproveShellExtension(CLSID_INFOTIP_HANDLER, INFOTIP_HANDLER_DESCRIPTIVE_NAME);
     else
         hr = E_FAIL;
 
-    if (SUCCEEDED(RegisterPropSheetHandler(module_path.c_str())))
+    if (SUCCEEDED(RegisterPropSheetHandler(ModuleFileName)))
         ApproveShellExtension(CLSID_PROPERTYSHEET_HANDLER, PROPSHEET_HANDLER_DESCRIPTIVE_NAME);
     else
         hr = E_FAIL;
 
-    if (SUCCEEDED(RegisterThumbviewerHandler(module_path.c_str())))
+    if (SUCCEEDED(RegisterThumbviewerHandler(ModuleFileName)))
         ApproveShellExtension(CLSID_THUMBVIEWER_HANDLER, THUMBVIEWER_HANDLER_DESCRIPTIVE_NAME);
     else
         hr = E_FAIL;
@@ -379,13 +378,13 @@ STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void** ppv)
         return E_NOINTERFACE;
 
     if ( rclsid == CLSID_INFOTIP_HANDLER )
-        OutputDebugStringFormatA( "DllGetClassObject: Create CLSID_INFOTIP_HANDLER\n" );
+        OutputDebugStringFormatW( L"DllGetClassObject: Create CLSID_INFOTIP_HANDLER\n" );
     else if ( rclsid == CLSID_COLUMN_HANDLER )
-        OutputDebugStringFormatA( "DllGetClassObject: Create CLSID_COLUMN_HANDLER\n" );
+        OutputDebugStringFormatW( L"DllGetClassObject: Create CLSID_COLUMN_HANDLER\n" );
     else if ( rclsid == CLSID_PROPERTYSHEET_HANDLER )
-        OutputDebugStringFormatA( "DllGetClassObject: Create CLSID_PROPERTYSHEET_HANDLER\n" );
+        OutputDebugStringFormatW( L"DllGetClassObject: Create CLSID_PROPERTYSHEET_HANDLER\n" );
     else if ( rclsid == CLSID_THUMBVIEWER_HANDLER )
-        OutputDebugStringFormatA( "DllGetClassObject: Create CLSID_THUMBVIEWER_HANDLER\n" );
+        OutputDebugStringFormatW( L"DllGetClassObject: Create CLSID_THUMBVIEWER_HANDLER\n" );
 
     IUnknown* pUnk = new CClassFactory(rclsid);
     *ppv = pUnk;
diff --git a/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx b/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx
index 740ae5708c93..360f89cacab0 100644
--- a/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx
+++ b/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx
@@ -73,10 +73,10 @@ namespace internal
 #ifdef _WIN32_WINNT_WINBLUE
         return IsWindowsXPOrGreater();
 #else
-        OSVERSIONINFO osvi;
+        OSVERSIONINFOW osvi;
         ZeroMemory(&osvi, sizeof(osvi));
         osvi.dwOSVersionInfoSize = sizeof(osvi);
-        GetVersionEx(&osvi);
+        GetVersionExW(&osvi);
 
         return ((osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
                 ((osvi.dwMajorVersion >= 5) && (osvi.dwMinorVersion >= 1)));
@@ -376,7 +376,7 @@ HRESULT STDMETHODCALLTYPE CThumbviewer::Extract(HBITMAP *phBmpImage)
     try
     {
         std::wstring fname = getShortPathName( filename_ );
-        std::unique_ptr<ZipFile> zipfile( new ZipFile( WStringToString( fname ) ) );
+        std::unique_ptr<ZipFile> zipfile( new ZipFile( fname ) );
 
         if (zipfile->HasContent(THUMBNAIL_CONTENT))
         {
@@ -477,7 +477,7 @@ HRESULT STDMETHODCALLTYPE CThumbviewer::Extract(HBITMAP *phBmpImage)
     }
     catch(std::exception&)
     {
-        OutputDebugStringFormatA( "CThumbviewer Extract ERROR!\n" );
+        OutputDebugStringFormatW( L"CThumbviewer Extract ERROR!\n" );
         hr = E_FAIL;
     }
     return hr;
diff --git a/shell/source/win32/shlxthandler/util/fileextensions.cxx b/shell/source/win32/shlxthandler/util/fileextensions.cxx
index cb73b1af9796..af13af50d469 100644
--- a/shell/source/win32/shlxthandler/util/fileextensions.cxx
+++ b/shell/source/win32/shlxthandler/util/fileextensions.cxx
@@ -23,37 +23,37 @@
 #include <sal/macros.h>
 
 
-const std::string WRITER_FILE_EXTENSIONS   = "sxwstwsxgodtottodm";
-const std::string CALC_FILE_EXTENSIONS     = "sxcstcodsots";
-const std::string DRAW_FILE_EXTENSIONS     = "sxdstdodgotg";
-const std::string IMPRESS_FILE_EXTENSIONS  = "sxistiodpotp";
-const std::string MATH_FILE_EXTENSIONS     = "sxmodf";
-const std::string WEB_FILE_EXTENSIONS      = "oth";
-const std::string DATABASE_FILE_EXTENSIONS = "odb";
+const std::wstring WRITER_FILE_EXTENSIONS   = L"sxwstwsxgodtottodm";
+const std::wstring CALC_FILE_EXTENSIONS     = L"sxcstcodsots";
+const std::wstring DRAW_FILE_EXTENSIONS     = L"sxdstdodgotg";
+const std::wstring IMPRESS_FILE_EXTENSIONS  = L"sxistiodpotp";
+const std::wstring MATH_FILE_EXTENSIONS     = L"sxmodf";
+const std::wstring WEB_FILE_EXTENSIONS      = L"oth";
+const std::wstring DATABASE_FILE_EXTENSIONS = L"odb";
 
 const FileExtensionEntry OOFileExtensionTable[] = {
-    { ".sxw", L".sxw", "soffice.StarWriterDocument.6"       },
-    { ".sxc", L".sxc", "soffice.StarCalcDocument.6"         },
-    { ".sxi", L".sxi", "soffice.StarImpressDocument.6"      },
-    { ".sxd", L".sxd", "soffice.StarDrawDocument.6"         },
-    { ".sxm", L".sxm", "soffice.StarMathDocument.6"         },
-    { ".stw", L".stw", "soffice.StarWriterTemplate.6"       },
-    { ".sxg", L".sxg", "soffice.StarWriterGlobalDocument.6" },
-    { ".std", L".std", "soffice.StarDrawTemplate.6"         },
-    { ".sti", L".sti", "soffice.StarImpressTemplate.6"      },
-    { ".stc", L".stc", "soffice.StarCalcTemplate.6"         },
-    { ".odt", L".odt", "LibreOffice.WriterDocument.1"       },
-    { ".ott", L".ott", "LibreOffice.WriterTemplate.1"       },
-    { ".odm", L".odm", "LibreOffice.WriterGlobalDocument.1" },
-    { ".oth", L".oth", "LibreOffice.WriterWebTemplate.1"    },
-    { ".ods", L".ods", "LibreOffice.CalcDocument.1"         },
-    { ".ots", L".ots", "LibreOffice.CalcTemplate.1"         },
-    { ".odg", L".odg", "LibreOffice.DrawDocument.1"         },
-    { ".otg", L".otg", "LibreOffice.DrawTemplate.1"         },
-    { ".odp", L".odp", "LibreOffice.ImpressDocument.1"      },
-    { ".otp", L".otp", "LibreOffice.ImpressTemplate.1"      },
-    { ".odf", L".odf", "LibreOffice.MathDocument.1"         },
-    { ".odb", L".odb", "LibreOffice.DatabaseDocument.1"     }
+    { ".sxw", L".sxw", L"soffice.StarWriterDocument.6"       },
+    { ".sxc", L".sxc", L"soffice.StarCalcDocument.6"         },
+    { ".sxi", L".sxi", L"soffice.StarImpressDocument.6"      },
+    { ".sxd", L".sxd", L"soffice.StarDrawDocument.6"         },
+    { ".sxm", L".sxm", L"soffice.StarMathDocument.6"         },
+    { ".stw", L".stw", L"soffice.StarWriterTemplate.6"       },
+    { ".sxg", L".sxg", L"soffice.StarWriterGlobalDocument.6" },
+    { ".std", L".std", L"soffice.StarDrawTemplate.6"         },
+    { ".sti", L".sti", L"soffice.StarImpressTemplate.6"      },
+    { ".stc", L".stc", L"soffice.StarCalcTemplate.6"         },
+    { ".odt", L".odt", L"LibreOffice.WriterDocument.1"       },
+    { ".ott", L".ott", L"LibreOffice.WriterTemplate.1"       },
+    { ".odm", L".odm", L"LibreOffice.WriterGlobalDocument.1" },
+    { ".oth", L".oth", L"LibreOffice.WriterWebTemplate.1"    },
+    { ".ods", L".ods", L"LibreOffice.CalcDocument.1"         },
+    { ".ots", L".ots", L"LibreOffice.CalcTemplate.1"         },
+    { ".odg", L".odg", L"LibreOffice.DrawDocument.1"         },
+    { ".otg", L".otg", L"LibreOffice.DrawTemplate.1"         },
+    { ".odp", L".odp", L"LibreOffice.ImpressDocument.1"      },
+    { ".otp", L".otp", L"LibreOffice.ImpressTemplate.1"      },
+    { ".odf", L".odf", L"LibreOffice.MathDocument.1"         },
+    { ".odb", L".odb", L"LibreOffice.DatabaseDocument.1"     }
     };
 
 
@@ -63,41 +63,41 @@ const size_t OOFileExtensionTableSize = SAL_N_ELEMENTS(OOFileExtensionTable);
 /** Return the extension of a file
     name without the '.'
 */
-std::string get_file_name_extension(const std::string& file_name)
+std::wstring get_file_name_extension(const std::wstring& file_name)
 {
-    std::string::size_type idx = file_name.find_last_of(".");
+    std::wstring::size_type idx = file_name.find_last_of(L".");
 
-    if (std::string::npos != idx++)
-        return std::string(file_name.begin() + idx, file_name.end());
+    if (std::wstring::npos != idx++)
+        return std::wstring(file_name.begin() + idx, file_name.end());
 
-    return std::string();
+    return std::wstring();
 }
 
 
 /** Return the type of a file
 */
 
-File_Type_t get_file_type(const std::string& file_name)
+File_Type_t get_file_type(const std::wstring& file_name)
 {
-    std::string fext = get_file_name_extension(file_name);
+    std::wstring fext = get_file_name_extension(file_name);
     std::transform(
         fext.begin(), fext.end(), fext.begin(),
-        [](char c) {
-            return rtl::toAsciiLowerCase(static_cast<unsigned char>(c)); });
+        [](wchar_t c) {
+            return rtl::toAsciiLowerCase(c); });
 
-    if (std::string::npos != WRITER_FILE_EXTENSIONS.find(fext))
+    if (std::wstring::npos != WRITER_FILE_EXTENSIONS.find(fext))
         return WRITER;
-    else if (std::string::npos != CALC_FILE_EXTENSIONS.find(fext))
+    else if (std::wstring::npos != CALC_FILE_EXTENSIONS.find(fext))
         return CALC;
-    else if (std::string::npos != DRAW_FILE_EXTENSIONS.find(fext))
+    else if (std::wstring::npos != DRAW_FILE_EXTENSIONS.find(fext))
         return DRAW;
-    else if (std::string::npos != IMPRESS_FILE_EXTENSIONS.find(fext))
+    else if (std::wstring::npos != IMPRESS_FILE_EXTENSIONS.find(fext))
         return IMPRESS;
-    else if (std::string::npos != MATH_FILE_EXTENSIONS.find(fext))
+    else if (std::wstring::npos != MATH_FILE_EXTENSIONS.find(fext))
         return MATH;
-    else if (std::string::npos != WEB_FILE_EXTENSIONS.find(fext))
+    else if (std::wstring::npos != WEB_FILE_EXTENSIONS.find(fext))
         return WEB;
-    else if (std::string::npos != DATABASE_FILE_EXTENSIONS.find(fext))
+    else if (std::wstring::npos != DATABASE_FILE_EXTENSIONS.find(fext))
         return DATABASE;
     else
         return UNKNOWN;
diff --git a/shell/source/win32/shlxthandler/util/registry.cxx b/shell/source/win32/shlxthandler/util/registry.cxx
index 9c76be19cab2..f7dc281c9818 100644
--- a/shell/source/win32/shlxthandler/util/registry.cxx
+++ b/shell/source/win32/shlxthandler/util/registry.cxx
@@ -39,20 +39,20 @@
 #pragma warning(pop)
 #endif
 
-bool SetRegistryKey(HKEY RootKey, const char* KeyName, const char* ValueName, const char* Value)
+bool SetRegistryKey(HKEY RootKey, const wchar_t* KeyName, const wchar_t* ValueName, const wchar_t* Value)
 {
     HKEY hSubKey;
 
     // open or create the desired key
-    char dummy[] = "";
-    int rc = RegCreateKeyExA(
+    wchar_t dummy[] = L"";
+    int rc = RegCreateKeyExW(
         RootKey, KeyName, 0, dummy, REG_OPTION_NON_VOLATILE, KEY_WRITE, nullptr, &hSubKey, nullptr);
 
     if (ERROR_SUCCESS == rc)
     {
-        rc = RegSetValueExA(
+        rc = RegSetValueExW(
             hSubKey, ValueName, 0, REG_SZ, reinterpret_cast<const BYTE*>(Value),
-            static_cast<DWORD>(strlen(Value) + 1));
+            static_cast<DWORD>((wcslen(Value) + 1) * sizeof(*Value)));
 
         RegCloseKey(hSubKey);
     }
@@ -61,11 +61,11 @@ bool SetRegistryKey(HKEY RootKey, const char* KeyName, const char* ValueName, co
 }
 
 
-bool DeleteRegistryKey(HKEY RootKey, const char* KeyName)
+bool DeleteRegistryKey(HKEY RootKey, const wchar_t* KeyName)
 {
     HKEY hKey;
 
-    int rc = RegOpenKeyExA(
+    int rc = RegOpenKeyExW(
         RootKey,
         KeyName,
         0,
@@ -77,24 +77,24 @@ bool DeleteRegistryKey(HKEY RootKey, const char* KeyName)
 
     if (ERROR_SUCCESS == rc)
     {
-        char* SubKey;
+        wchar_t* SubKey;
         DWORD nMaxSubKeyLen;
 
-        rc = RegQueryInfoKeyA(
+        rc = RegQueryInfoKeyW(
             hKey, nullptr, nullptr, nullptr, nullptr,
             &nMaxSubKeyLen,
             nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
 
         nMaxSubKeyLen++; // space for trailing '\0'
 
-        SubKey = static_cast<char*>(
-            _alloca(nMaxSubKeyLen*sizeof(char)));
+        SubKey = static_cast<wchar_t*>(
+            _alloca(nMaxSubKeyLen*sizeof(wchar_t)));
 
         while (ERROR_SUCCESS == rc)
         {
             DWORD nLen = nMaxSubKeyLen;
 
-            rc = RegEnumKeyExA(
+            rc = RegEnumKeyExW(
                 hKey,
                 0,       // always index zero
                 SubKey,
@@ -103,7 +103,7 @@ bool DeleteRegistryKey(HKEY RootKey, const char* KeyName)
 
             if (ERROR_NO_MORE_ITEMS == rc)
             {
-                rc = RegDeleteKeyA(RootKey, KeyName);
+                rc = RegDeleteKeyW(RootKey, KeyName);
                 break;
             }
             else if (rc == ERROR_SUCCESS)
@@ -123,18 +123,19 @@ bool DeleteRegistryKey(HKEY RootKey, const char* KeyName)
 /** May be used to determine if the specified registry key has subkeys
     The function returns true on success else if an error occurs false
 */
-bool HasSubkeysRegistryKey(HKEY RootKey, const char* KeyName, /* out */ bool& bResult)
+bool HasSubkeysRegistryKey(HKEY RootKey, const wchar_t* KeyName, /* out */ bool& bResult)
 {
     HKEY hKey;
 
-    LONG rc = RegOpenKeyExA(RootKey, KeyName, 0, KEY_READ, &hKey);
+    LONG rc = RegOpenKeyExW(RootKey, KeyName, 0, KEY_READ, &hKey);
 
     if (ERROR_SUCCESS == rc)
     {
         DWORD nSubKeys = 0;
 
-        rc = RegQueryInfoKeyA(hKey, nullptr, nullptr, nullptr, &nSubKeys, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
+        rc = RegQueryInfoKeyW(hKey, nullptr, nullptr, nullptr, &nSubKeys, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
 
+        RegCloseKey(hKey);
         bResult = (nSubKeys > 0);
     }
 
@@ -142,28 +143,26 @@ bool HasSubkeysRegistryKey(HKEY RootKey, const char* KeyName, /* out */ bool& bR
 }
 
 // Convert a CLSID to a char string.
-std::string ClsidToString(const CLSID& clsid)
+std::wstring ClsidToString(const CLSID& clsid)
 {
     // Get CLSID
     LPOLESTR wszCLSID = nullptr;
     StringFromCLSID(clsid, &wszCLSID);
 
-    char buff[39];
-    // Covert from wide characters to non-wide.
-    wcstombs(buff, wszCLSID, sizeof(buff));
+    std::wstring sResult = wszCLSID;
 
     // Free memory.
     CoTaskMemFree(wszCLSID) ;
 
-    return std::string(buff);
+    return sResult;
 }
 
 
-bool QueryRegistryKey(HKEY RootKey, const char* KeyName, const char* ValueName, char *pszData, DWORD dwBufLen)
+bool QueryRegistryKey(HKEY RootKey, const wchar_t* KeyName, const wchar_t* ValueName, wchar_t *pszData, DWORD dwBufLen)
 {
     HKEY hKey;
 
-    int rc = RegOpenKeyExA(
+    int rc = RegOpenKeyExW(
         RootKey,
         KeyName,
         0,
@@ -172,8 +171,9 @@ bool QueryRegistryKey(HKEY RootKey, const char* KeyName, const char* ValueName,
 
     if (ERROR_SUCCESS == rc)
     {
-        rc = RegQueryValueExA(
-            hKey, ValueName, nullptr, nullptr, reinterpret_cast<LPBYTE>(pszData),&dwBufLen);
+        DWORD dwBytes = dwBufLen * sizeof(*pszData);
+        rc = RegQueryValueExW(
+            hKey, ValueName, nullptr, nullptr, reinterpret_cast<LPBYTE>(pszData),&dwBytes);
 
         RegCloseKey(hKey);
     }
diff --git a/shell/source/win32/shlxthandler/util/utilities.cxx b/shell/source/win32/shlxthandler/util/utilities.cxx
index 03e013602699..9468b33a71c4 100644
--- a/shell/source/win32/shlxthandler/util/utilities.cxx
+++ b/shell/source/win32/shlxthandler/util/utilities.cxx
@@ -87,7 +87,7 @@ std::wstring GetResString(int ResId)
 
     int rc = LoadStringW( GetModuleHandleW(MODULE_NAME), ResId, szResStr, sizeof(szResStr) );
 
-    OutputDebugStringFormatA( "GetResString: read %d chars\n", rc );
+    OutputDebugStringFormatW( L"GetResString: read %d chars\n", rc );
     // OSL_ENSURE(rc, "String resource not found");
 
     return std::wstring(szResStr);
@@ -100,10 +100,10 @@ bool is_windows_xp_or_above()
 #ifdef _WIN32_WINNT_WINBLUE
     return IsWindowsXPOrGreater();
 #else
-    OSVERSIONINFO osvi;
+    OSVERSIONINFOW osvi;
     ZeroMemory(&osvi, sizeof(osvi));
     osvi.dwOSVersionInfoSize = sizeof(osvi);
-    GetVersionEx(&osvi);
+    GetVersionExW(&osvi);
 
     // LLA: check for windows xp or above (Vista)
     if (osvi.dwMajorVersion > 5 ||
diff --git a/shell/source/win32/simplemail/simplemapi.cxx b/shell/source/win32/simplemail/simplemapi.cxx
index 316cb70660de..e7680048c220 100644
--- a/shell/source/win32/simplemail/simplemapi.cxx
+++ b/shell/source/win32/simplemail/simplemapi.cxx
@@ -27,7 +27,7 @@ CSimpleMapi::CSimpleMapi() :
     m_lpfnMapiLogoff(nullptr),
     m_lpfnMapiSendMail(nullptr)
 {
-    m_hMapiDll = LoadLibrary("mapi32.dll");
+    m_hMapiDll = LoadLibraryW(L"mapi32.dll");
     if ((m_hMapiDll == INVALID_HANDLE_VALUE) || (m_hMapiDll == nullptr))
         throw std::runtime_error("Couldn't load MAPI library");
 
diff --git a/shell/source/win32/simplemail/smplmailsuppl.cxx b/shell/source/win32/simplemail/smplmailsuppl.cxx
index 0ade1644f1ea..22410f80216c 100644
--- a/shell/source/win32/simplemail/smplmailsuppl.cxx
+++ b/shell/source/win32/simplemail/smplmailsuppl.cxx
@@ -56,7 +56,7 @@ Reference<XSimpleMailClient> SAL_CALL CSmplMailSuppl::querySimpleMailClient()
     /* We just try to load the MAPI dll as a test
        if a mail client is available */
     Reference<XSimpleMailClient> xSmplMailClient;
-    HMODULE handle = LoadLibrary("mapi32.dll");
+    HMODULE handle = LoadLibraryW(L"mapi32.dll");
     if ((handle != INVALID_HANDLE_VALUE) && (handle != nullptr))
     {
         FreeLibrary(handle);
diff --git a/shell/source/win32/zipfile/zipfile.cxx b/shell/source/win32/zipfile/zipfile.cxx
index 3bff687982dc..f1fca5276d30 100644
--- a/shell/source/win32/zipfile/zipfile.cxx
+++ b/shell/source/win32/zipfile/zipfile.cxx
@@ -351,7 +351,7 @@ struct stricmp
             IOException if the specified file doesn't exist
             AccessViolationException if read access to the file is denied
 */
-bool ZipFile::IsZipFile(const std::string& /*FileName*/)
+bool ZipFile::IsZipFile(const std::wstring& /*FileName*/)
 {
     return true;
 }
@@ -377,7 +377,7 @@ bool ZipFile::IsZipFile(void* /*stream*/)
             IOException if the specified file doesn't exist or is no zip file
             AccessViolationException if read access to the file is denied
 */
-bool ZipFile::IsValidZipFileVersionNumber(const std::string& /*FileName*/)
+bool ZipFile::IsValidZipFileVersionNumber(const std::wstring& /*FileName*/)
 {
     return true;
 }
@@ -400,7 +400,7 @@ bool ZipFile::IsValidZipFileVersionNumber(void* /* stream*/)
             WrongZipVersionException if the zip file cannot be uncompressed
             with the used zlib version
 */
-ZipFile::ZipFile(const std::string &FileName) :
+ZipFile::ZipFile(const std::wstring &FileName) :
     m_pStream(nullptr),
     m_bShouldFree(true)
 {


More information about the Libreoffice-commits mailing list