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 .
21 #include <redline.hxx>
24 #include <frmtool.hxx>
26 RedlineFlags
SwEditShell::GetRedlineFlags() const
28 return GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags();
31 void SwEditShell::SetRedlineFlags( RedlineFlags eMode
)
33 if( eMode
!= GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags() )
35 CurrShell
aCurr( this );
37 GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags( eMode
);
42 bool SwEditShell::IsRedlineOn() const
44 return GetDoc()->getIDocumentRedlineAccess().IsRedlineOn();
47 SwRedlineTable::size_type
SwEditShell::GetRedlineCount() const
49 return GetDoc()->getIDocumentRedlineAccess().GetRedlineTable().size();
52 const SwRangeRedline
& SwEditShell::GetRedline( SwRedlineTable::size_type nPos
) const
54 return *GetDoc()->getIDocumentRedlineAccess().GetRedlineTable()[ nPos
];
57 static void lcl_InvalidateAll( SwViewShell
* pSh
)
59 for(SwViewShell
& rCurrentShell
: pSh
->GetRingContainer())
61 if ( rCurrentShell
.GetWin() )
62 rCurrentShell
.GetWin()->Invalidate();
66 bool SwEditShell::AcceptRedline( SwRedlineTable::size_type nPos
)
68 CurrShell
aCurr( this );
70 bool bRet
= GetDoc()->getIDocumentRedlineAccess().AcceptRedline( nPos
, true );
71 if( !nPos
&& !::IsExtraData( GetDoc() ) )
72 lcl_InvalidateAll( this );
77 bool SwEditShell::RejectRedline( SwRedlineTable::size_type nPos
)
79 CurrShell
aCurr( this );
81 bool bRet
= GetDoc()->getIDocumentRedlineAccess().RejectRedline( nPos
, true );
82 if( !nPos
&& !::IsExtraData( GetDoc() ) )
83 lcl_InvalidateAll( this );
88 bool SwEditShell::AcceptRedlinesInSelection()
90 CurrShell
aCurr( this );
92 bool bRet
= GetDoc()->getIDocumentRedlineAccess().AcceptRedline( *GetCursor(), true );
97 bool SwEditShell::RejectRedlinesInSelection()
99 CurrShell
aCurr( this );
101 bool bRet
= GetDoc()->getIDocumentRedlineAccess().RejectRedline( *GetCursor(), true );
106 // Set the comment at the Redline
107 bool SwEditShell::SetRedlineComment( const OUString
& rS
)
110 for(const SwPaM
& rPaM
: GetCursor()->GetRingContainer())
112 bRet
= bRet
|| GetDoc()->getIDocumentRedlineAccess().SetRedlineComment( rPaM
, rS
);
118 const SwRangeRedline
* SwEditShell::GetCurrRedline() const
120 if (const SwRangeRedline
* pRed
= GetDoc()->getIDocumentRedlineAccess().GetRedline( *GetCursor()->GetPoint(), nullptr ))
122 // check the other side of the selection to handle completely selected changes, where the Point is at the end
123 return GetDoc()->getIDocumentRedlineAccess().GetRedline( *GetCursor()->GetMark(), nullptr );
126 void SwEditShell::UpdateRedlineAttr()
128 if( IDocumentRedlineAccess::IsShowChanges(GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags()) )
130 CurrShell
aCurr( this );
133 GetDoc()->getIDocumentRedlineAccess().UpdateRedlineAttr();
139 /** Search the Redline of the data given
141 * @return Returns the Pos of the Array, or SwRedlineTable::npos if not present
143 SwRedlineTable::size_type
SwEditShell::FindRedlineOfData( const SwRedlineData
& rData
) const
145 const SwRedlineTable
& rTable
= GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
147 for( SwRedlineTable::size_type i
= 0, nCnt
= rTable
.size(); i
< nCnt
; ++i
)
148 if( &rTable
[ i
]->GetRedlineData() == &rData
)
150 return SwRedlineTable::npos
;
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */