xref: /aoo41x/main/sd/source/ui/view/bmcache.cxx (revision cdf0e10c)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 
32 #include <limits.h>     // LONG_MAX
33 #include <tools/solar.h>
34 #include <svtools/grfmgr.hxx>
35 #include "bmcache.hxx"
36 
37 // eine Struktur fuer die Cache-Eintraege
38 struct BitmapCacheEntry
39 {
40 	const SdPage*   pPage;
41     GraphicObject*  pGraphicObject;
42     sal_uInt32      nSizeBytes;
43 	long		    nZoom;
44 };
45 
46 /*************************************************************************
47 |*
48 |* Destruktor, loescht die gespeicherten Bitmaps
49 |*
50 \************************************************************************/
51 
52 BitmapCache::~BitmapCache()
53 {
54     for( void* pEntry = aEntries.First();  pEntry; pEntry = aEntries.Next() )
55     {
56 		delete static_cast< BitmapCacheEntry* >( pEntry )->pGraphicObject;
57 		delete static_cast< BitmapCacheEntry* >( pEntry );
58     }
59 }
60 
61 void BitmapCache::Remove( const SdPage* pPage )
62 {
63 	for( sal_uLong nPos = 0; nPos < aEntries.Count();  )
64 	{
65 		BitmapCacheEntry* pCand = (BitmapCacheEntry*) aEntries.GetObject( nPos );
66 
67 		if( pCand->pPage == pPage )
68 		{
69 			pCand = (BitmapCacheEntry*) aEntries.Remove((sal_uLong)nPos);
70 			delete pCand->pGraphicObject;
71 			delete pCand;
72 		}
73 		else
74 			nPos++;
75 	}
76 }
77 
78 
79