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() ))
144 GetDoc()->Insert(*PCURCRSR
, rHint
, nFlags
);
147 GetDoc()->EndUndo(UNDO_INSATTR
, NULL
);
151 if( !HasSelection() )
153 GetDoc()->Insert( *pCrsr
, rHint
, nFlags
);
159 void SwEditShell::SetAttr( const SfxItemSet
& rSet
, USHORT nFlags
)
161 SET_CURR_SHELL( this );
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
);
175 GetDoc()->EndUndo(UNDO_INSATTR
, NULL
);
179 if( !HasSelection() )
181 GetDoc()->Insert( *pCrsr
, rSet
, nFlags
);