1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SW_INC_EXPFLD_HXX
20 #define INCLUDED_SW_INC_EXPFLD_HXX
24 #include <cellfml.hxx>
35 class _SetGetExpFields
;
38 /// Forward declaration: get "BodyTextNode" for exp.fld in Fly's headers/footers/footnotes.
39 const SwTextNode
* GetBodyTextNode( const SwDoc
& pDoc
, SwPosition
& rPos
,
42 OUString
ReplacePoint(const OUString
& sTmpName
, bool bWithCommandType
= false);
44 struct _SeqFieldLstElem
49 _SeqFieldLstElem( const OUString
& rStr
, sal_uInt16 nNo
)
50 : sDlgEntry( rStr
), nSeqNo( nNo
)
54 class SW_DLLPUBLIC SwSeqFieldList
56 std::vector
<_SeqFieldLstElem
*> maData
;
60 for( std::vector
<_SeqFieldLstElem
*>::const_iterator it
= maData
.begin(); it
!= maData
.end(); ++it
)
64 bool InsertSort(_SeqFieldLstElem
* pNew
);
65 bool SeekEntry(const _SeqFieldLstElem
& rNew
, size_t* pPos
) const;
67 size_t Count() { return maData
.size(); }
68 _SeqFieldLstElem
* operator[](size_t nIndex
) { return maData
[nIndex
]; }
69 const _SeqFieldLstElem
* operator[](size_t nIndex
) const { return maData
[nIndex
]; }
70 void Clear() { maData
.clear(); }
73 class SwGetExpFieldType
: public SwValueFieldType
76 SwGetExpFieldType(SwDoc
* pDoc
);
77 virtual SwFieldType
* Copy() const SAL_OVERRIDE
;
79 /** Overlay, because get-field cannot be changed and therefore
80 does not need to be updated. Update at changing of set-values! */
82 virtual void Modify( const SfxPoolItem
* pOld
, const SfxPoolItem
*pNew
) SAL_OVERRIDE
;
85 class SW_DLLPUBLIC SwGetExpField
: public SwFormulaField
91 bool bLateInitialization
; // #i82544#
93 virtual OUString
Expand() const SAL_OVERRIDE
;
94 virtual SwField
* Copy() const SAL_OVERRIDE
;
97 SwGetExpField( SwGetExpFieldType
*, const OUString
& rFormel
,
98 sal_uInt16 nSubType
= nsSwGetSetExpType::GSE_EXPR
, sal_uLong nFormat
= 0);
100 virtual void SetValue( const double& rVal
) SAL_OVERRIDE
;
101 virtual void SetLanguage(sal_uInt16 nLng
) SAL_OVERRIDE
;
103 inline OUString
GetExpStr() const;
104 inline void ChgExpStr(const OUString
& rExpand
);
106 /// Called by formatting.
107 inline bool IsInBodyText() const;
109 /// Set by UpdateExpFields where node position is known.
110 inline void ChgBodyTextFlag( bool bIsInBody
);
112 /** For fields in header/footer/footnotes/flys:
113 Only called by formatting!! */
114 void ChangeExpansion( const SwFrm
&, const SwTextField
& );
116 virtual OUString
GetFieldName() const SAL_OVERRIDE
;
119 virtual OUString
GetPar2() const SAL_OVERRIDE
;
120 virtual void SetPar2(const OUString
& rStr
) SAL_OVERRIDE
;
122 virtual sal_uInt16
GetSubType() const SAL_OVERRIDE
;
123 virtual void SetSubType(sal_uInt16 nType
) SAL_OVERRIDE
;
124 virtual bool QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt16 nWhich
) const SAL_OVERRIDE
;
125 virtual bool PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt16 nWhich
) SAL_OVERRIDE
;
127 static sal_Int32
GetReferenceTextPos( const SwFormatField
& rFormat
, SwDoc
& rDoc
, sal_Int32 nHint
= 0);
129 void SetLateInitialization() { bLateInitialization
= true;}
132 inline void SwGetExpField::ChgExpStr(const OUString
& rExpand
)
133 { sExpand
= rExpand
;}
135 inline OUString
SwGetExpField::GetExpStr() const
138 /// Called by formatting.
139 inline bool SwGetExpField::IsInBodyText() const
140 { return bIsInBodyText
; }
142 /// Set by UpdateExpFields where node position is known.
143 inline void SwGetExpField::ChgBodyTextFlag( bool bIsInBody
)
144 { bIsInBodyText
= bIsInBody
; }
148 class SW_DLLPUBLIC SwSetExpFieldType
: public SwValueFieldType
151 const SwNode
* pOutlChgNd
;
158 virtual void Modify( const SfxPoolItem
* pOld
, const SfxPoolItem
*pNew
) SAL_OVERRIDE
;
161 SwSetExpFieldType( SwDoc
* pDoc
, const OUString
& rName
,
162 sal_uInt16 nType
= nsSwGetSetExpType::GSE_EXPR
);
163 virtual SwFieldType
* Copy() const SAL_OVERRIDE
;
164 virtual OUString
GetName() const SAL_OVERRIDE
;
166 inline void SetType(sal_uInt16 nTyp
);
167 inline sal_uInt16
GetType() const;
169 void SetSeqFormat(sal_uLong nFormat
);
170 sal_uLong
GetSeqFormat();
172 bool IsDeleted() const { return bDeleted
; }
173 void SetDeleted( bool b
) { bDeleted
= b
; }
175 /// Overlay, because set-field takes care for its being updated by itself.
176 inline OUString
GetSetRefName() const;
178 sal_uInt16
SetSeqRefNo( SwSetExpField
& rField
);
180 size_t GetSeqFieldList( SwSeqFieldList
& rList
);
181 OUString
MakeSeqName( sal_uInt16 nSeqNo
);
183 /// Number sequence fields chapterwise if required.
184 OUString
GetDelimiter() const { return sDelim
; }
185 void SetDelimiter( const OUString
& s
) { sDelim
= s
; }
186 sal_uInt8
GetOutlineLvl() const { return nLevel
; }
187 void SetOutlineLvl( sal_uInt8 n
) { nLevel
= n
; }
188 void SetChapter( SwSetExpField
& rField
, const SwNode
& rNd
);
190 /** Member only for SwDoc::UpdateExpField.
191 It is needed only at runtime of sequence field types! */
192 const SwNode
* GetOutlineChgNd() const { return pOutlChgNd
; }
193 void SetOutlineChgNd( const SwNode
* p
) { pOutlChgNd
= p
; }
195 virtual bool QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt16 nWhich
) const SAL_OVERRIDE
;
196 virtual bool PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt16 nWhich
) SAL_OVERRIDE
;
199 inline void SwSetExpFieldType::SetType( sal_uInt16 nTyp
)
202 EnableFormat( !(nType
& (nsSwGetSetExpType::GSE_SEQ
|nsSwGetSetExpType::GSE_STRING
)));
205 inline sal_uInt16
SwSetExpFieldType::GetType() const
208 inline OUString
SwSetExpFieldType::GetSetRefName() const
211 class SW_DLLPUBLIC SwSetExpField
: public SwFormulaField
218 SwFormatField
* mpFormatField
; /// pool item to which the SwSetExpField belongs
220 virtual OUString
Expand() const SAL_OVERRIDE
;
221 virtual SwField
* Copy() const SAL_OVERRIDE
;
224 SwSetExpField(SwSetExpFieldType
*, const OUString
& rFormel
, sal_uLong nFormat
= 0);
226 void SetFormatField(SwFormatField
& rFormatField
);
227 SwFormatField
* GetFormatField() { return mpFormatField
;}
229 virtual void SetValue( const double& rVal
) SAL_OVERRIDE
;
231 inline OUString
GetExpStr() const;
233 inline void ChgExpStr( const OUString
& rExpand
);
235 inline void SetPromptText(const OUString
& rStr
);
236 inline OUString
GetPromptText() const;
238 inline void SetInputFlag(bool bInp
);
239 inline bool GetInputFlag() const;
241 virtual OUString
GetFieldName() const SAL_OVERRIDE
;
243 virtual sal_uInt16
GetSubType() const SAL_OVERRIDE
;
244 virtual void SetSubType(sal_uInt16 nType
) SAL_OVERRIDE
;
246 inline bool IsSequenceField() const;
248 /// Logical number, sequence fields.
249 inline void SetSeqNumber( sal_uInt16 n
) { nSeqNo
= n
; }
250 inline sal_uInt16
GetSeqNumber() const { return nSeqNo
; }
253 virtual OUString
GetPar1() const SAL_OVERRIDE
;
256 virtual OUString
GetPar2() const SAL_OVERRIDE
;
257 virtual void SetPar2(const OUString
& rStr
) SAL_OVERRIDE
;
258 virtual bool QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt16 nWhich
) const SAL_OVERRIDE
;
259 virtual bool PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt16 nWhich
) SAL_OVERRIDE
;
262 inline OUString
SwSetExpField::GetExpStr() const
265 inline void SwSetExpField::ChgExpStr( const OUString
& rExpand
)
266 { sExpand
= rExpand
; }
268 inline void SwSetExpField::SetPromptText(const OUString
& rStr
)
271 inline OUString
SwSetExpField::GetPromptText() const
274 inline void SwSetExpField::SetInputFlag(bool bInp
)
277 inline bool SwSetExpField::GetInputFlag() const
280 inline bool SwSetExpField::IsSequenceField() const
281 { return 0 != (nsSwGetSetExpType::GSE_SEQ
& static_cast<SwSetExpFieldType
*>(GetTyp())->GetType()); }
283 class SwInputFieldType
: public SwFieldType
287 SwInputFieldType( SwDoc
* pDoc
);
289 virtual SwFieldType
* Copy() const SAL_OVERRIDE
;
291 SwDoc
* GetDoc() const { return pDoc
; }
294 class SW_DLLPUBLIC SwInputField
: public SwField
296 mutable OUString aContent
;
303 SwFormatField
* mpFormatField
; // attribute to which the <SwInputField> belongs to
305 virtual OUString
Expand() const SAL_OVERRIDE
;
306 virtual SwField
* Copy() const SAL_OVERRIDE
;
308 // Accessing Input Field's content
309 const OUString
& getContent() const { return aContent
;}
311 void LockNotifyContentChange();
312 void UnlockNotifyContentChange();
315 /// Direct input via dialog; delete old value.
317 SwInputFieldType
* pFieldType
,
318 const OUString
& rContent
,
319 const OUString
& rPrompt
,
320 sal_uInt16 nSubType
= 0,
321 sal_uLong nFormat
= 0,
322 bool bIsFormField
= true );
323 virtual ~SwInputField();
325 void SetFormatField( SwFormatField
& rFormatField
);
326 SwFormatField
* GetFormatField() { return mpFormatField
;}
328 // Providing new Input Field's content:
329 // Fill Input Field's content depending on <nSupType>.
330 void applyFieldContent( const OUString
& rNewFieldContent
);
332 bool isFormField() const;
334 virtual OUString
GetFieldName() const SAL_OVERRIDE
;
337 virtual OUString
GetPar1() const SAL_OVERRIDE
;
338 virtual void SetPar1(const OUString
& rStr
) SAL_OVERRIDE
;
341 virtual OUString
GetPar2() const SAL_OVERRIDE
;
342 virtual void SetPar2(const OUString
& rStr
) SAL_OVERRIDE
;
344 OUString
GetHelp() const;
345 void SetHelp(const OUString
& rStr
);
347 OUString
GetToolTip() const;
348 void SetToolTip(const OUString
& rStr
);
350 virtual sal_uInt16
GetSubType() const SAL_OVERRIDE
;
351 virtual void SetSubType(sal_uInt16 nSub
) SAL_OVERRIDE
;
352 virtual bool QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt16 nWhich
) const SAL_OVERRIDE
;
353 virtual bool PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt16 nWhich
) SAL_OVERRIDE
;
356 // Sorted list of input fields and DropDown fields
357 class SwInputFieldList
360 SwInputFieldList( SwEditShell
* pShell
, bool bBuildTmpLst
= false );
363 size_t Count() const;
364 SwField
* GetField(size_t nId
);
366 void GotoFieldPos(size_t nId
);
370 /** Put all that are new into SortLst for updating. @return true if not empty.
371 (For Glossary: only update its input-fields).
372 Compare TmpLst with current fields. */
377 _SetGetExpFields
* pSrtLst
;
378 std::set
<const SwTextField
*> aTmpLst
;
381 /// Implementation in tblcalc.cxx.
382 class SwTableFieldType
: public SwValueFieldType
385 SwTableFieldType(SwDoc
* pDocPtr
);
386 virtual SwFieldType
* Copy() const SAL_OVERRIDE
;
389 class SwTableField
: public SwValueField
, public SwTableFormula
394 virtual OUString
Expand() const SAL_OVERRIDE
;
395 virtual SwField
* Copy() const SAL_OVERRIDE
;
397 /// Search TextNode containing the field.
398 virtual const SwNode
* GetNodeOfFormula() const SAL_OVERRIDE
;
400 OUString
GetCommand();
403 SwTableField( SwTableFieldType
*, const OUString
& rFormel
,
404 sal_uInt16 nSubType
= 0, sal_uLong nFormat
= 0);
406 virtual void SetValue( const double& rVal
) SAL_OVERRIDE
;
407 virtual sal_uInt16
GetSubType() const SAL_OVERRIDE
;
408 virtual void SetSubType(sal_uInt16 nType
) SAL_OVERRIDE
;
410 OUString
GetExpStr() const { return sExpand
; }
411 void ChgExpStr(const OUString
& rStr
) { sExpand
= rStr
; }
413 void CalcField( SwTableCalcPara
& rCalcPara
);
415 virtual OUString
GetFieldName() const SAL_OVERRIDE
;
418 virtual OUString
GetPar2() const SAL_OVERRIDE
;
419 virtual void SetPar2(const OUString
& rStr
) SAL_OVERRIDE
;
420 virtual bool QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt16 nWhich
) const SAL_OVERRIDE
;
421 virtual bool PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt16 nWhich
) SAL_OVERRIDE
;
424 #endif // INCLUDED_SW_INC_EXPFLD_HXX
426 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */