update dev300-m58
[ooovba.git] / sw / source / core / edit / edfcol.cxx
blob273316e06996130fe16fcac7d1485ccc547cb8c7
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: edfcol.cxx,v $
10 * $Revision: 1.11 $
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>
37 #include <editsh.hxx>
38 #include <doc.hxx> // fuer SwTxtFmtColls
39 #include <edimp.hxx> // fuer MACROS
40 #include <ndtxt.hxx>
41 #include <paratr.hxx>
42 #include <fmtpdsc.hxx>
43 // --> FME 2004-06-29 #114856# Formular view
44 #include <viewopt.hxx>
45 // <--
46 #include <SwRewriter.hxx>
47 #include <undobj.hxx>
48 #include <swundo.hxx>
50 /*************************************
51 * FormatColl
52 *************************************/
53 // TXT
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];
78 StartAllAction();
80 SwRewriter aRewriter;
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() ) )
89 // <--
90 GetDoc()->SetTxtFmtColl( *PCURCRSR, pLocal, true, bResetListAttrs );
92 FOREACHPAM_END()
93 GetDoc()->EndUndo(UNDO_SETFMTCOLL, NULL);
94 EndAllAction();
96 // <--
99 SwTxtFmtColl* SwEditShell::MakeTxtFmtColl(const String& rFmtCollName,
100 SwTxtFmtColl* pParent)
102 SwTxtFmtColl *pColl;
103 if ( pParent == 0 )
104 pParent = &GetTxtFmtColl(0);
105 if ( (pColl=GetDoc()->MakeTxtFmtColl(rFmtCollName, pParent)) == 0 )
107 ASSERT( FALSE, "MakeTxtFmtColl failed" )
109 return pColl;
114 void SwEditShell::FillByEx(SwTxtFmtColl* pColl, BOOL bReset)
116 if( bReset )
118 // --> OD 2007-01-25 #i73790# - method renamed
119 pColl->ResetAllFmtAttr();
120 // <--
123 SwPaM * pCrsr = GetCrsr();
124 SwCntntNode * pCnt = pCrsr->GetCntntNode();
125 const SfxItemSet* pSet = pCnt->GetpSwAttrSet();
126 if( pSet )
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!)
131 // Bug 57568
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 );
154 if( aSet.Count() )
155 GetDoc()->ChgFmt(*pColl, aSet );
157 else
158 GetDoc()->ChgFmt(*pColl, *pSet );