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 <vcl/idle.hxx>
23 #include <svx/ctredlin.hxx>
33 SC_CONFLICT_ACTION_NONE
,
34 SC_CONFLICT_ACTION_KEEP_MINE
,
35 SC_CONFLICT_ACTION_KEEP_OTHER
38 // struct ScConflictsListEntry
40 struct ScConflictsListEntry
42 ScConflictAction meConflictAction
;
43 std::vector
<sal_uLong
> maSharedActions
;
44 std::vector
<sal_uLong
> maOwnActions
;
46 bool HasSharedAction( sal_uLong nSharedAction
) const;
47 bool HasOwnAction( sal_uLong nOwnAction
) const;
50 typedef ::std::vector
< ScConflictsListEntry
> ScConflictsList
;
53 class ScConflictsListHelper
56 static void Transform_Impl( std::vector
<sal_uLong
>& rActionList
, ScChangeActionMergeMap
* pMergeMap
);
59 static bool HasOwnAction( ScConflictsList
& rConflictsList
, sal_uLong nOwnAction
);
61 static ScConflictsListEntry
* GetSharedActionEntry( ScConflictsList
& rConflictsList
, sal_uLong nSharedAction
);
62 static ScConflictsListEntry
* GetOwnActionEntry( ScConflictsList
& rConflictsList
, sal_uLong nOwnAction
);
64 static void TransformConflictsList( ScConflictsList
& rConflictsList
,
65 ScChangeActionMergeMap
* pSharedMap
, ScChangeActionMergeMap
* pOwnMap
);
69 class ScConflictsFinder final
72 ScChangeTrack
* mpTrack
;
73 sal_uLong mnStartShared
;
74 sal_uLong mnEndShared
;
77 ScConflictsList
& mrConflictsList
;
79 static bool DoActionsIntersect( const ScChangeAction
* pAction1
, const ScChangeAction
* pAction2
);
80 ScConflictsListEntry
* GetIntersectingEntry( const ScChangeAction
* pAction
) const;
81 ScConflictsListEntry
& GetEntry(sal_uLong nSharedAction
, const std::vector
<sal_uLong
>& rOwnActions
);
84 ScConflictsFinder( ScChangeTrack
* pTrack
, sal_uLong nStartShared
, sal_uLong nEndShared
,
85 sal_uLong nStartOwn
, sal_uLong nEndOwn
, ScConflictsList
& rConflictsList
);
91 class ScConflictsResolver final
94 ScChangeTrack
* mpTrack
;
95 ScConflictsList
& mrConflictsList
;
98 ScConflictsResolver( ScChangeTrack
* pTrack
, ScConflictsList
& rConflictsList
);
100 void HandleAction( ScChangeAction
* pAction
, bool bIsSharedAction
,
101 bool bHandleContentAction
, bool bHandleNonContentAction
);
105 class ScConflictsDlg
: public weld::GenericDialogController
108 OUString maStrUnknownUser
;
110 ScViewData
* const mpViewData
;
111 ScDocument
* mpOwnDoc
;
112 ScChangeTrack
* mpOwnTrack
;
113 ScDocument
* const mpSharedDoc
;
114 ScChangeTrack
* mpSharedTrack
;
115 ScConflictsList
& mrConflictsList
;
117 Idle maSelectionIdle
;
120 std::unique_ptr
<weld::Button
> m_xBtnKeepMine
;
121 std::unique_ptr
<weld::Button
> m_xBtnKeepOther
;
122 std::unique_ptr
<weld::Button
> m_xBtnKeepAllMine
;
123 std::unique_ptr
<weld::Button
> m_xBtnKeepAllOthers
;
124 std::unique_ptr
<SvxRedlinTable
> m_xLbConflicts
;
126 OUString
GetConflictString( const ScConflictsListEntry
& rConflictEntry
);
127 void SetActionString(const ScChangeAction
* pAction
, ScDocument
* pDoc
, const weld::TreeIter
& rEntry
);
128 void HandleListBoxSelection();
130 void SetConflictAction(const weld::TreeIter
& rRootEntry
, ScConflictAction eConflictAction
);
131 void KeepHandler( bool bMine
);
132 void KeepAllHandler( bool bMine
);
134 DECL_LINK( SelectHandle
, weld::TreeView
&, void );
135 DECL_LINK( UpdateSelectionHdl
, Timer
*, void );
136 DECL_LINK( KeepMineHandle
, weld::Button
&, void );
137 DECL_LINK( KeepOtherHandle
, weld::Button
&, void );
138 DECL_LINK( KeepAllMineHandle
, weld::Button
&, void );
139 DECL_LINK( KeepAllOthersHandle
, weld::Button
&, void );
142 ScConflictsDlg(weld::Window
* pParent
, ScViewData
* pViewData
, ScDocument
* pSharedDoc
, ScConflictsList
& rConflictsList
);
143 virtual ~ScConflictsDlg() override
;
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */