/src/libreoffice/sw/inc/IDocumentRedlineAccess.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include <sal/config.h> |
23 | | |
24 | | #include <cstddef> |
25 | | |
26 | | #include <sal/types.h> |
27 | | |
28 | | #include <com/sun/star/uno/Sequence.h> |
29 | | #include <o3tl/typed_flags_set.hxx> |
30 | | #include <svx/ctredlin.hxx> |
31 | | #include <sfx2/redlinerecordingmode.hxx> |
32 | | |
33 | | #include "docary.hxx" |
34 | | |
35 | | class SwRangeRedline; |
36 | | class SwTableRowRedline; |
37 | | class SwTableCellRedline; |
38 | | class SwPaM; |
39 | | struct SwPosition; |
40 | | class SwStartNode; |
41 | | class SwNode; |
42 | | class SwViewShell; |
43 | | |
44 | | /// Sets per-document flags for track change recording and show/hiding. The later is read by the |
45 | | /// layout, which is shared between views. |
46 | | /// |
47 | | /// Note that RedlineFlags::On has a per-view version at SwViewOption::IsRedlineRecordingOn(), and |
48 | | /// that is used when the document has at least one view. |
49 | | enum class RedlineFlags |
50 | | { |
51 | | NONE = 0x000, ///< no RedlineFlags |
52 | | On = 0x001, ///< RedlineFlags on |
53 | | Ignore = 0x002, ///< ignore Redlines (only set from code, temporarily) |
54 | | ShowInsert = 0x010, ///< show all inserts |
55 | | ShowDelete = 0x020, ///< show all deletes |
56 | | ShowMask = ShowInsert | ShowDelete, |
57 | | |
58 | | // For internal management: |
59 | | // remove the original Redlines together with their content |
60 | | // (Clipboard/text modules). |
61 | | DeleteRedlines = 0x100, |
62 | | // don't combine any redlines. This flag may be only used in Undo. |
63 | | DontCombineRedlines = 0x400, |
64 | | }; |
65 | | namespace o3tl |
66 | | { |
67 | | template<> struct typed_flags<RedlineFlags> : is_typed_flags<RedlineFlags, 0x533> {}; |
68 | | } |
69 | | |
70 | | inline OUString SwRedlineTypeToOUString(RedlineType eType) |
71 | 0 | { |
72 | 0 | OUString sRet; |
73 | 0 | switch(eType) |
74 | 0 | { |
75 | 0 | case RedlineType::Insert: sRet = "Insert"; break; |
76 | 0 | case RedlineType::Delete: sRet = "Delete"; break; |
77 | 0 | case RedlineType::Format: sRet = "Format"; break; |
78 | 0 | case RedlineType::ParagraphFormat: sRet = "ParagraphFormat"; break; |
79 | 0 | case RedlineType::Table: sRet = "TextTable"; break; |
80 | 0 | case RedlineType::FmtColl:sRet = "Style"; break; |
81 | 0 | default: break; |
82 | 0 | } |
83 | 0 | return sRet; |
84 | 0 | }; |
85 | | |
86 | | /// This interface is implemented by DocumentRedlineManager: most clients only have to interact with |
87 | | /// this interface and not the underlying manager implementation. Also, the UI/filter code has no |
88 | | /// access to the manager, just to this interface. |
89 | | class IDocumentRedlineAccess |
90 | | { |
91 | | // Static helper functions |
92 | | public: |
93 | | static bool IsShowChanges(const RedlineFlags eM) |
94 | 649k | { return (RedlineFlags::ShowInsert | RedlineFlags::ShowDelete) == (eM & RedlineFlags::ShowMask); } |
95 | | |
96 | | static bool IsHideChanges(const RedlineFlags eM) |
97 | 8.28k | { return RedlineFlags::ShowInsert == (eM & RedlineFlags::ShowMask); } |
98 | | |
99 | | static bool IsShowOriginal(const RedlineFlags eM) |
100 | 346k | { return RedlineFlags::ShowDelete == (eM & RedlineFlags::ShowMask); } |
101 | | |
102 | | static bool IsRedlineOn(const RedlineFlags eM) |
103 | 75.7M | { return RedlineFlags::On == (eM & (RedlineFlags::On | RedlineFlags::Ignore )); } |
104 | | |
105 | | public: |
106 | | |
107 | | /** Query the currently set redline mode |
108 | | |
109 | | @returns |
110 | | the currently set redline mode |
111 | | */ |
112 | | virtual RedlineFlags GetRedlineFlags(const SwViewShell* pViewShell = nullptr) const = 0; |
113 | | |
114 | | /** Set a new redline mode. |
115 | | |
116 | | @param eMode |
117 | | [in] the new redline mode. |
118 | | */ |
119 | | virtual void SetRedlineFlags_intern(/*[in]*/RedlineFlags eMode, SfxRedlineRecordingMode eRedlineRecordingMode = SfxRedlineRecordingMode::ViewAgnostic, bool bRecordModeChange = false) = 0; |
120 | | |
121 | | /** Set a new redline mode. |
122 | | |
123 | | @param eMode |
124 | | [in] the new redline mode. |
125 | | */ |
126 | | virtual void SetRedlineFlags(/*[in]*/RedlineFlags eMode, SfxRedlineRecordingMode eRedlineRecordingMode = SfxRedlineRecordingMode::ViewAgnostic, bool bRecordModeChange = false) = 0; |
127 | | |
128 | | /** Query if redlining is on. |
129 | | |
130 | | @returns |
131 | | <TRUE/> if redlining is on <FALSE/> otherwise |
132 | | */ |
133 | | virtual bool IsRedlineOn() const = 0; |
134 | | |
135 | | virtual bool IsIgnoreRedline() const = 0; |
136 | | |
137 | | virtual const SwRedlineTable& GetRedlineTable() const = 0; |
138 | | virtual SwRedlineTable& GetRedlineTable() = 0; |
139 | | virtual const SwExtraRedlineTable& GetExtraRedlineTable() const = 0; |
140 | | virtual SwExtraRedlineTable& GetExtraRedlineTable() = 0; |
141 | | |
142 | | virtual bool IsInRedlines(const SwNode& rNode) const = 0; |
143 | | |
144 | | enum class AppendResult { IGNORED, MERGED, APPENDED }; |
145 | | /** Append a new redline |
146 | | |
147 | | @param pNewRedl redline to insert |
148 | | |
149 | | @param bCallDelete |
150 | | if set, then for a new DELETE redline that is inserted so that it |
151 | | overlaps an existing INSERT redline with the same author, the |
152 | | overlapping range is deleted, i.e. the new DELETE removes |
153 | | existing INSERT for that range |
154 | | |
155 | | @returns |
156 | | APPENDED if pNewRedl is still alive and was appended |
157 | | MERGED if pNewRedl was deleted but has been merged with existing one |
158 | | IGNORED if pNewRedl was deleted and ignored/invalid |
159 | | */ |
160 | | virtual AppendResult AppendRedline(/*[in]*/ SwRangeRedline* pNewRedl, /*[in]*/ bool bCallDelete, |
161 | | /*[in]*/ sal_uInt32 nMoveIDToDelete = 0) = 0; |
162 | | |
163 | | virtual bool AppendTableRowRedline(/*[in]*/SwTableRowRedline* pPtr) = 0; |
164 | | virtual bool AppendTableCellRedline(/*[in]*/SwTableCellRedline* pPtr) = 0; |
165 | | |
166 | | virtual bool SplitRedline(/*[in]*/const SwPaM& rPam) = 0; |
167 | | |
168 | | virtual bool DeleteRedline( |
169 | | /*[in]*/const SwPaM& rPam, |
170 | | /*[in]*/bool bSaveInUndo, |
171 | | /*[in]*/RedlineType nDelType) = 0; |
172 | | |
173 | | virtual bool DeleteRedline( |
174 | | /*[in]*/const SwStartNode& rSection, |
175 | | /*[in]*/bool bSaveInUndo, |
176 | | /*[in]*/RedlineType nDelType) = 0; |
177 | | |
178 | | virtual SwRedlineTable::size_type GetRedlinePos( |
179 | | /*[in]*/const SwNode& rNode, |
180 | | /*[in]*/RedlineType nType) const = 0; |
181 | | |
182 | | virtual SwRedlineTable::size_type GetRedlineEndPos( |
183 | | /*[in]*/ SwRedlineTable::size_type nStartPos, |
184 | | /*[in]*/ const SwNode& rNode, |
185 | | /*[in]*/ RedlineType nType) const = 0; |
186 | | |
187 | | virtual bool HasRedline( |
188 | | /*[in]*/const SwPaM& rPam, |
189 | | /*[in]*/RedlineType nType, |
190 | | /*[in]*/bool bStartOrEndInRange) const = 0; |
191 | | |
192 | | virtual void CompressRedlines(size_t nStartIndex = 0) = 0; |
193 | | |
194 | | virtual const SwRangeRedline* GetRedline( |
195 | | /*[in]*/const SwPosition& rPos, |
196 | | /*[in]*/SwRedlineTable::size_type* pFndPos) const = 0; |
197 | | |
198 | | virtual bool IsRedlineMove() const = 0; |
199 | | |
200 | | virtual void SetRedlineMove(/*[in]*/bool bFlag) = 0; |
201 | | |
202 | | virtual bool AcceptRedline(/*[in]*/ SwRedlineTable::size_type nPos, /*[in]*/ bool bCallDelete, |
203 | | /*[in]*/ bool bRange = false, |
204 | | bool bDirect = false) |
205 | | = 0; |
206 | | |
207 | | virtual bool AcceptRedline(/*[in]*/ const SwPaM& rPam, /*[in]*/ bool bCallDelete, |
208 | | /*[in]*/ sal_Int8 nDepth = 0, |
209 | | bool bDirect = false) |
210 | | = 0; |
211 | | |
212 | | virtual void AcceptRedlineParagraphFormatting(/*[in]*/const SwPaM& rPam ) = 0; |
213 | | |
214 | | virtual bool RejectRedline(/*[in]*/ SwRedlineTable::size_type nPos, |
215 | | /*[in]*/ bool bCallDelete, /*[in]*/ bool bRange = false, |
216 | | bool bDirect = false) |
217 | | = 0; |
218 | | |
219 | | virtual bool RejectRedline(/*[in]*/ const SwPaM& rPam, /*[in]*/ bool bCallDelete, |
220 | | /*[in]*/ sal_Int8 nDepth = 0, |
221 | | bool bDirect = false) |
222 | | = 0; |
223 | | |
224 | | virtual const SwRangeRedline* SelNextRedline(/*[in]*/SwPaM& rPam) const = 0; |
225 | | |
226 | | virtual const SwRangeRedline* SelPrevRedline(/*[in]*/SwPaM& rPam) const = 0; |
227 | | |
228 | | virtual void AcceptAllRedline(/*[in]*/bool bAcceptReject) = 0; |
229 | | |
230 | | // Representation has changed, invalidate all Redlines. |
231 | | virtual void UpdateRedlineAttr() = 0; |
232 | | |
233 | | // Create a new Author if required. |
234 | | virtual std::size_t GetRedlineAuthor() = 0; |
235 | | |
236 | | // For Readers etc.: register new Author in table. |
237 | | virtual std::size_t InsertRedlineAuthor(const OUString& rAuthor) = 0; |
238 | | |
239 | | // Place a comment at Redline at given position. |
240 | | virtual bool SetRedlineComment( |
241 | | /*[in]*/const SwPaM& rPam, |
242 | | /*[in]*/const OUString& rComment) = 0; |
243 | | |
244 | | virtual const css::uno::Sequence <sal_Int8>& GetRedlinePassword() const = 0; |
245 | | |
246 | | virtual void SetRedlinePassword( |
247 | | /*[in]*/const css::uno::Sequence <sal_Int8>& rNewPassword) = 0; |
248 | | |
249 | | virtual void UpdateRedlineContentNode(/*[in]*/ SwRedlineTable::size_type nStartPos, |
250 | | /*[in]*/ SwRedlineTable::size_type nEndPos) const = 0; |
251 | | |
252 | | virtual void dumpAsXml(xmlTextWriterPtr pWriter) const = 0; |
253 | | |
254 | | |
255 | | protected: |
256 | 77.0k | virtual ~IDocumentRedlineAccess() {}; |
257 | | }; |
258 | | |
259 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |