LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/edit - edatmisc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 77 2.6 %
Date: 2012-12-27 Functions: 1 6 16.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             : 
      21             : #include <editsh.hxx>
      22             : #include <doc.hxx>      // fuer aNodes
      23             : #include <IDocumentUndoRedo.hxx>
      24             : #include <pam.hxx>      // fuer SwPaM
      25             : #include <edimp.hxx>    // fuer MACROS
      26             : #include <swundo.hxx>   // fuer die UndoIds
      27             : #include <ndtxt.hxx>    // fuer Get-/ChgFmt Set-/GetAttrXXX
      28             : 
      29             : 
      30             : 
      31             : /*************************************
      32             :  * harte Formatierung (Attribute)
      33             :  *************************************/
      34             : 
      35             : 
      36           0 : void SwEditShell::ResetAttr( const std::set<sal_uInt16> &attrs, SwPaM* pPaM )
      37             : {
      38           0 :     SET_CURR_SHELL( this );
      39           0 :     SwPaM* pCrsr = pPaM ? pPaM : GetCrsr( );
      40             : 
      41           0 :     StartAllAction();
      42           0 :     bool bUndoGroup = pCrsr->GetNext() != pCrsr;
      43           0 :     if( bUndoGroup )
      44             :     {
      45           0 :         GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_RESETATTR, NULL);
      46             :     }
      47             : 
      48           0 :         SwPaM* pStartCrsr = pCrsr;
      49           0 :         do {
      50           0 :                 GetDoc()->ResetAttrs(*pCrsr, true, attrs);
      51           0 :         } while ( ( pCrsr = ( SwPaM* ) pCrsr->GetNext() ) != pStartCrsr );
      52             : 
      53           0 :     if( bUndoGroup )
      54             :     {
      55           0 :         GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_RESETATTR, NULL);
      56             :     }
      57           0 :     CallChgLnk();
      58           0 :     EndAllAction();
      59           0 : }
      60             : 
      61             : 
      62             : 
      63           0 : void SwEditShell::GCAttr()
      64             : {
      65           0 :     FOREACHPAM_START(this)
      66           0 :         if ( !PCURCRSR->HasMark() )
      67             :         {
      68             :             SwTxtNode *const pTxtNode =
      69           0 :                 PCURCRSR->GetPoint()->nNode.GetNode().GetTxtNode();
      70           0 :             if (pTxtNode)
      71             :             {
      72           0 :                 pTxtNode->GCAttr();
      73             :             }
      74             :         }
      75             :         else
      76             :         {
      77           0 :             const SwNodeIndex& rEnd = PCURCRSR->End()->nNode;
      78           0 :             SwNodeIndex aIdx( PCURCRSR->Start()->nNode );
      79           0 :             SwNode* pNd = &aIdx.GetNode();
      80           0 :             do {
      81           0 :                 if( pNd->IsTxtNode() )
      82           0 :                     ((SwTxtNode*)pNd)->GCAttr();
      83             :             }
      84           0 :             while( 0 != ( pNd = GetDoc()->GetNodes().GoNext( &aIdx )) &&
      85           0 :                     aIdx <= rEnd );
      86             :         }
      87           0 :     FOREACHPAM_END()
      88           0 : }
      89             : 
      90             : // Setze das Attribut als neues default Attribut im Dokument.
      91             : 
      92             : 
      93           0 : void SwEditShell::SetDefault( const SfxPoolItem& rFmtHint )
      94             : {
      95             :     // 7502: Action-Klammerung
      96           0 :     StartAllAction();
      97           0 :     GetDoc()->SetDefault( rFmtHint );
      98           0 :     EndAllAction();
      99           0 : }
     100             : 
     101             : // Erfrage das Default Attribut in diesem Dokument.
     102             : 
     103         104 : const SfxPoolItem& SwEditShell::GetDefault( sal_uInt16 nFmtHint ) const
     104             : {
     105         104 :     return GetDoc()->GetDefault( nFmtHint );
     106             : 
     107             : }
     108             : 
     109             : 
     110           0 : void SwEditShell::SetAttr( const SfxPoolItem& rHint, sal_uInt16 nFlags )
     111             : {
     112           0 :     SET_CURR_SHELL( this );
     113           0 :     StartAllAction();
     114           0 :     SwPaM* pCrsr = GetCrsr();
     115           0 :     if( pCrsr->GetNext() != pCrsr )     // Ring von Cursorn
     116             :     {
     117           0 :         sal_Bool bIsTblMode = IsTableMode();
     118           0 :         GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL);
     119             : 
     120           0 :         FOREACHPAM_START(this)
     121           0 :             if( PCURCRSR->HasMark() && ( bIsTblMode ||
     122           0 :                 *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() ))
     123             :             {
     124           0 :                 GetDoc()->InsertPoolItem(*PCURCRSR, rHint, nFlags );
     125             :             }
     126           0 :         FOREACHPAM_END()
     127             : 
     128           0 :         GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL);
     129             :     }
     130             :     else
     131             :     {
     132           0 :         if( !HasSelection() )
     133           0 :             UpdateAttr();
     134           0 :         GetDoc()->InsertPoolItem( *pCrsr, rHint, nFlags );
     135             :     }
     136           0 :     EndAllAction();
     137           0 : }
     138             : 
     139             : 
     140           0 : void SwEditShell::SetAttr( const SfxItemSet& rSet, sal_uInt16 nFlags, SwPaM* pPaM )
     141             : {
     142           0 :     SET_CURR_SHELL( this );
     143             : 
     144           0 :     SwPaM* pCrsr = pPaM ? pPaM : GetCrsr();
     145           0 :     StartAllAction();
     146           0 :     if( pCrsr->GetNext() != pCrsr )     // Ring von Cursorn
     147             :     {
     148           0 :         sal_Bool bIsTblMode = IsTableMode();
     149           0 :         GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL);
     150             : 
     151           0 :         SwPaM* pTmpCrsr = pCrsr;
     152           0 :         SwPaM* pStartPaM = pCrsr;
     153           0 :         do {
     154           0 :             if( pTmpCrsr->HasMark() && ( bIsTblMode ||
     155           0 :                 *pTmpCrsr->GetPoint() != *pTmpCrsr->GetMark() ))
     156             :             {
     157           0 :                 GetDoc()->InsertItemSet(*pTmpCrsr, rSet, nFlags );
     158             :             }
     159           0 :         } while ( ( pTmpCrsr = (SwPaM*)pTmpCrsr->GetNext() ) != pStartPaM );
     160             : 
     161           0 :         GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL);
     162             :     }
     163             :     else
     164             :     {
     165           0 :         if( !HasSelection() )
     166           0 :             UpdateAttr();
     167           0 :         GetDoc()->InsertItemSet( *pCrsr, rSet, nFlags );
     168             :     }
     169           0 :     EndAllAction();
     170           0 : }
     171             : 
     172             : 
     173             : 
     174             : 
     175             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10