LCOV - code coverage report
Current view: top level - sw/source/core/text - SwGrammarMarkUp.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 92 0.0 %
Date: 2014-04-14 Functions: 0 11 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 "SwGrammarMarkUp.hxx"
      21             : 
      22           0 : SwGrammarMarkUp::~SwGrammarMarkUp()
      23             : {
      24           0 : }
      25             : 
      26           0 : SwWrongList* SwGrammarMarkUp::Clone()
      27             : {
      28           0 :     SwWrongList* pClone = new SwGrammarMarkUp();
      29           0 :     pClone->CopyFrom( *this );
      30           0 :     return pClone;
      31             : }
      32             : 
      33           0 : void SwGrammarMarkUp::CopyFrom( const SwWrongList& rCopy )
      34             : {
      35           0 :     maSentence = ((const SwGrammarMarkUp&)rCopy).maSentence;
      36           0 :     SwWrongList::CopyFrom( rCopy );
      37           0 : }
      38             : 
      39           0 : void SwGrammarMarkUp::MoveGrammar( sal_Int32 nPos, sal_Int32 nDiff )
      40             : {
      41           0 :     Move( nPos, nDiff );
      42           0 :     if( !maSentence.size() )
      43           0 :         return;
      44           0 :     std::vector< sal_Int32 >::iterator pIter = maSentence.begin();
      45           0 :     while( pIter != maSentence.end() && *pIter < nPos )
      46           0 :         ++pIter;
      47           0 :     const sal_Int32 nEnd = nDiff < 0 ? nPos-nDiff : nPos;
      48           0 :     while( pIter != maSentence.end() )
      49             :     {
      50           0 :         if( *pIter >= nEnd )
      51           0 :             *pIter += nDiff;
      52             :         else
      53           0 :             *pIter = nPos;
      54           0 :         ++pIter;
      55             :     }
      56             : }
      57             : 
      58           0 : SwGrammarMarkUp* SwGrammarMarkUp::SplitGrammarList( sal_Int32 nSplitPos )
      59             : {
      60           0 :     SwGrammarMarkUp* pNew = (SwGrammarMarkUp*)SplitList( nSplitPos );
      61           0 :     if( !maSentence.size() )
      62           0 :         return pNew;
      63           0 :     std::vector< sal_Int32 >::iterator pIter = maSentence.begin();
      64           0 :     while( pIter != maSentence.end() && *pIter < nSplitPos )
      65           0 :         ++pIter;
      66           0 :     if( pIter != maSentence.begin() )
      67             :     {
      68           0 :         if( !pNew ) {
      69           0 :             pNew = new SwGrammarMarkUp();
      70           0 :             pNew->SetInvalid( 0, COMPLETE_STRING );
      71             :         }
      72           0 :         pNew->maSentence.insert( pNew->maSentence.begin(), maSentence.begin(), pIter );
      73           0 :         maSentence.erase( maSentence.begin(), pIter );
      74             :     }
      75           0 :     return pNew;
      76             : }
      77             : 
      78           0 : void SwGrammarMarkUp::JoinGrammarList( SwGrammarMarkUp* pNext, sal_Int32 nInsertPos )
      79             : {
      80           0 :     JoinList( pNext, nInsertPos );
      81           0 :     if (pNext)
      82             :     {
      83           0 :         if( !pNext->maSentence.size() )
      84           0 :             return;
      85           0 :         std::vector< sal_Int32 >::iterator pIter = pNext->maSentence.begin();
      86           0 :         while( pIter != pNext->maSentence.end() )
      87             :         {
      88           0 :             *pIter = *pIter + nInsertPos;
      89           0 :             ++pIter;
      90             :         }
      91           0 :         maSentence.insert( maSentence.end(), pNext->maSentence.begin(), pNext->maSentence.end() );
      92             :     }
      93             : }
      94             : 
      95           0 : void SwGrammarMarkUp::ClearGrammarList( sal_Int32 nSentenceEnd )
      96             : {
      97           0 :     if( COMPLETE_STRING == nSentenceEnd ) {
      98           0 :         ClearList();
      99           0 :         maSentence.clear();
     100           0 :         Validate();
     101           0 :     } else if( GetBeginInv() <= nSentenceEnd ) {
     102           0 :         std::vector< sal_Int32 >::iterator pIter = maSentence.begin();
     103           0 :         sal_Int32 nStart = 0;
     104           0 :         while( pIter != maSentence.end() && *pIter < GetBeginInv() )
     105             :         {
     106           0 :             nStart = *pIter;
     107           0 :             ++pIter;
     108             :         }
     109           0 :         std::vector< sal_Int32 >::iterator pLast = pIter;
     110           0 :         while( pLast != maSentence.end() && *pLast <= nSentenceEnd )
     111           0 :             ++pLast;
     112           0 :         maSentence.erase( pIter, pLast );
     113           0 :         RemoveEntry( nStart, nSentenceEnd );
     114           0 :         SetInvalid( nSentenceEnd + 1, COMPLETE_STRING );
     115             :     }
     116           0 : }
     117             : 
     118           0 : void SwGrammarMarkUp::setSentence( sal_Int32 nStart )
     119             : {
     120           0 :     std::vector< sal_Int32 >::iterator pIter = maSentence.begin();
     121           0 :     while( pIter != maSentence.end() && *pIter < nStart )
     122           0 :         ++pIter;
     123           0 :     if( pIter == maSentence.end() || *pIter > nStart )
     124           0 :         maSentence.insert( pIter, nStart );
     125           0 : }
     126             : 
     127           0 : sal_Int32 SwGrammarMarkUp::getSentenceStart( sal_Int32 nPos )
     128             : {
     129           0 :     if( !maSentence.size() )
     130           0 :         return 0;
     131           0 :     std::vector< sal_Int32 >::iterator pIter = maSentence.begin();
     132           0 :     while( pIter != maSentence.end() && *pIter < nPos )
     133           0 :         ++pIter;
     134           0 :     if( pIter != maSentence.begin() )
     135           0 :         --pIter;
     136           0 :     if( pIter != maSentence.end() && *pIter < nPos )
     137           0 :         return *pIter;
     138           0 :     return 0;
     139             : }
     140             : 
     141           0 : sal_Int32 SwGrammarMarkUp::getSentenceEnd( sal_Int32 nPos )
     142             : {
     143           0 :     if( !maSentence.size() )
     144           0 :         return COMPLETE_STRING;
     145           0 :     std::vector< sal_Int32 >::iterator pIter = maSentence.begin();
     146           0 :     while( pIter != maSentence.end() && *pIter <= nPos )
     147           0 :         ++pIter;
     148           0 :     if( pIter != maSentence.end() )
     149           0 :         return *pIter;
     150           0 :     return COMPLETE_STRING;
     151             : }
     152             : 
     153             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10