1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: saldata.cxx,v $
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
)
50 = rtl_getTextEncodingFromWindowsCodePage(nAnsiCodePage
);
51 if (nEnc
!= RTL_TEXTENCODING_DONTKNOW
)
58 // -----------------------------------------------------------------------
60 ByteString
ImplSalGetWinAnsiString( const UniString
& rStr
, BOOL bFileName
)
62 rtl_TextEncoding eEncoding
= ImplSalGetSystemEncoding();
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
);
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
)
102 // Ist das Zeichen zwischen 'A' und 'Z' dann umwandeln
105 if ( (c1
>= 65) && (c1
<= 90) )
107 if ( (c2
>= 65) && (c2
<= 90) )
109 nRet
= ((sal_Int32
)c1
)-((sal_Int32
)((unsigned char)c2
));
121 // =======================================================================
123 LONG
ImplSetWindowLong( HWND hWnd
, int nIndex
, DWORD dwNewLong
)
125 if ( aSalShlData
.mbWNT
)
126 return SetWindowLongW( hWnd
, nIndex
, dwNewLong
);
128 return SetWindowLongA( hWnd
, nIndex
, dwNewLong
);
131 // -----------------------------------------------------------------------
133 LONG
ImplGetWindowLong( HWND hWnd
, int nIndex
)
135 if ( aSalShlData
.mbWNT
)
136 return GetWindowLongW( hWnd
, nIndex
);
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
);
148 return PostMessageA( hWnd
, nMsg
, wParam
, lParam
);
151 // -----------------------------------------------------------------------
153 WIN_BOOL
ImplSendMessage( HWND hWnd
, UINT nMsg
, WPARAM wParam
, LPARAM lParam
)
156 if ( aSalShlData
.mbWNT
)
157 bRet
= SendMessageW( hWnd
, nMsg
, wParam
, lParam
);
159 bRet
= SendMessageA( hWnd
, nMsg
, wParam
, lParam
);
164 // -----------------------------------------------------------------------
166 WIN_BOOL
ImplGetMessage( LPMSG lpMsg
, HWND hWnd
, UINT wMsgFilterMin
, UINT wMsgFilterMax
)
168 if ( aSalShlData
.mbWNT
)
169 return GetMessageW( lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
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
);
181 return PeekMessageA( lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
, wRemoveMsg
);
184 // -----------------------------------------------------------------------
186 LONG
ImplDispatchMessage( CONST MSG
*lpMsg
)
188 if ( aSalShlData
.mbWNT
)
189 return DispatchMessageW( lpMsg
);
191 return DispatchMessageA( lpMsg
);