merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / edit / edatmisc.cxx
blob0c8952ff816e7533942143a3b5006c85df9c7671
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() ))
145 GetDoc()->InsertPoolItem(*PCURCRSR, rHint, nFlags );
147 FOREACHPAM_END()
149 GetDoc()->EndUndo(UNDO_INSATTR, NULL);
151 else
153 if( !HasSelection() )
154 UpdateAttr();
155 GetDoc()->InsertPoolItem( *pCrsr, rHint, nFlags );
157 EndAllAction();
161 void SwEditShell::SetAttr( const SfxItemSet& rSet, USHORT nFlags )
163 SET_CURR_SHELL( this );
164 StartAllAction();
165 SwPaM* pCrsr = GetCrsr();
166 if( pCrsr->GetNext() != pCrsr ) // Ring von Cursorn
168 BOOL bIsTblMode = IsTableMode();
169 GetDoc()->StartUndo(UNDO_INSATTR, NULL);
171 FOREACHPAM_START(this)
172 if( PCURCRSR->HasMark() && ( bIsTblMode ||
173 *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() ))
175 GetDoc()->InsertItemSet(*PCURCRSR, rSet, nFlags );
177 FOREACHPAM_END()
179 GetDoc()->EndUndo(UNDO_INSATTR, NULL);
181 else
183 if( !HasSelection() )
184 UpdateAttr();
185 GetDoc()->InsertItemSet( *pCrsr, rSet, nFlags );
187 EndAllAction();