xref: /trunk/main/sc/source/ui/inc/conflictsdlg.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_CONFLICTSDLG_HXX
29 #define SC_CONFLICTSDLG_HXX
30 
31 #include <vcl/button.hxx>
32 #include <vcl/dialog.hxx>
33 #include <vcl/fixed.hxx>
34 #include <vcl/lstbox.hxx>
35 #include <svx/ctredlin.hxx>
36 
37 #include "chgtrack.hxx"
38 #include "docsh.hxx"
39 
40 class ScViewData;
41 
42 
43 //=============================================================================
44 
45 enum ScConflictAction
46 {
47     SC_CONFLICT_ACTION_NONE,
48     SC_CONFLICT_ACTION_KEEP_MINE,
49     SC_CONFLICT_ACTION_KEEP_OTHER
50 };
51 
52 typedef ::std::vector< sal_uLong > ScChangeActionList;
53 
54 
55 //=============================================================================
56 // struct ScConflictsListEntry
57 //=============================================================================
58 
59 struct ScConflictsListEntry
60 {
61     ScConflictAction    meConflictAction;
62     ScChangeActionList  maSharedActions;
63     ScChangeActionList  maOwnActions;
64 
65     bool                HasSharedAction( sal_uLong nSharedAction ) const;
66     bool                HasOwnAction( sal_uLong nOwnAction ) const;
67 };
68 
69 
70 //=============================================================================
71 
72 typedef ::std::vector< ScConflictsListEntry > ScConflictsList;
73 
74 
75 //=============================================================================
76 // class ScConflictsListHelper
77 //=============================================================================
78 
79 class ScConflictsListHelper
80 {
81 private:
82     static void                     Transform_Impl( ScChangeActionList& rActionList, ScChangeActionMergeMap* pMergeMap );
83 
84 public:
85 //UNUSED2008-05  static bool                     HasSharedAction( ScConflictsList& rConflictsList, sal_uLong nSharedAction );
86     static bool                     HasOwnAction( ScConflictsList& rConflictsList, sal_uLong nOwnAction );
87 
88     static ScConflictsListEntry*    GetSharedActionEntry( ScConflictsList& rConflictsList, sal_uLong nSharedAction );
89     static ScConflictsListEntry*    GetOwnActionEntry( ScConflictsList& rConflictsList, sal_uLong nOwnAction );
90 
91     static void                     TransformConflictsList( ScConflictsList& rConflictsList,
92                                         ScChangeActionMergeMap* pSharedMap, ScChangeActionMergeMap* pOwnMap );
93 };
94 
95 
96 //=============================================================================
97 // class ScConflictsFinder
98 //=============================================================================
99 
100 class ScConflictsFinder
101 {
102 private:
103     ScChangeTrack*          mpTrack;
104     sal_uLong                   mnStartShared;
105     sal_uLong                   mnEndShared;
106     sal_uLong                   mnStartOwn;
107     sal_uLong                   mnEndOwn;
108     ScConflictsList&        mrConflictsList;
109 
110     static bool             DoActionsIntersect( const ScChangeAction* pAction1, const ScChangeAction* pAction2 );
111     ScConflictsListEntry*   GetIntersectingEntry( const ScChangeAction* pAction ) const;
112     ScConflictsListEntry*   GetEntry( sal_uLong nSharedAction, const ScChangeActionList& rOwnActions );
113 
114 public:
115                             ScConflictsFinder( ScChangeTrack* pTrack, sal_uLong nStartShared, sal_uLong nEndShared,
116                                 sal_uLong nStartOwn, sal_uLong nEndOwn, ScConflictsList& rConflictsList );
117     virtual                 ~ScConflictsFinder();
118 
119     bool                    Find();
120 };
121 
122 
123 //=============================================================================
124 // class ScConflictsResolver
125 //=============================================================================
126 
127 class ScConflictsResolver
128 {
129 private:
130     ScChangeTrack*      mpTrack;
131     ScConflictsList&    mrConflictsList;
132 
133 public:
134                         ScConflictsResolver( ScChangeTrack* pTrack, ScConflictsList& rConflictsList );
135     virtual             ~ScConflictsResolver();
136 
137     void                HandleAction( ScChangeAction* pAction, bool bIsSharedAction,
138                             bool bHandleContentAction, bool bHandleNonContentAction );
139 };
140 
141 
142 //=============================================================================
143 // class ScConflictsListBox
144 //=============================================================================
145 
146 class ScConflictsListBox: public SvxRedlinTable
147 {
148 private:
149 
150 public:
151 //UNUSED2008-05         ScConflictsListBox( Window* pParent, WinBits nBits = WB_BORDER );
152                         ScConflictsListBox( Window* pParent, const ResId& rResId );
153                         ~ScConflictsListBox();
154 
155 //UNUSED2008-05  sal_uLong               GetRootEntryPos( const SvLBoxEntry* pRootEntry ) const;
156 };
157 
158 //=============================================================================
159 // class ScConflictsDlg
160 //=============================================================================
161 
162 class ScConflictsDlg : public ModalDialog
163 {
164 private:
165     FixedText           maFtConflicts;
166     ScConflictsListBox  maLbConflicts;
167     PushButton          maBtnKeepMine;
168     PushButton          maBtnKeepOther;
169     FixedLine           maFlConflicts;
170     PushButton          maBtnKeepAllMine;
171     PushButton          maBtnKeepAllOthers;
172     CancelButton        maBtnCancel;
173     HelpButton          maBtnHelp;
174 
175     String              maStrTitleConflict;
176     String              maStrTitleAuthor;
177     String              maStrTitleDate;
178     String              maStrUnknownUser;
179 
180     ScViewData*         mpViewData;
181     ScDocument*         mpOwnDoc;
182     ScChangeTrack*      mpOwnTrack;
183     ScDocument*         mpSharedDoc;
184     ScChangeTrack*      mpSharedTrack;
185     ScConflictsList&    mrConflictsList;
186     Size                maDialogSize;
187 
188     Timer               maSelectionTimer;
189     bool                mbInSelectHdl;
190     bool                mbInDeselectHdl;
191 
192     String              GetConflictString( const ScConflictsListEntry& rConflictEntry );
193     String              GetActionString( const ScChangeAction* pAction, ScDocument* pDoc );
194     void                HandleListBoxSelection( bool bSelectHandle );
195 
196     void                SetConflictAction( SvLBoxEntry* pRootEntry, ScConflictAction eConflictAction );
197     void                KeepHandler( bool bMine );
198     void                KeepAllHandler( bool bMine );
199 
200     DECL_LINK( SelectHandle, SvxRedlinTable* );
201     DECL_LINK( DeselectHandle, SvxRedlinTable* );
202     DECL_LINK( UpdateSelectionHdl, Timer* );
203     DECL_LINK( KeepMineHandle, void* );
204     DECL_LINK( KeepOtherHandle, void* );
205     DECL_LINK( KeepAllMineHandle, void* );
206     DECL_LINK( KeepAllOthersHandle, void* );
207 
208 public:
209                         ScConflictsDlg( Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList );
210                         ~ScConflictsDlg();
211 
212     virtual void        Resize();
213     void                UpdateView();
214 };
215 
216 #endif
217