[Libreoffice-commits] core.git: basic/source compilerplugins/clang dbaccess/source drawinglayer/source editeng/qa editeng/source extensions/source filter/source i18npool/inc i18npool/source oox/source reportdesign/source sax/qa sc/source sdext/source sd/source svtools/source svx/source sw/source ucb/source UnoControls/source uui/source writerfilter/source xmloff/source

Noel Grandin noel at peralex.com
Sun Aug 2 23:37:38 PDT 2015


 UnoControls/source/controls/framecontrol.cxx                          |   18 
 UnoControls/source/inc/framecontrol.hxx                               |    6 
 basic/source/inc/namecont.hxx                                         |   10 
 basic/source/uno/dlgcont.cxx                                          |    2 
 basic/source/uno/namecont.cxx                                         |   88 +--
 basic/source/uno/scriptcont.cxx                                       |    8 
 compilerplugins/clang/refcounting.cxx                                 |  249 ++++++++++
 dbaccess/source/core/dataaccess/ComponentDefinition.cxx               |   13 
 dbaccess/source/core/dataaccess/ComponentDefinition.hxx               |    2 
 dbaccess/source/core/dataaccess/datasource.cxx                        |    4 
 dbaccess/source/core/dataaccess/datasource.hxx                        |    2 
 dbaccess/source/ui/misc/singledoccontroller.cxx                       |   10 
 drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx            |   38 -
 editeng/qa/unit/core-test.cxx                                         |   56 +-
 editeng/source/accessibility/AccessibleEditableTextPara.cxx           |   48 -
 editeng/source/misc/svxacorr.cxx                                      |    8 
 editeng/source/xml/xmltxtexp.cxx                                      |    4 
 extensions/source/scanner/sanedlg.cxx                                 |   12 
 filter/source/svg/svgwriter.cxx                                       |    2 
 i18npool/inc/calendar_gregorian.hxx                                   |    2 
 i18npool/source/calendar/calendar_gregorian.cxx                       |    4 
 i18npool/source/calendar/calendar_jewish.cxx                          |    2 
 i18npool/source/characterclassification/cclass_unicode.cxx            |    6 
 i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx |    4 
 i18npool/source/indexentry/indexentrysupplier.cxx                     |    6 
 i18npool/source/transliteration/ignoreKana.cxx                        |   14 
 i18npool/source/transliteration/ignoreSize_ja_JP.cxx                  |   14 
 i18npool/source/transliteration/ignoreWidth.cxx                       |   14 
 i18npool/source/transliteration/transliteration_body.cxx              |   12 
 i18npool/source/transliteration/transliteration_caseignore.cxx        |   16 
 oox/source/core/xmlfilterbase.cxx                                     |    8 
 reportdesign/source/ui/dlg/GroupsSorting.cxx                          |    9 
 sax/qa/cppunit/attributes.cxx                                         |   42 -
 sax/qa/cppunit/parser.cxx                                             |    9 
 sc/source/ui/dbgui/csvcontrol.cxx                                     |    2 
 sc/source/ui/dbgui/csvgrid.cxx                                        |    6 
 sc/source/ui/dbgui/csvruler.cxx                                       |    2 
 sc/source/ui/dbgui/csvtablebox.cxx                                    |    5 
 sc/source/ui/inc/csvcontrol.hxx                                       |    2 
 sc/source/ui/inc/csvgrid.hxx                                          |    2 
 sc/source/ui/inc/csvruler.hxx                                         |    2 
 sc/source/ui/inc/csvtablebox.hxx                                      |    2 
 sc/source/ui/unoobj/cellsuno.cxx                                      |   10 
 sc/source/ui/unoobj/chart2uno.cxx                                     |    4 
 sc/source/ui/unoobj/docuno.cxx                                        |   16 
 sc/source/ui/vba/vbafont.cxx                                          |   20 
 sc/source/ui/vba/vbawindow.cxx                                        |   12 
 sc/source/ui/vba/vbawindows.cxx                                       |    4 
 sd/source/ui/inc/EventMultiplexer.hxx                                 |    3 
 sd/source/ui/tools/EventMultiplexer.cxx                               |    6 
 sd/source/ui/view/drviews5.cxx                                        |    2 
 sdext/source/pdfimport/test/pdf2xml.cxx                               |    6 
 sdext/source/pdfimport/test/tests.cxx                                 |   12 
 svtools/source/edit/svmedit.cxx                                       |    4 
 svx/source/sdr/contact/viewcontactofgraphic.cxx                       |    6 
 svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx                  |   14 
 svx/source/xml/xmlxtexp.cxx                                           |    4 
 sw/source/core/swg/SwXMLTextBlocks1.cxx                               |    8 
 sw/source/core/unocore/unorefmk.cxx                                   |   38 -
 sw/source/filter/ww8/docxattributeoutput.cxx                          |  188 ++++---
 sw/source/filter/ww8/docxattributeoutput.hxx                          |   36 -
 sw/source/filter/ww8/docxsdrexport.cxx                                |   38 -
 sw/source/filter/ww8/docxsdrexport.hxx                                |    8 
 sw/source/ui/vba/vbawindow.cxx                                        |   12 
 sw/source/uibase/config/StoredChapterNumbering.cxx                    |    4 
 sw/source/uibase/dbui/dbtree.cxx                                      |    6 
 ucb/source/ucp/cmis/cmis_content.cxx                                  |    4 
 ucb/source/ucp/tdoc/tdoc_storage.cxx                                  |    3 
 uui/source/requeststringresolver.hxx                                  |    2 
 writerfilter/source/filter/WriterFilter.cxx                           |    4 
 writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx                |   19 
 writerfilter/source/ooxml/OOXMLFastDocumentHandler.hxx                |    4 
 xmloff/source/meta/xmlversion.cxx                                     |    4 
 73 files changed, 779 insertions(+), 487 deletions(-)

New commits:
commit 2660d24a07866e083c5135ea263030f3e3a2e729
Author: Noel Grandin <noel at peralex.com>
Date:   Mon Jul 13 16:17:00 2015 +0200

    new loplugin: refcounting
    
    This was a feature requested by mmeeks, as a result of
    tdf#92611.
    
    It validates that things that extend XInterface are not
    directly heap/stack-allocated, but have their lifecycle managed
    via css::uno::Reference or rtl::Reference.
    
    Change-Id: I28e3b8b236f6a4a56d0a6d6f26ad54e44b36e692
    Reviewed-on: https://gerrit.libreoffice.org/16924
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/UnoControls/source/controls/framecontrol.cxx b/UnoControls/source/controls/framecontrol.cxx
index 3b34a9f..e4fcd6d 100644
--- a/UnoControls/source/controls/framecontrol.cxx
+++ b/UnoControls/source/controls/framecontrol.cxx
@@ -47,11 +47,11 @@ namespace unocontrols{
 //  construct/destruct
 
 FrameControl::FrameControl( const Reference< XComponentContext >& rxContext)
-    : BaseControl                   ( rxContext                                                                             )
-    , OBroadcastHelper              ( m_aMutex                                                                              )
-    , OPropertySetHelper            ( *(static_cast< OBroadcastHelper * >(this))  )
-    , m_aInterfaceContainer         ( m_aMutex                                                                              )
-    , m_aConnectionPointContainer   ( m_aMutex                                                                              )
+    : BaseControl                   ( rxContext                                     )
+    , OBroadcastHelper              ( m_aMutex                                      )
+    , OPropertySetHelper            ( *(static_cast< OBroadcastHelper * >(this))    )
+    , m_aInterfaceContainer         ( m_aMutex                                      )
+    , m_aConnectionPointContainer   ( new OConnectionPointContainerHelper(m_aMutex) )
 {
 }
 
@@ -233,7 +233,7 @@ Reference< XGraphics > SAL_CALL FrameControl::getGraphics() throw( RuntimeExcept
 Sequence< Type > SAL_CALL FrameControl::getConnectionPointTypes() throw( RuntimeException, std::exception )
 {
     // Forwarded to helper class
-    return m_aConnectionPointContainer.getConnectionPointTypes();
+    return m_aConnectionPointContainer->getConnectionPointTypes();
 }
 
 //  XConnectionPointContainer
@@ -241,7 +241,7 @@ Sequence< Type > SAL_CALL FrameControl::getConnectionPointTypes() throw( Runtime
 Reference< XConnectionPoint > SAL_CALL FrameControl::queryConnectionPoint( const Type& aType ) throw( RuntimeException, std::exception )
 {
     // Forwarded to helper class
-    return m_aConnectionPointContainer.queryConnectionPoint( aType );
+    return m_aConnectionPointContainer->queryConnectionPoint( aType );
 }
 
 //  XConnectionPointContainer
@@ -250,7 +250,7 @@ void SAL_CALL FrameControl::advise( const   Type&                       aType
                                     const   Reference< XInterface >&    xListener   ) throw( RuntimeException, std::exception )
 {
     // Forwarded to helper class
-    m_aConnectionPointContainer.advise( aType, xListener );
+    m_aConnectionPointContainer->advise( aType, xListener );
 }
 
 //  XConnectionPointContainer
@@ -259,7 +259,7 @@ void SAL_CALL FrameControl::unadvise(   const   Type&                       aTyp
                                         const   Reference< XInterface >&    xListener   ) throw( RuntimeException, std::exception )
 {
     // Forwarded to helper class
-    m_aConnectionPointContainer.unadvise( aType, xListener );
+    m_aConnectionPointContainer->unadvise( aType, xListener );
 }
 
 //  impl but public method to register service
diff --git a/UnoControls/source/inc/framecontrol.hxx b/UnoControls/source/inc/framecontrol.hxx
index e1b48b7..257edec 100644
--- a/UnoControls/source/inc/framecontrol.hxx
+++ b/UnoControls/source/inc/framecontrol.hxx
@@ -211,10 +211,10 @@ private:
 private:
 
     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame2 >        m_xFrame;
-    OUString                                        m_sComponentURL;
+    OUString                                                                    m_sComponentURL;
     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >   m_seqLoaderArguments;
-    ::cppu::OMultiTypeInterfaceContainerHelper      m_aInterfaceContainer;
-    OConnectionPointContainerHelper                 m_aConnectionPointContainer;
+    ::cppu::OMultiTypeInterfaceContainerHelper                                  m_aInterfaceContainer;
+    css::uno::Reference<OConnectionPointContainerHelper>                        m_aConnectionPointContainer;
 
 };  // class FrameControl
 
diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx
index 19e611a..085d9e3 100644
--- a/basic/source/inc/namecont.hxx
+++ b/basic/source/inc/namecont.hxx
@@ -231,7 +231,7 @@ protected:
     ::osl::Mutex        maMutex;
     ModifiableHelper    maModifiable;
 
-    NameContainer maNameContainer;
+    css::uno::Reference<NameContainer> maNameContainer;
     bool    mbOldInfoFormat;
     bool    mbOasis2OOoFormat;
 
@@ -560,11 +560,11 @@ class SfxLibrary
     friend class SfxDialogLibraryContainer;
     friend class SfxScriptLibraryContainer;
 
-    css::uno::Reference< css::uno::XComponentContext >       mxContext;
-    css::uno::Reference< css::ucb::XSimpleFileAccess3 >      mxSFI;
+    css::uno::Reference< css::uno::XComponentContext >    mxContext;
+    css::uno::Reference< css::ucb::XSimpleFileAccess3 >   mxSFI;
 
-    ModifiableHelper&   mrModifiable;
-    NameContainer       maNameContainer;
+    ModifiableHelper&                                     mrModifiable;
+    css::uno::Reference<NameContainer>                    maNameContainer;
 
     bool mbLoaded;
     bool mbIsModified;
diff --git a/basic/source/uno/dlgcont.cxx b/basic/source/uno/dlgcont.cxx
index 758b6ed..f4aa67f 100644
--- a/basic/source/uno/dlgcont.cxx
+++ b/basic/source/uno/dlgcont.cxx
@@ -401,7 +401,7 @@ Reference< css::resource::XStringResourcePersistence >
 void SfxDialogLibraryContainer::onNewRootStorage()
 {
     // the library container is not modified, go through the libraries and check whether they are modified
-    Sequence< OUString > aNames = maNameContainer.getElementNames();
+    Sequence< OUString > aNames = maNameContainer->getElementNames();
     const OUString* pNames = aNames.getConstArray();
     sal_Int32 nNameCount = aNames.getLength();
 
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index f274d79..8bf3b5c 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -383,7 +383,7 @@ SfxLibraryContainer::SfxLibraryContainer()
     , mnRunningVBAScripts( 0 )
     , mbVBACompat( false )
     , maModifiable( *this, maMutex )
-    , maNameContainer( cppu::UnoType<XNameAccess>::get())
+    , maNameContainer( new NameContainer(cppu::UnoType<XNameAccess>::get()) )
     , mbOldInfoFormat( false )
     , mbOasis2OOoFormat( false )
     , mpBasMgr( NULL )
@@ -499,7 +499,7 @@ sal_Bool SfxLibraryContainer::isModified()
         return sal_True;
     }
     // the library container is not modified, go through the libraries and check whether they are modified
-    Sequence< OUString > aNames = maNameContainer.getElementNames();
+    Sequence< OUString > aNames = maNameContainer->getElementNames();
     const OUString* pNames = aNames.getConstArray();
     sal_Int32 nNameCount = aNames.getLength();
 
@@ -1016,7 +1016,7 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
 
     // Preload?
     {
-        Sequence< OUString > aNames = maNameContainer.getElementNames();
+        Sequence< OUString > aNames = maNameContainer->getElementNames();
         const OUString* pNames = aNames.getConstArray();
         sal_Int32 nNameCount = aNames.getLength();
         for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
@@ -1201,7 +1201,7 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
 
                         if( aLibName == aStandardStr )
                         {
-                            maNameContainer.removeByName( aLibName );
+                            maNameContainer->removeByName( aLibName );
                         }
 
                         // Create library
@@ -1341,7 +1341,7 @@ void SfxLibraryContainer::checkStorageURL( const OUString& aSourceURL,
 
 SfxLibrary* SfxLibraryContainer::getImplLib( const OUString& rLibraryName )
 {
-    Any aLibAny = maNameContainer.getByName( rLibraryName ) ;
+    Any aLibAny = maNameContainer->getByName( rLibraryName ) ;
     Reference< XNameAccess > xNameAccess;
     aLibAny >>= xNameAccess;
     SfxLibrary* pImplLib = static_cast< SfxLibrary* >( xNameAccess.get() );
@@ -1781,7 +1781,7 @@ void SfxLibraryContainer::implImportLibDescriptor( SfxLibrary* pLib,
         Any aDummyElement = createEmptyLibraryElement();
         for( sal_Int32 i = 0 ; i < nElementCount ; i++ )
         {
-            pLib->maNameContainer.insertByName( pElementNames[i], aDummyElement );
+            pLib->maNameContainer->insertByName( pElementNames[i], aDummyElement );
         }
         pLib->mbPasswordProtected = rLib.bPasswordProtected;
         pLib->mbReadOnly = rLib.bReadOnly;
@@ -1796,7 +1796,7 @@ void SfxLibraryContainer::implImportLibDescriptor( SfxLibrary* pLib,
 void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XStorage >& i_rStorage,
                                                bool bComplete )
 {
-    const Sequence< OUString > aNames = maNameContainer.getElementNames();
+    const Sequence< OUString > aNames = maNameContainer->getElementNames();
     const sal_Int32 nNameCount = aNames.getLength();
     const OUString* pName = aNames.getConstArray();
     const OUString* pNamesEnd = aNames.getConstArray() + nNameCount;
@@ -1832,7 +1832,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
         // Don't write if only empty standard lib exists
         if ( ( nLibsToSave == 1 ) && ( aNames[0] == "Standard" ) )
         {
-            Any aLibAny = maNameContainer.getByName( aNames[0] );
+            Any aLibAny = maNameContainer->getByName( aNames[0] );
             Reference< XNameAccess > xNameAccess;
             aLibAny >>= xNameAccess;
             if ( ! xNameAccess->hasElements() )
@@ -2187,14 +2187,14 @@ Type SAL_CALL SfxLibraryContainer::getElementType()
     throw(RuntimeException, std::exception)
 {
     LibraryContainerMethodGuard aGuard( *this );
-    return maNameContainer.getElementType();
+    return maNameContainer->getElementType();
 }
 
 sal_Bool SfxLibraryContainer::hasElements()
     throw(RuntimeException, std::exception)
 {
     LibraryContainerMethodGuard aGuard( *this );
-    bool bRet = maNameContainer.hasElements();
+    bool bRet = maNameContainer->hasElements();
     return bRet;
 }
 
@@ -2203,7 +2203,7 @@ Any SfxLibraryContainer::getByName( const OUString& aName )
     throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
 {
     LibraryContainerMethodGuard aGuard( *this );
-    Any aRetAny = maNameContainer.getByName( aName ) ;
+    Any aRetAny = maNameContainer->getByName( aName ) ;
     return aRetAny;
 }
 
@@ -2211,14 +2211,14 @@ Sequence< OUString > SfxLibraryContainer::getElementNames()
     throw(RuntimeException, std::exception)
 {
     LibraryContainerMethodGuard aGuard( *this );
-    return maNameContainer.getElementNames();
+    return maNameContainer->getElementNames();
 }
 
 sal_Bool SfxLibraryContainer::hasByName( const OUString& aName )
     throw(RuntimeException, std::exception)
 {
     LibraryContainerMethodGuard aGuard( *this );
-    return maNameContainer.hasByName( aName ) ;
+    return maNameContainer->hasByName( aName ) ;
 }
 
 // Methods XLibraryContainer
@@ -2234,7 +2234,7 @@ Reference< XNameContainer > SAL_CALL SfxLibraryContainer::createLibrary( const O
     Reference< XNameAccess > xNameAccess = static_cast< XNameAccess* >( pNewLib );
     Any aElement;
     aElement <<= xNameAccess;
-    maNameContainer.insertByName( Name, aElement );
+    maNameContainer->insertByName( Name, aElement );
     maModifiable.setModified( true );
     Reference< XNameContainer > xRet( xNameAccess, UNO_QUERY );
     return xRet;
@@ -2270,7 +2270,7 @@ Reference< XNameAccess > SAL_CALL SfxLibraryContainer::createLibraryLink
     Reference< XNameAccess > xRet = static_cast< XNameAccess* >( pNewLib );
     Any aElement;
     aElement <<= xRet;
-    maNameContainer.insertByName( Name, aElement );
+    maNameContainer->insertByName( Name, aElement );
     maModifiable.setModified( true );
 
     OUString aUserSearchStr("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE");
@@ -2294,7 +2294,7 @@ void SAL_CALL SfxLibraryContainer::removeLibrary( const OUString& Name )
 {
     LibraryContainerMethodGuard aGuard( *this );
     // Get and hold library before removing
-    Any aLibAny = maNameContainer.getByName( Name ) ;
+    Any aLibAny = maNameContainer->getByName( Name ) ;
     Reference< XNameAccess > xNameAccess;
     aLibAny >>= xNameAccess;
     SfxLibrary* pImplLib = static_cast< SfxLibrary* >( xNameAccess.get() );
@@ -2303,7 +2303,7 @@ void SAL_CALL SfxLibraryContainer::removeLibrary( const OUString& Name )
         throw IllegalArgumentException();
     }
     // Remove from container
-    maNameContainer.removeByName( Name );
+    maNameContainer->removeByName( Name );
     maModifiable.setModified( true );
 
     // Delete library files, but not for linked libraries
@@ -2374,7 +2374,7 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
     throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
 {
     LibraryContainerMethodGuard aGuard( *this );
-    Any aLibAny = maNameContainer.getByName( Name ) ;
+    Any aLibAny = maNameContainer->getByName( Name ) ;
     Reference< XNameAccess > xNameAccess;
     aLibAny >>= xNameAccess;
     SfxLibrary* pImplLib = static_cast< SfxLibrary* >( xNameAccess.get() );
@@ -2501,12 +2501,12 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
             {
                 if( aAny.hasValue() )
                 {
-                    pImplLib->maNameContainer.replaceByName( aElementName, aAny );
+                    pImplLib->maNameContainer->replaceByName( aElementName, aAny );
                 }
             }
             else
             {
-                pImplLib->maNameContainer.insertNoCheck(aElementName, aAny);
+                pImplLib->maNameContainer->insertNoCheck(aElementName, aAny);
             }
         }
         pImplLib->implSetModified( false );
@@ -2574,12 +2574,12 @@ void SAL_CALL SfxLibraryContainer::renameLibrary( const OUString& Name, const OU
     throw (NoSuchElementException, ElementExistException, RuntimeException, std::exception)
 {
     LibraryContainerMethodGuard aGuard( *this );
-    if( maNameContainer.hasByName( NewName ) )
+    if( maNameContainer->hasByName( NewName ) )
     {
         throw ElementExistException();
     }
     // Get and hold library before removing
-    Any aLibAny = maNameContainer.getByName( Name ) ;
+    Any aLibAny = maNameContainer->getByName( Name ) ;
 
     // #i24094 Maybe lib is not loaded!
     Reference< XNameAccess > xNameAccess;
@@ -2592,7 +2592,7 @@ void SAL_CALL SfxLibraryContainer::renameLibrary( const OUString& Name, const OU
     loadLibrary( Name );
 
     // Remove from container
-    maNameContainer.removeByName( Name );
+    maNameContainer->removeByName( Name );
     maModifiable.setModified( true );
 
     // Rename library folder, but not for linked libraries
@@ -2686,7 +2686,7 @@ void SAL_CALL SfxLibraryContainer::renameLibrary( const OUString& Name, const OU
         catch(const Exception& )
         {
             // Restore old library
-            maNameContainer.insertByName( Name, aLibAny ) ;
+            maNameContainer->insertByName( Name, aLibAny ) ;
         }
     }
 
@@ -2696,7 +2696,7 @@ void SAL_CALL SfxLibraryContainer::renameLibrary( const OUString& Name, const OU
     }
     if( bMovedSuccessful )
     {
-           maNameContainer.insertByName( NewName, aLibAny ) ;
+           maNameContainer->insertByName( NewName, aLibAny ) ;
     }
 }
 
@@ -2816,15 +2816,15 @@ void SAL_CALL SfxLibraryContainer::addContainerListener( const Reference< XConta
     throw (RuntimeException, std::exception)
 {
     LibraryContainerMethodGuard aGuard( *this );
-    maNameContainer.setEventSource( static_cast< XInterface* >( static_cast<OWeakObject*>(this) ) );
-    maNameContainer.addContainerListener( xListener );
+    maNameContainer->setEventSource( static_cast< XInterface* >( static_cast<OWeakObject*>(this) ) );
+    maNameContainer->addContainerListener( xListener );
 }
 
 void SAL_CALL SfxLibraryContainer::removeContainerListener( const Reference< XContainerListener >& xListener )
     throw (RuntimeException, std::exception)
 {
     LibraryContainerMethodGuard aGuard( *this );
-    maNameContainer.removeContainerListener( xListener );
+    maNameContainer->removeContainerListener( xListener );
 }
 
 // Methods XLibraryContainerExport
@@ -3008,7 +3008,7 @@ SfxLibrary::SfxLibrary( ModifiableHelper& _rModifiable, const Type& aType,
         , mxContext( xContext )
         , mxSFI( xSFI )
         , mrModifiable( _rModifiable )
-        , maNameContainer( aType )
+        , maNameContainer( new NameContainer(aType) )
         , mbLoaded( true )
         , mbIsModified( true )
         , mbInitialised( false )
@@ -3031,7 +3031,7 @@ SfxLibrary::SfxLibrary( ModifiableHelper& _rModifiable, const Type& aType,
         , mxContext( xContext )
         , mxSFI( xSFI )
         , mrModifiable( _rModifiable )
-        , maNameContainer( aType )
+        , maNameContainer( new NameContainer(aType) )
         , mbLoaded( false )
         , mbIsModified( true )
         , mbInitialised( false )
@@ -3092,13 +3092,13 @@ Any SAL_CALL SfxLibrary::queryInterface( const Type& rType )
 Type SfxLibrary::getElementType()
     throw(RuntimeException, std::exception)
 {
-    return maNameContainer.getElementType();
+    return maNameContainer->getElementType();
 }
 
 sal_Bool SfxLibrary::hasElements()
     throw(RuntimeException, std::exception)
 {
-    bool bRet = maNameContainer.hasElements();
+    bool bRet = maNameContainer->hasElements();
     return bRet;
 }
 
@@ -3108,20 +3108,20 @@ Any SfxLibrary::getByName( const OUString& aName )
 {
     impl_checkLoaded();
 
-    Any aRetAny = maNameContainer.getByName( aName ) ;
+    Any aRetAny = maNameContainer->getByName( aName ) ;
     return aRetAny;
 }
 
 Sequence< OUString > SfxLibrary::getElementNames()
     throw(RuntimeException, std::exception)
 {
-    return maNameContainer.getElementNames();
+    return maNameContainer->getElementNames();
 }
 
 sal_Bool SfxLibrary::hasByName( const OUString& aName )
     throw(RuntimeException, std::exception)
 {
-    bool bRet = maNameContainer.hasByName( aName );
+    bool bRet = maNameContainer->hasByName( aName );
     return bRet;
 }
 
@@ -3163,7 +3163,7 @@ void SfxLibrary::replaceByName( const OUString& aName, const Any& aElement )
         !isLibraryElementValid(aElement), "basic",
         "SfxLibrary::replaceByName: replacing element is invalid!");
 
-    maNameContainer.replaceByName( aName, aElement );
+    maNameContainer->replaceByName( aName, aElement );
     implSetModified( true );
 }
 
@@ -3179,13 +3179,13 @@ void SfxLibrary::insertByName( const OUString& aName, const Any& aElement )
         !isLibraryElementValid(aElement), "basic",
         "SfxLibrary::insertByName: to-be-inserted element is invalid!");
 
-    maNameContainer.insertByName( aName, aElement );
+    maNameContainer->insertByName( aName, aElement );
     implSetModified( true );
 }
 
 void SfxLibrary::impl_removeWithoutChecks( const OUString& _rElementName )
 {
-    maNameContainer.removeByName( _rElementName );
+    maNameContainer->removeByName( _rElementName );
     implSetModified( true );
 
     // Remove element file
@@ -3254,28 +3254,28 @@ Sequence< sal_Int8 > SfxLibrary::getImplementationId()
 void SAL_CALL SfxLibrary::addContainerListener( const Reference< XContainerListener >& xListener )
     throw (RuntimeException, std::exception)
 {
-    maNameContainer.setEventSource( static_cast< XInterface* >( static_cast<OWeakObject*>(this) ) );
-    maNameContainer.addContainerListener( xListener );
+    maNameContainer->setEventSource( static_cast< XInterface* >( static_cast<OWeakObject*>(this) ) );
+    maNameContainer->addContainerListener( xListener );
 }
 
 void SAL_CALL SfxLibrary::removeContainerListener( const Reference< XContainerListener >& xListener )
     throw (RuntimeException, std::exception)
 {
-    maNameContainer.removeContainerListener( xListener );
+    maNameContainer->removeContainerListener( xListener );
 }
 
 // Methods XChangesNotifier
 void SAL_CALL SfxLibrary::addChangesListener( const Reference< XChangesListener >& xListener )
     throw (RuntimeException, std::exception)
 {
-    maNameContainer.setEventSource( static_cast< XInterface* >( static_cast<OWeakObject*>(this) ) );
-    maNameContainer.addChangesListener( xListener );
+    maNameContainer->setEventSource( static_cast< XInterface* >( static_cast<OWeakObject*>(this) ) );
+    maNameContainer->addChangesListener( xListener );
 }
 
 void SAL_CALL SfxLibrary::removeChangesListener( const Reference< XChangesListener >& xListener )
     throw (RuntimeException, std::exception)
 {
-    maNameContainer.removeChangesListener( xListener );
+    maNameContainer->removeChangesListener( xListener );
 }
 
 
diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx
index 7b3ab75..c7df851 100644
--- a/basic/source/uno/scriptcont.cxx
+++ b/basic/source/uno/scriptcont.cxx
@@ -999,12 +999,12 @@ bool SfxScriptLibraryContainer::implLoadPasswordLibrary
                         {
                             if( aAny.hasValue() )
                             {
-                                pLib->maNameContainer.replaceByName( aElementName, aAny );
+                                pLib->maNameContainer->replaceByName( aElementName, aAny );
                             }
                         }
                         else
                         {
-                            pLib->maNameContainer.insertByName( aElementName, aAny );
+                            pLib->maNameContainer->insertByName( aElementName, aAny );
                         }
                     }
                 }
@@ -1113,12 +1113,12 @@ bool SfxScriptLibraryContainer::implLoadPasswordLibrary
                                 {
                                     if( aAny.hasValue() )
                                     {
-                                        pLib->maNameContainer.replaceByName( aElementName, aAny );
+                                        pLib->maNameContainer->replaceByName( aElementName, aAny );
                                     }
                                 }
                                 else
                                 {
-                                    pLib->maNameContainer.insertByName( aElementName, aAny );
+                                    pLib->maNameContainer->insertByName( aElementName, aAny );
                                 }
                             }
                         }
diff --git a/compilerplugins/clang/refcounting.cxx b/compilerplugins/clang/refcounting.cxx
new file mode 100644
index 0000000..0ecdf8e
--- /dev/null
+++ b/compilerplugins/clang/refcounting.cxx
@@ -0,0 +1,249 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <string>
+#include <iostream>
+
+#include "plugin.hxx"
+#include "compat.hxx"
+#include "clang/AST/CXXInheritance.h"
+
+/**
+
+If you have:
+
+    class Foo : public css::foo::XBaa {
+    };
+
+Then XBaa has acquire and release methods inherited from XInterface.
+These are hard lifecycle controls.
+
+If you see another class:
+
+    class Baz {
+        Foo aFooMember;
+    };
+
+this is a bug =) since aFooMember assumes heap allocated lifecycle and
+not delete on last 'release'.
+
+TODO check that things that extend SvRefBase are managed by SvRef
+TODO fix the SvXMLImportContext class (mentioned below)
+TODO fix the slideshow::internal::SlideView class (mentioned below)
+*/
+
+namespace {
+
+class RefCounting:
+    public RecursiveASTVisitor<RefCounting>, public loplugin::Plugin
+{
+public:
+    explicit RefCounting(InstantiationData const & data): Plugin(data) {}
+
+    virtual void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
+
+    bool VisitFieldDecl(const FieldDecl *);
+    bool VisitVarDecl(const VarDecl *);
+};
+
+bool BaseCheckNotSubclass(const CXXRecordDecl *BaseDefinition, void *p) {
+    if (!BaseDefinition)
+        return true;
+    const char *pString = static_cast<const char *>(p);
+    if (BaseDefinition->getQualifiedNameAsString() == pString) {
+        return false;
+    }
+    return true;
+}
+
+bool isDerivedFrom(const CXXRecordDecl *decl, const char *pString) {
+    if (!decl)
+        return false;
+    if (decl->getQualifiedNameAsString() == pString)
+        return true;
+    if (!decl->hasDefinition()) {
+        return false;
+    }
+    if (// not sure what hasAnyDependentBases() does,
+        // but it avoids classes we don't want, e.g. WeakAggComponentImplHelper1
+        !decl->hasAnyDependentBases() &&
+        !decl->forallBases(BaseCheckNotSubclass, static_cast<void*>(const_cast<char*>(pString)), true)) {
+        return true;
+    }
+    return false;
+}
+
+
+bool containsXInterfaceSubclass(const Type* pType0);
+
+bool containsXInterfaceSubclass(const QualType& qType) {
+    return containsXInterfaceSubclass(qType.getTypePtr());
+}
+
+static std::vector<std::string> PROBABLY_GOOD_TEMPLATES = {
+    "(anonymous namespace)::FindUnoInstanceHint",
+    "abp::OMultiInstanceAutoRegistration",
+    "com::sun::star::uno::Reference",
+    "com::sun::star::uno::WeakReference",
+    "com::sun::star::uno::Sequence",
+    "accessibility::HardCppRef",
+    "accessibility::WeakCppRef",
+    "dba::OAutoRegistration",
+    "dba::OSingletonRegistration",
+    "dbp::OMultiInstanceAutoRegistration",
+    "dbaui::OMultiInstanceAutoRegistration",
+    "dbaxml::OMultiInstanceAutoRegistration",
+    "io_acceptor::ReferenceEqual",
+    "io_acceptor::ReferenceHash",
+    "comphelper::OAutoRegistration",
+    "comphelper::OInterfaceCompare",
+    "comphelper::module::OSingletonRegistration",
+    "comphelper::WeakBag",
+    "comphelper::service_decl::class_",
+    "comphelper::service_decl::vba_service_class_",
+    "comphelper::service_decl::inheritingClass_",
+    "comphelper::module::OAutoRegistration",
+    "comphelper::mem_fun1_t",
+    "comphelper::OSimpleListenerContainer",
+    "dbmm::OAutoRegistration",
+    "pcr::OAutoRegistration",
+    "logging::ComponentMethodGuard",
+    "logging::OSingletonRegistration",
+    "logging::OAutoRegistration",
+    "rtl::Reference",
+    "sdbtools::OAutoRegistration",
+    "stoc_connector::ReferenceEqual",
+    "stoc_connector::ReferenceHash",
+    "std::mem_fun_t",
+    "std::mem_fun1_t",
+    "SwIterator",
+    "toolkit::InitGuard",
+    "utl::SharedUNOComponent",
+    "utl::OAutoRegistration",
+    "vcl::DeleteUnoReferenceOnDeinit",
+    "xmloff::OInterfaceCompare",
+};
+
+bool containsXInterfaceSubclass(const Type* pType0) {
+    if (!pType0)
+        return false;
+    const Type* pType = pType0->getUnqualifiedDesugaredType();
+    if (!pType)
+        return false;
+    const CXXRecordDecl* pRecordDecl = pType->getAsCXXRecordDecl();
+    if (pRecordDecl) {
+        pRecordDecl = pRecordDecl->getCanonicalDecl();
+        // these classes override acquire/release and forwards to it's parent
+        if (isDerivedFrom(pRecordDecl, "ListenerMultiplexerBase")) { // module UnoTools
+            return false;
+        }
+        if (isDerivedFrom(pRecordDecl, "toolkit::GridEventForwarder")) { // module toolkit
+            return false;
+        }
+        if (isDerivedFrom(pRecordDecl, "OWeakSubObject")) { // module svx
+            return false;
+        }
+        if (isDerivedFrom(pRecordDecl, "dbaui::OSbaWeakSubObject")) { // module dbaccess
+            return false;
+        }
+        // FIXME this class extends 2 different ref-counting bases, SvRefBase and XInterface (via. cppu::WeakImplHelper)
+        // I have no idea how to fix it
+        if (isDerivedFrom(pRecordDecl, "SvXMLImportContext")) { // module xmloff
+            return false;
+        }
+        // The actual problem child is SlideView, of which this is the parent.
+        // Everything in the hierarchy above this wants to be managed via boost::shared_ptr
+        if (isDerivedFrom(pRecordDecl, "slideshow::internal::UnoView")) { // module slideshow
+            return false;
+        }
+        // FIXME This class has private operator new, and I cannot figure out how it can be dynamically instantiated
+        if (isDerivedFrom(pRecordDecl, "XPropertyList")) { // module svx
+            return false;
+        }
+    }
+    if (pRecordDecl) {
+        const ClassTemplateSpecializationDecl* pTemplate = dyn_cast<ClassTemplateSpecializationDecl>(pRecordDecl);
+        if (pTemplate) {
+            std::string aName = pTemplate->getQualifiedNameAsString();
+            if (std::find(PROBABLY_GOOD_TEMPLATES.begin(), PROBABLY_GOOD_TEMPLATES.end(), aName) != PROBABLY_GOOD_TEMPLATES.end())
+                return false;
+            for(unsigned i=0; i<pTemplate->getTemplateArgs().size(); ++i) {
+                const TemplateArgument& rArg = pTemplate->getTemplateArgs()[i];
+                if (rArg.getKind() == TemplateArgument::ArgKind::Type &&
+                    containsXInterfaceSubclass(rArg.getAsType()))
+                {
+                    return true;
+                }
+            }
+        }
+    }
+    if (pType->isPointerType()) {
+        // ignore
+        return false;
+    } else if (pType->isArrayType()) {
+        const ArrayType* pArrayType = dyn_cast<ArrayType>(pType);
+        QualType elementType = pArrayType->getElementType();
+        return containsXInterfaceSubclass(elementType);
+    } else {
+        return isDerivedFrom(pRecordDecl, "com::sun::star::uno::XInterface");
+    }
+}
+
+
+
+bool RefCounting::VisitFieldDecl(const FieldDecl * fieldDecl) {
+    if (ignoreLocation(fieldDecl)) {
+        return true;
+    }
+    if (fieldDecl->isBitField()) {
+        return true;
+    }
+    std::string aParentName = fieldDecl->getParent()->getQualifiedNameAsString();
+    if ( aParentName == "com::sun::star::uno::BaseReference"
+         || aParentName == "cppu::detail::element_alias"
+         // this is playing some kind of game to avoid circular references
+         || aParentName == "ucbhelper::ResultSetDataSupplier")
+    {
+        return true;
+    }
+
+    if (containsXInterfaceSubclass(fieldDecl->getType())) {
+        report(
+            DiagnosticsEngine::Warning,
+            "XInterface subclass being directly heap managed, should be managed via uno::Reference, "
+            + fieldDecl->getType().getAsString()
+            + ", parent is " + aParentName,
+            fieldDecl->getLocation())
+          << fieldDecl->getSourceRange();
+        return true;
+    }
+    return true;
+}
+
+
+bool RefCounting::VisitVarDecl(const VarDecl * varDecl) {
+    if (ignoreLocation(varDecl)) {
+        return true;
+    }
+    if (containsXInterfaceSubclass(varDecl->getType())) {
+        report(
+            DiagnosticsEngine::Warning,
+            "XInterface subclass being directly stack managed, should be managed via uno::Reference, "
+            + varDecl->getType().getAsString(),
+            varDecl->getLocation())
+          << varDecl->getSourceRange();
+    }
+    return true;
+}
+
+loplugin::Plugin::Registration< RefCounting > X("refcounting");
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
index 7708a6a..ae89078 100644
--- a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
+++ b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
@@ -191,8 +191,9 @@ Reference< XInterface > OComponentDefinition::Create( const Reference< XComponen
 void SAL_CALL OComponentDefinition::disposing()
 {
     OContentHelper::disposing();
-    if ( m_pColumns.get() )
-        m_pColumns->disposing();
+    if ( m_xColumns.is() )
+        m_xColumns->disposing();
+    m_xColumns.clear();
     m_xColumnPropertyListener->clear();
     m_xColumnPropertyListener.clear();
 }
@@ -227,7 +228,7 @@ Reference< XNameAccess> OComponentDefinition::getColumns() throw (RuntimeExcepti
     ::osl::MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OContentHelper::rBHelper.bDisposed);
 
-    if ( !m_pColumns.get() )
+    if ( !m_xColumns.is() )
     {
         ::std::vector< OUString> aNames;
 
@@ -239,10 +240,10 @@ Reference< XNameAccess> OComponentDefinition::getColumns() throw (RuntimeExcepti
         for ( ; aIter != aEnd; ++aIter )
             aNames.push_back( aIter->first );
 
-        m_pColumns.reset( new OColumns( *this, m_aMutex, true, aNames, this, NULL, true, false, false ) );
-        m_pColumns->setParent( *this );
+        m_xColumns = new OColumns( *this, m_aMutex, true, aNames, this, NULL, true, false, false );
+        m_xColumns->setParent( *this );
     }
-    return m_pColumns.get();
+    return m_xColumns.get();
 }
 
 OColumn* OComponentDefinition::createColumn(const OUString& _rName) const
diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.hxx b/dbaccess/source/core/dataaccess/ComponentDefinition.hxx
index ad177f5..b561874 100644
--- a/dbaccess/source/core/dataaccess/ComponentDefinition.hxx
+++ b/dbaccess/source/core/dataaccess/ComponentDefinition.hxx
@@ -88,7 +88,7 @@ class OComponentDefinition  :public OContentHelper
     OComponentDefinition();
 
 protected:
-    ::std::unique_ptr< OColumns >     m_pColumns;
+    css::uno::Reference< OColumns >     m_xColumns;
     rtl::Reference<OColumnPropertyListener> m_xColumnPropertyListener;
     bool                        m_bTable;
 
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx
index 5568cb8..1f80f08 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -491,7 +491,7 @@ ODatabaseSource::ODatabaseSource(const ::rtl::Reference<ODatabaseModelImpl>& _pI
             :ModelDependentComponent( _pImpl )
             ,ODatabaseSource_Base( getMutex() )
             ,OPropertySetHelper( ODatabaseSource_Base::rBHelper )
-            ,m_aBookmarks( *this, getMutex() )
+            ,m_xBookmarks( new OBookmarkContainer( *this, getMutex() ) )
             ,m_aFlushListeners( getMutex() )
 {
     // some kind of default
@@ -1200,7 +1200,7 @@ Reference< XConnection > ODatabaseSource::getConnection(const OUString& user, co
 Reference< XNameAccess > SAL_CALL ODatabaseSource::getBookmarks(  ) throw (RuntimeException, std::exception)
 {
     ModelMethodGuard aGuard( *this );
-    return static_cast< XNameContainer* >(&m_aBookmarks);
+    return static_cast< XNameContainer* >(m_xBookmarks.get());
 }
 
 Reference< XNameAccess > SAL_CALL ODatabaseSource::getQueryDefinitions( ) throw(RuntimeException, std::exception)
diff --git a/dbaccess/source/core/dataaccess/datasource.hxx b/dbaccess/source/core/dataaccess/datasource.hxx
index 8e53e9f..1aef2a7 100644
--- a/dbaccess/source/core/dataaccess/datasource.hxx
+++ b/dbaccess/source/core/dataaccess/datasource.hxx
@@ -82,7 +82,7 @@ class ODatabaseSource   :public ModelDependentComponent // must be first
 
 private:
     using ODatabaseSource_Base::rBHelper;
-    OBookmarkContainer                      m_aBookmarks;
+    css::uno::Reference<OBookmarkContainer> m_xBookmarks;
     ::cppu::OInterfaceContainerHelper       m_aFlushListeners;
 
 private:
diff --git a/dbaccess/source/ui/misc/singledoccontroller.cxx b/dbaccess/source/ui/misc/singledoccontroller.cxx
index 77408cd..ed6180b 100644
--- a/dbaccess/source/ui/misc/singledoccontroller.cxx
+++ b/dbaccess/source/ui/misc/singledoccontroller.cxx
@@ -54,10 +54,10 @@ namespace dbaui
     // OSingleDocumentController_Data
     struct OSingleDocumentController_Data
     {
-        ::boost::scoped_ptr< UndoManager >  m_pUndoManager;
+        Reference< UndoManager >  m_xUndoManager;
 
         OSingleDocumentController_Data( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
-            :m_pUndoManager( new UndoManager( i_parent, i_mutex ) )
+            :m_xUndoManager( new UndoManager( i_parent, i_mutex ) )
         {
         }
     };
@@ -77,7 +77,7 @@ namespace dbaui
     {
         OSingleDocumentController_Base::disposing();
         ClearUndoManager();
-        m_pData->m_pUndoManager->disposing();
+        m_pData->m_xUndoManager->disposing();
     }
 
     void SAL_CALL OSingleDocumentController::disposing( const EventObject& i_event ) throw( RuntimeException, std::exception )
@@ -93,7 +93,7 @@ namespace dbaui
 
     SfxUndoManager& OSingleDocumentController::GetUndoManager() const
     {
-        return m_pData->m_pUndoManager->GetSfxUndoManager();
+        return m_pData->m_xUndoManager->GetSfxUndoManager();
     }
 
     void OSingleDocumentController::addUndoActionAndInvalidate(SfxUndoAction *_pAction)
@@ -111,7 +111,7 @@ namespace dbaui
 
     Reference< XUndoManager > SAL_CALL OSingleDocumentController::getUndoManager(  ) throw (RuntimeException, std::exception)
     {
-        return m_pData->m_pUndoManager.get();
+        return m_pData->m_xUndoManager.get();
     }
 
     FeatureState OSingleDocumentController::GetState(sal_uInt16 _nId) const
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
index 651e406..e6a12cd 100644
--- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
@@ -1165,11 +1165,11 @@ namespace drawinglayer
                         // per polygon. If there are more, split the polygon in half and call recursively
                         basegfx::B2DPolygon aLeft, aRight;
                         splitLinePolygon(rBasePolygon, aLeft, aRight);
-                        const primitive2d::PolygonHairlinePrimitive2D aPLeft(aLeft, rHairlinePrimitive.getBColor());
-                        const primitive2d::PolygonHairlinePrimitive2D aPRight(aRight, rHairlinePrimitive.getBColor());
+                        uno::Reference< primitive2d::PolygonHairlinePrimitive2D > xPLeft(new primitive2d::PolygonHairlinePrimitive2D(aLeft, rHairlinePrimitive.getBColor()));
+                        uno::Reference< primitive2d::PolygonHairlinePrimitive2D > xPRight(new primitive2d::PolygonHairlinePrimitive2D(aRight, rHairlinePrimitive.getBColor()));
 
-                        processBasePrimitive2D(aPLeft);
-                        processBasePrimitive2D(aPRight);
+                        processBasePrimitive2D(*xPLeft.get());
+                        processBasePrimitive2D(*xPRight.get());
                     }
                     else
                     {
@@ -1213,13 +1213,13 @@ namespace drawinglayer
                         // per polygon. If there are more, split the polygon in half and call recursively
                         basegfx::B2DPolygon aLeft, aRight;
                         splitLinePolygon(rBasePolygon, aLeft, aRight);
-                        const primitive2d::PolygonStrokePrimitive2D aPLeft(
-                            aLeft, rStrokePrimitive.getLineAttribute(), rStrokePrimitive.getStrokeAttribute());
-                        const primitive2d::PolygonStrokePrimitive2D aPRight(
-                            aRight, rStrokePrimitive.getLineAttribute(), rStrokePrimitive.getStrokeAttribute());
+                        uno::Reference< primitive2d::PolygonStrokePrimitive2D > xPLeft(new primitive2d::PolygonStrokePrimitive2D(
+                            aLeft, rStrokePrimitive.getLineAttribute(), rStrokePrimitive.getStrokeAttribute()));
+                        uno::Reference< primitive2d::PolygonStrokePrimitive2D > xPRight(new primitive2d::PolygonStrokePrimitive2D(
+                            aRight, rStrokePrimitive.getLineAttribute(), rStrokePrimitive.getStrokeAttribute()));
 
-                        processBasePrimitive2D(aPLeft);
-                        processBasePrimitive2D(aPRight);
+                        processBasePrimitive2D(*xPLeft.get());
+                        processBasePrimitive2D(*xPRight.get());
                     }
                     else
                     {
@@ -1294,21 +1294,21 @@ namespace drawinglayer
                         basegfx::B2DPolygon aLeft, aRight;
                         splitLinePolygon(rBasePolygon, aLeft, aRight);
                         const attribute::LineStartEndAttribute aEmpty;
-                        const primitive2d::PolygonStrokeArrowPrimitive2D aPLeft(
+                        uno::Reference< primitive2d::PolygonStrokeArrowPrimitive2D > xPLeft(new primitive2d::PolygonStrokeArrowPrimitive2D(
                             aLeft,
                             rStrokeArrowPrimitive.getLineAttribute(),
                             rStrokeArrowPrimitive.getStrokeAttribute(),
                             rStrokeArrowPrimitive.getStart(),
-                            aEmpty);
-                        const primitive2d::PolygonStrokeArrowPrimitive2D aPRight(
+                            aEmpty));
+                        uno::Reference< primitive2d::PolygonStrokeArrowPrimitive2D > xPRight(new primitive2d::PolygonStrokeArrowPrimitive2D(
                             aRight,
                             rStrokeArrowPrimitive.getLineAttribute(),
                             rStrokeArrowPrimitive.getStrokeAttribute(),
                             aEmpty,
-                            rStrokeArrowPrimitive.getEnd());
+                            rStrokeArrowPrimitive.getEnd()));
 
-                        processBasePrimitive2D(aPLeft);
-                        processBasePrimitive2D(aPRight);
+                        processBasePrimitive2D(*xPLeft.get());
+                        processBasePrimitive2D(*xPRight.get());
                     }
                     else
                     {
@@ -1372,11 +1372,11 @@ namespace drawinglayer
                     {
                         // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points
                         // per polygon. If there are more use the splitted polygon and call recursively
-                        const primitive2d::PolyPolygonGraphicPrimitive2D aSplitted(
+                        uno::Reference< primitive2d::PolyPolygonGraphicPrimitive2D > xSplitted(new primitive2d::PolyPolygonGraphicPrimitive2D(
                             aLocalPolyPolygon,
-                            rBitmapCandidate.getFillGraphic());
+                            rBitmapCandidate.getFillGraphic()));
 
-                        processBasePrimitive2D(aSplitted);
+                        processBasePrimitive2D(*xSplitted.get());
                     }
                     else
                     {
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index efb82d8..8d5fcf70 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -110,112 +110,112 @@ void Test::testUnoTextFields()
 {
     {
         // DATE
-        SvxUnoTextField aField(text::textfield::Type::DATE);
-        uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+        uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::DATE));
+        uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     }
 
     {
         // URL
-        SvxUnoTextField aField(text::textfield::Type::URL);
-        uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+        uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::URL));
+        uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.URL");
         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     }
 
     {
         // PAGE
-        SvxUnoTextField aField(text::textfield::Type::PAGE);
-        uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+        uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::PAGE));
+        uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.PageNumber");
         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     }
 
     {
         // PAGES
-        SvxUnoTextField aField(text::textfield::Type::PAGES);
-        uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+        uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::PAGES));
+        uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.PageCount");
         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     }
 
     {
         // TIME
-        SvxUnoTextField aField(text::textfield::Type::TIME);
-        uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+        uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::TIME));
+        uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     }
 
     {
         // FILE
-        SvxUnoTextField aField(text::textfield::Type::DOCINFO_TITLE);
-        uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+        uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::DOCINFO_TITLE));
+        uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.docinfo.Title");
         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     }
 
     {
         // TABLE
-        SvxUnoTextField aField(text::textfield::Type::TABLE);
-        uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+        uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::TABLE));
+        uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.SheetName");
         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     }
 
     {
         // EXTENDED TIME
-        SvxUnoTextField aField(text::textfield::Type::EXTENDED_TIME);
-        uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+        uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::EXTENDED_TIME));
+        uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     }
 
     {
         // EXTENDED FILE
-        SvxUnoTextField aField(text::textfield::Type::EXTENDED_FILE);
-        uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+        uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::EXTENDED_FILE));
+        uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.FileName");
         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     }
 
     {
         // AUTHOR
-        SvxUnoTextField aField(text::textfield::Type::AUTHOR);
-        uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+        uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::AUTHOR));
+        uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.Author");
         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     }
 
     {
         // MEASURE
-        SvxUnoTextField aField(text::textfield::Type::MEASURE);
-        uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+        uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::MEASURE));
+        uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.Measure");
         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     }
 
     {
         // PRESENTATION HEADER
-        SvxUnoTextField aField(text::textfield::Type::PRESENTATION_HEADER);
-        uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+        uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::PRESENTATION_HEADER));
+        uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
         bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.Header");
         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     }
 
     {
         // PRESENTATION FOOTER
-        SvxUnoTextField aField(text::textfield::Type::PRESENTATION_FOOTER);
-        uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+        uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::PRESENTATION_FOOTER));
+        uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
         bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.Footer");
         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     }
 
     {
         // PRESENTATION DATE TIME
-        SvxUnoTextField aField(text::textfield::Type::PRESENTATION_DATE_TIME);
-        uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+        uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::PRESENTATION_DATE_TIME));
+        uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
         bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.DateTime");
         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     }
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
index 8ce55d8..87886f4 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -1612,11 +1612,11 @@ namespace accessibility
 //                  SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
 //                      ImplGetSvxCharAndParaPropertiesMap() );
                     // MT IA2 TODO: Check if this is the correct replacement for ImplGetSvxCharAndParaPropertiesMap
-                    SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() );
+                    uno::Reference< SvxAccessibleTextPropertySet > xPropSet( new SvxAccessibleTextPropertySet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() ) );
 
-                    aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) );
-                    rRes.Value = aPropSet._getPropertyValue( rRes.Name, mnParagraphIndex );
-                    rRes.State = aPropSet._getPropertyState( rRes.Name, mnParagraphIndex );
+                    xPropSet->SetSelection( MakeSelection( 0, GetTextLen() ) );
+                    rRes.Value = xPropSet->_getPropertyValue( rRes.Name, mnParagraphIndex );
+                    rRes.State = xPropSet->_getPropertyState( rRes.Name, mnParagraphIndex );
                     rRes.Handle = -1;
                 }
                 continue;
@@ -1635,10 +1635,10 @@ namespace accessibility
                 else
                 {
                     // MT IA2 TODO: Check if this is the correct replacement for ImplGetSvxCharAndParaPropertiesMap
-                    SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() );
-                    aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) );
-                    rRes.Value = aPropSet._getPropertyValue( rRes.Name, mnParagraphIndex );
-                    rRes.State = aPropSet._getPropertyState( rRes.Name, mnParagraphIndex );
+                    uno::Reference< SvxAccessibleTextPropertySet > xPropSet( new SvxAccessibleTextPropertySet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() ) );
+                    xPropSet->SetSelection( MakeSelection( 0, GetTextLen() ) );
+                    rRes.Value = xPropSet->_getPropertyValue( rRes.Name, mnParagraphIndex );
+                    rRes.State = xPropSet->_getPropertyState( rRes.Name, mnParagraphIndex );
                     rRes.Handle = -1;
                 }
                 continue;
@@ -2416,13 +2416,13 @@ namespace accessibility
 
             // do the indices span the whole paragraph? Then use the outliner map
             // TODO: hold it as a member?
-            SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
+            uno::Reference< SvxAccessibleTextPropertySet > xPropSet( new SvxAccessibleTextPropertySet( &GetEditSource(),
                                                    0 == nStartIndex &&
                                                    rCacheTF.GetTextLen(nPara) == nEndIndex ?
                                                    ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() :
-                                                   ImplGetSvxTextPortionSvxPropertySet() );
+                                                   ImplGetSvxTextPortionSvxPropertySet() ) );
 
-            aPropSet.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
+            xPropSet->SetSelection( MakeSelection(nStartIndex, nEndIndex) );
 
             // convert from PropertyValue to Any
             sal_Int32 i, nLength( aAttributeSet.getLength() );
@@ -2431,7 +2431,7 @@ namespace accessibility
             {
                 try
                 {
-                    aPropSet.setPropertyValue(pPropArray->Name, pPropArray->Value);
+                    xPropSet->setPropertyValue(pPropArray->Name, pPropArray->Value);
                 }
                 catch (const uno::Exception&)
                 {
@@ -2481,10 +2481,10 @@ namespace accessibility
 
         // get XPropertySetInfo for paragraph attributes and
         // character attributes that span all the paragraphs text.
-        SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
-                ImplGetSvxCharAndParaPropertiesSet() );
-        aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) );
-        uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo();
+        uno::Reference< SvxAccessibleTextPropertySet > xPropSet( new SvxAccessibleTextPropertySet( &GetEditSource(),
+                ImplGetSvxCharAndParaPropertiesSet() ) );
+        xPropSet->SetSelection( MakeSelection( 0, GetTextLen() ) );
+        uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
         if (!xPropSetInfo.is())
             throw uno::RuntimeException("Cannot query XPropertySetInfo",
                         uno::Reference< uno::XInterface >
@@ -2530,7 +2530,7 @@ namespace accessibility
             // calling implementation functions:
             // _getPropertyState and _getPropertyValue (see below) to provide
             // the proper paragraph number when retrieving paragraph attributes
-            PropertyState eState = aPropSet._getPropertyState( pProperties->Name, mnParagraphIndex );
+            PropertyState eState = xPropSet->_getPropertyState( pProperties->Name, mnParagraphIndex );
             if ( eState == PropertyState_AMBIGUOUS_VALUE )
             {
                 OSL_FAIL( "ambiguous property value encountered" );
@@ -2543,7 +2543,7 @@ namespace accessibility
             {
                 pOutSequence->Name      = pProperties->Name;
                 pOutSequence->Handle    = pProperties->Handle;
-                pOutSequence->Value     = aPropSet._getPropertyValue( pProperties->Name, mnParagraphIndex );
+                pOutSequence->Value     = xPropSet->_getPropertyValue( pProperties->Name, mnParagraphIndex );
                 pOutSequence->State     = PropertyState_DEFAULT_VALUE;
 
                 ++pOutSequence;
@@ -2583,10 +2583,10 @@ namespace accessibility
         else
             CheckPosition(nIndex);
 
-        SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
-                                               ImplGetSvxCharAndParaPropertiesSet() );
-        aPropSet.SetSelection( MakeSelection( nIndex ) );
-        uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo();
+        uno::Reference< SvxAccessibleTextPropertySet > xPropSet( new SvxAccessibleTextPropertySet( &GetEditSource(),
+                                               ImplGetSvxCharAndParaPropertiesSet() ) );
+        xPropSet->SetSelection( MakeSelection( nIndex ) );
+        uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
         if (!xPropSetInfo.is())
             throw uno::RuntimeException("Cannot query XPropertySetInfo",
                                         uno::Reference< uno::XInterface >
@@ -2630,12 +2630,12 @@ namespace accessibility
         for (sal_Int32 i = 0;  i < nLength;  ++i)
         {
             // calling 'regular' functions that will operate on the selection
-            PropertyState eState = aPropSet.getPropertyState( pProperties->Name );
+            PropertyState eState = xPropSet->getPropertyState( pProperties->Name );
             if (eState == PropertyState_DIRECT_VALUE)
             {
                 pOutSequence->Name      = pProperties->Name;
                 pOutSequence->Handle    = pProperties->Handle;
-                pOutSequence->Value     = aPropSet.getPropertyValue( pProperties->Name );
+                pOutSequence->Value     = xPropSet->getPropertyValue( pProperties->Name );
                 pOutSequence->State     = eState;
 
                 ++pOutSequence;
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index cfeea48..3007ba0 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -2091,9 +2091,9 @@ void SvxAutoCorrectLanguageLists::SaveExceptList_Imp(
                 xWriter->setOutputStream(xOut);
 
                 uno::Reference < xml::sax::XDocumentHandler > xHandler(xWriter, UNO_QUERY_THROW);
-                SvXMLExceptionListExport aExp( xContext, rLst, sStrmName, xHandler );
+                uno::Reference< SvXMLExceptionListExport > xExp( new SvXMLExceptionListExport( xContext, rLst, sStrmName, xHandler ) );
 
-                aExp.exportDoc( XML_BLOCK_LIST );
+                xExp->exportDoc( XML_BLOCK_LIST );
 
                 xStrm->Commit();
                 if( xStrm->GetError() == SVSTREAM_OK )
@@ -2462,9 +2462,9 @@ bool SvxAutoCorrectLanguageLists::MakeBlocklist_Imp( SotStorage& rStg )
             xWriter->setOutputStream(xOut);
 
             uno::Reference<xml::sax::XDocumentHandler> xHandler(xWriter, uno::UNO_QUERY);
-            SvXMLAutoCorrectExport aExp( xContext, pAutocorr_List, sStrmName, xHandler );
+            uno::Reference< SvXMLAutoCorrectExport > xExp( new SvXMLAutoCorrectExport( xContext, pAutocorr_List, sStrmName, xHandler ) );
 
-            aExp.exportDoc( XML_BLOCK_LIST );
+            xExp->exportDoc( XML_BLOCK_LIST );
 
             refList->Commit();
             bRet = SVSTREAM_OK == refList->GetError();
diff --git a/editeng/source/xml/xmltxtexp.cxx b/editeng/source/xml/xmltxtexp.cxx
index 401472f..5d575a1 100644
--- a/editeng/source/xml/xmltxtexp.cxx
+++ b/editeng/source/xml/xmltxtexp.cxx
@@ -429,9 +429,9 @@ void SvxWriteXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection&
 
             // SvxXMLTextExportComponent aExporter( &rEditEngine, rSel, aName, xHandler );
             uno::Reference< xml::sax::XDocumentHandler > xHandler(xWriter, UNO_QUERY_THROW);
-            SvxXMLTextExportComponent aExporter( xContext, &rEditEngine, rSel, aName, xHandler );
+            uno::Reference< SvxXMLTextExportComponent > xExporter( new SvxXMLTextExportComponent( xContext, &rEditEngine, rSel, aName, xHandler ) );
 
-            aExporter.exportDoc();
+            xExporter->exportDoc();
 
 /* testcode
             aMedium.Commit();
diff --git a/extensions/source/scanner/sanedlg.cxx b/extensions/source/scanner/sanedlg.cxx
index 9078823..30b3778 100644
--- a/extensions/source/scanner/sanedlg.cxx
+++ b/extensions/source/scanner/sanedlg.cxx
@@ -906,8 +906,8 @@ void SaneDlg::AcquirePreview()
     else
         mrSane.SetOptionValue( nOption, true );
 
-    BitmapTransporter aTransporter;
-    if( ! mrSane.Start( aTransporter ) )
+    Reference<BitmapTransporter> xTransporter(new BitmapTransporter);
+    if( ! mrSane.Start( *xTransporter.get() ) )
     {
         ScopedVclPtrInstance< MessageDialog > aErrorBox(this, SaneResId(STR_ERROR_SCAN));
         aErrorBox->Execute();
@@ -915,11 +915,11 @@ void SaneDlg::AcquirePreview()
     else
     {
 #if OSL_DEBUG_LEVEL > 1
-        aTransporter.getStream().Seek( STREAM_SEEK_TO_END );
-        fprintf( stderr, "Previewbitmapstream contains %d bytes\n", (int)aTransporter.getStream().Tell() );
+        xTransporter->getStream().Seek( STREAM_SEEK_TO_END );
+        fprintf( stderr, "Previewbitmapstream contains %d bytes\n", (int)xTransporter->getStream().Tell() );
 #endif
-        aTransporter.getStream().Seek( STREAM_SEEK_TO_BEGIN );
-        mpPreview->SetBitmap(aTransporter.getStream());
+        xTransporter->getStream().Seek( STREAM_SEEK_TO_BEGIN );
+        mpPreview->SetBitmap(xTransporter->getStream());
     }
 
     SetAdjustedNumericalValue( "resolution", fResl );
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index d637ccb..abd5634 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -3710,7 +3710,7 @@ void SAL_CALL SVGWriter::write( const Reference<XDocumentHandler>& rxDocHandler,
     ReadGDIMetaFile( aMemStm, aMtf );
 
     const Reference< XDocumentHandler > xDocumentHandler( rxDocHandler );
-    boost::scoped_ptr<SVGExport> pWriter(new SVGExport( mxContext, xDocumentHandler, maFilterData ));
+    Reference<SVGExport> pWriter(new SVGExport( mxContext, xDocumentHandler, maFilterData ));
     pWriter->writeMtf( aMtf );
 }
 
diff --git a/i18npool/inc/calendar_gregorian.hxx b/i18npool/inc/calendar_gregorian.hxx
index f270779..a6b81c9 100644
--- a/i18npool/inc/calendar_gregorian.hxx
+++ b/i18npool/inc/calendar_gregorian.hxx
@@ -97,7 +97,7 @@ public:
 protected:
     const Era *eraArray;
     icu::Calendar *body;
-    NativeNumberSupplierService aNatNum;
+    css::uno::Reference<NativeNumberSupplierService> mxNatNum;
     const sal_Char* cCalendar;
     com::sun::star::lang::Locale aLocale;
     sal_uInt32 fieldSet;
diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx
index 5b4a9b7..e455c53 100644
--- a/i18npool/source/calendar/calendar_gregorian.cxx
+++ b/i18npool/source/calendar/calendar_gregorian.cxx
@@ -130,10 +130,12 @@ namespace com { namespace sun { namespace star { namespace i18n {
 #define ERROR RuntimeException()
 
 Calendar_gregorian::Calendar_gregorian()
+    : mxNatNum(new NativeNumberSupplierService)
 {
     init(NULL);
 }
 Calendar_gregorian::Calendar_gregorian(const Era *_earArray)
+    : mxNatNum(new NativeNumberSupplierService)
 {
     init(_earArray);
 }
@@ -1180,7 +1182,7 @@ Calendar_gregorian::getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_In
         }
         sal_Int16 nNatNum = NatNumForCalendar(aLocale, nCalendarDisplayCode, nNativeNumberMode, value);
         if (nNatNum > 0)
-            return aNatNum.getNativeNumberString(aOUStr, aLocale, nNatNum);
+            return mxNatNum->getNativeNumberString(aOUStr, aLocale, nNatNum);
     }
     return aOUStr;
 }
diff --git a/i18npool/source/calendar/calendar_jewish.cxx b/i18npool/source/calendar/calendar_jewish.cxx
index 0dc82bd..1e399eb 100644
--- a/i18npool/source/calendar/calendar_jewish.cxx
+++ b/i18npool/source/calendar/calendar_jewish.cxx
@@ -287,7 +287,7 @@ Calendar_jewish::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNa
 
     if (nCalendarDisplayCode == CalendarDisplayCode::SHORT_YEAR) {
         sal_Int32 value = getValue(CalendarFieldIndex::YEAR) % 1000; // take last 3 digits
-        return aNatNum.getNativeNumberString(OUString::number(value), aLocale, nNativeNumberMode );
+        return mxNatNum->getNativeNumberString(OUString::number(value), aLocale, nNativeNumberMode );
     }
     else
         return Calendar_gregorian::getDisplayString(nCalendarDisplayCode, nNativeNumberMode );
diff --git a/i18npool/source/characterclassification/cclass_unicode.cxx b/i18npool/source/characterclassification/cclass_unicode.cxx
index 495cd21..86891ad 100644
--- a/i18npool/source/characterclassification/cclass_unicode.cxx
+++ b/i18npool/source/characterclassification/cclass_unicode.cxx
@@ -92,12 +92,12 @@ cclass_Unicode::toTitle( const OUString& Text, sal_Int32 nPos, sal_Int32 nCount,
         trans->setMappingType(MappingTypeToTitle, rLocale);
         rtl_uString* pStr = rtl_uString_alloc(nCount);
         sal_Unicode* out = pStr->buffer;
-        BreakIteratorImpl brk(m_xContext);
-        Boundary bdy = brk.getWordBoundary(Text, nPos, rLocale,
+        Reference< BreakIteratorImpl > xBrk(new BreakIteratorImpl(m_xContext));
+        Boundary bdy = xBrk->getWordBoundary(Text, nPos, rLocale,
                     WordType::ANYWORD_IGNOREWHITESPACES, sal_True);
         for (sal_Int32 i = nPos; i < nCount + nPos; i++, out++) {
             if (i >= bdy.endPos)
-                bdy = brk.nextWord(Text, bdy.endPos, rLocale,
+                bdy = xBrk->nextWord(Text, bdy.endPos, rLocale,
                             WordType::ANYWORD_IGNOREWHITESPACES);
             *out = (i == bdy.startPos) ?
                 trans->transliterateChar2Char(Text[i]) : Text[i];
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index 5e4d582..a48f6e4 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -858,8 +858,8 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal
       }
 
         if (natNum) {
-            NativeNumberSupplierService sNatNum;
-            result += sNatNum.getNativeNumberString(OUString::number( number ), locale, natNum);
+            uno::Reference<NativeNumberSupplierService> xNatNum(new NativeNumberSupplierService);
+            result += xNatNum->getNativeNumberString(OUString::number( number ), locale, natNum);
         } else if (tableSize) {
             if ( number > tableSize && !recycleSymbol)
                 result += OUString::number( number);
diff --git a/i18npool/source/indexentry/indexentrysupplier.cxx b/i18npool/source/indexentry/indexentrysupplier.cxx
index fc10965..96fef17 100644
--- a/i18npool/source/indexentry/indexentrysupplier.cxx
+++ b/i18npool/source/indexentry/indexentrysupplier.cxx
@@ -116,14 +116,14 @@ IndexEntrySupplier::getLocaleSpecificIndexEntrySupplier(const Locale& rLocale, c
             rLocale.Country == aLocale.Country && rLocale.Variant == aLocale.Variant)
         return xIES;
     else {
-        LocaleDataImpl ld;
+        uno::Reference<LocaleDataImpl> ld(new LocaleDataImpl);
         aLocale = rLocale;
         if (rSortAlgorithm.isEmpty())
-            aSortAlgorithm = ld.getDefaultIndexAlgorithm( rLocale );
+            aSortAlgorithm = ld->getDefaultIndexAlgorithm( rLocale );
         else
             aSortAlgorithm = rSortAlgorithm;
 
-        OUString module = ld.getIndexModuleByAlgorithm(rLocale, aSortAlgorithm);
+        OUString module = ld->getIndexModuleByAlgorithm(rLocale, aSortAlgorithm);
         if (!module.isEmpty() && createLocaleSpecificIndexEntrySupplier(module))
             return xIES;
 
diff --git a/i18npool/source/transliteration/ignoreKana.cxx b/i18npool/source/transliteration/ignoreKana.cxx
index d468ecf..6aa1e90 100644
--- a/i18npool/source/transliteration/ignoreKana.cxx
+++ b/i18npool/source/transliteration/ignoreKana.cxx
@@ -31,25 +31,25 @@ OUString SAL_CALL
 ignoreKana::folding( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
   throw(RuntimeException, std::exception)
 {
-    hiraganaToKatakana t1;
-    return t1.transliterate(inStr, startPos, nCount, offset);
+    Reference< hiraganaToKatakana > t1(new hiraganaToKatakana);
+    return t1->transliterate(inStr, startPos, nCount, offset);
 }
 
 Sequence< OUString > SAL_CALL
 ignoreKana::transliterateRange( const OUString& str1, const OUString& str2 )
   throw(RuntimeException, std::exception)
 {
-    hiraganaToKatakana t1;
-    katakanaToHiragana t2;
+    Reference< hiraganaToKatakana > t1(new hiraganaToKatakana);
+    Reference< katakanaToHiragana > t2(new katakanaToHiragana);
 
-    return transliteration_Ignore::transliterateRange(str1, str2, t1, t2);
+    return transliteration_Ignore::transliterateRange(str1, str2, *t1.get(), *t2.get());
 }
 
 sal_Unicode SAL_CALL
 ignoreKana::transliterateChar2Char( sal_Unicode inChar) throw(RuntimeException, MultipleCharsOutputException, std::exception)
 {
-    hiraganaToKatakana t1;
-    return t1.transliterateChar2Char(inChar);
+    Reference< hiraganaToKatakana > t1(new hiraganaToKatakana);
+    return t1->transliterateChar2Char(inChar);
 }
 
 } } } }
diff --git a/i18npool/source/transliteration/ignoreSize_ja_JP.cxx b/i18npool/source/transliteration/ignoreSize_ja_JP.cxx
index e5645ad0..45f10be 100644
--- a/i18npool/source/transliteration/ignoreSize_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreSize_ja_JP.cxx
@@ -29,8 +29,8 @@ OUString SAL_CALL
 ignoreSize_ja_JP::folding( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
   throw(RuntimeException, std::exception)
 {
-    smallToLarge_ja_JP t1;
-    return t1.transliterate(inStr, startPos, nCount, offset);
+    Reference< smallToLarge_ja_JP > t1(new smallToLarge_ja_JP);
+    return t1->transliterate(inStr, startPos, nCount, offset);
 }
 
 
@@ -38,17 +38,17 @@ Sequence< OUString > SAL_CALL
 ignoreSize_ja_JP::transliterateRange( const OUString& str1, const OUString& str2 )
   throw(RuntimeException, std::exception)
 {
-    smallToLarge_ja_JP t1;
-    largeToSmall_ja_JP t2;
+    Reference< smallToLarge_ja_JP > t1(new smallToLarge_ja_JP);
+    Reference< largeToSmall_ja_JP > t2(new largeToSmall_ja_JP);
 
-    return transliteration_Ignore::transliterateRange(str1, str2, t1, t2);
+    return transliteration_Ignore::transliterateRange(str1, str2, *t1.get(), *t2.get());
 }
 
 sal_Unicode SAL_CALL
 ignoreSize_ja_JP::transliterateChar2Char( sal_Unicode inChar) throw(RuntimeException, MultipleCharsOutputException, std::exception)
 {
-    smallToLarge_ja_JP t1;
-    return t1.transliterateChar2Char(inChar);
+    Reference< smallToLarge_ja_JP > t1(new smallToLarge_ja_JP);
+    return t1->transliterateChar2Char(inChar);
 }
 
 } } } }
diff --git a/i18npool/source/transliteration/ignoreWidth.cxx b/i18npool/source/transliteration/ignoreWidth.cxx
index ebe640c..ab4ade0 100644
--- a/i18npool/source/transliteration/ignoreWidth.cxx
+++ b/i18npool/source/transliteration/ignoreWidth.cxx
@@ -31,25 +31,25 @@ OUString SAL_CALL
 ignoreWidth::folding( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
   throw(RuntimeException, std::exception)
 {
-    fullwidthToHalfwidth t1;
-    return t1.transliterate(inStr, startPos, nCount, offset);
+    Reference< fullwidthToHalfwidth > t1(new fullwidthToHalfwidth);
+    return t1->transliterate(inStr, startPos, nCount, offset);
 }
 
 Sequence< OUString > SAL_CALL
 ignoreWidth::transliterateRange( const OUString& str1, const OUString& str2 )
   throw(RuntimeException, std::exception)
 {
-    fullwidthToHalfwidth t1;
-    halfwidthToFullwidth t2;
+    Reference< fullwidthToHalfwidth > t1(new fullwidthToHalfwidth);
+    Reference< halfwidthToFullwidth > t2(new halfwidthToFullwidth);
 
-    return transliteration_Ignore::transliterateRange(str1, str2, t1, t2);
+    return transliteration_Ignore::transliterateRange(str1, str2, *t1.get(), *t2.get());
 }
 
 sal_Unicode SAL_CALL
 ignoreWidth::transliterateChar2Char( sal_Unicode inChar) throw(RuntimeException, MultipleCharsOutputException, std::exception)
 {
-    fullwidthToHalfwidth t1;
-    return t1.transliterateChar2Char(inChar);
+    Reference< fullwidthToHalfwidth > t1(new fullwidthToHalfwidth);
+    return t1->transliterateChar2Char(inChar);
 }
 
 } } } }
diff --git a/i18npool/source/transliteration/transliteration_body.cxx b/i18npool/source/transliteration/transliteration_body.cxx
index c9c41ef..875b4a1 100644
--- a/i18npool/source/transliteration/transliteration_body.cxx
+++ b/i18npool/source/transliteration/transliteration_body.cxx
@@ -269,9 +269,9 @@ static OUString transliterate_titlecase_Impl(
     if (!aText.isEmpty())
     {
         Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
-        CharacterClassificationImpl aCharClassImpl( xContext );
+        Reference< CharacterClassificationImpl > xCharClassImpl( new CharacterClassificationImpl( xContext ) );
 
-        // because aCharClassImpl.toTitle does not handle ligatures or Beta but will raise
+        // because xCharClassImpl.toTitle does not handle ligatures or Beta but will raise
         // an exception we need to handle the first chara manually...
 
         // we don't want to change surrogates by accident, thuse we use proper code point iteration
@@ -279,16 +279,16 @@ static OUString transliterate_titlecase_Impl(
         sal_uInt32 cFirstChar = aText.iterateCodePoints( &nPos );
         OUString aResolvedLigature( &cFirstChar, 1 );
         // toUpper can be used to properly resolve ligatures and characters like Beta
-        aResolvedLigature = aCharClassImpl.toUpper( aResolvedLigature, 0, aResolvedLigature.getLength(), rLocale );
+        aResolvedLigature = xCharClassImpl->toUpper( aResolvedLigature, 0, aResolvedLigature.getLength(), rLocale );
         // since toTitle will leave all-uppercase text unchanged we first need to
         // use toLower to bring possible 2nd and following chars in lowercase
-        aResolvedLigature = aCharClassImpl.toLower( aResolvedLigature, 0, aResolvedLigature.getLength(), rLocale );
+        aResolvedLigature = xCharClassImpl->toLower( aResolvedLigature, 0, aResolvedLigature.getLength(), rLocale );
         sal_Int32 nResolvedLen = aResolvedLigature.getLength();
 
         // now we can properly use toTitle to get the expected result for the resolved string.
         // The rest of the text should just become lowercase.
-        aRes = aCharClassImpl.toTitle( aResolvedLigature, 0, nResolvedLen, rLocale );
-        aRes += aCharClassImpl.toLower( aText, 1, aText.getLength() - 1, rLocale );
+        aRes = xCharClassImpl->toTitle( aResolvedLigature, 0, nResolvedLen, rLocale );
+        aRes += xCharClassImpl->toLower( aText, 1, aText.getLength() - 1, rLocale );
         offset.realloc( aRes.getLength() );
 
         sal_Int32 *pOffset = offset.getArray();
diff --git a/i18npool/source/transliteration/transliteration_caseignore.cxx b/i18npool/source/transliteration/transliteration_caseignore.cxx
index dcfefe3..9e89c39 100644
--- a/i18npool/source/transliteration/transliteration_caseignore.cxx
+++ b/i18npool/source/transliteration/transliteration_caseignore.cxx
@@ -59,16 +59,16 @@ Transliteration_caseignore::transliterateRange( const OUString& str1, const OUSt
     if (str1.getLength() != 1 || str2.getLength() != 1)
         throw RuntimeException();
 
-    static Transliteration_u2l u2l;
-    static Transliteration_l2u l2u;
+    static Reference< Transliteration_u2l > u2l(new Transliteration_u2l);
+    static Reference< Transliteration_l2u > l2u(new Transliteration_l2u);
 
-    u2l.loadModule((TransliterationModules)0, aLocale);
-    l2u.loadModule((TransliterationModules)0, aLocale);
+    u2l->loadModule((TransliterationModules)0, aLocale);
+    l2u->loadModule((TransliterationModules)0, aLocale);
 
-    OUString l1 = u2l.transliterateString2String(str1, 0, str1.getLength());
-    OUString u1 = l2u.transliterateString2String(str1, 0, str1.getLength());
-    OUString l2 = u2l.transliterateString2String(str2, 0, str2.getLength());
-    OUString u2 = l2u.transliterateString2String(str2, 0, str2.getLength());
+    OUString l1 = u2l->transliterateString2String(str1, 0, str1.getLength());
+    OUString u1 = l2u->transliterateString2String(str1, 0, str1.getLength());
+    OUString l2 = u2l->transliterateString2String(str2, 0, str2.getLength());
+    OUString u2 = l2u->transliterateString2String(str2, 0, str2.getLength());
 
     if ((l1 == u1) && (l2 == u2)) {
         Sequence< OUString > r(2);
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 535c811..122ee45 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -257,8 +257,8 @@ void XmlFilterBase::importDocumentProperties()
     MediaDescriptor aMediaDesc( getMediaDescriptor() );
     Reference< XInputStream > xInputStream;
     Reference< XComponentContext > xContext = getComponentContext();
-    ::oox::core::FilterDetect aDetector( xContext );
-    xInputStream = aDetector.extractUnencryptedPackage( aMediaDesc );
+    Reference< ::oox::core::FilterDetect > xDetector( new ::oox::core::FilterDetect( xContext ) );
+    xInputStream = xDetector->extractUnencryptedPackage( aMediaDesc );
     Reference< XComponent > xModel( getModel(), UNO_QUERY );
     Reference< XStorage > xDocumentStorage (
             ::comphelper::OStorageHelper::GetStorageOfFormatFromInputStream( OFOPXML_STORAGE_FORMAT_STRING, xInputStream ) );
@@ -823,8 +823,8 @@ Reference< XInputStream > XmlFilterBase::implGetInputStream( MediaDescriptor& rM
     /*  Get the input stream directly from the media descriptor, or decrypt the
         package again. The latter is needed e.g. when the document is reloaded.
         All this is implemented in the detector service. */
-    FilterDetect aDetector( getComponentContext() );
-    return aDetector.extractUnencryptedPackage( rMediaDesc );
+    Reference< FilterDetect > xDetector( new FilterDetect( getComponentContext() ) );
+    return xDetector->extractUnencryptedPackage( rMediaDesc );
 }
 
 Reference<XStream> XmlFilterBase::implGetOutputStream( MediaDescriptor& rMediaDescriptor ) const
diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx
index c3e8c75..6acd0d9 100644
--- a/reportdesign/source/ui/dlg/GroupsSorting.cxx
+++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx
@@ -107,7 +107,7 @@ class OFieldExpressionControl : public ::svt::EditBrowseBox
     ImplSVEvent *                   m_nDeleteEvent;
     VclPtr<OGroupsSortingDialog>    m_pParent;
     bool                            m_bIgnoreEvent;
-    OFieldExpressionControlContainerListener aContainerListener;
+    css::uno::Reference<OFieldExpressionControlContainerListener> aContainerListener;
 
     bool SaveModified(bool _bAppend);
 
@@ -205,7 +205,7 @@ OFieldExpressionControl::OFieldExpressionControl(OGroupsSortingDialog* _pParentD
     ,m_nDeleteEvent(0)
     ,m_pParent(_pParentDialog)
     ,m_bIgnoreEvent(false)
-    ,aContainerListener(this)
+    ,aContainerListener(new OFieldExpressionControlContainerListener(this))
 {
     SetBorderStyle(WindowBorderStyle::MONO);
 }
@@ -219,9 +219,8 @@ OFieldExpressionControl::~OFieldExpressionControl()
 
 void OFieldExpressionControl::dispose()
 {
-    aContainerListener.WeakImplHelper1::acquire();
     uno::Reference< report::XGroups > xGroups = m_pParent->getGroups();
-    xGroups->removeContainerListener(&aContainerListener);
+    xGroups->removeContainerListener(aContainerListener.get());
 
     // delete events from queue
     if( m_nPasteEvent )
@@ -408,7 +407,7 @@ void OFieldExpressionControl::lateInit()
         if( m_pParent->isReadOnly() )
             nMode |= BrowserMode::HIDECURSOR;
         SetMode(nMode);
-        xGroups->addContainerListener(&aContainerListener);
+        xGroups->addContainerListener(aContainerListener.get());
     }
     else
         // not the first call
diff --git a/sax/qa/cppunit/attributes.cxx b/sax/qa/cppunit/attributes.cxx
index a573f9d..c76fd65 100644
--- a/sax/qa/cppunit/attributes.cxx
+++ b/sax/qa/cppunit/attributes.cxx
@@ -34,44 +34,44 @@ public:
 
 void AttributesTest::test()
 {
-    sax_fastparser::FastAttributeList aAttributeList( NULL );
-    aAttributeList.add(1, "1");
-    aAttributeList.add(2, OString("2"));
+    uno::Reference<sax_fastparser::FastAttributeList> xAttributeList( new sax_fastparser::FastAttributeList(NULL) );
+    xAttributeList->add(1, "1");
+    xAttributeList->add(2, OString("2"));
 
     // We can't test getValueToken() and getOptionalValueToken()
     // without XFastTokenHandler :-(
     // Uncomment to get segmantation fault:
-    // aAttributeList.getOptionalValueToken(1, 0);
-    // aAttributeList.getValueToken(2);
+    // xAttributeList->getOptionalValueToken(1, 0);
+    // xAttributeList->getValueToken(2);
 
-    CPPUNIT_ASSERT( aAttributeList.hasAttribute(1) );
-    CPPUNIT_ASSERT( !aAttributeList.hasAttribute(3) );
+    CPPUNIT_ASSERT( xAttributeList->hasAttribute(1) );
+    CPPUNIT_ASSERT( !xAttributeList->hasAttribute(3) );
 
-    CPPUNIT_ASSERT_EQUAL( aAttributeList.getOptionalValue(2), OUString("2") );
-    CPPUNIT_ASSERT_EQUAL( aAttributeList.getOptionalValue(3), OUString() );
+    CPPUNIT_ASSERT_EQUAL( xAttributeList->getOptionalValue(2), OUString("2") );
+    CPPUNIT_ASSERT_EQUAL( xAttributeList->getOptionalValue(3), OUString() );
 
-    CPPUNIT_ASSERT_EQUAL( aAttributeList.getValue(1), OUString("1") );
+    CPPUNIT_ASSERT_EQUAL( xAttributeList->getValue(1), OUString("1") );
     mbException = false;
 
-    try { aAttributeList.getValue(3); }
+    try { xAttributeList->getValue(3); }
     catch (const sax::SAXException& )
     {
         mbException = true;
     }
     CPPUNIT_ASSERT( mbException );
 
-    aAttributeList.addUnknown("a", "a");
-    aAttributeList.addUnknown("b", "b", "b");
-    aAttributeList.addUnknown("c", "c");
-    CPPUNIT_ASSERT_EQUAL( (sal_Int32) 3, aAttributeList.getUnknownAttributes().getLength() );
+    xAttributeList->addUnknown("a", "a");
+    xAttributeList->addUnknown("b", "b", "b");
+    xAttributeList->addUnknown("c", "c");
+    CPPUNIT_ASSERT_EQUAL( (sal_Int32) 3, xAttributeList->getUnknownAttributes().getLength() );
 
-    CPPUNIT_ASSERT_EQUAL( (sal_Int32) 2, aAttributeList.getFastAttributes().getLength() );
+    CPPUNIT_ASSERT_EQUAL( (sal_Int32) 2, xAttributeList->getFastAttributes().getLength() );
 
-    aAttributeList.clear();
-    CPPUNIT_ASSERT( !aAttributeList.hasAttribute(1) );
-    CPPUNIT_ASSERT_EQUAL( (sal_Int32) 0, aAttributeList.getFastAttributes().getLength() );
-    aAttributeList.addUnknown("c", "c");
-    CPPUNIT_ASSERT_EQUAL( (sal_Int32) 1, aAttributeList.getUnknownAttributes().getLength() );
+    xAttributeList->clear();
+    CPPUNIT_ASSERT( !xAttributeList->hasAttribute(1) );
+    CPPUNIT_ASSERT_EQUAL( (sal_Int32) 0, xAttributeList->getFastAttributes().getLength() );
+    xAttributeList->addUnknown("c", "c");
+    CPPUNIT_ASSERT_EQUAL( (sal_Int32) 1, xAttributeList->getUnknownAttributes().getLength() );
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION( AttributesTest );
diff --git a/sax/qa/cppunit/parser.cxx b/sax/qa/cppunit/parser.cxx
index 824d5ec..b781d9e 100644
--- a/sax/qa/cppunit/parser.cxx
+++ b/sax/qa/cppunit/parser.cxx
@@ -45,7 +45,7 @@ public:
 class ParserTest: public test::BootstrapFixture
 {
     InputSource maInput;
-    sax_fastparser::FastSaxParser maParser;
+    uno::Reference< sax_fastparser::FastSaxParser > mxParser;
     uno::Reference< XFastDocumentHandler > mxDocumentHandler;
     uno::Reference< DummyTokenHandler > mxTokenHandler;
 
@@ -67,7 +67,8 @@ void ParserTest::setUp()
 {
     test::BootstrapFixture::setUp();
     mxTokenHandler.set( new DummyTokenHandler() );
-    maParser.setTokenHandler( mxTokenHandler );
+    mxParser.set( new sax_fastparser::FastSaxParser() );
+    mxParser->setTokenHandler( mxTokenHandler.get() );
 }
 
 void ParserTest::tearDown()
@@ -89,13 +90,13 @@ uno::Reference< io::XInputStream > ParserTest::createStream(const OString& sInpu
 void ParserTest::parse()
 {
     maInput.aInputStream = createStream("<a>...<b />..</a>");
-    maParser.parseStream( maInput );
+    mxParser->parseStream( maInput );
 
     maInput.aInputStream = createStream("<b></a>");
     bool bException = false;
     try
     {
-        maParser.parseStream( maInput );
+        mxParser->parseStream( maInput );
     }
     catch (const SAXParseException &)
     {
diff --git a/sc/source/ui/dbgui/csvcontrol.cxx b/sc/source/ui/dbgui/csvcontrol.cxx
index b53b5bc..583b510 100644
--- a/sc/source/ui/dbgui/csvcontrol.cxx
+++ b/sc/source/ui/dbgui/csvcontrol.cxx
@@ -300,7 +300,7 @@ ScMoveMode ScCsvControl::GetVertDirection( sal_uInt16 nCode, bool bHomeEnd )
 
 ScCsvControl::XAccessibleRef ScCsvControl::CreateAccessible()
 {
-    mxAccessible = ImplCreateAccessible();
+    mxAccessible = ImplCreateAccessible().get();
     return XAccessibleRef(mxAccessible.get());
 }
 
diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx
index 069edcf..71301e0 100644
--- a/sc/source/ui/dbgui/csvgrid.cxx
+++ b/sc/source/ui/dbgui/csvgrid.cxx
@@ -1357,11 +1357,11 @@ void ScCsvGrid::ImplDrawTrackingRect( sal_uInt32 nColIndex )
 
 // accessibility ==============================================================
 
-ScAccessibleCsvControl* ScCsvGrid::ImplCreateAccessible()
+rtl::Reference<ScAccessibleCsvControl> ScCsvGrid::ImplCreateAccessible()
 {
-    std::unique_ptr<ScAccessibleCsvControl> pControl(new ScAccessibleCsvGrid( *this ));
+    rtl::Reference<ScAccessibleCsvControl> pControl(new ScAccessibleCsvGrid( *this ));
     pControl->Init();
-    return pControl.release();
+    return pControl;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/csvruler.cxx b/sc/source/ui/dbgui/csvruler.cxx
index d6ad878..abe5375 100644
--- a/sc/source/ui/dbgui/csvruler.cxx
+++ b/sc/source/ui/dbgui/csvruler.cxx
@@ -654,7 +654,7 @@ void ScCsvRuler::ImplSetMousePointer( sal_Int32 nPos )
 
 // accessibility ==============================================================
 
-ScAccessibleCsvControl* ScCsvRuler::ImplCreateAccessible()
+rtl::Reference<ScAccessibleCsvControl> ScCsvRuler::ImplCreateAccessible()
 {
     return new ScAccessibleCsvRuler( *this );
 }
diff --git a/sc/source/ui/dbgui/csvtablebox.cxx b/sc/source/ui/dbgui/csvtablebox.cxx
index 785cb91..9ecbfb0 100644
--- a/sc/source/ui/dbgui/csvtablebox.cxx
+++ b/sc/source/ui/dbgui/csvtablebox.cxx
@@ -22,6 +22,7 @@
 #include <vcl/lstbox.hxx>
 #include <vcl/settings.hxx>
 #include "editutil.hxx"
+#include "AccessibleCsvControl.hxx"
 
 ScCsvTableBox::ScCsvTableBox( vcl::Window* pParent, WinBits nBits ) :
     ScCsvControl( pParent, maData, nBits ),
@@ -426,9 +427,9 @@ ScCsvTableBox::XAccessibleRef ScCsvTableBox::CreateAccessible()
     return Control::CreateAccessible();
 }
 
-ScAccessibleCsvControl* ScCsvTableBox::ImplCreateAccessible()
+rtl::Reference<ScAccessibleCsvControl> ScCsvTableBox::ImplCreateAccessible()
 {
-    return NULL;    // not used, see CreateAccessible()
+    return rtl::Reference<ScAccessibleCsvControl>();    // not used, see CreateAccessible()
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/csvcontrol.hxx b/sc/source/ui/inc/csvcontrol.hxx
index 0c9edb8..82cad60 100644
--- a/sc/source/ui/inc/csvcontrol.hxx
+++ b/sc/source/ui/inc/csvcontrol.hxx
@@ -383,7 +383,7 @@ public:
 
 protected:
     /** Derived classes create a new accessible object here. */
-    virtual ScAccessibleCsvControl* ImplCreateAccessible() = 0;
+    virtual rtl::Reference<ScAccessibleCsvControl> ImplCreateAccessible() = 0;
 };
 
 #endif
diff --git a/sc/source/ui/inc/csvgrid.hxx b/sc/source/ui/inc/csvgrid.hxx
index 85c71c1..4dc3e0e 100644
--- a/sc/source/ui/inc/csvgrid.hxx
+++ b/sc/source/ui/inc/csvgrid.hxx
@@ -323,7 +323,7 @@ private:
     // accessibility ----------------------------------------------------------
 protected:
     /** Creates a new accessible object. */
-    virtual ScAccessibleCsvControl* ImplCreateAccessible() SAL_OVERRIDE;
+    virtual rtl::Reference<ScAccessibleCsvControl> ImplCreateAccessible() SAL_OVERRIDE;
 };
 
 #endif
diff --git a/sc/source/ui/inc/csvruler.hxx b/sc/source/ui/inc/csvruler.hxx
index 44f8a76..ab2fb01 100644
--- a/sc/source/ui/inc/csvruler.hxx
+++ b/sc/source/ui/inc/csvruler.hxx
@@ -176,7 +176,7 @@ private:
     // accessibility ----------------------------------------------------------
 protected:
     /** Creates a new accessible object. */
-    virtual ScAccessibleCsvControl* ImplCreateAccessible() SAL_OVERRIDE;
+    virtual rtl::Reference<ScAccessibleCsvControl> ImplCreateAccessible() SAL_OVERRIDE;
 };
 
 #endif
diff --git a/sc/source/ui/inc/csvtablebox.hxx b/sc/source/ui/inc/csvtablebox.hxx
index 4386d78..e7bfd34 100644
--- a/sc/source/ui/inc/csvtablebox.hxx
+++ b/sc/source/ui/inc/csvtablebox.hxx
@@ -134,7 +134,7 @@ public:
 
 protected:
     /** Creates a new accessible object. */
-    virtual ScAccessibleCsvControl* ImplCreateAccessible() SAL_OVERRIDE;
+    virtual rtl::Reference<ScAccessibleCsvControl> ImplCreateAccessible() SAL_OVERRIDE;
 };
 
 #endif
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 6f0a835..f2f8193 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -5660,27 +5660,27 @@ void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDe
     //! wenn es schon ein ScFilterDescriptor ist, direkt per getImplementation?
 
     ScDocShell* pDocSh = GetDocShell();
-    ScFilterDescriptor aImpl(pDocSh);
+    uno::Reference<ScFilterDescriptor> xImpl(new ScFilterDescriptor(pDocSh));
     uno::Reference< sheet::XSheetFilterDescriptor2 > xDescriptor2( xDescriptor, uno::UNO_QUERY );
     if ( xDescriptor2.is() )
     {
-        aImpl.setFilterFields2( xDescriptor2->getFilterFields2() );
+        xImpl->setFilterFields2( xDescriptor2->getFilterFields2() );
     }
     else
     {
-        aImpl.setFilterFields( xDescriptor->getFilterFields() );
+        xImpl->setFilterFields( xDescriptor->getFilterFields() );
     }
     //  Rest sind jetzt Properties...
 
     uno::Reference<beans::XPropertySet> xPropSet( xDescriptor, uno::UNO_QUERY );
     if (xPropSet.is())
-        lcl_CopyProperties( aImpl, *xPropSet.get() );
+        lcl_CopyProperties( *xImpl.get(), *xPropSet.get() );
 
     //  ausfuehren...
 
     if (pDocSh)
     {
-        ScQueryParam aParam = aImpl.GetParam();
+        ScQueryParam aParam = xImpl->GetParam();
         //  im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
         SCCOLROW nFieldStart = aParam.bByRow ?
             static_cast<SCCOLROW>(aRange.aStart.Col()) :
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 755b7aa..bc67a5b 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -3359,9 +3359,9 @@ uno::Reference< util::XCloneable > SAL_CALL ScChart2DataSequence::createClone()
         }
     }
 
-    unique_ptr<ScChart2DataSequence> p(new ScChart2DataSequence(m_pDocument, m_xDataProvider, pTokensNew.release(), m_bIncludeHiddenCells));
+    uno::Reference<ScChart2DataSequence> p(new ScChart2DataSequence(m_pDocument, m_xDataProvider, pTokensNew.release(), m_bIncludeHiddenCells));
     p->CopyData(*this);
-    Reference< util::XCloneable > xClone(p.release());
+    Reference< util::XCloneable > xClone(p);
 
     return xClone;
 }
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index fd9cb63..979edea 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1910,17 +1910,17 @@ void SAL_CALL ScModelObj::consolidate(
     //  die Daten in ein ScConsolidationDescriptor Objekt zu kopieren:
     //! wenn es schon ein ScConsolidationDescriptor ist, direkt per getImplementation?
 
-    ScConsolidationDescriptor aImpl;
-    aImpl.setFunction( xDescriptor->getFunction() );
-    aImpl.setSources( xDescriptor->getSources() );
-    aImpl.setStartOutputPosition( xDescriptor->getStartOutputPosition() );
-    aImpl.setUseColumnHeaders( xDescriptor->getUseColumnHeaders() );
-    aImpl.setUseRowHeaders( xDescriptor->getUseRowHeaders() );
-    aImpl.setInsertLinks( xDescriptor->getInsertLinks() );
+    uno::Reference< ScConsolidationDescriptor > xImpl(new ScConsolidationDescriptor);
+    xImpl->setFunction( xDescriptor->getFunction() );
+    xImpl->setSources( xDescriptor->getSources() );
+    xImpl->setStartOutputPosition( xDescriptor->getStartOutputPosition() );
+    xImpl->setUseColumnHeaders( xDescriptor->getUseColumnHeaders() );
+    xImpl->setUseRowHeaders( xDescriptor->getUseRowHeaders() );
+    xImpl->setInsertLinks( xDescriptor->getInsertLinks() );
 
     if (pDocShell)
     {
-        const ScConsolidateParam& rParam = aImpl.GetParam();
+        const ScConsolidateParam& rParam = xImpl->GetParam();
         pDocShell->DoConsolidate( rParam, true );
         pDocShell->GetDocument().SetConsolidateDlgData( &rParam );
     }
diff --git a/sc/source/ui/vba/vbafont.cxx b/sc/source/ui/vba/vbafont.cxx
index 7d3cde1..eddb2f3 100644
--- a/sc/source/ui/vba/vbafont.cxx
+++ b/sc/source/ui/vba/vbafont.cxx
@@ -84,8 +84,8 @@ ScVbaFont::setSuperscript( const uno::Any& aValue ) throw ( uno::RuntimeExceptio
             for ( sal_Int32 row = 0; row < nRows; ++row )
             {
                 uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ) , uno::UNO_QUERY_THROW );
-                ScVbaFont aFont( getParent(), mxContext, mPalette, xProps );
-                aFont.setSuperscript( aValue );
+                uno::Reference< ScVbaFont > aFont( new ScVbaFont( getParent(), mxContext, mPalette, xProps ) );
+                aFont->setSuperscript( aValue );
             }
         }
         return;
@@ -124,10 +124,10 @@ ScVbaFont::getSuperscript() throw ( uno::RuntimeException, std::exception )
             for ( sal_Int32 row = 0; row < nRows; ++row )
             {
                 uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ), uno::UNO_QUERY_THROW );
-                ScVbaFont aFont( getParent(), mxContext, mPalette, xProps );
+                uno::Reference< ScVbaFont > aFont( new ScVbaFont( getParent(), mxContext, mPalette, xProps ) );
                 if ( !col && !row )
-                    aRes = aFont.getSuperscript();
-                else if ( aRes != aFont.getSuperscript() )
+                    aRes = aFont->getSuperscript();
+                else if ( aRes != aFont->getSuperscript() )
                     return aNULL();
             }
         }
@@ -156,8 +156,8 @@ ScVbaFont::setSubscript( const uno::Any& aValue ) throw ( uno::RuntimeException,
             for ( sal_Int32 row = 0; row < nRows; ++row )
             {
                 uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ) , uno::UNO_QUERY_THROW );
-                ScVbaFont aFont( getParent(), mxContext, mPalette, xProps );
-                aFont.setSubscript( aValue );
+                uno::Reference< ScVbaFont > aFont( new ScVbaFont( getParent(), mxContext, mPalette, xProps ) );
+                aFont->setSubscript( aValue );
             }
         }
         return;
@@ -198,10 +198,10 @@ ScVbaFont::getSubscript() throw ( uno::RuntimeException, std::exception )
             for ( sal_Int32 row = 0; row < nRows; ++row )
             {
                 uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ), uno::UNO_QUERY_THROW );
-                ScVbaFont aFont( getParent(), mxContext, mPalette, xProps );
+                uno::Reference< ScVbaFont > aFont( new ScVbaFont( getParent(), mxContext, mPalette, xProps ) );
                 if ( !col && !row )
-                    aRes = aFont.getSubscript();
-                else if ( aRes != aFont.getSubscript() )
+                    aRes = aFont->getSubscript();
+                else if ( aRes != aFont->getSubscript() )
                     return aNULL();
             }
         }
diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx
index 57adf47..6ed0c84 100644
--- a/sc/source/ui/vba/vbawindow.cxx
+++ b/sc/source/ui/vba/vbawindow.cxx
@@ -315,8 +315,8 @@ ScVbaWindow::getCaption() throw (uno::RuntimeException, std::exception)
         if ( ( nCrudLen + nCrudIndex ) == sTitle.getLength() )
         {
             sTitle = sTitle.copy( 0, nCrudIndex );
-            ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
-            OUString sName = workbook.getName();
+            uno::Reference< ScVbaWorkbook > workbook( new ScVbaWorkbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ) );
+            OUString sName = workbook->getName();
             // rather bizarre hack to make sure the name behavior
             // is like XL
             // if the adjusted title == workbook name, use name
@@ -447,16 +447,16 @@ ScVbaWindow::setWindowState( const uno::Any& _windowstate ) throw (uno::RuntimeE
 void
 ScVbaWindow::Activate() throw (css::uno::RuntimeException, std::exception)
 {
-    ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
+    uno::Reference<ScVbaWorkbook> workbook( new ScVbaWorkbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ) );
 
-    workbook.Activate();
+    workbook->Activate();
 }
 
 void
 ScVbaWindow::Close( const uno::Any& SaveChanges, const uno::Any& FileName, const uno::Any& RouteWorkBook ) throw (uno::RuntimeException, std::exception)
 {
-    ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list