update dev300-m57
[ooovba.git] / applied_patches / 0322-vba-worksheet-calculate-event-fix.diff
blobf924960a08e40f7120b81e0b35003cd35faf1b9a
1 --- sc/inc/document.hxx.old 2009-04-06 16:42:00.000000000 +0000
2 +++ sc/inc/document.hxx 2009-04-06 16:42:00.000000000 +0000
3 @@ -423,6 +423,9 @@ private:
5 sal_Int16 mnNamedRangesLockCount;
7 + // for worksheet calculate event
8 + ::std::vector< SCTAB > maTabs;
10 inline BOOL RowHidden( SCROW nRow, SCTAB nTab ); // FillInfo
12 public:
13 @@ -865,6 +868,10 @@ public:
14 BOOL IsForcedFormulaPending() const { return bForcedFormulaPending; }
15 // if CalcFormulaTree() is currently running
16 BOOL IsCalculatingFormulaTree() { return bCalculatingFormulaTree; }
18 + // for worksheet calculate event
19 + BOOL FireCalculateEvent( SCTAB nTab );
20 + void AddCalculateTable( SCTAB nTab );
22 USHORT GetErrCode( const ScAddress& ) const;
24 --- sc/source/core/data/documen7.cxx.old 2009-04-02 10:45:01.000000000 +0000
25 +++ sc/source/core/data/documen7.cxx 2009-04-06 16:42:00.000000000 +0000
26 @@ -59,7 +59,15 @@
29 #include "globstr.hrc"
30 +#include <algorithm>
31 +#include <vector>
34 +#include <com/sun/star/document/XVbaEventsHelper.hpp>
35 +#include <com/sun/star/document/VbaEventId.hpp>
37 +using namespace com::sun::star;
38 +using namespace com::sun::star::document::VbaEventId;
39 extern const ScFormulaCell* pLastFormulaTreeTop; // cellform.cxx Err527 WorkAround
41 // STATIC DATA -----------------------------------------------------------
42 @@ -520,5 +528,35 @@ void ScDocument::SetAutoCalc( BOOL bNewA
46 +BOOL ScDocument::FireCalculateEvent( SCTAB nTab )
48 + BOOL bSuccess = FALSE;
49 + ::std::vector<SCTAB>::iterator iter;
50 + iter = ::std::find( maTabs.begin(), maTabs.end(), nTab );
51 + if( iter != maTabs.end() )
52 + {
53 + // make sure fire worksheet calculate event only once for each sheet
54 + // regardless of how many formula cells are calculated.
55 + maTabs.erase(iter);
57 + uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper ( GetVbaEventsHelper(), uno::UNO_QUERY );
58 + if( xVbaEventsHelper.is() )
59 + {
60 + uno::Sequence< uno::Any > aArgs(1);
61 + aArgs[0] <<= nTab;
62 + bSuccess = xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_CALCULATE, aArgs );
63 + }
64 + }
65 + return bSuccess;
68 +void ScDocument::AddCalculateTable( SCTAB nTab )
70 + ::std::vector<SCTAB>::iterator iter;
71 + iter = ::std::find( maTabs.begin(), maTabs.end(), nTab );
72 + if( iter == maTabs.end() )
73 + {
74 + maTabs.push_back( nTab );
75 + }
78 --- sc/inc/cell.hxx.old 2009-04-06 16:41:50.000000000 +0000
79 +++ sc/inc/cell.hxx 2009-04-06 16:42:00.000000000 +0000
80 @@ -418,7 +418,7 @@ public:
81 const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
83 void SetDirty();
84 - inline void SetDirtyVar() { bDirty = TRUE; }
85 + void SetDirtyVar();
86 // If setting entire document dirty after load, no broadcasts but still append to FormulaTree.
87 void SetDirtyAfterLoad();
88 inline void ResetTableOpDirtyVar() { bTableOpDirty = FALSE; }
89 --- sc/source/core/data/cell.cxx.old 2009-04-06 16:41:50.000000000 +0000
90 +++ sc/source/core/data/cell.cxx 2009-04-06 16:42:00.000000000 +0000
91 @@ -1486,6 +1486,9 @@ void ScFormulaCell::Interpret()
93 } while (bIterationFromRecursion || bResumeIteration);
96 + // Fire worksheet calculate event
97 + pDocument->FireCalculateEvent( aPos.Tab() );
100 void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
101 @@ -1769,7 +1772,7 @@ void __EXPORT ScFormulaCell::Notify( Svt
102 else
104 bForceTrack = !bDirty;
105 - bDirty = TRUE;
106 + SetDirtyVar();
108 // #35962# Don't remove from FormulaTree to put in FormulaTrack to
109 // put in FormulaTree again and again, only if necessary.
110 @@ -1792,7 +1795,7 @@ void ScFormulaCell::SetDirty()
111 if ( !IsInChangeTrack() )
113 if ( pDocument->GetHardRecalcState() )
114 - bDirty = TRUE;
115 + SetDirtyVar();
116 else
118 // Mehrfach-FormulaTracking in Load und in CompileAll
119 @@ -1801,7 +1804,7 @@ void ScFormulaCell::SetDirty()
120 // setzen, z.B. in CompileTokenArray
121 if ( !bDirty || !pDocument->IsInFormulaTree( this ) )
123 - bDirty = TRUE;
124 + SetDirtyVar();
125 pDocument->AppendToFormulaTrack( this );
126 pDocument->TrackFormulas();
128 @@ -1809,6 +1812,13 @@ void ScFormulaCell::SetDirty()
132 +void ScFormulaCell::SetDirtyVar()
134 + bDirty = TRUE;
135 + // mark the sheet of this cell to be calculated
136 + pDocument->AddCalculateTable( aPos.Tab() );
139 void ScFormulaCell::SetDirtyAfterLoad()
141 bDirty = TRUE;