Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_sc / conditio.hxx
blob47c4dcdf5d95aa3997ded79c6a9da7184c18f990
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: conditio.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_CONDITIO_HXX
32 #define SC_CONDITIO_HXX
34 #ifndef SC_SCGLOB_HXX
35 #include "global.hxx"
36 #endif
38 #ifndef _SVARRAY_HXX //autogen
39 #include <bf_svtools/svarray.hxx>
40 #endif
41 namespace binfilter {
43 class ScBaseCell;
44 class ScFormulaCell;
45 class ScTokenArray;
46 class ScMultipleReadHeader;
47 class ScMultipleWriteHeader;
48 class ScRangeList;
51 #define SC_COND_GROW 16
53 // nOptions Flags
54 #define SC_COND_NOBLANKS 1
57 // Reihenfolge von ScConditionMode wie ScQueryOp,
58 // damit einmal zusammengefasst werden kann:
60 enum ScConditionMode
62 SC_COND_EQUAL,
63 SC_COND_LESS,
64 SC_COND_GREATER,
65 SC_COND_EQLESS,
66 SC_COND_EQGREATER,
67 SC_COND_NOTEQUAL,
68 SC_COND_BETWEEN,
69 SC_COND_NOTBETWEEN,
70 SC_COND_DIRECT,
71 SC_COND_NONE
74 enum ScConditionValType
76 SC_VAL_VALUE,
77 SC_VAL_STRING,
78 SC_VAL_FORMULA
81 class ScConditionEntry
83 // gespeicherte Daten:
84 ScConditionMode eOp;
85 USHORT nOptions;
86 double nVal1; // eingegeben oder berechnet
87 double nVal2;
88 String aStrVal1; // eingegeben oder berechnet
89 String aStrVal2;
90 BOOL bIsStr1; // um auch leere Strings zu erkennen
91 BOOL bIsStr2;
92 ScTokenArray* pFormula1; // eingegebene Formel
93 ScTokenArray* pFormula2;
94 ScAddress aSrcPos; // Quell-Adresse fuer Formeln
95 // temporaere Daten:
96 ScFormulaCell* pFCell1;
97 ScFormulaCell* pFCell2;
98 ScDocument* pDoc;
99 BOOL bRelRef1;
100 BOOL bRelRef2;
101 BOOL bFirstRun;
103 void MakeCells( const ScAddress& rPos );
104 void Compile( const String& rExpr1, const String& rExpr2, BOOL bEnglish,
105 BOOL bCompileXML, BOOL bTextToReal );
106 void Interpret( const ScAddress& rPos );
108 BOOL IsValid( double nArg ) const;
110 protected:
111 ScConditionEntry( SvStream& rStream, ScMultipleReadHeader& rHdr,
112 ScDocument* pDocument );
113 void StoreCondition(SvStream& rStream, ScMultipleWriteHeader& rHdr) const;
115 public:
116 ScConditionEntry( ScConditionMode eOper,
117 const String& rExpr1, const String& rExpr2,
118 ScDocument* pDocument, const ScAddress& rPos,
119 BOOL bCompileEnglish, BOOL bCompileXML );
120 ScConditionEntry( const ScConditionEntry& r ); // flache Kopie der Formeln
121 // echte Kopie der Formeln (fuer Ref-Undo):
122 ScConditionEntry( ScDocument* pDocument, const ScConditionEntry& r );
123 ~ScConditionEntry();
125 int operator== ( const ScConditionEntry& r ) const;
127 BOOL IsCellValid( ScBaseCell* pCell, const ScAddress& rPos ) const;
129 ScConditionMode GetOperation() const { return eOp; }
130 BOOL IsIgnoreBlank() const { return ( nOptions & SC_COND_NOBLANKS ) == 0; }
131 void SetIgnoreBlank(BOOL bSet);
132 ScAddress GetSrcPos() const { return aSrcPos; }
134 String GetExpression( const ScAddress& rCursor, USHORT nPos, ULONG nNumFmt = 0,
135 BOOL bEnglish = FALSE, BOOL bCompileXML = FALSE,
136 BOOL bTextToReal = FALSE ) const;
139 void CompileXML();
140 void UpdateReference( UpdateRefMode eUpdateRefMode,
141 const ScRange& rRange, short nDx, short nDy, short nDz );
143 void SourceChanged( const ScAddress& rChanged );
145 protected:
146 virtual void DataChanged( const ScRange* pModified ) const;
147 ScDocument* GetDocument() const { return pDoc; }
151 // einzelner Eintrag fuer bedingte Formatierung
154 class ScConditionalFormat;
156 class ScCondFormatEntry : public ScConditionEntry
158 String aStyleName;
159 ScConditionalFormat* pParent;
161 public:
162 ScCondFormatEntry( ScConditionMode eOper,
163 const String& rExpr1, const String& rExpr2,
164 ScDocument* pDocument, const ScAddress& rPos,
165 const String& rStyle,
166 BOOL bCompileEnglish = FALSE, BOOL bCompileXML = FALSE );
167 ScCondFormatEntry( const ScCondFormatEntry& r );
168 ScCondFormatEntry( ScDocument* pDocument, const ScCondFormatEntry& r );
169 ScCondFormatEntry( SvStream& rStream, ScMultipleReadHeader& rHdr,
170 ScDocument* pDocument );
171 ~ScCondFormatEntry();
173 void SetParent( ScConditionalFormat* pNew ) { pParent = pNew; }
175 void Store(SvStream& rStream, ScMultipleWriteHeader& rHdr) const;
177 int operator== ( const ScCondFormatEntry& r ) const;
179 const String& GetStyle() const { return aStyleName; }
181 protected:
182 virtual void DataChanged( const ScRange* pModified ) const;
186 // komplette bedingte Formatierung
189 class ScConditionalFormat
191 ScDocument* pDoc;
192 ScRangeList* pAreas; // Bereiche fuer Paint
193 sal_uInt32 nKey; // Index in Attributen
194 ScCondFormatEntry** ppEntries;
195 USHORT nEntryCount;
196 BOOL bIsUsed; // temporaer beim Speichern
198 public:
199 ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocument);
200 ScConditionalFormat(const ScConditionalFormat& r);
201 ScConditionalFormat(SvStream& rStream, ScMultipleReadHeader& rHdr,
202 ScDocument* pDocument);
203 ~ScConditionalFormat();
205 // echte Kopie der Formeln (fuer Ref-Undo / zwischen Dokumenten)
206 ScConditionalFormat* Clone(ScDocument* pNewDoc = NULL) const;
208 void Store(SvStream& rStream, ScMultipleWriteHeader& rHdr) const;
210 void AddEntry( const ScCondFormatEntry& rNew );
212 BOOL IsEmpty() const { return (nEntryCount == 0); }
213 USHORT Count() const { return nEntryCount; }
215 void CompileXML();
216 void UpdateReference( UpdateRefMode eUpdateRefMode,
217 const ScRange& rRange, short nDx, short nDy, short nDz );
219 void SourceChanged( const ScAddress& rAddr );
221 const ScCondFormatEntry* GetEntry( USHORT nPos ) const;
223 const String& GetCellStyle( ScBaseCell* pCell, const ScAddress& rPos ) const;
225 BOOL EqualEntries( const ScConditionalFormat& r ) const;
227 void DoRepaint( const ScRange* pModified );
228 void InvalidateArea();
230 sal_uInt32 GetKey() const { return nKey; }
231 void SetKey(sal_uInt32 nNew) { nKey = nNew; } // nur wenn nicht eingefuegt!
233 void SetUsed(BOOL bSet) { bIsUsed = bSet; }
234 BOOL IsUsed() const { return bIsUsed; }
236 // sortiert (per PTRARR) nach Index
237 // operator== nur fuer die Sortierung
238 BOOL operator ==( const ScConditionalFormat& r ) const { return nKey == r.nKey; }
239 BOOL operator < ( const ScConditionalFormat& r ) const { return nKey < r.nKey; }
243 // Liste der Bereiche und Formate:
246 typedef ScConditionalFormat* ScConditionalFormatPtr;
248 SV_DECL_PTRARR_SORT(ScConditionalFormats_Impl, ScConditionalFormatPtr,
249 SC_COND_GROW, SC_COND_GROW)//STRIP008 ;
251 class ScConditionalFormatList : public ScConditionalFormats_Impl
253 public:
254 ScConditionalFormatList() {}
255 ScConditionalFormatList(const ScConditionalFormatList& rList);
256 ~ScConditionalFormatList() {}
258 void InsertNew( ScConditionalFormat* pNew )
259 { if (!Insert(pNew)) delete pNew; }
261 ScConditionalFormat* GetFormat( sal_uInt32 nKey );
263 void Load( SvStream& rStream, ScDocument* pDocument );
264 void Store( SvStream& rStream ) const;
265 void ResetUsed();
267 void CompileXML();
268 void UpdateReference( UpdateRefMode eUpdateRefMode,
269 const ScRange& rRange, short nDx, short nDy, short nDz );
271 void SourceChanged( const ScAddress& rAddr );
275 } //namespace binfilter
276 #endif