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 #ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTREDLINEMANAGER_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTREDLINEMANAGER_HXX
22 
23 #include <IDocumentRedlineAccess.hxx>
24 #include <memory>
25 
26 class SwDoc;
27 
28 namespace sw
29 {
30 
31 class SAL_DLLPUBLIC_RTTI DocumentRedlineManager : public IDocumentRedlineAccess
32 {
33 public:
34     DocumentRedlineManager( SwDoc& i_rSwdoc );
35 
36     /**
37      * Replaced by SwRootFrame::IsHideRedlines() (this is model-level redline
38      * hiding).
39      */
40     virtual RedlineFlags GetRedlineFlags() const override;
41 
42     virtual void SetRedlineFlags_intern(/*[in]*/RedlineFlags eMode) override;
43 
44     virtual void SetRedlineFlags(/*[in]*/RedlineFlags eMode) override;
45 
46     virtual bool IsRedlineOn() const override;
47 
48     virtual bool IsIgnoreRedline() const override;
49 
50     virtual const SwRedlineTable& GetRedlineTable() const override;
51     virtual SwRedlineTable& GetRedlineTable() override;
52     virtual const SwExtraRedlineTable& GetExtraRedlineTable() const override;
53     virtual SwExtraRedlineTable& GetExtraRedlineTable() override;
54     virtual bool HasExtraRedlineTable() const override;
55 
56     virtual bool IsInRedlines(const SwNode& rNode) const override;
57 
58     virtual AppendResult AppendRedline(/*[in]*/SwRangeRedline* pPtr, /*[in]*/bool bCallDelete) override;
59 
60     virtual bool AppendTableRowRedline(/*[in]*/SwTableRowRedline* pPtr) override;
61     virtual bool AppendTableCellRedline(/*[in]*/SwTableCellRedline* pPtr) override;
62 
63     virtual bool SplitRedline(/*[in]*/const SwPaM& rPam) override;
64 
65     virtual bool DeleteRedline(
66         /*[in]*/const SwPaM& rPam,
67         /*[in]*/bool bSaveInUndo,
68         /*[in]*/RedlineType nDelType) override;
69 
70     virtual bool DeleteRedline(
71         /*[in]*/const SwStartNode& rSection,
72         /*[in]*/bool bSaveInUndo,
73         /*[in]*/RedlineType nDelType) override;
74 
75     virtual SwRedlineTable::size_type GetRedlinePos(
76         /*[in]*/const SwNode& rNode,
77         /*[in]*/RedlineType nType) const override;
78 
79     virtual bool HasRedline(
80         /*[in]*/const SwPaM& rPam,
81         /*[in]*/RedlineType nType,
82         /*[in]*/bool bStartOrEndInRange) const override;
83 
84     virtual void CompressRedlines() override;
85 
86     virtual const SwRangeRedline* GetRedline(
87         /*[in]*/const SwPosition& rPos,
88         /*[in]*/SwRedlineTable::size_type* pFndPos) const override;
89 
90     virtual bool IsRedlineMove() const override;
91 
92     virtual void SetRedlineMove(/*[in]*/bool bFlag) override;
93 
94     virtual bool AcceptRedline(/*[in]*/SwRedlineTable::size_type nPos, /*[in]*/bool bCallDelete) override;
95 
96     virtual bool AcceptRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) override;
97 
98     virtual void AcceptRedlineParagraphFormatting(/*[in]*/const SwPaM& rPam) override;
99 
100     virtual bool RejectRedline(/*[in]*/SwRedlineTable::size_type nPos, /*[in]*/bool bCallDelete) override;
101 
102     virtual bool RejectRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) override;
103 
104     virtual void AcceptAllRedline(/*[in]*/bool bAcceptReject) override;
105 
106     virtual const SwRangeRedline* SelNextRedline(/*[in]*/SwPaM& rPam) const override;
107 
108     virtual const SwRangeRedline* SelPrevRedline(/*[in]*/SwPaM& rPam) const override;
109 
110     virtual void UpdateRedlineAttr() override;
111 
112     virtual std::size_t GetRedlineAuthor() override;
113 
114     virtual std::size_t InsertRedlineAuthor(const OUString& rAuthor) override;
115 
116     virtual bool SetRedlineComment(
117         /*[in]*/const SwPaM& rPam,
118         /*[in]*/const OUString& rComment) override;
119 
120     virtual const css::uno::Sequence <sal_Int8>& GetRedlinePassword() const override;
121 
122     virtual void SetRedlinePassword(
123         /*[in]*/const css::uno::Sequence <sal_Int8>& rNewPassword) override;
124 
125     //Non Interface methods;
126 
127     /** Set comment-text for Redline. It then comes in via AppendRedLine.
128      Used by AutoFormat. 0-pointer resets mode.
129      Sequence number is for conjoining of Redlines by the UI. */
130     void SetAutoFormatRedlineComment( const OUString* pText, sal_uInt16 nSeqNo = 0 );
131 
IsHideRedlines() const132     bool IsHideRedlines() const { return m_bHideRedlines; }
SetHideRedlines(bool const bHideRedlines)133     void SetHideRedlines(bool const bHideRedlines) { m_bHideRedlines = bHideRedlines; }
134 
135     void HideAll(bool bDeletion);
136     void ShowAll();
137 
138     virtual ~DocumentRedlineManager() override;
139 
140 private:
141 
142     DocumentRedlineManager(DocumentRedlineManager const&) = delete;
143     DocumentRedlineManager& operator=(DocumentRedlineManager const&) = delete;
144 
145     SwDoc& m_rDoc;
146 
147     RedlineFlags meRedlineFlags;     //< Current Redline Mode.
148     std::unique_ptr<SwRedlineTable> mpRedlineTable;           //< List of all Ranged Redlines.
149     std::unique_ptr<SwExtraRedlineTable> mpExtraRedlineTable;      //< List of all Extra Redlines.
150     std::unique_ptr<OUString> mpAutoFormatRedlnComment;  //< Comment for Redlines inserted via AutoFormat.
151     bool mbIsRedlineMove;    //< true: Redlines are moved into to / out of the section.
152     sal_uInt16 mnAutoFormatRedlnCommentNo;  /**< SeqNo for conjoining of AutoFormat-Redlines.
153                                          by the UI. Managed by SwAutoFormat! */
154     css::uno::Sequence <sal_Int8 > maRedlinePasswd;
155 
156     /// this flag is necessary for file import because the ViewShell/layout is
157     /// created "too late" and the ShowRedlineChanges item is not below "Views"
158     bool m_bHideRedlines = false;
159 };
160 
161 }
162 
163 #endif
164 
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
166