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