1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 #include <editsh.hxx> 32 #include <doc.hxx> // fuer aNodes 33 #include <IDocumentUndoRedo.hxx> 34 #include <pam.hxx> // fuer SwPaM 35 #include <edimp.hxx> // fuer MACROS 36 #include <swundo.hxx> // fuer die UndoIds 37 #include <ndtxt.hxx> // fuer Get-/ChgFmt Set-/GetAttrXXX 38 39 40 41 /************************************* 42 * harte Formatierung (Attribute) 43 *************************************/ 44 45 46 void SwEditShell::ResetAttr( const SvUShortsSort* pAttrs ) 47 { 48 SET_CURR_SHELL( this ); 49 StartAllAction(); 50 sal_Bool bUndoGroup = GetCrsr()->GetNext() != GetCrsr(); 51 if( bUndoGroup ) 52 { 53 GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_RESETATTR, NULL); 54 } 55 56 FOREACHPAM_START(this) 57 // if ( PCURCRSR->HasMark() ) 58 GetDoc()->ResetAttrs(*PCURCRSR, sal_True, pAttrs); 59 FOREACHPAM_END() 60 61 if( bUndoGroup ) 62 { 63 GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_RESETATTR, NULL); 64 } 65 CallChgLnk(); 66 EndAllAction(); 67 } 68 69 70 71 void SwEditShell::GCAttr() 72 { 73 //JP 04.02.97: wozu eine Action-Klammerung - ein Formatierung sollte nicht 74 // ausgeloest werden, so dass es hier ueberfluessig ist. 75 // Sonst Probleme im MouseBut.DownHdl - Bug 35562 76 // StartAllAction(); 77 FOREACHPAM_START(this) 78 if ( !PCURCRSR->HasMark() ) 79 { 80 SwTxtNode *const pTxtNode = 81 PCURCRSR->GetPoint()->nNode.GetNode().GetTxtNode(); 82 if (pTxtNode) 83 { 84 pTxtNode->GCAttr(); 85 } 86 } 87 else 88 { 89 const SwNodeIndex& rEnd = PCURCRSR->End()->nNode; 90 SwNodeIndex aIdx( PCURCRSR->Start()->nNode ); 91 SwNode* pNd = &aIdx.GetNode(); 92 do { 93 if( pNd->IsTxtNode() ) 94 ((SwTxtNode*)pNd)->GCAttr(); 95 } 96 while( 0 != ( pNd = GetDoc()->GetNodes().GoNext( &aIdx )) && 97 aIdx <= rEnd ); 98 } 99 FOREACHPAM_END() 100 // EndAllAction(); 101 } 102 103 // Setze das Attribut als neues default Attribut im Dokument. 104 105 106 void SwEditShell::SetDefault( const SfxPoolItem& rFmtHint ) 107 { 108 // 7502: Action-Klammerung 109 StartAllAction(); 110 GetDoc()->SetDefault( rFmtHint ); 111 EndAllAction(); 112 } 113 114 /* 115 116 void SwEditShell::SetDefault( const SfxItemSet& rSet ) 117 { 118 // 7502: Action-Klammerung 119 StartAllAction(); 120 GetDoc()->SetDefault( rSet ); 121 EndAllAction(); 122 } 123 */ 124 125 // Erfrage das Default Attribut in diesem Dokument. 126 127 const SfxPoolItem& SwEditShell::GetDefault( sal_uInt16 nFmtHint ) const 128 { 129 return GetDoc()->GetDefault( nFmtHint ); 130 131 } 132 133 134 void SwEditShell::SetAttr( const SfxPoolItem& rHint, sal_uInt16 nFlags ) 135 { 136 SET_CURR_SHELL( this ); 137 StartAllAction(); 138 SwPaM* pCrsr = GetCrsr(); 139 if( pCrsr->GetNext() != pCrsr ) // Ring von Cursorn 140 { 141 sal_Bool bIsTblMode = IsTableMode(); 142 GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL); 143 144 FOREACHPAM_START(this) 145 if( PCURCRSR->HasMark() && ( bIsTblMode || 146 *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() )) 147 { 148 GetDoc()->InsertPoolItem(*PCURCRSR, rHint, nFlags ); 149 } 150 FOREACHPAM_END() 151 152 GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL); 153 } 154 else 155 { 156 if( !HasSelection() ) 157 UpdateAttr(); 158 GetDoc()->InsertPoolItem( *pCrsr, rHint, nFlags ); 159 } 160 EndAllAction(); 161 } 162 163 164 void SwEditShell::SetAttr( const SfxItemSet& rSet, sal_uInt16 nFlags ) 165 { 166 SET_CURR_SHELL( this ); 167 StartAllAction(); 168 SwPaM* pCrsr = GetCrsr(); 169 if( pCrsr->GetNext() != pCrsr ) // Ring von Cursorn 170 { 171 sal_Bool bIsTblMode = IsTableMode(); 172 GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL); 173 174 FOREACHPAM_START(this) 175 if( PCURCRSR->HasMark() && ( bIsTblMode || 176 *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() )) 177 { 178 GetDoc()->InsertItemSet(*PCURCRSR, rSet, nFlags ); 179 } 180 FOREACHPAM_END() 181 182 GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL); 183 } 184 else 185 { 186 if( !HasSelection() ) 187 UpdateAttr(); 188 GetDoc()->InsertItemSet( *pCrsr, rSet, nFlags ); 189 } 190 EndAllAction(); 191 } 192 193 194 195 196