LCOV - code coverage report
Current view: top level - vcl/source/edit - textdata.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 160 0.0 %
Date: 2014-04-14 Functions: 0 34 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 <vcl/textdata.hxx>
      21             : #include <textdat2.hxx>
      22             : 
      23             : #include <tools/debug.hxx>
      24             : 
      25           0 : TextSelection::TextSelection()
      26             : {
      27           0 : }
      28             : 
      29           0 : TextSelection::TextSelection( const TextPaM& rPaM ) :
      30           0 :     maStartPaM( rPaM ), maEndPaM( rPaM )
      31             : {
      32           0 : }
      33             : 
      34           0 : TextSelection::TextSelection( const TextPaM& rStart, const TextPaM& rEnd ) :
      35           0 :     maStartPaM( rStart ), maEndPaM( rEnd )
      36             : {
      37           0 : }
      38             : 
      39           0 : void TextSelection::Justify()
      40             : {
      41           0 :     if ( maEndPaM < maStartPaM )
      42             :     {
      43           0 :         TextPaM aTemp( maStartPaM );
      44           0 :         maStartPaM = maEndPaM;
      45           0 :         maEndPaM = aTemp;
      46             :     }
      47           0 : }
      48             : 
      49           0 : TETextPortionList::TETextPortionList()
      50             : {
      51           0 : }
      52             : 
      53           0 : TETextPortionList::~TETextPortionList()
      54             : {
      55           0 :     Reset();
      56           0 : }
      57             : 
      58           0 : void TETextPortionList::Reset()
      59             : {
      60           0 :     for ( iterator it = begin(); it != end(); ++it )
      61           0 :         delete *it;
      62           0 :     clear();
      63           0 : }
      64             : 
      65           0 : void TETextPortionList::DeleteFromPortion( sal_uInt16 nDelFrom )
      66             : {
      67             :     DBG_ASSERT( ( nDelFrom < size() ) || ( (nDelFrom == 0) && (size() == 0) ), "DeleteFromPortion: Out of range" );
      68           0 :     for ( iterator it = begin() + nDelFrom; it != end(); ++it )
      69           0 :         delete *it;
      70           0 :     erase( begin() + nDelFrom, end() );
      71           0 : }
      72             : 
      73           0 : sal_uInt16 TETextPortionList::FindPortion( sal_uInt16 nCharPos, sal_uInt16& nPortionStart, bool bPreferStartingPortion )
      74             : {
      75             :     // find left portion at nCharPos at portion border
      76           0 :     sal_uInt16 nTmpPos = 0;
      77           0 :     for ( sal_uInt16 nPortion = 0; nPortion < size(); nPortion++ )
      78             :     {
      79           0 :         TETextPortion* pPortion = operator[]( nPortion );
      80           0 :         nTmpPos = nTmpPos + pPortion->GetLen();
      81           0 :         if ( nTmpPos >= nCharPos )
      82             :         {
      83             :             // take this one if we don't prefer the starting portion, or if it's the last one
      84           0 :             if ( ( nTmpPos != nCharPos ) || !bPreferStartingPortion || ( nPortion == size() - 1 ) )
      85             :             {
      86           0 :                 nPortionStart = nTmpPos - pPortion->GetLen();
      87           0 :                 return nPortion;
      88             :             }
      89             :         }
      90             :     }
      91             :     OSL_FAIL( "FindPortion: Nicht gefunden!" );
      92           0 :     return ( size() - 1 );
      93             : }
      94             : 
      95           0 : TEParaPortion::TEParaPortion( TextNode* pN )
      96             : {
      97           0 :     mpNode = pN;
      98           0 :     mnInvalidPosStart = mnInvalidDiff = 0;
      99           0 :     mbInvalid = true;
     100           0 :     mbSimple = false;
     101           0 : }
     102             : 
     103           0 : TEParaPortion::~TEParaPortion()
     104             : {
     105           0 : }
     106             : 
     107           0 : void TEParaPortion::MarkInvalid( sal_uInt16 nStart, short nDiff )
     108             : {
     109           0 :     if ( !mbInvalid )
     110             :     {
     111           0 :         mnInvalidPosStart = ( nDiff >= 0 ) ? nStart : ( nStart + nDiff );
     112           0 :         mnInvalidDiff = nDiff;
     113             :     }
     114             :     else
     115             :     {
     116             :         // simple consecutive typing
     117           0 :         if ( ( nDiff > 0 ) && ( mnInvalidDiff > 0 ) &&
     118           0 :              ( ( mnInvalidPosStart+mnInvalidDiff ) == nStart ) )
     119             :         {
     120           0 :             mnInvalidDiff = mnInvalidDiff + nDiff;
     121             :         }
     122             :         // simple consecutive deleting
     123           0 :         else if ( ( nDiff < 0 ) && ( mnInvalidDiff < 0 ) && ( mnInvalidPosStart == nStart ) )
     124             :         {
     125           0 :             mnInvalidPosStart = mnInvalidPosStart + nDiff;
     126           0 :             mnInvalidDiff = mnInvalidDiff + nDiff;
     127             :         }
     128             :         else
     129             :         {
     130             :             DBG_ASSERT( ( nDiff >= 0 ) || ( (nStart+nDiff) >= 0 ), "MarkInvalid: Diff out of Range" );
     131           0 :             mnInvalidPosStart = std::min( mnInvalidPosStart, (sal_uInt16) ( (nDiff < 0) ? nStart+nDiff : nDiff ) );
     132           0 :             mnInvalidDiff = 0;
     133           0 :             mbSimple = false;
     134             :         }
     135             :     }
     136             : 
     137           0 :     maWritingDirectionInfos.clear();
     138             : 
     139           0 :     mbInvalid = true;
     140           0 : }
     141             : 
     142           0 : void TEParaPortion::MarkSelectionInvalid( sal_uInt16 nStart, sal_uInt16 /*nEnd*/ )
     143             : {
     144           0 :     if ( !mbInvalid )
     145             :     {
     146           0 :         mnInvalidPosStart = nStart;
     147             : //      nInvalidPosEnd = nEnd;
     148             :     }
     149             :     else
     150             :     {
     151           0 :         mnInvalidPosStart = std::min( mnInvalidPosStart, nStart );
     152             : //      nInvalidPosEnd = pNode->Len();
     153             :     }
     154             : 
     155           0 :     maWritingDirectionInfos.clear();
     156             : 
     157           0 :     mnInvalidDiff = 0;
     158           0 :     mbInvalid = true;
     159           0 :     mbSimple = false;
     160           0 : }
     161             : 
     162           0 : sal_uInt16 TEParaPortion::GetLineNumber( sal_uInt16 nChar, bool bInclEnd )
     163             : {
     164           0 :     for ( sal_uInt16 nLine = 0; nLine < maLines.size(); nLine++ )
     165             :     {
     166           0 :         TextLine* pLine = maLines[ nLine ];
     167           0 :         if ( ( bInclEnd && ( pLine->GetEnd() >= nChar ) ) ||
     168           0 :              ( pLine->GetEnd() > nChar ) )
     169             :         {
     170           0 :             return nLine;
     171             :         }
     172             :     }
     173             : 
     174             :     // Then it should be at the end of the last line
     175             :     OSL_ENSURE(nChar == maLines[maLines.size() - 1]->GetEnd(), "wrong Index");
     176             :     OSL_ENSURE(!bInclEnd, "Line not found: FindLine");
     177           0 :     return ( maLines.size() - 1 );
     178             : }
     179             : 
     180           0 : void TEParaPortion::CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormattedLine )
     181             : {
     182           0 :     sal_uInt16 nLines = maLines.size();
     183             :     DBG_ASSERT( nLines, "CorrectPortionNumbersFromLine: Leere Portion?" );
     184           0 :     if ( nLastFormattedLine < ( nLines - 1 ) )
     185             :     {
     186           0 :         const TextLine* pLastFormatted = maLines[ nLastFormattedLine ];
     187           0 :         const TextLine* pUnformatted = maLines[ nLastFormattedLine+1 ];
     188           0 :         short nPortionDiff = pUnformatted->GetStartPortion() - pLastFormatted->GetEndPortion();
     189           0 :         short nTextDiff = pUnformatted->GetStart() - pLastFormatted->GetEnd();
     190           0 :         nTextDiff++;    // LastFormatted->GetEnd() was inclusive => subtracted one too much!
     191             : 
     192             :         // The first unformated one has to start exactly one portion past the last
     193             :         // formated one.
     194             :         // If a portion got split in the changed row, nLastEnd could be > nNextStart!
     195           0 :         short nPDiff = sal::static_int_cast< short >(-( nPortionDiff-1 ));
     196           0 :         short nTDiff = sal::static_int_cast< short >(-( nTextDiff-1 ));
     197           0 :         if ( nPDiff || nTDiff )
     198             :         {
     199           0 :             for ( sal_uInt16 nL = nLastFormattedLine+1; nL < nLines; nL++ )
     200             :             {
     201           0 :                 TextLine* pLine = maLines[ nL ];
     202             : 
     203           0 :                 pLine->GetStartPortion() = pLine->GetStartPortion() + nPDiff;
     204           0 :                 pLine->GetEndPortion() = pLine->GetEndPortion() + nPDiff;
     205             : 
     206           0 :                 pLine->GetStart() = pLine->GetStart() + nTDiff;
     207           0 :                 pLine->GetEnd() = pLine->GetEnd() + nTDiff;
     208             : 
     209           0 :                 pLine->SetValid();
     210             :             }
     211             :         }
     212             :     }
     213           0 : }
     214             : 
     215           0 : TEParaPortions::TEParaPortions()
     216             : {
     217           0 : }
     218             : 
     219           0 : TEParaPortions::~TEParaPortions()
     220             : {
     221           0 :     Reset();
     222           0 : }
     223             : 
     224           0 : void TEParaPortions::Reset()
     225             : {
     226           0 :     TEParaPortions::iterator aIter( begin() );
     227           0 :     while ( aIter != end() )
     228           0 :         delete *aIter++;
     229           0 :     clear();
     230           0 : }
     231             : 
     232           0 : IdleFormatter::IdleFormatter()
     233             : {
     234           0 :     mpView = 0;
     235           0 :     mnRestarts = 0;
     236           0 : }
     237             : 
     238           0 : IdleFormatter::~IdleFormatter()
     239             : {
     240           0 :     mpView = 0;
     241           0 : }
     242             : 
     243           0 : void IdleFormatter::DoIdleFormat( TextView* pV, sal_uInt16 nMaxRestarts )
     244             : {
     245           0 :     mpView = pV;
     246             : 
     247           0 :     if ( IsActive() )
     248           0 :         mnRestarts++;
     249             : 
     250           0 :     if ( mnRestarts > nMaxRestarts )
     251             :     {
     252           0 :         mnRestarts = 0;
     253           0 :         ((Link&)GetTimeoutHdl()).Call( this );
     254             :     }
     255             :     else
     256             :     {
     257           0 :         Start();
     258             :     }
     259           0 : }
     260             : 
     261           0 : void IdleFormatter::ForceTimeout()
     262             : {
     263           0 :     if ( IsActive() )
     264             :     {
     265           0 :         Stop();
     266           0 :         mnRestarts = 0;
     267           0 :         ((Link&)GetTimeoutHdl()).Call( this );
     268             :     }
     269           0 : }
     270             : 
     271           0 : TYPEINIT1( TextHint, SfxSimpleHint );
     272             : 
     273           0 : TextHint::TextHint( sal_uLong Id ) : SfxSimpleHint( Id )
     274             : {
     275           0 :     mnValue = 0;
     276           0 : }
     277             : 
     278           0 : TextHint::TextHint( sal_uLong Id, sal_uLong nValue ) : SfxSimpleHint( Id )
     279             : {
     280           0 :     mnValue = nValue;
     281           0 : }
     282             : 
     283           0 : TEIMEInfos::TEIMEInfos( const TextPaM& rPos, const OUString& rOldTextAfterStartPos )
     284           0 : : aOldTextAfterStartPos( rOldTextAfterStartPos )
     285             : {
     286           0 :     aPos = rPos;
     287           0 :     nLen = 0;
     288           0 :     bCursor = true;
     289           0 :     pAttribs = NULL;
     290           0 :     bWasCursorOverwrite = false;
     291           0 : }
     292             : 
     293           0 : TEIMEInfos::~TEIMEInfos()
     294             : {
     295           0 :     delete[] pAttribs;
     296           0 : }
     297             : 
     298           0 : void TEIMEInfos::CopyAttribs(const sal_uInt16* pA, sal_Int32 nL)
     299             : {
     300           0 :     nLen = nL;
     301           0 :     delete[] pAttribs;
     302           0 :     pAttribs = new sal_uInt16[ nL ];
     303           0 :     memcpy( pAttribs, pA, nL*sizeof(sal_uInt16) );
     304           0 : }
     305             : 
     306           0 : void TEIMEInfos::DestroyAttribs()
     307             : {
     308           0 :     delete[] pAttribs;
     309           0 :     pAttribs = NULL;
     310           0 :     nLen = 0;
     311           0 : }
     312             : 
     313             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10