summaryrefslogtreecommitdiff
path: root/sfx2/source/view/viewsh.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/view/viewsh.cxx')
-rw-r--r--sfx2/source/view/viewsh.cxx98
1 files changed, 96 insertions, 2 deletions
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 70bbc4a28d02..299c928c748b 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -47,6 +47,9 @@
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
#include <com/sun/star/container/XContainerQuery.hpp>
#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <cppuhelper/implbase1.hxx>
#include <osl/file.hxx>
#include <vos/mutex.hxx>
@@ -112,6 +115,68 @@ DBG_NAME(SfxViewShell)
//=========================================================================
+class SfxClipboardChangeListener : public ::cppu::WeakImplHelper1<
+ datatransfer::clipboard::XClipboardListener >
+{
+ SfxViewShell* pViewShell;
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const lang::EventObject& rEventObject )
+ throw ( uno::RuntimeException );
+
+ // XClipboardListener
+ virtual void SAL_CALL changedContents( const datatransfer::clipboard::ClipboardEvent& rEventObject )
+ throw ( uno::RuntimeException );
+
+public:
+ SfxClipboardChangeListener( SfxViewShell* pView );
+ virtual ~SfxClipboardChangeListener();
+};
+
+SfxClipboardChangeListener::SfxClipboardChangeListener( SfxViewShell* pView )
+: pViewShell( 0 )
+{
+ uno::Reference < lang::XComponent > xCtrl( pView->GetController(), uno::UNO_QUERY );
+ if ( xCtrl.is() )
+ {
+ xCtrl->addEventListener( uno::Reference < lang::XEventListener > ( static_cast < lang::XEventListener* >( this ) ) );
+ pViewShell = pView;
+ }
+}
+
+SfxClipboardChangeListener::~SfxClipboardChangeListener()
+{
+}
+
+void SAL_CALL SfxClipboardChangeListener::disposing( const lang::EventObject& /*rEventObject*/ )
+throw ( uno::RuntimeException )
+{
+ // either clipboard or ViewShell is going to be destroyed -> no interest in listening anymore
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if ( pViewShell )
+ {
+ uno::Reference < lang::XComponent > xCtrl( pViewShell->GetController(), uno::UNO_QUERY );
+ if ( xCtrl.is() )
+ xCtrl->removeEventListener( uno::Reference < lang::XEventListener > ( static_cast < lang::XEventListener* >( this ) ) );
+ pViewShell->AddRemoveClipboardListener( uno::Reference < datatransfer::clipboard::XClipboardListener > (this), FALSE );
+ pViewShell = 0;
+ }
+}
+
+void SAL_CALL SfxClipboardChangeListener::changedContents( const datatransfer::clipboard::ClipboardEvent& )
+ throw ( RuntimeException )
+{
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if( pViewShell )
+ {
+ SfxBindings& rBind = pViewShell->GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_PASTE );
+ rBind.Invalidate( SID_PASTE_SPECIAL );
+ rBind.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+}
+
+
static ::rtl::OUString RetrieveLabelFromCommand(
const ::rtl::OUString& rCommandURL,
const css::uno::Reference< css::frame::XFrame >& rFrame )
@@ -687,6 +752,7 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
case SID_PRINTDOC:
case SID_PRINTDOCDIRECT:
case SID_SETUPPRINTER:
+ case SID_PRINTER_NAME:
{
BOOL bEnabled = pImp->bCanPrint && !pImp->nPrinterLocks;
bEnabled = bEnabled && !Application::GetSettings().GetMiscSettings().GetDisablePrinting();
@@ -720,9 +786,10 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
}
if ( !bEnabled )
{
- rSet.DisableItem( SID_PRINTDOC );
+ // will now be handled by requeing the request
+ /* rSet.DisableItem( SID_PRINTDOC );
rSet.DisableItem( SID_PRINTDOCDIRECT );
- rSet.DisableItem( SID_SETUPPRINTER );
+ rSet.DisableItem( SID_SETUPPRINTER ); */
}
break;
}
@@ -1187,6 +1254,7 @@ SfxViewShell::SfxViewShell
{
DBG_CTOR(SfxViewShell, 0);
+ pImp->pPrinterCommandQueue = new SfxAsyncPrintExec_Impl( this );
pImp->pController = 0;
pImp->bIsShowView =
!(SFX_VIEW_NO_SHOW == (nFlags & SFX_VIEW_NO_SHOW));
@@ -1240,6 +1308,8 @@ SfxViewShell::~SfxViewShell()
delete pImp->pAccExec;
pImp->pAccExec = 0;
}
+
+ delete pImp->pPrinterCommandQueue;
delete pImp;
delete pIPClientList;
}
@@ -1926,6 +1996,8 @@ void SfxViewShell::SetController( SfxBaseController* pController )
pImp->pController = pController;
pImp->pController->acquire();
pImp->bControllerSet = TRUE;
+
+ AddRemoveClipboardListener( new SfxClipboardChangeListener( this ), TRUE );
}
Reference < XController > SfxViewShell::GetController()
@@ -2128,3 +2200,25 @@ BOOL SfxViewShell::Escape()
{
return GetViewFrame()->GetBindings().Execute( SID_TERMINATE_INPLACEACTIVATION );
}
+
+void SfxViewShell::AddRemoveClipboardListener( const uno::Reference < datatransfer::clipboard::XClipboardListener >& rClp, BOOL bAdd )
+{
+ try
+ {
+ uno::Reference< datatransfer::clipboard::XClipboard > xClipboard( GetViewFrame()->GetWindow().GetClipboard() );
+ if( !xClipboard.is() )
+ return;
+
+ uno::Reference< datatransfer::clipboard::XClipboardNotifier > xClpbrdNtfr( xClipboard, uno::UNO_QUERY );
+ if( xClpbrdNtfr.is() )
+ {
+ if( bAdd )
+ xClpbrdNtfr->addClipboardListener( rClp );
+ else
+ xClpbrdNtfr->removeClipboardListener( rClp );
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ }
+}