Line data Source code
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_SC_SOURCE_UI_INC_CONFLICTSDLG_HXX
21 : #define INCLUDED_SC_SOURCE_UI_INC_CONFLICTSDLG_HXX
22 :
23 : #include <vcl/button.hxx>
24 : #include <vcl/dialog.hxx>
25 : #include <vcl/fixed.hxx>
26 : #include <vcl/lstbox.hxx>
27 : #include <vcl/idle.hxx>
28 : #include <svx/ctredlin.hxx>
29 :
30 : #include "chgtrack.hxx"
31 : #include "docsh.hxx"
32 :
33 : class ScViewData;
34 :
35 : enum ScConflictAction
36 : {
37 : SC_CONFLICT_ACTION_NONE,
38 : SC_CONFLICT_ACTION_KEEP_MINE,
39 : SC_CONFLICT_ACTION_KEEP_OTHER
40 : };
41 :
42 : typedef ::std::vector< sal_uLong > ScChangeActionList;
43 :
44 : // struct ScConflictsListEntry
45 :
46 0 : struct ScConflictsListEntry
47 : {
48 : ScConflictAction meConflictAction;
49 : ScChangeActionList maSharedActions;
50 : ScChangeActionList maOwnActions;
51 :
52 : bool HasSharedAction( sal_uLong nSharedAction ) const;
53 : bool HasOwnAction( sal_uLong nOwnAction ) const;
54 : };
55 :
56 : typedef ::std::vector< ScConflictsListEntry > ScConflictsList;
57 :
58 : // class ScConflictsListHelper
59 :
60 : class ScConflictsListHelper
61 : {
62 : private:
63 : static void Transform_Impl( ScChangeActionList& rActionList, ScChangeActionMergeMap* pMergeMap );
64 :
65 : public:
66 : static bool HasOwnAction( ScConflictsList& rConflictsList, sal_uLong nOwnAction );
67 :
68 : static ScConflictsListEntry* GetSharedActionEntry( ScConflictsList& rConflictsList, sal_uLong nSharedAction );
69 : static ScConflictsListEntry* GetOwnActionEntry( ScConflictsList& rConflictsList, sal_uLong nOwnAction );
70 :
71 : static void TransformConflictsList( ScConflictsList& rConflictsList,
72 : ScChangeActionMergeMap* pSharedMap, ScChangeActionMergeMap* pOwnMap );
73 : };
74 :
75 : // class ScConflictsFinder
76 :
77 : class ScConflictsFinder
78 : {
79 : private:
80 : ScChangeTrack* mpTrack;
81 : sal_uLong mnStartShared;
82 : sal_uLong mnEndShared;
83 : sal_uLong mnStartOwn;
84 : sal_uLong mnEndOwn;
85 : ScConflictsList& mrConflictsList;
86 :
87 : static bool DoActionsIntersect( const ScChangeAction* pAction1, const ScChangeAction* pAction2 );
88 : ScConflictsListEntry* GetIntersectingEntry( const ScChangeAction* pAction ) const;
89 : ScConflictsListEntry* GetEntry( sal_uLong nSharedAction, const ScChangeActionList& rOwnActions );
90 :
91 : public:
92 : ScConflictsFinder( ScChangeTrack* pTrack, sal_uLong nStartShared, sal_uLong nEndShared,
93 : sal_uLong nStartOwn, sal_uLong nEndOwn, ScConflictsList& rConflictsList );
94 : virtual ~ScConflictsFinder();
95 :
96 : bool Find();
97 : };
98 :
99 : // class ScConflictsResolver
100 :
101 : class ScConflictsResolver
102 : {
103 : private:
104 : ScChangeTrack* mpTrack;
105 : ScConflictsList& mrConflictsList;
106 :
107 : public:
108 : ScConflictsResolver( ScChangeTrack* pTrack, ScConflictsList& rConflictsList );
109 : virtual ~ScConflictsResolver();
110 :
111 : void HandleAction( ScChangeAction* pAction, bool bIsSharedAction,
112 : bool bHandleContentAction, bool bHandleNonContentAction );
113 : };
114 :
115 : // class ScConflictsDlg
116 :
117 : class ScConflictsDlg : public ModalDialog
118 : {
119 : private:
120 : VclPtr<SvSimpleTableContainer> m_pLbConflictsContainer;
121 : VclPtr<SvxRedlinTable> m_pLbConflicts;
122 : VclPtr<PushButton> m_pBtnKeepMine;
123 : VclPtr<PushButton> m_pBtnKeepOther;
124 : VclPtr<PushButton> m_pBtnKeepAllMine;
125 : VclPtr<PushButton> m_pBtnKeepAllOthers;
126 :
127 : OUString maStrTitleConflict;
128 : OUString maStrTitleAuthor;
129 : OUString maStrTitleDate;
130 : OUString maStrUnknownUser;
131 :
132 : ScViewData* mpViewData;
133 : ScDocument* mpOwnDoc;
134 : ScChangeTrack* mpOwnTrack;
135 : ScDocument* mpSharedDoc;
136 : ScChangeTrack* mpSharedTrack;
137 : ScConflictsList& mrConflictsList;
138 : Size maDialogSize;
139 :
140 : Idle maSelectionIdle;
141 : bool mbInSelectHdl;
142 : bool mbInDeselectHdl;
143 :
144 : OUString GetConflictString( const ScConflictsListEntry& rConflictEntry );
145 : OUString GetActionString( const ScChangeAction* pAction, ScDocument* pDoc );
146 : void HandleListBoxSelection( bool bSelectHandle );
147 :
148 : static void SetConflictAction( SvTreeListEntry* pRootEntry, ScConflictAction eConflictAction );
149 : void KeepHandler( bool bMine );
150 : void KeepAllHandler( bool bMine );
151 :
152 : DECL_LINK( SelectHandle, void* );
153 : DECL_LINK( DeselectHandle, void* );
154 : DECL_LINK_TYPED( UpdateSelectionHdl, Idle*, void );
155 : DECL_LINK( KeepMineHandle, void* );
156 : DECL_LINK( KeepOtherHandle, void* );
157 : DECL_LINK( KeepAllMineHandle, void* );
158 : DECL_LINK( KeepAllOthersHandle, void* );
159 :
160 : public:
161 : ScConflictsDlg( vcl::Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList );
162 : virtual ~ScConflictsDlg();
163 : virtual void dispose() SAL_OVERRIDE;
164 :
165 : void UpdateView();
166 : };
167 :
168 : #endif
169 :
170 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|