LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/crsr - findfmt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 27 3.7 %
Date: 2013-07-09 Functions: 2 3 66.7 %
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 <doc.hxx>
      21             : #include <pamtyp.hxx>
      22             : 
      23             : 
      24           0 : bool SwPaM::Find( const SwFmt& rFmt, SwMoveFn fnMove,
      25             :                   const SwPaM *pRegion, bool bInReadOnly  )
      26             : {
      27           0 :     bool bFound = false;
      28           0 :     const bool bSrchForward = (fnMove == fnMoveForward);
      29           0 :     SwPaM* pPam = MakeRegion( fnMove, pRegion );
      30             : 
      31             :     // if at beginning/end then move it out of the node
      32           0 :     if( bSrchForward
      33           0 :         ? pPam->GetPoint()->nContent.GetIndex() == pPam->GetCntntNode()->Len()
      34           0 :         : !pPam->GetPoint()->nContent.GetIndex() )
      35             :     {
      36           0 :         if( !(*fnMove->fnNds)( &pPam->GetPoint()->nNode, sal_False ))
      37             :         {
      38           0 :             delete pPam;
      39           0 :             return false;
      40             :         }
      41           0 :         SwCntntNode *pNd = pPam->GetPoint()->nNode.GetNode().GetCntntNode();
      42           0 :         xub_StrLen nTmpPos = bSrchForward ? 0 : pNd->Len();
      43           0 :         pPam->GetPoint()->nContent.Assign( pNd, nTmpPos );
      44             :     }
      45             : 
      46           0 :     sal_Bool bFirst = sal_True;
      47             :     SwCntntNode* pNode;
      48           0 :     while( 0 != ( pNode = ::GetNode( *pPam, bFirst, fnMove, bInReadOnly )))
      49             :     {
      50           0 :         if ( pNode->GetFmtColl() == &rFmt )
      51             :         {
      52             :             // if a FormatCollection is found then it is definitely a SwCntntNode
      53             : 
      54             :             // FORWARD:  SPoint at the end, GetMark at the beginning of the node
      55             :             // BACKWARD: SPoint at the beginning, GetMark at the end of the node
      56             :             // always: incl. start and incl. end
      57           0 :             *GetPoint() = *pPam->GetPoint();
      58           0 :             SetMark();
      59           0 :             pNode->MakeEndIndex( &GetPoint()->nContent );
      60           0 :             GetMark()->nContent = 0;
      61             : 
      62             :             // if backward search, switch point and mark
      63           0 :             if( !bSrchForward )
      64           0 :                 Exchange();
      65             : 
      66           0 :             bFound = true;
      67           0 :             break;
      68             :         }
      69             :     }
      70           0 :     delete pPam;
      71           0 :     return bFound;
      72          99 : }
      73             : 
      74             : 
      75             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10