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 );
40 }
41}
42
44{
46}
47
49{
51}
52
54{
56}
57
58static 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 );
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 );
86 return bRet;
87}
88
90{
91 CurrShell aCurr( this );
93 // in table selection mode, process the selected boxes in reverse order
94 // to allow accepting their text changes and the tracked row deletions
95 bool bRet = false;
96 if ( IsTableMode() )
97 {
98 const SwSelBoxes& rBoxes = GetTableCursor()->GetSelectedBoxes();
99 std::vector<std::unique_ptr<SwPaM>> vBoxes;
100 for(auto pBox : rBoxes)
101 {
102 if ( !pBox->IsEmpty() )
103 {
104 const SwStartNode *pSttNd = pBox->GetSttNd();
105 SwNode* pEndNode = pSttNd->GetNodes()[pSttNd->EndOfSectionIndex()];
106 vBoxes.push_back(std::unique_ptr<SwPaM>(new SwPaM(*pEndNode, 0, *pSttNd, 0)));
107 }
108 }
109
110 for (size_t i = 0; i < vBoxes.size(); ++i)
111 bRet |= GetDoc()->getIDocumentRedlineAccess().AcceptRedline( *vBoxes[vBoxes.size()-i-1], true );
112 }
113 else
115 EndAllAction();
116 return bRet;
117}
118
120{
121 CurrShell aCurr( this );
123 bool bRet = false;
124 // in table selection mode, process the selected boxes in reverse order
125 // to allow rejecting their text changes and the tracked row insertions
126 if ( IsTableMode() )
127 {
128 const SwSelBoxes& rBoxes = GetTableCursor()->GetSelectedBoxes();
129 std::vector<std::unique_ptr<SwPaM>> vBoxes;
130 for(auto pBox : rBoxes)
131 {
132 if ( !pBox->IsEmpty() )
133 {
134 const SwStartNode *pSttNd = pBox->GetSttNd();
135 SwNode* pEndNode = pSttNd->GetNodes()[pSttNd->EndOfSectionIndex()];
136 vBoxes.push_back(std::unique_ptr<SwPaM>(new SwPaM(*pEndNode, 0, *pSttNd, 0)));
137 }
138 }
139
140 for (size_t i = 0; i < vBoxes.size(); ++i)
141 bRet |= GetDoc()->getIDocumentRedlineAccess().RejectRedline( *vBoxes[vBoxes.size()-i-1], true );
142 }
143 else
145 EndAllAction();
146 return bRet;
147}
148
149// Set the comment at the Redline
150bool SwEditShell::SetRedlineComment( const OUString& rS )
151{
152 bool bRet = false;
153 for(const SwPaM& rPaM : GetCursor()->GetRingContainer())
154 {
155 bRet = bRet || GetDoc()->getIDocumentRedlineAccess().SetRedlineComment( rPaM, rS );
156 }
157
158 return bRet;
159}
160
162{
163 if (const SwRangeRedline* pRed = GetDoc()->getIDocumentRedlineAccess().GetRedline( *GetCursor()->GetPoint(), nullptr ))
164 return pRed;
165 // check the other side of the selection to handle completely selected changes, where the Point is at the end
166 return GetDoc()->getIDocumentRedlineAccess().GetRedline( *GetCursor()->GetMark(), nullptr );
167}
168
170{
172 {
173 CurrShell aCurr( this );
175
177
178 EndAllAction();
179 }
180}
181
187{
189
190 for( SwRedlineTable::size_type i = 0, nCnt = rTable.size(); i < nCnt; ++i )
191 if( &rTable[ i ]->GetRedlineData() == &rData )
192 return i;
194}
195
196/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool IsRedlineOn(const RedlineFlags eM)
virtual void UpdateRedlineAttr()=0
virtual bool RejectRedline(SwRedlineTable::size_type nPos, bool bCallDelete)=0
static bool IsShowChanges(const RedlineFlags eM)
virtual const SwRedlineTable & GetRedlineTable() const =0
virtual void SetRedlineFlags(RedlineFlags eMode)=0
Set a new redline mode.
virtual const SwRangeRedline * GetRedline(const SwPosition &rPos, SwRedlineTable::size_type *pFndPos) const =0
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
virtual bool AcceptRedline(SwRedlineTable::size_type nPos, bool bCallDelete)=0
virtual bool SetRedlineComment(const SwPaM &rPam, const OUString &rComment)=0
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:194
const SwShellTableCursor * GetTableCursor() const
Definition: crsrsh.hxx:670
bool IsTableMode() const
Definition: crsrsh.hxx:668
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:349
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
bool AcceptRedline(SwRedlineTable::size_type nPos)
Definition: edredln.cxx:67
bool IsRedlineOn() const
Definition: edredln.cxx:43
bool SetRedlineComment(const OUString &rS)
Set comment to Redline at position.
Definition: edredln.cxx:150
void SetRedlineFlags(RedlineFlags eMode)
Definition: edredln.cxx:32
RedlineFlags GetRedlineFlags() const
For Redlining.
Definition: edredln.cxx:27
bool RejectRedline(SwRedlineTable::size_type nPos)
Definition: edredln.cxx:78
const SwRangeRedline & GetRedline(SwRedlineTable::size_type nPos) const
Definition: edredln.cxx:53
const SwRangeRedline * GetCurrRedline() const
Definition: edredln.cxx:161
SwRedlineTable::size_type GetRedlineCount() const
Definition: edredln.cxx:48
bool AcceptRedlinesInSelection()
Definition: edredln.cxx:89
void EndAllAction()
Definition: edws.cxx:97
void UpdateRedlineAttr()
Redline attributes have been changed. Updated views.
Definition: edredln.cxx:169
bool RejectRedlinesInSelection()
Definition: edredln.cxx:119
SwRedlineTable::size_type FindRedlineOfData(const SwRedlineData &) const
Search Redline for this Data and.
Definition: edredln.cxx:186
Base class of the Writer document model elements.
Definition: node.hxx:98
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:706
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:691
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
static constexpr size_type npos
Definition: docary.hxx:224
size_type size() const
Definition: docary.hxx:268
vector_type::size_type size_type
Definition: docary.hxx:223
Starts a section of nodes in the document model.
Definition: node.hxx:348
const SwSelBoxes & GetSelectedBoxes() const
Definition: swcrsr.hxx:280
SwDoc * GetDoc() const
Definition: viewsh.hxx:308
const IDocumentRedlineAccess & getIDocumentRedlineAccess() const
Provides access to the document redline interface.
Definition: viewsh.cxx:2825
ring_container GetRingContainer()
Definition: ring.hxx:240
static void lcl_InvalidateAll(SwViewShell *pSh)
Definition: edredln.cxx:58
bool IsExtraData(const SwDoc *pDoc)
Definition: frmtool.cxx:3913
Mode eMode
sal_uInt16 nPos
int i