calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / vcl / win / app / salshl.cxx
blob5619ece1f05750627c51ee2ab7c1a59d4bd9ed57
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svsys.h>
21 #include <sal/log.hxx>
22 #include <win/saldata.hxx>
24 SalShlData aSalShlData;
26 extern "C" BOOL WINAPI DllMain(HINSTANCE hInst, DWORD nReason, LPVOID)
28 if ( nReason == DLL_PROCESS_ATTACH )
29 aSalShlData.mhInst = hInst;
30 return 1;
33 HCURSOR ImplLoadSalCursor( int nId )
35 SAL_WARN_IF( !aSalShlData.mhInst, "vcl", "no DLL instance handle" );
37 HCURSOR hCursor = LoadCursorW( aSalShlData.mhInst, MAKEINTRESOURCEW( nId ) );
39 SAL_WARN_IF( !hCursor, "vcl", "cursor not found in sal resource" );
41 return hCursor;
44 HBITMAP ImplLoadSalBitmap( int nId )
46 SAL_WARN_IF( !aSalShlData.mhInst, "vcl", "no DLL instance handle" );
48 HBITMAP hBitmap = LoadBitmapW( aSalShlData.mhInst, MAKEINTRESOURCEW( nId ) );
50 SAL_WARN_IF( !hBitmap, "vcl", "bitmap not found in sal resource" );
52 return hBitmap;
55 bool ImplLoadSalIcon( int nId, HICON& rIcon, HICON& rSmallIcon )
57 SAL_WARN_IF( !aSalShlData.mhInst, "vcl", "no DLL instance handle" );
59 SalData* pSalData = GetSalData();
61 // check the cache first
62 SalIcon *pSalIcon = pSalData->mpFirstIcon;
63 while( pSalIcon )
65 if( pSalIcon->nId != nId )
66 pSalIcon = pSalIcon->pNext;
67 else
69 rIcon = pSalIcon->hIcon;
70 rSmallIcon = pSalIcon->hSmallIcon;
71 return (rSmallIcon != nullptr);
75 // Try at first to load the icons from the application exe file
76 rIcon = static_cast<HICON>(LoadImageW( pSalData->mhInst, MAKEINTRESOURCEW( nId ),
77 IMAGE_ICON, GetSystemMetrics( SM_CXICON ), GetSystemMetrics( SM_CYICON ),
78 LR_DEFAULTCOLOR ));
79 if ( !rIcon )
81 // If the application don't provide these icons, then we try
82 // to load the icon from the VCL resource
83 rIcon = static_cast<HICON>(LoadImageW( aSalShlData.mhInst, MAKEINTRESOURCEW( nId ),
84 IMAGE_ICON, GetSystemMetrics( SM_CXICON ), GetSystemMetrics( SM_CYICON ),
85 LR_DEFAULTCOLOR ));
86 if ( rIcon )
88 rSmallIcon = static_cast<HICON>(LoadImageW( aSalShlData.mhInst, MAKEINTRESOURCEW( nId ),
89 IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
90 LR_DEFAULTCOLOR ));
92 else
93 rSmallIcon = nullptr;
95 else
97 rSmallIcon = static_cast<HICON>(LoadImageW( pSalData->mhInst, MAKEINTRESOURCEW( nId ),
98 IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
99 LR_DEFAULTCOLOR ));
102 if( rIcon )
104 // add to icon cache
105 pSalData->mpFirstIcon = new SalIcon{
106 nId, rIcon, rSmallIcon, pSalData->mpFirstIcon};
109 return (rSmallIcon != nullptr);
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */