diff options
author | Vladimir Glazunov <vg@openoffice.org> | 2011-01-05 13:23:59 +0100 |
---|---|---|
committer | Vladimir Glazunov <vg@openoffice.org> | 2011-01-05 13:23:59 +0100 |
commit | 1b5ad64832c0a6c1a1554f97b5a9dccce3d66c2e (patch) | |
tree | 4cfa855698e17ae4a0da41aa7b0aa2d064bc483e /vcl | |
parent | 2ddbbcba14d00da112e07fd8cbd77e74e3f37164 (diff) | |
parent | 8dd20306c4be9d0dfa0bc231a5c268efdba0aac3 (diff) |
CWS-TOOLING: integrate CWS impressdefaults1
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/vcl/lazydelete.hxx | 39 | ||||
-rw-r--r--[-rwxr-xr-x] | vcl/source/window/window.cxx | 13 |
2 files changed, 47 insertions, 5 deletions
diff --git a/vcl/inc/vcl/lazydelete.hxx b/vcl/inc/vcl/lazydelete.hxx index 4176d5b4454f..dad10fb62b33 100644 --- a/vcl/inc/vcl/lazydelete.hxx +++ b/vcl/inc/vcl/lazydelete.hxx @@ -39,6 +39,8 @@ #include <stdio.h> #endif +#include <com/sun/star/lang/XComponent.hpp> + namespace vcl { /* Helpers for lazy object deletion @@ -256,6 +258,43 @@ namespace vcl // ownership is transfered ! T* set( T* i_pNew ) { T* pOld = m_pT; m_pT = i_pNew; return pOld; } }; + + /** Similar to DeleteOnDeinit, the DeleteUnoReferenceOnDeinit + template class makes sure that a static UNO object is disposed + and released at the right time. + + Use like + static DeleteUnoReferenceOnDeinit<lang::XMultiServiceFactory> + xStaticFactory (<create factory object>); + Reference<lang::XMultiServiceFactory> xFactory (xStaticFactory.get()); + if (xFactory.is()) + <do something with xFactory> + */ + template <typename I> + class DeleteUnoReferenceOnDeinit : public ::vcl::DeleteOnDeinitBase + { + ::com::sun::star::uno::Reference<I> m_xI; + virtual void doCleanup() { set(NULL); } + public: + DeleteUnoReferenceOnDeinit(const ::com::sun::star::uno::Reference<I>& r_xI ) : m_xI( r_xI ) { + addDeinitContainer( this ); } + virtual ~DeleteUnoReferenceOnDeinit() {} + + ::com::sun::star::uno::Reference<I> get (void) { return m_xI; } + + void set (const ::com::sun::star::uno::Reference<I>& r_xNew ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> xComponent (m_xI, ::com::sun::star::uno::UNO_QUERY); + m_xI = r_xNew; + if (xComponent.is()) try + { + xComponent->dispose(); + } + catch( ::com::sun::star::uno::Exception& ) + { + } + } + }; } #endif diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index fe2af486c53a..0d20f3258fe2 100755..100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -9716,11 +9716,14 @@ Reference< rendering::XCanvas > Window::ImplGetCanvas( const Size& rFullscreenSi // ========================================= if ( xFactory.is() ) { - static Reference<lang::XMultiServiceFactory> xCanvasFactory( - xFactory->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star." - "rendering.CanvasFactory") ) ), UNO_QUERY ); + static ::vcl::DeleteUnoReferenceOnDeinit<XMultiServiceFactory> xStaticCanvasFactory( + Reference<XMultiServiceFactory>( + xFactory->createInstance( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.rendering.CanvasFactory") ) ), + UNO_QUERY )); + uno::Reference<XMultiServiceFactory> xCanvasFactory(xStaticCanvasFactory.get()); + if(xCanvasFactory.is()) { #ifdef WNT |