LCOV - code coverage report
Current view: top level - sw/source/core/txtnode - txatritr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 111 0.0 %
Date: 2012-08-25 Functions: 0 6 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 162 0.0 %

           Branch data     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 <hintids.hxx>
      21                 :            : 
      22                 :            : #include <com/sun/star/i18n/ScriptType.hpp>
      23                 :            : #include <tools/string.hxx>
      24                 :            : #include <editeng/langitem.hxx>
      25                 :            : #include <txatritr.hxx>
      26                 :            : #include <fchrfmt.hxx>
      27                 :            : #include <charfmt.hxx>
      28                 :            : #include <breakit.hxx>
      29                 :            : #include <ndtxt.hxx>
      30                 :            : #include <txatbase.hxx>
      31                 :            : 
      32                 :            : using namespace ::com::sun::star::i18n;
      33                 :            : 
      34                 :            : 
      35                 :          0 : SwScriptIterator::SwScriptIterator( const String& rStr, xub_StrLen nStt, sal_Bool bFrwrd )
      36                 :            :     : rText( rStr ),
      37                 :          0 :       nChgPos( rStr.Len() ),
      38                 :            :       nCurScript( ScriptType::WEAK ),
      39                 :          0 :       bForward( bFrwrd )
      40                 :            : {
      41         [ #  # ]:          0 :     if( pBreakIt->GetBreakIter().is() )
      42                 :            :     {
      43 [ #  # ][ #  # ]:          0 :         if ( ! bFrwrd && nStt )
      44                 :          0 :             --nStt;
      45                 :            : 
      46                 :          0 :         xub_StrLen nPos = nStt;
      47 [ #  # ][ #  # ]:          0 :         nCurScript = pBreakIt->GetBreakIter()->getScriptType( rText, nPos );
                 [ #  # ]
      48         [ #  # ]:          0 :         if( ScriptType::WEAK == nCurScript )
      49                 :            :         {
      50         [ #  # ]:          0 :             if( nPos )
      51                 :            :             {
      52         [ #  # ]:          0 :                 nPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfScript(
      53 [ #  # ][ #  # ]:          0 :                                                 rText, nPos, nCurScript );
      54 [ #  # ][ #  # ]:          0 :                 if( nPos && nPos < rText.Len() )
                 [ #  # ]
      55                 :            :                 {
      56                 :          0 :                     nStt = --nPos;
      57 [ #  # ][ #  # ]:          0 :                     nCurScript = pBreakIt->GetBreakIter()->getScriptType( rText,nPos);
                 [ #  # ]
      58                 :            :                 }
      59                 :            :             }
      60                 :            :         }
      61                 :            : 
      62                 :            :         nChgPos = bForward ?
      63 [ #  # ][ #  # ]:          0 :                   (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( rText, nStt, nCurScript ) :
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
      64 [ #  # ][ #  # ]:          0 :                   (xub_StrLen)pBreakIt->GetBreakIter()->beginOfScript( rText, nStt, nCurScript );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
      65                 :            :     }
      66                 :          0 : }
      67                 :            : 
      68                 :          0 : sal_Bool SwScriptIterator::Next()
      69                 :            : {
      70                 :          0 :     sal_Bool bRet = sal_False;
      71         [ #  # ]:          0 :     if( pBreakIt->GetBreakIter().is() )
      72                 :            :     {
      73 [ #  # ][ #  # ]:          0 :         if ( bForward && nChgPos < rText.Len() )
                 [ #  # ]
      74                 :            :         {
      75 [ #  # ][ #  # ]:          0 :             nCurScript = pBreakIt->GetBreakIter()->getScriptType( rText, nChgPos );
                 [ #  # ]
      76         [ #  # ]:          0 :             nChgPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript(
      77 [ #  # ][ #  # ]:          0 :                                                 rText, nChgPos, nCurScript );
      78                 :          0 :             bRet = sal_True;
      79                 :            :         }
      80 [ #  # ][ #  # ]:          0 :         else if ( ! bForward && nChgPos )
      81                 :            :         {
      82                 :          0 :             --nChgPos;
      83 [ #  # ][ #  # ]:          0 :             nCurScript = pBreakIt->GetBreakIter()->getScriptType( rText, nChgPos );
                 [ #  # ]
      84         [ #  # ]:          0 :             nChgPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfScript(
      85 [ #  # ][ #  # ]:          0 :                                                 rText, nChgPos, nCurScript );
      86                 :          0 :             bRet = sal_True;
      87                 :            :         }
      88                 :            :     }
      89                 :            :     else
      90                 :          0 :         nChgPos = rText.Len();
      91                 :          0 :     return bRet;
      92                 :            : }
      93                 :            : 
      94                 :            : // --------------------------------------------------------------------
      95                 :            : 
      96                 :          0 : SwTxtAttrIterator::SwTxtAttrIterator( const SwTxtNode& rTNd, sal_uInt16 nWhchId,
      97                 :            :                                         xub_StrLen nStt,
      98                 :            :                                         sal_Bool bUseGetWhichOfScript )
      99                 :          0 :     : aSIter( rTNd.GetTxt(), nStt ), rTxtNd( rTNd ),
     100                 :            :     pParaItem( 0 ), nChgPos( nStt ), nAttrPos( 0 ), nWhichId( nWhchId ),
     101                 :          0 :     bIsUseGetWhichOfScript( bUseGetWhichOfScript )
     102                 :            : {
     103         [ #  # ]:          0 :     SearchNextChg();
     104                 :          0 : }
     105                 :            : 
     106                 :          0 : sal_Bool SwTxtAttrIterator::Next()
     107                 :            : {
     108                 :          0 :     sal_Bool bRet = sal_False;
     109         [ #  # ]:          0 :     if( nChgPos < aSIter.GetText().Len() )
     110                 :            :     {
     111                 :          0 :         bRet = sal_True;
     112         [ #  # ]:          0 :         if( !aStack.empty() )
     113                 :            :         {
     114         [ #  # ]:          0 :             do {
     115                 :          0 :                 const SwTxtAttr* pHt = aStack.front();
     116                 :          0 :                 sal_uInt16 nEndPos = *pHt->GetEnd();
     117         [ #  # ]:          0 :                 if( nChgPos >= nEndPos )
     118                 :          0 :                     aStack.pop_front();
     119                 :            :                 else
     120                 :          0 :                     break;
     121                 :          0 :             } while( !aStack.empty() );
     122                 :            :         }
     123                 :            : 
     124         [ #  # ]:          0 :         if( !aStack.empty() )
     125                 :            :         {
     126                 :          0 :             sal_uInt16 nSavePos = nAttrPos;
     127                 :          0 :             SearchNextChg();
     128         [ #  # ]:          0 :             if( !aStack.empty() )
     129                 :            :             {
     130                 :          0 :                 const SwTxtAttr* pHt = aStack.front();
     131                 :          0 :                 sal_uInt16 nEndPos = *pHt->GetEnd();
     132         [ #  # ]:          0 :                 if( nChgPos >= nEndPos )
     133                 :            :                 {
     134                 :          0 :                     nChgPos = nEndPos;
     135                 :          0 :                     nAttrPos = nSavePos;
     136                 :            : 
     137         [ #  # ]:          0 :                     if( RES_TXTATR_CHARFMT == pHt->Which() )
     138                 :            :                     {
     139                 :            :                         sal_uInt16 nWId = bIsUseGetWhichOfScript ?
     140                 :            :                                 GetWhichOfScript( nWhichId,
     141         [ #  # ]:          0 :                                                   aSIter.GetCurrScript() ) : nWhichId;
     142                 :          0 :                         pCurItem = &pHt->GetCharFmt().GetCharFmt()->GetFmtAttr(nWId);
     143                 :            :                     }
     144                 :            :                     else
     145                 :          0 :                         pCurItem = &pHt->GetAttr();
     146                 :            : 
     147                 :          0 :                     aStack.pop_front();
     148                 :            :                 }
     149                 :            :             }
     150                 :            :         }
     151                 :            :         else
     152                 :          0 :             SearchNextChg();
     153                 :            :     }
     154                 :          0 :     return bRet;
     155                 :            : }
     156                 :            : 
     157                 :          0 : void SwTxtAttrIterator::AddToStack( const SwTxtAttr& rAttr )
     158                 :            : {
     159                 :          0 :     sal_uInt16 nIns = 0, nEndPos = *rAttr.GetEnd();
     160         [ #  # ]:          0 :     for( ; nIns < aStack.size(); ++nIns )
     161         [ #  # ]:          0 :         if( *aStack[ nIns ]->GetEnd() > nEndPos )
     162                 :          0 :             break;
     163                 :            : 
     164 [ #  # ][ #  # ]:          0 :     aStack.insert( aStack.begin() + nIns, &rAttr );
     165                 :          0 : }
     166                 :            : 
     167                 :          0 : void SwTxtAttrIterator::SearchNextChg()
     168                 :            : {
     169                 :          0 :     sal_uInt16 nWh = 0;
     170         [ #  # ]:          0 :     if( nChgPos == aSIter.GetScriptChgPos() )
     171                 :            :     {
     172                 :          0 :         aSIter.Next();
     173                 :          0 :         pParaItem = 0;
     174                 :          0 :         nAttrPos = 0;       // must be restart at the beginning, because
     175                 :            :                             // some attributes can start before or inside
     176                 :            :                             // the current scripttype!
     177                 :          0 :         aStack.clear();
     178                 :            :     }
     179         [ #  # ]:          0 :     if( !pParaItem )
     180                 :            :     {
     181                 :            :         nWh = bIsUseGetWhichOfScript ?
     182                 :            :                 GetWhichOfScript( nWhichId,
     183         [ #  # ]:          0 :                                   aSIter.GetCurrScript() ) : nWhichId;
     184                 :          0 :         pParaItem = &rTxtNd.GetSwAttrSet().Get( nWh );
     185                 :            :     }
     186                 :            : 
     187                 :          0 :     xub_StrLen nStt = nChgPos;
     188                 :          0 :     nChgPos = aSIter.GetScriptChgPos();
     189                 :          0 :     pCurItem = pParaItem;
     190                 :            : 
     191                 :          0 :     const SwpHints* pHts = rTxtNd.GetpSwpHints();
     192         [ #  # ]:          0 :     if( pHts )
     193                 :            :     {
     194         [ #  # ]:          0 :         if( !nWh )
     195                 :            :         {
     196                 :            :             nWh =  bIsUseGetWhichOfScript ?
     197                 :            :                         GetWhichOfScript( nWhichId,
     198         [ #  # ]:          0 :                                           aSIter.GetCurrScript() ) : nWhichId;
     199                 :            :         }
     200                 :            : 
     201                 :          0 :         const SfxPoolItem* pItem = 0;
     202         [ #  # ]:          0 :         for( ; nAttrPos < pHts->Count(); ++nAttrPos )
     203                 :            :         {
     204                 :          0 :             const SwTxtAttr* pHt = (*pHts)[ nAttrPos ];
     205                 :          0 :             const sal_uInt16* pEnd = pHt->GetEnd();
     206                 :          0 :             const sal_uInt16 nHtStt = *pHt->GetStart();
     207 [ #  # ][ #  # ]:          0 :             if( nHtStt < nStt && ( !pEnd || *pEnd <= nStt ))
                 [ #  # ]
     208                 :          0 :                 continue;
     209                 :            : 
     210         [ #  # ]:          0 :             if( nHtStt >= nChgPos )
     211                 :          0 :                 break;
     212                 :            : 
     213                 :          0 :             pItem = CharFmt::GetItem( *pHt, nWh );
     214         [ #  # ]:          0 :             if ( pItem )
     215                 :            :             {
     216         [ #  # ]:          0 :                 if( nHtStt > nStt )
     217                 :            :                 {
     218         [ #  # ]:          0 :                     if( nChgPos > nHtStt )
     219                 :          0 :                         nChgPos = nHtStt;
     220                 :          0 :                     break;
     221                 :            :                 }
     222                 :          0 :                 AddToStack( *pHt );
     223                 :          0 :                 pCurItem = pItem;
     224         [ #  # ]:          0 :                 if( *pEnd < nChgPos )
     225                 :          0 :                     nChgPos = *pEnd;
     226                 :            :             }
     227                 :            :         }
     228                 :            :     }
     229                 :          0 : }
     230                 :            : 
     231                 :            : 
     232                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10