xref: /aoo42x/main/sw/source/core/fields/expfld.cxx (revision c0286415)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #include <hintids.hxx>
28 #include <unotools/collatorwrapper.hxx>
29 #include <unotools/charclass.hxx>
30 #include <editeng/unolingu.hxx>
31 #include <svx/pageitem.hxx>
32 #include <editeng/langitem.hxx>
33 #include <editeng/fontitem.hxx>
34 #include <com/sun/star/text/SetVariableType.hpp>
35 #include <unofield.hxx>
36 #include <frmfmt.hxx>
37 #include <fmtfld.hxx>
38 #include <txtfld.hxx>
39 #include <fmtanchr.hxx>
40 #include <txtftn.hxx>
41 #include <doc.hxx>
42 #include <layfrm.hxx>
43 #include <pagefrm.hxx>
44 #include <cntfrm.hxx>
45 #include <rootfrm.hxx>
46 #include <tabfrm.hxx>
47 #include <flyfrm.hxx>
48 #include <ftnfrm.hxx>
49 #include <rowfrm.hxx>
50 #include <expfld.hxx>
51 #include <usrfld.hxx>
52 #include <ndtxt.hxx>
53 #include <calc.hxx>
54 #include <pam.hxx>
55 #include <docfld.hxx>
56 #include <swcache.hxx>
57 #include <swtable.hxx>
58 #include <breakit.hxx>
59 #include <SwStyleNameMapper.hxx>
60 #include <unofldmid.h>
61 #include <numrule.hxx>
62 #include <switerator.hxx>
63 
64 using namespace ::com::sun::star;
65 using namespace ::com::sun::star::text;
66 using ::rtl::OUString;
67 
68 SV_IMPL_PTRARR( _SwSeqFldList, _SeqFldLstElem* )
69 
70 //-----------------------------------------------------------------------------
71 sal_Int16 lcl_SubTypeToAPI(sal_uInt16 nSubType)
72 {
73 		sal_Int16 nRet = 0;
74 		switch(nSubType)
75 		{
76 			case nsSwGetSetExpType::GSE_EXPR:
77                 nRet = SetVariableType::VAR;      // 0
78                 break;
79 			case nsSwGetSetExpType::GSE_SEQ:
80                 nRet = SetVariableType::SEQUENCE; // 1
81                 break;
82 			case nsSwGetSetExpType::GSE_FORMULA:
83                 nRet = SetVariableType::FORMULA;  // 2
84                 break;
85 			case nsSwGetSetExpType::GSE_STRING:
86                 nRet = SetVariableType::STRING;   // 3
87                 break;
88 		}
89 		return nRet;
90 }
91 //-----------------------------------------------------------------------------
92 sal_Int32 lcl_APIToSubType(const uno::Any& rAny)
93 {
94 		sal_Int16 nVal = 0;
95 		rAny >>= nVal;
96 		sal_Int32 nSet = 0;
97 		switch(nVal)
98 		{
99 			case SetVariableType::VAR:		nSet = nsSwGetSetExpType::GSE_EXPR;  break;
100 			case SetVariableType::SEQUENCE: nSet = nsSwGetSetExpType::GSE_SEQ;  break;
101 			case SetVariableType::FORMULA:  nSet = nsSwGetSetExpType::GSE_FORMULA; break;
102 			case SetVariableType::STRING:	nSet = nsSwGetSetExpType::GSE_STRING;	break;
103 			default:
104 				DBG_ERROR("wrong value");
105 				nSet = -1;
106 		}
107 		return nSet;
108 }
109 
110 //-----------------------------------------------------------------------------
111 
112 void ReplacePoint( String& rTmpName, sal_Bool bWithCommandType )
113 {
114     // replace first and last (if bWithCommandType: last two) dot Ersten und letzten Punkt ersetzen, da in Tabellennamen Punkte erlaubt sind
115     // since table names may contain dots
116 
117 	xub_StrLen nLen = rTmpName.Len();
118 	sal_Unicode *pStr = rTmpName.GetBufferAccess(), *pBackStr = pStr + nLen;
119 
120     long nBackCount = bWithCommandType ? 2 : 1;
121     xub_StrLen i;
122 
123     for( i = nLen; i; --i, pBackStr-- )
124 		if( '.' == *pBackStr )
125 		{
126 			*pBackStr = DB_DELIM;
127             if(!--nBackCount)
128                 break;
129 		}
130 	for( i = 0; i < nLen; ++i, ++pStr )
131 		if( '.' == *pStr )
132 		{
133 			*pStr = DB_DELIM;
134 			break;
135 		}
136 }
137 
138 SwTxtNode* GetFirstTxtNode( const SwDoc& rDoc, SwPosition& rPos,
139 							const SwCntntFrm *pCFrm, Point &rPt )
140 {
141 	SwTxtNode* pTxtNode = 0;
142 	if ( !pCFrm )
143 	{
144         const SwNodes& rNodes = rDoc.GetNodes();
145         rPos.nNode = *rNodes.GetEndOfContent().StartOfSectionNode();
146 		SwCntntNode* pCNd;
147         while( 0 != (pCNd = rNodes.GoNext( &rPos.nNode ) ) &&
148 				0 == ( pTxtNode = pCNd->GetTxtNode() ) )
149 						;
150 		ASSERT( pTxtNode, "wo ist der 1.TextNode" );
151 		rPos.nContent.Assign( pTxtNode, 0 );
152 	}
153 	else if ( !pCFrm->IsValid() )
154 	{
155 		pTxtNode = (SwTxtNode*)pCFrm->GetNode();
156 		rPos.nNode = *pTxtNode;
157 		rPos.nContent.Assign( pTxtNode, 0 );
158 	}
159 	else
160 	{
161 		pCFrm->GetCrsrOfst( &rPos, rPt );
162 		pTxtNode = rPos.nNode.GetNode().GetTxtNode();
163 	}
164 	return pTxtNode;
165 }
166 
167 const SwTxtNode* GetBodyTxtNode( const SwDoc& rDoc, SwPosition& rPos,
168 								const SwFrm& rFrm )
169 {
170 	const SwLayoutFrm* pLayout = (SwLayoutFrm*)rFrm.GetUpper();
171 	const SwTxtNode* pTxtNode = 0;
172 
173 	while( pLayout )
174 	{
175 		if( pLayout->IsFlyFrm() )
176 		{
177 			// hole das FlyFormat
178 			SwFrmFmt* pFlyFmt = ((SwFlyFrm*)pLayout)->GetFmt();
179 			ASSERT( pFlyFmt, "kein FlyFormat gefunden, wo steht das Feld" );
180 
181 			const SwFmtAnchor &rAnchor = pFlyFmt->GetAnchor();
182 
183 			if( FLY_AT_FLY == rAnchor.GetAnchorId() )
184 			{
185 				// und der Fly muss irgendwo angehaengt sein, also
186 				// den befragen
187                 pLayout = (SwLayoutFrm*)((SwFlyFrm*)pLayout)->GetAnchorFrm();
188 				continue;
189 			}
190             else if ((FLY_AT_PARA == rAnchor.GetAnchorId()) ||
191                      (FLY_AT_CHAR == rAnchor.GetAnchorId()) ||
192                      (FLY_AS_CHAR == rAnchor.GetAnchorId()))
193 			{
194 				ASSERT( rAnchor.GetCntntAnchor(), "keine gueltige Position" );
195 				rPos = *rAnchor.GetCntntAnchor();
196 				pTxtNode = rPos.nNode.GetNode().GetTxtNode();
197                 if ( FLY_AT_PARA == rAnchor.GetAnchorId() )
198                 {
199                     const_cast<SwTxtNode*>(pTxtNode)->MakeStartIndex(
200                             &rPos.nContent );
201 // oder doch besser das Ende vom (Anker-)TextNode nehmen ??
202 //					((SwTxtNode*)pTxtNode)->MakeEndIndex( &rPos.nContent );
203                 }
204 
205 				// noch nicht abbrechen, kann ja auch noch im
206 				// Header/Footer/Footnote/Fly stehen !!
207                 pLayout = ((SwFlyFrm*)pLayout)->GetAnchorFrm()
208                             ? ((SwFlyFrm*)pLayout)->GetAnchorFrm()->GetUpper() : 0;
209 				continue;
210 			}
211 			else
212 			{
213 				pLayout->FindPageFrm()->GetCntntPosition(
214 												pLayout->Frm().Pos(), rPos );
215 				pTxtNode = rPos.nNode.GetNode().GetTxtNode();
216 			}
217 		}
218 		else if( pLayout->IsFtnFrm() )
219 		{
220 			// hole den Node vom Anker
221 			const SwTxtFtn* pFtn = ((SwFtnFrm*)pLayout)->GetAttr();
222 			pTxtNode = &pFtn->GetTxtNode();
223 			rPos.nNode = *pTxtNode;
224 			rPos.nContent = *pFtn->GetStart();
225 		}
226 		else if( pLayout->IsHeaderFrm() || pLayout->IsFooterFrm() )
227 		{
228 			const SwCntntFrm* pCntFrm;
229 			const SwPageFrm* pPgFrm = pLayout->FindPageFrm();
230 			if( pLayout->IsHeaderFrm() )
231 			{
232 				const SwTabFrm *pTab;
233 				if( 0 != ( pCntFrm = pPgFrm->FindFirstBodyCntnt()) &&
234 					0 != (pTab = pCntFrm->FindTabFrm()) && pTab->IsFollow() &&
235                     pTab->GetTable()->GetRowsToRepeat() > 0 &&
236                     pTab->IsInHeadline( *pCntFrm ) )
237                 {
238 					// take the next line
239                     const SwLayoutFrm* pRow = pTab->GetFirstNonHeadlineRow();
240                     pCntFrm = pRow->ContainsCntnt();
241 				}
242 			}
243 			else
244 				pCntFrm = pPgFrm->FindLastBodyCntnt();
245 
246 			if( pCntFrm )
247 			{
248 				pTxtNode = pCntFrm->GetNode()->GetTxtNode();
249 				rPos.nNode = *pTxtNode;
250 				((SwTxtNode*)pTxtNode)->MakeEndIndex( &rPos.nContent );
251 			}
252 			else
253 			{
254 				Point aPt( pLayout->Frm().Pos() );
255 				aPt.Y()++;		// aus dem Header raus
256 				pCntFrm = pPgFrm->GetCntntPos( aPt, sal_False, sal_True, sal_False );
257 				pTxtNode = GetFirstTxtNode( rDoc, rPos, pCntFrm, aPt );
258 			}
259 		}
260 		else
261 		{
262 			pLayout = pLayout->GetUpper();
263 			continue;
264 		}
265 		break;		// gefunden und beende die Schleife
266 	}
267 	return pTxtNode;
268 }
269 
270 /*--------------------------------------------------------------------
271 	Beschreibung: SwSetExpFieldType by JP
272  --------------------------------------------------------------------*/
273 
274 SwGetExpFieldType::SwGetExpFieldType(SwDoc* pDc)
275 	: SwValueFieldType( pDc, RES_GETEXPFLD )
276 {
277 }
278 
279 SwFieldType* SwGetExpFieldType::Copy() const
280 {
281 	return new SwGetExpFieldType(GetDoc());
282 }
283 
284 void SwGetExpFieldType::Modify( const SfxPoolItem*, const SfxPoolItem* pNew )
285 {
286 	if( pNew && RES_DOCPOS_UPDATE == pNew->Which() )
287 		NotifyClients( 0, pNew );
288 	// sonst nichts weiter expandieren
289 }
290 
291 /*--------------------------------------------------------------------
292 	Beschreibung: SwGetExpField by JP
293  --------------------------------------------------------------------*/
294 
295 SwGetExpField::SwGetExpField(SwGetExpFieldType* pTyp, const String& rFormel,
296 							sal_uInt16 nSub, sal_uLong nFmt)
297 	: SwFormulaField( pTyp, nFmt, 0.0 ),
298 	bIsInBodyTxt( sal_True ),
299     nSubType(nSub),
300 	bLateInitialization( false )
301 {
302 	SetFormula( rFormel );
303 }
304 
305 String SwGetExpField::Expand() const
306 {
307 	if(nSubType & nsSwExtendedSubType::SUB_CMD)
308 		return GetFormula();
309 	else
310 		return sExpand;
311 }
312 
313 String SwGetExpField::GetFieldName() const
314 {
315     String aStr( SwFieldType::GetTypeStr(
316         static_cast<sal_uInt16>(((nsSwGetSetExpType::GSE_FORMULA & nSubType) != 0)
317                                             ? TYP_FORMELFLD
318                                             : TYP_GETFLD ) ));
319     aStr += ' ';
320     aStr += GetFormula();
321     return aStr;
322 }
323 
324 SwField* SwGetExpField::Copy() const
325 {
326 	SwGetExpField *pTmp = new SwGetExpField((SwGetExpFieldType*)GetTyp(),
327 											GetFormula(), nSubType, GetFormat());
328 	pTmp->SetLanguage(GetLanguage());
329 	pTmp->SwValueField::SetValue(GetValue());
330 	pTmp->sExpand 		= sExpand;
331 	pTmp->bIsInBodyTxt 	= bIsInBodyTxt;
332     pTmp->SetAutomaticLanguage(IsAutomaticLanguage());
333 	if( bLateInitialization )
334 		pTmp->SetLateInitialization();
335 
336 	return pTmp;
337 }
338 
339 void SwGetExpField::ChangeExpansion( const SwFrm& rFrm, const SwTxtFld& rFld )
340 {
341 	if( bIsInBodyTxt )		// nur Felder in Footer, Header, FootNote, Flys
342 		return;
343 
344 	ASSERT( !rFrm.IsInDocBody(), "Flag ist nicht richtig, Frame steht im DocBody" );
345 
346 	// bestimme mal das Dokument (oder geht es noch einfacher?)
347 	const SwTxtNode* pTxtNode = &rFld.GetTxtNode();
348 	SwDoc& rDoc = *(SwDoc*)pTxtNode->GetDoc();
349 
350 	// einen Index fuers bestimmen vom TextNode anlegen
351 	SwPosition aPos( SwNodeIndex( rDoc.GetNodes() ) );
352 	pTxtNode = GetBodyTxtNode( rDoc, aPos, rFrm );
353 
354 	// Wenn kein Layout vorhanden, kommt es in Kopf und Fusszeilen dazu
355 	// das ChnageExpansion uebers Layout-Formatieren aufgerufen wird
356 	// aber kein TxtNode vorhanden ist
357 	//
358 	if(!pTxtNode)
359 		return;
360 	// #i82544#
361     if( bLateInitialization )
362 	{
363 		SwFieldType* pSetExpFld = rDoc.GetFldType(RES_SETEXPFLD, GetFormula(), sal_False);
364 		if( pSetExpFld )
365 		{
366 			bLateInitialization = false;
367 			if( !(GetSubType() & nsSwGetSetExpType::GSE_STRING) &&
368 				static_cast< SwSetExpFieldType* >(pSetExpFld)->GetType() == nsSwGetSetExpType::GSE_STRING )
369 			SetSubType( nsSwGetSetExpType::GSE_STRING );
370 		}
371 	}
372 
373 	_SetGetExpFld aEndFld( aPos.nNode, &rFld, &aPos.nContent );
374 	if(GetSubType() & nsSwGetSetExpType::GSE_STRING)
375 	{
376 		SwHash** ppHashTbl;
377 		sal_uInt16 nSize;
378 		rDoc.FldsToExpand( ppHashTbl, nSize, aEndFld );
379 		LookString( ppHashTbl, nSize, GetFormula(), sExpand );
380 		::DeleteHashTable( ppHashTbl, nSize );		// HashTabelle loeschen
381 	}
382 	else
383 	{
384 		// fuelle den Calculator mit den Werten
385 		SwCalc aCalc( rDoc );
386 		rDoc.FldsToCalc(aCalc, aEndFld);
387 
388 		// Wert berechnen
389 		SetValue(aCalc.Calculate(GetFormula()).GetDouble());
390 
391 		// Auswertung nach Format
392 		sExpand = ((SwValueFieldType*)GetTyp())->ExpandValue(
393 								GetValue(), GetFormat(), GetLanguage());
394 	}
395 }
396 
397 String SwGetExpField::GetPar2() const
398 {
399 	return GetFormula();
400 }
401 
402 void SwGetExpField::SetPar2(const String& rStr)
403 {
404 	SetFormula(rStr);
405 }
406 
407 sal_uInt16 SwGetExpField::GetSubType() const
408 {
409 	return nSubType;
410 }
411 
412 void SwGetExpField::SetSubType(sal_uInt16 nType)
413 {
414 	nSubType = nType;
415 }
416 
417 void SwGetExpField::SetLanguage(sal_uInt16 nLng)
418 {
419 	if (nSubType & nsSwExtendedSubType::SUB_CMD)
420 		SwField::SetLanguage(nLng);
421 	else
422 		SwValueField::SetLanguage(nLng);
423 }
424 
425 sal_Bool SwGetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
426 {
427     switch( nWhichId )
428 	{
429 	case FIELD_PROP_DOUBLE:
430 		rAny <<= GetValue();
431 		break;
432 	case FIELD_PROP_FORMAT:
433 		rAny <<= (sal_Int32)GetFormat();
434 		break;
435 	case FIELD_PROP_USHORT1:
436 		 rAny <<= (sal_Int16)nSubType;
437 		break;
438 	case FIELD_PROP_PAR1:
439 	 	rAny <<= OUString( GetFormula() );
440 		break;
441 	case FIELD_PROP_SUBTYPE:
442 		{
443 			sal_Int16 nRet = lcl_SubTypeToAPI(GetSubType() & 0xff);
444 			rAny <<= nRet;
445 		}
446 		break;
447 	case FIELD_PROP_BOOL2:
448 		{
449 			sal_Bool bTmp = 0 != (nSubType & nsSwExtendedSubType::SUB_CMD);
450 			rAny.setValue(&bTmp, ::getBooleanCppuType());
451 		}
452 		break;
453 	case FIELD_PROP_PAR4:
454 		rAny <<= rtl::OUString(GetExpStr());
455 		break;
456 	default:
457         return SwField::QueryValue(rAny, nWhichId);
458     }
459 	return sal_True;
460 }
461 
462 sal_Bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
463 {
464 	sal_Int32 nTmp = 0;
465 	String sTmp;
466     switch( nWhichId )
467 	{
468 	case FIELD_PROP_DOUBLE:
469 		SwValueField::SetValue(*(double*) rAny.getValue());
470 		break;
471 	case FIELD_PROP_FORMAT:
472 		rAny >>= nTmp;
473 		SetFormat(nTmp);
474 		break;
475 	case FIELD_PROP_USHORT1:
476 		 rAny >>= nTmp;
477 		 nSubType = static_cast<sal_uInt16>(nTmp);
478 		break;
479 	case FIELD_PROP_PAR1:
480 	 	SetFormula( ::GetString( rAny, sTmp ));
481 		break;
482 	case FIELD_PROP_SUBTYPE:
483 		nTmp = lcl_APIToSubType(rAny);
484 		if( nTmp >=0 )
485 			SetSubType( static_cast<sal_uInt16>((GetSubType() & 0xff00) | nTmp));
486 		break;
487 	case FIELD_PROP_BOOL2:
488 		if(*(sal_Bool*) rAny.getValue())
489 			nSubType |= nsSwExtendedSubType::SUB_CMD;
490 		else
491 			nSubType &= (~nsSwExtendedSubType::SUB_CMD);
492 		break;
493 	case FIELD_PROP_PAR4:
494 		ChgExpStr(::GetString( rAny, sTmp ));
495 		break;
496 	default:
497         return SwField::PutValue(rAny, nWhichId);
498     }
499 	return sal_True;
500 }
501 
502 SwSetExpFieldType::SwSetExpFieldType( SwDoc* pDc, const String& rName, sal_uInt16 nTyp )
503 	: SwValueFieldType( pDc, RES_SETEXPFLD ),
504 	sName( rName ),
505 	pOutlChgNd( 0 ),
506 	sDelim( String::CreateFromAscii( "." ) ),
507 	nType(nTyp), nLevel( UCHAR_MAX ),
508 	bDeleted( sal_False )
509 {
510 	if( ( nsSwGetSetExpType::GSE_SEQ | nsSwGetSetExpType::GSE_STRING ) & nType )
511 		EnableFormat(sal_False);	// Numberformatter nicht einsetzen
512 }
513 
514 SwFieldType* SwSetExpFieldType::Copy() const
515 {
516 	SwSetExpFieldType* pNew = new SwSetExpFieldType(GetDoc(), sName, nType);
517 	pNew->bDeleted = bDeleted;
518 	pNew->sDelim = sDelim;
519 	pNew->nLevel = nLevel;
520 
521 	return pNew;
522 }
523 
524 const String& SwSetExpFieldType::GetName() const
525 {
526 	return sName;
527 }
528 
529 void SwSetExpFieldType::Modify( const SfxPoolItem*, const SfxPoolItem* )
530 {
531 	return;		// nicht weiter expandieren
532 }
533 
534 void SwSetExpFieldType::SetSeqFormat(sal_uLong nFmt)
535 {
536 	SwIterator<SwFmtFld,SwFieldType> aIter(*this);
537 	for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
538 		pFmtFld->GetField()->ChangeFormat( nFmt );
539 }
540 
541 sal_uLong SwSetExpFieldType::GetSeqFormat()
542 {
543 	if( !GetDepends() )
544 		return SVX_NUM_ARABIC;
545 
546 	SwField *pFld = ((SwFmtFld*)GetDepends())->GetField();
547 	return pFld->GetFormat();
548 }
549 
550 sal_uInt16 SwSetExpFieldType::SetSeqRefNo( SwSetExpField& rFld )
551 {
552 	if( !GetDepends() || !(nsSwGetSetExpType::GSE_SEQ & nType) )
553 		return USHRT_MAX;
554 
555 extern void InsertSort( SvUShorts& rArr, sal_uInt16 nIdx, sal_uInt16* pInsPos = 0 );
556 	SvUShorts aArr( 64 );
557 
558 	sal_uInt16 n;
559 
560 	// dann testmal, ob die Nummer schon vergeben ist oder ob eine neue
561 	// bestimmt werden muss.
562 	SwIterator<SwFmtFld,SwFieldType> aIter( *this );
563 	const SwTxtNode* pNd;
564 	for( SwFmtFld* pF = aIter.First(); pF; pF = aIter.Next() )
565 		if( pF->GetField() != &rFld && pF->GetTxtFld() &&
566 			0 != ( pNd = pF->GetTxtFld()->GetpTxtNode() ) &&
567 			pNd->GetNodes().IsDocNodes() )
568 			InsertSort( aArr, ((SwSetExpField*)pF->GetField())->GetSeqNumber() );
569 
570 
571 	// teste erstmal ob die Nummer schon vorhanden ist:
572 	sal_uInt16 nNum = rFld.GetSeqNumber();
573 	if( USHRT_MAX != nNum )
574 	{
575 		for( n = 0; n < aArr.Count(); ++n )
576 			if( aArr[ n ] > nNum )
577 				return nNum;			// nicht vorhanden -> also benutzen
578 			else if( aArr[ n ] == nNum )
579 				break;					// schon vorhanden -> neue erzeugen
580 
581 		if( n == aArr.Count() )
582 			return nNum;			// nicht vorhanden -> also benutzen
583 	}
584 
585 	// alle Nummern entsprechend geflag, also bestimme die richtige Nummer
586 	for( n = 0; n < aArr.Count(); ++n )
587 		if( n != aArr[ n ] )
588 			break;
589 
590 	rFld.SetSeqNumber( n );
591 	return n;
592 }
593 
594 sal_uInt16 SwSetExpFieldType::GetSeqFldList( SwSeqFldList& rList )
595 {
596 	if( rList.Count() )
597 		rList.Remove( 0, rList.Count() );
598 
599 	SwIterator<SwFmtFld,SwFieldType> aIter( *this );
600 	const SwTxtNode* pNd;
601 	for( SwFmtFld* pF = aIter.First(); pF; pF = aIter.Next() )
602 		if( pF->GetTxtFld() &&
603 			0 != ( pNd = pF->GetTxtFld()->GetpTxtNode() ) &&
604 			pNd->GetNodes().IsDocNodes() )
605 		{
606             _SeqFldLstElem* pNew = new _SeqFldLstElem(
607                     pNd->GetExpandTxt( 0, (*pF->GetTxtFld()->GetStart()) + 1 ),
608                     ((SwSetExpField*)pF->GetField())->GetSeqNumber() );
609 			rList.InsertSort( pNew );
610 		}
611 
612 	return rList.Count();
613 }
614 
615 
616 void SwSetExpFieldType::SetChapter( SwSetExpField& rFld, const SwNode& rNd )
617 {
618 	const SwTxtNode* pTxtNd = rNd.FindOutlineNodeOfLevel( nLevel );
619 	if( pTxtNd )
620 	{
621         SwNumRule * pRule = pTxtNd->GetNumRule();
622 
623         if (pRule)
624         {
625             // --> OD 2005-11-02 #i51089 - TUNING#
626             if ( pTxtNd->GetNum() )
627             {
628                 const SwNodeNum & aNum = *(pTxtNd->GetNum());
629 
630                 // nur die Nummer besorgen, ohne Pre-/Post-fixstrings
631                 String sNumber( pRule->MakeNumString(aNum, sal_False ));
632 
633                 if( sNumber.Len() )
634                     rFld.ChgExpStr(  ( sNumber += sDelim ) += rFld.GetExpStr() );
635             }
636             else
637             {
638                 ASSERT( false,
639                         "<SwSetExpFieldType::SetChapter(..)> - text node with numbering rule, but without number. This is a serious defect -> inform OD" );
640             }
641         }
642 	}
643 }
644 
645 sal_Bool SwSetExpFieldType::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
646 {
647     switch( nWhichId )
648 	{
649 	case FIELD_PROP_SUBTYPE:
650 		{
651 			sal_Int16 nRet = lcl_SubTypeToAPI(GetType());
652 			rAny <<= nRet;
653 		}
654 		break;
655 	case FIELD_PROP_PAR2:
656 		rAny <<= OUString(GetDelimiter());
657 		break;
658 	case FIELD_PROP_SHORT1:
659 		{
660 			sal_Int8 nRet = nLevel < MAXLEVEL? nLevel : -1;
661 			rAny <<= nRet;
662 		}
663 		break;
664 	default:
665 		DBG_ERROR("illegal property");
666 	}
667 	return sal_True;
668 }
669 
670 sal_Bool SwSetExpFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
671 {
672     switch( nWhichId )
673 	{
674 	case FIELD_PROP_SUBTYPE:
675 		{
676 			sal_Int32 nSet = lcl_APIToSubType(rAny);
677 			if(nSet >=0)
678 				SetType(static_cast<sal_uInt16>(nSet));
679 		}
680 		break;
681 	case FIELD_PROP_PAR2:
682 		{
683 			String sTmp;
684 			if( ::GetString( rAny, sTmp ).Len() )
685 //				SetDelimiter( sTmp.GetChar( 0 ));
686 				SetDelimiter( sTmp );
687 			else
688 				SetDelimiter(String::CreateFromAscii( " "));
689 		}
690 		break;
691 	case FIELD_PROP_SHORT1:
692 		{
693 			sal_Int8 nLvl = 0;
694 			rAny >>= nLvl;
695 			if(nLvl < 0 || nLvl >= MAXLEVEL)
696 				SetOutlineLvl(UCHAR_MAX);
697 			else
698 				SetOutlineLvl(nLvl);
699 		}
700 		break;
701 	default:
702 		DBG_ERROR("illegal property");
703 	}
704 	return sal_True;
705 }
706 
707 sal_Bool SwSeqFldList::InsertSort( _SeqFldLstElem* pNew )
708 {
709 	sal_Unicode* p = pNew->sDlgEntry.GetBufferAccess();
710 	while( *p )
711 	{
712 		if( *p < 0x20 )
713 			*p = 0x20;
714 		++p;
715 	}
716 
717 	sal_uInt16 nPos;
718 	sal_Bool bRet = SeekEntry( *pNew, &nPos );
719 	if( !bRet )
720 		C40_INSERT( _SeqFldLstElem, pNew, nPos );
721 	return bRet;
722 }
723 
724 sal_Bool SwSeqFldList::SeekEntry( const _SeqFldLstElem& rNew, sal_uInt16* pP )
725 {
726 	sal_uInt16 nO = Count(), nM, nU = 0;
727 	if( nO > 0 )
728 	{
729 		CollatorWrapper & rCaseColl = ::GetAppCaseCollator(),
730 						& rColl = ::GetAppCollator();
731 		const CharClass& rCC = GetAppCharClass();
732 
733 		//#59900# Die Sortierung soll die Nummer korrekt einordnen
734 		//also "10" nach "9" und nicht "10" nach "1"
735 		const String& rTmp2 = rNew.sDlgEntry;
736 		xub_StrLen nFndPos2 = 0;
737 		String sNum2( rTmp2.GetToken( 0, ' ', nFndPos2 ));
738 		sal_Bool bIsNum2IsNumeric = rCC.isAsciiNumeric( sNum2 );
739 		sal_Int32 nNum2 = bIsNum2IsNumeric ? sNum2.ToInt32() : 0;
740 
741 		nO--;
742 		while( nU <= nO )
743 		{
744 			nM = nU + ( nO - nU ) / 2;
745 
746 			//#59900# Die Sortierung soll die Nummer korrekt einordnen
747 			//also "10" nach "9" und nicht "10" nach "1"
748 			const String& rTmp1 = (*((_SeqFldLstElem**)pData + nM))->sDlgEntry;
749 			xub_StrLen nFndPos1 = 0;
750 			String sNum1( rTmp1.GetToken( 0, ' ', nFndPos1 ));
751 			sal_Int32 nCmp;
752 
753 			if( bIsNum2IsNumeric && rCC.isNumeric( sNum1 ) )
754 			{
755 				sal_Int32 nNum1 = sNum1.ToInt32();
756 				nCmp = nNum2 - nNum1;
757 				if( 0 == nCmp )
758 					nCmp = rCaseColl.compareString( rTmp2.Copy( nFndPos2 ),
759 										 			  rTmp1.Copy( nFndPos1 ));
760 			}
761 			else
762 				nCmp = rColl.compareString( rTmp2, rTmp1 );
763 
764 			if( 0 == nCmp )
765 			{
766 				if( pP ) *pP = nM;
767 				return sal_True;
768 			}
769 			else if( 0 < nCmp )
770 				nU = nM + 1;
771 			else if( nM == 0 )
772 				break;
773 			else
774 				nO = nM - 1;
775 		}
776 	}
777 	if( pP ) *pP = nU;
778 	return sal_False;
779 }
780 
781 /*--------------------------------------------------------------------
782 	Beschreibung: SwSetExpField by JP
783  --------------------------------------------------------------------*/
784 
785 SwSetExpField::SwSetExpField(SwSetExpFieldType* pTyp, const String& rFormel,
786 										sal_uLong nFmt)
787 	: SwFormulaField( pTyp, nFmt, 0.0 ), nSeqNo( USHRT_MAX ),
788 	nSubType(0)
789 {
790 	SetFormula(rFormel);
791 	// SubType ignorieren !!!
792 	bInput = sal_False;
793 	if( IsSequenceFld() )
794 	{
795 		SwValueField::SetValue(1.0);
796 		if( !rFormel.Len() )
797 		{
798 			String sFormel(rFormel);
799 			sFormel += pTyp->GetName();
800 			sFormel += '+';
801 			sFormel += '1';
802 			SetFormula(sFormel);
803 		}
804 	}
805 }
806 
807 String SwSetExpField::Expand() const
808 {
809 	String aStr;
810 	if (nSubType & nsSwExtendedSubType::SUB_CMD)
811 	{	// Der CommandString ist gefragt
812 		aStr = GetTyp()->GetName();
813 		aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " = " ));
814 		aStr += GetFormula();
815 	}
816 	else if(!(nSubType & nsSwExtendedSubType::SUB_INVISIBLE))
817 	{   // Der Wert ist sichtbar
818 		aStr = sExpand;
819 	}
820 	return aStr;
821 }
822 
823 /*--------------------------------------------------------------------
824 	@return the field name
825  --------------------------------------------------------------------*/
826 
827 String SwSetExpField::GetFieldName() const
828 {
829     SwFldTypesEnum const nStrType( (IsSequenceFld())
830                             ? TYP_SEQFLD
831                             : (bInput)
832                                 ? TYP_SETINPFLD
833                                 : TYP_SETFLD   );
834 
835     String aStr( SwFieldType::GetTypeStr( static_cast<sal_uInt16>(nStrType) ) );
836     aStr += ' ';
837     aStr += GetTyp()->GetName();
838 
839     // Sequence: without formula
840     if (TYP_SEQFLD != nStrType)
841     {
842         aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " = " ) );
843         aStr += GetFormula();
844     }
845     return aStr;
846 }
847 
848 SwField* SwSetExpField::Copy() const
849 {
850 	SwSetExpField *pTmp = new SwSetExpField((SwSetExpFieldType*)GetTyp(),
851 											GetFormula(), GetFormat());
852 	pTmp->SwValueField::SetValue(GetValue());
853 	pTmp->sExpand   	= sExpand;
854     pTmp->SetAutomaticLanguage(IsAutomaticLanguage());
855     pTmp->SetLanguage(GetLanguage());
856 	pTmp->aPText		= aPText;
857 	pTmp->bInput		= bInput;
858 	pTmp->nSeqNo		= nSeqNo;
859 	pTmp->SetSubType(GetSubType());
860 
861 	return pTmp;
862 }
863 
864 void SwSetExpField::SetSubType(sal_uInt16 nSub)
865 {
866 	((SwSetExpFieldType*)GetTyp())->SetType(nSub & 0xff);
867 	nSubType = nSub & 0xff00;
868 
869 	DBG_ASSERT( (nSub & 0xff) != 3, "SubType ist illegal!" );
870 }
871 
872 sal_uInt16 SwSetExpField::GetSubType() const
873 {
874 	return ((SwSetExpFieldType*)GetTyp())->GetType() | nSubType;
875 }
876 
877 void SwSetExpField::SetValue( const double& rAny )
878 {
879 	SwValueField::SetValue(rAny);
880 
881 	if( IsSequenceFld() )
882 		sExpand = FormatNumber( (sal_uInt16)GetValue(), GetFormat() );
883 	else
884 		sExpand = ((SwValueFieldType*)GetTyp())->ExpandValue( rAny,
885 												GetFormat(), GetLanguage());
886 }
887 
888 void SwGetExpField::SetValue( const double& rAny )
889 {
890 	SwValueField::SetValue(rAny);
891 	sExpand = ((SwValueFieldType*)GetTyp())->ExpandValue( rAny, GetFormat(),
892 															GetLanguage());
893 }
894 /* -------------------------------------------------
895 	Description: Find the index of the reference text
896 	following the current field
897  --------------------------------------------------*/
898 xub_StrLen SwGetExpField::GetReferenceTextPos( const SwFmtFld& rFmt, SwDoc& rDoc)
899 {
900 	//
901 	const SwTxtFld* pTxtFld = rFmt.GetTxtFld();
902 	const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode();
903 	//
904 	xub_StrLen nRet = *pTxtFld->GetStart() + 1;
905 	String sNodeText = rTxtNode.GetTxt();
906 	sNodeText.Erase(0, nRet);
907 	if(sNodeText.Len())
908 	{
909 		//now check if sNodeText starts with a non-alphanumeric character plus a blank
910 		sal_uInt16 nSrcpt = pBreakIt->GetRealScriptOfText( sNodeText, 0 );
911 
912 		static sal_uInt16 nIds[] =
913 		{
914 			RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE,
915 			RES_CHRATR_FONT, RES_CHRATR_FONT,
916 			RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
917 			RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
918 			RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE,
919 			RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT,
920 			0, 0
921 		};
922 		SwAttrSet aSet(rDoc.GetAttrPool(), nIds);
923 		rTxtNode.GetAttr(aSet, nRet, nRet+1);
924 
925 		if( RTL_TEXTENCODING_SYMBOL != ((SvxFontItem&)aSet.Get(
926 				GetWhichOfScript( RES_CHRATR_FONT, nSrcpt )) ).GetCharSet() )
927 		{
928 			LanguageType eLang = ((SvxLanguageItem&)aSet.Get(
929 				GetWhichOfScript( RES_CHRATR_LANGUAGE, nSrcpt )) ).GetLanguage();
930 			CharClass aCC( SvxCreateLocale( eLang ));
931 			sal_Unicode c0 = sNodeText.GetChar(0);
932 			sal_Bool bIsAlphaNum = aCC.isAlphaNumeric( sNodeText, 0 );
933 			if( !bIsAlphaNum ||
934 				(c0 == ' ' || c0 == '\t'))
935 			{
936 				nRet++;
937 				if( sNodeText.Len() > 1 &&
938 					(sNodeText.GetChar(1) == ' ' ||
939 					 sNodeText.GetChar(1) == '\t'))
940 					nRet++;
941 			}
942 		}
943 	}
944 	return nRet;
945 }
946 
947 
948 /*--------------------------------------------------------------------
949 	Beschreibung: Parameter setzen
950  --------------------------------------------------------------------*/
951 
952 const String& SwSetExpField::GetPar1() const
953 {
954 	return ((SwSetExpFieldType*)GetTyp())->GetName();
955 }
956 
957 String SwSetExpField::GetPar2() const
958 {
959 	sal_uInt16 nType = ((SwSetExpFieldType*)GetTyp())->GetType();
960 
961 	if (nType & nsSwGetSetExpType::GSE_STRING)
962 		return GetFormula();
963 	return GetExpandedFormula();
964 }
965 
966 void SwSetExpField::SetPar2(const String& rStr)
967 {
968 	sal_uInt16 nType = ((SwSetExpFieldType*)GetTyp())->GetType();
969 
970 	if( !(nType & nsSwGetSetExpType::GSE_SEQ) || rStr.Len() )
971 	{
972 		if (nType & nsSwGetSetExpType::GSE_STRING)
973 			SetFormula(rStr);
974 		else
975 			SetExpandedFormula(rStr);
976 	}
977 }
978 
979 /*--------------------------------------------------------------------
980 	Beschreibung: Eingabefeld Type
981  ---------------------------------------------------------------------*/
982 
983 SwInputFieldType::SwInputFieldType( SwDoc* pD )
984 	: SwFieldType( RES_INPUTFLD ), pDoc( pD )
985 {
986 }
987 
988 SwFieldType* SwInputFieldType::Copy() const
989 {
990 	SwInputFieldType* pType = new SwInputFieldType( pDoc );
991 	return pType;
992 }
993 
994 /*--------------------------------------------------------------------
995 	Beschreibung: Eingabefeld
996  --------------------------------------------------------------------*/
997 
998 SwInputField::SwInputField(SwInputFieldType* pTyp, const String& rContent,
999 						   const String& rPrompt, sal_uInt16 nSub, sal_uLong nFmt) :
1000 	SwField(pTyp, nFmt), aContent(rContent), aPText(rPrompt), nSubType(nSub)
1001 {
1002 }
1003 
1004 String SwInputField::GetFieldName() const
1005 {
1006     String aStr(SwField::GetFieldName());
1007     if ((nSubType & 0x00ff) == INP_USR)
1008     {
1009         aStr += GetTyp()->GetName();
1010         aStr += ' ';
1011         aStr += aContent;
1012     }
1013     return aStr;
1014 }
1015 
1016 SwField* SwInputField::Copy() const
1017 {
1018 	SwInputField* pFld = new SwInputField((SwInputFieldType*)GetTyp(), aContent,
1019 										  aPText, GetSubType(), GetFormat());
1020 
1021     pFld->SetHelp(aHelp);
1022     pFld->SetToolTip(aToolTip);
1023 
1024     pFld->SetAutomaticLanguage(IsAutomaticLanguage());
1025     return pFld;
1026 }
1027 
1028 String SwInputField::Expand() const
1029 {
1030 	String sRet;
1031 	if((nSubType & 0x00ff) == INP_TXT)
1032 		sRet = aContent;
1033 
1034 	else if( (nSubType & 0x00ff) == INP_USR )
1035 	{
1036 		SwUserFieldType* pUserTyp = (SwUserFieldType*)
1037 							((SwInputFieldType*)GetTyp())->GetDoc()->
1038 							GetFldType( RES_USERFLD, aContent, false );
1039 		if( pUserTyp )
1040 			sRet = pUserTyp->GetContent();
1041 	}
1042 	return sRet;
1043 }
1044 
1045 sal_Bool SwInputField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
1046 {
1047     switch( nWhichId )
1048 	{
1049 	case FIELD_PROP_PAR1:
1050 		 rAny <<= OUString( aContent );
1051 		break;
1052 	case FIELD_PROP_PAR2:
1053 		rAny <<= OUString( aPText );
1054 		break;
1055     case FIELD_PROP_PAR3:
1056         rAny <<= OUString( aHelp );
1057         break;
1058     case FIELD_PROP_PAR4:
1059         rAny <<= OUString( aToolTip );
1060         break;
1061 	default:
1062 		DBG_ERROR("illegal property");
1063 	}
1064 	return sal_True;
1065 }
1066 
1067 sal_Bool SwInputField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
1068 {
1069     switch( nWhichId )
1070 	{
1071 	case FIELD_PROP_PAR1:
1072 		 ::GetString( rAny, aContent );
1073 		break;
1074 	case FIELD_PROP_PAR2:
1075 		::GetString( rAny, aPText );
1076 		break;
1077     case FIELD_PROP_PAR3:
1078         ::GetString( rAny, aHelp );
1079         break;
1080     case FIELD_PROP_PAR4:
1081         ::GetString( rAny, aToolTip );
1082         break;
1083 	default:
1084 		DBG_ERROR("illegal property");
1085 	}
1086 	return sal_True;
1087 }
1088 /*--------------------------------------------------------------------
1089 	Beschreibung: Bedingung setzen
1090  --------------------------------------------------------------------*/
1091 
1092 void SwInputField::SetPar1(const String& rStr)
1093 {
1094 	aContent = rStr;
1095 }
1096 
1097 const String& SwInputField::GetPar1() const
1098 {
1099 	return aContent;
1100 }
1101 
1102 /*--------------------------------------------------------------------
1103 	Beschreibung: True/False Text
1104  --------------------------------------------------------------------*/
1105 
1106 void SwInputField::SetPar2(const String& rStr)
1107 {
1108 	aPText = rStr;
1109 }
1110 
1111 String SwInputField::GetPar2() const
1112 {
1113 	return aPText;
1114 }
1115 
1116 void SwInputField::SetHelp(const String & rStr)
1117 {
1118     aHelp = rStr;
1119 }
1120 
1121 String SwInputField::GetHelp() const
1122 {
1123     return aHelp;
1124 }
1125 
1126 void SwInputField::SetToolTip(const String & rStr)
1127 {
1128     aToolTip = rStr;
1129 }
1130 
1131 String SwInputField::GetToolTip() const
1132 {
1133     return aToolTip;
1134 }
1135 
1136 sal_Bool SwInputField::isFormField() const
1137 {
1138     return aHelp.Len() > 0 || aToolTip.Len() > 0;
1139 }
1140 
1141 sal_uInt16 SwInputField::GetSubType() const
1142 {
1143 	return nSubType;
1144 }
1145 
1146 void SwInputField::SetSubType(sal_uInt16 nSub)
1147 {
1148 	nSubType = nSub;
1149 }
1150 
1151 sal_Bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
1152 {
1153     switch( nWhichId )
1154 	{
1155 	case FIELD_PROP_BOOL2:
1156 		{
1157 			sal_Bool bVal = 0 == (nSubType & nsSwExtendedSubType::SUB_INVISIBLE);
1158 			rAny.setValue(&bVal, ::getBooleanCppuType());
1159 		}
1160 		break;
1161 	case FIELD_PROP_FORMAT:
1162 		rAny <<= (sal_Int32)GetFormat();
1163 		break;
1164 	case FIELD_PROP_USHORT2:
1165 		rAny <<= (sal_Int16)GetFormat();
1166 		break;
1167 	case FIELD_PROP_USHORT1:
1168 		rAny <<= (sal_Int16)nSeqNo;
1169 		break;
1170 	case FIELD_PROP_PAR1:
1171 		rAny <<= OUString ( SwStyleNameMapper::GetProgName(GetPar1(), nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ) );
1172 		break;
1173 	case FIELD_PROP_PAR2:
1174 		{
1175 			//I18N - if the formula contains only "TypeName+1"
1176 			//and it's one of the initially created sequence fields
1177 			//then the localized names has to be replaced by a programmatic name
1178 			OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, GetFormula(), sal_True);
1179 			rAny <<= OUString( sMyFormula );
1180 		}
1181 		break;
1182 	case FIELD_PROP_DOUBLE:
1183 		rAny <<= (double)GetValue();
1184 		break;
1185 	case FIELD_PROP_SUBTYPE:
1186 		{
1187 			sal_Int16 nRet = 0;
1188 				nRet = lcl_SubTypeToAPI(GetSubType() & 0xff);
1189 			rAny <<= nRet;
1190 		}
1191 		break;
1192 	case FIELD_PROP_PAR3:
1193 		rAny <<= OUString( aPText );
1194 		break;
1195 	case FIELD_PROP_BOOL3:
1196 		{
1197 			sal_Bool bTmp = 0 != (nSubType & nsSwExtendedSubType::SUB_CMD);
1198 			rAny.setValue(&bTmp, ::getBooleanCppuType());
1199 		}
1200 		break;
1201 	case FIELD_PROP_BOOL1:
1202 		{
1203 			sal_Bool bTmp = GetInputFlag();
1204 			rAny.setValue(&bTmp, ::getBooleanCppuType());
1205 		}
1206 		break;
1207 	case FIELD_PROP_PAR4:
1208 		rAny <<= rtl::OUString(GetExpStr());
1209 		break;
1210 	default:
1211         return SwField::QueryValue(rAny, nWhichId);
1212     }
1213 	return sal_True;
1214 }
1215 
1216 sal_Bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
1217 {
1218 	sal_Int32 nTmp32 = 0;
1219 	sal_Int16 nTmp16 = 0;
1220 	String sTmp;
1221     switch( nWhichId )
1222 	{
1223 	case FIELD_PROP_BOOL2:
1224 		if(*(sal_Bool*)rAny.getValue())
1225 			nSubType &= ~nsSwExtendedSubType::SUB_INVISIBLE;
1226 		else
1227 			nSubType |= nsSwExtendedSubType::SUB_INVISIBLE;
1228 		break;
1229 	case FIELD_PROP_FORMAT:
1230 		rAny >>= nTmp32;
1231 		SetFormat(nTmp32);
1232 		break;
1233 	case FIELD_PROP_USHORT2:
1234 		{
1235 			rAny >>= nTmp16;
1236 			if(nTmp16 <= SVX_NUMBER_NONE )
1237 				SetFormat(nTmp16);
1238 			else {
1239 				//exception(wrong_value)
1240 				;
1241             }
1242 		}
1243 		break;
1244 	case FIELD_PROP_USHORT1:
1245 		rAny >>= nTmp16;
1246 		nSeqNo = nTmp16;
1247 		break;
1248 	case FIELD_PROP_PAR1:
1249 		SetPar1( SwStyleNameMapper::GetUIName(
1250 							::GetString( rAny, sTmp ), nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ) );
1251 		break;
1252 	case FIELD_PROP_PAR2:
1253 		{
1254 			OUString uTmp;
1255 			rAny >>= uTmp;
1256 			//I18N - if the formula contains only "TypeName+1"
1257 			//and it's one of the initially created sequence fields
1258 			//then the localized names has to be replaced by a programmatic name
1259 			OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, uTmp, sal_False);
1260 			SetFormula( sMyFormula );
1261 		}
1262 		break;
1263 	case FIELD_PROP_DOUBLE:
1264 		{
1265 		 	double fVal = 0.0;
1266 		 	rAny >>= fVal;
1267 		 	SetValue(fVal);
1268 		}
1269 		break;
1270 	case FIELD_PROP_SUBTYPE:
1271 		nTmp32 = lcl_APIToSubType(rAny);
1272 		if(nTmp32 >= 0)
1273 			SetSubType(static_cast<sal_uInt16>((GetSubType() & 0xff00) | nTmp32));
1274 		break;
1275 	case FIELD_PROP_PAR3:
1276 		::GetString( rAny, aPText );
1277 		break;
1278 	case FIELD_PROP_BOOL3:
1279 		if(*(sal_Bool*) rAny.getValue())
1280 			nSubType |= nsSwExtendedSubType::SUB_CMD;
1281 		else
1282 			nSubType &= (~nsSwExtendedSubType::SUB_CMD);
1283 		break;
1284 	case FIELD_PROP_BOOL1:
1285 		SetInputFlag(*(sal_Bool*) rAny.getValue());
1286 		break;
1287 	case FIELD_PROP_PAR4:
1288 		ChgExpStr( ::GetString( rAny, sTmp ));
1289 		break;
1290 	default:
1291         return SwField::PutValue(rAny, nWhichId);
1292     }
1293 	return sal_True;
1294 }
1295 
1296 
1297 
1298