bump product version to 5.0.4.1
[LibreOffice.git] / shell / inc / internal / utilities.hxx
blobccd537bec1f73216068ae5813f772ea4e7c86ab2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SHELL_INC_INTERNAL_UTILITIES_HXX
21 #define INCLUDED_SHELL_INC_INTERNAL_UTILITIES_HXX
23 #include <malloc.h>
24 #if defined _MSC_VER
25 #pragma warning(push, 1)
26 #endif
27 #include <windows.h>
28 #if defined _MSC_VER
29 #pragma warning(pop)
30 #endif
31 #include <stdio.h>
32 #include <fcntl.h>
33 #include <io.h>
34 #include "internal/types.hxx"
36 #include <string>
37 #define STRSAFE_NO_DEPRECATE
38 #ifdef __MINGW32__
40 // Work around lack of strsafe library in mingw-w64, do let their
41 // strsafe.h provide inlines of StringCchVPrintfA etc, avoid linking
42 // errors in a debug build.
43 #ifdef __CRT__NO_INLINE
44 #undef __CRT__NO_INLINE
45 #define DID_UNDEFINE__CRT__NO_INLINE
46 #endif
48 extern "C" {
50 #endif
52 #include <strsafe.h>
54 #ifdef __MINGW32__
57 #ifdef DID_UNDEFINE__CRT__NO_INLINE
58 #define __CRT__NO_INLINE
59 #endif
61 #endif
64 /** Convert a string to a wstring
65 using CP_ACP
67 std::wstring StringToWString(const std::string& String);
70 /** Convert a wstring to a string
71 using CP_ACP
73 std::string WStringToString(const std::wstring& String);
76 /** Convert a string to a wstring
77 using CP_UTF8
79 std::wstring UTF8ToWString(const std::string& String);
82 /** Retrieve a string from the
83 resources of this module
85 std::wstring GetResString(int ResId);
88 /** Returns whether we are running
89 on Windows XP or not
91 bool is_windows_xp_or_above();
94 /** helper function to judge if the string is only has spaces.
95 @returns
96 <TRUE>if the provided string contains only but at least one space
97 character else <FALSE/>.
99 bool HasOnlySpaces(const std::wstring& String);
101 /** convert LocaleSet pair into Windows LCID identifier.
102 @returns
103 Windows Locale Identifier corresponding to input LocaleSet.
107 /** Convert a long path name using Windows api call GetShortPathName
109 std::wstring getShortPathName( const std::wstring& aLongName );
112 LCID LocaleSetToLCID( const LocaleSet_t & Locale );
115 #ifdef DEBUG
116 inline void OutputDebugStringFormat( LPCSTR pFormat, ... )
118 CHAR buffer[1024];
119 va_list args;
121 va_start( args, pFormat );
122 StringCchVPrintfA( buffer, sizeof(buffer), pFormat, args );
123 va_end( args );
124 OutputDebugStringA( buffer );
126 #else
127 static inline void OutputDebugStringFormat( LPCSTR, ... )
130 #endif
134 #endif
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */