summaryrefslogtreecommitdiff
path: root/sc/source/core/tool
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2010-10-06 10:15:43 +0100
committerNoel Power <noel.power@novell.com>2010-10-06 10:15:43 +0100
commitf13fd7b138caee676cf5dbeae3474e4a4b0b177a (patch)
tree58bbab934d3fd26a8fd886a2dbc52b5a2d283092 /sc/source/core/tool
parent44231089eeda805727f6c7143729612059891b02 (diff)
initial commit for vba blob ( not including container_control stuff )
Diffstat (limited to 'sc/source/core/tool')
-rw-r--r--sc/source/core/tool/address.cxx2
-rw-r--r--sc/source/core/tool/appoptio.cxx4
-rw-r--r--sc/source/core/tool/interpr1.cxx13
-rw-r--r--sc/source/core/tool/interpr4.cxx134
-rw-r--r--sc/source/core/tool/interpr5.cxx5
-rw-r--r--sc/source/core/tool/rangelst.cxx19
6 files changed, 151 insertions, 26 deletions
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 462bcd042c86..00bd35c1b1a3 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -1367,7 +1367,7 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const String& r, ScDocument* pDoc, ScAdd
}
nRes1 = ( ( nRes1 | nRes2 ) & SCA_VALID )
| nRes1
- | ( ( nRes2 & 0x070F ) << 4 );
+ | ( ( nRes2 & SCA_BITS ) << 4 );
return nRes1;
}
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index 857efd972886..958db9806b13 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -82,6 +82,9 @@ ScAppOptions::~ScAppOptions()
void ScAppOptions::SetDefaults()
{
+ // Set default tab count for new spreadsheet.
+ nTabCountInNewSpreadsheet = 3;
+
if ( ScOptionsUtil::IsMetricSystem() )
eMetric = FUNIT_CM; // default for countries with metric system
else
@@ -119,6 +122,7 @@ void ScAppOptions::SetDefaults()
const ScAppOptions& ScAppOptions::operator=( const ScAppOptions& rCpy )
{
+ nTabCountInNewSpreadsheet = rCpy.nTabCountInNewSpreadsheet;
eMetric = rCpy.eMetric;
eZoomType = rCpy.eZoomType;
bSynchronizeZoom = rCpy.bSynchronizeZoom;
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 1e4c02967152..601b0546b869 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -71,6 +71,7 @@
#include "rangenam.hxx"
#include "compiler.hxx"
#include "externalrefmgr.hxx"
+#include <basic/sbstar.hxx>
#include "doubleref.hxx"
#include "queryparam.hxx"
@@ -4177,7 +4178,17 @@ void ScInterpreter::ScMatch()
}
}
if ( rEntry.bQueryByString )
- rParam.bRegExp = MayBeRegExp( *rEntry.pStr, pDok );
+ {
+ BOOL bIsVBAMode = FALSE;
+ if ( pDok )
+ bIsVBAMode = pDok->IsInVBAMode();
+
+ // #TODO handle MSO wildcards
+ if ( bIsVBAMode )
+ rParam.bRegExp = FALSE;
+ else
+ rParam.bRegExp = MayBeRegExp( *rEntry.pStr, pDok );
+ }
if (pMatSrc) // The source data is matrix array.
{
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 47cde7186067..542557cdb171 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -33,10 +33,14 @@
#include <sfx2/app.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/objsh.hxx>
+#include <sfx2/docfilt.hxx>
#include <basic/sbmeth.hxx>
#include <basic/sbmod.hxx>
#include <basic/sbstar.hxx>
#include <basic/sbx.hxx>
+#include <basic/sbxobj.hxx>
+#include <basic/sbuno.hxx>
+#include <svl/zforlist.hxx>
#include <svl/zforlist.hxx>
#include <tools/urlobj.hxx>
#include <rtl/logfile.hxx>
@@ -45,6 +49,8 @@
#include <signal.h>
#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XSheetCellRange.hpp>
+#include <comphelper/processfactory.hxx>
#include "interpre.hxx"
#include "global.hxx"
@@ -65,6 +71,8 @@
#include "jumpmatrix.hxx"
#include "parclass.hxx"
#include "externalrefmgr.hxx"
+#include "formula/FormulaCompiler.hxx"
+#include "macromgr.hxx"
#include "doubleref.hxx"
#include <math.h>
@@ -72,6 +80,8 @@
#include <map>
#include <algorithm>
#include <functional>
+#include <basic/basmgr.hxx>
+#include <vbahelper/vbaaccesshelper.hxx>
#include <memory>
using namespace com::sun::star;
@@ -2689,6 +2699,61 @@ void ScInterpreter::ScMissing()
PushTempToken( new FormulaMissingToken );
}
+uno::Any lcl_getSheetModule( const uno::Reference<table::XCellRange>& xCellRange, ScDocument* pDok )
+{
+ uno::Reference< sheet::XSheetCellRange > xSheetRange( xCellRange, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xSheetRange->getSpreadsheet(), uno::UNO_QUERY_THROW );
+ rtl::OUString sCodeName;
+ xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CodeName") ) ) >>= sCodeName;
+ // #TODO #FIXME ideally we should 'throw' here if we don't get a valid parent, but... it is possible
+ // to create a module ( and use 'Option VBASupport 1' ) for a calc document, in this scenario there
+ // are *NO* special document module objects ( of course being able to switch between vba/non vba mode at
+ // the document in the future could fix this, especially IF the switching of the vba mode takes care to
+ // create the special document module objects if they don't exist.
+ BasicManager* pBasMgr = pDok->GetDocumentShell()->GetBasicManager();
+
+ uno::Reference< uno::XInterface > xIf;
+ if ( pBasMgr && pBasMgr->GetName().Len() )
+ {
+ String sProj = String( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
+ if ( pDok->GetDocumentShell()->GetBasicManager()->GetName().Len() )
+ sProj = pDok->GetDocumentShell()->GetBasicManager()->GetName();
+ StarBASIC* pBasic = pDok->GetDocumentShell()->GetBasicManager()->GetLib( sProj );
+ if ( pBasic )
+ {
+ SbModule* pMod = pBasic->FindModule( sCodeName );
+ if ( pMod )
+ xIf = pMod->GetUnoModule();
+ }
+ }
+ return uno::makeAny( xIf );
+}
+
+bool
+lcl_setVBARange( ScRange& aRange, ScDocument* pDok, SbxVariable* pPar )
+{
+ bool bOk = false;
+ try
+ {
+ uno::Reference< uno::XInterface > xVBARange;
+ uno::Reference<table::XCellRange> xCellRange = ScCellRangeObj::CreateRangeFromDoc( pDok, aRange );
+ uno::Sequence< uno::Any > aArgs(2);
+ aArgs[0] = lcl_getSheetModule( xCellRange, pDok );
+ aArgs[1] = uno::Any( xCellRange );
+ xVBARange = ooo::vba::createVBAUnoAPIServiceWithArgs( pDok->GetDocumentShell(), "ooo.vba.excel.Range", aArgs );
+ if ( xVBARange.is() )
+ {
+ String sDummy(RTL_CONSTASCII_USTRINGPARAM("A-Range") );
+ SbxObjectRef aObj = GetSbUnoObject( sDummy, uno::Any( xVBARange ) );
+ SetSbUnoObjectDfltPropName( aObj );
+ bOk = pPar->PutObject( aObj );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return bOk;
+}
void ScInterpreter::ScMacro()
{
@@ -2726,8 +2791,11 @@ void ScInterpreter::ScMacro()
return;
}
+ bool bVolatileMacro = false;
SbMethod* pMethod = (SbMethod*)pVar;
+
SbModule* pModule = pMethod->GetModule();
+ bool bUseVBAObjects = pModule->IsVBACompat();
SbxObject* pObject = pModule->GetParent();
DBG_ASSERT(pObject->IsA(TYPE(StarBASIC)), "Kein Basic gefunden!");
String aMacroStr = pObject->GetName();
@@ -2737,7 +2805,13 @@ void ScInterpreter::ScMacro()
aMacroStr += pMethod->GetName();
String aBasicStr;
if (pObject->GetParent())
+ {
aBasicStr = pObject->GetParent()->GetName(); // Dokumentenbasic
+ const SfxFilter* pFilter = NULL;
+ SfxMedium* pMedium = pDok->GetDocumentShell()->GetMedium();
+ if ( pMedium )
+ pFilter = pMedium->GetFilter();
+ }
else
aBasicStr = SFX_APP()->GetName(); // Applikationsbasic
@@ -2761,7 +2835,13 @@ void ScInterpreter::ScMacro()
{
ScAddress aAdr;
PopSingleRef( aAdr );
- bOk = SetSbxVariable( pPar, aAdr );
+ if ( bUseVBAObjects )
+ {
+ ScRange aRange( aAdr );
+ bOk = lcl_setVBARange( aRange, pDok, pPar );
+ }
+ else
+ bOk = SetSbxVariable( pPar, aAdr );
}
break;
case svDoubleRef:
@@ -2780,24 +2860,32 @@ void ScInterpreter::ScMacro()
}
else
{
- SbxDimArrayRef refArray = new SbxDimArray;
- refArray->AddDim32( 1, nRow2 - nRow1 + 1 );
- refArray->AddDim32( 1, nCol2 - nCol1 + 1 );
- ScAddress aAdr( nCol1, nRow1, nTab1 );
- for( SCROW nRow = nRow1; bOk && nRow <= nRow2; nRow++ )
+ if ( bUseVBAObjects )
{
- aAdr.SetRow( nRow );
- INT32 nIdx[ 2 ];
- nIdx[ 0 ] = nRow-nRow1+1;
- for( SCCOL nCol = nCol1; bOk && nCol <= nCol2; nCol++ )
+ ScRange aRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
+ bOk = lcl_setVBARange( aRange, pDok, pPar );
+ }
+ else
+ {
+ SbxDimArrayRef refArray = new SbxDimArray;
+ refArray->AddDim32( 1, nRow2 - nRow1 + 1 );
+ refArray->AddDim32( 1, nCol2 - nCol1 + 1 );
+ ScAddress aAdr( nCol1, nRow1, nTab1 );
+ for( SCROW nRow = nRow1; bOk && nRow <= nRow2; nRow++ )
{
- aAdr.SetCol( nCol );
- nIdx[ 1 ] = nCol-nCol1+1;
- SbxVariable* p = refArray->Get32( nIdx );
- bOk = SetSbxVariable( p, aAdr );
+ aAdr.SetRow( nRow );
+ INT32 nIdx[ 2 ];
+ nIdx[ 0 ] = nRow-nRow1+1;
+ for( SCCOL nCol = nCol1; bOk && nCol <= nCol2; nCol++ )
+ {
+ aAdr.SetCol( nCol );
+ nIdx[ 1 ] = nCol-nCol1+1;
+ SbxVariable* p = refArray->Get32( nIdx );
+ bOk = SetSbxVariable( p, aAdr );
+ }
}
+ pPar->PutObject( refArray );
}
- pPar->PutObject( refArray );
}
}
break;
@@ -2845,6 +2933,13 @@ void ScInterpreter::ScMacro()
pDok->DecMacroInterpretLevel();
pDok->UnlockTable( aPos.Tab() );
+ ScMacroManager* pMacroMgr = pDok->GetMacroManager();
+ if (pMacroMgr)
+ {
+ bVolatileMacro = pMacroMgr->GetUserFuncVolatile( pMethod->GetName() );
+ pMacroMgr->AddDependentCell(pModule->GetName(), pMyFormulaCell);
+ }
+
SbxDataType eResType = refRes->GetType();
if( pVar->GetError() )
SetError( errNoValue);
@@ -2916,6 +3011,9 @@ void ScInterpreter::ScMacro()
}
pSfxApp->LeaveBasicCall();
+
+ if (bVolatileMacro && meVolaileType == NOT_VOLATILE)
+ meVolaileType = VOLATILE_MACRO;
}
@@ -3288,7 +3386,8 @@ ScInterpreter::ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc,
pMyFormulaCell( pCell ),
pFormatter( pDoc->GetFormatTable() ),
mnStringNoValueError( errNoValue),
- bCalcAsShown( pDoc->GetDocOptions().IsCalcAsShown() )
+ bCalcAsShown( pDoc->GetDocOptions().IsCalcAsShown() ),
+ meVolaileType(NOT_VOLATILE)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScTTT" );
// pStack = new ScToken*[ MAXSTACK ];
@@ -3735,6 +3834,9 @@ StackVar ScInterpreter::Interpret()
continue; // while( ( pCur = aCode.Next() ) != NULL ...
}
+ if (FormulaCompiler::IsOpCodeVolatile(eOp))
+ meVolaileType = VOLATILE;
+
// Remember result matrix in case it could be reused.
if (pTokenMatrixMap && sp && GetStackType() == svMatrix)
pTokenMatrixMap->insert( ScTokenMatrixMap::value_type( pCur,
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 73794cf15b2d..a51b4b256712 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -324,6 +324,11 @@ ScMatrixRef ScInterpreter::GetNewMat(SCSIZE nC, SCSIZE nR)
return pMat;
}
+ScInterpreter::VolatileType ScInterpreter::GetVolatileType() const
+{
+ return meVolaileType;
+}
+
ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken,
SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
SCCOL nCol2, SCROW nRow2, SCTAB nTab2 )
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index 1ab978866c67..11935a6e7d00 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -83,15 +83,18 @@ USHORT ScRangeList::Parse( const String& rStr, ScDocument* pDoc, USHORT nMask,
for ( USHORT i=0; i<nTCount; i++ )
{
aOne = rStr.GetToken( i, cDelimiter );
- // FIXME : broken for Lotus
- if ( aOne.Search( ':' ) == STRING_NOTFOUND )
- { // Range muss es sein
- String aStrTmp( aOne );
- aOne += ':';
- aOne += aStrTmp;
- }
aRange.aStart.SetTab( nTab ); // Default Tab wenn nicht angegeben
- USHORT nRes = aRange.Parse( aOne, pDoc, eConv );
+ USHORT nRes = aRange.ParseAny( aOne, pDoc, eConv );
+ USHORT nEndRangeBits = SCA_VALID_COL2 | SCA_VALID_ROW2 |
+SCA_VALID_TAB2;
+ USHORT nTmp1 = ( nRes & SCA_BITS );
+ USHORT nTmp2 = ( nRes & nEndRangeBits );
+ // If we have a valid single range with
+ // any of the address bits we are interested in
+ // set - set the equiv end range bits
+ if ( (nRes & SCA_VALID ) && nTmp1 && ( nTmp2 != nEndRangeBits ) )
+ nRes |= ( nTmp1 << 4 );
+
if ( (nRes & nMask) == nMask )
Append( aRange );
nResult &= nRes; // alle gemeinsamen Bits bleiben erhalten