1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include <svpm.h> 29 30 #define _SV_SALSHL_CXX 31 #include <saldata.hxx> 32 #include <tools/debug.hxx> 33 34 // ======================================================================= 35 36 SalShlData aSalShlData; 37 38 HMODULE ImplGetModule(void); 39 static HMODULE mhMod = ImplGetModule(); 40 41 // ======================================================================= 42 43 APIRET APIENTRY DosQueryModFromEIP (HMODULE *phMod, ULONG *pObjNum, 44 ULONG BuffLen, PCHAR pBuff, ULONG *pOffset, ULONG Address); 45 46 HMODULE ImplGetModule(void) 47 { 48 HMODULE hMod; 49 ULONG ObjNum; 50 CHAR Buff[2*_MAX_PATH]; 51 ULONG Offset; 52 APIRET rc; 53 54 // get module handle (and name) 55 rc = DosQueryModFromEIP( &hMod, &ObjNum, sizeof( Buff), Buff, &Offset, (ULONG)ImplGetModule); 56 if (rc) 57 return NULL; 58 // return module handle 59 aSalShlData.mhMod = hMod; 60 return hMod; 61 } 62 63 // ======================================================================= 64 65 HPOINTER ImplLoadSalCursor( int nId ) 66 { 67 DBG_ASSERT( aSalShlData.mhMod, "no DLL instance handle" ); 68 69 HPOINTER hPointer = WinLoadPointer( HWND_DESKTOP, aSalShlData.mhMod, nId ); 70 71 DBG_ASSERT( hPointer, "pointer not found in sal resource" ); 72 #if OSL_DEBUG_LEVEL>0 73 if (!hPointer) 74 debug_printf( "ImplLoadSalCursor: pointer %d not found in sal resource\n", nId); 75 #endif 76 return hPointer; 77 } 78 79 // ----------------------------------------------------------------------- 80 81 BOOL ImplLoadSalIcon( int nId, HPOINTER& rIcon) 82 { 83 DBG_ASSERT( aSalShlData.mhMod, "no DLL instance handle" ); 84 85 SalData* pSalData = GetSalData(); 86 87 // check the cache first 88 SalIcon *pSalIcon = pSalData->mpFirstIcon; 89 while( pSalIcon ) 90 { 91 if( pSalIcon->nId != nId ) 92 pSalIcon = pSalIcon->pNext; 93 else 94 { 95 rIcon = pSalIcon->hIcon; 96 return (rIcon != 0); 97 } 98 } 99 100 // Try at first to load the icons from the application exe file 101 rIcon = WinLoadPointer( HWND_DESKTOP, NULL, nId ); 102 if ( !rIcon ) 103 { 104 // If the application don't provide these icons, then we try 105 // to load the icon from the VCL resource 106 rIcon = WinLoadPointer( HWND_DESKTOP, aSalShlData.mhMod, nId ); 107 } 108 109 if( rIcon ) 110 { 111 // add to icon cache 112 pSalIcon = new SalIcon(); 113 pSalIcon->nId = nId; 114 pSalIcon->hIcon = rIcon; 115 pSalIcon->pNext = pSalData->mpFirstIcon; 116 pSalData->mpFirstIcon = pSalIcon; 117 } 118 119 return (rIcon != 0); 120 } 121 122 // ======================================================================= 123 124