1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2008 by Sun Microsystems, Inc. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * $RCSfile: shutdowniconw32.cxx,v $ 10*cdf0e10cSrcweir * $Revision: 1.48 $ 11*cdf0e10cSrcweir * 12*cdf0e10cSrcweir * This file is part of OpenOffice.org. 13*cdf0e10cSrcweir * 14*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 15*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 16*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 17*cdf0e10cSrcweir * 18*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 19*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 20*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 22*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 23*cdf0e10cSrcweir * 24*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 25*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 26*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 27*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 28*cdf0e10cSrcweir * 29*cdf0e10cSrcweir ************************************************************************/ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 32*cdf0e10cSrcweir #include "precompiled_sfx2.hxx" 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #ifdef WNT 36*cdf0e10cSrcweir #ifdef _MSC_VER 37*cdf0e10cSrcweir #pragma warning(disable:4917) 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir #include <shlobj.h> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir static bool _SHGetSpecialFolderW32( int nFolderID, WCHAR* pszFolder, int nSize ) 42*cdf0e10cSrcweir { 43*cdf0e10cSrcweir LPITEMIDLIST pidl; 44*cdf0e10cSrcweir HRESULT hHdl = SHGetSpecialFolderLocation( NULL, nFolderID, &pidl ); 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir if( hHdl == NOERROR ) 47*cdf0e10cSrcweir { 48*cdf0e10cSrcweir WCHAR *lpFolder = static_cast< WCHAR* >( HeapAlloc( GetProcessHeap(), 0, 16000 )); 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir SHGetPathFromIDListW( pidl, lpFolder ); 51*cdf0e10cSrcweir wcsncpy( pszFolder, lpFolder, nSize ); 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir HeapFree( GetProcessHeap(), 0, lpFolder ); 54*cdf0e10cSrcweir IMalloc *pMalloc; 55*cdf0e10cSrcweir if( NOERROR == SHGetMalloc(&pMalloc) ) 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir pMalloc->Free( pidl ); 58*cdf0e10cSrcweir pMalloc->Release(); 59*cdf0e10cSrcweir } 60*cdf0e10cSrcweir } 61*cdf0e10cSrcweir return true; 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir #endif 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir // Copied from sal/types.h to circumvent problems with precompiled headers 67*cdf0e10cSrcweir // and redefinitions of BOOL, INT32 and other types. Unfortunately tools 68*cdf0e10cSrcweir // also define these type incompatible with Win32 types which leads from 69*cdf0e10cSrcweir // time to time to very nasty compilation errors. If someone finds a better 70*cdf0e10cSrcweir // way to solve these probs please remove this copied part! 71*cdf0e10cSrcweir typedef unsigned short sal_uInt16; 72*cdf0e10cSrcweir #if ( defined(WIN32) && !defined(__MINGW32__) ) 73*cdf0e10cSrcweir typedef wchar_t sal_Unicode; 74*cdf0e10cSrcweir #else 75*cdf0e10cSrcweir typedef sal_uInt16 sal_Unicode; 76*cdf0e10cSrcweir #endif 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir extern "C" bool GetUserTemplateLocation(sal_Unicode* pFolder, int nSize) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir #ifdef WNT 81*cdf0e10cSrcweir return _SHGetSpecialFolderW32( CSIDL_TEMPLATES, reinterpret_cast<LPWSTR>(pFolder), nSize ); 82*cdf0e10cSrcweir #else 83*cdf0e10cSrcweir (void)pFolder; 84*cdf0e10cSrcweir (void)nSize; 85*cdf0e10cSrcweir return false; 86*cdf0e10cSrcweir #endif 87*cdf0e10cSrcweir } 88