Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / ui / inc / conflictsdlg.hxx
blob4220c2a1efead48a07192d55edd204841f18d423
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_SC_SOURCE_UI_INC_CONFLICTSDLG_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_CONFLICTSDLG_HXX
23 #include <vcl/idle.hxx>
24 #include <svx/ctredlin.hxx>
26 #include "docsh.hxx"
28 class ScViewData;
29 class ScChangeTrack;
30 class ScChangeAction;
32 enum ScConflictAction
34 SC_CONFLICT_ACTION_NONE,
35 SC_CONFLICT_ACTION_KEEP_MINE,
36 SC_CONFLICT_ACTION_KEEP_OTHER
39 // struct ScConflictsListEntry
41 struct ScConflictsListEntry
43 ScConflictAction meConflictAction;
44 std::vector<sal_uLong> maSharedActions;
45 std::vector<sal_uLong> maOwnActions;
47 bool HasSharedAction( sal_uLong nSharedAction ) const;
48 bool HasOwnAction( sal_uLong nOwnAction ) const;
51 typedef ::std::vector< ScConflictsListEntry > ScConflictsList;
53 // class ScConflictsListHelper
55 class ScConflictsListHelper
57 private:
58 static void Transform_Impl( std::vector<sal_uLong>& rActionList, ScChangeActionMergeMap* pMergeMap );
60 public:
61 static bool HasOwnAction( ScConflictsList& rConflictsList, sal_uLong nOwnAction );
63 static ScConflictsListEntry* GetSharedActionEntry( ScConflictsList& rConflictsList, sal_uLong nSharedAction );
64 static ScConflictsListEntry* GetOwnActionEntry( ScConflictsList& rConflictsList, sal_uLong nOwnAction );
66 static void TransformConflictsList( ScConflictsList& rConflictsList,
67 ScChangeActionMergeMap* pSharedMap, ScChangeActionMergeMap* pOwnMap );
70 // class ScConflictsFinder
72 class ScConflictsFinder final
74 private:
75 ScChangeTrack* const mpTrack;
76 sal_uLong const mnStartShared;
77 sal_uLong const mnEndShared;
78 sal_uLong const mnStartOwn;
79 sal_uLong const mnEndOwn;
80 ScConflictsList& mrConflictsList;
82 static bool DoActionsIntersect( const ScChangeAction* pAction1, const ScChangeAction* pAction2 );
83 ScConflictsListEntry* GetIntersectingEntry( const ScChangeAction* pAction ) const;
84 ScConflictsListEntry& GetEntry(sal_uLong nSharedAction, const std::vector<sal_uLong>& rOwnActions);
86 public:
87 ScConflictsFinder( ScChangeTrack* pTrack, sal_uLong nStartShared, sal_uLong nEndShared,
88 sal_uLong nStartOwn, sal_uLong nEndOwn, ScConflictsList& rConflictsList );
89 ~ScConflictsFinder();
91 bool Find();
94 // class ScConflictsResolver
96 class ScConflictsResolver final
98 private:
99 ScChangeTrack* mpTrack;
100 ScConflictsList& mrConflictsList;
102 public:
103 ScConflictsResolver( ScChangeTrack* pTrack, ScConflictsList& rConflictsList );
104 ~ScConflictsResolver();
106 void HandleAction( ScChangeAction* pAction, bool bIsSharedAction,
107 bool bHandleContentAction, bool bHandleNonContentAction );
110 // class ScConflictsDlg
112 class ScConflictsDlg : public weld::GenericDialogController
114 private:
115 OUString const maStrUnknownUser;
117 ScViewData* const mpViewData;
118 ScDocument* mpOwnDoc;
119 ScChangeTrack* mpOwnTrack;
120 ScDocument* const mpSharedDoc;
121 ScChangeTrack* mpSharedTrack;
122 ScConflictsList& mrConflictsList;
124 Idle maSelectionIdle;
125 bool mbInSelectHdl;
127 std::unique_ptr<weld::Button> m_xBtnKeepMine;
128 std::unique_ptr<weld::Button> m_xBtnKeepOther;
129 std::unique_ptr<weld::Button> m_xBtnKeepAllMine;
130 std::unique_ptr<weld::Button> m_xBtnKeepAllOthers;
131 std::unique_ptr<SvxRedlinTable> m_xLbConflicts;
133 OUString GetConflictString( const ScConflictsListEntry& rConflictEntry );
134 void SetActionString(const ScChangeAction* pAction, ScDocument* pDoc, const weld::TreeIter& rEntry);
135 void HandleListBoxSelection();
137 void SetConflictAction(const weld::TreeIter& rRootEntry, ScConflictAction eConflictAction);
138 void KeepHandler( bool bMine );
139 void KeepAllHandler( bool bMine );
141 DECL_LINK( SelectHandle, weld::TreeView&, void );
142 DECL_LINK( UpdateSelectionHdl, Timer*, void );
143 DECL_LINK( KeepMineHandle, weld::Button&, void );
144 DECL_LINK( KeepOtherHandle, weld::Button&, void );
145 DECL_LINK( KeepAllMineHandle, weld::Button&, void );
146 DECL_LINK( KeepAllOthersHandle, weld::Button&, void );
148 public:
149 ScConflictsDlg(weld::Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList);
150 virtual ~ScConflictsDlg() override;
152 void UpdateView();
155 #endif
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */