Bump version to 21.06.18.1
[LibreOffice.git] / sw / inc / IDocumentRedlineAccess.hxx
blob0e4c9e33fb52a913bab4c9730688a347b92331ad
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_INC_IDOCUMENTREDLINEACCESS_HXX
21 #define INCLUDED_SW_INC_IDOCUMENTREDLINEACCESS_HXX
23 #include <sal/config.h>
25 #include <cstddef>
27 #include <sal/types.h>
29 #include <com/sun/star/uno/Sequence.h>
30 #include <o3tl/typed_flags_set.hxx>
31 #include <svx/ctredlin.hxx>
33 #include "docary.hxx"
35 class SwRangeRedline;
36 class SwTableRowRedline;
37 class SwTableCellRedline;
38 class SwPaM;
39 struct SwPosition;
40 class SwStartNode;
41 class SwNode;
43 enum class RedlineFlags
45 NONE = 0x000, ///< no RedlineFlags
46 On = 0x001, ///< RedlineFlags on
47 Ignore = 0x002, ///< ignore Redlines
48 ShowInsert = 0x010, ///< show all inserts
49 ShowDelete = 0x020, ///< show all deletes
50 ShowMask = ShowInsert | ShowDelete,
52 // For internal management:
53 // remove the original Redlines together with their content
54 // (Clipboard/text modules).
55 DeleteRedlines = 0x100,
56 // don't combine any redlines. This flag may be only used in Undo.
57 DontCombineRedlines = 0x400,
59 namespace o3tl
61 template<> struct typed_flags<RedlineFlags> : is_typed_flags<RedlineFlags, 0x533> {};
64 inline OUString SwRedlineTypeToOUString(RedlineType eType)
66 OUString sRet;
67 switch(eType)
69 case RedlineType::Insert: sRet = "Insert"; break;
70 case RedlineType::Delete: sRet = "Delete"; break;
71 case RedlineType::Format: sRet = "Format"; break;
72 case RedlineType::ParagraphFormat: sRet = "ParagraphFormat"; break;
73 case RedlineType::Table: sRet = "TextTable"; break;
74 case RedlineType::FmtColl:sRet = "Style"; break;
75 default: break;
77 return sRet;
80 class IDocumentRedlineAccess
82 // Static helper functions
83 public:
84 static bool IsShowChanges(const RedlineFlags eM)
85 { return (RedlineFlags::ShowInsert | RedlineFlags::ShowDelete) == (eM & RedlineFlags::ShowMask); }
87 static bool IsHideChanges(const RedlineFlags eM)
88 { return RedlineFlags::ShowInsert == (eM & RedlineFlags::ShowMask); }
90 static bool IsShowOriginal(const RedlineFlags eM)
91 { return RedlineFlags::ShowDelete == (eM & RedlineFlags::ShowMask); }
93 static bool IsRedlineOn(const RedlineFlags eM)
94 { return RedlineFlags::On == (eM & (RedlineFlags::On | RedlineFlags::Ignore )); }
96 public:
98 /** Query the currently set redline mode
100 @returns
101 the currently set redline mode
103 virtual RedlineFlags GetRedlineFlags() const = 0;
105 /** Set a new redline mode.
107 @param eMode
108 [in] the new redline mode.
110 virtual void SetRedlineFlags_intern(/*[in]*/RedlineFlags eMode) = 0;
112 /** Set a new redline mode.
114 @param eMode
115 [in] the new redline mode.
117 virtual void SetRedlineFlags(/*[in]*/RedlineFlags eMode) = 0;
119 /** Query if redlining is on.
121 @returns
122 <TRUE/> if redlining is on <FALSE/> otherwise
124 virtual bool IsRedlineOn() const = 0;
126 virtual bool IsIgnoreRedline() const = 0;
128 virtual const SwRedlineTable& GetRedlineTable() const = 0;
129 virtual SwRedlineTable& GetRedlineTable() = 0;
130 virtual const SwExtraRedlineTable& GetExtraRedlineTable() const = 0;
131 virtual SwExtraRedlineTable& GetExtraRedlineTable() = 0;
132 virtual bool HasExtraRedlineTable() const = 0;
134 virtual bool IsInRedlines(const SwNode& rNode) const = 0;
136 enum class AppendResult { IGNORED, MERGED, APPENDED };
137 /** Append a new redline
139 @param pNewRedl redline to insert
141 @param bCallDelete
142 if set, then for a new DELETE redline that is inserted so that it
143 overlaps an existing INSERT redline with the same author, the
144 overlapping range is deleted, i.e. the new DELETE removes
145 existing INSERT for that range
147 @returns
148 APPENDED if pNewRedl is still alive and was appended
149 MERGED if pNewRedl was deleted but has been merged with existing one
150 IGNORED if pNewRedl was deleted and ignored/invalid
152 virtual AppendResult AppendRedline(/*[in]*/SwRangeRedline* pNewRedl, /*[in]*/bool bCallDelete) = 0;
154 virtual bool AppendTableRowRedline(/*[in]*/SwTableRowRedline* pPtr) = 0;
155 virtual bool AppendTableCellRedline(/*[in]*/SwTableCellRedline* pPtr) = 0;
157 virtual bool SplitRedline(/*[in]*/const SwPaM& rPam) = 0;
159 virtual bool DeleteRedline(
160 /*[in]*/const SwPaM& rPam,
161 /*[in]*/bool bSaveInUndo,
162 /*[in]*/RedlineType nDelType) = 0;
164 virtual bool DeleteRedline(
165 /*[in]*/const SwStartNode& rSection,
166 /*[in]*/bool bSaveInUndo,
167 /*[in]*/RedlineType nDelType) = 0;
169 virtual SwRedlineTable::size_type GetRedlinePos(
170 /*[in]*/const SwNode& rNode,
171 /*[in]*/RedlineType nType) const = 0;
173 virtual bool HasRedline(
174 /*[in]*/const SwPaM& rPam,
175 /*[in]*/RedlineType nType,
176 /*[in]*/bool bStartOrEndInRange) const = 0;
178 virtual void CompressRedlines() = 0;
180 virtual const SwRangeRedline* GetRedline(
181 /*[in]*/const SwPosition& rPos,
182 /*[in]*/SwRedlineTable::size_type* pFndPos) const = 0;
184 virtual bool IsRedlineMove() const = 0;
186 virtual void SetRedlineMove(/*[in]*/bool bFlag) = 0;
188 virtual bool AcceptRedline(/*[in]*/SwRedlineTable::size_type nPos, /*[in]*/bool bCallDelete) = 0;
190 virtual bool AcceptRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) = 0;
192 virtual void AcceptRedlineParagraphFormatting(/*[in]*/const SwPaM& rPam ) = 0;
194 virtual bool RejectRedline(/*[in]*/SwRedlineTable::size_type nPos, /*[in]*/bool bCallDelete) = 0;
196 virtual bool RejectRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) = 0;
198 virtual const SwRangeRedline* SelNextRedline(/*[in]*/SwPaM& rPam) const = 0;
200 virtual const SwRangeRedline* SelPrevRedline(/*[in]*/SwPaM& rPam) const = 0;
202 virtual void AcceptAllRedline(/*[in]*/bool bAcceptReject) = 0;
204 // Representation has changed, invalidate all Redlines.
205 virtual void UpdateRedlineAttr() = 0;
207 // Create a new Author if required.
208 virtual std::size_t GetRedlineAuthor() = 0;
210 // For Readers etc.: register new Author in table.
211 virtual std::size_t InsertRedlineAuthor(const OUString& rAuthor) = 0;
213 // Place a comment at Redline at given position.
214 virtual bool SetRedlineComment(
215 /*[in]*/const SwPaM& rPam,
216 /*[in]*/const OUString& rComment) = 0;
218 virtual const css::uno::Sequence <sal_Int8>& GetRedlinePassword() const = 0;
220 virtual void SetRedlinePassword(
221 /*[in]*/const css::uno::Sequence <sal_Int8>& rNewPassword) = 0;
223 protected:
224 virtual ~IDocumentRedlineAccess() {};
227 #endif
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */