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( 81 // --> FME 2004-06-29 #114856# Formular view 82 GetViewOptions()->IsFormView() ) ) 83 // <-- 84 GetDoc()->SetTxtFmtColl( *PCURCRSR, pLocal, true, bResetListAttrs ); 85 86 FOREACHPAM_END() 87 GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_SETFMTCOLL, &aRewriter); 88 EndAllAction(); 89 } 90 // <-- 91 92 93 SwTxtFmtColl* SwEditShell::MakeTxtFmtColl(const String& rFmtCollName, 94 SwTxtFmtColl* pParent) 95 { 96 SwTxtFmtColl *pColl; 97 if ( pParent == 0 ) 98 pParent = &GetTxtFmtColl(0); 99 if ( (pColl=GetDoc()->MakeTxtFmtColl(rFmtCollName, pParent)) == 0 ) 100 { 101 ASSERT( sal_False, "MakeTxtFmtColl failed" ) 102 } 103 return pColl; 104 105 } 106 107 108 void SwEditShell::FillByEx(SwTxtFmtColl* pColl, sal_Bool bReset) 109 { 110 if( bReset ) 111 { 112 // --> OD 2007-01-25 #i73790# - method renamed 113 pColl->ResetAllFmtAttr(); 114 // <-- 115 } 116 117 SwPaM * pCrsr = GetCrsr(); 118 SwCntntNode * pCnt = pCrsr->GetCntntNode(); 119 const SfxItemSet* pSet = pCnt->GetpSwAttrSet(); 120 if( pSet ) 121 { 122 // JP 05.10.98: falls eines der Attribute Break/PageDesc/NumRule(auto) 123 // im ItemSet steht, so entferne die VORM setzen an der Collection. 124 // Ansonst wird zu viel gemacht oder falsche gemacht (NumRules!) 125 // Bug 57568 126 127 // AutoNumRules NICHT in die Vorlagen uebernehmen 128 const SfxPoolItem* pItem; 129 const SwNumRule* pRule = 0; 130 if( SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, sal_False ) || 131 SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC,sal_False ) || 132 ( SFX_ITEM_SET == pSet->GetItemState( RES_PARATR_NUMRULE, 133 sal_False, &pItem ) && 0 != (pRule = GetDoc()->FindNumRulePtr( 134 ((SwNumRuleItem*)pItem)->GetValue() )) && 135 pRule && pRule->IsAutoRule() ) 136 ) 137 { 138 SfxItemSet aSet( *pSet ); 139 aSet.ClearItem( RES_BREAK ); 140 aSet.ClearItem( RES_PAGEDESC ); 141 142 if( pRule || (SFX_ITEM_SET == pSet->GetItemState( RES_PARATR_NUMRULE, 143 sal_False, &pItem ) && 0 != (pRule = GetDoc()->FindNumRulePtr( 144 ((SwNumRuleItem*)pItem)->GetValue() )) && 145 pRule && pRule->IsAutoRule() )) 146 aSet.ClearItem( RES_PARATR_NUMRULE ); 147 148 if( aSet.Count() ) 149 GetDoc()->ChgFmt(*pColl, aSet ); 150 } 151 else 152 GetDoc()->ChgFmt(*pColl, *pSet ); 153 } 154 } 155 156 157 158 159