1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: conditio.hxx,v $
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
38 #ifndef _SVARRAY_HXX //autogen
39 #include <bf_svtools/svarray.hxx>
46 class ScMultipleReadHeader
;
47 class ScMultipleWriteHeader
;
51 #define SC_COND_GROW 16
54 #define SC_COND_NOBLANKS 1
57 // Reihenfolge von ScConditionMode wie ScQueryOp,
58 // damit einmal zusammengefasst werden kann:
74 enum ScConditionValType
81 class ScConditionEntry
83 // gespeicherte Daten:
86 double nVal1
; // eingegeben oder berechnet
88 String aStrVal1
; // eingegeben oder berechnet
90 BOOL bIsStr1
; // um auch leere Strings zu erkennen
92 ScTokenArray
* pFormula1
; // eingegebene Formel
93 ScTokenArray
* pFormula2
;
94 ScAddress aSrcPos
; // Quell-Adresse fuer Formeln
96 ScFormulaCell
* pFCell1
;
97 ScFormulaCell
* pFCell2
;
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;
111 ScConditionEntry( SvStream
& rStream
, ScMultipleReadHeader
& rHdr
,
112 ScDocument
* pDocument
);
113 void StoreCondition(SvStream
& rStream
, ScMultipleWriteHeader
& rHdr
) const;
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
);
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;
140 void UpdateReference( UpdateRefMode eUpdateRefMode
,
141 const ScRange
& rRange
, short nDx
, short nDy
, short nDz
);
143 void SourceChanged( const ScAddress
& rChanged
);
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
159 ScConditionalFormat
* pParent
;
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
; }
182 virtual void DataChanged( const ScRange
* pModified
) const;
186 // komplette bedingte Formatierung
189 class ScConditionalFormat
192 ScRangeList
* pAreas
; // Bereiche fuer Paint
193 sal_uInt32 nKey
; // Index in Attributen
194 ScCondFormatEntry
** ppEntries
;
196 BOOL bIsUsed
; // temporaer beim Speichern
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
; }
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
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;
268 void UpdateReference( UpdateRefMode eUpdateRefMode
,
269 const ScRange
& rRange
, short nDx
, short nDy
, short nDz
);
271 void SourceChanged( const ScAddress
& rAddr
);
275 } //namespace binfilter