summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorChristian Lippka <christian.lippka@sun.com>2010-06-29 14:58:20 +0200
committerChristian Lippka <christian.lippka@sun.com>2010-06-29 14:58:20 +0200
commit7e954cc28b29865b3495fe496ed3010e89e04d3d (patch)
tree7a959b0e25895b435e69e7bac41a1286562853b0 /sd
parentff963981470616f9d43448ed6237e85648d3698a (diff)
#i112758# better fix to free static bitmaps on vcl deinit
Diffstat (limited to 'sd')
-rwxr-xr-xsd/source/ui/inc/view/viewoverlaymanager.hxx3
-rwxr-xr-xsd/source/ui/view/viewoverlaymanager.cxx76
2 files changed, 47 insertions, 32 deletions
diff --git a/sd/source/ui/inc/view/viewoverlaymanager.hxx b/sd/source/ui/inc/view/viewoverlaymanager.hxx
index ea6b27dc09f3..32820c1f27a7 100755
--- a/sd/source/ui/inc/view/viewoverlaymanager.hxx
+++ b/sd/source/ui/inc/view/viewoverlaymanager.hxx
@@ -59,9 +59,6 @@ public:
virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint);
- static BitmapEx* maLargeButtonImages[BMP_PLACEHOLDER_LARGE_END - BMP_PLACEHOLDER_LARGE_START];
- static BitmapEx* maSmallButtonImages[BMP_PLACEHOLDER_SMALL_END - BMP_PLACEHOLDER_SMALL_START];
-
private:
void UpdateImages();
diff --git a/sd/source/ui/view/viewoverlaymanager.cxx b/sd/source/ui/view/viewoverlaymanager.cxx
index 106cfb4f6d51..eb75a7a60f14 100755
--- a/sd/source/ui/view/viewoverlaymanager.cxx
+++ b/sd/source/ui/view/viewoverlaymanager.cxx
@@ -45,6 +45,7 @@
#include <vcl/help.hxx>
#include <vcl/imagerepository.hxx>
+#include <vcl/lazydelete.hxx>
#include <svx/sdrpagewindow.hxx>
#include <svx/sdrpaintwindow.hxx>
@@ -79,8 +80,17 @@ class ImageButtonHdl;
// --------------------------------------------------------------------
-BitmapEx* ViewOverlayManager::maSmallButtonImages[BMP_PLACEHOLDER_SMALL_END - BMP_PLACEHOLDER_SMALL_START] = { 0, 0, 0, 0 };
-BitmapEx* ViewOverlayManager::maLargeButtonImages[BMP_PLACEHOLDER_LARGE_END - BMP_PLACEHOLDER_LARGE_START] = { 0, 0, 0, 0 };
+static BitmapEx ** getLargeButtonImages()
+{
+ for( sal_uInt16 i = 0; i < (BMP_PLACEHOLDER_SMALL_END-BMP_PLACEHOLDER_SMALL_START); i++ )
+ {
+ delete getSmallButtonImages()[i].set( new BitmapEx( loadImageResource( BMP_PLACEHOLDER_SMALL_START + i ) ) );
+ delete getLargeButtonImages()[i].set( new BitmapEx( loadImageResource( BMP_PLACEHOLDER_LARGE_START + i ) ) );
+ }
+ return &gLargeButtonImages[0];
+}
+
+// --------------------------------------------------------------------
static USHORT gButtonSlots[] = { SID_INSERT_TABLE, SID_INSERT_DIAGRAM, SID_INSERT_GRAPHIC, SID_INSERT_AVMEDIA };
static USHORT gButtonToolTips[] = { STR_INSERT_TABLE, STR_INSERT_CHART, STR_INSERT_PICTURE, STR_INSERT_MOVIE };
@@ -97,6 +107,32 @@ static BitmapEx loadImageResource( USHORT nId )
// --------------------------------------------------------------------
+static BitmapEx* getButtonImage( int index, bool large )
+{
+ static vcl::DeleteOnDeinit< BitmapEx > gSmallButtonImages[BMP_PLACEHOLDER_SMALL_END - BMP_PLACEHOLDER_SMALL_START] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ static vcl::DeleteOnDeinit< BitmapEx > gLargeButtonImages[BMP_PLACEHOLDER_LARGE_END - BMP_PLACEHOLDER_LARGE_START] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+
+ if( !gSmallButtonImages[0].get() )
+ {
+ for( sal_uInt16 i = 0; i < (BMP_PLACEHOLDER_SMALL_END-BMP_PLACEHOLDER_SMALL_START); i++ )
+ {
+ gSmallButtonImages[i].set( new BitmapEx( loadImageResource( BMP_PLACEHOLDER_SMALL_START + i ) ) );
+ gLargeButtonImages[i].set( new BitmapEx( loadImageResource( BMP_PLACEHOLDER_LARGE_START + i ) ) );
+ }
+ }
+
+ if( large )
+ {
+ return gLargeButtonImages[index].get();
+ }
+ else
+ {
+ return gSmallButtonImages[index].get();
+ }
+}
+
+// --------------------------------------------------------------------
+
const sal_uInt32 SMART_TAG_HDL_NUM = SAL_MAX_UINT32;
class ChangePlaceholderTag : public SmartTag
@@ -374,20 +410,20 @@ BitmapEx ChangePlaceholderTag::createOverlayImage( int nHighlight )
Size aShapeSizePix = pDev->LogicToPixel(rSnapRect.GetSize());
long nShapeSizePix = std::min(aShapeSizePix.Width(),aShapeSizePix.Height());
- BitmapEx** ppImages = (nShapeSizePix > 250) ? &ViewOverlayManager::maLargeButtonImages[0] : &ViewOverlayManager::maSmallButtonImages[0];
+ bool bLarge = (nShapeSizePix > 250;
- Size aSize( ppImages[0]->GetSizePixel() );
+ Size aSize( ppImages[0].get()->GetSizePixel() );
aRet.SetSizePixel( Size( aSize.Width() << 1, aSize.Height() << 1 ) );
const Rectangle aRectSrc( Point( 0, 0 ), aSize );
- aRet = *(ppImages[(nHighlight == 0) ? 4 : 0]);
+ aRet = *(ppImages[(nHighlight == 0) ? 4 : 0].get());
aRet.Expand( aSize.Width(), aSize.Height(), NULL, TRUE );
- aRet.CopyPixel( Rectangle( Point( aSize.Width(), 0 ), aSize ), aRectSrc, ppImages[(nHighlight == 1) ? 5 : 1] );
- aRet.CopyPixel( Rectangle( Point( 0, aSize.Height() ), aSize ), aRectSrc, ppImages[(nHighlight == 2) ? 6 : 2] );
- aRet.CopyPixel( Rectangle( Point( aSize.Width(), aSize.Height() ), aSize ), aRectSrc, ppImages[(nHighlight == 3) ? 7 : 3] );
+ aRet.CopyPixel( Rectangle( Point( aSize.Width(), 0 ), aSize ), aRectSrc, ppImages[(nHighlight == 1) ? 5 : 1].get() );
+ aRet.CopyPixel( Rectangle( Point( 0, aSize.Height() ), aSize ), aRectSrc, ppImages[(nHighlight == 2) ? 6 : 2].get() );
+ aRet.CopyPixel( Rectangle( Point( aSize.Width(), aSize.Height() ), aSize ), aRectSrc, ppImages[(nHighlight == 3) ? 7 : 3].get() );
}
return aRet;
@@ -411,9 +447,9 @@ void ChangePlaceholderTag::addCustomHandles( SdrHdlList& rHandlerList )
if( 50 > nShapeSizePix )
return;
- BitmapEx* pImages = (nShapeSizePix > 250) ? ViewOverlayManager::maLargeButtonImages[0] : ViewOverlayManager::maSmallButtonImages[0];
+ vcl::DeleteOnDeinit< BitmapEx >* pImages = (nShapeSizePix > 250) ? getLargeButtonImages() : getSmallButtonImages();
- Size aButtonSize( pDev->PixelToLogic(pImages->GetSizePixel()) );
+ Size aButtonSize( pDev->PixelToLogic(pImages[0].get()->GetSizePixel()) );
const int nColumns = 2;
const int nRows = 2;
@@ -490,24 +526,6 @@ ViewOverlayManager::~ViewOverlayManager()
// --------------------------------------------------------------------
-void ViewOverlayManager::UpdateImages()
-{
- for( sal_uInt16 i = 0; i < (BMP_PLACEHOLDER_SMALL_END-BMP_PLACEHOLDER_SMALL_START); i++ )
- {
- if( maSmallButtonImages[i] )
- delete maSmallButtonImages[i];
-
- maSmallButtonImages[i] = new BitmapEx( loadImageResource( BMP_PLACEHOLDER_SMALL_START + i ) );
-
- if( maLargeButtonImages[i] )
- delete maLargeButtonImages[i];
-
- maLargeButtonImages[i] = new BitmapEx( loadImageResource( BMP_PLACEHOLDER_LARGE_START + i ) );
- }
-}
-
-// --------------------------------------------------------------------
-
void ViewOverlayManager::Notify(SfxBroadcaster&, const SfxHint& rHint)
{
const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
@@ -555,7 +573,7 @@ bool ViewOverlayManager::CreateTags()
if( pPage )
{
- if( !maSmallButtonImages[0] )
+ if( !getSmallButtonImages()[0].get() )
UpdateImages();
const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList();