Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <hintids.hxx>
21 : #include <editeng/brkitem.hxx>
22 : #include <editsh.hxx>
23 : #include <doc.hxx> // fuer SwTxtFmtColls
24 : #include <IDocumentUndoRedo.hxx>
25 : #include <edimp.hxx> // fuer MACROS
26 : #include <ndtxt.hxx>
27 : #include <paratr.hxx>
28 : #include <fmtpdsc.hxx>
29 : #include <viewopt.hxx> // Formular view
30 : #include <SwRewriter.hxx>
31 : #include <numrule.hxx>
32 : #include <swundo.hxx>
33 : #include <docary.hxx>
34 :
35 : /*************************************
36 : * FormatColl
37 : *************************************/
38 : // TXT
39 :
40 :
41 0 : SwTxtFmtColl& SwEditShell::GetDfltTxtFmtColl() const
42 : {
43 0 : return *((SwTxtFmtColl*) (GetDoc()->GetDfltTxtFmtColl()));
44 : }
45 :
46 :
47 0 : sal_uInt16 SwEditShell::GetTxtFmtCollCount() const
48 : {
49 0 : return GetDoc()->GetTxtFmtColls()->size();
50 : }
51 :
52 :
53 0 : SwTxtFmtColl& SwEditShell::GetTxtFmtColl( sal_uInt16 nFmtColl) const
54 : {
55 0 : return *((*(GetDoc()->GetTxtFmtColls()))[nFmtColl]);
56 : }
57 :
58 : // #i62675#
59 0 : void SwEditShell::SetTxtFmtColl( SwTxtFmtColl *pFmt,
60 : bool bResetListAttrs )
61 : {
62 0 : SwTxtFmtColl *pLocal = pFmt? pFmt: (*GetDoc()->GetTxtFmtColls())[0];
63 0 : StartAllAction();
64 :
65 0 : SwRewriter aRewriter;
66 0 : aRewriter.AddRule(UndoArg1, pLocal->GetName());
67 :
68 0 : GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_SETFMTCOLL, &aRewriter);
69 0 : FOREACHPAM_START(this)
70 :
71 0 : if( !PCURCRSR->HasReadonlySel(
72 : // Formular view
73 0 : GetViewOptions()->IsFormView() ) )
74 0 : GetDoc()->SetTxtFmtColl( *PCURCRSR, pLocal, true, bResetListAttrs );
75 :
76 0 : FOREACHPAM_END()
77 0 : GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_SETFMTCOLL, &aRewriter);
78 0 : EndAllAction();
79 0 : }
80 :
81 :
82 0 : SwTxtFmtColl* SwEditShell::MakeTxtFmtColl(const String& rFmtCollName,
83 : SwTxtFmtColl* pParent)
84 : {
85 : SwTxtFmtColl *pColl;
86 0 : if ( pParent == 0 )
87 0 : pParent = &GetTxtFmtColl(0);
88 0 : if ( (pColl=GetDoc()->MakeTxtFmtColl(rFmtCollName, pParent)) == 0 )
89 : {
90 : OSL_FAIL( "MakeTxtFmtColl failed" );
91 : }
92 0 : return pColl;
93 :
94 : }
95 :
96 :
97 0 : void SwEditShell::FillByEx(SwTxtFmtColl* pColl, sal_Bool bReset)
98 : {
99 0 : if( bReset )
100 : {
101 : // #i73790# - method renamed
102 0 : pColl->ResetAllFmtAttr();
103 : }
104 :
105 0 : SwPaM * pCrsr = GetCrsr();
106 0 : SwCntntNode * pCnt = pCrsr->GetCntntNode();
107 0 : const SfxItemSet* pSet = pCnt->GetpSwAttrSet();
108 0 : if( pSet )
109 : {
110 : // JP 05.10.98: falls eines der Attribute Break/PageDesc/NumRule(auto)
111 : // im ItemSet steht, so entferne die VORM setzen an der Collection.
112 : // Ansonst wird zu viel gemacht oder falsche gemacht (NumRules!)
113 : // Bug 57568
114 :
115 : // AutoNumRules NICHT in die Vorlagen uebernehmen
116 : const SfxPoolItem* pItem;
117 0 : const SwNumRule* pRule = 0;
118 0 : if( SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, sal_False ) ||
119 0 : SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC,sal_False ) ||
120 : ( SFX_ITEM_SET == pSet->GetItemState( RES_PARATR_NUMRULE,
121 0 : sal_False, &pItem ) && 0 != (pRule = GetDoc()->FindNumRulePtr(
122 0 : ((SwNumRuleItem*)pItem)->GetValue() )) &&
123 0 : pRule && pRule->IsAutoRule() )
124 : )
125 : {
126 0 : SfxItemSet aSet( *pSet );
127 0 : aSet.ClearItem( RES_BREAK );
128 0 : aSet.ClearItem( RES_PAGEDESC );
129 :
130 0 : if( pRule || (SFX_ITEM_SET == pSet->GetItemState( RES_PARATR_NUMRULE,
131 0 : sal_False, &pItem ) && 0 != (pRule = GetDoc()->FindNumRulePtr(
132 0 : ((SwNumRuleItem*)pItem)->GetValue() )) &&
133 0 : pRule && pRule->IsAutoRule() ))
134 0 : aSet.ClearItem( RES_PARATR_NUMRULE );
135 :
136 0 : if( aSet.Count() )
137 0 : GetDoc()->ChgFmt(*pColl, aSet );
138 : }
139 : else
140 0 : GetDoc()->ChgFmt(*pColl, *pSet );
141 : }
142 0 : }
143 :
144 :
145 :
146 :
147 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|