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 SC_CONFLICTSDLG_HXX
21 : #define SC_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 <svx/ctredlin.hxx>
28 :
29 : #include "chgtrack.hxx"
30 : #include "docsh.hxx"
31 :
32 : class ScViewData;
33 :
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 :
47 0 : struct ScConflictsListEntry
48 : {
49 : ScConflictAction meConflictAction;
50 : ScChangeActionList maSharedActions;
51 : ScChangeActionList maOwnActions;
52 :
53 : bool HasSharedAction( sal_uLong nSharedAction ) const;
54 : bool HasOwnAction( sal_uLong nOwnAction ) const;
55 : };
56 :
57 :
58 : typedef ::std::vector< ScConflictsListEntry > ScConflictsList;
59 :
60 : // class ScConflictsListHelper
61 :
62 :
63 : class ScConflictsListHelper
64 : {
65 : private:
66 : static void Transform_Impl( ScChangeActionList& rActionList, ScChangeActionMergeMap* pMergeMap );
67 :
68 : public:
69 : static bool HasOwnAction( ScConflictsList& rConflictsList, sal_uLong nOwnAction );
70 :
71 : static ScConflictsListEntry* GetSharedActionEntry( ScConflictsList& rConflictsList, sal_uLong nSharedAction );
72 : static ScConflictsListEntry* GetOwnActionEntry( ScConflictsList& rConflictsList, sal_uLong nOwnAction );
73 :
74 : static void TransformConflictsList( ScConflictsList& rConflictsList,
75 : ScChangeActionMergeMap* pSharedMap, ScChangeActionMergeMap* pOwnMap );
76 : };
77 :
78 : // class ScConflictsFinder
79 :
80 :
81 : class ScConflictsFinder
82 : {
83 : private:
84 : ScChangeTrack* mpTrack;
85 : sal_uLong mnStartShared;
86 : sal_uLong mnEndShared;
87 : sal_uLong mnStartOwn;
88 : sal_uLong mnEndOwn;
89 : ScConflictsList& mrConflictsList;
90 :
91 : static bool DoActionsIntersect( const ScChangeAction* pAction1, const ScChangeAction* pAction2 );
92 : ScConflictsListEntry* GetIntersectingEntry( const ScChangeAction* pAction ) const;
93 : ScConflictsListEntry* GetEntry( sal_uLong nSharedAction, const ScChangeActionList& rOwnActions );
94 :
95 : public:
96 : ScConflictsFinder( ScChangeTrack* pTrack, sal_uLong nStartShared, sal_uLong nEndShared,
97 : sal_uLong nStartOwn, sal_uLong nEndOwn, ScConflictsList& rConflictsList );
98 : virtual ~ScConflictsFinder();
99 :
100 : bool Find();
101 : };
102 :
103 : // class ScConflictsResolver
104 :
105 :
106 : class ScConflictsResolver
107 : {
108 : private:
109 : ScChangeTrack* mpTrack;
110 : ScConflictsList& mrConflictsList;
111 :
112 : public:
113 : ScConflictsResolver( ScChangeTrack* pTrack, ScConflictsList& rConflictsList );
114 : virtual ~ScConflictsResolver();
115 :
116 : void HandleAction( ScChangeAction* pAction, bool bIsSharedAction,
117 : bool bHandleContentAction, bool bHandleNonContentAction );
118 : };
119 :
120 : // class ScConflictsDlg
121 :
122 :
123 : class ScConflictsDlg : public ModalDialog
124 : {
125 : private:
126 : FixedText maFtConflicts;
127 : SvSimpleTableContainer m_aLbConflictsContainer;
128 : SvxRedlinTable maLbConflicts;
129 : PushButton maBtnKeepMine;
130 : PushButton maBtnKeepOther;
131 : FixedLine maFlConflicts;
132 : PushButton maBtnKeepAllMine;
133 : PushButton maBtnKeepAllOthers;
134 : CancelButton maBtnCancel;
135 : HelpButton maBtnHelp;
136 :
137 : OUString maStrTitleConflict;
138 : OUString maStrTitleAuthor;
139 : OUString maStrTitleDate;
140 : OUString maStrUnknownUser;
141 :
142 : ScViewData* mpViewData;
143 : ScDocument* mpOwnDoc;
144 : ScChangeTrack* mpOwnTrack;
145 : ScDocument* mpSharedDoc;
146 : ScChangeTrack* mpSharedTrack;
147 : ScConflictsList& mrConflictsList;
148 : Size maDialogSize;
149 :
150 : Timer maSelectionTimer;
151 : bool mbInSelectHdl;
152 : bool mbInDeselectHdl;
153 :
154 : OUString GetConflictString( const ScConflictsListEntry& rConflictEntry );
155 : OUString GetActionString( const ScChangeAction* pAction, ScDocument* pDoc );
156 : void HandleListBoxSelection( bool bSelectHandle );
157 :
158 : void SetConflictAction( SvTreeListEntry* pRootEntry, ScConflictAction eConflictAction );
159 : void KeepHandler( bool bMine );
160 : void KeepAllHandler( bool bMine );
161 :
162 : DECL_LINK( SelectHandle, void* );
163 : DECL_LINK( DeselectHandle, void* );
164 : DECL_LINK( UpdateSelectionHdl, void* );
165 : DECL_LINK( KeepMineHandle, void* );
166 : DECL_LINK( KeepOtherHandle, void* );
167 : DECL_LINK( KeepAllMineHandle, void* );
168 : DECL_LINK( KeepAllOthersHandle, void* );
169 :
170 : public:
171 : ScConflictsDlg( Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList );
172 : virtual ~ScConflictsDlg();
173 :
174 : virtual void Resize() SAL_OVERRIDE;
175 : void UpdateView();
176 : };
177 :
178 : #endif
179 :
180 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|