diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-01-08 10:47:13 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-01-08 10:47:13 +0000 |
commit | 87307aba9e8dbca16672e6df701d9f905b9e1786 (patch) | |
tree | c4c94029c34c3a5dc7e0ed2d6cee8cebc5d31e6b /sc/source | |
parent | b142ca03365a5a5bfd8487fda9bfeea2e6db0d0b (diff) |
CWS-TOOLING: integrate CWS frmdlg
2008-12-18 09:13:09 +0100 oj r265667 : merge from odff05
2008-12-18 07:58:16 +0100 oj r265658 : #i94555# patch from <regina>, ODFF:
Add GAMMA, CHISQDIST, CHISQINV.
Make the 'cumulative' parameter of GAMMADIST optional.
Adapt the domain of CHIDIST to allow negative x.
Remove the constraint "degrees of freedom < 1.0E5" from CHIDIST and CHIINV.
Plus a mechanism to write the now optional parameter of GAMMADIST to PODF and
ODFF if omitted, for backwards compatibility.
2008-12-15 14:06:11 +0100 oj r265490 : CWS-TOOLING: rebase CWS frmdlg to trunk@264807 (milestone: DEV300:m37)
2008-12-15 13:55:28 +0100 oj r265488 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:55:07 +0100 oj r265487 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:48 +0100 oj r265486 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:36 +0100 oj r265485 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:24 +0100 oj r265484 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:48:11 +0100 oj r265483 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:31:12 +0100 oj r265479 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:13:58 +0100 oj r265477 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:10:09 +0100 oj r265476 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:05:11 +0100 oj r265475 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:47:17 +0100 oj r265467 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:46:19 +0100 oj r265466 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:45:47 +0100 oj r265465 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 07:35:07 +0100 oj r265458 : add dependency to formula
2008-12-15 07:34:24 +0100 oj r265457 : add dependency to formula
2008-12-12 13:22:00 +0100 msc r265413 : #i97089#
2008-12-12 13:20:25 +0100 msc r265412 : #i97089#
2008-12-12 12:35:12 +0100 msc r265406 : #i97089#
2008-12-12 12:34:16 +0100 msc r265405 : #i97089#
2008-12-12 12:33:05 +0100 msc r265404 : #i97089#
2008-12-12 12:31:11 +0100 msc r265403 : #i97089#
2008-12-08 11:59:10 +0100 oj r264981 : insert RTL_LOG
2008-12-08 11:50:17 +0100 oj r264980 : some small changes
2008-12-05 12:57:57 +0100 oj r264902 : eof changed
2008-12-05 12:56:46 +0100 oj r264901 : eof changed
2008-12-05 12:28:47 +0100 oj r264899 : wrong var used
2008-12-05 10:08:57 +0100 oj r264890 : token order reversed
2008-12-04 13:49:22 +0100 oc r264843 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:45:27 +0100 oc r264842 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:42:54 +0100 oc r264841 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:37:41 +0100 oc r264840 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:34:11 +0100 oc r264839 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 12:35:31 +0100 oj r264835 : new help ids for struct and function tabpage
2008-12-04 12:00:35 +0100 oj r264828 : set explicit help id
2008-12-03 14:53:27 +0100 oj r264786 : #i96845# change ref button
2008-12-03 14:51:49 +0100 oj r264785 : #i96845# change ref button
2008-12-03 08:51:57 +0100 oj r264746 : convert dos to unix lineends
2008-12-03 08:50:45 +0100 oj r264745 : convert dos to unix lineends
2008-12-03 08:50:05 +0100 oj r264744 : convert dos to unix lineends
2008-12-02 12:28:33 +0100 oj r264686 : clear help text when new helpid is set
2008-12-02 12:28:02 +0100 oj r264685 : set help id for listbox category
2008-12-02 07:15:56 +0100 oj r264655 : remove define to auto generate help ids
2008-12-01 14:36:43 +0100 oj r264604 : use temp var
2008-12-01 14:18:31 +0100 oj r264601 : moved ScJumpToken to formula
2008-12-01 14:18:11 +0100 oj r264600 : moved ScJumpToken to formula
2008-12-01 14:14:35 +0100 oj r264599 : moved ScJumpToken from sc
2008-12-01 10:48:51 +0100 oj r264589 : change quickhelptext from Shrink to Select
2008-12-01 10:28:41 +0100 oj r264588 : fix opcode data, has to be Any.Void
2008-11-28 11:16:48 +0100 oj r264532 : add help ids
2008-11-28 10:16:56 +0100 oj r264529 : set help id
2008-11-28 10:16:43 +0100 oj r264528 : set help id
2008-11-26 13:55:04 +0100 oj r264381 : #94535# use of optional instead of deleting a string myself and some small changes
2008-11-26 09:53:20 +0100 oj r264346 : compile error with debug/without debug
2008-11-25 07:41:28 +0100 oj r264271 : put static into the method which make use of them
2008-11-24 08:16:07 +0100 oj r264196 : removed not needed classes for op code
2008-11-24 08:13:44 +0100 oj r264195 : removed not needed classes for op code
2008-11-21 14:05:53 +0100 oj r264135 : make GetOpCode inline
2008-11-21 12:35:27 +0100 oj r264124 : hold symbols
2008-11-20 09:27:27 +0100 oj r264028 : merged code from DEV300_m35 which got lost
2008-11-19 20:42:12 +0100 oj r264022 : more changes for formula dialog remove
2008-11-19 20:37:41 +0100 oj r264021 : removed unused var
2008-11-19 20:35:35 +0100 oj r264020 : some more changes at token
2008-11-19 10:59:47 +0100 oj r263967 : deleted
2008-11-19 10:58:24 +0100 oj r263966 : add forui and for res files
2008-11-18 15:27:36 +0100 oj r263777 : unused para removed
2008-11-18 15:23:23 +0100 oj r263775 : add insert button to add field dlg
2008-11-18 13:39:53 +0100 oj r263764 : enable the formula dialog as well for conditional print as for conditional formatting
2008-11-18 12:03:25 +0100 oj r263760 : rename isRef in IsRef
2008-11-17 11:46:16 +0100 oj r263711 : patches for function handling
2008-11-17 11:36:22 +0100 oj r263710 : add new for forui and res file
2008-11-17 09:21:12 +0100 oj r263704 : patches for some resource for libformula
2008-11-15 12:45:30 +0100 oj r263701 : changes for formula editor extraction
2008-11-07 08:23:27 +0100 oj r263416 : merge from DEV300:m35
2008-11-07 08:22:35 +0100 oj r263415 : merge from DEV300:m35
2008-11-07 08:22:16 +0100 oj r263414 : merge from DEV300:m35
2008-11-07 08:21:41 +0100 oj r263413 : merge from DEV300:m35
2008-11-07 08:21:31 +0100 oj r263412 : merge from DEV300:m35
2008-11-07 08:20:38 +0100 oj r263411 : merge from DEV300:m35
2008-11-07 08:20:00 +0100 oj r263410 : merge from DEV300:m35
2008-11-07 08:18:50 +0100 oj r263409 : merge from DEV300:m35
2008-11-07 08:18:19 +0100 oj r263408 : merge from DEV300:m35
2008-11-07 08:10:27 +0100 oj r263407 : merge from DEV300:m35
2008-10-21 07:43:46 +0200 oj r262560 : some compile errors resolved
2008-10-17 16:40:01 +0200 oj r262291 : dep for 1st target
2008-10-07 10:08:39 +0200 oj r262077 : copy
2008-10-07 09:45:31 +0200 oj r262076 : #i94535#
2008-10-07 09:44:26 +0200 oj r262075 : #i94535# new base class
2008-10-07 09:43:21 +0200 oj r262074 : moved to formula
2008-10-07 09:41:51 +0200 oj r262073 : new images
2008-10-07 09:03:01 +0200 oj r262072 : new ids for formula
2008-10-02 08:46:27 +0200 oj r262024 : #i94535# move the formula compiler to formula
2008-10-02 08:08:54 +0200 oj r262023 : #i94535#
2008-10-02 08:06:28 +0200 oj r262022 : #i94535#
2008-10-02 08:05:52 +0200 oj r262021 : #i94535#
2008-10-01 17:15:29 +0200 oj r262014 : #i94535#
2008-10-01 17:12:40 +0200 oj r262013 : new module formula
2008-10-01 17:04:55 +0200 oj r262012 : #i94535#
2008-10-01 16:49:03 +0200 oj r262010 : #i94535#
2008-10-01 16:46:59 +0200 oj r262009 : #i94535#
Diffstat (limited to 'sc/source')
162 files changed, 15507 insertions, 25560 deletions
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx index 1637eb3666ac..c3dd01f98970 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -58,6 +58,7 @@ #include <svx/flditem.hxx> #include <svtools/broadcast.hxx> +using namespace formula; // More or less arbitrary, of course all recursions must fit into available // stack space (which is what on all systems we don't know yet?). Choosing a // lower value may be better than trying a much higher value that also isn't @@ -216,8 +217,8 @@ void ScBaseCell::StartListeningTo( ScDocument* pDoc ) else { pArr->Reset(); - for( ScToken* t = pArr->GetNextReferenceRPN(); t; - t = pArr->GetNextReferenceRPN() ) + ScToken* t; + while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL ) { StackVar eType = t->GetType(); ScSingleRefData& rRef1 = t->GetSingleRef(); @@ -306,8 +307,8 @@ void ScBaseCell::EndListeningTo( ScDocument* pDoc, ScTokenArray* pArr, aPos = pFormCell->aPos; } pArr->Reset(); - for( ScToken* t = pArr->GetNextReferenceRPN(); t; - t = pArr->GetNextReferenceRPN() ) + ScToken* t; + while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL ) { StackVar eType = t->GetType(); ScSingleRefData& rRef1 = t->GetSingleRef(); @@ -503,8 +504,8 @@ BOOL ScBaseCell::CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ) { BOOL bEqual = TRUE; USHORT nLen = pCode1->GetLen(); - ScToken** ppToken1 = pCode1->GetArray(); - ScToken** ppToken2 = pCode2->GetArray(); + FormulaToken** ppToken1 = pCode1->GetArray(); + FormulaToken** ppToken2 = pCode2->GetArray(); for (USHORT i=0; i<nLen; i++) if ( !ppToken1[i]->TextEqual(*(ppToken2[i])) ) { @@ -532,7 +533,7 @@ BOOL ScBaseCell::CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ) ScFormulaCell::ScFormulaCell() : ScBaseCell( CELLTYPE_FORMULA ), - eTempGrammar( ScGrammar::GRAM_DEFAULT), + eTempGrammar( FormulaGrammar::GRAM_DEFAULT), pCode( NULL ), pDocument( NULL ), pPrevious(0), @@ -558,7 +559,7 @@ ScFormulaCell::ScFormulaCell() : ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, const String& rFormula, - const ScGrammar::Grammar eGrammar, + const FormulaGrammar::Grammar eGrammar, BYTE cMatInd ) : ScBaseCell( CELLTYPE_FORMULA ), eTempGrammar( eGrammar), @@ -590,7 +591,7 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, const ScTokenArray* pArr, - const ScGrammar::Grammar eGrammar, BYTE cInd ) : + const FormulaGrammar::Grammar eGrammar, BYTE cInd ) : ScBaseCell( CELLTYPE_FORMULA ), eTempGrammar( eGrammar), pCode( pArr ? new ScTokenArray( *pArr ) : new ScTokenArray ), @@ -617,7 +618,8 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, // UPN-Array erzeugen if( pCode->GetLen() && !pCode->GetCodeError() && !pCode->GetCodeLen() ) { - ScCompiler aComp( pDocument, aPos, *pCode, eTempGrammar); + ScCompiler aComp( pDocument, aPos, *pCode); + aComp.SetGrammar(eTempGrammar); bSubTotal = aComp.CompileTokenArray(); nFormatType = aComp.GetNumFormatType(); } @@ -674,8 +676,8 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rNewPos, if( !bCompile ) { // Name references with references and ColRowNames pCode->Reset(); - for( ScToken* t = pCode->GetNextReferenceOrName(); t && !bCompile; - t = pCode->GetNextReferenceOrName() ) + ScToken* t; + while ( ( t = static_cast<ScToken*>(pCode->GetNextReferenceOrName()) ) != NULL && !bCompile ) { if ( t->GetOpCode() == ocExternalRef ) { @@ -727,7 +729,7 @@ ScBaseCell* ScFormulaCell::Clone( ScDocument* pDoc, const ScAddress& rPos, } void ScFormulaCell::GetFormula( rtl::OUStringBuffer& rBuffer, - const ScGrammar::Grammar eGrammar ) const + const FormulaGrammar::Grammar eGrammar ) const { if( pCode->GetCodeError() && !pCode->GetLen() ) { @@ -738,7 +740,7 @@ void ScFormulaCell::GetFormula( rtl::OUStringBuffer& rBuffer, { // Reference to another cell that contains a matrix formula. pCode->Reset(); - ScToken* p = pCode->GetNextReferenceRPN(); + ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); if( p ) { /* FIXME: original GetFormula() code obtained @@ -760,7 +762,8 @@ void ScFormulaCell::GetFormula( rtl::OUStringBuffer& rBuffer, } else { - ScCompiler aComp( pDocument, aPos, *pCode, eGrammar); + ScCompiler aComp( pDocument, aPos, *pCode); + aComp.SetGrammar(eGrammar); aComp.CreateStringFromTokenArray( rBuffer ); } } @@ -771,7 +774,8 @@ void ScFormulaCell::GetFormula( rtl::OUStringBuffer& rBuffer, } else { - ScCompiler aComp( pDocument, aPos, *pCode, eGrammar); + ScCompiler aComp( pDocument, aPos, *pCode); + aComp.SetGrammar(eGrammar); aComp.CreateStringFromTokenArray( rBuffer ); } @@ -785,7 +789,7 @@ void ScFormulaCell::GetFormula( rtl::OUStringBuffer& rBuffer, } } -void ScFormulaCell::GetFormula( String& rFormula, const ScGrammar::Grammar eGrammar ) const +void ScFormulaCell::GetFormula( String& rFormula, const FormulaGrammar::Grammar eGrammar ) const { rtl::OUStringBuffer rBuffer( rFormula ); GetFormula( rBuffer, eGrammar ); @@ -799,7 +803,7 @@ void ScFormulaCell::GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows ) const ScMatrix* pMat = NULL; if (!pCode->GetCodeError() && aResult.GetType() == svMatrixCell && - ((pMat = aResult.GetToken()->GetMatrix()) != 0)) + ((pMat = static_cast<const ScToken*>(aResult.GetToken().get())->GetMatrix()) != 0)) pMat->GetDimensions( rCols, rRows ); else { @@ -809,7 +813,7 @@ void ScFormulaCell::GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows ) } void ScFormulaCell::Compile( const String& rFormula, BOOL bNoListening, - const ScGrammar::Grammar eGrammar ) + const FormulaGrammar::Grammar eGrammar ) { if ( pDocument->IsClipOrUndo() ) return; BOOL bWasInFormulaTree = pDocument->IsInFormulaTree( this ); @@ -819,7 +823,8 @@ void ScFormulaCell::Compile( const String& rFormula, BOOL bNoListening, if ( pCode ) pCode->Clear(); ScTokenArray* pCodeOld = pCode; - ScCompiler aComp( pDocument, aPos, eGrammar); + ScCompiler aComp( pDocument, aPos); + aComp.SetGrammar(eGrammar); pCode = aComp.CompileString( rFormula ); if ( pCodeOld ) delete pCodeOld; @@ -864,7 +869,8 @@ void ScFormulaCell::CompileTokenArray( BOOL bNoListening ) if( !bNoListening && pCode->GetCodeLen() ) EndListeningTo( pDocument ); - ScCompiler aComp(pDocument, aPos, *pCode, pDocument->GetGrammar()); + ScCompiler aComp(pDocument, aPos, *pCode); + aComp.SetGrammar(pDocument->GetGrammar()); bSubTotal = aComp.CompileTokenArray(); if( !pCode->GetCodeError() ) { @@ -891,7 +897,8 @@ void ScFormulaCell::CompileXML( ScProgress& rProgress ) return ; } - ScCompiler aComp( pDocument, aPos, *pCode, eTempGrammar); + ScCompiler aComp( pDocument, aPos, *pCode); + aComp.SetGrammar(eTempGrammar); String aFormula; aComp.CreateStringFromTokenArray( aFormula ); pDocument->DecXMLImportedFormulaCount( aFormula.Len() ); @@ -951,7 +958,8 @@ void ScFormulaCell::CalcAfterLoad() // wurde, da die RangeNames erst jetzt existieren. if( pCode->GetLen() && !pCode->GetCodeLen() && !pCode->GetCodeError() ) { - ScCompiler aComp(pDocument, aPos, *pCode, pDocument->GetGrammar()); + ScCompiler aComp(pDocument, aPos, *pCode); + aComp.SetGrammar(pDocument->GetGrammar()); bSubTotal = aComp.CompileTokenArray(); nFormatType = aComp.GetNumFormatType(); nFormatIndex = 0; @@ -1499,7 +1507,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam ) // In case of changes just obtain the result, no temporary and // comparison needed anymore. if (bChanged) - aResult.SetToken( p->GetResultToken()); + aResult.SetToken( p->GetResultToken() ); else { ScFormulaResult aNewResult( p->GetResultToken()); @@ -1831,13 +1839,13 @@ BOOL ScDetectiveRefIter::GetNextRef( ScRange& rRange ) { BOOL bRet = FALSE; - ScToken* p = pCode->GetNextReferenceRPN(); + ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); if (p) p->CalcAbsIfRel( aPos ); while ( p && lcl_ScDetectiveRefIter_SkipRef( p ) ) { - p = pCode->GetNextReferenceRPN(); + p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); if (p) p->CalcAbsIfRel( aPos ); } diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx index 6a4f4257dda8..6989730e883f 100644 --- a/sc/source/core/data/cell2.cxx +++ b/sc/source/core/data/cell2.cxx @@ -40,7 +40,7 @@ #include "cell.hxx" #include "compiler.hxx" -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" #include "document.hxx" #include "rangenam.hxx" #include "rechead.hxx" @@ -51,6 +51,8 @@ #include "indexmap.hxx" #include "externalrefmgr.hxx" +using namespace formula; + // STATIC DATA ----------------------------------------------------------- #ifdef USE_MEMPOOL @@ -182,7 +184,7 @@ BOOL ScFormulaCell::IsEmpty() { if (IsDirtyOrInTableOpDirty() && pDocument->GetAutoCalc()) Interpret(); - return aResult.GetCellResultType() == svEmptyCell; + return aResult.GetCellResultType() == formula::svEmptyCell; } BOOL ScFormulaCell::IsEmptyDisplayedAsString() @@ -254,7 +256,7 @@ BOOL ScFormulaCell::GetMatrixOrigin( ScAddress& rPos ) const case MM_REFERENCE : { pCode->Reset(); - ScToken* t = pCode->GetNextReferenceRPN(); + ScToken* t = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); if( t ) { ScSingleRefData& rRef = t->GetSingleRef(); @@ -435,7 +437,7 @@ USHORT ScFormulaCell::GetRawError() BOOL ScFormulaCell::HasOneReference( ScRange& r ) const { pCode->Reset(); - ScToken* p = pCode->GetNextReferenceRPN(); + ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); if( p && !pCode->GetNextReferenceRPN() ) // nur eine! { p->CalcAbsIfRel( aPos ); @@ -455,11 +457,11 @@ BOOL ScFormulaCell::HasOneReference( ScRange& r ) const BOOL ScFormulaCell::HasRelNameReference() const { pCode->Reset(); - for( ScToken* t = pCode->GetNextReferenceRPN(); t; - t = pCode->GetNextReferenceRPN() ) + ScToken* t; + while ( ( t = static_cast<ScToken*>(pCode->GetNextReferenceRPN()) ) != NULL ) { if ( t->GetSingleRef().IsRelName() || - (t->GetType() == svDoubleRef && + (t->GetType() == formula::svDoubleRef && t->GetDoubleRef().Ref2.IsRelName()) ) return TRUE; } @@ -567,7 +569,8 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode, BOOL bRefSizeChanged; if ( bHasRefs ) { - ScCompiler aComp(pDocument, aPos, *pCode, pDocument->GetGrammar()); + ScCompiler aComp(pDocument, aPos, *pCode); + aComp.SetGrammar(pDocument->GetGrammar()); pRangeData = aComp.UpdateReference(eUpdateRefMode, aOldPos, r, nDx, nDy, nDz, bValChanged, bRefSizeChanged); @@ -598,7 +601,7 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode, ScRangePairList* pColList = pDocument->GetColNameRanges(); ScRangePairList* pRowList = pDocument->GetRowNameRanges(); pCode->Reset(); - while ( !bColRowNameCompile && (t = pCode->GetNextColRowName()) != NULL ) + while ( !bColRowNameCompile && (t = static_cast<ScToken*>(pCode->GetNextColRowName())) != NULL ) { ScSingleRefData& rRef = t->GetSingleRef(); if ( nDy > 0 && rRef.IsColRel() ) @@ -643,7 +646,7 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode, { BOOL bMoved = (aPos != aOldPos); pCode->Reset(); - ScToken* t = pCode->GetNextColRowName(); + ScToken* t = static_cast<ScToken*>(pCode->GetNextColRowName()); if ( t && bMoved ) bColRowNameCompile = TRUE; while ( t && !bColRowNameCompile ) @@ -656,7 +659,7 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode, if ( r.In( aAdr ) ) bColRowNameCompile = TRUE; } - t = pCode->GetNextColRowName(); + t = static_cast<ScToken*>(pCode->GetNextColRowName()); } } } @@ -719,7 +722,8 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode, pDocument->RemoveFromFormulaTree( this ); // update formula count delete pCode; pCode = pRangeData->GetCode()->Clone(); - ScCompiler aComp2(pDocument, aPos, *pCode, pDocument->GetGrammar()); + ScCompiler aComp2(pDocument, aPos, *pCode); + aComp2.SetGrammar(pDocument->GetGrammar()); aComp2.UpdateSharedFormulaReference( eUpdateRefMode, aOldPos, r, nDx, nDy, nDz ); bValChanged = TRUE; @@ -782,7 +786,8 @@ void ScFormulaCell::UpdateInsertTab(SCTAB nTable) if ( bPosChanged ) aPos.IncTab(); ScRangeData* pRangeData; - ScCompiler aComp(pDocument, aPos, *pCode, pDocument->GetGrammar()); + ScCompiler aComp(pDocument, aPos, *pCode); + aComp.SetGrammar(pDocument->GetGrammar()); pRangeData = aComp.UpdateInsertTab( nTable, FALSE ); if (pRangeData) // Shared Formula gegen echte Formel { // austauschen @@ -790,7 +795,8 @@ void ScFormulaCell::UpdateInsertTab(SCTAB nTable) pDocument->RemoveFromFormulaTree( this ); // update formula count delete pCode; pCode = new ScTokenArray( *pRangeData->GetCode() ); - ScCompiler aComp2(pDocument, aPos, *pCode, pDocument->GetGrammar()); + ScCompiler aComp2(pDocument, aPos, *pCode); + aComp2.SetGrammar(pDocument->GetGrammar()); aComp2.MoveRelWrap(); aComp2.UpdateInsertTab( nTable, FALSE ); // If the shared formula contained a named range/formula containing @@ -816,14 +822,16 @@ BOOL ScFormulaCell::UpdateDeleteTab(SCTAB nTable, BOOL bIsMove) if ( bPosChanged ) aPos.IncTab(-1); ScRangeData* pRangeData; - ScCompiler aComp(pDocument, aPos, *pCode, pDocument->GetGrammar()); + ScCompiler aComp(pDocument, aPos, *pCode); + aComp.SetGrammar(pDocument->GetGrammar()); pRangeData = aComp.UpdateDeleteTab(nTable, bIsMove, FALSE, bRefChanged); if (pRangeData) // Shared Formula gegen echte Formel { // austauschen pDocument->RemoveFromFormulaTree( this ); // update formula count delete pCode; pCode = pRangeData->GetCode()->Clone(); - ScCompiler aComp2(pDocument, aPos, *pCode, pDocument->GetGrammar()); + ScCompiler aComp2(pDocument, aPos, *pCode); + aComp2.SetGrammar(pDocument->GetGrammar()); aComp2.CompileTokenArray(); aComp2.MoveRelWrap(); aComp2.UpdateDeleteTab( nTable, FALSE, FALSE, bRefChanged ); @@ -851,14 +859,16 @@ void ScFormulaCell::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo ) // SetTab _nach_ EndListeningTo und _vor_ Compiler UpdateMoveTab ! aPos.SetTab( nTabNo ); ScRangeData* pRangeData; - ScCompiler aComp(pDocument, aPos, *pCode, pDocument->GetGrammar()); + ScCompiler aComp(pDocument, aPos, *pCode); + aComp.SetGrammar(pDocument->GetGrammar()); pRangeData = aComp.UpdateMoveTab( nOldPos, nNewPos, FALSE ); if (pRangeData) // Shared Formula gegen echte Formel { // austauschen pDocument->RemoveFromFormulaTree( this ); // update formula count delete pCode; pCode = pRangeData->GetCode()->Clone(); - ScCompiler aComp2(pDocument, aPos, *pCode, pDocument->GetGrammar()); + ScCompiler aComp2(pDocument, aPos, *pCode); + aComp2.SetGrammar(pDocument->GetGrammar()); aComp2.CompileTokenArray(); aComp2.MoveRelWrap(); aComp2.UpdateMoveTab( nOldPos, nNewPos, TRUE ); @@ -875,19 +885,19 @@ void ScFormulaCell::UpdateInsertTabAbs(SCTAB nTable) if( !pDocument->IsClipOrUndo() ) { pCode->Reset(); - ScToken* p = pCode->GetNextReferenceRPN(); + ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); while( p ) { ScSingleRefData& rRef1 = p->GetSingleRef(); if( !rRef1.IsTabRel() && (SCsTAB) nTable <= rRef1.nTab ) rRef1.nTab++; - if( p->GetType() == svDoubleRef ) + if( p->GetType() == formula::svDoubleRef ) { ScSingleRefData& rRef2 = p->GetDoubleRef().Ref2; if( !rRef2.IsTabRel() && (SCsTAB) nTable <= rRef2.nTab ) rRef2.nTab++; } - p = pCode->GetNextReferenceRPN(); + p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); } } } @@ -898,7 +908,7 @@ BOOL ScFormulaCell::TestTabRefAbs(SCTAB nTable) if( !pDocument->IsClipOrUndo() ) { pCode->Reset(); - ScToken* p = pCode->GetNextReferenceRPN(); + ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); while( p ) { ScSingleRefData& rRef1 = p->GetSingleRef(); @@ -909,7 +919,7 @@ BOOL ScFormulaCell::TestTabRefAbs(SCTAB nTable) else if (nTable != aPos.Tab()) rRef1.nTab = aPos.Tab(); } - if( p->GetType() == svDoubleRef ) + if( p->GetType() == formula::svDoubleRef ) { ScSingleRefData& rRef2 = p->GetDoubleRef().Ref2; if( !rRef2.IsTabRel() ) @@ -920,7 +930,7 @@ BOOL ScFormulaCell::TestTabRefAbs(SCTAB nTable) rRef2.nTab = aPos.Tab(); } } - p = pCode->GetNextReferenceRPN(); + p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); } } return bRet; @@ -941,13 +951,13 @@ void ScFormulaCell::TransposeReference() { BOOL bFound = FALSE; pCode->Reset(); - for( ScToken* t = pCode->GetNextReference(); t; - t = pCode->GetNextReference() ) + ScToken* t; + while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL ) { ScSingleRefData& rRef1 = t->GetSingleRef(); if ( rRef1.IsColRel() && rRef1.IsRowRel() ) { - BOOL bDouble = (t->GetType() == svDoubleRef); + BOOL bDouble = (t->GetType() == formula::svDoubleRef); ScSingleRefData& rRef2 = (bDouble ? t->GetDoubleRef().Ref2 : rRef1); if ( !bDouble || (rRef2.IsColRel() && rRef2.IsRowRel()) ) { @@ -1002,7 +1012,7 @@ void ScFormulaCell::UpdateTranspose( const ScRange& rSource, const ScAddress& rD ScRangeData* pShared = NULL; pCode->Reset(); - for( t = pCode->GetNextReferenceOrName(); t; t = pCode->GetNextReferenceOrName() ) + while( (t = static_cast<ScToken*>(pCode->GetNextReferenceOrName())) != NULL ) { if( t->GetOpCode() == ocName ) { @@ -1040,7 +1050,7 @@ void ScFormulaCell::UpdateTranspose( const ScRange& rSource, const ScAddress& rD pCode = new ScTokenArray( *pShared->GetCode() ); bRefChanged = TRUE; pCode->Reset(); - for( t = pCode->GetNextReference(); t; t = pCode->GetNextReference() ) + while( (t = static_cast<ScToken*>(pCode->GetNextReference())) != NULL ) { if( t->GetType() != svIndex ) { @@ -1087,7 +1097,7 @@ void ScFormulaCell::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY ScRangeData* pShared = NULL; pCode->Reset(); - for( t = pCode->GetNextReferenceOrName(); t; t = pCode->GetNextReferenceOrName() ) + while( (t = static_cast<ScToken*>(pCode->GetNextReferenceOrName())) != NULL ) { if( t->GetOpCode() == ocName ) { @@ -1125,7 +1135,7 @@ void ScFormulaCell::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY pCode = new ScTokenArray( *pShared->GetCode() ); bRefChanged = TRUE; pCode->Reset(); - for( t = pCode->GetNextReference(); t; t = pCode->GetNextReference() ) + while( (t = static_cast<ScToken*>(pCode->GetNextReference())) != NULL ) { if( t->GetType() != svIndex ) { @@ -1155,7 +1165,7 @@ void ScFormulaCell::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY BOOL lcl_IsRangeNameInUse(USHORT nIndex, ScTokenArray* pCode, ScRangeName* pNames) { - for (ScToken* p = pCode->First(); p; p = pCode->Next()) + for (FormulaToken* p = pCode->First(); p; p = pCode->Next()) { if (p->GetOpCode() == ocName) { @@ -1181,7 +1191,7 @@ BOOL ScFormulaCell::IsRangeNameInUse(USHORT nIndex) const void lcl_FindRangeNamesInUse(std::set<USHORT>& rIndexes, ScTokenArray* pCode, ScRangeName* pNames) { - for (ScToken* p = pCode->First(); p; p = pCode->Next()) + for (FormulaToken* p = pCode->First(); p; p = pCode->Next()) { if (p->GetOpCode() == ocName) { @@ -1202,7 +1212,7 @@ void ScFormulaCell::FindRangeNamesInUse(std::set<USHORT>& rIndexes) const void ScFormulaCell::ReplaceRangeNamesInUse( const ScIndexMap& rMap ) { - for( ScToken* p = pCode->First(); p; p = pCode->Next() ) + for( FormulaToken* p = pCode->First(); p; p = pCode->Next() ) { if( p->GetOpCode() == ocName ) { @@ -1221,7 +1231,7 @@ void ScFormulaCell::ReplaceRangeNamesInUse( const ScIndexMap& rMap ) void ScFormulaCell::CompileDBFormula() { - for( ScToken* p = pCode->First(); p; p = pCode->Next() ) + for( FormulaToken* p = pCode->First(); p; p = pCode->Next() ) { if ( p->GetOpCode() == ocDBArea || (p->GetOpCode() == ocName && p->GetIndex() >= SC_START_INDEX_DB_COLL) ) @@ -1243,7 +1253,7 @@ void ScFormulaCell::CompileDBFormula( BOOL bCreateFormulaString ) { BOOL bRecompile = FALSE; pCode->Reset(); - for ( ScToken* p = pCode->First(); p && !bRecompile; p = pCode->Next() ) + for ( FormulaToken* p = pCode->First(); p && !bRecompile; p = pCode->Next() ) { switch ( p->GetOpCode() ) { @@ -1263,7 +1273,7 @@ void ScFormulaCell::CompileDBFormula( BOOL bCreateFormulaString ) if ( bRecompile ) { String aFormula; - GetFormula( aFormula, ScGrammar::GRAM_NATIVE); + GetFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE); if ( GetMatrixFlag() != MM_NONE && aFormula.Len() ) { if ( aFormula.GetChar( aFormula.Len()-1 ) == '}' ) @@ -1274,7 +1284,7 @@ void ScFormulaCell::CompileDBFormula( BOOL bCreateFormulaString ) EndListeningTo( pDocument ); pDocument->RemoveFromFormulaTree( this ); pCode->Clear(); - SetHybridFormula( aFormula, ScGrammar::GRAM_NATIVE); + SetHybridFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE); } } else if ( !pCode->GetLen() && aResult.GetHybridFormula().Len() ) @@ -1294,7 +1304,7 @@ void ScFormulaCell::CompileNameFormula( BOOL bCreateFormulaString ) { BOOL bRecompile = FALSE; pCode->Reset(); - for ( ScToken* p = pCode->First(); p && !bRecompile; p = pCode->Next() ) + for ( FormulaToken* p = pCode->First(); p && !bRecompile; p = pCode->Next() ) { switch ( p->GetOpCode() ) { @@ -1310,7 +1320,7 @@ void ScFormulaCell::CompileNameFormula( BOOL bCreateFormulaString ) if ( bRecompile ) { String aFormula; - GetFormula( aFormula, ScGrammar::GRAM_NATIVE); + GetFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE); if ( GetMatrixFlag() != MM_NONE && aFormula.Len() ) { if ( aFormula.GetChar( aFormula.Len()-1 ) == '}' ) @@ -1321,7 +1331,7 @@ void ScFormulaCell::CompileNameFormula( BOOL bCreateFormulaString ) EndListeningTo( pDocument ); pDocument->RemoveFromFormulaTree( this ); pCode->Clear(); - SetHybridFormula( aFormula, ScGrammar::GRAM_NATIVE); + SetHybridFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE); } } else if ( !pCode->GetLen() && aResult.GetHybridFormula().Len() ) @@ -1335,7 +1345,7 @@ void ScFormulaCell::CompileNameFormula( BOOL bCreateFormulaString ) void ScFormulaCell::CompileColRowNameFormula() { pCode->Reset(); - for ( ScToken* p = pCode->First(); p; p = pCode->Next() ) + for ( FormulaToken* p = pCode->First(); p; p = pCode->Next() ) { if ( p->GetOpCode() == ocColRowName ) { diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 737a4af008e3..4fbd4aa7b910 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -59,7 +59,7 @@ // nur Search ohne Optimierung! // STATIC DATA ----------------------------------------------------------- - +using namespace formula; inline BOOL CellVisible( const ScBaseCell* pCell ) //! an Zelle verschieben { @@ -956,8 +956,8 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) { BOOL bEqual = TRUE; USHORT nLen = pCode1->GetLen(); - ScToken** ppToken1 = pCode1->GetArray(); - ScToken** ppToken2 = pCode2->GetArray(); + FormulaToken** ppToken1 = pCode1->GetArray(); + FormulaToken** ppToken2 = pCode2->GetArray(); for (USHORT i=0; i<nLen; i++) { if ( !ppToken1[i]->TextEqual(*(ppToken2[i])) || diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index fc2fc227d130..2465bdf164c7 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -46,7 +46,8 @@ #include "patattr.hxx" #include "cellform.hxx" #include "collect.hxx" -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" +#include "formula/token.hxx" #include "brdcst.hxx" #include "docoptio.hxx" // GetStdPrecision fuer GetMaxNumberStringLen #include "subtotal.hxx" @@ -56,7 +57,7 @@ // Err527 Workaround extern const ScFormulaCell* pLastFormulaTreeTop; // in cellform.cxx - +using namespace formula; // STATIC DATA ----------------------------------------------------------- BOOL ScColumn::bDoubleAlloc = FALSE; // fuer Import: Groesse beim Allozieren verdoppeln @@ -963,10 +964,10 @@ void lcl_AddCode( ScTokenArray& rArr, ScFormulaCell* pCell ) ScTokenArray* pCode = pCell->GetCode(); if (pCode) { - ScToken* pToken = pCode->First(); + const formula::FormulaToken* pToken = pCode->First(); while (pToken) { - rArr.AddToken(*pToken); + rArr.AddToken( *pToken ); pToken = pCode->Next(); } } @@ -1240,7 +1241,7 @@ void ScColumn::StartListeningInArea( SCROW nRow1, SCROW nRow2 ) // TRUE = Zahlformat gesetzt BOOL ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, - ScAddress::Convention eConv ) + formula::FormulaGrammar::AddressConvention eConv ) { BOOL bNumFmtSet = FALSE; if (VALIDROW(nRow)) @@ -1278,7 +1279,7 @@ BOOL ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, else // =Formel pNewCell = new ScFormulaCell( pDocument, ScAddress( nCol, nRow, nTabP ), rString, - ScGrammar::mergeToGrammar( ScGrammar::GRAM_DEFAULT, + formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_DEFAULT, eConv), MM_NONE ); } else if ( cFirstChar == '\'') // 'Text diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 4b504e2e1d05..e5fd9776aa3e 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -52,6 +52,7 @@ #include "stlpool.hxx" #include "rangenam.hxx" +using namespace formula; //------------------------------------------------------------------------ SV_IMPL_OP_PTRARR_SORT( ScConditionalFormats_Impl, ScConditionalFormatPtr ); @@ -63,14 +64,14 @@ BOOL lcl_HasRelRef( ScDocument* pDoc, ScTokenArray* pFormula, USHORT nRecursion if (pFormula) { pFormula->Reset(); - ScToken* t; + FormulaToken* t; for( t = pFormula->Next(); t; t = pFormula->Next() ) { switch( t->GetType() ) { case svDoubleRef: { - ScSingleRefData& rRef2 = t->GetDoubleRef().Ref2; + ScSingleRefData& rRef2 = static_cast<ScToken*>(t)->GetDoubleRef().Ref2; if ( rRef2.IsColRel() || rRef2.IsRowRel() || rRef2.IsTabRel() ) return TRUE; } @@ -78,7 +79,7 @@ BOOL lcl_HasRelRef( ScDocument* pDoc, ScTokenArray* pFormula, USHORT nRecursion case svSingleRef: { - ScSingleRefData& rRef1 = t->GetSingleRef(); + ScSingleRefData& rRef1 = static_cast<ScToken*>(t)->GetSingleRef(); if ( rRef1.IsColRel() || rRef1.IsRowRel() || rRef1.IsTabRel() ) return TRUE; } @@ -188,7 +189,7 @@ ScConditionEntry::ScConditionEntry( ScDocument* pDocument, const ScConditionEntr ScConditionEntry::ScConditionEntry( ScConditionMode eOper, const String& rExpr1, const String& rExpr2, ScDocument* pDocument, const ScAddress& rPos, - const ScGrammar::Grammar eGrammar ) : + const FormulaGrammar::Grammar eGrammar ) : eOp(eOper), nOptions(0), // spaeter... nVal1(0.0), @@ -218,7 +219,7 @@ ScConditionEntry::ScConditionEntry( ScConditionMode eOper, nOptions(0), // spaeter... nVal1(0.0), nVal2(0.0), - eTempGrammar(ScGrammar::GRAM_DEFAULT), + eTempGrammar(FormulaGrammar::GRAM_DEFAULT), bIsStr1(FALSE), bIsStr2(FALSE), pFormula1(NULL), @@ -237,7 +238,7 @@ ScConditionEntry::ScConditionEntry( ScConditionMode eOper, if ( pFormula1->GetLen() == 1 ) { // einzelne (konstante Zahl) ? - ScToken* pToken = pFormula1->First(); + FormulaToken* pToken = pFormula1->First(); if ( pToken->GetOpCode() == ocPush ) { if ( pToken->GetType() == svDouble ) @@ -261,7 +262,7 @@ ScConditionEntry::ScConditionEntry( ScConditionMode eOper, if ( pFormula2->GetLen() == 1 ) { // einzelne (konstante Zahl) ? - ScToken* pToken = pFormula2->First(); + FormulaToken* pToken = pFormula2->First(); if ( pToken->GetOpCode() == ocPush ) { if ( pToken->GetType() == svDouble ) @@ -293,11 +294,12 @@ ScConditionEntry::~ScConditionEntry() } void ScConditionEntry::Compile( const String& rExpr1, const String& rExpr2, - const ScGrammar::Grammar eGrammar, BOOL bTextToReal ) + const FormulaGrammar::Grammar eGrammar, BOOL bTextToReal ) { if ( rExpr1.Len() || rExpr2.Len() ) { - ScCompiler aComp( pDoc, aSrcPos, eGrammar ); + ScCompiler aComp( pDoc, aSrcPos ); + aComp.SetGrammar(eGrammar); if ( rExpr1.Len() ) { @@ -315,7 +317,7 @@ void ScConditionEntry::Compile( const String& rExpr1, const String& rExpr2, if ( pFormula1->GetLen() == 1 ) { // einzelne (konstante Zahl) ? - ScToken* pToken = pFormula1->First(); + FormulaToken* pToken = pFormula1->First(); if ( pToken->GetOpCode() == ocPush ) { if ( pToken->GetType() == svDouble ) @@ -351,7 +353,7 @@ void ScConditionEntry::Compile( const String& rExpr1, const String& rExpr2, if ( pFormula2->GetLen() == 1 ) { // einzelne (konstante Zahl) ? - ScToken* pToken = pFormula2->First(); + FormulaToken* pToken = pFormula2->First(); if ( pToken->GetOpCode() == ocPush ) { if ( pToken->GetType() == svDouble ) @@ -467,7 +469,7 @@ void lcl_CondUpdateInsertTab( ScTokenArray& rCode, SCTAB nInsTab, SCTAB nPosTab, // For deleting, ScCompiler::UpdateDeleteTab is used because of the handling of invalid references. rCode.Reset(); - ScToken* p = rCode.GetNextReference(); + ScToken* p = static_cast<ScToken*>(rCode.GetNextReference()); while( p ) { ScSingleRefData& rRef1 = p->GetSingleRef(); @@ -487,7 +489,7 @@ void lcl_CondUpdateInsertTab( ScTokenArray& rCode, SCTAB nInsTab, SCTAB nPosTab, rChanged = TRUE; } } - p = rCode.GetNextReference(); + p = static_cast<ScToken*>(rCode.GetNextReference()); } } @@ -506,7 +508,8 @@ void ScConditionEntry::UpdateReference( UpdateRefMode eUpdateRefMode, lcl_CondUpdateInsertTab( *pFormula1, rRange.aStart.Tab(), aSrcPos.Tab(), bChanged1 ); else { - ScCompiler aComp( pDoc, aSrcPos, *pFormula1, pDoc->GetGrammar() ); + ScCompiler aComp( pDoc, aSrcPos, *pFormula1 ); + aComp.SetGrammar(pDoc->GetGrammar()); if ( bDeleteTab ) aComp.UpdateDeleteTab( rRange.aStart.Tab(), FALSE, TRUE, bChanged1 ); else @@ -522,7 +525,8 @@ void ScConditionEntry::UpdateReference( UpdateRefMode eUpdateRefMode, lcl_CondUpdateInsertTab( *pFormula2, rRange.aStart.Tab(), aSrcPos.Tab(), bChanged2 ); else { - ScCompiler aComp( pDoc, aSrcPos, *pFormula2, pDoc->GetGrammar() ); + ScCompiler aComp( pDoc, aSrcPos, *pFormula2); + aComp.SetGrammar(pDoc->GetGrammar()); if ( bDeleteTab ) aComp.UpdateDeleteTab( rRange.aStart.Tab(), FALSE, TRUE, bChanged2 ); else @@ -538,13 +542,15 @@ void ScConditionEntry::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ) { if (pFormula1) { - ScCompiler aComp( pDoc, aSrcPos, *pFormula1, pDoc->GetGrammar() ); + ScCompiler aComp( pDoc, aSrcPos, *pFormula1); + aComp.SetGrammar(pDoc->GetGrammar()); aComp.UpdateMoveTab(nOldPos, nNewPos, TRUE ); DELETEZ(pFCell1); } if (pFormula2) { - ScCompiler aComp( pDoc, aSrcPos, *pFormula2, pDoc->GetGrammar() ); + ScCompiler aComp( pDoc, aSrcPos, *pFormula2); + aComp.SetGrammar(pDoc->GetGrammar()); aComp.UpdateMoveTab(nOldPos, nNewPos, TRUE ); DELETEZ(pFCell2); } @@ -562,8 +568,8 @@ BOOL lcl_IsEqual( const ScTokenArray* pArr1, const ScTokenArray* pArr2 ) if ( pArr2->GetLen() != nLen ) return FALSE; - ScToken** ppToken1 = pArr1->GetArray(); - ScToken** ppToken2 = pArr2->GetArray(); + FormulaToken** ppToken1 = pArr1->GetArray(); + FormulaToken** ppToken2 = pArr2->GetArray(); for (USHORT i=0; i<nLen; i++) { if ( ppToken1[i] != ppToken2[i] && @@ -877,18 +883,19 @@ BOOL ScConditionEntry::IsCellValid( ScBaseCell* pCell, const ScAddress& rPos ) c String ScConditionEntry::GetExpression( const ScAddress& rCursor, USHORT nIndex, ULONG nNumFmt, - const ScGrammar::Grammar eGrammar ) const + const FormulaGrammar::Grammar eGrammar ) const { String aRet; - if ( ScGrammar::isEnglish( eGrammar) && nNumFmt == 0 ) + if ( FormulaGrammar::isEnglish( eGrammar) && nNumFmt == 0 ) nNumFmt = pDoc->GetFormatTable()->GetStandardIndex( LANGUAGE_ENGLISH_US ); if ( nIndex==0 ) { if ( pFormula1 ) { - ScCompiler aComp(pDoc, rCursor, *pFormula1, eGrammar); + ScCompiler aComp(pDoc, rCursor, *pFormula1); + aComp.SetGrammar(eGrammar); aComp.CreateStringFromTokenArray( aRet ); } else if (bIsStr1) @@ -904,7 +911,8 @@ String ScConditionEntry::GetExpression( const ScAddress& rCursor, USHORT nIndex, { if ( pFormula2 ) { - ScCompiler aComp(pDoc, rCursor, *pFormula2, eGrammar); + ScCompiler aComp(pDoc, rCursor, *pFormula2); + aComp.SetGrammar(eGrammar); aComp.CreateStringFromTokenArray( aRet ); } else if (bIsStr2) @@ -972,7 +980,7 @@ void ScConditionEntry::SourceChanged( const ScAddress& rChanged ) { pFormula->Reset(); ScToken* t; - for( t = pFormula->GetNextReference(); t; t = pFormula->GetNextReference() ) + while ( ( t = static_cast<ScToken*>(pFormula->GetNextReference()) ) != NULL ) { SingleDoubleRefProvider aProv( *t ); if ( aProv.Ref1.IsColRel() || aProv.Ref1.IsRowRel() || aProv.Ref1.IsTabRel() || @@ -1062,7 +1070,7 @@ ScAddress ScConditionEntry::GetValidSrcPos() const { pFormula->Reset(); ScToken* t; - while ( ( t = pFormula->GetNextReference() ) != NULL ) + while ( ( t = static_cast<ScToken*>(pFormula->GetNextReference()) ) != NULL ) { ScSingleRefData& rRef1 = t->GetSingleRef(); if ( rRef1.IsTabRel() && !rRef1.IsTabDeleted() ) @@ -1109,7 +1117,7 @@ ScCondFormatEntry::ScCondFormatEntry( ScConditionMode eOper, const String& rExpr1, const String& rExpr2, ScDocument* pDocument, const ScAddress& rPos, const String& rStyle, - const ScGrammar::Grammar eGrammar ) : + const FormulaGrammar::Grammar eGrammar ) : ScConditionEntry( eOper, rExpr1, rExpr2, pDocument, rPos, eGrammar ), aStyleName( rStyle ), pParent( NULL ) diff --git a/sc/source/core/data/dbdocutl.cxx b/sc/source/core/data/dbdocutl.cxx index e7b4e9fb6aef..6a849282a642 100644 --- a/sc/source/core/data/dbdocutl.cxx +++ b/sc/source/core/data/dbdocutl.cxx @@ -43,7 +43,7 @@ #include "dbdocutl.hxx" #include "document.hxx" #include "cell.hxx" -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" using namespace ::com::sun::star; diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index fe87a8a9868f..c3f8b2a06744 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -209,7 +209,7 @@ ScDocument::ScDocument( ScDocumentMode eMode, nInDdeLinkUpdate( 0 ), bInUnoBroadcast( FALSE ), bInUnoListenerCall( FALSE ), - eGrammar( ScGrammar::GRAM_NATIVE ), + eGrammar( formula::FormulaGrammar::GRAM_NATIVE ), bStyleSheetUsageInvalid( TRUE ), bUndoEnabled( TRUE ), mbAdjustHeightEnabled( true ), @@ -217,7 +217,7 @@ ScDocument::ScDocument( ScDocumentMode eMode, mbChangeReadOnlyEnabled( false ), mnNamedRangesLockCount( 0 ) { - SetStorageGrammar( ScGrammar::GRAM_STORAGE_DEFAULT); + SetStorageGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT); eSrcSet = gsl_getSystemTextEncoding(); @@ -263,11 +263,11 @@ ScDocument::ScDocument( ScDocumentMode eMode, } -void ScDocument::SetStorageGrammar( ScGrammar::Grammar eGram ) +void ScDocument::SetStorageGrammar( formula::FormulaGrammar::Grammar eGram ) { DBG_ASSERT( - eGram == ScGrammar::GRAM_ODFF || - eGram == ScGrammar::GRAM_PODF, + eGram == formula::FormulaGrammar::GRAM_ODFF || + eGram == formula::FormulaGrammar::GRAM_PODF, "ScDocument::SetStorageGrammar: wrong storage grammar"); eStorageGrammar = eGram; @@ -276,8 +276,8 @@ void ScDocument::SetStorageGrammar( ScGrammar::Grammar eGram ) // digest them instead, which could also speedup reference recognition // during import. - eXmlImportGrammar = ScGrammar::mergeToGrammar( eGram, - ScAddress::CONV_OOO); + eXmlImportGrammar = formula::FormulaGrammar::mergeToGrammar( eGram, + formula::FormulaGrammar::CONV_OOO); } diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 56aeda321ea7..72a5385f748b 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -303,10 +303,11 @@ void ScDocument::SetScenario( SCTAB nTab, BOOL bFlag ) BOOL ScDocument::IsScenario( SCTAB nTab ) const { - if (ValidTab(nTab) && pTab[nTab]) - return pTab[nTab]->IsScenario(); + return ValidTab(nTab) && pTab[nTab] &&pTab[nTab]->IsScenario(); + //if (ValidTab(nTab) && pTab[nTab]) + // return pTab[nTab]->IsScenario(); - return FALSE; + //return FALSE; } void ScDocument::SetScenarioData( SCTAB nTab, const String& rComment, @@ -339,22 +340,24 @@ void ScDocument::GetScenarioFlags( SCTAB nTab, USHORT& rFlags ) const BOOL ScDocument::IsLinked( SCTAB nTab ) const { - if (ValidTab(nTab) && pTab[nTab]) - return pTab[nTab]->IsLinked(); - return FALSE; + return ValidTab(nTab) && pTab[nTab] && pTab[nTab]->IsLinked(); + // euqivalent to + //if (ValidTab(nTab) && pTab[nTab]) + // return pTab[nTab]->IsLinked(); + //return FALSE; } -ScAddress::Convention ScDocument::GetAddressConvention() const +formula::FormulaGrammar::AddressConvention ScDocument::GetAddressConvention() const { - return ScGrammar::extractRefConvention(eGrammar); + return formula::FormulaGrammar::extractRefConvention(eGrammar); } -ScGrammar::Grammar ScDocument::GetGrammar() const +formula::FormulaGrammar::Grammar ScDocument::GetGrammar() const { return eGrammar; } -void ScDocument::SetGrammar( ScGrammar::Grammar eGram ) +void ScDocument::SetGrammar( formula::FormulaGrammar::Grammar eGram ) { eGrammar = eGram; } @@ -504,44 +507,44 @@ ScOutlineTable* ScDocument::GetOutlineTable( SCTAB nTab, BOOL bCreate ) BOOL ScDocument::SetOutlineTable( SCTAB nTab, const ScOutlineTable* pNewOutline ) { - if (VALIDTAB(nTab)) - if (pTab[nTab]) - return pTab[nTab]->SetOutlineTable(pNewOutline); + return VALIDTAB(nTab) && pTab[nTab] && pTab[nTab]->SetOutlineTable(pNewOutline); + //if (VALIDTAB(nTab)) + // if (pTab[nTab]) + // return pTab[nTab]->SetOutlineTable(pNewOutline); - return FALSE; + //return FALSE; } void ScDocument::DoAutoOutline( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) { - if (VALIDTAB(nTab)) - if (pTab[nTab]) - pTab[nTab]->DoAutoOutline( nStartCol, nStartRow, nEndCol, nEndRow ); + if (VALIDTAB(nTab) && pTab[nTab]) + pTab[nTab]->DoAutoOutline( nStartCol, nStartRow, nEndCol, nEndRow ); } BOOL ScDocument::TestRemoveSubTotals( SCTAB nTab, const ScSubTotalParam& rParam ) { - if (VALIDTAB(nTab)) - if (pTab[nTab]) - return pTab[nTab]->TestRemoveSubTotals( rParam ); + return VALIDTAB(nTab) && pTab[nTab] && pTab[nTab]->TestRemoveSubTotals( rParam ); + //if (VALIDTAB(nTab) && pTab[nTab] ) + // return pTab[nTab]->TestRemoveSubTotals( rParam ); - return FALSE; + //return FALSE; } void ScDocument::RemoveSubTotals( SCTAB nTab, ScSubTotalParam& rParam ) { - if (VALIDTAB(nTab)) - if (pTab[nTab]) - pTab[nTab]->RemoveSubTotals( rParam ); + if ( VALIDTAB(nTab) && pTab[nTab] ) + pTab[nTab]->RemoveSubTotals( rParam ); } BOOL ScDocument::DoSubTotals( SCTAB nTab, ScSubTotalParam& rParam ) { - if (VALIDTAB(nTab)) - if (pTab[nTab]) - return pTab[nTab]->DoSubTotals( rParam ); + return VALIDTAB(nTab) && pTab[nTab] && pTab[nTab]->DoSubTotals( rParam ); + //if (VALIDTAB(nTab)) + // if (pTab[nTab]) + // return pTab[nTab]->DoSubTotals( rParam ); - return FALSE; + //return FALSE; } BOOL ScDocument::HasSubTotalCells( const ScRange& rRange ) @@ -577,7 +580,7 @@ void ScDocument::CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, BOOL bNewScenario // und aktuelle Werte in bisher aktive Szenarios zurueckschreiben ScRangeList aRanges = *pTab[nSrcTab]->GetScenarioRanges(); - ULONG nRangeCount = aRanges.Count(); + const ULONG nRangeCount = aRanges.Count(); // nDestTab ist die Zieltabelle for ( SCTAB nTab = nDestTab+1; @@ -589,8 +592,8 @@ void ScDocument::CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, BOOL bNewScenario BOOL bTouched = FALSE; for ( ULONG nR=0; nR<nRangeCount && !bTouched; nR++) { - ScRange aRange = *aRanges.GetObject(nR); - if ( pTab[nTab]->HasScenarioRange( aRange ) ) + const ScRange* pRange = aRanges.GetObject(nR); + if ( pTab[nTab]->HasScenarioRange( *pRange ) ) bTouched = TRUE; } if (bTouched) @@ -628,10 +631,11 @@ void ScDocument::MarkScenario( SCTAB nSrcTab, SCTAB nDestTab, ScMarkData& rDestM BOOL ScDocument::HasScenarioRange( SCTAB nTab, const ScRange& rRange ) const { - if (ValidTab(nTab) && pTab[nTab]) - return pTab[nTab]->HasScenarioRange( rRange ); + return ValidTab(nTab) && pTab[nTab] && pTab[nTab]->HasScenarioRange( rRange ); + //if (ValidTab(nTab) && pTab[nTab]) + // return pTab[nTab]->HasScenarioRange( rRange ); - return FALSE; + //return FALSE; } const ScRangeList* ScDocument::GetScenarioRanges( SCTAB nTab ) const @@ -644,10 +648,11 @@ const ScRangeList* ScDocument::GetScenarioRanges( SCTAB nTab ) const BOOL ScDocument::IsActiveScenario( SCTAB nTab ) const { - if (ValidTab(nTab) && pTab[nTab]) - return pTab[nTab]->IsActiveScenario(); + return ValidTab(nTab) && pTab[nTab] && pTab[nTab]->IsActiveScenario( ); + //if (ValidTab(nTab) && pTab[nTab]) + // return pTab[nTab]->IsActiveScenario(); - return FALSE; + //return FALSE; } void ScDocument::SetActiveScenario( SCTAB nTab, BOOL bActive ) @@ -1243,21 +1248,23 @@ BOOL ScDocument::HasAutoFilter( SCCOL nCurCol, SCROW nCurRow, SCTAB nCurTab ) BOOL ScDocument::HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) { - if (VALIDTAB(nTab)) - if (pTab[nTab]) - return pTab[nTab]->HasColHeader( nStartCol, nStartRow, nEndCol, nEndRow ); + return VALIDTAB(nTab) && pTab[nTab] && pTab[nTab]->HasColHeader( nStartCol, nStartRow, nEndCol, nEndRow ); + //if (VALIDTAB(nTab)) + // if (pTab[nTab]) + // return pTab[nTab]->HasColHeader( nStartCol, nStartRow, nEndCol, nEndRow ); - return FALSE; + //return FALSE; } BOOL ScDocument::HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) { - if (VALIDTAB(nTab)) - if (pTab[nTab]) - return pTab[nTab]->HasRowHeader( nStartCol, nStartRow, nEndCol, nEndRow ); + return VALIDTAB(nTab) && pTab[nTab] && pTab[nTab]->HasRowHeader( nStartCol, nStartRow, nEndCol, nEndRow ); + //if (VALIDTAB(nTab)) + // if (pTab[nTab]) + // return pTab[nTab]->HasRowHeader( nStartCol, nStartRow, nEndCol, nEndRow ); - return FALSE; + //return FALSE; } // @@ -1352,10 +1359,11 @@ BOOL ScDocument::GetDataEntries( SCCOL nCol, SCROW nRow, SCTAB nTab, } } - if (ValidTab(nTab) && pTab[nTab]) - return pTab[nTab]->GetDataEntries( nCol, nRow, rStrings, bLimit ); + return ValidTab(nTab) && pTab[nTab] && pTab[nTab]->GetDataEntries( nCol, nRow, rStrings, bLimit ); + //if (ValidTab(nTab) && pTab[nTab]) + // return pTab[nTab]->GetDataEntries( nCol, nRow, rStrings, bLimit ); - return FALSE; + //return FALSE; } // @@ -1698,9 +1706,8 @@ BOOL ScDocument::IsDocEditable() const BOOL ScDocument::IsTabProtected( SCTAB nTab ) const { - if (VALIDTAB(nTab)) - if (pTab[nTab]) - return pTab[nTab]->IsProtected(); + if (VALIDTAB(nTab) && pTab[nTab]) + return pTab[nTab]->IsProtected(); DBG_ERROR("Falsche Tabellennummer"); return FALSE; @@ -1713,9 +1720,8 @@ const uno::Sequence<sal_Int8>& ScDocument::GetDocPassword() const const uno::Sequence<sal_Int8>& ScDocument::GetTabPassword( SCTAB nTab ) const { - if (VALIDTAB(nTab)) - if (pTab[nTab]) - return pTab[nTab]->GetPassword(); + if (VALIDTAB(nTab) && pTab[nTab]) + return pTab[nTab]->GetPassword(); DBG_ERROR("Falsche Tabellennummer"); return aProtectPass; diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index fb914947ff6d..926ae821d248 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -102,7 +102,7 @@ BOOL ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab, if (pCell) { - // FIXME FIXME FIXME this might need to be reworked now that we have ScErrorToken and ScFormulaResult, double check !!! + // FIXME FIXME FIXME this might need to be reworked now that we have formula::FormulaErrorToken and ScFormulaResult, double check !!! DBG_ERRORFILE("ScDocument::Solver: -> ScFormulaCell::GetValueAlways might need reimplementation"); pCell->Interpret(); USHORT nErrCode = pCell->GetErrCode(); @@ -121,7 +121,7 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1, const ScMarkData& rMark, const String& rFormula, const ScTokenArray* pArr, - const ScGrammar::Grammar eGram ) + const formula::FormulaGrammar::Grammar eGram ) { PutInOrder(nCol1, nCol2); PutInOrder(nRow1, nRow2); @@ -174,7 +174,7 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1, aRefData.CalcRelFromAbs( ScAddress( nCol1, nRow1, nTab1 ) ); ScTokenArray aArr; - ScToken* t = aArr.AddMatrixSingleReference( aRefData); + ScToken* t = static_cast<ScToken*>(aArr.AddMatrixSingleReference( aRefData)); for (i = 0; i <= MAXTAB; i++) { @@ -236,13 +236,15 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera String aForString = '='; aForString += ScCompiler::GetNativeSymbol(ocTableOp); aForString += ScCompiler::GetNativeSymbol( ocOpen); + + const String& sSep = ScCompiler::GetNativeSymbol( ocSep); if (rParam.nMode == 0) // nur Spalte { aRef.Set( rParam.aRefFormulaCell.GetAddress(), TRUE, FALSE, FALSE ); aForString += aRef.GetRefString(this, nTab1); - aForString += ScCompiler::GetNativeSymbol( ocSep); + aForString += sSep; aForString += rParam.aRefColCell.GetRefString(this, nTab1); - aForString += ScCompiler::GetNativeSymbol( ocSep); + aForString += sSep; aRef.Set( nCol1, nRow1, nTab1, FALSE, TRUE, TRUE ); aForString += aRef.GetRefString(this, nTab1); nCol1++; @@ -253,9 +255,9 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera { aRef.Set( rParam.aRefFormulaCell.GetAddress(), FALSE, TRUE, FALSE ); aForString += aRef.GetRefString(this, nTab1); - aForString += ScCompiler::GetNativeSymbol( ocSep); + aForString += sSep; aForString += rParam.aRefRowCell.GetRefString(this, nTab1); - aForString += ScCompiler::GetNativeSymbol( ocSep); + aForString += sSep; aRef.Set( nCol1, nRow1, nTab1, TRUE, FALSE, TRUE ); aForString += aRef.GetRefString(this, nTab1); nRow1++; @@ -265,14 +267,14 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera else // beides { aForString += rParam.aRefFormulaCell.GetRefString(this, nTab1); - aForString += ScCompiler::GetNativeSymbol( ocSep); + aForString += sSep; aForString += rParam.aRefColCell.GetRefString(this, nTab1); - aForString += ScCompiler::GetNativeSymbol( ocSep); + aForString += sSep; aRef.Set( nCol1, nRow1 + 1, nTab1, FALSE, TRUE, TRUE ); aForString += aRef.GetRefString(this, nTab1); - aForString += ScCompiler::GetNativeSymbol( ocSep); + aForString += sSep; aForString += rParam.aRefRowCell.GetRefString(this, nTab1); - aForString += ScCompiler::GetNativeSymbol( ocSep); + aForString += sSep; aRef.Set( nCol1 + 1, nRow1, nTab1, TRUE, FALSE, TRUE ); aForString += aRef.GetRefString(this, nTab1); nCol1++; nRow1++; @@ -280,7 +282,7 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera aForString += ScCompiler::GetNativeSymbol( ocClose); ScFormulaCell aRefCell( this, ScAddress( nCol1, nRow1, nTab1 ), aForString, - ScGrammar::GRAM_NATIVE, MM_NONE ); + formula::FormulaGrammar::GRAM_NATIVE, MM_NONE ); for( j = nCol1; j <= nCol2; j++ ) for( k = nRow1; k <= nRow2; k++ ) for (i = 0; i <= MAXTAB; i++) diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx index f74bb07f5da4..c1fb2bd51e70 100644 --- a/sc/source/core/data/documen7.cxx +++ b/sc/source/core/data/documen7.cxx @@ -46,7 +46,7 @@ #include "brdcst.hxx" #include "bcaslot.hxx" #include "cell.hxx" -#include "errorcodes.hxx" // errCircularReference +#include "formula/errorcodes.hxx" // errCircularReference #include "scerrors.hxx" #include "docoptio.hxx" #include "refupdat.hxx" diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index 850eff7902ec..63acede160c9 100644 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -50,7 +50,7 @@ #include "docpool.hxx" #include "markdata.hxx" #include "attrib.hxx" -#include "errorcodes.hxx" // errNoValue +#include "formula/errorcodes.hxx" // errNoValue #include "miscuno.hxx" #include "globstr.hrc" #include "stlpool.hxx" diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 8a118fa1209a..0baa974628fd 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -88,6 +88,8 @@ #include "globstr.hrc" #include "scfuncs.hrc" #include "sc.hrc" +#include "scmod.hxx" +#include "appoptio.hxx" // ----------------------------------------------------------------------- @@ -586,7 +588,7 @@ void ScGlobal::Init() pProtectedBrushItem = new SvxBrushItem( Color( COL_LIGHTGRAY ), ATTR_BACKGROUND ); UpdatePPT(NULL); - ScCompiler::InitSymbolsNative(); + //ScCompiler::InitSymbolsNative(); // ScParameterClassification _after_ Compiler, needs function resources if // arguments are to be merged in, which in turn need strings of function // names from the compiler. @@ -1129,344 +1131,6 @@ void ScGlobal::AddLanguage( SfxItemSet& rSet, SvNumberFormatter& rFormatter ) -//=================================================================== -// class ScFormulaUtil - statische Methoden -//=================================================================== - -#define FUNC_NOTFOUND 0xffff - -ScFuncDesc aDefaultFuncDesc; - -BOOL ScFormulaUtil::GetNextFunc( const String& rFormula, - BOOL bBack, - xub_StrLen& rFStart, // Ein- und Ausgabe - xub_StrLen* pFEnd, // = NULL - const ScFuncDesc** ppFDesc, // = NULL - String*** pppArgs ) // = NULL -{ - BOOL bFound = FALSE; - xub_StrLen nOldStart = rFStart; - String aFname; - - rFStart = GetFunctionStart( rFormula, rFStart, bBack, ppFDesc ? &aFname : NULL ); - bFound = ( rFStart != FUNC_NOTFOUND ); - - if ( bFound ) - { - if ( pFEnd ) - *pFEnd = GetFunctionEnd( rFormula, rFStart ); - - if ( ppFDesc ) - { - ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); - *ppFDesc = pFuncMgr->Get( aFname ); - if ( *ppFDesc ) - { - if (pppArgs) - *pppArgs = GetArgStrings( rFormula, rFStart, (*ppFDesc)->nArgCount ); - } - else - { - *ppFDesc = &aDefaultFuncDesc; - } - } - } - else - rFStart = nOldStart; - - return bFound; -} - -//------------------------------------------------------------------------ - -void ScFormulaUtil::FillArgStrings( const String& rFormula, - xub_StrLen nFuncPos, - USHORT nArgs, - String** aArgArr ) -{ - if ( !aArgArr ) return; - - xub_StrLen nStart = 0; - xub_StrLen nEnd = 0; - USHORT i; - BOOL bLast = FALSE; - - for ( i=0; i<nArgs && !bLast; i++ ) - { - nStart = GetArgStart( rFormula, nFuncPos, i ); - - if ( i+1<nArgs ) // letztes Argument? - { - nEnd = GetArgStart( rFormula, nFuncPos, i+1 ); - - if ( nEnd != nStart ) - aArgArr[i] = new String( rFormula.Copy( nStart, nEnd-1-nStart ) ); - else - aArgArr[i] = new String, bLast = TRUE; - } - else - { - nEnd = GetFunctionEnd( rFormula, nFuncPos )-1; - if ( nStart < nEnd ) - aArgArr[i] = new String( rFormula.Copy( nStart, nEnd-nStart ) ); - else - aArgArr[i] = new String; - } - } - - if ( bLast ) - for ( ; i<nArgs; i++ ) - aArgArr[i] = new String; -} - -//------------------------------------------------------------------------ - -String** ScFormulaUtil::GetArgStrings( const String& rFormula, - xub_StrLen nFuncPos, - USHORT nArgs ) -{ - String** aArgArr = NULL; - if (nArgs) - { - aArgArr = new String*[nArgs]; - FillArgStrings( rFormula, nFuncPos, nArgs, aArgArr ); - } - return aArgArr; -} - -//------------------------------------------------------------------------ - -inline BOOL IsFormulaText( const String& rStr, xub_StrLen nPos ) -{ - if( ScGlobal::pCharClass->isLetterNumeric( rStr, nPos ) ) - return TRUE; - else - { // In internationalized versions function names may contain a dot - // and in every version also an underscore... ;-) - sal_Unicode c = rStr.GetChar(nPos); - return c == '.' || c == '_'; - } - -} - -xub_StrLen ScFormulaUtil::GetFunctionStart( const String& rFormula, - xub_StrLen nStart, - BOOL bBack, - String* pFuncName ) -{ - xub_StrLen nStrLen = rFormula.Len(); - - if ( nStrLen < nStart ) - return nStart; - - xub_StrLen nFStart = FUNC_NOTFOUND; - xub_StrLen nParPos = nStart; - - BOOL bRepeat, bFound; - do - { - bFound = FALSE; - bRepeat = FALSE; - - if ( bBack ) - { - while ( !bFound && (nParPos > 0) ) - { - if ( rFormula.GetChar(nParPos) == '"' ) - { - nParPos--; - while ( (nParPos > 0) && rFormula.GetChar(nParPos) != '"' ) - nParPos--; - if (nParPos > 0) - nParPos--; - } - else if ( (bFound = ( rFormula.GetChar(nParPos) == '(' ) ) == FALSE ) - nParPos--; - } - } - else - { - while ( !bFound && (nParPos < nStrLen) ) - { - if ( rFormula.GetChar(nParPos) == '"' ) - { - nParPos++; - while ( (nParPos < nStrLen) && rFormula.GetChar(nParPos) != '"' ) - nParPos++; - nParPos++; - } - else if ( (bFound = ( rFormula.GetChar(nParPos) == '(' ) ) == FALSE ) - nParPos++; - } - } - - if ( bFound && (nParPos > 0) ) - { - nFStart = nParPos-1; - - while ( (nFStart > 0) && IsFormulaText( rFormula, nFStart )) - nFStart--; - } - - nFStart++; - - if ( bFound ) - { - if ( IsFormulaText( rFormula, nFStart ) ) - { - // Funktion gefunden - if ( pFuncName ) - *pFuncName = rFormula.Copy( nFStart, nParPos-nFStart ); - } - else // Klammern ohne Funktion -> weitersuchen - { - bRepeat = TRUE; - if ( !bBack ) - nParPos++; - else if (nParPos > 0) - nParPos--; - else - bRepeat = FALSE; - } - } - else // keine Klammern gefunden - { - nFStart = FUNC_NOTFOUND; - if ( pFuncName ) - pFuncName->Erase(); - } - } - while(bRepeat); - - return nFStart; -} - -//------------------------------------------------------------------------ - -xub_StrLen ScFormulaUtil::GetFunctionEnd( const String& rStr, xub_StrLen nStart ) -{ - xub_StrLen nStrLen = rStr.Len(); - - if ( nStrLen < nStart ) - return nStart; - - // We assume the following tokens are single-character tokens. - const sal_Unicode open = ScCompiler::GetStringFromOpCode(ocOpen).GetChar(0); - const sal_Unicode close = ScCompiler::GetStringFromOpCode(ocClose).GetChar(0); - const sal_Unicode sep = ScCompiler::GetStringFromOpCode(ocSep).GetChar(0); - const sal_Unicode arrayOpen = ScCompiler::GetStringFromOpCode(ocArrayOpen).GetChar(0); - const sal_Unicode arrayClose = ScCompiler::GetStringFromOpCode(ocArrayClose).GetChar(0); - - short nParCount = 0; - bool bInArray = false; - BOOL bFound = FALSE; - - while ( !bFound && (nStart < nStrLen) ) - { - sal_Unicode c = rStr.GetChar(nStart); - - if ( c == '"' ) - { - nStart++; - while ( (nStart < nStrLen) && rStr.GetChar(nStart) != '"' ) - nStart++; - } - else if ( c == open ) - nParCount++; - else if ( c == close ) - { - nParCount--; - if ( nParCount == 0 ) - bFound = TRUE; - else if ( nParCount < 0 ) - { - bFound = TRUE; - nStart--; // einen zu weit gelesen - } - } - else if ( c == arrayOpen ) - { - bInArray = true; - } - else if ( c == arrayClose ) - { - bInArray = false; - } - else if ( c == sep ) - { - if ( !bInArray && nParCount == 0 ) - { - bFound = TRUE; - nStart--; // einen zu weit gelesen - } - } - nStart++; // hinter gefundene Position stellen - } - - return nStart; -} - -//------------------------------------------------------------------ - -xub_StrLen ScFormulaUtil::GetArgStart( const String& rStr, xub_StrLen nStart, USHORT nArg ) -{ - xub_StrLen nStrLen = rStr.Len(); - - if ( nStrLen < nStart ) - return nStart; - - // We assume the following tokens are single-character tokens. - const sal_Unicode open = ScCompiler::GetStringFromOpCode(ocOpen).GetChar(0); - const sal_Unicode close = ScCompiler::GetStringFromOpCode(ocClose).GetChar(0); - const sal_Unicode sep = ScCompiler::GetStringFromOpCode(ocSep).GetChar(0); - const sal_Unicode arrayOpen = ScCompiler::GetStringFromOpCode(ocArrayOpen).GetChar(0); - const sal_Unicode arrayClose = ScCompiler::GetStringFromOpCode(ocArrayClose).GetChar(0); - - short nParCount = 0; - bool bInArray = false; - BOOL bFound = FALSE; - - while ( !bFound && (nStart < nStrLen) ) - { - sal_Unicode c = rStr.GetChar(nStart); - - if ( c == '"' ) - { - nStart++; - while ( (nStart < nStrLen) && rStr.GetChar(nStart) != '"' ) - nStart++; - } - else if ( c == open ) - { - bFound = ( nArg == 0 ); - nParCount++; - } - else if ( c == close ) - { - nParCount--; - bFound = ( nParCount == 0 ); - } - else if ( c == arrayOpen ) - { - bInArray = true; - } - else if ( c == arrayClose ) - { - bInArray = false; - } - else if ( c == sep ) - { - if ( !bInArray && nParCount == 1 ) - { - nArg--; - bFound = ( nArg == 0 ); - } - } - nStart++; - } - - return nStart; -} //=================================================================== @@ -1570,11 +1234,14 @@ USHORT ScFuncRes::GetNum() // um an die protected von Resource ranzukommen class ScResourcePublisher : public Resource { +private: + void FreeResource() { Resource::FreeResource(); } public: ScResourcePublisher( const ScResId& rId ) : Resource( rId ) {} + ~ScResourcePublisher() { FreeResource(); } BOOL IsAvailableRes( const ResId& rId ) const { return Resource::IsAvailableRes( rId ); } - void FreeResource() { Resource::FreeResource(); } + }; @@ -1596,8 +1263,7 @@ ScFunctionList::ScFunctionList() : for ( USHORT k = 0; k < nBlocks; k++ ) { - ScResourcePublisher* pBlock = - new ScResourcePublisher( ScResId( nDescBlock[k] ) ); + ::std::auto_ptr<ScResourcePublisher> pBlock( new ScResourcePublisher( ScResId( nDescBlock[k] ) ) ); // Browse for all possible OpCodes. This is not the fastest method, but // otherwise the sub resources within the resource blocks and the // resource blocks themselfs would had to be ordered according to @@ -1628,25 +1294,23 @@ ScFunctionList::ScFunctionList() : } } } - pBlock->FreeResource(); - delete pBlock; } USHORT nNextId = SC_OPCODE_LAST_OPCODE_ID + 1; // FuncID for AddIn functions // Auswertung AddIn-Liste - String aDefArgNameValue = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("value")); - String aDefArgNameString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("string")); - String aDefArgNameValues = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("values")); - String aDefArgNameStrings = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("strings")); - String aDefArgNameCells = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("cells")); - String aDefArgNameNone = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("none")); - String aDefArgDescValue = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("a value")); - String aDefArgDescString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("a string")); - String aDefArgDescValues = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("array of values")); - String aDefArgDescStrings = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("array of strings")); - String aDefArgDescCells = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("range of cells")); - String aDefArgDescNone = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("none")); + String aDefArgNameValue(RTL_CONSTASCII_STRINGPARAM("value")); + String aDefArgNameString(RTL_CONSTASCII_STRINGPARAM("string")); + String aDefArgNameValues(RTL_CONSTASCII_STRINGPARAM("values")); + String aDefArgNameStrings(RTL_CONSTASCII_STRINGPARAM("strings")); + String aDefArgNameCells(RTL_CONSTASCII_STRINGPARAM("cells")); + String aDefArgNameNone(RTL_CONSTASCII_STRINGPARAM("none")); + String aDefArgDescValue(RTL_CONSTASCII_STRINGPARAM("a value")); + String aDefArgDescString(RTL_CONSTASCII_STRINGPARAM("a string")); + String aDefArgDescValues(RTL_CONSTASCII_STRINGPARAM("array of values")); + String aDefArgDescStrings(RTL_CONSTASCII_STRINGPARAM("array of strings")); + String aDefArgDescCells(RTL_CONSTASCII_STRINGPARAM("range of cells")); + String aDefArgDescNone(RTL_CONSTASCII_STRINGPARAM("none")); String aArgName, aArgDesc; pFuncColl = ScGlobal::GetFuncCollection(); for (i = 0; i < pFuncColl->GetCount(); i++) @@ -1832,37 +1496,9 @@ void ScFuncDesc::Clear() //------------------------------------------------------------------------ -void ScFuncDesc::InitArgumentInfo() const -{ - // get the full argument description - // (add-in has to be instantiated to get the type information) - - if ( bIncomplete && pFuncName ) - { - ScUnoAddInCollection& rAddIns = *ScGlobal::GetAddInCollection(); - String aIntName = rAddIns.FindFunction( *pFuncName, TRUE ); // pFuncName is upper-case - - if ( aIntName.Len() ) - { - // GetFuncData with bComplete=true loads the component and updates - // the global function list if needed. - - rAddIns.GetFuncData( aIntName, true ); - } - - if ( bIncomplete ) - { - DBG_ERRORFILE( "couldn't initialize add-in function" ); - const_cast<ScFuncDesc*>(this)->bIncomplete = FALSE; // even if there was an error, don't try again - } - } -} - -//------------------------------------------------------------------------ - String ScFuncDesc::GetParamList() const { - const String& sep = ScCompiler::GetStringFromOpCode(ocSep); + const String& sep = ScCompiler::GetNativeSymbol(ocSep); String aSig; @@ -1949,41 +1585,41 @@ String ScFuncDesc::GetSignature() const //------------------------------------------------------------------------ -String ScFuncDesc::GetFormulaString( String** aArgArr ) const +::rtl::OUString ScFuncDesc::getFormula( const ::std::vector< ::rtl::OUString >& _aArguments ) const { - const String& sep = ScCompiler::GetStringFromOpCode(ocSep); + const String& sep = ScCompiler::GetNativeSymbol(ocSep); - String aFormula; + ::rtl::OUStringBuffer aFormula; if(pFuncName) { - aFormula= *pFuncName; + aFormula.append( *pFuncName ); - aFormula += '('; + aFormula.appendAscii( "(" ); + ::std::vector< ::rtl::OUString >::const_iterator aIter = _aArguments.begin(); + ::std::vector< ::rtl::OUString >::const_iterator aEnd = _aArguments.end(); - if ( nArgCount > 0 && aArgArr ) + if ( nArgCount > 0 && aIter != aEnd ) { - BOOL bLastArg = ( aArgArr[0]->Len() == 0 ); + BOOL bLastArg = ( aIter->getLength() == 0 ); - if ( !bLastArg ) + while( aIter != aEnd && !bLastArg ) { - for ( USHORT i=0; i<nArgCount && !bLastArg; i++ ) + aFormula.append( *(aIter) ); + if ( aIter != (aEnd-1) ) { - aFormula += *(aArgArr[i]); - - if ( i < (nArgCount-1) ) - { - bLastArg = !( aArgArr[i+1]->Len() > 0 ); - if ( !bLastArg ) - aFormula += sep; - } + bLastArg = !( (aIter+1)->getLength() > 0 ); + if ( !bLastArg ) + aFormula.append( sep ); } + + ++aIter; } } - aFormula += ')'; + aFormula.appendAscii( ")" ); } - return aFormula; + return aFormula.makeStringAndClear(); } //------------------------------------------------------------------------ @@ -2009,28 +1645,111 @@ USHORT ScFuncDesc::GetSuppressedArgCount() const //------------------------------------------------------------------------ -::std::vector<USHORT> ScFuncDesc::GetVisibleArgMapping() const +::rtl::OUString ScFuncDesc::getFunctionName() const +{ + ::rtl::OUString sRet; + if ( pFuncName ) + sRet = *pFuncName; + return sRet; +} +// ----------------------------------------------------------------------------- +const formula::IFunctionCategory* ScFuncDesc::getCategory() const +{ + return ScGlobal::GetStarCalcFunctionMgr()->getCategory(nCategory); +} +// ----------------------------------------------------------------------------- +::rtl::OUString ScFuncDesc::getDescription() const +{ + ::rtl::OUString sRet; + if ( pFuncDesc ) + sRet = *pFuncDesc; + return sRet; +} +// ----------------------------------------------------------------------------- +// GetSuppressedArgCount +xub_StrLen ScFuncDesc::getSuppressedArgumentCount() const +{ + return GetSuppressedArgCount(); +} +// ----------------------------------------------------------------------------- +// +void ScFuncDesc::fillVisibleArgumentMapping(::std::vector<USHORT>& _rArguments) const { - ::std::vector<USHORT> aMap; if (!bHasSuppressedArgs || !pDefArgFlags) { - aMap.resize( nArgCount); - ::std::iota( aMap.begin(), aMap.end(), 0); - return aMap; + _rArguments.resize( nArgCount); + ::std::iota( _rArguments.begin(), _rArguments.end(), 0); } - aMap.reserve( nArgCount); + _rArguments.reserve( nArgCount); USHORT nArgs = nArgCount; if (nArgs >= VAR_ARGS) nArgs -= VAR_ARGS - 1; for (USHORT i=0; i < nArgs; ++i) { if (!pDefArgFlags[i].bSuppress) - aMap.push_back(i); + _rArguments.push_back(i); + } +} +// ----------------------------------------------------------------------------- +void ScFuncDesc::initArgumentInfo() const +{ + // get the full argument description + // (add-in has to be instantiated to get the type information) + + if ( bIncomplete && pFuncName ) + { + ScUnoAddInCollection& rAddIns = *ScGlobal::GetAddInCollection(); + String aIntName = rAddIns.FindFunction( *pFuncName, TRUE ); // pFuncName is upper-case + + if ( aIntName.Len() ) + { + // GetFuncData with bComplete=true loads the component and updates + // the global function list if needed. + + rAddIns.GetFuncData( aIntName, true ); + } + + if ( bIncomplete ) + { + DBG_ERRORFILE( "couldn't initialize add-in function" ); + const_cast<ScFuncDesc*>(this)->bIncomplete = FALSE; // even if there was an error, don't try again + } } - return aMap; } +// ----------------------------------------------------------------------------- +::rtl::OUString ScFuncDesc::getSignature() const +{ + return GetSignature(); +} +// ----------------------------------------------------------------------------- +long ScFuncDesc::getHelpId() const +{ + return nHelpId; +} +// ----------------------------------------------------------------------------- +// parameter +sal_uInt32 ScFuncDesc::getParameterCount() const +{ + return nArgCount; +} +// ----------------------------------------------------------------------------- +::rtl::OUString ScFuncDesc::getParameterName(sal_uInt32 _nPos) const +{ + return *(ppDefArgNames[_nPos]); +} +// ----------------------------------------------------------------------------- +::rtl::OUString ScFuncDesc::getParameterDescription(sal_uInt32 _nPos) const +{ + return *(ppDefArgDescs[_nPos]); +} +// ----------------------------------------------------------------------------- +bool ScFuncDesc::isParameterOptional(sal_uInt32 _nPos) const +{ + return pDefArgFlags[_nPos].bOptional; +} +// ----------------------------------------------------------------------------- //======================================================================== // class ScFunctionMgr: @@ -2084,7 +1803,7 @@ ScFunctionMgr::~ScFunctionMgr() //------------------------------------------------------------------------ -const ScFuncDesc* ScFunctionMgr::Get( const String& rFName ) +const ScFuncDesc* ScFunctionMgr::Get( const String& rFName ) const { const ScFuncDesc* pDesc = NULL; if (rFName.Len() <= pFuncList->GetMaxFuncNameLen()) @@ -2096,7 +1815,7 @@ const ScFuncDesc* ScFunctionMgr::Get( const String& rFName ) //------------------------------------------------------------------------ -const ScFuncDesc* ScFunctionMgr::Get( USHORT nFIndex ) +const ScFuncDesc* ScFunctionMgr::Get( USHORT nFIndex ) const { const ScFuncDesc* pDesc; for (pDesc = First(0); pDesc; pDesc = Next()) @@ -2107,7 +1826,7 @@ const ScFuncDesc* ScFunctionMgr::Get( USHORT nFIndex ) //------------------------------------------------------------------------ -const ScFuncDesc* ScFunctionMgr::First( USHORT nCategory ) +const ScFuncDesc* ScFunctionMgr::First( USHORT nCategory ) const { DBG_ASSERT( nCategory < MAX_FUNCCAT, "Unbekannte Kategorie" ); @@ -2132,6 +1851,100 @@ const ScFuncDesc* ScFunctionMgr::Next() const else return NULL; } +sal_uInt32 ScFunctionMgr::getCount() const +{ + return MAX_FUNCCAT - 1; +} +const formula::IFunctionCategory* ScFunctionMgr::getCategory(sal_uInt32 nCategory) const +{ + formula::IFunctionCategory* pRet = NULL; + if ( nCategory < (MAX_FUNCCAT-1) ) + { + pRet = new ScFunctionCategory(const_cast<ScFunctionMgr*>(this),aCatLists[nCategory+1],nCategory); // aCatLists[0] is "all" + } + return pRet; +} +// ----------------------------------------------------------------------------- +const formula::IFunctionDescription* ScFunctionMgr::getFunctionByName(const ::rtl::OUString& _sFunctionName) const +{ + return Get(_sFunctionName); +} +// ----------------------------------------------------------------------------- +void ScFunctionMgr::fillLastRecentlyUsedFunctions(::std::vector< const formula::IFunctionDescription*>& _rLastRUFunctions) const +{ +#define LRU_MAX 10 + + const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions(); + USHORT nLRUFuncCount = Min( rAppOpt.GetLRUFuncListCount(), (USHORT)LRU_MAX ); + USHORT* pLRUListIds = rAppOpt.GetLRUFuncList(); + + if ( pLRUListIds ) + { + for ( USHORT i=0; i<nLRUFuncCount; i++ ) + _rLastRUFunctions.push_back( Get( pLRUListIds[i] ) ); + } +} +// ----------------------------------------------------------------------------- +String ScFunctionMgr::GetCategoryName(sal_uInt32 _nCategoryNumber ) +{ + if ( _nCategoryNumber > SC_FUNCGROUP_COUNT ) + { + DBG_ERROR("Invalid category number!"); + return String(); + } // if ( _nCategoryNumber >= SC_FUNCGROUP_COUNT ) + + ::std::auto_ptr<ScResourcePublisher> pCategories( new ScResourcePublisher( ScResId( RID_FUNCTION_CATEGORIES ) ) ); + return String(ScResId((USHORT)_nCategoryNumber)); +} +const sal_Unicode ScFunctionMgr::getSingleToken(const formula::IFunctionManager::EToken _eToken) const +{ + switch(_eToken) + { + case eOk: + return ScCompiler::GetNativeSymbol(ocOpen).GetChar(0); + case eClose: + return ScCompiler::GetNativeSymbol(ocClose).GetChar(0); + case eSep: + return ScCompiler::GetNativeSymbol(ocSep).GetChar(0); + case eArrayOpen: + return ScCompiler::GetNativeSymbol(ocArrayOpen).GetChar(0); + case eArrayClose: + return ScCompiler::GetNativeSymbol(ocArrayClose).GetChar(0); + } // switch(_eToken) + return 0; +} +// ----------------------------------------------------------------------------- +sal_uInt32 ScFunctionCategory::getCount() const +{ + return m_pCategory->Count(); +} +// ----------------------------------------------------------------------------- +const formula::IFunctionManager* ScFunctionCategory::getFunctionManager() const +{ + return m_pMgr; +} +// ----------------------------------------------------------------------------- +::rtl::OUString ScFunctionCategory::getName() const +{ + if ( !m_sName.getLength() ) + m_sName = ScFunctionMgr::GetCategoryName(m_nCategory+1); + return m_sName; +} +// ----------------------------------------------------------------------------- +const formula::IFunctionDescription* ScFunctionCategory::getFunction(sal_uInt32 _nPos) const +{ + const ScFuncDesc* pDesc = NULL; + sal_uInt32 i = 0; + for (pDesc = (const ScFuncDesc*)m_pCategory->First(); i < _nPos && pDesc; pDesc = (const ScFuncDesc*)m_pCategory->Next(),++i) + ; + return pDesc; +} +// ----------------------------------------------------------------------------- +sal_uInt32 ScFunctionCategory::getNumber() const +{ + return m_nCategory; +} +// ----------------------------------------------------------------------------- //------------------------------------------------------------------------ diff --git a/sc/source/core/data/pivot2.cxx b/sc/source/core/data/pivot2.cxx index 68d5a47010fe..20303f848b72 100644 --- a/sc/source/core/data/pivot2.cxx +++ b/sc/source/core/data/pivot2.cxx @@ -55,7 +55,7 @@ #include "userlist.hxx" #include "pivot.hxx" #include "rechead.hxx" -#include "errorcodes.hxx" // fuer errNoValue +#include "formula/errorcodes.hxx" // fuer errNoValue #include "refupdat.hxx" #include "stlpool.hxx" #include "stlsheet.hxx" diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 358369ede555..d5b87bc6c572 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -77,7 +77,7 @@ #include "userlist.hxx" #include "zforauto.hxx" #include "subtotal.hxx" -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" #include "rangenam.hxx" #include "docpool.hxx" #include "progress.hxx" diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx index 74d2166595b9..ef4c0c26da01 100644 --- a/sc/source/core/data/table6.cxx +++ b/sc/source/core/data/table6.cxx @@ -84,7 +84,7 @@ BOOL ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo { if ( eCellType == CELLTYPE_FORMULA ) ((ScFormulaCell*)pCell)->GetFormula( aString, - ScGrammar::GRAM_NATIVE_UI); + formula::FormulaGrammar::GRAM_NATIVE_UI); else if ( eCellType == CELLTYPE_EDIT ) bMultiLine = lcl_GetTextWithBreaks( *(const ScEditCell*)pCell, pDocument, aString ); @@ -244,7 +244,7 @@ BOOL ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo } ScAddress aAdr( nCol, nRow, nTab ); ScFormulaCell* pFCell = new ScFormulaCell( pDocument, aAdr, - aString, ScGrammar::GRAM_NATIVE_UI, cMatrixFlag ); + aString,formula::FormulaGrammar::GRAM_NATIVE_UI, cMatrixFlag ); SCCOL nMatCols; SCROW nMatRows; ((ScFormulaCell*)pCell)->GetMatColsRows( nMatCols, nMatRows ); diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index b3e88a05239b..ac01f84d291a 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -62,6 +62,7 @@ #include <math.h> #include <memory> +using namespace formula; //------------------------------------------------------------------------ SV_IMPL_OP_PTRARR_SORT( ScValidationEntries_Impl, ScValidationDataPtr ); @@ -75,7 +76,7 @@ SV_IMPL_OP_PTRARR_SORT( ScValidationEntries_Impl, ScValidationDataPtr ); ScValidationData::ScValidationData( ScValidationMode eMode, ScConditionMode eOper, const String& rExpr1, const String& rExpr2, ScDocument* pDocument, const ScAddress& rPos, - const ScGrammar::Grammar eGrammar ) : + const formula::FormulaGrammar::Grammar eGrammar ) : ScConditionEntry( eOper, rExpr1, rExpr2, pDocument, rPos, eGrammar ), nKey( 0 ), eDataMode( eMode ), @@ -594,11 +595,11 @@ const String* ScStringTokenIterator::Next() return NULL; // seek to next non-separator token - const ScToken* pToken = mrTokArr.NextNoSpaces(); + const FormulaToken* pToken = mrTokArr.NextNoSpaces(); while( pToken && (pToken->GetOpCode() == ocSep) ) pToken = mrTokArr.NextNoSpaces(); - mbOk = !pToken || (pToken->GetType() == svString); + mbOk = !pToken || (pToken->GetType() == formula::svString); const String* pString = (mbOk && pToken) ? &pToken->GetString() : NULL; // string found but empty -> get next token; otherwise return it return (mbSkipEmpty && pString && !pString->Len()) ? Next() : pString; @@ -645,7 +646,7 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings, return false; ScFormulaCell aValidationSrc( pDocument, rPos, &rTokArr, - ScGrammar::GRAM_DEFAULT, MM_FORMULA); + formula::FormulaGrammar::GRAM_DEFAULT, MM_FORMULA); // Make sure the formula gets interpreted and a result is delivered, // regardless of the AutoCalc setting. diff --git a/sc/source/core/inc/cellkeytranslator.hxx b/sc/source/core/inc/cellkeytranslator.hxx index 66805ea896e6..6bf9b9210af3 100644 --- a/sc/source/core/inc/cellkeytranslator.hxx +++ b/sc/source/core/inc/cellkeytranslator.hxx @@ -32,7 +32,7 @@ #define SC_CELLKEY_TRANSLATOR_HXX #include "global.hxx" -#include "opcode.hxx" +#include "formula/opcode.hxx" #include "unotools/transliterationwrapper.hxx" #include <hash_map> #include <list> diff --git a/sc/source/core/inc/core_pch.hxx b/sc/source/core/inc/core_pch.hxx index 8b5258a3a01c..d756d1a91246 100644 --- a/sc/source/core/inc/core_pch.hxx +++ b/sc/source/core/inc/core_pch.hxx @@ -113,7 +113,7 @@ #include <vcl/apptypes.hxx> #include <vcl/vclenum.hxx> #include <globstr.hrc> -#include <compiler.hrc> +#include <formula/compiler.hrc> #include <tools/shl.hxx> #include <compiler.hxx> #include <vcl/font.hxx> diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 3cce11685e54..d163b490c948 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -35,7 +35,7 @@ #include <math.h> #include <rtl/math.hxx> -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" #include "cell.hxx" #include "scdll.hxx" #include "document.hxx" @@ -53,6 +53,7 @@ class SbxVariable; class ScBaseCell; class ScFormulaCell; class SvNumberFormatter; +struct MatrixDoubleOp; struct ScCompare { @@ -71,13 +72,13 @@ struct ScCompare class ScToken; -#define MAXSTACK (4096 / sizeof(ScToken*)) +#define MAXSTACK (4096 / sizeof(formula::FormulaToken*)) class ScTokenStack { public: DECL_FIXEDMEMPOOL_NEWDEL( ScTokenStack ) - ScToken* pPointer[ MAXSTACK ]; + formula::FormulaToken* pPointer[ MAXSTACK ]; }; enum ScIterFunc { @@ -91,12 +92,12 @@ enum ScIterFunc { ifMAX // Maximum }; -struct ScConstTokenRef_less +struct FormulaTokenRef_less { - bool operator () ( const ScConstTokenRef& r1, const ScConstTokenRef& r2 ) const + bool operator () ( const formula::FormulaConstTokenRef& r1, const formula::FormulaConstTokenRef& r2 ) const { return &r1 < &r2; } }; -typedef ::std::map< const ScConstTokenRef, ScTokenRef, ScConstTokenRef_less> ScTokenMatrixMap; +typedef ::std::map< const formula::FormulaConstTokenRef, formula::FormulaTokenRef, FormulaTokenRef_less> ScTokenMatrixMap; class ScInterpreter { @@ -124,26 +125,28 @@ public: /// Fail safe division, returning an errDivisionByZero coded into a double /// if denominator is 0.0 - static inline double div( double fNumerator, double fDenominator ); + static inline double div( const double& fNumerator, const double& fDenominator ); + ScMatrixRef GetNewMat(SCSIZE nC, SCSIZE nR); private: static ScTokenStack* pGlobalStack; static BOOL bGlobalStackInUse; - ScTokenIterator aCode; + formula::FormulaTokenIterator aCode; ScAddress aPos; ScTokenArray& rArr; ScDocument* pDok; - ScTokenRef xResult; + formula::FormulaTokenRef xResult; ScJumpMatrix* pJumpMatrix; // currently active array condition, if any - ScTokenMatrixMap* pTokenMatrixMap; // map ScToken* to ScTokenRef if in array condition + ScTokenMatrixMap* pTokenMatrixMap; // map ScToken* to formula::FormulaTokenRef if in array condition ScFormulaCell* pMyFormulaCell; // the cell of this formula expression SvNumberFormatter* pFormatter; - const ScToken* pCur; // current token + const formula::FormulaToken* + pCur; // current token String aTempStr; // for GetString() ScTokenStack* pStackObj; // contains the stacks - ScToken** pStack; // the current stack + formula::FormulaToken** pStack; // the current stack USHORT nGlobalError; // global (local to this formula expression) error USHORT sp; // stack pointer USHORT maxsp; // the maximal used stack pointer @@ -206,37 +209,37 @@ BOOL CreateCellArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, // Stack operations //----------------------------------------------------------------------------- -/** Does substitute with ScErrorToken in case nGlobalError is set and the token - passed is not ScErrorToken. +/** Does substitute with formula::FormulaErrorToken in case nGlobalError is set and the token + passed is not formula::FormulaErrorToken. Increments RefCount of the original token if not substituted. */ -void Push( ScToken& r ); +void Push( formula::FormulaToken& r ); -/** Does not substitute with ScErrorToken in case nGlobalError is set. +/** Does not substitute with formula::FormulaErrorToken in case nGlobalError is set. Used to push RPN tokens or from within Push() or tokens that are already - explicit ScErrorToken. Increments RefCount. */ -void PushWithoutError( ScToken& r ); + explicit formula::FormulaErrorToken. Increments RefCount. */ +void PushWithoutError( formula::FormulaToken& r ); -/** Clones the token to be pushed or substitutes with ScErrorToken if - nGlobalError is set and the token passed is not ScErrorToken. */ -void PushTempToken( const ScToken& ); +/** Clones the token to be pushed or substitutes with formula::FormulaErrorToken if + nGlobalError is set and the token passed is not formula::FormulaErrorToken. */ +void PushTempToken( const formula::FormulaToken& ); -/** Does substitute with ScErrorToken in case nGlobalError is set and the token - passed is not ScErrorToken. +/** Does substitute with formula::FormulaErrorToken in case nGlobalError is set and the token + passed is not formula::FormulaErrorToken. Increments RefCount of the original token if not substituted. ATTENTION! The token had to be allocated with `new' and must not be used after this call if no RefCount was set because possibly it gets immediately - deleted in case of an errStackOverflow or if substituted with ScErrorToken! */ -void PushTempToken( ScToken* ); + deleted in case of an errStackOverflow or if substituted with formula::FormulaErrorToken! */ +void PushTempToken( formula::FormulaToken* ); -/** Does not substitute with ScErrorToken in case nGlobalError is set. +/** Does not substitute with formula::FormulaErrorToken in case nGlobalError is set. Used to push tokens from within PushTempToken() or tokens that are already - explicit ScErrorToken. Increments RefCount. + explicit formula::FormulaErrorToken. Increments RefCount. ATTENTION! The token had to be allocated with `new' and must not be used after this call if no RefCount was set because possibly it gets immediately decremented again and thus deleted in case of an errStackOverflow! */ -void PushTempTokenWithoutError( ScToken* ); +void PushTempTokenWithoutError( formula::FormulaToken* ); -/** If nGlobalError is set push ScErrorToken. +/** If nGlobalError is set push formula::FormulaErrorToken. If nGlobalError is not set do nothing. Used in PushTempToken() and alike to simplify handling. @return: <TRUE/> if nGlobalError. */ @@ -244,7 +247,7 @@ inline bool IfErrorPushError() { if (nGlobalError) { - PushTempTokenWithoutError( new ScErrorToken( nGlobalError)); + PushTempTokenWithoutError( new formula::FormulaErrorToken( nGlobalError)); return true; } return false; @@ -257,7 +260,7 @@ inline bool IfErrorPushError() void PushCellResultToken( bool bDisplayEmptyAsString, const ScAddress & rAddress, short * pRetTypeExpr, ULONG * pRetIndexExpr ); -ScTokenRef PopToken(); +formula::FormulaTokenRef PopToken(); void Pop(); void PopError(); double PopDouble(); @@ -269,7 +272,7 @@ void SingleRefToVars( const ScSingleRefData & rRef, SCCOL & rCol, SCROW & rRow, void PopSingleRef( ScAddress& ); void PopSingleRef(SCCOL& rCol, SCROW &rRow, SCTAB& rTab); void DoubleRefToRange( const ScComplexRefData&, ScRange&, BOOL bDontCheckForTableOp = FALSE ); -/** If StackVar svDoubleRef pop ScDoubleRefToken and return values of +/** If formula::StackVar formula::svDoubleRef pop ScDoubleRefToken and return values of ScComplexRefData. Else if StackVar svRefList return values of the ScComplexRefData where rRefInList is pointing to. rRefInList is incremented. If rRefInList was the @@ -288,7 +291,7 @@ void PopDoubleRef(SCCOL& rCol1, SCROW &rRow1, SCTAB& rTab1, BOOL bDontCheckForTableOp = FALSE ); BOOL PopDoubleRefOrSingleRef( ScAddress& rAdr ); void PopDoubleRefPushMatrix(); -// If MatrixFormula: convert svDoubleRef to svMatrix, create JumpMatrix. +// If MatrixFormula: convert formula::svDoubleRef to svMatrix, create JumpMatrix. // Else convert area reference parameters marked as ForceArray to array. // Returns TRUE if JumpMatrix created. bool ConvertMatrixParameters(); @@ -307,11 +310,11 @@ void PushDoubleRef(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, void PushMatrix(ScMatrix* pMat); void PushError( USHORT nError ); /// Raw stack type without default replacements. -StackVar GetRawStackType(); -/// Stack type with replacement of defaults, e.g. svMissing and svEmptyCell will result in svDouble. -StackVar GetStackType(); +formula::StackVar GetRawStackType(); +/// Stack type with replacement of defaults, e.g. svMissing and formula::svEmptyCell will result in formula::svDouble. +formula::StackVar GetStackType(); // peek StackType of Parameter, Parameter 1 == TOS, 2 == TOS-1, ... -StackVar GetStackType( BYTE nParam ); +formula::StackVar GetStackType( BYTE nParam ); BYTE GetByte() { return cPar; } // generiert aus DoubleRef positionsabhaengige SingleRef BOOL DoubleRefToPosSingleRef( const ScRange& rRange, ScAddress& rAdr ); @@ -322,7 +325,7 @@ BOOL GetBool() { return GetDouble() != 0.0; } const String& GetString(); // pop matrix and obtain one element, upper left or according to jump matrix ScMatValType GetDoubleOrStringFromMatrix( double& rDouble, String& rString ); -ScMatrixRef CreateMatrixFromDoubleRef( const ScToken* pToken, +ScMatrixRef CreateMatrixFromDoubleRef( const formula::FormulaToken* pToken, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2 ); inline ScTokenMatrixMap& GetTokenMatrixMap(); @@ -609,7 +612,7 @@ double ScGetGCD(double fx, double fy); void ScGCD(); void ScLCM(); //-------------------------- Matrixfunktionen --------------------------------- -ScMatrixRef GetNewMat(SCSIZE nC, SCSIZE nR); + void ScMatValue(); void MEMat(ScMatrix* mM, SCSIZE n); void MFastMult(ScMatrix* pA, ScMatrix* pB, ScMatrix* pR, SCSIZE n, SCSIZE m, SCSIZE l); @@ -619,11 +622,6 @@ void ScMatMult(); void ScMatTrans(); void ScEMat(); void ScMatRef(); -ScMatrixRef MatAdd(ScMatrix* pMat1, ScMatrix* pMat2); -ScMatrixRef MatSub(ScMatrix* pMat1, ScMatrix* pMat2); -ScMatrixRef MatMul(ScMatrix* pMat1, ScMatrix* pMat2); -ScMatrixRef MatDiv(ScMatrix* pMat1, ScMatrix* pMat2); -ScMatrixRef MatPow(ScMatrix* pMat1, ScMatrix* pMat2); ScMatrixRef MatConcat(ScMatrix* pMat1, ScMatrix* pMat2); void ScSumProduct(); void ScSumX2MY2(); @@ -633,6 +631,27 @@ void ScGrowth(); // multiple Regression: Varianzen der Koeffizienten BOOL RGetVariances( ScMatrix* pV, ScMatrix* pX, SCSIZE nC, SCSIZE nR, BOOL bSwapColRow, BOOL bZeroConstant ); +void Calculate(ScMatrixRef& pResMat,ScMatrixRef& pE,ScMatrixRef& pQ,ScMatrixRef& pV,ScMatrixRef& pMatX,BOOL bConstant,SCSIZE N,SCSIZE M,BYTE nCase); +ScMatrixRef Calculate2(const BOOL bConstant,const SCSIZE M ,const SCSIZE N,ScMatrixRef& pMatX,ScMatrixRef& pMatY,BYTE nCase); +bool Calculate3(const SCSIZE M ,ScMatrixRef& pQ); +bool Calculate4(BOOL _bExp,ScMatrixRef& pResMat,ScMatrixRef& pQ,BOOL bConstant,SCSIZE N,SCSIZE M); +bool CalculateSkew(double& fSum,double& fCount,double& vSum,std::vector<double>& values); +void CalculateSlopeIntercept(BOOL bSlope); +void CalculateSmallLarge(BOOL bSmall); +void CalculatePearsonCovar(BOOL _bPearson,BOOL _bStexy); +bool CalculateTest( BOOL _bTemplin + ,const SCSIZE nC1, const SCSIZE nC2,const SCSIZE nR1,const SCSIZE nR2 + ,const ScMatrixRef& pMat1,const ScMatrixRef& pMat2 + ,double& fT,double& fF); +void CalculateLookup(BOOL HLookup); +bool FillEntry(ScQueryEntry& rEntry); +void CalculateAddSub(BOOL _bSub); +void CalculateTrendGrowth(BOOL _bGrowth); +void CalulateRGPRKP(BOOL _bRKP); +void CalculateSumX2MY2SumX2DY2(BOOL _bSumX2DY2); +void CalculateMatrixValue(const ScMatrix* pMat,SCSIZE nC,SCSIZE nR); +bool CheckMatrix(BOOL _bLOG,BOOL _bTrendGrowth,BYTE& nCase,SCSIZE& nCX,SCSIZE& nCY,SCSIZE& nRX,SCSIZE& nRY,SCSIZE& M,SCSIZE& N,ScMatrixRef& pMatX,ScMatrixRef& pMatY); + void ScRGP(); void ScRKP(); void ScForecast(); @@ -747,25 +766,25 @@ public: const ScAddress&, ScTokenArray& ); ~ScInterpreter(); - StackVar Interpret(); + formula::StackVar Interpret(); void SetError(USHORT nError) { if (nError && !nGlobalError) nGlobalError = nError; } - USHORT GetError() { return nGlobalError; } - - StackVar GetResultType() { return xResult->GetType(); } - const String& GetStringResult() { return xResult->GetString(); } - double GetNumResult() { return xResult->GetDouble(); } - ScTokenRef GetResultToken() { return xResult; } - short GetRetFormatType() { return nRetFmtType; } - ULONG GetRetFormatIndex() { return nRetFmtIndex; } + USHORT GetError() const { return nGlobalError; } + formula::StackVar GetResultType() const { return xResult->GetType(); } + const String& GetStringResult() const { return xResult->GetString(); } + double GetNumResult() const { return xResult->GetDouble(); } + formula::FormulaTokenRef + GetResultToken() const { return xResult; } + short GetRetFormatType() const { return nRetFmtType; } + ULONG GetRetFormatIndex() const { return nRetFmtIndex; } }; inline void ScInterpreter::MatrixDoubleRefToMatrix() { - if ( bMatrixFormula && GetStackType() == svDoubleRef ) + if ( bMatrixFormula && GetStackType() == formula::svDoubleRef ) { GetTokenMatrixMap(); // make sure it exists, create if not. PopDoubleRefPushMatrix(); @@ -849,7 +868,7 @@ inline void ScInterpreter::TreatDoubleError( double& rVal ) // static -inline double ScInterpreter::div( double fNumerator, double fDenominator ) +inline double ScInterpreter::div( const double& fNumerator, const double& fDenominator ) { return (fDenominator != 0.0) ? (fNumerator / fDenominator) : CreateDoubleError( errDivisionByZero); diff --git a/sc/source/core/inc/jumpmatrix.hxx b/sc/source/core/inc/jumpmatrix.hxx index 34893187009c..56b7273f3ace 100644 --- a/sc/source/core/inc/jumpmatrix.hxx +++ b/sc/source/core/inc/jumpmatrix.hxx @@ -31,19 +31,19 @@ #ifndef SC_JUMPMATRIX_HXX #define SC_JUMPMATRIX_HXX -#include "token.hxx" -#include "scmatrix.hxx" -#include "errorcodes.hxx" +#include "formula/token.hxx" +#include "formula/errorcodes.hxx" #include <tools/solar.h> #include <vector> +#include "scmatrix.hxx" -typedef ::std::vector< ScToken*> ScTokenVec; +typedef ::std::vector< formula::FormulaToken*> ScTokenVec; struct ScJumpMatrixEntry { double fBool; // 0:= false 1:= true also if no-path // other values may contain error conditions like NAN and INF - short nStart; // start of path (actually start-1, see ScTokenIterator) + short nStart; // start of path (actually start-1, see formula::FormulaTokenIterator) short nNext; // next after path // jump path exists if nStart != nNext, else no path short nStop; // optional stop of path (nPC < nStop) diff --git a/sc/source/core/inc/parclass.hxx b/sc/source/core/inc/parclass.hxx index 6becd7e09b92..be66587b4c0e 100644 --- a/sc/source/core/inc/parclass.hxx +++ b/sc/source/core/inc/parclass.hxx @@ -31,10 +31,13 @@ #ifndef SC_PARCLASS_HXX #define SC_PARCLASS_HXX -#include "opcode.hxx" +#include "formula/opcode.hxx" #include <sys/types.h> // size_t -class ScToken; +namespace formula +{ + class FormulaToken; +} class ScParameterClassification { @@ -50,19 +53,19 @@ public: /** In array formula: single value to be passed. Results in JumpMatrix being created and multiple calls to function. Functions handling a - svDoubleRef by means of DoubleRefToPosSingleRef() or + formula::svDoubleRef by means of DoubleRefToPosSingleRef() or PopDoubleRefOrSingleRef() or GetDouble() or GetString() should have this. */ Value, /** In array formula: area reference must stay reference. Otherwise - don't care. Functions handling a svDoubleRef by means of + don't care. Functions handling a formula::svDoubleRef by means of PopDoubleRefOrSingleRef() should not have this. */ Reference, /** In array formula: convert area reference to array. Function will be called only once if no Value type is involved. Functions able to - handle a svMatrix parameter but not a svDoubleRef parameter as area + handle a svMatrix parameter but not a formula::svDoubleRef parameter as area should have this. */ Array, @@ -80,7 +83,7 @@ public: /** Get one parameter type for function eOp. @param nParameter Which parameter, 0-based */ - static Type GetParameterType( const ScToken* pToken, + static Type GetParameterType( const formula::FormulaToken* pToken, USHORT nParameter); /** Whether OpCode has a parameter of type @@ -126,7 +129,7 @@ private: // ocExternal AddIns static Type GetExternalParameterType( - const ScToken* pToken, USHORT nParameter); + const formula::FormulaToken* pToken, USHORT nParameter); #if OSL_DEBUG_LEVEL > 1 // Generate documentation to stdout if environment variable diff --git a/sc/source/core/src/compiler.src b/sc/source/core/src/compiler.src index 1c953ec8f981..ced403a2baef 100644 --- a/sc/source/core/src/compiler.src +++ b/sc/source/core/src/compiler.src @@ -28,1854 +28,55 @@ * ************************************************************************/ #include "sc.hrc" // Definition RID_XXX -#include "compiler.hrc" // Definition SC_OPCODE_XXX (interne OpCodes) +#include <formula/compiler.hrc> // Definition SC_OPCODE_XXX (interne OpCodes) -Resource RID_SC_FUNCTION_NAMES + + +Resource RID_FUNCTION_CATEGORIES { - String SC_OPCODE_IF - { - Text [ en-US ] = "IF" ; - }; - String SC_OPCODE_CHOSE - { - Text [ en-US ] = "CHOOSE" ; - }; - String SC_OPCODE_OPEN { Text = "(" ; }; - String SC_OPCODE_CLOSE { Text = ")" ; }; - String SC_OPCODE_ARRAY_OPEN { Text = "{" ; }; - String SC_OPCODE_ARRAY_CLOSE { Text = "}" ; }; - String SC_OPCODE_ARRAY_ROW_SEP { Text = "|" ; }; - String SC_OPCODE_ARRAY_COL_SEP { Text = ";" ; }; - String SC_OPCODE_SEP { Text = ";" ; }; - String SC_OPCODE_PERCENT_SIGN { Text = "%" ; }; - String SC_OPCODE_ADD { Text = "+" ; }; - String SC_OPCODE_SUB { Text = "-" ; }; - String SC_OPCODE_MUL { Text = "*" ; }; - String SC_OPCODE_DIV { Text = "/" ; }; - String SC_OPCODE_AMPERSAND { Text = "&" ; }; - String SC_OPCODE_POW { Text = "^" ; }; - String SC_OPCODE_EQUAL { Text = "=" ; }; - String SC_OPCODE_NOT_EQUAL { Text = "<>" ; }; - String SC_OPCODE_LESS { Text = "<" ; }; - String SC_OPCODE_GREATER { Text = ">" ; }; - String SC_OPCODE_LESS_EQUAL { Text = "<=" ; }; - String SC_OPCODE_GREATER_EQUAL { Text = ">=" ; }; - String SC_OPCODE_AND - { - Text [ en-US ] = "AND" ; - }; - String SC_OPCODE_OR - { - Text [ en-US ] = "OR" ; - }; - String SC_OPCODE_INTERSECT { Text = "!" ; }; - String SC_OPCODE_UNION { Text = "~" ; }; - String SC_OPCODE_RANGE { Text = ":" ; }; - String SC_OPCODE_NOT - { - Text [ en-US ] = "NOT" ; - }; - String SC_OPCODE_NEG - { - Text [ en-US ] = "NEG"; - }; - String SC_OPCODE_NEG_SUB { Text = "-" ; }; - String SC_OPCODE_PI - { - // ??? - Text [ en-US ] = "PI" ; - }; - String SC_OPCODE_RANDOM - { - Text [ en-US ] = "RAND" ; - }; - String SC_OPCODE_TRUE - { - Text [ en-US ] = "TRUE" ; - }; - String SC_OPCODE_FALSE - { - Text [ en-US ] = "FALSE" ; - }; - String SC_OPCODE_GET_ACT_DATE - { - Text [ en-US ] = "TODAY" ; - }; - String SC_OPCODE_GET_ACT_TIME - { - Text [ en-US ] = "NOW" ; - }; - String SC_OPCODE_NO_VALUE - { - Text [ en-US ] = "NA" ; - }; - String SC_OPCODE_CURRENT - { - Text [ en-US ] = "CURRENT" ; - }; - String SC_OPCODE_DEG - { - Text [ en-US ] = "DEGREES" ; - }; - String SC_OPCODE_RAD - { - Text [ en-US ] = "RADIANS" ; - }; - String SC_OPCODE_SIN - { - Text [ en-US ] = "SIN" ; - }; - String SC_OPCODE_COS - { - Text [ en-US ] = "COS"; - }; - String SC_OPCODE_TAN - { - Text [ en-US ] = "TAN"; - }; - String SC_OPCODE_COT - { - Text [ en-US ] = "COT"; - }; - String SC_OPCODE_ARC_SIN - { - Text [ en-US ] = "ASIN" ; - }; - String SC_OPCODE_ARC_COS - { - Text [ en-US ] = "ACOS" ; - }; - String SC_OPCODE_ARC_TAN - { - Text [ en-US ] = "ATAN" ; - }; - String SC_OPCODE_ARC_COT - { - Text [ en-US ] = "ACOT" ; - }; - String SC_OPCODE_SIN_HYP - { - Text [ en-US ] = "SINH" ; - }; - String SC_OPCODE_COS_HYP - { - Text [ en-US ] = "COSH" ; - }; - String SC_OPCODE_TAN_HYP - { - Text [ en-US ] = "TANH" ; - }; - String SC_OPCODE_COT_HYP - { - Text [ en-US ] = "COTH" ; - }; - String SC_OPCODE_ARC_SIN_HYP - { - Text [ en-US ] = "ASINH" ; - }; - String SC_OPCODE_ARC_COS_HYP - { - Text [ en-US ] = "ACOSH" ; - }; - String SC_OPCODE_ARC_TAN_HYP - { - Text [ en-US ] = "ATANH" ; - }; - String SC_OPCODE_ARC_COT_HYP - { - Text [ en-US ] = "ACOTH" ; - }; - String SC_OPCODE_EXP - { - Text [ en-US ] = "EXP"; - }; - String SC_OPCODE_LN - { - Text [ en-US ] = "LN"; - }; - String SC_OPCODE_SQRT - { - Text [ en-US ] = "SQRT" ; - }; - String SC_OPCODE_FACT - { - Text [ en-US ] = "FACT" ; - }; - String SC_OPCODE_GET_YEAR - { - Text [ en-US ] = "YEAR" ; - }; - String SC_OPCODE_GET_MONTH - { - Text [ en-US ] = "MONTH" ; - }; - String SC_OPCODE_GET_DAY - { - Text [ en-US ] = "DAY" ; - }; - String SC_OPCODE_GET_HOUR - { - Text [ en-US ] = "HOUR" ; - }; - String SC_OPCODE_GET_MIN - { - Text [ en-US ] = "MINUTE" ; - }; - String SC_OPCODE_GET_SEC - { - Text [ en-US ] = "SECOND" ; - }; - String SC_OPCODE_PLUS_MINUS - { - Text [ en-US ] = "SIGN" ; - }; - String SC_OPCODE_ABS - { - Text [ en-US ] = "ABS" ; - }; - String SC_OPCODE_INT - { - Text [ en-US ] = "INT" ; - }; - String SC_OPCODE_PHI - { - Text [ en-US ] = "PHI"; - }; - String SC_OPCODE_GAUSS - { - Text [ en-US ] = "GAUSS"; - }; - String SC_OPCODE_IS_EMPTY - { - Text [ en-US ] = "ISBLANK" ; - }; - String SC_OPCODE_IS_STRING - { - Text [ en-US ] = "ISTEXT" ; - }; - String SC_OPCODE_IS_NON_STRING - { - Text [ en-US ] = "ISNONTEXT" ; - }; - String SC_OPCODE_IS_LOGICAL - { - Text [ en-US ] = "ISLOGICAL" ; - }; - String SC_OPCODE_TYPE - { - Text [ en-US ] = "TYPE" ; - }; - String SC_OPCODE_CELL - { - Text [ en-US ] = "CELL"; - }; - String SC_OPCODE_IS_REF - { - Text [ en-US ] = "ISREF" ; - }; - String SC_OPCODE_IS_VALUE - { - Text [ en-US ] = "ISNUMBER" ; - }; - String SC_OPCODE_IS_FORMULA - { - Text [ en-US ] = "ISFORMULA" ; - }; - String SC_OPCODE_IS_NV - { - Text [ en-US ] = "ISNA" ; - }; - String SC_OPCODE_IS_ERR - { - Text [ en-US ] = "ISERR" ; - }; - String SC_OPCODE_IS_ERROR - { - Text [ en-US ] = "ISERROR" ; - }; - String SC_OPCODE_IS_EVEN - { - Text [ en-US ] = "ISEVEN" ; - }; - String SC_OPCODE_IS_ODD - { - Text [ en-US ] = "ISODD" ; - }; - String SC_OPCODE_N - { - Text [ en-US ] = "N" ; - }; - String SC_OPCODE_GET_DATE_VALUE - { - Text [ en-US ] = "DATEVALUE" ; - }; - String SC_OPCODE_GET_TIME_VALUE - { - Text [ en-US ] = "TIMEVALUE" ; - }; - String SC_OPCODE_CODE - { - Text [ en-US ] = "CODE" ; - }; - String SC_OPCODE_TRIM - { - Text [ en-US ] = "TRIM" ; - }; - String SC_OPCODE_UPPER - { - Text [ en-US ] = "UPPER" ; - }; - String SC_OPCODE_PROPPER - { - Text [ en-US ] = "PROPER" ; - }; - String SC_OPCODE_LOWER - { - Text [ en-US ] = "LOWER" ; - }; - String SC_OPCODE_LEN - { - Text [ en-US ] = "LEN" ; - }; - String SC_OPCODE_T - { - Text [ en-US ] = "T"; - }; - String SC_OPCODE_VALUE - { - Text [ en-US ] = "VALUE" ; - }; - String SC_OPCODE_CLEAN - { - Text [ en-US ] = "CLEAN" ; - }; - String SC_OPCODE_CHAR - { - Text [ en-US ] = "CHAR" ; - }; - String SC_OPCODE_JIS - { - Text [ en-US ] = "JIS" ; - }; - String SC_OPCODE_ASC - { - Text [ en-US ] = "ASC" ; - }; - String SC_OPCODE_UNICODE - { - Text [ en-US ] = "UNICODE" ; - }; - String SC_OPCODE_UNICHAR - { - Text [ en-US ] = "UNICHAR" ; - }; - String SC_OPCODE_LOG10 - { - Text [ en-US ] = "LOG10"; - }; - String SC_OPCODE_EVEN - { - Text [ en-US ] = "EVEN" ; - }; - String SC_OPCODE_ODD - { - Text [ en-US ] = "ODD" ; - }; - String SC_OPCODE_STD_NORM_DIST - { - Text [ en-US ] = "NORMSDIST" ; - }; - String SC_OPCODE_FISHER - { - Text [ en-US ] = "FISHER"; - }; - String SC_OPCODE_FISHER_INV - { - Text [ en-US ] = "FISHERINV" ; - }; - String SC_OPCODE_S_NORM_INV - { - Text [ en-US ] = "NORMSINV" ; - }; - String SC_OPCODE_GAMMA_LN - { - Text [ en-US ] = "GAMMALN" ; - }; - String SC_OPCODE_ERROR_TYPE - { - Text [ en-US ] = "ERRORTYPE" ; - }; - String SC_OPCODE_ERR_CELL { Text = "ZellError" ; }; // TODO: ancient legacy only, remove? - String SC_OPCODE_FORMULA - { - Text [ en-US ] = "FORMULA" ; - }; - String SC_OPCODE_ARABIC - { - Text [ en-US ] = "ARABIC"; - }; - String SC_OPCODE_ARC_TAN_2 - { - Text [ en-US ] = "ATAN2" ; - }; - String SC_OPCODE_CEIL - { - Text [ en-US ] = "CEILING" ; - }; - String SC_OPCODE_FLOOR - { - Text [ en-US ] = "FLOOR" ; - }; - String SC_OPCODE_ROUND - { - Text [ en-US ] = "ROUND" ; - }; - String SC_OPCODE_ROUND_UP - { - Text [ en-US ] = "ROUNDUP" ; - }; - String SC_OPCODE_ROUND_DOWN - { - Text [ en-US ] = "ROUNDDOWN" ; - }; - String SC_OPCODE_TRUNC - { - Text [ en-US ] = "TRUNC" ; - }; - String SC_OPCODE_LOG - { - Text [ en-US ] = "LOG"; - }; - String SC_OPCODE_POWER - { - Text [ en-US ] = "POWER" ; - }; - String SC_OPCODE_GGT - { - Text [ en-US ] = "GCD" ; - }; - String SC_OPCODE_KGV - { - Text [ en-US ] = "LCM" ; - }; - String SC_OPCODE_MOD - { - Text [ en-US ] = "MOD" ; - }; - String SC_OPCODE_SUM_PRODUCT - { - Text [ en-US ] = "SUMPRODUCT" ; - }; - String SC_OPCODE_SUM_SQ - { - Text [ en-US ] = "SUMSQ" ; - }; - String SC_OPCODE_SUM_X2MY2 - { - Text [ en-US ] = "SUMX2MY2" ; - }; - String SC_OPCODE_SUM_X2DY2 - { - Text [ en-US ] = "SUMX2PY2" ; - }; - String SC_OPCODE_SUM_XMY2 - { - Text [ en-US ] = "SUMXMY2" ; - }; - String SC_OPCODE_GET_DATE - { - Text [ en-US ] = "DATE" ; - }; - String SC_OPCODE_GET_TIME - { - Text [ en-US ] = "TIME" ; - }; - String SC_OPCODE_GET_DIFF_DATE - { - Text [ en-US ] = "DAYS" ; - }; - String SC_OPCODE_GET_DIFF_DATE_360 - { - Text [ en-US ] = "DAYS360" ; - }; - String SC_OPCODE_MIN - { - Text [ en-US ] = "MIN" ; - }; - String SC_OPCODE_MIN_A - { - Text [ en-US ] = "MINA" ; - }; - String SC_OPCODE_MAX - { - Text [ en-US ] = "MAX" ; - }; - String SC_OPCODE_MAX_A - { - Text [ en-US ] = "MAXA" ; - }; - String SC_OPCODE_SUM - { - Text [ en-US ] = "SUM" ; - }; - String SC_OPCODE_PRODUCT - { - Text [ en-US ] = "PRODUCT" ; - }; - String SC_OPCODE_AVERAGE - { - Text [ en-US ] = "AVERAGE" ; - }; - String SC_OPCODE_AVERAGE_A - { - Text [ en-US ] = "AVERAGEA" ; - }; - String SC_OPCODE_COUNT - { - Text [ en-US ] = "COUNT" ; - }; - String SC_OPCODE_COUNT_2 - { - Text [ en-US ] = "COUNTA" ; - }; - String SC_OPCODE_NBW - { - Text [ en-US ] = "NPV" ; - }; - String SC_OPCODE_IKV - { - Text [ en-US ] = "IRR" ; - }; - String SC_OPCODE_MIRR - { - Text [ en-US ] = "MIRR"; - }; - String SC_OPCODE_ISPMT - { - Text [ en-US ] = "ISPMT"; - }; - String SC_OPCODE_VAR - { - Text [ en-US ] = "VAR" ; - }; - String SC_OPCODE_VAR_A - { - Text [ en-US ] = "VARA" ; - }; - String SC_OPCODE_VAR_P - { - Text [ en-US ] = "VARP" ; - }; - String SC_OPCODE_VAR_P_A - { - Text [ en-US ] = "VARPA" ; - }; - String SC_OPCODE_ST_DEV - { - Text [ en-US ] = "STDEV" ; - }; - String SC_OPCODE_ST_DEV_A - { - Text [ en-US ] = "STDEVA" ; - }; - String SC_OPCODE_ST_DEV_P - { - Text [ en-US ] = "STDEVP" ; - }; - String SC_OPCODE_ST_DEV_P_A - { - Text [ en-US ] = "STDEVPA" ; - }; - String SC_OPCODE_B - { - Text [ en-US ] = "B"; - }; - String SC_OPCODE_NORM_DIST - { - Text [ en-US ] = "NORMDIST" ; - }; - String SC_OPCODE_EXP_DIST - { - Text [ en-US ] = "EXPONDIST" ; - }; - String SC_OPCODE_BINOM_DIST - { - Text [ en-US ] = "BINOMDIST" ; - }; - String SC_OPCODE_POISSON_DIST - { - Text [ en-US ] = "POISSON" ; - }; - String SC_OPCODE_KOMBIN - { - Text [ en-US ] = "COMBIN" ; - }; - String SC_OPCODE_KOMBIN_2 - { - Text [ en-US ] = "COMBINA" ; - }; - String SC_OPCODE_VARIATIONEN - { - Text [ en-US ] = "PERMUT" ; - }; - String SC_OPCODE_VARIATIONEN_2 - { - Text [ en-US ] = "PERMUTATIONA" ; - }; - String SC_OPCODE_BW + String 1 { - Text [ en-US ] = "PV" ; + Text[ en-US ] = "Database" ; }; - String SC_OPCODE_DIA + String 2 { - Text [ en-US ] = "SYD" ; + Text[ en-US ] = "Date&Time" ; }; - String SC_OPCODE_GDA + String 3 { - Text [ en-US ] = "DDB" ; + Text[ en-US ] = "Financial" ; }; - String SC_OPCODE_GDA_2 + String 4 { - Text [ en-US ] = "DB" ; + Text[ en-US ] = "Information" ; }; - String SC_OPCODE_VBD + String 5 { - Text [ en-US ] = "VDB" ; + Text[ en-US ] = "Logical" ; }; - String SC_OPCODE_LAUFZ + String 6 { - Text [ en-US ] = "DURATION" ; + Text[ en-US ] = "Mathematical" ; }; - String SC_OPCODE_LIA + String 7 { - Text [ en-US ] = "SLN" ; + Text[ en-US ] = "Array" ; }; - String SC_OPCODE_RMZ + String 8 { - Text [ en-US ] = "PMT" ; + Text[ en-US ] = "Statistical" ; }; - String SC_OPCODE_COLUMNS + String 9 { - Text [ en-US ] = "COLUMNS" ; + Text[ en-US ] = "Spreadsheet" ; }; - String SC_OPCODE_ROWS + String 10 { - Text [ en-US ] = "ROWS" ; + Text[ en-US ] = "Text" ; }; - String SC_OPCODE_TABLES + String 11 { - Text [ en-US ] = "SHEETS" ; + Text[ en-US ] = "Add-in" ; }; - String SC_OPCODE_COLUMN - { - Text [ en-US ] = "COLUMN" ; - }; - String SC_OPCODE_ROW - { - Text [ en-US ] = "ROW" ; - }; - String SC_OPCODE_TABLE - { - Text [ en-US ] = "SHEET" ; - }; - String SC_OPCODE_ZGZ - { - Text [ en-US ] = "RRI" ; - }; - String SC_OPCODE_ZW - { - Text [ en-US ] = "FV" ; - }; - String SC_OPCODE_ZZR - { - Text [ en-US ] = "NPER" ; - }; - String SC_OPCODE_ZINS - { - Text [ en-US ] = "RATE" ; - }; - String SC_OPCODE_ZINS_Z - { - Text [ en-US ] = "IPMT" ; - }; - String SC_OPCODE_KAPZ - { - Text [ en-US ] = "PPMT" ; - }; - String SC_OPCODE_KUM_ZINS_Z - { - Text [ en-US ] = "CUMIPMT" ; - }; - String SC_OPCODE_KUM_KAP_Z - { - Text [ en-US ] = "CUMPRINC" ; - }; - String SC_OPCODE_EFFEKTIV - { - Text [ en-US ] = "EFFECTIVE" ; - }; - String SC_OPCODE_NOMINAL - { - Text [ en-US ] = "NOMINAL" ; - }; - String SC_OPCODE_SUB_TOTAL - { - Text [ en-US ] = "SUBTOTAL" ; - }; - String SC_OPCODE_DB_SUM - { - Text [ en-US ] = "DSUM" ; - }; - String SC_OPCODE_DB_COUNT - { - Text [ en-US ] = "DCOUNT" ; - }; - String SC_OPCODE_DB_COUNT_2 - { - Text [ en-US ] = "DCOUNTA" ; - }; - String SC_OPCODE_DB_AVERAGE - { - Text [ en-US ] = "DAVERAGE" ; - }; - String SC_OPCODE_DB_GET - { - Text [ en-US ] = "DGET" ; - }; - String SC_OPCODE_DB_MAX - { - Text [ en-US ] = "DMAX" ; - }; - String SC_OPCODE_DB_MIN - { - Text [ en-US ] = "DMIN" ; - }; - String SC_OPCODE_DB_PRODUCT - { - Text [ en-US ] = "DPRODUCT" ; - }; - String SC_OPCODE_DB_STD_DEV - { - Text [ en-US ] = "DSTDEV" ; - }; - String SC_OPCODE_DB_STD_DEV_P - { - Text [ en-US ] = "DSTDEVP" ; - }; - String SC_OPCODE_DB_VAR - { - Text [ en-US ] = "DVAR" ; - }; - String SC_OPCODE_DB_VAR_P - { - Text [ en-US ] = "DVARP" ; - }; - String SC_OPCODE_INDIRECT - { - Text [ en-US ] = "INDIRECT" ; - }; - String SC_OPCODE_ADDRESS - { - Text [ en-US ] = "ADDRESS" ; - }; - String SC_OPCODE_MATCH - { - Text [ en-US ] = "MATCH" ; - }; - String SC_OPCODE_COUNT_EMPTY_CELLS - { - Text [ en-US ] = "COUNTBLANK" ; - }; - String SC_OPCODE_COUNT_IF - { - Text [ en-US ] = "COUNTIF" ; - }; - String SC_OPCODE_SUM_IF - { - Text [ en-US ] = "SUMIF" ; - }; - String SC_OPCODE_LOOKUP - { - Text [ en-US ] = "LOOKUP" ; - }; - String SC_OPCODE_V_LOOKUP - { - Text [ en-US ] = "VLOOKUP" ; - }; - String SC_OPCODE_H_LOOKUP - { - Text [ en-US ] = "HLOOKUP" ; - }; - String SC_OPCODE_MULTI_AREA // legacy for range list (union) - { - Text [ en-US ] = "MULTIRANGE" ; - }; - String SC_OPCODE_OFFSET - { - Text [ en-US ] = "OFFSET" ; - }; - String SC_OPCODE_INDEX - { - // ?? erstes Zeichen = I ?? - Text [ en-US ] = "INDEX" ; - }; - String SC_OPCODE_AREAS - { - Text [ en-US ] = "AREAS" ; - }; - String SC_OPCODE_CURRENCY - { - Text [ en-US ] = "DOLLAR" ; - }; - String SC_OPCODE_REPLACE - { - Text [ en-US ] = "REPLACE" ; - }; - String SC_OPCODE_FIXED - { - Text [ en-US ] = "FIXED" ; - }; - String SC_OPCODE_FIND - { - Text [ en-US ] = "FIND" ; - }; - String SC_OPCODE_EXACT - { - Text [ en-US ] = "EXACT" ; - }; - String SC_OPCODE_LEFT - { - Text [ en-US ] = "LEFT" ; - }; - String SC_OPCODE_RIGHT - { - Text [ en-US ] = "RIGHT" ; - }; - String SC_OPCODE_SEARCH - { - Text [ en-US ] = "SEARCH" ; - }; - String SC_OPCODE_MID - { - Text [ en-US ] = "MID" ; - }; - String SC_OPCODE_TEXT - { - Text [ en-US ] = "TEXT" ; - }; - String SC_OPCODE_SUBSTITUTE - { - Text [ en-US ] = "SUBSTITUTE" ; - }; - String SC_OPCODE_REPT - { - Text [ en-US ] = "REPT" ; - }; - String SC_OPCODE_CONCAT - { - Text [ en-US ] = "CONCATENATE" ; - }; - String SC_OPCODE_MAT_VALUE - { - Text [ en-US ] = "MVALUE" ; - }; - String SC_OPCODE_MAT_DET - { - Text [ en-US ] = "MDETERM" ; - }; - String SC_OPCODE_MAT_INV - { - Text [ en-US ] = "MINVERSE" ; - }; - String SC_OPCODE_MAT_MULT - { - Text [ en-US ] = "MMULT" ; - }; - String SC_OPCODE_MAT_TRANS - { - Text [ en-US ] = "TRANSPOSE" ; - }; - String SC_OPCODE_MATRIX_UNIT - { - Text [ en-US ] = "MUNIT" ; - }; - String SC_OPCODE_BACK_SOLVER - { - Text [ en-US ] = "GOALSEEK" ; - }; - String SC_OPCODE_HYP_GEOM_DIST - { - Text [ en-US ] = "HYPGEOMDIST" ; - }; - String SC_OPCODE_LOG_NORM_DIST - { - Text [ en-US ] = "LOGNORMDIST" ; - }; - String SC_OPCODE_T_DIST - { - Text [ en-US ] = "TDIST" ; - }; - String SC_OPCODE_F_DIST - { - Text [ en-US ] = "FDIST" ; - }; - String SC_OPCODE_CHI_DIST - { - Text [ en-US ] = "CHIDIST" ; - }; - String SC_OPCODE_WEIBULL - { - Text [ en-US ] = "WEIBULL" ; - }; - String SC_OPCODE_NEG_BINOM_VERT - { - Text [ en-US ] = "NEGBINOMDIST" ; - }; - String SC_OPCODE_KRIT_BINOM - { - Text [ en-US ] = "CRITBINOM" ; - }; - String SC_OPCODE_KURT - { - Text [ en-US ] = "KURT" ; - }; - String SC_OPCODE_HAR_MEAN - { - Text [ en-US ] = "HARMEAN" ; - }; - String SC_OPCODE_GEO_MEAN - { - Text [ en-US ] = "GEOMEAN" ; - }; - String SC_OPCODE_STANDARD - { - Text [ en-US ] = "STANDARDIZE" ; - }; - String SC_OPCODE_AVE_DEV - { - Text [ en-US ] = "AVEDEV" ; - }; - String SC_OPCODE_SCHIEFE - { - Text [ en-US ] = "SKEW" ; - }; - String SC_OPCODE_DEV_SQ - { - Text [ en-US ] = "DEVSQ" ; - }; - String SC_OPCODE_MEDIAN - { - Text [ en-US ] = "MEDIAN" ; - }; - String SC_OPCODE_MODAL_VALUE - { - Text [ en-US ] = "MODE" ; - }; - String SC_OPCODE_Z_TEST - { - Text [ en-US ] = "ZTEST" ; - }; - String SC_OPCODE_T_TEST - { - Text [ en-US ] = "TTEST" ; - }; - String SC_OPCODE_RANK - { - Text [ en-US ] = "RANK" ; - }; - String SC_OPCODE_PERCENTILE - { - Text [ en-US ] = "PERCENTILE" ; - }; - String SC_OPCODE_PERCENT_RANK - { - Text [ en-US ] = "PERCENTRANK" ; - }; - String SC_OPCODE_LARGE - { - Text [ en-US ] = "LARGE" ; - }; - String SC_OPCODE_SMALL - { - Text [ en-US ] = "SMALL" ; - }; - String SC_OPCODE_FREQUENCY - { - Text [ en-US ] = "FREQUENCY" ; - }; - String SC_OPCODE_QUARTILE - { - Text [ en-US ] = "QUARTILE" ; - }; - String SC_OPCODE_NORM_INV - { - Text [ en-US ] = "NORMINV" ; - }; - String SC_OPCODE_CONFIDENCE - { - Text [ en-US ] = "CONFIDENCE" ; - }; - String SC_OPCODE_F_TEST - { - Text [ en-US ] = "FTEST" ; - }; - String SC_OPCODE_TRIM_MEAN - { - Text [ en-US ] = "TRIMMEAN" ; - }; - String SC_OPCODE_PROB - { - Text [ en-US ] = "PROB" ; - }; - String SC_OPCODE_CORREL - { - Text [ en-US ] = "CORREL" ; - }; - String SC_OPCODE_COVAR - { - Text [ en-US ] = "COVAR" ; - }; - String SC_OPCODE_PEARSON - { - Text [ en-US ] = "PEARSON" ; - }; - String SC_OPCODE_RSQ - { - Text [ en-US ] = "RSQ" ; - }; - String SC_OPCODE_STEYX - { - Text [ en-US ] = "STEYX" ; - }; - String SC_OPCODE_SLOPE - { - Text [ en-US ] = "SLOPE" ; - }; - String SC_OPCODE_INTERCEPT - { - Text [ en-US ] = "INTERCEPT" ; - }; - String SC_OPCODE_TREND - { - Text [ en-US ] = "TREND" ; - }; - String SC_OPCODE_GROWTH - { - Text [ en-US ] = "GROWTH" ; - }; - String SC_OPCODE_RGP - { - Text [ en-US ] = "LINEST" ; - }; - String SC_OPCODE_RKP - { - Text [ en-US ] = "LOGEST" ; - }; - String SC_OPCODE_FORECAST - { - Text [ en-US ] = "FORECAST" ; - }; - String SC_OPCODE_CHI_INV - { - Text [ en-US ] = "CHIINV" ; - }; - String SC_OPCODE_GAMMA_DIST - { - Text [ en-US ] = "GAMMADIST" ; - }; - String SC_OPCODE_GAMMA_INV - { - Text [ en-US ] = "GAMMAINV" ; - }; - String SC_OPCODE_T_INV - { - Text [ en-US ] = "TINV" ; - }; - String SC_OPCODE_F_INV - { - Text [ en-US ] = "FINV" ; - }; - String SC_OPCODE_CHI_TEST - { - Text [ en-US ] = "CHITEST" ; - }; - String SC_OPCODE_LOG_INV - { - Text [ en-US ] = "LOGINV" ; - }; - String SC_OPCODE_TABLE_OP - { - Text [ en-US ] = "MULTIPLE.OPERATIONS" ; - }; - String SC_OPCODE_BETA_DIST - { - Text [ en-US ] = "BETADIST" ; - }; - String SC_OPCODE_BETA_INV - { - Text [ en-US ] = "BETAINV" ; - }; - String SC_OPCODE_WEEK - { - Text [ en-US ] = "WEEKNUM" ; - }; - String SC_OPCODE_EASTERSUNDAY - { - Text [ en-US ] = "EASTERSUNDAY" ; - }; - String SC_OPCODE_GET_DAY_OF_WEEK - { - Text [ en-US ] = "WEEKDAY" ; - }; - String SC_OPCODE_NO_NAME - { - Text [ en-US ] = "#NAME!" ; - }; - String SC_OPCODE_STYLE - { - Text [ en-US ] = "STYLE" ; - }; - String SC_OPCODE_DDE - { - Text [ en-US ] = "DDE"; - }; - String SC_OPCODE_BASE - { - Text [ en-US ] = "BASE" ; - }; - String SC_OPCODE_DECIMAL - { - Text [ en-US ] = "DECIMAL" ; - }; - String SC_OPCODE_CONVERT - { - Text [ en-US ] = "CONVERT"; - }; - String SC_OPCODE_ROMAN - { - Text [ en-US ] = "ROMAN"; - }; - String SC_OPCODE_HYPERLINK - { - Text[ en-US ] = "HYPERLINK"; - }; - String SC_OPCODE_INFO - { - Text [ en-US ] = "INFO"; - }; - String SC_OPCODE_BAHTTEXT - { - Text [ en-US ] = "BAHTTEXT"; - }; - String SC_OPCODE_GET_PIVOT_DATA - { - Text [ en-US ] = "GETPIVOTDATA"; - }; - String SC_OPCODE_EUROCONVERT - { - Text [ en-US ] = "EUROCONVERT"; - }; - String SC_OPCODE_NUMBERVALUE - { - Text [ en-US ] = "NUMBERVALUE" ; - }; - String SC_OPCODE_GAMMA - { - Text [ en-US ] = "GAMMA" ; - }; - String SC_OPCODE_CHISQ_DIST - { - Text [ en-US ] = "CHISQDIST" ; - }; - String SC_OPCODE_CHISQ_INV - { - Text [ en-US ] = "CHISQINV" ; - }; - - /* BEGIN defined ERROR.TYPE() values. */ - /* ERROR.TYPE( #NULL! ) == 1 */ - String SC_OPCODE_ERROR_NULL - { - Text [ en-US ] = "#NULL!" ; - }; - /* ERROR.TYPE( #DIV/0! ) == 2 */ - String SC_OPCODE_ERROR_DIVZERO - { - Text [ en-US ] = "#DIV/0!" ; - }; - /* ERROR.TYPE( #VALUE! ) == 3 */ - String SC_OPCODE_ERROR_VALUE - { - Text [ en-US ] = "#VALUE!" ; - }; - /* ERROR.TYPE( #REF! ) == 4 */ - String SC_OPCODE_ERROR_REF - { - Text [ en-US ] = "#REF!" ; - }; - /* ERROR.TYPE( #NAME! ) == 5 */ - String SC_OPCODE_ERROR_NAME - { - Text [ en-US ] = "#NAME?" ; - }; - /* ERROR.TYPE( #NUM! ) == 6 */ - String SC_OPCODE_ERROR_NUM - { - Text [ en-US ] = "#NUM!" ; - }; - /* ERROR.TYPE( #N/A ) == 7 */ - String SC_OPCODE_ERROR_NA - { - Text [ en-US ] = "#N/A" ; - }; - /* END defined ERROR.TYPE() values. */ -}; - - -// DO NOT CHANGE! -// These English names are used internally to store/load ODF v1.0/v1.1 and for -// API XFunctionAccess. -Resource RID_SC_FUNCTION_NAMES_ENGLISH -{ - String SC_OPCODE_IF { Text = "IF" ; }; - String SC_OPCODE_CHOSE { Text = "CHOOSE" ; }; - String SC_OPCODE_OPEN { Text = "(" ; }; - String SC_OPCODE_CLOSE { Text = ")" ; }; - String SC_OPCODE_ARRAY_OPEN { Text = "{" ; }; - String SC_OPCODE_ARRAY_CLOSE { Text = "}" ; }; - String SC_OPCODE_ARRAY_ROW_SEP { Text = "|" ; }; - String SC_OPCODE_ARRAY_COL_SEP { Text = ";" ; }; - String SC_OPCODE_SEP { Text = ";" ; }; - String SC_OPCODE_PERCENT_SIGN { Text = "%" ; }; - String SC_OPCODE_ADD { Text = "+" ; }; - String SC_OPCODE_SUB { Text = "-" ; }; - String SC_OPCODE_MUL { Text = "*" ; }; - String SC_OPCODE_DIV { Text = "/" ; }; - String SC_OPCODE_AMPERSAND { Text = "&" ; }; - String SC_OPCODE_POW { Text = "^" ; }; - String SC_OPCODE_EQUAL { Text = "=" ; }; - String SC_OPCODE_NOT_EQUAL { Text = "<>" ; }; - String SC_OPCODE_LESS { Text = "<" ; }; - String SC_OPCODE_GREATER { Text = ">" ; }; - String SC_OPCODE_LESS_EQUAL { Text = "<=" ; }; - String SC_OPCODE_GREATER_EQUAL { Text = ">=" ; }; - String SC_OPCODE_AND { Text = "AND" ; }; - String SC_OPCODE_OR { Text = "OR" ; }; - String SC_OPCODE_INTERSECT { Text = "!" ; }; - String SC_OPCODE_UNION { Text = "~" ; }; - String SC_OPCODE_RANGE { Text = ":" ; }; - String SC_OPCODE_NOT { Text = "NOT" ; }; - String SC_OPCODE_NEG { Text = "NEG" ; }; - String SC_OPCODE_NEG_SUB { Text = "-" ; }; - String SC_OPCODE_PI { Text = "PI" ; }; - String SC_OPCODE_RANDOM { Text = "RAND" ; }; - String SC_OPCODE_TRUE { Text = "TRUE" ; }; - String SC_OPCODE_FALSE { Text = "FALSE" ; }; - String SC_OPCODE_GET_ACT_DATE { Text = "TODAY" ; }; - String SC_OPCODE_GET_ACT_TIME { Text = "NOW" ; }; - String SC_OPCODE_NO_VALUE { Text = "NA" ; }; - String SC_OPCODE_CURRENT { Text = "CURRENT" ; }; - String SC_OPCODE_DEG { Text = "DEGREES" ; }; - String SC_OPCODE_RAD { Text = "RADIANS" ; }; - String SC_OPCODE_SIN { Text = "SIN" ; }; - String SC_OPCODE_COS { Text = "COS" ; }; - String SC_OPCODE_TAN { Text = "TAN" ; }; - String SC_OPCODE_COT { Text = "COT" ; }; - String SC_OPCODE_ARC_SIN { Text = "ASIN" ; }; - String SC_OPCODE_ARC_COS { Text = "ACOS" ; }; - String SC_OPCODE_ARC_TAN { Text = "ATAN" ; }; - String SC_OPCODE_ARC_COT { Text = "ACOT" ; }; - String SC_OPCODE_SIN_HYP { Text = "SINH" ; }; - String SC_OPCODE_COS_HYP { Text = "COSH" ; }; - String SC_OPCODE_TAN_HYP { Text = "TANH" ; }; - String SC_OPCODE_COT_HYP { Text = "COTH" ; }; - String SC_OPCODE_ARC_SIN_HYP { Text = "ASINH" ; }; - String SC_OPCODE_ARC_COS_HYP { Text = "ACOSH" ; }; - String SC_OPCODE_ARC_TAN_HYP { Text = "ATANH" ; }; - String SC_OPCODE_ARC_COT_HYP { Text = "ACOTH" ; }; - String SC_OPCODE_EXP { Text = "EXP" ; }; - String SC_OPCODE_LN { Text = "LN" ; }; - String SC_OPCODE_SQRT { Text = "SQRT" ; }; - String SC_OPCODE_FACT { Text = "FACT" ; }; - String SC_OPCODE_GET_YEAR { Text = "YEAR" ; }; - String SC_OPCODE_GET_MONTH { Text = "MONTH" ; }; - String SC_OPCODE_GET_DAY { Text = "DAY" ; }; - String SC_OPCODE_GET_HOUR { Text = "HOUR" ; }; - String SC_OPCODE_GET_MIN { Text = "MINUTE" ; }; - String SC_OPCODE_GET_SEC { Text = "SECOND" ; }; - String SC_OPCODE_PLUS_MINUS { Text = "SIGN" ; }; - String SC_OPCODE_ABS { Text = "ABS" ; }; - String SC_OPCODE_INT { Text = "INT" ; }; - String SC_OPCODE_PHI { Text = "PHI" ; }; - String SC_OPCODE_GAUSS { Text = "GAUSS" ; }; - String SC_OPCODE_IS_EMPTY { Text = "ISBLANK" ; }; - String SC_OPCODE_IS_STRING { Text = "ISTEXT" ; }; - String SC_OPCODE_IS_NON_STRING { Text = "ISNONTEXT" ; }; - String SC_OPCODE_IS_LOGICAL { Text = "ISLOGICAL" ; }; - String SC_OPCODE_TYPE { Text = "TYPE" ; }; - String SC_OPCODE_CELL { Text = "CELL" ; }; - String SC_OPCODE_IS_REF { Text = "ISREF" ; }; - String SC_OPCODE_IS_VALUE { Text = "ISNUMBER" ; }; - String SC_OPCODE_IS_FORMULA { Text = "ISFORMULA" ; }; - String SC_OPCODE_IS_NV { Text = "ISNA" ; }; - String SC_OPCODE_IS_ERR { Text = "ISERR" ; }; - String SC_OPCODE_IS_ERROR { Text = "ISERROR" ; }; - String SC_OPCODE_IS_EVEN { Text = "ISEVEN" ; }; - String SC_OPCODE_IS_ODD { Text = "ISODD" ; }; - String SC_OPCODE_N { Text = "N" ; }; - String SC_OPCODE_GET_DATE_VALUE { Text = "DATEVALUE" ; }; - String SC_OPCODE_GET_TIME_VALUE { Text = "TIMEVALUE" ; }; - String SC_OPCODE_CODE { Text = "CODE" ; }; - String SC_OPCODE_TRIM { Text = "TRIM" ; }; - String SC_OPCODE_UPPER { Text = "UPPER" ; }; - String SC_OPCODE_PROPPER { Text = "PROPER" ; }; - String SC_OPCODE_LOWER { Text = "LOWER" ; }; - String SC_OPCODE_LEN { Text = "LEN" ; }; - String SC_OPCODE_T { Text = "T" ; }; - String SC_OPCODE_VALUE { Text = "VALUE" ; }; - String SC_OPCODE_CLEAN { Text = "CLEAN" ; }; - String SC_OPCODE_CHAR { Text = "CHAR" ; }; - String SC_OPCODE_JIS { Text = "JIS" ; }; - String SC_OPCODE_ASC { Text = "ASC" ; }; - String SC_OPCODE_UNICODE { Text = "UNICODE" ; }; - String SC_OPCODE_UNICHAR { Text = "UNICHAR" ; }; - String SC_OPCODE_LOG10 { Text = "LOG10" ; }; - String SC_OPCODE_EVEN { Text = "EVEN" ; }; - String SC_OPCODE_ODD { Text = "ODD" ; }; - String SC_OPCODE_STD_NORM_DIST { Text = "NORMSDIST" ; }; - String SC_OPCODE_FISHER { Text = "FISHER" ; }; - String SC_OPCODE_FISHER_INV { Text = "FISHERINV" ; }; - String SC_OPCODE_S_NORM_INV { Text = "NORMSINV" ; }; - String SC_OPCODE_GAMMA_LN { Text = "GAMMALN" ; }; - String SC_OPCODE_ERROR_TYPE { Text = "ERRORTYPE" ; }; - String SC_OPCODE_ERR_CELL { Text = "ZellError" ; }; // TODO: ancient legacy only, remove? - String SC_OPCODE_FORMULA { Text = "FORMULA"; }; - String SC_OPCODE_ARC_TAN_2 { Text = "ATAN2" ; }; - String SC_OPCODE_CEIL { Text = "CEILING" ; }; - String SC_OPCODE_FLOOR { Text = "FLOOR" ; }; - String SC_OPCODE_ROUND { Text = "ROUND" ; }; - String SC_OPCODE_ROUND_UP { Text = "ROUNDUP" ; }; - String SC_OPCODE_ROUND_DOWN { Text = "ROUNDDOWN" ; }; - String SC_OPCODE_TRUNC { Text = "TRUNC" ; }; - String SC_OPCODE_LOG { Text = "LOG" ; }; - String SC_OPCODE_POWER { Text = "POWER" ; }; - String SC_OPCODE_GGT { Text = "GCD" ; }; - String SC_OPCODE_KGV { Text = "LCM" ; }; - String SC_OPCODE_MOD { Text = "MOD" ; }; - String SC_OPCODE_SUM_PRODUCT { Text = "SUMPRODUCT" ; }; - String SC_OPCODE_SUM_SQ { Text = "SUMSQ" ; }; - String SC_OPCODE_SUM_X2MY2 { Text = "SUMX2MY2" ; }; - String SC_OPCODE_SUM_X2DY2 { Text = "SUMX2PY2" ; }; - String SC_OPCODE_SUM_XMY2 { Text = "SUMXMY2" ; }; - String SC_OPCODE_GET_DATE { Text = "DATE" ; }; - String SC_OPCODE_GET_TIME { Text = "TIME" ; }; - String SC_OPCODE_GET_DIFF_DATE { Text = "DAYS" ; }; - String SC_OPCODE_GET_DIFF_DATE_360 { Text = "DAYS360" ; }; - String SC_OPCODE_MIN { Text = "MIN" ; }; - String SC_OPCODE_MIN_A { Text = "MINA" ; }; - String SC_OPCODE_MAX { Text = "MAX" ; }; - String SC_OPCODE_MAX_A { Text = "MAXA" ; }; - String SC_OPCODE_SUM { Text = "SUM" ; }; - String SC_OPCODE_PRODUCT { Text = "PRODUCT" ; }; - String SC_OPCODE_AVERAGE { Text = "AVERAGE" ; }; - String SC_OPCODE_AVERAGE_A { Text = "AVERAGEA" ; }; - String SC_OPCODE_COUNT { Text = "COUNT" ; }; - String SC_OPCODE_COUNT_2 { Text = "COUNTA" ; }; - String SC_OPCODE_NBW { Text = "NPV" ; }; - String SC_OPCODE_IKV { Text = "IRR" ; }; - String SC_OPCODE_MIRR { Text = "MIRR" ; }; - String SC_OPCODE_ISPMT { Text = "ISPMT" ; }; - String SC_OPCODE_VAR { Text = "VAR" ; }; - String SC_OPCODE_VAR_A { Text = "VARA" ; }; - String SC_OPCODE_VAR_P { Text = "VARP" ; }; - String SC_OPCODE_VAR_P_A { Text = "VARPA" ; }; - String SC_OPCODE_ST_DEV { Text = "STDEV" ; }; - String SC_OPCODE_ST_DEV_A { Text = "STDEVA" ; }; - String SC_OPCODE_ST_DEV_P { Text = "STDEVP" ; }; - String SC_OPCODE_ST_DEV_P_A { Text = "STDEVPA" ; }; - String SC_OPCODE_B { Text = "B" ; }; - String SC_OPCODE_NORM_DIST { Text = "NORMDIST" ; }; - String SC_OPCODE_EXP_DIST { Text = "EXPONDIST" ; }; - String SC_OPCODE_BINOM_DIST { Text = "BINOMDIST" ; }; - String SC_OPCODE_POISSON_DIST { Text = "POISSON" ; }; - String SC_OPCODE_KOMBIN { Text = "COMBIN" ; }; - String SC_OPCODE_KOMBIN_2 { Text = "COMBINA" ; }; - String SC_OPCODE_VARIATIONEN { Text = "PERMUT" ; }; - String SC_OPCODE_VARIATIONEN_2 { Text = "PERMUTATIONA" ; }; - String SC_OPCODE_BW { Text = "PV" ; }; - String SC_OPCODE_DIA { Text = "SYD" ; }; - String SC_OPCODE_GDA { Text = "DDB" ; }; - String SC_OPCODE_GDA_2 { Text = "DB" ; }; - String SC_OPCODE_VBD { Text = "VDB" ; }; - String SC_OPCODE_LAUFZ { Text = "DURATION" ; }; - String SC_OPCODE_LIA { Text = "SLN" ; }; - String SC_OPCODE_RMZ { Text = "PMT" ; }; - String SC_OPCODE_COLUMNS { Text = "COLUMNS" ; }; - String SC_OPCODE_ROWS { Text = "ROWS" ; }; - String SC_OPCODE_TABLES { Text = "SHEETS" ; }; - String SC_OPCODE_COLUMN { Text = "COLUMN" ; }; - String SC_OPCODE_ROW { Text = "ROW" ; }; - String SC_OPCODE_TABLE { Text = "SHEET" ; }; - String SC_OPCODE_ZGZ { Text = "ZGZ" ; }; - String SC_OPCODE_ZW { Text = "FV" ; }; - String SC_OPCODE_ZZR { Text = "NPER" ; }; - String SC_OPCODE_ZINS { Text = "RATE" ; }; - String SC_OPCODE_ZINS_Z { Text = "IPMT" ; }; - String SC_OPCODE_KAPZ { Text = "PPMT" ; }; - String SC_OPCODE_KUM_ZINS_Z { Text = "CUMIPMT" ; }; - String SC_OPCODE_KUM_KAP_Z { Text = "CUMPRINC" ; }; - String SC_OPCODE_EFFEKTIV { Text = "EFFECTIVE" ; }; - String SC_OPCODE_NOMINAL { Text = "NOMINAL" ; }; - String SC_OPCODE_SUB_TOTAL { Text = "SUBTOTAL" ; }; - String SC_OPCODE_DB_SUM { Text = "DSUM" ; }; - String SC_OPCODE_DB_COUNT { Text = "DCOUNT" ; }; - String SC_OPCODE_DB_COUNT_2 { Text = "DCOUNTA" ; }; - String SC_OPCODE_DB_AVERAGE { Text = "DAVERAGE" ; }; - String SC_OPCODE_DB_GET { Text = "DGET" ; }; - String SC_OPCODE_DB_MAX { Text = "DMAX" ; }; - String SC_OPCODE_DB_MIN { Text = "DMIN" ; }; - String SC_OPCODE_DB_PRODUCT { Text = "DPRODUCT" ; }; - String SC_OPCODE_DB_STD_DEV { Text = "DSTDEV" ; }; - String SC_OPCODE_DB_STD_DEV_P { Text = "DSTDEVP" ; }; - String SC_OPCODE_DB_VAR { Text = "DVAR" ; }; - String SC_OPCODE_DB_VAR_P { Text = "DVARP" ; }; - String SC_OPCODE_INDIRECT { Text = "INDIRECT" ; }; - String SC_OPCODE_ADDRESS { Text = "ADDRESS" ; }; - String SC_OPCODE_MATCH { Text = "MATCH" ; }; - String SC_OPCODE_COUNT_EMPTY_CELLS { Text = "COUNTBLANK" ; }; - String SC_OPCODE_COUNT_IF { Text = "COUNTIF" ; }; - String SC_OPCODE_SUM_IF { Text = "SUMIF" ; }; - String SC_OPCODE_LOOKUP { Text = "LOOKUP" ; }; - String SC_OPCODE_V_LOOKUP { Text = "VLOOKUP" ; }; - String SC_OPCODE_H_LOOKUP { Text = "HLOOKUP" ; }; - String SC_OPCODE_MULTI_AREA { Text = "MULTIRANGE" ; }; // legacy for range list (union) - String SC_OPCODE_OFFSET { Text = "OFFSET" ; }; - String SC_OPCODE_INDEX { Text = "INDEX" ; }; - String SC_OPCODE_AREAS { Text = "AREAS" ; }; - String SC_OPCODE_CURRENCY { Text = "DOLLAR" ; }; - String SC_OPCODE_REPLACE { Text = "REPLACE" ; }; - String SC_OPCODE_FIXED { Text = "FIXED" ; }; - String SC_OPCODE_FIND { Text = "FIND" ; }; - String SC_OPCODE_EXACT { Text = "EXACT" ; }; - String SC_OPCODE_LEFT { Text = "LEFT" ; }; - String SC_OPCODE_RIGHT { Text = "RIGHT" ; }; - String SC_OPCODE_SEARCH { Text = "SEARCH" ; }; - String SC_OPCODE_MID { Text = "MID" ; }; - String SC_OPCODE_TEXT { Text = "TEXT" ; }; - String SC_OPCODE_SUBSTITUTE { Text = "SUBSTITUTE" ; }; - String SC_OPCODE_REPT { Text = "REPT" ; }; - String SC_OPCODE_CONCAT { Text = "CONCATENATE" ; }; - String SC_OPCODE_MAT_VALUE { Text = "MVALUE" ; }; - String SC_OPCODE_MAT_DET { Text = "MDETERM" ; }; - String SC_OPCODE_MAT_INV { Text = "MINVERSE" ; }; - String SC_OPCODE_MAT_MULT { Text = "MMULT" ; }; - String SC_OPCODE_MAT_TRANS { Text = "TRANSPOSE" ; }; - String SC_OPCODE_MATRIX_UNIT { Text = "MUNIT" ; }; - String SC_OPCODE_BACK_SOLVER { Text = "GOALSEEK" ; }; - String SC_OPCODE_HYP_GEOM_DIST { Text = "HYPGEOMDIST" ; }; - String SC_OPCODE_LOG_NORM_DIST { Text = "LOGNORMDIST" ; }; - String SC_OPCODE_T_DIST { Text = "TDIST" ; }; - String SC_OPCODE_F_DIST { Text = "FDIST" ; }; - String SC_OPCODE_CHI_DIST { Text = "CHIDIST" ; }; - String SC_OPCODE_WEIBULL { Text = "WEIBULL" ; }; - String SC_OPCODE_NEG_BINOM_VERT { Text = "NEGBINOMDIST" ; }; - String SC_OPCODE_KRIT_BINOM { Text = "CRITBINOM" ; }; - String SC_OPCODE_KURT { Text = "KURT" ; }; - String SC_OPCODE_HAR_MEAN { Text = "HARMEAN" ; }; - String SC_OPCODE_GEO_MEAN { Text = "GEOMEAN" ; }; - String SC_OPCODE_STANDARD { Text = "STANDARDIZE" ; }; - String SC_OPCODE_AVE_DEV { Text = "AVEDEV" ; }; - String SC_OPCODE_SCHIEFE { Text = "SKEW" ; }; - String SC_OPCODE_DEV_SQ { Text = "DEVSQ" ; }; - String SC_OPCODE_MEDIAN { Text = "MEDIAN" ; }; - String SC_OPCODE_MODAL_VALUE { Text = "MODE" ; }; - String SC_OPCODE_Z_TEST { Text = "ZTEST" ; }; - String SC_OPCODE_T_TEST { Text = "TTEST" ; }; - String SC_OPCODE_RANK { Text = "RANK" ; }; - String SC_OPCODE_PERCENTILE { Text = "PERCENTILE" ; }; - String SC_OPCODE_PERCENT_RANK { Text = "PERCENTRANK" ; }; - String SC_OPCODE_LARGE { Text = "LARGE" ; }; - String SC_OPCODE_SMALL { Text = "SMALL" ; }; - String SC_OPCODE_FREQUENCY { Text = "FREQUENCY" ; }; - String SC_OPCODE_QUARTILE { Text = "QUARTILE" ; }; - String SC_OPCODE_NORM_INV { Text = "NORMINV" ; }; - String SC_OPCODE_CONFIDENCE { Text = "CONFIDENCE" ; }; - String SC_OPCODE_F_TEST { Text = "FTEST" ; }; - String SC_OPCODE_TRIM_MEAN { Text = "TRIMMEAN" ; }; - String SC_OPCODE_PROB { Text = "PROB" ; }; - String SC_OPCODE_CORREL { Text = "CORREL" ; }; - String SC_OPCODE_COVAR { Text = "COVAR" ; }; - String SC_OPCODE_PEARSON { Text = "PEARSON" ; }; - String SC_OPCODE_RSQ { Text = "RSQ" ; }; - String SC_OPCODE_STEYX { Text = "STEYX" ; }; - String SC_OPCODE_SLOPE { Text = "SLOPE" ; }; - String SC_OPCODE_INTERCEPT { Text = "INTERCEPT" ; }; - String SC_OPCODE_TREND { Text = "TREND" ; }; - String SC_OPCODE_GROWTH { Text = "GROWTH" ; }; - String SC_OPCODE_RGP { Text = "LINEST" ; }; - String SC_OPCODE_RKP { Text = "LOGEST" ; }; - String SC_OPCODE_FORECAST { Text = "FORECAST" ; }; - String SC_OPCODE_CHI_INV { Text = "CHIINV" ; }; - String SC_OPCODE_GAMMA_DIST { Text = "GAMMADIST" ; }; - String SC_OPCODE_GAMMA_INV { Text = "GAMMAINV" ; }; - String SC_OPCODE_T_INV { Text = "TINV" ; }; - String SC_OPCODE_F_INV { Text = "FINV" ; }; - String SC_OPCODE_CHI_TEST { Text = "CHITEST" ; }; - String SC_OPCODE_LOG_INV { Text = "LOGINV" ; }; - String SC_OPCODE_TABLE_OP { Text = "TABLE" ; }; - String SC_OPCODE_BETA_DIST { Text = "BETADIST" ; }; - String SC_OPCODE_BETA_INV { Text = "BETAINV" ; }; - String SC_OPCODE_WEEK { Text = "WEEKNUM" ; }; - String SC_OPCODE_EASTERSUNDAY { Text = "EASTERSUNDAY" ; }; - String SC_OPCODE_GET_DAY_OF_WEEK { Text = "WEEKDAY" ; }; - String SC_OPCODE_NO_NAME { Text = "#NAME!" ; }; - String SC_OPCODE_STYLE { Text = "STYLE" ; }; - String SC_OPCODE_DDE { Text = "DDE" ; }; - String SC_OPCODE_BASE { Text = "BASE" ; }; - String SC_OPCODE_DECIMAL { Text = "DECIMAL" ; }; - String SC_OPCODE_CONVERT { Text = "CONVERT" ; }; - String SC_OPCODE_ROMAN { Text = "ROMAN" ; }; - String SC_OPCODE_ARABIC { Text = "ARABIC" ; }; - String SC_OPCODE_HYPERLINK { Text = "HYPERLINK" ; }; - String SC_OPCODE_INFO { Text = "INFO" ; }; - String SC_OPCODE_BAHTTEXT { Text = "BAHTTEXT" ; }; - String SC_OPCODE_GET_PIVOT_DATA { Text = "GETPIVOTDATA" ; }; - String SC_OPCODE_EUROCONVERT { Text = "EUROCONVERT" ; }; - String SC_OPCODE_NUMBERVALUE { Text = "NUMBERVALUE" ; }; - String SC_OPCODE_GAMMA { Text = "GAMMA" ; }; - String SC_OPCODE_CHISQ_DIST { Text = "CHISQDIST" ; }; - String SC_OPCODE_CHISQ_INV { Text = "CHISQINV" ;}; - /* BEGIN defined ERROR.TYPE() values. */ - String SC_OPCODE_ERROR_NULL { Text = "#NULL!" ; }; - String SC_OPCODE_ERROR_DIVZERO { Text = "#DIV/0!" ; }; - String SC_OPCODE_ERROR_VALUE { Text = "#VALUE!" ; }; - String SC_OPCODE_ERROR_REF { Text = "#REF!" ; }; - String SC_OPCODE_ERROR_NAME { Text = "#NAME?" ; }; - String SC_OPCODE_ERROR_NUM { Text = "#NUM!" ; }; - String SC_OPCODE_ERROR_NA { Text = "#N/A" ; }; - /* END defined ERROR.TYPE() values. */ }; - -// DO NOT CHANGE! -// These English names are used internally to store/load ODFF as of ODF v1.2 -Resource RID_SC_FUNCTION_NAMES_ENGLISH_ODFF -{ - String SC_OPCODE_IF { Text = "IF" ; }; - String SC_OPCODE_CHOSE { Text = "CHOOSE" ; }; - String SC_OPCODE_OPEN { Text = "(" ; }; - String SC_OPCODE_CLOSE { Text = ")" ; }; - String SC_OPCODE_ARRAY_OPEN { Text = "{" ; }; - String SC_OPCODE_ARRAY_CLOSE { Text = "}" ; }; - String SC_OPCODE_ARRAY_ROW_SEP { Text = "|" ; }; - String SC_OPCODE_ARRAY_COL_SEP { Text = ";" ; }; - String SC_OPCODE_SEP { Text = ";" ; }; - String SC_OPCODE_PERCENT_SIGN { Text = "%" ; }; - String SC_OPCODE_ADD { Text = "+" ; }; - String SC_OPCODE_SUB { Text = "-" ; }; - String SC_OPCODE_MUL { Text = "*" ; }; - String SC_OPCODE_DIV { Text = "/" ; }; - String SC_OPCODE_AMPERSAND { Text = "&" ; }; - String SC_OPCODE_POW { Text = "^" ; }; - String SC_OPCODE_EQUAL { Text = "=" ; }; - String SC_OPCODE_NOT_EQUAL { Text = "<>" ; }; - String SC_OPCODE_LESS { Text = "<" ; }; - String SC_OPCODE_GREATER { Text = ">" ; }; - String SC_OPCODE_LESS_EQUAL { Text = "<=" ; }; - String SC_OPCODE_GREATER_EQUAL { Text = ">=" ; }; - String SC_OPCODE_AND { Text = "AND" ; }; - String SC_OPCODE_OR { Text = "OR" ; }; - String SC_OPCODE_INTERSECT { Text = "!" ; }; - String SC_OPCODE_UNION { Text = "~" ; }; - String SC_OPCODE_RANGE { Text = ":" ; }; - String SC_OPCODE_NOT { Text = "NOT" ; }; - String SC_OPCODE_NEG { Text = "NEG" ; }; - String SC_OPCODE_NEG_SUB { Text = "-" ; }; - String SC_OPCODE_PI { Text = "PI" ; }; - String SC_OPCODE_RANDOM { Text = "RAND" ; }; - String SC_OPCODE_TRUE { Text = "TRUE" ; }; - String SC_OPCODE_FALSE { Text = "FALSE" ; }; - String SC_OPCODE_GET_ACT_DATE { Text = "TODAY" ; }; - String SC_OPCODE_GET_ACT_TIME { Text = "NOW" ; }; - String SC_OPCODE_NO_VALUE { Text = "NA" ; }; - String SC_OPCODE_CURRENT { Text = "ORG.OPENOFFICE.CURRENT" ; }; - String SC_OPCODE_DEG { Text = "DEGREES" ; }; - String SC_OPCODE_RAD { Text = "RADIANS" ; }; - String SC_OPCODE_SIN { Text = "SIN" ; }; - String SC_OPCODE_COS { Text = "COS" ; }; - String SC_OPCODE_TAN { Text = "TAN" ; }; - String SC_OPCODE_COT { Text = "COT" ; }; - String SC_OPCODE_ARC_SIN { Text = "ASIN" ; }; - String SC_OPCODE_ARC_COS { Text = "ACOS" ; }; - String SC_OPCODE_ARC_TAN { Text = "ATAN" ; }; - String SC_OPCODE_ARC_COT { Text = "ACOT" ; }; - String SC_OPCODE_SIN_HYP { Text = "SINH" ; }; - String SC_OPCODE_COS_HYP { Text = "COSH" ; }; - String SC_OPCODE_TAN_HYP { Text = "TANH" ; }; - String SC_OPCODE_COT_HYP { Text = "COTH" ; }; - String SC_OPCODE_ARC_SIN_HYP { Text = "ASINH" ; }; - String SC_OPCODE_ARC_COS_HYP { Text = "ACOSH" ; }; - String SC_OPCODE_ARC_TAN_HYP { Text = "ATANH" ; }; - String SC_OPCODE_ARC_COT_HYP { Text = "ACOTH" ; }; - String SC_OPCODE_EXP { Text = "EXP" ; }; - String SC_OPCODE_LN { Text = "LN" ; }; - String SC_OPCODE_SQRT { Text = "SQRT" ; }; - String SC_OPCODE_FACT { Text = "FACT" ; }; - String SC_OPCODE_GET_YEAR { Text = "YEAR" ; }; - String SC_OPCODE_GET_MONTH { Text = "MONTH" ; }; - String SC_OPCODE_GET_DAY { Text = "DAY" ; }; - String SC_OPCODE_GET_HOUR { Text = "HOUR" ; }; - String SC_OPCODE_GET_MIN { Text = "MINUTE" ; }; - String SC_OPCODE_GET_SEC { Text = "SECOND" ; }; - String SC_OPCODE_PLUS_MINUS { Text = "SIGN" ; }; - String SC_OPCODE_ABS { Text = "ABS" ; }; - String SC_OPCODE_INT { Text = "INT" ; }; - String SC_OPCODE_PHI { Text = "PHI" ; }; - String SC_OPCODE_GAUSS { Text = "GAUSS" ; }; - String SC_OPCODE_IS_EMPTY { Text = "ISBLANK" ; }; - String SC_OPCODE_IS_STRING { Text = "ISTEXT" ; }; - String SC_OPCODE_IS_NON_STRING { Text = "ISNONTEXT" ; }; - String SC_OPCODE_IS_LOGICAL { Text = "ISLOGICAL" ; }; - String SC_OPCODE_TYPE { Text = "TYPE" ; }; - String SC_OPCODE_CELL { Text = "CELL" ; }; - String SC_OPCODE_IS_REF { Text = "ISREF" ; }; - String SC_OPCODE_IS_VALUE { Text = "ISNUMBER" ; }; - String SC_OPCODE_IS_FORMULA { Text = "ISFORMULA" ; }; - String SC_OPCODE_IS_NV { Text = "ISNA" ; }; - String SC_OPCODE_IS_ERR { Text = "ISERR" ; }; - String SC_OPCODE_IS_ERROR { Text = "ISERROR" ; }; - String SC_OPCODE_IS_EVEN { Text = "ISEVEN" ; }; - String SC_OPCODE_IS_ODD { Text = "ISODD" ; }; - String SC_OPCODE_N { Text = "N" ; }; - String SC_OPCODE_GET_DATE_VALUE { Text = "DATEVALUE" ; }; - String SC_OPCODE_GET_TIME_VALUE { Text = "TIMEVALUE" ; }; - String SC_OPCODE_CODE { Text = "CODE" ; }; - String SC_OPCODE_TRIM { Text = "TRIM" ; }; - String SC_OPCODE_UPPER { Text = "UPPER" ; }; - String SC_OPCODE_PROPPER { Text = "PROPER" ; }; - String SC_OPCODE_LOWER { Text = "LOWER" ; }; - String SC_OPCODE_LEN { Text = "LEN" ; }; - String SC_OPCODE_T { Text = "T" ; }; - String SC_OPCODE_VALUE { Text = "VALUE" ; }; - String SC_OPCODE_CLEAN { Text = "CLEAN" ; }; - String SC_OPCODE_CHAR { Text = "CHAR" ; }; - String SC_OPCODE_JIS { Text = "JIS" ; }; - String SC_OPCODE_ASC { Text = "ASC" ; }; - String SC_OPCODE_UNICODE { Text = "UNICODE" ; }; - String SC_OPCODE_UNICHAR { Text = "UNICHAR" ; }; - String SC_OPCODE_LOG10 { Text = "LOG10" ; }; - String SC_OPCODE_EVEN { Text = "EVEN" ; }; - String SC_OPCODE_ODD { Text = "ODD" ; }; - String SC_OPCODE_STD_NORM_DIST { Text = "LEGACY.NORMSDIST" ; }; - String SC_OPCODE_FISHER { Text = "FISHER" ; }; - String SC_OPCODE_FISHER_INV { Text = "FISHERINV" ; }; - String SC_OPCODE_S_NORM_INV { Text = "LEGACY.NORMSINV" ; }; - String SC_OPCODE_GAMMA_LN { Text = "GAMMALN" ; }; - String SC_OPCODE_ERROR_TYPE { Text = "ORG.OPENOFFICE.ERRORTYPE" ; }; - String SC_OPCODE_ERR_CELL { Text = "ZellError" ; }; // TODO: ancient legacy only, remove? - String SC_OPCODE_FORMULA { Text = "FORMULA"; }; - String SC_OPCODE_ARC_TAN_2 { Text = "ATAN2" ; }; - String SC_OPCODE_CEIL { Text = "CEILING" ; }; - String SC_OPCODE_FLOOR { Text = "FLOOR" ; }; - String SC_OPCODE_ROUND { Text = "ROUND" ; }; - String SC_OPCODE_ROUND_UP { Text = "ROUNDUP" ; }; - String SC_OPCODE_ROUND_DOWN { Text = "ROUNDDOWN" ; }; - String SC_OPCODE_TRUNC { Text = "TRUNC" ; }; - String SC_OPCODE_LOG { Text = "LOG" ; }; - String SC_OPCODE_POWER { Text = "POWER" ; }; - String SC_OPCODE_GGT { Text = "GCD" ; }; - String SC_OPCODE_KGV { Text = "LCM" ; }; - String SC_OPCODE_MOD { Text = "MOD" ; }; - String SC_OPCODE_SUM_PRODUCT { Text = "SUMPRODUCT" ; }; - String SC_OPCODE_SUM_SQ { Text = "SUMSQ" ; }; - String SC_OPCODE_SUM_X2MY2 { Text = "SUMX2MY2" ; }; - String SC_OPCODE_SUM_X2DY2 { Text = "SUMX2PY2" ; }; - String SC_OPCODE_SUM_XMY2 { Text = "SUMXMY2" ; }; - String SC_OPCODE_GET_DATE { Text = "DATE" ; }; - String SC_OPCODE_GET_TIME { Text = "TIME" ; }; - String SC_OPCODE_GET_DIFF_DATE { Text = "DAYS" ; }; - String SC_OPCODE_GET_DIFF_DATE_360 { Text = "DAYS360" ; }; - String SC_OPCODE_MIN { Text = "MIN" ; }; - String SC_OPCODE_MIN_A { Text = "MINA" ; }; - String SC_OPCODE_MAX { Text = "MAX" ; }; - String SC_OPCODE_MAX_A { Text = "MAXA" ; }; - String SC_OPCODE_SUM { Text = "SUM" ; }; - String SC_OPCODE_PRODUCT { Text = "PRODUCT" ; }; - String SC_OPCODE_AVERAGE { Text = "AVERAGE" ; }; - String SC_OPCODE_AVERAGE_A { Text = "AVERAGEA" ; }; - String SC_OPCODE_COUNT { Text = "COUNT" ; }; - String SC_OPCODE_COUNT_2 { Text = "COUNTA" ; }; - String SC_OPCODE_NBW { Text = "NPV" ; }; - String SC_OPCODE_IKV { Text = "IRR" ; }; - String SC_OPCODE_MIRR { Text = "MIRR" ; }; - String SC_OPCODE_ISPMT { Text = "ISPMT" ; }; - String SC_OPCODE_VAR { Text = "VAR" ; }; - String SC_OPCODE_VAR_A { Text = "VARA" ; }; - String SC_OPCODE_VAR_P { Text = "VARP" ; }; - String SC_OPCODE_VAR_P_A { Text = "VARPA" ; }; - String SC_OPCODE_ST_DEV { Text = "STDEV" ; }; - String SC_OPCODE_ST_DEV_A { Text = "STDEVA" ; }; - String SC_OPCODE_ST_DEV_P { Text = "STDEVP" ; }; - String SC_OPCODE_ST_DEV_P_A { Text = "STDEVPA" ; }; - String SC_OPCODE_B { Text = "B" ; }; - String SC_OPCODE_NORM_DIST { Text = "NORMDIST" ; }; - String SC_OPCODE_EXP_DIST { Text = "EXPONDIST" ; }; - String SC_OPCODE_BINOM_DIST { Text = "BINOMDIST" ; }; - String SC_OPCODE_POISSON_DIST { Text = "POISSON" ; }; - String SC_OPCODE_KOMBIN { Text = "COMBIN" ; }; - String SC_OPCODE_KOMBIN_2 { Text = "COMBINA" ; }; - String SC_OPCODE_VARIATIONEN { Text = "PERMUT" ; }; - String SC_OPCODE_VARIATIONEN_2 { Text = "PERMUTATIONA" ; }; - String SC_OPCODE_BW { Text = "PV" ; }; - String SC_OPCODE_DIA { Text = "SYD" ; }; - String SC_OPCODE_GDA { Text = "DDB" ; }; - String SC_OPCODE_GDA_2 { Text = "DB" ; }; - String SC_OPCODE_VBD { Text = "VDB" ; }; - String SC_OPCODE_LAUFZ { Text = "PDURATION" ; }; - String SC_OPCODE_LIA { Text = "SLN" ; }; - String SC_OPCODE_RMZ { Text = "PMT" ; }; - String SC_OPCODE_COLUMNS { Text = "COLUMNS" ; }; - String SC_OPCODE_ROWS { Text = "ROWS" ; }; - String SC_OPCODE_TABLES { Text = "SHEETS" ; }; - String SC_OPCODE_COLUMN { Text = "COLUMN" ; }; - String SC_OPCODE_ROW { Text = "ROW" ; }; - String SC_OPCODE_TABLE { Text = "SHEET" ; }; - String SC_OPCODE_ZGZ { Text = "ZGZ" ; }; - String SC_OPCODE_ZW { Text = "FV" ; }; - String SC_OPCODE_ZZR { Text = "NPER" ; }; - String SC_OPCODE_ZINS { Text = "RATE" ; }; - String SC_OPCODE_ZINS_Z { Text = "IPMT" ; }; - String SC_OPCODE_KAPZ { Text = "PPMT" ; }; - String SC_OPCODE_KUM_ZINS_Z { Text = "CUMIPMT" ; }; - String SC_OPCODE_KUM_KAP_Z { Text = "CUMPRINC" ; }; - String SC_OPCODE_EFFEKTIV { Text = "EFFECT" ; }; - String SC_OPCODE_NOMINAL { Text = "NOMINAL" ; }; - String SC_OPCODE_SUB_TOTAL { Text = "SUBTOTAL" ; }; - String SC_OPCODE_DB_SUM { Text = "DSUM" ; }; - String SC_OPCODE_DB_COUNT { Text = "DCOUNT" ; }; - String SC_OPCODE_DB_COUNT_2 { Text = "DCOUNTA" ; }; - String SC_OPCODE_DB_AVERAGE { Text = "DAVERAGE" ; }; - String SC_OPCODE_DB_GET { Text = "DGET" ; }; - String SC_OPCODE_DB_MAX { Text = "DMAX" ; }; - String SC_OPCODE_DB_MIN { Text = "DMIN" ; }; - String SC_OPCODE_DB_PRODUCT { Text = "DPRODUCT" ; }; - String SC_OPCODE_DB_STD_DEV { Text = "DSTDEV" ; }; - String SC_OPCODE_DB_STD_DEV_P { Text = "DSTDEVP" ; }; - String SC_OPCODE_DB_VAR { Text = "DVAR" ; }; - String SC_OPCODE_DB_VAR_P { Text = "DVARP" ; }; - String SC_OPCODE_INDIRECT { Text = "INDIRECT" ; }; - String SC_OPCODE_ADDRESS { Text = "ADDRESS" ; }; - String SC_OPCODE_MATCH { Text = "MATCH" ; }; - String SC_OPCODE_COUNT_EMPTY_CELLS { Text = "COUNTBLANK" ; }; - String SC_OPCODE_COUNT_IF { Text = "COUNTIF" ; }; - String SC_OPCODE_SUM_IF { Text = "SUMIF" ; }; - String SC_OPCODE_LOOKUP { Text = "LOOKUP" ; }; - String SC_OPCODE_V_LOOKUP { Text = "VLOOKUP" ; }; - String SC_OPCODE_H_LOOKUP { Text = "HLOOKUP" ; }; - String SC_OPCODE_MULTI_AREA { Text = "ORG.OPENOFFICE.MULTIRANGE" ; }; // legacy for range list (union) - String SC_OPCODE_OFFSET { Text = "OFFSET" ; }; - String SC_OPCODE_INDEX { Text = "INDEX" ; }; - String SC_OPCODE_AREAS { Text = "AREAS" ; }; - String SC_OPCODE_CURRENCY { Text = "DOLLAR" ; }; - String SC_OPCODE_REPLACE { Text = "REPLACE" ; }; - String SC_OPCODE_FIXED { Text = "FIXED" ; }; - String SC_OPCODE_FIND { Text = "FIND" ; }; - String SC_OPCODE_EXACT { Text = "EXACT" ; }; - String SC_OPCODE_LEFT { Text = "LEFT" ; }; - String SC_OPCODE_RIGHT { Text = "RIGHT" ; }; - String SC_OPCODE_SEARCH { Text = "SEARCH" ; }; - String SC_OPCODE_MID { Text = "MID" ; }; - String SC_OPCODE_TEXT { Text = "TEXT" ; }; - String SC_OPCODE_SUBSTITUTE { Text = "SUBSTITUTE" ; }; - String SC_OPCODE_REPT { Text = "REPT" ; }; - String SC_OPCODE_CONCAT { Text = "CONCATENATE" ; }; - String SC_OPCODE_MAT_VALUE { Text = "MVALUE" ; }; - String SC_OPCODE_MAT_DET { Text = "MDETERM" ; }; - String SC_OPCODE_MAT_INV { Text = "MINVERSE" ; }; - String SC_OPCODE_MAT_MULT { Text = "MMULT" ; }; - String SC_OPCODE_MAT_TRANS { Text = "TRANSPOSE" ; }; - String SC_OPCODE_MATRIX_UNIT { Text = "MUNIT" ; }; - String SC_OPCODE_BACK_SOLVER { Text = "GOALSEEK" ; }; - String SC_OPCODE_HYP_GEOM_DIST { Text = "HYPGEOMDIST" ; }; - String SC_OPCODE_LOG_NORM_DIST { Text = "LOGNORMDIST" ; }; - String SC_OPCODE_T_DIST { Text = "TDIST" ; }; - String SC_OPCODE_F_DIST { Text = "LEGACY.FDIST" ; }; - String SC_OPCODE_CHI_DIST { Text = "LEGACY.CHIDIST" ; }; - String SC_OPCODE_WEIBULL { Text = "WEIBULL" ; }; - String SC_OPCODE_NEG_BINOM_VERT { Text = "NEGBINOMDIST" ; }; - String SC_OPCODE_KRIT_BINOM { Text = "CRITBINOM" ; }; - String SC_OPCODE_KURT { Text = "KURT" ; }; - String SC_OPCODE_HAR_MEAN { Text = "HARMEAN" ; }; - String SC_OPCODE_GEO_MEAN { Text = "GEOMEAN" ; }; - String SC_OPCODE_STANDARD { Text = "STANDARDIZE" ; }; - String SC_OPCODE_AVE_DEV { Text = "AVEDEV" ; }; - String SC_OPCODE_SCHIEFE { Text = "SKEW" ; }; - String SC_OPCODE_DEV_SQ { Text = "DEVSQ" ; }; - String SC_OPCODE_MEDIAN { Text = "MEDIAN" ; }; - String SC_OPCODE_MODAL_VALUE { Text = "MODE" ; }; - String SC_OPCODE_Z_TEST { Text = "ZTEST" ; }; - String SC_OPCODE_T_TEST { Text = "TTEST" ; }; - String SC_OPCODE_RANK { Text = "RANK" ; }; - String SC_OPCODE_PERCENTILE { Text = "PERCENTILE" ; }; - String SC_OPCODE_PERCENT_RANK { Text = "PERCENTRANK" ; }; - String SC_OPCODE_LARGE { Text = "LARGE" ; }; - String SC_OPCODE_SMALL { Text = "SMALL" ; }; - String SC_OPCODE_FREQUENCY { Text = "FREQUENCY" ; }; - String SC_OPCODE_QUARTILE { Text = "QUARTILE" ; }; - String SC_OPCODE_NORM_INV { Text = "NORMINV" ; }; - String SC_OPCODE_CONFIDENCE { Text = "CONFIDENCE" ; }; - String SC_OPCODE_F_TEST { Text = "FTEST" ; }; - String SC_OPCODE_TRIM_MEAN { Text = "TRIMMEAN" ; }; - String SC_OPCODE_PROB { Text = "PROB" ; }; - String SC_OPCODE_CORREL { Text = "CORREL" ; }; - String SC_OPCODE_COVAR { Text = "COVAR" ; }; - String SC_OPCODE_PEARSON { Text = "PEARSON" ; }; - String SC_OPCODE_RSQ { Text = "RSQ" ; }; - String SC_OPCODE_STEYX { Text = "STEYX" ; }; - String SC_OPCODE_SLOPE { Text = "SLOPE" ; }; - String SC_OPCODE_INTERCEPT { Text = "INTERCEPT" ; }; - String SC_OPCODE_TREND { Text = "TREND" ; }; - String SC_OPCODE_GROWTH { Text = "GROWTH" ; }; - String SC_OPCODE_RGP { Text = "LINEST" ; }; - String SC_OPCODE_RKP { Text = "LOGEST" ; }; - String SC_OPCODE_FORECAST { Text = "FORECAST" ; }; - String SC_OPCODE_CHI_INV { Text = "LEGACY.CHIINV" ; }; - String SC_OPCODE_GAMMA_DIST { Text = "GAMMADIST" ; }; - String SC_OPCODE_GAMMA_INV { Text = "GAMMAINV" ; }; - String SC_OPCODE_T_INV { Text = "TINV" ; }; - String SC_OPCODE_F_INV { Text = "LEGACY.FINV" ; }; - String SC_OPCODE_CHI_TEST { Text = "LEGACY.CHITEST" ; }; - String SC_OPCODE_LOG_INV { Text = "LOGINV" ; }; - String SC_OPCODE_TABLE_OP { Text = "MULTIPLE.OPERATIONS" ; }; - String SC_OPCODE_BETA_DIST { Text = "BETADIST" ; }; - String SC_OPCODE_BETA_INV { Text = "BETAINV" ; }; - String SC_OPCODE_WEEK { Text = "ISOWEEKNUM" ; }; - String SC_OPCODE_EASTERSUNDAY { Text = "EASTERSUNDAY" ; }; - String SC_OPCODE_GET_DAY_OF_WEEK { Text = "WEEKDAY" ; }; - String SC_OPCODE_NO_NAME { Text = "#NAME!" ; }; - String SC_OPCODE_STYLE { Text = "ORG.OPENOFFICE.STYLE" ; }; - String SC_OPCODE_DDE { Text = "DDE" ; }; - String SC_OPCODE_BASE { Text = "BASE" ; }; - String SC_OPCODE_DECIMAL { Text = "DECIMAL" ; }; - String SC_OPCODE_CONVERT { Text = "ORG.OPENOFFICE.CONVERT" ; }; - String SC_OPCODE_ROMAN { Text = "ROMAN" ; }; - String SC_OPCODE_ARABIC { Text = "ARABIC" ; }; - String SC_OPCODE_HYPERLINK { Text = "HYPERLINK" ; }; - String SC_OPCODE_INFO { Text = "INFO" ; }; - String SC_OPCODE_BAHTTEXT { Text = "COM.MICROSOFT.BAHTTEXT" ; }; - String SC_OPCODE_GET_PIVOT_DATA { Text = "GETPIVOTDATA" ; }; - String SC_OPCODE_EUROCONVERT { Text = "EUROCONVERT" ; }; - String SC_OPCODE_NUMBERVALUE { Text = "NUMBERVALUE" ; }; - String SC_OPCODE_GAMMA { Text = "GAMMA" ; }; - String SC_OPCODE_CHISQ_DIST { Text = "CHISQDIST" ;}; - String SC_OPCODE_CHISQ_INV { Text = "CHISQINV" ;}; - /* BEGIN defined ERROR.TYPE() values. */ - String SC_OPCODE_ERROR_NULL { Text = "#NULL!" ; }; - String SC_OPCODE_ERROR_DIVZERO { Text = "#DIV/0!" ; }; - String SC_OPCODE_ERROR_VALUE { Text = "#VALUE!" ; }; - String SC_OPCODE_ERROR_REF { Text = "#REF!" ; }; - String SC_OPCODE_ERROR_NAME { Text = "#NAME?" ; }; - String SC_OPCODE_ERROR_NUM { Text = "#NUM!" ; }; - String SC_OPCODE_ERROR_NA { Text = "#N/A" ; }; - /* END defined ERROR.TYPE() values. */ -}; diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx index 3878fd6a1857..31f7fcd74ce6 100644 --- a/sc/source/core/tool/addincol.cxx +++ b/sc/source/core/tool/addincol.cxx @@ -60,7 +60,7 @@ #include "compiler.hxx" #include "scmatrix.hxx" #include "addinlis.hxx" -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" #include "scfuncs.hrc" #include "optutil.hxx" #include "addincfg.hxx" @@ -79,24 +79,6 @@ using namespace com::sun::star; //------------------------------------------------------------------------ -#define SC_FUNCGROUP_COUNT ID_FUNCTION_GRP_ADDINS - -static const sal_Char* __FAR_DATA aFuncNames[SC_FUNCGROUP_COUNT] = - { - // array index = ID - 1 (ID starts at 1) - // all upper case - "Database", // ID_FUNCTION_GRP_DATABASE - "Date&Time", // ID_FUNCTION_GRP_DATETIME - "Financial", // ID_FUNCTION_GRP_FINANZ - "Information", // ID_FUNCTION_GRP_INFO - "Logical", // ID_FUNCTION_GRP_LOGIC - "Mathematical", // ID_FUNCTION_GRP_MATH - "Matrix", // ID_FUNCTION_GRP_MATRIX - "Statistical", // ID_FUNCTION_GRP_STATISTIC - "Spreadsheet", // ID_FUNCTION_GRP_TABLE - "Text", // ID_FUNCTION_GRP_TEXT - "Add-In" // ID_FUNCTION_GRP_ADDINS - }; //------------------------------------------------------------------------ @@ -380,9 +362,26 @@ void ScUnoAddInCollection::Initialize() bInitialized = TRUE; // with or without functions } +// ----------------------------------------------------------------------------- USHORT lcl_GetCategory( const String& rName ) { + static const sal_Char* aFuncNames[SC_FUNCGROUP_COUNT] = + { + // array index = ID - 1 (ID starts at 1) + // all upper case + "Database", // ID_FUNCTION_GRP_DATABASE + "Date&Time", // ID_FUNCTION_GRP_DATETIME + "Financial", // ID_FUNCTION_GRP_FINANZ + "Information", // ID_FUNCTION_GRP_INFO + "Logical", // ID_FUNCTION_GRP_LOGIC + "Mathematical", // ID_FUNCTION_GRP_MATH + "Matrix", // ID_FUNCTION_GRP_MATRIX + "Statistical", // ID_FUNCTION_GRP_STATISTIC + "Spreadsheet", // ID_FUNCTION_GRP_TABLE + "Text", // ID_FUNCTION_GRP_TEXT + "Add-In" // ID_FUNCTION_GRP_ADDINS + }; for (USHORT i=0; i<SC_FUNCGROUP_COUNT; i++) if ( rName.EqualsAscii( aFuncNames[i] ) ) return i+1; // IDs start at 1 diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx index 7bfb14f795fe..9bf31053940f 100644 --- a/sc/source/core/tool/address.cxx +++ b/sc/source/core/tool/address.cxx @@ -49,7 +49,7 @@ using namespace ::com::sun::star; //////////////////////////////////////////////////////////////////////////// -const ScAddress::Details ScAddress::detailsOOOa1( CONV_OOO, 0, 0 ); +const ScAddress::Details ScAddress::detailsOOOa1( formula::FormulaGrammar::CONV_OOO, 0, 0 ); ScAddress::Details::Details ( const ScDocument* pDoc, const ScAddress & rAddr ) : @@ -1099,12 +1099,12 @@ lcl_ScAddress_Parse ( const sal_Unicode* p, ScDocument* pDoc, ScAddress& rAddr, switch (rDetails.eConv) { default : - case ScAddress::CONV_OOO: + case formula::FormulaGrammar::CONV_OOO: { return lcl_ScAddress_Parse_OOo( p, pDoc, rAddr, pExtInfo, NULL ); } - case ScAddress::CONV_XL_A1: + case formula::FormulaGrammar::CONV_XL_A1: case ScAddress::CONV_XL_OOX: { ScRange r = rAddr; @@ -1113,7 +1113,7 @@ lcl_ScAddress_Parse ( const sal_Unicode* p, ScDocument* pDoc, ScAddress& rAddr, rAddr = r.aStart; return nFlags; } - case ScAddress::CONV_XL_R1C1: + case formula::FormulaGrammar::CONV_XL_R1C1: { ScRange r = rAddr; USHORT nFlags = lcl_ScRange_Parse_XL_R1C1( r, p, pDoc, rDetails, true, pExtInfo ); @@ -1292,15 +1292,15 @@ USHORT ScRange::Parse( const String& r, ScDocument* pDoc, switch (rDetails.eConv) { default : - case ScAddress::CONV_OOO: + case formula::FormulaGrammar::CONV_OOO: return lcl_ScRange_Parse_OOo( *this, r, pDoc, pExtInfo ); - case ScAddress::CONV_XL_A1: + case formula::FormulaGrammar::CONV_XL_A1: case ScAddress::CONV_XL_OOX: return lcl_ScRange_Parse_XL_A1( *this, r.GetBuffer(), pDoc, false, pExtInfo, (rDetails.eConv == ScAddress::CONV_XL_OOX ? pExternalLinks : NULL) ); - case ScAddress::CONV_XL_R1C1: + case formula::FormulaGrammar::CONV_XL_R1C1: return lcl_ScRange_Parse_XL_R1C1( *this, r.GetBuffer(), pDoc, rDetails, false, pExtInfo ); } } @@ -1339,8 +1339,8 @@ USHORT ScRange::ParseCols( const String& rStr, ScDocument* pDoc, switch (rDetails.eConv) { default : - case ScAddress::CONV_OOO: // No full col refs in OOO yet, assume XL notation - case ScAddress::CONV_XL_A1: + case formula::FormulaGrammar::CONV_OOO: // No full col refs in OOO yet, assume XL notation + case formula::FormulaGrammar::CONV_XL_A1: case ScAddress::CONV_XL_OOX: if (NULL != (p = lcl_a1_get_col( p, &aStart, &ignored ) ) ) { @@ -1359,7 +1359,7 @@ USHORT ScRange::ParseCols( const String& rStr, ScDocument* pDoc, } break; - case ScAddress::CONV_XL_R1C1: + case formula::FormulaGrammar::CONV_XL_R1C1: if ((p[0] == 'C' || p[0] != 'c') && NULL != (p = lcl_r1c1_get_col( p, rDetails, &aStart, &ignored ))) { @@ -1398,8 +1398,8 @@ USHORT ScRange::ParseRows( const String& rStr, ScDocument* pDoc, switch (rDetails.eConv) { default : - case ScAddress::CONV_OOO: // No full row refs in OOO yet, assume XL notation - case ScAddress::CONV_XL_A1: + case formula::FormulaGrammar::CONV_OOO: // No full row refs in OOO yet, assume XL notation + case formula::FormulaGrammar::CONV_XL_A1: case ScAddress::CONV_XL_OOX: if (NULL != (p = lcl_a1_get_row( p, &aStart, &ignored ) ) ) { @@ -1418,7 +1418,7 @@ USHORT ScRange::ParseRows( const String& rStr, ScDocument* pDoc, } break; - case ScAddress::CONV_XL_R1C1: + case formula::FormulaGrammar::CONV_XL_R1C1: if ((p[0] == 'R' || p[0] != 'r') && NULL != (p = lcl_r1c1_get_row( p, rDetails, &aStart, &ignored ))) { @@ -1572,7 +1572,7 @@ void ScAddress::Format( String& r, USHORT nFlags, ScDocument* pDoc, switch( rDetails.eConv ) { default : - case CONV_OOO: + case formula::FormulaGrammar::CONV_OOO: r += aDocName; if( nFlags & SCA_TAB_ABSOLUTE ) r += '$'; @@ -1580,8 +1580,8 @@ void ScAddress::Format( String& r, USHORT nFlags, ScDocument* pDoc, r += '.'; break; - case CONV_XL_A1: - case CONV_XL_R1C1: + case formula::FormulaGrammar::CONV_XL_A1: + case formula::FormulaGrammar::CONV_XL_R1C1: case CONV_XL_OOX: if (aDocName.Len() > 0) { @@ -1598,8 +1598,8 @@ void ScAddress::Format( String& r, USHORT nFlags, ScDocument* pDoc, switch( rDetails.eConv ) { default : - case CONV_OOO: - case CONV_XL_A1: + case formula::FormulaGrammar::CONV_OOO: + case formula::FormulaGrammar::CONV_XL_A1: case CONV_XL_OOX: if( nFlags & SCA_VALID_COL ) lcl_a1_append_c ( r, nCol, nFlags & SCA_COL_ABSOLUTE ); @@ -1607,7 +1607,7 @@ void ScAddress::Format( String& r, USHORT nFlags, ScDocument* pDoc, lcl_a1_append_r ( r, nRow, nFlags & SCA_ROW_ABSOLUTE ); break; - case CONV_XL_R1C1: + case formula::FormulaGrammar::CONV_XL_R1C1: if( nFlags & SCA_VALID_ROW ) lcl_r1c1_append_r ( r, nRow, nFlags & SCA_ROW_ABSOLUTE, rDetails ); if( nFlags & SCA_VALID_COL ) @@ -1695,7 +1695,7 @@ void ScRange::Format( String& r, USHORT nFlags, ScDocument* pDoc, #define absrel_differ(nFlags, mask) (((nFlags) & (mask)) ^ (((nFlags) >> 4) & (mask))) switch( rDetails.eConv ) { default : - case ScAddress::CONV_OOO: { + case formula::FormulaGrammar::CONV_OOO: { BOOL bOneTab = (aStart.Tab() == aEnd.Tab()); if ( !bOneTab ) nFlags |= SCA_TAB_3D; @@ -1717,7 +1717,7 @@ void ScRange::Format( String& r, USHORT nFlags, ScDocument* pDoc, } break; - case ScAddress::CONV_XL_A1: + case formula::FormulaGrammar::CONV_XL_A1: case ScAddress::CONV_XL_OOX: lcl_ScRange_Format_XL_Header( r, *this, nFlags, pDoc, rDetails ); if( aStart.Col() == 0 && aEnd.Col() >= MAXCOL ) @@ -1749,7 +1749,7 @@ void ScRange::Format( String& r, USHORT nFlags, ScDocument* pDoc, } break; - case ScAddress::CONV_XL_R1C1: + case formula::FormulaGrammar::CONV_XL_R1C1: lcl_ScRange_Format_XL_Header( r, *this, nFlags, pDoc, rDetails ); if( aStart.Col() == 0 && aEnd.Col() >= MAXCOL ) { @@ -1825,8 +1825,8 @@ String ScAddress::GetColRowString( bool bAbsolute, switch( rDetails.eConv ) { default : - case ScAddress::CONV_OOO: - case ScAddress::CONV_XL_A1: + case formula::FormulaGrammar::CONV_OOO: + case formula::FormulaGrammar::CONV_XL_A1: case ScAddress::CONV_XL_OOX: if (bAbsolute) aString.Append( '$' ); @@ -1839,7 +1839,7 @@ String ScAddress::GetColRowString( bool bAbsolute, aString += String::CreateFromInt32(nRow+1); break; - case ScAddress::CONV_XL_R1C1: + case formula::FormulaGrammar::CONV_XL_R1C1: lcl_r1c1_append_r ( aString, nRow, bAbsolute, rDetails ); lcl_r1c1_append_c ( aString, nCol, bAbsolute, rDetails ); break; diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx index a5f9b3f9d9fc..3ba9ffb49abb 100644 --- a/sc/source/core/tool/appoptio.cxx +++ b/sc/source/core/tool/appoptio.cxx @@ -47,7 +47,7 @@ #include "global.hxx" #include "userlist.hxx" #include "sc.hrc" -#include "compiler.hrc" +#include <formula/compiler.hrc> #include "miscuno.hxx" using namespace utl; diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx index d70afab87f3f..238d0f943367 100644 --- a/sc/source/core/tool/cellform.cxx +++ b/sc/source/core/tool/cellform.cxx @@ -39,7 +39,7 @@ #include "cellform.hxx" #include "cell.hxx" #include "document.hxx" -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" #include "sc.hrc" // STATIC DATA ----------------------------------------------------------- diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index b85b4a02a660..17ea1a6cbb31 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -2027,7 +2027,7 @@ void ScChangeActionContent::SetValueString( String& rValue, ScBaseCell*& pCell, { rValue.Erase(); pCell = new ScFormulaCell( - pDoc, aBigRange.aStart.MakeAddress(), rStr, ScGrammar::GRAM_DEFAULT, ScAddress::CONV_OOO ); + pDoc, aBigRange.aStart.MakeAddress(), rStr, formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::CONV_OOO ); ((ScFormulaCell*)pCell)->SetInChangeTrack( TRUE ); } else @@ -2517,7 +2517,7 @@ void lcl_InvalidateReference( ScToken& rTok, const ScBigAddress& rPos ) rRef1.nRelTab = SCTAB_MAX; rRef1.SetTabDeleted( TRUE ); } - if ( rTok.GetType() == svDoubleRef ) + if ( rTok.GetType() == formula::svDoubleRef ) { ScSingleRefData& rRef2 = rTok.GetDoubleRef().Ref2; if ( rPos.Col() < 0 || MAXCOL < rPos.Col() ) @@ -2639,10 +2639,10 @@ void ScChangeActionContent::UpdateReference( const ScChangeTrack* pTrack, ScToken* t; ScTokenArray* pArr = ((ScFormulaCell*)pOldCell)->GetCode(); pArr->Reset(); - while ( ( t = pArr->GetNextReference() ) != NULL ) + while ( ( t = static_cast<ScToken*>(pArr->GetNextReference()) ) != NULL ) lcl_InvalidateReference( *t, rPos ); pArr->Reset(); - while ( ( t = pArr->GetNextReferenceRPN() ) != NULL ) + while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL ) lcl_InvalidateReference( *t, rPos ); } if ( bNewFormula ) @@ -2650,10 +2650,10 @@ void ScChangeActionContent::UpdateReference( const ScChangeTrack* pTrack, ScToken* t; ScTokenArray* pArr = ((ScFormulaCell*)pNewCell)->GetCode(); pArr->Reset(); - while ( ( t = pArr->GetNextReference() ) != NULL ) + while ( ( t = static_cast<ScToken*>(pArr->GetNextReference()) ) != NULL ) lcl_InvalidateReference( *t, rPos ); pArr->Reset(); - while ( ( t = pArr->GetNextReferenceRPN() ) != NULL ) + while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL ) lcl_InvalidateReference( *t, rPos ); } } diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index e9b583ec7783..1846fc21708f 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -46,7 +46,6 @@ #include <com/sun/star/sheet/FormulaOpCodeMapEntry.hpp> #include <com/sun/star/sheet/FormulaLanguage.hpp> #include <com/sun/star/sheet/FormulaMapGroup.hpp> -#include <com/sun/star/sheet/FormulaMapGroupSpecialOffset.hpp> #include <comphelper/processfactory.hxx> #include <unotools/transliterationwrapper.hxx> #include <tools/urlobj.hxx> @@ -69,11 +68,12 @@ #include "cell.hxx" #include "dociter.hxx" #include "docoptio.hxx" -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" #include "parclass.hxx" #include "autonamecache.hxx" #include "externalrefmgr.hxx" +using namespace formula; using namespace ::com::sun::star; using rtl::OUString; using ::std::vector; @@ -104,10 +104,6 @@ const char* dbg_sc_dump( const sal_Unicode c ) } #endif -ScCompiler::NonConstOpCodeMapPtr ScCompiler::mxSymbolsODFF; -ScCompiler::NonConstOpCodeMapPtr ScCompiler::mxSymbolsPODF; -ScCompiler::NonConstOpCodeMapPtr ScCompiler::mxSymbolsNative; -ScCompiler::NonConstOpCodeMapPtr ScCompiler::mxSymbolsEnglish; CharClass* ScCompiler::pCharClassEnglish = NULL; const ScCompiler::Convention* ScCompiler::pConventions[ ] = { NULL, NULL, NULL, NULL, NULL, NULL }; @@ -124,13 +120,6 @@ enum ScanState ssStop }; -struct ScArrayStack -{ - ScArrayStack* pNext; - ScTokenArray* pArr; - BOOL bTemp; -}; - static const sal_Char* pInternal[ 5 ] = { "GAME", "SPEW", "TTT", "STARCALCTEAM", "ANTWORT" }; using namespace ::com::sun::star::i18n; @@ -208,119 +197,7 @@ short lcl_GetRetFormat( OpCode eOpCode ) ///////////////////////////////////////////////////////////////////////// -class ScOpCodeList : public Resource // temp object for resource -{ -public: - - ScOpCodeList( USHORT, ScCompiler::NonConstOpCodeMapPtr ); - -private: - void init( ScGrammar::Grammar eGrammar ); - bool getOpCodeString( String& rStr, USHORT nOp ); - void putDefaultOpCode( ScCompiler::NonConstOpCodeMapPtr xMap, USHORT nOp ); - -private: - enum SeparatorType - { - SEMICOLON_BASE, - COMMA_BASE - }; - SeparatorType meSepType; -}; - -ScOpCodeList::ScOpCodeList( USHORT nRID, ScCompiler::NonConstOpCodeMapPtr xMap ) : - Resource( ScResId(nRID) ) -{ - init(xMap->getGrammar()); - - for (USHORT i = 0; i <= SC_OPCODE_LAST_OPCODE_ID; ++i) - { - String aOpStr; - if ( getOpCodeString(aOpStr, i) ) - xMap->putOpCode(aOpStr, OpCode(i)); - else - putDefaultOpCode(xMap, i); - } - - FreeResource(); -} - -void ScOpCodeList::init( ScGrammar::Grammar /*eGrammar*/ ) -{ - using namespace ::com::sun::star::sheet; - - meSepType = SEMICOLON_BASE; -#if 0 - if (ScGrammar::extractFormulaLanguage(eGrammar) == FormulaLanguage::NATIVE) - { - // Use localized separators. - const lang::Locale& rLocale = *ScGlobal::pLocale; - if (rLocale.Language.equalsAscii("en")) - meSepType = COMMA_BASE; - // TODO: Check for more locales. - } -#endif -} - -bool ScOpCodeList::getOpCodeString( String& rStr, USHORT nOp ) -{ - switch (nOp) - { - case SC_OPCODE_SEP: - { - if (meSepType == COMMA_BASE) - { - rStr = String::CreateFromAscii(","); - return true; - } - else if (meSepType == SEMICOLON_BASE) - { - rStr = String::CreateFromAscii(";"); - return true; - } - } - break; - case SC_OPCODE_ARRAY_COL_SEP: - { - if (meSepType == COMMA_BASE) - { - rStr = String::CreateFromAscii(","); - return true; - } - else if (meSepType == SEMICOLON_BASE) - { - rStr = String::CreateFromAscii(";"); - return true; - } - } - break; - case SC_OPCODE_ARRAY_ROW_SEP: - { - if (meSepType == COMMA_BASE) - { - rStr = String::CreateFromAscii(";"); - return true; - } - else if (meSepType == SEMICOLON_BASE) - { - rStr = String::CreateFromAscii("|"); - return true; - } - } - break; - } - - return false; -} - -void ScOpCodeList::putDefaultOpCode( ScCompiler::NonConstOpCodeMapPtr xMap, USHORT nOp ) -{ - ScResId aRes(nOp); - aRes.SetRT(RSC_STRING); - if (IsAvailableRes(aRes)) - xMap->putOpCode(aRes, OpCode(nOp)); -} class ScCompilerRecursionGuard { @@ -333,9 +210,22 @@ public: }; -// static -void ScCompiler::fillFromAddInMap( NonConstOpCodeMapPtr xMap, size_t nSymbolOffset ) +void ScCompiler::fillFromAddInMap( NonConstOpCodeMapPtr xMap,FormulaGrammar::Grammar _eGrammar ) const { + size_t nSymbolOffset; + switch( _eGrammar ) + { + case FormulaGrammar::GRAM_PODF: + nSymbolOffset = offsetof( AddInMap, pUpper); + break; + default: + case FormulaGrammar::GRAM_ODFF: + nSymbolOffset = offsetof( AddInMap, pODFF); + break; + case FormulaGrammar::GRAM_ENGLISH: + nSymbolOffset = offsetof( AddInMap, pEnglish); + break; + } const AddInMap* pMap = GetAddInMap(); const AddInMap* const pStop = pMap + GetAddInMapCount(); for ( ; pMap < pStop; ++pMap) @@ -348,8 +238,7 @@ void ScCompiler::fillFromAddInMap( NonConstOpCodeMapPtr xMap, size_t nSymbolOffs } } -// static -void ScCompiler::fillFromAddInCollectionUpperName( NonConstOpCodeMapPtr xMap ) +void ScCompiler::fillFromAddInCollectionUpperName( NonConstOpCodeMapPtr xMap ) const { ScUnoAddInCollection* pColl = ScGlobal::GetAddInCollection(); long nCount = pColl->GetFuncCount(); @@ -362,8 +251,7 @@ void ScCompiler::fillFromAddInCollectionUpperName( NonConstOpCodeMapPtr xMap ) } } -// static -void ScCompiler::fillFromAddInCollectionEnglishName( NonConstOpCodeMapPtr xMap ) +void ScCompiler::fillFromAddInCollectionEnglishName( NonConstOpCodeMapPtr xMap ) const { ScUnoAddInCollection* pColl = ScGlobal::GetAddInCollection(); long nCount = pColl->GetFuncCount(); @@ -383,82 +271,6 @@ void ScCompiler::fillFromAddInCollectionEnglishName( NonConstOpCodeMapPtr xMap ) } -// static -void ScCompiler::InitSymbolsNative() -{ - if (mxSymbolsNative.get()) - return; - - //! Experimental! - // Use English function names and separators instead of native in UI. - static const sal_Char aEnvVarName[] = "OOO_CALC_USE_ENGLISH_FORMULAS"; - const char* pEnv = getenv( aEnvVarName); - if (pEnv && (*pEnv == 'Y' || *pEnv == 'y' || *pEnv == '1') ) - { - fprintf( stderr, "%s=%s => UI uses English function names and separators in formulas.\n", - aEnvVarName, pEnv); - InitSymbolsEnglish(); - mxSymbolsNative = mxSymbolsEnglish; - return; - } - - // Core - mxSymbolsNative.reset( new OpCodeMap( SC_OPCODE_LAST_OPCODE_ID + 1, - true, ScGrammar::GRAM_NATIVE_UI)); - ScOpCodeList aOpCodeListNative( RID_SC_FUNCTION_NAMES, mxSymbolsNative ); - - // No AddInMap for native core mapping. -} - -// static -void ScCompiler::InitSymbolsEnglish() -{ - if (mxSymbolsEnglish.get()) - return; - - // Core - mxSymbolsEnglish.reset( new OpCodeMap( SC_OPCODE_LAST_OPCODE_ID + 1, - true, ScGrammar::GRAM_ENGLISH)); - ScOpCodeList aOpCodeList( RID_SC_FUNCTION_NAMES_ENGLISH, mxSymbolsEnglish ); - - fillFromAddInMap( mxSymbolsEnglish, offsetof( AddInMap, pEnglish)); - // Fill from collection for AddIns not already present. - fillFromAddInCollectionEnglishName( mxSymbolsEnglish); -} - -// static -void ScCompiler::InitSymbolsPODF() -{ - if (mxSymbolsPODF.get()) - return; - - // Core (though may change in future) - mxSymbolsPODF.reset( new OpCodeMap( SC_OPCODE_LAST_OPCODE_ID + 1, - true, ScGrammar::GRAM_PODF)); - // So far PODF internal names are identical to English. - ScOpCodeList aOpCodeList( RID_SC_FUNCTION_NAMES_ENGLISH, mxSymbolsPODF ); - - fillFromAddInMap( mxSymbolsPODF, offsetof( AddInMap, pUpper)); - // Fill from collection for AddIns not already present. - fillFromAddInCollectionUpperName( mxSymbolsPODF); -} - -// static -void ScCompiler::InitSymbolsODFF() -{ - if (mxSymbolsODFF.get()) - return; - - // not Core - mxSymbolsODFF.reset( new OpCodeMap( SC_OPCODE_LAST_OPCODE_ID + 1, - false, ScGrammar::GRAM_ODFF)); - ScOpCodeList aOpCodeList( RID_SC_FUNCTION_NAMES_ENGLISH_ODFF, mxSymbolsODFF ); - - fillFromAddInMap( mxSymbolsODFF, offsetof( AddInMap, pODFF)); - // Fill from collection for AddIns not already present. - fillFromAddInCollectionUpperName( mxSymbolsODFF); -} - #ifdef erGENERATEMAPPING // Run in en-US UI by calling from within gdb, edit pODFF entries afterwards. void dbg_call_generateMappingODFF() @@ -521,14 +333,14 @@ void dbg_call_generateMappingDiff() } // Actually they should all differ, so we could simply list them all, but // this is correct and we would find odd things, if any. - const ScExternalHashMap* pPODF = xPODF->getReverseExternalHashMap(); - const ScExternalHashMap* pODFF = xODFF->getReverseExternalHashMap(); - const ScExternalHashMap* pENUS = xENUS->getReverseExternalHashMap(); + const ExternalHashMap* pPODF = xPODF->getReverseExternalHashMap(); + const ExternalHashMap* pODFF = xODFF->getReverseExternalHashMap(); + const ExternalHashMap* pENUS = xENUS->getReverseExternalHashMap(); printf( "\n%s\n", "Add-In mapping"); - for (ScExternalHashMap::const_iterator it = pPODF->begin(); it != pPODF->end(); ++it) + for (ExternalHashMap::const_iterator it = pPODF->begin(); it != pPODF->end(); ++it) { - ScExternalHashMap::const_iterator iLookODFF = pODFF->find( (*it).first); - ScExternalHashMap::const_iterator iLookENUS = pENUS->find( (*it).first); + ExternalHashMap::const_iterator iLookODFF = pODFF->find( (*it).first); + ExternalHashMap::const_iterator iLookENUS = pENUS->find( (*it).first); String aNative( iLookENUS == pENUS->end() ? String::CreateFromAscii( "ENGLISH_SYMBOL_NOT_FOUND") : (*iLookENUS).second); @@ -547,10 +359,6 @@ void dbg_call_generateMappingDiff() // static void ScCompiler::DeInit() { - mxSymbolsNative.reset(); - mxSymbolsEnglish.reset(); - mxSymbolsODFF.reset(); - mxSymbolsPODF.reset(); if (pCharClassEnglish) { delete pCharClassEnglish; @@ -571,104 +379,24 @@ void ScCompiler::InitCharClassEnglish() } -// static -OpCode ScCompiler::GetEnglishOpCode( const String& rName ) -{ - if (!mxSymbolsEnglish.get()) - InitSymbolsEnglish(); - - ScOpCodeHashMap::const_iterator iLook( mxSymbolsEnglish->getHashMap()->find( rName ) ); - bool bFound = (iLook != mxSymbolsEnglish->getHashMap()->end()); - return bFound ? (*iLook).second : OpCode(ocNone); -} - - -// static -ScCompiler::OpCodeMapPtr ScCompiler::CreateOpCodeMap( - const ::com::sun::star::uno::Sequence< - const ::com::sun::star::sheet::FormulaOpCodeMapEntry > & rMapping, - bool bEnglish ) -{ - using ::com::sun::star::sheet::FormulaOpCodeMapEntry; - // Filter / API maps are never Core - NonConstOpCodeMapPtr xMap( new OpCodeMap( SC_OPCODE_LAST_OPCODE_ID + 1, - false, ScGrammar::mergeToGrammar( ScGrammar::setEnglishBit( - ScGrammar::GRAM_EXTERNAL, bEnglish), - ScAddress::CONV_UNSPECIFIED))); - FormulaOpCodeMapEntry const * pArr = rMapping.getConstArray(); - FormulaOpCodeMapEntry const * const pStop = pArr + rMapping.getLength(); - for ( ; pArr < pStop; ++pArr) - { - OpCode eOp = OpCode(pArr->Token.OpCode); - if (eOp != ocExternal) - xMap->putOpCode( pArr->Name, eOp); - else - { - OUString aExternalName; - if (pArr->Token.Data >>= aExternalName) - xMap->putExternal( pArr->Name, aExternalName); - else - { - DBG_ERRORFILE( "ScCompiler::CreateOpCodeMap: no Token.Data external name"); - } - } - } - return xMap; -} - - -// static -ScCompiler::OpCodeMapPtr ScCompiler::GetOpCodeMap( const sal_Int32 nLanguage ) -{ - ScCompiler::OpCodeMapPtr xMap; - using namespace ::com::sun::star::sheet; - switch (nLanguage) - { - case FormulaLanguage::ODFF : - if (!mxSymbolsODFF) - InitSymbolsODFF(); - xMap = mxSymbolsODFF; - break; - case FormulaLanguage::ODF_11 : - if (!mxSymbolsPODF) - InitSymbolsPODF(); - xMap = mxSymbolsPODF; - break; - case FormulaLanguage::ENGLISH : - if (!mxSymbolsEnglish) - InitSymbolsEnglish(); - xMap = mxSymbolsEnglish; - break; - case FormulaLanguage::NATIVE : - if (!mxSymbolsNative) - InitSymbolsNative(); - xMap = mxSymbolsNative; - break; - default: - ; // nothing, NULL map returned - } - return xMap; -} - - -void ScCompiler::SetGrammar( const ScGrammar::Grammar eGrammar ) +void ScCompiler::SetGrammar( const FormulaGrammar::Grammar eGrammar ) { - DBG_ASSERT( eGrammar != ScGrammar::GRAM_UNSPECIFIED, "ScCompiler::SetGrammar: don't pass ScGrammar::GRAM_UNSPECIFIED"); + DBG_ASSERT( eGrammar != FormulaGrammar::GRAM_UNSPECIFIED, "ScCompiler::SetGrammar: don't passFormulaGrammar::GRAM_UNSPECIFIED"); if (eGrammar == GetGrammar()) return; // nothing to be done - ScGrammar::Grammar eMyGrammar = eGrammar; - const sal_Int32 nFormulaLanguage = ScGrammar::extractFormulaLanguage( eMyGrammar); - ScCompiler::OpCodeMapPtr xMap( ScCompiler::GetOpCodeMap( nFormulaLanguage)); + FormulaGrammar::Grammar eMyGrammar = eGrammar; + const sal_Int32 nFormulaLanguage = FormulaGrammar::extractFormulaLanguage( eMyGrammar); + OpCodeMapPtr xMap( GetOpCodeMap( nFormulaLanguage)); DBG_ASSERT( xMap, "ScCompiler::SetGrammar: unknown formula language"); if (!xMap) { - xMap = ScCompiler::GetOpCodeMap( ::com::sun::star::sheet::FormulaLanguage::NATIVE); + xMap = GetOpCodeMap( ::com::sun::star::sheet::FormulaLanguage::NATIVE); eMyGrammar = xMap->getGrammar(); } // Save old grammar for call to SetGrammarAndRefConvention(). - ScGrammar::Grammar eOldGrammar = GetGrammar(); + FormulaGrammar::Grammar eOldGrammar = GetGrammar(); // This also sets the grammar associated with the map! SetFormulaLanguage( xMap); @@ -700,8 +428,8 @@ void ScCompiler::SetGrammarAndRefConvention( const ScGrammar::Grammar eNewGrammar, const ScGrammar::Grammar eOldGrammar ) { meGrammar = eNewGrammar; //! SetRefConvention needs the new grammar set! - ScAddress::Convention eConv = ScGrammar::extractRefConvention( meGrammar); - if (eConv == ScAddress::CONV_UNSPECIFIED && eOldGrammar == ScGrammar::GRAM_UNSPECIFIED) + FormulaGrammar::AddressConvention eConv = FormulaGrammar::extractRefConvention( meGrammar); + if (eConv == FormulaGrammar::CONV_UNSPECIFIED && eOldGrammar == FormulaGrammar::GRAM_UNSPECIFIED) { if (pDoc) SetRefConvention( pDoc->GetAddressConvention()); @@ -712,103 +440,11 @@ void ScCompiler::SetGrammarAndRefConvention( SetRefConvention( eConv ); } - -//----------------------------------------------------------------------------- - -void ScCompiler::OpCodeMap::putOpCode( const String & rStr, const OpCode eOp ) +String ScCompiler::FindAddInFunction( const String& rUpperName, BOOL bLocalFirst ) const { - DBG_ASSERT( 0 < eOp && USHORT(eOp) < mnSymbols, "OpCodeMap::putOpCode: OpCode out of range"); - if (0 < eOp && USHORT(eOp) < mnSymbols) - { - DBG_ASSERT( (mpTable[eOp].Len() == 0) || (mpTable[eOp] == rStr), - ByteString( "OpCodeMap::putOpCode: reusing OpCode "). - Append( ByteString::CreateFromInt32( sal_Int32( eOp))).Append( " ("). - Append( ByteString( rStr, RTL_TEXTENCODING_ASCII_US)).Append( ')').GetBuffer()); - mpTable[eOp] = rStr; - mpHashMap->insert( ScOpCodeHashMap::value_type( rStr, eOp)); - } -} - -void ScCompiler::OpCodeMap::putExternal( const String & rSymbol, const String & rAddIn ) -{ - bool bOk = mpExternalHashMap->insert( ScExternalHashMap::value_type( rSymbol, rAddIn)).second; - if (bOk) - bOk = mpReverseExternalHashMap->insert( ScExternalHashMap::value_type( rAddIn, rSymbol)).second; - DBG_ASSERT( bOk, "OpCodeMap::putExternal: symbol not inserted"); + return ScGlobal::GetAddInCollection()->FindFunction(rUpperName, bLocalFirst); // bLocalFirst=FALSE for english } -void ScCompiler::OpCodeMap::putExternalSoftly( const String & rSymbol, const String & rAddIn ) -{ - bool bOk = mpReverseExternalHashMap->insert( ScExternalHashMap::value_type( rAddIn, rSymbol)).second; - if (bOk) - mpExternalHashMap->insert( ScExternalHashMap::value_type( rSymbol, rAddIn)).second; -} - -::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > -ScCompiler::OpCodeMap::createSequenceOfFormulaTokens( - const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rNames ) const -{ - const sal_Int32 nLen = rNames.getLength(); - uno::Sequence< sheet::FormulaToken > aTokens( nLen); - sheet::FormulaToken* pToken = aTokens.getArray(); - OUString const * pName = rNames.getConstArray(); - OUString const * const pStop = pName + nLen; - for ( ; pName < pStop; ++pName, ++pToken) - { - ScOpCodeHashMap::const_iterator iLook( mpHashMap->find( *pName)); - if (iLook != mpHashMap->end()) - pToken->OpCode = (*iLook).second; - else - { - OUString aIntName; - if (hasExternals()) - { - ScExternalHashMap::const_iterator iExt( - mpExternalHashMap->find( *pName)); - if (iExt != mpExternalHashMap->end()) - aIntName = (*iExt).second; - // Check for existence not needed here, only name-mapping is of - // interest. - } - if (!aIntName.getLength()) - aIntName = ScGlobal::GetAddInCollection()->FindFunction( - *pName, !isEnglish()); // bLocalFirst=FALSE for english - if (!aIntName.getLength()) - pToken->OpCode = getOpCodeUnknown(); - else - { - pToken->OpCode = ocExternal; - pToken->Data <<= aIntName; - } - } - } - return aTokens; -} - -namespace { - -inline void lclPushOpCodeMapEntry( ::std::vector< ::com::sun::star::sheet::FormulaOpCodeMapEntry >& rVec, const String* pTable, USHORT nOpCode ) -{ - ::com::sun::star::sheet::FormulaOpCodeMapEntry aEntry; - aEntry.Token.OpCode = nOpCode; - aEntry.Name = pTable[nOpCode]; - rVec.push_back( aEntry); -} - -void lclPushOpCodeMapEntries( ::std::vector< ::com::sun::star::sheet::FormulaOpCodeMapEntry >& rVec, const String* pTable, USHORT nOpCodeBeg, USHORT nOpCodeEnd ) -{ - for (USHORT nOpCode = nOpCodeBeg; nOpCode < nOpCodeEnd; ++nOpCode) - lclPushOpCodeMapEntry( rVec, pTable, nOpCode ); -} - -void lclPushOpCodeMapEntries( ::std::vector< ::com::sun::star::sheet::FormulaOpCodeMapEntry >& rVec, const String* pTable, const USHORT* pnOpCodes, size_t nCount ) -{ - for (const USHORT* pnEnd = pnOpCodes + nCount; pnOpCodes < pnEnd; ++pnOpCodes) - lclPushOpCodeMapEntry( rVec, pTable, *pnOpCodes ); -} - -} // namespace - #ifdef erDEBUG void dbg_call_testcreatemapping() @@ -819,212 +455,6 @@ void dbg_call_testcreatemapping() } #endif -::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaOpCodeMapEntry > -ScCompiler::OpCodeMap::createSequenceOfAvailableMappings( const sal_Int32 nGroups ) const -{ - using namespace ::com::sun::star::sheet; - - // Unfortunately uno::Sequence can't grow without cumbersome reallocs. As - // we don't know in advance how many elements it will have we use a - // temporary vector to add elements and then copy to Sequence :-( - ::std::vector< FormulaOpCodeMapEntry > aVec; - - if (nGroups == FormulaMapGroup::SPECIAL) - { - // Use specific order, keep in sync with - // offapi/com/sun/star/sheet/FormulaMapGroupSpecialOffset.idl - static const struct - { - sal_Int32 nOff; - OpCode eOp; - } aMap[] = { - { FormulaMapGroupSpecialOffset::PUSH , ocPush } , - { FormulaMapGroupSpecialOffset::CALL , ocCall } , - { FormulaMapGroupSpecialOffset::STOP , ocStop } , - { FormulaMapGroupSpecialOffset::EXTERNAL , ocExternal } , - { FormulaMapGroupSpecialOffset::NAME , ocName } , - { FormulaMapGroupSpecialOffset::NO_NAME , ocNoName } , - { FormulaMapGroupSpecialOffset::MISSING , ocMissing } , - { FormulaMapGroupSpecialOffset::BAD , ocBad } , - { FormulaMapGroupSpecialOffset::SPACES , ocSpaces } , - { FormulaMapGroupSpecialOffset::MAT_REF , ocMatRef } , - { FormulaMapGroupSpecialOffset::DB_AREA , ocDBArea } , - { FormulaMapGroupSpecialOffset::MACRO , ocMacro } , - { FormulaMapGroupSpecialOffset::COL_ROW_NAME , ocColRowName } - }; - const size_t nCount = sizeof(aMap)/sizeof(aMap[0]); - // Preallocate vector elements. - if (aVec.size() < nCount) - { - FormulaOpCodeMapEntry aEntry; - aEntry.Token.OpCode = getOpCodeUnknown(); - aVec.resize( nCount, aEntry); - } - for (size_t i=0; i < nCount; ++i) - { - FormulaOpCodeMapEntry aEntry; - size_t nIndex = static_cast< size_t >( aMap[i].nOff ); - if (aVec.size() <= nIndex) - { - // The offsets really should be aligned with the size, so if - // the vector was preallocated above this code to resize it is - // just a measure in case the table isn't in sync with the API, - // usually it isn't executed. - aEntry.Token.OpCode = getOpCodeUnknown(); - aVec.resize( nIndex + 1, aEntry ); - } - aEntry.Token.OpCode = aMap[i].eOp; - aVec[nIndex] = aEntry; - } - } - else - { - /* FIXME: Once we support error constants in formulas we'll need a map - * group for that, e.g. FormulaMapGroup::ERROR_CONSTANTS, and fill - * SC_OPCODE_START_ERRORS to SC_OPCODE_STOP_ERRORS. */ - - // Anything else but SPECIAL. - if ((nGroups & FormulaMapGroup::SEPARATORS) != 0) - { - static const USHORT aOpCodes[] = { - SC_OPCODE_OPEN, - SC_OPCODE_CLOSE, - SC_OPCODE_SEP, - }; - lclPushOpCodeMapEntries( aVec, mpTable, aOpCodes, sizeof(aOpCodes)/sizeof(aOpCodes[0]) ); - } - if ((nGroups & FormulaMapGroup::ARRAY_SEPARATORS) != 0) - { - static const USHORT aOpCodes[] = { - SC_OPCODE_ARRAY_OPEN, - SC_OPCODE_ARRAY_CLOSE, - SC_OPCODE_ARRAY_ROW_SEP, - SC_OPCODE_ARRAY_COL_SEP - }; - lclPushOpCodeMapEntries( aVec, mpTable, aOpCodes, sizeof(aOpCodes)/sizeof(aOpCodes[0]) ); - } - if ((nGroups & FormulaMapGroup::UNARY_OPERATORS) != 0) - { - // Due to the nature of the percent operator following its operand - // it isn't sorted into unary operators for compiler interna. - lclPushOpCodeMapEntry( aVec, mpTable, ocPercentSign ); - // "+" can be used as unary operator too, push only if binary group is not set - if ((nGroups & FormulaMapGroup::BINARY_OPERATORS) == 0) - lclPushOpCodeMapEntry( aVec, mpTable, ocAdd ); - // regular unary operators - for (USHORT nOp = SC_OPCODE_START_UN_OP; nOp < SC_OPCODE_STOP_UN_OP && nOp < mnSymbols; ++nOp) - { - switch (nOp) - { - // NOT and NEG in fact are functions but for legacy reasons - // are sorted into unary operators for compiler interna. - case SC_OPCODE_NOT : - case SC_OPCODE_NEG : - break; // nothing, - default: - lclPushOpCodeMapEntry( aVec, mpTable, nOp ); - } - } - } - if ((nGroups & FormulaMapGroup::BINARY_OPERATORS) != 0) - { - for (USHORT nOp = SC_OPCODE_START_BIN_OP; nOp < SC_OPCODE_STOP_BIN_OP && nOp < mnSymbols; ++nOp) - { - switch (nOp) - { - // AND and OR in fact are functions but for legacy reasons - // are sorted into binary operators for compiler interna. - case SC_OPCODE_AND : - case SC_OPCODE_OR : - break; // nothing, - default: - lclPushOpCodeMapEntry( aVec, mpTable, nOp ); - } - } - } - if ((nGroups & FormulaMapGroup::FUNCTIONS) != 0) - { - // Function names are not consecutive, skip the gaps between - // functions with no parameter, functions with 1 parameter - lclPushOpCodeMapEntries( aVec, mpTable, SC_OPCODE_START_NO_PAR, ::std::min< USHORT >( SC_OPCODE_STOP_NO_PAR, mnSymbols ) ); - lclPushOpCodeMapEntries( aVec, mpTable, SC_OPCODE_START_1_PAR, ::std::min< USHORT >( SC_OPCODE_STOP_1_PAR, mnSymbols ) ); - // Additional functions not within range of functions. - static const USHORT aOpCodes[] = { - SC_OPCODE_IF, - SC_OPCODE_CHOSE, - SC_OPCODE_AND, - SC_OPCODE_OR, - SC_OPCODE_NOT, - SC_OPCODE_NEG - }; - lclPushOpCodeMapEntries( aVec, mpTable, aOpCodes, sizeof(aOpCodes)/sizeof(aOpCodes[0]) ); - // functions with 2 or more parameters. - for (USHORT nOp = SC_OPCODE_START_2_PAR; nOp < SC_OPCODE_STOP_2_PAR && nOp < mnSymbols; ++nOp) - { - switch (nOp) - { - // NO_NAME is in SPECIAL. - case SC_OPCODE_NO_NAME : - break; // nothing, - default: - lclPushOpCodeMapEntry( aVec, mpTable, nOp ); - } - } - // If AddIn functions are present in this mapping, use them, and only those. - if (hasExternals()) - { - for (ScExternalHashMap::const_iterator it( mpExternalHashMap->begin()); - it != mpExternalHashMap->end(); ++it) - { - FormulaOpCodeMapEntry aEntry; - aEntry.Name = (*it).first; - aEntry.Token.Data <<= OUString( (*it).second); - aEntry.Token.OpCode = ocExternal; - aVec.push_back( aEntry); - } - } - else - { - DBG_ASSERT( isCore(), "ScCompiler::OpCodeMap::createSequenceOfAvailableMappings: AddIn mapping from collection only implemented for core languages"); - // All known AddIn functions. - ScUnoAddInCollection* pColl = ScGlobal::GetAddInCollection(); - long nCount = pColl->GetFuncCount(); - for (long i=0; i < nCount; ++i) - { - const ScUnoAddInFuncData* pFuncData = pColl->GetFuncData(i); - if (pFuncData) - { - FormulaOpCodeMapEntry aEntry; - if (isEnglish()) - { - String aName; - if (pFuncData->GetExcelName( LANGUAGE_ENGLISH_US, aName)) - aEntry.Name = aName; - else - aEntry.Name = pFuncData->GetUpperName(); - } - else - aEntry.Name = pFuncData->GetUpperLocal(); - aEntry.Token.Data <<= OUString( pFuncData->GetOriginalName()); - aEntry.Token.OpCode = ocExternal; - aVec.push_back( aEntry); - } - } - // FIXME: what about those old non-UNO AddIns? - } - } - } - size_t nLen = aVec.size(); - uno::Sequence< FormulaOpCodeMapEntry > aSeq( nLen); - FormulaOpCodeMapEntry* pArr = aSeq.getArray(); - for (size_t i=0; i < nLen; ++i, ++pArr) - { - *pArr = aVec[i]; - } - return aSeq; -} - - //----------------------------------------------------------------------------- ScCompiler::Convention::~Convention() @@ -1033,7 +463,7 @@ ScCompiler::Convention::~Convention() mpCharTable = NULL; } -ScCompiler::Convention::Convention( ScAddress::Convention eConv ) +ScCompiler::Convention::Convention( FormulaGrammar::AddressConvention eConv ) : meConv( eConv ) { @@ -1048,7 +478,7 @@ ScCompiler::Convention::Convention( ScAddress::Convention eConv ) /* */ t[32] = SC_COMPILER_C_CHAR_DONTCARE | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP; /* ! */ t[33] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP; - if (ScAddress::CONV_ODF == meConv) + if (FormulaGrammar::CONV_ODF == meConv) /* ! */ t[33] |= SC_COMPILER_C_ODF_LABEL_OP; /* " */ t[34] = SC_COMPILER_C_CHAR_STRING | SC_COMPILER_C_STRING_SEP; /* # */ t[35] = SC_COMPILER_C_WORD_SEP; @@ -1081,7 +511,7 @@ ScCompiler::Convention::Convention( ScAddress::Convention eConv ) for (i = 65; i < 91; i++) /* A-Z */ t[i] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_IDENT | SC_COMPILER_C_IDENT; - if (ScAddress::CONV_ODF == meConv) + if (FormulaGrammar::CONV_ODF == meConv) { /* [ */ t[91] = SC_COMPILER_C_ODF_LBRACKET; /* \ */ // FREE @@ -1106,7 +536,7 @@ ScCompiler::Convention::Convention( ScAddress::Convention eConv ) /* ~ */ t[126] = SC_COMPILER_C_CHAR; // OOo specific /* 127 */ // FREE - if( ScAddress::CONV_XL_A1 == meConv || ScAddress::CONV_XL_R1C1 == meConv || ScAddress::CONV_XL_OOX == meConv ) + if( FormulaGrammar::CONV_XL_A1 == meConv || FormulaGrammar::CONV_XL_R1C1 == meConv || FormulaGrammar::CONV_XL_OOX == meConv ) { /* */ t[32] |= SC_COMPILER_C_WORD; /* ! */ t[33] |= SC_COMPILER_C_IDENT | SC_COMPILER_C_WORD; @@ -1143,7 +573,7 @@ ScCompiler::Convention::Convention( ScAddress::Convention eConv ) /* } */ t[125]|= SC_COMPILER_C_WORD; /* ~ */ t[126]|= SC_COMPILER_C_WORD; - if( ScAddress::CONV_XL_R1C1 == meConv ) + if( FormulaGrammar::CONV_XL_R1C1 == meConv ) { /* - */ t[45] |= SC_COMPILER_C_IDENT; /* [ */ t[91] |= SC_COMPILER_C_IDENT; @@ -1370,7 +800,7 @@ static String lcl_makeExternalNameStr( const String& rFile, const String& rName, } static bool lcl_getLastTabName( String& rTabName2, const String& rTabName1, - const vector<String>& rTabNames, const ComplRefData& rRef ) + const vector<String>& rTabNames, const ScComplexRefData& rRef ) { SCsTAB nTabSpan = rRef.Ref2.nTab - rRef.Ref1.nTab; if (nTabSpan > 0) @@ -1411,7 +841,7 @@ static void lcl_appendTabName(::rtl::OUStringBuffer& rBuffer, const String& rTab struct Convention_A1 : public ScCompiler::Convention { - Convention_A1( ScAddress::Convention eConv ) : ScCompiler::Convention( eConv ) { } + Convention_A1( FormulaGrammar::AddressConvention eConv ) : ScCompiler::Convention( eConv ) { } static void MakeColStr( rtl::OUStringBuffer& rBuffer, SCCOL nCol ); static void MakeRowStr( rtl::OUStringBuffer& rBuffer, SCROW nRow ); @@ -1453,8 +883,8 @@ void Convention_A1::MakeRowStr( rtl::OUStringBuffer& rBuffer, SCROW nRow ) struct ConventionOOO_A1 : public Convention_A1 { - ConventionOOO_A1() : Convention_A1 (ScAddress::CONV_OOO) { } - ConventionOOO_A1( ScAddress::Convention eConv ) : Convention_A1 (eConv) { } + ConventionOOO_A1() : Convention_A1 (FormulaGrammar::CONV_OOO) { } + ConventionOOO_A1( FormulaGrammar::AddressConvention eConv ) : Convention_A1 (eConv) { } static String MakeTabStr( const ScCompiler& rComp, SCTAB nTab, String& aDoc ) { String aString; @@ -1477,7 +907,7 @@ struct ConventionOOO_A1 : public Convention_A1 } else aDoc.Erase(); - ScCompiler::CheckTabQuotes( aString, ScAddress::CONV_OOO ); + ScCompiler::CheckTabQuotes( aString, FormulaGrammar::CONV_OOO ); } aString += '.'; return aString; @@ -1607,7 +1037,7 @@ struct ConventionOOO_A1 : public Convention_A1 } bool makeExternalSingleRefStr( ::rtl::OUStringBuffer& rBuffer, sal_uInt16 nFileId, - const String& rTabName, const SingleRefData& rRef, + const String& rTabName, const ScSingleRefData& rRef, ScExternalRefManager* pRefMgr, bool bDisplayTabName ) const { if (bDisplayTabName) @@ -1641,10 +1071,10 @@ struct ConventionOOO_A1 : public Convention_A1 } void makeExternalRefStrImpl( ::rtl::OUStringBuffer& rBuffer, const ScCompiler& rCompiler, - sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef, + sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef, ScExternalRefManager* pRefMgr, bool bODF ) const { - SingleRefData aRef(rRef); + ScSingleRefData aRef(rRef); aRef.CalcAbsIfRel(rCompiler.GetPos()); if (bODF) @@ -1655,17 +1085,17 @@ struct ConventionOOO_A1 : public Convention_A1 } virtual void makeExternalRefStr( ::rtl::OUStringBuffer& rBuffer, const ScCompiler& rCompiler, - sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef, + sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef, ScExternalRefManager* pRefMgr ) const { makeExternalRefStrImpl( rBuffer, rCompiler, nFileId, rTabName, rRef, pRefMgr, false); } void makeExternalRefStrImpl( ::rtl::OUStringBuffer& rBuffer, const ScCompiler& rCompiler, - sal_uInt16 nFileId, const String& rTabName, const ComplRefData& rRef, + sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef, ScExternalRefManager* pRefMgr, bool bODF ) const { - ComplRefData aRef(rRef); + ScComplexRefData aRef(rRef); aRef.CalcAbsIfRel(rCompiler.GetPos()); if (bODF) @@ -1705,7 +1135,7 @@ struct ConventionOOO_A1 : public Convention_A1 } virtual void makeExternalRefStr( ::rtl::OUStringBuffer& rBuffer, const ScCompiler& rCompiler, - sal_uInt16 nFileId, const String& rTabName, const ComplRefData& rRef, + sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef, ScExternalRefManager* pRefMgr ) const { makeExternalRefStrImpl( rBuffer, rCompiler, nFileId, rTabName, rRef, pRefMgr, false); @@ -1720,7 +1150,7 @@ const ScCompiler::Convention * const ScCompiler::pConvOOO_A1 = &ConvOOO_A1; struct ConventionOOO_A1_ODF : public ConventionOOO_A1 { - ConventionOOO_A1_ODF() : ConventionOOO_A1 (ScAddress::CONV_ODF) { } + ConventionOOO_A1_ODF() : ConventionOOO_A1 (FormulaGrammar::CONV_ODF) { } void MakeRefStr( rtl::OUStringBuffer& rBuffer, const ScCompiler& rComp, const ScComplexRefData& rRef, @@ -1735,14 +1165,14 @@ struct ConventionOOO_A1_ODF : public ConventionOOO_A1 } virtual void makeExternalRefStr( ::rtl::OUStringBuffer& rBuffer, const ScCompiler& rCompiler, - sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef, + sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef, ScExternalRefManager* pRefMgr ) const { makeExternalRefStrImpl( rBuffer, rCompiler, nFileId, rTabName, rRef, pRefMgr, true); } virtual void makeExternalRefStr( ::rtl::OUStringBuffer& rBuffer, const ScCompiler& rCompiler, - sal_uInt16 nFileId, const String& rTabName, const ComplRefData& rRef, + sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef, ScExternalRefManager* pRefMgr ) const { makeExternalRefStrImpl( rBuffer, rCompiler, nFileId, rTabName, rRef, pRefMgr, true); @@ -1788,7 +1218,7 @@ struct ConventionXL // XL uses the same sheet name quoting conventions in both modes // it is safe to use A1 here - ScCompiler::CheckTabQuotes( rTabName, ScAddress::CONV_XL_A1 ); + ScCompiler::CheckTabQuotes( rTabName, FormulaGrammar::CONV_XL_A1 ); return bHasDoc; } @@ -1886,7 +1316,7 @@ struct ConventionXL static void makeExternalTabNameRange( ::rtl::OUStringBuffer& rBuf, const String& rTabName, const vector<String>& rTabNames, - const ComplRefData& rRef ) + const ScComplexRefData& rRef ) { String aLastTabName; if (!lcl_getLastTabName(aLastTabName, rTabName, rTabNames, rRef)) @@ -1959,10 +1389,10 @@ struct ConventionXL struct ConventionXL_A1 : public Convention_A1, public ConventionXL { - ConventionXL_A1() : Convention_A1( ScAddress::CONV_XL_A1 ) { } + ConventionXL_A1() : Convention_A1( FormulaGrammar::CONV_XL_A1 ) { } ConventionXL_A1( ScAddress::Convention eConv ) : Convention_A1( eConv ) { } - void makeSingleCellStr( ::rtl::OUStringBuffer& rBuf, const SingleRefData& rRef ) const + void makeSingleCellStr( ::rtl::OUStringBuffer& rBuf, const ScSingleRefData& rRef ) const { if (!rRef.IsColRel()) rBuf.append(sal_Unicode('$')); @@ -2069,7 +1499,7 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL } virtual void makeExternalRefStr( ::rtl::OUStringBuffer& rBuffer, const ScCompiler& rCompiler, - sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef, + sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef, ScExternalRefManager* pRefMgr ) const { // ['file:///path/to/file/filename.xls']'Sheet Name'!$A$1 @@ -2082,7 +1512,7 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL if (!pFullName) return; - SingleRefData aRef(rRef); + ScSingleRefData aRef(rRef); aRef.CalcAbsIfRel(rCompiler.GetPos()); ConventionXL::makeExternalDocStr(rBuffer, *pFullName); @@ -2093,7 +1523,7 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL } virtual void makeExternalRefStr( ::rtl::OUStringBuffer& rBuffer, const ScCompiler& rCompiler, - sal_uInt16 nFileId, const String& rTabName, const ComplRefData& rRef, + sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef, ScExternalRefManager* pRefMgr ) const { const String* pFullName = pRefMgr->getExternalFileName(nFileId); @@ -2105,7 +1535,7 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL if (aTabNames.empty()) return; - ComplRefData aRef(rRef); + ScComplexRefData aRef(rRef); aRef.CalcAbsIfRel(rCompiler.GetPos()); ConventionXL::makeExternalDocStr(rBuffer, *pFullName); @@ -2171,7 +1601,7 @@ r1c1_add_row( rtl::OUStringBuffer &rBuf, const ScSingleRefData& rRef ) struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL { - ConventionXL_R1C1() : ScCompiler::Convention( ScAddress::CONV_XL_R1C1 ) { } + ConventionXL_R1C1() : ScCompiler::Convention( FormulaGrammar::CONV_XL_R1C1 ) { } void MakeRefStr( rtl::OUStringBuffer& rBuf, const ScCompiler& rComp, const ScComplexRefData& rRef, @@ -2273,7 +1703,7 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL } virtual void makeExternalRefStr( ::rtl::OUStringBuffer& rBuffer, const ScCompiler& rCompiler, - sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef, + sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef, ScExternalRefManager* pRefMgr ) const { // ['file:///path/to/file/filename.xls']'Sheet Name'!$A$1 @@ -2286,7 +1716,7 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL if (!pFullName) return; - SingleRefData aRef(rRef); + ScSingleRefData aRef(rRef); aRef.CalcAbsIfRel(rCompiler.GetPos()); ConventionXL::makeExternalDocStr(rBuffer, *pFullName); @@ -2298,7 +1728,7 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL } virtual void makeExternalRefStr( ::rtl::OUStringBuffer& rBuffer, const ScCompiler& rCompiler, - sal_uInt16 nFileId, const String& rTabName, const ComplRefData& rRef, + sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef, ScExternalRefManager* pRefMgr ) const { const String* pFullName = pRefMgr->getExternalFileName(nFileId); @@ -2310,7 +1740,7 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL if (aTabNames.empty()) return; - ComplRefData aRef(rRef); + ScComplexRefData aRef(rRef); aRef.CalcAbsIfRel(rCompiler.GetPos()); ConventionXL::makeExternalDocStr(rBuffer, *pFullName); @@ -2357,58 +1787,34 @@ static const ConventionXL_R1C1 ConvXL_R1C1; const ScCompiler::Convention * const ScCompiler::pConvXL_R1C1 = &ConvXL_R1C1; //----------------------------------------------------------------------------- -ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos, - ScTokenArray& rArr, const ScGrammar::Grammar eGrammar ) - : +ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos,ScTokenArray& rArr) + : FormulaCompiler(rArr), pDoc( pDocument ), aPos( rPos ), - pArr( &rArr ), - pStack( NULL ), - mxSymbols( mxSymbolsNative ), pCharClass( ScGlobal::pCharClass ), mnPredetectedReference(0), - nNumFmt( NUMBERFORMAT_UNDEFINED ), - nRecursion(0), - bAutoCorrect( FALSE ), - bCorrected( FALSE ), - bCompileForFAP( FALSE ), - bIgnoreErrors( FALSE ), pConv( pConvOOO_A1 ), mbCloseBrackets( true ), - meGrammar( ScGrammar::GRAM_UNSPECIFIED ), mbExtendedErrorDetection( false ) { - SetGrammar( eGrammar); nMaxTab = pDoc ? pDoc->GetTableCount() - 1 : 0; } -ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos, - const ScGrammar::Grammar eGrammar ) +ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos) : pDoc( pDocument ), aPos( rPos ), - pArr( NULL ), - pStack( NULL ), - mxSymbols( mxSymbolsNative ), pCharClass( ScGlobal::pCharClass ), mnPredetectedReference(0), - nNumFmt( NUMBERFORMAT_UNDEFINED ), - nRecursion(0), - bAutoCorrect( FALSE ), - bCorrected( FALSE ), - bCompileForFAP( FALSE ), - bIgnoreErrors( FALSE ), pConv( pConvOOO_A1 ), mbCloseBrackets( true ), - meGrammar( ScGrammar::GRAM_UNSPECIFIED ), mbExtendedErrorDetection( false ) { - SetGrammar( eGrammar); nMaxTab = pDoc ? pDoc->GetTableCount() - 1 : 0; } void ScCompiler::CheckTabQuotes( String& rString, - const ScAddress::Convention eConv ) + const FormulaGrammar::AddressConvention eConv ) { using namespace ::com::sun::star::i18n; sal_Int32 nStartFlags = KParseTokens::ANY_LETTER_OR_NUMBER | KParseTokens::ASC_UNDERSCORE; @@ -2420,11 +1826,11 @@ void ScCompiler::CheckTabQuotes( String& rString, switch ( eConv ) { default : - case ScAddress::CONV_UNSPECIFIED : + case FormulaGrammar::CONV_UNSPECIFIED : break; - case ScAddress::CONV_OOO : - case ScAddress::CONV_XL_A1 : - case ScAddress::CONV_XL_R1C1 : + case FormulaGrammar::CONV_OOO : + case FormulaGrammar::CONV_XL_A1 : + case FormulaGrammar::CONV_XL_R1C1 : case ScAddress::CONV_XL_OOX : if( bNeedsQuote ) { @@ -2451,16 +1857,16 @@ void ScCompiler::CheckTabQuotes( String& rString, //--------------------------------------------------------------------------- -void ScCompiler::SetRefConvention( ScAddress::Convention eConv ) +void ScCompiler::SetRefConvention( FormulaGrammar::AddressConvention eConv ) { switch ( eConv ) { - case ScAddress::CONV_UNSPECIFIED : + case FormulaGrammar::CONV_UNSPECIFIED : break; default : - case ScAddress::CONV_OOO : SetRefConvention( pConvOOO_A1 ); break; - case ScAddress::CONV_ODF : SetRefConvention( pConvOOO_A1_ODF ); break; - case ScAddress::CONV_XL_A1 : SetRefConvention( pConvXL_A1 ); break; - case ScAddress::CONV_XL_R1C1 : SetRefConvention( pConvXL_R1C1 ); break; + case FormulaGrammar::CONV_OOO : SetRefConvention( pConvOOO_A1 ); break; + case FormulaGrammar::CONV_ODF : SetRefConvention( pConvOOO_A1_ODF ); break; + case FormulaGrammar::CONV_XL_A1 : SetRefConvention( pConvXL_A1 ); break; + case FormulaGrammar::CONV_XL_R1C1 : SetRefConvention( pConvXL_R1C1 ); break; case ScAddress::CONV_XL_OOX : SetRefConvention( pConvXL_OOX ); break; } } @@ -2468,8 +1874,8 @@ void ScCompiler::SetRefConvention( ScAddress::Convention eConv ) void ScCompiler::SetRefConvention( const ScCompiler::Convention *pConvP ) { pConv = pConvP; - meGrammar = ScGrammar::mergeToGrammar( meGrammar, pConv->meConv); - DBG_ASSERT( ScGrammar::isSupported( meGrammar), + meGrammar = FormulaGrammar::mergeToGrammar( meGrammar, pConv->meConv); + DBG_ASSERT( FormulaGrammar::isSupported( meGrammar), "ScCompiler::SetRefConvention: unsupported grammar resulting"); } @@ -3049,7 +2455,7 @@ Label_MaskStateMachine: BOOL ScCompiler::IsOpCode( const String& rName, bool bInArray ) { - ScOpCodeHashMap::const_iterator iLook( mxSymbols->getHashMap()->find( rName)); + OpCodeHashMap::const_iterator iLook( mxSymbols->getHashMap()->find( rName)); BOOL bFound = (iLook != mxSymbols->getHashMap()->end()); if (bFound) { @@ -3071,7 +2477,7 @@ BOOL ScCompiler::IsOpCode( const String& rName, bool bInArray ) if (mxSymbols->hasExternals()) { // If symbols are set by filters get mapping to exact name. - ScExternalHashMap::const_iterator iExt( + ExternalHashMap::const_iterator iExt( mxSymbols->getExternalHashMap()->find( rName)); if (iExt != mxSymbols->getExternalHashMap()->end()) { @@ -3807,7 +3213,7 @@ BOOL ScCompiler::IsColRowName( const String& rName ) BOOL ScCompiler::IsBoolean( const String& rName ) { - ScOpCodeHashMap::const_iterator iLook( mxSymbols->getHashMap()->find( rName ) ); + OpCodeHashMap::const_iterator iLook( mxSymbols->getHashMap()->find( rName ) ); if( iLook != mxSymbols->getHashMap()->end() && ((*iLook).second == ocTrue || (*iLook).second == ocFalse) ) @@ -4032,7 +3438,7 @@ BOOL ScCompiler::NextNewToken( bool bInArray ) { aToken.SetOpCode( ocSpaces ); aToken.sbyte.cByte = (BYTE) ( nSpaces > 255 ? 255 : nSpaces ); - if( !pArr->AddToken( aToken ) ) + if( !static_cast<ScTokenArray*>(pArr)->AddRawToken( aToken ) ) { SetError(errCodeOverflow); return FALSE; } @@ -4045,7 +3451,7 @@ BOOL ScCompiler::NextNewToken( bool bInArray ) { /* TODO: it would be nice to generate a #REF! error here, which * would need an ocBad token with additional error value. - * ScErrorToken wouldn't do because we want to preserve the + * FormulaErrorToken wouldn't do because we want to preserve the * original string containing partial valid address * information. */ aToken.SetString( aStr.GetBuffer() ); @@ -4177,7 +3583,7 @@ ScTokenArray* ScCompiler::CompileString( const String& rFormula ) short nPar; }; // FunctionStack only used if PODF! - bool bPODF = ScGrammar::isPODF( meGrammar); + bool bPODF = FormulaGrammar::isPODF( meGrammar); const size_t nAlloc = 512; FunctionStack aFuncs[ nAlloc ]; FunctionStack* pFunctionStack = (bPODF && rFormula.Len() > nAlloc ? @@ -4274,7 +3680,7 @@ ScTokenArray* ScCompiler::CompileString( const String& rFormula ) { // FIXME: should we check for known functions with optional empty // args so the correction dialog can do better? - if ( !pArr->Add( new ScMissingToken ) ) + if ( !static_cast<ScTokenArray*>(pArr)->Add( new FormulaMissingToken ) ) { SetError(errCodeOverflow); break; } @@ -4288,22 +3694,22 @@ ScTokenArray* ScCompiler::CompileString( const String& rFormula ) pFunctionStack[ nFunction ].eOp == ocAddress && pFunctionStack[ nFunction ].nPar == 3) { - if (!pArr->Add( new ScOpToken( ocSep, svSep)) || - !pArr->Add( new ScDoubleToken( 1.0))) + if (!static_cast<ScTokenArray*>(pArr)->Add( new FormulaToken( svSep,ocSep)) || + !static_cast<ScTokenArray*>(pArr)->Add( new FormulaDoubleToken( 1.0))) { SetError(errCodeOverflow); break; } ++pFunctionStack[ nFunction ].nPar; } } - ScToken* pNewToken = pArr->Add( pRawToken->CreateToken()); + FormulaToken* pNewToken = static_cast<ScTokenArray*>(pArr)->Add( pRawToken->CreateToken()); if (!pNewToken) { SetError(errCodeOverflow); break; } else if (eLastOp == ocRange && pNewToken->GetOpCode() == ocPush && pNewToken->GetType() == svSingleRef) - pArr->MergeRangeReference( aPos); + static_cast<ScTokenArray*>(pArr)->MergeRangeReference( aPos); eLastOp = pRawToken->GetOpCode(); if ( bAutoCorrect ) aCorrectedFormula += aCorrectedSymbol; @@ -4312,7 +3718,7 @@ ScTokenArray* ScCompiler::CompileString( const String& rFormula ) { if( bInArray ) { - ScByteToken aToken( ocArrayClose ); + FormulaByteToken aToken( ocArrayClose ); if( !pArr->AddToken( aToken ) ) { SetError(errCodeOverflow); @@ -4321,7 +3727,7 @@ ScTokenArray* ScCompiler::CompileString( const String& rFormula ) aCorrectedFormula += mxSymbols->getSymbol(ocArrayClose); } - ScByteToken aToken( ocClose ); + FormulaByteToken aToken( ocClose ); while( nBrackets-- ) { if( !pArr->AddToken( aToken ) ) @@ -4339,1146 +3745,140 @@ ScTokenArray* ScCompiler::CompileString( const String& rFormula ) delete [] pFunctionStack; // remember pArr, in case a subsequent CompileTokenArray() is executed. - return pArr = new ScTokenArray( aArr ); + ScTokenArray* pNew = new ScTokenArray( aArr ); + pArr = pNew; + return pNew; } -void ScCompiler::PushTokenArray( ScTokenArray* pa, BOOL bTemp ) -{ - if ( bAutoCorrect && !pStack ) - { // #61426# don't merge stacked subroutine code into entered formula - aCorrectedFormula += aCorrectedSymbol; - aCorrectedSymbol.Erase(); - } - ScArrayStack* p = new ScArrayStack; - p->pNext = pStack; - p->pArr = pArr; - p->bTemp = bTemp; - pStack = p; - pArr = pa; -} -void ScCompiler::PopTokenArray() +BOOL ScCompiler::HandleRange() { - if( pStack ) - { - ScArrayStack* p = pStack; - pStack = p->pNext; - p->pArr->nRefs = sal::static_int_cast<short>( p->pArr->nRefs + pArr->nRefs ); - // obtain special RecalcMode from SharedFormula - if ( pArr->IsRecalcModeAlways() ) - p->pArr->SetRecalcModeAlways(); - else if ( !pArr->IsRecalcModeNormal() && p->pArr->IsRecalcModeNormal() ) - p->pArr->SetMaskedRecalcMode( pArr->GetRecalcMode() ); - p->pArr->SetCombinedBitsRecalcMode( pArr->GetRecalcMode() ); - if( p->bTemp ) - delete pArr; - pArr = p->pArr; - delete p; - } -} - -BOOL ScCompiler::GetToken() -{ - static const short nRecursionMax = 42; - ScCompilerRecursionGuard aRecursionGuard( nRecursion ); - if ( nRecursion > nRecursionMax ) - { - SetError( errStackOverflow ); - pToken = new ScByteToken( ocStop ); - return FALSE; - } - if ( bAutoCorrect && !pStack ) - { // #61426# don't merge stacked subroutine code into entered formula - aCorrectedFormula += aCorrectedSymbol; - aCorrectedSymbol.Erase(); - } - BOOL bStop = FALSE; - if( pArr->GetCodeError() && !bIgnoreErrors ) - bStop = TRUE; - else + ScRangeData* pRangeData = pDoc->GetRangeName()->FindIndex( pToken->GetIndex() ); + if (pRangeData) { - short nWasColRowName; - if ( pArr->nIndex - && pArr->pCode[ pArr->nIndex-1 ]->GetOpCode() == ocColRowName ) - nWasColRowName = 1; - else - nWasColRowName = 0; - pToken = pArr->Next(); - while( pToken && pToken->GetOpCode() == ocSpaces ) - { - if ( nWasColRowName ) - nWasColRowName++; - if ( bAutoCorrect && !pStack ) - CreateStringFromToken( aCorrectedFormula, pToken, FALSE ); - pToken = pArr->Next(); - } - if ( bAutoCorrect && !pStack && pToken ) - CreateStringFromToken( aCorrectedSymbol, pToken, FALSE ); - if( !pToken ) - { - if( pStack ) - { - PopTokenArray(); - return GetToken(); - } - else - bStop = TRUE; - } - else - { - if ( nWasColRowName >= 2 && pToken->GetOpCode() == ocColRowName ) - { // convert an ocSpaces to ocIntersect in RPN - pToken = new ScByteToken( ocIntersect ); - pArr->nIndex--; // we advanced to the second ocColRowName, step back - } - } - } - if( bStop ) - { - pToken = new ScByteToken( ocStop ); - return FALSE; - } - if( pToken->GetOpCode() == ocSubTotal ) - glSubTotal = TRUE; - else if ( pToken->GetOpCode() == ocExternalRef ) - { - // Handle external range names. - switch (pToken->GetType()) - { - case svExternalSingleRef: - case svExternalDoubleRef: - pArr->nRefs++; - break; - case svExternalName: - { - ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager(); - const String* pFile = pRefMgr->getExternalFileName(pToken->GetIndex()); - if (!pFile) - { - SetError(errNoName); - return true; - } - - const String& rName = pToken->GetString(); - ScExternalRefCache::TokenArrayRef xNew = pRefMgr->getRangeNameTokens( - pToken->GetIndex(), rName, &aPos); - - if (!xNew) - { - SetError(errNoName); - return true; - } - - ScTokenArray* pNew = xNew->Clone(); - PushTokenArray( pNew, true); - if (pNew->GetNextReference() != NULL) - { - SetRelNameReference(); - MoveRelWrap(); - } - pNew->Reset(); - return GetToken(); - } - //break; // unreachable, prevent compiler warning - default: - DBG_ERROR1( "ScCompiler::GetToken: unhandled ocExternalRef type %d", pToken->GetType()); - } - } - else if( pToken->GetOpCode() == ocName ) - { - ScRangeData* pRangeData = pDoc->GetRangeName()->FindIndex( pToken->GetIndex() ); - if (pRangeData) + USHORT nErr = pRangeData->GetErrCode(); + if( nErr ) + SetError( errNoName ); + else if ( !bCompileForFAP ) { - USHORT nErr = pRangeData->GetErrCode(); - if( nErr ) - SetError( errNoName ); - else if ( !bCompileForFAP ) + ScTokenArray* pNew; + // #35168# put named formula into parentheses. + // #37680# But only if there aren't any yet, parenthetical + // ocSep doesn't work, e.g. SUM((...;...)) + // or if not directly between ocSep/parenthesis, + // e.g. SUM(...;(...;...)) no, SUM(...;(...)*3) yes, + // in short: if it isn't a self-contained expression. + FormulaToken* p1 = pArr->PeekPrevNoSpaces(); + FormulaToken* p2 = pArr->PeekNextNoSpaces(); + OpCode eOp1 = (p1 ? p1->GetOpCode() : static_cast<OpCode>( ocSep ) ); + OpCode eOp2 = (p2 ? p2->GetOpCode() : static_cast<OpCode>( ocSep ) ); + BOOL bBorder1 = (eOp1 == ocSep || eOp1 == ocOpen); + BOOL bBorder2 = (eOp2 == ocSep || eOp2 == ocClose); + BOOL bAddPair = !(bBorder1 && bBorder2); + if ( bAddPair ) { - ScTokenArray* pNew; - // #35168# put named formula into parentheses. - // #37680# But only if there aren't any yet, parenthetical - // ocSep doesn't work, e.g. SUM((...;...)) - // or if not directly between ocSep/parenthesis, - // e.g. SUM(...;(...;...)) no, SUM(...;(...)*3) yes, - // in short: if it isn't a self-contained expression. - ScToken* p1 = pArr->PeekPrevNoSpaces(); - ScToken* p2 = pArr->PeekNextNoSpaces(); - OpCode eOp1 = (p1 ? p1->GetOpCode() : static_cast<OpCode>( ocSep ) ); - OpCode eOp2 = (p2 ? p2->GetOpCode() : static_cast<OpCode>( ocSep ) ); - BOOL bBorder1 = (eOp1 == ocSep || eOp1 == ocOpen); - BOOL bBorder2 = (eOp2 == ocSep || eOp2 == ocClose); - BOOL bAddPair = !(bBorder1 && bBorder2); - if ( bAddPair ) - { - pNew = new ScTokenArray; - pNew->AddOpCode( ocClose ); - PushTokenArray( pNew, TRUE ); - pNew->Reset(); - } - pNew = pRangeData->GetCode()->Clone(); + pNew = new ScTokenArray; + pNew->AddOpCode( ocClose ); PushTokenArray( pNew, TRUE ); - if( pRangeData->HasReferences() ) - { - SetRelNameReference(); - MoveRelWrap(); - } pNew->Reset(); - if ( bAddPair ) - { - pNew = new ScTokenArray; - pNew->AddOpCode( ocOpen ); - PushTokenArray( pNew, TRUE ); - pNew->Reset(); - } - return GetToken(); - } - } - else - SetError(errNoName); - } - else if( pToken->GetOpCode() == ocColRowName ) - { - ScSingleRefData& rRef = pToken->GetSingleRef(); - rRef.CalcAbsIfRel( aPos ); - if ( !rRef.Valid() ) - { - SetError( errNoRef ); - return TRUE; - } - SCCOL nCol = rRef.nCol; - SCROW nRow = rRef.nRow; - SCTAB nTab = rRef.nTab; - ScAddress aLook( nCol, nRow, nTab ); - BOOL bColName = rRef.IsColRel(); - SCCOL nMyCol = aPos.Col(); - SCROW nMyRow = aPos.Row(); - BOOL bInList = FALSE; - BOOL bValidName = FALSE; - ScRangePairList* pRL = (bColName ? - pDoc->GetColNameRanges() : pDoc->GetRowNameRanges()); - ScRange aRange; - for ( ScRangePair* pR = pRL->First(); pR; pR = pRL->Next() ) - { - if ( pR->GetRange(0).In( aLook ) ) - { - bInList = bValidName = TRUE; - aRange = pR->GetRange(1); - if ( bColName ) - { - aRange.aStart.SetCol( nCol ); - aRange.aEnd.SetCol( nCol ); - } - else - { - aRange.aStart.SetRow( nRow ); - aRange.aEnd.SetRow( nRow ); - } - break; // for - } - } - if ( !bInList && pDoc->GetDocOptions().IsLookUpColRowNames() ) - { // automagically or created by copying and NamePos isn't in list - BOOL bString = pDoc->HasStringData( nCol, nRow, nTab ); - if ( !bString && !pDoc->GetCell( aLook ) ) - bString = TRUE; // empty cell is ok - if ( bString ) - { //! coresponds with ScInterpreter::ScColRowNameAuto() - bValidName = TRUE; - if ( bColName ) - { // ColName - SCROW nStartRow = nRow + 1; - if ( nStartRow > MAXROW ) - nStartRow = MAXROW; - SCROW nMaxRow = MAXROW; - if ( nMyCol == nCol ) - { // formula cell in same column - if ( nMyRow == nStartRow ) - { // take remainder under name cell - nStartRow++; - if ( nStartRow > MAXROW ) - nStartRow = MAXROW; - } - else if ( nMyRow > nStartRow ) - { // from name cell down to formula cell - nMaxRow = nMyRow - 1; - } - } - for ( ScRangePair* pR = pRL->First(); pR; pR = pRL->Next() ) - { // next defined ColNameRange below limits row - const ScRange& rRange = pR->GetRange(1); - if ( rRange.aStart.Col() <= nCol && nCol <= rRange.aEnd.Col() ) - { // identical column range - SCROW nTmp = rRange.aStart.Row(); - if ( nStartRow < nTmp && nTmp <= nMaxRow ) - nMaxRow = nTmp - 1; - } - } - aRange.aStart.Set( nCol, nStartRow, nTab ); - aRange.aEnd.Set( nCol, nMaxRow, nTab ); - } - else - { // RowName - SCCOL nStartCol = nCol + 1; - if ( nStartCol > MAXCOL ) - nStartCol = MAXCOL; - SCCOL nMaxCol = MAXCOL; - if ( nMyRow == nRow ) - { // formula cell in same row - if ( nMyCol == nStartCol ) - { // take remainder right from name cell - nStartCol++; - if ( nStartCol > MAXCOL ) - nStartCol = MAXCOL; - } - else if ( nMyCol > nStartCol ) - { // from name cell right to formula cell - nMaxCol = nMyCol - 1; - } - } - for ( ScRangePair* pR = pRL->First(); pR; pR = pRL->Next() ) - { // next defined RowNameRange to the right limits column - const ScRange& rRange = pR->GetRange(1); - if ( rRange.aStart.Row() <= nRow && nRow <= rRange.aEnd.Row() ) - { // identical row range - SCCOL nTmp = rRange.aStart.Col(); - if ( nStartCol < nTmp && nTmp <= nMaxCol ) - nMaxCol = nTmp - 1; - } - } - aRange.aStart.Set( nStartCol, nRow, nTab ); - aRange.aEnd.Set( nMaxCol, nRow, nTab ); - } } - } - if ( bValidName ) - { - // And now the magic to distinguish between a range and a single - // cell thereof, which is picked position-dependent of the formula - // cell. If a direct neighbor is a binary operator (ocAdd, ...) a - // SingleRef matching the column/row of the formula cell is - // generated. A ocColRowName or ocIntersect as a neighbor results - // in a range. Special case: if label is valid for a single cell, a - // position independent SingleRef is generated. - BOOL bSingle = (aRange.aStart == aRange.aEnd); - BOOL bFound; - if ( bSingle ) - bFound = TRUE; - else + pNew = pRangeData->GetCode()->Clone(); + PushTokenArray( pNew, TRUE ); + if( pRangeData->HasReferences() ) { - ScToken* p1 = pArr->PeekPrevNoSpaces(); - ScToken* p2 = pArr->PeekNextNoSpaces(); - // begin/end of a formula => single - OpCode eOp1 = p1 ? p1->GetOpCode() : static_cast<OpCode>( ocAdd ); - OpCode eOp2 = p2 ? p2->GetOpCode() : static_cast<OpCode>( ocAdd ); - if ( eOp1 != ocColRowName && eOp1 != ocIntersect - && eOp2 != ocColRowName && eOp2 != ocIntersect ) - { - if ( (SC_OPCODE_START_BIN_OP <= eOp1 && eOp1 < SC_OPCODE_STOP_BIN_OP) || - (SC_OPCODE_START_BIN_OP <= eOp2 && eOp2 < SC_OPCODE_STOP_BIN_OP)) - bSingle = TRUE; - } - if ( bSingle ) - { // column and/or row must match range - if ( bColName ) - { - bFound = (aRange.aStart.Row() <= nMyRow - && nMyRow <= aRange.aEnd.Row()); - if ( bFound ) - aRange.aStart.SetRow( nMyRow ); - } - else - { - bFound = (aRange.aStart.Col() <= nMyCol - && nMyCol <= aRange.aEnd.Col()); - if ( bFound ) - aRange.aStart.SetCol( nMyCol ); - } - } - else - bFound = TRUE; + SetRelNameReference(); + MoveRelWrap(); } - if ( !bFound ) - SetError(errNoRef); - else if ( !bCompileForFAP ) + pNew->Reset(); + if ( bAddPair ) { - ScTokenArray* pNew = new ScTokenArray; - if ( bSingle ) - { - ScSingleRefData aRefData; - aRefData.InitAddress( aRange.aStart ); - if ( bColName ) - aRefData.SetColRel( TRUE ); - else - aRefData.SetRowRel( TRUE ); - aRefData.CalcRelFromAbs( aPos ); - pNew->AddSingleReference( aRefData ); - } - else - { - ScComplexRefData aRefData; - aRefData.InitRange( aRange ); - if ( bColName ) - { - aRefData.Ref1.SetColRel( TRUE ); - aRefData.Ref2.SetColRel( TRUE ); - } - else - { - aRefData.Ref1.SetRowRel( TRUE ); - aRefData.Ref2.SetRowRel( TRUE ); - } - aRefData.CalcRelFromAbs( aPos ); - if ( bInList ) - pNew->AddDoubleReference( aRefData ); - else - { // automagically - pNew->Add( new ScDoubleRefOpToken( ocColRowNameAuto, - aRefData ) ); - } - } + pNew = new ScTokenArray; + pNew->AddOpCode( ocOpen ); PushTokenArray( pNew, TRUE ); pNew->Reset(); - return GetToken(); } - } - else - SetError(errNoName); - } - else if( pToken->GetOpCode() == ocDBArea ) - { - ScDBData* pDBData = pDoc->GetDBCollection()->FindIndex( pToken->GetIndex() ); - if ( !pDBData ) - SetError(errNoName); - else if ( !bCompileForFAP ) - { - ScComplexRefData aRefData; - aRefData.InitFlags(); - pDBData->GetArea( (SCTAB&) aRefData.Ref1.nTab, - (SCCOL&) aRefData.Ref1.nCol, - (SCROW&) aRefData.Ref1.nRow, - (SCCOL&) aRefData.Ref2.nCol, - (SCROW&) aRefData.Ref2.nRow); - aRefData.Ref2.nTab = aRefData.Ref1.nTab; - aRefData.CalcRelFromAbs( aPos ); - ScTokenArray* pNew = new ScTokenArray; - pNew->AddDoubleReference( aRefData ); - PushTokenArray( pNew, TRUE ); - pNew->Reset(); return GetToken(); } } - else if( pToken->GetType() == svSingleRef ) - { -// if (!pDoc->HasTable( pToken->aRef.Ref1.nTab ) ) -// SetError(errNoRef); - pArr->nRefs++; - } - else if( pToken->GetType() == svDoubleRef ) - { -// if (!pDoc->HasTable( pToken->aRef.Ref1.nTab ) || -// !pDoc->HasTable( pToken->aRef.Ref2.nTab )) -// SetError(errNoRef); - pArr->nRefs++; - } + else + SetError(errNoName); return TRUE; } - -OpCode ScCompiler::NextToken() +// ----------------------------------------------------------------------------- +BOOL ScCompiler::HandleExternalReference(const FormulaToken& _aToken) { - if( !GetToken() ) - return ocStop; - OpCode eOp = pToken->GetOpCode(); - // There must be an operator before a push - if ( (eOp == ocPush || eOp == ocColRowNameAuto) && - !( (eLastOp == ocOpen) || (eLastOp == ocSep) || - (SC_OPCODE_START_BIN_OP <= eLastOp && eLastOp < SC_OPCODE_STOP_UN_OP)) ) - SetError(errOperatorExpected); - // Operator and Plus => operator - if (eOp == ocAdd && (eLastOp == ocOpen || eLastOp == ocSep || - (SC_OPCODE_START_BIN_OP <= eLastOp && eLastOp < SC_OPCODE_STOP_UN_OP))) - eOp = NextToken(); - else + // Handle external range names. + switch (_aToken.GetType()) { - // Before an operator there must not be another operator, with the - // exception of AND and OR. - if ( eOp != ocAnd && eOp != ocOr && - (SC_OPCODE_START_BIN_OP <= eOp && eOp < SC_OPCODE_STOP_BIN_OP ) - && (eLastOp == ocOpen || eLastOp == ocSep || - (SC_OPCODE_START_BIN_OP <= eLastOp && eLastOp < SC_OPCODE_STOP_UN_OP))) + case svExternalSingleRef: + case svExternalDoubleRef: + pArr->nRefs++; + break; + case svExternalName: { - SetError(errVariableExpected); - if ( bAutoCorrect && !pStack ) + ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager(); + const String* pFile = pRefMgr->getExternalFileName(_aToken.GetIndex()); + if (!pFile) { - if ( eOp == eLastOp || eLastOp == ocOpen ) - { // throw away duplicated operator - aCorrectedSymbol.Erase(); - bCorrected = TRUE; - } - else - { - xub_StrLen nPos = aCorrectedFormula.Len(); - if ( nPos ) - { - nPos--; - sal_Unicode c = aCorrectedFormula.GetChar( nPos ); - switch ( eOp ) - { // swap operators - case ocGreater: - if ( c == mxSymbols->getSymbol(ocEqual).GetChar(0) ) - { // >= instead of => - aCorrectedFormula.SetChar( nPos, - mxSymbols->getSymbol(ocGreater).GetChar(0) ); - aCorrectedSymbol = c; - bCorrected = TRUE; - } - break; - case ocLess: - if ( c == mxSymbols->getSymbol(ocEqual).GetChar(0) ) - { // <= instead of =< - aCorrectedFormula.SetChar( nPos, - mxSymbols->getSymbol(ocLess).GetChar(0) ); - aCorrectedSymbol = c; - bCorrected = TRUE; - } - else if ( c == mxSymbols->getSymbol(ocGreater).GetChar(0) ) - { // <> instead of >< - aCorrectedFormula.SetChar( nPos, - mxSymbols->getSymbol(ocLess).GetChar(0) ); - aCorrectedSymbol = c; - bCorrected = TRUE; - } - break; - case ocMul: - if ( c == mxSymbols->getSymbol(ocSub).GetChar(0) ) - { // *- instead of -* - aCorrectedFormula.SetChar( nPos, - mxSymbols->getSymbol(ocMul).GetChar(0) ); - aCorrectedSymbol = c; - bCorrected = TRUE; - } - break; - case ocDiv: - if ( c == mxSymbols->getSymbol(ocSub).GetChar(0) ) - { // /- instead of -/ - aCorrectedFormula.SetChar( nPos, - mxSymbols->getSymbol(ocDiv).GetChar(0) ); - aCorrectedSymbol = c; - bCorrected = TRUE; - } - break; - default: - ; // nothing - } - } - } + SetError(errNoName); + return true; } - } - eLastOp = eOp; - } - return eOp; -} - -//--------------------------------------------------------------------------- - -BOOL ScCompiler::CompileTokenArray() -{ - glSubTotal = FALSE; - bCorrected = FALSE; - if( !pArr->GetCodeError() || bIgnoreErrors ) - { - if ( bAutoCorrect ) - { - aCorrectedFormula.Erase(); - aCorrectedSymbol.Erase(); - } - pArr->nRefs = 0; // count from start - pArr->DelRPN(); - pStack = NULL; - ScToken* pData[ MAXCODE ]; - pCode = pData; - BOOL bWasForced = pArr->IsRecalcModeForced(); - if ( bWasForced ) - { - if ( bAutoCorrect ) - aCorrectedFormula = '='; - } - pArr->ClearRecalcMode(); - pArr->Reset(); - eLastOp = ocOpen; - pc = 0; - NextToken(); - OpCode eOp = Expression(); - // Some trailing garbage that doesn't form an expression? - if (eOp != ocStop) - SetError( errOperatorExpected); - - USHORT nErrorBeforePop = pArr->GetCodeError(); - - while( pStack ) - PopTokenArray(); - if( pc ) - { - pArr->pRPN = new ScToken*[ pc ]; - pArr->nRPN = pc; - memcpy( pArr->pRPN, pData, pc * sizeof( ScToken* ) ); - } - // once an error, always an error - if( !pArr->GetCodeError() && nErrorBeforePop ) - pArr->SetCodeError( nErrorBeforePop); + const String& rName = _aToken.GetString(); + ScExternalRefCache::TokenArrayRef xNew = pRefMgr->getRangeNameTokens( + _aToken.GetIndex(), rName, &aPos); - if( pArr->GetCodeError() && !bIgnoreErrors ) - { - pArr->DelRPN(); - pArr->SetHyperLink(FALSE); - } - - if ( bWasForced ) - pArr->SetRecalcModeForced(); - } - if( nNumFmt == NUMBERFORMAT_UNDEFINED ) - nNumFmt = NUMBERFORMAT_NUMBER; - return glSubTotal; -} - -//--------------------------------------------------------------------------- -// Append token to RPN code -//--------------------------------------------------------------------------- - -void ScCompiler::PutCode( ScTokenRef& p ) -{ - if( pc >= MAXCODE-1 ) - { - if ( pc == MAXCODE-1 ) - { - p = new ScByteToken( ocStop ); - p->IncRef(); - *pCode++ = p; - ++pc; - } - SetError(errCodeOverflow); - return; - } - if( pArr->GetCodeError() && !bCompileForFAP ) - return; - ForceArrayOperator( p, pCurrentFactorToken); - p->IncRef(); - *pCode++ = p; - pc++; -} - -//----------------------------------------------------------------------------- - -bool ScCompiler::MergeRangeReference( - ScToken * * const pCode1, ScToken * const * const pCode2 ) -{ - ScToken *p1, *p2; - if (pc < 2 || !pCode1 || !pCode2 || - (pCode2 - pCode1 != 1) || (pCode - pCode2 != 1) || - ((p1 = *pCode1) == 0) || ((p2 = *pCode2) == 0) ) - return false; - - ScTokenRef p = ScToken::ExtendRangeReference( *p1, *p2, aPos, true); - if (!p) - return false; - - p->IncRef(); - p1->DecRef(); - p2->DecRef(); - *pCode1 = p; - --pCode, --pc; - pArr->nRefs--; - - return true; -} - -//--------------------------------------------------------------------------- -// RPN creation by recursion -//--------------------------------------------------------------------------- - -void ScCompiler::Factor() -{ - if ( pArr->GetCodeError() && !bIgnoreErrors ) - return; - - CurrentFactor pFacToken( this ); - - OpCode eOp = pToken->GetOpCode(); - if( eOp == ocPush || eOp == ocColRowNameAuto || eOp == ocMatRef || - eOp == ocDBArea - || (bCompileForFAP && ((eOp == ocName) || (eOp == ocDBArea) - || (eOp == ocColRowName) || (eOp == ocBad))) - ) - { - PutCode( pToken ); - eOp = NextToken(); - if( eOp == ocOpen ) - { - // PUSH( is an error that may be caused by an unknown function. - SetError( - ( pToken->GetType() == svString - || pToken->GetType() == svSingleRef ) - ? errNoName : errOperatorExpected ); - if ( bAutoCorrect && !pStack ) - { // assume multiplication - aCorrectedFormula += mxSymbols->getSymbol(ocMul); - bCorrected = TRUE; - NextToken(); - eOp = Expression(); - if( eOp != ocClose ) - SetError(errPairExpected); - else - eOp = NextToken(); - } - } - } - else if( eOp == ocOpen ) - { - NextToken(); - eOp = Expression(); - while ((eOp == ocSep) && (!pArr->GetCodeError() || bIgnoreErrors)) - { // range list (A1;A2) converted to (A1~A2) - pFacToken = pToken; - NextToken(); - eOp = Expression(); - // Do not ignore error here, regardless of bIgnoreErrors, otherwise - // errors like =(1;) would also result in display of =(1~) - if (!pArr->GetCodeError()) + if (!xNew) { - ScOpToken* pOT = dynamic_cast<ScOpToken*>(pFacToken.operator->()); - DBG_ASSERT( pOT, "ScCompiler::Factor: not a ScOpToken for NewOpCode()"); - if (pOT) - pOT->NewOpCode( ocUnion); - PutCode( pFacToken); - } - } - if (eOp != ocClose) - SetError(errPairExpected); - else - eOp = NextToken(); - } - else - { - if( nNumFmt == NUMBERFORMAT_UNDEFINED ) - nNumFmt = lcl_GetRetFormat( eOp ); - // Functions that have to be always recalculated - switch( eOp ) - { - // no parameters: - case ocRandom: - case ocGetActDate: - case ocGetActTime: - // one parameter: - case ocFormula: - case ocInfo: - // more than one parameters: - // ocIndirect/ocIndirectXL otherwise would have to do - // StopListening and StartListening on a reference for every - // interpreted value. - case ocIndirect: - case ocIndirectXL: - // ocOffset results in indirect references. - case ocOffset: - pArr->SetRecalcModeAlways(); - break; - // Functions recalculated on every document load. - // Don't use SetRecalcModeOnLoad() which would override - // ModeAlways. - case ocConvert : - pArr->AddRecalcMode( RECALCMODE_ONLOAD ); - break; - // If the referred cell is moved the value changes. - case ocColumn : - case ocRow : - // ocCell needs recalc on move for some possible type values. - case ocCell : - pArr->SetRecalcModeOnRefMove(); - break; - case ocHyperLink : - pArr->SetHyperLink(TRUE); - break; - default: - ; // nothing - } - if (SC_OPCODE_START_NO_PAR <= eOp && eOp < SC_OPCODE_STOP_NO_PAR) - { - pFacToken = pToken; - eOp = NextToken(); - if (eOp != ocOpen) - { - SetError(errPairExpected); - PutCode( pFacToken ); - } - else - { - eOp = NextToken(); - if (eOp != ocClose) - SetError(errPairExpected); - PutCode(pFacToken); - eOp = NextToken(); - } - } - // special cases NOT() and NEG() - else if( eOp == ocNot || eOp == ocNeg - || (SC_OPCODE_START_1_PAR <= eOp && eOp < SC_OPCODE_STOP_1_PAR) ) - { - pFacToken = pToken; - eOp = NextToken(); - if( nNumFmt == NUMBERFORMAT_UNDEFINED && eOp == ocNot ) - nNumFmt = NUMBERFORMAT_LOGICAL; - if (eOp == ocOpen) - { - NextToken(); - eOp = Expression(); - } - else - SetError(errPairExpected); - if (eOp != ocClose) - SetError(errPairExpected); - else if ( !pArr->GetCodeError() ) - pFacToken->SetByte( 1 ); - PutCode( pFacToken ); - eOp = NextToken(); - } - else if ((SC_OPCODE_START_2_PAR <= eOp && eOp < SC_OPCODE_STOP_2_PAR) - || eOp == ocExternal - || eOp == ocMacro - || eOp == ocAnd - || eOp == ocOr - || eOp == ocBad - || ( eOp >= ocInternalBegin && eOp <= ocInternalEnd ) - || (bCompileForFAP && ((eOp == ocIf) || (eOp == ocChose))) - ) - { - pFacToken = pToken; - OpCode eMyLastOp = eOp; - eOp = NextToken(); - bool bNoParam = false; - bool bBadName = false; - if (eOp == ocOpen) - { - eOp = NextToken(); - if (eOp == ocClose) - bNoParam = true; - else - eOp = Expression(); - } - else if (eMyLastOp == ocBad) - { - // Just a bad name, not an unknown function, no parameters, no - // closing expected. - bBadName = true; - bNoParam = true; - } - else - SetError(errPairExpected); - BYTE nSepCount = 0; - if( !bNoParam ) - { - nSepCount++; - while ( (eOp == ocSep) && (!pArr->GetCodeError() || bIgnoreErrors) ) - { - nSepCount++; - NextToken(); - eOp = Expression(); - } - } - if (bBadName) - ; // nothing, keep current token for return - else if (eOp != ocClose) - SetError(errPairExpected); - else - eOp = NextToken(); - // Jumps are just normal functions for the FunctionAutoPilot tree view - if ( bCompileForFAP && pFacToken->GetType() == svJump ) - pFacToken = new ScFAPToken( pFacToken->GetOpCode(), nSepCount, pFacToken ); - else - pFacToken->SetByte( nSepCount ); - PutCode( pFacToken ); - } - else if (eOp == ocIf || eOp == ocChose) - { - // the PC counters are -1 - pFacToken = pToken; - if ( eOp == ocIf ) - pFacToken->GetJump()[ 0 ] = 3; // if, else, behind - else - pFacToken->GetJump()[ 0 ] = MAXJUMPCOUNT+1; - eOp = NextToken(); - if (eOp == ocOpen) - { - NextToken(); - eOp = Expression(); - } - else - SetError(errPairExpected); - short nJumpCount = 0; - PutCode( pFacToken ); - // #36253# during AutoCorrect (since pArr->GetCodeError() is - // ignored) an unlimited ocIf would crash because - // ScRawToken::Clone() allocates the JumpBuffer according to - // nJump[0]*2+2, which is 3*2+2 on ocIf. - const short nJumpMax = - (pFacToken->GetOpCode() == ocIf ? 3 : MAXJUMPCOUNT); - while ( (nJumpCount < (MAXJUMPCOUNT - 1)) && (eOp == ocSep) - && (!pArr->GetCodeError() || bIgnoreErrors) ) - { - if ( ++nJumpCount <= nJumpMax ) - pFacToken->GetJump()[nJumpCount] = pc-1; - NextToken(); - eOp = Expression(); - // ocSep or ocClose terminate the subexpression - PutCode( pToken ); - } - if (eOp != ocClose) - SetError(errPairExpected); - else - { - eOp = NextToken(); - // always limit to nJumpMax, no arbitrary overwrites - if ( ++nJumpCount <= nJumpMax ) - pFacToken->GetJump()[ nJumpCount ] = pc-1; - if ((pFacToken->GetOpCode() == ocIf && (nJumpCount > 3)) || - (nJumpCount >= MAXJUMPCOUNT)) - SetError(errIllegalParameter); - else - pFacToken->GetJump()[ 0 ] = nJumpCount; - } - } - else if ( eOp == ocMissing ) - { - PutCode( pToken ); - eOp = NextToken(); - } - else if ( eOp == ocClose ) - { - SetError( errParameterExpected ); - } - else if ( eOp == ocSep ) - { // Subsequent ocSep - SetError( errParameterExpected ); - if ( bAutoCorrect && !pStack ) - { - aCorrectedSymbol.Erase(); - bCorrected = TRUE; + SetError(errNoName); + return true; } - } - else if ( eOp == ocExternalRef ) - { - PutCode(pToken); - eOp = NextToken(); - } - else - { - SetError( errUnknownToken ); - if ( bAutoCorrect && !pStack ) + + ScTokenArray* pNew = xNew->Clone(); + PushTokenArray( pNew, true); + if (pNew->GetNextReference() != NULL) { - if ( eOp == ocStop ) - { // trailing operator w/o operand - xub_StrLen nLen = aCorrectedFormula.Len(); - if ( nLen ) - aCorrectedFormula.Erase( nLen - 1 ); - aCorrectedSymbol.Erase(); - bCorrected = TRUE; - } + SetRelNameReference(); + MoveRelWrap(); } + pNew->Reset(); + return GetToken(); } + default: + DBG_ERRROR("Wrong type for external reference!"); + return FALSE; } + return TRUE; } -//--------------------------------------------------------------------------- - -void ScCompiler::RangeLine() -{ - Factor(); - while (pToken->GetOpCode() == ocRange) - { - ScToken** pCode1 = pCode - 1; - ScTokenRef p = pToken; - NextToken(); - Factor(); - ScToken** pCode2 = pCode - 1; - if (!MergeRangeReference( pCode1, pCode2)) - PutCode(p); - } -} - -//--------------------------------------------------------------------------- - -void ScCompiler::UnionLine() -{ - RangeLine(); - while (pToken->GetOpCode() == ocUnion) - { - ScTokenRef p = pToken; - NextToken(); - RangeLine(); - PutCode(p); - } -} - -//--------------------------------------------------------------------------- - -void ScCompiler::IntersectionLine() -{ - UnionLine(); - while (pToken->GetOpCode() == ocIntersect) - { - ScTokenRef p = pToken; - NextToken(); - UnionLine(); - PutCode(p); - } -} - -//--------------------------------------------------------------------------- - -void ScCompiler::UnaryLine() -{ - if( pToken->GetOpCode() == ocAdd ) - GetToken(); - else if (SC_OPCODE_START_UN_OP <= pToken->GetOpCode() && - pToken->GetOpCode() < SC_OPCODE_STOP_UN_OP) - { - ScTokenRef p = pToken; - NextToken(); - UnaryLine(); - PutCode( p ); - } - else - IntersectionLine(); -} - -//--------------------------------------------------------------------------- - -void ScCompiler::PostOpLine() -{ - UnaryLine(); - while ( pToken->GetOpCode() == ocPercentSign ) - { // this operator _follows_ its operand - PutCode( pToken ); - NextToken(); - } -} //--------------------------------------------------------------------------- -void ScCompiler::PowLine() -{ - PostOpLine(); - while (pToken->GetOpCode() == ocPow) - { - ScTokenRef p = pToken; - NextToken(); - PostOpLine(); - PutCode(p); - } -} //--------------------------------------------------------------------------- - -void ScCompiler::MulDivLine() -{ - PowLine(); - while (pToken->GetOpCode() == ocMul || pToken->GetOpCode() == ocDiv) - { - ScTokenRef p = pToken; - NextToken(); - PowLine(); - PutCode(p); - } -} - +// Append token to RPN code //--------------------------------------------------------------------------- -void ScCompiler::AddSubLine() -{ - MulDivLine(); - while (pToken->GetOpCode() == ocAdd || pToken->GetOpCode() == ocSub) - { - ScTokenRef p = pToken; - NextToken(); - MulDivLine(); - PutCode(p); - } -} - -//--------------------------------------------------------------------------- -void ScCompiler::ConcatLine() -{ - AddSubLine(); - while (pToken->GetOpCode() == ocAmpersand) - { - ScTokenRef p = pToken; - NextToken(); - AddSubLine(); - PutCode(p); - } -} +//----------------------------------------------------------------------------- //--------------------------------------------------------------------------- - -void ScCompiler::CompareLine() -{ - ConcatLine(); - while (pToken->GetOpCode() >= ocEqual && pToken->GetOpCode() <= ocGreaterEqual) - { - ScTokenRef p = pToken; - NextToken(); - ConcatLine(); - PutCode(p); - } -} - +// RPN creation by recursion //--------------------------------------------------------------------------- -void ScCompiler::NotLine() -{ - CompareLine(); - while (pToken->GetOpCode() == ocNot) - { - ScTokenRef p = pToken; - NextToken(); - CompareLine(); - PutCode(p); - } -} -//--------------------------------------------------------------------------- - -OpCode ScCompiler::Expression() -{ - static const short nRecursionMax = 42; - ScCompilerRecursionGuard aRecursionGuard( nRecursion ); - if ( nRecursion > nRecursionMax ) - { - SetError( errStackOverflow ); - return ocStop; //! generate token instead? - } - NotLine(); - while (pToken->GetOpCode() == ocAnd || pToken->GetOpCode() == ocOr) - { - ScTokenRef p = pToken; - pToken->SetByte( 2 ); // 2 parameters! - NextToken(); - NotLine(); - PutCode(p); - } - return pToken->GetOpCode(); -} //----------------------------------------------------------------------------- BOOL ScCompiler::HasModifiedRange() { pArr->Reset(); - for ( ScToken* t = pArr->Next(); t; t = pArr->Next() ) + for ( FormulaToken* t = pArr->Next(); t; t = pArr->Next() ) { OpCode eOpCode = t->GetOpCode(); if ( eOpCode == ocName ) { - ScRangeData* pRangeData = pDoc->GetRangeName()->FindIndex(t->GetIndex()); + ScRangeData* pRangeData = pDoc->GetRangeName()->FindIndex(t->GetIndex()); if (pRangeData && pRangeData->IsModified()) return TRUE; @@ -5494,7 +3894,8 @@ BOOL ScCompiler::HasModifiedRange() return FALSE; } -//----------------------------------------------------------------------------- + +//--------------------------------------------------------------------------- template< typename T, typename S > S lcl_adjval( S& n, T pos, T max, BOOL bRel ) @@ -5516,8 +3917,8 @@ S lcl_adjval( S& n, T pos, T max, BOOL bRel ) void ScCompiler::SetRelNameReference() { pArr->Reset(); - for( ScToken* t = pArr->GetNextReference(); t; - t = pArr->GetNextReference() ) + for( ScToken* t = static_cast<ScToken*>(pArr->GetNextReference()); t; + t = static_cast<ScToken*>(pArr->GetNextReference()) ) { ScSingleRefData& rRef1 = t->GetSingleRef(); if ( rRef1.IsColRel() || rRef1.IsRowRel() || rRef1.IsTabRel() ) @@ -5536,8 +3937,8 @@ void ScCompiler::SetRelNameReference() void ScCompiler::MoveRelWrap() { pArr->Reset(); - for( ScToken* t = pArr->GetNextReference(); t; - t = pArr->GetNextReference() ) + for( ScToken* t = static_cast<ScToken*>(pArr->GetNextReference()); t; + t = static_cast<ScToken*>(pArr->GetNextReference()) ) { if ( t->GetType() == svSingleRef || t->GetType() == svExternalSingleRef ) ScRefUpdate::MoveRelWrap( pDoc, aPos, SingleDoubleRefModifier( t->GetSingleRef() ).Ref() ); @@ -5553,8 +3954,8 @@ void ScCompiler::MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc, const ScAddress& rPos ) { rArr.Reset(); - for( ScToken* t = rArr.GetNextReference(); t; - t = rArr.GetNextReference() ) + for( ScToken* t = static_cast<ScToken*>(rArr.GetNextReference()); t; + t = static_cast<ScToken*>(rArr.GetNextReference()) ) { if ( t->GetType() == svSingleRef || t->GetType() == svExternalSingleRef ) ScRefUpdate::MoveRelWrap( pDoc, rPos, SingleDoubleRefModifier( t->GetSingleRef() ).Ref() ); @@ -5578,8 +3979,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode, // copied header instead of the old position's new intersection. ScToken* t; pArr->Reset(); - for( t = pArr->GetNextColRowName(); t; - t = pArr->GetNextColRowName() ) + while( (t = static_cast<ScToken*>(pArr->GetNextColRowName())) != NULL ) { ScSingleRefData& rRef = t->GetSingleRef(); rRef.CalcAbsIfRel( rOldPos ); @@ -5597,12 +3997,12 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode, // Check for SharedFormulas. ScRangeData* pRangeData = NULL; pArr->Reset(); - for( t = pArr->GetNextName(); t && !pRangeData; - t = pArr->GetNextName() ) + for( FormulaToken* j = pArr->GetNextName(); j && !pRangeData; + j = pArr->GetNextName() ) { - if( t->GetOpCode() == ocName ) + if( j->GetOpCode() == ocName ) { - ScRangeData* pName = pDoc->GetRangeName()->FindIndex( t->GetIndex() ); + ScRangeData* pName = pDoc->GetRangeName()->FindIndex( j->GetIndex() ); if (pName && pName->HasType(RT_SHARED)) pRangeData = pName; } @@ -5613,8 +4013,8 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode, ScRangeData* pName = pRangeData; pRangeData = NULL; pArr->Reset(); - for( t = pArr->GetNextReferenceRPN(); t && !pRangeData; - t = pArr->GetNextReferenceRPN() ) + for( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()); t && !pRangeData; + t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) { BOOL bRelName = (t->GetType() == svSingleRef ? t->GetSingleRef().IsRelName() : @@ -5651,8 +4051,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode, ScRangeData* pRangeData = NULL; ScToken* t; pArr->Reset(); - for( t = pArr->GetNextReferenceOrName(); t; - t = pArr->GetNextReferenceOrName() ) + while( (t = static_cast<ScToken*>(pArr->GetNextReferenceOrName())) != NULL ) { if( t->GetOpCode() == ocName ) { @@ -5708,8 +4107,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode, } #endif pArr->Reset(); - for( t = pArr->GetNextReferenceRPN(); t; - t = pArr->GetNextReferenceRPN() ) + while ( (t = static_cast<ScToken*>(pArr->GetNextReferenceRPN())) != NULL ) { if ( t->GetRef() != 1 ) { @@ -5812,8 +4210,8 @@ BOOL ScCompiler::UpdateNameReference(UpdateRefMode eUpdateRefMode, BOOL bRelRef = FALSE; // set if relative reference rChanged = FALSE; pArr->Reset(); - for( ScToken* t = pArr->GetNextReference(); t; - t = pArr->GetNextReference() ) + ScToken* t; + while ( (t = static_cast<ScToken*>(pArr->GetNextReference())) != NULL ) { SingleDoubleRefModifier aMod( *t ); ScComplexRefData& rRef = aMod.Ref(); @@ -5861,8 +4259,7 @@ void ScCompiler::UpdateSharedFormulaReference( UpdateRefMode eUpdateRefMode, { ScToken* t; pArr->Reset(); - for( t = pArr->GetNextReference(); t; - t = pArr->GetNextReference() ) + while ( (t = static_cast<ScToken*>(pArr->GetNextReference())) != NULL ) { if( t->GetType() != svIndex ) // it may be a DB area!!! { @@ -5930,9 +4327,9 @@ ScRangeData* ScCompiler::UpdateInsertTab( SCTAB nTable, BOOL bIsName ) ScToken* t; pArr->Reset(); if (bIsName) - t = pArr->GetNextReference(); + t = static_cast<ScToken*>(pArr->GetNextReference()); else - t = pArr->GetNextReferenceOrName(); + t = static_cast<ScToken*>(pArr->GetNextReferenceOrName()); while( t ) { if( t->GetOpCode() == ocName ) @@ -5983,15 +4380,14 @@ ScRangeData* ScCompiler::UpdateInsertTab( SCTAB nTable, BOOL bIsName ) pRangeData = (ScRangeData*) this; // not dereferenced in rangenam } if (bIsName) - t = pArr->GetNextReference(); + t = static_cast<ScToken*>(pArr->GetNextReference()); else - t = pArr->GetNextReferenceOrName(); + t = static_cast<ScToken*>(pArr->GetNextReferenceOrName()); } if ( !bIsName ) { pArr->Reset(); - for ( t = pArr->GetNextReferenceRPN(); t; - t = pArr->GetNextReferenceRPN() ) + while ( (t = static_cast<ScToken*>(pArr->GetNextReferenceRPN())) != NULL ) { if ( t->GetRef() == 1 ) { @@ -6042,9 +4438,9 @@ ScRangeData* ScCompiler::UpdateDeleteTab(SCTAB nTable, BOOL /* bIsMove */, BOOL ScToken* t; pArr->Reset(); if (bIsName) - t = pArr->GetNextReference(); + t = static_cast<ScToken*>(pArr->GetNextReference()); else - t = pArr->GetNextReferenceOrName(); + t = static_cast<ScToken*>(pArr->GetNextReferenceOrName()); while( t ) { if( t->GetOpCode() == ocName ) @@ -6134,15 +4530,14 @@ ScRangeData* ScCompiler::UpdateDeleteTab(SCTAB nTable, BOOL /* bIsMove */, BOOL pRangeData = (ScRangeData*) this; // not dereferenced in rangenam } if (bIsName) - t = pArr->GetNextReference(); + t = static_cast<ScToken*>(pArr->GetNextReference()); else - t = pArr->GetNextReferenceOrName(); + t = static_cast<ScToken*>(pArr->GetNextReferenceOrName()); } if ( !bIsName ) { pArr->Reset(); - for ( t = pArr->GetNextReferenceRPN(); t; - t = pArr->GetNextReferenceRPN() ) + while ( (t = static_cast<ScToken*>(pArr->GetNextReferenceRPN())) != NULL ) { if ( t->GetRef() == 1 ) { @@ -6253,9 +4648,9 @@ ScRangeData* ScCompiler::UpdateMoveTab( SCTAB nOldTab, SCTAB nNewTab, ScToken* t; pArr->Reset(); if (bIsName) - t = pArr->GetNextReference(); + t = static_cast<ScToken*>(pArr->GetNextReference()); else - t = pArr->GetNextReferenceOrName(); + t = static_cast<ScToken*>(pArr->GetNextReferenceOrName()); while( t ) { if( t->GetOpCode() == ocName ) @@ -6322,16 +4717,15 @@ ScRangeData* ScCompiler::UpdateMoveTab( SCTAB nOldTab, SCTAB nNewTab, pRangeData = (ScRangeData*) this; // not dereferenced in rangenam } if (bIsName) - t = pArr->GetNextReference(); + t = static_cast<ScToken*>(pArr->GetNextReference()); else - t = pArr->GetNextReferenceOrName(); + t = static_cast<ScToken*>(pArr->GetNextReferenceOrName()); } if ( !bIsName ) { SCsTAB nMaxTabMod = (SCsTAB) pDoc->GetTableCount(); pArr->Reset(); - for ( t = pArr->GetNextReferenceRPN(); t; - t = pArr->GetNextReferenceRPN() ) + while ( (t = static_cast<ScToken*>(pArr->GetNextReferenceRPN())) != NULL ) { if ( t->GetRef() == 1 ) { @@ -6405,226 +4799,39 @@ ScRangeData* ScCompiler::UpdateMoveTab( SCTAB nOldTab, SCTAB nNewTab, } -const String& ScCompiler::GetStringFromOpCode( OpCode eOpCode ) -{ - return mxSymbolsNative->getSymbol( eOpCode ); -} - -ScToken* ScCompiler::CreateStringFromToken( String& rFormula, ScToken* pTokenP, - BOOL bAllowArrAdvance ) -{ - rtl::OUStringBuffer aBuffer; - ScToken* p = CreateStringFromToken( aBuffer, pTokenP, bAllowArrAdvance ); - rFormula += aBuffer; - return p; -} - -ScToken* ScCompiler::CreateStringFromToken( rtl::OUStringBuffer& rBuffer, ScToken* pTokenP, - BOOL bAllowArrAdvance ) +void ScCompiler::CreateStringFromExternal(rtl::OUStringBuffer& rBuffer, FormulaToken* pTokenP) { - BOOL bNext = TRUE; - BOOL bSpaces = FALSE; - ScToken* t = pTokenP; + FormulaToken* t = pTokenP; OpCode eOp = t->GetOpCode(); - if( eOp >= ocAnd && eOp <= ocOr ) - { - // AND, OR infix? - if ( bAllowArrAdvance ) - t = pArr->Next(); - else - t = pArr->PeekNext(); - bNext = FALSE; - bSpaces = ( !t || t->GetOpCode() != ocOpen ); - } - if( bSpaces ) - rBuffer.append(sal_Unicode(' ')); - - if( eOp == ocSpaces ) + ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager(); + switch (t->GetType()) { - bool bIntersectionOp = mxSymbols->isODFF(); - if (bIntersectionOp) + case svExternalName: { - const ScToken* p = pArr->PeekPrevNoSpaces(); - bIntersectionOp = (p && p->GetOpCode() == ocColRowName); - if (bIntersectionOp) - { - p = pArr->PeekNextNoSpaces(); - bIntersectionOp = (p && p->GetOpCode() == ocColRowName); - } + const String *pStr = pRefMgr->getExternalFileName(t->GetIndex()); + String aFileName = pStr ? *pStr : ScGlobal::GetRscString(STR_NO_NAME_REF); + rBuffer.append(pConv->makeExternalNameStr( aFileName, t->GetString())); } - if (bIntersectionOp) - rBuffer.appendAscii( "!!"); - else - { - // most times it's just one blank - BYTE n = t->GetByte(); - for ( BYTE j=0; j<n; ++j ) - { - rBuffer.append(sal_Unicode(' ')); - } - } - } - else if( eOp >= ocInternalBegin && eOp <= ocInternalEnd ) - rBuffer.appendAscii( pInternal[ eOp - ocInternalBegin ] ); - else if( (USHORT) eOp < mxSymbols->getSymbolCount()) // Keyword: - rBuffer.append(mxSymbols->getSymbol(eOp)); - else - { - DBG_ERRORFILE("unknown OpCode"); - rBuffer.append(ScGlobal::GetRscString(STR_NO_NAME_REF)); - } - if (bNext) - { - if (eOp == ocExternalRef) - { - ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager(); - switch (t->GetType()) - { - case svExternalName: - { - const String *pStr = pRefMgr->getExternalFileName(t->GetIndex()); - String aFileName = pStr ? *pStr : ScGlobal::GetRscString(STR_NO_NAME_REF); - rBuffer.append(pConv->makeExternalNameStr( - aFileName, t->GetString())); - } - break; - case svExternalSingleRef: - pConv->makeExternalRefStr( - rBuffer, *this, t->GetIndex(), t->GetString(), t->GetSingleRef(), pRefMgr); - break; - case svExternalDoubleRef: - pConv->makeExternalRefStr( + break; + case svExternalSingleRef: + pConv->makeExternalRefStr( + rBuffer, *this, t->GetIndex(), t->GetString(), t->GetSingleRef(), pRefMgr); + break; + case svExternalDoubleRef: + pConv->makeExternalRefStr( rBuffer, *this, t->GetIndex(), t->GetString(), t->GetDoubleRef(), pRefMgr); - break; - default: - // warning, not error, otherwise we may end up with a never - // ending message box loop if this was the cursor cell to be redrawn. - DBG_WARNING("ScCompiler::CreateStringFromToken: unknown type of ocExternalRef"); - } - } - else - { - switch( t->GetType() ) - { - case svDouble: - AppendDouble( rBuffer, t->GetDouble() ); - break; - - case svString: - if( eOp == ocBad ) - rBuffer.append(t->GetString()); - else - AppendString( rBuffer, t->GetString() ); - break; - case svSingleRef: - { - SingleRefData& rRef = t->GetSingleRef(); - ComplRefData aRef; - aRef.Ref1 = aRef.Ref2 = rRef; - if ( eOp == ocColRowName ) - { - rRef.CalcAbsIfRel( aPos ); - if ( pDoc->HasStringData( rRef.nCol, rRef.nRow, rRef.nTab ) ) - { - String aStr; - pDoc->GetString( rRef.nCol, rRef.nRow, rRef.nTab, aStr ); - EnQuote( aStr ); - rBuffer.append(aStr); - } - else - { - rBuffer.append(ScGlobal::GetRscString(STR_NO_NAME_REF)); - pConv->MakeRefStr (rBuffer, *this, aRef, TRUE ); - } - } - else - pConv->MakeRefStr( rBuffer, *this, aRef, TRUE ); - } - break; - case svDoubleRef: - pConv->MakeRefStr( rBuffer, *this, t->GetDoubleRef(), FALSE ); - break; - case svMatrix: - CreateStringFromScMatrix( rBuffer, t->GetMatrix() ); - break; - - case svIndex: - { - rtl::OUStringBuffer aBuffer; - switch ( eOp ) - { - case ocName: - { - ScRangeData* pData = pDoc->GetRangeName()->FindIndex(t->GetIndex()); - if (pData) - { - if (pData->HasType(RT_SHARED)) - pData->UpdateSymbol( aBuffer, aPos, GetGrammar()); - else - aBuffer.append(pData->GetName()); - } - } - break; - case ocDBArea: - { - ScDBData* pDBData = pDoc->GetDBCollection()->FindIndex(t->GetIndex()); - if (pDBData) - aBuffer.append(pDBData->GetName()); - } - break; - default: - ; // nothing - } - if ( aBuffer.getLength() ) - rBuffer.append(aBuffer); - else - rBuffer.append(ScGlobal::GetRscString(STR_NO_NAME_REF)); - break; - } - case svExternal: - { - // mapped or translated name of AddIns - String aAddIn( t->GetExternal() ); - bool bMapped = mxSymbols->isPODF(); // ODF 1.1 directly uses programmatical name - if (!bMapped && mxSymbols->hasExternals()) - { - ScExternalHashMap::const_iterator iLook = mxSymbols->getReverseExternalHashMap()->find( aAddIn); - if (iLook != mxSymbols->getReverseExternalHashMap()->end()) - { - aAddIn = (*iLook).second; - bMapped = true; - } - } - if (!bMapped && !mxSymbols->isEnglish()) - ScGlobal::GetAddInCollection()->LocalizeString( aAddIn ); - rBuffer.append(aAddIn); - } - break; - case svByte: - case svJump: - case svFAP: - case svMissing: - case svSep: - break; // Opcodes - default: - DBG_ERROR("ScCompiler:: GetStringFromToken errUnknownVariable"); - } // of switch - } - } - if( bSpaces ) - rBuffer.append(sal_Unicode(' ')); - if ( bAllowArrAdvance ) - { - if( bNext ) - t = pArr->Next(); - return t; + break; + default: + // warning, not error, otherwise we may end up with a never + // ending message box loop if this was the cursor cell to be redrawn. + DBG_WARNING("ScCompiler::CreateStringFromToken: unknown type of ocExternalRef"); } - return pTokenP; } -void ScCompiler::CreateStringFromScMatrix( rtl::OUStringBuffer& rBuffer, - const ScMatrix* pMatrix ) +void ScCompiler::CreateStringFromMatrix( rtl::OUStringBuffer& rBuffer, + FormulaToken* pTokenP) { + const ScMatrix* pMatrix = static_cast<ScToken*>(pTokenP)->GetMatrix(); SCSIZE nC, nMaxC, nR, nMaxR; pMatrix->GetDimensions( nMaxC, nMaxR); @@ -6669,86 +4876,73 @@ void ScCompiler::CreateStringFromScMatrix( rtl::OUStringBuffer& rBuffer, rBuffer.append( mxSymbols->getSymbol(ocArrayClose) ); } -void ScCompiler::AppendBoolean( rtl::OUStringBuffer& rBuffer, bool bVal ) -{ - rBuffer.append( mxSymbols->getSymbol(static_cast<OpCode>(bVal ? ocTrue : ocFalse)) ); -} - -void ScCompiler::AppendDouble( rtl::OUStringBuffer& rBuffer, double fVal ) +void ScCompiler::CreateStringFromSingleRef(rtl::OUStringBuffer& rBuffer,FormulaToken* _pTokenP) { - if ( mxSymbols->isEnglish() ) + const OpCode eOp = _pTokenP->GetOpCode(); + ScSingleRefData& rRef = static_cast<ScToken*>(_pTokenP)->GetSingleRef(); + ScComplexRefData aRef; + aRef.Ref1 = aRef.Ref2 = rRef; + if ( eOp == ocColRowName ) { - ::rtl::math::doubleToUStringBuffer( rBuffer, fVal, - rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', TRUE ); + rRef.CalcAbsIfRel( aPos ); + if ( pDoc->HasStringData( rRef.nCol, rRef.nRow, rRef.nTab ) ) + { + String aStr; + pDoc->GetString( rRef.nCol, rRef.nRow, rRef.nTab, aStr ); + EnQuote( aStr ); + rBuffer.append(aStr); + } + else + { + rBuffer.append(ScGlobal::GetRscString(STR_NO_NAME_REF)); + pConv->MakeRefStr (rBuffer, *this, aRef, TRUE ); + } } else - { - ::rtl::math::doubleToUStringBuffer( rBuffer, fVal, - rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, - ScGlobal::pLocaleData->getNumDecimalSep().GetChar(0), - TRUE ); - } + pConv->MakeRefStr( rBuffer, *this, aRef, TRUE ); } - -void ScCompiler::AppendString( rtl::OUStringBuffer& rBuffer, const String & rStr ) +// ----------------------------------------------------------------------------- +void ScCompiler::CreateStringFromDoubleRef(rtl::OUStringBuffer& rBuffer,FormulaToken* _pTokenP) { - if (pDoc->IsImportingXML()) - rBuffer.append( rStr ); - else + pConv->MakeRefStr( rBuffer, *this, static_cast<ScToken*>(_pTokenP)->GetDoubleRef(), FALSE ); +} +// ----------------------------------------------------------------------------- +void ScCompiler::CreateStringFromIndex(rtl::OUStringBuffer& rBuffer,FormulaToken* _pTokenP) +{ + const OpCode eOp = _pTokenP->GetOpCode(); + rtl::OUStringBuffer aBuffer; + switch ( eOp ) { - rBuffer.append(sal_Unicode('"')); - if ( ScGlobal::UnicodeStrChr( rStr.GetBuffer(), '"' ) == NULL ) - rBuffer.append( rStr ); - else + case ocName: { String aStr( rStr ); aStr.SearchAndReplaceAll( '"', String( RTL_CONSTASCII_USTRINGPARAM( "\"\""))); - rBuffer.append(aStr); } - rBuffer.append(sal_Unicode('"')); + break; + case ocDBArea: + { + ScDBData* pDBData = pDoc->GetDBCollection()->FindIndex(_pTokenP->GetIndex()); + if (pDBData) + aBuffer.append(pDBData->GetName()); + } + break; + default: + ; // nothing } + if ( aBuffer.getLength() ) + rBuffer.append(aBuffer); + else + rBuffer.append(ScGlobal::GetRscString(STR_NO_NAME_REF)); } - -void ScCompiler::CreateStringFromTokenArray( String& rFormula ) +// ----------------------------------------------------------------------------- +void ScCompiler::LocalizeString( String& rName ) { - rtl::OUStringBuffer aBuffer( pArr->GetLen() * 5 ); - CreateStringFromTokenArray( aBuffer ); - rFormula = aBuffer; + ScGlobal::GetAddInCollection()->LocalizeString( rName ); } - -void ScCompiler::CreateStringFromTokenArray( rtl::OUStringBuffer& rBuffer ) +// ----------------------------------------------------------------------------- +BOOL ScCompiler::IsImportingXML() const { - rBuffer.setLength(0); - if( !pArr->GetLen() ) - return; - - ScTokenArray* pSaveArr = pArr; - bool bODFF = ScGrammar::isODFF( meGrammar); - if (bODFF || ScGrammar::isPODF( meGrammar)) - { - // Scan token array for missing args and re-write if present. - ScMissingConvention aConv( bODFF); - if (pArr->NeedsPofRewrite( aConv)) - pArr = pArr->RewriteMissingToPof( aConv); - } - - // At least one character per token, plus some are references, some are - // function names, some are numbers, ... - rBuffer.ensureCapacity( pArr->GetLen() * 5 ); - - if ( pArr->IsRecalcModeForced() ) - rBuffer.append(sal_Unicode('=')); - ScToken* t = pArr->First(); - while( t ) - t = CreateStringFromToken( rBuffer, t, TRUE ); - - if (pSaveArr != pArr) - { - delete pArr; - pArr = pSaveArr; - } + return pDoc->IsImportingXML(); } // Put quotes around string if non-alphanumeric characters are contained, @@ -6771,27 +4965,276 @@ BOOL ScCompiler::EnQuote( String& rStr ) return TRUE; } -// Remove quotes, escaped quotes are unescaped. -BOOL ScCompiler::DeQuote( String& rStr ) +void ScCompiler::fillAddInToken(::std::vector< ::com::sun::star::sheet::FormulaOpCodeMapEntry >& _rVec,bool _bIsEnglish) const { - xub_StrLen nLen = rStr.Len(); - if ( nLen > 1 && rStr.GetChar(0) == '\'' && rStr.GetChar( nLen-1 ) == '\'' ) + // All known AddIn functions. + sheet::FormulaOpCodeMapEntry aEntry; + aEntry.Token.OpCode = ocExternal; + + ScUnoAddInCollection* pColl = ScGlobal::GetAddInCollection(); + const long nCount = pColl->GetFuncCount(); + for (long i=0; i < nCount; ++i) { - rStr.Erase( nLen-1, 1 ); - rStr.Erase( 0, 1 ); - xub_StrLen nPos = 0; - while ( (nPos = rStr.SearchAscii( "\\\'", nPos)) != STRING_NOTFOUND ) + const ScUnoAddInFuncData* pFuncData = pColl->GetFuncData(i); + if (pFuncData) { - rStr.Erase( nPos, 1 ); - ++nPos; + if ( _bIsEnglish ) + { + String aName; + if (pFuncData->GetExcelName( LANGUAGE_ENGLISH_US, aName)) + aEntry.Name = aName; + else + aEntry.Name = pFuncData->GetUpperName(); + } + else + aEntry.Name = pFuncData->GetUpperLocal(); + aEntry.Token.Data <<= ::rtl::OUString( pFuncData->GetOriginalName()); + _rVec.push_back( aEntry); } + } + // FIXME: what about those old non-UNO AddIns? +} +// ----------------------------------------------------------------------------- +BOOL ScCompiler::HandleSingleRef() +{ + ScSingleRefData& rRef = static_cast<ScToken*>((FormulaToken*)pToken)->GetSingleRef(); + rRef.CalcAbsIfRel( aPos ); + if ( !rRef.Valid() ) + { + SetError( errNoRef ); return TRUE; } - return FALSE; + SCCOL nCol = rRef.nCol; + SCROW nRow = rRef.nRow; + SCTAB nTab = rRef.nTab; + ScAddress aLook( nCol, nRow, nTab ); + BOOL bColName = rRef.IsColRel(); + SCCOL nMyCol = aPos.Col(); + SCROW nMyRow = aPos.Row(); + BOOL bInList = FALSE; + BOOL bValidName = FALSE; + ScRangePairList* pRL = (bColName ? + pDoc->GetColNameRanges() : pDoc->GetRowNameRanges()); + ScRange aRange; + for ( ScRangePair* pR = pRL->First(); pR; pR = pRL->Next() ) + { + if ( pR->GetRange(0).In( aLook ) ) + { + bInList = bValidName = TRUE; + aRange = pR->GetRange(1); + if ( bColName ) + { + aRange.aStart.SetCol( nCol ); + aRange.aEnd.SetCol( nCol ); + } + else + { + aRange.aStart.SetRow( nRow ); + aRange.aEnd.SetRow( nRow ); + } + break; // for + } + } + if ( !bInList && pDoc->GetDocOptions().IsLookUpColRowNames() ) + { // automagically or created by copying and NamePos isn't in list + BOOL bString = pDoc->HasStringData( nCol, nRow, nTab ); + if ( !bString && !pDoc->GetCell( aLook ) ) + bString = TRUE; // empty cell is ok + if ( bString ) + { //! coresponds with ScInterpreter::ScColRowNameAuto() + bValidName = TRUE; + if ( bColName ) + { // ColName + SCROW nStartRow = nRow + 1; + if ( nStartRow > MAXROW ) + nStartRow = MAXROW; + SCROW nMaxRow = MAXROW; + if ( nMyCol == nCol ) + { // formula cell in same column + if ( nMyRow == nStartRow ) + { // take remainder under name cell + nStartRow++; + if ( nStartRow > MAXROW ) + nStartRow = MAXROW; + } + else if ( nMyRow > nStartRow ) + { // from name cell down to formula cell + nMaxRow = nMyRow - 1; + } + } + for ( ScRangePair* pR = pRL->First(); pR; pR = pRL->Next() ) + { // next defined ColNameRange below limits row + const ScRange& rRange = pR->GetRange(1); + if ( rRange.aStart.Col() <= nCol && nCol <= rRange.aEnd.Col() ) + { // identical column range + SCROW nTmp = rRange.aStart.Row(); + if ( nStartRow < nTmp && nTmp <= nMaxRow ) + nMaxRow = nTmp - 1; + } + } + aRange.aStart.Set( nCol, nStartRow, nTab ); + aRange.aEnd.Set( nCol, nMaxRow, nTab ); + } + else + { // RowName + SCCOL nStartCol = nCol + 1; + if ( nStartCol > MAXCOL ) + nStartCol = MAXCOL; + SCCOL nMaxCol = MAXCOL; + if ( nMyRow == nRow ) + { // formula cell in same row + if ( nMyCol == nStartCol ) + { // take remainder right from name cell + nStartCol++; + if ( nStartCol > MAXCOL ) + nStartCol = MAXCOL; + } + else if ( nMyCol > nStartCol ) + { // from name cell right to formula cell + nMaxCol = nMyCol - 1; + } + } + for ( ScRangePair* pR = pRL->First(); pR; pR = pRL->Next() ) + { // next defined RowNameRange to the right limits column + const ScRange& rRange = pR->GetRange(1); + if ( rRange.aStart.Row() <= nRow && nRow <= rRange.aEnd.Row() ) + { // identical row range + SCCOL nTmp = rRange.aStart.Col(); + if ( nStartCol < nTmp && nTmp <= nMaxCol ) + nMaxCol = nTmp - 1; + } + } + aRange.aStart.Set( nStartCol, nRow, nTab ); + aRange.aEnd.Set( nMaxCol, nRow, nTab ); + } + } + } + if ( bValidName ) + { + // And now the magic to distinguish between a range and a single + // cell thereof, which is picked position-dependent of the formula + // cell. If a direct neighbor is a binary operator (ocAdd, ...) a + // SingleRef matching the column/row of the formula cell is + // generated. A ocColRowName or ocIntersect as a neighbor results + // in a range. Special case: if label is valid for a single cell, a + // position independent SingleRef is generated. + BOOL bSingle = (aRange.aStart == aRange.aEnd); + BOOL bFound; + if ( bSingle ) + bFound = TRUE; + else + { + FormulaToken* p1 = pArr->PeekPrevNoSpaces(); + FormulaToken* p2 = pArr->PeekNextNoSpaces(); + // begin/end of a formula => single + OpCode eOp1 = p1 ? p1->GetOpCode() : static_cast<OpCode>( ocAdd ); + OpCode eOp2 = p2 ? p2->GetOpCode() : static_cast<OpCode>( ocAdd ); + if ( eOp1 != ocColRowName && eOp1 != ocIntersect + && eOp2 != ocColRowName && eOp2 != ocIntersect ) + { + if ( (SC_OPCODE_START_BIN_OP <= eOp1 && eOp1 < SC_OPCODE_STOP_BIN_OP) || + (SC_OPCODE_START_BIN_OP <= eOp2 && eOp2 < SC_OPCODE_STOP_BIN_OP)) + bSingle = TRUE; + } + if ( bSingle ) + { // column and/or row must match range + if ( bColName ) + { + bFound = (aRange.aStart.Row() <= nMyRow + && nMyRow <= aRange.aEnd.Row()); + if ( bFound ) + aRange.aStart.SetRow( nMyRow ); + } + else + { + bFound = (aRange.aStart.Col() <= nMyCol + && nMyCol <= aRange.aEnd.Col()); + if ( bFound ) + aRange.aStart.SetCol( nMyCol ); + } + } + else + bFound = TRUE; + } + if ( !bFound ) + SetError(errNoRef); + else if ( !bCompileForFAP ) + { + ScTokenArray* pNew = new ScTokenArray; + if ( bSingle ) + { + ScSingleRefData aRefData; + aRefData.InitAddress( aRange.aStart ); + if ( bColName ) + aRefData.SetColRel( TRUE ); + else + aRefData.SetRowRel( TRUE ); + aRefData.CalcRelFromAbs( aPos ); + pNew->AddSingleReference( aRefData ); + } + else + { + ScScComplexRefData aRefData; + aRefData.InitRange( aRange ); + if ( bColName ) + { + aRefData.Ref1.SetColRel( TRUE ); + aRefData.Ref2.SetColRel( TRUE ); + } + else + { + aRefData.Ref1.SetRowRel( TRUE ); + aRefData.Ref2.SetRowRel( TRUE ); + } + aRefData.CalcRelFromAbs( aPos ); + if ( bInList ) + pNew->AddDoubleReference( aRefData ); + else + { // automagically + pNew->Add( new ScDoubleRefToken( aRefData, ocColRowNameAuto ) ); + } + } + PushTokenArray( pNew, TRUE ); + pNew->Reset(); + return GetToken(); + } + } + else + SetError(errNoName); + return TRUE; +} +// ----------------------------------------------------------------------------- +BOOL ScCompiler::HandleDbData() +{ + ScDBData* pDBData = pDoc->GetDBCollection()->FindIndex( pToken->GetIndex() ); + if ( !pDBData ) + SetError(errNoName); + else if ( !bCompileForFAP ) + { + ScComplexRefData aRefData; + aRefData.InitFlags(); + pDBData->GetArea( (SCTAB&) aRefData.Ref1.nTab, + (SCCOL&) aRefData.Ref1.nCol, + (SCROW&) aRefData.Ref1.nRow, + (SCCOL&) aRefData.Ref2.nCol, + (SCROW&) aRefData.Ref2.nRow); + aRefData.Ref2.nTab = aRefData.Ref1.nTab; + aRefData.CalcRelFromAbs( aPos ); + ScTokenArray* pNew = new ScTokenArray; + pNew->AddDoubleReference( aRefData ); + PushTokenArray( pNew, TRUE ); + pNew->Reset(); + return GetToken(); + } + return TRUE; } - String GetScCompilerNativeSymbol( OpCode eOp ) { return ScCompiler::GetNativeSymbol( eOp ); } +// ----------------------------------------------------------------------------- +FormulaTokenRef ScCompiler::ExtendRangeReference( FormulaToken & rTok1, FormulaToken & rTok2, bool bReuseDoubleRef ) +{ + return ScToken::ExtendRangeReference( rTok1, rTok2, aPos,bReuseDoubleRef ); +} diff --git a/sc/source/core/tool/consoli.cxx b/sc/source/core/tool/consoli.cxx index ec1c21ec4807..b464c78e1c8f 100644 --- a/sc/source/core/tool/consoli.cxx +++ b/sc/source/core/tool/consoli.cxx @@ -42,7 +42,7 @@ #include "olinetab.hxx" #include "globstr.hrc" #include "subtotal.hxx" -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" #include "cell.hxx" #include <math.h> diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index f1ab1da94432..53e05e1b0ec4 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: interpr1.cxx,v $ - * $Revision: 1.60.54.5 $ + * $Revision: 1.61 $ * * This file is part of OpenOffice.org. * @@ -45,6 +45,7 @@ #include <sfx2/printer.hxx> #include <unotools/collatorwrapper.hxx> #include <unotools/transliterationwrapper.hxx> +#include <rtl/logfile.hxx> #include "interpre.hxx" #include "patattr.hxx" @@ -75,7 +76,7 @@ IMPL_FIXEDMEMPOOL_NEWDEL( ScInterpreter, 32, 16 ) ScTokenStack* ScInterpreter::pGlobalStack = NULL; BOOL ScInterpreter::bGlobalStackInUse = FALSE; - +using namespace formula; //----------------------------------------------------------------------------- // Funktionen //----------------------------------------------------------------------------- @@ -83,6 +84,7 @@ BOOL ScInterpreter::bGlobalStackInUse = FALSE; void ScInterpreter::ScIfJump() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIfJump" ); const short* pJump = pCur->GetJump(); short nJumpCount = pJump[ 0 ]; MatrixDoubleRefToMatrix(); @@ -95,7 +97,7 @@ void ScInterpreter::ScIfJump() PushIllegalParameter(); else { - ScTokenRef xNew; + FormulaTokenRef xNew; ScTokenMatrixMap::const_iterator aMapIter; // DoubleError handled by JumpMatrix pMat->SetErrorInterpreter( NULL); @@ -169,8 +171,7 @@ void ScInterpreter::ScIfJump() } } xNew = new ScJumpMatrixToken( pJumpMat ); - GetTokenMatrixMap().insert( ScTokenMatrixMap::value_type( - pCur, xNew)); + GetTokenMatrixMap().insert( ScTokenMatrixMap::value_type(pCur, xNew)); } PushTempToken( xNew); // set endpoint of path for main code line @@ -213,6 +214,7 @@ void ScInterpreter::ScIfJump() void ScInterpreter::ScChoseJump() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScChoseJump" ); // We have to set a jump, if there was none chosen because of an error set // it to endpoint. bool bHaveJump = false; @@ -228,7 +230,7 @@ void ScInterpreter::ScChoseJump() PushIllegalParameter(); else { - ScTokenRef xNew; + FormulaTokenRef xNew; ScTokenMatrixMap::const_iterator aMapIter; // DoubleError handled by JumpMatrix pMat->SetErrorInterpreter( NULL); @@ -311,7 +313,6 @@ void ScInterpreter::ScChoseJump() aCode.Jump( pJump[ nJumpCount ], pJump[ nJumpCount ] ); } - void lcl_AdjustJumpMatrix( ScJumpMatrix* pJumpM, ScMatrixRef& pResMat, SCSIZE nParmCols, SCSIZE nParmRows ) { SCSIZE nJumpCols, nJumpRows; @@ -342,10 +343,10 @@ void lcl_AdjustJumpMatrix( ScJumpMatrix* pJumpM, ScMatrixRef& pResMat, SCSIZE nP } } - bool ScInterpreter::JumpMatrix( short nStackLevel ) { - pJumpMatrix = pStack[sp-nStackLevel]->GetJumpMatrix(); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::JumpMatrix" ); + pJumpMatrix = static_cast<ScToken*>(pStack[sp-nStackLevel])->GetJumpMatrix(); ScMatrixRef pResMat = pJumpMatrix->GetResultMatrix(); SCSIZE nC, nR; if ( nStackLevel == 2 ) @@ -455,12 +456,12 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) aRange.aEnd.Col() != aRange.aStart.Col()) || (nRow > static_cast<ULONG>(aRange.aEnd.Row()) && aRange.aEnd.Row() != aRange.aStart.Row())) - { + { fVal = CreateDoubleError( NOTAVAILABLE ); pResMat->PutDouble( fVal, nC, nR ); - } - else - { + } + else + { // Replicate column and/or row of a vector if it is // one. Note that this could be a range reference // that in fact consists of only one cell, e.g. A1:A1 @@ -474,7 +475,7 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) if (HasCellEmptyData( pCell)) pResMat->PutEmpty( nC, nR ); else if (HasCellValueData( pCell)) - { + { double fCellVal = GetCellValue( aAdr, pCell); if ( nGlobalError ) { @@ -483,8 +484,8 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) nGlobalError = 0; } pResMat->PutDouble( fCellVal, nC, nR ); - } - else + } + else { String aStr; GetCellString( aStr, pCell ); @@ -497,7 +498,7 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) else pResMat->PutString( aStr, nC, nR ); } - } + } SCSIZE nParmCols = aRange.aEnd.Col() - aRange.aStart.Col() + 1; SCSIZE nParmRows = aRange.aEnd.Row() - aRange.aStart.Row() + 1; lcl_AdjustJumpMatrix( pJumpMatrix, pResMat, nParmCols, nParmRows ); @@ -623,6 +624,7 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) double ScInterpreter::CompareFunc( const ScCompare& rComp ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CompareFunc" ); // Keep DoubleError if encountered // #i40539# if bEmpty is set, bVal/nVal are uninitialized if ( !rComp.bEmpty[0] && rComp.bVal[0] && !::rtl::math::isFinite( rComp.nVal[0])) @@ -705,6 +707,7 @@ double ScInterpreter::CompareFunc( const ScCompare& rComp ) double ScInterpreter::Compare() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::Compare" ); String aVal1, aVal2; ScCompare aComp( &aVal1, &aVal2 ); for( short i = 1; i >= 0; i-- ) @@ -758,6 +761,7 @@ double ScInterpreter::Compare() ScMatrixRef ScInterpreter::CompareMat() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CompareMat" ); String aVal1, aVal2; ScCompare aComp( &aVal1, &aVal2 ); ScMatrixRef pMat[2]; @@ -888,6 +892,7 @@ ScMatrixRef ScInterpreter::CompareMat() void ScInterpreter::ScEqual() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScEqual" ); if ( GetStackType(1) == svMatrix || GetStackType(2) == svMatrix ) { ScMatrixRef pMat = CompareMat(); @@ -906,6 +911,7 @@ void ScInterpreter::ScEqual() void ScInterpreter::ScNotEqual() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScNotEqual" ); if ( GetStackType(1) == svMatrix || GetStackType(2) == svMatrix ) { ScMatrixRef pMat = CompareMat(); @@ -924,6 +930,7 @@ void ScInterpreter::ScNotEqual() void ScInterpreter::ScLess() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLess" ); if ( GetStackType(1) == svMatrix || GetStackType(2) == svMatrix ) { ScMatrixRef pMat = CompareMat(); @@ -942,6 +949,7 @@ void ScInterpreter::ScLess() void ScInterpreter::ScGreater() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGreater" ); if ( GetStackType(1) == svMatrix || GetStackType(2) == svMatrix ) { ScMatrixRef pMat = CompareMat(); @@ -960,6 +968,7 @@ void ScInterpreter::ScGreater() void ScInterpreter::ScLessEqual() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLessEqual" ); if ( GetStackType(1) == svMatrix || GetStackType(2) == svMatrix ) { ScMatrixRef pMat = CompareMat(); @@ -978,6 +987,7 @@ void ScInterpreter::ScLessEqual() void ScInterpreter::ScGreaterEqual() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGreaterEqual" ); if ( GetStackType(1) == svMatrix || GetStackType(2) == svMatrix ) { ScMatrixRef pMat = CompareMat(); @@ -996,6 +1006,7 @@ void ScInterpreter::ScGreaterEqual() void ScInterpreter::ScAnd() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScAnd" ); nFuncFmtType = NUMBERFORMAT_LOGICAL; short nParamCount = GetByte(); if ( MustHaveParamCountMin( nParamCount, 1 ) ) @@ -1093,6 +1104,7 @@ void ScInterpreter::ScAnd() void ScInterpreter::ScOr() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScOr" ); nFuncFmtType = NUMBERFORMAT_LOGICAL; short nParamCount = GetByte(); if ( MustHaveParamCountMin( nParamCount, 1 ) ) @@ -1191,6 +1203,7 @@ void ScInterpreter::ScOr() void ScInterpreter::ScNeg() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScNeg" ); // Simple negation doesn't change current format type to number, keep // current type. nFuncFmtType = nCurFmtType; @@ -1232,12 +1245,13 @@ void ScInterpreter::ScNeg() void ScInterpreter::ScPercentSign() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScPercentSign" ); nFuncFmtType = NUMBERFORMAT_PERCENT; - const ScToken* pSaveCur = pCur; + const FormulaToken* pSaveCur = pCur; BYTE nSavePar = cPar; PushInt( 100 ); cPar = 2; - ScByteToken aDivOp( ocDiv, cPar ); + FormulaByteToken aDivOp( ocDiv, cPar ); pCur = &aDivOp; ScDiv(); pCur = pSaveCur; @@ -1247,6 +1261,7 @@ void ScInterpreter::ScPercentSign() void ScInterpreter::ScNot() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScNot" ); nFuncFmtType = NUMBERFORMAT_LOGICAL; switch ( GetStackType() ) { @@ -1286,18 +1301,21 @@ void ScInterpreter::ScNot() void ScInterpreter::ScPi() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScPi" ); PushDouble(F_PI); } void ScInterpreter::ScRandom() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRandom" ); PushDouble((double)rand() / ((double)RAND_MAX+1.0)); } void ScInterpreter::ScTrue() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScTrue" ); nFuncFmtType = NUMBERFORMAT_LOGICAL; PushInt(1); } @@ -1305,6 +1323,7 @@ void ScInterpreter::ScTrue() void ScInterpreter::ScFalse() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScFalse" ); nFuncFmtType = NUMBERFORMAT_LOGICAL; PushInt(0); } @@ -1312,90 +1331,105 @@ void ScInterpreter::ScFalse() void ScInterpreter::ScDeg() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDeg" ); PushDouble((GetDouble() / F_PI) * 180.0); } void ScInterpreter::ScRad() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRad" ); PushDouble(GetDouble() * (F_PI / 180)); } void ScInterpreter::ScSin() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSin" ); PushDouble(::rtl::math::sin(GetDouble())); } void ScInterpreter::ScCos() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCos" ); PushDouble(::rtl::math::cos(GetDouble())); } void ScInterpreter::ScTan() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScTan" ); PushDouble(::rtl::math::tan(GetDouble())); } void ScInterpreter::ScCot() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCot" ); PushDouble(1.0 / ::rtl::math::tan(GetDouble())); } void ScInterpreter::ScArcSin() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScArcSin" ); PushDouble(asin(GetDouble())); } void ScInterpreter::ScArcCos() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScArcCos" ); PushDouble(acos(GetDouble())); } void ScInterpreter::ScArcTan() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScArcTan" ); PushDouble(atan(GetDouble())); } void ScInterpreter::ScArcCot() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScArcCot" ); PushDouble((F_PI2) - atan(GetDouble())); } void ScInterpreter::ScSinHyp() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSinHyp" ); PushDouble(sinh(GetDouble())); } void ScInterpreter::ScCosHyp() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCosHyp" ); PushDouble(cosh(GetDouble())); } void ScInterpreter::ScTanHyp() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScTanHyp" ); PushDouble(tanh(GetDouble())); } void ScInterpreter::ScCotHyp() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCotHyp" ); PushDouble(1.0 / tanh(GetDouble())); } void ScInterpreter::ScArcSinHyp() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScArcSinHyp" ); double nVal = GetDouble(); PushDouble(log(nVal + sqrt((nVal * nVal) + 1.0))); } @@ -1403,6 +1437,7 @@ void ScInterpreter::ScArcSinHyp() void ScInterpreter::ScArcCosHyp() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScArcCosHyp" ); double nVal = GetDouble(); if (nVal < 1.0) PushIllegalArgument(); @@ -1413,6 +1448,7 @@ void ScInterpreter::ScArcCosHyp() void ScInterpreter::ScArcTanHyp() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScArcTanHyp" ); double nVal = GetDouble(); if (fabs(nVal) >= 1.0) PushIllegalArgument(); @@ -1423,6 +1459,7 @@ void ScInterpreter::ScArcTanHyp() void ScInterpreter::ScArcCotHyp() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScArcCotHyp" ); double nVal = GetDouble(); if (fabs(nVal) <= 1.0) PushIllegalArgument(); @@ -1433,12 +1470,14 @@ void ScInterpreter::ScArcCotHyp() void ScInterpreter::ScExp() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScExp" ); PushDouble(exp(GetDouble())); } void ScInterpreter::ScSqrt() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSqrt" ); double fVal = GetDouble(); if (fVal >= 0.0) PushDouble(sqrt(fVal)); @@ -1449,14 +1488,15 @@ void ScInterpreter::ScSqrt() void ScInterpreter::ScIsEmpty() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIsEmpty" ); short nRes = 0; nFuncFmtType = NUMBERFORMAT_LOGICAL; switch ( GetRawStackType() ) { case svEmptyCell: { - const ScToken* p = PopToken(); - if (!static_cast<const ScEmptyCellToken*>(p)->IsInherited()) + FormulaTokenRef p = PopToken(); + if (!static_cast<const ScEmptyCellToken*>(p.get())->IsInherited()) nRes = 1; } break; @@ -1503,6 +1543,7 @@ void ScInterpreter::ScIsEmpty() short ScInterpreter::IsString() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::IsString" ); nFuncFmtType = NUMBERFORMAT_LOGICAL; short nRes = 0; switch ( GetRawStackType() ) @@ -1563,18 +1604,21 @@ short ScInterpreter::IsString() void ScInterpreter::ScIsString() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIsString" ); PushInt( IsString() ); } void ScInterpreter::ScIsNonString() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIsNonString" ); PushInt( !IsString() ); } void ScInterpreter::ScIsLogical() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIsLogical" ); short nRes = 0; switch ( GetStackType() ) { @@ -1613,6 +1657,7 @@ void ScInterpreter::ScIsLogical() void ScInterpreter::ScType() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScType" ); short nType = 0; switch ( GetStackType() ) { @@ -1910,6 +1955,7 @@ void ScInterpreter::ScCell() void ScInterpreter::ScIsRef() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCell" ); nFuncFmtType = NUMBERFORMAT_LOGICAL; short nRes = 0; switch ( GetStackType() ) @@ -1932,9 +1978,9 @@ void ScInterpreter::ScIsRef() break; case svRefList : { - ScTokenRef x = PopToken(); + FormulaTokenRef x = PopToken(); if ( !nGlobalError ) - nRes = !x->GetRefList()->empty(); + nRes = !static_cast<ScToken*>(x.get())->GetRefList()->empty(); } break; default: @@ -1947,6 +1993,7 @@ void ScInterpreter::ScIsRef() void ScInterpreter::ScIsValue() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIsValue" ); nFuncFmtType = NUMBERFORMAT_LOGICAL; short nRes = 0; switch ( GetRawStackType() ) @@ -2010,6 +2057,7 @@ void ScInterpreter::ScIsValue() void ScInterpreter::ScIsFormula() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIsFormula" ); nFuncFmtType = NUMBERFORMAT_LOGICAL; short nRes = 0; switch ( GetStackType() ) @@ -2033,6 +2081,7 @@ void ScInterpreter::ScIsFormula() void ScInterpreter::ScFormula() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScFormula" ); String aFormula; switch ( GetStackType() ) { @@ -2064,6 +2113,7 @@ void ScInterpreter::ScFormula() void ScInterpreter::ScIsNV() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIsNV" ); nFuncFmtType = NUMBERFORMAT_LOGICAL; short nRes = 0; switch ( GetStackType() ) @@ -2112,6 +2162,7 @@ void ScInterpreter::ScIsNV() void ScInterpreter::ScIsErr() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIsErr" ); nFuncFmtType = NUMBERFORMAT_LOGICAL; short nRes = 0; switch ( GetStackType() ) @@ -2166,6 +2217,7 @@ void ScInterpreter::ScIsErr() void ScInterpreter::ScIsError() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIsError" ); nFuncFmtType = NUMBERFORMAT_LOGICAL; short nRes = 0; switch ( GetStackType() ) @@ -2217,6 +2269,7 @@ void ScInterpreter::ScIsError() short ScInterpreter::IsEven() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::IsEven" ); nFuncFmtType = NUMBERFORMAT_LOGICAL; short nRes = 0; double fVal = 0.0; @@ -2299,18 +2352,21 @@ short ScInterpreter::IsEven() void ScInterpreter::ScIsEven() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIsEven" ); PushInt( IsEven() ); } void ScInterpreter::ScIsOdd() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIsOdd" ); PushInt( !IsEven() ); } void ScInterpreter::ScN() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScN" ); USHORT nErr = nGlobalError; nGlobalError = 0; double fVal; @@ -2349,6 +2405,7 @@ void ScInterpreter::ScTrim() void ScInterpreter::ScUpper() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScTrim" ); String aString = GetString(); ScGlobal::pCharClass->toUpper(aString); PushString(aString); @@ -2357,6 +2414,7 @@ void ScInterpreter::ScUpper() void ScInterpreter::ScPropper() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScPropper" ); //2do: what to do with I18N-CJK ?!? String aStr( GetString() ); const xub_StrLen nLen = aStr.Len(); @@ -2389,6 +2447,7 @@ void ScInterpreter::ScPropper() void ScInterpreter::ScLower() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLower" ); String aString( GetString() ); ScGlobal::pCharClass->toLower(aString); PushString(aString); @@ -2397,6 +2456,7 @@ void ScInterpreter::ScLower() void ScInterpreter::ScLen() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLen" ); String aStr( GetString() ); PushDouble( aStr.Len() ); } @@ -2404,6 +2464,7 @@ void ScInterpreter::ScLen() void ScInterpreter::ScT() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScT" ); switch ( GetStackType() ) { case svDoubleRef : @@ -2458,6 +2519,7 @@ void ScInterpreter::ScT() void ScInterpreter::ScValue() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScValue" ); String aInputString; double fVal; @@ -2539,6 +2601,7 @@ inline BOOL lcl_ScInterpreter_IsPrintable( sal_Unicode c ) void ScInterpreter::ScClean() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScClean" ); String aStr( GetString() ); for ( xub_StrLen i = 0; i < aStr.Len(); i++ ) { @@ -2551,6 +2614,7 @@ void ScInterpreter::ScClean() void ScInterpreter::ScCode() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCode" ); //2do: make it full range unicode? const String& rStr = GetString(); PushInt( (sal_uChar) ByteString::ConvertFromUnicode( rStr.GetChar(0), gsl_getSystemTextEncoding() ) ); @@ -2559,6 +2623,7 @@ void ScInterpreter::ScCode() void ScInterpreter::ScChar() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScChar" ); //2do: make it full range unicode? double fVal = GetDouble(); if (fVal < 0.0 || fVal >= 256.0) @@ -2838,6 +2903,7 @@ static ::rtl::OUString lcl_convertIntoFullWidth( const ::rtl::OUString & rStr ) */ void ScInterpreter::ScJis() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScJis" ); if (MustHaveParamCount( GetByte(), 1)) PushString( lcl_convertIntoFullWidth( GetString())); } @@ -2851,6 +2917,7 @@ void ScInterpreter::ScJis() */ void ScInterpreter::ScAsc() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScAsc" ); if (MustHaveParamCount( GetByte(), 1)) PushString( lcl_convertIntoHalfWidth( GetString())); } @@ -2858,6 +2925,7 @@ void ScInterpreter::ScAsc() void ScInterpreter::ScMin( BOOL bTextAsZero ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMin" ); short nParamCount = GetByte(); if (!MustHaveParamCountMin( nParamCount, 1)) return; @@ -2982,6 +3050,7 @@ void ScInterpreter::ScMin( BOOL bTextAsZero ) void ScInterpreter::ScMax( BOOL bTextAsZero ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMax" ); short nParamCount = GetByte(); if (!MustHaveParamCountMin( nParamCount, 1)) return; @@ -3106,6 +3175,7 @@ void ScInterpreter::ScMax( BOOL bTextAsZero ) double ScInterpreter::IterateParameters( ScIterFunc eFunc, BOOL bTextAsZero ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::IterateParameters" ); short nParamCount = GetByte(); double fRes = ( eFunc == ifPRODUCT ) ? 1.0 : 0.0; double fVal = 0.0; @@ -3417,36 +3487,42 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, BOOL bTextAsZero ) void ScInterpreter::ScSumSQ() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSumSQ" ); PushDouble( IterateParameters( ifSUMSQ ) ); } void ScInterpreter::ScSum() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSum" ); PushDouble( IterateParameters( ifSUM ) ); } void ScInterpreter::ScProduct() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScProduct" ); PushDouble( IterateParameters( ifPRODUCT ) ); } void ScInterpreter::ScAverage( BOOL bTextAsZero ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScAverage" ); PushDouble( IterateParameters( ifAVERAGE, bTextAsZero ) ); } void ScInterpreter::ScCount() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCount" ); PushDouble( IterateParameters( ifCOUNT ) ); } void ScInterpreter::ScCount2() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCount2" ); PushDouble( IterateParameters( ifCOUNT2 ) ); } @@ -3454,6 +3530,7 @@ void ScInterpreter::ScCount2() void ScInterpreter::GetStVarParams( double& rVal, double& rValCount, BOOL bTextAsZero ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetStVarParams" ); short nParamCount = GetByte(); std::vector<double> values; @@ -3570,6 +3647,7 @@ void ScInterpreter::GetStVarParams( double& rVal, double& rValCount, void ScInterpreter::ScVar( BOOL bTextAsZero ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScVar" ); double nVal; double nValCount; GetStVarParams( nVal, nValCount, bTextAsZero ); @@ -3583,6 +3661,7 @@ void ScInterpreter::ScVar( BOOL bTextAsZero ) void ScInterpreter::ScVarP( BOOL bTextAsZero ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScVarP" ); double nVal; double nValCount; GetStVarParams( nVal, nValCount, bTextAsZero ); @@ -3593,6 +3672,7 @@ void ScInterpreter::ScVarP( BOOL bTextAsZero ) void ScInterpreter::ScStDev( BOOL bTextAsZero ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScStDev" ); double nVal; double nValCount; GetStVarParams( nVal, nValCount, bTextAsZero ); @@ -3605,6 +3685,7 @@ void ScInterpreter::ScStDev( BOOL bTextAsZero ) void ScInterpreter::ScStDevP( BOOL bTextAsZero ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScStDevP" ); double nVal; double nValCount; GetStVarParams( nVal, nValCount, bTextAsZero ); @@ -3634,6 +3715,7 @@ void ScInterpreter::ScStDevP( BOOL bTextAsZero ) void ScInterpreter::ScColumns() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScColumns" ); BYTE nParamCount = GetByte(); ULONG nVal = 0; SCCOL nCol1; @@ -3677,6 +3759,7 @@ void ScInterpreter::ScColumns() void ScInterpreter::ScRows() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRows" ); BYTE nParamCount = GetByte(); ULONG nVal = 0; SCCOL nCol1; @@ -3719,6 +3802,7 @@ void ScInterpreter::ScRows() void ScInterpreter::ScTables() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScTables" ); BYTE nParamCount = GetByte(); ULONG nVal; if ( nParamCount == 0 ) @@ -3760,6 +3844,7 @@ void ScInterpreter::ScTables() void ScInterpreter::ScColumn() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScColumn" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 0, 1 ) ) { @@ -3835,6 +3920,7 @@ void ScInterpreter::ScColumn() void ScInterpreter::ScRow() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRow" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 0, 1 ) ) { @@ -3909,6 +3995,7 @@ void ScInterpreter::ScRow() void ScInterpreter::ScTable() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScTable" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 0, 1 ) ) { @@ -4057,6 +4144,7 @@ static void lcl_GetLastMatch( SCSIZE& rIndex, const ScMatrix& rMat, void ScInterpreter::ScMatch() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMatch" ); ScMatrixRef pMatSrc = NULL; BYTE nParamCount = GetByte(); @@ -4315,6 +4403,7 @@ void ScInterpreter::ScMatch() void ScInterpreter::ScCountEmptyCells() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCountEmptyCells" ); if ( MustHaveParamCount( GetByte(), 1 ) ) { ULONG nMaxCount = 0, nCount = 0; @@ -4367,6 +4456,7 @@ void ScInterpreter::ScCountEmptyCells() void ScInterpreter::ScCountIf() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCountIf" ); if ( MustHaveParamCount( GetByte(), 2 ) ) { String rString; @@ -4517,6 +4607,7 @@ void ScInterpreter::ScCountIf() void ScInterpreter::ScSumIf() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSumIf" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 2, 3 ) ) { @@ -4756,6 +4847,7 @@ void ScInterpreter::ScSumIf() void ScInterpreter::ScLookup() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLookup" ); BYTE nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 2, 3 ) ) return ; @@ -4856,74 +4948,16 @@ void ScInterpreter::ScLookup() // Get the lookup value. - String sStr; ScQueryParam aParam; ScQueryEntry& rEntry = aParam.GetEntry(0); - - switch ( GetStackType() ) - { - case svDouble: - { - rEntry.bQueryByString = FALSE; - rEntry.nVal = GetDouble(); - } - break; - case svString: - { - sStr = GetString(); - rEntry.bQueryByString = TRUE; - *rEntry.pStr = sStr; - } - break; - case svDoubleRef : - case svSingleRef : - { - ScAddress aAdr; - if ( !PopDoubleRefOrSingleRef( aAdr ) ) - { - PushInt(0); - return ; - } - ScBaseCell* pCell = GetCell( aAdr ); - if (HasCellValueData(pCell)) - { - rEntry.bQueryByString = FALSE; - rEntry.nVal = GetCellValue( aAdr, pCell ); - } else - { - if ( GetCellType( pCell ) == CELLTYPE_NOTE ) - { - rEntry.bQueryByString = FALSE; - rEntry.nVal = 0.0; - } else - { - GetCellString(sStr, pCell); - rEntry.bQueryByString = TRUE; - *rEntry.pStr = sStr; - } - } - } - break; - case svMatrix : - { - ScMatValType nType = GetDoubleOrStringFromMatrix( rEntry.nVal, - *rEntry.pStr); - rEntry.bQueryByString = ScMatrix::IsNonValueType(nType); - } - break; - default: - { - PushIllegalParameter(); - return; - } - } + if ( !FillEntry(rEntry) ) + return; // Now, perform the search to compute the delta position (nDelta). if (pDataMat) { // Data array is given as a matrix. - rEntry.bDoQuery = true; rEntry.eOp = SC_LESS_EQUAL; bool bFound = false; @@ -5182,6 +5216,12 @@ void ScInterpreter::ScLookup() void ScInterpreter::ScHLookup() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScHLookup" ); + CalculateLookup(TRUE); +} +void ScInterpreter::CalculateLookup(BOOL HLookup) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CalculateLookup" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 3, 4 ) ) { @@ -5224,109 +5264,65 @@ void ScInterpreter::ScHLookup() PushIllegalParameter(); return; } - if ( fIndex < 0.0 || (pMat ? (fIndex >= nR) : (fIndex+nRow1 > nRow2)) ) + if ( fIndex < 0.0 || (HLookup ? (pMat ? (fIndex >= nR) : (fIndex+nRow1 > nRow2)) : (pMat ? (fIndex >= nC) : (fIndex+nCol1 > nCol2)) ) ) { PushIllegalArgument(); return; } SCROW nZIndex = static_cast<SCROW>(fIndex); + SCCOL nSpIndex = static_cast<SCCOL>(fIndex); + if (!pMat) + { nZIndex += nRow1; // Wertzeile + nSpIndex = sal::static_int_cast<SCCOL>( nSpIndex + nCol1 ); // value column + } + if (nGlobalError == 0) { - String sStr; ScQueryParam rParam; rParam.nCol1 = nCol1; rParam.nRow1 = nRow1; - rParam.nCol2 = nCol2; - rParam.nRow2 = nRow1; // nur in der ersten Zeile suchen - rParam.bByRow = FALSE; + if ( HLookup ) + { + rParam.nCol2 = nCol2; + rParam.nRow2 = nRow1; // nur in der ersten Zeile suchen + rParam.bByRow = FALSE; + } // if ( HLookup ) + else + { + rParam.nCol2 = nCol1; // nur in der ersten Spalte suchen + rParam.nRow2 = nRow2; + rParam.nTab = nTab1; + } rParam.bMixedComparison = TRUE; ScQueryEntry& rEntry = rParam.GetEntry(0); rEntry.bDoQuery = TRUE; if ( bSorted ) rEntry.eOp = SC_LESS_EQUAL; - switch ( GetStackType() ) - { - case svDouble: - { - rEntry.bQueryByString = FALSE; - rEntry.nVal = GetDouble(); - } - break; - case svString: - { - sStr = GetString(); - rEntry.bQueryByString = TRUE; - *rEntry.pStr = sStr; - } - break; - case svDoubleRef : - case svSingleRef : - { - ScAddress aAdr; - if ( !PopDoubleRefOrSingleRef( aAdr ) ) - { - PushInt(0); - return ; - } - ScBaseCell* pCell = GetCell( aAdr ); - if (HasCellValueData(pCell)) - { - rEntry.bQueryByString = FALSE; - rEntry.nVal = GetCellValue( aAdr, pCell ); - } - else - { - if ( GetCellType( pCell ) == CELLTYPE_NOTE ) - { - rEntry.bQueryByString = FALSE; - rEntry.nVal = 0.0; - } - else - { - GetCellString(sStr, pCell); - rEntry.bQueryByString = TRUE; - *rEntry.pStr = sStr; - } - } - } - break; - case svMatrix : - { - ScMatValType nType = GetDoubleOrStringFromMatrix( - rEntry.nVal, *rEntry.pStr); - rEntry.bQueryByString = ScMatrix::IsNonValueType( nType); - } - break; - default: - { - PushIllegalParameter(); - return; - } - } + if ( !FillEntry(rEntry) ) + return; if ( rEntry.bQueryByString ) rParam.bRegExp = MayBeRegExp( *rEntry.pStr, pDok ); if (pMat) { - SCSIZE nMatCount = nC; + SCSIZE nMatCount = HLookup ? nC : nR; SCSIZE nDelta = SCSIZE_MAX; if (rEntry.bQueryByString) { -//!!!!!!! -//! TODO: enable regex on matrix strings -//!!!!!!! + //!!!!!!! + //! TODO: enable regex on matrix strings + //!!!!!!! String aParamStr = *rEntry.pStr; if ( bSorted ) { for (SCSIZE i = 0; i < nMatCount; i++) { - if (pMat->IsString(i, 0)) + if (HLookup ? pMat->IsString(i, 0) : pMat->IsString(0, i)) { sal_Int32 nRes = - ScGlobal::pCollator->compareString( - pMat->GetString(i,0), aParamStr); + ScGlobal::pCollator->compareString( HLookup ? pMat->GetString(i,0) : pMat->GetString(0,i), aParamStr); if (nRes <= 0) nDelta = i; else if (i>0) // #i2168# ignore first mismatch @@ -5340,10 +5336,10 @@ void ScInterpreter::ScHLookup() { for (SCSIZE i = 0; i < nMatCount; i++) { - if (pMat->IsString(i, 0)) + if (HLookup ? pMat->IsString(i, 0) : pMat->IsString(0, i)) { if ( ScGlobal::pTransliteration->isEqual( - pMat->GetString(i,0), aParamStr ) ) + HLookup ? pMat->GetString(i,0) : pMat->GetString(0,i), aParamStr ) ) { nDelta = i; i = nMatCount + 1; @@ -5359,9 +5355,9 @@ void ScInterpreter::ScHLookup() // #i2168# ignore strings for (SCSIZE i = 0; i < nMatCount; i++) { - if (!pMat->IsString(i, 0)) + if (!(HLookup ? pMat->IsString(i, 0) : pMat->IsString(0, i))) { - if (pMat->GetDouble(i,0) <= rEntry.nVal) + if ((HLookup ? pMat->GetDouble(i,0) : pMat->GetDouble(0,i)) <= rEntry.nVal) nDelta = i; else i = nMatCount+1; @@ -5372,9 +5368,9 @@ void ScInterpreter::ScHLookup() { for (SCSIZE i = 0; i < nMatCount; i++) { - if (!pMat->IsString(i, 0)) + if (!(HLookup ? pMat->IsString(i, 0) : pMat->IsString(0, i))) { - if (pMat->GetDouble(i,0) == rEntry.nVal) + if ((HLookup ? pMat->GetDouble(i,0) : pMat->GetDouble(0,i)) == rEntry.nVal) { nDelta = i; i = nMatCount + 1; @@ -5385,12 +5381,17 @@ void ScInterpreter::ScHLookup() } if ( nDelta != SCSIZE_MAX ) { - if (!pMat->IsString( nDelta, static_cast<SCSIZE>(nZIndex))) - PushDouble(pMat->GetDouble( nDelta, - static_cast<SCSIZE>(nZIndex))); + SCSIZE nX = static_cast<SCSIZE>(nSpIndex); + SCSIZE nY = nDelta; + if ( HLookup ) + { + nX = nDelta; + nY = static_cast<SCSIZE>(nZIndex); + } + if ( pMat->IsString( nX, nY) ) + PushString(pMat->GetString( nX,nY)); else - PushString(pMat->GetString( nDelta, - static_cast<SCSIZE>(nZIndex))); + PushDouble(pMat->GetDouble( nX,nY)); } else PushNA(); @@ -5400,24 +5401,36 @@ void ScInterpreter::ScHLookup() rEntry.nField = nCol1; BOOL bFound = FALSE; SCCOL nCol = 0; + SCROW nRow = 0; if ( bSorted ) rEntry.eOp = SC_LESS_EQUAL; - ScQueryCellIterator aCellIter(pDok, nTab1, rParam, FALSE); - // advance Entry.nField in Iterator upon switching columns - aCellIter.SetAdvanceQueryParamEntryField( TRUE ); - if ( bSorted ) + if ( HLookup ) { - SCROW nRow; - bFound = aCellIter.FindEqualOrSortedLastInRange( nCol, nRow ); - } - else if ( aCellIter.GetFirst() ) + ScQueryCellIterator aCellIter(pDok, nTab1, rParam, FALSE); + // advance Entry.nField in Iterator upon switching columns + aCellIter.SetAdvanceQueryParamEntryField( TRUE ); + if ( bSorted ) + { + SCROW nRow1_temp; + bFound = aCellIter.FindEqualOrSortedLastInRange( nCol, nRow1_temp ); + } + else if ( aCellIter.GetFirst() ) + { + bFound = TRUE; + nCol = aCellIter.GetCol(); + } + nRow = nZIndex; + } // if ( HLookup ) + else { - bFound = TRUE; - nCol = aCellIter.GetCol(); + ScAddress aResultPos( nCol1, nRow1, nTab1); + bFound = LookupQueryWithCache( aResultPos, rParam); + nRow = aResultPos.Row(); + nCol = nSpIndex; } if ( bFound ) { - ScAddress aAdr( nCol, nZIndex, nTab1 ); + ScAddress aAdr( nCol, nRow, nTab1 ); PushCellResultToken( true, aAdr, NULL, NULL); } else @@ -5429,243 +5442,74 @@ void ScInterpreter::ScHLookup() } } - -void ScInterpreter::ScVLookup() +bool ScInterpreter::FillEntry(ScQueryEntry& rEntry) { - BYTE nParamCount = GetByte(); - if ( MustHaveParamCount( nParamCount, 3, 4 ) ) + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::FillEntry" ); + switch ( GetStackType() ) { - BOOL bSorted; - if (nParamCount == 4) - bSorted = GetBool(); - else - bSorted = TRUE; - double fIndex = ::rtl::math::approxFloor( GetDouble() ) - 1.0; - ScMatrixRef pMat = NULL; - SCSIZE nC = 0, nR = 0; - SCCOL nCol1 = 0; - SCROW nRow1 = 0; - SCTAB nTab1 = 0; - SCCOL nCol2 = 0; - SCROW nRow2 = 0; - SCTAB nTab2; - if (GetStackType() == svDoubleRef) - { - PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); - if (nTab1 != nTab2) - { - PushIllegalParameter(); - return; - } - } - else if (GetStackType() == svMatrix) - { - pMat = PopMatrix(); - if (pMat) - pMat->GetDimensions(nC, nR); - else - { - PushIllegalParameter(); - return; - } - } - else + case svDouble: { - PushIllegalParameter(); - return; + rEntry.bQueryByString = FALSE; + rEntry.nVal = GetDouble(); } - if ( fIndex < 0.0 || (pMat ? (fIndex >= nC) : (fIndex+nCol1 > nCol2)) ) + break; + case svString: { - PushIllegalArgument(); - return; + const String sStr = GetString(); + rEntry.bQueryByString = TRUE; + *rEntry.pStr = sStr; } - SCCOL nSpIndex = static_cast<SCCOL>(fIndex); - if (!pMat) - nSpIndex = sal::static_int_cast<SCCOL>( nSpIndex + nCol1 ); // value column - if (nGlobalError) - PushError( nGlobalError); - else + break; + case svDoubleRef : + case svSingleRef : { - String sStr; - ScQueryParam rParam; - rParam.nCol1 = nCol1; - rParam.nRow1 = nRow1; - rParam.nCol2 = nCol1; // nur in der ersten Spalte suchen - rParam.nRow2 = nRow2; - rParam.nTab = nTab1; - rParam.bMixedComparison = TRUE; - - ScQueryEntry& rEntry = rParam.GetEntry(0); - rEntry.bDoQuery = TRUE; - if ( bSorted ) - rEntry.eOp = SC_LESS_EQUAL; - switch ( GetStackType() ) + ScAddress aAdr; + if ( !PopDoubleRefOrSingleRef( aAdr ) ) { - case svDouble: - { - rEntry.bQueryByString = FALSE; - rEntry.nVal = GetDouble(); - } - break; - case svString: - { - sStr = GetString(); - rEntry.bQueryByString = TRUE; - *rEntry.pStr = sStr; - } - break; - case svDoubleRef : - case svSingleRef : - { - ScAddress aAdr; - if ( !PopDoubleRefOrSingleRef( aAdr ) ) - { - PushInt(0); - return ; - } - ScBaseCell* pCell = GetCell( aAdr ); - if (HasCellValueData(pCell)) - { - rEntry.bQueryByString = FALSE; - rEntry.nVal = GetCellValue( aAdr, pCell ); - } - else - { - if ( GetCellType( pCell ) == CELLTYPE_NOTE ) - { - rEntry.bQueryByString = FALSE; - rEntry.nVal = 0.0; - } - else - { - GetCellString(sStr, pCell); - rEntry.bQueryByString = TRUE; - *rEntry.pStr = sStr; - } - } - } - break; - case svMatrix : - { - ScMatValType nType = GetDoubleOrStringFromMatrix( - rEntry.nVal, *rEntry.pStr); - rEntry.bQueryByString = ScMatrix::IsNonValueType( nType); - } - break; - default: - { - PushIllegalParameter(); - return; - } + PushInt(0); + return false; } - if ( rEntry.bQueryByString ) - rParam.bRegExp = MayBeRegExp( *rEntry.pStr, pDok ); - if (pMat) + ScBaseCell* pCell = GetCell( aAdr ); + if (HasCellValueData(pCell)) { -//!!!!!!! -//! TODO: enable caching on matrix? -//!!!!!!! - SCSIZE nMatCount = nR; - SCSIZE nDelta = SCSIZE_MAX; - if (rEntry.bQueryByString) - { -//!!!!!!! -//! TODO: enable regex on matrix strings -//!!!!!!! - String aParamStr = *rEntry.pStr; - if ( bSorted ) - { - for (SCSIZE i = 0; i < nMatCount; i++) - { - if (pMat->IsString(0, i)) - { - sal_Int32 nRes = - ScGlobal::pCollator->compareString( - pMat->GetString(0,i), aParamStr); - if (nRes <= 0) - nDelta = i; - else if (i>0) // #i2168# ignore first mismatch - i = nMatCount+1; - } - else - nDelta = i; - } - } - else - { - for (SCSIZE i = 0; i < nMatCount; i++) - { - if (pMat->IsString(0, i)) - { - if ( ScGlobal::pTransliteration->isEqual( - pMat->GetString(0,i), aParamStr ) ) - { - nDelta = i; - i = nMatCount + 1; - } - } - } - } - } - else - { - if ( bSorted ) - { - // #i2168# ignore strings - for (SCSIZE i = 0; i < nMatCount; i++) - { - if (!pMat->IsString(0, i)) - { - if (pMat->GetDouble(0,i) <= rEntry.nVal) - nDelta = i; - else - i = nMatCount+1; - } - } - } - else - { - for (SCSIZE i = 0; i < nMatCount; i++) - { - if (!pMat->IsString(0, i)) - { - if (pMat->GetDouble(0,i) == rEntry.nVal) - { - nDelta = i; - i = nMatCount + 1; - } - } - } - } - } - if ( nDelta != SCSIZE_MAX ) - { - if (!pMat->IsString( static_cast<SCSIZE>(nSpIndex), nDelta)) - PushDouble( pMat->GetDouble( - static_cast<SCSIZE>(nSpIndex), nDelta)); - else - PushString( pMat->GetString( - static_cast<SCSIZE>(nSpIndex), nDelta)); - } - else - PushNA(); + rEntry.bQueryByString = FALSE; + rEntry.nVal = GetCellValue( aAdr, pCell ); } else { - rEntry.nField = nCol1; - if ( bSorted ) - rEntry.eOp = SC_LESS_EQUAL; - ScAddress aResultPos( nCol1, nRow1, nTab1); - if (LookupQueryWithCache( aResultPos, rParam)) + if ( GetCellType( pCell ) == CELLTYPE_NOTE ) { - ScAddress aAdr( nSpIndex, aResultPos.Row(), nTab1 ); - PushCellResultToken( true, aAdr, NULL, NULL); + rEntry.bQueryByString = FALSE; + rEntry.nVal = 0.0; } else - PushNA(); + { + String sStr; + GetCellString(sStr, pCell); + rEntry.bQueryByString = TRUE; + *rEntry.pStr = sStr; + } } } - } + break; + case svMatrix : + { + const ScMatValType nType = GetDoubleOrStringFromMatrix(rEntry.nVal, *rEntry.pStr); + rEntry.bQueryByString = ScMatrix::IsNonValueType( nType); + } + break; + default: + { + PushIllegalParameter(); + return false; + } + } // switch ( GetStackType() ) + return true; +} +void ScInterpreter::ScVLookup() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScVLookup" ); + CalculateLookup(FALSE); } #if defined(WIN) && defined(MSC) @@ -5674,11 +5518,12 @@ void ScInterpreter::ScVLookup() void ScInterpreter::ScSubTotal() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSubTotal" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCountMin( nParamCount, 2 ) ) { // We must fish the 1st parameter deep from the stack! And push it on top. - const ScToken* p = pStack[ sp - nParamCount ]; + const FormulaToken* p = pStack[ sp - nParamCount ]; PushTempToken( *p ); int nFunc = (int) ::rtl::math::approxFloor( GetDouble() ); if( nFunc < 1 || nFunc > 11 ) @@ -5718,6 +5563,7 @@ void ScInterpreter::ScSubTotal() BOOL ScInterpreter::GetDBParams(SCTAB& rTab, ScQueryParam& rParam, BOOL& rMissingField ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetDBParams" ); BOOL bRet = FALSE; BOOL bAllowMissingField = FALSE; if ( rMissingField ) @@ -5886,6 +5732,7 @@ BOOL ScInterpreter::GetDBParams(SCTAB& rTab, ScQueryParam& rParam, void ScInterpreter::DBIterator( ScIterFunc eFunc ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::DBIterator" ); SCTAB nTab1; double nErg = 0.0; double fMem = 0.0; @@ -5948,12 +5795,14 @@ void ScInterpreter::DBIterator( ScIterFunc eFunc ) void ScInterpreter::ScDBSum() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDBSum" ); DBIterator( ifSUM ); } void ScInterpreter::ScDBCount() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDBCount" ); SCTAB nTab; ScQueryParam aQueryParam; BOOL bMissingField = TRUE; @@ -6002,6 +5851,7 @@ void ScInterpreter::ScDBCount() void ScInterpreter::ScDBCount2() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDBCount2" ); SCTAB nTab; ScQueryParam aQueryParam; BOOL bMissingField = TRUE; @@ -6025,30 +5875,35 @@ void ScInterpreter::ScDBCount2() void ScInterpreter::ScDBAverage() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDBAverage" ); DBIterator( ifAVERAGE ); } void ScInterpreter::ScDBMax() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDBMax" ); DBIterator( ifMAX ); } void ScInterpreter::ScDBMin() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDBMin" ); DBIterator( ifMIN ); } void ScInterpreter::ScDBProduct() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDBProduct" ); DBIterator( ifPRODUCT ); } void ScInterpreter::GetDBStVarParams( double& rVal, double& rValCount ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetDBStVarParams" ); std::vector<double> values; double vSum = 0.0; double vMean = 0.0; @@ -6089,6 +5944,7 @@ void ScInterpreter::GetDBStVarParams( double& rVal, double& rValCount ) void ScInterpreter::ScDBStdDev() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDBStdDev" ); double fVal, fCount; GetDBStVarParams( fVal, fCount ); PushDouble( sqrt(fVal/(fCount-1))); @@ -6097,6 +5953,7 @@ void ScInterpreter::ScDBStdDev() void ScInterpreter::ScDBStdDevP() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDBStdDevP" ); double fVal, fCount; GetDBStVarParams( fVal, fCount ); PushDouble( sqrt(fVal/fCount)); @@ -6105,6 +5962,7 @@ void ScInterpreter::ScDBStdDevP() void ScInterpreter::ScDBVar() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDBVar" ); double fVal, fCount; GetDBStVarParams( fVal, fCount ); PushDouble(fVal/(fCount-1)); @@ -6113,6 +5971,7 @@ void ScInterpreter::ScDBVar() void ScInterpreter::ScDBVarP() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDBVarP" ); double fVal, fCount; GetDBStVarParams( fVal, fCount ); PushDouble(fVal/fCount); @@ -6121,19 +5980,19 @@ void ScInterpreter::ScDBVarP() void ScInterpreter::ScIndirect() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIndirect" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 1, 2 ) ) { bool bTryXlA1 = true; // whether to try XL_A1 style as well. - ScAddress::Convention eConv = ScAddress::CONV_OOO; + FormulaGrammar::AddressConvention eConv = FormulaGrammar::CONV_OOO; if (nParamCount == 2 && 0.0 == ::rtl::math::approxFloor( GetDouble())) { - eConv = ScAddress::CONV_XL_R1C1; + eConv = FormulaGrammar::CONV_XL_R1C1; bTryXlA1 = false; } - const ScAddress::Details aDetails( eConv, aPos ); - const ScAddress::Details aDetailsXlA1( ScAddress::CONV_XL_A1, aPos ); + const ScAddress::Details aDetailsXlA1( FormulaGrammar::CONV_XL_A1, aPos ); SCTAB nTab = aPos.Tab(); String sRefStr( GetString() ); ScRefAddress aRefAd, aRefAd2; @@ -6199,6 +6058,7 @@ void ScInterpreter::ScIndirect() void ScInterpreter::ScAddressFunc() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScAddressFunc" ); String sTabStr; BYTE nParamCount = GetByte(); @@ -6208,9 +6068,9 @@ void ScInterpreter::ScAddressFunc() if( nParamCount >= 5 ) sTabStr = GetString(); - ScAddress::Convention eConv = ScAddress::CONV_OOO; // default + FormulaGrammar::AddressConvention eConv = FormulaGrammar::CONV_OOO; // default if( nParamCount >= 4 && 0.0 == ::rtl::math::approxFloor( GetDoubleWithDefault( 1.0))) - eConv = ScAddress::CONV_XL_R1C1; + eConv = FormulaGrammar::CONV_XL_R1C1; USHORT nFlags = SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE; // default if( nParamCount >= 3 ) @@ -6236,7 +6096,7 @@ void ScInterpreter::ScAddressFunc() SCCOL nCol = (SCCOL) ::rtl::math::approxFloor(GetDouble()); SCROW nRow = (SCROW) ::rtl::math::approxFloor(GetDouble()); - if( eConv == ScAddress::CONV_XL_R1C1 ) + if( eConv == FormulaGrammar::CONV_XL_R1C1 ) { // YUCK! The XL interface actually treats rel R1C1 refs differently // than A1 @@ -6262,7 +6122,7 @@ void ScInterpreter::ScAddressFunc() if( nParamCount >= 5 ) { ScCompiler::CheckTabQuotes( sTabStr, eConv); - sTabStr += static_cast<sal_Unicode>(eConv == ScAddress::CONV_XL_R1C1 ? '!' : '.'); + sTabStr += static_cast<sal_Unicode>(eConv == FormulaGrammar::CONV_XL_R1C1 ? '!' : '.'); sTabStr += aRefStr; PushString( sTabStr ); } @@ -6273,6 +6133,7 @@ void ScInterpreter::ScAddressFunc() void ScInterpreter::ScOffset() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScOffset" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 3, 5 ) ) { @@ -6348,6 +6209,7 @@ void ScInterpreter::ScOffset() void ScInterpreter::ScIndex() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIndex" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 1, 4 ) ) { @@ -6368,7 +6230,7 @@ void ScInterpreter::ScIndex() else nRow = 0; if (GetStackType() == svRefList) - nAreaCount = (sp ? pStack[sp-1]->GetRefList()->size() : 0); + nAreaCount = (sp ? static_cast<ScToken*>(pStack[sp-1])->GetRefList()->size() : 0); else nAreaCount = 1; // one reference or array or whatever if (nAreaCount == 0 || (size_t)nArea > nAreaCount) @@ -6488,14 +6350,14 @@ void ScInterpreter::ScIndex() BOOL bRowArray = FALSE; if (GetStackType() == svRefList) { - ScTokenRef xRef = PopToken(); + FormulaTokenRef xRef = PopToken(); if (nGlobalError || !xRef) { PushIllegalParameter(); return; } ScRange aRange( ScAddress::UNINITIALIZED); - DoubleRefToRange( (*(xRef->GetRefList()))[nArea-1], aRange); + DoubleRefToRange( (*(static_cast<ScToken*>(xRef.get())->GetRefList()))[nArea-1], aRange); aRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); if ( nParamCount == 2 && nRow1 == nRow2 ) bRowArray = TRUE; @@ -6553,6 +6415,7 @@ void ScInterpreter::ScIndex() void ScInterpreter::ScMultiArea() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMultiArea" ); // Legacy support, convert to RefList BYTE nParamCount = GetByte(); if (MustHaveParamCountMin( nParamCount, 1)) @@ -6567,6 +6430,7 @@ void ScInterpreter::ScMultiArea() void ScInterpreter::ScAreas() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScAreas" ); BYTE nParamCount = GetByte(); if (MustHaveParamCount( nParamCount, 1)) { @@ -6575,23 +6439,23 @@ void ScInterpreter::ScAreas() { case svSingleRef: { - ScTokenRef xT = PopToken(); - ValidateRef( xT->GetSingleRef()); + FormulaTokenRef xT = PopToken(); + ValidateRef( static_cast<ScToken*>(xT.get())->GetSingleRef()); ++nCount; } break; case svDoubleRef: { - ScTokenRef xT = PopToken(); - ValidateRef( xT->GetDoubleRef()); + FormulaTokenRef xT = PopToken(); + ValidateRef( static_cast<ScToken*>(xT.get())->GetDoubleRef()); ++nCount; } break; case svRefList: { - ScTokenRef xT = PopToken(); - ValidateRef( *(xT->GetRefList())); - nCount += xT->GetRefList()->size(); + FormulaTokenRef xT = PopToken(); + ValidateRef( *(static_cast<ScToken*>(xT.get())->GetRefList())); + nCount += static_cast<ScToken*>(xT.get())->GetRefList()->size(); } break; default: @@ -6604,6 +6468,7 @@ void ScInterpreter::ScAreas() void ScInterpreter::ScCurrency() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCurrency" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 1, 2 ) ) { @@ -6664,6 +6529,7 @@ void ScInterpreter::ScCurrency() void ScInterpreter::ScReplace() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScReplace" ); if ( MustHaveParamCount( GetByte(), 4 ) ) { String aNewStr( GetString() ); @@ -6685,6 +6551,7 @@ void ScInterpreter::ScReplace() void ScInterpreter::ScFixed() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScFixed" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 1, 3 ) ) { @@ -6744,6 +6611,7 @@ void ScInterpreter::ScFixed() void ScInterpreter::ScFind() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScFind" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 2, 3 ) ) { @@ -6769,6 +6637,7 @@ void ScInterpreter::ScFind() void ScInterpreter::ScExact() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScExact" ); nFuncFmtType = NUMBERFORMAT_LOGICAL; if ( MustHaveParamCount( GetByte(), 2 ) ) { @@ -6781,6 +6650,7 @@ void ScInterpreter::ScExact() void ScInterpreter::ScLeft() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLeft" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 1, 2 ) ) { @@ -6807,6 +6677,7 @@ void ScInterpreter::ScLeft() void ScInterpreter::ScRight() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRight" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 1, 2 ) ) { @@ -6834,6 +6705,7 @@ void ScInterpreter::ScRight() void ScInterpreter::ScSearch() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSearch" ); double fAnz; BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 2, 3 ) ) @@ -6874,6 +6746,7 @@ void ScInterpreter::ScSearch() void ScInterpreter::ScMid() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMid" ); if ( MustHaveParamCount( GetByte(), 3 ) ) { double fAnz = ::rtl::math::approxFloor(GetDouble()); @@ -6889,6 +6762,7 @@ void ScInterpreter::ScMid() void ScInterpreter::ScText() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScText" ); if ( MustHaveParamCount( GetByte(), 2 ) ) { String sFormatString = GetString(); @@ -6914,6 +6788,7 @@ void ScInterpreter::ScText() void ScInterpreter::ScSubstitute() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSubstitute" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 3, 4 ) ) { @@ -6968,6 +6843,7 @@ void ScInterpreter::ScSubstitute() void ScInterpreter::ScRept() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRept" ); if ( MustHaveParamCount( GetByte(), 2 ) ) { double fAnz = ::rtl::math::approxFloor(GetDouble()); @@ -7000,6 +6876,7 @@ void ScInterpreter::ScRept() void ScInterpreter::ScConcat() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScConcat" ); BYTE nParamCount = GetByte(); String aRes; while( nParamCount-- > 0) @@ -7013,6 +6890,7 @@ void ScInterpreter::ScConcat() void ScInterpreter::ScErrorType() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScErrorType" ); USHORT nErr; USHORT nOldError = nGlobalError; nGlobalError = 0; @@ -7020,12 +6898,12 @@ void ScInterpreter::ScErrorType() { case svRefList : { - ScTokenRef x = PopToken(); + FormulaTokenRef x = PopToken(); if (nGlobalError) nErr = nGlobalError; else { - const ScRefList* pRefList = x->GetRefList(); + const ScRefList* pRefList = static_cast<ScToken*>(x.get())->GetRefList(); size_t n = pRefList->size(); if (!n) nErr = errNoRef; @@ -7094,6 +6972,7 @@ void ScInterpreter::ScErrorType() BOOL ScInterpreter::MayBeRegExp( const String& rStr, const ScDocument* pDoc ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::MayBeRegExp" ); if ( pDoc && !pDoc->GetDocOptions().IsFormulaRegexEnabled() ) return FALSE; if ( !rStr.Len() || (rStr.Len() == 1 && rStr.GetChar(0) != '.') ) @@ -7163,6 +7042,7 @@ static struct LookupCacheDebugCounter bool ScInterpreter::LookupQueryWithCache( ScAddress & o_rResultPos, const ScQueryParam & rParam ) const { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::LookupQueryWithCache" ); bool bFound = false; const ScQueryEntry& rEntry = rParam.GetEntry(0); bool bColumnsMatch = (rParam.nCol1 == rEntry.nField); diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 26e41b0df46f..e511e0876b71 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: interpr2.cxx,v $ - * $Revision: 1.37.100.3 $ + * $Revision: 1.38 $ * * This file is part of OpenOffice.org. * @@ -38,6 +38,7 @@ #include <sfx2/objsh.hxx> #include <svtools/stritem.hxx> #include <svtools/zforlist.hxx> +#include <rtl/logfile.hxx> #include "interpre.hxx" #include "attrib.hxx" @@ -58,6 +59,7 @@ #include <string.h> #include <math.h> +using namespace formula; // STATIC DATA ----------------------------------------------------------- #define D_TIMEFACTOR 86400.0 @@ -69,6 +71,7 @@ double ScInterpreter::GetDate(INT16 nYear, INT16 nMonth, INT16 nDay) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetDate" ); if ( nYear < 100 ) nYear = pFormatter->ExpandTwoDigitYear( nYear ); INT16 nY, nM; @@ -99,6 +102,7 @@ double ScInterpreter::GetDate(INT16 nYear, INT16 nMonth, INT16 nDay) void ScInterpreter::ScGetActDate() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetActDate" ); nFuncFmtType = NUMBERFORMAT_DATE; Date aActDate; long nDiff = aActDate - *(pFormatter->GetNullDate()); @@ -107,6 +111,7 @@ void ScInterpreter::ScGetActDate() void ScInterpreter::ScGetActTime() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetActTime" ); nFuncFmtType = NUMBERFORMAT_DATETIME; Date aActDate; long nDiff = aActDate - *(pFormatter->GetNullDate()); @@ -120,6 +125,7 @@ void ScInterpreter::ScGetActTime() void ScInterpreter::ScGetYear() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetYear" ); Date aDate = *(pFormatter->GetNullDate()); aDate += (long) ::rtl::math::approxFloor(GetDouble()); PushDouble( (double) aDate.GetYear() ); @@ -127,6 +133,7 @@ void ScInterpreter::ScGetYear() void ScInterpreter::ScGetMonth() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetMonth" ); Date aDate = *(pFormatter->GetNullDate()); aDate += (long) ::rtl::math::approxFloor(GetDouble()); PushDouble( (double) aDate.GetMonth() ); @@ -134,6 +141,7 @@ void ScInterpreter::ScGetMonth() void ScInterpreter::ScGetDay() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetDay" ); Date aDate = *(pFormatter->GetNullDate()); aDate += (long)::rtl::math::approxFloor(GetDouble()); PushDouble((double) aDate.GetDay()); @@ -141,6 +149,7 @@ void ScInterpreter::ScGetDay() void ScInterpreter::ScGetMin() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetMin" ); double fTime = GetDouble(); fTime -= ::rtl::math::approxFloor(fTime); // Datumsanteil weg long nVal = (long)::rtl::math::approxFloor(fTime*D_TIMEFACTOR+0.5) % 3600; @@ -149,6 +158,7 @@ void ScInterpreter::ScGetMin() void ScInterpreter::ScGetSec() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetSec" ); double fTime = GetDouble(); fTime -= ::rtl::math::approxFloor(fTime); // Datumsanteil weg long nVal = (long)::rtl::math::approxFloor(fTime*D_TIMEFACTOR+0.5) % 60; @@ -157,6 +167,7 @@ void ScInterpreter::ScGetSec() void ScInterpreter::ScGetHour() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetHour" ); double fTime = GetDouble(); fTime -= ::rtl::math::approxFloor(fTime); // Datumsanteil weg long nVal = (long)::rtl::math::approxFloor(fTime*D_TIMEFACTOR+0.5) / 3600; @@ -165,6 +176,7 @@ void ScInterpreter::ScGetHour() void ScInterpreter::ScGetDateValue() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetDateValue" ); String aInputString = GetString(); sal_uInt32 nFIndex = 0; // damit default Land/Spr. double fVal; @@ -182,6 +194,7 @@ void ScInterpreter::ScGetDateValue() void ScInterpreter::ScGetDayOfWeek() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetDayOfWeek" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 1, 2 ) ) { @@ -209,6 +222,7 @@ void ScInterpreter::ScGetDayOfWeek() void ScInterpreter::ScGetWeekOfYear() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetWeekOfYear" ); if ( MustHaveParamCount( GetByte(), 2 ) ) { short nFlag = (short) ::rtl::math::approxFloor(GetDouble()); @@ -221,6 +235,7 @@ void ScInterpreter::ScGetWeekOfYear() void ScInterpreter::ScEasterSunday() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScEasterSunday" ); nFuncFmtType = NUMBERFORMAT_DATE; if ( MustHaveParamCount( GetByte(), 1 ) ) { @@ -251,6 +266,7 @@ void ScInterpreter::ScEasterSunday() void ScInterpreter::ScGetDate() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetDate" ); nFuncFmtType = NUMBERFORMAT_DATE; if ( MustHaveParamCount( GetByte(), 3 ) ) { @@ -268,6 +284,7 @@ void ScInterpreter::ScGetDate() void ScInterpreter::ScGetTime() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetTime" ); nFuncFmtType = NUMBERFORMAT_TIME; if ( MustHaveParamCount( GetByte(), 3 ) ) { @@ -280,6 +297,7 @@ void ScInterpreter::ScGetTime() void ScInterpreter::ScGetDiffDate() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetDiffDate" ); if ( MustHaveParamCount( GetByte(), 2 ) ) { double nDate2 = GetDouble(); @@ -290,6 +308,7 @@ void ScInterpreter::ScGetDiffDate() void ScInterpreter::ScGetDiffDate360() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetDiffDate360" ); /* Implementation follows * http://www.bondmarkets.com/eCommerce/SMD_Fields_030802.pdf * Appendix B: Day-Count Bases, there are 7 different ways to calculate the @@ -384,6 +403,7 @@ void ScInterpreter::ScGetDiffDate360() void ScInterpreter::ScGetTimeValue() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetTimeValue" ); String aInputString = GetString(); sal_uInt32 nFIndex = 0; // damit default Land/Spr. double fVal; @@ -405,6 +425,7 @@ void ScInterpreter::ScGetTimeValue() void ScInterpreter::ScPlusMinus() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScPlusMinus" ); double nVal = GetDouble(); short n = 0; if (nVal < 0.0) @@ -416,17 +437,20 @@ void ScInterpreter::ScPlusMinus() void ScInterpreter::ScAbs() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScAbs" ); PushDouble(fabs(GetDouble())); } void ScInterpreter::ScInt() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScInt" ); PushDouble(::rtl::math::approxFloor(GetDouble())); } void ScInterpreter::RoundNumber( rtl_math_RoundingMode eMode ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::RoundNumber" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 1, 2 ) ) { @@ -447,21 +471,25 @@ void ScInterpreter::RoundNumber( rtl_math_RoundingMode eMode ) void ScInterpreter::ScRound() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRound" ); RoundNumber( rtl_math_RoundingMode_Corrected ); } void ScInterpreter::ScRoundDown() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRoundDown" ); RoundNumber( rtl_math_RoundingMode_Down ); } void ScInterpreter::ScRoundUp() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRoundUp" ); RoundNumber( rtl_math_RoundingMode_Up ); } void ScInterpreter::ScCeil() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCeil" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 2, 3 ) ) { @@ -484,6 +512,7 @@ void ScInterpreter::ScCeil() void ScInterpreter::ScFloor() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScFloor" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 2, 3 ) ) { @@ -506,6 +535,7 @@ void ScInterpreter::ScFloor() void ScInterpreter::ScEven() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScEven" ); double fVal = GetDouble(); if (fVal < 0.0) PushDouble(::rtl::math::approxFloor(fVal/2.0) * 2.0); @@ -515,6 +545,7 @@ void ScInterpreter::ScEven() void ScInterpreter::ScOdd() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScOdd" ); double fVal = GetDouble(); if (fVal >= 0.0) { @@ -533,6 +564,7 @@ void ScInterpreter::ScOdd() void ScInterpreter::ScArcTan2() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScArcTan2" ); if ( MustHaveParamCount( GetByte(), 2 ) ) { double nVal2 = GetDouble(); @@ -543,6 +575,7 @@ void ScInterpreter::ScArcTan2() void ScInterpreter::ScLog() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLog" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 1, 2 ) ) { @@ -561,6 +594,7 @@ void ScInterpreter::ScLog() void ScInterpreter::ScLn() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLn" ); double fVal = GetDouble(); if (fVal > 0.0) PushDouble(log(fVal)); @@ -570,6 +604,7 @@ void ScInterpreter::ScLn() void ScInterpreter::ScLog10() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLog10" ); double fVal = GetDouble(); if (fVal > 0.0) PushDouble(log10(fVal)); @@ -579,16 +614,17 @@ void ScInterpreter::ScLog10() void ScInterpreter::ScNPV() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScNPV" ); nFuncFmtType = NUMBERFORMAT_CURRENCY; short nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 2, 31 ) ) { double nVal = 0.0; // Wir drehen den Stack um!! - ScToken* pTemp[ 31 ]; + FormulaToken* pTemp[ 31 ]; for( short i = 0; i < nParamCount; i++ ) pTemp[ i ] = pStack[ sp - i - 1 ]; - memcpy( &pStack[ sp - nParamCount ], pTemp, nParamCount * sizeof( ScToken* ) ); + memcpy( &pStack[ sp - nParamCount ], pTemp, nParamCount * sizeof( FormulaToken* ) ); if (nGlobalError == 0) { double nCount = 1.0; @@ -646,6 +682,7 @@ void ScInterpreter::ScNPV() void ScInterpreter::ScIRR() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIRR" ); double fSchaetzwert; nFuncFmtType = NUMBERFORMAT_PERCENT; BYTE nParamCount = GetByte(); @@ -788,6 +825,7 @@ void ScInterpreter::ScISPMT() double ScInterpreter::ScGetBw(double fZins, double fZzr, double fRmz, double fZw, double fF) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMIRR" ); double fBw; if (fZins == 0.0) fBw = fZw + fRmz * fZzr; @@ -803,6 +841,7 @@ double ScInterpreter::ScGetBw(double fZins, double fZzr, double fRmz, void ScInterpreter::ScBW() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScBW" ); nFuncFmtType = NUMBERFORMAT_CURRENCY; double nRmz, nZzr, nZins, nZw = 0, nFlag = 0; BYTE nParamCount = GetByte(); @@ -820,6 +859,7 @@ void ScInterpreter::ScBW() void ScInterpreter::ScDIA() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDIA" ); nFuncFmtType = NUMBERFORMAT_CURRENCY; if ( MustHaveParamCount( GetByte(), 4 ) ) { @@ -836,6 +876,7 @@ void ScInterpreter::ScDIA() double ScInterpreter::ScGetGDA(double fWert, double fRest, double fDauer, double fPeriode, double fFaktor) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetGDA" ); double fGda, fZins, fAlterWert, fNeuerWert; fZins = fFaktor / fDauer; if (fZins >= 1.0) @@ -861,6 +902,7 @@ double ScInterpreter::ScGetGDA(double fWert, double fRest, double fDauer, void ScInterpreter::ScGDA() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGDA" ); nFuncFmtType = NUMBERFORMAT_CURRENCY; BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 4, 5 ) ) @@ -884,6 +926,7 @@ void ScInterpreter::ScGDA() void ScInterpreter::ScGDA2() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGDA2" ); nFuncFmtType = NUMBERFORMAT_CURRENCY; BYTE nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 4, 5 ) ) @@ -930,6 +973,7 @@ void ScInterpreter::ScGDA2() double ScInterpreter::ScInterVDB(double fWert,double fRest,double fDauer, double fDauer1,double fPeriode,double fFaktor) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScInterVDB" ); double fVdb=0; double fIntEnd = ::rtl::math::approxCeil(fPeriode); ULONG nLoopEnd = (ULONG) fIntEnd; @@ -980,6 +1024,7 @@ inline double DblMin( double a, double b ) void ScInterpreter::ScVDB() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScVDB" ); nFuncFmtType = NUMBERFORMAT_CURRENCY; BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 5, 7 ) ) @@ -1056,6 +1101,7 @@ void ScInterpreter::ScVDB() void ScInterpreter::ScLaufz() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLaufz" ); if ( MustHaveParamCount( GetByte(), 3 ) ) { double nZukunft = GetDouble(); @@ -1067,6 +1113,7 @@ void ScInterpreter::ScLaufz() void ScInterpreter::ScLIA() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLIA" ); nFuncFmtType = NUMBERFORMAT_CURRENCY; if ( MustHaveParamCount( GetByte(), 3 ) ) { @@ -1080,6 +1127,7 @@ void ScInterpreter::ScLIA() double ScInterpreter::ScGetRmz(double fZins, double fZzr, double fBw, double fZw, double fF) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetRmz" ); double fRmz; if (fZins == 0.0) fRmz = (fBw + fZw) / fZzr; @@ -1098,6 +1146,7 @@ double ScInterpreter::ScGetRmz(double fZins, double fZzr, double fBw, void ScInterpreter::ScRMZ() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRMZ" ); double nZins, nZzr, nBw, nZw = 0, nFlag = 0; nFuncFmtType = NUMBERFORMAT_CURRENCY; BYTE nParamCount = GetByte(); @@ -1115,6 +1164,7 @@ void ScInterpreter::ScRMZ() void ScInterpreter::ScZGZ() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScZGZ" ); nFuncFmtType = NUMBERFORMAT_PERCENT; if ( MustHaveParamCount( GetByte(), 3 ) ) { @@ -1128,6 +1178,7 @@ void ScInterpreter::ScZGZ() double ScInterpreter::ScGetZw(double fZins, double fZzr, double fRmz, double fBw, double fF) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetZw" ); double fZw; if (fZins == 0.0) fZw = fBw + fRmz * fZzr; @@ -1144,6 +1195,7 @@ double ScInterpreter::ScGetZw(double fZins, double fZzr, double fRmz, void ScInterpreter::ScZW() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScZW" ); double nZins, nZzr, nRmz, nBw = 0, nFlag = 0; nFuncFmtType = NUMBERFORMAT_CURRENCY; BYTE nParamCount = GetByte(); @@ -1161,6 +1213,7 @@ void ScInterpreter::ScZW() void ScInterpreter::ScZZR() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScZZR" ); double nZins, nRmz, nBw, nZw = 0, nFlag = 0; BYTE nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 3, 5 ) ) @@ -1184,6 +1237,7 @@ void ScInterpreter::ScZZR() bool ScInterpreter::RateIteration( double fNper, double fPayment, double fPv, double fFv, double fPayType, double & fGuess ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::RateIteration" ); // See also #i15090# // Newton-Raphson method: x(i+1) = x(i) - f(x(i)) / f'(x(i)) // This solution handles integer and non-integer values of Nper different. @@ -1277,6 +1331,7 @@ bool ScInterpreter::RateIteration( double fNper, double fPayment, double fPv, // In Calc UI it is the function RATE(Nper;Pmt;Pv;Fv;Type;Guess) void ScInterpreter::ScZins() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScZins" ); double fPv, fPayment, fNper; // defaults for missing arguments, see ODFF spec double fFv = 0, fPayType = 0, fGuess = 0.1; @@ -1311,6 +1366,7 @@ void ScInterpreter::ScZins() double ScInterpreter::ScGetZinsZ(double fZins, double fZr, double fZzr, double fBw, double fZw, double fF, double& fRmz) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetZinsZ" ); fRmz = ScGetRmz(fZins, fZzr, fBw, fZw, fF); // fuer kapz auch bei fZr == 1 double fZinsZ; nFuncFmtType = NUMBERFORMAT_CURRENCY; @@ -1333,6 +1389,7 @@ double ScInterpreter::ScGetZinsZ(double fZins, double fZr, double fZzr, double f void ScInterpreter::ScZinsZ() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScZinsZ" ); double nZins, nZr, nRmz, nZzr, nBw, nZw = 0, nFlag = 0; nFuncFmtType = NUMBERFORMAT_CURRENCY; BYTE nParamCount = GetByte(); @@ -1354,6 +1411,7 @@ void ScInterpreter::ScZinsZ() void ScInterpreter::ScKapz() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScKapz" ); double nZins, nZr, nZzr, nBw, nZw = 0, nFlag = 0, nRmz, nZinsz; nFuncFmtType = NUMBERFORMAT_CURRENCY; BYTE nParamCount = GetByte(); @@ -1378,6 +1436,7 @@ void ScInterpreter::ScKapz() void ScInterpreter::ScKumZinsZ() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScKumZinsZ" ); nFuncFmtType = NUMBERFORMAT_CURRENCY; if ( MustHaveParamCount( GetByte(), 6 ) ) { @@ -1418,6 +1477,7 @@ void ScInterpreter::ScKumZinsZ() void ScInterpreter::ScKumKapZ() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScKumKapZ" ); nFuncFmtType = NUMBERFORMAT_CURRENCY; if ( MustHaveParamCount( GetByte(), 6 ) ) { @@ -1459,6 +1519,7 @@ void ScInterpreter::ScKumKapZ() void ScInterpreter::ScEffektiv() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScEffektiv" ); nFuncFmtType = NUMBERFORMAT_PERCENT; if ( MustHaveParamCount( GetByte(), 2 ) ) { @@ -1476,6 +1537,7 @@ void ScInterpreter::ScEffektiv() void ScInterpreter::ScNominal() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScNominal" ); nFuncFmtType = NUMBERFORMAT_PERCENT; if ( MustHaveParamCount( GetByte(), 2 ) ) { @@ -1493,6 +1555,7 @@ void ScInterpreter::ScNominal() void ScInterpreter::ScMod() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMod" ); if ( MustHaveParamCount( GetByte(), 2 ) ) { double nVal2 = GetDouble(); @@ -1519,6 +1582,7 @@ void ScInterpreter::ScMod() */ void ScInterpreter::ScBackSolver() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScBackSolver" ); if ( MustHaveParamCount( GetByte(), 3 ) ) { BOOL bDoneIteration = FALSE; @@ -1679,6 +1743,7 @@ void ScInterpreter::ScBackSolver() // Try a nice rounded input value if possible. const double fNiceDelta = (bDoneIteration && fabs(fBestX) >= 1e-3 ? 1e-3 : fDelta); double nX = ::rtl::math::approxFloor((fBestX / fNiceDelta) + 0.5) * fNiceDelta; +// double nX = ::rtl::math::approxFloor((fBestX / fDelta) + 0.5) * fDelta; if ( bDoneIteration ) { @@ -1726,27 +1791,33 @@ void ScInterpreter::ScBackSolver() void ScInterpreter::ScIntersect() { - ScTokenRef x2 = PopToken(); - ScTokenRef x1 = PopToken(); - if (nGlobalError || !x1 || !x2) + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIntersect" ); + formula::FormulaTokenRef p2nd = PopToken(); + formula::FormulaTokenRef p1st = PopToken(); + + if (nGlobalError || !p2nd || !p1st) { PushIllegalArgument(); return; - } - StackVar sv1 = x1->GetType(); - StackVar sv2 = x2->GetType(); + } // if (nGlobalError || !xT2 || !xT1) + + StackVar sv1 = p1st->GetType(); + StackVar sv2 = p2nd->GetType(); if ((sv1 != svSingleRef && sv1 != svDoubleRef && sv1 != svRefList) || (sv2 != svSingleRef && sv2 != svDoubleRef && sv2 != svRefList)) { PushIllegalArgument(); return; } + + ScToken* x1 = static_cast<ScToken*>(p1st.get()); + ScToken* x2 = static_cast<ScToken*>(p2nd.get()); if (sv1 == svRefList || sv2 == svRefList) { // Now this is a bit nasty but it simplifies things, and having // intersections with lists isn't too common, if at all.. // Convert a reference to list. - ScTokenRef xt[2] = { x1, x2 }; + ScToken* xt[2] = { x1, x2 }; StackVar sv[2] = { sv1, sv2 }; for (size_t i=0; i<2; ++i) { @@ -1868,39 +1939,48 @@ void ScInterpreter::ScIntersect() void ScInterpreter::ScRangeFunc() { - ScTokenRef x2 = PopToken(); - ScTokenRef x1 = PopToken(); - if (nGlobalError || !x1 || !x2) + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRangeFunc" ); + formula::FormulaTokenRef x2 = PopToken(); + formula::FormulaTokenRef x1 = PopToken(); + + if (nGlobalError || !x2 || !x1) { PushIllegalArgument(); return; - } - ScTokenRef xRes = ScToken::ExtendRangeReference( *x1, *x2, aPos, false); + } // if (nGlobalError || !xT2 || !xT1) + FormulaTokenRef xRes = ScToken::ExtendRangeReference( *x1, *x2, aPos, false); if (!xRes) PushIllegalArgument(); else PushTempToken( xRes); - return; } void ScInterpreter::ScUnionFunc() { - ScTokenRef x2 = PopToken(); - ScTokenRef x1 = PopToken(); - if (nGlobalError || !x1 || !x2) + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScUnionFunc" ); + formula::FormulaTokenRef p2nd = PopToken(); + formula::FormulaTokenRef p1st = PopToken(); + + if (nGlobalError || !p2nd || !p1st) { PushIllegalArgument(); return; - } - StackVar sv1 = x1->GetType(); - StackVar sv2 = x2->GetType(); + } // if (nGlobalError || !xT2 || !xT1) + + StackVar sv1 = p1st->GetType(); + StackVar sv2 = p2nd->GetType(); if ((sv1 != svSingleRef && sv1 != svDoubleRef && sv1 != svRefList) || - (sv2 != svSingleRef && sv2 != svDoubleRef && sv2 != svRefList)) + (sv2 != svSingleRef && sv2 != svDoubleRef && sv2 != svRefList)) { PushIllegalArgument(); return; } + + ScToken* x1 = static_cast<ScToken*>(p1st.get()); + ScToken* x2 = static_cast<ScToken*>(p2nd.get()); + + ScTokenRef xRes; // Append to an existing RefList if there is one. if (sv1 == svRefList) @@ -1951,13 +2031,13 @@ void ScInterpreter::ScUnionFunc() } ValidateRef( *pRes); // set #REF! if needed PushTempToken( xRes); - return; } void ScInterpreter::ScCurrent() { - ScTokenRef xTok( PopToken()); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCurrent" ); + FormulaTokenRef xTok( PopToken()); if (xTok) { PushTempToken( xTok); @@ -1969,6 +2049,7 @@ void ScInterpreter::ScCurrent() void ScInterpreter::ScStyle() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScStyle" ); BYTE nParamCount = GetByte(); if (nParamCount >= 1 && nParamCount <= 3) { @@ -2029,6 +2110,7 @@ ScDdeLink* lcl_GetDdeLink( SvxLinkManager* pLinkMgr, void ScInterpreter::ScDde() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDde" ); // Applikation, Datei, Bereich // Application, Topic, Item @@ -2334,103 +2416,6 @@ void ScInterpreter::ScConvert() } -BOOL lclConvertMoney( const String& aSearchUnit, double& rfRate, int& rnDec ) -{ - struct ConvertInfo - { - const sal_Char* pCurrText; - double fRate; - int nDec; - }; - ConvertInfo aConvertTable[] = { - { "EUR", 1.0, 2 }, - { "ATS", 13.7603, 2 }, - { "BEF", 40.3399, 0 }, - { "DEM", 1.95583, 2 }, - { "ESP", 166.386, 0 }, - { "FIM", 5.94573, 2 }, - { "FRF", 6.55957, 2 }, - { "IEP", 0.787564, 2 }, - { "ITL", 1936.27, 0 }, - { "LUF", 40.3399, 0 }, - { "NLG", 2.20371, 2 }, - { "PTE", 200.482, 2 }, - { "GRD", 340.750, 2 }, - { "SIT", 239.640, 2 }, - { "MTL", 0.429300, 2 }, - { "CYP", 0.585274, 2 } - }; - - const size_t nConversionCount = sizeof( aConvertTable ) / sizeof( aConvertTable[0] ); - for ( size_t i = 0; i < nConversionCount; i++ ) - if ( aSearchUnit.EqualsIgnoreCaseAscii( aConvertTable[i].pCurrText ) ) - { - rfRate = aConvertTable[i].fRate; - rnDec = aConvertTable[i].nDec; - return TRUE; - } - return FALSE; -} - -void ScInterpreter::ScEuroConvert() -{ //Value, FromUnit, ToUnit[, FullPrecision, [TriangulationPrecision]] - BYTE nParamCount = GetByte(); - if ( MustHaveParamCount( nParamCount, 3, 5 ) ) - { - double nPrecision = 0.0; - if ( nParamCount == 5 ) - { - nPrecision = ::rtl::math::approxFloor(GetDouble()); - if ( nPrecision < 3 ) - { - PushIllegalArgument(); - return; - } - } - BOOL bFullPrecision = FALSE; - if ( nParamCount >= 4 ) - bFullPrecision = GetBool(); - String aToUnit( GetString() ); - String aFromUnit( GetString() ); - double fVal = GetDouble(); - if ( nGlobalError ) - PushError( nGlobalError); - else - { - double fRes; - double fFromRate; - double fToRate; - int nFromDec; - int nToDec; - String aEur( RTL_CONSTASCII_USTRINGPARAM("EUR")); - if ( lclConvertMoney( aFromUnit, fFromRate, nFromDec ) - && lclConvertMoney( aToUnit, fToRate, nToDec ) ) - { - if ( aFromUnit.EqualsIgnoreCaseAscii( aToUnit ) ) - fRes = fVal; - else - { - if ( aFromUnit.EqualsIgnoreCaseAscii( aEur ) ) - fRes = fVal * fToRate; - else - { - double fIntermediate = fVal / fFromRate; - if ( nPrecision ) - fIntermediate = ::rtl::math::round( fIntermediate, - (int) nPrecision ); - fRes = fIntermediate * fToRate; - } - if ( !bFullPrecision ) - fRes = ::rtl::math::round( fRes, nToDec ); - } - PushDouble( fRes ); - } - else - PushIllegalArgument(); - } - } -} - void ScInterpreter::ScRoman() { // Value [Mode] BYTE nParamCount = GetByte(); @@ -2491,6 +2476,7 @@ void ScInterpreter::ScRoman() BOOL lcl_GetArabicValue( sal_Unicode cChar, USHORT& rnValue, BOOL& rbIsDec ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScBase" ); switch( cChar ) { case 'M': rnValue = 1000; rbIsDec = TRUE; break; @@ -2508,6 +2494,7 @@ BOOL lcl_GetArabicValue( sal_Unicode cChar, USHORT& rnValue, BOOL& rbIsDec ) void ScInterpreter::ScArabic() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScArabic" ); String aRoman( GetString() ); if( nGlobalError ) PushError( nGlobalError); @@ -2564,6 +2551,7 @@ void ScInterpreter::ScArabic() void ScInterpreter::ScHyperLink() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScHyperLink" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 1, 2 ) ) { @@ -2575,6 +2563,103 @@ void ScInterpreter::ScHyperLink() PushMatrix(pResMat); } } +BOOL lclConvertMoney( const String& aSearchUnit, double& rfRate, int& rnDec ) +{ + struct ConvertInfo + { + const sal_Char* pCurrText; + double fRate; + int nDec; + }; + ConvertInfo aConvertTable[] = { + { "EUR", 1.0, 2 }, + { "ATS", 13.7603, 2 }, + { "BEF", 40.3399, 0 }, + { "DEM", 1.95583, 2 }, + { "ESP", 166.386, 0 }, + { "FIM", 5.94573, 2 }, + { "FRF", 6.55957, 2 }, + { "IEP", 0.787564, 2 }, + { "ITL", 1936.27, 0 }, + { "LUF", 40.3399, 0 }, + { "NLG", 2.20371, 2 }, + { "PTE", 200.482, 2 }, + { "GRD", 340.750, 2 }, + { "SIT", 239.640, 2 }, + { "MTL", 0.429300, 2 }, + { "CYP", 0.585274, 2 } + }; + + const size_t nConversionCount = sizeof( aConvertTable ) / sizeof( aConvertTable[0] ); + for ( size_t i = 0; i < nConversionCount; i++ ) + if ( aSearchUnit.EqualsIgnoreCaseAscii( aConvertTable[i].pCurrText ) ) + { + rfRate = aConvertTable[i].fRate; + rnDec = aConvertTable[i].nDec; + return TRUE; + } + return FALSE; +} + +void ScInterpreter::ScEuroConvert() +{ //Value, FromUnit, ToUnit[, FullPrecision, [TriangulationPrecision]] + BYTE nParamCount = GetByte(); + if ( MustHaveParamCount( nParamCount, 3, 5 ) ) + { + double nPrecision = 0.0; + if ( nParamCount == 5 ) + { + nPrecision = ::rtl::math::approxFloor(GetDouble()); + if ( nPrecision < 3 ) + { + PushIllegalArgument(); + return; + } + } + BOOL bFullPrecision = FALSE; + if ( nParamCount >= 4 ) + bFullPrecision = GetBool(); + String aToUnit( GetString() ); + String aFromUnit( GetString() ); + double fVal = GetDouble(); + if ( nGlobalError ) + PushError( nGlobalError); + else + { + double fRes; + double fFromRate; + double fToRate; + int nFromDec; + int nToDec; + String aEur( RTL_CONSTASCII_USTRINGPARAM("EUR")); + if ( lclConvertMoney( aFromUnit, fFromRate, nFromDec ) + && lclConvertMoney( aToUnit, fToRate, nToDec ) ) + { + if ( aFromUnit.EqualsIgnoreCaseAscii( aToUnit ) ) + fRes = fVal; + else + { + if ( aFromUnit.EqualsIgnoreCaseAscii( aEur ) ) + fRes = fVal * fToRate; + else + { + double fIntermediate = fVal / fFromRate; + if ( nPrecision ) + fIntermediate = ::rtl::math::round( fIntermediate, + (int) nPrecision ); + fRes = fIntermediate * fToRate; + } + if ( !bFullPrecision ) + fRes = ::rtl::math::round( fRes, nToDec ); + } + PushDouble( fRes ); + } + else + PushIllegalArgument(); + } + } +} + // BAHTTEXT =================================================================== @@ -2701,6 +2786,7 @@ void lclAppendBlock( ByteString& rText, sal_Int32 nValue ) void ScInterpreter::ScBahtText() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScBahtText" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 1 ) ) { @@ -2769,6 +2855,7 @@ void ScInterpreter::ScBahtText() void ScInterpreter::ScGetPivotData() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGetPivotData" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 2, 30 ) ) diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index 246632a4c2e4..e596d4bf5b90 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -36,6 +36,7 @@ #include <tools/solar.h> #include <stdlib.h> #include <string.h> +#include <rtl/logfile.hxx> #include "interpre.hxx" #include "global.hxx" @@ -51,6 +52,7 @@ #include <algorithm> using ::std::vector; +using namespace formula; // STATIC DATA ----------------------------------------------------------- @@ -186,11 +188,13 @@ double lcl_IterateInverse( const ScDistFunc& rFunction, double fAx, double fBx, void ScInterpreter::ScNoName() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScNoName" ); PushError(errNoName); } void ScInterpreter::ScBadName() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScBadName" ); short nParamCount = GetByte(); while (nParamCount-- > 0) { @@ -201,11 +205,13 @@ void ScInterpreter::ScBadName() double ScInterpreter::phi(double x) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::phi" ); return 0.39894228040143268 * exp(-(x * x) / 2.0); } double ScInterpreter::taylor(double* pPolynom, USHORT nMax, double x) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::taylor" ); double nVal = pPolynom[nMax]; for (short i = nMax-1; i >= 0; i--) { @@ -216,6 +222,7 @@ double ScInterpreter::taylor(double* pPolynom, USHORT nMax, double x) double ScInterpreter::gauss(double x) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::gauss" ); double t0[] = { 0.39894228040143268, -0.06649038006690545, 0.00997355701003582, -0.00118732821548045, 0.00011543468761616, -0.00000944465625950, @@ -263,6 +270,7 @@ double ScInterpreter::gauss(double x) double ScInterpreter::gaussinv(double x) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::gaussinv" ); double q,t,z; q=x-0.5; @@ -434,6 +442,7 @@ double ScInterpreter::gaussinv(double x) double ScInterpreter::Fakultaet(double x) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::Fakultaet" ); x = ::rtl::math::approxFloor(x); if (x < 0.0) return 0.0; @@ -459,6 +468,7 @@ double ScInterpreter::Fakultaet(double x) double ScInterpreter::BinomKoeff(double n, double k) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::BinomKoeff" ); double nVal = 0.0; k = ::rtl::math::approxFloor(k); if (n < k) @@ -596,6 +606,7 @@ double lcl_GetLogGammaHelper(double fZ) /** You must ensure non integer arguments for fZ<1 */ double ScInterpreter::GetGamma(double fZ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetGamma" ); const double fLogPi = log(F_PI); const double fLogDblMax = log( ::std::numeric_limits<double>::max()); @@ -641,6 +652,7 @@ double ScInterpreter::GetGamma(double fZ) /** You must ensure fZ>0 */ double ScInterpreter::GetLogGamma(double fZ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetLogGamma" ); if (fZ >= fMaxGammaArgument) return lcl_GetLogGammaHelper(fZ); if (fZ >= 1.0) @@ -652,6 +664,7 @@ double ScInterpreter::GetLogGamma(double fZ) double ScInterpreter::GetFDist(double x, double fF1, double fF2) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetFDist" ); double arg = fF2/(fF2+fF1*x); double alpha = fF2/2.0; double beta = fF1/2.0; @@ -665,6 +678,7 @@ double ScInterpreter::GetFDist(double x, double fF1, double fF2) double ScInterpreter::GetTDist(double T, double fDF) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetTDist" ); return 0.5 * GetBetaDist(fDF/(fDF+T*T), fDF/2.0, 0.5); /* USHORT DF = (USHORT) fDF; @@ -703,6 +717,7 @@ double ScInterpreter::GetTDist(double T, double fDF) /** You must ensure fDF>0.0 */ double ScInterpreter::GetChiDist(double fX, double fDF) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetChiDist" ); if (fX <= 0.0) return 1.0; // see ODFF else @@ -715,6 +730,7 @@ double ScInterpreter::GetChiDist(double fX, double fDF) /** You must ensure fDF>0.0 */ double ScInterpreter::GetChiSqDistCDF(double fX, double fDF) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetChiSqDistCDF" ); if (fX <= 0.0) return 0.0; // see ODFF else @@ -785,6 +801,7 @@ void ScInterpreter::ScChiSqDist() void ScInterpreter::ScGamma() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGamma" ); double x = GetDouble(); double fResult; if (x <= 0.0 && x == ::rtl::math::approxFloor(x)) @@ -804,6 +821,7 @@ void ScInterpreter::ScGamma() void ScInterpreter::ScLogGamma() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLogGamma" ); double x = GetDouble(); if (x > 0.0) // constraint from ODFF PushDouble( GetLogGamma(x)); @@ -1045,35 +1063,35 @@ double ScInterpreter::GetBetaDist(double fXin, double fAlpha, double fBeta) return fResult; } -void ScInterpreter::ScBetaDist() -{ - BYTE nParamCount = GetByte(); + void ScInterpreter::ScBetaDist() + { + BYTE nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 3, 6 ) ) // expanded, see #i91547# - return; + return; double fLowerBound, fUpperBound; double alpha, beta, x; bool bIsCumulative; if (nParamCount == 6) bIsCumulative = GetBool(); - else + else bIsCumulative = true; if (nParamCount >= 5) fUpperBound = GetDouble(); else fUpperBound = 1.0; - if (nParamCount >= 4) + if (nParamCount >= 4) fLowerBound = GetDouble(); - else + else fLowerBound = 0.0; - beta = GetDouble(); - alpha = GetDouble(); - x = GetDouble(); + beta = GetDouble(); + alpha = GetDouble(); + x = GetDouble(); double fScale = fUpperBound - fLowerBound; if (fScale <= 0.0 || alpha <= 0.0 || beta <= 0.0) - { - PushIllegalArgument(); - return; - } + { + PushIllegalArgument(); + return; + } if (bIsCumulative) // cumulative distribution function { // special cases @@ -1105,16 +1123,19 @@ void ScInterpreter::ScBetaDist() void ScInterpreter::ScPhi() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScPhi" ); PushDouble(phi(GetDouble())); } void ScInterpreter::ScGauss() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGauss" ); PushDouble(gauss(GetDouble())); } void ScInterpreter::ScFisher() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScFisher" ); double fVal = GetDouble(); if (fabs(fVal) >= 1.0) PushIllegalArgument(); @@ -1124,12 +1145,14 @@ void ScInterpreter::ScFisher() void ScInterpreter::ScFisherInv() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScFisherInv" ); double fVal = GetDouble(); PushDouble((exp(2.0*fVal)-1.0)/(exp(2.0*fVal)+1.0)); } void ScInterpreter::ScFact() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScFact" ); double nVal = GetDouble(); if (nVal < 0.0) PushIllegalArgument(); @@ -1139,6 +1162,7 @@ void ScInterpreter::ScFact() void ScInterpreter::ScKombin() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScKombin" ); if ( MustHaveParamCount( GetByte(), 2 ) ) { double k = ::rtl::math::approxFloor(GetDouble()); @@ -1152,6 +1176,7 @@ void ScInterpreter::ScKombin() void ScInterpreter::ScKombin2() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScKombin2" ); if ( MustHaveParamCount( GetByte(), 2 ) ) { double k = ::rtl::math::approxFloor(GetDouble()); @@ -1165,6 +1190,7 @@ void ScInterpreter::ScKombin2() void ScInterpreter::ScVariationen() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScVariationen" ); if ( MustHaveParamCount( GetByte(), 2 ) ) { double k = ::rtl::math::approxFloor(GetDouble()); @@ -1185,6 +1211,7 @@ void ScInterpreter::ScVariationen() void ScInterpreter::ScVariationen2() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScVariationen2" ); if ( MustHaveParamCount( GetByte(), 2 ) ) { double k = ::rtl::math::approxFloor(GetDouble()); @@ -1198,6 +1225,7 @@ void ScInterpreter::ScVariationen2() void ScInterpreter::ScB() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScB" ); BYTE nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 3, 4 ) ) return ; @@ -1319,6 +1347,7 @@ void ScInterpreter::ScB() void ScInterpreter::ScBinomDist() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScBinomDist" ); if ( MustHaveParamCount( GetByte(), 4 ) ) { double kum = GetDouble(); // 0 oder 1 @@ -1399,6 +1428,7 @@ void ScInterpreter::ScBinomDist() void ScInterpreter::ScCritBinom() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCritBinom" ); if ( MustHaveParamCount( GetByte(), 3 ) ) { double alpha = GetDouble(); // alpha @@ -1446,6 +1476,7 @@ void ScInterpreter::ScCritBinom() void ScInterpreter::ScNegBinomDist() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScNegBinomDist" ); if ( MustHaveParamCount( GetByte(), 3 ) ) { double p = GetDouble(); // p @@ -1466,6 +1497,7 @@ void ScInterpreter::ScNegBinomDist() void ScInterpreter::ScNormDist() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScNormDist" ); if ( MustHaveParamCount( GetByte(), 4 ) ) { double kum = GetDouble(); // 0 oder 1 @@ -1485,6 +1517,7 @@ void ScInterpreter::ScNormDist() void ScInterpreter::ScLogNormDist() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLogNormDist" ); if ( MustHaveParamCount( GetByte(), 3 ) ) { double sigma = GetDouble(); // Stdabw @@ -1503,11 +1536,13 @@ void ScInterpreter::ScLogNormDist() void ScInterpreter::ScStdNormDist() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScStdNormDist" ); PushDouble(0.5 + gauss(GetDouble())); } void ScInterpreter::ScExpDist() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScExpDist" ); if ( MustHaveParamCount( GetByte(), 3 ) ) { double kum = GetDouble(); // 0 oder 1 @@ -1534,6 +1569,7 @@ void ScInterpreter::ScExpDist() void ScInterpreter::ScTDist() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScTDist" ); if ( !MustHaveParamCount( GetByte(), 3 ) ) return; double fFlag = ::rtl::math::approxFloor(GetDouble()); @@ -1553,6 +1589,7 @@ void ScInterpreter::ScTDist() void ScInterpreter::ScFDist() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScFDist" ); if ( !MustHaveParamCount( GetByte(), 3 ) ) return; double fF2 = ::rtl::math::approxFloor(GetDouble()); @@ -1568,6 +1605,7 @@ void ScInterpreter::ScFDist() void ScInterpreter::ScChiDist() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScChiDist" ); double fResult; if ( !MustHaveParamCount( GetByte(), 2 ) ) return; @@ -1589,6 +1627,7 @@ void ScInterpreter::ScChiDist() void ScInterpreter::ScWeibull() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScWeibull" ); if ( MustHaveParamCount( GetByte(), 4 ) ) { double kum = GetDouble(); // 0 oder 1 @@ -1607,6 +1646,7 @@ void ScInterpreter::ScWeibull() void ScInterpreter::ScPoissonDist() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScPoissonDist" ); BYTE nParamCount = GetByte(); if ( MustHaveParamCount( nParamCount, 2, 3 ) ) { @@ -1675,6 +1715,7 @@ void lcl_PutFactorialElements( ::std::vector< double >& cn, double fLower, doubl */ void ScInterpreter::ScHypGeomDist() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScHypGeomDist" ); const size_t nMaxArraySize = 500000; // arbitrary max array size if ( !MustHaveParamCount( GetByte(), 4 ) ) @@ -1889,6 +1930,7 @@ void ScInterpreter::ScHypGeomDist() void ScInterpreter::ScGammaDist() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGammaDist" ); BYTE nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 3, 4 ) ) return; @@ -1913,6 +1955,7 @@ void ScInterpreter::ScGammaDist() void ScInterpreter::ScNormInv() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScNormInv" ); if ( MustHaveParamCount( GetByte(), 3 ) ) { double sigma = GetDouble(); @@ -1929,6 +1972,7 @@ void ScInterpreter::ScNormInv() void ScInterpreter::ScSNormInv() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSNormInv" ); double x = GetDouble(); if (x < 0.0 || x > 1.0) PushIllegalArgument(); @@ -1940,6 +1984,7 @@ void ScInterpreter::ScSNormInv() void ScInterpreter::ScLogNormInv() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLogNormInv" ); if ( MustHaveParamCount( GetByte(), 3 ) ) { double sigma = GetDouble(); // Stdabw @@ -1966,6 +2011,7 @@ public: void ScInterpreter::ScGammaInv() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGammaInv" ); if ( !MustHaveParamCount( GetByte(), 3 ) ) return; double fBeta = GetDouble(); @@ -2004,6 +2050,7 @@ public: void ScInterpreter::ScBetaInv() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScBetaInv" ); BYTE nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 3, 5 ) ) return; @@ -2057,6 +2104,7 @@ public: void ScInterpreter::ScTInv() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScTInv" ); if ( !MustHaveParamCount( GetByte(), 2 ) ) return; double fDF = ::rtl::math::approxFloor(GetDouble()); @@ -2089,6 +2137,7 @@ public: void ScInterpreter::ScFInv() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScFInv" ); if ( !MustHaveParamCount( GetByte(), 3 ) ) return; double fF2 = ::rtl::math::approxFloor(GetDouble()); @@ -2122,6 +2171,7 @@ public: void ScInterpreter::ScChiInv() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScChiInv" ); if ( !MustHaveParamCount( GetByte(), 2 ) ) return; double fDF = ::rtl::math::approxFloor(GetDouble()); @@ -2140,6 +2190,7 @@ void ScInterpreter::ScChiInv() PushDouble(fVal); } +/***********************************************/ class ScChiSqDistFunction : public ScDistFunc { ScInterpreter& rInt; @@ -2173,10 +2224,10 @@ void ScInterpreter::ScChiSqInv() PushDouble(fVal); } -/***********************************************/ void ScInterpreter::ScConfidence() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScConfidence" ); if ( MustHaveParamCount( GetByte(), 3 ) ) { double n = ::rtl::math::approxFloor(GetDouble()); @@ -2191,6 +2242,7 @@ void ScInterpreter::ScConfidence() void ScInterpreter::ScZTest() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScZTest" ); BYTE nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 2, 3 ) ) return; @@ -2212,7 +2264,7 @@ void ScInterpreter::ScZTest() double rValCount = 0.0; switch (GetStackType()) { - case svDouble : + case formula::svDouble : { fVal = GetDouble(); fSum += fVal; @@ -2235,7 +2287,7 @@ void ScInterpreter::ScZTest() } break; case svRefList : - case svDoubleRef : + case formula::svDoubleRef : { short nParam = 1; size_t nRefInList = 0; @@ -2304,9 +2356,80 @@ void ScInterpreter::ScZTest() PushDouble(0.5 - gauss((mue-x)/sqrt(sigma/rValCount))); } } +bool ScInterpreter::CalculateTest(BOOL _bTemplin + ,const SCSIZE nC1, const SCSIZE nC2,const SCSIZE nR1,const SCSIZE nR2 + ,const ScMatrixRef& pMat1,const ScMatrixRef& pMat2 + ,double& fT,double& fF) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CalculateTest" ); + double fCount1 = 0.0; + double fCount2 = 0.0; + double fSum1 = 0.0; + double fSumSqr1 = 0.0; + double fSum2 = 0.0; + double fSumSqr2 = 0.0; + double fVal; + SCSIZE i,j; + for (i = 0; i < nC1; i++) + for (j = 0; j < nR1; j++) + { + if (!pMat1->IsString(i,j)) + { + fVal = pMat1->GetDouble(i,j); + fSum1 += fVal; + fSumSqr1 += fVal * fVal; + fCount1++; + } + } + for (i = 0; i < nC2; i++) + for (j = 0; j < nR2; j++) + { + if (!pMat2->IsString(i,j)) + { + fVal = pMat2->GetDouble(i,j); + fSum2 += fVal; + fSumSqr2 += fVal * fVal; + fCount2++; + } + } + if (fCount1 < 2.0 || fCount2 < 2.0) + { + PushNoValue(); + return false; + } // if (fCount1 < 2.0 || fCount2 < 2.0) + if ( _bTemplin ) + { + double fS1 = (fSumSqr1-fSum1*fSum1/fCount1)/(fCount1-1.0)/fCount1; + double fS2 = (fSumSqr2-fSum2*fSum2/fCount2)/(fCount2-1.0)/fCount2; + if (fS1 + fS2 == 0.0) + { + PushNoValue(); + return false; + } + fT = fabs(fSum1/fCount1 - fSum2/fCount2)/sqrt(fS1+fS2); + double c = fS1/(fS1+fS2); +// s.u. fF = ::rtl::math::approxFloor(1.0/(c*c/(fCount1-1.0)+(1.0-c)*(1.0-c)/(fCount2-1.0))); +// fF = ::rtl::math::approxFloor((fS1+fS2)*(fS1+fS2)/(fS1*fS1/(fCount1-1.0) + fS2*fS2/(fCount2-1.0))); + // GetTDist wird mit GetBetaDist berechnet und kommt auch mit nicht ganzzahligen + // Freiheitsgraden klar. Dann stimmt das Ergebnis auch mit Excel ueberein (#52406#): + fF = 1.0/(c*c/(fCount1-1.0)+(1.0-c)*(1.0-c)/(fCount2-1.0)); + } + else + { + // laut Bronstein-Semendjajew + double fS1 = (fSumSqr1 - fSum1*fSum1/fCount1) / (fCount1 - 1.0); // Varianz + double fS2 = (fSumSqr2 - fSum2*fSum2/fCount2) / (fCount2 - 1.0); + fT = fabs( fSum1/fCount1 - fSum2/fCount2 ) / + sqrt( (fCount1-1.0)*fS1 + (fCount2-1.0)*fS2 ) * + sqrt( fCount1*fCount2*(fCount1+fCount2-2)/(fCount1+fCount2) ); + fF = fCount1 + fCount2 - 2; + } + return true; +} void ScInterpreter::ScTTest() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScTTest" ); if ( !MustHaveParamCount( GetByte(), 4 ) ) return; double fTyp = ::rtl::math::approxFloor(GetDouble()); @@ -2366,112 +2489,11 @@ void ScInterpreter::ScTTest() } else if (fTyp == 2.0) { - double fCount1 = 0.0; - double fCount2 = 0.0; - double fSum1 = 0.0; - double fSumSqr1 = 0.0; - double fSum2 = 0.0; - double fSumSqr2 = 0.0; - double fVal; - for (i = 0; i < nC1; i++) - for (j = 0; j < nR1; j++) - { - if (!pMat1->IsString(i,j)) - { - fVal = pMat1->GetDouble(i,j); - fSum1 += fVal; - fSumSqr1 += fVal * fVal; - fCount1++; - } - } - for (i = 0; i < nC2; i++) - for (j = 0; j < nR2; j++) - { - if (!pMat2->IsString(i,j)) - { - fVal = pMat2->GetDouble(i,j); - fSum2 += fVal; - fSumSqr2 += fVal * fVal; - fCount2++; - } - } - if (fCount1 < 2.0 || fCount2 < 2.0) - { - PushNoValue(); - return; - } -#if 0 - // alter Templin-Code - double fS1 = (fSumSqr1-fSum1*fSum1/fCount1)/(fCount1-1.0)/fCount1; - double fS2 = (fSumSqr2-fSum2*fSum2/fCount2)/(fCount2-1.0)/fCount2; - if (fS1 + fS2 == 0.0) - { - PushNoValue(); - return; - } - fT = fabs(fSum1/fCount1 - fSum2/fCount2)/sqrt(fS1+fS2); - fF = fCount1 + fCount2 - 2; -#else - // laut Bronstein-Semendjajew - double fS1 = (fSumSqr1 - fSum1*fSum1/fCount1) / (fCount1 - 1.0); // Varianz - double fS2 = (fSumSqr2 - fSum2*fSum2/fCount2) / (fCount2 - 1.0); - fT = fabs( fSum1/fCount1 - fSum2/fCount2 ) / - sqrt( (fCount1-1.0)*fS1 + (fCount2-1.0)*fS2 ) * - sqrt( fCount1*fCount2*(fCount1+fCount2-2)/(fCount1+fCount2) ); - fF = fCount1 + fCount2 - 2; -#endif + CalculateTest(FALSE,nC1, nC2,nR1, nR2,pMat1,pMat2,fT,fF); } else if (fTyp == 3.0) { - double fCount1 = 0.0; - double fCount2 = 0.0; - double fSum1 = 0.0; - double fSumSqr1 = 0.0; - double fSum2 = 0.0; - double fSumSqr2 = 0.0; - double fVal; - for (i = 0; i < nC1; i++) - for (j = 0; j < nR1; j++) - { - if (!pMat1->IsString(i,j)) - { - fVal = pMat1->GetDouble(i,j); - fSum1 += fVal; - fSumSqr1 += fVal * fVal; - fCount1++; - } - } - for (i = 0; i < nC2; i++) - for (j = 0; j < nR2; j++) - { - if (!pMat2->IsString(i,j)) - { - fVal = pMat2->GetDouble(i,j); - fSum2 += fVal; - fSumSqr2 += fVal * fVal; - fCount2++; - } - } - if (fCount1 < 2.0 || fCount2 < 2.0) - { - PushNoValue(); - return; - } - double fS1 = (fSumSqr1-fSum1*fSum1/fCount1)/(fCount1-1.0)/fCount1; - double fS2 = (fSumSqr2-fSum2*fSum2/fCount2)/(fCount2-1.0)/fCount2; - if (fS1 + fS2 == 0.0) - { - PushNoValue(); - return; - } - fT = fabs(fSum1/fCount1 - fSum2/fCount2)/sqrt(fS1+fS2); - double c = fS1/(fS1+fS2); -// s.u. fF = ::rtl::math::approxFloor(1.0/(c*c/(fCount1-1.0)+(1.0-c)*(1.0-c)/(fCount2-1.0))); -// fF = ::rtl::math::approxFloor((fS1+fS2)*(fS1+fS2)/(fS1*fS1/(fCount1-1.0) + fS2*fS2/(fCount2-1.0))); - - // GetTDist wird mit GetBetaDist berechnet und kommt auch mit nicht ganzzahligen - // Freiheitsgraden klar. Dann stimmt das Ergebnis auch mit Excel ueberein (#52406#): - fF = 1.0/(c*c/(fCount1-1.0)+(1.0-c)*(1.0-c)/(fCount2-1.0)); + CalculateTest(TRUE,nC1, nC2,nR1, nR2,pMat1,pMat2,fT,fF); } else @@ -2487,6 +2509,7 @@ void ScInterpreter::ScTTest() void ScInterpreter::ScFTest() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScFTest" ); if ( !MustHaveParamCount( GetByte(), 2 ) ) return; ScMatrixRef pMat2 = GetMatrix(); @@ -2565,6 +2588,7 @@ void ScInterpreter::ScFTest() void ScInterpreter::ScChiTest() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScChiTest" ); if ( !MustHaveParamCount( GetByte(), 2 ) ) return; ScMatrixRef pMat2 = GetMatrix(); @@ -2637,105 +2661,11 @@ void ScInterpreter::ScChiTest() void ScInterpreter::ScKurt() { - short nParamCount = GetByte(); - if ( !MustHaveParamCountMin( nParamCount, 1 ) ) - return; - double fSum = 0.0; - double vSum = 0.0; + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScKurt" ); + double fSum,fCount,vSum; std::vector<double> values; - double fCount = 0.0; - double fVal = 0.0; - ScAddress aAdr; - ScRange aRange; - size_t nRefInList = 0; - while (nParamCount-- > 0) - { - switch (GetStackType()) - { - case svDouble : - { - fVal = GetDouble(); - fSum += fVal; - values.push_back(fVal); - fCount++; - } - break; - case svSingleRef : - { - PopSingleRef( aAdr ); - ScBaseCell* pCell = GetCell( aAdr ); - if (HasCellValueData(pCell)) - { - fVal = GetCellValue( aAdr, pCell ); - fSum += fVal; - values.push_back(fVal); - fCount++; - } - } - break; - case svDoubleRef : - case svRefList : - { - PopDoubleRef( aRange, nParamCount, nRefInList); - USHORT nErr = 0; - ScValueIterator aValIter(pDok, aRange); - if (aValIter.GetFirst(fVal, nErr)) - { - fSum += fVal; - values.push_back(fVal); - fCount++; - SetError(nErr); - while ((nErr == 0) && aValIter.GetNext(fVal, nErr)) - { - fSum += fVal; - values.push_back(fVal); - fCount++; - } - SetError(nErr); - } - } - break; - case svMatrix : - { - ScMatrixRef pMat = PopMatrix(); - if (pMat) - { - SCSIZE nCount = pMat->GetElementCount(); - if (pMat->IsNumeric()) - { - for (SCSIZE nElem = 0; nElem < nCount; nElem++) - { - fVal = pMat->GetDouble(nElem); - fSum += fVal; - values.push_back(fVal); - fCount++; - } - } - else - { - for (SCSIZE nElem = 0; nElem < nCount; nElem++) - if (!pMat->IsString(nElem)) - { - fVal = pMat->GetDouble(nElem); - fSum += fVal; - values.push_back(fVal); - fCount++; - } - } - } - } - break; - default : - SetError(errIllegalParameter); - break; - } - } - - if (nGlobalError) - { - PushError( nGlobalError); + if ( !CalculateSkew(fSum,fCount,vSum,values) ) return; - } if (fCount == 0.0) { @@ -2773,6 +2703,7 @@ void ScInterpreter::ScKurt() void ScInterpreter::ScHarMean() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScHarMean" ); short nParamCount = GetByte(); double nVal = 0.0; double nValCount = 0.0; @@ -2783,7 +2714,7 @@ void ScInterpreter::ScHarMean() { switch (GetStackType()) { - case svDouble : + case formula::svDouble : { double x = GetDouble(); if (x > 0.0) @@ -2812,7 +2743,7 @@ void ScInterpreter::ScHarMean() } break; } - case svDoubleRef : + case formula::svDoubleRef : case svRefList : { USHORT nErr = 0; @@ -2892,6 +2823,7 @@ void ScInterpreter::ScHarMean() void ScInterpreter::ScGeoMean() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGeoMean" ); short nParamCount = GetByte(); double nVal = 0.0; double nValCount = 0.0; @@ -2903,7 +2835,7 @@ void ScInterpreter::ScGeoMean() { switch (GetStackType()) { - case svDouble : + case formula::svDouble : { double x = GetDouble(); if (x > 0.0) @@ -2932,7 +2864,7 @@ void ScInterpreter::ScGeoMean() } break; } - case svDoubleRef : + case formula::svDoubleRef : case svRefList : { USHORT nErr = 0; @@ -3012,6 +2944,7 @@ void ScInterpreter::ScGeoMean() void ScInterpreter::ScStandard() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScStandard" ); if ( MustHaveParamCount( GetByte(), 3 ) ) { double sigma = GetDouble(); @@ -3025,16 +2958,16 @@ void ScInterpreter::ScStandard() PushDouble((x-mue)/sigma); } } - -void ScInterpreter::ScSkew() +bool ScInterpreter::CalculateSkew(double& fSum,double& fCount,double& vSum,std::vector<double>& values) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CalculateSkew" ); short nParamCount = GetByte(); if ( !MustHaveParamCountMin( nParamCount, 1 ) ) - return; - double fSum = 0.0; - double vSum = 0.0; - std::vector<double> values; - double fCount = 0.0; + return false; + + fSum = 0.0; + fCount = 0.0; + vSum = 0.0; double fVal = 0.0; ScAddress aAdr; ScRange aRange; @@ -3043,7 +2976,7 @@ void ScInterpreter::ScSkew() { switch (GetStackType()) { - case svDouble : + case formula::svDouble : { fVal = GetDouble(); fSum += fVal; @@ -3064,7 +2997,7 @@ void ScInterpreter::ScSkew() } } break; - case svDoubleRef : + case formula::svDoubleRef : case svRefList : { PopDoubleRef( aRange, nParamCount, nRefInList); @@ -3125,8 +3058,18 @@ void ScInterpreter::ScSkew() if (nGlobalError) { PushError( nGlobalError); + return false; + } // if (nGlobalError) + return true; +} + +void ScInterpreter::ScSkew() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSkew" ); + double fSum,fCount,vSum; + std::vector<double> values; + if ( !CalculateSkew(fSum,fCount,vSum,values) ) return; - } double fMean = fSum / fCount; @@ -3154,6 +3097,7 @@ void ScInterpreter::ScSkew() void ScInterpreter::ScMedian() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMedian" ); BYTE nParamCount = GetByte(); if ( !MustHaveParamCountMin( nParamCount, 1 ) ) return; @@ -3173,6 +3117,7 @@ void ScInterpreter::ScMedian() void ScInterpreter::ScPercentile() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScPercentile" ); if ( !MustHaveParamCount( GetByte(), 2 ) ) return; double alpha = GetDouble(); @@ -3209,6 +3154,7 @@ void ScInterpreter::ScPercentile() void ScInterpreter::ScQuartile() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScQuartile" ); if ( !MustHaveParamCount( GetByte(), 2 ) ) return; double fFlag = ::rtl::math::approxFloor(GetDouble()); @@ -3273,6 +3219,7 @@ void ScInterpreter::ScQuartile() void ScInterpreter::ScModalValue() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScModalValue" ); BYTE nParamCount = GetByte(); if ( !MustHaveParamCountMin( nParamCount, 1 ) ) return; @@ -3315,9 +3262,9 @@ void ScInterpreter::ScModalValue() PushDouble(aSortArray[nMaxIndex]); } } - -void ScInterpreter::ScLarge() +void ScInterpreter::CalculateSmallLarge(BOOL bSmall) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CalculateSmallLarge" ); if ( !MustHaveParamCount( GetByte(), 2 ) ) return; double f = ::rtl::math::approxFloor(GetDouble()); @@ -3334,70 +3281,24 @@ void ScInterpreter::ScLarge() PushNoValue(); else { -#if 0 -/* - SCSIZE nCount = 1; - double nOldVal = pSortArray[nSize-1]; - for (long i = nSize-2; i >= 0 && nCount < k; i--) - { - if (pSortArray[i] != nOldVal) - { - nCount++; - nOldVal = pSortArray[i]; - } - } - if (nCount < k) - PushNoValue(); - else - PushDouble(nOldVal); -*/ -#endif - PushDouble( aSortArray[ nSize-k ] ); + PushDouble( aSortArray[ bSmall ? k-1 : nSize-k ] ); } } +void ScInterpreter::ScLarge() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScLarge" ); + CalculateSmallLarge(FALSE); +} void ScInterpreter::ScSmall() { - if ( !MustHaveParamCount( GetByte(), 2 ) ) - return; - double f = ::rtl::math::approxFloor(GetDouble()); - if (f < 1.0) - { - PushIllegalArgument(); - return; - } - SCSIZE k = static_cast<SCSIZE>(f); - vector<double> aSortArray; - GetSortArray(1, aSortArray); - SCSIZE nSize = aSortArray.size(); - if (aSortArray.empty() || nSize == 0 || nGlobalError || nSize < k) - PushNoValue(); - else - { -#if 0 -/* - SCSIZE nCount = 1; - double nOldVal = pSortArray[0]; - for (SCSIZE i = 1; i < nSize && nCount < k; i++) - { - if (pSortArray[i] != nOldVal) - { - nCount++; - nOldVal = pSortArray[i]; - } - } - if (nCount < k) - PushNoValue(); - else - PushDouble(nOldVal); -*/ -#endif - PushDouble( aSortArray[ k-1 ] ); - } + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSmall" ); + CalculateSmallLarge(TRUE); } void ScInterpreter::ScPercentrank() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScPercentrank" ); BYTE nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 2 ) ) return; @@ -3472,6 +3373,7 @@ void ScInterpreter::ScPercentrank() void ScInterpreter::ScTrimMean() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScTrimMean" ); if ( !MustHaveParamCount( GetByte(), 2 ) ) return; double alpha = GetDouble(); @@ -3501,6 +3403,7 @@ void ScInterpreter::ScTrimMean() void ScInterpreter::GetSortArray(BYTE nParamCount, vector<double>& rSortArray, vector<long>* pIndexOrder) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetSortArray" ); ScAddress aAdr; ScRange aRange; short nParam = nParamCount; @@ -3509,7 +3412,7 @@ void ScInterpreter::GetSortArray(BYTE nParamCount, vector<double>& rSortArray, v { switch (GetStackType()) { - case svDouble : + case formula::svDouble : rSortArray.push_back( PopDouble()); break; case svSingleRef : @@ -3520,7 +3423,7 @@ void ScInterpreter::GetSortArray(BYTE nParamCount, vector<double>& rSortArray, v rSortArray.push_back( GetCellValue( aAdr, pCell)); } break; - case svDoubleRef : + case formula::svDoubleRef : case svRefList : { PopDoubleRef( aRange, nParam, nRefInList); @@ -3640,6 +3543,7 @@ static void lcl_QuickSort( long nLo, long nHi, vector<double>& rSortArray, vecto void ScInterpreter::QuickSort( vector<double>& rSortArray, vector<long>* pIndexOrder ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::QuickSort" ); long n = static_cast<long>(rSortArray.size()); if (pIndexOrder) @@ -3667,6 +3571,7 @@ void ScInterpreter::QuickSort( vector<double>& rSortArray, vector<long>* pIndexO void ScInterpreter::ScRank() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRank" ); BYTE nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 2, 3 ) ) return; @@ -3679,7 +3584,7 @@ void ScInterpreter::ScRank() BOOL bValid = FALSE; switch (GetStackType()) { - case svDouble : + case formula::svDouble : { double x = GetDouble(); double fVal = GetDouble(); @@ -3701,7 +3606,7 @@ void ScInterpreter::ScRank() } break; } - case svDoubleRef : + case formula::svDoubleRef : case svRefList : { ScRange aRange; @@ -3786,6 +3691,7 @@ void ScInterpreter::ScRank() void ScInterpreter::ScAveDev() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScAveDev" ); BYTE nParamCount = GetByte(); if ( !MustHaveParamCountMin( nParamCount, 1 ) ) return; @@ -3801,7 +3707,7 @@ void ScInterpreter::ScAveDev() { switch (GetStackType()) { - case svDouble : + case formula::svDouble : rVal += GetDouble(); rValCount++; break; @@ -3816,7 +3722,7 @@ void ScInterpreter::ScAveDev() } } break; - case svDoubleRef : + case formula::svDoubleRef : case svRefList : { USHORT nErr = 0; @@ -3882,7 +3788,7 @@ void ScInterpreter::ScAveDev() { switch (GetStackType()) { - case svDouble : + case formula::svDouble : rVal += fabs(GetDouble() - nMiddle); break; case svSingleRef : @@ -3893,7 +3799,7 @@ void ScInterpreter::ScAveDev() rVal += fabs(GetCellValue( aAdr, pCell ) - nMiddle); } break; - case svDoubleRef : + case formula::svDoubleRef : case svRefList : { USHORT nErr = 0; @@ -3940,6 +3846,7 @@ void ScInterpreter::ScAveDev() void ScInterpreter::ScDevSq() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDevSq" ); double nVal; double nValCount; GetStVarParams(nVal, nValCount); @@ -3948,6 +3855,7 @@ void ScInterpreter::ScDevSq() void ScInterpreter::ScProbability() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScProbability" ); BYTE nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 3, 4 ) ) return; @@ -4011,77 +3919,25 @@ void ScInterpreter::ScProbability() void ScInterpreter::ScCorrel() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCorrel" ); // This is identical to ScPearson() ScPearson(); } void ScInterpreter::ScCovar() { - if ( !MustHaveParamCount( GetByte(), 2 ) ) - return; - ScMatrixRef pMat1 = GetMatrix(); - ScMatrixRef pMat2 = GetMatrix(); - if (!pMat1 || !pMat2) - { - PushIllegalParameter(); - return; - } - SCSIZE nC1, nC2; - SCSIZE nR1, nR2; - pMat1->GetDimensions(nC1, nR1); - pMat2->GetDimensions(nC2, nR2); - if (nR1 != nR2 || nC1 != nC2) - { - PushIllegalArgument(); - return; - } - /* #i78250# - * (sum((X-MeanX)(Y-MeanY)))/N equals (SumXY)/N-MeanX*MeanY mathematically, - * but the latter produces wrong results if the absolute values are high, - * for example above 10^8 - */ - double fCount = 0.0; - double fSumX = 0.0; - double fSumY = 0.0; - double fSumDeltaXDeltaY = 0.0; // sum of (ValX-MeanX)*(ValY-MeanY) - for (SCSIZE i = 0; i < nC1; i++) - { - for (SCSIZE j = 0; j < nR1; j++) - { - if (!pMat1->IsString(i,j) && !pMat2->IsString(i,j)) - { - double fValX = pMat1->GetDouble(i,j); - double fValY = pMat2->GetDouble(i,j); - fSumX += fValX; - fSumY += fValY; - fCount++; - } - } - } - if (fCount < 1.0) - PushNoValue(); - else - { - double fMeanX = fSumX / fCount; - double fMeanY = fSumY / fCount; - for (SCSIZE i = 0; i < nC1; i++) - { - for (SCSIZE j = 0; j < nR1; j++) - { - if (!pMat1->IsString(i,j) && !pMat2->IsString(i,j)) - { - double fValX = pMat1->GetDouble(i,j); - double fValY = pMat2->GetDouble(i,j); - fSumDeltaXDeltaY += (fValX - fMeanX) * (fValY - fMeanY); - } - } - } - PushDouble( fSumDeltaXDeltaY / fCount); - } + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCovar" ); + CalculatePearsonCovar(FALSE,FALSE); } void ScInterpreter::ScPearson() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScPearson" ); + CalculatePearsonCovar(TRUE,FALSE); +} +void ScInterpreter::CalculatePearsonCovar(BOOL _bPearson,BOOL _bStexy) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CalculatePearsonCovar" ); if ( !MustHaveParamCount( GetByte(), 2 ) ) return; ScMatrixRef pMat1 = GetMatrix(); @@ -4125,42 +3981,56 @@ void ScInterpreter::ScPearson() } } } - if (fCount < 1.0) // fCount==1 is handled by checking denominator later on + if (fCount < (_bStexy ? 3.0 : 1.0)) // fCount==1 is handled by checking denominator later on PushNoValue(); else { - double fMeanX = fSumX / fCount; - double fMeanY = fSumY / fCount; + const double fMeanX = fSumX / fCount; + const double fMeanY = fSumY / fCount; for (SCSIZE i = 0; i < nC1; i++) { for (SCSIZE j = 0; j < nR1; j++) { if (!pMat1->IsString(i,j) && !pMat2->IsString(i,j)) { - double fValX = pMat1->GetDouble(i,j); - double fValY = pMat2->GetDouble(i,j); + const double fValX = pMat1->GetDouble(i,j); + const double fValY = pMat2->GetDouble(i,j); fSumDeltaXDeltaY += (fValX - fMeanX) * (fValY - fMeanY); - fSumSqrDeltaX += (fValX - fMeanX) * (fValX - fMeanX); - fSumSqrDeltaY += (fValY - fMeanY) * (fValY - fMeanY); + if ( _bPearson ) + { + fSumSqrDeltaX += (fValX - fMeanX) * (fValX - fMeanX); + fSumSqrDeltaY += (fValY - fMeanY) * (fValY - fMeanY); + } } } - } - if (fSumSqrDeltaX == 0.0 || fSumSqrDeltaY == 0.0) - PushError( errDivisionByZero); + } // for (SCSIZE i = 0; i < nC1; i++) + if ( _bPearson ) + { + if (fSumSqrDeltaX == 0.0 || ( !_bStexy && fSumSqrDeltaY == 0.0) ) + PushError( errDivisionByZero); + else if ( _bStexy ) + PushDouble( sqrt( (fSumSqrDeltaY - fSumDeltaXDeltaY * + fSumDeltaXDeltaY / fSumSqrDeltaX) / (fCount-2))); + else + PushDouble( fSumDeltaXDeltaY / sqrt( fSumSqrDeltaX * fSumSqrDeltaY)); + } // if ( _bPearson ) else - PushDouble( fSumDeltaXDeltaY / sqrt( fSumSqrDeltaX * fSumSqrDeltaY)); + { + PushDouble( fSumDeltaXDeltaY / fCount); + } } } void ScInterpreter::ScRSQ() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRSQ" ); // Same as ScPearson()*ScPearson() ScPearson(); if (!nGlobalError) { switch (GetStackType()) { - case svDouble: + case formula::svDouble: { double fVal = PopDouble(); PushDouble( fVal * fVal); @@ -4175,6 +4045,12 @@ void ScInterpreter::ScRSQ() void ScInterpreter::ScSTEXY() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSTEXY" ); + CalculatePearsonCovar(TRUE,TRUE); +} +void ScInterpreter::CalculateSlopeIntercept(BOOL bSlope) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CalculateSlopeIntercept" ); if ( !MustHaveParamCount( GetByte(), 2 ) ) return; ScMatrixRef pMat1 = GetMatrix(); @@ -4199,7 +4075,6 @@ void ScInterpreter::ScSTEXY() double fSumY = 0.0; double fSumDeltaXDeltaY = 0.0; // sum of (ValX-MeanX)*(ValY-MeanY) double fSumSqrDeltaX = 0.0; // sum of (ValX-MeanX)^2 - double fSumSqrDeltaY = 0.0; // sum of (ValY-MeanY)^2 for (SCSIZE i = 0; i < nC1; i++) { for (SCSIZE j = 0; j < nR1; j++) @@ -4214,7 +4089,7 @@ void ScInterpreter::ScSTEXY() } } } - if (fCount < 3.0) + if (fCount < 1.0) PushNoValue(); else { @@ -4230,152 +4105,36 @@ void ScInterpreter::ScSTEXY() double fValY = pMat2->GetDouble(i,j); fSumDeltaXDeltaY += (fValX - fMeanX) * (fValY - fMeanY); fSumSqrDeltaX += (fValX - fMeanX) * (fValX - fMeanX); - fSumSqrDeltaY += (fValY - fMeanY) * (fValY - fMeanY); } } } if (fSumSqrDeltaX == 0.0) PushError( errDivisionByZero); else - PushDouble( sqrt( (fSumSqrDeltaY - fSumDeltaXDeltaY * - fSumDeltaXDeltaY / fSumSqrDeltaX) / (fCount-2))); + { + if ( bSlope ) + PushDouble( fSumDeltaXDeltaY / fSumSqrDeltaX); + else + PushDouble( fMeanY - fSumDeltaXDeltaY / fSumSqrDeltaX * fMeanX); + } } } void ScInterpreter::ScSlope() { - if ( !MustHaveParamCount( GetByte(), 2 ) ) - return; - ScMatrixRef pMat1 = GetMatrix(); - ScMatrixRef pMat2 = GetMatrix(); - if (!pMat1 || !pMat2) - { - PushIllegalParameter(); - return; - } - SCSIZE nC1, nC2; - SCSIZE nR1, nR2; - pMat1->GetDimensions(nC1, nR1); - pMat2->GetDimensions(nC2, nR2); - if (nR1 != nR2 || nC1 != nC2) - { - PushIllegalArgument(); - return; - } - // #i78250# numerical stability improved - double fCount = 0.0; - double fSumX = 0.0; - double fSumY = 0.0; - double fSumDeltaXDeltaY = 0.0; // sum of (ValX-MeanX)*(ValY-MeanY) - double fSumSqrDeltaX = 0.0; // sum of (ValX-MeanX)^2 - for (SCSIZE i = 0; i < nC1; i++) - { - for (SCSIZE j = 0; j < nR1; j++) - { - if (!pMat1->IsString(i,j) && !pMat2->IsString(i,j)) - { - double fValX = pMat1->GetDouble(i,j); - double fValY = pMat2->GetDouble(i,j); - fSumX += fValX; - fSumY += fValY; - fCount++; - } - } - } - if (fCount < 1.0) - PushNoValue(); - else - { - double fMeanX = fSumX / fCount; - double fMeanY = fSumY / fCount; - for (SCSIZE i = 0; i < nC1; i++) - { - for (SCSIZE j = 0; j < nR1; j++) - { - if (!pMat1->IsString(i,j) && !pMat2->IsString(i,j)) - { - double fValX = pMat1->GetDouble(i,j); - double fValY = pMat2->GetDouble(i,j); - fSumDeltaXDeltaY += (fValX - fMeanX) * (fValY - fMeanY); - fSumSqrDeltaX += (fValX - fMeanX) * (fValX - fMeanX); - } - } - } - if (fSumSqrDeltaX == 0.0) - PushError( errDivisionByZero); - else - PushDouble( fSumDeltaXDeltaY / fSumSqrDeltaX); - } + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSlope" ); + CalculateSlopeIntercept(TRUE); } void ScInterpreter::ScIntercept() { - if ( !MustHaveParamCount( GetByte(), 2 ) ) - return; - ScMatrixRef pMat1 = GetMatrix(); - ScMatrixRef pMat2 = GetMatrix(); - if (!pMat1 || !pMat2) - { - PushIllegalParameter(); - return; - } - SCSIZE nC1, nC2; - SCSIZE nR1, nR2; - pMat1->GetDimensions(nC1, nR1); - pMat2->GetDimensions(nC2, nR2); - if (nR1 != nR2 || nC1 != nC2) - { - PushIllegalArgument(); - return; - } - // #i78250# numerical stability improved - double fCount = 0.0; - double fSumX = 0.0; - double fSumY = 0.0; - double fSumDeltaXDeltaY = 0.0; // sum of (ValX-MeanX)*(ValY-MeanY) - double fSumSqrDeltaX = 0.0; // sum of (ValX-MeanX)^2 - for (SCSIZE i = 0; i < nC1; i++) - { - for (SCSIZE j = 0; j < nR1; j++) - { - if (!pMat1->IsString(i,j) && !pMat2->IsString(i,j)) - { - double fValX = pMat1->GetDouble(i,j); - double fValY = pMat2->GetDouble(i,j); - fSumX += fValX; - fSumY += fValY; - fCount++; - } - } - } - if (fCount < 1.0) - PushNoValue(); - else - { - double fMeanX = fSumX / fCount; - double fMeanY = fSumY / fCount; - for (SCSIZE i = 0; i < nC1; i++) - { - for (SCSIZE j = 0; j < nR1; j++) - { - if (!pMat1->IsString(i,j) && !pMat2->IsString(i,j)) - { - double fValX = pMat1->GetDouble(i,j); - double fValY = pMat2->GetDouble(i,j); - fSumDeltaXDeltaY += (fValX - fMeanX) * (fValY - fMeanY); - fSumSqrDeltaX += (fValX - fMeanX) * (fValX - fMeanX); - } - } - } - if (fSumSqrDeltaX == 0.0) - PushError( errDivisionByZero); - else - PushDouble( fMeanY - fSumDeltaXDeltaY / fSumSqrDeltaX * fMeanX); - } + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScIntercept" ); + CalculateSlopeIntercept(FALSE); } void ScInterpreter::ScForecast() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScForecast" ); if ( !MustHaveParamCount( GetByte(), 3 ) ) return; ScMatrixRef pMat1 = GetMatrix(); diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 4ef402815f9b..c19ff07fa83e 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -42,6 +42,7 @@ #include <basic/sbx.hxx> #include <svtools/zforlist.hxx> #include <tools/urlobj.hxx> +#include <rtl/logfile.hxx> #include <stdlib.h> #include <string.h> #include <signal.h> @@ -75,6 +76,7 @@ #include <functional> using namespace com::sun::star; +using namespace formula; #define ADDIN_MAXSTRLEN 256 @@ -97,6 +99,7 @@ ScSpew ScInterpreter::theSpew; void ScInterpreter::ReplaceCell( ScAddress& rPos ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ReplaceCell" ); ScInterpreterTableOpParams* pTOp = pDok->aTableOpList.First(); while (pTOp) { @@ -118,6 +121,7 @@ void ScInterpreter::ReplaceCell( ScAddress& rPos ) void ScInterpreter::ReplaceCell( SCCOL& rCol, SCROW& rRow, SCTAB& rTab ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ReplaceCell" ); ScAddress aCellPos( rCol, rRow, rTab ); ScInterpreterTableOpParams* pTOp = pDok->aTableOpList.First(); while (pTOp) @@ -144,6 +148,7 @@ void ScInterpreter::ReplaceCell( SCCOL& rCol, SCROW& rRow, SCTAB& rTab ) BOOL ScInterpreter::IsTableOpInRange( const ScRange& rRange ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::IsTableOpInRange" ); if ( rRange.aStart == rRange.aEnd ) return FALSE; // not considered to be a range in TableOp sense @@ -163,6 +168,7 @@ BOOL ScInterpreter::IsTableOpInRange( const ScRange& rRange ) ULONG ScInterpreter::GetCellNumberFormat( const ScAddress& rPos, const ScBaseCell* pCell) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetCellNumberFormat" ); ULONG nFormat; USHORT nErr; if ( pCell ) @@ -190,6 +196,7 @@ ULONG ScInterpreter::GetCellNumberFormat( const ScAddress& rPos, const ScBaseCel // nur ValueCell, Formelzellen speichern das Ergebnis bereits gerundet double ScInterpreter::GetValueCellValue( const ScAddress& rPos, const ScValueCell* pCell ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetValueCellValue" ); double fVal = pCell->GetValue(); if ( bCalcAsShown && fVal != 0.0 ) { @@ -202,6 +209,7 @@ double ScInterpreter::GetValueCellValue( const ScAddress& rPos, const ScValueCel double ScInterpreter::GetCellValue( const ScAddress& rPos, const ScBaseCell* pCell ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetCellValue" ); USHORT nErr = nGlobalError; nGlobalError = 0; double nVal = GetCellValueOrZero( rPos, pCell ); @@ -213,6 +221,7 @@ double ScInterpreter::GetCellValue( const ScAddress& rPos, const ScBaseCell* pCe double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, const ScBaseCell* pCell ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetCellValueOrZero" ); double fValue; if (pCell) { @@ -285,6 +294,7 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, const ScBaseCel void ScInterpreter::GetCellString( String& rStr, const ScBaseCell* pCell ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetCellString" ); USHORT nErr = 0; if (pCell) { @@ -335,6 +345,7 @@ void ScInterpreter::GetCellString( String& rStr, const ScBaseCell* pCell ) BOOL ScInterpreter::CreateDoubleArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, BYTE* pCellArr) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CreateDoubleArr" ); #if SC_ROWLIMIT_MORE_THAN_64K #error row limit 64k #endif @@ -415,6 +426,7 @@ BOOL ScInterpreter::CreateStringArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, BYTE* pCellArr) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CreateStringArr" ); #if SC_ROWLIMIT_MORE_THAN_64K #error row limit 64k #endif @@ -509,6 +521,7 @@ BOOL ScInterpreter::CreateCellArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, BYTE* pCellArr) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CreateCellArr" ); #if SC_ROWLIMIT_MORE_THAN_64K #error row limit 64k #endif @@ -627,8 +640,9 @@ BOOL ScInterpreter::CreateCellArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, // Also releases a TempToken if appropriate. -void ScInterpreter::PushWithoutError( ScToken& r ) +void ScInterpreter::PushWithoutError( FormulaToken& r ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushWithoutError" ); if ( sp >= MAXSTACK ) SetError( errStackOverflow ); else @@ -644,8 +658,9 @@ void ScInterpreter::PushWithoutError( ScToken& r ) } } -void ScInterpreter::Push( ScToken& r ) +void ScInterpreter::Push( FormulaToken& r ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::Push" ); if ( sp >= MAXSTACK ) SetError( errStackOverflow ); else @@ -658,7 +673,7 @@ void ScInterpreter::Push( ScToken& r ) PushWithoutError( r); } else - PushWithoutError( *(new ScErrorToken( nGlobalError))); + PushWithoutError( *(new FormulaErrorToken( nGlobalError))); } else PushWithoutError( r); @@ -666,8 +681,9 @@ void ScInterpreter::Push( ScToken& r ) } -void ScInterpreter::PushTempToken( ScToken* p ) +void ScInterpreter::PushTempToken( FormulaToken* p ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushTempToken" ); if ( sp >= MAXSTACK ) { SetError( errStackOverflow ); @@ -689,7 +705,7 @@ void ScInterpreter::PushTempToken( ScToken* p ) if (!p->GetRef()) //! p is a dangling pointer hereafter! p->Delete(); - PushTempTokenWithoutError( new ScErrorToken( nGlobalError)); + PushTempTokenWithoutError( new FormulaErrorToken( nGlobalError)); } } else @@ -698,8 +714,9 @@ void ScInterpreter::PushTempToken( ScToken* p ) } -void ScInterpreter::PushTempTokenWithoutError( ScToken* p ) +void ScInterpreter::PushTempTokenWithoutError( FormulaToken* p ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushTempTokenWithoutError" ); p->IncRef(); if ( sp >= MAXSTACK ) { @@ -719,8 +736,9 @@ void ScInterpreter::PushTempTokenWithoutError( ScToken* p ) } -void ScInterpreter::PushTempToken( const ScToken& r ) +void ScInterpreter::PushTempToken( const FormulaToken& r ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushTempToken" ); if (!IfErrorPushError()) PushTempTokenWithoutError( r.Clone()); } @@ -729,6 +747,7 @@ void ScInterpreter::PushTempToken( const ScToken& r ) void ScInterpreter::PushCellResultToken( bool bDisplayEmptyAsString, const ScAddress & rAddress, short * pRetTypeExpr, ULONG * pRetIndexExpr ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushCellResultToken" ); ScBaseCell* pCell = pDok->GetCell( rAddress); if (!pCell || pCell->HasEmptyData()) { @@ -773,6 +792,7 @@ void ScInterpreter::PushCellResultToken( bool bDisplayEmptyAsString, void ScInterpreter::Pop() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::Pop" ); if( sp ) sp--; else @@ -784,6 +804,7 @@ void ScInterpreter::Pop() void ScInterpreter::PopError() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PopError" ); if( sp ) { sp--; @@ -795,12 +816,13 @@ void ScInterpreter::PopError() } -ScTokenRef ScInterpreter::PopToken() +FormulaTokenRef ScInterpreter::PopToken() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PopToken" ); if (sp) { sp--; - ScToken* p = pStack[ sp ]; + FormulaToken* p = pStack[ sp ]; if (p->GetType() == svError) nGlobalError = p->GetError(); return p; @@ -813,12 +835,13 @@ ScTokenRef ScInterpreter::PopToken() double ScInterpreter::PopDouble() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PopDouble" ); nCurFmtType = NUMBERFORMAT_NUMBER; nCurFmtIndex = 0; if( sp ) { --sp; - ScToken* p = pStack[ sp ]; + FormulaToken* p = pStack[ sp ]; switch (p->GetType()) { case svError: @@ -841,12 +864,13 @@ double ScInterpreter::PopDouble() const String& ScInterpreter::PopString() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PopString" ); nCurFmtType = NUMBERFORMAT_TEXT; nCurFmtIndex = 0; if( sp ) { --sp; - ScToken* p = pStack[ sp ]; + FormulaToken* p = pStack[ sp ]; switch (p->GetType()) { case svError: @@ -869,6 +893,7 @@ const String& ScInterpreter::PopString() void ScInterpreter::ValidateRef( const ScSingleRefData & rRef ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ValidateRef" ); SCCOL nCol; SCROW nRow; SCTAB nTab; @@ -878,6 +903,7 @@ void ScInterpreter::ValidateRef( const ScSingleRefData & rRef ) void ScInterpreter::ValidateRef( const ScComplexRefData & rRef ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ValidateRef" ); ValidateRef( rRef.Ref1); ValidateRef( rRef.Ref2); } @@ -885,6 +911,7 @@ void ScInterpreter::ValidateRef( const ScComplexRefData & rRef ) void ScInterpreter::ValidateRef( const ScRefList & rRefList ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ValidateRef" ); ScRefList::const_iterator it( rRefList.begin()); ScRefList::const_iterator end( rRefList.end()); for ( ; it != end; ++it) @@ -897,6 +924,7 @@ void ScInterpreter::ValidateRef( const ScRefList & rRefList ) void ScInterpreter::SingleRefToVars( const ScSingleRefData & rRef, SCCOL & rCol, SCROW & rRow, SCTAB & rTab ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::SingleRefToVars" ); if ( rRef.IsColRel() ) rCol = aPos.Col() + rRef.nRelCol; else @@ -920,17 +948,18 @@ void ScInterpreter::SingleRefToVars( const ScSingleRefData & rRef, void ScInterpreter::PopSingleRef(SCCOL& rCol, SCROW &rRow, SCTAB& rTab) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PopSingleRef" ); if( sp ) { --sp; - ScToken* p = pStack[ sp ]; + FormulaToken* p = pStack[ sp ]; switch (p->GetType()) { case svError: nGlobalError = p->GetError(); break; case svSingleRef: - SingleRefToVars( p->GetSingleRef(), rCol, rRow, rTab); + SingleRefToVars( static_cast<ScToken*>(p)->GetSingleRef(), rCol, rRow, rTab); if ( pDok->aTableOpList.Count() > 0 ) ReplaceCell( rCol, rRow, rTab ); break; @@ -945,10 +974,11 @@ void ScInterpreter::PopSingleRef(SCCOL& rCol, SCROW &rRow, SCTAB& rTab) void ScInterpreter::PopSingleRef( ScAddress& rAdr ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PopSingleRef" ); if( sp ) { --sp; - ScToken* p = pStack[ sp ]; + FormulaToken* p = pStack[ sp ]; switch (p->GetType()) { case svError: @@ -959,7 +989,7 @@ void ScInterpreter::PopSingleRef( ScAddress& rAdr ) SCCOL nCol; SCROW nRow; SCTAB nTab; - SingleRefToVars( p->GetSingleRef(), nCol, nRow, nTab); + SingleRefToVars( static_cast<ScToken*>(p)->GetSingleRef(), nCol, nRow, nTab); rAdr.Set( nCol, nRow, nTab ); if ( pDok->aTableOpList.Count() > 0 ) ReplaceCell( rAdr ); @@ -979,6 +1009,7 @@ void ScInterpreter::DoubleRefToVars( const ScToken* p, SCCOL& rCol2, SCROW &rRow2, SCTAB& rTab2, BOOL bDontCheckForTableOp ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::DoubleRefToVars" ); const ScComplexRefData& rCRef = p->GetDoubleRef(); SingleRefToVars( rCRef.Ref1, rCol1, rRow1, rTab1); SingleRefToVars( rCRef.Ref2, rCol2, rRow2, rTab2); @@ -995,17 +1026,18 @@ void ScInterpreter::PopDoubleRef(SCCOL& rCol1, SCROW &rRow1, SCTAB& rTab1, SCCOL& rCol2, SCROW &rRow2, SCTAB& rTab2, BOOL bDontCheckForTableOp ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PopDoubleRef" ); if( sp ) { --sp; - ScToken* p = pStack[ sp ]; + FormulaToken* p = pStack[ sp ]; switch (p->GetType()) { case svError: nGlobalError = p->GetError(); break; case svDoubleRef: - DoubleRefToVars( p, rCol1, rRow1, rTab1, rCol2, rRow2, rTab2, + DoubleRefToVars( static_cast<ScToken*>(p), rCol1, rRow1, rTab1, rCol2, rRow2, rTab2, bDontCheckForTableOp); break; default: @@ -1020,6 +1052,7 @@ void ScInterpreter::PopDoubleRef(SCCOL& rCol1, SCROW &rRow1, SCTAB& rTab1, void ScInterpreter::DoubleRefToRange( const ScComplexRefData & rCRef, ScRange & rRange, BOOL bDontCheckForTableOp ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::DoubleRefToRange" ); SCCOL nCol; SCROW nRow; SCTAB nTab; @@ -1037,10 +1070,12 @@ void ScInterpreter::DoubleRefToRange( const ScComplexRefData & rCRef, void ScInterpreter::PopDoubleRef( ScRange & rRange, short & rParam, size_t & rRefInList ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PopDoubleRef" ); if (sp) { - ScToken* p = pStack[ sp-1 ]; - switch (p->GetType()) + formula::FormulaToken* pToken = pStack[ sp-1 ]; + ScToken* p = static_cast<ScToken*>(pToken); + switch (pToken->GetType()) { case svError: nGlobalError = p->GetError(); @@ -1082,17 +1117,18 @@ void ScInterpreter::PopDoubleRef( ScRange & rRange, short & rParam, size_t & rRe void ScInterpreter::PopDoubleRef( ScRange& rRange, BOOL bDontCheckForTableOp ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PopDoubleRef" ); if( sp ) { --sp; - ScToken* p = pStack[ sp ]; + FormulaToken* p = pStack[ sp ]; switch (p->GetType()) { case svError: nGlobalError = p->GetError(); break; case svDoubleRef: - DoubleRefToRange( p->GetDoubleRef(), rRange, bDontCheckForTableOp); + DoubleRefToRange( static_cast<ScToken*>(p)->GetDoubleRef(), rRange, bDontCheckForTableOp); break; default: SetError( errIllegalParameter); @@ -1105,6 +1141,7 @@ void ScInterpreter::PopDoubleRef( ScRange& rRange, BOOL bDontCheckForTableOp ) BOOL ScInterpreter::PopDoubleRefOrSingleRef( ScAddress& rAdr ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PopDoubleRefOrSingleRef" ); switch ( GetStackType() ) { case svDoubleRef : @@ -1130,6 +1167,7 @@ BOOL ScInterpreter::PopDoubleRefOrSingleRef( ScAddress& rAdr ) void ScInterpreter::PopDoubleRefPushMatrix() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PopDoubleRefPushMatrix" ); if ( GetStackType() == svDoubleRef ) { ScMatrixRef pMat = GetMatrix(); @@ -1145,18 +1183,20 @@ void ScInterpreter::PopDoubleRefPushMatrix() ScTokenMatrixMap* ScInterpreter::CreateTokenMatrixMap() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CreateTokenMatrixMap" ); return new ScTokenMatrixMap; } bool ScInterpreter::ConvertMatrixParameters() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ConvertMatrixParameters" ); USHORT nParams = pCur->GetParamCount(); DBG_ASSERT( nParams <= sp, "ConvertMatrixParameters: stack/param count mismatch"); SCSIZE nJumpCols = 0, nJumpRows = 0; for ( USHORT i=1; i <= nParams && i <= sp; ++i ) { - ScToken* p = pStack[ sp - i ]; + FormulaToken* p = pStack[ sp - i ]; if ( p->GetOpCode() != ocPush ) { DBG_ERRORFILE( "ConvertMatrixParameters: not a push"); @@ -1178,7 +1218,7 @@ bool ScInterpreter::ConvertMatrixParameters() if ( ScParameterClassification::GetParameterType( pCur, nParams - i) == ScParameterClassification::Value ) { // only if single value expected - ScMatrixRef pMat = p->GetMatrix(); + ScMatrixRef pMat = static_cast<ScToken*>(p)->GetMatrix(); if ( !pMat ) SetError( errUnknownVariable); else @@ -1202,7 +1242,7 @@ bool ScInterpreter::ConvertMatrixParameters() SCCOL nCol1, nCol2; SCROW nRow1, nRow2; SCTAB nTab1, nTab2; - DoubleRefToVars( p, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); + DoubleRefToVars( static_cast<const ScToken*>( p), nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); // Make sure the map exists, created if not. GetTokenMatrixMap(); ScMatrixRef pMat = CreateMatrixFromDoubleRef( p, @@ -1246,7 +1286,7 @@ bool ScInterpreter::ConvertMatrixParameters() short nStart = nPC - 1; // restart on current code (-1) short nNext = nPC; // next instruction after subroutine short nStop = nPC + 1; // stop subroutine before reaching that - ScTokenRef xNew; + FormulaTokenRef xNew; ScTokenMatrixMap::const_iterator aMapIter; if (pTokenMatrixMap && ((aMapIter = pTokenMatrixMap->find( pCur)) != pTokenMatrixMap->end())) @@ -1259,7 +1299,7 @@ bool ScInterpreter::ConvertMatrixParameters() ScTokenVec* pParams = new ScTokenVec( nParams); for ( USHORT i=1; i <= nParams && sp > 0; ++i ) { - ScToken* p = pStack[ --sp ]; + FormulaToken* p = pStack[ --sp ]; p->IncRef(); // store in reverse order such that a push may simply iterate (*pParams)[ nParams - i ] = p; @@ -1280,10 +1320,11 @@ bool ScInterpreter::ConvertMatrixParameters() ScMatrixRef ScInterpreter::PopMatrix() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PopMatrix" ); if( sp ) { --sp; - ScToken* p = pStack[ sp ]; + FormulaToken* p = pStack[ sp ]; switch (p->GetType()) { case svError: @@ -1291,7 +1332,7 @@ ScMatrixRef ScInterpreter::PopMatrix() break; case svMatrix: { - ScMatrix* pMat = p->GetMatrix(); + ScMatrix* pMat = static_cast<ScToken*>(p)->GetMatrix(); if ( pMat ) pMat->SetErrorInterpreter( this); else @@ -1310,21 +1351,24 @@ ScMatrixRef ScInterpreter::PopMatrix() void ScInterpreter::PushDouble(double nVal) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushDouble" ); TreatDoubleError( nVal ); if (!IfErrorPushError()) - PushTempTokenWithoutError( new ScDoubleToken( nVal ) ); + PushTempTokenWithoutError( new FormulaDoubleToken( nVal ) ); } void ScInterpreter::PushInt(int nVal) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushInt" ); if (!IfErrorPushError()) - PushTempTokenWithoutError( new ScDoubleToken( nVal ) ); + PushTempTokenWithoutError( new FormulaDoubleToken( nVal ) ); } void ScInterpreter::PushStringBuffer( const sal_Unicode* pString ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushStringBuffer" ); if ( pString ) PushString( String( pString ) ); else @@ -1334,13 +1378,15 @@ void ScInterpreter::PushStringBuffer( const sal_Unicode* pString ) void ScInterpreter::PushString( const String& rString ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushString" ); if (!IfErrorPushError()) - PushTempTokenWithoutError( new ScStringToken( rString ) ); + PushTempTokenWithoutError( new FormulaStringToken( rString ) ); } void ScInterpreter::PushSingleRef(SCCOL nCol, SCROW nRow, SCTAB nTab) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushSingleRef" ); if (!IfErrorPushError()) { ScSingleRefData aRef; @@ -1356,6 +1402,7 @@ void ScInterpreter::PushSingleRef(SCCOL nCol, SCROW nRow, SCTAB nTab) void ScInterpreter::PushDoubleRef(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushDoubleRef" ); if (!IfErrorPushError()) { ScComplexRefData aRef; @@ -1373,6 +1420,7 @@ void ScInterpreter::PushDoubleRef(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, void ScInterpreter::PushMatrix(ScMatrix* pMat) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushMatrix" ); pMat->SetErrorInterpreter( NULL); // No if (!IfErrorPushError()) because ScMatrix stores errors itself, // but with notifying ScInterpreter via nGlobalError, substituting it would @@ -1385,48 +1433,56 @@ void ScInterpreter::PushMatrix(ScMatrix* pMat) void ScInterpreter::PushError( USHORT nError ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushError" ); SetError( nError ); // only sets error if not already set - PushTempTokenWithoutError( new ScErrorToken( nGlobalError)); + PushTempTokenWithoutError( new FormulaErrorToken( nGlobalError)); } void ScInterpreter::PushParameterExpected() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushParameterExpected" ); PushError( errParameterExpected); } void ScInterpreter::PushIllegalParameter() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushIllegalParameter" ); PushError( errIllegalParameter); } void ScInterpreter::PushIllegalArgument() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushIllegalArgument" ); PushError( errIllegalArgument); } void ScInterpreter::PushNA() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushNA" ); PushError( NOTAVAILABLE); } void ScInterpreter::PushNoValue() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::PushNoValue" ); PushError( errNoValue); } BOOL ScInterpreter::IsMissing() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::IsMissing" ); return sp && pStack[sp - 1]->GetType() == svMissing; } StackVar ScInterpreter::GetRawStackType() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetRawStackType" ); StackVar eRes; if( sp ) { @@ -1443,6 +1499,7 @@ StackVar ScInterpreter::GetRawStackType() StackVar ScInterpreter::GetStackType() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetStackType" ); StackVar eRes; if( sp ) { @@ -1461,6 +1518,7 @@ StackVar ScInterpreter::GetStackType() StackVar ScInterpreter::GetStackType( BYTE nParam ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetStackType" ); StackVar eRes; if( sp > nParam-1 ) { @@ -1476,6 +1534,7 @@ StackVar ScInterpreter::GetStackType( BYTE nParam ) BOOL ScInterpreter::DoubleRefToPosSingleRef( const ScRange& rRange, ScAddress& rAdr ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::DoubleRefToPosSingleRef" ); // Check for a singleton first - no implicit intersection for them. if( rRange.aStart == rRange.aEnd ) { @@ -1564,6 +1623,7 @@ BOOL ScInterpreter::DoubleRefToPosSingleRef( const ScRange& rRange, ScAddress& r double ScInterpreter::GetDouble() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetDouble" ); double nVal; switch( GetRawStackType() ) { @@ -1647,6 +1707,7 @@ double ScInterpreter::GetDouble() double ScInterpreter::GetDoubleWithDefault(double nDefault) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetDoubleWithDefault" ); bool bMissing = IsMissing(); double nResultVal = GetDouble(); if ( bMissing ) @@ -1657,6 +1718,7 @@ double ScInterpreter::GetDoubleWithDefault(double nDefault) const String& ScInterpreter::GetString() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetString" ); switch (GetRawStackType()) { case svError: @@ -1747,6 +1809,7 @@ const String& ScInterpreter::GetString() ScMatValType ScInterpreter::GetDoubleOrStringFromMatrix( double& rDouble, String& rString ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetDoubleOrStringFromMatrix" ); ScMatValType nMatValType = SC_MATVAL_EMPTY; switch ( GetStackType() ) { @@ -1796,6 +1859,7 @@ ScMatValType ScInterpreter::GetDoubleOrStringFromMatrix( double& rDouble, void ScInterpreter::ScDBGet() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDBGet" ); SCTAB nTab; ScQueryParam aQueryParam; BOOL bMissingField = FALSE; @@ -1873,6 +1937,7 @@ void ScInterpreter::ScDBGet() void ScInterpreter::ScExternal() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScExternal" ); USHORT nIndex; BYTE nParamCount = GetByte(); String aUnoName; @@ -2419,12 +2484,14 @@ void ScInterpreter::ScExternal() void ScInterpreter::ScMissing() { - PushTempToken( new ScMissingToken ); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMissing" ); + PushTempToken( new FormulaMissingToken ); } void ScInterpreter::ScMacro() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMacro" ); SbxBase::ResetError(); BYTE nParamCount = GetByte(); @@ -2653,6 +2720,7 @@ void ScInterpreter::ScMacro() BOOL ScInterpreter::SetSbxVariable( SbxVariable* pVar, const ScAddress& rPos ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::SetSbxVariable" ); BOOL bOk = TRUE; ScBaseCell* pCell = pDok->GetCell( rPos ); if (pCell) @@ -2710,6 +2778,7 @@ BOOL ScInterpreter::SetSbxVariable( SbxVariable* pVar, const ScAddress& rPos ) void ScInterpreter::ScTableOp() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScTableOp" ); BYTE nParamCount = GetByte(); if (nParamCount != 3 && nParamCount != 5) { @@ -2805,6 +2874,7 @@ void ScInterpreter::ScTableOp() void ScInterpreter::ScErrCell() { +RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScErrCell" ); double fErrNum = GetDouble(); PushError((USHORT) fErrNum); } @@ -2812,6 +2882,7 @@ void ScInterpreter::ScErrCell() void ScInterpreter::ScDBArea() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDBArea" ); ScDBData* pDBData = pDok->GetDBCollection()->FindIndex( pCur->GetIndex()); if (pDBData) { @@ -2833,6 +2904,7 @@ void ScInterpreter::ScDBArea() void ScInterpreter::ScColRowNameAuto() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScColRowNameAuto" ); ScComplexRefData aRefData( pCur->GetDoubleRef() ); aRefData.CalcAbsIfRel( aPos ); if ( aRefData.Valid() ) @@ -2923,7 +2995,7 @@ void ScInterpreter::ScExternalRef() { case svExternalSingleRef: { - SingleRefData aData(pCur->GetSingleRef()); + ScSingleRefData aData(pCur->GetSingleRef()); if (aData.IsTabRel()) { DBG_ERROR("ScCompiler::GetToken: external single reference must have an absolute table reference!"); @@ -2951,7 +3023,7 @@ void ScInterpreter::ScExternalRef() //break; // unreachable, prevent compiler warning case svExternalDoubleRef: { - ComplRefData aData(pCur->GetDoubleRef()); + ScComplexRefData aData(pCur->GetDoubleRef()); if (aData.Ref1.IsTabRel() || aData.Ref2.IsTabRel()) { DBG_ERROR("ScCompiler::GetToken: external double reference must have an absolute table reference!"); @@ -2993,6 +3065,7 @@ void ScInterpreter::ScExternalRef() void ScInterpreter::ScAnswer() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScAnswer" ); String aStr( GetString() ); if( aStr.EqualsIgnoreCaseAscii( "Das Leben, das Universum und der ganze Rest" ) ) { @@ -3006,6 +3079,7 @@ void ScInterpreter::ScAnswer() void ScInterpreter::ScCalcTeam() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScCalcTeam" ); static BOOL bShown = FALSE; if( !bShown ) { @@ -3023,6 +3097,7 @@ void ScInterpreter::ScCalcTeam() void ScInterpreter::ScSpewFunc() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSpewFunc" ); BOOL bRefresh = FALSE; BOOL bClear = FALSE; // Stack aufraeumen @@ -3070,6 +3145,7 @@ extern "C" { static void SAL_CALL thisModule() {} } void ScInterpreter::ScGame() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGame" ); enum GameType { SC_GAME_NONE, SC_GAME_ONCE, @@ -3298,6 +3374,7 @@ ScInterpreter::ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc, pFormatter( pDoc->GetFormatTable() ), bCalcAsShown( pDoc->GetDocOptions().IsCalcAsShown() ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScTTT" ); // pStack = new ScToken*[ MAXSTACK ]; BYTE cMatFlag = pMyFormulaCell->GetMatrixFlag(); @@ -3331,6 +3408,7 @@ ScInterpreter::~ScInterpreter() void ScInterpreter::GlobalExit() // static { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GlobalExit" ); DBG_ASSERT(!bGlobalStackInUse, "wer benutzt noch den TokenStack?"); DELETEZ(pGlobalStack); } @@ -3338,6 +3416,7 @@ void ScInterpreter::GlobalExit() // static StackVar ScInterpreter::Interpret() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::Interpret" ); short nRetTypeExpr = NUMBERFORMAT_UNDEFINED; ULONG nRetIndexExpr = 0; USHORT nErrorFunction = 0; @@ -3370,7 +3449,7 @@ StackVar ScInterpreter::Interpret() if ( eOp == ocPush ) { // RPN code push without error - PushWithoutError( (ScToken&) *pCur ); + PushWithoutError( (FormulaToken&) *pCur ); } else if (pTokenMatrixMap && !(eOp == ocIf || eOp == ocChose) && ((aTokenMatrixMapIter = pTokenMatrixMap->find( pCur)) != @@ -3754,7 +3833,7 @@ StackVar ScInterpreter::Interpret() // Not all functions pop all parameters in case an error is // generated. Clean up stack. Assumes that every function pushes a // result, may be arbitrary in case of error. - const ScToken* pLocalResult = pStack[ sp - 1 ]; + const FormulaToken* pLocalResult = pStack[ sp - 1 ]; while (sp > nStackBase) Pop(); PushTempToken( *pLocalResult ); @@ -3808,7 +3887,7 @@ StackVar ScInterpreter::Interpret() { if ( !nErrorFunctionCount ) { // count of errorcode functions in formula - for ( ScToken* t = rArr.FirstRPN(); t; t = rArr.NextRPN() ) + for ( FormulaToken* t = rArr.FirstRPN(); t; t = rArr.NextRPN() ) { switch ( t->GetOpCode() ) { @@ -3895,14 +3974,14 @@ StackVar ScInterpreter::Interpret() { if ( xMat->IsEmptyPath( 0, 0)) { // result of empty FALSE jump path - ScTokenRef xRes = new ScDoubleToken( 0.0); + FormulaTokenRef xRes = new FormulaDoubleToken( 0.0); PushTempToken( new ScMatrixCellResultToken( xMat, xRes)); nRetTypeExpr = NUMBERFORMAT_LOGICAL; } else { String aStr( pMatVal->GetString()); - ScTokenRef xRes = new ScStringToken( aStr); + FormulaTokenRef xRes = new FormulaStringToken( aStr); PushTempToken( new ScMatrixCellResultToken( xMat, xRes)); nRetTypeExpr = NUMBERFORMAT_TEXT; } @@ -3910,11 +3989,11 @@ StackVar ScInterpreter::Interpret() else { USHORT nErr = GetDoubleErrorValue( pMatVal->fVal); - ScTokenRef xRes; + FormulaTokenRef xRes; if (nErr) - xRes = new ScErrorToken( nErr); + xRes = new FormulaErrorToken( nErr); else - xRes = new ScDoubleToken( pMatVal->fVal); + xRes = new FormulaDoubleToken( pMatVal->fVal); PushTempToken( new ScMatrixCellResultToken( xMat, xRes)); if ( nRetTypeExpr != NUMBERFORMAT_LOGICAL ) nRetTypeExpr = NUMBERFORMAT_NUMBER; @@ -3961,10 +4040,10 @@ StackVar ScInterpreter::Interpret() // THE final result. xResult = PopToken(); if (!xResult) - xResult = new ScErrorToken( errUnknownStackVariable); + xResult = new FormulaErrorToken( errUnknownStackVariable); // release tokens in expression stack - ScToken** p = pStack; + FormulaToken** p = pStack; while( maxsp-- ) (*p++)->DecRef(); diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index 32be76431569..41ddf3dc0aa0 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -36,7 +36,7 @@ #ifndef INCLUDED_RTL_MATH_HXX #include <rtl/math.hxx> #endif - +#include <rtl/logfile.hxx> #include <string.h> #include <math.h> #include <stdio.h> @@ -63,13 +63,50 @@ #include <vector> using ::std::vector; +using namespace formula; const double fInvEpsilon = 1.0E-7; // ----------------------------------------------------------------------- + struct MatrixAdd : public ::std::binary_function<double,double,double> + { + inline double operator() (const double& lhs, const double& rhs) const + { + return ::rtl::math::approxAdd( lhs,rhs); + } + }; + struct MatrixSub : public ::std::binary_function<double,double,double> + { + inline double operator() (const double& lhs, const double& rhs) const + { + return ::rtl::math::approxSub( lhs,rhs); + } + }; + struct MatrixMul : public ::std::binary_function<double,double,double> + { + inline double operator() (const double& lhs, const double& rhs) const + { + return lhs * rhs; + } + }; + struct MatrixDiv : public ::std::binary_function<double,double,double> + { + inline double operator() (const double& lhs, const double& rhs) const + { + return ScInterpreter::div( lhs,rhs); + } + }; + struct MatrixPow : public ::std::binary_function<double,double,double> + { + inline double operator() (const double& lhs, const double& rhs) const + { + return ::pow( lhs,rhs); + } + }; double ScInterpreter::ScGetGCD(double fx, double fy) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::div" ); // By ODFF definition GCD(0,a) => a. This is also vital for the code in // ScGCD() to work correctly with a preset fy=0.0 if (fy == 0.0) @@ -91,6 +128,7 @@ double ScInterpreter::ScGetGCD(double fx, double fy) void ScInterpreter::ScGCD() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGCD" ); short nParamCount = GetByte(); if ( MustHaveParamCountMin( nParamCount, 1 ) ) { @@ -272,6 +310,7 @@ void ScInterpreter:: ScLCM() ScMatrixRef ScInterpreter::GetNewMat(SCSIZE nC, SCSIZE nR) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetNewMat" ); ScMatrix* pMat = new ScMatrix( nC, nR); pMat->SetErrorInterpreter( this); SCSIZE nCols, nRows; @@ -285,10 +324,11 @@ ScMatrixRef ScInterpreter::GetNewMat(SCSIZE nC, SCSIZE nR) return pMat; } -ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const ScToken* pToken, +ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2 ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CreateMatrixFromDoubleRef" ); ScMatrixRef pMat = NULL; if (nTab1 == nTab2 && !nGlobalError) { @@ -299,7 +339,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const ScToken* pToken, SetError(errStackOverflow); else if (pTokenMatrixMap && ((aIter = pTokenMatrixMap->find( pToken)) != pTokenMatrixMap->end())) - pMat = (*aIter).second->GetMatrix(); + pMat = static_cast<ScToken*>((*aIter).second.get())->GetMatrix(); else { SCSIZE nMatCols = static_cast<SCSIZE>(nCol2 - nCol1 + 1); @@ -409,6 +449,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const ScToken* pToken, ScMatrixRef ScInterpreter::GetMatrix() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetMatrix" ); ScMatrixRef pMat = NULL; switch (GetRawStackType()) { @@ -438,7 +479,7 @@ ScMatrixRef ScInterpreter::GetMatrix() SCCOL nCol1, nCol2; SCROW nRow1, nRow2; SCTAB nTab1, nTab2; - const ScToken* p = sp ? pStack[sp-1] : NULL; + const ScToken* p = sp ? static_cast<const ScToken*>(pStack[sp-1]) : NULL; PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); pMat = CreateMatrixFromDoubleRef( p, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); @@ -491,6 +532,7 @@ ScMatrixRef ScInterpreter::GetMatrix() void ScInterpreter::ScMatValue() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMatValue" ); if ( MustHaveParamCount( GetByte(), 3 ) ) { // 0 to count-1 @@ -511,26 +553,7 @@ void ScInterpreter::ScMatValue() else { const ScMatrix* pMat = ((ScFormulaCell*)pCell)->GetMatrix(); - if (pMat) - { - SCSIZE nCl, nRw; - pMat->GetDimensions(nCl, nRw); - if (nC < nCl && nR < nRw) - { - ScMatValType nMatValType; - const ScMatrixValue* pMatVal = pMat->Get( nC, - nR, nMatValType); - if (ScMatrix::IsNonValueType( nMatValType)) - PushString( pMatVal->GetString() ); - else - PushDouble(pMatVal->fVal); - // also handles DoubleError - } - else - PushNoValue(); - } - else - PushNoValue(); + CalculateMatrixValue(pMat,nC,nR); } } else @@ -569,26 +592,7 @@ void ScInterpreter::ScMatValue() case svMatrix: { ScMatrixRef pMat = PopMatrix(); - if (pMat) - { - SCSIZE nCl, nRw; - pMat->GetDimensions(nCl, nRw); - if (nC < nCl && nR < nRw) - { - ScMatValType nMatValType; - const ScMatrixValue* pMatVal = pMat->Get( nC, nR, - nMatValType); - if (ScMatrix::IsNonValueType( nMatValType)) - PushString( pMatVal->GetString() ); - else - PushDouble(pMatVal->fVal); - // also handles DoubleError - } - else - PushNoValue(); - } - else - PushNoValue(); + CalculateMatrixValue(pMat,nC,nR); } break; default: @@ -598,9 +602,33 @@ void ScInterpreter::ScMatValue() } } } +void ScInterpreter::CalculateMatrixValue(const ScMatrix* pMat,SCSIZE nC,SCSIZE nR) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CalculateMatrixValue" ); + if (pMat) + { + SCSIZE nCl, nRw; + pMat->GetDimensions(nCl, nRw); + if (nC < nCl && nR < nRw) + { + ScMatValType nMatValType; + const ScMatrixValue* pMatVal = pMat->Get( nC, nR,nMatValType); + if (ScMatrix::IsNonValueType( nMatValType)) + PushString( pMatVal->GetString() ); + else + PushDouble(pMatVal->fVal); + // also handles DoubleError + } + else + PushNoValue(); + } + else + PushNoValue(); +} void ScInterpreter::ScEMat() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScEMat" ); if ( MustHaveParamCount( GetByte(), 1 ) ) { SCSIZE nDim = static_cast<SCSIZE>(::rtl::math::approxFloor(GetDouble())); @@ -622,6 +650,7 @@ void ScInterpreter::ScEMat() void ScInterpreter::MEMat(ScMatrix* mM, SCSIZE n) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::MEMat" ); mM->FillDouble(0.0, 0, 0, n-1, n-1); for (SCSIZE i = 0; i < n; i++) mM->PutDouble(1.0, i, i); @@ -631,6 +660,7 @@ void ScInterpreter::MFastMult(ScMatrix* pA, ScMatrix* pB, ScMatrix* pR, SCSIZE n, SCSIZE m, SCSIZE l) // Multipliziert n x m Mat a mit m x l Mat b nach Mat r { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::MFastMult" ); double sum; for (SCSIZE i = 0; i < n; i++) { @@ -800,6 +830,7 @@ static void lcl_LUP_solve( const ScMatrix* mLU, const SCSIZE n, void ScInterpreter::ScMatDet() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMatDet" ); if ( MustHaveParamCount( GetByte(), 1 ) ) { ScMatrixRef pMat = GetMatrix(); @@ -846,6 +877,7 @@ void ScInterpreter::ScMatDet() void ScInterpreter::ScMatInv() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMatInv" ); if ( MustHaveParamCount( GetByte(), 1 ) ) { ScMatrixRef pMat = GetMatrix(); @@ -947,6 +979,7 @@ void ScInterpreter::ScMatInv() void ScInterpreter::ScMatMult() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMatMult" ); if ( MustHaveParamCount( GetByte(), 2 ) ) { ScMatrixRef pMat2 = GetMatrix(); @@ -996,6 +1029,7 @@ void ScInterpreter::ScMatMult() void ScInterpreter::ScMatTrans() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMatTrans" ); if ( MustHaveParamCount( GetByte(), 1 ) ) { ScMatrixRef pMat = GetMatrix(); @@ -1035,36 +1069,8 @@ inline SCSIZE lcl_GetMinExtent( SCSIZE n1, SCSIZE n2 ) return n2; } -ScMatrixRef ScInterpreter::MatAdd(ScMatrix* pMat1, ScMatrix* pMat2) -{ - SCSIZE nC1, nC2, nMinC; - SCSIZE nR1, nR2, nMinR; - SCSIZE i, j; - pMat1->GetDimensions(nC1, nR1); - pMat2->GetDimensions(nC2, nR2); - nMinC = lcl_GetMinExtent( nC1, nC2); - nMinR = lcl_GetMinExtent( nR1, nR2); - ScMatrixRef xResMat = GetNewMat(nMinC, nMinR); - if (xResMat) - { - ScMatrix* pResMat = xResMat; - for (i = 0; i < nMinC; i++) - { - for (j = 0; j < nMinR; j++) - { - if (pMat1->IsValueOrEmpty(i,j) && pMat2->IsValueOrEmpty(i,j)) - pResMat->PutDouble( ::rtl::math::approxAdd( pMat1->GetDouble(i,j), - pMat2->GetDouble(i,j)), i, j); - else - pResMat->PutString(ScGlobal::GetRscString( - STR_NO_VALUE), i, j); - } - } - } - return xResMat; -} - -ScMatrixRef ScInterpreter::MatSub(ScMatrix* pMat1, ScMatrix* pMat2) +template<class _Function> +ScMatrixRef lcl_MatrixCalculation(const _Function& _pOperation,ScMatrix* pMat1, ScMatrix* pMat2,ScInterpreter* _pIterpreter) { SCSIZE nC1, nC2, nMinC; SCSIZE nR1, nR2, nMinR; @@ -1073,7 +1079,7 @@ ScMatrixRef ScInterpreter::MatSub(ScMatrix* pMat1, ScMatrix* pMat2) pMat2->GetDimensions(nC2, nR2); nMinC = lcl_GetMinExtent( nC1, nC2); nMinR = lcl_GetMinExtent( nR1, nR2); - ScMatrixRef xResMat = GetNewMat(nMinC, nMinR); + ScMatrixRef xResMat = _pIterpreter->GetNewMat(nMinC, nMinR); if (xResMat) { ScMatrix* pResMat = xResMat; @@ -1082,99 +1088,12 @@ ScMatrixRef ScInterpreter::MatSub(ScMatrix* pMat1, ScMatrix* pMat2) for (j = 0; j < nMinR; j++) { if (pMat1->IsValueOrEmpty(i,j) && pMat2->IsValueOrEmpty(i,j)) - pResMat->PutDouble( ::rtl::math::approxSub( pMat1->GetDouble(i,j), - pMat2->GetDouble(i,j)), i, j); - else - pResMat->PutString(ScGlobal::GetRscString( - STR_NO_VALUE), i, j); - } - } - } - return xResMat; -} - -ScMatrixRef ScInterpreter::MatMul(ScMatrix* pMat1, ScMatrix* pMat2) -{ - SCSIZE nC1, nC2, nMinC; - SCSIZE nR1, nR2, nMinR; - SCSIZE i, j; - pMat1->GetDimensions(nC1, nR1); - pMat2->GetDimensions(nC2, nR2); - nMinC = lcl_GetMinExtent( nC1, nC2); - nMinR = lcl_GetMinExtent( nR1, nR2); - ScMatrixRef xResMat = GetNewMat(nMinC, nMinR); - if (xResMat) - { - ScMatrix* pResMat = xResMat; - for (i = 0; i < nMinC; i++) - { - for (j = 0; j < nMinR; j++) - { - if (pMat1->IsValueOrEmpty(i,j) && pMat2->IsValueOrEmpty(i,j)) - pResMat->PutDouble(pMat1->GetDouble(i,j) * - pMat2->GetDouble(i,j), i, j); - else - pResMat->PutString(ScGlobal::GetRscString( - STR_NO_VALUE), i, j); - } - } - } - return xResMat; -} - -ScMatrixRef ScInterpreter::MatDiv(ScMatrix* pMat1, ScMatrix* pMat2) -{ - SCSIZE nC1, nC2, nMinC; - SCSIZE nR1, nR2, nMinR; - SCSIZE i, j; - pMat1->GetDimensions(nC1, nR1); - pMat2->GetDimensions(nC2, nR2); - nMinC = lcl_GetMinExtent( nC1, nC2); - nMinR = lcl_GetMinExtent( nR1, nR2); - ScMatrixRef xResMat = GetNewMat(nMinC, nMinR); - if (xResMat) - { - ScMatrix* pResMat = xResMat; - for (i = 0; i < nMinC; i++) - { - for (j = 0; j < nMinR; j++) - { - if (pMat1->IsValueOrEmpty(i,j) && pMat2->IsValueOrEmpty(i,j)) - pResMat->PutDouble( - div( pMat1->GetDouble(i,j), pMat2->GetDouble(i,j)), - i, j); - else - pResMat->PutString(ScGlobal::GetRscString( - STR_NO_VALUE), i, j); - } - } - } - return xResMat; -} - -ScMatrixRef ScInterpreter::MatPow(ScMatrix* pMat1, ScMatrix* pMat2) -{ - SCSIZE nC1, nC2, nMinC; - SCSIZE nR1, nR2, nMinR; - SCSIZE i, j; - pMat1->GetDimensions(nC1, nR1); - pMat2->GetDimensions(nC2, nR2); - nMinC = lcl_GetMinExtent( nC1, nC2); - nMinR = lcl_GetMinExtent( nR1, nR2); - ScMatrixRef xResMat = GetNewMat(nMinC, nMinR); - if (xResMat) - { - ScMatrix* pResMat = xResMat; - for (i = 0; i < nMinC; i++) - { - for (j = 0; j < nMinR; j++) - { - if (pMat1->IsValueOrEmpty(i,j) && pMat2->IsValueOrEmpty(i,j)) - pResMat->PutDouble(pow(pMat1->GetDouble(i,j), - pMat2->GetDouble(i,j)), i, j); + { + double d = _pOperation(pMat1->GetDouble(i,j),pMat2->GetDouble(i,j)); + pResMat->PutDouble( d, i, j); + } else - pResMat->PutString(ScGlobal::GetRscString( - STR_NO_VALUE), i, j); + pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i, j); } } } @@ -1183,6 +1102,7 @@ ScMatrixRef ScInterpreter::MatPow(ScMatrix* pMat1, ScMatrix* pMat2) ScMatrixRef ScInterpreter::MatConcat(ScMatrix* pMat1, ScMatrix* pMat2) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::MatConcat" ); SCSIZE nC1, nC2, nMinC; SCSIZE nR1, nR2, nMinR; SCSIZE i, j; @@ -1246,6 +1166,12 @@ void lcl_GetDiffDateTimeFmtType( short& nFuncFmt, short nFmt1, short nFmt2 ) void ScInterpreter::ScAdd() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScAdd" ); + CalculateAddSub(FALSE); +} +void ScInterpreter::CalculateAddSub(BOOL _bSub) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CalculateAddSub" ); ScMatrixRef pMat1 = NULL; ScMatrixRef pMat2 = NULL; double fVal1 = 0.0, fVal2 = 0.0; @@ -1298,7 +1224,18 @@ void ScInterpreter::ScAdd() } if (pMat1 && pMat2) { - ScMatrixRef pResMat = MatAdd(pMat1, pMat2); + ScMatrixRef pResMat; + if ( _bSub ) + { + MatrixSub aSub; + pResMat = lcl_MatrixCalculation(aSub ,pMat1, pMat2,this); + } + else + { + MatrixAdd aAdd; + pResMat = lcl_MatrixCalculation(aAdd ,pMat1, pMat2,this); + } + if (!pResMat) PushNoValue(); else @@ -1307,32 +1244,51 @@ void ScInterpreter::ScAdd() else if (pMat1 || pMat2) { double fVal; + BOOL bFlag; ScMatrixRef pMat = pMat1; if (!pMat) { fVal = fVal1; pMat = pMat2; + bFlag = TRUE; // double - Matrix } else + { fVal = fVal2; + bFlag = FALSE; // Matrix - double + } SCSIZE nC, nR; pMat->GetDimensions(nC, nR); ScMatrixRef pResMat = GetNewMat(nC, nR); if (pResMat) { SCSIZE nCount = nC * nR; - for ( SCSIZE i = 0; i < nCount; i++ ) + if (bFlag || !_bSub ) { - if (pMat->IsValue(i)) - pResMat->PutDouble( ::rtl::math::approxAdd( pMat->GetDouble(i), fVal), i); - else - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i); + for ( SCSIZE i = 0; i < nCount; i++ ) + { + if (pMat->IsValue(i)) + pResMat->PutDouble( _bSub ? ::rtl::math::approxSub( fVal, pMat->GetDouble(i)) : ::rtl::math::approxAdd( pMat->GetDouble(i), fVal), i); + else + pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i); + } // for ( SCSIZE i = 0; i < nCount; i++ ) + } // if (bFlag || !_bSub ) + else + { + for ( SCSIZE i = 0; i < nCount; i++ ) + { if (pMat->IsValue(i)) + pResMat->PutDouble( ::rtl::math::approxSub( pMat->GetDouble(i), fVal), i); + else + pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i); + } // for ( SCSIZE i = 0; i < nCount; i++ ) } PushMatrix(pResMat); } else PushIllegalArgument(); } + else if ( _bSub ) + PushDouble( ::rtl::math::approxSub( fVal1, fVal2 ) ); else PushDouble( ::rtl::math::approxAdd( fVal1, fVal2 ) ); if ( nFmtCurrencyType == NUMBERFORMAT_CURRENCY ) @@ -1350,6 +1306,7 @@ void ScInterpreter::ScAdd() void ScInterpreter::ScAmpersand() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScAmpersand" ); ScMatrixRef pMat1 = NULL; ScMatrixRef pMat2 = NULL; String sStr1, sStr2; @@ -1441,124 +1398,13 @@ void ScInterpreter::ScAmpersand() void ScInterpreter::ScSub() { - ScMatrixRef pMat1 = NULL; - ScMatrixRef pMat2 = NULL; - double fVal1 = 0.0, fVal2 = 0.0; - short nFmt1, nFmt2; - nFmt1 = nFmt2 = NUMBERFORMAT_UNDEFINED; - short nFmtCurrencyType = nCurFmtType; - ULONG nFmtCurrencyIndex = nCurFmtIndex; - short nFmtPercentType = nCurFmtType; - if ( GetStackType() == svMatrix ) - pMat2 = GetMatrix(); - else - { - fVal2 = GetDouble(); - switch ( nCurFmtType ) - { - case NUMBERFORMAT_DATE : - case NUMBERFORMAT_TIME : - case NUMBERFORMAT_DATETIME : - nFmt2 = nCurFmtType; - break; - case NUMBERFORMAT_CURRENCY : - nFmtCurrencyType = nCurFmtType; - nFmtCurrencyIndex = nCurFmtIndex; - break; - case NUMBERFORMAT_PERCENT : - nFmtPercentType = NUMBERFORMAT_PERCENT; - break; - } - } - if ( GetStackType() == svMatrix ) - pMat1 = GetMatrix(); - else - { - fVal1 = GetDouble(); - switch ( nCurFmtType ) - { - case NUMBERFORMAT_DATE : - case NUMBERFORMAT_TIME : - case NUMBERFORMAT_DATETIME : - nFmt1 = nCurFmtType; - break; - case NUMBERFORMAT_CURRENCY : - nFmtCurrencyType = nCurFmtType; - nFmtCurrencyIndex = nCurFmtIndex; - break; - case NUMBERFORMAT_PERCENT : - nFmtPercentType = NUMBERFORMAT_PERCENT; - break; - } - } - if (pMat1 && pMat2) - { - ScMatrixRef pResMat = MatSub(pMat1, pMat2); - if (!pResMat) - PushNoValue(); - else - PushMatrix(pResMat); - } - else if (pMat1 || pMat2) - { - double fVal; - BOOL bFlag; - ScMatrixRef pMat = pMat1; - if (!pMat) - { - fVal = fVal1; - pMat = pMat2; - bFlag = TRUE; // double - Matrix - } - else - { - fVal = fVal2; - bFlag = FALSE; // Matrix - double - } - SCSIZE nC, nR; - pMat->GetDimensions(nC, nR); - ScMatrixRef pResMat = GetNewMat(nC, nR); - if (pResMat) - { // mehr klammern wg. compiler macke - SCSIZE nCount = nC * nR; - if (bFlag) - { for ( SCSIZE i = 0; i < nCount; i++ ) - { if (pMat->IsValue(i)) - pResMat->PutDouble( ::rtl::math::approxSub( fVal, pMat->GetDouble(i)), i); - else - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i); - } - } - else - { for ( SCSIZE i = 0; i < nCount; i++ ) - { if (pMat->IsValue(i)) - pResMat->PutDouble( ::rtl::math::approxSub( pMat->GetDouble(i), fVal), i); - else - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i); - } - } - PushMatrix(pResMat); - } - else - PushIllegalArgument(); - } - else - PushDouble( ::rtl::math::approxSub( fVal1, fVal2 ) ); - if ( nFmtCurrencyType == NUMBERFORMAT_CURRENCY ) - { - nFuncFmtType = nFmtCurrencyType; - nFuncFmtIndex = nFmtCurrencyIndex; - } - else - { - lcl_GetDiffDateTimeFmtType( nFuncFmtType, nFmt1, nFmt2 ); - if ( nFmtPercentType == NUMBERFORMAT_PERCENT && nFuncFmtType == NUMBERFORMAT_NUMBER ) - nFuncFmtType = NUMBERFORMAT_PERCENT; - } + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSub" ); + CalculateAddSub(TRUE); } void ScInterpreter::ScMul() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMul" ); ScMatrixRef pMat1 = NULL; ScMatrixRef pMat2 = NULL; double fVal1 = 0.0, fVal2 = 0.0; @@ -1592,7 +1438,8 @@ void ScInterpreter::ScMul() } if (pMat1 && pMat2) { - ScMatrixRef pResMat = MatMul(pMat1, pMat2); + MatrixMul aMul; + ScMatrixRef pResMat = lcl_MatrixCalculation(aMul,pMat1, pMat2,this); if (!pResMat) PushNoValue(); else @@ -1636,6 +1483,7 @@ void ScInterpreter::ScMul() void ScInterpreter::ScDiv() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScDiv" ); ScMatrixRef pMat1 = NULL; ScMatrixRef pMat2 = NULL; double fVal1 = 0.0, fVal2 = 0.0; @@ -1665,7 +1513,8 @@ void ScInterpreter::ScDiv() } if (pMat1 && pMat2) { - ScMatrixRef pResMat = MatDiv(pMat1, pMat2); + MatrixDiv aDiv; + ScMatrixRef pResMat = lcl_MatrixCalculation(aDiv,pMat1, pMat2,this); if (!pResMat) PushNoValue(); else @@ -1725,12 +1574,14 @@ void ScInterpreter::ScDiv() void ScInterpreter::ScPower() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScPower" ); if ( MustHaveParamCount( GetByte(), 2 ) ) ScPow(); } void ScInterpreter::ScPow() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScPow" ); ScMatrixRef pMat1 = NULL; ScMatrixRef pMat2 = NULL; double fVal1 = 0.0, fVal2 = 0.0; @@ -1744,7 +1595,8 @@ void ScInterpreter::ScPow() fVal1 = GetDouble(); if (pMat1 && pMat2) { - ScMatrixRef pResMat = MatPow(pMat1, pMat2); + MatrixPow aPow; + ScMatrixRef pResMat = lcl_MatrixCalculation(aPow,pMat1, pMat2,this); if (!pResMat) PushNoValue(); else @@ -1797,6 +1649,7 @@ void ScInterpreter::ScPow() void ScInterpreter::ScSumProduct() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSumProduct" ); BYTE nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 1, 30 ) ) return; @@ -1814,6 +1667,7 @@ void ScInterpreter::ScSumProduct() SCSIZE nR, nR1; pMat2->GetDimensions(nC, nR); pMat = pMat2; + MatrixMul aMul; for (USHORT i = 1; i < nParamCount; i++) { pMat1 = GetMatrix(); @@ -1828,7 +1682,7 @@ void ScInterpreter::ScSumProduct() PushNoValue(); return; } - ScMatrixRef pResMat = MatMul(pMat1, pMat); + ScMatrixRef pResMat = lcl_MatrixCalculation(aMul,pMat1, pMat,this); if (!pResMat) { PushNoValue(); @@ -1849,6 +1703,12 @@ void ScInterpreter::ScSumProduct() void ScInterpreter::ScSumX2MY2() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSumX2MY2" ); + CalculateSumX2MY2SumX2DY2(FALSE); +} +void ScInterpreter::CalculateSumX2MY2SumX2DY2(BOOL _bSumX2DY2) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CalculateSumX2MY2SumX2DY2" ); if ( !MustHaveParamCount( GetByte(), 2 ) ) return; @@ -1879,50 +1739,23 @@ void ScInterpreter::ScSumX2MY2() fVal = pMat1->GetDouble(i,j); fSum += fVal * fVal; fVal = pMat2->GetDouble(i,j); - fSum -= fVal * fVal; + if ( _bSumX2DY2 ) + fSum += fVal * fVal; + else + fSum -= fVal * fVal; } PushDouble(fSum); } void ScInterpreter::ScSumX2DY2() { - if ( !MustHaveParamCount( GetByte(), 2 ) ) - return; - - ScMatrixRef pMat1 = NULL; - ScMatrixRef pMat2 = NULL; - SCSIZE i, j; - pMat2 = GetMatrix(); - pMat1 = GetMatrix(); - if (!pMat2 || !pMat1) - { - PushIllegalParameter(); - return; - } - SCSIZE nC1, nC2; - SCSIZE nR1, nR2; - pMat2->GetDimensions(nC2, nR2); - pMat1->GetDimensions(nC1, nR1); - if (nC1 != nC2 || nR1 != nR2) - { - PushNoValue(); - return; - } - double fVal, fSum = 0.0; - for (i = 0; i < nC1; i++) - for (j = 0; j < nR1; j++) - if (!pMat1->IsString(i,j) && !pMat2->IsString(i,j)) - { - fVal = pMat1->GetDouble(i,j); - fSum += fVal * fVal; - fVal = pMat2->GetDouble(i,j); - fSum += fVal * fVal; - } - PushDouble(fSum); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSumX2DY2" ); + CalculateSumX2MY2SumX2DY2(TRUE); } void ScInterpreter::ScSumXMY2() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScSumXMY2" ); if ( !MustHaveParamCount( GetByte(), 2 ) ) return; @@ -1943,12 +1776,12 @@ void ScInterpreter::ScSumXMY2() { PushNoValue(); return; - } - ScMatrixRef pResMat = MatSub(pMat1, pMat2); + } // if (nC1 != nC2 || nR1 != nR2) + MatrixSub aSub; + ScMatrixRef pResMat = lcl_MatrixCalculation(aSub,pMat1, pMat2,this); if (!pResMat) { PushNoValue(); - return; } else { @@ -1966,6 +1799,7 @@ void ScInterpreter::ScSumXMY2() void ScInterpreter::ScFrequency() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScFrequency" ); if ( !MustHaveParamCount( GetByte(), 2 ) ) return; @@ -2122,68 +1956,163 @@ BOOL ScInterpreter::RGetVariances( ScMatrix* pV, ScMatrix* pX, } return bOk; } - -void ScInterpreter::ScRGP() +// ----------------------------------------------------------------------------- +void ScInterpreter::Calculate(ScMatrixRef& pResMat,ScMatrixRef& pE,ScMatrixRef& pQ,ScMatrixRef& pV,ScMatrixRef& pMatX,BOOL bConstant,SCSIZE N,SCSIZE M,BYTE nCase) { - BYTE nParamCount = GetByte(); - if ( !MustHaveParamCount( nParamCount, 1, 4 ) ) - return; - BOOL bConstant, bStats; - if (nParamCount == 4) - bStats = GetBool(); - else - bStats = FALSE; - if (nParamCount >= 3) - bConstant = GetBool(); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::RGetVariances" ); + // pE[0] := Sigma i=1...n (Yi) + // pE[k] := Sigma i=1...n (Xki*Yi) + // pE[M+1] := Sigma i=1...n (Yi**2) + // pQ[0,M+1]:= B + // pQ[k,M+1]:= Mk + double fSQR, fSQT, fSQE; + fSQT = pE->GetDouble(M+1) + - pE->GetDouble(0) * pE->GetDouble(0) / (double)N; + fSQR = pE->GetDouble(M+1); + SCSIZE i, j; + for (i = 0; i < M+1; i++) + fSQR -= pQ->GetDouble(i, M+1) * pE->GetDouble(i); + fSQE = fSQT-fSQR; + // r2 (Bestimmtheitsmass, 0...1) + if (fSQT == 0.0) + pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 0, 2); else - bConstant = TRUE; - ScMatrixRef pMatX; - ScMatrixRef pMatY; - if (nParamCount >= 2) - pMatX = GetMatrix(); + pResMat->PutDouble (fSQE/fSQT, 0, 2); + // ssReg (Regressions-Quadratsumme) + pResMat->PutDouble(fSQE, 0, 4); + // ssResid (Residual-Quadratsumme, Summe der Abweichungsquadrate) + pResMat->PutDouble(fSQR, 1, 4); + for (i = 2; i < 5; i++) + for (j = 2; j < M+1; j++) + pResMat->PutString(ScGlobal::GetRscString(STR_NV_STR), j, i); + if (bConstant) + { + if (N-M-1 == 0) + { + pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 1, 2); + for (i = 0; i < M+1; i++) + pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i, 1); + } + else + { + double fSE2 = fSQR/(N-M-1); + // sey (Standardfehler des Schaetzwertes y) + pResMat->PutDouble(sqrt(fSE2), 1, 2); + // sen...se1 (Standardfehler der Koeffizienten mn...m1) + // seb (Standardfehler der Konstanten b) + if ( RGetVariances( pV, pMatX, M+1, N, nCase != 2, FALSE ) ) + { + for (i = 0; i < M+1; i++) + pResMat->PutDouble( sqrt(fSE2 * pV->GetDouble(i)), M-i, 1 ); + } + else + { + for (i = 0; i < M+1; i++) + pResMat->PutString(ScGlobal::GetRscString(STR_NV_STR), i, 1); + } + } + // F (F-Statistik) + if (fSQR == 0.0) + pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 0, 3); + else + pResMat->PutDouble(((double)(N-M-1))*fSQE/fSQR/((double)M),0, 3); + // df (Freiheitsgrad) + pResMat->PutDouble(((double)(N-M-1)), 1, 3); + } else - pMatX = NULL; - pMatY = GetMatrix(); - if (!pMatY) { - PushIllegalParameter(); - return; + if (N-M == 0) + { + pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 1, 2); + for (i = 0; i < M+1; i++) + pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i, 1); + } + else + { + double fSE2 = fSQR/(N-M); + pResMat->PutDouble(sqrt(fSE2), 1, 2); + if ( RGetVariances( pV, pMatX, M, N, nCase != 2, TRUE ) ) + { + for (i = 0; i < M; i++) + pResMat->PutDouble( sqrt(fSE2 * pV->GetDouble(i)), M-i-1, 1 ); + pResMat->PutString(ScGlobal::GetRscString(STR_NV_STR), M, 1); + } + else + { + for (i = 0; i < M+1; i++) + pResMat->PutString(ScGlobal::GetRscString(STR_NV_STR), i, 1); + } + } + if (fSQR == 0.0) + pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 0, 3); + else + pResMat->PutDouble(((double)(N-M))*fSQE/fSQR/((double)M),0, 3); + pResMat->PutDouble(((double)(N-M)), 1, 3); } - BYTE nCase; // 1 = normal, 2,3 = mehrfach - SCSIZE nCX, nCY; - SCSIZE nRX, nRY; - SCSIZE M = 0, N = 0; +} + +void ScInterpreter::ScRGP() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRGP" ); + CalulateRGPRKP(FALSE); +} +bool ScInterpreter::CheckMatrix(BOOL _bLOG,BOOL _bTrendGrowth,BYTE& nCase,SCSIZE& nCX,SCSIZE& nCY,SCSIZE& nRX,SCSIZE& nRY,SCSIZE& M,SCSIZE& N,ScMatrixRef& pMatX,ScMatrixRef& pMatY) +{ + nCX = 0; + nCY = 0; + nRX = 0; + nRY = 0; + M = 0; + N = 0; pMatY->GetDimensions(nCY, nRY); - SCSIZE nCountY = nCY * nRY; + const SCSIZE nCountY = nCY * nRY; for ( SCSIZE i = 0; i < nCountY; i++ ) + { if (!pMatY->IsValue(i)) { PushIllegalArgument(); - return; - } + return false; + } // if (!pMatY->IsValue(i)) + } // for ( SCSIZE i = 0; i < nCountY; i++ ) + if ( _bLOG ) + { + for (SCSIZE nElem = 0; nElem < nCountY; nElem++) + { + const double fVal = pMatY->GetDouble(nElem); + if (fVal <= 0.0) + { + PushIllegalArgument(); + return false; + } + else + pMatY->PutDouble(log(fVal), nElem); + } // for (nElem = 0; nElem < nCountY; nElem++) + } // if ( _bRKP ) + + if (pMatX) { pMatX->GetDimensions(nCX, nRX); - SCSIZE nCountX = nCX * nRX; + const SCSIZE nCountX = nCX * nRX; for ( SCSIZE i = 0; i < nCountX; i++ ) if (!pMatX->IsValue(i)) { PushIllegalArgument(); - return; + return false; } if (nCX == nCY && nRX == nRY) nCase = 1; // einfache Regression else if (nCY != 1 && nRY != 1) { PushIllegalArgument(); - return; + return false; } else if (nCY == 1) { if (nRX != nRY) { PushIllegalArgument(); - return; + return false; } else { @@ -2195,7 +2124,7 @@ void ScInterpreter::ScRGP() else if (nCX != nCY) { PushIllegalArgument(); - return; + return false; } else { @@ -2207,343 +2136,25 @@ void ScInterpreter::ScRGP() else { pMatX = GetNewMat(nCY, nRY); + if ( _bTrendGrowth ) + { + nCX = nCY; + nRX = nRY; + } if (!pMatX) { PushIllegalArgument(); - return; + return false; } for ( SCSIZE i = 1; i <= nCountY; i++ ) pMatX->PutDouble((double)i, i-1); nCase = 1; } - ScMatrixRef pResMat; - if (nCase == 1) - { - if (!bStats) - pResMat = GetNewMat(2,1); - else - pResMat = GetNewMat(2,5); - if (!pResMat) - { - PushIllegalArgument(); - return; - } - double fCount = 0.0; - double fSumX = 0.0; - double fSumSqrX = 0.0; - double fSumY = 0.0; - double fSumSqrY = 0.0; - double fSumXY = 0.0; - double fValX, fValY; - for (SCSIZE i = 0; i < nCY; i++) - for (SCSIZE j = 0; j < nRY; j++) - { - fValX = pMatX->GetDouble(i,j); - fValY = pMatY->GetDouble(i,j); - fSumX += fValX; - fSumSqrX += fValX * fValX; - fSumY += fValY; - fSumSqrY += fValY * fValY; - fSumXY += fValX*fValY; - fCount++; - } - if (fCount < 1.0) - PushNoValue(); - else - { - double f1 = fCount*fSumXY-fSumX*fSumY; - double fX = fCount*fSumSqrX-fSumX*fSumX; - double b, m; - if (bConstant) - { - b = fSumY/fCount - f1/fX*fSumX/fCount; - m = f1/fX; - } - else - { - b = 0.0; - m = fSumXY/fSumSqrX; - } - pResMat->PutDouble(m, 0, 0); - pResMat->PutDouble(b, 1, 0); - if (bStats) - { - double fY = fCount*fSumSqrY-fSumY*fSumY; - double fSyx = fSumSqrY-b*fSumY-m*fSumXY; - double fR2 = f1*f1/(fX*fY); - pResMat->PutDouble (fR2, 0, 2); - if (fCount < 3.0) - { - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 0, 1 ); - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 1, 1 ); - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 1, 2 ); - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 0, 3 ); - } - else - { - pResMat->PutDouble(sqrt(fSyx*fCount/(fX*(fCount-2.0))), 0, 1); - pResMat->PutDouble(sqrt(fSyx*fSumSqrX/fX/(fCount-2.0)), 1, 1); - pResMat->PutDouble( - sqrt((fCount*fSumSqrY - fSumY*fSumY - f1*f1/fX)/ - (fCount*(fCount-2.0))), 1, 2); - if (fR2 == 1.0) - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 0, 3 ); - else - pResMat->PutDouble(fR2*(fCount-2.0)/(1.0-fR2), 0, 3); - } - pResMat->PutDouble(((double)(nCY*nRY))-2.0, 1, 3); - pResMat->PutDouble(fY/fCount-fSyx, 0, 4); - pResMat->PutDouble(fSyx, 1, 4); - } - } - } - else - { - SCSIZE i, j, k; - if (!bStats) - pResMat = GetNewMat(M+1,1); - else - pResMat = GetNewMat(M+1,5); - if (!pResMat) - { - PushIllegalArgument(); - return; - } - ScMatrixRef pQ = GetNewMat(M+1, M+2); - ScMatrixRef pE = GetNewMat(M+2, 1); - ScMatrixRef pV = GetNewMat(M+1, 1); - pE->PutDouble(0.0, M+1); - pQ->FillDouble(0.0, 0, 0, M, M+1); - if (nCase == 2) - { - for (k = 0; k < N; k++) - { - double Yk = pMatY->GetDouble(k); - pE->PutDouble( pE->GetDouble(M+1)+Yk*Yk, M+1 ); - double sumYk = pQ->GetDouble(0, M+1) + Yk; - pQ->PutDouble( sumYk, 0, M+1 ); - pE->PutDouble( sumYk, 0 ); - for (i = 0; i < M; i++) - { - double Xik = pMatX->GetDouble(i,k); - double sumXik = pQ->GetDouble(0, i+1) + Xik; - pQ->PutDouble( sumXik, 0, i+1); - pQ->PutDouble( sumXik, i+1, 0); - double sumXikYk = pQ->GetDouble(i+1, M+1) + Xik * Yk; - pQ->PutDouble( sumXikYk, i+1, M+1); - pE->PutDouble( sumXikYk, i+1); - for (j = i; j < M; j++) - { - double fVal = pMatX->GetDouble(j,k); - double sumXikXjk = pQ->GetDouble(j+1, i+1) + - Xik * fVal; - pQ->PutDouble( sumXikXjk, j+1, i+1); - pQ->PutDouble( sumXikXjk, i+1, j+1); - } - } - } - } - else - { - for (k = 0; k < N; k++) - { - double Yk = pMatY->GetDouble(k); - pE->PutDouble( pE->GetDouble(M+1)+Yk*Yk, M+1 ); - double sumYk = pQ->GetDouble(0, M+1) + Yk; - pQ->PutDouble( sumYk, 0, M+1 ); - pE->PutDouble( sumYk, 0 ); - for (i = 0; i < M; i++) - { - double Xki = pMatX->GetDouble(k,i); - double sumXki = pQ->GetDouble(0, i+1) + Xki; - pQ->PutDouble( sumXki, 0, i+1); - pQ->PutDouble( sumXki, i+1, 0); - double sumXkiYk = pQ->GetDouble(i+1, M+1) + Xki * Yk; - pQ->PutDouble( sumXkiYk, i+1, M+1); - pE->PutDouble( sumXkiYk, i+1); - for (j = i; j < M; j++) - { - double fVal = pMatX->GetDouble(k,j); - double sumXkiXkj = pQ->GetDouble(j+1, i+1) + - Xki * fVal; - pQ->PutDouble( sumXkiXkj, j+1, i+1); - pQ->PutDouble( sumXkiXkj, i+1, j+1); - } - } - } - } - pQ->PutDouble((double)N, 0, 0); - if (bConstant) - { - SCSIZE S, L; - for (S = 0; S < M+1; S++) - { - i = S; - while (i < M+1 && pQ->GetDouble(i, S) == 0.0) - i++; - if (i >= M+1) - { - PushNoValue(); - return; - } - double fVal; - for (L = 0; L < M+2; L++) - { - fVal = pQ->GetDouble(S, L); - pQ->PutDouble(pQ->GetDouble(i, L), S, L); - pQ->PutDouble(fVal, i, L); - } - fVal = 1.0/pQ->GetDouble(S, S); - for (L = 0; L < M+2; L++) - pQ->PutDouble(pQ->GetDouble(S, L)*fVal, S, L); - for (i = 0; i < M+1; i++) - { - if (i != S) - { - fVal = -pQ->GetDouble(i, S); - for (L = 0; L < M+2; L++) - pQ->PutDouble( - pQ->GetDouble(i,L)+fVal*pQ->GetDouble(S,L),i,L); - } - } - } - } - else - { - SCSIZE S, L; - for (S = 1; S < M+1; S++) - { - i = S; - while (i < M+1 && pQ->GetDouble(i, S) == 0.0) - i++; - if (i >= M+1) - { - PushNoValue(); - return; - } - double fVal; - for (L = 1; L < M+2; L++) - { - fVal = pQ->GetDouble(S, L); - pQ->PutDouble(pQ->GetDouble(i, L), S, L); - pQ->PutDouble(fVal, i, L); - } - fVal = 1.0/pQ->GetDouble(S, S); - for (L = 1; L < M+2; L++) - pQ->PutDouble(pQ->GetDouble(S, L)*fVal, S, L); - for (i = 1; i < M+1; i++) - { - if (i != S) - { - fVal = -pQ->GetDouble(i, S); - for (L = 1; L < M+2; L++) - pQ->PutDouble( - pQ->GetDouble(i,L)+fVal*pQ->GetDouble(S,L),i,L); - } - } - pQ->PutDouble(0.0, 0, M+1); // Konstante b - } - } - // mn ... m1, b - for (i = 0; i < M+1; i++) - pResMat->PutDouble(pQ->GetDouble(M-i,M+1), i, 0); - if (bStats) - { - // pE[0] := Sigma i=1...n (Yi) - // pE[k] := Sigma i=1...n (Xki*Yi) - // pE[M+1] := Sigma i=1...n (Yi**2) - // pQ[0,M+1]:= B - // pQ[k,M+1]:= Mk - double fSQR, fSQT, fSQE; - fSQT = pE->GetDouble(M+1) - - pE->GetDouble(0) * pE->GetDouble(0) / (double)N; - fSQR = pE->GetDouble(M+1); - for (i = 0; i < M+1; i++) - fSQR -= pQ->GetDouble(i, M+1) * pE->GetDouble(i); - fSQE = fSQT-fSQR; - // r2 (Bestimmtheitsmass, 0...1) - if (fSQT == 0.0) - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 0, 2); - else - pResMat->PutDouble (fSQE/fSQT, 0, 2); - // ssReg (Regressions-Quadratsumme) - pResMat->PutDouble(fSQE, 0, 4); - // ssResid (Residual-Quadratsumme, Summe der Abweichungsquadrate) - pResMat->PutDouble(fSQR, 1, 4); - for (i = 2; i < 5; i++) - for (j = 2; j < M+1; j++) - pResMat->PutString(ScGlobal::GetRscString(STR_NV_STR), j, i); - if (bConstant) - { - if (N-M-1 == 0) - { - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 1, 2); - for (i = 0; i < M+1; i++) - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i, 1); - } - else - { - double fSE2 = fSQR/(N-M-1); - // sey (Standardfehler des Schaetzwertes y) - pResMat->PutDouble(sqrt(fSE2), 1, 2); - // sen...se1 (Standardfehler der Koeffizienten mn...m1) - // seb (Standardfehler der Konstanten b) - if ( RGetVariances( pV, pMatX, M+1, N, nCase != 2, FALSE ) ) - { - for (i = 0; i < M+1; i++) - pResMat->PutDouble( sqrt(fSE2 * pV->GetDouble(i)), M-i, 1 ); - } - else - { - for (i = 0; i < M+1; i++) - pResMat->PutString(ScGlobal::GetRscString(STR_NV_STR), i, 1); - } - } - // F (F-Statistik) - if (fSQR == 0.0) - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 0, 3); - else - pResMat->PutDouble(((double)(N-M-1))*fSQE/fSQR/((double)M),0, 3); - // df (Freiheitsgrad) - pResMat->PutDouble(((double)(N-M-1)), 1, 3); - } - else - { - if (N-M == 0) - { - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 1, 2); - for (i = 0; i < M+1; i++) - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i, 1); - } - else - { - double fSE2 = fSQR/(N-M); - pResMat->PutDouble(sqrt(fSE2), 1, 2); - if ( RGetVariances( pV, pMatX, M, N, nCase != 2, TRUE ) ) - { - for (i = 0; i < M; i++) - pResMat->PutDouble( sqrt(fSE2 * pV->GetDouble(i)), M-i-1, 1 ); - pResMat->PutString(ScGlobal::GetRscString(STR_NV_STR), M, 1); - } - else - { - for (i = 0; i < M+1; i++) - pResMat->PutString(ScGlobal::GetRscString(STR_NV_STR), i, 1); - } - } - if (fSQR == 0.0) - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 0, 3); - else - pResMat->PutDouble(((double)(N-M))*fSQE/fSQR/((double)M),0, 3); - pResMat->PutDouble(((double)(N-M)), 1, 3); - } - } - } - PushMatrix(pResMat); + return true; } - -void ScInterpreter::ScRKP() +void ScInterpreter::CalulateRGPRKP(BOOL _bRKP) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CheckMatrix" ); BYTE nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 1, 4 ) ) return; @@ -2567,86 +2178,14 @@ void ScInterpreter::ScRKP() { PushIllegalParameter(); return; - } + } // if (!pMatY) BYTE nCase; // 1 = normal, 2,3 = mehrfach SCSIZE nCX, nCY; SCSIZE nRX, nRY; SCSIZE M = 0, N = 0; - pMatY->GetDimensions(nCY, nRY); - SCSIZE nCountY = nCY * nRY; - SCSIZE nElem; - for (nElem = 0; nElem < nCountY; nElem++) - if (!pMatY->IsValue(nElem)) - { - PushIllegalArgument(); - return; - } - for (nElem = 0; nElem < nCountY; nElem++) - { - double fVal = pMatY->GetDouble(nElem); - if (fVal <= 0.0) - { - PushIllegalArgument(); - return; - } - else - pMatY->PutDouble(log(pMatY->GetDouble(nElem)), nElem); - } - if (pMatX) - { - pMatX->GetDimensions(nCX, nRX); - SCSIZE nCountX = nCX * nRX; - for (nElem = 0; nElem < nCountX; nElem++) - if (!pMatX->IsValue(nElem)) - { - PushIllegalArgument(); - return; - } - if (nCX == nCY && nRX == nRY) - nCase = 1; // einfache Regression - else if (nCY != 1 && nRY != 1) - { - PushIllegalArgument(); - return; - } - else if (nCY == 1) - { - if (nRX != nRY) - { - PushIllegalArgument(); - return; - } - else - { - nCase = 2; // zeilenweise - N = nRY; - M = nCX; - } - } - else if (nCX != nCY) - { - PushIllegalArgument(); - return; - } - else - { - nCase = 3; // spaltenweise - N = nCY; - M = nRX; - } - } - else - { - pMatX = GetNewMat(nCY, nRY); - if (!pMatX) - { - PushIllegalArgument(); - return; - } - for ( SCSIZE i = 1; i <= nCountY; i++ ) - pMatX->PutDouble((double)i, i-1); - nCase = 1; - } + if ( !CheckMatrix(_bRKP,FALSE,nCase,nCX,nCY,nRX,nRY,M,N,pMatX,pMatY) ) + return; + ScMatrixRef pResMat; if (nCase == 1) { @@ -2695,8 +2234,8 @@ void ScInterpreter::ScRKP() b = 0.0; m = fSumXY/fSumSqrX; } - pResMat->PutDouble(exp(m), 0, 0); - pResMat->PutDouble(exp(b), 1, 0); + pResMat->PutDouble(_bRKP ? exp(m) : m, 0, 0); + pResMat->PutDouble(_bRKP ? exp(b) : b, 1, 0); if (bStats) { double fY = fCount*fSumSqrY-fSumY*fSumY; @@ -2727,8 +2266,8 @@ void ScInterpreter::ScRKP() pResMat->PutDouble(fSyx, 1, 4); } } - } - else + } // if (nCase == 1) + if ( nCase != 1 ) { SCSIZE i, j, k; if (!bStats) @@ -2765,8 +2304,9 @@ void ScInterpreter::ScRKP() pE->PutDouble( sumXikYk, i+1); for (j = i; j < M; j++) { + const double fVal = pMatX->GetDouble(j,k); double sumXikXjk = pQ->GetDouble(j+1, i+1) + - Xik * pMatX->GetDouble(j,k); + Xik * fVal; pQ->PutDouble( sumXikXjk, j+1, i+1); pQ->PutDouble( sumXikXjk, i+1, j+1); } @@ -2793,512 +2333,229 @@ void ScInterpreter::ScRKP() pE->PutDouble( sumXkiYk, i+1); for (j = i; j < M; j++) { + const double fVal = pMatX->GetDouble(k,j); double sumXkiXkj = pQ->GetDouble(j+1, i+1) + - Xki * pMatX->GetDouble(k,j); + Xki * fVal; pQ->PutDouble( sumXkiXkj, j+1, i+1); pQ->PutDouble( sumXkiXkj, i+1, j+1); } } } } - pQ->PutDouble((double)N, 0, 0); - if (bConstant) - { - SCSIZE S, L; - for (S = 0; S < M+1; S++) - { - i = S; - while (i < M+1 && pQ->GetDouble(i, S) == 0.0) - i++; - if (i >= M+1) - { - PushNoValue(); - return; - } - double fVal; - for (L = 0; L < M+2; L++) - { - fVal = pQ->GetDouble(S, L); - pQ->PutDouble(pQ->GetDouble(i, L), S, L); - pQ->PutDouble(fVal, i, L); - } - fVal = 1.0/pQ->GetDouble(S, S); - for (L = 0; L < M+2; L++) - pQ->PutDouble(pQ->GetDouble(S, L)*fVal, S, L); - for (i = 0; i < M+1; i++) - { - if (i != S) - { - fVal = -pQ->GetDouble(i, S); - for (L = 0; L < M+2; L++) - pQ->PutDouble( - pQ->GetDouble(i,L)+fVal*pQ->GetDouble(S,L),i,L); - } - } - } - } - else - { - SCSIZE S, L; - for (S = 1; S < M+1; S++) - { - i = S; - while (i < M+1 && pQ->GetDouble(i, S) == 0.0) - i++; - if (i >= M+1) - { - PushNoValue(); - return; - } - double fVal; - for (L = 1; L < M+2; L++) - { - fVal = pQ->GetDouble(S, L); - pQ->PutDouble(pQ->GetDouble(i, L), S, L); - pQ->PutDouble(fVal, i, L); - } - fVal = 1.0/pQ->GetDouble(S, S); - for (L = 1; L < M+2; L++) - pQ->PutDouble(pQ->GetDouble(S, L)*fVal, S, L); - for (i = 1; i < M+1; i++) - { - if (i != S) - { - fVal = -pQ->GetDouble(i, S); - for (L = 1; L < M+2; L++) - pQ->PutDouble( - pQ->GetDouble(i,L)+fVal*pQ->GetDouble(S,L),i,L); - } - } - pQ->PutDouble(0.0, 0, M+1); - } - } - for (i = 0; i < M+1; i++) - pResMat->PutDouble(exp(pQ->GetDouble(M-i,M+1)), i, 0); + if ( !Calculate4(_bRKP,pResMat,pQ,bConstant,N,M) ) + return; + if (bStats) - { - double fSQR, fSQT, fSQE; - fSQT = pE->GetDouble(M+1)-pE->GetDouble(0)*pE->GetDouble(0)/((double)N); - fSQR = pE->GetDouble(M+1); - for (i = 0; i < M+1; i++) - fSQR += -pQ->GetDouble(i, M+1)*pE->GetDouble(i); - fSQE = fSQT-fSQR; - if (fSQT == 0.0) - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 0, 2); - else - pResMat->PutDouble (fSQE/fSQT, 0, 2); - pResMat->PutDouble(fSQE, 0, 4); - pResMat->PutDouble(fSQR, 1, 4); - for (i = 2; i < 5; i++) - for (j = 2; j < M+1; j++) - pResMat->PutString(ScGlobal::GetRscString(STR_NV_STR), j, i); - if (bConstant) - { - if (N-M-1 == 0) - { - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 1, 2); - for (i = 0; i < M+1; i++) - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i, 1); - } - else - { - double fSE2 = fSQR/(N-M-1); - pResMat->PutDouble(sqrt(fSE2), 1, 2); - if ( RGetVariances( pV, pMatX, M+1, N, nCase != 2, FALSE ) ) - { - for (i = 0; i < M+1; i++) - pResMat->PutDouble( sqrt(fSE2 * pV->GetDouble(i)), M-i, 1 ); - } - else - { - for (i = 0; i < M+1; i++) - pResMat->PutString(ScGlobal::GetRscString(STR_NV_STR), i, 1); - } - } - if (fSQR == 0.0) - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 0, 3); - else - pResMat->PutDouble(((double)(N-M-1))*fSQE/fSQR/((double)M),0, 3); - pResMat->PutDouble(((double)(N-M-1)), 1, 3); - } - else - { - if (N-M == 0) - { - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 1, 2); - for (i = 0; i < M+1; i++) - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i, 1); - } - else - { - double fSE2 = fSQR/(N-M); - pResMat->PutDouble(sqrt(fSE2), 1, 2); - if ( RGetVariances( pV, pMatX, M, N, nCase != 2, TRUE ) ) - { - for (i = 0; i < M; i++) - pResMat->PutDouble( sqrt(fSE2 * pV->GetDouble(i)), M-i-1, 1 ); - pResMat->PutString(ScGlobal::GetRscString(STR_NV_STR), M, 1); - } - else - { - for (i = 0; i < M+1; i++) - pResMat->PutString(ScGlobal::GetRscString(STR_NV_STR), i, 1); - } - } - if (fSQR == 0.0) - pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), 0, 3); - else - pResMat->PutDouble(((double)(N-M))*fSQE/fSQR/((double)M),0, 3); - pResMat->PutDouble(((double)(N-M)), 1, 3); - } - } + Calculate(pResMat,pE,pQ,pV,pMatX,bConstant,N,M,nCase); } PushMatrix(pResMat); } - -void ScInterpreter::ScTrend() +void ScInterpreter::ScRKP() { - BYTE nParamCount = GetByte(); - if ( !MustHaveParamCount( nParamCount, 1, 4 ) ) - return; - BOOL bConstant; - if (nParamCount == 4) - bConstant = GetBool(); - else - bConstant = TRUE; - ScMatrixRef pMatX; - ScMatrixRef pMatY; - ScMatrixRef pMatNewX; - if (nParamCount >= 3) - pMatNewX = GetMatrix(); - else - pMatNewX = NULL; - if (nParamCount >= 2) - pMatX = GetMatrix(); - else - pMatX = NULL; - pMatY = GetMatrix(); - if (!pMatY) + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScRKP" ); + CalulateRGPRKP(TRUE); +} +// ----------------------------------------------------------------------------- +bool ScInterpreter::Calculate4(BOOL _bExp,ScMatrixRef& pResMat,ScMatrixRef& pQ,BOOL bConstant,SCSIZE N,SCSIZE M) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::Calculate4" ); + pQ->PutDouble((double)N, 0, 0); + if (bConstant) { - PushIllegalParameter(); - return; - } - BYTE nCase; // 1 = normal, 2,3 = mehrfach - SCSIZE nCX, nCY; - SCSIZE nRX, nRY; - SCSIZE M = 0, N = 0; - pMatY->GetDimensions(nCY, nRY); - SCSIZE nCountY = nCY * nRY; - SCSIZE nElem; - for (nElem = 0; nElem < nCountY; nElem++) - if (!pMatY->IsValue(nElem)) + SCSIZE S, L; + for (S = 0; S < M+1; S++) { - PushIllegalArgument(); - return; - } - if (pMatX) - { - pMatX->GetDimensions(nCX, nRX); - SCSIZE nCountX = nCX * nRX; - for (nElem = 0; nElem < nCountX; nElem++) - if (!pMatX->IsValue(nElem)) + SCSIZE i = S; + while (i < M+1 && pQ->GetDouble(i, S) == 0.0) + i++; + if (i >= M+1) { - PushIllegalArgument(); - return; + PushNoValue(); + return false; } - if (nCX == nCY && nRX == nRY) - nCase = 1; // einfache Regression - else if (nCY != 1 && nRY != 1) - { - PushIllegalArgument(); - return; - } - else if (nCY == 1) - { - if (nRX != nRY) + double fVal; + for (L = 0; L < M+2; L++) { - PushIllegalArgument(); - return; + fVal = pQ->GetDouble(S, L); + pQ->PutDouble(pQ->GetDouble(i, L), S, L); + pQ->PutDouble(fVal, i, L); } - else + fVal = 1.0/pQ->GetDouble(S, S); + for (L = 0; L < M+2; L++) + pQ->PutDouble(pQ->GetDouble(S, L)*fVal, S, L); + for (i = 0; i < M+1; i++) { - nCase = 2; // zeilenweise - N = nRY; - M = nCX; + if (i != S) + { + fVal = -pQ->GetDouble(i, S); + for (L = 0; L < M+2; L++) + pQ->PutDouble( + pQ->GetDouble(i,L)+fVal*pQ->GetDouble(S,L),i,L); + } } } - else if (nCX != nCY) - { - PushIllegalArgument(); - return; - } - else - { - nCase = 3; // spaltenweise - N = nCY; - M = nRX; - } } else { - pMatX = GetNewMat(nCY, nRY); - nCX = nCY; - nRX = nRY; - if (!pMatX) - { - PushIllegalArgument(); - return; - } - for (nElem = 1; nElem <= nCountY; nElem++) - pMatX->PutDouble((double)nElem, nElem-1); - nCase = 1; - } - SCSIZE nCXN, nRXN; - SCSIZE nCountXN; - if (!pMatNewX) - { - nCXN = nCX; - nRXN = nRX; - nCountXN = nCXN * nRXN; - pMatNewX = pMatX; + if ( !Calculate3(M,pQ) ) + return false; + } - else + for (SCSIZE i = 0; i < M+1; i++) { - pMatNewX->GetDimensions(nCXN, nRXN); - if ((nCase == 2 && nCX != nCXN) || (nCase == 3 && nRX != nRXN)) - { - PushIllegalArgument(); - return; - } - nCountXN = nCXN * nRXN; - for ( SCSIZE i = 0; i < nCountXN; i++ ) - if (!pMatNewX->IsValue(i)) - { - PushIllegalArgument(); - return; - } - } - ScMatrixRef pResMat; - if (nCase == 1) + const double d = pQ->GetDouble(M-i,M+1); + pResMat->PutDouble(_bExp ? exp(d) : d, i, 0); + } // for (SCSIZE i = 0; i < M+1; i++) + return true; +} + +ScMatrixRef ScInterpreter::Calculate2(const BOOL bConstant,const SCSIZE M ,const SCSIZE N,ScMatrixRef& pMatX,ScMatrixRef& pMatY,BYTE nCase) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::Calculate2" ); + SCSIZE i, j, k; + ScMatrixRef pQ = GetNewMat(M+1, M+2); + ScMatrixRef pE = GetNewMat(M+2, 1); + pE->PutDouble(0.0, M+1); + pQ->FillDouble(0.0, 0, 0, M, M+1); + if (nCase == 2) { - double fCount = 0.0; - double fSumX = 0.0; - double fSumSqrX = 0.0; - double fSumY = 0.0; - double fSumSqrY = 0.0; - double fSumXY = 0.0; - double fValX, fValY; - SCSIZE i; - for (i = 0; i < nCY; i++) - for (SCSIZE j = 0; j < nRY; j++) - { - fValX = pMatX->GetDouble(i,j); - fValY = pMatY->GetDouble(i,j); - fSumX += fValX; - fSumSqrX += fValX * fValX; - fSumY += fValY; - fSumSqrY += fValY * fValY; - fSumXY += fValX*fValY; - fCount++; - } - if (fCount < 1.0) + for (k = 0; k < N; k++) { - PushNoValue(); - return; - } - else - { - double f1 = fCount*fSumXY-fSumX*fSumY; - double fX = fCount*fSumSqrX-fSumX*fSumX; - double b, m; - if (bConstant) - { - b = fSumY/fCount - f1/fX*fSumX/fCount; - m = f1/fX; - } - else - { - b = 0.0; - m = fSumXY/fSumSqrX; - } - pResMat = GetNewMat(nCXN, nRXN); - if (!pResMat) + pE->PutDouble( + pE->GetDouble(M+1)+pMatY->GetDouble(k)*pMatY->GetDouble(k), M+1); + pQ->PutDouble(pQ->GetDouble(0, M+1) + pMatY->GetDouble(k), 0, M+1); + pE->PutDouble(pQ->GetDouble(0, M+1), 0); + for (i = 0; i < M; i++) { - PushIllegalArgument(); - return; + pQ->PutDouble(pQ->GetDouble(0, i+1)+pMatX->GetDouble(i,k), 0, i+1); + pQ->PutDouble(pQ->GetDouble(0, i+1), i+1, 0); + pQ->PutDouble(pQ->GetDouble(i+1, M+1) + + pMatX->GetDouble(i,k)*pMatY->GetDouble(k), i+1, M+1); + pE->PutDouble(pQ->GetDouble(i+1, M+1), i+1); + for (j = i; j < M; j++) + { + pQ->PutDouble(pQ->GetDouble(j+1, i+1) + + pMatX->GetDouble(i,k)*pMatX->GetDouble(j,k), j+1, i+1); + pQ->PutDouble(pQ->GetDouble(j+1, i+1), i+1, j+1); + } } - for (i = 0; i < nCountXN; i++) - pResMat->PutDouble(pMatNewX->GetDouble(i)*m+b, i); } } else { - SCSIZE i, j, k; - ScMatrixRef pQ = GetNewMat(M+1, M+2); - ScMatrixRef pE = GetNewMat(M+2, 1); - pE->PutDouble(0.0, M+1); - pQ->FillDouble(0.0, 0, 0, M, M+1); - if (nCase == 2) + for (k = 0; k < N; k++) { - for (k = 0; k < N; k++) + pE->PutDouble( + pE->GetDouble(M+1)+pMatY->GetDouble(k)*pMatY->GetDouble(k), M+1); + pQ->PutDouble(pQ->GetDouble(0, M+1) + pMatY->GetDouble(k), 0, M+1); + pE->PutDouble(pQ->GetDouble(0, M+1), 0); + for (i = 0; i < M; i++) { - pE->PutDouble( - pE->GetDouble(M+1)+pMatY->GetDouble(k)*pMatY->GetDouble(k), M+1); - pQ->PutDouble(pQ->GetDouble(0, M+1) + pMatY->GetDouble(k), 0, M+1); - pE->PutDouble(pQ->GetDouble(0, M+1), 0); - for (i = 0; i < M; i++) + pQ->PutDouble(pQ->GetDouble(0, i+1)+pMatX->GetDouble(k,i), 0, i+1); + pQ->PutDouble(pQ->GetDouble(0, i+1), i+1, 0); + pQ->PutDouble(pQ->GetDouble(i+1, M+1) + + pMatX->GetDouble(k,i)*pMatY->GetDouble(k), i+1, M+1); + pE->PutDouble(pQ->GetDouble(i+1, M+1), i+1); + for (j = i; j < M; j++) { - pQ->PutDouble(pQ->GetDouble(0, i+1)+pMatX->GetDouble(i,k), 0, i+1); - pQ->PutDouble(pQ->GetDouble(0, i+1), i+1, 0); - pQ->PutDouble(pQ->GetDouble(i+1, M+1) + - pMatX->GetDouble(i,k)*pMatY->GetDouble(k), i+1, M+1); - pE->PutDouble(pQ->GetDouble(i+1, M+1), i+1); - for (j = i; j < M; j++) - { - pQ->PutDouble(pQ->GetDouble(j+1, i+1) + - pMatX->GetDouble(i,k)*pMatX->GetDouble(j,k), j+1, i+1); - pQ->PutDouble(pQ->GetDouble(j+1, i+1), i+1, j+1); - } + pQ->PutDouble(pQ->GetDouble(j+1, i+1) + + pMatX->GetDouble(k, i)*pMatX->GetDouble(k, j), j+1, i+1); + pQ->PutDouble(pQ->GetDouble(j+1, i+1), i+1, j+1); } } } - else + } + pQ->PutDouble((double)N, 0, 0); + if (bConstant) + { + SCSIZE S, L; + for (S = 0; S < M+1; S++) { - for (k = 0; k < N; k++) + i = S; + while (i < M+1 && pQ->GetDouble(i, S) == 0.0) + i++; + if (i >= M+1) { - pE->PutDouble( - pE->GetDouble(M+1)+pMatY->GetDouble(k)*pMatY->GetDouble(k), M+1); - pQ->PutDouble(pQ->GetDouble(0, M+1) + pMatY->GetDouble(k), 0, M+1); - pE->PutDouble(pQ->GetDouble(0, M+1), 0); - for (i = 0; i < M; i++) - { - pQ->PutDouble(pQ->GetDouble(0, i+1)+pMatX->GetDouble(k,i), 0, i+1); - pQ->PutDouble(pQ->GetDouble(0, i+1), i+1, 0); - pQ->PutDouble(pQ->GetDouble(i+1, M+1) + - pMatX->GetDouble(k,i)*pMatY->GetDouble(k), i+1, M+1); - pE->PutDouble(pQ->GetDouble(i+1, M+1), i+1); - for (j = i; j < M; j++) - { - pQ->PutDouble(pQ->GetDouble(j+1, i+1) + - pMatX->GetDouble(k, i)*pMatX->GetDouble(k, j), j+1, i+1); - pQ->PutDouble(pQ->GetDouble(j+1, i+1), i+1, j+1); - } - } + PushNoValue(); + return ScMatrixRef(); } - } - pQ->PutDouble((double)N, 0, 0); - if (bConstant) - { - SCSIZE S, L; - for (S = 0; S < M+1; S++) + double fVal; + for (L = 0; L < M+2; L++) { - i = S; - while (i < M+1 && pQ->GetDouble(i, S) == 0.0) - i++; - if (i >= M+1) - { - PushNoValue(); - return; - } - double fVal; - for (L = 0; L < M+2; L++) - { - fVal = pQ->GetDouble(S, L); - pQ->PutDouble(pQ->GetDouble(i, L), S, L); - pQ->PutDouble(fVal, i, L); - } - fVal = 1.0/pQ->GetDouble(S, S); - for (L = 0; L < M+2; L++) - pQ->PutDouble(pQ->GetDouble(S, L)*fVal, S, L); - for (i = 0; i < M+1; i++) - { - if (i != S) - { - fVal = -pQ->GetDouble(i, S); - for (L = 0; L < M+2; L++) - pQ->PutDouble( - pQ->GetDouble(i,L)+fVal*pQ->GetDouble(S,L),i,L); - } - } + fVal = pQ->GetDouble(S, L); + pQ->PutDouble(pQ->GetDouble(i, L), S, L); + pQ->PutDouble(fVal, i, L); } - } - else - { - SCSIZE S, L; - for (S = 1; S < M+1; S++) + fVal = 1.0/pQ->GetDouble(S, S); + for (L = 0; L < M+2; L++) + pQ->PutDouble(pQ->GetDouble(S, L)*fVal, S, L); + for (i = 0; i < M+1; i++) { - i = S; - while (i < M+1 && pQ->GetDouble(i, S) == 0.0) - i++; - if (i >= M+1) - { - PushNoValue(); - return; - } - double fVal; - for (L = 1; L < M+2; L++) - { - fVal = pQ->GetDouble(S, L); - pQ->PutDouble(pQ->GetDouble(i, L), S, L); - pQ->PutDouble(fVal, i, L); - } - fVal = 1.0/pQ->GetDouble(S, S); - for (L = 1; L < M+2; L++) - pQ->PutDouble(pQ->GetDouble(S, L)*fVal, S, L); - for (i = 1; i < M+1; i++) + if (i != S) { - if (i != S) - { - fVal = -pQ->GetDouble(i, S); - for (L = 1; L < M+2; L++) - pQ->PutDouble( - pQ->GetDouble(i,L)+fVal*pQ->GetDouble(S,L),i,L); - } + fVal = -pQ->GetDouble(i, S); + for (L = 0; L < M+2; L++) + pQ->PutDouble( + pQ->GetDouble(i,L)+fVal*pQ->GetDouble(S,L),i,L); } - pQ->PutDouble(0.0, 0, M+1); } } - if (nCase == 2) + } + else + { + if ( !Calculate3(M,pQ) ) + return ScMatrixRef(); + } + return pQ; +} +bool ScInterpreter::Calculate3(const SCSIZE M ,ScMatrixRef& pQ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::Calculate3" ); + SCSIZE S, L; + for (S = 1; S < M+1; S++) + { + SCSIZE i = S; + while (i < M+1 && pQ->GetDouble(i, S) == 0.0) + i++; + if (i >= M+1) { - pResMat = GetNewMat(1, nRXN); - if (!pResMat) - { - PushIllegalArgument(); - return; - } - double fVal; - for (i = 0; i < nRXN; i++) - { - fVal = pQ->GetDouble(0, M+1); - for (j = 0; j < M; j++) - fVal += pQ->GetDouble(j+1, M+1)*pMatNewX->GetDouble(j, i); - pResMat->PutDouble(fVal, i); - } + PushNoValue(); + return ScMatrixRef(); } - else + double fVal; + for (L = 1; L < M+2; L++) { - pResMat = GetNewMat(nCXN, 1); - if (!pResMat) - { - PushIllegalArgument(); - return; - } - double fVal; - for (i = 0; i < nCXN; i++) + fVal = pQ->GetDouble(S, L); + pQ->PutDouble(pQ->GetDouble(i, L), S, L); + pQ->PutDouble(fVal, i, L); + } + fVal = 1.0/pQ->GetDouble(S, S); + for (L = 1; L < M+2; L++) + pQ->PutDouble(pQ->GetDouble(S, L)*fVal, S, L); + for (i = 1; i < M+1; i++) + { + if (i != S) { - fVal = pQ->GetDouble(0, M+1); - for (j = 0; j < M; j++) - fVal += pQ->GetDouble(j+1, M+1)*pMatNewX->GetDouble(i, j); - pResMat->PutDouble(fVal, i); + fVal = -pQ->GetDouble(i, S); + for (L = 1; L < M+2; L++) + pQ->PutDouble( + pQ->GetDouble(i,L)+fVal*pQ->GetDouble(S,L),i,L); } } - } - PushMatrix(pResMat); + pQ->PutDouble(0.0, 0, M+1); + } // for (S = 1; S < M+1; S++) + return true; } -void ScInterpreter::ScGrowth() +void ScInterpreter::ScTrend() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScTrend" ); + CalculateTrendGrowth(FALSE); +} +void ScInterpreter::CalculateTrendGrowth(BOOL _bGrowth) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::CalculateTrendGrowth" ); BYTE nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 1, 4 ) ) return; @@ -3323,89 +2580,16 @@ void ScInterpreter::ScGrowth() { PushIllegalParameter(); return; - } + } // if (!pMatY) + BYTE nCase; // 1 = normal, 2,3 = mehrfach SCSIZE nCX, nCY; SCSIZE nRX, nRY; SCSIZE M = 0, N = 0; - pMatY->GetDimensions(nCY, nRY); - SCSIZE nCountY = nCY * nRY; - SCSIZE nElem; - for (nElem = 0; nElem < nCountY; nElem++) - { - if (!pMatY->IsValue(nElem)) - { - PushIllegalArgument(); - return; - } - } - for (nElem = 0; nElem < nCountY; nElem++) - { - if (pMatY->GetDouble(nElem) <= 0.0) - { - PushIllegalArgument(); - return; - } - else - pMatY->PutDouble(log(pMatY->GetDouble(nElem)), nElem); - } - if (pMatX) - { - pMatX->GetDimensions(nCX, nRX); - SCSIZE nCountX = nCX * nRX; - for ( SCSIZE i = 0; i < nCountX; i++ ) - if (!pMatX->IsValue(i)) - { - PushIllegalArgument(); - return; - } - if (nCX == nCY && nRX == nRY) - nCase = 1; // einfache Regression - else if (nCY != 1 && nRY != 1) - { - PushIllegalArgument(); - return; - } - else if (nCY == 1) - { - if (nRX != nRY) - { - PushIllegalArgument(); - return; - } - else - { - nCase = 2; // zeilenweise - N = nRY; - M = nCX; - } - } - else if (nCX != nCY) - { - PushIllegalArgument(); - return; - } - else - { - nCase = 3; // spaltenweise - N = nCY; - M = nRX; - } - } - else - { - pMatX = GetNewMat(nCY, nRY); - nCX = nCY; - nRX = nRY; - if (!pMatX) - { - PushIllegalArgument(); - return; - } - for (SCSIZE i = 1; i <= nCountY; i++) - pMatX->PutDouble((double)i, i-1); - nCase = 1; - } + if ( !CheckMatrix(_bGrowth,TRUE,nCase,nCX,nCY,nRX,nRY,M,N,pMatX,pMatY) ) + return; + + SCSIZE nCXN, nRXN; SCSIZE nCountXN; if (!pMatNewX) @@ -3441,7 +2625,8 @@ void ScInterpreter::ScGrowth() double fSumSqrY = 0.0; double fSumXY = 0.0; double fValX, fValY; - for (SCSIZE i = 0; i < nCY; i++) + SCSIZE i; + for (i = 0; i < nCY; i++) for (SCSIZE j = 0; j < nRY; j++) { fValX = pMatX->GetDouble(i,j); @@ -3479,137 +2664,18 @@ void ScInterpreter::ScGrowth() PushIllegalArgument(); return; } - for (SCSIZE i = 0; i < nCountXN; i++) - pResMat->PutDouble(exp(pMatNewX->GetDouble(i)*m+b), i); + for (i = 0; i < nCountXN; i++) + { + const double d = pMatNewX->GetDouble(i)*m+b; + pResMat->PutDouble(_bGrowth ? exp(d) : d, i); + } } } else { - SCSIZE i, j, k; - ScMatrixRef pQ = GetNewMat(M+1, M+2); - ScMatrixRef pE = GetNewMat(M+2, 1); - pE->PutDouble(0.0, M+1); - pQ->FillDouble(0.0, 0, 0, M, M+1); - if (nCase == 2) - { - for (k = 0; k < N; k++) - { - pE->PutDouble( - pE->GetDouble(M+1)+pMatY->GetDouble(k)*pMatY->GetDouble(k), M+1); - pQ->PutDouble(pQ->GetDouble(0, M+1) + pMatY->GetDouble(k), 0, M+1); - pE->PutDouble(pQ->GetDouble(0, M+1), 0); - for (i = 0; i < M; i++) - { - pQ->PutDouble(pQ->GetDouble(0, i+1)+pMatX->GetDouble(i,k), 0, i+1); - pQ->PutDouble(pQ->GetDouble(0, i+1), i+1, 0); - pQ->PutDouble(pQ->GetDouble(i+1, M+1) + - pMatX->GetDouble(i,k)*pMatY->GetDouble(k), i+1, M+1); - pE->PutDouble(pQ->GetDouble(i+1, M+1), i+1); - for (j = i; j < M; j++) - { - pQ->PutDouble(pQ->GetDouble(j+1, i+1) + - pMatX->GetDouble(i,k)*pMatX->GetDouble(j,k), j+1, i+1); - pQ->PutDouble(pQ->GetDouble(j+1, i+1), i+1, j+1); - } - } - } - } - else - { - for (k = 0; k < N; k++) - { - pE->PutDouble( - pE->GetDouble(M+1)+pMatY->GetDouble(k)*pMatY->GetDouble(k), M+1); - pQ->PutDouble(pQ->GetDouble(0, M+1) + pMatY->GetDouble(k), 0, M+1); - pE->PutDouble(pQ->GetDouble(0, M+1), 0); - for (i = 0; i < M; i++) - { - pQ->PutDouble(pQ->GetDouble(0, i+1)+pMatX->GetDouble(k,i), 0, i+1); - pQ->PutDouble(pQ->GetDouble(0, i+1), i+1, 0); - pQ->PutDouble(pQ->GetDouble(i+1, M+1) + - pMatX->GetDouble(k,i)*pMatY->GetDouble(k), i+1, M+1); - pE->PutDouble(pQ->GetDouble(i+1, M+1), i+1); - for (j = i; j < M; j++) - { - pQ->PutDouble(pQ->GetDouble(j+1, i+1) + - pMatX->GetDouble(k, i)*pMatX->GetDouble(k, j), j+1, i+1); - pQ->PutDouble(pQ->GetDouble(j+1, i+1), i+1, j+1); - } - } - } - } - pQ->PutDouble((double)N, 0, 0); - if (bConstant) - { - SCSIZE S, L; - for (S = 0; S < M+1; S++) - { - i = S; - while (i < M+1 && pQ->GetDouble(i, S) == 0.0) - i++; - if (i >= M+1) - { - PushNoValue(); - return; - } - double fVal; - for (L = 0; L < M+2; L++) - { - fVal = pQ->GetDouble(S, L); - pQ->PutDouble(pQ->GetDouble(i, L), S, L); - pQ->PutDouble(fVal, i, L); - } - fVal = 1.0/pQ->GetDouble(S, S); - for (L = 0; L < M+2; L++) - pQ->PutDouble(pQ->GetDouble(S, L)*fVal, S, L); - for (i = 0; i < M+1; i++) - { - if (i != S) - { - fVal = -pQ->GetDouble(i, S); - for (L = 0; L < M+2; L++) - pQ->PutDouble( - pQ->GetDouble(i,L)+fVal*pQ->GetDouble(S,L),i,L); - } - } - } - } - else - { - SCSIZE S, L; - for (S = 1; S < M+1; S++) - { - i = S; - while (i < M+1 && pQ->GetDouble(i, S) == 0.0) - i++; - if (i >= M+1) - { - PushNoValue(); - return; - } - double fVal; - for (L = 1; L < M+2; L++) - { - fVal = pQ->GetDouble(S, L); - pQ->PutDouble(pQ->GetDouble(i, L), S, L); - pQ->PutDouble(fVal, i, L); - } - fVal = 1.0/pQ->GetDouble(S, S); - for (L = 1; L < M+2; L++) - pQ->PutDouble(pQ->GetDouble(S, L)*fVal, S, L); - for (i = 1; i < M+1; i++) - { - if (i != S) - { - fVal = -pQ->GetDouble(i, S); - for (L = 1; L < M+2; L++) - pQ->PutDouble( - pQ->GetDouble(i,L)+fVal*pQ->GetDouble(S,L),i,L); - } - } - pQ->PutDouble(0.0, 0, M+1); - } - } + ScMatrixRef pQ = Calculate2(bConstant,M ,N,pMatX,pMatY,nCase); + if ( !pQ.Is() ) + return; if (nCase == 2) { pResMat = GetNewMat(1, nRXN); @@ -3619,12 +2685,12 @@ void ScInterpreter::ScGrowth() return; } double fVal; - for (i = 0; i < nRXN; i++) + for (SCSIZE i = 0; i < nRXN; i++) { fVal = pQ->GetDouble(0, M+1); - for (j = 0; j < M; j++) + for (SCSIZE j = 0; j < M; j++) fVal += pQ->GetDouble(j+1, M+1)*pMatNewX->GetDouble(j, i); - pResMat->PutDouble(exp(fVal), i); + pResMat->PutDouble(_bGrowth ? exp(fVal) : fVal, i); } } else @@ -3636,22 +2702,29 @@ void ScInterpreter::ScGrowth() return; } double fVal; - for (i = 0; i < nCXN; i++) + for (SCSIZE i = 0; i < nCXN; i++) { fVal = pQ->GetDouble(0, M+1); - for (j = 0; j < M; j++) + for (SCSIZE j = 0; j < M; j++) fVal += pQ->GetDouble(j+1, M+1)*pMatNewX->GetDouble(i, j); - pResMat->PutDouble(exp(fVal), i); + pResMat->PutDouble(_bGrowth ? exp(fVal) : fVal, i); } } } PushMatrix(pResMat); } +void ScInterpreter::ScGrowth() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScGrowth" ); + CalculateTrendGrowth(TRUE); +} + void ScInterpreter::ScMatRef() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScMatRef" ); // Falls Deltarefs drin sind... - Push( (ScToken&) *pCur ); + Push( (FormulaToken&)*pCur ); ScAddress aAdr; PopSingleRef( aAdr ); ScFormulaCell* pCell = (ScFormulaCell*) GetCell( aAdr ); @@ -3719,6 +2792,7 @@ void ScInterpreter::ScMatRef() void ScInterpreter::ScInfo() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::ScInfo" ); if( MustHaveParamCount( GetByte(), 1 ) ) { String aStr = GetString(); diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx index 15854f3b3b03..118b5f0ece68 100644 --- a/sc/source/core/tool/interpr6.cxx +++ b/sc/source/core/tool/interpr6.cxx @@ -34,6 +34,7 @@ // #include <math.h> #include <tools/debug.hxx> +#include <rtl/logfile.hxx> #include "interpre.hxx" double const fHalfMachEps = 0.5 * ::std::numeric_limits<double>::epsilon(); @@ -47,6 +48,7 @@ double const fHalfMachEps = 0.5 * ::std::numeric_limits<double>::epsilon(); uses continued fraction with odd items */ double ScInterpreter::GetGammaContFraction( double fA, double fX ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetGammaContFraction" ); double const fBigInv = ::std::numeric_limits<double>::epsilon(); double const fBig = 1.0/fBigInv; @@ -103,6 +105,7 @@ double ScInterpreter::GetGammaContFraction( double fA, double fX ) uses power series */ double ScInterpreter::GetGammaSeries( double fA, double fX ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetGammaSeries" ); double fDenomfactor = fA; double fSummand = 1.0/fA; double fSum = fSummand; @@ -126,6 +129,7 @@ double ScInterpreter::GetGammaSeries( double fA, double fX ) /** You must ensure fA>0.0 && fX>0.0) */ double ScInterpreter::GetLowRegIGamma( double fA, double fX ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetLowRegIGamma" ); double fLnFactor = fA * log(fX) - fX - GetLogGamma(fA); double fFactor = exp(fLnFactor); // Do we need more accuracy than exp(ln()) has? if (fX>fA+1.0) // includes fX>1.0; 1-GetUpRegIGamma, continued fraction @@ -137,6 +141,7 @@ double ScInterpreter::GetLowRegIGamma( double fA, double fX ) /** You must ensure fA>0.0 && fX>0.0) */ double ScInterpreter::GetUpRegIGamma( double fA, double fX ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetUpRegIGamma" ); double fLnFactor= fA*log(fX)-fX-GetLogGamma(fA); double fFactor = exp(fLnFactor); //Do I need more accuracy than exp(ln()) has?; @@ -151,6 +156,7 @@ double ScInterpreter::GetUpRegIGamma( double fA, double fX ) You must ensure fAlpha>0.0 and fLambda>0.0 */ double ScInterpreter::GetGammaDistPDF( double fX, double fAlpha, double fLambda ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetGammaDistPDF" ); if (fX <= 0.0) return 0.0; // see ODFF else @@ -188,6 +194,7 @@ double ScInterpreter::GetGammaDistPDF( double fX, double fAlpha, double fLambda You must ensure fAlpha>0.0 and fLambda>0.0 */ double ScInterpreter::GetGammaDist( double fX, double fAlpha, double fLambda ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "Eike.Rathke@sun.com", "ScInterpreter::GetGammaDist" ); if (fX <= 0.0) return 0.0; else diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx index 8e4d3e0b1272..634c6adbb5cf 100644 --- a/sc/source/core/tool/parclass.cxx +++ b/sc/source/core/tool/parclass.cxx @@ -288,7 +288,7 @@ void ScParameterClassification::Exit() ScParameterClassification::Type ScParameterClassification::GetParameterType( - const ScToken* pToken, USHORT nParameter) + const formula::FormulaToken* pToken, USHORT nParameter) { OpCode eOp = pToken->GetOpCode(); switch ( eOp ) @@ -321,7 +321,7 @@ ScParameterClassification::Type ScParameterClassification::GetParameterType( ScParameterClassification::Type -ScParameterClassification::GetExternalParameterType( const ScToken* pToken, +ScParameterClassification::GetExternalParameterType( const formula::FormulaToken* pToken, USHORT nParameter) { Type eRet = Unknown; @@ -451,8 +451,9 @@ void ScParameterClassification::GenerateDocumentation() if ( !getenv( aEnvVarName) ) return; MergeArgumentsFromFunctionResource(); - ScCompiler::OpCodeMapPtr xMap( ScCompiler::GetOpCodeMap( - ::com::sun::star::sheet::FormulaLanguage::ENGLISH)); + ScAddress aAddress; + ScCompiler aComp(NULL,aAddress); + ScCompiler::OpCodeMapPtr xMap( aComp.GetOpCodeMap(::com::sun::star::sheet::FormulaLanguage::ENGLISH)); if (!xMap) return; fflush( stderr); @@ -465,7 +466,7 @@ void ScParameterClassification::GenerateDocumentation() fprintf( stdout, "%s: ", aEnvVarName); ByteString aStr( xMap->getSymbol(eOp), RTL_TEXTENCODING_UTF8); aStr += "("; - ScByteToken aToken( eOp); + formula::FormulaByteToken aToken( eOp); BYTE nParams = GetMinimumParameters( eOp); // preset parameter count according to opcode value, with some // special handling @@ -574,3 +575,4 @@ void ScParameterClassification::GenerateDocumentation() } #endif // OSL_DEBUG_LEVEL + diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx index e18a2aab06e1..5c11249ef6be 100644 --- a/sc/source/core/tool/rangelst.cxx +++ b/sc/source/core/tool/rangelst.cxx @@ -61,19 +61,19 @@ void ScRangeList::RemoveAll() Clear(); } -static void defaultDelimiter( char& cDelimiter, ScAddress::Convention eConv) +static void defaultDelimiter( char& cDelimiter, formula::FormulaGrammar::AddressConvention eConv) { if( cDelimiter == 0) { switch( eConv ) { default : - case ScAddress::CONV_OOO : + case formula::FormulaGrammar::CONV_OOO : cDelimiter = ';'; break; - case ScAddress::CONV_XL_A1 : - case ScAddress::CONV_XL_R1C1 : + case formula::FormulaGrammar::CONV_XL_A1 : + case formula::FormulaGrammar::CONV_XL_R1C1 : cDelimiter = ','; break; } @@ -81,7 +81,7 @@ static void defaultDelimiter( char& cDelimiter, ScAddress::Convention eConv) } USHORT ScRangeList::Parse( const String& rStr, ScDocument* pDoc, USHORT nMask, - ScAddress::Convention eConv, + formula::FormulaGrammar::AddressConvention eConv, char cDelimiter ) { if ( rStr.Len() ) @@ -125,7 +125,7 @@ USHORT ScRangeList::Parse( const String& rStr, ScDocument* pDoc, USHORT nMask, void ScRangeList::Format( String& rStr, USHORT nFlags, ScDocument* pDoc, - ScAddress::Convention eConv, + formula::FormulaGrammar::AddressConvention eConv, char cDelimiter ) const { rStr.Erase(); diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx index 0128f17c2393..66100a01b566 100644 --- a/sc/source/core/tool/rangenam.cxx +++ b/sc/source/core/tool/rangenam.cxx @@ -40,6 +40,8 @@ #include <unotools/collatorwrapper.hxx> #include <unotools/transliterationwrapper.hxx> +#include "token.hxx" +#include "tokenarray.hxx" #include "rangenam.hxx" #include "global.hxx" #include "compiler.hxx" @@ -49,6 +51,7 @@ #include "document.hxx" #include "indexmap.hxx" +using namespace formula; //======================================================================== // ScRangeData @@ -65,7 +68,7 @@ ScRangeData::ScRangeData( ScDocument* pDok, const String& rSymbol, const ScAddress& rAddress, RangeType nType, - const ScGrammar::Grammar eGrammar ) : + const FormulaGrammar::Grammar eGrammar ) : aName ( rName ), aUpperName ( ScGlobal::pCharClass->upper( rName ) ), pCode ( NULL ), @@ -77,12 +80,13 @@ ScRangeData::ScRangeData( ScDocument* pDok, { if (rSymbol.Len() > 0) { - ScCompiler aComp( pDoc, aPos, eGrammar ); + ScCompiler aComp( pDoc, aPos ); + aComp.SetGrammar(eGrammar); pCode = aComp.CompileString( rSymbol ); if( !pCode->GetCodeError() ) { pCode->Reset(); - ScToken* p = pCode->GetNextReference(); + FormulaToken* p = pCode->GetNextReference(); if( p )// genau eine Referenz als erstes { if( p->GetType() == svSingleRef ) @@ -123,7 +127,7 @@ ScRangeData::ScRangeData( ScDocument* pDok, if( !pCode->GetCodeError() ) { pCode->Reset(); - ScToken* p = pCode->GetNextReference(); + FormulaToken* p = pCode->GetNextReference(); if( p )// genau eine Referenz als erstes { if( p->GetType() == svSingleRef ) @@ -159,7 +163,8 @@ ScRangeData::ScRangeData( ScDocument* pDok, aRefData.InitAddress( rTarget ); aRefData.SetFlag3D( TRUE ); pCode->AddSingleReference( aRefData ); - ScCompiler aComp( pDoc, aPos, *pCode, pDoc->GetGrammar() ); + ScCompiler aComp( pDoc, aPos, *pCode ); + aComp.SetGrammar(pDoc->GetGrammar()); aComp.CompileTokenArray(); if ( !pCode->GetCodeError() ) eType |= RT_ABSPOS; @@ -200,7 +205,7 @@ void ScRangeData::GuessPosition() ScToken* t; pCode->Reset(); - while ( ( t = pCode->GetNextReference() ) != NULL ) + while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL ) { ScSingleRefData& rRef1 = t->GetSingleRef(); if ( rRef1.IsColRel() && rRef1.nRelCol < nMinCol ) @@ -229,30 +234,21 @@ void ScRangeData::GuessPosition() // String((SCROW)(-nMinRow))+String("/")+String((SCTAB)(-nMinTab))); } -void ScRangeData::GetSymbol( String& rSymbol, const ScGrammar::Grammar eGrammar ) const +void ScRangeData::GetSymbol( String& rSymbol, const FormulaGrammar::Grammar eGrammar ) const { - ScCompiler aScComp(pDoc, aPos, *pCode, eGrammar); - aScComp.CreateStringFromTokenArray( rSymbol ); -} - -void ScRangeData::UpdateSymbol( String& rSymbol, const ScAddress& rPos, - const ScGrammar::Grammar eGrammar ) -{ - ScTokenArray* pTemp = pCode->Clone(); - ScCompiler aComp( pDoc, rPos, *pTemp, eGrammar ); - aComp.MoveRelWrap(); + ScCompiler aComp(pDoc, aPos, *pCode); + aComp.SetGrammar(eGrammar); aComp.CreateStringFromTokenArray( rSymbol ); - delete pTemp; } void ScRangeData::UpdateSymbol( rtl::OUStringBuffer& rBuffer, const ScAddress& rPos, - const ScGrammar::Grammar eGrammar ) + const FormulaGrammar::Grammar eGrammar ) { - ScTokenArray* pTemp = pCode->Clone(); - ScCompiler aComp( pDoc, rPos, *pTemp, eGrammar ); + ::std::auto_ptr<ScTokenArray> pTemp( pCode->Clone() ); + ScCompiler aComp( pDoc, rPos, *pTemp.get()); + aComp.SetGrammar(eGrammar); aComp.MoveRelWrap(); aComp.CreateStringFromTokenArray( rBuffer ); - delete pTemp; } void ScRangeData::UpdateReference( UpdateRefMode eUpdateRefMode, @@ -265,8 +261,9 @@ void ScRangeData::UpdateReference( UpdateRefMode eUpdateRefMode, if( pCode->GetNextReference() ) { BOOL bSharedFormula = ((eType & RT_SHARED) == RT_SHARED); - ScCompiler aComp( pDoc, aPos, *pCode, pDoc->GetGrammar() ); - BOOL bRelRef = aComp.UpdateNameReference( eUpdateRefMode, r, + ScCompiler aComp( pDoc, aPos, *pCode ); + aComp.SetGrammar(pDoc->GetGrammar()); + const BOOL bRelRef = aComp.UpdateNameReference( eUpdateRefMode, r, nDx, nDy, nDz, bChanged, bSharedFormula); if (bSharedFormula) @@ -289,7 +286,7 @@ void ScRangeData::UpdateTranspose( const ScRange& rSource, const ScAddress& rDes ScToken* t; pCode->Reset(); - for( t = pCode->GetNextReference(); t; t = pCode->GetNextReference() ) + while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL ) { if( t->GetType() != svIndex ) { @@ -317,7 +314,7 @@ void ScRangeData::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY ) ScToken* t; pCode->Reset(); - for( t = pCode->GetNextReference(); t; t = pCode->GetNextReference() ) + while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL ) { if( t->GetType() != svIndex ) { @@ -348,8 +345,8 @@ BOOL ScRangeData::operator== (const ScRangeData& rData) const // fuer Undo USHORT nLen = pCode->GetLen(); if ( nLen != rData.pCode->GetLen() ) return FALSE; - ScToken** ppThis = pCode->GetArray(); - ScToken** ppOther = rData.pCode->GetArray(); + FormulaToken** ppThis = pCode->GetArray(); + FormulaToken** ppOther = rData.pCode->GetArray(); for ( USHORT i=0; i<nLen; i++ ) if ( ppThis[i] != ppOther[i] && !(*ppThis[i] == *ppOther[i]) ) @@ -383,32 +380,30 @@ BOOL ScRangeData::IsRangeAtBlock( const ScRange& rBlock ) const BOOL ScRangeData::IsReference( ScRange& rRange ) const { - if ( eType & ( RT_ABSAREA | RT_REFAREA | RT_ABSPOS ) ) - if ( pCode ) - return pCode->IsReference( rRange ); + if ( (eType & ( RT_ABSAREA | RT_REFAREA | RT_ABSPOS )) && pCode ) + return pCode->IsReference( rRange ); return FALSE; } BOOL ScRangeData::IsReference( ScRange& rRange, const ScAddress& rPos ) const { - if ( eType & ( RT_ABSAREA | RT_REFAREA | RT_ABSPOS ) ) - if ( pCode ) - { - ::std::auto_ptr<ScTokenArray> pTemp( pCode->Clone() ); - ScCompiler aComp( pDoc, rPos, *pTemp, pDoc->GetGrammar() ); - aComp.MoveRelWrap(); - return pTemp->IsReference( rRange ); - } + if ( (eType & ( RT_ABSAREA | RT_REFAREA | RT_ABSPOS ) ) && pCode ) + { + ::std::auto_ptr<ScTokenArray> pTemp( pCode->Clone() ); + ScCompiler aComp( pDoc, rPos, *pTemp); + aComp.SetGrammar(pDoc->GetGrammar()); + aComp.MoveRelWrap(); + return pTemp->IsReference( rRange ); + } return FALSE; } BOOL ScRangeData::IsValidReference( ScRange& rRange ) const { - if ( eType & ( RT_ABSAREA | RT_REFAREA | RT_ABSPOS ) ) - if ( pCode ) - return pCode->IsValidReference( rRange ); + if ( (eType & ( RT_ABSAREA | RT_REFAREA | RT_ABSPOS ) ) && pCode ) + return pCode->IsValidReference( rRange ); return FALSE; } @@ -420,7 +415,8 @@ void ScRangeData::UpdateTabRef(SCTAB nOldTable, USHORT nFlag, SCTAB nNewTable) { ScRangeData* pRangeData = NULL; // must not be dereferenced BOOL bChanged; - ScCompiler aComp( pDoc, aPos, *pCode, pDoc->GetGrammar() ); + ScCompiler aComp( pDoc, aPos, *pCode); + aComp.SetGrammar(pDoc->GetGrammar()); switch (nFlag) { case 1: // einfache InsertTab (doc.cxx) @@ -454,7 +450,7 @@ void ScRangeData::UpdateTabRef(SCTAB nOldTable, USHORT nFlag, SCTAB nNewTable) void ScRangeData::MakeValidName( String& rName ) // static { - ScCompiler::InitSymbolsNative(); + //ScCompiler::InitSymbolsNative(); // ungueltige Zeichen vorne weglassen xub_StrLen nPos = 0; @@ -479,12 +475,12 @@ void ScRangeData::MakeValidName( String& rName ) // static // Name darf keine Referenz beinhalten, wie in IsNameValid ScAddress aAddr; ScRange aRange; - int nConv = ScAddress::CONV_UNSPECIFIED; // use int so that op++ works + int nConv = FormulaGrammar::CONV_UNSPECIFIED; // use int so that op++ works // Ensure that the proposed name is not an address under any convention - while ( ++nConv != ScAddress::CONV_LAST ) + while ( ++nConv != FormulaGrammar::CONV_LAST ) { - ScAddress::Details details( static_cast<ScAddress::Convention>( nConv ) ); + ScAddress::Details details( static_cast<FormulaGrammar::AddressConvention>( nConv ) ); while( aRange.Parse( rName, NULL, details ) || aAddr.Parse( rName, NULL, details ) ) { @@ -546,7 +542,7 @@ void ScRangeData::TransferTabRef( SCTAB nOldTab, SCTAB nNewTab ) aPos.SetTab( nNewTab ); ScToken* t; pCode->Reset(); - while ( ( t = pCode->GetNextReference() ) != NULL ) + while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL ) { ScSingleRefData& rRef1 = t->GetSingleRef(); if ( rRef1.IsTabRel() ) @@ -568,12 +564,12 @@ void ScRangeData::TransferTabRef( SCTAB nOldTab, SCTAB nNewTab ) void ScRangeData::ReplaceRangeNamesInUse( const ScIndexMap& rMap ) { BOOL bCompile = FALSE; - for ( ScToken* p = pCode->First(); p; p = pCode->Next() ) + for ( FormulaToken* p = pCode->First(); p; p = pCode->Next() ) { if ( p->GetOpCode() == ocName ) { - USHORT nOldIndex = p->GetIndex(); - USHORT nNewIndex = rMap.Find( nOldIndex ); + const USHORT nOldIndex = p->GetIndex(); + const USHORT nNewIndex = rMap.Find( nOldIndex ); if ( nOldIndex != nNewIndex ) { p->SetIndex( nNewIndex ); @@ -583,7 +579,8 @@ void ScRangeData::ReplaceRangeNamesInUse( const ScIndexMap& rMap ) } if ( bCompile ) { - ScCompiler aComp( pDoc, aPos, *pCode, pDoc->GetGrammar() ); + ScCompiler aComp( pDoc, aPos, *pCode); + aComp.SetGrammar(pDoc->GetGrammar()); aComp.CompileTokenArray(); } } @@ -603,7 +600,7 @@ void ScRangeData::ValidateTabRefs() SCTAB nMaxTab = nMinTab; ScToken* t; pCode->Reset(); - while ( ( t = pCode->GetNextReference() ) != NULL ) + while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL ) { ScSingleRefData& rRef1 = t->GetSingleRef(); if ( rRef1.IsTabRel() && !rRef1.IsTabDeleted() ) @@ -636,7 +633,7 @@ void ScRangeData::ValidateTabRefs() aPos.SetTab( aPos.Tab() - nMove ); pCode->Reset(); - while ( ( t = pCode->GetNextReference() ) != NULL ) + while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL ) { ScSingleRefData& rRef1 = t->GetSingleRef(); if ( rRef1.IsTabRel() && !rRef1.IsTabDeleted() ) diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx index ea94d0ea9f23..6f1f46b9991b 100644 --- a/sc/source/core/tool/rangeutl.cxx +++ b/sc/source/core/tool/rangeutl.cxx @@ -658,7 +658,7 @@ void ScRangeStringConverter::GetStringFromRange( ScAddress aEndAddress( rRange.aEnd ); String sStartAddress; String sEndAddress; - ScAddress::Convention eConv = pDocument->GetAddressConvention(); + formula::FormulaGrammar::AddressConvention eConv = pDocument->GetAddressConvention(); aStartAddress.Format( sStartAddress, nFormatFlags, (ScDocument*) pDocument, eConv ); aEndAddress.Format( sEndAddress, nFormatFlags, (ScDocument*) pDocument, eConv ); OUString sOUStartAddress( sStartAddress ); diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx index db2d54268e80..c96ce2763cd3 100644 --- a/sc/source/core/tool/refdata.cxx +++ b/sc/source/core/tool/refdata.cxx @@ -199,7 +199,7 @@ BOOL ScSingleRefData::operator==( const ScSingleRefData& r ) const (Flags.bTabRel ? nRelTab == r.nRelTab : nTab == r.nTab); } -bool SingleRefData::operator!=( const SingleRefData& r ) const +bool ScSingleRefData::operator!=( const ScSingleRefData& r ) const { return !operator==(r); } diff --git a/sc/source/core/tool/reffind.cxx b/sc/source/core/tool/reffind.cxx index 3997e7ea5ec2..e98a8a8165cb 100644 --- a/sc/source/core/tool/reffind.cxx +++ b/sc/source/core/tool/reffind.cxx @@ -69,7 +69,7 @@ inline BOOL IsText( BOOL& bQuote, sal_Unicode c ) } ScRefFinder::ScRefFinder(const String& rFormula, ScDocument* pDocument, - ScAddress::Convention eConvP) : + formula::FormulaGrammar::AddressConvention eConvP) : aFormula( rFormula ), eConv( eConvP ), pDoc( pDocument ) diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 891ed6378022..af22bf7e43a3 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -36,7 +36,7 @@ #include "scmatrix.hxx" #include "global.hxx" #include "address.hxx" -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" #include "interpre.hxx" #include <svtools/zforlist.hxx> #include <tools/stream.hxx> diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 776831726fe6..cb2f84f2ec4c 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -49,15 +49,47 @@ #include "token.hxx" #include "tokenarray.hxx" #include "compiler.hxx" -#include "compiler.hrc" +#include <formula/compiler.hrc> #include "rechead.hxx" #include "parclass.hxx" #include "jumpmatrix.hxx" +#include "rangeseq.hxx" using ::std::vector; +#include <com/sun/star/sheet/ComplexReference.hpp> +#include <com/sun/star/sheet/ReferenceFlags.hpp> + +using namespace formula; +using namespace com::sun::star; + +namespace +{ + void lcl_SingleRefToCalc( ScSingleRefData& rRef, const sheet::SingleReference& rAPI ) + { + rRef.InitFlags(); + + rRef.nCol = static_cast<SCsCOL>(rAPI.Column); + rRef.nRow = static_cast<SCsROW>(rAPI.Row); + rRef.nTab = static_cast<SCsTAB>(rAPI.Sheet); + rRef.nRelCol = static_cast<SCsCOL>(rAPI.RelativeColumn); + rRef.nRelRow = static_cast<SCsROW>(rAPI.RelativeRow); + rRef.nRelTab = static_cast<SCsTAB>(rAPI.RelativeSheet); + + rRef.SetColRel( ( rAPI.Flags & sheet::ReferenceFlags::COLUMN_RELATIVE ) != 0 ); + rRef.SetRowRel( ( rAPI.Flags & sheet::ReferenceFlags::ROW_RELATIVE ) != 0 ); + rRef.SetTabRel( ( rAPI.Flags & sheet::ReferenceFlags::SHEET_RELATIVE ) != 0 ); + rRef.SetColDeleted( ( rAPI.Flags & sheet::ReferenceFlags::COLUMN_DELETED ) != 0 ); + rRef.SetRowDeleted( ( rAPI.Flags & sheet::ReferenceFlags::ROW_DELETED ) != 0 ); + rRef.SetTabDeleted( ( rAPI.Flags & sheet::ReferenceFlags::SHEET_DELETED ) != 0 ); + rRef.SetFlag3D( ( rAPI.Flags & sheet::ReferenceFlags::SHEET_3D ) != 0 ); + rRef.SetRelName( ( rAPI.Flags & sheet::ReferenceFlags::RELATIVE_NAME ) != 0 ); + } +// +} // namespace +// // ImpTokenIterator wird je Interpreter angelegt, mehrfache auch durch -// SubCode via ScTokenIterator Push/Pop moeglich +// SubCode via FormulaTokenIterator Push/Pop moeglich IMPL_FIXEDMEMPOOL_NEWDEL( ImpTokenIterator, 32, 16 ) // Align MemPools on 4k boundaries - 64 bytes (4k is a MUST for OS/2) @@ -72,19 +104,9 @@ IMPL_FIXEDMEMPOOL_NEWDEL( ScDoubleRawToken, nMemPoolDoubleRawToken, nMemPoolDoub // Need a whole bunch of ScSingleRefToken const USHORT nMemPoolSingleRefToken = (0x4000 - 64) / sizeof(ScSingleRefToken); IMPL_FIXEDMEMPOOL_NEWDEL( ScSingleRefToken, nMemPoolSingleRefToken, nMemPoolSingleRefToken ) -// Need a lot of ScDoubleToken -const USHORT nMemPoolDoubleToken = (0x3000 - 64) / sizeof(ScDoubleToken); -IMPL_FIXEDMEMPOOL_NEWDEL( ScDoubleToken, nMemPoolDoubleToken, nMemPoolDoubleToken ) -// Need a lot of ScByteToken -const USHORT nMemPoolByteToken = (0x3000 - 64) / sizeof(ScByteToken); -IMPL_FIXEDMEMPOOL_NEWDEL( ScByteToken, nMemPoolByteToken, nMemPoolByteToken ) // Need quite a lot of ScDoubleRefToken const USHORT nMemPoolDoubleRefToken = (0x2000 - 64) / sizeof(ScDoubleRefToken); IMPL_FIXEDMEMPOOL_NEWDEL( ScDoubleRefToken, nMemPoolDoubleRefToken, nMemPoolDoubleRefToken ) -// Need several ScStringToken -const USHORT nMemPoolStringToken = (0x1000 - 64) / sizeof(ScStringToken); -IMPL_FIXEDMEMPOOL_NEWDEL( ScStringToken, nMemPoolStringToken, nMemPoolStringToken ) - // --- helpers -------------------------------------------------------------- @@ -346,40 +368,40 @@ ScRawToken* ScRawToken::Clone() const } -ScToken* ScRawToken::CreateToken() const +FormulaToken* ScRawToken::CreateToken() const { #ifndef PRODUCT -#define IF_NOT_OPCODE_ERROR(o,c) if (eOp!=o) DBG_ERROR1( #c "::ctor: OpCode %d lost, converted to " #o "; maybe inherit from ScOpToken instead!", int(eOp)) +#define IF_NOT_OPCODE_ERROR(o,c) if (eOp!=o) DBG_ERROR1( #c "::ctor: OpCode %d lost, converted to " #o "; maybe inherit from FormulaToken instead!", int(eOp)) #else #define IF_NOT_OPCODE_ERROR(o,c) #endif switch ( GetType() ) { case svByte : - return new ScByteToken( eOp, sbyte.cByte, sbyte.bHasForceArray ); + return new FormulaByteToken( eOp, sbyte.cByte, sbyte.bHasForceArray ); case svDouble : - IF_NOT_OPCODE_ERROR( ocPush, ScDoubleToken); - return new ScDoubleToken( nValue ); + IF_NOT_OPCODE_ERROR( ocPush, FormulaDoubleToken); + return new FormulaDoubleToken( nValue ); case svString : if (eOp == ocPush) - return new ScStringToken( String( cStr ) ); + return new FormulaStringToken( String( cStr ) ); else - return new ScStringOpToken( eOp, String( cStr ) ); + return new FormulaStringOpToken( eOp, String( cStr ) ); case svSingleRef : if (eOp == ocPush) return new ScSingleRefToken( aRef.Ref1 ); else - return new ScSingleRefOpToken( eOp, aRef.Ref1 ); + return new ScSingleRefToken( aRef.Ref1, eOp ); case svDoubleRef : if (eOp == ocPush) return new ScDoubleRefToken( aRef ); else - return new ScDoubleRefOpToken( eOp, aRef ); + return new ScDoubleRefToken( aRef, eOp ); case svMatrix : IF_NOT_OPCODE_ERROR( ocPush, ScMatrixToken); return new ScMatrixToken( pMat ); case svIndex : - return new ScIndexToken( eOp, nIndex ); + return new FormulaIndexToken( eOp, nIndex ); case svExternalSingleRef: { String aTabName(extref.cTabName); @@ -396,22 +418,22 @@ ScToken* ScRawToken::CreateToken() const return new ScExternalNameToken( extname.nFileId, aName ); } case svJump : - return new ScJumpToken( eOp, (short*) nJump ); + return new FormulaJumpToken( eOp, (short*) nJump ); case svExternal : - return new ScExternalToken( eOp, sbyte.cByte, String( cStr+1 ) ); + return new FormulaExternalToken( eOp, sbyte.cByte, String( cStr+1 ) ); case svFAP : - return new ScFAPToken( eOp, sbyte.cByte, NULL ); + return new FormulaFAPToken( eOp, sbyte.cByte, NULL ); case svMissing : - IF_NOT_OPCODE_ERROR( ocMissing, ScMissingToken); - return new ScMissingToken; + IF_NOT_OPCODE_ERROR( ocMissing, FormulaMissingToken); + return new FormulaMissingToken; case svSep : - return new ScOpToken( eOp, svSep ); + return new FormulaToken( svSep,eOp ); case svUnknown : - return new ScUnknownToken( eOp ); + return new FormulaUnknownToken( eOp ); default: { DBG_ERROR1( "unknown ScRawToken::CreateToken() type %d", int(GetType())); - return new ScUnknownToken( ocBad ); + return new FormulaUnknownToken( ocBad ); } } #undef IF_NOT_OPCODE_ERROR @@ -453,168 +475,21 @@ ScComplexRefData lcl_ScToken_InitDoubleRef() return aRef; } -String ScToken::aDummyString; - - ScToken::~ScToken() { } - -OpCode ScToken::GetOpCode() const -{ - return ocPush; -} - - -BOOL ScToken::IsFunction() const -{ - OpCode eOp = GetOpCode(); - return (eOp != ocPush && eOp != ocBad && eOp != ocColRowName && - eOp != ocColRowNameAuto && eOp != ocName && eOp != ocDBArea && - (GetByte() != 0 // x parameters - || (SC_OPCODE_START_NO_PAR <= eOp && eOp < SC_OPCODE_STOP_NO_PAR) // no parameter - || (ocIf == eOp || ocChose == eOp ) // @ jump commands - || (SC_OPCODE_START_1_PAR <= eOp && eOp < SC_OPCODE_STOP_1_PAR) // one parameter - || (SC_OPCODE_START_2_PAR <= eOp && eOp < SC_OPCODE_STOP_2_PAR) // x parameters (cByte==0 in - // FuncAutoPilot) - || eOp == ocMacro || eOp == ocExternal // macros, AddIns - || eOp == ocAnd || eOp == ocOr // former binary, now x parameters - || eOp == ocNot || eOp == ocNeg // unary but function - || (eOp >= ocInternalBegin && eOp <= ocInternalEnd) // internal - )); -} - - -BYTE ScToken::GetParamCount() const -{ - OpCode eOp = GetOpCode(); - if ( eOp < SC_OPCODE_STOP_DIV && eOp != ocExternal && eOp != ocMacro && - eOp != ocIf && eOp != ocChose && eOp != ocPercentSign ) - return 0; // parameters and specials - // ocIf and ocChose not for FAP, have cByte then -//2do: BOOL parameter whether FAP or not? - else if ( GetByte() ) - return GetByte(); // all functions, also ocExternal and ocMacro - else if (SC_OPCODE_START_BIN_OP <= eOp && eOp < SC_OPCODE_STOP_BIN_OP) - return 2; // binary - else if ((SC_OPCODE_START_UN_OP <= eOp && eOp < SC_OPCODE_STOP_UN_OP) - || eOp == ocPercentSign) - return 1; // unary - else if (SC_OPCODE_START_NO_PAR <= eOp && eOp < SC_OPCODE_STOP_NO_PAR) - return 0; // no parameter - else if (SC_OPCODE_START_1_PAR <= eOp && eOp < SC_OPCODE_STOP_1_PAR) - return 1; // one parameter - else if ( eOp == ocIf || eOp == ocChose ) - return 1; // only the condition counts as parameter - else - return 0; // all the rest, no Parameter, or - // if so then it should be in cByte -} - - -BOOL ScToken::IsMatrixFunction() const -{ - OpCode eOp = GetOpCode(); - switch ( eOp ) - { - case ocDde : - case ocGrowth : - case ocTrend : - case ocRKP : - case ocRGP : - case ocFrequency : - case ocMatTrans : - case ocMatMult : - case ocMatInv : - case ocMatrixUnit : - return TRUE; - default: - { - // added to avoid warnings - } - } - return FALSE; -} - - -ScToken* ScToken::Clone() const -{ - OpCode nOp = GetOpCode(); - switch ( GetType() ) - { - case svByte : - return new ScByteToken( *static_cast<const ScByteToken*>(this) ); - case svDouble : - return new ScDoubleToken( *static_cast<const ScDoubleToken*>(this) ); - case svString : - if (nOp == ocPush) - return new ScStringToken( *static_cast<const ScStringToken*>(this) ); - else - return new ScStringOpToken( *static_cast<const ScStringOpToken*>(this) ); - case svSingleRef : - if (nOp == ocPush) - return new ScSingleRefToken( *static_cast<const ScSingleRefToken*>(this) ); - else - return new ScSingleRefOpToken( *static_cast<const ScSingleRefOpToken*>(this) ); - case svDoubleRef : - if (nOp == ocPush) - return new ScDoubleRefToken( *static_cast<const ScDoubleRefToken*>(this) ); - else - return new ScDoubleRefOpToken( *static_cast<const ScDoubleRefOpToken*>(this) ); - case svMatrix : - return new ScMatrixToken( *static_cast<const ScMatrixToken*>(this) ); - case svIndex : - return new ScIndexToken( *static_cast<const ScIndexToken*>(this) ); - case svJump : - return new ScJumpToken( *static_cast<const ScJumpToken*>(this) ); - case svJumpMatrix : - return new ScJumpMatrixToken( *static_cast<const ScJumpMatrixToken*>(this) ); - case svRefList : - return new ScRefListToken( *static_cast<const ScRefListToken*>(this) ); - case svExternal : - return new ScExternalToken( *static_cast<const ScExternalToken*>(this) ); - case svExternalSingleRef : - return new ScExternalSingleRefToken( *static_cast<const ScExternalSingleRefToken*>(this) ); - case svExternalDoubleRef : - return new ScExternalDoubleRefToken( *static_cast<const ScExternalDoubleRefToken*>(this) ); - case svExternalName : - return new ScExternalNameToken( *static_cast<const ScExternalNameToken*>(this) ); - case svFAP : - return new ScFAPToken( *static_cast<const ScFAPToken*>(this) ); - case svMissing : - return new ScMissingToken( *static_cast<const ScMissingToken*>(this) ); - case svError : - return new ScErrorToken( *static_cast<const ScErrorToken*>(this) ); - case svEmptyCell : - return new ScEmptyCellToken( *static_cast<const ScEmptyCellToken*>(this) ); - case svSep : - return new ScOpToken( *static_cast<const ScOpToken*>(this) ); - case svUnknown : - return new ScUnknownToken( *static_cast<const ScUnknownToken*>(this) ); - default: - DBG_ERROR1( "unknown ScToken::Clone() type %d", int(GetType())); - return new ScUnknownToken( ocBad ); - } -} - -BOOL ScToken::operator==( const ScToken& rToken ) const -{ - // don't compare reference count! - return eType == rToken.eType && GetOpCode() == rToken.GetOpCode(); -} - - // TextEqual: if same formula entered (for optimization in sort) -BOOL ScToken::TextEqual( const ScToken& rToken ) const +BOOL ScToken::TextEqual( const FormulaToken& _rToken ) const { if ( eType == svSingleRef || eType == svDoubleRef ) { // in relative Refs only compare relative parts - if ( eType != rToken.eType || GetOpCode() != rToken.GetOpCode() ) + if ( eType != _rToken.GetType() || GetOpCode() != _rToken.GetOpCode() ) return FALSE; + const ScToken& rToken = static_cast<const ScToken&>(_rToken); ScComplexRefData aTemp1; if ( eType == svSingleRef ) { @@ -649,7 +524,7 @@ BOOL ScToken::TextEqual( const ScToken& rToken ) const aTemp1.Ref2.bFlags == aTemp2.Ref2.bFlags; } else - return *this == rToken; // else normal operator== + return *this == _rToken; // else normal operator== } @@ -673,45 +548,22 @@ BOOL ScToken::Is3DRef() const return FALSE; } - -//UNUSED2008-05 BOOL ScToken::IsRPNReferenceAbsName() const -//UNUSED2008-05 { -//UNUSED2008-05 if ( GetRef() == 1 && GetOpCode() == ocPush ) -//UNUSED2008-05 { // only in RPN and not ocColRowNameAuto or similar -//UNUSED2008-05 switch ( GetType() ) -//UNUSED2008-05 { -//UNUSED2008-05 case svDoubleRef : -//UNUSED2008-05 if ( !GetSingleRef2().IsRelName() ) -//UNUSED2008-05 return TRUE; -//UNUSED2008-05 //! fallthru -//UNUSED2008-05 case svSingleRef : -//UNUSED2008-05 if ( !GetSingleRef().IsRelName() ) -//UNUSED2008-05 return TRUE; -//UNUSED2008-05 break; -//UNUSED2008-05 default: -//UNUSED2008-05 { -//UNUSED2008-05 // added to avoid warnings -//UNUSED2008-05 } -//UNUSED2008-05 } -//UNUSED2008-05 } -//UNUSED2008-05 return FALSE; -//UNUSED2008-05 } - - // static -ScTokenRef ScToken::ExtendRangeReference( ScToken & rTok1, ScToken & rTok2, +FormulaTokenRef ScToken::ExtendRangeReference( FormulaToken & rTok1, FormulaToken & rTok2, const ScAddress & rPos, bool bReuseDoubleRef ) { - ScToken *p1, *p2; + StackVar sv1, sv2; // Doing a RangeOp with RefList is probably utter nonsense, but Xcl // supports it, so do we. - if (((p1 = &rTok1) == 0) || ((p2 = &rTok2) == 0) || - ((sv1 = p1->GetType()) != svSingleRef && sv1 != svDoubleRef && sv1 != svRefList && - sv1 != svExternalSingleRef && sv1 != svExternalDoubleRef) || - ((sv2 = p2->GetType()) != svSingleRef && sv2 != svDoubleRef && sv2 != svRefList)) + if (((sv1 = rTok1.GetType()) != svSingleRef && sv1 != svDoubleRef && sv1 != svRefList && + sv1 != svExternalSingleRef && sv1 != svExternalDoubleRef ) || + ((sv2 = rTok2.GetType()) != svSingleRef && sv2 != svDoubleRef && sv2 != svRefList)) return NULL; + ScToken *p1 = static_cast<ScToken*>(&rTok1); + ScToken *p2 = static_cast<ScToken*>(&rTok2); + ScTokenRef xRes; bool bExternal = (sv1 == svExternalSingleRef); if ((sv1 == svSingleRef || bExternal) && sv2 == svSingleRef) @@ -721,7 +573,6 @@ ScTokenRef ScToken::ExtendRangeReference( ScToken & rTok1, ScToken & rTok2, // generating Sheet1.A1:A1, and then extending that with A2 as if // Sheet1.A1:A1:A2 was encountered, so the mechanisms to adjust the // references apply as well. -<<<<<<< .working /* Given the current structure of external references an external * reference can only be extended if the second reference does not @@ -757,12 +608,12 @@ ScTokenRef ScToken::ExtendRangeReference( ScToken & rTok1, ScToken & rTok2, const ScRefList* pRefList = NULL; if (sv1 == svDoubleRef) { - xRes = (bReuseDoubleRef && p1->GetRef() == 1 ? p1 : p1->Clone()); + xRes = (bReuseDoubleRef && p1->GetRef() == 1 ? p1 : static_cast<ScToken*>(p1->Clone())); sv1 = svUnknown; // mark as handled } else if (sv2 == svDoubleRef) { - xRes = (bReuseDoubleRef && p2->GetRef() == 1 ? p2 : p2->Clone()); + xRes = (bReuseDoubleRef && p2->GetRef() == 1 ? p2 : static_cast<ScToken*>(p2->Clone())); sv2 = svUnknown; // mark as handled } else if (sv1 == svRefList) @@ -822,51 +673,7 @@ ScTokenRef ScToken::ExtendRangeReference( ScToken & rTok1, ScToken & rTok2, } } } - return xRes; -} - - -// --- virtual dummy methods ------------------------------------------------- - -BYTE ScToken::GetByte() const -{ - // ok to be called for any derived class - return 0; -} - -void ScToken::SetByte( BYTE ) -{ - DBG_ERRORFILE( "ScToken::SetByte: virtual dummy called" ); -} - -bool ScToken::HasForceArray() const -{ - // ok to be called for any derived class - return false; -} - -void ScToken::SetForceArray( bool ) -{ - DBG_ERRORFILE( "ScToken::SetForceArray: virtual dummy called" ); -} - -double ScToken::GetDouble() const -{ - DBG_ERRORFILE( "ScToken::GetDouble: virtual dummy called" ); - return 0.0; -} - -double & ScToken::GetDoubleAsReference() -{ - DBG_ERRORFILE( "ScToken::GetDouble: virtual dummy called" ); - static double fVal = 0.0; - return fVal; -} - -const String& ScToken::GetString() const -{ - DBG_ERRORFILE( "ScToken::GetString: virtual dummy called" ); - return aDummyString; + return FormulaTokenRef(xRes.get()); } const ScSingleRefData& ScToken::GetSingleRef() const @@ -933,41 +740,12 @@ ScMatrix* ScToken::GetMatrix() return NULL; } -USHORT ScToken::GetIndex() const -{ - DBG_ERRORFILE( "ScToken::GetIndex: virtual dummy called" ); - return 0; -} - -void ScToken::SetIndex( USHORT ) -{ - DBG_ERRORFILE( "ScToken::SetIndex: virtual dummy called" ); -} - -short* ScToken::GetJump() const -{ - DBG_ERRORFILE( "ScToken::GetJump: virtual dummy called" ); - return NULL; -} ScJumpMatrix* ScToken::GetJumpMatrix() const { DBG_ERRORFILE( "ScToken::GetJumpMatrix: virtual dummy called" ); return NULL; } - -const String& ScToken::GetExternal() const -{ - DBG_ERRORFILE( "ScToken::GetExternal: virtual dummy called" ); - return aDummyString; -} - -ScToken* ScToken::GetFAPOrigToken() const -{ - DBG_ERRORFILE( "ScToken::GetFAPOrigToken: virtual dummy called" ); - return NULL; -} - const ScRefList* ScToken::GetRefList() const { DBG_ERRORFILE( "ScToken::GetRefList: virtual dummy called" ); @@ -979,64 +757,11 @@ ScRefList* ScToken::GetRefList() DBG_ERRORFILE( "ScToken::GetRefList: virtual dummy called" ); return NULL; } - -USHORT ScToken::GetError() const -{ - DBG_ERRORFILE( "ScToken::GetError: virtual dummy called" ); - return 0; -} - -void ScToken::SetError( USHORT ) -{ - DBG_ERRORFILE( "ScToken::SetError: virtual dummy called" ); -} - // ========================================================================== // real implementations of virtual functions // -------------------------------------------------------------------------- -OpCode ScOpToken::GetOpCode() const { return eOp; } - - -BYTE ScByteToken::GetByte() const { return nByte; } -void ScByteToken::SetByte( BYTE n ) { nByte = n; } -bool ScByteToken::HasForceArray() const { return bHasForceArray; } -void ScByteToken::SetForceArray( bool b ) { bHasForceArray = b; } -BOOL ScByteToken::operator==( const ScToken& r ) const -{ - return ScToken::operator==( r ) && nByte == r.GetByte() && - bHasForceArray == r.HasForceArray(); -} - - -ScToken* ScFAPToken::GetFAPOrigToken() const { return pOrigToken; } -BOOL ScFAPToken::operator==( const ScToken& r ) const -{ - return ScByteToken::operator==( r ) && pOrigToken == r.GetFAPOrigToken(); -} - - -double ScDoubleToken::GetDouble() const { return fDouble; } -double & ScDoubleToken::GetDoubleAsReference() { return fDouble; } -BOOL ScDoubleToken::operator==( const ScToken& r ) const -{ - return ScToken::operator==( r ) && fDouble == r.GetDouble(); -} - - -const String& ScStringToken::GetString() const { return aString; } -BOOL ScStringToken::operator==( const ScToken& r ) const -{ - return ScToken::operator==( r ) && aString == r.GetString(); -} - - -const String& ScStringOpToken::GetString() const { return aString; } -BOOL ScStringOpToken::operator==( const ScToken& r ) const -{ - return ScByteToken::operator==( r ) && aString == r.GetString(); -} const ScSingleRefData& ScSingleRefToken::GetSingleRef() const { return aSingleRef; } @@ -1045,21 +770,9 @@ void ScSingleRefToken::CalcAbsIfRel( const ScAddress& rPos ) { aSingleRef.CalcAbsIfRel( rPos ); } void ScSingleRefToken::CalcRelFromAbs( const ScAddress& rPos ) { aSingleRef.CalcRelFromAbs( rPos ); } -BOOL ScSingleRefToken::operator==( const ScToken& r ) const +BOOL ScSingleRefToken::operator==( const FormulaToken& r ) const { - return ScToken::operator==( r ) && aSingleRef == r.GetSingleRef(); -} - - -const ScSingleRefData& ScSingleRefOpToken::GetSingleRef() const { return aSingleRef; } -ScSingleRefData& ScSingleRefOpToken::GetSingleRef() { return aSingleRef; } -void ScSingleRefOpToken::CalcAbsIfRel( const ScAddress& rPos ) - { aSingleRef.CalcAbsIfRel( rPos ); } -void ScSingleRefOpToken::CalcRelFromAbs( const ScAddress& rPos ) - { aSingleRef.CalcRelFromAbs( rPos ); } -BOOL ScSingleRefOpToken::operator==( const ScToken& r ) const -{ - return ScToken::operator==( r ) && aSingleRef == r.GetSingleRef(); + return FormulaToken::operator==( r ) && aSingleRef == static_cast<const ScToken&>(r).GetSingleRef(); } @@ -1073,25 +786,9 @@ void ScDoubleRefToken::CalcAbsIfRel( const ScAddress& rPos ) { aDoubleRef.CalcAbsIfRel( rPos ); } void ScDoubleRefToken::CalcRelFromAbs( const ScAddress& rPos ) { aDoubleRef.CalcRelFromAbs( rPos ); } -BOOL ScDoubleRefToken::operator==( const ScToken& r ) const -{ - return ScToken::operator==( r ) && aDoubleRef == r.GetDoubleRef(); -} - - -const ScSingleRefData& ScDoubleRefOpToken::GetSingleRef() const { return aDoubleRef.Ref1; } -ScSingleRefData& ScDoubleRefOpToken::GetSingleRef() { return aDoubleRef.Ref1; } -const ScComplexRefData& ScDoubleRefOpToken::GetDoubleRef() const { return aDoubleRef; } -ScComplexRefData& ScDoubleRefOpToken::GetDoubleRef() { return aDoubleRef; } -const ScSingleRefData& ScDoubleRefOpToken::GetSingleRef2() const { return aDoubleRef.Ref2; } -ScSingleRefData& ScDoubleRefOpToken::GetSingleRef2() { return aDoubleRef.Ref2; } -void ScDoubleRefOpToken::CalcAbsIfRel( const ScAddress& rPos ) - { aDoubleRef.CalcAbsIfRel( rPos ); } -void ScDoubleRefOpToken::CalcRelFromAbs( const ScAddress& rPos ) - { aDoubleRef.CalcRelFromAbs( rPos ); } -BOOL ScDoubleRefOpToken::operator==( const ScToken& r ) const +BOOL ScDoubleRefToken::operator==( const FormulaToken& r ) const { - return ScToken::operator==( r ) && aDoubleRef == r.GetDoubleRef(); + return FormulaToken::operator==( r ) && aDoubleRef == static_cast<const ScToken&>(r).GetDoubleRef(); } @@ -1107,31 +804,23 @@ void ScRefListToken::CalcRelFromAbs( const ScAddress& rPos ) for (ScRefList::iterator it( aRefList.begin()); it != aRefList.end(); ++it) (*it).CalcRelFromAbs( rPos); } -BOOL ScRefListToken::operator==( const ScToken& r ) const +BOOL ScRefListToken::operator==( const FormulaToken& r ) const { - return ScToken::operator==( r ) && &aRefList == r.GetRefList(); + return FormulaToken::operator==( r ) && &aRefList == static_cast<const ScToken&>(r).GetRefList(); } const ScMatrix* ScMatrixToken::GetMatrix() const { return pMatrix; } ScMatrix* ScMatrixToken::GetMatrix() { return pMatrix; } -BOOL ScMatrixToken::operator==( const ScToken& r ) const +BOOL ScMatrixToken::operator==( const FormulaToken& r ) const { - return ScToken::operator==( r ) && pMatrix == r.GetMatrix(); -} - - -USHORT ScIndexToken::GetIndex() const { return nIndex; } -void ScIndexToken::SetIndex( USHORT n ) { nIndex = n; } -BOOL ScIndexToken::operator==( const ScToken& r ) const -{ - return ScToken::operator==( r ) && nIndex == r.GetIndex(); + return FormulaToken::operator==( r ) && pMatrix == static_cast<const ScToken&>(r).GetMatrix(); } // ============================================================================ ScExternalSingleRefToken::ScExternalSingleRefToken( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& r ) : - ScOpToken(ocExternalRef, svExternalSingleRef), + ScToken( svExternalSingleRef, ocExternalRef), mnFileId(nFileId), maTabName(rTabName), maSingleRef(r) @@ -1139,7 +828,7 @@ ScExternalSingleRefToken::ScExternalSingleRefToken( sal_uInt16 nFileId, const St } ScExternalSingleRefToken::ScExternalSingleRefToken( const ScExternalSingleRefToken& r ) : - ScOpToken(r), + ScToken(r), mnFileId(r.mnFileId), maTabName(r.maTabName), maSingleRef(r.maSingleRef) @@ -1187,7 +876,7 @@ BOOL ScExternalSingleRefToken::operator ==( const ScToken& r ) const // ============================================================================ ScExternalDoubleRefToken::ScExternalDoubleRefToken( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& r ) : - ScOpToken(ocExternalRef, svExternalDoubleRef), + ScToken( svExternalDoubleRef, ocExternalRef), mnFileId(nFileId), maTabName(rTabName), maDoubleRef(r) @@ -1195,7 +884,7 @@ ScExternalDoubleRefToken::ScExternalDoubleRefToken( sal_uInt16 nFileId, const St } ScExternalDoubleRefToken::ScExternalDoubleRefToken( const ScExternalDoubleRefToken& r ) : - ScOpToken(r), + ScToken(r), mnFileId(r.mnFileId), maTabName(r.maTabName), maDoubleRef(r.maDoubleRef) @@ -1263,14 +952,14 @@ BOOL ScExternalDoubleRefToken::operator ==( const ScToken& r ) const // ============================================================================ ScExternalNameToken::ScExternalNameToken( sal_uInt16 nFileId, const String& rName ) : - ScOpToken(ocExternalRef, svExternalName), + ScToken( svExternalName, ocExternalRef), mnFileId(nFileId), maName(rName) { } ScExternalNameToken::ScExternalNameToken( const ScExternalNameToken& r ) : - ScOpToken(r), + ScToken(r), mnFileId(r.mnFileId), maName(r.maName) { @@ -1313,53 +1002,25 @@ BOOL ScExternalNameToken::operator==( const ScToken& r ) const // ============================================================================ -short* ScJumpToken::GetJump() const { return pJump; } -BOOL ScJumpToken::operator==( const ScToken& r ) const -{ - return ScToken::operator==( r ) && pJump[0] == r.GetJump()[0] && - memcmp( pJump+1, r.GetJump()+1, pJump[0] * sizeof(short) ) == 0; -} -ScJumpToken::~ScJumpToken() -{ - delete [] pJump; -} - - ScJumpMatrix* ScJumpMatrixToken::GetJumpMatrix() const { return pJumpMatrix; } -BOOL ScJumpMatrixToken::operator==( const ScToken& r ) const +BOOL ScJumpMatrixToken::operator==( const FormulaToken& r ) const { - return ScToken::operator==( r ) && pJumpMatrix == r.GetJumpMatrix(); + return FormulaToken::operator==( r ) && pJumpMatrix == static_cast<const ScToken&>(r).GetJumpMatrix(); } ScJumpMatrixToken::~ScJumpMatrixToken() { delete pJumpMatrix; } - -const String& ScExternalToken::GetExternal() const { return aExternal; } -BYTE ScExternalToken::GetByte() const { return nByte; } -void ScExternalToken::SetByte( BYTE n ) { nByte = n; } -BOOL ScExternalToken::operator==( const ScToken& r ) const -{ - return ScToken::operator==( r ) && nByte == r.GetByte() && - aExternal == r.GetExternal(); -} - - -USHORT ScErrorToken::GetError() const { return nError; } -void ScErrorToken::SetError( USHORT nErr ) { nError = nErr; } -BOOL ScErrorToken::operator==( const ScToken& r ) const +double ScEmptyCellToken::GetDouble() const { return 0.0; } +const String & ScEmptyCellToken::GetString() const { - return ScToken::operator==( r ) && - nError == static_cast< const ScErrorToken & >(r).GetError(); + static String aDummyString; + return aDummyString; } - - -double ScEmptyCellToken::GetDouble() const { return 0.0; } -const String & ScEmptyCellToken::GetString() const { return aDummyString; } -BOOL ScEmptyCellToken::operator==( const ScToken& r ) const +BOOL ScEmptyCellToken::operator==( const FormulaToken& r ) const { - return ScToken::operator==( r ) && + return FormulaToken::operator==( r ) && bInherited == static_cast< const ScEmptyCellToken & >(r).IsInherited() && bDisplayedAsString == static_cast< const ScEmptyCellToken & >(r).IsDisplayedAsString(); } @@ -1370,25 +1031,25 @@ const String & ScMatrixCellResultToken::GetString() const { return xUpperLeft- const ScMatrix* ScMatrixCellResultToken::GetMatrix() const { return xMatrix; } // Non-const GetMatrix() is private and unused but must be implemented to // satisfy vtable linkage. - ScMatrix* ScMatrixCellResultToken::GetMatrix() +ScMatrix* ScMatrixCellResultToken::GetMatrix() { return const_cast<ScMatrix*>(xMatrix.operator->()); } -BOOL ScMatrixCellResultToken::operator==( const ScToken& r ) const +BOOL ScMatrixCellResultToken::operator==( const FormulaToken& r ) const { - return ScToken::operator==( r ) && + return FormulaToken::operator==( r ) && xUpperLeft == static_cast<const ScMatrixCellResultToken &>(r).xUpperLeft && xMatrix == static_cast<const ScMatrixCellResultToken &>(r).xMatrix; } -BOOL ScMatrixFormulaCellToken::operator==( const ScToken& r ) const +BOOL ScMatrixFormulaCellToken::operator==( const FormulaToken& r ) const { const ScMatrixFormulaCellToken* p = dynamic_cast<const ScMatrixFormulaCellToken*>(&r); return p && ScMatrixCellResultToken::operator==( r ) && nCols == p->nCols && nRows == p->nRows; } -void ScMatrixFormulaCellToken::Assign( const ScToken& r ) +void ScMatrixFormulaCellToken::Assign( const formula::FormulaToken& r ) { if (this == &r) return; @@ -1401,7 +1062,7 @@ void ScMatrixFormulaCellToken::Assign( const ScToken& r ) if (r.GetType() == svMatrix) { xUpperLeft = NULL; - xMatrix = r.GetMatrix(); + xMatrix = static_cast<const ScToken&>(r).GetMatrix(); } else { @@ -1415,15 +1076,12 @@ void ScMatrixFormulaCellToken::SetUpperLeftDouble( double f ) switch (GetUpperLeftType()) { case svDouble: - { - const ScToken* pT = xUpperLeft; - const_cast<ScToken*>(pT)->GetDoubleAsReference() = f; - } + const_cast<FormulaToken*>(xUpperLeft.get())->GetDoubleAsReference() = f; break; case svUnknown: if (!xUpperLeft) { - xUpperLeft = new ScDoubleToken( f); + xUpperLeft = new FormulaDoubleToken( f); break; } // fall thru @@ -1437,280 +1095,146 @@ void ScMatrixFormulaCellToken::SetUpperLeftDouble( double f ) double ScHybridCellToken::GetDouble() const { return fDouble; } const String & ScHybridCellToken::GetString() const { return aString; } -BOOL ScHybridCellToken::operator==( const ScToken& r ) const +BOOL ScHybridCellToken::operator==( const FormulaToken& r ) const { - return ScToken::operator==( r ) && + return FormulaToken::operator==( r ) && fDouble == r.GetDouble() && aString == r.GetString() && aFormula == static_cast<const ScHybridCellToken &>(r).GetFormula(); } -double ScMissingToken::GetDouble() const { return 0.0; } -const String& ScMissingToken::GetString() const { return aDummyString; } -BOOL ScMissingToken::operator==( const ScToken& r ) const -{ - return ScToken::operator==( r ); -} - - -BOOL ScUnknownToken::operator==( const ScToken& r ) const -{ - return ScToken::operator==( r ); -} ////////////////////////////////////////////////////////////////////////// -ScToken* ScTokenArray::GetNextReference() -{ - while( nIndex < nLen ) - { - ScToken* t = pCode[ nIndex++ ]; - switch( t->GetType() ) - { - case svSingleRef: - case svDoubleRef: - case svExternalSingleRef: - case svExternalDoubleRef: - return t; - default: - { - // added to avoid warnings - } - } - } - return NULL; -} - -ScToken* ScTokenArray::GetNextColRowName() -{ - while( nIndex < nLen ) - { - ScToken* t = pCode[ nIndex++ ]; - if ( t->GetOpCode() == ocColRowName ) - return t; - } - return NULL; -} - -ScToken* ScTokenArray::GetNextReferenceRPN() +bool ScTokenArray::AddFormulaToken(const com::sun::star::sheet::FormulaToken& _aToken) { - while( nIndex < nRPN ) + bool bError = FormulaTokenArray::AddFormulaToken(_aToken); + if ( bError ) { - ScToken* t = pRPN[ nIndex++ ]; - switch( t->GetType() ) - { - case svSingleRef: - case svDoubleRef: - case svExternalSingleRef: - case svExternalDoubleRef: - return t; - default: - { - // added to avoid warnings - } - } - } - return NULL; -} + bError = false; + const OpCode eOpCode = static_cast<OpCode>(_aToken.OpCode); //! assuming equal values for the moment -ScToken* ScTokenArray::GetNextReferenceOrName() -{ - for( ScToken* t = Next(); t; t = Next() ) - { - switch( t->GetType() ) + const uno::TypeClass eClass = _aToken.Data.getValueTypeClass(); + switch ( eClass ) { - case svSingleRef: - case svDoubleRef: - case svIndex: - case svExternalSingleRef: - case svExternalDoubleRef: - case svExternalName: - return t; + case uno::TypeClass_STRUCT: + { + uno::Type aType = _aToken.Data.getValueType(); + if ( aType.equals( cppu::UnoType<sheet::SingleReference>::get() ) ) + { + ScSingleRefData aSingleRef; + sheet::SingleReference aApiRef; + _aToken.Data >>= aApiRef; + lcl_SingleRefToCalc( aSingleRef, aApiRef ); + if ( eOpCode == ocPush ) + AddSingleReference( aSingleRef ); + else if ( eOpCode == ocColRowName ) + AddColRowName( aSingleRef ); + else + bError = true; + } + else if ( aType.equals( cppu::UnoType<sheet::ComplexReference>::get() ) ) + { + ScComplexRefData aComplRef; + sheet::ComplexReference aApiRef; + _aToken.Data >>= aApiRef; + lcl_SingleRefToCalc( aComplRef.Ref1, aApiRef.Reference1 ); + lcl_SingleRefToCalc( aComplRef.Ref2, aApiRef.Reference2 ); + + if ( eOpCode == ocPush ) + AddDoubleReference( aComplRef ); + else + bError = true; + } + else if ( aType.equals( cppu::UnoType<sheet::ExternalReference>::get() ) ) + { + sheet::ExternalReference aApiExtRef; + if( (eOpCode == ocPush) && (rAPI.Data >>= aApiExtRef) && (0 <= aApiExtRef.Index) && (aApiExtRef.Index <= SAL_MAX_UINT16) ) + { + sal_uInt16 nFileId = static_cast< sal_uInt16 >( aApiExtRef.Index ); + sheet::SingleReference aApiSRef; + sheet::ComplexReference aApiCRef; + ::rtl::OUString aName; + if( aApiExtRef.Reference >>= aApiSRef ) + { + // try to resolve cache index to sheet name + size_t nCacheId = static_cast< size_t >( aApiSRef.Sheet ); + String aTabName = rDoc.GetExternalRefManager()->getCacheTableName( nFileId, nCacheId ); + if( aTabName.Len() > 0 ) + { + ScSingleRefData aSingleRef; + // convert column/row settings, set sheet index to absolute + lcl_ExternalRefToCalc( aSingleRef, aApiSRef ); + AddExternalSingleReference( nFileId, aTabName, aSingleRef ); + } + else + bError = true; + } + else if( aApiExtRef.Reference >>= aApiCRef ) + { + // try to resolve cache index to sheet name. + size_t nCacheId = static_cast< size_t >( aApiCRef.Reference1.Sheet ); + String aTabName = rDoc.GetExternalRefManager()->getCacheTableName( nFileId, nCacheId ); + if( aTabName.Len() > 0 ) + { + ScComplexRefData aComplRef; + // convert column/row settings, set sheet index to absolute + lcl_ExternalRefToCalc( aComplRef.Ref1, aApiCRef.Reference1 ); + lcl_ExternalRefToCalc( aComplRef.Ref2, aApiCRef.Reference2 ); + // NOTE: This assumes that cached sheets are in consecutive order! + aComplRef.Ref2.nTab = aComplRef.Ref1.nTab + (aApiCRef.Reference2.Sheet - aApiCRef.Reference1.Sheet); + AddExternalDoubleReference( nFileId, aTabName, aComplRef ); + } + else + bError = true; + } + else if( aApiExtRef.Reference >>= aName ) + { + if( aName.getLength() > 0 ) + AddExternalName( nFileId, aName ); + else + bError = true; + } + else + bError = true; + } + else + bError = true; + } + else + bError = true; // unknown struct + } + break; + case uno::TypeClass_SEQUENCE: + { + if ( eOpCode != ocPush ) + bError = true; // not an inline array + else if (!_aToken.Data.getValueType().equals( getCppuType( + (uno::Sequence< uno::Sequence< uno::Any > > *)0))) + bError = true; // unexpected sequence type + else + { + ScMatrixRef xMat = ScSequenceToMatrix::CreateMixedMatrix( _aToken.Data); + if (xMat) + AddMatrix( xMat); + else + bError = true; + } + } + break; default: - { - // added to avoid warnings - } - } - } - return NULL; -} - -ScToken* ScTokenArray::GetNextName() -{ - for( ScToken* t = Next(); t; t = Next() ) - { - if( t->GetType() == svIndex ) - return t; - } - return NULL; -} - -ScToken* ScTokenArray::GetNextDBArea() -{ - for( ScToken* t = Next(); t; t = Next() ) - { - if ( t->GetOpCode() == ocDBArea ) - return t; - } - return NULL; -} - -ScToken* ScTokenArray::GetNextOpCodeRPN( OpCode eOp ) -{ - while( nIndex < nRPN ) - { - ScToken* t = pRPN[ nIndex++ ]; - if ( t->GetOpCode() == eOp ) - return t; - } - return NULL; -} - -ScToken* ScTokenArray::Next() -{ - if( pCode && nIndex < nLen ) - return pCode[ nIndex++ ]; - else - return NULL; -} - -ScToken* ScTokenArray::NextNoSpaces() -{ - if( pCode ) - { - while( (nIndex < nLen) && (pCode[ nIndex ]->GetOpCode() == ocSpaces) ) - ++nIndex; - if( nIndex < nLen ) - return pCode[ nIndex++ ]; - } - return NULL; -} - -ScToken* ScTokenArray::NextRPN() -{ - if( pRPN && nIndex < nRPN ) - return pRPN[ nIndex++ ]; - else - return NULL; -} - -ScToken* ScTokenArray::PrevRPN() -{ - if( pRPN && nIndex ) - return pRPN[ --nIndex ]; - else - return NULL; -} - -void ScTokenArray::DelRPN() -{ - if( nRPN ) - { - ScToken** p = pRPN; - for( USHORT i = 0; i < nRPN; i++ ) - { - (*p++)->DecRef(); + bError = true; } - delete [] pRPN; } - pRPN = NULL; - nRPN = nIndex = 0; -} - -ScToken* ScTokenArray::PeekPrev( USHORT & nIdx ) -{ - if (0 < nIdx && nIdx <= nLen) - return pCode[--nIdx]; - return NULL; + return bError; } - -ScToken* ScTokenArray::PeekNext() -{ - if( pCode && nIndex < nLen ) - return pCode[ nIndex ]; - else - return NULL; -} - -ScToken* ScTokenArray::PeekNextNoSpaces() -{ - if( pCode && nIndex < nLen ) - { - USHORT j = nIndex; - while ( pCode[j]->GetOpCode() == ocSpaces && j < nLen ) - j++; - if ( j < nLen ) - return pCode[ j ]; - else - return NULL; - } - else - return NULL; -} - -ScToken* ScTokenArray::PeekPrevNoSpaces() -{ - if( pCode && nIndex > 1 ) - { - USHORT j = nIndex - 2; - while ( pCode[j]->GetOpCode() == ocSpaces && j > 0 ) - j--; - if ( j > 0 || pCode[j]->GetOpCode() != ocSpaces ) - return pCode[ j ]; - else - return NULL; - } - else - return NULL; -} - -BOOL ScTokenArray::HasOpCode( OpCode eOp ) const -{ - for ( USHORT j=0; j < nLen; j++ ) - { - if ( pCode[j]->GetOpCode() == eOp ) - return TRUE; - } - return FALSE; -} - -BOOL ScTokenArray::HasOpCodeRPN( OpCode eOp ) const -{ - for ( USHORT j=0; j < nRPN; j++ ) - { - if ( pRPN[j]->GetOpCode() == eOp ) - return TRUE; - } - return FALSE; -} - -//UNUSED2008-05 BOOL ScTokenArray::HasName() const -//UNUSED2008-05 { -//UNUSED2008-05 for ( USHORT j=0; j < nLen; j++ ) -//UNUSED2008-05 { -//UNUSED2008-05 if ( pCode[j]->GetType() == svIndex ) -//UNUSED2008-05 return TRUE; -//UNUSED2008-05 } -//UNUSED2008-05 return FALSE; -//UNUSED2008-05 } - -BOOL ScTokenArray::HasNameOrColRowName() const -{ - for ( USHORT j=0; j < nLen; j++ ) - { - if( pCode[j]->GetType() == svIndex || pCode[j]->GetOpCode() == ocColRowName ) - return TRUE; - } - return FALSE; -} - BOOL ScTokenArray::ImplGetReference( ScRange& rRange, BOOL bValidOnly ) const { BOOL bIs = FALSE; if ( pCode && nLen == 1 ) { - const ScToken* pToken = pCode[0]; + const FormulaToken* pToken = pCode[0]; if ( pToken ) { if ( pToken->GetType() == svSingleRef ) @@ -1747,49 +1271,17 @@ BOOL ScTokenArray::IsValidReference( ScRange& rRange ) const ScTokenArray::ScTokenArray() { - pCode = NULL; pRPN = NULL; - nError = nLen = nIndex = nRPN = nRefs = 0; - bHyperLink = FALSE; - ClearRecalcMode(); } -ScTokenArray::ScTokenArray( const ScTokenArray& rArr ) +ScTokenArray::ScTokenArray( const ScTokenArray& rArr ) : FormulaTokenArray(rArr) { - Assign( rArr ); } ScTokenArray::~ScTokenArray() { - Clear(); } -void ScTokenArray::Assign( const ScTokenArray& r ) -{ - nLen = r.nLen; - nRPN = r.nRPN; - nIndex = r.nIndex; - nError = r.nError; - nRefs = r.nRefs; - nMode = r.nMode; - bHyperLink = r.bHyperLink; - pCode = NULL; - pRPN = NULL; - ScToken** pp; - if( nLen ) - { - pp = pCode = new ScToken*[ nLen ]; - memcpy( pp, r.pCode, nLen * sizeof( ScToken* ) ); - for( USHORT i = 0; i < nLen; i++ ) - (*pp++)->IncRef(); - } - if( nRPN ) - { - pp = pRPN = new ScToken*[ nRPN ]; - memcpy( pp, r.pRPN, nRPN * sizeof( ScToken* ) ); - for( USHORT i = 0; i < nRPN; i++ ) - (*pp++)->IncRef(); - } -} + ScTokenArray& ScTokenArray::operator=( const ScTokenArray& rArr ) { @@ -1807,10 +1299,10 @@ ScTokenArray* ScTokenArray::Clone() const p->nMode = nMode; p->nError = nError; p->bHyperLink = bHyperLink; - ScToken** pp; + FormulaToken** pp; if( nLen ) { - pp = p->pCode = new ScToken*[ nLen ]; + pp = p->pCode = new FormulaToken*[ nLen ]; memcpy( pp, pCode, nLen * sizeof( ScToken* ) ); for( USHORT i = 0; i < nLen; i++, pp++ ) { @@ -1820,14 +1312,14 @@ ScTokenArray* ScTokenArray::Clone() const } if( nRPN ) { - pp = p->pRPN = new ScToken*[ nRPN ]; + pp = p->pRPN = new FormulaToken*[ nRPN ]; memcpy( pp, pRPN, nRPN * sizeof( ScToken* ) ); for( USHORT i = 0; i < nRPN; i++, pp++ ) { - ScToken* t = *pp; + FormulaToken* t = *pp; if( t->GetRef() > 1 ) { - ScToken** p2 = pCode; + FormulaToken** p2 = pCode; USHORT nIdx = 0xFFFF; for( USHORT j = 0; j < nLen; j++, p2++ ) { @@ -1849,34 +1341,11 @@ ScTokenArray* ScTokenArray::Clone() const return p; } -void ScTokenArray::Clear() -{ - if( nRPN ) DelRPN(); - if( pCode ) - { - ScToken** p = pCode; - for( USHORT i = 0; i < nLen; i++ ) - { - (*p++)->DecRef(); - } - delete [] pCode; - } - pCode = NULL; pRPN = NULL; - nError = nLen = nIndex = nRPN = nRefs = 0; - bHyperLink = FALSE; - ClearRecalcMode(); -} - -ScToken* ScTokenArray::AddToken( const ScRawToken& r ) +FormulaToken* ScTokenArray::AddRawToken( const ScRawToken& r ) { return Add( r.CreateToken() ); } -ScToken* ScTokenArray::AddToken( const ScToken& r ) -{ - return Add( r.Clone() ); -} - // Utility function to ensure that there is strict alternation of values and // seperators. static bool @@ -1887,12 +1356,12 @@ checkArraySep( bool & bPrevWasSep, bool bNewVal ) return bResult; } -ScToken* ScTokenArray::MergeArray( ) +FormulaToken* ScTokenArray::MergeArray( ) { int nCol = -1, nRow = 0; int i, nPrevRowSep = -1, nStart = 0; bool bPrevWasSep = false; // top of stack is ocArrayClose - ScToken* t; + FormulaToken* t; bool bNumeric = false; // numeric value encountered in current element // (1) Iterate from the end to the start to find matrix dims @@ -2064,18 +1533,18 @@ ScToken* ScTokenArray::MergeArray( ) } -ScToken* ScTokenArray::MergeRangeReference( const ScAddress & rPos ) +FormulaToken* ScTokenArray::MergeRangeReference( const ScAddress & rPos ) { if (!pCode || !nLen) return NULL; USHORT nIdx = nLen; - ScToken *p1, *p2, *p3; // ref, ocRange, ref + FormulaToken *p1, *p2, *p3; // ref, ocRange, ref // The actual types are checked in ExtendRangeReference(). if (((p3 = PeekPrev(nIdx)) != 0) && (((p2 = PeekPrev(nIdx)) != 0) && p2->GetOpCode() == ocRange) && ((p1 = PeekPrev(nIdx)) != 0)) { - ScTokenRef p = ScToken::ExtendRangeReference( *p1, *p3, rPos, true); + FormulaTokenRef p = ScToken::ExtendRangeReference( *p1, *p3, rPos, true); if (p) { p->IncRef(); @@ -2090,125 +1559,53 @@ ScToken* ScTokenArray::MergeRangeReference( const ScAddress & rPos ) return pCode[ nLen-1 ]; } - -ScToken* ScTokenArray::Add( ScToken* t ) -{ - if( !pCode ) - pCode = new ScToken*[ MAXCODE ]; - if( nLen < MAXCODE-1 ) - { - // fprintf (stderr, "Add : %d\n", t->GetOpCode()); - pCode[ nLen++ ] = t; - if( t->GetOpCode() == ocPush - && ( t->GetType() == svSingleRef || t->GetType() == svDoubleRef ) ) - nRefs++; - t->IncRef(); - if( t->GetOpCode() == ocArrayClose ) - return MergeArray(); - return t; - } - else - { - t->Delete(); - if ( nLen == MAXCODE-1 ) - { - t = new ScByteToken( ocStop ); - pCode[ nLen++ ] = t; - t->IncRef(); - } - return NULL; - } -} - -ScToken* ScTokenArray::AddOpCode( OpCode e ) +FormulaToken* ScTokenArray::AddOpCode( OpCode e ) { ScRawToken t; t.SetOpCode( e ); - return AddToken( t ); -} - -ScToken* ScTokenArray::AddString( const sal_Unicode* pStr ) -{ - return AddString( String( pStr ) ); -} - -ScToken* ScTokenArray::AddString( const String& rStr ) -{ - return Add( new ScStringToken( rStr ) ); -} - -ScToken* ScTokenArray::AddDouble( double fVal ) -{ - return Add( new ScDoubleToken( fVal ) ); + return AddRawToken( t ); } -ScToken* ScTokenArray::AddSingleReference( const ScSingleRefData& rRef ) +FormulaToken* ScTokenArray::AddSingleReference( const ScSingleRefData& rRef ) { return Add( new ScSingleRefToken( rRef ) ); } -ScToken* ScTokenArray::AddMatrixSingleReference( const ScSingleRefData& rRef ) +FormulaToken* ScTokenArray::AddMatrixSingleReference( const ScSingleRefData& rRef ) { - return Add( new ScSingleRefOpToken( ocMatRef, rRef ) ); + return Add( new ScSingleRefToken( rRef, ocMatRef ) ); } -ScToken* ScTokenArray::AddDoubleReference( const ScComplexRefData& rRef ) +FormulaToken* ScTokenArray::AddDoubleReference( const ScScComplexRefData& rRef ) { return Add( new ScDoubleRefToken( rRef ) ); } -ScToken* ScTokenArray::AddName( USHORT n ) -{ - return Add( new ScIndexToken( ocName, n ) ); -} - -ScToken* ScTokenArray::AddExternal( const sal_Unicode* pStr ) -{ - return AddExternal( String( pStr ) ); -} - -ScToken* ScTokenArray::AddExternal( const String& rStr, - OpCode eOp /* = ocExternal */ ) -{ - return Add( new ScExternalToken( eOp, rStr ) ); -} - -ScToken* ScTokenArray::AddMatrix( ScMatrix* p ) +FormulaToken* ScTokenArray::AddMatrix( ScMatrix* p ) { return Add( new ScMatrixToken( p ) ); } -ScToken* ScTokenArray::AddExternalName( sal_uInt16 nFileId, const String& rName ) +FormulaToken* ScTokenArray::AddExternalName( sal_uInt16 nFileId, const String& rName ) { return Add( new ScExternalNameToken(nFileId, rName) ); } -ScToken* ScTokenArray::AddExternalSingleReference( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ) +FormulaToken* ScTokenArray::AddExternalSingleReference( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ) { return Add( new ScExternalSingleRefToken(nFileId, rTabName, rRef) ); } -ScToken* ScTokenArray::AddExternalDoubleReference( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef ) +FormulaToken* ScTokenArray::AddExternalDoubleReference( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef ) { return Add( new ScExternalDoubleRefToken(nFileId, rTabName, rRef) ); } -ScToken* ScTokenArray::AddColRowName( const ScSingleRefData& rRef ) -{ - return Add( new ScSingleRefOpToken( ocColRowName, rRef ) ); -} - -ScToken* ScTokenArray::AddBad( const sal_Unicode* pStr ) +FormulaToken* ScTokenArray::AddColRowName( const ScSingleRefData& rRef ) { - return AddBad( String( pStr ) ); + return Add( new ScSingleRefToken( rRef, ocColRowName ) ); } -ScToken* ScTokenArray::AddBad( const String& rStr ) -{ - return Add( new ScStringOpToken( ocBad, rStr ) ); -} - - BOOL ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend, const ScAddress& rPos, ScDirection eDir ) { @@ -2246,7 +1643,7 @@ BOOL ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend, } if ( pRPN && nRPN ) { - ScToken* t = pRPN[nRPN-1]; + FormulaToken* t = pRPN[nRPN-1]; if ( t->GetType() == svByte ) { BYTE nParamCount = t->GetByte(); @@ -2256,12 +1653,12 @@ BOOL ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend, USHORT nParam = nRPN - nParamCount - 1; for ( ; nParam < nRPN-1; nParam++ ) { - ScToken* p = pRPN[nParam]; + FormulaToken* p = pRPN[nParam]; switch ( p->GetType() ) { case svSingleRef : { - ScSingleRefData& rRef = p->GetSingleRef(); + ScSingleRefData& rRef = static_cast<ScToken*>(p)->GetSingleRef(); rRef.CalcAbsIfRel( rPos ); switch ( eDir ) { @@ -2304,7 +1701,7 @@ BOOL ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend, break; case svDoubleRef : { - ScComplexRefData& rRef = p->GetDoubleRef(); + ScScComplexRefData& rRef = static_cast<ScToken*>(p)->GetDoubleRef(); rRef.CalcAbsIfRel( rPos ); switch ( eDir ) { @@ -2359,94 +1756,6 @@ BOOL ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend, } -void ScTokenArray::AddRecalcMode( ScRecalcMode nBits ) -{ - //! Reihenfolge ist wichtig - if ( nBits & RECALCMODE_ALWAYS ) - SetRecalcModeAlways(); - else if ( !IsRecalcModeAlways() ) - { - if ( nBits & RECALCMODE_ONLOAD ) - SetRecalcModeOnLoad(); - else if ( nBits & RECALCMODE_ONLOAD_ONCE && !IsRecalcModeOnLoad() ) - SetRecalcModeOnLoadOnce(); - } - SetCombinedBitsRecalcMode( nBits ); -} - - -BOOL ScTokenArray::HasMatrixDoubleRefOps() -{ - if ( pRPN && nRPN ) - { - // RPN-Interpreter Simulation - // als Ergebnis jeder Funktion wird einfach ein Double angenommen - ScToken** pStack = new ScToken* [nRPN]; - ScToken* pResult = new ScDoubleToken( 0.0 ); - short sp = 0; - for ( USHORT j = 0; j < nRPN; j++ ) - { - ScToken* t = pRPN[j]; - OpCode eOp = t->GetOpCode(); - BYTE nParams = t->GetParamCount(); - switch ( eOp ) - { - case ocAdd : - case ocSub : - case ocMul : - case ocDiv : - case ocPow : - case ocPower : - case ocAmpersand : - case ocEqual : - case ocNotEqual : - case ocLess : - case ocGreater : - case ocLessEqual : - case ocGreaterEqual : - { - for ( BYTE k = nParams; k; k-- ) - { - if ( sp >= k && pStack[sp-k]->GetType() == svDoubleRef ) - { - pResult->Delete(); - delete [] pStack; - return TRUE; - } - } - } - break; - default: - { - // added to avoid warnings - } - } - if ( eOp == ocPush || lcl_IsReference( eOp, t->GetType() ) ) - pStack[sp++] = t; - else if ( eOp == ocIf || eOp == ocChose ) - { // Jumps ignorieren, vorheriges Result (Condition) poppen - if ( sp ) - --sp; - } - else - { // pop parameters, push result - sp = sal::static_int_cast<short>( sp - nParams ); - if ( sp < 0 ) - { - DBG_ERROR( "ScTokenArray::HasMatrixDoubleRefOps: sp < 0" ); - sp = 0; - } - pStack[sp++] = pResult; - } - } - pResult->Delete(); - delete [] pStack; - } - - return FALSE; -} - - void ScTokenArray::ReadjustRelative3DReferences( const ScAddress& rOldPos, const ScAddress& rNewPos ) { @@ -2456,9 +1765,9 @@ void ScTokenArray::ReadjustRelative3DReferences( const ScAddress& rOldPos, { case svDoubleRef : { - ScSingleRefData& rRef2 = pCode[j]->GetSingleRef2(); + ScSingleRefData& rRef2 = static_cast<ScToken*>(pCode[j])->GetSingleRef2(); // Also adjust if the reference is of the form Sheet1.A2:A3 - if ( rRef2.IsFlag3D() || pCode[j]->GetSingleRef().IsFlag3D() ) + if ( rRef2.IsFlag3D() || static_cast<ScToken*>(pCode[j])->GetSingleRef().IsFlag3D() ) { rRef2.CalcAbsIfRel( rOldPos ); rRef2.CalcRelFromAbs( rNewPos ); @@ -2467,9 +1776,7 @@ void ScTokenArray::ReadjustRelative3DReferences( const ScAddress& rOldPos, //! fallthru case svSingleRef : { - ScSingleRefData& rRef1 = pCode[j]->GetSingleRef(); - if ( rRef1.IsFlag3D() ) - { + ScSingleRefData& rRef1 = static_cast<ScToken*>(pCode[j])->GetSingleRef(); rRef1.CalcAbsIfRel( rOldPos ); rRef1.CalcRelFromAbs( rNewPos ); } @@ -2484,378 +1791,3 @@ void ScTokenArray::ReadjustRelative3DReferences( const ScAddress& rOldPos, } -// --- POF (plain old formula) rewrite of a token array --------------------- - -#if 0 -// static function can't be compiled if not used (warning) -//#if OSL_DEBUG_LEVEL > 0 -static void DumpTokArr( ScTokenArray *pCode ) -{ - fprintf (stderr, "TokenArr: "); - for ( ScToken *pCur = pCode->First(); pCur; pCur = pCode->Next() ) - fprintf( stderr, "t%d,o%d ", - pCur->GetType(), pCur->GetOpCode() ); - fprintf (stderr, "\n"); -} -#endif - -class ScMissingContext -{ - public: - const ScToken* mpFunc; - int mnCurArg; - - void Clear() { mpFunc = NULL; mnCurArg = 0; } - inline bool AddDefaultArg( ScTokenArray* pNewArr, int nArg, double f ) const; - bool AddMissingExternal( ScTokenArray* pNewArr ) const; - bool AddMissing( ScTokenArray *pNewArr, const ScMissingConvention & rConv ) const; - void AddMoreArgs( ScTokenArray *pNewArr, const ScMissingConvention & rConv ) const; -}; - -inline bool ScMissingConvention::isRewriteNeeded( OpCode eOp ) const -{ - switch (eOp) - { - case ocGammaDist: - case ocPoissonDist: - return true; - case ocMissing: - case ocLog: - case ocAddress: - return !isODFF(); // rewrite only for PODF - default: - return false; - } -} - -inline bool ScMissingContext::AddDefaultArg( ScTokenArray* pNewArr, int nArg, double f ) const -{ - if (mnCurArg == nArg) - { - pNewArr->AddDouble( f ); - return true; - } - return false; -} - -bool ScMissingContext::AddMissingExternal( ScTokenArray *pNewArr ) const -{ - // Only called for PODF, not ODFF. No need to distinguish. - - const String &rName = mpFunc->GetExternal(); - - // initial (fast) check: - sal_Unicode nLastChar = rName.GetChar( rName.Len() - 1); - if ( nLastChar != 't' && nLastChar != 'm' ) - return false; - - if (rName.EqualsIgnoreCaseAscii( - "com.sun.star.sheet.addin.Analysis.getAccrint" )) - { - return AddDefaultArg( pNewArr, 4, 1000.0 ); - } - if (rName.EqualsIgnoreCaseAscii( - "com.sun.star.sheet.addin.Analysis.getAccrintm" )) - { - return AddDefaultArg( pNewArr, 3, 1000.0 ); - } - return false; -} - -bool ScMissingContext::AddMissing( ScTokenArray *pNewArr, const ScMissingConvention & rConv ) const -{ - if ( !mpFunc ) - return false; - - bool bRet = false; - if (rConv.isODFF()) - { - } - else - { - switch ( mpFunc->GetOpCode() ) - { - case ocFixed: - return AddDefaultArg( pNewArr, 1, 2.0 ); - //break; - case ocBetaDist: - case ocBetaInv: - case ocRMZ: // PMT - return AddDefaultArg( pNewArr, 3, 0.0 ); - //break; - case ocZinsZ: // IPMT - case ocKapz: // PPMT - return AddDefaultArg( pNewArr, 4, 0.0 ); - //break; - case ocBW: // PV - case ocZW: // FV - bRet |= AddDefaultArg( pNewArr, 2, 0.0 ); // pmt - bRet |= AddDefaultArg( pNewArr, 3, 0.0 ); // [fp]v - break; - case ocZins: // RATE - bRet |= AddDefaultArg( pNewArr, 1, 0.0 ); // pmt - bRet |= AddDefaultArg( pNewArr, 3, 0.0 ); // fv - bRet |= AddDefaultArg( pNewArr, 4, 0.0 ); // type - break; - case ocExternal: - return AddMissingExternal( pNewArr ); - //break; - - // --- more complex cases --- - - case ocOffset: - // FIXME: rather tough. - // if arg 3 (height) ommitted, export arg1 (rows) - break; - default: - break; - } - } - - return bRet; -} - -void ScMissingContext::AddMoreArgs( ScTokenArray *pNewArr, const ScMissingConvention & rConv ) const -{ - if ( !mpFunc ) - return; - - switch (mpFunc->GetOpCode()) - { - case ocGammaDist: - if (mnCurArg == 2) - { - pNewArr->AddOpCode( ocSep ); - pNewArr->AddDouble( 1.0 ); // 4th, Cumulative=TRUE() - } - break; - case ocPoissonDist: - if (mnCurArg == 1) - { - pNewArr->AddOpCode( ocSep ); - pNewArr->AddDouble( 1.0 ); // 3rd, Cumulative=TRUE() - } - break; - case ocLog: - if ( !rConv.isODFF() && mnCurArg == 0 ) - { - pNewArr->AddOpCode( ocSep ); - pNewArr->AddDouble( 10.0 ); // 2nd, basis 10 - } - break; - default: - break; - } -} - - -bool ScTokenArray::NeedsPofRewrite( const ScMissingConvention & rConv ) -{ - for ( ScToken *pCur = First(); pCur; pCur = Next() ) - { - if (rConv.isRewriteNeeded( pCur->GetOpCode())) - return true; - } - return false; -} - - -ScTokenArray * ScTokenArray::RewriteMissingToPof( const ScMissingConvention & rConv ) -{ - const size_t nAlloc = 256; - ScMissingContext aCtx[ nAlloc ]; - int aOpCodeAddressStack[ nAlloc ]; // use of ADDRESS() function - const int nOmitAddressArg = 3; // ADDRESS() 4th parameter A1/R1C1 - USHORT nTokens = GetLen() + 1; - ScMissingContext* pCtx = (nAlloc < nTokens ? new ScMissingContext[nTokens] : &aCtx[0]); - int* pOcas = (nAlloc < nTokens ? new int[nTokens] : &aOpCodeAddressStack[0]); - // Never go below 0, never use 0, mpFunc always NULL. - pCtx[0].Clear(); - int nFn = 0; - int nOcas = 0; - - ScTokenArray *pNewArr = new ScTokenArray; - // At least RECALCMODE_ALWAYS needs to be set. - pNewArr->AddRecalcMode( GetRecalcMode()); - - for ( ScToken *pCur = First(); pCur; pCur = Next() ) - { - bool bAdd = true; - // Don't write the expression of the new inserted ADDRESS() parameter. - // Do NOT omit the new second parameter of INDIRECT() though. If that - // was done for both, INDIRECT() actually could calculate different and - // valid (but wrong) results with the then changed return value of - // ADDRESS(). Better let it generate an error instead. - for (int i = nOcas; i-- > 0 && bAdd; ) - { - if (pCtx[ pOcas[ i ] ].mnCurArg == nOmitAddressArg) - { - // Omit erverything except a trailing separator, the leading - // separator is omitted below. The other way around would leave - // an extraneous separator if no parameter followed. - if (!(pOcas[ i ] == nFn && pCur->GetOpCode() == ocSep)) - bAdd = false; - } - //fprintf( stderr, "ocAddress %d arg %d%s\n", (int)i, (int)pCtx[ pOcas[ i ] ].mnCurArg, (bAdd ? "" : " omitted")); - } - switch ( pCur->GetOpCode() ) - { - case ocOpen: - ++nFn; // all following operations on _that_ function - pCtx[ nFn ].mpFunc = PeekPrevNoSpaces(); - pCtx[ nFn ].mnCurArg = 0; - if (pCtx[ nFn ].mpFunc && pCtx[ nFn ].mpFunc->GetOpCode() == ocAddress) - pOcas[ nOcas++ ] = nFn; // entering ADDRESS() - break; - case ocClose: - pCtx[ nFn ].AddMoreArgs( pNewArr, rConv ); - DBG_ASSERT( nFn > 0, "ScTokenArray::RewriteMissingToPof: underflow"); - if (nOcas > 0 && pOcas[ nOcas-1 ] == nFn) - --nOcas; // leaving ADDRESS() - if (nFn > 0) - --nFn; - break; - case ocSep: - pCtx[ nFn ].mnCurArg++; - // Omit leading separator of ADDRESS() parameter. - if (nOcas && pOcas[ nOcas-1 ] == nFn && pCtx[ nFn ].mnCurArg == nOmitAddressArg) - { - bAdd = false; - //fprintf( stderr, "ocAddress %d sep %d omitted\n", (int)nOcas-1, nOmitAddressArg); - } - break; - case ocMissing: - if (bAdd) - bAdd = !pCtx[ nFn ].AddMissing( pNewArr, rConv ); - break; - default: - break; - } - if (bAdd) - pNewArr->AddToken( *pCur ); - } - - if (pOcas != &aOpCodeAddressStack[0]) - delete [] pOcas; - if (pCtx != &aCtx[0]) - delete [] pCtx; - - return pNewArr; -} - -bool ScTokenArray::MayReferenceFollow() -{ - if ( pCode && nLen > 0 ) - { - // ignore trailing spaces - USHORT i = nLen - 1; - while ( i > 0 && pCode[i]->GetOpCode() == SC_OPCODE_SPACES ) - { - --i; - } - if ( i > 0 || pCode[i]->GetOpCode() != SC_OPCODE_SPACES ) - { - OpCode eOp = pCode[i]->GetOpCode(); - if ( (SC_OPCODE_START_BIN_OP <= eOp && eOp < SC_OPCODE_STOP_BIN_OP ) || - (SC_OPCODE_START_UN_OP <= eOp && eOp < SC_OPCODE_STOP_UN_OP ) || - eOp == SC_OPCODE_OPEN || eOp == SC_OPCODE_SEP ) - { - return true; - } - } - } - return false; -} - - -/*----------------------------------------------------------------------*/ - -ScTokenIterator::ScTokenIterator( const ScTokenArray& rArr ) -{ - pCur = NULL; - Push( &rArr ); -} - -ScTokenIterator::~ScTokenIterator() -{ - while( pCur ) - Pop(); -} - -void ScTokenIterator::Push( const ScTokenArray* pArr ) -{ - ImpTokenIterator* p = new ImpTokenIterator; - p->pArr = pArr; - p->nPC = -1; - p->nStop = SHRT_MAX; - p->pNext = pCur; - pCur = p; -} - -void ScTokenIterator::Pop() -{ - ImpTokenIterator* p = pCur; - if( p ) - { - pCur = p->pNext; - delete p; - } -} - -void ScTokenIterator::Reset() -{ - while( pCur->pNext ) - Pop(); - pCur->nPC = -1; -} - -const ScToken* ScTokenIterator::First() -{ - Reset(); - return Next(); -} - -const ScToken* ScTokenIterator::Next() -{ - const ScToken* t = NULL; - ++pCur->nPC; - if( pCur->nPC < pCur->pArr->nRPN && pCur->nPC < pCur->nStop ) - { - t = pCur->pArr->pRPN[ pCur->nPC ]; - // such an OpCode ends an IF() or CHOOSE() path - if( t->GetOpCode() == ocSep || t->GetOpCode() == ocClose ) - t = NULL; - } - if( !t && pCur->pNext ) - { - Pop(); - t = Next(); - } - return t; -} - -//! The nPC counts after a Push() are -1 - -void ScTokenIterator::Jump( short nStart, short nNext, short nStop ) -{ - pCur->nPC = nNext; - if( nStart != nNext ) - { - Push( pCur->pArr ); - pCur->nPC = nStart; - pCur->nStop = nStop; - } -} - -bool ScTokenIterator::IsEndOfPath() const -{ - USHORT nTest = pCur->nPC + 1; - if( nTest < pCur->pArr->nRPN && nTest < pCur->nStop ) - { - const ScToken* t = pCur->pArr->pRPN[ nTest ]; - // such an OpCode ends an IF() or CHOOSE() path - return t->GetOpCode() == ocSep || t->GetOpCode() == ocClose; - } - return true; -} - diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx index 13d94d9f2587..6d83f263d47b 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -37,7 +37,7 @@ #include "document.hxx" #include "rangenam.hxx" #include "global.hxx" -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" #include "imp_op.hxx" #include "root.hxx" diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx index 47fbd506099c..6093ef5d8eeb 100644 --- a/sc/source/filter/excel/excform8.cxx +++ b/sc/source/filter/excel/excform8.cxx @@ -1228,7 +1228,7 @@ ConvErr ExcelToSc8::ConvertExternName( const ScTokenArray*& rpArray, XclImpStrea bool bError = false; ScSingleRefData aSRD; - ComplRefData aCRD; + ScComplexRefData aCRD; if (eStatus != ConvOK) { diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index 421bdd669480..e97a0d9fdd6f 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -88,7 +88,7 @@ #include "stlsheet.hxx" #include "stlpool.hxx" #include "editutil.hxx" -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" #include "excdoc.hxx" #include "xeformula.hxx" diff --git a/sc/source/filter/excel/tokstack.cxx b/sc/source/filter/excel/tokstack.cxx index c6cff9bbce78..28ce1a19b932 100644 --- a/sc/source/filter/excel/tokstack.cxx +++ b/sc/source/filter/excel/tokstack.cxx @@ -39,6 +39,7 @@ #include "compiler.hxx" #include "tokstack.hxx" #include "global.hxx" +#include "scmatrix.hxx" #include <stdio.h> // printf @@ -803,7 +804,7 @@ const TokenId TokenPool::StoreExtName( sal_uInt16 nFileId, const String& rName ) return static_cast<const TokenId>(nElementAkt); } -const TokenId TokenPool::StoreExtRef( sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef ) +const TokenId TokenPool::StoreExtRef( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ) { if ( nElementAkt >= nElement ) GrowElement(); @@ -822,7 +823,7 @@ const TokenId TokenPool::StoreExtRef( sal_uInt16 nFileId, const String& rTabName return static_cast<const TokenId>(nElementAkt); } -const TokenId TokenPool::StoreExtRef( sal_uInt16 nFileId, const String& rTabName, const ComplRefData& rRef ) +const TokenId TokenPool::StoreExtRef( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef ) { if ( nElementAkt >= nElement ) GrowElement(); diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx index 6fc5f782df8e..410badbc63f4 100644 --- a/sc/source/filter/excel/xeformula.cxx +++ b/sc/source/filter/excel/xeformula.cxx @@ -41,12 +41,15 @@ #include "xelink.hxx" #include "xename.hxx" #include "xeformula.hxx" +#include "token.hxx" +#include "tokenarray.hxx" #include "document.hxx" #include "externalrefmgr.hxx" #include <memory> +using namespace formula; // External reference log ===================================================== XclExpRefLogEntry::XclExpRefLogEntry() : @@ -135,12 +138,13 @@ XclExpCompData::XclExpCompData() : /** Working data for a processed Calc formula token. */ struct XclExpTokenData { - const ScToken* mpScToken; /// Currently processed Calc token. + const formula::FormulaToken* + mpScToken; /// Currently processed Calc token. sal_uInt8 mnSpaces; /// Number of spaces before the Calc token. inline explicit XclExpTokenData() : mpScToken( 0 ), mnSpaces( 0 ) {} inline bool Is() const { return mpScToken != 0; } - inline StackVar GetType() const { return mpScToken ? mpScToken->GetType() : static_cast< StackVar >( svUnknown ); } + inline formula::StackVar GetType() const { return mpScToken ? mpScToken->GetType() : static_cast< formula::StackVar >( svUnknown ); } inline OpCode GetOpCode() const { return mpScToken ? mpScToken->GetOpCode() : static_cast< OpCode >( ocNone ); } }; @@ -176,7 +180,7 @@ public: const XclExpExtFuncData& rExtFuncData, sal_uInt8 nExpRetClass ); - inline const ScToken& GetScToken() const { return *mrTokData.mpScToken; } + inline const formula::FormulaToken& GetScToken() const { return *mrTokData.mpScToken; } inline OpCode GetOpCode() const { return mrFuncInfo.meOpCode; } inline sal_uInt16 GetXclFuncIdx() const { return mrFuncInfo.mnXclFunc; } inline bool IsVolatile() const { return mrFuncInfo.IsVolatile(); } @@ -220,7 +224,7 @@ XclExpFuncData::XclExpFuncData( { DBG_ASSERT( mrTokData.mpScToken, "XclExpFuncData::XclExpFuncData - missing core token" ); // set name of an add-in function - if( !maExtFuncData.maFuncName.Len() && dynamic_cast< const ScExternalToken* >( mrTokData.mpScToken ) ) + if( !maExtFuncData.maFuncName.Len() && dynamic_cast< const formula::FormulaExternalToken* >( mrTokData.mpScToken ) ) maExtFuncData.Set( GetScToken().GetExternal(), true, false ); } @@ -234,22 +238,22 @@ void XclExpFuncData::IncExpParamClassIdx() namespace { -inline bool lclIsRefRel2D( const SingleRefData& rRefData ) +inline bool lclIsRefRel2D( const ScSingleRefData& rRefData ) { return rRefData.IsColRel() || rRefData.IsRowRel(); } -inline bool lclIsRefDel2D( const SingleRefData& rRefData ) +inline bool lclIsRefDel2D( const ScSingleRefData& rRefData ) { return rRefData.IsColDeleted() || rRefData.IsRowDeleted(); } -inline bool lclIsRefRel2D( const ComplRefData& rRefData ) +inline bool lclIsRefRel2D( const ScComplexRefData& rRefData ) { return lclIsRefRel2D( rRefData.Ref1 ) || lclIsRefRel2D( rRefData.Ref2 ); } -inline bool lclIsRefDel2D( const ComplRefData& rRefData ) +inline bool lclIsRefDel2D( const ScComplexRefData& rRefData ) { return lclIsRefDel2D( rRefData.Ref1 ) || lclIsRefDel2D( rRefData.Ref2 ); } @@ -296,8 +300,8 @@ private: // compiler --------------------------------------------------------------- // XclExpTokenData: pass-by-value and return-by-value is intended - const ScToken* GetNextRawToken(); - const ScToken* PeekNextRawToken( bool bSkipSpaces ) const; + const formula::FormulaToken* GetNextRawToken(); + const formula::FormulaToken* PeekNextRawToken( bool bSkipSpaces ) const; bool GetNextToken( XclExpTokenData& rTokData ); XclExpTokenData GetNextToken(); @@ -785,14 +789,14 @@ XclTokenArrayRef XclExpFmlaCompImpl::CreateTokenArray( ScfUInt8Vec* pExtensionTo // compiler ------------------------------------------------------------------- -const ScToken* XclExpFmlaCompImpl::GetNextRawToken() +const formula::FormulaToken* XclExpFmlaCompImpl::GetNextRawToken() { - const ScToken* pScToken = maTokArrIt.Get(); + const formula::FormulaToken* pScToken = maTokArrIt.Get(); ++maTokArrIt; return pScToken; } -const ScToken* XclExpFmlaCompImpl::PeekNextRawToken( bool bSkipSpaces ) const +const formula::FormulaToken* XclExpFmlaCompImpl::PeekNextRawToken( bool bSkipSpaces ) const { /* Returns pointer to next raw token in the token array. The token array iterator already points to the next token (A call to GetNextToken() @@ -1144,7 +1148,7 @@ XclExpTokenData XclExpFmlaCompImpl::Factor( XclExpTokenData aTokData, sal_uInt8 { if( !mbOk || !aTokData.Is() ) return XclExpTokenData(); - StackVar eTokType = aTokData.GetType(); + formula::StackVar eTokType = aTokData.GetType(); OpCode eOpCode = aTokData.GetOpCode(); if (eOpCode == ocExternalRef) @@ -1156,13 +1160,13 @@ XclExpTokenData XclExpFmlaCompImpl::Factor( XclExpTokenData aTokData, sal_uInt8 switch( eTokType ) { case svUnknown: mbOk = false; break; - case svDouble: ProcessDouble( aTokData ); break; - case svString: ProcessString( aTokData ); break; + case formula::svDouble: ProcessDouble( aTokData ); break; + case formula::svString: ProcessString( aTokData ); break; #if 0 // erAck - case svError: ProcessError( aTokData ); break; + case formula::svError: ProcessError( aTokData ); break; #endif case svSingleRef: ProcessCellRef( aTokData, nExpClass ); break; - case svDoubleRef: ProcessRangeRef( aTokData, nExpClass ); break; + case formula::svDoubleRef: ProcessRangeRef( aTokData, nExpClass ); break; case svMatrix: ProcessMatrix( aTokData, nExpClass ); break; case svExternal: ProcessExternal( aTokData, nExpClass ); break; @@ -1244,7 +1248,7 @@ namespace { inline bool lclGetTokenString( String& rString, const XclExpTokenData& rTokData ) { - bool bIsStr = (rTokData.GetType() == svString) && (rTokData.GetOpCode() == ocPush); + bool bIsStr = (rTokData.GetType() == formula::svString) && (rTokData.GetOpCode() == ocPush); if( bIsStr ) rString = rTokData.mpScToken->GetString(); return bIsStr; @@ -1280,7 +1284,7 @@ void XclExpFmlaCompImpl::ProcessExternal( const XclExpTokenData& rTokData, sal_u names and for external/invalid function calls. This function looks for the next token in the token array. If it is an opening parenthesis, the token is processed as external function call, otherwise as undefined name. */ - const ScToken* pNextScToken = PeekNextRawToken( true ); + const formula::FormulaToken* pNextScToken = PeekNextRawToken( true ); if( !pNextScToken || (pNextScToken->GetOpCode() != ocOpen) ) AppendMissingNameToken( rTokData.mpScToken->GetExternal(), nExpClass, rTokData.mnSpaces ); else @@ -1302,7 +1306,7 @@ void XclExpFmlaCompImpl::ProcessExternalName( const XclExpTokenData& rTokData, s AppendErrorToken(EXC_ERR_REF, rTokData.mnSpaces); break; } - SingleRefData aRef(rTokData.mpScToken->GetSingleRef()); + ScSingleRefData aRef(rTokData.mpScToken->GetSingleRef()); aRef.CalcAbsIfRel(*mpScBasePos); const String& rTabName = rTokData.mpScToken->GetString(); ScExternalRefCache::TokenRef p = pRefMgr->getSingleRefToken(nFileId, rTabName, ScAddress(aRef.nCol, aRef.nRow, aRef.nTab), NULL, NULL); @@ -1338,11 +1342,11 @@ void XclExpFmlaCompImpl::ProcessExternalName( const XclExpTokenData& rTokData, s AppendErrorToken(XclTools::GetXclErrorCode(errNoRef), rTokData.mnSpaces); break; } - ComplRefData aRef(rTokData.mpScToken->GetDoubleRef()); + ScComplexRefData aRef(rTokData.mpScToken->GetDoubleRef()); aRef.CalcAbsIfRel(*mpScBasePos); const String& rTabName = rTokData.mpScToken->GetString(); - const SingleRefData& r1 = aRef.Ref1; - const SingleRefData& r2 = aRef.Ref2; + const ScSingleRefData& r1 = aRef.Ref1; + const ScSingleRefData& r2 = aRef.Ref2; ScRange aRange(r1.nCol, r1.nRow, r1.nTab, r2.nCol, r2.nRow, r2.nTab); ScExternalRefCache::TokenArrayRef pArray = pRefMgr->getDoubleRefTokens(nFileId, rTabName, aRange, NULL); if (!pArray.get()) @@ -1388,13 +1392,13 @@ void XclExpFmlaCompImpl::ProcessExternalName( const XclExpTokenData& rTokData, s { if (p->GetType() == svExternalSingleRef) { - SingleRefData aData(p->GetSingleRef()); + ScSingleRefData aData(p->GetSingleRef()); aData.CalcAbsIfRel(*mpScBasePos); mpLinkMgr->StoreCell(nFileId, p->GetString(), aData); } else if (p->GetType() == svExternalDoubleRef) { - ComplRefData aData(p->GetDoubleRef()); + ScComplexRefData aData(p->GetDoubleRef()); aData.CalcAbsIfRel(*mpScBasePos); mpLinkMgr->StoreCellRange(nFileId, p->GetString(), aData); } @@ -1424,7 +1428,7 @@ void XclExpFmlaCompImpl::ProcessFunction( const XclExpTokenData& rTokData, sal_u // no exportable function found - try to create an external macro call if( !pFuncInfo && (eOpCode >= SC_OPCODE_START_NO_PAR) ) { - const String& rFuncName = ScCompiler::GetStringFromOpCode( eOpCode ); + const String& rFuncName = ScCompiler::GetNativeSymbol( eOpCode ); if( rFuncName.Len() ) { aExtFuncData.Set( rFuncName, true, false ); @@ -1912,7 +1916,7 @@ void XclExpFmlaCompImpl::ProcessCellRef( const XclExpTokenData& rTokData, sal_uI { // get the Excel address components, adjust internal data in aRefData bool bNatLangRef = (meBiff == EXC_BIFF8) && mpScBasePos && (rTokData.GetOpCode() == ocColRowName); - ScSingleRefData aRefData( rTokData.mpScToken->GetSingleRef() ); + ScSingleRefData aRefData( static_cast<const ScToken*>(rTokData.mpScToken)->GetSingleRef() ); XclAddress aXclPos( ScAddress::UNINITIALIZED ); ConvertRefData( aRefData, aXclPos, bNatLangRef, false, false ); @@ -1969,7 +1973,7 @@ void XclExpFmlaCompImpl::ProcessCellRef( const XclExpTokenData& rTokData, sal_uI void XclExpFmlaCompImpl::ProcessRangeRef( const XclExpTokenData& rTokData, sal_uInt8 nExpClass ) { // get the Excel address components, adjust internal data in aRefData - ScComplexRefData aRefData( rTokData.mpScToken->GetDoubleRef() ); + ScComplexRefData aRefData( static_cast<const ScToken*>(rTokData.mpScToken)->GetDoubleRef() ); XclRange aXclRange( ScAddress::UNINITIALIZED ); ConvertRefData( aRefData, aXclRange, false ); @@ -2527,7 +2531,7 @@ XclTokenArrayRef XclExpFormulaCompiler::CreateNameXFormula( void XclExpFmlaCompImpl::ProcessMatrix( const XclExpTokenData& rTokData, sal_uInt8 nExpClass ) { - const ScMatrix* pMatrix = rTokData.mpScToken->GetMatrix(); + const ScMatrix* pMatrix = static_cast<const ScToken*>(rTokData.mpScToken)->GetMatrix(); if( maCfg.mbAllowArrays && pMatrix ) { SCSIZE nCols, nRows; diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx index 9d1b7df3e741..fdcb2f1559bb 100644 --- a/sc/source/filter/excel/xelink.cxx +++ b/sc/source/filter/excel/xelink.cxx @@ -529,8 +529,8 @@ public: /** Derived classes store all cells in the given range in a CRN record list. */ virtual void StoreCellRange( const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 ) = 0; - virtual void StoreCell( sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef ) = 0; - virtual void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef1, const SingleRefData& rRef2 ) = 0; + virtual void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ) = 0; + virtual void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 ) = 0; /** Derived classes find or insert an EXTERNNAME record for an add-in function name. */ virtual bool InsertAddIn( @@ -577,8 +577,8 @@ public: virtual void StoreCellRange( const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 ); - virtual void StoreCell( sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef ); - virtual void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef1, const SingleRefData& rRef2 ); + virtual void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ); + virtual void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 ); virtual bool InsertAddIn( sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, @@ -647,8 +647,8 @@ public: virtual void StoreCellRange( const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 ); - virtual void StoreCell( sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef ); - virtual void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef1, const SingleRefData& rRef2 ); + virtual void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ); + virtual void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 ); virtual bool InsertAddIn( sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, @@ -1021,7 +1021,7 @@ void XclExpExtName::WriteAddData( XclExpStream& rStrm ) { case svExternalSingleRef: { - const SingleRefData& rRef = p->GetSingleRef(); + const ScSingleRefData& rRef = p->GetSingleRef(); if (rRef.IsTabRel()) break; @@ -1045,9 +1045,9 @@ void XclExpExtName::WriteAddData( XclExpStream& rStrm ) } case svExternalDoubleRef: { - const ComplRefData& rRef = p->GetDoubleRef(); - const SingleRefData& r1 = rRef.Ref1; - const SingleRefData& r2 = rRef.Ref2; + const ScComplexRefData& rRef = p->GetDoubleRef(); + const ScSingleRefData& r1 = rRef.Ref1; + const ScSingleRefData& r2 = rRef.Ref2; if (r1.IsTabRel() || r2.IsTabRel()) break; @@ -2047,12 +2047,12 @@ void XclExpLinkManagerImpl5::StoreCellRange( const ScSingleRefData& /*rRef1*/, c // not implemented } -void XclExpLinkManagerImpl5::StoreCell( sal_uInt16 /*nFileId*/, const String& /*rTabName*/, const SingleRefData& /*rRef*/ ) +void XclExpLinkManagerImpl5::StoreCell( sal_uInt16 /*nFileId*/, const String& /*rTabName*/, const ScSingleRefData& /*rRef*/ ) { // not implemented } -void XclExpLinkManagerImpl5::StoreCellRange( sal_uInt16 /*nFileId*/, const String& /*rTabName*/, const SingleRefData& /*rRef1*/, const SingleRefData& /*rRef2*/ ) +void XclExpLinkManagerImpl5::StoreCellRange( sal_uInt16 /*nFileId*/, const String& /*rTabName*/, const ScSingleRefData& /*rRef1*/, const ScSingleRefData& /*rRef2*/ ) { // not implemented } @@ -2245,13 +2245,13 @@ void XclExpLinkManagerImpl8::StoreCellRange( const ScSingleRefData& rRef1, const } } -void XclExpLinkManagerImpl8::StoreCell( sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef ) +void XclExpLinkManagerImpl8::StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ) { ScAddress aAddr(rRef.nCol, rRef.nRow, rRef.nTab); maSBBuffer.StoreCell(nFileId, rTabName, aAddr); } -void XclExpLinkManagerImpl8::StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef1, const SingleRefData& rRef2 ) +void XclExpLinkManagerImpl8::StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 ) { ScRange aRange(static_cast<SCCOL>(rRef1.nCol), static_cast<SCROW>(rRef1.nRow), static_cast<SCTAB>(rRef1.nTab), static_cast<SCCOL>(rRef2.nCol), static_cast<SCROW>(rRef2.nRow), static_cast<SCTAB>(rRef2.nTab)); @@ -2393,12 +2393,12 @@ void XclExpLinkManager::StoreCellRange( const ScComplexRefData& rRef ) mxImpl->StoreCellRange( rRef.Ref1, rRef.Ref2 ); } -void XclExpLinkManager::StoreCell( sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef ) +void XclExpLinkManager::StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ) { mxImpl->StoreCell( nFileId, rTabName, rRef ); } -void XclExpLinkManager::StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ComplRefData& rRef ) +void XclExpLinkManager::StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef ) { mxImpl->StoreCellRange( nFileId, rTabName, rRef.Ref1, rRef.Ref2 ); } diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index a46c0ccea121..b01c094f22ec 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -168,10 +168,10 @@ XclExpArrayRef XclExpArrayBuffer::FindArray( const ScTokenArray& rScTokArr ) con // try to extract a matrix reference token if( rScTokArr.GetLen() == 1 ) { - const ScToken* pToken = rScTokArr.GetArray()[ 0 ]; + const formula::FormulaToken* pToken = rScTokArr.GetArray()[ 0 ]; if( pToken && (pToken->GetOpCode() == ocMatRef) ) { - const ScSingleRefData& rRef = pToken->GetSingleRef(); + const ScSingleRefData& rRef = static_cast<const ScToken*>(pToken)->GetSingleRef(); ScAddress aBasePos( rRef.nCol, rRef.nRow, GetCurrScTab() ); XclExpArrayMap::const_iterator aIt = maRecMap.find( aBasePos ); if( aIt != maRecMap.end() ) @@ -2552,7 +2552,7 @@ void XclExpCellTable::Finalize() mxDefrowheight->SetDefaultData( aDefRowData ); } -XclExpRecordRef XclExpCellTable::CreateRecord( sal_uInt16 nRecId ) +XclExpRecordRef XclExpCellTable::CreateRecord( sal_uInt16 nRecId ) const { XclExpRecordRef xRec; switch( nRecId ) diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx index 85286469ba62..ef14839f9bda 100644 --- a/sc/source/filter/excel/xlformula.cxx +++ b/sc/source/filter/excel/xlformula.cxx @@ -30,13 +30,16 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" +#include "xlformula.hxx" #include "compiler.hxx" #include "rangenam.hxx" -#include "xestream.hxx" #include "xlroot.hxx" #include "xistream.hxx" -#include "xlformula.hxx" +#include "xestream.hxx" +#include "token.hxx" +#include "tokenarray.hxx" +using namespace formula; // Function data ============================================================== String XclFunctionInfo::GetMacroFuncName() const @@ -555,7 +558,7 @@ void XclTokenArrayIterator::Init() void XclTokenArrayIterator::Init( const ScTokenArray& rScTokArr, bool bSkipSpaces ) { USHORT nTokArrLen = rScTokArr.GetLen(); - mppScTokenBeg = static_cast< const ScToken*const* >( nTokArrLen ? rScTokArr.GetArray() : 0 ); + mppScTokenBeg = static_cast< const formula::FormulaToken*const* >( nTokArrLen ? rScTokArr.GetArray() : 0 ); mppScTokenEnd = mppScTokenBeg ? (mppScTokenBeg + nTokArrLen) : 0; mppScToken = (mppScTokenBeg != mppScTokenEnd) ? mppScTokenBeg : 0; mbSkipSpaces = bSkipSpaces; @@ -585,9 +588,9 @@ void XclTokenArrayIterator::SkipSpaces() // strings and string lists --------------------------------------------------- -bool XclTokenArrayHelper::GetTokenString( String& rString, const ScToken& rScToken ) +bool XclTokenArrayHelper::GetTokenString( String& rString, const formula::FormulaToken& rScToken ) { - bool bIsStr = (rScToken.GetType() == svString) && (rScToken.GetOpCode() == ocPush); + bool bIsStr = (rScToken.GetType() == formula::svString) && (rScToken.GetOpCode() == ocPush); if( bIsStr ) rString = rScToken.GetString(); return bIsStr; } @@ -650,7 +653,7 @@ void XclTokenArrayHelper::ConvertStringToList( ScTokenArray& rScTokArr, sal_Unic const ScTokenArray* XclTokenArrayHelper::GetSharedFormula( const XclRoot& rRoot, const ScTokenArray& rScTokArr ) { if( rScTokArr.GetLen() == 1 ) - if( const ScToken* pScToken = rScTokArr.GetArray()[ 0 ] ) + if( const formula::FormulaToken* pScToken = rScTokArr.GetArray()[ 0 ] ) if( pScToken->GetOpCode() == ocName ) if( ScRangeData* pData = rRoot.GetNamedRanges().FindIndex( pScToken->GetIndex() ) ) if( pData->HasType( RT_SHARED ) ) @@ -662,13 +665,13 @@ const ScTokenArray* XclTokenArrayHelper::GetSharedFormula( const XclRoot& rRoot, namespace { -inline bool lclGetAddress( ScAddress& rAddress, const ScToken& rToken ) +inline bool lclGetAddress( ScAddress& rAddress, const formula::FormulaToken& rToken ) { OpCode eOpCode = rToken.GetOpCode(); bool bIsSingleRef = (eOpCode == ocPush) && (rToken.GetType() == svSingleRef); if( bIsSingleRef ) { - const ScSingleRefData& rRef = rToken.GetSingleRef(); + const ScSingleRefData& rRef = static_cast<const ScToken&>(rToken).GetSingleRef(); rAddress.Set( rRef.nCol, rRef.nRow, rRef.nTab ); bIsSingleRef = !rRef.IsDeleted(); } diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx index a80900f0c986..ef38a0037ca0 100644 --- a/sc/source/filter/excel/xltools.cxx +++ b/sc/source/filter/excel/xltools.cxx @@ -41,7 +41,7 @@ #include "document.hxx" #include "docuno.hxx" #include "editutil.hxx" -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" #include "globstr.hrc" #include "xlstyle.hxx" #include "xlname.hxx" diff --git a/sc/source/filter/html/htmlimp.cxx b/sc/source/filter/html/htmlimp.cxx index 9b3a155db0e1..36491a4a12c7 100644 --- a/sc/source/filter/html/htmlimp.cxx +++ b/sc/source/filter/html/htmlimp.cxx @@ -57,6 +57,7 @@ #include "rangenam.hxx" #include "attrib.hxx" #include "ftools.hxx" +#include "tokenarray.hxx" //------------------------------------------------------------------------ diff --git a/sc/source/filter/inc/filt_pch.hxx b/sc/source/filter/inc/filt_pch.hxx index cdf273dca1c3..4f576c861272 100644 --- a/sc/source/filter/inc/filt_pch.hxx +++ b/sc/source/filter/inc/filt_pch.hxx @@ -1,324 +1,324 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: filt_pch.hxx,v $ - * $Revision: 1.13 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// ItemID-Defines etc. muessen immer ganz vorne stehen - -#include "scitems.hxx" - - -#define _ZFORLIST_DECLARE_TABLE - -#define SC_PROGRESS_CXX - -// ab hier automatisch per makepch generiert -// folgende duerfen nicht aufgenommen werden: -// ... - -#include <tools/solar.h> -#include <tools/string.hxx> -#include <rtl/textenc.h> -#include <sal/types.h> -#include <sal/config.h> -#include <rtl/textcvt.h> -#include <rtl/string.hxx> -#include <rtl/string.h> -#include <rtl/ustring.h> -#include <rtl/memory.h> -#include <rtl/ustring.hxx> -#include <rtl/locale.hxx> -#include <rtl/locale.h> -#include <tools/contnr.hxx> -#include <i18npool/lang.h> -#include <tools/list.hxx> -#include <global.hxx> -#include <tools/stream.hxx> -#include <tools/errinf.hxx> -#include <tools/rtti.hxx> -#include <tools/errcode.hxx> -#include <tools/ref.hxx> -#include <tools/link.hxx> -#include <tools/debug.hxx> -#include <tools/time.hxx> -#include <tools/date.hxx> -#include <svtools/svarray.hxx> -#include <vcl/sv.h> -#include <vcl/timer.hxx> -#include <tools/gen.hxx> -#include <tools/color.hxx> -#include <tools/color.hxx> -#include <filter.hxx> -#include <rangelst.hxx> -#include <osl/mutex.h> -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/uno/Any.h> -#include <cppu/macros.hxx> -#include <uno/lbnames.h> -#include <uno/any2.h> -#include <uno/data.h> -#include <typelib/typedescription.h> -#include <typelib/uik.h> -#include <typelib/typeclass.h> -#include <com/sun/star/uno/Type.h> -#include <com/sun/star/uno/TypeClass.hdl> -#include <com/sun/star/uno/Type.hxx> -#include <osl/mutex.hxx> -#include <com/sun/star/uno/genfunc.hxx> -#include <com/sun/star/uno/genfunc.h> -#include <com/sun/star/uno/XInterface.hpp> -#include <com/sun/star/uno/XInterface.hdl> -#include <com/sun/star/uno/Reference.h> -#include <com/sun/star/uno/RuntimeException.hdl> -#include <com/sun/star/uno/Exception.hdl> -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/uno/RuntimeException.hpp> -#include <com/sun/star/uno/Exception.hpp> -#include <svtools/hint.hxx> -#include <svtools/poolitem.hxx> -#include <document.hxx> -#include <vcl/prntypes.hxx> -#include <table.hxx> -#include <column.hxx> -#include <markarr.hxx> -#include <root.hxx> -#include <flttypes.hxx> -#include <svtools/solar.hrc> -#include <sfx2/sfxsids.hrc> -#include <svtools/cntwids.hrc> -#include <sfx2/cntids.hrc> -#include <tools/mempool.hxx> -#include <compiler.hxx> -#include <compiler.hrc> -#include <sfx2/sfx.hrc> -#include <scitems.hxx> -#include <svx/svxids.hrc> -#include <svtools/itemset.hxx> -#include <svtools/memberid.hrc> -#include <tools/table.hxx> -#include <flttools.hxx> -#include <vcl/vclenum.hxx> -#include <tools/resid.hxx> -#include <tools/rc.hxx> -#include <tools/resmgr.hxx> -#include <tools/fract.hxx> -#include <vcl/bitmap.hxx> -#include <vcl/mapmod.hxx> -#include <vcl/mapunit.hxx> -#include <vcl/region.hxx> -#include <svtools/lstner.hxx> -#include <patattr.hxx> -#include <vcl/font.hxx> -#include <svtools/cenumitm.hxx> -#include <svtools/eitem.hxx> -#include <svtools/intitem.hxx> -#include <svtools/cintitem.hxx> -#include <svtools/brdcst.hxx> -#include <sot/sotref.hxx> -#include <tools/globname.hxx> -#include <sot/factory.hxx> -#include <sot/object.hxx> -#include <sot/sotdata.hxx> -#include <vcl/bitmapex.hxx> -#include <vcl/alpha.hxx> -#include <vcl/gdimtf.hxx> -#include <tools/unqidx.hxx> -#include <vcl/graph.hxx> -#include <vcl/animate.hxx> -#include <vcl/graph.h> -#include <vcl/gfxlink.hxx> -#include <rsc/rscsfx.hxx> -#include <vcl/wall.hxx> -#include <vcl/settings.hxx> -#include <vcl/accel.hxx> -#include <vcl/keycod.hxx> -#include <vcl/keycodes.hxx> -#include <namebuff.hxx> -#include <tools/shl.hxx> -#include <tools/pstm.hxx> -#include <svx/fhgtitem.hxx> -#include <vos/types.hxx> -#include <vos/object.hxx> -#include <vos/macros.hxx> -#include <tools/unqid.hxx> -#include <com/sun/star/uno/Sequence.h> -#include <uno/sequence2.h> -#include <com/sun/star/uno/Sequence.hxx> -#include <attrib.hxx> -#include <svtools/zforlist.hxx> -#include <svx/fontitem.hxx> -#include <com/sun/star/lang/XEventListener.hpp> -#include <com/sun/star/lang/XEventListener.hdl> -#include <com/sun/star/lang/EventObject.hdl> -#include <com/sun/star/lang/EventObject.hpp> -#include <vcl/outdev.hxx> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/beans/PropertyValue.hdl> -#include <com/sun/star/beans/PropertyState.hdl> -#include <com/sun/star/beans/PropertyState.hpp> -#include <collect.hxx> -#include <vcl/window.hxx> -#include <vcl/pointr.hxx> -#include <vcl/ptrstyle.hxx> -#include <vcl/wintypes.hxx> -#include <vcl/inputctx.hxx> -#include <vcl/event.hxx> -#include <tools/ownlist.hxx> -#include <vcl/cmdevt.hxx> -#include <vcl/vclenum.hxx> -#include <cell.hxx> -#include <osl/interlck.h> -#include <sfx2/sfxuno.hxx> -#include <colrowst.hxx> -#include <com/sun/star/util/URL.hpp> -#include <com/sun/star/util/URL.hdl> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hdl> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hdl> -#include <com/sun/star/lang/XTypeProvider.hpp> -#include <com/sun/star/lang/XTypeProvider.hdl> -#include <cppuhelper/typeprovider.hxx> -#include <rtl/uuid.h> -#include <cppuhelper/queryinterface.hxx> -#include <cppuhelper/factory.hxx> -#include <uno/dispatcher.h> -#include <com/sun/star/registry/XRegistryKey.hpp> -#include <com/sun/star/registry/XRegistryKey.hdl> -#include <com/sun/star/registry/InvalidRegistryException.hdl> -#include <com/sun/star/registry/InvalidValueException.hdl> -#include <com/sun/star/registry/RegistryKeyType.hdl> -#include <com/sun/star/registry/RegistryValueType.hdl> -#include <com/sun/star/registry/InvalidRegistryException.hpp> -#include <com/sun/star/registry/InvalidValueException.hpp> -#include <com/sun/star/registry/RegistryKeyType.hpp> -#include <com/sun/star/registry/RegistryValueType.hpp> -#include <sot/storage.hxx> -#include <tools/datetime.hxx> -#include <osl/thread.h> -#include <imp_op.hxx> -#include <otlnbuff.hxx> -#include <tokstack.hxx> -#include <com/sun/star/container/NoSuchElementException.hdl> -#include <com/sun/star/container/NoSuchElementException.hpp> -#include <vcl/svapp.hxx> -#include <vos/thread.hxx> -#include <vos/runnable.hxx> -#include <vos/refernce.hxx> -#include <vcl/apptypes.hxx> -#include <svx/editdata.hxx> -#include <svx/editeng.hxx> -#include <com/sun/star/lang/WrappedTargetException.hdl> -#include <com/sun/star/lang/WrappedTargetException.hpp> -#include <sfx2/shell.hxx> -#include <tools/stack.hxx> -#include <com/sun/star/lang/XComponent.hpp> -#include <com/sun/star/lang/XComponent.hdl> -#include <svx/svxenum.hxx> -#include <formel.hxx> -#include <com/sun/star/container/XElementAccess.hdl> -#include <com/sun/star/container/XElementAccess.hpp> -#include <svtools/itempool.hxx> -#include <svx/eeitem.hxx> -#include <rangenam.hxx> -#include <vcl/syswin.hxx> -#include <svtools/smplhint.hxx> -#include <fontbuff.hxx> -#include <vcl/ctrl.hxx> -#include <vcl/field.hxx> -#include <vcl/spinfld.hxx> -#include <vcl/edit.hxx> -#include <vcl/menu.hxx> -#include <vcl/combobox.hxx> -#include <vcl/combobox.h> -#include <vcl/fldunit.hxx> -#include <com/sun/star/frame/XFrame.hpp> -#include <com/sun/star/frame/XFrame.hdl> -#include <com/sun/star/awt/XWindow.hpp> -#include <com/sun/star/awt/XWindow.hdl> -#include <com/sun/star/awt/Rectangle.hdl> -#include <com/sun/star/awt/Rectangle.hpp> -#include <com/sun/star/awt/XFocusListener.hpp> -#include <com/sun/star/awt/XFocusListener.hdl> -#include <com/sun/star/awt/FocusEvent.hdl> -#include <com/sun/star/awt/FocusEvent.hpp> -#include <com/sun/star/awt/XKeyListener.hpp> -#include <com/sun/star/awt/XKeyListener.hdl> -#include <com/sun/star/awt/KeyEvent.hdl> -#include <com/sun/star/awt/InputEvent.hdl> -#include <com/sun/star/awt/KeyEvent.hpp> -#include <com/sun/star/awt/InputEvent.hpp> -#include <com/sun/star/awt/XMouseListener.hpp> -#include <com/sun/star/awt/XMouseListener.hdl> -#include <com/sun/star/awt/MouseEvent.hdl> -#include <com/sun/star/awt/MouseEvent.hpp> -#include <com/sun/star/awt/XMouseMotionListener.hpp> -#include <com/sun/star/awt/XMouseMotionListener.hdl> -#include <com/sun/star/awt/XPaintListener.hpp> -#include <com/sun/star/awt/XPaintListener.hdl> -#include <com/sun/star/awt/PaintEvent.hdl> -#include <com/sun/star/awt/PaintEvent.hpp> -#include <com/sun/star/awt/XWindowListener.hpp> -#include <com/sun/star/awt/XWindowListener.hdl> -#include <com/sun/star/awt/WindowEvent.hdl> -#include <com/sun/star/awt/WindowEvent.hpp> -#include <com/sun/star/frame/XController.hpp> -#include <com/sun/star/frame/XController.hdl> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/frame/XModel.hdl> -#include <com/sun/star/lang/IndexOutOfBoundsException.hdl> -#include <com/sun/star/lang/IndexOutOfBoundsException.hpp> -#include <com/sun/star/container/XIndexAccess.hdl> -#include <com/sun/star/container/XIndexAccess.hpp> -#include <excrecds.hxx> -#include <scerrors.hxx> -#include <docpool.hxx> -#include <svx/msdffimp.hxx> -#include <com/sun/star/lang/IllegalArgumentException.hdl> -#include <com/sun/star/lang/IllegalArgumentException.hpp> -#include <tools/urlobj.hxx> -#include <svx/colritem.hxx> -#include <vcl/wrkwin.hxx> -#include <excimp8.hxx> -#include <excscen.hxx> -#include <com/sun/star/frame/XFrameActionListener.hpp> -#include <com/sun/star/frame/XFrameActionListener.hdl> -#include <com/sun/star/frame/FrameActionEvent.hdl> -#include <com/sun/star/frame/FrameAction.hdl> -#include <com/sun/star/frame/FrameActionEvent.hpp> -#include <com/sun/star/frame/FrameAction.hpp> -#include <com/sun/star/frame/XFramesSupplier.hpp> -#include <com/sun/star/frame/XFramesSupplier.hdl> -#include <com/sun/star/frame/XFrames.hpp> -#include <com/sun/star/frame/XFrames.hdl> -#include <svx/msdffdef.hxx> -#include <vcl/image.hxx> - - - - +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: filt_pch.hxx,v $
+ * $Revision: 1.13 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// ItemID-Defines etc. muessen immer ganz vorne stehen
+
+#include "scitems.hxx"
+
+
+#define _ZFORLIST_DECLARE_TABLE
+
+#define SC_PROGRESS_CXX
+
+// ab hier automatisch per makepch generiert
+// folgende duerfen nicht aufgenommen werden:
+// ...
+
+#include <tools/solar.h>
+#include <tools/string.hxx>
+#include <rtl/textenc.h>
+#include <sal/types.h>
+#include <sal/config.h>
+#include <rtl/textcvt.h>
+#include <rtl/string.hxx>
+#include <rtl/string.h>
+#include <rtl/ustring.h>
+#include <rtl/memory.h>
+#include <rtl/ustring.hxx>
+#include <rtl/locale.hxx>
+#include <rtl/locale.h>
+#include <tools/contnr.hxx>
+#include <i18npool/lang.h>
+#include <tools/list.hxx>
+#include <global.hxx>
+#include <tools/stream.hxx>
+#include <tools/errinf.hxx>
+#include <tools/rtti.hxx>
+#include <tools/errcode.hxx>
+#include <tools/ref.hxx>
+#include <tools/link.hxx>
+#include <tools/debug.hxx>
+#include <tools/time.hxx>
+#include <tools/date.hxx>
+#include <svtools/svarray.hxx>
+#include <vcl/sv.h>
+#include <vcl/timer.hxx>
+#include <tools/gen.hxx>
+#include <tools/color.hxx>
+#include <tools/color.hxx>
+#include <filter.hxx>
+#include <rangelst.hxx>
+#include <osl/mutex.h>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Any.h>
+#include <cppu/macros.hxx>
+#include <uno/lbnames.h>
+#include <uno/any2.h>
+#include <uno/data.h>
+#include <typelib/typedescription.h>
+#include <typelib/uik.h>
+#include <typelib/typeclass.h>
+#include <com/sun/star/uno/Type.h>
+#include <com/sun/star/uno/TypeClass.hdl>
+#include <com/sun/star/uno/Type.hxx>
+#include <osl/mutex.hxx>
+#include <com/sun/star/uno/genfunc.hxx>
+#include <com/sun/star/uno/genfunc.h>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/XInterface.hdl>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/RuntimeException.hdl>
+#include <com/sun/star/uno/Exception.hdl>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Exception.hpp>
+#include <svtools/hint.hxx>
+#include <svtools/poolitem.hxx>
+#include <document.hxx>
+#include <vcl/prntypes.hxx>
+#include <table.hxx>
+#include <column.hxx>
+#include <markarr.hxx>
+#include <root.hxx>
+#include <flttypes.hxx>
+#include <svtools/solar.hrc>
+#include <sfx2/sfxsids.hrc>
+#include <svtools/cntwids.hrc>
+#include <sfx2/cntids.hrc>
+#include <tools/mempool.hxx>
+#include <compiler.hxx>
+#include <formula/compiler.hrc>
+#include <sfx2/sfx.hrc>
+#include <scitems.hxx>
+#include <svx/svxids.hrc>
+#include <svtools/itemset.hxx>
+#include <svtools/memberid.hrc>
+#include <tools/table.hxx>
+#include <flttools.hxx>
+#include <vcl/vclenum.hxx>
+#include <tools/resid.hxx>
+#include <tools/rc.hxx>
+#include <tools/resmgr.hxx>
+#include <tools/fract.hxx>
+#include <vcl/bitmap.hxx>
+#include <vcl/mapmod.hxx>
+#include <vcl/mapunit.hxx>
+#include <vcl/region.hxx>
+#include <svtools/lstner.hxx>
+#include <patattr.hxx>
+#include <vcl/font.hxx>
+#include <svtools/cenumitm.hxx>
+#include <svtools/eitem.hxx>
+#include <svtools/intitem.hxx>
+#include <svtools/cintitem.hxx>
+#include <svtools/brdcst.hxx>
+#include <sot/sotref.hxx>
+#include <tools/globname.hxx>
+#include <sot/factory.hxx>
+#include <sot/object.hxx>
+#include <sot/sotdata.hxx>
+#include <vcl/bitmapex.hxx>
+#include <vcl/alpha.hxx>
+#include <vcl/gdimtf.hxx>
+#include <tools/unqidx.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/animate.hxx>
+#include <vcl/graph.h>
+#include <vcl/gfxlink.hxx>
+#include <rsc/rscsfx.hxx>
+#include <vcl/wall.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/accel.hxx>
+#include <vcl/keycod.hxx>
+#include <vcl/keycodes.hxx>
+#include <namebuff.hxx>
+#include <tools/shl.hxx>
+#include <tools/pstm.hxx>
+#include <svx/fhgtitem.hxx>
+#include <vos/types.hxx>
+#include <vos/object.hxx>
+#include <vos/macros.hxx>
+#include <tools/unqid.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include <uno/sequence2.h>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <attrib.hxx>
+#include <svtools/zforlist.hxx>
+#include <svx/fontitem.hxx>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/XEventListener.hdl>
+#include <com/sun/star/lang/EventObject.hdl>
+#include <com/sun/star/lang/EventObject.hpp>
+#include <vcl/outdev.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/PropertyValue.hdl>
+#include <com/sun/star/beans/PropertyState.hdl>
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <collect.hxx>
+#include <vcl/window.hxx>
+#include <vcl/pointr.hxx>
+#include <vcl/ptrstyle.hxx>
+#include <vcl/wintypes.hxx>
+#include <vcl/inputctx.hxx>
+#include <vcl/event.hxx>
+#include <tools/ownlist.hxx>
+#include <vcl/cmdevt.hxx>
+#include <vcl/vclenum.hxx>
+#include <cell.hxx>
+#include <osl/interlck.h>
+#include <sfx2/sfxuno.hxx>
+#include <colrowst.hxx>
+#include <com/sun/star/util/URL.hpp>
+#include <com/sun/star/util/URL.hdl>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hdl>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hdl>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XTypeProvider.hdl>
+#include <cppuhelper/typeprovider.hxx>
+#include <rtl/uuid.h>
+#include <cppuhelper/queryinterface.hxx>
+#include <cppuhelper/factory.hxx>
+#include <uno/dispatcher.h>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/registry/XRegistryKey.hdl>
+#include <com/sun/star/registry/InvalidRegistryException.hdl>
+#include <com/sun/star/registry/InvalidValueException.hdl>
+#include <com/sun/star/registry/RegistryKeyType.hdl>
+#include <com/sun/star/registry/RegistryValueType.hdl>
+#include <com/sun/star/registry/InvalidRegistryException.hpp>
+#include <com/sun/star/registry/InvalidValueException.hpp>
+#include <com/sun/star/registry/RegistryKeyType.hpp>
+#include <com/sun/star/registry/RegistryValueType.hpp>
+#include <sot/storage.hxx>
+#include <tools/datetime.hxx>
+#include <osl/thread.h>
+#include <imp_op.hxx>
+#include <otlnbuff.hxx>
+#include <tokstack.hxx>
+#include <com/sun/star/container/NoSuchElementException.hdl>
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <vcl/svapp.hxx>
+#include <vos/thread.hxx>
+#include <vos/runnable.hxx>
+#include <vos/refernce.hxx>
+#include <vcl/apptypes.hxx>
+#include <svx/editdata.hxx>
+#include <svx/editeng.hxx>
+#include <com/sun/star/lang/WrappedTargetException.hdl>
+#include <com/sun/star/lang/WrappedTargetException.hpp>
+#include <sfx2/shell.hxx>
+#include <tools/stack.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XComponent.hdl>
+#include <svx/svxenum.hxx>
+#include <formel.hxx>
+#include <com/sun/star/container/XElementAccess.hdl>
+#include <com/sun/star/container/XElementAccess.hpp>
+#include <svtools/itempool.hxx>
+#include <svx/eeitem.hxx>
+#include <rangenam.hxx>
+#include <vcl/syswin.hxx>
+#include <svtools/smplhint.hxx>
+#include <fontbuff.hxx>
+#include <vcl/ctrl.hxx>
+#include <vcl/field.hxx>
+#include <vcl/spinfld.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/combobox.h>
+#include <vcl/fldunit.hxx>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XFrame.hdl>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/XWindow.hdl>
+#include <com/sun/star/awt/Rectangle.hdl>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/awt/XFocusListener.hdl>
+#include <com/sun/star/awt/FocusEvent.hdl>
+#include <com/sun/star/awt/FocusEvent.hpp>
+#include <com/sun/star/awt/XKeyListener.hpp>
+#include <com/sun/star/awt/XKeyListener.hdl>
+#include <com/sun/star/awt/KeyEvent.hdl>
+#include <com/sun/star/awt/InputEvent.hdl>
+#include <com/sun/star/awt/KeyEvent.hpp>
+#include <com/sun/star/awt/InputEvent.hpp>
+#include <com/sun/star/awt/XMouseListener.hpp>
+#include <com/sun/star/awt/XMouseListener.hdl>
+#include <com/sun/star/awt/MouseEvent.hdl>
+#include <com/sun/star/awt/MouseEvent.hpp>
+#include <com/sun/star/awt/XMouseMotionListener.hpp>
+#include <com/sun/star/awt/XMouseMotionListener.hdl>
+#include <com/sun/star/awt/XPaintListener.hpp>
+#include <com/sun/star/awt/XPaintListener.hdl>
+#include <com/sun/star/awt/PaintEvent.hdl>
+#include <com/sun/star/awt/PaintEvent.hpp>
+#include <com/sun/star/awt/XWindowListener.hpp>
+#include <com/sun/star/awt/XWindowListener.hdl>
+#include <com/sun/star/awt/WindowEvent.hdl>
+#include <com/sun/star/awt/WindowEvent.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XController.hdl>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XModel.hdl>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hdl>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/container/XIndexAccess.hdl>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <excrecds.hxx>
+#include <scerrors.hxx>
+#include <docpool.hxx>
+#include <svx/msdffimp.hxx>
+#include <com/sun/star/lang/IllegalArgumentException.hdl>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <tools/urlobj.hxx>
+#include <svx/colritem.hxx>
+#include <vcl/wrkwin.hxx>
+#include <excimp8.hxx>
+#include <excscen.hxx>
+#include <com/sun/star/frame/XFrameActionListener.hpp>
+#include <com/sun/star/frame/XFrameActionListener.hdl>
+#include <com/sun/star/frame/FrameActionEvent.hdl>
+#include <com/sun/star/frame/FrameAction.hdl>
+#include <com/sun/star/frame/FrameActionEvent.hpp>
+#include <com/sun/star/frame/FrameAction.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hdl>
+#include <com/sun/star/frame/XFrames.hpp>
+#include <com/sun/star/frame/XFrames.hdl>
+#include <svx/msdffdef.hxx>
+#include <vcl/image.hxx>
+
+
+
+
diff --git a/sc/source/filter/inc/tokstack.hxx b/sc/source/filter/inc/tokstack.hxx index ecf1028f39ed..9627f2457a67 100644 --- a/sc/source/filter/inc/tokstack.hxx +++ b/sc/source/filter/inc/tokstack.hxx @@ -34,10 +34,10 @@ #include <string.h> #include <tools/debug.hxx> #include "compiler.hxx" +#include "tokenarray.hxx" #include <vector> - typedef OpCode DefTokenId; // in PRODUCT version: ambiguity between OpCode (being USHORT) and UINT16 // Unfortunately a typedef is just a dumb alias and not a real type ... @@ -152,7 +152,7 @@ class TokenPool { sal_uInt16 mnFileId; String maTabName; - SingleRefData maRef; + ScSingleRefData maRef; }; ::std::vector<ExtCellRef> maExtCellRefs; @@ -161,7 +161,7 @@ class TokenPool { sal_uInt16 mnFileId; String maTabName; - ComplRefData maRef; + ScComplexRefData maRef; }; ::std::vector<ExtAreaRef> maExtAreaRefs; @@ -212,8 +212,8 @@ class TokenPool const TokenId StoreNlf( const ScSingleRefData& rTr ); const TokenId StoreMatrix( SCSIZE nC, SCSIZE nR ); const TokenId StoreExtName( sal_uInt16 nFileId, const String& rName ); - const TokenId StoreExtRef( sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef ); - const TokenId StoreExtRef( sal_uInt16 nFileId, const String& rTabName, const ComplRefData& rRef ); + const TokenId StoreExtRef( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ); + const TokenId StoreExtRef( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef ); inline const TokenId LastId( void ) const; inline const ScTokenArray* operator []( const TokenId nId ); diff --git a/sc/source/filter/inc/xelink.hxx b/sc/source/filter/inc/xelink.hxx index b478ad150877..3a016759275e 100644 --- a/sc/source/filter/inc/xelink.hxx +++ b/sc/source/filter/inc/xelink.hxx @@ -183,9 +183,9 @@ public: /** Stores all cells in the given range in a CRN record list. */ void StoreCellRange( const ScComplexRefData& rRef ); - void StoreCell( sal_uInt16 nFileId, const String& rTabName, const SingleRefData& rRef ); + void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ); - void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ComplRefData& rRef ); + void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef ); /** Finds or inserts an EXTERNNAME record for an add-in function name. @param rnExtSheet (out-param) Returns the index of the EXTSHEET structure for the add-in function name. diff --git a/sc/source/filter/inc/xlformula.hxx b/sc/source/filter/inc/xlformula.hxx index 684222e7e037..0c3496bdee30 100644 --- a/sc/source/filter/inc/xlformula.hxx +++ b/sc/source/filter/inc/xlformula.hxx @@ -1,474 +1,477 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: xlformula.hxx,v $ - * $Revision: 1.14 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SC_XLFORMULA_HXX -#define SC_XLFORMULA_HXX - -#include <map> -#include "address.hxx" -#include "opcode.hxx" -#include "ftools.hxx" - -// Constants ================================================================== - -const size_t EXC_TOKARR_MAXLEN = 4096; /// Maximum size of a token array. - -// Token class flags ---------------------------------------------------------- - -const sal_uInt8 EXC_TOKCLASS_MASK = 0x60; -const sal_uInt8 EXC_TOKCLASS_INOP_FLAG = 0x80; /// Used in operators (internal flag). - -const sal_uInt8 EXC_TOKCLASS_NONE = 0x00; /// 00-1F: Base tokens. -const sal_uInt8 EXC_TOKCLASS_REF = 0x20; /// 20-3F: Reference class tokens. -const sal_uInt8 EXC_TOKCLASS_VAL = 0x40; /// 40-5F: Value class tokens. -const sal_uInt8 EXC_TOKCLASS_ARR = 0x60; /// 60-7F: Array class tokens. - -const sal_uInt8 EXC_TOKCLASS_ANY_IN_REFOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_NONE; -const sal_uInt8 EXC_TOKCLASS_REF_IN_VALOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_REF; -const sal_uInt8 EXC_TOKCLASS_VAL_IN_VALOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_VAL; -const sal_uInt8 EXC_TOKCLASS_ARR_IN_VALOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_ARR; - -// Base tokens ---------------------------------------------------------------- - -const sal_uInt8 EXC_TOKID_MASK = 0x1F; - -const sal_uInt8 EXC_TOKID_NONE = 0x00; /// Placeholder for invalid token id. -const sal_uInt8 EXC_TOKID_EXP = 0x01; /// Array or shared formula reference. -const sal_uInt8 EXC_TOKID_TBL = 0x02; /// Multiple operation reference. -const sal_uInt8 EXC_TOKID_ADD = 0x03; /// Addition operator. -const sal_uInt8 EXC_TOKID_SUB = 0x04; /// Subtraction operator. -const sal_uInt8 EXC_TOKID_MUL = 0x05; /// Multiplication operator. -const sal_uInt8 EXC_TOKID_DIV = 0x06; /// Division operator. -const sal_uInt8 EXC_TOKID_POWER = 0x07; /// Power operator. -const sal_uInt8 EXC_TOKID_CONCAT = 0x08; /// String concatenation operator. -const sal_uInt8 EXC_TOKID_LT = 0x09; /// Less than operator. -const sal_uInt8 EXC_TOKID_LE = 0x0A; /// Less than or equal operator. -const sal_uInt8 EXC_TOKID_EQ = 0x0B; /// Equal operator. -const sal_uInt8 EXC_TOKID_GE = 0x0C; /// Greater than or equal operator. -const sal_uInt8 EXC_TOKID_GT = 0x0D; /// Greater than operator. -const sal_uInt8 EXC_TOKID_NE = 0x0E; /// Not equal operator. -const sal_uInt8 EXC_TOKID_ISECT = 0x0F; /// Intersection operator. -const sal_uInt8 EXC_TOKID_LIST = 0x10; /// List operator. -const sal_uInt8 EXC_TOKID_RANGE = 0x11; /// Range operator. -const sal_uInt8 EXC_TOKID_UPLUS = 0x12; /// Unary plus. -const sal_uInt8 EXC_TOKID_UMINUS = 0x13; /// Unary minus. -const sal_uInt8 EXC_TOKID_PERCENT = 0x14; /// Percent sign. -const sal_uInt8 EXC_TOKID_PAREN = 0x15; /// Parentheses. -const sal_uInt8 EXC_TOKID_MISSARG = 0x16; /// Missing argument. -const sal_uInt8 EXC_TOKID_STR = 0x17; /// String constant. -const sal_uInt8 EXC_TOKID_NLR = 0x18; /// Natural language reference (NLR). -const sal_uInt8 EXC_TOKID_ATTR = 0x19; /// Special attribute. -const sal_uInt8 EXC_TOKID_SHEET = 0x1A; /// Start of a sheet reference (BIFF2-BIFF4). -const sal_uInt8 EXC_TOKID_ENDSHEET = 0x1B; /// End of a sheet reference (BIFF2-BIFF4). -const sal_uInt8 EXC_TOKID_ERR = 0x1C; /// Error constant. -const sal_uInt8 EXC_TOKID_BOOL = 0x1D; /// Boolean constant. -const sal_uInt8 EXC_TOKID_INT = 0x1E; /// Integer constant. -const sal_uInt8 EXC_TOKID_NUM = 0x1F; /// Floating-point constant. - -// Base IDs of classified tokens ---------------------------------------------- - -const sal_uInt8 EXC_TOKID_ARRAY = 0x00; /// Array constant. -const sal_uInt8 EXC_TOKID_FUNC = 0x01; /// Function, fixed number of arguments. -const sal_uInt8 EXC_TOKID_FUNCVAR = 0x02; /// Function, variable number of arguments. -const sal_uInt8 EXC_TOKID_NAME = 0x03; /// Defined name. -const sal_uInt8 EXC_TOKID_REF = 0x04; /// 2D cell reference. -const sal_uInt8 EXC_TOKID_AREA = 0x05; /// 2D area reference. -const sal_uInt8 EXC_TOKID_MEMAREA = 0x06; /// Constant reference subexpression. -const sal_uInt8 EXC_TOKID_MEMERR = 0x07; /// Deleted reference subexpression. -const sal_uInt8 EXC_TOKID_MEMNOMEM = 0x08; /// Constant reference subexpression without result. -const sal_uInt8 EXC_TOKID_MEMFUNC = 0x09; /// Variable reference subexpression. -const sal_uInt8 EXC_TOKID_REFERR = 0x0A; /// Deleted 2D cell reference. -const sal_uInt8 EXC_TOKID_AREAERR = 0x0B; /// Deleted 2D area reference. -const sal_uInt8 EXC_TOKID_REFN = 0x0C; /// Relative 2D cell reference (in names). -const sal_uInt8 EXC_TOKID_AREAN = 0x0D; /// Relative 2D area reference (in names). -const sal_uInt8 EXC_TOKID_MEMAREAN = 0x0E; /// Reference subexpression (in names). -const sal_uInt8 EXC_TOKID_MEMNOMEMN = 0x0F; /// Reference subexpression (in names) without result. -const sal_uInt8 EXC_TOKID_FUNCCE = 0x18; -const sal_uInt8 EXC_TOKID_NAMEX = 0x19; /// External reference. -const sal_uInt8 EXC_TOKID_REF3D = 0x1A; /// 3D cell reference. -const sal_uInt8 EXC_TOKID_AREA3D = 0x1B; /// 3D area reference. -const sal_uInt8 EXC_TOKID_REFERR3D = 0x1C; /// Deleted 3D cell reference. -const sal_uInt8 EXC_TOKID_AREAERR3D = 0x1D; /// Deleted 3D area reference - -// specific token constants --------------------------------------------------- - -const sal_uInt16 EXC_TOK_STR_MAXLEN = 255; /// Maximum string length of a tStr token. - -const sal_uInt8 EXC_TOK_BOOL_FALSE = 0; /// FALSE value of a tBool token. -const sal_uInt8 EXC_TOK_BOOL_TRUE = 1; /// TRUE value of a tBool token. - -const sal_uInt8 EXC_TOK_ATTR_VOLATILE = 0x01; /// Volatile function. -const sal_uInt8 EXC_TOK_ATTR_IF = 0x02; /// Start of true condition in IF function. -const sal_uInt8 EXC_TOK_ATTR_CHOOSE = 0x04; /// Jump array of CHOOSE function. -const sal_uInt8 EXC_TOK_ATTR_GOTO = 0x08; /// Jump to token. -const sal_uInt8 EXC_TOK_ATTR_SUM = 0x10; /// SUM function with one parameter. -const sal_uInt8 EXC_TOK_ATTR_ASSIGN = 0x20; /// BASIC style assignment. -const sal_uInt8 EXC_TOK_ATTR_SPACE = 0x40; /// Spaces in formula representation. - -const sal_uInt8 EXC_TOK_ATTR_SPACE_SP = 0x00; /// Spaces before next token. -const sal_uInt8 EXC_TOK_ATTR_SPACE_BR = 0x01; /// Line breaks before next token. -const sal_uInt8 EXC_TOK_ATTR_SPACE_SP_OPEN = 0x02; /// Spaces before opening parenthesis. -const sal_uInt8 EXC_TOK_ATTR_SPACE_BR_OPEN = 0x03; /// Line breaks before opening parenthesis. -const sal_uInt8 EXC_TOK_ATTR_SPACE_SP_CLOSE = 0x04; /// Spaces before closing parenthesis. -const sal_uInt8 EXC_TOK_ATTR_SPACE_BR_CLOSE = 0x05; /// Line breaks before closing parenthesis. -const sal_uInt8 EXC_TOK_ATTR_SPACE_SP_PRE = 0x06; /// Spaces before formula (BIFF3). - -const sal_uInt16 EXC_TOK_FUNCVAR_CMD = 0x8000; /// Macro command. -const sal_uInt16 EXC_TOK_FUNCVAR_INDEXMASK = 0x7FFF; /// Mask for function/command index. -const sal_uInt8 EXC_TOK_FUNCVAR_PROMPT = 0x80; /// User prompt for macro commands. -const sal_uInt8 EXC_TOK_FUNCVAR_COUNTMASK = 0x7F; /// Mask for parameter count. - -const sal_uInt16 EXC_TOK_REF_COLREL = 0x4000; /// True = Column is relative. -const sal_uInt16 EXC_TOK_REF_ROWREL = 0x8000; /// True = Row is relative. - -const sal_uInt8 EXC_TOK_NLR_ERR = 0x01; /// NLR: Invalid/deleted. -const sal_uInt8 EXC_TOK_NLR_ROWR = 0x02; /// NLR: Row index. -const sal_uInt8 EXC_TOK_NLR_COLR = 0x03; /// NLR: Column index. -const sal_uInt8 EXC_TOK_NLR_ROWV = 0x06; /// NLR: Value in row. -const sal_uInt8 EXC_TOK_NLR_COLV = 0x07; /// NLR: Value in column. -const sal_uInt8 EXC_TOK_NLR_RANGE = 0x0A; /// NLR: Range. -const sal_uInt8 EXC_TOK_NLR_SRANGE = 0x0B; /// Stacked NLR: Range. -const sal_uInt8 EXC_TOK_NLR_SROWR = 0x0C; /// Stacked NLR: Row index. -const sal_uInt8 EXC_TOK_NLR_SCOLR = 0x0D; /// Stacked NLR: Column index. -const sal_uInt8 EXC_TOK_NLR_SROWV = 0x0E; /// Stacked NLR: Value in row. -const sal_uInt8 EXC_TOK_NLR_SCOLV = 0x0F; /// Stacked NLR: Value in column. -const sal_uInt8 EXC_TOK_NLR_RANGEERR = 0x10; /// NLR: Invalid/deleted range. -const sal_uInt8 EXC_TOK_NLR_SXNAME = 0x1D; /// NLR: Pivot table name. -const sal_uInt16 EXC_TOK_NLR_REL = 0x8000; /// True = Natural language ref is relative. - -const sal_uInt32 EXC_TOK_NLR_ADDREL = 0x80000000; /// NLR relative (in appended data). -const sal_uInt32 EXC_TOK_NLR_ADDMASK = 0x3FFFFFFF; /// Mask for number of appended ranges. - -// ---------------------------------------------------------------------------- - -/** Type of a formula. */ -enum XclFormulaType -{ - EXC_FMLATYPE_CELL, /// Simple cell formula, also used in change tracking. - EXC_FMLATYPE_MATRIX, /// Matrix (array) formula. - EXC_FMLATYPE_SHARED, /// Shared formula. - EXC_FMLATYPE_CONDFMT, /// Conditional format. - EXC_FMLATYPE_DATAVAL, /// Data validation. - EXC_FMLATYPE_NAME, /// Defined name. - EXC_FMLATYPE_CHART, /// Chart source ranges. - EXC_FMLATYPE_CONTROL, /// Spreadsheet links in form controls. - EXC_FMLATYPE_WQUERY, /// Web query source range. - EXC_FMLATYPE_LISTVAL /// List (cell range) validation. -}; - -// Function data ============================================================== - -const sal_uInt8 EXC_FUNC_MAXPARAM = 30; /// Maximum parameter count. - -const sal_uInt8 EXC_FUNC_PAR_CALCONLY = 0xFD; /// Placeholder for a parameter existing in Calc, but not in Excel. -const sal_uInt8 EXC_FUNC_PAR_EXCELONLY = 0xFE; /// Placeholder for a parameter existing in Excel, but not in Calc. -const sal_uInt8 EXC_FUNC_PAR_INVALID = 0xFF; /// Placeholder for an invalid token class. - -const sal_uInt8 EXC_FUNCINFO_CLASSCOUNT = 5; /// Number of token class entries. - -const sal_uInt8 EXC_FUNCFLAG_VOLATILE = 0x01; /// Result is volatile (e.g. NOW() function). -const sal_uInt8 EXC_FUNCFLAG_IMPORTONLY = 0x02; /// Only used in import filter. -const sal_uInt8 EXC_FUNCFLAG_EXPORTONLY = 0x04; /// Only used in export filter. - -// selected function IDs -const sal_uInt16 EXC_FUNCID_IF = 1; -const sal_uInt16 EXC_FUNCID_SUM = 4; -const sal_uInt16 EXC_FUNCID_AND = 36; -const sal_uInt16 EXC_FUNCID_OR = 37; -const sal_uInt16 EXC_FUNCID_CHOOSE = 100; -const sal_uInt16 EXC_FUNCID_EXTERNCALL = 255; - -/** Represents information for a spreadsheet function for import and export. - - The member mpnParamClass contains an array of token classes for each - parameter of the function. The last existing (non-null) value in this array - is used for all following parameters used in a function. Additionally to - the three actual token classes, this array may contain the special values - EXC_FUNC_PAR_CALCONLY, EXC_FUNC_PAR_EXCELONLY, and EXC_FUNC_PAR_INVALID. - The former two specify parameters only existing in one of the applications. - EXC_FUNC_PAR_INVALID is simply a terminator for the array to prevent that - the last token class or special value is repeated for additional parameters. - */ -struct XclFunctionInfo -{ - OpCode meOpCode; /// Calc function opcode. - sal_uInt16 mnXclFunc; /// Excel function index. - sal_uInt8 mnMinParamCount; /// Minimum number of parameters. - sal_uInt8 mnMaxParamCount; /// Maximum number of parameters. - sal_uInt8 mnRetClass; /// Token class of the return value. - sal_uInt8 mpnParamClass[ EXC_FUNCINFO_CLASSCOUNT ]; /// Expected token classes of parameters. - sal_uInt8 mnFlags; /// Additional flags. - const sal_Char* mpcMacroName; /// Function name, if simulated by a macro call (UTF-8). - - /** Returns true, if the function is volatile. */ - inline bool IsVolatile() const { return ::get_flag( mnFlags, EXC_FUNCFLAG_VOLATILE ); } - /** Returns true, if the function is simulated by a macro call. */ - inline bool IsMacroFunc() const { return mpcMacroName != 0; } - /** Returns the name of the external function as string. */ - String GetMacroFuncName() const; -}; - -// ---------------------------------------------------------------------------- - -class XclRoot; - -/** Provides access to function info structs for all available functions. */ -class XclFunctionProvider -{ -public: - explicit XclFunctionProvider( const XclRoot& rRoot ); - - /** Returns the function data for an Excel function index, or 0 on error. */ - const XclFunctionInfo* GetFuncInfoFromXclFunc( sal_uInt16 nXclFunc ) const; - /** Returns the function data for an Excel function simulated by a macro call, or 0 on error. */ - const XclFunctionInfo* GetFuncInfoFromXclMacroName( const String& rXclMacroName ) const; - /** Returns the function data for a Calc opcode, or 0 on error. */ - const XclFunctionInfo* GetFuncInfoFromOpCode( OpCode eOpCode ) const; - -private: - void FillXclFuncMap( const XclFunctionInfo* pBeg, const XclFunctionInfo* pEnd ); - void FillScFuncMap( const XclFunctionInfo* pBeg, const XclFunctionInfo* pEnd ); - -private: - typedef ::std::map< sal_uInt16, const XclFunctionInfo* > XclFuncMap; - typedef ::std::map< String, const XclFunctionInfo* > XclMacroNameMap; - typedef ::std::map< OpCode, const XclFunctionInfo* > ScFuncMap; - - XclFuncMap maXclFuncMap; /// Maps Excel function indexes to function data. - XclMacroNameMap maXclMacroNameMap; /// Maps macro function names to function data. - ScFuncMap maScFuncMap; /// Maps Calc opcodes to function data. -}; - -// Token array ================================================================ - -class XclImpStream; -class XclExpStream; - -/** Binary representation of an Excel token array. */ -class XclTokenArray -{ -public: - /** Creates an empty token array. */ - explicit XclTokenArray( bool bVolatile = false ); - /** Creates a token array, swaps passed token vector into own data. */ - explicit XclTokenArray( ScfUInt8Vec& rTokVec, bool bVolatile = false, - ScfUInt8Vec* pExtensionTokens = NULL); - - /** Returns true, if the token array is empty. */ - inline bool Empty() const { return maTokVec.empty(); } - /** Returns the size of the token array in bytes. */ - sal_uInt16 GetSize() const; - /** Returns read-only access to the byte vector storing token data. */ - inline const sal_uInt8* GetData() const { return maTokVec.empty() ? 0 : &maTokVec.front(); } - /** Returns true, if the formula contains a volatile function. */ - inline bool IsVolatile() const { return mbVolatile; } - - /** Reads the size field of the token array. */ - void ReadSize( XclImpStream& rStrm ); - /** Reads the tokens of the token array (without size field). */ - void ReadArray( XclImpStream& rStrm ); - /** Reads size field and the tokens. */ - void Read( XclImpStream& rStrm ); - - /** Writes the size field of the token array. */ - void WriteSize( XclExpStream& rStrm ) const; - /** Writes the tokens of the token array (without size field). */ - void WriteArray( XclExpStream& rStrm ) const; - /** Writes size field and the tokens. */ - void Write( XclExpStream& rStrm ) const; - - /** Compares this token array with the passed. */ - bool operator==( const XclTokenArray& rTokArr ) const; - -private: - ScfUInt8Vec maTokVec; /// Byte vector containing token data. - ScfUInt8Vec maExtensions; /// Byte vector of extensions (eg inline arrays) - bool mbVolatile; /// True = Formula contains volatile function. -}; - -typedef ScfRef< XclTokenArray > XclTokenArrayRef; - -/** Calls the Read() function at the passed token array. */ -XclImpStream& operator>>( XclImpStream& rStrm, XclTokenArray& rTokArr ); -/** Calls the Read() function at the passed token array. */ -XclImpStream& operator>>( XclImpStream& rStrm, XclTokenArrayRef& rxTokArr ); -/** Calls the Write() function at the passed token array. */ -XclExpStream& operator<<( XclExpStream& rStrm, const XclTokenArray& rTokArr ); -/** Calls the Write() function at the passed token array. */ -XclExpStream& operator<<( XclExpStream& rStrm, const XclTokenArrayRef& rxTokArr ); - -// ---------------------------------------------------------------------------- - -class ScToken; -class ScTokenArray; - -/** Special token array iterator for the Excel filters. - - Iterates over a Calc token array without modifying it (therefore the - iterator can be used with constant token arrays). - - Usage: Construct a new iterator object and pass a Calc token array, or use - the Init() function to assign another Calc token array. As long as the Is() - function returns true, the accessor functions can be used to get the - current Calc token. - */ -class XclTokenArrayIterator -{ -public: - explicit XclTokenArrayIterator(); - explicit XclTokenArrayIterator( const ScTokenArray& rScTokArr, bool bSkipSpaces ); - /** Copy constructor that allowa to change the skip-spaces mode. */ - explicit XclTokenArrayIterator( const XclTokenArrayIterator& rTokArrIt, bool bSkipSpaces ); - - void Init(); - void Init( const ScTokenArray& rScTokArr, bool bSkipSpaces ); - - inline bool Is() const { return mppScToken != 0; } - inline bool operator!() const { return !Is(); } - inline const ScToken* Get() const { return mppScToken ? *mppScToken : 0; } - inline const ScToken* operator->() const { return Get(); } - inline const ScToken& operator*() const { return *Get(); } - - XclTokenArrayIterator& operator++(); - -private: - void NextRawToken(); - void SkipSpaces(); - -private: - const ScToken*const* mppScTokenBeg; /// Pointer to first token pointer of token array. - const ScToken*const* mppScTokenEnd; /// Pointer behind last token pointer of token array. - const ScToken*const* mppScToken; /// Pointer to current token pointer of token array. - bool mbSkipSpaces; /// true = Skip whitespace tokens. -}; - -// ---------------------------------------------------------------------------- - -/** Contains all cell references that can be extracted from a multiple operations formula. */ -struct XclMultipleOpRefs -{ - ScAddress maFmlaScPos; /// Position of the (first) formula cell. - ScAddress maColFirstScPos; - ScAddress maColRelScPos; - ScAddress maRowFirstScPos; - ScAddress maRowRelScPos; - bool mbDblRefMode; /// true = One formula with row and column values. -}; - -// ---------------------------------------------------------------------------- - -/** A helper with Excel specific token array functions. - - The purpose to not add these functions to ScTokenArray is to prevent code - changes in low-level Calc headers and to keep the Excel specific source - code in the filter directory. Deriving from ScTokenArray is not viable - because that would need expensive copy-constructions of the token arrays. - */ -class XclTokenArrayHelper -{ -public: - // token identifiers ------------------------------------------------------ - - /** Returns the base token ID of the passed (classified) token ID. */ - inline static sal_uInt8 GetBaseTokenId( sal_uInt8 nTokenId ) { return nTokenId & EXC_TOKID_MASK; } - /** Returns the classified token ID from a base ID and the token class. */ - inline static sal_uInt8 GetTokenId( sal_uInt8 nBaseId, sal_uInt8 nTokenClass ); - - /** Returns the token class of the passed token ID. */ - inline static sal_uInt8 GetTokenClass( sal_uInt8 nTokenId ) { return nTokenId & EXC_TOKCLASS_MASK; } - /** Changes the token class in the passed classified token ID. */ - inline static void ChangeTokenClass( sal_uInt8& rnTokenId, sal_uInt8 nTokenClass ); - - // strings and string lists ----------------------------------------------- - - /** Tries to extract a string from the passed token. - @param rString (out-parameter) The string contained in the token. - @return true = Passed token is a string token, rString parameter is valid. */ - static bool GetTokenString( String& rString, const ScToken& rScToken ); - - /** Parses the passed formula and tries to find a single string token, i.e. "abc". - @param rString (out-parameter) The string contained in the formula. - @return true = String token found, rString parameter is valid. */ - static bool GetString( String& rString, const ScTokenArray& rScTokArr ); - - /** Parses the passed formula and tries to find a string token list, i.e. "abc";"def";"ghi". - @descr Returns the unquoted (!) strings in a single string, separated with the - passed character. If a comma is specified, the function will return abc,def,ghi from - the example above. - @param rStringList (out-parameter) All strings contained in the formula as list. - @param cSep List separator character. - @return true = String token list found, rString parameter is valid. */ - static bool GetStringList( String& rStringList, const ScTokenArray& rScTokArr, sal_Unicode cSep ); - - /** Tries to convert a formula that consists of a single string token to a list of strings. - @descr Example: The formula ="abc\ndef\nghi" will be converted to the formula - ="abc";"def";"ghi", if the LF character is specified as separator. - @param rScTokArr (in/out-parameter) The token array to modify. - @param cStringSep The separator in the source string. - @param bTrimLeadingSpaces true = remove leading spaces from each token. */ - static void ConvertStringToList( ScTokenArray& rScTokArr, sal_Unicode cStringSep, bool bTrimLeadingSpaces ); - - // shared formulas -------------------------------------------------------- - - /** Tries to extract the definition of a shared formula from the passed token array. - @descr Shared formulas are stored as hidden defined names in Calc. This - function looks if the passed token array consists of the reference to - such a hidden defined name and returns its definition on success. */ - static const ScTokenArray* GetSharedFormula( const XclRoot& rRoot, const ScTokenArray& rScTokArr ); - - // multiple operations ---------------------------------------------------- - - /** Parses the passed formula and tries to extract references of a multiple operation. - @descr Requires that the formula contains a single MULTIPLE.OPERATION function call. - Spaces in the formula are silently ignored. - @return true = Multiple operation found, and all references successfully extracted. */ - static bool GetMultipleOpRefs( XclMultipleOpRefs& rRefs, const ScTokenArray& rScTokArr ); -}; - -// ---------------------------------------------------------------------------- - -inline sal_uInt8 XclTokenArrayHelper::GetTokenId( sal_uInt8 nBaseId, sal_uInt8 nTokenClass ) -{ - DBG_ASSERT( !::get_flag( nBaseId, static_cast< sal_uInt8 >( ~EXC_TOKID_MASK ) ), "XclTokenArrayHelper::GetTokenId - invalid token ID" ); - DBG_ASSERT( !::get_flag( nTokenClass, static_cast< sal_uInt8 >( ~EXC_TOKCLASS_MASK ) ), "XclTokenArrayHelper::GetTokenId - invalid token class" ); - return nBaseId | nTokenClass; -} - -inline void XclTokenArrayHelper::ChangeTokenClass( sal_uInt8& rnTokenId, sal_uInt8 nTokenClass ) -{ - DBG_ASSERT( !::get_flag( nTokenClass, static_cast< sal_uInt8 >( ~EXC_TOKCLASS_MASK ) ), "XclTokenArrayHelper::ChangeTokenClass - invalid token class" ); - ::set_flag( rnTokenId, EXC_TOKCLASS_MASK, false ); - ::set_flag( rnTokenId, nTokenClass ); -} - -// ============================================================================ - -#endif - +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: xlformula.hxx,v $
+ * $Revision: 1.14 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_XLFORMULA_HXX
+#define SC_XLFORMULA_HXX
+
+#include <map>
+#include "address.hxx"
+#include "formula/opcode.hxx"
+#include "ftools.hxx"
+
+// Constants ==================================================================
+
+const size_t EXC_TOKARR_MAXLEN = 4096; /// Maximum size of a token array.
+
+// Token class flags ----------------------------------------------------------
+
+const sal_uInt8 EXC_TOKCLASS_MASK = 0x60;
+const sal_uInt8 EXC_TOKCLASS_INOP_FLAG = 0x80; /// Used in operators (internal flag).
+
+const sal_uInt8 EXC_TOKCLASS_NONE = 0x00; /// 00-1F: Base tokens.
+const sal_uInt8 EXC_TOKCLASS_REF = 0x20; /// 20-3F: Reference class tokens.
+const sal_uInt8 EXC_TOKCLASS_VAL = 0x40; /// 40-5F: Value class tokens.
+const sal_uInt8 EXC_TOKCLASS_ARR = 0x60; /// 60-7F: Array class tokens.
+
+const sal_uInt8 EXC_TOKCLASS_ANY_IN_REFOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_NONE;
+const sal_uInt8 EXC_TOKCLASS_REF_IN_VALOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_REF;
+const sal_uInt8 EXC_TOKCLASS_VAL_IN_VALOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_VAL;
+const sal_uInt8 EXC_TOKCLASS_ARR_IN_VALOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_ARR;
+
+// Base tokens ----------------------------------------------------------------
+
+const sal_uInt8 EXC_TOKID_MASK = 0x1F;
+
+const sal_uInt8 EXC_TOKID_NONE = 0x00; /// Placeholder for invalid token id.
+const sal_uInt8 EXC_TOKID_EXP = 0x01; /// Array or shared formula reference.
+const sal_uInt8 EXC_TOKID_TBL = 0x02; /// Multiple operation reference.
+const sal_uInt8 EXC_TOKID_ADD = 0x03; /// Addition operator.
+const sal_uInt8 EXC_TOKID_SUB = 0x04; /// Subtraction operator.
+const sal_uInt8 EXC_TOKID_MUL = 0x05; /// Multiplication operator.
+const sal_uInt8 EXC_TOKID_DIV = 0x06; /// Division operator.
+const sal_uInt8 EXC_TOKID_POWER = 0x07; /// Power operator.
+const sal_uInt8 EXC_TOKID_CONCAT = 0x08; /// String concatenation operator.
+const sal_uInt8 EXC_TOKID_LT = 0x09; /// Less than operator.
+const sal_uInt8 EXC_TOKID_LE = 0x0A; /// Less than or equal operator.
+const sal_uInt8 EXC_TOKID_EQ = 0x0B; /// Equal operator.
+const sal_uInt8 EXC_TOKID_GE = 0x0C; /// Greater than or equal operator.
+const sal_uInt8 EXC_TOKID_GT = 0x0D; /// Greater than operator.
+const sal_uInt8 EXC_TOKID_NE = 0x0E; /// Not equal operator.
+const sal_uInt8 EXC_TOKID_ISECT = 0x0F; /// Intersection operator.
+const sal_uInt8 EXC_TOKID_LIST = 0x10; /// List operator.
+const sal_uInt8 EXC_TOKID_RANGE = 0x11; /// Range operator.
+const sal_uInt8 EXC_TOKID_UPLUS = 0x12; /// Unary plus.
+const sal_uInt8 EXC_TOKID_UMINUS = 0x13; /// Unary minus.
+const sal_uInt8 EXC_TOKID_PERCENT = 0x14; /// Percent sign.
+const sal_uInt8 EXC_TOKID_PAREN = 0x15; /// Parentheses.
+const sal_uInt8 EXC_TOKID_MISSARG = 0x16; /// Missing argument.
+const sal_uInt8 EXC_TOKID_STR = 0x17; /// String constant.
+const sal_uInt8 EXC_TOKID_NLR = 0x18; /// Natural language reference (NLR).
+const sal_uInt8 EXC_TOKID_ATTR = 0x19; /// Special attribute.
+const sal_uInt8 EXC_TOKID_SHEET = 0x1A; /// Start of a sheet reference (BIFF2-BIFF4).
+const sal_uInt8 EXC_TOKID_ENDSHEET = 0x1B; /// End of a sheet reference (BIFF2-BIFF4).
+const sal_uInt8 EXC_TOKID_ERR = 0x1C; /// Error constant.
+const sal_uInt8 EXC_TOKID_BOOL = 0x1D; /// Boolean constant.
+const sal_uInt8 EXC_TOKID_INT = 0x1E; /// Integer constant.
+const sal_uInt8 EXC_TOKID_NUM = 0x1F; /// Floating-point constant.
+
+// Base IDs of classified tokens ----------------------------------------------
+
+const sal_uInt8 EXC_TOKID_ARRAY = 0x00; /// Array constant.
+const sal_uInt8 EXC_TOKID_FUNC = 0x01; /// Function, fixed number of arguments.
+const sal_uInt8 EXC_TOKID_FUNCVAR = 0x02; /// Function, variable number of arguments.
+const sal_uInt8 EXC_TOKID_NAME = 0x03; /// Defined name.
+const sal_uInt8 EXC_TOKID_REF = 0x04; /// 2D cell reference.
+const sal_uInt8 EXC_TOKID_AREA = 0x05; /// 2D area reference.
+const sal_uInt8 EXC_TOKID_MEMAREA = 0x06; /// Constant reference subexpression.
+const sal_uInt8 EXC_TOKID_MEMERR = 0x07; /// Deleted reference subexpression.
+const sal_uInt8 EXC_TOKID_MEMNOMEM = 0x08; /// Constant reference subexpression without result.
+const sal_uInt8 EXC_TOKID_MEMFUNC = 0x09; /// Variable reference subexpression.
+const sal_uInt8 EXC_TOKID_REFERR = 0x0A; /// Deleted 2D cell reference.
+const sal_uInt8 EXC_TOKID_AREAERR = 0x0B; /// Deleted 2D area reference.
+const sal_uInt8 EXC_TOKID_REFN = 0x0C; /// Relative 2D cell reference (in names).
+const sal_uInt8 EXC_TOKID_AREAN = 0x0D; /// Relative 2D area reference (in names).
+const sal_uInt8 EXC_TOKID_MEMAREAN = 0x0E; /// Reference subexpression (in names).
+const sal_uInt8 EXC_TOKID_MEMNOMEMN = 0x0F; /// Reference subexpression (in names) without result.
+const sal_uInt8 EXC_TOKID_FUNCCE = 0x18;
+const sal_uInt8 EXC_TOKID_NAMEX = 0x19; /// External reference.
+const sal_uInt8 EXC_TOKID_REF3D = 0x1A; /// 3D cell reference.
+const sal_uInt8 EXC_TOKID_AREA3D = 0x1B; /// 3D area reference.
+const sal_uInt8 EXC_TOKID_REFERR3D = 0x1C; /// Deleted 3D cell reference.
+const sal_uInt8 EXC_TOKID_AREAERR3D = 0x1D; /// Deleted 3D area reference
+
+// specific token constants ---------------------------------------------------
+
+const sal_uInt16 EXC_TOK_STR_MAXLEN = 255; /// Maximum string length of a tStr token.
+
+const sal_uInt8 EXC_TOK_BOOL_FALSE = 0; /// FALSE value of a tBool token.
+const sal_uInt8 EXC_TOK_BOOL_TRUE = 1; /// TRUE value of a tBool token.
+
+const sal_uInt8 EXC_TOK_ATTR_VOLATILE = 0x01; /// Volatile function.
+const sal_uInt8 EXC_TOK_ATTR_IF = 0x02; /// Start of true condition in IF function.
+const sal_uInt8 EXC_TOK_ATTR_CHOOSE = 0x04; /// Jump array of CHOOSE function.
+const sal_uInt8 EXC_TOK_ATTR_GOTO = 0x08; /// Jump to token.
+const sal_uInt8 EXC_TOK_ATTR_SUM = 0x10; /// SUM function with one parameter.
+const sal_uInt8 EXC_TOK_ATTR_ASSIGN = 0x20; /// BASIC style assignment.
+const sal_uInt8 EXC_TOK_ATTR_SPACE = 0x40; /// Spaces in formula representation.
+
+const sal_uInt8 EXC_TOK_ATTR_SPACE_SP = 0x00; /// Spaces before next token.
+const sal_uInt8 EXC_TOK_ATTR_SPACE_BR = 0x01; /// Line breaks before next token.
+const sal_uInt8 EXC_TOK_ATTR_SPACE_SP_OPEN = 0x02; /// Spaces before opening parenthesis.
+const sal_uInt8 EXC_TOK_ATTR_SPACE_BR_OPEN = 0x03; /// Line breaks before opening parenthesis.
+const sal_uInt8 EXC_TOK_ATTR_SPACE_SP_CLOSE = 0x04; /// Spaces before closing parenthesis.
+const sal_uInt8 EXC_TOK_ATTR_SPACE_BR_CLOSE = 0x05; /// Line breaks before closing parenthesis.
+const sal_uInt8 EXC_TOK_ATTR_SPACE_SP_PRE = 0x06; /// Spaces before formula (BIFF3).
+
+const sal_uInt16 EXC_TOK_FUNCVAR_CMD = 0x8000; /// Macro command.
+const sal_uInt16 EXC_TOK_FUNCVAR_INDEXMASK = 0x7FFF; /// Mask for function/command index.
+const sal_uInt8 EXC_TOK_FUNCVAR_PROMPT = 0x80; /// User prompt for macro commands.
+const sal_uInt8 EXC_TOK_FUNCVAR_COUNTMASK = 0x7F; /// Mask for parameter count.
+
+const sal_uInt16 EXC_TOK_REF_COLREL = 0x4000; /// True = Column is relative.
+const sal_uInt16 EXC_TOK_REF_ROWREL = 0x8000; /// True = Row is relative.
+
+const sal_uInt8 EXC_TOK_NLR_ERR = 0x01; /// NLR: Invalid/deleted.
+const sal_uInt8 EXC_TOK_NLR_ROWR = 0x02; /// NLR: Row index.
+const sal_uInt8 EXC_TOK_NLR_COLR = 0x03; /// NLR: Column index.
+const sal_uInt8 EXC_TOK_NLR_ROWV = 0x06; /// NLR: Value in row.
+const sal_uInt8 EXC_TOK_NLR_COLV = 0x07; /// NLR: Value in column.
+const sal_uInt8 EXC_TOK_NLR_RANGE = 0x0A; /// NLR: Range.
+const sal_uInt8 EXC_TOK_NLR_SRANGE = 0x0B; /// Stacked NLR: Range.
+const sal_uInt8 EXC_TOK_NLR_SROWR = 0x0C; /// Stacked NLR: Row index.
+const sal_uInt8 EXC_TOK_NLR_SCOLR = 0x0D; /// Stacked NLR: Column index.
+const sal_uInt8 EXC_TOK_NLR_SROWV = 0x0E; /// Stacked NLR: Value in row.
+const sal_uInt8 EXC_TOK_NLR_SCOLV = 0x0F; /// Stacked NLR: Value in column.
+const sal_uInt8 EXC_TOK_NLR_RANGEERR = 0x10; /// NLR: Invalid/deleted range.
+const sal_uInt8 EXC_TOK_NLR_SXNAME = 0x1D; /// NLR: Pivot table name.
+const sal_uInt16 EXC_TOK_NLR_REL = 0x8000; /// True = Natural language ref is relative.
+
+const sal_uInt32 EXC_TOK_NLR_ADDREL = 0x80000000; /// NLR relative (in appended data).
+const sal_uInt32 EXC_TOK_NLR_ADDMASK = 0x3FFFFFFF; /// Mask for number of appended ranges.
+
+// ----------------------------------------------------------------------------
+
+/** Type of a formula. */
+enum XclFormulaType
+{
+ EXC_FMLATYPE_CELL, /// Simple cell formula, also used in change tracking.
+ EXC_FMLATYPE_MATRIX, /// Matrix (array) formula.
+ EXC_FMLATYPE_SHARED, /// Shared formula.
+ EXC_FMLATYPE_CONDFMT, /// Conditional format.
+ EXC_FMLATYPE_DATAVAL, /// Data validation.
+ EXC_FMLATYPE_NAME, /// Defined name.
+ EXC_FMLATYPE_CHART, /// Chart source ranges.
+ EXC_FMLATYPE_CONTROL, /// Spreadsheet links in form controls.
+ EXC_FMLATYPE_WQUERY, /// Web query source range.
+ EXC_FMLATYPE_LISTVAL /// List (cell range) validation.
+};
+
+// Function data ==============================================================
+
+const sal_uInt8 EXC_FUNC_MAXPARAM = 30; /// Maximum parameter count.
+
+const sal_uInt8 EXC_FUNC_PAR_CALCONLY = 0xFD; /// Placeholder for a parameter existing in Calc, but not in Excel.
+const sal_uInt8 EXC_FUNC_PAR_EXCELONLY = 0xFE; /// Placeholder for a parameter existing in Excel, but not in Calc.
+const sal_uInt8 EXC_FUNC_PAR_INVALID = 0xFF; /// Placeholder for an invalid token class.
+
+const sal_uInt8 EXC_FUNCINFO_CLASSCOUNT = 5; /// Number of token class entries.
+
+const sal_uInt8 EXC_FUNCFLAG_VOLATILE = 0x01; /// Result is volatile (e.g. NOW() function).
+const sal_uInt8 EXC_FUNCFLAG_IMPORTONLY = 0x02; /// Only used in import filter.
+const sal_uInt8 EXC_FUNCFLAG_EXPORTONLY = 0x04; /// Only used in export filter.
+
+// selected function IDs
+const sal_uInt16 EXC_FUNCID_IF = 1;
+const sal_uInt16 EXC_FUNCID_SUM = 4;
+const sal_uInt16 EXC_FUNCID_AND = 36;
+const sal_uInt16 EXC_FUNCID_OR = 37;
+const sal_uInt16 EXC_FUNCID_CHOOSE = 100;
+const sal_uInt16 EXC_FUNCID_EXTERNCALL = 255;
+
+/** Represents information for a spreadsheet function for import and export.
+
+ The member mpnParamClass contains an array of token classes for each
+ parameter of the function. The last existing (non-null) value in this array
+ is used for all following parameters used in a function. Additionally to
+ the three actual token classes, this array may contain the special values
+ EXC_FUNC_PAR_CALCONLY, EXC_FUNC_PAR_EXCELONLY, and EXC_FUNC_PAR_INVALID.
+ The former two specify parameters only existing in one of the applications.
+ EXC_FUNC_PAR_INVALID is simply a terminator for the array to prevent that
+ the last token class or special value is repeated for additional parameters.
+ */
+struct XclFunctionInfo
+{
+ OpCode meOpCode; /// Calc function opcode.
+ sal_uInt16 mnXclFunc; /// Excel function index.
+ sal_uInt8 mnMinParamCount; /// Minimum number of parameters.
+ sal_uInt8 mnMaxParamCount; /// Maximum number of parameters.
+ sal_uInt8 mnRetClass; /// Token class of the return value.
+ sal_uInt8 mpnParamClass[ EXC_FUNCINFO_CLASSCOUNT ]; /// Expected token classes of parameters.
+ sal_uInt8 mnFlags; /// Additional flags.
+ const sal_Char* mpcMacroName; /// Function name, if simulated by a macro call (UTF-8).
+
+ /** Returns true, if the function is volatile. */
+ inline bool IsVolatile() const { return ::get_flag( mnFlags, EXC_FUNCFLAG_VOLATILE ); }
+ /** Returns true, if the function is simulated by a macro call. */
+ inline bool IsMacroFunc() const { return mpcMacroName != 0; }
+ /** Returns the name of the external function as string. */
+ String GetMacroFuncName() const;
+};
+
+// ----------------------------------------------------------------------------
+
+class XclRoot;
+
+/** Provides access to function info structs for all available functions. */
+class XclFunctionProvider
+{
+public:
+ explicit XclFunctionProvider( const XclRoot& rRoot );
+
+ /** Returns the function data for an Excel function index, or 0 on error. */
+ const XclFunctionInfo* GetFuncInfoFromXclFunc( sal_uInt16 nXclFunc ) const;
+ /** Returns the function data for an Excel function simulated by a macro call, or 0 on error. */
+ const XclFunctionInfo* GetFuncInfoFromXclMacroName( const String& rXclMacroName ) const;
+ /** Returns the function data for a Calc opcode, or 0 on error. */
+ const XclFunctionInfo* GetFuncInfoFromOpCode( OpCode eOpCode ) const;
+
+private:
+ void FillXclFuncMap( const XclFunctionInfo* pBeg, const XclFunctionInfo* pEnd );
+ void FillScFuncMap( const XclFunctionInfo* pBeg, const XclFunctionInfo* pEnd );
+
+private:
+ typedef ::std::map< sal_uInt16, const XclFunctionInfo* > XclFuncMap;
+ typedef ::std::map< String, const XclFunctionInfo* > XclMacroNameMap;
+ typedef ::std::map< OpCode, const XclFunctionInfo* > ScFuncMap;
+
+ XclFuncMap maXclFuncMap; /// Maps Excel function indexes to function data.
+ XclMacroNameMap maXclMacroNameMap; /// Maps macro function names to function data.
+ ScFuncMap maScFuncMap; /// Maps Calc opcodes to function data.
+};
+
+// Token array ================================================================
+
+class XclImpStream;
+class XclExpStream;
+
+/** Binary representation of an Excel token array. */
+class XclTokenArray
+{
+public:
+ /** Creates an empty token array. */
+ explicit XclTokenArray( bool bVolatile = false );
+ /** Creates a token array, swaps passed token vector into own data. */
+ explicit XclTokenArray( ScfUInt8Vec& rTokVec, bool bVolatile = false,
+ ScfUInt8Vec* pExtensionTokens = NULL);
+
+ /** Returns true, if the token array is empty. */
+ inline bool Empty() const { return maTokVec.empty(); }
+ /** Returns the size of the token array in bytes. */
+ sal_uInt16 GetSize() const;
+ /** Returns read-only access to the byte vector storing token data. */
+ inline const sal_uInt8* GetData() const { return maTokVec.empty() ? 0 : &maTokVec.front(); }
+ /** Returns true, if the formula contains a volatile function. */
+ inline bool IsVolatile() const { return mbVolatile; }
+
+ /** Reads the size field of the token array. */
+ void ReadSize( XclImpStream& rStrm );
+ /** Reads the tokens of the token array (without size field). */
+ void ReadArray( XclImpStream& rStrm );
+ /** Reads size field and the tokens. */
+ void Read( XclImpStream& rStrm );
+
+ /** Writes the size field of the token array. */
+ void WriteSize( XclExpStream& rStrm ) const;
+ /** Writes the tokens of the token array (without size field). */
+ void WriteArray( XclExpStream& rStrm ) const;
+ /** Writes size field and the tokens. */
+ void Write( XclExpStream& rStrm ) const;
+
+ /** Compares this token array with the passed. */
+ bool operator==( const XclTokenArray& rTokArr ) const;
+
+private:
+ ScfUInt8Vec maTokVec; /// Byte vector containing token data.
+ ScfUInt8Vec maExtensions; /// Byte vector of extensions (eg inline arrays)
+ bool mbVolatile; /// True = Formula contains volatile function.
+};
+
+typedef ScfRef< XclTokenArray > XclTokenArrayRef;
+
+/** Calls the Read() function at the passed token array. */
+XclImpStream& operator>>( XclImpStream& rStrm, XclTokenArray& rTokArr );
+/** Calls the Read() function at the passed token array. */
+XclImpStream& operator>>( XclImpStream& rStrm, XclTokenArrayRef& rxTokArr );
+/** Calls the Write() function at the passed token array. */
+XclExpStream& operator<<( XclExpStream& rStrm, const XclTokenArray& rTokArr );
+/** Calls the Write() function at the passed token array. */
+XclExpStream& operator<<( XclExpStream& rStrm, const XclTokenArrayRef& rxTokArr );
+
+// ----------------------------------------------------------------------------
+
+namespace formula
+{
+ class FormulaToken;
+}
+class ScTokenArray;
+
+/** Special token array iterator for the Excel filters.
+
+ Iterates over a Calc token array without modifying it (therefore the
+ iterator can be used with constant token arrays).
+
+ Usage: Construct a new iterator object and pass a Calc token array, or use
+ the Init() function to assign another Calc token array. As long as the Is()
+ function returns true, the accessor functions can be used to get the
+ current Calc token.
+ */
+class XclTokenArrayIterator
+{
+public:
+ explicit XclTokenArrayIterator();
+ explicit XclTokenArrayIterator( const ScTokenArray& rScTokArr, bool bSkipSpaces );
+ /** Copy constructor that allowa to change the skip-spaces mode. */
+ explicit XclTokenArrayIterator( const XclTokenArrayIterator& rTokArrIt, bool bSkipSpaces );
+
+ void Init();
+ void Init( const ScTokenArray& rScTokArr, bool bSkipSpaces );
+
+ inline bool Is() const { return mppScToken != 0; }
+ inline bool operator!() const { return !Is(); }
+ inline const formula::FormulaToken* Get() const { return mppScToken ? *mppScToken : 0; }
+ inline const formula::FormulaToken* operator->() const { return Get(); }
+ inline const formula::FormulaToken& operator*() const { return *Get(); }
+
+ XclTokenArrayIterator& operator++();
+
+private:
+ void NextRawToken();
+ void SkipSpaces();
+
+private:
+ const formula::FormulaToken*const* mppScTokenBeg; /// Pointer to first token pointer of token array.
+ const formula::FormulaToken*const* mppScTokenEnd; /// Pointer behind last token pointer of token array.
+ const formula::FormulaToken*const* mppScToken; /// Pointer to current token pointer of token array.
+ bool mbSkipSpaces; /// true = Skip whitespace tokens.
+};
+
+// ----------------------------------------------------------------------------
+
+/** Contains all cell references that can be extracted from a multiple operations formula. */
+struct XclMultipleOpRefs
+{
+ ScAddress maFmlaScPos; /// Position of the (first) formula cell.
+ ScAddress maColFirstScPos;
+ ScAddress maColRelScPos;
+ ScAddress maRowFirstScPos;
+ ScAddress maRowRelScPos;
+ bool mbDblRefMode; /// true = One formula with row and column values.
+};
+
+// ----------------------------------------------------------------------------
+
+/** A helper with Excel specific token array functions.
+
+ The purpose to not add these functions to ScTokenArray is to prevent code
+ changes in low-level Calc headers and to keep the Excel specific source
+ code in the filter directory. Deriving from ScTokenArray is not viable
+ because that would need expensive copy-constructions of the token arrays.
+ */
+class XclTokenArrayHelper
+{
+public:
+ // token identifiers ------------------------------------------------------
+
+ /** Returns the base token ID of the passed (classified) token ID. */
+ inline static sal_uInt8 GetBaseTokenId( sal_uInt8 nTokenId ) { return nTokenId & EXC_TOKID_MASK; }
+ /** Returns the classified token ID from a base ID and the token class. */
+ inline static sal_uInt8 GetTokenId( sal_uInt8 nBaseId, sal_uInt8 nTokenClass );
+
+ /** Returns the token class of the passed token ID. */
+ inline static sal_uInt8 GetTokenClass( sal_uInt8 nTokenId ) { return nTokenId & EXC_TOKCLASS_MASK; }
+ /** Changes the token class in the passed classified token ID. */
+ inline static void ChangeTokenClass( sal_uInt8& rnTokenId, sal_uInt8 nTokenClass );
+
+ // strings and string lists -----------------------------------------------
+
+ /** Tries to extract a string from the passed token.
+ @param rString (out-parameter) The string contained in the token.
+ @return true = Passed token is a string token, rString parameter is valid. */
+ static bool GetTokenString( String& rString, const formula::FormulaToken& rScToken );
+
+ /** Parses the passed formula and tries to find a single string token, i.e. "abc".
+ @param rString (out-parameter) The string contained in the formula.
+ @return true = String token found, rString parameter is valid. */
+ static bool GetString( String& rString, const ScTokenArray& rScTokArr );
+
+ /** Parses the passed formula and tries to find a string token list, i.e. "abc";"def";"ghi".
+ @descr Returns the unquoted (!) strings in a single string, separated with the
+ passed character. If a comma is specified, the function will return abc,def,ghi from
+ the example above.
+ @param rStringList (out-parameter) All strings contained in the formula as list.
+ @param cSep List separator character.
+ @return true = String token list found, rString parameter is valid. */
+ static bool GetStringList( String& rStringList, const ScTokenArray& rScTokArr, sal_Unicode cSep );
+
+ /** Tries to convert a formula that consists of a single string token to a list of strings.
+ @descr Example: The formula ="abc\ndef\nghi" will be converted to the formula
+ ="abc";"def";"ghi", if the LF character is specified as separator.
+ @param rScTokArr (in/out-parameter) The token array to modify.
+ @param cStringSep The separator in the source string.
+ @param bTrimLeadingSpaces true = remove leading spaces from each token. */
+ static void ConvertStringToList( ScTokenArray& rScTokArr, sal_Unicode cStringSep, bool bTrimLeadingSpaces );
+
+ // shared formulas --------------------------------------------------------
+
+ /** Tries to extract the definition of a shared formula from the passed token array.
+ @descr Shared formulas are stored as hidden defined names in Calc. This
+ function looks if the passed token array consists of the reference to
+ such a hidden defined name and returns its definition on success. */
+ static const ScTokenArray* GetSharedFormula( const XclRoot& rRoot, const ScTokenArray& rScTokArr );
+
+ // multiple operations ----------------------------------------------------
+
+ /** Parses the passed formula and tries to extract references of a multiple operation.
+ @descr Requires that the formula contains a single MULTIPLE.OPERATION function call.
+ Spaces in the formula are silently ignored.
+ @return true = Multiple operation found, and all references successfully extracted. */
+ static bool GetMultipleOpRefs( XclMultipleOpRefs& rRefs, const ScTokenArray& rScTokArr );
+};
+
+// ----------------------------------------------------------------------------
+
+inline sal_uInt8 XclTokenArrayHelper::GetTokenId( sal_uInt8 nBaseId, sal_uInt8 nTokenClass )
+{
+ DBG_ASSERT( !::get_flag( nBaseId, static_cast< sal_uInt8 >( ~EXC_TOKID_MASK ) ), "XclTokenArrayHelper::GetTokenId - invalid token ID" );
+ DBG_ASSERT( !::get_flag( nTokenClass, static_cast< sal_uInt8 >( ~EXC_TOKCLASS_MASK ) ), "XclTokenArrayHelper::GetTokenId - invalid token class" );
+ return nBaseId | nTokenClass;
+}
+
+inline void XclTokenArrayHelper::ChangeTokenClass( sal_uInt8& rnTokenId, sal_uInt8 nTokenClass )
+{
+ DBG_ASSERT( !::get_flag( nTokenClass, static_cast< sal_uInt8 >( ~EXC_TOKCLASS_MASK ) ), "XclTokenArrayHelper::ChangeTokenClass - invalid token class" );
+ ::set_flag( rnTokenId, EXC_TOKCLASS_MASK, false );
+ ::set_flag( rnTokenId, nTokenClass );
+}
+
+// ============================================================================
+
+#endif
+
diff --git a/sc/source/filter/starcalc/scflt.cxx b/sc/source/filter/starcalc/scflt.cxx index 05b0bdc8259a..bbbae5e89d5f 100644 --- a/sc/source/filter/starcalc/scflt.cxx +++ b/sc/source/filter/starcalc/scflt.cxx @@ -1690,7 +1690,7 @@ void Sc10Import::LoadCol(SCCOL Col, SCTAB Tab) s[0] = '='; s[Len + 1] = 0; ScFormulaCell* pCell = new ScFormulaCell( pDoc, ScAddress( Col, static_cast<SCROW> (Row), Tab ) ); - pCell->SetHybridFormula( SC10TOSTRING( s ), ScGrammar::GRAM_NATIVE ); + pCell->SetHybridFormula( SC10TOSTRING( s ),formula::FormulaGrammar::GRAM_NATIVE ); pDoc->PutCell( Col, static_cast<SCROW> (Row), Tab, pCell, (BOOL)TRUE ); break; } diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx index 9d1c8375b53b..77994ed77a65 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -1388,7 +1388,7 @@ void XclDelta::SaveXml( XclExpXmlStream& rStrm ) XclRefmode::XclRefmode( const ScDocument& rDoc ) : - XclExpBoolRecord( 0x000F, rDoc.GetAddressConvention() != ScAddress::CONV_XL_R1C1 ) + XclExpBoolRecord( 0x000F, rDoc.GetAddressConvention() != formula::FormulaGrammar::CONV_XL_R1C1 ) { } diff --git a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx index 8abb1573aaa7..b66578c8593f 100644 --- a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx @@ -397,8 +397,8 @@ void ScChangeTrackingExportHelper::WriteFormulaCell(const ScBaseCell* pCell, con const ScDocument* pDoc = rExport.GetDocument(); ScRangeStringConverter::GetStringFromAddress(sAddress, pFormulaCell->aPos, pDoc); rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CELL_ADDRESS, sAddress); - const ScGrammar::Grammar eGrammar = pDoc->GetStorageGrammar(); - sal_uInt16 nNamespacePrefix = (eGrammar == ScGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC); + const formula::FormulaGrammar::Grammar eGrammar = pDoc->GetStorageGrammar(); + sal_uInt16 nNamespacePrefix = (eGrammar == formula::FormulaGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC); String sFormula; pFormulaCell->GetFormula(sFormula, eGrammar); rtl::OUString sOUFormula(sFormula); diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx index 302bd51f5038..aec80af1bc8a 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: XMLChangeTrackingImportHelper.cxx,v $ - * $Revision: 1.29.32.2 $ + * $Revision: 1.30 $ * * This file is part of OpenOffice.org. * @@ -43,8 +43,22 @@ #define SC_CHANGE_ID_PREFIX "ct" +ScMyCellInfo::ScMyCellInfo() + : pCell(NULL), + sFormulaAddress(), + sFormula(), + sInputString(), + fValue(0.0), + nMatrixCols(0), + nMatrixRows(0), + eGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT), + nType(NUMBERFORMAT_ALL), + nMatrixFlag(MM_NONE) +{ +} + ScMyCellInfo::ScMyCellInfo(ScBaseCell* pTempCell, const rtl::OUString& rFormulaAddress, const rtl::OUString& rFormula, - const ScGrammar::Grammar eTempGrammar, const rtl::OUString& rInputString, + const formula::FormulaGrammar::Grammar eTempGrammar, const rtl::OUString& rInputString, const double& rValue, const sal_uInt16 nTempType, const sal_uInt8 nTempMatrixFlag, const sal_Int32 nTempMatrixCols, const sal_Int32 nTempMatrixRows) : pCell(pTempCell), @@ -775,7 +789,7 @@ void ScXMLChangeTrackingImportHelper::SetNewCell(ScMyContentAction* pAction) /* FIXME: new cell should be created with a clone * of the token array instead. Any reason why this * wasn't done? */ - static_cast<ScFormulaCell*>(pCell)->GetFormula(sFormula, ScGrammar::GRAM_ODFF); + static_cast<ScFormulaCell*>(pCell)->GetFormula(sFormula,formula::FormulaGrammar::GRAM_ODFF); rtl::OUString sOUFormula(sFormula); // #i87826# [Collaboration] Rejected move destroys formulas @@ -792,7 +806,7 @@ void ScXMLChangeTrackingImportHelper::SetNewCell(ScMyContentAction* pAction) } String sFormula2(sOUFormula2); - pNewCell = new ScFormulaCell(pDoc, aAddress, sFormula2, ScGrammar::GRAM_ODFF, nMatrixFlag); + pNewCell = new ScFormulaCell(pDoc, aAddress, sFormula2,formula::FormulaGrammar::GRAM_ODFF, nMatrixFlag); if (pNewCell) { if (nMatrixFlag == MM_FORMULA) diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx index 339eed189613..c675a9f7df59 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx @@ -55,12 +55,12 @@ struct ScMyCellInfo double fValue; sal_Int32 nMatrixCols; sal_Int32 nMatrixRows; - ScGrammar::Grammar eGrammar; + formula::FormulaGrammar::Grammar eGrammar; sal_uInt16 nType; sal_uInt8 nMatrixFlag; ScMyCellInfo(ScBaseCell* pCell, const rtl::OUString& sFormulaAddress, const rtl::OUString& sFormula, - const ScGrammar::Grammar eGrammar, const rtl::OUString& sInputString, + const formula::FormulaGrammar::Grammar eGrammar, const rtl::OUString& sInputString, const double& fValue, const sal_uInt16 nType, const sal_uInt8 nMatrixFlag, const sal_Int32 nMatrixCols, const sal_Int32 nMatrixRows); ~ScMyCellInfo(); diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx index 32766c1b1897..c38c01f7efec 100644 --- a/sc/source/filter/xml/XMLStylesExportHelper.cxx +++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx @@ -1,1245 +1,1245 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: XMLStylesExportHelper.cxx,v $ - * $Revision: 1.52 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - - -// INCLUDE --------------------------------------------------------------- -#include "XMLStylesExportHelper.hxx" -#include "global.hxx" -#include "unonames.hxx" -#include "XMLConverter.hxx" -#include "xmlexprt.hxx" -#include "document.hxx" -#include "rangeutl.hxx" -#include <xmloff/xmltoken.hxx> -#include <xmloff/xmlnmspe.hxx> -#include <xmloff/XMLEventExport.hxx> -#include <xmloff/nmspmap.hxx> -#include <tools/debug.hxx> -#include <com/sun/star/uno/Reference.h> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/sheet/XSheetCondition.hpp> -#include <com/sun/star/sheet/TableValidationVisibility.hpp> -#include <comphelper/extract.hxx> -#include <sfx2/app.hxx> - -#include <algorithm> - -using namespace com::sun::star; -using namespace xmloff::token; - -ScMyValidation::ScMyValidation() - : sName(), - sErrorMessage(), - sErrorTitle(), - sImputMessage(), - sImputTitle(), - sFormula1(), - sFormula2(), - bShowErrorMessage(sal_False), - bShowImputMessage(sal_False), - bIgnoreBlanks(sal_False) -{ -} - -ScMyValidation::~ScMyValidation() -{ -} - -sal_Bool ScMyValidation::IsEqual(const ScMyValidation& aVal) const -{ - if (aVal.bIgnoreBlanks == bIgnoreBlanks && - aVal.bShowImputMessage == bShowImputMessage && - aVal.bShowErrorMessage == bShowErrorMessage && - aVal.aBaseCell.Sheet == aBaseCell.Sheet && - aVal.aBaseCell.Column == aBaseCell.Column && - aVal.aBaseCell.Row == aBaseCell.Row && - aVal.aAlertStyle == aAlertStyle && - aVal.aValidationType == aValidationType && - aVal.aOperator == aOperator && - aVal.sErrorTitle == sErrorTitle && - aVal.sImputTitle == sImputTitle && - aVal.sErrorMessage == sErrorMessage && - aVal.sImputMessage == sImputMessage && - aVal.sFormula1 == sFormula1 && - aVal.sFormula2 == sFormula2) - return sal_True; - else - return sal_False; -} - -ScMyValidationsContainer::ScMyValidationsContainer() - : aValidationVec(), - sEmptyString(), - sERRALSTY(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRALSTY)), - sIGNOREBL(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_IGNOREBL)), - sSHOWLIST(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWLIST)), - sTYPE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_TYPE)), - sSHOWINP(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWINP)), - sSHOWERR(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWERR)), - sINPTITLE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INPTITLE)), - sINPMESS(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INPMESS)), - sERRTITLE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRTITLE)), - sERRMESS(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRMESS)), - sOnError(RTL_CONSTASCII_USTRINGPARAM("OnError")), - sEventType(RTL_CONSTASCII_USTRINGPARAM("EventType")), - sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic")), - sScript(RTL_CONSTASCII_USTRINGPARAM("Script")), - sLibrary(RTL_CONSTASCII_USTRINGPARAM("Library")), - sMacroName(RTL_CONSTASCII_USTRINGPARAM("MacroName")) -{ -} - -ScMyValidationsContainer::~ScMyValidationsContainer() -{ -} - -sal_Bool ScMyValidationsContainer::AddValidation(const uno::Any& aTempAny, - sal_Int32& nValidationIndex) -{ - sal_Bool bAdded(sal_False); - uno::Reference<beans::XPropertySet> xPropertySet(aTempAny, uno::UNO_QUERY); - if (xPropertySet.is()) - { - rtl::OUString sErrorMessage; - xPropertySet->getPropertyValue(sERRMESS) >>= sErrorMessage; - rtl::OUString sErrorTitle; - xPropertySet->getPropertyValue(sERRTITLE) >>= sErrorTitle; - rtl::OUString sImputMessage; - xPropertySet->getPropertyValue(sINPMESS) >>= sImputMessage; - rtl::OUString sImputTitle; - xPropertySet->getPropertyValue(sINPTITLE) >>= sImputTitle; - sal_Bool bShowErrorMessage = ::cppu::any2bool(xPropertySet->getPropertyValue(sSHOWERR)); - sal_Bool bShowImputMessage = ::cppu::any2bool(xPropertySet->getPropertyValue(sSHOWINP)); - sheet::ValidationType aValidationType; - xPropertySet->getPropertyValue(sTYPE) >>= aValidationType; - if (bShowErrorMessage || bShowImputMessage || aValidationType != sheet::ValidationType_ANY || - sErrorMessage.getLength() || sErrorTitle.getLength() || sImputMessage.getLength() || sImputTitle.getLength()) - { - ScMyValidation aValidation; - aValidation.sErrorMessage = sErrorMessage; - aValidation.sErrorTitle = sErrorTitle; - aValidation.sImputMessage = sImputMessage; - aValidation.sImputTitle = sImputTitle; - aValidation.bShowErrorMessage = bShowErrorMessage; - aValidation.bShowImputMessage = bShowImputMessage; - aValidation.aValidationType = aValidationType; - aValidation.bIgnoreBlanks = ::cppu::any2bool(xPropertySet->getPropertyValue(sIGNOREBL)); - xPropertySet->getPropertyValue(sSHOWLIST) >>= aValidation.nShowList; - xPropertySet->getPropertyValue(sERRALSTY) >>= aValidation.aAlertStyle; - uno::Reference<sheet::XSheetCondition> xCondition(xPropertySet, uno::UNO_QUERY); - if (xCondition.is()) - { - aValidation.sFormula1 = xCondition->getFormula1(); - aValidation.sFormula2 = xCondition->getFormula2(); - aValidation.aOperator = xCondition->getOperator(); - aValidation.aBaseCell = xCondition->getSourcePosition(); - } - //ScMyValidationRange aValidationRange; - sal_Bool bEqualFound(sal_False); - sal_Int32 i(0); - sal_Int32 nCount(aValidationVec.size()); - while (i < nCount && !bEqualFound) - { - bEqualFound = aValidationVec[i].IsEqual(aValidation); - if (!bEqualFound) - ++i; - } - if (bEqualFound) - nValidationIndex = i; - else - { - sal_Int32 nNameIndex(nCount + 1); - rtl::OUString sCount(rtl::OUString::valueOf(nNameIndex)); - rtl::OUString sPrefix(RTL_CONSTASCII_USTRINGPARAM("val")); - aValidation.sName += sPrefix; - aValidation.sName += sCount; - aValidationVec.push_back(aValidation); - nValidationIndex = nCount; - bAdded = sal_True; - } - } - } - return bAdded; -} - -rtl::OUString ScMyValidationsContainer::GetCondition(ScXMLExport& rExport, const ScMyValidation& aValidation) -{ - rtl::OUString sCondition; - if (aValidation.aValidationType != sheet::ValidationType_ANY) - { - switch (aValidation.aValidationType) - { - //case sheet::ValidationType_CUSTOM - case sheet::ValidationType_DATE : - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-date()")); - break; - case sheet::ValidationType_DECIMAL : - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-decimal-number()")); - break; - case sheet::ValidationType_LIST : - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-in-list(")); - sCondition += aValidation.sFormula1; - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")); - break; - case sheet::ValidationType_TEXT_LEN : - if (aValidation.aOperator != sheet::ConditionOperator_BETWEEN && - aValidation.aOperator != sheet::ConditionOperator_NOT_BETWEEN) - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length()")); - break; - case sheet::ValidationType_TIME : - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-time()")); - break; - case sheet::ValidationType_WHOLE : - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-whole-number()")); - break; - default: - { - // added to avoid warnings - } - } - if (aValidation.aValidationType != sheet::ValidationType_LIST && - (aValidation.sFormula1.getLength() || - (aValidation.aOperator == sheet::ConditionOperator_BETWEEN && - aValidation.aOperator == sheet::ConditionOperator_NOT_BETWEEN && - aValidation.sFormula2.getLength()))) - { - if (aValidation.aValidationType != sheet::ValidationType_TEXT_LEN) - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" and ")); - if (aValidation.aOperator != sheet::ConditionOperator_BETWEEN && - aValidation.aOperator != sheet::ConditionOperator_NOT_BETWEEN) - { - if (aValidation.aValidationType != sheet::ValidationType_TEXT_LEN) - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content()")); - switch (aValidation.aOperator) - { - case sheet::ConditionOperator_EQUAL : - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=")); - break; - case sheet::ConditionOperator_GREATER : - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">")); - break; - case sheet::ConditionOperator_GREATER_EQUAL : - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">=")); - break; - case sheet::ConditionOperator_LESS : - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<")); - break; - case sheet::ConditionOperator_LESS_EQUAL : - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<=")); - break; - case sheet::ConditionOperator_NOT_EQUAL : - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("!=")); - break; - default: - { - // added to avoid warnings - } - } - sCondition += aValidation.sFormula1; - } - else - { - if (aValidation.aValidationType == sheet::ValidationType_TEXT_LEN) - { - if (aValidation.aOperator == sheet::ConditionOperator_BETWEEN) - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-between(")); - else - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-not-between(")); - } - else - { - if (aValidation.aOperator == sheet::ConditionOperator_BETWEEN) - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-between(")); - else - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-not-between(")); - } - sCondition += aValidation.sFormula1; - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(",")); - sCondition += aValidation.sFormula2; - sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")); - } - } - else - if (aValidation.aValidationType == sheet::ValidationType_TEXT_LEN) - sCondition = rtl::OUString(); - } - if (sCondition.getLength()) - { - const ScGrammar::Grammar eGrammar = rExport.GetDocument()->GetStorageGrammar(); - sal_uInt16 nNamespacePrefix = (eGrammar == ScGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC); - sCondition = rExport.GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sCondition, sal_False ); - } - - return sCondition; -} - -rtl::OUString ScMyValidationsContainer::GetBaseCellAddress(ScDocument* pDoc, const table::CellAddress& aCell) -{ - rtl::OUString sAddress; - ScRangeStringConverter::GetStringFromAddress( sAddress, aCell, pDoc ); - return sAddress; -} - -void ScMyValidationsContainer::WriteMessage(ScXMLExport& rExport, - const rtl::OUString& sTitle, const rtl::OUString& sOUMessage, - const sal_Bool bShowMessage, const sal_Bool bIsHelpMessage) -{ - if (sTitle.getLength()) - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TITLE, sTitle); - if (bShowMessage) - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TRUE); - else - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, XML_FALSE); - SvXMLElementExport* pMessage(NULL); - if (bIsHelpMessage) - pMessage = new SvXMLElementExport(rExport, XML_NAMESPACE_TABLE, XML_HELP_MESSAGE, sal_True, sal_True); - else - pMessage = new SvXMLElementExport(rExport, XML_NAMESPACE_TABLE, XML_ERROR_MESSAGE, sal_True, sal_True); - if (sOUMessage.getLength()) - { - sal_Int32 i(0); - rtl::OUStringBuffer sTemp; - String sMessage(sOUMessage); - rtl::OUString sText (sMessage.ConvertLineEnd(LINEEND_LF)); - sal_Bool bPrevCharWasSpace(sal_True); - while(i < sText.getLength()) - { - if ((sText[i] == '\n')) - { - SvXMLElementExport aElemP(rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False); - rExport.GetTextParagraphExport()->exportText(sTemp.makeStringAndClear(), bPrevCharWasSpace); - } - else - sTemp.append(sText[i]); - ++i; - } - if (sTemp.getLength()) - { - SvXMLElementExport aElemP(rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False); - rExport.GetTextParagraphExport()->exportText(sTemp.makeStringAndClear(), bPrevCharWasSpace); - } - } - if (pMessage) - delete pMessage; -} - -void ScMyValidationsContainer::WriteValidations(ScXMLExport& rExport) -{ - if (aValidationVec.size()) - { - SvXMLElementExport aElemVs(rExport, XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATIONS, sal_True, sal_True); - ScMyValidationVec::iterator aItr(aValidationVec.begin()); - ScMyValidationVec::iterator aEndItr(aValidationVec.end()); - while (aItr != aEndItr) - { - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, aItr->sName); - rtl::OUString sCondition(GetCondition(rExport, *aItr)); - if (sCondition.getLength()) - { - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONDITION, sCondition); - if (aItr->bIgnoreBlanks) - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_TRUE); - else - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_FALSE); - if (aItr->aValidationType == sheet::ValidationType_LIST) - { - switch (aItr->nShowList) - { - case sheet::TableValidationVisibility::INVISIBLE: - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_NO); - break; - case sheet::TableValidationVisibility::UNSORTED: - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_UNSORTED); - break; - case sheet::TableValidationVisibility::SORTEDASCENDING: - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_SORTED_ASCENDING); - break; - default: - DBG_ERROR("unknown ListType"); - } - } - } - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, GetBaseCellAddress(rExport.GetDocument(), aItr->aBaseCell)); - SvXMLElementExport aElemV(rExport, XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION, sal_True, sal_True); - if (aItr->bShowImputMessage || aItr->sImputMessage.getLength() || aItr->sImputTitle.getLength()) - { - WriteMessage(rExport, aItr->sImputTitle, aItr->sImputMessage, aItr->bShowImputMessage, sal_True); - } - if (aItr->bShowErrorMessage || aItr->sErrorMessage.getLength() || aItr->sErrorTitle.getLength()) - { - switch (aItr->aAlertStyle) - { - case sheet::ValidationAlertStyle_INFO : - { - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_INFORMATION); - WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False); - } - break; - case sheet::ValidationAlertStyle_WARNING : - { - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_WARNING); - WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False); - } - break; - case sheet::ValidationAlertStyle_STOP : - { - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_STOP); - WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False); - } - break; - case sheet::ValidationAlertStyle_MACRO : - { - { - //rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, aItr->sErrorTitle); - if (aItr->bShowErrorMessage) - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_EXECUTE, XML_TRUE); - else - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_EXECUTE, XML_FALSE); - SvXMLElementExport aEMElem(rExport, XML_NAMESPACE_TABLE, XML_ERROR_MACRO, sal_True, sal_True); - } - { - // #i47525# for a script URL the type and the property name for the URL - // are both "Script", for a simple macro name the type is "StarBasic" - // and the property name is "MacroName". - bool bScriptURL = SfxApplication::IsXScriptURL( aItr->sErrorTitle ); - - uno::Sequence<beans::PropertyValue> aSeq(3); - beans::PropertyValue* pArr(aSeq.getArray()); - pArr[0].Name = sEventType; - pArr[0].Value <<= bScriptURL ? sScript : sStarBasic; - pArr[1].Name = sLibrary; - pArr[1].Value <<= sEmptyString; - pArr[2].Name = bScriptURL ? sScript : sMacroName; - pArr[2].Value <<= aItr->sErrorTitle; - - // 2) export the sequence - rExport.GetEventExport().ExportSingleEvent( aSeq, sOnError); - } - } - break; - default: - { - // added to avoid warnings - } - } - } - ++aItr; - } - } -} - -const rtl::OUString& ScMyValidationsContainer::GetValidationName(const sal_Int32 nIndex) -{ - DBG_ASSERT( static_cast<size_t>(nIndex) < aValidationVec.size(), "out of range" ); - return aValidationVec[nIndex].sName; -} - -//============================================================================== - -sal_Int32 ScMyDefaultStyles::GetStyleNameIndex(const ScFormatRangeStyles* pCellStyles, - const sal_Int32 nTable, const sal_Int32 nPos, - const sal_Int32 i, const sal_Bool bRow, sal_Bool& bIsAutoStyle) -{ - if (bRow) - return pCellStyles->GetStyleNameIndex(nTable, nPos, i, - bIsAutoStyle); - else - return pCellStyles->GetStyleNameIndex(nTable, i, nPos, - bIsAutoStyle); -} - -void ScMyDefaultStyles::FillDefaultStyles(const sal_Int32 nTable, - const sal_Int32 nLastRow, const sal_Int32 nLastCol, - const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc, - const sal_Bool bRow) -{ - if (pDoc) - { - SCTAB nTab = static_cast<SCTAB>(nTable); - sal_Int32 nPos; - sal_Int32 nLast; - ScMyDefaultStyleList* pDefaults; - if (bRow) - { - pDefaults = pRowDefaults; - nLast = nLastRow; - } - else - { - pDefaults = pColDefaults; - nLast = nLastCol; - } - sal_Bool bPrevAutoStyle(sal_False); - sal_Bool bIsAutoStyle; - sal_Bool bResult; - sal_Int32 nPrevIndex(0); - sal_Int32 nIndex; - sal_Int32 nRepeat(0); - sal_Int32 nEmptyRepeat(0); - for (sal_Int32 i = nLast; i >= 0; --i) - { - if (bRow) - { - SCCOL nCol; - bResult = pDoc->GetRowDefault(nTab, - static_cast<SCROW>(i), static_cast<SCCOL>(nLastCol), nCol); - nPos = static_cast<sal_Int32>(nCol); - } - else - { - SCROW nRow; - bResult = pDoc->GetColDefault(nTab, - static_cast<SCCOL>(i), static_cast<SCROW>(nLastRow), nRow); - nPos = static_cast<sal_Int32>(nRow); - } - if (bResult) - { - nEmptyRepeat = 0; - if (!nRepeat) - { - nPrevIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i, - bRow, bPrevAutoStyle); - (*pDefaults)[i].nIndex = nPrevIndex; - (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle; - nRepeat = 1; - } - else - { - nIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i, - bRow, bIsAutoStyle); - if ((nIndex != nPrevIndex) || (bIsAutoStyle != bPrevAutoStyle)) - { - nRepeat = 1; - nPrevIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i, - bRow, bPrevAutoStyle); - (*pDefaults)[i].nIndex = nPrevIndex; - (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle; - } - else - { - (*pDefaults)[i].nIndex = nPrevIndex; - (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle; - ++nRepeat; - if (nRepeat > 1) - (*pDefaults)[i].nRepeat = nRepeat; - } - } - } - else - { - nRepeat = 0; - if (!nEmptyRepeat) - nEmptyRepeat = 1; - else - { - ++nEmptyRepeat; - if (nEmptyRepeat > 1) - (*pDefaults)[i].nRepeat = nEmptyRepeat; - } - } - } - } -} - -void ScMyDefaultStyles::FillDefaultStyles(const sal_Int32 nTable, - const sal_Int32 nLastRow, const sal_Int32 nLastCol, - const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc) -{ - if (pRowDefaults) - delete pRowDefaults; - pRowDefaults = new ScMyDefaultStyleList(nLastRow + 1); - FillDefaultStyles(nTable, nLastRow, nLastCol, pCellStyles, pDoc, sal_True); - if (pColDefaults) - delete pColDefaults; - pColDefaults = new ScMyDefaultStyleList(nLastCol + 1); - FillDefaultStyles(nTable, nLastRow, nLastCol, pCellStyles, pDoc, sal_False); -} - -ScMyDefaultStyles::~ScMyDefaultStyles() -{ - if (pRowDefaults) - delete pRowDefaults; - if (pColDefaults) - delete pColDefaults; -} - -ScMyRowFormatRange::ScMyRowFormatRange() - : nStartColumn(0), - nRepeatColumns(0), - nRepeatRows(0), - nIndex(-1), - nValidationIndex(-1), - bIsAutoStyle(sal_True) -{ -} - -sal_Bool ScMyRowFormatRange::operator< (const ScMyRowFormatRange& rRange) const -{ - return (nStartColumn < rRange.nStartColumn); -} - -ScRowFormatRanges::ScRowFormatRanges() - : aRowFormatRanges(), - pRowDefaults(NULL), - pColDefaults(NULL), - nSize(0) -{ -} - -ScRowFormatRanges::ScRowFormatRanges(const ScRowFormatRanges* pRanges) - : aRowFormatRanges(pRanges->aRowFormatRanges), - pRowDefaults(pRanges->pRowDefaults), - pColDefaults(pRanges->pColDefaults), - nSize(pRanges->nSize) -{ -} - -ScRowFormatRanges::~ScRowFormatRanges() -{ -} - -void ScRowFormatRanges::Clear() -{ - aRowFormatRanges.clear(); - nSize = 0; -} - -void ScRowFormatRanges::AddRange(const sal_Int32 nPrevStartCol, const sal_Int32 nRepeat, const sal_Int32 nPrevIndex, - const sal_Bool bPrevAutoStyle, const ScMyRowFormatRange& rFormatRange) -{ - sal_Int32 nIndex(-1); - if ((nPrevIndex != rFormatRange.nIndex) || - (bPrevAutoStyle != rFormatRange.bIsAutoStyle)) - nIndex = rFormatRange.nIndex; - - sal_Bool bInserted(sal_False); - if (!aRowFormatRanges.empty()) - { - ScMyRowFormatRange* pRange(&aRowFormatRanges.back()); - if (pRange) - { - if ((nPrevStartCol == (pRange->nStartColumn + pRange->nRepeatColumns)) && - (pRange->bIsAutoStyle == rFormatRange.bIsAutoStyle) && - (pRange->nIndex == nIndex) && - (pRange->nValidationIndex == rFormatRange.nValidationIndex)) - { - if (rFormatRange.nRepeatRows < pRange->nRepeatRows) - pRange->nRepeatRows = rFormatRange.nRepeatRows; - pRange->nRepeatColumns += nRepeat; - bInserted = sal_True; - } - } - } - if (!bInserted) - { - ScMyRowFormatRange aRange; - aRange.nStartColumn = nPrevStartCol; - aRange.nRepeatColumns = nRepeat; - aRange.nRepeatRows = rFormatRange.nRepeatRows; - aRange.nValidationIndex = rFormatRange.nValidationIndex; - aRange.bIsAutoStyle = rFormatRange.bIsAutoStyle; - aRange.nIndex = nIndex; - aRowFormatRanges.push_back(aRange); - ++nSize; - } -} - -void ScRowFormatRanges::AddRange(ScMyRowFormatRange& rFormatRange, - const sal_Int32 nRow) -{ - DBG_ASSERT(pRowDefaults, "no row defaults"); - DBG_ASSERT(pColDefaults, "no column defaults"); - sal_uInt32 nEnd (rFormatRange.nRepeatRows + nRow - 1); - sal_Int32 nPrevIndex((*pRowDefaults)[nRow].nIndex); - sal_Bool bPrevAutoStyle((*pRowDefaults)[nRow].bIsAutoStyle); - sal_uInt32 i(nRow + 1); - sal_Bool bReady(sal_False); - while ((i < nEnd) && !bReady && (i < pRowDefaults->size())) - { - if ((nPrevIndex != (*pRowDefaults)[i].nIndex) || - (bPrevAutoStyle != (*pRowDefaults)[i].bIsAutoStyle)) - bReady = sal_True; - else - i += (*pRowDefaults)[i].nRepeat; - } - if (i > nEnd) - i = nEnd; - if (bReady) - rFormatRange.nRepeatRows = i - nRow + 1; - if (nPrevIndex == -1) - { - nPrevIndex = (*pColDefaults)[rFormatRange.nStartColumn].nIndex; - bPrevAutoStyle = (*pColDefaults)[rFormatRange.nStartColumn].bIsAutoStyle; - sal_uInt32 nPrevStartCol(rFormatRange.nStartColumn); - sal_uInt32 nRepeat((*pColDefaults)[rFormatRange.nStartColumn].nRepeat); - nEnd = rFormatRange.nStartColumn + rFormatRange.nRepeatColumns; - for(i = nPrevStartCol + nRepeat; i < nEnd; i += (*pColDefaults)[i].nRepeat) - { - DBG_ASSERT(sal_uInt32(nPrevStartCol + nRepeat) <= nEnd, "something wents wrong"); - if ((nPrevIndex != (*pColDefaults)[i].nIndex) || - (bPrevAutoStyle != (*pColDefaults)[i].bIsAutoStyle)) - { - AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange); - nPrevStartCol = i; - nRepeat = (*pColDefaults)[i].nRepeat; - nPrevIndex = (*pColDefaults)[i].nIndex; - bPrevAutoStyle = (*pColDefaults)[i].bIsAutoStyle; - } - else - nRepeat += (*pColDefaults)[i].nRepeat; - } - if (sal_uInt32(nPrevStartCol + nRepeat) > nEnd) - nRepeat = nEnd - nPrevStartCol; - AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange); - } - else if ((nPrevIndex == rFormatRange.nIndex) && - (bPrevAutoStyle == rFormatRange.bIsAutoStyle)) - { - rFormatRange.nIndex = -1; - aRowFormatRanges.push_back(rFormatRange); - ++nSize; - } -} - -sal_Bool ScRowFormatRanges::GetNext(ScMyRowFormatRange& aFormatRange) -{ - ScMyRowFormatRangesList::iterator aItr(aRowFormatRanges.begin()); - if (aItr != aRowFormatRanges.end()) - { - aFormatRange = (*aItr); - aRowFormatRanges.erase(aItr); - --nSize; - return sal_True; - } - return sal_False; -} - -sal_Int32 ScRowFormatRanges::GetMaxRows() -{ - ScMyRowFormatRangesList::iterator aItr(aRowFormatRanges.begin()); - ScMyRowFormatRangesList::iterator aEndItr(aRowFormatRanges.end()); - sal_Int32 nMaxRows = MAXROW + 1; - if (aItr != aEndItr) - while (aItr != aEndItr) - { - if ((*aItr).nRepeatRows < nMaxRows) - nMaxRows = (*aItr).nRepeatRows; - ++aItr; - } - else - { - DBG_ERROR("no ranges found"); - } - return nMaxRows; -} - -sal_Int32 ScRowFormatRanges::GetSize() -{ - return nSize; -} - -void ScRowFormatRanges::Sort() -{ - aRowFormatRanges.sort(); -} - -// ============================================================================ -ScMyFormatRange::ScMyFormatRange() - : nStyleNameIndex(-1), - nValidationIndex(-1), - bIsAutoStyle(sal_True) -{ -} - -sal_Bool ScMyFormatRange::operator<(const ScMyFormatRange& rRange) const -{ - if (aRangeAddress.StartRow < rRange.aRangeAddress.StartRow) - return sal_True; - else - if (aRangeAddress.StartRow == rRange.aRangeAddress.StartRow) - return (aRangeAddress.StartColumn < rRange.aRangeAddress.StartColumn); - else - return sal_False; -} - -ScFormatRangeStyles::ScFormatRangeStyles() - : aTables(), - aStyleNames(), - aAutoStyleNames() -{ -} - -ScFormatRangeStyles::~ScFormatRangeStyles() -{ - ScMyOUStringVec::iterator i(aStyleNames.begin()); - ScMyOUStringVec::iterator endi(aStyleNames.end()); - while (i != endi) - { - delete *i; - ++i; - } - i = aAutoStyleNames.begin(); - endi = aAutoStyleNames.end(); - while (i != endi) - { - delete *i; - ++i; - } - ScMyFormatRangeListVec::iterator j(aTables.begin()); - ScMyFormatRangeListVec::iterator endj(aTables.end()); - while (j != endj) - { - delete *j; - ++j; - } -} - -void ScFormatRangeStyles::AddNewTable(const sal_Int32 nTable) -{ - sal_Int32 nSize = aTables.size() - 1; - if (nTable > nSize) - for (sal_Int32 i = nSize; i < nTable; ++i) - { - ScMyFormatRangeAddresses* aRangeAddresses(new ScMyFormatRangeAddresses); - aTables.push_back(aRangeAddresses); - } -} - -sal_Bool ScFormatRangeStyles::AddStyleName(rtl::OUString* rpString, sal_Int32& rIndex, const sal_Bool bIsAutoStyle) -{ - if (bIsAutoStyle) - { - aAutoStyleNames.push_back(rpString); - rIndex = aAutoStyleNames.size() - 1; - return sal_True; - } - else - { - sal_Int32 nCount(aStyleNames.size()); - sal_Bool bFound(sal_False); - sal_Int32 i(nCount - 1); - while ((i >= 0) && (!bFound)) - { - if (aStyleNames.at(i)->equals(*rpString)) - bFound = sal_True; - else - i--; - } - if (bFound) - { - rIndex = i; - return sal_False; - } - else - { - aStyleNames.push_back(rpString); - rIndex = aStyleNames.size() - 1; - return sal_True; - } - } -} - -sal_Int32 ScFormatRangeStyles::GetIndexOfStyleName(const rtl::OUString& rString, const rtl::OUString& rPrefix, sal_Bool& bIsAutoStyle) -{ - sal_Int32 nPrefixLength(rPrefix.getLength()); - rtl::OUString sTemp(rString.copy(nPrefixLength)); - sal_Int32 nIndex(sTemp.toInt32()); - if (aAutoStyleNames.at(nIndex - 1)->equals(rString)) - { - bIsAutoStyle = sal_True; - return nIndex - 1; - } - else - { - sal_Int32 i(0); - sal_Bool bFound(sal_False); - while (!bFound && static_cast<size_t>(i) < aStyleNames.size()) - { - if (aStyleNames[i]->equals(rString)) - bFound = sal_True; - else - ++i; - } - if (bFound) - { - bIsAutoStyle = sal_False; - return i; - } - else - { - i = 0; - while (!bFound && static_cast<size_t>(i) < aAutoStyleNames.size()) - { - if (aAutoStyleNames[i]->equals(rString)) - bFound = sal_True; - else - ++i; - } - if (bFound) - { - bIsAutoStyle = sal_True; - return i; - } - else - return -1; - } - } -} - -sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_Int32 nTable, - const sal_Int32 nColumn, const sal_Int32 nRow, sal_Bool& bIsAutoStyle) const -{ - DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table"); - ScMyFormatRangeAddresses* pFormatRanges(aTables[nTable]); - ScMyFormatRangeAddresses::iterator aItr(pFormatRanges->begin()); - ScMyFormatRangeAddresses::iterator aEndItr(pFormatRanges->end()); - while (aItr != aEndItr) - { - if (((*aItr).aRangeAddress.StartColumn <= nColumn) && - ((*aItr).aRangeAddress.EndColumn >= nColumn) && - ((*aItr).aRangeAddress.StartRow <= nRow) && - ((*aItr).aRangeAddress.EndRow >= nRow)) - { - bIsAutoStyle = aItr->bIsAutoStyle; - return (*aItr).nStyleNameIndex; - } - else - ++aItr; - } - return -1; -} - -sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nColumn, const sal_Int32 nRow, - sal_Bool& bIsAutoStyle, sal_Int32& nValidationIndex, sal_Int32& nNumberFormat, const sal_Bool bRemoveRange) -{ - DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table"); - ScMyFormatRangeAddresses* pFormatRanges(aTables[nTable]); - ScMyFormatRangeAddresses::iterator aItr(pFormatRanges->begin()); - ScMyFormatRangeAddresses::iterator aEndItr(pFormatRanges->end()); - while (aItr != aEndItr) - { - if (((*aItr).aRangeAddress.StartColumn <= nColumn) && - ((*aItr).aRangeAddress.EndColumn >= nColumn) && - ((*aItr).aRangeAddress.StartRow <= nRow) && - ((*aItr).aRangeAddress.EndRow >= nRow)) - { - bIsAutoStyle = aItr->bIsAutoStyle; - nValidationIndex = aItr->nValidationIndex; - nNumberFormat = aItr->nNumberFormat; - if (((*pRowDefaults)[nRow].nIndex != -1)) - { - if (((*pRowDefaults)[nRow].nIndex == (*aItr).nStyleNameIndex) && - ((*pRowDefaults)[nRow].bIsAutoStyle == (*aItr).bIsAutoStyle)) - return -1; - else - return (*aItr).nStyleNameIndex; - } - else if (((*pColDefaults)[nColumn].nIndex != -1) && - ((*pColDefaults)[nColumn].nIndex == (*aItr).nStyleNameIndex) && - ((*pColDefaults)[nColumn].bIsAutoStyle == (*aItr).bIsAutoStyle)) - return -1; - else - return (*aItr).nStyleNameIndex; - } - else - { - if (bRemoveRange && (*aItr).aRangeAddress.EndRow < nRow) - aItr = pFormatRanges->erase(aItr); - else - ++aItr; - } - } - return -1; -} - -void ScFormatRangeStyles::GetFormatRanges(const sal_Int32 nStartColumn, const sal_Int32 nEndColumn, const sal_Int32 nRow, - const sal_Int32 nTable, ScRowFormatRanges* pRowFormatRanges) -{ - sal_Int32 nTotalColumns(nEndColumn - nStartColumn + 1); - DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table"); - ScMyFormatRangeAddresses* pFormatRanges(aTables[nTable]); - ScMyFormatRangeAddresses::iterator aItr(pFormatRanges->begin()); - ScMyFormatRangeAddresses::iterator aEndItr(pFormatRanges->end()); - sal_Int32 nColumns = 0; - while (aItr != aEndItr && nColumns < nTotalColumns) - { -#if OSL_DEBUG_LEVEL > 1 - table::CellRangeAddress aTempRangeAddress((*aItr).aRangeAddress); -#endif - if (((*aItr).aRangeAddress.StartRow <= nRow) && - ((*aItr).aRangeAddress.EndRow >= nRow)) - { - if ((((*aItr).aRangeAddress.StartColumn <= nStartColumn) && - ((*aItr).aRangeAddress.EndColumn >= nStartColumn)) || - (((*aItr).aRangeAddress.StartColumn <= nEndColumn) && - ((*aItr).aRangeAddress.EndColumn >= nEndColumn)) || - (((*aItr).aRangeAddress.StartColumn >= nStartColumn) && - ((*aItr).aRangeAddress.EndColumn <= nEndColumn))) - { - ScMyRowFormatRange aRange; - aRange.nIndex = aItr->nStyleNameIndex; - aRange.nValidationIndex = aItr->nValidationIndex; - aRange.bIsAutoStyle = aItr->bIsAutoStyle; - if ((aItr->aRangeAddress.StartColumn < nStartColumn) && - (aItr->aRangeAddress.EndColumn >= nStartColumn)) - { - if (aItr->aRangeAddress.EndColumn >= nEndColumn) - aRange.nRepeatColumns = nTotalColumns; - else - aRange.nRepeatColumns = aItr->aRangeAddress.EndColumn - nStartColumn + 1; - aRange.nStartColumn = nStartColumn; - } - else if ((aItr->aRangeAddress.StartColumn >= nStartColumn) && - (aItr->aRangeAddress.EndColumn <= nEndColumn)) - { - aRange.nRepeatColumns = aItr->aRangeAddress.EndColumn - aItr->aRangeAddress.StartColumn + 1; - aRange.nStartColumn = aItr->aRangeAddress.StartColumn; - } - else if ((aItr->aRangeAddress.StartColumn >= nStartColumn) && - (aItr->aRangeAddress.StartColumn <= nEndColumn) && - (aItr->aRangeAddress.EndColumn > nEndColumn)) - { - aRange.nRepeatColumns = nEndColumn - aItr->aRangeAddress.StartColumn + 1; - aRange.nStartColumn = aItr->aRangeAddress.StartColumn; - } - aRange.nRepeatRows = aItr->aRangeAddress.EndRow - nRow + 1; - pRowFormatRanges->AddRange(aRange, nRow); - nColumns += aRange.nRepeatColumns; - } - ++aItr; - } - else - if(aItr->aRangeAddress.EndRow < nRow) - aItr = pFormatRanges->erase(aItr); - else - ++aItr; - } - pRowFormatRanges->Sort(); -} - -void ScFormatRangeStyles::AddRangeStyleName(const table::CellRangeAddress aCellRangeAddress, - const sal_Int32 nStringIndex, const sal_Bool bIsAutoStyle, const sal_Int32 nValidationIndex, - const sal_Int32 nNumberFormat) -{ - ScMyFormatRange aFormatRange; - aFormatRange.aRangeAddress = aCellRangeAddress; - aFormatRange.nStyleNameIndex = nStringIndex; - aFormatRange.nValidationIndex = nValidationIndex; - aFormatRange.nNumberFormat = nNumberFormat; - aFormatRange.bIsAutoStyle = bIsAutoStyle; - DBG_ASSERT(static_cast<size_t>(aCellRangeAddress.Sheet) < aTables.size(), "wrong table"); - ScMyFormatRangeAddresses* pFormatRanges(aTables[aCellRangeAddress.Sheet]); - pFormatRanges->push_back(aFormatRange); -} - -rtl::OUString* ScFormatRangeStyles::GetStyleNameByIndex(const sal_Int32 nIndex, const sal_Bool bIsAutoStyle) -{ - if (bIsAutoStyle) - return aAutoStyleNames[nIndex]; - else - return aStyleNames[nIndex]; -} - -void ScFormatRangeStyles::Sort() -{ - sal_Int32 nTables = aTables.size(); - for (sal_Int16 i = 0; i < nTables; ++i) - if (!aTables[i]->empty()) - aTables[i]->sort(); -} - -//=========================================================================== - -ScColumnRowStylesBase::ScColumnRowStylesBase() - : aStyleNames() -{ -} - -ScColumnRowStylesBase::~ScColumnRowStylesBase() -{ - ScMyOUStringVec::iterator i(aStyleNames.begin()); - ScMyOUStringVec::iterator endi(aStyleNames.end()); - while (i != endi) - { - delete *i; - ++i; - } -} - -sal_Int32 ScColumnRowStylesBase::AddStyleName(rtl::OUString* pString) -{ - aStyleNames.push_back(pString); - return aStyleNames.size() - 1; -} - -sal_Int32 ScColumnRowStylesBase::GetIndexOfStyleName(const rtl::OUString& rString, const rtl::OUString& rPrefix) -{ - sal_Int32 nPrefixLength(rPrefix.getLength()); - rtl::OUString sTemp(rString.copy(nPrefixLength)); - sal_Int32 nIndex(sTemp.toInt32()); - if (aStyleNames.at(nIndex - 1)->equals(rString)) - return nIndex - 1; - else - { - sal_Int32 i(0); - sal_Bool bFound(sal_False); - while (!bFound && static_cast<size_t>(i) < aStyleNames.size()) - { - if (aStyleNames.at(i)->equals(rString)) - bFound = sal_True; - else - ++i; - } - if (bFound) - return i; - else - return -1; - } -} - -rtl::OUString* ScColumnRowStylesBase::GetStyleNameByIndex(const sal_Int32 nIndex) -{ - if ( nIndex < 0 || nIndex >= sal::static_int_cast<sal_Int32>( aStyleNames.size() ) ) - { - // #123981# should no longer happen, use first style then - DBG_ERRORFILE("GetStyleNameByIndex: invalid index"); - return aStyleNames[0]; - } - - return aStyleNames[nIndex]; -} - -//=========================================================================== - -ScColumnStyles::ScColumnStyles() - : ScColumnRowStylesBase(), - aTables() -{ -} - -ScColumnStyles::~ScColumnStyles() -{ -} - -void ScColumnStyles::AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) -{ - sal_Int32 nSize(aTables.size() - 1); - if (nTable > nSize) - for (sal_Int32 i = nSize; i < nTable; ++i) - { - ScMyColumnStyleVec aFieldsVec(nFields + 1, ScColumnStyle()); - aTables.push_back(aFieldsVec); - } -} - -sal_Int32 ScColumnStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField, - sal_Bool& bIsVisible) -{ - DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table"); - if (static_cast<size_t>(nField) < aTables[nTable].size()) - { - bIsVisible = aTables[nTable][nField].bIsVisible; - return aTables[nTable][nField].nIndex; - } - else - { - bIsVisible = aTables[nTable][aTables[nTable].size() - 1].bIsVisible; - return aTables[nTable][aTables[nTable].size() - 1].nIndex; - } -} - -void ScColumnStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, - const sal_Int32 nStringIndex, const sal_Bool bIsVisible) -{ - DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table"); - DBG_ASSERT(aTables[nTable].size() >= static_cast<sal_uInt32>(nField), "wrong field"); - ScColumnStyle aStyle; - aStyle.nIndex = nStringIndex; - aStyle.bIsVisible = bIsVisible; - if (aTables[nTable].size() == static_cast<sal_uInt32>(nField)) - aTables[nTable].push_back(aStyle); - aTables[nTable][nField] = aStyle; -} - -rtl::OUString* ScColumnStyles::GetStyleName(const sal_Int32 nTable, const sal_Int32 nField) -{ - sal_Bool bTemp; - return GetStyleNameByIndex(GetStyleNameIndex(nTable, nField, bTemp)); -} - -//=========================================================================== - -ScRowStyles::ScRowStyles() - : ScColumnRowStylesBase(), - aTables() -{ -} - -ScRowStyles::~ScRowStyles() -{ -} - -void ScRowStyles::AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) -{ - sal_Int32 nSize(aTables.size() - 1); - if (nTable > nSize) - for (sal_Int32 i = nSize; i < nTable; ++i) - { - ScMysalInt32Vec aFieldsVec(nFields + 1, -1); - aTables.push_back(aFieldsVec); - } -} - -sal_Int32 ScRowStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField) -{ - DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table"); - if (static_cast<size_t>(nField) < aTables[nTable].size()) - return aTables[nTable][nField]; - else - return aTables[nTable][aTables[nTable].size() - 1]; -} - -void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, - const sal_Int32 nStringIndex) -{ - DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table"); - DBG_ASSERT(aTables[nTable].size() >= static_cast<sal_uInt32>(nField), "wrong field"); - if (aTables[nTable].size() == static_cast<sal_uInt32>(nField)) - aTables[nTable].push_back(nStringIndex); - aTables[nTable][nField] = nStringIndex; -} - -rtl::OUString* ScRowStyles::GetStyleName(const sal_Int32 nTable, const sal_Int32 nField) -{ - return GetStyleNameByIndex(GetStyleNameIndex(nTable, nField)); -} +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: XMLStylesExportHelper.cxx,v $
+ * $Revision: 1.52 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+// INCLUDE ---------------------------------------------------------------
+#include "XMLStylesExportHelper.hxx"
+#include "global.hxx"
+#include "unonames.hxx"
+#include "XMLConverter.hxx"
+#include "xmlexprt.hxx"
+#include "document.hxx"
+#include "rangeutl.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/XMLEventExport.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSheetCondition.hpp>
+#include <com/sun/star/sheet/TableValidationVisibility.hpp>
+#include <comphelper/extract.hxx>
+#include <sfx2/app.hxx>
+
+#include <algorithm>
+
+using namespace com::sun::star;
+using namespace xmloff::token;
+
+ScMyValidation::ScMyValidation()
+ : sName(),
+ sErrorMessage(),
+ sErrorTitle(),
+ sImputMessage(),
+ sImputTitle(),
+ sFormula1(),
+ sFormula2(),
+ bShowErrorMessage(sal_False),
+ bShowImputMessage(sal_False),
+ bIgnoreBlanks(sal_False)
+{
+}
+
+ScMyValidation::~ScMyValidation()
+{
+}
+
+sal_Bool ScMyValidation::IsEqual(const ScMyValidation& aVal) const
+{
+ if (aVal.bIgnoreBlanks == bIgnoreBlanks &&
+ aVal.bShowImputMessage == bShowImputMessage &&
+ aVal.bShowErrorMessage == bShowErrorMessage &&
+ aVal.aBaseCell.Sheet == aBaseCell.Sheet &&
+ aVal.aBaseCell.Column == aBaseCell.Column &&
+ aVal.aBaseCell.Row == aBaseCell.Row &&
+ aVal.aAlertStyle == aAlertStyle &&
+ aVal.aValidationType == aValidationType &&
+ aVal.aOperator == aOperator &&
+ aVal.sErrorTitle == sErrorTitle &&
+ aVal.sImputTitle == sImputTitle &&
+ aVal.sErrorMessage == sErrorMessage &&
+ aVal.sImputMessage == sImputMessage &&
+ aVal.sFormula1 == sFormula1 &&
+ aVal.sFormula2 == sFormula2)
+ return sal_True;
+ else
+ return sal_False;
+}
+
+ScMyValidationsContainer::ScMyValidationsContainer()
+ : aValidationVec(),
+ sEmptyString(),
+ sERRALSTY(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRALSTY)),
+ sIGNOREBL(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_IGNOREBL)),
+ sSHOWLIST(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWLIST)),
+ sTYPE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_TYPE)),
+ sSHOWINP(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWINP)),
+ sSHOWERR(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWERR)),
+ sINPTITLE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INPTITLE)),
+ sINPMESS(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INPMESS)),
+ sERRTITLE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRTITLE)),
+ sERRMESS(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRMESS)),
+ sOnError(RTL_CONSTASCII_USTRINGPARAM("OnError")),
+ sEventType(RTL_CONSTASCII_USTRINGPARAM("EventType")),
+ sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic")),
+ sScript(RTL_CONSTASCII_USTRINGPARAM("Script")),
+ sLibrary(RTL_CONSTASCII_USTRINGPARAM("Library")),
+ sMacroName(RTL_CONSTASCII_USTRINGPARAM("MacroName"))
+{
+}
+
+ScMyValidationsContainer::~ScMyValidationsContainer()
+{
+}
+
+sal_Bool ScMyValidationsContainer::AddValidation(const uno::Any& aTempAny,
+ sal_Int32& nValidationIndex)
+{
+ sal_Bool bAdded(sal_False);
+ uno::Reference<beans::XPropertySet> xPropertySet(aTempAny, uno::UNO_QUERY);
+ if (xPropertySet.is())
+ {
+ rtl::OUString sErrorMessage;
+ xPropertySet->getPropertyValue(sERRMESS) >>= sErrorMessage;
+ rtl::OUString sErrorTitle;
+ xPropertySet->getPropertyValue(sERRTITLE) >>= sErrorTitle;
+ rtl::OUString sImputMessage;
+ xPropertySet->getPropertyValue(sINPMESS) >>= sImputMessage;
+ rtl::OUString sImputTitle;
+ xPropertySet->getPropertyValue(sINPTITLE) >>= sImputTitle;
+ sal_Bool bShowErrorMessage = ::cppu::any2bool(xPropertySet->getPropertyValue(sSHOWERR));
+ sal_Bool bShowImputMessage = ::cppu::any2bool(xPropertySet->getPropertyValue(sSHOWINP));
+ sheet::ValidationType aValidationType;
+ xPropertySet->getPropertyValue(sTYPE) >>= aValidationType;
+ if (bShowErrorMessage || bShowImputMessage || aValidationType != sheet::ValidationType_ANY ||
+ sErrorMessage.getLength() || sErrorTitle.getLength() || sImputMessage.getLength() || sImputTitle.getLength())
+ {
+ ScMyValidation aValidation;
+ aValidation.sErrorMessage = sErrorMessage;
+ aValidation.sErrorTitle = sErrorTitle;
+ aValidation.sImputMessage = sImputMessage;
+ aValidation.sImputTitle = sImputTitle;
+ aValidation.bShowErrorMessage = bShowErrorMessage;
+ aValidation.bShowImputMessage = bShowImputMessage;
+ aValidation.aValidationType = aValidationType;
+ aValidation.bIgnoreBlanks = ::cppu::any2bool(xPropertySet->getPropertyValue(sIGNOREBL));
+ xPropertySet->getPropertyValue(sSHOWLIST) >>= aValidation.nShowList;
+ xPropertySet->getPropertyValue(sERRALSTY) >>= aValidation.aAlertStyle;
+ uno::Reference<sheet::XSheetCondition> xCondition(xPropertySet, uno::UNO_QUERY);
+ if (xCondition.is())
+ {
+ aValidation.sFormula1 = xCondition->getFormula1();
+ aValidation.sFormula2 = xCondition->getFormula2();
+ aValidation.aOperator = xCondition->getOperator();
+ aValidation.aBaseCell = xCondition->getSourcePosition();
+ }
+ //ScMyValidationRange aValidationRange;
+ sal_Bool bEqualFound(sal_False);
+ sal_Int32 i(0);
+ sal_Int32 nCount(aValidationVec.size());
+ while (i < nCount && !bEqualFound)
+ {
+ bEqualFound = aValidationVec[i].IsEqual(aValidation);
+ if (!bEqualFound)
+ ++i;
+ }
+ if (bEqualFound)
+ nValidationIndex = i;
+ else
+ {
+ sal_Int32 nNameIndex(nCount + 1);
+ rtl::OUString sCount(rtl::OUString::valueOf(nNameIndex));
+ rtl::OUString sPrefix(RTL_CONSTASCII_USTRINGPARAM("val"));
+ aValidation.sName += sPrefix;
+ aValidation.sName += sCount;
+ aValidationVec.push_back(aValidation);
+ nValidationIndex = nCount;
+ bAdded = sal_True;
+ }
+ }
+ }
+ return bAdded;
+}
+
+rtl::OUString ScMyValidationsContainer::GetCondition(ScXMLExport& rExport, const ScMyValidation& aValidation)
+{
+ rtl::OUString sCondition;
+ if (aValidation.aValidationType != sheet::ValidationType_ANY)
+ {
+ switch (aValidation.aValidationType)
+ {
+ //case sheet::ValidationType_CUSTOM
+ case sheet::ValidationType_DATE :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-date()"));
+ break;
+ case sheet::ValidationType_DECIMAL :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-decimal-number()"));
+ break;
+ case sheet::ValidationType_LIST :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-in-list("));
+ sCondition += aValidation.sFormula1;
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
+ break;
+ case sheet::ValidationType_TEXT_LEN :
+ if (aValidation.aOperator != sheet::ConditionOperator_BETWEEN &&
+ aValidation.aOperator != sheet::ConditionOperator_NOT_BETWEEN)
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length()"));
+ break;
+ case sheet::ValidationType_TIME :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-time()"));
+ break;
+ case sheet::ValidationType_WHOLE :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-whole-number()"));
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ if (aValidation.aValidationType != sheet::ValidationType_LIST &&
+ (aValidation.sFormula1.getLength() ||
+ (aValidation.aOperator == sheet::ConditionOperator_BETWEEN &&
+ aValidation.aOperator == sheet::ConditionOperator_NOT_BETWEEN &&
+ aValidation.sFormula2.getLength())))
+ {
+ if (aValidation.aValidationType != sheet::ValidationType_TEXT_LEN)
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" and "));
+ if (aValidation.aOperator != sheet::ConditionOperator_BETWEEN &&
+ aValidation.aOperator != sheet::ConditionOperator_NOT_BETWEEN)
+ {
+ if (aValidation.aValidationType != sheet::ValidationType_TEXT_LEN)
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content()"));
+ switch (aValidation.aOperator)
+ {
+ case sheet::ConditionOperator_EQUAL :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("="));
+ break;
+ case sheet::ConditionOperator_GREATER :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">"));
+ break;
+ case sheet::ConditionOperator_GREATER_EQUAL :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">="));
+ break;
+ case sheet::ConditionOperator_LESS :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<"));
+ break;
+ case sheet::ConditionOperator_LESS_EQUAL :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<="));
+ break;
+ case sheet::ConditionOperator_NOT_EQUAL :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("!="));
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ sCondition += aValidation.sFormula1;
+ }
+ else
+ {
+ if (aValidation.aValidationType == sheet::ValidationType_TEXT_LEN)
+ {
+ if (aValidation.aOperator == sheet::ConditionOperator_BETWEEN)
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-between("));
+ else
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-not-between("));
+ }
+ else
+ {
+ if (aValidation.aOperator == sheet::ConditionOperator_BETWEEN)
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-between("));
+ else
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-not-between("));
+ }
+ sCondition += aValidation.sFormula1;
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(","));
+ sCondition += aValidation.sFormula2;
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
+ }
+ }
+ else
+ if (aValidation.aValidationType == sheet::ValidationType_TEXT_LEN)
+ sCondition = rtl::OUString();
+ }
+ if (sCondition.getLength())
+ {
+ const formula::FormulaGrammar::Grammar eGrammar = rExport.GetDocument()->GetStorageGrammar();
+ sal_uInt16 nNamespacePrefix = (eGrammar == formula::FormulaGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC);
+ sCondition = rExport.GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sCondition, sal_False );
+ }
+
+ return sCondition;
+}
+
+rtl::OUString ScMyValidationsContainer::GetBaseCellAddress(ScDocument* pDoc, const table::CellAddress& aCell)
+{
+ rtl::OUString sAddress;
+ ScRangeStringConverter::GetStringFromAddress( sAddress, aCell, pDoc );
+ return sAddress;
+}
+
+void ScMyValidationsContainer::WriteMessage(ScXMLExport& rExport,
+ const rtl::OUString& sTitle, const rtl::OUString& sOUMessage,
+ const sal_Bool bShowMessage, const sal_Bool bIsHelpMessage)
+{
+ if (sTitle.getLength())
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TITLE, sTitle);
+ if (bShowMessage)
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TRUE);
+ else
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, XML_FALSE);
+ SvXMLElementExport* pMessage(NULL);
+ if (bIsHelpMessage)
+ pMessage = new SvXMLElementExport(rExport, XML_NAMESPACE_TABLE, XML_HELP_MESSAGE, sal_True, sal_True);
+ else
+ pMessage = new SvXMLElementExport(rExport, XML_NAMESPACE_TABLE, XML_ERROR_MESSAGE, sal_True, sal_True);
+ if (sOUMessage.getLength())
+ {
+ sal_Int32 i(0);
+ rtl::OUStringBuffer sTemp;
+ String sMessage(sOUMessage);
+ rtl::OUString sText (sMessage.ConvertLineEnd(LINEEND_LF));
+ sal_Bool bPrevCharWasSpace(sal_True);
+ while(i < sText.getLength())
+ {
+ if ((sText[i] == '\n'))
+ {
+ SvXMLElementExport aElemP(rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False);
+ rExport.GetTextParagraphExport()->exportText(sTemp.makeStringAndClear(), bPrevCharWasSpace);
+ }
+ else
+ sTemp.append(sText[i]);
+ ++i;
+ }
+ if (sTemp.getLength())
+ {
+ SvXMLElementExport aElemP(rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False);
+ rExport.GetTextParagraphExport()->exportText(sTemp.makeStringAndClear(), bPrevCharWasSpace);
+ }
+ }
+ if (pMessage)
+ delete pMessage;
+}
+
+void ScMyValidationsContainer::WriteValidations(ScXMLExport& rExport)
+{
+ if (aValidationVec.size())
+ {
+ SvXMLElementExport aElemVs(rExport, XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATIONS, sal_True, sal_True);
+ ScMyValidationVec::iterator aItr(aValidationVec.begin());
+ ScMyValidationVec::iterator aEndItr(aValidationVec.end());
+ while (aItr != aEndItr)
+ {
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, aItr->sName);
+ rtl::OUString sCondition(GetCondition(rExport, *aItr));
+ if (sCondition.getLength())
+ {
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONDITION, sCondition);
+ if (aItr->bIgnoreBlanks)
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_TRUE);
+ else
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_FALSE);
+ if (aItr->aValidationType == sheet::ValidationType_LIST)
+ {
+ switch (aItr->nShowList)
+ {
+ case sheet::TableValidationVisibility::INVISIBLE:
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_NO);
+ break;
+ case sheet::TableValidationVisibility::UNSORTED:
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_UNSORTED);
+ break;
+ case sheet::TableValidationVisibility::SORTEDASCENDING:
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_SORTED_ASCENDING);
+ break;
+ default:
+ DBG_ERROR("unknown ListType");
+ }
+ }
+ }
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, GetBaseCellAddress(rExport.GetDocument(), aItr->aBaseCell));
+ SvXMLElementExport aElemV(rExport, XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION, sal_True, sal_True);
+ if (aItr->bShowImputMessage || aItr->sImputMessage.getLength() || aItr->sImputTitle.getLength())
+ {
+ WriteMessage(rExport, aItr->sImputTitle, aItr->sImputMessage, aItr->bShowImputMessage, sal_True);
+ }
+ if (aItr->bShowErrorMessage || aItr->sErrorMessage.getLength() || aItr->sErrorTitle.getLength())
+ {
+ switch (aItr->aAlertStyle)
+ {
+ case sheet::ValidationAlertStyle_INFO :
+ {
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_INFORMATION);
+ WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False);
+ }
+ break;
+ case sheet::ValidationAlertStyle_WARNING :
+ {
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_WARNING);
+ WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False);
+ }
+ break;
+ case sheet::ValidationAlertStyle_STOP :
+ {
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_STOP);
+ WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False);
+ }
+ break;
+ case sheet::ValidationAlertStyle_MACRO :
+ {
+ {
+ //rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, aItr->sErrorTitle);
+ if (aItr->bShowErrorMessage)
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_EXECUTE, XML_TRUE);
+ else
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_EXECUTE, XML_FALSE);
+ SvXMLElementExport aEMElem(rExport, XML_NAMESPACE_TABLE, XML_ERROR_MACRO, sal_True, sal_True);
+ }
+ {
+ // #i47525# for a script URL the type and the property name for the URL
+ // are both "Script", for a simple macro name the type is "StarBasic"
+ // and the property name is "MacroName".
+ bool bScriptURL = SfxApplication::IsXScriptURL( aItr->sErrorTitle );
+
+ uno::Sequence<beans::PropertyValue> aSeq(3);
+ beans::PropertyValue* pArr(aSeq.getArray());
+ pArr[0].Name = sEventType;
+ pArr[0].Value <<= bScriptURL ? sScript : sStarBasic;
+ pArr[1].Name = sLibrary;
+ pArr[1].Value <<= sEmptyString;
+ pArr[2].Name = bScriptURL ? sScript : sMacroName;
+ pArr[2].Value <<= aItr->sErrorTitle;
+
+ // 2) export the sequence
+ rExport.GetEventExport().ExportSingleEvent( aSeq, sOnError);
+ }
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ ++aItr;
+ }
+ }
+}
+
+const rtl::OUString& ScMyValidationsContainer::GetValidationName(const sal_Int32 nIndex)
+{
+ DBG_ASSERT( static_cast<size_t>(nIndex) < aValidationVec.size(), "out of range" );
+ return aValidationVec[nIndex].sName;
+}
+
+//==============================================================================
+
+sal_Int32 ScMyDefaultStyles::GetStyleNameIndex(const ScFormatRangeStyles* pCellStyles,
+ const sal_Int32 nTable, const sal_Int32 nPos,
+ const sal_Int32 i, const sal_Bool bRow, sal_Bool& bIsAutoStyle)
+{
+ if (bRow)
+ return pCellStyles->GetStyleNameIndex(nTable, nPos, i,
+ bIsAutoStyle);
+ else
+ return pCellStyles->GetStyleNameIndex(nTable, i, nPos,
+ bIsAutoStyle);
+}
+
+void ScMyDefaultStyles::FillDefaultStyles(const sal_Int32 nTable,
+ const sal_Int32 nLastRow, const sal_Int32 nLastCol,
+ const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc,
+ const sal_Bool bRow)
+{
+ if (pDoc)
+ {
+ SCTAB nTab = static_cast<SCTAB>(nTable);
+ sal_Int32 nPos;
+ sal_Int32 nLast;
+ ScMyDefaultStyleList* pDefaults;
+ if (bRow)
+ {
+ pDefaults = pRowDefaults;
+ nLast = nLastRow;
+ }
+ else
+ {
+ pDefaults = pColDefaults;
+ nLast = nLastCol;
+ }
+ sal_Bool bPrevAutoStyle(sal_False);
+ sal_Bool bIsAutoStyle;
+ sal_Bool bResult;
+ sal_Int32 nPrevIndex(0);
+ sal_Int32 nIndex;
+ sal_Int32 nRepeat(0);
+ sal_Int32 nEmptyRepeat(0);
+ for (sal_Int32 i = nLast; i >= 0; --i)
+ {
+ if (bRow)
+ {
+ SCCOL nCol;
+ bResult = pDoc->GetRowDefault(nTab,
+ static_cast<SCROW>(i), static_cast<SCCOL>(nLastCol), nCol);
+ nPos = static_cast<sal_Int32>(nCol);
+ }
+ else
+ {
+ SCROW nRow;
+ bResult = pDoc->GetColDefault(nTab,
+ static_cast<SCCOL>(i), static_cast<SCROW>(nLastRow), nRow);
+ nPos = static_cast<sal_Int32>(nRow);
+ }
+ if (bResult)
+ {
+ nEmptyRepeat = 0;
+ if (!nRepeat)
+ {
+ nPrevIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i,
+ bRow, bPrevAutoStyle);
+ (*pDefaults)[i].nIndex = nPrevIndex;
+ (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
+ nRepeat = 1;
+ }
+ else
+ {
+ nIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i,
+ bRow, bIsAutoStyle);
+ if ((nIndex != nPrevIndex) || (bIsAutoStyle != bPrevAutoStyle))
+ {
+ nRepeat = 1;
+ nPrevIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i,
+ bRow, bPrevAutoStyle);
+ (*pDefaults)[i].nIndex = nPrevIndex;
+ (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
+ }
+ else
+ {
+ (*pDefaults)[i].nIndex = nPrevIndex;
+ (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
+ ++nRepeat;
+ if (nRepeat > 1)
+ (*pDefaults)[i].nRepeat = nRepeat;
+ }
+ }
+ }
+ else
+ {
+ nRepeat = 0;
+ if (!nEmptyRepeat)
+ nEmptyRepeat = 1;
+ else
+ {
+ ++nEmptyRepeat;
+ if (nEmptyRepeat > 1)
+ (*pDefaults)[i].nRepeat = nEmptyRepeat;
+ }
+ }
+ }
+ }
+}
+
+void ScMyDefaultStyles::FillDefaultStyles(const sal_Int32 nTable,
+ const sal_Int32 nLastRow, const sal_Int32 nLastCol,
+ const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc)
+{
+ if (pRowDefaults)
+ delete pRowDefaults;
+ pRowDefaults = new ScMyDefaultStyleList(nLastRow + 1);
+ FillDefaultStyles(nTable, nLastRow, nLastCol, pCellStyles, pDoc, sal_True);
+ if (pColDefaults)
+ delete pColDefaults;
+ pColDefaults = new ScMyDefaultStyleList(nLastCol + 1);
+ FillDefaultStyles(nTable, nLastRow, nLastCol, pCellStyles, pDoc, sal_False);
+}
+
+ScMyDefaultStyles::~ScMyDefaultStyles()
+{
+ if (pRowDefaults)
+ delete pRowDefaults;
+ if (pColDefaults)
+ delete pColDefaults;
+}
+
+ScMyRowFormatRange::ScMyRowFormatRange()
+ : nStartColumn(0),
+ nRepeatColumns(0),
+ nRepeatRows(0),
+ nIndex(-1),
+ nValidationIndex(-1),
+ bIsAutoStyle(sal_True)
+{
+}
+
+sal_Bool ScMyRowFormatRange::operator< (const ScMyRowFormatRange& rRange) const
+{
+ return (nStartColumn < rRange.nStartColumn);
+}
+
+ScRowFormatRanges::ScRowFormatRanges()
+ : aRowFormatRanges(),
+ pRowDefaults(NULL),
+ pColDefaults(NULL),
+ nSize(0)
+{
+}
+
+ScRowFormatRanges::ScRowFormatRanges(const ScRowFormatRanges* pRanges)
+ : aRowFormatRanges(pRanges->aRowFormatRanges),
+ pRowDefaults(pRanges->pRowDefaults),
+ pColDefaults(pRanges->pColDefaults),
+ nSize(pRanges->nSize)
+{
+}
+
+ScRowFormatRanges::~ScRowFormatRanges()
+{
+}
+
+void ScRowFormatRanges::Clear()
+{
+ aRowFormatRanges.clear();
+ nSize = 0;
+}
+
+void ScRowFormatRanges::AddRange(const sal_Int32 nPrevStartCol, const sal_Int32 nRepeat, const sal_Int32 nPrevIndex,
+ const sal_Bool bPrevAutoStyle, const ScMyRowFormatRange& rFormatRange)
+{
+ sal_Int32 nIndex(-1);
+ if ((nPrevIndex != rFormatRange.nIndex) ||
+ (bPrevAutoStyle != rFormatRange.bIsAutoStyle))
+ nIndex = rFormatRange.nIndex;
+
+ sal_Bool bInserted(sal_False);
+ if (!aRowFormatRanges.empty())
+ {
+ ScMyRowFormatRange* pRange(&aRowFormatRanges.back());
+ if (pRange)
+ {
+ if ((nPrevStartCol == (pRange->nStartColumn + pRange->nRepeatColumns)) &&
+ (pRange->bIsAutoStyle == rFormatRange.bIsAutoStyle) &&
+ (pRange->nIndex == nIndex) &&
+ (pRange->nValidationIndex == rFormatRange.nValidationIndex))
+ {
+ if (rFormatRange.nRepeatRows < pRange->nRepeatRows)
+ pRange->nRepeatRows = rFormatRange.nRepeatRows;
+ pRange->nRepeatColumns += nRepeat;
+ bInserted = sal_True;
+ }
+ }
+ }
+ if (!bInserted)
+ {
+ ScMyRowFormatRange aRange;
+ aRange.nStartColumn = nPrevStartCol;
+ aRange.nRepeatColumns = nRepeat;
+ aRange.nRepeatRows = rFormatRange.nRepeatRows;
+ aRange.nValidationIndex = rFormatRange.nValidationIndex;
+ aRange.bIsAutoStyle = rFormatRange.bIsAutoStyle;
+ aRange.nIndex = nIndex;
+ aRowFormatRanges.push_back(aRange);
+ ++nSize;
+ }
+}
+
+void ScRowFormatRanges::AddRange(ScMyRowFormatRange& rFormatRange,
+ const sal_Int32 nRow)
+{
+ DBG_ASSERT(pRowDefaults, "no row defaults");
+ DBG_ASSERT(pColDefaults, "no column defaults");
+ sal_uInt32 nEnd (rFormatRange.nRepeatRows + nRow - 1);
+ sal_Int32 nPrevIndex((*pRowDefaults)[nRow].nIndex);
+ sal_Bool bPrevAutoStyle((*pRowDefaults)[nRow].bIsAutoStyle);
+ sal_uInt32 i(nRow + 1);
+ sal_Bool bReady(sal_False);
+ while ((i < nEnd) && !bReady && (i < pRowDefaults->size()))
+ {
+ if ((nPrevIndex != (*pRowDefaults)[i].nIndex) ||
+ (bPrevAutoStyle != (*pRowDefaults)[i].bIsAutoStyle))
+ bReady = sal_True;
+ else
+ i += (*pRowDefaults)[i].nRepeat;
+ }
+ if (i > nEnd)
+ i = nEnd;
+ if (bReady)
+ rFormatRange.nRepeatRows = i - nRow + 1;
+ if (nPrevIndex == -1)
+ {
+ nPrevIndex = (*pColDefaults)[rFormatRange.nStartColumn].nIndex;
+ bPrevAutoStyle = (*pColDefaults)[rFormatRange.nStartColumn].bIsAutoStyle;
+ sal_uInt32 nPrevStartCol(rFormatRange.nStartColumn);
+ sal_uInt32 nRepeat((*pColDefaults)[rFormatRange.nStartColumn].nRepeat);
+ nEnd = rFormatRange.nStartColumn + rFormatRange.nRepeatColumns;
+ for(i = nPrevStartCol + nRepeat; i < nEnd; i += (*pColDefaults)[i].nRepeat)
+ {
+ DBG_ASSERT(sal_uInt32(nPrevStartCol + nRepeat) <= nEnd, "something wents wrong");
+ if ((nPrevIndex != (*pColDefaults)[i].nIndex) ||
+ (bPrevAutoStyle != (*pColDefaults)[i].bIsAutoStyle))
+ {
+ AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange);
+ nPrevStartCol = i;
+ nRepeat = (*pColDefaults)[i].nRepeat;
+ nPrevIndex = (*pColDefaults)[i].nIndex;
+ bPrevAutoStyle = (*pColDefaults)[i].bIsAutoStyle;
+ }
+ else
+ nRepeat += (*pColDefaults)[i].nRepeat;
+ }
+ if (sal_uInt32(nPrevStartCol + nRepeat) > nEnd)
+ nRepeat = nEnd - nPrevStartCol;
+ AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange);
+ }
+ else if ((nPrevIndex == rFormatRange.nIndex) &&
+ (bPrevAutoStyle == rFormatRange.bIsAutoStyle))
+ {
+ rFormatRange.nIndex = -1;
+ aRowFormatRanges.push_back(rFormatRange);
+ ++nSize;
+ }
+}
+
+sal_Bool ScRowFormatRanges::GetNext(ScMyRowFormatRange& aFormatRange)
+{
+ ScMyRowFormatRangesList::iterator aItr(aRowFormatRanges.begin());
+ if (aItr != aRowFormatRanges.end())
+ {
+ aFormatRange = (*aItr);
+ aRowFormatRanges.erase(aItr);
+ --nSize;
+ return sal_True;
+ }
+ return sal_False;
+}
+
+sal_Int32 ScRowFormatRanges::GetMaxRows()
+{
+ ScMyRowFormatRangesList::iterator aItr(aRowFormatRanges.begin());
+ ScMyRowFormatRangesList::iterator aEndItr(aRowFormatRanges.end());
+ sal_Int32 nMaxRows = MAXROW + 1;
+ if (aItr != aEndItr)
+ while (aItr != aEndItr)
+ {
+ if ((*aItr).nRepeatRows < nMaxRows)
+ nMaxRows = (*aItr).nRepeatRows;
+ ++aItr;
+ }
+ else
+ {
+ DBG_ERROR("no ranges found");
+ }
+ return nMaxRows;
+}
+
+sal_Int32 ScRowFormatRanges::GetSize()
+{
+ return nSize;
+}
+
+void ScRowFormatRanges::Sort()
+{
+ aRowFormatRanges.sort();
+}
+
+// ============================================================================
+ScMyFormatRange::ScMyFormatRange()
+ : nStyleNameIndex(-1),
+ nValidationIndex(-1),
+ bIsAutoStyle(sal_True)
+{
+}
+
+sal_Bool ScMyFormatRange::operator<(const ScMyFormatRange& rRange) const
+{
+ if (aRangeAddress.StartRow < rRange.aRangeAddress.StartRow)
+ return sal_True;
+ else
+ if (aRangeAddress.StartRow == rRange.aRangeAddress.StartRow)
+ return (aRangeAddress.StartColumn < rRange.aRangeAddress.StartColumn);
+ else
+ return sal_False;
+}
+
+ScFormatRangeStyles::ScFormatRangeStyles()
+ : aTables(),
+ aStyleNames(),
+ aAutoStyleNames()
+{
+}
+
+ScFormatRangeStyles::~ScFormatRangeStyles()
+{
+ ScMyOUStringVec::iterator i(aStyleNames.begin());
+ ScMyOUStringVec::iterator endi(aStyleNames.end());
+ while (i != endi)
+ {
+ delete *i;
+ ++i;
+ }
+ i = aAutoStyleNames.begin();
+ endi = aAutoStyleNames.end();
+ while (i != endi)
+ {
+ delete *i;
+ ++i;
+ }
+ ScMyFormatRangeListVec::iterator j(aTables.begin());
+ ScMyFormatRangeListVec::iterator endj(aTables.end());
+ while (j != endj)
+ {
+ delete *j;
+ ++j;
+ }
+}
+
+void ScFormatRangeStyles::AddNewTable(const sal_Int32 nTable)
+{
+ sal_Int32 nSize = aTables.size() - 1;
+ if (nTable > nSize)
+ for (sal_Int32 i = nSize; i < nTable; ++i)
+ {
+ ScMyFormatRangeAddresses* aRangeAddresses(new ScMyFormatRangeAddresses);
+ aTables.push_back(aRangeAddresses);
+ }
+}
+
+sal_Bool ScFormatRangeStyles::AddStyleName(rtl::OUString* rpString, sal_Int32& rIndex, const sal_Bool bIsAutoStyle)
+{
+ if (bIsAutoStyle)
+ {
+ aAutoStyleNames.push_back(rpString);
+ rIndex = aAutoStyleNames.size() - 1;
+ return sal_True;
+ }
+ else
+ {
+ sal_Int32 nCount(aStyleNames.size());
+ sal_Bool bFound(sal_False);
+ sal_Int32 i(nCount - 1);
+ while ((i >= 0) && (!bFound))
+ {
+ if (aStyleNames.at(i)->equals(*rpString))
+ bFound = sal_True;
+ else
+ i--;
+ }
+ if (bFound)
+ {
+ rIndex = i;
+ return sal_False;
+ }
+ else
+ {
+ aStyleNames.push_back(rpString);
+ rIndex = aStyleNames.size() - 1;
+ return sal_True;
+ }
+ }
+}
+
+sal_Int32 ScFormatRangeStyles::GetIndexOfStyleName(const rtl::OUString& rString, const rtl::OUString& rPrefix, sal_Bool& bIsAutoStyle)
+{
+ sal_Int32 nPrefixLength(rPrefix.getLength());
+ rtl::OUString sTemp(rString.copy(nPrefixLength));
+ sal_Int32 nIndex(sTemp.toInt32());
+ if (aAutoStyleNames.at(nIndex - 1)->equals(rString))
+ {
+ bIsAutoStyle = sal_True;
+ return nIndex - 1;
+ }
+ else
+ {
+ sal_Int32 i(0);
+ sal_Bool bFound(sal_False);
+ while (!bFound && static_cast<size_t>(i) < aStyleNames.size())
+ {
+ if (aStyleNames[i]->equals(rString))
+ bFound = sal_True;
+ else
+ ++i;
+ }
+ if (bFound)
+ {
+ bIsAutoStyle = sal_False;
+ return i;
+ }
+ else
+ {
+ i = 0;
+ while (!bFound && static_cast<size_t>(i) < aAutoStyleNames.size())
+ {
+ if (aAutoStyleNames[i]->equals(rString))
+ bFound = sal_True;
+ else
+ ++i;
+ }
+ if (bFound)
+ {
+ bIsAutoStyle = sal_True;
+ return i;
+ }
+ else
+ return -1;
+ }
+ }
+}
+
+sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_Int32 nTable,
+ const sal_Int32 nColumn, const sal_Int32 nRow, sal_Bool& bIsAutoStyle) const
+{
+ DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ ScMyFormatRangeAddresses* pFormatRanges(aTables[nTable]);
+ ScMyFormatRangeAddresses::iterator aItr(pFormatRanges->begin());
+ ScMyFormatRangeAddresses::iterator aEndItr(pFormatRanges->end());
+ while (aItr != aEndItr)
+ {
+ if (((*aItr).aRangeAddress.StartColumn <= nColumn) &&
+ ((*aItr).aRangeAddress.EndColumn >= nColumn) &&
+ ((*aItr).aRangeAddress.StartRow <= nRow) &&
+ ((*aItr).aRangeAddress.EndRow >= nRow))
+ {
+ bIsAutoStyle = aItr->bIsAutoStyle;
+ return (*aItr).nStyleNameIndex;
+ }
+ else
+ ++aItr;
+ }
+ return -1;
+}
+
+sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nColumn, const sal_Int32 nRow,
+ sal_Bool& bIsAutoStyle, sal_Int32& nValidationIndex, sal_Int32& nNumberFormat, const sal_Bool bRemoveRange)
+{
+ DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ ScMyFormatRangeAddresses* pFormatRanges(aTables[nTable]);
+ ScMyFormatRangeAddresses::iterator aItr(pFormatRanges->begin());
+ ScMyFormatRangeAddresses::iterator aEndItr(pFormatRanges->end());
+ while (aItr != aEndItr)
+ {
+ if (((*aItr).aRangeAddress.StartColumn <= nColumn) &&
+ ((*aItr).aRangeAddress.EndColumn >= nColumn) &&
+ ((*aItr).aRangeAddress.StartRow <= nRow) &&
+ ((*aItr).aRangeAddress.EndRow >= nRow))
+ {
+ bIsAutoStyle = aItr->bIsAutoStyle;
+ nValidationIndex = aItr->nValidationIndex;
+ nNumberFormat = aItr->nNumberFormat;
+ if (((*pRowDefaults)[nRow].nIndex != -1))
+ {
+ if (((*pRowDefaults)[nRow].nIndex == (*aItr).nStyleNameIndex) &&
+ ((*pRowDefaults)[nRow].bIsAutoStyle == (*aItr).bIsAutoStyle))
+ return -1;
+ else
+ return (*aItr).nStyleNameIndex;
+ }
+ else if (((*pColDefaults)[nColumn].nIndex != -1) &&
+ ((*pColDefaults)[nColumn].nIndex == (*aItr).nStyleNameIndex) &&
+ ((*pColDefaults)[nColumn].bIsAutoStyle == (*aItr).bIsAutoStyle))
+ return -1;
+ else
+ return (*aItr).nStyleNameIndex;
+ }
+ else
+ {
+ if (bRemoveRange && (*aItr).aRangeAddress.EndRow < nRow)
+ aItr = pFormatRanges->erase(aItr);
+ else
+ ++aItr;
+ }
+ }
+ return -1;
+}
+
+void ScFormatRangeStyles::GetFormatRanges(const sal_Int32 nStartColumn, const sal_Int32 nEndColumn, const sal_Int32 nRow,
+ const sal_Int32 nTable, ScRowFormatRanges* pRowFormatRanges)
+{
+ sal_Int32 nTotalColumns(nEndColumn - nStartColumn + 1);
+ DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ ScMyFormatRangeAddresses* pFormatRanges(aTables[nTable]);
+ ScMyFormatRangeAddresses::iterator aItr(pFormatRanges->begin());
+ ScMyFormatRangeAddresses::iterator aEndItr(pFormatRanges->end());
+ sal_Int32 nColumns = 0;
+ while (aItr != aEndItr && nColumns < nTotalColumns)
+ {
+#if OSL_DEBUG_LEVEL > 1
+ table::CellRangeAddress aTempRangeAddress((*aItr).aRangeAddress);
+#endif
+ if (((*aItr).aRangeAddress.StartRow <= nRow) &&
+ ((*aItr).aRangeAddress.EndRow >= nRow))
+ {
+ if ((((*aItr).aRangeAddress.StartColumn <= nStartColumn) &&
+ ((*aItr).aRangeAddress.EndColumn >= nStartColumn)) ||
+ (((*aItr).aRangeAddress.StartColumn <= nEndColumn) &&
+ ((*aItr).aRangeAddress.EndColumn >= nEndColumn)) ||
+ (((*aItr).aRangeAddress.StartColumn >= nStartColumn) &&
+ ((*aItr).aRangeAddress.EndColumn <= nEndColumn)))
+ {
+ ScMyRowFormatRange aRange;
+ aRange.nIndex = aItr->nStyleNameIndex;
+ aRange.nValidationIndex = aItr->nValidationIndex;
+ aRange.bIsAutoStyle = aItr->bIsAutoStyle;
+ if ((aItr->aRangeAddress.StartColumn < nStartColumn) &&
+ (aItr->aRangeAddress.EndColumn >= nStartColumn))
+ {
+ if (aItr->aRangeAddress.EndColumn >= nEndColumn)
+ aRange.nRepeatColumns = nTotalColumns;
+ else
+ aRange.nRepeatColumns = aItr->aRangeAddress.EndColumn - nStartColumn + 1;
+ aRange.nStartColumn = nStartColumn;
+ }
+ else if ((aItr->aRangeAddress.StartColumn >= nStartColumn) &&
+ (aItr->aRangeAddress.EndColumn <= nEndColumn))
+ {
+ aRange.nRepeatColumns = aItr->aRangeAddress.EndColumn - aItr->aRangeAddress.StartColumn + 1;
+ aRange.nStartColumn = aItr->aRangeAddress.StartColumn;
+ }
+ else if ((aItr->aRangeAddress.StartColumn >= nStartColumn) &&
+ (aItr->aRangeAddress.StartColumn <= nEndColumn) &&
+ (aItr->aRangeAddress.EndColumn > nEndColumn))
+ {
+ aRange.nRepeatColumns = nEndColumn - aItr->aRangeAddress.StartColumn + 1;
+ aRange.nStartColumn = aItr->aRangeAddress.StartColumn;
+ }
+ aRange.nRepeatRows = aItr->aRangeAddress.EndRow - nRow + 1;
+ pRowFormatRanges->AddRange(aRange, nRow);
+ nColumns += aRange.nRepeatColumns;
+ }
+ ++aItr;
+ }
+ else
+ if(aItr->aRangeAddress.EndRow < nRow)
+ aItr = pFormatRanges->erase(aItr);
+ else
+ ++aItr;
+ }
+ pRowFormatRanges->Sort();
+}
+
+void ScFormatRangeStyles::AddRangeStyleName(const table::CellRangeAddress aCellRangeAddress,
+ const sal_Int32 nStringIndex, const sal_Bool bIsAutoStyle, const sal_Int32 nValidationIndex,
+ const sal_Int32 nNumberFormat)
+{
+ ScMyFormatRange aFormatRange;
+ aFormatRange.aRangeAddress = aCellRangeAddress;
+ aFormatRange.nStyleNameIndex = nStringIndex;
+ aFormatRange.nValidationIndex = nValidationIndex;
+ aFormatRange.nNumberFormat = nNumberFormat;
+ aFormatRange.bIsAutoStyle = bIsAutoStyle;
+ DBG_ASSERT(static_cast<size_t>(aCellRangeAddress.Sheet) < aTables.size(), "wrong table");
+ ScMyFormatRangeAddresses* pFormatRanges(aTables[aCellRangeAddress.Sheet]);
+ pFormatRanges->push_back(aFormatRange);
+}
+
+rtl::OUString* ScFormatRangeStyles::GetStyleNameByIndex(const sal_Int32 nIndex, const sal_Bool bIsAutoStyle)
+{
+ if (bIsAutoStyle)
+ return aAutoStyleNames[nIndex];
+ else
+ return aStyleNames[nIndex];
+}
+
+void ScFormatRangeStyles::Sort()
+{
+ sal_Int32 nTables = aTables.size();
+ for (sal_Int16 i = 0; i < nTables; ++i)
+ if (!aTables[i]->empty())
+ aTables[i]->sort();
+}
+
+//===========================================================================
+
+ScColumnRowStylesBase::ScColumnRowStylesBase()
+ : aStyleNames()
+{
+}
+
+ScColumnRowStylesBase::~ScColumnRowStylesBase()
+{
+ ScMyOUStringVec::iterator i(aStyleNames.begin());
+ ScMyOUStringVec::iterator endi(aStyleNames.end());
+ while (i != endi)
+ {
+ delete *i;
+ ++i;
+ }
+}
+
+sal_Int32 ScColumnRowStylesBase::AddStyleName(rtl::OUString* pString)
+{
+ aStyleNames.push_back(pString);
+ return aStyleNames.size() - 1;
+}
+
+sal_Int32 ScColumnRowStylesBase::GetIndexOfStyleName(const rtl::OUString& rString, const rtl::OUString& rPrefix)
+{
+ sal_Int32 nPrefixLength(rPrefix.getLength());
+ rtl::OUString sTemp(rString.copy(nPrefixLength));
+ sal_Int32 nIndex(sTemp.toInt32());
+ if (aStyleNames.at(nIndex - 1)->equals(rString))
+ return nIndex - 1;
+ else
+ {
+ sal_Int32 i(0);
+ sal_Bool bFound(sal_False);
+ while (!bFound && static_cast<size_t>(i) < aStyleNames.size())
+ {
+ if (aStyleNames.at(i)->equals(rString))
+ bFound = sal_True;
+ else
+ ++i;
+ }
+ if (bFound)
+ return i;
+ else
+ return -1;
+ }
+}
+
+rtl::OUString* ScColumnRowStylesBase::GetStyleNameByIndex(const sal_Int32 nIndex)
+{
+ if ( nIndex < 0 || nIndex >= sal::static_int_cast<sal_Int32>( aStyleNames.size() ) )
+ {
+ // #123981# should no longer happen, use first style then
+ DBG_ERRORFILE("GetStyleNameByIndex: invalid index");
+ return aStyleNames[0];
+ }
+
+ return aStyleNames[nIndex];
+}
+
+//===========================================================================
+
+ScColumnStyles::ScColumnStyles()
+ : ScColumnRowStylesBase(),
+ aTables()
+{
+}
+
+ScColumnStyles::~ScColumnStyles()
+{
+}
+
+void ScColumnStyles::AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields)
+{
+ sal_Int32 nSize(aTables.size() - 1);
+ if (nTable > nSize)
+ for (sal_Int32 i = nSize; i < nTable; ++i)
+ {
+ ScMyColumnStyleVec aFieldsVec(nFields + 1, ScColumnStyle());
+ aTables.push_back(aFieldsVec);
+ }
+}
+
+sal_Int32 ScColumnStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField,
+ sal_Bool& bIsVisible)
+{
+ DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ if (static_cast<size_t>(nField) < aTables[nTable].size())
+ {
+ bIsVisible = aTables[nTable][nField].bIsVisible;
+ return aTables[nTable][nField].nIndex;
+ }
+ else
+ {
+ bIsVisible = aTables[nTable][aTables[nTable].size() - 1].bIsVisible;
+ return aTables[nTable][aTables[nTable].size() - 1].nIndex;
+ }
+}
+
+void ScColumnStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField,
+ const sal_Int32 nStringIndex, const sal_Bool bIsVisible)
+{
+ DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ DBG_ASSERT(aTables[nTable].size() >= static_cast<sal_uInt32>(nField), "wrong field");
+ ScColumnStyle aStyle;
+ aStyle.nIndex = nStringIndex;
+ aStyle.bIsVisible = bIsVisible;
+ if (aTables[nTable].size() == static_cast<sal_uInt32>(nField))
+ aTables[nTable].push_back(aStyle);
+ aTables[nTable][nField] = aStyle;
+}
+
+rtl::OUString* ScColumnStyles::GetStyleName(const sal_Int32 nTable, const sal_Int32 nField)
+{
+ sal_Bool bTemp;
+ return GetStyleNameByIndex(GetStyleNameIndex(nTable, nField, bTemp));
+}
+
+//===========================================================================
+
+ScRowStyles::ScRowStyles()
+ : ScColumnRowStylesBase(),
+ aTables()
+{
+}
+
+ScRowStyles::~ScRowStyles()
+{
+}
+
+void ScRowStyles::AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields)
+{
+ sal_Int32 nSize(aTables.size() - 1);
+ if (nTable > nSize)
+ for (sal_Int32 i = nSize; i < nTable; ++i)
+ {
+ ScMysalInt32Vec aFieldsVec(nFields + 1, -1);
+ aTables.push_back(aFieldsVec);
+ }
+}
+
+sal_Int32 ScRowStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField)
+{
+ DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ if (static_cast<size_t>(nField) < aTables[nTable].size())
+ return aTables[nTable][nField];
+ else
+ return aTables[nTable][aTables[nTable].size() - 1];
+}
+
+void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField,
+ const sal_Int32 nStringIndex)
+{
+ DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ DBG_ASSERT(aTables[nTable].size() >= static_cast<sal_uInt32>(nField), "wrong field");
+ if (aTables[nTable].size() == static_cast<sal_uInt32>(nField))
+ aTables[nTable].push_back(nStringIndex);
+ aTables[nTable][nField] = nStringIndex;
+}
+
+rtl::OUString* ScRowStyles::GetStyleName(const sal_Int32 nTable, const sal_Int32 nField)
+{
+ return GetStyleNameByIndex(GetStyleNameIndex(nTable, nField));
+}
diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.cxx b/sc/source/filter/xml/XMLTrackedChangesContext.cxx index bc76bf2abc9e..3b6530c14167 100644 --- a/sc/source/filter/xml/XMLTrackedChangesContext.cxx +++ b/sc/source/filter/xml/XMLTrackedChangesContext.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: XMLTrackedChangesContext.cxx,v $ - * $Revision: 1.32.62.1 $ + * $Revision: 1.32 $ * * This file is part of OpenOffice.org. * @@ -48,7 +48,6 @@ using namespace com::sun::star; using namespace xmloff::token; -using ::rtl::OUString; //----------------------------------------------------------------------------- @@ -117,7 +116,7 @@ class ScXMLCellContentDeletionContext : public SvXMLImportContext sal_uInt32 nID; sal_Int32 nMatrixCols; sal_Int32 nMatrixRows; - ScGrammar::Grammar eGrammar; + formula::FormulaGrammar::Grammar eGrammar; sal_uInt16 nType; sal_uInt8 nMatrixFlag; sal_Bool bBigRange; @@ -299,7 +298,7 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList, ScBaseCell*& rOldCell, rtl::OUString& sAddress, rtl::OUString& sFormula, - ScGrammar::Grammar& rGrammar, + formula::FormulaGrammar::Grammar& rGrammar, rtl::OUString& rInputString, double& fValue, sal_uInt16& nType, sal_uInt8& nMatrixFlag, sal_Int32& nMatrixCols, sal_Int32& nMatrixRows); virtual ~ScXMLChangeCellContext(); @@ -329,7 +328,7 @@ class ScXMLPreviousContext : public SvXMLImportContext sal_uInt32 nID; sal_Int32 nMatrixCols; sal_Int32 nMatrixRows; - ScGrammar::Grammar eGrammar; + formula::FormulaGrammar::Grammar eGrammar; sal_uInt16 nType; sal_uInt8 nMatrixFlag; @@ -1116,7 +1115,7 @@ ScXMLChangeCellContext::ScXMLChangeCellContext( ScXMLImport& rImport, const ::rtl::OUString& rLName, const uno::Reference<xml::sax::XAttributeList>& xAttrList, ScBaseCell*& rTempOldCell, rtl::OUString& rAddress, rtl::OUString& rFormula, - ScGrammar::Grammar& rGrammar, + formula::FormulaGrammar::Grammar& rGrammar, rtl::OUString& rTempInputString, double& fDateTimeValue, sal_uInt16& nType, sal_uInt8& nMatrixFlag, sal_Int32& nMatrixCols, sal_Int32& nMatrixRows ) : SvXMLImportContext( rImport, nPrfx, rLName ), @@ -1130,7 +1129,7 @@ ScXMLChangeCellContext::ScXMLChangeCellContext( ScXMLImport& rImport, bString(sal_True), bFormula(sal_False) { - const ScGrammar::Grammar eStorageGrammar = rGrammar = GetScImport().GetDocument()->GetStorageGrammar(); + const formula::FormulaGrammar::Grammar eStorageGrammar = rGrammar = GetScImport().GetDocument()->GetStorageGrammar(); sal_Bool bIsMatrix(sal_False); sal_Bool bIsCoveredMatrix(sal_False); sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0); @@ -1346,7 +1345,7 @@ ScXMLPreviousContext::ScXMLPreviousContext( ScXMLImport& rImport, nID(0), nMatrixCols(0), nMatrixRows(0), - eGrammar( ScGrammar::GRAM_STORAGE_DEFAULT), + eGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT), nType(NUMBERFORMAT_ALL), nMatrixFlag(MM_NONE) { @@ -2029,3 +2028,4 @@ void ScXMLRejectionContext::EndElement() } + diff --git a/sc/source/filter/xml/xmlbodyi.cxx b/sc/source/filter/xml/xmlbodyi.cxx index f1e2ccd8ce73..7c80014dcaf9 100644 --- a/sc/source/filter/xml/xmlbodyi.cxx +++ b/sc/source/filter/xml/xmlbodyi.cxx @@ -1,3 +1,4 @@ +<<<<<<< .working /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -7,7 +8,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: xmlbodyi.cxx,v $ - * $Revision: 1.32.28.1 $ + * $Revision: 1.32 $ * * This file is part of OpenOffice.org. * @@ -64,7 +65,6 @@ using namespace com::sun::star; using namespace xmloff::token; -using ::rtl::OUString; //------------------------------------------------------------------ @@ -83,7 +83,7 @@ ScXMLBodyContext::ScXMLBodyContext( ScXMLImport& rImport, { // ODF 1.1 and earlier => GRAM_PODF; ODF 1.2 and later => GRAM_ODFF; // no version => earlier than 1.2 => GRAM_PODF. - ScGrammar::Grammar eGrammar = ScGrammar::GRAM_ODFF; + formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_ODFF; OUString aVer( rImport.GetODFVersion()); sal_Int32 nLen = aVer.getLength(); #if OSL_DEBUG_LEVEL > 1 @@ -91,7 +91,7 @@ ScXMLBodyContext::ScXMLBodyContext( ScXMLImport& rImport, (int)nLen, OUStringToOString( aVer, RTL_TEXTENCODING_UTF8).getStr()); #endif if (!nLen) - eGrammar = ScGrammar::GRAM_PODF; + eGrammar = formula::FormulaGrammar::GRAM_PODF; else { // In case there was a micro version, e.g. "1.2.3", this would @@ -99,7 +99,7 @@ ScXMLBodyContext::ScXMLBodyContext( ScXMLImport& rImport, // passed here) would point before string end upon return. double fVer = ::rtl::math::stringToDouble( aVer, '.', 0, NULL, NULL); if (fVer < 1.2) - eGrammar = ScGrammar::GRAM_PODF; + eGrammar = formula::FormulaGrammar::GRAM_PODF; } pDoc->SetStorageGrammar( eGrammar); } diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 7b44a57a926c..1de87a103ffa 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -114,9 +114,6 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, const sal_Bool bTempIsCovered, const sal_Int32 nTempRepeatedRows ) : SvXMLImportContext( rImport, nPrfx, rLName ), - pOUTextValue(NULL), - pOUTextContent(NULL), - pOUFormula(NULL), pContentValidationName(NULL), pMyAnnotation(NULL), pDetectiveObjVec(NULL), @@ -127,7 +124,7 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, nRepeatedRows(nTempRepeatedRows), nCellsRepeated(1), rXMLImport((ScXMLImport&)rImport), - eGrammar( ScGrammar::GRAM_STORAGE_DEFAULT), + eGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT), nCellType(util::NumberFormat::TEXT), bIsMerged(sal_False), bIsMatrix(sal_False), @@ -139,10 +136,10 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, bSolarMutexLocked(sal_False), bFormulaTextResult(sal_False) { - ScGrammar::Grammar eStorageGrammar = eGrammar = GetScImport().GetDocument()->GetStorageGrammar(); + formula::FormulaGrammar::Grammar eStorageGrammar = eGrammar = GetScImport().GetDocument()->GetStorageGrammar(); rXMLImport.SetRemoveLastChar(sal_False); rXMLImport.GetTables().AddColumn(bTempIsCovered); - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; rtl::OUString aLocalName; rtl::OUString* pStyleName = NULL; rtl::OUString* pCurrencySymbol = NULL; @@ -218,7 +215,7 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, if (sValue.getLength()) { DBG_ASSERT(!pOUTextValue, "here should be only one string value"); - pOUTextValue = new rtl::OUString(sValue); + pOUTextValue.reset(sValue); bIsEmpty = sal_False; } } @@ -242,7 +239,6 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, if (sValue.getLength()) { DBG_ASSERT(!pOUFormula, "here should be only one formula"); - DELETEZ( pOUFormula); rtl::OUString sFormula; sal_uInt16 nFormulaPrefix = GetImport().GetNamespaceMap(). _GetKeyByAttrName( sValue, &sFormula, sal_False ); @@ -252,7 +248,7 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, eStorageGrammar)) { // Namespaces we accept. - pOUFormula = new rtl::OUString( sFormula); + pOUFormula.reset( sFormula); } else { @@ -260,7 +256,7 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, // Also unknown namespace included in formula, // so hopefully will result in string or // compile error. - pOUFormula = new rtl::OUString( sValue); + pOUFormula.reset( sValue); } } } @@ -283,12 +279,6 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, ScXMLTableRowCellContext::~ScXMLTableRowCellContext() { - if (pOUTextValue) - delete pOUTextValue; - if (pOUTextContent) - delete pOUTextContent; - if (pOUFormula) - delete pOUFormula; if (pContentValidationName) delete pContentValidationName; if (pMyAnnotation) @@ -386,8 +376,7 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( USHORT nPrefix if (pOUTextContent) { SetCursorOnTextImport(*pOUTextContent); - delete pOUTextContent; - pOUTextContent = NULL; + pOUTextContent.reset(); } else SetCursorOnTextImport(rtl::OUString()); @@ -411,19 +400,16 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( USHORT nPrefix break; case XML_TOK_TABLE_ROW_CELL_TABLE: { - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; rtl::OUString aLocalName; - rtl::OUString sValue; for( sal_Int16 i=0; i < nAttrCount; i++ ) { sal_uInt16 nAttrPrefix = rXMLImport.GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( i ), &aLocalName ); - sValue = xAttrList->getValueByIndex( i ); - - if (nAttrPrefix == XML_NAMESPACE_TABLE) + if ( nAttrPrefix == XML_NAMESPACE_TABLE + && IsXMLToken(aLocalName, XML_IS_SUB_TABLE)) { - if (IsXMLToken(aLocalName, XML_IS_SUB_TABLE)) - bHasSubTable = IsXMLToken(sValue, XML_TRUE); + bHasSubTable = IsXMLToken(xAttrList->getValueByIndex( i ), XML_TRUE); } } DBG_ASSERT(bHasSubTable, "it should be a subtable"); @@ -527,31 +513,21 @@ void ScXMLTableRowCellContext::DoMerge(const com::sun::star::table::CellAddress& uno::Reference<table::XCellRange> xCellRange(rXMLImport.GetTables().GetCurrentXCellRange()); if ( xCellRange.is() ) { - // Stored merge range may actually be of a larger extend than what - // we support, in which case getCellRangeByPosition() throws - // IndexOutOfBoundsException. Do nothing then. - try + table::CellRangeAddress aCellAddress; + if (IsMerged(xCellRange, aCellPos.Column, aCellPos.Row, aCellAddress)) { - table::CellRangeAddress aCellAddress; - if (IsMerged(xCellRange, aCellPos.Column, aCellPos.Row, aCellAddress)) - { - //unmerge - uno::Reference <util::XMergeable> xMergeable (xCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, - aCellAddress.EndColumn, aCellAddress.EndRow), uno::UNO_QUERY); - if (xMergeable.is()) - xMergeable->merge(sal_False); - } - - //merge + //unmerge uno::Reference <util::XMergeable> xMergeable (xCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, - aCellAddress.EndColumn + nCols, aCellAddress.EndRow + nRows), uno::UNO_QUERY); + aCellAddress.EndColumn, aCellAddress.EndRow), uno::UNO_QUERY); if (xMergeable.is()) - xMergeable->merge(sal_True); - } - catch ( lang::IndexOutOfBoundsException & ) - { - DBG_ERRORFILE("ScXMLTableRowCellContext::DoMerge: range to be merged larger than what we support"); + xMergeable->merge(sal_False); } + + //merge + uno::Reference <util::XMergeable> xMergeable (xCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, + aCellAddress.EndColumn + nCols, aCellAddress.EndRow + nRows), uno::UNO_QUERY); + if (xMergeable.is()) + xMergeable->merge(sal_True); } } } @@ -771,7 +747,7 @@ void ScXMLTableRowCellContext::EndElement() { if (bHasTextImport && rXMLImport.GetRemoveLastChar()) { - if (GetImport().GetTextImport()->GetCursor().is()) + if (rXMLImport.GetTextImport()->GetCursor().is()) { //GetImport().GetTextImport()->GetCursor()->gotoEnd(sal_False); if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, sal_True ) ) @@ -793,7 +769,8 @@ void ScXMLTableRowCellContext::EndElement() DoMerge(aCellPos, nMergedCols - 1, nMergedRows - 1); if ( !pOUFormula ) { - rtl::OUString* pOUText = NULL; + ::boost::optional< rtl::OUString > pOUText; + if(nCellType == util::NumberFormat::TEXT) { if (xLockable.is()) @@ -818,16 +795,14 @@ void ScXMLTableRowCellContext::EndElement() uno::Reference <text::XText> xTempText (xBaseCell, uno::UNO_QUERY); if (xTempText.is()) { - rtl::OUString sBla(xTempText->getString()); - pOUText = new rtl::OUString(sBla); + pOUText.reset(xTempText->getString()); } } - if (!pOUTextContent && !pOUText && !pOUTextValue) - bIsEmpty = sal_True; - else if ( (pOUTextContent && !pOUTextContent->getLength()) || !pOUTextContent ) - if ( (pOUText && !pOUText->getLength()) || !pOUText ) - if ( (pOUTextValue && !pOUTextValue->getLength()) || !pOUTextValue ) - bIsEmpty = sal_True; + if ( (!pOUTextContent && !pOUText && !pOUTextValue) + && ( (pOUTextContent && !pOUTextContent->getLength()) || !pOUTextContent ) + && ( (pOUText && !pOUText->getLength()) || !pOUText ) + && ( (pOUTextValue && !pOUTextValue->getLength()) || !pOUTextValue )) + bIsEmpty = sal_True; } sal_Bool bWasEmpty = bIsEmpty; // uno::Reference <table::XCell> xCell; @@ -835,11 +810,13 @@ void ScXMLTableRowCellContext::EndElement() if ((pContentValidationName && pContentValidationName->getLength()) || pMyAnnotation || pDetectiveObjVec || pCellRangeSource) bIsEmpty = sal_False; + + ScMyTables& rTables = rXMLImport.GetTables(); for (sal_Int32 i = 0; i < nCellsRepeated; ++i) { aCurrentPos.Column = aCellPos.Column + i; if (i > 0) - rXMLImport.GetTables().AddColumn(sal_False); + rTables.AddColumn(sal_False); if (!bIsEmpty) { for (sal_Int32 j = 0; j < nRepeatedRows; ++j) @@ -847,8 +824,8 @@ void ScXMLTableRowCellContext::EndElement() aCurrentPos.Row = aCellPos.Row + j; if ((aCurrentPos.Column == 0) && (j > 0)) { - rXMLImport.GetTables().AddRow(); - rXMLImport.GetTables().AddColumn(sal_False); + rTables.AddRow(); + rTables.AddColumn(sal_False); } if (CellExists(aCurrentPos)) { @@ -876,7 +853,7 @@ void ScXMLTableRowCellContext::EndElement() case util::NumberFormat::TEXT: { sal_Bool bDoIncrement = sal_True; - if (rXMLImport.GetTables().IsPartOfMatrix(aCurrentPos.Column, aCurrentPos.Row)) + if (rTables.IsPartOfMatrix(aCurrentPos.Column, aCurrentPos.Row)) { LockSolarMutex(); // test - bypass the API @@ -899,7 +876,8 @@ void ScXMLTableRowCellContext::EndElement() ScAddress aScAddress; ScUnoConversion::FillScAddress( aScAddress, aCurrentPos ); ScBaseCell* pCell = rXMLImport.GetDocument()->GetCell( aScAddress ); - if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA ) + bDoIncrement = ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA ); + if ( bDoIncrement ) { ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell); if (pOUTextValue && pOUTextValue->getLength()) @@ -911,8 +889,6 @@ void ScXMLTableRowCellContext::EndElement() else bDoIncrement = sal_False; } - else - bDoIncrement = sal_False; } else { @@ -940,14 +916,14 @@ void ScXMLTableRowCellContext::EndElement() pNewCell = ScBaseCell::CreateTextCell( *pOUTextContent, pDoc ); else if ( i > 0 && pOUText && pOUText->getLength() ) pNewCell = ScBaseCell::CreateTextCell( *pOUText, pDoc ); - if ( pNewCell ) + + bDoIncrement = pNewCell != NULL; + if ( bDoIncrement ) { ScAddress aScAddress; ScUnoConversion::FillScAddress( aScAddress, aCurrentPos ); pDoc->PutCell( aScAddress, pNewCell ); } - else - bDoIncrement = sal_False; } // #i56027# This is about setting simple text, not edit cells, // so ProgressBarIncrement must be called with bEditCell = FALSE. @@ -964,7 +940,7 @@ void ScXMLTableRowCellContext::EndElement() case util::NumberFormat::DATETIME: case util::NumberFormat::LOGICAL: { - if (rXMLImport.GetTables().IsPartOfMatrix(aCurrentPos.Column, aCurrentPos.Row)) + if (rTables.IsPartOfMatrix(aCurrentPos.Column, aCurrentPos.Row)) { LockSolarMutex(); // test - bypass the API @@ -1034,8 +1010,8 @@ void ScXMLTableRowCellContext::EndElement() if ((i == 0) && (aCellPos.Column == 0)) for (sal_Int32 j = 1; j < nRepeatedRows; ++j) { - rXMLImport.GetTables().AddRow(); - rXMLImport.GetTables().AddColumn(sal_False); + rTables.AddRow(); + rTables.AddColumn(sal_False); } } } @@ -1061,8 +1037,6 @@ void ScXMLTableRowCellContext::EndElement() //SetType(xTempCell); } - if (pOUText) - delete pOUText; } else { diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx index 7f31fe46a127..14d7fdb9786f 100644 --- a/sc/source/filter/xml/xmlcelli.hxx +++ b/sc/source/filter/xml/xmlcelli.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: xmlcelli.hxx,v $ - * $Revision: 1.26.134.1 $ + * $Revision: 1.26 $ * * This file is part of OpenOffice.org. * @@ -44,7 +44,8 @@ #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/document/XActionLockable.hpp> -#include "grammar.hxx" +#include "formula/grammar.hxx" +#include <boost/optional.hpp> class ScXMLImport; class OutlinerParaObject; @@ -67,9 +68,9 @@ class ScXMLTableRowCellContext : public SvXMLImportContext { com::sun::star::uno::Reference<com::sun::star::table::XCell> xBaseCell; com::sun::star::uno::Reference<com::sun::star::document::XActionLockable> xLockable; - rtl::OUString* pOUTextValue; - rtl::OUString* pOUTextContent; - rtl::OUString* pOUFormula; + ::boost::optional< rtl::OUString > pOUTextValue; + ::boost::optional< rtl::OUString > pOUTextContent; + ::boost::optional< rtl::OUString > pOUFormula; rtl::OUString* pContentValidationName; ScMyImportAnnotation* pMyAnnotation; ScMyImpDetectiveObjVec* pDetectiveObjVec; @@ -80,7 +81,7 @@ class ScXMLTableRowCellContext : public SvXMLImportContext sal_Int32 nRepeatedRows; sal_Int32 nCellsRepeated; ScXMLImport& rXMLImport; - ScGrammar::Grammar eGrammar; + formula::FormulaGrammar::Grammar eGrammar; sal_Int16 nCellType; sal_Bool bIsMerged; sal_Bool bIsMatrix; @@ -95,6 +96,8 @@ class ScXMLTableRowCellContext : public SvXMLImportContext const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + sal_Int16 GetCellType(const rtl::OUString& sOUValue) const; + sal_Bool IsMerged (const com::sun::star::uno::Reference <com::sun::star::table::XCellRange>& xCellRange, const sal_Int32 nCol, const sal_Int32 nRow, com::sun::star::table::CellRangeAddress& aCellAddress) const; @@ -129,10 +132,7 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); - void SetString(const rtl::OUString& rOUTempText) { - if (pOUTextContent) - delete pOUTextContent; - pOUTextContent = new ::rtl::OUString(rOUTempText); } + inline void SetString(const rtl::OUString& rOUTempText) { pOUTextContent.reset(rOUTempText); } void SetCursorOnTextImport(const rtl::OUString& rOUTempText); void SetAnnotation(const ::com::sun::star::table::CellAddress& rPosition ); @@ -145,3 +145,4 @@ public: }; #endif + diff --git a/sc/source/filter/xml/xmlcvali.cxx b/sc/source/filter/xml/xmlcvali.cxx index 7a6c4c41d211..0d78a79a5eea 100644 --- a/sc/source/filter/xml/xmlcvali.cxx +++ b/sc/source/filter/xml/xmlcvali.cxx @@ -1,788 +1,788 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: xmlcvali.cxx,v $ - * $Revision: 1.27 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - - - -// INCLUDE --------------------------------------------------------------- - -#include "xmlcvali.hxx" -#include "xmlimprt.hxx" -#include "xmlconti.hxx" -#include "document.hxx" -#include "XMLConverter.hxx" - -#include <xmloff/xmltkmap.hxx> -#include <xmloff/nmspmap.hxx> -#include <xmloff/xmltoken.hxx> -#include <xmloff/xmlnmspe.hxx> -#include <xmloff/XMLEventsImportContext.hxx> -#include <com/sun/star/sheet/TableValidationVisibility.hpp> -#include <tools/debug.hxx> - -using namespace com::sun::star; -using namespace xmloff::token; - -class ScXMLContentValidationContext : public SvXMLImportContext -{ - rtl::OUString sName; - rtl::OUString sHelpTitle; - rtl::OUString sHelpMessage; - rtl::OUString sErrorTitle; - rtl::OUString sErrorMessage; - rtl::OUString sErrorMessageType; - rtl::OUString sBaseCellAddress; - rtl::OUString sCondition; - ScGrammar::Grammar eGrammar; - sal_Int16 nShowList; - sal_Bool bAllowEmptyCell; - sal_Bool bDisplayHelp; - sal_Bool bDisplayError; - - SvXMLImportContextRef xEventContext; - - const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } - ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } - - void GetAlertStyle(const rtl::OUString& sMessageType, com::sun::star::sheet::ValidationAlertStyle& aAlertStyle); - void SetFormulas(const rtl::OUString& sFormulas, rtl::OUString& sFormula1, rtl::OUString& sFormula2) const; - void GetCondition(const rtl::OUString& sCondition, rtl::OUString& sFormula1, rtl::OUString& sFormula2, - com::sun::star::sheet::ValidationType& aValidationType, - com::sun::star::sheet::ConditionOperator& aOperator); - -public: - - ScXMLContentValidationContext( ScXMLImport& rImport, USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList); - - virtual ~ScXMLContentValidationContext(); - - virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); - - virtual void EndElement(); - - void SetHelpMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const sal_Bool bDisplay); - void SetErrorMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const rtl::OUString& sMessageType, const sal_Bool bDisplay); - void SetErrorMacro(const sal_Bool bExecute); -}; - -class ScXMLHelpMessageContext : public SvXMLImportContext -{ - rtl::OUString sTitle; - rtl::OUStringBuffer sMessage; - sal_Int32 nParagraphCount; - sal_Bool bDisplay; - - ScXMLContentValidationContext* pValidationContext; - - const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } - ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } - -public: - - ScXMLHelpMessageContext( ScXMLImport& rImport, USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList, - ScXMLContentValidationContext* pValidationContext); - - virtual ~ScXMLHelpMessageContext(); - - virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); - - virtual void EndElement(); -}; - -class ScXMLErrorMessageContext : public SvXMLImportContext -{ - rtl::OUString sTitle; - rtl::OUStringBuffer sMessage; - rtl::OUString sMessageType; - sal_Int32 nParagraphCount; - sal_Bool bDisplay; - - ScXMLContentValidationContext* pValidationContext; - - const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } - ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } - -public: - - ScXMLErrorMessageContext( ScXMLImport& rImport, USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList, - ScXMLContentValidationContext* pValidationContext); - - virtual ~ScXMLErrorMessageContext(); - - virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); - - virtual void EndElement(); -}; - -class ScXMLErrorMacroContext : public SvXMLImportContext -{ - rtl::OUString sName; - sal_Bool bExecute; - - ScXMLContentValidationContext* pValidationContext; - - const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } - ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } - -public: - - ScXMLErrorMacroContext( ScXMLImport& rImport, USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList, - ScXMLContentValidationContext* pValidationContext); - - virtual ~ScXMLErrorMacroContext(); - - virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); - virtual void EndElement(); -}; - -//------------------------------------------------------------------ - -ScXMLContentValidationsContext::ScXMLContentValidationsContext( ScXMLImport& rImport, - USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) : - SvXMLImportContext( rImport, nPrfx, rLName ) -{ - // here are no attributes -} - -ScXMLContentValidationsContext::~ScXMLContentValidationsContext() -{ -} - -SvXMLImportContext *ScXMLContentValidationsContext::CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) -{ - SvXMLImportContext *pContext = 0; - - const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationsElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLName ) ) - { - case XML_TOK_CONTENT_VALIDATION: - pContext = new ScXMLContentValidationContext( GetScImport(), nPrefix, rLName, xAttrList); - break; - } - - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); - - return pContext; -} - -void ScXMLContentValidationsContext::EndElement() -{ -} - -ScXMLContentValidationContext::ScXMLContentValidationContext( ScXMLImport& rImport, - USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : - SvXMLImportContext( rImport, nPrfx, rLName ), - sName(), - sHelpTitle(), - sHelpMessage(), - sErrorTitle(), - sErrorMessage(), - sErrorMessageType(), - sBaseCellAddress(), - sCondition(), - nShowList(sheet::TableValidationVisibility::UNSORTED), - bAllowEmptyCell(sal_True), - bDisplayHelp(sal_False), - bDisplayError(sal_False) -{ - const ScGrammar::Grammar eStorageGrammar = eGrammar = GetScImport().GetDocument()->GetStorageGrammar(); - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationAttrTokenMap(); - for( sal_Int16 i=0; i < nAttrCount; ++i ) - { - const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i )); - rtl::OUString aLocalName; - USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( - sAttrName, &aLocalName ); - const rtl::OUString& sValue(xAttrList->getValueByIndex( i )); - - switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) - { - case XML_TOK_CONTENT_VALIDATION_NAME: - sName = sValue; - break; - case XML_TOK_CONTENT_VALIDATION_CONDITION: - { - sal_uInt16 nCondPrefix = GetImport().GetNamespaceMap(). - _GetKeyByAttrName( sValue, &sCondition, sal_False ); - - if (!ScXMLImport::IsAcceptedFormulaNamespace( nCondPrefix, - sValue, eGrammar, eStorageGrammar)) - sCondition = sValue; - } - break; - case XML_TOK_CONTENT_VALIDATION_BASE_CELL_ADDRESS: - sBaseCellAddress = sValue; - break; - case XML_TOK_CONTENT_VALIDATION_ALLOW_EMPTY_CELL: - if (IsXMLToken(sValue, XML_FALSE)) - bAllowEmptyCell = sal_False; - break; - case XML_TOK_CONTENT_VALIDATION_DISPLAY_LIST: - { - if (IsXMLToken(sValue, XML_NO)) - { - nShowList = sheet::TableValidationVisibility::INVISIBLE; - } - else if (IsXMLToken(sValue, XML_UNSORTED)) - { - nShowList = sheet::TableValidationVisibility::UNSORTED; - } - else if (IsXMLToken(sValue, XML_SORTED_ASCENDING)) - { - nShowList = sheet::TableValidationVisibility::SORTEDASCENDING; - } - } - break; - } - } -} - -ScXMLContentValidationContext::~ScXMLContentValidationContext() -{ -} - -SvXMLImportContext *ScXMLContentValidationContext::CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) -{ - SvXMLImportContext *pContext = 0; - - const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLName ) ) - { - case XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE: - pContext = new ScXMLHelpMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this); - break; - case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE: - pContext = new ScXMLErrorMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this); - break; - case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO: - pContext = new ScXMLErrorMacroContext( GetScImport(), nPrefix, rLName, xAttrList, this); - break; - case XML_TOK_CONTENT_VALIDATION_ELEM_EVENT_LISTENERS: - pContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName ); - xEventContext = pContext; - break; - } - - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); - - return pContext; -} - -void ScXMLContentValidationContext::GetAlertStyle(const rtl::OUString& sMessageType, com::sun::star::sheet::ValidationAlertStyle& aAlertStyle) -{ - if (IsXMLToken(sMessageType, XML_MACRO)) - aAlertStyle = sheet::ValidationAlertStyle_MACRO; - else if (IsXMLToken(sMessageType, XML_STOP)) - aAlertStyle = sheet::ValidationAlertStyle_STOP; - else if (IsXMLToken(sMessageType, XML_WARNING)) - aAlertStyle = sheet::ValidationAlertStyle_WARNING; - else if (IsXMLToken(sMessageType, XML_INFORMATION)) - aAlertStyle = sheet::ValidationAlertStyle_INFO; - else // don't leave uninitialized - aAlertStyle = sheet::ValidationAlertStyle_STOP; -} - -void ScXMLContentValidationContext::SetFormulas(const rtl::OUString& sFormulas, rtl::OUString& sFormula1, rtl::OUString& sFormula2) const -{ - sal_Int32 i = 0; - sal_Bool bString = sal_False; - sal_Int32 nBrakes = 0; - while ((sFormulas[i] != ',' || nBrakes > 0 || bString) && i < sFormulas.getLength()) - { - if (sFormulas[i] == '(') - ++nBrakes; - if (sFormulas[i] == ')') - --nBrakes; - if (sFormulas[i] == '"') - bString = !bString; - ++i; - } - if (sFormulas[i] == ',') - { - sFormula1 = sFormulas.copy(0, i); - sFormula2 = sFormulas.copy(i + 1); - } -} - -void ScXMLContentValidationContext::GetCondition(const rtl::OUString& sTempCondition, rtl::OUString& sFormula1, rtl::OUString& sFormula2, - com::sun::star::sheet::ValidationType& aValidationType, - com::sun::star::sheet::ConditionOperator& aOperator) -{ - aValidationType = sheet::ValidationType_ANY; // #b6343997# default if no condition is given - aOperator = sheet::ConditionOperator_NONE; - - rtl::OUString sLocalCondition(sTempCondition); - if (sLocalCondition.getLength()) - { - // ToDo: erase all blanks in the condition, but not in formulas or strings - rtl::OUString scell_content(RTL_CONSTASCII_USTRINGPARAM("cell_content")); - rtl::OUString scell_content_is_date(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-date")); - rtl::OUString scell_content_is_time(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-time")); - rtl::OUString scell_content_is_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-between")); - rtl::OUString scell_content_is_in_list(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-in-list")); - rtl::OUString scell_content_text_length(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length")); - rtl::OUString scell_content_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-not-between")); - rtl::OUString scell_content_is_whole_number(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-whole-number")); - rtl::OUString scell_content_is_decimal_number(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-decimal-number")); - rtl::OUString scell_content_text_length_is_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-between")); - rtl::OUString scell_content_text_length_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-not-between")); - sal_Int32 i = 0; - sal_Bool bAnd(sal_True); - while (sLocalCondition[i] != '(' && i < sLocalCondition.getLength()) - ++i; - if (sLocalCondition[i] == '(') - { - if (i != scell_content_text_length.getLength() && - i != scell_content_text_length_is_between.getLength() && - i != scell_content_text_length_is_not_between.getLength() && - i != scell_content_is_in_list.getLength()) - { - if (i == scell_content_is_time.getLength()) - { - rtl::OUString sTemp = sLocalCondition.copy(0, i); - if (sTemp == scell_content_is_time) - aValidationType = sheet::ValidationType_TIME; - else - aValidationType = sheet::ValidationType_DATE; - } - else if (i == scell_content_is_whole_number.getLength()) - aValidationType = sheet::ValidationType_WHOLE; - else if (i == scell_content_is_decimal_number.getLength()) - aValidationType = sheet::ValidationType_DECIMAL; - sLocalCondition = sLocalCondition.copy(i + 2); - rtl::OUString sTemp = sLocalCondition.copy(0, 5); - if (sTemp.compareToAscii(" and ") == 0) - sLocalCondition = sLocalCondition.copy(5); - else - bAnd = sal_False; - } - if (sLocalCondition.getLength() && bAnd) - { - i = 0; - while (sLocalCondition[i] != '(' && i < sLocalCondition.getLength()) - ++i; - if (sLocalCondition[i] == '(') - { - rtl::OUString sTemp = sLocalCondition.copy(0, i); - sLocalCondition = sLocalCondition.copy(i + 1); - if (i == scell_content_is_between.getLength() || - i == scell_content_text_length_is_between.getLength()) - { - if (sTemp == scell_content_is_in_list) - { - aValidationType = sheet::ValidationType_LIST; - sFormula1 = sLocalCondition.copy(0, sLocalCondition.getLength() - 1); - aOperator = sheet::ConditionOperator_EQUAL; - } - else - { - if (i == scell_content_text_length_is_between.getLength()) - aValidationType = sheet::ValidationType_TEXT_LEN; - aOperator = sheet::ConditionOperator_BETWEEN; - sLocalCondition = sLocalCondition.copy(0, sLocalCondition.getLength() - 1); - SetFormulas(sLocalCondition, sFormula1, sFormula2); - } - } - else if (i == scell_content_is_not_between.getLength() || - i == scell_content_text_length_is_not_between.getLength()) - { - if (i == scell_content_text_length_is_not_between.getLength()) - aValidationType = sheet::ValidationType_TEXT_LEN; - aOperator = sheet::ConditionOperator_NOT_BETWEEN; - sLocalCondition = sLocalCondition.copy(0, sLocalCondition.getLength() - 1); - SetFormulas(sLocalCondition, sFormula1, sFormula2); - } - else if (i == scell_content.getLength() || - i == scell_content_text_length.getLength()) - { - if (i == scell_content_text_length.getLength()) - aValidationType = sheet::ValidationType_TEXT_LEN; - sLocalCondition = sLocalCondition.copy(1); - switch (sLocalCondition[0]) - { - case '<' : - { - if (sLocalCondition[1] == '=') - { - aOperator = sheet::ConditionOperator_LESS_EQUAL; - sLocalCondition = sLocalCondition.copy(2); - } - else - { - aOperator = sheet::ConditionOperator_LESS; - sLocalCondition = sLocalCondition.copy(1); - } - } - break; - case '>' : - { - if (sLocalCondition[1] == '=') - { - aOperator = sheet::ConditionOperator_GREATER_EQUAL; - sLocalCondition = sLocalCondition.copy(2); - } - else - { - aOperator = sheet::ConditionOperator_GREATER; - sLocalCondition = sLocalCondition.copy(1); - } - } - break; - case '=' : - { - aOperator = sheet::ConditionOperator_EQUAL; - sLocalCondition = sLocalCondition.copy(1); - } - break; - case '!' : - { - aOperator = sheet::ConditionOperator_NOT_EQUAL; - sLocalCondition = sLocalCondition.copy(1); - } - break; - } - sFormula1 = sLocalCondition; - } - } - } - } - } - - // a validation type (date, integer) without a condition isn't possible - if ( aOperator == sheet::ConditionOperator_NONE ) - aValidationType = sheet::ValidationType_ANY; -} - -void ScXMLContentValidationContext::EndElement() -{ - // #i36650# event-listeners element moved up one level - if (xEventContext.Is()) - { - rtl::OUString sOnError(RTL_CONSTASCII_USTRINGPARAM("OnError")); - XMLEventsImportContext* pEvents = - (XMLEventsImportContext*)&xEventContext; - uno::Sequence<beans::PropertyValue> aValues; - pEvents->GetEventSequence( sOnError, aValues ); - - sal_Int32 nLength = aValues.getLength(); - for( sal_Int32 i = 0; i < nLength; i++ ) - { - // #i47525# must allow "MacroName" or "Script" - if ( aValues[i].Name.equalsAsciiL( "MacroName", sizeof("MacroName")-1 ) || - aValues[i].Name.equalsAsciiL( "Script", sizeof("Script")-1 ) ) - { - aValues[i].Value >>= sErrorTitle; - break; - } - } - } - - ScMyImportValidation aValidation; - aValidation.eGrammar = eGrammar; - aValidation.sName = sName; - aValidation.sBaseCellAddress = sBaseCellAddress; - aValidation.sImputTitle = sHelpTitle; - aValidation.sImputMessage = sHelpMessage; - aValidation.sErrorTitle = sErrorTitle; - aValidation.sErrorMessage = sErrorMessage; - GetCondition(sCondition, aValidation.sFormula1, aValidation.sFormula2, aValidation.aValidationType, aValidation.aOperator); - GetAlertStyle(sErrorMessageType, aValidation.aAlertStyle); - aValidation.bShowErrorMessage = bDisplayError; - aValidation.bShowImputMessage = bDisplayHelp; - aValidation.bIgnoreBlanks = bAllowEmptyCell; - aValidation.nShowList = nShowList; - GetScImport().AddValidation(aValidation); -} - -void ScXMLContentValidationContext::SetHelpMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const sal_Bool bDisplay) -{ - sHelpTitle = sTitle; - sHelpMessage = sMessage; - bDisplayHelp = bDisplay; -} - -void ScXMLContentValidationContext::SetErrorMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, - const rtl::OUString& sMessageType, const sal_Bool bDisplay) -{ - sErrorTitle = sTitle; - sErrorMessage = sMessage; - sErrorMessageType = sMessageType; - bDisplayError = bDisplay; -} - -void ScXMLContentValidationContext::SetErrorMacro(const sal_Bool bExecute) -{ - sErrorMessageType = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("macro")); - bDisplayError = bExecute; -} - -ScXMLHelpMessageContext::ScXMLHelpMessageContext( ScXMLImport& rImport, - USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList, - ScXMLContentValidationContext* pTempValidationContext) : - SvXMLImportContext( rImport, nPrfx, rLName ), - sTitle(), - sMessage(), - nParagraphCount(0), - bDisplay(sal_False) -{ - pValidationContext = pTempValidationContext; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationHelpMessageAttrTokenMap(); - for( sal_Int16 i=0; i < nAttrCount; ++i ) - { - const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i )); - rtl::OUString aLocalName; - USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( - sAttrName, &aLocalName ); - const rtl::OUString& sValue(xAttrList->getValueByIndex( i )); - - switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) - { - case XML_TOK_HELP_MESSAGE_ATTR_TITLE: - sTitle = sValue; - break; - case XML_TOK_HELP_MESSAGE_ATTR_DISPLAY: - bDisplay = IsXMLToken(sValue, XML_TRUE); - break; - } - } -} - -ScXMLHelpMessageContext::~ScXMLHelpMessageContext() -{ -} - -SvXMLImportContext *ScXMLHelpMessageContext::CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) -{ - SvXMLImportContext *pContext = 0; - - const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationMessageElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLName ) ) - { - case XML_TOK_P: - { - if(nParagraphCount) - sMessage.append(static_cast<sal_Unicode>('\n')); - ++nParagraphCount; - pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sMessage); - } - break; - } - - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); - - return pContext; -} - -void ScXMLHelpMessageContext::EndElement() -{ - pValidationContext->SetHelpMessage(sTitle, sMessage.makeStringAndClear(), bDisplay); -} - -ScXMLErrorMessageContext::ScXMLErrorMessageContext( ScXMLImport& rImport, - USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList, - ScXMLContentValidationContext* pTempValidationContext) : - SvXMLImportContext( rImport, nPrfx, rLName ), - sTitle(), - sMessage(), - sMessageType(), - nParagraphCount(0), - bDisplay(sal_False) -{ - pValidationContext = pTempValidationContext; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMessageAttrTokenMap(); - for( sal_Int16 i=0; i < nAttrCount; ++i ) - { - const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i )); - rtl::OUString aLocalName; - USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( - sAttrName, &aLocalName ); - const rtl::OUString& sValue(xAttrList->getValueByIndex( i )); - - switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) - { - case XML_TOK_ERROR_MESSAGE_ATTR_TITLE: - sTitle = sValue; - break; - case XML_TOK_ERROR_MESSAGE_ATTR_MESSAGE_TYPE: - sMessageType = sValue; - break; - case XML_TOK_ERROR_MESSAGE_ATTR_DISPLAY: - bDisplay = IsXMLToken(sValue, XML_TRUE); - break; - } - } -} - -ScXMLErrorMessageContext::~ScXMLErrorMessageContext() -{ -} - -SvXMLImportContext *ScXMLErrorMessageContext::CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) -{ - SvXMLImportContext *pContext = 0; - - const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationMessageElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLName ) ) - { - case XML_TOK_P: - { - if(nParagraphCount) - sMessage.append(static_cast<sal_Unicode>('\n')); - ++nParagraphCount; - pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sMessage); - } - break; - } - - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); - - return pContext; -} - -void ScXMLErrorMessageContext::EndElement() -{ - pValidationContext->SetErrorMessage(sTitle, sMessage.makeStringAndClear(), sMessageType, bDisplay); -} - -ScXMLErrorMacroContext::ScXMLErrorMacroContext( ScXMLImport& rImport, - USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList, - ScXMLContentValidationContext* pTempValidationContext) : - SvXMLImportContext( rImport, nPrfx, rLName ), - sName(), - bExecute(sal_False) -{ - pValidationContext = pTempValidationContext; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMacroAttrTokenMap(); - for( sal_Int16 i=0; i < nAttrCount; ++i ) - { - const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i )); - rtl::OUString aLocalName; - USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( - sAttrName, &aLocalName ); - const rtl::OUString& sValue(xAttrList->getValueByIndex( i )); - - switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) - { - case XML_TOK_ERROR_MACRO_ATTR_NAME: - sName = sValue; - break; - case XML_TOK_ERROR_MACRO_ATTR_EXECUTE: - bExecute = IsXMLToken(sValue, XML_TRUE); - break; - } - } -} - -ScXMLErrorMacroContext::~ScXMLErrorMacroContext() -{ -} - -SvXMLImportContext *ScXMLErrorMacroContext::CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) -{ - SvXMLImportContext *pContext = NULL; - - if ((nPrefix == XML_NAMESPACE_SCRIPT) && IsXMLToken(rLName, XML_EVENTS)) - { - pContext = new XMLEventsImportContext(GetImport(), nPrefix, rLName); - } - if (!pContext) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); - - return pContext; -} - -void ScXMLErrorMacroContext::EndElement() -{ - pValidationContext->SetErrorMacro( bExecute ); -} +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: xmlcvali.cxx,v $
+ * $Revision: 1.27 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "xmlcvali.hxx"
+#include "xmlimprt.hxx"
+#include "xmlconti.hxx"
+#include "document.hxx"
+#include "XMLConverter.hxx"
+
+#include <xmloff/xmltkmap.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/XMLEventsImportContext.hxx>
+#include <com/sun/star/sheet/TableValidationVisibility.hpp>
+#include <tools/debug.hxx>
+
+using namespace com::sun::star;
+using namespace xmloff::token;
+
+class ScXMLContentValidationContext : public SvXMLImportContext
+{
+ rtl::OUString sName;
+ rtl::OUString sHelpTitle;
+ rtl::OUString sHelpMessage;
+ rtl::OUString sErrorTitle;
+ rtl::OUString sErrorMessage;
+ rtl::OUString sErrorMessageType;
+ rtl::OUString sBaseCellAddress;
+ rtl::OUString sCondition;
+ formula::FormulaGrammar::Grammar eGrammar;
+ sal_Int16 nShowList;
+ sal_Bool bAllowEmptyCell;
+ sal_Bool bDisplayHelp;
+ sal_Bool bDisplayError;
+
+ SvXMLImportContextRef xEventContext;
+
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+
+ void GetAlertStyle(const rtl::OUString& sMessageType, com::sun::star::sheet::ValidationAlertStyle& aAlertStyle);
+ void SetFormulas(const rtl::OUString& sFormulas, rtl::OUString& sFormula1, rtl::OUString& sFormula2) const;
+ void GetCondition(const rtl::OUString& sCondition, rtl::OUString& sFormula1, rtl::OUString& sFormula2,
+ com::sun::star::sheet::ValidationType& aValidationType,
+ com::sun::star::sheet::ConditionOperator& aOperator);
+
+public:
+
+ ScXMLContentValidationContext( ScXMLImport& rImport, USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList);
+
+ virtual ~ScXMLContentValidationContext();
+
+ virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+
+ virtual void EndElement();
+
+ void SetHelpMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const sal_Bool bDisplay);
+ void SetErrorMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const rtl::OUString& sMessageType, const sal_Bool bDisplay);
+ void SetErrorMacro(const sal_Bool bExecute);
+};
+
+class ScXMLHelpMessageContext : public SvXMLImportContext
+{
+ rtl::OUString sTitle;
+ rtl::OUStringBuffer sMessage;
+ sal_Int32 nParagraphCount;
+ sal_Bool bDisplay;
+
+ ScXMLContentValidationContext* pValidationContext;
+
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+
+public:
+
+ ScXMLHelpMessageContext( ScXMLImport& rImport, USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pValidationContext);
+
+ virtual ~ScXMLHelpMessageContext();
+
+ virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+
+ virtual void EndElement();
+};
+
+class ScXMLErrorMessageContext : public SvXMLImportContext
+{
+ rtl::OUString sTitle;
+ rtl::OUStringBuffer sMessage;
+ rtl::OUString sMessageType;
+ sal_Int32 nParagraphCount;
+ sal_Bool bDisplay;
+
+ ScXMLContentValidationContext* pValidationContext;
+
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+
+public:
+
+ ScXMLErrorMessageContext( ScXMLImport& rImport, USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pValidationContext);
+
+ virtual ~ScXMLErrorMessageContext();
+
+ virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+
+ virtual void EndElement();
+};
+
+class ScXMLErrorMacroContext : public SvXMLImportContext
+{
+ rtl::OUString sName;
+ sal_Bool bExecute;
+
+ ScXMLContentValidationContext* pValidationContext;
+
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+
+public:
+
+ ScXMLErrorMacroContext( ScXMLImport& rImport, USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pValidationContext);
+
+ virtual ~ScXMLErrorMacroContext();
+
+ virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+ virtual void EndElement();
+};
+
+//------------------------------------------------------------------
+
+ScXMLContentValidationsContext::ScXMLContentValidationsContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+ // here are no attributes
+}
+
+ScXMLContentValidationsContext::~ScXMLContentValidationsContext()
+{
+}
+
+SvXMLImportContext *ScXMLContentValidationsContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationsElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ case XML_TOK_CONTENT_VALIDATION:
+ pContext = new ScXMLContentValidationContext( GetScImport(), nPrefix, rLName, xAttrList);
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLContentValidationsContext::EndElement()
+{
+}
+
+ScXMLContentValidationContext::ScXMLContentValidationContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ sName(),
+ sHelpTitle(),
+ sHelpMessage(),
+ sErrorTitle(),
+ sErrorMessage(),
+ sErrorMessageType(),
+ sBaseCellAddress(),
+ sCondition(),
+ nShowList(sheet::TableValidationVisibility::UNSORTED),
+ bAllowEmptyCell(sal_True),
+ bDisplayHelp(sal_False),
+ bDisplayError(sal_False)
+{
+ const formula::FormulaGrammar::Grammar eStorageGrammar = eGrammar = GetScImport().GetDocument()->GetStorageGrammar();
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationAttrTokenMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName );
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_CONTENT_VALIDATION_NAME:
+ sName = sValue;
+ break;
+ case XML_TOK_CONTENT_VALIDATION_CONDITION:
+ {
+ sal_uInt16 nCondPrefix = GetImport().GetNamespaceMap().
+ _GetKeyByAttrName( sValue, &sCondition, sal_False );
+
+ if (!ScXMLImport::IsAcceptedFormulaNamespace( nCondPrefix,
+ sValue, eGrammar, eStorageGrammar))
+ sCondition = sValue;
+ }
+ break;
+ case XML_TOK_CONTENT_VALIDATION_BASE_CELL_ADDRESS:
+ sBaseCellAddress = sValue;
+ break;
+ case XML_TOK_CONTENT_VALIDATION_ALLOW_EMPTY_CELL:
+ if (IsXMLToken(sValue, XML_FALSE))
+ bAllowEmptyCell = sal_False;
+ break;
+ case XML_TOK_CONTENT_VALIDATION_DISPLAY_LIST:
+ {
+ if (IsXMLToken(sValue, XML_NO))
+ {
+ nShowList = sheet::TableValidationVisibility::INVISIBLE;
+ }
+ else if (IsXMLToken(sValue, XML_UNSORTED))
+ {
+ nShowList = sheet::TableValidationVisibility::UNSORTED;
+ }
+ else if (IsXMLToken(sValue, XML_SORTED_ASCENDING))
+ {
+ nShowList = sheet::TableValidationVisibility::SORTEDASCENDING;
+ }
+ }
+ break;
+ }
+ }
+}
+
+ScXMLContentValidationContext::~ScXMLContentValidationContext()
+{
+}
+
+SvXMLImportContext *ScXMLContentValidationContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ case XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE:
+ pContext = new ScXMLHelpMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this);
+ break;
+ case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE:
+ pContext = new ScXMLErrorMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this);
+ break;
+ case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO:
+ pContext = new ScXMLErrorMacroContext( GetScImport(), nPrefix, rLName, xAttrList, this);
+ break;
+ case XML_TOK_CONTENT_VALIDATION_ELEM_EVENT_LISTENERS:
+ pContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName );
+ xEventContext = pContext;
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLContentValidationContext::GetAlertStyle(const rtl::OUString& sMessageType, com::sun::star::sheet::ValidationAlertStyle& aAlertStyle)
+{
+ if (IsXMLToken(sMessageType, XML_MACRO))
+ aAlertStyle = sheet::ValidationAlertStyle_MACRO;
+ else if (IsXMLToken(sMessageType, XML_STOP))
+ aAlertStyle = sheet::ValidationAlertStyle_STOP;
+ else if (IsXMLToken(sMessageType, XML_WARNING))
+ aAlertStyle = sheet::ValidationAlertStyle_WARNING;
+ else if (IsXMLToken(sMessageType, XML_INFORMATION))
+ aAlertStyle = sheet::ValidationAlertStyle_INFO;
+ else // don't leave uninitialized
+ aAlertStyle = sheet::ValidationAlertStyle_STOP;
+}
+
+void ScXMLContentValidationContext::SetFormulas(const rtl::OUString& sFormulas, rtl::OUString& sFormula1, rtl::OUString& sFormula2) const
+{
+ sal_Int32 i = 0;
+ sal_Bool bString = sal_False;
+ sal_Int32 nBrakes = 0;
+ while ((sFormulas[i] != ',' || nBrakes > 0 || bString) && i < sFormulas.getLength())
+ {
+ if (sFormulas[i] == '(')
+ ++nBrakes;
+ if (sFormulas[i] == ')')
+ --nBrakes;
+ if (sFormulas[i] == '"')
+ bString = !bString;
+ ++i;
+ }
+ if (sFormulas[i] == ',')
+ {
+ sFormula1 = sFormulas.copy(0, i);
+ sFormula2 = sFormulas.copy(i + 1);
+ }
+}
+
+void ScXMLContentValidationContext::GetCondition(const rtl::OUString& sTempCondition, rtl::OUString& sFormula1, rtl::OUString& sFormula2,
+ com::sun::star::sheet::ValidationType& aValidationType,
+ com::sun::star::sheet::ConditionOperator& aOperator)
+{
+ aValidationType = sheet::ValidationType_ANY; // #b6343997# default if no condition is given
+ aOperator = sheet::ConditionOperator_NONE;
+
+ rtl::OUString sLocalCondition(sTempCondition);
+ if (sLocalCondition.getLength())
+ {
+ // ToDo: erase all blanks in the condition, but not in formulas or strings
+ rtl::OUString scell_content(RTL_CONSTASCII_USTRINGPARAM("cell_content"));
+ rtl::OUString scell_content_is_date(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-date"));
+ rtl::OUString scell_content_is_time(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-time"));
+ rtl::OUString scell_content_is_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-between"));
+ rtl::OUString scell_content_is_in_list(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-in-list"));
+ rtl::OUString scell_content_text_length(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length"));
+ rtl::OUString scell_content_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-not-between"));
+ rtl::OUString scell_content_is_whole_number(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-whole-number"));
+ rtl::OUString scell_content_is_decimal_number(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-decimal-number"));
+ rtl::OUString scell_content_text_length_is_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-between"));
+ rtl::OUString scell_content_text_length_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-not-between"));
+ sal_Int32 i = 0;
+ sal_Bool bAnd(sal_True);
+ while (sLocalCondition[i] != '(' && i < sLocalCondition.getLength())
+ ++i;
+ if (sLocalCondition[i] == '(')
+ {
+ if (i != scell_content_text_length.getLength() &&
+ i != scell_content_text_length_is_between.getLength() &&
+ i != scell_content_text_length_is_not_between.getLength() &&
+ i != scell_content_is_in_list.getLength())
+ {
+ if (i == scell_content_is_time.getLength())
+ {
+ rtl::OUString sTemp = sLocalCondition.copy(0, i);
+ if (sTemp == scell_content_is_time)
+ aValidationType = sheet::ValidationType_TIME;
+ else
+ aValidationType = sheet::ValidationType_DATE;
+ }
+ else if (i == scell_content_is_whole_number.getLength())
+ aValidationType = sheet::ValidationType_WHOLE;
+ else if (i == scell_content_is_decimal_number.getLength())
+ aValidationType = sheet::ValidationType_DECIMAL;
+ sLocalCondition = sLocalCondition.copy(i + 2);
+ rtl::OUString sTemp = sLocalCondition.copy(0, 5);
+ if (sTemp.compareToAscii(" and ") == 0)
+ sLocalCondition = sLocalCondition.copy(5);
+ else
+ bAnd = sal_False;
+ }
+ if (sLocalCondition.getLength() && bAnd)
+ {
+ i = 0;
+ while (sLocalCondition[i] != '(' && i < sLocalCondition.getLength())
+ ++i;
+ if (sLocalCondition[i] == '(')
+ {
+ rtl::OUString sTemp = sLocalCondition.copy(0, i);
+ sLocalCondition = sLocalCondition.copy(i + 1);
+ if (i == scell_content_is_between.getLength() ||
+ i == scell_content_text_length_is_between.getLength())
+ {
+ if (sTemp == scell_content_is_in_list)
+ {
+ aValidationType = sheet::ValidationType_LIST;
+ sFormula1 = sLocalCondition.copy(0, sLocalCondition.getLength() - 1);
+ aOperator = sheet::ConditionOperator_EQUAL;
+ }
+ else
+ {
+ if (i == scell_content_text_length_is_between.getLength())
+ aValidationType = sheet::ValidationType_TEXT_LEN;
+ aOperator = sheet::ConditionOperator_BETWEEN;
+ sLocalCondition = sLocalCondition.copy(0, sLocalCondition.getLength() - 1);
+ SetFormulas(sLocalCondition, sFormula1, sFormula2);
+ }
+ }
+ else if (i == scell_content_is_not_between.getLength() ||
+ i == scell_content_text_length_is_not_between.getLength())
+ {
+ if (i == scell_content_text_length_is_not_between.getLength())
+ aValidationType = sheet::ValidationType_TEXT_LEN;
+ aOperator = sheet::ConditionOperator_NOT_BETWEEN;
+ sLocalCondition = sLocalCondition.copy(0, sLocalCondition.getLength() - 1);
+ SetFormulas(sLocalCondition, sFormula1, sFormula2);
+ }
+ else if (i == scell_content.getLength() ||
+ i == scell_content_text_length.getLength())
+ {
+ if (i == scell_content_text_length.getLength())
+ aValidationType = sheet::ValidationType_TEXT_LEN;
+ sLocalCondition = sLocalCondition.copy(1);
+ switch (sLocalCondition[0])
+ {
+ case '<' :
+ {
+ if (sLocalCondition[1] == '=')
+ {
+ aOperator = sheet::ConditionOperator_LESS_EQUAL;
+ sLocalCondition = sLocalCondition.copy(2);
+ }
+ else
+ {
+ aOperator = sheet::ConditionOperator_LESS;
+ sLocalCondition = sLocalCondition.copy(1);
+ }
+ }
+ break;
+ case '>' :
+ {
+ if (sLocalCondition[1] == '=')
+ {
+ aOperator = sheet::ConditionOperator_GREATER_EQUAL;
+ sLocalCondition = sLocalCondition.copy(2);
+ }
+ else
+ {
+ aOperator = sheet::ConditionOperator_GREATER;
+ sLocalCondition = sLocalCondition.copy(1);
+ }
+ }
+ break;
+ case '=' :
+ {
+ aOperator = sheet::ConditionOperator_EQUAL;
+ sLocalCondition = sLocalCondition.copy(1);
+ }
+ break;
+ case '!' :
+ {
+ aOperator = sheet::ConditionOperator_NOT_EQUAL;
+ sLocalCondition = sLocalCondition.copy(1);
+ }
+ break;
+ }
+ sFormula1 = sLocalCondition;
+ }
+ }
+ }
+ }
+ }
+
+ // a validation type (date, integer) without a condition isn't possible
+ if ( aOperator == sheet::ConditionOperator_NONE )
+ aValidationType = sheet::ValidationType_ANY;
+}
+
+void ScXMLContentValidationContext::EndElement()
+{
+ // #i36650# event-listeners element moved up one level
+ if (xEventContext.Is())
+ {
+ rtl::OUString sOnError(RTL_CONSTASCII_USTRINGPARAM("OnError"));
+ XMLEventsImportContext* pEvents =
+ (XMLEventsImportContext*)&xEventContext;
+ uno::Sequence<beans::PropertyValue> aValues;
+ pEvents->GetEventSequence( sOnError, aValues );
+
+ sal_Int32 nLength = aValues.getLength();
+ for( sal_Int32 i = 0; i < nLength; i++ )
+ {
+ // #i47525# must allow "MacroName" or "Script"
+ if ( aValues[i].Name.equalsAsciiL( "MacroName", sizeof("MacroName")-1 ) ||
+ aValues[i].Name.equalsAsciiL( "Script", sizeof("Script")-1 ) )
+ {
+ aValues[i].Value >>= sErrorTitle;
+ break;
+ }
+ }
+ }
+
+ ScMyImportValidation aValidation;
+ aValidation.eGrammar = eGrammar;
+ aValidation.sName = sName;
+ aValidation.sBaseCellAddress = sBaseCellAddress;
+ aValidation.sImputTitle = sHelpTitle;
+ aValidation.sImputMessage = sHelpMessage;
+ aValidation.sErrorTitle = sErrorTitle;
+ aValidation.sErrorMessage = sErrorMessage;
+ GetCondition(sCondition, aValidation.sFormula1, aValidation.sFormula2, aValidation.aValidationType, aValidation.aOperator);
+ GetAlertStyle(sErrorMessageType, aValidation.aAlertStyle);
+ aValidation.bShowErrorMessage = bDisplayError;
+ aValidation.bShowImputMessage = bDisplayHelp;
+ aValidation.bIgnoreBlanks = bAllowEmptyCell;
+ aValidation.nShowList = nShowList;
+ GetScImport().AddValidation(aValidation);
+}
+
+void ScXMLContentValidationContext::SetHelpMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const sal_Bool bDisplay)
+{
+ sHelpTitle = sTitle;
+ sHelpMessage = sMessage;
+ bDisplayHelp = bDisplay;
+}
+
+void ScXMLContentValidationContext::SetErrorMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage,
+ const rtl::OUString& sMessageType, const sal_Bool bDisplay)
+{
+ sErrorTitle = sTitle;
+ sErrorMessage = sMessage;
+ sErrorMessageType = sMessageType;
+ bDisplayError = bDisplay;
+}
+
+void ScXMLContentValidationContext::SetErrorMacro(const sal_Bool bExecute)
+{
+ sErrorMessageType = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("macro"));
+ bDisplayError = bExecute;
+}
+
+ScXMLHelpMessageContext::ScXMLHelpMessageContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pTempValidationContext) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ sTitle(),
+ sMessage(),
+ nParagraphCount(0),
+ bDisplay(sal_False)
+{
+ pValidationContext = pTempValidationContext;
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationHelpMessageAttrTokenMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName );
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_HELP_MESSAGE_ATTR_TITLE:
+ sTitle = sValue;
+ break;
+ case XML_TOK_HELP_MESSAGE_ATTR_DISPLAY:
+ bDisplay = IsXMLToken(sValue, XML_TRUE);
+ break;
+ }
+ }
+}
+
+ScXMLHelpMessageContext::~ScXMLHelpMessageContext()
+{
+}
+
+SvXMLImportContext *ScXMLHelpMessageContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationMessageElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ case XML_TOK_P:
+ {
+ if(nParagraphCount)
+ sMessage.append(static_cast<sal_Unicode>('\n'));
+ ++nParagraphCount;
+ pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sMessage);
+ }
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLHelpMessageContext::EndElement()
+{
+ pValidationContext->SetHelpMessage(sTitle, sMessage.makeStringAndClear(), bDisplay);
+}
+
+ScXMLErrorMessageContext::ScXMLErrorMessageContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pTempValidationContext) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ sTitle(),
+ sMessage(),
+ sMessageType(),
+ nParagraphCount(0),
+ bDisplay(sal_False)
+{
+ pValidationContext = pTempValidationContext;
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMessageAttrTokenMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName );
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_ERROR_MESSAGE_ATTR_TITLE:
+ sTitle = sValue;
+ break;
+ case XML_TOK_ERROR_MESSAGE_ATTR_MESSAGE_TYPE:
+ sMessageType = sValue;
+ break;
+ case XML_TOK_ERROR_MESSAGE_ATTR_DISPLAY:
+ bDisplay = IsXMLToken(sValue, XML_TRUE);
+ break;
+ }
+ }
+}
+
+ScXMLErrorMessageContext::~ScXMLErrorMessageContext()
+{
+}
+
+SvXMLImportContext *ScXMLErrorMessageContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationMessageElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ case XML_TOK_P:
+ {
+ if(nParagraphCount)
+ sMessage.append(static_cast<sal_Unicode>('\n'));
+ ++nParagraphCount;
+ pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sMessage);
+ }
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLErrorMessageContext::EndElement()
+{
+ pValidationContext->SetErrorMessage(sTitle, sMessage.makeStringAndClear(), sMessageType, bDisplay);
+}
+
+ScXMLErrorMacroContext::ScXMLErrorMacroContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pTempValidationContext) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ sName(),
+ bExecute(sal_False)
+{
+ pValidationContext = pTempValidationContext;
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMacroAttrTokenMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName );
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_ERROR_MACRO_ATTR_NAME:
+ sName = sValue;
+ break;
+ case XML_TOK_ERROR_MACRO_ATTR_EXECUTE:
+ bExecute = IsXMLToken(sValue, XML_TRUE);
+ break;
+ }
+ }
+}
+
+ScXMLErrorMacroContext::~ScXMLErrorMacroContext()
+{
+}
+
+SvXMLImportContext *ScXMLErrorMacroContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
+{
+ SvXMLImportContext *pContext = NULL;
+
+ if ((nPrefix == XML_NAMESPACE_SCRIPT) && IsXMLToken(rLName, XML_EVENTS))
+ {
+ pContext = new XMLEventsImportContext(GetImport(), nPrefix, rLName);
+ }
+ if (!pContext)
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLErrorMacroContext::EndElement()
+{
+ pValidationContext->SetErrorMacro( bExecute );
+}
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 8076fe7a8e83..4e006963421b 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -2389,8 +2389,8 @@ void ScXMLExport::WriteCell (ScMyCell& aCell) ScFormulaCell* pFormulaCell((ScFormulaCell*) pBaseCell); if (!bIsMatrix || (bIsMatrix && bIsFirstMatrixCell)) { - const ScGrammar::Grammar eGrammar = pDoc->GetStorageGrammar(); - sal_uInt16 nNamespacePrefix = (eGrammar == ScGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC); + const formula::FormulaGrammar::Grammar eGrammar = pDoc->GetStorageGrammar(); + sal_uInt16 nNamespacePrefix = (eGrammar == formula::FormulaGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC); pFormulaCell->GetFormula(sFormula, eGrammar); rtl::OUString sOUFormula(sFormula.makeStringAndClear()); if (!bIsMatrix) @@ -3831,10 +3831,10 @@ void SAL_CALL ScXMLExport::setSourceDocument( const uno::Reference<lang::XCompon // ODF 1.0 and 1.1 use GRAM_PODF, everything later or unspecified GRAM_ODFF case SvtSaveOptions::ODFVER_010: case SvtSaveOptions::ODFVER_011: - pDoc->SetStorageGrammar( ScGrammar::GRAM_PODF); + pDoc->SetStorageGrammar( formula::FormulaGrammar::GRAM_PODF); break; default: - pDoc->SetStorageGrammar( ScGrammar::GRAM_ODFF); + pDoc->SetStorageGrammar( formula::FormulaGrammar::GRAM_ODFF); } } diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 0c9a4abdc85c..ebaf78c9902c 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -1,32 +1,32 @@ /************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: xmlimprt.cxx,v $ - * $Revision: 1.132.30.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2008 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile: xmlimprt.cxx,v $ +* $Revision: 1.132.30.4 $ +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" @@ -118,7 +118,7 @@ uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_getSupportedServiceNames() t } uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_createInstance( - const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) { // #110680# // return (cppu::OWeakObject*)new ScXMLImport(IMPORT_ALL); @@ -137,7 +137,7 @@ uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Meta_getSupportedServiceName } uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Meta_createInstance( - const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) { // #110680# // return (cppu::OWeakObject*)new ScXMLImport(IMPORT_META); @@ -156,7 +156,7 @@ uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Styles_getSupportedServiceNa } uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Styles_createInstance( - const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) { // #110680# // return (cppu::OWeakObject*)new ScXMLImport(IMPORT_STYLES|IMPORT_AUTOSTYLES|IMPORT_MASTERSTYLES|IMPORT_FONTDECLS); @@ -175,7 +175,7 @@ uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Content_getSupportedServiceN } uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Content_createInstance( - const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) { // #110680# // return (cppu::OWeakObject*)new ScXMLImport(IMPORT_META|IMPORT_STYLES|IMPORT_MASTERSTYLES|IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_SETTINGS|IMPORT_FONTDECLS); @@ -194,7 +194,7 @@ uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Settings_getSupportedService } uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Settings_createInstance( - const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) + const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) { // #110680# // return (cppu::OWeakObject*)new ScXMLImport(IMPORT_SETTINGS); @@ -203,587 +203,24 @@ uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Settings_createInstance( //---------------------------------------------------------------------------- -static __FAR_DATA SvXMLTokenMapEntry aDocTokenMap[] = -{ - { XML_NAMESPACE_OFFICE, XML_FONT_FACE_DECLS, XML_TOK_DOC_FONTDECLS }, - { XML_NAMESPACE_OFFICE, XML_STYLES, XML_TOK_DOC_STYLES }, - { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES }, - { XML_NAMESPACE_OFFICE, XML_MASTER_STYLES, XML_TOK_DOC_MASTERSTYLES }, - { XML_NAMESPACE_OFFICE, XML_META, XML_TOK_DOC_META }, - { XML_NAMESPACE_OFFICE, XML_SCRIPTS, XML_TOK_DOC_SCRIPTS }, - { XML_NAMESPACE_OFFICE, XML_BODY, XML_TOK_DOC_BODY }, - { XML_NAMESPACE_OFFICE, XML_SETTINGS, XML_TOK_DOC_SETTINGS }, - XML_TOKEN_MAP_END -}; - -#if 0 // apparently not used - 2008-08-15 (Friday) -static __FAR_DATA SvXMLTokenMapEntry aStylesTokenMap[] = -{ - { XML_NAMESPACE_STYLE, XML_STYLE, XML_TOK_STYLES_STYLE }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aStylesAttrTokenMap[] = -{ - { XML_NAMESPACE_STYLE, XML_NAME, XML_TOK_STYLES_STYLE_NAME }, - { XML_NAMESPACE_STYLE, XML_FAMILY, XML_TOK_STYLES_STYLE_FAMILY }, - { XML_NAMESPACE_STYLE, XML_PARENT_STYLE_NAME, XML_TOK_STYLES_STYLE_PARENT_STYLE_NAME }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aStyleTokenMap[] = -{ - { XML_NAMESPACE_STYLE, XML_PROPERTIES, XML_TOK_STYLE_PROPERTIES }, - XML_TOKEN_MAP_END -}; -#endif - -static __FAR_DATA SvXMLTokenMapEntry aBodyTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_TRACKED_CHANGES, XML_TOK_BODY_TRACKED_CHANGES }, - { XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, XML_TOK_BODY_CALCULATION_SETTINGS }, - { XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATIONS, XML_TOK_BODY_CONTENT_VALIDATIONS }, - { XML_NAMESPACE_TABLE, XML_LABEL_RANGES, XML_TOK_BODY_LABEL_RANGES }, - { XML_NAMESPACE_TABLE, XML_TABLE, XML_TOK_BODY_TABLE }, - { XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSIONS, XML_TOK_BODY_NAMED_EXPRESSIONS }, - { XML_NAMESPACE_TABLE, XML_DATABASE_RANGES, XML_TOK_BODY_DATABASE_RANGES }, - { XML_NAMESPACE_TABLE, XML_DATABASE_RANGE, XML_TOK_BODY_DATABASE_RANGE }, - { XML_NAMESPACE_TABLE, XML_DATA_PILOT_TABLES, XML_TOK_BODY_DATA_PILOT_TABLES }, - { XML_NAMESPACE_TABLE, XML_CONSOLIDATION, XML_TOK_BODY_CONSOLIDATION }, - { XML_NAMESPACE_TABLE, XML_DDE_LINKS, XML_TOK_BODY_DDE_LINKS }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aContentValidationsElemTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION, XML_TOK_CONTENT_VALIDATION }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aContentValidationElemTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_HELP_MESSAGE, XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE }, - { XML_NAMESPACE_TABLE, XML_ERROR_MESSAGE, XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE }, - { XML_NAMESPACE_TABLE, XML_ERROR_MACRO, XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO }, - { XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, XML_TOK_CONTENT_VALIDATION_ELEM_EVENT_LISTENERS }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aContentValidationAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_CONTENT_VALIDATION_NAME }, - { XML_NAMESPACE_TABLE, XML_CONDITION, XML_TOK_CONTENT_VALIDATION_CONDITION }, - { XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, XML_TOK_CONTENT_VALIDATION_BASE_CELL_ADDRESS }, - { XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_TOK_CONTENT_VALIDATION_ALLOW_EMPTY_CELL }, - { XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_TOK_CONTENT_VALIDATION_DISPLAY_LIST }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aContentValidationMessageElemTokenMap[] = -{ - { XML_NAMESPACE_TEXT, XML_P, XML_TOK_P }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aContentValidationHelpMessageAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_TITLE, XML_TOK_HELP_MESSAGE_ATTR_TITLE }, - { XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TOK_HELP_MESSAGE_ATTR_DISPLAY }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aContentValidationErrorMessageAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_TITLE, XML_TOK_ERROR_MESSAGE_ATTR_TITLE }, - { XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TOK_ERROR_MESSAGE_ATTR_DISPLAY }, - { XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_TOK_ERROR_MESSAGE_ATTR_MESSAGE_TYPE }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aContentValidationErrorMacroAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_ERROR_MACRO_ATTR_NAME }, - { XML_NAMESPACE_TABLE, XML_EXECUTE, XML_TOK_ERROR_MACRO_ATTR_EXECUTE }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aLabelRangesElemTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_LABEL_RANGE, XML_TOK_LABEL_RANGE_ELEM }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aLabelRangeAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_LABEL_CELL_RANGE_ADDRESS, XML_TOK_LABEL_RANGE_ATTR_LABEL_RANGE }, - { XML_NAMESPACE_TABLE, XML_DATA_CELL_RANGE_ADDRESS, XML_TOK_LABEL_RANGE_ATTR_DATA_RANGE }, - { XML_NAMESPACE_TABLE, XML_ORIENTATION, XML_TOK_LABEL_RANGE_ATTR_ORIENTATION }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aTableTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN_GROUP, XML_TOK_TABLE_COL_GROUP }, - { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, XML_TOK_TABLE_HEADER_COLS }, - { XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, XML_TOK_TABLE_COLS }, - { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, XML_TOK_TABLE_COL }, - { XML_NAMESPACE_TABLE, XML_TABLE_ROW_GROUP, XML_TOK_TABLE_ROW_GROUP }, - { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, XML_TOK_TABLE_HEADER_ROWS }, - { XML_NAMESPACE_TABLE, XML_TABLE_ROWS, XML_TOK_TABLE_ROWS }, - { XML_NAMESPACE_TABLE, XML_TABLE_ROW, XML_TOK_TABLE_ROW }, - { XML_NAMESPACE_TABLE, XML_TABLE_SOURCE, XML_TOK_TABLE_SOURCE }, - { XML_NAMESPACE_TABLE, XML_SCENARIO, XML_TOK_TABLE_SCENARIO }, - { XML_NAMESPACE_TABLE, XML_SHAPES, XML_TOK_TABLE_SHAPES }, - { XML_NAMESPACE_OFFICE, XML_FORMS, XML_TOK_TABLE_FORMS }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aTableRowsElemTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_TABLE_ROW_GROUP, XML_TOK_TABLE_ROWS_ROW_GROUP }, - { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, XML_TOK_TABLE_ROWS_HEADER_ROWS }, - { XML_NAMESPACE_TABLE, XML_TABLE_ROWS, XML_TOK_TABLE_ROWS_ROWS }, - { XML_NAMESPACE_TABLE, XML_TABLE_ROW, XML_TOK_TABLE_ROWS_ROW }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aTableColsElemTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN_GROUP, XML_TOK_TABLE_COLS_COL_GROUP }, - { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, XML_TOK_TABLE_COLS_HEADER_COLS }, - { XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, XML_TOK_TABLE_COLS_COLS }, - { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, XML_TOK_TABLE_COLS_COL }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aTableAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_TABLE_NAME }, - { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_STYLE_NAME }, - { XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TOK_TABLE_PROTECTION }, - { XML_NAMESPACE_TABLE, XML_PRINT_RANGES, XML_TOK_TABLE_PRINT_RANGES }, - { XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, XML_TOK_TABLE_PASSWORD }, - { XML_NAMESPACE_TABLE, XML_PRINT, XML_TOK_TABLE_PRINT }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aTableScenarioAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_DISPLAY_BORDER, XML_TOK_TABLE_SCENARIO_ATTR_DISPLAY_BORDER }, - { XML_NAMESPACE_TABLE, XML_BORDER_COLOR, XML_TOK_TABLE_SCENARIO_ATTR_BORDER_COLOR }, - { XML_NAMESPACE_TABLE, XML_COPY_BACK, XML_TOK_TABLE_SCENARIO_ATTR_COPY_BACK }, - { XML_NAMESPACE_TABLE, XML_COPY_STYLES, XML_TOK_TABLE_SCENARIO_ATTR_COPY_STYLES }, - { XML_NAMESPACE_TABLE, XML_COPY_FORMULAS, XML_TOK_TABLE_SCENARIO_ATTR_COPY_FORMULAS }, - { XML_NAMESPACE_TABLE, XML_IS_ACTIVE, XML_TOK_TABLE_SCENARIO_ATTR_IS_ACTIVE }, - { XML_NAMESPACE_TABLE, XML_SCENARIO_RANGES, XML_TOK_TABLE_SCENARIO_ATTR_SCENARIO_RANGES }, - { XML_NAMESPACE_TABLE, XML_COMMENT, XML_TOK_TABLE_SCENARIO_ATTR_COMMENT }, - { XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TOK_TABLE_SCENARIO_ATTR_PROTECTED }, - XML_TOKEN_MAP_END -}; - - -static __FAR_DATA SvXMLTokenMapEntry aTableColAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_COL_ATTR_STYLE_NAME }, - { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, XML_TOK_TABLE_COL_ATTR_REPEATED }, - { XML_NAMESPACE_TABLE, XML_VISIBILITY, XML_TOK_TABLE_COL_ATTR_VISIBILITY }, - { XML_NAMESPACE_TABLE, XML_DEFAULT_CELL_STYLE_NAME, XML_TOK_TABLE_COL_ATTR_DEFAULT_CELL_STYLE_NAME }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aTableRowTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_TABLE_CELL, XML_TOK_TABLE_ROW_CELL }, - { XML_NAMESPACE_TABLE, XML_COVERED_TABLE_CELL, XML_TOK_TABLE_ROW_COVERED_CELL }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aTableRowAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_ROW_ATTR_STYLE_NAME }, - { XML_NAMESPACE_TABLE, XML_VISIBILITY, XML_TOK_TABLE_ROW_ATTR_VISIBILITY }, - { XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, XML_TOK_TABLE_ROW_ATTR_REPEATED }, - { XML_NAMESPACE_TABLE, XML_DEFAULT_CELL_STYLE_NAME, XML_TOK_TABLE_ROW_ATTR_DEFAULT_CELL_STYLE_NAME }, -// { XML_NAMESPACE_TABLE, XML_USE_OPTIMAL_HEIGHT, XML_TOK_TABLE_ROW_ATTR_USE_OPTIMAL_HEIGHT }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aTableRowCellTokenMap[] = -{ - { XML_NAMESPACE_TEXT, XML_P, XML_TOK_TABLE_ROW_CELL_P }, - { XML_NAMESPACE_TABLE, XML_SUB_TABLE, XML_TOK_TABLE_ROW_CELL_TABLE }, - { XML_NAMESPACE_OFFICE, XML_ANNOTATION, XML_TOK_TABLE_ROW_CELL_ANNOTATION }, - { XML_NAMESPACE_TABLE, XML_DETECTIVE, XML_TOK_TABLE_ROW_CELL_DETECTIVE }, - { XML_NAMESPACE_TABLE, XML_CELL_RANGE_SOURCE, XML_TOK_TABLE_ROW_CELL_CELL_RANGE_SOURCE }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aTableRowCellAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_ROW_CELL_ATTR_STYLE_NAME }, - { XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION_NAME, XML_TOK_TABLE_ROW_CELL_ATTR_CONTENT_VALIDATION_NAME }, - { XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED, XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_ROWS }, - { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED, XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_COLS }, - { XML_NAMESPACE_TABLE, XML_NUMBER_MATRIX_COLUMNS_SPANNED, XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_MATRIX_COLS }, - { XML_NAMESPACE_TABLE, XML_NUMBER_MATRIX_ROWS_SPANNED, XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_MATRIX_ROWS }, - { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, XML_TOK_TABLE_ROW_CELL_ATTR_REPEATED }, - { XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_TOK_TABLE_ROW_CELL_ATTR_VALUE_TYPE }, - { XML_NAMESPACE_OFFICE, XML_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_VALUE }, - { XML_NAMESPACE_OFFICE, XML_DATE_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_DATE_VALUE }, - { XML_NAMESPACE_OFFICE, XML_TIME_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_TIME_VALUE }, - { XML_NAMESPACE_OFFICE, XML_STRING_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_STRING_VALUE }, - { XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_BOOLEAN_VALUE }, - { XML_NAMESPACE_TABLE, XML_FORMULA, XML_TOK_TABLE_ROW_CELL_ATTR_FORMULA }, - { XML_NAMESPACE_OFFICE, XML_CURRENCY, XML_TOK_TABLE_ROW_CELL_ATTR_CURRENCY }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aTableAnnotationAttrTokenMap[] = -{ - { XML_NAMESPACE_OFFICE, XML_AUTHOR, XML_TOK_TABLE_ANNOTATION_ATTR_AUTHOR }, - { XML_NAMESPACE_OFFICE, XML_CREATE_DATE, XML_TOK_TABLE_ANNOTATION_ATTR_CREATE_DATE }, - { XML_NAMESPACE_OFFICE, XML_CREATE_DATE_STRING, XML_TOK_TABLE_ANNOTATION_ATTR_CREATE_DATE_STRING }, - { XML_NAMESPACE_OFFICE, XML_DISPLAY, XML_TOK_TABLE_ANNOTATION_ATTR_DISPLAY }, - { XML_NAMESPACE_SVG, XML_X, XML_TOK_TABLE_ANNOTATION_ATTR_X }, - { XML_NAMESPACE_SVG, XML_Y, XML_TOK_TABLE_ANNOTATION_ATTR_Y }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aDetectiveElemTokenMap[]= -{ - { XML_NAMESPACE_TABLE, XML_HIGHLIGHTED_RANGE, XML_TOK_DETECTIVE_ELEM_HIGHLIGHTED }, - { XML_NAMESPACE_TABLE, XML_OPERATION, XML_TOK_DETECTIVE_ELEM_OPERATION }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aDetectiveHighlightedAttrTokenMap[]= -{ - { XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_CELL_RANGE }, - { XML_NAMESPACE_TABLE, XML_DIRECTION, XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_DIRECTION }, - { XML_NAMESPACE_TABLE, XML_CONTAINS_ERROR, XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_CONTAINS_ERROR }, - { XML_NAMESPACE_TABLE, XML_MARKED_INVALID, XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_MARKED_INVALID }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDetectiveOperationAttrTokenMap[]= -{ - { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_DETECTIVE_OPERATION_ATTR_NAME }, - { XML_NAMESPACE_TABLE, XML_INDEX, XML_TOK_DETECTIVE_OPERATION_ATTR_INDEX }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aTableCellRangeSourceAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_NAME }, - { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_HREF }, - { XML_NAMESPACE_TABLE, XML_FILTER_NAME, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_NAME }, - { XML_NAMESPACE_TABLE, XML_FILTER_OPTIONS, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_OPTIONS }, - { XML_NAMESPACE_TABLE, XML_LAST_COLUMN_SPANNED, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_COLUMN }, - { XML_NAMESPACE_TABLE, XML_LAST_ROW_SPANNED, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_ROW }, - { XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_REFRESH_DELAY }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aNamedExpressionsTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_NAMED_RANGE, XML_TOK_NAMED_EXPRESSIONS_NAMED_RANGE }, - { XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSION, XML_TOK_NAMED_EXPRESSIONS_NAMED_EXPRESSION }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aNamedRangeAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_NAMED_RANGE_ATTR_NAME }, - { XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, XML_TOK_NAMED_RANGE_ATTR_CELL_RANGE_ADDRESS }, - { XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, XML_TOK_NAMED_RANGE_ATTR_BASE_CELL_ADDRESS }, - { XML_NAMESPACE_TABLE, XML_RANGE_USABLE_AS, XML_TOK_NAMED_RANGE_ATTR_RANGE_USABLE_AS }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aNamedExpressionAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_NAMED_EXPRESSION_ATTR_NAME }, - { XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, XML_TOK_NAMED_EXPRESSION_ATTR_BASE_CELL_ADDRESS }, - { XML_NAMESPACE_TABLE, XML_EXPRESSION, XML_TOK_NAMED_EXPRESSION_ATTR_EXPRESSION }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangesTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_DATABASE_RANGE, XML_TOK_DATABASE_RANGE }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_SQL, XML_TOK_DATABASE_RANGE_SOURCE_SQL }, - { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_TABLE, XML_TOK_DATABASE_RANGE_SOURCE_TABLE }, - { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_QUERY, XML_TOK_DATABASE_RANGE_SOURCE_QUERY }, - { XML_NAMESPACE_TABLE, XML_FILTER, XML_TOK_FILTER }, - { XML_NAMESPACE_TABLE, XML_SORT, XML_TOK_SORT }, - { XML_NAMESPACE_TABLE, XML_SUBTOTAL_RULES, XML_TOK_DATABASE_RANGE_SUBTOTAL_RULES }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_DATABASE_RANGE_ATTR_NAME }, - { XML_NAMESPACE_TABLE, XML_IS_SELECTION, XML_TOK_DATABASE_RANGE_ATTR_IS_SELECTION }, - { XML_NAMESPACE_TABLE, XML_ON_UPDATE_KEEP_STYLES, XML_TOK_DATABASE_RANGE_ATTR_ON_UPDATE_KEEP_STYLES }, - { XML_NAMESPACE_TABLE, XML_ON_UPDATE_KEEP_SIZE, XML_TOK_DATABASE_RANGE_ATTR_ON_UPDATE_KEEP_SIZE }, - { XML_NAMESPACE_TABLE, XML_HAS_PERSISTENT_DATA, XML_TOK_DATABASE_RANGE_ATTR_HAS_PERSISTENT_DATA }, - { XML_NAMESPACE_TABLE, XML_ORIENTATION, XML_TOK_DATABASE_RANGE_ATTR_ORIENTATION }, - { XML_NAMESPACE_TABLE, XML_CONTAINS_HEADER, XML_TOK_DATABASE_RANGE_ATTR_CONTAINS_HEADER }, - { XML_NAMESPACE_TABLE, XML_DISPLAY_FILTER_BUTTONS, XML_TOK_DATABASE_RANGE_ATTR_DISPLAY_FILTER_BUTTONS }, - { XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, XML_TOK_DATABASE_RANGE_ATTR_TARGET_RANGE_ADDRESS }, - { XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, XML_TOK_DATABASE_RANGE_ATTR_REFRESH_DELAY }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSourceSQLAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_DATABASE_NAME, XML_TOK_SOURCE_SQL_ATTR_DATABASE_NAME }, - { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_SOURCE_SQL_ATTR_HREF }, - { XML_NAMESPACE_TABLE, XML_CONNECTION_RESOURCE, XML_TOK_SOURCE_SQL_ATTR_CONNECTION_RESSOURCE}, - { XML_NAMESPACE_TABLE, XML_SQL_STATEMENT, XML_TOK_SOURCE_SQL_ATTR_SQL_STATEMENT }, - { XML_NAMESPACE_TABLE, XML_PARSE_SQL_STATEMENT, XML_TOK_SOURCE_SQL_ATTR_PARSE_SQL_STATEMENT }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSourceTableAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_DATABASE_NAME, XML_TOK_SOURCE_TABLE_ATTR_DATABASE_NAME }, - { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_SOURCE_TABLE_ATTR_HREF }, - { XML_NAMESPACE_TABLE, XML_CONNECTION_RESOURCE, XML_TOK_SOURCE_TABLE_ATTR_CONNECTION_RESSOURCE }, - { XML_NAMESPACE_TABLE, XML_TABLE_NAME, XML_TOK_SOURCE_TABLE_ATTR_TABLE_NAME }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSourceQueryAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_DATABASE_NAME, XML_TOK_SOURCE_QUERY_ATTR_DATABASE_NAME }, - { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_SOURCE_QUERY_ATTR_HREF }, - { XML_NAMESPACE_TABLE, XML_CONNECTION_RESOURCE, XML_TOK_SOURCE_QUERY_ATTR_CONNECTION_RESSOURCE }, - { XML_NAMESPACE_TABLE, XML_QUERY_NAME, XML_TOK_SOURCE_QUERY_ATTR_QUERY_NAME }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aFilterTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_FILTER_AND, XML_TOK_FILTER_AND }, - { XML_NAMESPACE_TABLE, XML_FILTER_OR, XML_TOK_FILTER_OR }, - { XML_NAMESPACE_TABLE, XML_FILTER_CONDITION, XML_TOK_FILTER_CONDITION }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aFilterAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, XML_TOK_FILTER_ATTR_TARGET_RANGE_ADDRESS }, - { XML_NAMESPACE_TABLE, XML_CONDITION_SOURCE_RANGE_ADDRESS, XML_TOK_FILTER_ATTR_CONDITION_SOURCE_RANGE_ADDRESS }, - { XML_NAMESPACE_TABLE, XML_CONDITION_SOURCE, XML_TOK_FILTER_ATTR_CONDITION_SOURCE }, - { XML_NAMESPACE_TABLE, XML_DISPLAY_DUPLICATES, XML_TOK_FILTER_ATTR_DISPLAY_DUPLICATES }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aFilterConditionAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, XML_TOK_CONDITION_ATTR_FIELD_NUMBER }, - { XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TOK_CONDITION_ATTR_CASE_SENSITIVE }, - { XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_TOK_CONDITION_ATTR_DATA_TYPE }, - { XML_NAMESPACE_TABLE, XML_VALUE, XML_TOK_CONDITION_ATTR_VALUE }, - { XML_NAMESPACE_TABLE, XML_OPERATOR, XML_TOK_CONDITION_ATTR_OPERATOR }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aSortTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_SORT_BY, XML_TOK_SORT_SORT_BY }, - XML_TOKEN_MAP_END -}; -static __FAR_DATA SvXMLTokenMapEntry aSortAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_BIND_STYLES_TO_CONTENT, XML_TOK_SORT_ATTR_BIND_STYLES_TO_CONTENT }, - { XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, XML_TOK_SORT_ATTR_TARGET_RANGE_ADDRESS }, - { XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TOK_SORT_ATTR_CASE_SENSITIVE }, - { XML_NAMESPACE_TABLE, XML_LANGUAGE, XML_TOK_SORT_ATTR_LANGUAGE }, - { XML_NAMESPACE_TABLE, XML_COUNTRY, XML_TOK_SORT_ATTR_COUNTRY }, - { XML_NAMESPACE_TABLE, XML_ALGORITHM, XML_TOK_SORT_ATTR_ALGORITHM }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aSortSortByAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, XML_TOK_SORT_BY_ATTR_FIELD_NUMBER }, - { XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_TOK_SORT_BY_ATTR_DATA_TYPE }, - { XML_NAMESPACE_TABLE, XML_ORDER, XML_TOK_SORT_BY_ATTR_ORDER }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSubTotalRulesTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_SORT_GROUPS, XML_TOK_SUBTOTAL_RULES_SORT_GROUPS }, - { XML_NAMESPACE_TABLE, XML_SUBTOTAL_RULE, XML_TOK_SUBTOTAL_RULES_SUBTOTAL_RULE }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSubTotalRulesAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_BIND_STYLES_TO_CONTENT, XML_TOK_SUBTOTAL_RULES_ATTR_BIND_STYLES_TO_CONTENT }, - { XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TOK_SUBTOTAL_RULES_ATTR_CASE_SENSITIVE }, - { XML_NAMESPACE_TABLE, XML_PAGE_BREAKS_ON_GROUP_CHANGE, XML_TOK_SUBTOTAL_RULES_ATTR_PAGE_BREAKS_ON_GROUP_CHANGE }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aSubTotalRulesSortGroupsAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_TOK_SORT_GROUPS_ATTR_DATA_TYPE }, - { XML_NAMESPACE_TABLE, XML_ORDER, XML_TOK_SORT_GROUPS_ATTR_ORDER }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aSubTotalRulesSubTotalRuleTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_SUBTOTAL_FIELD, XML_TOK_SUBTOTAL_RULE_SUBTOTAL_FIELD }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aSubTotalRulesSubTotalRuleAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_GROUP_BY_FIELD_NUMBER, XML_TOK_SUBTOTAL_RULE_ATTR_GROUP_BY_FIELD_NUMBER }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aSubTotalRuleSubTotalFieldAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, XML_TOK_SUBTOTAL_FIELD_ATTR_FIELD_NUMBER }, - { XML_NAMESPACE_TABLE, XML_FUNCTION, XML_TOK_SUBTOTAL_FIELD_ATTR_FUNCTION }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDataPilotTablesElemTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_DATA_PILOT_TABLE, XML_TOK_DATA_PILOT_TABLE }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_DATA_PILOT_TABLE_ATTR_NAME }, - { XML_NAMESPACE_TABLE, XML_APPLICATION_DATA, XML_TOK_DATA_PILOT_TABLE_ATTR_APPLICATION_DATA }, - { XML_NAMESPACE_TABLE, XML_GRAND_TOTAL, XML_TOK_DATA_PILOT_TABLE_ATTR_GRAND_TOTAL }, - { XML_NAMESPACE_TABLE, XML_IGNORE_EMPTY_ROWS, XML_TOK_DATA_PILOT_TABLE_ATTR_IGNORE_EMPTY_ROWS }, - { XML_NAMESPACE_TABLE, XML_IDENTIFY_CATEGORIES, XML_TOK_DATA_PILOT_TABLE_ATTR_IDENTIFY_CATEGORIES }, - { XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, XML_TOK_DATA_PILOT_TABLE_ATTR_TARGET_RANGE_ADDRESS }, - { XML_NAMESPACE_TABLE, XML_BUTTONS, XML_TOK_DATA_PILOT_TABLE_ATTR_BUTTONS }, - { XML_NAMESPACE_TABLE, XML_SHOW_FILTER_BUTTON, XML_TOK_DATA_PILOT_TABLE_ATTR_SHOW_FILTER_BUTTON }, - { XML_NAMESPACE_TABLE, XML_DRILL_DOWN_ON_DOUBLE_CLICK, XML_TOK_DATA_PILOT_TABLE_ATTR_DRILL_DOWN }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableElemTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_SQL, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SQL }, - { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_TABLE, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_TABLE }, - { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_QUERY, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_QUERY }, - { XML_NAMESPACE_TABLE, XML_SOURCE_SERVICE, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SERVICE }, - { XML_NAMESPACE_TABLE, XML_SOURCE_CELL_RANGE, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_CELL_RANGE }, - { XML_NAMESPACE_TABLE, XML_DATA_PILOT_FIELD, XML_TOK_DATA_PILOT_TABLE_ELEM_DATA_PILOT_FIELD }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableSourceServiceAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_SOURCE_SERVICE_ATTR_NAME }, - { XML_NAMESPACE_TABLE, XML_SOURCE_NAME, XML_TOK_SOURCE_SERVICE_ATTR_SOURCE_NAME }, - { XML_NAMESPACE_TABLE, XML_OBJECT_NAME, XML_TOK_SOURCE_SERVICE_ATTR_OBJECT_NAME }, - { XML_NAMESPACE_TABLE, XML_USER_NAME, XML_TOK_SOURCE_SERVICE_ATTR_USER_NAME }, - { XML_NAMESPACE_TABLE, XML_PASSWORT, XML_TOK_SOURCE_SERVICE_ATTR_PASSWORD }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableSourceCellRangeAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, XML_TOK_SOURCE_CELL_RANGE_ATTR_CELL_RANGE_ADDRESS}, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableSourceCellRangeElemTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_FILTER, XML_TOK_SOURCE_CELL_RANGE_ELEM_FILTER}, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDataPilotFieldAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_SOURCE_FIELD_NAME, XML_TOK_DATA_PILOT_FIELD_ATTR_SOURCE_FIELD_NAME }, - { XML_NAMESPACE_TABLE, XML_IS_DATA_LAYOUT_FIELD, XML_TOK_DATA_PILOT_FIELD_ATTR_IS_DATA_LAYOUT_FIELD }, - { XML_NAMESPACE_TABLE, XML_FUNCTION, XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION }, - { XML_NAMESPACE_TABLE, XML_ORIENTATION, XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION }, - { XML_NAMESPACE_TABLE, XML_SELECTED_PAGE, XML_TOK_DATA_PILOT_FIELD_ATTR_SELECTED_PAGE }, - { XML_NAMESPACE_TABLE, XML_USED_HIERARCHY, XML_TOK_DATA_PILOT_FIELD_ATTR_USED_HIERARCHY }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDataPilotFieldElemTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_DATA_PILOT_LEVEL, XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LEVEL }, - { XML_NAMESPACE_TABLE, XML_DATA_PILOT_FIELD_REFERENCE, XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_REFERENCE }, - { XML_NAMESPACE_TABLE, XML_DATA_PILOT_GROUPS, XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_GROUPS }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDataPilotLevelAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_SHOW_EMPTY, XML_TOK_DATA_PILOT_LEVEL_ATTR_SHOW_EMPTY }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDataPilotLevelElemTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_DATA_PILOT_SUBTOTALS, XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_SUBTOTALS }, - { XML_NAMESPACE_TABLE, XML_DATA_PILOT_MEMBERS, XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_MEMBERS }, - { XML_NAMESPACE_TABLE, XML_DATA_PILOT_DISPLAY_INFO, XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_DISPLAY_INFO }, - { XML_NAMESPACE_TABLE, XML_DATA_PILOT_SORT_INFO, XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_SORT_INFO }, - { XML_NAMESPACE_TABLE, XML_DATA_PILOT_LAYOUT_INFO, XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LAYOUT_INFO }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDataPilotSubTotalsElemTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_DATA_PILOT_SUBTOTAL, XML_TOK_DATA_PILOT_SUBTOTALS_ELEM_DATA_PILOT_SUBTOTAL }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDataPilotSubTotalAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_FUNCTION, XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_FUNCTION }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDataPilotMembersElemTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_DATA_PILOT_MEMBER, XML_TOK_DATA_PILOT_MEMBERS_ELEM_DATA_PILOT_MEMBER }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aDataPilotMemberAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_DATA_PILOT_MEMBER_ATTR_NAME }, - { XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY }, - { XML_NAMESPACE_TABLE, XML_SHOW_DETAILS, XML_TOK_DATA_PILOT_MEMBER_ATTR_SHOW_DETAILS }, - XML_TOKEN_MAP_END -}; - -static __FAR_DATA SvXMLTokenMapEntry aConsolidationAttrTokenMap[] = -{ - { XML_NAMESPACE_TABLE, XML_FUNCTION, XML_TOK_CONSOLIDATION_ATTR_FUNCTION }, - { XML_NAMESPACE_TABLE, XML_SOURCE_CELL_RANGE_ADDRESSES, XML_TOK_CONSOLIDATION_ATTR_SOURCE_RANGES }, - { XML_NAMESPACE_TABLE, XML_TARGET_CELL_ADDRESS, XML_TOK_CONSOLIDATION_ATTR_TARGET_ADDRESS }, - { XML_NAMESPACE_TABLE, XML_USE_LABEL, XML_TOK_CONSOLIDATION_ATTR_USE_LABEL }, - { XML_NAMESPACE_TABLE, XML_LINK_TO_SOURCE_DATA, XML_TOK_CONSOLIDATION_ATTR_LINK_TO_SOURCE }, - XML_TOKEN_MAP_END -}; // NB: virtually inherit so we can multiply inherit properly @@ -797,20 +234,20 @@ protected: public: ScXMLDocContext_Impl( ScXMLImport& rImport, - USHORT nPrfx, - const OUString& rLName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList ); + USHORT nPrfx, + const OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList ); virtual ~ScXMLDocContext_Impl(); virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, - const rtl::OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList ); + const rtl::OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList ); }; ScXMLDocContext_Impl::ScXMLDocContext_Impl( ScXMLImport& rImport, USHORT nPrfx, - const OUString& rLName, - const uno::Reference<xml::sax::XAttributeList>& /* xAttrList */ ) : - SvXMLImportContext( rImport, nPrfx, rLName ) + const OUString& rLName, + const uno::Reference<xml::sax::XAttributeList>& /* xAttrList */ ) : +SvXMLImportContext( rImport, nPrfx, rLName ) { } @@ -838,14 +275,14 @@ public: }; ScXMLFlatDocContext_Impl::ScXMLFlatDocContext_Impl( ScXMLImport& i_rImport, - USHORT i_nPrefix, const OUString & i_rLName, - const uno::Reference<xml::sax::XAttributeList>& i_xAttrList, - const uno::Reference<document::XDocumentProperties>& i_xDocProps, - const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder) : - SvXMLImportContext(i_rImport, i_nPrefix, i_rLName), - ScXMLDocContext_Impl(i_rImport, i_nPrefix, i_rLName, i_xAttrList), - SvXMLMetaDocumentContext(i_rImport, i_nPrefix, i_rLName, - i_xDocProps, i_xDocBuilder) + USHORT i_nPrefix, const OUString & i_rLName, + const uno::Reference<xml::sax::XAttributeList>& i_xAttrList, + const uno::Reference<document::XDocumentProperties>& i_xDocProps, + const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder) : +SvXMLImportContext(i_rImport, i_nPrefix, i_rLName), +ScXMLDocContext_Impl(i_rImport, i_nPrefix, i_rLName, i_xAttrList), +SvXMLMetaDocumentContext(i_rImport, i_nPrefix, i_rLName, + i_xDocProps, i_xDocBuilder) { } @@ -860,35 +297,35 @@ SvXMLImportContext *ScXMLFlatDocContext_Impl::CreateChildContext( const SvXMLTokenMap& rTokenMap = GetScImport().GetDocElemTokenMap(); if ( XML_TOK_DOC_META == rTokenMap.Get( i_nPrefix, i_rLocalName ) ) { return SvXMLMetaDocumentContext::CreateChildContext( - i_nPrefix, i_rLocalName, i_xAttrList ); + i_nPrefix, i_rLocalName, i_xAttrList ); } else { return ScXMLDocContext_Impl::CreateChildContext( - i_nPrefix, i_rLocalName, i_xAttrList ); + i_nPrefix, i_rLocalName, i_xAttrList ); } } class ScXMLBodyContext_Impl : public SvXMLImportContext { const ScXMLImport& GetScImport() const - { return (const ScXMLImport&)GetImport(); } + { return (const ScXMLImport&)GetImport(); } ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } public: ScXMLBodyContext_Impl( ScXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ); + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList ); virtual ~ScXMLBodyContext_Impl(); virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ); + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList ); }; ScXMLBodyContext_Impl::ScXMLBodyContext_Impl( ScXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLName, - const uno::Reference< xml::sax::XAttributeList > & /* xAttrList */ ) : - SvXMLImportContext( rImport, nPrfx, rLName ) + sal_uInt16 nPrfx, const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList > & /* xAttrList */ ) : +SvXMLImportContext( rImport, nPrfx, rLName ) { } @@ -897,16 +334,16 @@ ScXMLBodyContext_Impl::~ScXMLBodyContext_Impl() } SvXMLImportContext *ScXMLBodyContext_Impl::CreateChildContext( - sal_uInt16 /* nPrefix */, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ) + sal_uInt16 /* nPrefix */, + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList ) { return GetScImport().CreateBodyContext( rLocalName, xAttrList ); } SvXMLImportContext *ScXMLDocContext_Impl::CreateChildContext( USHORT nPrefix, - const rtl::OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList ) + const rtl::OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList ) { SvXMLImportContext *pContext(0); @@ -928,7 +365,7 @@ SvXMLImportContext *ScXMLDocContext_Impl::CreateChildContext( USHORT nPrefix, case XML_TOK_DOC_MASTERSTYLES: if (GetScImport().getImportFlags() & IMPORT_MASTERSTYLES) pContext = new ScXMLMasterStylesContext( GetImport(), nPrefix, rLocalName, - xAttrList ); + xAttrList ); break; case XML_TOK_DOC_META: DBG_WARNING("XML_TOK_DOC_META: should not have come here, maybe document is invalid?"); @@ -940,7 +377,7 @@ SvXMLImportContext *ScXMLDocContext_Impl::CreateChildContext( USHORT nPrefix, case XML_TOK_DOC_BODY: if (GetScImport().getImportFlags() & IMPORT_CONTENT) pContext = new ScXMLBodyContext_Impl( GetScImport(), nPrefix, - rLocalName, xAttrList ); + rLocalName, xAttrList ); break; case XML_TOK_DOC_SETTINGS: if (GetScImport().getImportFlags() & IMPORT_SETTINGS) @@ -957,489 +394,1180 @@ SvXMLImportContext *ScXMLDocContext_Impl::CreateChildContext( USHORT nPrefix, const SvXMLTokenMap& ScXMLImport::GetDocElemTokenMap() { if( !pDocElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDocTokenMap[] = + { + { XML_NAMESPACE_OFFICE, XML_FONT_FACE_DECLS, XML_TOK_DOC_FONTDECLS }, + { XML_NAMESPACE_OFFICE, XML_STYLES, XML_TOK_DOC_STYLES }, + { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES }, + { XML_NAMESPACE_OFFICE, XML_MASTER_STYLES, XML_TOK_DOC_MASTERSTYLES }, + { XML_NAMESPACE_OFFICE, XML_META, XML_TOK_DOC_META }, + { XML_NAMESPACE_OFFICE, XML_SCRIPTS, XML_TOK_DOC_SCRIPTS }, + { XML_NAMESPACE_OFFICE, XML_BODY, XML_TOK_DOC_BODY }, + { XML_NAMESPACE_OFFICE, XML_SETTINGS, XML_TOK_DOC_SETTINGS }, + XML_TOKEN_MAP_END + }; + pDocElemTokenMap = new SvXMLTokenMap( aDocTokenMap ); + } // if( !pDocElemTokenMap ) + return *pDocElemTokenMap; } -//UNUSED2008-05 const SvXMLTokenMap& ScXMLImport::GetStylesElemTokenMap() -//UNUSED2008-05 { -//UNUSED2008-05 if( !pStylesElemTokenMap ) -//UNUSED2008-05 pStylesElemTokenMap = new SvXMLTokenMap( aStylesTokenMap ); -//UNUSED2008-05 -//UNUSED2008-05 return *pStylesElemTokenMap; -//UNUSED2008-05 } -//UNUSED2008-05 -//UNUSED2008-05 const SvXMLTokenMap& ScXMLImport::GetStylesAttrTokenMap() -//UNUSED2008-05 { -//UNUSED2008-05 if( !pStylesAttrTokenMap ) -//UNUSED2008-05 pStylesAttrTokenMap = new SvXMLTokenMap( aStylesAttrTokenMap ); -//UNUSED2008-05 -//UNUSED2008-05 return *pStylesAttrTokenMap; -//UNUSED2008-05 } -//UNUSED2008-05 -//UNUSED2008-05 const SvXMLTokenMap& ScXMLImport::GetStyleElemTokenMap() -//UNUSED2008-05 { -//UNUSED2008-05 if ( !pStyleElemTokenMap ) -//UNUSED2008-05 pStyleElemTokenMap = new SvXMLTokenMap( aStyleTokenMap ); -//UNUSED2008-05 -//UNUSED2008-05 return *pStyleElemTokenMap; -//UNUSED2008-05 } - const SvXMLTokenMap& ScXMLImport::GetBodyElemTokenMap() { if( !pBodyElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aBodyTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_TRACKED_CHANGES, XML_TOK_BODY_TRACKED_CHANGES }, + { XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, XML_TOK_BODY_CALCULATION_SETTINGS }, + { XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATIONS, XML_TOK_BODY_CONTENT_VALIDATIONS }, + { XML_NAMESPACE_TABLE, XML_LABEL_RANGES, XML_TOK_BODY_LABEL_RANGES }, + { XML_NAMESPACE_TABLE, XML_TABLE, XML_TOK_BODY_TABLE }, + { XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSIONS, XML_TOK_BODY_NAMED_EXPRESSIONS }, + { XML_NAMESPACE_TABLE, XML_DATABASE_RANGES, XML_TOK_BODY_DATABASE_RANGES }, + { XML_NAMESPACE_TABLE, XML_DATABASE_RANGE, XML_TOK_BODY_DATABASE_RANGE }, + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_TABLES, XML_TOK_BODY_DATA_PILOT_TABLES }, + { XML_NAMESPACE_TABLE, XML_CONSOLIDATION, XML_TOK_BODY_CONSOLIDATION }, + { XML_NAMESPACE_TABLE, XML_DDE_LINKS, XML_TOK_BODY_DDE_LINKS }, + XML_TOKEN_MAP_END + }; + pBodyElemTokenMap = new SvXMLTokenMap( aBodyTokenMap ); + } // if( !pBodyElemTokenMap ) + return *pBodyElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetContentValidationsElemTokenMap() { if( !pContentValidationsElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aContentValidationsElemTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION, XML_TOK_CONTENT_VALIDATION }, + XML_TOKEN_MAP_END + }; + pContentValidationsElemTokenMap = new SvXMLTokenMap( aContentValidationsElemTokenMap ); + } // if( !pContentValidationsElemTokenMap ) + return *pContentValidationsElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetContentValidationElemTokenMap() { if( !pContentValidationElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aContentValidationElemTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_HELP_MESSAGE, XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE }, + { XML_NAMESPACE_TABLE, XML_ERROR_MESSAGE, XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE }, + { XML_NAMESPACE_TABLE, XML_ERROR_MACRO, XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO }, + { XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, XML_TOK_CONTENT_VALIDATION_ELEM_EVENT_LISTENERS }, + XML_TOKEN_MAP_END + }; + pContentValidationElemTokenMap = new SvXMLTokenMap( aContentValidationElemTokenMap ); + } // if( !pContentValidationElemTokenMap ) + return *pContentValidationElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetContentValidationAttrTokenMap() { if( !pContentValidationAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aContentValidationAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_CONTENT_VALIDATION_NAME }, + { XML_NAMESPACE_TABLE, XML_CONDITION, XML_TOK_CONTENT_VALIDATION_CONDITION }, + { XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, XML_TOK_CONTENT_VALIDATION_BASE_CELL_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_TOK_CONTENT_VALIDATION_ALLOW_EMPTY_CELL }, + { XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_TOK_CONTENT_VALIDATION_DISPLAY_LIST }, + XML_TOKEN_MAP_END + }; + pContentValidationAttrTokenMap = new SvXMLTokenMap( aContentValidationAttrTokenMap ); + } // if( !pContentValidationAttrTokenMap ) + return *pContentValidationAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetContentValidationMessageElemTokenMap() { if( !pContentValidationMessageElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aContentValidationMessageElemTokenMap[] = + { + { XML_NAMESPACE_TEXT, XML_P, XML_TOK_P }, + XML_TOKEN_MAP_END + }; + pContentValidationMessageElemTokenMap = new SvXMLTokenMap( aContentValidationMessageElemTokenMap ); + } // if( !pContentValidationMessageElemTokenMap ) + return *pContentValidationMessageElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetContentValidationHelpMessageAttrTokenMap() { if( !pContentValidationHelpMessageAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aContentValidationHelpMessageAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_TITLE, XML_TOK_HELP_MESSAGE_ATTR_TITLE }, + { XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TOK_HELP_MESSAGE_ATTR_DISPLAY }, + XML_TOKEN_MAP_END + }; + pContentValidationHelpMessageAttrTokenMap = new SvXMLTokenMap( aContentValidationHelpMessageAttrTokenMap ); + } // if( !pContentValidationHelpMessageAttrTokenMap ) + return *pContentValidationHelpMessageAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetContentValidationErrorMessageAttrTokenMap() { if( !pContentValidationErrorMessageAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aContentValidationErrorMessageAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_TITLE, XML_TOK_ERROR_MESSAGE_ATTR_TITLE }, + { XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TOK_ERROR_MESSAGE_ATTR_DISPLAY }, + { XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_TOK_ERROR_MESSAGE_ATTR_MESSAGE_TYPE }, + XML_TOKEN_MAP_END + }; + pContentValidationErrorMessageAttrTokenMap = new SvXMLTokenMap( aContentValidationErrorMessageAttrTokenMap ); + } // if( !pContentValidationErrorMessageAttrTokenMap ) + return *pContentValidationErrorMessageAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetContentValidationErrorMacroAttrTokenMap() { if( !pContentValidationErrorMacroAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aContentValidationErrorMacroAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_ERROR_MACRO_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_EXECUTE, XML_TOK_ERROR_MACRO_ATTR_EXECUTE }, + XML_TOKEN_MAP_END + }; + pContentValidationErrorMacroAttrTokenMap = new SvXMLTokenMap( aContentValidationErrorMacroAttrTokenMap ); + } // if( !pContentValidationErrorMacroAttrTokenMap ) + return *pContentValidationErrorMacroAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetLabelRangesElemTokenMap() { if( !pLabelRangesElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aLabelRangesElemTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_LABEL_RANGE, XML_TOK_LABEL_RANGE_ELEM }, + XML_TOKEN_MAP_END + }; + pLabelRangesElemTokenMap = new SvXMLTokenMap( aLabelRangesElemTokenMap ); + } // if( !pLabelRangesElemTokenMap ) + return *pLabelRangesElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetLabelRangeAttrTokenMap() { if( !pLabelRangeAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aLabelRangeAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_LABEL_CELL_RANGE_ADDRESS, XML_TOK_LABEL_RANGE_ATTR_LABEL_RANGE }, + { XML_NAMESPACE_TABLE, XML_DATA_CELL_RANGE_ADDRESS, XML_TOK_LABEL_RANGE_ATTR_DATA_RANGE }, + { XML_NAMESPACE_TABLE, XML_ORIENTATION, XML_TOK_LABEL_RANGE_ATTR_ORIENTATION }, + XML_TOKEN_MAP_END + }; + pLabelRangeAttrTokenMap = new SvXMLTokenMap( aLabelRangeAttrTokenMap ); + } // if( !pLabelRangeAttrTokenMap ) + return *pLabelRangeAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetTableElemTokenMap() { if( !pTableElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aTableTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN_GROUP, XML_TOK_TABLE_COL_GROUP }, + { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, XML_TOK_TABLE_HEADER_COLS }, + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, XML_TOK_TABLE_COLS }, + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, XML_TOK_TABLE_COL }, + { XML_NAMESPACE_TABLE, XML_TABLE_ROW_GROUP, XML_TOK_TABLE_ROW_GROUP }, + { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, XML_TOK_TABLE_HEADER_ROWS }, + { XML_NAMESPACE_TABLE, XML_TABLE_ROWS, XML_TOK_TABLE_ROWS }, + { XML_NAMESPACE_TABLE, XML_TABLE_ROW, XML_TOK_TABLE_ROW }, + { XML_NAMESPACE_TABLE, XML_TABLE_SOURCE, XML_TOK_TABLE_SOURCE }, + { XML_NAMESPACE_TABLE, XML_SCENARIO, XML_TOK_TABLE_SCENARIO }, + { XML_NAMESPACE_TABLE, XML_SHAPES, XML_TOK_TABLE_SHAPES }, + { XML_NAMESPACE_OFFICE, XML_FORMS, XML_TOK_TABLE_FORMS }, + XML_TOKEN_MAP_END + }; + pTableElemTokenMap = new SvXMLTokenMap( aTableTokenMap ); + } // if( !pTableElemTokenMap ) + return *pTableElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetTableRowsElemTokenMap() { if( !pTableRowsElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aTableRowsElemTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_TABLE_ROW_GROUP, XML_TOK_TABLE_ROWS_ROW_GROUP }, + { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, XML_TOK_TABLE_ROWS_HEADER_ROWS }, + { XML_NAMESPACE_TABLE, XML_TABLE_ROWS, XML_TOK_TABLE_ROWS_ROWS }, + { XML_NAMESPACE_TABLE, XML_TABLE_ROW, XML_TOK_TABLE_ROWS_ROW }, + XML_TOKEN_MAP_END + }; + pTableRowsElemTokenMap = new SvXMLTokenMap( aTableRowsElemTokenMap ); + } // if( !pTableRowsElemTokenMap ) + return *pTableRowsElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetTableColsElemTokenMap() { if( !pTableColsElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aTableColsElemTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN_GROUP, XML_TOK_TABLE_COLS_COL_GROUP }, + { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, XML_TOK_TABLE_COLS_HEADER_COLS }, + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, XML_TOK_TABLE_COLS_COLS }, + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, XML_TOK_TABLE_COLS_COL }, + XML_TOKEN_MAP_END + }; + pTableColsElemTokenMap = new SvXMLTokenMap( aTableColsElemTokenMap ); + } // if( !pTableColsElemTokenMap ) + return *pTableColsElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetTableAttrTokenMap() { if( !pTableAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aTableAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_TABLE_NAME }, + { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_STYLE_NAME }, + { XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TOK_TABLE_PROTECTION }, + { XML_NAMESPACE_TABLE, XML_PRINT_RANGES, XML_TOK_TABLE_PRINT_RANGES }, + { XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, XML_TOK_TABLE_PASSWORD }, + { XML_NAMESPACE_TABLE, XML_PRINT, XML_TOK_TABLE_PRINT }, + XML_TOKEN_MAP_END + }; + pTableAttrTokenMap = new SvXMLTokenMap( aTableAttrTokenMap ); + } // if( !pTableAttrTokenMap ) + return *pTableAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetTableScenarioAttrTokenMap() { if( !pTableScenarioAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aTableScenarioAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_DISPLAY_BORDER, XML_TOK_TABLE_SCENARIO_ATTR_DISPLAY_BORDER }, + { XML_NAMESPACE_TABLE, XML_BORDER_COLOR, XML_TOK_TABLE_SCENARIO_ATTR_BORDER_COLOR }, + { XML_NAMESPACE_TABLE, XML_COPY_BACK, XML_TOK_TABLE_SCENARIO_ATTR_COPY_BACK }, + { XML_NAMESPACE_TABLE, XML_COPY_STYLES, XML_TOK_TABLE_SCENARIO_ATTR_COPY_STYLES }, + { XML_NAMESPACE_TABLE, XML_COPY_FORMULAS, XML_TOK_TABLE_SCENARIO_ATTR_COPY_FORMULAS }, + { XML_NAMESPACE_TABLE, XML_IS_ACTIVE, XML_TOK_TABLE_SCENARIO_ATTR_IS_ACTIVE }, + { XML_NAMESPACE_TABLE, XML_SCENARIO_RANGES, XML_TOK_TABLE_SCENARIO_ATTR_SCENARIO_RANGES }, + { XML_NAMESPACE_TABLE, XML_COMMENT, XML_TOK_TABLE_SCENARIO_ATTR_COMMENT }, + { XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TOK_TABLE_SCENARIO_ATTR_PROTECTED }, + XML_TOKEN_MAP_END + }; + pTableScenarioAttrTokenMap = new SvXMLTokenMap( aTableScenarioAttrTokenMap ); + } // if( !pTableScenarioAttrTokenMap ) + return *pTableScenarioAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetTableColAttrTokenMap() { if( !pTableColAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aTableColAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_COL_ATTR_STYLE_NAME }, + { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, XML_TOK_TABLE_COL_ATTR_REPEATED }, + { XML_NAMESPACE_TABLE, XML_VISIBILITY, XML_TOK_TABLE_COL_ATTR_VISIBILITY }, + { XML_NAMESPACE_TABLE, XML_DEFAULT_CELL_STYLE_NAME, XML_TOK_TABLE_COL_ATTR_DEFAULT_CELL_STYLE_NAME }, + XML_TOKEN_MAP_END + }; + pTableColAttrTokenMap = new SvXMLTokenMap( aTableColAttrTokenMap ); + } // if( !pTableColAttrTokenMap ) + return *pTableColAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetTableRowElemTokenMap() { if( !pTableRowElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aTableRowTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_TABLE_CELL, XML_TOK_TABLE_ROW_CELL }, + { XML_NAMESPACE_TABLE, XML_COVERED_TABLE_CELL, XML_TOK_TABLE_ROW_COVERED_CELL }, + XML_TOKEN_MAP_END + }; + pTableRowElemTokenMap = new SvXMLTokenMap( aTableRowTokenMap ); + } // if( !pTableRowElemTokenMap ) + return *pTableRowElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetTableRowAttrTokenMap() { if( !pTableRowAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aTableRowAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_ROW_ATTR_STYLE_NAME }, + { XML_NAMESPACE_TABLE, XML_VISIBILITY, XML_TOK_TABLE_ROW_ATTR_VISIBILITY }, + { XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, XML_TOK_TABLE_ROW_ATTR_REPEATED }, + { XML_NAMESPACE_TABLE, XML_DEFAULT_CELL_STYLE_NAME, XML_TOK_TABLE_ROW_ATTR_DEFAULT_CELL_STYLE_NAME }, + // { XML_NAMESPACE_TABLE, XML_USE_OPTIMAL_HEIGHT, XML_TOK_TABLE_ROW_ATTR_USE_OPTIMAL_HEIGHT }, + XML_TOKEN_MAP_END + }; + pTableRowAttrTokenMap = new SvXMLTokenMap( aTableRowAttrTokenMap ); + } // if( !pTableRowAttrTokenMap ) + return *pTableRowAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetTableRowCellElemTokenMap() { if( !pTableRowCellElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aTableRowCellTokenMap[] = + { + { XML_NAMESPACE_TEXT, XML_P, XML_TOK_TABLE_ROW_CELL_P }, + { XML_NAMESPACE_TABLE, XML_SUB_TABLE, XML_TOK_TABLE_ROW_CELL_TABLE }, + { XML_NAMESPACE_OFFICE, XML_ANNOTATION, XML_TOK_TABLE_ROW_CELL_ANNOTATION }, + { XML_NAMESPACE_TABLE, XML_DETECTIVE, XML_TOK_TABLE_ROW_CELL_DETECTIVE }, + { XML_NAMESPACE_TABLE, XML_CELL_RANGE_SOURCE, XML_TOK_TABLE_ROW_CELL_CELL_RANGE_SOURCE }, + XML_TOKEN_MAP_END + }; + pTableRowCellElemTokenMap = new SvXMLTokenMap( aTableRowCellTokenMap ); - return *pTableRowCellElemTokenMap; -} + } // if( !pTableRowCellElemTokenMap ) -const SvXMLTokenMap& ScXMLImport::GetTableRowCellAttrTokenMap() -{ - if ( !pTableRowCellAttrTokenMap ) - pTableRowCellAttrTokenMap = new SvXMLTokenMap( aTableRowCellAttrTokenMap ); - return *pTableRowCellAttrTokenMap; + return *pTableRowCellElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetTableAnnotationAttrTokenMap() { if( !pTableAnnotationAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aTableAnnotationAttrTokenMap[] = + { + { XML_NAMESPACE_OFFICE, XML_AUTHOR, XML_TOK_TABLE_ANNOTATION_ATTR_AUTHOR }, + { XML_NAMESPACE_OFFICE, XML_CREATE_DATE, XML_TOK_TABLE_ANNOTATION_ATTR_CREATE_DATE }, + { XML_NAMESPACE_OFFICE, XML_CREATE_DATE_STRING, XML_TOK_TABLE_ANNOTATION_ATTR_CREATE_DATE_STRING }, + { XML_NAMESPACE_OFFICE, XML_DISPLAY, XML_TOK_TABLE_ANNOTATION_ATTR_DISPLAY }, + { XML_NAMESPACE_SVG, XML_X, XML_TOK_TABLE_ANNOTATION_ATTR_X }, + { XML_NAMESPACE_SVG, XML_Y, XML_TOK_TABLE_ANNOTATION_ATTR_Y }, + XML_TOKEN_MAP_END + }; + pTableAnnotationAttrTokenMap = new SvXMLTokenMap( aTableAnnotationAttrTokenMap ); + } // if( !pTableAnnotationAttrTokenMap ) + return *pTableAnnotationAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDetectiveElemTokenMap() { if( !pDetectiveElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDetectiveElemTokenMap[]= + { + { XML_NAMESPACE_TABLE, XML_HIGHLIGHTED_RANGE, XML_TOK_DETECTIVE_ELEM_HIGHLIGHTED }, + { XML_NAMESPACE_TABLE, XML_OPERATION, XML_TOK_DETECTIVE_ELEM_OPERATION }, + XML_TOKEN_MAP_END + }; + pDetectiveElemTokenMap = new SvXMLTokenMap( aDetectiveElemTokenMap ); + } // if( !pDetectiveElemTokenMap ) + return *pDetectiveElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDetectiveHighlightedAttrTokenMap() { if( !pDetectiveHighlightedAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDetectiveHighlightedAttrTokenMap[]= + { + { XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_CELL_RANGE }, + { XML_NAMESPACE_TABLE, XML_DIRECTION, XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_DIRECTION }, + { XML_NAMESPACE_TABLE, XML_CONTAINS_ERROR, XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_CONTAINS_ERROR }, + { XML_NAMESPACE_TABLE, XML_MARKED_INVALID, XML_TOK_DETECTIVE_HIGHLIGHTED_ATTR_MARKED_INVALID }, + XML_TOKEN_MAP_END + }; + pDetectiveHighlightedAttrTokenMap = new SvXMLTokenMap( aDetectiveHighlightedAttrTokenMap ); + } // if( !pDetectiveHighlightedAttrTokenMap ) + return *pDetectiveHighlightedAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDetectiveOperationAttrTokenMap() { if( !pDetectiveOperationAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDetectiveOperationAttrTokenMap[]= + { + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_DETECTIVE_OPERATION_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_INDEX, XML_TOK_DETECTIVE_OPERATION_ATTR_INDEX }, + XML_TOKEN_MAP_END + }; + pDetectiveOperationAttrTokenMap = new SvXMLTokenMap( aDetectiveOperationAttrTokenMap ); + } // if( !pDetectiveOperationAttrTokenMap ) + return *pDetectiveOperationAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetTableCellRangeSourceAttrTokenMap() { if( !pTableCellRangeSourceAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aTableCellRangeSourceAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_NAME }, + { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_HREF }, + { XML_NAMESPACE_TABLE, XML_FILTER_NAME, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_NAME }, + { XML_NAMESPACE_TABLE, XML_FILTER_OPTIONS, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_OPTIONS }, + { XML_NAMESPACE_TABLE, XML_LAST_COLUMN_SPANNED, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_COLUMN }, + { XML_NAMESPACE_TABLE, XML_LAST_ROW_SPANNED, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_ROW }, + { XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_REFRESH_DELAY }, + XML_TOKEN_MAP_END + }; + pTableCellRangeSourceAttrTokenMap = new SvXMLTokenMap( aTableCellRangeSourceAttrTokenMap ); + } // if( !pTableCellRangeSourceAttrTokenMap ) + return *pTableCellRangeSourceAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetNamedExpressionsElemTokenMap() { if( !pNamedExpressionsElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aNamedExpressionsTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_NAMED_RANGE, XML_TOK_NAMED_EXPRESSIONS_NAMED_RANGE }, + { XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSION, XML_TOK_NAMED_EXPRESSIONS_NAMED_EXPRESSION }, + XML_TOKEN_MAP_END + }; + pNamedExpressionsElemTokenMap = new SvXMLTokenMap( aNamedExpressionsTokenMap ); + } // if( !pNamedExpressionsElemTokenMap ) + return *pNamedExpressionsElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetNamedRangeAttrTokenMap() { if( !pNamedRangeAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aNamedRangeAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_NAMED_RANGE_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, XML_TOK_NAMED_RANGE_ATTR_CELL_RANGE_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, XML_TOK_NAMED_RANGE_ATTR_BASE_CELL_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_RANGE_USABLE_AS, XML_TOK_NAMED_RANGE_ATTR_RANGE_USABLE_AS }, + XML_TOKEN_MAP_END + }; + pNamedRangeAttrTokenMap = new SvXMLTokenMap( aNamedRangeAttrTokenMap ); + } // if( !pNamedRangeAttrTokenMap ) + return *pNamedRangeAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetNamedExpressionAttrTokenMap() { if( !pNamedExpressionAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aNamedExpressionAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_NAMED_EXPRESSION_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, XML_TOK_NAMED_EXPRESSION_ATTR_BASE_CELL_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_EXPRESSION, XML_TOK_NAMED_EXPRESSION_ATTR_EXPRESSION }, + XML_TOKEN_MAP_END + }; + pNamedExpressionAttrTokenMap = new SvXMLTokenMap( aNamedExpressionAttrTokenMap ); + } // if( !pNamedExpressionAttrTokenMap ) + return *pNamedExpressionAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDatabaseRangesElemTokenMap() { if( !pDatabaseRangesElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangesTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_DATABASE_RANGE, XML_TOK_DATABASE_RANGE }, + XML_TOKEN_MAP_END + }; + pDatabaseRangesElemTokenMap = new SvXMLTokenMap( aDatabaseRangesTokenMap ); + } // if( !pDatabaseRangesElemTokenMap ) + return *pDatabaseRangesElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDatabaseRangeElemTokenMap() { if( !pDatabaseRangeElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_SQL, XML_TOK_DATABASE_RANGE_SOURCE_SQL }, + { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_TABLE, XML_TOK_DATABASE_RANGE_SOURCE_TABLE }, + { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_QUERY, XML_TOK_DATABASE_RANGE_SOURCE_QUERY }, + { XML_NAMESPACE_TABLE, XML_FILTER, XML_TOK_FILTER }, + { XML_NAMESPACE_TABLE, XML_SORT, XML_TOK_SORT }, + { XML_NAMESPACE_TABLE, XML_SUBTOTAL_RULES, XML_TOK_DATABASE_RANGE_SUBTOTAL_RULES }, + XML_TOKEN_MAP_END + }; + pDatabaseRangeElemTokenMap = new SvXMLTokenMap( aDatabaseRangeTokenMap ); + } // if( !pDatabaseRangeElemTokenMap ) + return *pDatabaseRangeElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDatabaseRangeAttrTokenMap() { if( !pDatabaseRangeAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_DATABASE_RANGE_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_IS_SELECTION, XML_TOK_DATABASE_RANGE_ATTR_IS_SELECTION }, + { XML_NAMESPACE_TABLE, XML_ON_UPDATE_KEEP_STYLES, XML_TOK_DATABASE_RANGE_ATTR_ON_UPDATE_KEEP_STYLES }, + { XML_NAMESPACE_TABLE, XML_ON_UPDATE_KEEP_SIZE, XML_TOK_DATABASE_RANGE_ATTR_ON_UPDATE_KEEP_SIZE }, + { XML_NAMESPACE_TABLE, XML_HAS_PERSISTENT_DATA, XML_TOK_DATABASE_RANGE_ATTR_HAS_PERSISTENT_DATA }, + { XML_NAMESPACE_TABLE, XML_ORIENTATION, XML_TOK_DATABASE_RANGE_ATTR_ORIENTATION }, + { XML_NAMESPACE_TABLE, XML_CONTAINS_HEADER, XML_TOK_DATABASE_RANGE_ATTR_CONTAINS_HEADER }, + { XML_NAMESPACE_TABLE, XML_DISPLAY_FILTER_BUTTONS, XML_TOK_DATABASE_RANGE_ATTR_DISPLAY_FILTER_BUTTONS }, + { XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, XML_TOK_DATABASE_RANGE_ATTR_TARGET_RANGE_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, XML_TOK_DATABASE_RANGE_ATTR_REFRESH_DELAY }, + XML_TOKEN_MAP_END + }; + pDatabaseRangeAttrTokenMap = new SvXMLTokenMap( aDatabaseRangeAttrTokenMap ); + } // if( !pDatabaseRangeAttrTokenMap ) + return *pDatabaseRangeAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDatabaseRangeSourceSQLAttrTokenMap() { if( !pDatabaseRangeSourceSQLAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSourceSQLAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_DATABASE_NAME, XML_TOK_SOURCE_SQL_ATTR_DATABASE_NAME }, + { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_SOURCE_SQL_ATTR_HREF }, + { XML_NAMESPACE_TABLE, XML_CONNECTION_RESOURCE, XML_TOK_SOURCE_SQL_ATTR_CONNECTION_RESSOURCE}, + { XML_NAMESPACE_TABLE, XML_SQL_STATEMENT, XML_TOK_SOURCE_SQL_ATTR_SQL_STATEMENT }, + { XML_NAMESPACE_TABLE, XML_PARSE_SQL_STATEMENT, XML_TOK_SOURCE_SQL_ATTR_PARSE_SQL_STATEMENT }, + XML_TOKEN_MAP_END + }; + pDatabaseRangeSourceSQLAttrTokenMap = new SvXMLTokenMap( aDatabaseRangeSourceSQLAttrTokenMap ); + } // if( !pDatabaseRangeSourceSQLAttrTokenMap ) + return *pDatabaseRangeSourceSQLAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDatabaseRangeSourceTableAttrTokenMap() { if( !pDatabaseRangeSourceTableAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSourceTableAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_DATABASE_NAME, XML_TOK_SOURCE_TABLE_ATTR_DATABASE_NAME }, + { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_SOURCE_TABLE_ATTR_HREF }, + { XML_NAMESPACE_TABLE, XML_CONNECTION_RESOURCE, XML_TOK_SOURCE_TABLE_ATTR_CONNECTION_RESSOURCE }, + { XML_NAMESPACE_TABLE, XML_TABLE_NAME, XML_TOK_SOURCE_TABLE_ATTR_TABLE_NAME }, + XML_TOKEN_MAP_END + }; + pDatabaseRangeSourceTableAttrTokenMap = new SvXMLTokenMap( aDatabaseRangeSourceTableAttrTokenMap ); + } // if( !pDatabaseRangeSourceTableAttrTokenMap ) + return *pDatabaseRangeSourceTableAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDatabaseRangeSourceQueryAttrTokenMap() { if( !pDatabaseRangeSourceQueryAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSourceQueryAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_DATABASE_NAME, XML_TOK_SOURCE_QUERY_ATTR_DATABASE_NAME }, + { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_SOURCE_QUERY_ATTR_HREF }, + { XML_NAMESPACE_TABLE, XML_CONNECTION_RESOURCE, XML_TOK_SOURCE_QUERY_ATTR_CONNECTION_RESSOURCE }, + { XML_NAMESPACE_TABLE, XML_QUERY_NAME, XML_TOK_SOURCE_QUERY_ATTR_QUERY_NAME }, + XML_TOKEN_MAP_END + }; + pDatabaseRangeSourceQueryAttrTokenMap = new SvXMLTokenMap( aDatabaseRangeSourceQueryAttrTokenMap ); + } // if( !pDatabaseRangeSourceQueryAttrTokenMap ) + return *pDatabaseRangeSourceQueryAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetFilterElemTokenMap() { if( !pFilterElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aFilterTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_FILTER_AND, XML_TOK_FILTER_AND }, + { XML_NAMESPACE_TABLE, XML_FILTER_OR, XML_TOK_FILTER_OR }, + { XML_NAMESPACE_TABLE, XML_FILTER_CONDITION, XML_TOK_FILTER_CONDITION }, + XML_TOKEN_MAP_END + }; + pFilterElemTokenMap = new SvXMLTokenMap( aFilterTokenMap ); + } // if( !pFilterElemTokenMap ) + return *pFilterElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetFilterAttrTokenMap() { if( !pFilterAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aFilterAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, XML_TOK_FILTER_ATTR_TARGET_RANGE_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_CONDITION_SOURCE_RANGE_ADDRESS, XML_TOK_FILTER_ATTR_CONDITION_SOURCE_RANGE_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_CONDITION_SOURCE, XML_TOK_FILTER_ATTR_CONDITION_SOURCE }, + { XML_NAMESPACE_TABLE, XML_DISPLAY_DUPLICATES, XML_TOK_FILTER_ATTR_DISPLAY_DUPLICATES }, + XML_TOKEN_MAP_END + }; + pFilterAttrTokenMap = new SvXMLTokenMap( aFilterAttrTokenMap ); + } // if( !pFilterAttrTokenMap ) + return *pFilterAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetFilterConditionAttrTokenMap() { if( !pFilterConditionAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aFilterConditionAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, XML_TOK_CONDITION_ATTR_FIELD_NUMBER }, + { XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TOK_CONDITION_ATTR_CASE_SENSITIVE }, + { XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_TOK_CONDITION_ATTR_DATA_TYPE }, + { XML_NAMESPACE_TABLE, XML_VALUE, XML_TOK_CONDITION_ATTR_VALUE }, + { XML_NAMESPACE_TABLE, XML_OPERATOR, XML_TOK_CONDITION_ATTR_OPERATOR }, + XML_TOKEN_MAP_END + }; + pFilterConditionAttrTokenMap = new SvXMLTokenMap( aFilterConditionAttrTokenMap ); + } // if( !pFilterConditionAttrTokenMap ) + return *pFilterConditionAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetSortElemTokenMap() { if( !pSortElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aSortTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_SORT_BY, XML_TOK_SORT_SORT_BY }, + XML_TOKEN_MAP_END + }; + pSortElemTokenMap = new SvXMLTokenMap( aSortTokenMap ); + } // if( !pSortElemTokenMap ) + return *pSortElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetSortAttrTokenMap() { if( !pSortAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aSortAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_BIND_STYLES_TO_CONTENT, XML_TOK_SORT_ATTR_BIND_STYLES_TO_CONTENT }, + { XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, XML_TOK_SORT_ATTR_TARGET_RANGE_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TOK_SORT_ATTR_CASE_SENSITIVE }, + { XML_NAMESPACE_TABLE, XML_LANGUAGE, XML_TOK_SORT_ATTR_LANGUAGE }, + { XML_NAMESPACE_TABLE, XML_COUNTRY, XML_TOK_SORT_ATTR_COUNTRY }, + { XML_NAMESPACE_TABLE, XML_ALGORITHM, XML_TOK_SORT_ATTR_ALGORITHM }, + XML_TOKEN_MAP_END + }; + pSortAttrTokenMap = new SvXMLTokenMap( aSortAttrTokenMap ); + } // if( !pSortAttrTokenMap ) + return *pSortAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetSortSortByAttrTokenMap() { if( !pSortSortByAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aSortSortByAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, XML_TOK_SORT_BY_ATTR_FIELD_NUMBER }, + { XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_TOK_SORT_BY_ATTR_DATA_TYPE }, + { XML_NAMESPACE_TABLE, XML_ORDER, XML_TOK_SORT_BY_ATTR_ORDER }, + XML_TOKEN_MAP_END + }; + pSortSortByAttrTokenMap = new SvXMLTokenMap( aSortSortByAttrTokenMap ); + } // if( !pSortSortByAttrTokenMap ) + return *pSortSortByAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDatabaseRangeSubTotalRulesElemTokenMap() { if( !pDatabaseRangeSubTotalRulesElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSubTotalRulesTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_SORT_GROUPS, XML_TOK_SUBTOTAL_RULES_SORT_GROUPS }, + { XML_NAMESPACE_TABLE, XML_SUBTOTAL_RULE, XML_TOK_SUBTOTAL_RULES_SUBTOTAL_RULE }, + XML_TOKEN_MAP_END + }; + pDatabaseRangeSubTotalRulesElemTokenMap = new SvXMLTokenMap( aDatabaseRangeSubTotalRulesTokenMap ); + } // if( !pDatabaseRangeSubTotalRulesElemTokenMap ) + return *pDatabaseRangeSubTotalRulesElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDatabaseRangeSubTotalRulesAttrTokenMap() { if( !pDatabaseRangeSubTotalRulesAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDatabaseRangeSubTotalRulesAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_BIND_STYLES_TO_CONTENT, XML_TOK_SUBTOTAL_RULES_ATTR_BIND_STYLES_TO_CONTENT }, + { XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TOK_SUBTOTAL_RULES_ATTR_CASE_SENSITIVE }, + { XML_NAMESPACE_TABLE, XML_PAGE_BREAKS_ON_GROUP_CHANGE, XML_TOK_SUBTOTAL_RULES_ATTR_PAGE_BREAKS_ON_GROUP_CHANGE }, + XML_TOKEN_MAP_END + }; + pDatabaseRangeSubTotalRulesAttrTokenMap = new SvXMLTokenMap( aDatabaseRangeSubTotalRulesAttrTokenMap ); + } // if( !pDatabaseRangeSubTotalRulesAttrTokenMap ) + return *pDatabaseRangeSubTotalRulesAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetSubTotalRulesSortGroupsAttrTokenMap() { if( !pSubTotalRulesSortGroupsAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aSubTotalRulesSortGroupsAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_TOK_SORT_GROUPS_ATTR_DATA_TYPE }, + { XML_NAMESPACE_TABLE, XML_ORDER, XML_TOK_SORT_GROUPS_ATTR_ORDER }, + XML_TOKEN_MAP_END + }; + pSubTotalRulesSortGroupsAttrTokenMap = new SvXMLTokenMap( aSubTotalRulesSortGroupsAttrTokenMap ); + } // if( !pSubTotalRulesSortGroupsAttrTokenMap ) + return *pSubTotalRulesSortGroupsAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetSubTotalRulesSubTotalRuleElemTokenMap() { if( !pSubTotalRulesSubTotalRuleElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aSubTotalRulesSubTotalRuleTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_SUBTOTAL_FIELD, XML_TOK_SUBTOTAL_RULE_SUBTOTAL_FIELD }, + XML_TOKEN_MAP_END + }; + pSubTotalRulesSubTotalRuleElemTokenMap = new SvXMLTokenMap( aSubTotalRulesSubTotalRuleTokenMap ); + } // if( !pSubTotalRulesSubTotalRuleElemTokenMap ) + return *pSubTotalRulesSubTotalRuleElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetSubTotalRulesSubTotalRuleAttrTokenMap() { if( !pSubTotalRulesSubTotalRuleAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aSubTotalRulesSubTotalRuleAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_GROUP_BY_FIELD_NUMBER, XML_TOK_SUBTOTAL_RULE_ATTR_GROUP_BY_FIELD_NUMBER }, + XML_TOKEN_MAP_END + }; + pSubTotalRulesSubTotalRuleAttrTokenMap = new SvXMLTokenMap( aSubTotalRulesSubTotalRuleAttrTokenMap ); + } // if( !pSubTotalRulesSubTotalRuleAttrTokenMap ) + return *pSubTotalRulesSubTotalRuleAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetSubTotalRuleSubTotalFieldAttrTokenMap() { if( !pSubTotalRuleSubTotalFieldAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aSubTotalRuleSubTotalFieldAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, XML_TOK_SUBTOTAL_FIELD_ATTR_FIELD_NUMBER }, + { XML_NAMESPACE_TABLE, XML_FUNCTION, XML_TOK_SUBTOTAL_FIELD_ATTR_FUNCTION }, + XML_TOKEN_MAP_END + }; + pSubTotalRuleSubTotalFieldAttrTokenMap = new SvXMLTokenMap( aSubTotalRuleSubTotalFieldAttrTokenMap ); + } // if( !pSubTotalRuleSubTotalFieldAttrTokenMap ) + return *pSubTotalRuleSubTotalFieldAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDataPilotTablesElemTokenMap() { if( !pDataPilotTablesElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDataPilotTablesElemTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_TABLE, XML_TOK_DATA_PILOT_TABLE }, + XML_TOKEN_MAP_END + }; + pDataPilotTablesElemTokenMap = new SvXMLTokenMap( aDataPilotTablesElemTokenMap ); + } // if( !pDataPilotTablesElemTokenMap ) + return *pDataPilotTablesElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDataPilotTableAttrTokenMap() { if( !pDataPilotTableAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_DATA_PILOT_TABLE_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_APPLICATION_DATA, XML_TOK_DATA_PILOT_TABLE_ATTR_APPLICATION_DATA }, + { XML_NAMESPACE_TABLE, XML_GRAND_TOTAL, XML_TOK_DATA_PILOT_TABLE_ATTR_GRAND_TOTAL }, + { XML_NAMESPACE_TABLE, XML_IGNORE_EMPTY_ROWS, XML_TOK_DATA_PILOT_TABLE_ATTR_IGNORE_EMPTY_ROWS }, + { XML_NAMESPACE_TABLE, XML_IDENTIFY_CATEGORIES, XML_TOK_DATA_PILOT_TABLE_ATTR_IDENTIFY_CATEGORIES }, + { XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, XML_TOK_DATA_PILOT_TABLE_ATTR_TARGET_RANGE_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_BUTTONS, XML_TOK_DATA_PILOT_TABLE_ATTR_BUTTONS }, + { XML_NAMESPACE_TABLE, XML_SHOW_FILTER_BUTTON, XML_TOK_DATA_PILOT_TABLE_ATTR_SHOW_FILTER_BUTTON }, + { XML_NAMESPACE_TABLE, XML_DRILL_DOWN_ON_DOUBLE_CLICK, XML_TOK_DATA_PILOT_TABLE_ATTR_DRILL_DOWN }, + XML_TOKEN_MAP_END + }; + pDataPilotTableAttrTokenMap = new SvXMLTokenMap( aDataPilotTableAttrTokenMap ); + } // if( !pDataPilotTableAttrTokenMap ) + return *pDataPilotTableAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDataPilotTableElemTokenMap() { if( !pDataPilotTableElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableElemTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_SQL, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SQL }, + { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_TABLE, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_TABLE }, + { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_QUERY, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_QUERY }, + { XML_NAMESPACE_TABLE, XML_SOURCE_SERVICE, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SERVICE }, + { XML_NAMESPACE_TABLE, XML_SOURCE_CELL_RANGE, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_CELL_RANGE }, + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_FIELD, XML_TOK_DATA_PILOT_TABLE_ELEM_DATA_PILOT_FIELD }, + XML_TOKEN_MAP_END + }; + pDataPilotTableElemTokenMap = new SvXMLTokenMap( aDataPilotTableElemTokenMap ); + } // if( !pDataPilotTableElemTokenMap ) + return *pDataPilotTableElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDataPilotTableSourceServiceAttrTokenMap() { if( !pDataPilotTableSourceServiceAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableSourceServiceAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_SOURCE_SERVICE_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_SOURCE_NAME, XML_TOK_SOURCE_SERVICE_ATTR_SOURCE_NAME }, + { XML_NAMESPACE_TABLE, XML_OBJECT_NAME, XML_TOK_SOURCE_SERVICE_ATTR_OBJECT_NAME }, + { XML_NAMESPACE_TABLE, XML_USER_NAME, XML_TOK_SOURCE_SERVICE_ATTR_USER_NAME }, + { XML_NAMESPACE_TABLE, XML_PASSWORT, XML_TOK_SOURCE_SERVICE_ATTR_PASSWORD }, + XML_TOKEN_MAP_END + }; + pDataPilotTableSourceServiceAttrTokenMap = new SvXMLTokenMap( aDataPilotTableSourceServiceAttrTokenMap ); + } // if( !pDataPilotTableSourceServiceAttrTokenMap ) + return *pDataPilotTableSourceServiceAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDataPilotTableSourceCellRangeAttrTokenMap() { if( !pDataPilotTableSourceCellRangeAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableSourceCellRangeAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, XML_TOK_SOURCE_CELL_RANGE_ATTR_CELL_RANGE_ADDRESS}, + XML_TOKEN_MAP_END + }; + pDataPilotTableSourceCellRangeAttrTokenMap = new SvXMLTokenMap( aDataPilotTableSourceCellRangeAttrTokenMap ); + } // if( !pDataPilotTableSourceCellRangeAttrTokenMap ) + return *pDataPilotTableSourceCellRangeAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDataPilotTableSourceCellRangeElemTokenMap() { if( !pDataPilotTableSourceCellRangeElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDataPilotTableSourceCellRangeElemTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_FILTER, XML_TOK_SOURCE_CELL_RANGE_ELEM_FILTER}, + XML_TOKEN_MAP_END + }; + pDataPilotTableSourceCellRangeElemTokenMap = new SvXMLTokenMap( aDataPilotTableSourceCellRangeElemTokenMap ); + } // if( !pDataPilotTableSourceCellRangeElemTokenMap ) + return *pDataPilotTableSourceCellRangeElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDataPilotFieldAttrTokenMap() { if( !pDataPilotFieldAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDataPilotFieldAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_SOURCE_FIELD_NAME, XML_TOK_DATA_PILOT_FIELD_ATTR_SOURCE_FIELD_NAME }, + { XML_NAMESPACE_TABLE, XML_IS_DATA_LAYOUT_FIELD, XML_TOK_DATA_PILOT_FIELD_ATTR_IS_DATA_LAYOUT_FIELD }, + { XML_NAMESPACE_TABLE, XML_FUNCTION, XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION }, + { XML_NAMESPACE_TABLE, XML_ORIENTATION, XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION }, + { XML_NAMESPACE_TABLE, XML_SELECTED_PAGE, XML_TOK_DATA_PILOT_FIELD_ATTR_SELECTED_PAGE }, + { XML_NAMESPACE_TABLE, XML_USED_HIERARCHY, XML_TOK_DATA_PILOT_FIELD_ATTR_USED_HIERARCHY }, + XML_TOKEN_MAP_END + }; + pDataPilotFieldAttrTokenMap = new SvXMLTokenMap( aDataPilotFieldAttrTokenMap ); + } // if( !pDataPilotFieldAttrTokenMap ) + return *pDataPilotFieldAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDataPilotFieldElemTokenMap() { if( !pDataPilotFieldElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDataPilotFieldElemTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_LEVEL, XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LEVEL }, + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_FIELD_REFERENCE, XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_REFERENCE }, + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_GROUPS, XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_GROUPS }, + XML_TOKEN_MAP_END + }; + pDataPilotFieldElemTokenMap = new SvXMLTokenMap( aDataPilotFieldElemTokenMap ); + } // if( !pDataPilotFieldElemTokenMap ) + return *pDataPilotFieldElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDataPilotLevelAttrTokenMap() { if( !pDataPilotLevelAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDataPilotLevelAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_SHOW_EMPTY, XML_TOK_DATA_PILOT_LEVEL_ATTR_SHOW_EMPTY }, + XML_TOKEN_MAP_END + }; + pDataPilotLevelAttrTokenMap = new SvXMLTokenMap( aDataPilotLevelAttrTokenMap ); + } // if( !pDataPilotLevelAttrTokenMap ) + return *pDataPilotLevelAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDataPilotLevelElemTokenMap() { if( !pDataPilotLevelElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDataPilotLevelElemTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_SUBTOTALS, XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_SUBTOTALS }, + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_MEMBERS, XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_MEMBERS }, + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_DISPLAY_INFO, XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_DISPLAY_INFO }, + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_SORT_INFO, XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_SORT_INFO }, + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_LAYOUT_INFO, XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LAYOUT_INFO }, + XML_TOKEN_MAP_END + }; + pDataPilotLevelElemTokenMap = new SvXMLTokenMap( aDataPilotLevelElemTokenMap ); + } // if( !pDataPilotLevelElemTokenMap ) + return *pDataPilotLevelElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDataPilotSubTotalsElemTokenMap() { if( !pDataPilotSubTotalsElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDataPilotSubTotalsElemTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_SUBTOTAL, XML_TOK_DATA_PILOT_SUBTOTALS_ELEM_DATA_PILOT_SUBTOTAL }, + XML_TOKEN_MAP_END + }; + pDataPilotSubTotalsElemTokenMap = new SvXMLTokenMap( aDataPilotSubTotalsElemTokenMap ); + } // if( !pDataPilotSubTotalsElemTokenMap ) + return *pDataPilotSubTotalsElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDataPilotSubTotalAttrTokenMap() { if( !pDataPilotSubTotalAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDataPilotSubTotalAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_FUNCTION, XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_FUNCTION }, + XML_TOKEN_MAP_END + }; + pDataPilotSubTotalAttrTokenMap = new SvXMLTokenMap( aDataPilotSubTotalAttrTokenMap ); + } // if( !pDataPilotSubTotalAttrTokenMap ) + return *pDataPilotSubTotalAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDataPilotMembersElemTokenMap() { if( !pDataPilotMembersElemTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDataPilotMembersElemTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_MEMBER, XML_TOK_DATA_PILOT_MEMBERS_ELEM_DATA_PILOT_MEMBER }, + XML_TOKEN_MAP_END + }; + pDataPilotMembersElemTokenMap = new SvXMLTokenMap( aDataPilotMembersElemTokenMap ); + } // if( !pDataPilotMembersElemTokenMap ) + return *pDataPilotMembersElemTokenMap; } const SvXMLTokenMap& ScXMLImport::GetDataPilotMemberAttrTokenMap() { if( !pDataPilotMemberAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aDataPilotMemberAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_DATA_PILOT_MEMBER_ATTR_NAME }, + { XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY }, + { XML_NAMESPACE_TABLE, XML_SHOW_DETAILS, XML_TOK_DATA_PILOT_MEMBER_ATTR_SHOW_DETAILS }, + XML_TOKEN_MAP_END + }; + pDataPilotMemberAttrTokenMap = new SvXMLTokenMap( aDataPilotMemberAttrTokenMap ); + } // if( !pDataPilotMemberAttrTokenMap ) + return *pDataPilotMemberAttrTokenMap; } const SvXMLTokenMap& ScXMLImport::GetConsolidationAttrTokenMap() { if( !pConsolidationAttrTokenMap ) + { + static __FAR_DATA SvXMLTokenMapEntry aConsolidationAttrTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_FUNCTION, XML_TOK_CONSOLIDATION_ATTR_FUNCTION }, + { XML_NAMESPACE_TABLE, XML_SOURCE_CELL_RANGE_ADDRESSES, XML_TOK_CONSOLIDATION_ATTR_SOURCE_RANGES }, + { XML_NAMESPACE_TABLE, XML_TARGET_CELL_ADDRESS, XML_TOK_CONSOLIDATION_ATTR_TARGET_ADDRESS }, + { XML_NAMESPACE_TABLE, XML_USE_LABEL, XML_TOK_CONSOLIDATION_ATTR_USE_LABEL }, + { XML_NAMESPACE_TABLE, XML_LINK_TO_SOURCE_DATA, XML_TOK_CONSOLIDATION_ATTR_LINK_TO_SOURCE }, + XML_TOKEN_MAP_END + }; + pConsolidationAttrTokenMap = new SvXMLTokenMap( aConsolidationAttrTokenMap ); + } // if( !pConsolidationAttrTokenMap ) + return *pConsolidationAttrTokenMap; } SvXMLImportContext *ScXMLImport::CreateContext( USHORT nPrefix, - const OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList ) + const OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList ) { SvXMLImportContext *pContext = 0; if( (XML_NAMESPACE_OFFICE == nPrefix) && ( IsXMLToken(rLocalName, XML_DOCUMENT_STYLES) || - IsXMLToken(rLocalName, XML_DOCUMENT_CONTENT) || - IsXMLToken(rLocalName, XML_DOCUMENT_SETTINGS) )) { - pContext = new ScXMLDocContext_Impl( *this, nPrefix, rLocalName, - xAttrList ); + IsXMLToken(rLocalName, XML_DOCUMENT_CONTENT) || + IsXMLToken(rLocalName, XML_DOCUMENT_SETTINGS) )) { + pContext = new ScXMLDocContext_Impl( *this, nPrefix, rLocalName, + xAttrList ); } else if ( (XML_NAMESPACE_OFFICE == nPrefix) && - ( IsXMLToken(rLocalName, XML_DOCUMENT_META)) ) { - pContext = CreateMetaContext(rLocalName); + ( IsXMLToken(rLocalName, XML_DOCUMENT_META)) ) { + pContext = CreateMetaContext(rLocalName); } else if ( (XML_NAMESPACE_OFFICE == nPrefix) && - ( IsXMLToken(rLocalName, XML_DOCUMENT)) ) { - uno::Reference<xml::sax::XDocumentHandler> xDocBuilder( - mxServiceFactory->createInstance(::rtl::OUString::createFromAscii( + ( IsXMLToken(rLocalName, XML_DOCUMENT)) ) { + uno::Reference<xml::sax::XDocumentHandler> xDocBuilder( + mxServiceFactory->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.xml.dom.SAXDocumentBuilder")), uno::UNO_QUERY_THROW); - uno::Reference<document::XDocumentPropertiesSupplier> xDPS( - GetModel(), uno::UNO_QUERY_THROW); - // flat OpenDocument file format - pContext = new ScXMLFlatDocContext_Impl( *this, nPrefix, rLocalName, - xAttrList, xDPS->getDocumentProperties(), xDocBuilder); + uno::Reference<document::XDocumentPropertiesSupplier> xDPS( + GetModel(), uno::UNO_QUERY_THROW); + // flat OpenDocument file format + pContext = new ScXMLFlatDocContext_Impl( *this, nPrefix, rLocalName, + xAttrList, xDPS->getDocumentProperties(), xDocBuilder); } else pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList ); @@ -1449,106 +1577,106 @@ SvXMLImportContext *ScXMLImport::CreateContext( USHORT nPrefix, // #110680# ScXMLImport::ScXMLImport( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, - const sal_uInt16 nImportFlag) -: SvXMLImport( xServiceFactory, nImportFlag ), - pDoc( NULL ), - pChangeTrackingImportHelper(NULL), - pStylesImportHelper(NULL), - sNumberFormat(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT)), - sLocale(RTL_CONSTASCII_USTRINGPARAM(SC_LOCALE)), - sCellStyle(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLSTYL)), - sStandardFormat(RTL_CONSTASCII_USTRINGPARAM(SC_STANDARDFORMAT)), - sType(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_TYPE)), -// pScAutoStylePool(new SvXMLAutoStylePoolP), -// pParaItemMapper( 0 ), -// pI18NMap( new SvI18NMap ), - pDocElemTokenMap( 0 ), - pStylesElemTokenMap( 0 ), - pStylesAttrTokenMap( 0 ), - pStyleElemTokenMap( 0 ), - pBodyElemTokenMap( 0 ), - pContentValidationsElemTokenMap( 0 ), - pContentValidationElemTokenMap( 0 ), - pContentValidationAttrTokenMap( 0 ), - pContentValidationMessageElemTokenMap( 0 ), - pContentValidationHelpMessageAttrTokenMap( 0 ), - pContentValidationErrorMessageAttrTokenMap( 0 ), - pContentValidationErrorMacroAttrTokenMap( 0 ), - pLabelRangesElemTokenMap( 0 ), - pLabelRangeAttrTokenMap( 0 ), - pTableElemTokenMap( 0 ), - pTableRowsElemTokenMap( 0 ), - pTableColsElemTokenMap( 0 ), - pTableScenarioAttrTokenMap( 0 ), - pTableAttrTokenMap( 0 ), - pTableColAttrTokenMap( 0 ), - pTableRowElemTokenMap( 0 ), - pTableRowAttrTokenMap( 0 ), - pTableRowCellElemTokenMap( 0 ), - pTableRowCellAttrTokenMap( 0 ), - pTableAnnotationAttrTokenMap( 0 ), - pDetectiveElemTokenMap( 0 ), - pDetectiveHighlightedAttrTokenMap( 0 ), - pDetectiveOperationAttrTokenMap( 0 ), - pTableCellRangeSourceAttrTokenMap( 0 ), - pNamedExpressionsElemTokenMap( 0 ), - pNamedRangeAttrTokenMap( 0 ), - pNamedExpressionAttrTokenMap( 0 ), - pDatabaseRangesElemTokenMap( 0 ), - pDatabaseRangeElemTokenMap( 0 ), - pDatabaseRangeAttrTokenMap( 0 ), - pDatabaseRangeSourceSQLAttrTokenMap( 0 ), - pDatabaseRangeSourceTableAttrTokenMap( 0 ), - pDatabaseRangeSourceQueryAttrTokenMap( 0 ), - pFilterElemTokenMap( 0 ), - pFilterAttrTokenMap( 0 ), - pFilterConditionAttrTokenMap( 0 ), - pSortElemTokenMap( 0 ), - pSortAttrTokenMap( 0 ), - pSortSortByAttrTokenMap( 0 ), - pDatabaseRangeSubTotalRulesElemTokenMap( 0 ), - pDatabaseRangeSubTotalRulesAttrTokenMap( 0 ), - pSubTotalRulesSortGroupsAttrTokenMap( 0 ), - pSubTotalRulesSubTotalRuleElemTokenMap( 0 ), - pSubTotalRulesSubTotalRuleAttrTokenMap( 0 ), - pSubTotalRuleSubTotalFieldAttrTokenMap( 0 ), - pDataPilotTablesElemTokenMap( 0 ), - pDataPilotTableAttrTokenMap( 0 ), - pDataPilotTableElemTokenMap( 0 ), - pDataPilotTableSourceServiceAttrTokenMap( 0 ), - pDataPilotTableSourceCellRangeElemTokenMap( 0 ), - pDataPilotTableSourceCellRangeAttrTokenMap( 0 ), - pDataPilotFieldAttrTokenMap( 0 ), - pDataPilotFieldElemTokenMap( 0 ), - pDataPilotLevelAttrTokenMap( 0 ), - pDataPilotLevelElemTokenMap( 0 ), - pDataPilotSubTotalsElemTokenMap( 0 ), - pDataPilotSubTotalAttrTokenMap( 0 ), - pDataPilotMembersElemTokenMap( 0 ), - pDataPilotMemberAttrTokenMap( 0 ), - pConsolidationAttrTokenMap( 0 ), - aTables(*this), - pMyNamedExpressions(NULL), - pMyLabelRanges(NULL), - pValidations(NULL), - pDetectiveOpArray(NULL), - pDefaultNotes(NULL), - pScUnoGuard(NULL), - pNumberFormatAttributesExportHelper(NULL), - pStyleNumberFormats(NULL), - sPrevStyleName(), - sPrevCurrency(), - nSolarMutexLocked(0), - nProgressCount(0), - nStyleFamilyMask( 0 ), - nPrevCellType(0), - bLoadDoc( sal_True ), - bRemoveLastChar(sal_False), - bNullDateSetted(sal_False), - bSelfImportingXMLSet(sal_False), - bLatinDefaultStyle(sal_False), - bFromWrapper(sal_False) + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + const sal_uInt16 nImportFlag) + : SvXMLImport( xServiceFactory, nImportFlag ), + pDoc( NULL ), + pChangeTrackingImportHelper(NULL), + pStylesImportHelper(NULL), + sNumberFormat(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT)), + sLocale(RTL_CONSTASCII_USTRINGPARAM(SC_LOCALE)), + sCellStyle(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLSTYL)), + sStandardFormat(RTL_CONSTASCII_USTRINGPARAM(SC_STANDARDFORMAT)), + sType(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_TYPE)), + // pScAutoStylePool(new SvXMLAutoStylePoolP), + // pParaItemMapper( 0 ), + // pI18NMap( new SvI18NMap ), + pDocElemTokenMap( 0 ), + pStylesElemTokenMap( 0 ), + pStylesAttrTokenMap( 0 ), + pStyleElemTokenMap( 0 ), + pBodyElemTokenMap( 0 ), + pContentValidationsElemTokenMap( 0 ), + pContentValidationElemTokenMap( 0 ), + pContentValidationAttrTokenMap( 0 ), + pContentValidationMessageElemTokenMap( 0 ), + pContentValidationHelpMessageAttrTokenMap( 0 ), + pContentValidationErrorMessageAttrTokenMap( 0 ), + pContentValidationErrorMacroAttrTokenMap( 0 ), + pLabelRangesElemTokenMap( 0 ), + pLabelRangeAttrTokenMap( 0 ), + pTableElemTokenMap( 0 ), + pTableRowsElemTokenMap( 0 ), + pTableColsElemTokenMap( 0 ), + pTableScenarioAttrTokenMap( 0 ), + pTableAttrTokenMap( 0 ), + pTableColAttrTokenMap( 0 ), + pTableRowElemTokenMap( 0 ), + pTableRowAttrTokenMap( 0 ), + pTableRowCellElemTokenMap( 0 ), + pTableRowCellAttrTokenMap( 0 ), + pTableAnnotationAttrTokenMap( 0 ), + pDetectiveElemTokenMap( 0 ), + pDetectiveHighlightedAttrTokenMap( 0 ), + pDetectiveOperationAttrTokenMap( 0 ), + pTableCellRangeSourceAttrTokenMap( 0 ), + pNamedExpressionsElemTokenMap( 0 ), + pNamedRangeAttrTokenMap( 0 ), + pNamedExpressionAttrTokenMap( 0 ), + pDatabaseRangesElemTokenMap( 0 ), + pDatabaseRangeElemTokenMap( 0 ), + pDatabaseRangeAttrTokenMap( 0 ), + pDatabaseRangeSourceSQLAttrTokenMap( 0 ), + pDatabaseRangeSourceTableAttrTokenMap( 0 ), + pDatabaseRangeSourceQueryAttrTokenMap( 0 ), + pFilterElemTokenMap( 0 ), + pFilterAttrTokenMap( 0 ), + pFilterConditionAttrTokenMap( 0 ), + pSortElemTokenMap( 0 ), + pSortAttrTokenMap( 0 ), + pSortSortByAttrTokenMap( 0 ), + pDatabaseRangeSubTotalRulesElemTokenMap( 0 ), + pDatabaseRangeSubTotalRulesAttrTokenMap( 0 ), + pSubTotalRulesSortGroupsAttrTokenMap( 0 ), + pSubTotalRulesSubTotalRuleElemTokenMap( 0 ), + pSubTotalRulesSubTotalRuleAttrTokenMap( 0 ), + pSubTotalRuleSubTotalFieldAttrTokenMap( 0 ), + pDataPilotTablesElemTokenMap( 0 ), + pDataPilotTableAttrTokenMap( 0 ), + pDataPilotTableElemTokenMap( 0 ), + pDataPilotTableSourceServiceAttrTokenMap( 0 ), + pDataPilotTableSourceCellRangeElemTokenMap( 0 ), + pDataPilotTableSourceCellRangeAttrTokenMap( 0 ), + pDataPilotFieldAttrTokenMap( 0 ), + pDataPilotFieldElemTokenMap( 0 ), + pDataPilotLevelAttrTokenMap( 0 ), + pDataPilotLevelElemTokenMap( 0 ), + pDataPilotSubTotalsElemTokenMap( 0 ), + pDataPilotSubTotalAttrTokenMap( 0 ), + pDataPilotMembersElemTokenMap( 0 ), + pDataPilotMemberAttrTokenMap( 0 ), + pConsolidationAttrTokenMap( 0 ), + aTables(*this), + pMyNamedExpressions(NULL), + pMyLabelRanges(NULL), + pValidations(NULL), + pDetectiveOpArray(NULL), + pDefaultNotes(NULL), + pScUnoGuard(NULL), + pNumberFormatAttributesExportHelper(NULL), + pStyleNumberFormats(NULL), + sPrevStyleName(), + sPrevCurrency(), + nSolarMutexLocked(0), + nProgressCount(0), + nStyleFamilyMask( 0 ), + nPrevCellType(0), + bLoadDoc( sal_True ), + bRemoveLastChar(sal_False), + bNullDateSetted(sal_False), + bSelfImportingXMLSet(sal_False), + bLatinDefaultStyle(sal_False), + bFromWrapper(sal_False) { pStylesImportHelper = new ScMyStylesImportHelper(*this); @@ -1586,9 +1714,7 @@ ScXMLImport::ScXMLImport( ScXMLImport::~ScXMLImport() throw() { -// RemoveUnusedNumRules(); - -// delete pI18NMap; + // delete pI18NMap; delete pDocElemTokenMap; delete pStylesElemTokenMap; delete pStylesAttrTokenMap; @@ -1655,8 +1781,8 @@ ScXMLImport::~ScXMLImport() throw() delete pDataPilotMemberAttrTokenMap; delete pConsolidationAttrTokenMap; -// if (pScAutoStylePool) -// delete pScAutoStylePool; + // if (pScAutoStylePool) + // delete pScAutoStylePool; if (pChangeTrackingImportHelper) delete pChangeTrackingImportHelper; if (pNumberFormatAttributesExportHelper) @@ -1684,15 +1810,15 @@ ScXMLImport::~ScXMLImport() throw() // --------------------------------------------------------------------- SvXMLImportContext *ScXMLImport::CreateFontDeclsContext(const USHORT nPrefix, const ::rtl::OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList) + const uno::Reference<xml::sax::XAttributeList>& xAttrList) { SvXMLImportContext *pContext = NULL; if (!pContext) { XMLFontStylesContext *pFSContext( new XMLFontStylesContext( *this, nPrefix, - rLocalName, xAttrList, - gsl_getSystemTextEncoding() )); + rLocalName, xAttrList, + gsl_getSystemTextEncoding() )); SetFontDecls( pFSContext ); pContext = pFSContext; } @@ -1700,7 +1826,7 @@ SvXMLImportContext *ScXMLImport::CreateFontDeclsContext(const USHORT nPrefix, co } SvXMLImportContext *ScXMLImport::CreateStylesContext(const ::rtl::OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList, sal_Bool bIsAutoStyle ) + const uno::Reference<xml::sax::XAttributeList>& xAttrList, sal_Bool bIsAutoStyle ) { SvXMLImportContext *pContext(NULL); if (!pContext) @@ -1717,7 +1843,7 @@ SvXMLImportContext *ScXMLImport::CreateStylesContext(const ::rtl::OUString& rLoc } SvXMLImportContext *ScXMLImport::CreateBodyContext(const ::rtl::OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList) + const uno::Reference<xml::sax::XAttributeList>& xAttrList) { //GetShapeImport()->SetAutoStylesContext((XMLTableStylesContext *)&xAutoStyles); //GetChartImport()->SetAutoStylesContext(GetAutoStyles()/*(XMLTableStylesContext *)&xAutoStyles*/); @@ -1726,7 +1852,7 @@ SvXMLImportContext *ScXMLImport::CreateBodyContext(const ::rtl::OUString& rLocal } SvXMLImportContext *ScXMLImport::CreateMetaContext( - const OUString& rLocalName ) + const OUString& rLocalName ) { SvXMLImportContext *pContext(0); @@ -1734,46 +1860,46 @@ SvXMLImportContext *ScXMLImport::CreateMetaContext( { uno::Reference<xml::sax::XDocumentHandler> xDocBuilder( mxServiceFactory->createInstance(::rtl::OUString::createFromAscii( - "com.sun.star.xml.dom.SAXDocumentBuilder")), - uno::UNO_QUERY_THROW); + "com.sun.star.xml.dom.SAXDocumentBuilder")), + uno::UNO_QUERY_THROW); uno::Reference<document::XDocumentPropertiesSupplier> xDPS( GetModel(), uno::UNO_QUERY_THROW); pContext = new SvXMLMetaDocumentContext(*this, - XML_NAMESPACE_OFFICE, rLocalName, - xDPS->getDocumentProperties(), xDocBuilder); + XML_NAMESPACE_OFFICE, rLocalName, + xDPS->getDocumentProperties(), xDocBuilder); } if( !pContext ) pContext = new SvXMLImportContext( *this, - XML_NAMESPACE_OFFICE, rLocalName ); + XML_NAMESPACE_OFFICE, rLocalName ); return pContext; } SvXMLImportContext *ScXMLImport::CreateScriptContext( - const OUString& rLocalName ) + const OUString& rLocalName ) { SvXMLImportContext *pContext(0); if( !(IsStylesOnlyMode()) ) { pContext = new XMLScriptContext( *this, - XML_NAMESPACE_OFFICE, rLocalName, - GetModel() ); + XML_NAMESPACE_OFFICE, rLocalName, + GetModel() ); } if( !pContext ) pContext = new SvXMLImportContext( *this, XML_NAMESPACE_OFFICE, - rLocalName ); + rLocalName ); return pContext; } void ScXMLImport::SetStatistics( - const uno::Sequence<beans::NamedValue> & i_rStats) + const uno::Sequence<beans::NamedValue> & i_rStats) { static const char* s_stats[] = - { "TableCount", "CellCount", "ObjectCount", 0 }; + { "TableCount", "CellCount", "ObjectCount", 0 }; SvXMLImport::SetStatistics(i_rStats); @@ -1882,7 +2008,7 @@ void ScXMLImport::ExamineDefaultStyle() else { LocaleDataWrapper aLocaleData( pDoc->GetServiceManager(), - MsLangId::convertLanguageToLocale( nFormatLang ) ); + MsLangId::convertLanguageToLocale( nFormatLang ) ); aDecSep = aLocaleData.getNumDecimalSep(); } @@ -2118,7 +2244,7 @@ sal_Int32 ScXMLImport::SetCurrencySymbol(const sal_Int32 nKey, const rtl::OUStri } } } - return nKey; + return nKey; } sal_Bool ScXMLImport::IsCurrencySymbol(const sal_Int32 nNumberFormat, const rtl::OUString& sCurrentCurrency, const rtl::OUString& sBankSymbol) @@ -2165,9 +2291,9 @@ sal_Bool ScXMLImport::IsCurrencySymbol(const sal_Int32 nNumberFormat, const rtl: } void ScXMLImport::SetType(uno::Reference <beans::XPropertySet>& rProperties, - sal_Int32& rNumberFormat, - const sal_Int16 nCellType, - const rtl::OUString& rCurrency) + sal_Int32& rNumberFormat, + const sal_Int16 nCellType, + const rtl::OUString& rCurrency) { if ((nCellType != util::NumberFormat::TEXT) && (nCellType != util::NumberFormat::UNDEFINED)) { @@ -2279,15 +2405,15 @@ void ScXMLImport::SetStyleToRanges() uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY); if (xMultiServiceFactory.is()) xSheetCellRanges.set(uno::Reference <sheet::XSheetCellRangeContainer>( - xMultiServiceFactory->createInstance( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SheetCellRanges"))), - uno::UNO_QUERY)); + xMultiServiceFactory->createInstance( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SheetCellRanges"))), + uno::UNO_QUERY)); } DBG_ASSERT(xSheetCellRanges.is(), "didn't get SheetCellRanges"); } void ScXMLImport::SetStyleToRange(const ScRange& rRange, const rtl::OUString* pStyleName, - const sal_Int16 nCellType, const rtl::OUString* pCurrency) + const sal_Int16 nCellType, const rtl::OUString* pCurrency) { if (!sPrevStyleName.getLength()) { @@ -2300,10 +2426,10 @@ void ScXMLImport::SetStyleToRange(const ScRange& rRange, const rtl::OUString* pS sPrevCurrency = sEmpty; } else if ((nCellType != nPrevCellType) || - ((pStyleName && !pStyleName->equals(sPrevStyleName)) || - (!pStyleName && sPrevStyleName.getLength())) || - ((pCurrency && !pCurrency->equals(sPrevCurrency)) || - (!pCurrency && sPrevCurrency.getLength()))) + ((pStyleName && !pStyleName->equals(sPrevStyleName)) || + (!pStyleName && sPrevStyleName.getLength())) || + ((pCurrency && !pCurrency->equals(sPrevCurrency)) || + (!pCurrency && sPrevCurrency.getLength()))) { SetStyleToRanges(); nPrevCellType = nCellType; @@ -2355,7 +2481,7 @@ void ScXMLImport::SetStylesToRangesFinished() // XImporter void SAL_CALL ScXMLImport::setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) - throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { LockSolarMutex(); SvXMLImport::setTargetDocument( xDoc ); @@ -2376,30 +2502,30 @@ void SAL_CALL ScXMLImport::setTargetDocument( const ::com::sun::star::uno::Refer // XServiceInfo ::rtl::OUString SAL_CALL ScXMLImport::getImplementationName( ) - throw(::com::sun::star::uno::RuntimeException) +throw(::com::sun::star::uno::RuntimeException) { switch( getImportFlags() ) { - case IMPORT_ALL: - return ScXMLImport_getImplementationName(); - case (IMPORT_STYLES|IMPORT_MASTERSTYLES|IMPORT_AUTOSTYLES|IMPORT_FONTDECLS): - return ScXMLImport_Styles_getImplementationName(); - case (IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_FONTDECLS): - return ScXMLImport_Content_getImplementationName(); - case IMPORT_META: - return ScXMLImport_Meta_getImplementationName(); - case IMPORT_SETTINGS: - return ScXMLImport_Settings_getImplementationName(); - default: - // generic name for 'unknown' cases - return ScXMLImport_getImplementationName(); + case IMPORT_ALL: + return ScXMLImport_getImplementationName(); + case (IMPORT_STYLES|IMPORT_MASTERSTYLES|IMPORT_AUTOSTYLES|IMPORT_FONTDECLS): + return ScXMLImport_Styles_getImplementationName(); + case (IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_FONTDECLS): + return ScXMLImport_Content_getImplementationName(); + case IMPORT_META: + return ScXMLImport_Meta_getImplementationName(); + case IMPORT_SETTINGS: + return ScXMLImport_Settings_getImplementationName(); + default: + // generic name for 'unknown' cases + return ScXMLImport_getImplementationName(); } return SvXMLImport::getImplementationName(); } // ::com::sun::star::xml::sax::XDocumentHandler void SAL_CALL ScXMLImport::startDocument(void) - throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ) +throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ) { LockSolarMutex(); SvXMLImport::startDocument(); @@ -2433,9 +2559,9 @@ sal_Int32 ScXMLImport::GetRangeType(const rtl::OUString sRangeType) const else if (sTemp.compareToAscii(SC_REPEAT_ROW) == 0) nRangeType |= sheet::NamedRangeFlag::ROW_HEADER; else if (sTemp.compareToAscii(SC_FILTER) == 0) - nRangeType |= sheet::NamedRangeFlag::FILTER_CRITERIA; + nRangeType |= sheet::NamedRangeFlag::FILTER_CRITERIA; else if (sTemp.compareToAscii(SC_PRINT_RANGE) == 0) - nRangeType |= sheet::NamedRangeFlag::PRINT_AREA; + nRangeType |= sheet::NamedRangeFlag::PRINT_AREA; } else if (i < sRangeType.getLength()) sBuffer.append(sRangeType[i]); @@ -2573,7 +2699,7 @@ void ScXMLImport::SetNamedRanges() } void SAL_CALL ScXMLImport::endDocument(void) - throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ) +throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ) { LockSolarMutex(); if (getImportFlags() & IMPORT_CONTENT) @@ -2727,31 +2853,31 @@ void ScXMLImport::ProgressBarIncrement(sal_Bool bEditCell, sal_Int32 nInc) // static bool ScXMLImport::IsAcceptedFormulaNamespace( const sal_uInt16 nFormulaPrefix, - const rtl::OUString & rValue, ScGrammar::Grammar& rGrammar, - const ScGrammar::Grammar eStorageGrammar ) + const rtl::OUString & rValue, formula::FormulaGrammar::Grammar& rGrammar, + const formula::FormulaGrammar::Grammar eStorageGrammar ) { switch (nFormulaPrefix) { - case XML_NAMESPACE_OF: - rGrammar = ScGrammar::GRAM_ODFF; - return true; - case XML_NAMESPACE_OOOC: - rGrammar = ScGrammar::GRAM_PODF; - return true; + case XML_NAMESPACE_OF: + rGrammar = formula::FormulaGrammar::GRAM_ODFF; + return true; + case XML_NAMESPACE_OOOC: + rGrammar = formula::FormulaGrammar::GRAM_PODF; + return true; } // An invalid namespace can occur from a colon in the formula text if no // namespace tag was added. First character in string has to be '=' in that // case. bool bNoNamespace = (nFormulaPrefix == XML_NAMESPACE_NONE || - (nFormulaPrefix == XML_NAMESPACE_UNKNOWN && rValue.toChar() == '=')); + (nFormulaPrefix == XML_NAMESPACE_UNKNOWN && rValue.toChar() == '=')); - if (bNoNamespace && eStorageGrammar == ScGrammar::GRAM_PODF) + if (bNoNamespace && eStorageGrammar == formula::FormulaGrammar::GRAM_PODF) // There may be documents in the wild that stored no namespace in ODF 1.x - rGrammar = ScGrammar::GRAM_PODF; + rGrammar = formula::FormulaGrammar::GRAM_PODF; else if (bNoNamespace) // The default for ODF 1.2 and later without namespace is 'of:' ODFF - rGrammar = ScGrammar::GRAM_ODFF; + rGrammar = formula::FormulaGrammar::GRAM_ODFF; else // Whatever ... rGrammar = eStorageGrammar; diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx index bbafdc2a2ea5..bf5f263d1875 100644 --- a/sc/source/filter/xml/xmlimprt.hxx +++ b/sc/source/filter/xml/xmlimprt.hxx @@ -42,7 +42,7 @@ #include <com/sun/star/util/DateTime.hpp> #include "xmlsubti.hxx" #include "global.hxx" -#include "grammar.hxx" +#include "formula/grammar.hxx" #include "xmlstyle.hxx" #include "XMLDetectiveContext.hxx" @@ -600,7 +600,7 @@ struct ScMyNamedExpression rtl::OUString sContent; rtl::OUString sBaseCellAddress; rtl::OUString sRangeType; - ScGrammar::Grammar eGrammar; + formula::FormulaGrammar::Grammar eGrammar; sal_Bool bIsExpression; }; @@ -628,7 +628,7 @@ struct ScMyImportValidation com::sun::star::sheet::ValidationAlertStyle aAlertStyle; com::sun::star::sheet::ValidationType aValidationType; com::sun::star::sheet::ConditionOperator aOperator; - ScGrammar::Grammar eGrammar; + formula::FormulaGrammar::Grammar eGrammar; sal_Int16 nShowList; sal_Bool bShowErrorMessage; sal_Bool bShowImputMessage; @@ -1008,13 +1008,13 @@ public: any. @param rGrammar - Return value set to ScGrammar::GRAM_ODFF or ScGrammar::GRAM_PODF or + Return value set toformula::FormulaGrammar::GRAM_ODFF orformula::FormulaGrammar::GRAM_PODF or eStorageGrammar, according to the namespace or absence thereof encountered. @param eStorageGrammar - Default storage grammar of the document, ScGrammar::GRAM_ODFF for - ODF 1.2 and later documents, ScGrammar::GRAM_PODF for ODF 1.x + Default storage grammar of the document,formula::FormulaGrammar::GRAM_ODFF for + ODF 1.2 and later documents,formula::FormulaGrammar::GRAM_PODF for ODF 1.x documents. @return @@ -1023,8 +1023,8 @@ public: */ static bool IsAcceptedFormulaNamespace( const sal_uInt16 nFormulaPrefix, - const rtl::OUString & rValue, ScGrammar::Grammar& rGrammar, - const ScGrammar::Grammar eStorageGrammar ); + const rtl::OUString & rValue, formula::FormulaGrammar::Grammar& rGrammar, + const formula::FormulaGrammar::Grammar eStorageGrammar ); }; diff --git a/sc/source/filter/xml/xmlnexpi.cxx b/sc/source/filter/xml/xmlnexpi.cxx index 63342989ba1d..249522c1a9bc 100644 --- a/sc/source/filter/xml/xmlnexpi.cxx +++ b/sc/source/filter/xml/xmlnexpi.cxx @@ -1,262 +1,262 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: xmlnexpi.cxx,v $ - * $Revision: 1.18 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - - - -// INCLUDE --------------------------------------------------------------- -#include <rtl/ustrbuf.hxx> - -#include "xmlnexpi.hxx" -#include "xmlimprt.hxx" -#include "xmlcelli.hxx" -#include "docuno.hxx" -#include "global.hxx" -#include "document.hxx" -#include "XMLConverter.hxx" - -#include <xmloff/xmltkmap.hxx> -#include <xmloff/nmspmap.hxx> - -using namespace com::sun::star; - -//------------------------------------------------------------------ - -ScXMLNamedExpressionsContext::ScXMLNamedExpressionsContext( ScXMLImport& rImport, - USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) : - SvXMLImportContext( rImport, nPrfx, rLName ) -{ -/* sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; ++i ) - { - const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i )); - rtl::OUString aLocalName; - USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( - sAttrName, &aLocalName ); - const rtl::OUString& sValue(xAttrList->getValueByIndex( i )); - - const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedRangeAttrTokenMap(); - - switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) - { - } - }*/ - rImport.LockSolarMutex(); -} - -ScXMLNamedExpressionsContext::~ScXMLNamedExpressionsContext() -{ - GetScImport().UnlockSolarMutex(); -} - -SvXMLImportContext *ScXMLNamedExpressionsContext::CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) -{ - SvXMLImportContext *pContext(0); - - const SvXMLTokenMap& rTokenMap(GetScImport().GetNamedExpressionsElemTokenMap()); - switch( rTokenMap.Get( nPrefix, rLName ) ) - { - case XML_TOK_NAMED_EXPRESSIONS_NAMED_RANGE: - pContext = new ScXMLNamedRangeContext( GetScImport(), nPrefix, - rLName, xAttrList//, - //this - ); - break; - case XML_TOK_NAMED_EXPRESSIONS_NAMED_EXPRESSION: - pContext = new ScXMLNamedExpressionContext( GetScImport(), nPrefix, - rLName, xAttrList//, - //this - ); - break; - } - - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); - - return pContext; -} - -void ScXMLNamedExpressionsContext::EndElement() -{ - // happends in ScXMLImport::EndDocument() - // because it has to be set after the Database Ranges -} - -ScXMLNamedRangeContext::ScXMLNamedRangeContext( ScXMLImport& rImport, - USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : - SvXMLImportContext( rImport, nPrfx, rLName ) -{ - ScMyNamedExpression* pNamedExpression(new ScMyNamedExpression); - // A simple table:cell-range-address is not a formula expression, stored - // without [] brackets but with dot, .A1 - pNamedExpression->eGrammar = ScGrammar::mergeToGrammar( - GetScImport().GetDocument()->GetStorageGrammar(), - ScAddress::CONV_OOO); - sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0); - const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedRangeAttrTokenMap(); - for( sal_Int16 i=0; i < nAttrCount; ++i ) - { - const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i )); - rtl::OUString aLocalName; - USHORT nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName( - sAttrName, &aLocalName )); - const rtl::OUString& sValue(xAttrList->getValueByIndex( i )); - - switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) - { - case XML_TOK_NAMED_RANGE_ATTR_NAME : - { - pNamedExpression->sName = sValue; - } - break; - case XML_TOK_NAMED_RANGE_ATTR_CELL_RANGE_ADDRESS : - { - pNamedExpression->sContent = sValue; - } - break; - case XML_TOK_NAMED_RANGE_ATTR_BASE_CELL_ADDRESS : - { - pNamedExpression->sBaseCellAddress = sValue; - } - break; - case XML_TOK_NAMED_RANGE_ATTR_RANGE_USABLE_AS : - { - pNamedExpression->sRangeType = sValue; - } - break; - } - } - pNamedExpression->bIsExpression = sal_False; - GetScImport().AddNamedExpression(pNamedExpression); -} - -ScXMLNamedRangeContext::~ScXMLNamedRangeContext() -{ -} - -SvXMLImportContext *ScXMLNamedRangeContext::CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) -{ -/* const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLName ) ) - { - }*/ - return new SvXMLImportContext( GetImport(), nPrefix, rLName ); -} - -void ScXMLNamedRangeContext::EndElement() -{ -} - -ScXMLNamedExpressionContext::ScXMLNamedExpressionContext( ScXMLImport& rImport, - USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : - SvXMLImportContext( rImport, nPrfx, rLName ) -{ - ScMyNamedExpression* pNamedExpression(new ScMyNamedExpression); - const ScGrammar::Grammar eStorageGrammar = pNamedExpression->eGrammar = - GetScImport().GetDocument()->GetStorageGrammar(); - sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0); - const SvXMLTokenMap& rAttrTokenMap(GetScImport().GetNamedExpressionAttrTokenMap()); - for( sal_Int16 i=0; i < nAttrCount; ++i ) - { - const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i )); - rtl::OUString aLocalName; - USHORT nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName( - sAttrName, &aLocalName )); - const rtl::OUString& sValue(xAttrList->getValueByIndex( i )); - - switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) - { - case XML_TOK_NAMED_EXPRESSION_ATTR_NAME : - { - pNamedExpression->sName = sValue; - } - break; - case XML_TOK_NAMED_EXPRESSION_ATTR_EXPRESSION : - { - rtl::OUString sFormula; - sal_uInt16 nFormulaPrefix = GetImport().GetNamespaceMap(). - _GetKeyByAttrName( sValue, &sFormula, sal_False ); - - if (ScXMLImport::IsAcceptedFormulaNamespace( nFormulaPrefix, - sValue, pNamedExpression->eGrammar, - eStorageGrammar)) - pNamedExpression->sContent = sFormula; - else - pNamedExpression->sContent = sValue; - } - break; - case XML_TOK_NAMED_EXPRESSION_ATTR_BASE_CELL_ADDRESS : - { - pNamedExpression->sBaseCellAddress = sValue; - } - break; - } - } - pNamedExpression->bIsExpression = sal_True; - GetScImport().AddNamedExpression(pNamedExpression); -} - -ScXMLNamedExpressionContext::~ScXMLNamedExpressionContext() -{ -} - -SvXMLImportContext *ScXMLNamedExpressionContext::CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) -{ -/* const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLName ) ) - { - }*/ - return new SvXMLImportContext( GetImport(), nPrefix, rLName );; -} - -void ScXMLNamedExpressionContext::EndElement() -{ -} - +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: xmlnexpi.cxx,v $
+ * $Revision: 1.18 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+#include <rtl/ustrbuf.hxx>
+
+#include "xmlnexpi.hxx"
+#include "xmlimprt.hxx"
+#include "xmlcelli.hxx"
+#include "docuno.hxx"
+#include "global.hxx"
+#include "document.hxx"
+#include "XMLConverter.hxx"
+
+#include <xmloff/xmltkmap.hxx>
+#include <xmloff/nmspmap.hxx>
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------
+
+ScXMLNamedExpressionsContext::ScXMLNamedExpressionsContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+/* sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName );
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedRangeAttrTokenMap();
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ }
+ }*/
+ rImport.LockSolarMutex();
+}
+
+ScXMLNamedExpressionsContext::~ScXMLNamedExpressionsContext()
+{
+ GetScImport().UnlockSolarMutex();
+}
+
+SvXMLImportContext *ScXMLNamedExpressionsContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ SvXMLImportContext *pContext(0);
+
+ const SvXMLTokenMap& rTokenMap(GetScImport().GetNamedExpressionsElemTokenMap());
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ case XML_TOK_NAMED_EXPRESSIONS_NAMED_RANGE:
+ pContext = new ScXMLNamedRangeContext( GetScImport(), nPrefix,
+ rLName, xAttrList//,
+ //this
+ );
+ break;
+ case XML_TOK_NAMED_EXPRESSIONS_NAMED_EXPRESSION:
+ pContext = new ScXMLNamedExpressionContext( GetScImport(), nPrefix,
+ rLName, xAttrList//,
+ //this
+ );
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLNamedExpressionsContext::EndElement()
+{
+ // happends in ScXMLImport::EndDocument()
+ // because it has to be set after the Database Ranges
+}
+
+ScXMLNamedRangeContext::ScXMLNamedRangeContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+ ScMyNamedExpression* pNamedExpression(new ScMyNamedExpression);
+ // A simple table:cell-range-address is not a formula expression, stored
+ // without [] brackets but with dot, .A1
+ pNamedExpression->eGrammar = formula::FormulaGrammar::mergeToGrammar(
+ GetScImport().GetDocument()->GetStorageGrammar(),
+ formula::FormulaGrammar::CONV_OOO);
+ sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedRangeAttrTokenMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ USHORT nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName ));
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_NAMED_RANGE_ATTR_NAME :
+ {
+ pNamedExpression->sName = sValue;
+ }
+ break;
+ case XML_TOK_NAMED_RANGE_ATTR_CELL_RANGE_ADDRESS :
+ {
+ pNamedExpression->sContent = sValue;
+ }
+ break;
+ case XML_TOK_NAMED_RANGE_ATTR_BASE_CELL_ADDRESS :
+ {
+ pNamedExpression->sBaseCellAddress = sValue;
+ }
+ break;
+ case XML_TOK_NAMED_RANGE_ATTR_RANGE_USABLE_AS :
+ {
+ pNamedExpression->sRangeType = sValue;
+ }
+ break;
+ }
+ }
+ pNamedExpression->bIsExpression = sal_False;
+ GetScImport().AddNamedExpression(pNamedExpression);
+}
+
+ScXMLNamedRangeContext::~ScXMLNamedRangeContext()
+{
+}
+
+SvXMLImportContext *ScXMLNamedRangeContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
+{
+/* const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ }*/
+ return new SvXMLImportContext( GetImport(), nPrefix, rLName );
+}
+
+void ScXMLNamedRangeContext::EndElement()
+{
+}
+
+ScXMLNamedExpressionContext::ScXMLNamedExpressionContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+ ScMyNamedExpression* pNamedExpression(new ScMyNamedExpression);
+ const formula::FormulaGrammar::Grammar eStorageGrammar = pNamedExpression->eGrammar =
+ GetScImport().GetDocument()->GetStorageGrammar();
+ sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
+ const SvXMLTokenMap& rAttrTokenMap(GetScImport().GetNamedExpressionAttrTokenMap());
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ USHORT nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName ));
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_NAMED_EXPRESSION_ATTR_NAME :
+ {
+ pNamedExpression->sName = sValue;
+ }
+ break;
+ case XML_TOK_NAMED_EXPRESSION_ATTR_EXPRESSION :
+ {
+ rtl::OUString sFormula;
+ sal_uInt16 nFormulaPrefix = GetImport().GetNamespaceMap().
+ _GetKeyByAttrName( sValue, &sFormula, sal_False );
+
+ if (ScXMLImport::IsAcceptedFormulaNamespace( nFormulaPrefix,
+ sValue, pNamedExpression->eGrammar,
+ eStorageGrammar))
+ pNamedExpression->sContent = sFormula;
+ else
+ pNamedExpression->sContent = sValue;
+ }
+ break;
+ case XML_TOK_NAMED_EXPRESSION_ATTR_BASE_CELL_ADDRESS :
+ {
+ pNamedExpression->sBaseCellAddress = sValue;
+ }
+ break;
+ }
+ }
+ pNamedExpression->bIsExpression = sal_True;
+ GetScImport().AddNamedExpression(pNamedExpression);
+}
+
+ScXMLNamedExpressionContext::~ScXMLNamedExpressionContext()
+{
+}
+
+SvXMLImportContext *ScXMLNamedExpressionContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
+{
+/* const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ }*/
+ return new SvXMLImportContext( GetImport(), nPrefix, rLName );;
+}
+
+void ScXMLNamedExpressionContext::EndElement()
+{
+}
+
diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx index 5911d27376b3..3c21646cc50e 100644 --- a/sc/source/filter/xml/xmlstyli.cxx +++ b/sc/source/filter/xml/xmlstyli.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: xmlstyli.cxx,v $ - * $Revision: 1.63.134.1 $ + * $Revision: 1.63 $ * * This file is part of OpenOffice.org. * @@ -393,7 +393,7 @@ void XMLTableStyleContext::SetFormulas(com::sun::star::uno::Sequence<com::sun::s } void XMLTableStyleContext::SetGrammar(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps, - const ScGrammar::Grammar eGrammar) const + const formula::FormulaGrammar::Grammar eGrammar) const { sal_Int32 nLength(aProps.getLength()); aProps.realloc(nLength + 1); @@ -411,8 +411,8 @@ void XMLTableStyleContext::GetConditionalFormat(uno::Any& aAny, uno::Reference<sheet::XSheetConditionalEntries> xConditionalEntries(aAny, uno::UNO_QUERY); if (xConditionalEntries.is()) { - const ScGrammar::Grammar eStorageGrammar = GetScImport().GetDocument()->GetStorageGrammar(); - ScGrammar::Grammar eGrammar = eStorageGrammar; + const formula::FormulaGrammar::Grammar eStorageGrammar = GetScImport().GetDocument()->GetStorageGrammar(); + formula::FormulaGrammar::Grammar eGrammar = eStorageGrammar; // ToDo: erase all blanks in the condition, but not in formulas or strings rtl::OUString scell_content(RTL_CONSTASCII_USTRINGPARAM("cell_content")); rtl::OUString scell_content_is_between(RTL_CONSTASCII_USTRINGPARAM("cell_content_is_between")); @@ -587,7 +587,6 @@ void XMLTableStyleContext::FillPropertySet( sal_Int32 nNumFmt = GetNumberFormat(); if (nNumFmt >= 0) AddProperty(CTF_SC_NUMBERFORMAT, uno::makeAny(nNumFmt)); - if (!bConditionalFormatCreated && (aMaps.size() > 0)) { aConditionalFormat = rPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CONDXML))); @@ -688,7 +687,6 @@ sal_Int32 XMLTableStyleContext::GetNumberFormat() } return nNumberFormat; } - // ---------------------------------------------------------------------------- SvXMLStyleContext *XMLTableStylesContext::CreateStyleStyleChildContext( @@ -1083,3 +1081,4 @@ void ScMasterPageContext::Finish( sal_Bool bOverwrite ) if (!bContainsRightHeader) ClearContent(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_PAGE_RIGHTHDRCON))); } + diff --git a/sc/source/filter/xml/xmlstyli.hxx b/sc/source/filter/xml/xmlstyli.hxx index 09f931c94cf5..18a42e3185ea 100644 --- a/sc/source/filter/xml/xmlstyli.hxx +++ b/sc/source/filter/xml/xmlstyli.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: xmlstyli.hxx,v $ - * $Revision: 1.29.62.1 $ + * $Revision: 1.29 $ * * This file is part of OpenOffice.org. * @@ -120,7 +120,7 @@ class XMLTableStyleContext : public XMLPropStyleContext void SetFormulas(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps, const rtl::OUString& sFormulas) const; void SetGrammar(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps, - const ScGrammar::Grammar eGrammar) const; + const formula::FormulaGrammar::Grammar eGrammar) const; void GetConditionalFormat( ::com::sun::star::uno::Any& aAny, const rtl::OUString& sCondition, @@ -154,7 +154,7 @@ public: void AddProperty(sal_Int16 nContextID, const com::sun::star::uno::Any& aValue); XMLPropertyState* FindProperty(const sal_Int16 nContextID); - sal_Int32 GetNumberFormat(); + sal_Int32 GetNumberFormat() { return nNumberFormat; } private: using XMLPropStyleContext::SetStyle; @@ -297,3 +297,4 @@ public: }; #endif + diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx index 647067f9fe85..03437449ec61 100644 --- a/sc/source/filter/xml/xmlsubti.cxx +++ b/sc/source/filter/xml/xmlsubti.cxx @@ -540,10 +540,11 @@ void ScMyTables::NewTable(sal_Int32 nTempSpannedCols) ScMyTableData* aTable(new ScMyTableData(nCurrentSheet)); if (nTableCount > 1) { - sal_Int32 nCol(aTableVec[nTableCount - 2]->GetColumn()); - sal_Int32 nColCount(aTableVec[nTableCount - 2]->GetColCount()); - sal_Int32 nColsPerCol(aTableVec[nTableCount - 2]->GetColsPerCol(nCol)); - sal_Int32 nSpannedCols(aTableVec[nTableCount - 2]->GetSpannedCols()); + ScMyTableData* pTableData = aTableVec[nTableCount - 2]; + const sal_Int32 nCol(pTableData->GetColumn()); + const sal_Int32 nColCount(pTableData->GetColCount()); + const sal_Int32 nColsPerCol(pTableData->GetColsPerCol(nCol)); + sal_Int32 nSpannedCols(pTableData->GetSpannedCols()); sal_Int32 nTemp(nSpannedCols - nColCount); sal_Int32 nTemp2(nCol - (nColCount - 1)); if ((nTemp > 0) && (nTemp2 == 0)) @@ -554,9 +555,9 @@ void ScMyTables::NewTable(sal_Int32 nTempSpannedCols) sal_Int32 nToMerge; if (nSpannedCols > nColCount) - nToMerge = aTableVec[nTableCount - 2]->GetChangedCols(nCol, nCol + nColsPerCol + nSpannedCols - nColCount); + nToMerge = pTableData->GetChangedCols(nCol, nCol + nColsPerCol + nSpannedCols - nColCount); else - nToMerge = aTableVec[nTableCount - 2]->GetChangedCols(nCol, nCol + nColsPerCol); + nToMerge = pTableData->GetChangedCols(nCol, nCol + nColsPerCol); if (nToMerge > nCol) nTempSpannedCols += nToMerge; } @@ -654,10 +655,11 @@ table::CellAddress ScMyTables::GetRealCellPos() { sal_Int32 nRow(0); sal_Int32 nCol(0); - for (sal_Int32 i = 1; i <= nTableCount; ++i) + for (sal_Int32 i = 0; i < nTableCount; ++i) { - nCol += aTableVec[i - 1]->GetRealCols(aTableVec[i - 1]->GetColumn()); - nRow += aTableVec[i - 1]->GetRealRows(aTableVec[i - 1]->GetRow()); + ScMyTableData* pTableData = aTableVec[i]; + nCol += pTableData->GetRealCols(pTableData->GetColumn()); + nRow += pTableData->GetRealRows(pTableData->GetRow()); } aRealCellPos.Row = nRow; aRealCellPos.Column = nCol; @@ -721,7 +723,7 @@ void ScMyTables::AddShape(uno::Reference <drawing::XShape>& rShape, aResizeShapes.AddShape(rShape, pRangeList, rStartAddress, rEndAddress, nEndX, nEndY); } -void ScMyTables::AddMatrixRange(sal_Int32 nStartColumn, sal_Int32 nStartRow, sal_Int32 nEndColumn, sal_Int32 nEndRow, const rtl::OUString& rFormula, const ScGrammar::Grammar eGrammar) +void ScMyTables::AddMatrixRange(sal_Int32 nStartColumn, sal_Int32 nStartRow, sal_Int32 nEndColumn, sal_Int32 nEndRow, const rtl::OUString& rFormula, const formula::FormulaGrammar::Grammar eGrammar) { DBG_ASSERT(nEndRow >= nStartRow, "wrong row order"); DBG_ASSERT(nEndColumn >= nStartColumn, "wrong column order"); @@ -769,7 +771,7 @@ sal_Bool ScMyTables::IsPartOfMatrix(sal_Int32 nColumn, sal_Int32 nRow) return bResult; } -void ScMyTables::SetMatrix(const table::CellRangeAddress& rRange, const rtl::OUString& rFormula, const ScGrammar::Grammar eGrammar) +void ScMyTables::SetMatrix(const table::CellRangeAddress& rRange, const rtl::OUString& rFormula, const formula::FormulaGrammar::Grammar eGrammar) { uno::Reference <table::XCellRange> xMatrixCellRange( GetCurrentXCellRange()->getCellRangeByPosition(rRange.StartColumn, rRange.StartRow, diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx index fae1d22922d1..84a07ff90449 100644 --- a/sc/source/filter/xml/xmlsubti.hxx +++ b/sc/source/filter/xml/xmlsubti.hxx @@ -42,7 +42,7 @@ #include <vector> #include <list> #include "XMLTableShapeResizer.hxx" -#include "grammar.hxx" +#include "formula/grammar.hxx" class ScXMLImport; @@ -97,9 +97,9 @@ public: struct ScMatrixRange { rtl::OUString sFormula; - ScGrammar::Grammar eGrammar; + formula::FormulaGrammar::Grammar eGrammar; com::sun::star::table::CellRangeAddress aRange; - ScMatrixRange(const com::sun::star::table::CellRangeAddress& rRange, const rtl::OUString& rFormula, const ScGrammar::Grammar eGrammarP) : + ScMatrixRange(const com::sun::star::table::CellRangeAddress& rRange, const rtl::OUString& rFormula, const formula::FormulaGrammar::Grammar eGrammarP) : sFormula(rFormula), eGrammar(eGrammarP), aRange(rRange) @@ -181,12 +181,12 @@ public: sal_Int32 nEndColumn, sal_Int32 nEndRow, const rtl::OUString& rFormula, - const ScGrammar::Grammar ); + const formula::FormulaGrammar::Grammar ); sal_Bool IsPartOfMatrix(sal_Int32 nColumn, sal_Int32 nRow); void SetMatrix( const com::sun::star::table::CellRangeAddress& rRange, const rtl::OUString& rFormula, - const ScGrammar::Grammar ); + const formula::FormulaGrammar::Grammar ); }; #endif diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 6381c9150b44..8d1cd4179516 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -162,7 +162,7 @@ handle_r1c1: if( nPos < nLen && nPos > 0 && '-' == pChar[nPos] && '[' == pChar[nPos-1] && NULL != pDoc && - ScAddress::CONV_XL_R1C1 == pDoc->GetAddressConvention() ) + formula::FormulaGrammar::CONV_XL_R1C1 == pDoc->GetAddressConvention() ) { nPos++; goto handle_r1c1; @@ -3384,7 +3384,7 @@ void ScInputHandler::NotifyChange( const ScInputHdlState* pState, if ( !aPosStr.Len() ) // kein Name -> formatieren { USHORT nFlags = 0; - if( aAddrDetails.eConv == ScAddress::CONV_XL_R1C1 ) + if( aAddrDetails.eConv == formula::FormulaGrammar::CONV_XL_R1C1 ) nFlags |= SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE; if ( rSPos != rEPos ) { diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index e1ec599e8fbe..8fd3c1f8ac0b 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -70,7 +70,7 @@ #include "docsh.hxx" #include "appoptio.hxx" #include "rangenam.hxx" -#include "compiler.hrc" +#include <formula/compiler.hrc> #include "dbcolect.hxx" #include "rangeutl.hxx" #include "docfunc.hxx" @@ -1539,7 +1539,7 @@ ScNameInputType lcl_GetInputType( const String& rText ) ScViewData* pViewData = pViewSh->GetViewData(); ScDocument* pDoc = pViewData->GetDocument(); SCTAB nTab = pViewData->GetTabNo(); - ScAddress::Convention eConv = pDoc->GetAddressConvention(); + formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention(); // test in same order as in SID_CURRENTCELL execute diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 60f2ae2729ad..98885067c5b0 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -52,6 +52,8 @@ #include <sfx2/objface.hxx> #include <svx/hyprlink.hxx> +#include "IAnyRefDialog.hxx" + #include <svtools/ehdl.hxx> #include <svtools/accessibilityoptions.hxx> #include <svtools/ctloptions.hxx> @@ -1687,7 +1689,7 @@ BOOL ScModule::IsModalMode(SfxObjectShell* pDocSh) SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId ); if ( pChildWnd ) { - ScAnyRefDlg* pRefDlg = (ScAnyRefDlg*)pChildWnd->GetWindow(); + IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow()); bIsModal = pChildWnd->IsVisible() && !( pRefDlg->IsRefInputMode() && pRefDlg->IsDocAllowed(pDocSh) ); } @@ -1725,7 +1727,7 @@ BOOL ScModule::IsTableLocked() { SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId ); if ( pChildWnd ) - bLocked = ((ScAnyRefDlg*)pChildWnd->GetWindow())->IsTableLocked(); + bLocked = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow())->IsTableLocked(); else bLocked = TRUE; // for other views, see IsModalMode } @@ -1764,7 +1766,7 @@ BOOL ScModule::IsFormulaMode() SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId ); if ( pChildWnd ) { - ScAnyRefDlg* pRefDlg = (ScAnyRefDlg*)pChildWnd->GetWindow(); + IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow()); bIsFormula = pChildWnd->IsVisible() && pRefDlg->IsRefInputMode(); } } @@ -1824,7 +1826,7 @@ void ScModule::SetReference( const ScRange& rRef, ScDocument* pDoc, aNew.aEnd.SetTab(nEndTab); } - ScAnyRefDlg* pRefDlg = (ScAnyRefDlg*)pChildWnd->GetWindow(); + IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow()); // hide the (color) selection now instead of later from LoseFocus, // don't abort the ref input that causes this call (bDoneRefMode = FALSE) @@ -1855,7 +1857,7 @@ void ScModule::AddRefEntry() // "Mehrfachselektion" DBG_ASSERT( pChildWnd, "NoChildWin" ); if ( pChildWnd ) { - ScAnyRefDlg* pRefDlg = (ScAnyRefDlg*)pChildWnd->GetWindow(); + IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow()); pRefDlg->AddRefEntry(); } } @@ -1882,7 +1884,7 @@ void ScModule::EndReference() DBG_ASSERT( pChildWnd, "NoChildWin" ); if ( pChildWnd ) { - ScAnyRefDlg* pRefDlg = (ScAnyRefDlg*)pChildWnd->GetWindow(); + IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow()); pRefDlg->SetActive(); } } diff --git a/sc/source/ui/attrdlg/condfrmt.cxx b/sc/source/ui/attrdlg/condfrmt.cxx index b9ffd5a55242..e97b13405af0 100644 --- a/sc/source/ui/attrdlg/condfrmt.cxx +++ b/sc/source/ui/attrdlg/condfrmt.cxx @@ -66,10 +66,10 @@ ScConditionalFormatDlg::ScConditionalFormatDlg( aLbCond11 ( this, ScResId( LB_COND1_1 ) ), aLbCond12 ( this, ScResId( LB_COND1_2 ) ), aEdtCond11 ( this, ScResId( EDT_COND1_1 ) ), - aRbCond11 ( this, ScResId( RB_COND1_1 ), &aEdtCond11 ), + aRbCond11 ( this, ScResId( RB_COND1_1 ), &aEdtCond11,this ), aFtCond1And ( this, ScResId( FT_COND1_AND ) ), aEdtCond12 ( this, ScResId( EDT_COND1_2 ) ), - aRbCond12 ( this, ScResId( RB_COND1_2 ), &aEdtCond12 ), + aRbCond12 ( this, ScResId( RB_COND1_2 ), &aEdtCond12,this ), aFtCond1Template ( this, ScResId( FT_COND1_TEMPLATE ) ), aLbCond1Template ( this, ScResId( LB_COND1_TEMPLATE ) ), aFlSep1 ( this, ScResId( FL_SEP1 ) ), @@ -78,10 +78,10 @@ ScConditionalFormatDlg::ScConditionalFormatDlg( aLbCond21 ( this, ScResId( LB_COND2_1 ) ), aLbCond22 ( this, ScResId( LB_COND2_2 ) ), aEdtCond21 ( this, ScResId( EDT_COND2_1 ) ), - aRbCond21 ( this, ScResId( RB_COND2_1 ), &aEdtCond21 ), + aRbCond21 ( this, ScResId( RB_COND2_1 ), &aEdtCond21,this ), aFtCond2And ( this, ScResId( FT_COND2_AND ) ), aEdtCond22 ( this, ScResId( EDT_COND2_2 ) ), - aRbCond22 ( this, ScResId( RB_COND2_2 ), &aEdtCond22 ), + aRbCond22 ( this, ScResId( RB_COND2_2 ), &aEdtCond22,this ), aFtCond2Template ( this, ScResId( FT_COND2_TEMPLATE ) ), aLbCond2Template ( this, ScResId( LB_COND2_TEMPLATE ) ), aFlSep2 ( this, ScResId( FL_SEP2 ) ), @@ -90,10 +90,10 @@ ScConditionalFormatDlg::ScConditionalFormatDlg( aLbCond31 ( this, ScResId( LB_COND3_1 ) ), aLbCond32 ( this, ScResId( LB_COND3_2 ) ), aEdtCond31 ( this, ScResId( EDT_COND3_1 ) ), - aRbCond31 ( this, ScResId( RB_COND3_1 ), &aEdtCond31 ), + aRbCond31 ( this, ScResId( RB_COND3_1 ), &aEdtCond31,this ), aFtCond3And ( this, ScResId( FT_COND3_AND ) ), aEdtCond32 ( this, ScResId( EDT_COND3_2 ) ), - aRbCond32 ( this, ScResId( RB_COND3_2 ), &aEdtCond32 ), + aRbCond32 ( this, ScResId( RB_COND3_2 ), &aEdtCond32,this ), aFtCond3Template ( this, ScResId( FT_COND3_TEMPLATE ) ), aLbCond3Template ( this, ScResId( LB_COND3_TEMPLATE ) ), diff --git a/sc/source/ui/dbgui/consdlg.cxx b/sc/source/ui/dbgui/consdlg.cxx index 5d8d6baad874..d0a0ff55a307 100644 --- a/sc/source/ui/dbgui/consdlg.cxx +++ b/sc/source/ui/dbgui/consdlg.cxx @@ -98,12 +98,12 @@ ScConsolidateDlg::ScConsolidateDlg( SfxBindings* pB, SfxChildWindow* pCW, Window aLbDataArea ( this, ScResId( LB_DATA_AREA ) ), aFtDataArea ( this, ScResId( FT_DATA_AREA ) ), aEdDataArea ( this, ScResId( ED_DATA_AREA ) ), - aRbDataArea ( this, ScResId( RB_DATA_AREA ), &aEdDataArea ), + aRbDataArea ( this, ScResId( RB_DATA_AREA ), &aEdDataArea, this ), aLbDestArea ( this, ScResId( LB_DEST_AREA ) ), aFtDestArea ( this, ScResId( FT_DEST_AREA ) ), aEdDestArea ( this, ScResId( ED_DEST_AREA ) ), - aRbDestArea ( this, ScResId( RB_DEST_AREA ), &aEdDestArea ), + aRbDestArea ( this, ScResId( RB_DEST_AREA ), &aEdDestArea, this), aFlConsBy ( this, ScResId( FL_CONSBY ) ), aBtnByRow ( this, ScResId( BTN_BYROW ) ), @@ -192,7 +192,7 @@ void ScConsolidateDlg::Init() // Einlesen der Konsolidierungsbereiche aLbConsAreas.Clear(); - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); + const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention(); for ( i=0; i<theConsData.nDataAreaCount; i++ ) { const ScArea& rArea = *(theConsData.ppDataAreas[i] ); @@ -298,7 +298,7 @@ void ScConsolidateDlg::SetReference( const ScRange& rRef, ScDocument* pDocP ) String aStr; USHORT nFmt = SCR_ABS_3D; //!!! nCurTab fehlt noch - const ScAddress::Convention eConv = pDocP->GetAddressConvention(); + const formula::FormulaGrammar::AddressConvention eConv = pDocP->GetAddressConvention(); if ( rRef.aStart.Tab() != rRef.aEnd.Tab() ) nFmt |= SCA_TAB2_3D; @@ -354,7 +354,7 @@ void __EXPORT ScConsolidateDlg::Deactivate() //---------------------------------------------------------------------------- -BOOL ScConsolidateDlg::VerifyEdit( ScRefEdit* pEd ) +BOOL ScConsolidateDlg::VerifyEdit( formula::RefEdit* pEd ) { if ( !pRangeUtil || !pDoc || !pViewData || ((pEd != &aEdDataArea) && (pEd != &aEdDestArea)) ) @@ -363,7 +363,7 @@ BOOL ScConsolidateDlg::VerifyEdit( ScRefEdit* pEd ) SCTAB nTab = pViewData->GetTabNo(); BOOL bEditOk = FALSE; String theCompleteStr; - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); + const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention(); if ( pEd == &aEdDataArea ) { @@ -395,7 +395,7 @@ IMPL_LINK( ScConsolidateDlg, GetFocusHdl, Control*, pCtr ) if ( pCtr ==(Control*)&aEdDataArea || pCtr ==(Control*)&aEdDestArea) { - pRefInputEdit = (ScRefEdit*)pCtr; + pRefInputEdit = (formula::RefEdit*)pCtr; } else if(pCtr ==(Control*)&aLbDataArea ) { @@ -420,7 +420,7 @@ IMPL_LINK( ScConsolidateDlg, OkHdl, void*, EMPTYARG ) ScRefAddress aDestAddress; SCTAB nTab = pViewData->GetTabNo(); String aDestPosStr( aEdDestArea.GetText() ); - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); + const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention(); if ( pRangeUtil->IsAbsPos( aDestPosStr, pDoc, nTab, NULL, &aDestAddress, eConv ) ) { @@ -484,7 +484,7 @@ IMPL_LINK( ScConsolidateDlg, ClickHdl, PushButton*, pBtn ) String aNewEntry( aEdDataArea.GetText() ); ScArea** ppAreas = NULL; USHORT nAreaCount = 0; - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); + const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention(); if ( pRangeUtil->IsAbsTabArea( aNewEntry, pDoc, &ppAreas, &nAreaCount, TRUE, eConv ) ) { @@ -586,7 +586,7 @@ IMPL_LINK( ScConsolidateDlg, SelectHdl, ListBox*, pLb ) //---------------------------------------------------------------------------- -IMPL_LINK( ScConsolidateDlg, ModifyHdl, ScRefEdit*, pEd ) +IMPL_LINK( ScConsolidateDlg, ModifyHdl, formula::RefEdit*, pEd ) { if ( pEd == &aEdDataArea ) { diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx index d5a8c8aaade6..66f270213ce4 100644 --- a/sc/source/ui/dbgui/dbnamdlg.cxx +++ b/sc/source/ui/dbgui/dbnamdlg.cxx @@ -148,7 +148,7 @@ ScDbNameDlg::ScDbNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, aFlAssign ( this, ScResId( FL_ASSIGN ) ), aEdAssign ( this, ScResId( ED_DBAREA ) ), - aRbAssign ( this, ScResId( RB_DBAREA ), &aEdAssign ), + aRbAssign ( this, ScResId( RB_DBAREA ), &aEdAssign, this ), aFlOptions ( this, ScResId( FL_OPTIONS ) ), aBtnHeader ( this, ScResId( BTN_HEADER ) ), diff --git a/sc/source/ui/dbgui/foptmgr.cxx b/sc/source/ui/dbgui/foptmgr.cxx index 44c4f14de22d..603a9a3a5eea 100644 --- a/sc/source/ui/dbgui/foptmgr.cxx +++ b/sc/source/ui/dbgui/foptmgr.cxx @@ -65,7 +65,7 @@ ScFilterOptionsMgr::ScFilterOptionsMgr( CheckBox& refBtnDestPers, ListBox& refLbCopyArea, Edit& refEdCopyArea, - ScRefButton& refRbCopyArea, + formula::RefButton& refRbCopyArea, FixedText& refFtDbAreaLabel, FixedInfo& refFtDbArea, FixedLine& refFlOptions, @@ -148,7 +148,7 @@ void ScFilterOptionsMgr::Init() ScDBCollection* pDBColl = pDoc->GetDBCollection(); String theDbArea; String theDbName = rStrNoName; - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); + const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention(); theCurArea.Format( theAreaStr, SCR_ABS_3D, pDoc, eConv ); diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx index 5a0321935fe0..fba9846e331f 100644 --- a/sc/source/ui/dbgui/pvlaydlg.cxx +++ b/sc/source/ui/dbgui/pvlaydlg.cxx @@ -123,7 +123,7 @@ ScDPLayoutDlg::ScDPLayoutDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pPar aLbOutPos ( this, ScResId( LB_OUTAREA ) ), aFtOutArea ( this, ScResId( FT_OUTAREA ) ), aEdOutPos ( this, ScResId( ED_OUTAREA ) ), - aRbOutPos ( this, ScResId( RB_OUTAREA ), &aEdOutPos ), + aRbOutPos ( this, ScResId( RB_OUTAREA ), &aEdOutPos, this ), aBtnIgnEmptyRows( this, ScResId( BTN_IGNEMPTYROWS ) ), aBtnDetectCat ( this, ScResId( BTN_DETECTCAT ) ), aBtnTotalCol ( this, ScResId( BTN_TOTALCOL ) ), diff --git a/sc/source/ui/dbgui/sfiltdlg.cxx b/sc/source/ui/dbgui/sfiltdlg.cxx index cba8a0b28c85..dbff3c6dabab 100644 --- a/sc/source/ui/dbgui/sfiltdlg.cxx +++ b/sc/source/ui/dbgui/sfiltdlg.cxx @@ -76,7 +76,7 @@ ScSpecialFilterDlg::ScSpecialFilterDlg( SfxBindings* pB, SfxChildWindow* pCW, Wi aLbFilterArea ( this, ScResId( LB_CRITERIA_AREA ) ), aFtFilterArea ( this, ScResId( FT_CRITERIA_AREA ) ), aEdFilterArea ( this, ScResId( ED_CRITERIA_AREA ) ), - aRbFilterArea ( this, ScResId( RB_CRITERIA_AREA ), &aEdFilterArea ), + aRbFilterArea ( this, ScResId( RB_CRITERIA_AREA ), &aEdFilterArea, this ), // _INIT_COMMON_FILTER_RSCOBJS // @@ -249,7 +249,7 @@ void ScSpecialFilterDlg::SetReference( const ScRange& rRef, ScDocument* pDocP ) RefInputStart( pRefInputEdit ); String aRefStr; - const ScAddress::Convention eConv = pDocP->GetAddressConvention(); + const formula::FormulaGrammar::AddressConvention eConv = pDocP->GetAddressConvention(); if ( pRefInputEdit == &aEdCopyArea) rRef.aStart.Format( aRefStr, SCA_ABS_3D, pDocP, eConv ); @@ -324,7 +324,7 @@ IMPL_LINK( ScSpecialFilterDlg, EndDlgHdl, Button*, pBtn ) BOOL bEditInputOk = TRUE; BOOL bQueryOk = FALSE; ScRange theFilterArea; - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); + const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention(); if ( aBtnCopyResult.IsChecked() ) { @@ -490,7 +490,7 @@ IMPL_LINK( ScSpecialFilterDlg, FilterAreaSelHdl, ListBox*, pLb ) //---------------------------------------------------------------------------- -IMPL_LINK( ScSpecialFilterDlg, FilterAreaModHdl, ScRefEdit*, pEd ) +IMPL_LINK( ScSpecialFilterDlg, FilterAreaModHdl, formula::RefEdit*, pEd ) { if ( pEd == &aEdFilterArea ) { diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx index 080e2a2ccb05..a5b42fc9f364 100644 --- a/sc/source/ui/dbgui/tpsort.cxx +++ b/sc/source/ui/dbgui/tpsort.cxx @@ -636,7 +636,7 @@ void ScTabPageSortOptions::Init() String theDbArea; String theDbName = aStrNoName; const SCTAB nCurTab = pViewData->GetTabNo(); - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); + const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention(); aLbOutPos.Clear(); aLbOutPos.InsertEntry( aStrUndefined, 0 ); diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx index d547bae25de9..8700c936e0f5 100644 --- a/sc/source/ui/dbgui/validate.cxx +++ b/sc/source/ui/dbgui/validate.cxx @@ -52,7 +52,7 @@ #include "validate.hrc" #include "validate.hxx" #include "compiler.hxx" -#include "opcode.hxx" //CHINA001 +#include "formula/opcode.hxx" //CHINA001 // ============================================================================ diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 4208014ee491..6e9010d7856b 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -957,7 +957,7 @@ ScTokenArray* lcl_ScDocFunc_CreateTokenArrayXML( const String& rText ) ScBaseCell* ScDocFunc::InterpretEnglishString( const ScAddress& rPos, - const String& rText, const ScGrammar::Grammar eGrammar ) + const String& rText, const formula::FormulaGrammar::Grammar eGrammar ) { ScDocument* pDoc = rDocShell.GetDocument(); ScBaseCell* pNewCell = NULL; @@ -972,7 +972,8 @@ ScBaseCell* ScDocFunc::InterpretEnglishString( const ScAddress& rPos, } else { - ScCompiler aComp( pDoc, rPos, eGrammar ); + ScCompiler aComp( pDoc, rPos ); + aComp.SetGrammar(eGrammar); pCode = aComp.CompileString( rText ); } pNewCell = new ScFormulaCell( pDoc, rPos, pCode, eGrammar, MM_NONE ); @@ -1004,7 +1005,7 @@ ScBaseCell* ScDocFunc::InterpretEnglishString( const ScAddress& rPos, BOOL ScDocFunc::SetCellText( const ScAddress& rPos, const String& rText, BOOL bInterpret, BOOL bEnglish, BOOL bApi, - const ScGrammar::Grammar eGrammar ) + const formula::FormulaGrammar::Grammar eGrammar ) { // SetCellText ruft PutCell oder SetNormalString @@ -2411,7 +2412,7 @@ BOOL ScDocFunc::SetLayoutRTL( SCTAB nTab, BOOL bRTL, BOOL /* bApi */ ) return TRUE; } -BOOL ScDocFunc::SetGrammar( ScGrammar::Grammar eGrammar ) +BOOL ScDocFunc::SetGrammar( formula::FormulaGrammar::Grammar eGrammar ) { ScDocument* pDoc = rDocShell.GetDocument(); @@ -3115,7 +3116,7 @@ BOOL ScDocFunc::AutoFormat( const ScRange& rRange, const ScMarkData* pTabMark, BOOL ScDocFunc::EnterMatrix( const ScRange& rRange, const ScMarkData* pTabMark, const ScTokenArray* pTokenArray, const String& rString, BOOL bApi, BOOL bEnglish, - const ScGrammar::Grammar eGrammar ) + const formula::FormulaGrammar::Grammar eGrammar ) { ScDocShellModificator aModificator( rDocShell ); @@ -3170,7 +3171,8 @@ BOOL ScDocFunc::EnterMatrix( const ScRange& rRange, const ScMarkData* pTabMark, } else if (bEnglish) { - ScCompiler aComp( pDoc, rRange.aStart, eGrammar); + ScCompiler aComp( pDoc, rRange.aStart); + aComp.SetGrammar(eGrammar); ScTokenArray* pCode = aComp.CompileString( rString ); pDoc->InsertMatrixFormula( nStartCol, nStartRow, nEndCol, nEndRow, aMark, EMPTY_STRING, pCode, eGrammar); @@ -4039,7 +4041,7 @@ BOOL ScDocFunc::InsertNameList( const ScAddress& rStartPos, BOOL bApi ) ICCQsortNameCompare ); #endif String aName; - String aContent; + rtl::OUStringBuffer aContent; String aFormula; SCROW nOutRow = nStartRow; for (j=0; j<nValidCount; j++) @@ -4114,11 +4116,11 @@ BOOL ScDocFunc::ResizeMatrix( const ScRange& rOldRange, const ScAddress& rNewEnd if ( DeleteContents( aMark, IDF_CONTENTS, TRUE, bApi ) ) { // GRAM_PODF_A1 for API compatibility. - bRet = EnterMatrix( aNewRange, &aMark, NULL, aFormula, bApi, FALSE, ScGrammar::GRAM_PODF_A1 ); + bRet = EnterMatrix( aNewRange, &aMark, NULL, aFormula, bApi, FALSE,formula::FormulaGrammar::GRAM_PODF_A1 ); if (!bRet) { // versuchen, alten Zustand wiederherzustellen - EnterMatrix( rOldRange, &aMark, NULL, aFormula, bApi, FALSE, ScGrammar::GRAM_PODF_A1 ); + EnterMatrix( rOldRange, &aMark, NULL, aFormula, bApi, FALSE,formula::FormulaGrammar::GRAM_PODF_A1 ); } } diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index 2a627bc2d047..786e99921b63 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -1042,7 +1042,7 @@ void ScDocShell::MergeDocument( ScDocument& rOtherDoc, bool bShared, bool bCheck aValue.Erase( aValue.Len()-1, 1 ); GetDocFunc().EnterMatrix( aSourceRange, NULL, NULL, aValue, FALSE, FALSE, - ScGrammar::GRAM_DEFAULT ); + formula::FormulaGrammar::GRAM_DEFAULT ); } break; case MM_REFERENCE : // do nothing diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index a7709367a659..3da74feae40e 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -2474,7 +2474,7 @@ long __EXPORT ScDocShell::DdeSetData( const String& rItem, } } ScRange aRange; - ScAddress::Convention eConv = aDocument.GetAddressConvention(); + formula::FormulaGrammar::AddressConvention eConv = aDocument.GetAddressConvention(); BOOL bValid = ( ( aRange.Parse( aPos, &aDocument, eConv ) & SCA_VALID ) || ( aRange.aStart.Parse( aPos, &aDocument, eConv ) & SCA_VALID ) ); diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 5b580796458c..ca8204203f18 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -1416,7 +1416,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokens(sal_u { case svSingleRef: { - const SingleRefData& rRef = pToken->GetSingleRef(); + const ScSingleRefData& rRef = pToken->GetSingleRef(); String aTabName; pSrcDoc->GetName(rRef.nTab, aTabName); ScExternalSingleRefToken aNewToken(nFileId, aTabName, pToken->GetSingleRef()); @@ -1426,7 +1426,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokens(sal_u break; case svDoubleRef: { - const SingleRefData& rRef = pToken->GetSingleRef(); + const ScSingleRefData& rRef = pToken->GetSingleRef(); String aTabName; pSrcDoc->GetName(rRef.nTab, aTabName); ScExternalDoubleRefToken aNewToken(nFileId, aTabName, pToken->GetDoubleRef()); diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index c463533a1924..10f39e7d8676 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -172,7 +172,7 @@ ScImportExport::ScImportExport( ScDocument* p, const String& rPos ) pData->GetSymbol( aPos ); // mit dem Inhalt weitertesten } } - ScAddress::Convention eConv = pDoc->GetAddressConvention(); + formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention(); // Bereich? if( aRange.Parse( aPos, pDoc, eConv ) & SCA_VALID ) bSingle = FALSE; @@ -1479,8 +1479,9 @@ BOOL ScImportExport::Sylk2Doc( SvStream& rStrm ) /* FIXME: do we want GRAM_ODFF_A1 instead? At the * end it probably should be GRAM_ODFF_R1C1, since * R1C1 is what Excel writes in SYLK. */ - const ScGrammar::Grammar eGrammar = ScGrammar::GRAM_PODF_A1; - ScCompiler aComp( pDoc, aPos, eGrammar ); + const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_PODF_A1; + ScCompiler aComp( pDoc, aPos); + aComp.SetGrammar(eGrammar); ScTokenArray* pCode = aComp.CompileString( aText ); if ( ch == 'M' ) { @@ -1680,7 +1681,7 @@ BOOL ScImportExport::Doc2Sylk( SvStream& rStrm ) aCellStr.Erase(); break; default: - pFCell->GetFormula( aCellStr, ScGrammar::GRAM_PODF_A1); + pFCell->GetFormula( aCellStr,formula::FormulaGrammar::GRAM_PODF_A1); /* FIXME: do we want GRAM_ODFF_A1 instead? At * the end it probably should be * GRAM_ODFF_R1C1, since R1C1 is what Excel diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx index 9a06e945dbd6..9f7c201c8aca 100644 --- a/sc/source/ui/docshell/tablink.cxx +++ b/sc/source/ui/docshell/tablink.cxx @@ -64,7 +64,7 @@ #include "hints.hxx" #include "cell.hxx" #include "dociter.hxx" -#include "opcode.hxx" +#include "formula/opcode.hxx" struct TableLink_Impl { diff --git a/sc/source/ui/formdlg/dwfunctr.cxx b/sc/source/ui/formdlg/dwfunctr.cxx index 9a713fe09d52..787932f59c53 100644 --- a/sc/source/ui/formdlg/dwfunctr.cxx +++ b/sc/source/ui/formdlg/dwfunctr.cxx @@ -1,1185 +1,1185 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: dwfunctr.cxx,v $ - * $Revision: 1.15 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - - - -// INCLUDE --------------------------------------------------------------- - -#include <svx/editview.hxx> -#include <sfx2/bindings.hxx> -#include <sfx2/dispatch.hxx> -#include <sfx2/objsh.hxx> -#include <sfx2/viewsh.hxx> - -#include "sc.hrc" -#include "global.hxx" // ScAddress -#include "scresid.hxx" -#include "reffact.hxx" -#include "document.hxx" -#include "cell.hxx" -#include "scmod.hxx" -#include "inputhdl.hxx" -#include "tabvwsh.hxx" -#include "appoptio.hxx" -#include "compiler.hxx" - -#include "dwfunctr.hrc" -#include "dwfunctr.hxx" - -// ----------------------------------------------------------------------- - -#define ARG_SEPERATOR String("; ") -SFX_IMPL_DOCKINGWINDOW( ScFunctionChildWindow, FID_FUNCTION_BOX ) - -/************************************************************************* -#* Member: ScFunctionChildWindow Datum:06.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionChildWindow -#* -#* Funktion: Konstruktor der Klasse ScFunctionChildWindow -#* Ableitung vom SfxChildWindow als "Behaelter" fuer -#* Funktions- Fenster in Clac -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -__EXPORT ScFunctionChildWindow::ScFunctionChildWindow( Window* pParentP, - USHORT nId, - SfxBindings* pBindings, - SfxChildWinInfo* pInfo ) : - SfxChildWindow( pParentP, nId ) -{ - ScFunctionDockWin* pWin = new ScFunctionDockWin( pBindings, this, - pParentP, ScResId( FID_FUNCTION_BOX ) ); - pWindow = pWin; - - eChildAlignment = SFX_ALIGN_RIGHT; - - pWin->Initialize( pInfo ); -} - -/************************************************************************* -#* Member: ScFunctionDockWin Datum:06.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Konstruktor der Klasse ScFunctionDockWin -#* -#* Input: Sfx- Verknuepfungen, Fenster, Resource -#* -#* Output: --- -#* -#************************************************************************/ - -ScFunctionDockWin::ScFunctionDockWin( SfxBindings* pBindingsP, - SfxChildWindow *pCW, Window* pParent, const ResId& rResId ) : - - SfxDockingWindow( pBindingsP, pCW, pParent, rResId ), - aPrivatSplit ( this, ResId( FT_SPLIT, *rResId.GetResMgr() ),SC_SPLIT_VERT), - aCatBox ( this, ResId( CB_CAT, *rResId.GetResMgr() ) ), - aFuncList ( this, ResId( LB_FUNC, *rResId.GetResMgr() ) ), - aDDFuncList ( this, ResId( DDLB_FUNC, *rResId.GetResMgr() ) ), - aInsertButton ( this, ResId( IMB_INSERT, *rResId.GetResMgr() ) ), - aFiFuncDesc ( this, ResId( FI_FUNCDESC, *rResId.GetResMgr() ) ), - aOldSize (0,0) -{ - FreeResource(); - InitLRUList(); - SetStyle(GetStyle()|WB_CLIPCHILDREN); - - aTimer.SetTimeout(200); - aTimer.SetTimeoutHdl(LINK( this, ScFunctionDockWin, TimerHdl)); - - eSfxNewAlignment=GetAlignment(); - eSfxOldAlignment=eSfxNewAlignment; - aFiFuncDesc.SetUpdateMode(TRUE); - pAllFuncList=&aFuncList; - aDDFuncList.Disable(); - aDDFuncList.Hide(); - nArgs=0; - nDockMode=0; - bSizeFlag=FALSE; - aCatBox.SetDropDownLineCount(9); - Font aFont=aFiFuncDesc.GetFont(); - aFont.SetColor(Color(COL_BLACK)); - aFiFuncDesc.SetFont(aFont); - aFiFuncDesc.SetBackground( GetBackground() ); //! never transparent? -//? SetBackground(); - - Link aLink=LINK( this, ScFunctionDockWin, SelHdl); - aCatBox.SetSelectHdl(aLink); - aFuncList.SetSelectHdl(aLink); - aDDFuncList.SetSelectHdl(aLink); - - Link a2Link=LINK( this, ScFunctionDockWin, SetSelectionHdl); - aFuncList.SetDoubleClickHdl(a2Link); - aDDFuncList.SetSelectHdl(aLink); - aInsertButton.SetClickHdl(a2Link); - - Link a3Link=LINK( this, ScFunctionDockWin, SetSplitHdl); - aPrivatSplit.SetCtrModifiedHdl(a3Link); - StartListening( *pBindingsP, TRUE ); - - Point aTopLeft=aCatBox.GetPosPixel(); - //String aString=aCatBox.GetEntry( 0)+String("www"); - String aString=String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww")); - Size aTxtSize( aFiFuncDesc.GetTextWidth(aString), aFiFuncDesc.GetTextHeight() ); - nMinWidth=aTxtSize.Width()+aTopLeft.X() - +2*aFuncList.GetPosPixel().X(); - nMinHeight=19*aTxtSize.Height(); - aCatBox.SelectEntryPos(0); - - Range aYRange(3*aTxtSize.Height()+aFuncList.GetPosPixel().Y(), - GetOutputSizePixel().Height()-2*aTxtSize.Height()); - aPrivatSplit.SetYRange(aYRange); - SelHdl(&aCatBox); - bInit=TRUE; -} - -/************************************************************************* -#* Member: ScFunctionDockWin Datum:06.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Destruktor der Klasse ScFunctionDockWin -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -__EXPORT ScFunctionDockWin::~ScFunctionDockWin() -{ - EndListening( GetBindings() ); -} - -/************************************************************************* -#* Member: UpdateFunctionList Datum:06.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Aktualisiert die Liste der Funktionen ab- -#* haengig von der eingestellten Kategorie. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -void ScFunctionDockWin::InitLRUList() -{ - const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions(); - USHORT nLRUFuncCount = Min( rAppOpt.GetLRUFuncListCount(), (USHORT)LRU_MAX ); - USHORT* pLRUListIds = rAppOpt.GetLRUFuncList(); - - USHORT i; - for ( i=0; i<LRU_MAX; i++ ) - aLRUList[i] = NULL; - - if ( pLRUListIds ) - { - ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); - for ( i=0; i<nLRUFuncCount; i++ ) - aLRUList[i] = pFuncMgr->Get( pLRUListIds[i] ); - } - - USHORT nSelPos = aCatBox.GetSelectEntryPos(); - - if(nSelPos == 0) - UpdateFunctionList(); -} - -/************************************************************************* -#* Member: UpdateFunctionList Datum:10.12.99 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Aktualisiert die Liste der zuletzt verwendeten Funktionen. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -void ScFunctionDockWin::UpdateLRUList() -{ - if (pFuncDesc && pFuncDesc->nFIndex!=0) - { - ScModule* pScMod = SC_MOD(); - pScMod->InsertEntryToLRUList(pFuncDesc->nFIndex); - } -} - - -/************************************************************************* -#* Member: SetSize Datum:06.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Groesse fuer die einzelnen Controls einzustellen. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -void ScFunctionDockWin::SetSize() -{ - USHORT nSelEntry=0; - SfxChildAlignment aChildAlign=eSfxOldAlignment;//GetAlignment(); - short nNewDockMode; - switch(aChildAlign) - { - case SFX_ALIGN_HIGHESTTOP: - case SFX_ALIGN_TOP: - case SFX_ALIGN_LOWESTTOP: - case SFX_ALIGN_LOWESTBOTTOM: - case SFX_ALIGN_BOTTOM: - case SFX_ALIGN_TOOLBOXTOP: - case SFX_ALIGN_TOOLBOXBOTTOM: - - - nNewDockMode=1; - if(nDockMode!=nNewDockMode) - { - nDockMode=nNewDockMode; - nSelEntry=aFuncList.GetSelectEntryPos(); - aFuncList.Clear(); - aFiFuncDesc.SetPosPixel(aFuncList.GetPosPixel()); - aDDFuncList.Enable(); - aDDFuncList.Show(); - aPrivatSplit.Disable(); - aPrivatSplit.Hide(); - aFuncList.Disable(); - aFuncList.Hide(); - pAllFuncList=&aDDFuncList; - SelHdl(&aCatBox); - aDDFuncList.SelectEntryPos(nSelEntry); - } - break; - - default: nNewDockMode=0; - if(nDockMode!=nNewDockMode) - { - nDockMode=nNewDockMode; - nSelEntry=aDDFuncList.GetSelectEntryPos(); - aDDFuncList.Clear(); - aDDFuncList.Disable(); - aDDFuncList.Hide(); - aPrivatSplit.Enable(); - aPrivatSplit.Show(); - aFuncList.Enable(); - aFuncList.Show(); - pAllFuncList=&aFuncList; - SelHdl(&aCatBox); - aFuncList.SelectEntryPos(nSelEntry); - } - break; - } - - if(nDockMode==0) - { - SetLeftRightSize(); - } - else - { - SetTopBottonSize(); - } -} -/************************************************************************* -#* Member: SetLeftRightSize Datum:15.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Groesse fuer die einzelnen Controls einstellen, -#* wenn Links oder Rechts angedockt wird. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -void ScFunctionDockWin::SetLeftRightSize() -{ - if(bSizeFlag==FALSE) - { - bSizeFlag=TRUE; - - Size aDiffSize=GetSizePixel(); - Size aNewSize=GetOutputSizePixel(); - aDiffSize.Width()-=aNewSize.Width(); - aDiffSize.Height()-=aNewSize.Height(); - - //@ SetUpdateMode( FALSE); - - String aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww")); - - Size aTxtSize( aFuncList.GetTextWidth(aString), aFuncList.GetTextHeight() ); - - Range aYRange(3*aTxtSize.Height()+aFuncList.GetPosPixel().Y(), - GetOutputSizePixel().Height()-2*aTxtSize.Height()); - aPrivatSplit.SetYRange(aYRange); - - - if(aOldSize.Width()!=aNewSize.Width()) - SetMyWidthLeRi(aNewSize); - - if(aOldSize.Height()!=aNewSize.Height()) - SetMyHeightLeRi(aNewSize); - - aOldSize=aNewSize; - aNewSize.Width()+=aDiffSize.Width(); - aNewSize.Height()+=aDiffSize.Height(); - //SetSizePixel(aNewSize); - //@ SetUpdateMode( TRUE); - bSizeFlag=FALSE; - } - -} -/************************************************************************* -#* Member: SetTopBottonSize Datum:15.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Groesse fuer die einzelnen Controls einzustellen. -#* wenn oben oder unten angedockt wird. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -void ScFunctionDockWin::SetTopBottonSize() -{ - if(bSizeFlag==FALSE) - { - bSizeFlag=TRUE; - Size aDiffSize=GetSizePixel(); - Size aNewSize=GetOutputSizePixel(); - aDiffSize.Width()-=aNewSize.Width(); - aDiffSize.Height()-=aNewSize.Height(); - - SetMyWidthToBo(aNewSize); - SetMyHeightToBo(aNewSize); - - aNewSize.Width()+=aDiffSize.Width(); - aNewSize.Height()+=aDiffSize.Height(); - //SetSizePixel(aNewSize); - //@ SetUpdateMode( TRUE); - bSizeFlag=FALSE; - } -} - -/************************************************************************* -#* Member: SetMyWidthLeRi Datum:15.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Breite fuer die einzelnen Controls und -#* das Fenster einstellen,wenn Li oder Re -#* -#* Input: neue Fenstergroesse -#* -#* Output: --- -#* -#************************************************************************/ - -void ScFunctionDockWin::SetMyWidthLeRi(Size &aNewSize) -{ - if((ULONG)aNewSize.Width()<nMinWidth) aNewSize.Width()=nMinWidth; - - Size aCDSize=aCatBox.GetSizePixel(); - Size aFLSize=aFuncList.GetSizePixel(); - Size aSplitterSize=aPrivatSplit.GetSizePixel(); - Size aFDSize=aFiFuncDesc.GetSizePixel(); - - Point aCDTopLeft=aCatBox.GetPosPixel(); - Point aFLTopLeft=aFuncList.GetPosPixel(); - Point aSplitterTopLeft=aPrivatSplit.GetPosPixel(); - Point aFDTopLeft=aFiFuncDesc.GetPosPixel(); - - aCDSize.Width()=aNewSize.Width()-aCDTopLeft.X()-aFLTopLeft.X(); - aFLSize.Width()=aNewSize.Width()-2*aFLTopLeft.X(); - aFDSize.Width()=aFLSize.Width(); - aSplitterSize.Width()=aFLSize.Width(); - - aCatBox.SetSizePixel(aCDSize); - aFuncList.SetSizePixel(aFLSize); - aPrivatSplit.SetSizePixel(aSplitterSize); - aFiFuncDesc.SetSizePixel(aFDSize); -} - -/************************************************************************* -#* Member: SetHeight Datum:06.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Hoehe fuer die einzelnen Controls und -#* das Fenster einstellen bei Li oder Re -#* -#* Input: neue Fenstergroesse -#* -#* Output: --- -#* -#************************************************************************/ - -void ScFunctionDockWin::SetMyHeightLeRi(Size &aNewSize) -{ - if((ULONG)aNewSize.Height()<nMinHeight) aNewSize.Height()=nMinHeight; - - Size aFLSize=aFuncList.GetSizePixel(); - Size aSplitterSize=aPrivatSplit.GetSizePixel(); - Size aFDSize=aFiFuncDesc.GetSizePixel(); - - Point aFLTopLeft=aFuncList.GetPosPixel(); - Point aSplitterTopLeft=aPrivatSplit.GetPosPixel(); - Point aFDTopLeft=aFiFuncDesc.GetPosPixel(); - - long nTxtHeight = aFuncList.GetTextHeight(); - - short nY=(short)(3*nTxtHeight+ - aFuncList.GetPosPixel().Y()+aSplitterSize.Height()); - - aFDTopLeft.Y()=aNewSize.Height()-aFDSize.Height()-4; - if(nY>aFDTopLeft.Y()) - { - aFDSize.Height()-=nY-aFDTopLeft.Y(); - aFDTopLeft.Y()=nY; - } - aSplitterTopLeft.Y()=aFDTopLeft.Y()-aSplitterSize.Height()-1; - aFLSize.Height()=aSplitterTopLeft.Y()-aFLTopLeft.Y()-1; - - aFuncList.SetSizePixel(aFLSize); - aPrivatSplit.SetPosPixel(aSplitterTopLeft); - aFiFuncDesc.SetPosPixel(aFDTopLeft); - aFiFuncDesc.SetSizePixel(aFDSize); - -} - -/************************************************************************* -#* Member: SetMyWidthToBo Datum:16.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Breite fuer die einzelnen Controls und -#* das Fenster einstellen, wenn oben oder -#* unten angedockt werden soll. -#* -#* Input: neue Fenstergroesse -#* -#* Output: --- -#* -#************************************************************************/ - -void ScFunctionDockWin::SetMyWidthToBo(Size &aNewSize) -{ - if((ULONG)aNewSize.Width()<nMinWidth) aNewSize.Width()=nMinWidth; - - Size aCDSize=aCatBox.GetSizePixel(); - Size aDdFLSize=aDDFuncList.GetSizePixel(); - Size aFDSize=aFiFuncDesc.GetSizePixel(); - - Point aCDTopLeft=aCatBox.GetPosPixel(); - Point aDdFLTopLeft=aDDFuncList.GetPosPixel(); - Point aFDTopLeft=aFiFuncDesc.GetPosPixel(); - - aCDSize.Width()=aDdFLTopLeft.X()-aFDTopLeft.X()-aCDTopLeft.X(); - aDdFLTopLeft.X()=aCDSize.Width()+aCDTopLeft.X()+aFDTopLeft.X(); - - aDdFLSize.Width()=aNewSize.Width()-aDdFLTopLeft.X()-aFDTopLeft.X(); - - aFDSize.Width()=aNewSize.Width()-2*aFDTopLeft.X(); - - aDDFuncList.SetPosPixel(aDdFLTopLeft); - aDDFuncList.SetSizePixel(aDdFLSize); - aCatBox.SetSizePixel(aCDSize); - aFiFuncDesc.SetSizePixel(aFDSize); -} - -/************************************************************************* -#* Member: SetHeight Datum:16.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Hoehe fuer die einzelnen Controls und -#* das Fenster einstellen, wenn oben oder -#* unten angedockt werden soll. -#* -#* Input: neue Fenstergroesse -#* -#* Output: --- -#* -#************************************************************************/ - -void ScFunctionDockWin::SetMyHeightToBo(Size &aNewSize) -{ - if((ULONG)aNewSize.Height()<nMinHeight) aNewSize.Height()=nMinHeight; - - Size aFDSize=aFiFuncDesc.GetSizePixel(); - - Point aFDTopLeft=aFiFuncDesc.GetPosPixel(); - Point aCBTopLeft=aCatBox.GetPosPixel(); - aFDSize.Height()=aNewSize.Height()-aFDTopLeft.Y()-aCBTopLeft.Y(); - aFiFuncDesc.SetSizePixel(aFDSize); - -} - -/************************************************************************* -#* Member: SetDescription Datum:13.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Erklaerungstext fuer die Funktion einstellen. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -void ScFunctionDockWin::SetDescription() -{ - aFiFuncDesc.SetText( EMPTY_STRING ); - const ScFuncDesc* pDesc = - (const ScFuncDesc*)pAllFuncList->GetEntryData( - pAllFuncList->GetSelectEntryPos() ); - if (pDesc) - { - pDesc->InitArgumentInfo(); // full argument info is needed - - String aString=pAllFuncList->GetSelectEntry(); - if(nDockMode==0) - { - aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ":\n\n" )); - } - else - { - aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " )); - } - - aString+=pDesc->GetParamList(); - - if(nDockMode==0) - { - aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "\n\n" )); - } - else - { - aString += '\n'; - } - - aString+=*(pDesc->pFuncDesc); - - aFiFuncDesc.SetText(aString); - aFiFuncDesc.StateChanged(STATE_CHANGE_TEXT); - aFiFuncDesc.Invalidate(); - aFiFuncDesc.Update(); - - } - } - -/************************************************************************* -#* Member: Resizing Datum:06.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Ueberladene Funktion um die Groesse der -#* einzelnen Controls einzustellen. -#* -#* Input: neue Groesse -#* -#* Output: --- -#* -#************************************************************************/ - -void __EXPORT ScFunctionDockWin::Resizing( Size& rNewSize ) -{ - if((ULONG)rNewSize.Width()<nMinWidth) rNewSize.Width()=nMinWidth; - if((ULONG)rNewSize.Height()<nMinHeight) rNewSize.Height()=nMinHeight; - -} - -/************************************************************************* -#* Member: Close Datum:07.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Schliessen des Fensters -#* -#* Input: --- -#* -#* Output: TRUE -#* -#************************************************************************/ - -BOOL __EXPORT ScFunctionDockWin::Close() -{ - SfxBoolItem aItem( FID_FUNCTION_BOX, FALSE ); - - GetBindings().GetDispatcher()->Execute( FID_FUNCTION_BOX, - SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, - &aItem, 0L ); - - SfxDockingWindow::Close(); - - return( TRUE ); -} - - -/************************************************************************* -#* Member: CheckAlignment Datum:16.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Ueberprueft den Andockmodus und stellt die -#* Groessen dementsprechend ein. -#* -#* Input: Das neue Alignment -#* -#* Output: Das uebergebene Alignment -#* -#************************************************************************/ -SfxChildAlignment __EXPORT ScFunctionDockWin::CheckAlignment(SfxChildAlignment /* abla */, - SfxChildAlignment aChildAlign) -{ - String aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww")); - Size aTxtSize( aFiFuncDesc.GetTextWidth(aString), aFiFuncDesc.GetTextHeight() ); - if(!bInit) - { - eSfxOldAlignment=eSfxNewAlignment; - eSfxNewAlignment=aChildAlign; - } - else - { - bInit=FALSE; - eSfxOldAlignment=aChildAlign; - eSfxNewAlignment=aChildAlign; - } - - switch(eSfxOldAlignment) - { - case SFX_ALIGN_HIGHESTTOP: - case SFX_ALIGN_TOP: - case SFX_ALIGN_LOWESTTOP: - case SFX_ALIGN_LOWESTBOTTOM: - case SFX_ALIGN_BOTTOM: - case SFX_ALIGN_TOOLBOXTOP: - case SFX_ALIGN_TOOLBOXBOTTOM: - - nMinWidth= 0;/*aDDFuncList.GetPosPixel().X()+ - 10*aTxtSize.Width()+ - aFuncList.GetPosPixel().X();*/ - nMinHeight=0; - - break; - - case SFX_ALIGN_NOALIGNMENT: - - aString = aCatBox.GetEntry(0); - aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM("www")); - aTxtSize = Size( aFiFuncDesc.GetTextWidth(aString), - aFiFuncDesc.GetTextHeight() ); - - default: Point aTopLeft=aCatBox.GetPosPixel(); - nMinWidth=aTxtSize.Width()+aTopLeft.X() - +2*aFuncList.GetPosPixel().X(); - nMinHeight=19*aTxtSize.Height(); - //aCatBox.SelectEntryPos(0); - - break; - } - - return aChildAlign; -} -/************************************************************************* -#* Member: Close Datum:07.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Aenderungen erkennen -#* -#* Input: --- -#* -#* Output: TRUE -#* -#************************************************************************/ -void ScFunctionDockWin::Notify( SfxBroadcaster&, const SfxHint& /* rHint */ ) -{ -// const SfxPoolItemHint *pPoolItemHint = PTR_CAST(SfxPoolItemHint, &rHint); - /* - if ( pPoolItemHint - && ( pPoolItemHint->GetObject()->ISA( SvxColorTableItem ) ) ) - { - // Die Liste der Farben hat sich geaendert - pColorTable = ( (SvxColorTableItem*) pPoolItemHint->GetObject() )->GetColorTable(); - FillValueSet(); - } - */ -} - - -/************************************************************************* -#* Member: Resize Datum:06.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Ueberladene Funktion um die Groesse der -#* einzelnen Controls einzustellen. -#* -#* Input: neue Groesse -#* -#* Output: --- -#* -#************************************************************************/ - -void __EXPORT ScFunctionDockWin::Resize() -{ - if ( !IsFloatingMode() || - !GetFloatingWindow()->IsRollUp() ) - { - Size aQSize=GetOutputSizePixel(); - Resizing( aQSize); - SetSize(); - } - SfxDockingWindow::Resize(); -} - -/************************************************************************* -#* Member: UpdateFunctionList Datum:06.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Aktualisiert die Liste der Funktionen ab- -#* haengig von der eingestellten Kategorie. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -void ScFunctionDockWin::UpdateFunctionList() -{ - USHORT nSelPos = aCatBox.GetSelectEntryPos(); - USHORT nCategory = ( LISTBOX_ENTRY_NOTFOUND != nSelPos ) - ? (nSelPos-1) : 0; - - pAllFuncList->Clear(); - pAllFuncList->SetUpdateMode( FALSE ); - - if ( nSelPos > 0 ) - { - ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); - - const ScFuncDesc* pDesc = pFuncMgr->First( nCategory ); - while ( pDesc ) - { - pAllFuncList->SetEntryData( - pAllFuncList->InsertEntry( *(pDesc->pFuncName) ), - (void*)pDesc ); - pDesc = pFuncMgr->Next(); - } - } - else // LRU-Liste - { - for ( USHORT i=0; i<LRU_MAX && aLRUList[i]; i++ ) - { - const ScFuncDesc* pDesc = aLRUList[i]; - pAllFuncList->SetEntryData( - pAllFuncList->InsertEntry( *(pDesc->pFuncName) ), - (void*)pDesc ); - } - } - - - //------------------------------------------------------ - pAllFuncList->SetUpdateMode( TRUE ); - - if ( pAllFuncList->GetEntryCount() > 0 ) - { - pAllFuncList->Enable(); - pAllFuncList->SelectEntryPos( 0 ); - } - else - { - pAllFuncList->Disable(); - } -} - -/************************************************************************* -#* Member: DoEnter Datum:06.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Eingabe ins Dokument uebernehmen. Wird aufgerufen -#* nach betaetigen der Uebernehmen- Schaltflaeche -#* oder einem Doppelklick in die Funktionsliste. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -void ScFunctionDockWin::DoEnter(BOOL /* bOk */) //@@ ??? -{ - String aFirstArgStr; - String aParaStr; - String aArgStr; - String aString=pAllFuncList->GetSelectEntry(); - SfxViewShell* pCurSh = SfxViewShell::Current(); - nArgs=0; - - if(aString.Len()>0) - { - - ScModule* pScMod = SC_MOD(); - ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, pCurSh); - ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh ); - if(!pScMod->IsEditMode()) - { - pScMod->SetInputMode(SC_INPUT_TABLE); - aString = '='; - aString += pAllFuncList->GetSelectEntry(); - if (pHdl) - pHdl->ClearText(); - } - const ScFuncDesc* pDesc = - (const ScFuncDesc*)pAllFuncList->GetEntryData( - pAllFuncList->GetSelectEntryPos() ); - if (pDesc) - { - pFuncDesc=pDesc; - UpdateLRUList(); - nArgs = pDesc->nArgCount; - if(nArgs>0) - { - // NOTE: Theoretically the first parameter could have the - // suppress flag as well, but practically it doesn't. - aFirstArgStr = *(pDesc->ppDefArgNames[0]); - aFirstArgStr.EraseLeadingAndTrailingChars(); - aFirstArgStr.SearchAndReplaceAll(' ', '_'); - aArgStr = aFirstArgStr; - if ( nArgs != VAR_ARGS ) - { // no VarArgs or Fix plus VarArgs, but not VarArgs only - String aArgSep = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( "; " )); - USHORT nFix = ( nArgs < VAR_ARGS ? nArgs : nArgs - VAR_ARGS + 1 ); - for ( USHORT nArg = 1; - nArg < nFix && !pDesc->pDefArgFlags[nArg].bOptional; nArg++ ) - { - if (!pDesc->pDefArgFlags[nArg].bSuppress) - { - aArgStr += aArgSep; - String sTmp(*(pDesc->ppDefArgNames[nArg])); - sTmp.EraseLeadingAndTrailingChars(); - sTmp.SearchAndReplaceAll(' ', '_'); - aArgStr += sTmp; - } - } - } - } - } - if (pHdl) - { - if(pHdl->GetEditString().Len()==0) - { - aString = '='; - aString += pAllFuncList->GetSelectEntry(); - } - EditView *pEdView=pHdl->GetActiveView(); - if(pEdView!=NULL) // @ Wegen Absturz bei Namen festlegen - { - if(nArgs>0) - { - pHdl->InsertFunction(aString); - pEdView->InsertText(aArgStr,TRUE); - ESelection aESel=pEdView->GetSelection(); - aESel.nEndPos=aESel.nStartPos+aFirstArgStr.Len(); - pEdView->SetSelection(aESel); - pHdl->DataChanged(); - } - else - { - aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" )); - pEdView->InsertText(aString,FALSE); - pHdl->DataChanged(); - } - } - } - InitLRUList(); - } - if ( pCurSh ) - { - Window* pShellWnd = pCurSh->GetWindow(); - - if ( pShellWnd ) - pShellWnd->GrabFocus(); - } - - -} - - - -/************************************************************************* -#* Handle: SelHdl Datum:06.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Bei einer Aenderung der Kategorie wird die -#* die Liste der Funktionen aktualisiert. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -IMPL_LINK( ScFunctionDockWin, SelHdl, ListBox*, pLb ) -{ - if ( pLb == &aCatBox) - { - UpdateFunctionList(); - SetDescription(); - } - - if ( pLb == &aFuncList||pLb == &aDDFuncList) - { - SetDescription(); - } - - - //SetSize(); - return 0; -} - -/************************************************************************* -#* Handle: SelHdl Datum:06.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Bei einer Aenderung der Kategorie wird die -#* die Liste der Funktionen aktualisiert. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -IMPL_LINK( ScFunctionDockWin, SetSelectionHdl, void*, pCtrl ) -{ - if ((ImageButton *)pCtrl == &aInsertButton || - (ListBox *)pCtrl == &aFuncList) - { - DoEnter(TRUE); // Uebernimmt die Eingabe - } - //... - - return 0; -} - -/************************************************************************* -#* Handle: SetSplitHdl Datum:13.10.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScFunctionDockWin -#* -#* Funktion: Bei einer Aenderung des Split- Controls werden die -#* einzelnen Controls an die neue Groesse angepasst. -#* -#* Input: Zeiger auf Control -#* -#* Output: --- -#* -#************************************************************************/ - -IMPL_LINK( ScFunctionDockWin, SetSplitHdl, ScPrivatSplit*, pCtrl ) -{ - if (pCtrl == &aPrivatSplit) - { - short nDeltaY=aPrivatSplit.GetDeltaY(); - Size aFLSize=aFuncList.GetSizePixel(); - Size aFDSize=aFiFuncDesc.GetSizePixel(); - Point aFDTopLeft=aFiFuncDesc.GetPosPixel(); - - aFLSize.Height()+=nDeltaY; - aFDSize.Height()-=nDeltaY; - aFDTopLeft.Y()+=nDeltaY; - aFuncList.SetSizePixel(aFLSize); - aFiFuncDesc.SetPosPixel(aFDTopLeft); - aFiFuncDesc.SetSizePixel(aFDSize); - /* - aFuncList.Invalidate(); - aFuncList.Update(); - aFiFuncDesc.Invalidate(); - aFiFuncDesc.Update(); - */ - } - //... - - return 0; -} - -void ScFunctionDockWin::ToggleFloatingMode() -{ - aSplitterInitPos = Point(); - SfxDockingWindow::ToggleFloatingMode(); - - eSfxNewAlignment=GetAlignment(); - eSfxOldAlignment=eSfxNewAlignment; - - aOldSize.Height()=0; - aOldSize.Width()=0; - aTimer.Start(); -} - -IMPL_LINK( ScFunctionDockWin, TimerHdl, Timer*, EMPTYARG ) -{ - CheckAlignment(eSfxOldAlignment,eSfxNewAlignment); - SetSize(); - return 0; -} - -void ScFunctionDockWin::Initialize(SfxChildWinInfo *pInfo) -{ - String aStr; - if(pInfo!=NULL) - { - if ( pInfo->aExtraString.Len() ) - { - xub_StrLen nPos = pInfo->aExtraString.Search( - String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScFuncList:"))); - - // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn - // er nicht vorhanden ist, liegt eine "altere Version vor - if ( nPos != STRING_NOTFOUND ) - { - xub_StrLen n1 = pInfo->aExtraString.Search('(', nPos); - if ( n1 != STRING_NOTFOUND ) - { - xub_StrLen n2 = pInfo->aExtraString.Search(')', n1); - if ( n2 != STRING_NOTFOUND ) - { - // Alignment-String herausschneiden - aStr = pInfo->aExtraString.Copy(nPos, n2 - nPos + 1); - pInfo->aExtraString.Erase(nPos, n2 - nPos + 1); - aStr.Erase(0, n1-nPos+1); - } - } - } - } - } - SfxDockingWindow::Initialize(pInfo); - - if ( aStr.Len()) - { - aSplitterInitPos=aPrivatSplit.GetPosPixel(); - aSplitterInitPos.Y()=(USHORT) aStr.ToInt32(); - xub_StrLen n1 = aStr.Search(';'); - aStr.Erase(0, n1+1); - USHORT nSelPos=sal::static_int_cast<USHORT>( aStr.ToInt32() ); - aCatBox.SelectEntryPos(nSelPos); - SelHdl(&aCatBox); - - // if the window has already been shown (from SfxDockingWindow::Initialize if docked), - // set the splitter position now, otherwise it is set in StateChanged with type INITSHOW - - UseSplitterInitPos(); - } -} - -//------------------------------------------------------------------------- - -void ScFunctionDockWin::FillInfo(SfxChildWinInfo& rInfo) const -{ - SfxDockingWindow::FillInfo(rInfo); - Point aPoint=aPrivatSplit.GetPosPixel(); - rInfo.aExtraString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "ScFuncList:(" )); - rInfo.aExtraString += String::CreateFromInt32(aPoint.Y()); - rInfo.aExtraString += ';'; - rInfo.aExtraString += String::CreateFromInt32(aCatBox.GetSelectEntryPos()); - rInfo.aExtraString += ')'; -} - -void ScFunctionDockWin::UseSplitterInitPos() -{ - if ( IsVisible() && aPrivatSplit.IsEnabled() && aSplitterInitPos != Point() ) - { - aPrivatSplit.MoveSplitTo(aSplitterInitPos); - aSplitterInitPos = Point(); // use only once - } -} - -void ScFunctionDockWin::StateChanged( StateChangedType nStateChange ) -{ - SfxDockingWindow::StateChanged( nStateChange ); - - if (nStateChange == STATE_CHANGE_INITSHOW) - { - UseSplitterInitPos(); // set initial splitter position if necessary - } -} - - +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dwfunctr.cxx,v $
+ * $Revision: 1.15 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/editview.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewsh.hxx>
+
+#include "sc.hrc"
+#include "global.hxx" // ScAddress
+#include "scresid.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "cell.hxx"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "tabvwsh.hxx"
+#include "appoptio.hxx"
+#include "compiler.hxx"
+
+#include "dwfunctr.hrc"
+#include "dwfunctr.hxx"
+
+// -----------------------------------------------------------------------
+
+#define ARG_SEPERATOR String("; ")
+SFX_IMPL_DOCKINGWINDOW( ScFunctionChildWindow, FID_FUNCTION_BOX )
+
+/*************************************************************************
+#* Member: ScFunctionChildWindow Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionChildWindow
+#*
+#* Funktion: Konstruktor der Klasse ScFunctionChildWindow
+#* Ableitung vom SfxChildWindow als "Behaelter" fuer
+#* Funktions- Fenster in Clac
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+__EXPORT ScFunctionChildWindow::ScFunctionChildWindow( Window* pParentP,
+ USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( pParentP, nId )
+{
+ ScFunctionDockWin* pWin = new ScFunctionDockWin( pBindings, this,
+ pParentP, ScResId( FID_FUNCTION_BOX ) );
+ pWindow = pWin;
+
+ eChildAlignment = SFX_ALIGN_RIGHT;
+
+ pWin->Initialize( pInfo );
+}
+
+/*************************************************************************
+#* Member: ScFunctionDockWin Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Konstruktor der Klasse ScFunctionDockWin
+#*
+#* Input: Sfx- Verknuepfungen, Fenster, Resource
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+ScFunctionDockWin::ScFunctionDockWin( SfxBindings* pBindingsP,
+ SfxChildWindow *pCW, Window* pParent, const ResId& rResId ) :
+
+ SfxDockingWindow( pBindingsP, pCW, pParent, rResId ),
+ aPrivatSplit ( this, ResId( FT_SPLIT, *rResId.GetResMgr() ),SC_SPLIT_VERT),
+ aCatBox ( this, ResId( CB_CAT, *rResId.GetResMgr() ) ),
+ aFuncList ( this, ResId( LB_FUNC, *rResId.GetResMgr() ) ),
+ aDDFuncList ( this, ResId( DDLB_FUNC, *rResId.GetResMgr() ) ),
+ aInsertButton ( this, ResId( IMB_INSERT, *rResId.GetResMgr() ) ),
+ aFiFuncDesc ( this, ResId( FI_FUNCDESC, *rResId.GetResMgr() ) ),
+ aOldSize (0,0)
+{
+ FreeResource();
+ InitLRUList();
+ SetStyle(GetStyle()|WB_CLIPCHILDREN);
+
+ aTimer.SetTimeout(200);
+ aTimer.SetTimeoutHdl(LINK( this, ScFunctionDockWin, TimerHdl));
+
+ eSfxNewAlignment=GetAlignment();
+ eSfxOldAlignment=eSfxNewAlignment;
+ aFiFuncDesc.SetUpdateMode(TRUE);
+ pAllFuncList=&aFuncList;
+ aDDFuncList.Disable();
+ aDDFuncList.Hide();
+ nArgs=0;
+ nDockMode=0;
+ bSizeFlag=FALSE;
+ aCatBox.SetDropDownLineCount(9);
+ Font aFont=aFiFuncDesc.GetFont();
+ aFont.SetColor(Color(COL_BLACK));
+ aFiFuncDesc.SetFont(aFont);
+ aFiFuncDesc.SetBackground( GetBackground() ); //! never transparent?
+//? SetBackground();
+
+ Link aLink=LINK( this, ScFunctionDockWin, SelHdl);
+ aCatBox.SetSelectHdl(aLink);
+ aFuncList.SetSelectHdl(aLink);
+ aDDFuncList.SetSelectHdl(aLink);
+
+ Link a2Link=LINK( this, ScFunctionDockWin, SetSelectionHdl);
+ aFuncList.SetDoubleClickHdl(a2Link);
+ aDDFuncList.SetSelectHdl(aLink);
+ aInsertButton.SetClickHdl(a2Link);
+
+ Link a3Link=LINK( this, ScFunctionDockWin, SetSplitHdl);
+ aPrivatSplit.SetCtrModifiedHdl(a3Link);
+ StartListening( *pBindingsP, TRUE );
+
+ Point aTopLeft=aCatBox.GetPosPixel();
+ //String aString=aCatBox.GetEntry( 0)+String("www");
+ String aString=String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
+ Size aTxtSize( aFiFuncDesc.GetTextWidth(aString), aFiFuncDesc.GetTextHeight() );
+ nMinWidth=aTxtSize.Width()+aTopLeft.X()
+ +2*aFuncList.GetPosPixel().X();
+ nMinHeight=19*aTxtSize.Height();
+ aCatBox.SelectEntryPos(0);
+
+ Range aYRange(3*aTxtSize.Height()+aFuncList.GetPosPixel().Y(),
+ GetOutputSizePixel().Height()-2*aTxtSize.Height());
+ aPrivatSplit.SetYRange(aYRange);
+ SelHdl(&aCatBox);
+ bInit=TRUE;
+}
+
+/*************************************************************************
+#* Member: ScFunctionDockWin Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Destruktor der Klasse ScFunctionDockWin
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+__EXPORT ScFunctionDockWin::~ScFunctionDockWin()
+{
+ EndListening( GetBindings() );
+}
+
+/*************************************************************************
+#* Member: UpdateFunctionList Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aktualisiert die Liste der Funktionen ab-
+#* haengig von der eingestellten Kategorie.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::InitLRUList()
+{
+ const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
+ USHORT nLRUFuncCount = Min( rAppOpt.GetLRUFuncListCount(), (USHORT)LRU_MAX );
+ USHORT* pLRUListIds = rAppOpt.GetLRUFuncList();
+
+ USHORT i;
+ for ( i=0; i<LRU_MAX; i++ )
+ aLRUList[i] = NULL;
+
+ if ( pLRUListIds )
+ {
+ ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr();
+ for ( i=0; i<nLRUFuncCount; i++ )
+ aLRUList[i] = pFuncMgr->Get( pLRUListIds[i] );
+ }
+
+ USHORT nSelPos = aCatBox.GetSelectEntryPos();
+
+ if(nSelPos == 0)
+ UpdateFunctionList();
+}
+
+/*************************************************************************
+#* Member: UpdateFunctionList Datum:10.12.99
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aktualisiert die Liste der zuletzt verwendeten Funktionen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::UpdateLRUList()
+{
+ if (pFuncDesc && pFuncDesc->nFIndex!=0)
+ {
+ ScModule* pScMod = SC_MOD();
+ pScMod->InsertEntryToLRUList(pFuncDesc->nFIndex);
+ }
+}
+
+
+/*************************************************************************
+#* Member: SetSize Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Groesse fuer die einzelnen Controls einzustellen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetSize()
+{
+ USHORT nSelEntry=0;
+ SfxChildAlignment aChildAlign=eSfxOldAlignment;//GetAlignment();
+ short nNewDockMode;
+ switch(aChildAlign)
+ {
+ case SFX_ALIGN_HIGHESTTOP:
+ case SFX_ALIGN_TOP:
+ case SFX_ALIGN_LOWESTTOP:
+ case SFX_ALIGN_LOWESTBOTTOM:
+ case SFX_ALIGN_BOTTOM:
+ case SFX_ALIGN_TOOLBOXTOP:
+ case SFX_ALIGN_TOOLBOXBOTTOM:
+
+
+ nNewDockMode=1;
+ if(nDockMode!=nNewDockMode)
+ {
+ nDockMode=nNewDockMode;
+ nSelEntry=aFuncList.GetSelectEntryPos();
+ aFuncList.Clear();
+ aFiFuncDesc.SetPosPixel(aFuncList.GetPosPixel());
+ aDDFuncList.Enable();
+ aDDFuncList.Show();
+ aPrivatSplit.Disable();
+ aPrivatSplit.Hide();
+ aFuncList.Disable();
+ aFuncList.Hide();
+ pAllFuncList=&aDDFuncList;
+ SelHdl(&aCatBox);
+ aDDFuncList.SelectEntryPos(nSelEntry);
+ }
+ break;
+
+ default: nNewDockMode=0;
+ if(nDockMode!=nNewDockMode)
+ {
+ nDockMode=nNewDockMode;
+ nSelEntry=aDDFuncList.GetSelectEntryPos();
+ aDDFuncList.Clear();
+ aDDFuncList.Disable();
+ aDDFuncList.Hide();
+ aPrivatSplit.Enable();
+ aPrivatSplit.Show();
+ aFuncList.Enable();
+ aFuncList.Show();
+ pAllFuncList=&aFuncList;
+ SelHdl(&aCatBox);
+ aFuncList.SelectEntryPos(nSelEntry);
+ }
+ break;
+ }
+
+ if(nDockMode==0)
+ {
+ SetLeftRightSize();
+ }
+ else
+ {
+ SetTopBottonSize();
+ }
+}
+/*************************************************************************
+#* Member: SetLeftRightSize Datum:15.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Groesse fuer die einzelnen Controls einstellen,
+#* wenn Links oder Rechts angedockt wird.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetLeftRightSize()
+{
+ if(bSizeFlag==FALSE)
+ {
+ bSizeFlag=TRUE;
+
+ Size aDiffSize=GetSizePixel();
+ Size aNewSize=GetOutputSizePixel();
+ aDiffSize.Width()-=aNewSize.Width();
+ aDiffSize.Height()-=aNewSize.Height();
+
+ //@ SetUpdateMode( FALSE);
+
+ String aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
+
+ Size aTxtSize( aFuncList.GetTextWidth(aString), aFuncList.GetTextHeight() );
+
+ Range aYRange(3*aTxtSize.Height()+aFuncList.GetPosPixel().Y(),
+ GetOutputSizePixel().Height()-2*aTxtSize.Height());
+ aPrivatSplit.SetYRange(aYRange);
+
+
+ if(aOldSize.Width()!=aNewSize.Width())
+ SetMyWidthLeRi(aNewSize);
+
+ if(aOldSize.Height()!=aNewSize.Height())
+ SetMyHeightLeRi(aNewSize);
+
+ aOldSize=aNewSize;
+ aNewSize.Width()+=aDiffSize.Width();
+ aNewSize.Height()+=aDiffSize.Height();
+ //SetSizePixel(aNewSize);
+ //@ SetUpdateMode( TRUE);
+ bSizeFlag=FALSE;
+ }
+
+}
+/*************************************************************************
+#* Member: SetTopBottonSize Datum:15.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Groesse fuer die einzelnen Controls einzustellen.
+#* wenn oben oder unten angedockt wird.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetTopBottonSize()
+{
+ if(bSizeFlag==FALSE)
+ {
+ bSizeFlag=TRUE;
+ Size aDiffSize=GetSizePixel();
+ Size aNewSize=GetOutputSizePixel();
+ aDiffSize.Width()-=aNewSize.Width();
+ aDiffSize.Height()-=aNewSize.Height();
+
+ SetMyWidthToBo(aNewSize);
+ SetMyHeightToBo(aNewSize);
+
+ aNewSize.Width()+=aDiffSize.Width();
+ aNewSize.Height()+=aDiffSize.Height();
+ //SetSizePixel(aNewSize);
+ //@ SetUpdateMode( TRUE);
+ bSizeFlag=FALSE;
+ }
+}
+
+/*************************************************************************
+#* Member: SetMyWidthLeRi Datum:15.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Breite fuer die einzelnen Controls und
+#* das Fenster einstellen,wenn Li oder Re
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyWidthLeRi(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Width()<nMinWidth) aNewSize.Width()=nMinWidth;
+
+ Size aCDSize=aCatBox.GetSizePixel();
+ Size aFLSize=aFuncList.GetSizePixel();
+ Size aSplitterSize=aPrivatSplit.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aCDTopLeft=aCatBox.GetPosPixel();
+ Point aFLTopLeft=aFuncList.GetPosPixel();
+ Point aSplitterTopLeft=aPrivatSplit.GetPosPixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ aCDSize.Width()=aNewSize.Width()-aCDTopLeft.X()-aFLTopLeft.X();
+ aFLSize.Width()=aNewSize.Width()-2*aFLTopLeft.X();
+ aFDSize.Width()=aFLSize.Width();
+ aSplitterSize.Width()=aFLSize.Width();
+
+ aCatBox.SetSizePixel(aCDSize);
+ aFuncList.SetSizePixel(aFLSize);
+ aPrivatSplit.SetSizePixel(aSplitterSize);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+}
+
+/*************************************************************************
+#* Member: SetHeight Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Hoehe fuer die einzelnen Controls und
+#* das Fenster einstellen bei Li oder Re
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyHeightLeRi(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Height()<nMinHeight) aNewSize.Height()=nMinHeight;
+
+ Size aFLSize=aFuncList.GetSizePixel();
+ Size aSplitterSize=aPrivatSplit.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aFLTopLeft=aFuncList.GetPosPixel();
+ Point aSplitterTopLeft=aPrivatSplit.GetPosPixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ long nTxtHeight = aFuncList.GetTextHeight();
+
+ short nY=(short)(3*nTxtHeight+
+ aFuncList.GetPosPixel().Y()+aSplitterSize.Height());
+
+ aFDTopLeft.Y()=aNewSize.Height()-aFDSize.Height()-4;
+ if(nY>aFDTopLeft.Y())
+ {
+ aFDSize.Height()-=nY-aFDTopLeft.Y();
+ aFDTopLeft.Y()=nY;
+ }
+ aSplitterTopLeft.Y()=aFDTopLeft.Y()-aSplitterSize.Height()-1;
+ aFLSize.Height()=aSplitterTopLeft.Y()-aFLTopLeft.Y()-1;
+
+ aFuncList.SetSizePixel(aFLSize);
+ aPrivatSplit.SetPosPixel(aSplitterTopLeft);
+ aFiFuncDesc.SetPosPixel(aFDTopLeft);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+
+}
+
+/*************************************************************************
+#* Member: SetMyWidthToBo Datum:16.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Breite fuer die einzelnen Controls und
+#* das Fenster einstellen, wenn oben oder
+#* unten angedockt werden soll.
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyWidthToBo(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Width()<nMinWidth) aNewSize.Width()=nMinWidth;
+
+ Size aCDSize=aCatBox.GetSizePixel();
+ Size aDdFLSize=aDDFuncList.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aCDTopLeft=aCatBox.GetPosPixel();
+ Point aDdFLTopLeft=aDDFuncList.GetPosPixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ aCDSize.Width()=aDdFLTopLeft.X()-aFDTopLeft.X()-aCDTopLeft.X();
+ aDdFLTopLeft.X()=aCDSize.Width()+aCDTopLeft.X()+aFDTopLeft.X();
+
+ aDdFLSize.Width()=aNewSize.Width()-aDdFLTopLeft.X()-aFDTopLeft.X();
+
+ aFDSize.Width()=aNewSize.Width()-2*aFDTopLeft.X();
+
+ aDDFuncList.SetPosPixel(aDdFLTopLeft);
+ aDDFuncList.SetSizePixel(aDdFLSize);
+ aCatBox.SetSizePixel(aCDSize);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+}
+
+/*************************************************************************
+#* Member: SetHeight Datum:16.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Hoehe fuer die einzelnen Controls und
+#* das Fenster einstellen, wenn oben oder
+#* unten angedockt werden soll.
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyHeightToBo(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Height()<nMinHeight) aNewSize.Height()=nMinHeight;
+
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+ Point aCBTopLeft=aCatBox.GetPosPixel();
+ aFDSize.Height()=aNewSize.Height()-aFDTopLeft.Y()-aCBTopLeft.Y();
+ aFiFuncDesc.SetSizePixel(aFDSize);
+
+}
+
+/*************************************************************************
+#* Member: SetDescription Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Erklaerungstext fuer die Funktion einstellen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetDescription()
+{
+ aFiFuncDesc.SetText( EMPTY_STRING );
+ const ScFuncDesc* pDesc =
+ (const ScFuncDesc*)pAllFuncList->GetEntryData(
+ pAllFuncList->GetSelectEntryPos() );
+ if (pDesc)
+ {
+ pDesc->initArgumentInfo(); // full argument info is needed
+
+ String aString=pAllFuncList->GetSelectEntry();
+ if(nDockMode==0)
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ":\n\n" ));
+ }
+ else
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
+ }
+
+ aString+=pDesc->GetParamList();
+
+ if(nDockMode==0)
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "\n\n" ));
+ }
+ else
+ {
+ aString += '\n';
+ }
+
+ aString+=*(pDesc->pFuncDesc);
+
+ aFiFuncDesc.SetText(aString);
+ aFiFuncDesc.StateChanged(STATE_CHANGE_TEXT);
+ aFiFuncDesc.Invalidate();
+ aFiFuncDesc.Update();
+
+ }
+ }
+
+/*************************************************************************
+#* Member: Resizing Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Ueberladene Funktion um die Groesse der
+#* einzelnen Controls einzustellen.
+#*
+#* Input: neue Groesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void __EXPORT ScFunctionDockWin::Resizing( Size& rNewSize )
+{
+ if((ULONG)rNewSize.Width()<nMinWidth) rNewSize.Width()=nMinWidth;
+ if((ULONG)rNewSize.Height()<nMinHeight) rNewSize.Height()=nMinHeight;
+
+}
+
+/*************************************************************************
+#* Member: Close Datum:07.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Schliessen des Fensters
+#*
+#* Input: ---
+#*
+#* Output: TRUE
+#*
+#************************************************************************/
+
+BOOL __EXPORT ScFunctionDockWin::Close()
+{
+ SfxBoolItem aItem( FID_FUNCTION_BOX, FALSE );
+
+ GetBindings().GetDispatcher()->Execute( FID_FUNCTION_BOX,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aItem, 0L );
+
+ SfxDockingWindow::Close();
+
+ return( TRUE );
+}
+
+
+/*************************************************************************
+#* Member: CheckAlignment Datum:16.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Ueberprueft den Andockmodus und stellt die
+#* Groessen dementsprechend ein.
+#*
+#* Input: Das neue Alignment
+#*
+#* Output: Das uebergebene Alignment
+#*
+#************************************************************************/
+SfxChildAlignment __EXPORT ScFunctionDockWin::CheckAlignment(SfxChildAlignment /* abla */,
+ SfxChildAlignment aChildAlign)
+{
+ String aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
+ Size aTxtSize( aFiFuncDesc.GetTextWidth(aString), aFiFuncDesc.GetTextHeight() );
+ if(!bInit)
+ {
+ eSfxOldAlignment=eSfxNewAlignment;
+ eSfxNewAlignment=aChildAlign;
+ }
+ else
+ {
+ bInit=FALSE;
+ eSfxOldAlignment=aChildAlign;
+ eSfxNewAlignment=aChildAlign;
+ }
+
+ switch(eSfxOldAlignment)
+ {
+ case SFX_ALIGN_HIGHESTTOP:
+ case SFX_ALIGN_TOP:
+ case SFX_ALIGN_LOWESTTOP:
+ case SFX_ALIGN_LOWESTBOTTOM:
+ case SFX_ALIGN_BOTTOM:
+ case SFX_ALIGN_TOOLBOXTOP:
+ case SFX_ALIGN_TOOLBOXBOTTOM:
+
+ nMinWidth= 0;/*aDDFuncList.GetPosPixel().X()+
+ 10*aTxtSize.Width()+
+ aFuncList.GetPosPixel().X();*/
+ nMinHeight=0;
+
+ break;
+
+ case SFX_ALIGN_NOALIGNMENT:
+
+ aString = aCatBox.GetEntry(0);
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM("www"));
+ aTxtSize = Size( aFiFuncDesc.GetTextWidth(aString),
+ aFiFuncDesc.GetTextHeight() );
+
+ default: Point aTopLeft=aCatBox.GetPosPixel();
+ nMinWidth=aTxtSize.Width()+aTopLeft.X()
+ +2*aFuncList.GetPosPixel().X();
+ nMinHeight=19*aTxtSize.Height();
+ //aCatBox.SelectEntryPos(0);
+
+ break;
+ }
+
+ return aChildAlign;
+}
+/*************************************************************************
+#* Member: Close Datum:07.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aenderungen erkennen
+#*
+#* Input: ---
+#*
+#* Output: TRUE
+#*
+#************************************************************************/
+void ScFunctionDockWin::Notify( SfxBroadcaster&, const SfxHint& /* rHint */ )
+{
+// const SfxPoolItemHint *pPoolItemHint = PTR_CAST(SfxPoolItemHint, &rHint);
+ /*
+ if ( pPoolItemHint
+ && ( pPoolItemHint->GetObject()->ISA( SvxColorTableItem ) ) )
+ {
+ // Die Liste der Farben hat sich geaendert
+ pColorTable = ( (SvxColorTableItem*) pPoolItemHint->GetObject() )->GetColorTable();
+ FillValueSet();
+ }
+ */
+}
+
+
+/*************************************************************************
+#* Member: Resize Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Ueberladene Funktion um die Groesse der
+#* einzelnen Controls einzustellen.
+#*
+#* Input: neue Groesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void __EXPORT ScFunctionDockWin::Resize()
+{
+ if ( !IsFloatingMode() ||
+ !GetFloatingWindow()->IsRollUp() )
+ {
+ Size aQSize=GetOutputSizePixel();
+ Resizing( aQSize);
+ SetSize();
+ }
+ SfxDockingWindow::Resize();
+}
+
+/*************************************************************************
+#* Member: UpdateFunctionList Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aktualisiert die Liste der Funktionen ab-
+#* haengig von der eingestellten Kategorie.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::UpdateFunctionList()
+{
+ USHORT nSelPos = aCatBox.GetSelectEntryPos();
+ USHORT nCategory = ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
+ ? (nSelPos-1) : 0;
+
+ pAllFuncList->Clear();
+ pAllFuncList->SetUpdateMode( FALSE );
+
+ if ( nSelPos > 0 )
+ {
+ ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr();
+
+ const ScFuncDesc* pDesc = pFuncMgr->First( nCategory );
+ while ( pDesc )
+ {
+ pAllFuncList->SetEntryData(
+ pAllFuncList->InsertEntry( *(pDesc->pFuncName) ),
+ (void*)pDesc );
+ pDesc = pFuncMgr->Next();
+ }
+ }
+ else // LRU-Liste
+ {
+ for ( USHORT i=0; i<LRU_MAX && aLRUList[i]; i++ )
+ {
+ const ScFuncDesc* pDesc = aLRUList[i];
+ pAllFuncList->SetEntryData(
+ pAllFuncList->InsertEntry( *(pDesc->pFuncName) ),
+ (void*)pDesc );
+ }
+ }
+
+
+ //------------------------------------------------------
+ pAllFuncList->SetUpdateMode( TRUE );
+
+ if ( pAllFuncList->GetEntryCount() > 0 )
+ {
+ pAllFuncList->Enable();
+ pAllFuncList->SelectEntryPos( 0 );
+ }
+ else
+ {
+ pAllFuncList->Disable();
+ }
+}
+
+/*************************************************************************
+#* Member: DoEnter Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Eingabe ins Dokument uebernehmen. Wird aufgerufen
+#* nach betaetigen der Uebernehmen- Schaltflaeche
+#* oder einem Doppelklick in die Funktionsliste.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::DoEnter(BOOL /* bOk */) //@@ ???
+{
+ String aFirstArgStr;
+ String aParaStr;
+ String aArgStr;
+ String aString=pAllFuncList->GetSelectEntry();
+ SfxViewShell* pCurSh = SfxViewShell::Current();
+ nArgs=0;
+
+ if(aString.Len()>0)
+ {
+
+ ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, pCurSh);
+ ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh );
+ if(!pScMod->IsEditMode())
+ {
+ pScMod->SetInputMode(SC_INPUT_TABLE);
+ aString = '=';
+ aString += pAllFuncList->GetSelectEntry();
+ if (pHdl)
+ pHdl->ClearText();
+ }
+ const ScFuncDesc* pDesc =
+ (const ScFuncDesc*)pAllFuncList->GetEntryData(
+ pAllFuncList->GetSelectEntryPos() );
+ if (pDesc)
+ {
+ pFuncDesc=pDesc;
+ UpdateLRUList();
+ nArgs = pDesc->nArgCount;
+ if(nArgs>0)
+ {
+ // NOTE: Theoretically the first parameter could have the
+ // suppress flag as well, but practically it doesn't.
+ aFirstArgStr = *(pDesc->ppDefArgNames[0]);
+ aFirstArgStr.EraseLeadingAndTrailingChars();
+ aFirstArgStr.SearchAndReplaceAll(' ', '_');
+ aArgStr = aFirstArgStr;
+ if ( nArgs != VAR_ARGS )
+ { // no VarArgs or Fix plus VarArgs, but not VarArgs only
+ String aArgSep = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( "; " ));
+ USHORT nFix = ( nArgs < VAR_ARGS ? nArgs : nArgs - VAR_ARGS + 1 );
+ for ( USHORT nArg = 1;
+ nArg < nFix && !pDesc->pDefArgFlags[nArg].bOptional; nArg++ )
+ {
+ if (!pDesc->pDefArgFlags[nArg].bSuppress)
+ {
+ aArgStr += aArgSep;
+ String sTmp(*(pDesc->ppDefArgNames[nArg]));
+ sTmp.EraseLeadingAndTrailingChars();
+ sTmp.SearchAndReplaceAll(' ', '_');
+ aArgStr += sTmp;
+ }
+ }
+ }
+ }
+ }
+ if (pHdl)
+ {
+ if(pHdl->GetEditString().Len()==0)
+ {
+ aString = '=';
+ aString += pAllFuncList->GetSelectEntry();
+ }
+ EditView *pEdView=pHdl->GetActiveView();
+ if(pEdView!=NULL) // @ Wegen Absturz bei Namen festlegen
+ {
+ if(nArgs>0)
+ {
+ pHdl->InsertFunction(aString);
+ pEdView->InsertText(aArgStr,TRUE);
+ ESelection aESel=pEdView->GetSelection();
+ aESel.nEndPos=aESel.nStartPos+aFirstArgStr.Len();
+ pEdView->SetSelection(aESel);
+ pHdl->DataChanged();
+ }
+ else
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" ));
+ pEdView->InsertText(aString,FALSE);
+ pHdl->DataChanged();
+ }
+ }
+ }
+ InitLRUList();
+ }
+ if ( pCurSh )
+ {
+ Window* pShellWnd = pCurSh->GetWindow();
+
+ if ( pShellWnd )
+ pShellWnd->GrabFocus();
+ }
+
+
+}
+
+
+
+/*************************************************************************
+#* Handle: SelHdl Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Bei einer Aenderung der Kategorie wird die
+#* die Liste der Funktionen aktualisiert.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScFunctionDockWin, SelHdl, ListBox*, pLb )
+{
+ if ( pLb == &aCatBox)
+ {
+ UpdateFunctionList();
+ SetDescription();
+ }
+
+ if ( pLb == &aFuncList||pLb == &aDDFuncList)
+ {
+ SetDescription();
+ }
+
+
+ //SetSize();
+ return 0;
+}
+
+/*************************************************************************
+#* Handle: SelHdl Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Bei einer Aenderung der Kategorie wird die
+#* die Liste der Funktionen aktualisiert.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScFunctionDockWin, SetSelectionHdl, void*, pCtrl )
+{
+ if ((ImageButton *)pCtrl == &aInsertButton ||
+ (ListBox *)pCtrl == &aFuncList)
+ {
+ DoEnter(TRUE); // Uebernimmt die Eingabe
+ }
+ //...
+
+ return 0;
+}
+
+/*************************************************************************
+#* Handle: SetSplitHdl Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Bei einer Aenderung des Split- Controls werden die
+#* einzelnen Controls an die neue Groesse angepasst.
+#*
+#* Input: Zeiger auf Control
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScFunctionDockWin, SetSplitHdl, ScPrivatSplit*, pCtrl )
+{
+ if (pCtrl == &aPrivatSplit)
+ {
+ short nDeltaY=aPrivatSplit.GetDeltaY();
+ Size aFLSize=aFuncList.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ aFLSize.Height()+=nDeltaY;
+ aFDSize.Height()-=nDeltaY;
+ aFDTopLeft.Y()+=nDeltaY;
+ aFuncList.SetSizePixel(aFLSize);
+ aFiFuncDesc.SetPosPixel(aFDTopLeft);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+ /*
+ aFuncList.Invalidate();
+ aFuncList.Update();
+ aFiFuncDesc.Invalidate();
+ aFiFuncDesc.Update();
+ */
+ }
+ //...
+
+ return 0;
+}
+
+void ScFunctionDockWin::ToggleFloatingMode()
+{
+ aSplitterInitPos = Point();
+ SfxDockingWindow::ToggleFloatingMode();
+
+ eSfxNewAlignment=GetAlignment();
+ eSfxOldAlignment=eSfxNewAlignment;
+
+ aOldSize.Height()=0;
+ aOldSize.Width()=0;
+ aTimer.Start();
+}
+
+IMPL_LINK( ScFunctionDockWin, TimerHdl, Timer*, EMPTYARG )
+{
+ CheckAlignment(eSfxOldAlignment,eSfxNewAlignment);
+ SetSize();
+ return 0;
+}
+
+void ScFunctionDockWin::Initialize(SfxChildWinInfo *pInfo)
+{
+ String aStr;
+ if(pInfo!=NULL)
+ {
+ if ( pInfo->aExtraString.Len() )
+ {
+ xub_StrLen nPos = pInfo->aExtraString.Search(
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScFuncList:")));
+
+ // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn
+ // er nicht vorhanden ist, liegt eine "altere Version vor
+ if ( nPos != STRING_NOTFOUND )
+ {
+ xub_StrLen n1 = pInfo->aExtraString.Search('(', nPos);
+ if ( n1 != STRING_NOTFOUND )
+ {
+ xub_StrLen n2 = pInfo->aExtraString.Search(')', n1);
+ if ( n2 != STRING_NOTFOUND )
+ {
+ // Alignment-String herausschneiden
+ aStr = pInfo->aExtraString.Copy(nPos, n2 - nPos + 1);
+ pInfo->aExtraString.Erase(nPos, n2 - nPos + 1);
+ aStr.Erase(0, n1-nPos+1);
+ }
+ }
+ }
+ }
+ }
+ SfxDockingWindow::Initialize(pInfo);
+
+ if ( aStr.Len())
+ {
+ aSplitterInitPos=aPrivatSplit.GetPosPixel();
+ aSplitterInitPos.Y()=(USHORT) aStr.ToInt32();
+ xub_StrLen n1 = aStr.Search(';');
+ aStr.Erase(0, n1+1);
+ USHORT nSelPos=sal::static_int_cast<USHORT>( aStr.ToInt32() );
+ aCatBox.SelectEntryPos(nSelPos);
+ SelHdl(&aCatBox);
+
+ // if the window has already been shown (from SfxDockingWindow::Initialize if docked),
+ // set the splitter position now, otherwise it is set in StateChanged with type INITSHOW
+
+ UseSplitterInitPos();
+ }
+}
+
+//-------------------------------------------------------------------------
+
+void ScFunctionDockWin::FillInfo(SfxChildWinInfo& rInfo) const
+{
+ SfxDockingWindow::FillInfo(rInfo);
+ Point aPoint=aPrivatSplit.GetPosPixel();
+ rInfo.aExtraString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "ScFuncList:(" ));
+ rInfo.aExtraString += String::CreateFromInt32(aPoint.Y());
+ rInfo.aExtraString += ';';
+ rInfo.aExtraString += String::CreateFromInt32(aCatBox.GetSelectEntryPos());
+ rInfo.aExtraString += ')';
+}
+
+void ScFunctionDockWin::UseSplitterInitPos()
+{
+ if ( IsVisible() && aPrivatSplit.IsEnabled() && aSplitterInitPos != Point() )
+ {
+ aPrivatSplit.MoveSplitTo(aSplitterInitPos);
+ aSplitterInitPos = Point(); // use only once
+ }
+}
+
+void ScFunctionDockWin::StateChanged( StateChangedType nStateChange )
+{
+ SfxDockingWindow::StateChanged( nStateChange );
+
+ if (nStateChange == STATE_CHANGE_INITSHOW)
+ {
+ UseSplitterInitPos(); // set initial splitter position if necessary
+ }
+}
+
+
diff --git a/sc/source/ui/formdlg/formdata.cxx b/sc/source/ui/formdlg/formdata.cxx index 1a7338986538..e9d4a293888d 100644 --- a/sc/source/ui/formdlg/formdata.cxx +++ b/sc/source/ui/formdlg/formdata.cxx @@ -38,53 +38,20 @@ //============================================================================ -ScFormEditData::ScFormEditData() +ScFormEditData::ScFormEditData() : formula::FormEditData() { Reset(); } ScFormEditData::~ScFormEditData() { - delete pParent; } -ScFormEditData::ScFormEditData( const ScFormEditData& r ) +ScFormEditData::ScFormEditData( const ScFormEditData& r ) : formula::FormEditData(r) { *this = r; } - -void ScFormEditData::Reset() -{ - pParent = NULL; - nMode = 0; - nFStart = 0; - nCatSel = 1; //! oder 0 (zuletzt benutzte) - nFuncSel = 0; - nOffset = 0; - nEdFocus = 0; - bMatrix =FALSE; - nUniqueId=0; - aSelection.Min()=0; - aSelection.Max()=0; - aUndoStr.Erase(); -} - -const ScFormEditData& ScFormEditData::operator=( const ScFormEditData& r ) -{ - pParent = r.pParent; - nMode = r.nMode; - nFStart = r.nFStart; - nCatSel = r.nCatSel; - nFuncSel = r.nFuncSel; - nOffset = r.nOffset; - nEdFocus = r.nEdFocus; - aUndoStr = r.aUndoStr; - bMatrix = r.bMatrix ; - nUniqueId = r.nUniqueId; - aSelection = r.aSelection; - return *this; -} - +// ----------------------------------------------------------------------------- void ScFormEditData::SaveValues() { ScFormEditData* pTemp = new ScFormEditData(*this); diff --git a/sc/source/ui/formdlg/formdlgs.hrc b/sc/source/ui/formdlg/formdlgs.hrc deleted file mode 100644 index 8c554c3b0870..000000000000 --- a/sc/source/ui/formdlg/formdlgs.hrc +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: formdlgs.hrc,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "sc.hrc" // -> RID_SCDLG_FORMULA - - - -#define FT_RESULT 1 -#define WND_RESULT 2 -#define FT_EDITNAME 3 -#define STR_TITLE1 4 -#define STR_TITLE2 5 -#define BTN_HELP 6 -#define BTN_CANCEL 7 -#define BTN_BACKWARD 8 -#define BTN_FORWARD 9 -#define BTN_END 10 -#define BTN_MATRIX 11 -#define FT_FUNCNAME 12 -#define FT_FUNCDESC 13 -#define FT_HEADLINE 14 -#define GB_EDIT 15 -#define FT_FORMULA 16 -#define ED_FORMULA 17 -#define TC_FUNCTION 18 -#define ED_REF 19 -#define RB_REF 20 -#define FT_FORMULA_RESULT 21 -#define WND_FORMULA_RESULT 22 -// Fuer Tabpage -#define TP_FUNCTION 1 -#define TP_STRUCT 2 - -// Funktions-Tabpage -#define FT_FUNCTION 1 -#define FT_CATEGORY 2 -#define LB_CATEGORY 3 -#define LB_FUNCTION 4 -#define IB_FUNCTION 5 - - -// Struktur-Tabpage -#define FT_STRUCT 1 -#define TLB_STRUCT 2 - -// Bitmaps -#define BMP_STR_CLOSE 1 -#define BMP_STR_OPEN 2 -#define BMP_STR_END 3 -#define BMP_STR_ERROR 4 -#define BMP_STR_CLOSE_H 11 -#define BMP_STR_OPEN_H 12 -#define BMP_STR_END_H 13 -#define BMP_STR_ERROR_H 14 - -// Texte -#define STR_STRUCT_ERR1 1 -#define STR_STRUCT_ERR2 2 - - diff --git a/sc/source/ui/formdlg/formdlgs.src b/sc/source/ui/formdlg/formdlgs.src index 4d730e42e8d5..2e9ceb6b1dd3 100644 --- a/sc/source/ui/formdlg/formdlgs.src +++ b/sc/source/ui/formdlg/formdlgs.src @@ -1,354 +1,32 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: formdlgs.src,v $ - * $Revision: 1.49 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "formdlgs.hrc" - //--------------------------------------------------------------------------- -TabPage RID_SCTAB_FUNCTION -{ - Hide = TRUE ; - Size = MAP_APPFONT ( 96 , 180 ) ; - // Titel wird dynamisch gesetzt (s.u.) - // 1. Seite - ImageButton IB_FUNCTION - { - Hide = TRUE ; - //@new - Pos = MAP_APPFONT ( 81 , 29 ) ; - Size = MAP_APPFONT ( 13 , 13 ) ; - TabStop = TRUE ; - ButtonImage = Image - { - ImageBitmap = Bitmap - { - File = "sc06300.bmp" ; - }; - }; - QuickHelpText [ en-US ] = "Apply Function" ; - }; - ListBox LB_CATEGORY - { - Border = TRUE ; - Pos = MAP_APPFONT ( 6 , 14 ) ; - Size = MAP_APPFONT ( 86 , 112 ) ; - DropDown = TRUE ; - StringList [ en-US ] = - { - < "Last Used" ; Default ; > ; - < "All" ; Default ; > ; - < "Database" ; Default ; > ; - < "Date&Time" ; Default ; > ; - < "Financial" ; Default ; > ; - < "Information" ; Default ; > ; - < "Logical" ; Default ; > ; - < "Mathematical" ; Default ; > ; - < "Array" ; Default ; > ; - < "Statistical" ; Default ; > ; - < "Spreadsheet" ; Default ; > ; - < "Text" ; Default ; > ; - < "Add-in" ; Default ; > ; - }; - }; - ListBox LB_FUNCTION - { - Border = TRUE ; - Pos = MAP_APPFONT ( 6 , 43 ) ; - Size = MAP_APPFONT ( 86 , 133 ) ; - // Sort = TRUE; - }; - FixedText FT_CATEGORY - { - Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 84 , 8 ) ; - Text [ en-US ] = "~Category" ; - }; - FixedText FT_FUNCTION - { - Pos = MAP_APPFONT ( 6 , 32 ) ; - Size = MAP_APPFONT ( 72 , 8 ) ; - Text [ en-US ] = "~Function" ; - }; -}; -TabPage RID_SCTAB_STRUCT -{ - Hide = TRUE ; - Size = MAP_APPFONT ( 96 , 180 ) ; - // Titel wird dynamisch gesetzt (s.u.) - // 1. Seite - Control TLB_STRUCT - { - Border = TRUE ; - TabStop = TRUE ; - Pos = MAP_APPFONT ( 6 , 14 ) ; - Size = MAP_APPFONT ( 86 , 162 ) ; - HelpId = HID_SC_FAP_STRUCT ; - }; - FixedText FT_STRUCT - { - Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 86 , 8 ) ; - Text [ en-US ] = "~Structure" ; - }; - Image BMP_STR_CLOSE - { - ImageBitmap = Bitmap { File = "fapclose.bmp"; }; - MaskColor = SC_HC_MASKCOLOR; - }; - Image BMP_STR_CLOSE_H - { - ImageBitmap = Bitmap { File = "fapclose_h.bmp"; }; - MaskColor = SC_HC_MASKCOLOR; - }; - Image BMP_STR_OPEN - { - ImageBitmap = Bitmap { File = "fapopen.bmp"; }; - MaskColor = SC_HC_MASKCOLOR; - }; - Image BMP_STR_OPEN_H - { - ImageBitmap = Bitmap { File = "fapopen_h.bmp"; }; - MaskColor = SC_HC_MASKCOLOR; - }; - Image BMP_STR_END - { - ImageBitmap = Bitmap { File = "fapok.bmp"; }; - MaskColor = SC_HC_MASKCOLOR; - }; - Image BMP_STR_END_H - { - ImageBitmap = Bitmap { File = "fapok_h.bmp"; }; - MaskColor = SC_HC_MASKCOLOR; - }; - Image BMP_STR_ERROR - { - ImageBitmap = Bitmap { File = "faperror.bmp"; }; - MaskColor = SC_HC_MASKCOLOR; - }; - Image BMP_STR_ERROR_H - { - ImageBitmap = Bitmap { File = "faperror_h.bmp"; }; - MaskColor = SC_HC_MASKCOLOR; - }; - String STR_STRUCT_ERR1 - { - Text [ en-US ] = "=?" ; - }; - String STR_STRUCT_ERR2 - { - Text [ en-US ] = "Error" ; - }; -}; -ModelessDialog RID_SCDLG_FORMULA -{ - OutputSize = TRUE ; - Hide = TRUE ; - SVLook = TRUE ; - Size = MAP_APPFONT ( 321 , 228 ) ; - HelpId = HID_SCDLG_FORMULA ; - Moveable = TRUE ; - // Titel wird dynamisch gesetzt (s.u.) - TabControl TC_FUNCTION - { - Pos = MAP_APPFONT ( 6 , 5 ) ; - Size = MAP_APPFONT ( 102 , 199 ) ; - PageList = - { - PageItem - { - Identifier = TP_FUNCTION ; - Text [ en-US ] = "Functions" ; - }; - PageItem - { - Identifier = TP_STRUCT ; - Text [ en-US ] = "Structure" ; - }; - }; - }; - FixedText FT_HEADLINE - { - Pos = MAP_APPFONT ( 115 , 24 ) ; - Size = MAP_APPFONT ( 194 , 8 ) ; - WordBreak = TRUE ; - }; - FixedText FT_FUNCNAME - { - Pos = MAP_APPFONT ( 115 , 38 ) ; - Size = MAP_APPFONT ( 194 , 24 ) ; - WordBreak = TRUE ; - }; - FixedText FT_FUNCDESC - { - Pos = MAP_APPFONT ( 115 , 68 ) ; - Size = MAP_APPFONT ( 194 , 64 ) ; - WordBreak = TRUE ; - }; - // 2. Seite - FixedText FT_EDITNAME - { - Pos = MAP_APPFONT ( 113 , 6 ) ; - Size = MAP_APPFONT ( 83 , 10 ) ; - }; - GroupBox GB_EDIT - { - Pos = MAP_APPFONT ( 112 , 18 ) ; - Size = MAP_APPFONT ( 203 , 128 ) ; - }; - FixedText FT_FORMULA - { - Pos = MAP_APPFONT ( 112 , 151 ) ; - Size = MAP_APPFONT ( 50 , 10 ) ; - WordBreak = TRUE ; - Text [ en-US ] = "For~mula" ; - }; - Control ED_FORMULA - { - Border = TRUE ; - Pos = MAP_APPFONT ( 112 , 161 ) ; - Size = MAP_APPFONT ( 203 , 43 ) ; - //TabStop = TRUE ; - HelpId = HID_SC_FAP_FORMULA ; - }; - FixedText FT_RESULT - { - Pos = MAP_APPFONT ( 198 , 6 ) ; - Size = MAP_APPFONT ( 55 , 10 ) ; - Right = TRUE ; - Text [ en-US ] = "Function result" ; - }; - Window WND_RESULT - { - Border = TRUE ; - Pos = MAP_APPFONT ( 255 , 4 ) ; - Size = MAP_APPFONT ( 60 , 12 ) ; - }; - FixedText FT_FORMULA_RESULT - { - Pos = MAP_APPFONT ( 217 , 149 ) ; - Size = MAP_APPFONT ( 35 , 10 ) ; - Text [ en-US ] = "Result" ; - Right = TRUE ; - }; - Window WND_FORMULA_RESULT - { - Border = TRUE ; - Pos = MAP_APPFONT ( 255 , 147 ) ; - Size = MAP_APPFONT ( 60 , 12 ) ; - }; - // gemeinsam - CheckBox BTN_MATRIX - { - Pos = MAP_APPFONT ( 6 , 208 ) ; - Size = MAP_APPFONT ( 50 , 10 ) ; - TabStop = TRUE ; - Text [ en-US ] = "Array" ; - }; - Edit ED_REF - { - Border = TRUE ; - Pos = MAP_APPFONT ( 76 , 205 ) ; - Size = MAP_APPFONT ( 66 , 12 ) ; - }; - ImageButton RB_REF - { - Pos = MAP_APPFONT ( 144 , 205 ) ; - Size = MAP_APPFONT ( 13 , 15 ) ; - TabStop = FALSE ; - QuickHelpText [ en-US ] = "Maximize" ; - }; - // - HelpButton BTN_HELP - { - Pos = MAP_APPFONT ( 72 , 208 ) ; - Size = MAP_APPFONT ( 45 , 14 ) ; - TabStop = TRUE ; - }; - CancelButton BTN_CANCEL - { - Pos = MAP_APPFONT ( 121 , 208 ) ; - Size = MAP_APPFONT ( 45 , 14 ) ; - TabStop = TRUE ; - }; - PushButton BTN_BACKWARD - { - // Disable = FALSE ; - Pos = MAP_APPFONT ( 171 , 208 ) ; - Size = MAP_APPFONT ( 45 , 14 ) ; - TabStop = TRUE ; - Text [ en-US ] = "<< ~Back" ; - }; - PushButton BTN_FORWARD - { - Pos = MAP_APPFONT ( 219 , 208 ) ; - Size = MAP_APPFONT ( 45 , 14 ) ; - TabStop = TRUE ; - Text [ en-US ] = "~Next >>" ; - }; - OKButton BTN_END - { - Pos = MAP_APPFONT ( 270 , 208 ) ; - Size = MAP_APPFONT ( 45 , 14 ) ; - TabStop = TRUE ; - DefButton = TRUE ; - }; - // - String STR_TITLE1 - { - Text [ en-US ] = "Function Wizard" ; - }; - String STR_TITLE2 - { - Text [ en-US ] = "Function Wizard -" ; - }; -}; - - - - - - - - - - - - - - - - - - - - - - - - - +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: formdlgs.src,v $
+ * $Revision: 1.49 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+ //---------------------------------------------------------------------------
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx index 8b13021c7262..a244704b76af 100644 --- a/sc/source/ui/formdlg/formula.cxx +++ b/sc/source/ui/formdlg/formula.cxx @@ -40,16 +40,19 @@ #include <sfx2/docfile.hxx> #include <sfx2/objsh.hxx> #include <svtools/zforlist.hxx> +#include <svtools/stritem.hxx> +#include <svtools/svtreebx.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/topfrm.hxx> #include <vcl/svapp.hxx> #include <vcl/mnemonic.hxx> #include <unotools/charclass.hxx> -#include <svtools/stritem.hxx> #include <tools/urlobj.hxx> +#include <formula/formulahelper.hxx> +#include <formula/IFunctionDescription.hxx> +#include "tokenuno.hxx" #include "formula.hxx" -#include "formdlgs.hrc" #include "formdata.hxx" #include "globstr.hrc" #include "scresid.hxx" @@ -62,185 +65,87 @@ #include "appoptio.hxx" #include "docsh.hxx" #include "funcdesc.hxx" +#include "formula/token.hxx" +#include "tokenarray.hxx" +#include "sc.hrc" +#include "servuno.hxx" +#include "unonames.hxx" + +#include <com/sun/star/table/CellAddress.hpp> //============================================================================ +using namespace formula; +using namespace com::sun::star; ScDocument* ScFormulaDlg::pDoc = NULL; ScAddress ScFormulaDlg::aCursorPos; -inline void ShowHide( Window& rWin, BOOL bShow ) -{ - if (bShow) - rWin.Show(); - else - rWin.Hide(); -} - // -------------------------------------------------------------------------- // Initialisierung / gemeinsame Funktionen fuer Dialog // -------------------------------------------------------------------------- ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW, - Window* pParent, ScViewData* pViewData ) : - ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_FORMULA ), - // - aTabCtrl ( this, ScResId( TC_FUNCTION ) ), - aGbEdit ( this, ScResId( GB_EDIT ) ), - aScParaWin ( this, aGbEdit.GetPosPixel()), - aFtHeadLine ( this, ScResId( FT_HEADLINE ) ), - aFtFuncName ( this, ScResId( FT_FUNCNAME ) ), - aFtFuncDesc ( this, ScResId( FT_FUNCDESC ) ), - // - aFtEditName ( this, ScResId( FT_EDITNAME ) ), - aFtResult ( this, ScResId( FT_RESULT ) ), - aWndResult ( this, ScResId( WND_RESULT ) ), - - aFtFormula ( this, ScResId( FT_FORMULA ) ), - aMEFormula ( this, ScResId( ED_FORMULA ) ), - // - aBtnMatrix ( this, ScResId( BTN_MATRIX ) ), - aBtnHelp ( this, ScResId( BTN_HELP ) ), - aBtnCancel ( this, ScResId( BTN_CANCEL ) ), - aBtnBackward ( this, ScResId( BTN_BACKWARD ) ), - aBtnForward ( this, ScResId( BTN_FORWARD ) ), - aBtnEnd ( this, ScResId( BTN_END ) ), - aEdRef ( this, ScResId( ED_REF) ), - aRefBtn ( this, ScResId( RB_REF),&aEdRef ), - aFtFormResult ( this, ScResId( FT_FORMULA_RESULT)), - aWndFormResult ( this, ScResId( WND_FORMULA_RESULT)), - // - pTheRefEdit (NULL), - pScTokA (NULL), - pMEdit (NULL), - bUserMatrixFlag (FALSE), - // - aTitle1 ( ScResId( STR_TITLE1 ) ), // lokale Resource - aTitle2 ( ScResId( STR_TITLE2 ) ), // lokale Resource - aTxtEnd ( ScResId( SCSTR_END ) ), // globale Resource - aTxtOk ( aBtnEnd.GetText() ), - // - nActivWinId (0), - bIsShutDown (FALSE), - nEdFocus (0), - pFuncDesc (NULL), - nArgs (0), - pArgArr (NULL) + Window* pParent, ScViewData* pViewData,formula::IFunctionManager* _pFunctionMgr ) + : formula::FormulaDlg( pB, pCW, pParent, true,true,true,this, _pFunctionMgr,this) + , m_aHelper(this,pB) { - FreeResource(); - SetText(aTitle1); - - aEdRef.Hide(); - aRefBtn.Hide(); - - pMEdit=aMEFormula.GetEdit(); - bEditFlag=FALSE; - bStructUpdate=TRUE; - Point aPos=aGbEdit.GetPosPixel(); - aScParaWin.SetPosPixel(aPos); - aScParaWin.SetArgModifiedHdl(LINK( this, ScFormulaDlg, ModifyHdl ) ); - aScParaWin.SetFxHdl(LINK( this, ScFormulaDlg, FxHdl ) ); - - pScFuncPage= new ScFuncPage( &aTabCtrl); - pScStructPage= new ScStructPage( &aTabCtrl); - pScFuncPage->Hide(); - pScStructPage->Hide(); - aTabCtrl.SetTabPage( TP_FUNCTION, pScFuncPage); - aTabCtrl.SetTabPage( TP_STRUCT, pScStructPage); - - nOldHelp = GetHelpId(); // HelpId aus Resource immer fuer "Seite 1" - nOldUnique = GetUniqueId(); - - aBtnMatrix.SetClickHdl(LINK( this, ScFormulaDlg, MatrixHdl ) ); - aBtnCancel .SetClickHdl( LINK( this, ScFormulaDlg, BtnHdl ) ); - aBtnEnd .SetClickHdl( LINK( this, ScFormulaDlg, BtnHdl ) ); - aBtnForward .SetClickHdl( LINK( this, ScFormulaDlg, BtnHdl ) ); - aBtnBackward.SetClickHdl( LINK( this, ScFormulaDlg, BtnHdl ) ); - - pScFuncPage->SetDoubleClickHdl( LINK( this, ScFormulaDlg, DblClkHdl ) ); - pScFuncPage->SetSelectHdl( LINK( this, ScFormulaDlg, FuncSelHdl) ); - pScStructPage->SetSelectionHdl( LINK( this, ScFormulaDlg, StructSelHdl ) ); - pMEdit->SetModifyHdl( LINK( this, ScFormulaDlg, FormulaHdl ) ); - aMEFormula .SetSelChangedHdl( LINK( this, ScFormulaDlg, FormulaCursorHdl ) ); - - aFntLight = aFtFormula.GetFont(); - aFntLight.SetTransparent( TRUE ); - aFntBold = aFntLight; - aFntBold.SetWeight( WEIGHT_BOLD ); - - aScParaWin.SetArgumentFonts(aFntBold,aFntLight); - - // function description for choosing a function is no longer in a different color - - aFtHeadLine.SetFont(aFntBold); - aFtFuncName.SetFont(aFntLight); - aFtFuncDesc.SetFont(aFntLight); - + m_aHelper.SetWindow(this); ScModule* pScMod = SC_MOD(); + pScMod->InputEnterHandler(); + ScTabViewShell* pScViewShell = NULL; - ScInputHandler* pInputHdl = pScMod->GetInputHdl(); - if ( pInputHdl ) - pInputHdl->NotifyChange( NULL ); - + // title has to be from the view that opened the dialog, + // even if it's not the current view - ScFormEditData* pData = pScMod->GetFormEditData(); - String rStrExp; - if (pData) + SfxObjectShell* pParentDoc = NULL; + if ( pB ) { - // Daten schon vorhanden -> Zustand wiederherstellen (nach Umschalten) - // pDoc und aCursorPos nicht neu initialisieren - //pDoc = pViewData->GetDocument(); - if(IsInputHdl(pData->GetInputHandler())) - { - pScMod->SetRefInputHdl(pData->GetInputHandler()); - } - else + SfxDispatcher* pMyDisp = pB->GetDispatcher(); + if (pMyDisp) { - PtrTabViewShell pTabViewShell; - pInputHdl=GetNextInputHandler(pData->GetDocShell(),&pTabViewShell); - - if(pInputHdl==NULL) //DocShell hat keinen InputHandler mehr, - { //hat der Anwender halt Pech gehabt. - aBtnEnd.Disable(); - pInputHdl=pScMod->GetInputHdl(); - } - else + SfxViewFrame* pMyViewFrm = pMyDisp->GetFrame(); + if (pMyViewFrm) { - pInputHdl->SetRefViewShell(pTabViewShell); + pScViewShell = PTR_CAST( ScTabViewShell, pMyViewFrm->GetViewShell() ); + if( pScViewShell ) + pScViewShell->UpdateInputHandler(TRUE); + pParentDoc = pMyViewFrm->GetObjectShell(); } - pScMod->SetRefInputHdl(pInputHdl); - pData->SetInputHandler(pInputHdl); } + } + //if ( !pParentDoc && pScViewShell ) // use current only if above fails + // pParentDoc = pScViewShell->GetObjectShell(); + //if ( pParentDoc ) + // aDocName = pParentDoc->GetTitle(); - String aOldFormulaTmp(pScMod->InputGetFormulaStr()); - pScMod->InputSetSelection( 0, aOldFormulaTmp.Len()); + if ( pDoc == NULL ) + pDoc = pViewData->GetDocument(); + m_xParser.set(ScServiceProvider::MakeInstance(SC_SERVICE_FORMULAPARS,(ScDocShell*)pDoc->GetDocumentShell()),uno::UNO_QUERY); + uno::Reference< beans::XPropertySet> xSet(m_xParser,uno::UNO_QUERY); + xSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_COMPILEFAP)),uno::makeAny(sal_True)); + xSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_REFERENCEPOS)),uno::makeAny(table::CellAddress(aCursorPos.Tab(),aCursorPos.Col(),aCursorPos.Row()))); - rStrExp=pData->GetUndoStr(); - pScMod->InputReplaceSelection(rStrExp); - pMEdit->SetText(rStrExp); - pMEdit->SetSelection( pData->GetSelection()); - aMEFormula.UpdateOldSel(); + m_xOpCodeMapper.set(ScServiceProvider::MakeInstance(SC_SERVICE_OPCODEMAPPER,(ScDocShell*)pDoc->GetDocumentShell()),uno::UNO_QUERY); - pCell = new ScFormulaCell( pDoc, aCursorPos, rStrExp ); - pComp=new ScCompiler( pDoc, aCursorPos, pDoc->GetGrammar() ); - pComp->SetCompileForFAP(TRUE); - UpdateTokenArray(pMEdit->GetText()); - FormulaCursorHdl(&aMEFormula); - CalcStruct(rStrExp); - if(pData->GetMode()==SC_FORMDLG_FORMULA) - aTabCtrl.SetCurPageId(TP_FUNCTION); - else - aTabCtrl.SetCurPageId(TP_STRUCT); - aBtnMatrix.Check(pData->GetMatrixFlag()); - aTimer.SetTimeout(200); - aTimer.SetTimeoutHdl(LINK( this, ScFormulaDlg, UpdateFocusHdl)); - aTimer.Start(); + ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(pScViewShell); - // Jetzt nochmals zurueckschalten, da evtl. neues Doc geoeffnet wurde! - pScMod->SetRefInputHdl(NULL); - } - else + DBG_ASSERT( pInputHdl, "Missing input handler :-/" ); + + if ( pInputHdl ) + pInputHdl->NotifyChange( NULL ); + + m_aHelper.enableInput( FALSE ); + m_aHelper.EnableSpreadsheets(); + m_aHelper.Init(); + m_aHelper.SetDispatcherLock( TRUE ); + + notifyChange(); + fill(); + + ScFormEditData* pData = pScMod->GetFormEditData(); + if (!pData) { //Nun wird es Zeit den Inputhandler festzulegen pScMod->SetRefInputHdl(pScMod->GetInputHdl()); @@ -258,7 +163,7 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW, DBG_ASSERT(pData,"FormEditData ist nicht da"); - ScFormulaDlgMode eMode = SC_FORMDLG_FORMULA; // Default... + formula::FormulaDlgMode eMode = FORMULA_FORMDLG_FORMULA; // Default... // Formel vorhanden? Dann editieren @@ -268,56 +173,19 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW, BOOL bMatrix = FALSE; if ( bEdit ) { - pMEdit->GrabFocus(); - xub_StrLen nLen = aFormula.Len(); - bMatrix = nLen > 3 // Matrix-Formel ? - && aFormula.GetChar(0) == '{' - && aFormula.GetChar(1) == '=' - && aFormula.GetChar(nLen-1) == '}'; - if ( bMatrix ) - { - aFormula.Erase( 0, 1 ); - aFormula.Erase( aFormula.Len()-1, 1); - aBtnMatrix.Check( bMatrix ); - aBtnMatrix.Disable(); - } - - // #40892# auch Formeln mit Fehlern koennen editiert werden - // (ob ueberhaupt gueltige Funktionen enthalten sind, wird bei - // ScFormulaUtil::GetNextFunc getestet) -#if 0 - // Test auf Fehler (ohne Interpretieren, also nur Compiler-Fehler) - ScFormulaCell aCell( pDoc, aCursorPos, aFormula); - BOOL bAutoCalc = pDoc->GetAutoCalc(); - pDoc->SetAutoCalc( FALSE ); // Interpretieren fuer GetErrCode abstellen - USHORT nErrCode = aCell.GetErrCode(); - pDoc->SetAutoCalc( bAutoCalc ); - bEdit = ( nErrCode == 0 ); -#endif - } - - if ( bEdit ) - { - aTabCtrl.SetCurPageId(TP_STRUCT); + bMatrix = CheckMatrix(aFormula); xub_StrLen nFStart = 0; xub_StrLen nFEnd = 0; - if ( ScFormulaUtil::GetNextFunc( aFormula, FALSE, nFStart, &nFEnd) ) + if ( GetFormulaHelper().GetNextFunc( aFormula, FALSE, nFStart, &nFEnd) ) { pScMod->InputReplaceSelection( aFormula ); pScMod->InputSetSelection( nFStart, nFEnd ); - if(!bEditFlag) - pMEdit->SetText(pScMod->InputGetFormulaStr()); xub_StrLen PrivStart, PrivEnd; pScMod->InputGetSelection( PrivStart, PrivEnd); - pMEdit->SetSelection( Selection(PrivStart, PrivEnd)); - aMEFormula.UpdateOldSel(); - pMEdit->Invalidate(); - HighlightFunctionParas(pMEdit->GetSelected()); - eMode = SC_FORMDLG_EDIT; - - pData->SetFStart(nFStart ); - aBtnMatrix.Check( bMatrix ); + + eMode = SetMeText(pScMod->InputGetFormulaStr(),PrivStart, PrivEnd,bMatrix,TRUE,TRUE); + pData->SetFStart( nFStart ); } else bEdit = FALSE; @@ -326,73 +194,98 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW, if ( !bEdit ) { String aNewFormula = '='; - if(aFormula.Len()>0) - { - if ( aFormula.GetChar(0) == '=' ) - aNewFormula=aFormula; - } + if ( aFormula.Len() > 0 && aFormula.GetChar(0) == '=' ) + aNewFormula=aFormula; + pScMod->InputReplaceSelection( aNewFormula ); pScMod->InputSetSelection( 1, aNewFormula.Len()+1 ); - if(!bEditFlag) - pMEdit->SetText(pScMod->InputGetFormulaStr()); xub_StrLen PrivStart, PrivEnd; pScMod->InputGetSelection( PrivStart, PrivEnd); - if(!bEditFlag) - pMEdit->SetSelection( Selection(PrivStart, PrivEnd)); + SetMeText(pScMod->InputGetFormulaStr(),PrivStart, PrivEnd,bMatrix,FALSE,FALSE); pData->SetFStart( 1 ); // hinter dem "=" } pData->SetMode( (USHORT) eMode ); - rStrExp=pMEdit->GetText(); + String rStrExp = GetMeText(); + pCell = new ScFormulaCell( pDoc, aCursorPos, rStrExp ); - pComp=new ScCompiler( pDoc, aCursorPos, pDoc->GetGrammar() ); - pComp->SetCompileForFAP(TRUE); - CalcStruct(rStrExp); - FillDialog(); - //aBtnForward.Enable(TRUE); //@New - FuncSelHdl(NULL); - } + Update(rStrExp); + } // if (!pData) + } -__EXPORT ScFormulaDlg::~ScFormulaDlg() +void ScFormulaDlg::notifyChange() { ScModule* pScMod = SC_MOD(); - ScFormEditData* pData = pScMod->GetFormEditData(); - if (pData) // wird nicht ueber Close zerstoert; + ScInputHandler* pInputHdl = pScMod->GetInputHdl(); + if ( pInputHdl ) + pInputHdl->NotifyChange( NULL ); +} +// ----------------------------------------------------------------------------- +void ScFormulaDlg::fill() +{ + ScModule* pScMod = SC_MOD(); + ScFormEditData* pData = pScMod->GetFormEditData(); + notifyChange(); + String rStrExp; + if (pData) { - //Referenz Inputhandler zuruecksetzen - - pScMod->SetRefInputHdl(NULL); - - if(aTimer.IsActive()) + // Daten schon vorhanden -> Zustand wiederherstellen (nach Umschalten) + // pDoc und aCursorPos nicht neu initialisieren + //pDoc = pViewData->GetDocument(); + if(IsInputHdl(pData->GetInputHandler())) { - aTimer.SetTimeoutHdl(Link()); - aTimer.Stop(); + pScMod->SetRefInputHdl(pData->GetInputHandler()); } - bIsShutDown=TRUE;// Setzen, damit PreNotify keinen GetFocus speichert. + else + { + PtrTabViewShell pTabViewShell; + ScInputHandler* pInputHdl = GetNextInputHandler(pData->GetDocShell(),&pTabViewShell); - pData->SetFStart((xub_StrLen)pMEdit->GetSelection().Min()); - pData->SetSelection(pMEdit->GetSelection()); + if ( pInputHdl == NULL ) //DocShell hat keinen InputHandler mehr, + { //hat der Anwender halt Pech gehabt. + disableOk(); + pInputHdl = pScMod->GetInputHdl(); + } + else + { + pInputHdl->SetRefViewShell(pTabViewShell); + } + pScMod->SetRefInputHdl(pInputHdl); + pData->SetInputHandler(pInputHdl); + } - if(aTabCtrl.GetCurPageId()==TP_FUNCTION) - pData->SetMode( (USHORT) SC_FORMDLG_FORMULA ); - else - pData->SetMode( (USHORT) SC_FORMDLG_EDIT ); - pData->SetUndoStr(pMEdit->GetText()); - pData->SetMatrixFlag(aBtnMatrix.IsChecked()); + String aOldFormulaTmp(pScMod->InputGetFormulaStr()); + pScMod->InputSetSelection( 0, aOldFormulaTmp.Len()); + + rStrExp=pData->GetUndoStr(); + pScMod->InputReplaceSelection(rStrExp); + + SetMeText(rStrExp); + + pCell = new ScFormulaCell( pDoc, aCursorPos, rStrExp ); + + Update(); + // Jetzt nochmals zurueckschalten, da evtl. neues Doc geoeffnet wurde! + pScMod->SetRefInputHdl(NULL); } +} - aTabCtrl.RemovePage(TP_FUNCTION); - aTabCtrl.RemovePage(TP_STRUCT); +__EXPORT ScFormulaDlg::~ScFormulaDlg() +{ + ScModule* pScMod = SC_MOD(); + ScFormEditData* pData = pScMod->GetFormEditData(); + + if (pData) // wird nicht ueber Close zerstoert; + { + //Referenz Inputhandler zuruecksetzen + pScMod->SetRefInputHdl(NULL); + } // if (pData) // wird nicht ueber Close zerstoert; - delete pComp; delete pCell; - delete pScStructPage; - delete pScFuncPage; - DeleteArgs(); } BOOL ScFormulaDlg::IsInputHdl(ScInputHandler* pHdl) @@ -436,973 +329,110 @@ ScInputHandler* ScFormulaDlg::GetNextInputHandler(ScDocShell* pDocShell,PtrTabVi } - -void ScFormulaDlg::FillDialog(BOOL nFlag) -{ - if(nFlag) FillControls(); - FillListboxes(); - - String aStrResult; - - ScModule* pScMod = SC_MOD(); - if ( CalcValue(pScMod->InputGetFormulaStr(), aStrResult ) ) - aWndFormResult.SetValue( aStrResult ); - else - { - aStrResult.Erase(); - aWndFormResult.SetValue( aStrResult ); - } - -} - -void ScFormulaDlg::FillListboxes() -{ - // Umschalten zwischen den "Seiten" - - ScModule* pScMod = SC_MOD(); - ScFormEditData* pData = pScMod->GetFormEditData(); - - String aNewTitle; - // 1. Seite: Funktion auswaehlen - - if(pFuncDesc) - { - if(pScFuncPage->GetCategory()!=pFuncDesc->nCategory+1) - pScFuncPage->SetCategory(pFuncDesc->nCategory+1); - - USHORT nPos=pScFuncPage->GetFuncPos(pFuncDesc); - - pScFuncPage->SetFunction(nPos); - } - else if (pData) - { - pScFuncPage->SetCategory(pData->GetCatSel() ); - pScFuncPage->SetFunction( pData->GetFuncSel() ); - } - FuncSelHdl(NULL); - - // ResizeArgArr jetzt schon in UpdateFunctionDesc - - //pScFuncPage->GetFunctionPtr()->GrabFocus(); - - SetDispatcherLock( TRUE ); // Modal-Modus einschalten - - /* - aBtnBackward.Enable(FALSE); - aBtnForward.Enable(TRUE); - */ - aNewTitle = aTitle1; - - // HelpId fuer 1. Seite ist die aus der Resource - SetHelpId( nOldHelp ); - SetUniqueId( nOldUnique ); - -} -void ScFormulaDlg::FillControls() -{ - // Umschalten zwischen den "Seiten" - - ScModule* pScMod = SC_MOD(); - ScFormEditData* pData = pScMod->GetFormEditData(); - if (!pData) return; - - String aNewTitle; - // 2. Seite oder Editieren: ausgewaehlte Funktion anzeigen - - xub_StrLen nFStart = pData->GetFStart(); - String aFormula = pScMod->InputGetFormulaStr(); - xub_StrLen nNextFStart = nFStart; - xub_StrLen nNextFEnd = 0; - - aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " )" )); - DeleteArgs(); - const ScFuncDesc* pOldFuncDesc=pFuncDesc; - BOOL bTestFlag=FALSE; - - if ( ScFormulaUtil::GetNextFunc( aFormula, FALSE, - nNextFStart, &nNextFEnd, &pFuncDesc, &pArgArr ) ) - { - bTestFlag=(pOldFuncDesc!=pFuncDesc); - if(bTestFlag) - { - aFtHeadLine.Hide(); - aFtFuncName.Hide(); - aFtFuncDesc.Hide(); - aScParaWin.SetFunctionDesc(pFuncDesc); - if(pFuncDesc->pFuncName) - aFtEditName.SetText( *(pFuncDesc->pFuncName) ); - else - aFtEditName.SetText( EMPTY_STRING); - - } - - xub_StrLen nOldStart, nOldEnd; - pScMod->InputGetSelection( nOldStart, nOldEnd ); - if ( nOldStart != nNextFStart || nOldEnd != nNextFEnd ) - { - pScMod->InputSetSelection( nNextFStart, nNextFEnd ); - } - aFuncSel.Min()=nNextFStart; - aFuncSel.Max()=nNextFEnd; - - if(!bEditFlag) - pMEdit->SetText(pScMod->InputGetFormulaStr()); - xub_StrLen PrivStart, PrivEnd; - pScMod->InputGetSelection( PrivStart, PrivEnd); - if(!bEditFlag) - pMEdit->SetSelection( Selection(PrivStart, PrivEnd)); - - nArgs = pFuncDesc->GetSuppressedArgCount(); - USHORT nOffset = pData->GetOffset(); - nEdFocus = pData->GetEdFocus(); - - // Verkettung der Edit's fuer Focus-Kontrolle - - if(bTestFlag) - aScParaWin.SetArgumentOffset(nOffset); - USHORT nActiv=0; - xub_StrLen nArgPos=ScFormulaUtil::GetArgStart( aFormula, nFStart, 0 ); - xub_StrLen nEditPos=(xub_StrLen) pMEdit->GetSelection().Min(); - BOOL bFlag=FALSE; - - for(USHORT i=0;i<nArgs;i++) - { - xub_StrLen nLength=(pArgArr[i])->Len()+1; - aScParaWin.SetArgument(i,*(pArgArr[i])); - if(nArgPos<=nEditPos && nEditPos<nArgPos+nLength) - { - nActiv=i; - bFlag=TRUE; - } - nArgPos = sal::static_int_cast<xub_StrLen>( nArgPos + nLength ); - } - aScParaWin.UpdateParas(); - - if(bFlag) - { - aScParaWin.SetActiveLine(nActiv); - } - - //aScParaWin.SetEdFocus( nEdFocus ); - UpdateValues(); - } - else - { - aFtEditName.SetText(EMPTY_STRING); - } - // Test, ob vorne/hinten noch mehr Funktionen sind - - xub_StrLen nTempStart = ScFormulaUtil::GetArgStart( aFormula, nFStart, 0 ); - BOOL bNext = ScFormulaUtil::GetNextFunc( aFormula, FALSE, nTempStart ); - nTempStart=(xub_StrLen)pMEdit->GetSelection().Min(); - pData->SetFStart(nTempStart); - BOOL bPrev = ScFormulaUtil::GetNextFunc( aFormula, TRUE, nTempStart ); - aBtnBackward.Enable(bPrev); - aBtnForward.Enable(bNext); -} - -void ScFormulaDlg::ClearAllParas() -{ - DeleteArgs(); - pFuncDesc=NULL; - aScParaWin.ClearAll(); - aWndResult.SetValue(EMPTY_STRING); - aFtEditName.SetText(EMPTY_STRING); - FuncSelHdl(NULL); - - if(pScFuncPage->IsVisible()) - { - aBtnForward.Enable(TRUE); //@new - aFtHeadLine.Show(); - aFtFuncName.Show(); - aFtFuncDesc.Show(); - aFtHeadLine.ToTop(); - aFtFuncName.ToTop(); - aFtFuncDesc.ToTop(); - } -} - -void ScFormulaDlg::DeleteArgs() -{ - if ( pArgArr ) - { - for ( USHORT i=0; i<nArgs; i++ ) - delete pArgArr[i]; - delete [] pArgArr; - } - - pArgArr = NULL; - nArgs = 0; -} - BOOL __EXPORT ScFormulaDlg::Close() { DoEnter(FALSE); return TRUE; } -void ScFormulaDlg::DoEnter(BOOL bOk) -{ - // Eingabe ins Dokument uebernehmen oder abbrechen - - ScModule* pScMod = SC_MOD(); - - if ( bOk) - { - // ggf. Dummy-Argumente entfernen - String aInputFormula=pScMod->InputGetFormulaStr(); - String aString=RepairFormula(pMEdit->GetText()); - pScMod->InputSetSelection(0, aInputFormula.Len()); - pScMod->InputReplaceSelection(aString); - } - - // auf das Dokument zurueckschalten - // (noetig, weil ein fremdes oben sein kann - #34222#) - ScInputHandler* pHdl = pScMod->GetInputHdl(); - if ( pHdl ) - { - pHdl->ViewShellGone(NULL); // -> aktive View neu holen - pHdl->ShowRefFrame(); - } - - // aktuelle Tabelle ggF. restaurieren (wg. Maus-RefInput) - ScTabViewShell* pScViewShell = PTR_CAST(ScTabViewShell, SfxViewShell::Current()); - if ( pScViewShell ) - { - ScViewData* pVD=pScViewShell->GetViewData(); - SCTAB nExecTab = aCursorPos.Tab(); - if ( nExecTab != pVD->GetTabNo() ) - pScViewShell->SetTabNo( nExecTab ); - - SCROW nRow=aCursorPos.Row(); - SCCOL nCol=aCursorPos.Col(); - - if(pVD->GetCurX()!=nCol || pVD->GetCurY()!=nRow) - pScViewShell->SetCursor(nCol,nRow); - } - - SfxBoolItem aRetItem( SID_DLG_RETOK, bOk ); - SfxBoolItem aMatItem( SID_DLG_MATRIX, aBtnMatrix.IsChecked() ); - SfxStringItem aStrItem( SCITEM_STRING, pScMod->InputGetFormulaStr() ); - - // Wenn durch Dokument-Umschalterei die Eingabezeile weg war/ist, - // ist der String leer. Dann nicht die alte Formel loeschen. - if ( !aStrItem.GetValue().Len() ) - aRetItem.SetValue( FALSE ); // FALSE = Cancel - - SetDispatcherLock( FALSE ); // Modal-Modus ausschalten - - pDoc = NULL; - - //Referenz Inputhandler zuruecksetzen - - pScMod->SetRefInputHdl(NULL); - - - // Enable() der Eingabezeile erzwingen: - if ( pScViewShell ) - pScViewShell->UpdateInputHandler(); - GetBindings().GetDispatcher()->Execute( SID_INS_FUNCTION, - SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, - &aRetItem, &aStrItem, &aMatItem, 0L ); - - // Daten loeschen - pScMod->ClearFormEditData(); // pData wird ungueltig! - - /* - - ScInputHandler* pInputHdl = pScMod->GetInputHdl(); - if ( pInputHdl ) - pInputHdl->NotifyChange( NULL ); - - */ - // Dialog schliessen - DoClose( ScFormulaDlgWrapper::GetChildWindowId() ); -} - -IMPL_LINK( ScFormulaDlg, BtnHdl, PushButton*, pBtn ) -{ - if ( pBtn == &aBtnCancel ) - { - DoEnter(FALSE); // schliesst den Dialog - } - else if ( pBtn == &aBtnEnd ) - { - DoEnter(TRUE); // schliesst den Dialog - } - else if ( pBtn == &aBtnForward ) - { - //@pMEdit->GrabFocus(); // Damit die Selektion auch angezeigt wird. - const ScFuncDesc* pDesc =pScFuncPage->GetFuncDesc( - pScFuncPage->GetFunction() ); - - if(pDesc==pFuncDesc || !pScFuncPage->IsVisible()) - EditNextFunc( TRUE ); - else - { - DblClkHdl(pScFuncPage); //new - aBtnForward.Enable(FALSE); //new - } - //@EditNextFunc( TRUE ); - } - else if ( pBtn == &aBtnBackward ) - { - bEditFlag=FALSE; - aBtnForward.Enable(TRUE); - EditNextFunc( FALSE ); - aMEFormula.Invalidate(); - aMEFormula.Update(); - } - //... - - return 0; -} - - -// -------------------------------------------------------------------------- -// Funktionen fuer 1. Seite -// -------------------------------------------------------------------------- - -//UNUSED2008-05 void ScFormulaDlg::ResizeArgArr( const ScFuncDesc* pNewFunc ) -//UNUSED2008-05 { -//UNUSED2008-05 if ( pFuncDesc != pNewFunc ) -//UNUSED2008-05 { -//UNUSED2008-05 DeleteArgs(); -//UNUSED2008-05 -//UNUSED2008-05 if ( pNewFunc ) -//UNUSED2008-05 { -//UNUSED2008-05 nArgs = pNewFunc->GetSuppressedArgCount(); -//UNUSED2008-05 if ( nArgs > 0 ) -//UNUSED2008-05 { -//UNUSED2008-05 pArgArr = new String*[nArgs]; -//UNUSED2008-05 for ( USHORT i=0; i<nArgs; i++ ) -//UNUSED2008-05 pArgArr[i] = new String; -//UNUSED2008-05 } -//UNUSED2008-05 } -//UNUSED2008-05 -//UNUSED2008-05 pFuncDesc = pNewFunc; -//UNUSED2008-05 } -//UNUSED2008-05 } - -// Handler fuer Listboxen - -IMPL_LINK( ScFormulaDlg, DblClkHdl, ScFuncPage*, EMPTYARG ) -{ - ScModule* pScMod = SC_MOD(); - - USHORT nFunc = pScFuncPage->GetFunction(); - - // ex-UpdateLRUList - const ScFuncDesc* pDesc = pScFuncPage->GetFuncDesc(nFunc); - if (pDesc && pDesc->nFIndex!=0) - pScMod->InsertEntryToLRUList(pDesc->nFIndex); - - String aFuncName=pScFuncPage->GetSelFunctionName(); - aFuncName.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" )); - pScMod->InputReplaceSelection(aFuncName); - pMEdit->ReplaceSelected(aFuncName); - - Selection aSel=pMEdit->GetSelection(); - aSel.Max()=aSel.Max()-1; - pMEdit->SetSelection(aSel); - - FormulaHdl(pMEdit); - - aSel.Min()=aSel.Max(); - pMEdit->SetSelection(aSel); - - if(nArgs==0) - { - BtnHdl(&aBtnBackward); - } - - aScParaWin.SetEdFocus(0); - aBtnForward.Enable(FALSE); //@New - - return 0; -} - // -------------------------------------------------------------------------- // Funktionen fuer rechte Seite // -------------------------------------------------------------------------- - -void ScFormulaDlg::EditThisFunc(xub_StrLen nFStart) -{ - ScModule* pScMod = SC_MOD(); - ScFormEditData* pData = pScMod->GetFormEditData(); - if (!pData) return; - - String aFormula = pScMod->InputGetFormulaStr(); - - if(nFStart==NOT_FOUND) - { - nFStart = pData->GetFStart(); - } - else - { - pData->SetFStart(nFStart); - } - - xub_StrLen nNextFStart = nFStart; - xub_StrLen nNextFEnd = 0; - - BOOL bFound; - - //@bFound = ScFormulaUtil::GetNextFunc( aFormula, FALSE, nNextFStart, &nNextFEnd, &pFuncDesc ); - - bFound = ScFormulaUtil::GetNextFunc( aFormula, FALSE, nNextFStart, &nNextFEnd); - if ( bFound ) - { - xub_StrLen nFEnd; - - // Selektion merken und neue setzen - pScMod->InputGetSelection( nFStart, nFEnd ); - pScMod->InputSetSelection( nNextFStart, nNextFEnd ); - if(!bEditFlag) - pMEdit->SetText(pScMod->InputGetFormulaStr()); - - xub_StrLen PrivStart, PrivEnd; - pScMod->InputGetSelection( PrivStart, PrivEnd); - if(!bEditFlag) - { - pMEdit->SetSelection( Selection(PrivStart, PrivEnd)); - aMEFormula.UpdateOldSel(); - } - - pData->SetFStart( nNextFStart ); - pData->SetOffset( 0 ); - pData->SetEdFocus( 0 ); - - HighlightFunctionParas(aFormula.Copy(PrivStart, PrivEnd-PrivStart)); - FillDialog(); - } - else - { - ClearAllParas(); - /* - aScParaWin.ClearAll(); - aWndResult.SetValue(EMPTY_STRING); - aFtEditName.SetText(EMPTY_STRING); - */ - } -} - -void ScFormulaDlg::EditNextFunc( BOOL bForward, xub_StrLen nFStart ) -{ - ScModule* pScMod = SC_MOD(); - ScFormEditData* pData = pScMod->GetFormEditData(); - if (!pData) return; - - String aFormula = pScMod->InputGetFormulaStr(); - - if(nFStart==NOT_FOUND) - { - nFStart = pData->GetFStart(); - } - else - { - pData->SetFStart(nFStart); - } - - xub_StrLen nNextFStart = 0; - xub_StrLen nNextFEnd = 0; - - BOOL bFound; - if ( bForward ) - { - nNextFStart = ScFormulaUtil::GetArgStart( aFormula, nFStart, 0 ); - //@bFound = ScFormulaUtil::GetNextFunc( aFormula, FALSE, nNextFStart, &nNextFEnd, &pFuncDesc ); - bFound = ScFormulaUtil::GetNextFunc( aFormula, FALSE, nNextFStart, &nNextFEnd); - } - else - { - nNextFStart = nFStart; - //@bFound = ScFormulaUtil::GetNextFunc( aFormula, TRUE, nNextFStart, &nNextFEnd, &pFuncDesc ); - bFound = ScFormulaUtil::GetNextFunc( aFormula, TRUE, nNextFStart, &nNextFEnd); - } - - if ( bFound ) - { - xub_StrLen nFEnd; - - // Selektion merken und neue setzen - pScMod->InputGetSelection( nFStart, nFEnd ); - pScMod->InputSetSelection( nNextFStart, nNextFEnd ); - if(!bEditFlag) - pMEdit->SetText(pScMod->InputGetFormulaStr()); - - xub_StrLen PrivStart, PrivEnd; - pScMod->InputGetSelection( PrivStart, PrivEnd); - if(!bEditFlag) - { - pMEdit->SetSelection( Selection(PrivStart, PrivEnd)); - aMEFormula.UpdateOldSel(); - } - - pData->SetFStart( nNextFStart ); - pData->SetOffset( 0 ); - pData->SetEdFocus( 0 ); - - FillDialog(); - } -} - -//UNUSED2008-05 IMPL_LINK( ScFormulaDlg, ScrollHdl, ScParaWin*, EMPTYARG ) -//UNUSED2008-05 { -//UNUSED2008-05 ScModule* pScMod = SC_MOD(); -//UNUSED2008-05 ScFormEditData* pData = pScMod->GetFormEditData(); -//UNUSED2008-05 if (!pData) return 0; -//UNUSED2008-05 USHORT nOffset = aScParaWin.GetSliderPos(); -//UNUSED2008-05 pData->SetOffset( nOffset ); -//UNUSED2008-05 -//UNUSED2008-05 aScParaWin.UpdateParas(); -//UNUSED2008-05 -//UNUSED2008-05 UpdateValues(); -//UNUSED2008-05 -//UNUSED2008-05 return 0; -//UNUSED2008-05 } - -BOOL ScFormulaDlg::CalcValue( const String& rStrExp, String& rStrResult ) +bool ScFormulaDlg::calculateValue( const String& rStrExp, String& rStrResult ) { BOOL bResult = TRUE; - if ( rStrExp.Len() > 0 ) - { - // nur, wenn keine Tastatureingabe mehr anliegt, den Wert berechnen: - - if ( !Application::AnyInput( INPUT_KEYBOARD ) ) - { - ScFormulaCell* pFCell = new ScFormulaCell( pDoc, aCursorPos, rStrExp ); - - // #35521# HACK! um bei ColRowNames kein #REF! zu bekommen, - // wenn ein Name eigentlich als Bereich in die Gesamt-Formel - // eingefuegt wird, bei der Einzeldarstellung aber als - // single-Zellbezug interpretiert wird - BOOL bColRowName = pCell->HasColRowName(); - if ( bColRowName ) - { - // ColRowName im RPN-Code? - if ( pCell->GetCode()->GetCodeLen() <= 1 ) - { // ==1: einzelner ist als Parameter immer Bereich - // ==0: es waere vielleicht einer, wenn.. - String aBraced( '(' ); - aBraced += rStrExp; - aBraced += ')'; - delete pFCell; - pFCell = new ScFormulaCell( pDoc, aCursorPos, aBraced ); - } - else - bColRowName = FALSE; - } - - USHORT nErrCode = pFCell->GetErrCode(); - if ( nErrCode == 0 ) - { - SvNumberFormatter& aFormatter = *(pDoc->GetFormatTable()); - Color* pColor; - if ( pFCell->IsValue() ) - { - double n = pFCell->GetValue(); - ULONG nFormat = aFormatter.GetStandardFormat( n, 0, - pFCell->GetFormatType(), ScGlobal::eLnge ); - aFormatter.GetOutputString( n, nFormat, - rStrResult, &pColor ); - } - else - { - String aStr; - - pFCell->GetString( aStr ); - ULONG nFormat = aFormatter.GetStandardFormat( - pFCell->GetFormatType(), ScGlobal::eLnge); - aFormatter.GetOutputString( aStr, nFormat, - rStrResult, &pColor ); - } - - ScRange aTestRange; - if ( bColRowName || (aTestRange.Parse(rStrExp) & SCA_VALID) ) - rStrResult.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " ..." )); - // Bereich - } - else - rStrResult += ScGlobal::GetErrorString(nErrCode); + ::std::auto_ptr<ScFormulaCell> pFCell( new ScFormulaCell( pDoc, aCursorPos, rStrExp ) ); - if(!bUserMatrixFlag && pFCell->GetMatrixFlag()) - { - aBtnMatrix.Check(); - } - - delete pFCell; + // #35521# HACK! um bei ColRowNames kein #REF! zu bekommen, + // wenn ein Name eigentlich als Bereich in die Gesamt-Formel + // eingefuegt wird, bei der Einzeldarstellung aber als + // single-Zellbezug interpretiert wird + BOOL bColRowName = pCell->HasColRowName(); + if ( bColRowName ) + { + // ColRowName im RPN-Code? + if ( pCell->GetCode()->GetCodeLen() <= 1 ) + { // ==1: einzelner ist als Parameter immer Bereich + // ==0: es waere vielleicht einer, wenn.. + String aBraced( '(' ); + aBraced += rStrExp; + aBraced += ')'; + pFCell.reset( new ScFormulaCell( pDoc, aCursorPos, aBraced ) ); } else - bResult = FALSE; + bColRowName = FALSE; } - return bResult; -} - -void ScFormulaDlg::UpdateValues() -{ - ScModule* pScMod = SC_MOD(); - String aStrResult; - - if ( CalcValue( pFuncDesc->GetFormulaString( pArgArr ), aStrResult ) ) - aWndResult.SetValue( aStrResult ); - - aStrResult.Erase(); - if ( CalcValue(pScMod->InputGetFormulaStr(), aStrResult ) ) - aWndFormResult.SetValue( aStrResult ); - else - { - aStrResult.Erase(); - aWndFormResult.SetValue( aStrResult ); - } - CalcStruct(pMEdit->GetText()); -} - -void ScFormulaDlg::SaveArg( USHORT nEd ) -{ - if (nEd<nArgs) + USHORT nErrCode = pFCell->GetErrCode(); + if ( nErrCode == 0 ) { - USHORT i; - for(i=0;i<=nEd;i++) + SvNumberFormatter& aFormatter = *(pDoc->GetFormatTable()); + Color* pColor; + if ( pFCell->IsValue() ) { - if(pArgArr[i]->Len()==0) - *(pArgArr[i]) = ' '; + double n = pFCell->GetValue(); + ULONG nFormat = aFormatter.GetStandardFormat( n, 0, + pFCell->GetFormatType(), ScGlobal::eLnge ); + aFormatter.GetOutputString( n, nFormat, + rStrResult, &pColor ); } - if(aScParaWin.GetArgument(nEd).Len()!=0) - *(pArgArr[nEd]) = aScParaWin.GetArgument(nEd); - - USHORT nClearPos=nEd+1; - for(i=nEd+1;i<nArgs;i++) + else { - if(aScParaWin.GetArgument(i).Len()!=0) - { - nClearPos=i+1; - } - } + String aStr; - for(i=nClearPos;i<nArgs;i++) - { - *(pArgArr[i]) = EMPTY_STRING; + pFCell->GetString( aStr ); + ULONG nFormat = aFormatter.GetStandardFormat( + pFCell->GetFormatType(), ScGlobal::eLnge); + aFormatter.GetOutputString( aStr, nFormat, + rStrResult, &pColor ); } - } -} -IMPL_LINK( ScFormulaDlg, FxHdl, ScParaWin*, pPtr ) -{ - if(pPtr==&aScParaWin) - { - aBtnForward.Enable(TRUE); //@ Damit eine neue Fkt eingegeben werden kann. - aTabCtrl.SetCurPageId(TP_FUNCTION); - ScModule* pScMod = SC_MOD(); - String aUndoStr = pScMod->InputGetFormulaStr(); // bevor unten ein ";" eingefuegt wird - ScFormEditData* pData = pScMod->GetFormEditData(); - if (!pData) return 0; - - USHORT nArgNo = aScParaWin.GetActiveLine(); - nEdFocus=nArgNo; - - SaveArg(nArgNo); - UpdateSelection(); - - xub_StrLen nFormulaStrPos = pData->GetFStart(); - - String aFormula = pScMod->InputGetFormulaStr(); - xub_StrLen n1 = ScFormulaUtil::GetArgStart( aFormula, nFormulaStrPos, nEdFocus+pData->GetOffset() ); - - pData->SetEdFocus( nEdFocus ); - pData->SaveValues(); - pData->SetMode( (USHORT) SC_FORMDLG_FORMULA ); - pData->SetFStart( n1 ); - pData->SetUndoStr( aUndoStr ); - ClearAllParas(); - - FillDialog(FALSE); - pScFuncPage->SetFocus(); //Da Parawin nicht mehr sichtbar - } - return 0; -} - -IMPL_LINK( ScFormulaDlg, ModifyHdl, ScParaWin*, pPtr ) -{ - if(pPtr==&aScParaWin) - { - SaveArg(aScParaWin.GetActiveLine()); - UpdateValues(); - - UpdateSelection(); - CalcStruct(pMEdit->GetText()); - } - return 0; -} - -IMPL_LINK( ScFormulaDlg, FormulaHdl, MultiLineEdit*, EMPTYARG ) -{ - ScModule* pScMod = SC_MOD(); - ScFormEditData* pData = pScMod->GetFormEditData(); - if (!pData) return 0; - - bEditFlag=TRUE; - String aInputFormula=pScMod->InputGetFormulaStr(); - String aString=pMEdit->GetText(); - - Selection aSel =pMEdit->GetSelection(); - xub_StrLen nTest=0; - - if(aString.Len()==0) //falls alles geloescht wurde - { - aString +='='; - pMEdit->SetText(aString); - aSel .Min()=1; - aSel .Max()=1; - pMEdit->SetSelection(aSel); - } - else if(aString.GetChar(nTest)!='=') //falls ersetzt wurde; - { - aString.Insert( (sal_Unicode)'=', 0 ); - pMEdit->SetText(aString); - aSel .Min()+=1; - aSel .Max()+=1; - pMEdit->SetSelection(aSel); - } - - - pScMod->InputSetSelection(0, aInputFormula.Len()); - pScMod->InputReplaceSelection(aString); - pScMod->InputSetSelection((xub_StrLen)aSel.Min(),(xub_StrLen)aSel.Max()); - - xub_StrLen nPos=(xub_StrLen)aSel.Min()-1; - - String aStrResult; - - if ( CalcValue(pScMod->InputGetFormulaStr(), aStrResult ) ) - aWndFormResult.SetValue( aStrResult ); - else - { - aStrResult.Erase(); - aWndFormResult.SetValue( aStrResult ); - } - CalcStruct(aString); - - nPos=GetFunctionPos(nPos); - - if(nPos<aSel.Min()-1) - { - xub_StrLen nPos1=aString.Search('(',nPos); - EditNextFunc( FALSE, nPos1); + ScRange aTestRange; + if ( bColRowName || (aTestRange.Parse(rStrExp) & SCA_VALID) ) + rStrResult.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " ..." )); + // Bereich } else - { - ClearAllParas(); - /* - aScParaWin.ClearAll(); - aWndResult.SetValue(EMPTY_STRING); - aFtEditName.SetText(EMPTY_STRING); - */ - } - - pScMod->InputSetSelection((xub_StrLen)aSel.Min(),(xub_StrLen)aSel.Max()); - bEditFlag=FALSE; - return 0; -} - -IMPL_LINK( ScFormulaDlg, FormulaCursorHdl, ScEditBox*, EMPTYARG ) -{ - ScModule* pScMod = SC_MOD(); - ScFormEditData* pData = pScMod->GetFormEditData(); - if (!pData) return 0; - xub_StrLen nFStart = pData->GetFStart(); - - bEditFlag=TRUE; - - String aInputFormula=pScMod->InputGetFormulaStr(); - String aString=pMEdit->GetText(); + rStrResult += ScGlobal::GetErrorString(nErrCode); - Selection aSel =pMEdit->GetSelection(); - pScMod->InputSetSelection((xub_StrLen)aSel.Min(),(xub_StrLen)aSel.Max()); - - - if(aSel.Min()==0) + if(!isUserMatrix() && pFCell->GetMatrixFlag()) { - aSel.Min()=1; - pMEdit->SetSelection(aSel); - } - - if(aSel.Min()!=aString.Len()) - { - - xub_StrLen nPos=(xub_StrLen)aSel.Min(); - - nFStart=GetFunctionPos(nPos-1); - - if(nFStart<nPos) - { - xub_StrLen nPos1=ScFormulaUtil::GetFunctionEnd(aString,nFStart); - - if(nPos1>nPos || nPos1==STRING_NOTFOUND) - { - EditThisFunc(nFStart); - } - else - { - xub_StrLen n=nPos; - short nCount=1; - while(n>0) - { - if(aString.GetChar(n)==')') - nCount++; - else if(aString.GetChar(n)=='(') - nCount--; - if(nCount==0) break; - n--; - } - if(nCount==0) - { - nFStart=ScFormulaUtil::GetFunctionStart(aString,n,TRUE); - EditThisFunc(nFStart); - } - else - { - ClearAllParas(); - } - } - } - else - { - ClearAllParas(); - } + CheckMatrix(); } - pScMod->InputSetSelection((xub_StrLen)aSel.Min(),(xub_StrLen)aSel.Max()); - bEditFlag=FALSE; - return 0; + return bResult; } -void ScFormulaDlg::UpdateSelection() -{ - ScModule* pScMod = SC_MOD(); - - pScMod->InputSetSelection((xub_StrLen)aFuncSel.Min(),(xub_StrLen)aFuncSel.Max()); - - pScMod->InputReplaceSelection( pFuncDesc->GetFormulaString( pArgArr ) ); - pMEdit->SetText(pScMod->InputGetFormulaStr()); - xub_StrLen PrivStart, PrivEnd; - pScMod->InputGetSelection( PrivStart, PrivEnd); - aFuncSel.Min()=PrivStart; - aFuncSel.Max()=PrivEnd; - - nArgs = pFuncDesc->GetSuppressedArgCount(); - String aFormula=pMEdit->GetText(); - xub_StrLen nArgPos=ScFormulaUtil::GetArgStart( aFormula,PrivStart,0); - - USHORT nPos=aScParaWin.GetActiveLine(); - - for(USHORT i=0;i<nPos;i++) - { - xub_StrLen nTmpLength=(pArgArr[i])->Len(); - nArgPos+=nTmpLength+1; - } - xub_StrLen nLength=(pArgArr[nPos])->Len(); - - Selection aSel(nArgPos,nArgPos+nLength); - pScMod->InputSetSelection(nArgPos,nArgPos+nLength); - pMEdit->SetSelection(aSel); - aMEFormula.UpdateOldSel(); -} // virtuelle Methoden von ScAnyRefDlg: -void ScFormulaDlg::RefInputStart( ScRefEdit* pEdit, ScRefButton* pButton ) +void ScFormulaDlg::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton ) { - aEdRef.Show(); - pTheRefEdit = pEdit; - pTheRefButton = pButton; - - if( pTheRefEdit ) - { - aEdRef.SetRefString( pTheRefEdit->GetText() ); - aEdRef.SetSelection( pTheRefEdit->GetSelection() ); - aEdRef.SetHelpId( pTheRefEdit->GetHelpId() ); - aEdRef.SetUniqueId( pTheRefEdit->GetUniqueId() ); - } - - aRefBtn.Show( pButton != NULL ); - ScAnyRefDlg::RefInputStart( &aEdRef, pButton ? &aRefBtn : NULL ); - aRefBtn.SetEndImage(); - - if( pTheRefEdit ) - { - String aStr = aTitle2; - aStr += ' '; - aStr += aFtEditName.GetText(); - aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "( " ) ); - if( aScParaWin.GetActiveLine() > 0 ) - aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "...; " ) ); - aStr += aScParaWin.GetActiveArgName(); - if( aScParaWin.GetActiveLine() + 1 < nArgs ) - aStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "; ..." )); - aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " )" ) ); - - SetText( MnemonicGenerator::EraseAllMnemonicChars( aStr ) ); - } + ::std::pair<formula::RefButton*,formula::RefEdit*> aPair = RefInputStartBefore( pEdit, pButton ); + m_aHelper.RefInputStart( aPair.second, aPair.first); + RefInputStartAfter( aPair.second, aPair.first ); } - void ScFormulaDlg::RefInputDone( BOOL bForced ) { - ScAnyRefDlg::RefInputDone( bForced ); - aRefBtn.SetStartImage(); - if( bForced || !aRefBtn.IsVisible() ) - { - aEdRef.Hide(); - aRefBtn.Hide(); - if( pTheRefEdit ) - { - pTheRefEdit->SetRefString( aEdRef.GetText() ); - pTheRefEdit->GrabFocus(); - - if( pTheRefButton ) - pTheRefButton->SetStartImage(); - - USHORT nPrivActiv = aScParaWin.GetActiveLine(); - aScParaWin.SetArgument( nPrivActiv, aEdRef.GetText() ); - ModifyHdl( &aScParaWin ); - pTheRefEdit = NULL; - } - SetText( aTitle1 ); - } + m_aHelper.RefInputDone( bForced ); + RefInputDoneAfter( bForced ); } void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument* pRefDoc ) { - if (nArgs > 0 ) + const IFunctionDescription* pFunc = getCurrentFunctionDescription(); + if ( pFunc && pFunc->getSuppressedArgumentCount() > 0 ) { - aScParaWin.SetRefMode(TRUE); + Selection theSel; + BOOL bRefNull = UpdateParaWin(theSel); - Selection theSel; - String aStrEd; - Edit* pEd = GetCurrRefEdit(); - if(pEd!=NULL && pTheRefEdit==NULL) - { - theSel=pEd->GetSelection(); - theSel.Justify(); - aStrEd=pEd->GetText(); - aEdRef.SetRefString(aStrEd); - aEdRef.SetSelection( theSel ); - } - else + if ( rRef.aStart != rRef.aEnd && bRefNull ) { - theSel=aEdRef.GetSelection(); - theSel.Justify(); - aStrEd=aEdRef.GetText(); - } - String aRefStr; - - if ( rRef.aStart != rRef.aEnd && pTheRefEdit==NULL) - { - RefInputStart(aScParaWin.GetActiveEdit()); + RefInputStart(GetActiveEdit()); } + String aRefStr; BOOL bOtherDoc = ( pRefDoc != pDoc && pRefDoc->GetDocumentShell()->HasName() ); if ( bOtherDoc ) { @@ -1432,26 +462,14 @@ void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument* pRefDoc ) rRef.Format( aRefStr, nFmt, pRefDoc, pRefDoc->GetAddressConvention() ); } - aEdRef.ReplaceSelected( aRefStr ); - theSel.Max() = theSel.Min() + aRefStr.Len(); - aEdRef.SetSelection( theSel ); - - //------------------------------------- - // Manuelles Update der Ergebnisfelder: - //------------------------------------- - USHORT nPrivActiv=aScParaWin.GetActiveLine(); - aScParaWin.SetArgument(nPrivActiv,aEdRef.GetText()); - aScParaWin.UpdateParas(); - - if(pEd!=NULL) pEd->SetSelection( theSel ); - - aScParaWin.SetRefMode(FALSE); + UpdateParaWin(theSel,aRefStr); } } BOOL ScFormulaDlg::IsRefInputMode() const { - BOOL bRef = (nArgs > 0)&& (pDoc!=NULL); + const IFunctionDescription* pDesc = getCurrentFunctionDescription(); + BOOL bRef = (!pDesc || (pDesc->getSuppressedArgumentCount() > 0)) && (pDoc!=NULL); return bRef; } @@ -1467,490 +485,181 @@ BOOL ScFormulaDlg::IsDocAllowed(SfxObjectShell* pDocSh) const void ScFormulaDlg::SetActive() { - if(nArgs > 0) + const IFunctionDescription* pFunc = getCurrentFunctionDescription(); + if ( pFunc && pFunc->getSuppressedArgumentCount() > 0 ) { RefInputDone(); - Edit* pEd = GetCurrRefEdit()/*aScParaWin.GetActiveEdit()*/; - if( pEd ) - { - Selection theSel=aEdRef.GetSelection(); - // Edit may have the focus -> call ModifyHdl in addition - // to what's happening in GetFocus - pEd->GetModifyHdl().Call(pEd); - pEd->GrabFocus(); - pEd->SetSelection(theSel); - } + SetEdSelection(); } } -void ScFormulaDlg::MakeTree(SvLBoxEntry* pParent,ScToken* pScToken,long Count, - ScTokenArray* pScTokAP, ScCompiler* pCompP) +void ScFormulaDlg::SaveLRUEntry(const ScFuncDesc* pFuncDescP) { - if(pScToken!=NULL && Count>0) + if (pFuncDescP && pFuncDescP->nFIndex!=0) { - String aResult; - long nParas=pScToken->GetParamCount(); - OpCode eOp = pScToken->GetOpCode(); - - if(nParas>0) - { - pCompP->CreateStringFromToken( aResult,pScToken); - - SvLBoxEntry* pEntry; - - String aTest=pScStructPage->GetEntryText(pParent); - - if(aTest==aResult && - (eOp==ocAdd || eOp==ocMul || - eOp==ocAmpersand)) - { - pEntry=pParent; - } - else - { - if(eOp==ocBad) - { - pEntry=pScStructPage->InsertEntry(aResult,pParent,STRUCT_ERROR,0,pScToken); - } - else - { - pEntry=pScStructPage->InsertEntry(aResult,pParent,STRUCT_FOLDER,0,pScToken); - } - } - - MakeTree(pEntry,pScTokAP->PrevRPN(),nParas,pScTokAP,pCompP); - --Count; - pScTokAP->NextRPN(); - MakeTree(pParent,pScTokAP->PrevRPN(),Count,pScTokAP,pCompP); - } - else - { - pCompP->CreateStringFromToken( aResult,pScToken); - - if(eOp==ocBad) - { - pScStructPage->InsertEntry(aResult,pParent,STRUCT_ERROR,0,pScToken); - } - else - { - pScStructPage->InsertEntry(aResult,pParent,STRUCT_END,0,pScToken); - } - --Count; - MakeTree(pParent,pScTokAP->PrevRPN(),Count,pScTokAP,pCompP); - } + ScModule* pScMod = SC_MOD(); + pScMod->InsertEntryToLRUList(pFuncDescP->nFIndex); } } - -void ScFormulaDlg::UpdateTokenArray( const String& rStrExp) +void ScFormulaDlg::doClose(BOOL /*_bOk*/) { - if(pScTokA!=NULL) delete pScTokA; - pScTokA=pComp->CompileString(rStrExp); - pComp->CompileTokenArray(); + m_aHelper.DoClose( ScFormulaDlgWrapper::GetChildWindowId() ); } - -xub_StrLen ScFormulaDlg::GetFunctionPos(xub_StrLen nPos) +void ScFormulaDlg::insertEntryToLRUList(const formula::IFunctionDescription* _pDesc) { - const sal_Unicode sep = ScCompiler::GetStringFromOpCode(ocSep).GetChar(0); - - xub_StrLen nTokPos=1; - xub_StrLen nOldTokPos=1; - xub_StrLen nFuncPos=STRING_NOTFOUND; //@ Testweise - xub_StrLen nPrevFuncPos=1; - short nBracketCount=0; - BOOL bFlag=FALSE; - String aFormString=pMEdit->GetText(); - ScGlobal::pCharClass->toUpper( aFormString ); - if(pScTokA!=NULL) - { - ScToken* pToken=pScTokA->First(); - while(pToken!=NULL) - { - String aString; - OpCode eOp = pToken->GetOpCode(); - pComp->CreateStringFromToken( aString,pToken); - ScToken* pNextToken=pScTokA->Next(); - - if(!bUserMatrixFlag && pToken->IsMatrixFunction()) - { - aBtnMatrix.Check(); - } - - if(eOp==ocPush || eOp==ocSpaces) - { - xub_StrLen n1=aFormString.Search(sep, nTokPos); - xub_StrLen n2=aFormString.Search(')',nTokPos); - xub_StrLen nXXX=nTokPos; - if(n1<n2) - { - nTokPos=n1; - } - else - { - nTokPos=n2; - } - if(pNextToken!=NULL) - { - String a2String; - pComp->CreateStringFromToken( a2String,pNextToken); - xub_StrLen n3=aFormString.Search(a2String,nXXX); - - if(n3<nTokPos) - nTokPos=n3; - } - } - else - { - nTokPos = sal::static_int_cast<xub_StrLen>( nTokPos + aString.Len() ); - } - - if(eOp==ocOpen) - { - nBracketCount++; - bFlag=TRUE; - } - else if(eOp==ocClose) - { - nBracketCount--; - bFlag=FALSE; - nFuncPos=nPrevFuncPos; - } - - if((pToken->IsFunction()|| ocArcTan2<=eOp) && ocSpaces!=eOp) - { - nPrevFuncPos=nFuncPos; - nFuncPos=nOldTokPos; - } - - if(nOldTokPos<=nPos && nPos<nTokPos) - { - if(!(pToken->IsFunction()|| ocArcTan2<=eOp)) - { - if(nBracketCount<1) - { - nFuncPos=pMEdit->GetText().Len(); - } - else if(!bFlag) - { - nFuncPos=nPrevFuncPos; - } - } - break; - } - - pToken=pNextToken; - nOldTokPos=nTokPos; - } - } - - return nFuncPos; + const ScFuncDesc* pDesc = dynamic_cast<const ScFuncDesc*>(_pDesc); + SaveLRUEntry(pDesc); } - -BOOL ScFormulaDlg::CalcStruct( const String& rStrExp) +void ScFormulaDlg::showReference(const String& _sFormula) { - BOOL bResult = TRUE; - xub_StrLen nLength=rStrExp.Len(); - - if ( rStrExp.Len() > 0 && aOldFormula!=rStrExp && bStructUpdate) - { - // nur, wenn keine Tastatureingabe mehr anliegt, den Wert berechnen: - - if ( !Application::AnyInput( INPUT_KEYBOARD ) ) - { - pScStructPage->ClearStruct(); - - String aString=rStrExp; - if(rStrExp.GetChar(nLength-1)=='(') - { - aString.Erase((xub_StrLen)(nLength-1)); - } - - aString.EraseAllChars('\n'); - String aStrResult; - - if ( CalcValue(aString, aStrResult ) ) - aWndFormResult.SetValue( aStrResult ); - - UpdateTokenArray(aString); - - ScToken* pScToken=pScTokA->LastRPN(); - - if(pScToken!=NULL) - { - MakeTree(NULL,pScToken,1,pScTokA,pComp); - } - aOldFormula=rStrExp; - if(rStrExp.GetChar(nLength-1)=='(') - UpdateTokenArray(rStrExp); - } - else - bResult = FALSE; - } - return bResult; + ShowReference(_sFormula); } - -IMPL_LINK( ScFormulaDlg, StructSelHdl, ScStructPage*, pStruP ) +void ScFormulaDlg::ShowReference(const String& _sFormula) { - bStructUpdate=FALSE; - if(pScStructPage->IsVisible()) aBtnForward.Enable(FALSE); //@New - - if(pScStructPage==pStruP) - { - ScToken* pSelToken = pScStructPage->GetSelectedToken(); - ScToken* pOrigToken = ((pSelToken && pSelToken->GetType() == svFAP) ? - pSelToken->GetFAPOrigToken() : pSelToken); - xub_StrLen nTokPos=1; - - if(pScTokA!=NULL) - { - ScToken* pToken = pScTokA->First(); - - while(pToken!=NULL) - { - String aString; - if ( pToken == pOrigToken ) - break; - pComp->CreateStringFromToken( aString,pToken); - nTokPos = sal::static_int_cast<xub_StrLen>( nTokPos + aString.Len() ); - pToken=pScTokA->Next(); - } - EditThisFunc(nTokPos); - } - - if( pOrigToken ) - { - String aStr; - pComp->CreateStringFromToken( aStr, pOrigToken ); - String aEntryTxt=pScStructPage->GetSelectedEntryText(); - - if(aEntryTxt!=aStr) - ShowReference(aEntryTxt); - } - - } - bStructUpdate=TRUE; - return 0; + m_aHelper.ShowReference(_sFormula); } - -ULONG ScFormulaDlg::FindFocusWin(Window *pWin) +void ScFormulaDlg::HideReference( BOOL bDoneRefMode ) { - ULONG nUniqueId=0; - if(pWin->HasFocus()) - { - nUniqueId=pWin->GetUniqueId(); - if(nUniqueId==0) - { - Window* pParent=pWin->GetParent(); - while(pParent!=NULL) - { - nUniqueId=pParent->GetUniqueId(); - - if(nUniqueId!=0) break; - - pParent=pParent->GetParent(); - } - } - } - else - { - USHORT nCount=pWin->GetChildCount(); - - for(USHORT i=0;i<nCount;i++) - { - Window* pChild=pWin->GetChild(i); - nUniqueId=FindFocusWin(pChild); - if(nUniqueId>0) break; - } - } - return nUniqueId; + m_aHelper.HideReference(bDoneRefMode); } - -void ScFormulaDlg::SetFocusWin(Window *pWin,ULONG nUniqueId) +void ScFormulaDlg::ViewShellChanged( ScTabViewShell* pScViewShell ) { - if(pWin->GetUniqueId()==nUniqueId) - { - pWin->GrabFocus(); - } - else - { - USHORT nCount=pWin->GetChildCount(); - - for(USHORT i=0;i<nCount;i++) - { - Window* pChild=pWin->GetChild(i); - SetFocusWin(pChild,nUniqueId); - } - } + m_aHelper.ViewShellChanged( pScViewShell ); } +void ScFormulaDlg::AddRefEntry( ) +{ -IMPL_LINK( ScFormulaDlg, MatrixHdl, CheckBox *, EMPTYARG ) +} +BOOL ScFormulaDlg::IsTableLocked( ) const { - bUserMatrixFlag=TRUE; - return 0; + // per Default kann bei Referenzeingabe auch die Tabelle umgeschaltet werden + return FALSE; } - -IMPL_LINK( ScFormulaDlg, FuncSelHdl, ScFuncPage*, EMPTYARG ) +void ScFormulaDlg::ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton) +{ + m_aHelper.ToggleCollapsed(pEdit,pButton); +} +void ScFormulaDlg::ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton) +{ + m_aHelper.ReleaseFocus(pEdit,pButton); +} +void ScFormulaDlg::dispatch(BOOL _bOK,BOOL _bMartixChecked) { - USHORT nCat = pScFuncPage->GetCategory(); - if ( nCat == LISTBOX_ENTRY_NOTFOUND ) nCat = 0; - USHORT nFunc = pScFuncPage->GetFunction(); - if ( nFunc == LISTBOX_ENTRY_NOTFOUND ) nFunc = 0; + SfxBoolItem aRetItem( SID_DLG_RETOK, _bOK ); + SfxBoolItem aMatItem( SID_DLG_MATRIX, _bMartixChecked ); + SfxStringItem aStrItem( SCITEM_STRING, getCurrentFormula() ); - if ( (pScFuncPage->GetFunctionEntryCount() > 0) - && (pScFuncPage->GetFunction() != LISTBOX_ENTRY_NOTFOUND) ) - { - const ScFuncDesc* pDesc =pScFuncPage->GetFuncDesc( - pScFuncPage->GetFunction() ); + // Wenn durch Dokument-Umschalterei die Eingabezeile weg war/ist, + // ist der String leer. Dann nicht die alte Formel loeschen. + if ( !aStrItem.GetValue().Len() ) + aRetItem.SetValue( FALSE ); // FALSE = Cancel - if(pDesc!=pFuncDesc) aBtnForward.Enable(TRUE); //new + m_aHelper.SetDispatcherLock( FALSE ); // Modal-Modus ausschalten - if (pDesc) - { - pDesc->InitArgumentInfo(); // full argument info is needed + clear(); - String aSig = pDesc->GetSignature(); - if(pDesc->pFuncName) - aFtHeadLine.SetText( *(pDesc->pFuncName) ); - else - aFtHeadLine.SetText( EMPTY_STRING); - aFtFuncName.SetText( aSig ); - if(pDesc->pFuncDesc) - aFtFuncDesc.SetText( *(pDesc->pFuncDesc) ); - else - aFtFuncDesc.SetText( EMPTY_STRING); - } - } - else - { - aFtHeadLine.SetText( EMPTY_STRING ); - aFtFuncName.SetText( EMPTY_STRING ); - aFtFuncDesc.SetText( EMPTY_STRING ); - } - return 0; + GetBindings().GetDispatcher()->Execute( SID_INS_FUNCTION, + SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, + &aRetItem, &aStrItem, &aMatItem, 0L ); } - -IMPL_LINK( ScFormulaDlg, UpdateFocusHdl, Timer*, EMPTYARG ) +void ScFormulaDlg::setDispatcherLock( BOOL bLock ) +{ + m_aHelper.SetDispatcherLock( bLock ); +} +void ScFormulaDlg::setReferenceInput(const formula::FormEditData* _pData) { ScModule* pScMod = SC_MOD(); - ScFormEditData* pData = pScMod->GetFormEditData(); - - if (pData) // wird nicht ueber Close zerstoert; - { - pScMod->SetRefInputHdl(pData->GetInputHandler()); - ULONG nUniqueId=pData->GetUniqueId(); - SetFocusWin((Window *)this,nUniqueId); - } - return 0; + ScFormEditData* pData = const_cast<ScFormEditData*>(dynamic_cast<const ScFormEditData*>(_pData)); + pScMod->SetRefInputHdl(pData->GetInputHandler()); } - -long ScFormulaDlg::PreNotify( NotifyEvent& rNEvt ) +void ScFormulaDlg::deleteFormData() { - USHORT nSwitch=rNEvt.GetType(); - if(nSwitch==EVENT_GETFOCUS && !bIsShutDown) - { - Window* pWin=rNEvt.GetWindow(); - if(pWin!=NULL) - { - nActivWinId=pWin->GetUniqueId(); - if(nActivWinId==0) - { - Window* pParent=pWin->GetParent(); - while(pParent!=NULL) - { - nActivWinId=pParent->GetUniqueId(); - - if(nActivWinId!=0) break; - - pParent=pParent->GetParent(); - } - } - if(nActivWinId!=0) - { - ScModule* pScMod = SC_MOD(); - ScFormEditData* pData = pScMod->GetFormEditData(); - - if (pData && !aTimer.IsActive()) // wird nicht ueber Close zerstoert; - { - pData->SetUniqueId(nActivWinId); - } - } - } - } - return ScAnyRefDlg::PreNotify(rNEvt); + ScModule* pScMod = SC_MOD(); + pScMod->ClearFormEditData(); // pData wird ungueltig! } - -String ScFormulaDlg::RepairFormula(const String& aFormula) +void ScFormulaDlg::clear() { - String aResult('='); - String aString2; - BOOL bSep=FALSE; - - ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); + pDoc = NULL; - UpdateTokenArray(aFormula); + //Referenz Inputhandler zuruecksetzen + ScModule* pScMod = SC_MOD(); + pScMod->SetRefInputHdl(NULL); - if(pScTokA!=NULL) + // Enable() der Eingabezeile erzwingen: + ScTabViewShell* pScViewShell = PTR_CAST(ScTabViewShell, SfxViewShell::Current()); + if ( pScViewShell ) + pScViewShell->UpdateInputHandler(); +} +void ScFormulaDlg::switchBack() +{ + ScModule* pScMod = SC_MOD(); + // auf das Dokument zurueckschalten + // (noetig, weil ein fremdes oben sein kann - #34222#) + ScInputHandler* pHdl = pScMod->GetInputHdl(); + if ( pHdl ) { - ScToken* pToken=pScTokA->First(); - while(pToken!=NULL) - { - String aString; - OpCode eOp = pToken->GetOpCode(); - pComp->CreateStringFromToken( aString,pToken); - ScToken* pNextToken=pScTokA->Next(); - - if(eOp==ocSep) - { - bSep=TRUE; - //aResult+=aString2; - aString2+=aString; - } - else if(eOp==ocClose &&bSep) - { - aString2.Erase(); - bSep=FALSE; - aResult+=aString; - } - else if(eOp!=ocSpaces) - { - if(bSep) - { - aResult+=aString2; - aString2.Erase(); - bSep=FALSE; - } - aResult+=aString; - } - - const ScFuncDesc* pDesc= pFuncMgr->Get(aString); + pHdl->ViewShellGone(NULL); // -> aktive View neu holen + pHdl->ShowRefFrame(); + } - SaveLRUEntry(pDesc); //! is this necessary?? (EnterData updates the list) + // aktuelle Tabelle ggF. restaurieren (wg. Maus-RefInput) + ScTabViewShell* pScViewShell = PTR_CAST(ScTabViewShell, SfxViewShell::Current()); + if ( pScViewShell ) + { + ScViewData* pVD=pScViewShell->GetViewData(); + SCTAB nExecTab = aCursorPos.Tab(); + if ( nExecTab != pVD->GetTabNo() ) + pScViewShell->SetTabNo( nExecTab ); - pToken=pNextToken; - } + SCROW nRow=aCursorPos.Row(); + SCCOL nCol=aCursorPos.Col(); + if(pVD->GetCurX()!=nCol || pVD->GetCurY()!=nRow) + pScViewShell->SetCursor(nCol,nRow); } - - return aResult; } - -void ScFormulaDlg::HighlightFunctionParas(const String& aFormula) +formula::FormEditData* ScFormulaDlg::getFormEditData() const { - ShowReference(aFormula); + ScModule* pScMod = SC_MOD(); + return pScMod->GetFormEditData(); } - -void ScFormulaDlg::SaveLRUEntry(const ScFuncDesc* pFuncDescP) +void ScFormulaDlg::setCurrentFormula(const String& _sReplacement) { - if (pFuncDescP && pFuncDescP->nFIndex!=0) - { - ScModule* pScMod = SC_MOD(); - pScMod->InsertEntryToLRUList(pFuncDescP->nFIndex); - } + ScModule* pScMod = SC_MOD(); + pScMod->InputReplaceSelection(_sReplacement); } - -ScRefEdit* ScFormulaDlg::GetCurrRefEdit() +void ScFormulaDlg::setSelection(xub_StrLen _nStart,xub_StrLen _nEnd) { - return aEdRef.IsVisible() ? &aEdRef : aScParaWin.GetActiveEdit(); + ScModule* pScMod = SC_MOD(); + pScMod->InputSetSelection( _nStart, _nEnd ); +} +void ScFormulaDlg::getSelection(xub_StrLen& _nStart,xub_StrLen& _nEnd) const +{ + ScModule* pScMod = SC_MOD(); + pScMod->InputGetSelection( _nStart, _nEnd ); +} +String ScFormulaDlg::getCurrentFormula() const +{ + ScModule* pScMod = SC_MOD(); + return pScMod->InputGetFormulaStr(); +} +formula::IFunctionManager* ScFormulaDlg::getFunctionManager() +{ + return ScGlobal::GetStarCalcFunctionMgr(); +} +uno::Reference< sheet::XFormulaParser> ScFormulaDlg::getFormulaParser() const +{ + return m_xParser; +} +uno::Reference< sheet::XFormulaOpCodeMapper> ScFormulaDlg::getFormulaOpCodeMapper() const +{ + return m_xOpCodeMapper; +} +::std::auto_ptr<formula::FormulaTokenArray> ScFormulaDlg::convertToTokenArray(const uno::Sequence< sheet::FormulaToken >& _aTokenList) +{ + ::std::auto_ptr<formula::FormulaTokenArray> pArray(new ScTokenArray()); + pArray->Fill(_aTokenList); + return pArray; } - diff --git a/sc/source/ui/formdlg/funcpage.cxx b/sc/source/ui/formdlg/funcpage.cxx deleted file mode 100644 index 4d2570d5f4d1..000000000000 --- a/sc/source/ui/formdlg/funcpage.cxx +++ /dev/null @@ -1,253 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: funcpage.cxx,v $ - * $Revision: 1.7.32.1 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - - - -//---------------------------------------------------------------------------- - -#include "scitems.hxx" -#include <sfx2/dispatch.hxx> -#include <sfx2/docfile.hxx> -#include <sfx2/objsh.hxx> -#include <svtools/zforlist.hxx> -#include <svtools/stritem.hxx> - -#include "funcpage.hxx" -#include "formdlgs.hrc" -#include "formdata.hxx" -#include "globstr.hrc" -#include "scresid.hxx" -#include "reffact.hxx" -#include "document.hxx" -#include "cell.hxx" -#include "scmod.hxx" -#include "inputhdl.hxx" -#include "tabvwsh.hxx" -#include "appoptio.hxx" -#include "funcdesc.hxx" - -//============================================================================ - -ScListBox::ScListBox( Window* pParent, const ResId& rResId ): - ListBox(pParent,rResId) -{} - -void ScListBox::KeyInput( const KeyEvent& rKEvt ) -{ - KeyEvent aKEvt=rKEvt; - //ListBox::KeyInput(rKEvt); - - if(aKEvt.GetCharCode()==' ') - DoubleClick(); -} - -long ScListBox::PreNotify( NotifyEvent& rNEvt ) -{ - NotifyEvent aNotifyEvt=rNEvt; - - long nResult=ListBox::PreNotify(rNEvt); - - USHORT nSwitch=aNotifyEvt.GetType(); - if(nSwitch==EVENT_KEYINPUT) - { - KeyInput(*aNotifyEvt.GetKeyEvent()); - } - return nResult; -} - - - -//============================================================================ - -inline USHORT Lb2Cat( USHORT nLbPos ) -{ - // Kategorie 0 == LRU, sonst Categories == LbPos-1 - if ( nLbPos > 0 ) - nLbPos -= 1; - - return nLbPos; -} - -//============================================================================ - -ScFuncPage::ScFuncPage(Window* pParent): - TabPage(pParent,ScResId(RID_SCTAB_FUNCTION)), - // - aFtCategory ( this, ScResId( FT_CATEGORY ) ), - aLbCategory ( this, ScResId( LB_CATEGORY ) ), - aFtFunction ( this, ScResId( FT_FUNCTION ) ), - aLbFunction ( this, ScResId( LB_FUNCTION ) ), - aIBFunction ( this, ScResId( IB_FUNCTION ) ) -{ - FreeResource(); - InitLRUList(); - aLbCategory.SelectEntryPos(1); - UpdateFunctionList(); - aLbCategory.SetSelectHdl( LINK( this, ScFuncPage, SelHdl ) ); - aLbFunction.SetSelectHdl( LINK( this, ScFuncPage, SelHdl ) ); - aLbFunction.SetDoubleClickHdl( LINK( this, ScFuncPage, DblClkHdl ) ); - aIBFunction.SetClickHdl( LINK( this, ScFuncPage, DblClkHdl ) ); -} - -void ScFuncPage::UpdateFunctionList() -{ - USHORT nSelPos = aLbCategory.GetSelectEntryPos(); - USHORT nCategory = ( LISTBOX_ENTRY_NOTFOUND != nSelPos ) - ? Lb2Cat( nSelPos ) : 0; - - aLbFunction.Clear(); - aLbFunction.SetUpdateMode( FALSE ); - //------------------------------------------------------ - - if ( nSelPos > 0 ) - { - ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); - - const ScFuncDesc* pDesc = pFuncMgr->First( nCategory ); - while ( pDesc ) - { - aLbFunction.SetEntryData( - aLbFunction.InsertEntry(*(pDesc->pFuncName) ),(void*)pDesc ); - pDesc = pFuncMgr->Next(); - } - } - else // LRU-Liste - { - for ( USHORT i=0; i<LRU_MAX && aLRUList[i]; i++ ) - { - const ScFuncDesc* pDesc = aLRUList[i]; - aLbFunction.SetEntryData( - aLbFunction.InsertEntry( *(pDesc->pFuncName) ),(void*)pDesc ); - } - } - - //------------------------------------------------------ - aLbFunction.SetUpdateMode( TRUE ); - aLbFunction.SelectEntryPos(0); - - if(IsVisible()) SelHdl(&aLbFunction); -} - -IMPL_LINK( ScFuncPage, SelHdl, ListBox*, pLb ) -{ - if(pLb==&aLbFunction) - { - aSelectionLink.Call(this); - } - else - { - UpdateFunctionList(); - } - return 0; -} - -IMPL_LINK( ScFuncPage, DblClkHdl, ListBox*, EMPTYARG ) -{ - aDoubleClickLink.Call(this); - return 0; -} - -void ScFuncPage::SetCategory(USHORT nCat) -{ - aLbCategory.SelectEntryPos(nCat); - UpdateFunctionList(); -} - -void ScFuncPage::SetFunction(USHORT nFunc) -{ - aLbFunction.SelectEntryPos(nFunc); -} - -void ScFuncPage::SetFocus() -{ - aLbFunction.GrabFocus(); -} - -USHORT ScFuncPage::GetCategory() -{ - return aLbCategory.GetSelectEntryPos(); -} - -USHORT ScFuncPage::GetFunction() -{ - return aLbFunction.GetSelectEntryPos(); -} - -USHORT ScFuncPage::GetFunctionEntryCount() -{ - return aLbFunction.GetSelectEntryCount(); -} - -const ScFuncDesc* ScFuncPage::GetFuncDesc( USHORT nPos ) const -{ - // nicht schoen, aber hoffentlich selten - return (const ScFuncDesc*) aLbFunction.GetEntryData(nPos); -} - -USHORT ScFuncPage::GetFuncPos(const ScFuncDesc* pFuncDesc) -{ - if(pFuncDesc!=NULL && pFuncDesc->pFuncName!=NULL) - { - return aLbFunction.GetEntryPos(*(pFuncDesc->pFuncName)); - } - else - { - return LISTBOX_ENTRY_NOTFOUND; - } -} -String ScFuncPage::GetSelFunctionName() const -{ - return aLbFunction.GetSelectEntry(); -} - -void ScFuncPage::InitLRUList() -{ - const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions(); - USHORT nLRUFuncCount = Min( rAppOpt.GetLRUFuncListCount(), (USHORT)LRU_MAX ); - USHORT* pLRUListIds = rAppOpt.GetLRUFuncList(); - - USHORT i; - for ( i=0; i<LRU_MAX; i++ ) - aLRUList[i] = NULL; - - if ( pLRUListIds ) - { - ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); - for ( i=0; i<nLRUFuncCount; i++ ) - aLRUList[i] = pFuncMgr->Get( pLRUListIds[i] ); - } -} - - - - diff --git a/sc/source/ui/formdlg/funcutl.cxx b/sc/source/ui/formdlg/funcutl.cxx deleted file mode 100644 index cdfac01eda8a..000000000000 --- a/sc/source/ui/formdlg/funcutl.cxx +++ /dev/null @@ -1,859 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: funcutl.cxx,v $ - * $Revision: 1.9.32.2 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - - - -//---------------------------------------------------------------------------- - -#include <vcl/sound.hxx> -#include <vcl/svapp.hxx> - -#include "funcutl.hxx" - - -//============================================================================ -// class ValWnd -//---------------------------------------------------------------------------- - -ValWnd::ValWnd( Window* pParent, const ResId& rId ) : Window( pParent, rId ) -{ - Font aFnt( GetFont() ); - aFnt.SetTransparent( TRUE ); - aFnt.SetWeight( WEIGHT_LIGHT ); - if ( pParent->IsBackground() ) - { - Wallpaper aBack = pParent->GetBackground(); - SetFillColor( aBack.GetColor() ); - SetBackground( aBack ); - aFnt.SetFillColor( aBack.GetColor() ); - } - else - { - SetFillColor(); - SetBackground(); - } - SetFont( aFnt ); - SetLineColor(); - - Size aSzWnd = GetOutputSizePixel(); - long nHeight = GetTextHeight(); - long nDiff = aSzWnd.Height()-nHeight; - - aRectOut = Rectangle( Point( 1, ( nDiff<2 ) ? 1 : nDiff/2), - Size ( aSzWnd.Width()-2, nHeight ) ); - SetClipRegion( Region( aRectOut ) ); -} - -//---------------------------------------------------------------------------- - -void __EXPORT ValWnd::Paint( const Rectangle& ) -{ - DrawText( aRectOut.TopLeft(), aStrValue ); -} - -//---------------------------------------------------------------------------- - -void ValWnd::SetValue( const String& rStrVal ) -{ - if ( aStrValue != rStrVal ) - { - aStrValue = rStrVal; - DrawRect( aRectOut ); // alten Text loeschen - Paint( aRectOut ); // und neu malen - } -} - -//============================================================================ -// class ArgEdit -//---------------------------------------------------------------------------- - -ArgEdit::ArgEdit( Window* pParent, const ResId& rResId ) - : ScRefEdit( pParent, rResId ), - pEdPrev ( NULL ), - pEdNext ( NULL ), - pSlider ( NULL ), - nArgs ( 0 ) -{ -} - -//---------------------------------------------------------------------------- - -void ArgEdit::Init( ArgEdit* pPrevEdit, ArgEdit* pNextEdit, - ScrollBar& rArgSlider, USHORT nArgCount ) -{ - pEdPrev = pPrevEdit; - pEdNext = pNextEdit; - pSlider = &rArgSlider; - nArgs = nArgCount; -} - -//---------------------------------------------------------------------------- - -// Cursorsteuerung fuer EditFelder im Argument-Dialog - -void __EXPORT ArgEdit::KeyInput( const KeyEvent& rKEvt ) -{ - KeyCode aCode = rKEvt.GetKeyCode(); - BOOL bUp = (aCode.GetCode() == KEY_UP); - BOOL bDown = (aCode.GetCode() == KEY_DOWN); - ArgEdit* pEd = NULL; - - if ( pSlider - && ( !aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() ) - && ( bUp || bDown ) ) - { - if ( nArgs > 1 ) - { - long nThumb = pSlider->GetThumbPos(); - BOOL bDoScroll = FALSE; - BOOL bChangeFocus = FALSE; - - if ( bDown ) - { - if ( nArgs > 4 ) - { - if ( !pEdNext ) - { - nThumb++; - bDoScroll = ( nThumb+3 < (long)nArgs ); - } - else - { - pEd = pEdNext; - bChangeFocus = TRUE; - } - } - else if ( pEdNext ) - { - pEd = pEdNext; - bChangeFocus = TRUE; - } - } - else // if ( bUp ) - { - if ( nArgs > 4 ) - { - if ( !pEdPrev ) - { - nThumb--; - bDoScroll = ( nThumb >= 0 ); - } - else - { - pEd = pEdPrev; - bChangeFocus = TRUE; - } - } - else if ( pEdPrev ) - { - pEd = pEdPrev; - bChangeFocus = TRUE; - } - } - - if ( bDoScroll ) - { - pSlider->SetThumbPos( nThumb ); - ((Link&)pSlider->GetEndScrollHdl()).Call( pSlider ); - } - else if ( bChangeFocus ) - { - pEd->GrabFocus(); - } - else - Sound::Beep(); - } - else - Sound::Beep(); - } - else - ScRefEdit::KeyInput( rKEvt ); -} - - - - -/************************************************************************* -#* Member: ArgInput Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Konstruktor der Klasse ArgInput -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -ArgInput::ArgInput() -{ - pFtArg=NULL; - pBtnFx=NULL; - pEdArg=NULL; - pRefBtn=NULL; -} - -/************************************************************************* -#* Member: InitArgInput Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Initialisiert die Pointer der Klasse -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -void ArgInput::InitArgInput(FixedText* pftArg, - ImageButton* pbtnFx, - ArgEdit* pedArg, - ScRefButton* prefBtn) -{ - pFtArg =pftArg; - pBtnFx =pbtnFx; - pEdArg =pedArg; - pRefBtn=prefBtn; - - if(pBtnFx!=NULL) - { - pBtnFx->SetClickHdl ( LINK( this, ArgInput, FxBtnClickHdl ) ); - pBtnFx->SetGetFocusHdl( LINK( this, ArgInput, FxBtnFocusHdl ) ); - } - if(pRefBtn!=NULL) - { - pRefBtn->SetClickHdl ( LINK( this, ArgInput, RefBtnClickHdl ) ); - pRefBtn->SetGetFocusHdl( LINK( this, ArgInput, RefBtnFocusHdl ) ); - } - if(pEdArg!=NULL) - { - pEdArg->SetGetFocusHdl ( LINK( this, ArgInput, EdFocusHdl ) ); - pEdArg->SetModifyHdl ( LINK( this, ArgInput, EdModifyHdl ) ); - } - -} - -/************************************************************************* -#* Member: SetArgName Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Setzt den Namen fuer das Argument -#* -#* Input: String -#* -#* Output: --- -#* -#************************************************************************/ -void ArgInput::SetArgName(const String &aArg) -{ - if(pFtArg !=NULL) pFtArg->SetText(aArg ); -} - -/************************************************************************* -#* Member: GetArgName Datum:06.02.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Liefert den Namen fuer das Argument zurueck -#* -#* Input: String -#* -#* Output: --- -#* -#************************************************************************/ -String ArgInput::GetArgName() -{ - String aPrivArgName; - if(pFtArg !=NULL) - aPrivArgName=pFtArg->GetText(); - - return aPrivArgName; -} - - -/************************************************************************* -#* Member: SetArgName Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Setzt den Namen fuer das Argument -#* -#* Input: String -#* -#* Output: --- -#* -#************************************************************************/ -void ArgInput::SetArgNameFont (const Font &aFont) -{ - if(pFtArg !=NULL) pFtArg->SetFont(aFont); -} - -/************************************************************************* -#* Member: SetArgSelection Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Stellt die Selection fuer die EditBox ein. -#* -#* Input: String -#* -#* Output: --- -#* -#************************************************************************/ -void ArgInput::SetArgSelection (const Selection& rSel ) -{ - if(pEdArg !=NULL) pEdArg ->SetSelection(rSel ); -} - -/************************************************************************* -#* Member: SetArgVal Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Setzt den Wert fuer das Argument -#* -#* Input: String -#* -#* Output: --- -#* -#************************************************************************/ -void ArgInput::SetArgVal(const String &aVal) -{ - if(pEdArg !=NULL) - { - pEdArg ->SetRefString(aVal ); - } -} - -/************************************************************************* -#* Member: SetArgName Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Liefert den Wert fuer das Argument -#* -#* Input: --- -#* -#* Output: String -#* -#************************************************************************/ -String ArgInput::GetArgVal() -{ - String aResult; - if(pEdArg!=NULL) - { - aResult=pEdArg->GetText(); - } - return aResult; -} - -/************************************************************************* -#* Member: SetArgName Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Versteckt die Controls -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -void ArgInput::Hide() -{ - if ( pFtArg && pBtnFx && pEdArg && pRefBtn) - { - pFtArg->Hide(); - pBtnFx->Hide(); - pEdArg->Hide(); - pRefBtn->Hide(); - } -} - -/************************************************************************* -#* Member: SetArgName Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Zaubert die Controls wieder hervor. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -void ArgInput::Show() -{ - if ( pFtArg && pBtnFx && pEdArg && pRefBtn) - { - pFtArg->Show(); - pBtnFx->Show(); - pEdArg->Show(); - pRefBtn->Show(); - } -} - -/************************************************************************* -#* Member: FxClick Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Gibt den Event weiter. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -void ArgInput::FxClick() -{ - aFxClickLink.Call(this); -} - -/************************************************************************* -#* Member: RefClick Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Gibt den Event weiter. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -void ArgInput::RefClick() -{ - aRefClickLink.Call(this); -} - -/************************************************************************* -#* Member: FxFocus Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Gibt den Event weiter. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -void ArgInput::FxFocus() -{ - aFxFocusLink.Call(this); -} - -/************************************************************************* -#* Member: RefFocus Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Gibt den Event weiter. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -void ArgInput::RefFocus() -{ - aRefFocusLink.Call(this); -} - -/************************************************************************* -#* Member: EdFocus Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Gibt den Event weiter. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -void ArgInput::EdFocus() -{ - aEdFocusLink.Call(this); -} - -/************************************************************************* -#* Member: EdModify Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Gibt den Event weiter. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -void ArgInput::EdModify() -{ - aEdModifyLink.Call(this); -} - -/************************************************************************* -#* Handle: FxBtnHdl Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Handle fuer Fx-Button Click-Event. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -IMPL_LINK( ArgInput, FxBtnClickHdl, ImageButton*, pBtn ) -{ - if(pBtn==pBtnFx) FxClick(); - - return 0; -} - -/************************************************************************* -#* Handle: RefBtnClickHdl Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Handle fuer Fx-Button Click-Event. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -IMPL_LINK( ArgInput, RefBtnClickHdl,ScRefButton*, pBtn ) -{ - if(pRefBtn==pBtn) RefClick(); - - return 0; -} - -/************************************************************************* -#* Handle: FxBtnFocusHdl Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Handle fuer Fx-Button Focus-Event. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -IMPL_LINK( ArgInput, FxBtnFocusHdl, ImageButton*, pBtn ) -{ - if(pBtn==pBtnFx) FxFocus(); - - return 0; -} - -/************************************************************************* -#* Handle: RefBtnFocusHdl Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Handle fuer Fx-Button Focus-Event. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -IMPL_LINK( ArgInput, RefBtnFocusHdl,ScRefButton*, pBtn ) -{ - if(pRefBtn==pBtn) RefFocus(); - - return 0; -} - -/************************************************************************* -#* Handle: EdFocusHdl Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Handle fuer Fx-Button Focus-Event. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -IMPL_LINK( ArgInput, EdFocusHdl, ArgEdit*, pEd ) -{ - if(pEd==pEdArg) EdFocus(); - - return 0; -} - -/************************************************************************* -#* Handle: RefBtnClickHdl Datum:13.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ArgInput -#* -#* Funktion: Handle fuer Fx-Button Focus-Event. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -IMPL_LINK( ArgInput, EdModifyHdl,ArgEdit*, pEd ) -{ - if(pEd==pEdArg) EdModify(); - - return 0; -} - -/************************************************************************* -#* Member: ScEditBox Datum:20.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScEditBox -#* -#* Funktion: Konstruktor der Klasse ArgInput -#* -#* Input: Parent, Resource -#* -#* Output: --- -#* -#************************************************************************/ -ScEditBox::ScEditBox( Window* pParent, const ResId& rResId ) - :Control(pParent,rResId), - bMouseFlag(FALSE) -{ - WinBits nStyle=GetStyle(); - SetStyle( nStyle| WB_DIALOGCONTROL); - - pMEdit=new MultiLineEdit(this,WB_LEFT | WB_VSCROLL | (nStyle & WB_TABSTOP) | - WB_NOBORDER | WB_NOHIDESELECTION | WB_IGNORETAB); - pMEdit->Show(); - aOldSel=pMEdit->GetSelection(); - Resize(); - WinBits nWinStyle=GetStyle() | WB_DIALOGCONTROL; - SetStyle(nWinStyle); - - // #105582# the HelpId from the resource must be set for the MultiLineEdit, - // not for the control that contains it. - pMEdit->SetHelpId( GetHelpId() ); - SetHelpId( 0 ); -} - -ScEditBox::~ScEditBox() -{ - MultiLineEdit* pTheEdit=pMEdit; - pMEdit->Disable(); - pMEdit=NULL; - delete pTheEdit; -} -/************************************************************************* -#* Member: ScEditBox Datum:20.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScEditBox -#* -#* Funktion: Wenn sich die Selektion geaendert hat, so wird -#* diese Funktion aufgerufen. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -void ScEditBox::SelectionChanged() -{ - aSelChangedLink.Call(this); -} - -/************************************************************************* -#* Member: ScEditBox Datum:20.05.98 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScEditBox -#* -#* Funktion: Wenn sich die Groesse geaendert hat, so muss -#* auch der MultiLineEdit angepasst werden.. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -void ScEditBox::Resize() -{ - Size aSize=GetOutputSizePixel(); - if(pMEdit!=NULL) pMEdit->SetOutputSizePixel(aSize); -} - -/************************************************************************* -#* Member: GetFocus Datum:26.05.98 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScEditBox -#* -#* Funktion: Wenn der Control aktiviert wird, so wird -#* die Selection aufgehoben und der Cursor ans -#* Ende gesetzt. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ -void ScEditBox::GetFocus() -{ - if(pMEdit!=NULL) - { - pMEdit->GrabFocus(); - } -} - - - -/************************************************************************* -#* Member: ScEditBox Datum:20.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScEditBox -#* -#* Funktion: Wenn ein Event ausgeloest wird, so wird diese Routine -#* zuerst aufgerufen und ein PostUserEvent verschickt. -#* -#* Input: Notify-Event -#* -#* Output: --- -#* -#************************************************************************/ -long ScEditBox::PreNotify( NotifyEvent& rNEvt ) -{ - long nResult=TRUE; - - if(pMEdit==NULL) return nResult; - - USHORT nSwitch=rNEvt.GetType(); - if(nSwitch==EVENT_KEYINPUT)// || nSwitch==EVENT_KEYUP) - { - const KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode(); - USHORT nKey=aKeyCode.GetCode(); - if(nKey==KEY_RETURN && (!aKeyCode.IsShift() || nKey==KEY_TAB)) - { - nResult=GetParent()->Notify(rNEvt); - } - else - { - nResult=Control::PreNotify(rNEvt); - Application::PostUserEvent( LINK( this, ScEditBox, ChangedHdl ) ); - } - - } - else - { - nResult=Control::PreNotify(rNEvt); - - if(nSwitch==EVENT_MOUSEBUTTONDOWN || nSwitch==EVENT_MOUSEBUTTONUP) - { - bMouseFlag=TRUE; - Application::PostUserEvent( LINK( this, ScEditBox, ChangedHdl ) ); - } - } - return nResult; -} - -/************************************************************************* -#* Member: ScEditBox Datum:21.01.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScEditBox -#* -#* Funktion: Wenn ein Event ausgeloest wurde, so wird diese Routine -#* zuerst aufgerufen. -#* -#* Input: Key-Event -#* -#* Output: --- -#* -#************************************************************************/ -IMPL_LINK( ScEditBox, ChangedHdl, ScEditBox*, EMPTYARG ) -{ - if(pMEdit!=NULL) - { - Selection aNewSel=pMEdit->GetSelection(); - - if(aNewSel.Min()!=aOldSel.Min() || aNewSel.Max()!=aOldSel.Max()) - { - SelectionChanged(); - aOldSel=aNewSel; - } - } - return 0; -} - -void ScEditBox::UpdateOldSel() -{ - // if selection is set for editing a function, store it as aOldSel, - // so SelectionChanged isn't called in the next ChangedHdl call - - if (pMEdit) - aOldSel = pMEdit->GetSelection(); -} - - diff --git a/sc/source/ui/formdlg/makefile.mk b/sc/source/ui/formdlg/makefile.mk index a9370a6cd3c0..dd705c8085ff 100644 --- a/sc/source/ui/formdlg/makefile.mk +++ b/sc/source/ui/formdlg/makefile.mk @@ -43,35 +43,16 @@ TARGET=formdlgs # --- Files -------------------------------------------------------- -CXXFILES = \ - funcutl.cxx \ - parawin.cxx \ - structpg.cxx \ - funcpage.cxx \ - formula.cxx \ - formdata.cxx \ - privsplt.cxx \ - dwfunctr.cxx - SLOFILES = \ - $(SLO)$/funcutl.obj \ - $(SLO)$/parawin.obj \ - $(SLO)$/structpg.obj \ - $(SLO)$/funcpage.obj \ $(SLO)$/formula.obj \ - $(SLO)$/formdata.obj \ + $(SLO)$/formdata.obj \ $(SLO)$/privsplt.obj \ $(SLO)$/dwfunctr.obj SRS1NAME=$(TARGET) SRC1FILES = \ - parawin.src \ - formdlgs.src \ dwfunctr.src -EXCEPTIONSFILES+= \ - $(SLO)$/parawin.obj \ - # --- Tagets ------------------------------------------------------- .INCLUDE : target.mk diff --git a/sc/source/ui/formdlg/parawin.cxx b/sc/source/ui/formdlg/parawin.cxx deleted file mode 100644 index 8d40eb741c7a..000000000000 --- a/sc/source/ui/formdlg/parawin.cxx +++ /dev/null @@ -1,615 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: parawin.cxx,v $ - * $Revision: 1.10 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - - - -//---------------------------------------------------------------------------- - -#include "scitems.hxx" -#include <sfx2/dispatch.hxx> -#include <sfx2/docfile.hxx> -#include <sfx2/objsh.hxx> -#include <svtools/zforlist.hxx> -#include <svtools/stritem.hxx> - -#include "parawin.hxx" -#include "parawin.hrc" -#include "formdata.hxx" -#include "globstr.hrc" -#include "scresid.hxx" -#include "reffact.hxx" -#include "document.hxx" -#include "cell.hxx" -#include "scmod.hxx" -#include "inputhdl.hxx" -#include "tabvwsh.hxx" -#include "appoptio.hxx" -#include "compiler.hxx" -#include "funcdesc.hxx" - -//============================================================================ - -ScParaWin::ScParaWin(ScAnyRefDlg* pParent,Point aPos): - TabPage (pParent,ScResId(RID_SCTAB_PARAMETER)), - pFuncDesc ( NULL ), - aFtEditDesc ( this, ScResId( FT_EDITDESC ) ), - aFtArgName ( this, ScResId( FT_PARNAME ) ), - aFtArgDesc ( this, ScResId( FT_PARDESC ) ), - - aBtnFx1 ( this, ScResId( BTN_FX1 ) ), - aFtArg1 ( this, ScResId( FT_ARG1 ) ), - aEdArg1 ( this, ScResId( ED_ARG1 ) ), - aRefBtn1 ( this, ScResId( RB_ARG1 ) ), - aBtnFx2 ( this, ScResId( BTN_FX2 ) ), - aFtArg2 ( this, ScResId( FT_ARG2 ) ), - aEdArg2 ( this, ScResId( ED_ARG2 ) ), - aRefBtn2 ( this, ScResId( RB_ARG2 ) ), - aBtnFx3 ( this, ScResId( BTN_FX3 ) ), - aFtArg3 ( this, ScResId( FT_ARG3 ) ), - aEdArg3 ( this, ScResId( ED_ARG3 ) ), - aRefBtn3 ( this, ScResId( RB_ARG3 ) ), - aBtnFx4 ( this, ScResId( BTN_FX4 ) ), - aFtArg4 ( this, ScResId( FT_ARG4 ) ), - aEdArg4 ( this, ScResId( ED_ARG4 ) ), - aRefBtn4 ( this, ScResId( RB_ARG4 ) ), - aSlider ( this, ScResId( WND_SLIDER ) ), - bRefMode (FALSE) -{ - Image aFxHC( ScResId( IMG_FX_H ) ); - FreeResource(); - aDefaultString=aFtEditDesc.GetText(); - pMyParent=pParent; - SetPosPixel(aPos); - nEdFocus=NOT_FOUND; - nActiveLine=0; - Size aSize = aSlider.GetSizePixel(); - aSize.Width() = GetSettings().GetStyleSettings().GetScrollBarSize(); - aSlider.SetSizePixel( aSize ); - aSlider.SetEndScrollHdl( LINK( this, ScParaWin, ScrollHdl ) ); - aSlider.SetScrollHdl( LINK( this, ScParaWin, ScrollHdl ) ); - - aBtnFx1.SetModeImage( aFxHC, BMP_COLOR_HIGHCONTRAST ); - aBtnFx2.SetModeImage( aFxHC, BMP_COLOR_HIGHCONTRAST ); - aBtnFx3.SetModeImage( aFxHC, BMP_COLOR_HIGHCONTRAST ); - aBtnFx4.SetModeImage( aFxHC, BMP_COLOR_HIGHCONTRAST ); - - InitArgInput( 0, aFtArg1, aBtnFx1, aEdArg1, aRefBtn1); - InitArgInput( 1, aFtArg2, aBtnFx2, aEdArg2, aRefBtn2); - InitArgInput( 2, aFtArg3, aBtnFx3, aEdArg3, aRefBtn3); - InitArgInput( 3, aFtArg4, aBtnFx4, aEdArg4, aRefBtn4); - ClearAll(); -} - -void ScParaWin::UpdateArgDesc( USHORT nArg ) -{ - if (nArg==NOT_FOUND) return; - - if ( nArgs > 4 ) - nArg = sal::static_int_cast<USHORT>( nArg + GetSliderPos() ); - //@ nArg += (USHORT)aSlider.GetThumbPos(); - - if ( (nArgs > 0) && (nArg<nArgs) ) - { - String aArgDesc; - String aArgName; - - SetArgumentDesc( EMPTY_STRING ); - SetArgumentText( EMPTY_STRING ); - - if ( nArgs < VAR_ARGS ) - { - USHORT nRealArg = aVisibleArgMapping[nArg]; - aArgDesc = *(pFuncDesc->ppDefArgDescs[nRealArg]); - aArgName = *(pFuncDesc->ppDefArgNames[nRealArg]); - aArgName += ' '; - aArgName += ScGlobal::GetRscString( - (pFuncDesc->pDefArgFlags[nRealArg].bOptional) ? - STR_OPTIONAL : STR_REQUIRED ); - } - else - { - USHORT nFix = nArgs - VAR_ARGS; - USHORT nPos = ( nArg < nFix ? nArg : nFix ); - USHORT nRealArg = (nPos < aVisibleArgMapping.size() ? - aVisibleArgMapping[nPos] : aVisibleArgMapping.back()); - aArgDesc = *(pFuncDesc->ppDefArgDescs[nRealArg]); - aArgName = *(pFuncDesc->ppDefArgNames[nRealArg]); - if ( nArg >= nFix ) - aArgName += String::CreateFromInt32(nArg-nFix+1); - aArgName += ' '; - aArgName += ScGlobal::GetRscString( - (nArg > nFix || pFuncDesc->pDefArgFlags[nRealArg].bOptional) ? - STR_OPTIONAL : STR_REQUIRED ); - } - - SetArgumentDesc(aArgDesc); - SetArgumentText(aArgName); - } -} - -void ScParaWin::UpdateArgInput( USHORT nOffset, USHORT i ) -{ - USHORT nArg = nOffset + i; - if ( nArgs < VAR_ARGS) - { - if(nArg<nArgs) - { - USHORT nRealArg = aVisibleArgMapping[nArg]; - SetArgNameFont (i,(pFuncDesc->pDefArgFlags[nRealArg].bOptional) - ? aFntLight : aFntBold ); - SetArgName (i,*(pFuncDesc->ppDefArgNames[nRealArg])); - } - } - else - { - USHORT nFix = nArgs - VAR_ARGS; - USHORT nPos = ( nArg < nFix ? nArg : nFix ); - USHORT nRealArg = (nPos < aVisibleArgMapping.size() ? - aVisibleArgMapping[nPos] : aVisibleArgMapping.back()); - SetArgNameFont( i, - (nArg > nFix || pFuncDesc->pDefArgFlags[nRealArg].bOptional) ? - aFntLight : aFntBold ); - if ( nArg >= nFix ) - { - String aArgName( *(pFuncDesc->ppDefArgNames[nRealArg]) ); - aArgName += String::CreateFromInt32(nArg-nFix+1); - SetArgName( i, aArgName ); - } - else - SetArgName( i, *(pFuncDesc->ppDefArgNames[nRealArg]) ); - } - if(nArg<nArgs) SetArgVal(i,*(aParaArray[nArg])); - //@ aArgInput[i].SetArgVal( *(pArgArr[nOffset+i]) ); - -} - -ScParaWin::~ScParaWin() -{ - DelParaArray(); - - // #i66422# if the focus changes during destruction of the controls, - // don't call the focus handlers - Link aEmptyLink; - aBtnFx1.SetGetFocusHdl( aEmptyLink ); - aBtnFx2.SetGetFocusHdl( aEmptyLink ); - aBtnFx3.SetGetFocusHdl( aEmptyLink ); - aBtnFx4.SetGetFocusHdl( aEmptyLink ); -} - -USHORT ScParaWin::GetActiveLine() -{ - return nActiveLine; -} - -void ScParaWin::SetActiveLine(USHORT no) -{ - if(no<nArgs) - { - long nOffset = GetSliderPos(); - nActiveLine=no; - long nNewEdPos=(long)nActiveLine-nOffset; - if(nNewEdPos<0 || nNewEdPos>3) - { - nOffset+=nNewEdPos; - SetSliderPos((USHORT) nOffset); - nOffset=GetSliderPos(); - } - nEdFocus=no-(USHORT)nOffset; - UpdateArgDesc( nEdFocus ); - } -} - -ScRefEdit* ScParaWin::GetActiveEdit() -{ - if(nArgs>0 && nEdFocus!=NOT_FOUND) - { - return aArgInput[nEdFocus].GetArgEdPtr(); - } - else - { - return NULL; - } -} - - -String ScParaWin::GetArgument(USHORT no) -{ - String aStr; - if(no<aParaArray.Count()) - { - aStr=*aParaArray[no]; - if(no==nActiveLine && aStr.Len()==0) - aStr+=' '; - } - return aStr; -} - -String ScParaWin::GetActiveArgName() -{ - String aStr; - if(nArgs>0 && nEdFocus!=NOT_FOUND) - { - aStr=aArgInput[nEdFocus].GetArgName(); - } - return aStr; -} - - -void ScParaWin::SetArgument(USHORT no, const String& aString) -{ - if(no<aParaArray.Count()) - { - *aParaArray[no]=aString; - aParaArray[no]->EraseLeadingChars(); - } -} - -void ScParaWin::DelParaArray() -{ - for(int i=0;i<aParaArray.Count();i++) - { - String* pStr=aParaArray[sal::static_int_cast<USHORT>(i)]; - delete pStr; - } - aParaArray.Remove(0,aParaArray.Count()); - -} - -void ScParaWin::SetArgumentFonts(const Font&aBoldFont,const Font&aLightFont) -{ - aFntBold=aBoldFont; - aFntLight=aLightFont; -} - -void ScParaWin::SetFunctionDesc(const ScFuncDesc* pFDesc) -{ - pFuncDesc=pFDesc; - - SetArgumentDesc( EMPTY_STRING ); - SetArgumentText( EMPTY_STRING ); - SetEditDesc( EMPTY_STRING ); - nArgs = 0; - if ( pFuncDesc!=NULL) - { - if(pFuncDesc->pFuncDesc != NULL) - { - SetEditDesc(*(pFuncDesc->pFuncDesc)); - } - else - { - SetEditDesc(aDefaultString); - } - long nHelpId = pFuncDesc->nHelpId; - nArgs = pFuncDesc->GetSuppressedArgCount(); - aVisibleArgMapping = pFuncDesc->GetVisibleArgMapping(); - aSlider.Hide(); - SetHelpId( nHelpId ); - aEdArg1.SetHelpId( nHelpId ); - aEdArg2.SetHelpId( nHelpId ); - aEdArg3.SetHelpId( nHelpId ); - aEdArg4.SetHelpId( nHelpId ); - - // Unique-IDs muessen gleich bleiben fuer Automatisierung - SetUniqueId( HID_SC_FAP_PAGE ); - aEdArg1.SetUniqueId( HID_SC_FAP_EDIT1 ); - aEdArg2.SetUniqueId( HID_SC_FAP_EDIT2 ); - aEdArg3.SetUniqueId( HID_SC_FAP_EDIT3 ); - aEdArg4.SetUniqueId( HID_SC_FAP_EDIT4 ); - SetActiveLine(0); - } - else - { - nActiveLine=0; - } - -} - -void ScParaWin::SetArgumentText(const String& aText) -{ - aFtArgName.SetText(aText); -} - -void ScParaWin::SetArgumentDesc(const String& aText) -{ - aFtArgDesc.SetText(aText); -} - -void ScParaWin::SetEditDesc(const String& aText) -{ - aFtEditDesc.SetText(aText); -} - -void ScParaWin::SetArgName(USHORT no,const String& aText) -{ - aArgInput[no].SetArgName(aText); -} - -void ScParaWin::SetArgNameFont(USHORT no,const Font& aFont) -{ - aArgInput[no].SetArgNameFont(aFont); -} - -void ScParaWin::SetArgVal(USHORT no,const String& aText) -{ - aArgInput[no].SetArgVal(aText); -} - -void ScParaWin::HideParaLine(USHORT no) -{ - aArgInput[no].Hide(); -} - -void ScParaWin::ShowParaLine(USHORT no) -{ - aArgInput[no].Show(); -} - -void ScParaWin::SetEdFocus(USHORT no) -{ - UpdateArgDesc(no); - if(no<4 && no<aParaArray.Count()) - aArgInput[no].GetArgEdPtr()->GrabFocus(); -} - - -void ScParaWin::InitArgInput( USHORT nPos, FixedText& rFtArg, ImageButton& rBtnFx, - ArgEdit& rEdArg, ScRefButton& rRefBtn) -{ - - rRefBtn.SetReferences(pMyParent,&rEdArg); - rEdArg.SetRefDialog(pMyParent); - - aArgInput[nPos].InitArgInput (&rFtArg,&rBtnFx,&rEdArg,&rRefBtn); - - aArgInput[nPos].Hide(); - - aArgInput[nPos].SetFxClickHdl ( LINK( this, ScParaWin, GetFxHdl ) ); - aArgInput[nPos].SetFxFocusHdl ( LINK( this, ScParaWin, GetFxFocusHdl ) ); - aArgInput[nPos].SetEdFocusHdl ( LINK( this, ScParaWin, GetEdFocusHdl ) ); - aArgInput[nPos].SetEdModifyHdl ( LINK( this, ScParaWin, ModifyHdl ) ); -} - -void ScParaWin::ClearAll() -{ - SetFunctionDesc(NULL); - SetArgumentOffset(0); -} - -void ScParaWin::SetArgumentOffset(USHORT nOffset) -{ - DelParaArray(); - aSlider.SetThumbPos(0); - int i; - for(i=0;i<nArgs;i++) - aParaArray.Insert( new String, aParaArray.Count() ); - - if ( nArgs > 0 ) - { - for ( i=0; i<4 && i<nArgs; i++ ) - { - String aString; - aArgInput[i].SetArgVal(aString); - aArgInput[i].GetArgEdPtr()->Init( - (i==0) ? (ArgEdit *)NULL : aArgInput[i-1].GetArgEdPtr(), - (i==3 || i==nArgs-1) ? (ArgEdit *)NULL : aArgInput[i+1].GetArgEdPtr(), - aSlider, nArgs ); - } - } - - if ( nArgs < 5 ) - { - aSlider.Hide(); - } - else - { - //aSlider.SetEndScrollHdl( LINK( this, ScFormulaDlg, ScrollHdl ) ); - aSlider.SetPageSize( 4 ); - aSlider.SetVisibleSize( 4 ); - aSlider.SetLineSize( 1 ); - aSlider.SetRange( Range( 0, nArgs ) ); - aSlider.SetThumbPos( nOffset ); - aSlider.Show(); - } - - UpdateParas(); -} - -void ScParaWin::UpdateParas() -{ - USHORT i; - USHORT nOffset = GetSliderPos(); - - if ( nArgs > 0 ) - { - for ( i=0; (i<nArgs) && (i<4); i++ ) - { - UpdateArgInput( nOffset, i ); - ShowParaLine(i); - } - } - - for ( i=nArgs; i<4; i++ ) HideParaLine(i); -} - - -USHORT ScParaWin::GetSliderPos() -{ - return (USHORT) aSlider.GetThumbPos(); -} - -void ScParaWin::SetSliderPos(USHORT nSliderPos) -{ - USHORT nOffset = GetSliderPos(); - - if(aSlider.IsVisible() && nOffset!=nSliderPos) - { - aSlider.SetThumbPos(nSliderPos); - for ( USHORT i=0; i<4; i++ ) - { - UpdateArgInput( nSliderPos, i ); - } - } -} - -void ScParaWin::SliderMoved() -{ - USHORT nOffset = GetSliderPos(); - - for ( USHORT i=0; i<4; i++ ) - { - UpdateArgInput( nOffset, i ); - } - if(nEdFocus!=NOT_FOUND) - { - UpdateArgDesc( nEdFocus ); - aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX )); - nActiveLine=nEdFocus+nOffset; - ArgumentModified(); - } - aScrollLink.Call(this); -} - -void ScParaWin::ArgumentModified() -{ - aArgModifiedLink.Call(this); -} - -void ScParaWin::FxClick() -{ - aFxLink.Call(this); -} - - -IMPL_LINK( ScParaWin, GetFxHdl, ArgInput*, pPtr ) -{ - USHORT nOffset = GetSliderPos(); - nEdFocus=NOT_FOUND; - for ( USHORT nPos=0; nPos<5;nPos++) - { - if(pPtr == &aArgInput[nPos]) - { - nEdFocus=nPos; - break; - } - } - - if(nEdFocus!=NOT_FOUND) - { - aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX )); - nActiveLine=nEdFocus+nOffset; - FxClick(); - } - return 0; -} - -IMPL_LINK( ScParaWin, GetFxFocusHdl, ArgInput*, pPtr ) -{ - USHORT nOffset = GetSliderPos(); - nEdFocus=NOT_FOUND; - for ( USHORT nPos=0; nPos<5;nPos++) - { - if(pPtr == &aArgInput[nPos]) - { - nEdFocus=nPos; - break; - } - } - - if(nEdFocus!=NOT_FOUND) - { - aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX )); - UpdateArgDesc( nEdFocus ); - nActiveLine=nEdFocus+nOffset; - } - return 0; -} - - - -IMPL_LINK( ScParaWin, GetEdFocusHdl, ArgInput*, pPtr ) -{ - USHORT nOffset = GetSliderPos(); - nEdFocus=NOT_FOUND; - for ( USHORT nPos=0; nPos<5;nPos++) - { - if(pPtr == &aArgInput[nPos]) - { - nEdFocus=nPos; - break; - } - } - - if(nEdFocus!=NOT_FOUND) - { - aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX )); - UpdateArgDesc( nEdFocus ); - nActiveLine=nEdFocus+nOffset; - ArgumentModified(); - } - - return 0; -} - - -IMPL_LINK( ScParaWin, ScrollHdl, ScrollBar*, EMPTYARG ) -{ - SliderMoved(); - - return 0; -} - -IMPL_LINK( ScParaWin, ModifyHdl, ArgInput*, pPtr ) -{ - USHORT nOffset = GetSliderPos(); - nEdFocus=NOT_FOUND; - for ( USHORT nPos=0; nPos<5;nPos++) - { - if(pPtr == &aArgInput[nPos]) - { - nEdFocus=nPos; - break; - } - } - if(nEdFocus!=NOT_FOUND) - { - *(aParaArray[nEdFocus+nOffset])=aArgInput[nEdFocus].GetArgVal(); - UpdateArgDesc( nEdFocus); - nActiveLine=nEdFocus+nOffset; - } - - ArgumentModified(); - return 0; -} - - - diff --git a/sc/source/ui/formdlg/parawin.hrc b/sc/source/ui/formdlg/parawin.hrc deleted file mode 100644 index a425bda49335..000000000000 --- a/sc/source/ui/formdlg/parawin.hrc +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: parawin.hrc,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "sc.hrc" // -> RID_SCTAB_PARAMETER - -// #define RID_SCTAB_PARAMETER 256 - -#define FT_PARNAME 1 -#define FT_PARDESC 2 -#define FT_EDITDESC 3 -#define FT_ARG1 4 -#define FT_ARG2 5 -#define FT_ARG3 6 -#define FT_ARG4 7 -#define BTN_FX1 8 -#define BTN_FX2 9 -#define BTN_FX3 10 -#define BTN_FX4 11 -#define ED_ARG1 12 -#define ED_ARG2 13 -#define ED_ARG3 14 -#define ED_ARG4 15 -#define RB_ARG1 16 -#define RB_ARG2 17 -#define RB_ARG3 18 -#define RB_ARG4 19 -#define WND_SLIDER 20 -#define IMG_FX_H 30 - diff --git a/sc/source/ui/formdlg/parawin.src b/sc/source/ui/formdlg/parawin.src deleted file mode 100644 index ffa3d06e9ab9..000000000000 --- a/sc/source/ui/formdlg/parawin.src +++ /dev/null @@ -1,179 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: parawin.src,v $ - * $Revision: 1.30 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "parawin.hrc" - - //--------------------------------------------------------------------------- - -#define FT_ARGBLOCK( y ) \ - Pos = MAP_APPFONT (6 , y ) ; \ - Size = MAP_APPFONT ( 74 , 8 ) ; \ - Right = TRUE ; - -#define FXBUTTONBLOCK( y ) \ - Pos = MAP_APPFONT (83 , y-1 ) ; \ - Size = MAP_APPFONT ( 13 , 15 ) ; \ - TabStop = TRUE ; \ - ButtonImage = Image\ - {\ - ImageBitmap = Bitmap\ - {\ - File = "fx.bmp" ; \ - };\ - MaskColor = STD_MASKCOLOR;\ - }; - -#define ED_ARGBLOCK( y ) \ - Border = TRUE; \ - Pos = MAP_APPFONT( 98, y ); \ - Size = MAP_APPFONT( 66, 12 ); \ - TabStop = TRUE; - -#define RB_ARGBLOCK( y ) \ - Pos = MAP_APPFONT ( 166 , y-1 ) ; \ - Size = MAP_APPFONT ( 13 , 15 ) ; \ - TabStop = FALSE ; \ - QuickHelpText [ en-US ] = "Shrink"; \ - - //--------------------------------------------------------------------------- - - // jetzt alles zusammen - -TabPage RID_SCTAB_PARAMETER -{ - Border = FALSE; - Size = MAP_APPFONT( 203, 128 ); - DialogControl = TRUE; - SVLook = TRUE; - - FixedText FT_EDITDESC - { - Pos = MAP_APPFONT (3 , 6 ) ; - Size = MAP_APPFONT ( 198 , 20 ) ; - WordBreak = TRUE ; - Text [ en-US ] = "Function not known"; - }; - - FixedText FT_PARNAME - { - Pos = MAP_APPFONT ( 3, 29) ; - Size = MAP_APPFONT ( 198 , 10 ) ; - }; - FixedText FT_PARDESC - { - Pos = MAP_APPFONT ( 3, 42 ) ; - Size = MAP_APPFONT ( 198 , 20 ) ; - WordBreak = TRUE ; - }; - - FixedText FT_ARG1 { FT_ARGBLOCK ( 66 ) }; - FixedText FT_ARG2 { FT_ARGBLOCK ( 81 ) }; - FixedText FT_ARG3 { FT_ARGBLOCK ( 96 ) }; - FixedText FT_ARG4 { FT_ARGBLOCK ( 111 ) }; - - ImageButton BTN_FX1 - { - HelpId=HID_SC_FAP_BTN_FX1; - FXBUTTONBLOCK ( 64 ) - }; - ImageButton BTN_FX2 - { - HelpId=HID_SC_FAP_BTN_FX2; - FXBUTTONBLOCK ( 79 ) - }; - - ImageButton BTN_FX3 - { - HelpId=HID_SC_FAP_BTN_FX3; - FXBUTTONBLOCK ( 94 ) - }; - ImageButton BTN_FX4 - { - HelpId=HID_SC_FAP_BTN_FX4; - FXBUTTONBLOCK ( 109 ) - }; - Edit ED_ARG1 { ED_ARGBLOCK ( 64 ) }; - Edit ED_ARG2 { ED_ARGBLOCK ( 79 ) }; - Edit ED_ARG3 { ED_ARGBLOCK ( 94 ) }; - Edit ED_ARG4 { ED_ARGBLOCK ( 109 ) }; - - ImageButton RB_ARG1 - { - HelpId=HID_SC_FAP_BTN_REF1; - RB_ARGBLOCK ( 64 ) - }; - - ImageButton RB_ARG2 - { - HelpId=HID_SC_FAP_BTN_REF2; - RB_ARGBLOCK ( 79 ) - }; - ImageButton RB_ARG3 - { - HelpId=HID_SC_FAP_BTN_REF3; - RB_ARGBLOCK ( 94 ) - }; - ImageButton RB_ARG4 - { - HelpId=HID_SC_FAP_BTN_REF4; - RB_ARGBLOCK ( 109 ) - }; - - ScrollBar WND_SLIDER - { - Pos = MAP_APPFONT ( 183, 63 ) ; - Size = MAP_APPFONT ( 8 , 59 ) ; - VScroll = TRUE ; - }; - - Image IMG_FX_H - { - ImageBitmap = Bitmap { File = "fx_h.bmp" ; }; - MaskColor = SC_HC_MASKCOLOR; - }; -}; - - - - - - - - - - - - - - - - - - diff --git a/sc/source/ui/formdlg/structpg.cxx b/sc/source/ui/formdlg/structpg.cxx deleted file mode 100644 index 1605e8283ccd..000000000000 --- a/sc/source/ui/formdlg/structpg.cxx +++ /dev/null @@ -1,236 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: structpg.cxx,v $ - * $Revision: 1.9 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - - - -//---------------------------------------------------------------------------- - -#include "scitems.hxx" -#include <sfx2/dispatch.hxx> -#include <sfx2/docfile.hxx> -#include <sfx2/objsh.hxx> -#include <svtools/zforlist.hxx> -#include <svtools/stritem.hxx> - -#include "structpg.hxx" -#include "formdlgs.hrc" -#include "formdata.hxx" -#include "globstr.hrc" -#include "scresid.hxx" -#include "reffact.hxx" -#include "document.hxx" -#include "cell.hxx" -#include "scmod.hxx" -#include "inputhdl.hxx" -#include "tabvwsh.hxx" -#include "appoptio.hxx" - -//---------------------------------------------------------------------------- - -ScStructListBox::ScStructListBox(Window* pParent, const ResId& rResId ): - SvTreeListBox(pParent,rResId ) -{ - bActiveFlag=FALSE; - - Font aFont( GetFont() ); - Size aSize = aFont.GetSize(); - aSize.Height() -= 2; - aFont.SetSize( aSize ); - SetFont( aFont ); -} - -SvLBoxEntry* ScStructListBox::InsertStaticEntry( - const XubString& rText, - const Image& rEntryImg, const Image& rEntryImgHC, - SvLBoxEntry* pParent, ULONG nPos, ScToken* pToken ) -{ - SvLBoxEntry* pEntry = InsertEntry( rText, rEntryImg, rEntryImg, pParent, FALSE, nPos, pToken ); - SvLBoxContextBmp* pBmpItem = static_cast< SvLBoxContextBmp* >( pEntry->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP ) ); - DBG_ASSERT( pBmpItem, "ScStructListBox::InsertStaticEntry - missing item" ); - pBmpItem->SetBitmap1( rEntryImgHC, BMP_COLOR_HIGHCONTRAST ); - pBmpItem->SetBitmap2( rEntryImgHC, BMP_COLOR_HIGHCONTRAST ); - return pEntry; -} - -void ScStructListBox::SetActiveFlag(BOOL bFlag) -{ - bActiveFlag=bFlag; -} - -BOOL ScStructListBox::GetActiveFlag() -{ - return bActiveFlag; -} - -void ScStructListBox::MouseButtonDown( const MouseEvent& rMEvt ) -{ - bActiveFlag=TRUE; - SvTreeListBox::MouseButtonDown(rMEvt); -} - -void ScStructListBox::GetFocus() -{ - bActiveFlag=TRUE; - SvTreeListBox::GetFocus(); -} - -void ScStructListBox::LoseFocus() -{ - bActiveFlag=FALSE; - SvTreeListBox::LoseFocus(); -} - -//============================================================================== - -ScStructPage::ScStructPage(Window* pParent): - TabPage(pParent,ScResId(RID_SCTAB_STRUCT)), - // - aFtStruct ( this, ScResId( FT_STRUCT ) ), - aTlbStruct ( this, ScResId( TLB_STRUCT ) ), - maImgEnd ( ScResId( BMP_STR_END ) ), - maImgError ( ScResId( BMP_STR_ERROR ) ), - maImgEndHC ( ScResId( BMP_STR_END_H ) ), - maImgErrorHC ( ScResId( BMP_STR_ERROR_H ) ), - pSelectedToken ( NULL ) -{ - aTlbStruct.SetWindowBits(WB_HASLINES|WB_CLIPCHILDREN| - WB_HASBUTTONS|WB_HSCROLL|WB_NOINITIALSELECTION); - - aTlbStruct.SetNodeDefaultImages(); - aTlbStruct.SetDefaultExpandedEntryBmp( Image( ScResId( BMP_STR_OPEN ) ) ); - aTlbStruct.SetDefaultCollapsedEntryBmp( Image( ScResId( BMP_STR_CLOSE ) ) ); - aTlbStruct.SetDefaultExpandedEntryBmp( Image( ScResId( BMP_STR_OPEN_H ) ), BMP_COLOR_HIGHCONTRAST ); - aTlbStruct.SetDefaultCollapsedEntryBmp( Image( ScResId( BMP_STR_CLOSE_H ) ), BMP_COLOR_HIGHCONTRAST ); - - FreeResource(); - - aTlbStruct.SetSelectHdl(LINK( this, ScStructPage, SelectHdl ) ); -} - -void ScStructPage::ClearStruct() -{ - aTlbStruct.SetActiveFlag(FALSE); - aTlbStruct.Clear(); -} - -SvLBoxEntry* ScStructPage::InsertEntry( const XubString& rText, SvLBoxEntry* pParent, - USHORT nFlag,ULONG nPos,ScToken* pScToken) -{ - aTlbStruct.SetActiveFlag( FALSE ); - - SvLBoxEntry* pEntry = NULL; - switch( nFlag ) - { - case STRUCT_FOLDER: - pEntry = aTlbStruct.InsertEntry( rText, pParent, FALSE, nPos, pScToken ); - break; - case STRUCT_END: - pEntry = aTlbStruct.InsertStaticEntry( rText, maImgEnd, maImgEndHC, pParent, nPos, pScToken ); - break; - case STRUCT_ERROR: - pEntry = aTlbStruct.InsertStaticEntry( rText, maImgError, maImgErrorHC, pParent, nPos, pScToken ); - break; - } - - if( pEntry && pParent ) - aTlbStruct.Expand( pParent ); - return pEntry; -} - -String ScStructPage::GetEntryText(SvLBoxEntry* pEntry) -{ - String aString; - if(pEntry!=NULL) - aString=aTlbStruct.GetEntryText(pEntry); - return aString; -} - -ScToken* ScStructPage::GetFunctionEntry(SvLBoxEntry* pEntry) -{ - if(pEntry!=NULL) - { - ScToken * pToken=(ScToken *)pEntry->GetUserData(); - if(pToken!=NULL) - { - OpCode eOp = pToken->GetOpCode(); - if(!(pToken->IsFunction()|| ocArcTan2<=eOp)) - { - return GetFunctionEntry(aTlbStruct.GetParent(pEntry)); - } - else - { - return pToken; - } - } - } - return NULL; -} - -IMPL_LINK( ScStructPage, SelectHdl, SvTreeListBox*, pTlb ) -{ - if(aTlbStruct.GetActiveFlag()) - { - if(pTlb==&aTlbStruct) - { - SvLBoxEntry* pCurEntry=aTlbStruct.GetCurEntry(); - if(pCurEntry!=NULL) - { - pSelectedToken=(ScToken *)pCurEntry->GetUserData(); - if(pSelectedToken!=NULL) - { - OpCode eOp = pSelectedToken->GetOpCode(); - if(!(pSelectedToken->IsFunction()|| ocArcTan2<=eOp)) - { - pSelectedToken=GetFunctionEntry(pCurEntry); - } - } - } - } - - aSelLink.Call(this); - } - return 0; -} - -ScToken * ScStructPage::GetSelectedToken() -{ - return pSelectedToken; -} - -String ScStructPage::GetSelectedEntryText() -{ - return aTlbStruct.GetEntryText(aTlbStruct.GetCurEntry()); -} - - - diff --git a/sc/source/ui/inc/IAnyRefDialog.hxx b/sc/source/ui/inc/IAnyRefDialog.hxx new file mode 100644 index 000000000000..bd115b2ad1c0 --- /dev/null +++ b/sc/source/ui/inc/IAnyRefDialog.hxx @@ -0,0 +1,67 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: formula.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_IANYREFDIALOG_HXX_INCLUDED +#define SC_IANYREFDIALOG_HXX_INCLUDED + +#include <formula/IControlReferenceHandler.hxx> + +class ScRange; +class ScDocument; +class ScTabViewShell; +class SfxObjectShell; +namespace formula +{ + class RefEdit; + class RefButton; +} +class SAL_NO_VTABLE IAnyRefDialog : public formula::IControlReferenceHandler +{ +public: + virtual ~IAnyRefDialog(){} + + //virtual void ShowReference(const String& _sRef) = 0; + //virtual void HideReference( BOOL bDoneRefMode = TRUE ) = 0; + //virtual void ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ) = 0; + //virtual void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ) = 0; + + + virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) = 0; + virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ) = 0; + virtual void RefInputDone( BOOL bForced = FALSE ) = 0; + virtual BOOL IsTableLocked() const = 0; + virtual BOOL IsRefInputMode() const = 0; + + virtual BOOL IsDocAllowed( SfxObjectShell* pDocSh ) const = 0; + virtual void AddRefEntry() = 0; + virtual void SetActive() = 0; + virtual void ViewShellChanged( ScTabViewShell* pScViewShell ) = 0; +}; + +#endif // SC_IANYREFDIALOG_HXX_INCLUDED diff --git a/sc/source/ui/inc/anyrefdg.hxx b/sc/source/ui/inc/anyrefdg.hxx index c95a75a6ec8f..74621d3ced41 100644 --- a/sc/source/ui/inc/anyrefdg.hxx +++ b/sc/source/ui/inc/anyrefdg.hxx @@ -42,121 +42,98 @@ #endif #include <sfx2/basedlgs.hxx> #include "address.hxx" +#include "formula/funcutl.hxx" +#include "IAnyRefDialog.hxx" +#include <memory> class SfxObjectShell; class ScRange; class ScDocument; class ScTabViewShell; class ScAnyRefDlg; -class ScRefButton; class ScFormulaCell; class ScCompiler; class ScRangeList; -//============================================================================ - -class ScRefEdit : public Edit +class ScFormulaReferenceHelper { -private: - Timer aTimer; - ScAnyRefDlg* pAnyRefDlg; // parent dialog - BOOL bSilentFocus; // for SilentGrabFocus() - - DECL_LINK( UpdateHdl, Timer* ); - -protected: - virtual void KeyInput( const KeyEvent& rKEvt ); - virtual void GetFocus(); - virtual void LoseFocus(); - -public: - ScRefEdit( ScAnyRefDlg* pParent, const ResId& rResId ); - ScRefEdit( Window* pParent, const ResId& rResId ); - virtual ~ScRefEdit(); - - void SetRefString( const XubString& rStr ); - using Edit::SetText; - virtual void SetText( const XubString& rStr ); - virtual void Modify(); - - void StartUpdateData(); - -//UNUSED2008-05 void SilentGrabFocus(); // does not update any references - - void SetRefDialog( ScAnyRefDlg* pDlg ); - inline ScAnyRefDlg* GetRefDialog() { return pAnyRefDlg; } -}; + IAnyRefDialog* m_pDlg; + ::std::auto_ptr<ScFormulaCell> pRefCell; + ::std::auto_ptr<ScCompiler> pRefComp; + formula::RefEdit* pRefEdit; // aktives Eingabefeld + formula::RefButton* pRefBtn; // Button dazu + Window* m_pWindow; + SfxBindings* m_pBindings; + ::std::auto_ptr<Accelerator> + pAccel; // fuer Enter/Escape + BOOL* pHiddenMarks; // Merkfeld fuer versteckte Controls + SCTAB nRefTab; // used for ShowReference -//============================================================================ + String sOldDialogText; // Originaltitel des Dialogfensters + Size aOldDialogSize; // Originalgroesse Dialogfenster + Point aOldEditPos; // Originalposition des Eingabefeldes + Size aOldEditSize; // Originalgroesse des Eingabefeldes + Point aOldButtonPos; // Originalpositiuon des Buttons -class ScRefButton : public ImageButton -{ -private: - Image aImgRefStart; /// Start reference input - Image aImgRefStartHC; /// Start reference input (high contrast) - Image aImgRefDone; /// Stop reference input - Image aImgRefDoneHC; /// Stop reference input (high contrast) - ScAnyRefDlg* pAnyRefDlg; // parent dialog - ScRefEdit* pRefEdit; // zugeordnetes Edit-Control + BOOL bEnableColorRef; + BOOL bHighLightRef; + BOOL bAccInserted; -protected: - virtual void Click(); - virtual void KeyInput( const KeyEvent& rKEvt ); - virtual void GetFocus(); - virtual void LoseFocus(); + DECL_LINK( AccelSelectHdl, Accelerator* ); public: - ScRefButton( ScAnyRefDlg* pParent, const ResId& rResId, ScRefEdit* pEdit ); - ScRefButton( Window* pParent, const ResId& rResId ); + ScFormulaReferenceHelper(IAnyRefDialog* _pDlg,SfxBindings* _pBindings); + ~ScFormulaReferenceHelper(); - void SetReferences( ScAnyRefDlg* pDlg, ScRefEdit* pEdit ); + void ShowSimpleReference( const XubString& rStr ); + void ShowFormulaReference( const XubString& rStr ); + bool ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc ); + void Init(); - void SetStartImage(); - void SetEndImage(); - inline void DoRef() { Click(); } -}; + void ShowReference( const XubString& rStr ); + void ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ); + void HideReference( BOOL bDoneRefMode = TRUE ); + void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ); + void RefInputDone( BOOL bForced = FALSE ); + void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ); + inline void SetWindow(Window* _pWindow) { m_pWindow = _pWindow; } + BOOL DoClose( USHORT nId ); + void SetDispatcherLock( BOOL bLock ); + void EnableSpreadsheets( BOOL bFlag = TRUE, BOOL bChilds = TRUE ); + void ViewShellChanged( ScTabViewShell* pScViewShell ); + static void enableInput(BOOL _bInput); +}; //============================================================================ -class ScAnyRefDlg : public SfxModelessDialog +class ScAnyRefDlg : public SfxModelessDialog, + public IAnyRefDialog { - friend class ScRefButton; - friend class ScRefEdit; + friend class formula::RefButton; + friend class formula::RefEdit; private: + ScFormulaReferenceHelper + m_aHelper; SfxBindings* pMyBindings; - ScRefEdit* pRefEdit; // aktives Eingabefeld - ScRefButton* pRefBtn; // Button dazu - String sOldDialogText; // Originaltitel des Dialogfensters - Size aOldDialogSize; // Originalgroesse Dialogfenster - Point aOldEditPos; // Originalposition des Eingabefeldes - Size aOldEditSize; // Originalgroesse des Eingabefeldes - Point aOldButtonPos; // Originalpositiuon des Buttons - BOOL* pHiddenMarks; // Merkfeld fuer versteckte Controls - Accelerator* pAccel; // fuer Enter/Escape - BOOL bAccInserted; - BOOL bHighLightRef; - BOOL bEnableColorRef; - ScFormulaCell* pRefCell; - ScCompiler* pRefComp; + Window* pActiveWin; Timer aTimer; String aDocName; // document on which the dialog was opened - SCTAB nRefTab; // used for ShowReference DECL_LINK( UpdateFocusHdl, Timer* ); - DECL_LINK( AccelSelectHdl, Accelerator* ); + protected: - BOOL DoClose( USHORT nId ); + virtual BOOL DoClose( USHORT nId ); void EnableSpreadsheets( BOOL bFlag = TRUE, BOOL bChilds = TRUE ); void SetDispatcherLock( BOOL bLock ); virtual long PreNotify( NotifyEvent& rNEvt ); - virtual void RefInputStart( ScRefEdit* pEdit, ScRefButton* pButton = NULL ); + virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ); virtual void RefInputDone( BOOL bForced = FALSE ); void ShowSimpleReference( const XubString& rStr ); void ShowFormulaReference( const XubString& rStr ); @@ -175,13 +152,13 @@ public: virtual BOOL IsTableLocked() const; virtual BOOL IsDocAllowed( SfxObjectShell* pDocSh ) const; - void ShowReference( const XubString& rStr ); - void HideReference( BOOL bDoneRefMode = TRUE ); + virtual void ShowReference( const XubString& rStr ); + virtual void HideReference( BOOL bDoneRefMode = TRUE ); - void ToggleCollapsed( ScRefEdit* pEdit, ScRefButton* pButton = NULL ); - void ReleaseFocus( ScRefEdit* pEdit, ScRefButton* pButton = NULL ); + virtual void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ); + virtual void ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ); - void ViewShellChanged( ScTabViewShell* pScViewShell ); + virtual void ViewShellChanged( ScTabViewShell* pScViewShell ); void SwitchToDocument(); SfxBindings& GetBindings(); diff --git a/sc/source/ui/inc/areasdlg.hxx b/sc/source/ui/inc/areasdlg.hxx index 5437db2e0dc3..9b7e7234123e 100644 --- a/sc/source/ui/inc/areasdlg.hxx +++ b/sc/source/ui/inc/areasdlg.hxx @@ -67,25 +67,25 @@ public: private: ListBox aLbPrintArea; FixedLine aFlPrintArea; - ScRefEdit aEdPrintArea; - ScRefButton aRbPrintArea; + formula::RefEdit aEdPrintArea; + formula::RefButton aRbPrintArea; ListBox aLbRepeatRow; FixedLine aFlRepeatRow; - ScRefEdit aEdRepeatRow; - ScRefButton aRbRepeatRow; + formula::RefEdit aEdRepeatRow; + formula::RefButton aRbRepeatRow; ListBox aLbRepeatCol; FixedLine aFlRepeatCol; - ScRefEdit aEdRepeatCol; - ScRefButton aRbRepeatCol; + formula::RefEdit aEdRepeatCol; + formula::RefButton aRbRepeatCol; OKButton aBtnOk; CancelButton aBtnCancel; HelpButton aBtnHelp; BOOL bDlgLostFocus; - ScRefEdit* pRefInputEdit; + formula::RefEdit* pRefInputEdit; ScDocument* pDoc; ScViewData* pViewData; SCTAB nCurTab; @@ -99,7 +99,7 @@ private: // Handler: DECL_LINK( Impl_SelectHdl, ListBox* ); - DECL_LINK( Impl_ModifyHdl, ScRefEdit* ); + DECL_LINK( Impl_ModifyHdl, formula::RefEdit* ); DECL_LINK( Impl_BtnHdl, PushButton* ); DECL_LINK( Impl_GetFocusHdl, Control* ); #endif diff --git a/sc/source/ui/inc/condfrmt.hxx b/sc/source/ui/inc/condfrmt.hxx index 66bcae715631..4e74bc6cb5db 100644 --- a/sc/source/ui/inc/condfrmt.hxx +++ b/sc/source/ui/inc/condfrmt.hxx @@ -64,11 +64,11 @@ private: CheckBox aCbxCond1; ListBox aLbCond11; ListBox aLbCond12; - ScRefEdit aEdtCond11; - ScRefButton aRbCond11; + formula::RefEdit aEdtCond11; + formula::RefButton aRbCond11; FixedText aFtCond1And; - ScRefEdit aEdtCond12; - ScRefButton aRbCond12; + formula::RefEdit aEdtCond12; + formula::RefButton aRbCond12; FixedText aFtCond1Template; ListBox aLbCond1Template; FixedLine aFlSep1; @@ -76,11 +76,11 @@ private: CheckBox aCbxCond2; ListBox aLbCond21; ListBox aLbCond22; - ScRefEdit aEdtCond21; - ScRefButton aRbCond21; + formula::RefEdit aEdtCond21; + formula::RefButton aRbCond21; FixedText aFtCond2And; - ScRefEdit aEdtCond22; - ScRefButton aRbCond22; + formula::RefEdit aEdtCond22; + formula::RefButton aRbCond22; FixedText aFtCond2Template; ListBox aLbCond2Template; FixedLine aFlSep2; @@ -88,11 +88,11 @@ private: CheckBox aCbxCond3; ListBox aLbCond31; ListBox aLbCond32; - ScRefEdit aEdtCond31; - ScRefButton aRbCond31; + formula::RefEdit aEdtCond31; + formula::RefButton aRbCond31; FixedText aFtCond3And; - ScRefEdit aEdtCond32; - ScRefButton aRbCond32; + formula::RefEdit aEdtCond32; + formula::RefButton aRbCond32; FixedText aFtCond3Template; ListBox aLbCond3Template; @@ -124,7 +124,7 @@ private: Size aCond3Size2; Size aCond3Size3; - ScRefEdit* pEdActive; + formula::RefEdit* pEdActive; BOOL bDlgLostFocus; ScDocument* pDoc; diff --git a/sc/source/ui/inc/consdlg.hxx b/sc/source/ui/inc/consdlg.hxx index ff7f98a8fdbf..a4db4575f64d 100644 --- a/sc/source/ui/inc/consdlg.hxx +++ b/sc/source/ui/inc/consdlg.hxx @@ -80,13 +80,13 @@ private: ListBox aLbDataArea; FixedText aFtDataArea; - ScRefEdit aEdDataArea; - ScRefButton aRbDataArea; + formula::RefEdit aEdDataArea; + formula::RefButton aRbDataArea; ListBox aLbDestArea; FixedText aFtDestArea; - ScRefEdit aEdDestArea; - ScRefButton aRbDestArea; + formula::RefEdit aEdDestArea; + formula::RefButton aRbDestArea; FixedLine aFlConsBy; CheckBox aBtnByRow; @@ -113,19 +113,19 @@ private: USHORT nAreaDataCount; USHORT nWhichCons; - ScRefEdit* pRefInputEdit; + formula::RefEdit* pRefInputEdit; BOOL bDlgLostFocus; #ifdef _CONSDLG_CXX private: void Init (); void FillAreaLists (); - BOOL VerifyEdit ( ScRefEdit* pEd ); + BOOL VerifyEdit ( formula::RefEdit* pEd ); DECL_LINK( OkHdl, void* ); DECL_LINK( ClickHdl, PushButton* ); DECL_LINK( GetFocusHdl, Control* ); - DECL_LINK( ModifyHdl, ScRefEdit* ); + DECL_LINK( ModifyHdl, formula::RefEdit* ); DECL_LINK( SelectHdl, ListBox* ); ScSubTotalFunc LbPosToFunc( USHORT nPos ); diff --git a/sc/source/ui/inc/crnrdlg.hxx b/sc/source/ui/inc/crnrdlg.hxx index 12f0ef9fc269..5ae033947b2f 100644 --- a/sc/source/ui/inc/crnrdlg.hxx +++ b/sc/source/ui/inc/crnrdlg.hxx @@ -61,13 +61,13 @@ private: FixedLine aFlAssign; ListBox aLbRange; - ScRefEdit aEdAssign; - ScRefButton aRbAssign; + formula::RefEdit aEdAssign; + formula::RefButton aRbAssign; RadioButton aBtnColHead; RadioButton aBtnRowHead; FixedText aFtAssign2; - ScRefEdit aEdAssign2; - ScRefButton aRbAssign2; + formula::RefEdit aEdAssign2; + formula::RefButton aRbAssign2; OKButton aBtnOk; CancelButton aBtnCancel; @@ -85,7 +85,7 @@ private: NameRangeMap aRangeMap; ScViewData* pViewData; ScDocument* pDoc; - ScRefEdit* pEdActive; + formula::RefEdit* pEdActive; BOOL bDlgLostFocus; #ifdef _CRNRDLG_CXX diff --git a/sc/source/ui/inc/dbnamdlg.hxx b/sc/source/ui/inc/dbnamdlg.hxx index d680e65de014..d8d6e34a0885 100644 --- a/sc/source/ui/inc/dbnamdlg.hxx +++ b/sc/source/ui/inc/dbnamdlg.hxx @@ -70,8 +70,8 @@ private: ComboBox aEdName; FixedLine aFlAssign; - ScRefEdit aEdAssign; - ScRefButton aRbAssign; + formula::RefEdit aEdAssign; + formula::RefButton aRbAssign; FixedLine aFlOptions; CheckBox aBtnHeader; diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx index b45a3d6825de..103d17c9dd8d 100644 --- a/sc/source/ui/inc/docfunc.hxx +++ b/sc/source/ui/inc/docfunc.hxx @@ -34,7 +34,7 @@ #include <tools/link.hxx> #include "global.hxx" #include "postit.hxx" -#include "grammar.hxx" +#include "formula/grammar.hxx" class ScEditEngineDefaulter; class SfxUndoAction; @@ -90,11 +90,11 @@ public: BOOL bInterpret, BOOL bApi ); BOOL SetCellText( const ScAddress& rPos, const String& rText, BOOL bInterpret, BOOL bEnglish, BOOL bApi, - const ScGrammar::Grammar eGrammar ); + const formula::FormulaGrammar::Grammar eGrammar ); // creates a new cell for use with PutCell ScBaseCell* InterpretEnglishString( const ScAddress& rPos, const String& rText, - const ScGrammar::Grammar eGrammar ); + const formula::FormulaGrammar::Grammar eGrammar ); BOOL SetNoteText( const ScAddress& rPos, const String& rText, BOOL bApi ); @@ -120,7 +120,7 @@ public: BOOL SetLayoutRTL( SCTAB nTab, BOOL bRTL, BOOL bApi ); - BOOL SetGrammar( ScGrammar::Grammar eGrammar ); + BOOL SetGrammar( formula::FormulaGrammar::Grammar eGrammar ); SC_DLLPUBLIC BOOL SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRanges, SCTAB nTab, ScSizeMode eMode, USHORT nSizeTwips, @@ -142,7 +142,7 @@ public: BOOL EnterMatrix( const ScRange& rRange, const ScMarkData* pTabMark, const ScTokenArray* pTokenArray, const String& rString, BOOL bApi, BOOL bEnglish, - const ScGrammar::Grammar ); + const formula::FormulaGrammar::Grammar ); BOOL TabOp( const ScRange& rRange, const ScMarkData* pTabMark, const ScTabOpParam& rParam, BOOL bRecord, BOOL bApi ); diff --git a/sc/source/ui/inc/dwfunctr.hxx b/sc/source/ui/inc/dwfunctr.hxx index bf2db0f0fd24..068a05d57711 100644 --- a/sc/source/ui/inc/dwfunctr.hxx +++ b/sc/source/ui/inc/dwfunctr.hxx @@ -47,7 +47,6 @@ #include <vcl/combobox.hxx> #endif #include "anyrefdg.hxx" -#include "funcutl.hxx" #include "global.hxx" // ScAddress #include "privsplt.hxx" #include "funcdesc.hxx" diff --git a/sc/source/ui/inc/filtdlg.hxx b/sc/source/ui/inc/filtdlg.hxx index a7a1c3f6a1ce..7b99c5d580a9 100644 --- a/sc/source/ui/inc/filtdlg.hxx +++ b/sc/source/ui/inc/filtdlg.hxx @@ -66,8 +66,8 @@ class TypedScStrCollection; CheckBox aBtnUnique; \ CheckBox aBtnCopyResult; \ ListBox aLbCopyArea; \ - ScRefEdit aEdCopyArea; \ - ScRefButton aRbCopyArea; \ + formula::RefEdit aEdCopyArea; \ + formula::RefButton aRbCopyArea; \ CheckBox aBtnDestPers; \ FixedText aFtDbAreaLabel; \ FixedInfo aFtDbArea; \ @@ -89,7 +89,7 @@ class TypedScStrCollection; aBtnCopyResult ( this, ScResId( BTN_COPY_RESULT ) ), \ aLbCopyArea ( this, ScResId( LB_COPY_AREA ) ), \ aEdCopyArea ( this, ScResId( ED_COPY_AREA ) ), \ - aRbCopyArea ( this, ScResId( RB_COPY_AREA ), &aEdCopyArea ), \ + aRbCopyArea ( this, ScResId( RB_COPY_AREA ), &aEdCopyArea, this ), \ aBtnDestPers ( this, ScResId( BTN_DEST_PERS ) ), \ aFtDbAreaLabel ( this, ScResId( FT_DBAREA_LABEL ) ), \ aFtDbArea ( this, ScResId( FT_DBAREA ) ), \ @@ -209,8 +209,8 @@ public: private: ListBox aLbFilterArea; FixedText aFtFilterArea; - ScRefEdit aEdFilterArea; - ScRefButton aRbFilterArea; + formula::RefEdit aEdFilterArea; + formula::RefButton aRbFilterArea; _COMMON_FILTER_RSCOBJS @@ -222,7 +222,7 @@ private: ScViewData* pViewData; ScDocument* pDoc; - ScRefEdit* pRefInputEdit; + formula::RefEdit* pRefInputEdit; BOOL bRefInputMode; // Hack: RefInput-Kontrolle @@ -236,7 +236,7 @@ private: // Handler DECL_LINK( FilterAreaSelHdl, ListBox* ); - DECL_LINK( FilterAreaModHdl, ScRefEdit* ); + DECL_LINK( FilterAreaModHdl, formula::RefEdit* ); DECL_LINK( EndDlgHdl, Button* ); // Hack: RefInput-Kontrolle diff --git a/sc/source/ui/inc/foptmgr.hxx b/sc/source/ui/inc/foptmgr.hxx index cee598aa51d6..424493b2506a 100644 --- a/sc/source/ui/inc/foptmgr.hxx +++ b/sc/source/ui/inc/foptmgr.hxx @@ -47,7 +47,10 @@ //---------------------------------------------------------------------------- class FixedInfo; -class ScRefButton; +namespace formula +{ + class RefButton; +} class MoreButton; class Dialog; struct ScQueryParam; @@ -71,7 +74,7 @@ public: CheckBox& refBtnDestPers, ListBox& refLbCopyArea, Edit& refEdCopyArea, - ScRefButton& refRbCopyArea, + formula::RefButton& refRbCopyArea, FixedText& refFtDbAreaLabel, FixedInfo& refFtDbArea, FixedLine& refFlOptions, @@ -95,7 +98,7 @@ private: CheckBox& rBtnDestPers; ListBox& rLbCopyPos; Edit& rEdCopyPos; - ScRefButton& rRbCopyPos; + formula::RefButton& rRbCopyPos; FixedText& rFtDbAreaLabel; FixedInfo& rFtDbArea; FixedLine& rFlOptions; diff --git a/sc/source/ui/inc/formdata.hxx b/sc/source/ui/inc/formdata.hxx index d47b7d7fb69a..c36a625543c5 100644 --- a/sc/source/ui/inc/formdata.hxx +++ b/sc/source/ui/inc/formdata.hxx @@ -33,65 +33,32 @@ #include <tools/string.hxx> #include <tools/gen.hxx> - +#include <formula/formdata.hxx> class ScInputHandler; class ScDocShell; //============================================================================ -class ScFormEditData +class ScFormEditData : public formula::FormEditData { public: ScFormEditData(); - ~ScFormEditData(); - - void SaveValues(); - BOOL HasParent() const { return pParent != NULL; } + virtual ~ScFormEditData(); - USHORT GetMode() const { return nMode; } - xub_StrLen GetFStart() const { return nFStart; } - USHORT GetCatSel() const { return nCatSel; } - USHORT GetFuncSel() const { return nFuncSel; } - USHORT GetOffset() const { return nOffset; } - USHORT GetEdFocus() const { return nEdFocus; } - const String& GetUndoStr() const { return aUndoStr; } - BOOL GetMatrixFlag()const{ return bMatrix;} - ULONG GetUniqueId()const { return nUniqueId;} - const Selection& GetSelection()const { return aSelection;} ScInputHandler* GetInputHandler() { return pInputHandler;} ScDocShell* GetDocShell() { return pScDocShell;} - void SetMode( USHORT nNew ) { nMode = nNew; } - void SetFStart( xub_StrLen nNew ) { nFStart = nNew; } - void SetCatSel( USHORT nNew ) { nCatSel = nNew; } - void SetFuncSel( USHORT nNew ) { nFuncSel = nNew; } - void SetOffset( USHORT nNew ) { nOffset = nNew; } - void SetEdFocus( USHORT nNew ) { nEdFocus = nNew; } - void SetUndoStr( const String& rNew ) { aUndoStr = rNew; } - void SetMatrixFlag(BOOL bNew) { bMatrix=bNew;} - void SetUniqueId(ULONG nNew) { nUniqueId=nNew;} - void SetSelection(const Selection& aSel) { aSelection=aSel;} void SetInputHandler(ScInputHandler* pHdl) { pInputHandler=pHdl;} void SetDocShell(ScDocShell* pSds) { pScDocShell=pSds;} + virtual void SaveValues(); private: ScFormEditData( const ScFormEditData& ); - const ScFormEditData& operator=( const ScFormEditData& r ); - void Reset(); +// const ScFormEditData& operator=( const ScFormEditData& r ); + - ScFormEditData* pParent; // fuer Verschachtelung - USHORT nMode; // enum ScFormulaDlgMode - xub_StrLen nFStart; - USHORT nCatSel; - USHORT nFuncSel; - USHORT nOffset; - USHORT nEdFocus; - String aUndoStr; - BOOL bMatrix; - ULONG nUniqueId; - Selection aSelection; ScInputHandler* pInputHandler; ScDocShell* pScDocShell; }; diff --git a/sc/source/ui/inc/formula.hxx b/sc/source/ui/inc/formula.hxx index 3078ee1453f2..52bd475df543 100644 --- a/sc/source/ui/inc/formula.hxx +++ b/sc/source/ui/inc/formula.hxx @@ -32,7 +32,6 @@ #define SC_FORMULA_HXX #include "anyrefdg.hxx" -#include "funcutl.hxx" #include "global.hxx" // ScAddress #include <svtools/stdctrl.hxx> #ifndef _LSTBOX_HXX //autogen @@ -48,171 +47,91 @@ #include <svtools/svstdarr.hxx> #endif -#include <vcl/tabctrl.hxx> -#include "parawin.hxx" -#include <svtools/svtreebx.hxx> #include "compiler.hxx" #include "cell.hxx" -#include "funcpage.hxx" -#include "structpg.hxx" + +#include "formula/formula.hxx" +#include "IAnyRefDialog.hxx" +#include "anyrefdg.hxx" +#include <formula/IFunctionDescription.hxx> class ScViewData; class ScDocument; class ScFuncDesc; class ScInputHandler; class ScDocShell; +class SvLBoxEntry; //============================================================================ - -enum ScFormulaDlgMode { SC_FORMDLG_FORMULA, SC_FORMDLG_ARGS, SC_FORMDLG_EDIT }; - -//============================================================================ - typedef ScTabViewShell* PtrTabViewShell; - //============================================================================ -//============================================================================ - -class ScFormulaDlg : public ScAnyRefDlg +class ScFormulaDlg : public formula::FormulaDlg, + public IAnyRefDialog, + public formula::IFormulaEditorHelper { + ScFormulaReferenceHelper m_aHelper; + ScFormulaCell* pCell; + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser> m_xParser; + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper> m_xOpCodeMapper; + + static ScDocument* pDoc; + static ScAddress aCursorPos; public: ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW, - Window* pParent, ScViewData* pViewData ); + Window* pParent, ScViewData* pViewData ,formula::IFunctionManager* _pFunctionMgr); ~ScFormulaDlg(); - virtual void SetReference( const ScRange& rRef, ScDocument* pRefDoc ); - virtual BOOL IsRefInputMode() const; - virtual BOOL IsDocAllowed(SfxObjectShell* pDocSh) const; - virtual void SetActive(); - virtual BOOL Close(); - -private: + // IFormulaEditorHelper + virtual void notifyChange(); + virtual void fill(); + virtual bool calculateValue(const String& _sExpression,String& _rResult); + virtual void doClose(BOOL _bOk); + virtual void insertEntryToLRUList(const formula::IFunctionDescription* pDesc); + virtual void showReference(const String& _sFormula); + virtual void dispatch(BOOL _bOK,BOOL _bMartixChecked); + virtual void setDispatcherLock( BOOL bLock ); + virtual void setReferenceInput(const formula::FormEditData* _pData); + virtual void deleteFormData(); + virtual void clear(); + virtual void switchBack(); + virtual formula::FormEditData* getFormEditData() const; + virtual void setCurrentFormula(const String& _sReplacement); + virtual void setSelection(xub_StrLen _nStart,xub_StrLen _nEnd); + virtual void getSelection(xub_StrLen& _nStart,xub_StrLen& _nEnd) const; + virtual String getCurrentFormula() const; + + virtual formula::IFunctionManager* getFunctionManager(); + virtual ::std::auto_ptr<formula::FormulaTokenArray> convertToTokenArray(const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >& _aTokenList); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser> getFormulaParser() const; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper> getFormulaOpCodeMapper() const; - TabControl aTabCtrl; - GroupBox aGbEdit; //! MUST be placed before aScParaWin for initializing - ScParaWin aScParaWin; - FixedText aFtHeadLine; - FixedInfo aFtFuncName; - FixedInfo aFtFuncDesc; - - FixedText aFtEditName; - //FixedInfo aFtEditDesc; - - FixedText aFtResult; - ValWnd aWndResult; - - FixedText aFtFormula; - ScEditBox aMEFormula; - - CheckBox aBtnMatrix; - HelpButton aBtnHelp; - CancelButton aBtnCancel; - - PushButton aBtnBackward; - PushButton aBtnForward; - OKButton aBtnEnd; - - ScRefEdit aEdRef; - ScRefButton aRefBtn; - - FixedText aFtFormResult; - ValWnd aWndFormResult; - - ScRefEdit* pTheRefEdit; - ScRefButton* pTheRefButton; - ScFuncPage* pScFuncPage; - ScStructPage* pScStructPage; - ScFormulaCell* pCell; - ScCompiler* pComp; - ScTokenArray* pScTokA; - String aOldFormula; - BOOL bStructUpdate; - MultiLineEdit* pMEdit; - BOOL bUserMatrixFlag; - Timer aTimer; - - const String aTitle1; - const String aTitle2; - const String aTxtEnd; - const String aTxtOk; // hinter aBtnEnd - - ULONG nOldHelp; - ULONG nOldUnique; - ULONG nActivWinId; - BOOL bIsShutDown; - - - - Font aFntBold; - Font aFntLight; - USHORT nEdFocus; -// Selection theCurSel; - BOOL bEditFlag; - const ScFuncDesc* pFuncDesc; - USHORT nArgs; - String** pArgArr; - Selection aFuncSel; - - static ScDocument* pDoc; - static ScAddress aCursorPos; + virtual BOOL Close(); + // sc::IAnyRefDialog + virtual void ShowReference(const String& _sRef); + virtual void HideReference( BOOL bDoneRefMode = TRUE ); + virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ); + + virtual void ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ); + virtual void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ); + virtual void RefInputDone( BOOL bForced = FALSE ); + virtual BOOL IsTableLocked() const; + virtual BOOL IsRefInputMode() const; + + virtual BOOL IsDocAllowed( SfxObjectShell* pDocSh ) const; + virtual void AddRefEntry(); + virtual void SetActive(); + virtual void ViewShellChanged( ScTabViewShell* pScViewShell ); protected: - virtual long PreNotify( NotifyEvent& rNEvt ); - virtual void RefInputStart( ScRefEdit* pEdit, ScRefButton* pButton = NULL ); - virtual void RefInputDone( BOOL bForced = FALSE ); - ULONG FindFocusWin(Window *pWin); - void SetFocusWin(Window *pWin,ULONG nUniqueId); - String RepairFormula(const String& aFormula); - void SaveLRUEntry(const ScFuncDesc* pFuncDesc); - void HighlightFunctionParas(const String& aFormula); - -private: - - BOOL IsInputHdl(ScInputHandler* pHdl); - ScInputHandler* GetNextInputHandler(ScDocShell* pDocShell,PtrTabViewShell* ppViewSh=NULL); - - void MakeTree(SvLBoxEntry* pParent,ScToken* pScToken,long Count, - ScTokenArray* pScTokA,ScCompiler* pComp); - - void ClearAllParas(); - void DeleteArgs(); - void FillDialog(BOOL nFlag=TRUE); - void EditNextFunc( BOOL bForward, xub_StrLen nFStart=NOT_FOUND ); - void EditThisFunc(xub_StrLen nFStart); - - void UpdateArgInput( USHORT nOffset, USHORT nInput ); - BOOL CalcValue( const String& rStrExp, String& rStrResult ); - BOOL CalcStruct( const String& rStrExp); - - void UpdateValues(); - void SaveArg( USHORT nEd ); - void UpdateSelection(); - void DoEnter( BOOL bOk ); -//UNUSED2008-05 void ResizeArgArr( const ScFuncDesc* pNewFunc ); - void FillListboxes(); - void FillControls(); - - xub_StrLen GetFunctionPos(xub_StrLen nPos); - void UpdateTokenArray( const String& rStrExp); - - ScRefEdit* GetCurrRefEdit(); - -//UNUSED2008-05 DECL_LINK( ScrollHdl, ScParaWin* ); - DECL_LINK( ModifyHdl, ScParaWin* ); - DECL_LINK( FxHdl, ScParaWin* ); - - DECL_LINK( MatrixHdl, CheckBox *); - DECL_LINK( FormulaHdl, MultiLineEdit* ); - DECL_LINK( FormulaCursorHdl, ScEditBox*); - DECL_LINK( BtnHdl, PushButton* ); - DECL_LINK( GetEdFocusHdl, ArgInput* ); - DECL_LINK( GetFxFocusHdl, ArgInput* ); - DECL_LINK( DblClkHdl, ScFuncPage* ); - DECL_LINK( FuncSelHdl, ScFuncPage*); - DECL_LINK( StructSelHdl, ScStructPage * ); - DECL_LINK( UpdateFocusHdl, Timer*); + virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ); + ULONG FindFocusWin(Window *pWin); + void SaveLRUEntry(const ScFuncDesc* pFuncDesc); + void HighlightFunctionParas(const String& aFormula); + + BOOL IsInputHdl(ScInputHandler* pHdl); + ScInputHandler* GetNextInputHandler(ScDocShell* pDocShell,PtrTabViewShell* ppViewSh); }; diff --git a/sc/source/ui/inc/funcutl.hxx b/sc/source/ui/inc/funcutl.hxx index 892f2cb60be8..b511c105e8ca 100644 --- a/sc/source/ui/inc/funcutl.hxx +++ b/sc/source/ui/inc/funcutl.hxx @@ -38,7 +38,7 @@ #include <vcl/fixed.hxx> #endif #include <svtools/svmedit.hxx> -#include "anyrefdg.hxx" // ScRefButton +#include "anyrefdg.hxx" // formula::RefButton //============================================================================ @@ -99,7 +99,7 @@ public: //============================================================================ // class ArgEdit -class ArgEdit : public ScRefEdit +class ArgEdit : public formula::RefEdit { public: ArgEdit( Window* pParent, const ResId& rResId ); @@ -135,12 +135,12 @@ private: FixedText* pFtArg; ImageButton* pBtnFx; ArgEdit* pEdArg; - ScRefButton* pRefBtn; + formula::RefButton* pRefBtn; DECL_LINK( FxBtnClickHdl, ImageButton* ); - DECL_LINK( RefBtnClickHdl,ScRefButton* ); + DECL_LINK( RefBtnClickHdl,formula::RefButton* ); DECL_LINK( FxBtnFocusHdl, ImageButton* ); - DECL_LINK( RefBtnFocusHdl,ScRefButton* ); + DECL_LINK( RefBtnFocusHdl,formula::RefButton* ); DECL_LINK( EdFocusHdl, ArgEdit* ); DECL_LINK( EdModifyHdl,ArgEdit* ); @@ -160,7 +160,7 @@ public: void InitArgInput ( FixedText* pftArg, ImageButton* pbtnFx, ArgEdit* pedArg, - ScRefButton* prefBtn); + formula::RefButton* prefBtn); void SetArgName(const String &aArg); String GetArgName(); diff --git a/sc/source/ui/inc/highred.hxx b/sc/source/ui/inc/highred.hxx index 1d34924fd0cc..0250c2bafe1b 100644 --- a/sc/source/ui/inc/highred.hxx +++ b/sc/source/ui/inc/highred.hxx @@ -87,8 +87,8 @@ private: CancelButton aCancelButton; HelpButton aHelpButton; - ScRefEdit aEdAssign; - ScRefButton aRbAssign; + formula::RefEdit aEdAssign; + formula::RefButton aRbAssign; ScViewData* pViewData; ScDocument* pDoc; diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx index bcc14ed48671..5afa0d244987 100644 --- a/sc/source/ui/inc/namedlg.hxx +++ b/sc/source/ui/inc/namedlg.hxx @@ -57,8 +57,8 @@ private: ComboBox aEdName; FixedLine aFlAssign; - ScRefEdit aEdAssign; - ScRefButton aRbAssign; + formula::RefEdit aEdAssign; + formula::RefButton aRbAssign; FixedLine aFlType; CheckBox aBtnPrintArea; diff --git a/sc/source/ui/inc/optsolver.hxx b/sc/source/ui/inc/optsolver.hxx index f364d0356f8d..3fc71d5d9b75 100644 --- a/sc/source/ui/inc/optsolver.hxx +++ b/sc/source/ui/inc/optsolver.hxx @@ -47,7 +47,7 @@ namespace com { namespace sun { namespace star { //============================================================================ -class ScCursorRefEdit : public ScRefEdit +class ScCursorRefEdit : public formula::RefEdit { Link maCursorUpLink; Link maCursorDownLink; @@ -118,51 +118,51 @@ public: private: FixedText maFtObjectiveCell; - ScRefEdit maEdObjectiveCell; - ScRefButton maRBObjectiveCell; + formula::RefEdit maEdObjectiveCell; + formula::RefButton maRBObjectiveCell; FixedText maFtDirection; RadioButton maRbMax; RadioButton maRbMin; RadioButton maRbValue; - ScRefEdit maEdTargetValue; - ScRefButton maRBTargetValue; + formula::RefEdit maEdTargetValue; + formula::RefButton maRBTargetValue; FixedText maFtVariableCells; - ScRefEdit maEdVariableCells; - ScRefButton maRBVariableCells; + formula::RefEdit maEdVariableCells; + formula::RefButton maRBVariableCells; FixedLine maFlConditions; FixedText maFtCellRef; // labels are together with controls for the first row ScCursorRefEdit maEdLeft1; - ScRefButton maRBLeft1; + formula::RefButton maRBLeft1; FixedText maFtOperator; ListBox maLbOp1; FixedText maFtConstraint; ScCursorRefEdit maEdRight1; - ScRefButton maRBRight1; + formula::RefButton maRBRight1; ImageButton maBtnDel1; ScCursorRefEdit maEdLeft2; - ScRefButton maRBLeft2; + formula::RefButton maRBLeft2; ListBox maLbOp2; ScCursorRefEdit maEdRight2; - ScRefButton maRBRight2; + formula::RefButton maRBRight2; ImageButton maBtnDel2; ScCursorRefEdit maEdLeft3; - ScRefButton maRBLeft3; + formula::RefButton maRBLeft3; ListBox maLbOp3; ScCursorRefEdit maEdRight3; - ScRefButton maRBRight3; + formula::RefButton maRBRight3; ImageButton maBtnDel3; ScCursorRefEdit maEdLeft4; - ScRefButton maRBLeft4; + formula::RefButton maRBLeft4; ListBox maLbOp4; ScCursorRefEdit maEdRight4; - ScRefButton maRBRight4; + formula::RefButton maRBRight4; ImageButton maBtnDel4; ScrollBar maScrollBar; @@ -180,14 +180,14 @@ private: ScDocShell* mpDocShell; ScDocument* mpDoc; const SCTAB mnCurTab; - ScRefEdit* mpEdActive; + formula::RefEdit* mpEdActive; bool mbDlgLostFocus; static const sal_uInt16 EDIT_ROW_COUNT = 4; ScCursorRefEdit* mpLeftEdit[EDIT_ROW_COUNT]; - ScRefButton* mpLeftButton[EDIT_ROW_COUNT]; + formula::RefButton* mpLeftButton[EDIT_ROW_COUNT]; ScCursorRefEdit* mpRightEdit[EDIT_ROW_COUNT]; - ScRefButton* mpRightButton[EDIT_ROW_COUNT]; + formula::RefButton* mpRightButton[EDIT_ROW_COUNT]; ListBox* mpOperator[EDIT_ROW_COUNT]; ImageButton* mpDelButton[EDIT_ROW_COUNT]; @@ -206,7 +206,7 @@ private: void EnableButtons(); bool ParseRef( ScRange& rRange, const String& rInput, bool bAllowRange ); bool FindTimeout( sal_Int32& rTimeout ); - void ShowError( bool bCondition, ScRefEdit* pFocus ); + void ShowError( bool bCondition, formula::RefEdit* pFocus ); DECL_LINK( BtnHdl, PushButton* ); DECL_LINK( DelBtnHdl, PushButton* ); diff --git a/sc/source/ui/inc/parawin.hxx b/sc/source/ui/inc/parawin.hxx index 01e2332e1e0b..3835f94157ca 100644 --- a/sc/source/ui/inc/parawin.hxx +++ b/sc/source/ui/inc/parawin.hxx @@ -79,19 +79,19 @@ private: ImageButton aBtnFx1; FixedText aFtArg1; ArgEdit aEdArg1; - ScRefButton aRefBtn1; + formula::RefButton aRefBtn1; ImageButton aBtnFx2; FixedText aFtArg2; ArgEdit aEdArg2; - ScRefButton aRefBtn2; + formula::RefButton aRefBtn2; ImageButton aBtnFx3; FixedText aFtArg3; ArgEdit aEdArg3; - ScRefButton aRefBtn3; + formula::RefButton aRefBtn3; ImageButton aBtnFx4; FixedText aFtArg4; ArgEdit aEdArg4; - ScRefButton aRefBtn4; + formula::RefButton aRefBtn4; ScrollBar aSlider; BOOL bRefMode; @@ -114,7 +114,7 @@ protected: virtual void FxClick(); void InitArgInput( USHORT nPos, FixedText& rFtArg, ImageButton& rBtnFx, - ArgEdit& rEdArg, ScRefButton& rRefBtn); + ArgEdit& rEdArg, formula::RefButton& rRefBtn); void DelParaArray(); void SetArgumentDesc(const String& aText); @@ -145,7 +145,7 @@ public: USHORT GetActiveLine(); void SetActiveLine(USHORT no); - ScRefEdit* GetActiveEdit(); + formula::RefEdit* GetActiveEdit(); String GetActiveArgName(); String GetArgument(USHORT no); diff --git a/sc/source/ui/inc/pvlaydlg.hxx b/sc/source/ui/inc/pvlaydlg.hxx index 158c9c7e7e4a..b0fd8a02c946 100644 --- a/sc/source/ui/inc/pvlaydlg.hxx +++ b/sc/source/ui/inc/pvlaydlg.hxx @@ -131,8 +131,8 @@ private: FixedLine aFlAreas; ListBox aLbOutPos; FixedText aFtOutArea; - ScRefEdit aEdOutPos; - ScRefButton aRbOutPos; + formula::RefEdit aEdOutPos; + formula::RefButton aRbOutPos; CheckBox aBtnIgnEmptyRows; CheckBox aBtnDetectCat; CheckBox aBtnTotalCol; diff --git a/sc/source/ui/inc/simpref.hxx b/sc/source/ui/inc/simpref.hxx index 7443dad543c8..127e3ac2bc56 100644 --- a/sc/source/ui/inc/simpref.hxx +++ b/sc/source/ui/inc/simpref.hxx @@ -65,8 +65,8 @@ private: Link aChangeHdl; FixedText aFtAssign; - ScRefEdit aEdAssign; - ScRefButton aRbAssign; + formula::RefEdit aEdAssign; + formula::RefButton aRbAssign; OKButton aBtnOk; CancelButton aBtnCancel; diff --git a/sc/source/ui/inc/solvrdlg.hxx b/sc/source/ui/inc/solvrdlg.hxx index f8d44710959d..21e36fd92366 100644 --- a/sc/source/ui/inc/solvrdlg.hxx +++ b/sc/source/ui/inc/solvrdlg.hxx @@ -68,15 +68,15 @@ public: private: FixedLine aFlVariables; FixedText aFtFormulaCell; - ScRefEdit aEdFormulaCell; - ScRefButton aRBFormulaCell; + formula::RefEdit aEdFormulaCell; + formula::RefButton aRBFormulaCell; FixedText aFtTargetVal; Edit aEdTargetVal; FixedText aFtVariableCell; - ScRefEdit aEdVariableCell; - ScRefButton aRBVariableCell; + formula::RefEdit aEdVariableCell; + formula::RefButton aRBVariableCell; OKButton aBtnOk; CancelButton aBtnCancel; @@ -88,7 +88,7 @@ private: ScDocument* pDoc; const SCTAB nCurTab; - ScRefEdit* pEdActive; + formula::RefEdit* pEdActive; BOOL bDlgLostFocus; const String errMsgInvalidVar; const String errMsgInvalidForm; diff --git a/sc/source/ui/inc/structpg.hxx b/sc/source/ui/inc/structpg.hxx deleted file mode 100644 index a4d4a8c10e87..000000000000 --- a/sc/source/ui/inc/structpg.hxx +++ /dev/null @@ -1,146 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: structpg.hxx,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SC_STRUCTPG_HXX -#define SC_STRUCTPG_HXX - -#include "funcutl.hxx" -#include "global.hxx" // ScAddress -#include <svtools/stdctrl.hxx> -#ifndef _LSTBOX_HXX //autogen -#include <vcl/lstbox.hxx> -#endif -#include <vcl/group.hxx> -#include <svtools/svmedit.hxx> -#include <vcl/tabpage.hxx> - -#ifndef _SVSTDARR_STRINGS - -#define _SVSTDARR_STRINGS -#include <svtools/svstdarr.hxx> - -#endif -#include <vcl/tabctrl.hxx> -#include "parawin.hxx" -#include <svtools/svtreebx.hxx> -#include "compiler.hxx" -#include "cell.hxx" - - -class ScViewData; -class ScFuncName_Impl; -class ScDocument; -class ScFuncDesc; - -//============================================================================ - -#define STRUCT_END 1 -#define STRUCT_FOLDER 2 -#define STRUCT_ERROR 3 - -#define STRUCT_ERR_C1 1 -#define STRUCT_ERR_C2 2 - -//============================================================================ - - -class ScStructListBox : public SvTreeListBox -{ -private: - - BOOL bActiveFlag; - -protected: - virtual void MouseButtonDown( const MouseEvent& rMEvt ); - -public: - - ScStructListBox(Window* pParent, const ResId& rResId ); - - /** Inserts an entry with static image (no difference between collapsed/expanded). */ - SvLBoxEntry* InsertStaticEntry( - const XubString& rText, - const Image& rEntryImg, - const Image& rEntryImgHC, - SvLBoxEntry* pParent = NULL, - ULONG nPos = LIST_APPEND, - ScToken* pToken = NULL ); - - void SetActiveFlag(BOOL bFlag=TRUE); - BOOL GetActiveFlag(); - void GetFocus(); - void LoseFocus(); -}; - -//============================================================================ - -class ScStructPage : public TabPage -{ -private: - - Link aSelLink; - - FixedText aFtStruct; - ScStructListBox aTlbStruct; - Image maImgEnd; - Image maImgError; - Image maImgEndHC; - Image maImgErrorHC; - - ScToken* pSelectedToken; - - DECL_LINK( SelectHdl, SvTreeListBox* ); - -protected: - - ScToken* GetFunctionEntry(SvLBoxEntry* pEntry); - -public: - - ScStructPage( Window* pParent); - - SvTreeListBox* GetStructPtr() {return &aTlbStruct;} - - void ClearStruct(); - SvLBoxEntry* InsertEntry(const XubString& rText, SvLBoxEntry* pParent, - USHORT nFlag,ULONG nPos=0,ScToken* pScToken=NULL); - - String GetEntryText(SvLBoxEntry* pEntry); - String GetSelectedEntryText(); - ScToken* GetSelectedToken(); - - void SetSelectionHdl( const Link& rLink ) { aSelLink = rLink; } - const Link& GetSelectionHdl() const { return aSelLink; } -}; - - - -#endif - diff --git a/sc/source/ui/inc/tabopdlg.hxx b/sc/source/ui/inc/tabopdlg.hxx index ebfe305983a3..fd1e880c8901 100644 --- a/sc/source/ui/inc/tabopdlg.hxx +++ b/sc/source/ui/inc/tabopdlg.hxx @@ -70,16 +70,16 @@ public: private: FixedLine aFlVariables; FixedText aFtFormulaRange; - ScRefEdit aEdFormulaRange; - ScRefButton aRBFormulaRange; + formula::RefEdit aEdFormulaRange; + formula::RefButton aRBFormulaRange; FixedText aFtRowCell; - ScRefEdit aEdRowCell; - ScRefButton aRBRowCell; + formula::RefEdit aEdRowCell; + formula::RefButton aRBRowCell; FixedText aFtColCell; - ScRefEdit aEdColCell; - ScRefButton aRBColCell; + formula::RefEdit aEdColCell; + formula::RefButton aRBColCell; OKButton aBtnOk; CancelButton aBtnCancel; @@ -92,7 +92,7 @@ private: ScDocument* pDoc; const SCTAB nCurTab; - ScRefEdit* pEdActive; + formula::RefEdit* pEdActive; BOOL bDlgLostFocus; const String errMsgNoFormula; const String errMsgNoColRow; diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx index 4da2e7c2b45e..99f0c7b5f16a 100644 --- a/sc/source/ui/inc/undoblk.hxx +++ b/sc/source/ui/inc/undoblk.hxx @@ -711,7 +711,7 @@ public: private: ScDocument* pUndoDoc; String aFormula; - ScAddress::Convention eConv; + formula::FormulaGrammar::AddressConvention eConv; ULONG nStartChangeAction; ULONG nEndChangeAction; diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx index ea2951eede5e..ff76ebd16702 100644 --- a/sc/source/ui/inc/undotab.hxx +++ b/sc/source/ui/inc/undotab.hxx @@ -33,7 +33,7 @@ #include "undobase.hxx" #include "markdata.hxx" -#include "grammar.hxx" +#include "formula/grammar.hxx" #include <tools/color.hxx> #ifndef _SVSTDARR_SHORTS @@ -470,7 +470,7 @@ class ScUndoSetGrammar : public ScSimpleUndo public: TYPEINFO(); ScUndoSetGrammar( ScDocShell* pShell, - ScGrammar::Grammar eGrammar ); + formula::FormulaGrammar::Grammar eGrammar ); virtual ~ScUndoSetGrammar(); virtual void Undo(); @@ -481,9 +481,9 @@ public: virtual String GetComment() const; private: - ScGrammar::Grammar meNewGrammar, meOldGrammar; + formula::FormulaGrammar::Grammar meNewGrammar, meOldGrammar; - void DoChange( ScGrammar::Grammar eGrammar ); + void DoChange( formula::FormulaGrammar::Grammar eGrammar ); }; #endif diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx index 75cc94e0e377..0b410d4cc8d6 100644 --- a/sc/source/ui/miscdlgs/anyrefdg.cxx +++ b/sc/source/ui/miscdlgs/anyrefdg.cxx @@ -65,9 +65,29 @@ #include "inputopt.hxx" #include "rangeutl.hxx" -//---------------------------------------------------------------------------- -void lcl_EnableInput( BOOL bEnable ) +ScFormulaReferenceHelper::ScFormulaReferenceHelper(IAnyRefDialog* _pDlg,SfxBindings* _pBindings) + : m_pDlg(_pDlg) + , pRefEdit (NULL) + , m_pWindow(NULL) + , m_pBindings(_pBindings) + , pAccel( NULL ) + , pHiddenMarks(NULL) + , nRefTab(0) + , bHighLightRef( FALSE ) + , bAccInserted( FALSE ) +{ + ScInputOptions aInputOption=SC_MOD()->GetInputOptions(); + bEnableColorRef=aInputOption.GetRangeFinder(); +} +// ----------------------------------------------------------------------------- +ScFormulaReferenceHelper::~ScFormulaReferenceHelper() +{ + if (bAccInserted) + Application::RemoveAccel( pAccel.get() ); +} +// ----------------------------------------------------------------------------- +void ScFormulaReferenceHelper::enableInput( BOOL bEnable ) { TypeId aType(TYPE(ScDocShell)); ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType); @@ -102,222 +122,538 @@ void lcl_EnableInput( BOOL bEnable ) pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType); } } - -void lcl_InvalidateWindows() +// ----------------------------------------------------------------------------- +void ScFormulaReferenceHelper::ShowSimpleReference( const XubString& rStr ) { - TypeId aType(TYPE(ScDocShell)); - ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType); - while( pDocShell ) + if( /*!pRefEdit &&*/ bEnableColorRef ) { - SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell ); - while( pFrame ) + bHighLightRef=TRUE; + ScViewData* pViewData=ScDocShell::GetViewData(); + if ( pViewData ) { - // #71577# enable everything except InPlace, including bean frames - if ( !pFrame->GetFrame()->IsInPlace() ) + ScDocument* pDoc=pViewData->GetDocument(); + ScTabViewShell* pTabViewShell=pViewData->GetViewShell(); + + ScRangeList aRangeList; + + pTabViewShell->DoneRefMode( FALSE ); + pTabViewShell->ClearHighlightRanges(); + + if( ParseWithNames( aRangeList, rStr, pDoc ) ) { - SfxViewShell* p = pFrame->GetViewShell(); - ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p); - if(pViewSh!=NULL) + ScRange* pRangeEntry = aRangeList.First(); + + USHORT nIndex=0; + while(pRangeEntry != NULL) { - Window *pWin=pViewSh->GetWindow(); - if(pWin) - { - Window *pParent=pWin->GetParent(); - if(pParent) - pParent->Invalidate(); - } + ColorData aColName = ScRangeFindList::GetColorName(nIndex++); + pTabViewShell->AddHighlightRange(*pRangeEntry, aColName); + + pRangeEntry = aRangeList.Next(); } } - pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell ); } - - pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType); } } +// ----------------------------------------------------------------------------- +bool ScFormulaReferenceHelper::ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc ) +{ + bool bError = false; + rRanges.RemoveAll(); -//============================================================================ -// class ScRefEdit -//---------------------------------------------------------------------------- + ScAddress::Details aDetails(pDoc->GetAddressConvention(), 0, 0); + ScRangeUtil aRangeUtil; + xub_StrLen nTokenCnt = rStr.GetTokenCount(); + for( xub_StrLen nToken = 0; nToken < nTokenCnt; ++nToken ) + { + ScRange aRange; + String aRangeStr( rStr.GetToken( nToken ) ); -#define SC_ENABLE_TIME 100 + USHORT nFlags = aRange.ParseAny( aRangeStr, pDoc, aDetails ); + if ( nFlags & SCA_VALID ) + { + if ( (nFlags & SCA_TAB_3D) == 0 ) + aRange.aStart.SetTab( nRefTab ); + if ( (nFlags & SCA_TAB2_3D) == 0 ) + aRange.aEnd.SetTab( aRange.aStart.Tab() ); + rRanges.Append( aRange ); + } + else if ( aRangeUtil.MakeRangeFromName( aRangeStr, pDoc, nRefTab, aRange, RUTL_NAMES, aDetails ) ) + rRanges.Append( aRange ); + else + bError = true; + } -ScRefEdit::ScRefEdit( ScAnyRefDlg* pParent, const ResId& rResId ) : - Edit( pParent, rResId ), - pAnyRefDlg( pParent ), - bSilentFocus( FALSE ) -{ - aTimer.SetTimeoutHdl( LINK( this, ScRefEdit, UpdateHdl ) ); - aTimer.SetTimeout( SC_ENABLE_TIME ); + return !bError; } - -ScRefEdit::ScRefEdit( Window* pParent, const ResId& rResId ) : - Edit( pParent, rResId ), - pAnyRefDlg( NULL ), - bSilentFocus( FALSE ) +// ----------------------------------------------------------------------------- +void ScFormulaReferenceHelper::ShowFormulaReference( const XubString& rStr ) { -} + if( /*!pRefEdit &&*/ bEnableColorRef) + { + bHighLightRef=TRUE; + ScViewData* pViewData=ScDocShell::GetViewData(); + if ( pViewData && pRefComp.get() ) + { + ScTabViewShell* pTabViewShell=pViewData->GetViewShell(); + SCCOL nCol = pViewData->GetCurX(); + SCROW nRow = pViewData->GetCurY(); + SCTAB nTab = pViewData->GetTabNo(); + ScAddress aPos( nCol, nRow, nTab ); -ScRefEdit::~ScRefEdit() -{ - aTimer.SetTimeoutHdl( Link() ); - aTimer.Stop(); -} + ScTokenArray* pScTokA=pRefComp->CompileString(rStr); + //pRefComp->CompileTokenArray(); -void ScRefEdit::SetRefString( const XubString& rStr ) -{ - Edit::SetText( rStr ); -} + if(pTabViewShell!=NULL && pScTokA!=NULL) + { + pTabViewShell->DoneRefMode( FALSE ); + pTabViewShell->ClearHighlightRanges(); -void ScRefEdit::SetText( const XubString& rStr ) -{ - Edit::SetText( rStr ); - UpdateHdl( &aTimer ); -} + pScTokA->Reset(); + const ScToken* pToken = static_cast<const ScToken*>(pScTokA->GetNextReference()); -void ScRefEdit::StartUpdateData() -{ - aTimer.Start(); -} + USHORT nIndex=0; -//UNUSED2008-05 void ScRefEdit::SilentGrabFocus() -//UNUSED2008-05 { -//UNUSED2008-05 bSilentFocus = TRUE; -//UNUSED2008-05 GrabFocus(); -//UNUSED2008-05 bSilentFocus = FALSE; -//UNUSED2008-05 } + while(pToken!=NULL) + { + BOOL bDoubleRef=(pToken->GetType()==formula::svDoubleRef); -void ScRefEdit::SetRefDialog( ScAnyRefDlg* pDlg ) + + if(pToken->GetType()==formula::svSingleRef || bDoubleRef) + { + ScRange aRange; + if(bDoubleRef) + { + ScComplexRefData aRef( pToken->GetDoubleRef() ); + aRef.CalcAbsIfRel( aPos ); + aRange.aStart.Set( aRef.Ref1.nCol, aRef.Ref1.nRow, aRef.Ref1.nTab ); + aRange.aEnd.Set( aRef.Ref2.nCol, aRef.Ref2.nRow, aRef.Ref2.nTab ); + } + else + { + ScSingleRefData aRef( pToken->GetSingleRef() ); + aRef.CalcAbsIfRel( aPos ); + aRange.aStart.Set( aRef.nCol, aRef.nRow, aRef.nTab ); + aRange.aEnd = aRange.aStart; + } + ColorData aColName=ScRangeFindList::GetColorName(nIndex++); + pTabViewShell->AddHighlightRange(aRange, aColName); + } + + pToken = static_cast<const ScToken*>(pScTokA->GetNextReference()); + } + } + if(pScTokA!=NULL) delete pScTokA; + } + } +} +// ----------------------------------------------------------------------------- +void ScFormulaReferenceHelper::HideReference( BOOL bDoneRefMode ) { - pAnyRefDlg = pDlg; + ScViewData* pViewData=ScDocShell::GetViewData(); - if( pDlg ) + if( pViewData && /*!pRefEdit &&*/ bHighLightRef && bEnableColorRef) { - aTimer.SetTimeoutHdl( LINK( this, ScRefEdit, UpdateHdl ) ); - aTimer.SetTimeout( SC_ENABLE_TIME ); + ScTabViewShell* pTabViewShell=pViewData->GetViewShell(); + + if(pTabViewShell!=NULL) + { + // bDoneRefMode is FALSE when called from before SetReference. + // In that case, RefMode was just started and must not be ended now. + + if ( bDoneRefMode ) + pTabViewShell->DoneRefMode( FALSE ); + pTabViewShell->ClearHighlightRanges(); + } + bHighLightRef=FALSE; } - else +} +// ----------------------------------------------------------------------------- +void ScFormulaReferenceHelper::ShowReference( const XubString& rStr ) +{ + if( /*!pRefEdit &&*/ bEnableColorRef ) { - aTimer.SetTimeoutHdl( Link() ); - aTimer.Stop(); + if( rStr.Search('(')!=STRING_NOTFOUND || + rStr.Search('+')!=STRING_NOTFOUND || + rStr.Search('*')!=STRING_NOTFOUND || + rStr.Search('-')!=STRING_NOTFOUND || + rStr.Search('/')!=STRING_NOTFOUND || + rStr.Search('&')!=STRING_NOTFOUND || + rStr.Search('<')!=STRING_NOTFOUND || + rStr.Search('>')!=STRING_NOTFOUND || + rStr.Search('=')!=STRING_NOTFOUND || + rStr.Search('^')!=STRING_NOTFOUND) + { + ShowFormulaReference(rStr); + } + else + { + ShowSimpleReference(rStr); + } } } - -void ScRefEdit::Modify() +// ----------------------------------------------------------------------------- +void ScFormulaReferenceHelper::ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton ) { - Edit::Modify(); - if( pAnyRefDlg ) - pAnyRefDlg->HideReference(); -} + if( !pRefEdit && pEdit ) + { + m_pDlg->RefInputStart( pEdit, pButton ); +// if( pRefEdit ) +// pRefEdit->SilentGrabFocus(); + } -void ScRefEdit::KeyInput( const KeyEvent& rKEvt ) -{ - const KeyCode& rKeyCode = rKEvt.GetKeyCode(); - if( pAnyRefDlg && !rKeyCode.GetModifier() && (rKeyCode.GetCode() == KEY_F2) ) - pAnyRefDlg->ReleaseFocus( this ); - else - Edit::KeyInput( rKEvt ); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if( pViewShell ) + { + pViewShell->ActiveGrabFocus(); + if( pRefEdit ) + { + const ScViewData* pViewData = pViewShell->GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + ScRangeList aRangeList; + if( ParseWithNames( aRangeList, pRefEdit->GetText(), pDoc ) ) + { + const ScRange* pRange = aRangeList.GetObject( 0 ); + if( pRange ) + { + pViewShell->SetTabNo( pRange->aStart.Tab() ); + pViewShell->MoveCursorAbs( pRange->aStart.Col(), + pRange->aStart.Row(), SC_FOLLOW_JUMP, FALSE, FALSE ); + pViewShell->MoveCursorAbs( pRange->aEnd.Col(), + pRange->aEnd.Row(), SC_FOLLOW_JUMP, TRUE, FALSE ); + m_pDlg->SetReference( *pRange, pDoc ); + } + } + } + } } - -void ScRefEdit::GetFocus() +// ----------------------------------------------------------------------------- +void ScFormulaReferenceHelper::Init() { - Edit::GetFocus(); - if( !bSilentFocus ) - StartUpdateData(); -} + ScViewData* pViewData=ScDocShell::GetViewData(); //! use pScViewShell? + if ( pViewData ) + { + ScDocument* pDoc = pViewData->GetDocument(); + SCCOL nCol = pViewData->GetCurX(); + SCROW nRow = pViewData->GetCurY(); + SCTAB nTab = pViewData->GetTabNo(); + ScAddress aCursorPos( nCol, nRow, nTab ); -void ScRefEdit::LoseFocus() -{ - Edit::LoseFocus(); - if( pAnyRefDlg ) - pAnyRefDlg->HideReference(); -} + String rStrExp; + pRefCell.reset( new ScFormulaCell( pDoc, aCursorPos, rStrExp ) ); + pRefComp.reset( new ScCompiler( pDoc, aCursorPos) ); + pRefComp->SetGrammar( pDoc->GetGrammar() ); + pRefComp->SetCompileForFAP(TRUE); -IMPL_LINK( ScRefEdit, UpdateHdl, Timer*, EMPTYARG ) + nRefTab = nTab; + } // if ( pViewData ) +} +// ----------------------------------------------------------------------------- +IMPL_LINK( ScFormulaReferenceHelper, AccelSelectHdl, Accelerator *, pSelAccel ) { - if( pAnyRefDlg ) - pAnyRefDlg->ShowReference( GetText() ); - return 0; + if ( !pSelAccel ) + return 0; + + switch ( pSelAccel->GetCurKeyCode().GetCode() ) + { + case KEY_RETURN: + case KEY_ESCAPE: + if( pRefEdit ) + pRefEdit->GrabFocus(); + m_pDlg->RefInputDone( TRUE ); + break; + } + return TRUE; } +//---------------------------------------------------------------------------- +void ScFormulaReferenceHelper::RefInputDone( BOOL bForced ) +{ + if (pRefEdit && (bForced || !pRefBtn)) + { + if (bAccInserted) // Accelerator wieder abschalten + { + Application::RemoveAccel( pAccel.get() ); + bAccInserted = FALSE; + } + // Fenstertitel anpassen + m_pWindow->SetText(sOldDialogText); -//============================================================================ -// class ScRefButton -//---------------------------------------------------------------------------- + // Fenster wieder gross + m_pWindow->SetOutputSizePixel(aOldDialogSize); -ScRefButton::ScRefButton( ScAnyRefDlg* pParent, const ResId& rResId, ScRefEdit* pEdit ) : - ImageButton( pParent, rResId ), - aImgRefStart( ScResId( RID_BMP_REFBTN1 ) ), - aImgRefStartHC( ScResId( RID_BMP_REFBTN1_H ) ), - aImgRefDone( ScResId( RID_BMP_REFBTN2 ) ), - aImgRefDoneHC( ScResId( RID_BMP_REFBTN2_H ) ), - pAnyRefDlg( pParent ), - pRefEdit( pEdit ) -{ - SetStartImage(); -} + // pEditCell an alte Position + pRefEdit->SetPosSizePixel(aOldEditPos, aOldEditSize); -ScRefButton::ScRefButton( Window *pParent, const ResId& rResId ) : - ImageButton( pParent, rResId ), - aImgRefStart( ScResId( RID_BMP_REFBTN1 ) ), - aImgRefStartHC( ScResId( RID_BMP_REFBTN1_H ) ), - aImgRefDone( ScResId( RID_BMP_REFBTN2 ) ), - aImgRefDoneHC( ScResId( RID_BMP_REFBTN2_H ) ), - pAnyRefDlg( NULL ), - pRefEdit( NULL ) -{ - SetStartImage(); + // set button position and image + if( pRefBtn ) + { + pRefBtn->SetPosPixel( aOldButtonPos ); + pRefBtn->SetStartImage(); + } + + // Alle anderen: Show(); + USHORT nChildren = m_pWindow->GetChildCount(); + for ( USHORT i = 0; i < nChildren; i++ ) + if (pHiddenMarks[i]) + { + m_pWindow->GetChild(i)->GetWindow( WINDOW_CLIENT )->Show(); + } + delete [] pHiddenMarks; + + pRefEdit = NULL; + pRefBtn = NULL; + } } +// ----------------------------------------------------------------------------- +void ScFormulaReferenceHelper::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton ) +{ + if (!pRefEdit) + { + pRefEdit = pEdit; + pRefBtn = pButton; + + // Neuen Fenstertitel basteln + String sNewDialogText; + sOldDialogText = m_pWindow->GetText(); + sNewDialogText = sOldDialogText; + sNewDialogText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " )); + + // Alle Elemente ausser EditCell und Button verstecken + USHORT nChildren = m_pWindow->GetChildCount(); + pHiddenMarks = new BOOL [nChildren]; + for (USHORT i = 0; i < nChildren; i++) + { + pHiddenMarks[i] = FALSE; + Window* pWin = m_pWindow->GetChild(i); + pWin = pWin->GetWindow( WINDOW_CLIENT ); + if (pWin == (Window*)pRefEdit) + { + sNewDialogText += m_pWindow->GetChild(i-1)->GetWindow( WINDOW_CLIENT )->GetText(); + } + else if (pWin == (Window*)pRefBtn) + ; // do nothing + else if (pWin->IsVisible()) + { + pHiddenMarks[i] = TRUE; + pWin->Hide(); + } + } + + // Alte Daten merken + aOldDialogSize = m_pWindow->GetOutputSizePixel(); + aOldEditPos = pRefEdit->GetPosPixel(); + aOldEditSize = pRefEdit->GetSizePixel(); + if (pRefBtn) + aOldButtonPos = pRefBtn->GetPosPixel(); + + // Edit-Feld verschieben und anpassen + Size aNewDlgSize(aOldDialogSize.Width(), aOldEditSize.Height()); + Size aNewEditSize(aNewDlgSize); + long nOffset = 0; + if (pRefBtn) + { + aNewEditSize.Width() -= pRefBtn->GetSizePixel().Width(); + aNewEditSize.Width() -= aOldButtonPos.X() - (aOldEditPos.X()+aOldEditSize.Width()); + + long nHeight = pRefBtn->GetSizePixel().Height(); + if ( nHeight > aOldEditSize.Height() ) + { + aNewDlgSize.Height() = nHeight; + nOffset = (nHeight-aOldEditSize.Height()) / 2; + } + aNewEditSize.Width() -= nOffset; + } + pRefEdit->SetPosSizePixel(Point(nOffset, nOffset), aNewEditSize); + + // set button position and image + if( pRefBtn ) + { + pRefBtn->SetPosPixel( Point( aOldDialogSize.Width() - pRefBtn->GetSizePixel().Width(), 0 ) ); + pRefBtn->SetEndImage(); + } -void ScRefButton::SetStartImage() + // Fenster verkleinern + m_pWindow->SetOutputSizePixel(aNewDlgSize); + + // Fenstertitel anpassen + m_pWindow->SetText( MnemonicGenerator::EraseAllMnemonicChars( sNewDialogText ) ); + +// if ( pButton ) // ueber den Button: Enter und Escape abfangen +// { + if (!pAccel.get()) + { + pAccel.reset( new Accelerator ); + pAccel->InsertItem( 1, KeyCode( KEY_RETURN ) ); + pAccel->InsertItem( 2, KeyCode( KEY_ESCAPE ) ); + pAccel->SetSelectHdl( LINK( this, ScFormulaReferenceHelper, AccelSelectHdl ) ); + } + Application::InsertAccel( pAccel.get() ); + bAccInserted = TRUE; +// } + } +} +// ----------------------------------------------------------------------------- +void ScFormulaReferenceHelper::ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton ) { - SetModeImage( aImgRefStart ); - SetModeImage( aImgRefStartHC, BMP_COLOR_HIGHCONTRAST ); + if( pEdit ) + { + if( pRefEdit == pEdit ) // is this the active ref edit field? + { + pRefEdit->GrabFocus(); // before RefInputDone() + m_pDlg->RefInputDone( TRUE ); // finish ref input + } + else + { + m_pDlg->RefInputDone( TRUE ); // another active ref edit? + m_pDlg->RefInputStart( pEdit, pButton ); // start ref input + // pRefEdit might differ from pEdit after RefInputStart() (i.e. ScFormulaDlg) + if( pRefEdit ) + pRefEdit->GrabFocus(); + } + } } +// ----------------------------------------------------------------------------- +BOOL ScFormulaReferenceHelper::DoClose( USHORT nId ) +{ + SfxApplication* pSfxApp = SFX_APP(); -void ScRefButton::SetEndImage() + SetDispatcherLock( FALSE ); //! here and in dtor ? + + SfxViewFrame* pViewFrm = SfxViewFrame::Current(); + if ( pViewFrm && pViewFrm->HasChildWindow(FID_INPUTLINE_STATUS) ) + { + // Die Eingabezeile wird per ToolBox::Disable disabled, muss darum auch + // per ToolBox::Enable wieder aktiviert werden (vor dem Enable des AppWindow), + // damit die Buttons auch wieder enabled gezeichnet werden. + SfxChildWindow* pChild = pViewFrm->GetChildWindow(FID_INPUTLINE_STATUS); + if (pChild) + { + ScInputWindow* pWin = (ScInputWindow*)pChild->GetWindow(); + pWin->Enable(); + } + } + + // find parent view frame to close dialog + SfxViewFrame* pMyViewFrm = NULL; + if ( m_pBindings ) + { + SfxDispatcher* pMyDisp = m_pBindings->GetDispatcher(); + if (pMyDisp) + pMyViewFrm = pMyDisp->GetFrame(); + } + SC_MOD()->SetRefDialog( nId, FALSE, pMyViewFrm ); + + pSfxApp->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) ); + + ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell(); + if ( pScViewShell ) + pScViewShell->UpdateInputHandler(TRUE); + + return TRUE; +} +void ScFormulaReferenceHelper::SetDispatcherLock( BOOL bLock ) { - SetModeImage( aImgRefDone ); - SetModeImage( aImgRefDoneHC, BMP_COLOR_HIGHCONTRAST ); + // lock / unlock only the dispatchers of Calc documents + + TypeId aType(TYPE(ScDocShell)); + ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType); + while( pDocShell ) + { + SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell ); + while( pFrame ) + { + SfxDispatcher* pDisp = pFrame->GetDispatcher(); + if (pDisp) + pDisp->Lock( bLock ); + + pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell ); + } + pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType); + } + + // if a new view is created while the dialog is open, + // that view's dispatcher is locked when trying to create the dialog + // for that view (ScTabViewShell::CreateRefDialog) } +// ----------------------------------------------------------------------------- +void ScFormulaReferenceHelper::ViewShellChanged(ScTabViewShell* /* pScViewShell */) +{ + enableInput( FALSE ); -void ScRefButton::SetReferences( ScAnyRefDlg* pDlg, ScRefEdit* pEdit ) + EnableSpreadsheets(); +} +void ScFormulaReferenceHelper::EnableSpreadsheets(BOOL bFlag, BOOL bChilds) { - pAnyRefDlg = pDlg; - pRefEdit = pEdit; + TypeId aType(TYPE(ScDocShell)); + ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType); + while( pDocShell ) + { + SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell ); + while( pFrame ) + { + // #71577# enable everything except InPlace, including bean frames + if ( !pFrame->GetFrame()->IsInPlace() ) + { + SfxViewShell* p = pFrame->GetViewShell(); + ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p); + if(pViewSh!=NULL) + { + Window *pWin=pViewSh->GetWindow(); + if(pWin) + { + Window *pParent=pWin->GetParent(); + if(pParent) + { + pParent->EnableInput(bFlag,FALSE); + if(bChilds) + pViewSh->EnableRefInput(bFlag); + } + } + } + } + pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell ); + } + + pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType); + } } //---------------------------------------------------------------------------- -void ScRefButton::Click() -{ - if( pAnyRefDlg ) - pAnyRefDlg->ToggleCollapsed( pRefEdit, this ); -} -void ScRefButton::KeyInput( const KeyEvent& rKEvt ) -{ - const KeyCode& rKeyCode = rKEvt.GetKeyCode(); - if( pAnyRefDlg && !rKeyCode.GetModifier() && (rKeyCode.GetCode() == KEY_F2) ) - pAnyRefDlg->ReleaseFocus( pRefEdit ); - else - ImageButton::KeyInput( rKEvt ); -} -void ScRefButton::GetFocus() +void lcl_InvalidateWindows() { - ImageButton::GetFocus(); - if( pRefEdit ) - pRefEdit->StartUpdateData(); -} + TypeId aType(TYPE(ScDocShell)); + ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType); + while( pDocShell ) + { + SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell ); + while( pFrame ) + { + // #71577# enable everything except InPlace, including bean frames + if ( !pFrame->GetFrame()->IsInPlace() ) + { + SfxViewShell* p = pFrame->GetViewShell(); + ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p); + if(pViewSh!=NULL) + { + Window *pWin=pViewSh->GetWindow(); + if(pWin) + { + Window *pParent=pWin->GetParent(); + if(pParent) + pParent->Invalidate(); + } + } + } + pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell ); + } -void ScRefButton::LoseFocus() -{ - ImageButton::LoseFocus(); - if( pRefEdit ) - pRefEdit->Modify(); + pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType); + } } - - //---------------------------------------------------------------------------- void lcl_HideAllReferences() @@ -338,17 +674,11 @@ void lcl_HideAllReferences() ScAnyRefDlg::ScAnyRefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, USHORT nResId) : SfxModelessDialog ( pB, pCW, pParent, ScResId( nResId ) ), + m_aHelper(this,pB), pMyBindings( pB ), - pRefEdit( NULL ), - pAccel( NULL ), - bAccInserted( FALSE ), - bHighLightRef( FALSE ), - bEnableColorRef( FALSE ), - pRefCell(NULL), - pRefComp(NULL), - pActiveWin(NULL), - nRefTab(0) + pActiveWin(NULL) { + m_aHelper.SetWindow(this); if(GetHelpId()==0) //Hack, da im SfxModelessDialog die HelpId SetHelpId(GetUniqueId()); //fuer einen ModelessDialog entfernt und //in eine UniqueId gewandelt wird, machen @@ -360,16 +690,6 @@ ScAnyRefDlg::ScAnyRefDlg( SfxBindings* pB, SfxChildWindow* pCW, // ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell(); ScTabViewShell* pScViewShell = NULL; - SfxDispatcher* pDisp = pB->GetDispatcher(); - if ( pDisp ) - { - SfxViewFrame* pViewFrm = pDisp->GetFrame(); - if ( pViewFrm ) - pScViewShell = PTR_CAST( ScTabViewShell, pViewFrm->GetViewShell() ); - } - - if( pScViewShell ) - pScViewShell->UpdateInputHandler(TRUE); // title has to be from the view that opened the dialog, // even if it's not the current view @@ -382,7 +702,12 @@ ScAnyRefDlg::ScAnyRefDlg( SfxBindings* pB, SfxChildWindow* pCW, { SfxViewFrame* pMyViewFrm = pMyDisp->GetFrame(); if (pMyViewFrm) + { + pScViewShell = PTR_CAST( ScTabViewShell, pMyViewFrm->GetViewShell() ); + if( pScViewShell ) + pScViewShell->UpdateInputHandler(TRUE); pParentDoc = pMyViewFrm->GetObjectShell(); + } } } if ( !pParentDoc && pScViewShell ) // use current only if above fails @@ -397,32 +722,13 @@ ScAnyRefDlg::ScAnyRefDlg( SfxBindings* pB, SfxChildWindow* pCW, if ( pInputHdl ) pInputHdl->NotifyChange( NULL ); - lcl_EnableInput( FALSE ); + m_aHelper.enableInput( FALSE ); - EnableSpreadsheets(); - - ScInputOptions aInputOption=SC_MOD()->GetInputOptions(); - bEnableColorRef=aInputOption.GetRangeFinder(); + m_aHelper.EnableSpreadsheets(); - ScViewData* pViewData=ScDocShell::GetViewData(); //! use pScViewShell? - if ( pViewData ) - { - ScDocument* pDoc = pViewData->GetDocument(); - SCCOL nCol = pViewData->GetCurX(); - SCROW nRow = pViewData->GetCurY(); - SCTAB nTab = pViewData->GetTabNo(); - ScAddress aCursorPos( nCol, nRow, nTab ); - - String rStrExp; - pRefCell = new ScFormulaCell( pDoc, aCursorPos, rStrExp ); - pRefComp=new ScCompiler( pDoc, aCursorPos, pDoc->GetGrammar() ); - pRefComp->SetCompileForFAP(TRUE); + m_aHelper.Init(); - nRefTab = nTab; - } - - - SetDispatcherLock( TRUE ); + m_aHelper.SetDispatcherLock( TRUE ); //@Test //SFX_APPWINDOW->Disable(TRUE); //@BugID 54702 } @@ -434,19 +740,13 @@ ScAnyRefDlg::~ScAnyRefDlg() HideReference(); lcl_HideAllReferences(); - lcl_EnableInput( TRUE ); + m_aHelper.enableInput( TRUE ); SetModalInputMode(FALSE); SetDispatcherLock( FALSE ); //! here and in DoClose ? - delete pRefComp; - delete pRefCell; - ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell(); if( pScViewShell ) pScViewShell->UpdateInputHandler(TRUE); - if (bAccInserted) - Application::RemoveAccel( pAccel ); - delete pAccel; ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(); @@ -520,281 +820,25 @@ BOOL __EXPORT ScAnyRefDlg::IsRefInputMode() const BOOL __EXPORT ScAnyRefDlg::DoClose( USHORT nId ) { - SfxApplication* pSfxApp = SFX_APP(); - - SetDispatcherLock( FALSE ); //! here and in dtor ? - - SfxViewFrame* pViewFrm = SfxViewFrame::Current(); - if ( pViewFrm && pViewFrm->HasChildWindow(FID_INPUTLINE_STATUS) ) - { - // Die Eingabezeile wird per ToolBox::Disable disabled, muss darum auch - // per ToolBox::Enable wieder aktiviert werden (vor dem Enable des AppWindow), - // damit die Buttons auch wieder enabled gezeichnet werden. - SfxChildWindow* pChild = pViewFrm->GetChildWindow(FID_INPUTLINE_STATUS); - if (pChild) - { - ScInputWindow* pWin = (ScInputWindow*)pChild->GetWindow(); - pWin->Enable(); - } - } - - // find parent view frame to close dialog - SfxViewFrame* pMyViewFrm = NULL; - if ( pMyBindings ) - { - SfxDispatcher* pMyDisp = pMyBindings->GetDispatcher(); - if (pMyDisp) - pMyViewFrm = pMyDisp->GetFrame(); - } - SC_MOD()->SetRefDialog( nId, FALSE, pMyViewFrm ); - - pSfxApp->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) ); - - ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell(); - if ( pScViewShell ) - pScViewShell->UpdateInputHandler(TRUE); - + m_aHelper.DoClose(nId); return TRUE; } void ScAnyRefDlg::EnableSpreadsheets(BOOL bFlag, BOOL bChilds) { - TypeId aType(TYPE(ScDocShell)); - ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType); - while( pDocShell ) - { - SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell ); - while( pFrame ) - { - // #71577# enable everything except InPlace, including bean frames - if ( !pFrame->GetFrame()->IsInPlace() ) - { - SfxViewShell* p = pFrame->GetViewShell(); - ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p); - if(pViewSh!=NULL) - { - Window *pWin=pViewSh->GetWindow(); - if(pWin) - { - Window *pParent=pWin->GetParent(); - if(pParent) - { - pParent->EnableInput(bFlag,FALSE); - if(bChilds) - pViewSh->EnableRefInput(bFlag); - } - } - } - } - pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell ); - } - - pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType); - } + m_aHelper.EnableSpreadsheets(bFlag, bChilds); } void ScAnyRefDlg::SetDispatcherLock( BOOL bLock ) { - // lock / unlock only the dispatchers of Calc documents - - TypeId aType(TYPE(ScDocShell)); - ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType); - while( pDocShell ) - { - SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell ); - while( pFrame ) - { - SfxDispatcher* pDisp = pFrame->GetDispatcher(); - if (pDisp) - pDisp->Lock( bLock ); - - pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell ); - } - pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType); - } - - // if a new view is created while the dialog is open, - // that view's dispatcher is locked when trying to create the dialog - // for that view (ScTabViewShell::CreateRefDialog) + m_aHelper.SetDispatcherLock( bLock ); } //---------------------------------------------------------------------------- -void ScAnyRefDlg::ViewShellChanged(ScTabViewShell* /* pScViewShell */) -{ - lcl_EnableInput( FALSE ); - - EnableSpreadsheets(); -} - -bool ScAnyRefDlg::ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc ) -{ - bool bError = false; - rRanges.RemoveAll(); - - ScAddress::Details aDetails(pDoc->GetAddressConvention(), 0, 0); - ScRangeUtil aRangeUtil; - xub_StrLen nTokenCnt = rStr.GetTokenCount(); - for( xub_StrLen nToken = 0; nToken < nTokenCnt; ++nToken ) - { - ScRange aRange; - String aRangeStr( rStr.GetToken( nToken ) ); - - USHORT nFlags = aRange.ParseAny( aRangeStr, pDoc, aDetails ); - if ( nFlags & SCA_VALID ) - { - if ( (nFlags & SCA_TAB_3D) == 0 ) - aRange.aStart.SetTab( nRefTab ); - if ( (nFlags & SCA_TAB2_3D) == 0 ) - aRange.aEnd.SetTab( aRange.aStart.Tab() ); - rRanges.Append( aRange ); - } - else if ( aRangeUtil.MakeRangeFromName( aRangeStr, pDoc, nRefTab, aRange, RUTL_NAMES, aDetails ) ) - rRanges.Append( aRange ); - else - bError = true; - } - - return !bError; -} - -void ScAnyRefDlg::ShowReference( const XubString& rStr ) -{ - if( /*!pRefEdit &&*/ bEnableColorRef ) - { - if( rStr.Search('(')!=STRING_NOTFOUND || - rStr.Search('+')!=STRING_NOTFOUND || - rStr.Search('*')!=STRING_NOTFOUND || - rStr.Search('-')!=STRING_NOTFOUND || - rStr.Search('/')!=STRING_NOTFOUND || - rStr.Search('&')!=STRING_NOTFOUND || - rStr.Search('<')!=STRING_NOTFOUND || - rStr.Search('>')!=STRING_NOTFOUND || - rStr.Search('=')!=STRING_NOTFOUND || - rStr.Search('^')!=STRING_NOTFOUND) - { - ShowFormulaReference(rStr); - } - else - { - ShowSimpleReference(rStr); - } - } -} - -void ScAnyRefDlg::ShowSimpleReference( const XubString& rStr ) +void ScAnyRefDlg::ViewShellChanged(ScTabViewShell* pScViewShell ) { - if( /*!pRefEdit &&*/ bEnableColorRef ) - { - bHighLightRef=TRUE; - ScViewData* pViewData=ScDocShell::GetViewData(); - if ( pViewData ) - { - ScDocument* pDoc=pViewData->GetDocument(); - ScTabViewShell* pTabViewShell=pViewData->GetViewShell(); - - ScRangeList aRangeList; - - pTabViewShell->DoneRefMode( FALSE ); - pTabViewShell->ClearHighlightRanges(); - - if( ParseWithNames( aRangeList, rStr, pDoc ) ) - { - ScRange* pRangeEntry=aRangeList.First(); - - USHORT nIndex=0; - while(pRangeEntry!=NULL) - { - ColorData aColName=ScRangeFindList::GetColorName(nIndex++); - pTabViewShell->AddHighlightRange(*pRangeEntry, aColName); - - pRangeEntry=aRangeList.Next(); - } - } - } - } -} - -void ScAnyRefDlg::ShowFormulaReference( const XubString& rStr ) -{ - if( /*!pRefEdit &&*/ bEnableColorRef) - { - bHighLightRef=TRUE; - ScViewData* pViewData=ScDocShell::GetViewData(); - if ( pViewData && pRefComp ) - { - ScTabViewShell* pTabViewShell=pViewData->GetViewShell(); - SCCOL nCol = pViewData->GetCurX(); - SCROW nRow = pViewData->GetCurY(); - SCTAB nTab = pViewData->GetTabNo(); - ScAddress aPos( nCol, nRow, nTab ); - - ScTokenArray* pScTokA=pRefComp->CompileString(rStr); - //pRefComp->CompileTokenArray(); - - if(pTabViewShell!=NULL && pScTokA!=NULL) - { - pTabViewShell->DoneRefMode( FALSE ); - pTabViewShell->ClearHighlightRanges(); - - pScTokA->Reset(); - const ScToken* pToken=pScTokA->GetNextReference(); - - USHORT nIndex=0; - - while(pToken!=NULL) - { - BOOL bDoubleRef=(pToken->GetType()==svDoubleRef); - - - if(pToken->GetType()==svSingleRef || bDoubleRef) - { - ScRange aRange; - if(bDoubleRef) - { - ScComplexRefData aRef( pToken->GetDoubleRef() ); - aRef.CalcAbsIfRel( aPos ); - aRange.aStart.Set( aRef.Ref1.nCol, aRef.Ref1.nRow, aRef.Ref1.nTab ); - aRange.aEnd.Set( aRef.Ref2.nCol, aRef.Ref2.nRow, aRef.Ref2.nTab ); - } - else - { - ScSingleRefData aRef( pToken->GetSingleRef() ); - aRef.CalcAbsIfRel( aPos ); - aRange.aStart.Set( aRef.nCol, aRef.nRow, aRef.nTab ); - aRange.aEnd = aRange.aStart; - } - ColorData aColName=ScRangeFindList::GetColorName(nIndex++); - pTabViewShell->AddHighlightRange(aRange, aColName); - } - - pToken=pScTokA->GetNextReference(); - } - } - if(pScTokA!=NULL) delete pScTokA; - } - } -} - -void ScAnyRefDlg::HideReference( BOOL bDoneRefMode ) -{ - ScViewData* pViewData=ScDocShell::GetViewData(); - - if( pViewData && /*!pRefEdit &&*/ bHighLightRef && bEnableColorRef) - { - ScTabViewShell* pTabViewShell=pViewData->GetViewShell(); - - if(pTabViewShell!=NULL) - { - // bDoneRefMode is FALSE when called from before SetReference. - // In that case, RefMode was just started and must not be ended now. - - if ( bDoneRefMode ) - pTabViewShell->DoneRefMode( FALSE ); - pTabViewShell->ClearHighlightRanges(); - } - bHighLightRef=FALSE; - } + m_aHelper.ViewShellChanged(pScViewShell); } //---------------------------------------------------------------------------- @@ -820,191 +864,16 @@ BOOL __EXPORT ScAnyRefDlg::IsTableLocked() const // //---------------------------------------------------------------------------- -void ScAnyRefDlg::RefInputStart( ScRefEdit* pEdit, ScRefButton* pButton ) -{ - if (!pRefEdit) - { - pRefEdit = pEdit; - pRefBtn = pButton; - - // Neuen Fenstertitel basteln - String sNewDialogText; - sOldDialogText = GetText(); - sNewDialogText = sOldDialogText; - sNewDialogText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " )); - - // Alle Elemente ausser EditCell und Button verstecken - USHORT nChildren = GetChildCount(); - pHiddenMarks = new BOOL [nChildren]; - for (USHORT i = 0; i < nChildren; i++) - { - pHiddenMarks[i] = FALSE; - Window* pWin = GetChild(i); - pWin = pWin->GetWindow( WINDOW_CLIENT ); - if (pWin == (Window*)pRefEdit) - { - sNewDialogText += GetChild(i-1)->GetWindow( WINDOW_CLIENT )->GetText(); - } - else if (pWin == (Window*)pRefBtn) - ; // do nothing - else if (pWin->IsVisible()) - { - pHiddenMarks[i] = TRUE; - pWin->Hide(); - } - } - - // Alte Daten merken - aOldDialogSize = GetOutputSizePixel(); - aOldEditPos = pRefEdit->GetPosPixel(); - aOldEditSize = pRefEdit->GetSizePixel(); - if (pRefBtn) - aOldButtonPos = pRefBtn->GetPosPixel(); - - // Edit-Feld verschieben und anpassen - Size aNewDlgSize(aOldDialogSize.Width(), aOldEditSize.Height()); - Size aNewEditSize(aNewDlgSize); - long nOffset = 0; - if (pRefBtn) - { - aNewEditSize.Width() -= pRefBtn->GetSizePixel().Width(); - aNewEditSize.Width() -= aOldButtonPos.X() - (aOldEditPos.X()+aOldEditSize.Width()); - - long nHeight = pRefBtn->GetSizePixel().Height(); - if ( nHeight > aOldEditSize.Height() ) - { - aNewDlgSize.Height() = nHeight; - nOffset = (nHeight-aOldEditSize.Height()) / 2; - } - aNewEditSize.Width() -= nOffset; - } - pRefEdit->SetPosSizePixel(Point(nOffset, nOffset), aNewEditSize); - - // set button position and image - if( pRefBtn ) - { - pRefBtn->SetPosPixel( Point( aOldDialogSize.Width() - pRefBtn->GetSizePixel().Width(), 0 ) ); - pRefBtn->SetEndImage(); - } - - // Fenster verkleinern - SetOutputSizePixel(aNewDlgSize); - - // Fenstertitel anpassen - SetText( MnemonicGenerator::EraseAllMnemonicChars( sNewDialogText ) ); - -// if ( pButton ) // ueber den Button: Enter und Escape abfangen -// { - if (!pAccel) - { - pAccel = new Accelerator; - pAccel->InsertItem( 1, KeyCode( KEY_RETURN ) ); - pAccel->InsertItem( 2, KeyCode( KEY_ESCAPE ) ); - pAccel->SetSelectHdl( LINK( this, ScAnyRefDlg, AccelSelectHdl ) ); - } - Application::InsertAccel( pAccel ); - bAccInserted = TRUE; -// } - } -} - -//---------------------------------------------------------------------------- - -void ScAnyRefDlg::RefInputDone( BOOL bForced ) +void ScAnyRefDlg::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton ) { - if (pRefEdit && (bForced || !pRefBtn)) - { - if (bAccInserted) // Accelerator wieder abschalten - { - Application::RemoveAccel( pAccel ); - bAccInserted = FALSE; - } - - // Fenstertitel anpassen - SetText(sOldDialogText); - - // Fenster wieder gross - SetOutputSizePixel(aOldDialogSize); - - // pEditCell an alte Position - pRefEdit->SetPosSizePixel(aOldEditPos, aOldEditSize); - - // set button position and image - if( pRefBtn ) - { - pRefBtn->SetPosPixel( aOldButtonPos ); - pRefBtn->SetStartImage(); - } - - // Alle anderen: Show(); - USHORT nChildren = GetChildCount(); - for ( USHORT i = 0; i < nChildren; i++ ) - if (pHiddenMarks[i]) - { - GetChild(i)->GetWindow( WINDOW_CLIENT )->Show(); - } - delete [] pHiddenMarks; - - pRefEdit = NULL; - pRefBtn = NULL; - } + m_aHelper.RefInputStart( pEdit, pButton ); } -void ScAnyRefDlg::ToggleCollapsed( ScRefEdit* pEdit, ScRefButton* pButton ) -{ - if( pEdit ) - { - if( pRefEdit == pEdit ) // is this the active ref edit field? - { - pRefEdit->GrabFocus(); // before RefInputDone() - RefInputDone( TRUE ); // finish ref input - } - else - { - RefInputDone( TRUE ); // another active ref edit? - RefInputStart( pEdit, pButton ); // start ref input - // pRefEdit might differ from pEdit after RefInputStart() (i.e. ScFormulaDlg) - if( pRefEdit ) - pRefEdit->GrabFocus(); - } - } -} -void ScAnyRefDlg::ReleaseFocus( ScRefEdit* pEdit, ScRefButton* pButton ) +void ScAnyRefDlg::ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton ) { - if( !pRefEdit && pEdit ) - { - RefInputStart( pEdit, pButton ); -// if( pRefEdit ) -// pRefEdit->SilentGrabFocus(); - } - - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); - if( pViewShell ) - { - pViewShell->ActiveGrabFocus(); - if( pRefEdit ) - { - const ScViewData* pViewData = pViewShell->GetViewData(); - ScDocument* pDoc = pViewData->GetDocument(); - ScRangeList aRangeList; - if( ParseWithNames( aRangeList, pRefEdit->GetText(), pDoc ) ) - { - const ScRange* pRange = aRangeList.GetObject( 0 ); - if( pRange ) - { - pViewShell->SetTabNo( pRange->aStart.Tab() ); - pViewShell->MoveCursorAbs( pRange->aStart.Col(), - pRange->aStart.Row(), SC_FOLLOW_JUMP, FALSE, FALSE ); - pViewShell->MoveCursorAbs( pRange->aEnd.Col(), - pRange->aEnd.Row(), SC_FOLLOW_JUMP, TRUE, FALSE ); - SetReference( *pRange, pDoc ); - } - } - } - } + m_aHelper.ToggleCollapsed( pEdit, pButton ); } - long ScAnyRefDlg::PreNotify( NotifyEvent& rNEvt ) { USHORT nSwitch=rNEvt.GetType(); @@ -1023,15 +892,15 @@ void ScAnyRefDlg::StateChanged( StateChangedType nStateChange ) { if(IsVisible()) { - lcl_EnableInput( FALSE ); - EnableSpreadsheets(); - SetDispatcherLock( TRUE ); + m_aHelper.enableInput( FALSE ); + m_aHelper.EnableSpreadsheets(); + m_aHelper.SetDispatcherLock( TRUE ); aTimer.Start(); } else { - lcl_EnableInput( TRUE ); - SetDispatcherLock( FALSE ); //! here and in DoClose ? + m_aHelper.enableInput( TRUE ); + m_aHelper.SetDispatcherLock( FALSE ); //! here and in DoClose ? } } } @@ -1044,23 +913,29 @@ IMPL_LINK( ScAnyRefDlg, UpdateFocusHdl, Timer*, EMPTYARG ) } return 0; } - +// ----------------------------------------------------------------------------- +bool ScAnyRefDlg::ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc ) +{ + return m_aHelper.ParseWithNames( rRanges, rStr, pDoc ); +} +// ----------------------------------------------------------------------------- +void ScAnyRefDlg::HideReference( BOOL bDoneRefMode ) +{ + m_aHelper.HideReference( bDoneRefMode ); +} +// ----------------------------------------------------------------------------- +void ScAnyRefDlg::ShowReference( const XubString& rStr ) +{ + m_aHelper.ShowReference( rStr ); +} +// ----------------------------------------------------------------------------- +void ScAnyRefDlg::ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton ) +{ + m_aHelper.ReleaseFocus( pEdit,pButton ); +} //---------------------------------------------------------------------------- - -IMPL_LINK( ScAnyRefDlg, AccelSelectHdl, Accelerator *, pSelAccel ) +void ScAnyRefDlg::RefInputDone( BOOL bForced ) { - if ( !pSelAccel ) - return 0; - - switch ( pSelAccel->GetCurKeyCode().GetCode() ) - { - case KEY_RETURN: - case KEY_ESCAPE: - if( pRefEdit ) - pRefEdit->GrabFocus(); - RefInputDone( TRUE ); - break; - } - return TRUE; + m_aHelper.RefInputDone( bForced ); } diff --git a/sc/source/ui/miscdlgs/crnrdlg.cxx b/sc/source/ui/miscdlgs/crnrdlg.cxx index dd5103a30813..8684ea3fa558 100644 --- a/sc/source/ui/miscdlgs/crnrdlg.cxx +++ b/sc/source/ui/miscdlgs/crnrdlg.cxx @@ -1,1175 +1,1175 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: crnrdlg.cxx,v $ - * $Revision: 1.11 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - -// System - Includes --------------------------------------------------------- - - - -// INCLUDE ------------------------------------------------------------------- - -#include "reffact.hxx" -#include "document.hxx" -#include "scresid.hxx" -#include "globstr.hrc" -#include "crnrdlg.hrc" -#include "docsh.hxx" - -#define _CRNRDLG_CXX -#include "crnrdlg.hxx" -#undef _CRNRDLG_CXX -#include <vcl/msgbox.hxx> - - -//============================================================================ - -#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute() -#define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute() - -const ULONG nEntryDataCol = 0; -const ULONG nEntryDataRow = 1; -const ULONG nEntryDataDelim = 2; - - -//============================================================================ -// class ScColRowNameRangesDlg - - -/************************************************************************* -#* Member: ScColRowNameRangesDlg Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Konstruktor der Klasse ScColRowNameRangesDlg. -#* Initialisieren der Klassen- Mitglieder, -#* Uebernahme der Range- Angaben und Aufruf -#* der eigentlichen Initialisierungsroutine -#* -#* Input: Sfx- Verknuepfungen -#* Parent- Window -#* SCViewData -#* -#* Output: --- -#* -#************************************************************************/ - -ScColRowNameRangesDlg::ScColRowNameRangesDlg( SfxBindings* pB, - SfxChildWindow* pCW, - Window* pParent, - ScViewData* ptrViewData ) - - : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_COLROWNAMERANGES ), - // - aFlAssign ( this, ScResId( FL_ASSIGN ) ), - aLbRange ( this, ScResId( LB_RANGE ) ), - - aEdAssign ( this, ScResId( ED_AREA ) ), - aRbAssign ( this, ScResId( RB_AREA ), &aEdAssign ), - aBtnColHead ( this, ScResId( BTN_COLHEAD ) ), - aBtnRowHead ( this, ScResId( BTN_ROWHEAD ) ), - aFtAssign2 ( this, ScResId( FT_DATA_LABEL ) ), - aEdAssign2 ( this, ScResId( ED_DATA ) ), - aRbAssign2 ( this, ScResId( RB_DATA ), &aEdAssign2 ), - - aBtnOk ( this, ScResId( BTN_OK ) ), - aBtnCancel ( this, ScResId( BTN_CANCEL ) ), - aBtnHelp ( this, ScResId( BTN_HELP ) ), - aBtnAdd ( this, ScResId( BTN_ADD ) ), - aBtnRemove ( this, ScResId( BTN_REMOVE ) ), - - pViewData ( ptrViewData ), - pDoc ( ptrViewData->GetDocument() ), - - pEdActive ( NULL ), - bDlgLostFocus ( FALSE ) -{ - xColNameRanges = pDoc->GetColNameRanges()->Clone(); - xRowNameRanges = pDoc->GetRowNameRanges()->Clone(); - Init(); - FreeResource(); -} - - -/************************************************************************* -#* Member: ~ScColRowNameRangesDlg Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Destruktor der Klasse -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -__EXPORT ScColRowNameRangesDlg::~ScColRowNameRangesDlg() -{ -} - - -/************************************************************************* -#* Member: Init Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Initialisierungs- Routine: -#* Umlenken der Event- Handler und einstellen der -#* Startparameter. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -void ScColRowNameRangesDlg::Init() -{ - SCCOL nStartCol = 0; - SCROW nStartRow = 0; - SCTAB nStartTab = 0; - SCCOL nEndCol = 0; - SCROW nEndRow = 0; - SCTAB nEndTab = 0; - - aBtnOk.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, OkBtnHdl ) ); - aBtnCancel.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, CancelBtnHdl ) ); - aBtnAdd.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, AddBtnHdl ) ); - aBtnRemove.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, RemoveBtnHdl ) ); - aLbRange.SetSelectHdl ( LINK( this, ScColRowNameRangesDlg, Range1SelectHdl ) ); - aEdAssign.SetModifyHdl ( LINK( this, ScColRowNameRangesDlg, Range1DataModifyHdl ) ); - aBtnColHead.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, ColClickHdl ) ); - aBtnRowHead.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, RowClickHdl ) ); - aEdAssign2.SetModifyHdl ( LINK( this, ScColRowNameRangesDlg, Range2DataModifyHdl ) ); - - Link aLink = LINK( this, ScColRowNameRangesDlg, GetFocusHdl ); - aEdAssign.SetGetFocusHdl( aLink ); - aRbAssign.SetGetFocusHdl( aLink ); - aEdAssign2.SetGetFocusHdl( aLink ); - aRbAssign2.SetGetFocusHdl( aLink ); - - aLink = LINK( this, ScColRowNameRangesDlg, LoseFocusHdl ); - aEdAssign.SetLoseFocusHdl( aLink ); - aRbAssign.SetLoseFocusHdl( aLink ); - aEdAssign2.SetLoseFocusHdl( aLink ); - aRbAssign2.SetLoseFocusHdl( aLink ); - - pEdActive = &aEdAssign; - - UpdateNames(); - - if ( pViewData && pDoc ) - { - pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab, - nEndCol, nEndRow, nEndTab ); - SetColRowData( ScRange( ScAddress( nStartCol, nStartRow, nStartTab ), - ScAddress( nEndCol, nEndRow, nEndTab ) ) ); - } - else - { - aBtnColHead.Check( TRUE ); - aBtnRowHead.Check( FALSE ); - aEdAssign.SetText( EMPTY_STRING ); - aEdAssign2.SetText( EMPTY_STRING ); - } - - aLbRange.SetBorderStyle( WINDOW_BORDER_MONO ); - aBtnColHead.Enable(); - aBtnRowHead.Enable(); - aEdAssign.Enable(); - aEdAssign.GrabFocus(); - aRbAssign.Enable(); - //@BugID 54702 Enablen/Disablen nur noch in Basisklasse - //SFX_APPWINDOW->Enable(); // Ref-Feld hat Focus - - Range1SelectHdl( 0 ); -} - - -/************************************************************************* -#* Member: SetColRowData Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: zugehoerigen Datenbereich eines Beschriftungsbereiches -#* auf default Werte setzen und beide Referenz-Edit-Felder -#* fuellen. -#* -#* Input: Einstellbereich fuer Labels -#* -#* Output: --- -#* -#************************************************************************/ - -void ScColRowNameRangesDlg::SetColRowData( const ScRange& rLabelRange,BOOL bRef) -{ - theCurData = theCurArea = rLabelRange; - BOOL bValid = TRUE; - SCCOL nCol1 = theCurArea.aStart.Col(); - SCCOL nCol2 = theCurArea.aEnd.Col(); - SCROW nRow1 = theCurArea.aStart.Row(); - SCROW nRow2 = theCurArea.aEnd.Row(); - if ( (static_cast<SCCOLROW>(nCol2 - nCol1) >= nRow2 - nRow1) || (nCol1 == 0 && nCol2 == MAXCOL) ) - { // Spaltenkoepfe und Grenzfall gesamte Tabelle - aBtnColHead.Check( TRUE ); - aBtnRowHead.Check( FALSE ); - if ( nRow2 == MAXROW ) - { - if ( nRow1 == 0 ) - bValid = FALSE; // Grenzfall gesamte Tabelle - else - { // Head unten, Data oben - theCurData.aStart.SetRow( 0 ); - theCurData.aEnd.SetRow( nRow1 - 1 ); - } - } - else - { // Head oben, Data unten - theCurData.aStart.SetRow( nRow2 + 1 ); - theCurData.aEnd.SetRow( MAXROW ); - } - } - else - { // Zeilenkoepfe - aBtnRowHead.Check( TRUE ); - aBtnColHead.Check( FALSE ); - if ( nCol2 == MAXCOL ) - { // Head rechts, Data links - theCurData.aStart.SetCol( 0 ); - theCurData.aEnd.SetCol( nCol2 - 1 ); - } - else - { // Head links, Data rechts - theCurData.aStart.SetCol( nCol2 + 1 ); - theCurData.aEnd.SetCol( MAXCOL ); - } - } - if ( bValid ) - { - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); - String aStr; - theCurArea.Format( aStr, SCR_ABS_3D, pDoc, eConv ); - - if(bRef) - aEdAssign.SetRefString( aStr ); - else - aEdAssign.SetText( aStr ); - - aEdAssign.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) ); - theCurData.Format( aStr, SCR_ABS_3D, pDoc, eConv ); - - if(bRef) - aEdAssign2.SetRefString( aStr ); - else - aEdAssign2.SetText( aStr ); - } - else - { - theCurData = theCurArea = ScRange(); - - if(bRef) - { - aEdAssign.SetRefString( EMPTY_STRING ); - aEdAssign2.SetRefString( EMPTY_STRING ); - } - else - { - aEdAssign.SetText( EMPTY_STRING ); - aEdAssign2.SetText( EMPTY_STRING ); - } - - aBtnColHead.Disable(); - aBtnRowHead.Disable(); - aEdAssign2.Disable(); - aRbAssign2.Disable(); - } -} - - -/************************************************************************* -#* Member: AdjustColRowData Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: zugehoerigen Datenbereich eines Beschriftungsbereiches -#* anpassen und Data-Referenz-Edit-Feld fuellen. -#* -#* Input: Bereich fuer Labels -#* -#* Output: --- -#* -#************************************************************************/ - -void ScColRowNameRangesDlg::AdjustColRowData( const ScRange& rDataRange,BOOL bRef) -{ - theCurData = rDataRange; - if ( aBtnColHead.IsChecked() ) - { // Datenbereich gleiche Spalten wie Koepfe - theCurData.aStart.SetCol( theCurArea.aStart.Col() ); - theCurData.aEnd.SetCol( theCurArea.aEnd.Col() ); - if ( theCurData.Intersects( theCurArea ) ) - { - SCROW nRow1 = theCurArea.aStart.Row(); - SCROW nRow2 = theCurArea.aEnd.Row(); - if ( nRow1 > 0 - && (theCurData.aEnd.Row() < nRow2 || nRow2 == MAXROW) ) - { // Data oben - theCurData.aEnd.SetRow( nRow1 - 1 ); - if ( theCurData.aStart.Row() > theCurData.aEnd.Row() ) - theCurData.aStart.SetRow( theCurData.aEnd.Row() ); - } - else - { // Data unten - theCurData.aStart.SetRow( nRow2 + 1 ); - if ( theCurData.aStart.Row() > theCurData.aEnd.Row() ) - theCurData.aEnd.SetRow( theCurData.aStart.Row() ); - } - } - } - else - { // Datenbereich gleiche Zeilen wie Koepfe - theCurData.aStart.SetRow( theCurArea.aStart.Row() ); - theCurData.aEnd.SetRow( theCurArea.aEnd.Row() ); - if ( theCurData.Intersects( theCurArea ) ) - { - SCCOL nCol1 = theCurArea.aStart.Col(); - SCCOL nCol2 = theCurArea.aEnd.Col(); - if ( nCol1 > 0 - && (theCurData.aEnd.Col() < nCol2 || nCol2 == MAXCOL) ) - { // Data links - theCurData.aEnd.SetCol( nCol1 - 1 ); - if ( theCurData.aStart.Col() > theCurData.aEnd.Col() ) - theCurData.aStart.SetCol( theCurData.aEnd.Col() ); - } - else - { // Data rechts - theCurData.aStart.SetCol( nCol2 + 1 ); - if ( theCurData.aStart.Col() > theCurData.aEnd.Col() ) - theCurData.aEnd.SetCol( theCurData.aStart.Col() ); - } - } - } - String aStr; - theCurData.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() ); - - if(bRef) - aEdAssign2.SetRefString( aStr ); - else - aEdAssign2.SetText( aStr ); - - aEdAssign2.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) ); -} - - -/************************************************************************* -#* Member: SetReference Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Uebergabe eines mit der Maus selektierten Tabellen- -#* bereiches, der dann als neue Selektion im Referenz- -#* Fenster angezeigt wird. -#* -#* Input: Bereich fuer Labels -#* Dokumentklasse -#* -#* Output: --- -#* -#************************************************************************/ - -void ScColRowNameRangesDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ ) -{ - if ( pEdActive ) - { - if ( rRef.aStart != rRef.aEnd ) - RefInputStart( pEdActive ); - - String aRefStr; - if ( pEdActive == &aEdAssign ) - SetColRowData( rRef, TRUE ); - else - AdjustColRowData( rRef, TRUE ); - aBtnColHead.Enable(); - aBtnRowHead.Enable(); - aBtnAdd.Enable(); - aBtnRemove.Disable(); - } -} - - -/************************************************************************* -#* Member: Close Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Schliessen des Fensters -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -BOOL __EXPORT ScColRowNameRangesDlg::Close() -{ - return DoClose( ScColRowNameRangesDlgWrapper::GetChildWindowId() ); -} - - -/************************************************************************* -#* Member: SetActive Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Aktivieren des Fensters -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -void ScColRowNameRangesDlg::SetActive() -{ - if ( bDlgLostFocus ) - { - bDlgLostFocus = FALSE; - if( pEdActive ) - pEdActive->GrabFocus(); - } - else - GrabFocus(); - - if( pEdActive == &aEdAssign ) - Range1DataModifyHdl( 0 ); - else if( pEdActive == &aEdAssign2 ) - Range2DataModifyHdl( 0 ); - - RefInputDone(); -} - - -/************************************************************************* -#* Member: UpdateNames Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Aktualisieren der Namen -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -void ScColRowNameRangesDlg::UpdateNames() -{ - aLbRange.SetUpdateMode( FALSE ); - //----------------------------------------------------------- - aLbRange.Clear(); - aRangeMap.clear(); - aEdAssign.SetText( EMPTY_STRING ); - - ULONG nCount, j; - USHORT nPos; //@008 Hilfsvariable q eingefuegt - - SCCOL nCol1; //@008 04.09.97 - SCROW nRow1; //Erweiterung fuer Bereichsnamen - SCTAB nTab1; - SCCOL nCol2; - SCROW nRow2; - SCTAB nTab2; - String rString; - String strShow; - const ScAddress::Details aDetails(pDoc->GetAddressConvention()); - - String aString; - String strDelim = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( " --- " )); - aString = strDelim; - aString += ScGlobal::GetRscString( STR_COLUMN ); - aString += strDelim; - nPos = aLbRange.InsertEntry( aString ); - aLbRange.SetEntryData( nPos, (void*)nEntryDataDelim ); - if ( (nCount = xColNameRanges->Count()) > 0 ) - { - ScRangePair** ppSortArray = xColNameRanges->CreateNameSortedArray( - nCount, pDoc ); - for ( j=0; j < nCount; j++ ) - { - const ScRange aRange(ppSortArray[j]->GetRange(0)); - aRange.Format( aString, SCR_ABS_3D, pDoc, aDetails ); - - //@008 Hole Bereichsparameter aus Dok - ppSortArray[j]->GetRange(0).GetVars( nCol1, nRow1, nTab1, - nCol2, nRow2, nTab2 ); - SCCOL q=nCol1+3; - if(q>nCol2) q=nCol2; - //@008 Baue String zusammen - strShow.AssignAscii(RTL_CONSTASCII_STRINGPARAM(" [")); - if(pDoc!=NULL) - { - pDoc->GetString(nCol1, nRow1, nTab1,rString); - strShow +=rString; - for(SCCOL i=nCol1+1;i<=q;i++) - { - strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ")); - pDoc->GetString(i, nRow1, nTab1,rString); - strShow += rString; - } - } - if(q<nCol2) // Zu lang? Ergaenzen um ",..." - { - strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ...")); - } - strShow += ']'; - - //@008 String einfuegen in Listbox - String aInsStr = aString; - aInsStr += strShow; - nPos = aLbRange.InsertEntry( aInsStr ); - aRangeMap.insert( NameRangeMap::value_type(aInsStr, aRange) ); - aLbRange.SetEntryData( nPos, (void*)nEntryDataCol ); - } - delete [] ppSortArray; - } - aString = strDelim; - aString += ScGlobal::GetRscString( STR_ROW ); - aString += strDelim; - nPos = aLbRange.InsertEntry( aString ); - aLbRange.SetEntryData( nPos, (void*)nEntryDataDelim ); - if ( (nCount = xRowNameRanges->Count()) > 0 ) - { - ScRangePair** ppSortArray = xRowNameRanges->CreateNameSortedArray( - nCount, pDoc ); - for ( j=0; j < nCount; j++ ) - { - const ScRange aRange(ppSortArray[j]->GetRange(0)); - aRange.Format( aString, SCR_ABS_3D, pDoc, aDetails ); - - //@008 Ab hier baue String fuer Zeilen - ppSortArray[j]->GetRange(0).GetVars( nCol1, nRow1, nTab1, - nCol2, nRow2, nTab2 ); - SCROW q=nRow1+3; - if(q>nRow2) q=nRow2; - strShow.AssignAscii(RTL_CONSTASCII_STRINGPARAM(" [")); - if(pDoc!=NULL) - { - pDoc->GetString(nCol1, nRow1, nTab1,rString); - strShow += rString; - for(SCROW i=nRow1+1;i<=q;i++) - { - strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ")); - pDoc->GetString(nCol1, i, nTab1,rString); - strShow += rString; - } - } - if(q<nRow2) - { - strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ...")); - } - strShow += ']'; - - String aInsStr = aString; - aInsStr += strShow; - nPos = aLbRange.InsertEntry( aInsStr ); - aRangeMap.insert( NameRangeMap::value_type(aInsStr, aRange) ); - aLbRange.SetEntryData( nPos, (void*)nEntryDataRow ); - } - delete [] ppSortArray; - } - //----------------------------------------------------------- - aLbRange.SetUpdateMode( TRUE ); - aLbRange.Invalidate(); -} - - -/************************************************************************* -#* Member: UpdateRangeData Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Aktualisieren der Bereichsdaten -#* -#* Input: Bereichs-String -#* Flag fuer Spalten -#* -#* Output: --- -#* -#************************************************************************/ - -void ScColRowNameRangesDlg::UpdateRangeData( const ScRange& rRange, BOOL bColName ) -{ - ScRangePair* pPair = NULL; - BOOL bFound = FALSE; - if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL ) - bFound = TRUE; - else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL ) - bFound = TRUE; - - if ( bFound ) - { - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); - String aStr; - theCurArea = rRange; - theCurArea.Format( aStr, SCR_ABS_3D, pDoc, eConv ); - aEdAssign.SetText( aStr ); - aBtnAdd.Disable(); - aBtnRemove.Enable(); - aBtnColHead.Check( bColName ); - aBtnRowHead.Check( !bColName ); - theCurData = pPair->GetRange(1); - theCurData.Format( aStr, SCR_ABS_3D, pDoc, eConv ); - aEdAssign2.SetText( aStr ); - } - else - { - aBtnAdd.Enable(); - aBtnRemove.Disable(); - } - aBtnColHead.Enable(); - aBtnRowHead.Enable(); - aEdAssign2.Enable(); - aRbAssign2.Enable(); -} - - -/************************************************************************* -#* Member: IsRefInputMode Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Abfragefunktion fuer Referenz- Input- Mode. -#* -#* Input: Bereichs-String -#* Flag fuer Spalten -#* -#* Output: true, wenn Referenz- Input- Mode -#* -#************************************************************************/ - -BOOL ScColRowNameRangesDlg::IsRefInputMode() const -{ - return (pEdActive != NULL); -} - -//------------------------------------------------------------------------ -// Handler: -// ======== - -/************************************************************************* -#* Handler: OkBtnHdl Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Wird ausgeloest, wenn der OK- Button gedrueckt wurde. -#* Hinzufuegen- Button ausloesen, und die neu einge- -#* stellten Bereiche ans Dokument uebergeben. -#* Fensterschliessen- Anweisung ausloesen. -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -IMPL_LINK( ScColRowNameRangesDlg, OkBtnHdl, void *, EMPTYARG ) -{ - AddBtnHdl( 0 ); - - // die RangeLists den Refs am Doc zuweisen - pDoc->GetColNameRangesRef() = xColNameRanges; - pDoc->GetRowNameRangesRef() = xRowNameRanges; - // geaenderte Datenbereiche muessen sich auswirken - pDoc->CompileColRowNameFormula(); - ScDocShell* pDocShell = pViewData->GetDocShell(); - pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID ); - pDocShell->SetDocumentModified(); - - Close(); - return 0; -} - - -/************************************************************************* -#* Handler: CancelBtnHdl Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Fensterschliessen- Anweisung ausloesen. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -IMPL_LINK_INLINE_START( ScColRowNameRangesDlg, CancelBtnHdl, void *, EMPTYARG ) -{ - Close(); - return 0; -} -IMPL_LINK_INLINE_END( ScColRowNameRangesDlg, CancelBtnHdl, void *, EMPTYARG ) - - -/************************************************************************* -#* Handler: AddBtnHdl Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Nach betaetigen des Hinzufuegen- Buttons, werden -#* die Bereichsangaben eingestellt und in der -#* Listbox dargestellt. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -IMPL_LINK( ScColRowNameRangesDlg, AddBtnHdl, void *, EMPTYARG ) -{ - String aNewArea( aEdAssign.GetText() ); - String aNewData( aEdAssign2.GetText() ); - - if ( aNewArea.Len() > 0 && aNewData.Len() > 0 ) - { - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); - ScRange aRange1, aRange2; - BOOL bOk1; - if ( (bOk1 = ((aRange1.ParseAny( aNewArea, pDoc, eConv ) & SCA_VALID) == SCA_VALID)) != FALSE - && ((aRange2.ParseAny( aNewData, pDoc, eConv ) & SCA_VALID) == SCA_VALID) ) - { - theCurArea = aRange1; - AdjustColRowData( aRange2 ); - ScRangePair* pPair; - if ( ( pPair = xColNameRanges->Find( theCurArea ) ) != NULL ) - { - xColNameRanges->Remove( pPair ); - delete pPair; - } - if ( ( pPair = xRowNameRanges->Find( theCurArea ) ) != NULL ) - { - xRowNameRanges->Remove( pPair ); - delete pPair; - } - if ( aBtnColHead.IsChecked() ) - xColNameRanges->Join( ScRangePair( theCurArea, theCurData ) ); - else - xRowNameRanges->Join( ScRangePair( theCurArea, theCurData ) ); - - UpdateNames(); - - aEdAssign.GrabFocus(); - aBtnAdd.Disable(); - aBtnRemove.Disable(); - aEdAssign.SetText( EMPTY_STRING ); - aBtnColHead.Check( TRUE ); - aBtnRowHead.Check( FALSE ); - aEdAssign2.SetText( EMPTY_STRING ); - theCurArea = ScRange(); - theCurData = theCurArea; - Range1SelectHdl( 0 ); - } - else - { - ERRORBOX( ScGlobal::GetRscString(STR_INVALIDTABNAME) ); - if ( !bOk1 ) - aEdAssign.GrabFocus(); - else - aEdAssign2.GrabFocus(); - } - } - return 0; -} - - -/************************************************************************* -#* Handler: RemoveBtnHdl Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Nach betaetigen des Loeschen- Buttons, wird -#* die markierte Bereichsangabe geloescht. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -IMPL_LINK( ScColRowNameRangesDlg, RemoveBtnHdl, void *, EMPTYARG ) -{ - String aRangeStr = aLbRange.GetSelectEntry(); - USHORT nSelectPos = aLbRange.GetSelectEntryPos(); - BOOL bColName = - ((ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataCol); - NameRangeMap::const_iterator itr = aRangeMap.find(aRangeStr); - if (itr == aRangeMap.end()) - return 0; - const ScRange& rRange = itr->second; - - ScRangePair* pPair = NULL; - BOOL bFound = FALSE; - if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL ) - bFound = TRUE; - else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL ) - bFound = TRUE; - if ( bFound ) - { - String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY ); - String aMsg = aStrDelMsg.GetToken( 0, '#' ); - - aMsg += aRangeStr; - aMsg += aStrDelMsg.GetToken( 1, '#' ); - - if ( RET_YES == QUERYBOX(aMsg) ) - { - if ( bColName ) - xColNameRanges->Remove( pPair ); - else - xRowNameRanges->Remove( pPair ); - delete pPair; - - UpdateNames(); - USHORT nCnt = aLbRange.GetEntryCount(); - if ( nSelectPos >= nCnt ) - { - if ( nCnt ) - nSelectPos = nCnt - 1; - else - nSelectPos = 0; - } - aLbRange.SelectEntryPos( nSelectPos ); - if ( nSelectPos && - (ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim ) - aLbRange.SelectEntryPos( --nSelectPos ); // ---Zeile--- - - aLbRange.GrabFocus(); - aBtnAdd.Disable(); - aBtnRemove.Disable(); - aEdAssign.SetText( EMPTY_STRING ); - theCurArea = theCurData = ScRange(); - aBtnColHead.Check( TRUE ); - aBtnRowHead.Check( FALSE ); - aEdAssign2.SetText( EMPTY_STRING ); - Range1SelectHdl( 0 ); - } - } - return 0; -} - - -/************************************************************************* -#* Handler: Range1SelectHdl Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Wenn Zeile in Listbox ausgewaehlt wird, -#* werden die Eingabefelder entsprechend -#* eingestellt. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -IMPL_LINK( ScColRowNameRangesDlg, Range1SelectHdl, void *, EMPTYARG ) -{ - USHORT nSelectPos = aLbRange.GetSelectEntryPos(); - USHORT nCnt = aLbRange.GetEntryCount(); - USHORT nMoves = 0; - while ( nSelectPos < nCnt - && (ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim ) - { // skip Delimiter - ++nMoves; - aLbRange.SelectEntryPos( ++nSelectPos ); - } - String aRangeStr = aLbRange.GetSelectEntry(); - if ( nMoves ) - { - if ( nSelectPos > 1 && nSelectPos >= nCnt ) - { // am Ende nicht auf dem " --- Zeile --- " Delimiter stehenbleiben - // wenn davor Eintraege existieren - nSelectPos = nCnt - 2; - aLbRange.SelectEntryPos( nSelectPos ); - aRangeStr = aLbRange.GetSelectEntry(); - } - else if ( nSelectPos > 2 && nSelectPos < nCnt && aRangeStr.Len() - && aRangeStr == aEdAssign.GetText() ) - { // nach oben wandern statt nach unten auf die vorherige Position - nSelectPos -= 2; - aLbRange.SelectEntryPos( nSelectPos ); - aRangeStr = aLbRange.GetSelectEntry(); - } - } - NameRangeMap::const_iterator itr = aRangeMap.find(aRangeStr); - if ( itr != aRangeMap.end() ) - { - BOOL bColName = - ((ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataCol); - UpdateRangeData( itr->second, bColName ); - aBtnAdd.Disable(); - aBtnRemove.Enable(); - } - else - { - if ( aEdAssign.GetText().Len() > 0 ) - { - if ( aEdAssign2.GetText().Len() > 0 ) - aBtnAdd.Enable(); - else - aBtnAdd.Disable(); - aBtnColHead.Enable(); - aBtnRowHead.Enable(); - aEdAssign2.Enable(); - aRbAssign2.Enable(); - } - else - { - aBtnAdd.Disable(); - aBtnColHead.Disable(); - aBtnRowHead.Disable(); - aEdAssign2.Disable(); - aRbAssign2.Disable(); - } - aBtnRemove.Disable(); - aEdAssign.GrabFocus(); - } - - aEdAssign.Enable(); - aRbAssign.Enable(); - - //@BugID 54702 Enablen/Disablen nur noch in Basisklasse - //SFX_APPWINDOW->Enable(); - return 0; -} - - -/************************************************************************* -#* Handler: Range1DataModifyHdl Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Wird ausgeloest, wenn in der Tabelle, der Label- -#* Bereich geaendert wurde. -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -IMPL_LINK( ScColRowNameRangesDlg, Range1DataModifyHdl, void *, EMPTYARG ) -{ - String aNewArea( aEdAssign.GetText() ); - BOOL bValid = FALSE; - if ( aNewArea.Len() > 0 ) - { - ScRange aRange; - if ( (aRange.ParseAny( aNewArea, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID ) - { - SetColRowData( aRange ); - bValid = TRUE; - } - } - if ( bValid ) - { - aBtnAdd.Enable(); - aBtnColHead.Enable(); - aBtnRowHead.Enable(); - aEdAssign2.Enable(); - aRbAssign2.Enable(); - } - else - { - aBtnAdd.Disable(); - aBtnColHead.Disable(); - aBtnRowHead.Disable(); - aEdAssign2.Disable(); - aRbAssign2.Disable(); - } - aBtnRemove.Disable(); - return 0; -} - - -/************************************************************************* -#* Handler: Range2DataModifyHdl Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Wird ausgeloest, wenn in der Tabelle, der Daten- -#* Bereich geaendert wurde -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -IMPL_LINK( ScColRowNameRangesDlg, Range2DataModifyHdl, void *, EMPTYARG ) -{ - String aNewData( aEdAssign2.GetText() ); - if ( aNewData.Len() > 0 ) - { - ScRange aRange; - if ( (aRange.ParseAny( aNewData, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID ) - { - AdjustColRowData( aRange ); - aBtnAdd.Enable(); - } - else - aBtnAdd.Disable(); - } - else - { - aBtnAdd.Disable(); - } - return 0; -} - - -/************************************************************************* -#* Handler: ColClickHdl Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Radiobutton fuer Spalten wurde betaetigt, -#* die entsprechenden Einstellungen werden -#* vorgenommen -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -IMPL_LINK( ScColRowNameRangesDlg, ColClickHdl, void *, EMPTYARG ) -{ - if ( !aBtnColHead.GetSavedValue() ) - { - aBtnColHead.Check( TRUE ); - aBtnRowHead.Check( FALSE ); - if ( theCurArea.aStart.Row() == 0 && theCurArea.aEnd.Row() == MAXROW ) - { - theCurArea.aEnd.SetRow( MAXROW - 1 ); - String aStr; - theCurArea.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() ); - aEdAssign.SetText( aStr ); - } - ScRange aRange( theCurData ); - aRange.aStart.SetRow( Min( (long)(theCurArea.aEnd.Row() + 1), (long)MAXROW ) ); - aRange.aEnd.SetRow( MAXROW ); - AdjustColRowData( aRange ); - } - return 0; -} - - -/************************************************************************* -#* Handler: RowClickHdl Datum:04.09.97 -#*------------------------------------------------------------------------ -#* -#* Klasse: ScColRowNameRangesDlg -#* -#* Funktion: Radiobutton fuer Zeilen wurde betaetigt, -#* die entsprechenden Einstellungen werden -#* vorgenommen -#* -#* Input: --- -#* -#* Output: --- -#* -#************************************************************************/ - -IMPL_LINK( ScColRowNameRangesDlg, RowClickHdl, void *, EMPTYARG ) -{ - if ( !aBtnRowHead.GetSavedValue() ) - { - aBtnRowHead.Check( TRUE ); - aBtnColHead.Check( FALSE ); - if ( theCurArea.aStart.Col() == 0 && theCurArea.aEnd.Col() == MAXCOL ) - { - theCurArea.aEnd.SetCol( MAXCOL - 1 ); - String aStr; - theCurArea.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() ); - aEdAssign.SetText( aStr ); - } - ScRange aRange( theCurData ); - aRange.aStart.SetCol( static_cast<SCCOL>(Min( (long)(theCurArea.aEnd.Col() + 1), (long)MAXCOL )) ); - aRange.aEnd.SetCol( MAXCOL ); - AdjustColRowData( aRange ); - } - return 0; -} - - -IMPL_LINK( ScColRowNameRangesDlg, GetFocusHdl, Control*, pCtrl ) -{ - if( (pCtrl == (Control*)&aEdAssign) || (pCtrl == (Control*)&aRbAssign) ) - pEdActive = &aEdAssign; - else if( (pCtrl == (Control*)&aEdAssign2) || (pCtrl == (Control*)&aRbAssign2) ) - pEdActive = &aEdAssign2; - else - pEdActive = NULL; - - if( pEdActive ) - pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) ); - - return 0; -} - - -IMPL_LINK( ScColRowNameRangesDlg, LoseFocusHdl, Control*, EMPTYARG ) -{ - bDlgLostFocus = !IsActive(); - return 0; -} +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: crnrdlg.cxx,v $
+ * $Revision: 1.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "crnrdlg.hrc"
+#include "docsh.hxx"
+
+#define _CRNRDLG_CXX
+#include "crnrdlg.hxx"
+#undef _CRNRDLG_CXX
+#include <vcl/msgbox.hxx>
+
+
+//============================================================================
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
+#define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute()
+
+const ULONG nEntryDataCol = 0;
+const ULONG nEntryDataRow = 1;
+const ULONG nEntryDataDelim = 2;
+
+
+//============================================================================
+// class ScColRowNameRangesDlg
+
+
+/*************************************************************************
+#* Member: ScColRowNameRangesDlg Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Konstruktor der Klasse ScColRowNameRangesDlg.
+#* Initialisieren der Klassen- Mitglieder,
+#* Uebernahme der Range- Angaben und Aufruf
+#* der eigentlichen Initialisierungsroutine
+#*
+#* Input: Sfx- Verknuepfungen
+#* Parent- Window
+#* SCViewData
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+ScColRowNameRangesDlg::ScColRowNameRangesDlg( SfxBindings* pB,
+ SfxChildWindow* pCW,
+ Window* pParent,
+ ScViewData* ptrViewData )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_COLROWNAMERANGES ),
+ //
+ aFlAssign ( this, ScResId( FL_ASSIGN ) ),
+ aLbRange ( this, ScResId( LB_RANGE ) ),
+
+ aEdAssign ( this, ScResId( ED_AREA ) ),
+ aRbAssign ( this, ScResId( RB_AREA ), &aEdAssign, this ),
+ aBtnColHead ( this, ScResId( BTN_COLHEAD ) ),
+ aBtnRowHead ( this, ScResId( BTN_ROWHEAD ) ),
+ aFtAssign2 ( this, ScResId( FT_DATA_LABEL ) ),
+ aEdAssign2 ( this, ScResId( ED_DATA ) ),
+ aRbAssign2 ( this, ScResId( RB_DATA ), &aEdAssign2, this ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnAdd ( this, ScResId( BTN_ADD ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+
+ pEdActive ( NULL ),
+ bDlgLostFocus ( FALSE )
+{
+ xColNameRanges = pDoc->GetColNameRanges()->Clone();
+ xRowNameRanges = pDoc->GetRowNameRanges()->Clone();
+ Init();
+ FreeResource();
+}
+
+
+/*************************************************************************
+#* Member: ~ScColRowNameRangesDlg Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Destruktor der Klasse
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+__EXPORT ScColRowNameRangesDlg::~ScColRowNameRangesDlg()
+{
+}
+
+
+/*************************************************************************
+#* Member: Init Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Initialisierungs- Routine:
+#* Umlenken der Event- Handler und einstellen der
+#* Startparameter.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::Init()
+{
+ SCCOL nStartCol = 0;
+ SCROW nStartRow = 0;
+ SCTAB nStartTab = 0;
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+ SCTAB nEndTab = 0;
+
+ aBtnOk.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, OkBtnHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, CancelBtnHdl ) );
+ aBtnAdd.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, AddBtnHdl ) );
+ aBtnRemove.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, RemoveBtnHdl ) );
+ aLbRange.SetSelectHdl ( LINK( this, ScColRowNameRangesDlg, Range1SelectHdl ) );
+ aEdAssign.SetModifyHdl ( LINK( this, ScColRowNameRangesDlg, Range1DataModifyHdl ) );
+ aBtnColHead.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, ColClickHdl ) );
+ aBtnRowHead.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, RowClickHdl ) );
+ aEdAssign2.SetModifyHdl ( LINK( this, ScColRowNameRangesDlg, Range2DataModifyHdl ) );
+
+ Link aLink = LINK( this, ScColRowNameRangesDlg, GetFocusHdl );
+ aEdAssign.SetGetFocusHdl( aLink );
+ aRbAssign.SetGetFocusHdl( aLink );
+ aEdAssign2.SetGetFocusHdl( aLink );
+ aRbAssign2.SetGetFocusHdl( aLink );
+
+ aLink = LINK( this, ScColRowNameRangesDlg, LoseFocusHdl );
+ aEdAssign.SetLoseFocusHdl( aLink );
+ aRbAssign.SetLoseFocusHdl( aLink );
+ aEdAssign2.SetLoseFocusHdl( aLink );
+ aRbAssign2.SetLoseFocusHdl( aLink );
+
+ pEdActive = &aEdAssign;
+
+ UpdateNames();
+
+ if ( pViewData && pDoc )
+ {
+ pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab );
+ SetColRowData( ScRange( ScAddress( nStartCol, nStartRow, nStartTab ),
+ ScAddress( nEndCol, nEndRow, nEndTab ) ) );
+ }
+ else
+ {
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ aEdAssign.SetText( EMPTY_STRING );
+ aEdAssign2.SetText( EMPTY_STRING );
+ }
+
+ aLbRange.SetBorderStyle( WINDOW_BORDER_MONO );
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign.Enable();
+ aEdAssign.GrabFocus();
+ aRbAssign.Enable();
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable(); // Ref-Feld hat Focus
+
+ Range1SelectHdl( 0 );
+}
+
+
+/*************************************************************************
+#* Member: SetColRowData Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: zugehoerigen Datenbereich eines Beschriftungsbereiches
+#* auf default Werte setzen und beide Referenz-Edit-Felder
+#* fuellen.
+#*
+#* Input: Einstellbereich fuer Labels
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::SetColRowData( const ScRange& rLabelRange,BOOL bRef)
+{
+ theCurData = theCurArea = rLabelRange;
+ BOOL bValid = TRUE;
+ SCCOL nCol1 = theCurArea.aStart.Col();
+ SCCOL nCol2 = theCurArea.aEnd.Col();
+ SCROW nRow1 = theCurArea.aStart.Row();
+ SCROW nRow2 = theCurArea.aEnd.Row();
+ if ( (static_cast<SCCOLROW>(nCol2 - nCol1) >= nRow2 - nRow1) || (nCol1 == 0 && nCol2 == MAXCOL) )
+ { // Spaltenkoepfe und Grenzfall gesamte Tabelle
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ if ( nRow2 == MAXROW )
+ {
+ if ( nRow1 == 0 )
+ bValid = FALSE; // Grenzfall gesamte Tabelle
+ else
+ { // Head unten, Data oben
+ theCurData.aStart.SetRow( 0 );
+ theCurData.aEnd.SetRow( nRow1 - 1 );
+ }
+ }
+ else
+ { // Head oben, Data unten
+ theCurData.aStart.SetRow( nRow2 + 1 );
+ theCurData.aEnd.SetRow( MAXROW );
+ }
+ }
+ else
+ { // Zeilenkoepfe
+ aBtnRowHead.Check( TRUE );
+ aBtnColHead.Check( FALSE );
+ if ( nCol2 == MAXCOL )
+ { // Head rechts, Data links
+ theCurData.aStart.SetCol( 0 );
+ theCurData.aEnd.SetCol( nCol2 - 1 );
+ }
+ else
+ { // Head links, Data rechts
+ theCurData.aStart.SetCol( nCol2 + 1 );
+ theCurData.aEnd.SetCol( MAXCOL );
+ }
+ }
+ if ( bValid )
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ String aStr;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+
+ if(bRef)
+ aEdAssign.SetRefString( aStr );
+ else
+ aEdAssign.SetText( aStr );
+
+ aEdAssign.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
+ theCurData.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+
+ if(bRef)
+ aEdAssign2.SetRefString( aStr );
+ else
+ aEdAssign2.SetText( aStr );
+ }
+ else
+ {
+ theCurData = theCurArea = ScRange();
+
+ if(bRef)
+ {
+ aEdAssign.SetRefString( EMPTY_STRING );
+ aEdAssign2.SetRefString( EMPTY_STRING );
+ }
+ else
+ {
+ aEdAssign.SetText( EMPTY_STRING );
+ aEdAssign2.SetText( EMPTY_STRING );
+ }
+
+ aBtnColHead.Disable();
+ aBtnRowHead.Disable();
+ aEdAssign2.Disable();
+ aRbAssign2.Disable();
+ }
+}
+
+
+/*************************************************************************
+#* Member: AdjustColRowData Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: zugehoerigen Datenbereich eines Beschriftungsbereiches
+#* anpassen und Data-Referenz-Edit-Feld fuellen.
+#*
+#* Input: Bereich fuer Labels
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::AdjustColRowData( const ScRange& rDataRange,BOOL bRef)
+{
+ theCurData = rDataRange;
+ if ( aBtnColHead.IsChecked() )
+ { // Datenbereich gleiche Spalten wie Koepfe
+ theCurData.aStart.SetCol( theCurArea.aStart.Col() );
+ theCurData.aEnd.SetCol( theCurArea.aEnd.Col() );
+ if ( theCurData.Intersects( theCurArea ) )
+ {
+ SCROW nRow1 = theCurArea.aStart.Row();
+ SCROW nRow2 = theCurArea.aEnd.Row();
+ if ( nRow1 > 0
+ && (theCurData.aEnd.Row() < nRow2 || nRow2 == MAXROW) )
+ { // Data oben
+ theCurData.aEnd.SetRow( nRow1 - 1 );
+ if ( theCurData.aStart.Row() > theCurData.aEnd.Row() )
+ theCurData.aStart.SetRow( theCurData.aEnd.Row() );
+ }
+ else
+ { // Data unten
+ theCurData.aStart.SetRow( nRow2 + 1 );
+ if ( theCurData.aStart.Row() > theCurData.aEnd.Row() )
+ theCurData.aEnd.SetRow( theCurData.aStart.Row() );
+ }
+ }
+ }
+ else
+ { // Datenbereich gleiche Zeilen wie Koepfe
+ theCurData.aStart.SetRow( theCurArea.aStart.Row() );
+ theCurData.aEnd.SetRow( theCurArea.aEnd.Row() );
+ if ( theCurData.Intersects( theCurArea ) )
+ {
+ SCCOL nCol1 = theCurArea.aStart.Col();
+ SCCOL nCol2 = theCurArea.aEnd.Col();
+ if ( nCol1 > 0
+ && (theCurData.aEnd.Col() < nCol2 || nCol2 == MAXCOL) )
+ { // Data links
+ theCurData.aEnd.SetCol( nCol1 - 1 );
+ if ( theCurData.aStart.Col() > theCurData.aEnd.Col() )
+ theCurData.aStart.SetCol( theCurData.aEnd.Col() );
+ }
+ else
+ { // Data rechts
+ theCurData.aStart.SetCol( nCol2 + 1 );
+ if ( theCurData.aStart.Col() > theCurData.aEnd.Col() )
+ theCurData.aEnd.SetCol( theCurData.aStart.Col() );
+ }
+ }
+ }
+ String aStr;
+ theCurData.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+
+ if(bRef)
+ aEdAssign2.SetRefString( aStr );
+ else
+ aEdAssign2.SetText( aStr );
+
+ aEdAssign2.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
+}
+
+
+/*************************************************************************
+#* Member: SetReference Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Uebergabe eines mit der Maus selektierten Tabellen-
+#* bereiches, der dann als neue Selektion im Referenz-
+#* Fenster angezeigt wird.
+#*
+#* Input: Bereich fuer Labels
+#* Dokumentklasse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ )
+{
+ if ( pEdActive )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( pEdActive );
+
+ String aRefStr;
+ if ( pEdActive == &aEdAssign )
+ SetColRowData( rRef, TRUE );
+ else
+ AdjustColRowData( rRef, TRUE );
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aBtnAdd.Enable();
+ aBtnRemove.Disable();
+ }
+}
+
+
+/*************************************************************************
+#* Member: Close Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Schliessen des Fensters
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+BOOL __EXPORT ScColRowNameRangesDlg::Close()
+{
+ return DoClose( ScColRowNameRangesDlgWrapper::GetChildWindowId() );
+}
+
+
+/*************************************************************************
+#* Member: SetActive Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Aktivieren des Fensters
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+ if( pEdActive )
+ pEdActive->GrabFocus();
+ }
+ else
+ GrabFocus();
+
+ if( pEdActive == &aEdAssign )
+ Range1DataModifyHdl( 0 );
+ else if( pEdActive == &aEdAssign2 )
+ Range2DataModifyHdl( 0 );
+
+ RefInputDone();
+}
+
+
+/*************************************************************************
+#* Member: UpdateNames Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Aktualisieren der Namen
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::UpdateNames()
+{
+ aLbRange.SetUpdateMode( FALSE );
+ //-----------------------------------------------------------
+ aLbRange.Clear();
+ aRangeMap.clear();
+ aEdAssign.SetText( EMPTY_STRING );
+
+ ULONG nCount, j;
+ USHORT nPos; //@008 Hilfsvariable q eingefuegt
+
+ SCCOL nCol1; //@008 04.09.97
+ SCROW nRow1; //Erweiterung fuer Bereichsnamen
+ SCTAB nTab1;
+ SCCOL nCol2;
+ SCROW nRow2;
+ SCTAB nTab2;
+ String rString;
+ String strShow;
+ const ScAddress::Details aDetails(pDoc->GetAddressConvention());
+
+ String aString;
+ String strDelim = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( " --- " ));
+ aString = strDelim;
+ aString += ScGlobal::GetRscString( STR_COLUMN );
+ aString += strDelim;
+ nPos = aLbRange.InsertEntry( aString );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataDelim );
+ if ( (nCount = xColNameRanges->Count()) > 0 )
+ {
+ ScRangePair** ppSortArray = xColNameRanges->CreateNameSortedArray(
+ nCount, pDoc );
+ for ( j=0; j < nCount; j++ )
+ {
+ const ScRange aRange(ppSortArray[j]->GetRange(0));
+ aRange.Format( aString, SCR_ABS_3D, pDoc, aDetails );
+
+ //@008 Hole Bereichsparameter aus Dok
+ ppSortArray[j]->GetRange(0).GetVars( nCol1, nRow1, nTab1,
+ nCol2, nRow2, nTab2 );
+ SCCOL q=nCol1+3;
+ if(q>nCol2) q=nCol2;
+ //@008 Baue String zusammen
+ strShow.AssignAscii(RTL_CONSTASCII_STRINGPARAM(" ["));
+ if(pDoc!=NULL)
+ {
+ pDoc->GetString(nCol1, nRow1, nTab1,rString);
+ strShow +=rString;
+ for(SCCOL i=nCol1+1;i<=q;i++)
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ pDoc->GetString(i, nRow1, nTab1,rString);
+ strShow += rString;
+ }
+ }
+ if(q<nCol2) // Zu lang? Ergaenzen um ",..."
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ..."));
+ }
+ strShow += ']';
+
+ //@008 String einfuegen in Listbox
+ String aInsStr = aString;
+ aInsStr += strShow;
+ nPos = aLbRange.InsertEntry( aInsStr );
+ aRangeMap.insert( NameRangeMap::value_type(aInsStr, aRange) );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataCol );
+ }
+ delete [] ppSortArray;
+ }
+ aString = strDelim;
+ aString += ScGlobal::GetRscString( STR_ROW );
+ aString += strDelim;
+ nPos = aLbRange.InsertEntry( aString );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataDelim );
+ if ( (nCount = xRowNameRanges->Count()) > 0 )
+ {
+ ScRangePair** ppSortArray = xRowNameRanges->CreateNameSortedArray(
+ nCount, pDoc );
+ for ( j=0; j < nCount; j++ )
+ {
+ const ScRange aRange(ppSortArray[j]->GetRange(0));
+ aRange.Format( aString, SCR_ABS_3D, pDoc, aDetails );
+
+ //@008 Ab hier baue String fuer Zeilen
+ ppSortArray[j]->GetRange(0).GetVars( nCol1, nRow1, nTab1,
+ nCol2, nRow2, nTab2 );
+ SCROW q=nRow1+3;
+ if(q>nRow2) q=nRow2;
+ strShow.AssignAscii(RTL_CONSTASCII_STRINGPARAM(" ["));
+ if(pDoc!=NULL)
+ {
+ pDoc->GetString(nCol1, nRow1, nTab1,rString);
+ strShow += rString;
+ for(SCROW i=nRow1+1;i<=q;i++)
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ pDoc->GetString(nCol1, i, nTab1,rString);
+ strShow += rString;
+ }
+ }
+ if(q<nRow2)
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ..."));
+ }
+ strShow += ']';
+
+ String aInsStr = aString;
+ aInsStr += strShow;
+ nPos = aLbRange.InsertEntry( aInsStr );
+ aRangeMap.insert( NameRangeMap::value_type(aInsStr, aRange) );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataRow );
+ }
+ delete [] ppSortArray;
+ }
+ //-----------------------------------------------------------
+ aLbRange.SetUpdateMode( TRUE );
+ aLbRange.Invalidate();
+}
+
+
+/*************************************************************************
+#* Member: UpdateRangeData Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Aktualisieren der Bereichsdaten
+#*
+#* Input: Bereichs-String
+#* Flag fuer Spalten
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::UpdateRangeData( const ScRange& rRange, BOOL bColName )
+{
+ ScRangePair* pPair = NULL;
+ BOOL bFound = FALSE;
+ if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+ else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+
+ if ( bFound )
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ String aStr;
+ theCurArea = rRange;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+ aEdAssign.SetText( aStr );
+ aBtnAdd.Disable();
+ aBtnRemove.Enable();
+ aBtnColHead.Check( bColName );
+ aBtnRowHead.Check( !bColName );
+ theCurData = pPair->GetRange(1);
+ theCurData.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+ aEdAssign2.SetText( aStr );
+ }
+ else
+ {
+ aBtnAdd.Enable();
+ aBtnRemove.Disable();
+ }
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign2.Enable();
+ aRbAssign2.Enable();
+}
+
+
+/*************************************************************************
+#* Member: IsRefInputMode Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Abfragefunktion fuer Referenz- Input- Mode.
+#*
+#* Input: Bereichs-String
+#* Flag fuer Spalten
+#*
+#* Output: true, wenn Referenz- Input- Mode
+#*
+#************************************************************************/
+
+BOOL ScColRowNameRangesDlg::IsRefInputMode() const
+{
+ return (pEdActive != NULL);
+}
+
+//------------------------------------------------------------------------
+// Handler:
+// ========
+
+/*************************************************************************
+#* Handler: OkBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wird ausgeloest, wenn der OK- Button gedrueckt wurde.
+#* Hinzufuegen- Button ausloesen, und die neu einge-
+#* stellten Bereiche ans Dokument uebergeben.
+#* Fensterschliessen- Anweisung ausloesen.
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, OkBtnHdl, void *, EMPTYARG )
+{
+ AddBtnHdl( 0 );
+
+ // die RangeLists den Refs am Doc zuweisen
+ pDoc->GetColNameRangesRef() = xColNameRanges;
+ pDoc->GetRowNameRangesRef() = xRowNameRanges;
+ // geaenderte Datenbereiche muessen sich auswirken
+ pDoc->CompileColRowNameFormula();
+ ScDocShell* pDocShell = pViewData->GetDocShell();
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
+ pDocShell->SetDocumentModified();
+
+ Close();
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: CancelBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Fensterschliessen- Anweisung ausloesen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK_INLINE_START( ScColRowNameRangesDlg, CancelBtnHdl, void *, EMPTYARG )
+{
+ Close();
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScColRowNameRangesDlg, CancelBtnHdl, void *, EMPTYARG )
+
+
+/*************************************************************************
+#* Handler: AddBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Nach betaetigen des Hinzufuegen- Buttons, werden
+#* die Bereichsangaben eingestellt und in der
+#* Listbox dargestellt.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, AddBtnHdl, void *, EMPTYARG )
+{
+ String aNewArea( aEdAssign.GetText() );
+ String aNewData( aEdAssign2.GetText() );
+
+ if ( aNewArea.Len() > 0 && aNewData.Len() > 0 )
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ ScRange aRange1, aRange2;
+ BOOL bOk1;
+ if ( (bOk1 = ((aRange1.ParseAny( aNewArea, pDoc, eConv ) & SCA_VALID) == SCA_VALID)) != FALSE
+ && ((aRange2.ParseAny( aNewData, pDoc, eConv ) & SCA_VALID) == SCA_VALID) )
+ {
+ theCurArea = aRange1;
+ AdjustColRowData( aRange2 );
+ ScRangePair* pPair;
+ if ( ( pPair = xColNameRanges->Find( theCurArea ) ) != NULL )
+ {
+ xColNameRanges->Remove( pPair );
+ delete pPair;
+ }
+ if ( ( pPair = xRowNameRanges->Find( theCurArea ) ) != NULL )
+ {
+ xRowNameRanges->Remove( pPair );
+ delete pPair;
+ }
+ if ( aBtnColHead.IsChecked() )
+ xColNameRanges->Join( ScRangePair( theCurArea, theCurData ) );
+ else
+ xRowNameRanges->Join( ScRangePair( theCurArea, theCurData ) );
+
+ UpdateNames();
+
+ aEdAssign.GrabFocus();
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aEdAssign.SetText( EMPTY_STRING );
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ aEdAssign2.SetText( EMPTY_STRING );
+ theCurArea = ScRange();
+ theCurData = theCurArea;
+ Range1SelectHdl( 0 );
+ }
+ else
+ {
+ ERRORBOX( ScGlobal::GetRscString(STR_INVALIDTABNAME) );
+ if ( !bOk1 )
+ aEdAssign.GrabFocus();
+ else
+ aEdAssign2.GrabFocus();
+ }
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: RemoveBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Nach betaetigen des Loeschen- Buttons, wird
+#* die markierte Bereichsangabe geloescht.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, RemoveBtnHdl, void *, EMPTYARG )
+{
+ String aRangeStr = aLbRange.GetSelectEntry();
+ USHORT nSelectPos = aLbRange.GetSelectEntryPos();
+ BOOL bColName =
+ ((ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataCol);
+ NameRangeMap::const_iterator itr = aRangeMap.find(aRangeStr);
+ if (itr == aRangeMap.end())
+ return 0;
+ const ScRange& rRange = itr->second;
+
+ ScRangePair* pPair = NULL;
+ BOOL bFound = FALSE;
+ if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+ else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+ if ( bFound )
+ {
+ String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
+ String aMsg = aStrDelMsg.GetToken( 0, '#' );
+
+ aMsg += aRangeStr;
+ aMsg += aStrDelMsg.GetToken( 1, '#' );
+
+ if ( RET_YES == QUERYBOX(aMsg) )
+ {
+ if ( bColName )
+ xColNameRanges->Remove( pPair );
+ else
+ xRowNameRanges->Remove( pPair );
+ delete pPair;
+
+ UpdateNames();
+ USHORT nCnt = aLbRange.GetEntryCount();
+ if ( nSelectPos >= nCnt )
+ {
+ if ( nCnt )
+ nSelectPos = nCnt - 1;
+ else
+ nSelectPos = 0;
+ }
+ aLbRange.SelectEntryPos( nSelectPos );
+ if ( nSelectPos &&
+ (ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim )
+ aLbRange.SelectEntryPos( --nSelectPos ); // ---Zeile---
+
+ aLbRange.GrabFocus();
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aEdAssign.SetText( EMPTY_STRING );
+ theCurArea = theCurData = ScRange();
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ aEdAssign2.SetText( EMPTY_STRING );
+ Range1SelectHdl( 0 );
+ }
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: Range1SelectHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wenn Zeile in Listbox ausgewaehlt wird,
+#* werden die Eingabefelder entsprechend
+#* eingestellt.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, Range1SelectHdl, void *, EMPTYARG )
+{
+ USHORT nSelectPos = aLbRange.GetSelectEntryPos();
+ USHORT nCnt = aLbRange.GetEntryCount();
+ USHORT nMoves = 0;
+ while ( nSelectPos < nCnt
+ && (ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim )
+ { // skip Delimiter
+ ++nMoves;
+ aLbRange.SelectEntryPos( ++nSelectPos );
+ }
+ String aRangeStr = aLbRange.GetSelectEntry();
+ if ( nMoves )
+ {
+ if ( nSelectPos > 1 && nSelectPos >= nCnt )
+ { // am Ende nicht auf dem " --- Zeile --- " Delimiter stehenbleiben
+ // wenn davor Eintraege existieren
+ nSelectPos = nCnt - 2;
+ aLbRange.SelectEntryPos( nSelectPos );
+ aRangeStr = aLbRange.GetSelectEntry();
+ }
+ else if ( nSelectPos > 2 && nSelectPos < nCnt && aRangeStr.Len()
+ && aRangeStr == aEdAssign.GetText() )
+ { // nach oben wandern statt nach unten auf die vorherige Position
+ nSelectPos -= 2;
+ aLbRange.SelectEntryPos( nSelectPos );
+ aRangeStr = aLbRange.GetSelectEntry();
+ }
+ }
+ NameRangeMap::const_iterator itr = aRangeMap.find(aRangeStr);
+ if ( itr != aRangeMap.end() )
+ {
+ BOOL bColName =
+ ((ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataCol);
+ UpdateRangeData( itr->second, bColName );
+ aBtnAdd.Disable();
+ aBtnRemove.Enable();
+ }
+ else
+ {
+ if ( aEdAssign.GetText().Len() > 0 )
+ {
+ if ( aEdAssign2.GetText().Len() > 0 )
+ aBtnAdd.Enable();
+ else
+ aBtnAdd.Disable();
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign2.Enable();
+ aRbAssign2.Enable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ aBtnColHead.Disable();
+ aBtnRowHead.Disable();
+ aEdAssign2.Disable();
+ aRbAssign2.Disable();
+ }
+ aBtnRemove.Disable();
+ aEdAssign.GrabFocus();
+ }
+
+ aEdAssign.Enable();
+ aRbAssign.Enable();
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: Range1DataModifyHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wird ausgeloest, wenn in der Tabelle, der Label-
+#* Bereich geaendert wurde.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, Range1DataModifyHdl, void *, EMPTYARG )
+{
+ String aNewArea( aEdAssign.GetText() );
+ BOOL bValid = FALSE;
+ if ( aNewArea.Len() > 0 )
+ {
+ ScRange aRange;
+ if ( (aRange.ParseAny( aNewArea, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID )
+ {
+ SetColRowData( aRange );
+ bValid = TRUE;
+ }
+ }
+ if ( bValid )
+ {
+ aBtnAdd.Enable();
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign2.Enable();
+ aRbAssign2.Enable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ aBtnColHead.Disable();
+ aBtnRowHead.Disable();
+ aEdAssign2.Disable();
+ aRbAssign2.Disable();
+ }
+ aBtnRemove.Disable();
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: Range2DataModifyHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wird ausgeloest, wenn in der Tabelle, der Daten-
+#* Bereich geaendert wurde
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, Range2DataModifyHdl, void *, EMPTYARG )
+{
+ String aNewData( aEdAssign2.GetText() );
+ if ( aNewData.Len() > 0 )
+ {
+ ScRange aRange;
+ if ( (aRange.ParseAny( aNewData, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID )
+ {
+ AdjustColRowData( aRange );
+ aBtnAdd.Enable();
+ }
+ else
+ aBtnAdd.Disable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: ColClickHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Radiobutton fuer Spalten wurde betaetigt,
+#* die entsprechenden Einstellungen werden
+#* vorgenommen
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, ColClickHdl, void *, EMPTYARG )
+{
+ if ( !aBtnColHead.GetSavedValue() )
+ {
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ if ( theCurArea.aStart.Row() == 0 && theCurArea.aEnd.Row() == MAXROW )
+ {
+ theCurArea.aEnd.SetRow( MAXROW - 1 );
+ String aStr;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ aEdAssign.SetText( aStr );
+ }
+ ScRange aRange( theCurData );
+ aRange.aStart.SetRow( Min( (long)(theCurArea.aEnd.Row() + 1), (long)MAXROW ) );
+ aRange.aEnd.SetRow( MAXROW );
+ AdjustColRowData( aRange );
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: RowClickHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Radiobutton fuer Zeilen wurde betaetigt,
+#* die entsprechenden Einstellungen werden
+#* vorgenommen
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, RowClickHdl, void *, EMPTYARG )
+{
+ if ( !aBtnRowHead.GetSavedValue() )
+ {
+ aBtnRowHead.Check( TRUE );
+ aBtnColHead.Check( FALSE );
+ if ( theCurArea.aStart.Col() == 0 && theCurArea.aEnd.Col() == MAXCOL )
+ {
+ theCurArea.aEnd.SetCol( MAXCOL - 1 );
+ String aStr;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ aEdAssign.SetText( aStr );
+ }
+ ScRange aRange( theCurData );
+ aRange.aStart.SetCol( static_cast<SCCOL>(Min( (long)(theCurArea.aEnd.Col() + 1), (long)MAXCOL )) );
+ aRange.aEnd.SetCol( MAXCOL );
+ AdjustColRowData( aRange );
+ }
+ return 0;
+}
+
+
+IMPL_LINK( ScColRowNameRangesDlg, GetFocusHdl, Control*, pCtrl )
+{
+ if( (pCtrl == (Control*)&aEdAssign) || (pCtrl == (Control*)&aRbAssign) )
+ pEdActive = &aEdAssign;
+ else if( (pCtrl == (Control*)&aEdAssign2) || (pCtrl == (Control*)&aRbAssign2) )
+ pEdActive = &aEdAssign2;
+ else
+ pEdActive = NULL;
+
+ if( pEdActive )
+ pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+
+IMPL_LINK( ScColRowNameRangesDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ bDlgLostFocus = !IsActive();
+ return 0;
+}
diff --git a/sc/source/ui/miscdlgs/highred.cxx b/sc/source/ui/miscdlgs/highred.cxx index b6d93ee4c386..01755bb86fbf 100644 --- a/sc/source/ui/miscdlgs/highred.cxx +++ b/sc/source/ui/miscdlgs/highred.cxx @@ -88,7 +88,7 @@ ScHighlightChgDlg::ScHighlightChgDlg( SfxBindings* pB, SfxChildWindow* pCW, Wind aCancelButton ( this, ScResId( BTN_CANCEL ) ), aHelpButton ( this, ScResId( BTN_HELP ) ), aEdAssign ( this, ScResId( ED_ASSIGN ) ), - aRbAssign ( this, ScResId( RB_ASSIGN ), &aEdAssign ), + aRbAssign ( this, ScResId( RB_ASSIGN ), &aEdAssign, this ), // pViewData ( ptrViewData ), pDoc ( ptrViewData->GetDocument() ), diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx index 32a701d71e53..e7e902caecd6 100644 --- a/sc/source/ui/miscdlgs/optsolver.cxx +++ b/sc/source/ui/miscdlgs/optsolver.cxx @@ -1,1069 +1,1069 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: optsolver.cxx,v $ - * $Revision: 1.5 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - -//---------------------------------------------------------------------------- - -#include "rangelst.hxx" -#include "scitems.hxx" -#include <sfx2/bindings.hxx> -#include <sfx2/imagemgr.hxx> -#include <svtools/zforlist.hxx> -#include <vcl/msgbox.hxx> -#include <vcl/svapp.hxx> - -#include "uiitems.hxx" -#include "reffact.hxx" -#include "docsh.hxx" -#include "docfunc.hxx" -#include "cell.hxx" -#include "rangeutl.hxx" -#include "scresid.hxx" -#include "convuno.hxx" -#include "unonames.hxx" -#include "solveroptions.hxx" -#include "solverutil.hxx" -#include "optsolver.hrc" - -#include "optsolver.hxx" - -#include <com/sun/star/sheet/Solver.hpp> -#include <com/sun/star/sheet/XSolverDescription.hpp> - -using namespace com::sun::star; - -//---------------------------------------------------------------------------- - -ScSolverProgressDialog::ScSolverProgressDialog( Window* pParent ) - : ModelessDialog( pParent, ScResId( RID_SCDLG_SOLVER_PROGRESS ) ), - maFtProgress ( this, ScResId( FT_PROGRESS ) ), - maFtTime ( this, ScResId( FT_TIMELIMIT ) ), - maFlButtons ( this, ScResId( FL_BUTTONS ) ), - maBtnOk ( this, ScResId( BTN_OK ) ) -{ - maBtnOk.Enable(FALSE); - FreeResource(); -} - -ScSolverProgressDialog::~ScSolverProgressDialog() -{ -} - -void ScSolverProgressDialog::HideTimeLimit() -{ - maFtTime.Hide(); -} - -void ScSolverProgressDialog::SetTimeLimit( sal_Int32 nSeconds ) -{ - String aOld = maFtTime.GetText(); - String aNew = aOld.GetToken(0,'#'); - aNew += String::CreateFromInt32( nSeconds ); - aNew += aOld.GetToken(1,'#'); - maFtTime.SetText( aNew ); -} - -//---------------------------------------------------------------------------- - -ScSolverNoSolutionDialog::ScSolverNoSolutionDialog( Window* pParent, const String& rErrorText ) - : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_NOSOLUTION ) ), - maFtNoSolution ( this, ScResId( FT_NOSOLUTION ) ), - maFtErrorText ( this, ScResId( FT_ERRORTEXT ) ), - maFlButtons ( this, ScResId( FL_BUTTONS ) ), - maBtnOk ( this, ScResId( BTN_OK ) ) -{ - maFtErrorText.SetText( rErrorText ); - FreeResource(); -} - -ScSolverNoSolutionDialog::~ScSolverNoSolutionDialog() -{ -} - -//---------------------------------------------------------------------------- - -ScSolverSuccessDialog::ScSolverSuccessDialog( Window* pParent, const String& rSolution ) - : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_SUCCESS ) ), - maFtSuccess ( this, ScResId( FT_SUCCESS ) ), - maFtResult ( this, ScResId( FT_RESULT ) ), - maFtQuestion ( this, ScResId( FT_QUESTION ) ), - maFlButtons ( this, ScResId( FL_BUTTONS ) ), - maBtnOk ( this, ScResId( BTN_OK ) ), - maBtnCancel ( this, ScResId( BTN_CANCEL ) ) -{ - String aMessage = maFtResult.GetText(); - aMessage.Append( (sal_Char) ' ' ); - aMessage.Append( rSolution ); - maFtResult.SetText( aMessage ); - FreeResource(); -} - -ScSolverSuccessDialog::~ScSolverSuccessDialog() -{ -} - -//---------------------------------------------------------------------------- - -ScCursorRefEdit::ScCursorRefEdit( ScAnyRefDlg* pParent, const ResId& rResId ) : - ScRefEdit( pParent, rResId ) -{ -} - -void ScCursorRefEdit::SetCursorLinks( const Link& rUp, const Link& rDown ) -{ - maCursorUpLink = rUp; - maCursorDownLink = rDown; -} - -void ScCursorRefEdit::KeyInput( const KeyEvent& rKEvt ) -{ - KeyCode aCode = rKEvt.GetKeyCode(); - bool bUp = (aCode.GetCode() == KEY_UP); - bool bDown = (aCode.GetCode() == KEY_DOWN); - if ( !aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() && ( bUp || bDown ) ) - { - if ( bUp ) - maCursorUpLink.Call( this ); - else - maCursorDownLink.Call( this ); - } - else - ScRefEdit::KeyInput( rKEvt ); -} - -//---------------------------------------------------------------------------- - -ScOptSolverSave::ScOptSolverSave( const String& rObjective, BOOL bMax, BOOL bMin, BOOL bValue, - const String& rTarget, const String& rVariable, - const std::vector<ScOptConditionRow>& rConditions, - const String& rEngine, - const uno::Sequence<beans::PropertyValue>& rProperties ) : - maObjective( rObjective ), - mbMax( bMax ), - mbMin( bMin ), - mbValue( bValue ), - maTarget( rTarget ), - maVariable( rVariable ), - maConditions( rConditions ), - maEngine( rEngine ), - maProperties( rProperties ) -{ -} - -//============================================================================ -// class ScOptSolverDlg -//---------------------------------------------------------------------------- - -ScOptSolverDlg::ScOptSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, - ScDocShell* pDocSh, ScAddress aCursorPos ) - - : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_OPTSOLVER ), - // - maFtObjectiveCell ( this, ScResId( FT_OBJECTIVECELL ) ), - maEdObjectiveCell ( this, ScResId( ED_OBJECTIVECELL ) ), - maRBObjectiveCell ( this, ScResId( IB_OBJECTIVECELL ), &maEdObjectiveCell ), - maFtDirection ( this, ScResId( FT_DIRECTION ) ), - maRbMax ( this, ScResId( RB_MAX ) ), - maRbMin ( this, ScResId( RB_MIN ) ), - maRbValue ( this, ScResId( RB_VALUE ) ), - maEdTargetValue ( this, ScResId( ED_TARGET ) ), - maRBTargetValue ( this, ScResId( IB_TARGET ), &maEdTargetValue ), - maFtVariableCells ( this, ScResId( FT_VARIABLECELLS ) ), - maEdVariableCells ( this, ScResId( ED_VARIABLECELLS ) ), - maRBVariableCells ( this, ScResId( IB_VARIABLECELLS ), &maEdVariableCells ), - maFlConditions ( this, ScResId( FL_CONDITIONS ) ), - maFtCellRef ( this, ScResId( FT_CELLREF ) ), - maEdLeft1 ( this, ScResId( ED_LEFT1 ) ), - maRBLeft1 ( this, ScResId( IB_LEFT1 ), &maEdLeft1 ), - maFtOperator ( this, ScResId( FT_OPERATOR ) ), - maLbOp1 ( this, ScResId( LB_OP1 ) ), - maFtConstraint ( this, ScResId( FT_CONSTRAINT ) ), - maEdRight1 ( this, ScResId( ED_RIGHT1 ) ), - maRBRight1 ( this, ScResId( IB_RIGHT1 ), &maEdRight1 ), - maBtnDel1 ( this, ScResId( IB_DELETE1 ) ), - maEdLeft2 ( this, ScResId( ED_LEFT2 ) ), - maRBLeft2 ( this, ScResId( IB_LEFT2 ), &maEdLeft2 ), - maLbOp2 ( this, ScResId( LB_OP2 ) ), - maEdRight2 ( this, ScResId( ED_RIGHT2 ) ), - maRBRight2 ( this, ScResId( IB_RIGHT2 ), &maEdRight2 ), - maBtnDel2 ( this, ScResId( IB_DELETE2 ) ), - maEdLeft3 ( this, ScResId( ED_LEFT3 ) ), - maRBLeft3 ( this, ScResId( IB_LEFT3 ), &maEdLeft3 ), - maLbOp3 ( this, ScResId( LB_OP3 ) ), - maEdRight3 ( this, ScResId( ED_RIGHT3 ) ), - maRBRight3 ( this, ScResId( IB_RIGHT3 ), &maEdRight3 ), - maBtnDel3 ( this, ScResId( IB_DELETE3 ) ), - maEdLeft4 ( this, ScResId( ED_LEFT4 ) ), - maRBLeft4 ( this, ScResId( IB_LEFT4 ), &maEdLeft4 ), - maLbOp4 ( this, ScResId( LB_OP4 ) ), - maEdRight4 ( this, ScResId( ED_RIGHT4 ) ), - maRBRight4 ( this, ScResId( IB_RIGHT4 ), &maEdRight4 ), - maBtnDel4 ( this, ScResId( IB_DELETE4 ) ), - maScrollBar ( this, ScResId( SB_SCROLL ) ), - maFlButtons ( this, ScResId( FL_BUTTONS ) ), - maBtnOpt ( this, ScResId( BTN_OPTIONS ) ), - maBtnHelp ( this, ScResId( BTN_HELP ) ), - maBtnCancel ( this, ScResId( BTN_CLOSE ) ), - maBtnSolve ( this, ScResId( BTN_SOLVE ) ), - maInputError ( ScResId( STR_INVALIDINPUT ) ), - maConditionError ( ScResId( STR_INVALIDCONDITION ) ), - // - mpDocShell ( pDocSh ), - mpDoc ( pDocSh->GetDocument() ), - mnCurTab ( aCursorPos.Tab() ), - mpEdActive ( NULL ), - mbDlgLostFocus ( false ), - nScrollPos ( 0 ) -{ - mpLeftEdit[0] = &maEdLeft1; - mpLeftButton[0] = &maRBLeft1; - mpRightEdit[0] = &maEdRight1; - mpRightButton[0] = &maRBRight1; - mpOperator[0] = &maLbOp1; - mpDelButton[0] = &maBtnDel1; - - mpLeftEdit[1] = &maEdLeft2; - mpLeftButton[1] = &maRBLeft2; - mpRightEdit[1] = &maEdRight2; - mpRightButton[1] = &maRBRight2; - mpOperator[1] = &maLbOp2; - mpDelButton[1] = &maBtnDel2; - - mpLeftEdit[2] = &maEdLeft3; - mpLeftButton[2] = &maRBLeft3; - mpRightEdit[2] = &maEdRight3; - mpRightButton[2] = &maRBRight3; - mpOperator[2] = &maLbOp3; - mpDelButton[2] = &maBtnDel3; - - mpLeftEdit[3] = &maEdLeft4; - mpLeftButton[3] = &maRBLeft4; - mpRightEdit[3] = &maEdRight4; - mpRightButton[3] = &maRBRight4; - mpOperator[3] = &maLbOp4; - mpDelButton[3] = &maBtnDel4; - - Init( aCursorPos ); - FreeResource(); -} - -//---------------------------------------------------------------------------- - -ScOptSolverDlg::~ScOptSolverDlg() -{ -} - -//---------------------------------------------------------------------------- - -void ScOptSolverDlg::Init(const ScAddress& rCursorPos) -{ - // Get the "Delete Rows" commandimagelist images from sfx instead of - // adding a second copy to sc (see ScTbxInsertCtrl::StateChanged) - - rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" )); - aSlotURL += rtl::OUString::valueOf( sal_Int32( SID_DEL_ROWS ) ); - uno::Reference<frame::XFrame> xFrame = GetBindings().GetActiveFrame(); - Image aDelNm = ::GetImage( xFrame, aSlotURL, FALSE, FALSE ); - Image aDelHC = ::GetImage( xFrame, aSlotURL, FALSE, TRUE ); // high contrast - - for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow ) - { - mpDelButton[nRow]->SetModeImage( aDelNm, BMP_COLOR_NORMAL ); - mpDelButton[nRow]->SetModeImage( aDelHC, BMP_COLOR_HIGHCONTRAST ); - } - - maBtnOpt.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) ); - maBtnCancel.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) ); - maBtnSolve.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) ); - - Link aLink = LINK( this, ScOptSolverDlg, GetFocusHdl ); - maEdObjectiveCell.SetGetFocusHdl( aLink ); - maRBObjectiveCell.SetGetFocusHdl( aLink ); - maEdTargetValue.SetGetFocusHdl( aLink ); - maRBTargetValue.SetGetFocusHdl( aLink ); - maEdVariableCells.SetGetFocusHdl( aLink ); - maRBVariableCells.SetGetFocusHdl( aLink ); - maRbValue.SetGetFocusHdl( aLink ); - for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow ) - { - mpLeftEdit[nRow]->SetGetFocusHdl( aLink ); - mpLeftButton[nRow]->SetGetFocusHdl( aLink ); - mpRightEdit[nRow]->SetGetFocusHdl( aLink ); - mpRightButton[nRow]->SetGetFocusHdl( aLink ); - mpOperator[nRow]->SetGetFocusHdl( aLink ); - } - - aLink = LINK( this, ScOptSolverDlg, LoseFocusHdl ); - maEdObjectiveCell.SetLoseFocusHdl( aLink ); - maRBObjectiveCell.SetLoseFocusHdl( aLink ); - maEdTargetValue. SetLoseFocusHdl( aLink ); - maRBTargetValue. SetLoseFocusHdl( aLink ); - maEdVariableCells.SetLoseFocusHdl( aLink ); - maRBVariableCells.SetLoseFocusHdl( aLink ); - for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow ) - { - mpLeftEdit[nRow]->SetLoseFocusHdl( aLink ); - mpLeftButton[nRow]->SetLoseFocusHdl( aLink ); - mpRightEdit[nRow]->SetLoseFocusHdl( aLink ); - mpRightButton[nRow]->SetLoseFocusHdl( aLink ); - } - - Link aCursorUp = LINK( this, ScOptSolverDlg, CursorUpHdl ); - Link aCursorDown = LINK( this, ScOptSolverDlg, CursorDownHdl ); - Link aCondModify = LINK( this, ScOptSolverDlg, CondModifyHdl ); - for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow ) - { - mpLeftEdit[nRow]->SetCursorLinks( aCursorUp, aCursorDown ); - mpRightEdit[nRow]->SetCursorLinks( aCursorUp, aCursorDown ); - mpLeftEdit[nRow]->SetModifyHdl( aCondModify ); - mpRightEdit[nRow]->SetModifyHdl( aCondModify ); - mpDelButton[nRow]->SetClickHdl( LINK( this, ScOptSolverDlg, DelBtnHdl ) ); - mpOperator[nRow]->SetSelectHdl( LINK( this, ScOptSolverDlg, SelectHdl ) ); - } - maEdTargetValue.SetModifyHdl( LINK( this, ScOptSolverDlg, TargetModifyHdl ) ); - - maScrollBar.SetEndScrollHdl( LINK( this, ScOptSolverDlg, ScrollHdl ) ); - maScrollBar.SetScrollHdl( LINK( this, ScOptSolverDlg, ScrollHdl ) ); - - maScrollBar.SetPageSize( EDIT_ROW_COUNT ); - maScrollBar.SetVisibleSize( EDIT_ROW_COUNT ); - maScrollBar.SetLineSize( 1 ); - // Range is set in ShowConditions - - // get available solver implementations - //! sort by descriptions? - ScSolverUtil::GetImplementations( maImplNames, maDescriptions ); - sal_Int32 nImplCount = maImplNames.getLength(); - - const ScOptSolverSave* pOldData = mpDocShell->GetSolverSaveData(); - if ( pOldData ) - { - maEdObjectiveCell.SetRefString( pOldData->GetObjective() ); - maRbMax.Check( pOldData->GetMax() ); - maRbMin.Check( pOldData->GetMin() ); - maRbValue.Check( pOldData->GetValue() ); - maEdTargetValue.SetRefString( pOldData->GetTarget() ); - maEdVariableCells.SetRefString( pOldData->GetVariable() ); - maConditions = pOldData->GetConditions(); - maEngine = pOldData->GetEngine(); - maProperties = pOldData->GetProperties(); - } - else - { - maRbMax.Check(); - String aCursorStr; - if ( !mpDoc->GetRangeAtBlock( ScRange(rCursorPos), &aCursorStr ) ) - rCursorPos.Format( aCursorStr, SCA_ABS, NULL, mpDoc->GetAddressConvention() ); - maEdObjectiveCell.SetRefString( aCursorStr ); - if ( nImplCount > 0 ) - maEngine = maImplNames[0]; // use first implementation - } - ShowConditions(); - - maEdObjectiveCell.GrabFocus(); - mpEdActive = &maEdObjectiveCell; -} - -//---------------------------------------------------------------------------- - -void ScOptSolverDlg::ReadConditions() -{ - for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow ) - { - ScOptConditionRow aRowEntry; - aRowEntry.aLeftStr = mpLeftEdit[nRow]->GetText(); - aRowEntry.aRightStr = mpRightEdit[nRow]->GetText(); - aRowEntry.nOperator = mpOperator[nRow]->GetSelectEntryPos(); - - long nVecPos = nScrollPos + nRow; - if ( nVecPos >= (long)maConditions.size() && !aRowEntry.IsDefault() ) - maConditions.resize( nVecPos + 1 ); - - if ( nVecPos < (long)maConditions.size() ) - maConditions[nVecPos] = aRowEntry; - - // remove default entries at the end - size_t nSize = maConditions.size(); - while ( nSize > 0 && maConditions[ nSize-1 ].IsDefault() ) - --nSize; - maConditions.resize( nSize ); - } -} - -void ScOptSolverDlg::ShowConditions() -{ - for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow ) - { - ScOptConditionRow aRowEntry; - - long nVecPos = nScrollPos + nRow; - if ( nVecPos < (long)maConditions.size() ) - aRowEntry = maConditions[nVecPos]; - - mpLeftEdit[nRow]->SetRefString( aRowEntry.aLeftStr ); - mpRightEdit[nRow]->SetRefString( aRowEntry.aRightStr ); - mpOperator[nRow]->SelectEntryPos( aRowEntry.nOperator ); - } - - // allow to scroll one page behind the visible or stored rows - long nVisible = nScrollPos + EDIT_ROW_COUNT; - long nMax = std::max( nVisible, (long) maConditions.size() ); - maScrollBar.SetRange( Range( 0, nMax + EDIT_ROW_COUNT ) ); - maScrollBar.SetThumbPos( nScrollPos ); - - EnableButtons(); -} - -void ScOptSolverDlg::EnableButtons() -{ - for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow ) - { - long nVecPos = nScrollPos + nRow; - mpDelButton[nRow]->Enable( nVecPos < (long)maConditions.size() ); - } -} - -//---------------------------------------------------------------------------- - -BOOL ScOptSolverDlg::Close() -{ - return DoClose( ScOptSolverDlgWrapper::GetChildWindowId() ); -} - -//---------------------------------------------------------------------------- - -void ScOptSolverDlg::SetActive() -{ - if ( mbDlgLostFocus ) - { - mbDlgLostFocus = false; - if( mpEdActive ) - mpEdActive->GrabFocus(); - } - else - { - GrabFocus(); - } - RefInputDone(); -} - -//---------------------------------------------------------------------------- - -void ScOptSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP ) -{ - if( mpEdActive ) - { - if ( rRef.aStart != rRef.aEnd ) - RefInputStart(mpEdActive); - - // "target"/"value": single cell - bool bSingle = ( mpEdActive == &maEdObjectiveCell || mpEdActive == &maEdTargetValue ); - - String aStr; - ScAddress aAdr = rRef.aStart; - ScRange aNewRef( rRef ); - if ( bSingle ) - aNewRef.aEnd = aAdr; - - String aName; - if ( pDocP->GetRangeAtBlock( aNewRef, &aName ) ) // named range: show name - aStr = aName; - else // format cell/range reference - { - USHORT nFmt = ( aAdr.Tab() == mnCurTab ) ? SCA_ABS : SCA_ABS_3D; - if ( bSingle ) - aAdr.Format( aStr, nFmt, pDocP, pDocP->GetAddressConvention() ); - else - rRef.Format( aStr, nFmt | SCR_ABS, pDocP, pDocP->GetAddressConvention() ); - } - - // variable cells can be several ranges, so only the selection is replaced - if ( mpEdActive == &maEdVariableCells ) - { - String aVal = mpEdActive->GetText(); - Selection aSel = mpEdActive->GetSelection(); - aSel.Justify(); - aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() ); - aVal.Insert( aStr, (xub_StrLen)aSel.Min() ); - Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() ); - mpEdActive->SetRefString( aVal ); - mpEdActive->SetSelection( aNewSel ); - } - else - mpEdActive->SetRefString( aStr ); - - ReadConditions(); - EnableButtons(); - - // select "Value of" if a ref is input into "target" edit - if ( mpEdActive == &maEdTargetValue ) - maRbValue.Check(); - } -} - -//---------------------------------------------------------------------------- - -BOOL ScOptSolverDlg::IsRefInputMode() const -{ - return mpEdActive != NULL; -} - -//---------------------------------------------------------------------------- -// Handler: - -IMPL_LINK( ScOptSolverDlg, BtnHdl, PushButton*, pBtn ) -{ - if ( pBtn == &maBtnSolve || pBtn == &maBtnCancel ) - { - bool bSolve = ( pBtn == &maBtnSolve ); - - SetDispatcherLock( FALSE ); - SwitchToDocument(); - - bool bClose = true; - if ( bSolve ) - bClose = CallSolver(); - - if ( bClose ) - { - // Close: write dialog settings to DocShell for subsequent calls - ReadConditions(); - ScOptSolverSave aSave( - maEdObjectiveCell.GetText(), maRbMax.IsChecked(), maRbMin.IsChecked(), maRbValue.IsChecked(), - maEdTargetValue.GetText(), maEdVariableCells.GetText(), maConditions, maEngine, maProperties ); - mpDocShell->SetSolverSaveData( aSave ); - Close(); - } - else - { - // no solution -> dialog is kept open - SetDispatcherLock( TRUE ); - } - } - else if ( pBtn == &maBtnOpt ) - { - //! move options dialog to UI lib? - ScSolverOptionsDialog* pOptDlg = - new ScSolverOptionsDialog( this, maImplNames, maDescriptions, maEngine, maProperties ); - if ( pOptDlg->Execute() == RET_OK ) - { - maEngine = pOptDlg->GetEngine(); - maProperties = pOptDlg->GetProperties(); - } - delete pOptDlg; - } - - return 0; -} - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScOptSolverDlg, GetFocusHdl, Control*, pCtrl ) -{ - Edit* pEdit = NULL; - mpEdActive = NULL; - - if( pCtrl == &maEdObjectiveCell || pCtrl == &maRBObjectiveCell ) - pEdit = mpEdActive = &maEdObjectiveCell; - else if( pCtrl == &maEdTargetValue || pCtrl == &maRBTargetValue ) - pEdit = mpEdActive = &maEdTargetValue; - else if( pCtrl == &maEdVariableCells || pCtrl == &maRBVariableCells ) - pEdit = mpEdActive = &maEdVariableCells; - for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow ) - { - if( pCtrl == mpLeftEdit[nRow] || pCtrl == mpLeftButton[nRow] ) - pEdit = mpEdActive = mpLeftEdit[nRow]; - else if( pCtrl == mpRightEdit[nRow] || pCtrl == mpRightButton[nRow] ) - pEdit = mpEdActive = mpRightEdit[nRow]; - else if( pCtrl == mpOperator[nRow] ) // focus on "operator" list box - mpEdActive = mpRightEdit[nRow]; // use right edit for ref input, but don't change selection - } - if( pCtrl == &maRbValue ) // focus on "Value of" radio button - mpEdActive = &maEdTargetValue; // use value edit for ref input, but don't change selection - - if( pEdit ) - pEdit->SetSelection( Selection( 0, SELECTION_MAX ) ); - - return 0; -} - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScOptSolverDlg, LoseFocusHdl, Control*, EMPTYARG ) -{ - mbDlgLostFocus = !IsActive(); - return 0; -} - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScOptSolverDlg, DelBtnHdl, PushButton*, pBtn ) -{ - for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow ) - if( pBtn == mpDelButton[nRow] ) - { - BOOL bHadFocus = pBtn->HasFocus(); - - ReadConditions(); - long nVecPos = nScrollPos + nRow; - if ( nVecPos < (long)maConditions.size() ) - { - maConditions.erase( maConditions.begin() + nVecPos ); - ShowConditions(); - - if ( bHadFocus && !pBtn->IsEnabled() ) - { - // If the button is disabled, focus would normally move to the next control, - // (left edit of the next row). Move it to left edit of this row instead. - - mpEdActive = mpLeftEdit[nRow]; - mpEdActive->GrabFocus(); - } - } - } - - return 0; -} - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScOptSolverDlg, TargetModifyHdl, Edit*, EMPTYARG ) -{ - // modify handler for the target edit: - // select "Value of" if something is input into the edit - if ( maEdTargetValue.GetText().Len() ) - maRbValue.Check(); - return 0; -} - -IMPL_LINK( ScOptSolverDlg, CondModifyHdl, Edit*, EMPTYARG ) -{ - // modify handler for the condition edits, just to enable/disable "delete" buttons - ReadConditions(); - EnableButtons(); - return 0; -} - -IMPL_LINK( ScOptSolverDlg, SelectHdl, ListBox*, EMPTYARG ) -{ - // select handler for operator list boxes, just to enable/disable "delete" buttons - ReadConditions(); - EnableButtons(); - return 0; -} - -IMPL_LINK( ScOptSolverDlg, ScrollHdl, ScrollBar*, EMPTYARG ) -{ - ReadConditions(); - nScrollPos = maScrollBar.GetThumbPos(); - ShowConditions(); - if( mpEdActive ) - mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) ); - return 0; -} - -IMPL_LINK( ScOptSolverDlg, CursorUpHdl, ScCursorRefEdit*, pEdit ) -{ - if ( pEdit == mpLeftEdit[0] || pEdit == mpRightEdit[0] ) - { - if ( nScrollPos > 0 ) - { - ReadConditions(); - --nScrollPos; - ShowConditions(); - if( mpEdActive ) - mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) ); - } - } - else - { - ScRefEdit* pFocus = NULL; - for ( sal_uInt16 nRow = 1; nRow < EDIT_ROW_COUNT; ++nRow ) // second row or below: move focus - { - if ( pEdit == mpLeftEdit[nRow] ) - pFocus = mpLeftEdit[nRow-1]; - else if ( pEdit == mpRightEdit[nRow] ) - pFocus = mpRightEdit[nRow-1]; - } - if (pFocus) - { - mpEdActive = pFocus; - pFocus->GrabFocus(); - } - } - - return 0; -} - -IMPL_LINK( ScOptSolverDlg, CursorDownHdl, ScCursorRefEdit*, pEdit ) -{ - if ( pEdit == mpLeftEdit[EDIT_ROW_COUNT-1] || pEdit == mpRightEdit[EDIT_ROW_COUNT-1] ) - { - //! limit scroll position? - ReadConditions(); - ++nScrollPos; - ShowConditions(); - if( mpEdActive ) - mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) ); - } - else - { - ScRefEdit* pFocus = NULL; - for ( sal_uInt16 nRow = 0; nRow+1 < EDIT_ROW_COUNT; ++nRow ) // before last row: move focus - { - if ( pEdit == mpLeftEdit[nRow] ) - pFocus = mpLeftEdit[nRow+1]; - else if ( pEdit == mpRightEdit[nRow] ) - pFocus = mpRightEdit[nRow+1]; - } - if (pFocus) - { - mpEdActive = pFocus; - pFocus->GrabFocus(); - } - } - - return 0; -} - -//---------------------------------------------------------------------------- - -void ScOptSolverDlg::ShowError( bool bCondition, ScRefEdit* pFocus ) -{ - String aMessage = bCondition ? maConditionError : maInputError; - ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ), aMessage ).Execute(); - if (pFocus) - { - mpEdActive = pFocus; - pFocus->GrabFocus(); - } -} - -//---------------------------------------------------------------------------- - -bool ScOptSolverDlg::ParseRef( ScRange& rRange, const String& rInput, bool bAllowRange ) -{ - ScRangeUtil aRangeUtil; - ScAddress::Details aDetails(mpDoc->GetAddressConvention(), 0, 0); - USHORT nFlags = rRange.ParseAny( rInput, mpDoc, aDetails ); - if ( nFlags & SCA_VALID ) - { - if ( (nFlags & SCA_TAB_3D) == 0 ) - rRange.aStart.SetTab( mnCurTab ); - if ( (nFlags & SCA_TAB2_3D) == 0 ) - rRange.aEnd.SetTab( rRange.aStart.Tab() ); - return ( bAllowRange || rRange.aStart == rRange.aEnd ); - } - else if ( aRangeUtil.MakeRangeFromName( rInput, mpDoc, mnCurTab, rRange, RUTL_NAMES, aDetails ) ) - return ( bAllowRange || rRange.aStart == rRange.aEnd ); - - return false; // not recognized -} - -bool ScOptSolverDlg::FindTimeout( sal_Int32& rTimeout ) -{ - bool bFound = false; - - if ( !maProperties.getLength() ) - maProperties = ScSolverUtil::GetDefaults( maEngine ); // get property defaults from component - - sal_Int32 nPropCount = maProperties.getLength(); - for (sal_Int32 nProp=0; nProp<nPropCount && !bFound; ++nProp) - { - const beans::PropertyValue& rValue = maProperties[nProp]; - if ( rValue.Name.equalsAscii( SC_UNONAME_TIMEOUT ) ) - bFound = ( rValue.Value >>= rTimeout ); - } - return bFound; -} - -bool ScOptSolverDlg::CallSolver() // return true -> close dialog after calling -{ - // show progress dialog - - ScSolverProgressDialog aProgress( this ); - sal_Int32 nTimeout = 0; - if ( FindTimeout( nTimeout ) ) - aProgress.SetTimeLimit( nTimeout ); - else - aProgress.HideTimeLimit(); - aProgress.Show(); - aProgress.Update(); - aProgress.Sync(); - // try to make sure the progress dialog is painted before continuing - Application::Reschedule(true); - - // collect solver parameters - - ReadConditions(); - - uno::Reference<sheet::XSpreadsheetDocument> xDocument( mpDocShell->GetModel(), uno::UNO_QUERY ); - - ScRange aObjRange; - if ( !ParseRef( aObjRange, maEdObjectiveCell.GetText(), false ) ) - { - ShowError( false, &maEdObjectiveCell ); - return false; - } - table::CellAddress aObjective( aObjRange.aStart.Tab(), aObjRange.aStart.Col(), aObjRange.aStart.Row() ); - - // "changing cells" can be several ranges - ScRangeList aVarRanges; - if ( !ParseWithNames( aVarRanges, maEdVariableCells.GetText(), mpDoc ) ) - { - ShowError( false, &maEdVariableCells ); - return false; - } - uno::Sequence<table::CellAddress> aVariables; - sal_Int32 nVarPos = 0; - ULONG nRangeCount = aVarRanges.Count(); - for (ULONG nRangePos=0; nRangePos<nRangeCount; ++nRangePos) - { - ScRange aRange(*aVarRanges.GetObject(nRangePos)); - aRange.Justify(); - SCTAB nTab = aRange.aStart.Tab(); - - // resolve into single cells - - sal_Int32 nAdd = ( aRange.aEnd.Col() - aRange.aStart.Col() + 1 ) * - ( aRange.aEnd.Row() - aRange.aStart.Row() + 1 ); - aVariables.realloc( nVarPos + nAdd ); - - for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow) - for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol) - aVariables[nVarPos++] = table::CellAddress( nTab, nCol, nRow ); - } - - uno::Sequence<sheet::SolverConstraint> aConstraints; - sal_Int32 nConstrPos = 0; - for ( std::vector<ScOptConditionRow>::const_iterator aConstrIter = maConditions.begin(); - aConstrIter != maConditions.end(); ++aConstrIter ) - { - if ( aConstrIter->aLeftStr.Len() ) - { - sheet::SolverConstraint aConstraint; - // order of list box entries must match enum values - aConstraint.Operator = static_cast<sheet::SolverConstraintOperator>(aConstrIter->nOperator); - - ScRange aLeftRange; - if ( !ParseRef( aLeftRange, aConstrIter->aLeftStr, true ) ) - { - ShowError( true, NULL ); - return false; - } - - bool bIsRange = false; - ScRange aRightRange; - if ( ParseRef( aRightRange, aConstrIter->aRightStr, true ) ) - { - if ( aRightRange.aStart == aRightRange.aEnd ) - aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(), - aRightRange.aStart.Col(), aRightRange.aStart.Row() ); - else if ( aRightRange.aEnd.Col()-aRightRange.aStart.Col() == aLeftRange.aEnd.Col()-aLeftRange.aStart.Col() && - aRightRange.aEnd.Row()-aRightRange.aStart.Row() == aLeftRange.aEnd.Row()-aLeftRange.aStart.Row() ) - bIsRange = true; // same size as "left" range, resolve into single cells - else - { - ShowError( true, NULL ); - return false; - } - } - else - { - sal_uInt32 nFormat = 0; //! explicit language? - double fValue = 0.0; - if ( mpDoc->GetFormatTable()->IsNumberFormat( aConstrIter->aRightStr, nFormat, fValue ) ) - aConstraint.Right <<= fValue; - else if ( aConstraint.Operator != sheet::SolverConstraintOperator_INTEGER && - aConstraint.Operator != sheet::SolverConstraintOperator_BINARY ) - { - ShowError( true, NULL ); - return false; - } - } - - // resolve into single cells - - sal_Int32 nAdd = ( aLeftRange.aEnd.Col() - aLeftRange.aStart.Col() + 1 ) * - ( aLeftRange.aEnd.Row() - aLeftRange.aStart.Row() + 1 ); - aConstraints.realloc( nConstrPos + nAdd ); - - for (SCROW nRow = aLeftRange.aStart.Row(); nRow <= aLeftRange.aEnd.Row(); ++nRow) - for (SCCOL nCol = aLeftRange.aStart.Col(); nCol <= aLeftRange.aEnd.Col(); ++nCol) - { - aConstraint.Left = table::CellAddress( aLeftRange.aStart.Tab(), nCol, nRow ); - if ( bIsRange ) - aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(), - aRightRange.aStart.Col() + ( nCol - aLeftRange.aStart.Col() ), - aRightRange.aStart.Row() + ( nRow - aLeftRange.aStart.Row() ) ); - - aConstraints[nConstrPos++] = aConstraint; - } - } - } - - sal_Bool bMaximize = maRbMax.IsChecked(); - if ( maRbValue.IsChecked() ) - { - // handle "value of" with an additional constraint (and then minimize) - - sheet::SolverConstraint aConstraint; - aConstraint.Left = aObjective; - aConstraint.Operator = sheet::SolverConstraintOperator_EQUAL; - - String aValStr = maEdTargetValue.GetText(); - ScRange aRightRange; - if ( ParseRef( aRightRange, aValStr, false ) ) - aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(), - aRightRange.aStart.Col(), aRightRange.aStart.Row() ); - else - { - sal_uInt32 nFormat = 0; //! explicit language? - double fValue = 0.0; - if ( mpDoc->GetFormatTable()->IsNumberFormat( aValStr, nFormat, fValue ) ) - aConstraint.Right <<= fValue; - else - { - ShowError( false, &maEdTargetValue ); - return false; - } - } - - aConstraints.realloc( nConstrPos + 1 ); - aConstraints[nConstrPos++] = aConstraint; - } - - // copy old document values - - sal_Int32 nVarCount = aVariables.getLength(); - uno::Sequence<double> aOldValues; - aOldValues.realloc( nVarCount ); - for (nVarPos=0; nVarPos<nVarCount; ++nVarPos) - { - ScAddress aCellPos; - ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] ); - aOldValues[nVarPos] = mpDoc->GetValue( aCellPos ); - } - - // create and initialize solver - - uno::Reference<sheet::XSolver> xSolver = ScSolverUtil::GetSolver( maEngine ); - DBG_ASSERT( xSolver.is(), "can't get solver component" ); - if ( !xSolver.is() ) - return false; - - xSolver->setDocument( xDocument ); - xSolver->setObjective( aObjective ); - xSolver->setVariables( aVariables ); - xSolver->setConstraints( aConstraints ); - xSolver->setMaximize( bMaximize ); - - // set options - uno::Reference<beans::XPropertySet> xOptProp(xSolver, uno::UNO_QUERY); - if ( xOptProp.is() ) - { - sal_Int32 nPropCount = maProperties.getLength(); - for (sal_Int32 nProp=0; nProp<nPropCount; ++nProp) - { - const beans::PropertyValue& rValue = maProperties[nProp]; - try - { - xOptProp->setPropertyValue( rValue.Name, rValue.Value ); - } - catch ( uno::Exception & ) - { - DBG_ERRORFILE("Exception in solver option property"); - } - } - } - - xSolver->solve(); - sal_Bool bSuccess = xSolver->getSuccess(); - - aProgress.Hide(); - bool bClose = false; - bool bRestore = true; // restore old values unless a solution is accepted - if ( bSuccess ) - { - // put solution into document so it is visible when asking - uno::Sequence<double> aSolution = xSolver->getSolution(); - if ( aSolution.getLength() == nVarCount ) - { - mpDocShell->LockPaint(); - ScDocFunc aFunc(*mpDocShell); - for (nVarPos=0; nVarPos<nVarCount; ++nVarPos) - { - ScAddress aCellPos; - ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] ); - aFunc.PutCell( aCellPos, new ScValueCell( aSolution[nVarPos] ), TRUE ); - } - mpDocShell->UnlockPaint(); - } - //! else error? - - // take formatted result from document (result value from component is ignored) - String aResultStr; - mpDoc->GetString( (SCCOL)aObjective.Column, (SCROW)aObjective.Row, (SCTAB)aObjective.Sheet, aResultStr ); - ScSolverSuccessDialog aDialog( this, aResultStr ); - if ( aDialog.Execute() == RET_OK ) - { - // keep results and close dialog - bRestore = false; - bClose = true; - } - } - else - { - rtl::OUString aError; - uno::Reference<sheet::XSolverDescription> xDesc( xSolver, uno::UNO_QUERY ); - if ( xDesc.is() ) - aError = xDesc->getStatusDescription(); // error description from component - ScSolverNoSolutionDialog aDialog( this, aError ); - aDialog.Execute(); - } - - if ( bRestore ) // restore old values - { - mpDocShell->LockPaint(); - ScDocFunc aFunc(*mpDocShell); - for (nVarPos=0; nVarPos<nVarCount; ++nVarPos) - { - ScAddress aCellPos; - ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] ); - aFunc.PutCell( aCellPos, new ScValueCell( aOldValues[nVarPos] ), TRUE ); - } - mpDocShell->UnlockPaint(); - } - - return bClose; -} - +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: optsolver.cxx,v $
+ * $Revision: 1.5 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//----------------------------------------------------------------------------
+
+#include "rangelst.hxx"
+#include "scitems.hxx"
+#include <sfx2/bindings.hxx>
+#include <sfx2/imagemgr.hxx>
+#include <svtools/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+
+#include "uiitems.hxx"
+#include "reffact.hxx"
+#include "docsh.hxx"
+#include "docfunc.hxx"
+#include "cell.hxx"
+#include "rangeutl.hxx"
+#include "scresid.hxx"
+#include "convuno.hxx"
+#include "unonames.hxx"
+#include "solveroptions.hxx"
+#include "solverutil.hxx"
+#include "optsolver.hrc"
+
+#include "optsolver.hxx"
+
+#include <com/sun/star/sheet/Solver.hpp>
+#include <com/sun/star/sheet/XSolverDescription.hpp>
+
+using namespace com::sun::star;
+
+//----------------------------------------------------------------------------
+
+ScSolverProgressDialog::ScSolverProgressDialog( Window* pParent )
+ : ModelessDialog( pParent, ScResId( RID_SCDLG_SOLVER_PROGRESS ) ),
+ maFtProgress ( this, ScResId( FT_PROGRESS ) ),
+ maFtTime ( this, ScResId( FT_TIMELIMIT ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) )
+{
+ maBtnOk.Enable(FALSE);
+ FreeResource();
+}
+
+ScSolverProgressDialog::~ScSolverProgressDialog()
+{
+}
+
+void ScSolverProgressDialog::HideTimeLimit()
+{
+ maFtTime.Hide();
+}
+
+void ScSolverProgressDialog::SetTimeLimit( sal_Int32 nSeconds )
+{
+ String aOld = maFtTime.GetText();
+ String aNew = aOld.GetToken(0,'#');
+ aNew += String::CreateFromInt32( nSeconds );
+ aNew += aOld.GetToken(1,'#');
+ maFtTime.SetText( aNew );
+}
+
+//----------------------------------------------------------------------------
+
+ScSolverNoSolutionDialog::ScSolverNoSolutionDialog( Window* pParent, const String& rErrorText )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_NOSOLUTION ) ),
+ maFtNoSolution ( this, ScResId( FT_NOSOLUTION ) ),
+ maFtErrorText ( this, ScResId( FT_ERRORTEXT ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) )
+{
+ maFtErrorText.SetText( rErrorText );
+ FreeResource();
+}
+
+ScSolverNoSolutionDialog::~ScSolverNoSolutionDialog()
+{
+}
+
+//----------------------------------------------------------------------------
+
+ScSolverSuccessDialog::ScSolverSuccessDialog( Window* pParent, const String& rSolution )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_SUCCESS ) ),
+ maFtSuccess ( this, ScResId( FT_SUCCESS ) ),
+ maFtResult ( this, ScResId( FT_RESULT ) ),
+ maFtQuestion ( this, ScResId( FT_QUESTION ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) )
+{
+ String aMessage = maFtResult.GetText();
+ aMessage.Append( (sal_Char) ' ' );
+ aMessage.Append( rSolution );
+ maFtResult.SetText( aMessage );
+ FreeResource();
+}
+
+ScSolverSuccessDialog::~ScSolverSuccessDialog()
+{
+}
+
+//----------------------------------------------------------------------------
+
+ScCursorRefEdit::ScCursorRefEdit( ScAnyRefDlg* pParent, const ResId& rResId ) :
+ formula::RefEdit( pParent, rResId )
+{
+}
+
+void ScCursorRefEdit::SetCursorLinks( const Link& rUp, const Link& rDown )
+{
+ maCursorUpLink = rUp;
+ maCursorDownLink = rDown;
+}
+
+void ScCursorRefEdit::KeyInput( const KeyEvent& rKEvt )
+{
+ KeyCode aCode = rKEvt.GetKeyCode();
+ bool bUp = (aCode.GetCode() == KEY_UP);
+ bool bDown = (aCode.GetCode() == KEY_DOWN);
+ if ( !aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() && ( bUp || bDown ) )
+ {
+ if ( bUp )
+ maCursorUpLink.Call( this );
+ else
+ maCursorDownLink.Call( this );
+ }
+ else
+ formula::RefEdit::KeyInput( rKEvt );
+}
+
+//----------------------------------------------------------------------------
+
+ScOptSolverSave::ScOptSolverSave( const String& rObjective, BOOL bMax, BOOL bMin, BOOL bValue,
+ const String& rTarget, const String& rVariable,
+ const std::vector<ScOptConditionRow>& rConditions,
+ const String& rEngine,
+ const uno::Sequence<beans::PropertyValue>& rProperties ) :
+ maObjective( rObjective ),
+ mbMax( bMax ),
+ mbMin( bMin ),
+ mbValue( bValue ),
+ maTarget( rTarget ),
+ maVariable( rVariable ),
+ maConditions( rConditions ),
+ maEngine( rEngine ),
+ maProperties( rProperties )
+{
+}
+
+//============================================================================
+// class ScOptSolverDlg
+//----------------------------------------------------------------------------
+
+ScOptSolverDlg::ScOptSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocShell* pDocSh, ScAddress aCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_OPTSOLVER ),
+ //
+ maFtObjectiveCell ( this, ScResId( FT_OBJECTIVECELL ) ),
+ maEdObjectiveCell ( this, ScResId( ED_OBJECTIVECELL ) ),
+ maRBObjectiveCell ( this, ScResId( IB_OBJECTIVECELL ), &maEdObjectiveCell, this ),
+ maFtDirection ( this, ScResId( FT_DIRECTION ) ),
+ maRbMax ( this, ScResId( RB_MAX ) ),
+ maRbMin ( this, ScResId( RB_MIN ) ),
+ maRbValue ( this, ScResId( RB_VALUE ) ),
+ maEdTargetValue ( this, ScResId( ED_TARGET ) ),
+ maRBTargetValue ( this, ScResId( IB_TARGET ), &maEdTargetValue, this ),
+ maFtVariableCells ( this, ScResId( FT_VARIABLECELLS ) ),
+ maEdVariableCells ( this, ScResId( ED_VARIABLECELLS ) ),
+ maRBVariableCells ( this, ScResId( IB_VARIABLECELLS ), &maEdVariableCells, this),
+ maFlConditions ( this, ScResId( FL_CONDITIONS ) ),
+ maFtCellRef ( this, ScResId( FT_CELLREF ) ),
+ maEdLeft1 ( this, ScResId( ED_LEFT1 ) ),
+ maRBLeft1 ( this, ScResId( IB_LEFT1 ), &maEdLeft1, this ),
+ maFtOperator ( this, ScResId( FT_OPERATOR ) ),
+ maLbOp1 ( this, ScResId( LB_OP1 ) ),
+ maFtConstraint ( this, ScResId( FT_CONSTRAINT ) ),
+ maEdRight1 ( this, ScResId( ED_RIGHT1 ) ),
+ maRBRight1 ( this, ScResId( IB_RIGHT1 ), &maEdRight1, this ),
+ maBtnDel1 ( this, ScResId( IB_DELETE1 ) ),
+ maEdLeft2 ( this, ScResId( ED_LEFT2 ) ),
+ maRBLeft2 ( this, ScResId( IB_LEFT2 ), &maEdLeft2, this ),
+ maLbOp2 ( this, ScResId( LB_OP2 ) ),
+ maEdRight2 ( this, ScResId( ED_RIGHT2 ) ),
+ maRBRight2 ( this, ScResId( IB_RIGHT2 ), &maEdRight2, this ),
+ maBtnDel2 ( this, ScResId( IB_DELETE2 ) ),
+ maEdLeft3 ( this, ScResId( ED_LEFT3 ) ),
+ maRBLeft3 ( this, ScResId( IB_LEFT3 ), &maEdLeft3, this ),
+ maLbOp3 ( this, ScResId( LB_OP3 ) ),
+ maEdRight3 ( this, ScResId( ED_RIGHT3 ) ),
+ maRBRight3 ( this, ScResId( IB_RIGHT3 ), &maEdRight3, this ),
+ maBtnDel3 ( this, ScResId( IB_DELETE3 ) ),
+ maEdLeft4 ( this, ScResId( ED_LEFT4 ) ),
+ maRBLeft4 ( this, ScResId( IB_LEFT4 ), &maEdLeft4, this ),
+ maLbOp4 ( this, ScResId( LB_OP4 ) ),
+ maEdRight4 ( this, ScResId( ED_RIGHT4 ) ),
+ maRBRight4 ( this, ScResId( IB_RIGHT4 ), &maEdRight4, this ),
+ maBtnDel4 ( this, ScResId( IB_DELETE4 ) ),
+ maScrollBar ( this, ScResId( SB_SCROLL ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOpt ( this, ScResId( BTN_OPTIONS ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maBtnCancel ( this, ScResId( BTN_CLOSE ) ),
+ maBtnSolve ( this, ScResId( BTN_SOLVE ) ),
+ maInputError ( ScResId( STR_INVALIDINPUT ) ),
+ maConditionError ( ScResId( STR_INVALIDCONDITION ) ),
+ //
+ mpDocShell ( pDocSh ),
+ mpDoc ( pDocSh->GetDocument() ),
+ mnCurTab ( aCursorPos.Tab() ),
+ mpEdActive ( NULL ),
+ mbDlgLostFocus ( false ),
+ nScrollPos ( 0 )
+{
+ mpLeftEdit[0] = &maEdLeft1;
+ mpLeftButton[0] = &maRBLeft1;
+ mpRightEdit[0] = &maEdRight1;
+ mpRightButton[0] = &maRBRight1;
+ mpOperator[0] = &maLbOp1;
+ mpDelButton[0] = &maBtnDel1;
+
+ mpLeftEdit[1] = &maEdLeft2;
+ mpLeftButton[1] = &maRBLeft2;
+ mpRightEdit[1] = &maEdRight2;
+ mpRightButton[1] = &maRBRight2;
+ mpOperator[1] = &maLbOp2;
+ mpDelButton[1] = &maBtnDel2;
+
+ mpLeftEdit[2] = &maEdLeft3;
+ mpLeftButton[2] = &maRBLeft3;
+ mpRightEdit[2] = &maEdRight3;
+ mpRightButton[2] = &maRBRight3;
+ mpOperator[2] = &maLbOp3;
+ mpDelButton[2] = &maBtnDel3;
+
+ mpLeftEdit[3] = &maEdLeft4;
+ mpLeftButton[3] = &maRBLeft4;
+ mpRightEdit[3] = &maEdRight4;
+ mpRightButton[3] = &maRBRight4;
+ mpOperator[3] = &maLbOp4;
+ mpDelButton[3] = &maBtnDel4;
+
+ Init( aCursorPos );
+ FreeResource();
+}
+
+//----------------------------------------------------------------------------
+
+ScOptSolverDlg::~ScOptSolverDlg()
+{
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::Init(const ScAddress& rCursorPos)
+{
+ // Get the "Delete Rows" commandimagelist images from sfx instead of
+ // adding a second copy to sc (see ScTbxInsertCtrl::StateChanged)
+
+ rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
+ aSlotURL += rtl::OUString::valueOf( sal_Int32( SID_DEL_ROWS ) );
+ uno::Reference<frame::XFrame> xFrame = GetBindings().GetActiveFrame();
+ Image aDelNm = ::GetImage( xFrame, aSlotURL, FALSE, FALSE );
+ Image aDelHC = ::GetImage( xFrame, aSlotURL, FALSE, TRUE ); // high contrast
+
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpDelButton[nRow]->SetModeImage( aDelNm, BMP_COLOR_NORMAL );
+ mpDelButton[nRow]->SetModeImage( aDelHC, BMP_COLOR_HIGHCONTRAST );
+ }
+
+ maBtnOpt.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
+ maBtnCancel.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
+ maBtnSolve.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
+
+ Link aLink = LINK( this, ScOptSolverDlg, GetFocusHdl );
+ maEdObjectiveCell.SetGetFocusHdl( aLink );
+ maRBObjectiveCell.SetGetFocusHdl( aLink );
+ maEdTargetValue.SetGetFocusHdl( aLink );
+ maRBTargetValue.SetGetFocusHdl( aLink );
+ maEdVariableCells.SetGetFocusHdl( aLink );
+ maRBVariableCells.SetGetFocusHdl( aLink );
+ maRbValue.SetGetFocusHdl( aLink );
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpLeftEdit[nRow]->SetGetFocusHdl( aLink );
+ mpLeftButton[nRow]->SetGetFocusHdl( aLink );
+ mpRightEdit[nRow]->SetGetFocusHdl( aLink );
+ mpRightButton[nRow]->SetGetFocusHdl( aLink );
+ mpOperator[nRow]->SetGetFocusHdl( aLink );
+ }
+
+ aLink = LINK( this, ScOptSolverDlg, LoseFocusHdl );
+ maEdObjectiveCell.SetLoseFocusHdl( aLink );
+ maRBObjectiveCell.SetLoseFocusHdl( aLink );
+ maEdTargetValue. SetLoseFocusHdl( aLink );
+ maRBTargetValue. SetLoseFocusHdl( aLink );
+ maEdVariableCells.SetLoseFocusHdl( aLink );
+ maRBVariableCells.SetLoseFocusHdl( aLink );
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpLeftEdit[nRow]->SetLoseFocusHdl( aLink );
+ mpLeftButton[nRow]->SetLoseFocusHdl( aLink );
+ mpRightEdit[nRow]->SetLoseFocusHdl( aLink );
+ mpRightButton[nRow]->SetLoseFocusHdl( aLink );
+ }
+
+ Link aCursorUp = LINK( this, ScOptSolverDlg, CursorUpHdl );
+ Link aCursorDown = LINK( this, ScOptSolverDlg, CursorDownHdl );
+ Link aCondModify = LINK( this, ScOptSolverDlg, CondModifyHdl );
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpLeftEdit[nRow]->SetCursorLinks( aCursorUp, aCursorDown );
+ mpRightEdit[nRow]->SetCursorLinks( aCursorUp, aCursorDown );
+ mpLeftEdit[nRow]->SetModifyHdl( aCondModify );
+ mpRightEdit[nRow]->SetModifyHdl( aCondModify );
+ mpDelButton[nRow]->SetClickHdl( LINK( this, ScOptSolverDlg, DelBtnHdl ) );
+ mpOperator[nRow]->SetSelectHdl( LINK( this, ScOptSolverDlg, SelectHdl ) );
+ }
+ maEdTargetValue.SetModifyHdl( LINK( this, ScOptSolverDlg, TargetModifyHdl ) );
+
+ maScrollBar.SetEndScrollHdl( LINK( this, ScOptSolverDlg, ScrollHdl ) );
+ maScrollBar.SetScrollHdl( LINK( this, ScOptSolverDlg, ScrollHdl ) );
+
+ maScrollBar.SetPageSize( EDIT_ROW_COUNT );
+ maScrollBar.SetVisibleSize( EDIT_ROW_COUNT );
+ maScrollBar.SetLineSize( 1 );
+ // Range is set in ShowConditions
+
+ // get available solver implementations
+ //! sort by descriptions?
+ ScSolverUtil::GetImplementations( maImplNames, maDescriptions );
+ sal_Int32 nImplCount = maImplNames.getLength();
+
+ const ScOptSolverSave* pOldData = mpDocShell->GetSolverSaveData();
+ if ( pOldData )
+ {
+ maEdObjectiveCell.SetRefString( pOldData->GetObjective() );
+ maRbMax.Check( pOldData->GetMax() );
+ maRbMin.Check( pOldData->GetMin() );
+ maRbValue.Check( pOldData->GetValue() );
+ maEdTargetValue.SetRefString( pOldData->GetTarget() );
+ maEdVariableCells.SetRefString( pOldData->GetVariable() );
+ maConditions = pOldData->GetConditions();
+ maEngine = pOldData->GetEngine();
+ maProperties = pOldData->GetProperties();
+ }
+ else
+ {
+ maRbMax.Check();
+ String aCursorStr;
+ if ( !mpDoc->GetRangeAtBlock( ScRange(rCursorPos), &aCursorStr ) )
+ rCursorPos.Format( aCursorStr, SCA_ABS, NULL, mpDoc->GetAddressConvention() );
+ maEdObjectiveCell.SetRefString( aCursorStr );
+ if ( nImplCount > 0 )
+ maEngine = maImplNames[0]; // use first implementation
+ }
+ ShowConditions();
+
+ maEdObjectiveCell.GrabFocus();
+ mpEdActive = &maEdObjectiveCell;
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::ReadConditions()
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ ScOptConditionRow aRowEntry;
+ aRowEntry.aLeftStr = mpLeftEdit[nRow]->GetText();
+ aRowEntry.aRightStr = mpRightEdit[nRow]->GetText();
+ aRowEntry.nOperator = mpOperator[nRow]->GetSelectEntryPos();
+
+ long nVecPos = nScrollPos + nRow;
+ if ( nVecPos >= (long)maConditions.size() && !aRowEntry.IsDefault() )
+ maConditions.resize( nVecPos + 1 );
+
+ if ( nVecPos < (long)maConditions.size() )
+ maConditions[nVecPos] = aRowEntry;
+
+ // remove default entries at the end
+ size_t nSize = maConditions.size();
+ while ( nSize > 0 && maConditions[ nSize-1 ].IsDefault() )
+ --nSize;
+ maConditions.resize( nSize );
+ }
+}
+
+void ScOptSolverDlg::ShowConditions()
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ ScOptConditionRow aRowEntry;
+
+ long nVecPos = nScrollPos + nRow;
+ if ( nVecPos < (long)maConditions.size() )
+ aRowEntry = maConditions[nVecPos];
+
+ mpLeftEdit[nRow]->SetRefString( aRowEntry.aLeftStr );
+ mpRightEdit[nRow]->SetRefString( aRowEntry.aRightStr );
+ mpOperator[nRow]->SelectEntryPos( aRowEntry.nOperator );
+ }
+
+ // allow to scroll one page behind the visible or stored rows
+ long nVisible = nScrollPos + EDIT_ROW_COUNT;
+ long nMax = std::max( nVisible, (long) maConditions.size() );
+ maScrollBar.SetRange( Range( 0, nMax + EDIT_ROW_COUNT ) );
+ maScrollBar.SetThumbPos( nScrollPos );
+
+ EnableButtons();
+}
+
+void ScOptSolverDlg::EnableButtons()
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ long nVecPos = nScrollPos + nRow;
+ mpDelButton[nRow]->Enable( nVecPos < (long)maConditions.size() );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScOptSolverDlg::Close()
+{
+ return DoClose( ScOptSolverDlgWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::SetActive()
+{
+ if ( mbDlgLostFocus )
+ {
+ mbDlgLostFocus = false;
+ if( mpEdActive )
+ mpEdActive->GrabFocus();
+ }
+ else
+ {
+ GrabFocus();
+ }
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if( mpEdActive )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(mpEdActive);
+
+ // "target"/"value": single cell
+ bool bSingle = ( mpEdActive == &maEdObjectiveCell || mpEdActive == &maEdTargetValue );
+
+ String aStr;
+ ScAddress aAdr = rRef.aStart;
+ ScRange aNewRef( rRef );
+ if ( bSingle )
+ aNewRef.aEnd = aAdr;
+
+ String aName;
+ if ( pDocP->GetRangeAtBlock( aNewRef, &aName ) ) // named range: show name
+ aStr = aName;
+ else // format cell/range reference
+ {
+ USHORT nFmt = ( aAdr.Tab() == mnCurTab ) ? SCA_ABS : SCA_ABS_3D;
+ if ( bSingle )
+ aAdr.Format( aStr, nFmt, pDocP, pDocP->GetAddressConvention() );
+ else
+ rRef.Format( aStr, nFmt | SCR_ABS, pDocP, pDocP->GetAddressConvention() );
+ }
+
+ // variable cells can be several ranges, so only the selection is replaced
+ if ( mpEdActive == &maEdVariableCells )
+ {
+ String aVal = mpEdActive->GetText();
+ Selection aSel = mpEdActive->GetSelection();
+ aSel.Justify();
+ aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
+ aVal.Insert( aStr, (xub_StrLen)aSel.Min() );
+ Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() );
+ mpEdActive->SetRefString( aVal );
+ mpEdActive->SetSelection( aNewSel );
+ }
+ else
+ mpEdActive->SetRefString( aStr );
+
+ ReadConditions();
+ EnableButtons();
+
+ // select "Value of" if a ref is input into "target" edit
+ if ( mpEdActive == &maEdTargetValue )
+ maRbValue.Check();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScOptSolverDlg::IsRefInputMode() const
+{
+ return mpEdActive != NULL;
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScOptSolverDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &maBtnSolve || pBtn == &maBtnCancel )
+ {
+ bool bSolve = ( pBtn == &maBtnSolve );
+
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+
+ bool bClose = true;
+ if ( bSolve )
+ bClose = CallSolver();
+
+ if ( bClose )
+ {
+ // Close: write dialog settings to DocShell for subsequent calls
+ ReadConditions();
+ ScOptSolverSave aSave(
+ maEdObjectiveCell.GetText(), maRbMax.IsChecked(), maRbMin.IsChecked(), maRbValue.IsChecked(),
+ maEdTargetValue.GetText(), maEdVariableCells.GetText(), maConditions, maEngine, maProperties );
+ mpDocShell->SetSolverSaveData( aSave );
+ Close();
+ }
+ else
+ {
+ // no solution -> dialog is kept open
+ SetDispatcherLock( TRUE );
+ }
+ }
+ else if ( pBtn == &maBtnOpt )
+ {
+ //! move options dialog to UI lib?
+ ScSolverOptionsDialog* pOptDlg =
+ new ScSolverOptionsDialog( this, maImplNames, maDescriptions, maEngine, maProperties );
+ if ( pOptDlg->Execute() == RET_OK )
+ {
+ maEngine = pOptDlg->GetEngine();
+ maProperties = pOptDlg->GetProperties();
+ }
+ delete pOptDlg;
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, GetFocusHdl, Control*, pCtrl )
+{
+ Edit* pEdit = NULL;
+ mpEdActive = NULL;
+
+ if( pCtrl == &maEdObjectiveCell || pCtrl == &maRBObjectiveCell )
+ pEdit = mpEdActive = &maEdObjectiveCell;
+ else if( pCtrl == &maEdTargetValue || pCtrl == &maRBTargetValue )
+ pEdit = mpEdActive = &maEdTargetValue;
+ else if( pCtrl == &maEdVariableCells || pCtrl == &maRBVariableCells )
+ pEdit = mpEdActive = &maEdVariableCells;
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ if( pCtrl == mpLeftEdit[nRow] || pCtrl == mpLeftButton[nRow] )
+ pEdit = mpEdActive = mpLeftEdit[nRow];
+ else if( pCtrl == mpRightEdit[nRow] || pCtrl == mpRightButton[nRow] )
+ pEdit = mpEdActive = mpRightEdit[nRow];
+ else if( pCtrl == mpOperator[nRow] ) // focus on "operator" list box
+ mpEdActive = mpRightEdit[nRow]; // use right edit for ref input, but don't change selection
+ }
+ if( pCtrl == &maRbValue ) // focus on "Value of" radio button
+ mpEdActive = &maEdTargetValue; // use value edit for ref input, but don't change selection
+
+ if( pEdit )
+ pEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ mbDlgLostFocus = !IsActive();
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, DelBtnHdl, PushButton*, pBtn )
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ if( pBtn == mpDelButton[nRow] )
+ {
+ BOOL bHadFocus = pBtn->HasFocus();
+
+ ReadConditions();
+ long nVecPos = nScrollPos + nRow;
+ if ( nVecPos < (long)maConditions.size() )
+ {
+ maConditions.erase( maConditions.begin() + nVecPos );
+ ShowConditions();
+
+ if ( bHadFocus && !pBtn->IsEnabled() )
+ {
+ // If the button is disabled, focus would normally move to the next control,
+ // (left edit of the next row). Move it to left edit of this row instead.
+
+ mpEdActive = mpLeftEdit[nRow];
+ mpEdActive->GrabFocus();
+ }
+ }
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, TargetModifyHdl, Edit*, EMPTYARG )
+{
+ // modify handler for the target edit:
+ // select "Value of" if something is input into the edit
+ if ( maEdTargetValue.GetText().Len() )
+ maRbValue.Check();
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, CondModifyHdl, Edit*, EMPTYARG )
+{
+ // modify handler for the condition edits, just to enable/disable "delete" buttons
+ ReadConditions();
+ EnableButtons();
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, SelectHdl, ListBox*, EMPTYARG )
+{
+ // select handler for operator list boxes, just to enable/disable "delete" buttons
+ ReadConditions();
+ EnableButtons();
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, ScrollHdl, ScrollBar*, EMPTYARG )
+{
+ ReadConditions();
+ nScrollPos = maScrollBar.GetThumbPos();
+ ShowConditions();
+ if( mpEdActive )
+ mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, CursorUpHdl, ScCursorRefEdit*, pEdit )
+{
+ if ( pEdit == mpLeftEdit[0] || pEdit == mpRightEdit[0] )
+ {
+ if ( nScrollPos > 0 )
+ {
+ ReadConditions();
+ --nScrollPos;
+ ShowConditions();
+ if( mpEdActive )
+ mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+ }
+ }
+ else
+ {
+ formula::RefEdit* pFocus = NULL;
+ for ( sal_uInt16 nRow = 1; nRow < EDIT_ROW_COUNT; ++nRow ) // second row or below: move focus
+ {
+ if ( pEdit == mpLeftEdit[nRow] )
+ pFocus = mpLeftEdit[nRow-1];
+ else if ( pEdit == mpRightEdit[nRow] )
+ pFocus = mpRightEdit[nRow-1];
+ }
+ if (pFocus)
+ {
+ mpEdActive = pFocus;
+ pFocus->GrabFocus();
+ }
+ }
+
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, CursorDownHdl, ScCursorRefEdit*, pEdit )
+{
+ if ( pEdit == mpLeftEdit[EDIT_ROW_COUNT-1] || pEdit == mpRightEdit[EDIT_ROW_COUNT-1] )
+ {
+ //! limit scroll position?
+ ReadConditions();
+ ++nScrollPos;
+ ShowConditions();
+ if( mpEdActive )
+ mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+ }
+ else
+ {
+ formula::RefEdit* pFocus = NULL;
+ for ( sal_uInt16 nRow = 0; nRow+1 < EDIT_ROW_COUNT; ++nRow ) // before last row: move focus
+ {
+ if ( pEdit == mpLeftEdit[nRow] )
+ pFocus = mpLeftEdit[nRow+1];
+ else if ( pEdit == mpRightEdit[nRow] )
+ pFocus = mpRightEdit[nRow+1];
+ }
+ if (pFocus)
+ {
+ mpEdActive = pFocus;
+ pFocus->GrabFocus();
+ }
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::ShowError( bool bCondition, formula::RefEdit* pFocus )
+{
+ String aMessage = bCondition ? maConditionError : maInputError;
+ ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ), aMessage ).Execute();
+ if (pFocus)
+ {
+ mpEdActive = pFocus;
+ pFocus->GrabFocus();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+bool ScOptSolverDlg::ParseRef( ScRange& rRange, const String& rInput, bool bAllowRange )
+{
+ ScRangeUtil aRangeUtil;
+ ScAddress::Details aDetails(mpDoc->GetAddressConvention(), 0, 0);
+ USHORT nFlags = rRange.ParseAny( rInput, mpDoc, aDetails );
+ if ( nFlags & SCA_VALID )
+ {
+ if ( (nFlags & SCA_TAB_3D) == 0 )
+ rRange.aStart.SetTab( mnCurTab );
+ if ( (nFlags & SCA_TAB2_3D) == 0 )
+ rRange.aEnd.SetTab( rRange.aStart.Tab() );
+ return ( bAllowRange || rRange.aStart == rRange.aEnd );
+ }
+ else if ( aRangeUtil.MakeRangeFromName( rInput, mpDoc, mnCurTab, rRange, RUTL_NAMES, aDetails ) )
+ return ( bAllowRange || rRange.aStart == rRange.aEnd );
+
+ return false; // not recognized
+}
+
+bool ScOptSolverDlg::FindTimeout( sal_Int32& rTimeout )
+{
+ bool bFound = false;
+
+ if ( !maProperties.getLength() )
+ maProperties = ScSolverUtil::GetDefaults( maEngine ); // get property defaults from component
+
+ sal_Int32 nPropCount = maProperties.getLength();
+ for (sal_Int32 nProp=0; nProp<nPropCount && !bFound; ++nProp)
+ {
+ const beans::PropertyValue& rValue = maProperties[nProp];
+ if ( rValue.Name.equalsAscii( SC_UNONAME_TIMEOUT ) )
+ bFound = ( rValue.Value >>= rTimeout );
+ }
+ return bFound;
+}
+
+bool ScOptSolverDlg::CallSolver() // return true -> close dialog after calling
+{
+ // show progress dialog
+
+ ScSolverProgressDialog aProgress( this );
+ sal_Int32 nTimeout = 0;
+ if ( FindTimeout( nTimeout ) )
+ aProgress.SetTimeLimit( nTimeout );
+ else
+ aProgress.HideTimeLimit();
+ aProgress.Show();
+ aProgress.Update();
+ aProgress.Sync();
+ // try to make sure the progress dialog is painted before continuing
+ Application::Reschedule(true);
+
+ // collect solver parameters
+
+ ReadConditions();
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDocument( mpDocShell->GetModel(), uno::UNO_QUERY );
+
+ ScRange aObjRange;
+ if ( !ParseRef( aObjRange, maEdObjectiveCell.GetText(), false ) )
+ {
+ ShowError( false, &maEdObjectiveCell );
+ return false;
+ }
+ table::CellAddress aObjective( aObjRange.aStart.Tab(), aObjRange.aStart.Col(), aObjRange.aStart.Row() );
+
+ // "changing cells" can be several ranges
+ ScRangeList aVarRanges;
+ if ( !ParseWithNames( aVarRanges, maEdVariableCells.GetText(), mpDoc ) )
+ {
+ ShowError( false, &maEdVariableCells );
+ return false;
+ }
+ uno::Sequence<table::CellAddress> aVariables;
+ sal_Int32 nVarPos = 0;
+ ULONG nRangeCount = aVarRanges.Count();
+ for (ULONG nRangePos=0; nRangePos<nRangeCount; ++nRangePos)
+ {
+ ScRange aRange(*aVarRanges.GetObject(nRangePos));
+ aRange.Justify();
+ SCTAB nTab = aRange.aStart.Tab();
+
+ // resolve into single cells
+
+ sal_Int32 nAdd = ( aRange.aEnd.Col() - aRange.aStart.Col() + 1 ) *
+ ( aRange.aEnd.Row() - aRange.aStart.Row() + 1 );
+ aVariables.realloc( nVarPos + nAdd );
+
+ for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow)
+ for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol)
+ aVariables[nVarPos++] = table::CellAddress( nTab, nCol, nRow );
+ }
+
+ uno::Sequence<sheet::SolverConstraint> aConstraints;
+ sal_Int32 nConstrPos = 0;
+ for ( std::vector<ScOptConditionRow>::const_iterator aConstrIter = maConditions.begin();
+ aConstrIter != maConditions.end(); ++aConstrIter )
+ {
+ if ( aConstrIter->aLeftStr.Len() )
+ {
+ sheet::SolverConstraint aConstraint;
+ // order of list box entries must match enum values
+ aConstraint.Operator = static_cast<sheet::SolverConstraintOperator>(aConstrIter->nOperator);
+
+ ScRange aLeftRange;
+ if ( !ParseRef( aLeftRange, aConstrIter->aLeftStr, true ) )
+ {
+ ShowError( true, NULL );
+ return false;
+ }
+
+ bool bIsRange = false;
+ ScRange aRightRange;
+ if ( ParseRef( aRightRange, aConstrIter->aRightStr, true ) )
+ {
+ if ( aRightRange.aStart == aRightRange.aEnd )
+ aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
+ aRightRange.aStart.Col(), aRightRange.aStart.Row() );
+ else if ( aRightRange.aEnd.Col()-aRightRange.aStart.Col() == aLeftRange.aEnd.Col()-aLeftRange.aStart.Col() &&
+ aRightRange.aEnd.Row()-aRightRange.aStart.Row() == aLeftRange.aEnd.Row()-aLeftRange.aStart.Row() )
+ bIsRange = true; // same size as "left" range, resolve into single cells
+ else
+ {
+ ShowError( true, NULL );
+ return false;
+ }
+ }
+ else
+ {
+ sal_uInt32 nFormat = 0; //! explicit language?
+ double fValue = 0.0;
+ if ( mpDoc->GetFormatTable()->IsNumberFormat( aConstrIter->aRightStr, nFormat, fValue ) )
+ aConstraint.Right <<= fValue;
+ else if ( aConstraint.Operator != sheet::SolverConstraintOperator_INTEGER &&
+ aConstraint.Operator != sheet::SolverConstraintOperator_BINARY )
+ {
+ ShowError( true, NULL );
+ return false;
+ }
+ }
+
+ // resolve into single cells
+
+ sal_Int32 nAdd = ( aLeftRange.aEnd.Col() - aLeftRange.aStart.Col() + 1 ) *
+ ( aLeftRange.aEnd.Row() - aLeftRange.aStart.Row() + 1 );
+ aConstraints.realloc( nConstrPos + nAdd );
+
+ for (SCROW nRow = aLeftRange.aStart.Row(); nRow <= aLeftRange.aEnd.Row(); ++nRow)
+ for (SCCOL nCol = aLeftRange.aStart.Col(); nCol <= aLeftRange.aEnd.Col(); ++nCol)
+ {
+ aConstraint.Left = table::CellAddress( aLeftRange.aStart.Tab(), nCol, nRow );
+ if ( bIsRange )
+ aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
+ aRightRange.aStart.Col() + ( nCol - aLeftRange.aStart.Col() ),
+ aRightRange.aStart.Row() + ( nRow - aLeftRange.aStart.Row() ) );
+
+ aConstraints[nConstrPos++] = aConstraint;
+ }
+ }
+ }
+
+ sal_Bool bMaximize = maRbMax.IsChecked();
+ if ( maRbValue.IsChecked() )
+ {
+ // handle "value of" with an additional constraint (and then minimize)
+
+ sheet::SolverConstraint aConstraint;
+ aConstraint.Left = aObjective;
+ aConstraint.Operator = sheet::SolverConstraintOperator_EQUAL;
+
+ String aValStr = maEdTargetValue.GetText();
+ ScRange aRightRange;
+ if ( ParseRef( aRightRange, aValStr, false ) )
+ aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
+ aRightRange.aStart.Col(), aRightRange.aStart.Row() );
+ else
+ {
+ sal_uInt32 nFormat = 0; //! explicit language?
+ double fValue = 0.0;
+ if ( mpDoc->GetFormatTable()->IsNumberFormat( aValStr, nFormat, fValue ) )
+ aConstraint.Right <<= fValue;
+ else
+ {
+ ShowError( false, &maEdTargetValue );
+ return false;
+ }
+ }
+
+ aConstraints.realloc( nConstrPos + 1 );
+ aConstraints[nConstrPos++] = aConstraint;
+ }
+
+ // copy old document values
+
+ sal_Int32 nVarCount = aVariables.getLength();
+ uno::Sequence<double> aOldValues;
+ aOldValues.realloc( nVarCount );
+ for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
+ {
+ ScAddress aCellPos;
+ ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
+ aOldValues[nVarPos] = mpDoc->GetValue( aCellPos );
+ }
+
+ // create and initialize solver
+
+ uno::Reference<sheet::XSolver> xSolver = ScSolverUtil::GetSolver( maEngine );
+ DBG_ASSERT( xSolver.is(), "can't get solver component" );
+ if ( !xSolver.is() )
+ return false;
+
+ xSolver->setDocument( xDocument );
+ xSolver->setObjective( aObjective );
+ xSolver->setVariables( aVariables );
+ xSolver->setConstraints( aConstraints );
+ xSolver->setMaximize( bMaximize );
+
+ // set options
+ uno::Reference<beans::XPropertySet> xOptProp(xSolver, uno::UNO_QUERY);
+ if ( xOptProp.is() )
+ {
+ sal_Int32 nPropCount = maProperties.getLength();
+ for (sal_Int32 nProp=0; nProp<nPropCount; ++nProp)
+ {
+ const beans::PropertyValue& rValue = maProperties[nProp];
+ try
+ {
+ xOptProp->setPropertyValue( rValue.Name, rValue.Value );
+ }
+ catch ( uno::Exception & )
+ {
+ DBG_ERRORFILE("Exception in solver option property");
+ }
+ }
+ }
+
+ xSolver->solve();
+ sal_Bool bSuccess = xSolver->getSuccess();
+
+ aProgress.Hide();
+ bool bClose = false;
+ bool bRestore = true; // restore old values unless a solution is accepted
+ if ( bSuccess )
+ {
+ // put solution into document so it is visible when asking
+ uno::Sequence<double> aSolution = xSolver->getSolution();
+ if ( aSolution.getLength() == nVarCount )
+ {
+ mpDocShell->LockPaint();
+ ScDocFunc aFunc(*mpDocShell);
+ for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
+ {
+ ScAddress aCellPos;
+ ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
+ aFunc.PutCell( aCellPos, new ScValueCell( aSolution[nVarPos] ), TRUE );
+ }
+ mpDocShell->UnlockPaint();
+ }
+ //! else error?
+
+ // take formatted result from document (result value from component is ignored)
+ String aResultStr;
+ mpDoc->GetString( (SCCOL)aObjective.Column, (SCROW)aObjective.Row, (SCTAB)aObjective.Sheet, aResultStr );
+ ScSolverSuccessDialog aDialog( this, aResultStr );
+ if ( aDialog.Execute() == RET_OK )
+ {
+ // keep results and close dialog
+ bRestore = false;
+ bClose = true;
+ }
+ }
+ else
+ {
+ rtl::OUString aError;
+ uno::Reference<sheet::XSolverDescription> xDesc( xSolver, uno::UNO_QUERY );
+ if ( xDesc.is() )
+ aError = xDesc->getStatusDescription(); // error description from component
+ ScSolverNoSolutionDialog aDialog( this, aError );
+ aDialog.Execute();
+ }
+
+ if ( bRestore ) // restore old values
+ {
+ mpDocShell->LockPaint();
+ ScDocFunc aFunc(*mpDocShell);
+ for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
+ {
+ ScAddress aCellPos;
+ ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
+ aFunc.PutCell( aCellPos, new ScValueCell( aOldValues[nVarPos] ), TRUE );
+ }
+ mpDocShell->UnlockPaint();
+ }
+
+ return bClose;
+}
+
diff --git a/sc/source/ui/miscdlgs/simpref.cxx b/sc/source/ui/miscdlgs/simpref.cxx index 05134f9bb114..a18f8646b75e 100644 --- a/sc/source/ui/miscdlgs/simpref.cxx +++ b/sc/source/ui/miscdlgs/simpref.cxx @@ -74,7 +74,7 @@ ScSimpleRefDlg::ScSimpleRefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pP // aFtAssign ( this, ScResId( FT_ASSIGN ) ), aEdAssign ( this, ScResId( ED_ASSIGN ) ), - aRbAssign ( this, ScResId( RB_ASSIGN ), &aEdAssign ), + aRbAssign ( this, ScResId( RB_ASSIGN ), &aEdAssign, this ), aBtnOk ( this, ScResId( BTN_OK ) ), aBtnCancel ( this, ScResId( BTN_CANCEL ) ), diff --git a/sc/source/ui/miscdlgs/solvrdlg.cxx b/sc/source/ui/miscdlgs/solvrdlg.cxx index 4f26c9626838..7b81004dc43c 100644 --- a/sc/source/ui/miscdlgs/solvrdlg.cxx +++ b/sc/source/ui/miscdlgs/solvrdlg.cxx @@ -1,316 +1,316 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: solvrdlg.cxx,v $ - * $Revision: 1.13 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - - - -//---------------------------------------------------------------------------- - -#include "rangelst.hxx" -#include "scitems.hxx" -#include <sfx2/dispatch.hxx> -#include <svtools/zforlist.hxx> -#include <vcl/msgbox.hxx> - -#include "uiitems.hxx" -#include "reffact.hxx" -#include "document.hxx" -#include "scresid.hxx" -#include "solvrdlg.hrc" - -#define _SOLVRDLG_CXX -#include "solvrdlg.hxx" -#undef _SOLVERDLG_CXX - - -#define ERRORBOX(s) ErrorBox( this, WinBits( WB_OK | WB_DEF_OK), s ).Execute() - - -//============================================================================ -// class ScSolverDlg -//---------------------------------------------------------------------------- - -ScSolverDlg::ScSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, - ScDocument* pDocument, - ScAddress aCursorPos ) - - : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_SOLVER ), - // - aFlVariables ( this, ScResId( FL_VARIABLES ) ), - aFtFormulaCell ( this, ScResId( FT_FORMULACELL ) ), - aEdFormulaCell ( this, ScResId( ED_FORMULACELL ) ), - aRBFormulaCell ( this, ScResId( RB_FORMULACELL ), &aEdFormulaCell ), - aFtTargetVal ( this, ScResId( FT_TARGETVAL ) ), - aEdTargetVal ( this, ScResId( ED_TARGETVAL ) ), - aFtVariableCell ( this, ScResId( FT_VARCELL ) ), - aEdVariableCell ( this, ScResId( ED_VARCELL ) ), - aRBVariableCell ( this, ScResId( RB_VARCELL ), &aEdVariableCell ), - aBtnOk ( this, ScResId( BTN_OK ) ), - aBtnCancel ( this, ScResId( BTN_CANCEL ) ), - aBtnHelp ( this, ScResId( BTN_HELP ) ), - // - theFormulaCell ( aCursorPos ), - theVariableCell ( aCursorPos ), - pDoc ( pDocument ), - nCurTab ( aCursorPos.Tab() ), - pEdActive ( NULL ), - bDlgLostFocus ( FALSE ), - errMsgInvalidVar ( ScResId( STR_INVALIDVAR ) ), - errMsgInvalidForm ( ScResId( STR_INVALIDFORM ) ), - errMsgNoFormula ( ScResId( STR_NOFORMULA ) ), - errMsgInvalidVal ( ScResId( STR_INVALIDVAL ) ) -{ - Init(); - FreeResource(); -} - -//---------------------------------------------------------------------------- - -__EXPORT ScSolverDlg::~ScSolverDlg() -{ -} - -//---------------------------------------------------------------------------- - -void __EXPORT ScSolverDlg::Init() -{ - String aStr; - - aBtnOk. SetClickHdl ( LINK( this, ScSolverDlg, BtnHdl ) ); - aBtnCancel. SetClickHdl ( LINK( this, ScSolverDlg, BtnHdl ) ); - - Link aLink = LINK( this, ScSolverDlg, GetFocusHdl ); - aEdFormulaCell. SetGetFocusHdl ( aLink ); - aRBFormulaCell. SetGetFocusHdl ( aLink ); - aEdVariableCell.SetGetFocusHdl ( aLink ); - aRBVariableCell.SetGetFocusHdl ( aLink ); - aEdTargetVal. SetGetFocusHdl ( aLink ); - - aLink = LINK( this, ScSolverDlg, LoseFocusHdl ); - aEdFormulaCell. SetLoseFocusHdl ( aLink ); - aRBFormulaCell. SetLoseFocusHdl ( aLink ); - aEdVariableCell.SetLoseFocusHdl ( aLink ); - aRBVariableCell.SetLoseFocusHdl ( aLink ); - - theFormulaCell.Format( aStr, SCA_ABS, NULL, pDoc->GetAddressConvention() ); - - aEdFormulaCell.SetText( aStr ); - aEdFormulaCell.GrabFocus(); - pEdActive = &aEdFormulaCell; -} - -//---------------------------------------------------------------------------- - -BOOL __EXPORT ScSolverDlg::Close() -{ - return DoClose( ScSolverDlgWrapper::GetChildWindowId() ); -} - -//---------------------------------------------------------------------------- - -void ScSolverDlg::SetActive() -{ - if ( bDlgLostFocus ) - { - bDlgLostFocus = FALSE; - if( pEdActive ) - pEdActive->GrabFocus(); - } - else - { - GrabFocus(); - } - RefInputDone(); -} - -//---------------------------------------------------------------------------- - -void ScSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP ) -{ - if( pEdActive ) - { - if ( rRef.aStart != rRef.aEnd ) - RefInputStart(pEdActive); - - String aStr; - ScAddress aAdr = rRef.aStart; - USHORT nFmt = ( aAdr.Tab() == nCurTab ) - ? SCA_ABS - : SCA_ABS_3D; - - aAdr.Format( aStr, nFmt, pDocP, pDocP->GetAddressConvention() ); - pEdActive->SetRefString( aStr ); - - if ( pEdActive == &aEdFormulaCell ) - theFormulaCell = aAdr; - else if ( pEdActive == &aEdVariableCell ) - theVariableCell = aAdr; - } -} - -//---------------------------------------------------------------------------- - -void ScSolverDlg::RaiseError( ScSolverErr eError ) -{ - switch ( eError ) - { - case SOLVERR_NOFORMULA: - ERRORBOX( errMsgNoFormula ); - aEdFormulaCell.GrabFocus(); - break; - - case SOLVERR_INVALID_FORMULA: - ERRORBOX( errMsgInvalidForm ); - aEdFormulaCell.GrabFocus(); - break; - - case SOLVERR_INVALID_VARIABLE: - ERRORBOX( errMsgInvalidVar ); - aEdVariableCell.GrabFocus(); - break; - - case SOLVERR_INVALID_TARGETVALUE: - ERRORBOX( errMsgInvalidVal ); - aEdTargetVal.GrabFocus(); - break; - } -} - -//---------------------------------------------------------------------------- - -BOOL ScSolverDlg::IsRefInputMode() const -{ - return pEdActive != NULL; -} - -//---------------------------------------------------------------------------- - -BOOL __EXPORT ScSolverDlg::CheckTargetValue( String& rStrVal ) -{ - sal_uInt32 n1 = 0; - double n2; - - return pDoc->GetFormatTable()->IsNumberFormat( rStrVal, n1, n2 ); -} - -//---------------------------------------------------------------------------- -// Handler: - -IMPL_LINK( ScSolverDlg, BtnHdl, PushButton*, pBtn ) -{ - if ( pBtn == &aBtnOk ) - { - theTargetValStr = aEdTargetVal.GetText(); - - // Zu ueberpruefen: - // 1. enthalten die Strings korrekte Tabellenkoordinaten/def.Namen? - // 2. verweist die Formel-Koordinate wirklich auf eine Formelzelle? - // 3. wurde ein korrekter Zielwert eingegeben - - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); - USHORT nRes1 = theFormulaCell .Parse( aEdFormulaCell.GetText(), pDoc, eConv ); - USHORT nRes2 = theVariableCell.Parse( aEdVariableCell.GetText(), pDoc, eConv ); - - if ( SCA_VALID == ( nRes1 & SCA_VALID ) ) - { - if ( SCA_VALID == ( nRes2 & SCA_VALID ) ) - { - if ( CheckTargetValue( theTargetValStr ) ) - { - CellType eType; - pDoc->GetCellType( theFormulaCell.Col(), - theFormulaCell.Row(), - theFormulaCell.Tab(), - eType ); - - if ( CELLTYPE_FORMULA == eType ) - { - ScSolveParam aOutParam( theFormulaCell, - theVariableCell, - theTargetValStr ); - ScSolveItem aOutItem( SCITEM_SOLVEDATA, &aOutParam ); - - SetDispatcherLock( FALSE ); - - SwitchToDocument(); - GetBindings().GetDispatcher()->Execute( SID_SOLVE, - SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, - &aOutItem, 0L, 0L ); - Close(); - } - else RaiseError( SOLVERR_NOFORMULA ); - } - else RaiseError( SOLVERR_INVALID_TARGETVALUE ); - } - else RaiseError( SOLVERR_INVALID_VARIABLE ); - } - else RaiseError( SOLVERR_INVALID_FORMULA ); - } - else if ( pBtn == &aBtnCancel ) - { - Close(); - } - - return 0; -} - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScSolverDlg, GetFocusHdl, Control*, pCtrl ) -{ - Edit* pEdit = NULL; - pEdActive = NULL; - - if( (pCtrl == (Control*)&aEdFormulaCell) || (pCtrl == (Control*)&aRBFormulaCell) ) - pEdit = pEdActive = &aEdFormulaCell; - else if( (pCtrl == (Control*)&aEdVariableCell) || (pCtrl == (Control*)&aRBVariableCell) ) - pEdit = pEdActive = &aEdVariableCell; - else if( pCtrl == (Control*)&aEdTargetVal ) - pEdit = &aEdTargetVal; - - if( pEdit ) - pEdit->SetSelection( Selection( 0, SELECTION_MAX ) ); - - return 0; -} - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScSolverDlg, LoseFocusHdl, Control*, EMPTYARG ) -{ - bDlgLostFocus = !IsActive(); - return 0; -} - - - - +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: solvrdlg.cxx,v $
+ * $Revision: 1.13 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include "rangelst.hxx"
+#include "scitems.hxx"
+#include <sfx2/dispatch.hxx>
+#include <svtools/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "uiitems.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "solvrdlg.hrc"
+
+#define _SOLVRDLG_CXX
+#include "solvrdlg.hxx"
+#undef _SOLVERDLG_CXX
+
+
+#define ERRORBOX(s) ErrorBox( this, WinBits( WB_OK | WB_DEF_OK), s ).Execute()
+
+
+//============================================================================
+// class ScSolverDlg
+//----------------------------------------------------------------------------
+
+ScSolverDlg::ScSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocument* pDocument,
+ ScAddress aCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_SOLVER ),
+ //
+ aFlVariables ( this, ScResId( FL_VARIABLES ) ),
+ aFtFormulaCell ( this, ScResId( FT_FORMULACELL ) ),
+ aEdFormulaCell ( this, ScResId( ED_FORMULACELL ) ),
+ aRBFormulaCell ( this, ScResId( RB_FORMULACELL ), &aEdFormulaCell, this ),
+ aFtTargetVal ( this, ScResId( FT_TARGETVAL ) ),
+ aEdTargetVal ( this, ScResId( ED_TARGETVAL ) ),
+ aFtVariableCell ( this, ScResId( FT_VARCELL ) ),
+ aEdVariableCell ( this, ScResId( ED_VARCELL ) ),
+ aRBVariableCell ( this, ScResId( RB_VARCELL ), &aEdVariableCell, this ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ theFormulaCell ( aCursorPos ),
+ theVariableCell ( aCursorPos ),
+ pDoc ( pDocument ),
+ nCurTab ( aCursorPos.Tab() ),
+ pEdActive ( NULL ),
+ bDlgLostFocus ( FALSE ),
+ errMsgInvalidVar ( ScResId( STR_INVALIDVAR ) ),
+ errMsgInvalidForm ( ScResId( STR_INVALIDFORM ) ),
+ errMsgNoFormula ( ScResId( STR_NOFORMULA ) ),
+ errMsgInvalidVal ( ScResId( STR_INVALIDVAL ) )
+{
+ Init();
+ FreeResource();
+}
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScSolverDlg::~ScSolverDlg()
+{
+}
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScSolverDlg::Init()
+{
+ String aStr;
+
+ aBtnOk. SetClickHdl ( LINK( this, ScSolverDlg, BtnHdl ) );
+ aBtnCancel. SetClickHdl ( LINK( this, ScSolverDlg, BtnHdl ) );
+
+ Link aLink = LINK( this, ScSolverDlg, GetFocusHdl );
+ aEdFormulaCell. SetGetFocusHdl ( aLink );
+ aRBFormulaCell. SetGetFocusHdl ( aLink );
+ aEdVariableCell.SetGetFocusHdl ( aLink );
+ aRBVariableCell.SetGetFocusHdl ( aLink );
+ aEdTargetVal. SetGetFocusHdl ( aLink );
+
+ aLink = LINK( this, ScSolverDlg, LoseFocusHdl );
+ aEdFormulaCell. SetLoseFocusHdl ( aLink );
+ aRBFormulaCell. SetLoseFocusHdl ( aLink );
+ aEdVariableCell.SetLoseFocusHdl ( aLink );
+ aRBVariableCell.SetLoseFocusHdl ( aLink );
+
+ theFormulaCell.Format( aStr, SCA_ABS, NULL, pDoc->GetAddressConvention() );
+
+ aEdFormulaCell.SetText( aStr );
+ aEdFormulaCell.GrabFocus();
+ pEdActive = &aEdFormulaCell;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScSolverDlg::Close()
+{
+ return DoClose( ScSolverDlgWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScSolverDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+ if( pEdActive )
+ pEdActive->GrabFocus();
+ }
+ else
+ {
+ GrabFocus();
+ }
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+
+void ScSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if( pEdActive )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(pEdActive);
+
+ String aStr;
+ ScAddress aAdr = rRef.aStart;
+ USHORT nFmt = ( aAdr.Tab() == nCurTab )
+ ? SCA_ABS
+ : SCA_ABS_3D;
+
+ aAdr.Format( aStr, nFmt, pDocP, pDocP->GetAddressConvention() );
+ pEdActive->SetRefString( aStr );
+
+ if ( pEdActive == &aEdFormulaCell )
+ theFormulaCell = aAdr;
+ else if ( pEdActive == &aEdVariableCell )
+ theVariableCell = aAdr;
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScSolverDlg::RaiseError( ScSolverErr eError )
+{
+ switch ( eError )
+ {
+ case SOLVERR_NOFORMULA:
+ ERRORBOX( errMsgNoFormula );
+ aEdFormulaCell.GrabFocus();
+ break;
+
+ case SOLVERR_INVALID_FORMULA:
+ ERRORBOX( errMsgInvalidForm );
+ aEdFormulaCell.GrabFocus();
+ break;
+
+ case SOLVERR_INVALID_VARIABLE:
+ ERRORBOX( errMsgInvalidVar );
+ aEdVariableCell.GrabFocus();
+ break;
+
+ case SOLVERR_INVALID_TARGETVALUE:
+ ERRORBOX( errMsgInvalidVal );
+ aEdTargetVal.GrabFocus();
+ break;
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScSolverDlg::IsRefInputMode() const
+{
+ return pEdActive != NULL;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScSolverDlg::CheckTargetValue( String& rStrVal )
+{
+ sal_uInt32 n1 = 0;
+ double n2;
+
+ return pDoc->GetFormatTable()->IsNumberFormat( rStrVal, n1, n2 );
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScSolverDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnOk )
+ {
+ theTargetValStr = aEdTargetVal.GetText();
+
+ // Zu ueberpruefen:
+ // 1. enthalten die Strings korrekte Tabellenkoordinaten/def.Namen?
+ // 2. verweist die Formel-Koordinate wirklich auf eine Formelzelle?
+ // 3. wurde ein korrekter Zielwert eingegeben
+
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ USHORT nRes1 = theFormulaCell .Parse( aEdFormulaCell.GetText(), pDoc, eConv );
+ USHORT nRes2 = theVariableCell.Parse( aEdVariableCell.GetText(), pDoc, eConv );
+
+ if ( SCA_VALID == ( nRes1 & SCA_VALID ) )
+ {
+ if ( SCA_VALID == ( nRes2 & SCA_VALID ) )
+ {
+ if ( CheckTargetValue( theTargetValStr ) )
+ {
+ CellType eType;
+ pDoc->GetCellType( theFormulaCell.Col(),
+ theFormulaCell.Row(),
+ theFormulaCell.Tab(),
+ eType );
+
+ if ( CELLTYPE_FORMULA == eType )
+ {
+ ScSolveParam aOutParam( theFormulaCell,
+ theVariableCell,
+ theTargetValStr );
+ ScSolveItem aOutItem( SCITEM_SOLVEDATA, &aOutParam );
+
+ SetDispatcherLock( FALSE );
+
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( SID_SOLVE,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aOutItem, 0L, 0L );
+ Close();
+ }
+ else RaiseError( SOLVERR_NOFORMULA );
+ }
+ else RaiseError( SOLVERR_INVALID_TARGETVALUE );
+ }
+ else RaiseError( SOLVERR_INVALID_VARIABLE );
+ }
+ else RaiseError( SOLVERR_INVALID_FORMULA );
+ }
+ else if ( pBtn == &aBtnCancel )
+ {
+ Close();
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScSolverDlg, GetFocusHdl, Control*, pCtrl )
+{
+ Edit* pEdit = NULL;
+ pEdActive = NULL;
+
+ if( (pCtrl == (Control*)&aEdFormulaCell) || (pCtrl == (Control*)&aRBFormulaCell) )
+ pEdit = pEdActive = &aEdFormulaCell;
+ else if( (pCtrl == (Control*)&aEdVariableCell) || (pCtrl == (Control*)&aRBVariableCell) )
+ pEdit = pEdActive = &aEdVariableCell;
+ else if( pCtrl == (Control*)&aEdTargetVal )
+ pEdit = &aEdTargetVal;
+
+ if( pEdit )
+ pEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScSolverDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ bDlgLostFocus = !IsActive();
+ return 0;
+}
+
+
+
+
diff --git a/sc/source/ui/miscdlgs/tabopdlg.cxx b/sc/source/ui/miscdlgs/tabopdlg.cxx index bb91e18c562a..f819579b7601 100644 --- a/sc/source/ui/miscdlgs/tabopdlg.cxx +++ b/sc/source/ui/miscdlgs/tabopdlg.cxx @@ -1,374 +1,374 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: tabopdlg.cxx,v $ - * $Revision: 1.12 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - - - -//---------------------------------------------------------------------------- - -#include "scitems.hxx" -#include <sfx2/dispatch.hxx> -#include <vcl/msgbox.hxx> - -#include "uiitems.hxx" -#include "global.hxx" -#include "document.hxx" -#include "scresid.hxx" -#include "sc.hrc" -#include "reffact.hxx" -#include "tabopdlg.hrc" - -#define _TABOPDLG_CXX -#include "tabopdlg.hxx" - - -//============================================================================ -// class ScTabOpDlg -//---------------------------------------------------------------------------- - -ScTabOpDlg::ScTabOpDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, - ScDocument* pDocument, - const ScRefAddress& rCursorPos ) - - : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_TABOP ), - // - aFlVariables ( this, ScResId( FL_VARIABLES ) ), - aFtFormulaRange ( this, ScResId( FT_FORMULARANGE ) ), - aEdFormulaRange ( this, ScResId( ED_FORMULARANGE ) ), - aRBFormulaRange ( this, ScResId( RB_FORMULARANGE ), &aEdFormulaRange ), - aFtRowCell ( this, ScResId( FT_ROWCELL ) ), - aEdRowCell ( this, ScResId( ED_ROWCELL ) ), - aRBRowCell ( this, ScResId( RB_ROWCELL ), &aEdRowCell ), - aFtColCell ( this, ScResId( FT_COLCELL ) ), - aEdColCell ( this, ScResId( ED_COLCELL ) ), - aRBColCell ( this, ScResId( RB_COLCELL ), &aEdColCell ), - aBtnOk ( this, ScResId( BTN_OK ) ), - aBtnCancel ( this, ScResId( BTN_CANCEL ) ), - aBtnHelp ( this, ScResId( BTN_HELP ) ), - // - theFormulaCell ( rCursorPos ), - pDoc ( pDocument ), - nCurTab ( theFormulaCell.Tab() ), - pEdActive ( NULL ), - bDlgLostFocus ( FALSE ), - errMsgNoFormula ( ScResId( STR_NOFORMULA ) ), - errMsgNoColRow ( ScResId( STR_NOCOLROW ) ), - errMsgWrongFormula ( ScResId( STR_WRONGFORMULA ) ), - errMsgWrongRowCol ( ScResId( STR_WRONGROWCOL ) ), - errMsgNoColFormula ( ScResId( STR_NOCOLFORMULA ) ), - errMsgNoRowFormula ( ScResId( STR_NOROWFORMULA ) ) -{ - Init(); - FreeResource(); -} - -//---------------------------------------------------------------------------- - -__EXPORT ScTabOpDlg::~ScTabOpDlg() -{ - Hide(); -} - -//---------------------------------------------------------------------------- - -void __EXPORT ScTabOpDlg::Init() -{ - aBtnOk. SetClickHdl ( LINK( this, ScTabOpDlg, BtnHdl ) ); - aBtnCancel. SetClickHdl ( LINK( this, ScTabOpDlg, BtnHdl ) ); - - Link aLink = LINK( this, ScTabOpDlg, GetFocusHdl ); - aEdFormulaRange.SetGetFocusHdl( aLink ); - aRBFormulaRange.SetGetFocusHdl( aLink ); - aEdRowCell. SetGetFocusHdl( aLink ); - aRBRowCell. SetGetFocusHdl( aLink ); - aEdColCell. SetGetFocusHdl( aLink ); - aRBColCell. SetGetFocusHdl( aLink ); - - aLink = LINK( this, ScTabOpDlg, LoseFocusHdl ); - aEdFormulaRange.SetLoseFocusHdl( aLink ); - aRBFormulaRange.SetLoseFocusHdl( aLink ); - aEdRowCell. SetLoseFocusHdl( aLink ); - aRBRowCell. SetLoseFocusHdl( aLink ); - aEdColCell. SetLoseFocusHdl( aLink ); - aRBColCell. SetLoseFocusHdl( aLink ); - - aEdFormulaRange.GrabFocus(); - pEdActive = &aEdFormulaRange; - - //@BugID 54702 Enablen/Disablen nur noch in Basisklasse - //SFX_APPWINDOW->Enable(); -} - -//---------------------------------------------------------------------------- - -BOOL __EXPORT ScTabOpDlg::Close() -{ - return DoClose( ScTabOpDlgWrapper::GetChildWindowId() ); -} - -//---------------------------------------------------------------------------- - -void ScTabOpDlg::SetActive() -{ - if ( bDlgLostFocus ) - { - bDlgLostFocus = FALSE; - if( pEdActive ) - pEdActive->GrabFocus(); - } - else - GrabFocus(); - - RefInputDone(); -} - -//---------------------------------------------------------------------------- - -void ScTabOpDlg::SetReference( const ScRange& rRef, ScDocument* pDocP ) -{ - if ( pEdActive ) - { - ScAddress::Details aDetails(pDocP->GetAddressConvention(), 0, 0); - - if ( rRef.aStart != rRef.aEnd ) - RefInputStart(pEdActive); - - String aStr; - USHORT nFmt = ( rRef.aStart.Tab() == nCurTab ) - ? SCR_ABS - : SCR_ABS_3D; - - if ( pEdActive == &aEdFormulaRange ) - { - theFormulaCell.Set( rRef.aStart, false, false, false); - theFormulaEnd.Set( rRef.aEnd, false, false, false); - rRef.Format( aStr, nFmt, pDocP, aDetails ); - } - else if ( pEdActive == &aEdRowCell ) - { - theRowCell.Set( rRef.aStart, false, false, false); - rRef.aStart.Format( aStr, nFmt, pDocP, aDetails ); - } - else if ( pEdActive == &aEdColCell ) - { - theColCell.Set( rRef.aStart, false, false, false); - rRef.aStart.Format( aStr, nFmt, pDocP, aDetails ); - } - - pEdActive->SetRefString( aStr ); - } -} - -//---------------------------------------------------------------------------- - -void ScTabOpDlg::RaiseError( ScTabOpErr eError ) -{ - const String* pMsg = &errMsgNoFormula; - Edit* pEd = &aEdFormulaRange; - - switch ( eError ) - { - case TABOPERR_NOFORMULA: - pMsg = &errMsgNoFormula; - pEd = &aEdFormulaRange; - break; - - case TABOPERR_NOCOLROW: - pMsg = &errMsgNoColRow; - pEd = &aEdRowCell; - break; - - case TABOPERR_WRONGFORMULA: - pMsg = &errMsgWrongFormula; - pEd = &aEdFormulaRange; - break; - - case TABOPERR_WRONGROW: - pMsg = &errMsgWrongRowCol; - pEd = &aEdRowCell; - break; - - case TABOPERR_NOCOLFORMULA: - pMsg = &errMsgNoColFormula; - pEd = &aEdFormulaRange; - break; - - case TABOPERR_WRONGCOL: - pMsg = &errMsgWrongRowCol; - pEd = &aEdColCell; - break; - - case TABOPERR_NOROWFORMULA: - pMsg = &errMsgNoRowFormula; - pEd = &aEdFormulaRange; - break; - } - - ErrorBox( this, WinBits( WB_OK_CANCEL | WB_DEF_OK), *pMsg ).Execute(); - pEd->GrabFocus(); -} - -//---------------------------------------------------------------------------- - -BOOL lcl_Parse( const String& rString, ScDocument* pDoc, SCTAB nCurTab, - ScRefAddress& rStart, ScRefAddress& rEnd ) -{ - BOOL bRet = FALSE; - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); - if ( rString.Search(':') != STRING_NOTFOUND ) - bRet = ConvertDoubleRef( pDoc, rString, nCurTab, rStart, rEnd, eConv ); - else - { - bRet = ConvertSingleRef( pDoc, rString, nCurTab, rStart, eConv ); - rEnd = rStart; - } - return bRet; -} - -//---------------------------------------------------------------------------- -// Handler: - -IMPL_LINK( ScTabOpDlg, BtnHdl, PushButton*, pBtn ) -{ - if ( pBtn == &aBtnOk ) - { - BYTE nMode = 3; - USHORT nError = 0; - - // Zu ueberpruefen: - // 1. enthalten die Strings korrekte Tabellenkoordinaten/def.Namen? - // 2. IstFormelRang Zeile bei leerer Zeile bzw. Spalte bei leerer Spalte - // bzw. Einfachreferenz bei beidem? - // 3. Ist mindestens Zeile oder Spalte und Formel voll? - - if (aEdFormulaRange.GetText().Len() == 0) - nError = TABOPERR_NOFORMULA; - else if (aEdRowCell.GetText().Len() == 0 && - aEdColCell.GetText().Len() == 0) - nError = TABOPERR_NOCOLROW; - else if ( !lcl_Parse( aEdFormulaRange.GetText(), pDoc, nCurTab, - theFormulaCell, theFormulaEnd ) ) - nError = TABOPERR_WRONGFORMULA; - else - { - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); - if (aEdRowCell.GetText().Len() > 0) - { - if (!ConvertSingleRef( pDoc, aEdRowCell.GetText(), nCurTab, - theRowCell, eConv )) - nError = TABOPERR_WRONGROW; - else - { - if (aEdColCell.GetText().Len() == 0 && - theFormulaCell.Col() != theFormulaEnd.Col()) - nError = TABOPERR_NOCOLFORMULA; - else - nMode = 1; - } - } - if (aEdColCell.GetText().Len() > 0) - { - if (!ConvertSingleRef( pDoc, aEdColCell.GetText(), nCurTab, - theColCell, eConv )) - nError = TABOPERR_WRONGCOL; - else - { - if (nMode == 1) // beides - { - nMode = 2; - ConvertSingleRef( pDoc, aEdFormulaRange.GetText(), nCurTab, - theFormulaCell, eConv ); - } - else if (theFormulaCell.Row() != theFormulaEnd.Row()) - nError = TABOPERR_NOROWFORMULA; - else - nMode = 0; - } - } - } - - if (nError) - RaiseError( (ScTabOpErr) nError ); - else - { - ScTabOpParam aOutParam( theFormulaCell, - theFormulaEnd, - theRowCell, - theColCell, - nMode ); - ScTabOpItem aOutItem( SID_TABOP, &aOutParam ); - - SetDispatcherLock( FALSE ); - SwitchToDocument(); - GetBindings().GetDispatcher()->Execute( SID_TABOP, - SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, - &aOutItem, 0L, 0L ); - Close(); - } - } - else if ( pBtn == &aBtnCancel ) - Close(); - - return 0; -} - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScTabOpDlg, GetFocusHdl, Control*, pCtrl ) -{ - if( (pCtrl == (Control*)&aEdFormulaRange) || (pCtrl == (Control*)&aRBFormulaRange) ) - pEdActive = &aEdFormulaRange; - else if( (pCtrl == (Control*)&aEdRowCell) || (pCtrl == (Control*)&aRBRowCell) ) - pEdActive = &aEdRowCell; - else if( (pCtrl == (Control*)&aEdColCell) || (pCtrl == (Control*)&aRBColCell) ) - pEdActive = &aEdColCell; - else - pEdActive = NULL; - - if( pEdActive ) - pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) ); - - return 0; -} - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScTabOpDlg, LoseFocusHdl, Control*, EMPTYARG ) -{ - bDlgLostFocus = !IsActive(); - return 0; -} - - - - - +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: tabopdlg.cxx,v $
+ * $Revision: 1.12 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <sfx2/dispatch.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "uiitems.hxx"
+#include "global.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "reffact.hxx"
+#include "tabopdlg.hrc"
+
+#define _TABOPDLG_CXX
+#include "tabopdlg.hxx"
+
+
+//============================================================================
+// class ScTabOpDlg
+//----------------------------------------------------------------------------
+
+ScTabOpDlg::ScTabOpDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocument* pDocument,
+ const ScRefAddress& rCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_TABOP ),
+ //
+ aFlVariables ( this, ScResId( FL_VARIABLES ) ),
+ aFtFormulaRange ( this, ScResId( FT_FORMULARANGE ) ),
+ aEdFormulaRange ( this, ScResId( ED_FORMULARANGE ) ),
+ aRBFormulaRange ( this, ScResId( RB_FORMULARANGE ), &aEdFormulaRange, this ),
+ aFtRowCell ( this, ScResId( FT_ROWCELL ) ),
+ aEdRowCell ( this, ScResId( ED_ROWCELL ) ),
+ aRBRowCell ( this, ScResId( RB_ROWCELL ), &aEdRowCell, this ),
+ aFtColCell ( this, ScResId( FT_COLCELL ) ),
+ aEdColCell ( this, ScResId( ED_COLCELL ) ),
+ aRBColCell ( this, ScResId( RB_COLCELL ), &aEdColCell, this ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ theFormulaCell ( rCursorPos ),
+ pDoc ( pDocument ),
+ nCurTab ( theFormulaCell.Tab() ),
+ pEdActive ( NULL ),
+ bDlgLostFocus ( FALSE ),
+ errMsgNoFormula ( ScResId( STR_NOFORMULA ) ),
+ errMsgNoColRow ( ScResId( STR_NOCOLROW ) ),
+ errMsgWrongFormula ( ScResId( STR_WRONGFORMULA ) ),
+ errMsgWrongRowCol ( ScResId( STR_WRONGROWCOL ) ),
+ errMsgNoColFormula ( ScResId( STR_NOCOLFORMULA ) ),
+ errMsgNoRowFormula ( ScResId( STR_NOROWFORMULA ) )
+{
+ Init();
+ FreeResource();
+}
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScTabOpDlg::~ScTabOpDlg()
+{
+ Hide();
+}
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScTabOpDlg::Init()
+{
+ aBtnOk. SetClickHdl ( LINK( this, ScTabOpDlg, BtnHdl ) );
+ aBtnCancel. SetClickHdl ( LINK( this, ScTabOpDlg, BtnHdl ) );
+
+ Link aLink = LINK( this, ScTabOpDlg, GetFocusHdl );
+ aEdFormulaRange.SetGetFocusHdl( aLink );
+ aRBFormulaRange.SetGetFocusHdl( aLink );
+ aEdRowCell. SetGetFocusHdl( aLink );
+ aRBRowCell. SetGetFocusHdl( aLink );
+ aEdColCell. SetGetFocusHdl( aLink );
+ aRBColCell. SetGetFocusHdl( aLink );
+
+ aLink = LINK( this, ScTabOpDlg, LoseFocusHdl );
+ aEdFormulaRange.SetLoseFocusHdl( aLink );
+ aRBFormulaRange.SetLoseFocusHdl( aLink );
+ aEdRowCell. SetLoseFocusHdl( aLink );
+ aRBRowCell. SetLoseFocusHdl( aLink );
+ aEdColCell. SetLoseFocusHdl( aLink );
+ aRBColCell. SetLoseFocusHdl( aLink );
+
+ aEdFormulaRange.GrabFocus();
+ pEdActive = &aEdFormulaRange;
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScTabOpDlg::Close()
+{
+ return DoClose( ScTabOpDlgWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScTabOpDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+ if( pEdActive )
+ pEdActive->GrabFocus();
+ }
+ else
+ GrabFocus();
+
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+
+void ScTabOpDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( pEdActive )
+ {
+ ScAddress::Details aDetails(pDocP->GetAddressConvention(), 0, 0);
+
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(pEdActive);
+
+ String aStr;
+ USHORT nFmt = ( rRef.aStart.Tab() == nCurTab )
+ ? SCR_ABS
+ : SCR_ABS_3D;
+
+ if ( pEdActive == &aEdFormulaRange )
+ {
+ theFormulaCell.Set( rRef.aStart, false, false, false);
+ theFormulaEnd.Set( rRef.aEnd, false, false, false);
+ rRef.Format( aStr, nFmt, pDocP, aDetails );
+ }
+ else if ( pEdActive == &aEdRowCell )
+ {
+ theRowCell.Set( rRef.aStart, false, false, false);
+ rRef.aStart.Format( aStr, nFmt, pDocP, aDetails );
+ }
+ else if ( pEdActive == &aEdColCell )
+ {
+ theColCell.Set( rRef.aStart, false, false, false);
+ rRef.aStart.Format( aStr, nFmt, pDocP, aDetails );
+ }
+
+ pEdActive->SetRefString( aStr );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScTabOpDlg::RaiseError( ScTabOpErr eError )
+{
+ const String* pMsg = &errMsgNoFormula;
+ Edit* pEd = &aEdFormulaRange;
+
+ switch ( eError )
+ {
+ case TABOPERR_NOFORMULA:
+ pMsg = &errMsgNoFormula;
+ pEd = &aEdFormulaRange;
+ break;
+
+ case TABOPERR_NOCOLROW:
+ pMsg = &errMsgNoColRow;
+ pEd = &aEdRowCell;
+ break;
+
+ case TABOPERR_WRONGFORMULA:
+ pMsg = &errMsgWrongFormula;
+ pEd = &aEdFormulaRange;
+ break;
+
+ case TABOPERR_WRONGROW:
+ pMsg = &errMsgWrongRowCol;
+ pEd = &aEdRowCell;
+ break;
+
+ case TABOPERR_NOCOLFORMULA:
+ pMsg = &errMsgNoColFormula;
+ pEd = &aEdFormulaRange;
+ break;
+
+ case TABOPERR_WRONGCOL:
+ pMsg = &errMsgWrongRowCol;
+ pEd = &aEdColCell;
+ break;
+
+ case TABOPERR_NOROWFORMULA:
+ pMsg = &errMsgNoRowFormula;
+ pEd = &aEdFormulaRange;
+ break;
+ }
+
+ ErrorBox( this, WinBits( WB_OK_CANCEL | WB_DEF_OK), *pMsg ).Execute();
+ pEd->GrabFocus();
+}
+
+//----------------------------------------------------------------------------
+
+BOOL lcl_Parse( const String& rString, ScDocument* pDoc, SCTAB nCurTab,
+ ScRefAddress& rStart, ScRefAddress& rEnd )
+{
+ BOOL bRet = FALSE;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ if ( rString.Search(':') != STRING_NOTFOUND )
+ bRet = ConvertDoubleRef( pDoc, rString, nCurTab, rStart, rEnd, eConv );
+ else
+ {
+ bRet = ConvertSingleRef( pDoc, rString, nCurTab, rStart, eConv );
+ rEnd = rStart;
+ }
+ return bRet;
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScTabOpDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnOk )
+ {
+ BYTE nMode = 3;
+ USHORT nError = 0;
+
+ // Zu ueberpruefen:
+ // 1. enthalten die Strings korrekte Tabellenkoordinaten/def.Namen?
+ // 2. IstFormelRang Zeile bei leerer Zeile bzw. Spalte bei leerer Spalte
+ // bzw. Einfachreferenz bei beidem?
+ // 3. Ist mindestens Zeile oder Spalte und Formel voll?
+
+ if (aEdFormulaRange.GetText().Len() == 0)
+ nError = TABOPERR_NOFORMULA;
+ else if (aEdRowCell.GetText().Len() == 0 &&
+ aEdColCell.GetText().Len() == 0)
+ nError = TABOPERR_NOCOLROW;
+ else if ( !lcl_Parse( aEdFormulaRange.GetText(), pDoc, nCurTab,
+ theFormulaCell, theFormulaEnd ) )
+ nError = TABOPERR_WRONGFORMULA;
+ else
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ if (aEdRowCell.GetText().Len() > 0)
+ {
+ if (!ConvertSingleRef( pDoc, aEdRowCell.GetText(), nCurTab,
+ theRowCell, eConv ))
+ nError = TABOPERR_WRONGROW;
+ else
+ {
+ if (aEdColCell.GetText().Len() == 0 &&
+ theFormulaCell.Col() != theFormulaEnd.Col())
+ nError = TABOPERR_NOCOLFORMULA;
+ else
+ nMode = 1;
+ }
+ }
+ if (aEdColCell.GetText().Len() > 0)
+ {
+ if (!ConvertSingleRef( pDoc, aEdColCell.GetText(), nCurTab,
+ theColCell, eConv ))
+ nError = TABOPERR_WRONGCOL;
+ else
+ {
+ if (nMode == 1) // beides
+ {
+ nMode = 2;
+ ConvertSingleRef( pDoc, aEdFormulaRange.GetText(), nCurTab,
+ theFormulaCell, eConv );
+ }
+ else if (theFormulaCell.Row() != theFormulaEnd.Row())
+ nError = TABOPERR_NOROWFORMULA;
+ else
+ nMode = 0;
+ }
+ }
+ }
+
+ if (nError)
+ RaiseError( (ScTabOpErr) nError );
+ else
+ {
+ ScTabOpParam aOutParam( theFormulaCell,
+ theFormulaEnd,
+ theRowCell,
+ theColCell,
+ nMode );
+ ScTabOpItem aOutItem( SID_TABOP, &aOutParam );
+
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( SID_TABOP,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aOutItem, 0L, 0L );
+ Close();
+ }
+ }
+ else if ( pBtn == &aBtnCancel )
+ Close();
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScTabOpDlg, GetFocusHdl, Control*, pCtrl )
+{
+ if( (pCtrl == (Control*)&aEdFormulaRange) || (pCtrl == (Control*)&aRBFormulaRange) )
+ pEdActive = &aEdFormulaRange;
+ else if( (pCtrl == (Control*)&aEdRowCell) || (pCtrl == (Control*)&aRBRowCell) )
+ pEdActive = &aEdRowCell;
+ else if( (pCtrl == (Control*)&aEdColCell) || (pCtrl == (Control*)&aRBColCell) )
+ pEdActive = &aEdColCell;
+ else
+ pEdActive = NULL;
+
+ if( pEdActive )
+ pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScTabOpDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ bDlgLostFocus = !IsActive();
+ return 0;
+}
+
+
+
+
+
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx index f97d1a7acd99..0709a84ad085 100644 --- a/sc/source/ui/namedlg/namedlg.cxx +++ b/sc/source/ui/namedlg/namedlg.cxx @@ -1,650 +1,652 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: namedlg.cxx,v $ - * $Revision: 1.11 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - -// System - Includes --------------------------------------------------------- - - - -// INCLUDE ------------------------------------------------------------------- - -#include "global.hxx" -#include "reffact.hxx" -#include "document.hxx" -#include "docfunc.hxx" -#include "scresid.hxx" -#include "globstr.hrc" -#include "namedlg.hrc" - -#define _NAMEDLG_CXX -#include "namedlg.hxx" -#undef _NAMEDLG_CXX -#include <vcl/msgbox.hxx> - - - -// defines ------------------------------------------------------------------- - -#define ABS_SREF SCA_VALID \ - | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE -#define ABS_DREF ABS_SREF \ - | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE -#define ABS_SREF3D ABS_SREF | SCA_TAB_3D -#define ABS_DREF3D ABS_DREF | SCA_TAB_3D - - -//============================================================================ -// Hilfsklasse: Merken der aktuellen Bereichsoptionen, -// wenn ein Name in der ComboBox gefunden wird. - -struct SaveData -{ - SaveData() - : bCriteria(FALSE),bPrintArea(FALSE), - bColHeader(FALSE),bRowHeader(FALSE), - bDirty(FALSE) {} - - void Clear() - { - aStrSymbol.Erase(); - bCriteria = bPrintArea = - bColHeader = bRowHeader = FALSE; - bDirty = TRUE; - } - - String aStrSymbol; - BOOL bCriteria:1; - BOOL bPrintArea:1; - BOOL bColHeader:1; - BOOL bRowHeader:1; - BOOL bDirty:1; -}; - -static SaveData* pSaveObj = NULL; - -#define SAVE_DATA() \ - pSaveObj->aStrSymbol = aEdAssign.GetText(); \ - pSaveObj->bCriteria = aBtnCriteria.IsChecked(); \ - pSaveObj->bPrintArea = aBtnPrintArea.IsChecked(); \ - pSaveObj->bColHeader = aBtnColHeader.IsChecked(); \ - pSaveObj->bRowHeader = aBtnRowHeader.IsChecked(); \ - pSaveObj->bDirty = TRUE; - -#define RESTORE_DATA() \ - if ( pSaveObj->bDirty ) \ - { \ - aEdAssign.SetText( pSaveObj->aStrSymbol ); \ - aBtnCriteria.Check( pSaveObj->bCriteria ); \ - aBtnPrintArea.Check( pSaveObj->bPrintArea ); \ - aBtnColHeader.Check( pSaveObj->bColHeader ); \ - aBtnRowHeader.Check( pSaveObj->bRowHeader ); \ - pSaveObj->bDirty = FALSE; \ - } - -#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute(); - - -//============================================================================ -// class ScNameDlg - -//---------------------------------------------------------------------------- - -ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, - ScViewData* ptrViewData, - const ScAddress& aCursorPos ) - - : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_NAMES ), - // - aFlName ( this, ScResId( FL_NAME ) ), - aEdName ( this, ScResId( ED_NAME ) ), - // - aFlAssign ( this, ScResId( FL_ASSIGN ) ), - aEdAssign ( this, ScResId( ED_ASSIGN ) ), - aRbAssign ( this, ScResId( RB_ASSIGN ), &aEdAssign ), - // - aFlType ( this, ScResId( FL_TYPE ) ), - aBtnPrintArea ( this, ScResId( BTN_PRINTAREA ) ), - aBtnColHeader ( this, ScResId( BTN_COLHEADER ) ), - aBtnCriteria ( this, ScResId( BTN_CRITERIA ) ), - aBtnRowHeader ( this, ScResId( BTN_ROWHEADER ) ), - // - aBtnOk ( this, ScResId( BTN_OK ) ), - aBtnCancel ( this, ScResId( BTN_CANCEL ) ), - aBtnHelp ( this, ScResId( BTN_HELP ) ), - aBtnAdd ( this, ScResId( BTN_ADD ) ), - aBtnRemove ( this, ScResId( BTN_REMOVE ) ), - aBtnMore ( this, ScResId( BTN_MORE ) ), - // - bSaved (FALSE), - aStrAdd ( ScResId( STR_ADD ) ), - aStrModify ( ScResId( STR_MODIFY ) ), - errMsgInvalidSym( ScResId( STR_INVALIDSYMBOL ) ), - // - pViewData ( ptrViewData ), - pDoc ( ptrViewData->GetDocument() ), - aLocalRangeName ( *(pDoc->GetRangeName()) ), - theCursorPos ( aCursorPos ) // zum Berechnen der Referenzen -{ - pSaveObj = new SaveData; - Init(); - FreeResource(); -} - - -//---------------------------------------------------------------------------- - -__EXPORT ScNameDlg::~ScNameDlg() -{ - DELETEZ( pSaveObj ); -} - - -//---------------------------------------------------------------------------- - -void __EXPORT ScNameDlg::Init() -{ - String aAreaStr; - ScRange aRange; - - DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" ); - - aBtnOk.SetClickHdl ( LINK( this, ScNameDlg, OkBtnHdl ) ); - aBtnCancel.SetClickHdl ( LINK( this, ScNameDlg, CancelBtnHdl ) ); - aBtnAdd.SetClickHdl ( LINK( this, ScNameDlg, AddBtnHdl ) ); - aBtnRemove.SetClickHdl ( LINK( this, ScNameDlg, RemoveBtnHdl ) ); - aEdAssign.SetGetFocusHdl( LINK( this, ScNameDlg, AssignGetFocusHdl ) ); - aEdAssign.SetModifyHdl ( LINK( this, ScNameDlg, EdModifyHdl ) ); - aEdName.SetModifyHdl ( LINK( this, ScNameDlg, EdModifyHdl ) ); - aEdName.SetSelectHdl ( LINK( this, ScNameDlg, NameSelectHdl ) ); - - aBtnCriteria .Hide(); - aBtnPrintArea.Hide(); - aBtnColHeader.Hide(); - aBtnRowHeader.Hide(); - - aBtnMore.AddWindow( &aFlType ); - aBtnMore.AddWindow( &aBtnCriteria ); - aBtnMore.AddWindow( &aBtnPrintArea ); - aBtnMore.AddWindow( &aBtnColHeader ); - aBtnMore.AddWindow( &aBtnRowHeader ); - - UpdateNames(); - - pViewData->GetSimpleArea( aRange ); - aRange.Format( aAreaStr, ABS_DREF3D, pDoc, - ScAddress::Details(pDoc->GetAddressConvention(), 0, 0) ); - - theCurSel = Selection( 0, SELECTION_MAX ); - aEdAssign.GrabFocus(); - aEdAssign.SetText( aAreaStr ); - aEdAssign.SetSelection( theCurSel ); - aEdName.GrabFocus(); - - aBtnAdd.Disable(); - aBtnRemove.Disable(); - if ( aEdName.GetEntryCount() > 0 ) - aBtnAdd.SetText( aStrAdd ); - UpdateChecks(); - EdModifyHdl( 0 ); - - bSaved=TRUE; - SAVE_DATA() - - //@BugID 54702 - //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg -} - -//---------------------------------------------------------------------------- -BOOL ScNameDlg::IsRefInputMode() const -{ - return aEdAssign.IsEnabled(); -} - -void ScNameDlg::RefInputDone( BOOL bForced) -{ - ScAnyRefDlg::RefInputDone(bForced); - EdModifyHdl(&aEdAssign); -} -//---------------------------------------------------------------------------- -// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als -// neue Selektion im Referenz-Edit angezeigt wird. - - -void ScNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP ) -{ - if ( aEdAssign.IsEnabled() ) - { - if ( rRef.aStart != rRef.aEnd ) - RefInputStart(&aEdAssign); - String aRefStr; - rRef.Format( aRefStr, ABS_DREF3D, pDocP, - ScAddress::Details(pDocP->GetAddressConvention(), 0, 0) ); - aEdAssign.SetRefString( aRefStr ); - } -} - - -//---------------------------------------------------------------------------- -BOOL __EXPORT ScNameDlg::Close() -{ - return DoClose( ScNameDlgWrapper::GetChildWindowId() ); -} - - -//---------------------------------------------------------------------------- - -void ScNameDlg::SetActive() -{ - aEdAssign.GrabFocus(); - RefInputDone(); -} - - -//---------------------------------------------------------------------------- - -void __EXPORT ScNameDlg::UpdateChecks() -{ - USHORT nCurPos=0; - - if(aLocalRangeName.SearchName( aEdName.GetText(), nCurPos)) - { - ScRangeData* pData=(ScRangeData*)(aLocalRangeName.At( nCurPos )); - aBtnCriteria .Check( pData->HasType( RT_CRITERIA ) ); - aBtnPrintArea.Check( pData->HasType( RT_PRINTAREA ) ); - aBtnColHeader.Check( pData->HasType( RT_COLHEADER ) ); - aBtnRowHeader.Check( pData->HasType( RT_ROWHEADER ) ); - } - - // Falls Edit-Feld leer ist: Typ-CheckBoxen deaktivieren: - - if ( aEdName.GetText().Len() != 0 ) - { - if ( !aFlType.IsEnabled() ) - { - aFlType .Enable(); - aBtnCriteria .Enable(); - aBtnPrintArea.Enable(); - aBtnColHeader.Enable(); - aBtnRowHeader.Enable(); - aFlAssign .Enable(); - aEdAssign .Enable(); - aRbAssign .Enable(); - } - } - else if ( aFlType.IsEnabled() ) - { - aFlType .Disable(); - aBtnCriteria .Disable(); - aBtnPrintArea.Disable(); - aBtnColHeader.Disable(); - aBtnRowHeader.Disable(); - aFlAssign .Disable(); - aEdAssign .Disable(); - aRbAssign .Disable(); - } -} - - -//---------------------------------------------------------------------------- - -void __EXPORT ScNameDlg::UpdateNames() -{ - USHORT nRangeCount = aLocalRangeName.GetCount(); - - aEdName.SetUpdateMode( FALSE ); - //----------------------------------------------------------- - USHORT nNamePos = aEdName.GetTopEntry(); - aEdName.Clear(); - - aEdAssign.SetText( EMPTY_STRING ); - - if ( nRangeCount > 0 ) - { - ScRangeData* pRangeData = NULL; - String aString; - - for ( USHORT i=0; i<nRangeCount; i++ ) - { - pRangeData = (ScRangeData*)(aLocalRangeName.At( i )); - if ( pRangeData ) - { - if ( !pRangeData->HasType( RT_DATABASE ) - && !pRangeData->HasType( RT_SHARED ) ) - { - pRangeData->GetName( aString ); - aEdName.InsertEntry( aString ); - } - } - } - } - else - { - aBtnAdd.SetText( aStrAdd ); - aBtnAdd.Disable(); - aBtnRemove.Disable(); - } - //----------------------------------------------------------- - aEdName.SetUpdateMode( TRUE ); - aEdName.SetTopEntry(nNamePos); - aEdName.Invalidate(); -} - - -//---------------------------------------------------------------------------- - -void __EXPORT ScNameDlg::CalcCurTableAssign( String& aAssign, USHORT nCurPos ) -{ - ScRangeData* pRangeData = (ScRangeData*)(aLocalRangeName.At( nCurPos )); - - if ( pRangeData ) - { - pRangeData->UpdateSymbol( aAssign, theCursorPos ); - } - else - { - aAssign.Erase(); - } -} - - -//---------------------------------------------------------------------------- -// Handler: -// ======== - -IMPL_LINK( ScNameDlg, OkBtnHdl, void *, EMPTYARG ) -{ - if ( aBtnAdd.IsEnabled() ) - AddBtnHdl( 0 ); - - if ( !aBtnAdd.IsEnabled() && !aBtnRemove.IsEnabled() ) - { - ScDocShell* pDocSh = pViewData->GetDocShell(); - ScDocFunc aFunc(*pDocSh); - aFunc.ModifyRangeNames( aLocalRangeName, FALSE ); - Close(); - } - return 0; -} - - -//---------------------------------------------------------------------------- - -IMPL_LINK_INLINE_START( ScNameDlg, CancelBtnHdl, void *, EMPTYARG ) -{ - Close(); - return 0; -} -IMPL_LINK_INLINE_END( ScNameDlg, CancelBtnHdl, void *, EMPTYARG ) - - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScNameDlg, AddBtnHdl, void *, EMPTYARG ) -{ - BOOL bAdded = FALSE; - String aNewEntry = aEdName.GetText(); - USHORT nNamePos = aEdName.GetTopEntry(); - aNewEntry.EraseLeadingChars( ' ' ); - aNewEntry.EraseTrailingChars( ' ' ); - - if ( aNewEntry.Len() > 0 ) - { - if ( ScRangeData::IsNameValid( aNewEntry, pDoc ) ) - { - if ( pDoc ) - { - ScRangeData* pNewEntry = NULL; - RangeType nType = RT_NAME; - USHORT nFoundAt = 0; - String theSymbol = aEdAssign.GetText(); - String aStrPos; - String aStrArea; - - pNewEntry = new ScRangeData( pDoc, - aNewEntry, - theSymbol, - theCursorPos, - nType ); - if (pNewEntry) - { - nType = nType - | (aBtnRowHeader .IsChecked() ? RT_ROWHEADER : RangeType(0)) - | (aBtnColHeader .IsChecked() ? RT_COLHEADER : RangeType(0)) - | (aBtnPrintArea .IsChecked() ? RT_PRINTAREA : RangeType(0)) - | (aBtnCriteria .IsChecked() ? RT_CRITERIA : RangeType(0)); - pNewEntry->AddType(nType); - } - - // theSymbol gueltig? - // (= konnte theSymbol im ScRangeData-Ctor - // in ein Token-Array uebersetzt werden?) - if ( 0 == pNewEntry->GetErrCode() ) - { - // Eintrag bereits vorhanden? Dann vorher entfernen (=Aendern) - if ( aLocalRangeName.SearchName( aNewEntry, nFoundAt ) ) - { // alten Index uebernehmen - pNewEntry->SetIndex( - ((ScRangeData*)(aLocalRangeName.At(nFoundAt)))->GetIndex() ); - aLocalRangeName.AtFree( nFoundAt ); - } - else - pSaveObj->Clear(); - - if ( !aLocalRangeName.Insert( pNewEntry ) ) - delete pNewEntry; - - UpdateNames(); - bSaved=FALSE; - RESTORE_DATA() - aEdName.SetText(EMPTY_STRING); - aEdName.GrabFocus(); - UpdateChecks(); - aBtnAdd.SetText( aStrAdd ); - aBtnAdd.Disable(); - aBtnRemove.Disable(); - - //@BugID 54702 raus mit dem Sch. - //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg - - bAdded = TRUE; - } - else // theSymbol ungueltig - { - delete pNewEntry; - ERRORBOX( errMsgInvalidSym ); - theCurSel = Selection( 0, SELECTION_MAX ); - aEdAssign.GrabFocus(); - } - } - } - else - { - ERRORBOX( ScGlobal::GetRscString(STR_INVALIDNAME) ); - aEdName.SetSelection( Selection( 0, SELECTION_MAX ) ); - aEdName.GrabFocus(); - } - } - - aEdName.SetTopEntry(nNamePos); - return bAdded; -} - - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScNameDlg, RemoveBtnHdl, void *, EMPTYARG ) -{ - USHORT nRemoveAt = 0; - const String aStrEntry = aEdName.GetText(); - - if ( aLocalRangeName.SearchName( aStrEntry, nRemoveAt ) ) - { - String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY ); - String aMsg = aStrDelMsg.GetToken( 0, '#' ); - - aMsg += aStrEntry; - aMsg += aStrDelMsg.GetToken( 1, '#' ); - - if ( RET_YES == - QueryBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), aMsg ).Execute() ) - { - aLocalRangeName.AtFree( nRemoveAt ); - UpdateNames(); - UpdateChecks(); - bSaved=FALSE; - RESTORE_DATA() - theCurSel = Selection( 0, SELECTION_MAX ); - aBtnAdd.SetText( aStrAdd ); - aBtnAdd.Disable(); - aBtnRemove.Disable(); - } - } - return 0; -} - - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScNameDlg, NameSelectHdl, void *, EMPTYARG ) -{ - USHORT nAtPos; - - if ( aLocalRangeName.SearchName( aEdName.GetText(), nAtPos ) ) - { - String aSymbol; - ScRangeData* pData = (ScRangeData*)(aLocalRangeName.At( nAtPos )); - - if ( pData ) - { - pData->GetSymbol( aSymbol ); - CalcCurTableAssign( aSymbol, nAtPos ); - aEdAssign.SetText( aSymbol ); - aBtnAdd.SetText( aStrModify ); - theCurSel = Selection( 0, SELECTION_MAX ); - } - } - UpdateChecks(); - return 0; -} - - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScNameDlg, EdModifyHdl, Edit *, pEd ) -{ - String theName = aEdName.GetText(); - String theSymbol = aEdAssign.GetText(); - BOOL bNameFound = (COMBOBOX_ENTRY_NOTFOUND - != aEdName.GetEntryPos( theName )); - - if ( pEd == &aEdName ) - { - if ( theName.Len() == 0 ) - { - if ( aBtnAdd.GetText() != aStrAdd ) - aBtnAdd.SetText( aStrAdd ); - aBtnAdd.Disable(); - aBtnRemove.Disable(); - aFlAssign.Disable(); - aEdAssign.Disable(); - aRbAssign.Disable(); - //@BugID 54702 raus mit dem Sch. - //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg - } - else - { - if ( bNameFound ) - { - if ( aBtnAdd.GetText() != aStrModify ) - aBtnAdd.SetText( aStrModify ); - - aBtnRemove.Enable(); - - if(!bSaved) - { - bSaved=TRUE; - SAVE_DATA() - } - NameSelectHdl( 0 ); - } - else - { - if ( aBtnAdd.GetText() != aStrAdd ) - aBtnAdd.SetText( aStrAdd ); - aBtnRemove.Disable(); - - bSaved=FALSE; - RESTORE_DATA() - } - theSymbol = aEdAssign.GetText(); - - if ( theSymbol.Len() > 0 ) - aBtnAdd.Enable(); - else - aBtnAdd.Disable(); - - aFlAssign.Enable(); - aEdAssign.Enable(); - aRbAssign.Enable(); - //@BugID 54702 raus mit dem Sch. - //SFX_APPWINDOW->Enable(); - } - UpdateChecks(); - theCurSel = Selection( 0, SELECTION_MAX ); - } - else if ( pEd == &aEdAssign ) - { - if ( (theName.Len()>0) && (theSymbol.Len()>0) ) - { - aBtnAdd.Enable(); - if ( bNameFound ) - aBtnRemove.Enable(); - } - else - { - aBtnAdd.Disable(); - aBtnRemove.Disable(); - } - } - return 0; -} - -//------------------------------------------------------------------------ - -IMPL_LINK_INLINE_START( ScNameDlg, AssignGetFocusHdl, void *, EMPTYARG ) -{ - EdModifyHdl( &aEdAssign ); - return 0; -} -IMPL_LINK_INLINE_END( ScNameDlg, AssignGetFocusHdl, void *, EMPTYARG ) - - +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: namedlg.cxx,v $
+ * $Revision: 1.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "global.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "docfunc.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "namedlg.hrc"
+
+#define _NAMEDLG_CXX
+#include "namedlg.hxx"
+#undef _NAMEDLG_CXX
+#include <vcl/msgbox.hxx>
+
+
+
+// defines -------------------------------------------------------------------
+
+#define ABS_SREF SCA_VALID \
+ | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
+#define ABS_DREF ABS_SREF \
+ | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
+#define ABS_SREF3D ABS_SREF | SCA_TAB_3D
+#define ABS_DREF3D ABS_DREF | SCA_TAB_3D
+
+
+//============================================================================
+// Hilfsklasse: Merken der aktuellen Bereichsoptionen,
+// wenn ein Name in der ComboBox gefunden wird.
+
+struct SaveData
+{
+ SaveData()
+ : bCriteria(FALSE),bPrintArea(FALSE),
+ bColHeader(FALSE),bRowHeader(FALSE),
+ bDirty(FALSE) {}
+
+ void Clear()
+ {
+ aStrSymbol.Erase();
+ bCriteria = bPrintArea =
+ bColHeader = bRowHeader = FALSE;
+ bDirty = TRUE;
+ }
+
+ String aStrSymbol;
+ BOOL bCriteria:1;
+ BOOL bPrintArea:1;
+ BOOL bColHeader:1;
+ BOOL bRowHeader:1;
+ BOOL bDirty:1;
+};
+
+static SaveData* pSaveObj = NULL;
+
+#define SAVE_DATA() \
+ pSaveObj->aStrSymbol = aEdAssign.GetText(); \
+ pSaveObj->bCriteria = aBtnCriteria.IsChecked(); \
+ pSaveObj->bPrintArea = aBtnPrintArea.IsChecked(); \
+ pSaveObj->bColHeader = aBtnColHeader.IsChecked(); \
+ pSaveObj->bRowHeader = aBtnRowHeader.IsChecked(); \
+ pSaveObj->bDirty = TRUE;
+
+#define RESTORE_DATA() \
+ if ( pSaveObj->bDirty ) \
+ { \
+ aEdAssign.SetText( pSaveObj->aStrSymbol ); \
+ aBtnCriteria.Check( pSaveObj->bCriteria ); \
+ aBtnPrintArea.Check( pSaveObj->bPrintArea ); \
+ aBtnColHeader.Check( pSaveObj->bColHeader ); \
+ aBtnRowHeader.Check( pSaveObj->bRowHeader ); \
+ pSaveObj->bDirty = FALSE; \
+ }
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute();
+
+
+//============================================================================
+// class ScNameDlg
+
+//----------------------------------------------------------------------------
+
+ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData,
+ const ScAddress& aCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_NAMES ),
+ //
+ aFlName ( this, ScResId( FL_NAME ) ),
+ aEdName ( this, ScResId( ED_NAME ) ),
+ //
+ aFlAssign ( this, ScResId( FL_ASSIGN ) ),
+ aEdAssign ( this, ScResId( ED_ASSIGN ) ),
+ aRbAssign ( this, ScResId( RB_ASSIGN ), &aEdAssign, this ),
+ //
+ aFlType ( this, ScResId( FL_TYPE ) ),
+ aBtnPrintArea ( this, ScResId( BTN_PRINTAREA ) ),
+ aBtnColHeader ( this, ScResId( BTN_COLHEADER ) ),
+ aBtnCriteria ( this, ScResId( BTN_CRITERIA ) ),
+ aBtnRowHeader ( this, ScResId( BTN_ROWHEADER ) ),
+ //
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnAdd ( this, ScResId( BTN_ADD ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+ //
+ bSaved (FALSE),
+ aStrAdd ( ScResId( STR_ADD ) ),
+ aStrModify ( ScResId( STR_MODIFY ) ),
+ errMsgInvalidSym( ScResId( STR_INVALIDSYMBOL ) ),
+ //
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+ aLocalRangeName ( *(pDoc->GetRangeName()) ),
+ theCursorPos ( aCursorPos ) // zum Berechnen der Referenzen
+{
+ pSaveObj = new SaveData;
+ Init();
+ FreeResource();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScNameDlg::~ScNameDlg()
+{
+ DELETEZ( pSaveObj );
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScNameDlg::Init()
+{
+ String aAreaStr;
+ ScRange aRange;
+
+ DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
+
+ aBtnOk.SetClickHdl ( LINK( this, ScNameDlg, OkBtnHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScNameDlg, CancelBtnHdl ) );
+ aBtnAdd.SetClickHdl ( LINK( this, ScNameDlg, AddBtnHdl ) );
+ aBtnRemove.SetClickHdl ( LINK( this, ScNameDlg, RemoveBtnHdl ) );
+ aEdAssign.SetGetFocusHdl( LINK( this, ScNameDlg, AssignGetFocusHdl ) );
+ aEdAssign.SetModifyHdl ( LINK( this, ScNameDlg, EdModifyHdl ) );
+ aEdName.SetModifyHdl ( LINK( this, ScNameDlg, EdModifyHdl ) );
+ aEdName.SetSelectHdl ( LINK( this, ScNameDlg, NameSelectHdl ) );
+
+ aBtnCriteria .Hide();
+ aBtnPrintArea.Hide();
+ aBtnColHeader.Hide();
+ aBtnRowHeader.Hide();
+
+ aBtnMore.AddWindow( &aFlType );
+ aBtnMore.AddWindow( &aBtnCriteria );
+ aBtnMore.AddWindow( &aBtnPrintArea );
+ aBtnMore.AddWindow( &aBtnColHeader );
+ aBtnMore.AddWindow( &aBtnRowHeader );
+
+ UpdateNames();
+
+ pViewData->GetSimpleArea( aRange );
+ aRange.Format( aAreaStr, ABS_DREF3D, pDoc,
+ ScAddress::Details(pDoc->GetAddressConvention(), 0, 0) );
+
+ theCurSel = Selection( 0, SELECTION_MAX );
+ aEdAssign.GrabFocus();
+ aEdAssign.SetText( aAreaStr );
+ aEdAssign.SetSelection( theCurSel );
+ aEdName.GrabFocus();
+
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ if ( aEdName.GetEntryCount() > 0 )
+ aBtnAdd.SetText( aStrAdd );
+ UpdateChecks();
+ EdModifyHdl( 0 );
+
+ bSaved=TRUE;
+ SAVE_DATA()
+
+ //@BugID 54702
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+}
+
+//----------------------------------------------------------------------------
+BOOL ScNameDlg::IsRefInputMode() const
+{
+ return aEdAssign.IsEnabled();
+}
+
+void ScNameDlg::RefInputDone( BOOL bForced)
+{
+ ScAnyRefDlg::RefInputDone(bForced);
+ EdModifyHdl(&aEdAssign);
+}
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Edit angezeigt wird.
+
+
+void ScNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( aEdAssign.IsEnabled() )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(&aEdAssign);
+ String aRefStr;
+ rRef.Format( aRefStr, ABS_DREF3D, pDocP,
+ ScAddress::Details(pDocP->GetAddressConvention(), 0, 0) );
+ aEdAssign.SetRefString( aRefStr );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+BOOL __EXPORT ScNameDlg::Close()
+{
+ return DoClose( ScNameDlgWrapper::GetChildWindowId() );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScNameDlg::SetActive()
+{
+ aEdAssign.GrabFocus();
+ RefInputDone();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScNameDlg::UpdateChecks()
+{
+ USHORT nCurPos=0;
+
+ if(aLocalRangeName.SearchName( aEdName.GetText(), nCurPos))
+ {
+ ScRangeData* pData=(ScRangeData*)(aLocalRangeName.At( nCurPos ));
+ aBtnCriteria .Check( pData->HasType( RT_CRITERIA ) );
+ aBtnPrintArea.Check( pData->HasType( RT_PRINTAREA ) );
+ aBtnColHeader.Check( pData->HasType( RT_COLHEADER ) );
+ aBtnRowHeader.Check( pData->HasType( RT_ROWHEADER ) );
+ }
+
+ // Falls Edit-Feld leer ist: Typ-CheckBoxen deaktivieren:
+
+ if ( aEdName.GetText().Len() != 0 )
+ {
+ if ( !aFlType.IsEnabled() )
+ {
+ aFlType .Enable();
+ aBtnCriteria .Enable();
+ aBtnPrintArea.Enable();
+ aBtnColHeader.Enable();
+ aBtnRowHeader.Enable();
+ aFlAssign .Enable();
+ aEdAssign .Enable();
+ aRbAssign .Enable();
+ }
+ }
+ else if ( aFlType.IsEnabled() )
+ {
+ aFlType .Disable();
+ aBtnCriteria .Disable();
+ aBtnPrintArea.Disable();
+ aBtnColHeader.Disable();
+ aBtnRowHeader.Disable();
+ aFlAssign .Disable();
+ aEdAssign .Disable();
+ aRbAssign .Disable();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScNameDlg::UpdateNames()
+{
+ USHORT nRangeCount = aLocalRangeName.GetCount();
+
+ aEdName.SetUpdateMode( FALSE );
+ //-----------------------------------------------------------
+ USHORT nNamePos = aEdName.GetTopEntry();
+ aEdName.Clear();
+
+ aEdAssign.SetText( EMPTY_STRING );
+
+ if ( nRangeCount > 0 )
+ {
+ ScRangeData* pRangeData = NULL;
+ String aString;
+
+ for ( USHORT i=0; i<nRangeCount; i++ )
+ {
+ pRangeData = (ScRangeData*)(aLocalRangeName.At( i ));
+ if ( pRangeData )
+ {
+ if ( !pRangeData->HasType( RT_DATABASE )
+ && !pRangeData->HasType( RT_SHARED ) )
+ {
+ pRangeData->GetName( aString );
+ aEdName.InsertEntry( aString );
+ }
+ }
+ }
+ }
+ else
+ {
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ }
+ //-----------------------------------------------------------
+ aEdName.SetUpdateMode( TRUE );
+ aEdName.SetTopEntry(nNamePos);
+ aEdName.Invalidate();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScNameDlg::CalcCurTableAssign( String& aAssign, USHORT nCurPos )
+{
+ ScRangeData* pRangeData = (ScRangeData*)(aLocalRangeName.At( nCurPos ));
+
+ if ( pRangeData )
+ {
+ rtl::OUStringBuffer sBuffer;
+ pRangeData->UpdateSymbol( sBuffer, theCursorPos );
+ aAssign = sBuffer;
+ }
+ else
+ {
+ aAssign.Erase();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+// ========
+
+IMPL_LINK( ScNameDlg, OkBtnHdl, void *, EMPTYARG )
+{
+ if ( aBtnAdd.IsEnabled() )
+ AddBtnHdl( 0 );
+
+ if ( !aBtnAdd.IsEnabled() && !aBtnRemove.IsEnabled() )
+ {
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.ModifyRangeNames( aLocalRangeName, FALSE );
+ Close();
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScNameDlg, CancelBtnHdl, void *, EMPTYARG )
+{
+ Close();
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScNameDlg, CancelBtnHdl, void *, EMPTYARG )
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScNameDlg, AddBtnHdl, void *, EMPTYARG )
+{
+ BOOL bAdded = FALSE;
+ String aNewEntry = aEdName.GetText();
+ USHORT nNamePos = aEdName.GetTopEntry();
+ aNewEntry.EraseLeadingChars( ' ' );
+ aNewEntry.EraseTrailingChars( ' ' );
+
+ if ( aNewEntry.Len() > 0 )
+ {
+ if ( ScRangeData::IsNameValid( aNewEntry, pDoc ) )
+ {
+ if ( pDoc )
+ {
+ ScRangeData* pNewEntry = NULL;
+ RangeType nType = RT_NAME;
+ USHORT nFoundAt = 0;
+ String theSymbol = aEdAssign.GetText();
+ String aStrPos;
+ String aStrArea;
+
+ pNewEntry = new ScRangeData( pDoc,
+ aNewEntry,
+ theSymbol,
+ theCursorPos,
+ nType );
+ if (pNewEntry)
+ {
+ nType = nType
+ | (aBtnRowHeader .IsChecked() ? RT_ROWHEADER : RangeType(0))
+ | (aBtnColHeader .IsChecked() ? RT_COLHEADER : RangeType(0))
+ | (aBtnPrintArea .IsChecked() ? RT_PRINTAREA : RangeType(0))
+ | (aBtnCriteria .IsChecked() ? RT_CRITERIA : RangeType(0));
+ pNewEntry->AddType(nType);
+ }
+
+ // theSymbol gueltig?
+ // (= konnte theSymbol im ScRangeData-Ctor
+ // in ein Token-Array uebersetzt werden?)
+ if ( 0 == pNewEntry->GetErrCode() )
+ {
+ // Eintrag bereits vorhanden? Dann vorher entfernen (=Aendern)
+ if ( aLocalRangeName.SearchName( aNewEntry, nFoundAt ) )
+ { // alten Index uebernehmen
+ pNewEntry->SetIndex(
+ ((ScRangeData*)(aLocalRangeName.At(nFoundAt)))->GetIndex() );
+ aLocalRangeName.AtFree( nFoundAt );
+ }
+ else
+ pSaveObj->Clear();
+
+ if ( !aLocalRangeName.Insert( pNewEntry ) )
+ delete pNewEntry;
+
+ UpdateNames();
+ bSaved=FALSE;
+ RESTORE_DATA()
+ aEdName.SetText(EMPTY_STRING);
+ aEdName.GrabFocus();
+ UpdateChecks();
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+
+ //@BugID 54702 raus mit dem Sch.
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+
+ bAdded = TRUE;
+ }
+ else // theSymbol ungueltig
+ {
+ delete pNewEntry;
+ ERRORBOX( errMsgInvalidSym );
+ theCurSel = Selection( 0, SELECTION_MAX );
+ aEdAssign.GrabFocus();
+ }
+ }
+ }
+ else
+ {
+ ERRORBOX( ScGlobal::GetRscString(STR_INVALIDNAME) );
+ aEdName.SetSelection( Selection( 0, SELECTION_MAX ) );
+ aEdName.GrabFocus();
+ }
+ }
+
+ aEdName.SetTopEntry(nNamePos);
+ return bAdded;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScNameDlg, RemoveBtnHdl, void *, EMPTYARG )
+{
+ USHORT nRemoveAt = 0;
+ const String aStrEntry = aEdName.GetText();
+
+ if ( aLocalRangeName.SearchName( aStrEntry, nRemoveAt ) )
+ {
+ String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
+ String aMsg = aStrDelMsg.GetToken( 0, '#' );
+
+ aMsg += aStrEntry;
+ aMsg += aStrDelMsg.GetToken( 1, '#' );
+
+ if ( RET_YES ==
+ QueryBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), aMsg ).Execute() )
+ {
+ aLocalRangeName.AtFree( nRemoveAt );
+ UpdateNames();
+ UpdateChecks();
+ bSaved=FALSE;
+ RESTORE_DATA()
+ theCurSel = Selection( 0, SELECTION_MAX );
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ }
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScNameDlg, NameSelectHdl, void *, EMPTYARG )
+{
+ USHORT nAtPos;
+
+ if ( aLocalRangeName.SearchName( aEdName.GetText(), nAtPos ) )
+ {
+ String aSymbol;
+ ScRangeData* pData = (ScRangeData*)(aLocalRangeName.At( nAtPos ));
+
+ if ( pData )
+ {
+ pData->GetSymbol( aSymbol );
+ CalcCurTableAssign( aSymbol, nAtPos );
+ aEdAssign.SetText( aSymbol );
+ aBtnAdd.SetText( aStrModify );
+ theCurSel = Selection( 0, SELECTION_MAX );
+ }
+ }
+ UpdateChecks();
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScNameDlg, EdModifyHdl, Edit *, pEd )
+{
+ String theName = aEdName.GetText();
+ String theSymbol = aEdAssign.GetText();
+ BOOL bNameFound = (COMBOBOX_ENTRY_NOTFOUND
+ != aEdName.GetEntryPos( theName ));
+
+ if ( pEd == &aEdName )
+ {
+ if ( theName.Len() == 0 )
+ {
+ if ( aBtnAdd.GetText() != aStrAdd )
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aFlAssign.Disable();
+ aEdAssign.Disable();
+ aRbAssign.Disable();
+ //@BugID 54702 raus mit dem Sch.
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+ }
+ else
+ {
+ if ( bNameFound )
+ {
+ if ( aBtnAdd.GetText() != aStrModify )
+ aBtnAdd.SetText( aStrModify );
+
+ aBtnRemove.Enable();
+
+ if(!bSaved)
+ {
+ bSaved=TRUE;
+ SAVE_DATA()
+ }
+ NameSelectHdl( 0 );
+ }
+ else
+ {
+ if ( aBtnAdd.GetText() != aStrAdd )
+ aBtnAdd.SetText( aStrAdd );
+ aBtnRemove.Disable();
+
+ bSaved=FALSE;
+ RESTORE_DATA()
+ }
+ theSymbol = aEdAssign.GetText();
+
+ if ( theSymbol.Len() > 0 )
+ aBtnAdd.Enable();
+ else
+ aBtnAdd.Disable();
+
+ aFlAssign.Enable();
+ aEdAssign.Enable();
+ aRbAssign.Enable();
+ //@BugID 54702 raus mit dem Sch.
+ //SFX_APPWINDOW->Enable();
+ }
+ UpdateChecks();
+ theCurSel = Selection( 0, SELECTION_MAX );
+ }
+ else if ( pEd == &aEdAssign )
+ {
+ if ( (theName.Len()>0) && (theSymbol.Len()>0) )
+ {
+ aBtnAdd.Enable();
+ if ( bNameFound )
+ aBtnRemove.Enable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ }
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScNameDlg, AssignGetFocusHdl, void *, EMPTYARG )
+{
+ EdModifyHdl( &aEdAssign );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScNameDlg, AssignGetFocusHdl, void *, EMPTYARG )
+
+
diff --git a/sc/source/ui/pagedlg/areasdlg.cxx b/sc/source/ui/pagedlg/areasdlg.cxx index 63f06cfc0aff..bce864c71b11 100644 --- a/sc/source/ui/pagedlg/areasdlg.cxx +++ b/sc/source/ui/pagedlg/areasdlg.cxx @@ -1,909 +1,909 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: areasdlg.cxx,v $ - * $Revision: 1.18 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - - - -//---------------------------------------------------------------------------- -#include <rangelst.hxx> - -#include <sfx2/dispatch.hxx> -#include <svtools/stritem.hxx> -#include <vcl/msgbox.hxx> -#include <unotools/charclass.hxx> -#include <stdlib.h> - -#define _AREASDLG_CXX -#include "areasdlg.hxx" -#undef _AREASDLG_CXX - -#include "scresid.hxx" -#include "rangenam.hxx" -#include "reffact.hxx" -#include "tabvwsh.hxx" -#include "docsh.hxx" -#include "globstr.hrc" -#include "pagedlg.hrc" -#include "compiler.hxx" - -// STATIC DATA --------------------------------------------------------------- - -// List box positions for print range (PR) -const USHORT SC_AREASDLG_PR_NONE = 0; -const USHORT SC_AREASDLG_PR_ENTIRE = 1; -const USHORT SC_AREASDLG_PR_USER = 2; -const USHORT SC_AREASDLG_PR_SELECT = 3; -const USHORT SC_AREASDLG_PR_OFFSET = 4; - -// List box positions for repeat ranges (RR) -const USHORT SC_AREASDLG_RR_NONE = 0; -const USHORT SC_AREASDLG_RR_USER = 1; -const USHORT SC_AREASDLG_RR_OFFSET = 2; - -//============================================================================ - -#define HDL(hdl) LINK( this, ScPrintAreasDlg, hdl ) -#define ERRORBOX(nId) ErrorBox( this, WinBits(WB_OK|WB_DEF_OK), \ - ScGlobal::GetRscString( nId ) ).Execute() -#define SWAP(x1,x2) { int n=x1; x1=x2; x2=n; } - -// globale Funktionen (->am Ende der Datei): - -bool lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange ); -void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr ); - -#if 0 -static void printAddressFlags(USHORT nFlag) -{ - if ((nFlag & SCA_COL_ABSOLUTE ) == SCA_COL_ABSOLUTE ) printf("SCA_COL_ABSOLUTE \n"); - if ((nFlag & SCA_ROW_ABSOLUTE ) == SCA_ROW_ABSOLUTE ) printf("SCA_ROW_ABSOLUTE \n"); - if ((nFlag & SCA_TAB_ABSOLUTE ) == SCA_TAB_ABSOLUTE ) printf("SCA_TAB_ABSOLUTE \n"); - if ((nFlag & SCA_TAB_3D ) == SCA_TAB_3D ) printf("SCA_TAB_3D \n"); - if ((nFlag & SCA_COL2_ABSOLUTE ) == SCA_COL2_ABSOLUTE ) printf("SCA_COL2_ABSOLUTE\n"); - if ((nFlag & SCA_ROW2_ABSOLUTE ) == SCA_ROW2_ABSOLUTE ) printf("SCA_ROW2_ABSOLUTE\n"); - if ((nFlag & SCA_TAB2_ABSOLUTE ) == SCA_TAB2_ABSOLUTE ) printf("SCA_TAB2_ABSOLUTE\n"); - if ((nFlag & SCA_TAB2_3D ) == SCA_TAB2_3D ) printf("SCA_TAB2_3D \n"); - if ((nFlag & SCA_VALID_ROW ) == SCA_VALID_ROW ) printf("SCA_VALID_ROW \n"); - if ((nFlag & SCA_VALID_COL ) == SCA_VALID_COL ) printf("SCA_VALID_COL \n"); - if ((nFlag & SCA_VALID_TAB ) == SCA_VALID_TAB ) printf("SCA_VALID_TAB \n"); - if ((nFlag & SCA_FORCE_DOC ) == SCA_FORCE_DOC ) printf("SCA_FORCE_DOC \n"); - if ((nFlag & SCA_VALID_ROW2 ) == SCA_VALID_ROW2 ) printf("SCA_VALID_ROW2 \n"); - if ((nFlag & SCA_VALID_COL2 ) == SCA_VALID_COL2 ) printf("SCA_VALID_COL2 \n"); - if ((nFlag & SCA_VALID_TAB2 ) == SCA_VALID_TAB2 ) printf("SCA_VALID_TAB2 \n"); - if ((nFlag & SCA_VALID ) == SCA_VALID ) printf("SCA_VALID \n"); - if ((nFlag & SCA_ABS ) == SCA_ABS ) printf("SCA_ABS \n"); - if ((nFlag & SCR_ABS ) == SCR_ABS ) printf("SCR_ABS \n"); - if ((nFlag & SCA_ABS_3D ) == SCA_ABS_3D ) printf("SCA_ABS_3D \n"); - if ((nFlag & SCR_ABS_3D ) == SCR_ABS_3D ) printf("SCR_ABS_3D \n"); -} -#endif - -//============================================================================ -// class ScPrintAreasDlg - -//---------------------------------------------------------------------------- - -ScPrintAreasDlg::ScPrintAreasDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent ) - : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_AREAS), - // - aLbPrintArea ( this, ScResId( LB_PRINTAREA ) ), - aFlPrintArea ( this, ScResId( FL_PRINTAREA ) ), - aEdPrintArea ( this, ScResId( ED_PRINTAREA ) ), - aRbPrintArea ( this, ScResId( RB_PRINTAREA ), &aEdPrintArea ), - // - aLbRepeatRow ( this, ScResId( LB_REPEATROW ) ), - aFlRepeatRow ( this, ScResId( FL_REPEATROW ) ), - aEdRepeatRow ( this, ScResId( ED_REPEATROW ) ), - aRbRepeatRow ( this, ScResId( RB_REPEATROW ), &aEdRepeatRow ), - // - aLbRepeatCol ( this, ScResId( LB_REPEATCOL ) ), - aFlRepeatCol ( this, ScResId( FL_REPEATCOL ) ), - aEdRepeatCol ( this, ScResId( ED_REPEATCOL ) ), - aRbRepeatCol ( this, ScResId( RB_REPEATCOL ), &aEdRepeatCol ), - // - aBtnOk ( this, ScResId( BTN_OK ) ), - aBtnCancel ( this, ScResId( BTN_CANCEL ) ), - aBtnHelp ( this, ScResId( BTN_HELP ) ), - // - bDlgLostFocus ( FALSE ), - pRefInputEdit ( &aEdPrintArea ), - pDoc ( NULL ), - pViewData ( NULL ), - nCurTab ( 0 ) -{ - ScTabViewShell* pScViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); - ScDocShell* pScDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() ); - - DBG_ASSERT( pScDocSh, "Current DocumentShell not found :-(" ); - - pDoc = pScDocSh->GetDocument(); - - if ( pScViewSh ) - { - pViewData = pScViewSh->GetViewData(); - nCurTab = pViewData->GetTabNo(); - } - - Impl_Reset(); - - //@BugID 54702 Enablen/Disablen nur noch in Basisklasse - //SFX_APPWINDOW->Enable(); - - FreeResource(); -} - - -//---------------------------------------------------------------------------- - -ScPrintAreasDlg::~ScPrintAreasDlg() -{ - // Extra-Data an ListBox-Entries abraeumen - ListBox* pLb[3] = { &aLbPrintArea, &aLbRepeatRow, &aLbRepeatCol }; - - for ( USHORT i=0; i<3; i++ ) - { - USHORT nCount = pLb[i]->GetEntryCount(); - for ( USHORT j=0; j<nCount; j++ ) - delete (String*)pLb[i]->GetEntryData(j); - } -} - - -//---------------------------------------------------------------------------- - -BOOL ScPrintAreasDlg::Close() -{ - return DoClose( ScPrintAreasDlgWrapper::GetChildWindowId() ); -} - - -//---------------------------------------------------------------------------- - -BOOL ScPrintAreasDlg::IsTableLocked() const -{ - // Druckbereiche gelten pro Tabelle, darum macht es keinen Sinn, - // bei der Eingabe die Tabelle umzuschalten - - return TRUE; -} - - -//---------------------------------------------------------------------------- - -void ScPrintAreasDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ ) -{ - if ( pRefInputEdit ) - { - if ( rRef.aStart != rRef.aEnd ) - RefInputStart( pRefInputEdit ); - - String aStr; - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); - - if ( &aEdPrintArea == pRefInputEdit ) - { - rRef.Format( aStr, SCR_ABS, pDoc, eConv ); - -// aEdPrintArea.ReplaceSelected( aStr ); - - String aVal = aEdPrintArea.GetText(); - Selection aSel = aEdPrintArea.GetSelection(); - aSel.Justify(); - aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() ); - aVal.Insert( aStr, (xub_StrLen)aSel.Min() ); - Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() ); - aEdPrintArea.SetRefString( aVal ); - aEdPrintArea.SetSelection( aNewSel ); - } - else - { - BOOL bRow = ( &aEdRepeatRow == pRefInputEdit ); - lcl_GetRepeatRangeString(&rRef, pDoc, bRow, aStr); - pRefInputEdit->SetRefString( aStr ); - } - } - - Impl_ModifyHdl( pRefInputEdit ); -} - - -//---------------------------------------------------------------------------- - -void ScPrintAreasDlg::AddRefEntry() -{ - if ( pRefInputEdit == &aEdPrintArea ) - { - const sal_Unicode sep = ScCompiler::GetStringFromOpCode(ocSep).GetChar(0); - String aVal = aEdPrintArea.GetText(); - aVal += sep; - aEdPrintArea.SetText(aVal); - - xub_StrLen nLen = aVal.Len(); - aEdPrintArea.SetSelection( Selection( nLen, nLen ) ); - - Impl_ModifyHdl( &aEdPrintArea ); - } -} - - -//---------------------------------------------------------------------------- - -void ScPrintAreasDlg::Deactivate() -{ - bDlgLostFocus = TRUE; -} - - -//---------------------------------------------------------------------------- - -void ScPrintAreasDlg::SetActive() -{ - if ( bDlgLostFocus ) - { - bDlgLostFocus = FALSE; - - if ( pRefInputEdit ) - { - pRefInputEdit->GrabFocus(); - Impl_ModifyHdl( pRefInputEdit ); - } - } - else - GrabFocus(); - - RefInputDone(); -} - - -//---------------------------------------------------------------------------- - -void ScPrintAreasDlg::Impl_Reset() -{ - String aStrRange; - const ScRange* pRepeatColRange = pDoc->GetRepeatColRange( nCurTab ); - const ScRange* pRepeatRowRange = pDoc->GetRepeatRowRange( nCurTab ); - - aEdPrintArea.SetModifyHdl ( HDL(Impl_ModifyHdl) ); - aEdRepeatRow.SetModifyHdl ( HDL(Impl_ModifyHdl) ); - aEdRepeatCol.SetModifyHdl ( HDL(Impl_ModifyHdl) ); - aEdPrintArea.SetGetFocusHdl( HDL(Impl_GetFocusHdl) ); - aEdRepeatRow.SetGetFocusHdl( HDL(Impl_GetFocusHdl) ); - aEdRepeatCol.SetGetFocusHdl( HDL(Impl_GetFocusHdl) ); - aLbPrintArea.SetGetFocusHdl( HDL(Impl_GetFocusHdl) ); - aLbRepeatRow.SetGetFocusHdl( HDL(Impl_GetFocusHdl) ); - aLbRepeatCol.SetGetFocusHdl( HDL(Impl_GetFocusHdl) ); - aLbPrintArea.SetSelectHdl ( HDL(Impl_SelectHdl) ); - aLbRepeatRow.SetSelectHdl ( HDL(Impl_SelectHdl) ); - aLbRepeatCol.SetSelectHdl ( HDL(Impl_SelectHdl) ); - aBtnOk .SetClickHdl ( HDL(Impl_BtnHdl) ); - aBtnCancel .SetClickHdl ( HDL(Impl_BtnHdl) ); - - Impl_FillLists(); - - //------------------------- - // Druckbereich - //------------------------- - aStrRange.Erase(); - String aOne; - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); - const sal_Unicode sep = ScCompiler::GetStringFromOpCode(ocSep).GetChar(0); - USHORT nRangeCount = pDoc->GetPrintRangeCount( nCurTab ); - for (USHORT i=0; i<nRangeCount; i++) - { - const ScRange* pPrintRange = pDoc->GetPrintRange( nCurTab, i ); - if (pPrintRange) - { - if ( aStrRange.Len() ) - aStrRange += sep; - pPrintRange->Format( aOne, SCR_ABS, pDoc, eConv ); - aStrRange += aOne; - } - } - aEdPrintArea.SetText( aStrRange ); - - //------------------------------- - // Wiederholungszeile - //------------------------------- - lcl_GetRepeatRangeString(pRepeatRowRange, pDoc, true, aStrRange); - aEdRepeatRow.SetText( aStrRange ); - - //-------------------------------- - // Wiederholungsspalte - //-------------------------------- - lcl_GetRepeatRangeString(pRepeatColRange, pDoc, false, aStrRange); - aEdRepeatCol.SetText( aStrRange ); - - Impl_ModifyHdl( &aEdPrintArea ); - Impl_ModifyHdl( &aEdRepeatRow ); - Impl_ModifyHdl( &aEdRepeatCol ); - if( pDoc->IsPrintEntireSheet( nCurTab ) ) - aLbPrintArea.SelectEntryPos( SC_AREASDLG_PR_ENTIRE ); - - aEdPrintArea.SaveValue(); // fuer FillItemSet() merken: - aEdRepeatRow.SaveValue(); - aEdRepeatCol.SaveValue(); -} - - -//---------------------------------------------------------------------------- - -BOOL ScPrintAreasDlg::Impl_GetItem( Edit* pEd, SfxStringItem& rItem ) -{ - String aRangeStr = pEd->GetText(); - BOOL bDataChanged = (pEd->GetSavedValue() != aRangeStr); - - if ( (aRangeStr.Len() > 0) && &aEdPrintArea != pEd ) - { - ScRange aRange; - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); - lcl_CheckRepeatString(aRangeStr, pDoc, &aEdRepeatRow == pEd, &aRange); - aRange.Format(aRangeStr, SCR_ABS, pDoc, eConv); - } - - rItem.SetValue( aRangeStr ); - - return bDataChanged; -} - - -//---------------------------------------------------------------------------- - -BOOL ScPrintAreasDlg::Impl_CheckRefStrings() -{ - BOOL bOk = FALSE; - String aStrPrintArea = aEdPrintArea.GetText(); - String aStrRepeatRow = aEdRepeatRow.GetText(); - String aStrRepeatCol = aEdRepeatCol.GetText(); - - BOOL bPrintAreaOk = TRUE; - if ( aStrPrintArea.Len() ) - { - const USHORT nValidAddr = SCA_VALID | SCA_VALID_ROW | SCA_VALID_COL; - const USHORT nValidRange = nValidAddr | SCA_VALID_ROW2 | SCA_VALID_COL2; - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); - const sal_Unicode sep = ScCompiler::GetStringFromOpCode(ocSep).GetChar(0); - // const sal_Unicode rsep = ScCompiler::GetStringFromOpCode(ocRange).GetChar(0); - - ScAddress aAddr; - ScRange aRange; - xub_StrLen nSepCount = aStrPrintArea.GetTokenCount(sep); - for ( xub_StrLen i = 0; i < nSepCount && bPrintAreaOk; ++i ) - { - String aOne = aStrPrintArea.GetToken(i, sep); - USHORT nResult = aRange.Parse( aOne, pDoc, eConv ); - if ((nResult & nValidRange) != nValidRange) - { - USHORT nAddrResult = aAddr.Parse( aOne, pDoc, eConv ); - if ((nAddrResult & nValidAddr) != nValidAddr) - bPrintAreaOk = FALSE; - } - } - } - - BOOL bRepeatRowOk = (aStrRepeatRow.Len() == 0); - if ( !bRepeatRowOk ) - bRepeatRowOk = lcl_CheckRepeatString(aStrRepeatRow, pDoc, true, NULL); - - BOOL bRepeatColOk = (aStrRepeatCol.Len() == 0); - if ( !bRepeatColOk ) - bRepeatColOk = lcl_CheckRepeatString(aStrRepeatCol, pDoc, false, NULL); - - // Fehlermeldungen - - bOk = (bPrintAreaOk && bRepeatRowOk && bRepeatColOk); - - if ( !bOk ) - { - Edit* pEd = NULL; - - if ( !bPrintAreaOk ) pEd = &aEdPrintArea; - else if ( !bRepeatRowOk ) pEd = &aEdRepeatRow; - else if ( !bRepeatColOk ) pEd = &aEdRepeatCol; - - ERRORBOX( STR_INVALID_TABREF ); - pEd->GrabFocus(); - } - - return bOk; -} - - -//---------------------------------------------------------------------------- - -void ScPrintAreasDlg::Impl_FillLists() -{ - //------------------------------------------------------ - // Selektion holen und String in PrintArea-ListBox merken - //------------------------------------------------------ - ScRange aRange; - String aStrRange; - BOOL bSimple = TRUE; - - if ( pViewData ) - bSimple = (pViewData->GetSimpleArea( aRange ) == SC_MARK_SIMPLE); - - ScAddress::Convention eConv = pDoc->GetAddressConvention(); - - if ( bSimple ) - aRange.Format( aStrRange, SCR_ABS, pDoc, eConv ); - else - { - ScRangeListRef aList( new ScRangeList ); - pViewData->GetMarkData().FillRangeListWithMarks( aList, FALSE ); - aList->Format( aStrRange, SCR_ABS, pDoc, eConv ); - } - - aLbPrintArea.SetEntryData( SC_AREASDLG_PR_SELECT, new String( aStrRange ) ); - - //------------------------------------------------------ - // Ranges holen und in ListBoxen merken - //------------------------------------------------------ - ScRangeName* pRangeNames = pDoc->GetRangeName(); - const USHORT nCount = pRangeNames ? pRangeNames->GetCount() : 0; - - if ( nCount > 0 ) - { - String aName; - String aSymbol; -// ScRange aRange; - ScRangeData* pData = NULL; - - for ( USHORT i=0; i<nCount; i++ ) - { - pData = (ScRangeData*)(pRangeNames->At( i )); - if ( pData ) - { - if ( pData->HasType( RT_ABSAREA ) - || pData->HasType( RT_REFAREA ) - || pData->HasType( RT_ABSPOS ) ) - { - pData->GetName( aName ); - pData->GetSymbol( aSymbol ); - if ( aRange.ParseAny( aSymbol, pDoc, eConv ) & SCA_VALID ) - { - if ( pData->HasType( RT_PRINTAREA ) ) - { - aRange.Format( aSymbol, SCR_ABS, pDoc, eConv ); - aLbPrintArea.SetEntryData( - aLbPrintArea.InsertEntry( aName ), - new String( aSymbol ) ); - } - - if ( pData->HasType( RT_ROWHEADER ) ) - { - lcl_GetRepeatRangeString(&aRange, pDoc, true, aSymbol); - aLbRepeatRow.SetEntryData( - aLbRepeatRow.InsertEntry( aName ), - new String( aSymbol ) ); - } - - if ( pData->HasType( RT_COLHEADER ) ) - { - lcl_GetRepeatRangeString(&aRange, pDoc, false, aSymbol); - aLbRepeatCol.SetEntryData( - aLbRepeatCol.InsertEntry( aName ), - new String( aSymbol ) ); - } - } - } - } - } - } -} - - -//---------------------------------------------------------------------------- -// Handler: -//---------------------------------------------------------------------------- - -IMPL_LINK( ScPrintAreasDlg, Impl_BtnHdl, PushButton*, pBtn ) -{ - if ( &aBtnOk == pBtn ) - { - if ( Impl_CheckRefStrings() ) - { - BOOL bDataChanged = FALSE; - String aStr; - SfxStringItem aPrintArea( SID_CHANGE_PRINTAREA, aStr ); - SfxStringItem aRepeatRow( FN_PARAM_2, aStr ); - SfxStringItem aRepeatCol( FN_PARAM_3, aStr ); - - //------------------------- - // Druckbereich veraendert? - //------------------------- - - // first try the list box, if "Entite sheet" is selected - BOOL bEntireSheet = (aLbPrintArea.GetSelectEntryPos() == SC_AREASDLG_PR_ENTIRE); - SfxBoolItem aEntireSheet( FN_PARAM_4, bEntireSheet ); - - bDataChanged = bEntireSheet != pDoc->IsPrintEntireSheet( nCurTab ); - if( !bEntireSheet ) - { - // if new list box selection is not "Entire sheet", get the edit field contents - bDataChanged |= Impl_GetItem( &aEdPrintArea, aPrintArea ); - } - - //------------------------------- - // Wiederholungszeile veraendert? - //------------------------------- - bDataChanged |= Impl_GetItem( &aEdRepeatRow, aRepeatRow ); - - //-------------------------------- - // Wiederholungsspalte veraendert? - //-------------------------------- - bDataChanged |= Impl_GetItem( &aEdRepeatCol, aRepeatCol ); - - if ( bDataChanged ) - { - SetDispatcherLock( FALSE ); - SwitchToDocument(); - GetBindings().GetDispatcher()->Execute( SID_CHANGE_PRINTAREA, - SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, - &aPrintArea, &aRepeatRow, &aRepeatCol, &aEntireSheet, 0L ); - } - - Close(); - } - } - else if ( &aBtnCancel == pBtn ) - Close(); - - return 0; -} - - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScPrintAreasDlg, Impl_GetFocusHdl, Control*, pCtr ) -{ - if ( pCtr ==(Control *) &aEdPrintArea || - pCtr ==(Control *) &aEdRepeatRow || - pCtr ==(Control *) &aEdRepeatCol) - { - pRefInputEdit = (ScRefEdit*) pCtr; - } - else if ( pCtr ==(Control *) &aLbPrintArea) - { - pRefInputEdit = &aEdPrintArea; - } - else if ( pCtr ==(Control *) &aLbRepeatRow) - { - pRefInputEdit = &aEdRepeatRow; - } - else if ( pCtr ==(Control *) &aLbRepeatCol) - { - pRefInputEdit = &aEdRepeatCol; - } - - return 0; -} - - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScPrintAreasDlg, Impl_SelectHdl, ListBox*, pLb ) -{ - USHORT nSelPos = pLb->GetSelectEntryPos(); - Edit* pEd = NULL; - - // list box positions of specific entries, default to "repeat row/column" list boxes - USHORT nAllSheetPos = SC_AREASDLG_RR_NONE; - USHORT nUserDefPos = SC_AREASDLG_RR_USER; - USHORT nFirstCustomPos = SC_AREASDLG_RR_OFFSET; - - // find edit field for list box, and list box positions - if( pLb == &aLbPrintArea ) - { - pEd = &aEdPrintArea; - nAllSheetPos = SC_AREASDLG_PR_ENTIRE; - nUserDefPos = SC_AREASDLG_PR_USER; - nFirstCustomPos = SC_AREASDLG_PR_SELECT; // "Selection" and following - } - else if( pLb == &aLbRepeatCol ) - pEd = &aEdRepeatCol; - else if( pLb == &aLbRepeatRow ) - pEd = &aEdRepeatRow; - else - return 0; - - // fill edit field according to list box selection - if( (nSelPos == 0) || (nSelPos == nAllSheetPos) ) - pEd->SetText( EMPTY_STRING ); - else if( nSelPos == nUserDefPos && !pLb->IsTravelSelect() && pEd->GetText().Len() == 0 ) - pLb->SelectEntryPos( 0 ); - else if( nSelPos >= nFirstCustomPos ) - pEd->SetText( *static_cast< String* >( pLb->GetEntryData( nSelPos ) ) ); - - return 0; -} - - -//---------------------------------------------------------------------------- - -IMPL_LINK( ScPrintAreasDlg, Impl_ModifyHdl, ScRefEdit*, pEd ) -{ - ListBox* pLb = NULL; - - // list box positions of specific entries, default to "repeat row/column" list boxes - USHORT nUserDefPos = SC_AREASDLG_RR_USER; - USHORT nFirstCustomPos = SC_AREASDLG_RR_OFFSET; - - if( pEd == &aEdPrintArea ) - { - pLb = &aLbPrintArea; - nUserDefPos = SC_AREASDLG_PR_USER; - nFirstCustomPos = SC_AREASDLG_PR_SELECT; // "Selection" and following - } - else if( pEd == &aEdRepeatCol ) - pLb = &aLbRepeatCol; - else if( pEd == &aEdRepeatRow ) - pLb = &aLbRepeatRow; - else - return 0; - - // set list box selection according to edit field - USHORT nEntryCount = pLb->GetEntryCount(); - String aStrEd( pEd->GetText() ); - String aEdUpper = aStrEd; - aEdUpper.ToUpperAscii(); - - if ( (nEntryCount > nFirstCustomPos) && aStrEd.Len() > 0 ) - { - BOOL bFound = FALSE; - String* pSymbol = NULL; - USHORT i; - - for ( i=nFirstCustomPos; i<nEntryCount && !bFound; i++ ) - { - pSymbol = (String*)pLb->GetEntryData( i ); - bFound = ( (*pSymbol == aStrEd) || (*pSymbol == aEdUpper) ); - } - - pLb->SelectEntryPos( bFound ? i-1 : nUserDefPos ); - } - else - pLb->SelectEntryPos( aStrEd.Len() ? nUserDefPos : 0 ); - - return 0; -} - - -//============================================================================ -// globale Funktionen: - -// ---------------------------------------------------------------------------- - -// TODO: It might make sense to move these functions to address.?xx. -kohei - -bool lcl_CheckOne_OOO( const String& rStr, bool bIsRow, SCCOLROW& rVal ) -{ - // Zulaessige Syntax fuer rStr: - // Row: [$]1-MAXTAB - // Col: [$]A-IV - - String aStr = rStr; - xub_StrLen nLen = aStr.Len(); - SCCOLROW nNum = 0; - BOOL bStrOk = ( nLen > 0 ) && ( bIsRow ? ( nLen < 6 ) : ( nLen < 4 ) ); - - if ( bStrOk ) - { - if ( '$' == aStr.GetChar(0) ) - aStr.Erase( 0, 1 ); - - if ( bIsRow ) - { - bStrOk = CharClass::isAsciiNumeric(aStr); - - if ( bStrOk ) - { - sal_Int32 n = aStr.ToInt32(); - - if ( ( bStrOk = (n > 0) && ( n <= MAXROWCOUNT ) ) != FALSE ) - nNum = static_cast<SCCOLROW>(n - 1); - } - } - else - { - SCCOL nCol = 0; - bStrOk = ::AlphaToCol( nCol, aStr); - nNum = nCol; - } - } - - if ( bStrOk ) - rVal = nNum; - - return bStrOk; -} - -bool lcl_CheckOne_XL_A1( const String& rStr, bool bIsRow, SCCOLROW& rVal ) -{ - // XL A1 style is identical to OOO one for print range formats. - return lcl_CheckOne_OOO(rStr, bIsRow, rVal); -} - -bool lcl_CheckOne_XL_R1C1( const String& rStr, bool bIsRow, SCCOLROW& rVal ) -{ - xub_StrLen nLen = rStr.Len(); - if (nLen <= 1) - // There must be at least two characters. - return false; - - const sal_Unicode preUpper = bIsRow ? 'R' : 'C'; - const sal_Unicode preLower = bIsRow ? 'r' : 'c'; - if (rStr.GetChar(0) != preUpper && rStr.GetChar(0) != preLower) - return false; - - String aNumStr = rStr.Copy(1); - if (!CharClass::isAsciiNumeric(aNumStr)) - return false; - - sal_Int32 nNum = aNumStr.ToInt32(); - - if (nNum <= 0) - return false; - - if ((bIsRow && nNum > MAXROWCOUNT) || (!bIsRow && nNum > MAXCOLCOUNT)) - return false; - - rVal = static_cast<SCCOLROW>(nNum-1); - return true; -} - -bool lcl_CheckRepeatOne( const String& rStr, ScAddress::Convention eConv, bool bIsRow, SCCOLROW& rVal ) -{ - switch (eConv) - { - case ScAddress::CONV_OOO: - return lcl_CheckOne_OOO(rStr, bIsRow, rVal); - case ScAddress::CONV_XL_A1: - return lcl_CheckOne_XL_A1(rStr, bIsRow, rVal); - case ScAddress::CONV_XL_R1C1: - return lcl_CheckOne_XL_R1C1(rStr, bIsRow, rVal); - default: - { - // added to avoid warnings - } - } - return false; -} - -bool lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange ) -{ - // Row: [valid row] rsep [valid row] - // Col: [valid col] rsep [valid col] - - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); - const sal_Unicode rsep = ScCompiler::GetStringFromOpCode(ocRange).GetChar(0); - - if (pRange) - { - // initialize the range value. - pRange->aStart.SetCol(0); - pRange->aStart.SetRow(0); - pRange->aEnd.SetCol(0); - pRange->aEnd.SetRow(0); - } - - String aBuf; - SCCOLROW nVal = 0; - xub_StrLen nLen = rStr.Len(); - bool bEndPos = false; - for (xub_StrLen i = 0; i < nLen; ++i) - { - const sal_Unicode c = rStr.GetChar(i); - if (c == rsep) - { - if (bEndPos) - // We aren't supposed to have more than one range separator. - return false; - - // range separator - if (aBuf.Len() == 0) - return false; - - bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal); - if (!bRes) - return false; - - if (pRange) - { - if (bIsRow) - { - pRange->aStart.SetRow(static_cast<SCROW>(nVal)); - pRange->aEnd.SetRow(static_cast<SCROW>(nVal)); - } - else - { - pRange->aStart.SetCol(static_cast<SCCOL>(nVal)); - pRange->aEnd.SetCol(static_cast<SCCOL>(nVal)); - } - } - - aBuf.Erase(); - bEndPos = true; - } - else - aBuf.Append(c); - } - - if (aBuf.Len() > 0) - { - bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal); - if (!bRes) - return false; - - if (pRange) - { - if (bIsRow) - { - if (!bEndPos) - pRange->aStart.SetRow(static_cast<SCROW>(nVal)); - pRange->aEnd.SetRow(static_cast<SCROW>(nVal)); - } - else - { - if (!bEndPos) - pRange->aStart.SetCol(static_cast<SCCOL>(nVal)); - pRange->aEnd.SetCol(static_cast<SCCOL>(nVal)); - } - } - } - - return true; -} - -// ---------------------------------------------------------------------------- - -void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr ) -{ - rStr.Erase(); - if (!pRange) - return; - - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); - const ScAddress& rStart = pRange->aStart; - const ScAddress& rEnd = pRange->aEnd; - - const USHORT nFmt = bIsRow ? (SCA_VALID_ROW | SCA_ROW_ABSOLUTE) : (SCA_VALID_COL | SCA_COL_ABSOLUTE); - String aTmpStr; - rStart.Format(aTmpStr, nFmt, pDoc, eConv); - rStr += aTmpStr; - if ((bIsRow && rStart.Row() != rEnd.Row()) || (!bIsRow && rStart.Col() != rEnd.Col())) - { - rStr += ScCompiler::GetStringFromOpCode(ocRange); - rEnd.Format(aTmpStr, nFmt, pDoc, eConv); - rStr += aTmpStr; - } -} - +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: areasdlg.cxx,v $
+ * $Revision: 1.18 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+#include <rangelst.hxx>
+
+#include <sfx2/dispatch.hxx>
+#include <svtools/stritem.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/charclass.hxx>
+#include <stdlib.h>
+
+#define _AREASDLG_CXX
+#include "areasdlg.hxx"
+#undef _AREASDLG_CXX
+
+#include "scresid.hxx"
+#include "rangenam.hxx"
+#include "reffact.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "globstr.hrc"
+#include "pagedlg.hrc"
+#include "compiler.hxx"
+
+// STATIC DATA ---------------------------------------------------------------
+
+// List box positions for print range (PR)
+const USHORT SC_AREASDLG_PR_NONE = 0;
+const USHORT SC_AREASDLG_PR_ENTIRE = 1;
+const USHORT SC_AREASDLG_PR_USER = 2;
+const USHORT SC_AREASDLG_PR_SELECT = 3;
+const USHORT SC_AREASDLG_PR_OFFSET = 4;
+
+// List box positions for repeat ranges (RR)
+const USHORT SC_AREASDLG_RR_NONE = 0;
+const USHORT SC_AREASDLG_RR_USER = 1;
+const USHORT SC_AREASDLG_RR_OFFSET = 2;
+
+//============================================================================
+
+#define HDL(hdl) LINK( this, ScPrintAreasDlg, hdl )
+#define ERRORBOX(nId) ErrorBox( this, WinBits(WB_OK|WB_DEF_OK), \
+ ScGlobal::GetRscString( nId ) ).Execute()
+#define SWAP(x1,x2) { int n=x1; x1=x2; x2=n; }
+
+// globale Funktionen (->am Ende der Datei):
+
+bool lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange );
+void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr );
+
+#if 0
+static void printAddressFlags(USHORT nFlag)
+{
+ if ((nFlag & SCA_COL_ABSOLUTE ) == SCA_COL_ABSOLUTE ) printf("SCA_COL_ABSOLUTE \n");
+ if ((nFlag & SCA_ROW_ABSOLUTE ) == SCA_ROW_ABSOLUTE ) printf("SCA_ROW_ABSOLUTE \n");
+ if ((nFlag & SCA_TAB_ABSOLUTE ) == SCA_TAB_ABSOLUTE ) printf("SCA_TAB_ABSOLUTE \n");
+ if ((nFlag & SCA_TAB_3D ) == SCA_TAB_3D ) printf("SCA_TAB_3D \n");
+ if ((nFlag & SCA_COL2_ABSOLUTE ) == SCA_COL2_ABSOLUTE ) printf("SCA_COL2_ABSOLUTE\n");
+ if ((nFlag & SCA_ROW2_ABSOLUTE ) == SCA_ROW2_ABSOLUTE ) printf("SCA_ROW2_ABSOLUTE\n");
+ if ((nFlag & SCA_TAB2_ABSOLUTE ) == SCA_TAB2_ABSOLUTE ) printf("SCA_TAB2_ABSOLUTE\n");
+ if ((nFlag & SCA_TAB2_3D ) == SCA_TAB2_3D ) printf("SCA_TAB2_3D \n");
+ if ((nFlag & SCA_VALID_ROW ) == SCA_VALID_ROW ) printf("SCA_VALID_ROW \n");
+ if ((nFlag & SCA_VALID_COL ) == SCA_VALID_COL ) printf("SCA_VALID_COL \n");
+ if ((nFlag & SCA_VALID_TAB ) == SCA_VALID_TAB ) printf("SCA_VALID_TAB \n");
+ if ((nFlag & SCA_FORCE_DOC ) == SCA_FORCE_DOC ) printf("SCA_FORCE_DOC \n");
+ if ((nFlag & SCA_VALID_ROW2 ) == SCA_VALID_ROW2 ) printf("SCA_VALID_ROW2 \n");
+ if ((nFlag & SCA_VALID_COL2 ) == SCA_VALID_COL2 ) printf("SCA_VALID_COL2 \n");
+ if ((nFlag & SCA_VALID_TAB2 ) == SCA_VALID_TAB2 ) printf("SCA_VALID_TAB2 \n");
+ if ((nFlag & SCA_VALID ) == SCA_VALID ) printf("SCA_VALID \n");
+ if ((nFlag & SCA_ABS ) == SCA_ABS ) printf("SCA_ABS \n");
+ if ((nFlag & SCR_ABS ) == SCR_ABS ) printf("SCR_ABS \n");
+ if ((nFlag & SCA_ABS_3D ) == SCA_ABS_3D ) printf("SCA_ABS_3D \n");
+ if ((nFlag & SCR_ABS_3D ) == SCR_ABS_3D ) printf("SCR_ABS_3D \n");
+}
+#endif
+
+//============================================================================
+// class ScPrintAreasDlg
+
+//----------------------------------------------------------------------------
+
+ScPrintAreasDlg::ScPrintAreasDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent )
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_AREAS),
+ //
+ aLbPrintArea ( this, ScResId( LB_PRINTAREA ) ),
+ aFlPrintArea ( this, ScResId( FL_PRINTAREA ) ),
+ aEdPrintArea ( this, ScResId( ED_PRINTAREA ) ),
+ aRbPrintArea ( this, ScResId( RB_PRINTAREA ), &aEdPrintArea, this ),
+ //
+ aLbRepeatRow ( this, ScResId( LB_REPEATROW ) ),
+ aFlRepeatRow ( this, ScResId( FL_REPEATROW ) ),
+ aEdRepeatRow ( this, ScResId( ED_REPEATROW ) ),
+ aRbRepeatRow ( this, ScResId( RB_REPEATROW ), &aEdRepeatRow, this ),
+ //
+ aLbRepeatCol ( this, ScResId( LB_REPEATCOL ) ),
+ aFlRepeatCol ( this, ScResId( FL_REPEATCOL ) ),
+ aEdRepeatCol ( this, ScResId( ED_REPEATCOL ) ),
+ aRbRepeatCol ( this, ScResId( RB_REPEATCOL ), &aEdRepeatCol, this ),
+ //
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ bDlgLostFocus ( FALSE ),
+ pRefInputEdit ( &aEdPrintArea ),
+ pDoc ( NULL ),
+ pViewData ( NULL ),
+ nCurTab ( 0 )
+{
+ ScTabViewShell* pScViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
+ ScDocShell* pScDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
+
+ DBG_ASSERT( pScDocSh, "Current DocumentShell not found :-(" );
+
+ pDoc = pScDocSh->GetDocument();
+
+ if ( pScViewSh )
+ {
+ pViewData = pScViewSh->GetViewData();
+ nCurTab = pViewData->GetTabNo();
+ }
+
+ Impl_Reset();
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+
+ FreeResource();
+}
+
+
+//----------------------------------------------------------------------------
+
+ScPrintAreasDlg::~ScPrintAreasDlg()
+{
+ // Extra-Data an ListBox-Entries abraeumen
+ ListBox* pLb[3] = { &aLbPrintArea, &aLbRepeatRow, &aLbRepeatCol };
+
+ for ( USHORT i=0; i<3; i++ )
+ {
+ USHORT nCount = pLb[i]->GetEntryCount();
+ for ( USHORT j=0; j<nCount; j++ )
+ delete (String*)pLb[i]->GetEntryData(j);
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScPrintAreasDlg::Close()
+{
+ return DoClose( ScPrintAreasDlgWrapper::GetChildWindowId() );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScPrintAreasDlg::IsTableLocked() const
+{
+ // Druckbereiche gelten pro Tabelle, darum macht es keinen Sinn,
+ // bei der Eingabe die Tabelle umzuschalten
+
+ return TRUE;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ )
+{
+ if ( pRefInputEdit )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( pRefInputEdit );
+
+ String aStr;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ if ( &aEdPrintArea == pRefInputEdit )
+ {
+ rRef.Format( aStr, SCR_ABS, pDoc, eConv );
+
+// aEdPrintArea.ReplaceSelected( aStr );
+
+ String aVal = aEdPrintArea.GetText();
+ Selection aSel = aEdPrintArea.GetSelection();
+ aSel.Justify();
+ aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
+ aVal.Insert( aStr, (xub_StrLen)aSel.Min() );
+ Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() );
+ aEdPrintArea.SetRefString( aVal );
+ aEdPrintArea.SetSelection( aNewSel );
+ }
+ else
+ {
+ BOOL bRow = ( &aEdRepeatRow == pRefInputEdit );
+ lcl_GetRepeatRangeString(&rRef, pDoc, bRow, aStr);
+ pRefInputEdit->SetRefString( aStr );
+ }
+ }
+
+ Impl_ModifyHdl( pRefInputEdit );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::AddRefEntry()
+{
+ if ( pRefInputEdit == &aEdPrintArea )
+ {
+ const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ String aVal = aEdPrintArea.GetText();
+ aVal += sep;
+ aEdPrintArea.SetText(aVal);
+
+ xub_StrLen nLen = aVal.Len();
+ aEdPrintArea.SetSelection( Selection( nLen, nLen ) );
+
+ Impl_ModifyHdl( &aEdPrintArea );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::Deactivate()
+{
+ bDlgLostFocus = TRUE;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+
+ if ( pRefInputEdit )
+ {
+ pRefInputEdit->GrabFocus();
+ Impl_ModifyHdl( pRefInputEdit );
+ }
+ }
+ else
+ GrabFocus();
+
+ RefInputDone();
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::Impl_Reset()
+{
+ String aStrRange;
+ const ScRange* pRepeatColRange = pDoc->GetRepeatColRange( nCurTab );
+ const ScRange* pRepeatRowRange = pDoc->GetRepeatRowRange( nCurTab );
+
+ aEdPrintArea.SetModifyHdl ( HDL(Impl_ModifyHdl) );
+ aEdRepeatRow.SetModifyHdl ( HDL(Impl_ModifyHdl) );
+ aEdRepeatCol.SetModifyHdl ( HDL(Impl_ModifyHdl) );
+ aEdPrintArea.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aEdRepeatRow.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aEdRepeatCol.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aLbPrintArea.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aLbRepeatRow.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aLbRepeatCol.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aLbPrintArea.SetSelectHdl ( HDL(Impl_SelectHdl) );
+ aLbRepeatRow.SetSelectHdl ( HDL(Impl_SelectHdl) );
+ aLbRepeatCol.SetSelectHdl ( HDL(Impl_SelectHdl) );
+ aBtnOk .SetClickHdl ( HDL(Impl_BtnHdl) );
+ aBtnCancel .SetClickHdl ( HDL(Impl_BtnHdl) );
+
+ Impl_FillLists();
+
+ //-------------------------
+ // Druckbereich
+ //-------------------------
+ aStrRange.Erase();
+ String aOne;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ USHORT nRangeCount = pDoc->GetPrintRangeCount( nCurTab );
+ for (USHORT i=0; i<nRangeCount; i++)
+ {
+ const ScRange* pPrintRange = pDoc->GetPrintRange( nCurTab, i );
+ if (pPrintRange)
+ {
+ if ( aStrRange.Len() )
+ aStrRange += sep;
+ pPrintRange->Format( aOne, SCR_ABS, pDoc, eConv );
+ aStrRange += aOne;
+ }
+ }
+ aEdPrintArea.SetText( aStrRange );
+
+ //-------------------------------
+ // Wiederholungszeile
+ //-------------------------------
+ lcl_GetRepeatRangeString(pRepeatRowRange, pDoc, true, aStrRange);
+ aEdRepeatRow.SetText( aStrRange );
+
+ //--------------------------------
+ // Wiederholungsspalte
+ //--------------------------------
+ lcl_GetRepeatRangeString(pRepeatColRange, pDoc, false, aStrRange);
+ aEdRepeatCol.SetText( aStrRange );
+
+ Impl_ModifyHdl( &aEdPrintArea );
+ Impl_ModifyHdl( &aEdRepeatRow );
+ Impl_ModifyHdl( &aEdRepeatCol );
+ if( pDoc->IsPrintEntireSheet( nCurTab ) )
+ aLbPrintArea.SelectEntryPos( SC_AREASDLG_PR_ENTIRE );
+
+ aEdPrintArea.SaveValue(); // fuer FillItemSet() merken:
+ aEdRepeatRow.SaveValue();
+ aEdRepeatCol.SaveValue();
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScPrintAreasDlg::Impl_GetItem( Edit* pEd, SfxStringItem& rItem )
+{
+ String aRangeStr = pEd->GetText();
+ BOOL bDataChanged = (pEd->GetSavedValue() != aRangeStr);
+
+ if ( (aRangeStr.Len() > 0) && &aEdPrintArea != pEd )
+ {
+ ScRange aRange;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ lcl_CheckRepeatString(aRangeStr, pDoc, &aEdRepeatRow == pEd, &aRange);
+ aRange.Format(aRangeStr, SCR_ABS, pDoc, eConv);
+ }
+
+ rItem.SetValue( aRangeStr );
+
+ return bDataChanged;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScPrintAreasDlg::Impl_CheckRefStrings()
+{
+ BOOL bOk = FALSE;
+ String aStrPrintArea = aEdPrintArea.GetText();
+ String aStrRepeatRow = aEdRepeatRow.GetText();
+ String aStrRepeatCol = aEdRepeatCol.GetText();
+
+ BOOL bPrintAreaOk = TRUE;
+ if ( aStrPrintArea.Len() )
+ {
+ const USHORT nValidAddr = SCA_VALID | SCA_VALID_ROW | SCA_VALID_COL;
+ const USHORT nValidRange = nValidAddr | SCA_VALID_ROW2 | SCA_VALID_COL2;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ // const sal_Unicode rsep = ScCompiler::GetNativeSymbol(ocRange).GetChar(0);
+
+ ScAddress aAddr;
+ ScRange aRange;
+ xub_StrLen nSepCount = aStrPrintArea.GetTokenCount(sep);
+ for ( xub_StrLen i = 0; i < nSepCount && bPrintAreaOk; ++i )
+ {
+ String aOne = aStrPrintArea.GetToken(i, sep);
+ USHORT nResult = aRange.Parse( aOne, pDoc, eConv );
+ if ((nResult & nValidRange) != nValidRange)
+ {
+ USHORT nAddrResult = aAddr.Parse( aOne, pDoc, eConv );
+ if ((nAddrResult & nValidAddr) != nValidAddr)
+ bPrintAreaOk = FALSE;
+ }
+ }
+ }
+
+ BOOL bRepeatRowOk = (aStrRepeatRow.Len() == 0);
+ if ( !bRepeatRowOk )
+ bRepeatRowOk = lcl_CheckRepeatString(aStrRepeatRow, pDoc, true, NULL);
+
+ BOOL bRepeatColOk = (aStrRepeatCol.Len() == 0);
+ if ( !bRepeatColOk )
+ bRepeatColOk = lcl_CheckRepeatString(aStrRepeatCol, pDoc, false, NULL);
+
+ // Fehlermeldungen
+
+ bOk = (bPrintAreaOk && bRepeatRowOk && bRepeatColOk);
+
+ if ( !bOk )
+ {
+ Edit* pEd = NULL;
+
+ if ( !bPrintAreaOk ) pEd = &aEdPrintArea;
+ else if ( !bRepeatRowOk ) pEd = &aEdRepeatRow;
+ else if ( !bRepeatColOk ) pEd = &aEdRepeatCol;
+
+ ERRORBOX( STR_INVALID_TABREF );
+ pEd->GrabFocus();
+ }
+
+ return bOk;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::Impl_FillLists()
+{
+ //------------------------------------------------------
+ // Selektion holen und String in PrintArea-ListBox merken
+ //------------------------------------------------------
+ ScRange aRange;
+ String aStrRange;
+ BOOL bSimple = TRUE;
+
+ if ( pViewData )
+ bSimple = (pViewData->GetSimpleArea( aRange ) == SC_MARK_SIMPLE);
+
+ formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ if ( bSimple )
+ aRange.Format( aStrRange, SCR_ABS, pDoc, eConv );
+ else
+ {
+ ScRangeListRef aList( new ScRangeList );
+ pViewData->GetMarkData().FillRangeListWithMarks( aList, FALSE );
+ aList->Format( aStrRange, SCR_ABS, pDoc, eConv );
+ }
+
+ aLbPrintArea.SetEntryData( SC_AREASDLG_PR_SELECT, new String( aStrRange ) );
+
+ //------------------------------------------------------
+ // Ranges holen und in ListBoxen merken
+ //------------------------------------------------------
+ ScRangeName* pRangeNames = pDoc->GetRangeName();
+ const USHORT nCount = pRangeNames ? pRangeNames->GetCount() : 0;
+
+ if ( nCount > 0 )
+ {
+ String aName;
+ String aSymbol;
+// ScRange aRange;
+ ScRangeData* pData = NULL;
+
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ pData = (ScRangeData*)(pRangeNames->At( i ));
+ if ( pData )
+ {
+ if ( pData->HasType( RT_ABSAREA )
+ || pData->HasType( RT_REFAREA )
+ || pData->HasType( RT_ABSPOS ) )
+ {
+ pData->GetName( aName );
+ pData->GetSymbol( aSymbol );
+ if ( aRange.ParseAny( aSymbol, pDoc, eConv ) & SCA_VALID )
+ {
+ if ( pData->HasType( RT_PRINTAREA ) )
+ {
+ aRange.Format( aSymbol, SCR_ABS, pDoc, eConv );
+ aLbPrintArea.SetEntryData(
+ aLbPrintArea.InsertEntry( aName ),
+ new String( aSymbol ) );
+ }
+
+ if ( pData->HasType( RT_ROWHEADER ) )
+ {
+ lcl_GetRepeatRangeString(&aRange, pDoc, true, aSymbol);
+ aLbRepeatRow.SetEntryData(
+ aLbRepeatRow.InsertEntry( aName ),
+ new String( aSymbol ) );
+ }
+
+ if ( pData->HasType( RT_COLHEADER ) )
+ {
+ lcl_GetRepeatRangeString(&aRange, pDoc, false, aSymbol);
+ aLbRepeatCol.SetEntryData(
+ aLbRepeatCol.InsertEntry( aName ),
+ new String( aSymbol ) );
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScPrintAreasDlg, Impl_BtnHdl, PushButton*, pBtn )
+{
+ if ( &aBtnOk == pBtn )
+ {
+ if ( Impl_CheckRefStrings() )
+ {
+ BOOL bDataChanged = FALSE;
+ String aStr;
+ SfxStringItem aPrintArea( SID_CHANGE_PRINTAREA, aStr );
+ SfxStringItem aRepeatRow( FN_PARAM_2, aStr );
+ SfxStringItem aRepeatCol( FN_PARAM_3, aStr );
+
+ //-------------------------
+ // Druckbereich veraendert?
+ //-------------------------
+
+ // first try the list box, if "Entite sheet" is selected
+ BOOL bEntireSheet = (aLbPrintArea.GetSelectEntryPos() == SC_AREASDLG_PR_ENTIRE);
+ SfxBoolItem aEntireSheet( FN_PARAM_4, bEntireSheet );
+
+ bDataChanged = bEntireSheet != pDoc->IsPrintEntireSheet( nCurTab );
+ if( !bEntireSheet )
+ {
+ // if new list box selection is not "Entire sheet", get the edit field contents
+ bDataChanged |= Impl_GetItem( &aEdPrintArea, aPrintArea );
+ }
+
+ //-------------------------------
+ // Wiederholungszeile veraendert?
+ //-------------------------------
+ bDataChanged |= Impl_GetItem( &aEdRepeatRow, aRepeatRow );
+
+ //--------------------------------
+ // Wiederholungsspalte veraendert?
+ //--------------------------------
+ bDataChanged |= Impl_GetItem( &aEdRepeatCol, aRepeatCol );
+
+ if ( bDataChanged )
+ {
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( SID_CHANGE_PRINTAREA,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aPrintArea, &aRepeatRow, &aRepeatCol, &aEntireSheet, 0L );
+ }
+
+ Close();
+ }
+ }
+ else if ( &aBtnCancel == pBtn )
+ Close();
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScPrintAreasDlg, Impl_GetFocusHdl, Control*, pCtr )
+{
+ if ( pCtr ==(Control *) &aEdPrintArea ||
+ pCtr ==(Control *) &aEdRepeatRow ||
+ pCtr ==(Control *) &aEdRepeatCol)
+ {
+ pRefInputEdit = (formula::RefEdit*) pCtr;
+ }
+ else if ( pCtr ==(Control *) &aLbPrintArea)
+ {
+ pRefInputEdit = &aEdPrintArea;
+ }
+ else if ( pCtr ==(Control *) &aLbRepeatRow)
+ {
+ pRefInputEdit = &aEdRepeatRow;
+ }
+ else if ( pCtr ==(Control *) &aLbRepeatCol)
+ {
+ pRefInputEdit = &aEdRepeatCol;
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScPrintAreasDlg, Impl_SelectHdl, ListBox*, pLb )
+{
+ USHORT nSelPos = pLb->GetSelectEntryPos();
+ Edit* pEd = NULL;
+
+ // list box positions of specific entries, default to "repeat row/column" list boxes
+ USHORT nAllSheetPos = SC_AREASDLG_RR_NONE;
+ USHORT nUserDefPos = SC_AREASDLG_RR_USER;
+ USHORT nFirstCustomPos = SC_AREASDLG_RR_OFFSET;
+
+ // find edit field for list box, and list box positions
+ if( pLb == &aLbPrintArea )
+ {
+ pEd = &aEdPrintArea;
+ nAllSheetPos = SC_AREASDLG_PR_ENTIRE;
+ nUserDefPos = SC_AREASDLG_PR_USER;
+ nFirstCustomPos = SC_AREASDLG_PR_SELECT; // "Selection" and following
+ }
+ else if( pLb == &aLbRepeatCol )
+ pEd = &aEdRepeatCol;
+ else if( pLb == &aLbRepeatRow )
+ pEd = &aEdRepeatRow;
+ else
+ return 0;
+
+ // fill edit field according to list box selection
+ if( (nSelPos == 0) || (nSelPos == nAllSheetPos) )
+ pEd->SetText( EMPTY_STRING );
+ else if( nSelPos == nUserDefPos && !pLb->IsTravelSelect() && pEd->GetText().Len() == 0 )
+ pLb->SelectEntryPos( 0 );
+ else if( nSelPos >= nFirstCustomPos )
+ pEd->SetText( *static_cast< String* >( pLb->GetEntryData( nSelPos ) ) );
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScPrintAreasDlg, Impl_ModifyHdl, formula::RefEdit*, pEd )
+{
+ ListBox* pLb = NULL;
+
+ // list box positions of specific entries, default to "repeat row/column" list boxes
+ USHORT nUserDefPos = SC_AREASDLG_RR_USER;
+ USHORT nFirstCustomPos = SC_AREASDLG_RR_OFFSET;
+
+ if( pEd == &aEdPrintArea )
+ {
+ pLb = &aLbPrintArea;
+ nUserDefPos = SC_AREASDLG_PR_USER;
+ nFirstCustomPos = SC_AREASDLG_PR_SELECT; // "Selection" and following
+ }
+ else if( pEd == &aEdRepeatCol )
+ pLb = &aLbRepeatCol;
+ else if( pEd == &aEdRepeatRow )
+ pLb = &aLbRepeatRow;
+ else
+ return 0;
+
+ // set list box selection according to edit field
+ USHORT nEntryCount = pLb->GetEntryCount();
+ String aStrEd( pEd->GetText() );
+ String aEdUpper = aStrEd;
+ aEdUpper.ToUpperAscii();
+
+ if ( (nEntryCount > nFirstCustomPos) && aStrEd.Len() > 0 )
+ {
+ BOOL bFound = FALSE;
+ String* pSymbol = NULL;
+ USHORT i;
+
+ for ( i=nFirstCustomPos; i<nEntryCount && !bFound; i++ )
+ {
+ pSymbol = (String*)pLb->GetEntryData( i );
+ bFound = ( (*pSymbol == aStrEd) || (*pSymbol == aEdUpper) );
+ }
+
+ pLb->SelectEntryPos( bFound ? i-1 : nUserDefPos );
+ }
+ else
+ pLb->SelectEntryPos( aStrEd.Len() ? nUserDefPos : 0 );
+
+ return 0;
+}
+
+
+//============================================================================
+// globale Funktionen:
+
+// ----------------------------------------------------------------------------
+
+// TODO: It might make sense to move these functions to address.?xx. -kohei
+
+bool lcl_CheckOne_OOO( const String& rStr, bool bIsRow, SCCOLROW& rVal )
+{
+ // Zulaessige Syntax fuer rStr:
+ // Row: [$]1-MAXTAB
+ // Col: [$]A-IV
+
+ String aStr = rStr;
+ xub_StrLen nLen = aStr.Len();
+ SCCOLROW nNum = 0;
+ BOOL bStrOk = ( nLen > 0 ) && ( bIsRow ? ( nLen < 6 ) : ( nLen < 4 ) );
+
+ if ( bStrOk )
+ {
+ if ( '$' == aStr.GetChar(0) )
+ aStr.Erase( 0, 1 );
+
+ if ( bIsRow )
+ {
+ bStrOk = CharClass::isAsciiNumeric(aStr);
+
+ if ( bStrOk )
+ {
+ sal_Int32 n = aStr.ToInt32();
+
+ if ( ( bStrOk = (n > 0) && ( n <= MAXROWCOUNT ) ) != FALSE )
+ nNum = static_cast<SCCOLROW>(n - 1);
+ }
+ }
+ else
+ {
+ SCCOL nCol = 0;
+ bStrOk = ::AlphaToCol( nCol, aStr);
+ nNum = nCol;
+ }
+ }
+
+ if ( bStrOk )
+ rVal = nNum;
+
+ return bStrOk;
+}
+
+bool lcl_CheckOne_XL_A1( const String& rStr, bool bIsRow, SCCOLROW& rVal )
+{
+ // XL A1 style is identical to OOO one for print range formats.
+ return lcl_CheckOne_OOO(rStr, bIsRow, rVal);
+}
+
+bool lcl_CheckOne_XL_R1C1( const String& rStr, bool bIsRow, SCCOLROW& rVal )
+{
+ xub_StrLen nLen = rStr.Len();
+ if (nLen <= 1)
+ // There must be at least two characters.
+ return false;
+
+ const sal_Unicode preUpper = bIsRow ? 'R' : 'C';
+ const sal_Unicode preLower = bIsRow ? 'r' : 'c';
+ if (rStr.GetChar(0) != preUpper && rStr.GetChar(0) != preLower)
+ return false;
+
+ String aNumStr = rStr.Copy(1);
+ if (!CharClass::isAsciiNumeric(aNumStr))
+ return false;
+
+ sal_Int32 nNum = aNumStr.ToInt32();
+
+ if (nNum <= 0)
+ return false;
+
+ if ((bIsRow && nNum > MAXROWCOUNT) || (!bIsRow && nNum > MAXCOLCOUNT))
+ return false;
+
+ rVal = static_cast<SCCOLROW>(nNum-1);
+ return true;
+}
+
+bool lcl_CheckRepeatOne( const String& rStr, formula::FormulaGrammar::AddressConvention eConv, bool bIsRow, SCCOLROW& rVal )
+{
+ switch (eConv)
+ {
+ case formula::FormulaGrammar::CONV_OOO:
+ return lcl_CheckOne_OOO(rStr, bIsRow, rVal);
+ case formula::FormulaGrammar::CONV_XL_A1:
+ return lcl_CheckOne_XL_A1(rStr, bIsRow, rVal);
+ case formula::FormulaGrammar::CONV_XL_R1C1:
+ return lcl_CheckOne_XL_R1C1(rStr, bIsRow, rVal);
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ return false;
+}
+
+bool lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange )
+{
+ // Row: [valid row] rsep [valid row]
+ // Col: [valid col] rsep [valid col]
+
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ const sal_Unicode rsep = ScCompiler::GetNativeSymbol(ocRange).GetChar(0);
+
+ if (pRange)
+ {
+ // initialize the range value.
+ pRange->aStart.SetCol(0);
+ pRange->aStart.SetRow(0);
+ pRange->aEnd.SetCol(0);
+ pRange->aEnd.SetRow(0);
+ }
+
+ String aBuf;
+ SCCOLROW nVal = 0;
+ xub_StrLen nLen = rStr.Len();
+ bool bEndPos = false;
+ for (xub_StrLen i = 0; i < nLen; ++i)
+ {
+ const sal_Unicode c = rStr.GetChar(i);
+ if (c == rsep)
+ {
+ if (bEndPos)
+ // We aren't supposed to have more than one range separator.
+ return false;
+
+ // range separator
+ if (aBuf.Len() == 0)
+ return false;
+
+ bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal);
+ if (!bRes)
+ return false;
+
+ if (pRange)
+ {
+ if (bIsRow)
+ {
+ pRange->aStart.SetRow(static_cast<SCROW>(nVal));
+ pRange->aEnd.SetRow(static_cast<SCROW>(nVal));
+ }
+ else
+ {
+ pRange->aStart.SetCol(static_cast<SCCOL>(nVal));
+ pRange->aEnd.SetCol(static_cast<SCCOL>(nVal));
+ }
+ }
+
+ aBuf.Erase();
+ bEndPos = true;
+ }
+ else
+ aBuf.Append(c);
+ }
+
+ if (aBuf.Len() > 0)
+ {
+ bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal);
+ if (!bRes)
+ return false;
+
+ if (pRange)
+ {
+ if (bIsRow)
+ {
+ if (!bEndPos)
+ pRange->aStart.SetRow(static_cast<SCROW>(nVal));
+ pRange->aEnd.SetRow(static_cast<SCROW>(nVal));
+ }
+ else
+ {
+ if (!bEndPos)
+ pRange->aStart.SetCol(static_cast<SCCOL>(nVal));
+ pRange->aEnd.SetCol(static_cast<SCCOL>(nVal));
+ }
+ }
+ }
+
+ return true;
+}
+
+// ----------------------------------------------------------------------------
+
+void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr )
+{
+ rStr.Erase();
+ if (!pRange)
+ return;
+
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ const ScAddress& rStart = pRange->aStart;
+ const ScAddress& rEnd = pRange->aEnd;
+
+ const USHORT nFmt = bIsRow ? (SCA_VALID_ROW | SCA_ROW_ABSOLUTE) : (SCA_VALID_COL | SCA_COL_ABSOLUTE);
+ String aTmpStr;
+ rStart.Format(aTmpStr, nFmt, pDoc, eConv);
+ rStr += aTmpStr;
+ if ((bIsRow && rStart.Row() != rEnd.Row()) || (!bIsRow && rStart.Col() != rEnd.Col()))
+ {
+ rStr += ScCompiler::GetNativeSymbol(ocRange);
+ rEnd.Format(aTmpStr, nFmt, pDoc, eConv);
+ rStr += aTmpStr;
+ }
+}
+
diff --git a/sc/source/ui/src/sc.src b/sc/source/ui/src/sc.src index eb5dd48c94b4..4f1510582288 100644 --- a/sc/source/ui/src/sc.src +++ b/sc/source/ui/src/sc.src @@ -44,41 +44,6 @@ String RID_APPTITLE // Icons & Bitmaps: ---------------------------------------------------------- -Image RID_BMP_REFBTN1 -{ - ImageBitmap = Bitmap - { - File = "refinp1.bmp"; - }; - MaskColor = STD_MASKCOLOR; -}; - -Image RID_BMP_REFBTN1_H -{ - ImageBitmap = Bitmap - { - File = "refinp1_h.bmp"; - }; - MaskColor = SC_HC_MASKCOLOR; -}; - -Image RID_BMP_REFBTN2 -{ - ImageBitmap = Bitmap - { - File = "refinp2.bmp"; - }; - MaskColor = STD_MASKCOLOR; -}; - -Image RID_BMP_REFBTN2_H -{ - ImageBitmap = Bitmap - { - File = "refinp2_h.bmp"; - }; - MaskColor = SC_HC_MASKCOLOR; -}; // ??? diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src index bb73e6fd52d8..ed6273e26ae4 100644 --- a/sc/source/ui/src/scfuncs.src +++ b/sc/source/ui/src/scfuncs.src @@ -82,7 +82,7 @@ // resource entries must consider this and undo the conversion. #include "scfuncs.hrc" // ID_FUNCTION_GRP_XXX, HID_FUNC_XXX -#include "compiler.hrc" // SC_OPCODE_XXX +#include "formula/compiler.hrc" // SC_OPCODE_XXX Resource RID_SC_FUNCTION_DESCRIPTIONS1 { diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index 502554bc6a9f..d3ff10783c27 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -1553,7 +1553,7 @@ String __EXPORT ScUndoLayoutRTL::GetComment() const // ScUndoSetGrammar::ScUndoSetGrammar( ScDocShell* pShell, - ScGrammar::Grammar eGrammar ) : + formula::FormulaGrammar::Grammar eGrammar ) : ScSimpleUndo( pShell ), meNewGrammar( eGrammar ) { @@ -1564,7 +1564,7 @@ __EXPORT ScUndoSetGrammar::~ScUndoSetGrammar() { } -void ScUndoSetGrammar::DoChange( ScGrammar::Grammar eGrammar ) +void ScUndoSetGrammar::DoChange( formula::FormulaGrammar::Grammar eGrammar ) { pDocShell->SetInUndo( TRUE ); ScDocument* pDoc = pDocShell->GetDocument(); diff --git a/sc/source/ui/unoobj/appluno.cxx b/sc/source/ui/unoobj/appluno.cxx index 7b1e02b65020..1c97f7d72078 100644 --- a/sc/source/ui/unoobj/appluno.cxx +++ b/sc/source/ui/unoobj/appluno.cxx @@ -36,9 +36,7 @@ #include <osl/diagnose.h> #include <cppuhelper/factory.hxx> -#ifndef _SFX_APP_HXX #include <sfx2/app.hxx> -#endif #include <sfx2/sfxmodelfactory.hxx> #include "afmtuno.hxx" #include "funcuno.hxx" @@ -49,9 +47,7 @@ #include "inputopt.hxx" #include "printopt.hxx" #include "userlist.hxx" -#ifndef SC_SC_HRC #include "sc.hrc" // VAR_ARGS -#endif #include "unoguard.hxx" #include "unonames.hxx" #include "funcdesc.hxx" @@ -478,7 +474,6 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( ScDocument_createInstance, ScDocument_getSupportedServiceNames() )); - void* pRet = NULL; if (xFactory.is()) { @@ -870,7 +865,7 @@ uno::Sequence<rtl::OUString> ScFunctionListObj::getSupportedServiceNames_Static( static void lcl_FillSequence( uno::Sequence<beans::PropertyValue>& rSequence, const ScFuncDesc& rDesc ) { - rDesc.InitArgumentInfo(); // full argument info is needed + rDesc.initArgumentInfo(); // full argument info is needed DBG_ASSERT( rSequence.getLength() == SC_FUNCDESC_PROPCOUNT, "Falscher Count" ); diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 9c3cdde04756..a4eaacd46563 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -122,9 +122,9 @@ #include "rangeseq.hxx" #include "unowids.hxx" #include "paramisc.hxx" -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" #include "unoreflist.hxx" -#include "grammar.hxx" +#include "formula/grammar.hxx" #include <list> @@ -1218,7 +1218,7 @@ BOOL lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange, BOOL lcl_PutFormulaArray( ScDocShell& rDocShell, const ScRange& rRange, const uno::Sequence< uno::Sequence<rtl::OUString> >& aData, - const ScGrammar::Grammar eGrammar ) + const formula::FormulaGrammar::Grammar eGrammar ) { // BOOL bApi = TRUE; @@ -1318,7 +1318,7 @@ String lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPosition, BOOL bE if ( eType == CELLTYPE_FORMULA ) { ScFormulaCell* pForm = (ScFormulaCell*)pCell; - pForm->GetFormula( aVal, ScGrammar::mapAPItoGrammar( bEnglish, false)); + pForm->GetFormula( aVal,formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false)); } else { @@ -2080,9 +2080,9 @@ uno::Any SAL_CALL ScCellRangesBase::getPropertyDefault( const rtl::OUString& aPr { BOOL bEnglish = ( pMap->nWID != SC_WID_UNO_CONDLOC ); BOOL bXML = ( pMap->nWID == SC_WID_UNO_CONDXML ); - ScGrammar::Grammar eGrammar = (bXML ? + formula::FormulaGrammar::Grammar eGrammar = (bXML ? pDoc->GetStorageGrammar() : - ScGrammar::mapAPItoGrammar( bEnglish, bXML)); + formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML)); aAny <<= uno::Reference<sheet::XSheetConditionalEntries>( new ScTableConditionalFormat( pDoc, 0, eGrammar )); @@ -2094,9 +2094,9 @@ uno::Any SAL_CALL ScCellRangesBase::getPropertyDefault( const rtl::OUString& aPr { BOOL bEnglish = ( pMap->nWID != SC_WID_UNO_VALILOC ); BOOL bXML = ( pMap->nWID == SC_WID_UNO_VALIXML ); - ScGrammar::Grammar eGrammar = (bXML ? + formula::FormulaGrammar::Grammar eGrammar = (bXML ? pDoc->GetStorageGrammar() : - ScGrammar::mapAPItoGrammar( bEnglish, bXML)); + formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML)); aAny <<= uno::Reference<beans::XPropertySet>( new ScTableValidationObj( pDoc, 0, eGrammar )); @@ -2336,9 +2336,9 @@ void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertyMap* pMap, cons ScDocument* pDoc = pDocShell->GetDocument(); BOOL bEnglish = ( pMap->nWID != SC_WID_UNO_CONDLOC ); BOOL bXML = ( pMap->nWID == SC_WID_UNO_CONDXML ); - ScGrammar::Grammar eGrammar = (bXML ? - ScGrammar::GRAM_UNSPECIFIED : - ScGrammar::mapAPItoGrammar( bEnglish, bXML)); + formula::FormulaGrammar::Grammar eGrammar = (bXML ? + formula::FormulaGrammar::GRAM_UNSPECIFIED : + formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML)); ScConditionalFormat aNew( 0, pDoc ); // Index wird beim Einfuegen gesetzt pFormat->FillFormat( aNew, pDoc, eGrammar ); @@ -2367,9 +2367,9 @@ void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertyMap* pMap, cons ScDocument* pDoc = pDocShell->GetDocument(); BOOL bEnglish = ( pMap->nWID != SC_WID_UNO_VALILOC ); BOOL bXML = ( pMap->nWID == SC_WID_UNO_VALIXML ); - ScGrammar::Grammar eGrammar = (bXML ? - ScGrammar::GRAM_UNSPECIFIED : - ScGrammar::mapAPItoGrammar( bEnglish, bXML)); + formula::FormulaGrammar::Grammar eGrammar = (bXML ? + formula::FormulaGrammar::GRAM_UNSPECIFIED : + formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML)); ScValidationData* pNewData = pValidObj->CreateValidationData( pDoc, eGrammar ); @@ -2501,9 +2501,9 @@ void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertyMap* pMap, ScDocument* pDoc = pDocShell->GetDocument(); BOOL bEnglish = ( pMap->nWID != SC_WID_UNO_CONDLOC ); BOOL bXML = ( pMap->nWID == SC_WID_UNO_CONDXML ); - ScGrammar::Grammar eGrammar = (bXML ? + formula::FormulaGrammar::Grammar eGrammar = (bXML ? pDoc->GetStorageGrammar() : - ScGrammar::mapAPItoGrammar( bEnglish, bXML)); + formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML)); ULONG nIndex = ((const SfxUInt32Item&) pPattern->GetItem(ATTR_CONDITIONAL)).GetValue(); rAny <<= uno::Reference<sheet::XSheetConditionalEntries>( @@ -2521,9 +2521,9 @@ void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertyMap* pMap, ScDocument* pDoc = pDocShell->GetDocument(); BOOL bEnglish = ( pMap->nWID != SC_WID_UNO_VALILOC ); BOOL bXML = ( pMap->nWID == SC_WID_UNO_VALIXML ); - ScGrammar::Grammar eGrammar = (bXML ? + formula::FormulaGrammar::Grammar eGrammar = (bXML ? pDoc->GetStorageGrammar() : - ScGrammar::mapAPItoGrammar( bEnglish, bXML)); + formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML)); ULONG nIndex = ((const SfxUInt32Item&) pPattern->GetItem(ATTR_VALIDDATA)).GetValue(); rAny <<= uno::Reference<beans::XPropertySet>( @@ -5122,7 +5122,7 @@ rtl::OUString SAL_CALL ScCellRangeObj::getArrayFormula() throw(uno::RuntimeExcep } void ScCellRangeObj::SetArrayFormula_Impl( const rtl::OUString& aFormula, - const ScGrammar::Grammar eGrammar ) throw(uno::RuntimeException) + const formula::FormulaGrammar::Grammar eGrammar ) throw(uno::RuntimeException) { ScDocShell* pDocSh = GetDocShell(); if (pDocSh) @@ -5155,11 +5155,11 @@ void SAL_CALL ScCellRangeObj::setArrayFormula( const rtl::OUString& aFormula ) { ScUnoGuard aGuard; // GRAM_PODF_A1 for API compatibility. - SetArrayFormula_Impl( aFormula, ScGrammar::GRAM_PODF_A1); + SetArrayFormula_Impl( aFormula,formula::FormulaGrammar::GRAM_PODF_A1); } void ScCellRangeObj::SetArrayFormulaWithGrammar( const rtl::OUString& aFormula, - const ScGrammar::Grammar eGrammar ) throw(uno::RuntimeException) + const formula::FormulaGrammar::Grammar eGrammar ) throw(uno::RuntimeException) { ScUnoGuard aGuard; SetArrayFormula_Impl( aFormula, eGrammar); @@ -5222,7 +5222,7 @@ void SAL_CALL ScCellRangeObj::setArrayTokens( const uno::Sequence<sheet::Formula // Actually GRAM_PODF_A1 is a don't-care here because of the token // array being set, it fits with other API compatibility grammars // though. - aFunc.EnterMatrix( aRange, NULL, &aTokenArray, EMPTY_STRING, TRUE, TRUE, ScGrammar::GRAM_PODF_A1 ); + aFunc.EnterMatrix( aRange, NULL, &aTokenArray, EMPTY_STRING, TRUE, TRUE,formula::FormulaGrammar::GRAM_PODF_A1 ); } else { @@ -5338,7 +5338,7 @@ void SAL_CALL ScCellRangeObj::setFormulaArray( if (pDocSh) { // GRAM_PODF_A1 for API compatibility. - bDone = lcl_PutFormulaArray( *pDocSh, aRange, aArray, ScGrammar::GRAM_PODF_A1 ); + bDone = lcl_PutFormulaArray( *pDocSh, aRange, aArray,formula::FormulaGrammar::GRAM_PODF_A1 ); } if (!bDone) @@ -6268,7 +6268,7 @@ void ScCellObj::SetString_Impl(const String& rString, BOOL bInterpret, BOOL bEng { ScDocFunc aFunc(*pDocSh); // GRAM_PODF_A1 for API compatibility. - (void)aFunc.SetCellText( aCellPos, rString, bInterpret, bEnglish, TRUE, ScGrammar::GRAM_PODF_A1 ); + (void)aFunc.SetCellText( aCellPos, rString, bInterpret, bEnglish, TRUE,formula::FormulaGrammar::GRAM_PODF_A1 ); } } @@ -6316,7 +6316,7 @@ void ScCellObj::SetFormulaResultDouble( double fResult ) } void ScCellObj::SetFormulaWithGrammar( const ::rtl::OUString& rFormula, - const ScGrammar::Grammar eGrammar ) + const formula::FormulaGrammar::Grammar eGrammar ) { ScDocShell* pDocSh = GetDocShell(); if ( pDocSh ) diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx index 20560509e669..759d723aa020 100644 --- a/sc/source/ui/unoobj/fmtuno.cxx +++ b/sc/source/ui/unoobj/fmtuno.cxx @@ -135,7 +135,7 @@ ScConditionMode lcl_ConditionOperatorToMode( sheet::ConditionOperator eOper ) //UNUSED2008-05 } ScTableConditionalFormat::ScTableConditionalFormat(ScDocument* pDoc, ULONG nKey, - const ScGrammar::Grammar eGrammar) + const formula::FormulaGrammar::Grammar eGrammar) { // Eintrag aus dem Dokument lesen... @@ -167,7 +167,7 @@ ScTableConditionalFormat::ScTableConditionalFormat(ScDocument* pDoc, ULONG nKey, } void ScTableConditionalFormat::FillFormat( ScConditionalFormat& rFormat, - ScDocument* pDoc, ScGrammar::Grammar eGrammar ) const + ScDocument* pDoc, formula::FormulaGrammar::Grammar eGrammar ) const { // ScConditionalFormat = Core-Struktur, muss leer sein @@ -181,12 +181,12 @@ void ScTableConditionalFormat::FillFormat( ScConditionalFormat& rFormat, ScCondFormatEntryItem aData; pEntry->GetData(aData); - if (eGrammar == ScGrammar::GRAM_UNSPECIFIED) + if (eGrammar == formula::FormulaGrammar::GRAM_UNSPECIFIED) eGrammar = aData.meGrammar; - if (eGrammar == ScGrammar::GRAM_UNSPECIFIED) + if (eGrammar == formula::FormulaGrammar::GRAM_UNSPECIFIED) { DBG_ERRORFILE("FillFormat: unspecified grammar, using GRAM_PODF_A1"); - eGrammar = ScGrammar::GRAM_PODF_A1; + eGrammar = formula::FormulaGrammar::GRAM_PODF_A1; } ScCondFormatEntry aCoreEntry( static_cast<ScConditionMode>(aData.mnMode), aData.maExpr1, aData.maExpr2, pDoc, aData.maPos, aData.maStyle, eGrammar ); @@ -306,7 +306,7 @@ void SAL_CALL ScTableConditionalFormat::addNew( { sal_Int32 nVal = 0; if ( rProp.Value >>= nVal ) - aEntry.meGrammar = static_cast<ScGrammar::Grammar>(nVal); + aEntry.meGrammar = static_cast<formula::FormulaGrammar::Grammar>(nVal); } else { @@ -599,14 +599,8 @@ void SAL_CALL ScTableConditionalEntry::setStyleName( const rtl::OUString& aStyle //------------------------------------------------------------------------ -//UNUSED2008-05 ScTableValidationObj::ScTableValidationObj() : -//UNUSED2008-05 aPropSet( lcl_GetValidatePropertyMap() ), -//UNUSED2008-05 meGrammar( ScGrammar::GRAM_UNSPECIFIED ) -//UNUSED2008-05 { -//UNUSED2008-05 } - ScTableValidationObj::ScTableValidationObj(ScDocument* pDoc, ULONG nKey, - const ScGrammar::Grammar eGrammar) : + const formula::FormulaGrammar::Grammar eGrammar) : aPropSet( lcl_GetValidatePropertyMap() ) { // Eintrag aus dem Dokument lesen... @@ -638,16 +632,16 @@ ScTableValidationObj::ScTableValidationObj(ScDocument* pDoc, ULONG nKey, } ScValidationData* ScTableValidationObj::CreateValidationData( ScDocument* pDoc, - ScGrammar::Grammar eGrammar ) const + formula::FormulaGrammar::Grammar eGrammar ) const { // ScValidationData = Core-Struktur - if (eGrammar == ScGrammar::GRAM_UNSPECIFIED) + if (eGrammar == formula::FormulaGrammar::GRAM_UNSPECIFIED) eGrammar = meGrammar; - if (eGrammar == ScGrammar::GRAM_UNSPECIFIED) + if (eGrammar == formula::FormulaGrammar::GRAM_UNSPECIFIED) { DBG_ERRORFILE("CreateValidationData: unspecified grammar, using GRAM_PODF_A1"); - eGrammar = ScGrammar::GRAM_PODF_A1; + eGrammar = formula::FormulaGrammar::GRAM_PODF_A1; } ScValidationData* pRet = new ScValidationData( (ScValidationMode)nValMode, @@ -697,7 +691,7 @@ void ScTableValidationObj::ClearData_Impl() aSrcPos.Set(0,0,0); aExpr1.Erase(); aExpr2.Erase(); - meGrammar = ScGrammar::GRAM_UNSPECIFIED; // will be overriden when needed + meGrammar = formula::FormulaGrammar::GRAM_UNSPECIFIED; // will be overriden when needed aInputTitle.Erase(); aInputMessage.Erase(); aErrorTitle.Erase(); @@ -906,7 +900,7 @@ void SAL_CALL ScTableValidationObj::setPropertyValue( sal_Int32 nVal = 0; if ( aValue >>= nVal ) - meGrammar = static_cast<ScGrammar::Grammar>(nVal); + meGrammar = static_cast<formula::FormulaGrammar::Grammar>(nVal); } DataChanged(); diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index 41b0de34840b..8e56ceedf616 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -44,7 +44,7 @@ #include "scdll.hxx" #include "document.hxx" #include "compiler.hxx" -#include "errorcodes.hxx" +#include "formula/errorcodes.hxx" #include "callform.hxx" #include "addincol.hxx" #include "rangeseq.hxx" @@ -318,7 +318,7 @@ SC_IMPL_DUMMY_PROPERTY_LISTENER( ScFunctionAccess ) // XFunctionAccess -BOOL lcl_AddFunctionToken( ScTokenArray& rArray, const rtl::OUString& rName ) +BOOL lcl_AddFunctionToken( ScTokenArray& rArray, const rtl::OUString& rName,const ScCompiler& rCompiler ) { // function names are always case-insensitive String aUpper( ScGlobal::pCharClass->upper( rName ) ); @@ -326,7 +326,7 @@ BOOL lcl_AddFunctionToken( ScTokenArray& rArray, const rtl::OUString& rName ) // same options as in ScCompiler::IsOpCode: // 1. built-in function name - OpCode eOp = ScCompiler::GetEnglishOpCode( aUpper ); + OpCode eOp = rCompiler.GetEnglishOpCode( aUpper ); if ( eOp != ocNone ) { rArray.AddOpCode( eOp ); @@ -512,15 +512,19 @@ uno::Any SAL_CALL ScFunctionAccess::callFunction( const rtl::OUString& aName, if ( !pDoc->HasTable( nTempSheet ) ) pDoc->MakeTable( nTempSheet ); - if (!ScCompiler::IsInitialized()) - ScCompiler::InitSymbolsEnglish(); + /// TODO: check + ScAddress aAdr; + ScCompiler aCompiler(pDoc,aAdr); + aCompiler.SetGrammar(pDoc->GetGrammar()); + //if (!ScCompiler::IsInitialized()) + // ScCompiler::InitSymbolsEnglish(); // // find function // ScTokenArray aTokenArr; - if ( !lcl_AddFunctionToken( aTokenArr, aName ) ) + if ( !lcl_AddFunctionToken( aTokenArr, aName,aCompiler ) ) { // function not found throw container::NoSuchElementException(); @@ -648,7 +652,7 @@ uno::Any SAL_CALL ScFunctionAccess::callFunction( const rtl::OUString& aName, // GRAM_PODF_A1 doesn't really matter for the token array but fits with // other API compatibility grammars. ScFormulaCell* pFormula = new ScFormulaCell( pDoc, aFormulaPos, - &aTokenArr, ScGrammar::GRAM_PODF_A1, MM_FORMULA ); + &aTokenArr,formula::FormulaGrammar::GRAM_PODF_A1, MM_FORMULA ); pDoc->PutCell( aFormulaPos, pFormula ); //! necessary? // call GetMatrix before GetErrCode because GetMatrix always recalculates diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx index 4e114b53954d..823a088ba3d3 100644 --- a/sc/source/ui/unoobj/nameuno.cxx +++ b/sc/source/ui/unoobj/nameuno.cxx @@ -138,7 +138,7 @@ ScRangeData* ScNamedRangeObj::GetRangeData_Impl() void ScNamedRangeObj::Modify_Impl( const String* pNewName, const ScTokenArray* pNewTokens, const String* pNewContent, const ScAddress* pNewPos, const sal_uInt16* pNewType, - const ScGrammar::Grammar eGrammar ) + const formula::FormulaGrammar::Grammar eGrammar ) { if (pDocShell) { @@ -206,7 +206,7 @@ void SAL_CALL ScNamedRangeObj::setName( const rtl::OUString& aNewName ) String aNewStr(aNewName); // GRAM_PODF_A1 for API compatibility. - Modify_Impl( &aNewStr, NULL, NULL, NULL, NULL, ScGrammar::GRAM_PODF_A1 ); + Modify_Impl( &aNewStr, NULL, NULL, NULL, NULL,formula::FormulaGrammar::GRAM_PODF_A1 ); if ( aName != aNewStr ) // some error occured... throw uno::RuntimeException(); // no other exceptions specified @@ -219,7 +219,7 @@ rtl::OUString SAL_CALL ScNamedRangeObj::getContent() throw(uno::RuntimeException ScRangeData* pData = GetRangeData_Impl(); if (pData) // GRAM_PODF_A1 for API compatibility. - pData->GetSymbol( aContent, ScGrammar::GRAM_PODF_A1); + pData->GetSymbol( aContent,formula::FormulaGrammar::GRAM_PODF_A1); return aContent; } @@ -229,11 +229,11 @@ void SAL_CALL ScNamedRangeObj::setContent( const rtl::OUString& aContent ) ScUnoGuard aGuard; String aContStr(aContent); // GRAM_PODF_A1 for API compatibility. - Modify_Impl( NULL, NULL, &aContStr, NULL, NULL, ScGrammar::GRAM_PODF_A1 ); + Modify_Impl( NULL, NULL, &aContStr, NULL, NULL,formula::FormulaGrammar::GRAM_PODF_A1 ); } void ScNamedRangeObj::SetContentWithGrammar( const ::rtl::OUString& aContent, - const ScGrammar::Grammar eGrammar ) + const formula::FormulaGrammar::Grammar eGrammar ) throw(::com::sun::star::uno::RuntimeException) { String aContStr(aContent); @@ -272,7 +272,7 @@ void SAL_CALL ScNamedRangeObj::setReferencePosition( const table::CellAddress& a ScUnoGuard aGuard; ScAddress aPos( (SCCOL)aReferencePosition.Column, (SCROW)aReferencePosition.Row, aReferencePosition.Sheet ); // GRAM_PODF_A1 for API compatibility. - Modify_Impl( NULL, NULL, NULL, &aPos, NULL, ScGrammar::GRAM_PODF_A1 ); + Modify_Impl( NULL, NULL, NULL, &aPos, NULL,formula::FormulaGrammar::GRAM_PODF_A1 ); } sal_Int32 SAL_CALL ScNamedRangeObj::getType() throw(uno::RuntimeException) @@ -303,7 +303,7 @@ void SAL_CALL ScNamedRangeObj::setType( sal_Int32 nUnoType ) throw(uno::RuntimeE if ( nUnoType & sheet::NamedRangeFlag::ROW_HEADER ) nNewType |= RT_ROWHEADER; // GRAM_PODF_A1 for API compatibility. - Modify_Impl( NULL, NULL, NULL, NULL, &nNewType, ScGrammar::GRAM_PODF_A1 ); + Modify_Impl( NULL, NULL, NULL, NULL, &nNewType,formula::FormulaGrammar::GRAM_PODF_A1 ); } // XFormulaTokens @@ -330,7 +330,7 @@ void SAL_CALL ScNamedRangeObj::setTokens( const uno::Sequence<sheet::FormulaToke ScTokenArray aTokenArray; (void)ScTokenConversion::ConvertToTokenArray( *pDocShell->GetDocument(), aTokenArray, rTokens ); // GRAM_PODF_A1 for API compatibility. - Modify_Impl( NULL, &aTokenArray, NULL, NULL, NULL, ScGrammar::GRAM_PODF_A1 ); + Modify_Impl( NULL, &aTokenArray, NULL, NULL, NULL, formula::FormulaGrammar::GRAM_PODF_A1 ); } } @@ -378,7 +378,7 @@ void SAL_CALL ScNamedRangeObj::setPropertyValue( if( aValue >>= bIsShared ) { sal_uInt16 nNewType = bIsShared ? RT_SHARED : RT_NAME; - Modify_Impl( NULL, NULL, NULL, NULL, &nNewType, ScGrammar::GRAM_PODF_A1 ); + Modify_Impl( NULL, NULL, NULL, NULL, &nNewType,formula::FormulaGrammar::GRAM_PODF_A1 ); } } } @@ -562,7 +562,7 @@ void SAL_CALL ScNamedRangesObj::addNewByName( const rtl::OUString& aName, ScRangeName* pNewRanges = new ScRangeName( *pNames ); // GRAM_PODF_A1 for API compatibility. ScRangeData* pNew = new ScRangeData( pDoc, aNameStr, aContStr, - aPos, nNewType, ScGrammar::GRAM_PODF_A1 ); + aPos, nNewType,formula::FormulaGrammar::GRAM_PODF_A1 ); if ( pNewRanges->Insert(pNew) ) { ScDocFunc aFunc(*pDocShell); diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx index 76ee5be86e0b..71f45e6ab12b 100644 --- a/sc/source/ui/unoobj/servuno.cxx +++ b/sc/source/ui/unoobj/servuno.cxx @@ -355,7 +355,13 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance( break; case SC_SERVICE_OPCODEMAPPER: - xRet.set(static_cast<sheet::XFormulaOpCodeMapper*>(new ScFormulaOpCodeMapperObj)); + { + ScDocument* pDoc = pDocShell->GetDocument(); + ScAddress aAddress; + ScCompiler* pComp = new ScCompiler(pDoc,aAddress); + pComp->SetGrammar( pDoc->GetGrammar() ); + xRet.set(static_cast<sheet::XFormulaOpCodeMapper*>(new ScFormulaOpCodeMapperObj(::std::auto_ptr<formula::FormulaCompiler> (pComp)))); + } break; } return xRet; diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx index cd4b52577367..03499ffddcbc 100644 --- a/sc/source/ui/unoobj/tokenuno.cxx +++ b/sc/source/ui/unoobj/tokenuno.cxx @@ -45,11 +45,13 @@ #include "convuno.hxx" #include "unonames.hxx" #include "unoguard.hxx" +#include "token.hxx" #include "compiler.hxx" #include "tokenarray.hxx" #include "docsh.hxx" #include "rangeseq.hxx" #include "externalrefmgr.hxx" +using namespace formula; using namespace com::sun::star; @@ -60,6 +62,7 @@ const SfxItemPropertyMap* lcl_GetFormulaParserMap() static SfxItemPropertyMap aFormulaParserMap_Impl[] = { {MAP_CHAR_LEN(SC_UNO_REFERENCEPOS), 0, &getCppuType((table::CellAddress*)0), 0, 0 }, + {MAP_CHAR_LEN(SC_UNO_COMPILEFAP), 0, &getBooleanCppuType(), 0, 0 }, {MAP_CHAR_LEN(SC_UNO_COMPILEENGLISH), 0, &getBooleanCppuType(), 0, 0 }, {MAP_CHAR_LEN(SC_UNO_IGNORELEADING), 0, &getBooleanCppuType(), 0, 0 }, {MAP_CHAR_LEN(SC_UNO_FORMULACONVENTION), 0, &getCppuType(&sheet::AddressConvention::UNSPECIFIED), 0, 0 }, @@ -77,7 +80,8 @@ ScFormulaParserObj::ScFormulaParserObj(ScDocShell* pDocSh) : mpDocShell( pDocSh ), mnConv( sheet::AddressConvention::UNSPECIFIED ), mbEnglish( false ), - mbIgnoreSpaces( true ) + mbIgnoreSpaces( true ), + mbCompileFAP( false ) { mpDocShell->GetDocument()->AddUnoObject(*this); } @@ -98,12 +102,12 @@ void ScFormulaParserObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) void ScFormulaParserObj::SetCompilerFlags( ScCompiler& rCompiler ) const { - static const ScAddress::Convention aConvMap[] = { - ScAddress::CONV_OOO, // <- AddressConvention::OOO - ScAddress::CONV_XL_A1, // <- AddressConvention::XL_A1 - ScAddress::CONV_XL_R1C1, // <- AddressConvention::XL_R1C1 - ScAddress::CONV_XL_OOX, // <- AddressConvention::XL_OOX - ScAddress::CONV_LOTUS_A1 // <- AddressConvention::LOTUS_A1 + static const formula::FormulaGrammar::AddressConvention aConvMap[] = { + formula::FormulaGrammar::CONV_OOO, // <- AddressConvention::OOO + formula::FormulaGrammar::CONV_XL_A1, // <- AddressConvention::XL_A1 + formula::FormulaGrammar::CONV_XL_R1C1, // <- AddressConvention::XL_R1C1 + formula::FormulaGrammar::CONV_XL_OOX, // <- AddressConvention::XL_OOX + formula::FormulaGrammar::CONV_LOTUS_A1 // <- AddressConvention::LOTUS_A1 }; static const sal_Int16 nConvMapCount = sizeof(aConvMap)/sizeof(aConvMap[0]); @@ -116,16 +120,18 @@ void ScFormulaParserObj::SetCompilerFlags( ScCompiler& rCompiler ) const sal_Int32 nFormulaLanguage = mbEnglish ? sheet::FormulaLanguage::ENGLISH : sheet::FormulaLanguage::NATIVE; - ScCompiler::OpCodeMapPtr xMap = ScCompiler::GetOpCodeMap( nFormulaLanguage); + ScCompiler::OpCodeMapPtr xMap = rCompiler.GetOpCodeMap( nFormulaLanguage); rCompiler.SetFormulaLanguage( xMap); } - ScAddress::Convention eConv = ScAddress::CONV_UNSPECIFIED; + formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_UNSPECIFIED; if (mnConv >= 0 && mnConv < nConvMapCount) eConv = aConvMap[mnConv]; rCompiler.SetRefConvention( eConv ); + rCompiler.SetCompileForFAP(mbCompileFAP); + rCompiler.SetExternalLinks( maExternalLinks); } @@ -138,7 +144,8 @@ uno::Sequence<sheet::FormulaToken> SAL_CALL ScFormulaParserObj::parseFormula( co if (mpDocShell) { ScDocument* pDoc = mpDocShell->GetDocument(); - ScCompiler aCompiler( pDoc, maRefPos, pDoc->GetGrammar() ); + ScCompiler aCompiler( pDoc, maRefPos); + aCompiler.SetGrammar(pDoc->GetGrammar()); SetCompilerFlags( aCompiler ); ScTokenArray* pCode = aCompiler.CompileString( aFormula ); @@ -160,7 +167,8 @@ rtl::OUString SAL_CALL ScFormulaParserObj::printFormula( const uno::Sequence<she ScDocument* pDoc = mpDocShell->GetDocument(); ScTokenArray aCode; (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aCode, aTokens ); - ScCompiler aCompiler( pDoc, maRefPos, aCode, pDoc->GetGrammar() ); + ScCompiler aCompiler( pDoc, maRefPos, aCode); + aCompiler.SetGrammar(pDoc->GetGrammar()); SetCompilerFlags( aCompiler ); rtl::OUStringBuffer aBuffer; @@ -194,6 +202,10 @@ void SAL_CALL ScFormulaParserObj::setPropertyValue( table::CellAddress aAddress; aValue >>= aAddress; ScUnoConversion::FillScAddress( maRefPos, aAddress ); + } // if ( aString.EqualsAscii( SC_UNO_REFERENCEPOS ) ) + else if ( aString.EqualsAscii( SC_UNO_COMPILEFAP ) ) + { + aValue >>= mbCompileFAP; } else if ( aString.EqualsAscii( SC_UNO_COMPILEENGLISH ) ) { @@ -204,7 +216,12 @@ void SAL_CALL ScFormulaParserObj::setPropertyValue( // because the map is const. So for performance reasons set // CompileEnglish _before_ OpCodeMap! if (mxOpCodeMap.get() && mbEnglish != bOldEnglish) - mxOpCodeMap = ScCompiler::CreateOpCodeMap( maOpCodeMapping, mbEnglish); + { + ScDocument* pDoc = mpDocShell->GetDocument(); + ScCompiler aCompiler( pDoc, maRefPos); + aCompiler.SetGrammar(pDoc->GetGrammar()); + mxOpCodeMap = aCompiler.CreateOpCodeMap( maOpCodeMapping, mbEnglish); + } } else throw lang::IllegalArgumentException(); @@ -220,7 +237,12 @@ void SAL_CALL ScFormulaParserObj::setPropertyValue( else if ( aString.EqualsAscii( SC_UNO_OPCODEMAP ) ) { if (aValue >>= maOpCodeMapping) - mxOpCodeMap = ScCompiler::CreateOpCodeMap( maOpCodeMapping, mbEnglish); + { + ScDocument* pDoc = mpDocShell->GetDocument(); + ScCompiler aCompiler( pDoc, maRefPos); + aCompiler.SetGrammar(pDoc->GetGrammar()); + mxOpCodeMap = aCompiler.CreateOpCodeMap( maOpCodeMapping, mbEnglish); + } else throw lang::IllegalArgumentException(); } @@ -240,6 +262,10 @@ uno::Any SAL_CALL ScFormulaParserObj::getPropertyValue( const rtl::OUString& aPr ScUnoGuard aGuard; uno::Any aRet; String aString(aPropertyName); + } // if ( aString.EqualsAscii( SC_UNO_REFERENCEPOS ) ) + else if ( aString.EqualsAscii( SC_UNO_COMPILEFAP ) ) + { + aRet <<= mbCompileFAP; if ( aString.EqualsAscii( SC_UNO_REFERENCEPOS ) ) { table::CellAddress aAddress; @@ -296,27 +322,6 @@ void lcl_ExternalRefToCalc( ScSingleRefData& rRef, const sheet::SingleReference& rRef.SetRelName( false ); } -void lcl_SingleRefToCalc( ScSingleRefData& rRef, const sheet::SingleReference& rAPI ) -{ - rRef.InitFlags(); - - rRef.nCol = static_cast<SCsCOL>(rAPI.Column); - rRef.nRow = static_cast<SCsROW>(rAPI.Row); - rRef.nTab = static_cast<SCsTAB>(rAPI.Sheet); - rRef.nRelCol = static_cast<SCsCOL>(rAPI.RelativeColumn); - rRef.nRelRow = static_cast<SCsROW>(rAPI.RelativeRow); - rRef.nRelTab = static_cast<SCsTAB>(rAPI.RelativeSheet); - - rRef.SetColRel( ( rAPI.Flags & sheet::ReferenceFlags::COLUMN_RELATIVE ) != 0 ); - rRef.SetRowRel( ( rAPI.Flags & sheet::ReferenceFlags::ROW_RELATIVE ) != 0 ); - rRef.SetTabRel( ( rAPI.Flags & sheet::ReferenceFlags::SHEET_RELATIVE ) != 0 ); - rRef.SetColDeleted( ( rAPI.Flags & sheet::ReferenceFlags::COLUMN_DELETED ) != 0 ); - rRef.SetRowDeleted( ( rAPI.Flags & sheet::ReferenceFlags::ROW_DELETED ) != 0 ); - rRef.SetTabDeleted( ( rAPI.Flags & sheet::ReferenceFlags::SHEET_DELETED ) != 0 ); - rRef.SetFlag3D( ( rAPI.Flags & sheet::ReferenceFlags::SHEET_3D ) != 0 ); - rRef.SetRelName( ( rAPI.Flags & sheet::ReferenceFlags::RELATIVE_NAME ) != 0 ); -} - void lcl_ExternalRefToApi( sheet::SingleReference& rAPI, const ScSingleRefData& rRef ) { rAPI.Column = rRef.nCol; @@ -361,164 +366,7 @@ void lcl_SingleRefToApi( sheet::SingleReference& rAPI, const ScSingleRefData& rR bool ScTokenConversion::ConvertToTokenArray( ScDocument& rDoc, ScTokenArray& rTokenArray, const uno::Sequence<sheet::FormulaToken>& rSequence ) { - bool bError = false; - sal_Int32 nCount = rSequence.getLength(); - for (sal_Int32 nPos=0; nPos<nCount; nPos++) - { - const sheet::FormulaToken& rAPI = rSequence[nPos]; - OpCode eOpCode = static_cast<OpCode>(rAPI.OpCode); //! assuming equal values for the moment - - uno::TypeClass eClass = rAPI.Data.getValueTypeClass(); - switch ( eClass ) - { - case uno::TypeClass_VOID: - // empty data -> use AddOpCode (does some special cases) - rTokenArray.AddOpCode( eOpCode ); - break; - case uno::TypeClass_DOUBLE: - // double is only used for "push" - if ( eOpCode == ocPush ) - rTokenArray.AddDouble( rAPI.Data.get<double>() ); - else - bError = true; - break; - case uno::TypeClass_LONG: - { - // long is svIndex, used for name / database area, or "byte" for spaces - sal_Int32 nValue = rAPI.Data.get<sal_Int32>(); - if ( eOpCode == ocName || eOpCode == ocDBArea ) - rTokenArray.AddToken( ScIndexToken( eOpCode, static_cast<USHORT>(nValue) ) ); - else if ( eOpCode == ocSpaces ) - rTokenArray.AddToken( ScByteToken( ocSpaces, static_cast<BYTE>(nValue) ) ); - else - bError = true; - } - break; - case uno::TypeClass_STRING: - { - String aStrVal( rAPI.Data.get<rtl::OUString>() ); - if ( eOpCode == ocPush ) - rTokenArray.AddString( aStrVal ); - else if ( eOpCode == ocBad ) - rTokenArray.AddBad( aStrVal ); - else if ( eOpCode == ocExternal || eOpCode == ocMacro ) - rTokenArray.AddToken( ScExternalToken( eOpCode, aStrVal ) ); - else - bError = true; // unexpected string: don't know what to do with it - } - break; - case uno::TypeClass_STRUCT: - { - uno::Type aType = rAPI.Data.getValueType(); - if ( aType.equals( cppu::UnoType<sheet::SingleReference>::get() ) ) - { - ScSingleRefData aSingleRef; - sheet::SingleReference aApiRef; - rAPI.Data >>= aApiRef; - lcl_SingleRefToCalc( aSingleRef, aApiRef ); - - if ( eOpCode == ocPush ) - rTokenArray.AddSingleReference( aSingleRef ); - else if ( eOpCode == ocColRowName ) - rTokenArray.AddColRowName( aSingleRef ); - else - bError = true; - } - else if ( aType.equals( cppu::UnoType<sheet::ComplexReference>::get() ) ) - { - ScComplexRefData aComplRef; - sheet::ComplexReference aApiRef; - rAPI.Data >>= aApiRef; - lcl_SingleRefToCalc( aComplRef.Ref1, aApiRef.Reference1 ); - lcl_SingleRefToCalc( aComplRef.Ref2, aApiRef.Reference2 ); - - if ( eOpCode == ocPush ) - rTokenArray.AddDoubleReference( aComplRef ); - else - bError = true; - } - else if ( aType.equals( cppu::UnoType<sheet::ExternalReference>::get() ) ) - { - sheet::ExternalReference aApiExtRef; - if( (eOpCode == ocPush) && (rAPI.Data >>= aApiExtRef) && (0 <= aApiExtRef.Index) && (aApiExtRef.Index <= SAL_MAX_UINT16) ) - { - sal_uInt16 nFileId = static_cast< sal_uInt16 >( aApiExtRef.Index ); - sheet::SingleReference aApiSRef; - sheet::ComplexReference aApiCRef; - ::rtl::OUString aName; - if( aApiExtRef.Reference >>= aApiSRef ) - { - // try to resolve cache index to sheet name - size_t nCacheId = static_cast< size_t >( aApiSRef.Sheet ); - String aTabName = rDoc.GetExternalRefManager()->getCacheTableName( nFileId, nCacheId ); - if( aTabName.Len() > 0 ) - { - ScSingleRefData aSingleRef; - // convert column/row settings, set sheet index to absolute - lcl_ExternalRefToCalc( aSingleRef, aApiSRef ); - rTokenArray.AddExternalSingleReference( nFileId, aTabName, aSingleRef ); - } - else - bError = true; - } - else if( aApiExtRef.Reference >>= aApiCRef ) - { - // try to resolve cache index to sheet name. - size_t nCacheId = static_cast< size_t >( aApiCRef.Reference1.Sheet ); - String aTabName = rDoc.GetExternalRefManager()->getCacheTableName( nFileId, nCacheId ); - if( aTabName.Len() > 0 ) - { - ComplRefData aComplRef; - // convert column/row settings, set sheet index to absolute - lcl_ExternalRefToCalc( aComplRef.Ref1, aApiCRef.Reference1 ); - lcl_ExternalRefToCalc( aComplRef.Ref2, aApiCRef.Reference2 ); - // NOTE: This assumes that cached sheets are in consecutive order! - aComplRef.Ref2.nTab = aComplRef.Ref1.nTab + (aApiCRef.Reference2.Sheet - aApiCRef.Reference1.Sheet); - rTokenArray.AddExternalDoubleReference( nFileId, aTabName, aComplRef ); - } - else - bError = true; - } - else if( aApiExtRef.Reference >>= aName ) - { - if( aName.getLength() > 0 ) - rTokenArray.AddExternalName( nFileId, aName ); - else - bError = true; - } - else - bError = true; - } - else - bError = true; - } - else - bError = true; // unknown struct - } - break; - case uno::TypeClass_SEQUENCE: - { - if ( eOpCode != ocPush ) - bError = true; // not an inline array - else if (!rAPI.Data.getValueType().equals( getCppuType( - (uno::Sequence< uno::Sequence< uno::Any > > *)0))) - bError = true; // unexpected sequence type - else - { - ScMatrixRef xMat = ScSequenceToMatrix::CreateMixedMatrix( rAPI.Data); - if (xMat) - rTokenArray.AddMatrix( xMat); - else - bError = true; - } - } - break; - default: - bError = true; - } - } - - return !bError; + return rTokenArray.Fill(rSequence); } // static @@ -528,13 +376,13 @@ bool ScTokenConversion::ConvertToTokenSequence( ScDocument& rDoc, bool bError = false; sal_Int32 nLen = static_cast<sal_Int32>(rTokenArray.GetLen()); - ScToken** pTokens = rTokenArray.GetArray(); + formula::FormulaToken** pTokens = rTokenArray.GetArray(); if ( pTokens ) { rSequence.realloc(nLen); for (sal_Int32 nPos=0; nPos<nLen; nPos++) { - const ScToken& rToken = *pTokens[nPos]; + const formula::FormulaToken& rToken = *pTokens[nPos]; sheet::FormulaToken& rAPI = rSequence[nPos]; OpCode eOpCode = rToken.GetOpCode(); @@ -548,10 +396,10 @@ bool ScTokenConversion::ConvertToTokenSequence( ScDocument& rDoc, else rAPI.Data.clear(); // no data break; - case svDouble: + case formula::svDouble: rAPI.Data <<= rToken.GetDouble(); break; - case svString: + case formula::svString: rAPI.Data <<= rtl::OUString( rToken.GetString() ); break; case svExternal: @@ -562,15 +410,15 @@ bool ScTokenConversion::ConvertToTokenSequence( ScDocument& rDoc, case svSingleRef: { sheet::SingleReference aSingleRef; - lcl_SingleRefToApi( aSingleRef, rToken.GetSingleRef() ); + lcl_SingleRefToApi( aSingleRef, static_cast<const ScToken&>(rToken).GetSingleRef() ); rAPI.Data <<= aSingleRef; } break; - case svDoubleRef: + case formula::svDoubleRef: { sheet::ComplexReference aCompRef; - lcl_SingleRefToApi( aCompRef.Reference1, rToken.GetSingleRef() ); - lcl_SingleRefToApi( aCompRef.Reference2, rToken.GetSingleRef2() ); + lcl_SingleRefToApi( aCompRef.Reference1, static_cast<const ScToken&>(rToken).GetSingleRef() ); + lcl_SingleRefToApi( aCompRef.Reference2, static_cast<const ScToken&>(rToken).GetSingleRef2() ); rAPI.Data <<= aCompRef; } break; @@ -578,13 +426,13 @@ bool ScTokenConversion::ConvertToTokenSequence( ScDocument& rDoc, rAPI.Data <<= static_cast<sal_Int32>( rToken.GetIndex() ); break; case svMatrix: - if (!ScRangeToSequence::FillMixedArray( rAPI.Data, rToken.GetMatrix(), true)) + if (!ScRangeToSequence::FillMixedArray( rAPI.Data, static_cast<const ScToken&>(rToken).GetMatrix(), true)) rAPI.Data.clear(); break; case svExternalSingleRef: { sheet::SingleReference aSingleRef; - lcl_ExternalRefToApi( aSingleRef, rToken.GetSingleRef() ); + lcl_ExternalRefToApi( aSingleRef, static_cast<const ScToken&>(rToken).GetSingleRef() ); size_t nCacheId; rDoc.GetExternalRefManager()->getCacheTable( rToken.GetIndex(), rToken.GetString(), false, &nCacheId ); aSingleRef.Sheet = static_cast< sal_Int32 >( nCacheId ); @@ -598,13 +446,13 @@ bool ScTokenConversion::ConvertToTokenSequence( ScDocument& rDoc, case svExternalDoubleRef: { sheet::ComplexReference aComplRef; - lcl_ExternalRefToApi( aComplRef.Reference1, rToken.GetSingleRef() ); - lcl_ExternalRefToApi( aComplRef.Reference2, rToken.GetSingleRef2() ); + lcl_ExternalRefToApi( aComplRef.Reference1, static_cast<const ScToken&>(rToken).GetSingleRef() ); + lcl_ExternalRefToApi( aComplRef.Reference2, static_cast<const ScToken&>(rToken).GetSingleRef2() ); size_t nCacheId; rDoc.GetExternalRefManager()->getCacheTable( rToken.GetIndex(), rToken.GetString(), false, &nCacheId ); aComplRef.Reference1.Sheet = static_cast< sal_Int32 >( nCacheId ); // NOTE: This assumes that cached sheets are in consecutive order! - aComplRef.Reference2.Sheet = aComplRef.Reference1.Sheet + (rToken.GetSingleRef2().nTab - rToken.GetSingleRef().nTab); + aComplRef.Reference2.Sheet = aComplRef.Reference1.Sheet + (static_cast<const ScToken&>(rToken).GetSingleRef2().nTab - static_cast<const ScToken&>(rToken).GetSingleRef().nTab); sheet::ExternalReference aExtRef; aExtRef.Index = rToken.GetIndex(); aExtRef.Reference <<= aComplRef; @@ -636,59 +484,9 @@ bool ScTokenConversion::ConvertToTokenSequence( ScDocument& rDoc, return !bError; } - - -//------------------------------------------------------------------------ - -SC_SIMPLE_SERVICE_INFO( ScFormulaOpCodeMapperObj, "ScFormulaOpCodeMapperObj", SC_SERVICENAME_OPCODEMAPPER ) - -//------------------------------------------------------------------------ - -ScFormulaOpCodeMapperObj::ScFormulaOpCodeMapperObj() +// ----------------------------------------------------------------------------- +ScFormulaOpCodeMapperObj::ScFormulaOpCodeMapperObj(::std::auto_ptr<formula::FormulaCompiler> _pCompiler) +: formula::FormulaOpCodeMapperObj(_pCompiler) { } -ScFormulaOpCodeMapperObj::~ScFormulaOpCodeMapperObj() -{ -} - - -::sal_Int32 SAL_CALL ScFormulaOpCodeMapperObj::getOpCodeExternal() - throw (::com::sun::star::uno::RuntimeException) -{ - return ocExternal; -} - - -::sal_Int32 SAL_CALL ScFormulaOpCodeMapperObj::getOpCodeUnknown() - throw (::com::sun::star::uno::RuntimeException) -{ - return ScCompiler::OpCodeMap::getOpCodeUnknown(); -} - - -::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > -SAL_CALL ScFormulaOpCodeMapperObj::getMappings( - const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rNames, - sal_Int32 nLanguage ) - throw ( ::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) -{ - ScCompiler::OpCodeMapPtr xMap = ScCompiler::GetOpCodeMap( nLanguage); - if (!xMap) - throw lang::IllegalArgumentException(); - return xMap->createSequenceOfFormulaTokens( rNames); -} - - -::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaOpCodeMapEntry > -SAL_CALL ScFormulaOpCodeMapperObj::getAvailableMappings( - sal_Int32 nLanguage, sal_Int32 nGroups ) - throw ( ::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) -{ - ScCompiler::OpCodeMapPtr xMap = ScCompiler::GetOpCodeMap( nLanguage); - if (!xMap) - throw lang::IllegalArgumentException(); - return xMap->createSequenceOfAvailableMappings( nGroups); -} diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index c1b645c33ad4..ccf4b077c755 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -1,959 +1,959 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: vbaapplication.cxx,v $ - * $Revision: 1.7 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <stdio.h> - - -#include<com/sun/star/sheet/XSpreadsheetView.hpp> -#include <com/sun/star/sheet/XSpreadsheets.hpp> -#include<com/sun/star/view/XSelectionSupplier.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include<org/openoffice/excel/XlCalculation.hpp> -#include <com/sun/star/sheet/XCellRangeReferrer.hpp> -#include <com/sun/star/sheet/XCalculatable.hpp> -#include <com/sun/star/frame/XLayoutManager.hpp> -#include <com/sun/star/task/XStatusIndicatorSupplier.hpp> -#include <com/sun/star/task/XStatusIndicator.hpp> -#include <org/openoffice/excel/XlMousePointer.hpp> -#include <com/sun/star/sheet/XNamedRanges.hpp> - -#include "vbaapplication.hxx" -#include "vbaworkbooks.hxx" -#include "vbaworkbook.hxx" -#include "vbaworksheets.hxx" -#include "vbarange.hxx" -#include "vbawsfunction.hxx" -#include "vbadialogs.hxx" -#include "vbawindow.hxx" -#include "vbawindows.hxx" -#include "vbaglobals.hxx" -#include "tabvwsh.hxx" -#include "gridwin.hxx" -#include "vbanames.hxx" -#include "vbashape.hxx" -#include "sc.hrc" - -#include <osl/file.hxx> - -#include <sfx2/request.hxx> -#include <sfx2/objsh.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/app.hxx> - -#include <toolkit/awt/vclxwindow.hxx> -#include <toolkit/helper/vclunohelper.hxx> - -#include <tools/diagnose_ex.h> - -#include <docuno.hxx> - -#include <basic/sbx.hxx> -#include <basic/sbstar.hxx> -#include <basic/sbuno.hxx> -#include <basic/sbmeth.hxx> - -using namespace ::org::openoffice; -using namespace ::com::sun::star; - -// #TODO is this defined somewhere else? -#if ( defined UNX ) || ( defined OS2 ) //unix -#define FILE_PATH_SEPERATOR "/" -#else // windows -#define FILE_PATH_SEPERATOR "\\" -#endif - -#define EXCELVERSION "11.0" - -class ActiveWorkbook : public ScVbaWorkbook -{ -protected: - virtual uno::Reference< frame::XModel > getModel() - { - return getCurrentDocument(); - } -public: - ActiveWorkbook( const uno::Reference< vba::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext) : ScVbaWorkbook( xParent, xContext ){} -}; - -ScVbaApplication::ScVbaApplication( uno::Reference<uno::XComponentContext >& xContext ): ScVbaApplication_BASE( uno::Reference< vba::XHelperInterface >(), xContext ), m_xCalculation( excel::XlCalculation::xlCalculationAutomatic ) -{ -} - -ScVbaApplication::~ScVbaApplication() -{ -} - - - -uno::Reference< excel::XWorkbook > -ScVbaApplication::getActiveWorkbook() throw (uno::RuntimeException) -{ - return new ActiveWorkbook( this, mxContext ); -} -uno::Reference< excel::XWorkbook > SAL_CALL -ScVbaApplication::getThisWorkbook() throw (uno::RuntimeException) -{ - return getActiveWorkbook(); -} - -uno::Any SAL_CALL -ScVbaApplication::getSelection() throw (uno::RuntimeException) -{ - uno::Reference< lang::XServiceInfo > xServiceInfo( getCurrentDocument()->getCurrentSelection(), uno::UNO_QUERY_THROW ); - rtl::OUString sImpementaionName = xServiceInfo->getImplementationName(); - if( sImpementaionName.equalsIgnoreAsciiCaseAscii("com.sun.star.drawing.SvxShapeCollection") ) - { - uno::Reference< drawing::XShapes > xShapes( getCurrentDocument()->getCurrentSelection(), uno::UNO_QUERY_THROW ); - uno::Reference< container::XIndexAccess > xIndexAccess( xShapes, uno::UNO_QUERY_THROW ); - uno::Reference< drawing::XShape > xShape( xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< msforms::XShape >(new ScVbaShape( this, mxContext, xShape, xShapes, ScVbaShape::getType( xShape ) ) ) ); - } - else if( xServiceInfo->supportsService( rtl::OUString::createFromAscii("com.sun.star.sheet.SheetCellRange")) || - xServiceInfo->supportsService( rtl::OUString::createFromAscii("com.sun.star.sheet.SheetCellRanges"))) - { - uno::Reference< table::XCellRange > xRange( getCurrentDocument()->getCurrentSelection(), ::uno::UNO_QUERY); - if ( !xRange.is() ) - { - uno::Reference< sheet::XSheetCellRangeContainer > xRanges( getCurrentDocument()->getCurrentSelection(), ::uno::UNO_QUERY); - if ( xRanges.is() ) - return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( this, mxContext, xRanges ) ) ); - - } - return uno::makeAny( uno::Reference< excel::XRange >(new ScVbaRange( this, mxContext, xRange ) ) ); - } - else - { - throw uno::RuntimeException( sImpementaionName + rtl::OUString::createFromAscii(" donot be surpported"), uno::Reference< uno::XInterface >() ); - } -} - -uno::Reference< excel::XRange > -ScVbaApplication::getActiveCell() throw (uno::RuntimeException ) -{ - uno::Reference< sheet::XSpreadsheetView > xView( getCurrentDocument()->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< table::XCellRange > xRange( xView->getActiveSheet(), ::uno::UNO_QUERY_THROW); - ScTabViewShell* pViewShell = getCurrentBestViewShell(); - if ( !pViewShell ) - throw uno::RuntimeException( rtl::OUString::createFromAscii("No ViewShell available"), uno::Reference< uno::XInterface >() ); - ScViewData* pTabView = pViewShell->GetViewData(); - if ( !pTabView ) - throw uno::RuntimeException( rtl::OUString::createFromAscii("No ViewData available"), uno::Reference< uno::XInterface >() ); - - sal_Int32 nCursorX = pTabView->GetCurX(); - sal_Int32 nCursorY = pTabView->GetCurY(); - - return new ScVbaRange( this, mxContext, xRange->getCellRangeByPosition( nCursorX, nCursorY, nCursorX, nCursorY ) ); -} - -sal_Bool -ScVbaApplication::getScreenUpdating() throw (uno::RuntimeException) -{ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - return !xModel->hasControllersLocked(); -} - -void -ScVbaApplication::setScreenUpdating(sal_Bool bUpdate) throw (uno::RuntimeException) -{ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - if (bUpdate) - xModel->unlockControllers(); - else - xModel->lockControllers(); -} - -sal_Bool -ScVbaApplication::getDisplayStatusBar() throw (uno::RuntimeException) -{ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW ); - - if( xProps.is() ){ - uno::Reference< frame::XLayoutManager > xLayoutManager( xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LayoutManager")) ), uno::UNO_QUERY_THROW ); - rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" )); - if( xLayoutManager.is() && xLayoutManager->isElementVisible( url ) ){ - return sal_True; - } - } - return sal_False; -} - -void -ScVbaApplication::setDisplayStatusBar(sal_Bool bDisplayStatusBar) throw (uno::RuntimeException) -{ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW ); - - if( xProps.is() ){ - uno::Reference< frame::XLayoutManager > xLayoutManager( xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LayoutManager")) ), uno::UNO_QUERY_THROW ); - rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" )); - if( xLayoutManager.is() ){ - if( bDisplayStatusBar && !xLayoutManager->isElementVisible( url ) ){ - if( !xLayoutManager->showElement( url ) ) - xLayoutManager->createElement( url ); - return; - } - else if( !bDisplayStatusBar && xLayoutManager->isElementVisible( url ) ){ - xLayoutManager->hideElement( url ); - return; - } - } - } - return; -} - -uno::Any SAL_CALL -ScVbaApplication::Workbooks( const uno::Any& aIndex ) throw (uno::RuntimeException) -{ - uno::Reference< vba::XCollection > xWorkBooks( new ScVbaWorkbooks( this, mxContext ) ); - if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID ) - { - // void then somebody did Workbooks.something in vba - return uno::Any( xWorkBooks ); - } - - return uno::Any ( xWorkBooks->Item( aIndex, uno::Any() ) ); -} - -uno::Any SAL_CALL -ScVbaApplication::Worksheets( const uno::Any& aIndex ) throw (uno::RuntimeException) -{ - uno::Reference< excel::XWorkbook > xWorkbook( getActiveWorkbook(), uno::UNO_QUERY ); - uno::Any result; - if ( xWorkbook.is() ) - result = xWorkbook->Worksheets( aIndex ); - - else - // Fixme - check if this is reasonable/desired behavior - throw uno::RuntimeException( rtl::OUString::createFromAscii( - "No ActiveWorkBook available" ), uno::Reference< uno::XInterface >() ); - - return result; -} - -uno::Any SAL_CALL -ScVbaApplication::WorksheetFunction( ) throw (::com::sun::star::uno::RuntimeException) -{ - return uno::makeAny( uno::Reference< script::XInvocation >( new ScVbaWSFunction( this, mxContext) ) ); -} - -uno::Any SAL_CALL -ScVbaApplication::Evaluate( const ::rtl::OUString& Name ) throw (uno::RuntimeException) -{ - // #TODO Evaluate allows other things to be evaluated, e.g. functions - // I think ( like SIN(3) etc. ) need to investigate that - // named Ranges also? e.g. [MyRange] if so need a list of named ranges - uno::Any aVoid; - return uno::Any( getActiveWorkbook()->getActiveSheet()->Range( uno::Any( Name ), aVoid ) ); -} - -uno::Any -ScVbaApplication::Dialogs( const uno::Any &aIndex ) throw (uno::RuntimeException) -{ - uno::Reference< excel::XDialogs > xDialogs( new ScVbaDialogs( uno::Reference< vba::XHelperInterface >( ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication(), uno::UNO_QUERY_THROW ), mxContext ) ); - if( !aIndex.hasValue() ) - return uno::Any( xDialogs ); - return uno::Any( xDialogs->Item( aIndex ) ); -} - -uno::Reference< excel::XWindow > SAL_CALL -ScVbaApplication::getActiveWindow() throw (uno::RuntimeException) -{ - // #FIXME sofar can't determine Parent - return new ScVbaWindow( uno::Reference< vba::XHelperInterface >(), mxContext, getCurrentDocument() ); -} - -uno::Any SAL_CALL -ScVbaApplication::getCutCopyMode() throw (uno::RuntimeException) -{ - //# FIXME TODO, implementation - uno::Any result; - result <<= sal_False; - return result; -} - -::rtl::OUString -ScVbaApplication::getVersion() throw (uno::RuntimeException) -{ - return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(EXCELVERSION)); -} - -void SAL_CALL -ScVbaApplication::setCutCopyMode( const uno::Any& /*_cutcopymode*/ ) throw (uno::RuntimeException) -{ - //# FIXME TODO, implementation -} - -uno::Any SAL_CALL -ScVbaApplication::getStatusBar() throw (uno::RuntimeException) -{ - return uno::makeAny( !getDisplayStatusBar() ); -} - -void SAL_CALL -ScVbaApplication::setStatusBar( const uno::Any& _statusbar ) throw (uno::RuntimeException) -{ - rtl::OUString sText; - sal_Bool bDefault = sal_False; - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< task::XStatusIndicatorSupplier > xStatusIndicatorSupplier( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< task::XStatusIndicator > xStatusIndicator( xStatusIndicatorSupplier->getStatusIndicator(), uno::UNO_QUERY_THROW ); - if( _statusbar >>= sText ) - { - setDisplayStatusBar( sal_True ); - xStatusIndicator->start( sText, 100 ); - //xStatusIndicator->setText( sText ); - } - else if( _statusbar >>= bDefault ) - { - if( bDefault == sal_False ) - { - xStatusIndicator->end(); - setDisplayStatusBar( sal_True ); - } - } - else - throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid prarameter. It should be a string or False" ), - uno::Reference< uno::XInterface >() ); -} - -double SAL_CALL -ScVbaApplication::CountA( const uno::Any& arg1 ) throw (uno::RuntimeException) -{ - double result = 0; - uno::Reference< script::XInvocation > xInvoc( WorksheetFunction(), uno::UNO_QUERY_THROW ); - if ( xInvoc.is() ) - { - static rtl::OUString FunctionName( RTL_CONSTASCII_USTRINGPARAM("CountA" ) ); - uno::Sequence< uno::Any > Params(1); - Params[0] = arg1; - uno::Sequence< sal_Int16 > OutParamIndex; - uno::Sequence< uno::Any > OutParam; - xInvoc->invoke( FunctionName, Params, OutParamIndex, OutParam ) >>= result; - } - return result; -} - -::sal_Int32 SAL_CALL -ScVbaApplication::getCalculation() throw (uno::RuntimeException) -{ - uno::Reference<sheet::XCalculatable> xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW); - if(xCalc->isAutomaticCalculationEnabled()) - return excel::XlCalculation::xlCalculationAutomatic; - else - return excel::XlCalculation::xlCalculationManual; -} - -void SAL_CALL -ScVbaApplication::setCalculation( ::sal_Int32 _calculation ) throw (uno::RuntimeException) -{ - uno::Reference< sheet::XCalculatable > xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW); - switch(_calculation) - { - case excel::XlCalculation::xlCalculationManual: - xCalc->enableAutomaticCalculation(sal_False); - break; - case excel::XlCalculation::xlCalculationAutomatic: - case excel::XlCalculation::xlCalculationSemiautomatic: - xCalc->enableAutomaticCalculation(sal_True); - break; - } -} - -uno::Any SAL_CALL -ScVbaApplication::Windows( const uno::Any& aIndex ) throw (uno::RuntimeException) -{ - uno::Reference< vba::XCollection > xWindows = ScVbaWindows::Windows( mxContext ); - if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID ) - return uno::Any( xWindows ); - return uno::Any( xWindows->Item( aIndex, uno::Any() ) ); -} -void SAL_CALL -ScVbaApplication::wait( double time ) throw (uno::RuntimeException) -{ - StarBASIC* pBasic = SFX_APP()->GetBasic(); - SFX_APP()->EnterBasicCall(); - SbxArrayRef aArgs = new SbxArray; - SbxVariableRef aRef = new SbxVariable; - aRef->PutDouble( time ); - aArgs->Put( aRef, 1 ); - SbMethod* pMeth = (SbMethod*)pBasic->GetRtl()->Find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("WaitUntil") ), SbxCLASS_METHOD ); - - if ( pMeth ) - { - pMeth->SetParameters( aArgs ); - SbxVariableRef refTemp = pMeth; - // forces a broadcast - SbxVariableRef pNew = new SbxMethod( *((SbxMethod*)pMeth)); - } - SFX_APP()->LeaveBasicCall(); - -} - -uno::Any SAL_CALL -ScVbaApplication::Range( const uno::Any& Cell1, const uno::Any& Cell2 ) throw (uno::RuntimeException) -{ - uno::Reference< excel::XRange > xVbRange = ScVbaRange::ApplicationRange( mxContext, Cell1, Cell2 ); - return uno::makeAny( xVbRange ); -} - -uno::Any SAL_CALL -ScVbaApplication::Names( ) throw ( uno::RuntimeException ) -{ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< sheet::XNamedRanges > xNamedRanges( getActiveSheet() , uno::UNO_QUERY_THROW ); - css::uno::Reference< excel::XNames > xNames ( new ScVbaNames( this , mxContext , xNamedRanges , xModel ) ); - return uno::makeAny( xNames ); -} - - -uno::Reference< excel::XWorksheet > SAL_CALL -ScVbaApplication::getActiveSheet() throw (uno::RuntimeException) -{ - uno::Reference< excel::XWorksheet > result; - uno::Reference< excel::XWorkbook > xWorkbook( getActiveWorkbook(), uno::UNO_QUERY ); - if ( xWorkbook.is() ) - { - uno::Reference< excel::XWorksheet > xWorksheet( - xWorkbook->getActiveSheet(), uno::UNO_QUERY ); - if ( xWorksheet.is() ) - { - result = xWorksheet; - } - } - - if ( !result.is() ) - { - // Fixme - check if this is reasonable/desired behavior - throw uno::RuntimeException( rtl::OUString::createFromAscii( - "No activeSheet available" ), uno::Reference< uno::XInterface >() ); - } - return result; - -} - -/******************************************************************************* - * In msdn: - * Reference Optional Variant. The destination. Can be a Range - * object, a string that contains a cell reference in R1C1-style notation, - * or a string that contains a Visual Basic procedure name. - * Scroll Optional Variant. True to scrol, False to not scroll through - * the window. The default is False. - * Parser is split to three parts, Range, R1C1 string and procedure name. - * by test excel, it seems Scroll no effect. ??? -*******************************************************************************/ -void SAL_CALL -ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) throw (uno::RuntimeException) -{ - //test Scroll is a boolean - sal_Bool bScroll = sal_False; - //R1C1-style string or a string of procedure name. - - if( Scroll.hasValue() ) - { - sal_Bool aScroll = sal_False; - if( Scroll >>= aScroll ) - { - bScroll = aScroll; - } - else - throw uno::RuntimeException( rtl::OUString::createFromAscii( "sencond parameter should be boolean" ), - uno::Reference< uno::XInterface >() ); - } - - rtl::OUString sRangeName; - if( Reference >>= sRangeName ) - { - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< sheet::XSpreadsheetView > xSpreadsheet( - xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< sheet::XSpreadsheet > xDoc = xSpreadsheet->getActiveSheet(); - - ScTabViewShell* pShell = getCurrentBestViewShell(); - ScGridWindow* gridWindow = (ScGridWindow*)pShell->GetWindow(); - try - { - uno::Reference< excel::XRange > xVbaSheetRange = ScVbaRange::getRangeObjectForName( mxContext, sRangeName, getDocShell( xModel ), ScAddress::CONV_XL_R1C1 ); -; - if( bScroll ) - { - xVbaSheetRange->Select(); - uno::Reference< excel::XWindow > xWindow = getActiveWindow(); - ScSplitPos eWhich = pShell->GetViewData()->GetActivePart(); - sal_Int32 nValueX = pShell->GetViewData()->GetPosX(WhichH(eWhich)); - sal_Int32 nValueY = pShell->GetViewData()->GetPosY(WhichV(eWhich)); - xWindow->SmallScroll( uno::makeAny( (sal_Int16)(xVbaSheetRange->getRow() - 1) ), - uno::makeAny( (sal_Int16)nValueY ), - uno::makeAny( (sal_Int16)(xVbaSheetRange->getColumn() - 1) ), - uno::makeAny( (sal_Int16)nValueX ) ); - gridWindow->GrabFocus(); - } - else - { - xVbaSheetRange->Select(); - gridWindow->GrabFocus(); - } - } - catch( uno::RuntimeException ) - { - //maybe this should be a procedure name - //TODO for procedure name - //browse::XBrowseNodeFactory is a singlton. OUString::createFromAscii( "/singletons/com.sun.star.script.browse.theBrowseNodeFactory") - //and the createView( browse::BrowseNodeFactoryViewTypes::MACROSELECTOR ) to get a root browse::XBrowseNode. - //for query XInvocation interface. - //but how to directly get the XInvocation? - throw uno::RuntimeException( rtl::OUString::createFromAscii( "invalid reference for range name, it should be procedure name" ), - uno::Reference< uno::XInterface >() ); - } - return; - } - uno::Reference< excel::XRange > xRange; - if( Reference >>= xRange ) - { - uno::Reference< excel::XRange > xVbaRange( Reference, uno::UNO_QUERY ); - ScTabViewShell* pShell = getCurrentBestViewShell(); - ScGridWindow* gridWindow = (ScGridWindow*)pShell->GetWindow(); - if ( xVbaRange.is() ) - { - //TODO bScroll should be using, In this time, it doesenot have effection - if( bScroll ) - { - xVbaRange->Select(); - uno::Reference< excel::XWindow > xWindow = getActiveWindow(); - ScSplitPos eWhich = pShell->GetViewData()->GetActivePart(); - sal_Int32 nValueX = pShell->GetViewData()->GetPosX(WhichH(eWhich)); - sal_Int32 nValueY = pShell->GetViewData()->GetPosY(WhichV(eWhich)); - xWindow->SmallScroll( uno::makeAny( (sal_Int16)(xVbaRange->getRow() - 1) ), - uno::makeAny( (sal_Int16)nValueY ), - uno::makeAny( (sal_Int16)(xVbaRange->getColumn() - 1) ), - uno::makeAny( (sal_Int16)nValueX ) ); - gridWindow->GrabFocus(); - } - else - { - xVbaRange->Select(); - gridWindow->GrabFocus(); - } - } - return; - } - throw uno::RuntimeException( rtl::OUString::createFromAscii( "invalid reference or name" ), - uno::Reference< uno::XInterface >() ); -} - -namespace -{ - static uno::Reference< frame::XController > lcl_getCurrentController() - { - const uno::Reference< frame::XModel > xWorkingDoc( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY ); - uno::Reference< frame::XController > xController; - if ( xWorkingDoc.is() ) - xController.set( xWorkingDoc->getCurrentController(), uno::UNO_SET_THROW ); - else - xController.set( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY_THROW ); - return xController; - } -} - -sal_Int32 SAL_CALL -ScVbaApplication::getCursor() throw (uno::RuntimeException) -{ - sal_Int32 nPointerStyle( POINTER_ARROW ); - try - { - const uno::Reference< frame::XController > xController( lcl_getCurrentController(), uno::UNO_SET_THROW ); - const uno::Reference< frame::XFrame > xFrame ( xController->getFrame(), uno::UNO_SET_THROW ); - const uno::Reference< awt::XWindow > xWindow ( xFrame->getContainerWindow(), uno::UNO_SET_THROW ); - // why the heck isn't there an XWindowPeer::getPointer, but a setPointer only? - const Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); - if ( pWindow ) - nPointerStyle = pWindow->GetSystemWindow()->GetPointer().GetStyle(); - } - catch( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - - switch( nPointerStyle ) - { - case POINTER_ARROW: - return excel::XlMousePointer::xlNorthwestArrow; - case POINTER_NULL: - return excel::XlMousePointer::xlDefault; - case POINTER_WAIT: - return excel::XlMousePointer::xlWait; - case POINTER_TEXT: - return excel::XlMousePointer::xlIBeam; - default: - return excel::XlMousePointer::xlDefault; - } -} - -void SAL_CALL -ScVbaApplication::setCursor( sal_Int32 _cursor ) throw (uno::RuntimeException) -{ - try - { - ::std::vector< uno::Reference< frame::XController > > aControllers; - - const uno::Reference< frame::XModel2 > xModel2( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY ); - if ( xModel2.is() ) - { - const uno::Reference< container::XEnumeration > xEnumControllers( xModel2->getControllers(), uno::UNO_SET_THROW ); - while ( xEnumControllers->hasMoreElements() ) - { - const uno::Reference< frame::XController > xController( xEnumControllers->nextElement(), uno::UNO_QUERY_THROW ); - aControllers.push_back( xController ); - } - } - else - { - const uno::Reference< frame::XModel > xModel( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY ); - if ( xModel.is() ) - { - const uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW ); - aControllers.push_back( xController ); - } - else - { - const uno::Reference< frame::XController > xController( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY_THROW ); - aControllers.push_back( xController ); - } - } - - for ( ::std::vector< uno::Reference< frame::XController > >::const_iterator controller = aControllers.begin(); - controller != aControllers.end(); - ++controller - ) - { - const uno::Reference< frame::XFrame > xFrame ( (*controller)->getFrame(), uno::UNO_SET_THROW ); - const uno::Reference< awt::XWindow > xWindow ( xFrame->getContainerWindow(), uno::UNO_SET_THROW ); - - Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); - OSL_ENSURE( pWindow, "ScVbaApplication::setCursor: no window!" ); - if ( !pWindow ) - continue; - - switch( _cursor ) - { - case excel::XlMousePointer::xlNorthwestArrow: - { - const Pointer& rPointer( POINTER_ARROW ); - pWindow->GetSystemWindow()->SetPointer( rPointer ); - pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_False ); - break; - } - case excel::XlMousePointer::xlWait: - case excel::XlMousePointer::xlIBeam: - { - const Pointer& rPointer( static_cast< PointerStyle >( _cursor ) ); - //It will set the edit window, toobar and statusbar's mouse pointer. - pWindow->GetSystemWindow()->SetPointer( rPointer ); - pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_True ); - //It only set the edit window's mouse pointer - //pWindow->.SetPointer( rPointer ); - //pWindow->.EnableChildPointerOverwrite( sal_True ); - //printf("\nset Cursor...%d\n", pWindow->.GetType()); - break; - } - case excel::XlMousePointer::xlDefault: - { - const Pointer& rPointer( POINTER_NULL ); - pWindow->GetSystemWindow()->SetPointer( rPointer ); - pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_False ); - break; - } - default: - throw uno::RuntimeException( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("Unknown value for Cursor pointer")), uno::Reference< uno::XInterface >() ); - // TODO: isn't this a flaw in the API? It should be allowed to throw an - // IllegalArgumentException, or so - } - } - } - catch( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } -} - -// #TODO perhaps we should switch the return type depending of the filter -// type, e.g. return Calc for Calc and Excel if its an imported doc -rtl::OUString SAL_CALL -ScVbaApplication::getName() throw (uno::RuntimeException) -{ - static rtl::OUString appName( RTL_CONSTASCII_USTRINGPARAM("Microsoft Excel" ) ); - return appName; -} - -// #TODO #FIXME get/setDisplayAlerts are just stub impl -void SAL_CALL -ScVbaApplication::setDisplayAlerts(sal_Bool /*displayAlerts*/) throw (uno::RuntimeException) -{ -} - -sal_Bool SAL_CALL -ScVbaApplication::getDisplayAlerts() throw (uno::RuntimeException) -{ - return sal_True; -} -void SAL_CALL -ScVbaApplication::Calculate() throw( script::BasicErrorException , uno::RuntimeException ) -{ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< sheet::XCalculatable > xCalculatable( getCurrentDocument(), uno::UNO_QUERY_THROW ); - xCalculatable->calculateAll(); -} - -uno::Reference< beans::XPropertySet > lcl_getPathSettingsService( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::RuntimeException ) -{ - static uno::Reference< beans::XPropertySet > xPathSettings; - if ( !xPathSettings.is() ) - { - uno::Reference< lang::XMultiComponentFactory > xSMgr( xContext->getServiceManager(), uno::UNO_QUERY_THROW ); - xPathSettings.set( xSMgr->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.util.PathSettings"), xContext), uno::UNO_QUERY_THROW ); - } - return xPathSettings; -} -rtl::OUString ScVbaApplication::getOfficePath( const rtl::OUString& _sPathType ) throw ( uno::RuntimeException ) -{ - rtl::OUString sRetPath; - uno::Reference< beans::XPropertySet > xProps = lcl_getPathSettingsService( mxContext ); - try - { - rtl::OUString sUrl; - xProps->getPropertyValue( _sPathType ) >>= sUrl; - - // if its a list of paths then use the last one - sal_Int32 nIndex = sUrl.lastIndexOf( ';' ) ; - if ( nIndex > 0 ) - sUrl = sUrl.copy( nIndex + 1 ); - ::osl::File::getSystemPathFromFileURL( sUrl, sRetPath ); - } - catch (uno::Exception&) - { - DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString()); - } - return sRetPath; -} -void SAL_CALL -ScVbaApplication::setDefaultFilePath( const ::rtl::OUString& DefaultFilePath ) throw (script::BasicErrorException, uno::RuntimeException) -{ - uno::Reference< beans::XPropertySet > xProps = lcl_getPathSettingsService( mxContext ); - rtl::OUString aURL; - osl::FileBase::getFileURLFromSystemPath( DefaultFilePath, aURL ); - xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Work")), uno::makeAny( aURL ) ); - - -} - -::rtl::OUString SAL_CALL -ScVbaApplication::getDefaultFilePath( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - return getOfficePath( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Work"))); -} - -::rtl::OUString SAL_CALL -ScVbaApplication::LibraryPath( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - return getOfficePath( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Basic"))); -} - -::rtl::OUString SAL_CALL -ScVbaApplication::TemplatesPath( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - return getOfficePath( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Template"))); -} - -::rtl::OUString SAL_CALL -ScVbaApplication::PathSeparator( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - static rtl::OUString sPathSep( RTL_CONSTASCII_USTRINGPARAM( FILE_PATH_SEPERATOR ) ); - return sPathSep; -} - -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) -{ - std::vector< uno::Reference< excel::XRange > > vRanges; - if ( !Arg1.is() || !Arg2.is() ) - DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() ); - - vRanges.push_back( Arg1 ); - vRanges.push_back( Arg2 ); - - if ( Arg3.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg3, uno::UNO_QUERY_THROW ) ); - if ( Arg4.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg4, uno::UNO_QUERY_THROW ) ); - if ( Arg5.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg5, uno::UNO_QUERY_THROW ) ); - if ( Arg6.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg6, uno::UNO_QUERY_THROW ) ); - if ( Arg7.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg7, uno::UNO_QUERY_THROW ) ); - if ( Arg8.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg8, uno::UNO_QUERY_THROW ) ); - if ( Arg9.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg9, uno::UNO_QUERY_THROW ) ); - if ( Arg10.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg10, uno::UNO_QUERY_THROW ) ); - if ( Arg11.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg11, uno::UNO_QUERY_THROW ) ); - if ( Arg12.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg12, uno::UNO_QUERY_THROW ) ); - if ( Arg13.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg13, uno::UNO_QUERY_THROW ) ); - if ( Arg14.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg14, uno::UNO_QUERY_THROW ) ); - if ( Arg15.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg15, uno::UNO_QUERY_THROW ) ); - if ( Arg16.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg16, uno::UNO_QUERY_THROW ) ); - if ( Arg17.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg17, uno::UNO_QUERY_THROW ) ); - if ( Arg18.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg18, uno::UNO_QUERY_THROW ) ); - if ( Arg19.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg19, uno::UNO_QUERY_THROW ) ); - if ( Arg20.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg20, uno::UNO_QUERY_THROW ) ); - if ( Arg21.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg21, uno::UNO_QUERY_THROW ) ); - if ( Arg22.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg22, uno::UNO_QUERY_THROW ) ); - if ( Arg23.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg23, uno::UNO_QUERY_THROW ) ); - if ( Arg24.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg24, uno::UNO_QUERY_THROW ) ); - if ( Arg25.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg25, uno::UNO_QUERY_THROW ) ); - if ( Arg26.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg26, uno::UNO_QUERY_THROW ) ); - if ( Arg27.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg27, uno::UNO_QUERY_THROW ) ); - if ( Arg28.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg28, uno::UNO_QUERY_THROW ) ); - if ( Arg29.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg29, uno::UNO_QUERY_THROW ) ); - if ( Arg30.hasValue() ) - vRanges.push_back( uno::Reference< excel::XRange >( Arg30, uno::UNO_QUERY_THROW ) ); - - std::vector< uno::Reference< excel::XRange > >::iterator it = vRanges.begin(); - std::vector< uno::Reference< excel::XRange > >::iterator it_end = vRanges.end(); - - uno::Reference< excel::XRange > xRefRange( *it ); - ++it; - for ( ; it != it_end; ++it ) - { - ScVbaRange* pRange = dynamic_cast< ScVbaRange * >( xRefRange.get()); - if ( pRange ) - xRefRange = pRange->intersect( *it ); - if ( !xRefRange.is() ) - return uno::Reference< excel::XRange >(); - } - return xRefRange; -} - -void -ScVbaApplication::Volatile( const uno::Any& aVolatile ) throw ( uno::RuntimeException ) -{ - sal_Bool bVolatile = sal_True; - aVolatile >>= bVolatile; - return; -/* - if ( bVolatile ) - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Volatile - not supported" ) ), uno::Reference< uno::XInterface >() ); - // bVoloatile is false - currently this only would make sense if - // the autocalculate mode is set to be true. - - // so really this is crap, #TODO try and understand how ( or if ) - // the calculation mode and volatile interoperate - if ( ! getCalculation() == excel::XlCalculation::xlCalculationAutomatic ) - setCalculation( excel::XlCalculation::xlCalculationAutomatic ); -*/ -} - -void SAL_CALL -ScVbaApplication::DoEvents() throw ( uno::RuntimeException ) -{ -} - -::sal_Bool SAL_CALL -ScVbaApplication::getDisplayFormulaBar() throw ( css::uno::RuntimeException ) -{ - sal_Bool bRes = sal_False; - ScTabViewShell* pViewShell = getCurrentBestViewShell(); - if ( pViewShell ) - { - SfxBoolItem sfxFormBar( FID_TOGGLEINPUTLINE); - SfxAllItemSet reqList( SFX_APP()->GetPool() ); - reqList.Put( sfxFormBar ); - - pViewShell->GetState( reqList ); - const SfxPoolItem *pItem=0; - if ( reqList.GetItemState( FID_TOGGLEINPUTLINE, sal_False, &pItem ) == SFX_ITEM_SET ) - bRes = ((SfxBoolItem*)pItem)->GetValue(); - } - return bRes; -} - -void SAL_CALL -ScVbaApplication::setDisplayFormulaBar( ::sal_Bool _displayformulabar ) throw ( css::uno::RuntimeException ) -{ - ScTabViewShell* pViewShell = getCurrentBestViewShell(); - if ( pViewShell && ( _displayformulabar != getDisplayFormulaBar() ) ) - { - SfxBoolItem sfxFormBar( FID_TOGGLEINPUTLINE, _displayformulabar); - SfxAllItemSet reqList( SFX_APP()->GetPool() ); - SfxRequest aReq( FID_TOGGLEINPUTLINE, 0, reqList ); - pViewShell->Execute( aReq ); - } -} - -rtl::OUString& -ScVbaApplication::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaApplication") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -ScVbaApplication::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Application" ) ); - } - return aServiceNames; -} +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vbaapplication.cxx,v $
+ * $Revision: 1.7 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <stdio.h>
+
+
+#include<com/sun/star/sheet/XSpreadsheetView.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include<com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include<org/openoffice/excel/XlCalculation.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+#include <com/sun/star/sheet/XCalculatable.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <org/openoffice/excel/XlMousePointer.hpp>
+#include <com/sun/star/sheet/XNamedRanges.hpp>
+
+#include "vbaapplication.hxx"
+#include "vbaworkbooks.hxx"
+#include "vbaworkbook.hxx"
+#include "vbaworksheets.hxx"
+#include "vbarange.hxx"
+#include "vbawsfunction.hxx"
+#include "vbadialogs.hxx"
+#include "vbawindow.hxx"
+#include "vbawindows.hxx"
+#include "vbaglobals.hxx"
+#include "tabvwsh.hxx"
+#include "gridwin.hxx"
+#include "vbanames.hxx"
+#include "vbashape.hxx"
+#include "sc.hrc"
+
+#include <osl/file.hxx>
+
+#include <sfx2/request.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/app.hxx>
+
+#include <toolkit/awt/vclxwindow.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include <tools/diagnose_ex.h>
+
+#include <docuno.hxx>
+
+#include <basic/sbx.hxx>
+#include <basic/sbstar.hxx>
+#include <basic/sbuno.hxx>
+#include <basic/sbmeth.hxx>
+
+using namespace ::org::openoffice;
+using namespace ::com::sun::star;
+
+// #TODO is this defined somewhere else?
+#if ( defined UNX ) || ( defined OS2 ) //unix
+#define FILE_PATH_SEPERATOR "/"
+#else // windows
+#define FILE_PATH_SEPERATOR "\\"
+#endif
+
+#define EXCELVERSION "11.0"
+
+class ActiveWorkbook : public ScVbaWorkbook
+{
+protected:
+ virtual uno::Reference< frame::XModel > getModel()
+ {
+ return getCurrentDocument();
+ }
+public:
+ ActiveWorkbook( const uno::Reference< vba::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext) : ScVbaWorkbook( xParent, xContext ){}
+};
+
+ScVbaApplication::ScVbaApplication( uno::Reference<uno::XComponentContext >& xContext ): ScVbaApplication_BASE( uno::Reference< vba::XHelperInterface >(), xContext ), m_xCalculation( excel::XlCalculation::xlCalculationAutomatic )
+{
+}
+
+ScVbaApplication::~ScVbaApplication()
+{
+}
+
+
+
+uno::Reference< excel::XWorkbook >
+ScVbaApplication::getActiveWorkbook() throw (uno::RuntimeException)
+{
+ return new ActiveWorkbook( this, mxContext );
+}
+uno::Reference< excel::XWorkbook > SAL_CALL
+ScVbaApplication::getThisWorkbook() throw (uno::RuntimeException)
+{
+ return getActiveWorkbook();
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::getSelection() throw (uno::RuntimeException)
+{
+ uno::Reference< lang::XServiceInfo > xServiceInfo( getCurrentDocument()->getCurrentSelection(), uno::UNO_QUERY_THROW );
+ rtl::OUString sImpementaionName = xServiceInfo->getImplementationName();
+ if( sImpementaionName.equalsIgnoreAsciiCaseAscii("com.sun.star.drawing.SvxShapeCollection") )
+ {
+ uno::Reference< drawing::XShapes > xShapes( getCurrentDocument()->getCurrentSelection(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndexAccess( xShapes, uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XShape > xShape( xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW );
+ return uno::makeAny( uno::Reference< msforms::XShape >(new ScVbaShape( this, mxContext, xShape, xShapes, ScVbaShape::getType( xShape ) ) ) );
+ }
+ else if( xServiceInfo->supportsService( rtl::OUString::createFromAscii("com.sun.star.sheet.SheetCellRange")) ||
+ xServiceInfo->supportsService( rtl::OUString::createFromAscii("com.sun.star.sheet.SheetCellRanges")))
+ {
+ uno::Reference< table::XCellRange > xRange( getCurrentDocument()->getCurrentSelection(), ::uno::UNO_QUERY);
+ if ( !xRange.is() )
+ {
+ uno::Reference< sheet::XSheetCellRangeContainer > xRanges( getCurrentDocument()->getCurrentSelection(), ::uno::UNO_QUERY);
+ if ( xRanges.is() )
+ return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( this, mxContext, xRanges ) ) );
+
+ }
+ return uno::makeAny( uno::Reference< excel::XRange >(new ScVbaRange( this, mxContext, xRange ) ) );
+ }
+ else
+ {
+ throw uno::RuntimeException( sImpementaionName + rtl::OUString::createFromAscii(" donot be surpported"), uno::Reference< uno::XInterface >() );
+ }
+}
+
+uno::Reference< excel::XRange >
+ScVbaApplication::getActiveCell() throw (uno::RuntimeException )
+{
+ uno::Reference< sheet::XSpreadsheetView > xView( getCurrentDocument()->getCurrentController(), uno::UNO_QUERY_THROW );
+ uno::Reference< table::XCellRange > xRange( xView->getActiveSheet(), ::uno::UNO_QUERY_THROW);
+ ScTabViewShell* pViewShell = getCurrentBestViewShell();
+ if ( !pViewShell )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("No ViewShell available"), uno::Reference< uno::XInterface >() );
+ ScViewData* pTabView = pViewShell->GetViewData();
+ if ( !pTabView )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("No ViewData available"), uno::Reference< uno::XInterface >() );
+
+ sal_Int32 nCursorX = pTabView->GetCurX();
+ sal_Int32 nCursorY = pTabView->GetCurY();
+
+ return new ScVbaRange( this, mxContext, xRange->getCellRangeByPosition( nCursorX, nCursorY, nCursorX, nCursorY ) );
+}
+
+sal_Bool
+ScVbaApplication::getScreenUpdating() throw (uno::RuntimeException)
+{
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ return !xModel->hasControllersLocked();
+}
+
+void
+ScVbaApplication::setScreenUpdating(sal_Bool bUpdate) throw (uno::RuntimeException)
+{
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ if (bUpdate)
+ xModel->unlockControllers();
+ else
+ xModel->lockControllers();
+}
+
+sal_Bool
+ScVbaApplication::getDisplayStatusBar() throw (uno::RuntimeException)
+{
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW );
+
+ if( xProps.is() ){
+ uno::Reference< frame::XLayoutManager > xLayoutManager( xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LayoutManager")) ), uno::UNO_QUERY_THROW );
+ rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" ));
+ if( xLayoutManager.is() && xLayoutManager->isElementVisible( url ) ){
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+
+void
+ScVbaApplication::setDisplayStatusBar(sal_Bool bDisplayStatusBar) throw (uno::RuntimeException)
+{
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW );
+
+ if( xProps.is() ){
+ uno::Reference< frame::XLayoutManager > xLayoutManager( xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LayoutManager")) ), uno::UNO_QUERY_THROW );
+ rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" ));
+ if( xLayoutManager.is() ){
+ if( bDisplayStatusBar && !xLayoutManager->isElementVisible( url ) ){
+ if( !xLayoutManager->showElement( url ) )
+ xLayoutManager->createElement( url );
+ return;
+ }
+ else if( !bDisplayStatusBar && xLayoutManager->isElementVisible( url ) ){
+ xLayoutManager->hideElement( url );
+ return;
+ }
+ }
+ }
+ return;
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::Workbooks( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< vba::XCollection > xWorkBooks( new ScVbaWorkbooks( this, mxContext ) );
+ if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID )
+ {
+ // void then somebody did Workbooks.something in vba
+ return uno::Any( xWorkBooks );
+ }
+
+ return uno::Any ( xWorkBooks->Item( aIndex, uno::Any() ) );
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::Worksheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XWorkbook > xWorkbook( getActiveWorkbook(), uno::UNO_QUERY );
+ uno::Any result;
+ if ( xWorkbook.is() )
+ result = xWorkbook->Worksheets( aIndex );
+
+ else
+ // Fixme - check if this is reasonable/desired behavior
+ throw uno::RuntimeException( rtl::OUString::createFromAscii(
+ "No ActiveWorkBook available" ), uno::Reference< uno::XInterface >() );
+
+ return result;
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::WorksheetFunction( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return uno::makeAny( uno::Reference< script::XInvocation >( new ScVbaWSFunction( this, mxContext) ) );
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::Evaluate( const ::rtl::OUString& Name ) throw (uno::RuntimeException)
+{
+ // #TODO Evaluate allows other things to be evaluated, e.g. functions
+ // I think ( like SIN(3) etc. ) need to investigate that
+ // named Ranges also? e.g. [MyRange] if so need a list of named ranges
+ uno::Any aVoid;
+ return uno::Any( getActiveWorkbook()->getActiveSheet()->Range( uno::Any( Name ), aVoid ) );
+}
+
+uno::Any
+ScVbaApplication::Dialogs( const uno::Any &aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XDialogs > xDialogs( new ScVbaDialogs( uno::Reference< vba::XHelperInterface >( ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication(), uno::UNO_QUERY_THROW ), mxContext ) );
+ if( !aIndex.hasValue() )
+ return uno::Any( xDialogs );
+ return uno::Any( xDialogs->Item( aIndex ) );
+}
+
+uno::Reference< excel::XWindow > SAL_CALL
+ScVbaApplication::getActiveWindow() throw (uno::RuntimeException)
+{
+ // #FIXME sofar can't determine Parent
+ return new ScVbaWindow( uno::Reference< vba::XHelperInterface >(), mxContext, getCurrentDocument() );
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::getCutCopyMode() throw (uno::RuntimeException)
+{
+ //# FIXME TODO, implementation
+ uno::Any result;
+ result <<= sal_False;
+ return result;
+}
+
+::rtl::OUString
+ScVbaApplication::getVersion() throw (uno::RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(EXCELVERSION));
+}
+
+void SAL_CALL
+ScVbaApplication::setCutCopyMode( const uno::Any& /*_cutcopymode*/ ) throw (uno::RuntimeException)
+{
+ //# FIXME TODO, implementation
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::getStatusBar() throw (uno::RuntimeException)
+{
+ return uno::makeAny( !getDisplayStatusBar() );
+}
+
+void SAL_CALL
+ScVbaApplication::setStatusBar( const uno::Any& _statusbar ) throw (uno::RuntimeException)
+{
+ rtl::OUString sText;
+ sal_Bool bDefault = sal_False;
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< task::XStatusIndicatorSupplier > xStatusIndicatorSupplier( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ uno::Reference< task::XStatusIndicator > xStatusIndicator( xStatusIndicatorSupplier->getStatusIndicator(), uno::UNO_QUERY_THROW );
+ if( _statusbar >>= sText )
+ {
+ setDisplayStatusBar( sal_True );
+ xStatusIndicator->start( sText, 100 );
+ //xStatusIndicator->setText( sText );
+ }
+ else if( _statusbar >>= bDefault )
+ {
+ if( bDefault == sal_False )
+ {
+ xStatusIndicator->end();
+ setDisplayStatusBar( sal_True );
+ }
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid prarameter. It should be a string or False" ),
+ uno::Reference< uno::XInterface >() );
+}
+
+double SAL_CALL
+ScVbaApplication::CountA( const uno::Any& arg1 ) throw (uno::RuntimeException)
+{
+ double result = 0;
+ uno::Reference< script::XInvocation > xInvoc( WorksheetFunction(), uno::UNO_QUERY_THROW );
+ if ( xInvoc.is() )
+ {
+ static rtl::OUString FunctionName( RTL_CONSTASCII_USTRINGPARAM("CountA" ) );
+ uno::Sequence< uno::Any > Params(1);
+ Params[0] = arg1;
+ uno::Sequence< sal_Int16 > OutParamIndex;
+ uno::Sequence< uno::Any > OutParam;
+ xInvoc->invoke( FunctionName, Params, OutParamIndex, OutParam ) >>= result;
+ }
+ return result;
+}
+
+::sal_Int32 SAL_CALL
+ScVbaApplication::getCalculation() throw (uno::RuntimeException)
+{
+ uno::Reference<sheet::XCalculatable> xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW);
+ if(xCalc->isAutomaticCalculationEnabled())
+ return excel::XlCalculation::xlCalculationAutomatic;
+ else
+ return excel::XlCalculation::xlCalculationManual;
+}
+
+void SAL_CALL
+ScVbaApplication::setCalculation( ::sal_Int32 _calculation ) throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XCalculatable > xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW);
+ switch(_calculation)
+ {
+ case excel::XlCalculation::xlCalculationManual:
+ xCalc->enableAutomaticCalculation(sal_False);
+ break;
+ case excel::XlCalculation::xlCalculationAutomatic:
+ case excel::XlCalculation::xlCalculationSemiautomatic:
+ xCalc->enableAutomaticCalculation(sal_True);
+ break;
+ }
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::Windows( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< vba::XCollection > xWindows = ScVbaWindows::Windows( mxContext );
+ if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID )
+ return uno::Any( xWindows );
+ return uno::Any( xWindows->Item( aIndex, uno::Any() ) );
+}
+void SAL_CALL
+ScVbaApplication::wait( double time ) throw (uno::RuntimeException)
+{
+ StarBASIC* pBasic = SFX_APP()->GetBasic();
+ SFX_APP()->EnterBasicCall();
+ SbxArrayRef aArgs = new SbxArray;
+ SbxVariableRef aRef = new SbxVariable;
+ aRef->PutDouble( time );
+ aArgs->Put( aRef, 1 );
+ SbMethod* pMeth = (SbMethod*)pBasic->GetRtl()->Find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("WaitUntil") ), SbxCLASS_METHOD );
+
+ if ( pMeth )
+ {
+ pMeth->SetParameters( aArgs );
+ SbxVariableRef refTemp = pMeth;
+ // forces a broadcast
+ SbxVariableRef pNew = new SbxMethod( *((SbxMethod*)pMeth));
+ }
+ SFX_APP()->LeaveBasicCall();
+
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::Range( const uno::Any& Cell1, const uno::Any& Cell2 ) throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XRange > xVbRange = ScVbaRange::ApplicationRange( mxContext, Cell1, Cell2 );
+ return uno::makeAny( xVbRange );
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::Names( ) throw ( uno::RuntimeException )
+{
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XNamedRanges > xNamedRanges( getActiveSheet() , uno::UNO_QUERY_THROW );
+ css::uno::Reference< excel::XNames > xNames ( new ScVbaNames( this , mxContext , xNamedRanges , xModel ) );
+ return uno::makeAny( xNames );
+}
+
+
+uno::Reference< excel::XWorksheet > SAL_CALL
+ScVbaApplication::getActiveSheet() throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XWorksheet > result;
+ uno::Reference< excel::XWorkbook > xWorkbook( getActiveWorkbook(), uno::UNO_QUERY );
+ if ( xWorkbook.is() )
+ {
+ uno::Reference< excel::XWorksheet > xWorksheet(
+ xWorkbook->getActiveSheet(), uno::UNO_QUERY );
+ if ( xWorksheet.is() )
+ {
+ result = xWorksheet;
+ }
+ }
+
+ if ( !result.is() )
+ {
+ // Fixme - check if this is reasonable/desired behavior
+ throw uno::RuntimeException( rtl::OUString::createFromAscii(
+ "No activeSheet available" ), uno::Reference< uno::XInterface >() );
+ }
+ return result;
+
+}
+
+/*******************************************************************************
+ * In msdn:
+ * Reference Optional Variant. The destination. Can be a Range
+ * object, a string that contains a cell reference in R1C1-style notation,
+ * or a string that contains a Visual Basic procedure name.
+ * Scroll Optional Variant. True to scrol, False to not scroll through
+ * the window. The default is False.
+ * Parser is split to three parts, Range, R1C1 string and procedure name.
+ * by test excel, it seems Scroll no effect. ???
+*******************************************************************************/
+void SAL_CALL
+ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) throw (uno::RuntimeException)
+{
+ //test Scroll is a boolean
+ sal_Bool bScroll = sal_False;
+ //R1C1-style string or a string of procedure name.
+
+ if( Scroll.hasValue() )
+ {
+ sal_Bool aScroll = sal_False;
+ if( Scroll >>= aScroll )
+ {
+ bScroll = aScroll;
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "sencond parameter should be boolean" ),
+ uno::Reference< uno::XInterface >() );
+ }
+
+ rtl::OUString sRangeName;
+ if( Reference >>= sRangeName )
+ {
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSpreadsheetView > xSpreadsheet(
+ xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSpreadsheet > xDoc = xSpreadsheet->getActiveSheet();
+
+ ScTabViewShell* pShell = getCurrentBestViewShell();
+ ScGridWindow* gridWindow = (ScGridWindow*)pShell->GetWindow();
+ try
+ {
+ uno::Reference< excel::XRange > xVbaSheetRange = ScVbaRange::getRangeObjectForName( mxContext, sRangeName, getDocShell( xModel ), formula::FormulaGrammar::CONV_XL_R1C1 );
+;
+ if( bScroll )
+ {
+ xVbaSheetRange->Select();
+ uno::Reference< excel::XWindow > xWindow = getActiveWindow();
+ ScSplitPos eWhich = pShell->GetViewData()->GetActivePart();
+ sal_Int32 nValueX = pShell->GetViewData()->GetPosX(WhichH(eWhich));
+ sal_Int32 nValueY = pShell->GetViewData()->GetPosY(WhichV(eWhich));
+ xWindow->SmallScroll( uno::makeAny( (sal_Int16)(xVbaSheetRange->getRow() - 1) ),
+ uno::makeAny( (sal_Int16)nValueY ),
+ uno::makeAny( (sal_Int16)(xVbaSheetRange->getColumn() - 1) ),
+ uno::makeAny( (sal_Int16)nValueX ) );
+ gridWindow->GrabFocus();
+ }
+ else
+ {
+ xVbaSheetRange->Select();
+ gridWindow->GrabFocus();
+ }
+ }
+ catch( uno::RuntimeException )
+ {
+ //maybe this should be a procedure name
+ //TODO for procedure name
+ //browse::XBrowseNodeFactory is a singlton. OUString::createFromAscii( "/singletons/com.sun.star.script.browse.theBrowseNodeFactory")
+ //and the createView( browse::BrowseNodeFactoryViewTypes::MACROSELECTOR ) to get a root browse::XBrowseNode.
+ //for query XInvocation interface.
+ //but how to directly get the XInvocation?
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "invalid reference for range name, it should be procedure name" ),
+ uno::Reference< uno::XInterface >() );
+ }
+ return;
+ }
+ uno::Reference< excel::XRange > xRange;
+ if( Reference >>= xRange )
+ {
+ uno::Reference< excel::XRange > xVbaRange( Reference, uno::UNO_QUERY );
+ ScTabViewShell* pShell = getCurrentBestViewShell();
+ ScGridWindow* gridWindow = (ScGridWindow*)pShell->GetWindow();
+ if ( xVbaRange.is() )
+ {
+ //TODO bScroll should be using, In this time, it doesenot have effection
+ if( bScroll )
+ {
+ xVbaRange->Select();
+ uno::Reference< excel::XWindow > xWindow = getActiveWindow();
+ ScSplitPos eWhich = pShell->GetViewData()->GetActivePart();
+ sal_Int32 nValueX = pShell->GetViewData()->GetPosX(WhichH(eWhich));
+ sal_Int32 nValueY = pShell->GetViewData()->GetPosY(WhichV(eWhich));
+ xWindow->SmallScroll( uno::makeAny( (sal_Int16)(xVbaRange->getRow() - 1) ),
+ uno::makeAny( (sal_Int16)nValueY ),
+ uno::makeAny( (sal_Int16)(xVbaRange->getColumn() - 1) ),
+ uno::makeAny( (sal_Int16)nValueX ) );
+ gridWindow->GrabFocus();
+ }
+ else
+ {
+ xVbaRange->Select();
+ gridWindow->GrabFocus();
+ }
+ }
+ return;
+ }
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "invalid reference or name" ),
+ uno::Reference< uno::XInterface >() );
+}
+
+namespace
+{
+ static uno::Reference< frame::XController > lcl_getCurrentController()
+ {
+ const uno::Reference< frame::XModel > xWorkingDoc( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY );
+ uno::Reference< frame::XController > xController;
+ if ( xWorkingDoc.is() )
+ xController.set( xWorkingDoc->getCurrentController(), uno::UNO_SET_THROW );
+ else
+ xController.set( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY_THROW );
+ return xController;
+ }
+}
+
+sal_Int32 SAL_CALL
+ScVbaApplication::getCursor() throw (uno::RuntimeException)
+{
+ sal_Int32 nPointerStyle( POINTER_ARROW );
+ try
+ {
+ const uno::Reference< frame::XController > xController( lcl_getCurrentController(), uno::UNO_SET_THROW );
+ const uno::Reference< frame::XFrame > xFrame ( xController->getFrame(), uno::UNO_SET_THROW );
+ const uno::Reference< awt::XWindow > xWindow ( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
+ // why the heck isn't there an XWindowPeer::getPointer, but a setPointer only?
+ const Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
+ if ( pWindow )
+ nPointerStyle = pWindow->GetSystemWindow()->GetPointer().GetStyle();
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ switch( nPointerStyle )
+ {
+ case POINTER_ARROW:
+ return excel::XlMousePointer::xlNorthwestArrow;
+ case POINTER_NULL:
+ return excel::XlMousePointer::xlDefault;
+ case POINTER_WAIT:
+ return excel::XlMousePointer::xlWait;
+ case POINTER_TEXT:
+ return excel::XlMousePointer::xlIBeam;
+ default:
+ return excel::XlMousePointer::xlDefault;
+ }
+}
+
+void SAL_CALL
+ScVbaApplication::setCursor( sal_Int32 _cursor ) throw (uno::RuntimeException)
+{
+ try
+ {
+ ::std::vector< uno::Reference< frame::XController > > aControllers;
+
+ const uno::Reference< frame::XModel2 > xModel2( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY );
+ if ( xModel2.is() )
+ {
+ const uno::Reference< container::XEnumeration > xEnumControllers( xModel2->getControllers(), uno::UNO_SET_THROW );
+ while ( xEnumControllers->hasMoreElements() )
+ {
+ const uno::Reference< frame::XController > xController( xEnumControllers->nextElement(), uno::UNO_QUERY_THROW );
+ aControllers.push_back( xController );
+ }
+ }
+ else
+ {
+ const uno::Reference< frame::XModel > xModel( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY );
+ if ( xModel.is() )
+ {
+ const uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
+ aControllers.push_back( xController );
+ }
+ else
+ {
+ const uno::Reference< frame::XController > xController( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY_THROW );
+ aControllers.push_back( xController );
+ }
+ }
+
+ for ( ::std::vector< uno::Reference< frame::XController > >::const_iterator controller = aControllers.begin();
+ controller != aControllers.end();
+ ++controller
+ )
+ {
+ const uno::Reference< frame::XFrame > xFrame ( (*controller)->getFrame(), uno::UNO_SET_THROW );
+ const uno::Reference< awt::XWindow > xWindow ( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
+
+ Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
+ OSL_ENSURE( pWindow, "ScVbaApplication::setCursor: no window!" );
+ if ( !pWindow )
+ continue;
+
+ switch( _cursor )
+ {
+ case excel::XlMousePointer::xlNorthwestArrow:
+ {
+ const Pointer& rPointer( POINTER_ARROW );
+ pWindow->GetSystemWindow()->SetPointer( rPointer );
+ pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_False );
+ break;
+ }
+ case excel::XlMousePointer::xlWait:
+ case excel::XlMousePointer::xlIBeam:
+ {
+ const Pointer& rPointer( static_cast< PointerStyle >( _cursor ) );
+ //It will set the edit window, toobar and statusbar's mouse pointer.
+ pWindow->GetSystemWindow()->SetPointer( rPointer );
+ pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_True );
+ //It only set the edit window's mouse pointer
+ //pWindow->.SetPointer( rPointer );
+ //pWindow->.EnableChildPointerOverwrite( sal_True );
+ //printf("\nset Cursor...%d\n", pWindow->.GetType());
+ break;
+ }
+ case excel::XlMousePointer::xlDefault:
+ {
+ const Pointer& rPointer( POINTER_NULL );
+ pWindow->GetSystemWindow()->SetPointer( rPointer );
+ pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_False );
+ break;
+ }
+ default:
+ throw uno::RuntimeException( rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Unknown value for Cursor pointer")), uno::Reference< uno::XInterface >() );
+ // TODO: isn't this a flaw in the API? It should be allowed to throw an
+ // IllegalArgumentException, or so
+ }
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// #TODO perhaps we should switch the return type depending of the filter
+// type, e.g. return Calc for Calc and Excel if its an imported doc
+rtl::OUString SAL_CALL
+ScVbaApplication::getName() throw (uno::RuntimeException)
+{
+ static rtl::OUString appName( RTL_CONSTASCII_USTRINGPARAM("Microsoft Excel" ) );
+ return appName;
+}
+
+// #TODO #FIXME get/setDisplayAlerts are just stub impl
+void SAL_CALL
+ScVbaApplication::setDisplayAlerts(sal_Bool /*displayAlerts*/) throw (uno::RuntimeException)
+{
+}
+
+sal_Bool SAL_CALL
+ScVbaApplication::getDisplayAlerts() throw (uno::RuntimeException)
+{
+ return sal_True;
+}
+void SAL_CALL
+ScVbaApplication::Calculate() throw( script::BasicErrorException , uno::RuntimeException )
+{
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XCalculatable > xCalculatable( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ xCalculatable->calculateAll();
+}
+
+uno::Reference< beans::XPropertySet > lcl_getPathSettingsService( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::RuntimeException )
+{
+ static uno::Reference< beans::XPropertySet > xPathSettings;
+ if ( !xPathSettings.is() )
+ {
+ uno::Reference< lang::XMultiComponentFactory > xSMgr( xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ xPathSettings.set( xSMgr->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.util.PathSettings"), xContext), uno::UNO_QUERY_THROW );
+ }
+ return xPathSettings;
+}
+rtl::OUString ScVbaApplication::getOfficePath( const rtl::OUString& _sPathType ) throw ( uno::RuntimeException )
+{
+ rtl::OUString sRetPath;
+ uno::Reference< beans::XPropertySet > xProps = lcl_getPathSettingsService( mxContext );
+ try
+ {
+ rtl::OUString sUrl;
+ xProps->getPropertyValue( _sPathType ) >>= sUrl;
+
+ // if its a list of paths then use the last one
+ sal_Int32 nIndex = sUrl.lastIndexOf( ';' ) ;
+ if ( nIndex > 0 )
+ sUrl = sUrl.copy( nIndex + 1 );
+ ::osl::File::getSystemPathFromFileURL( sUrl, sRetPath );
+ }
+ catch (uno::Exception&)
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return sRetPath;
+}
+void SAL_CALL
+ScVbaApplication::setDefaultFilePath( const ::rtl::OUString& DefaultFilePath ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps = lcl_getPathSettingsService( mxContext );
+ rtl::OUString aURL;
+ osl::FileBase::getFileURLFromSystemPath( DefaultFilePath, aURL );
+ xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Work")), uno::makeAny( aURL ) );
+
+
+}
+
+::rtl::OUString SAL_CALL
+ScVbaApplication::getDefaultFilePath( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return getOfficePath( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Work")));
+}
+
+::rtl::OUString SAL_CALL
+ScVbaApplication::LibraryPath( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return getOfficePath( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Basic")));
+}
+
+::rtl::OUString SAL_CALL
+ScVbaApplication::TemplatesPath( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return getOfficePath( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Template")));
+}
+
+::rtl::OUString SAL_CALL
+ScVbaApplication::PathSeparator( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ static rtl::OUString sPathSep( RTL_CONSTASCII_USTRINGPARAM( FILE_PATH_SEPERATOR ) );
+ return sPathSep;
+}
+
+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)
+{
+ std::vector< uno::Reference< excel::XRange > > vRanges;
+ if ( !Arg1.is() || !Arg2.is() )
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+
+ vRanges.push_back( Arg1 );
+ vRanges.push_back( Arg2 );
+
+ if ( Arg3.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg3, uno::UNO_QUERY_THROW ) );
+ if ( Arg4.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg4, uno::UNO_QUERY_THROW ) );
+ if ( Arg5.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg5, uno::UNO_QUERY_THROW ) );
+ if ( Arg6.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg6, uno::UNO_QUERY_THROW ) );
+ if ( Arg7.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg7, uno::UNO_QUERY_THROW ) );
+ if ( Arg8.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg8, uno::UNO_QUERY_THROW ) );
+ if ( Arg9.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg9, uno::UNO_QUERY_THROW ) );
+ if ( Arg10.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg10, uno::UNO_QUERY_THROW ) );
+ if ( Arg11.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg11, uno::UNO_QUERY_THROW ) );
+ if ( Arg12.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg12, uno::UNO_QUERY_THROW ) );
+ if ( Arg13.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg13, uno::UNO_QUERY_THROW ) );
+ if ( Arg14.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg14, uno::UNO_QUERY_THROW ) );
+ if ( Arg15.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg15, uno::UNO_QUERY_THROW ) );
+ if ( Arg16.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg16, uno::UNO_QUERY_THROW ) );
+ if ( Arg17.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg17, uno::UNO_QUERY_THROW ) );
+ if ( Arg18.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg18, uno::UNO_QUERY_THROW ) );
+ if ( Arg19.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg19, uno::UNO_QUERY_THROW ) );
+ if ( Arg20.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg20, uno::UNO_QUERY_THROW ) );
+ if ( Arg21.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg21, uno::UNO_QUERY_THROW ) );
+ if ( Arg22.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg22, uno::UNO_QUERY_THROW ) );
+ if ( Arg23.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg23, uno::UNO_QUERY_THROW ) );
+ if ( Arg24.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg24, uno::UNO_QUERY_THROW ) );
+ if ( Arg25.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg25, uno::UNO_QUERY_THROW ) );
+ if ( Arg26.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg26, uno::UNO_QUERY_THROW ) );
+ if ( Arg27.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg27, uno::UNO_QUERY_THROW ) );
+ if ( Arg28.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg28, uno::UNO_QUERY_THROW ) );
+ if ( Arg29.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg29, uno::UNO_QUERY_THROW ) );
+ if ( Arg30.hasValue() )
+ vRanges.push_back( uno::Reference< excel::XRange >( Arg30, uno::UNO_QUERY_THROW ) );
+
+ std::vector< uno::Reference< excel::XRange > >::iterator it = vRanges.begin();
+ std::vector< uno::Reference< excel::XRange > >::iterator it_end = vRanges.end();
+
+ uno::Reference< excel::XRange > xRefRange( *it );
+ ++it;
+ for ( ; it != it_end; ++it )
+ {
+ ScVbaRange* pRange = dynamic_cast< ScVbaRange * >( xRefRange.get());
+ if ( pRange )
+ xRefRange = pRange->intersect( *it );
+ if ( !xRefRange.is() )
+ return uno::Reference< excel::XRange >();
+ }
+ return xRefRange;
+}
+
+void
+ScVbaApplication::Volatile( const uno::Any& aVolatile ) throw ( uno::RuntimeException )
+{
+ sal_Bool bVolatile = sal_True;
+ aVolatile >>= bVolatile;
+ return;
+/*
+ if ( bVolatile )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Volatile - not supported" ) ), uno::Reference< uno::XInterface >() );
+ // bVoloatile is false - currently this only would make sense if
+ // the autocalculate mode is set to be true.
+
+ // so really this is crap, #TODO try and understand how ( or if )
+ // the calculation mode and volatile interoperate
+ if ( ! getCalculation() == excel::XlCalculation::xlCalculationAutomatic )
+ setCalculation( excel::XlCalculation::xlCalculationAutomatic );
+*/
+}
+
+void SAL_CALL
+ScVbaApplication::DoEvents() throw ( uno::RuntimeException )
+{
+}
+
+::sal_Bool SAL_CALL
+ScVbaApplication::getDisplayFormulaBar() throw ( css::uno::RuntimeException )
+{
+ sal_Bool bRes = sal_False;
+ ScTabViewShell* pViewShell = getCurrentBestViewShell();
+ if ( pViewShell )
+ {
+ SfxBoolItem sfxFormBar( FID_TOGGLEINPUTLINE);
+ SfxAllItemSet reqList( SFX_APP()->GetPool() );
+ reqList.Put( sfxFormBar );
+
+ pViewShell->GetState( reqList );
+ const SfxPoolItem *pItem=0;
+ if ( reqList.GetItemState( FID_TOGGLEINPUTLINE, sal_False, &pItem ) == SFX_ITEM_SET )
+ bRes = ((SfxBoolItem*)pItem)->GetValue();
+ }
+ return bRes;
+}
+
+void SAL_CALL
+ScVbaApplication::setDisplayFormulaBar( ::sal_Bool _displayformulabar ) throw ( css::uno::RuntimeException )
+{
+ ScTabViewShell* pViewShell = getCurrentBestViewShell();
+ if ( pViewShell && ( _displayformulabar != getDisplayFormulaBar() ) )
+ {
+ SfxBoolItem sfxFormBar( FID_TOGGLEINPUTLINE, _displayformulabar);
+ SfxAllItemSet reqList( SFX_APP()->GetPool() );
+ SfxRequest aReq( FID_TOGGLEINPUTLINE, 0, reqList );
+ pViewShell->Execute( aReq );
+ }
+}
+
+rtl::OUString&
+ScVbaApplication::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaApplication") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaApplication::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Application" ) );
+ }
+ return aServiceNames;
+}
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 47acd7b8a497..6f5902f91447 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -145,7 +145,7 @@ #include "rangelst.hxx" #include "convuno.hxx" #include "compiler.hxx" -#include "grammar.hxx" +#include "formula/grammar.hxx" #include "attrib.hxx" #include "undodat.hxx" #include "dbdocfun.hxx" @@ -744,9 +744,9 @@ class CellFormulaValueSetter : public CellValueSetter { private: ScDocument* m_pDoc; - ScGrammar::Grammar m_eGrammar; + formula::FormulaGrammar::Grammar m_eGrammar; public: - CellFormulaValueSetter( const uno::Any& aValue, ScDocument* pDoc, ScGrammar::Grammar eGram ):CellValueSetter( aValue ), m_pDoc( pDoc ), m_eGrammar( eGram ){} + CellFormulaValueSetter( const uno::Any& aValue, ScDocument* pDoc, formula::FormulaGrammar::Grammar eGram ):CellValueSetter( aValue ), m_pDoc( pDoc ), m_eGrammar( eGram ){} protected: bool processValue( const uno::Any& aValue, const uno::Reference< table::XCell >& xCell ) { @@ -756,18 +756,19 @@ protected: // convert to CONV_OOO style formula string because XCell::setFormula // always compile it in CONV_OOO style. Perhaps css.sheet.FormulaParser // should be used in future to directly pass formula tokens. - if ( m_eGrammar != ScGrammar::GRAM_PODF_A1 && ( sFormula.trim().indexOf('=') == 0 ) ) + if ( m_eGrammar != formula::FormulaGrammar::GRAM_PODF_A1 && ( sFormula.trim().indexOf('=') == 0 ) ) { uno::Reference< uno::XInterface > xIf( xCell, uno::UNO_QUERY_THROW ); ScCellRangesBase* pUnoRangesBase = dynamic_cast< ScCellRangesBase* >( xIf.get() ); if ( pUnoRangesBase ) { ScRangeList aCellRanges = pUnoRangesBase->GetRangeList(); - ScCompiler aCompiler( m_pDoc, aCellRanges.First()->aStart, m_eGrammar ); + ScCompiler aCompiler( m_pDoc, aCellRanges.First()->aStart ); + aCompiler.SetGrammar(m_eGrammar); // compile the string in the format passed in aCompiler.CompileString( sFormula ); // set desired convention to that of the document - aCompiler.SetGrammar( ScGrammar::GRAM_PODF_A1 ); + aCompiler.SetGrammar( formula::FormulaGrammar::GRAM_PODF_A1 ); String sConverted; aCompiler.CreateStringFromTokenArray(sConverted); sFormula = EQUALS + sConverted; @@ -786,9 +787,9 @@ class CellFormulaValueGetter : public CellValueGetter { private: ScDocument* m_pDoc; - ScGrammar::Grammar m_eGrammar; + formula::FormulaGrammar::Grammar m_eGrammar; public: - CellFormulaValueGetter(ScDocument* pDoc, ScGrammar::Grammar eGram ) : CellValueGetter( ), m_pDoc( pDoc ), m_eGrammar( eGram ) {} + CellFormulaValueGetter(ScDocument* pDoc, formula::FormulaGrammar::Grammar eGram ) : CellValueGetter( ), m_pDoc( pDoc ), m_eGrammar( eGram ) {} virtual void visitNode( sal_Int32 x, sal_Int32 y, const uno::Reference< table::XCell >& xCell ) { uno::Any aValue; @@ -801,7 +802,8 @@ public: pUnoRangesBase ) { ScRangeList aCellRanges = pUnoRangesBase->GetRangeList(); - ScCompiler aCompiler( m_pDoc, aCellRanges.First()->aStart, ScGrammar::GRAM_DEFAULT ); + ScCompiler aCompiler( m_pDoc, aCellRanges.First()->aStart ); + aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_DEFAULT); aCompiler.CompileString( sVal ); // set desired convention aCompiler.SetGrammar( m_eGrammar ); @@ -1009,7 +1011,7 @@ public: }; bool -getCellRangesForAddress( USHORT& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, ScAddress::Convention& eConv ) +getCellRangesForAddress( USHORT& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv ) { ScDocument* pDoc = NULL; @@ -1018,7 +1020,7 @@ getCellRangesForAddress( USHORT& rResFlags, const rtl::OUString& sAddress, ScDoc pDoc = pDocSh->GetDocument(); String aString(sAddress); USHORT nMask = SCA_VALID; - //USHORT nParse = rCellRanges.Parse( sAddress, pDoc, nMask, ScAddress::CONV_XL_A1 ); + //USHORT nParse = rCellRanges.Parse( sAddress, pDoc, nMask, formula::FormulaGrammar::CONV_XL_A1 ); rResFlags = rCellRanges.Parse( sAddress, pDoc, nMask, eConv, 0 ); if ( rResFlags & SCA_VALID ) { @@ -1028,7 +1030,7 @@ getCellRangesForAddress( USHORT& rResFlags, const rtl::OUString& sAddress, ScDoc return false; } -bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, ScRange& refRange, ScRangeList& aCellRanges, ScAddress::Convention aConv = ScAddress::CONV_XL_A1 ) throw ( uno::RuntimeException ) +bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, ScRange& refRange, ScRangeList& aCellRanges, formula::FormulaGrammar::AddressConvention aConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( uno::RuntimeException ) { // see if there is a match with a named range uno::Reference< beans::XPropertySet > xProps( pDocSh->GetModel(), uno::UNO_QUERY_THROW ); @@ -1051,7 +1053,7 @@ bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, S for ( ; it != it_end; ++it ) { - ScAddress::Convention eConv = aConv; + formula::FormulaGrammar::AddressConvention eConv = aConv; // spaces are illegal ( but the user of course can enter them ) rtl::OUString sAddress = (*it).trim(); if ( xNameAccess->hasByName( sAddress ) ) @@ -1084,7 +1086,7 @@ bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, S ScVbaRange* -getRangeForName( const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, ScDocShell* pDocSh, table::CellRangeAddress& pAddr, ScAddress::Convention eConv = ScAddress::CONV_XL_A1 ) throw ( uno::RuntimeException ) +getRangeForName( const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, ScDocShell* pDocSh, table::CellRangeAddress& pAddr, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( uno::RuntimeException ) { ScRangeList aCellRanges; ScRange refRange; @@ -1105,14 +1107,14 @@ getRangeForName( const uno::Reference< uno::XComponentContext >& xContext, const } css::uno::Reference< excel::XRange > -ScVbaRange::getRangeObjectForName( const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sRangeName, ScDocShell* pDocSh, ScAddress::Convention eConv ) throw ( uno::RuntimeException ) +ScVbaRange::getRangeObjectForName( const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sRangeName, ScDocShell* pDocSh, formula::FormulaGrammar::AddressConvention eConv ) throw ( uno::RuntimeException ) { table::CellRangeAddress refAddr; return getRangeForName( xContext, sRangeName, pDocSh, refAddr, eConv ); } -table::CellRangeAddress getCellRangeAddressForVBARange( const uno::Any& aParam, ScDocShell* pDocSh, ScAddress::Convention aConv = ScAddress::CONV_XL_A1) throw ( uno::RuntimeException ) +table::CellRangeAddress getCellRangeAddressForVBARange( const uno::Any& aParam, ScDocShell* pDocSh, formula::FormulaGrammar::AddressConvention aConv = formula::FormulaGrammar::CONV_XL_A1) throw ( uno::RuntimeException ) { uno::Reference< table::XCellRange > xRangeParam; switch ( aParam.getValueTypeClass() ) @@ -1372,7 +1374,7 @@ ScVbaRange::ClearFormats() throw (uno::RuntimeException) } void -ScVbaRange::setFormulaValue( const uno::Any& rFormula, ScGrammar::Grammar eGram ) throw (uno::RuntimeException) +ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar::Grammar eGram ) throw (uno::RuntimeException) { // If this is a multiple selection apply setFormula over all areas if ( m_Areas->getCount() > 1 ) @@ -1387,7 +1389,7 @@ ScVbaRange::setFormulaValue( const uno::Any& rFormula, ScGrammar::Grammar eGram } uno::Any -ScVbaRange::getFormulaValue( ScGrammar::Grammar eGram ) throw (uno::RuntimeException) +ScVbaRange::getFormulaValue( formula::FormulaGrammar::Grammar eGram ) throw (uno::RuntimeException) { // #TODO code within the test below "if ( m_Areas.... " can be removed // Test is performed only because m_xRange is NOT set to be @@ -1407,25 +1409,25 @@ void ScVbaRange::setFormula(const uno::Any &rFormula ) throw (uno::RuntimeException) { // #FIXME converting "=$a$1" e.g. CONV_XL_A1 -> CONV_OOO // results in "=$a$1:a1", temporalily disable conversion - setFormulaValue( rFormula, ScGrammar::GRAM_NATIVE_XL_A1 );; + setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );; } uno::Any ScVbaRange::getFormulaR1C1() throw (::com::sun::star::uno::RuntimeException) { - return getFormulaValue( ScGrammar::GRAM_NATIVE_XL_R1C1 ); + return getFormulaValue( formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 ); } void ScVbaRange::setFormulaR1C1(const uno::Any& rFormula ) throw (uno::RuntimeException) { - setFormulaValue( rFormula, ScGrammar::GRAM_NATIVE_XL_R1C1 ); + setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 ); } uno::Any ScVbaRange::getFormula() throw (::com::sun::star::uno::RuntimeException) { - return getFormulaValue( ScGrammar::GRAM_NATIVE_XL_A1 ); + return getFormulaValue( formula::FormulaGrammar::GRAM_NATIVE_XL_A1 ); } sal_Int32 @@ -1755,13 +1757,13 @@ ScVbaRange::Address( const uno::Any& RowAbsolute, const uno::Any& ColumnAbsolut return sAddress; } - ScAddress::Details dDetails( ScAddress::CONV_XL_A1, 0, 0 ); + ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 ); if ( ReferenceStyle.hasValue() ) { sal_Int32 refStyle = excel::XlReferenceStyle::xlA1; ReferenceStyle >>= refStyle; if ( refStyle == excel::XlReferenceStyle::xlR1C1 ) - dDetails = ScAddress::Details( ScAddress::CONV_XL_R1C1, 0, 0 ); + dDetails = ScAddress::Details( formula::FormulaGrammar::CONV_XL_R1C1, 0, 0 ); } USHORT nFlags = SCA_VALID; ScDocShell* pDocShell = getScDocShell(); @@ -1801,7 +1803,7 @@ ScVbaRange::Address( const uno::Any& RowAbsolute, const uno::Any& ColumnAbsolut // #TODO should I throw an error if R1C1 is not set? table::CellRangeAddress refAddress = getCellRangeAddressForVBARange( RelativeTo, pDocShell ); - dDetails = ScAddress::Details( ScAddress::CONV_XL_R1C1, static_cast< SCROW >( refAddress.StartRow ), static_cast< SCCOL >( refAddress.StartColumn ) ); + dDetails = ScAddress::Details( formula::FormulaGrammar::CONV_XL_R1C1, static_cast< SCROW >( refAddress.StartRow ), static_cast< SCCOL >( refAddress.StartColumn ) ); } aRange.Format( sRange, nFlags, pDoc, dDetails ); return sRange; @@ -1986,7 +1988,7 @@ ScVbaRange::Rows(const uno::Any& aIndex ) throw (uno::RuntimeException) else if ( aIndex >>= sAddress ) { - ScAddress::Details dDetails( ScAddress::CONV_XL_A1, 0, 0 ); + ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 ); ScRange tmpRange; tmpRange.ParseRows( sAddress, getDocumentFromRange( mxRange ), dDetails ); nStartRow = tmpRange.aStart.Row(); @@ -2033,7 +2035,7 @@ ScVbaRange::Columns(const uno::Any& aIndex ) throw (uno::RuntimeException) else if ( aIndex >>= sAddress ) { - ScAddress::Details dDetails( ScAddress::CONV_XL_A1, 0, 0 ); + ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 ); ScRange tmpRange; tmpRange.ParseCols( sAddress, getDocumentFromRange( mxRange ), dDetails ); nStartCol = tmpRange.aStart.Col(); diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx index 9844b732736b..37702bcf16a8 100644 --- a/sc/source/ui/vba/vbarange.hxx +++ b/sc/source/ui/vba/vbarange.hxx @@ -1,275 +1,275 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: vbarange.hxx,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SC_VBA_RANGE_HXX -#define SC_VBA_RANGE_HXX - -#include <cppuhelper/implbase4.hxx> -#include <com/sun/star/container/XEnumerationAccess.hpp> - -#include <org/openoffice/excel/XRange.hpp> -#include <com/sun/star/table/XCellRange.hpp> -#include <org/openoffice/excel/XFont.hpp> -#include <org/openoffice/excel/XComment.hpp> -#include <org/openoffice/vba/XCollection.hpp> -#include <org/openoffice/excel/XlPasteType.hdl> -#include <org/openoffice/excel/XlPasteSpecialOperation.hdl> - -#include <comphelper/proparrhlp.hxx> -#include <comphelper/propertycontainer.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <com/sun/star/script/XDefaultMethod.hpp> -#include <com/sun/star/script/XDefaultProperty.hpp> -#include <com/sun/star/sheet/FillDateMode.hpp> -#include <com/sun/star/sheet/FillMode.hpp> -#include <com/sun/star/sheet/FillDirection.hpp> -#include <com/sun/star/sheet/XSpreadsheet.hpp> -#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp> - -//#include "vbahelperinterface.hxx" -#include "vbaformat.hxx" - -class ScTableSheetsObj; -class ScCellRangesBase; - -//typedef InheritedHelperInterfaceImpl1< oo::excel::XRange > ScVbaRange_BASE; -typedef ScVbaFormat< oo::excel::XRange > ScVbaRange_BASE; - -class ArrayVisitor -{ -public: - virtual void visitNode( sal_Int32 x, sal_Int32 y, const css::uno::Reference< css::table::XCell >& xCell ) = 0; - virtual ~ArrayVisitor(){} -}; - -class ValueSetter : public ArrayVisitor -{ -public: - virtual bool processValue( const css::uno::Any& aValue, const css::uno::Reference< css::table::XCell >& xCell ) = 0; - - -}; - -class ValueGetter : public ArrayVisitor -{ - -public: - virtual void processValue( sal_Int32 x, sal_Int32 y, const css::uno::Any& aValue ) = 0; - virtual const css::uno::Any& getValue() const = 0; -}; - - - -class ScVbaRange : public ScVbaRange_BASE -{ - css::uno::Reference< oo::vba::XCollection > m_Areas; - css::uno::Reference< oo::vba::XCollection > m_Borders; - css::uno::Reference< css::table::XCellRange > mxRange; - css::uno::Reference< css::sheet::XSheetCellRangeContainer > mxRanges; - sal_Bool mbIsRows; - sal_Bool mbIsColumns; - css::uno::Reference< oo::excel::XValidation > m_xValidation; - double getCalcColWidth( const css::table::CellRangeAddress& ) throw (css::uno::RuntimeException); - double getCalcRowHeight( const css::table::CellRangeAddress& ) throw (css::uno::RuntimeException); - void visitArray( ArrayVisitor& vistor ); - - css::uno::Reference< oo::excel::XRange > getEntireColumnOrRow( bool bColumn = true ) throw( css::uno::RuntimeException ); - - void fillSeries( css::sheet::FillDirection nFillDirection, css::sheet::FillMode nFillMode, css::sheet::FillDateMode nFillDateMode, double fStep, double fEndValue ) throw( css::uno::RuntimeException ); - - void ClearContents( sal_Int32 nFlags ) throw (css::uno::RuntimeException); - virtual void setValue( const css::uno::Any& aValue, ValueSetter& setter) throw ( css::uno::RuntimeException); - virtual css::uno::Any getValue( ValueGetter& rValueGetter ) throw (css::uno::RuntimeException); - virtual css::uno::Any getFormulaValue( ScGrammar::Grammar ) throw (css::uno::RuntimeException); - virtual void setFormulaValue( const css::uno::Any& aValue, ScGrammar::Grammar ) throw ( css::uno::RuntimeException); - css::uno::Reference< oo::excel::XRange > getArea( sal_Int32 nIndex ) throw( css::uno::RuntimeException ); - ScCellRangesBase* getCellRangesBase() throw ( css::uno::RuntimeException ); - SfxItemSet* getCurrentDataSet( ) throw ( css::uno::RuntimeException ); - css::uno::Reference< oo::vba::XCollection >& getBorders(); - void groupUnGroup( bool bUnGroup = false ) throw ( css::script::BasicErrorException, css::uno::RuntimeException ); - css::uno::Reference< oo::excel::XRange > PreviousNext( bool bIsPrevious ); - css::uno::Reference< oo::excel::XRange > SpecialCellsImpl( sal_Int32 nType, const css::uno::Any& _oValue) throw ( css::script::BasicErrorException ); - css::awt::Point getPosition() throw ( css::uno::RuntimeException ); -public: - ScVbaRange( const css::uno::Reference< oo::vba::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::table::XCellRange >& xRange, sal_Bool bIsRows = false, sal_Bool bIsColumns = false ) throw ( css::lang::IllegalArgumentException ); - ScVbaRange( const css::uno::Reference< oo::vba::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges, sal_Bool bIsRows = false, sal_Bool bIsColumns = false ) throw ( css::lang::IllegalArgumentException ); - ScVbaRange( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ) throw ( css::lang::IllegalArgumentException ); - - ScDocument* getScDocument(); - ScDocShell* getScDocShell(); - - virtual ~ScVbaRange(); - virtual css::uno::Reference< oo::vba::XHelperInterface > thisHelperIface() { return this; } - bool isSingleCellRange(); - css::uno::Reference< oo::excel::XRange > intersect( const css::uno::Reference< oo::excel::XRange >& xRange ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - static css::uno::Reference< oo::excel::XRange > getRangeObjectForName( const css::uno::Reference< css::uno::XComponentContext >& xContext, const rtl::OUString& sRangeName, ScDocShell* pDocSh, ScAddress::Convention eConv = ScAddress::CONV_XL_A1 ) throw ( css::uno::RuntimeException ); - - // Attributes - virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); - virtual void SAL_CALL setValue( const css::uno::Any& aValue ) throw ( css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getFormula() throw (css::uno::RuntimeException); - virtual void SAL_CALL setFormula( const css::uno::Any& rFormula ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getFormulaArray() throw (css::uno::RuntimeException); - virtual void SAL_CALL setFormulaArray(const css::uno::Any& rFormula) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getFormulaR1C1() throw (css::uno::RuntimeException); - virtual void SAL_CALL setFormulaR1C1( const css::uno::Any &rFormula ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getRow() throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getColumn() throw (css::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException); - using ScVbaRange_BASE::setNumberFormat; - virtual void SAL_CALL setNumberFormat( const css::uno::Any& rNumberFormat ) throw ( css::script::BasicErrorException, css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getNumberFormat() throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL setMergeCells( const css::uno::Any& bMerge ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getMergeCells() throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL setWrapText( const css::uno::Any& bIsWrapped ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getWrapText() throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL getEntireRow() throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL getEntireColumn() throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XComment > SAL_CALL getComment() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getHidden() throw (css::uno::RuntimeException); - virtual void SAL_CALL setHidden( const css::uno::Any& _hidden ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getColumnWidth() throw (css::uno::RuntimeException); - virtual void SAL_CALL setColumnWidth( const css::uno::Any& _columnwidth ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getRowHeight() throw (css::uno::RuntimeException); - virtual void SAL_CALL setRowHeight( const css::uno::Any& _rowheight ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getWidth() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getHeight() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getTop() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getLeft() throw (css::uno::RuntimeException); - - virtual css::uno::Reference< oo::excel::XWorksheet > SAL_CALL getWorksheet() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getPageBreak() throw (css::uno::RuntimeException); - virtual void SAL_CALL setPageBreak( const css::uno::Any& _pagebreak ) throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XValidation > SAL_CALL getValidation() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getFormulaHidden() throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL setFormulaHidden(const css::uno::Any& aHidden) throw (css::script::BasicErrorException, css::uno::RuntimeException); - // Methods - sal_Bool IsRows() { return mbIsRows; } - sal_Bool IsColumns() { return mbIsColumns; } - virtual css::uno::Reference< oo::excel::XComment > SAL_CALL AddComment( const css::uno::Any& Text ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Clear() throw (css::uno::RuntimeException); - virtual void SAL_CALL ClearComments() throw (css::uno::RuntimeException); - virtual void SAL_CALL ClearContents() throw (css::uno::RuntimeException); - virtual void SAL_CALL ClearFormats() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL HasFormula() throw (css::uno::RuntimeException); - virtual void SAL_CALL FillLeft() throw (css::uno::RuntimeException); - virtual void SAL_CALL FillRight() throw (css::uno::RuntimeException); - virtual void SAL_CALL FillUp() throw (css::uno::RuntimeException); - virtual void SAL_CALL FillDown() throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Offset( const css::uno::Any &nRowOffset, const css::uno::Any &nColOffset ) - throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL CurrentRegion() throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL CurrentArray() throw (css::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL Characters( const css::uno::Any& nIndex, const css::uno::Any& nCount ) - throw (css::uno::RuntimeException); - - virtual ::rtl::OUString SAL_CALL Address( const css::uno::Any& RowAbsolute, const css::uno::Any& ColumnAbsolute, const css::uno::Any& ReferenceStyle, const css::uno::Any& External, const css::uno::Any& RelativeTo ) throw (css::uno::RuntimeException); - - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Cells( const css::uno::Any &nRow, const css::uno::Any &nCol ) - throw (css::uno::RuntimeException); - virtual void SAL_CALL Select() throw (css::uno::RuntimeException); - virtual void SAL_CALL Activate() throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Rows( const css::uno::Any& nIndex ) throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Columns( const css::uno::Any &nIndex ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Copy( const css::uno::Any& Destination ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Cut( const css::uno::Any& Destination ) throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Resize( const css::uno::Any& RowSize, const css::uno::Any& ColumnSize ) - throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XFont > SAL_CALL Font() throw ( css::script::BasicErrorException, css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XInterior > SAL_CALL Interior( ) throw ( css::script::BasicErrorException, css::uno::RuntimeException) ; - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Range( const css::uno::Any &Cell1, const css::uno::Any &Cell2 ) throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XRange > Range( const css::uno::Any &Cell1, const css::uno::Any &Cell2, bool bForceUseInpuRangeTab ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getCellRange( ) throw (css::uno::RuntimeException); - virtual void SAL_CALL PasteSpecial( const css::uno::Any& Paste, const css::uno::Any& Operation, const css::uno::Any& SkipBlanks, const css::uno::Any& Transpose ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL Replace( const ::rtl::OUString& What, const ::rtl::OUString& Replacement, const css::uno::Any& LookAt, const css::uno::Any& SearchOrder, const css::uno::Any& MatchCase, const css::uno::Any& MatchByte, const css::uno::Any& SearchFormat, const css::uno::Any& ReplaceFormat ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Sort( const css::uno::Any& Key1, const css::uno::Any& Order1, const css::uno::Any& Key2, const css::uno::Any& Type, const css::uno::Any& Order2, const css::uno::Any& Key3, const css::uno::Any& Order3, const css::uno::Any& Header, const css::uno::Any& OrderCustom, const css::uno::Any& MatchCase, const css::uno::Any& Orientation, const css::uno::Any& SortMethod, const css::uno::Any& DataOption1, const css::uno::Any& DataOption2, const css::uno::Any& DataOption3 ) throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL End( ::sal_Int32 Direction ) throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XCharacters > SAL_CALL characters( const css::uno::Any& Start, const css::uno::Any& Length ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Delete( const css::uno::Any& Shift ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Areas( const css::uno::Any& ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Borders( const css::uno::Any& ) throw ( css::script::BasicErrorException, css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL BorderAround( const css::uno::Any& LineStyle, - const css::uno::Any& Weight, const css::uno::Any& ColorIndex, const css::uno::Any& Color ) throw (css::uno::RuntimeException); - virtual void SAL_CALL TextToColumns( const css::uno::Any& Destination, const css::uno::Any& DataType, const css::uno::Any& TextQualifier, - const css::uno::Any& ConsecutinveDelimiter, const css::uno::Any& Tab, const css::uno::Any& Semicolon, const css::uno::Any& Comma, - const css::uno::Any& Space, const css::uno::Any& Other, const css::uno::Any& OtherChar, const css::uno::Any& FieldInfo, - const css::uno::Any& DecimalSeparator, const css::uno::Any& ThousandsSeparator, const css::uno::Any& TrailingMinusNumbers ) throw (css::uno::RuntimeException); - - virtual void SAL_CALL AutoFilter( const css::uno::Any& Field, const css::uno::Any& Criteria1, const css::uno::Any& Operator, const css::uno::Any& Criteria2, const css::uno::Any& VisibleDropDown ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Insert( const css::uno::Any& Shift, const css::uno::Any& CopyOrigin ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Autofit() throw (css::uno::RuntimeException); - virtual void SAL_CALL PrintOut( const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName ) throw (css::uno::RuntimeException); - virtual void SAL_CALL AutoFill( const css::uno::Reference< oo::excel::XRange >& Destination, const css::uno::Any& Type ) throw (css::uno::RuntimeException) ; - void SAL_CALL Calculate( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL AutoOutline( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Item( const ::css::uno::Any& row, const css::uno::Any& column ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL ClearOutline( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL Ungroup( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL Group( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL Merge( const css::uno::Any& Across ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL UnMerge( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getStyle() throw (css::uno::RuntimeException); - virtual void SAL_CALL setStyle( const css::uno::Any& _style ) throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Next() throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Previous() throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL RemoveSubtotal( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL Subtotal( ::sal_Int32 GroupBy, ::sal_Int32 Function, const css::uno::Sequence< ::sal_Int32 >& TotalList, const css::uno::Any& Replace, const css::uno::Any& PageBreaks, const css::uno::Any& SummaryBelowData ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - // XEnumerationAccess - virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); - // XElementAccess - virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException) - { - return oo::excel::XRange::static_type(0); - - } - virtual sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException); - // XDefaultMethod - ::rtl::OUString SAL_CALL getDefaultMethodName( ) throw (css::uno::RuntimeException); - // XDefaultProperty - ::rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } - - -// #TODO completely rewrite ScVbaRange, its become a hackfest -// it needs to be closer to ScCellRangeBase in that the underlying -// object model should probably be a ScRangelst. -// * would be nice to be able to construct a range from an addres only -// * or a list of address ( multi-area ) -// * object should be a lightweight as possible -// * we shouldn't need hacks like this below - static css::uno::Reference< oo::excel::XRange > ApplicationRange( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Any &Cell1, const css::uno::Any &Cell2 ) throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL GoalSeek( const css::uno::Any& Goal, const css::uno::Reference< oo::excel::XRange >& ChangingCell ) throw (css::uno::RuntimeException); - virtual css::uno::Reference< oo::excel::XRange > SAL_CALL SpecialCells( const css::uno::Any& _oType, const css::uno::Any& _oValue) throw ( css::script::BasicErrorException ); - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SC_VBA_RANGE_HXX */ - +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vbarange.hxx,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_RANGE_HXX
+#define SC_VBA_RANGE_HXX
+
+#include <cppuhelper/implbase4.hxx>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+
+#include <org/openoffice/excel/XRange.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <org/openoffice/excel/XFont.hpp>
+#include <org/openoffice/excel/XComment.hpp>
+#include <org/openoffice/vba/XCollection.hpp>
+#include <org/openoffice/excel/XlPasteType.hdl>
+#include <org/openoffice/excel/XlPasteSpecialOperation.hdl>
+
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/script/XDefaultMethod.hpp>
+#include <com/sun/star/script/XDefaultProperty.hpp>
+#include <com/sun/star/sheet/FillDateMode.hpp>
+#include <com/sun/star/sheet/FillMode.hpp>
+#include <com/sun/star/sheet/FillDirection.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
+
+//#include "vbahelperinterface.hxx"
+#include "vbaformat.hxx"
+
+class ScTableSheetsObj;
+class ScCellRangesBase;
+
+//typedef InheritedHelperInterfaceImpl1< oo::excel::XRange > ScVbaRange_BASE;
+typedef ScVbaFormat< oo::excel::XRange > ScVbaRange_BASE;
+
+class ArrayVisitor
+{
+public:
+ virtual void visitNode( sal_Int32 x, sal_Int32 y, const css::uno::Reference< css::table::XCell >& xCell ) = 0;
+ virtual ~ArrayVisitor(){}
+};
+
+class ValueSetter : public ArrayVisitor
+{
+public:
+ virtual bool processValue( const css::uno::Any& aValue, const css::uno::Reference< css::table::XCell >& xCell ) = 0;
+
+
+};
+
+class ValueGetter : public ArrayVisitor
+{
+
+public:
+ virtual void processValue( sal_Int32 x, sal_Int32 y, const css::uno::Any& aValue ) = 0;
+ virtual const css::uno::Any& getValue() const = 0;
+};
+
+
+
+class ScVbaRange : public ScVbaRange_BASE
+{
+ css::uno::Reference< oo::vba::XCollection > m_Areas;
+ css::uno::Reference< oo::vba::XCollection > m_Borders;
+ css::uno::Reference< css::table::XCellRange > mxRange;
+ css::uno::Reference< css::sheet::XSheetCellRangeContainer > mxRanges;
+ sal_Bool mbIsRows;
+ sal_Bool mbIsColumns;
+ css::uno::Reference< oo::excel::XValidation > m_xValidation;
+ double getCalcColWidth( const css::table::CellRangeAddress& ) throw (css::uno::RuntimeException);
+ double getCalcRowHeight( const css::table::CellRangeAddress& ) throw (css::uno::RuntimeException);
+ void visitArray( ArrayVisitor& vistor );
+
+ css::uno::Reference< oo::excel::XRange > getEntireColumnOrRow( bool bColumn = true ) throw( css::uno::RuntimeException );
+
+ void fillSeries( css::sheet::FillDirection nFillDirection, css::sheet::FillMode nFillMode, css::sheet::FillDateMode nFillDateMode, double fStep, double fEndValue ) throw( css::uno::RuntimeException );
+
+ void ClearContents( sal_Int32 nFlags ) throw (css::uno::RuntimeException);
+ virtual void setValue( const css::uno::Any& aValue, ValueSetter& setter) throw ( css::uno::RuntimeException);
+ virtual css::uno::Any getValue( ValueGetter& rValueGetter ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any getFormulaValue( formula::FormulaGrammar::Grammar ) throw (css::uno::RuntimeException);
+ virtual void setFormulaValue( const css::uno::Any& aValue, formula::FormulaGrammar::Grammar ) throw ( css::uno::RuntimeException);
+ css::uno::Reference< oo::excel::XRange > getArea( sal_Int32 nIndex ) throw( css::uno::RuntimeException );
+ ScCellRangesBase* getCellRangesBase() throw ( css::uno::RuntimeException );
+ SfxItemSet* getCurrentDataSet( ) throw ( css::uno::RuntimeException );
+ css::uno::Reference< oo::vba::XCollection >& getBorders();
+ void groupUnGroup( bool bUnGroup = false ) throw ( css::script::BasicErrorException, css::uno::RuntimeException );
+ css::uno::Reference< oo::excel::XRange > PreviousNext( bool bIsPrevious );
+ css::uno::Reference< oo::excel::XRange > SpecialCellsImpl( sal_Int32 nType, const css::uno::Any& _oValue) throw ( css::script::BasicErrorException );
+ css::awt::Point getPosition() throw ( css::uno::RuntimeException );
+public:
+ ScVbaRange( const css::uno::Reference< oo::vba::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::table::XCellRange >& xRange, sal_Bool bIsRows = false, sal_Bool bIsColumns = false ) throw ( css::lang::IllegalArgumentException );
+ ScVbaRange( const css::uno::Reference< oo::vba::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges, sal_Bool bIsRows = false, sal_Bool bIsColumns = false ) throw ( css::lang::IllegalArgumentException );
+ ScVbaRange( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ) throw ( css::lang::IllegalArgumentException );
+
+ ScDocument* getScDocument();
+ ScDocShell* getScDocShell();
+
+ virtual ~ScVbaRange();
+ virtual css::uno::Reference< oo::vba::XHelperInterface > thisHelperIface() { return this; }
+ bool isSingleCellRange();
+ css::uno::Reference< oo::excel::XRange > intersect( const css::uno::Reference< oo::excel::XRange >& xRange ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ static css::uno::Reference< oo::excel::XRange > getRangeObjectForName( const css::uno::Reference< css::uno::XComponentContext >& xContext, const rtl::OUString& sRangeName, ScDocShell* pDocSh, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( css::uno::RuntimeException );
+
+ // Attributes
+ virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const css::uno::Any& aValue ) throw ( css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getFormula() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFormula( const css::uno::Any& rFormula ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getFormulaArray() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFormulaArray(const css::uno::Any& rFormula) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getFormulaR1C1() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFormulaR1C1( const css::uno::Any &rFormula ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getRow() throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getColumn() throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
+ using ScVbaRange_BASE::setNumberFormat;
+ virtual void SAL_CALL setNumberFormat( const css::uno::Any& rNumberFormat ) throw ( css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getNumberFormat() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setMergeCells( const css::uno::Any& bMerge ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getMergeCells() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setWrapText( const css::uno::Any& bIsWrapped ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getWrapText() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL getEntireRow() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL getEntireColumn() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XComment > SAL_CALL getComment() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getHidden() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setHidden( const css::uno::Any& _hidden ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getColumnWidth() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setColumnWidth( const css::uno::Any& _columnwidth ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getRowHeight() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setRowHeight( const css::uno::Any& _rowheight ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getWidth() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getHeight() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getTop() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getLeft() throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference< oo::excel::XWorksheet > SAL_CALL getWorksheet() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getPageBreak() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setPageBreak( const css::uno::Any& _pagebreak ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XValidation > SAL_CALL getValidation() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getFormulaHidden() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setFormulaHidden(const css::uno::Any& aHidden) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // Methods
+ sal_Bool IsRows() { return mbIsRows; }
+ sal_Bool IsColumns() { return mbIsColumns; }
+ virtual css::uno::Reference< oo::excel::XComment > SAL_CALL AddComment( const css::uno::Any& Text ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Clear() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL ClearComments() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL ClearContents() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL ClearFormats() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL HasFormula() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL FillLeft() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL FillRight() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL FillUp() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL FillDown() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Offset( const css::uno::Any &nRowOffset, const css::uno::Any &nColOffset )
+ throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL CurrentRegion() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL CurrentArray() throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL Characters( const css::uno::Any& nIndex, const css::uno::Any& nCount )
+ throw (css::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL Address( const css::uno::Any& RowAbsolute, const css::uno::Any& ColumnAbsolute, const css::uno::Any& ReferenceStyle, const css::uno::Any& External, const css::uno::Any& RelativeTo ) throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Cells( const css::uno::Any &nRow, const css::uno::Any &nCol )
+ throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Select() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Activate() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Rows( const css::uno::Any& nIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Columns( const css::uno::Any &nIndex ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Copy( const css::uno::Any& Destination ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Cut( const css::uno::Any& Destination ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Resize( const css::uno::Any& RowSize, const css::uno::Any& ColumnSize )
+ throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XFont > SAL_CALL Font() throw ( css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XInterior > SAL_CALL Interior( ) throw ( css::script::BasicErrorException, css::uno::RuntimeException) ;
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Range( const css::uno::Any &Cell1, const css::uno::Any &Cell2 ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XRange > Range( const css::uno::Any &Cell1, const css::uno::Any &Cell2, bool bForceUseInpuRangeTab ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getCellRange( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL PasteSpecial( const css::uno::Any& Paste, const css::uno::Any& Operation, const css::uno::Any& SkipBlanks, const css::uno::Any& Transpose ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL Replace( const ::rtl::OUString& What, const ::rtl::OUString& Replacement, const css::uno::Any& LookAt, const css::uno::Any& SearchOrder, const css::uno::Any& MatchCase, const css::uno::Any& MatchByte, const css::uno::Any& SearchFormat, const css::uno::Any& ReplaceFormat ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Sort( const css::uno::Any& Key1, const css::uno::Any& Order1, const css::uno::Any& Key2, const css::uno::Any& Type, const css::uno::Any& Order2, const css::uno::Any& Key3, const css::uno::Any& Order3, const css::uno::Any& Header, const css::uno::Any& OrderCustom, const css::uno::Any& MatchCase, const css::uno::Any& Orientation, const css::uno::Any& SortMethod, const css::uno::Any& DataOption1, const css::uno::Any& DataOption2, const css::uno::Any& DataOption3 ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL End( ::sal_Int32 Direction ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XCharacters > SAL_CALL characters( const css::uno::Any& Start, const css::uno::Any& Length ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Delete( const css::uno::Any& Shift ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Areas( const css::uno::Any& ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Borders( const css::uno::Any& ) throw ( css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL BorderAround( const css::uno::Any& LineStyle,
+ const css::uno::Any& Weight, const css::uno::Any& ColorIndex, const css::uno::Any& Color ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL TextToColumns( const css::uno::Any& Destination, const css::uno::Any& DataType, const css::uno::Any& TextQualifier,
+ const css::uno::Any& ConsecutinveDelimiter, const css::uno::Any& Tab, const css::uno::Any& Semicolon, const css::uno::Any& Comma,
+ const css::uno::Any& Space, const css::uno::Any& Other, const css::uno::Any& OtherChar, const css::uno::Any& FieldInfo,
+ const css::uno::Any& DecimalSeparator, const css::uno::Any& ThousandsSeparator, const css::uno::Any& TrailingMinusNumbers ) throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL AutoFilter( const css::uno::Any& Field, const css::uno::Any& Criteria1, const css::uno::Any& Operator, const css::uno::Any& Criteria2, const css::uno::Any& VisibleDropDown ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Insert( const css::uno::Any& Shift, const css::uno::Any& CopyOrigin ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Autofit() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL PrintOut( const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL AutoFill( const css::uno::Reference< oo::excel::XRange >& Destination, const css::uno::Any& Type ) throw (css::uno::RuntimeException) ;
+ void SAL_CALL Calculate( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL AutoOutline( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Item( const ::css::uno::Any& row, const css::uno::Any& column ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL ClearOutline( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL Ungroup( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL Group( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL Merge( const css::uno::Any& Across ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL UnMerge( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setStyle( const css::uno::Any& _style ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Next() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Previous() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL RemoveSubtotal( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL Subtotal( ::sal_Int32 GroupBy, ::sal_Int32 Function, const css::uno::Sequence< ::sal_Int32 >& TotalList, const css::uno::Any& Replace, const css::uno::Any& PageBreaks, const css::uno::Any& SummaryBelowData ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // XEnumerationAccess
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+ // XElementAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException)
+ {
+ return oo::excel::XRange::static_type(0);
+
+ }
+ virtual sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException);
+ // XDefaultMethod
+ ::rtl::OUString SAL_CALL getDefaultMethodName( ) throw (css::uno::RuntimeException);
+ // XDefaultProperty
+ ::rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
+
+
+// #TODO completely rewrite ScVbaRange, its become a hackfest
+// it needs to be closer to ScCellRangeBase in that the underlying
+// object model should probably be a ScRangelst.
+// * would be nice to be able to construct a range from an addres only
+// * or a list of address ( multi-area )
+// * object should be a lightweight as possible
+// * we shouldn't need hacks like this below
+ static css::uno::Reference< oo::excel::XRange > ApplicationRange( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Any &Cell1, const css::uno::Any &Cell2 ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL GoalSeek( const css::uno::Any& Goal, const css::uno::Reference< oo::excel::XRange >& ChangingCell ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< oo::excel::XRange > SAL_CALL SpecialCells( const css::uno::Any& _oType, const css::uno::Any& _oValue) throw ( css::script::BasicErrorException );
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SC_VBA_RANGE_HXX */
+
diff --git a/sc/source/ui/view/colrowba.cxx b/sc/source/ui/view/colrowba.cxx index 66a5815b9782..984006d365d6 100644 --- a/sc/source/ui/view/colrowba.cxx +++ b/sc/source/ui/view/colrowba.cxx @@ -89,7 +89,7 @@ ScColBar::~ScColBar() inline BOOL ScColBar::UseNumericHeader() const { - return pViewData->GetDocument()->GetAddressConvention() == ScAddress::CONV_XL_R1C1; + return pViewData->GetDocument()->GetAddressConvention() == formula::FormulaGrammar::CONV_XL_R1C1; } SCCOLROW ScColBar::GetPos() diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 9123704a6ff9..47b1e083e26f 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -3936,18 +3936,19 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos aSource.Format( aItem, SCA_VALID | SCA_TAB_3D, pSourceDoc ); // TODO: we could define ocQuote for " - String aQuote( '"' ); + const String aQuote( '"' ); + const String& sSep = ScCompiler::GetNativeSymbol( ocSep); String aFormula( '=' ); aFormula += ScCompiler::GetNativeSymbol( ocDde); aFormula += ScCompiler::GetNativeSymbol( ocOpen); aFormula += aQuote; aFormula += aApp; aFormula += aQuote; - aFormula += ScCompiler::GetNativeSymbol( ocSep); + aFormula += sSep; aFormula += aQuote; aFormula += aTopic; aFormula += aQuote; - aFormula += ScCompiler::GetNativeSymbol( ocSep); + aFormula += sSep; aFormula += aQuote; aFormula += aItem; aFormula += aQuote; diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 445f029c6039..46552b7d34d7 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -1751,7 +1751,7 @@ void ScTabView::SetTabNo( SCTAB nTab, BOOL bNew, BOOL bExtendSelection ) SfxChildWindow* pChildWnd = pViewFrm->GetChildWindow( nCurRefDlgId ); if ( pChildWnd ) { - ScAnyRefDlg* pRefDlg = (ScAnyRefDlg*)pChildWnd->GetWindow(); + IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow()); pRefDlg->ViewShellChanged(NULL); } } diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx index dab177c97e8b..f0b6fb7565a1 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -103,7 +103,7 @@ USHORT lcl_ParseRange(ScRange& rScRange, const String& aAddress, ScDocument* pDo if ( (nResult & SCA_VALID) ) return nResult; - return rScRange.Parse(aAddress, pDoc, ScAddress::Details(ScAddress::CONV_XL_A1, 0, 0)); + return rScRange.Parse(aAddress, pDoc, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1, 0, 0)); } /** Try to parse the given address using Calc-style syntax first, then @@ -114,7 +114,7 @@ USHORT lcl_ParseAddress(ScAddress& rScAddress, const String& aAddress, ScDocumen if ( (nResult & SCA_VALID) ) return nResult; - return rScAddress.Parse(aAddress, pDoc, ScAddress::Details(ScAddress::CONV_XL_A1, 0, 0)); + return rScAddress.Parse(aAddress, pDoc, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1, 0, 0)); } void ScTabViewShell::Execute( SfxRequest& rReq ) @@ -314,7 +314,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) else { ScRangeUtil aRangeUtil; - ScAddress::Convention eConv = pDoc->GetAddressConvention(); + formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention(); if( aRangeUtil.MakeRangeFromName( aAddress, pDoc, nTab, aScRange, RUTL_NAMES, eConv ) || aRangeUtil.MakeRangeFromName( aAddress, pDoc, nTab, aScRange, RUTL_DBASE, eConv ) ) { diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index d246b5cf0968..680c1ce0f40a 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -224,7 +224,7 @@ void __EXPORT ScTabViewShell::Activate(BOOL bMDI) SfxChildWindow* pChildWnd = pThisFrame->GetChildWindow( nModRefDlgId ); if ( pChildWnd ) { - ScAnyRefDlg* pRefDlg = (ScAnyRefDlg*)pChildWnd->GetWindow(); + IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow()); pRefDlg->ViewShellChanged(this); } } diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx index 3ef2561bf2b3..cd28936afe98 100644 --- a/sc/source/ui/view/tabvwsha.cxx +++ b/sc/source/ui/view/tabvwsha.cxx @@ -544,7 +544,8 @@ bool ScTabViewShell::IsRefInputMode() const if ( pDoc ) { const ScAddress aPos( pViewData->GetCurPos() ); - ScCompiler aComp( pDoc, aPos, pDoc->GetGrammar() ); + ScCompiler aComp( pDoc, aPos ); + aComp.SetGrammar(pDoc->GetGrammar()); aComp.SetCloseBrackets( false ); ScTokenArray* pArr = aComp.CompileString( aString ); if ( pArr && pArr->MayReferenceFollow() ) diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index eb1cdf38ff12..b27902805189 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -70,6 +70,7 @@ #include "acredlin.hxx" #include "highred.hxx" #include "simpref.hxx" +#include "funcdesc.hxx" #include "dpobject.hxx" //------------------------------------------------------------------ @@ -283,7 +284,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( { // Dialog schaut selber, was in der Zelle steht - pResult = new ScFormulaDlg( pB, pCW, pParent, GetViewData() ); + pResult = new ScFormulaDlg( pB, pCW, pParent, GetViewData(),ScGlobal::GetStarCalcFunctionMgr() ); } break; diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 36b2b43b4e81..1d724541b679 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -981,7 +981,7 @@ void ScViewFunc::SetPrintRanges( BOOL bEntireSheet, const String* pPrint, { if ( pPrint->Len() ) { - const sal_Unicode sep = ScCompiler::GetStringFromOpCode(ocSep).GetChar(0); + const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0); USHORT nTCount = pPrint->GetTokenCount(sep); for (USHORT i=0; i<nTCount; i++) { diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx index beb2d7bf56f5..2c4890a5f861 100644 --- a/sc/source/ui/view/viewfun5.cxx +++ b/sc/source/ui/view/viewfun5.cxx @@ -702,18 +702,19 @@ BOOL ScViewFunc::PasteDDE( const uno::Reference<datatransfer::XTransferable>& rx String aItem( aByteItem, eSysEnc ); // TODO: we could define ocQuote for " - String aQuote( '"' ); + const String aQuote( '"' ); + const String& sSep = ScCompiler::GetNativeSymbol( ocSep); String aFormula( '=' ); aFormula += ScCompiler::GetNativeSymbol( ocDde); aFormula += ScCompiler::GetNativeSymbol( ocOpen); aFormula += aQuote; aFormula += aApp; aFormula += aQuote; - aFormula += ScCompiler::GetNativeSymbol( ocSep); + aFormula += sSep; aFormula += aQuote; aFormula += aTopic; aFormula += aQuote; - aFormula += ScCompiler::GetNativeSymbol( ocSep); + aFormula += sSep; aFormula += aQuote; aFormula += aItem; aFormula += aQuote; diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 4abb89d551de..d5cbd4690080 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -462,7 +462,8 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS if (rMark.GetTableSelect(i)) break; ScAddress aPos( nCol, nRow, i ); - ScCompiler aComp( pDoc, aPos, pDoc->GetGrammar() ); + ScCompiler aComp( pDoc, aPos); + aComp.SetGrammar(pDoc->GetGrammar()); //2do: AutoCorrection via CalcOptions abschaltbar machen aComp.SetAutoCorrection( TRUE ); if ( rString.GetChar(0) == '+' || rString.GetChar(0) == '-' ) @@ -543,12 +544,12 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS ScAppOptions aAppOpt = pScMod->GetAppOptions(); BOOL bOptChanged = FALSE; - ScToken** ppToken = pArr->GetArray(); + formula::FormulaToken** ppToken = pArr->GetArray(); USHORT nTokens = pArr->GetLen(); USHORT nLevel = 0; for (USHORT nTP=0; nTP<nTokens; nTP++) { - ScToken* pTok = ppToken[nTP]; + formula::FormulaToken* pTok = ppToken[nTP]; OpCode eOp = pTok->GetOpCode(); if ( eOp == ocOpen ) ++nLevel; @@ -566,7 +567,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS } } - ScFormulaCell aCell( pDoc, aPos, pArr, ScGrammar::GRAM_DEFAULT, MM_NONE ); + ScFormulaCell aCell( pDoc, aPos, pArr,formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE ); delete pArr; BOOL bAutoCalc = pDoc->GetAutoCalc(); SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); @@ -867,7 +868,7 @@ void ScViewFunc::EnterMatrix( const String& rString ) SCCOL nCol = pData->GetCurX(); SCROW nRow = pData->GetCurY(); SCTAB nTab = pData->GetTabNo(); - ScFormulaCell aFormCell( pDoc, ScAddress(nCol,nRow,nTab), rString, ScGrammar::GRAM_DEFAULT, MM_FORMULA ); + ScFormulaCell aFormCell( pDoc, ScAddress(nCol,nRow,nTab), rString,formula::FormulaGrammar::GRAM_DEFAULT, MM_FORMULA ); SCSIZE nSizeX; SCSIZE nSizeY; @@ -887,7 +888,7 @@ void ScViewFunc::EnterMatrix( const String& rString ) if (pData->GetSimpleArea(aRange) == SC_MARK_SIMPLE) { ScDocShell* pDocSh = pData->GetDocShell(); - BOOL bSuccess = pDocSh->GetDocFunc().EnterMatrix( aRange, &rMark, NULL, rString, FALSE, FALSE, ScGrammar::GRAM_DEFAULT ); + BOOL bSuccess = pDocSh->GetDocFunc().EnterMatrix( aRange, &rMark, NULL, rString, FALSE, FALSE,formula::FormulaGrammar::GRAM_DEFAULT ); if (bSuccess) pDocSh->UpdateOle(GetViewData()); } |