LCOV - code coverage report
Current view: top level - sw/source/core/fields - fldlst.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 68 0.0 %
Date: 2014-04-11 Functions: 0 8 0.0 %
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 "switerator.hxx"
      21             : #include "editsh.hxx"
      22             : #include "doc.hxx"
      23             : #include <docary.hxx>
      24             : #include <fmtfld.hxx>
      25             : #include <txtfld.hxx>
      26             : #include "edimp.hxx"
      27             : #include "expfld.hxx"
      28             : #include "pam.hxx"
      29             : #include "docfld.hxx"
      30             : #include "ndtxt.hxx"
      31             : 
      32             : // sort input values
      33             : 
      34           0 : SwInputFieldList::SwInputFieldList( SwEditShell* pShell, sal_Bool bBuildTmpLst )
      35           0 :     : pSh(pShell)
      36             : {
      37             :     // create sorted list of all  input fields
      38           0 :     pSrtLst = new _SetGetExpFlds();
      39             : 
      40           0 :     const SwFldTypes& rFldTypes = *pSh->GetDoc()->GetFldTypes();
      41           0 :     const sal_uInt16 nSize = rFldTypes.size();
      42             : 
      43             :     // iterate over all types
      44           0 :     for(sal_uInt16 i=0; i < nSize; ++i)
      45             :     {
      46           0 :         SwFieldType* pFldType = (SwFieldType*)rFldTypes[ i ];
      47           0 :         sal_uInt16 nType = pFldType->Which();
      48             : 
      49           0 :         if( RES_SETEXPFLD == nType || RES_INPUTFLD == nType || RES_DROPDOWN == nType )
      50             :         {
      51           0 :             SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
      52           0 :             for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
      53             :             {
      54           0 :                 const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld();
      55             : 
      56             :                 // only process InputFields, interactive SetExpFlds and DropDown fields
      57           0 :                 if( !pTxtFld || ( RES_SETEXPFLD == nType &&
      58           0 :                     !((SwSetExpField*)pFmtFld->GetField())->GetInputFlag()))
      59           0 :                     continue;
      60             : 
      61           0 :                 const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode();
      62           0 :                 if( rTxtNode.GetNodes().IsDocNodes() )
      63             :                 {
      64           0 :                     if( bBuildTmpLst )
      65             :                     {
      66           0 :                         aTmpLst.insert( pTxtFld );
      67             :                     }
      68             :                     else
      69             :                     {
      70           0 :                         SwNodeIndex aIdx( rTxtNode );
      71           0 :                         _SetGetExpFld* pNew = new _SetGetExpFld(aIdx, pTxtFld );
      72           0 :                         pSrtLst->insert( pNew );
      73             :                     }
      74             :                 }
      75           0 :             }
      76             :         }
      77             :     }
      78           0 : }
      79             : 
      80           0 : SwInputFieldList::~SwInputFieldList()
      81             : {
      82           0 :     delete pSrtLst;
      83           0 : }
      84             : 
      85           0 : sal_uInt16 SwInputFieldList::Count() const
      86             : {
      87           0 :     return pSrtLst->size();
      88             : }
      89             : 
      90             : // get field from list in sorted order
      91           0 : SwField* SwInputFieldList::GetField(sal_uInt16 nId)
      92             : {
      93           0 :     const SwTxtFld* pTxtFld = (*pSrtLst)[ nId ]->GetTxtFld();
      94             :     OSL_ENSURE( pTxtFld, "no TextFld" );
      95           0 :     return (SwField*)pTxtFld->GetFmtFld().GetField();
      96             : }
      97             : 
      98             : /// save cursor
      99           0 : void SwInputFieldList::PushCrsr()
     100             : {
     101           0 :     pSh->Push();
     102           0 :     pSh->ClearMark();
     103           0 : }
     104             : 
     105             : /// get cursor
     106           0 : void SwInputFieldList::PopCrsr()
     107             : {
     108           0 :     pSh->Pop(sal_False);
     109           0 : }
     110             : 
     111             : /// go to position of a field
     112           0 : void SwInputFieldList::GotoFieldPos(sal_uInt16 nId)
     113             : {
     114           0 :     pSh->StartAllAction();
     115           0 :     (*pSrtLst)[ nId ]->GetPosOfContent( *pSh->GetCrsr()->GetPoint() );
     116           0 :     pSh->EndAllAction();
     117           0 : }
     118             : 
     119             : /** Compare TmpLst with current fields.
     120             :  *
     121             :  * All new ones are added to SortList so that they can be updated.
     122             :  * For text blocks: update only input fields.
     123             :  *
     124             :  * @return count
     125             :  */
     126           0 : sal_uInt16 SwInputFieldList::BuildSortLst()
     127             : {
     128           0 :     const SwFldTypes& rFldTypes = *pSh->GetDoc()->GetFldTypes();
     129           0 :     sal_uInt16 nSize = rFldTypes.size();
     130             : 
     131             :     // iterate over all types
     132           0 :     for( sal_uInt16 i = 0; i < nSize; ++i )
     133             :     {
     134           0 :         SwFieldType* pFldType = (SwFieldType*)rFldTypes[ i ];
     135           0 :         sal_uInt16 nType = pFldType->Which();
     136             : 
     137           0 :         if( RES_SETEXPFLD == nType || RES_INPUTFLD == nType )
     138             :         {
     139           0 :             SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
     140           0 :             for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
     141             :             {
     142           0 :                 const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld();
     143             : 
     144             :                 //  process only InputFields and interactive SetExpFlds
     145           0 :                 if( !pTxtFld || ( RES_SETEXPFLD == nType &&
     146           0 :                     !((SwSetExpField*)pFmtFld->GetField())->GetInputFlag()))
     147           0 :                     continue;
     148             : 
     149           0 :                 const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode();
     150           0 :                 if( rTxtNode.GetNodes().IsDocNodes() )
     151             :                 {
     152             :                     // not in TempList, thus add to SortList
     153           0 :                     std::set<const SwTxtFld*>::iterator it = aTmpLst.find( pTxtFld );
     154           0 :                     if( aTmpLst.end() == it )
     155             :                     {
     156           0 :                         SwNodeIndex aIdx( rTxtNode );
     157           0 :                         _SetGetExpFld* pNew = new _SetGetExpFld(aIdx, pTxtFld );
     158           0 :                         pSrtLst->insert( pNew );
     159             :                     }
     160             :                     else
     161           0 :                         aTmpLst.erase( it );
     162             :                 }
     163           0 :             }
     164             :         }
     165             :     }
     166             : 
     167             :     // the pointers are not needed anymore
     168           0 :     aTmpLst.clear();
     169           0 :     return pSrtLst->size();
     170             : }
     171             : 
     172             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10