summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-11-28 21:41:13 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2011-11-29 00:04:23 -0500
commitffca779f3765f730cc9f4f416b728ecdf762931c (patch)
treebc38fab4cd9d3ccc2bd27f6fe78a25450b85accb /sc
parent654d9eb40c4232c180b5f88ed2774cb9c9bb18c1 (diff)
Create an UNO controller object for the preview shell.
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/viewuno.hxx10
-rw-r--r--sc/source/ui/unoobj/viewuno.cxx54
-rw-r--r--sc/source/ui/view/prevwsh.cxx3
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()