1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 28 #include <hintids.hxx> 29 #include <editeng/brkitem.hxx> 30 #include <editsh.hxx> 31 #include <doc.hxx> // fuer SwTxtFmtColls 32 #include <IDocumentUndoRedo.hxx> 33 #include <edimp.hxx> // fuer MACROS 34 #include <ndtxt.hxx> 35 #include <paratr.hxx> 36 #include <fmtpdsc.hxx> 37 // --> FME 2004-06-29 #114856# Formular view 38 #include <viewopt.hxx> 39 // <-- 40 #include <SwRewriter.hxx> 41 #include <numrule.hxx> 42 #include <swundo.hxx> 43 44 /************************************* 45 * FormatColl 46 *************************************/ 47 // TXT 48 49 50 SwTxtFmtColl& SwEditShell::GetDfltTxtFmtColl() const 51 { 52 return *((SwTxtFmtColl*) (GetDoc()->GetDfltTxtFmtColl())); 53 } 54 55 56 sal_uInt16 SwEditShell::GetTxtFmtCollCount() const 57 { 58 return GetDoc()->GetTxtFmtColls()->Count(); 59 } 60 61 62 SwTxtFmtColl& SwEditShell::GetTxtFmtColl( sal_uInt16 nFmtColl) const 63 { 64 return *((*(GetDoc()->GetTxtFmtColls()))[nFmtColl]); 65 } 66 67 // --> OD 2007-11-06 #i62675# 68 void SwEditShell::SetTxtFmtColl( SwTxtFmtColl *pFmt, 69 bool bResetListAttrs ) 70 { 71 SwTxtFmtColl *pLocal = pFmt? pFmt: (*GetDoc()->GetTxtFmtColls())[0]; 72 StartAllAction(); 73 74 SwRewriter aRewriter; 75 aRewriter.AddRule(UNDO_ARG1, pLocal->GetName()); 76 77 GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_SETFMTCOLL, &aRewriter); 78 FOREACHPAM_START(this) 79 80 if ( !PCURCRSR->HasReadonlySel( GetViewOptions()->IsFormView() ) ) 81 { 82 GetDoc()->SetTxtFmtColl( *PCURCRSR, pLocal, true, bResetListAttrs ); 83 } 84 85 FOREACHPAM_END() 86 GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_SETFMTCOLL, &aRewriter); 87 EndAllAction(); 88 } 89 // <-- 90 91 92 SwTxtFmtColl* SwEditShell::MakeTxtFmtColl(const String& rFmtCollName, 93 SwTxtFmtColl* pParent) 94 { 95 SwTxtFmtColl *pColl; 96 if ( pParent == 0 ) 97 pParent = &GetTxtFmtColl(0); 98 if ( (pColl=GetDoc()->MakeTxtFmtColl(rFmtCollName, pParent)) == 0 ) 99 { 100 ASSERT( sal_False, "MakeTxtFmtColl failed" ) 101 } 102 return pColl; 103 104 } 105 106 107 void SwEditShell::FillByEx(SwTxtFmtColl* pColl, sal_Bool bReset) 108 { 109 if( bReset ) 110 { 111 // --> OD 2007-01-25 #i73790# - method renamed 112 pColl->ResetAllFmtAttr(); 113 // <-- 114 } 115 116 SwPaM * pCrsr = GetCrsr(); 117 SwCntntNode * pCnt = pCrsr->GetCntntNode(); 118 const SfxItemSet* pSet = pCnt->GetpSwAttrSet(); 119 if( pSet ) 120 { 121 // JP 05.10.98: falls eines der Attribute Break/PageDesc/NumRule(auto) 122 // im ItemSet steht, so entferne die VORM setzen an der Collection. 123 // Ansonst wird zu viel gemacht oder falsche gemacht (NumRules!) 124 // Bug 57568 125 126 // AutoNumRules NICHT in die Vorlagen uebernehmen 127 const SfxPoolItem* pItem; 128 const SwNumRule* pRule = 0; 129 if( SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, sal_False ) || 130 SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC,sal_False ) || 131 ( SFX_ITEM_SET == pSet->GetItemState( RES_PARATR_NUMRULE, 132 sal_False, &pItem ) && 0 != (pRule = GetDoc()->FindNumRulePtr( 133 ((SwNumRuleItem*)pItem)->GetValue() )) && 134 pRule && pRule->IsAutoRule() ) 135 ) 136 { 137 SfxItemSet aSet( *pSet ); 138 aSet.ClearItem( RES_BREAK ); 139 aSet.ClearItem( RES_PAGEDESC ); 140 141 if( pRule || (SFX_ITEM_SET == pSet->GetItemState( RES_PARATR_NUMRULE, 142 sal_False, &pItem ) && 0 != (pRule = GetDoc()->FindNumRulePtr( 143 ((SwNumRuleItem*)pItem)->GetValue() )) && 144 pRule && pRule->IsAutoRule() )) 145 aSet.ClearItem( RES_PARATR_NUMRULE ); 146 147 if( aSet.Count() ) 148 GetDoc()->ChgFmt(*pColl, aSet ); 149 } 150 else 151 GetDoc()->ChgFmt(*pColl, *pSet ); 152 } 153 } 154 155 156 157 158