LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/text - wrong.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 308 0.0 %
Date: 2012-12-27 Functions: 0 24 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 "swtypes.hxx"
      21             : #include "txttypes.hxx"
      22             : 
      23             : #include "SwGrammarMarkUp.hxx"
      24             : 
      25             : 
      26             : /*************************************************************************
      27             :  * SwWrongList::SwWrongList()
      28             :  *************************************************************************/
      29           0 : SwWrongList::SwWrongList( WrongListType eType ) :
      30             :     meType       (eType),
      31             :     nBeginInvalid(STRING_LEN),  // everything correct... (the invalid area starts beyond the string)
      32           0 :     nEndInvalid  (STRING_LEN)
      33             : {
      34           0 :     maList.reserve( 5 );
      35           0 : }
      36             : 
      37           0 : SwWrongList::~SwWrongList()
      38             : {
      39           0 :     ClearList();
      40           0 : }
      41             : 
      42             : /*************************************************************************
      43             :  * SwWrongList* SwWrongList::Clone()
      44             :  *************************************************************************/
      45             : 
      46           0 : SwWrongList* SwWrongList::Clone()
      47             : {
      48           0 :     SwWrongList* pClone = new SwWrongList( meType );
      49           0 :     pClone->CopyFrom( *this );
      50           0 :     return pClone;
      51             : }
      52             : 
      53             : /*************************************************************************
      54             :  * void SwWrongList::CopyFrom( const SwWrongList& rCopy )
      55             :  *************************************************************************/
      56             : 
      57           0 : void SwWrongList::CopyFrom( const SwWrongList& rCopy )
      58             : {
      59           0 :     maList = rCopy.maList;
      60           0 :     meType = rCopy.meType;
      61           0 :     nBeginInvalid = rCopy.nBeginInvalid;
      62           0 :     nEndInvalid = rCopy.nEndInvalid;
      63           0 :     for( size_t i = 0; i < maList.size(); ++i )
      64             :     {
      65           0 :         if( maList[i].mpSubList )
      66           0 :             maList[i].mpSubList = maList[i].mpSubList->Clone();
      67             :     }
      68           0 : }
      69             : 
      70             : /*************************************************************************
      71             :  * SwWrongList::ClearList()
      72             :  *************************************************************************/
      73           0 : void SwWrongList::ClearList()
      74             : {
      75           0 :     for ( size_t i = 0; i < maList.size(); ++i)
      76             :     {
      77           0 :         if (maList[i].mpSubList)
      78           0 :             delete maList[i].mpSubList;
      79           0 :         maList[i].mpSubList = NULL;
      80             :     }
      81           0 :     maList.clear();
      82           0 : }
      83             : 
      84             : /*************************************************************************
      85             :  * sal_Bool SwWrongList::InWrongWord() gibt den Anfang und die Laenge des
      86             :  * Wortes zurueck, wenn es als falsch markiert ist.
      87             :  *************************************************************************/
      88           0 : sal_Bool SwWrongList::InWrongWord( xub_StrLen &rChk, xub_StrLen &rLn ) const
      89             : {
      90           0 :     MSHORT nPos = GetWrongPos( rChk );
      91             :     xub_StrLen nWrPos;
      92           0 :     if( nPos < Count() && ( nWrPos = Pos( nPos ) ) <= rChk )
      93             :     {
      94           0 :         rLn = Len( nPos );
      95           0 :         if( nWrPos + rLn <= rChk )
      96           0 :             return sal_False;
      97           0 :         rChk = nWrPos;
      98           0 :         return sal_True;
      99             :     }
     100           0 :     return sal_False;
     101             : }
     102             : 
     103             : /*************************************************************************
     104             :  * sal_Bool SwWrongList::Check() liefert den ersten falschen Bereich
     105             :  *************************************************************************/
     106           0 : sal_Bool SwWrongList::Check( xub_StrLen &rChk, xub_StrLen &rLn ) const
     107             : {
     108           0 :     MSHORT nPos = GetWrongPos( rChk );
     109           0 :     rLn = rLn + rChk;
     110             :     xub_StrLen nWrPos;
     111             : 
     112           0 :     if( nPos == Count() )
     113           0 :         return sal_False;
     114             : 
     115           0 :     xub_StrLen nEnd = Len( nPos );
     116           0 :     nEnd = nEnd + ( nWrPos = Pos( nPos ) );
     117           0 :     if( nEnd == rChk )
     118             :     {
     119           0 :         ++nPos;
     120           0 :         if( nPos == Count() )
     121           0 :             return sal_False;
     122             :         else
     123             :         {
     124           0 :             nEnd = Len( nPos );
     125           0 :             nEnd = nEnd + ( nWrPos = Pos( nPos ) );
     126             :         }
     127             :     }
     128           0 :     if( nEnd > rChk && nWrPos < rLn )
     129             :     {
     130           0 :         if( nWrPos > rChk )
     131           0 :             rChk = nWrPos;
     132           0 :         if( nEnd < rLn )
     133           0 :             rLn = nEnd;
     134           0 :         rLn = rLn - rChk;
     135           0 :         return 0 != rLn;
     136             :     }
     137           0 :     return sal_False;
     138             : }
     139             : 
     140             : /*************************************************************************
     141             :  * xub_StrLen SwWrongList::NextWrong() liefert die naechste Fehlerposition
     142             :  *************************************************************************/
     143             : 
     144           0 : xub_StrLen SwWrongList::NextWrong( xub_StrLen nChk ) const
     145             : {
     146             :     xub_StrLen nRet;
     147           0 :     xub_StrLen nPos = GetWrongPos( nChk );
     148           0 :     if( nPos < Count() )
     149             :     {
     150           0 :         nRet = Pos( nPos );
     151           0 :         if( nRet < nChk && nRet + Len( nPos ) <= nChk )
     152             :         {
     153           0 :             if( ++nPos < Count() )
     154           0 :                 nRet = Pos( nPos );
     155             :             else
     156           0 :                 nRet = STRING_LEN;
     157             :         }
     158             :     }
     159             :     else
     160           0 :         nRet = STRING_LEN;
     161           0 :     if( nRet > GetBeginInv() && nChk < GetEndInv() )
     162           0 :         nRet = nChk > GetBeginInv() ? nChk : GetBeginInv();
     163           0 :     return nRet;
     164             : }
     165             : 
     166             : /*************************************************************************
     167             :  *                 MSHORT SwWrongList::GetWrongPos( xub_StrLen nValue )
     168             :  *  sucht die erste Position im Array, die groessergleich nValue ist,
     169             :  * dies kann natuerlich auch hinter dem letzten Element sein!
     170             :  *************************************************************************/
     171             : 
     172           0 : MSHORT SwWrongList::GetWrongPos( xub_StrLen nValue ) const
     173             : {
     174           0 :     MSHORT nOben = Count(), nUnten = 0;
     175             : 
     176           0 :     if( nOben > 0 )
     177             :     {
     178             :         // For smart tag lists, we may not use a binary search. We return the
     179             :         // position of the first smart tag which coveres nValue
     180           0 :         if ( !maList[0].maType.isEmpty() || maList[0].mpSubList )
     181             :         {
     182           0 :             std::vector<SwWrongArea>::const_iterator aIter = maList.begin();
     183           0 :             while ( aIter != maList.end() )
     184             :             {
     185           0 :                 const xub_StrLen nSTPos = (*aIter).mnPos;
     186           0 :                 const xub_StrLen nSTLen = (*aIter).mnLen;
     187           0 :                 if ( nSTPos <= nValue && nValue < nSTPos + nSTLen )
     188           0 :                     break;
     189           0 :                 else if ( nSTPos > nValue )
     190           0 :                     break;
     191             : 
     192           0 :                 ++aIter;
     193           0 :                 ++nUnten;
     194             :             }
     195           0 :             return nUnten;
     196             :         }
     197             : 
     198           0 :         --nOben;
     199           0 :         MSHORT nMitte = 0;
     200           0 :         while( nUnten <= nOben )
     201             :         {
     202           0 :             nMitte = nUnten + ( nOben - nUnten ) / 2;
     203           0 :             xub_StrLen nTmp = Pos( nMitte );
     204           0 :             if( nTmp == nValue )
     205             :             {
     206           0 :                 nUnten = nMitte;
     207           0 :                 break;
     208             :             }
     209           0 :             else if( nTmp < nValue )
     210             :             {
     211           0 :                 if( nTmp + Len( nMitte ) >= nValue )
     212             :                 {
     213           0 :                     nUnten = nMitte;
     214           0 :                     break;
     215             :                 }
     216           0 :                 nUnten = nMitte + 1;
     217             :             }
     218           0 :             else if( nMitte == 0 )
     219             :             {
     220           0 :                 break;
     221             :             }
     222             :             else
     223           0 :                 nOben = nMitte - 1;
     224             :         }
     225             :     }
     226             : 
     227             :     // nUnten now points to an index i into the wrong list which
     228             :     // 1. nValue is inside [ Area[i].pos, Area[i].pos + Area[i].len ] (inkl!!!)
     229             :     // 2. nValue < Area[i].pos
     230             : 
     231           0 :     return nUnten;
     232             : }
     233             : 
     234             : /*************************************************************************
     235             :  *                 void SwWrongList::_Invalidate()
     236             :  *************************************************************************/
     237             : 
     238           0 : void SwWrongList::_Invalidate( xub_StrLen nBegin, xub_StrLen nEnd )
     239             : {
     240           0 :     if ( nBegin < GetBeginInv() )
     241           0 :         nBeginInvalid = nBegin;
     242           0 :     if ( nEnd > GetEndInv() )
     243           0 :         nEndInvalid = nEnd;
     244           0 : }
     245             : 
     246           0 : void SwWrongList::SetInvalid( xub_StrLen nBegin, xub_StrLen nEnd )
     247             : {
     248           0 :     nBeginInvalid = nBegin;
     249           0 :     nEndInvalid = nEnd;
     250           0 : }
     251             : 
     252             : 
     253             : /*************************************************************************
     254             :  *                      SwWrongList::Move( xub_StrLen nPos, long nDiff )
     255             :  *  veraendert alle Positionen ab nPos um den angegebenen Wert,
     256             :  *  wird nach Einfuegen oder Loeschen von Buchstaben benoetigt.
     257             :  *************************************************************************/
     258             : 
     259           0 : void SwWrongList::Move( xub_StrLen nPos, long nDiff )
     260             : {
     261           0 :     MSHORT i = GetWrongPos( nPos );
     262           0 :     if( nDiff < 0 )
     263             :     {
     264           0 :         xub_StrLen nEnd = nPos + xub_StrLen( -nDiff );
     265           0 :         MSHORT nLst = i;
     266             :         xub_StrLen nWrPos;
     267             :         xub_StrLen nWrLen;
     268           0 :         bool bJump = false;
     269           0 :         while( nLst < Count() && Pos( nLst ) < nEnd )
     270           0 :             ++nLst;
     271           0 :         if( nLst > i && ( nWrPos = Pos( nLst - 1 ) ) <= nPos )
     272             :         {
     273           0 :             nWrLen = Len( nLst - 1 );
     274             :             // calculate new length of word
     275             :             nWrLen = ( nEnd > nWrPos + nWrLen ) ?
     276             :                        nPos - nWrPos :
     277           0 :                        static_cast<xub_StrLen>(nWrLen + nDiff);
     278           0 :             if( nWrLen )
     279             :             {
     280           0 :                 maList[--nLst].mnLen = nWrLen;
     281           0 :                 bJump = true;
     282             :             }
     283             :         }
     284           0 :         Remove( i, nLst - i );
     285             : 
     286           0 :         if ( bJump )
     287           0 :             ++i;
     288           0 :         if( STRING_LEN == GetBeginInv() )
     289           0 :             SetInvalid( nPos ? nPos - 1 : nPos, nPos + 1 );
     290             :         else
     291             :         {
     292           0 :             ShiftLeft( nBeginInvalid, nPos, nEnd );
     293           0 :             ShiftLeft( nEndInvalid, nPos, nEnd );
     294           0 :             _Invalidate( nPos ? nPos - 1 : nPos, nPos + 1 );
     295             :         }
     296             :     }
     297             :     else
     298             :     {
     299             :         xub_StrLen nWrPos;
     300           0 :         xub_StrLen nEnd = nPos + xub_StrLen( nDiff );
     301           0 :         if( STRING_LEN != GetBeginInv() )
     302             :         {
     303           0 :             if( nBeginInvalid > nPos )
     304           0 :                 nBeginInvalid = nBeginInvalid + xub_StrLen( nDiff );
     305           0 :             if( nEndInvalid >= nPos )
     306           0 :                 nEndInvalid = nEndInvalid + xub_StrLen( nDiff );
     307             :         }
     308             :         // Wenn wir mitten in einem falschen Wort stehen, muss vom Wortanfang
     309             :         // invalidiert werden.
     310           0 :         if( i < Count() && nPos >= ( nWrPos = Pos( i ) ) )
     311             :         {
     312           0 :             Invalidate( nWrPos, nEnd );
     313           0 :             xub_StrLen nWrLen = Len( i ) + xub_StrLen( nDiff );
     314           0 :             maList[i++].mnLen = nWrLen;
     315           0 :             nWrLen = nWrLen + nWrPos;
     316           0 :             Invalidate( nWrPos, nWrLen );
     317             :         }
     318             :         else
     319           0 :             Invalidate( nPos, nEnd );
     320             :     }
     321           0 :     while( i < Count() )
     322             :     {
     323           0 :         const xub_StrLen nTmp = static_cast<xub_StrLen>(nDiff + maList[i].mnPos);
     324           0 :         maList[i++].mnPos = nTmp;
     325             :     }
     326           0 : }
     327             : 
     328             : /*************************************************************************
     329             :  *                      SwWrongList::Fresh
     330             :  *
     331             :  * For a given range [nPos, nPos + nLen[ and an index nIndex, this function
     332             :  * basically counts the number of SwWrongArea entries starting with nIndex
     333             :  * up to nPos + nLen. All these entries are removed.
     334             :  *************************************************************************/
     335           0 : sal_Bool SwWrongList::Fresh( xub_StrLen &rStart, xub_StrLen &rEnd, xub_StrLen nPos,
     336             :                              xub_StrLen nLen, MSHORT nIndex, xub_StrLen nCursorPos )
     337             : {
     338             :     // length of word must be greater than 0 and cursor position must be outside the word
     339           0 :     sal_Bool bRet = nLen && ( nCursorPos > nPos + nLen || nCursorPos < nPos );
     340             : 
     341           0 :     xub_StrLen nWrPos = 0;
     342           0 :     xub_StrLen nWrEnd = rEnd;
     343           0 :     MSHORT nCnt = nIndex;
     344           0 :     if( nCnt < Count() && ( nWrPos = Pos( nIndex ) ) < nPos )
     345             :     {
     346           0 :         if( rStart > nWrPos )
     347           0 :             rStart = nWrPos;
     348             :     }
     349             : 
     350           0 :     while( nCnt < Count() && ( nWrPos = Pos( nCnt ) ) < nPos )
     351           0 :         nWrEnd = nWrPos + Len( nCnt++ );
     352             : 
     353           0 :     if( nCnt < Count() && nWrPos == nPos && Len( nCnt ) == nLen )
     354             :     {
     355           0 :         ++nCnt;
     356           0 :         bRet = sal_True;
     357             :     }
     358             :     else
     359             :     {
     360           0 :         if( bRet )
     361             :         {
     362           0 :             if( rStart > nPos )
     363           0 :                 rStart = nPos;
     364           0 :             nWrEnd = nPos + nLen;
     365             :         }
     366             :     }
     367             : 
     368           0 :     nPos = nPos + nLen;
     369             : 
     370           0 :     if( nCnt < Count() && ( nWrPos = Pos( nCnt ) ) < nPos )
     371             :     {
     372           0 :         if( rStart > nWrPos )
     373           0 :             rStart = nWrPos;
     374             :     }
     375             : 
     376           0 :     while( nCnt < Count() && ( nWrPos = Pos( nCnt ) ) < nPos )
     377           0 :         nWrEnd = nWrPos + Len( nCnt++ );
     378             : 
     379           0 :     if( rEnd < nWrEnd )
     380           0 :         rEnd = nWrEnd;
     381             : 
     382           0 :     Remove( nIndex, nCnt - nIndex );
     383             : 
     384           0 :     return bRet;
     385             : }
     386             : 
     387           0 : void SwWrongList::Invalidate( xub_StrLen nBegin, xub_StrLen nEnd )
     388             : {
     389           0 :     if (STRING_LEN == GetBeginInv())
     390           0 :         SetInvalid( nBegin, nEnd );
     391             :     else
     392           0 :         _Invalidate( nBegin, nEnd );
     393           0 : }
     394             : 
     395           0 : sal_Bool SwWrongList::InvalidateWrong( )
     396             : {
     397           0 :     if( Count() )
     398             :     {
     399           0 :         xub_StrLen nFirst = Pos( 0 );
     400           0 :         xub_StrLen nLast = Pos( Count() - 1 ) + Len( Count() - 1 );
     401           0 :         Invalidate( nFirst, nLast );
     402           0 :         return sal_True;
     403             :     }
     404             :     else
     405           0 :         return sal_False;
     406             : }
     407             : 
     408           0 : SwWrongList* SwWrongList::SplitList( xub_StrLen nSplitPos )
     409             : {
     410           0 :     SwWrongList *pRet = NULL;
     411           0 :     MSHORT nLst = 0;
     412             :     xub_StrLen nWrPos;
     413             :     xub_StrLen nWrLen;
     414           0 :     while( nLst < Count() && Pos( nLst ) < nSplitPos )
     415           0 :         ++nLst;
     416           0 :     if( nLst && ( nWrPos = Pos( nLst - 1 ) )
     417           0 :         + ( nWrLen = Len( nLst - 1 ) ) > nSplitPos )
     418             :     {
     419           0 :         nWrLen += nWrPos - nSplitPos;
     420           0 :         maList[--nLst].mnPos = nSplitPos;
     421           0 :         maList[nLst].mnLen = nWrLen;
     422             :     }
     423           0 :     if( nLst )
     424             :     {
     425           0 :         if( WRONGLIST_GRAMMAR == GetWrongListType() )
     426           0 :             pRet = new SwGrammarMarkUp();
     427             :         else
     428           0 :             pRet = new SwWrongList( GetWrongListType() );
     429           0 :         pRet->Insert(0, maList.begin(), ( nLst >= maList.size() ? maList.end() : maList.begin() + nLst ) );
     430           0 :         pRet->SetInvalid( GetBeginInv(), GetEndInv() );
     431           0 :         pRet->_Invalidate( nSplitPos ? nSplitPos - 1 : nSplitPos, nSplitPos );
     432           0 :         Remove( 0, nLst );
     433             :     }
     434           0 :     if( STRING_LEN == GetBeginInv() )
     435           0 :         SetInvalid( 0, 1 );
     436             :     else
     437             :     {
     438           0 :         ShiftLeft( nBeginInvalid, 0, nSplitPos );
     439           0 :         ShiftLeft( nEndInvalid, 0, nSplitPos );
     440           0 :         _Invalidate( 0, 1 );
     441             :     }
     442           0 :     nLst = 0;
     443           0 :     while( nLst < Count() )
     444             :     {
     445           0 :         nWrPos = maList[nLst].mnPos - nSplitPos;
     446           0 :         maList[nLst++].mnPos = nWrPos;
     447             :     }
     448           0 :     return pRet;
     449             : }
     450             : 
     451           0 : void SwWrongList::JoinList( SwWrongList* pNext, xub_StrLen nInsertPos )
     452             : {
     453             :     if (pNext)
     454             :     {
     455             :         OSL_ENSURE( GetWrongListType() == pNext->GetWrongListType(), "type mismatch with next list" );
     456             :     }
     457           0 :     if( pNext )
     458             :     {
     459           0 :         sal_uInt16 nCnt = Count();
     460           0 :         pNext->Move( 0, nInsertPos );
     461           0 :         Insert(nCnt, pNext->maList.begin(), pNext->maList.end());
     462             : 
     463           0 :         Invalidate( pNext->GetBeginInv(), pNext->GetEndInv() );
     464           0 :         if( nCnt && Count() > nCnt )
     465             :         {
     466           0 :             xub_StrLen nWrPos = Pos( nCnt );
     467           0 :             xub_StrLen nWrLen = Len( nCnt );
     468           0 :             if( !nWrPos )
     469             :             {
     470           0 :                 nWrPos = nWrPos + nInsertPos;
     471           0 :                 nWrLen = nWrLen - nInsertPos;
     472           0 :                 maList[nCnt].mnPos = nWrPos;
     473           0 :                 maList[nCnt].mnLen = nWrLen;
     474             :             }
     475           0 :             if( nWrPos == Pos( nCnt - 1 ) + Len( nCnt - 1 ) )
     476             :             {
     477           0 :                 nWrLen = nWrLen + Len( nCnt - 1 );
     478           0 :                 maList[nCnt - 1].mnLen = nWrLen;
     479           0 :                 Remove( nCnt, 1 );
     480             :             }
     481             :         }
     482             :     }
     483           0 :     Invalidate( nInsertPos ? nInsertPos - 1 : nInsertPos, nInsertPos + 1 );
     484           0 : }
     485             : 
     486             : 
     487           0 : void SwWrongList::InsertSubList( xub_StrLen nNewPos, xub_StrLen nNewLen, sal_uInt16 nWhere, SwWrongList* pSubList )
     488             : {
     489             :     if (pSubList)
     490             :     {
     491             :         OSL_ENSURE( GetWrongListType() == pSubList->GetWrongListType(), "type mismatch with sub list" );
     492             :     }
     493           0 :     std::vector<SwWrongArea>::iterator i = maList.begin();
     494           0 :     if ( nWhere >= maList.size() )
     495           0 :         i = maList.end(); // robust
     496             :     else
     497           0 :         i += nWhere;
     498           0 :     maList.insert(i, SwWrongArea( OUString(), 0, nNewPos, nNewLen, pSubList ) );
     499           0 : }
     500             : 
     501             : 
     502             : // New functions: Necessary because SwWrongList has been changed to use std::vector
     503           0 : void SwWrongList::Insert(sal_uInt16 nWhere, std::vector<SwWrongArea>::iterator startPos, std::vector<SwWrongArea>::iterator endPos)
     504             : {
     505           0 :     std::vector<SwWrongArea>::iterator i = maList.begin();
     506           0 :     if ( nWhere >= maList.size() )
     507           0 :         i = maList.end(); // robust
     508             :     else
     509           0 :         i += nWhere;
     510           0 :     maList.insert(i, startPos, endPos); // insert [startPos, endPos[ before i
     511             : 
     512             :     // ownership of the sublist is passed to maList, therefore we have to set the
     513             :     // pSubList-Pointers to 0
     514           0 :     while ( startPos != endPos )
     515             :     {
     516           0 :         (*startPos).mpSubList = 0;
     517           0 :         ++startPos;
     518             :     }
     519           0 : }
     520             : 
     521           0 : void SwWrongList::Remove(sal_uInt16 nIdx, sal_uInt16 nLen )
     522             : {
     523           0 :     if ( nIdx >= maList.size() ) return;
     524           0 :     std::vector<SwWrongArea>::iterator i1 = maList.begin();
     525           0 :     i1 += nIdx;
     526             : 
     527           0 :     std::vector<SwWrongArea>::iterator i2 = i1;
     528           0 :     if ( nIdx + nLen >= static_cast<sal_uInt16>(maList.size()) )
     529           0 :         i2 = maList.end(); // robust
     530             :     else
     531           0 :         i2 += nLen;
     532             : 
     533           0 :     std::vector<SwWrongArea>::iterator iLoop = i1;
     534           0 :     while ( iLoop != i2 )
     535             :     {
     536           0 :         if ( (*iLoop).mpSubList )
     537           0 :             delete (*iLoop).mpSubList;
     538           0 :         ++iLoop;
     539             :     }
     540             : 
     541             : #if OSL_DEBUG_LEVEL > 0
     542             :     const int nOldSize = Count();
     543             :     (void) nOldSize;
     544             : #endif
     545             : 
     546           0 :     maList.erase(i1, i2);
     547             : 
     548             : #if OSL_DEBUG_LEVEL > 0
     549             :     OSL_ENSURE( Count() + nLen == nOldSize, "SwWrongList::Remove() trouble" );
     550             : #endif
     551             : }
     552             : 
     553           0 : void SwWrongList::RemoveEntry( xub_StrLen nBegin, xub_StrLen nEnd ) {
     554           0 :     sal_uInt16 nDelPos = 0;
     555           0 :     sal_uInt16 nDel = 0;
     556           0 :     std::vector<SwWrongArea>::iterator aIter = maList.begin();
     557           0 :     while( aIter != maList.end() && (*aIter).mnPos < nBegin )
     558             :     {
     559           0 :         ++aIter;
     560           0 :         ++nDelPos;
     561             :     }
     562           0 :     if( WRONGLIST_GRAMMAR == GetWrongListType() )
     563             :     {
     564           0 :         while( aIter != maList.end() && nBegin < nEnd && nEnd > (*aIter).mnPos )
     565             :         {
     566           0 :             ++aIter;
     567           0 :             ++nDel;
     568             :         }
     569             :     }
     570             :     else
     571             :     {
     572           0 :         while( aIter != maList.end() && nBegin == (*aIter).mnPos && nEnd == (*aIter).mnPos +(*aIter).mnLen )
     573             :         {
     574           0 :             ++aIter;
     575           0 :             ++nDel;
     576             :         }
     577             :     }
     578           0 :     if( nDel )
     579           0 :         Remove( nDelPos, nDel );
     580           0 : }
     581             : 
     582           0 : bool SwWrongList::LookForEntry( xub_StrLen nBegin, xub_StrLen nEnd ) {
     583           0 :     std::vector<SwWrongArea>::iterator aIter = maList.begin();
     584           0 :     while( aIter != maList.end() && (*aIter).mnPos < nBegin )
     585           0 :         ++aIter;
     586           0 :     if( aIter != maList.end() && nBegin == (*aIter).mnPos && nEnd == (*aIter).mnPos +(*aIter).mnLen )
     587           0 :         return true;
     588           0 :     return false;
     589             : }
     590             : 
     591           0 : void SwWrongList::Insert( const OUString& rType,
     592             :                           com::sun::star::uno::Reference< com::sun::star::container::XStringKeyMap > xPropertyBag,
     593             :                           xub_StrLen nNewPos, xub_StrLen nNewLen )
     594             : {
     595           0 :     std::vector<SwWrongArea>::iterator aIter = maList.begin();
     596             : 
     597           0 :     while ( aIter != maList.end() )
     598             :     {
     599           0 :         const xub_StrLen nSTPos = (*aIter).mnPos;
     600             : 
     601           0 :         if ( nNewPos < nSTPos )
     602             :         {
     603             :             // insert at current position
     604           0 :             break;
     605             :         }
     606           0 :         else if ( nNewPos == nSTPos )
     607             :         {
     608           0 :             while ( aIter != maList.end() && (*aIter).mnPos == nSTPos )
     609             :             {
     610           0 :                 const xub_StrLen nSTLen = (*aIter).mnLen;
     611             : 
     612           0 :                 if ( nNewLen < nSTLen )
     613             :                 {
     614             :                     // insert at current position
     615           0 :                     break;
     616             :                 }
     617             : 
     618           0 :                 ++aIter;
     619             :             }
     620             : 
     621           0 :             break;
     622             :         }
     623             : 
     624           0 :         ++aIter;
     625             :     }
     626             : 
     627           0 :     maList.insert(aIter, SwWrongArea( rType, xPropertyBag, nNewPos, nNewLen, 0 ) );
     628           0 : }
     629             : 
     630             : 
     631             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10