[Libreoffice-commits] .: 40 commits - desktop/source desktop/unx drawinglayer/source editeng/inc editeng/source framework/source linguistic/source sfx2/inc sfx2/source svx/inc svx/source xmloff/source

Caolán McNamara caolan at kemper.freedesktop.org
Fri May 20 08:37:15 PDT 2011


 desktop/source/app/app.cxx                                  |   21 +
 desktop/source/app/dispatchwatcher.cxx                      |   17 -
 desktop/source/app/dispatchwatcher.hxx                      |    2 
 desktop/source/app/officeipcthread.cxx                      |   24 -
 desktop/source/app/officeipcthread.hxx                      |    1 
 desktop/unx/source/start.c                                  |   20 -
 drawinglayer/source/primitive2d/textlayoutdevice.cxx        |   61 ++--
 editeng/inc/editeng/acorrcfg.hxx                            |    2 
 editeng/inc/editeng/eerdll.hxx                              |    6 
 editeng/source/editeng/editdoc.cxx                          |    3 
 editeng/source/editeng/editeng.cxx                          |    2 
 editeng/source/editeng/editobj.cxx                          |    6 
 editeng/source/editeng/editview.cxx                         |    4 
 editeng/source/editeng/eerdll.cxx                           |   32 --
 editeng/source/editeng/eerdll2.hxx                          |    3 
 editeng/source/editeng/impedit2.cxx                         |   12 
 editeng/source/items/frmitems.cxx                           |    2 
 editeng/source/misc/acorrcfg.cxx                            |   21 -
 editeng/source/rtf/rtfgrf.cxx                               |    8 
 framework/source/fwe/classes/addonsoptions.cxx              |    4 
 framework/source/layoutmanager/layoutmanager.cxx            |    3 
 framework/source/services/desktop.cxx                       |    2 
 framework/source/services/frame.cxx                         |    3 
 framework/source/uielement/imagebuttontoolbarcontroller.cxx |    4 
 linguistic/source/dlistimp.cxx                              |    1 
 linguistic/source/lngsvcmgr.cxx                             |   25 -
 sfx2/inc/sfx2/fcontnr.hxx                                   |   13 
 sfx2/source/appl/app.cxx                                    |  182 +++++-------
 sfx2/source/appl/appinit.cxx                                |   14 
 sfx2/source/appl/appmisc.cxx                                |    4 
 sfx2/source/appl/appquit.cxx                                |    8 
 sfx2/source/appl/fileobj.cxx                                |   12 
 sfx2/source/appl/opengrf.cxx                                |   20 -
 sfx2/source/appl/sfxpicklist.cxx                            |   59 +--
 sfx2/source/bastyp/fltfnc.cxx                               |  154 +++++-----
 sfx2/source/doc/docfac.cxx                                  |    2 
 sfx2/source/doc/objcont.cxx                                 |    6 
 sfx2/source/doc/objmisc.cxx                                 |    2 
 sfx2/source/inc/appdata.hxx                                 |    7 
 sfx2/source/inc/sfxpicklist.hxx                             |    7 
 sfx2/source/menu/virtmenu.cxx                               |    4 
 sfx2/source/toolbox/imgmgr.cxx                              |   94 +++---
 svx/inc/svx/svxerr.hxx                                      |    4 
 svx/inc/svx/xtable.hxx                                      |    2 
 svx/source/gallery2/galbrws2.cxx                            |    6 
 svx/source/gallery2/galctrl.cxx                             |    6 
 svx/source/gallery2/galmisc.cxx                             |    8 
 svx/source/items/svxerr.cxx                                 |   15 
 svx/source/svdraw/svdograf.cxx                              |   10 
 svx/source/unodraw/UnoGraphicExporter.cxx                   |   28 -
 svx/source/unodraw/unoshap2.cxx                             |    6 
 svx/source/xml/xmlgrhlp.cxx                                 |   16 -
 svx/source/xoutdev/_xoutbmp.cxx                             |   12 
 svx/source/xoutdev/xtabcolr.cxx                             |   13 
 xmloff/source/transform/TransformerBase.cxx                 |    4 
 55 files changed, 517 insertions(+), 490 deletions(-)

New commits:
commit 1e3b37905b803960b3c7f047ee5c4cec91a3db71
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 20 09:10:56 2011 +0100

    make these a well-behaved non-leaky singleton

diff --git a/sfx2/source/toolbox/imgmgr.cxx b/sfx2/source/toolbox/imgmgr.cxx
index 9744d4b..cb4eefe 100644
--- a/sfx2/source/toolbox/imgmgr.cxx
+++ b/sfx2/source/toolbox/imgmgr.cxx
@@ -31,6 +31,7 @@
 
 #include <stdio.h>
 #include <boost/unordered_map.hpp>
+#include <boost/shared_ptr.hpp>
 
 #include "sfx2/imgmgr.hxx"
 #include <sfx2/sfx.hrc>
@@ -60,54 +61,46 @@ struct ToolBoxInf_Impl
 class SfxImageManager_Impl
 {
 public:
-    sal_Int16                       m_nSymbolsSize;
-    SvtMiscOptions		            m_aOpt;
+    SvtMiscOptions                  m_aOpt;
     std::vector< ToolBoxInf_Impl* > m_aToolBoxes;
+    sal_Int16                       m_nSymbolsSize;
     ImageList*                      m_pImageList[IMAGELIST_COUNT];
     SfxModule*                      m_pModule;
+    bool                            m_bAppEventListener;
 
     ImageList*              GetImageList( bool bBig );
     Image                   GetImage( sal_uInt16 nId, bool bBig );
     void                    SetSymbolsSize_Impl( sal_Int16 );
     
     DECL_LINK( OptionsChanged_Impl, void* );
-    DECL_LINK( SettingsChanged_Impl, void* );
+    DECL_LINK( SettingsChanged_Impl, VclWindowEvent* );
 
     
     SfxImageManager_Impl( SfxModule* pModule );
     ~SfxImageManager_Impl();
 };
 
-typedef boost::unordered_map< sal_Int64, sal_Int64 > SfxImageManagerMap;
-
-// global image lists
-static SfxImageManager_Impl* pGlobalImageManager = 0;
-static SfxImageManagerMap    m_ImageManager_ImplMap;
-static SfxImageManagerMap    m_ImageManagerMap;
-
 static SfxImageManager_Impl* GetImageManager( SfxModule* pModule )
 {
     SolarMutexGuard aGuard;
 
     if ( pModule == 0 )
     {
-        if ( !pGlobalImageManager )
-            pGlobalImageManager = new SfxImageManager_Impl( 0 );
-        return pGlobalImageManager;
+        static SfxImageManager_Impl aGlobalImageManager(0);
+        return &aGlobalImageManager;
     }
     else
     {
+        typedef boost::unordered_map< SfxModule*, boost::shared_ptr<SfxImageManager_Impl> > SfxImageManagerImplMap;
+        static SfxImageManagerImplMap  m_ImageManager_ImplMap;
         SfxImageManager_Impl* pImpl( 0 );
-        SfxImageManagerMap::const_iterator pIter = m_ImageManager_ImplMap.find( sal::static_int_cast< sal_Int64>( reinterpret_cast< sal_IntPtr >( pModule )));
+        SfxImageManagerImplMap::const_iterator pIter = m_ImageManager_ImplMap.find(pModule);
         if ( pIter != m_ImageManager_ImplMap.end() )
-            pImpl = reinterpret_cast< SfxImageManager_Impl* >( sal::static_int_cast< sal_IntPtr >( pIter->second ));
+            pImpl = pIter->second.get();
         else
         {
-            pImpl = new SfxImageManager_Impl( pModule );
-            m_ImageManager_ImplMap.insert(
-                SfxImageManagerMap::value_type(
-                    sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( pModule )),
-                    sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( pImpl )) ));
+            m_ImageManager_ImplMap[pModule].reset(new SfxImageManager_Impl(pModule));
+            pImpl = m_ImageManager_ImplMap[pModule].get();
         }
         return pImpl;
     }
@@ -145,15 +138,18 @@ static sal_Int16 impl_convertBools( sal_Bool bLarge )
 
 //=========================================================================
 
-SfxImageManager_Impl::SfxImageManager_Impl( SfxModule* pModule ) :
-    m_nSymbolsSize( SvtMiscOptions().GetCurrentSymbolsSize() ),
-    m_pModule( pModule )
+SfxImageManager_Impl::SfxImageManager_Impl( SfxModule* pModule )
+    : m_pModule(pModule)
+    , m_bAppEventListener(false)
 {
+    m_nSymbolsSize = m_aOpt.GetCurrentSymbolsSize();
+
     for ( sal_uInt32 i = 0; i < IMAGELIST_COUNT; i++ )
         m_pImageList[i] = 0;
     
     m_aOpt.AddListenerLink( LINK( this, SfxImageManager_Impl, OptionsChanged_Impl ) );
     Application::AddEventListener( LINK( this, SfxImageManager_Impl, SettingsChanged_Impl ) );
+    m_bAppEventListener = true;
 }
 
 //-------------------------------------------------------------------------
@@ -161,8 +157,8 @@ SfxImageManager_Impl::SfxImageManager_Impl( SfxModule* pModule ) :
 SfxImageManager_Impl::~SfxImageManager_Impl()
 {
     m_aOpt.RemoveListenerLink( LINK( this, SfxImageManager_Impl, OptionsChanged_Impl ) );
-    Application::RemoveEventListener( LINK( this, SfxImageManager_Impl, SettingsChanged_Impl ) );
-
+    if (m_bAppEventListener)
+        Application::RemoveEventListener( LINK( this, SfxImageManager_Impl, SettingsChanged_Impl ) );
     for ( sal_uInt32 i = 0; i < m_aToolBoxes.size(); i++ )
         delete m_aToolBoxes[i];
 }
@@ -243,18 +239,37 @@ void SfxImageManager_Impl::SetSymbolsSize_Impl( sal_Int16 nNewSymbolsSize )
 
 IMPL_LINK( SfxImageManager_Impl, OptionsChanged_Impl, void*, EMPTYARG )
 {
-    SetSymbolsSize_Impl( SvtMiscOptions().GetCurrentSymbolsSize() );
+    SetSymbolsSize_Impl( m_aOpt.GetCurrentSymbolsSize() );
     return 0L;
 }
 
 //-------------------------------------------------------------------------
 
-IMPL_LINK( SfxImageManager_Impl, SettingsChanged_Impl, void*, EMPTYARG )
+IMPL_LINK( SfxImageManager_Impl, SettingsChanged_Impl, VclWindowEvent*, pEvent)
 {
-    // Check if toolbar button size have changed and we have to use system settings
-    sal_Int16 nSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize();
-    if ( m_nSymbolsSize != nSymbolsSize )
-        SetSymbolsSize_Impl( nSymbolsSize );
+    if (pEvent)
+    {
+        switch (pEvent->GetId())
+        {
+            case VCLEVENT_OBJECT_DYING:
+                if (m_bAppEventListener)
+                {
+                    Application::RemoveEventListener( LINK( this, SfxImageManager_Impl, SettingsChanged_Impl ) );
+                    m_bAppEventListener = false;
+                }
+                break;
+            case VCLEVENT_APPLICATION_DATACHANGED:
+                // Check if toolbar button size have changed and we have to use system settings
+                {
+                    sal_Int16 nSymbolsSize = m_aOpt.GetCurrentSymbolsSize();
+                    if (m_nSymbolsSize != nSymbolsSize)
+                        SetSymbolsSize_Impl(nSymbolsSize);
+                }
+                break;
+            default:
+                break;
+        }
+    }
     return 0L;
 }
 
@@ -278,19 +293,20 @@ SfxImageManager::~SfxImageManager()
 SfxImageManager* SfxImageManager::GetImageManager( SfxModule* pModule )
 {
     SolarMutexGuard aGuard;
+    SfxImageManager* pSfxImageManager(0);
+
+    typedef boost::unordered_map< SfxModule*, boost::shared_ptr<SfxImageManager> > SfxImageManagerMap;
+    static SfxImageManagerMap m_ImageManagerMap;
 
-    SfxImageManagerMap::const_iterator pIter =
-        m_ImageManagerMap.find( sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( pModule )));
+    SfxImageManagerMap::const_iterator pIter = m_ImageManagerMap.find(pModule);
     if ( pIter != m_ImageManagerMap.end() )
-        return reinterpret_cast< SfxImageManager* >( sal::static_int_cast< sal_IntPtr >( pIter->second ));
+        pSfxImageManager = pIter->second.get();
     else
     {
-        SfxImageManager* pSfxImageManager = new SfxImageManager( pModule );
-        m_ImageManagerMap.insert( SfxImageManagerMap::value_type(
-            sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( pModule )),
-            sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( pSfxImageManager )) ));
-        return pSfxImageManager;
+        m_ImageManagerMap[pModule].reset(new SfxImageManager(pModule));
+        pSfxImageManager = m_ImageManagerMap[pModule].get();
     }
+    return pSfxImageManager;
 }
 
 //-------------------------------------------------------------------------
commit 93f9abda6b191f2be9cadae9fb23e9a7f7d230b3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 20 08:59:38 2011 +0100

    return by ref instead of pointer

diff --git a/editeng/inc/editeng/eerdll.hxx b/editeng/inc/editeng/eerdll.hxx
index 7388b09..14b4a2d 100644
--- a/editeng/inc/editeng/eerdll.hxx
+++ b/editeng/inc/editeng/eerdll.hxx
@@ -47,12 +47,12 @@ class EditDLL
     GlobalEditData*	pGlobalData;
 
 public:
-                    EditDLL();
-                    ~EditDLL();
+    EditDLL();
+    ~EditDLL();
 
     ResMgr*			GetResMgr() const 		{ return pResMgr; }
     GlobalEditData*	GetGlobalData() const	{ return pGlobalData; }
-    static EditDLL* Get();
+    static EditDLL& Get();
 };
 
 #define EE_DLL() EditDLL::Get()
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 08758a8..3412d70 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -2262,8 +2262,7 @@ EditEngineItemPool::EditEngineItemPool( sal_Bool bPersistenRefCounts )
     SetVersionMap( 4, 3994, 4022, aV4Map );
     SetVersionMap( 5, 3994, 4037, aV5Map );
 
