[ooo-build-commit] .: 25 commits - chart2/source sc/inc sc/source

Jan Holesovsky kendy at kemper.freedesktop.org
Wed Sep 8 08:35:28 PDT 2010


 chart2/source/controller/main/ChartController_Tools.cxx |   12 
 chart2/source/model/main/ChartModel.cxx                 |    1 
 sc/inc/scmatrix.hxx                                     |   11 
 sc/source/core/tool/interpr1.cxx                        |   27 
 sc/source/core/tool/interpr4.cxx                        |   13 
 sc/source/core/tool/interpr5.cxx                        |   21 
 sc/source/core/tool/scmatrix.cxx                        |    5 
 sc/source/ui/vba/makefile.mk                            |   92 +-
 sc/source/ui/vba/vbaapplication.cxx                     |  612 ++++++----------
 sc/source/ui/vba/vbaglobals.cxx                         |   28 
 sc/source/ui/vba/vbaglobals.hxx                         |    3 
 sc/source/ui/vba/vbanames.cxx                           |    5 
 sc/source/ui/vba/vbarange.cxx                           |   50 -
 sc/source/ui/vba/vbaworkbook.cxx                        |   19 
 sc/source/ui/vba/vbaworkbooks.cxx                       |    2 
 sc/source/ui/vba/vbaworksheet.cxx                       |   47 +
 sc/source/ui/vba/vbaworksheet.hxx                       |    6 
 sc/source/ui/vba/vbaworksheets.cxx                      |    2 
 18 files changed, 468 insertions(+), 488 deletions(-)

New commits:
commit eb4914f043304ba7d164733509794104c7ea5b33
Merge: 5ada805... 0815e6f...
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Tue Sep 7 09:33:00 2010 +0200

    Merge commit 'ooo/OOO330_m6'

commit 0815e6f3086d4513fb1dfed2a0ff8e83a3589afc
Merge: 51cfacc... 1d0dc69...
Author: Ivo Hinkelmann <ihi at openoffice.org>
Date:   Thu Aug 26 13:52:56 2010 +0200

    CWS-TOOLING: integrate CWS calc58

commit 51cfacc73ee6162c82dbb735448f5321a2a57269
Merge: 1f33e95... 8676b47...
Author: Ivo Hinkelmann <ihi at openoffice.org>
Date:   Wed Aug 25 12:49:35 2010 +0200

    CWS-TOOLING: integrate CWS mib18

commit 1d0dc690de7aa8ef1fd93d26578251248fd66d9a
Author: Thomas Benisch <tbe at openoffice.org>
Date:   Fri Aug 20 13:23:46 2010 +0200

    calc58: #i113948# office crashes after resizing chart

diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index 2994ab6..382ccf6 100755
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -1043,6 +1043,7 @@ void SAL_CALL ChartModel::setVisualAreaSize( ::sal_Int64 nAspect, const awt::Siz
 {
     if( nAspect == embed::Aspects::MSOLE_CONTENT )
     {
+        ControllerLockGuard aLockGuard( this );
         bool bChanged =
             (m_aVisualAreaSize.Width != aSize.Width ||
              m_aVisualAreaSize.Height != aSize.Height);
commit db48b114e54b6ceaebd4d77fbb0de1d41a0d69ca
Author: Thomas Benisch <tbe at openoffice.org>
Date:   Fri Aug 20 13:03:55 2010 +0200

    calc58: #i113946# undo does not work for deleting shapes

diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index 5dd7294..5ce82de 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -827,16 +827,14 @@ bool ChartController::executeDispatch_Delete()
     else
     {
         //remove additional shape
-        uno::Reference< drawing::XShape > xShape( m_aSelection.getSelectedAdditionalShape() );
-        if( xShape.is() )
+        impl_ClearSelection();
         {
-            impl_ClearSelection();
+            ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+            if ( m_pDrawViewWrapper )
             {
-                ::vos::OGuard aSolarGuard( Application::GetSolarMutex());
-                if( m_pDrawViewWrapper )
-                    m_pDrawViewWrapper->UnmarkAll();
+                m_pDrawViewWrapper->DeleteMarked();
+                bReturn = true;
             }
-            bReturn = DrawModelWrapper::removeShape( xShape );
         }
     }
     return bReturn;
commit 3fa83707418cb221c94dcbe32864e5555b618159
Author: Eike Rathke [er] <eike.rathke at oracle.com>
Date:   Thu Aug 19 17:12:37 2010 +0200

    calc58: #i113879# add ScMatrix::CloneIfConst() and regard only temporary matrices created by the interpreter as mutable

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 51d5d58..9163d6a 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -99,6 +99,7 @@ class SC_DLLPUBLIC ScMatrix
     mutable ULONG   nRefCnt;    // reference count
     SCSIZE          nColCount;
     SCSIZE          nRowCount;
+    bool            mbCloneIfConst;     // Whether the matrix is cloned with a CloneIfConst() call.
 
     void ResetIsString();
     void DeleteIsString();
@@ -171,11 +172,19 @@ public:
     /** If nC*nR results in more than GetElementsMax() entries, a 1x1 matrix is
         created instead and a double error value (errStackOverflow) is set.
         Compare nC and nR with a GetDimensions() call to check. */
-    ScMatrix( SCSIZE nC, SCSIZE nR) : nRefCnt(0) { CreateMatrix( nC, nR); }
+    ScMatrix( SCSIZE nC, SCSIZE nR) : nRefCnt(0), mbCloneIfConst(true) { CreateMatrix( nC, nR); }
 
     /** Clone the matrix. */
     ScMatrix* Clone() const;
 
+    /** Clone the matrix if mbCloneIfConst (immutable) is set, otherwise 
+        return _this_ matrix, to be assigned to a ScMatrixRef. */
+    ScMatrix* CloneIfConst();
+
+    /** Set the matrix to (im)mutable for CloneIfConst(), only the interpreter 
+        should do this and know the consequences. */
+    inline void SetImmutable( bool bVal ) { mbCloneIfConst = bVal; }
+
     /** 
      * Resize the matrix to specified new dimension.  Note that this operation
      * clears all stored values. 
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 303ce4e..d248211 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3970,5 +3970,10 @@ StackVar ScInterpreter::Interpret()
     while( maxsp-- )
         (*p++)->DecRef();
 
-    return xResult->GetType();
+    StackVar eType = xResult->GetType();
+    if (eType == svMatrix)
+        // Results are immutable in case they would be reused as input for new 
+        // interpreters.
+        static_cast<ScToken*>(xResult.operator->())->GetMatrix()->SetImmutable( true);
+    return eType;
 }
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 3bf95dc..e342a89 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -310,6 +310,9 @@ ScMatrixRef ScInterpreter::GetNewMat(SCSIZE nC, SCSIZE nR)
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetNewMat" );
     ScMatrix* pMat = new ScMatrix( nC, nR);
     pMat->SetErrorInterpreter( this);
+    // A temporary matrix is mutable and ScMatrix::CloneIfConst() returns the 
+    // very matrix.
+    pMat->SetImmutable( false);
     SCSIZE nCols, nRows;
     pMat->GetDimensions( nCols, nRows);
     if ( nCols != nC || nRows != nR )
@@ -2069,24 +2072,26 @@ bool ScInterpreter::CheckMatrix(BOOL _bLOG,BOOL _bTrendGrowth,BYTE& nCase,SCSIZE
         {
             PushIllegalArgument();
             return false;
-        } // if (!pMatY->IsValue(i))
-    } // for ( SCSIZE i = 0; i < nCountY; i++ )
+        }
+    }
+
     if ( _bLOG )
     {
+        ScMatrixRef pNewY = pMatY->CloneIfConst();
         for (SCSIZE nElem = 0; nElem < nCountY; nElem++)
         {
-            const double fVal = pMatY->GetDouble(nElem);
+            const double fVal = pNewY->GetDouble(nElem);
             if (fVal <= 0.0)
             {
                 PushIllegalArgument();
                 return false;
             }
             else
-                pMatY->PutDouble(log(fVal), nElem);
-        } // for (nElem = 0; nElem < nCountY; nElem++)
-    } // if ( _bRKP )
-    
-    
+                pNewY->PutDouble(log(fVal), nElem);
+        }
+        pMatY = pNewY;
+    }
+
     if (pMatX)
     {
         pMatX->GetDimensions(nCX, nRX);
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 9c3282d..96fca90 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -81,6 +81,11 @@ ScMatrix* ScMatrix::Clone() const
     return pScMat;
 }
 
+ScMatrix* ScMatrix::CloneIfConst()
+{
+    return (mbCloneIfConst || IsEternalRef()) ? Clone() : this;
+}
+
 void ScMatrix::Resize( SCSIZE nC, SCSIZE nR)
 {
     Clear();
commit baac8ebc6989a5771b5d1903e5e8f4014ecafeac
Author: Eike Rathke [er] <eike.rathke at oracle.com>
Date:   Wed Aug 18 18:56:10 2010 +0200

    calc58: #i113739# make N return 0 for all strings again

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index be5ed51..2249ff2 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2481,22 +2481,13 @@ void ScInterpreter::ScN()
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScN" );
     USHORT nErr = nGlobalError;
     nGlobalError = 0;
-    double fVal;
-    if ( GetRawStackType() == svString )
-    {
-        fVal = 0.0;
-        Pop();
-    }
-    else
-    {
-        // Temporarily override the ConvertStringToValue() error for 
-        // GetCellValue() / GetCellValueOrZero()
-        USHORT nSErr = mnStringNoValueError;
-        mnStringNoValueError = errCellNoValue;
-        fVal = GetDouble();
-        mnStringNoValueError = nSErr;
-    }
-    if ( nGlobalError == NOTAVAILABLE || nGlobalError == errIllegalArgument )
+    // Temporarily override the ConvertStringToValue() error for 
+    // GetCellValue() / GetCellValueOrZero()
+    USHORT nSErr = mnStringNoValueError;
+    mnStringNoValueError = errCellNoValue;
+    double fVal = GetDouble();
+    mnStringNoValueError = nSErr;
+    if ( nGlobalError == NOTAVAILABLE || nGlobalError == errCellNoValue )
         nGlobalError = 0;       // N(#NA) and N("text") are ok
     if ( !nGlobalError && nErr != NOTAVAILABLE )
         nGlobalError = nErr;
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 37ba5b9..303ce4e 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -231,6 +231,12 @@ double ScInterpreter::ConvertStringToValue( const String& rStr )
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ConvertStringToValue" );
     double fValue = 0.0;
+    if (mnStringNoValueError == errCellNoValue)
+    {
+        // Requested that all strings result in 0, error handled by caller.
+        SetError( mnStringNoValueError);
+        return fValue;
+    }
     ::rtl::OUString aStr( rStr);
     rtl_math_ConversionStatus eStatus;
     sal_Int32 nParseEnd;
commit ac9660fc7e47b2a7eecdb0c749ee46f592a70635
Author: Eike Rathke [er] <eike.rathke at oracle.com>
Date:   Wed Aug 18 16:52:22 2010 +0200

    calc58: #i113820# make TEXT treat string results and inline strings identical to referenced cell text

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 516b96e..be5ed51 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -7108,10 +7108,6 @@ void ScInterpreter::ScText()
             case svDouble:
                 fVal = PopDouble();
                 break;
-            case svString:
-                aStr = PopString();
-                bString = true;
-                break;
             default:
                 {
                     FormulaTokenRef xTok( PopToken());
commit 8676b47d16a1670a4d6ebbc610e8a00abd2367f7
Merge: 6423ab8... 1f33e95...
Author: Daniel Rentz <dr at openoffice.org>
Date:   Fri Aug 13 11:29:46 2010 +0200

    mib18: rebase to OOO330m4

commit 6423ab81e71f7090d61e81b8992878ce7de43f27
Merge: 6e0de89... 772dd5e...
Author: Andreas Bregas <ab at openoffice.org>
Date:   Wed Aug 11 08:28:57 2010 +0200

    mib18: Merge

commit 772dd5e59b0b28c3e24cac6ae52ea0141b39c240
Author: Daniel Rentz <dr at openoffice.org>
Date:   Tue Aug 10 20:18:10 2010 +0200

    mib18: adjusted service name to match VBA symbol

diff --git a/sc/source/ui/vba/vbaglobals.cxx b/sc/source/ui/vba/vbaglobals.cxx
index eb4ccf3..adb9b7f 100644
--- a/sc/source/ui/vba/vbaglobals.cxx
+++ b/sc/source/ui/vba/vbaglobals.cxx
@@ -238,7 +238,7 @@ ScVbaGlobals::getDebug() throw (uno::RuntimeException)
         aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this );
         uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
         uno::Reference< uno::XInterface > xVBADebug = xServiceManager->createInstanceWithArgumentsAndContext(
-            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VbaDebug" ) ), aArgs, mxContext );
+            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.Debug" ) ), aArgs, mxContext );
         return uno::Any( xVBADebug );
     }
     catch( uno::Exception& )
commit 9725c306fd4502fc6de7d4acf5c302427310a20d
Author: Michael E. Bohn <mbn at openoffice.org>
Date:   Tue Aug 10 18:14:58 2010 +0200

    mib18: #163259# implementation of global symbol Excel

diff --git a/sc/source/ui/vba/vbaglobals.cxx b/sc/source/ui/vba/vbaglobals.cxx
index f6dacb5..eb4ccf3 100644
--- a/sc/source/ui/vba/vbaglobals.cxx
+++ b/sc/source/ui/vba/vbaglobals.cxx
@@ -80,6 +80,15 @@ ScVbaGlobals::getApplication() throw (uno::RuntimeException)
        return mxApplication; 
 }
 
+
+uno::Reference<excel::XApplication > SAL_CALL
+ScVbaGlobals::getExcel() throw (uno::RuntimeException)
+{
+       return getApplication(); 
+}
+
+
+
 uno::Reference< excel::XWorkbook > SAL_CALL 
 ScVbaGlobals::getActiveWorkbook() throw (uno::RuntimeException)
 {
diff --git a/sc/source/ui/vba/vbaglobals.hxx b/sc/source/ui/vba/vbaglobals.hxx
index a495cb1..025cf66 100644
--- a/sc/source/ui/vba/vbaglobals.hxx
+++ b/sc/source/ui/vba/vbaglobals.hxx
@@ -82,6 +82,7 @@ typedef ::cppu::ImplInheritanceHelper1< VbaGlobalsBase, ov::excel::XGlobals > Sc
     virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw ( css::uno::RuntimeException );
     virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicError
 Exception, css::uno::RuntimeException);
     virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorExce
 ption, css::uno::RuntimeException);
+    virtual css::uno::Reference< ov::excel::XApplication > SAL_CALL getExcel() throw (css::uno::RuntimeException);
     virtual css::uno::Any SAL_CALL getDebug() throw (css::uno::RuntimeException);
 
 
commit ff7c55aff1293fb51c8ab268d0f478480b0c5685
Merge: 80722e0... 6e0de89...
Author: Michael E. Bohn <mbn at openoffice.org>
Date:   Tue Aug 10 16:57:47 2010 +0200

    heads merged

commit 80722e0f75ad7d3204f39a580df2f48412e001c3
Author: Michael E. Bohn <mbn at openoffice.org>
Date:   Tue Aug 10 16:55:52 2010 +0200

    mib18: #163120# adding the entrypoint for symbol Debug

diff --git a/sc/source/ui/vba/vbaglobals.cxx b/sc/source/ui/vba/vbaglobals.cxx
index d937784..f6dacb5 100644
--- a/sc/source/ui/vba/vbaglobals.cxx
+++ b/sc/source/ui/vba/vbaglobals.cxx
@@ -219,6 +219,25 @@ ScVbaGlobals::Rows( const uno::Any& aIndex ) throw (uno::RuntimeException)
     
 }
 
+
+uno::Any SAL_CALL
+ScVbaGlobals::getDebug() throw (uno::RuntimeException)
+{
+    try // return empty object on error
+    {
+        uno::Sequence< uno::Any > aArgs( 1 );
+        aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this );
+        uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
+        uno::Reference< uno::XInterface > xVBADebug = xServiceManager->createInstanceWithArgumentsAndContext(
+            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VbaDebug" ) ), aArgs, mxContext );
+        return uno::Any( xVBADebug );
+    }
+    catch( uno::Exception& )
+    {
+    }
+    return uno::Any();
+}
+
 uno::Sequence< ::rtl::OUString > SAL_CALL 
 ScVbaGlobals::getAvailableServiceNames(  ) throw (uno::RuntimeException)
 {
diff --git a/sc/source/ui/vba/vbaglobals.hxx b/sc/source/ui/vba/vbaglobals.hxx
index 38a51f2..a495cb1 100644
--- a/sc/source/ui/vba/vbaglobals.hxx
+++ b/sc/source/ui/vba/vbaglobals.hxx
@@ -82,7 +82,7 @@ typedef ::cppu::ImplInheritanceHelper1< VbaGlobalsBase, ov::excel::XGlobals > Sc
     virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw ( css::uno::RuntimeException );
     virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicError
 Exception, css::uno::RuntimeException);
     virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorExce
 ption, css::uno::RuntimeException);
-
+    virtual css::uno::Any SAL_CALL getDebug() throw (css::uno::RuntimeException);
 
 
     // XMultiServiceFactory
commit 6e0de8945fbfbee500e0fc9bfa26aaa67abeafa4
Author: Daniel Rentz <dr at openoffice.org>
Date:   Tue Aug 10 11:52:54 2010 +0200

    mib18: #163243# enable regular expressions in VBA symbol Range.Find

diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index c3ae2d8..82f6f44 100755
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -2997,7 +2997,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L
     // return a Range object that represents the first cell where that information is found.
     rtl::OUString sWhat;
     sal_Int32 nWhat = 0;
-    float fWhat = 0.0;
+    double fWhat = 0.0;
     
     // string.
     if( What >>= sWhat )
@@ -3029,6 +3029,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L
     {
         uno::Reference< util::XSearchDescriptor > xDescriptor = xSearch->createSearchDescriptor();
         xDescriptor->setSearchString( sSearch );
+        xDescriptor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SRCHREGEXP ) ), uno::Any( true ) );
 
         uno::Reference< excel::XRange > xAfterRange;
         uno::Reference< table::XCellRange > xStartCell;
@@ -3132,10 +3133,9 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L
         // SearchFormat
         // ignore
 
-        ScGlobal::SetSearchItem( newOptions );	
+        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< uno::XInterface > xInterface = xStartCell.is() ? xSearch->findNext( xStartCell, xDescriptor) : xSearch->findFirst( xDescriptor );
         uno::Reference< table::XCellRange > xCellRange( xInterface, uno::UNO_QUERY );
         if ( xCellRange.is() )
         {
commit d0093c4e1b54648d1e09c16b389519fdf2564f6e
Author: Daniel Rentz <dr at openoffice.org>
Date:   Tue Aug 10 10:27:30 2010 +0200

    mib18: #163246# add VBA symbol Worksheet.ProtectScenarios

diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx
index 89f7293..71e4fae 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -414,7 +414,7 @@ ScVbaWorksheet::getStandardHeight() throw (uno::RuntimeException)
 sal_Bool 
 ScVbaWorksheet::getProtectionMode() throw (uno::RuntimeException) 
 {
-    return false;
+    return sal_False;
 }
 
 sal_Bool
@@ -427,7 +427,13 @@ ScVbaWorksheet::getProtectContents()throw (uno::RuntimeException)
 sal_Bool 
 ScVbaWorksheet::getProtectDrawingObjects() throw (uno::RuntimeException) 
 {
-    return false;
+    return sal_False;
+}
+
+sal_Bool
+ScVbaWorksheet::getProtectScenarios() throw (uno::RuntimeException)
+{
+    return sal_False;
 }
 
 void
diff --git a/sc/source/ui/vba/vbaworksheet.hxx b/sc/source/ui/vba/vbaworksheet.hxx
index 935c0c8..eaa9fdf 100644
--- a/sc/source/ui/vba/vbaworksheet.hxx
+++ b/sc/source/ui/vba/vbaworksheet.hxx
@@ -98,6 +98,7 @@ public:
     virtual ::sal_Bool SAL_CALL getProtectionMode() throw (css::uno::RuntimeException);
     virtual ::sal_Bool SAL_CALL getProtectContents() throw (css::uno::RuntimeException);
     virtual ::sal_Bool SAL_CALL getProtectDrawingObjects() throw (css::uno::RuntimeException);
+    virtual ::sal_Bool SAL_CALL getProtectScenarios() throw (css::uno::RuntimeException);
     virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getUsedRange() throw (css::uno::RuntimeException) ;
     virtual css::uno::Any SAL_CALL ChartObjects( const css::uno::Any& Index ) throw (css::uno::RuntimeException);
     virtual css::uno::Reference< ov::excel::XOutline > SAL_CALL Outline( ) throw (css::uno::RuntimeException);
commit b9876f93ddc6eaa0e5cf4aaf62cd19d3a08776c4
Author: Michael E. Bohn <mbn at openoffice.org>
Date:   Tue Aug 10 06:57:53 2010 +0200

    mib18: #163148# creation og basic modules in library Standard during Workbooks.add

diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx
index 81cb2f4..5316c58 100644
--- a/sc/source/ui/vba/vbaworkbooks.cxx
+++ b/sc/source/ui/vba/vbaworkbooks.cxx
@@ -76,7 +76,7 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >&
         uno::Reference<script::XLibraryContainer> xLibContainer = pShell->GetBasicContainer();
         uno::Reference<script::vba::XVBACompatibility> xVBACompat( xLibContainer, uno::UNO_QUERY_THROW );
         xVBACompat->setVBACompatibilityMode( sal_True );
-        String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "VBAProject" ) );
+        String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
         pShell->GetBasicManager()->SetName( aPrjName );
 
         if( xLibContainer.is() )
commit 80e4fe02a80b90182180c409d2f4f803562e02b8
Merge: 36f7091... 81cec49...
Author: Andreas Bregas <ab at openoffice.org>
Date:   Fri Aug 6 09:39:35 2010 +0200

    mib18: Merge

commit 81cec496df67c85bb1b64ef7d15c9f73987882a0
Author: Daniel Rentz <dr at openoffice.org>
Date:   Thu Aug 5 15:43:06 2010 +0200

    mib18: #162503# do not create a new Worksheet object in Workbook.ActiveSheet but return existing object supporting VBA module access

diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
index 5fa25a4..60fe765 100644
--- a/sc/source/ui/vba/vbaworkbook.cxx
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -50,6 +50,7 @@
 #include "vbanames.hxx"  // Amelia Wang
 #include "nameuno.hxx"
 #include "docoptio.hxx"
+#include "unonames.hxx"
 
 // Much of the impl. for the equivalend UNO module is
 // sc/source/ui/unoobj/docuno.cxx, viewuno.cxx
@@ -208,7 +209,6 @@ ScVbaWorkbook::ScVbaWorkbook( 	const css::uno::Reference< ov::XHelperInterface >
 
 ScVbaWorkbook::ScVbaWorkbook( uno::Sequence< uno::Any> const & args,
     uno::Reference< uno::XComponentContext> const & xContext ) : ScVbaWorkbook_BASE( args, xContext )
-
 {
     init();
 }
@@ -216,21 +216,24 @@ ScVbaWorkbook::ScVbaWorkbook( uno::Sequence< uno::Any> const & args,
 uno::Reference< excel::XWorksheet >
 ScVbaWorkbook::getActiveSheet() throw (uno::RuntimeException)
 {
-    uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ) );	
-    uno::Reference< sheet::XSpreadsheet > xSheet;
+    uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ), uno::UNO_SET_THROW );
     uno::Reference< sheet::XSpreadsheetView > xView( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
-    if ( xView.is() )
-        xSheet = xView->getActiveSheet();
-    return new ScVbaWorksheet( this, mxContext, xSheet, xModel );
+    uno::Reference< beans::XPropertySet > xSheetProps( xView->getActiveSheet(), uno::UNO_QUERY_THROW );
+    // #162503# return the original document module wrapper object, instead of a new instance
+    ::rtl::OUString aCodeName;
+    xSheetProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_CODENAME ) ) ) >>= aCodeName;
+    ScDocShell* pShell = excel::getDocShell( xModel );
+    if( !pShell )
+        throw uno::RuntimeException();
+    return uno::Reference< excel::XWorksheet >( getUnoDocModule( aCodeName, pShell ), uno::UNO_QUERY_THROW );
 }
+
 uno::Any SAL_CALL
 ScVbaWorkbook::Sheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
 {
     return Worksheets( aIndex );
 }
 
-
-
 uno::Any SAL_CALL
 ScVbaWorkbook::Worksheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
 {
diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx
index 85ed97c..8e764d1 100644
--- a/sc/source/ui/vba/vbaworksheets.cxx
+++ b/sc/source/ui/vba/vbaworksheets.cxx
@@ -52,7 +52,7 @@
 #include "vbaglobals.hxx"
 #include "vbaworksheet.hxx"
 #include "vbaworkbook.hxx"
-#include <unonames.hxx>
+#include "unonames.hxx"
 
 using namespace ::ooo::vba;
 using namespace ::com::sun::star;
commit 36f709143ffc8056ece58e93e155a6dab9831cd9
Author: Daniel Rentz <dr at openoffice.org>
Date:   Wed Aug 4 18:13:02 2010 +0200

    mib18: #162938# add VBA symbol Worksheet.AutoFilterMode

diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx
index c09e229..89f7293 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -40,6 +40,7 @@
 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
 #include <com/sun/star/sheet/XCalculatable.hpp>
 #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
 #include <com/sun/star/sheet/XSheetCellRange.hpp>
 #include <com/sun/star/sheet/XSheetCellCursor.hpp>
 #include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
@@ -319,7 +320,41 @@ ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection ) throw (uno::RuntimeEx
 
 }
 
-uno::Reference< excel::XRange > 
+uno::Reference< beans::XPropertySet > ScVbaWorksheet::getFirstDBRangeProperties() throw (uno::RuntimeException)
+{
+    uno::Reference< beans::XPropertySet > xModelProps( mxModel, uno::UNO_QUERY_THROW );
+    uno::Reference< container::XIndexAccess > xDBRangesIA( xModelProps->getPropertyValue(
+        ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DatabaseRanges" ) ) ), uno::UNO_QUERY_THROW );
+
+    for( sal_Int32 nIndex = 0, nCount = xDBRangesIA->getCount(); nIndex < nCount; ++nIndex )
+    {
+        uno::Reference< sheet::XCellRangeReferrer > xDBRange( xDBRangesIA->getByIndex( nIndex ), uno::UNO_QUERY_THROW );
+        // check if the database area is on this sheet
+        uno::Reference< sheet::XCellRangeAddressable > xRangeAddr( xDBRange->getReferredCells(), uno::UNO_QUERY_THROW );
+        if( getSheetID() == xRangeAddr->getRangeAddress().Sheet )
+            return uno::Reference< beans::XPropertySet >( xDBRange, uno::UNO_QUERY_THROW );
+    }
+    return uno::Reference< beans::XPropertySet >();
+}
+
+sal_Bool SAL_CALL ScVbaWorksheet::getAutoFilterMode() throw (uno::RuntimeException)
+{
+    uno::Reference< beans::XPropertySet > xDBRangeProps = getFirstDBRangeProperties();
+    sal_Bool bAutoFilterMode = sal_False;
+    return
+        xDBRangeProps.is() &&
+        (xDBRangeProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoFilter" ) ) ) >>= bAutoFilterMode) &&
+        bAutoFilterMode;
+}
+
+void SAL_CALL ScVbaWorksheet::setAutoFilterMode( sal_Bool bAutoFilterMode ) throw (uno::RuntimeException)
+{
+    uno::Reference< beans::XPropertySet > xDBRangeProps = getFirstDBRangeProperties();
+    if( xDBRangeProps.is() )
+        xDBRangeProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoFilter" ) ), uno::Any( bAutoFilterMode ) );
+}
+
+uno::Reference< excel::XRange >
 ScVbaWorksheet::getUsedRange() throw (uno::RuntimeException)
 {
      uno::Reference< sheet::XSheetCellRange > xSheetCellRange(getSheet(), uno::UNO_QUERY_THROW );
diff --git a/sc/source/ui/vba/vbaworksheet.hxx b/sc/source/ui/vba/vbaworksheet.hxx
index 4c730ab..935c0c8 100644
--- a/sc/source/ui/vba/vbaworksheet.hxx
+++ b/sc/source/ui/vba/vbaworksheet.hxx
@@ -68,6 +68,9 @@ class ScVbaWorksheet : public WorksheetImpl_BASE
 
     css::uno::Reference< css::container::XNameAccess > getFormControls();
     css::uno::Any getControlShape( const rtl::OUString& sName );
+    
+    css::uno::Reference< css::beans::XPropertySet > getFirstDBRangeProperties() throw (css::uno::RuntimeException);
+    
 protected:
 
     ScVbaWorksheet( const css::uno::Reference< ov::XHelperInterface >& xParent,  const css::uno::Reference< css::uno::XComponentContext >& xContext );
@@ -106,6 +109,8 @@ public:
      virtual sal_Int16 SAL_CALL getIndex() throw (css::uno::RuntimeException);
      virtual sal_Int32 SAL_CALL getEnableSelection() throw (css::uno::RuntimeException);
      virtual void SAL_CALL setEnableSelection( sal_Int32 nSelection ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getAutoFilterMode() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setAutoFilterMode( sal_Bool bAutoFilterMode ) throw (css::uno::RuntimeException);
 
     // Methods
     virtual void SAL_CALL Activate() throw (css::uno::RuntimeException);
commit c650f967f769e4da07f669f60e1f7a636d7e9614
Author: Daniel Rentz <dr at openoffice.org>
Date:   Wed Aug 4 16:00:21 2010 +0200

    mib18: #163200# full rework of VBA symbols Application.Intersect and Application.Union

diff --git a/sc/source/ui/vba/makefile.mk b/sc/source/ui/vba/makefile.mk
index 4cb7e3e..92bb3fd 100644
--- a/sc/source/ui/vba/makefile.mk
+++ b/sc/source/ui/vba/makefile.mk
@@ -47,63 +47,63 @@ INCPRE=$(INCCOM)$/$(TARGET)
 # ------------------------------------------------------------------
 
 SLOFILES= \
-        $(SLO)$/vbaglobals.obj \
-        $(SLO)$/vbaworkbook.obj \
-        $(SLO)$/vbaworksheets.obj \
+        $(SLO)$/excelvbahelper.obj \
+        $(SLO)$/service.obj \
         $(SLO)$/vbaapplication.obj \
-        $(SLO)$/vbarange.obj \
-        $(SLO)$/vbaname.obj \
-        $(SLO)$/vbanames.obj \
-        $(SLO)$/vbacomment.obj \
-        $(SLO)$/vbacomments.obj \
-        $(SLO)$/vbaworkbooks.obj \
-        $(SLO)$/vbaworksheet.obj \
-        $(SLO)$/vbaoutline.obj \
-        $(SLO)$/vbafont.obj\
-        $(SLO)$/excelvbahelper.obj\
-        $(SLO)$/vbainterior.obj\
-        $(SLO)$/vbawsfunction.obj\
-        $(SLO)$/vbawindow.obj\
-        $(SLO)$/vbachart.obj\
-        $(SLO)$/vbachartobject.obj\
-        $(SLO)$/vbachartobjects.obj\
-        $(SLO)$/vbaseriescollection.obj\
-        $(SLO)$/vbadialogs.obj \
-        $(SLO)$/vbadialog.obj	\
-        $(SLO)$/vbapivottable.obj \
-        $(SLO)$/vbapivotcache.obj \
-        $(SLO)$/vbapivottables.obj \
-        $(SLO)$/vbawindows.obj \
-        $(SLO)$/vbapalette.obj \
+        $(SLO)$/vbaassistant.obj \
+        $(SLO)$/vbaaxes.obj \
+        $(SLO)$/vbaaxis.obj \
+        $(SLO)$/vbaaxistitle.obj \
         $(SLO)$/vbaborders.obj \
         $(SLO)$/vbacharacters.obj \
-        $(SLO)$/vbavalidation.obj \
-        $(SLO)$/vbasheetobject.obj \
-        $(SLO)$/vbasheetobjects.obj \
-        $(SLO)$/vbaoleobject.obj \
-        $(SLO)$/vbaoleobjects.obj \
-        $(SLO)$/vbatextboxshape.obj \
-        $(SLO)$/vbapane.obj \
-        $(SLO)$/vbatextframe.obj \
-        $(SLO)$/vbacharttitle.obj \
+        $(SLO)$/vbachart.obj \
+        $(SLO)$/vbachartobject.obj \
+        $(SLO)$/vbachartobjects.obj \
         $(SLO)$/vbacharts.obj \
-        $(SLO)$/vbaaxistitle.obj \
-        $(SLO)$/vbaaxes.obj \
-        $(SLO)$/vbaaxis.obj \
-        $(SLO)$/vbaformat.obj \
+        $(SLO)$/vbacharttitle.obj \
+        $(SLO)$/vbacomment.obj \
+        $(SLO)$/vbacomments.obj \
         $(SLO)$/vbacondition.obj \
+        $(SLO)$/vbadialog.obj \
+        $(SLO)$/vbadialogs.obj \
+        $(SLO)$/vbaeventshelper.obj \
+        $(SLO)$/vbafont.obj \
+        $(SLO)$/vbaformat.obj \
         $(SLO)$/vbaformatcondition.obj \
         $(SLO)$/vbaformatconditions.obj \
-        $(SLO)$/vbastyle.obj \
-        $(SLO)$/vbastyles.obj \
-        $(SLO)$/vbaassistant.obj \
+        $(SLO)$/vbaglobals.obj \
         $(SLO)$/vbahyperlink.obj \
         $(SLO)$/vbahyperlinks.obj \
-        $(SLO)$/vbapagesetup.obj \
+        $(SLO)$/vbainterior.obj \
+        $(SLO)$/vbaname.obj \
+        $(SLO)$/vbanames.obj \
+        $(SLO)$/vbaoleobject.obj \
+        $(SLO)$/vbaoleobjects.obj \
+        $(SLO)$/vbaoutline.obj \
         $(SLO)$/vbapagebreak.obj \
         $(SLO)$/vbapagebreaks.obj \
-        $(SLO)$/vbaeventshelper.obj \
-        $(SLO)$/service.obj
+        $(SLO)$/vbapagesetup.obj \
+        $(SLO)$/vbapalette.obj \
+        $(SLO)$/vbapane.obj \
+        $(SLO)$/vbapivotcache.obj \
+        $(SLO)$/vbapivottable.obj \
+        $(SLO)$/vbapivottables.obj \
+        $(SLO)$/vbarange.obj \
+        $(SLO)$/vbaseriescollection.obj \
+        $(SLO)$/vbasheetobject.obj \
+        $(SLO)$/vbasheetobjects.obj \
+        $(SLO)$/vbastyle.obj \
+        $(SLO)$/vbastyles.obj \
+        $(SLO)$/vbatextboxshape.obj \
+        $(SLO)$/vbatextframe.obj \
+        $(SLO)$/vbavalidation.obj \
+        $(SLO)$/vbawindow.obj \
+        $(SLO)$/vbawindows.obj \
+        $(SLO)$/vbaworkbook.obj \
+        $(SLO)$/vbaworkbooks.obj \
+        $(SLO)$/vbaworksheet.obj \
+        $(SLO)$/vbaworksheets.obj \
+        $(SLO)$/vbawsfunction.obj
 
 .ENDIF
 # --- Targets ------------------------------------------------------
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index bf6d4e2..624fb61 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -88,12 +88,6 @@
 using namespace ::ooo::vba;
 using namespace ::com::sun::star;
 
-// Enable our own join detection for Intersection and Union
-// should be more efficient than using ScRangeList::Join ( because
-// we already are testing the same things )
-
-#define OWN_JOIN 1
-
 // #TODO is this defined somewhere else?
 #if ( defined UNX ) || ( defined OS2 ) //unix
 #define FILE_PATH_SEPERATOR "/"
@@ -806,412 +800,289 @@ ScVbaApplication::PathSeparator(  ) throw (script::BasicErrorException, uno::Run
     return sPathSep;
 }
 
-typedef std::list< ScRange > Ranges;
-typedef std::list< ScRangeList > RangesList;
+// ----------------------------------------------------------------------------
+// Helpers for Intersect and Union
+
+namespace {
+
+typedef ::std::list< ScRange > ListOfScRange;
 
-void lcl_addRangesToVec( RangesList& vRanges, const uno::Any& aArg ) throw ( script::BasicErrorException, uno::RuntimeException )
+/** Appends all ranges of a VBA Range object in the passed Any to the list of ranges. */
+void lclAddToListOfScRange( ListOfScRange& rList, const uno::Any& rArg )
+        throw (script::BasicErrorException, uno::RuntimeException)
 {
-    ScRangeList theRanges;
-    uno::Reference< excel::XRange > xRange( aArg, uno::UNO_QUERY_THROW );
-    uno::Reference< XCollection > xCol( xRange->Areas( uno::Any() ), uno::UNO_QUERY_THROW );
-    sal_Int32 nCount = xCol->getCount();
-    for( sal_Int32 i = 1; i <= nCount; ++i )
+    if( rArg.hasValue() )
     {
-        uno::Reference< excel::XRange > xAreaRange( xCol->Item( uno::makeAny( sal_Int32(i) ), uno::Any() ), uno::UNO_QUERY_THROW );
-        uno::Reference< sheet::XCellRangeAddressable > xAddressable( xAreaRange->getCellRange(), uno::UNO_QUERY_THROW );
-        table::CellRangeAddress addr = xAddressable->getRangeAddress(); 
-        ScRange refRange;
-        ScUnoConversion::FillScRange( refRange, addr );
-        theRanges.Append( refRange );
+        uno::Reference< excel::XRange > xRange( rArg, uno::UNO_QUERY_THROW );
+        uno::Reference< XCollection > xCol( xRange->Areas( uno::Any() ), uno::UNO_QUERY_THROW );
+        for( sal_Int32 nIdx = 1, nCount = xCol->getCount(); nIdx <= nCount; ++nIdx )
+        {
+            uno::Reference< excel::XRange > xAreaRange( xCol->Item( uno::Any( nIdx ), uno::Any() ), uno::UNO_QUERY_THROW );
+            uno::Reference< sheet::XCellRangeAddressable > xAddressable( xAreaRange->getCellRange(), uno::UNO_QUERY_THROW );
+            ScRange aScRange;
+            ScUnoConversion::FillScRange( aScRange, xAddressable->getRangeAddress() );
+            rList.push_back( aScRange );
+        }
     }
-    vRanges.push_back( theRanges );
 }
 
-void lcl_addRangeToVec( Ranges& vRanges, const uno::Any& aArg ) throw ( script::BasicErrorException, uno::RuntimeException )
+/** Returns true, if the passed ranges can be expressed by a single range. The
+    new range will be contained in r1 then, the range r2 can be removed. */
+bool lclTryJoin( ScRange& r1, const ScRange& r2 )
 {
-    uno::Reference< excel::XRange > xRange( aArg, uno::UNO_QUERY_THROW );
-    uno::Reference< XCollection > xCol( xRange->Areas( uno::Any() ), uno::UNO_QUERY_THROW );
-    sal_Int32 nCount = xCol->getCount();
-    for( sal_Int32 i = 1; i <= nCount; ++i )
+    // 1) r2 is completely inside r1
+    if( r1.In( r2 ) )
+        return true;
+
+    // 2) r1 is completely inside r2
+    if( r2.In( r1 ) )
     {
-        uno::Reference< excel::XRange > xAreaRange( xCol->Item( uno::makeAny( sal_Int32(i) ), uno::Any() ), uno::UNO_QUERY_THROW );
-        uno::Reference< sheet::XCellRangeAddressable > xAddressable( xAreaRange->getCellRange(), uno::UNO_QUERY_THROW );
-        table::CellRangeAddress addr = xAddressable->getRangeAddress(); 
-        ScRange refRange;
-        ScUnoConversion::FillScRange( refRange, addr );
-        vRanges.push_back( refRange );
+        r1 = r2;
+        return true;
     }
-}
 
-bool lcl_canJoin( ScRange& r1, ScRange& r2 )
-{
-    bool bCanJoin = false;
-    SCCOL startEndColDiff = r2.aStart.Col() - r1.aEnd.Col(); 
-    SCROW startEndRowDiff = r2.aStart.Row() - r1.aEnd.Row(); 
-    SCCOL startColDiff = r2.aStart.Col() - r1.aStart.Col();
-    SCCOL endColDiff = r2.aEnd.Col() - r1.aEnd.Col();
-    SCROW startRowDiff =  r2.aStart.Row() - r1.aStart.Row();
-    SCROW endRowDiff = r2.aEnd.Row() - r1.aEnd.Row();
-    if ( ( startRowDiff == endRowDiff ) && startRowDiff == 0 && startColDiff >=0 && endColDiff > 0 && ( startEndColDiff <= 1 && startEndColDiff >= -r1.aEnd.Col() ) )
-        bCanJoin = true;
-    else if ( ( startColDiff == endColDiff ) && startColDiff == 0 && startRowDiff >= 0 && endRowDiff > 0 && ( startEndRowDiff <= 1 && startEndRowDiff  >= -r1.aEnd.Row() ) )
-        bCanJoin = true;
-#ifdef DEBUG
-    String sr1;
-    String sr2;
-    r1.Format( sr1, SCA_VALID ) ;
-    r2.Format( sr2, SCA_VALID ) ;
-    OSL_TRACE(" canJoin address %s with %s %s ( startRowDiff(%d), endRowDiff(%d), startColDiff(%d) endColDiff(%d) startEndRowDiff(%d), startEndColDiff(%d) ", 
-        rtl::OUStringToOString( sr1, RTL_TEXTENCODING_UTF8 ).getStr(),
-        rtl::OUStringToOString( sr2, RTL_TEXTENCODING_UTF8 ).getStr(), bCanJoin ? "true" : "false", startRowDiff, endRowDiff, startColDiff, endColDiff, startEndRowDiff, startEndColDiff );
-#endif
-    return bCanJoin;
-}
-// strips out ranges that contain other ranges, also
-// if the borders of the intersecting ranges are alligned 
-// then the the range is extended to the larger
-// e.g. Range("A4:D10"), Range("B4:E10") would be combined
-// to Range("A4:E10")
-void lcl_strip_containedRanges( Ranges& vRanges )
-{
-    // get rid of ranges that are surrounded by other ranges
-    Ranges::iterator it_outer = vRanges.begin();
-    while( it_outer != vRanges.end() )
+    SCCOL n1L = r1.aStart.Col();
+    SCCOL n1R = r1.aEnd.Col();
+    SCROW n1T = r1.aStart.Row();
+    SCROW n1B = r1.aEnd.Row();
+    SCCOL n2L = r2.aStart.Col();
+    SCCOL n2R = r2.aEnd.Col();
+    SCROW n2T = r2.aStart.Row();
+    SCROW n2B = r2.aEnd.Row();
+
+    // 3) r1 and r2 have equal upper and lower border
+    if( (n1T == n2T) && (n1B == n2B) )
     {
-        bool it_outer_erased = false;   // true = it_outer erased from vRanges
-        Ranges::iterator it_inner = vRanges.begin();
-        /*  Exit the inner loop if outer iterator has been erased in its last
-            iteration (this means it has been joined to last it_inner, or that
-            the it_inner contains it completely). The inner loop will restart
-            with next element of the outer loop, and all elements (from the
-            beginning of the list) will be checked against that new element. */
-        while( !it_outer_erased && (it_inner != vRanges.end()) )
+        // check that r1 overlaps or touches r2
+        if( ((n1L < n2L) && (n2L - 1 <= n1R)) || ((n2L < n1L) && (n1L - 1 <= n2R)) )
         {
-            bool it_inner_erased = false;   // true = it_inner erased from vRanges
-            if ( it_outer != it_inner )
-            {
-#ifdef DEBUG
-                String r1;
-                String r2;
-                it_outer->Format( r1, SCA_VALID ) ;
-                it_inner->Format( r2, SCA_VALID ) ;
-                OSL_TRACE( "try strip/join address %s with %s ",
-                    rtl::OUStringToOString( r1, RTL_TEXTENCODING_UTF8 ).getStr(),
-                    rtl::OUStringToOString( r2, RTL_TEXTENCODING_UTF8 ).getStr() );
-#endif
-                if ( it_outer->In( *it_inner ) )
-                {
-                    it_inner = vRanges.erase( it_inner );
-                    it_inner_erased = true;
-                }
-                else if ( it_inner->In( *it_outer ) )
-                {
-                    it_outer = vRanges.erase( it_outer );
-                    it_outer_erased = true;
-                }
-#ifndef OWN_JOIN
-                else if ( (*it_inner).aStart.Row() == (*it_outer).aStart.Row()
-                        && (*it_inner).aEnd.Row() == (*it_outer).aEnd.Row() )
-                {
-                    it_outer->ExtendTo( *it_inner );
-                    it_inner = vRanges.erase( it_inner );
-                    it_inner_erased = true;
-                }
-#else
-                else if ( lcl_canJoin( *it_outer, *it_inner ) )
-                {
-                    it_outer->ExtendTo( *it_inner );
-                    it_inner = vRanges.erase( it_inner );
-                    it_inner_erased = true;
-                }
-                else if ( lcl_canJoin( *it_inner, *it_outer) )
-                {
-                    it_inner->ExtendTo( *it_outer );
-                    it_outer = vRanges.erase( it_outer );
-                    it_outer_erased = true;
-                }
-#endif
-            }
-            /*  If it_inner has not been erased from vRanges, continue inner
-                loop with next element. Otherwise, it_inner already points to
-                the next element (return value of list::erase()). */
-            if( !it_inner_erased )
-                ++it_inner;
+            r1.aStart.SetCol( ::std::min( n1L, n2L ) );
+            r1.aEnd.SetCol( ::std::max( n1R, n2R ) );
+            return true;
         }
-        /*  If it_outer has not been erased from vRanges, continue outer loop
-            with next element. Otherwise, it_outer already points to the next
-            element (return value of list::erase()). */
-        if( !it_outer_erased )
-            ++it_outer;
+        return false;
     }
-    
-}
 
-Ranges
-lcl_intersectionImpl( ScRangeList& rl1, ScRangeList& rl2 )
-{
-    Ranges intersections;
-    for ( USHORT x = 0 ; x < rl1.Count(); ++x )
+    // 4) r1 and r2 have equal left and right border
+    if( (n1L == n2L) && (n1R == n2R) )
     {
-        for ( USHORT y = 0 ; y < rl2.Count(); ++y )
+        // check that r1 overlaps or touches r2
+        if( ((n1T < n2T) && (n2T + 1 <= n1B)) || ((n2T < n1T) && (n1T + 1 <= n2B)) )
         {
-#ifdef DEBUG
-            String r1;
-            String r2;
-            rl1.GetObject( x )->Format( r1, SCA_VALID ) ;
-            rl2.GetObject( y )->Format( r2, SCA_VALID ) ;
-            OSL_TRACE( "comparing address %s with %s ", 
-                rtl::OUStringToOString( r1, RTL_TEXTENCODING_UTF8 ).getStr(),
-                rtl::OUStringToOString( r2, RTL_TEXTENCODING_UTF8 ).getStr() );
-#endif
-            if( rl1.GetObject( x )->Intersects( *rl2.GetObject( y ) ) )
-            {     
-                ScRange aIntersection = ScRange( Max( rl1.GetObject( x )->aStart.Col(), rl2.GetObject( y )->aStart.Col() ),
-                    Max( rl1.GetObject( x )->aStart.Row(), rl2.GetObject( y )->aStart.Row() ),
-                    Max( rl1.GetObject( x )->aStart.Tab(), rl2.GetObject( y )->aStart.Tab() ),
-                    Min( rl1.GetObject( x )->aEnd.Col(), rl2.GetObject( y )->aEnd.Col() ),
-                    Min( rl1.GetObject( x )->aEnd.Row(), rl2.GetObject( y )->aEnd.Row() ),
-                        Min( rl1.GetObject( x )->aEnd.Tab(), rl2.GetObject( y )->aEnd.Tab() ) );
-                intersections.push_back( aIntersection );
-            }
+            r1.aStart.SetRow( ::std::min( n1T, n2T ) );
+            r1.aEnd.SetRow( ::std::max( n1B, n2B ) );
+            return true;
         }
+        return false;
     }
-    lcl_strip_containedRanges( intersections );
-    return intersections;
+
+    // 5) cannot join these ranges
+    return false;
 }
 
-// Intersection of a set of ranges ( where each range is represented by a ScRangeList e.g.
-// any range can be a multi-area range )
-// An intersection is performed between each range in the set of ranges. 
-// The resulting set of intersections is then processed to strip out any 
-// intersections that contain other intersections ( and also ranges that directly line up
-// are joined ) ( see lcl_strip_containedRanges )
-RangesList lcl_intersections( RangesList& vRanges )
+/** Strips out ranges that are contained by other ranges, joins ranges that can be joined
+    together (aligned borders, e.g. A4:D10 and B4:E10 would be combined to A4:E10. */
+void lclJoinRanges( ListOfScRange& rList )
 {
-    RangesList intersections;
-    RangesList::iterator it = vRanges.begin();
-    while( it != vRanges.end() )
+    ListOfScRange::iterator aOuterIt = rList.begin();
+    while( aOuterIt != rList.end() )
     {
-        Ranges intermediateList;
-        for( RangesList::iterator it_inner = vRanges.begin(); it_inner != vRanges.end(); ++it_inner )
+        bool bAnyErased = false;    // true = any range erased from rList
+        ListOfScRange::iterator aInnerIt = rList.begin();
+        while( aInnerIt != rList.end() )
         {
-            if ( it != it_inner )
+            bool bInnerErased = false;   // true = aInnerIt erased from rList
+            // do not compare a range with itself
+            if( (aOuterIt != aInnerIt) && lclTryJoin( *aOuterIt, *aInnerIt ) )
             {
-                Ranges ranges = lcl_intersectionImpl( *it, *it_inner );
-                for ( Ranges::iterator range_it = ranges.begin(); range_it != ranges.end(); ++range_it )
-                    intermediateList.push_back( *range_it );					
+                // aOuterIt points to joined range, aInnerIt will be removed
+                aInnerIt = rList.erase( aInnerIt );
+                bInnerErased = bAnyErased = true;
             }
+            /*  If aInnerIt has been erased from rList, it already points to
+                the next element (return value of list::erase()). */
+            if( !bInnerErased )
+                ++aInnerIt;
         }
-        it = vRanges.erase( it ); // remove it so we don't include it in the next pass.
-        // 'it' is removed uncontidionally from vRanges, so the while loop will terminate
-
-        ScRangeList argIntersect;
-        lcl_strip_containedRanges( intermediateList );
-
-        for( Ranges::iterator it_inter = intermediateList.begin(); it_inter != intermediateList.end(); ++it_inter )
-#ifndef OWN_JOIN
-            argIntersect.Join( *it_inter );
-#else
-            argIntersect.Append( *it_inter );
-#endif
-
-        intersections.push_back( argIntersect );
-    }
-    return intersections;
-}
-
-uno::Reference< excel::XRange > SAL_CALL 
-ScVbaApplication::Intersect( const uno::Reference< excel::XRange >& Arg1, const uno::Reference< excel::XRange >& Arg2, const uno::Any& Arg3, const uno::Any& Arg4, const uno::Any& Arg5, const uno::Any& Arg6, const uno::Any& Arg7, const uno::Any& Arg8, const uno::Any& Arg9, const uno::Any& Arg10, const uno::Any& Arg11, const uno::Any& Arg12, const uno::Any& Arg13, const uno::Any& Arg14, const uno::Any& Arg15, const uno::Any& Arg16, const uno::Any& Arg17, const uno::Any& Arg18, const uno::Any& Arg19, const uno::Any& Arg20, const uno::Any& Arg21, const uno::Any& Arg22, const uno::Any& Arg23, const uno::Any& Arg24, const uno::Any& Arg25, const uno::Any& Arg26, const uno::Any& Arg27, const uno::Any& Arg28, const uno::Any& Arg29, const uno::Any& Arg30 ) throw (script::BasicErrorException, uno::RuntimeException)
-{
-    if ( !Arg1.is() || !Arg2.is() )
-        DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
-
-    RangesList vRanges;
-    lcl_addRangesToVec( vRanges, uno::makeAny( Arg1 ) );
-    lcl_addRangesToVec( vRanges, uno::makeAny( Arg2 ) );
-
-    if ( Arg3.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg3 );
-    if ( Arg4.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg4 );
-    if ( Arg5.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg5 );
-    if ( Arg6.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg6 );
-    if ( Arg7.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg7 );
-    if ( Arg8.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg8 );
-    if ( Arg9.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg9 );
-    if ( Arg10.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg10 );
-    if ( Arg11.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg11 );
-    if ( Arg12.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg12 );
-    if ( Arg13.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg13 );
-    if ( Arg14.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg14 );
-    if ( Arg15.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg15 );
-    if ( Arg16.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg16 );
-    if ( Arg17.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg17 );
-    if ( Arg18.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg18 );
-    if ( Arg19.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg19 );
-    if ( Arg20.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg20 );
-    if ( Arg21.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg21 );
-    if ( Arg22.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg22 );
-    if ( Arg23.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg23 );
-    if ( Arg24.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg24 );
-    if ( Arg25.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg25 );
-    if ( Arg26.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg26 );
-    if ( Arg27.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg27 );
-    if ( Arg28.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg28 );
-    if ( Arg29.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg29 );
-    if ( Arg30.hasValue() )
-        lcl_addRangesToVec( vRanges, Arg30 );
-
-    uno::Reference< excel::XRange > xRefRange; 
-
-    ScRangeList aCellRanges;
-    // first pass - gets the set of all possible interections of Arg1..ArgN
-    RangesList intersections = lcl_intersections( vRanges );
-    // second pass - gets the intersections of the intersections ( don't ask, but this
-    // is what seems to happen )
-    if ( intersections.size() > 1)
-        intersections = lcl_intersections( intersections );
-    for( RangesList::iterator it = intersections.begin(); it != intersections.end(); ++it )
-    {
-        for ( USHORT x = 0 ; x < it->Count(); ++x )
-#ifndef OWN_JOIN
-            aCellRanges.Join( *it->GetObject(x) );
-#else
-            aCellRanges.Append( *it->GetObject(x) );
-#endif
+        // if any range has been erased, repeat outer loop with the same range
+        if( !bAnyErased )
+            ++aOuterIt;
     }
+}
 
-    uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
-    ScDocShell* pDocShell = excel::getDocShell( xModel );
-    if ( aCellRanges.Count() == 1 )
-    {
-                uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pDocShell, *aCellRanges.First() ));
-        xRefRange = new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), mxContext, xRange );
-    }
-    else if ( aCellRanges.Count() > 1 )
+/** Intersects the passed list with all ranges of a VBA Range object in the passed Any. */
+void lclIntersectRanges( ListOfScRange& rList, const uno::Any& rArg )
+        throw (script::BasicErrorException, uno::RuntimeException)
+{
+    // extract the ranges from the passed argument, will throw on invalid data
+    ListOfScRange aList2;
+    lclAddToListOfScRange( aList2, rArg );
+    // do nothing, if the passed list is already empty
+    if( !rList.empty() && !aList2.empty() )
     {
-        uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDocShell, aCellRanges ) );
-        xRefRange = new ScVbaRange( excel::getUnoSheetModuleObj( xRanges ) , mxContext, xRanges );
-
+        // save original list in a local
+        ListOfScRange aList1;
+        aList1.swap( rList );
+        // join ranges from passed argument
+        lclJoinRanges( aList2 );
+        // calculate intersection of the ranges in both lists
+        for( ListOfScRange::const_iterator aOuterIt = aList1.begin(), aOuterEnd = aList1.end(); aOuterIt != aOuterEnd; ++aOuterIt )
+        {
+            for( ListOfScRange::const_iterator aInnerIt = aList2.begin(), aInnerEnd = aList2.end(); aInnerIt != aInnerEnd; ++aInnerIt )
+            {
+                if( aOuterIt->Intersects( *aInnerIt ) )
+                {
+                    ScRange aIsectRange(
+                        Max( aOuterIt->aStart.Col(), aInnerIt->aStart.Col() ),
+                        Max( aOuterIt->aStart.Row(), aInnerIt->aStart.Row() ),
+                        Max( aOuterIt->aStart.Tab(), aInnerIt->aStart.Tab() ),
+                        Min( aOuterIt->aEnd.Col(),   aInnerIt->aEnd.Col() ),
+                        Min( aOuterIt->aEnd.Row(),   aInnerIt->aEnd.Row() ),
+                        Min( aOuterIt->aEnd.Tab(),   aInnerIt->aEnd.Tab() ) );
+                    rList.push_back( aIsectRange );
+                }
+            }
+        }
+        // again, join the result ranges
+        lclJoinRanges( rList );
     }
