LCOV - code coverage report
Current view: top level - sw/source/core/edit - edfcol.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 18 53 34.0 %
Date: 2015-06-13 12:38:46 Functions: 3 8 37.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 <hintids.hxx>
      21             : #include <editeng/formatbreakitem.hxx>
      22             : #include <editsh.hxx>
      23             : #include <doc.hxx>
      24             : #include <IDocumentUndoRedo.hxx>
      25             : #include <edimp.hxx>
      26             : #include <ndtxt.hxx>
      27             : #include <paratr.hxx>
      28             : #include <fmtpdsc.hxx>
      29             : #include <viewopt.hxx>
      30             : #include <SwRewriter.hxx>
      31             : #include <numrule.hxx>
      32             : #include <swundo.hxx>
      33             : #include <docary.hxx>
      34             : 
      35           0 : SwTextFormatColl& SwEditShell::GetDfltTextFormatColl() const
      36             : {
      37           0 :     return *static_cast<SwTextFormatColl*>( (GetDoc()->GetDfltTextFormatColl()));
      38             : }
      39             : 
      40           0 : sal_uInt16 SwEditShell::GetTextFormatCollCount() const
      41             : {
      42           0 :     return GetDoc()->GetTextFormatColls()->size();
      43             : }
      44             : 
      45           0 : SwTextFormatColl& SwEditShell::GetTextFormatColl( sal_uInt16 nFormatColl) const
      46             : {
      47           0 :     return *((*(GetDoc()->GetTextFormatColls()))[nFormatColl]);
      48             : }
      49             : 
      50             : // #i62675#
      51           1 : void SwEditShell::SetTextFormatColl(SwTextFormatColl *pFormat,
      52             :                                 const bool bResetListAttrs)
      53             : {
      54           1 :     SwTextFormatColl *pLocal = pFormat? pFormat: (*GetDoc()->GetTextFormatColls())[0];
      55           1 :     StartAllAction();
      56             : 
      57           1 :     SwRewriter aRewriter;
      58           1 :     aRewriter.AddRule(UndoArg1, pLocal->GetName());
      59             : 
      60           1 :     GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_SETFMTCOLL, &aRewriter);
      61           2 :     for(SwPaM& rPaM : GetCrsr()->GetRingContainer())
      62             :     {
      63             : 
      64           1 :         if ( !rPaM.HasReadonlySel( GetViewOptions()->IsFormView() ) )
      65             :         {
      66             :             // Change the paragraph style to pLocal and remove all direct paragraph formatting.
      67           1 :             GetDoc()->SetTextFormatColl( rPaM, pLocal, true, bResetListAttrs );
      68             : 
      69             :             // If there are hints on the nodes which cover the whole node, then remove those, too.
      70           1 :             SwPaM aPaM(*rPaM.Start(), *rPaM.End());
      71           1 :             if (SwTextNode* pEndTextNode = aPaM.End()->nNode.GetNode().GetTextNode())
      72             :             {
      73           1 :                 aPaM.Start()->nContent = 0;
      74           1 :                 aPaM.End()->nContent = pEndTextNode->GetText().getLength();
      75             :             }
      76           1 :             GetDoc()->RstTextAttrs(aPaM, /*bInclRefToxMark=*/false, /*bExactRange=*/true);
      77             :         }
      78             : 
      79             :     }
      80           1 :     GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_SETFMTCOLL, &aRewriter);
      81           1 :     EndAllAction();
      82           1 : }
      83             : 
      84           0 : SwTextFormatColl* SwEditShell::MakeTextFormatColl(const OUString& rFormatCollName,
      85             :         SwTextFormatColl* pParent)
      86             : {
      87             :     SwTextFormatColl *pColl;
      88           0 :     if ( pParent == 0 )
      89           0 :         pParent = &GetTextFormatColl(0);
      90           0 :     if (  (pColl=GetDoc()->MakeTextFormatColl(rFormatCollName, pParent)) == 0 )
      91             :     {
      92             :         OSL_FAIL( "MakeTextFormatColl failed" );
      93             :     }
      94           0 :     return pColl;
      95             : 
      96             : }
      97             : 
      98           0 : void SwEditShell::FillByEx(SwTextFormatColl* pColl, bool bReset)
      99             : {
     100           0 :     if( bReset )
     101             :     {
     102           0 :         pColl->ResetAllFormatAttr();
     103             :     }
     104             : 
     105           0 :     SwPaM * pCrsr = GetCrsr();
     106           0 :     SwContentNode * pCnt = pCrsr->GetContentNode();
     107           0 :     const SfxItemSet* pSet = pCnt->GetpSwAttrSet();
     108           0 :     if( pSet )
     109             :     {
     110             :         // JP 05.10.98: Special treatment if one of the attribues Break/PageDesc/NumRule(auto) is
     111             :         //      in the ItemSet. Otherwise there will be too much or wrong processing (NumRules!)
     112             :         //      Bug 57568
     113             : 
     114             :         // Do NOT copy AutoNumRules into the template
     115             :         const SfxPoolItem* pItem;
     116           0 :         const SwNumRule* pRule = 0;
     117           0 :         if( SfxItemState::SET == pSet->GetItemState( RES_BREAK, false ) ||
     118           0 :             SfxItemState::SET == pSet->GetItemState( RES_PAGEDESC,false ) ||
     119             :             ( SfxItemState::SET == pSet->GetItemState( RES_PARATR_NUMRULE,
     120           0 :                 false, &pItem ) && 0 != (pRule = GetDoc()->FindNumRulePtr(
     121           0 :                 static_cast<const SwNumRuleItem*>(pItem)->GetValue() )) &&
     122           0 :                 pRule && pRule->IsAutoRule() )
     123             :             )
     124             :         {
     125           0 :             SfxItemSet aSet( *pSet );
     126           0 :             aSet.ClearItem( RES_BREAK );
     127           0 :             aSet.ClearItem( RES_PAGEDESC );
     128             : 
     129           0 :             if( pRule || (SfxItemState::SET == pSet->GetItemState( RES_PARATR_NUMRULE,
     130           0 :                 false, &pItem ) && 0 != (pRule = GetDoc()->FindNumRulePtr(
     131           0 :                 static_cast<const SwNumRuleItem*>(pItem)->GetValue() )) &&
     132           0 :                 pRule && pRule->IsAutoRule() ))
     133           0 :                 aSet.ClearItem( RES_PARATR_NUMRULE );
     134             : 
     135           0 :             if( aSet.Count() )
     136           0 :                 GetDoc()->ChgFormat(*pColl, aSet );
     137             :         }
     138             :         else
     139           0 :             GetDoc()->ChgFormat(*pColl, *pSet );
     140             :     }
     141         177 : }
     142             : 
     143             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11