update dev300-m58
[ooovba.git] / sw / source / core / edit / edatmisc.cxx
blob1913da57a982feb70dab1a68e359909c937670e5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: edatmisc.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <editsh.hxx>
36 #include <doc.hxx> // fuer aNodes
37 #include <pam.hxx> // fuer SwPaM
38 #include <edimp.hxx> // fuer MACROS
39 #include <swundo.hxx> // fuer die UndoIds
40 #include <ndtxt.hxx> // fuer Get-/ChgFmt Set-/GetAttrXXX
44 /*************************************
45 * harte Formatierung (Attribute)
46 *************************************/
49 void SwEditShell::ResetAttr( const SvUShortsSort* pAttrs )
51 SET_CURR_SHELL( this );
52 StartAllAction();
53 BOOL bUndoGroup = GetCrsr()->GetNext() != GetCrsr();
54 if( bUndoGroup )
55 GetDoc()->StartUndo(UNDO_RESETATTR, NULL);
57 FOREACHPAM_START(this)
58 // if ( PCURCRSR->HasMark() )
59 GetDoc()->ResetAttrs(*PCURCRSR, sal_True, pAttrs);
60 FOREACHPAM_END()
62 if( bUndoGroup )
63 GetDoc()->EndUndo(UNDO_RESETATTR, NULL);
64 CallChgLnk();
65 EndAllAction();
70 void SwEditShell::GCAttr()
72 //JP 04.02.97: wozu eine Action-Klammerung - ein Formatierung sollte nicht
73 // ausgeloest werden, so dass es hier ueberfluessig ist.
74 // Sonst Probleme im MouseBut.DownHdl - Bug 35562
75 // StartAllAction();
76 FOREACHPAM_START(this)
77 SwTxtNode *pTxtNode;
78 if ( !PCURCRSR->HasMark() )
80 if( 0 != (pTxtNode = GetDoc()->GetNodes()[
81 PCURCRSR->GetPoint()->nNode]->GetTxtNode()))
82 pTxtNode->GCAttr();
84 else
86 const SwNodeIndex& rEnd = PCURCRSR->End()->nNode;
87 SwNodeIndex aIdx( PCURCRSR->Start()->nNode );
88 SwNode* pNd = &aIdx.GetNode();
89 do {
90 if( pNd->IsTxtNode() )
91 ((SwTxtNode*)pNd)->GCAttr();
93 while( 0 != ( pNd = GetDoc()->GetNodes().GoNext( &aIdx )) &&
94 aIdx <= rEnd );
96 FOREACHPAM_END()
97 // EndAllAction();
100 // Setze das Attribut als neues default Attribut im Dokument.
103 void SwEditShell::SetDefault( const SfxPoolItem& rFmtHint )
105 // 7502: Action-Klammerung
106 StartAllAction();
107 GetDoc()->SetDefault( rFmtHint );
108 EndAllAction();
113 void SwEditShell::SetDefault( const SfxItemSet& rSet )
115 // 7502: Action-Klammerung
116 StartAllAction();
117 GetDoc()->SetDefault( rSet );
118 EndAllAction();
122 // Erfrage das Default Attribut in diesem Dokument.
124 const SfxPoolItem& SwEditShell::GetDefault( USHORT nFmtHint ) const
126 return GetDoc()->GetDefault( nFmtHint );
131 void SwEditShell::SetAttr( const SfxPoolItem& rHint, USHORT nFlags )
133 SET_CURR_SHELL( this );
134 StartAllAction();
135 SwPaM* pCrsr = GetCrsr();
136 if( pCrsr->GetNext() != pCrsr ) // Ring von Cursorn
138 BOOL bIsTblMode = IsTableMode();
139 GetDoc()->StartUndo(UNDO_INSATTR, NULL);
141 FOREACHPAM_START(this)
142 if( PCURCRSR->HasMark() && ( bIsTblMode ||
143 *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() ))
144 GetDoc()->Insert(*PCURCRSR, rHint, nFlags );
145 FOREACHPAM_END()
147 GetDoc()->EndUndo(UNDO_INSATTR, NULL);
149 else
151 if( !HasSelection() )
152 UpdateAttr();
153 GetDoc()->Insert( *pCrsr, rHint, nFlags );
155 EndAllAction();
159 void SwEditShell::SetAttr( const SfxItemSet& rSet, USHORT nFlags )
161 SET_CURR_SHELL( this );
162 StartAllAction();
163 SwPaM* pCrsr = GetCrsr();
164 if( pCrsr->GetNext() != pCrsr ) // Ring von Cursorn
166 BOOL bIsTblMode = IsTableMode();
167 GetDoc()->StartUndo(UNDO_INSATTR, NULL);
169 FOREACHPAM_START(this)
170 if( PCURCRSR->HasMark() && ( bIsTblMode ||
171 *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() ))
172 GetDoc()->Insert(*PCURCRSR, rSet, nFlags );
173 FOREACHPAM_END()
175 GetDoc()->EndUndo(UNDO_INSATTR, NULL);
177 else
179 if( !HasSelection() )
180 UpdateAttr();
181 GetDoc()->Insert( *pCrsr, rSet, nFlags );
183 EndAllAction();