xref: /aoo42x/main/sc/source/ui/inc/conflictsdlg.hxx (revision 38d50f7b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_CONFLICTSDLG_HXX
25 #define SC_CONFLICTSDLG_HXX
26 
27 #include <vcl/button.hxx>
28 #include <vcl/dialog.hxx>
29 #include <vcl/fixed.hxx>
30 #include <vcl/lstbox.hxx>
31 #include <svx/ctredlin.hxx>
32 
33 #include "chgtrack.hxx"
34 #include "docsh.hxx"
35 
36 class ScViewData;
37 
38 
39 //=============================================================================
40 
41 enum ScConflictAction
42 {
43     SC_CONFLICT_ACTION_NONE,
44     SC_CONFLICT_ACTION_KEEP_MINE,
45     SC_CONFLICT_ACTION_KEEP_OTHER
46 };
47 
48 typedef ::std::vector< sal_uLong > ScChangeActionList;
49 
50 
51 //=============================================================================
52 // struct ScConflictsListEntry
53 //=============================================================================
54 
55 struct ScConflictsListEntry
56 {
57     ScConflictAction    meConflictAction;
58     ScChangeActionList  maSharedActions;
59     ScChangeActionList  maOwnActions;
60 
61     bool                HasSharedAction( sal_uLong nSharedAction ) const;
62     bool                HasOwnAction( sal_uLong nOwnAction ) const;
63 };
64 
65 
66 //=============================================================================
67 
68 typedef ::std::vector< ScConflictsListEntry > ScConflictsList;
69 
70 
71 //=============================================================================
72 // class ScConflictsListHelper
73 //=============================================================================
74 
75 class ScConflictsListHelper
76 {
77 private:
78     static void                     Transform_Impl( ScChangeActionList& rActionList, ScChangeActionMergeMap* pMergeMap );
79 
80 public:
81 //UNUSED2008-05  static bool                     HasSharedAction( ScConflictsList& rConflictsList, sal_uLong nSharedAction );
82     static bool                     HasOwnAction( ScConflictsList& rConflictsList, sal_uLong nOwnAction );
83 
84     static ScConflictsListEntry*    GetSharedActionEntry( ScConflictsList& rConflictsList, sal_uLong nSharedAction );
85     static ScConflictsListEntry*    GetOwnActionEntry( ScConflictsList& rConflictsList, sal_uLong nOwnAction );
86 
87     static void                     TransformConflictsList( ScConflictsList& rConflictsList,
88                                         ScChangeActionMergeMap* pSharedMap, ScChangeActionMergeMap* pOwnMap );
89 };
90 
91 
92 //=============================================================================
93 // class ScConflictsFinder
94 //=============================================================================
95 
96 class ScConflictsFinder
97 {
98 private:
99     ScChangeTrack*          mpTrack;
100     sal_uLong                   mnStartShared;
101     sal_uLong                   mnEndShared;
102     sal_uLong                   mnStartOwn;
103     sal_uLong                   mnEndOwn;
104     ScConflictsList&        mrConflictsList;
105 
106     static bool             DoActionsIntersect( const ScChangeAction* pAction1, const ScChangeAction* pAction2 );
107     ScConflictsListEntry*   GetIntersectingEntry( const ScChangeAction* pAction ) const;
108     ScConflictsListEntry*   GetEntry( sal_uLong nSharedAction, const ScChangeActionList& rOwnActions );
109 
110 public:
111                             ScConflictsFinder( ScChangeTrack* pTrack, sal_uLong nStartShared, sal_uLong nEndShared,
112                                 sal_uLong nStartOwn, sal_uLong nEndOwn, ScConflictsList& rConflictsList );
113     virtual                 ~ScConflictsFinder();
114 
115     bool                    Find();
116 };
117 
118 
119 //=============================================================================
120 // class ScConflictsResolver
121 //=============================================================================
122 
123 class ScConflictsResolver
124 {
125 private:
126     ScChangeTrack*      mpTrack;
127     ScConflictsList&    mrConflictsList;
128 
129 public:
130                         ScConflictsResolver( ScChangeTrack* pTrack, ScConflictsList& rConflictsList );
131     virtual             ~ScConflictsResolver();
132 
133     void                HandleAction( ScChangeAction* pAction, bool bIsSharedAction,
134                             bool bHandleContentAction, bool bHandleNonContentAction );
135 };
136 
137 
138 //=============================================================================
139 // class ScConflictsListBox
140 //=============================================================================
141 
142 class ScConflictsListBox: public SvxRedlinTable
143 {
144 private:
145 
146 public:
147 //UNUSED2008-05         ScConflictsListBox( Window* pParent, WinBits nBits = WB_BORDER );
148                         ScConflictsListBox( Window* pParent, const ResId& rResId );
149                         ~ScConflictsListBox();
150 
151 //UNUSED2008-05  sal_uLong               GetRootEntryPos( const SvLBoxEntry* pRootEntry ) const;
152 };
153 
154 //=============================================================================
155 // class ScConflictsDlg
156 //=============================================================================
157 
158 class ScConflictsDlg : public ModalDialog
159 {
160 private:
161     FixedText           maFtConflicts;
162     ScConflictsListBox  maLbConflicts;
163     PushButton          maBtnKeepMine;
164     PushButton          maBtnKeepOther;
165     FixedLine           maFlConflicts;
166     PushButton          maBtnKeepAllMine;
167     PushButton          maBtnKeepAllOthers;
168     CancelButton        maBtnCancel;
169     HelpButton          maBtnHelp;
170 
171     String              maStrTitleConflict;
172     String              maStrTitleAuthor;
173     String              maStrTitleDate;
174     String              maStrUnknownUser;
175 
176     ScViewData*         mpViewData;
177     ScDocument*         mpOwnDoc;
178     ScChangeTrack*      mpOwnTrack;
179     ScDocument*         mpSharedDoc;
180     ScChangeTrack*      mpSharedTrack;
181     ScConflictsList&    mrConflictsList;
182     Size                maDialogSize;
183 
184     Timer               maSelectionTimer;
185     bool                mbInSelectHdl;
186     bool                mbInDeselectHdl;
187 
188     String              GetConflictString( const ScConflictsListEntry& rConflictEntry );
189     String              GetActionString( const ScChangeAction* pAction, ScDocument* pDoc );
190     void                HandleListBoxSelection( bool bSelectHandle );
191 
192     void                SetConflictAction( SvLBoxEntry* pRootEntry, ScConflictAction eConflictAction );
193     void                KeepHandler( bool bMine );
194     void                KeepAllHandler( bool bMine );
195 
196     DECL_LINK( SelectHandle, SvxRedlinTable* );
197     DECL_LINK( DeselectHandle, SvxRedlinTable* );
198     DECL_LINK( UpdateSelectionHdl, Timer* );
199     DECL_LINK( KeepMineHandle, void* );
200     DECL_LINK( KeepOtherHandle, void* );
201     DECL_LINK( KeepAllMineHandle, void* );
202     DECL_LINK( KeepAllOthersHandle, void* );
203 
204 public:
205                         ScConflictsDlg( Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList );
206                         ~ScConflictsDlg();
207 
208     virtual void        Resize();
209     void                UpdateView();
210 };
211 
212 #endif
213