diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-27 14:20:25 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-28 08:55:04 +0200 |
commit | e80aef4e032f08ef0c4cfbb028bf83b81002f112 (patch) | |
tree | abb1d7e2ae7f46623d2769b5820e716ad063b4eb /shell/inc | |
parent | 09917566b6ce86ea65a246f2055b5d1f41df4e76 (diff) |
shell: use Unicode on Windows
Change-Id: I9f7962db320f8832879ba327108425a7592b4b77
Reviewed-on: https://gerrit.libreoffice.org/42885
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'shell/inc')
-rw-r--r-- | shell/inc/basereader.hxx | 3 | ||||
-rw-r--r-- | shell/inc/contentreader.hxx | 3 | ||||
-rw-r--r-- | shell/inc/fileextensions.hxx | 12 | ||||
-rw-r--r-- | shell/inc/filepath.hxx | 29 | ||||
-rw-r--r-- | shell/inc/infotips.hxx | 7 | ||||
-rw-r--r-- | shell/inc/metainforeader.hxx | 3 | ||||
-rw-r--r-- | shell/inc/propsheets.hxx | 3 | ||||
-rw-r--r-- | shell/inc/registry.hxx | 11 | ||||
-rw-r--r-- | shell/inc/stream_helper.hxx | 3 | ||||
-rw-r--r-- | shell/inc/utilities.hxx | 10 | ||||
-rw-r--r-- | shell/inc/zipfile.hxx | 8 |
11 files changed, 64 insertions, 28 deletions
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); |