nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / core / edit / edredln.cxx
bloba1ff08b5df9cceb349e29b5d3385af7420e62cdd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <docary.hxx>
21 #include <redline.hxx>
22 #include <doc.hxx>
23 #include <editsh.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 );
36 StartAllAction();
37 GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags( eMode );
38 EndAllAction();
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 );
69 StartAllAction();
70 bool bRet = GetDoc()->getIDocumentRedlineAccess().AcceptRedline( nPos, true );
71 if( !nPos && !::IsExtraData( GetDoc() ) )
72 lcl_InvalidateAll( this );
73 EndAllAction();
74 return bRet;
77 bool SwEditShell::RejectRedline( SwRedlineTable::size_type nPos )
79 CurrShell aCurr( this );
80 StartAllAction();
81 bool bRet = GetDoc()->getIDocumentRedlineAccess().RejectRedline( nPos, true );
82 if( !nPos && !::IsExtraData( GetDoc() ) )
83 lcl_InvalidateAll( this );
84 EndAllAction();
85 return bRet;
88 bool SwEditShell::AcceptRedlinesInSelection()
90 CurrShell aCurr( this );
91 StartAllAction();
92 bool bRet = GetDoc()->getIDocumentRedlineAccess().AcceptRedline( *GetCursor(), true );
93 EndAllAction();
94 return bRet;
97 bool SwEditShell::RejectRedlinesInSelection()
99 CurrShell aCurr( this );
100 StartAllAction();
101 bool bRet = GetDoc()->getIDocumentRedlineAccess().RejectRedline( *GetCursor(), true );
102 EndAllAction();
103 return bRet;
106 // Set the comment at the Redline
107 bool SwEditShell::SetRedlineComment( const OUString& rS )
109 bool bRet = false;
110 for(const SwPaM& rPaM : GetCursor()->GetRingContainer())
112 bRet = bRet || GetDoc()->getIDocumentRedlineAccess().SetRedlineComment( rPaM, rS );
115 return bRet;
118 const SwRangeRedline* SwEditShell::GetCurrRedline() const
120 if (const SwRangeRedline* pRed = GetDoc()->getIDocumentRedlineAccess().GetRedline( *GetCursor()->GetPoint(), nullptr ))
121 return pRed;
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 );
131 StartAllAction();
133 GetDoc()->getIDocumentRedlineAccess().UpdateRedlineAttr();
135 EndAllAction();
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 )
149 return i;
150 return SwRedlineTable::npos;
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */