xref: /AOO41X/main/vcl/win/source/app/saldata.cxx (revision 79aad27f7f29270c03e208e3d687e8e3850af11d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_vcl.hxx"
26 
27 #include "tools/svwin.h"
28 #include "rtl/tencinfo.h"
29 #include "vcl/svapp.hxx"
30 
31 #include "win/saldata.hxx"
32 
33 // =======================================================================
34 
ImplSalGetSystemEncoding()35 rtl_TextEncoding ImplSalGetSystemEncoding()
36 {
37     static UINT nOldAnsiCodePage = 0;
38     static rtl_TextEncoding eEncoding = RTL_TEXTENCODING_MS_1252;
39 
40     UINT nAnsiCodePage = GetACP();
41     if ( nAnsiCodePage != nOldAnsiCodePage )
42     {
43         rtl_TextEncoding nEnc
44             = rtl_getTextEncodingFromWindowsCodePage(nAnsiCodePage);
45         if (nEnc != RTL_TEXTENCODING_DONTKNOW)
46             eEncoding = nEnc;
47     }
48 
49     return eEncoding;
50 }
51 
52 // -----------------------------------------------------------------------
53 
ImplSalGetWinAnsiString(const UniString & rStr,sal_Bool bFileName)54 ByteString ImplSalGetWinAnsiString( const UniString& rStr, sal_Bool bFileName )
55 {
56     rtl_TextEncoding eEncoding = ImplSalGetSystemEncoding();
57     if ( bFileName )
58     {
59         return ByteString( rStr, eEncoding,
60                            RTL_UNICODETOTEXT_FLAGS_UNDEFINED_UNDERLINE |
61                            RTL_UNICODETOTEXT_FLAGS_INVALID_UNDERLINE |
62                            RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |
63                            RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR |
64                            RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 );
65     }
66     else
67     {
68         return ByteString( rStr, eEncoding,
69                            RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT |
70                            RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT |
71                            RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |
72                            RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR |
73                            RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 );
74     }
75 }
76 
77 // -----------------------------------------------------------------------
78 
ImplSalGetUniString(const sal_Char * pStr,xub_StrLen nLen)79 UniString ImplSalGetUniString( const sal_Char* pStr, xub_StrLen nLen )
80 {
81     return UniString( pStr, nLen, ImplSalGetSystemEncoding(),
82                       RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT |
83                       RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |
84                       RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT );
85 }
86 
87 // =======================================================================
88 
ImplSalWICompareAscii(const wchar_t * pStr1,const char * pStr2)89 int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 )
90 {
91     int         nRet;
92     wchar_t     c1;
93     char       c2;
94     do
95     {
96         // Ist das Zeichen zwischen 'A' und 'Z' dann umwandeln
97         c1 = *pStr1;
98         c2 = *pStr2;
99         if ( (c1 >= 65) && (c1 <= 90) )
100             c1 += 32;
101         if ( (c2 >= 65) && (c2 <= 90) )
102             c2 += 32;
103         nRet = ((sal_Int32)c1)-((sal_Int32)((unsigned char)c2));
104         if ( nRet != 0 )
105             break;
106 
107         pStr1++;
108         pStr2++;
109     }
110     while ( c2 );
111 
112     return nRet;
113 }
114 
115 // =======================================================================
116 
ImplSetWindowLong(HWND hWnd,int nIndex,DWORD dwNewLong)117 LONG ImplSetWindowLong( HWND hWnd, int nIndex, DWORD dwNewLong )
118 {
119     return SetWindowLongW( hWnd, nIndex, dwNewLong );
120 }
121 
122 // -----------------------------------------------------------------------
123 
ImplGetWindowLong(HWND hWnd,int nIndex)124 LONG ImplGetWindowLong( HWND hWnd, int nIndex )
125 {
126     return GetWindowLongW( hWnd, nIndex );
127 }
128 
129 // -----------------------------------------------------------------------
130 
ImplPostMessage(HWND hWnd,UINT nMsg,WPARAM wParam,LPARAM lParam)131 BOOL ImplPostMessage( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
132 {
133     return PostMessageW( hWnd, nMsg, wParam, lParam );
134 }
135 
136 // -----------------------------------------------------------------------
137 
ImplSendMessage(HWND hWnd,UINT nMsg,WPARAM wParam,LPARAM lParam)138 BOOL ImplSendMessage( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
139 {
140     BOOL bRet = SendMessageW( hWnd, nMsg, wParam, lParam );
141     return bRet;
142 }
143 
144 // -----------------------------------------------------------------------
145 
ImplGetMessage(LPMSG lpMsg,HWND hWnd,UINT wMsgFilterMin,UINT wMsgFilterMax)146 BOOL ImplGetMessage( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax )
147 {
148     return GetMessageW( lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax );
149 }
150 
151 // -----------------------------------------------------------------------
152 
ImplPeekMessage(LPMSG lpMsg,HWND hWnd,UINT wMsgFilterMin,UINT wMsgFilterMax,UINT wRemoveMsg)153 BOOL ImplPeekMessage( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg )
154 {
155     return PeekMessageW( lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg );
156 }
157 
158 // -----------------------------------------------------------------------
159 
ImplDispatchMessage(CONST MSG * lpMsg)160 LONG ImplDispatchMessage( CONST MSG *lpMsg )
161 {
162     return DispatchMessageW( lpMsg );
163 }
164 
165