xref: /aoo41x/main/sfx2/source/doc/syspathw32.cxx (revision cdf0e10c)
1 /*************************************************************************
2 *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
6 *
7 * OpenOffice.org - a multi-platform office productivity suite
8 *
9 * $RCSfile: shutdowniconw32.cxx,v $
10 * $Revision: 1.48 $
11 *
12 * This file is part of OpenOffice.org.
13 *
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.
17 *
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).
23 *
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.
28 *
29 ************************************************************************/
30 
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
33 
34 
35 #ifdef WNT
36 #ifdef _MSC_VER
37 #pragma warning(disable:4917)
38 #endif
39 #include <shlobj.h>
40 
41 static bool _SHGetSpecialFolderW32( int nFolderID, WCHAR* pszFolder, int nSize )
42 {
43 	LPITEMIDLIST	pidl;
44 	HRESULT			hHdl = SHGetSpecialFolderLocation( NULL, nFolderID, &pidl );
45 
46 	if( hHdl == NOERROR )
47 	{
48 		WCHAR *lpFolder = static_cast< WCHAR* >( HeapAlloc( GetProcessHeap(), 0, 16000 ));
49 
50 		SHGetPathFromIDListW( pidl, lpFolder );
51         wcsncpy( pszFolder, lpFolder, nSize );
52 
53         HeapFree( GetProcessHeap(), 0, lpFolder );
54 		IMalloc	*pMalloc;
55 		if( NOERROR == SHGetMalloc(&pMalloc) )
56 		{
57 			pMalloc->Free( pidl );
58 			pMalloc->Release();
59 		}
60 	}
61 	return true;
62 }
63 
64 #endif
65 
66 // Copied from sal/types.h to circumvent problems with precompiled headers
67 // and redefinitions of BOOL, INT32 and other types. Unfortunately tools
68 // also define these type incompatible with Win32 types which leads from
69 // time to time to very nasty compilation errors. If someone finds a better
70 // way to solve these probs please remove this copied part!
71 typedef unsigned short sal_uInt16;
72 #if ( defined(WIN32) && !defined(__MINGW32__) )
73 	typedef wchar_t             sal_Unicode;
74 #else
75 	typedef sal_uInt16          sal_Unicode;
76 #endif
77 
78 extern "C" bool GetUserTemplateLocation(sal_Unicode* pFolder, int nSize)
79 {
80 #ifdef WNT
81     return _SHGetSpecialFolderW32( CSIDL_TEMPLATES, reinterpret_cast<LPWSTR>(pFolder), nSize );
82 #else
83     (void)pFolder;
84     (void)nSize;
85     return false;
86 #endif
87 }
88