1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <sal/config.h>
26 #include <sal/types.h>
28 #include <com/sun/star/uno/Sequence.h>
29 #include <o3tl/typed_flags_set.hxx>
30 #include <svx/ctredlin.hxx>
35 class SwTableRowRedline
;
36 class SwTableCellRedline
;
42 enum class RedlineFlags
44 NONE
= 0x000, ///< no RedlineFlags
45 On
= 0x001, ///< RedlineFlags on
46 Ignore
= 0x002, ///< ignore Redlines
47 ShowInsert
= 0x010, ///< show all inserts
48 ShowDelete
= 0x020, ///< show all deletes
49 ShowMask
= ShowInsert
| ShowDelete
,
51 // For internal management:
52 // remove the original Redlines together with their content
53 // (Clipboard/text modules).
54 DeleteRedlines
= 0x100,
55 // don't combine any redlines. This flag may be only used in Undo.
56 DontCombineRedlines
= 0x400,
60 template<> struct typed_flags
<RedlineFlags
> : is_typed_flags
<RedlineFlags
, 0x533> {};
63 inline OUString
SwRedlineTypeToOUString(RedlineType eType
)
68 case RedlineType::Insert
: sRet
= "Insert"; break;
69 case RedlineType::Delete
: sRet
= "Delete"; break;
70 case RedlineType::Format
: sRet
= "Format"; break;
71 case RedlineType::ParagraphFormat
: sRet
= "ParagraphFormat"; break;
72 case RedlineType::Table
: sRet
= "TextTable"; break;
73 case RedlineType::FmtColl
:sRet
= "Style"; break;
79 class IDocumentRedlineAccess
81 // Static helper functions
83 static bool IsShowChanges(const RedlineFlags eM
)
84 { return (RedlineFlags::ShowInsert
| RedlineFlags::ShowDelete
) == (eM
& RedlineFlags::ShowMask
); }
86 static bool IsHideChanges(const RedlineFlags eM
)
87 { return RedlineFlags::ShowInsert
== (eM
& RedlineFlags::ShowMask
); }
89 static bool IsShowOriginal(const RedlineFlags eM
)
90 { return RedlineFlags::ShowDelete
== (eM
& RedlineFlags::ShowMask
); }
92 static bool IsRedlineOn(const RedlineFlags eM
)
93 { return RedlineFlags::On
== (eM
& (RedlineFlags::On
| RedlineFlags::Ignore
)); }
97 /** Query the currently set redline mode
100 the currently set redline mode
102 virtual RedlineFlags
GetRedlineFlags() const = 0;
104 /** Set a new redline mode.
107 [in] the new redline mode.
109 virtual void SetRedlineFlags_intern(/*[in]*/RedlineFlags eMode
) = 0;
111 /** Set a new redline mode.
114 [in] the new redline mode.
116 virtual void SetRedlineFlags(/*[in]*/RedlineFlags eMode
) = 0;
118 /** Query if redlining is on.
121 <TRUE/> if redlining is on <FALSE/> otherwise
123 virtual bool IsRedlineOn() const = 0;
125 virtual bool IsIgnoreRedline() const = 0;
127 virtual const SwRedlineTable
& GetRedlineTable() const = 0;
128 virtual SwRedlineTable
& GetRedlineTable() = 0;
129 virtual const SwExtraRedlineTable
& GetExtraRedlineTable() const = 0;
130 virtual SwExtraRedlineTable
& GetExtraRedlineTable() = 0;
132 virtual bool IsInRedlines(const SwNode
& rNode
) const = 0;
134 enum class AppendResult
{ IGNORED
, MERGED
, APPENDED
};
135 /** Append a new redline
137 @param pNewRedl redline to insert
140 if set, then for a new DELETE redline that is inserted so that it
141 overlaps an existing INSERT redline with the same author, the
142 overlapping range is deleted, i.e. the new DELETE removes
143 existing INSERT for that range
146 APPENDED if pNewRedl is still alive and was appended
147 MERGED if pNewRedl was deleted but has been merged with existing one
148 IGNORED if pNewRedl was deleted and ignored/invalid
150 virtual AppendResult
AppendRedline(/*[in]*/ SwRangeRedline
* pNewRedl
, /*[in]*/ bool bCallDelete
,
151 /*[in]*/ sal_uInt32 nMoveIDToDelete
= 0) = 0;
153 virtual bool AppendTableRowRedline(/*[in]*/SwTableRowRedline
* pPtr
) = 0;
154 virtual bool AppendTableCellRedline(/*[in]*/SwTableCellRedline
* pPtr
) = 0;
156 virtual bool SplitRedline(/*[in]*/const SwPaM
& rPam
) = 0;
158 virtual bool DeleteRedline(
159 /*[in]*/const SwPaM
& rPam
,
160 /*[in]*/bool bSaveInUndo
,
161 /*[in]*/RedlineType nDelType
) = 0;
163 virtual bool DeleteRedline(
164 /*[in]*/const SwStartNode
& rSection
,
165 /*[in]*/bool bSaveInUndo
,
166 /*[in]*/RedlineType nDelType
) = 0;
168 virtual SwRedlineTable::size_type
GetRedlinePos(
169 /*[in]*/const SwNode
& rNode
,
170 /*[in]*/RedlineType nType
) const = 0;
172 virtual SwRedlineTable::size_type
GetRedlineEndPos(
173 /*[in]*/ SwRedlineTable::size_type nStartPos
,
174 /*[in]*/ const SwNode
& rNode
,
175 /*[in]*/ RedlineType nType
) const = 0;
177 virtual bool HasRedline(
178 /*[in]*/const SwPaM
& rPam
,
179 /*[in]*/RedlineType nType
,
180 /*[in]*/bool bStartOrEndInRange
) const = 0;
182 virtual void CompressRedlines(size_t nStartIndex
= 0) = 0;
184 virtual const SwRangeRedline
* GetRedline(
185 /*[in]*/const SwPosition
& rPos
,
186 /*[in]*/SwRedlineTable::size_type
* pFndPos
) const = 0;
188 virtual bool IsRedlineMove() const = 0;
190 virtual void SetRedlineMove(/*[in]*/bool bFlag
) = 0;
192 virtual bool AcceptRedline(/*[in]*/ SwRedlineTable::size_type nPos
, /*[in]*/ bool bCallDelete
,
193 /*[in]*/ bool bRange
= false)
196 virtual bool AcceptRedline(/*[in]*/ const SwPaM
& rPam
, /*[in]*/ bool bCallDelete
,
197 /*[in]*/ sal_Int8 nDepth
= 0)
200 virtual void AcceptRedlineParagraphFormatting(/*[in]*/const SwPaM
& rPam
) = 0;
202 virtual bool RejectRedline(/*[in]*/ SwRedlineTable::size_type nPos
,
203 /*[in]*/ bool bCallDelete
, /*[in]*/ bool bRange
= false)
206 virtual bool RejectRedline(/*[in]*/ const SwPaM
& rPam
, /*[in]*/ bool bCallDelete
,
207 /*[in]*/ sal_Int8 nDepth
= 0)
210 virtual const SwRangeRedline
* SelNextRedline(/*[in]*/SwPaM
& rPam
) const = 0;
212 virtual const SwRangeRedline
* SelPrevRedline(/*[in]*/SwPaM
& rPam
) const = 0;
214 virtual void AcceptAllRedline(/*[in]*/bool bAcceptReject
) = 0;
216 // Representation has changed, invalidate all Redlines.
217 virtual void UpdateRedlineAttr() = 0;
219 // Create a new Author if required.
220 virtual std::size_t GetRedlineAuthor() = 0;
222 // For Readers etc.: register new Author in table.
223 virtual std::size_t InsertRedlineAuthor(const OUString
& rAuthor
) = 0;
225 // Place a comment at Redline at given position.
226 virtual bool SetRedlineComment(
227 /*[in]*/const SwPaM
& rPam
,
228 /*[in]*/const OUString
& rComment
) = 0;
230 virtual const css::uno::Sequence
<sal_Int8
>& GetRedlinePassword() const = 0;
232 virtual void SetRedlinePassword(
233 /*[in]*/const css::uno::Sequence
<sal_Int8
>& rNewPassword
) = 0;
235 virtual void UpdateRedlineContentNode(/*[in]*/ SwRedlineTable::size_type nStartPos
,
236 /*[in]*/ SwRedlineTable::size_type nEndPos
) const = 0;
240 virtual ~IDocumentRedlineAccess() {};
243 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */