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: edfcol.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"
35 #include <hintids.hxx>
36 #include <svx/brkitem.hxx>
38 #include <doc.hxx> // fuer SwTxtFmtColls
39 #include <edimp.hxx> // fuer MACROS
42 #include <fmtpdsc.hxx>
43 // --> FME 2004-06-29 #114856# Formular view
44 #include <viewopt.hxx>
46 #include <SwRewriter.hxx>
50 /*************************************
52 *************************************/
56 SwTxtFmtColl
& SwEditShell::GetDfltTxtFmtColl() const
58 return *((SwTxtFmtColl
*) (GetDoc()->GetDfltTxtFmtColl()));
62 USHORT
SwEditShell::GetTxtFmtCollCount() const
64 return GetDoc()->GetTxtFmtColls()->Count();
68 SwTxtFmtColl
& SwEditShell::GetTxtFmtColl( USHORT nFmtColl
) const
70 return *((*(GetDoc()->GetTxtFmtColls()))[nFmtColl
]);
73 // --> OD 2007-11-06 #i62675#
74 void SwEditShell::SetTxtFmtColl( SwTxtFmtColl
*pFmt
,
75 bool bResetListAttrs
)
77 SwTxtFmtColl
*pLocal
= pFmt
? pFmt
: (*GetDoc()->GetTxtFmtColls())[0];
81 aRewriter
.AddRule(UNDO_ARG1
, pLocal
->GetName());
83 GetDoc()->StartUndo(UNDO_SETFMTCOLL
, &aRewriter
);
84 FOREACHPAM_START(this)
86 if( !PCURCRSR
->HasReadonlySel(
87 // --> FME 2004-06-29 #114856# Formular view
88 GetViewOptions()->IsFormView() ) )
90 GetDoc()->SetTxtFmtColl( *PCURCRSR
, pLocal
, true, bResetListAttrs
);
93 GetDoc()->EndUndo(UNDO_SETFMTCOLL
, NULL
);
99 SwTxtFmtColl
* SwEditShell::MakeTxtFmtColl(const String
& rFmtCollName
,
100 SwTxtFmtColl
* pParent
)
104 pParent
= &GetTxtFmtColl(0);
105 if ( (pColl
=GetDoc()->MakeTxtFmtColl(rFmtCollName
, pParent
)) == 0 )
107 ASSERT( FALSE
, "MakeTxtFmtColl failed" )
114 void SwEditShell::FillByEx(SwTxtFmtColl
* pColl
, BOOL bReset
)
118 // --> OD 2007-01-25 #i73790# - method renamed
119 pColl
->ResetAllFmtAttr();
123 SwPaM
* pCrsr
= GetCrsr();
124 SwCntntNode
* pCnt
= pCrsr
->GetCntntNode();
125 const SfxItemSet
* pSet
= pCnt
->GetpSwAttrSet();
128 // JP 05.10.98: falls eines der Attribute Break/PageDesc/NumRule(auto)
129 // im ItemSet steht, so entferne die VORM setzen an der Collection.
130 // Ansonst wird zu viel gemacht oder falsche gemacht (NumRules!)
133 // AutoNumRules NICHT in die Vorlagen uebernehmen
134 const SfxPoolItem
* pItem
;
135 const SwNumRule
* pRule
= 0;
136 if( SFX_ITEM_SET
== pSet
->GetItemState( RES_BREAK
, FALSE
) ||
137 SFX_ITEM_SET
== pSet
->GetItemState( RES_PAGEDESC
,FALSE
) ||
138 ( SFX_ITEM_SET
== pSet
->GetItemState( RES_PARATR_NUMRULE
,
139 FALSE
, &pItem
) && 0 != (pRule
= GetDoc()->FindNumRulePtr(
140 ((SwNumRuleItem
*)pItem
)->GetValue() )) &&
141 pRule
&& pRule
->IsAutoRule() )
144 SfxItemSet
aSet( *pSet
);
145 aSet
.ClearItem( RES_BREAK
);
146 aSet
.ClearItem( RES_PAGEDESC
);
148 if( pRule
|| (SFX_ITEM_SET
== pSet
->GetItemState( RES_PARATR_NUMRULE
,
149 FALSE
, &pItem
) && 0 != (pRule
= GetDoc()->FindNumRulePtr(
150 ((SwNumRuleItem
*)pItem
)->GetValue() )) &&
151 pRule
&& pRule
->IsAutoRule() ))
152 aSet
.ClearItem( RES_PARATR_NUMRULE
);
155 GetDoc()->ChgFmt(*pColl
, aSet
);
158 GetDoc()->ChgFmt(*pColl
, *pSet
);