xref: /AOO41X/main/sw/source/core/edit/edatmisc.cxx (revision 69a743679e823ad8f875be547552acb607b8ada5)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #include <editsh.hxx>
28 #include <doc.hxx>      // fuer aNodes
29 #include <IDocumentUndoRedo.hxx>
30 #include <pam.hxx>      // fuer SwPaM
31 #include <edimp.hxx>    // fuer MACROS
32 #include <swundo.hxx>   // fuer die UndoIds
33 #include <ndtxt.hxx>    // fuer Get-/ChgFmt Set-/GetAttrXXX
34 
35 
36 
37 /*************************************
38  * harte Formatierung (Attribute)
39  *************************************/
40 
41 
ResetAttr(const SvUShortsSort * pAttrs)42 void SwEditShell::ResetAttr( const SvUShortsSort* pAttrs )
43 {
44     SET_CURR_SHELL( this );
45     StartAllAction();
46     sal_Bool bUndoGroup = GetCrsr()->GetNext() != GetCrsr();
47     if( bUndoGroup )
48     {
49         GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_RESETATTR, NULL);
50     }
51 
52         FOREACHPAM_START(this)
53             // if ( PCURCRSR->HasMark() )
54                 GetDoc()->ResetAttrs(*PCURCRSR, sal_True, pAttrs);
55         FOREACHPAM_END()
56 
57     if( bUndoGroup )
58     {
59         GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_RESETATTR, NULL);
60     }
61     CallChgLnk();
62     EndAllAction();
63 }
64 
65 
66 
GCAttr()67 void SwEditShell::GCAttr()
68 {
69 //JP 04.02.97: wozu eine Action-Klammerung - ein Formatierung sollte nicht
70 //              ausgeloest werden, so dass es hier ueberfluessig ist.
71 //              Sonst Probleme im MouseBut.DownHdl - Bug 35562
72 //  StartAllAction();
73     FOREACHPAM_START(this)
74         if ( !PCURCRSR->HasMark() )
75         {
76             SwTxtNode *const pTxtNode =
77                 PCURCRSR->GetPoint()->nNode.GetNode().GetTxtNode();
78             if (pTxtNode)
79             {
80                 pTxtNode->GCAttr();
81             }
82         }
83         else
84         {
85             const SwNodeIndex& rEnd = PCURCRSR->End()->nNode;
86             SwNodeIndex aIdx( PCURCRSR->Start()->nNode );
87             SwNode* pNd = &aIdx.GetNode();
88             do {
89                 if( pNd->IsTxtNode() )
90                     ((SwTxtNode*)pNd)->GCAttr();
91             }
92             while( 0 != ( pNd = GetDoc()->GetNodes().GoNext( &aIdx )) &&
93                     aIdx <= rEnd );
94         }
95     FOREACHPAM_END()
96 //  EndAllAction();
97 }
98 
99 // Setze das Attribut als neues default Attribut im Dokument.
100 
101 
SetDefault(const SfxPoolItem & rFmtHint)102 void SwEditShell::SetDefault( const SfxPoolItem& rFmtHint )
103 {
104     // 7502: Action-Klammerung
105     StartAllAction();
106     GetDoc()->SetDefault( rFmtHint );
107     EndAllAction();
108 }
109 
110 /*
111 
112 void SwEditShell::SetDefault( const SfxItemSet& rSet )
113 {
114     // 7502: Action-Klammerung
115     StartAllAction();
116     GetDoc()->SetDefault( rSet );
117     EndAllAction();
118 }
119 */
120 
121 // Erfrage das Default Attribut in diesem Dokument.
122 
GetDefault(sal_uInt16 nFmtHint) const123 const SfxPoolItem& SwEditShell::GetDefault( sal_uInt16 nFmtHint ) const
124 {
125     return GetDoc()->GetDefault( nFmtHint );
126 
127 }
128 
129 
SetAttrItem(const SfxPoolItem & rHint,sal_uInt16 nFlags)130 void SwEditShell::SetAttrItem( const SfxPoolItem& rHint, sal_uInt16 nFlags )
131 {
132     SET_CURR_SHELL( this );
133     StartAllAction();
134     SwPaM* pCrsr = GetCrsr();
135     if( pCrsr->GetNext() != pCrsr )     // Ring von Cursorn
136     {
137         sal_Bool bIsTblMode = IsTableMode();
138         GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL);
139 
140         FOREACHPAM_START(this)
141             if( PCURCRSR->HasMark() && ( bIsTblMode ||
142                 *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() ))
143             {
144                 GetDoc()->InsertPoolItem(*PCURCRSR, rHint, nFlags );
145             }
146         FOREACHPAM_END()
147 
148         GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL);
149     }
150     else
151     {
152         if( !HasSelection() )
153             UpdateAttr();
154         GetDoc()->InsertPoolItem( *pCrsr, rHint, nFlags );
155     }
156     EndAllAction();
157 }
158 
159 
SetAttrSet(const SfxItemSet & rSet,sal_uInt16 nFlags)160 void SwEditShell::SetAttrSet( const SfxItemSet& rSet, sal_uInt16 nFlags )
161 {
162     SET_CURR_SHELL( this );
163     StartAllAction();
164     SwPaM* pCrsr = GetCrsr();
165     if( pCrsr->GetNext() != pCrsr )     // Ring von Cursorn
166     {
167         sal_Bool bIsTblMode = IsTableMode();
168         GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL);
169 
170         FOREACHPAM_START(this)
171             if( PCURCRSR->HasMark() && ( bIsTblMode ||
172                 *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() ))
173             {
174                 GetDoc()->InsertItemSet(*PCURCRSR, rSet, nFlags );
175             }
176         FOREACHPAM_END()
177 
178         GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL);
179     }
180     else
181     {
182         if( !HasSelection() )
183             UpdateAttr();
184         GetDoc()->InsertItemSet( *pCrsr, rSet, nFlags );
185     }
186     EndAllAction();
187 }
188 
189 
190 
191 
192