1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SC_TOKENARRAY_HXX 29 #define SC_TOKENARRAY_HXX 30 31 #include "formula/token.hxx" 32 #include <tools/solar.h> 33 #include "scdllapi.h" 34 #include <formula/tokenarray.hxx> 35 36 struct ScRawToken; 37 struct ScSingleRefData; 38 struct ScComplexRefData; 39 class ScMatrix; 40 41 class SC_DLLPUBLIC ScTokenArray : public formula::FormulaTokenArray 42 { 43 friend class ScCompiler; 44 sal_Bool ImplGetReference( ScRange& rRange, sal_Bool bValidOnly ) const; 45 46 public: 47 ScTokenArray(); 48 /// Assignment with references to ScToken entries (not copied!) 49 ScTokenArray( const ScTokenArray& ); 50 virtual ~ScTokenArray(); 51 ScTokenArray* Clone() const; /// True copy! 52 53 /// Exactly and only one range (valid or deleted) 54 sal_Bool IsReference( ScRange& rRange ) const; 55 /// Exactly and only one valid range (no #REF!s) 56 sal_Bool IsValidReference( ScRange& rRange ) const; 57 58 59 /** Determines the extent of direct adjacent 60 references. Only use with real functions, e.g. 61 GetOuterFuncOpCode() == ocSum ! */ 62 sal_Bool GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend, 63 const ScAddress& rPos, ScDirection ); 64 65 formula::FormulaToken* AddRawToken( const ScRawToken& ); 66 virtual bool AddFormulaToken(const com::sun::star::sheet::FormulaToken& _aToken,formula::ExternalReferenceHelper* _pRef); 67 virtual formula::FormulaToken* AddOpCode( OpCode eCode ); 68 /** ScSingleRefToken with ocPush. */ 69 formula::FormulaToken* AddSingleReference( const ScSingleRefData& rRef ); 70 /** ScSingleRefOpToken with ocMatRef. */ 71 formula::FormulaToken* AddMatrixSingleReference( const ScSingleRefData& rRef ); 72 formula::FormulaToken* AddDoubleReference( const ScComplexRefData& rRef ); 73 formula::FormulaToken* AddExternalName( sal_uInt16 nFileId, const String& rName ); 74 formula::FormulaToken* AddExternalSingleReference( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ); 75 formula::FormulaToken* AddExternalDoubleReference( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef ); 76 formula::FormulaToken* AddMatrix( ScMatrix* p ); 77 /** ScSingleRefOpToken with ocColRowName. */ 78 formula::FormulaToken* AddColRowName( const ScSingleRefData& rRef ); 79 virtual formula::FormulaToken* MergeArray( ); 80 81 /** Merge very last SingleRef+ocRange+SingleRef combination into DoubleRef 82 and adjust pCode array, or do nothing if conditions not met. 83 Unconditionally returns last token from the resulting pCode array, or 84 NULL if there is no pCode (which actually would be caller's fault). */ 85 formula::FormulaToken* MergeRangeReference( const ScAddress & rPos ); 86 87 /// Assignment with references to ScToken entries (not copied!) 88 ScTokenArray& operator=( const ScTokenArray& ); 89 90 /// Make 3D references point to old referenced position even if relative 91 void ReadjustRelative3DReferences( 92 const ScAddress& rOldPos, 93 const ScAddress& rNewPos ); 94 }; 95 96 #endif // SC_TOKENARRAY_HXX 97 98