1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: edatmisc.cxx,v $
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"
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 );
53 BOOL bUndoGroup
= GetCrsr()->GetNext() != GetCrsr();
55 GetDoc()->StartUndo(UNDO_RESETATTR
, NULL
);
57 FOREACHPAM_START(this)
58 // if ( PCURCRSR->HasMark() )
59 GetDoc()->ResetAttrs(*PCURCRSR
, sal_True
, pAttrs
);
63 GetDoc()->EndUndo(UNDO_RESETATTR
, NULL
);
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
76 FOREACHPAM_START(this)
78 if ( !PCURCRSR
->HasMark() )
80 if( 0 != (pTxtNode
= GetDoc()->GetNodes()[
81 PCURCRSR
->GetPoint()->nNode
]->GetTxtNode()))
86 const SwNodeIndex
& rEnd
= PCURCRSR
->End()->nNode
;
87 SwNodeIndex
aIdx( PCURCRSR
->Start()->nNode
);
88 SwNode
* pNd
= &aIdx
.GetNode();
90 if( pNd
->IsTxtNode() )
91 ((SwTxtNode
*)pNd
)->GCAttr();
93 while( 0 != ( pNd
= GetDoc()->GetNodes().GoNext( &aIdx
)) &&
100 // Setze das Attribut als neues default Attribut im Dokument.
103 void SwEditShell::SetDefault( const SfxPoolItem
& rFmtHint
)
105 // 7502: Action-Klammerung
107 GetDoc()->SetDefault( rFmtHint
);
113 void SwEditShell::SetDefault( const SfxItemSet& rSet )
115 // 7502: Action-Klammerung
117 GetDoc()->SetDefault( rSet );
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 );
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
);
149 GetDoc()->EndUndo(UNDO_INSATTR
, NULL
);
153 if( !HasSelection() )
155 GetDoc()->InsertPoolItem( *pCrsr
, rHint
, nFlags
);
161 void SwEditShell::SetAttr( const SfxItemSet
& rSet
, USHORT nFlags
)
163 SET_CURR_SHELL( this );
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
);
179 GetDoc()->EndUndo(UNDO_INSATTR
, NULL
);
183 if( !HasSelection() )
185 GetDoc()->InsertItemSet( *pCrsr
, rSet
, nFlags
);