-    return xRefRange;
 }
 
-uno::Reference< excel::XRange > SAL_CALL 
-ScVbaApplication::Union( const uno::Reference< excel::XRange >& Arg1, const uno::Reference< excel::XRange >& Arg2, const uno::Any& Arg3, const uno::Any& Arg4, const uno::Any& Arg5, const uno::Any& Arg6, const uno::Any& Arg7, const uno::Any& Arg8, const uno::Any& Arg9, const uno::Any& Arg10, const uno::Any& Arg11, const uno::Any& Arg12, const uno::Any& Arg13, const uno::Any& Arg14, const uno::Any& Arg15, const uno::Any& Arg16, const uno::Any& Arg17, const uno::Any& Arg18, const uno::Any& Arg19, const uno::Any& Arg20, const uno::Any& Arg21, const uno::Any& Arg22, const uno::Any& Arg23, const uno::Any& Arg24, const uno::Any& Arg25, const uno::Any& Arg26, const uno::Any& Arg27, const uno::Any& Arg28, const uno::Any& Arg29, const uno::Any& Arg30 ) throw (script::BasicErrorException, uno::RuntimeException)
+/** Creates a VBA Range object from the passed list of ranges. */
+uno::Reference< excel::XRange > lclCreateVbaRange(
+        const uno::Reference< uno::XComponentContext >& rxContext,
+        const uno::Reference< frame::XModel >& rxModel,
+        const ListOfScRange& rList ) throw (uno::RuntimeException)
 {
-    if ( !Arg1.is() || !Arg2.is() )
-        DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
-
-    uno::Reference< excel::XRange > xRange;
-    Ranges vRanges;
-    lcl_addRangeToVec( vRanges, uno::makeAny( Arg1 ) );
-    lcl_addRangeToVec( vRanges, uno::makeAny( Arg2 ) );
-
-    if ( Arg3.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg3 );
-    if ( Arg4.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg4 );
-    if ( Arg5.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg5 );
-    if ( Arg6.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg6 );
-    if ( Arg7.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg7 );
-    if ( Arg8.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg8 );
-    if ( Arg9.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg9 );
-    if ( Arg10.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg10 );
-    if ( Arg11.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg11 );
-    if ( Arg12.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg12 );
-    if ( Arg13.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg13 );
-    if ( Arg14.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg14 );
-    if ( Arg15.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg15 );
-    if ( Arg16.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg16 );
-    if ( Arg17.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg17 );
-    if ( Arg18.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg18 );
-    if ( Arg19.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg19 );
-    if ( Arg20.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg20 );
-    if ( Arg21.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg21 );
-    if ( Arg22.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg22 );
-    if ( Arg23.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg23 );
-    if ( Arg24.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg24 );
-    if ( Arg25.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg25 );
-    if ( Arg26.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg26 );
-    if ( Arg27.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg27 );
-    if ( Arg28.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg28 );
-    if ( Arg29.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg29 );
-    if ( Arg30.hasValue() )
-        lcl_addRangeToVec( vRanges, Arg30 );
+    ScDocShell* pDocShell = excel::getDocShell( rxModel );
+    if( !pDocShell ) throw uno::RuntimeException();
 
     ScRangeList aCellRanges;
-    lcl_strip_containedRanges( vRanges );
-
-    for( Ranges::iterator it = vRanges.begin(); it != vRanges.end(); ++it )
-        aCellRanges.Append( *it );
+    for( ListOfScRange::const_iterator aIt = rList.begin(), aEnd = rList.end(); aIt != aEnd; ++aIt )
+        aCellRanges.Append( *aIt );
 
-    uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
-    ScDocShell* pDocShell = excel::getDocShell( xModel ); 
-    if ( aCellRanges.Count() == 1 ) 
+    if( aCellRanges.Count() == 1 )
     {
-    // normal range
-                uno::Reference< table::XCellRange > xCalcRange( new ScCellRangeObj( pDocShell, *aCellRanges.First() ) );
-        xRange = new ScVbaRange( excel::getUnoSheetModuleObj( xCalcRange ), mxContext, xCalcRange );
+        uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pDocShell, *aCellRanges.First() ) );
+        return new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), rxContext, xRange );
     }
