tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / inc / conflictsdlg.hxx
blobf0ab643e053315c32c4818049014f87230607041
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 #pragma once
22 #include <vcl/idle.hxx>
23 #include <svx/ctredlin.hxx>
25 #include "docsh.hxx"
27 class ScViewData;
28 class ScChangeTrack;
29 class ScChangeAction;
31 enum ScConflictAction
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
55 private:
56 static void Transform_Impl( std::vector<sal_uLong>& rActionList, ScChangeActionMergeMap* pMergeMap );
58 public:
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
71 private:
72 ScChangeTrack* mpTrack;
73 sal_uLong mnStartShared;
74 sal_uLong mnEndShared;
75 sal_uLong mnStartOwn;
76 sal_uLong mnEndOwn;
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);
83 public:
84 ScConflictsFinder( ScChangeTrack* pTrack, sal_uLong nStartShared, sal_uLong nEndShared,
85 sal_uLong nStartOwn, sal_uLong nEndOwn, ScConflictsList& rConflictsList );
87 bool Find();
91 class ScConflictsResolver final
93 private:
94 ScChangeTrack* mpTrack;
95 ScConflictsList& mrConflictsList;
97 public:
98 ScConflictsResolver( ScChangeTrack* pTrack, ScConflictsList& rConflictsList );
100 void HandleAction( ScChangeAction* pAction, bool bIsSharedAction,
101 bool bHandleContentAction, bool bHandleNonContentAction );
105 class ScConflictsDlg : public weld::GenericDialogController
107 private:
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;
118 bool mbInSelectHdl;
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 );
141 public:
142 ScConflictsDlg(weld::Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList);
143 virtual ~ScConflictsDlg() override;
145 void UpdateView();
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */