update dev300-m58
[ooovba.git] / sw / inc / expfld.hxx
blobe878b44602f35c3249306a19de5060cc4f792371
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: expfld.hxx,v $
10 * $Revision: 1.12 $
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 ************************************************************************/
30 #ifndef _EXPFLD_HXX
31 #define _EXPFLD_HXX
33 #include <svtools/svarray.hxx>
34 #include "swdllapi.h"
35 #include <fldbas.hxx>
36 #include <cellfml.hxx>
38 class SfxPoolItem;
39 class SwTxtNode;
40 class SwFrm;
41 struct SwPosition;
42 class SwTxtFld;
43 class SwDoc;
44 class SwFmtFld;
45 class _SetGetExpFlds;
46 class SwEditShell;
48 // Vorwaertsdeklaration: besorge den "Body-TextNode", fuer Exp.Fld in Fly's
49 // Header/Footers/Footnodes
50 const SwTxtNode* GetBodyTxtNode( const SwDoc& pDoc, SwPosition& rPos,
51 const SwFrm& rFrm );
52 // Wandlung Address -> Adressen
53 void ReplacePoint(String& sTmpName, BOOL bWithCommandType = FALSE);
55 struct _SeqFldLstElem
57 String sDlgEntry;
58 USHORT nSeqNo;
60 _SeqFldLstElem( const String& rStr, USHORT nNo )
61 : sDlgEntry( rStr ), nSeqNo( nNo )
64 SV_DECL_PTRARR_DEL( _SwSeqFldList, _SeqFldLstElem*, 10, 10 )
66 class SW_DLLPUBLIC SwSeqFldList : public _SwSeqFldList
68 public:
69 SwSeqFldList() : _SwSeqFldList( 10, 10 ) {}
71 BOOL InsertSort( _SeqFldLstElem* );
72 BOOL SeekEntry( const _SeqFldLstElem& , USHORT* pPos = 0 );
75 /*--------------------------------------------------------------------
76 Beschreibung: Ausdruck
77 --------------------------------------------------------------------*/
79 class SwGetExpFieldType : public SwValueFieldType
81 public:
82 SwGetExpFieldType(SwDoc* pDoc);
83 virtual SwFieldType* Copy() const;
85 // ueberlagert, weil das Get-Field nicht veraendert werden kann
86 // und dann auch nicht aktualisiert werden muss. Aktualisierung
87 // erfolgt beim Aendern von Set-Werten !
89 virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew );
92 /*--------------------------------------------------------------------
93 Beschreibung: GetExperession
94 --------------------------------------------------------------------*/
96 class SW_DLLPUBLIC SwGetExpField : public SwFormulaField
98 String sExpand;
99 BOOL bIsInBodyTxt;
100 USHORT nSubType;
102 bool bLateInitialization; // #i82544#
104 public:
105 SwGetExpField( SwGetExpFieldType*, const String& rFormel,
106 USHORT nSubType = nsSwGetSetExpType::GSE_EXPR, ULONG nFmt = 0);
108 virtual void SetValue( const double& rVal );
109 virtual void SetLanguage(USHORT nLng);
111 virtual String Expand() const;
112 virtual SwField* Copy() const;
114 inline const String& GetExpStr() const;
115 inline void ChgExpStr(const String& rExpand);
117 // wird von der Formatierung abgefragt
118 inline BOOL IsInBodyTxt() const;
119 // wird von UpdateExpFlds gesetzt (dort ist die Node-Position bekannt)
120 inline void ChgBodyTxtFlag( BOOL bIsInBody );
121 // fuer Felder in Header/Footer/Footnotes/Flys:
122 // (wird nur von der Formatierung aufgerufen!!)
123 void ChangeExpansion( const SwFrm&, const SwTxtFld& );
125 virtual String GetCntnt(BOOL bName = FALSE) const;
127 // Die Formel aendern
128 virtual String GetPar2() const;
129 virtual void SetPar2(const String& rStr);
131 virtual USHORT GetSubType() const;
132 virtual void SetSubType(USHORT nType);
133 virtual BOOL QueryValue( com::sun::star::uno::Any& rVal, USHORT nWhich ) const;
134 virtual BOOL PutValue( const com::sun::star::uno::Any& rVal, USHORT nWhich );
136 static USHORT GetReferenceTextPos( const SwFmtFld& rFmt, SwDoc& rDoc);
137 // #i82544#
138 void SetLateInitialization() { bLateInitialization = true;}
141 inline void SwGetExpField::ChgExpStr(const String& rExpand)
142 { sExpand = rExpand;}
144 inline const String& SwGetExpField::GetExpStr() const
145 { return sExpand; }
147 // wird von der Formatierung abgefragt
148 inline BOOL SwGetExpField::IsInBodyTxt() const
149 { return bIsInBodyTxt; }
151 // wird von UpdateExpFlds gesetzt (dort ist die Node-Position bekannt)
152 inline void SwGetExpField::ChgBodyTxtFlag( BOOL bIsInBody )
153 { bIsInBodyTxt = bIsInBody; }
156 /*--------------------------------------------------------------------
157 Beschreibung: Ausdruck setzen
158 --------------------------------------------------------------------*/
160 class SwSetExpField;
162 class SW_DLLPUBLIC SwSetExpFieldType : public SwValueFieldType
164 String sName;
165 const SwNode* pOutlChgNd;
166 // sal_Unicode cDelim;
167 String sDelim;
168 USHORT nType;
169 BYTE nLevel;
170 BOOL bDeleted;
172 public:
173 SwSetExpFieldType( SwDoc* pDoc, const String& rName,
174 USHORT nType = nsSwGetSetExpType::GSE_EXPR );
175 virtual SwFieldType* Copy() const;
176 virtual const String& GetName() const;
178 inline void SetType(USHORT nTyp);
179 inline USHORT GetType() const;
181 void SetSeqFormat(ULONG nFormat);
182 ULONG GetSeqFormat();
184 BOOL IsDeleted() const { return bDeleted; }
185 void SetDeleted( BOOL b ) { bDeleted = b; }
187 // ueberlagert, weil das Set-Field selbst dafuer sorgt, das
188 // es aktualisiert wird.
189 virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew );
190 inline const String& GetSetRefName() const;
192 USHORT SetSeqRefNo( SwSetExpField& rFld );
194 USHORT GetSeqFldList( SwSeqFldList& rList );
195 String MakeSeqName( USHORT nSeqNo );
197 // Seqencefelder ggfs. Kapitelweise numerieren
198 // sal_Unicode GetDelimiter() const { return cDelim; }
199 // void SetDelimiter( sal_Unicode c ) { cDelim = c; }
200 const String& GetDelimiter() const { return sDelim; }
201 void SetDelimiter( const String& s ) { sDelim = s; }
202 BYTE GetOutlineLvl() const { return nLevel; }
203 void SetOutlineLvl( BYTE n ) { nLevel = n; }
204 void SetChapter( SwSetExpField& rFld, const SwNode& rNd );
205 // Member nur fuers SwDoc::UpdateExpFld - wird nur waehrend der Laufzeit
206 // von SequencefeldTypen benoetigt!!!
207 const SwNode* GetOutlineChgNd() const { return pOutlChgNd; }
208 void SetOutlineChgNd( const SwNode* p ) { pOutlChgNd = p; }
210 virtual BOOL QueryValue( com::sun::star::uno::Any& rVal, USHORT nWhich ) const;
211 virtual BOOL PutValue( const com::sun::star::uno::Any& rVal, USHORT nWhich );
214 inline void SwSetExpFieldType::SetType( USHORT nTyp )
216 nType = nTyp;
217 EnableFormat( !(nType & (nsSwGetSetExpType::GSE_SEQ|nsSwGetSetExpType::GSE_STRING)));
220 inline USHORT SwSetExpFieldType::GetType() const
221 { return nType; }
223 inline const String& SwSetExpFieldType::GetSetRefName() const
224 { return sName; }
227 /*--------------------------------------------------------------------
228 Beschreibung: Ausdruck
229 --------------------------------------------------------------------*/
231 class SW_DLLPUBLIC SwSetExpField : public SwFormulaField
233 String sExpand;
234 String aPText;
235 String aSeqText;
236 BOOL bInput;
237 USHORT nSeqNo;
238 USHORT nSubType;
240 public:
241 SwSetExpField(SwSetExpFieldType*, const String& rFormel, ULONG nFmt = 0);
243 virtual void SetValue( const double& rVal );
245 virtual String Expand() const;
246 virtual SwField* Copy() const;
248 inline const String& GetExpStr() const;
250 inline void ChgExpStr( const String& rExpand );
252 inline void SetPromptText(const String& rStr);
253 inline const String& GetPromptText() const;
255 inline void SetInputFlag(BOOL bInp);
256 inline BOOL GetInputFlag() const;
258 virtual String GetCntnt(BOOL bName = FALSE) const;
259 virtual USHORT GetSubType() const;
260 virtual void SetSubType(USHORT nType);
262 inline BOOL IsSequenceFld() const;
264 // fuer SequenceFelder - logische Nummer
265 inline void SetSeqNumber( USHORT n ) { nSeqNo = n; }
266 inline USHORT GetSeqNumber() const { return nSeqNo; }
268 // Der Name nur erfragen
269 virtual const String& GetPar1() const;
271 // Die Formel
272 virtual String GetPar2() const;
273 virtual void SetPar2(const String& rStr);
274 virtual BOOL QueryValue( com::sun::star::uno::Any& rVal, USHORT nWhich ) const;
275 virtual BOOL PutValue( const com::sun::star::uno::Any& rVal, USHORT nWhich );
278 inline const String& SwSetExpField::GetExpStr() const
279 { return sExpand; }
281 inline void SwSetExpField::ChgExpStr( const String& rExpand )
282 { sExpand = rExpand; }
284 inline void SwSetExpField::SetPromptText(const String& rStr)
285 { aPText = rStr; }
287 inline const String& SwSetExpField::GetPromptText() const
288 { return aPText; }
290 inline void SwSetExpField::SetInputFlag(BOOL bInp)
291 { bInput = bInp; }
293 inline BOOL SwSetExpField::GetInputFlag() const
294 { return bInput; }
296 inline BOOL SwSetExpField::IsSequenceFld() const
297 { return 0 != (nsSwGetSetExpType::GSE_SEQ & ((SwSetExpFieldType*)GetTyp())->GetType()); }
299 /*--------------------------------------------------------------------
300 Beschreibung: Eingabe im Text/Variable setzen
301 --------------------------------------------------------------------*/
303 class SwInputFieldType : public SwFieldType
305 SwDoc* pDoc;
306 public:
307 SwInputFieldType( SwDoc* pDoc );
309 virtual SwFieldType* Copy() const;
311 SwDoc* GetDoc() const { return pDoc; }
314 /*--------------------------------------------------------------------
315 Beschreibung: Eingabefeld
316 --------------------------------------------------------------------*/
318 class SW_DLLPUBLIC SwInputField : public SwField
320 String aContent;
321 String aPText;
322 String aHelp;
323 String aToolTip;
324 USHORT nSubType;
325 public:
326 // Direkte Eingabe ueber Dialog alten Wert loeschen
327 SwInputField(SwInputFieldType*, const String& rContent ,
328 const String& rPrompt, USHORT nSubType = 0,
329 ULONG nFmt = 0);
331 virtual String GetCntnt(BOOL bName = FALSE) const;
332 virtual String Expand() const;
333 virtual SwField* Copy() const;
335 // Content
336 virtual const String& GetPar1() const;
337 virtual void SetPar1(const String& rStr);
339 // aPromptText
340 virtual String GetPar2() const;
341 virtual void SetPar2(const String& rStr);
343 virtual String GetHelp() const;
344 virtual void SetHelp(const String & rStr);
346 virtual String GetToolTip() const;
347 virtual void SetToolTip(const String & rStr);
349 virtual BOOL isFormField() const;
351 virtual USHORT GetSubType() const;
352 virtual void SetSubType(USHORT nSub);
353 virtual BOOL QueryValue( com::sun::star::uno::Any& rVal, USHORT nWhich ) const;
354 virtual BOOL PutValue( const com::sun::star::uno::Any& rVal, USHORT nWhich );
357 /*--------------------------------------------------------------------
358 Description: Sorted list of input fields and DropDown fields
359 --------------------------------------------------------------------*/
361 class SwInputFieldList
363 public:
364 SwInputFieldList( SwEditShell* pShell, BOOL bBuildTmpLst = FALSE );
365 ~SwInputFieldList();
367 USHORT Count() const;
368 SwField* GetField(USHORT nId);
370 void GotoFieldPos(USHORT nId);
371 void PushCrsr();
372 void PopCrsr();
374 // vergleiche TmpLst mit akt Feldern. Alle neue kommen in die SortLst
375 // damit sie geupdatet werden koennen. Returnt die Anzahl.
376 // (Fuer Textbausteine: nur seine Input-Felder aktualisieren)
377 USHORT BuildSortLst();
379 // Alle unselektierten Felder aus Liste entfernen
380 void RemoveUnselectedFlds();
382 private:
383 SwEditShell* pSh;
384 _SetGetExpFlds* pSrtLst;
385 SvPtrarr aTmpLst;
388 /*--------------------------------------------------------------------
389 Beschreibung: Tabellen-Formelfeld
390 (Implementierung steht in tblcalc.cxx)
391 --------------------------------------------------------------------*/
393 class SwTblFieldType : public SwValueFieldType
395 public:
396 SwTblFieldType(SwDoc* pDocPtr);
397 virtual SwFieldType* Copy() const;
401 // MSC will den hier nicht
402 //typedef void (SwField:: *FnScanFormel)( const SwTable&, String&,
403 // String&, String* = 0, void* = 0 );
406 class SwTblField : public SwValueField, public SwTableFormula
408 String sExpand;
409 USHORT nSubType;
411 // suche den TextNode, in dem das Feld steht
412 virtual const SwNode* GetNodeOfFormula() const;
414 public:
415 SwTblField( SwTblFieldType*, const String& rFormel,
416 USHORT nSubType = 0, ULONG nFmt = 0);
418 virtual void SetValue( const double& rVal );
419 virtual USHORT GetSubType() const;
420 virtual void SetSubType(USHORT nType);
421 virtual String Expand() const;
422 virtual SwField* Copy() const;
424 const String& GetExpStr() const { return sExpand; }
425 void ChgExpStr(const String& rStr) { sExpand = rStr; }
427 // berechne sich selbst
428 void CalcField( SwTblCalcPara& rCalcPara );
430 virtual String GetCntnt(BOOL bName = FALSE) const;
431 // Die Formel
432 virtual String GetPar2() const;
433 virtual void SetPar2(const String& rStr);
434 virtual BOOL QueryValue( com::sun::star::uno::Any& rVal, USHORT nWhich ) const;
435 virtual BOOL PutValue( const com::sun::star::uno::Any& rVal, USHORT nWhich );
439 #endif // _EXPFLD_HXX