merge the formfield patch from ooo-build
[ooovba.git] / vcl / os2 / source / app / salshl.cxx
blob92cee12d93266609318c867b5acae9a4511253b3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salshl.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
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.
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).
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.
29 ************************************************************************/
31 #include <svpm.h>
33 #define _SV_SALSHL_CXX
34 #include <saldata.hxx>
35 #include <tools/debug.hxx>
37 // =======================================================================
39 SalShlData aSalShlData;
41 HMODULE ImplGetModule(void);
42 static HMODULE mhMod = ImplGetModule();
44 // =======================================================================
46 APIRET APIENTRY DosQueryModFromEIP (HMODULE *phMod, ULONG *pObjNum,
47 ULONG BuffLen, PCHAR pBuff, ULONG *pOffset, ULONG Address);
49 HMODULE ImplGetModule(void)
51 HMODULE hMod;
52 ULONG ObjNum;
53 CHAR Buff[2*_MAX_PATH];
54 ULONG Offset;
55 APIRET rc;
57 // get module handle (and name)
58 rc = DosQueryModFromEIP( &hMod, &ObjNum, sizeof( Buff), Buff, &Offset, (ULONG)ImplGetModule);
59 if (rc)
60 return NULL;
61 // return module handle
62 aSalShlData.mhMod = hMod;
63 return hMod;
66 // =======================================================================
68 HPOINTER ImplLoadSalCursor( int nId )
70 DBG_ASSERT( aSalShlData.mhMod, "no DLL instance handle" );
72 HPOINTER hPointer = WinLoadPointer( HWND_DESKTOP, aSalShlData.mhMod, nId );
74 DBG_ASSERT( hPointer, "pointer not found in sal resource" );
75 #if OSL_DEBUG_LEVEL>0
76 if (!hPointer)
77 debug_printf( "ImplLoadSalCursor: pointer %d not found in sal resource\n", nId);
78 #endif
79 return hPointer;
82 // -----------------------------------------------------------------------
84 BOOL ImplLoadSalIcon( int nId, HPOINTER& rIcon)
86 DBG_ASSERT( aSalShlData.mhMod, "no DLL instance handle" );
88 SalData* pSalData = GetSalData();
90 // check the cache first
91 SalIcon *pSalIcon = pSalData->mpFirstIcon;
92 while( pSalIcon )
94 if( pSalIcon->nId != nId )
95 pSalIcon = pSalIcon->pNext;
96 else
98 rIcon = pSalIcon->hIcon;
99 return (rIcon != 0);
103 // Try at first to load the icons from the application exe file
104 rIcon = WinLoadPointer( HWND_DESKTOP, NULL, nId );
105 if ( !rIcon )
107 // If the application don't provide these icons, then we try
108 // to load the icon from the VCL resource
109 rIcon = WinLoadPointer( HWND_DESKTOP, aSalShlData.mhMod, nId );
112 if( rIcon )
114 // add to icon cache
115 pSalIcon = new SalIcon();
116 pSalIcon->nId = nId;
117 pSalIcon->hIcon = rIcon;
118 pSalIcon->pNext = pSalData->mpFirstIcon;
119 pSalData->mpFirstIcon = pSalIcon;
122 return (rIcon != 0);
125 // =======================================================================