merge the formfield patch from ooo-build
[ooovba.git] / vcl / win / source / app / saldata.cxx
blobefbec4dde0791cf920b1dbe6ed6ef1db5ceda4a4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: saldata.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
33 #include <tools/svwin.h>
34 #include "rtl/tencinfo.h"
35 #include <saldata.hxx>
36 #include <vcl/svapp.hxx>
39 // =======================================================================
41 rtl_TextEncoding ImplSalGetSystemEncoding()
43 static UINT nOldAnsiCodePage = 0;
44 static rtl_TextEncoding eEncoding = RTL_TEXTENCODING_MS_1252;
46 UINT nAnsiCodePage = GetACP();
47 if ( nAnsiCodePage != nOldAnsiCodePage )
49 rtl_TextEncoding nEnc
50 = rtl_getTextEncodingFromWindowsCodePage(nAnsiCodePage);
51 if (nEnc != RTL_TEXTENCODING_DONTKNOW)
52 eEncoding = nEnc;
55 return eEncoding;
58 // -----------------------------------------------------------------------
60 ByteString ImplSalGetWinAnsiString( const UniString& rStr, BOOL bFileName )
62 rtl_TextEncoding eEncoding = ImplSalGetSystemEncoding();
63 if ( bFileName )
65 return ByteString( rStr, eEncoding,
66 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_UNDERLINE |
67 RTL_UNICODETOTEXT_FLAGS_INVALID_UNDERLINE |
68 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |
69 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR |
70 RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 );
72 else
74 return ByteString( rStr, eEncoding,
75 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT |
76 RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT |
77 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |
78 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR |
79 RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 );
83 // -----------------------------------------------------------------------
85 UniString ImplSalGetUniString( const sal_Char* pStr, xub_StrLen nLen )
87 return UniString( pStr, nLen, ImplSalGetSystemEncoding(),
88 RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT |
89 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |
90 RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT );
93 // =======================================================================
95 int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 )
97 int nRet;
98 wchar_t c1;
99 char c2;
102 // Ist das Zeichen zwischen 'A' und 'Z' dann umwandeln
103 c1 = *pStr1;
104 c2 = *pStr2;
105 if ( (c1 >= 65) && (c1 <= 90) )
106 c1 += 32;
107 if ( (c2 >= 65) && (c2 <= 90) )
108 c2 += 32;
109 nRet = ((sal_Int32)c1)-((sal_Int32)((unsigned char)c2));
110 if ( nRet != 0 )
111 break;
113 pStr1++;
114 pStr2++;
116 while ( c2 );
118 return nRet;
121 // =======================================================================
123 LONG ImplSetWindowLong( HWND hWnd, int nIndex, DWORD dwNewLong )
125 if ( aSalShlData.mbWNT )
126 return SetWindowLongW( hWnd, nIndex, dwNewLong );
127 else
128 return SetWindowLongA( hWnd, nIndex, dwNewLong );
131 // -----------------------------------------------------------------------
133 LONG ImplGetWindowLong( HWND hWnd, int nIndex )
135 if ( aSalShlData.mbWNT )
136 return GetWindowLongW( hWnd, nIndex );
137 else
138 return GetWindowLongA( hWnd, nIndex );
141 // -----------------------------------------------------------------------
143 WIN_BOOL ImplPostMessage( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
145 if ( aSalShlData.mbWNT )
146 return PostMessageW( hWnd, nMsg, wParam, lParam );
147 else
148 return PostMessageA( hWnd, nMsg, wParam, lParam );
151 // -----------------------------------------------------------------------
153 WIN_BOOL ImplSendMessage( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
155 WIN_BOOL bRet;
156 if ( aSalShlData.mbWNT )
157 bRet = SendMessageW( hWnd, nMsg, wParam, lParam );
158 else
159 bRet = SendMessageA( hWnd, nMsg, wParam, lParam );
161 return bRet;
164 // -----------------------------------------------------------------------
166 WIN_BOOL ImplGetMessage( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax )
168 if ( aSalShlData.mbWNT )
169 return GetMessageW( lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax );
170 else
171 return GetMessageA( lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax );
174 // -----------------------------------------------------------------------
176 WIN_BOOL ImplPeekMessage( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg )
178 if ( aSalShlData.mbWNT )
179 return PeekMessageW( lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg );
180 else
181 return PeekMessageA( lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg );
184 // -----------------------------------------------------------------------
186 LONG ImplDispatchMessage( CONST MSG *lpMsg )
188 if ( aSalShlData.mbWNT )
189 return DispatchMessageW( lpMsg );
190 else
191 return DispatchMessageA( lpMsg );