Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <editsh.hxx>
31 : : #include <doc.hxx> // fuer aNodes
32 : : #include <IDocumentUndoRedo.hxx>
33 : : #include <pam.hxx> // fuer SwPaM
34 : : #include <edimp.hxx> // fuer MACROS
35 : : #include <swundo.hxx> // fuer die UndoIds
36 : : #include <ndtxt.hxx> // fuer Get-/ChgFmt Set-/GetAttrXXX
37 : :
38 : :
39 : :
40 : : /*************************************
41 : : * harte Formatierung (Attribute)
42 : : *************************************/
43 : :
44 : :
45 : 0 : void SwEditShell::ResetAttr( const std::set<sal_uInt16> &attrs, SwPaM* pPaM )
46 : : {
47 [ # # ]: 0 : SET_CURR_SHELL( this );
48 [ # # ][ # # ]: 0 : SwPaM* pCrsr = pPaM ? pPaM : GetCrsr( );
49 : :
50 [ # # ]: 0 : StartAllAction();
51 : 0 : sal_Bool bUndoGroup = pCrsr->GetNext() != pCrsr;
52 [ # # ]: 0 : if( bUndoGroup )
53 : : {
54 [ # # ][ # # ]: 0 : GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_RESETATTR, NULL);
55 : : }
56 : :
57 : 0 : SwPaM* pStartCrsr = pCrsr;
58 [ # # ]: 0 : do {
59 [ # # ]: 0 : GetDoc()->ResetAttrs(*pCrsr, sal_True, attrs);
60 : 0 : } while ( ( pCrsr = ( SwPaM* ) pCrsr->GetNext() ) != pStartCrsr );
61 : :
62 [ # # ]: 0 : if( bUndoGroup )
63 : : {
64 [ # # ][ # # ]: 0 : GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_RESETATTR, NULL);
65 : : }
66 [ # # ]: 0 : CallChgLnk();
67 [ # # ][ # # ]: 0 : EndAllAction();
68 : 0 : }
69 : :
70 : :
71 : :
72 : 0 : void SwEditShell::GCAttr()
73 : : {
74 [ # # ]: 0 : FOREACHPAM_START(this)
75 [ # # ]: 0 : if ( !PCURCRSR->HasMark() )
76 : : {
77 : : SwTxtNode *const pTxtNode =
78 : 0 : PCURCRSR->GetPoint()->nNode.GetNode().GetTxtNode();
79 [ # # ]: 0 : if (pTxtNode)
80 : : {
81 : 0 : pTxtNode->GCAttr();
82 : : }
83 : : }
84 : : else
85 : : {
86 [ # # ]: 0 : const SwNodeIndex& rEnd = PCURCRSR->End()->nNode;
87 [ # # ][ # # ]: 0 : SwNodeIndex aIdx( PCURCRSR->Start()->nNode );
88 : 0 : SwNode* pNd = &aIdx.GetNode();
89 [ # # # # ]: 0 : do {
[ # # ]
90 [ # # ]: 0 : if( pNd->IsTxtNode() )
91 [ # # ][ # # ]: 0 : ((SwTxtNode*)pNd)->GCAttr();
92 : : }
93 [ # # ][ # # ]: 0 : while( 0 != ( pNd = GetDoc()->GetNodes().GoNext( &aIdx )) &&
[ # # ]
94 [ # # ]: 0 : aIdx <= rEnd );
95 : : }
96 : 0 : FOREACHPAM_END()
97 : 0 : }
98 : :
99 : : // Setze das Attribut als neues default Attribut im Dokument.
100 : :
101 : :
102 : 0 : void SwEditShell::SetDefault( const SfxPoolItem& rFmtHint )
103 : : {
104 : : // 7502: Action-Klammerung
105 : 0 : StartAllAction();
106 : 0 : GetDoc()->SetDefault( rFmtHint );
107 : 0 : EndAllAction();
108 : 0 : }
109 : :
110 : : // Erfrage das Default Attribut in diesem Dokument.
111 : :
112 : 670 : const SfxPoolItem& SwEditShell::GetDefault( sal_uInt16 nFmtHint ) const
113 : : {
114 : 670 : return GetDoc()->GetDefault( nFmtHint );
115 : :
116 : : }
117 : :
118 : :
119 : 0 : void SwEditShell::SetAttr( const SfxPoolItem& rHint, sal_uInt16 nFlags )
120 : : {
121 [ # # ]: 0 : SET_CURR_SHELL( this );
122 [ # # ]: 0 : StartAllAction();
123 [ # # ]: 0 : SwPaM* pCrsr = GetCrsr();
124 [ # # ]: 0 : if( pCrsr->GetNext() != pCrsr ) // Ring von Cursorn
125 : : {
126 : 0 : sal_Bool bIsTblMode = IsTableMode();
127 [ # # ][ # # ]: 0 : GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL);
128 : :
129 [ # # ][ # # ]: 0 : FOREACHPAM_START(this)
130 [ # # ][ # # ]: 0 : if( PCURCRSR->HasMark() && ( bIsTblMode ||
[ # # ][ # # ]
131 [ # # ]: 0 : *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() ))
132 : : {
133 [ # # ]: 0 : GetDoc()->InsertPoolItem(*PCURCRSR, rHint, nFlags );
134 : : }
135 : 0 : FOREACHPAM_END()
136 : :
137 [ # # ][ # # ]: 0 : GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL);
138 : : }
139 : : else
140 : : {
141 [ # # ][ # # ]: 0 : if( !HasSelection() )
142 : 0 : UpdateAttr();
143 [ # # ]: 0 : GetDoc()->InsertPoolItem( *pCrsr, rHint, nFlags );
144 : : }
145 [ # # ][ # # ]: 0 : EndAllAction();
146 : 0 : }
147 : :
148 : :
149 : 0 : void SwEditShell::SetAttr( const SfxItemSet& rSet, sal_uInt16 nFlags, SwPaM* pPaM )
150 : : {
151 [ # # ]: 0 : SET_CURR_SHELL( this );
152 : :
153 [ # # ][ # # ]: 0 : SwPaM* pCrsr = pPaM ? pPaM : GetCrsr();
154 [ # # ]: 0 : StartAllAction();
155 [ # # ]: 0 : if( pCrsr->GetNext() != pCrsr ) // Ring von Cursorn
156 : : {
157 : 0 : sal_Bool bIsTblMode = IsTableMode();
158 [ # # ][ # # ]: 0 : GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL);
159 : :
160 : 0 : SwPaM* pTmpCrsr = pCrsr;
161 : 0 : SwPaM* pStartPaM = pCrsr;
162 [ # # ]: 0 : do {
163 [ # # ][ # # ]: 0 : if( pTmpCrsr->HasMark() && ( bIsTblMode ||
[ # # ][ # # ]
164 [ # # ]: 0 : *pTmpCrsr->GetPoint() != *pTmpCrsr->GetMark() ))
165 : : {
166 [ # # ]: 0 : GetDoc()->InsertItemSet(*pTmpCrsr, rSet, nFlags );
167 : : }
168 : 0 : } while ( ( pTmpCrsr = (SwPaM*)pTmpCrsr->GetNext() ) != pStartPaM );
169 : :
170 [ # # ][ # # ]: 0 : GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL);
171 : : }
172 : : else
173 : : {
174 [ # # ][ # # ]: 0 : if( !HasSelection() )
175 : 0 : UpdateAttr();
176 [ # # ]: 0 : GetDoc()->InsertItemSet( *pCrsr, rSet, nFlags );
177 : : }
178 [ # # ][ # # ]: 0 : EndAllAction();
179 : 0 : }
180 : :
181 : :
182 : :
183 : :
184 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|