diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-07-29 14:46:52 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-07-29 14:46:52 +0000 |
commit | 32cd63b065ce197e0e141177e3cde3858e8f91c0 (patch) | |
tree | d56ff441aa296af7e529d65143d9547bdbee64bc /sc/inc | |
parent | ab8dd2505c7486eed6f9ab9d4a4fba6e586ce81b (diff) |
CWS-TOOLING: integrate CWS dr71
2009-07-07 16:26:00 +0200 dr r273805 : #i10000# unused variables
2009-07-07 10:27:14 +0200 dr r273780 : CWS-TOOLING: rebase CWS dr71 to trunk@273468 (milestone: DEV300:m51)
2009-07-01 11:28:24 +0200 dr r273559 : #101471# special handling for XL library functions in ODF formulas (EUROCONVERT)
2009-06-29 17:48:46 +0200 dr r273478 : #i101471# typo
2009-06-29 17:35:16 +0200 dr r273477 : #i101471# import msoxl: formulas from conditional formatting and data validation
2009-06-18 13:45:17 +0200 dr r273115 : #101471# changed interface css.sheet.XFormulaParser
2009-06-18 13:44:43 +0200 dr r273114 : #101471# changed interface css.sheet.XFormulaParser
2009-06-17 17:29:23 +0200 dr r273089 : #i101471# extend the XFormulaParser interface with a ReferencePosition parameter, make rel-refs from msoxl: namespace working
2009-06-17 17:28:39 +0200 dr r273088 : #i101471# extend the XFormulaParser interface with a ReferencePosition parameter
2009-06-17 17:28:19 +0200 dr r273087 : #i101471# extend the XFormulaParser interface with a ReferencePosition parameter
2009-06-17 17:27:19 +0200 dr r273086 : #i101471# extend the XFormulaParser interface with a ReferencePosition parameter, remove that property from FormulaParser service
2009-06-17 12:52:20 +0200 dr r273059 : #i101471# import cell formulas from msoxl: namespace
2009-06-16 11:40:50 +0200 dr r273013 : #i101471# import formula namespace from xml elements
2009-06-12 18:34:13 +0200 dr r272935 : #i101471# external formula parser for oox in odf
2009-06-12 18:33:13 +0200 dr r272934 : #i101471# external formula parsers
2009-06-12 18:29:46 +0200 dr r272933 : #i101471# external formula parsers
2009-06-05 15:53:47 +0200 dr r272705 : #i101471# provide OOX formula parser as UNO service
Diffstat (limited to 'sc/inc')
-rw-r--r-- | sc/inc/cellsuno.hxx | 12 | ||||
-rw-r--r-- | sc/inc/compiler.hxx | 5 | ||||
-rw-r--r-- | sc/inc/conditio.hxx | 19 | ||||
-rw-r--r-- | sc/inc/document.hxx | 10 | ||||
-rw-r--r-- | sc/inc/fmtuno.hxx | 33 | ||||
-rw-r--r-- | sc/inc/formulaparserpool.hxx | 70 | ||||
-rw-r--r-- | sc/inc/tokenuno.hxx | 20 | ||||
-rw-r--r-- | sc/inc/unonames.hxx | 6 | ||||
-rw-r--r-- | sc/inc/validat.hxx | 4 |
9 files changed, 146 insertions, 33 deletions
diff --git a/sc/inc/cellsuno.hxx b/sc/inc/cellsuno.hxx index e73869489ebc..2dd0bd6cc16e 100644 --- a/sc/inc/cellsuno.hxx +++ b/sc/inc/cellsuno.hxx @@ -629,9 +629,10 @@ protected: throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); - void SetArrayFormula_Impl( const rtl::OUString& aFormula, - const formula::FormulaGrammar::Grammar eGrammar ) - throw(::com::sun::star::uno::RuntimeException); + void SetArrayFormula_Impl( const rtl::OUString& rFormula, + const rtl::OUString& rFormulaNmsp, + const formula::FormulaGrammar::Grammar eGrammar ) + throw(::com::sun::star::uno::RuntimeException); public: ScCellRangeObj(ScDocShell* pDocSh, const ScRange& rR); @@ -650,7 +651,8 @@ public: virtual void RefChanged(); // via getImplementation() - virtual void SetArrayFormulaWithGrammar( const ::rtl::OUString& aFormula, + virtual void SetArrayFormulaWithGrammar( const ::rtl::OUString& rFormula, + const ::rtl::OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar ) throw(::com::sun::star::uno::RuntimeException); @@ -869,7 +871,7 @@ public: void SetFormulaResultString( const ::rtl::OUString& rResult ); void SetFormulaResultDouble( double fResult ); void SetFormulaWithGrammar( const ::rtl::OUString& rFormula, - const formula::FormulaGrammar::Grammar ); + const ::rtl::OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar ); const ScAddress& GetPosition() const { return aCellPos; } // XText diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx index 9f245322fdb7..058b3b30f30a 100644 --- a/sc/inc/compiler.hxx +++ b/sc/inc/compiler.hxx @@ -354,9 +354,9 @@ public: const formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO ); static BOOL EnQuote( String& rStr ); - sal_Unicode GetNativeAddressSymbol( Convention::SpecialSymbolType eType ) const; + // Check if it is a valid english function name bool IsEnglishSymbol( const String& rName ); @@ -396,6 +396,8 @@ public: maExternalLinks = rLinks; } + void CreateStringFromXMLTokenArray( String& rFormula, String& rFormulaNmsp ); + void SetExtendedErrorDetection( bool bVal ) { mbExtendedErrorDetection = bVal; } BOOL IsCorrected() { return bCorrected; } @@ -403,6 +405,7 @@ public: // Use convention from this->aPos by default ScTokenArray* CompileString( const String& rFormula ); + ScTokenArray* CompileString( const String& rFormula, const String& rFormulaNmsp ); const ScDocument* GetDoc() const { return pDoc; } const ScAddress& GetPos() const { return aPos; } diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index 42a030b8e809..edb0f9371788 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -84,7 +84,10 @@ class SC_DLLPUBLIC ScConditionEntry double nVal2; String aStrVal1; // eingegeben oder berechnet String aStrVal2; - formula::FormulaGrammar::Grammar eTempGrammar; // grammar to be used on (re)compilation, e.g. in XML import + String aStrNmsp1; // namespace to be used on (re)compilation, e.g. in XML import + String aStrNmsp2; // namespace to be used on (re)compilation, e.g. in XML import + formula::FormulaGrammar::Grammar eTempGrammar1; // grammar to be used on (re)compilation, e.g. in XML import + formula::FormulaGrammar::Grammar eTempGrammar2; // grammar to be used on (re)compilation, e.g. in XML import BOOL bIsStr1; // um auch leere Strings zu erkennen BOOL bIsStr2; ScTokenArray* pFormula1; // eingegebene Formel @@ -101,7 +104,10 @@ class SC_DLLPUBLIC ScConditionEntry void MakeCells( const ScAddress& rPos ); void Compile( const String& rExpr1, const String& rExpr2, - const formula::FormulaGrammar::Grammar eGrammar, BOOL bTextToReal ); + const String& rExprNmsp1, const String& rExprNmsp2, + formula::FormulaGrammar::Grammar eGrammar1, + formula::FormulaGrammar::Grammar eGrammar2, + BOOL bTextToReal ); void Interpret( const ScAddress& rPos ); BOOL IsValid( double nArg ) const; @@ -111,7 +117,9 @@ public: ScConditionEntry( ScConditionMode eOper, const String& rExpr1, const String& rExpr2, ScDocument* pDocument, const ScAddress& rPos, - const formula::FormulaGrammar::Grammar eGrammar ); + const String& rExprNmsp1, const String& rExprNmsp2, + formula::FormulaGrammar::Grammar eGrammar1, + formula::FormulaGrammar::Grammar eGrammar2 ); ScConditionEntry( ScConditionMode eOper, const ScTokenArray* pArr1, const ScTokenArray* pArr2, ScDocument* pDocument, const ScAddress& rPos ); @@ -174,7 +182,10 @@ public: const String& rExpr1, const String& rExpr2, ScDocument* pDocument, const ScAddress& rPos, const String& rStyle, - const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ); + const String& rExprNmsp1 = EMPTY_STRING, + const String& rExprNmsp2 = EMPTY_STRING, + formula::FormulaGrammar::Grammar eGrammar1 = formula::FormulaGrammar::GRAM_DEFAULT, + formula::FormulaGrammar::Grammar eGrammar2 = formula::FormulaGrammar::GRAM_DEFAULT ); ScCondFormatEntry( ScConditionMode eOper, const ScTokenArray* pArr1, const ScTokenArray* pArr2, ScDocument* pDocument, const ScAddress& rPos, diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 17c3234a7723..c8d3751a7aaf 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -139,6 +139,7 @@ class ScTemporaryChartLock; class ScLookupCache; struct ScLookupCacheMapImpl; class SfxUndoManager; +class ScFormulaParserPool; namespace com { namespace sun { namespace star { namespace lang { @@ -291,6 +292,11 @@ private: ::std::auto_ptr<ScDocProtection> pDocProtection; ::std::auto_ptr<ScExternalRefManager> pExternalRefMgr; + + // mutable for lazy construction + mutable ::std::auto_ptr< ScFormulaParserPool > + mxFormulaParserPool; /// Pool for all external formula parsers used by this document. + String aDocName; // opt: Dokumentname ScRangePairListRef xColNameRanges; ScRangePairListRef xRowNameRanges; @@ -619,6 +625,10 @@ public: void MarkUsedExternalReferences(); bool MarkUsedExternalReferences( ScTokenArray & rArr ); + /** Returns the pool containing external formula parsers. Creates the pool + on first call. */ + ScFormulaParserPool& GetFormulaParserPool() const; + BOOL HasDdeLinks() const; BOOL HasAreaLinks() const; void UpdateExternalRefLinks(); diff --git a/sc/inc/fmtuno.hxx b/sc/inc/fmtuno.hxx index ba4e02041faa..6005a849fb0f 100644 --- a/sc/inc/fmtuno.hxx +++ b/sc/inc/fmtuno.hxx @@ -32,7 +32,8 @@ #define SC_FMTUNO_HXX #include "address.hxx" -#include "formula/grammar.hxx" +#include "conditio.hxx" +#include <formula/grammar.hxx> #include <tools/list.hxx> #include <svtools/itemprop.hxx> #include <com/sun/star/sheet/XSheetConditionalEntries.hpp> @@ -61,16 +62,19 @@ struct ScCondFormatEntryItem { ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > maTokens1; ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > maTokens2; - String maExpr1; - String maExpr2; - String maPosStr; // formula position as text - String maStyle; // display name as stored in ScStyleSheet - ScAddress maPos; - formula::FormulaGrammar::Grammar meGrammar; // grammar used with maExpr1 and maExpr2 - USHORT mnMode; // stores enum ScConditionMode + String maExpr1; + String maExpr2; + String maExprNmsp1; + String maExprNmsp2; + String maPosStr; // formula position as text + String maStyle; // display name as stored in ScStyleSheet + ScAddress maPos; + formula::FormulaGrammar::Grammar meGrammar1; // grammar used with maExpr1 + formula::FormulaGrammar::Grammar meGrammar2; // grammar used with maExpr2 + ScConditionMode meMode; // Make sure the grammar is initialized for API calls. - ScCondFormatEntryItem() : meGrammar( formula::FormulaGrammar::GRAM_UNSPECIFIED ) {} + ScCondFormatEntryItem(); }; class ScTableConditionalFormat : public cppu::WeakImplHelper5< @@ -89,11 +93,11 @@ private: ScTableConditionalFormat(); // disable public: ScTableConditionalFormat(ScDocument* pDoc, ULONG nKey, - const formula::FormulaGrammar::Grammar eGrammar); + formula::FormulaGrammar::Grammar eGrammar); virtual ~ScTableConditionalFormat(); - void FillFormat( ScConditionalFormat& rFormat, - ScDocument* pDoc, formula::FormulaGrammar::Grammar eGrammar ) const; + void FillFormat( ScConditionalFormat& rFormat, ScDocument* pDoc, + formula::FormulaGrammar::Grammar eGrammar) const; void DataChanged(); // XSheetConditionalEntries @@ -211,7 +215,10 @@ private: USHORT nMode; // enum ScConditionMode String aExpr1; String aExpr2; - formula::FormulaGrammar::Grammar meGrammar; // grammar used with aExpr1 and aExpr2 + String maExprNmsp1; + String maExprNmsp2; + formula::FormulaGrammar::Grammar meGrammar1; // grammar used with aExpr1 and aExpr2 + formula::FormulaGrammar::Grammar meGrammar2; // grammar used with aExpr1 and aExpr2 ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > aTokens1; ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > aTokens2; ScAddress aSrcPos; diff --git a/sc/inc/formulaparserpool.hxx b/sc/inc/formulaparserpool.hxx new file mode 100644 index 000000000000..af6b0ed3ebf1 --- /dev/null +++ b/sc/inc/formulaparserpool.hxx @@ -0,0 +1,70 @@ +/************************************************************************* + * + * 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: formulaparserpool.hxx,v $ + * $Revision: 1.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. + * + ************************************************************************/ + +#ifndef SC_FORMULAPARSERPOOL_HXX +#define SC_FORMULAPARSERPOOL_HXX + +#include <hash_map> +#include <com/sun/star/sheet/XFormulaParser.hpp> + +class ScDocument; + +// ============================================================================ + +/** Stores the used instances of the FilterFormulaParser service + implementations, mapped by the formula namespace they support. */ +class ScFormulaParserPool +{ +public: + explicit ScFormulaParserPool( const ScDocument& rDoc ); + ~ScFormulaParserPool(); + + /** Returns true, if a formula parser is registered for the passed namespace. */ + bool hasFormulaParser( const ::rtl::OUString& rNamespace ); + + /** Returns the formula parser that is registered for the passed namespace. */ + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser > + getFormulaParser( const ::rtl::OUString& rNamespace ); + +private: + typedef ::std::hash_map< + ::rtl::OUString, + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser >, + ::rtl::OUStringHash, + ::std::equal_to< ::rtl::OUString > > ParserMap; + + const ScDocument& mrDoc; + ParserMap maParsers; +}; + +// ============================================================================ + +#endif + diff --git a/sc/inc/tokenuno.hxx b/sc/inc/tokenuno.hxx index abb9d1d06a22..bcd3435668be 100644 --- a/sc/inc/tokenuno.hxx +++ b/sc/inc/tokenuno.hxx @@ -31,15 +31,14 @@ #ifndef SC_TOKENUNO_HXX #define SC_TOKENUNO_HXX -#include <svtools/lstner.hxx> -#include <com/sun/star/sheet/FormulaToken.hpp> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/sheet/XFormulaParser.hpp> -#include <com/sun/star/sheet/XFormulaOpCodeMapper.hpp> #include <com/sun/star/sheet/FormulaOpCodeMapEntry.hpp> +#include <com/sun/star/sheet/FormulaToken.hpp> +#include <com/sun/star/sheet/XFormulaParser.hpp> #include <cppuhelper/implbase3.hxx> +#include <svtools/lstner.hxx> #include <formula/FormulaOpCodeMapperObj.hxx> #include "address.hxx" #include "compiler.hxx" @@ -47,6 +46,7 @@ class ScTokenArray; class ScDocShell; +// ============================================================================ class ScTokenConversion { @@ -61,6 +61,7 @@ public: const ScTokenArray& rTokenArray ); }; +// ============================================================================ class ScFormulaParserObj : public ::cppu::WeakImplHelper3< ::com::sun::star::sheet::XFormulaParser, @@ -73,7 +74,6 @@ private: ::com::sun::star::uno::Sequence< const ::com::sun::star::sheet::ExternalLinkInfo > maExternalLinks; ScCompiler::OpCodeMapPtr mxOpCodeMap; ScDocShell* mpDocShell; - ScAddress maRefPos; sal_Int16 mnConv; bool mbEnglish; bool mbIgnoreSpaces; @@ -89,10 +89,12 @@ public: // XFormulaParser virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > SAL_CALL parseFormula( - const ::rtl::OUString& aFormula ) + const ::rtl::OUString& aFormula, + const ::com::sun::star::table::CellAddress& rReferencePos ) throw (::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL printFormula( const ::com::sun::star::uno::Sequence< - ::com::sun::star::sheet::FormulaToken >& aTokens ) + ::com::sun::star::sheet::FormulaToken >& aTokens, + const ::com::sun::star::table::CellAddress& rReferencePos ) throw (::com::sun::star::uno::RuntimeException); // XPropertySet @@ -145,11 +147,15 @@ public: throw(::com::sun::star::uno::RuntimeException); }; +// ============================================================================ + class ScFormulaOpCodeMapperObj : public formula::FormulaOpCodeMapperObj { public: ScFormulaOpCodeMapperObj(::std::auto_ptr<formula::FormulaCompiler> _pCompiler); }; +// ============================================================================ + #endif diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 367e7d7cfe35..010e420feb42 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -318,7 +318,10 @@ #define SC_UNONAME_FORMULA2 "Formula2" #define SC_UNONAME_SOURCEPOS "SourcePosition" #define SC_UNONAME_SOURCESTR "SourcePositionAsString" // only for use in XML filter -#define SC_UNONAME_GRAMMAR "Grammar" // only for use in XML filter +#define SC_UNONAME_FORMULANMSP1 "FormulaNamespace1" // only for use in XML filter +#define SC_UNONAME_FORMULANMSP2 "FormulaNamespace2" // only for use in XML filter +#define SC_UNONAME_GRAMMAR1 "Grammar1" // only for use in XML filter +#define SC_UNONAME_GRAMMAR2 "Grammar2" // only for use in XML filter #define SC_UNONAME_STYLENAME "StyleName" // validation @@ -599,7 +602,6 @@ // <-- // FormulaParser -#define SC_UNO_REFERENCEPOS "ReferencePosition" #define SC_UNO_COMPILEENGLISH "CompileEnglish" #define SC_UNO_FORMULACONVENTION "FormulaConvention" #define SC_UNO_IGNORELEADING "IgnoreLeadingSpaces" diff --git a/sc/inc/validat.hxx b/sc/inc/validat.hxx index d3588c366a7c..cea9c154f04a 100644 --- a/sc/inc/validat.hxx +++ b/sc/inc/validat.hxx @@ -93,7 +93,9 @@ public: ScValidationData( ScValidationMode eMode, ScConditionMode eOper, const String& rExpr1, const String& rExpr2, ScDocument* pDocument, const ScAddress& rPos, - const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ); + const String& rExprNmsp1 = EMPTY_STRING, const String& rExprNmsp2 = EMPTY_STRING, + formula::FormulaGrammar::Grammar eGrammar1 = formula::FormulaGrammar::GRAM_DEFAULT, + formula::FormulaGrammar::Grammar eGrammar2 = formula::FormulaGrammar::GRAM_DEFAULT ); ScValidationData( ScValidationMode eMode, ScConditionMode eOper, const ScTokenArray* pArr1, const ScTokenArray* pArr2, ScDocument* pDocument, const ScAddress& rPos ); |