xref: /trunk/main/shell/inc/internal/utilities.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef UTILITIES_HXX_INCLUDED
29 #define UTILITIES_HXX_INCLUDED
30 
31 #include <malloc.h>
32 #if defined _MSC_VER
33 #pragma warning(push, 1)
34 #endif
35 #ifndef OS2
36 #include <windows.h>
37 #endif
38 #if defined _MSC_VER
39 #pragma warning(pop)
40 #endif
41 #include <stdio.h>
42 #include <fcntl.h>
43 #include <io.h>
44 #include "internal/types.hxx"
45 
46 #include <string>
47 #define STRSAFE_NO_DEPRECATE
48 #include <strsafe.h>
49 
50 //---------------------------------
51 /** Convert a string to a wstring
52 	using CP_ACP
53 */
54 std::wstring StringToWString(const std::string& String);
55 
56 //---------------------------------
57 /** Convert a wstring to a string
58 	using CP_ACP
59 */
60 std::string WStringToString(const std::wstring& String);
61 
62 //---------------------------------
63 /** Retrieve a string from the
64 	resources of this module
65 */
66 std::wstring GetResString(int ResId);
67 
68 //---------------------------------
69 /** Returns whether we are running
70     on Windows XP or not
71 */
72 bool is_windows_xp_or_above();
73 
74 //---------------------------------
75 /** helper function to judge if the string is only has spaces.
76     @returns
77         <TRUE>if the provided string contains only but at least one space
78         character else <FALSE/>.
79 */
80 bool HasOnlySpaces(const std::wstring& String);
81 
82 /** convert LocaleSet pair into Windows LCID identifier.
83     @returns
84         Windows Locale Identifier corresponding to input LocaleSet.
85 */
86 
87 //---------------------------------
88 /** Convert a long path name using Windows api call GetShortPathName
89 */
90 std::wstring getShortPathName( const std::wstring& aLongName );
91 
92 
93 #ifndef OS2
94 LCID LocaleSetToLCID( const LocaleSet_t & Locale );
95 #endif
96 
97 //----------------------------------------------------------
98 #ifdef DEBUG
99 inline void OutputDebugStringFormat( LPCSTR pFormat, ... )
100 {
101 	CHAR    buffer[1024];
102 	va_list args;
103 
104 	va_start( args, pFormat );
105 	StringCchVPrintfA( buffer, sizeof(buffer), pFormat, args );
106 	OutputDebugStringA( buffer );
107 }
108 #else
109 static inline void OutputDebugStringFormat( LPCSTR, ... )
110 {
111 }
112 #endif
113 //----------------------------------------------------------
114 
115 
116 #endif
117