-    else if ( aCellRanges.Count() > 1 ) // Multi-Area
+    if( aCellRanges.Count() > 1 )
     {
         uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDocShell, aCellRanges ) );
-        xRange = new ScVbaRange( excel::getUnoSheetModuleObj( xRanges ), mxContext, xRanges );
+        return new ScVbaRange( excel::getUnoSheetModuleObj( xRanges ), rxContext, xRanges );
     }
+    return 0;
+}
+
+} // namespace
+
+// ----------------------------------------------------------------------------
+
+uno::Reference< excel::XRange > SAL_CALL ScVbaApplication::Intersect(
+        const uno::Reference< excel::XRange >& rArg1, const uno::Reference< excel::XRange >& rArg2,
+        const uno::Any& rArg3, const uno::Any& rArg4, const uno::Any& rArg5, const uno::Any& rArg6,
+        const uno::Any& rArg7, const uno::Any& rArg8, const uno::Any& rArg9, const uno::Any& rArg10,
+        const uno::Any& rArg11, const uno::Any& rArg12, const uno::Any& rArg13, const uno::Any& rArg14,
+        const uno::Any& rArg15, const uno::Any& rArg16, const uno::Any& rArg17, const uno::Any& rArg18,
+        const uno::Any& rArg19, const uno::Any& rArg20, const uno::Any& rArg21, const uno::Any& rArg22,
+        const uno::Any& rArg23, const uno::Any& rArg24, const uno::Any& rArg25, const uno::Any& rArg26,
+        const uno::Any& rArg27, const uno::Any& rArg28, const uno::Any& rArg29, const uno::Any& rArg30 )
+        throw (script::BasicErrorException, uno::RuntimeException)
+{
+    if( !rArg1.is() || !rArg2.is() )
+        DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
+
+    // initialize the result list with 1st parameter, join its ranges together
+    ListOfScRange aList;
+    lclAddToListOfScRange( aList, uno::Any( rArg1 ) );
+    lclJoinRanges( aList );
+
+    // process all other parameters, this updates the list with intersection
+    lclIntersectRanges( aList, uno::Any( rArg2 ) );
+    lclIntersectRanges( aList, rArg3 );
+    lclIntersectRanges( aList, rArg4 );
+    lclIntersectRanges( aList, rArg5 );
+    lclIntersectRanges( aList, rArg6 );
+    lclIntersectRanges( aList, rArg7 );
+    lclIntersectRanges( aList, rArg8 );
+    lclIntersectRanges( aList, rArg9 );
+    lclIntersectRanges( aList, rArg10 );
+    lclIntersectRanges( aList, rArg11 );
+    lclIntersectRanges( aList, rArg12 );
+    lclIntersectRanges( aList, rArg13 );
+    lclIntersectRanges( aList, rArg14 );
+    lclIntersectRanges( aList, rArg15 );
+    lclIntersectRanges( aList, rArg16 );
+    lclIntersectRanges( aList, rArg17 );
+    lclIntersectRanges( aList, rArg18 );
+    lclIntersectRanges( aList, rArg19 );
+    lclIntersectRanges( aList, rArg20 );
+    lclIntersectRanges( aList, rArg21 );
+    lclIntersectRanges( aList, rArg22 );
+    lclIntersectRanges( aList, rArg23 );
+    lclIntersectRanges( aList, rArg24 );
+    lclIntersectRanges( aList, rArg25 );
+    lclIntersectRanges( aList, rArg26 );
+    lclIntersectRanges( aList, rArg27 );
+    lclIntersectRanges( aList, rArg28 );
+    lclIntersectRanges( aList, rArg29 );
+    lclIntersectRanges( aList, rArg30 );
+
+    // create the VBA Range object
+    return lclCreateVbaRange( mxContext, getCurrentDocument(), aList );
+}
+
+uno::Reference< excel::XRange > SAL_CALL ScVbaApplication::Union(
+        const uno::Reference< excel::XRange >& rArg1, const uno::Reference< excel::XRange >& rArg2,
+        const uno::Any& rArg3, const uno::Any& rArg4, const uno::Any& rArg5, const uno::Any& rArg6,
+        const uno::Any& rArg7, const uno::Any& rArg8, const uno::Any& rArg9, const uno::Any& rArg10,
+        const uno::Any& rArg11, const uno::Any& rArg12, const uno::Any& rArg13, const uno::Any& rArg14,
+        const uno::Any& rArg15, const uno::Any& rArg16, const uno::Any& rArg17, const uno::Any& rArg18,
+        const uno::Any& rArg19, const uno::Any& rArg20, const uno::Any& rArg21, const uno::Any& rArg22,
+        const uno::Any& rArg23, const uno::Any& rArg24, const uno::Any& rArg25, const uno::Any& rArg26,
+        const uno::Any& rArg27, const uno::Any& rArg28, const uno::Any& rArg29, const uno::Any& rArg30 )
+        throw (script::BasicErrorException, uno::RuntimeException)
+{
+    if( !rArg1.is() || !rArg2.is() )
+        DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
+
+    ListOfScRange aList;
+    lclAddToListOfScRange( aList, uno::Any( rArg1 ) );
+    lclAddToListOfScRange( aList, uno::Any( rArg2 ) );
+    lclAddToListOfScRange( aList, rArg3 );
+    lclAddToListOfScRange( aList, rArg4 );
+    lclAddToListOfScRange( aList, rArg5 );
+    lclAddToListOfScRange( aList, rArg6 );
+    lclAddToListOfScRange( aList, rArg7 );
+    lclAddToListOfScRange( aList, rArg8 );
+    lclAddToListOfScRange( aList, rArg9 );
+    lclAddToListOfScRange( aList, rArg10 );
+    lclAddToListOfScRange( aList, rArg11 );
+    lclAddToListOfScRange( aList, rArg12 );
+    lclAddToListOfScRange( aList, rArg13 );
+    lclAddToListOfScRange( aList, rArg14 );
+    lclAddToListOfScRange( aList, rArg15 );
+    lclAddToListOfScRange( aList, rArg16 );
+    lclAddToListOfScRange( aList, rArg17 );
+    lclAddToListOfScRange( aList, rArg18 );
+    lclAddToListOfScRange( aList, rArg19 );
+    lclAddToListOfScRange( aList, rArg20 );
+    lclAddToListOfScRange( aList, rArg21 );
+    lclAddToListOfScRange( aList, rArg22 );
+    lclAddToListOfScRange( aList, rArg23 );
+    lclAddToListOfScRange( aList, rArg24 );
+    lclAddToListOfScRange( aList, rArg25 );
+    lclAddToListOfScRange( aList, rArg26 );
+    lclAddToListOfScRange( aList, rArg27 );
+    lclAddToListOfScRange( aList, rArg28 );
+    lclAddToListOfScRange( aList, rArg29 );
+    lclAddToListOfScRange( aList, rArg30 );
+
+    // simply join together all ranges as much as possible, strip out covered ranges etc.
+    lclJoinRanges( aList );
     
-    // #FIXME need proper (WorkSheet) parent
-    return xRange;
+    // create the VBA Range object
+    return lclCreateVbaRange( mxContext, getCurrentDocument(), aList );
 }
 
 void
