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 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_vcl.hxx" 30 31 #include "tools/svwin.h" 32 #include "rtl/tencinfo.h" 33 #include "vcl/svapp.hxx" 34 35 #include "win/saldata.hxx" 36 37 // ======================================================================= 38 39 rtl_TextEncoding ImplSalGetSystemEncoding() 40 { 41 static UINT nOldAnsiCodePage = 0; 42 static rtl_TextEncoding eEncoding = RTL_TEXTENCODING_MS_1252; 43 44 UINT nAnsiCodePage = GetACP(); 45 if ( nAnsiCodePage != nOldAnsiCodePage ) 46 { 47 rtl_TextEncoding nEnc 48 = rtl_getTextEncodingFromWindowsCodePage(nAnsiCodePage); 49 if (nEnc != RTL_TEXTENCODING_DONTKNOW) 50 eEncoding = nEnc; 51 } 52 53 return eEncoding; 54 } 55 56 // ----------------------------------------------------------------------- 57 58 ByteString ImplSalGetWinAnsiString( const UniString& rStr, sal_Bool bFileName ) 59 { 60 rtl_TextEncoding eEncoding = ImplSalGetSystemEncoding(); 61 if ( bFileName ) 62 { 63 return ByteString( rStr, eEncoding, 64 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_UNDERLINE | 65 RTL_UNICODETOTEXT_FLAGS_INVALID_UNDERLINE | 66 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE | 67 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR | 68 RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 ); 69 } 70 else 71 { 72 return ByteString( rStr, eEncoding, 73 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT | 74 RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT | 75 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE | 76 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR | 77 RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 ); 78 } 79 } 80 81 // ----------------------------------------------------------------------- 82 83 UniString ImplSalGetUniString( const sal_Char* pStr, xub_StrLen nLen ) 84 { 85 return UniString( pStr, nLen, ImplSalGetSystemEncoding(), 86 RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT | 87 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT | 88 RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT ); 89 } 90 91 // ======================================================================= 92 93 int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 ) 94 { 95 int nRet; 96 wchar_t c1; 97 char c2; 98 do 99 { 100 // Ist das Zeichen zwischen 'A' und 'Z' dann umwandeln 101 c1 = *pStr1; 102 c2 = *pStr2; 103 if ( (c1 >= 65) && (c1 <= 90) ) 104 c1 += 32; 105 if ( (c2 >= 65) && (c2 <= 90) ) 106 c2 += 32; 107 nRet = ((sal_Int32)c1)-((sal_Int32)((unsigned char)c2)); 108 if ( nRet != 0 ) 109 break; 110 111 pStr1++; 112 pStr2++; 113 } 114 while ( c2 ); 115 116 return nRet; 117 } 118 119 // ======================================================================= 120 121 LONG ImplSetWindowLong( HWND hWnd, int nIndex, DWORD dwNewLong ) 122 { 123 return SetWindowLongW( hWnd, nIndex, dwNewLong ); 124 } 125 126 // ----------------------------------------------------------------------- 127 128 LONG ImplGetWindowLong( HWND hWnd, int nIndex ) 129 { 130 return GetWindowLongW( hWnd, nIndex ); 131 } 132 133 // ----------------------------------------------------------------------- 134 135 BOOL ImplPostMessage( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) 136 { 137 return PostMessageW( hWnd, nMsg, wParam, lParam ); 138 } 139 140 // ----------------------------------------------------------------------- 141 142 BOOL ImplSendMessage( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) 143 { 144 BOOL bRet = SendMessageW( hWnd, nMsg, wParam, lParam ); 145 return bRet; 146 } 147 148 // ----------------------------------------------------------------------- 149 150 BOOL ImplGetMessage( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax ) 151 { 152 return GetMessageW( lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax ); 153 } 154 155 // ----------------------------------------------------------------------- 156 157 BOOL ImplPeekMessage( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg ) 158 { 159 return PeekMessageW( lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg ); 160 } 161 162 // ----------------------------------------------------------------------- 163 164 LONG ImplDispatchMessage( CONST MSG *lpMsg ) 165 { 166 return DispatchMessageW( lpMsg ); 167 } 168 169