LCOV - code coverage report
Current view: top level - sw/source/core/edit - edatmisc.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 41 70 58.6 %
Date: 2015-06-13 12:38:46 Functions: 7 8 87.5 %
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 <editsh.hxx>
      21             : #include <doc.hxx>
      22             : #include <IDocumentUndoRedo.hxx>
      23             : #include <pam.hxx>
      24             : #include <edimp.hxx>
      25             : #include <swundo.hxx>
      26             : #include <ndtxt.hxx>
      27             : 
      28             : /*
      29             :  * hard formatting (Attribute)
      30             :  */
      31             : 
      32           2 : void SwEditShell::ResetAttr( const std::set<sal_uInt16> &attrs, SwPaM* pPaM )
      33             : {
      34           2 :     SET_CURR_SHELL( this );
      35           2 :     SwPaM* pCrsr = pPaM ? pPaM : GetCrsr( );
      36             : 
      37           2 :     StartAllAction();
      38           2 :     bool bUndoGroup = pCrsr->GetNext() != pCrsr;
      39           2 :     if( bUndoGroup )
      40             :     {
      41           0 :         GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_RESETATTR, NULL);
      42             :     }
      43             : 
      44           4 :     for(SwPaM& rCurCrsr : pCrsr->GetRingContainer())
      45           2 :         GetDoc()->ResetAttrs(rCurCrsr, true, attrs);
      46             : 
      47           2 :     if( bUndoGroup )
      48             :     {
      49           0 :         GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_RESETATTR, NULL);
      50             :     }
      51           2 :     CallChgLnk();
      52           2 :     EndAllAction();
      53           2 : }
      54             : 
      55           1 : void SwEditShell::GCAttr()
      56             : {
      57           2 :     for(SwPaM& rPaM : GetCrsr()->GetRingContainer())
      58             :     {
      59           1 :         if ( !rPaM.HasMark() )
      60             :         {
      61             :             SwTextNode *const pTextNode =
      62           1 :                 rPaM.GetPoint()->nNode.GetNode().GetTextNode();
      63           1 :             if (pTextNode)
      64             :             {
      65           1 :                 pTextNode->GCAttr();
      66             :             }
      67             :         }
      68             :         else
      69             :         {
      70           0 :             const SwNodeIndex& rEnd = rPaM.End()->nNode;
      71           0 :             SwNodeIndex aIdx( rPaM.Start()->nNode );
      72           0 :             SwNode* pNd = &aIdx.GetNode();
      73           0 :             do {
      74           0 :                 if( pNd->IsTextNode() )
      75           0 :                     static_cast<SwTextNode*>(pNd)->GCAttr();
      76             :             }
      77           0 :             while( 0 != ( pNd = GetDoc()->GetNodes().GoNext( &aIdx )) &&
      78           0 :                     aIdx <= rEnd );
      79             :         }
      80             :     }
      81           1 : }
      82             : 
      83             : /// Set the attribute as new default attribute in the document.
      84           0 : void SwEditShell::SetDefault( const SfxPoolItem& rFormatHint )
      85             : {
      86             :     // 7502: Action-Parenthesis
      87           0 :     StartAllAction();
      88           0 :     GetDoc()->SetDefault( rFormatHint );
      89           0 :     EndAllAction();
      90           0 : }
      91             : 
      92             : /// request the default attribute in this document.
      93         542 : const SfxPoolItem& SwEditShell::GetDefault( sal_uInt16 nFormatHint ) const
      94             : {
      95         542 :     return GetDoc()->GetDefault( nFormatHint );
      96             : }
      97             : 
      98          44 : void SwEditShell::SetAttrItem( const SfxPoolItem& rHint, SetAttrMode nFlags )
      99             : {
     100          44 :     SET_CURR_SHELL( this );
     101          44 :     StartAllAction();
     102          44 :     SwPaM* pCrsr = GetCrsr();
     103          44 :     if( pCrsr->GetNext() != pCrsr )     // Ring of Cursors
     104             :     {
     105           0 :         bool bIsTableMode = IsTableMode();
     106           0 :         GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL);
     107             : 
     108           0 :         for(SwPaM& rPaM : GetCrsr()->GetRingContainer())
     109             :         {
     110           0 :             if( rPaM.HasMark() && ( bIsTableMode ||
     111           0 :                 *rPaM.GetPoint() != *rPaM.GetMark() ))
     112             :             {
     113           0 :                 GetDoc()->getIDocumentContentOperations().InsertPoolItem(rPaM, rHint, nFlags );
     114             :             }
     115             :         }
     116             : 
     117           0 :         GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL);
     118             :     }
     119             :     else
     120             :     {
     121          44 :         if( !HasSelection() )
     122          44 :             UpdateAttr();
     123          44 :         GetDoc()->getIDocumentContentOperations().InsertPoolItem( *pCrsr, rHint, nFlags );
     124             :     }
     125          44 :     EndAllAction();
     126          44 : }
     127             : 
     128           7 : void SwEditShell::SetAttrSet( const SfxItemSet& rSet, SetAttrMode nFlags, SwPaM* pPaM )
     129             : {
     130           7 :     SET_CURR_SHELL( this );
     131             : 
     132           7 :     SwPaM* pCrsr = pPaM ? pPaM : GetCrsr();
     133           7 :     StartAllAction();
     134           7 :     if( pCrsr->GetNext() != pCrsr )     // Ring of Cursors
     135             :     {
     136           0 :         bool bIsTableMode = IsTableMode();
     137           0 :         GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL);
     138             : 
     139           0 :         for(SwPaM& rTmpCrsr : pCrsr->GetRingContainer())
     140             :         {
     141           0 :             if( rTmpCrsr.HasMark() && ( bIsTableMode ||
     142           0 :                 *rTmpCrsr.GetPoint() != *rTmpCrsr.GetMark() ))
     143             :             {
     144           0 :                 GetDoc()->getIDocumentContentOperations().InsertItemSet(rTmpCrsr, rSet, nFlags );
     145             :             }
     146             :         }
     147             : 
     148           0 :         GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL);
     149             :     }
     150             :     else
     151             :     {
     152           7 :         if( !HasSelection() )
     153           3 :             UpdateAttr();
     154           7 :         GetDoc()->getIDocumentContentOperations().InsertItemSet( *pCrsr, rSet, nFlags );
     155             :     }
     156           7 :     EndAllAction();
     157         184 : }
     158             : 
     159             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11