ooo-build r13492 - in trunk: . patches/dev300 patches/vba



Author: pflin
Date: Thu Aug  7 07:43:26 2008
New Revision: 13492
URL: http://svn.gnome.org/viewvc/ooo-build?rev=13492&view=rev

Log:
2008-08-07  Fong Lin  <pflin novell com>
	* patches/dev300/cws-npower11.diff: remove vba events stuff. 
	* patches/vba/vbaevents-services-sources.diff:
	* patches/vba/vba-workbook-worksheet-events.diff:
	* patches/dev300/apply.



Added:
   trunk/patches/vba/vba-workbook-worksheet-events.diff
Modified:
   trunk/ChangeLog
   trunk/patches/dev300/apply
   trunk/patches/dev300/cws-npower11.diff
   trunk/patches/vba/vbaevents-services-sources.diff

Modified: trunk/patches/dev300/apply
==============================================================================
--- trunk/patches/dev300/apply	(original)
+++ trunk/patches/dev300/apply	Thu Aug  7 07:43:26 2008
@@ -1448,9 +1448,6 @@
 # core changes not yet upstream
 sc-source-ui-vba-makefile-mk.diff
 
-# enable vba events in ooo-build
-vba-enable-vbaevents.diff, Fong
-
 # export of macro bindings for shapes
 sc-export-shape-macro-bindings.diff, n#304739, noelpwer
 
@@ -1491,6 +1488,9 @@
 
 vbaevents-services-sources.diff, i#68893
 
+# vba workbook/worksheet events
+vba-workbook-worksheet-events.diff, Fong
+
 # add support for passing a caller to basic when calling a script
 # via the scripting framework - note depends on vbaevents-services-sources.diff
 basic-caller-support.diff

Modified: trunk/patches/dev300/cws-npower11.diff
==============================================================================
--- trunk/patches/dev300/cws-npower11.diff	(original)
+++ trunk/patches/dev300/cws-npower11.diff	Thu Aug  7 07:43:26 2008
@@ -9,30 +9,11 @@
 ===================================================================
 RCS file: /cvs/sc/sc/inc/document.hxx,v
 retrieving revision 1.115
-retrieving revision 1.115.22.2
-diff -u -p -b -w -B -r1.115 -r1.115.22.2
+retrieving revision 1.115.22.1
+diff -u -p -b -w -B -r1.115 -r1.115.22.1
 --- sc/inc/document.hxx	8 Jul 2008 07:19:13 -0000	1.115
-+++ sc/inc/document.hxx	1 Aug 2008 03:32:42 -0000	1.115.22.2
-@@ -150,6 +150,9 @@ namespace com { namespace sun { namespac
-     }
- } } }
- 
-+namespace com { namespace sun { namespace star { namespace document {
-+    class XVbaEventsHelper;
-+} } } }
- #include <svtools/zforlist.hxx>
- /*
- #ifdef _ZFORLIST_DECLARE_TABLE
-@@ -307,6 +310,8 @@ private:
- 
- 	Timer				aTrackTimer;
- 
-+    com::sun::star::uno::Reference< com::sun::star::document::XVbaEventsHelper > mxVbaEventsHelper;
-+
- public:
-     ScTabOpList         aTableOpList;		            // list of ScInterpreterTableOpParams currently in use
-     ScInterpreterTableOpParams  aLastTableOpParams;     // remember last params
-@@ -703,7 +708,7 @@ SC_DLLPUBLIC	ScDBCollection*	GetDBCollec
++++ sc/inc/document.hxx	29 Jul 2008 06:35:39 -0000	1.115.22.1
+@@ -703,7 +703,7 @@ SC_DLLPUBLIC	ScDBCollection*	GetDBCollec
  	BOOL			HasBackgroundDraw( SCTAB nTab, const Rectangle& rMMRect );
  	BOOL			HasAnyDraw( SCTAB nTab, const Rectangle& rMMRect );
  
@@ -41,48 +22,6 @@
  	BOOL			SetOutlineTable( SCTAB nTab, const ScOutlineTable* pNewOutline );
  
  	void			DoAutoOutline( SCCOL nStartCol, SCROW nStartRow,
-@@ -1709,6 +1714,8 @@ public:
- 	void GetSortParam( ScSortParam& rParam, SCTAB nTab );
- 	void SetSortParam( ScSortParam& rParam, SCTAB nTab );
- 
-+    com::sun::star::uno::Reference< com::sun::star::document::XVbaEventsHelper > GetVbaEventsHelper();
-+
-     /** Should only be GRAM_PODF or GRAM_ODFF. */
-     void                SetStorageGrammar( ScGrammar::Grammar eGrammar );
-     ScGrammar::Grammar  GetStorageGrammar() const
-Index: sc/inc/docuno.hxx
-===================================================================
-RCS file: /cvs/sc/sc/inc/docuno.hxx,v
-retrieving revision 1.27
-retrieving revision 1.27.96.1
-diff -u -p -b -w -B -r1.27 -r1.27.96.1
---- sc/inc/docuno.hxx	10 Apr 2008 18:26:48 -0000	1.27
-+++ sc/inc/docuno.hxx	1 Aug 2008 03:32:42 -0000	1.27.96.1
-@@ -55,6 +55,7 @@
- #include <com/sun/star/sheet/XSheetAnnotations.hpp>
- #include <com/sun/star/beans/XPropertySet.hpp>
- #include <com/sun/star/sheet/XCellRangesAccess.hpp>
-+#include <com/sun/star/document/XDocumentEventCompatibleHelper.hpp>
- #include <cppuhelper/implbase2.hxx>
- #include <cppuhelper/implbase3.hxx>
- #include <cppuhelper/implbase4.hxx>
-@@ -86,6 +87,7 @@ class SC_DLLPUBLIC ScModelObj : public S
- 					public com::sun::star::view::XRenderable,
- 					public com::sun::star::document::XLinkTargetSupplier,
- 					public com::sun::star::beans::XPropertySet,
-+                    public com::sun::star::document::XDocumentEventCompatibleHelper,
- 					public SvxFmMSFactory,	// derived from XMultiServiceFactory
-                     public com::sun::star::lang::XServiceInfo
- {
-@@ -298,6 +300,8 @@ public:
- 								throw(::com::sun::star::uno::RuntimeException);
- 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
- 								throw(::com::sun::star::uno::RuntimeException);
-+                            // XVbaEventHelper
-+    virtual sal_Bool SAL_CALL processCompatibleEvent( sal_Int16 nEventId ) throw (::com::sun::star::uno::RuntimeException);
- };
- 
- 
 Index: sc/inc/olinetab.hxx
 ===================================================================
 RCS file: /cvs/sc/sc/inc/olinetab.hxx,v
@@ -119,113 +58,6 @@
 cvs diff: Diffing sc/source
 cvs diff: Diffing sc/source/core
 cvs diff: Diffing sc/source/core/data
-Index: sc/source/core/data/documen2.cxx
-===================================================================
-RCS file: /cvs/sc/sc/source/core/data/documen2.cxx,v
-retrieving revision 1.74
-retrieving revision 1.74.22.1
-diff -u -p -b -w -B -r1.74 -r1.74.22.1
---- sc/source/core/data/documen2.cxx	7 Jul 2008 07:39:38 -0000	1.74
-+++ sc/source/core/data/documen2.cxx	1 Aug 2008 03:32:42 -0000	1.74.22.1
-@@ -93,6 +93,7 @@
- #include "listenercalls.hxx"
- #include "recursionhelper.hxx"
- #include "lookupcache.hxx"
-+#include <com/sun/star/document/XVbaEventsHelper.hpp>
- 
- // pImpl because including lookupcache.hxx in document.hxx isn't wanted, and
- // dtor plus helpers are convenient.
-@@ -1874,3 +1875,26 @@ void ScDocument::ClearLookupCaches()
- {
-     pLookupCacheMapImpl->clear();
- }
-+
-+using namespace com::sun::star;
-+uno::Reference< document::XVbaEventsHelper > 
-+ScDocument::GetVbaEventsHelper()
-+{
-+	if( !mxVbaEventsHelper.is() )
-+	{
-+        try
-+        {
-+            uno::Reference< lang::XMultiServiceFactory > xSF( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
-+            uno::Reference< frame::XModel > xModel( pShell ? pShell->GetModel() : NULL, uno::UNO_QUERY );
-+            uno::Sequence< uno::Any > aArgs(1);
-+            aArgs[0] = uno::Any( xModel );
-+            uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper( xSF->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.VbaEventsHelper" ) ), aArgs ), uno::UNO_QUERY );
-+            // helper will always be created successfully.
-+            mxVbaEventsHelper.set( xVbaEventsHelper, uno::UNO_QUERY );
-+        }
-+        catch( uno::Exception& e )
-+        {
-+        }
-+	}
-+	return mxVbaEventsHelper;
-+}
-Index: sc/source/core/data/documen7.cxx
-===================================================================
-RCS file: /cvs/sc/sc/source/core/data/documen7.cxx,v
-retrieving revision 1.12
-retrieving revision 1.12.96.1
-diff -u -p -b -w -B -r1.12 -r1.12.96.1
---- sc/source/core/data/documen7.cxx	10 Apr 2008 19:23:56 -0000	1.12
-+++ sc/source/core/data/documen7.cxx	1 Aug 2008 03:32:42 -0000	1.12.96.1
-@@ -59,7 +59,15 @@
- 
- 
- #include "globstr.hrc"
-+#include <algorithm>
-+#include <vector>
- 
-+
-+#include <com/sun/star/document/XVbaEventsHelper.hpp>
-+#include <com/sun/star/document/VbaEventId.hpp>
-+
-+using namespace com::sun::star;
-+using namespace com::sun::star::document::VbaEventId;
- extern const ScFormulaCell* pLastFormulaTreeTop;	// cellform.cxx Err527 WorkAround
- 
- // STATIC DATA -----------------------------------------------------------
-@@ -449,6 +457,7 @@ void ScDocument::TrackFormulas( ULONG nH
- 		ScFormulaCell* pTrack;
- 		ScFormulaCell* pNext;
- 		pTrack = pFormulaTrack;
-+		::std::vector<SCTAB> aTabs; 
- 		do
- 		{
- 			ScHint aHint( nHintId, pTrack->aPos, pTrack );
-@@ -458,6 +467,12 @@ void ScDocument::TrackFormulas( ULONG nH
- 			//	Repaint fuer bedingte Formate mit relativen Referenzen:
- 			if ( pCondFormList )
- 				pCondFormList->SourceChanged( pTrack->aPos );
-+			::std::vector<SCTAB>::iterator result;
-+			result = ::std::find( aTabs.begin(), aTabs.end(), pTrack->aPos.Tab() );
-+			if( result == aTabs.end() )
-+			{
-+				aTabs.push_back( pTrack->aPos.Tab() );
-+			}
- 			pTrack = pTrack->GetNextTrack();
- 		} while ( pTrack );
- 		pTrack = pFormulaTrack;
-@@ -480,6 +495,18 @@ void ScDocument::TrackFormulas( ULONG nH
- 			else
- 				SetForcedFormulaPending( TRUE );
- 		}
-+
-+		::std::vector<SCTAB>::iterator iter;
-+		for( iter = aTabs.begin(); iter != aTabs.end(); iter++ )
-+		{
-+            uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper ( GetVbaEventsHelper(), uno::UNO_QUERY );
-+            if( xVbaEventsHelper.is() )
-+            {
-+			    uno::Sequence< uno::Any > aArgs(1);
-+                aArgs[0] <<= *iter;
-+			    xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_CALCULATE, aArgs );
-+            }
-+		}
- 	}
- 	DBG_ASSERT( nFormulaTrackCount==0, "TrackFormulas: nFormulaTrackCount!=0" );
- }
 cvs diff: Diffing sc/source/core/inc
 cvs diff: Diffing sc/source/core/src
 cvs diff: Diffing sc/source/core/tool
@@ -248,202 +80,9 @@
 cvs diff: Diffing sc/source/ui/cctrl
 cvs diff: Diffing sc/source/ui/dbgui
 cvs diff: Diffing sc/source/ui/docshell
-Index: sc/source/ui/docshell/docsh.cxx
-===================================================================
-RCS file: /cvs/sc/sc/source/ui/docshell/docsh.cxx,v
-retrieving revision 1.103
-retrieving revision 1.103.22.1
-diff -u -p -b -w -B -r1.103 -r1.103.22.1
---- sc/source/ui/docshell/docsh.cxx	8 Jul 2008 09:43:20 -0000	1.103
-+++ sc/source/ui/docshell/docsh.cxx	1 Aug 2008 03:32:43 -0000	1.103.22.1
-@@ -132,6 +132,13 @@
- #include <rtl/logfile.hxx>
- 
- #include <comphelper/processfactory.hxx>
-+#include "uiitems.hxx"
-+#include "cellsuno.hxx"
-+#include <com/sun/star/document/XVbaEventsHelper.hpp>
-+#include <com/sun/star/document/VbaEventId.hpp>
-+
-+using namespace com::sun::star;
-+using namespace com::sun::star::document::VbaEventId;
- 
- using namespace com::sun::star;
- 
-@@ -515,6 +522,10 @@ sal_uInt16 ScDocShell::GetHiddenInformat
- void ScDocShell::BeforeXMLLoading()
- {
-     aDocument.DisableIdle( TRUE );
-+    // suppress VBA events when loading the xml
-+    uno::Reference< document::XVbaEventsHelper > xEvt( aDocument.GetVbaEventsHelper() );
-+    if ( xEvt.is() )
-+       xEvt->setIgnoreEvents( sal_True );
- 
-     // prevent unnecessary broadcasts and updates
-     DBG_ASSERT(pModificator == NULL, "The Modificator should not exist");
-@@ -600,6 +611,10 @@ void ScDocShell::AfterXMLLoading(sal_Boo
-     else
- 		aDocument.SetInsertingFromOtherDoc( FALSE );
- 
-+        // suppress VBA events when loading the xml
-+        uno::Reference< document::XVbaEventsHelper > xEvt( aDocument.GetVbaEventsHelper() );
-+        if ( xEvt.is() )
-+            xEvt->setIgnoreEvents( sal_False );
- 	aDocument.SetImportingXML( FALSE );
-     aDocument.EnableUndo( TRUE );
-     bIsEmpty = FALSE;
-@@ -720,9 +735,71 @@ BOOL __EXPORT ScDocShell::Load( SfxMediu
- 	return bRet;
- }
- 
-+void lcl_processCompatibleSfxHint( uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper, const SfxHint& rHint )
-+{
-+    if (rHint.ISA(ScTablesHint) )
-+    {
-+		USHORT nId = ((ScTablesHint&)rHint).GetId();	
-+		SCTAB nTab = ((ScTablesHint&)rHint).GetTab1();	
-+        if( nId == SC_TAB_INSERTED )
-+        {
-+            uno::Sequence< uno::Any > aArgs(1);
-+            aArgs[0] <<= nTab;
-+            xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_NEWSHEET, aArgs );
-+        }
-+    }
-+    else if ( rHint.ISA( SfxEventHint ) )
-+    {
-+        ULONG nEventId = ((SfxEventHint&)rHint).GetEventId();
-+        switch ( nEventId )
-+        {
-+            case SFX_EVENT_ACTIVATEDOC:
-+            {
-+                uno::Sequence< uno::Any > aArgs;
-+                xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_ACTIVATE, aArgs );
-+            }
-+                break;
-+            case SFX_EVENT_DEACTIVATEDOC:
-+            {
-+                uno::Sequence< uno::Any > aArgs;
-+                xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_DEACTIVATE, aArgs );
-+            }
-+                break;
-+            /*case SFX_EVENT_CLOSEDOC :
-+            {
-+                uno::Sequence< uno::Any > aArgs;
-+                xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_CLOSE, aArgs );
-+            }
-+                break;
-+            case SFX_EVENT_CLOSEVIEW :
-+            {
-+                uno::Sequence< uno::Any > aArgs;
-+                xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_WINDOWCOLSE, aArgs );
-+            }
-+                break;
-+            */    
-+            case SFX_EVENT_OPENDOC:
-+            {
-+                // some later than workbook activate.
-+                uno::Sequence< uno::Any > aArgs;
-+                xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_OPEN, aArgs );
-+            }
-+                break;
-+            default:
-+                {
-+                }
-+                break;
-+        }
-+    }
-+}
- 
- void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
- {
-+    uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper ( aDocument.GetVbaEventsHelper(), uno::UNO_QUERY );
-+    if ( xVbaEventsHelper.is() )
-+    {
-+        lcl_processCompatibleSfxHint( xVbaEventsHelper, rHint );
-+    }
- 	if (rHint.ISA(SfxSimpleHint))								// ohne Parameter
- 	{
- 		ULONG nSlot = ((const SfxSimpleHint&)rHint).GetId();
-@@ -2268,6 +2345,16 @@ USHORT __EXPORT ScDocShell::PrepareClose
- 
- 	DoEnterHandler();
- 
-+	// start handler for possible veto from DocBefore_Close
-+    uno::Sequence< uno::Any > aArgs;
-+    uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper ( aDocument.GetVbaEventsHelper(), uno::UNO_QUERY );
-+    if ( !IsInPrepareClose() && xVbaEventsHelper.is() )
-+    {
-+	    if ( xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_BEFORECLOSE, aArgs ) )
-+		    return sal_False;
-+    }
-+	// end handler code
-+
- 	USHORT nRet = SfxObjectShell::PrepareClose( bUI, bForBrowsing );
- 	if (nRet == TRUE)						// TRUE = schliessen
- 		aDocument.DisableIdle(TRUE);		// nicht mehr drin rumpfuschen !!!
-@@ -2477,6 +2564,34 @@ void ScDocShell::SetModified( BOOL bModi
- 	}
- }
- 
-+void ScDocShell::PostContentChanged( const ScRange& rRange )
-+{
-+    ScRangeList aList;
-+    aList.Append(rRange);
-+    PostContentChanged(aList);
-+}
-+
-+void ScDocShell::PostContentChanged( const ScRangeList& rList )
-+{
-+    ScCellRangesBase* pObj = NULL;
-+	const ScRange& rRange = *(rList.GetObject(0));	
-+	if( rList.Count() == 1 )
-+	{
-+    	if (rRange.aStart == rRange.aEnd)
-+    	    pObj = new ScCellObj( this, rRange.aStart );
-+	   	else
-+	       	pObj = new ScCellRangeObj( this, rRange );
-+	}
-+	else
-+		pObj = new ScCellRangesObj( this, rList );	
-+
-+    uno::Sequence< uno::Any > aArgs(1);
-+    aArgs[0] = uno::makeAny(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj)));
-+
-+    uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper( aDocument.GetVbaEventsHelper(), uno::UNO_QUERY );
-+    if ( xVbaEventsHelper.is() )
-+        xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_CHANGE, aArgs );
-+}
- 
- void ScDocShell::SetDocumentModified( BOOL bIsModified /* = TRUE */ )
- {
 cvs diff: Diffing sc/source/ui/drawfunc
 cvs diff: Diffing sc/source/ui/formdlg
 cvs diff: Diffing sc/source/ui/inc
-Index: sc/source/ui/inc/docsh.hxx
-===================================================================
-RCS file: /cvs/sc/sc/source/ui/inc/docsh.hxx,v
-retrieving revision 1.50
-retrieving revision 1.50.96.1
-diff -u -p -b -w -B -r1.50 -r1.50.96.1
---- sc/source/ui/inc/docsh.hxx	15 Apr 2008 14:34:04 -0000	1.50
-+++ sc/source/ui/inc/docsh.hxx	1 Aug 2008 03:32:43 -0000	1.50.96.1
-@@ -47,6 +47,7 @@
- #include "refreshtimer.hxx"
- 
- #include <hash_map>
-+#include <cppuhelper/implbase1.hxx>
- 
- class ScEditEngineDefaulter;
- class FontList;
-@@ -326,6 +327,8 @@ public:
- 	void            PostPaintExtras();
- 
- 	void            PostDataChanged();
-+	void			PostContentChanged( const ScRange& rRange ); // for worsheet/workbook changed event
-+    void            PostContentChanged( const ScRangeList& rList );
- 
- 	void			UpdatePaintExt( USHORT& rExtFlags, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
- 													   SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab );
 cvs diff: Diffing sc/source/ui/miscdlgs
 cvs diff: Diffing sc/source/ui/namedlg
 cvs diff: Diffing sc/source/ui/navipi
@@ -452,440 +91,16 @@
 cvs diff: Diffing sc/source/ui/src
 cvs diff: Diffing sc/source/ui/styleui
 cvs diff: Diffing sc/source/ui/undo
-Index: sc/source/ui/undo/undoblk.cxx
-===================================================================
-RCS file: /cvs/sc/sc/source/ui/undo/undoblk.cxx,v
-retrieving revision 1.27
-retrieving revision 1.27.96.1
-diff -u -p -b -w -B -r1.27 -r1.27.96.1
---- sc/source/ui/undo/undoblk.cxx	11 Apr 2008 00:24:23 -0000	1.27
-+++ sc/source/ui/undo/undoblk.cxx	1 Aug 2008 03:32:43 -0000	1.27.96.1
-@@ -125,6 +125,7 @@ ScUndoInsertCells::ScUndoInsertCells( Sc
- 	}
- 
- 	SetChangeTrack();
-+	pDocShell->PostContentChanged( aEffRange );
- }
- 
- __EXPORT ScUndoInsertCells::~ScUndoInsertCells()
-@@ -271,6 +272,7 @@ void __EXPORT ScUndoInsertCells::Undo()
- 	BeginUndo();
- 	DoChange( TRUE );
- 	EndUndo();
-+	pDocShell->PostContentChanged( aEffRange );
- }
- 
- void __EXPORT ScUndoInsertCells::Redo()
-@@ -279,6 +281,7 @@ void __EXPORT ScUndoInsertCells::Redo()
- 	BeginRedo();
- 	DoChange( FALSE );
- 	EndRedo();
-+	pDocShell->PostContentChanged( aEffRange );
- 
- 	if ( pPasteUndo )
- 		pPasteUndo->Redo();		// redo paste last
-@@ -333,6 +336,7 @@ ScUndoDeleteCells::ScUndoDeleteCells( Sc
- 	}
- 
- 	SetChangeTrack();
-+	pDocShell->PostContentChanged( aEffRange );
- }
- 
- __EXPORT ScUndoDeleteCells::~ScUndoDeleteCells()
-@@ -474,6 +478,7 @@ void __EXPORT ScUndoDeleteCells::Undo()
- 	BeginUndo();
- 	DoChange( TRUE );
- 	EndUndo();
-+	pDocShell->PostContentChanged( aEffRange );
-     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
- 
- 	// Markierung erst nach EndUndo
-@@ -488,6 +493,7 @@ void __EXPORT ScUndoDeleteCells::Redo()
- 	BeginRedo();
- 	DoChange( FALSE);
- 	EndRedo();
-+	pDocShell->PostContentChanged( aEffRange );
-     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
- 
- 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
-@@ -714,6 +720,7 @@ ScUndoCut::ScUndoCut( ScDocShell* pNewDo
- 	aExtendedRange( aRange )
- {
- 	SetChangeTrack();
-+	pDocShell->PostContentChanged( aExtendedRange );
- }
- 
- __EXPORT ScUndoCut::~ScUndoCut()
-@@ -778,6 +785,7 @@ void __EXPORT ScUndoCut::Undo()
- 	BeginUndo();
- 	DoChange( TRUE );
- 	EndUndo();
-+	pDocShell->PostContentChanged( aExtendedRange );
- }
- 
- void __EXPORT ScUndoCut::Redo()
-@@ -788,6 +796,7 @@ void __EXPORT ScUndoCut::Redo()
- 	DoChange( FALSE );
- 	EnableDrawAdjust( pDoc, TRUE );					//! include in ScBlockUndo?
- 	EndRedo();
-+	pDocShell->PostContentChanged( aExtendedRange );
- }
- 
- void __EXPORT ScUndoCut::Repeat(SfxRepeatTarget& rTarget)
-@@ -839,6 +848,7 @@ ScUndoPaste::ScUndoPaste( ScDocShell* pN
- 		aPasteOptions = *pOptions;		// used only for Repeat
- 
- 	SetChangeTrack();
-+	pDocShell->PostContentChanged( aBlockRange );
- }
- 
- __EXPORT ScUndoPaste::~ScUndoPaste()
-@@ -1020,6 +1030,7 @@ void __EXPORT ScUndoPaste::Undo()
- 	DoChange( TRUE );
- 	ShowTable( aBlockRange );
- 	EndUndo();
-+	pDocShell->PostContentChanged( aBlockRange );
-     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
- }
- 
-@@ -1031,6 +1042,7 @@ void __EXPORT ScUndoPaste::Redo()
- 	DoChange( FALSE );
- 	EnableDrawAdjust( pDoc, TRUE );					//! include in ScBlockUndo?
- 	EndRedo();
-+	pDocShell->PostContentChanged( aBlockRange );
-     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
- }
- 
-Index: sc/source/ui/undo/undoblk3.cxx
-===================================================================
-RCS file: /cvs/sc/sc/source/ui/undo/undoblk3.cxx,v
-retrieving revision 1.22
-retrieving revision 1.22.96.1
-diff -u -p -b -w -B -r1.22 -r1.22.96.1
---- sc/source/ui/undo/undoblk3.cxx	11 Apr 2008 00:24:52 -0000	1.22
-+++ sc/source/ui/undo/undoblk3.cxx	1 Aug 2008 03:32:43 -0000	1.22.96.1
-@@ -78,7 +78,17 @@ TYPEINIT1(ScUndoInsertAreaLink,		SfxUndo
- TYPEINIT1(ScUndoRemoveAreaLink,		SfxUndoAction);
- TYPEINIT1(ScUndoUpdateAreaLink,		SfxUndoAction);
- 
--
-+void lcl_PostContentChanged( ScDocShell* pDocShell, const ScMarkData& rMark, const ScRange& rRange )
-+{
-+    if (rMark.IsMarked() || rMark.IsMultiMarked())
-+    {
-+        ScRangeList aList;
-+        rMark.FillRangeListWithMarks(&aList, false);
-+        pDocShell->PostContentChanged(aList);
-+    }
-+    else
-+        pDocShell->PostContentChanged( rRange );
-+}
- // To Do:
- /*A*/	// SetOptimalHeight auf Dokument, wenn keine View
- 
-@@ -112,6 +122,8 @@ ScUndoDeleteContents::ScUndoDeleteConten
- 		aMarkData.SetMarkArea( aRange );							// Zelle unter Cursor markieren
- 
- 	SetChangeTrack();
-+
-+	lcl_PostContentChanged( pDocShell, aMarkData, aRange );
- }
- 
- 
-@@ -212,6 +224,7 @@ void __EXPORT ScUndoDeleteContents::Undo
- 	BeginUndo();
- 	DoChange( TRUE );
- 	EndUndo();
-+	lcl_PostContentChanged( pDocShell, aMarkData, aRange );
- }
- 
- 
-@@ -222,6 +235,7 @@ void __EXPORT ScUndoDeleteContents::Redo
- 	BeginRedo();
- 	DoChange( FALSE );
- 	EndRedo();
-+	lcl_PostContentChanged( pDocShell, aMarkData, aRange );
- }
- 
- 
-Index: sc/source/ui/undo/undocell.cxx
-===================================================================
-RCS file: /cvs/sc/sc/source/ui/undo/undocell.cxx,v
-retrieving revision 1.15
-retrieving revision 1.15.96.1
-diff -u -p -b -w -B -r1.15 -r1.15.96.1
---- sc/source/ui/undo/undocell.cxx	11 Apr 2008 00:25:08 -0000	1.15
-+++ sc/source/ui/undo/undocell.cxx	1 Aug 2008 03:32:44 -0000	1.15.96.1
-@@ -198,6 +198,7 @@ ScUndoEnterData::ScUndoEnterData( ScDocS
- 	nCount( nNewCount )
- {
- 	SetChangeTrack();
-+	pDocShell->PostContentChanged( ScRange( ScAddress( nCol, nRow, nTab ) ) );
- }
- 
- __EXPORT ScUndoEnterData::~ScUndoEnterData()
-@@ -303,6 +304,7 @@ void __EXPORT ScUndoEnterData::Undo()
- 
- 	DoChange();
- 	EndUndo();
-+	pDocShell->PostContentChanged( ScRange( ScAddress( nCol, nRow, nTab ) ) );
- }
- 
- void __EXPORT ScUndoEnterData::Redo()
-@@ -324,6 +326,7 @@ void __EXPORT ScUndoEnterData::Redo()
- 
- 	DoChange();
- 	EndRedo();
-+	pDocShell->PostContentChanged( ScRange( ScAddress( nCol, nRow, nTab ) ) );
- }
- 
- void __EXPORT ScUndoEnterData::Repeat(SfxRepeatTarget& rTarget)
-@@ -355,6 +358,7 @@ ScUndoEnterValue::ScUndoEnterValue( ScDo
- 	bNeedHeight	( bHeight )
- {
- 	SetChangeTrack();
-+	pDocShell->PostContentChanged( ScRange( aPos ) );
- }
- 
- __EXPORT ScUndoEnterValue::~ScUndoEnterValue()
-@@ -409,6 +413,7 @@ void __EXPORT ScUndoEnterValue::Undo()
- 		pChangeTrack->Undo( nEndChangeAction, nEndChangeAction );
- 
- 	EndUndo();
-+	pDocShell->PostContentChanged( ScRange( aPos ) );
- }
- 
- void __EXPORT ScUndoEnterValue::Redo()
-@@ -422,6 +427,7 @@ void __EXPORT ScUndoEnterValue::Redo()
- 	SetChangeTrack();
- 
- 	EndRedo();
-+	pDocShell->PostContentChanged( ScRange( aPos ) );
- }
- 
- void __EXPORT ScUndoEnterValue::Repeat(SfxRepeatTarget& /* rTarget */)
-@@ -449,6 +455,7 @@ ScUndoPutCell::ScUndoPutCell( ScDocShell
- 	bNeedHeight	( bHeight )
- {
- 	SetChangeTrack();
-+	pDocShell->PostContentChanged( ScRange( aPos ) );
- }
- 
- __EXPORT ScUndoPutCell::~ScUndoPutCell()
-@@ -505,6 +512,7 @@ void __EXPORT ScUndoPutCell::Undo()
- 		pChangeTrack->Undo( nEndChangeAction, nEndChangeAction );
- 
- 	EndUndo();
-+	pDocShell->PostContentChanged( ScRange( aPos ) );
- }
- 
- void __EXPORT ScUndoPutCell::Redo()
-@@ -533,6 +541,7 @@ void __EXPORT ScUndoPutCell::Redo()
- 	SetChangeTrack();
- 
- 	EndRedo();
-+	pDocShell->PostContentChanged( ScRange( aPos ) );
- }
- 
- void __EXPORT ScUndoPutCell::Repeat(SfxRepeatTarget& /* rTarget */)
 cvs diff: Diffing sc/source/ui/unoobj
