LibreOffice Module shell (master) 1
utilities.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_SHELL_INC_INTERNAL_UTILITIES_HXX
21#define INCLUDED_SHELL_INC_INTERNAL_UTILITIES_HXX
22
23#include <malloc.h>
24
25#if !defined WIN32_LEAN_AND_MEAN
26#define WIN32_LEAN_AND_MEAN
27#endif
28#include <windows.h>
29
30#include <stdio.h>
31#include <fcntl.h>
32#include <io.h>
33#include "types.hxx"
34
35#include <string>
36#define STRSAFE_NO_DEPRECATE
37#include <strsafe.h>
38
42std::wstring StringToWString(const std::string& String);
43
47std::string WStringToString(const std::wstring& String);
48
52std::wstring UTF8ToWString(const std::string& String);
53
57std::wstring GetResString(int ResId);
58
64bool HasOnlySpaces(const std::wstring& String);
65
73std::wstring getShortPathName(const std::wstring& aLongName);
74
75LCID LocaleSetToLCID(const LocaleSet_t& Locale);
76
77#ifdef DEBUG
78inline void OutputDebugStringFormatW(LPCWSTR pFormat, ...)
79{
80 WCHAR buffer[1024];
81 va_list args;
82
83 va_start(args, pFormat);
84 StringCchVPrintfW(buffer, sizeof(buffer) / sizeof(*buffer), pFormat, args);
85 va_end(args);
86 OutputDebugStringW(buffer);
87}
88#else
89static inline void OutputDebugStringFormatW(LPCWSTR, ...) {}
90#endif
91
92#endif
93
94/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
args
::std::pair< Language_t, Country_t > LocaleSet_t
Definition: types.hxx:48
std::wstring GetResString(int ResId)
Retrieve a string from the resources of this module.
Definition: utilities.cxx:81
bool HasOnlySpaces(const std::wstring &String)
helper function to judge if the string is only has spaces.
Definition: utilities.cxx:100
std::string WStringToString(const std::wstring &String)
Convert a wstring to a string using CP_ACP.
Definition: utilities.cxx:69
void OutputDebugStringFormatW(LPCWSTR pFormat,...)
Definition: utilities.hxx:78
std::wstring UTF8ToWString(const std::string &String)
Convert a string to a wstring using CP_UTF8.
Definition: utilities.cxx:75
LCID LocaleSetToLCID(const LocaleSet_t &Locale)
convert LocaleSet pair into Microsoft List of Locale ID (LCID) according to ISO-639 and ISO-3166.
Definition: utilities.cxx:154
std::wstring getShortPathName(const std::wstring &aLongName)
convert LocaleSet pair into Windows LCID identifier.
Definition: utilities.cxx:122
std::wstring StringToWString(const std::string &String)
Convert a string to a wstring using CP_ACP.
Definition: utilities.cxx:63