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