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 
21 #include <docary.hxx>
22 #include <redline.hxx>
23 #include <doc.hxx>
24 #include <editsh.hxx>
25 #include <frmtool.hxx>
26 
28 {
30 }
31 
33 {
35  {
36  CurrShell aCurr( this );
39  EndAllAction();
40  }
41 }
42 
44 {
46 }
47 
49 {
51 }
52 
54 {
55  return *GetDoc()->getIDocumentRedlineAccess().GetRedlineTable()[ nPos ];
56 }
57 
58 static void lcl_InvalidateAll( SwViewShell* pSh )
59 {
60  for(SwViewShell& rCurrentShell : pSh->GetRingContainer())
61  {
62  if ( rCurrentShell.GetWin() )
63  rCurrentShell.GetWin()->Invalidate();
64  }
65 }
66 
68 {
69  CurrShell aCurr( this );
71  bool bRet = GetDoc()->getIDocumentRedlineAccess().AcceptRedline( nPos, true );
72  if( !nPos && !::IsExtraData( GetDoc() ) )
73  lcl_InvalidateAll( this );
74  EndAllAction();
75  return bRet;
76 }
77 
79 {
80  CurrShell aCurr( this );
82  bool bRet = GetDoc()->getIDocumentRedlineAccess().RejectRedline( nPos, true );
83  if( !nPos && !::IsExtraData( GetDoc() ) )
84  lcl_InvalidateAll( this );
85  EndAllAction();
86  return bRet;
87 }
88 
90 {
91  CurrShell aCurr( this );
93  bool bRet = GetDoc()->getIDocumentRedlineAccess().AcceptRedline( *GetCursor(), true );
94  EndAllAction();
95  return bRet;
96 }
97 
99 {
100  CurrShell aCurr( this );
101  StartAllAction();
102  bool bRet = GetDoc()->getIDocumentRedlineAccess().RejectRedline( *GetCursor(), true );
103  EndAllAction();
104  return bRet;
105 }
106 
107 // Set the comment at the Redline
108 bool SwEditShell::SetRedlineComment( const OUString& rS )
109 {
110  bool bRet = false;
111  for(const SwPaM& rPaM : GetCursor()->GetRingContainer())
112  {
113  bRet = bRet || GetDoc()->getIDocumentRedlineAccess().SetRedlineComment( rPaM, rS );
114  }
115 
116  return bRet;
117 }
118 
120 {
121  if (const SwRangeRedline* pRed = GetDoc()->getIDocumentRedlineAccess().GetRedline( *GetCursor()->GetPoint(), nullptr ))
122  return pRed;
123  // check the other side of the selection to handle completely selected changes, where the Point is at the end
124  return GetDoc()->getIDocumentRedlineAccess().GetRedline( *GetCursor()->GetMark(), nullptr );
125 }
126 
128 {
130  {
131  CurrShell aCurr( this );
132  StartAllAction();
133 
135 
136  EndAllAction();
137  }
138 }
139 
145 {
147 
148  for( SwRedlineTable::size_type i = 0, nCnt = rTable.size(); i < nCnt; ++i )
149  if( &rTable[ i ]->GetRedlineData() == &rData )
150  return i;
151  return SwRedlineTable::npos;
152 }
153 
154 /* 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:127
const SwRangeRedline & GetRedline(SwRedlineTable::size_type nPos) const
Definition: edredln.cxx:53
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:194
void SetRedlineFlags(RedlineFlags eMode)
Definition: edredln.cxx:32
void EndAllAction()
Definition: edws.cxx:97
static bool IsShowChanges(const RedlineFlags eM)
RedlineFlags GetRedlineFlags() const
For Redlining.
Definition: edredln.cxx:27
size_type size() const
Definition: docary.hxx:266
bool IsRedlineOn() const
Definition: edredln.cxx:43
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:2669
bool AcceptRedline(SwRedlineTable::size_type nPos)
Definition: edredln.cxx:67
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:108
SwRedlineTable::size_type GetRedlineCount() const
Definition: edredln.cxx:48
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:144
bool IsExtraData(const SwDoc *pDoc)
Definition: frmtool.cxx:3824
bool RejectRedlinesInSelection()
Definition: edredln.cxx:98
ring_container GetRingContainer()
Definition: ring.hxx:240
bool AcceptRedlinesInSelection()
Definition: edredln.cxx:89
static void lcl_InvalidateAll(SwViewShell *pSh)
Definition: edredln.cxx:58
virtual const SwRangeRedline * GetRedline(const SwPosition &rPos, SwRedlineTable::size_type *pFndPos) const =0
const SwRangeRedline * GetCurrRedline() const
Definition: edredln.cxx:119
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
bool RejectRedline(SwRedlineTable::size_type nPos)
Definition: edredln.cxx:78
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