LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/fields - fldlst.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 84 0.0 %
Date: 2012-12-27 Functions: 0 9 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             : 
      21             : #include "switerator.hxx"
      22             : #include "editsh.hxx"
      23             : #include "doc.hxx"
      24             : #include <docary.hxx>
      25             : #include <fmtfld.hxx>
      26             : #include <txtfld.hxx>
      27             : #include "edimp.hxx"
      28             : #include "expfld.hxx"
      29             : #include "pam.hxx"
      30             : #include "docfld.hxx"
      31             : #include "ndtxt.hxx"
      32             : 
      33             : 
      34             : /*--------------------------------------------------------------------
      35             :     Beschreibung: Sortieren der Input-Eintraege
      36             :  --------------------------------------------------------------------*/
      37             : 
      38           0 : SwInputFieldList::SwInputFieldList( SwEditShell* pShell, sal_Bool bBuildTmpLst )
      39           0 :     : pSh(pShell)
      40             : {
      41             :     // Hier die Liste aller Eingabefelder sortiert erstellen
      42           0 :     pSrtLst = new _SetGetExpFlds();
      43             : 
      44           0 :     const SwFldTypes& rFldTypes = *pSh->GetDoc()->GetFldTypes();
      45           0 :     const sal_uInt16 nSize = rFldTypes.size();
      46             : 
      47             :     // Alle Typen abklappern
      48             : 
      49           0 :     for(sal_uInt16 i=0; i < nSize; ++i)
      50             :     {
      51           0 :         SwFieldType* pFldType = (SwFieldType*)rFldTypes[ i ];
      52           0 :         sal_uInt16 nType = pFldType->Which();
      53             : 
      54           0 :         if( RES_SETEXPFLD == nType || RES_INPUTFLD == nType || RES_DROPDOWN == nType )
      55             :         {
      56           0 :             SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
      57           0 :             for( SwFmtFld* pFld = aIter.First(); pFld; pFld = aIter.Next() )
      58             :             {
      59           0 :                 const SwTxtFld* pTxtFld = pFld->GetTxtFld();
      60             : 
      61             :                 //  nur InputFields und interaktive SetExpFlds bearbeiten
      62             :                 //  and DropDown fields
      63           0 :                 if( !pTxtFld || ( RES_SETEXPFLD == nType &&
      64           0 :                     !((SwSetExpField*)pFld->GetFld())->GetInputFlag()))
      65           0 :                     continue;
      66             : 
      67           0 :                 const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode();
      68           0 :                 if( rTxtNode.GetNodes().IsDocNodes() )
      69             :                 {
      70           0 :                     if( bBuildTmpLst )
      71             :                     {
      72           0 :                         aTmpLst.insert( pTxtFld );
      73             :                     }
      74             :                     else
      75             :                     {
      76           0 :                         SwNodeIndex aIdx( rTxtNode );
      77           0 :                         _SetGetExpFld* pNew = new _SetGetExpFld(aIdx, pTxtFld );
      78           0 :                         pSrtLst->insert( pNew );
      79             :                     }
      80             :                 }
      81           0 :             }
      82             :         }
      83             :     }
      84           0 : }
      85             : 
      86           0 : SwInputFieldList::~SwInputFieldList()
      87             : {
      88           0 :     delete pSrtLst;
      89           0 : }
      90             : 
      91             : /*--------------------------------------------------------------------
      92             :     Beschreibung: Felder aus der Liste in sortierter Reihenfolge
      93             :  --------------------------------------------------------------------*/
      94             : 
      95           0 : sal_uInt16 SwInputFieldList::Count() const
      96             : {
      97           0 :     return pSrtLst->size();
      98             : }
      99             : 
     100             : 
     101           0 : SwField* SwInputFieldList::GetField(sal_uInt16 nId)
     102             : {
     103           0 :     const SwTxtFld* pTxtFld = (*pSrtLst)[ nId ]->GetFld();
     104             :     OSL_ENSURE( pTxtFld, "kein TextFld" );
     105           0 :     return (SwField*)pTxtFld->GetFld().GetFld();
     106             : }
     107             : 
     108             : /*--------------------------------------------------------------------
     109             :     Beschreibung: Cursor sichern
     110             :  --------------------------------------------------------------------*/
     111             : 
     112           0 : void SwInputFieldList::PushCrsr()
     113             : {
     114           0 :     pSh->Push();
     115           0 :     pSh->ClearMark();
     116           0 : }
     117             : 
     118           0 : void SwInputFieldList::PopCrsr()
     119             : {
     120           0 :     pSh->Pop(sal_False);
     121           0 : }
     122             : 
     123             : /*--------------------------------------------------------------------
     124             :     Beschreibung: Position eines Feldes ansteuern
     125             :  --------------------------------------------------------------------*/
     126             : 
     127           0 : void SwInputFieldList::GotoFieldPos(sal_uInt16 nId)
     128             : {
     129           0 :     pSh->StartAllAction();
     130           0 :     (*pSrtLst)[ nId ]->GetPosOfContent( *pSh->GetCrsr()->GetPoint() );
     131           0 :     pSh->EndAllAction();
     132           0 : }
     133             : 
     134             :     // vergleiche TmpLst mit akt Feldern. Alle neue kommen in die SortLst
     135             :     // damit sie geupdatet werden koennen. Returnt die Anzahl.
     136             :     // (Fuer Textbausteine: nur seine Input-Felder aktualisieren)
     137           0 : sal_uInt16 SwInputFieldList::BuildSortLst()
     138             : {
     139           0 :     const SwFldTypes& rFldTypes = *pSh->GetDoc()->GetFldTypes();
     140           0 :     sal_uInt16 nSize = rFldTypes.size();
     141             : 
     142             :     // Alle Typen abklappern
     143             : 
     144           0 :     for( sal_uInt16 i = 0; i < nSize; ++i )
     145             :     {
     146           0 :         SwFieldType* pFldType = (SwFieldType*)rFldTypes[ i ];
     147           0 :         sal_uInt16 nType = pFldType->Which();
     148             : 
     149           0 :         if( RES_SETEXPFLD == nType || RES_INPUTFLD == nType )
     150             :         {
     151           0 :             SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
     152           0 :             for( SwFmtFld* pFld = aIter.First(); pFld; pFld = aIter.Next() )
     153             :             {
     154           0 :                 const SwTxtFld* pTxtFld = pFld->GetTxtFld();
     155             : 
     156             :                 //  nur InputFields und interaktive SetExpFlds bearbeiten
     157           0 :                 if( !pTxtFld || ( RES_SETEXPFLD == nType &&
     158           0 :                     !((SwSetExpField*)pFld->GetFld())->GetInputFlag()))
     159           0 :                     continue;
     160             : 
     161           0 :                 const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode();
     162           0 :                 if( rTxtNode.GetNodes().IsDocNodes() )
     163             :                 {
     164             :                     // nicht in der TempListe vorhanden, also in die SortListe
     165             :                     // aufnehemen
     166           0 :                     std::set<const SwTxtFld*>::iterator it = aTmpLst.find( pTxtFld );
     167           0 :                     if( aTmpLst.end() == it )
     168             :                     {
     169           0 :                         SwNodeIndex aIdx( rTxtNode );
     170           0 :                         _SetGetExpFld* pNew = new _SetGetExpFld(aIdx, pTxtFld );
     171           0 :                         pSrtLst->insert( pNew );
     172             :                     }
     173             :                     else
     174           0 :                         aTmpLst.erase( it );
     175             :                 }
     176           0 :             }
     177             :         }
     178             :     }
     179             : 
     180             :     // die Pointer werden nicht mehr gebraucht
     181           0 :     aTmpLst.clear();
     182           0 :     return pSrtLst->size();
     183             : }
     184             : 
     185             : /*--------------------------------------------------------------------
     186             :     Beschreibung: Alle Felder auáerhalb von Selektionen aus Liste entfernen
     187             :  --------------------------------------------------------------------*/
     188             : 
     189           0 : void SwInputFieldList::RemoveUnselectedFlds()
     190             : {
     191           0 :     _SetGetExpFlds* pNewLst = new _SetGetExpFlds();
     192             : 
     193           0 :     FOREACHPAM_START(pSh)
     194             :     {
     195           0 :         for (sal_uInt16 i = 0; i < Count();)
     196             :         {
     197           0 :             _SetGetExpFld* pFld = (*pSrtLst)[i];
     198           0 :             SwPosition aPos(*PCURCRSR->GetPoint());
     199             : 
     200           0 :             pFld->GetPos( aPos );
     201             : 
     202           0 :             if (aPos >= *PCURCRSR->Start() && aPos < *PCURCRSR->End())
     203             :             {
     204             :                 // Feld innerhalb der Selektion
     205           0 :                 pNewLst->insert( (*pSrtLst)[i] );
     206           0 :                 pSrtLst->erase(i);
     207             :             }
     208             :             else
     209           0 :                 i++;
     210           0 :         }
     211             :     }
     212           0 :     FOREACHPAM_END()
     213             : 
     214           0 :     delete pSrtLst;
     215           0 :     pSrtLst = pNewLst;
     216           0 : }
     217             : 
     218             : 
     219             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10