summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/ui/drawfunc/drtxtob.cxx48
-rw-r--r--sc/source/ui/inc/cellsh.hxx16
-rw-r--r--sc/source/ui/inc/drtxtob.hxx13
-rw-r--r--sc/source/ui/inc/editsh.hxx13
-rw-r--r--sc/source/ui/view/editsh.cxx46
5 files changed, 117 insertions, 19 deletions
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx
index a3f43cebf303..5d24536a2748 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: drtxtob.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: nn $ $Date: 2001-05-21 18:18:24 $
+ * last change: $Author: nn $ $Date: 2001-07-19 19:38:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -97,6 +97,7 @@
#include <sfx2/request.hxx>
#include <sfx2/viewfrm.hxx>
#include <svtools/cjkoptions.hxx>
+#include <svtools/cliplistener.hxx>
#include <svtools/transfer.hxx>
#include <svtools/whiter.hxx>
#include <vcl/msgbox.hxx>
@@ -143,7 +144,9 @@ void ScDrawTextObjectBar::StateDisableItems( SfxItemSet &rSet )
ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) :
SfxShell(pData->GetViewShell()),
- pViewData(pData)
+ pViewData(pData),
+ pClipEvtLstnr(NULL),
+ bPastePossible(FALSE)
{
SetPool( pViewData->GetScDrawView()->GetDefaultAttr().GetPool() );
@@ -156,6 +159,11 @@ ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) :
__EXPORT ScDrawTextObjectBar::~ScDrawTextObjectBar()
{
+ if ( pClipEvtLstnr )
+ {
+ pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), FALSE );
+ pClipEvtLstnr->release();
+ }
}
//========================================================================
@@ -410,6 +418,20 @@ void __EXPORT ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
}
}
+IMPL_LINK( ScDrawTextObjectBar, ClipboardChanged, TransferableDataHelper*, pDataHelper )
+{
+ if ( pDataHelper )
+ {
+ bPastePossible = ( pDataHelper->HasFormat( SOT_FORMAT_STRING ) || pDataHelper->HasFormat( SOT_FORMAT_RTF ) );
+
+ SfxBindings& rBindings = pViewData->GetBindings();
+ rBindings.Invalidate( SID_PASTE );
+ rBindings.Invalidate( FID_PASTE_CONTENTS );
+ rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+ return 0;
+}
+
void __EXPORT ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet )
{
SdrView* pView = pViewData->GetScDrawView();
@@ -419,8 +441,18 @@ void __EXPORT ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet )
return;
}
- TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
- BOOL bPaste = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
+ if ( !pClipEvtLstnr )
+ {
+ // create listener
+ pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) );
+ pClipEvtLstnr->acquire();
+ Window* pWin = pViewData->GetActiveWin();
+ pClipEvtLstnr->AddRemoveListener( pWin, TRUE );
+
+ // get initial state
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
+ bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
+ }
SfxWhichIter aIter( rSet );
USHORT nWhich = aIter.FirstWhich();
@@ -430,13 +462,15 @@ void __EXPORT ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet )
{
case SID_PASTE:
case FID_PASTE_CONTENTS:
- if( !bPaste )
+ if( !bPastePossible )
rSet.DisableItem( nWhich );
break;
case SID_CLIPBOARD_FORMAT_ITEMS:
- if ( bPaste )
+ if ( bPastePossible )
{
SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
aFormats.AddClipbrdFormat( SOT_FORMAT_STRING, String( ScResId( SCSTR_CLIP_STRING ) ) );
diff --git a/sc/source/ui/inc/cellsh.hxx b/sc/source/ui/inc/cellsh.hxx
index e69ab6290613..783074606068 100644
--- a/sc/source/ui/inc/cellsh.hxx
+++ b/sc/source/ui/inc/cellsh.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: cellsh.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: nn $ $Date: 2001-05-11 17:50:01 $
+ * last change: $Author: nn $ $Date: 2001-07-19 19:36:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -74,17 +74,29 @@
#include <svx/svdmark.hxx>
#endif
+#ifndef _LINK_HXX
+#include <tools/link.hxx>
+#endif
+
#ifndef SC_FORMATSH_HXX
#include "formatsh.hxx"
#endif
class SvxClipboardFmtItem;
+class TransferableDataHelper;
+class TransferableClipboardListener;
+
class ScCellShell: public ScFormatShell
{
private:
+ TransferableClipboardListener* pClipEvtLstnr;
+ BOOL bPastePossible;
+
void GetPossibleClipboardFormats( SvxClipboardFmtItem& rFormats );
+ DECL_LINK( ClipboardChanged, TransferableDataHelper* );
+
public:
TYPEINFO();
diff --git a/sc/source/ui/inc/drtxtob.hxx b/sc/source/ui/inc/drtxtob.hxx
index a07a90d0bc9b..0a3dc3605395 100644
--- a/sc/source/ui/inc/drtxtob.hxx
+++ b/sc/source/ui/inc/drtxtob.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: drtxtob.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: nn $ $Date: 2001-04-23 17:02:34 $
+ * last change: $Author: nn $ $Date: 2001-07-19 19:36:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,16 +71,25 @@
#ifndef _SFXMODULE_HXX //autogen
#include <sfx2/module.hxx>
#endif
+#ifndef _LINK_HXX
+#include <tools/link.hxx>
+#endif
#include "shellids.hxx"
USHORT ScGetFontWorkId(); // statt SvxFontWorkChildWindow::GetChildWindowId()
class ScViewData;
+class TransferableDataHelper;
+class TransferableClipboardListener;
class ScDrawTextObjectBar : public SfxShell
{
ScViewData* pViewData;
+ TransferableClipboardListener* pClipEvtLstnr;
+ BOOL bPastePossible;
+
+ DECL_LINK( ClipboardChanged, TransferableDataHelper* );
public:
TYPEINFO();
diff --git a/sc/source/ui/inc/editsh.hxx b/sc/source/ui/inc/editsh.hxx
index a969f8c48381..bc2cf606c408 100644
--- a/sc/source/ui/inc/editsh.hxx
+++ b/sc/source/ui/inc/editsh.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: editsh.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: nn $ $Date: 2001-05-09 12:51:39 $
+ * last change: $Author: nn $ $Date: 2001-07-19 19:36:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,6 +68,9 @@
#ifndef _SFXMODULE_HXX //autogen
#include <sfx2/module.hxx>
#endif
+#ifndef _LINK_HXX
+#include <tools/link.hxx>
+#endif
#include "shellids.hxx"
@@ -75,17 +78,23 @@ class EditView;
class ScViewData;
class ScInputHandler;
class SvxURLField;
+class TransferableDataHelper;
+class TransferableClipboardListener;
class ScEditShell : public SfxShell
{
private:
EditView* pEditView;
ScViewData* pViewData;
+ TransferableClipboardListener* pClipEvtLstnr;
+ BOOL bPastePossible;
BOOL bIsInsertMode;
const SvxURLField* GetURLField();
ScInputHandler* GetMyInputHdl();
+ DECL_LINK( ClipboardChanged, TransferableDataHelper* );
+
public:
TYPEINFO();
SFX_DECL_INTERFACE(SCID_EDIT_SHELL);
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index c2de0ffdcb71..d4b742ec33d1 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: editsh.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: nn $ $Date: 2001-05-11 17:51:27 $
+ * last change: $Author: nn $ $Date: 2001-07-19 19:37:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -97,6 +97,7 @@
#include <so3/pastedlg.hxx>
#include <sot/exchange.hxx>
#include <svtools/cjkoptions.hxx>
+#include <svtools/cliplistener.hxx>
#include <svtools/whiter.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/sound.hxx>
@@ -133,6 +134,8 @@ SFX_IMPL_INTERFACE(ScEditShell, SfxShell, ScResId(SCSTR_EDITSHELL))
ScEditShell::ScEditShell(EditView* pView, ScViewData* pData) :
pEditView (pView),
pViewData (pData),
+ pClipEvtLstnr (NULL),
+ bPastePossible (FALSE),
bIsInsertMode (TRUE)
{
SetPool( pEditView->GetEditEngine()->GetEmptyItemSet().GetPool() );
@@ -142,6 +145,11 @@ ScEditShell::ScEditShell(EditView* pView, ScViewData* pData) :
ScEditShell::~ScEditShell()
{
+ if ( pClipEvtLstnr )
+ {
+ pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), FALSE );
+ pClipEvtLstnr->release();
+ }
}
ScInputHandler* ScEditShell::GetMyInputHdl()
@@ -567,10 +575,34 @@ const SvxURLField* ScEditShell::GetURLField()
return NULL;
}
+IMPL_LINK( ScEditShell, ClipboardChanged, TransferableDataHelper*, pDataHelper )
+{
+ if ( pDataHelper )
+ {
+ bPastePossible = ( pDataHelper->HasFormat( SOT_FORMAT_STRING ) || pDataHelper->HasFormat( SOT_FORMAT_RTF ) );
+
+ SfxBindings& rBindings = pViewData->GetBindings();
+ rBindings.Invalidate( SID_PASTE );
+ rBindings.Invalidate( FID_PASTE_CONTENTS );
+ rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+ return 0;
+}
+
void __EXPORT ScEditShell::GetClipState( SfxItemSet& rSet )
{
- TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
- BOOL bPaste = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
+ if ( !pClipEvtLstnr )
+ {
+ // create listener
+ pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScEditShell, ClipboardChanged ) );
+ pClipEvtLstnr->acquire();
+ Window* pWin = pViewData->GetActiveWin();
+ pClipEvtLstnr->AddRemoveListener( pWin, TRUE );
+
+ // get initial state
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
+ bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
+ }
SfxWhichIter aIter( rSet );
USHORT nWhich = aIter.FirstWhich();
@@ -580,13 +612,15 @@ void __EXPORT ScEditShell::GetClipState( SfxItemSet& rSet )
{
case SID_PASTE:
case FID_PASTE_CONTENTS:
- if( !bPaste )
+ if( !bPastePossible )
rSet.DisableItem( nWhich );
break;
case SID_CLIPBOARD_FORMAT_ITEMS:
- if( bPaste )
+ if( bPastePossible )
{
SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
aFormats.AddClipbrdFormat( SOT_FORMAT_STRING, String( ScResId( SCSTR_CLIP_STRING ) ) );