commit 5fa3d6e55b2ab5aac185c10293f8c6a1b7264e63
Author: Daniel Rentz <dr at openoffice.org>
Date:   Wed Aug 4 09:59:00 2010 +0200

    mib18: #163198# VBA Names collection must return VBA Name objects

diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx
index f993aee..6a32914 100644
--- a/sc/source/ui/vba/vbanames.cxx
+++ b/sc/source/ui/vba/vbanames.cxx
@@ -173,11 +173,6 @@ ScVbaNames::getElementType() throw( css::uno::RuntimeException )
 uno::Reference< container::XEnumeration >
 ScVbaNames::createEnumeration() throw (uno::RuntimeException)
 {
-    if ( mxNames.is() )
-    {
-        uno::Reference< container::XEnumerationAccess > xAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
-        return xAccess->createEnumeration();
-    }
     uno::Reference< container::XEnumerationAccess > xEnumAccess( mxNames, uno::UNO_QUERY_THROW );
     return new NamesEnumeration( this, mxContext, xEnumAccess->createEnumeration(), mxModel , mxNames );
 }
commit 783c57ec2174b11b06ec29ecb1ae6b9b87996bf6
Author: Daniel Rentz <dr at openoffice.org>
Date:   Wed Aug 4 09:58:00 2010 +0200

    mib18: #163195# set correct parent for range returned by VBA ActiveCell symbol

diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index 63db284..bf6d4e2 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -302,7 +302,8 @@ ScVbaApplication::getActiveCell() throw (uno::RuntimeException )
     sal_Int32 nCursorX = pTabView->GetCurX();
     sal_Int32 nCursorY = pTabView->GetCurY();
 
-    return  new ScVbaRange( this, mxContext, xRange->getCellRangeByPosition( nCursorX, nCursorY, nCursorX, nCursorY ) );
+    uno::Reference< XHelperInterface > xParent( excel::getUnoSheetModuleObj( xRange ), uno::UNO_QUERY_THROW );
+    return new ScVbaRange( xParent, mxContext, xRange->getCellRangeByPosition( nCursorX, nCursorY, nCursorX, nCursorY ) );
 }
 
 uno::Any SAL_CALL
commit 32876274fc8fae906bdb52e76059ddedadfa8572
Author: Daniel Rentz <dr at openoffice.org>
Date:   Wed Aug 4 09:56:54 2010 +0200

    mib18: #162937# extract all integer and floating values from an 'Any' for Boolean parameters

diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 50a0057..c3ae2d8 100755
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -2315,8 +2315,7 @@ ScVbaRange::Columns(const uno::Any& aIndex ) throw (uno::RuntimeException)
 void
 ScVbaRange::setMergeCells( const uno::Any& aIsMerged ) throw (script::BasicErrorException, uno::RuntimeException)
 {
-    bool bMerge = false;
-    aIsMerged >>= bMerge;
+    bool bMerge = extractBoolFromAny( aIsMerged );
 
     if( mxRanges.is() )
     {
@@ -2517,7 +2516,8 @@ ScVbaRange::setWrapText( const uno::Any& aIsWrapped ) throw (script::BasicErrorE
     }
 
     uno::Reference< beans::XPropertySet > xProps(mxRange, ::uno::UNO_QUERY_THROW );
-    xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsTextWrapped" ) ), aIsWrapped );
+    bool bIsWrapped = extractBoolFromAny( aIsWrapped );
+    xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsTextWrapped" ) ), uno::Any( bIsWrapped ) );
 }
                                                                                                                              
 uno::Any
@@ -2896,13 +2896,11 @@ ScVbaRange::setHidden( const uno::Any& _hidden ) throw (uno::RuntimeException)
         return;
     }
 
