Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <comphelper/string.hxx>
30 : : #include <vcl/msgbox.hxx>
31 : :
32 : : #include "conflictsdlg.hxx"
33 : : #include "conflictsdlg.hrc"
34 : : #include "scresid.hxx"
35 : : #include "viewdata.hxx"
36 : : #include "dbfunc.hxx"
37 : :
38 : :
39 : : //=============================================================================
40 : : // struct ScConflictsListEntry
41 : : //=============================================================================
42 : :
43 : 0 : bool ScConflictsListEntry::HasSharedAction( sal_uLong nSharedAction ) const
44 : : {
45 : 0 : ScChangeActionList::const_iterator aEnd = maSharedActions.end();
46 [ # # ][ # # ]: 0 : for ( ScChangeActionList::const_iterator aItr = maSharedActions.begin(); aItr != aEnd; ++aItr )
[ # # ]
47 : : {
48 [ # # ][ # # ]: 0 : if ( *aItr == nSharedAction )
49 : : {
50 : 0 : return true;
51 : : }
52 : : }
53 : :
54 : 0 : return false;
55 : : }
56 : :
57 : 0 : bool ScConflictsListEntry::HasOwnAction( sal_uLong nOwnAction ) const
58 : : {
59 : 0 : ScChangeActionList::const_iterator aEnd = maOwnActions.end();
60 [ # # ][ # # ]: 0 : for ( ScChangeActionList::const_iterator aItr = maOwnActions.begin(); aItr != aEnd; ++aItr )
[ # # ]
61 : : {
62 [ # # ][ # # ]: 0 : if ( *aItr == nOwnAction )
63 : : {
64 : 0 : return true;
65 : : }
66 : : }
67 : :
68 : 0 : return false;
69 : : }
70 : :
71 : :
72 : : //=============================================================================
73 : : // class ScConflictsListHelper
74 : : //=============================================================================
75 : :
76 : 0 : bool ScConflictsListHelper::HasOwnAction( ScConflictsList& rConflictsList, sal_uLong nOwnAction )
77 : : {
78 [ # # ]: 0 : ScConflictsList::const_iterator aEnd = rConflictsList.end();
79 [ # # ][ # # ]: 0 : for ( ScConflictsList::const_iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr )
[ # # ]
80 : : {
81 [ # # ][ # # ]: 0 : if ( aItr->HasOwnAction( nOwnAction ) )
82 : : {
83 : 0 : return true;
84 : : }
85 : : }
86 : :
87 : 0 : return false;
88 : : }
89 : :
90 : 0 : ScConflictsListEntry* ScConflictsListHelper::GetSharedActionEntry( ScConflictsList& rConflictsList, sal_uLong nSharedAction )
91 : : {
92 : 0 : ScConflictsList::iterator aEnd = rConflictsList.end();
93 [ # # ][ # # ]: 0 : for ( ScConflictsList::iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr )
94 : : {
95 [ # # ][ # # ]: 0 : if ( aItr->HasSharedAction( nSharedAction ) )
96 : : {
97 : 0 : return &(*aItr);
98 : : }
99 : : }
100 : :
101 : 0 : return NULL;
102 : : }
103 : :
104 : 0 : ScConflictsListEntry* ScConflictsListHelper::GetOwnActionEntry( ScConflictsList& rConflictsList, sal_uLong nOwnAction )
105 : : {
106 : 0 : ScConflictsList::iterator aEnd = rConflictsList.end();
107 [ # # ][ # # ]: 0 : for ( ScConflictsList::iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr )
108 : : {
109 [ # # ][ # # ]: 0 : if ( aItr->HasOwnAction( nOwnAction ) )
110 : : {
111 : 0 : return &(*aItr);
112 : : }
113 : : }
114 : :
115 : 0 : return NULL;
116 : : }
117 : :
118 : 0 : void ScConflictsListHelper::Transform_Impl( ScChangeActionList& rActionList, ScChangeActionMergeMap* pMergeMap )
119 : : {
120 [ # # ]: 0 : if ( !pMergeMap )
121 : : {
122 : 0 : return;
123 : : }
124 : :
125 [ # # ][ # # ]: 0 : for ( ScChangeActionList::iterator aItr = rActionList.begin(); aItr != rActionList.end(); )
126 : : {
127 [ # # ][ # # ]: 0 : ScChangeActionMergeMap::iterator aItrMap = pMergeMap->find( *aItr );
128 [ # # ][ # # ]: 0 : if ( aItrMap != pMergeMap->end() )
129 : : {
130 [ # # ][ # # ]: 0 : *aItr = aItrMap->second;
131 [ # # ]: 0 : ++aItr;
132 : : }
133 : : else
134 : : {
135 [ # # ]: 0 : aItr = rActionList.erase( aItr );
136 : : OSL_FAIL( "ScConflictsListHelper::Transform_Impl: erased action from conflicts list!" );
137 : : }
138 : : }
139 : : }
140 : :
141 : 0 : void ScConflictsListHelper::TransformConflictsList( ScConflictsList& rConflictsList,
142 : : ScChangeActionMergeMap* pSharedMap, ScChangeActionMergeMap* pOwnMap )
143 : : {
144 : 0 : ScConflictsList::iterator aEnd = rConflictsList.end();
145 [ # # ][ # # ]: 0 : for ( ScConflictsList::iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr )
146 : : {
147 [ # # ]: 0 : if ( pSharedMap )
148 : : {
149 [ # # ]: 0 : ScConflictsListHelper::Transform_Impl( aItr->maSharedActions, pSharedMap );
150 : : }
151 : :
152 [ # # ]: 0 : if ( pOwnMap )
153 : : {
154 [ # # ]: 0 : ScConflictsListHelper::Transform_Impl( aItr->maOwnActions, pOwnMap );
155 : : }
156 : : }
157 : 0 : }
158 : :
159 : :
160 : : //=============================================================================
161 : : // class ScConflictsFinder
162 : : //=============================================================================
163 : :
164 : 0 : ScConflictsFinder::ScConflictsFinder( ScChangeTrack* pTrack, sal_uLong nStartShared, sal_uLong nEndShared,
165 : : sal_uLong nStartOwn, sal_uLong nEndOwn, ScConflictsList& rConflictsList )
166 : : :mpTrack( pTrack )
167 : : ,mnStartShared( nStartShared )
168 : : ,mnEndShared( nEndShared )
169 : : ,mnStartOwn( nStartOwn )
170 : : ,mnEndOwn( nEndOwn )
171 : 0 : ,mrConflictsList( rConflictsList )
172 : : {
173 : 0 : }
174 : :
175 : 0 : ScConflictsFinder::~ScConflictsFinder()
176 : : {
177 [ # # ]: 0 : }
178 : :
179 : 0 : bool ScConflictsFinder::DoActionsIntersect( const ScChangeAction* pAction1, const ScChangeAction* pAction2 )
180 : : {
181 [ # # ][ # # ]: 0 : if ( pAction1 && pAction2 && pAction1->GetBigRange().Intersects( pAction2->GetBigRange() ) )
[ # # ][ # # ]
182 : : {
183 : 0 : return true;
184 : : }
185 : 0 : return false;
186 : : }
187 : :
188 : 0 : ScConflictsListEntry* ScConflictsFinder::GetIntersectingEntry( const ScChangeAction* pAction ) const
189 : : {
190 : 0 : ScConflictsList::iterator aEnd = mrConflictsList.end();
191 [ # # ][ # # ]: 0 : for ( ScConflictsList::iterator aItr = mrConflictsList.begin(); aItr != aEnd; ++aItr )
192 : : {
193 [ # # ]: 0 : ScChangeActionList::const_iterator aEndShared = aItr->maSharedActions.end();
194 [ # # ][ # # ]: 0 : for ( ScChangeActionList::const_iterator aItrShared = aItr->maSharedActions.begin(); aItrShared != aEndShared; ++aItrShared )
[ # # ][ # # ]
195 : : {
196 [ # # ][ # # ]: 0 : if ( DoActionsIntersect( mpTrack->GetAction( *aItrShared ), pAction ) )
[ # # ][ # # ]
197 : : {
198 : 0 : return &(*aItr);
199 : : }
200 : : }
201 : :
202 [ # # ]: 0 : ScChangeActionList::const_iterator aEndOwn = aItr->maOwnActions.end();
203 [ # # ][ # # ]: 0 : for ( ScChangeActionList::const_iterator aItrOwn = aItr->maOwnActions.begin(); aItrOwn != aEndOwn; ++aItrOwn )
[ # # ][ # # ]
204 : : {
205 [ # # ][ # # ]: 0 : if ( DoActionsIntersect( mpTrack->GetAction( *aItrOwn ), pAction ) )
[ # # ][ # # ]
206 : : {
207 : 0 : return &(*aItr);
208 : : }
209 : : }
210 : : }
211 : :
212 : 0 : return NULL;
213 : : }
214 : :
215 : 0 : ScConflictsListEntry* ScConflictsFinder::GetEntry( sal_uLong nSharedAction, const ScChangeActionList& rOwnActions )
216 : : {
217 : : // try to get a list entry which already contains the shared action
218 [ # # ]: 0 : ScConflictsListEntry* pEntry = ScConflictsListHelper::GetSharedActionEntry( mrConflictsList, nSharedAction );
219 [ # # ]: 0 : if ( pEntry )
220 : : {
221 : 0 : return pEntry;
222 : : }
223 : :
224 : : // try to get a list entry for which the shared action intersects with any
225 : : // other action of this entry
226 [ # # ][ # # ]: 0 : pEntry = GetIntersectingEntry( mpTrack->GetAction( nSharedAction ) );
227 [ # # ]: 0 : if ( pEntry )
228 : : {
229 [ # # ]: 0 : pEntry->maSharedActions.push_back( nSharedAction );
230 : 0 : return pEntry;
231 : : }
232 : :
233 : : // try to get a list entry for which any of the own actions intersects with
234 : : // any other action of this entry
235 : 0 : ScChangeActionList::const_iterator aEnd = rOwnActions.end();
236 [ # # ][ # # ]: 0 : for ( ScChangeActionList::const_iterator aItr = rOwnActions.begin(); aItr != aEnd; ++aItr )
[ # # ]
237 : : {
238 [ # # ][ # # ]: 0 : pEntry = GetIntersectingEntry( mpTrack->GetAction( *aItr ) );
[ # # ]
239 [ # # ]: 0 : if ( pEntry )
240 : : {
241 [ # # ]: 0 : pEntry->maSharedActions.push_back( nSharedAction );
242 : 0 : return pEntry;
243 : : }
244 : : }
245 : :
246 : : // if no entry was found, create a new one
247 [ # # ]: 0 : ScConflictsListEntry aEntry;
248 : 0 : aEntry.meConflictAction = SC_CONFLICT_ACTION_NONE;
249 [ # # ]: 0 : aEntry.maSharedActions.push_back( nSharedAction );
250 [ # # ]: 0 : mrConflictsList.push_back( aEntry );
251 [ # # ]: 0 : return &(mrConflictsList.back());
252 : : }
253 : :
254 : 0 : bool ScConflictsFinder::Find()
255 : : {
256 [ # # ]: 0 : if ( !mpTrack )
257 : : {
258 : 0 : return false;
259 : : }
260 : :
261 : 0 : bool bReturn = false;
262 : 0 : ScChangeAction* pSharedAction = mpTrack->GetAction( mnStartShared );
263 [ # # ][ # # ]: 0 : while ( pSharedAction && pSharedAction->GetActionNumber() <= mnEndShared )
[ # # ]
264 : : {
265 [ # # ]: 0 : ScChangeActionList aOwnActions;
266 [ # # ]: 0 : ScChangeAction* pOwnAction = mpTrack->GetAction( mnStartOwn );
267 [ # # ][ # # ]: 0 : while ( pOwnAction && pOwnAction->GetActionNumber() <= mnEndOwn )
[ # # ]
268 : : {
269 [ # # ][ # # ]: 0 : if ( DoActionsIntersect( pSharedAction, pOwnAction ) )
270 : : {
271 [ # # ]: 0 : aOwnActions.push_back( pOwnAction->GetActionNumber() );
272 : : }
273 : 0 : pOwnAction = pOwnAction->GetNext();
274 : : }
275 : :
276 [ # # ]: 0 : if ( aOwnActions.size() )
277 : : {
278 [ # # ]: 0 : ScConflictsListEntry* pEntry = GetEntry( pSharedAction->GetActionNumber(), aOwnActions );
279 : 0 : ScChangeActionList::iterator aEnd = aOwnActions.end();
280 [ # # ][ # # ]: 0 : for ( ScChangeActionList::iterator aItr = aOwnActions.begin(); aItr != aEnd; ++aItr )
[ # # ]
281 : : {
282 [ # # ][ # # ]: 0 : if ( pEntry && !ScConflictsListHelper::HasOwnAction( mrConflictsList, *aItr ) )
[ # # ][ # # ]
[ # # ]
283 : : {
284 [ # # ][ # # ]: 0 : pEntry->maOwnActions.push_back( *aItr );
285 : : }
286 : : }
287 : 0 : bReturn = true;
288 : : }
289 : :
290 : 0 : pSharedAction = pSharedAction->GetNext();
291 : 0 : }
292 : :
293 : 0 : return bReturn;
294 : : }
295 : :
296 : : //=============================================================================
297 : : // class ScConflictsResolver
298 : : //=============================================================================
299 : :
300 : 0 : ScConflictsResolver::ScConflictsResolver( ScChangeTrack* pTrack, ScConflictsList& rConflictsList )
301 : : :mpTrack ( pTrack )
302 : 0 : ,mrConflictsList ( rConflictsList )
303 : : {
304 : : OSL_ENSURE( mpTrack, "ScConflictsResolver CTOR: mpTrack is null!" );
305 : 0 : }
306 : :
307 : 0 : ScConflictsResolver::~ScConflictsResolver()
308 : : {
309 [ # # ]: 0 : }
310 : :
311 : 0 : void ScConflictsResolver::HandleAction( ScChangeAction* pAction, bool bIsSharedAction,
312 : : bool bHandleContentAction, bool bHandleNonContentAction )
313 : : {
314 [ # # ][ # # ]: 0 : if ( !mpTrack || !pAction )
315 : : {
316 : 0 : return;
317 : : }
318 : :
319 [ # # ]: 0 : if ( bIsSharedAction )
320 : : {
321 : : ScConflictsListEntry* pConflictEntry = ScConflictsListHelper::GetSharedActionEntry(
322 : 0 : mrConflictsList, pAction->GetActionNumber() );
323 [ # # ]: 0 : if ( pConflictEntry )
324 : : {
325 : 0 : ScConflictAction eConflictAction = pConflictEntry->meConflictAction;
326 [ # # ]: 0 : if ( eConflictAction == SC_CONFLICT_ACTION_KEEP_MINE )
327 : : {
328 [ # # ]: 0 : if ( pAction->GetType() == SC_CAT_CONTENT )
329 : : {
330 [ # # ]: 0 : if ( bHandleContentAction )
331 : : {
332 : 0 : mpTrack->Reject( pAction );
333 : : }
334 : : }
335 : : else
336 : : {
337 [ # # ]: 0 : if ( bHandleNonContentAction )
338 : : {
339 : 0 : mpTrack->Reject( pAction );
340 : : }
341 : : }
342 : : }
343 : : }
344 : : }
345 : : else
346 : : {
347 : : ScConflictsListEntry* pConflictEntry = ScConflictsListHelper::GetOwnActionEntry(
348 : 0 : mrConflictsList, pAction->GetActionNumber() );
349 [ # # ]: 0 : if ( pConflictEntry )
350 : : {
351 : 0 : ScConflictAction eConflictAction = pConflictEntry->meConflictAction;
352 [ # # ]: 0 : if ( eConflictAction == SC_CONFLICT_ACTION_KEEP_MINE )
353 : : {
354 : 0 : if ( pAction->GetType() == SC_CAT_CONTENT )
355 : : {
356 : : if ( bHandleContentAction )
357 : : {
358 : : // do nothing
359 : : //mpTrack->SelectContent( pAction );
360 : : }
361 : : }
362 : : else
363 : : {
364 : : if ( bHandleNonContentAction )
365 : : {
366 : : // do nothing
367 : : //mpTrack->Accept( pAction );
368 : : }
369 : : }
370 : : }
371 [ # # ]: 0 : else if ( eConflictAction == SC_CONFLICT_ACTION_KEEP_OTHER )
372 : : {
373 [ # # ]: 0 : if ( pAction->GetType() == SC_CAT_CONTENT )
374 : : {
375 [ # # ]: 0 : if ( bHandleContentAction )
376 : : {
377 : 0 : mpTrack->Reject( pAction );
378 : : }
379 : : }
380 : : else
381 : : {
382 [ # # ]: 0 : if ( bHandleNonContentAction )
383 : : {
384 : 0 : mpTrack->Reject( pAction );
385 : : }
386 : : }
387 : : }
388 : : }
389 : : }
390 : : }
391 : :
392 : : //=============================================================================
393 : : // class ScConflictsDlg
394 : : //=============================================================================
395 : :
396 : 0 : ScConflictsDlg::ScConflictsDlg( Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList )
397 : : :ModalDialog( pParent, ScResId( RID_SCDLG_CONFLICTS ) )
398 : : ,maFtConflicts ( this, ScResId( FT_CONFLICTS ) )
399 : : ,m_aLbConflictsContainer(this, ScResId( LB_CONFLICTS))
400 : : ,maLbConflicts(m_aLbConflictsContainer)
401 : : ,maBtnKeepMine ( this, ScResId( BTN_KEEPMINE ) )
402 : : ,maBtnKeepOther ( this, ScResId( BTN_KEEPOTHER ) )
403 : : ,maFlConflicts ( this, ScResId( FL_CONFLICTS ) )
404 : : ,maBtnKeepAllMine ( this, ScResId( BTN_KEEPALLMINE ) )
405 : : ,maBtnKeepAllOthers ( this, ScResId( BTN_KEEPALLOTHERS ) )
406 : : ,maBtnCancel ( this, ScResId( BTN_CANCEL ) )
407 : : ,maBtnHelp ( this, ScResId( BTN_HELP ) )
408 : : ,maStrTitleConflict ( ScResId( STR_TITLE_CONFLICT ) )
409 : : ,maStrTitleAuthor ( ScResId( STR_TITLE_AUTHOR ) )
410 : : ,maStrTitleDate ( ScResId( STR_TITLE_DATE ) )
411 : : ,maStrUnknownUser ( ScResId( STR_UNKNOWN_USER ) )
412 : : ,mpViewData ( pViewData )
413 : : ,mpOwnDoc ( NULL )
414 : : ,mpOwnTrack ( NULL )
415 : : ,mpSharedDoc ( pSharedDoc )
416 : : ,mpSharedTrack ( NULL )
417 : : ,mrConflictsList ( rConflictsList )
418 : 0 : ,maDialogSize ( GetSizePixel() )
419 : : ,mbInSelectHdl ( false )
420 [ # # ][ # # ]: 0 : ,mbInDeselectHdl ( false )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
421 : : {
422 : : OSL_ENSURE( mpViewData, "ScConflictsDlg CTOR: mpViewData is null!" );
423 [ # # ][ # # ]: 0 : mpOwnDoc = ( mpViewData ? mpViewData->GetDocument() : NULL );
424 : : OSL_ENSURE( mpOwnDoc, "ScConflictsDlg CTOR: mpOwnDoc is null!" );
425 [ # # ]: 0 : mpOwnTrack = ( mpOwnDoc ? mpOwnDoc->GetChangeTrack() : NULL );
426 : : OSL_ENSURE( mpOwnTrack, "ScConflictsDlg CTOR: mpOwnTrack is null!" );
427 : : OSL_ENSURE( mpSharedDoc, "ScConflictsDlg CTOR: mpSharedDoc is null!" );
428 [ # # ]: 0 : mpSharedTrack = ( mpSharedDoc ? mpSharedDoc->GetChangeTrack() : NULL );
429 : : OSL_ENSURE( mpSharedTrack, "ScConflictsDlg CTOR: mpSharedTrack is null!" );
430 : :
431 [ # # ]: 0 : FreeResource();
432 : :
433 [ # # ]: 0 : SetMinOutputSizePixel( maDialogSize );
434 : :
435 : 0 : long nTabs[] = { 3, 10, 216, 266 };
436 [ # # ]: 0 : maLbConflicts.SetTabs( nTabs );
437 : :
438 : 0 : rtl::OUString aTab('\t');
439 [ # # ]: 0 : String aHeader( maStrTitleConflict );
440 [ # # ]: 0 : aHeader += aTab;
441 [ # # ]: 0 : aHeader += maStrTitleAuthor;
442 [ # # ]: 0 : aHeader += aTab;
443 [ # # ]: 0 : aHeader += maStrTitleDate;
444 [ # # ][ # # ]: 0 : maLbConflicts.InsertHeaderEntry( aHeader, HEADERBAR_APPEND, HIB_LEFT | HIB_LEFTIMAGE | HIB_VCENTER );
445 : :
446 [ # # ][ # # ]: 0 : maLbConflicts.SetStyle( maLbConflicts.GetStyle() | WB_HASLINES | WB_CLIPCHILDREN | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HSCROLL );
447 [ # # ]: 0 : maLbConflicts.SetSelectionMode( MULTIPLE_SELECTION );
448 [ # # ]: 0 : maLbConflicts.SetHighlightRange();
449 : :
450 [ # # ]: 0 : maSelectionTimer.SetTimeout( 100 );
451 [ # # ]: 0 : maSelectionTimer.SetTimeoutHdl( LINK( this, ScConflictsDlg, UpdateSelectionHdl ) );
452 : :
453 [ # # ]: 0 : maLbConflicts.SetSelectHdl( LINK( this, ScConflictsDlg, SelectHandle ) );
454 [ # # ]: 0 : maLbConflicts.SetDeselectHdl( LINK( this, ScConflictsDlg, DeselectHandle ) );
455 : :
456 [ # # ]: 0 : maBtnKeepMine.SetClickHdl( LINK( this, ScConflictsDlg, KeepMineHandle ) );
457 [ # # ]: 0 : maBtnKeepOther.SetClickHdl( LINK( this, ScConflictsDlg, KeepOtherHandle ) );
458 [ # # ]: 0 : maBtnKeepAllMine.SetClickHdl( LINK( this, ScConflictsDlg, KeepAllMineHandle ) );
459 [ # # ]: 0 : maBtnKeepAllOthers.SetClickHdl( LINK( this, ScConflictsDlg, KeepAllOthersHandle ) );
460 : :
461 [ # # ]: 0 : UpdateView();
462 : :
463 [ # # ]: 0 : SvLBoxEntry* pEntry = maLbConflicts.First();
464 [ # # ]: 0 : if ( pEntry != NULL )
465 : : {
466 [ # # ]: 0 : maLbConflicts.Select( pEntry );
467 [ # # ]: 0 : }
468 : 0 : }
469 : :
470 [ # # ][ # # ]: 0 : ScConflictsDlg::~ScConflictsDlg()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
471 : : {
472 [ # # ]: 0 : }
473 : :
474 : 0 : String ScConflictsDlg::GetConflictString( const ScConflictsListEntry& rConflictEntry )
475 : : {
476 : 0 : rtl::OUString aString;
477 [ # # ]: 0 : if ( mpOwnTrack )
478 : : {
479 [ # # ][ # # ]: 0 : const ScChangeAction* pAction = mpOwnTrack->GetAction( rConflictEntry.maOwnActions[ 0 ] );
480 [ # # ][ # # ]: 0 : if ( pAction && mpOwnDoc )
481 : : {
482 : 0 : SCTAB nTab = pAction->GetBigRange().MakeRange().aStart.Tab();
483 [ # # ]: 0 : mpOwnDoc->GetName( nTab, aString );
484 : : }
485 : : }
486 [ # # ]: 0 : return aString;
487 : : }
488 : :
489 : 0 : String ScConflictsDlg::GetActionString( const ScChangeAction* pAction, ScDocument* pDoc )
490 : : {
491 : 0 : String aString;
492 : :
493 : : OSL_ENSURE( pAction, "ScConflictsDlg::GetActionString(): pAction is null!" );
494 : : OSL_ENSURE( pDoc, "ScConflictsDlg::GetActionString(): pDoc is null!" );
495 [ # # ][ # # ]: 0 : if ( pAction && pDoc )
496 : : {
497 : 0 : rtl::OUString aDesc;
498 [ # # ]: 0 : pAction->GetDescription(aDesc, pDoc, true, false);
499 [ # # ][ # # ]: 0 : aString += String(aDesc);
[ # # ]
500 [ # # ]: 0 : aString += '\t';
501 : :
502 [ # # ][ # # ]: 0 : String aUser = comphelper::string::strip(pAction->GetUser(), ' ');
[ # # ]
503 [ # # ]: 0 : if ( aUser.Len() == 0 )
504 : : {
505 [ # # ]: 0 : aUser = maStrUnknownUser;
506 : : }
507 [ # # ]: 0 : aString += aUser;
508 [ # # ]: 0 : aString += '\t';
509 : :
510 [ # # ]: 0 : DateTime aDateTime = pAction->GetDateTime();
511 [ # # ][ # # ]: 0 : aString += ScGlobal::pLocaleData->getDate( aDateTime );
512 [ # # ]: 0 : aString += ' ';
513 [ # # ][ # # ]: 0 : aString += ScGlobal::pLocaleData->getTime( aDateTime, false );
514 [ # # ][ # # ]: 0 : aString += '\t';
515 : : }
516 : :
517 : 0 : return aString;
518 : : }
519 : :
520 : 0 : void ScConflictsDlg::HandleListBoxSelection( bool bSelectHandle )
521 : : {
522 : 0 : SvLBoxEntry* pSelEntry = maLbConflicts.GetCurEntry();
523 [ # # ]: 0 : if ( !pSelEntry )
524 : : {
525 : 0 : pSelEntry = maLbConflicts.FirstSelected();
526 : : }
527 [ # # ]: 0 : if ( !pSelEntry )
528 : : {
529 : 0 : return;
530 : : }
531 : :
532 : 0 : SvLBoxEntry* pRootEntry = maLbConflicts.GetRootLevelParent( pSelEntry );
533 [ # # ]: 0 : if ( pRootEntry )
534 : : {
535 [ # # ]: 0 : if ( bSelectHandle )
536 : : {
537 : 0 : maLbConflicts.SelectAll( false );
538 : : }
539 [ # # ]: 0 : if ( !maLbConflicts.IsSelected( pRootEntry ) )
540 : : {
541 : 0 : maLbConflicts.Select( pRootEntry );
542 : : }
543 : 0 : SvLBoxEntry* pEntry = maLbConflicts.FirstChild( pRootEntry );
544 [ # # ]: 0 : while ( pEntry )
545 : : {
546 [ # # ]: 0 : if ( !maLbConflicts.IsSelected( pEntry ) )
547 : : {
548 : 0 : maLbConflicts.Select( pEntry );
549 : : }
550 : 0 : pEntry = maLbConflicts.NextSibling( pEntry );
551 : : }
552 : : }
553 : : }
554 : :
555 : 0 : IMPL_LINK_NOARG(ScConflictsDlg, SelectHandle)
556 : : {
557 [ # # ][ # # ]: 0 : if ( mbInSelectHdl || mbInDeselectHdl )
558 : : {
559 : 0 : return 0;
560 : : }
561 : :
562 : 0 : mbInSelectHdl = true;
563 : 0 : HandleListBoxSelection( true );
564 : 0 : maSelectionTimer.Start();
565 : 0 : mbInSelectHdl = false;
566 : :
567 : 0 : return 0;
568 : : }
569 : :
570 : 0 : IMPL_LINK_NOARG(ScConflictsDlg, DeselectHandle)
571 : : {
572 [ # # ][ # # ]: 0 : if ( mbInDeselectHdl || mbInSelectHdl )
573 : : {
574 : 0 : return 0;
575 : : }
576 : :
577 : 0 : mbInDeselectHdl = true;
578 : 0 : HandleListBoxSelection( false );
579 : 0 : mbInDeselectHdl = false;
580 : :
581 : 0 : return 0;
582 : : }
583 : :
584 : 0 : IMPL_LINK_NOARG(ScConflictsDlg, UpdateSelectionHdl)
585 : : {
586 [ # # ][ # # ]: 0 : if ( !mpViewData || !mpOwnDoc )
587 : : {
588 : 0 : return 0;
589 : : }
590 : :
591 [ # # ]: 0 : ScTabView* pTabView = mpViewData->GetView();
592 : 0 : pTabView->DoneBlockMode();
593 : 0 : sal_Bool bContMark = false;
594 : 0 : SvLBoxEntry* pEntry = maLbConflicts.FirstSelected();
595 [ # # ]: 0 : while ( pEntry )
596 : : {
597 [ # # ]: 0 : if ( pEntry != maLbConflicts.GetRootLevelParent( pEntry ) )
598 : : {
599 : 0 : RedlinData* pUserData = static_cast< RedlinData* >( pEntry->GetUserData() );
600 [ # # ]: 0 : if ( pUserData )
601 : : {
602 : 0 : ScChangeAction* pAction = static_cast< ScChangeAction* >( pUserData->pData );
603 [ # # ][ # # : 0 : if ( pAction && ( pAction->GetType() != SC_CAT_DELETE_TABS ) &&
# # # # ]
[ # # ]
604 : 0 : ( pAction->IsClickable() || pAction->IsVisible() ) )
605 : : {
606 : 0 : const ScBigRange& rBigRange = ( static_cast< const ScChangeAction* >( pAction ) )->GetBigRange();
607 [ # # ]: 0 : if ( rBigRange.IsValid( mpOwnDoc ) )
608 : : {
609 : 0 : sal_Bool bSetCursor = !maLbConflicts.NextSelected( pEntry );
610 [ # # ]: 0 : pTabView->MarkRange( rBigRange.MakeRange(), bSetCursor, bContMark );
611 : 0 : bContMark = sal_True;
612 : : }
613 : : }
614 : : }
615 : : }
616 : 0 : pEntry = maLbConflicts.NextSelected( pEntry );
617 : : }
618 : :
619 : 0 : return 0;
620 : : }
621 : :
622 : 0 : void ScConflictsDlg::SetConflictAction( SvLBoxEntry* pRootEntry, ScConflictAction eConflictAction )
623 : : {
624 [ # # ]: 0 : RedlinData* pUserData = static_cast< RedlinData* >( pRootEntry ? pRootEntry->GetUserData() : NULL );
625 [ # # ]: 0 : ScConflictsListEntry* pConflictEntry = static_cast< ScConflictsListEntry* >( pUserData ? pUserData->pData : NULL );
626 [ # # ]: 0 : if ( pConflictEntry )
627 : : {
628 : 0 : pConflictEntry->meConflictAction = eConflictAction;
629 : : }
630 : 0 : }
631 : :
632 : 0 : void ScConflictsDlg::KeepHandler( bool bMine )
633 : : {
634 : 0 : SvLBoxEntry* pEntry = maLbConflicts.FirstSelected();
635 [ # # ]: 0 : SvLBoxEntry* pRootEntry = ( pEntry ? maLbConflicts.GetRootLevelParent( pEntry ) : NULL );
636 [ # # ]: 0 : if ( !pRootEntry )
637 : : {
638 : 0 : return;
639 : : }
640 [ # # ]: 0 : SetPointer( Pointer( POINTER_WAIT ) );
641 [ # # ]: 0 : ScConflictAction eConflictAction = ( bMine ? SC_CONFLICT_ACTION_KEEP_MINE : SC_CONFLICT_ACTION_KEEP_OTHER );
642 : 0 : SetConflictAction( pRootEntry, eConflictAction );
643 : 0 : maLbConflicts.RemoveEntry( pRootEntry );
644 [ # # ]: 0 : SetPointer( Pointer( POINTER_ARROW ) );
645 [ # # ]: 0 : if ( maLbConflicts.GetEntryCount() == 0 )
646 : : {
647 : 0 : EndDialog( RET_OK );
648 : : }
649 : : }
650 : :
651 : 0 : void ScConflictsDlg::KeepAllHandler( bool bMine )
652 : : {
653 : 0 : SvLBoxEntry* pEntry = maLbConflicts.First();
654 [ # # ]: 0 : SvLBoxEntry* pRootEntry = ( pEntry ? maLbConflicts.GetRootLevelParent( pEntry ) : NULL );
655 [ # # ]: 0 : if ( !pRootEntry )
656 : : {
657 : 0 : return;
658 : : }
659 [ # # ]: 0 : SetPointer( Pointer( POINTER_WAIT ) );
660 [ # # ]: 0 : ScConflictAction eConflictAction = ( bMine ? SC_CONFLICT_ACTION_KEEP_MINE : SC_CONFLICT_ACTION_KEEP_OTHER );
661 [ # # ]: 0 : while ( pRootEntry )
662 : : {
663 : 0 : SetConflictAction( pRootEntry, eConflictAction );
664 : 0 : pRootEntry = maLbConflicts.NextSibling( pRootEntry );
665 : : }
666 : 0 : maLbConflicts.SetUpdateMode( false );
667 : 0 : maLbConflicts.Clear();
668 : 0 : maLbConflicts.SetUpdateMode( sal_True );
669 [ # # ]: 0 : SetPointer( Pointer( POINTER_ARROW ) );
670 : 0 : EndDialog( RET_OK );
671 : : }
672 : :
673 : 0 : IMPL_LINK_NOARG(ScConflictsDlg, KeepMineHandle)
674 : : {
675 : 0 : KeepHandler( true );
676 : :
677 : 0 : return 0;
678 : : }
679 : :
680 : 0 : IMPL_LINK_NOARG(ScConflictsDlg, KeepOtherHandle)
681 : : {
682 : 0 : KeepHandler( false );
683 : :
684 : 0 : return 0;
685 : : }
686 : :
687 : 0 : IMPL_LINK_NOARG(ScConflictsDlg, KeepAllMineHandle)
688 : : {
689 : 0 : KeepAllHandler( true );
690 : :
691 : 0 : return 0;
692 : : }
693 : :
694 : 0 : IMPL_LINK_NOARG(ScConflictsDlg, KeepAllOthersHandle)
695 : : {
696 : 0 : KeepAllHandler( false );
697 : :
698 : 0 : return 0;
699 : : }
700 : :
701 : 0 : void lcl_MoveControlX( Window& rWindow, long nDelta )
702 : : {
703 [ # # ]: 0 : Point aPos( rWindow.GetPosPixel() );
704 : 0 : aPos.X() += nDelta;
705 [ # # ]: 0 : rWindow.SetPosPixel( aPos );
706 : 0 : }
707 : :
708 : 0 : void lcl_MoveControlY( Window& rWindow, long nDelta )
709 : : {
710 [ # # ]: 0 : Point aPos( rWindow.GetPosPixel() );
711 : 0 : aPos.Y() += nDelta;
712 [ # # ]: 0 : rWindow.SetPosPixel( aPos );
713 : 0 : }
714 : :
715 : 0 : void lcl_ChangeControlWidth( Window& rWindow, long nDelta )
716 : : {
717 [ # # ]: 0 : Size aSize( rWindow.GetSizePixel() );
718 : 0 : aSize.Width() += nDelta;
719 [ # # ]: 0 : rWindow.SetSizePixel( aSize );
720 : 0 : }
721 : :
722 : 0 : void lcl_ChangeControlHeight( Window& rWindow, long nDelta )
723 : : {
724 [ # # ]: 0 : Size aSize( rWindow.GetSizePixel() );
725 : 0 : aSize.Height() += nDelta;
726 [ # # ]: 0 : rWindow.SetSizePixel( aSize );
727 : 0 : }
728 : :
729 : 0 : void ScConflictsDlg::Resize()
730 : : {
731 [ # # ]: 0 : Size aSize( GetSizePixel() );
732 : 0 : long nDeltaWidth = aSize.Width() - maDialogSize.Width();
733 : 0 : long nDeltaHeight = aSize.Height() - maDialogSize.Height();
734 : 0 : maDialogSize = aSize;
735 : :
736 [ # # ]: 0 : lcl_ChangeControlWidth( maFtConflicts, nDeltaWidth );
737 : :
738 [ # # ]: 0 : lcl_ChangeControlWidth( m_aLbConflictsContainer, nDeltaWidth );
739 [ # # ]: 0 : lcl_ChangeControlHeight( m_aLbConflictsContainer, nDeltaHeight );
740 : :
741 [ # # ]: 0 : lcl_MoveControlX( maBtnKeepMine, nDeltaWidth / 2 );
742 [ # # ]: 0 : lcl_MoveControlY( maBtnKeepMine, nDeltaHeight );
743 : :
744 [ # # ]: 0 : lcl_MoveControlX( maBtnKeepOther, nDeltaWidth / 2 );
745 [ # # ]: 0 : lcl_MoveControlY( maBtnKeepOther, nDeltaHeight );
746 : :
747 [ # # ]: 0 : lcl_MoveControlY( maFlConflicts, nDeltaHeight );
748 [ # # ]: 0 : lcl_ChangeControlWidth( maFlConflicts, nDeltaWidth );
749 : :
750 [ # # ]: 0 : lcl_MoveControlX( maBtnKeepAllMine, nDeltaWidth );
751 [ # # ]: 0 : lcl_MoveControlY( maBtnKeepAllMine, nDeltaHeight );
752 : :
753 [ # # ]: 0 : lcl_MoveControlX( maBtnKeepAllOthers, nDeltaWidth );
754 [ # # ]: 0 : lcl_MoveControlY( maBtnKeepAllOthers, nDeltaHeight );
755 : :
756 [ # # ]: 0 : lcl_MoveControlX( maBtnCancel, nDeltaWidth );
757 [ # # ]: 0 : lcl_MoveControlY( maBtnCancel, nDeltaHeight );
758 : :
759 [ # # ]: 0 : lcl_MoveControlX( maBtnHelp, nDeltaWidth );
760 [ # # ]: 0 : lcl_MoveControlY( maBtnHelp, nDeltaHeight );
761 : 0 : }
762 : :
763 : 0 : void ScConflictsDlg::UpdateView()
764 : : {
765 : 0 : ScConflictsList::iterator aEndItr = mrConflictsList.end();
766 [ # # ][ # # ]: 0 : for ( ScConflictsList::iterator aItr = mrConflictsList.begin(); aItr != aEndItr; ++aItr )
767 : : {
768 : 0 : ScConflictsListEntry* pConflictEntry = &(*aItr);
769 [ # # ][ # # ]: 0 : if ( pConflictEntry && pConflictEntry->meConflictAction == SC_CONFLICT_ACTION_NONE )
770 : : {
771 [ # # ][ # # ]: 0 : RedlinData* pRootUserData = new RedlinData();
772 : 0 : pRootUserData->pData = static_cast< void* >( pConflictEntry );
773 [ # # ][ # # ]: 0 : SvLBoxEntry* pRootEntry = maLbConflicts.InsertEntry( GetConflictString( *aItr ), pRootUserData );
[ # # ]
774 : :
775 [ # # ]: 0 : ScChangeActionList::const_iterator aEndShared = aItr->maSharedActions.end();
776 [ # # ][ # # ]: 0 : for ( ScChangeActionList::const_iterator aItrShared = aItr->maSharedActions.begin(); aItrShared != aEndShared; ++aItrShared )
[ # # ][ # # ]
777 : : {
778 [ # # ][ # # ]: 0 : ScChangeAction* pAction = mpSharedTrack->GetAction( *aItrShared );
779 [ # # ]: 0 : if ( pAction )
780 : : {
781 : : // only display shared top content entries
782 [ # # ]: 0 : if ( pAction->GetType() == SC_CAT_CONTENT )
783 : : {
784 [ # # ]: 0 : ScChangeActionContent* pNextContent = ( dynamic_cast< ScChangeActionContent* >( pAction ) )->GetNextContent();
785 [ # # ][ # # ]: 0 : if ( pNextContent && aItr->HasSharedAction( pNextContent->GetActionNumber() ) )
[ # # ][ # # ]
786 : : {
787 : 0 : continue;
788 : : }
789 : : }
790 : :
791 [ # # ]: 0 : String aString( GetActionString( pAction, mpSharedDoc ) );
792 [ # # ][ # # ]: 0 : maLbConflicts.InsertEntry( aString, static_cast< RedlinData* >( NULL ), pRootEntry );
793 : : }
794 : : }
795 : :
796 [ # # ]: 0 : ScChangeActionList::const_iterator aEndOwn = aItr->maOwnActions.end();
797 [ # # ][ # # ]: 0 : for ( ScChangeActionList::const_iterator aItrOwn = aItr->maOwnActions.begin(); aItrOwn != aEndOwn; ++aItrOwn )
[ # # ][ # # ]
798 : : {
799 [ # # ][ # # ]: 0 : ScChangeAction* pAction = mpOwnTrack->GetAction( *aItrOwn );
800 [ # # ]: 0 : if ( pAction )
801 : : {
802 : : // only display own top content entries
803 [ # # ]: 0 : if ( pAction->GetType() == SC_CAT_CONTENT )
804 : : {
805 [ # # ]: 0 : ScChangeActionContent* pNextContent = ( dynamic_cast< ScChangeActionContent* >( pAction ) )->GetNextContent();
806 [ # # ][ # # ]: 0 : if ( pNextContent && aItr->HasOwnAction( pNextContent->GetActionNumber() ) )
[ # # ][ # # ]
807 : : {
808 : 0 : continue;
809 : : }
810 : : }
811 : :
812 [ # # ]: 0 : String aString( GetActionString( pAction, mpOwnDoc ) );
813 [ # # ][ # # ]: 0 : RedlinData* pUserData = new RedlinData();
814 : 0 : pUserData->pData = static_cast< void* >( pAction );
815 [ # # ][ # # ]: 0 : maLbConflicts.InsertEntry( aString, pUserData, pRootEntry );
816 : : }
817 : : }
818 : :
819 [ # # ]: 0 : maLbConflicts.Expand( pRootEntry );
820 : : }
821 : : }
822 : 0 : }
823 : :
824 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|