LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/crsr - findcoll.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 36 0.0 %
Date: 2012-12-27 Functions: 0 6 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             : 
      21             : #include <tools/resid.hxx>
      22             : 
      23             : #include <swcrsr.hxx>
      24             : #include <doc.hxx>
      25             : #include <IDocumentUndoRedo.hxx>
      26             : #include <pamtyp.hxx>
      27             : #include <swundo.hxx>
      28             : #include <SwRewriter.hxx>
      29             : #include <comcore.hrc>
      30             : 
      31             : /// parameters for a search for FormatCollections
      32             : struct SwFindParaFmtColl : public SwFindParas
      33             : {
      34             :     const SwTxtFmtColl *pFmtColl, *pReplColl;
      35             :     SwCursor& rCursor;
      36           0 :     SwFindParaFmtColl( const SwTxtFmtColl& rFmtColl,
      37             :                         const SwTxtFmtColl* pRpColl, SwCursor& rCrsr )
      38           0 :         : pFmtColl( &rFmtColl ), pReplColl( pRpColl ), rCursor( rCrsr )
      39           0 :     {}
      40           0 :     virtual ~SwFindParaFmtColl() {}
      41             :     virtual int Find( SwPaM* , SwMoveFn , const SwPaM*, sal_Bool bInReadOnly );
      42             :     virtual int IsReplaceMode() const;
      43             : };
      44             : 
      45             : 
      46           0 : int SwFindParaFmtColl::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion,
      47             :                             sal_Bool bInReadOnly )
      48             : {
      49           0 :     int nRet = FIND_FOUND;
      50           0 :     if( bInReadOnly && pReplColl )
      51           0 :         bInReadOnly = sal_False;
      52             : 
      53           0 :     if( !pCrsr->Find( *pFmtColl, fnMove, pRegion, bInReadOnly ) )
      54           0 :         nRet = FIND_NOT_FOUND;
      55           0 :     else if( pReplColl )
      56             :     {
      57           0 :         pCrsr->GetDoc()->SetTxtFmtColl( *pCrsr, (SwTxtFmtColl*)pReplColl );
      58           0 :         nRet = FIND_NO_RING;
      59             :     }
      60           0 :     return nRet;
      61             : }
      62             : 
      63             : 
      64           0 : int SwFindParaFmtColl::IsReplaceMode() const
      65             : {
      66           0 :     return 0 != pReplColl;
      67             : }
      68             : 
      69             : /// search for Format-Collections
      70           0 : sal_uLong SwCursor::Find( const SwTxtFmtColl& rFmtColl, SwDocPositions nStart,
      71             :                           SwDocPositions nEnd, sal_Bool& bCancel,
      72             :                           FindRanges eFndRngs, const SwTxtFmtColl* pReplFmtColl )
      73             : {
      74             :     // switch off OLE-notifications
      75           0 :     SwDoc* pDoc = GetDoc();
      76           0 :     Link aLnk( pDoc->GetOle2Link() );
      77           0 :     pDoc->SetOle2Link( Link() );
      78             : 
      79             :     bool const bStartUndo =
      80           0 :         pDoc->GetIDocumentUndoRedo().DoesUndo() && pReplFmtColl;
      81           0 :     if (bStartUndo)
      82             :     {
      83           0 :         SwRewriter aRewriter;
      84           0 :         aRewriter.AddRule(UndoArg1, rFmtColl.GetName());
      85           0 :         aRewriter.AddRule(UndoArg2, SW_RES(STR_YIELDS));
      86           0 :         aRewriter.AddRule(UndoArg3, pReplFmtColl->GetName());
      87             : 
      88           0 :         pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_UI_REPLACE_STYLE,
      89           0 :                 &aRewriter );
      90             :     }
      91             : 
      92           0 :     SwFindParaFmtColl aSwFindParaFmtColl( rFmtColl, pReplFmtColl, *this );
      93             : 
      94           0 :     sal_uLong nRet = FindAll( aSwFindParaFmtColl, nStart, nEnd, eFndRngs, bCancel );
      95           0 :     pDoc->SetOle2Link( aLnk );
      96             : 
      97           0 :     if( nRet && pReplFmtColl )
      98           0 :         pDoc->SetModified();
      99             : 
     100           0 :     if (bStartUndo)
     101             :     {
     102           0 :         pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, 0);
     103             :     }
     104           0 :     return nRet;
     105             : }
     106             : 
     107             : 
     108             : 
     109             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10