-    DBG_ASSERT( EE_DLL(), "EditDLL?!" );
-    SfxPoolItem** ppDefItems = EE_DLL()->GetGlobalData()->GetDefItems();
+    SfxPoolItem** ppDefItems = EE_DLL().GetGlobalData()->GetDefItems();
     SetDefaults( ppDefItems );
 }
 
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index 40c9242..ba27a22 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -1121,7 +1121,7 @@ sal_Bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditVie
                     xub_Unicode nCharCode = rKeyEvent.GetCharCode();
                     pEditView->pImpEditView->DrawSelection();
                     // Autocorrection?
-                    SvxAutoCorrect*	pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect();
+                    SvxAutoCorrect*	pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
                     if ( ( pImpEditEngine->GetStatus().DoAutoCorrect() ) &&
                         ( SvxAutoCorrect::IsAutoCorrectChar( nCharCode ) ||
                           pAutoCorrect->HasRunNext() ) )
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index eb586a4..89ac0e1 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1055,7 +1055,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack )
         Reference< XSpellAlternatives >  xSpellAlt =
                 xSpeller->spell( aSelected, PIMPEE->GetLanguage( aPaM2 ), aPropVals );
 
-        Reference< XLanguageGuessing >  xLangGuesser( EE_DLL()->GetGlobalData()->GetLanguageGuesser() );
+        Reference< XLanguageGuessing >  xLangGuesser( EE_DLL().GetGlobalData()->GetLanguageGuesser() );
 
         // check if text might belong to a different language...
         LanguageType nGuessLangWord = LANGUAGE_NONE;
@@ -1272,7 +1272,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack )
         {
             DBG_ASSERT(nId - MN_AUTOSTART < aAlt.getLength(), "index out of range");
             String aWord = pAlt[nId - MN_AUTOSTART];
-            SvxAutoCorrect*	pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect();
+            SvxAutoCorrect*	pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
             if ( pAutoCorrect )
                 pAutoCorrect->PutText( aSelected, aWord, PIMPEE->GetLanguage( aPaM2 ) );
             InsertText( aWord );
diff --git a/editeng/source/editeng/eerdll.cxx b/editeng/source/editeng/eerdll.cxx
index 219e603..9a4e563 100644
--- a/editeng/source/editeng/eerdll.cxx
+++ b/editeng/source/editeng/eerdll.cxx
@@ -76,22 +76,24 @@
 #include <editeng/forbiddencharacterstable.hxx>
 #include <editeng/justifyitem.hxx>
 #include <comphelper/processfactory.hxx>
-
-static EditDLL* pDLL=0;
+#include <rtl/instance.hxx>
 
 using namespace ::com::sun::star;
 
-EditDLL* EditDLL::Get()
+namespace
+{
+    class theEditDLL : public rtl::Static<EditDLL, theEditDLL> {};
+}
+
+EditDLL& EditDLL::Get()
 {
-    if ( !pDLL )
-        pDLL = new EditDLL;
-    return pDLL;
+    return theEditDLL::get();
 }
 
 GlobalEditData::GlobalEditData()
+    : m_aStdRefDevice(::com::sun::star::uno::Reference<com::sun::star::lang::XComponent>(::comphelper::getProcessComponentContext(), ::com::sun::star::uno::UNO_QUERY_THROW))
 {
     ppDefItems = NULL;
-    pStdRefDevice = NULL;
 }
 
 GlobalEditData::~GlobalEditData()
@@ -100,7 +102,6 @@ GlobalEditData::~GlobalEditData()
     // Or simply keep them, since at end of excecution?!
     if ( ppDefItems )
         SfxItemPool::ReleaseDefaults( ppDefItems, EDITITEMCOUNT, sal_True );
-    delete pStdRefDevice;
 }
 
 SfxPoolItem** GlobalEditData::GetDefItems()
@@ -208,30 +209,27 @@ uno::Reference< linguistic2::XLanguageGuessing > GlobalEditData::GetLanguageGues
 
 OutputDevice* GlobalEditData::GetStdRefDevice()
 {
-    if ( !pStdRefDevice )
+    if ( !m_aStdRefDevice )
     {
-        pStdRefDevice = new VirtualDevice;
-        pStdRefDevice->SetMapMode( MAP_TWIP );
+        m_aStdRefDevice.reset(new VirtualDevice);
+        m_aStdRefDevice->SetMapMode( MAP_TWIP );
     }
-    return pStdRefDevice;
+    return m_aStdRefDevice.get();
 }
 
 EditResId::EditResId( sal_uInt16 nId ):
-    ResId( nId, *EE_DLL()->GetResMgr() )
+    ResId( nId, *EE_DLL().GetResMgr() )
 {
 }
 
 EditDLL::EditDLL()
 {
     pGlobalData = new GlobalEditData;
-    ByteString aResMgrName( "editeng" );
-    pResMgr = ResMgr::CreateResMgr(
-        aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
+    pResMgr = ResMgr::CreateResMgr( "editeng", Application::GetSettings().GetUILocale() );
 }
 
 EditDLL::~EditDLL()
 {
-    delete pResMgr;
     delete pGlobalData;
 }
 
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 666d630..93decd9 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -160,7 +160,7 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) :
     aOnlineSpellTimer.SetTimeout( 100 );
     aOnlineSpellTimer.SetTimeoutHdl( LINK( this, ImpEditEngine, OnlineSpellHdl ) );
 
-    pRefDev 			= EE_DLL()->GetGlobalData()->GetStdRefDevice();
+    pRefDev 			= EE_DLL().GetGlobalData()->GetStdRefDevice();
 
     // Access data already from here on!
     SetRefDevice( pRefDev );
@@ -206,7 +206,7 @@ void ImpEditEngine::SetRefDevice( OutputDevice* pRef )
     bOwnerOfRefDev = sal_False;
 
     if ( !pRef )
-        pRefDev = EE_DLL()->GetGlobalData()->GetStdRefDevice();
+        pRefDev = EE_DLL().GetGlobalData()->GetStdRefDevice();
 
     nOnePixelInRef = (sal_uInt16)pRefDev->PixelToLogic( Size( 1, 0 ) ).Width();
 
@@ -223,7 +223,7 @@ void ImpEditEngine::SetRefMapMode( const MapMode& rMapMode )
         return;
 
     // When RefDev == GlobalRefDev => create own!
-    if ( !bOwnerOfRefDev && ( pRefDev == EE_DLL()->GetGlobalData()->GetStdRefDevice() ) )
+    if ( !bOwnerOfRefDev && ( pRefDev == EE_DLL().GetGlobalData()->GetStdRefDevice() ) )
     {
         pRefDev = new VirtualDevice;
         pRefDev->SetMapMode( MAP_TWIP );
@@ -2521,7 +2521,7 @@ EditPaM ImpEditEngine::AutoCorrect( const EditSelection& rCurSel, xub_Unicode c,
                                     sal_Bool bOverwrite, Window* pFrameWin )
 {
     EditSelection aSel( rCurSel );
-    SvxAutoCorrect*	pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect();
+    SvxAutoCorrect*	pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
     if ( pAutoCorrect )
     {
         if ( aSel.HasRange() )
@@ -4452,13 +4452,13 @@ rtl::Reference<SvxForbiddenCharactersTable> ImpEditEngine::GetForbiddenCharsTabl
 {
     rtl::Reference<SvxForbiddenCharactersTable> xF = xForbiddenCharsTable;
     if ( !xF.is() && bGetInternal )
-        xF = EE_DLL()->GetGlobalData()->GetForbiddenCharsTable();
+        xF = EE_DLL().GetGlobalData()->GetForbiddenCharsTable();
     return xF;
 }
 
 void ImpEditEngine::SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars )
 {
-    EE_DLL()->GetGlobalData()->SetForbiddenCharsTable( xForbiddenChars );
+    EE_DLL().GetGlobalData()->SetForbiddenCharsTable( xForbiddenChars );
 }
 
 svtools::ColorConfig& ImpEditEngine::GetColorConfig()
commit 66f729541c1144bbe28f3c08c6a8930c646bdc56
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 20 08:59:13 2011 +0100

    make this a singleton that dtors on desktop::termination

diff --git a/editeng/source/editeng/eerdll2.hxx b/editeng/source/editeng/eerdll2.hxx
index 43bf536..4073f7a 100644
--- a/editeng/source/editeng/eerdll2.hxx
+++ b/editeng/source/editeng/eerdll2.hxx
@@ -32,6 +32,7 @@
 #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
 #include <editeng/forbiddencharacterstable.hxx>
 #include <rtl/ref.hxx>
+#include <comphelper/scoped_disposing_ptr.hxx>
 
 class SfxPoolItem;
 
@@ -40,8 +41,8 @@ class GlobalEditData
 private:
     ::com::sun::star::uno::Reference<
         ::com::sun::star::linguistic2::XLanguageGuessing >  xLanguageGuesser;
+    comphelper::scoped_disposing_solar_mutex_reset_ptr<OutputDevice> m_aStdRefDevice;
     SfxPoolItem** 	ppDefItems;
-    OutputDevice*	pStdRefDevice;
 
     rtl::Reference<SvxForbiddenCharactersTable>	xForbiddenCharsTable;
 
commit 47e532694fb40ed03f897d0b5c5966b45d963b3b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 20 08:58:28 2011 +0100

    valgrind: strange leak, bad merge maybe

diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index b6aa52a..91db40a 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -192,11 +192,8 @@ ContentInfo::ContentInfo( SfxItemPool& rPool ) : aParaAttribs( rPool, EE_PARA_ST
 // the real Copy constructor is nonsens, since I have to work with another Pool!
 ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse )
     : aParaAttribs( rPoolToUse, EE_PARA_START, EE_CHAR_END )
+    , pWrongs(0)
 {
-    pWrongs = NULL;
-
-    if ( rCopyFrom.GetWrongList() )
-        pWrongs = rCopyFrom.GetWrongList()->Clone();
     // this should ensure that the Items end up in the correct Pool!
     aParaAttribs.Set( rCopyFrom.GetParaAttribs() );
     aText = rCopyFrom.GetText();
@@ -210,7 +207,6 @@ ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse
         aAttribs.Insert( pMyAttr, aAttribs.Count()  );
     }
 
-    pWrongs = NULL;
     if ( rCopyFrom.GetWrongList() )
         pWrongs = rCopyFrom.GetWrongList()->Clone();
 }
commit 1fb0704635e5c7ec1169358d0eea1dffd30283e1
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 20 08:57:24 2011 +0100

    make this a well-behaved singleton

diff --git a/editeng/source/misc/acorrcfg.cxx b/editeng/source/misc/acorrcfg.cxx
index f16dbdb..1c6d8e1 100644
--- a/editeng/source/misc/acorrcfg.cxx
+++ b/editeng/source/misc/acorrcfg.cxx
@@ -39,15 +39,13 @@
 #include <com/sun/star/uno/Any.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
 
+#include <rtl/instance.hxx>
+
 using namespace utl;
 using namespace com::sun::star::uno;
 
 using ::rtl::OUString;
 
-#define C2U(cChar) OUString::createFromAscii(cChar)
-
-static SvxAutoCorrCfg* pAutoCorrCfg = 0;
-
 SvxAutoCorrCfg::SvxAutoCorrCfg() :
     aBaseConfig(*this),
     aSwConfig(*this),
@@ -230,7 +228,7 @@ void SvxBaseAutoCorrCfg::Load(sal_Bool bInit)
 }
 
 SvxBaseAutoCorrCfg::SvxBaseAutoCorrCfg(SvxAutoCorrCfg& rPar) :
-    utl::ConfigItem(C2U("Office.Common/AutoCorrect")),
+    utl::ConfigItem(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/AutoCorrect"))),
     rParent(rPar)
 {
 }
@@ -539,7 +537,7 @@ void SvxSwAutoCorrCfg::Load(sal_Bool bInit)
 }
 
 SvxSwAutoCorrCfg::SvxSwAutoCorrCfg(SvxAutoCorrCfg& rPar) :
-    utl::ConfigItem(C2U("Office.Writer/AutoFunction")),
+    utl::ConfigItem(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Writer/AutoFunction"))),
     rParent(rPar)
 {
 }
@@ -650,11 +648,14 @@ void SvxSwAutoCorrCfg::Notify( const Sequence<OUString>& /* aPropertyNames */ )
     Load(sal_False);
 }
 
-SvxAutoCorrCfg*	SvxAutoCorrCfg::Get()
+namespace
+{
+    class theSvxAutoCorrCfg : public rtl::Static<SvxAutoCorrCfg, theSvxAutoCorrCfg>{};
+}
+
+SvxAutoCorrCfg&	SvxAutoCorrCfg::Get()
 {
-    if( !pAutoCorrCfg )
-        pAutoCorrCfg = new SvxAutoCorrCfg;
-    return pAutoCorrCfg;
+    return theSvxAutoCorrCfg::get();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 8155ca2403be96cf15dc5c0369c14979f8c02464
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 20 08:56:25 2011 +0100

    don't be so noisy

diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index 36dcb1e..2457796 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -229,7 +229,7 @@ OfficeIPCThread*	OfficeIPCThread::pGlobalOfficeIPCThread = 0;
 // Into a hex string of well known length ff132a86...
 String CreateMD5FromString( const OUString& aMsg )
 {
-#if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
+#if (OSL_DEBUG_LEVEL > 2)
     fprintf (stderr, "create md5 from '%s'\n",
              (const sal_Char *)rtl::OUStringToOString (aMsg, RTL_TEXTENCODING_UTF8));
 #endif
commit dc1b9452e6e733092b3acde46cfec32e1f13ff6d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 19 23:12:57 2011 +0100

    adjust for return by ref instead of pointer

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 31ab7d1..d0443f9 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -1988,7 +1988,7 @@ int Desktop::doShutdown()
 
 IMPL_LINK( Desktop, ImplInitFilterHdl, ConvertData*, pData )
 {
-    return GraphicFilter::GetGraphicFilter()->GetFilterCallback().Call( pData );
+    return GraphicFilter::GetGraphicFilter().GetFilterCallback().Call( pData );
 }
 
 sal_Bool Desktop::InitializeConfiguration()
commit 80b6675bd0ab18178e333dce400e4bcd989f2a90
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 19 22:15:51 2011 +0100

    adapt for singleton api change

diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx
index ef95bbd..8b5d698 100644
--- a/svx/source/gallery2/galbrws2.cxx
+++ b/svx/source/gallery2/galbrws2.cxx
@@ -1172,12 +1172,12 @@ String GalleryBrowser2::GetFilterName() const
 
         if( ( SGA_OBJ_BMP == eObjKind ) || ( SGA_OBJ_ANIM == eObjKind ) )
         {
-            GraphicFilter*		pFilter = GraphicFilter::GetGraphicFilter();
+            GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
             INetURLObject		aURL; mpCurTheme->GetURL( mnCurActionPos, aURL );
-            sal_uInt16			nFilter = pFilter->GetImportFormatNumberForShortName( aURL.GetExtension() );
+            sal_uInt16			nFilter = rFilter.GetImportFormatNumberForShortName( aURL.GetExtension() );
             
             if( GRFILTER_FORMAT_DONTKNOW != nFilter )
-                aFilterName = pFilter->GetImportFormatName( nFilter );
+                aFilterName = rFilter.GetImportFormatName( nFilter );
         }
     }
 
diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx
index e611983..8b8edfc 100644
--- a/svx/source/gallery2/galctrl.cxx
+++ b/svx/source/gallery2/galctrl.cxx
@@ -95,9 +95,9 @@ bool GalleryPreview::SetGraphic( const INetURLObject& _aURL )
     }
     else
     {
-        GraphicFilter*  pFilter = GraphicFilter::GetGraphicFilter();
-        GalleryProgress aProgress( pFilter );
-        if( pFilter->ImportGraphic( aGraphic, _aURL, GRFILTER_FORMAT_DONTKNOW ) )
+        GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
+        GalleryProgress aProgress( &rFilter );
+        if( rFilter.ImportGraphic( aGraphic, _aURL, GRFILTER_FORMAT_DONTKNOW ) )
             bRet = false;
     }
 
