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 <swundo.hxx>
24 #include <editsh.hxx>
25 #include <edimp.hxx>
26 #include <frmtool.hxx>
27 
29 {
31 }
32 
34 {
36  {
37  SET_CURR_SHELL( this );
40  EndAllAction();
41  }
42 }
43 
45 {
47 }
48 
50 {
52 }
53 
55 {
56  return *GetDoc()->getIDocumentRedlineAccess().GetRedlineTable()[ nPos ];
57 }
58 
59 static void lcl_InvalidateAll( SwViewShell* pSh )
60 {
61  for(SwViewShell& rCurrentShell : pSh->GetRingContainer())
62  {
63  if ( rCurrentShell.GetWin() )
64  rCurrentShell.GetWin()->Invalidate();
65  }
66 }
67 
69 {
70  SET_CURR_SHELL( this );
72  bool bRet = GetDoc()->getIDocumentRedlineAccess().AcceptRedline( nPos, true );
73  if( !nPos && !::IsExtraData( GetDoc() ) )
74  lcl_InvalidateAll( this );
75  EndAllAction();
76  return bRet;
77 }
78 
80 {
81  SET_CURR_SHELL( this );
83  bool bRet = GetDoc()->getIDocumentRedlineAccess().RejectRedline( nPos, true );
84  if( !nPos && !::IsExtraData( GetDoc() ) )
85  lcl_InvalidateAll( this );
86  EndAllAction();
87  return bRet;
88 }
89 
91 {
92  SET_CURR_SHELL( this );
94  bool bRet = GetDoc()->getIDocumentRedlineAccess().AcceptRedline( *GetCursor(), true );
95  EndAllAction();
96  return bRet;
97 }
98 
100 {
101  SET_CURR_SHELL( this );
102  StartAllAction();
103  bool bRet = GetDoc()->getIDocumentRedlineAccess().RejectRedline( *GetCursor(), true );
104  EndAllAction();
105  return bRet;
106 }
107 
108 // Set the comment at the Redline
109 bool SwEditShell::SetRedlineComment( const OUString& rS )
110 {
111  bool bRet = false;
112  for(SwPaM& rPaM : GetCursor()->GetRingContainer())
113  {
114  bRet = bRet || GetDoc()->getIDocumentRedlineAccess().SetRedlineComment( rPaM, rS );
115  }
116 
117  return bRet;
118 }
119 
121 {
122  if (const SwRangeRedline* pRed = GetDoc()->getIDocumentRedlineAccess().GetRedline( *GetCursor()->GetPoint(), nullptr ))
123  return pRed;
124  // check the other side of the selection to handle completely selected changes, where the Point is at the end
125  return GetDoc()->getIDocumentRedlineAccess().GetRedline( *GetCursor()->GetMark(), nullptr );
126 }
127 
129 {
131  {
132  SET_CURR_SHELL( this );
133  StartAllAction();
134 
136 
137  EndAllAction();
138  }
139 }
140 
146 {
148 
149  for( SwRedlineTable::size_type i = 0, nCnt = rTable.size(); i < nCnt; ++i )
150  if( &rTable[ i ]->GetRedlineData() == &rData )
151  return i;
152  return SwRedlineTable::npos;
153 }
154 
155 /* 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:128
const SwRangeRedline & GetRedline(SwRedlineTable::size_type nPos) const
Definition: edredln.cxx:54
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:185
void SetRedlineFlags(RedlineFlags eMode)
Definition: edredln.cxx:33
void EndAllAction()
Definition: edws.cxx:96
static bool IsShowChanges(const RedlineFlags eM)
RedlineFlags GetRedlineFlags() const
For Redlining.
Definition: edredln.cxx:28
size_type size() const
Definition: docary.hxx:368
bool IsRedlineOn() const
Definition: edredln.cxx:44
static bool IsRedlineOn(const RedlineFlags eM)
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
const IDocumentRedlineAccess & getIDocumentRedlineAccess() const
Provides access to the document redline interface.
Definition: viewsh.cxx:2596
bool AcceptRedline(SwRedlineTable::size_type nPos)
Definition: edredln.cxx:68
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
bool SetRedlineComment(const OUString &rS)
Set comment to Redline at position.
Definition: edredln.cxx:109
SwRedlineTable::size_type GetRedlineCount() const
Definition: edredln.cxx:49
int i
vector_type::size_type size_type
Definition: docary.hxx:330
SwRedlineTable::size_type FindRedlineOfData(const SwRedlineData &) const
Search Redline for this Data and.
Definition: edredln.cxx:145
#define SET_CURR_SHELL(shell)
Definition: swtypes.hxx:101
bool IsExtraData(const SwDoc *pDoc)
Definition: frmtool.cxx:3563
bool RejectRedlinesInSelection()
Definition: edredln.cxx:99
ring_container GetRingContainer()
Definition: ring.hxx:240
bool AcceptRedlinesInSelection()
Definition: edredln.cxx:90
static void lcl_InvalidateAll(SwViewShell *pSh)
Definition: edredln.cxx:59
virtual const SwRangeRedline * GetRedline(const SwPosition &rPos, SwRedlineTable::size_type *pFndPos) const =0
const SwRangeRedline * GetCurrRedline() const
Definition: edredln.cxx:120
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:367
bool RejectRedline(SwRedlineTable::size_type nPos)
Definition: edredln.cxx:79
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:85
static constexpr size_type npos
Definition: docary.hxx:331