LibreOffice Module sw (master)  1
edredln.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <docary.hxx>
21 #include <redline.hxx>
22 #include <doc.hxx>
23 #include <editsh.hxx>
24 #include <frmtool.hxx>
25 
27 {
29 }
30 
32 {
34  {
35  CurrShell aCurr( this );
38  EndAllAction();
39  }
40 }
41 
43 {
45 }
46 
48 {
50 }
51 
53 {
54  return *GetDoc()->getIDocumentRedlineAccess().GetRedlineTable()[ nPos ];
55 }
56 
57 static void lcl_InvalidateAll( SwViewShell* pSh )
58 {
59  for(SwViewShell& rCurrentShell : pSh->GetRingContainer())
60  {
61  if ( rCurrentShell.GetWin() )
62  rCurrentShell.GetWin()->Invalidate();
63  }
64 }
65 
67 {
68  CurrShell aCurr( this );
70  bool bRet = GetDoc()->getIDocumentRedlineAccess().AcceptRedline( nPos, true );
71  if( !nPos && !::IsExtraData( GetDoc() ) )
72  lcl_InvalidateAll( this );
73  EndAllAction();
74  return bRet;
75 }
76 
78 {
79  CurrShell aCurr( this );
81  bool bRet = GetDoc()->getIDocumentRedlineAccess().RejectRedline( nPos, true );
82  if( !nPos && !::IsExtraData( GetDoc() ) )
83  lcl_InvalidateAll( this );
84  EndAllAction();
85  return bRet;
86 }
87 
89 {
90  CurrShell aCurr( this );
92  bool bRet = GetDoc()->getIDocumentRedlineAccess().AcceptRedline( *GetCursor(), true );
93  EndAllAction();
94  return bRet;
95 }
96 
98 {
99  CurrShell aCurr( this );
100  StartAllAction();
101  bool bRet = GetDoc()->getIDocumentRedlineAccess().RejectRedline( *GetCursor(), true );
102  EndAllAction();
103  return bRet;
104 }
105 
106 // Set the comment at the Redline
107 bool SwEditShell::SetRedlineComment( const OUString& rS )
108 {
109  bool bRet = false;
110  for(const SwPaM& rPaM : GetCursor()->GetRingContainer())
111  {
112  bRet = bRet || GetDoc()->getIDocumentRedlineAccess().SetRedlineComment( rPaM, rS );
113  }
114 
115  return bRet;
116 }
117 
119 {
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 );
124 }
125 
127 {
129  {
130  CurrShell aCurr( this );
131  StartAllAction();
132 
134 
135  EndAllAction();
136  }
137 }
138 
144 {
146 
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;
151 }
152 
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool SetRedlineComment(const SwPaM &rPam, const OUString &rComment)=0
void UpdateRedlineAttr()
Redline attributes have been changed. Updated views.
Definition: edredln.cxx:126
const SwRangeRedline & GetRedline(SwRedlineTable::size_type nPos) const
Definition: edredln.cxx:52
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:190
void SetRedlineFlags(RedlineFlags eMode)
Definition: edredln.cxx:31
void EndAllAction()
Definition: edws.cxx:97
static bool IsShowChanges(const RedlineFlags eM)
RedlineFlags GetRedlineFlags() const
For Redlining.
Definition: edredln.cxx:26
size_type size() const
Definition: docary.hxx:269
bool IsRedlineOn() const
Definition: edredln.cxx:42
static bool IsRedlineOn(const RedlineFlags eM)
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
const IDocumentRedlineAccess & getIDocumentRedlineAccess() const
Provides access to the document redline interface.
Definition: viewsh.cxx:2671
bool AcceptRedline(SwRedlineTable::size_type nPos)
Definition: edredln.cxx:66
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
int i
bool SetRedlineComment(const OUString &rS)
Set comment to Redline at position.
Definition: edredln.cxx:107
SwRedlineTable::size_type GetRedlineCount() const
Definition: edredln.cxx:47
vector_type::size_type size_type
Definition: docary.hxx:228
SwRedlineTable::size_type FindRedlineOfData(const SwRedlineData &) const
Search Redline for this Data and.
Definition: edredln.cxx:143
bool IsExtraData(const SwDoc *pDoc)
Definition: frmtool.cxx:3769
bool RejectRedlinesInSelection()
Definition: edredln.cxx:97
ring_container GetRingContainer()
Definition: ring.hxx:240
bool AcceptRedlinesInSelection()
Definition: edredln.cxx:88
static void lcl_InvalidateAll(SwViewShell *pSh)
Definition: edredln.cxx:57
virtual const SwRangeRedline * GetRedline(const SwPosition &rPos, SwRedlineTable::size_type *pFndPos) const =0
const SwRangeRedline * GetCurrRedline() const
Definition: edredln.cxx:118
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
bool RejectRedline(SwRedlineTable::size_type nPos)
Definition: edredln.cxx:77
virtual void SetRedlineFlags(RedlineFlags eMode)=0
Set a new redline mode.
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
virtual void UpdateRedlineAttr()=0
virtual bool AcceptRedline(SwRedlineTable::size_type nPos, bool bCallDelete)=0
virtual bool RejectRedline(SwRedlineTable::size_type nPos, bool bCallDelete)=0
virtual const SwRedlineTable & GetRedlineTable() const =0
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
static constexpr size_type npos
Definition: docary.hxx:229