-Index: sc/source/ui/unoobj/docuno.cxx
-===================================================================
-RCS file: /cvs/sc/sc/source/ui/unoobj/docuno.cxx,v
-retrieving revision 1.68
-retrieving revision 1.68.38.1
-diff -u -p -b -w -B -r1.68 -r1.68.38.1
---- sc/source/ui/unoobj/docuno.cxx	1 Jul 2008 16:26:56 -0000	1.68
-+++ sc/source/ui/unoobj/docuno.cxx	1 Aug 2008 03:32:44 -0000	1.68.38.1
-@@ -96,7 +96,10 @@
- #include <svx/unoshape.hxx>
- #endif
- 
-+#include <com/sun/star/document/XVbaEventsHelper.hpp>
-+#include <com/sun/star/document/VbaEventId.hpp>
- using namespace com::sun::star;
-+using namespace com::sun::star::document::VbaEventId;
- 
- //------------------------------------------------------------------------
- 
-@@ -331,6 +334,7 @@ uno::Any SAL_CALL ScModelObj::queryInter
- 	SC_QUERYINTERFACE( view::XRenderable )
- 	SC_QUERYINTERFACE( document::XLinkTargetSupplier )
- 	SC_QUERYINTERFACE( beans::XPropertySet )
-+ 	SC_QUERYINTERFACE( document::XDocumentEventCompatibleHelper)
- 	SC_QUERYINTERFACE( lang::XMultiServiceFactory )
- 	SC_QUERYINTERFACE( lang::XServiceInfo )
- 
-@@ -1726,6 +1730,39 @@ uno::Sequence<rtl::OUString> SAL_CALL Sc
- 	return concatServiceNames( aMyServices, aDrawServices );
- }
- 
-+// XVbaEventHelper
-+// For Vba Event
-+sal_Bool SAL_CALL
-+ScModelObj::processCompatibleEvent( sal_Int16 nSlotId ) throw( ::com::sun::star::uno::RuntimeException )
-+{
-+    USHORT nId = (USHORT)nSlotId;
-+    uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper( GetDocument()->GetVbaEventsHelper(), uno::UNO_QUERY );
-+    if( xVbaEventsHelper.is() )
-+    {
-+        switch( nId )
-+        {
-+            case SID_SAVEDOC:
-+            {
-+                uno::Sequence< uno::Any > aArgs(1);
-+                aArgs[0] <<= sal_False;
-+                return xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_BEFORESAVE, aArgs );
-+            }
-+            case SID_SAVEASDOC:
-+            {
-+                uno::Sequence< uno::Any > aArgs(1);
-+                aArgs[0] <<= sal_True;
-+                return xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_BEFORESAVE, aArgs );
-+            }
-+            case SID_PRINTDOC:
-+            case SID_PRINTDOCDIRECT:
-+            {
-+                uno::Sequence< uno::Any > aArgs;
-+                return xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_BEFOREPRINT, aArgs );
-+            }
-+        }
-+    }
-+    return sal_False;
-+}
- // XServiceInfo
- 
- rtl::OUString SAL_CALL ScModelObj::getImplementationName() throw(uno::RuntimeException)
-Index: sc/source/ui/unoobj/viewuno.cxx
-===================================================================
-RCS file: /cvs/sc/sc/source/ui/unoobj/viewuno.cxx,v
-retrieving revision 1.38
-retrieving revision 1.38.38.1
-diff -u -p -b -w -B -r1.38 -r1.38.38.1
---- sc/source/ui/unoobj/viewuno.cxx	1 Jul 2008 16:27:14 -0000	1.38
-+++ sc/source/ui/unoobj/viewuno.cxx	1 Aug 2008 03:32:44 -0000	1.38.38.1
-@@ -71,8 +71,12 @@
- #include "gridwin.hxx"
- #include <com/sun/star/view/DocumentZoomType.hpp>
- #include "AccessibilityHints.hxx"
-+#include <com/sun/star/awt/MouseButton.hpp>
-+#include <com/sun/star/document/XVbaEventsHelper.hpp>
-+#include <com/sun/star/document/VbaEventId.hpp>
- 
- using namespace com::sun::star;
-+using namespace com::sun::star::document::VbaEventId;
- 
- //------------------------------------------------------------------------
- 
-@@ -458,6 +462,78 @@ void SAL_CALL ScViewPaneObj::release() t
- 	OWeakObject::release();
- }
- 
-+// To process sheet compatibile event
-+typedef ::cppu::WeakImplHelper2< awt::XEnhancedMouseClickHandler, view::XSelectionChangeListener > TabViewEventListener_BASE;
-+class ScTabViewEventListener: public TabViewEventListener_BASE
-+{
-+private:
-+    uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper;
-+    ScTabViewObj* pViewObj;
-+    
-+public:
-+    ScTabViewEventListener( ScTabViewObj* pObj, uno::Reference< document::XVbaEventsHelper >& rVbaEventsHelper);
-+    ~ScTabViewEventListener();
-+	// XEnhancedMouseClickHandler
-+	virtual sal_Bool SAL_CALL mousePressed( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException);
-+	virtual sal_Bool SAL_CALL mouseReleased( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException);
-+
-+    // XSelectionChangeListener
-+    virtual void SAL_CALL selectionChanged( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
-+    // XEventListener
-+	virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
-+};
-+
-+ScTabViewEventListener::ScTabViewEventListener(ScTabViewObj* pObj, uno::Reference< document::XVbaEventsHelper >& rVbaEventsHelper):
-+                        pViewObj( pObj ),xVbaEventsHelper( rVbaEventsHelper )
-+{
-+}
-+
-+ScTabViewEventListener::~ScTabViewEventListener()
-+{
-+}
-+
-+void SAL_CALL ScTabViewEventListener::disposing(  const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
-+{
-+}
-+
-+sal_Bool SAL_CALL ScTabViewEventListener::mousePressed( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException)
-+{
-+	sal_Bool result =  sal_False;
-+    // process BeforeDoubleClick and BeforeRightClick events
-+	if( e.ClickCount == 2 || e.Buttons == ::com::sun::star::awt::MouseButton::RIGHT )
-+	{
-+		// ensure the target is a cell
-+        uno::Reference< table::XCell > xCell( e.Target, uno::UNO_QUERY );
-+		if( xCell.is() && xVbaEventsHelper.is() && pViewObj)
-+		{
-+			uno::Sequence< uno::Any > aArgs(1);
-+			aArgs[0] = pViewObj->getSelection();
-+			sal_Int32 nEventId = VBAEVENT_WORKSHEET_BEFORERIGHTCLICK;
-+			if( e.ClickCount == 2 )
-+				nEventId = VBAEVENT_WORKSHEET_BEFOREDOUBLECLICK;
-+            
-+            result = xVbaEventsHelper->ProcessCompatibleVbaEvent( nEventId, aArgs );
-+			// TODO: process Cancel argument	
-+		}
-+	}
-+	return result;
-+}
-+
-+sal_Bool SAL_CALL ScTabViewEventListener::mouseReleased( const awt::EnhancedMouseEvent&/*e*/) throw (uno::RuntimeException)
-+{
-+	return sal_False;
-+}
-+
-+void SAL_CALL ScTabViewEventListener::selectionChanged( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
-+{
-+	if ( xVbaEventsHelper.is() && pViewObj)
-+	{
-+	    uno::Sequence< uno::Any > aArgs(1);
-+	    aArgs[0] = pViewObj->getSelection();
-+	    xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_SELECTIONCHANGE, aArgs );
-+	}
-+}
-+
- //------------------------------------------------------------------------
- 
- //	Default-ctor wird fuer SMART_REFLECTION_IMPLEMENTATION gebraucht
-@@ -480,7 +556,19 @@ ScTabViewObj::ScTabViewObj( ScTabViewShe
- 	aActivationListeners( 0 ),
- 	bDrawSelModeSet(sal_False)
- {
--	//!	Listening oder so
-+	if( pViewSh )
-+	{
-+		ScViewData* pViewData = pViewSh->GetViewData();
-+		if( pViewData )
-+		{
-+            uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper (pViewData->GetDocument()->GetVbaEventsHelper(), uno::UNO_QUERY );
-+			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()
 cvs diff: Diffing sc/source/ui/vba
 Index: sc/source/ui/vba/makefile.mk
 ===================================================================
 RCS file: /cvs/sc/sc/source/ui/vba/makefile.mk,v
 retrieving revision 1.6
-retrieving revision 1.5.42.6
-diff -u -p -b -w -B -r1.6 -r1.5.42.6
+retrieving revision 1.5.42.5
+diff -u -p -b -w -B -r1.6 -r1.5.42.5
 --- sc/source/ui/vba/makefile.mk	11 Apr 2008 00:46:57 -0000	1.6
-+++ sc/source/ui/vba/makefile.mk	1 Aug 2008 03:32:44 -0000	1.5.42.6
++++ sc/source/ui/vba/makefile.mk	29 Jul 2008 06:35:39 -0000	1.5.42.5
 @@ -88,6 +88,7 @@ SLOFILES= \
                  $(SLO)$/vbabutton.obj \
                  $(SLO)$/vbalabel.obj \
@@ -894,12 +109,10 @@
                  $(SLO)$/vbaradiobutton.obj \
                  $(SLO)$/vbalistbox.obj \
                  $(SLO)$/vbapropvalue.obj \
-@@ -111,8 +112,25 @@ SLOFILES= \
+@@ -111,6 +112,24 @@ SLOFILES= \
                  $(SLO)$/vbaformatconditions.obj \
                  $(SLO)$/vbastyle.obj \
                  $(SLO)$/vbastyles.obj \
--		$(SLO)$/service.obj \
-- 
 +                $(SLO)$/vbaassistant.obj \
 +                $(SLO)$/vbauserform.obj \
 +                $(SLO)$/vbacheckbox.obj \
@@ -918,19 +131,18 @@
 +		        $(SLO)$/vbapagebreak.obj \
 +        		$(SLO)$/vbapagebreaks.obj \
 +		        $(SLO)$/vbaspinbutton.obj \
-+				$(SLO)$/service.obj
- 
- # --- Targets ------------------------------------------------------
+ 		$(SLO)$/service.obj \
+  
  
 Index: sc/source/ui/vba/service.cxx
 ===================================================================
 RCS file: /cvs/sc/sc/source/ui/vba/service.cxx,v
 retrieving revision 1.4
-retrieving revision 1.3.42.4
-diff -u -p -b -w -B -r1.4 -r1.3.42.4
+retrieving revision 1.3.42.3
+diff -u -p -b -w -B -r1.4 -r1.3.42.3
 --- sc/source/ui/vba/service.cxx	11 Apr 2008 00:47:11 -0000	1.4
-+++ sc/source/ui/vba/service.cxx	1 Aug 2008 03:32:44 -0000	1.3.42.4
-@@ -53,12 +53,28 @@ namespace  worksheet
++++ sc/source/ui/vba/service.cxx	29 Jul 2008 06:35:39 -0000	1.3.42.3
+@@ -53,11 +53,22 @@ namespace  worksheet
  {
  extern sdecl::ServiceDecl const serviceDecl;
  }
@@ -943,7 +155,6 @@
  extern sdecl::ServiceDecl const serviceDecl;
  }
 -
--
 +namespace  userform
 +{
 +extern sdecl::ServiceDecl const serviceDecl;
@@ -952,40 +163,24 @@
 +{
 +extern sdecl::ServiceDecl const serviceDecl;
 +}
-+#ifdef VBA_OOBUILD_HACK
-+namespace vbaeventshelper
-+{
-+extern sdecl::ServiceDecl const serviceDecl;
-+}
-+#endif
+ 
  
  extern "C"
- {
-@@ -75,8 +91,13 @@ extern "C"
- 		OSL_TRACE("In component_writeInfo");
+@@ -76,7 +87,7 @@ extern "C"
  
  	// Component registration
-+#ifdef VBA_OOBUILD_HACK
-+        if ( component_writeInfoHelper( pServiceManager, pRegistryKey, 
-+		range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, userform::serviceDecl, window::serviceDecl, hyperlink::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl ) )
-+#else	
          if ( component_writeInfoHelper( pServiceManager, pRegistryKey, 
 -		range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl ) )
 +		range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, userform::serviceDecl, window::serviceDecl, hyperlink::serviceDecl ) )
-+#endif	
  		{
  			// Singleton registration
  			try
-@@ -104,7 +125,11 @@ extern "C"
+@@ -104,7 +115,7 @@ extern "C"
      {
  		OSL_TRACE("In component_getFactory for %s", pImplName );
  	void* pRet =  component_getFactoryHelper(
 -        	pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl );
 +        	pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, userform::serviceDecl, window::serviceDecl, hyperlink::serviceDecl );
-+#ifdef VBA_OOBUILD_HACK			
-+    if( !pRet )
-+        pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl );
-+#endif		
  	OSL_TRACE("Ret is 0x%x", pRet);
  	return pRet;
      }
@@ -4065,1173 +3260,10 @@
  };
  
  #endif//SC_VBA_CONTROL_HXX
-Index: sc/source/ui/vba/vbaeventshelper.cxx
+Index: sc/source/ui/vba/vbaframe.cxx
 ===================================================================
-RCS file: sc/source/ui/vba/vbaeventshelper.cxx
-diff -N sc/source/ui/vba/vbaeventshelper.cxx
---- /dev/null	1 Jan 1970 00:00:00 -0000
-+++ sc/source/ui/vba/vbaeventshelper.cxx	1 Aug 2008 03:32:45 -0000	1.1.2.1
-@@ -0,0 +1,1066 @@
-+/*************************************************************************
-+ *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile$
-+ *
-+ *  $Revision$
-+ *
-+ *  last change: $Author$ $Date$
-+ *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
-+ *
-+ *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
-+ *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
-+ *
-+ *    This library is distributed in the hope that it will be useful,
-+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-+ *    Lesser General Public License for more details.
-+ *
-+ *    You should have received a copy of the GNU Lesser General Public
-+ *    License along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
-+ *
-+ ************************************************************************/
-+#include "vbaeventshelper.hxx"
-+#include "helperdecl.hxx"
-+#include <sfx2/objsh.hxx> 
-+#include <basic/basmgr.hxx>
-+#include <basic/sbmod.hxx>
-+#include <basic/sbmeth.hxx>
-+#include <basic/sbx.hxx>
-+#include "scextopt.hxx"
-+#include <sfx2/evntconf.hxx>
-+#include <sfx2/event.hxx>
-+#include <sfx2/sfx.hrc>
-+#include <toolkit/unohlp.hxx>
-+#include <comphelper/processfactory.hxx>
-+#include <cppuhelper/implbase1.hxx>
-+#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
-+#include <com/sun/star/document/XEventsSupplier.hpp>
-+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
-+#include <com/sun/star/table/XCell.hpp> 
-+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-+#include <com/sun/star/sheet/XSpreadsheet.hpp>
-+#include <com/sun/star/container/XNamed.hpp>
-+#include <com/sun/star/awt/XWindowListener.hpp>
-+#include <com/sun/star/awt/WindowEvent.hpp>
-+#include <com/sun/star/lang/EventObject.hpp>
-+#include <com/sun/star/util/XCloseListener.hpp>
-+#include <com/sun/star/util/XCloseBroadcaster.hpp>
-+#include <com/sun/star/frame/XControllerBorder.hpp>
-+#include <com/sun/star/frame/XBorderResizeListener.hpp>
-+#include "cellsuno.hxx" 
-+
-+#include <map>
-+
-+using namespace std;
-+using namespace com::sun::star;
-+using namespace org::openoffice;
-+using namespace com::sun::star::document::VbaEventId;
-+
-+const static String sLibrary( RTL_CONSTASCII_USTRINGPARAM("Standard"));
-+
-+const static rtl::OUString sUrlPart0 = rtl::OUString::createFromAscii( "vnd.sun.star.script:");
-+const static rtl::OUString sUrlPart1 = rtl::OUString::createFromAscii( "vnd.sun.star.script:Standard.");
-+const static rtl::OUString sUrlPart2 = rtl::OUString::createFromAscii( "?language=Basic&location=document"); 
-+
-+
-+typedef ::cppu::WeakImplHelper3< awt::XWindowListener, util::XCloseListener, frame::XBorderResizeListener > WindowListener_BASE;
-+
-+// This class is to process Workbook window related event
-+class VbaEventsListener : public WindowListener_BASE
-+{
-+    ScVbaEventsHelper* pVbaEventsHelper;
-+    uno::Reference< frame::XModel > m_xModel;
-+    sal_Bool m_bPrepare;
-+    sal_Bool m_bWindowResized;
-+    sal_Bool m_bBorderChanged;
-+protected :
-+    uno::Reference< awt::XWindow > GetContainerWindow();
-+    uno::Reference< frame::XFrame > GetFrame();
-+    sal_Bool IsMouseReleased();
-+    DECL_LINK( fireResizeMacro, Timer* );
-+    void processWindowResizeMacro();
-+public :
-+    VbaEventsListener( ScVbaEventsHelper* pHelper );
-+    void startEventsLinstener();
-+    void stopEventsLinstener();
-+    // XWindowListener
-+    virtual void SAL_CALL windowResized( const awt::WindowEvent& aEvent ) throw ( uno::RuntimeException );
-+    virtual void SAL_CALL windowMoved( const awt::WindowEvent& aEvent ) throw ( uno::RuntimeException );
-+    virtual void SAL_CALL windowShown( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
-+    virtual void SAL_CALL windowHidden( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
-+    virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
-+    // XCloseListener
-+    virtual void SAL_CALL queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership ) throw (util::CloseVetoException, uno::RuntimeException);
-+    virtual void SAL_CALL notifyClosing( const lang::EventObject& Source ) throw (uno::RuntimeException);
-+    // XBorderResizeListener
-+    virtual void SAL_CALL borderWidthsChanged( const uno::Reference< uno::XInterface >& aObject, const frame::BorderWidths& aNewSize ) throw (uno::RuntimeException);
-+};
-+VbaEventsListener::VbaEventsListener( ScVbaEventsHelper* pHelper ) : pVbaEventsHelper( pHelper )
-+{
-+    m_xModel.set( pVbaEventsHelper->getDocument()->GetDocumentShell()->GetModel(), uno::UNO_QUERY );
-+    m_bPrepare = sal_False;
-+    m_bWindowResized = sal_False;
-+    m_bBorderChanged = sal_False;
-+}
-+uno::Reference< frame::XFrame > 
-+VbaEventsListener::GetFrame()
-+{
-+    try
-+    {
-+        if( pVbaEventsHelper )
-+        {
-+            if( m_xModel.is() )
-+            {
-+                uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY );
-+                if( xController.is() )
-+                {
-+                    uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_QUERY );
-+                    if( xFrame.is() )
-+                    {
-+                            return xFrame;
-+                    }
-+                }
-+            }
-+        }
-+    }
-+	catch( uno::Exception& /*e*/ )
-+    {
-+    }
-+    return uno::Reference< frame::XFrame >();
-+}
-+uno::Reference< awt::XWindow > 
-+VbaEventsListener::GetContainerWindow() 
-+{
-+    try
-+    {
-+        uno::Reference< frame::XFrame > xFrame( GetFrame(), uno::UNO_QUERY );
-+        if( xFrame.is() )
-+        {
-+            uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_QUERY );
-+            if( xWindow.is() )
-+                return xWindow;
-+        }
-+    }
-+	catch( uno::Exception& /*e*/ )
-+    {
-+    }
-+    return uno::Reference< awt::XWindow >();
-+}
-+sal_Bool
-+VbaEventsListener::IsMouseReleased()
-+{
-+    Window* pWindow = (VCLUnoHelper::GetWindow(  GetContainerWindow() ) );
-+    if( pWindow )
-+    {
-+        Window::PointerState aPointerState = pWindow->GetPointerState();
-+        if( !aPointerState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) )
-+            return sal_True; 
-+    }
-+    return sal_False;
-+}
-+void
-+VbaEventsListener::startEventsLinstener()
-+{
-+    if( m_xModel.is() )
-+    {
-+        // add window listener
-+        uno::Reference< awt::XWindow > xWindow( GetContainerWindow(), uno::UNO_QUERY );
-+        if( xWindow.is() )
-+            xWindow->addWindowListener( this );
-+        // add close listener
-+        //uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( GetFrame(), uno::UNO_QUERY );
-+        uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( m_xModel, uno::UNO_QUERY );
-+        if( xCloseBroadcaster.is() )
-+        {
-+            xCloseBroadcaster->addCloseListener( this );
-+        }
-+        // add Border resize listener
-+        uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY );
-+        if( xController.is() )
-+        {
-+            uno::Reference< frame::XControllerBorder > xControllerBorder( xController, uno::UNO_QUERY );
-+            if( xControllerBorder.is() )
-+            {
-+                xControllerBorder->addBorderResizeListener( this );
-+            }
-+        }
-+    }
-+}
-+void
-+VbaEventsListener::stopEventsLinstener()
-+{
-+    if( m_xModel.is() )
-+    {
-+        uno::Reference< awt::XWindow > xWindow( GetContainerWindow(), uno::UNO_QUERY );
-+        if( xWindow.is() )
-+        {
-+            xWindow->removeWindowListener( this );
-+        }
-+        //uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( GetFrame(), uno::UNO_QUERY );
-+        uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( m_xModel, uno::UNO_QUERY );
-+        if( xCloseBroadcaster.is() )
-+        {
-+            xCloseBroadcaster->removeCloseListener( this );
-+        }
-+        uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY );
-+        if( xController.is() )
-+        {
-+            uno::Reference< frame::XControllerBorder > xControllerBorder( xController, uno::UNO_QUERY );
-+            if( xControllerBorder.is() )
-+            {
-+                xControllerBorder->removeBorderResizeListener( this );
-+            }
-+        }
-+        pVbaEventsHelper = NULL;
-+    }
-+}
-+void
-+VbaEventsListener::processWindowResizeMacro()
-+{
-+    if( pVbaEventsHelper )
-+        pVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_WINDOWRESIZE, uno::Sequence< uno::Any >() );
-+}
-+IMPL_LINK( VbaEventsListener, fireResizeMacro, Timer*, pTimer )
-+{
-+    if( pVbaEventsHelper && m_bPrepare && pTimer )
-+    {
-+        if( IsMouseReleased() )
-+        {
-+            pTimer->Stop();
-+            delete pTimer;
-+            pTimer = 0;
-+            m_bPrepare = sal_False;
-+            processWindowResizeMacro();
-+        }
-+    }
-+    return 0;
-+}
-+void SAL_CALL
-+VbaEventsListener::windowResized(  const awt::WindowEvent& /*aEvent*/ ) throw ( uno::RuntimeException )
-+{
-+    // Workbook_window_resize event
-+    OSL_TRACE("VbaEventsListener::windowResized");
-+    m_bWindowResized = sal_True;
-+    Window* pWindow = (VCLUnoHelper::GetWindow(  GetContainerWindow() ) );
-+    if( pWindow && !m_bPrepare && m_bBorderChanged )
-+    {
-+        m_bPrepare = sal_True;
-+        m_bBorderChanged = m_bWindowResized = sal_False;
-+        AutoTimer* pTimer = new AutoTimer();
-+        pTimer->SetTimeoutHdl( LINK( this, VbaEventsListener, fireResizeMacro ) );
-+        pTimer->Start();
-+    }
-+}
-+void SAL_CALL
-+VbaEventsListener::windowMoved(  const awt::WindowEvent& /*aEvent*/ ) throw ( uno::RuntimeException )
-+{
-+    // not interest this time
-+}
-+void SAL_CALL
-+VbaEventsListener::windowShown(  const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
-+{
-+    // not interest this time
-+}
-+void SAL_CALL
-+VbaEventsListener::windowHidden(  const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
-+{
-+    // not interest this time
-+}
-+void SAL_CALL
-+VbaEventsListener::disposing(  const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
-+{
-+    pVbaEventsHelper = NULL;
-+}
-+void SAL_CALL 
-+VbaEventsListener::queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership ) throw (util::CloseVetoException, uno::RuntimeException)
-+{
-+     // it can cancel the close, but need to throw a CloseVetoException, and it will be transmit to caller.
-+}
-+void SAL_CALL 
-+VbaEventsListener::notifyClosing( const lang::EventObject& Source ) throw (uno::RuntimeException)
-+{
-+    OSL_TRACE("VbaEventsListener::notifyClosing");
-+    stopEventsLinstener();
-+}
-+void SAL_CALL 
-+VbaEventsListener::borderWidthsChanged( const uno::Reference< uno::XInterface >& aObject, const frame::BorderWidths& aNewSize ) throw (uno::RuntimeException)
-+{
-+    // work with WindowResized event to guard Window Resize event.
-+    OSL_TRACE("VbaEventsListener::borderWidthsChanged");
-+    m_bBorderChanged = sal_True;
-+    Window* pWindow = (VCLUnoHelper::GetWindow(  GetContainerWindow() ) );
-+    if( pWindow && !m_bPrepare && m_bWindowResized )
-+    {
-+        m_bPrepare = sal_True;
-+        m_bWindowResized = m_bBorderChanged = sal_False;
-+        AutoTimer* pTimer = new AutoTimer();
-+        pTimer->SetTimeoutHdl( LINK( this, VbaEventsListener, fireResizeMacro ) );
-+        pTimer->Start();
-+    }
-+}
-+
-+class ImplVbaEventNameInfo
-+{
-+private:
-+    map< sal_Int32, rtl::OUString > m_aEventNameMap;
-+
-+protected:
-+    static ImplVbaEventNameInfo* pImplVbaEventNameInfo;
-+    ImplVbaEventNameInfo() { InitImplVbaEventNameInfo(); }
-+private:
-+    void insert( const sal_Int32 nId, const rtl::OUString sEventName )
-+    {
-+        m_aEventNameMap.insert( make_pair( nId, sEventName ) );
-+    }
-+    void InitImplVbaEventNameInfo();
-+public:
-+    virtual ~ImplVbaEventNameInfo();
-+    rtl::OUString getEventName( const sal_Int32 nId )
-+    {
-+        map< sal_Int32, rtl::OUString >::iterator iter = m_aEventNameMap.find( nId );
-+        if( iter != m_aEventNameMap.end() )
-+            return iter->second;
-+        return rtl::OUString();
-+    }
-+    static ImplVbaEventNameInfo* GetImplVbaEventNameInfo();
-+};
-+ImplVbaEventNameInfo* ImplVbaEventNameInfo::pImplVbaEventNameInfo = NULL;
-+
-+ImplVbaEventNameInfo::~ImplVbaEventNameInfo()
-+{
-+    if( pImplVbaEventNameInfo )
-+    {
-+        delete pImplVbaEventNameInfo;
-+        pImplVbaEventNameInfo = NULL;
-+    }
-+}
-+
-+ImplVbaEventNameInfo* 
-+ImplVbaEventNameInfo::GetImplVbaEventNameInfo()
-+{
-+    if( !pImplVbaEventNameInfo )
-+    {
-+        pImplVbaEventNameInfo = new ImplVbaEventNameInfo;
-+    }
-+    return pImplVbaEventNameInfo;
-+}
-+
-+#define CREATEOUSTRING(asciistr) rtl::OUString::createFromAscii(asciistr)
-+
-+#define INSERT_EVENT_INFO( Object, Event, ObjectName, EventName ) \
-+        insert( VBAEVENT_##Object##_##Event, ObjectName + CREATEOUSTRING( EventName ) )
-+
-+#define INSERT_WORKSHEET_EVENT_INFO( Event, EventName ) \
-+        INSERT_EVENT_INFO( WORKSHEET, Event,CREATEOUSTRING("Worksheet_"), EventName ); \
-+        INSERT_EVENT_INFO( WORKBOOK_SHEET, Event, CREATEOUSTRING("Workbook_Sheet"), EventName )
-+
-+#define INSERT_WORKBOOK_EVENT_INFO( Event, EventName ) \
-+        INSERT_EVENT_INFO(  WORKBOOK, Event, CREATEOUSTRING("Workbook_"), EventName )
-+
-+void ImplVbaEventNameInfo::InitImplVbaEventNameInfo()
-+{
-+    INSERT_WORKSHEET_EVENT_INFO( ACTIVATE, "Activate");
-+    INSERT_WORKSHEET_EVENT_INFO( BEFOREDOUBLECLICK, "BeforeDoubleClick" );
-+    INSERT_WORKSHEET_EVENT_INFO( BEFORERIGHTCLICK, "BeforeRightClick" );
-+    INSERT_WORKSHEET_EVENT_INFO( CALCULATE, "Calculate" );
-+    INSERT_WORKSHEET_EVENT_INFO( CHANGE, "Change" );
-+    INSERT_WORKSHEET_EVENT_INFO( DEACTIVATE, "Deactivate" );
-+    INSERT_WORKSHEET_EVENT_INFO( FOLLOWHYPERLINK, "FollowHyperlink" );
-+    INSERT_WORKSHEET_EVENT_INFO( PIVOTTABLEUPDATE, "PivotTableUpdate" );
-+    INSERT_WORKSHEET_EVENT_INFO( SELECTIONCHANGE, "SelectionChange" );
-+
-+    // Workbook
-+    INSERT_WORKBOOK_EVENT_INFO( ACTIVATE, "Activate" );
-+    INSERT_WORKBOOK_EVENT_INFO( DEACTIVATE, "Deactivate" );
-+    INSERT_WORKBOOK_EVENT_INFO( OPEN, "Open" );
-+    // AUTOOPEN doesn't be used. TODO, this should be "auto_open"
-+    INSERT_WORKBOOK_EVENT_INFO( BEFORECLOSE, "BeforeClose" );
-+    INSERT_WORKBOOK_EVENT_INFO( BEFOREPRINT, "BeforePrint" );
-+    INSERT_WORKBOOK_EVENT_INFO( BEFORESAVE, "BeforeSave" );
-+    INSERT_WORKBOOK_EVENT_INFO( NEWSHEET, "NewSheet" );
-+    INSERT_WORKBOOK_EVENT_INFO( WINDOWACTIVATE, "WindowActivate" );
-+    INSERT_WORKBOOK_EVENT_INFO( WINDOWDEACTIVATE, "WindowDeactivate" );
-+    INSERT_WORKBOOK_EVENT_INFO( WINDOWRESIZE, "WindowResize" );
-+}
-+
-+ScVbaEventsHelper::ScVbaEventsHelper( uno::Sequence< css::uno::Any > const& aArgs, uno::Reference< uno::XComponentContext > const& xContext )
-+    : m_xContext( xContext ), mpVbaEventsListener( NULL ), mbOpened( sal_False ), mbIgnoreEvents( sal_False )
-+{
-+    uno::Reference< frame::XModel > xModel ( getXSomethingFromArgs< frame::XModel >( aArgs, 0 ), uno::UNO_QUERY );
-+    ScDocShell* pDocShell = getDocShell( xModel );
-+    pDoc = pDocShell->GetDocument();
-+}
-+
-+ScVbaEventsHelper::~ScVbaEventsHelper()
-+{
-+    if( mpVbaEventsListener )
-+    {
-+        mpVbaEventsListener = NULL;
-+    }
-+}
-+
-+rtl::OUString
-+ScVbaEventsHelper::getEventName( const sal_Int32 nId )
-+{
-+    rtl::OUString sEventName;
-+    ImplVbaEventNameInfo* pEventInfo = ImplVbaEventNameInfo::GetImplVbaEventNameInfo();
-+    if( pEventInfo )
-+        sEventName = pEventInfo->getEventName( nId );
-+    return sEventName;
-+}
-+
-+// Treat the args as possible inouts ( convertion at bottom of method )
-+sal_Bool ScVbaEventsHelper::executeMacro( SfxObjectShell* pShell, const String& sMacroName, uno::Sequence< uno::Any >& aArgs, uno::Any& aRet )
-+{
-+	// until ObjectModules ( and persisting of codenames ) is supported, if this is a
-+	// document saved from XL then we won't be able to determine the codename for the Workbook
-+	// Module, so... we have no choice but to search all modules for the moment, thus the macro
-+	// passed in should be the fully specified name. 	
-+	rtl::OUString sUrl = sUrlPart0.concat( sMacroName ).concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".") ) ).concat( sUrlPart2 ) ;
-+	uno::Sequence< sal_Int16 > aOutArgsIndex;
-+	uno::Sequence< uno::Any > aOutArgs;
-+	ErrCode nErr = pShell->CallXScript( sUrl,  aArgs, aRet,
-+			aOutArgsIndex, aOutArgs, sal_False );
-+
-+	// Script Executed?
-+	if ( nErr != ERRCODE_NONE )
-+		return sal_False;
-+
-+	sal_Int32 nLen = aOutArgs.getLength();
-+	// convert any out params to seem like they were inouts
-+	if ( nLen )
-+	{
-+		for ( sal_Int32 index=0; index < nLen; ++index )
-+		{
-+			sal_Int32 nOutIndex = aOutArgsIndex[ index ];
-+			aArgs[ nOutIndex ] = aOutArgs[ index ];
-+		}
-+
-+	}
-+	return sal_True;
-+}
-+String ScVbaEventsHelper::workbookMacroExists( SfxObjectShell* pShell, const String& sMod, const String& sMacro )
-+{
-+	String sFullName;	
-+	// would use the script provider to see if the macro exists but
-+	// called at this stage tdoc content handler stuff is not set up
-+	// so it fails
-+
-+	BasicManager* pBasicMgr = pShell-> GetBasicManager();
-+	if ( pBasicMgr )
-+	{
-+		StarBASIC* pBasic = pBasicMgr->GetLib( sLibrary );
-+		if ( !pBasic )
-+		{
-+			USHORT nId = pBasicMgr->GetLibId( sLibrary );
-+			pBasicMgr->LoadLib( nId );
-+			pBasic = pBasicMgr->GetLib( sLibrary );
-+		}
-+		if ( pBasic )
-+		{
-+			if ( sMod.Len() ) // we wish to find the macro is a specific module
-+			{
-+				SbModule* pModule = pBasic->FindModule( sMod );
-+				if ( pModule )
-+				{
-+					SbxArray* pMethods = pModule->GetMethods();
-+					if ( pMethods )
-+					{
-+						SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Find( sMacro, SbxCLASS_METHOD ) );
-+						if ( pMethod )
-+						{
-+							sFullName = sMacro;
-+							sFullName.Insert( '.', 0 ).Insert( sMod, 0 ).Insert( '.', 0 ).Insert( sLibrary, 0 );
-+						}
-+					}
-+				}
-+			}
-+			else if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( sMacro, SbxCLASS_METHOD ) ) )
-+			{
-+					if( SbModule* pModule = pMethod->GetModule() )
-+					{
-+						sFullName = sMacro;
-+						sFullName.Insert( '.', 0 ).Insert( pModule->GetName(), 0).Insert( '.', 0 ).Insert( sLibrary, 0 );
-+					}
-+			}		
-+				
-+		}
-+	}
-+	return sFullName;
-+}
-+
-+uno::Any ScVbaEventsHelper::createWorkSheet( SfxObjectShell* pShell, SCTAB nTab )
-+{
-+	uno::Any aRet;
-+	try
-+	{
-+		uno::Reference< lang::XMultiComponentFactory > xSMgr( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
-+		uno::Reference< beans::XPropertySet > xProps( xSMgr, uno::UNO_QUERY_THROW );
-+		uno::Reference<uno::XComponentContext > xCtx( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
-+		// Eventually we will be able to pull the Workbook/Worksheet objects
-+		// directly from basic and register them as listeners
-+
-+		// create Workbook
-+		uno::Sequence< uno::Any > aArgs(2);
-+		aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
-+		aArgs[1] = uno::Any( pShell->GetModel() );
-+		uno::Reference< uno::XInterface > xWorkbook( xSMgr->createInstanceWithArgumentsAndContext(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Workbook") ), aArgs, xCtx ), uno::UNO_QUERY );
-+
-+		// create WorkSheet
-+		String sSheetName;
-+		pDoc->GetName( nTab, sSheetName );
-+		aArgs = uno::Sequence< uno::Any >(3);
-+		aArgs[ 0 ] <<= xWorkbook;
-+		aArgs[ 1 ] <<= pShell->GetModel();
-+		aArgs[ 2 ] = uno::makeAny( rtl::OUString( sSheetName ) );
-+		aRet <<= xSMgr->createInstanceWithArgumentsAndContext(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Worksheet") ), aArgs, xCtx );
-+	}
-+	catch( uno::Exception& e )
-+	{
-+	}
-+	return aRet;
-+}
-+
-+uno::Any ScVbaEventsHelper::createRange( const uno::Any& aRange )
-+{
-+	uno::Any aRet;
-+	try
-+	{
-+		uno::Reference< sheet::XSheetCellRangeContainer > xRanges( 	aRange, uno::UNO_QUERY );
-+		uno::Reference< table::XCellRange > xRange( aRange, uno::UNO_QUERY );
-+		uno::Reference< lang::XMultiComponentFactory > xSMgr( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
-+		uno::Reference< beans::XPropertySet > xProps( xSMgr, uno::UNO_QUERY_THROW );
-+		if (  xRanges.is() || xRange.is() )
-+		{
-+			uno::Reference<uno::XComponentContext > xCtx( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
-+			uno::Sequence< uno::Any > aArgs(2);
-+			aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() ); // dummy parent
-+			if ( xRanges.is() )
-+			{
-+				aArgs[1] <<= xRanges;
-+			}
-+			else if ( xRange.is() )
-+			{
-+				aArgs[1] <<= xRange;
-+			}
-+			else
-+			{
-+				throw uno::RuntimeException(); // 
-+			}
-+			aRet <<= xSMgr->createInstanceWithArgumentsAndContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Range") ), aArgs, xCtx  );	
-+		}
-+	}
-+	catch( uno::Exception& e ) 
-+	{
-+	}
-+	return aRet;
-+}
-+
-+uno::Any ScVbaEventsHelper::createHyperlink( const uno::Any& rCell )
-+{
-+	uno::Any aRet;
-+	try
-+	{
-+		uno::Reference< lang::XMultiComponentFactory > xSMgr( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
-+		uno::Reference< beans::XPropertySet > xProps( xSMgr, uno::UNO_QUERY_THROW ); 
-+		uno::Reference< table::XCell > xCell( rCell, uno::UNO_QUERY );
-+		if( xCell.is() )
-+		{
-+			uno::Reference<uno::XComponentContext > xCtx( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
-+			uno::Sequence< uno::Any > aArgs(2);
-+			aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() ); // dummy parent
-+			aArgs[1] <<= rCell;
-+			
-+			aRet <<= xSMgr->createInstanceWithArgumentsAndContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Hyperlink") ), aArgs, xCtx  );	
-+		}
-+		else
-+		{
-+			throw uno::RuntimeException(); // 
-+		}
-+	}
-+	catch( uno::Exception& e ) 
-+	{
-+	}
-+	return aRet;
-+}
-+
-+uno::Any ScVbaEventsHelper::createWindow( SfxObjectShell* pShell )
-+{
-+    try
-+    {
-+        uno::Reference< lang::XMultiServiceFactory > xSF( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
-+        uno::Reference< frame::XModel > xModel( pShell->GetModel(), uno::UNO_QUERY );
-+        uno::Sequence< uno::Any > aWindowArgs(2);
-+        aWindowArgs[0] = uno::Any( uno::Reference< uno::XInterface > () );
-+        aWindowArgs[1] = uno::Any( xModel );
-+        uno::Reference< uno::XInterface > xWindow( xSF->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Window" ) ), aWindowArgs ), uno::UNO_QUERY );
-+        if( xWindow.is() )
-+            return uno::makeAny( xWindow );
-+    }
-+	catch( uno::Exception& e )
-+	{
-+	}
-+    return uno::Any();
-+}
-+
-+String ScVbaEventsHelper::getSheetModuleName( SCTAB nTab )
-+{
-+	ScExtDocOptions* pExtOptions = pDoc->GetExtDocOptions();
-+	String aCodeName;
-+	pDoc->GetName( nTab, aCodeName);
-+	// Use code name if that exists
-+	if ( pExtOptions )
-+		aCodeName = pExtOptions->GetCodeName( nTab );
-+	return aCodeName;	
-+}
-+
-+rtl::OUString
-+ScVbaEventsHelper::getMacroPath( const sal_Int32 nEventId, const SCTAB nTab )
-+{
-+	SfxObjectShell* pShell = pDoc->GetDocumentShell();
-+    rtl::OUString sMacroPath;
-+    rtl::OUString sMacroName = getEventName( nEventId );
-+    switch( nEventId )
-+    {
-+        // Worksheet
-+    	case VBAEVENT_WORKSHEET_ACTIVATE                      :
-+    	case VBAEVENT_WORKSHEET_BEFOREDOUBLECLICK             :
-+    	case VBAEVENT_WORKSHEET_BEFORERIGHTCLICK              :
-+    	case VBAEVENT_WORKSHEET_CALCULATE                     :
-+    	case VBAEVENT_WORKSHEET_CHANGE                        :
-+    	case VBAEVENT_WORKSHEET_DEACTIVATE                    :
-+    	case VBAEVENT_WORKSHEET_FOLLOWHYPERLINK               :
-+    	case VBAEVENT_WORKSHEET_PIVOTTABLEUPDATE              :
-+    	case VBAEVENT_WORKSHEET_SELECTIONCHANGE               :
-+        {
-+            rtl::OUString  aSheetModuleName = getSheetModuleName( nTab );
-+            sMacroPath = workbookMacroExists( pShell, aSheetModuleName, sMacroName );
-+            break;
-+        }
-+        // Workbook
-+    	case VBAEVENT_WORKBOOK_ACTIVATE                       :
-+    	case VBAEVENT_WORKBOOK_DEACTIVATE                     :
-+    	case VBAEVENT_WORKBOOK_OPEN                           :
-+    	case VBAEVENT_WORKBOOK_AUTOOPEN                       :
-+    	case VBAEVENT_WORKBOOK_BEFORECLOSE                    :
-+    	case VBAEVENT_WORKBOOK_BEFOREPRINT                    :
-+    	case VBAEVENT_WORKBOOK_BEFORESAVE                     :
-+    	case VBAEVENT_WORKBOOK_NEWSHEET                       :
-+    	case VBAEVENT_WORKBOOK_WINDOWACTIVATE                 :
-+    	case VBAEVENT_WORKBOOK_WINDOWDEACTIVATE               :
-+    	case VBAEVENT_WORKBOOK_WINDOWRESIZE                   :
-+        // Workbook_sheet
-+    	case VBAEVENT_WORKBOOK_SHEET_ACTIVATE                 :
-+    	case VBAEVENT_WORKBOOK_SHEET_BEFOREDOUBLECLICK        :
-+    	case VBAEVENT_WORKBOOK_SHEET_BEFORERIGHTCLICK         :
-+    	case VBAEVENT_WORKBOOK_SHEET_CALCULATE                :
-+    	case VBAEVENT_WORKBOOK_SHEET_CHANGE                   :
-+    	case VBAEVENT_WORKBOOK_SHEET_DEACTIVATE               :
-+    	case VBAEVENT_WORKBOOK_SHEET_FOLLOWHYPERLINK          :
-+    	case VBAEVENT_WORKBOOK_SHEET_PIVOTTABLEUPDATE         :
-+    	case VBAEVENT_WORKBOOK_SHEET_SELECTIONCHANGE          :
-+        {
-+	        ScExtDocOptions* pExtOptions = pDoc->GetExtDocOptions();
-+            String sWorkbookModuleName = pDoc->GetCodeName();
-+            if( pExtOptions )
-+            {
-+                ScExtDocSettings aExtDocSettings = pExtOptions->GetDocSettings();
-+                sWorkbookModuleName = aExtDocSettings.maGlobCodeName;
-+            }
-+           
-+            sMacroPath = workbookMacroExists( pShell, sWorkbookModuleName, sMacroName );
-+            break;
-+        }
-+        default:
-+            break;
-+    }
-+    return sMacroPath;
-+}
-+
-+sal_Bool ScVbaEventsHelper::processVbaEvent( const sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs, const SCTAB nTab )
-+{
-+	SfxObjectShell* pShell = pDoc->GetDocumentShell();
-+
-+	sal_Bool result = sal_False;
-+    sal_Bool bCancel = sal_False;
-+	uno::Sequence< uno::Any > aArgs;
-+	uno::Any aRet;
-+    
-+    // For most cases, there is no corresponsible event macro in the document. 
-+    // It is better fo check if the event macro exists before process the arguments to improve performance.
-+    rtl::OUString sMacroPath = getMacroPath( nEventId, nTab );
-+	if( sMacroPath.getLength() )
-+	{
-+		switch( nEventId )
-+		{
-+			case VBAEVENT_WORKSHEET_ACTIVATE:
-+			case VBAEVENT_WORKSHEET_CALCULATE:
-+			case VBAEVENT_WORKSHEET_DEACTIVATE:
-+            case VBAEVENT_WORKBOOK_ACTIVATE:
-+            case VBAEVENT_WORKBOOK_DEACTIVATE:
-+            case VBAEVENT_WORKBOOK_OPEN:
-+			{
-+				// no arguments
-+				break;
-+			}
-+    	    case VBAEVENT_WORKBOOK_SHEET_DEACTIVATE:
-+    	    case VBAEVENT_WORKBOOK_SHEET_CALCULATE:
-+    	    case VBAEVENT_WORKBOOK_SHEET_ACTIVATE:
-+            case VBAEVENT_WORKBOOK_NEWSHEET:
-+            {
-+				aArgs = uno::Sequence< uno::Any >(1);
-+				aArgs[0] = createWorkSheet( pShell, nTab ); 
-+				break;
-+            }
-+			case VBAEVENT_WORKSHEET_CHANGE:
-+			case VBAEVENT_WORKSHEET_SELECTIONCHANGE:
-+			{
-+				// one argument: range
-+				uno::Any aRange = createRange( rArgs[0] );
-+				aArgs = uno::Sequence< uno::Any >(1);
-+				aArgs[0] = aRange;
-+				break;
-+			}
-+    	    case VBAEVENT_WORKBOOK_SHEET_CHANGE:
-+    	    case VBAEVENT_WORKBOOK_SHEET_SELECTIONCHANGE:
-+            {
-+				uno::Any aRange = createRange( rArgs[0] );
-+				aArgs = uno::Sequence< uno::Any >(2);
-+				aArgs[0] = createWorkSheet( pShell, nTab );
-+				aArgs[1] = aRange;
-+				break;
-+            }
-+			case VBAEVENT_WORKSHEET_BEFOREDOUBLECLICK:
-+			case VBAEVENT_WORKSHEET_BEFORERIGHTCLICK:
-+			{
-+				// two aruments: range and cancel
-+				uno::Any aRange = createRange( rArgs[0] );
-+				aArgs = uno::Sequence< uno::Any >(2);
-+				aArgs[0] = aRange;
-+				aArgs[1] <<= bCancel;
-+				// TODO: process "cancel" action  
-+				break;
-+			}
-+    	    case VBAEVENT_WORKBOOK_SHEET_BEFOREDOUBLECLICK:
-+    	    case VBAEVENT_WORKBOOK_SHEET_BEFORERIGHTCLICK:
-+            {
-+				uno::Any aRange = createRange( rArgs[0] );
-+				aArgs = uno::Sequence< uno::Any >(3);
-+				aArgs[0] = createWorkSheet( pShell, nTab );
-+				aArgs[1] = aRange;
-+				aArgs[2] <<= bCancel;
-+				// TODO: process "cancel" action  
-+				break;
-+            }
-+			case VBAEVENT_WORKSHEET_FOLLOWHYPERLINK:
-+			{
-+				// one argument: hyperlink
-+				uno::Any aHyperlink = createHyperlink( rArgs[0] );
-+				aArgs = uno::Sequence< uno::Any >(1);
-+				aArgs[0] = aHyperlink;
-+				break;
-+			}
-+    	    case VBAEVENT_WORKBOOK_SHEET_FOLLOWHYPERLINK:
-+            {
-+				uno::Any aHyperlink = createHyperlink( rArgs[0] );
-+				aArgs = uno::Sequence< uno::Any >(2);
-+				aArgs[0] = createWorkSheet( pShell, nTab );
-+				aArgs[1] = aHyperlink;
-+				break;
-+            }
-+			case VBAEVENT_WORKSHEET_PIVOTTABLEUPDATE:
-+    	    case VBAEVENT_WORKBOOK_SHEET_PIVOTTABLEUPDATE:
-+			{
-+				// one argument: pivottable
-+                // TODO: not support yet
-+				return result;
-+			}
-+            case VBAEVENT_WORKBOOK_BEFORECLOSE:
-+            case VBAEVENT_WORKBOOK_BEFOREPRINT:
-+            {
-+                // process Cancel argument
-+                aArgs = uno::Sequence< uno::Any >(1);
-+                aArgs[0] <<= bCancel;
-+                executeMacro( pShell, sMacroPath, aArgs, aRet );
-+                aArgs[0] >>= bCancel;
-+                return bCancel;
-+            }
-+            case VBAEVENT_WORKBOOK_BEFORESAVE:
-+            {
-+                // two arguments: SaveAs and Cancel
-+                aArgs = uno::Sequence< uno::Any >(2);
-+                aArgs[0] = rArgs[0];
-+                aArgs[1] <<= bCancel;
-+                executeMacro( pShell, sMacroPath, aArgs, aRet );
-+                aArgs[1] >>= bCancel;
-+                return bCancel;
-+            }
-+            case VBAEVENT_WORKBOOK_WINDOWACTIVATE:
-+            case VBAEVENT_WORKBOOK_WINDOWDEACTIVATE:
-+            case VBAEVENT_WORKBOOK_WINDOWRESIZE:
-+            {
-+                // one argument: windows
-+                aArgs = uno::Sequence< uno::Any >(1);
-+                aArgs[0] = createWindow( pShell );
-+                break;
-+            }
-+            default:
-+                return result;
-+		}
-+    
-+        // excute the macro
-+        result = executeMacro( pShell, sMacroPath, aArgs, aRet );
-+	}
-+    
-+	return result;
-+}
-+
-+SCTAB ScVbaEventsHelper::getTabFromArgs( const uno::Sequence< uno::Any > aArgs, const sal_Int32 nPos )
-+{
-+    SCTAB nTab = -1;
-+    uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable( getXSomethingFromArgs< sheet::XCellRangeAddressable >( aArgs, nPos ), uno::UNO_QUERY );
-+    if( xCellRangeAddressable.is() )
-+    {
-+        table::CellRangeAddress aAddress = xCellRangeAddressable->getRangeAddress();
-+        nTab = aAddress.Sheet;
-+    }
-+    return nTab;
-+}
-+
-+sal_Bool SAL_CALL 
-+ScVbaEventsHelper::ProcessCompatibleVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& aArgs ) throw (uno::RuntimeException)
-+{
-+	SfxObjectShell* pShell = pDoc->GetDocumentShell();
-+	if( !pShell )
-+		return sal_False;
-+    
-+    // In order to better support "withevents" in the future, 
-+    // it is better to process a event at a time
-+    SCTAB nTab = INVALID_TAB;
-+    switch( nEventId )
-+    {
-+        // Worksheet
-+		case VBAEVENT_WORKSHEET_ACTIVATE:
-+        {
-+            aArgs[0] >>= nTab;
-+            if( nTab != INVALID_TAB )
-+            {
-+                // process the event
-+                processVbaEvent( nEventId, aArgs, nTab );
-+                // recursive process related workbook sheet event.
-+                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_ACTIVATE, aArgs );
-+            }
-+            break;
-+        }
-+		case VBAEVENT_WORKSHEET_BEFOREDOUBLECLICK:
-+        {
-+            nTab = getTabFromArgs( aArgs );
-+            if( nTab != INVALID_TAB )
-+            {
-+                processVbaEvent( nEventId, aArgs, nTab );
-+                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_BEFOREDOUBLECLICK, aArgs );
-+            }
-+            break;
-+        }
-+		case VBAEVENT_WORKSHEET_BEFORERIGHTCLICK:
-+        {
-+            nTab = getTabFromArgs( aArgs );
-+            if( nTab != INVALID_TAB )
-+            {
-+                processVbaEvent( nEventId, aArgs, nTab );
-+                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_BEFORERIGHTCLICK, aArgs );
-+            }
-+            break;
-+        }
-+		case VBAEVENT_WORKSHEET_CALCULATE:
-+        {
-+            aArgs[0] >>= nTab;
-+            if( nTab != INVALID_TAB )
-+            {
-+                processVbaEvent( nEventId, aArgs, nTab );
-+                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_CALCULATE, aArgs );
-+            }
-+            break;
-+        }
-+		case VBAEVENT_WORKSHEET_CHANGE:
-+        {
-+            nTab = getTabFromArgs( aArgs );
-+            if( nTab != INVALID_TAB )
-+            {
-+                processVbaEvent( nEventId, aArgs, nTab );
-+                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_CHANGE, aArgs );
-+            }
-+            break;
-+        }
-+		case VBAEVENT_WORKSHEET_DEACTIVATE:
-+        {
-+            aArgs[0] >>= nTab;
-+            if( nTab != INVALID_TAB )
-+            {
-+                processVbaEvent( nEventId, aArgs, nTab );
-+                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_DEACTIVATE, aArgs );
-+            }
-+            break;
-+        }
-+		case VBAEVENT_WORKSHEET_FOLLOWHYPERLINK:
-+        {
-+            nTab = getTabFromArgs( aArgs );
-+            if( nTab != INVALID_TAB )
-+            {
-+                processVbaEvent( nEventId, aArgs, nTab );
-+                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_FOLLOWHYPERLINK, aArgs );
-+            }
-+            break;
-+        }
-+		case VBAEVENT_WORKSHEET_PIVOTTABLEUPDATE:
-+            // TODO
-+            break;
-+		case VBAEVENT_WORKSHEET_SELECTIONCHANGE:
-+        {
-+            nTab = getTabFromArgs( aArgs );
-+            if( nTab != INVALID_TAB )
-+            {
-+                processVbaEvent( nEventId, aArgs, nTab );
-+                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_SELECTIONCHANGE, aArgs );
-+            }
-+            break;
-+        }
-+        // Workbook_sheet
-+    	case VBAEVENT_WORKBOOK_SHEET_ACTIVATE:
-+        case VBAEVENT_WORKBOOK_SHEET_CALCULATE:
-+    	case VBAEVENT_WORKBOOK_SHEET_DEACTIVATE:
-+        {
-+            aArgs[0] >>= nTab;
-+            if( nTab != INVALID_TAB )
-+            {
-+                processVbaEvent( nEventId, aArgs, nTab );
-+            }
-+            break;
-+        }
-+    	case VBAEVENT_WORKBOOK_SHEET_BEFOREDOUBLECLICK:
-+        case VBAEVENT_WORKBOOK_SHEET_BEFORERIGHTCLICK:
-+    	case VBAEVENT_WORKBOOK_SHEET_CHANGE:
-+    	case VBAEVENT_WORKBOOK_SHEET_FOLLOWHYPERLINK:
-+    	case VBAEVENT_WORKBOOK_SHEET_SELECTIONCHANGE:
-+        {
-+            nTab = getTabFromArgs( aArgs );
-+            if( nTab != INVALID_TAB )
-+            {
-+                processVbaEvent( nEventId, aArgs, nTab );
-+            }
-+            break;
-+        }
-+    	case VBAEVENT_WORKBOOK_SHEET_PIVOTTABLEUPDATE:
-+        // TODO
-+            break;
-+		// Workbook
-+		case VBAEVENT_WORKBOOK_ACTIVATE:
-+        {
-+            // if workbook open event do not be fired. fired it before 
-+            // workbook activate event to compatible with MSO.
-+            if( mbOpened )
-+            {
-+                // process workbook activate event
-+                processVbaEvent( nEventId, aArgs );
-+                // process workbook window activate event at the same time
-+                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_WINDOWACTIVATE, aArgs );
-+            }
-+            break;
-+        }
-+		case VBAEVENT_WORKBOOK_DEACTIVATE:
-+        {
-+            processVbaEvent( nEventId, aArgs );
-+            // same as workbook window deactivate
-+            ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_WINDOWDEACTIVATE, aArgs );
-+            break;
-+        }
-+		case VBAEVENT_WORKBOOK_OPEN:
-+        {
-+            // process workbook open macro
-+            // does auto open work here?
-+            if( !mbOpened )
-+            {
-+                processVbaEvent( nEventId, aArgs );
-+                mbOpened = sal_True;
-+                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_ACTIVATE, aArgs );
-+            }
-+            // register the window listener.
-+            if( !mpVbaEventsListener )
-+            {
-+                mpVbaEventsListener = new VbaEventsListener( this );
-+                mpVbaEventsListener->startEventsLinstener();
-+            }
-+            break;
-+        }
-+		case VBAEVENT_WORKBOOK_AUTOOPEN:
-+            // TODO
-+            break;
-+		case VBAEVENT_WORKBOOK_BEFORECLOSE:
-+        {
-+            sal_Bool bCancel = processVbaEvent( nEventId, aArgs ); 
-+            if( mpVbaEventsListener && !bCancel )
-+            {
-+                mpVbaEventsListener->stopEventsLinstener();
-+                mpVbaEventsListener = NULL;
-+            }
-+            return bCancel;
-+        }
-+		case VBAEVENT_WORKBOOK_BEFOREPRINT:
-+		case VBAEVENT_WORKBOOK_BEFORESAVE:
-+		case VBAEVENT_WORKBOOK_WINDOWACTIVATE:
-+		case VBAEVENT_WORKBOOK_WINDOWDEACTIVATE:
-+		case VBAEVENT_WORKBOOK_WINDOWRESIZE:
-+        {
-+            return processVbaEvent( nEventId, aArgs );
-+        }
-+		case VBAEVENT_WORKBOOK_NEWSHEET:
-+        {
-+            aArgs[0] >>= nTab;
-+            if( nTab != INVALID_TAB )
-+            {
-+                processVbaEvent( nEventId, aArgs, nTab );
-+            }
-+            break;
-+        }
-+        default:
-+            OSL_TRACE( "Invalid Event" );
-+    }
-+
-+    return sal_True;
-+}
-+
-+::sal_Bool SAL_CALL 
-+ScVbaEventsHelper::getIgnoreEvents() throw (uno::RuntimeException)
-+{
-+    return mbIgnoreEvents;
-+}
-+
-+void SAL_CALL 
-+ScVbaEventsHelper::setIgnoreEvents( ::sal_Bool _ignoreevents ) throw (uno::RuntimeException)
-+{
-+    mbIgnoreEvents = _ignoreevents;
-+}
-+
-+
-+namespace vbaeventshelper
-+{
-+namespace sdecl = comphelper::service_decl;
-+sdecl::class_<ScVbaEventsHelper, sdecl::with_args<true> > serviceImpl;
-+extern sdecl::ServiceDecl const serviceDecl(
-+    serviceImpl,
-+    "ScVbaEventsHelper",
-+    "com.sun.star.document.VbaEventsHelper" );
-+}
-Index: sc/source/ui/vba/vbaeventshelper.hxx
-===================================================================
-RCS file: sc/source/ui/vba/vbaeventshelper.hxx
-diff -N sc/source/ui/vba/vbaeventshelper.hxx
---- /dev/null	1 Jan 1970 00:00:00 -0000
-+++ sc/source/ui/vba/vbaeventshelper.hxx	1 Aug 2008 03:32:45 -0000	1.1.2.1
-@@ -0,0 +1,83 @@
-+/*************************************************************************
-+ *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile$
-+ *
-+ *  $Revision$
-+ *
-+ *  last change: $Author$ $Date$
-+ *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
-+ *
-+ *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
-+ *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
-+ *
-+ *    This library is distributed in the hope that it will be useful,
-+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-+ *    Lesser General Public License for more details.
-+ *
-+ *    You should have received a copy of the GNU Lesser General Public
-+ *    License along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
-+ *
-+ ************************************************************************/
-+
-+#ifndef SC_VBAEVENTS_HXX
-+#define SC_VBAEVENTS_HXX
-+
-+#include "document.hxx"
-+#include <cppuhelper/implbase1.hxx>
-+#include <com/sun/star/document/VbaEventId.hpp>
-+#include <com/sun/star/document/XVbaEventsHelper.hpp>
-+#include "vbahelper.hxx"
-+
-+#define INVALID_TAB -1
-+
-+typedef ::cppu::WeakImplHelper1< com::sun::star::document::XVbaEventsHelper > VBAWorkbookEvent_BASE;
-+
-+class VbaEventsListener;
-+class ScVbaEventsHelper : public VBAWorkbookEvent_BASE
-+{
-+private:
-+	ScDocument* pDoc;
-+    css::uno::Reference< css::uno::XComponentContext > m_xContext;
-+    VbaEventsListener* mpVbaEventsListener;
-+    sal_Bool mbOpened;
-+    sal_Bool mbIgnoreEvents;
-+
-+	String getSheetModuleName( SCTAB nTab );
-+	String workbookMacroExists( SfxObjectShell* pShell, const String& sMod, const String& sMacro );
-+	css::uno::Any createWorkSheet( SfxObjectShell* pShell, SCTAB nTab );
-+	css::uno::Any createRange( const css::uno::Any& aRange );
-+	css::uno::Any createHyperlink( const css::uno::Any& rCell );
-+	css::uno::Any createWindow( SfxObjectShell* pShell );
-+	sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, css::uno::Sequence< css::uno::Any >& aArgs, css::uno::Any& aRet );
-+    SCTAB getTabFromArgs( const css::uno::Sequence< css::uno::Any > aArgs, const sal_Int32 nPos = 0 );
-+    rtl::OUString getEventName( const sal_Int32 nEventId );
-+    rtl::OUString getMacroPath( const sal_Int32 nEventId, const SCTAB nTab = INVALID_TAB );
-+    sal_Bool processVbaEvent( const sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs, const SCTAB nTab = INVALID_TAB );
-+
-+public:
-+	ScVbaEventsHelper( ScDocument* pDocument ):pDoc( pDocument ), mpVbaEventsListener( NULL ), mbOpened( sal_False ){};
-+    ScVbaEventsHelper( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext > const& xContext );
-+    ~ScVbaEventsHelper();
-+	ScDocument* getDocument() { return pDoc; };
-+    // XVBAWorkbookEventHelper
-+    virtual sal_Bool SAL_CALL ProcessCompatibleVbaEvent( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& aArgs ) throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setIgnoreEvents( ::sal_Bool _ignoreevents ) throw (css::uno::RuntimeException);
-+    virtual ::sal_Bool SAL_CALL getIgnoreEvents() throw (css::uno::RuntimeException);
-+};
-+
-+#endif
-+
-Index: sc/source/ui/vba/vbaframe.cxx
-===================================================================
-RCS file: sc/source/ui/vba/vbaframe.cxx
-diff -N sc/source/ui/vba/vbaframe.cxx
+RCS file: sc/source/ui/vba/vbaframe.cxx
+diff -N sc/source/ui/vba/vbaframe.cxx
 --- /dev/null	1 Jan 1970 00:00:00 -0000
 +++ sc/source/ui/vba/vbaframe.cxx	22 Apr 2008 19:53:15 -0000	1.1.2.1
 @@ -0,0 +1,93 @@
@@ -9057,10 +7089,10 @@
 ===================================================================
 RCS file: /cvs/sc/sc/source/ui/vba/vbarange.cxx,v
 retrieving revision 1.9
-retrieving revision 1.5.34.12
-diff -u -p -b -w -B -r1.9 -r1.5.34.12
+retrieving revision 1.5.34.11
+diff -u -p -b -w -B -r1.9 -r1.5.34.11
 --- sc/source/ui/vba/vbarange.cxx	14 May 2008 10:03:31 -0000	1.9
-+++ sc/source/ui/vba/vbarange.cxx	30 Jul 2008 10:39:13 -0000	1.5.34.12
++++ sc/source/ui/vba/vbarange.cxx	29 Jul 2008 09:36:01 -0000	1.5.34.11
 @@ -115,6 +115,7 @@
  #include <org/openoffice/excel/XlCellType.hpp>
  #include <org/openoffice/excel/XlSpecialCellsValue.hpp>
@@ -9210,7 +7242,7 @@
                                                                                                                         
  	RangeHelper thisRange( mxRange );
  	table::CellRangeAddress thisRangeAddress =  thisRange.getCellRangeAddressable()->getRangeAddress();
-@@ -2686,6 +2763,167 @@ ScVbaRange::Replace( const ::rtl::OUStri
+@@ -2686,6 +2763,166 @@ ScVbaRange::Replace( const ::rtl::OUStri
  	return sal_True; // always
  }
  
@@ -9358,8 +7390,7 @@
 +		ScGlobal::SetSearchItem( newOptions );	
 +
 +		uno::Reference< util::XSearchDescriptor > xSearchDescriptor( xDescriptor, uno::UNO_QUERY );
-+		uno::Reference< uno::XInterface > xInterface = xStartCell.is() ? xSearch->findNext( xStartCell, xSearchDescriptor) : xSearch->findFirst( xSearchDescriptor );
-+		uno::Reference< table::XCellRange > xCellRange( xInterface, uno::UNO_QUERY );
++		uno::Reference< table::XCellRange > xCellRange( xSearch->findNext( xStartCell, xSearchDescriptor ), uno::UNO_QUERY );
 +        if ( xCellRange.is() )
 +        {
 +            uno::Reference< excel::XRange > xResultRange = new ScVbaRange( this, mxContext, xCellRange );
@@ -9378,7 +7409,7 @@
  uno::Reference< table::XCellRange > processKey( const uno::Any& Key, uno::Reference<  uno::XComponentContext >& xContext, ScDocShell* pDocSh )
  {
  	uno::Reference< excel::XRange > xKeyRange;
-@@ -3116,6 +3354,18 @@ ScVbaRange::hasElements() throw (uno::Ru
+@@ -3116,6 +3353,18 @@ ScVbaRange::hasElements() throw (uno::Ru
  uno::Reference< container::XEnumeration > SAL_CALL 
  ScVbaRange::createEnumeration() throw (uno::RuntimeException)
  {
@@ -9397,7 +7428,7 @@
  	return new CellsEnumeration( mxContext, m_Areas );
  }
  
-@@ -4119,7 +4369,7 @@ ScVbaRange::Autofit() throw (uno::Runtim
+@@ -4119,7 +4368,7 @@ ScVbaRange::Autofit() throw (uno::Runtim
  		// if the range is a not a row or column range autofit will
  		// throw an error
  
@@ -9406,7 +7437,7 @@
  			DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString()); 			
          ScDocShell* pDocShell = getDocShellFromRange( mxRange );
          if ( pDocShell )
-@@ -4298,6 +4548,113 @@ void ScVbaRange::setFormulaHidden(const 
+@@ -4298,6 +4547,113 @@ void ScVbaRange::setFormulaHidden(const 
  	xProps->setPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLPRO)), uno::makeAny(rCellAttr));
  }
  
@@ -9520,7 +7551,7 @@
  
  void SAL_CALL 
  ScVbaRange::PrintOut( const uno::Any& From, const uno::Any& To, const uno::Any& Copies, const uno::Any& Preview, const uno::Any& ActivePrinter, const uno::Any& PrintToFile, const uno::Any& Collate, const uno::Any& PrToFileName ) throw (uno::RuntimeException)
-@@ -4516,7 +4873,7 @@ ScVbaRange::AutoOutline(  ) throw (scrip
+@@ -4516,7 +4872,7 @@ ScVbaRange::AutoOutline(  ) throw (scrip
  {
  	// #TODO #FIXME needs to check for summary row/col ( whatever they are )
  	// not valid for multi Area Addresses
@@ -9529,7 +7560,7 @@
  		DebugHelper::exception(SbERR_METHOD_FAILED, STR_ERRORMESSAGE_APPLIESTOSINGLERANGEONLY); 			
  	// So needs to either span an entire Row or a just be a single cell 
  	// ( that contains a summary RowColumn )
-@@ -4734,6 +5091,7 @@ ScVbaRange::SpecialCells( const uno::Any
+@@ -4734,6 +5090,7 @@ ScVbaRange::SpecialCells( const uno::Any
  		case excel::XlCellType::xlCellTypeConstants:
  		case excel::XlCellType::xlCellTypeFormulas:
  		case excel::XlCellType::xlCellTypeVisible:
@@ -12283,117 +10314,117 @@
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/AutoFilter.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/AutoFilter.xls
-Binary files /dev/null and /tmp/cvsChaGPg differ
+Binary files /dev/null and /tmp/cvs6sa4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/MiscRangeTests.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/MiscRangeTests.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/MiscRangeTests.xls
-Binary files /dev/null and /tmp/cvsDhaGPg differ
+Binary files /dev/null and /tmp/cvs7sa4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/PageBreaks.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/PageBreaks.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/PageBreaks.xls
-Binary files /dev/null and /tmp/cvsEhaGPg differ
+Binary files /dev/null and /tmp/cvs8sa4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/PageSetup.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/PageSetup.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/PageSetup.xls
-Binary files /dev/null and /tmp/cvsFhaGPg differ
+Binary files /dev/null and /tmp/cvs9sa4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/Ranges-2.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/Ranges-2.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/Ranges-2.xls
-Binary files /dev/null and /tmp/cvsGhaGPg differ
+Binary files /dev/null and /tmp/cvs.sa4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/Ranges-3.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/Ranges-3.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/Ranges-3.xls
-Binary files /dev/null and /tmp/cvsHhaGPg differ
+Binary files /dev/null and /tmp/cvs_sa4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/Ranges.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/Ranges.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/Ranges.xls
-Binary files /dev/null and /tmp/cvsIhaGPg differ
+Binary files /dev/null and /tmp/cvsata4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/Shapes.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/Shapes.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/Shapes.xls
-Binary files /dev/null and /tmp/cvsJhaGPg differ
+Binary files /dev/null and /tmp/cvsbta4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/StrConv-test.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/StrConv-test.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/StrConv-test.xls
-Binary files /dev/null and /tmp/cvsKhaGPg differ
+Binary files /dev/null and /tmp/cvscta4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/Template.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/Template.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/Template.xls
-Binary files /dev/null and /tmp/cvsLhaGPg differ
+Binary files /dev/null and /tmp/cvsdta4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/TestAddress.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/TestAddress.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/TestAddress.xls
-Binary files /dev/null and /tmp/cvsMhaGPg differ
+Binary files /dev/null and /tmp/cvseta4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/TestCalc_Rangetest.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/TestCalc_Rangetest.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/TestCalc_Rangetest.xls
-Binary files /dev/null and /tmp/cvsNhaGPg differ
+Binary files /dev/null and /tmp/cvsfta4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/TestCalc_Rangetest2.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/TestCalc_Rangetest2.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/TestCalc_Rangetest2.xls
-Binary files /dev/null and /tmp/cvsOhaGPg differ
+Binary files /dev/null and /tmp/cvsgta4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/Window.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/Window.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/Window.xls
-Binary files /dev/null and /tmp/cvsPhaGPg differ
+Binary files /dev/null and /tmp/cvshta4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/bytearraystring.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/bytearraystring.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/bytearraystring.xls
-Binary files /dev/null and /tmp/cvsQhaGPg differ
+Binary files /dev/null and /tmp/cvsita4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/dateserial.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/dateserial.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/dateserial.xls
-Binary files /dev/null and /tmp/cvsRhaGPg differ
+Binary files /dev/null and /tmp/cvsjta4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/datevalue.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/datevalue.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/datevalue.xls
-Binary files /dev/null and /tmp/cvsShaGPg differ
+Binary files /dev/null and /tmp/cvskta4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/format.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/format.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/format.xls
-Binary files /dev/null and /tmp/cvsThaGPg differ
+Binary files /dev/null and /tmp/cvslta4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/partition.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/partition.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/partition.xls
-Binary files /dev/null and /tmp/cvsUhaGPg differ
+Binary files /dev/null and /tmp/cvsmta4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/range-4.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/range-4.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/range-4.xls
-Binary files /dev/null and /tmp/cvsVhaGPg differ
+Binary files /dev/null and /tmp/cvsnta4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/replace.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/replace.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/replace.xls
-Binary files /dev/null and /tmp/cvsWhaGPg differ
+Binary files /dev/null and /tmp/cvsota4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/stringplusdouble.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/stringplusdouble.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/stringplusdouble.xls
-Binary files /dev/null and /tmp/cvsXhaGPg differ
+Binary files /dev/null and /tmp/cvspta4KP differ
 Index: sc/source/ui/vba/testvba/TestDocuments/window2.xls
 ===================================================================
 RCS file: sc/source/ui/vba/testvba/TestDocuments/window2.xls
 diff -N sc/source/ui/vba/testvba/TestDocuments/window2.xls
-Binary files /dev/null and /tmp/cvsYhaGPg differ
+Binary files /dev/null and /tmp/cvsqta4KP differ
 cvs diff: Diffing sc/source/ui/vba/testvba/TestDocuments/logs
 cvs diff: Diffing sc/source/ui/vba/testvba/TestDocuments/logs/excel
 Index: sc/source/ui/vba/testvba/TestDocuments/logs/excel/AutoFilter.log
@@ -15153,210 +13184,35 @@
 +  ITEM Assertion OK : PageSetup.PrintHeadings set/get
 +  ITEM Assertion OK : PageSetup.PrintHeadings set/get
 + TEST OK : Test PrintHeadings
-+ TEST START : Test PrintTitleRows
-+  ITEM Assertion OK : PageSetup.PrintTitleRows get
-+  ITEM Assertion OK : PageSetup.PrintTitleRows set range/get
-+  ITEM Assertion OK : PageSetup.PrintTitleRows set false/get
-+ TEST OK : Test PrintTitleRows
-+END  PageSetup
-+Test run finished : 7/21/2008 10:37:32 AM
-Index: sc/source/ui/vba/testvba/TestDocuments/logs/win/replace.log
-===================================================================
-RCS file: sc/source/ui/vba/testvba/TestDocuments/logs/win/replace.log
-diff -N sc/source/ui/vba/testvba/TestDocuments/logs/win/replace.log
---- /dev/null	1 Jan 1970 00:00:00 -0000
-+++ sc/source/ui/vba/testvba/TestDocuments/logs/win/replace.log	29 Jul 2008 07:23:00 -0000	1.1.2.1
-@@ -0,0 +1,14 @@
-+Test run started : 2007-11-21 11:24:04
-+BEGIN Replace
-+ TEST START : Test Replace function
-+  ITEM Assertion OK : common string:aefefdBc
-+  ITEM Assertion OK : expression string:aefefdef
-+  ITEM Assertion OK : binanary compare:aefefdBc
-+  ITEM Assertion OK : text compare:aefefdef
-+  ITEM Assertion OK : text compare:aefefdef
-+  ITEM Assertion OK : start = 3:cefdBc
-+  ITEM Assertion OK : count = 2: aefefdBc
-+  ITEM Assertion OK : start = 1, count = 0, not support in Unix: abcbcdBc
-+ TEST OK : Test Replace function
-+END  Replace
-+Test run finished : 2007-11-21 11:24:04
-cvs diff: Diffing sc/source/ui/view
-Index: sc/source/ui/view/gridwin.cxx
-===================================================================
-RCS file: /cvs/sc/sc/source/ui/view/gridwin.cxx,v
-retrieving revision 1.96
-retrieving revision 1.96.36.1
-diff -u -p -b -w -B -r1.96 -r1.96.36.1
---- sc/source/ui/view/gridwin.cxx	1 Jul 2008 16:27:56 -0000	1.96
-+++ sc/source/ui/view/gridwin.cxx	1 Aug 2008 03:32:45 -0000	1.96.36.1
-@@ -148,7 +148,13 @@
- #include <svx/sdr/overlay/overlaymanager.hxx>
- #include <vcl/svapp.hxx>
- 
-+#include "cellsuno.hxx"
-+
-+#include <com/sun/star/document/XVbaEventsHelper.hpp>
-+#include <com/sun/star/document/VbaEventId.hpp>
-+
- using namespace com::sun::star;
-+using namespace com::sun::star::document::VbaEventId;
- using ::com::sun::star::uno::Sequence;
- using ::com::sun::star::uno::Any;
- 
-@@ -396,6 +402,32 @@ void lcl_UnLockComment( SdrView* pView, 
- 
- }
- 
-+sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTAB nTab, ScBaseCell*& rpCell )
-+{
-+	BOOL bFound = FALSE;
-+	do
-+	{
-+		pDoc->GetCell( rPosX, rPosY, nTab, rpCell );
-+		if ( !rpCell || rpCell->GetCellType() == CELLTYPE_NOTE )
-+		{
-+			if ( rPosX <= 0 )
-+				return FALSE;							// alles leer bis links
-+			else
-+				--rPosX;								// weitersuchen
-+		}
-+                else if ( rpCell->GetCellType() == CELLTYPE_EDIT)
-+                    bFound = TRUE;
-+                else if (rpCell->GetCellType() == CELLTYPE_FORMULA &&
-+                  static_cast<ScFormulaCell*>(rpCell)->IsHyperLinkCell())
-+                    bFound = TRUE;
-+	    else
-+			return FALSE;								// andere Zelle
-+	}
-+	while ( !bFound );
-+
-+	return bFound;
-+}
-+
- //==================================================================
- 
- //	WB_DIALOGCONTROL noetig fuer UNO-Controls
-@@ -1424,6 +1456,7 @@ void ScGridWindow::HandleMouseButtonDown
- 	SCCOL	nOldColFBox	  = bWasFilterBox ? pFilterBox->GetCol() : 0;
- 	SCROW  nOldRowFBox	  = bWasFilterBox ? pFilterBox->GetRow() : 0;
- #endif
-+#include "cellsuno.hxx" 
- 
- 	ClickExtern();	// loescht FilterBox, wenn vorhanden
- 
-@@ -2085,6 +2118,26 @@ void __EXPORT ScGridWindow::MouseButtonU
- 		{
- 			nMouseStatus = SC_GM_NONE;				// keinen Doppelklick anfangen
- 			ScGlobal::OpenURL( aUrl, aTarget );
-+			
-+			// fire worksheet_followhyperlink event
-+			Point aPos = rMEvt.GetPosPixel();
-+	        SCsCOL nPosX;
-+    	    SCsROW nPosY;
-+        	SCTAB nTab = pViewData->GetTabNo();
-+        	pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
-+			ScBaseCell* pCell = NULL;
-+
-+			BOOL bFound = lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell );
-+			if( bFound )
-+			{
-+				ScAddress aCellPos( nPosX, nPosY, nTab );
-+				ScCellObj* pObj = new ScCellObj( pViewData->GetDocShell(), aCellPos );
-+				uno::Sequence< uno::Any > aArgs(1);
-+				aArgs[0] = uno::makeAny(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj)));
-+                uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper ( pViewData->GetDocument()->GetVbaEventsHelper(), uno::UNO_QUERY );
-+                if( xVbaEventsHelper.is() )
-+			        xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_FOLLOWHYPERLINK, aArgs );
-+			}
- 			return;
- 		}
- 	}
-@@ -4768,26 +4821,9 @@ BOOL ScGridWindow::GetEditUrlOrError( BO
- 	ScDocument* pDoc = pDocSh->GetDocument();
- 	ScBaseCell* pCell = NULL;
- 
--	BOOL bFound = FALSE;
--	do
--	{
--		pDoc->GetCell( nPosX, nPosY, nTab, pCell );
--		if ( !pCell || pCell->GetCellType() == CELLTYPE_NOTE )
--		{
--			if ( nPosX <= 0 )
--				return FALSE;							// alles leer bis links
--			else
--				--nPosX;								// weitersuchen
--		}
--                else if ( pCell->GetCellType() == CELLTYPE_EDIT)
--                    bFound = TRUE;
--                else if (pCell->GetCellType() == CELLTYPE_FORMULA &&
--                  static_cast<ScFormulaCell*>(pCell)->IsHyperLinkCell())
--                    bFound = TRUE;
--	    else
--			return FALSE;								// andere Zelle
--	}
--	while ( !bFound );
-+	BOOL bFound = lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell );
-+	if( !bFound )
-+		return FALSE;
- 
- 	ScHideTextCursor aHideCursor( pViewData, eWhich );	// before GetEditArea (MapMode is changed)
- 
-Index: sc/source/ui/view/tabview3.cxx
-===================================================================
-RCS file: /cvs/sc/sc/source/ui/view/tabview3.cxx,v
-retrieving revision 1.68
-retrieving revision 1.68.36.1
-diff -u -p -b -w -B -r1.68 -r1.68.36.1
---- sc/source/ui/view/tabview3.cxx	1 Jul 2008 16:28:34 -0000	1.68
-+++ sc/source/ui/view/tabview3.cxx	1 Aug 2008 03:32:46 -0000	1.68.36.1
-@@ -81,6 +81,10 @@
- #include "client.hxx"
- 
- #include <com/sun/star/chart2/data/HighlightedRange.hpp>
-+#include <com/sun/star/document/XVbaEventsHelper.hpp>
-+#include <com/sun/star/document/VbaEventId.hpp>
-+
-+using namespace com::sun::star::document::VbaEventId;
- 
- namespace
- {
-@@ -1643,6 +1647,17 @@ void ScTabView::SetTabNo( SCTAB nTab, BO
- 										//	nicht InputEnterHandler wegen Referenzeingabe !
- 
- 		ScDocument* pDoc = aViewData.GetDocument();
-+		if( !bNew )
-+		{
-+            uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper ( pDoc->GetVbaEventsHelper(), uno::UNO_QUERY );
-+            if( xVbaEventsHelper.is() )
-+            {
-+                uno::Sequence< uno::Any > aArgs(1);
-+                aArgs[0] <<= aViewData.GetTabNo();
-+			    xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_DEACTIVATE, aArgs );
-+            }
-+		}
-+			
- 		pDoc->MakeTable( nTab );
- 
- 		SCTAB nTabCount = pDoc->GetTableCount();
-@@ -1742,6 +1757,17 @@ void ScTabView::SetTabNo( SCTAB nTab, BO
- 						pGridWin[i]->UpdateEditViewPos();
- 		}
- 
-+		if( !bNew )
-+		{
-+            uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper ( pDoc->GetVbaEventsHelper(), uno::UNO_QUERY );
-+            if( xVbaEventsHelper.is() )
-+            {
-+                uno::Sequence< uno::Any > aArgs(1);
-+                aArgs[0] <<= aViewData.GetTabNo();
-+			    xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_ACTIVATE,  aArgs );
-+            }
-+		}
-+			
- 		TabChanged();										// DrawView
- 		aViewData.GetViewShell()->WindowChanged();			// falls das aktive Fenster anders ist
-         if ( !bUnoRefDialog )
++ TEST START : Test PrintTitleRows
++  ITEM Assertion OK : PageSetup.PrintTitleRows get
++  ITEM Assertion OK : PageSetup.PrintTitleRows set range/get
++  ITEM Assertion OK : PageSetup.PrintTitleRows set false/get
++ TEST OK : Test PrintTitleRows
++END  PageSetup
++Test run finished : 7/21/2008 10:37:32 AM
+Index: sc/source/ui/vba/testvba/TestDocuments/logs/win/replace.log
+===================================================================
+RCS file: sc/source/ui/vba/testvba/TestDocuments/logs/win/replace.log
+diff -N sc/source/ui/vba/testvba/TestDocuments/logs/win/replace.log
+--- /dev/null	1 Jan 1970 00:00:00 -0000
++++ sc/source/ui/vba/testvba/TestDocuments/logs/win/replace.log	29 Jul 2008 07:23:00 -0000	1.1.2.1
+@@ -0,0 +1,14 @@
++Test run started : 2007-11-21 11:24:04
++BEGIN Replace
++ TEST START : Test Replace function
++  ITEM Assertion OK : common string:aefefdBc
++  ITEM Assertion OK : expression string:aefefdef
++  ITEM Assertion OK : binanary compare:aefefdBc
++  ITEM Assertion OK : text compare:aefefdef
++  ITEM Assertion OK : text compare:aefefdef
++  ITEM Assertion OK : start = 3:cefdBc
++  ITEM Assertion OK : count = 2: aefefdBc
++  ITEM Assertion OK : start = 1, count = 0, not support in Unix: abcbcdBc
++ TEST OK : Test Replace function
++END  Replace
++Test run finished : 2007-11-21 11:24:04
+cvs diff: Diffing sc/source/ui/view
 cvs diff: Diffing sc/uiconfig
 cvs diff: Diffing sc/uiconfig/scalc
 cvs diff: Diffing sc/uiconfig/scalc/accelerator
@@ -17253,642 +15109,3 @@
  # ------------------------------------------------------------------
 cvs diff: Diffing oovbaapi/prj
 cvs diff: Diffing oovbaapi/util
-cvs diff: Diffing offapi
-cvs diff: Diffing offapi/com
-cvs diff: Diffing offapi/com/sun
-cvs diff: Diffing offapi/com/sun/star
-cvs diff: Diffing offapi/com/sun/star/accessibility
-cvs diff: Diffing offapi/com/sun/star/animations
-cvs diff: Diffing offapi/com/sun/star/auth
-cvs diff: Diffing offapi/com/sun/star/awt
-cvs diff: Diffing offapi/com/sun/star/awt/tree
-cvs diff: Diffing offapi/com/sun/star/chart
-cvs diff: Diffing offapi/com/sun/star/chart2
-cvs diff: Diffing offapi/com/sun/star/chart2/data
-cvs diff: Diffing offapi/com/sun/star/configuration
-cvs diff: Diffing offapi/com/sun/star/configuration/backend
-cvs diff: Diffing offapi/com/sun/star/configuration/backend/xml
-cvs diff: Diffing offapi/com/sun/star/configuration/bootstrap
-cvs diff: Diffing offapi/com/sun/star/datatransfer
-cvs diff: Diffing offapi/com/sun/star/datatransfer/clipboard
-cvs diff: Diffing offapi/com/sun/star/datatransfer/dnd
-cvs diff: Diffing offapi/com/sun/star/deployment
-cvs diff: Diffing offapi/com/sun/star/deployment/test
-cvs diff: Diffing offapi/com/sun/star/deployment/ui
-cvs diff: Diffing offapi/com/sun/star/document
-Index: offapi/com/sun/star/document/VbaEventId.idl
-===================================================================
-RCS file: offapi/com/sun/star/document/VbaEventId.idl
-diff -N offapi/com/sun/star/document/VbaEventId.idl
---- /dev/null	1 Jan 1970 00:00:00 -0000
-+++ offapi/com/sun/star/document/VbaEventId.idl	1 Aug 2008 03:13:19 -0000	1.1.2.1
-@@ -0,0 +1,82 @@
-+/*************************************************************************
-+ *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile$
-+ *
-+ *  $Revision$
-+ *
-+ *  last change: $Author$ $Date$
-+ *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
-+ *
-+ *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
-+ *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
-+ *
-+ *    This library is distributed in the hope that it will be useful,
-+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-+ *    Lesser General Public License for more details.
-+ *
-+ *    You should have received a copy of the GNU Lesser General Public
-+ *    License along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
-+ *
-+ ************************************************************************/
-+#ifndef __org_openoffice_vba_VbaEventId_idl__
-+#define __org_openoffice_vba_VbaEventId_idl__
-+
-+//=============================================================================
-+
-+module com {  module sun {  module star { module document {
-+//=============================================================================
-+
-+/* VBA compatibility event id */
-+constants VbaEventId
-+{
-+    // Worksheet
-+    const long VBAEVENT_WORKSHEET_ACTIVATE                  	= 1;
-+    const long VBAEVENT_WORKSHEET_BEFOREDOUBLECLICK         	= 2;
-+    const long VBAEVENT_WORKSHEET_BEFORERIGHTCLICK          	= 3;
-+    const long VBAEVENT_WORKSHEET_CALCULATE                 	= 4;
-+    const long VBAEVENT_WORKSHEET_CHANGE                    	= 5;
-+    const long VBAEVENT_WORKSHEET_DEACTIVATE                	= 6;
-+    const long VBAEVENT_WORKSHEET_FOLLOWHYPERLINK           	= 7;
-+    const long VBAEVENT_WORKSHEET_PIVOTTABLEUPDATE          	= 8;
-+    const long VBAEVENT_WORKSHEET_SELECTIONCHANGE           	= 9;
-+    // Workbook
-+    const long VBAEVENT_WORKBOOK_ACTIVATE            			= 20;
-+    const long VBAEVENT_WORKBOOK_DEACTIVATE          			= 21;
-+    const long VBAEVENT_WORKBOOK_OPEN                			= 22;
-+    const long VBAEVENT_WORKBOOK_AUTOOPEN            			= 23;
-+    const long VBAEVENT_WORKBOOK_BEFORECLOSE         			= 24;
-+    const long VBAEVENT_WORKBOOK_BEFOREPRINT         			= 25;
-+    const long VBAEVENT_WORKBOOK_BEFORESAVE          			= 26;
-+    const long VBAEVENT_WORKBOOK_NEWSHEET            			= 27;
-+    const long VBAEVENT_WORKBOOK_WINDOWACTIVATE      			= 28;
-+    const long VBAEVENT_WORKBOOK_WINDOWDEACTIVATE    			= 29;
-+    const long VBAEVENT_WORKBOOK_WINDOWRESIZE        			= 30;
-+    // Workbook_sheet
-+    const long VBAEVENT_WORKBOOK_SHEET_ACTIVATE               	= 51;
-+    const long VBAEVENT_WORKBOOK_SHEET_BEFOREDOUBLECLICK      	= 52;
-+    const long VBAEVENT_WORKBOOK_SHEET_BEFORERIGHTCLICK       	= 53;
-+    const long VBAEVENT_WORKBOOK_SHEET_CALCULATE              	= 54;
-+    const long VBAEVENT_WORKBOOK_SHEET_CHANGE                 	= 55;
-+    const long VBAEVENT_WORKBOOK_SHEET_DEACTIVATE             	= 56;
-+    const long VBAEVENT_WORKBOOK_SHEET_FOLLOWHYPERLINK        	= 57;
-+    const long VBAEVENT_WORKBOOK_SHEET_PIVOTTABLEUPDATE       	= 58;
-+    const long VBAEVENT_WORKBOOK_SHEET_SELECTIONCHANGE        	= 59;
-+};
-+
-+}; }; }; };
-+
-+#endif
-Index: offapi/com/sun/star/document/VbaEventsHelper.idl
-===================================================================
-RCS file: offapi/com/sun/star/document/VbaEventsHelper.idl
-diff -N offapi/com/sun/star/document/VbaEventsHelper.idl
---- /dev/null	1 Jan 1970 00:00:00 -0000
-+++ offapi/com/sun/star/document/VbaEventsHelper.idl	1 Aug 2008 03:13:19 -0000	1.1.2.1
-@@ -0,0 +1,55 @@
-+/*************************************************************************
-+ *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile$
-+ *
-+ *  $Revision$
-+ *
-+ *  last change: $Author$ $Date$
-+ *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
-+ *
-+ *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
-+ *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
-+ *
-+ *    This library is distributed in the hope that it will be useful,
-+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-+ *    Lesser General Public License for more details.
-+ *
-+ *    You should have received a copy of the GNU Lesser General Public
-+ *    License along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
-+ *
-+ ************************************************************************/
-+#ifndef __org_openoffice_vba_VbaEventsHelper_idl__
-+#define __org_openoffice_vba_VbaEventsHelper_idl__
-+
-+#ifndef __com_sun_star_uno_XInterface_idl__
-+#include <com/sun/star/uno/XInterface.idl>
-+#endif
-+#include <com/sun/star/frame/XModel.idl>
-+#include <com/sun/star/document/XVbaEventsHelper.idl>
-+//=============================================================================
-+
-+module com {  module sun {  module star { module document {
-+//=============================================================================
-+
-+service VbaEventsHelper : XVbaEventsHelper
-+{
-+  	createVbaEventsHelper(  [in] ::com::sun::star::frame::XModel xModel );
-+};
-+
-+}; }; }; };
-+
-+#endif
-Index: offapi/com/sun/star/document/XDocumentEventCompatibleHelper.idl
-===================================================================
-RCS file: offapi/com/sun/star/document/XDocumentEventCompatibleHelper.idl
-diff -N offapi/com/sun/star/document/XDocumentEventCompatibleHelper.idl
---- /dev/null	1 Jan 1970 00:00:00 -0000
-+++ offapi/com/sun/star/document/XDocumentEventCompatibleHelper.idl	1 Aug 2008 03:13:19 -0000	1.1.2.1
-@@ -0,0 +1,53 @@
-+/*************************************************************************
-+ *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
-+ *
-+ * OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ * $RCSfile$
-+ * $Revision$
-+ *
-+ * This file is part of OpenOffice.org.
-+ *
-+ * OpenOffice.org is free software: you can redistribute it and/or modify
-+ * it under the terms of the GNU Lesser General Public License version 3
-+ * only, as published by the Free Software Foundation.
-+ *
-+ * OpenOffice.org is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+ * GNU Lesser General Public License version 3 for more details
-+ * (a copy is included in the LICENSE file that accompanied this code).
-+ *
-+ * You should have received a copy of the GNU Lesser General Public License
-+ * version 3 along with OpenOffice.org.  If not, see
-+ * <http://www.openoffice.org/license.html>
-+ * for a copy of the LGPLv3 License.
-+ *
-+ ************************************************************************/
-+#ifndef __com_sun_star_document_XDocumentEventCompatibleHelper_idl__
-+#define __com_sun_star_document_XDocumentEventCompatibleHelper_idl__
-+
-+#ifndef __com_sun_star_uno_XInterface_idl__
-+#include <com/sun/star/uno/XInterface.idl>
-+#endif
-+//=============================================================================
-+
-+module com {   module sun {   module star {   module document {
-+
-+//=============================================================================
-+interface XDocumentEventCompatibleHelper
-+{
-+    /* Execute some compatible VBA event related to document, such as document save, document print.
-+       nEventId: event id.
-+    */
-+    boolean processCompatibleEvent( [in] short nEventId );
-+};
-+
-+//=============================================================================
-+
-+}; }; }; };
-+
-+#endif
-Index: offapi/com/sun/star/document/XVbaEventsHelper.idl
-===================================================================
-RCS file: offapi/com/sun/star/document/XVbaEventsHelper.idl
-diff -N offapi/com/sun/star/document/XVbaEventsHelper.idl
---- /dev/null	1 Jan 1970 00:00:00 -0000
-+++ offapi/com/sun/star/document/XVbaEventsHelper.idl	1 Aug 2008 03:13:19 -0000	1.1.2.1
-@@ -0,0 +1,60 @@
-+/*************************************************************************
-+ *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile$
-+ *
-+ *  $Revision$
-+ *
-+ *  last change: $Author$ $Date$
-+ *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
-+ *
-+ *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
-+ *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
-+ *
-+ *    This library is distributed in the hope that it will be useful,
-+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-+ *    Lesser General Public License for more details.
-+ *
-+ *    You should have received a copy of the GNU Lesser General Public
-+ *    License along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
-+ *
-+ ************************************************************************/
-+#ifndef __org_openoffice_vba_XVbaEventsHelper_idl__
-+#define __org_openoffice_vba_XVbaEventsHelper_idl__
-+
-+#ifndef __com_sun_star_uno_XInterface_idl__
-+#include <com/sun/star/uno/XInterface.idl>
-+#endif
-+//=============================================================================
-+
-+module com {  module sun {  module star {  module document {
-+//=============================================================================
-+
-+interface XVbaEventsHelper
-+{
-+    /**
-+        Execute VBA compatible event.
-+        VbaEvent: Compatible VBA event id.
-+        aArgs: the array of input arguments.
-+        return: True if execute successfully, or False.
-+    **/
-+    boolean ProcessCompatibleVbaEvent( [in] long nEventId, [in] sequence< any > aArgs );
-+    [attribute ] boolean IgnoreEvents;
-+};
-+
-+}; }; }; };
-+
-+#endif
-Index: offapi/com/sun/star/document/makefile.mk
-===================================================================
-RCS file: /cvs/api/offapi/com/sun/star/document/makefile.mk,v
-retrieving revision 1.47
-retrieving revision 1.47.32.1
-diff -u -p -b -w -B -r1.47 -r1.47.32.1
---- offapi/com/sun/star/document/makefile.mk	1 Jul 2008 12:38:47 -0000	1.47
-+++ offapi/com/sun/star/document/makefile.mk	1 Aug 2008 03:13:19 -0000	1.47.32.1
-@@ -108,7 +108,11 @@ IDLFILES=\
-     LinkUpdateModes.idl\
-     XDocumentRevisionListPersistence.idl\
-     DocumentRevisionListPersistence.idl \
--    XDocumentLanguages.idl
-+    XDocumentLanguages.idl	\
-+	XDocumentEventCompatibleHelper.idl \
-+	VbaEventId.idl \
-+	XVbaEventsHelper.idl \
-+	VbaEventsHelper.idl \
- 
- # ------------------------------------------------------------------
- 
-cvs diff: Diffing offapi/com/sun/star/drawing
-cvs diff: Diffing offapi/com/sun/star/drawing/framework
-cvs diff: Diffing offapi/com/sun/star/embed
-cvs diff: Diffing offapi/com/sun/star/form
-cvs diff: Diffing offapi/com/sun/star/form/binding
-cvs diff: Diffing offapi/com/sun/star/form/component
-cvs diff: Diffing offapi/com/sun/star/form/control
-cvs diff: Diffing offapi/com/sun/star/form/inspection
-cvs diff: Diffing offapi/com/sun/star/form/runtime
-cvs diff: Diffing offapi/com/sun/star/form/submission
-cvs diff: Diffing offapi/com/sun/star/form/validation
-cvs diff: Diffing offapi/com/sun/star/formula
-cvs diff: Diffing offapi/com/sun/star/frame
-cvs diff: Diffing offapi/com/sun/star/frame/status
-cvs diff: Diffing offapi/com/sun/star/gallery
-cvs diff: Diffing offapi/com/sun/star/geometry
-cvs diff: Diffing offapi/com/sun/star/graphic
-cvs diff: Diffing offapi/com/sun/star/i18n
-cvs diff: Diffing offapi/com/sun/star/image
-cvs diff: Diffing offapi/com/sun/star/inspection
-cvs diff: Diffing offapi/com/sun/star/installation
-cvs diff: Diffing offapi/com/sun/star/ldap
-cvs diff: Diffing offapi/com/sun/star/linguistic2
-cvs diff: Diffing offapi/com/sun/star/logging
-cvs diff: Diffing offapi/com/sun/star/mail
-cvs diff: Diffing offapi/com/sun/star/media
-cvs diff: Diffing offapi/com/sun/star/mozilla
-cvs diff: Diffing offapi/com/sun/star/packages
-cvs diff: Diffing offapi/com/sun/star/packages/manifest
-cvs diff: Diffing offapi/com/sun/star/packages/zip
-cvs diff: Diffing offapi/com/sun/star/plugin
-cvs diff: Diffing offapi/com/sun/star/presentation
-cvs diff: Diffing offapi/com/sun/star/presentation/textfield
-cvs diff: Diffing offapi/com/sun/star/rdf
-cvs diff: Diffing offapi/com/sun/star/rendering
-cvs diff: Diffing offapi/com/sun/star/report
-cvs diff: Diffing offapi/com/sun/star/report/inspection
-cvs diff: Diffing offapi/com/sun/star/resource
-cvs diff: Diffing offapi/com/sun/star/scanner
-cvs diff: Diffing offapi/com/sun/star/script
-cvs diff: Diffing offapi/com/sun/star/script/browse
-cvs diff: Diffing offapi/com/sun/star/script/provider
-cvs diff: Diffing offapi/com/sun/star/sdb
-cvs diff: Diffing offapi/com/sun/star/sdb/application
-cvs diff: Diffing offapi/com/sun/star/sdb/tools
-cvs diff: Diffing offapi/com/sun/star/sdbc
-cvs diff: Diffing offapi/com/sun/star/sdbcx
-cvs diff: Diffing offapi/com/sun/star/security
-cvs diff: Diffing offapi/com/sun/star/setup
-cvs diff: Diffing offapi/com/sun/star/sheet
-cvs diff: Diffing offapi/com/sun/star/smarttags
-cvs diff: Diffing offapi/com/sun/star/style
-cvs diff: Diffing offapi/com/sun/star/svg
-cvs diff: Diffing offapi/com/sun/star/sync
-cvs diff: Diffing offapi/com/sun/star/sync2
-cvs diff: Diffing offapi/com/sun/star/system
-cvs diff: Diffing offapi/com/sun/star/table
-cvs diff: Diffing offapi/com/sun/star/task
-cvs diff: Diffing offapi/com/sun/star/text
-cvs diff: Diffing offapi/com/sun/star/text/fieldmaster
-cvs diff: Diffing offapi/com/sun/star/text/textfield
-cvs diff: Diffing offapi/com/sun/star/text/textfield/docinfo
-cvs diff: Diffing offapi/com/sun/star/ucb
-cvs diff: Diffing offapi/com/sun/star/ucb/smart
-cvs diff: Diffing offapi/com/sun/star/ui
-cvs diff: Diffing offapi/com/sun/star/ui/dialogs
-cvs diff: Diffing offapi/com/sun/star/util
-cvs diff: Diffing offapi/com/sun/star/view
-cvs diff: Diffing offapi/com/sun/star/xforms
-cvs diff: Diffing offapi/com/sun/star/xml
-cvs diff: Diffing offapi/com/sun/star/xml/crypto
-cvs diff: Diffing offapi/com/sun/star/xml/crypto/sax
-cvs diff: Diffing offapi/com/sun/star/xml/csax
-cvs diff: Diffing offapi/com/sun/star/xml/dom
-cvs diff: Diffing offapi/com/sun/star/xml/dom/events
-cvs diff: Diffing offapi/com/sun/star/xml/dom/views
-cvs diff: Diffing offapi/com/sun/star/xml/input
-cvs diff: Diffing offapi/com/sun/star/xml/sax
-cvs diff: Diffing offapi/com/sun/star/xml/wrapper
-cvs diff: Diffing offapi/com/sun/star/xml/xpath
-cvs diff: Diffing offapi/com/sun/star/xsd
-cvs diff: Diffing offapi/drafts
-cvs diff: Diffing offapi/drafts/com
-cvs diff: Diffing offapi/drafts/com/sun
-cvs diff: Diffing offapi/drafts/com/sun/star
-cvs diff: Diffing offapi/drafts/com/sun/star/form
-cvs diff: Diffing offapi/prj
-cvs diff: Diffing offapi/type_reference
-cvs diff: Diffing offapi/util
-cvs diff: Diffing sfx2
-cvs diff: Diffing sfx2/inc
-cvs diff: Diffing sfx2/inc/pch
-cvs diff: Diffing sfx2/inc/sfx2
-Index: sfx2/inc/sfx2/objsh.hxx
-===================================================================
-RCS file: /cvs/framework/sfx2/inc/sfx2/objsh.hxx,v
-retrieving revision 1.14
-retrieving revision 1.14.96.1
-diff -u -p -b -w -B -r1.14 -r1.14.96.1
---- sfx2/inc/sfx2/objsh.hxx	20 May 2008 18:57:30 -0000	1.14
-+++ sfx2/inc/sfx2/objsh.hxx	1 Aug 2008 03:23:55 -0000	1.14.96.1
-@@ -304,6 +304,7 @@ public:
-     void                        SetNoName();
-     sal_Bool                    IsInModalMode() const;
-     sal_Bool					HasModalViews() const;
-+    sal_Bool                    IsInPrepareClose() const;
-     sal_Bool                    IsHelpDocument() const;
- 
-     sal_Bool                    IsDocShared() const;
-@@ -403,7 +404,8 @@ public:
-         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams,
-         ::com::sun::star::uno::Any& aRet,
-         ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex,
--        ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam
-+        ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam,
-+        bool bRaiseError = true
-     );
- 
-     static ErrCode  CallXScript(
-@@ -412,7 +414,8 @@ public:
-         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams,
-         ::com::sun::star::uno::Any& aRet,
-         ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex,
--        ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam
-+        ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam,
-+        bool bRaiseError = true
-     );
- 
-     /** adjusts the internal macro mode, according to the current security settings
-cvs diff: Diffing sfx2/prj
-cvs diff: Diffing sfx2/qa
-cvs diff: Diffing sfx2/qa/complex
-cvs diff: Diffing sfx2/qa/complex/DocHelper
-cvs diff: Diffing sfx2/qa/complex/docinfo
-cvs diff: Diffing sfx2/qa/complex/standalonedocumentinfo
-cvs diff: Diffing sfx2/qa/complex/testdocuments
-cvs diff: Diffing sfx2/qa/unoapi
-cvs diff: Diffing sfx2/qa/unoapi/testdocuments
-cvs diff: Diffing sfx2/sdi
-cvs diff: Diffing sfx2/source
-cvs diff: Diffing sfx2/source/appl
-cvs diff: Diffing sfx2/source/bastyp
-cvs diff: Diffing sfx2/source/config
-cvs diff: Diffing sfx2/source/control
-cvs diff: Diffing sfx2/source/dialog
-cvs diff: Diffing sfx2/source/doc
-Index: sfx2/source/doc/objmisc.cxx
-===================================================================
-RCS file: /cvs/framework/sfx2/source/doc/objmisc.cxx,v
-retrieving revision 1.102
-retrieving revision 1.102.106.1
-diff -u -p -b -w -B -r1.102 -r1.102.106.1
---- sfx2/source/doc/objmisc.cxx	5 May 2008 16:18:09 -0000	1.102
-+++ sfx2/source/doc/objmisc.cxx	1 Aug 2008 03:23:55 -0000	1.102.106.1
-@@ -1591,7 +1591,7 @@ namespace
- }
- 
- ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptContext, const ::rtl::OUString& _rScriptURL,
--    const Sequence< Any >& aParams, Any& aRet, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam )
-+    const Sequence< Any >& aParams, Any& aRet, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam, bool bRaiseError )
- {
-     OSL_TRACE( "in CallXScript" );
- 	ErrCode nErr = ERRCODE_NONE;
-@@ -1632,7 +1632,7 @@ ErrCode SfxObjectShell::CallXScript( con
-         nErr = ERRCODE_BASIC_INTERNAL_ERROR;
-     }
- 
--	if ( bCaughtException )
-+	if ( bCaughtException && bRaiseError )
- 	{
-         ::std::auto_ptr< VclAbstractDialog > pScriptErrDlg;
- 		SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
-@@ -1656,9 +1656,9 @@ ErrCode SfxObjectShell::CallXScript( con
-         ::com::sun::star::uno::Any& aRet,
-         ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex,
-         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >&
--            aOutParam)
-+            aOutParam, bool bRaiseError )
- {
--    return CallXScript( GetModel(), rScriptURL, aParams, aRet, aOutParamIndex, aOutParam );
-+    return CallXScript( GetModel(), rScriptURL, aParams, aRet, aOutParamIndex, aOutParam, bRaiseError );
- }
- 
- //-------------------------------------------------------------------------
-Index: sfx2/source/doc/objserv.cxx
-===================================================================
-RCS file: /cvs/framework/sfx2/source/doc/objserv.cxx,v
-retrieving revision 1.106
-retrieving revision 1.106.94.1
-diff -u -p -b -w -B -r1.106 -r1.106.94.1
---- sfx2/source/doc/objserv.cxx	20 May 2008 18:59:49 -0000	1.106
-+++ sfx2/source/doc/objserv.cxx	1 Aug 2008 03:23:55 -0000	1.106.94.1
-@@ -109,6 +109,7 @@
- #include <com/sun/star/document/XDocumentInfo.hpp>
- #include <com/sun/star/document/XDocumentInfoSupplier.hpp>
- #include <com/sun/star/document/XDocumentProperties.hpp>
-+#include <com/sun/star/document/XDocumentEventCompatibleHelper.hpp>
- 
- #ifndef _SFX_HELPID_HRC
- #include "helpid.hrc"
-@@ -522,6 +523,18 @@ void SfxObjectShell::ExecFile_Impl(SfxRe
- 		case SID_SAVEASDOC:
- 		case SID_SAVEDOC:
- 		{
-+            if( nId == SID_SAVEDOC || nId == SID_SAVEASDOC )
-+            {
-+                uno::Reference< document::XDocumentEventCompatibleHelper > xVbaEventHelper( GetModel(), uno::UNO_QUERY );
-+                if( xVbaEventHelper.is() )
-+                {
-+                    if( xVbaEventHelper->processCompatibleEvent( nId ) )
-+                    {
-+                        rReq.SetReturnValue( SfxBoolItem( 0, sal_True ) );
-+                        return;
-+                    }
-+                }
-+            }
- 			//!! detaillierte Auswertung eines Fehlercodes
- 			SfxObjectShellRef xLock( this );
- 
-Index: sfx2/source/doc/objxtor.cxx
-===================================================================
-RCS file: /cvs/framework/sfx2/source/doc/objxtor.cxx,v
-retrieving revision 1.84
-retrieving revision 1.84.32.1
-diff -u -p -b -w -B -r1.84 -r1.84.32.1
---- sfx2/source/doc/objxtor.cxx	6 Jun 2008 12:13:32 -0000	1.84
-+++ sfx2/source/doc/objxtor.cxx	1 Aug 2008 03:23:55 -0000	1.84.32.1
-@@ -576,6 +576,13 @@ SfxObjectShell* SfxObjectShell::Current(
- 	return pFrame ? pFrame->GetObjectShell() : 0;
- }
- 
-+//-------------------------------------------------------------------------
-+
-+sal_Bool SfxObjectShell::IsInPrepareClose() const
-+{
-+    return pImp->bInPrepareClose;
-+}
-+
- //------------------------------------------------------------------------
- 
- struct BoolEnv_Impl
-cvs diff: Diffing sfx2/source/explorer
-cvs diff: Diffing sfx2/source/inc
-cvs diff: Diffing sfx2/source/inet
-cvs diff: Diffing sfx2/source/menu
-cvs diff: Diffing sfx2/source/notify
-cvs diff: Diffing sfx2/source/statbar
-cvs diff: Diffing sfx2/source/toolbox
-cvs diff: Diffing sfx2/source/view
-Index: sfx2/source/view/viewprn.cxx
-===================================================================
-RCS file: /cvs/framework/sfx2/source/view/viewprn.cxx,v
-retrieving revision 1.36
-retrieving revision 1.36.124.1
-diff -u -p -b -w -B -r1.36 -r1.36.124.1
---- sfx2/source/view/viewprn.cxx	11 Apr 2008 13:42:19 -0000	1.36
-+++ sfx2/source/view/viewprn.cxx	1 Aug 2008 03:23:56 -0000	1.36.124.1
-@@ -32,6 +32,7 @@
- #include "precompiled_sfx2.hxx"
- 
- #include <com/sun/star/document/XDocumentProperties.hpp>
-+#include <com/sun/star/document/XDocumentEventCompatibleHelper.hpp>
- #include <com/sun/star/view/PrintableState.hpp>
- #include <svtools/itempool.hxx>
- #ifndef _MSGBOX_HXX //autogen
-@@ -67,6 +68,8 @@
- #include "view.hrc"
- #include "helpid.hrc"
- 
-+using namespace com::sun::star;
-+
- TYPEINIT1(SfxPrintingHint, SfxHint);
- 
- // -----------------------------------------------------------------------
-@@ -405,6 +408,22 @@ void SfxViewShell::ExecPrint_Impl( SfxRe
- 		case SID_SETUPPRINTER:
- 	    case SID_PRINTER_NAME :
- 		{
-+            if( nId == SID_PRINTDOC )
-+            {
-+				SfxObjectShell* pDoc = GetObjectShell();
-+                if( pDoc )
-+                {
-+                    uno::Reference< document::XDocumentEventCompatibleHelper > xVbaEventHelper( pDoc->GetModel(), uno::UNO_QUERY );
-+                    if( xVbaEventHelper.is() )
-+                    {
-+                        if( xVbaEventHelper->processCompatibleEvent( nId ) )
-+                        {
-+                            rReq.SetReturnValue(SfxBoolItem(0,FALSE));
-+                            return;
-+                        }
-+                    }
-+                }
-+            }
- 	        // quiet mode (AppEvent, API call)
- 			SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, FALSE);
- 			bSilent = pSilentItem && pSilentItem->GetValue();
-@@ -714,6 +733,15 @@ void SfxViewShell::ExecPrint_Impl( SfxRe
- 	        if ( SID_PRINTDOCDIRECT == nId )
- 	        {
- 				SfxObjectShell* pDoc = GetObjectShell();
-+                uno::Reference< document::XDocumentEventCompatibleHelper > xVbaEventHelper( pDoc->GetModel(), uno::UNO_QUERY );
-+                if( xVbaEventHelper.is() )
-+                {
-+                    if( xVbaEventHelper->processCompatibleEvent( nId ) )
-+                    {
-+                        rReq.SetReturnValue(SfxBoolItem(0,FALSE));
-+                        return;
-+                    }
-+                }
- 				bool bDetectHidden = ( !bSilent && pDoc );
- 				if ( bDetectHidden && pDoc->QueryHiddenInformation( WhenPrinting, NULL ) != RET_YES )
- 					return;
-cvs diff: Diffing sfx2/util
-cvs diff: Diffing sfx2/util/defs
-cvs diff: Diffing sfx2/win
-cvs diff: Diffing sfx2/win/res

Added: trunk/patches/vba/vba-workbook-worksheet-events.diff
==============================================================================
--- (empty file)
+++ trunk/patches/vba/vba-workbook-worksheet-events.diff	Thu Aug  7 07:43:26 2008
@@ -0,0 +1,2563 @@
+--- /dev/null	2008-04-03 19:37:22.000000000 +0800
++++ offapi/com/sun/star/document/VbaEventId.idl	2008-06-16 14:27:47.000000000 +0800
+@@ -0,0 +1,82 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile$
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#ifndef __org_openoffice_vba_VbaEventId_idl__
++#define __org_openoffice_vba_VbaEventId_idl__
++
++//=============================================================================
++
++module com {  module sun {  module star { module document {
++//=============================================================================
++
++/* VBA compatibility event id */
++constants VbaEventId
++{
++    // Worksheet
++    const long VBAEVENT_WORKSHEET_ACTIVATE                  	= 1;
++    const long VBAEVENT_WORKSHEET_BEFOREDOUBLECLICK         	= 2;
++    const long VBAEVENT_WORKSHEET_BEFORERIGHTCLICK          	= 3;
++    const long VBAEVENT_WORKSHEET_CALCULATE                 	= 4;
++    const long VBAEVENT_WORKSHEET_CHANGE                    	= 5;
++    const long VBAEVENT_WORKSHEET_DEACTIVATE                	= 6;
++    const long VBAEVENT_WORKSHEET_FOLLOWHYPERLINK           	= 7;
++    const long VBAEVENT_WORKSHEET_PIVOTTABLEUPDATE          	= 8;
++    const long VBAEVENT_WORKSHEET_SELECTIONCHANGE           	= 9;
++    // Workbook
++    const long VBAEVENT_WORKBOOK_ACTIVATE            			= 20;
++    const long VBAEVENT_WORKBOOK_DEACTIVATE          			= 21;
++    const long VBAEVENT_WORKBOOK_OPEN                			= 22;
++    const long VBAEVENT_WORKBOOK_AUTOOPEN            			= 23;
++    const long VBAEVENT_WORKBOOK_BEFORECLOSE         			= 24;
++    const long VBAEVENT_WORKBOOK_BEFOREPRINT         			= 25;
++    const long VBAEVENT_WORKBOOK_BEFORESAVE          			= 26;
++    const long VBAEVENT_WORKBOOK_NEWSHEET            			= 27;
++    const long VBAEVENT_WORKBOOK_WINDOWACTIVATE      			= 28;
++    const long VBAEVENT_WORKBOOK_WINDOWDEACTIVATE    			= 29;
++    const long VBAEVENT_WORKBOOK_WINDOWRESIZE        			= 30;
++    // Workbook_sheet
++    const long VBAEVENT_WORKBOOK_SHEET_ACTIVATE               	= 51;
++    const long VBAEVENT_WORKBOOK_SHEET_BEFOREDOUBLECLICK      	= 52;
++    const long VBAEVENT_WORKBOOK_SHEET_BEFORERIGHTCLICK       	= 53;
++    const long VBAEVENT_WORKBOOK_SHEET_CALCULATE              	= 54;
++    const long VBAEVENT_WORKBOOK_SHEET_CHANGE                 	= 55;
++    const long VBAEVENT_WORKBOOK_SHEET_DEACTIVATE             	= 56;
++    const long VBAEVENT_WORKBOOK_SHEET_FOLLOWHYPERLINK        	= 57;
++    const long VBAEVENT_WORKBOOK_SHEET_PIVOTTABLEUPDATE       	= 58;
++    const long VBAEVENT_WORKBOOK_SHEET_SELECTIONCHANGE        	= 59;
++};
++
++}; }; }; };
++
++#endif
+
+--- /dev/null	2008-04-03 19:37:22.000000000 +0800
++++ offapi/com/sun/star/document/XVbaEventsHelper.idl	2008-06-12 10:59:31.000000000 +0800
+@@ -0,0 +1,60 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile$
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#ifndef __org_openoffice_vba_XVbaEventsHelper_idl__
++#define __org_openoffice_vba_XVbaEventsHelper_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++//=============================================================================
++
++module com {  module sun {  module star {  module document {
++//=============================================================================
++
++interface XVbaEventsHelper
++{
++    /**
++        Execute VBA compatible event.
++        VbaEvent: Compatible VBA event id.
++        aArgs: the array of input arguments.
++        return: True if execute successfully, or False.
++    **/
++    boolean ProcessCompatibleVbaEvent( [in] long nEventId, [in] sequence< any > aArgs );
++    [attribute ] boolean IgnoreEvents;
++};
++
++}; }; }; };
++
++#endif
+
+--- /dev/null	2008-04-03 19:37:22.000000000 +0800
++++ offapi/com/sun/star/document/VbaEventsHelper.idl	2008-06-05 18:11:39.000000000 +0800
+@@ -0,0 +1,55 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile$
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#ifndef __org_openoffice_vba_VbaEventsHelper_idl__
++#define __org_openoffice_vba_VbaEventsHelper_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++#include <com/sun/star/frame/XModel.idl>
++#include <com/sun/star/document/XVbaEventsHelper.idl>
++//=============================================================================
++
++module com {  module sun {  module star { module document {
++//=============================================================================
++
++service VbaEventsHelper : XVbaEventsHelper
++{
++  	createVbaEventsHelper(  [in] ::com::sun::star::frame::XModel xModel );
++};
++
++}; }; }; };
++
++#endif
+
+--- /dev/null	2008-04-03 19:37:22.000000000 +0800
++++ offapi/com/sun/star/document/XDocumentEventCompatibleHelper.idl	2008-06-09 08:28:28.000000000 +0800
+@@ -0,0 +1,53 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: XVbaEventHelper.idl,v $
++ * $Revision: 1.0 $
++ *
++ * This file is part of OpenOffice.org.
++ *
++ * OpenOffice.org is free software: you can redistribute it and/or modify
++ * it under the terms of the GNU Lesser General Public License version 3
++ * only, as published by the Free Software Foundation.
++ *
++ * OpenOffice.org is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU Lesser General Public License version 3 for more details
++ * (a copy is included in the LICENSE file that accompanied this code).
++ *
++ * You should have received a copy of the GNU Lesser General Public License
++ * version 3 along with OpenOffice.org.  If not, see
++ * <http://www.openoffice.org/license.html>
++ * for a copy of the LGPLv3 License.
++ *
++ ************************************************************************/
++#ifndef __com_sun_star_document_XDocumentEventCompatibleHelper_idl__
++#define __com_sun_star_document_XDocumentEventCompatibleHelper_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++//=============================================================================
++
++module com {   module sun {   module star {   module document {
++
++//=============================================================================
++interface XDocumentEventCompatibleHelper
++{
++    /* Execute some compatible VBA event related to document, such as document save, document print.
++       nEventId: event id.
++    */
++    boolean processCompatibleEvent( [in] short nEventId );
++};
++
++//=============================================================================
++
++}; }; }; };
++
++#endif
+
+--- /home/feng/work/ooo-build/build/dev300-m14/offapi/com/sun/star/document/makefile.mk	2008-06-16 21:30:17.000000000 +0800
++++ offapi/com/sun/star/document/makefile.mk	2008-06-05 18:11:39.000000000 +0800
+@@ -109,6 +109,10 @@ IDLFILES=\
+     DocumentRevisionListPersistence.idl \
+     XDocumentLanguages.idl \
+     XCodeNameQuery.idl \
++    XDocumentEventCompatibleHelper.idl \
++    VbaEventId.idl \
++    XVbaEventsHelper.idl \
++    VbaEventsHelper.idl \
+ 
+ 
+ # ------------------------------------------------------------------
+
+--- /dev/null	2007-09-22 05:50:58.000000000 +0800
++++ sc/source/ui/vba/vbaeventshelper.hxx	2008-07-15 11:55:59.000000000 +0800
+@@ -0,0 +1,83 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: vbaeventshelper.hxx,v $
++ *
++ *  $Revision: 1.0 $
++ *
++ *  last change: $Author: vg $ $Date: 2007/12/07 10:42:26 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++
++#ifndef SC_VBAEVENTS_HXX
++#define SC_VBAEVENTS_HXX
++
++#include "document.hxx"
++#include <cppuhelper/implbase1.hxx>
++#include <com/sun/star/document/VbaEventId.hpp>
++#include <com/sun/star/document/XVbaEventsHelper.hpp>
++#include "vbahelper.hxx"
++
++#define INVALID_TAB -1
++
++typedef ::cppu::WeakImplHelper1< com::sun::star::document::XVbaEventsHelper > VBAWorkbookEvent_BASE;
++
++class VbaEventsListener;
++class ScVbaEventsHelper : public VBAWorkbookEvent_BASE
++{
++private:
++	ScDocument* pDoc;
++    css::uno::Reference< css::uno::XComponentContext > m_xContext;
++    VbaEventsListener* mpVbaEventsListener;
++    sal_Bool mbOpened;
++    sal_Bool mbIgnoreEvents;
++
++	String getSheetModuleName( SCTAB nTab );
++	String workbookMacroExists( SfxObjectShell* pShell, const String& sMod, const String& sMacro );
++	css::uno::Any createWorkSheet( SfxObjectShell* pShell, SCTAB nTab );
++	css::uno::Any createRange( const css::uno::Any& aRange );
++	css::uno::Any createHyperlink( const css::uno::Any& rCell );
++	css::uno::Any createWindow( SfxObjectShell* pShell );
++	sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, css::uno::Sequence< css::uno::Any >& aArgs, css::uno::Any& aRet );
++    SCTAB getTabFromArgs( const css::uno::Sequence< css::uno::Any > aArgs, const sal_Int32 nPos = 0 );
++    rtl::OUString getEventName( const sal_Int32 nEventId );
++    rtl::OUString getMacroPath( const sal_Int32 nEventId, const SCTAB nTab = INVALID_TAB );
++    sal_Bool processVbaEvent( const sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs, const SCTAB nTab = INVALID_TAB );
++
++public:
++	ScVbaEventsHelper( ScDocument* pDocument ):pDoc( pDocument ), mpVbaEventsListener( NULL ), mbOpened( sal_False ){};
++    ScVbaEventsHelper( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext > const& xContext );
++    ~ScVbaEventsHelper();
++	ScDocument* getDocument() { return pDoc; };
++    // XVBAWorkbookEventHelper
++    virtual sal_Bool SAL_CALL ProcessCompatibleVbaEvent( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& aArgs ) throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setIgnoreEvents( ::sal_Bool _ignoreevents ) throw (css::uno::RuntimeException);
++    virtual ::sal_Bool SAL_CALL getIgnoreEvents() throw (css::uno::RuntimeException);
++};
++
++#endif
++
+--- /dev/null	2007-09-22 05:50:58.000000000 +0800
++++ sc/source/ui/vba/vbaeventshelper.cxx	2008-07-15 12:04:50.000000000 +0800
+@@ -0,0 +1,1066 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: vbaeventshelper.cxx,v $
++ *
++ *  $Revision: 1.0 $
++ *
++ *  last change: $Author: vg $ $Date: 2007/12/07 10:42:26 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#include "vbaeventshelper.hxx"
++#include "helperdecl.hxx"
++#include <sfx2/objsh.hxx> 
++#include <basic/basmgr.hxx>
++#include <basic/sbmod.hxx>
++#include <basic/sbmeth.hxx>
++#include <basic/sbx.hxx>
++#include "scextopt.hxx"
++#include <sfx2/evntconf.hxx>
++#include <sfx2/event.hxx>
++#include <sfx2/sfx.hrc>
++#include <toolkit/unohlp.hxx>
++#include <comphelper/processfactory.hxx>
++#include <cppuhelper/implbase1.hxx>
++#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
++#include <com/sun/star/document/XEventsSupplier.hpp>
++#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
++#include <com/sun/star/table/XCell.hpp> 
++#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
++#include <com/sun/star/sheet/XSpreadsheet.hpp>
++#include <com/sun/star/container/XNamed.hpp>
++#include <com/sun/star/awt/XWindowListener.hpp>
++#include <com/sun/star/awt/WindowEvent.hpp>
++#include <com/sun/star/lang/EventObject.hpp>
++#include <com/sun/star/util/XCloseListener.hpp>
++#include <com/sun/star/util/XCloseBroadcaster.hpp>
++#include <com/sun/star/frame/XControllerBorder.hpp>
++#include <com/sun/star/frame/XBorderResizeListener.hpp>
++#include "cellsuno.hxx" 
++
++#include <map>
++
++using namespace std;
++using namespace com::sun::star;
++using namespace org::openoffice;
++using namespace com::sun::star::document::VbaEventId;
++
++const static String sLibrary( RTL_CONSTASCII_USTRINGPARAM("Standard"));
++
++const static rtl::OUString sUrlPart0 = rtl::OUString::createFromAscii( "vnd.sun.star.script:");
++const static rtl::OUString sUrlPart1 = rtl::OUString::createFromAscii( "vnd.sun.star.script:Standard.");
++const static rtl::OUString sUrlPart2 = rtl::OUString::createFromAscii( "?language=Basic&location=document"); 
++
++
++typedef ::cppu::WeakImplHelper3< awt::XWindowListener, util::XCloseListener, frame::XBorderResizeListener > WindowListener_BASE;
++
++// This class is to process Workbook window related event
++class VbaEventsListener : public WindowListener_BASE
++{
++    ScVbaEventsHelper* pVbaEventsHelper;
++    uno::Reference< frame::XModel > m_xModel;
++    sal_Bool m_bPrepare;
++    sal_Bool m_bWindowResized;
++    sal_Bool m_bBorderChanged;
++protected :
++    uno::Reference< awt::XWindow > GetContainerWindow();
++    uno::Reference< frame::XFrame > GetFrame();
++    sal_Bool IsMouseReleased();
++    DECL_LINK( fireResizeMacro, Timer* );
++    void processWindowResizeMacro();
++public :
++    VbaEventsListener( ScVbaEventsHelper* pHelper );
++    void startEventsLinstener();
++    void stopEventsLinstener();
++    // XWindowListener
++    virtual void SAL_CALL windowResized( const awt::WindowEvent& aEvent ) throw ( uno::RuntimeException );
++    virtual void SAL_CALL windowMoved( const awt::WindowEvent& aEvent ) throw ( uno::RuntimeException );
++    virtual void SAL_CALL windowShown( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
++    virtual void SAL_CALL windowHidden( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
++    virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
++    // XCloseListener
++    virtual void SAL_CALL queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership ) throw (util::CloseVetoException, uno::RuntimeException);
++    virtual void SAL_CALL notifyClosing( const lang::EventObject& Source ) throw (uno::RuntimeException);
++    // XBorderResizeListener
++    virtual void SAL_CALL borderWidthsChanged( const uno::Reference< uno::XInterface >& aObject, const frame::BorderWidths& aNewSize ) throw (uno::RuntimeException);
++};
++VbaEventsListener::VbaEventsListener( ScVbaEventsHelper* pHelper ) : pVbaEventsHelper( pHelper )
++{
++    m_xModel.set( pVbaEventsHelper->getDocument()->GetDocumentShell()->GetModel(), uno::UNO_QUERY );
++    m_bPrepare = sal_False;
++    m_bWindowResized = sal_False;
++    m_bBorderChanged = sal_False;
++}
++uno::Reference< frame::XFrame > 
++VbaEventsListener::GetFrame()
++{
++    try
++    {
++        if( pVbaEventsHelper )
++        {
++            if( m_xModel.is() )
++            {
++                uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY );
++                if( xController.is() )
++                {
++                    uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_QUERY );
++                    if( xFrame.is() )
++                    {
++                            return xFrame;
++                    }
++                }
++            }
++        }
++    }
++	catch( uno::Exception& /*e*/ )
++    {
++    }
++    return uno::Reference< frame::XFrame >();
++}
++uno::Reference< awt::XWindow > 
++VbaEventsListener::GetContainerWindow() 
++{
++    try
++    {
++        uno::Reference< frame::XFrame > xFrame( GetFrame(), uno::UNO_QUERY );
++        if( xFrame.is() )
++        {
++            uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_QUERY );
++            if( xWindow.is() )
++                return xWindow;
++        }
++    }
++	catch( uno::Exception& /*e*/ )
++    {
++    }
++    return uno::Reference< awt::XWindow >();
++}
++sal_Bool
++VbaEventsListener::IsMouseReleased()
++{
++    Window* pWindow = (VCLUnoHelper::GetWindow(  GetContainerWindow() ) );
++    if( pWindow )
++    {
++        Window::PointerState aPointerState = pWindow->GetPointerState();
++        if( !aPointerState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) )
++            return sal_True; 
++    }
++    return sal_False;
++}
++void
++VbaEventsListener::startEventsLinstener()
++{
++    if( m_xModel.is() )
++    {
++        // add window listener
++        uno::Reference< awt::XWindow > xWindow( GetContainerWindow(), uno::UNO_QUERY );
++        if( xWindow.is() )
++            xWindow->addWindowListener( this );
++        // add close listener
++        //uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( GetFrame(), uno::UNO_QUERY );
++        uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( m_xModel, uno::UNO_QUERY );
++        if( xCloseBroadcaster.is() )
++        {
++            xCloseBroadcaster->addCloseListener( this );
++        }
++        // add Border resize listener
++        uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY );
++        if( xController.is() )
++        {
++            uno::Reference< frame::XControllerBorder > xControllerBorder( xController, uno::UNO_QUERY );
++            if( xControllerBorder.is() )
++            {
++                xControllerBorder->addBorderResizeListener( this );
++            }
++        }
++    }
++}
++void
++VbaEventsListener::stopEventsLinstener()
++{
++    if( m_xModel.is() )
++    {
++        uno::Reference< awt::XWindow > xWindow( GetContainerWindow(), uno::UNO_QUERY );
++        if( xWindow.is() )
++        {
++            xWindow->removeWindowListener( this );
++        }
++        //uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( GetFrame(), uno::UNO_QUERY );
++        uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( m_xModel, uno::UNO_QUERY );
++        if( xCloseBroadcaster.is() )
++        {
++            xCloseBroadcaster->removeCloseListener( this );
++        }
++        uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY );
++        if( xController.is() )
++        {
++            uno::Reference< frame::XControllerBorder > xControllerBorder( xController, uno::UNO_QUERY );
++            if( xControllerBorder.is() )
++            {
++                xControllerBorder->removeBorderResizeListener( this );
++            }
++        }
++        pVbaEventsHelper = NULL;
++    }
++}
++void
++VbaEventsListener::processWindowResizeMacro()
++{
++    if( pVbaEventsHelper )
++        pVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_WINDOWRESIZE, uno::Sequence< uno::Any >() );
++}
++IMPL_LINK( VbaEventsListener, fireResizeMacro, Timer*, pTimer )
++{
++    if( pVbaEventsHelper && m_bPrepare && pTimer )
++    {
++        if( IsMouseReleased() )
++        {
++            pTimer->Stop();
++            delete pTimer;
++            pTimer = 0;
++            m_bPrepare = sal_False;
++            processWindowResizeMacro();
++        }
++    }
++    return 0;
++}
++void SAL_CALL
++VbaEventsListener::windowResized(  const awt::WindowEvent& /*aEvent*/ ) throw ( uno::RuntimeException )
++{
++    // Workbook_window_resize event
++    OSL_TRACE("VbaEventsListener::windowResized");
++    m_bWindowResized = sal_True;
++    Window* pWindow = (VCLUnoHelper::GetWindow(  GetContainerWindow() ) );
++    if( pWindow && !m_bPrepare && m_bBorderChanged )
++    {
++        m_bPrepare = sal_True;
++        m_bBorderChanged = m_bWindowResized = sal_False;
++        AutoTimer* pTimer = new AutoTimer();
++        pTimer->SetTimeoutHdl( LINK( this, VbaEventsListener, fireResizeMacro ) );
++        pTimer->Start();
++    }
++}
++void SAL_CALL
++VbaEventsListener::windowMoved(  const awt::WindowEvent& /*aEvent*/ ) throw ( uno::RuntimeException )
++{
++    // not interest this time
++}
++void SAL_CALL
++VbaEventsListener::windowShown(  const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
++{
++    // not interest this time
++}
++void SAL_CALL
++VbaEventsListener::windowHidden(  const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
++{
++    // not interest this time
++}
++void SAL_CALL
++VbaEventsListener::disposing(  const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
++{
++    pVbaEventsHelper = NULL;
++}
++void SAL_CALL 
++VbaEventsListener::queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership ) throw (util::CloseVetoException, uno::RuntimeException)
++{
++     // it can cancel the close, but need to throw a CloseVetoException, and it will be transmit to caller.
++}
++void SAL_CALL 
++VbaEventsListener::notifyClosing( const lang::EventObject& Source ) throw (uno::RuntimeException)
++{
++    OSL_TRACE("VbaEventsListener::notifyClosing");
++    stopEventsLinstener();
++}
++void SAL_CALL 
++VbaEventsListener::borderWidthsChanged( const uno::Reference< uno::XInterface >& aObject, const frame::BorderWidths& aNewSize ) throw (uno::RuntimeException)
++{
++    // work with WindowResized event to guard Window Resize event.
++    OSL_TRACE("VbaEventsListener::borderWidthsChanged");
++    m_bBorderChanged = sal_True;
++    Window* pWindow = (VCLUnoHelper::GetWindow(  GetContainerWindow() ) );
++    if( pWindow && !m_bPrepare && m_bWindowResized )
++    {
++        m_bPrepare = sal_True;
++        m_bWindowResized = m_bBorderChanged = sal_False;
++        AutoTimer* pTimer = new AutoTimer();
++        pTimer->SetTimeoutHdl( LINK( this, VbaEventsListener, fireResizeMacro ) );
++        pTimer->Start();
++    }
++}
++
++class ImplVbaEventNameInfo
++{
++private:
++    map< sal_Int32, rtl::OUString > m_aEventNameMap;
++
++protected:
++    static ImplVbaEventNameInfo* pImplVbaEventNameInfo;
++    ImplVbaEventNameInfo() { InitImplVbaEventNameInfo(); }
++private:
++    void insert( const sal_Int32 nId, const rtl::OUString sEventName )
++    {
++        m_aEventNameMap.insert( make_pair( nId, sEventName ) );
++    }
++    void InitImplVbaEventNameInfo();
++public:
++    virtual ~ImplVbaEventNameInfo();
++    rtl::OUString getEventName( const sal_Int32 nId )
++    {
++        map< sal_Int32, rtl::OUString >::iterator iter = m_aEventNameMap.find( nId );
++        if( iter != m_aEventNameMap.end() )
++            return iter->second;
++        return rtl::OUString();
++    }
++    static ImplVbaEventNameInfo* GetImplVbaEventNameInfo();
++};
++ImplVbaEventNameInfo* ImplVbaEventNameInfo::pImplVbaEventNameInfo = NULL;
++
++ImplVbaEventNameInfo::~ImplVbaEventNameInfo()
++{
++    if( pImplVbaEventNameInfo )
++    {
++        delete pImplVbaEventNameInfo;
++        pImplVbaEventNameInfo = NULL;
++    }
++}
++
++ImplVbaEventNameInfo* 
++ImplVbaEventNameInfo::GetImplVbaEventNameInfo()
++{
++    if( !pImplVbaEventNameInfo )
++    {
++        pImplVbaEventNameInfo = new ImplVbaEventNameInfo;
++    }
++    return pImplVbaEventNameInfo;
++}
++
++#define CREATEOUSTRING(asciistr) rtl::OUString::createFromAscii(asciistr)
++
++#define INSERT_EVENT_INFO( Object, Event, ObjectName, EventName ) \
++        insert( VBAEVENT_##Object##_##Event, ObjectName + CREATEOUSTRING( EventName ) )
++
++#define INSERT_WORKSHEET_EVENT_INFO( Event, EventName ) \
++        INSERT_EVENT_INFO( WORKSHEET, Event,CREATEOUSTRING("Worksheet_"), EventName ); \
++        INSERT_EVENT_INFO( WORKBOOK_SHEET, Event, CREATEOUSTRING("Workbook_Sheet"), EventName )
++
++#define INSERT_WORKBOOK_EVENT_INFO( Event, EventName ) \
++        INSERT_EVENT_INFO(  WORKBOOK, Event, CREATEOUSTRING("Workbook_"), EventName )
++
++void ImplVbaEventNameInfo::InitImplVbaEventNameInfo()
++{
++    INSERT_WORKSHEET_EVENT_INFO( ACTIVATE, "Activate");
++    INSERT_WORKSHEET_EVENT_INFO( BEFOREDOUBLECLICK, "BeforeDoubleClick" );
++    INSERT_WORKSHEET_EVENT_INFO( BEFORERIGHTCLICK, "BeforeRightClick" );
++    INSERT_WORKSHEET_EVENT_INFO( CALCULATE, "Calculate" );
++    INSERT_WORKSHEET_EVENT_INFO( CHANGE, "Change" );
++    INSERT_WORKSHEET_EVENT_INFO( DEACTIVATE, "Deactivate" );
++    INSERT_WORKSHEET_EVENT_INFO( FOLLOWHYPERLINK, "FollowHyperlink" );
++    INSERT_WORKSHEET_EVENT_INFO( PIVOTTABLEUPDATE, "PivotTableUpdate" );
++    INSERT_WORKSHEET_EVENT_INFO( SELECTIONCHANGE, "SelectionChange" );
++
++    // Workbook
++    INSERT_WORKBOOK_EVENT_INFO( ACTIVATE, "Activate" );
++    INSERT_WORKBOOK_EVENT_INFO( DEACTIVATE, "Deactivate" );
++    INSERT_WORKBOOK_EVENT_INFO( OPEN, "Open" );
++    // AUTOOPEN doesn't be used. TODO, this should be "auto_open"
++    INSERT_WORKBOOK_EVENT_INFO( BEFORECLOSE, "BeforeClose" );
++    INSERT_WORKBOOK_EVENT_INFO( BEFOREPRINT, "BeforePrint" );
++    INSERT_WORKBOOK_EVENT_INFO( BEFORESAVE, "BeforeSave" );
++    INSERT_WORKBOOK_EVENT_INFO( NEWSHEET, "NewSheet" );
++    INSERT_WORKBOOK_EVENT_INFO( WINDOWACTIVATE, "WindowActivate" );
++    INSERT_WORKBOOK_EVENT_INFO( WINDOWDEACTIVATE, "WindowDeactivate" );
++    INSERT_WORKBOOK_EVENT_INFO( WINDOWRESIZE, "WindowResize" );
++}
++
++ScVbaEventsHelper::ScVbaEventsHelper( uno::Sequence< css::uno::Any > const& aArgs, uno::Reference< uno::XComponentContext > const& xContext )
++    : m_xContext( xContext ), mpVbaEventsListener( NULL ), mbOpened( sal_False ), mbIgnoreEvents( sal_False )
++{
++    uno::Reference< frame::XModel > xModel ( getXSomethingFromArgs< frame::XModel >( aArgs, 0 ), uno::UNO_QUERY );
++    ScDocShell* pDocShell = getDocShell( xModel );
++    pDoc = pDocShell->GetDocument();
++}
++
++ScVbaEventsHelper::~ScVbaEventsHelper()
++{
++    if( mpVbaEventsListener )
++    {
++        mpVbaEventsListener = NULL;
++    }
++}
++
++rtl::OUString
++ScVbaEventsHelper::getEventName( const sal_Int32 nId )
++{
++    rtl::OUString sEventName;
++    ImplVbaEventNameInfo* pEventInfo = ImplVbaEventNameInfo::GetImplVbaEventNameInfo();
++    if( pEventInfo )
++        sEventName = pEventInfo->getEventName( nId );
++    return sEventName;
++}
++
++// Treat the args as possible inouts ( convertion at bottom of method )
++sal_Bool ScVbaEventsHelper::executeMacro( SfxObjectShell* pShell, const String& sMacroName, uno::Sequence< uno::Any >& aArgs, uno::Any& aRet )
++{
++	// until ObjectModules ( and persisting of codenames ) is supported, if this is a
++	// document saved from XL then we won't be able to determine the codename for the Workbook
++	// Module, so... we have no choice but to search all modules for the moment, thus the macro
++	// passed in should be the fully specified name. 	
++	rtl::OUString sUrl = sUrlPart0.concat( sMacroName ).concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".") ) ).concat( sUrlPart2 ) ;
++	uno::Sequence< sal_Int16 > aOutArgsIndex;
++	uno::Sequence< uno::Any > aOutArgs;
++	ErrCode nErr = pShell->CallXScript( sUrl,  aArgs, aRet,
++			aOutArgsIndex, aOutArgs, sal_False );
++
++	// Script Executed?
++	if ( nErr != ERRCODE_NONE )
++		return sal_False;
++
++	sal_Int32 nLen = aOutArgs.getLength();
++	// convert any out params to seem like they were inouts
++	if ( nLen )
++	{
++		for ( sal_Int32 index=0; index < nLen; ++index )
++		{
++			sal_Int32 nOutIndex = aOutArgsIndex[ index ];
++			aArgs[ nOutIndex ] = aOutArgs[ index ];
++		}
++
++	}
++	return sal_True;
++}
++String ScVbaEventsHelper::workbookMacroExists( SfxObjectShell* pShell, const String& sMod, const String& sMacro )
++{
++	String sFullName;	
++	// would use the script provider to see if the macro exists but
++	// called at this stage tdoc content handler stuff is not set up
++	// so it fails
++
++	BasicManager* pBasicMgr = pShell-> GetBasicManager();
++	if ( pBasicMgr )
++	{
++		StarBASIC* pBasic = pBasicMgr->GetLib( sLibrary );
++		if ( !pBasic )
++		{
++			USHORT nId = pBasicMgr->GetLibId( sLibrary );
++			pBasicMgr->LoadLib( nId );
++			pBasic = pBasicMgr->GetLib( sLibrary );
++		}
++		if ( pBasic )
++		{
++			if ( sMod.Len() ) // we wish to find the macro is a specific module
++			{
++				SbModule* pModule = pBasic->FindModule( sMod );
++				if ( pModule )
++				{
++					SbxArray* pMethods = pModule->GetMethods();
++					if ( pMethods )
++					{
++						SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Find( sMacro, SbxCLASS_METHOD ) );
++						if ( pMethod )
++						{
++							sFullName = sMacro;
++							sFullName.Insert( '.', 0 ).Insert( sMod, 0 ).Insert( '.', 0 ).Insert( sLibrary, 0 );
++						}
++					}
++				}
++			}
++			else if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( sMacro, SbxCLASS_METHOD ) ) )
++			{
++					if( SbModule* pModule = pMethod->GetModule() )
++					{
++						sFullName = sMacro;
++						sFullName.Insert( '.', 0 ).Insert( pModule->GetName(), 0).Insert( '.', 0 ).Insert( sLibrary, 0 );
++					}
++			}		
++				
++		}
++	}
++	return sFullName;
++}
++
++uno::Any ScVbaEventsHelper::createWorkSheet( SfxObjectShell* pShell, SCTAB nTab )
++{
++	uno::Any aRet;
++	try
++	{
++		uno::Reference< lang::XMultiComponentFactory > xSMgr( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
++		uno::Reference< beans::XPropertySet > xProps( xSMgr, uno::UNO_QUERY_THROW );
++		uno::Reference<uno::XComponentContext > xCtx( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
++		// Eventually we will be able to pull the Workbook/Worksheet objects
++		// directly from basic and register them as listeners
++
++		// create Workbook
++		uno::Sequence< uno::Any > aArgs(2);
++		aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
++		aArgs[1] = uno::Any( pShell->GetModel() );
++		uno::Reference< uno::XInterface > xWorkbook( xSMgr->createInstanceWithArgumentsAndContext(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Workbook") ), aArgs, xCtx ), uno::UNO_QUERY );
++
++		// create WorkSheet
++		String sSheetName;
++		pDoc->GetName( nTab, sSheetName );
++		aArgs = uno::Sequence< uno::Any >(3);
++		aArgs[ 0 ] <<= xWorkbook;
++		aArgs[ 1 ] <<= pShell->GetModel();
++		aArgs[ 2 ] = uno::makeAny( rtl::OUString( sSheetName ) );
++		aRet <<= xSMgr->createInstanceWithArgumentsAndContext(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Worksheet") ), aArgs, xCtx );
++	}
++	catch( uno::Exception& e )
++	{
++	}
++	return aRet;
++}
++
++uno::Any ScVbaEventsHelper::createRange( const uno::Any& aRange )
++{
++	uno::Any aRet;
++	try
++	{
++		uno::Reference< sheet::XSheetCellRangeContainer > xRanges( 	aRange, uno::UNO_QUERY );
++		uno::Reference< table::XCellRange > xRange( aRange, uno::UNO_QUERY );
++		uno::Reference< lang::XMultiComponentFactory > xSMgr( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
++		uno::Reference< beans::XPropertySet > xProps( xSMgr, uno::UNO_QUERY_THROW );
++		if (  xRanges.is() || xRange.is() )
++		{
++			uno::Reference<uno::XComponentContext > xCtx( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
++			uno::Sequence< uno::Any > aArgs(2);
++			aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() ); // dummy parent
++			if ( xRanges.is() )
++			{
++				aArgs[1] <<= xRanges;
++			}
++			else if ( xRange.is() )
++			{
++				aArgs[1] <<= xRange;
++			}
++			else
++			{
++				throw uno::RuntimeException(); // 
++			}
++			aRet <<= xSMgr->createInstanceWithArgumentsAndContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Range") ), aArgs, xCtx  );	
++		}
++	}
++	catch( uno::Exception& e ) 
++	{
++	}
++	return aRet;
++}
++
++uno::Any ScVbaEventsHelper::createHyperlink( const uno::Any& rCell )
++{
++	uno::Any aRet;
++	try
++	{
++		uno::Reference< lang::XMultiComponentFactory > xSMgr( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
++		uno::Reference< beans::XPropertySet > xProps( xSMgr, uno::UNO_QUERY_THROW ); 
++		uno::Reference< table::XCell > xCell( rCell, uno::UNO_QUERY );
++		if( xCell.is() )
++		{
++			uno::Reference<uno::XComponentContext > xCtx( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
++			uno::Sequence< uno::Any > aArgs(2);
++			aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() ); // dummy parent
++			aArgs[1] <<= rCell;
++			
++			aRet <<= xSMgr->createInstanceWithArgumentsAndContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Hyperlink") ), aArgs, xCtx  );	
++		}
++		else
++		{
++			throw uno::RuntimeException(); // 
++		}
++	}
++	catch( uno::Exception& e ) 
++	{
++	}
++	return aRet;
++}
++
++uno::Any ScVbaEventsHelper::createWindow( SfxObjectShell* pShell )
++{
++    try
++    {
++        uno::Reference< lang::XMultiServiceFactory > xSF( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
++        uno::Reference< frame::XModel > xModel( pShell->GetModel(), uno::UNO_QUERY );
++        uno::Sequence< uno::Any > aWindowArgs(2);
++        aWindowArgs[0] = uno::Any( uno::Reference< uno::XInterface > () );
++        aWindowArgs[1] = uno::Any( xModel );
++        uno::Reference< uno::XInterface > xWindow( xSF->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Window" ) ), aWindowArgs ), uno::UNO_QUERY );
++        if( xWindow.is() )
++            return uno::makeAny( xWindow );
++    }
++	catch( uno::Exception& e )
++	{
++	}
++    return uno::Any();
++}
++
++String ScVbaEventsHelper::getSheetModuleName( SCTAB nTab )
++{
++	ScExtDocOptions* pExtOptions = pDoc->GetExtDocOptions();
++	String aCodeName;
++	pDoc->GetName( nTab, aCodeName);
++	// Use code name if that exists
++	if ( pExtOptions )
++		aCodeName = pExtOptions->GetCodeName( nTab );
++	return aCodeName;	
++}
++
++rtl::OUString
++ScVbaEventsHelper::getMacroPath( const sal_Int32 nEventId, const SCTAB nTab )
++{
++	SfxObjectShell* pShell = pDoc->GetDocumentShell();
++    rtl::OUString sMacroPath;
++    rtl::OUString sMacroName = getEventName( nEventId );
++    switch( nEventId )
++    {
++        // Worksheet
++    	case VBAEVENT_WORKSHEET_ACTIVATE                      :
++    	case VBAEVENT_WORKSHEET_BEFOREDOUBLECLICK             :
++    	case VBAEVENT_WORKSHEET_BEFORERIGHTCLICK              :
++    	case VBAEVENT_WORKSHEET_CALCULATE                     :
++    	case VBAEVENT_WORKSHEET_CHANGE                        :
++    	case VBAEVENT_WORKSHEET_DEACTIVATE                    :
++    	case VBAEVENT_WORKSHEET_FOLLOWHYPERLINK               :
++    	case VBAEVENT_WORKSHEET_PIVOTTABLEUPDATE              :
++    	case VBAEVENT_WORKSHEET_SELECTIONCHANGE               :
++        {
++            rtl::OUString  aSheetModuleName = getSheetModuleName( nTab );
++            sMacroPath = workbookMacroExists( pShell, aSheetModuleName, sMacroName );
++            break;
++        }
++        // Workbook
++    	case VBAEVENT_WORKBOOK_ACTIVATE                       :
++    	case VBAEVENT_WORKBOOK_DEACTIVATE                     :
++    	case VBAEVENT_WORKBOOK_OPEN                           :
++    	case VBAEVENT_WORKBOOK_AUTOOPEN                       :
++    	case VBAEVENT_WORKBOOK_BEFORECLOSE                    :
++    	case VBAEVENT_WORKBOOK_BEFOREPRINT                    :
++    	case VBAEVENT_WORKBOOK_BEFORESAVE                     :
++    	case VBAEVENT_WORKBOOK_NEWSHEET                       :
++    	case VBAEVENT_WORKBOOK_WINDOWACTIVATE                 :
++    	case VBAEVENT_WORKBOOK_WINDOWDEACTIVATE               :
++    	case VBAEVENT_WORKBOOK_WINDOWRESIZE                   :
++        // Workbook_sheet
++    	case VBAEVENT_WORKBOOK_SHEET_ACTIVATE                 :
++    	case VBAEVENT_WORKBOOK_SHEET_BEFOREDOUBLECLICK        :
++    	case VBAEVENT_WORKBOOK_SHEET_BEFORERIGHTCLICK         :
++    	case VBAEVENT_WORKBOOK_SHEET_CALCULATE                :
++    	case VBAEVENT_WORKBOOK_SHEET_CHANGE                   :
++    	case VBAEVENT_WORKBOOK_SHEET_DEACTIVATE               :
++    	case VBAEVENT_WORKBOOK_SHEET_FOLLOWHYPERLINK          :
++    	case VBAEVENT_WORKBOOK_SHEET_PIVOTTABLEUPDATE         :
++    	case VBAEVENT_WORKBOOK_SHEET_SELECTIONCHANGE          :
++        {
++	        ScExtDocOptions* pExtOptions = pDoc->GetExtDocOptions();
++            String sWorkbookModuleName = pDoc->GetCodeName();
++            if( pExtOptions )
++            {
++                ScExtDocSettings aExtDocSettings = pExtOptions->GetDocSettings();
++                sWorkbookModuleName = aExtDocSettings.maGlobCodeName;
++            }
++           
++            sMacroPath = workbookMacroExists( pShell, sWorkbookModuleName, sMacroName );
++            break;
++        }
++        default:
++            break;
++    }
++    return sMacroPath;
++}
++
++sal_Bool ScVbaEventsHelper::processVbaEvent( const sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs, const SCTAB nTab )
++{
++	SfxObjectShell* pShell = pDoc->GetDocumentShell();
++
++	sal_Bool result = sal_False;
++    sal_Bool bCancel = sal_False;
++	uno::Sequence< uno::Any > aArgs;
++	uno::Any aRet;
++    
++    // For most cases, there is no corresponsible event macro in the document. 
++    // It is better fo check if the event macro exists before process the arguments to improve performance.
++    rtl::OUString sMacroPath = getMacroPath( nEventId, nTab );
++	if( sMacroPath.getLength() )
++	{
++		switch( nEventId )
++		{
++			case VBAEVENT_WORKSHEET_ACTIVATE:
++			case VBAEVENT_WORKSHEET_CALCULATE:
++			case VBAEVENT_WORKSHEET_DEACTIVATE:
++            case VBAEVENT_WORKBOOK_ACTIVATE:
++            case VBAEVENT_WORKBOOK_DEACTIVATE:
++            case VBAEVENT_WORKBOOK_OPEN:
++			{
++				// no arguments
++				break;
++			}
++    	    case VBAEVENT_WORKBOOK_SHEET_DEACTIVATE:
++    	    case VBAEVENT_WORKBOOK_SHEET_CALCULATE:
++    	    case VBAEVENT_WORKBOOK_SHEET_ACTIVATE:
++            case VBAEVENT_WORKBOOK_NEWSHEET:
++            {
++				aArgs = uno::Sequence< uno::Any >(1);
++				aArgs[0] = createWorkSheet( pShell, nTab ); 
++				break;
++            }
++			case VBAEVENT_WORKSHEET_CHANGE:
++			case VBAEVENT_WORKSHEET_SELECTIONCHANGE:
++			{
++				// one argument: range
++				uno::Any aRange = createRange( rArgs[0] );
++				aArgs = uno::Sequence< uno::Any >(1);
++				aArgs[0] = aRange;
++				break;
++			}
++    	    case VBAEVENT_WORKBOOK_SHEET_CHANGE:
++    	    case VBAEVENT_WORKBOOK_SHEET_SELECTIONCHANGE:
++            {
++				uno::Any aRange = createRange( rArgs[0] );
++				aArgs = uno::Sequence< uno::Any >(2);
++				aArgs[0] = createWorkSheet( pShell, nTab );
++				aArgs[1] = aRange;
++				break;
++            }
++			case VBAEVENT_WORKSHEET_BEFOREDOUBLECLICK:
++			case VBAEVENT_WORKSHEET_BEFORERIGHTCLICK:
++			{
++				// two aruments: range and cancel
++				uno::Any aRange = createRange( rArgs[0] );
++				aArgs = uno::Sequence< uno::Any >(2);
++				aArgs[0] = aRange;
++				aArgs[1] <<= bCancel;
++				// TODO: process "cancel" action  
++				break;
++			}
++    	    case VBAEVENT_WORKBOOK_SHEET_BEFOREDOUBLECLICK:
++    	    case VBAEVENT_WORKBOOK_SHEET_BEFORERIGHTCLICK:
++            {
++				uno::Any aRange = createRange( rArgs[0] );
++				aArgs = uno::Sequence< uno::Any >(3);
++				aArgs[0] = createWorkSheet( pShell, nTab );
++				aArgs[1] = aRange;
++				aArgs[2] <<= bCancel;
++				// TODO: process "cancel" action  
++				break;
++            }
++			case VBAEVENT_WORKSHEET_FOLLOWHYPERLINK:
++			{
++				// one argument: hyperlink
++				uno::Any aHyperlink = createHyperlink( rArgs[0] );
++				aArgs = uno::Sequence< uno::Any >(1);
++				aArgs[0] = aHyperlink;
++				break;
++			}
++    	    case VBAEVENT_WORKBOOK_SHEET_FOLLOWHYPERLINK:
++            {
++				uno::Any aHyperlink = createHyperlink( rArgs[0] );
++				aArgs = uno::Sequence< uno::Any >(2);
++				aArgs[0] = createWorkSheet( pShell, nTab );
++				aArgs[1] = aHyperlink;
++				break;
++            }
++			case VBAEVENT_WORKSHEET_PIVOTTABLEUPDATE:
++    	    case VBAEVENT_WORKBOOK_SHEET_PIVOTTABLEUPDATE:
++			{
++				// one argument: pivottable
++                // TODO: not support yet
++				return result;
++			}
++            case VBAEVENT_WORKBOOK_BEFORECLOSE:
++            case VBAEVENT_WORKBOOK_BEFOREPRINT:
++            {
++                // process Cancel argument
++                aArgs = uno::Sequence< uno::Any >(1);
++                aArgs[0] <<= bCancel;
++                executeMacro( pShell, sMacroPath, aArgs, aRet );
++                aArgs[0] >>= bCancel;
++                return bCancel;
++            }
++            case VBAEVENT_WORKBOOK_BEFORESAVE:
++            {
++                // two arguments: SaveAs and Cancel
++                aArgs = uno::Sequence< uno::Any >(2);
++                aArgs[0] = rArgs[0];
++                aArgs[1] <<= bCancel;
++                executeMacro( pShell, sMacroPath, aArgs, aRet );
++                aArgs[1] >>= bCancel;
++                return bCancel;
++            }
++            case VBAEVENT_WORKBOOK_WINDOWACTIVATE:
++            case VBAEVENT_WORKBOOK_WINDOWDEACTIVATE:
++            case VBAEVENT_WORKBOOK_WINDOWRESIZE:
++            {
++                // one argument: windows
++                aArgs = uno::Sequence< uno::Any >(1);
++                aArgs[0] = createWindow( pShell );
++                break;
++            }
++            default:
++                return result;
++		}
++    
++        // excute the macro
++        result = executeMacro( pShell, sMacroPath, aArgs, aRet );
++	}
++    
++	return result;
++}
++
++SCTAB ScVbaEventsHelper::getTabFromArgs( const uno::Sequence< uno::Any > aArgs, const sal_Int32 nPos )
++{
++    SCTAB nTab = -1;
++    uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable( getXSomethingFromArgs< sheet::XCellRangeAddressable >( aArgs, nPos ), uno::UNO_QUERY );
++    if( xCellRangeAddressable.is() )
++    {
++        table::CellRangeAddress aAddress = xCellRangeAddressable->getRangeAddress();
++        nTab = aAddress.Sheet;
++    }
++    return nTab;
++}
++
++sal_Bool SAL_CALL 
++ScVbaEventsHelper::ProcessCompatibleVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& aArgs ) throw (uno::RuntimeException)
++{
++	SfxObjectShell* pShell = pDoc->GetDocumentShell();
++	if( !pShell )
++		return sal_False;
++    
++    // In order to better support "withevents" in the future, 
++    // it is better to process a event at a time
++    SCTAB nTab = INVALID_TAB;
++    switch( nEventId )
++    {
++        // Worksheet
++		case VBAEVENT_WORKSHEET_ACTIVATE:
++        {
++            aArgs[0] >>= nTab;
++            if( nTab != INVALID_TAB )
++            {
++                // process the event
++                processVbaEvent( nEventId, aArgs, nTab );
++                // recursive process related workbook sheet event.
++                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_ACTIVATE, aArgs );
++            }
++            break;
++        }
++		case VBAEVENT_WORKSHEET_BEFOREDOUBLECLICK:
++        {
++            nTab = getTabFromArgs( aArgs );
++            if( nTab != INVALID_TAB )
++            {
++                processVbaEvent( nEventId, aArgs, nTab );
++                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_BEFOREDOUBLECLICK, aArgs );
++            }
++            break;
++        }
++		case VBAEVENT_WORKSHEET_BEFORERIGHTCLICK:
++        {
++            nTab = getTabFromArgs( aArgs );
++            if( nTab != INVALID_TAB )
++            {
++                processVbaEvent( nEventId, aArgs, nTab );
++                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_BEFORERIGHTCLICK, aArgs );
++            }
++            break;
++        }
++		case VBAEVENT_WORKSHEET_CALCULATE:
++        {
++            aArgs[0] >>= nTab;
++            if( nTab != INVALID_TAB )
++            {
++                processVbaEvent( nEventId, aArgs, nTab );
++                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_CALCULATE, aArgs );
++            }
++            break;
++        }
++		case VBAEVENT_WORKSHEET_CHANGE:
++        {
++            nTab = getTabFromArgs( aArgs );
++            if( nTab != INVALID_TAB )
++            {
++                processVbaEvent( nEventId, aArgs, nTab );
++                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_CHANGE, aArgs );
++            }
++            break;
++        }
++		case VBAEVENT_WORKSHEET_DEACTIVATE:
++        {
++            aArgs[0] >>= nTab;
++            if( nTab != INVALID_TAB )
++            {
++                processVbaEvent( nEventId, aArgs, nTab );
++                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_DEACTIVATE, aArgs );
++            }
++            break;
++        }
++		case VBAEVENT_WORKSHEET_FOLLOWHYPERLINK:
++        {
++            nTab = getTabFromArgs( aArgs );
++            if( nTab != INVALID_TAB )
++            {
++                processVbaEvent( nEventId, aArgs, nTab );
++                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_FOLLOWHYPERLINK, aArgs );
++            }
++            break;
++        }
++		case VBAEVENT_WORKSHEET_PIVOTTABLEUPDATE:
++            // TODO
++            break;
++		case VBAEVENT_WORKSHEET_SELECTIONCHANGE:
++        {
++            nTab = getTabFromArgs( aArgs );
++            if( nTab != INVALID_TAB )
++            {
++                processVbaEvent( nEventId, aArgs, nTab );
++                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_SHEET_SELECTIONCHANGE, aArgs );
++            }
++            break;
++        }
++        // Workbook_sheet
++    	case VBAEVENT_WORKBOOK_SHEET_ACTIVATE:
++        case VBAEVENT_WORKBOOK_SHEET_CALCULATE:
++    	case VBAEVENT_WORKBOOK_SHEET_DEACTIVATE:
++        {
++            aArgs[0] >>= nTab;
++            if( nTab != INVALID_TAB )
++            {
++                processVbaEvent( nEventId, aArgs, nTab );
++            }
++            break;
++        }
++    	case VBAEVENT_WORKBOOK_SHEET_BEFOREDOUBLECLICK:
++        case VBAEVENT_WORKBOOK_SHEET_BEFORERIGHTCLICK:
++    	case VBAEVENT_WORKBOOK_SHEET_CHANGE:
++    	case VBAEVENT_WORKBOOK_SHEET_FOLLOWHYPERLINK:
++    	case VBAEVENT_WORKBOOK_SHEET_SELECTIONCHANGE:
++        {
++            nTab = getTabFromArgs( aArgs );
++            if( nTab != INVALID_TAB )
++            {
++                processVbaEvent( nEventId, aArgs, nTab );
++            }
++            break;
++        }
++    	case VBAEVENT_WORKBOOK_SHEET_PIVOTTABLEUPDATE:
++        // TODO
++            break;
++		// Workbook
++		case VBAEVENT_WORKBOOK_ACTIVATE:
++        {
++            // if workbook open event do not be fired. fired it before 
++            // workbook activate event to compatible with MSO.
++            if( mbOpened )
++            {
++                // process workbook activate event
++                processVbaEvent( nEventId, aArgs );
++                // process workbook window activate event at the same time
++                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_WINDOWACTIVATE, aArgs );
++            }
++            break;
++        }
++		case VBAEVENT_WORKBOOK_DEACTIVATE:
++        {
++            processVbaEvent( nEventId, aArgs );
++            // same as workbook window deactivate
++            ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_WINDOWDEACTIVATE, aArgs );
++            break;
++        }
++		case VBAEVENT_WORKBOOK_OPEN:
++        {
++            // process workbook open macro
++            // does auto open work here?
++            if( !mbOpened )
++            {
++                processVbaEvent( nEventId, aArgs );
++                mbOpened = sal_True;
++                ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_ACTIVATE, aArgs );
++            }
++            // register the window listener.
++            if( !mpVbaEventsListener )
++            {
++                mpVbaEventsListener = new VbaEventsListener( this );
++                mpVbaEventsListener->startEventsLinstener();
++            }
++            break;
++        }
++		case VBAEVENT_WORKBOOK_AUTOOPEN:
++            // TODO
++            break;
++		case VBAEVENT_WORKBOOK_BEFORECLOSE:
++        {
++            sal_Bool bCancel = processVbaEvent( nEventId, aArgs ); 
++            if( mpVbaEventsListener && !bCancel )
++            {
++                mpVbaEventsListener->stopEventsLinstener();
++                mpVbaEventsListener = NULL;
++            }
++            return bCancel;
++        }
++		case VBAEVENT_WORKBOOK_BEFOREPRINT:
++		case VBAEVENT_WORKBOOK_BEFORESAVE:
++		case VBAEVENT_WORKBOOK_WINDOWACTIVATE:
++		case VBAEVENT_WORKBOOK_WINDOWDEACTIVATE:
++		case VBAEVENT_WORKBOOK_WINDOWRESIZE:
++        {
++            return processVbaEvent( nEventId, aArgs );
++        }
++		case VBAEVENT_WORKBOOK_NEWSHEET:
++        {
++            aArgs[0] >>= nTab;
++            if( nTab != INVALID_TAB )
++            {
++                processVbaEvent( nEventId, aArgs, nTab );
++            }
++            break;
++        }
++        default:
++            OSL_TRACE( "Invalid Event" );
++    }
++
++    return sal_True;
++}
++
++::sal_Bool SAL_CALL 
++ScVbaEventsHelper::getIgnoreEvents() throw (uno::RuntimeException)
++{
++    return mbIgnoreEvents;
++}
++
++void SAL_CALL 
++ScVbaEventsHelper::setIgnoreEvents( ::sal_Bool _ignoreevents ) throw (uno::RuntimeException)
++{
++    mbIgnoreEvents = _ignoreevents;
++}
++
++
++namespace vbaeventshelper
++{
++namespace sdecl = comphelper::service_decl;
++sdecl::class_<ScVbaEventsHelper, sdecl::with_args<true> > serviceImpl;
++extern sdecl::ServiceDecl const serviceDecl(
++    serviceImpl,
++    "ScVbaEventsHelper",
++    "com.sun.star.document.VbaEventsHelper" );
++}
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/inc/document.hxx	2008-06-16 21:30:17.000000000 +0800
++++ sc/inc/document.hxx	2008-06-16 14:34:49.000000000 +0800
+@@ -151,6 +151,9 @@ namespace com { namespace sun { namespac
+     }
+ } } }
+ 
++namespace com { namespace sun { namespace star { namespace document {
++    class XVbaEventsHelper;
++} } } }
+ #include <svtools/zforlist.hxx>
+ /*
+ #ifdef _ZFORLIST_DECLARE_TABLE
+@@ -309,6 +312,8 @@ private:
+ 
+ 	Timer				aTrackTimer;
+ 
++    com::sun::star::uno::Reference< com::sun::star::document::XVbaEventsHelper > mxVbaEventsHelper;
++
+ public:
+     ScTabOpList         aTableOpList;		            // list of ScInterpreterTableOpParams currently in use
+     ScInterpreterTableOpParams  aLastTableOpParams;     // remember last params
+@@ -1722,6 +1727,8 @@ public:
+ 	void GetSortParam( ScSortParam& rParam, SCTAB nTab );
+ 	void SetSortParam( ScSortParam& rParam, SCTAB nTab );
+ 
++    com::sun::star::uno::Reference< com::sun::star::document::XVbaEventsHelper > GetVbaEventsHelper();
++
+     /** Should only be GRAM_PODF or GRAM_ODFF. */
+     void                SetStorageGrammar( ScGrammar::Grammar eGrammar );
+     ScGrammar::Grammar  GetStorageGrammar() const
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/source/core/data/documen2.cxx	2008-06-16 21:30:17.000000000 +0800
++++ sc/source/core/data/documen2.cxx	2008-06-16 14:35:26.000000000 +0800
+@@ -93,6 +93,7 @@
+ #include "listenercalls.hxx"
+ #include "recursionhelper.hxx"
+ #include "lookupcache.hxx"
++#include <com/sun/star/document/XVbaEventsHelper.hpp>
+ 
+ // pImpl because including lookupcache.hxx in document.hxx isn't wanted, and
+ // dtor is convenient.
+@@ -1863,3 +1864,26 @@ void ScDocument::RemoveLookupCache( ScLo
+         EndListeningArea( pCache->getRange(), &rCache);
+     }
+ }
++
++using namespace com::sun::star;
++uno::Reference< document::XVbaEventsHelper > 
++ScDocument::GetVbaEventsHelper()
++{
++	if( !mxVbaEventsHelper.is() )
++	{
++        try
++        {
++            uno::Reference< lang::XMultiServiceFactory > xSF( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
++            uno::Reference< frame::XModel > xModel( pShell ? pShell->GetModel() : NULL, uno::UNO_QUERY );
++            uno::Sequence< uno::Any > aArgs(1);
++            aArgs[0] = uno::Any( xModel );
++            uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper( xSF->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.VbaEventsHelper" ) ), aArgs ), uno::UNO_QUERY );
++            // helper will always be created successfully.
++            mxVbaEventsHelper.set( xVbaEventsHelper, uno::UNO_QUERY );
++        }
++        catch( uno::Exception& e )
++        {
++        }
++	}
++	return mxVbaEventsHelper;
++}
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/source/core/data/documen7.cxx	2008-06-16 21:30:17.000000000 +0800
++++ sc/source/core/data/documen7.cxx	2008-06-05 18:11:39.000000000 +0800
+@@ -59,7 +59,15 @@
+ 
+ 
+ #include "globstr.hrc"
++#include <algorithm>
++#include <vector>
+ 
++
++#include <com/sun/star/document/XVbaEventsHelper.hpp>
++#include <com/sun/star/document/VbaEventId.hpp>
++
++using namespace com::sun::star;
++using namespace com::sun::star::document::VbaEventId;
+ extern const ScFormulaCell* pLastFormulaTreeTop;	// cellform.cxx Err527 WorkAround
+ 
+ // STATIC DATA -----------------------------------------------------------
+@@ -449,6 +457,7 @@ void ScDocument::TrackFormulas( ULONG nH
+ 		ScFormulaCell* pTrack;
+ 		ScFormulaCell* pNext;
+ 		pTrack = pFormulaTrack;
++		::std::vector<SCTAB> aTabs; 
+ 		do
+ 		{
+ 			ScHint aHint( nHintId, pTrack->aPos, pTrack );
+@@ -458,6 +467,12 @@ void ScDocument::TrackFormulas( ULONG nH
+ 			//	Repaint fuer bedingte Formate mit relativen Referenzen:
+ 			if ( pCondFormList )
+ 				pCondFormList->SourceChanged( pTrack->aPos );
++			::std::vector<SCTAB>::iterator result;
++			result = ::std::find( aTabs.begin(), aTabs.end(), pTrack->aPos.Tab() );
++			if( result == aTabs.end() )
++			{
++				aTabs.push_back( pTrack->aPos.Tab() );
++			}
+ 			pTrack = pTrack->GetNextTrack();
+ 		} while ( pTrack );
+ 		pTrack = pFormulaTrack;
+@@ -480,6 +495,18 @@ void ScDocument::TrackFormulas( ULONG nH
+ 			else
+ 				SetForcedFormulaPending( TRUE );
+ 		}
++
++		::std::vector<SCTAB>::iterator iter;
++		for( iter = aTabs.begin(); iter != aTabs.end(); iter++ )
++		{
++            uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper ( GetVbaEventsHelper(), uno::UNO_QUERY );
++            if( xVbaEventsHelper.is() )
++            {
++			    uno::Sequence< uno::Any > aArgs(1);
++                aArgs[0] <<= *iter;
++			    xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_CALCULATE, aArgs );
++            }
++		}
+ 	}
+ 	DBG_ASSERT( nFormulaTrackCount==0, "TrackFormulas: nFormulaTrackCount!=0" );
+ }
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/source/ui/docshell/docsh.cxx	2008-06-16 21:30:17.000000000 +0800
++++ sc/source/ui/docshell/docsh.cxx	2008-06-16 17:15:54.000000000 +0800
+@@ -126,6 +126,13 @@
+ #include <rtl/logfile.hxx>
+ 
+ #include <comphelper/processfactory.hxx>
++#include "uiitems.hxx"
++#include "cellsuno.hxx"
++#include <com/sun/star/document/XVbaEventsHelper.hpp>
++#include <com/sun/star/document/VbaEventId.hpp>
++
++using namespace com::sun::star;
++using namespace com::sun::star::document::VbaEventId;
+ 
+ using namespace com::sun::star;
+ 
+@@ -516,7 +517,11 @@ sal_uInt16 ScDocShell::GetHiddenInformat
+ void ScDocShell::BeforeXMLLoading()
+ {
+     aDocument.DisableIdle( TRUE );
+-
++    // suppress VBA events when loading the xml
++    uno::Reference< document::XVbaEventsHelper > xEvt( aDocument.GetVbaEventsHelper() );
++    if ( xEvt.is() )
++       xEvt->setIgnoreEvents( sal_True );
++    
+     // prevent unnecessary broadcasts and updates
+     DBG_ASSERT(pModificator == NULL, "The Modificator should not exist");
+ 	pModificator = new ScDocShellModificator( *this );
+@@ -601,6 +605,10 @@ void ScDocShell::AfterXMLLoading(sal_Boo
+     else
+ 		aDocument.SetInsertingFromOtherDoc( FALSE );
+ 
++        // suppress VBA events when loading the xml
++        uno::Reference< document::XVbaEventsHelper > xEvt( aDocument.GetVbaEventsHelper() );
++        if ( xEvt.is() )
++            xEvt->setIgnoreEvents( sal_False );
+ 	aDocument.SetImportingXML( FALSE );
+     aDocument.EnableUndo( TRUE );
+     bIsEmpty = FALSE;
+@@ -714,9 +721,71 @@ BOOL __EXPORT ScDocShell::Load( SfxMediu
+ 	return bRet;
+ }
+ 
++void lcl_processCompatibleSfxHint( uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper, const SfxHint& rHint )
++{
++    if (rHint.ISA(ScTablesHint) )
++    {
++		USHORT nId = ((ScTablesHint&)rHint).GetId();	
++		SCTAB nTab = ((ScTablesHint&)rHint).GetTab1();	
++        if( nId == SC_TAB_INSERTED )
++        {
++            uno::Sequence< uno::Any > aArgs(1);
++            aArgs[0] <<= nTab;
++            xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_NEWSHEET, aArgs );
++        }
++    }
++    else if ( rHint.ISA( SfxEventHint ) )
++    {
++        ULONG nEventId = ((SfxEventHint&)rHint).GetEventId();
++        switch ( nEventId )
++        {
++            case SFX_EVENT_ACTIVATEDOC:
++            {
++                uno::Sequence< uno::Any > aArgs;
++                xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_ACTIVATE, aArgs );
++            }
++                break;
++            case SFX_EVENT_DEACTIVATEDOC:
++            {
++                uno::Sequence< uno::Any > aArgs;
++                xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_DEACTIVATE, aArgs );
++            }
++                break;
++            /*case SFX_EVENT_CLOSEDOC :
++            {
++                uno::Sequence< uno::Any > aArgs;
++                xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_CLOSE, aArgs );
++            }
++                break;
++            case SFX_EVENT_CLOSEVIEW :
++            {
++                uno::Sequence< uno::Any > aArgs;
++                xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_WINDOWCOLSE, aArgs );
++            }
++                break;
++            */    
++            case SFX_EVENT_OPENDOC:
++            {
++                // some later than workbook activate.
++                uno::Sequence< uno::Any > aArgs;
++                xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_OPEN, aArgs );
++            }
++                break;
++            default:
++                {
++                }
++                break;
++        }
++    }
++}
+ 
+ void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
+ {
++    uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper ( aDocument.GetVbaEventsHelper(), uno::UNO_QUERY );
++    if ( xVbaEventsHelper.is() )
++    {
++        lcl_processCompatibleSfxHint( xVbaEventsHelper, rHint );
++    }
+ 	if (rHint.ISA(SfxSimpleHint))								// ohne Parameter
+ 	{
+ 		ULONG nSlot = ((const SfxSimpleHint&)rHint).GetId();
+@@ -2276,6 +2345,16 @@ USHORT __EXPORT ScDocShell::PrepareClose
+ 
+ 	DoEnterHandler();
+ 
++	// start handler for possible veto from DocBefore_Close
++    uno::Sequence< uno::Any > aArgs;
++    uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper ( aDocument.GetVbaEventsHelper(), uno::UNO_QUERY );
++    if ( !IsInPrepareClose() && xVbaEventsHelper.is() )
++    {
++	    if ( xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_BEFORECLOSE, aArgs ) )
++		    return sal_False;
++    }
++	// end handler code
++
+ 	USHORT nRet = SfxObjectShell::PrepareClose( bUI, bForBrowsing );
+ 	if (nRet == TRUE)						// TRUE = schliessen
+ 		aDocument.DisableIdle(TRUE);		// nicht mehr drin rumpfuschen !!!
+@@ -2485,6 +2564,34 @@ void ScDocShell::SetModified( BOOL bModi
+ 	}
+ }
+ 
++void ScDocShell::PostContentChanged( const ScRange& rRange )
++{
++    ScRangeList aList;
++    aList.Append(rRange);
++    PostContentChanged(aList);
++}
++
++void ScDocShell::PostContentChanged( const ScRangeList& rList )
++{
++    ScCellRangesBase* pObj = NULL;
++	const ScRange& rRange = *(rList.GetObject(0));	
++	if( rList.Count() == 1 )
++	{
++    	if (rRange.aStart == rRange.aEnd)
++    	    pObj = new ScCellObj( this, rRange.aStart );
++	   	else
++	       	pObj = new ScCellRangeObj( this, rRange );
++	}
++	else
++		pObj = new ScCellRangesObj( this, rList );	
++
++    uno::Sequence< uno::Any > aArgs(1);
++    aArgs[0] = uno::makeAny(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj)));
++
++    uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper( aDocument.GetVbaEventsHelper(), uno::UNO_QUERY );
++    if ( xVbaEventsHelper.is() )
++        xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_CHANGE, aArgs );
++}
+ 
+ void ScDocShell::SetDocumentModified( BOOL bIsModified /* = TRUE */ )
+ {
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/source/ui/inc/docsh.hxx	2008-06-16 21:30:17.000000000 +0800
++++ sc/source/ui/inc/docsh.hxx	2008-06-05 18:11:39.000000000 +0800
+@@ -47,6 +47,7 @@
+ #include "refreshtimer.hxx"
+ 
+ #include <hash_map>
++#include <cppuhelper/implbase1.hxx>
+ 
+ class ScEditEngineDefaulter;
+ class FontList;
+@@ -325,6 +326,8 @@ public:
+ 	void            PostPaintExtras();
+ 
+ 	void            PostDataChanged();
++	void			PostContentChanged( const ScRange& rRange ); // for worsheet/workbook changed event
++    void            PostContentChanged( const ScRangeList& rList );
+ 
+ 	void			UpdatePaintExt( USHORT& rExtFlags, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
+ 													   SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab );
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/source/ui/undo/undoblk3.cxx	2008-06-16 21:30:17.000000000 +0800
++++ sc/source/ui/undo/undoblk3.cxx	2008-06-05 18:11:39.000000000 +0800
+@@ -79,7 +79,17 @@ TYPEINIT1(ScUndoInsertAreaLink,		SfxUndo
+ TYPEINIT1(ScUndoRemoveAreaLink,		SfxUndoAction);
+ TYPEINIT1(ScUndoUpdateAreaLink,		SfxUndoAction);
+ 
+-
++void lcl_PostContentChanged( ScDocShell* pDocShell, const ScMarkData& rMark, const ScRange& rRange )
++{
++    if (rMark.IsMarked() || rMark.IsMultiMarked())
++    {
++        ScRangeList aList;
++        rMark.FillRangeListWithMarks(&aList, false);
++        pDocShell->PostContentChanged(aList);
++    }
++    else
++        pDocShell->PostContentChanged( rRange );
++}
+ // To Do:
+ /*A*/	// SetOptimalHeight auf Dokument, wenn keine View
+ 
+@@ -113,6 +123,8 @@ ScUndoDeleteContents::ScUndoDeleteConten
+ 		aMarkData.SetMarkArea( aRange );							// Zelle unter Cursor markieren
+ 
+ 	SetChangeTrack();
++
++	lcl_PostContentChanged( pDocShell, aMarkData, aRange );
+ }
+ 
+ 
+@@ -213,6 +225,7 @@ void __EXPORT ScUndoDeleteContents::Undo
+ 	BeginUndo();
+ 	DoChange( TRUE );
+ 	EndUndo();
++	lcl_PostContentChanged( pDocShell, aMarkData, aRange );
+ }
+ 
+ 
+@@ -223,6 +236,7 @@ void __EXPORT ScUndoDeleteContents::Redo
+ 	BeginRedo();
+ 	DoChange( FALSE );
+ 	EndRedo();
++	lcl_PostContentChanged( pDocShell, aMarkData, aRange );
+ }
+ 
+ 
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/source/ui/undo/undoblk.cxx	2008-06-16 21:30:17.000000000 +0800
++++ sc/source/ui/undo/undoblk.cxx	2008-06-05 18:11:39.000000000 +0800
+@@ -125,6 +125,7 @@ ScUndoInsertCells::ScUndoInsertCells( Sc
+ 	}
+ 
+ 	SetChangeTrack();
++	pDocShell->PostContentChanged( aEffRange );
+ }
+ 
+ __EXPORT ScUndoInsertCells::~ScUndoInsertCells()
+@@ -271,6 +272,7 @@ void __EXPORT ScUndoInsertCells::Undo()
+ 	BeginUndo();
+ 	DoChange( TRUE );
+ 	EndUndo();
++	pDocShell->PostContentChanged( aEffRange );
+ }
+ 
+ void __EXPORT ScUndoInsertCells::Redo()
+@@ -279,6 +281,7 @@ void __EXPORT ScUndoInsertCells::Redo()
+ 	BeginRedo();
+ 	DoChange( FALSE );
+ 	EndRedo();
++	pDocShell->PostContentChanged( aEffRange );
+ 
+ 	if ( pPasteUndo )
+ 		pPasteUndo->Redo();		// redo paste last
+@@ -333,6 +336,7 @@ ScUndoDeleteCells::ScUndoDeleteCells( Sc
+ 	}
+ 
+ 	SetChangeTrack();
++	pDocShell->PostContentChanged( aEffRange );
+ }
+ 
+ __EXPORT ScUndoDeleteCells::~ScUndoDeleteCells()
+@@ -474,6 +478,7 @@ void __EXPORT ScUndoDeleteCells::Undo()
+ 	BeginUndo();
+ 	DoChange( TRUE );
+ 	EndUndo();
++	pDocShell->PostContentChanged( aEffRange );
+     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+ 
+ 	// Markierung erst nach EndUndo
+@@ -488,6 +493,7 @@ void __EXPORT ScUndoDeleteCells::Redo()
+ 	BeginRedo();
+ 	DoChange( FALSE);
+ 	EndRedo();
++	pDocShell->PostContentChanged( aEffRange );
+     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+ 
+ 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+@@ -714,6 +720,7 @@ ScUndoCut::ScUndoCut( ScDocShell* pNewDo
+ 	aExtendedRange( aRange )
+ {
+ 	SetChangeTrack();
++	pDocShell->PostContentChanged( aExtendedRange );
+ }
+ 
+ __EXPORT ScUndoCut::~ScUndoCut()
+@@ -778,6 +785,7 @@ void __EXPORT ScUndoCut::Undo()
+ 	BeginUndo();
+ 	DoChange( TRUE );
+ 	EndUndo();
++	pDocShell->PostContentChanged( aExtendedRange );
+ }
+ 
+ void __EXPORT ScUndoCut::Redo()
+@@ -788,6 +796,7 @@ void __EXPORT ScUndoCut::Redo()
+ 	DoChange( FALSE );
+ 	EnableDrawAdjust( pDoc, TRUE );					//! include in ScBlockUndo?
+ 	EndRedo();
++	pDocShell->PostContentChanged( aExtendedRange );
+ }
+ 
+ void __EXPORT ScUndoCut::Repeat(SfxRepeatTarget& rTarget)
+@@ -839,6 +848,7 @@ ScUndoPaste::ScUndoPaste( ScDocShell* pN
+ 		aPasteOptions = *pOptions;		// used only for Repeat
+ 
+ 	SetChangeTrack();
++	pDocShell->PostContentChanged( aBlockRange );
+ }
+ 
+ __EXPORT ScUndoPaste::~ScUndoPaste()
+@@ -1020,6 +1030,7 @@ void __EXPORT ScUndoPaste::Undo()
+ 	DoChange( TRUE );
+ 	ShowTable( aBlockRange );
+ 	EndUndo();
++	pDocShell->PostContentChanged( aBlockRange );
+     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+ }
+ 
+@@ -1031,6 +1042,7 @@ void __EXPORT ScUndoPaste::Redo()
+ 	DoChange( FALSE );
+ 	EnableDrawAdjust( pDoc, TRUE );					//! include in ScBlockUndo?
+ 	EndRedo();
++	pDocShell->PostContentChanged( aBlockRange );
+     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+ }
+ 
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/source/ui/undo/undocell.cxx	2008-06-16 21:30:17.000000000 +0800
++++ sc/source/ui/undo/undocell.cxx	2008-06-05 18:11:39.000000000 +0800
+@@ -214,6 +214,7 @@ ScUndoEnterData::ScUndoEnterData( ScDocS
+ 	nCount( nNewCount )
+ {
+ 	SetChangeTrack();
++	pDocShell->PostContentChanged( ScRange( ScAddress( nCol, nRow, nTab ) ) );
+ }
+ 
+ __EXPORT ScUndoEnterData::~ScUndoEnterData()
+@@ -319,6 +320,7 @@ void __EXPORT ScUndoEnterData::Undo()
+ 
+ 	DoChange();
+ 	EndUndo();
++	pDocShell->PostContentChanged( ScRange( ScAddress( nCol, nRow, nTab ) ) );
+ }
+ 
+ void __EXPORT ScUndoEnterData::Redo()
+@@ -340,6 +342,7 @@ void __EXPORT ScUndoEnterData::Redo()
+ 
+ 	DoChange();
+ 	EndRedo();
++	pDocShell->PostContentChanged( ScRange( ScAddress( nCol, nRow, nTab ) ) );
+ }
+ 
+ void __EXPORT ScUndoEnterData::Repeat(SfxRepeatTarget& rTarget)
+@@ -371,6 +374,7 @@ ScUndoEnterValue::ScUndoEnterValue( ScDo
+ 	bNeedHeight	( bHeight )
+ {
+ 	SetChangeTrack();
++	pDocShell->PostContentChanged( ScRange( aPos ) );
+ }
+ 
+ __EXPORT ScUndoEnterValue::~ScUndoEnterValue()
+@@ -425,6 +429,7 @@ void __EXPORT ScUndoEnterValue::Undo()
+ 		pChangeTrack->Undo( nEndChangeAction, nEndChangeAction );
+ 
+ 	EndUndo();
++	pDocShell->PostContentChanged( ScRange( aPos ) );
+ }
+ 
+ void __EXPORT ScUndoEnterValue::Redo()
+@@ -438,6 +443,7 @@ void __EXPORT ScUndoEnterValue::Redo()
+ 	SetChangeTrack();
+ 
+ 	EndRedo();
++	pDocShell->PostContentChanged( ScRange( aPos ) );
+ }
+ 
+ void __EXPORT ScUndoEnterValue::Repeat(SfxRepeatTarget& /* rTarget */)
+@@ -465,6 +471,7 @@ ScUndoPutCell::ScUndoPutCell( ScDocShell
+ 	bNeedHeight	( bHeight )
+ {
+ 	SetChangeTrack();
++	pDocShell->PostContentChanged( ScRange( aPos ) );
+ }
+ 
+ __EXPORT ScUndoPutCell::~ScUndoPutCell()
+@@ -521,6 +528,7 @@ void __EXPORT ScUndoPutCell::Undo()
+ 		pChangeTrack->Undo( nEndChangeAction, nEndChangeAction );
+ 
+ 	EndUndo();
++	pDocShell->PostContentChanged( ScRange( aPos ) );
+ }
+ 
+ void __EXPORT ScUndoPutCell::Redo()
+@@ -549,6 +557,7 @@ void __EXPORT ScUndoPutCell::Redo()
+ 	SetChangeTrack();
+ 
+ 	EndRedo();
++	pDocShell->PostContentChanged( ScRange( aPos ) );
+ }
+ 
+ void __EXPORT ScUndoPutCell::Repeat(SfxRepeatTarget& /* rTarget */)
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/source/ui/unoobj/viewuno.cxx	2008-06-16 21:30:17.000000000 +0800
++++ sc/source/ui/unoobj/viewuno.cxx	2008-06-16 21:21:54.000000000 +0800
+@@ -71,8 +71,12 @@
+ #include "gridwin.hxx"
+ #include <com/sun/star/view/DocumentZoomType.hpp>
+ #include "AccessibilityHints.hxx"
++#include <com/sun/star/awt/MouseButton.hpp>
++#include <com/sun/star/document/XVbaEventsHelper.hpp>
++#include <com/sun/star/document/VbaEventId.hpp>
+ 
+ using namespace com::sun::star;
++using namespace com::sun::star::document::VbaEventId;
+ 
+ //------------------------------------------------------------------------
+ 
+@@ -458,6 +462,78 @@ void SAL_CALL ScViewPaneObj::release() t
+ 	OWeakObject::release();
+ }
+ 
++// To process sheet compatibile event
++typedef ::cppu::WeakImplHelper2< awt::XEnhancedMouseClickHandler, view::XSelectionChangeListener > TabViewEventListener_BASE;
++class ScTabViewEventListener: public TabViewEventListener_BASE
++{
++private:
++    uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper;
++    ScTabViewObj* pViewObj;
++    
++public:
++    ScTabViewEventListener( ScTabViewObj* pObj, uno::Reference< document::XVbaEventsHelper >& rVbaEventsHelper);
++    ~ScTabViewEventListener();
++	// XEnhancedMouseClickHandler
++	virtual sal_Bool SAL_CALL mousePressed( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException);
++	virtual sal_Bool SAL_CALL mouseReleased( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException);
++
++    // XSelectionChangeListener
++    virtual void SAL_CALL selectionChanged( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
++    // XEventListener
++	virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
++};
++
++ScTabViewEventListener::ScTabViewEventListener(ScTabViewObj* pObj, uno::Reference< document::XVbaEventsHelper >& rVbaEventsHelper):
++                        pViewObj( pObj ),xVbaEventsHelper( rVbaEventsHelper )
++{
++}
++
++ScTabViewEventListener::~ScTabViewEventListener()
++{
++}
++
++void SAL_CALL ScTabViewEventListener::disposing(  const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
++{
++}
++
++sal_Bool SAL_CALL ScTabViewEventListener::mousePressed( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException)
++{
++	sal_Bool result =  sal_False;
++    // process BeforeDoubleClick and BeforeRightClick events
++	if( e.ClickCount == 2 || e.Buttons == ::com::sun::star::awt::MouseButton::RIGHT )
++	{
++		// ensure the target is a cell
++        uno::Reference< table::XCell > xCell( e.Target, uno::UNO_QUERY );
++		if( xCell.is() && xVbaEventsHelper.is() && pViewObj)
++		{
++			uno::Sequence< uno::Any > aArgs(1);
++			aArgs[0] = pViewObj->getSelection();
++			sal_Int32 nEventId = VBAEVENT_WORKSHEET_BEFORERIGHTCLICK;
++			if( e.ClickCount == 2 )
++				nEventId = VBAEVENT_WORKSHEET_BEFOREDOUBLECLICK;
++            
++            result = xVbaEventsHelper->ProcessCompatibleVbaEvent( nEventId, aArgs );
++			// TODO: process Cancel argument	
++		}
++	}
++	return result;
++}
++
++sal_Bool SAL_CALL ScTabViewEventListener::mouseReleased( const awt::EnhancedMouseEvent&/*e*/) throw (uno::RuntimeException)
++{
++	return sal_False;
++}
++
++void SAL_CALL ScTabViewEventListener::selectionChanged( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
++{
++	if ( xVbaEventsHelper.is() && pViewObj)
++	{
++	    uno::Sequence< uno::Any > aArgs(1);
++	    aArgs[0] = pViewObj->getSelection();
++	    xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_SELECTIONCHANGE, aArgs );
++	}
++}
++
+ //------------------------------------------------------------------------
+ 
+ //	Default-ctor wird fuer SMART_REFLECTION_IMPLEMENTATION gebraucht
+@@ -480,7 +556,19 @@ ScTabViewObj::ScTabViewObj( ScTabViewShe
+ 	aActivationListeners( 0 ),
+ 	bDrawSelModeSet(sal_False)
+ {
+-	//!	Listening oder so
++	if( pViewSh )
++	{
++		ScViewData* pViewData = pViewSh->GetViewData();
++		if( pViewData )
++		{
++            uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper (pViewData->GetDocument()->GetVbaEventsHelper(), uno::UNO_QUERY );
++			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()
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/source/ui/unoobj/docuno.cxx	2008-06-16 21:30:17.000000000 +0800
++++ sc/source/ui/unoobj/docuno.cxx	2008-06-16 15:09:05.000000000 +0800
+@@ -92,7 +92,10 @@
+ #include "rangeutl.hxx"
+ #include "ViewSettingsSequenceDefines.hxx"
+ 
++#include <com/sun/star/document/XVbaEventsHelper.hpp>
++#include <com/sun/star/document/VbaEventId.hpp>
+ using namespace com::sun::star;
++using namespace com::sun::star::document::VbaEventId;
+ 
+ //------------------------------------------------------------------------
+ 
+@@ -329,6 +332,7 @@ uno::Any SAL_CALL ScModelObj::queryInter
+ 	SC_QUERYINTERFACE( document::XLinkTargetSupplier )
+ 	SC_QUERYINTERFACE( beans::XPropertySet )
+ 	SC_QUERYINTERFACE( document::XCodeNameQuery )
++	SC_QUERYINTERFACE( document::XDocumentEventCompatibleHelper)
+ 	SC_QUERYINTERFACE( lang::XMultiServiceFactory )
+ 	SC_QUERYINTERFACE( lang::XServiceInfo )
+ 
+@@ -1730,6 +1734,39 @@ ScModelObj::getCodeNameForObject( const 
+     // Probably should throw here ( if !bMatched )
+      return sCodeName;
+ }
++// XVbaEventHelper
++// For Vba Event
++sal_Bool SAL_CALL
++ScModelObj::processCompatibleEvent( sal_Int16 nSlotId ) throw( ::com::sun::star::uno::RuntimeException )
++{
++    USHORT nId = (USHORT)nSlotId;
++    uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper( GetDocument()->GetVbaEventsHelper(), uno::UNO_QUERY );
++    if( xVbaEventsHelper.is() )
++    {
++        switch( nId )
++        {
++            case SID_SAVEDOC:
++            {
++                uno::Sequence< uno::Any > aArgs(1);
++                aArgs[0] <<= sal_False;
++                return xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_BEFORESAVE, aArgs );
++            }
++            case SID_SAVEASDOC:
++            {
++                uno::Sequence< uno::Any > aArgs(1);
++                aArgs[0] <<= sal_True;
++                return xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_BEFORESAVE, aArgs );
++            }
++            case SID_PRINTDOC:
++            case SID_PRINTDOCDIRECT:
++            {
++                uno::Sequence< uno::Any > aArgs;
++                return xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_BEFOREPRINT, aArgs );
++            }
++        }
++    }
++    return sal_False;
++}
+ // XServiceInfo
+ 
+ rtl::OUString SAL_CALL ScModelObj::getImplementationName() throw(uno::RuntimeException)
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/inc/docuno.hxx	2008-06-16 21:30:17.000000000 +0800
++++ sc/inc/docuno.hxx	2008-06-16 15:08:17.000000000 +0800
+@@ -55,6 +55,7 @@
+ #include <com/sun/star/sheet/XSheetAnnotations.hpp>
+ #include <com/sun/star/beans/XPropertySet.hpp>
+ #include <com/sun/star/sheet/XCellRangesAccess.hpp>
++#include <com/sun/star/document/XDocumentEventCompatibleHelper.hpp>
+ #include <cppuhelper/implbase2.hxx>
+ #include <cppuhelper/implbase3.hxx>
+ #include <cppuhelper/implbase4.hxx>
+@@ -89,6 +90,7 @@ class SC_DLLPUBLIC ScModelObj : public S
+ 					public com::sun::star::document::XLinkTargetSupplier,
+ 					public com::sun::star::beans::XPropertySet,
+ 					public com::sun::star::document::XCodeNameQuery,
++                    public com::sun::star::document::XDocumentEventCompatibleHelper,
+ 					public SvxFmMSFactory,	// derived from XMultiServiceFactory
+                     public com::sun::star::lang::XServiceInfo
+ {
+@@ -303,6 +305,8 @@ public:
+ 								throw(::com::sun::star::uno::RuntimeException);
+  	virtual rtl::OUString SAL_CALL getCodeNameForObject( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& aObj )
+ 								throw(::com::sun::star::uno::RuntimeException);
++                            // XVbaEventHelper
++    virtual sal_Bool SAL_CALL processCompatibleEvent( sal_Int16 nEventId ) throw (::com::sun::star::uno::RuntimeException);
+ };
+ 
+ 
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/source/ui/view/gridwin.cxx	2008-06-16 21:30:17.000000000 +0800
++++ sc/source/ui/view/gridwin.cxx	2008-06-16 17:37:15.000000000 +0800
+@@ -150,7 +150,13 @@
+ #include <svx/sdr/overlay/overlaymanager.hxx>
+ #include <vcl/svapp.hxx>
+ 
++#include "cellsuno.hxx"
++
++#include <com/sun/star/document/XVbaEventsHelper.hpp>
++#include <com/sun/star/document/VbaEventId.hpp>
++
+ using namespace com::sun::star;
++using namespace com::sun::star::document::VbaEventId;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Any;
+ 
+@@ -399,6 +405,32 @@ void lcl_UnLockComment( SdrView* pView, 
+ 
+ }
+ 
++sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTAB nTab, ScBaseCell*& rpCell )
++{
++	BOOL bFound = FALSE;
++	do
++	{
++		pDoc->GetCell( rPosX, rPosY, nTab, rpCell );
++		if ( !rpCell || rpCell->GetCellType() == CELLTYPE_NOTE )
++		{
++			if ( rPosX <= 0 )
++				return FALSE;							// alles leer bis links
++			else
++				--rPosX;								// weitersuchen
++		}
++                else if ( rpCell->GetCellType() == CELLTYPE_EDIT)
++                    bFound = TRUE;
++                else if (rpCell->GetCellType() == CELLTYPE_FORMULA &&
++                  static_cast<ScFormulaCell*>(rpCell)->IsHyperLinkCell())
++                    bFound = TRUE;
++	    else
++			return FALSE;								// andere Zelle
++	}
++	while ( !bFound );
++
++	return bFound;
++}
++
+ //==================================================================
+ 
+ //	WB_DIALOGCONTROL noetig fuer UNO-Controls
+@@ -1443,6 +1475,7 @@ void ScGridWindow::HandleMouseButtonDown
+ 	SCCOL	nOldColFBox	  = bWasFilterBox ? pFilterBox->GetCol() : 0;
+ 	SCROW  nOldRowFBox	  = bWasFilterBox ? pFilterBox->GetRow() : 0;
+ #endif
++#include "cellsuno.hxx" 
+ 
+ 	ClickExtern();	// loescht FilterBox, wenn vorhanden
+ 
+@@ -2123,6 +2156,26 @@ void __EXPORT ScGridWindow::MouseButtonU
+ 		{
+ 			nMouseStatus = SC_GM_NONE;				// keinen Doppelklick anfangen
+ 			ScGlobal::OpenURL( aUrl, aTarget );
++			
++			// fire worksheet_followhyperlink event
++			Point aPos = rMEvt.GetPosPixel();
++	        SCsCOL nPosX;
++    	    SCsROW nPosY;
++        	SCTAB nTab = pViewData->GetTabNo();
++        	pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
++			ScBaseCell* pCell = NULL;
++
++			BOOL bFound = lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell );
++			if( bFound )
++			{
++				ScAddress aCellPos( nPosX, nPosY, nTab );
++				ScCellObj* pObj = new ScCellObj( pViewData->GetDocShell(), aCellPos );
++				uno::Sequence< uno::Any > aArgs(1);
++				aArgs[0] = uno::makeAny(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj)));
++                uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper ( pViewData->GetDocument()->GetVbaEventsHelper(), uno::UNO_QUERY );
++                if( xVbaEventsHelper.is() )
++			        xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_FOLLOWHYPERLINK, aArgs );
++			}
+ 			return;
+ 		}
+ 	}
+@@ -2448,7 +2501,7 @@ long ScGridWindow::PreNotify( NotifyEven
+ 			                lcl_InitMouseEvent( aEvent, *rNEvt.GetMouseEvent() );
+ 	                        if ( rNEvt.GetWindow() )
+ 		                        aEvent.Source = rNEvt.GetWindow()->GetComponentInterface();
+-                            if ( nType == EVENT_MOUSEBUTTONDOWN)
++                            if ( nType == EVENT_MOUSEBUTTONDOWN )
+ 					            pImp->MousePressed( aEvent );
+                             else
+                                 pImp->MouseReleased( aEvent );
+@@ -4858,26 +4911,9 @@ BOOL ScGridWindow::GetEditUrlOrError( BO
+ 	ScDocument* pDoc = pDocSh->GetDocument();
+ 	ScBaseCell* pCell = NULL;
+ 
+-	BOOL bFound = FALSE;
+-	do
+-	{
+-		pDoc->GetCell( nPosX, nPosY, nTab, pCell );
+-		if ( !pCell || pCell->GetCellType() == CELLTYPE_NOTE )
+-		{
+-			if ( nPosX <= 0 )
+-				return FALSE;							// alles leer bis links
+-			else
+-				--nPosX;								// weitersuchen
+-		}
+-                else if ( pCell->GetCellType() == CELLTYPE_EDIT)
+-                    bFound = TRUE;
+-                else if (pCell->GetCellType() == CELLTYPE_FORMULA &&
+-                  static_cast<ScFormulaCell*>(pCell)->IsHyperLinkCell())
+-                    bFound = TRUE;
+-	    else
+-			return FALSE;								// andere Zelle
+-	}
+-	while ( !bFound );
++	BOOL bFound = lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell );
++	if( !bFound )
++		return FALSE;
+ 
+ 	ScHideTextCursor aHideCursor( pViewData, eWhich );	// before GetEditArea (MapMode is changed)
+ 
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/source/ui/view/tabview3.cxx	2008-06-16 21:30:17.000000000 +0800
++++ sc/source/ui/view/tabview3.cxx	2008-06-05 18:11:39.000000000 +0800
+@@ -82,6 +82,10 @@
+ #include "client.hxx"
+ 
+ #include <com/sun/star/chart2/data/HighlightedRange.hpp>
++#include <com/sun/star/document/XVbaEventsHelper.hpp>
++#include <com/sun/star/document/VbaEventId.hpp>
++
++using namespace com::sun::star::document::VbaEventId;
+ 
+ namespace
+ {
+@@ -1685,6 +1689,17 @@ void ScTabView::SetTabNo( SCTAB nTab, BO
+ 										//	nicht InputEnterHandler wegen Referenzeingabe !
+ 
+ 		ScDocument* pDoc = aViewData.GetDocument();
++		if( !bNew )
++		{
++            uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper ( pDoc->GetVbaEventsHelper(), uno::UNO_QUERY );
++            if( xVbaEventsHelper.is() )
++            {
++                uno::Sequence< uno::Any > aArgs(1);
++                aArgs[0] <<= aViewData.GetTabNo();
++			    xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_DEACTIVATE, aArgs );
++            }
++		}
++			
+ 		pDoc->MakeTable( nTab );
+ 
+ 		SCTAB nTabCount = pDoc->GetTableCount();
+@@ -1783,7 +1798,18 @@ void ScTabView::SetTabNo( SCTAB nTab, BO
+ 					if ( pGridWin[i]->IsVisible() )
+ 						pGridWin[i]->UpdateEditViewPos();
+ 		}
+-
++		
++		if( !bNew )
++		{
++            uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper ( pDoc->GetVbaEventsHelper(), uno::UNO_QUERY );
++            if( xVbaEventsHelper.is() )
++            {
++                uno::Sequence< uno::Any > aArgs(1);
++                aArgs[0] <<= aViewData.GetTabNo();
++			    xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_ACTIVATE,  aArgs );
++            }
++		}
++			
+ 		TabChanged();										// DrawView
+ 		aViewData.GetViewShell()->WindowChanged();			// falls das aktive Fenster anders ist
+         if ( !bUnoRefDialog )
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/source/ui/vba/makefile.mk	2008-06-16 21:30:17.000000000 +0800
++++ sc/source/ui/vba/makefile.mk	2008-06-05 18:11:39.000000000 +0800
+@@ -128,6 +128,7 @@ SLOFILES= \
+         $(SLO)$/vbahyperlink.obj \
+         $(SLO)$/vbapagesetup.obj \
+ 		$(SLO)$/service.obj \
++        $(SLO)$/vbaeventshelper.obj \
+  
+ 
+ # --- Targets ------------------------------------------------------
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sc/source/ui/vba/service.cxx	2008-06-16 21:30:17.000000000 +0800
++++ sc/source/ui/vba/service.cxx	2008-06-05 18:11:39.000000000 +0800
+@@ -69,6 +69,10 @@ namespace hyperlink 
+ {
+ extern sdecl::ServiceDecl const serviceDecl;
+ }
++namespace vbaeventshelper
++{
++extern sdecl::ServiceDecl const serviceDecl;
++}
+ 
+ 
+ extern "C"
+@@ -87,7 +91,7 @@ extern "C"
+ 
+ 	// Component registration
+         if ( component_writeInfoHelper( pServiceManager, pRegistryKey, 
+-		range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, userform::serviceDecl, window::serviceDecl, hyperlink::serviceDecl ) )
++		range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, userform::serviceDecl, window::serviceDecl, hyperlink::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl ) )
+ 		{
+ 			// Singleton registration
+ 			try
+@@ -116,6 +120,8 @@ extern "C"
+ 		OSL_TRACE("In component_getFactory for %s", pImplName );
+ 	void* pRet =  component_getFactoryHelper(
+         	pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, userform::serviceDecl, window::serviceDecl, hyperlink::serviceDecl );
++    if( !pRet )
++        pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl );
+ 	OSL_TRACE("Ret is 0x%x", pRet);
+ 	return pRet;
+     }
+
+--- sfx2/inc/sfx2/objsh.hxx.orig	2008-06-04 11:30:47.000000000 +0800
++++ sfx2/inc/sfx2/objsh.hxx	2008-06-04 10:41:41.000000000 +0800
+@@ -304,6 +304,7 @@ public:
+     void                        SetNoName();
+     sal_Bool                    IsInModalMode() const;
+     sal_Bool					HasModalViews() const;
++    sal_Bool                    IsInPrepareClose() const;
+     sal_Bool                    IsHelpDocument() const;
+ 
+     sal_Bool                    IsDocShared() const;
+@@ -403,7 +404,8 @@ public:
+         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams,
+         ::com::sun::star::uno::Any& aRet,
+         ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex,
+-        ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam
++        ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam,
++        bool bRaiseError = true
+     );
+ 
+     static ErrCode  CallXScript(
+@@ -412,7 +414,8 @@ public:
+         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams,
+         ::com::sun::star::uno::Any& aRet,
+         ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex,
+-        ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam
++        ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam,
++        bool bRaiseError = true
+     );
+ 
+     /** adjusts the internal macro mode, according to the current security settings
+
+--- sfx2/source/doc/objmisc.cxx.orig	2008-06-04 11:20:37.000000000 +0800
++++ sfx2/source/doc/objmisc.cxx	2008-06-03 18:53:21.000000000 +0800
+@@ -1591,7 +1591,7 @@ namespace
+ }
+ 
+ ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptContext, const ::rtl::OUString& _rScriptURL,
+-    const Sequence< Any >& aParams, Any& aRet, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam )
++    const Sequence< Any >& aParams, Any& aRet, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam, bool bRaiseError )
+ {
+     OSL_TRACE( "in CallXScript" );
+ 	ErrCode nErr = ERRCODE_NONE;
+@@ -1632,7 +1632,7 @@ ErrCode SfxObjectShell::CallXScript( con
+         nErr = ERRCODE_BASIC_INTERNAL_ERROR;
+     }
+ 
+-	if ( bCaughtException )
++	if ( bCaughtException && bRaiseError )
+ 	{
+         ::std::auto_ptr< VclAbstractDialog > pScriptErrDlg;
+ 		SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
+@@ -1656,9 +1656,9 @@ ErrCode SfxObjectShell::CallXScript( con
+         ::com::sun::star::uno::Any& aRet,
+         ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex,
+         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >&
+-            aOutParam)
++            aOutParam, bool bRaiseError )
+ {
+-    return CallXScript( GetModel(), rScriptURL, aParams, aRet, aOutParamIndex, aOutParam );
++    return CallXScript( GetModel(), rScriptURL, aParams, aRet, aOutParamIndex, aOutParam, bRaiseError );
+ }
+ 
+ //-------------------------------------------------------------------------
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sfx2/source/doc/objserv.cxx	2008-06-16 21:30:17.000000000 +0800
++++ sfx2/source/doc/objserv.cxx	2008-06-16 15:11:04.000000000 +0800
+@@ -109,6 +109,7 @@
+ #include <com/sun/star/document/XDocumentInfo.hpp>
+ #include <com/sun/star/document/XDocumentInfoSupplier.hpp>
+ #include <com/sun/star/document/XDocumentProperties.hpp>
++#include <com/sun/star/document/XDocumentEventCompatibleHelper.hpp>
+ 
+ #ifndef _SFX_HELPID_HRC
+ #include "helpid.hrc"
+@@ -522,6 +523,18 @@ void SfxObjectShell::ExecFile_Impl(SfxRe
+ 		case SID_SAVEASDOC:
+ 		case SID_SAVEDOC:
+ 		{
++            if( nId == SID_SAVEDOC || nId == SID_SAVEASDOC )
++            {
++                uno::Reference< document::XDocumentEventCompatibleHelper > xVbaEventHelper( GetModel(), uno::UNO_QUERY );
++                if( xVbaEventHelper.is() )
++                {
++                    if( xVbaEventHelper->processCompatibleEvent( nId ) )
++                    {
++                        rReq.SetReturnValue( SfxBoolItem( 0, sal_True ) );
++                        return;
++                    }
++                }
++            }
+ 			//!! detaillierte Auswertung eines Fehlercodes
+ 			SfxObjectShellRef xLock( this );
+ 
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sfx2/source/view/viewprn.cxx	2008-06-16 21:30:17.000000000 +0800
++++ sfx2/source/view/viewprn.cxx	2008-06-16 15:12:05.000000000 +0800
+@@ -32,6 +32,7 @@
+ #include "precompiled_sfx2.hxx"
+ 
+ #include <com/sun/star/document/XDocumentProperties.hpp>
++#include <com/sun/star/document/XDocumentEventCompatibleHelper.hpp>
+ #include <com/sun/star/view/PrintableState.hpp>
+ #include <svtools/itempool.hxx>
+ #ifndef _MSGBOX_HXX //autogen
+@@ -67,6 +68,8 @@
+ #include "view.hrc"
+ #include "helpid.hrc"
+ 
++using namespace com::sun::star;
++
+ TYPEINIT1(SfxPrintingHint, SfxHint);
+ 
+ // -----------------------------------------------------------------------
+@@ -405,6 +408,22 @@ void SfxViewShell::ExecPrint_Impl( SfxRe
+ 		case SID_SETUPPRINTER:
+ 	    case SID_PRINTER_NAME :
+ 		{
++            if( nId == SID_PRINTDOC )
++            {
++				SfxObjectShell* pDoc = GetObjectShell();
++                if( pDoc )
++                {
++                    uno::Reference< document::XDocumentEventCompatibleHelper > xVbaEventHelper( pDoc->GetModel(), uno::UNO_QUERY );
++                    if( xVbaEventHelper.is() )
++                    {
++                        if( xVbaEventHelper->processCompatibleEvent( nId ) )
++                        {
++                            rReq.SetReturnValue(SfxBoolItem(0,FALSE));
++                            return;
++                        }
++                    }
++                }
++            }
+ 	        // quiet mode (AppEvent, API call)
+ 			SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, FALSE);
+ 			bSilent = pSilentItem && pSilentItem->GetValue();
+@@ -714,6 +733,15 @@ void SfxViewShell::ExecPrint_Impl( SfxRe
+ 	        if ( SID_PRINTDOCDIRECT == nId )
+ 	        {
+ 				SfxObjectShell* pDoc = GetObjectShell();
++                uno::Reference< document::XDocumentEventCompatibleHelper > xVbaEventHelper( pDoc->GetModel(), uno::UNO_QUERY );
++                if( xVbaEventHelper.is() )
++                {
++                    if( xVbaEventHelper->processCompatibleEvent( nId ) )
++                    {
++                        rReq.SetReturnValue(SfxBoolItem(0,FALSE));
++                        return;
++                    }
++                }
+ 				bool bDetectHidden = ( !bSilent && pDoc );
+ 				if ( bDetectHidden && pDoc->QueryHiddenInformation( WhenPrinting, NULL ) != RET_YES )
+ 					return;
+
+--- /home/feng/work/ooo-build/build/dev300-m14/sfx2/source/doc/objxtor.cxx	2008-06-16 21:30:17.000000000 +0800
++++ sfx2/source/doc/objxtor.cxx	2008-06-05 18:11:40.000000000 +0800
+@@ -594,6 +594,13 @@ SfxObjectShell* SfxObjectShell::Current(
+ 	return pFrame ? pFrame->GetObjectShell() : 0;
+ }
+ 
++//-------------------------------------------------------------------------
++
++sal_Bool SfxObjectShell::IsInPrepareClose() const
++{
++    return pImp->bInPrepareClose;
++}
++
+ //------------------------------------------------------------------------
+ 
+ struct BoolEnv_Impl
+

Modified: trunk/patches/vba/vbaevents-services-sources.diff
==============================================================================
--- trunk/patches/vba/vbaevents-services-sources.diff	(original)
+++ trunk/patches/vba/vbaevents-services-sources.diff	Thu Aug  7 07:43:26 2008
@@ -1252,7 +1252,7 @@
 diff -rup sc/inc/docuno.hxx sc/inc/docuno.hxx
 --- sc/inc/docuno.hxx	2008-03-05 17:29:55.000000000 +0000
 +++ sc/inc/docuno.hxx	2008-04-28 17:52:17.000000000 +0100
-@@ -74,6 +74,8 @@ class ScTableSheetObj;
+@@ -144,6 +144,8 @@ class ScTableSheetObj;
  class SvxFmDrawPage;
  class SvxDrawPage;
  
@@ -1261,24 +1261,23 @@
  class SC_DLLPUBLIC ScModelObj : public SfxBaseModel,
  					public com::sun::star::sheet::XSpreadsheetDocument,
  					public com::sun::star::document::XActionLockable,
-@@ -87,6 +89,7 @@ class SC_DLLPUBLIC ScModelObj : public S
+@@ -157,6 +159,7 @@ class SC_DLLPUBLIC ScModelObj : public S
  					public com::sun::star::view::XRenderable,
  					public com::sun::star::document::XLinkTargetSupplier,
  					public com::sun::star::beans::XPropertySet,
-+ 					public com::sun::star::document::XCodeNameQuery,
-                     public com::sun::star::document::XDocumentEventCompatibleHelper,
++					public com::sun::star::document::XCodeNameQuery,
  					public SvxFmMSFactory,	// derived from XMultiServiceFactory
                      public com::sun::star::lang::XServiceInfo
-@@ -300,6 +303,9 @@ public:
+ {
+@@ -369,6 +372,8 @@ public:
  								throw(::com::sun::star::uno::RuntimeException);
  	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
  								throw(::com::sun::star::uno::RuntimeException);
-+							// XCodeNameQuery
 + 	virtual rtl::OUString SAL_CALL getCodeNameForObject( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& aObj )
 +								throw(::com::sun::star::uno::RuntimeException);
-                             // XVbaEventHelper
-     virtual sal_Bool SAL_CALL processCompatibleEvent( sal_Int16 nEventId ) throw (::com::sun::star::uno::RuntimeException);
  };
+ 
+ 
 diff -rup sc/inc/scextopt.hxx sc/inc/scextopt.hxx
 --- sc/inc/scextopt.hxx	2008-04-29 13:37:35.000000000 +0100
 +++ sc/inc/scextopt.hxx	2008-04-28 15:44:25.000000000 +0100
@@ -1437,7 +1436,7 @@
 diff -rup sc/source/ui/unoobj/docuno.cxx sc/source/ui/unoobj/docuno.cxx
 --- sc/source/ui/unoobj/docuno.cxx	2008-03-05 17:33:11.000000000 +0000
 +++ sc/source/ui/unoobj/docuno.cxx	2008-04-29 00:10:59.000000000 +0100
-@@ -106,6 +106,7 @@ using namespace com::sun::star::document
+@@ -108,6 +108,7 @@ using namespace com::sun::star;
  //	alles ohne Which-ID, Map nur fuer PropertySetInfo
  
  //!	umbenennen, sind nicht mehr nur Options
@@ -1445,18 +1444,19 @@
  const SfxItemPropertyMap* lcl_GetDocOptPropertyMap()
  {
  	static SfxItemPropertyMap aDocOptPropertyMap_Impl[] =
-@@ -334,6 +335,7 @@ uno::Any SAL_CALL ScModelObj::queryInter
+@@ -336,6 +337,7 @@ uno::Any SAL_CALL ScModelObj::queryInter
  	SC_QUERYINTERFACE( view::XRenderable )
  	SC_QUERYINTERFACE( document::XLinkTargetSupplier )
  	SC_QUERYINTERFACE( beans::XPropertySet )
-+ 	SC_QUERYINTERFACE( document::XCodeNameQuery )
-  	SC_QUERYINTERFACE( document::XDocumentEventCompatibleHelper)
++	SC_QUERYINTERFACE( document::XCodeNameQuery )
  	SC_QUERYINTERFACE( lang::XMultiServiceFactory )
  	SC_QUERYINTERFACE( lang::XServiceInfo )
-@@ -1730,6 +1732,50 @@ uno::Sequence<rtl::OUString> SAL_CALL Sc
+ 
+@@ -1694,7 +1696,49 @@ uno::Sequence<rtl::OUString> SAL_CALL Sc
+ 
  	return concatServiceNames( aMyServices, aDrawServices );
  }
- 
+-
 +// XCodeNameQuery
 +rtl::OUString SAL_CALL 
 +ScModelObj::getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
@@ -1500,10 +1500,9 @@
 +    // Probably should throw here ( if !bMatched )
 +     return sCodeName;
 +}
-+
- // XVbaEventHelper
- // For Vba Event
- sal_Bool SAL_CALL
+ // XServiceInfo
+ 
+ rtl::OUString SAL_CALL ScModelObj::getImplementationName() throw(uno::RuntimeException)
 diff -rup oovbaapi/org/openoffice/vba/XVBAToOOEventDescGen.idl oovbaapi/org/openoffice/vba/XVBAToOOEventDescGen.idl
 --- oovbaapi/org/openoffice/vba/XVBAToOOEventDescGen.idl	2007-04-27 08:32:41.000000000 +0100
 +++ oovbaapi/org/openoffice/vba/XVBAToOOEventDescGen.idl	2008-04-28 16:14:51.000000000 +0100
@@ -1520,14 +1519,17 @@
  }; }; };
 --- /data4/OOOBuildDEVM4-source-only/ooo-build/build/dev300-m4/offapi/com/sun/star/document/makefile.mk	2008-03-07 12:31:01.000000000 +0000
 +++ offapi/com/sun/star/document/makefile.mk	2008-04-28 17:25:31.000000000 +0100
-@@ -109,6 +109,7 @@ IDLFILES=\
+@@ -111,7 +111,9 @@ IDLFILES=\
+     LinkUpdateModes.idl\
      XDocumentRevisionListPersistence.idl\
      DocumentRevisionListPersistence.idl \
-     XDocumentLanguages.idl	\
+-    XDocumentLanguages.idl
++    XDocumentLanguages.idl \
 +    XCodeNameQuery.idl \
- 	XDocumentEventCompatibleHelper.idl \
- 	VbaEventId.idl \
- 	XVbaEventsHelper.idl \
++
+ 
+ # ------------------------------------------------------------------
+ 
 --- /dev/null	2007-05-04 11:54:36.000000000 +0100
 +++ offapi/com/sun/star/document/XCodeNameQuery.idl	2008-04-28 17:39:33.000000000 +0100
 @@ -0,0 +1,56 @@



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]