-    sal_Bool bHidden = sal_False;
-    _hidden >>= bHidden;
-
+    bool bHidden = extractBoolFromAny( _hidden );
     try
     {
         uno::Reference< beans::XPropertySet > xProps = getRowOrColumnProps( mxRange, mbIsRows );
-        xProps->setPropertyValue( ISVISIBLE, uno::makeAny( !bHidden ) );
+        xProps->setPropertyValue( ISVISIBLE, uno::Any( !bHidden ) );
     }
     catch( uno::Exception& e )
     {
@@ -4931,8 +4929,7 @@ void ScVbaRange::setShowDetail(const uno::Any& aShowDetail) throw ( css::uno::Ru
     if( m_Areas->getCount() > 1 )
         throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can not set Range.ShowDetail attribute ")), uno::Reference< uno::XInterface >() );
     
-    sal_Bool bShowDetail = sal_False;
-    aShowDetail >>= bShowDetail;
+    bool bShowDetail = extractBoolFromAny( aShowDetail );
 
     RangeHelper helper( mxRange );
     uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor = helper.getSheetCellCursor();
commit faa445a0730322e8522999ffb30fdde97bb9b9b9
Author: Daniel Rentz <dr at openoffice.org>
Date:   Wed Aug 4 09:54:13 2010 +0200

    mib18: #162039# clear covered cells when merging via VBA MergeCells symbol

diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 8fcfcd5..50a0057 100755
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -1206,6 +1206,14 @@ inline table::CellRangeAddress lclGetRangeAddress( const uno::Reference< RangeTy
     return uno::Reference< sheet::XCellRangeAddressable >( rxCellRange, uno::UNO_QUERY_THROW )->getRangeAddress();
 }
 
+void lclClearRange( const uno::Reference< table::XCellRange >& rxCellRange ) throw (uno::RuntimeException)
+{
+    using namespace ::com::sun::star::sheet::CellFlags;
+    sal_Int32 nFlags = VALUE | DATETIME | STRING | ANNOTATION | FORMULA | HARDATTR | STYLES | EDITATTR | FORMATTED;
+    uno::Reference< sheet::XSheetOperation > xSheetOperation( rxCellRange, uno::UNO_QUERY_THROW );
+    xSheetOperation->clearContents( nFlags );
+}
+
 uno::Reference< sheet::XSheetCellRange > lclExpandToMerged( const uno::Reference< table::XCellRange >& rxCellRange, bool bRecursive ) throw (uno::RuntimeException)
 {
     uno::Reference< sheet::XSheetCellRange > xNewCellRange( rxCellRange, uno::UNO_QUERY_THROW );
@@ -1251,15 +1259,27 @@ void lclExpandAndMerge( const uno::Reference< table::XCellRange >& rxCellRange,
     // Calc cannot merge over merged ranges, always unmerge first
     xMerge->merge( sal_False );
     if( bMerge )
+    {
+        // clear all contents of the covered cells (not the top-left cell)
+        table::CellRangeAddress aRangeAddr = lclGetRangeAddress( rxCellRange );
+        sal_Int32 nLastColIdx = aRangeAddr.EndColumn - aRangeAddr.StartColumn;
+        sal_Int32 nLastRowIdx = aRangeAddr.EndRow - aRangeAddr.StartRow;
+        // clear cells of top row, right of top-left cell
+        if( nLastColIdx > 0 )
+            lclClearRange( rxCellRange->getCellRangeByPosition( 1, 0, nLastColIdx, 0 ) );
+        // clear all rows below top row
+        if( nLastRowIdx > 0 )
+            lclClearRange( rxCellRange->getCellRangeByPosition( 0, 1, nLastColIdx, nLastRowIdx ) );
+        // merge the range
         xMerge->merge( sal_True );
-    // FIXME need to check whether all the cell contents are retained or lost by popping up a dialog
+    }
 }
 
 util::TriState lclGetMergedState( const uno::Reference< table::XCellRange >& rxCellRange ) throw (uno::RuntimeException)
 {
     /*  1) Check if range is completely inside one single merged range. To do
         this, try to extend from top-left cell only (not from entire range).
-        This will excude cases where this range consists of several merged
+        This will exclude cases where this range consists of several merged
         ranges (or parts of them). */
     table::CellRangeAddress aRangeAddr = lclGetRangeAddress( rxCellRange );
     uno::Reference< table::XCellRange > xTopLeft( rxCellRange->getCellRangeByPosition( 0, 0, 0, 0 ), uno::UNO_SET_THROW );
@@ -1508,7 +1528,8 @@ ScVbaRange::setValue( const uno::Any  &aValue ) throw (uno::RuntimeException)
 void
 ScVbaRange::Clear() throw (uno::RuntimeException)
 {
-    sal_Int32 nFlags = sheet::CellFlags::VALUE | sheet::CellFlags::STRING | sheet::CellFlags::HARDATTR | sheet::CellFlags::FORMATTED | sheet::CellFlags::EDITATTR | sheet::CellFlags::FORMULA;
+    using namespace ::com::sun::star::sheet::CellFlags;
+    sal_Int32 nFlags = VALUE | DATETIME | STRING | FORMULA | HARDATTR | EDITATTR | FORMATTED;
     ClearContents( nFlags );
 }
 


More information about the ooo-build-commit mailing list