diff --git a/svx/source/gallery2/galmisc.cxx b/svx/source/gallery2/galmisc.cxx
index 80eb92b..f8d2f4e 100644
--- a/svx/source/gallery2/galmisc.cxx
+++ b/svx/source/gallery2/galmisc.cxx
@@ -126,13 +126,13 @@ sal_uInt16 GalleryGraphicImport( const INetURLObject& rURL, Graphic& rGraphic,
 
     if( pIStm )
     {
-        GraphicFilter*		pGraphicFilter = GraphicFilter::GetGraphicFilter();
-        GalleryProgress*	pProgress = bShowProgress ? new GalleryProgress( pGraphicFilter ) : NULL;
+        GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+        GalleryProgress*	pProgress = bShowProgress ? new GalleryProgress( &rGraphicFilter ) : NULL;
         sal_uInt16				nFormat;
 
-        if( !pGraphicFilter->ImportGraphic( rGraphic, rURL.GetMainURL( INetURLObject::NO_DECODE ), *pIStm, GRFILTER_FORMAT_DONTKNOW, &nFormat ) )
+        if( !rGraphicFilter.ImportGraphic( rGraphic, rURL.GetMainURL( INetURLObject::NO_DECODE ), *pIStm, GRFILTER_FORMAT_DONTKNOW, &nFormat ) )
         {
-            rFilterName = pGraphicFilter->GetImportFormatName( nFormat );
+            rFilterName = rGraphicFilter.GetImportFormatName( nFormat );
             nRet = SGA_IMPORT_FILE;
         }
 
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index e51a268..7261fd7 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -100,10 +100,10 @@ const Graphic ImpLoadLinkedGraphic( const String& rFileName, const String& rFilt
     if ( pInStrm )
     {
         pInStrm->Seek( STREAM_SEEK_TO_BEGIN );
-        GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
+        GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
 
-        const sal_uInt16 nFilter = rFilterName.Len() && pGF->GetImportFormatCount()
-                            ? pGF->GetImportFormatNumber( rFilterName )
+        const sal_uInt16 nFilter = rFilterName.Len() && rGF.GetImportFormatCount()
+                            ? rGF.GetImportFormatNumber( rFilterName )
                             : GRFILTER_FORMAT_DONTKNOW;
 
         String aEmptyStr;
@@ -115,7 +115,7 @@ const Graphic ImpLoadLinkedGraphic( const String& rFileName, const String& rFilt
         // there we should create a new service to provide this data if needed
         aFilterData[ 0 ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CreateNativeLink" ) );
         aFilterData[ 0 ].Value = Any( sal_True );
-        pGF->ImportGraphic( aGraphic, aEmptyStr, *pInStrm, nFilter, NULL, 0, &aFilterData );
+        rGF.ImportGraphic( aGraphic, aEmptyStr, *pInStrm, nFilter, NULL, 0, &aFilterData );
     }
     return aGraphic;
 }
@@ -1299,7 +1299,7 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO )
                         mbIsPreview = sal_True;
                     }
 
-                    if( !GraphicFilter::GetGraphicFilter()->ImportGraphic( aGraphic, String(), *pStream,
+                    if( !GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, String(), *pStream,
                                                         GRFILTER_FORMAT_DONTKNOW, NULL, 0, pFilterData ) )
                     {
                         const String aUserData( pGraphic->GetUserData() );
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx
index ff67870..e753cdd 100644
--- a/svx/source/unodraw/UnoGraphicExporter.cxx
+++ b/svx/source/unodraw/UnoGraphicExporter.cxx
@@ -1005,19 +1005,19 @@ sal_Bool SAL_CALL GraphicExporter::filter( const Sequence< PropertyValue >& aDes
     if( NULL == mpUnoPage )
         return sal_False;
 
-    GraphicFilter*				pFilter = GraphicFilter::GetGraphicFilter();
-   
-    if( NULL == pFilter || NULL == mpUnoPage->GetSdrPage() || NULL == mpDoc )
+    if( NULL == mpUnoPage->GetSdrPage() || NULL == mpDoc )
         return sal_False;
 
+    GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
+
     // get the arguments from the descriptor
     ExportSettings aSettings( mpDoc );
     ParseSettings( aDescriptor, aSettings );
 
     const sal_uInt16	nFilter = aSettings.maMediaType.getLength()
-                            ? pFilter->GetExportFormatNumberForMediaType( aSettings.maMediaType )
-                            : pFilter->GetExportFormatNumberForShortName( aSettings.maFilterName );
-    sal_Bool			bVectorType = !pFilter->IsExportPixelFormat( nFilter );
+                            ? rFilter.GetExportFormatNumberForMediaType( aSettings.maMediaType )
+                            : rFilter.GetExportFormatNumberForShortName( aSettings.maFilterName );
+    sal_Bool			bVectorType = !rFilter.IsExportPixelFormat( nFilter );
 
     // create the output stuff
     Graphic aGraphic;
@@ -1046,7 +1046,7 @@ sal_Bool SAL_CALL GraphicExporter::filter( const Sequence< PropertyValue >& aDes
                 // SvOutputStream, or adapt the graphic filter to not seek anymore.
                 SvMemoryStream aStream( 1024, 1024 );
 
-                nStatus = pFilter->ExportGraphic( aGraphic, String(), aStream, nFilter, &aSettings.maFilterData );
+                nStatus = rFilter.ExportGraphic( aGraphic, String(), aStream, nFilter, &aSettings.maFilterData );
 
                 // copy temp stream to XOutputStream
                 SvOutputStream aOutputStream( aSettings.mxOutputStream );
@@ -1058,7 +1058,7 @@ sal_Bool SAL_CALL GraphicExporter::filter( const Sequence< PropertyValue >& aDes
                 INetURLObject aURLObject( aSettings.maURL.Complete );
                 DBG_ASSERT( aURLObject.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
 
-                nStatus = XOutBitmap::ExportGraphic( aGraphic, aURLObject, *pFilter, nFilter, &aSettings.maFilterData );
+                nStatus = XOutBitmap::ExportGraphic( aGraphic, aURLObject, rFilter, nFilter, &aSettings.maFilterData );
             }
         }
     }
@@ -1223,12 +1223,12 @@ sal_Bool SAL_CALL GraphicExporter::supportsMimeType( const OUString& MimeTypeNam
 {
     const String aMimeTypeName( MimeTypeName );
 
-    GraphicFilter*	pFilter = GraphicFilter::GetGraphicFilter();
-    sal_uInt16 nCount = pFilter->GetExportFormatCount();
+    GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
+    sal_uInt16 nCount = rFilter.GetExportFormatCount();
     sal_uInt16 nFilter;
     for( nFilter = 0; nFilter < nCount; nFilter++ )
     {
-        if( aMimeTypeName.Equals( pFilter->GetExportFormatMediaType( nFilter ) ) )
+        if( aMimeTypeName.Equals( rFilter.GetExportFormatMediaType( nFilter ) ) )
         {
             return sal_True;
         }
@@ -1239,8 +1239,8 @@ sal_Bool SAL_CALL GraphicExporter::supportsMimeType( const OUString& MimeTypeNam
 
 Sequence< OUString > SAL_CALL GraphicExporter::getSupportedMimeTypeNames(  ) throw (RuntimeException)
 {
-    GraphicFilter*	pFilter = GraphicFilter::GetGraphicFilter();
-    sal_uInt16 nCount = pFilter->GetExportFormatCount();
+    GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
+    sal_uInt16 nCount = rFilter.GetExportFormatCount();
     sal_uInt16 nFilter;
     sal_uInt16 nFound = 0;
 
@@ -1249,7 +1249,7 @@ Sequence< OUString > SAL_CALL GraphicExporter::getSupportedMimeTypeNames(  ) thr
 
     for( nFilter = 0; nFilter < nCount; nFilter++ )
     {
-        OUString aMimeType( pFilter->GetExportFormatMediaType( nFilter ) );
+        OUString aMimeType( rFilter.GetExportFormatMediaType( nFilter ) );
         if( aMimeType.getLength() )
         {
             *pStr++ = aMimeType;
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index fab6abb..1037b0a 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -101,11 +101,13 @@ SvxShapeGroup::SvxShapeGroup( SdrObject* pObj, SvxDrawPage* pDrawPage  )  throw(
     SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_GROUP), getSvxMapProvider().GetPropertySet(SVXMAP_GROUP, SdrObject::GetGlobalDrawObjectItemPool()) ),
     mxPage( pDrawPage )
 {
+    fprintf(stderr, "SvxShapeGroup::SvxShapeGroup ctor %p\n", this);
 }
 
 //----------------------------------------------------------------------
 SvxShapeGroup::~SvxShapeGroup() throw()
 {
+    fprintf(stderr, "SvxShapeGroup::SvxShapeGroup dtor %p\n", this);
 }
 
 //----------------------------------------------------------------------
@@ -1730,8 +1732,8 @@ bool SvxGraphicObject::setPropertyValueImpl( const ::rtl::OUString& rName, const
 
                     if( aURLObj.GetProtocol() != INET_PROT_NOT_VALID )
                     {
-                        GraphicFilter* pGrfFilter = GraphicFilter::GetGraphicFilter();
-                        aFilterName = pGrfFilter->GetImportFormatName( pGrfFilter->GetImportFormatNumberForShortName( aURLObj.getExtension() ) );
+                        GraphicFilter &rGrfFilter = GraphicFilter::GetGraphicFilter();
+                        aFilterName = rGrfFilter.GetImportFormatName( rGrfFilter.GetImportFormatNumberForShortName( aURLObj.getExtension() ) );
                     }
                 }
                 else
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 52584c5..ea0e331 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -139,7 +139,7 @@ SvXMLGraphicInputStream::SvXMLGraphicInputStream( const ::rtl::OUString& rGraphi
             {
                 if( aGraphic.GetType() == GRAPHIC_BITMAP )
                 {
-                    GraphicFilter*  pFilter = GraphicFilter::GetGraphicFilter();
+                    GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
                     String          aFormat;
 
                     if( aGraphic.IsAnimated() )
@@ -147,7 +147,7 @@ SvXMLGraphicInputStream::SvXMLGraphicInputStream( const ::rtl::OUString& rGraphi
                     else
                         aFormat = String( RTL_CONSTASCII_USTRINGPARAM( "png" ) );
 
-                    bRet = ( pFilter->ExportGraphic( aGraphic, String(), *pStm, pFilter->GetExportFormatNumberForShortName( aFormat ) ) == 0 );
+                    bRet = ( rFilter.ExportGraphic( aGraphic, String(), *pStm, rFilter.GetExportFormatNumberForShortName( aFormat ) ) == 0 );
                 }
                 else if( aGraphic.GetType() == GRAPHIC_GDIMETAFILE )
                 {
@@ -331,7 +331,7 @@ const GraphicObject& SvXMLGraphicOutputStream::GetGraphicObject()
         mpOStm->Seek( 0 );
         sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW;
         sal_uInt16 pDeterminedFormat = GRFILTER_FORMAT_DONTKNOW;
-        GraphicFilter::GetGraphicFilter()->ImportGraphic( aGraphic, String(), *mpOStm ,nFormat,&pDeterminedFormat );
+        GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, String(), *mpOStm ,nFormat,&pDeterminedFormat );
 
         if (pDeterminedFormat == GRFILTER_FORMAT_DONTKNOW)
         {
@@ -374,7 +374,7 @@ const GraphicObject& SvXMLGraphicOutputStream::GetGraphicObject()
                         if (nStreamLen_)
                         {
                             pDest->Seek(0L);
-                            GraphicFilter::GetGraphicFilter()->ImportGraphic( aGraphic, String(), *pDest ,nFormat,&pDeterminedFormat );
+                            GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, String(), *pDest ,nFormat,&pDeterminedFormat );
                         }
                     }
                     delete pDest;
@@ -569,7 +569,7 @@ Graphic SvXMLGraphicHelper::ImplReadGraphic( const ::rtl::OUString& rPictureStor
     if( aStream.xStream.is() )
     {
         SvStream* pStream = utl::UcbStreamHelper::CreateStream( aStream.xStream );
-        GraphicFilter::GetGraphicFilter()->ImportGraphic( aGraphic, String(), *pStream );
+        GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, String(), *pStream );
         delete pStream;
     }
 
@@ -615,7 +615,7 @@ sal_Bool SvXMLGraphicHelper::ImplWriteGraphic( const ::rtl::OUString& rPictureSt
             {
                 if( aGraphic.GetType() == GRAPHIC_BITMAP )
                 {
-                    GraphicFilter*  pFilter = GraphicFilter::GetGraphicFilter();
+                    GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
                     String          aFormat;
 
                     if( aGraphic.IsAnimated() )
@@ -623,8 +623,8 @@ sal_Bool SvXMLGraphicHelper::ImplWriteGraphic( const ::rtl::OUString& rPictureSt
                     else
                         aFormat = String( RTL_CONSTASCII_USTRINGPARAM( "png" ) );
 
-                    bRet = ( pFilter->ExportGraphic( aGraphic, String(), *pStream,
-                                                     pFilter->GetExportFormatNumberForShortName( aFormat ) ) == 0 );
+                    bRet = ( rFilter.ExportGraphic( aGraphic, String(), *pStream,
+                                                     rFilter.GetExportFormatNumberForShortName( aFormat ) ) == 0 );
                 }
                 else if( aGraphic.GetType() == GRAPHIC_GDIMETAFILE )
                 {
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx
index 365c731..f500b3f 100644
--- a/svx/source/xoutdev/_xoutbmp.cxx
+++ b/svx/source/xoutdev/_xoutbmp.cxx
@@ -328,7 +328,7 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, String& rFileName,
         INetURLObject	aURL( rFileName );
         Graphic			aGraphic;
         String			aExt;
-        GraphicFilter*	pFilter = GraphicFilter::GetGraphicFilter();
+        GraphicFilter&	rFilter = GraphicFilter::GetGraphicFilter();
         sal_uInt16			nErr = GRFILTER_FILTERERROR, nFilter = GRFILTER_FORMAT_NOTFOUND;
         sal_Bool			bTransparent = rGraphic.IsTransparent(), bAnimated = rGraphic.IsAnimated();
 
@@ -397,19 +397,19 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, String& rFileName,
             if( bWriteTransGrf )
                 aFilter = FORMAT_GIF;
 
-            nFilter = pFilter->GetExportFormatNumberForShortName( aFilter );
+            nFilter = rFilter.GetExportFormatNumberForShortName( aFilter );
 
             if( GRFILTER_FORMAT_NOTFOUND == nFilter )
             {
-                nFilter = pFilter->GetExportFormatNumberForShortName( FORMAT_JPG );
+                nFilter = rFilter.GetExportFormatNumberForShortName( FORMAT_JPG );
 
                 if( GRFILTER_FORMAT_NOTFOUND == nFilter )
-                    nFilter = pFilter->GetExportFormatNumberForShortName( FORMAT_BMP );
+                    nFilter = rFilter.GetExportFormatNumberForShortName( FORMAT_BMP );
             }
 
             if( GRFILTER_FORMAT_NOTFOUND != nFilter )
             {
-                aExt = pFilter->GetExportFormatShortName( nFilter ).ToLowerAscii();
+                aExt = rFilter.GetExportFormatShortName( nFilter ).ToLowerAscii();
 
                 if( bWriteTransGrf )
                 {
@@ -475,7 +475,7 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, String& rFileName,
                 {
                     aURL.setExtension( aExt );
                     rFileName = aURL.GetMainURL( INetURLObject::NO_DECODE );
-                    nErr = ExportGraphic( aGraphic, aURL, *pFilter, nFilter, NULL );
+                    nErr = ExportGraphic( aGraphic, aURL, rFilter, nFilter, NULL );
                 }
             }
         }
commit bde86c1ae22f4df4de53ff4919d4302869d9e66c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 19 21:57:41 2011 +0100

    adapt for singleton api change

diff --git a/sfx2/source/appl/appmisc.cxx b/sfx2/source/appl/appmisc.cxx
index e0b5ef1..77131c1 100644
--- a/sfx2/source/appl/appmisc.cxx
+++ b/sfx2/source/appl/appmisc.cxx
@@ -296,8 +296,8 @@ static bool impl_loadBitmap(
         // Use graphic class to also support more graphic formats (bmp,png,...)
         Graphic aGraphic;
 
-        GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
-        pGF->ImportGraphic( aGraphic, String(), aStrm, GRFILTER_FORMAT_DONTKNOW );
+        GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
+        rGF.ImportGraphic( aGraphic, String(), aStrm, GRFILTER_FORMAT_DONTKNOW );
 
         // Default case, we load the intro bitmap from a seperate file
         // (e.g. staroffice_intro.bmp or starsuite_intro.bmp)
diff --git a/sfx2/source/appl/fileobj.cxx b/sfx2/source/appl/fileobj.cxx
index 7287bc2..b5290aa 100644
--- a/sfx2/source/appl/fileobj.cxx
+++ b/sfx2/source/appl/fileobj.cxx
@@ -313,10 +313,10 @@ sal_Bool SvFileObject::LoadFile_Impl()
 
 sal_Bool SvFileObject::GetGraphic_Impl( Graphic& rGrf, SvStream* pStream )
 {
-    GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
+    GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
 
-    const sal_uInt16 nFilter = sFilter.Len() && pGF->GetImportFormatCount()
-                            ? pGF->GetImportFormatNumber( sFilter )
+    const sal_uInt16 nFilter = sFilter.Len() && rGF.GetImportFormatCount()
+                            ? rGF.GetImportFormatNumber( sFilter )
                             : GRFILTER_FORMAT_DONTKNOW;
 
     String aEmptyStr;
@@ -329,16 +329,16 @@ sal_Bool SvFileObject::GetGraphic_Impl( Graphic& rGrf, SvStream* pStream )
 
     if( !pStream )
         nRes = xMed.Is() ? GRFILTER_OPENERROR
-                         : pGF->ImportGraphic( rGrf, INetURLObject(sFileNm),
+                         : rGF.ImportGraphic( rGrf, INetURLObject(sFileNm),
                             nFilter );
     else if( !pDownLoadData )
     {
         pStream->Seek( STREAM_SEEK_TO_BEGIN );
-        nRes = pGF->ImportGraphic( rGrf, aEmptyStr, *pStream, nFilter );
+        nRes = rGF.ImportGraphic( rGrf, aEmptyStr, *pStream, nFilter );
     }
     else
     {
-        nRes = pGF->ImportGraphic( pDownLoadData->aGrf, aEmptyStr,
+        nRes = rGF.ImportGraphic( pDownLoadData->aGrf, aEmptyStr,
                                     *pStream, nFilter );
 
         if( pDownLoadData )
diff --git a/sfx2/source/appl/opengrf.cxx b/sfx2/source/appl/opengrf.cxx
index c24d05d..802b7d0 100644
--- a/sfx2/source/appl/opengrf.cxx
+++ b/sfx2/source/appl/opengrf.cxx
@@ -127,12 +127,12 @@ short SvxOpenGraphicDialog::Execute()
     {
         if( GetPath().Len() )
         {
-            GraphicFilter*	pFilter = GraphicFilter::GetGraphicFilter();
+            GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
             INetURLObject aObj( GetPath() );
 
             // check whether we can load the graphic
             String	aCurFilter( GetCurrentFilter() );
-            sal_uInt16 	nFormatNum = pFilter->GetImportFormatNumber( aCurFilter );
+            sal_uInt16 	nFormatNum = rFilter.GetImportFormatNumber( aCurFilter );
             sal_uInt16 	nRetFormat = 0;
             sal_uInt16	nFound = USHRT_MAX;
 
@@ -144,23 +144,23 @@ short SvxOpenGraphicDialog::Execute()
                 SvStream* pStream = aMed.GetInStream();
 
                 if( pStream )
-                    nImpRet = pFilter->CanImportGraphic( aObj.GetMainURL( INetURLObject::NO_DECODE ), *pStream, nFormatNum, &nRetFormat );
+                    nImpRet = rFilter.CanImportGraphic( aObj.GetMainURL( INetURLObject::NO_DECODE ), *pStream, nFormatNum, &nRetFormat );
                 else
-                    nImpRet = pFilter->CanImportGraphic( aObj, nFormatNum, &nRetFormat );
+                    nImpRet = rFilter.CanImportGraphic( aObj, nFormatNum, &nRetFormat );
 
                 if ( GRFILTER_OK != nImpRet )
                 {
                     if ( !pStream )
-                        nImpRet = pFilter->CanImportGraphic( aObj, GRFILTER_FORMAT_DONTKNOW, &nRetFormat );
+                        nImpRet = rFilter.CanImportGraphic( aObj, GRFILTER_FORMAT_DONTKNOW, &nRetFormat );
                     else
-                        nImpRet = pFilter->CanImportGraphic( aObj.GetMainURL( INetURLObject::NO_DECODE ), *pStream,
+                        nImpRet = rFilter.CanImportGraphic( aObj.GetMainURL( INetURLObject::NO_DECODE ), *pStream,
                                                              GRFILTER_FORMAT_DONTKNOW, &nRetFormat );
                 }
             }
             else
             {
-                if( (nImpRet=pFilter->CanImportGraphic( aObj, nFormatNum, &nRetFormat )) != GRFILTER_OK )
-                    nImpRet = pFilter->CanImportGraphic( aObj, GRFILTER_FORMAT_DONTKNOW, &nRetFormat );
+                if( (nImpRet=rFilter.CanImportGraphic( aObj, nFormatNum, &nRetFormat )) != GRFILTER_OK )
+                    nImpRet = rFilter.CanImportGraphic( aObj, GRFILTER_FORMAT_DONTKNOW, &nRetFormat );
             }
 
             if ( GRFILTER_OK == nImpRet )
@@ -175,9 +175,9 @@ short SvxOpenGraphicDialog::Execute()
             else
             {
                 // setup appropriate filter (so next time, it will work)
-                if( pFilter->GetImportFormatCount() )
+                if( rFilter.GetImportFormatCount() )
                 {
-                    String	aFormatName(pFilter->GetImportFormatName(nFound));
+                    String	aFormatName(rFilter.GetImportFormatName(nFound));
                     SetCurrentFilter(aFormatName);
                 }
 
commit 80e58f1135b35b46bb097678726c7cff8692b9cf
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 19 21:49:45 2011 +0100

    adapt for singleton api change

diff --git a/framework/source/fwe/classes/addonsoptions.cxx b/framework/source/fwe/classes/addonsoptions.cxx
index b2fab5a..8eca5c5 100644
--- a/framework/source/fwe/classes/addonsoptions.cxx
+++ b/framework/source/fwe/classes/addonsoptions.cxx
@@ -1353,8 +1353,8 @@ void AddonsOptions_Impl::ReadImageFromURL( ImageSize nImageSize, const ::rtl::OU
         // Use graphic class to also support more graphic formats (bmp,png,...)
         Graphic aGraphic;
 
-        GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
-        pGF->ImportGraphic( aGraphic, String(), *pStream, GRFILTER_FORMAT_DONTKNOW );
+        GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
+        rGF.ImportGraphic( aGraphic, String(), *pStream, GRFILTER_FORMAT_DONTKNOW );
 
         BitmapEx aBitmapEx = aGraphic.GetBitmapEx();
 
diff --git a/framework/source/uielement/imagebuttontoolbarcontroller.cxx b/framework/source/uielement/imagebuttontoolbarcontroller.cxx
index 26643f4..0d5e238 100644
--- a/framework/source/uielement/imagebuttontoolbarcontroller.cxx
+++ b/framework/source/uielement/imagebuttontoolbarcontroller.cxx
@@ -205,8 +205,8 @@ sal_Bool ImageButtonToolbarController::ReadImageFromURL( sal_Bool bBigImage, con
         // Use graphic class to also support more graphic formats (bmp,png,...)
         Graphic aGraphic;
 
-        GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
-        pGF->ImportGraphic( aGraphic, String(), *pStream, GRFILTER_FORMAT_DONTKNOW );
+        GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
+        rGF.ImportGraphic( aGraphic, String(), *pStream, GRFILTER_FORMAT_DONTKNOW );
 
         BitmapEx aBitmapEx = aGraphic.GetBitmapEx();
 
commit 5aeef17d32b8bdef55f8b60f5e8a0781e06e5feb
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 19 21:47:37 2011 +0100

    adapt for singleton api change

diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index ace04fb..7ae29a3 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -3883,7 +3883,7 @@ const GraphicObject* SvxBrushItem::GetGraphicObject() const
                 Graphic aGraphic;
                 int	nRes;
                 pImpl->pStream->Seek( STREAM_SEEK_TO_BEGIN );
-                nRes = GraphicFilter::GetGraphicFilter()->
+                nRes = GraphicFilter::GetGraphicFilter().
                     ImportGraphic( aGraphic, *pStrLink, *pImpl->pStream,
                                    GRFILTER_FORMAT_DONTKNOW, NULL, GRFILTER_I_FLAGS_DONT_SET_LOGSIZE_FOR_JPEG );
 
commit e97177e5d8c7c54fc7321c5b80d838291e2f1206
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 20 10:04:48 2011 +0100

    resolve merge conflicts

diff --git a/editeng/source/rtf/rtfgrf.cxx b/editeng/source/rtf/rtfgrf.cxx
index 7a42799..a11e810 100644
--- a/editeng/source/rtf/rtfgrf.cxx
+++ b/editeng/source/rtf/rtfgrf.cxx
@@ -477,15 +477,15 @@ sal_Bool SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType )
 
         if( bValidBmp )
         {
-            GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
+            GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
             sal_uInt16 nImportFilter = GRFILTER_FORMAT_DONTKNOW;
 
             if( pFilterNm )
             {
                 String sTmp;
-                for( sal_uInt16 n = pGF->GetImportFormatCount(); n; )
+                for( sal_uInt16 n = rGF.GetImportFormatCount(); n; )
                 {
-                    sTmp = pGF->GetImportFormatShortName( --n );
+                    sTmp = rGF.GetImportFormatShortName( --n );
                     if( sTmp.EqualsAscii( pFilterNm ))
                     {
                         nImportFilter = n;
@@ -503,7 +503,7 @@ sal_Bool SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType )
 
             WMF_APMFILEHEADER *pAPMHeader=(aAPMHeader.right>0 && aAPMHeader.bottom>0?&aAPMHeader:NULL);
             pTmpFile->Seek( STREAM_SEEK_TO_BEGIN );
-            bValidBmp = 0 == pGF->ImportGraphic( rGrf, sTmpStr, *pTmpFile, nImportFilter, NULL, 0, pAPMHeader );
+            bValidBmp = 0 == rGF.ImportGraphic( rGrf, sTmpStr, *pTmpFile, nImportFilter, NULL, 0, pAPMHeader );
         }
     }
 
commit 21d75c573e4da2c1dae6a9ebf78b99caec3c038a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 17 22:01:51 2011 +0100

    adjust for return by reference

diff --git a/editeng/inc/editeng/acorrcfg.hxx b/editeng/inc/editeng/acorrcfg.hxx
index f9d6267..c80a045 100644
--- a/editeng/inc/editeng/acorrcfg.hxx
+++ b/editeng/inc/editeng/acorrcfg.hxx
@@ -123,7 +123,7 @@ public:
 
     SvxAutoCorrCfg();
     virtual ~SvxAutoCorrCfg();
-    static SvxAutoCorrCfg*      Get();
+    static SvxAutoCorrCfg& Get();
 };
 
 
commit 7ce7535758d243e35e69cd8cc45b8a19cb868fc4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 17 21:26:54 2011 +0100

    valgrind: use non-leaky singleton pattern

diff --git a/svx/inc/svx/svxerr.hxx b/svx/inc/svx/svxerr.hxx
index eef4ada..40366ff 100644
--- a/svx/inc/svx/svxerr.hxx
+++ b/svx/inc/svx/svxerr.hxx
@@ -94,9 +94,9 @@
 
 class SVX_DLLPUBLIC SvxErrorHandler : private SfxErrorHandler
 {
-  public:
+public:
     SvxErrorHandler();
-    static void Get();
+    static void ensure();
 };
 
 #endif
diff --git a/svx/source/items/svxerr.cxx b/svx/source/items/svxerr.cxx
index 37b02b9..4afd540 100644
--- a/svx/source/items/svxerr.cxx
+++ b/svx/source/items/svxerr.cxx
@@ -37,20 +37,23 @@
 
 #include <svx/dialogs.hrc>
 
-static SvxErrorHandler* pHandler=NULL;
+#include <rtl/instance.hxx>
 
 SvxErrorHandler::SvxErrorHandler() :
-
   SfxErrorHandler(
       RID_SVXERRCODE, ERRCODE_AREA_SVX, ERRCODE_AREA_SVX_END, &DIALOG_MGR() )
 {
-    pHandler = this;
 }
 
-void SvxErrorHandler::Get()
+namespace
+{
+    class theSvxErrorHandler
+        : public rtl::Static<SvxErrorHandler, theSvxErrorHandler> {};
+}
+
+void SvxErrorHandler::ensure()
 {
-    if ( !pHandler )
-        new SvxErrorHandler;
+    theSvxErrorHandler::get();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit e6de857ed920417aa8d012778c6f0175971e04e3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 17 21:17:24 2011 +0100

    remove debugging-mode leak

diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx
index 3b65327..3e373c3 100644
--- a/sfx2/source/appl/appinit.cxx
+++ b/sfx2/source/appl/appinit.cxx
@@ -255,7 +255,7 @@ bool SfxApplication::Initialize_Impl()
 #ifdef DBG_UTIL
     // The SimplerErrorHandler is for debugging. In the Product errors
     // not processed are given to SFX as Errorcode 1.
-    new SimpleErrorHandler;
+    pAppData_Impl->m_pSimpleErrorHdl = new SimpleErrorHandler;
 #endif
     pAppData_Impl->m_pToolsErrorHdl = new SfxErrorHandler(
         RID_ERRHDL, ERRCODE_AREA_TOOLS, ERRCODE_AREA_LIB1);
diff --git a/sfx2/source/appl/appquit.cxx b/sfx2/source/appl/appquit.cxx
index f08435b..a81ccbe 100644
--- a/sfx2/source/appl/appquit.cxx
+++ b/sfx2/source/appl/appquit.cxx
@@ -159,6 +159,9 @@ void SfxApplication::Deinitialize()
     delete pAppData_Impl->m_pSbxErrorHdl;
     delete pAppData_Impl->m_pSoErrorHdl;
     delete pAppData_Impl->m_pToolsErrorHdl;
+#ifdef DBG_UTIL
+    delete pAppData_Impl->m_pSimpleErrorHdl;
+#endif
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx
index b38e5d8..29f8631 100644
--- a/sfx2/source/inc/appdata.hxx
+++ b/sfx2/source/inc/appdata.hxx
@@ -112,6 +112,9 @@ public:
     // application members
     SfxFilterMatcher*                   pMatcher;
     ResMgr*                             pLabelResMgr;
+#ifdef DBG_UTIL
+    SimpleErrorHandler *m_pSimpleErrorHdl;
+#endif
     SfxErrorHandler *m_pToolsErrorHdl;
     SfxErrorHandler *m_pSoErrorHdl;
     SfxErrorHandler *m_pSbxErrorHdl;
commit 4843a52598ec8fe4612d3dca74e66e1a1749d91c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 17 21:12:03 2011 +0100

    valgrind: remove leaks

diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx
index 1b6f286..b38e5d8 100644
--- a/sfx2/source/inc/appdata.hxx
+++ b/sfx2/source/inc/appdata.hxx
@@ -32,6 +32,7 @@
 #include <svl/lstner.hxx>
 #include <vcl/timer.hxx>
 #include <tools/string.hxx>
+#include <svtools/ehdl.hxx>
 #include "rtl/ref.hxx"
 
 #include <com/sun/star/frame/XModel.hpp>
@@ -111,6 +112,9 @@ public:
     // application members
     SfxFilterMatcher*                   pMatcher;
     ResMgr*                             pLabelResMgr;
+    SfxErrorHandler *m_pToolsErrorHdl;
+    SfxErrorHandler *m_pSoErrorHdl;
+    SfxErrorHandler *m_pSbxErrorHdl;
     SfxStatusDispatcher*				pAppDispatch;
     SfxDocumentTemplates*               pTemplates;
 
commit c4bf0bd8e9f47096dba1b7108d264742057b72fd
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 17 21:11:38 2011 +0100

    use non-leaky singleton pattern

diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx
index 19e53c2..3b65327 100644
--- a/sfx2/source/appl/appinit.cxx
+++ b/sfx2/source/appl/appinit.cxx
@@ -264,9 +264,6 @@ bool SfxApplication::Initialize_Impl()
     pAppData_Impl->m_pSbxErrorHdl = new SfxErrorHandler(
         RID_BASIC_START, ERRCODE_AREA_SBX, ERRCODE_AREA_SBX_END );
 
-    // diverse Pointer
-    SfxPickList::GetOrCreate( SvtHistoryOptions().GetSize( ePICKLIST ) );
-
     DBG_ASSERT( !pAppData_Impl->pAppDispat, "AppDispatcher already exists" );
     pAppData_Impl->pAppDispat = new SfxDispatcher((SfxDispatcher*)0);
     pAppData_Impl->pSlotPool = new SfxSlotPool;
diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index 7b43139..d633b99 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -170,28 +170,10 @@ SfxPickList::PickListEntry*	SfxPickList::GetPickListEntry( sal_uInt32 nIndex )
         return 0;
 }
 
-SfxPickList& SfxPickList::GetOrCreate( const sal_uInt32 nMenuSize )
-{
-    if ( !pUniqueInstance )
-    {
-        ::osl::MutexGuard aGuard( thePickListMutex::get() );
-        if ( !pUniqueInstance )
-            pUniqueInstance = new SfxPickList( nMenuSize );
-    }
-
-    return *pUniqueInstance;
-}
-
 SfxPickList& SfxPickList::Get()
 {
-    ::osl::MutexGuard aGuard( thePickListMutex::get() );
-    return *pUniqueInstance;
-}
-
-void SfxPickList::Delete()
-{
-    ::osl::MutexGuard aGuard( thePickListMutex::get() );
-    DELETEZ( pUniqueInstance );
+    static SfxPickList aUniqueInstance(SvtHistoryOptions().GetSize(ePICKLIST));
+    return aUniqueInstance;
 }
 
 SfxPickList::SfxPickList( sal_uInt32 nAllowedMenuSize ) :
diff --git a/sfx2/source/inc/sfxpicklist.hxx b/sfx2/source/inc/sfxpicklist.hxx
index 987e1b9..af99e1f 100644
--- a/sfx2/source/inc/sfxpicklist.hxx
+++ b/sfx2/source/inc/sfxpicklist.hxx
@@ -67,9 +67,7 @@ class SfxPickList : public SfxListener
     void					RemovePickListEntries();
 
     public:
-        static SfxPickList& GetOrCreate( const sal_uInt32 nMenuSize );
         static SfxPickList& Get();
-        static void			Delete();
 
         sal_uInt32			GetAllowedMenuSize() { return m_nAllowedMenuSize; }
         sal_uInt32			GetNumOfEntries() const { return m_aPicklistVector.size(); }
commit 254c2fca2d8c439774dad9c0e8667eb92811ca7e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 17 21:10:49 2011 +0100

    valgrind: remove leaks

diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx
index 103d981..19e53c2 100644
--- a/sfx2/source/appl/appinit.cxx
+++ b/sfx2/source/appl/appinit.cxx
@@ -257,17 +257,16 @@ bool SfxApplication::Initialize_Impl()
     // not processed are given to SFX as Errorcode 1.
     new SimpleErrorHandler;
 #endif
-    new SfxErrorHandler(RID_ERRHDL, ERRCODE_AREA_TOOLS, ERRCODE_AREA_LIB1);
-
-    new SfxErrorHandler(
+    pAppData_Impl->m_pToolsErrorHdl = new SfxErrorHandler(
+        RID_ERRHDL, ERRCODE_AREA_TOOLS, ERRCODE_AREA_LIB1);
+    pAppData_Impl->m_pSoErrorHdl = new SfxErrorHandler(
         RID_SO_ERROR_HANDLER, ERRCODE_AREA_SO, ERRCODE_AREA_SO_END);
-    new SfxErrorHandler(
+    pAppData_Impl->m_pSbxErrorHdl = new SfxErrorHandler(
         RID_BASIC_START, ERRCODE_AREA_SBX, ERRCODE_AREA_SBX_END );
 
     // diverse Pointer
     SfxPickList::GetOrCreate( SvtHistoryOptions().GetSize( ePICKLIST ) );
 
-
     DBG_ASSERT( !pAppData_Impl->pAppDispat, "AppDispatcher already exists" );
     pAppData_Impl->pAppDispat = new SfxDispatcher((SfxDispatcher*)0);
     pAppData_Impl->pSlotPool = new SfxSlotPool;
diff --git a/sfx2/source/appl/appquit.cxx b/sfx2/source/appl/appquit.cxx
index 8a354d9..f08435b 100644
--- a/sfx2/source/appl/appquit.cxx
+++ b/sfx2/source/appl/appquit.cxx
@@ -154,6 +154,11 @@ void SfxApplication::Deinitialize()
     //TODO/CLEANTUP
     //ReleaseArgs could be used instead!
     pAppData_Impl->pPool = NULL;
+    NoChaos::ReleaseItemPool();
+
+    delete pAppData_Impl->m_pSbxErrorHdl;
+    delete pAppData_Impl->m_pSoErrorHdl;
+    delete pAppData_Impl->m_pToolsErrorHdl;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 415b8e8e577b388b0b76f73c32066f8efa39d896
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 17 21:05:15 2011 +0100

    return by reference instead of pointer

diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index dfcc03c..7b43139 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -170,7 +170,7 @@ SfxPickList::PickListEntry*	SfxPickList::GetPickListEntry( sal_uInt32 nIndex )
         return 0;
 }
 
-SfxPickList*	SfxPickList::GetOrCreate( const sal_uInt32 nMenuSize )
+SfxPickList& SfxPickList::GetOrCreate( const sal_uInt32 nMenuSize )
 {
     if ( !pUniqueInstance )
     {
@@ -179,13 +179,13 @@ SfxPickList*	SfxPickList::GetOrCreate( const sal_uInt32 nMenuSize )
             pUniqueInstance = new SfxPickList( nMenuSize );
     }
 
-    return pUniqueInstance;
+    return *pUniqueInstance;
 }
 
-SfxPickList* SfxPickList::Get()
+SfxPickList& SfxPickList::Get()
 {
     ::osl::MutexGuard aGuard( thePickListMutex::get() );
-    return pUniqueInstance;
+    return *pUniqueInstance;
 }
 
 void SfxPickList::Delete()
@@ -258,10 +258,10 @@ void SfxPickList::CreatePickListEntries()
 
 void SfxPickList::CreateMenuEntries( Menu* pMenu )
 {
-    static sal_Bool	bPickListMenuInitializing = sal_False;
-
     ::osl::MutexGuard aGuard( thePickListMutex::get() );
 
+    static sal_Bool bPickListMenuInitializing = sal_False;
+
     if ( bPickListMenuInitializing ) // method is not reentrant!
         return;
 
@@ -295,7 +295,7 @@ void SfxPickList::ExecuteEntry( sal_uInt32 nIndex )
 {
     ::osl::ClearableMutexGuard aGuard( thePickListMutex::get() );
 
-    PickListEntry *pPick = SfxPickList::Get()->GetPickListEntry( nIndex );
+    PickListEntry *pPick = SfxPickList::Get().GetPickListEntry( nIndex );
 
     if ( pPick )
     {
@@ -327,7 +327,7 @@ void SfxPickList::ExecuteMenuEntry( sal_uInt16 nId )
 
 String SfxPickList::GetMenuEntryTitle( sal_uInt32 nIndex )
 {
-    PickListEntry *pPick = SfxPickList::Get()->GetPickListEntry( nIndex );
+    PickListEntry *pPick = SfxPickList::Get().GetPickListEntry( nIndex );
 
     if ( pPick )
         return pPick->aTitle;
diff --git a/sfx2/source/inc/sfxpicklist.hxx b/sfx2/source/inc/sfxpicklist.hxx
index 28845aa..987e1b9 100644
--- a/sfx2/source/inc/sfxpicklist.hxx
+++ b/sfx2/source/inc/sfxpicklist.hxx
@@ -67,8 +67,8 @@ class SfxPickList : public SfxListener
     void					RemovePickListEntries();
 
     public:
-        static SfxPickList*	GetOrCreate( const sal_uInt32 nMenuSize );
-        static SfxPickList*	Get();
+        static SfxPickList& GetOrCreate( const sal_uInt32 nMenuSize );
+        static SfxPickList& Get();
         static void			Delete();
 
         sal_uInt32			GetAllowedMenuSize() { return m_nAllowedMenuSize; }
diff --git a/sfx2/source/menu/virtmenu.cxx b/sfx2/source/menu/virtmenu.cxx
index b9fd414..457c065 100644
--- a/sfx2/source/menu/virtmenu.cxx
+++ b/sfx2/source/menu/virtmenu.cxx
@@ -899,7 +899,7 @@ IMPL_LINK( SfxVirtualMenu, Activate, Menu *, pMenu )
         // ggf. Pick-Menu erzeugen
         if ( pParent && pSVMenu == pParent->pPickMenu )
         {
-            SfxPickList::Get()->CreateMenuEntries( pParent->pPickMenu );
+            SfxPickList::Get().CreateMenuEntries( pParent->pPickMenu );
         }
         else
             pPickMenu = pSVMenu->GetPopupMenu(SID_PICKLIST);
@@ -1068,7 +1068,7 @@ IMPL_LINK( SfxVirtualMenu, Select, Menu *, pMenu )
     }
     else if ( nSlotId >= START_ITEMID_PICKLIST && nSlotId <= END_ITEMID_PICKLIST )
     {
-        SfxPickList::Get()->ExecuteMenuEntry( nSlotId );
+        SfxPickList::Get().ExecuteMenuEntry( nSlotId );
         return sal_True;
     }
 
commit 85cfb6009aa8ab4a4901d6b09c5da5096499d446
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 17 16:40:57 2011 +0100

    valgrind: use non-leaky singleton here

diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx
index afaccc4..5aba2d7 100644
--- a/sfx2/source/appl/app.cxx
+++ b/sfx2/source/appl/app.cxx
@@ -147,6 +147,7 @@
 #include <framework/addonsoptions.hxx>
 #include <svtools/ttprops.hxx>
 #include <unotools/extendedsecurityoptions.hxx>
+#include <rtl/instance.hxx>
 
 using namespace ::com::sun::star;
 
@@ -155,118 +156,110 @@ SfxApplication* SfxApplication::pApp = NULL;
 static BasicDLL*       pBasic   = NULL;
 static SfxHelp*        pSfxHelp = NULL;
 
-class SfxPropertyHandler : public PropertyHandler
+namespace
 {
-    virtual void Property( ApplicationProperty& );
-};
-
-static SfxPropertyHandler*	pPropertyHandler = 0;
-
-SfxPropertyHandler* GetOrCreatePropertyHandler()
-{
-    if ( !pPropertyHandler )
+    class SfxPropertyHandler : public PropertyHandler
     {
-        ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
-        if ( !pPropertyHandler )
-            pPropertyHandler = new SfxPropertyHandler;
-    }
+        virtual void Property( ApplicationProperty& );
+    };
 
-    return pPropertyHandler;
-}
-
-void SfxPropertyHandler::Property( ApplicationProperty& rProp )
-{
-    TTProperties* pTTProperties = PTR_CAST( TTProperties, &rProp );
-    if ( pTTProperties )
+    void SfxPropertyHandler::Property( ApplicationProperty& rProp )
     {
-        pTTProperties->nPropertyVersion = TT_PROPERTIES_VERSION;
-        switch ( pTTProperties->nActualPR )
+        TTProperties* pTTProperties = PTR_CAST( TTProperties, &rProp );
+        if ( pTTProperties )
         {
-            case TT_PR_SLOTS:
-            {
-                pTTProperties->nSidOpenUrl = SID_OPENURL;
-                pTTProperties->nSidFileName = SID_FILE_NAME;
-                pTTProperties->nSidNewDocDirect = SID_NEWDOCDIRECT;
-                pTTProperties->nSidCopy = SID_COPY;
-                pTTProperties->nSidPaste = SID_PASTE;
-                pTTProperties->nSidSourceView = SID_SOURCEVIEW;
-                pTTProperties->nSidSelectAll = SID_SELECTALL;
-                pTTProperties->nSidReferer = SID_REFERER;
-                pTTProperties->nActualPR = 0;
-            }
-            break;
-            case TT_PR_DISPATCHER:
+            pTTProperties->nPropertyVersion = TT_PROPERTIES_VERSION;
+            switch ( pTTProperties->nActualPR )
             {
-                // interface for TestTool
-                SfxViewFrame* pViewFrame=0;
-                SfxDispatcher* pDispatcher=0;
-                pViewFrame = SfxViewFrame::Current();
-                if ( !pViewFrame )
-                    pViewFrame = SfxViewFrame::GetFirst();
-                if ( pViewFrame )
-                    pDispatcher = pViewFrame->GetDispatcher();
-                else
-                    pDispatcher = NULL;
-                if ( !pDispatcher )
-                    pTTProperties->nActualPR = TT_PR_ERR_NODISPATCHER;
-                else
+                case TT_PR_SLOTS:
                 {
-                    pDispatcher->SetExecuteMode(EXECUTEMODE_DIALOGASYNCHRON);
-                    if ( pTTProperties->mnSID == SID_NEWDOCDIRECT
-                      || pTTProperties->mnSID == SID_OPENDOC )
+                    pTTProperties->nSidOpenUrl = SID_OPENURL;
+                    pTTProperties->nSidFileName = SID_FILE_NAME;
+                    pTTProperties->nSidNewDocDirect = SID_NEWDOCDIRECT;
+                    pTTProperties->nSidCopy = SID_COPY;
+                    pTTProperties->nSidPaste = SID_PASTE;
+                    pTTProperties->nSidSourceView = SID_SOURCEVIEW;
+                    pTTProperties->nSidSelectAll = SID_SELECTALL;
+                    pTTProperties->nSidReferer = SID_REFERER;
+                    pTTProperties->nActualPR = 0;
+                }
+                break;
+                case TT_PR_DISPATCHER:
+                {
+                    // interface for TestTool
+                    SfxViewFrame* pViewFrame=0;
+                    SfxDispatcher* pDispatcher=0;
+                    pViewFrame = SfxViewFrame::Current();
+                    if ( !pViewFrame )
+                        pViewFrame = SfxViewFrame::GetFirst();
+                    if ( pViewFrame )
+                        pDispatcher = pViewFrame->GetDispatcher();
+                    else
+                        pDispatcher = NULL;
+                    if ( !pDispatcher )
+                        pTTProperties->nActualPR = TT_PR_ERR_NODISPATCHER;
+                    else
                     {
-                        SfxPoolItem** pArgs = pTTProperties->mppArgs;
-                        SfxAllItemSet aSet( SFX_APP()->GetPool() );
-                        if ( pArgs && *pArgs )
-                        {
-                            for ( SfxPoolItem **pArg = pArgs; *pArg; ++pArg )
-                                aSet.Put( **pArg );
-                        }
-                        if ( pTTProperties->mnSID == SID_NEWDOCDIRECT )
+                        pDispatcher->SetExecuteMode(EXECUTEMODE_DIALOGASYNCHRON);
+                        if ( pTTProperties->mnSID == SID_NEWDOCDIRECT
+                          || pTTProperties->mnSID == SID_OPENDOC )
                         {
-                            String aFactory = String::CreateFromAscii("private:factory/");
+                            SfxPoolItem** pArgs = pTTProperties->mppArgs;
+                            SfxAllItemSet aSet( SFX_APP()->GetPool() );
                             if ( pArgs && *pArgs )
                             {
-                                SFX_ITEMSET_ARG( &aSet, pFactoryName, SfxStringItem, SID_NEWDOCDIRECT, sal_False );
-                                if ( pFactoryName )
-                                    aFactory += pFactoryName->GetValue();
+                                for ( SfxPoolItem **pArg = pArgs; *pArg; ++pArg )
+                                    aSet.Put( **pArg );
+                            }
+                            if ( pTTProperties->mnSID == SID_NEWDOCDIRECT )
+                            {
+                                String aFactory = String::CreateFromAscii("private:factory/");
+                                if ( pArgs && *pArgs )
+                                {
+                                    SFX_ITEMSET_ARG( &aSet, pFactoryName, SfxStringItem, SID_NEWDOCDIRECT, sal_False );
+                                    if ( pFactoryName )
+                                        aFactory += pFactoryName->GetValue();
+                                    else
+                                        aFactory += String::CreateFromAscii("swriter");
+                                }
                                 else
                                     aFactory += String::CreateFromAscii("swriter");
+
+                                aSet.Put( SfxStringItem( SID_FILE_NAME, aFactory ) );
+                                aSet.ClearItem( SID_NEWDOCDIRECT );
+                                pTTProperties->mnSID = SID_OPENDOC;
                             }
-                            else
-                                aFactory += String::CreateFromAscii("swriter");
 
-                            aSet.Put( SfxStringItem( SID_FILE_NAME, aFactory ) );
-                            aSet.ClearItem( SID_NEWDOCDIRECT );
-                            pTTProperties->mnSID = SID_OPENDOC;
+                            aSet.Put( SfxStringItem( SID_TARGETNAME, DEFINE_CONST_UNICODE("_blank") ) );
+                            if ( pDispatcher->ExecuteFunction( pTTProperties->mnSID, aSet, pTTProperties->mnMode )
+                                        == EXECUTE_NO )
+                                pTTProperties->nActualPR = TT_PR_ERR_NOEXECUTE;
+                            else
+                                pTTProperties->nActualPR = 0;
                         }
-
-                        aSet.Put( SfxStringItem( SID_TARGETNAME, DEFINE_CONST_UNICODE("_blank") ) );
-                        if ( pDispatcher->ExecuteFunction( pTTProperties->mnSID, aSet, pTTProperties->mnMode )
-                                    == EXECUTE_NO )
-                            pTTProperties->nActualPR = TT_PR_ERR_NOEXECUTE;
-                        else
-                            pTTProperties->nActualPR = 0;
-                    }
-                    else
-                    {
-                        if ( pDispatcher->ExecuteFunction(
-                                pTTProperties->mnSID, pTTProperties->mppArgs, pTTProperties->mnMode )
-                            == EXECUTE_NO )
-                            pTTProperties->nActualPR = TT_PR_ERR_NOEXECUTE;
                         else
-                            pTTProperties->nActualPR = 0;
+                        {
+                            if ( pDispatcher->ExecuteFunction(
+                                    pTTProperties->mnSID, pTTProperties->mppArgs, pTTProperties->mnMode )
+                                == EXECUTE_NO )
+                                pTTProperties->nActualPR = TT_PR_ERR_NOEXECUTE;
+                            else
+                                pTTProperties->nActualPR = 0;
+                        }
                     }
                 }
+                break;
+                default:
+                {
+                    pTTProperties->nPropertyVersion = 0;
+                }
             }
-            break;
-            default:
-            {
-                pTTProperties->nPropertyVersion = 0;
-            }
+            return;
         }
-        return;
     }
+
+    class thePropertyHandler
+        : public rtl::Static<SfxPropertyHandler, thePropertyHandler> {};
 }
 
 #include <framework/imageproducer.hxx>
@@ -325,7 +318,7 @@ SfxApplication::SfxApplication()
     RTL_LOGFILE_CONTEXT( aLog, "sfx2 (mb93783) ::SfxApplication::SfxApplication" );
 
     SetName( DEFINE_CONST_UNICODE("StarOffice") );
-    GetpApp()->SetPropertyHandler( GetOrCreatePropertyHandler() );
+    GetpApp()->SetPropertyHandler( &thePropertyHandler::get() );
 
     SvtViewOptions::AcquireOptions();
 
commit e77040b6ef545032c58ee863243217fd4889eb09
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 17 16:15:49 2011 +0100

    valgrind: use non-leaky singleton here

diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index 62ca967..dfcc03c 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -58,6 +58,8 @@
 #include "objshimp.hxx"
 #include <sfx2/docfilt.hxx>
 
+#include <rtl/instance.hxx>
+
 #include <algorithm>
 
 // ----------------------------------------------------------------------------
@@ -68,7 +70,6 @@ using namespace ::com::sun::star::util;
 
 // ----------------------------------------------------------------------------
 
-osl::Mutex*		SfxPickList::pMutex = 0;
 SfxPickList*	SfxPickList::pUniqueInstance = 0;
 
 // ----------------------------------------------------------------------------
@@ -87,20 +88,6 @@ class StringLength : public ::cppu::WeakImplHelper1< XStringWidth >
         }
 };
 
-// ----------------------------------------------------------------------------
-
-osl::Mutex*	SfxPickList::GetOrCreateMutex()
-{
-    if ( !pMutex )
-    {
-        ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
-        if ( !pMutex )
-            pMutex = new osl::Mutex;
-    }
-
-    return pMutex;
-}
-
 void SfxPickList::CreatePicklistMenuTitle( Menu* pMenu, sal_uInt16 nItemId, const String& aURLString, sal_uInt32 nNo )
 {
     String aPickEntry;
@@ -159,9 +146,15 @@ void SfxPickList::CreatePicklistMenuTitle( Menu* pMenu, sal_uInt16 nItemId, cons
     pMenu->SetAccessibleName( nItemId, aAccessibleName );
 }
 
+namespace
+{
+    class thePickListMutex
+        : public rtl::Static<osl::Mutex, thePickListMutex> {};
+}
+
 void SfxPickList::RemovePickListEntries()
 {
-    ::osl::MutexGuard aGuard( GetOrCreateMutex() );
+    ::osl::MutexGuard aGuard( thePickListMutex::get() );
     for ( sal_uInt32 i = 0; i < m_aPicklistVector.size(); i++ )
         delete m_aPicklistVector[i];
     m_aPicklistVector.clear();
@@ -181,7 +174,7 @@ SfxPickList*	SfxPickList::GetOrCreate( const sal_uInt32 nMenuSize )
 {
     if ( !pUniqueInstance )
     {
-        ::osl::MutexGuard aGuard( GetOrCreateMutex() );
+        ::osl::MutexGuard aGuard( thePickListMutex::get() );
         if ( !pUniqueInstance )
             pUniqueInstance = new SfxPickList( nMenuSize );
     }
@@ -191,13 +184,13 @@ SfxPickList*	SfxPickList::GetOrCreate( const sal_uInt32 nMenuSize )
 
 SfxPickList* SfxPickList::Get()
 {
-    ::osl::MutexGuard aGuard( GetOrCreateMutex() );
+    ::osl::MutexGuard aGuard( thePickListMutex::get() );
     return pUniqueInstance;
 }
 
 void SfxPickList::Delete()
 {
-    ::osl::MutexGuard aGuard( GetOrCreateMutex() );
+    ::osl::MutexGuard aGuard( thePickListMutex::get() );
     DELETEZ( pUniqueInstance );
 }
 
@@ -267,7 +260,7 @@ void SfxPickList::CreateMenuEntries( Menu* pMenu )
 {
     static sal_Bool	bPickListMenuInitializing = sal_False;
 
-    ::osl::MutexGuard aGuard( GetOrCreateMutex() );
+    ::osl::MutexGuard aGuard( thePickListMutex::get() );
 
     if ( bPickListMenuInitializing ) // method is not reentrant!
         return;
@@ -300,7 +293,7 @@ void SfxPickList::CreateMenuEntries( Menu* pMenu )
 
 void SfxPickList::ExecuteEntry( sal_uInt32 nIndex )
 {
-    ::osl::ClearableMutexGuard aGuard( GetOrCreateMutex() );
+    ::osl::ClearableMutexGuard aGuard( thePickListMutex::get() );
 
     PickListEntry *pPick = SfxPickList::Get()->GetPickListEntry( nIndex );
 
diff --git a/sfx2/source/inc/sfxpicklist.hxx b/sfx2/source/inc/sfxpicklist.hxx
index 0f90669..28845aa 100644
--- a/sfx2/source/inc/sfxpicklist.hxx
+++ b/sfx2/source/inc/sfxpicklist.hxx
@@ -53,7 +53,6 @@ class SfxPickList : public SfxListener
     };
     
     static SfxPickList*				pUniqueInstance;
-    static osl::Mutex*				pMutex;
     
     std::vector< PickListEntry* >	m_aPicklistVector;
     sal_uInt32						m_nAllowedMenuSize;
@@ -62,8 +61,6 @@ class SfxPickList : public SfxListener
                             SfxPickList( sal_uInt32 nMenuSize );
                             ~SfxPickList();
 
-    static osl::Mutex*		GetOrCreateMutex();
-    
     void					CreatePicklistMenuTitle( Menu* pMenu, sal_uInt16 nItemId, const String& aURL, sal_uInt32 nNo );
     PickListEntry*			GetPickListEntry( sal_uInt32 nIndex );
     void					CreatePickListEntries();
commit d6c5f4f3d5c3a92ce94c0d25649d67ffe7faad4e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 17 11:59:19 2011 +0100

    valgrind: use non-leaky singleton pattern here

diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index 9a1b6c3..04816ff 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -63,6 +63,7 @@
 
 #include <vector>
 #include <osl/thread.hxx>
+#include <rtl/instance.hxx>
 
 using ::rtl::OUString;
 using namespace ::osl;
@@ -122,18 +123,14 @@ static OUString impl_GuessFilter( OUString aUrlIn, OUString aUrlOut )
     return  impl_GetFilterFromExt( aUrlOut, SFX_FILTER_EXPORT, aAppl );
 }
 
-Mutex* DispatchWatcher::pWatcherMutex = NULL;
+namespace
+{
+    class theWatcherMutex : public rtl::Static<Mutex, theWatcherMutex> {};
+}
 
 Mutex& DispatchWatcher::GetMutex()
 {
-    if ( !pWatcherMutex )
-    {
-        ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
-        if ( !pWatcherMutex )
-            pWatcherMutex = new osl::Mutex();
-    }
-
-    return *pWatcherMutex;
+    return theWatcherMutex::get();
 }
 
 // Create or get the dispatch watcher implementation. This implementation must be 
diff --git a/desktop/source/app/dispatchwatcher.hxx b/desktop/source/app/dispatchwatcher.hxx
index a787c1e..a756622 100644
--- a/desktop/source/app/dispatchwatcher.hxx
+++ b/desktop/source/app/dispatchwatcher.hxx
@@ -118,8 +118,6 @@ class DispatchWatcher : public ::cppu::WeakImplHelper1< ::com::sun::star::frame:
 
         DispatchWatcherHashMap		m_aRequestContainer;
 
-        static ::osl::Mutex*		pWatcherMutex;
-
         sal_Int16                   m_nRequestCount;
 };
 
commit ee60a220693cd94afd289d822f2b1af2236b2315
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 17 11:37:57 2011 +0100

    valgrind: use non-leaky singleton pattern here

diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index 94eecf9..36dcb1e 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -50,7 +50,8 @@
 #include <rtl/strbuf.hxx>
 #include <comphelper/processfactory.hxx>
 #include <osl/file.hxx>
-#include "rtl/process.h"
+#include <rtl/process.h>
+#include <rtl/instance.hxx>
 #include "tools/getprocessworkingdir.hxx"
 
 using namespace desktop;
@@ -223,7 +224,6 @@ bool addArgument(
 
 OfficeIPCThread*	OfficeIPCThread::pGlobalOfficeIPCThread = 0;
     namespace { struct Security : public rtl::Static<osl::Security, Security> {}; }
-::osl::Mutex*		OfficeIPCThread::pOfficeIPCThreadMutex = 0;
 
 // Turns a string in aMsg such as file:///home/foo/.libreoffice/3
 // Into a hex string of well known length ff132a86...
@@ -360,19 +360,15 @@ throw( RuntimeException )
 {
 }
 
-// ----------------------------------------------------------------------------
-
-::osl::Mutex&	OfficeIPCThread::GetMutex()
+namespace
 {
-    // Get or create our mutex for thread-saftey
-    if ( !pOfficeIPCThreadMutex )
-    {
-        ::osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() );
-        if ( !pOfficeIPCThreadMutex )
-            pOfficeIPCThreadMutex = new osl::Mutex;
-    }
+    class theOfficeIPCThreadMutex
+        : public rtl::Static<osl::Mutex, theOfficeIPCThreadMutex> {};
+}
 
-    return *pOfficeIPCThreadMutex;
+::osl::Mutex& OfficeIPCThread::GetMutex()
+{
+    return theOfficeIPCThreadMutex::get();
 }
 
 void OfficeIPCThread::SetDowning()
diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx
index e72db07..8d2cda1 100644
--- a/desktop/source/app/officeipcthread.hxx
+++ b/desktop/source/app/officeipcthread.hxx
@@ -74,7 +74,6 @@ class OfficeIPCThread : public osl::Thread
 {
   private:
     static OfficeIPCThread*		pGlobalOfficeIPCThread;
-    static ::osl::Mutex*		pOfficeIPCThreadMutex;
 
     osl::Pipe                   maPipe;
     osl::StreamPipe             maStreamPipe;
commit 657d23df43cb643c3b474ebb7b783b86bb436196
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon May 16 23:43:41 2011 +0100

    valgrind: make this a well behaved singleton

diff --git a/svx/inc/svx/xtable.hxx b/svx/inc/svx/xtable.hxx
index 5a26bff..77eee35 100644
--- a/svx/inc/svx/xtable.hxx
+++ b/svx/inc/svx/xtable.hxx
@@ -316,7 +316,7 @@ public:
     virtual sal_Bool    CreateBitmapsForUI();
     virtual Bitmap* CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True );
 
-    static XColorTable*	GetStdColorTable();
+    static XColorTable&	GetStdColorTable();
 };
 
 // -------------------
diff --git a/svx/source/xoutdev/xtabcolr.cxx b/svx/source/xoutdev/xtabcolr.cxx
index 4f3de11..a0c8875 100644
--- a/svx/source/xoutdev/xtabcolr.cxx
+++ b/svx/source/xoutdev/xtabcolr.cxx
@@ -57,12 +57,6 @@ static char const aChckColor[]  = { 0x04, 0x00, 'S','O','C','L'};	// < 5.2
 static char const aChckColor0[] = { 0x04, 0x00, 'S','O','C','0'};	// = 5.2
 static char const aChckXML[]    = { '<', '?', 'x', 'm', 'l' };		// = 6.0
 
-// ------------------
-// class XColorTable
-// ------------------
-
-static XColorTable* pTable=0;
-
 /*************************************************************************
 |*
 |* XColorTable::XColorTable()
@@ -84,11 +78,10 @@ XColorTable::~XColorTable()
 {
 }
 
-XColorTable* XColorTable::GetStdColorTable()
+XColorTable& XColorTable::GetStdColorTable()
 {
-    if ( !pTable )
-        pTable = new XColorTable( SvtPathOptions().GetPalettePath() );
-    return pTable;
+    static XColorTable aTable(SvtPathOptions().GetPalettePath());
+    return aTable;
 }
 
 /************************************************************************/
commit a0c92c8d310366a9bcf5304d3ac3d88691161079
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon May 16 16:38:15 2011 +0100

    break circular dependency in dispose

diff --git a/linguistic/source/dlistimp.cxx b/linguistic/source/dlistimp.cxx
index 27a126e..bc0cafc 100644
--- a/linguistic/source/dlistimp.cxx
+++ b/linguistic/source/dlistimp.cxx
@@ -638,6 +638,7 @@ void SAL_CALL
                     xDic->removeDictionaryEventListener( xDicEvtLstnrHelper );
             }
         }
+        xDicEvtLstnrHelper.clear();
     }
 }
 
commit 9fa5c3f513dabd4c7b95a352accd0cae09c38c89
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon May 16 15:00:36 2011 +0100

    do we really need to be so noisy when nothing is actually wrong

diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c
index 23cb3a3..242a83b 100755
--- a/desktop/unx/source/start.c
+++ b/desktop/unx/source/start.c
@@ -79,7 +79,7 @@ charp_to_ustr( const char *pStr )
 }
 
 /* Easier debugging of rtl_uString values. */
-#if OSL_DEBUG_LEVEL > 0
+#if OSL_DEBUG_LEVEL > 1
 static void
 ustr_debug( const char *pMessage, rtl_uString *pStr )
 {
@@ -236,7 +236,7 @@ get_md5hash( rtl_uString *pText )
     if ( !pText )
         return NULL;
 
-#if OSL_DEBUG_LEVEL > 0
+#if OSL_DEBUG_LEVEL > 1
     rtl_String *pOut = ustr_to_str( pText );
     fprintf (stderr, "Generate pipe md5 for '%s'\n", pOut->buffer);
     rtl_string_release( pOut );
@@ -697,7 +697,7 @@ read_percent( ChildInfo *info, int *pPercent )
         }
     }
 
-#if OSL_DEBUG_LEVEL > 0
+#if OSL_DEBUG_LEVEL > 1
     fprintf( stderr, "Got status: %s\n", pBegin );
 #endif
     if ( !strncasecmp( pBegin, "end", 3 ) )
@@ -884,7 +884,7 @@ exec_javaldx (Args *args)
             *chomp = '\0';
     }
 
-#if OSL_DEBUG_LEVEL > 0
+#if OSL_DEBUG_LEVEL > 1
     fprintf (stderr, "Adding javaldx path of '%s'\n", newpath);
 #endif
     extend_library_path (newpath);
@@ -932,7 +932,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
 
         close( fd );
     }
-#if OSL_DEBUG_LEVEL > 0
+#if OSL_DEBUG_LEVEL > 1
     else
         ustr_debug( "Failed to connect to pipe", pPipePath );
 #endif
@@ -990,7 +990,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
                     bShortWait = sal_False;
                 }
 
-#if OSL_DEBUG_LEVEL > 0
+#if OSL_DEBUG_LEVEL > 1
                 fprintf( stderr, "Polling, result is %s\n",
                          ( eResult == ProgressContinue )? "continue" :
                          ( ( eResult == ProgressRestart )? "restart" : "exit" ) );
commit c5d95535677992d90938e18315bc34bf81dda11e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon May 16 14:58:46 2011 +0100

    valgrind: leak in debugging code

diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c
index 26d771b..23cb3a3 100755
--- a/desktop/unx/source/start.c
+++ b/desktop/unx/source/start.c
@@ -233,13 +233,15 @@ get_md5hash( rtl_uString *pText )
     rtl_uString *pResult = NULL;
     sal_Int32 nCapacity = 100;
 
-#if OSL_DEBUG_LEVEL > 0
-    fprintf (stderr, "Generate pipe md5 for '%s'\n", ustr_to_str (pText)->buffer);
-#endif
-
     if ( !pText )
         return NULL;
 
+#if OSL_DEBUG_LEVEL > 0
+    rtl_String *pOut = ustr_to_str( pText );
+    fprintf (stderr, "Generate pipe md5 for '%s'\n", pOut->buffer);
+    rtl_string_release( pOut );
+#endif
+
     unsigned char *pData = (unsigned char *)rtl_uString_getStr( pText );
     sal_uInt32   nSize = rtl_uString_getLength( pText ) * sizeof( sal_Unicode );
     if ( !pData )
commit 9c402a35b3216f04162a4b69634eced8d1277137
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat May 14 22:06:34 2011 +0100

    WaE: track debug level for usage

diff --git a/xmloff/source/transform/TransformerBase.cxx b/xmloff/source/transform/TransformerBase.cxx
index 81a94f1..24f67ad 100644
--- a/xmloff/source/transform/TransformerBase.cxx
+++ b/xmloff/source/transform/TransformerBase.cxx
@@ -325,7 +325,7 @@ void SAL_CALL XMLTransformerBase::startElement( const OUString& rName,
 }
 
 void SAL_CALL XMLTransformerBase::endElement( const OUString&
-#ifdef DBG_UTIL
+#if OSL_DEBUG_LEVEL > 0
 rName
 #endif
 )
@@ -336,7 +336,7 @@ rName
         // Get topmost context
         ::rtl::Reference< XMLTransformerContext > xContext = m_pContexts->back();
 
-#ifdef DBG_UTIL
+#if OSL_DEBUG_LEVEL > 0
         OSL_ENSURE( xContext->GetQName() == rName,
                 "XMLTransformerBase::endElement: popped context has wrong lname" );
 #endif
commit 1666ccac15f122eebb553fe5dfa74e970b05c278
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 20 10:03:09 2011 +0100

    resolve merge conflicts

diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index 87ae3d3..9a1b6c3 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -96,6 +96,7 @@ static String impl_GetFilterFromExt( OUString aUrl, SfxFilterFlags nFlags,
     String aFilter;
     SfxMedium* pMedium = new SfxMedium( aUrl,
                                         STREAM_STD_READ, sal_False );
+
     const SfxFilter *pSfxFilter = NULL;
     if( nFlags == SFX_FILTER_EXPORT )
     {
@@ -105,6 +106,7 @@ static String impl_GetFilterFromExt( OUString aUrl, SfxFilterFlags nFlags,
     {
         SFX_APP()->GetFilterMatcher().GuessFilter( *pMedium, &pSfxFilter, nFlags, 0 );
     }
+
     if( pSfxFilter )
         aFilter = ( nFlags == SFX_FILTER_EXPORT ) ? pSfxFilter->GetFilterName() :
                                                     pSfxFilter->GetServiceName();
commit aed7428945c044aacaff3e80c09bf5fb07715cf1
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 13 21:05:34 2011 +0100

    remove leak and refactor to make less ugly

diff --git a/sfx2/inc/sfx2/fcontnr.hxx b/sfx2/inc/sfx2/fcontnr.hxx
index 246bfe4..b1dcca5 100644
--- a/sfx2/inc/sfx2/fcontnr.hxx
+++ b/sfx2/inc/sfx2/fcontnr.hxx
@@ -40,6 +40,8 @@
 #include <sfx2/docfilt.hxx>
 #include <sfx2/sfxdefs.hxx>
 
+#include <boost/utility.hpp>
+
 class Window;
 class SfxFilter;
 class SfxFilterArr_Impl;
@@ -124,10 +126,10 @@ public:
 
 class SfxFilterMatcher_Impl;
 
-class SFX2_DLLPUBLIC SfxFilterMatcher
+class SFX2_DLLPUBLIC SfxFilterMatcher : private boost::noncopyable
 {
     friend class SfxFilterMatcherIter;
-    SfxFilterMatcher_Impl *pImpl;
+    SfxFilterMatcher_Impl &m_rImpl;
 public:
                         SfxFilterMatcher( const String& rFact );
                         SfxFilterMatcher();
@@ -152,17 +154,18 @@ public:
 };
 
 class SfxFilterContainer_Impl;
-class SFX2_DLLPUBLIC SfxFilterMatcherIter
+class SFX2_DLLPUBLIC SfxFilterMatcherIter : private boost::noncopyable
+
 {
     SfxFilterFlags nOrMask;
     SfxFilterFlags nAndMask;
     sal_uInt16 nCurrent;
-    const SfxFilterMatcher_Impl *pMatch;
+    const SfxFilterMatcher_Impl &m_rMatch;
 
     SAL_DLLPRIVATE const SfxFilter* Find_Impl();
 
 public:
-    SfxFilterMatcherIter( const SfxFilterMatcher* pMatchP, SfxFilterFlags nMask = 0, SfxFilterFlags nNotMask = SFX_FILTER_NOTINSTALLED );
+    SfxFilterMatcherIter( const SfxFilterMatcher& rMatcher, SfxFilterFlags nMask = 0, SfxFilterFlags nNotMask = SFX_FILTER_NOTINSTALLED );
     const SfxFilter* First();
     const SfxFilter* Next();
 };
diff --git a/sfx2/source/doc/docfac.cxx b/sfx2/source/doc/docfac.cxx
index 70b18aa..7963f0c 100644
--- a/sfx2/source/doc/docfac.cxx
+++ b/sfx2/source/doc/docfac.cxx
@@ -351,7 +351,7 @@ const SfxFilter* SfxObjectFactory::GetTemplateFilter() const
 {
     sal_uInt16 nVersion=0;
     SfxFilterMatcher aMatcher ( String::CreateFromAscii( pShortName ) );
-    SfxFilterMatcherIter aIter( &aMatcher );
+    SfxFilterMatcherIter aIter( aMatcher );
     const SfxFilter *pFilter = 0;
     const SfxFilter *pTemp = aIter.First();
     while ( pTemp )
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 0e15aeb..c49b980 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -285,7 +285,7 @@ void SfxObjectShell::SetTemplate(sal_Bool bIs)
 {
     pImp->bIsTemplate=bIs;
     SfxFilterMatcher aMatcher( GetFactory().GetFactoryName() );
-    SfxFilterMatcherIter aIter( &aMatcher, SFX_FILTER_TEMPLATEPATH );
+    SfxFilterMatcherIter aIter( aMatcher, SFX_FILTER_TEMPLATEPATH );
     SfxMedium* pMed = GetMedium();
     if( pMed ) pMed->SetFilter( aIter.First() );
 }
commit b46dc3d47c23e8272d394007c66699138b2c3249
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 20 09:55:42 2011 +0100

    fix merge conflicts

diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx
index 4e87ea6..43b0793 100644
--- a/sfx2/source/bastyp/fltfnc.cxx
+++ b/sfx2/source/bastyp/fltfnc.cxx
@@ -123,6 +123,9 @@ using namespace ::com::sun::star::beans;
 #include <sfx2/appuno.hxx>
 #include <sfx2/viewfrm.hxx>
 
+#include <boost/ptr_container/ptr_vector.hpp>
+#include <functional>
+
 namespace
 {
     class theSfxFilterListener : public rtl::Static<SfxFilterListener, theSfxFilterListener> {};
@@ -255,9 +258,6 @@ const SfxFilter* SfxFilterContainer::GetDefaultFilter_Impl( const String& rName
 
 //----------------------------------------------------------------
 
-class SfxFilterMatcherArr_Impl;
-static SfxFilterMatcherArr_Impl* pImplArr = 0;
-
 // Impl-Data is shared between all FilterMatchers of the same factory
 class SfxFilterMatcher_Impl
 {
@@ -265,56 +265,75 @@ public:
     ::rtl::OUString 	aName;
     SfxFilterList_Impl* pList;		// is created on demand
 
-    void				InitForIterating() const;
-    void				Update();
-                        SfxFilterMatcher_Impl()
-                            : pList(0)
-                        {}
+    void InitForIterating() const;
+    void Update();
+    SfxFilterMatcher_Impl(const ::rtl::OUString &rName)
+        : aName(rName)
+        , pList(0)
+    {
+    }
 };
 
-DECL_PTRARRAY( SfxFilterMatcherArr_Impl, SfxFilterMatcher_Impl*, 2, 2 )
-
-SfxFilterMatcher::SfxFilterMatcher( const String& rName )
-    : pImpl( 0 )
+namespace
 {
-    if ( !pImplArr )
-        // keep track of created filter matchers to recycle the FilterLists
-        pImplArr = new SfxFilterMatcherArr_Impl;
+    typedef boost::ptr_vector<SfxFilterMatcher_Impl> SfxFilterMatcherArr_Impl;
+    static SfxFilterMatcherArr_Impl aImplArr;
+    static int nSfxFilterMatcherCount;
 
-    String aName = SfxObjectShell::GetServiceNameFromFactory( rName );
-    DBG_ASSERT(aName.Len(), "Found boes type :-)");
-    for ( sal_uInt16 n=0; n<pImplArr->Count(); n++ )
+    class hasName :
+        public std::unary_function<SfxFilterMatcher_Impl, bool>
     {
-        // find the impl-Data of any comparable FilterMatcher that was created before
-        SfxFilterMatcher_Impl* pImp = pImplArr->GetObject(n);
-        if ( String(pImp->aName) == aName )
-            pImpl = pImp;
-    }
+    private:
+        const rtl::OUString& mrName;
+    public:
+        hasName(const rtl::OUString &rName) : mrName(rName) {}
+        bool operator() (const SfxFilterMatcher_Impl& rImpl) const
+        {
+            return rImpl.aName == mrName;
+        }
+    };
 
-    if ( !pImpl )
+    SfxFilterMatcher_Impl & getSfxFilterMatcher_Impl(const rtl::OUString &rName)
     {
+        rtl::OUString aName;
+
+        if (rName.getLength())
+            aName = SfxObjectShell::GetServiceNameFromFactory(rName);
+
+        // find the impl-Data of any comparable FilterMatcher that was created
+        // previously
+        SfxFilterMatcherArr_Impl::iterator aEnd = aImplArr.end();
+        SfxFilterMatcherArr_Impl::iterator aIter =
+            std::find_if(aImplArr.begin(), aEnd, hasName(rName));
+        if (aIter != aEnd)
+            return *aIter;
+
         // first Matcher created for this factory
-        pImpl = new SfxFilterMatcher_Impl;
-        pImpl->aName = aName;
-        pImplArr->Insert( pImplArr->Count(), pImpl );
+        SfxFilterMatcher_Impl *pImpl = new SfxFilterMatcher_Impl(aName);
+        aImplArr.push_back(pImpl);
+        return *pImpl;
     }
 }
 
+SfxFilterMatcher::SfxFilterMatcher( const String& rName )
+    : m_rImpl( getSfxFilterMatcher_Impl(rName) )
+{
+    ++nSfxFilterMatcherCount;
+}
+
 SfxFilterMatcher::SfxFilterMatcher()
+    : m_rImpl( getSfxFilterMatcher_Impl(::rtl::OUString()) )
 {
-    // global FilterMatcher always uses global filter array (also created on demand)
-    pImpl = new SfxFilterMatcher_Impl;
+    // global FilterMatcher always uses global filter array (also created on
+    // demand)
+    ++nSfxFilterMatcherCount;
 }
 
 SfxFilterMatcher::~SfxFilterMatcher()
 {
-    if ( !pImpl->aName.getLength() )
-    {
-        // only the global Matcher owns his ImplData
-        if( pImplArr )
-            pImplArr->Remove( pImpl );
-        delete pImpl;
-    }
+    --nSfxFilterMatcherCount;
+    if (nSfxFilterMatcherCount == 0)
+        aImplArr.clear();
 }
 
 void SfxFilterMatcher_Impl::Update()
@@ -356,10 +375,10 @@ void SfxFilterMatcher_Impl::InitForIterating() const
 
 const SfxFilter* SfxFilterMatcher::GetAnyFilter( SfxFilterFlags nMust, SfxFilterFlags nDont ) const
 {
-    pImpl->InitForIterating();
-    for ( size_t i = 0, n = pImpl->pList->size(); i < n; ++i )
+    m_rImpl.InitForIterating();
+    for ( size_t i = 0, n = m_rImpl.pList->size(); i < n; ++i )
     {
-        const SfxFilter* pFilter = pImpl->pList->at( i );
+        const SfxFilter* pFilter = m_rImpl.pList->at( i );
         SfxFilterFlags nFlags = pFilter->GetFilterFlags();
         if ( (nFlags & nMust) == nMust && !(nFlags & nDont ) )
             return pFilter;
@@ -390,7 +409,7 @@ sal_uInt32  SfxFilterMatcher::GuessFilterIgnoringContent(
     if ( sTypeName.getLength() )
     {
         // make sure filter list is initialized
-        pImpl->InitForIterating();
+        m_rImpl.InitForIterating();
         *ppFilter = GetFilter4EA( sTypeName, nMust, nDont );
     }
 
@@ -449,8 +468,8 @@ sal_uInt32  SfxFilterMatcher::GuessFilterControlDefaultUI( SfxMedium& rMedium, c
             aDescriptor[::comphelper::MediaDescriptor::PROP_INPUTSTREAM()       ] <<= xInStream;
             aDescriptor[::comphelper::MediaDescriptor::PROP_INTERACTIONHANDLER()] <<= rMedium.GetInteractionHandler();
 
-            if ( pImpl->aName.getLength() )
-                aDescriptor[::comphelper::MediaDescriptor::PROP_DOCUMENTSERVICE()] <<= pImpl->aName;
+            if ( m_rImpl.aName.getLength() )
+                aDescriptor[::comphelper::MediaDescriptor::PROP_DOCUMENTSERVICE()] <<= m_rImpl.aName;
 
             if ( pOldFilter )
             {
@@ -624,14 +643,14 @@ const SfxFilter* SfxFilterMatcher::GetFilterForProps( const com::sun::star::uno:
                     // pFilter == 0: if preferred filter is a Writer filter, but Writer module is not installed
                     continue;
 
-                if ( pImpl->aName.getLength() )
+                if ( m_rImpl.aName.getLength() )
                 {
                     // if this is not the global FilterMatcher: check if filter matches the document type
                     ::rtl::OUString aService;
-                    if ( pFilter->GetServiceName() != String(pImpl->aName) )
+                    if ( pFilter->GetServiceName() != String(m_rImpl.aName) )
                     {
                         // preferred filter belongs to another document type; now we must search the filter
-                        pImpl->InitForIterating();
+                        m_rImpl.InitForIterating();
                         aProps[::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"))] >>= aValue;
                         pFilter = GetFilter4EA( aValue, nMust, nDont );
                         if ( pFilter )
@@ -651,11 +670,11 @@ const SfxFilter* SfxFilterMatcher::GetFilterForProps( const com::sun::star::uno:
 
 const SfxFilter* SfxFilterMatcher::GetFilter4Mime( const String& rMediaType,SfxFilterFlags nMust, SfxFilterFlags nDont ) const
 {
-    if ( pImpl->pList )
+    if ( m_rImpl.pList )
     {
-        for ( size_t i = 0, n = pImpl->pList->size(); i < n; ++i )
+        for ( size_t i = 0, n = m_rImpl.pList->size(); i < n; ++i )
         {
-            const SfxFilter* pFilter = pImpl->pList->at( i );
+            const SfxFilter* pFilter = m_rImpl.pList->at( i );
             SfxFilterFlags nFlags = pFilter->GetFilterFlags();
             if ( (nFlags & nMust) == nMust && !(nFlags & nDont ) && pFilter->GetMimeType() == rMediaType )
                 return pFilter;
@@ -672,12 +691,12 @@ const SfxFilter* SfxFilterMatcher::GetFilter4Mime( const String& rMediaType,SfxF
 
 const SfxFilter* SfxFilterMatcher::GetFilter4EA( const String& rType,SfxFilterFlags nMust, SfxFilterFlags nDont ) const
 {
-    if ( pImpl->pList )
+    if ( m_rImpl.pList )
     {
         const SfxFilter* pFirst = 0;
-        for ( size_t i = 0, n = pImpl->pList->size(); i < n; ++i )
+        for ( size_t i = 0, n = m_rImpl.pList->size(); i < n; ++i )
         {
-            const SfxFilter* pFilter = pImpl->pList->at( i );
+            const SfxFilter* pFilter = m_rImpl.pList->at( i );
             SfxFilterFlags nFlags = pFilter->GetFilterFlags();
             if ( (nFlags & nMust) == nMust && !(nFlags & nDont ) && pFilter->GetTypeName() == rType )
             {
@@ -701,11 +720,11 @@ const SfxFilter* SfxFilterMatcher::GetFilter4EA( const String& rType,SfxFilterFl
 
 const SfxFilter* SfxFilterMatcher::GetFilter4Extension( const String& rExt, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
 {
-    if ( pImpl->pList )
+    if ( m_rImpl.pList )
     {
-        for ( size_t i = 0, n = pImpl->pList->size(); i < n; ++i )
+        for ( size_t i = 0, n = m_rImpl.pList->size(); i < n; ++i )
         {
-            const SfxFilter* pFilter = pImpl->pList->at( i );
+            const SfxFilter* pFilter = m_rImpl.pList->at( i );

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list