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_sfx2.hxx"
26
27
28 #ifdef WNT
29 #ifdef _MSC_VER
30 #pragma warning(disable:4917)
31 #endif
32 #include <shlobj.h>
33
_SHGetSpecialFolderW32(int nFolderID,WCHAR * pszFolder,int nSize)34 static bool _SHGetSpecialFolderW32( int nFolderID, WCHAR* pszFolder, int nSize )
35 {
36 LPITEMIDLIST pidl;
37 HRESULT hHdl = SHGetSpecialFolderLocation( NULL, nFolderID, &pidl );
38
39 if( hHdl == NOERROR )
40 {
41 WCHAR *lpFolder = static_cast< WCHAR* >( HeapAlloc( GetProcessHeap(), 0, 16000 ));
42
43 SHGetPathFromIDListW( pidl, lpFolder );
44 wcsncpy( pszFolder, lpFolder, nSize );
45
46 HeapFree( GetProcessHeap(), 0, lpFolder );
47 IMalloc *pMalloc;
48 if( NOERROR == SHGetMalloc(&pMalloc) )
49 {
50 pMalloc->Free( pidl );
51 pMalloc->Release();
52 }
53 }
54 return true;
55 }
56
57 #endif
58
59 // Copied from sal/types.h to circumvent problems with precompiled headers
60 // and redefinitions of BOOL, INT32 and other types. Unfortunately tools
61 // also define these type incompatible with Win32 types which leads from
62 // time to time to very nasty compilation errors. If someone finds a better
63 // way to solve these probs please remove this copied part!
64 typedef unsigned short sal_uInt16;
65 #if ( defined(WIN32) && !defined(__MINGW32__) )
66 typedef wchar_t sal_Unicode;
67 #else
68 typedef sal_uInt16 sal_Unicode;
69 #endif
70
GetUserTemplateLocation(sal_Unicode * pFolder,int nSize)71 extern "C" bool GetUserTemplateLocation(sal_Unicode* pFolder, int nSize)
72 {
73 #ifdef WNT
74 return _SHGetSpecialFolderW32( CSIDL_TEMPLATES, reinterpret_cast<LPWSTR>(pFolder), nSize );
75 #else
76 (void)pFolder;
77 (void)nSize;
78 return false;
79 #endif
80 }
81