diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/viewuno.hxx | 10 | ||||
-rw-r--r-- | sc/source/ui/unoobj/viewuno.cxx | 54 | ||||
-rw-r--r-- | sc/source/ui/view/prevwsh.cxx | 3 |
3 files changed, 49 insertions, 18 deletions
diff --git a/sc/inc/viewuno.hxx b/sc/inc/viewuno.hxx index 9b4e276465cd..2c129f8368fe 100644 --- a/sc/inc/viewuno.hxx +++ b/sc/inc/viewuno.hxx @@ -52,6 +52,7 @@ #include "address.hxx" class ScTabViewShell; +class ScPreviewShell; #define SC_VIEWPANE_ACTIVE 0xFFFF @@ -399,6 +400,15 @@ public: virtual void SAL_CALL insertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ) throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::uno::RuntimeException); }; +class ScPreviewObj : public SfxBaseController, SfxListener +{ + ScPreviewShell* mpViewShell; +public: + ScPreviewObj(ScPreviewShell* pViewSh); + virtual ~ScPreviewObj(); + + virtual void Notify(SfxBroadcaster&, const SfxHint& rHint); +}; #endif diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index cdcfa5584c10..598b35dd9c54 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -60,6 +60,7 @@ #include "cellsuno.hxx" #include "miscuno.hxx" #include "tabvwsh.hxx" +#include "prevwsh.hxx" #include "docsh.hxx" #include "drwlayer.hxx" #include "drawview.hxx" @@ -562,23 +563,24 @@ ScTabViewObj::ScTabViewObj( ScTabViewShell* pViewSh ) : nPreviousTab( 0 ), bDrawSelModeSet(false) { - if (pViewSh) - { - nPreviousTab = pViewSh->GetViewData()->GetTabNo(); + if (!pViewSh) + return; + + nPreviousTab = pViewSh->GetViewData()->GetTabNo(); ScViewData* pViewData = pViewSh->GetViewData(); - if( pViewData ) - { - uno::Reference< script::vba::XVBAEventProcessor > xVbaEventsHelper (pViewData->GetDocument()->GetVbaEventProcessor(), uno::UNO_QUERY ); - if ( xVbaEventsHelper.is() ) - { - ScTabViewEventListener* pEventListener = new ScTabViewEventListener( this, xVbaEventsHelper ); - uno::Reference< awt::XEnhancedMouseClickHandler > aMouseClickHandler( *pEventListener, uno::UNO_QUERY ); - addEnhancedMouseClickHandler( aMouseClickHandler ); - uno::Reference< view::XSelectionChangeListener > aSelectionChangeListener( *pEventListener, uno::UNO_QUERY ); - addSelectionChangeListener( aSelectionChangeListener ); - } - } - } + if (!pViewData) + return; + + uno::Reference< script::vba::XVBAEventProcessor > xVbaEventsHelper( + pViewData->GetDocument()->GetVbaEventProcessor(), uno::UNO_QUERY ); + if (!xVbaEventsHelper.is()) + return; + + ScTabViewEventListener* pEventListener = new ScTabViewEventListener( this, xVbaEventsHelper ); + uno::Reference< awt::XEnhancedMouseClickHandler > aMouseClickHandler( *pEventListener, uno::UNO_QUERY ); + addEnhancedMouseClickHandler( aMouseClickHandler ); + uno::Reference< view::XSelectionChangeListener > aSelectionChangeListener( *pEventListener, uno::UNO_QUERY ); + addSelectionChangeListener( aSelectionChangeListener ); } ScTabViewObj::~ScTabViewObj() @@ -2369,9 +2371,25 @@ void SAL_CALL ScTabViewObj::insertTransferable( const ::com::sun::star::uno::Ref } } -//------------------------------------------------------------------------ - +ScPreviewObj::ScPreviewObj(ScPreviewShell* pViewSh) : + SfxBaseController(pViewSh), + mpViewShell(pViewSh) +{ + if (mpViewShell) + StartListening(*mpViewShell); +} +ScPreviewObj::~ScPreviewObj() +{ + if (mpViewShell) + EndListening(*mpViewShell); +} +void ScPreviewObj::Notify(SfxBroadcaster&, const SfxHint& rHint) +{ + const SfxSimpleHint* p = dynamic_cast<const SfxSimpleHint*>(&rHint); + if (p && p->GetId() == SFX_HINT_DYING) + mpViewShell = NULL; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx index 5f9033500080..89fd96891685 100644 --- a/sc/source/ui/view/prevwsh.cxx +++ b/sc/source/ui/view/prevwsh.cxx @@ -67,6 +67,7 @@ #include "ViewSettingsSequenceDefines.hxx" #include "tpprint.hxx" #include "printopt.hxx" +#include "viewuno.hxx" #include <sax/tools/converter.hxx> #include <rtl/ustrbuf.hxx> @@ -167,6 +168,8 @@ ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame, if ( pDrawView ) nSourceDesignMode = pDrawView->IsDesignMode(); } + + new ScPreviewObj(this); } ScPreviewShell::~ScPreviewShell() |