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 void CompressRedlines() override;
80 
81     virtual const SwRangeRedline* GetRedline(
82         /*[in]*/const SwPosition& rPos,
83         /*[in]*/SwRedlineTable::size_type* pFndPos) const override;
84 
85     virtual bool IsRedlineMove() const override;
86 
87     virtual void SetRedlineMove(/*[in]*/bool bFlag) override;
88 
89     virtual bool AcceptRedline(/*[in]*/SwRedlineTable::size_type nPos, /*[in]*/bool bCallDelete) override;
90 
91     virtual bool AcceptRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) override;
92 
93     virtual void AcceptRedlineParagraphFormatting(/*[in]*/const SwPaM& rPam) override;
94 
95     virtual bool RejectRedline(/*[in]*/SwRedlineTable::size_type nPos, /*[in]*/bool bCallDelete) override;
96 
97     virtual bool RejectRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) override;
98 
99     virtual void AcceptAllRedline(/*[in]*/bool bAcceptReject) override;
100 
101     virtual const SwRangeRedline* SelNextRedline(/*[in]*/SwPaM& rPam) const override;
102 
103     virtual const SwRangeRedline* SelPrevRedline(/*[in]*/SwPaM& rPam) const override;
104 
105     virtual void UpdateRedlineAttr() override;
106 
107     virtual std::size_t GetRedlineAuthor() override;
108 
109     virtual std::size_t InsertRedlineAuthor(const OUString& rAuthor) override;
110 
111     virtual bool SetRedlineComment(
112         /*[in]*/const SwPaM& rPam,
113         /*[in]*/const OUString& rComment) override;
114 
115     virtual const css::uno::Sequence <sal_Int8>& GetRedlinePassword() const override;
116 
117     virtual void SetRedlinePassword(
118         /*[in]*/const css::uno::Sequence <sal_Int8>& rNewPassword) override;
119 
120     //Non Interface methods;
121 
122     /** Set comment-text for Redline. It then comes in via AppendRedLine.
123      Used by AutoFormat. 0-pointer resets mode.
124      Sequence number is for conjoining of Redlines by the UI. */
125     void SetAutoFormatRedlineComment( const OUString* pText, sal_uInt16 nSeqNo = 0 );
126 
IsHideRedlines() const127     bool IsHideRedlines() const { return m_bHideRedlines; }
SetHideRedlines(bool const bHideRedlines)128     void SetHideRedlines(bool const bHideRedlines) { m_bHideRedlines = bHideRedlines; }
129 
130     virtual ~DocumentRedlineManager() override;
131 
132 private:
133 
134     DocumentRedlineManager(DocumentRedlineManager const&) = delete;
135     DocumentRedlineManager& operator=(DocumentRedlineManager const&) = delete;
136 
137     SwDoc& m_rDoc;
138 
139     RedlineFlags meRedlineFlags;     //< Current Redline Mode.
140     std::unique_ptr<SwRedlineTable> mpRedlineTable;           //< List of all Ranged Redlines.
141     std::unique_ptr<SwExtraRedlineTable> mpExtraRedlineTable;      //< List of all Extra Redlines.
142     std::unique_ptr<OUString> mpAutoFormatRedlnComment;  //< Comment for Redlines inserted via AutoFormat.
143     bool mbIsRedlineMove;    //< true: Redlines are moved into to / out of the section.
144     sal_uInt16 mnAutoFormatRedlnCommentNo;  /**< SeqNo for conjoining of AutoFormat-Redlines.
145                                          by the UI. Managed by SwAutoFormat! */
146     css::uno::Sequence <sal_Int8 > maRedlinePasswd;
147 
148     /// this flag is necessary for file import because the ViewShell/layout is
149     /// created "too late" and the ShowRedlineChanges item is not below "Views"
150     bool m_bHideRedlines = false;
151 };
152 
153 }
154 
155 #endif
156 
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
158