1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <IDocumentUndoRedo.hxx>
23 #include <IDocumentRedlineAccess.hxx>
29 * hard formatting (Attribute)
32 void SwEditShell::ResetAttr( const o3tl::sorted_vector
<sal_uInt16
> &attrs
, SwPaM
* pPaM
)
34 CurrShell
aCurr( this );
35 SwPaM
* pCursor
= pPaM
? pPaM
: GetCursor( );
38 bool bUndoGroup
= pCursor
->GetNext() != pCursor
;
41 GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::RESETATTR
, nullptr);
44 for(const SwPaM
& rCurrentCursor
: pCursor
->GetRingContainer())
45 GetDoc()->ResetAttrs(rCurrentCursor
, true, attrs
, true, GetLayout());
49 GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::RESETATTR
, nullptr);
55 void SwEditShell::GCAttr()
57 for(SwPaM
& rPaM
: GetCursor()->GetRingContainer())
59 if ( !rPaM
.HasMark() )
61 SwTextNode
*const pTextNode
=
62 rPaM
.GetPoint()->GetNode().GetTextNode();
70 const SwNode
& rEnd
= rPaM
.End()->GetNode();
71 SwNodeIndex
aIdx( rPaM
.Start()->GetNode() );
72 SwNode
* pNd
= &aIdx
.GetNode();
74 if( pNd
->IsTextNode() )
75 static_cast<SwTextNode
*>(pNd
)->GCAttr();
77 while( nullptr != ( pNd
= GetDoc()->GetNodes().GoNext( &aIdx
)) &&
83 /// Set the attribute as new default attribute in the document.
84 void SwEditShell::SetDefault( const SfxPoolItem
& rFormatHint
)
86 // 7502: Action-Parenthesis
88 GetDoc()->SetDefault( rFormatHint
);
92 /// request the default attribute in this document.
93 const SfxPoolItem
& SwEditShell::GetDefault( sal_uInt16 nFormatHint
) const
95 return GetDoc()->GetDefault( nFormatHint
);
98 void SwEditShell::SetAttrItem( const SfxPoolItem
& rHint
, SetAttrMode nFlags
, const bool /*bParagraphSetting*/ )
100 CurrShell
aCurr( this );
102 SwPaM
* pCursor
= GetCursor();
103 if( pCursor
->GetNext() != pCursor
) // Ring of Cursors
105 bool bIsTableMode
= IsTableMode();
106 GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSATTR
, nullptr);
108 for(SwPaM
& rPaM
: GetCursor()->GetRingContainer())
110 if( rPaM
.HasMark() && ( bIsTableMode
||
111 *rPaM
.GetPoint() != *rPaM
.GetMark() ))
113 GetDoc()->getIDocumentContentOperations().InsertPoolItem(rPaM
, rHint
, nFlags
, GetLayout());
117 GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSATTR
, nullptr);
121 if( !HasSelection() )
124 GetDoc()->getIDocumentContentOperations().InsertPoolItem(*pCursor
, rHint
, nFlags
, GetLayout());
129 void SwEditShell::SetAttrSet( const SfxItemSet
& rSet
, SetAttrMode nFlags
, SwPaM
* pPaM
, const bool /*bParagraphSetting*/ )
131 CurrShell
aCurr( this );
132 SwPaM
* pCursor
= pPaM
? pPaM
: GetCursor();
134 if( pCursor
->GetNext() != pCursor
) // Ring of Cursors
136 bool bIsTableMode
= IsTableMode();
137 GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSATTR
, nullptr);
139 for(SwPaM
& rTmpCursor
: pCursor
->GetRingContainer())
141 if( rTmpCursor
.HasMark() && ( bIsTableMode
||
142 *rTmpCursor
.GetPoint() != *rTmpCursor
.GetMark() ))
144 GetDoc()->getIDocumentContentOperations().InsertItemSet(rTmpCursor
, rSet
, nFlags
, GetLayout());
148 GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSATTR
, nullptr);
152 if( !HasSelection() )
155 GetDoc()->getIDocumentContentOperations().InsertItemSet(*pCursor
, rSet
, nFlags
, GetLayout());
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */