LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/fields - expfld.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 223 633 35.2 %
Date: 2013-07-09 Functions: 36 68 52.9 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10