1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: conflictsdlg.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 //-----------------------------------------------------------------------------
36 #include <vcl/msgbox.hxx>
38 #include "conflictsdlg.hxx"
39 #include "conflictsdlg.hrc"
40 #include "scresid.hxx"
41 #include "viewdata.hxx"
42 #include "tabview.hxx"
45 //=============================================================================
46 // struct ScConflictsListEntry
47 //=============================================================================
49 bool ScConflictsListEntry::HasSharedAction( ULONG nSharedAction
) const
51 ScChangeActionList::const_iterator aEnd
= maSharedActions
.end();
52 for ( ScChangeActionList::const_iterator aItr
= maSharedActions
.begin(); aItr
!= aEnd
; ++aItr
)
54 if ( *aItr
== nSharedAction
)
63 bool ScConflictsListEntry::HasOwnAction( ULONG nOwnAction
) const
65 ScChangeActionList::const_iterator aEnd
= maOwnActions
.end();
66 for ( ScChangeActionList::const_iterator aItr
= maOwnActions
.begin(); aItr
!= aEnd
; ++aItr
)
68 if ( *aItr
== nOwnAction
)
78 //=============================================================================
79 // class ScConflictsListHelper
80 //=============================================================================
82 //UNUSED2008-05 bool ScConflictsListHelper::HasSharedAction( ScConflictsList& rConflictsList, ULONG nSharedAction )
84 //UNUSED2008-05 ScConflictsList::const_iterator aEnd = rConflictsList.end();
85 //UNUSED2008-05 for ( ScConflictsList::const_iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr )
87 //UNUSED2008-05 if ( aItr->HasSharedAction( nSharedAction ) )
89 //UNUSED2008-05 return true;
93 //UNUSED2008-05 return false;
96 bool ScConflictsListHelper::HasOwnAction( ScConflictsList
& rConflictsList
, ULONG nOwnAction
)
98 ScConflictsList::const_iterator aEnd
= rConflictsList
.end();
99 for ( ScConflictsList::const_iterator aItr
= rConflictsList
.begin(); aItr
!= aEnd
; ++aItr
)
101 if ( aItr
->HasOwnAction( nOwnAction
) )
110 ScConflictsListEntry
* ScConflictsListHelper::GetSharedActionEntry( ScConflictsList
& rConflictsList
, ULONG nSharedAction
)
112 ScConflictsList::iterator aEnd
= rConflictsList
.end();
113 for ( ScConflictsList::iterator aItr
= rConflictsList
.begin(); aItr
!= aEnd
; ++aItr
)
115 if ( aItr
->HasSharedAction( nSharedAction
) )
124 ScConflictsListEntry
* ScConflictsListHelper::GetOwnActionEntry( ScConflictsList
& rConflictsList
, ULONG nOwnAction
)
126 ScConflictsList::iterator aEnd
= rConflictsList
.end();
127 for ( ScConflictsList::iterator aItr
= rConflictsList
.begin(); aItr
!= aEnd
; ++aItr
)
129 if ( aItr
->HasOwnAction( nOwnAction
) )
138 void ScConflictsListHelper::Transform_Impl( ScChangeActionList
& rActionList
, ScChangeActionMergeMap
* pMergeMap
)
145 for ( ScChangeActionList::iterator aItr
= rActionList
.begin(); aItr
!= rActionList
.end(); )
147 ScChangeActionMergeMap::iterator aItrMap
= pMergeMap
->find( *aItr
);
148 if ( aItrMap
!= pMergeMap
->end() )
150 *aItr
= aItrMap
->second
;
155 aItr
= rActionList
.erase( aItr
);
156 DBG_ERROR( "ScConflictsListHelper::Transform_Impl: erased action from conflicts list!" );
161 void ScConflictsListHelper::TransformConflictsList( ScConflictsList
& rConflictsList
,
162 ScChangeActionMergeMap
* pSharedMap
, ScChangeActionMergeMap
* pOwnMap
)
164 ScConflictsList::iterator aEnd
= rConflictsList
.end();
165 for ( ScConflictsList::iterator aItr
= rConflictsList
.begin(); aItr
!= aEnd
; ++aItr
)
169 ScConflictsListHelper::Transform_Impl( aItr
->maSharedActions
, pSharedMap
);
174 ScConflictsListHelper::Transform_Impl( aItr
->maOwnActions
, pOwnMap
);
180 //=============================================================================
181 // class ScConflictsFinder
182 //=============================================================================
184 ScConflictsFinder::ScConflictsFinder( ScChangeTrack
* pTrack
, ULONG nStartShared
, ULONG nEndShared
,
185 ULONG nStartOwn
, ULONG nEndOwn
, ScConflictsList
& rConflictsList
)
187 ,mnStartShared( nStartShared
)
188 ,mnEndShared( nEndShared
)
189 ,mnStartOwn( nStartOwn
)
191 ,mrConflictsList( rConflictsList
)
195 ScConflictsFinder::~ScConflictsFinder()
199 bool ScConflictsFinder::DoActionsIntersect( const ScChangeAction
* pAction1
, const ScChangeAction
* pAction2
)
201 if ( pAction1
&& pAction2
&& pAction1
->GetBigRange().Intersects( pAction2
->GetBigRange() ) )
208 ScConflictsListEntry
* ScConflictsFinder::GetIntersectingEntry( const ScChangeAction
* pAction
) const
210 ScConflictsList::iterator aEnd
= mrConflictsList
.end();
211 for ( ScConflictsList::iterator aItr
= mrConflictsList
.begin(); aItr
!= aEnd
; ++aItr
)
213 ScChangeActionList::const_iterator aEndShared
= aItr
->maSharedActions
.end();
214 for ( ScChangeActionList::const_iterator aItrShared
= aItr
->maSharedActions
.begin(); aItrShared
!= aEndShared
; ++aItrShared
)
216 if ( DoActionsIntersect( mpTrack
->GetAction( *aItrShared
), pAction
) )
222 ScChangeActionList::const_iterator aEndOwn
= aItr
->maOwnActions
.end();
223 for ( ScChangeActionList::const_iterator aItrOwn
= aItr
->maOwnActions
.begin(); aItrOwn
!= aEndOwn
; ++aItrOwn
)
225 if ( DoActionsIntersect( mpTrack
->GetAction( *aItrOwn
), pAction
) )
235 ScConflictsListEntry
* ScConflictsFinder::GetEntry( ULONG nSharedAction
, const ScChangeActionList
& rOwnActions
)
237 // try to get a list entry which already contains the shared action
238 ScConflictsListEntry
* pEntry
= ScConflictsListHelper::GetSharedActionEntry( mrConflictsList
, nSharedAction
);
244 // try to get a list entry for which the shared action intersects with any
245 // other action of this entry
246 pEntry
= GetIntersectingEntry( mpTrack
->GetAction( nSharedAction
) );
249 pEntry
->maSharedActions
.push_back( nSharedAction
);
253 // try to get a list entry for which any of the own actions intersects with
254 // any other action of this entry
255 ScChangeActionList::const_iterator aEnd
= rOwnActions
.end();
256 for ( ScChangeActionList::const_iterator aItr
= rOwnActions
.begin(); aItr
!= aEnd
; ++aItr
)
258 pEntry
= GetIntersectingEntry( mpTrack
->GetAction( *aItr
) );
261 pEntry
->maSharedActions
.push_back( nSharedAction
);
266 // if no entry was found, create a new one
267 ScConflictsListEntry aEntry
;
268 aEntry
.meConflictAction
= SC_CONFLICT_ACTION_NONE
;
269 aEntry
.maSharedActions
.push_back( nSharedAction
);
270 mrConflictsList
.push_back( aEntry
);
271 return &(mrConflictsList
.back());
274 bool ScConflictsFinder::Find()
281 bool bReturn
= false;
282 ScChangeAction
* pSharedAction
= mpTrack
->GetAction( mnStartShared
);
283 while ( pSharedAction
&& pSharedAction
->GetActionNumber() <= mnEndShared
)
285 ScChangeActionList aOwnActions
;
286 ScChangeAction
* pOwnAction
= mpTrack
->GetAction( mnStartOwn
);
287 while ( pOwnAction
&& pOwnAction
->GetActionNumber() <= mnEndOwn
)
289 if ( DoActionsIntersect( pSharedAction
, pOwnAction
) )
291 aOwnActions
.push_back( pOwnAction
->GetActionNumber() );
293 pOwnAction
= pOwnAction
->GetNext();
296 if ( aOwnActions
.size() )
298 ScConflictsListEntry
* pEntry
= GetEntry( pSharedAction
->GetActionNumber(), aOwnActions
);;
299 ScChangeActionList::iterator aEnd
= aOwnActions
.end();
300 for ( ScChangeActionList::iterator aItr
= aOwnActions
.begin(); aItr
!= aEnd
; ++aItr
)
302 if ( pEntry
&& !ScConflictsListHelper::HasOwnAction( mrConflictsList
, *aItr
) )
304 pEntry
->maOwnActions
.push_back( *aItr
);
310 pSharedAction
= pSharedAction
->GetNext();
316 //=============================================================================
317 // class ScConflictsResolver
318 //=============================================================================
320 ScConflictsResolver::ScConflictsResolver( ScChangeTrack
* pTrack
, ScConflictsList
& rConflictsList
)
322 ,mrConflictsList ( rConflictsList
)
324 DBG_ASSERT( mpTrack
, "ScConflictsResolver CTOR: mpTrack is null!" );
327 ScConflictsResolver::~ScConflictsResolver()
331 void ScConflictsResolver::HandleAction( ScChangeAction
* pAction
, bool bIsSharedAction
,
332 bool bHandleContentAction
, bool bHandleNonContentAction
)
334 if ( !mpTrack
|| !pAction
)
339 if ( bIsSharedAction
)
341 ScConflictsListEntry
* pConflictEntry
= ScConflictsListHelper::GetSharedActionEntry(
342 mrConflictsList
, pAction
->GetActionNumber() );
343 if ( pConflictEntry
)
345 ScConflictAction eConflictAction
= pConflictEntry
->meConflictAction
;
346 if ( eConflictAction
== SC_CONFLICT_ACTION_KEEP_MINE
)
348 if ( pAction
->GetType() == SC_CAT_CONTENT
)
350 if ( bHandleContentAction
)
352 mpTrack
->Reject( pAction
);
357 if ( bHandleNonContentAction
)
359 mpTrack
->Reject( pAction
);
363 else if ( eConflictAction
== SC_CONFLICT_ACTION_KEEP_OTHER
)
365 if ( pAction
->GetType() == SC_CAT_CONTENT
)
367 if ( bHandleContentAction
)
370 //mpTrack->SelectContent( pAction );
375 if ( bHandleNonContentAction
)
378 //mpTrack->Accept( pAction );
386 ScConflictsListEntry
* pConflictEntry
= ScConflictsListHelper::GetOwnActionEntry(
387 mrConflictsList
, pAction
->GetActionNumber() );
388 if ( pConflictEntry
)
390 ScConflictAction eConflictAction
= pConflictEntry
->meConflictAction
;
391 if ( eConflictAction
== SC_CONFLICT_ACTION_KEEP_MINE
)
393 if ( pAction
->GetType() == SC_CAT_CONTENT
)
395 if ( bHandleContentAction
)
398 //mpTrack->SelectContent( pAction );
403 if ( bHandleNonContentAction
)
406 //mpTrack->Accept( pAction );
410 else if ( eConflictAction
== SC_CONFLICT_ACTION_KEEP_OTHER
)
412 if ( pAction
->GetType() == SC_CAT_CONTENT
)
414 if ( bHandleContentAction
)
416 mpTrack
->Reject( pAction
);
421 if ( bHandleNonContentAction
)
423 mpTrack
->Reject( pAction
);
432 //=============================================================================
433 // class ScConflictsListBox
434 //=============================================================================
436 //UNUSED2008-05 ScConflictsListBox::ScConflictsListBox( Window* pParent, WinBits nBits )
437 //UNUSED2008-05 :SvxRedlinTable( pParent, nBits )
441 ScConflictsListBox::ScConflictsListBox( Window
* pParent
, const ResId
& rResId
)
442 :SvxRedlinTable( pParent
, rResId
)
446 ScConflictsListBox::~ScConflictsListBox()
450 //UNUSED2008-05 ULONG ScConflictsListBox::GetRootEntryPos( const SvLBoxEntry* pRootEntry ) const
452 //UNUSED2008-05 ULONG nPos = 0;
453 //UNUSED2008-05 SvLBoxEntry* pEntry = GetRootLevelParent( First() );
454 //UNUSED2008-05 while ( pEntry )
456 //UNUSED2008-05 if ( pEntry == pRootEntry )
458 //UNUSED2008-05 return nPos;
460 //UNUSED2008-05 pEntry = NextSibling( pEntry );
461 //UNUSED2008-05 ++nPos;
463 //UNUSED2008-05 return 0xffffffff;
467 //=============================================================================
468 // class ScConflictsDlg
469 //=============================================================================
471 ScConflictsDlg::ScConflictsDlg( Window
* pParent
, ScViewData
* pViewData
, ScDocument
* pSharedDoc
, ScConflictsList
& rConflictsList
)
472 :ModalDialog( pParent
, ScResId( RID_SCDLG_CONFLICTS
) )
473 ,maFtConflicts ( this, ScResId( FT_CONFLICTS
) )
474 ,maLbConflicts ( this, ScResId( LB_CONFLICTS
) )
475 ,maBtnKeepMine ( this, ScResId( BTN_KEEPMINE
) )
476 ,maBtnKeepOther ( this, ScResId( BTN_KEEPOTHER
) )
477 ,maFlConflicts ( this, ScResId( FL_CONFLICTS
) )
478 ,maBtnKeepAllMine ( this, ScResId( BTN_KEEPALLMINE
) )
479 ,maBtnKeepAllOthers ( this, ScResId( BTN_KEEPALLOTHERS
) )
480 ,maBtnCancel ( this, ScResId( BTN_CANCEL
) )
481 ,maBtnHelp ( this, ScResId( BTN_HELP
) )
482 ,maStrTitleConflict ( ScResId( STR_TITLE_CONFLICT
) )
483 ,maStrTitleAuthor ( ScResId( STR_TITLE_AUTHOR
) )
484 ,maStrTitleDate ( ScResId( STR_TITLE_DATE
) )
485 ,maStrUnknownUser ( ScResId( STR_UNKNOWN_USER
) )
486 ,mpViewData ( pViewData
)
489 ,mpSharedDoc ( pSharedDoc
)
490 ,mpSharedTrack ( NULL
)
491 ,mrConflictsList ( rConflictsList
)
492 ,maDialogSize ( GetSizePixel() )
493 ,mbInSelectHdl ( false )
494 ,mbInDeselectHdl ( false )
496 DBG_ASSERT( mpViewData
, "ScConflictsDlg CTOR: mpViewData is null!" );
497 mpOwnDoc
= ( mpViewData
? mpViewData
->GetDocument() : NULL
);
498 DBG_ASSERT( mpOwnDoc
, "ScConflictsDlg CTOR: mpOwnDoc is null!" );
499 mpOwnTrack
= ( mpOwnDoc
? mpOwnDoc
->GetChangeTrack() : NULL
);
500 DBG_ASSERT( mpOwnTrack
, "ScConflictsDlg CTOR: mpOwnTrack is null!" );
501 DBG_ASSERT( mpSharedDoc
, "ScConflictsDlg CTOR: mpSharedDoc is null!" );
502 mpSharedTrack
= ( mpSharedDoc
? mpSharedDoc
->GetChangeTrack() : NULL
);
503 DBG_ASSERT( mpSharedTrack
, "ScConflictsDlg CTOR: mpSharedTrack is null!" );
507 SetMinOutputSizePixel( maDialogSize
);
509 long nTabs
[] = { 3, 10, 216, 266 };
510 maLbConflicts
.SetTabs( nTabs
);
512 String
aTab( sal_Unicode( '\t' ) );
513 String
aHeader( maStrTitleConflict
);
515 aHeader
+= maStrTitleAuthor
;
517 aHeader
+= maStrTitleDate
;
518 maLbConflicts
.InsertHeaderEntry( aHeader
, HEADERBAR_APPEND
, HIB_LEFT
| HIB_LEFTIMAGE
| HIB_VCENTER
);
520 maLbConflicts
.SetWindowBits( WB_HASLINES
| WB_CLIPCHILDREN
| WB_HASBUTTONS
| WB_HASBUTTONSATROOT
| WB_HSCROLL
);
521 maLbConflicts
.SetSelectionMode( MULTIPLE_SELECTION
);
522 maLbConflicts
.SetHighlightRange();
524 maSelectionTimer
.SetTimeout( 100 );
525 maSelectionTimer
.SetTimeoutHdl( LINK( this, ScConflictsDlg
, UpdateSelectionHdl
) );
527 maLbConflicts
.SetSelectHdl( LINK( this, ScConflictsDlg
, SelectHandle
) );
528 maLbConflicts
.SetDeselectHdl( LINK( this, ScConflictsDlg
, DeselectHandle
) );
530 maBtnKeepMine
.SetClickHdl( LINK( this, ScConflictsDlg
, KeepMineHandle
) );
531 maBtnKeepOther
.SetClickHdl( LINK( this, ScConflictsDlg
, KeepOtherHandle
) );
532 maBtnKeepAllMine
.SetClickHdl( LINK( this, ScConflictsDlg
, KeepAllMineHandle
) );
533 maBtnKeepAllOthers
.SetClickHdl( LINK( this, ScConflictsDlg
, KeepAllOthersHandle
) );
537 SvLBoxEntry
* pEntry
= maLbConflicts
.First();
538 if ( pEntry
!= NULL
)
540 maLbConflicts
.Select( pEntry
);
544 ScConflictsDlg::~ScConflictsDlg()
548 String
ScConflictsDlg::GetConflictString( const ScConflictsListEntry
& rConflictEntry
)
553 const ScChangeAction
* pAction
= mpOwnTrack
->GetAction( rConflictEntry
.maOwnActions
[ 0 ] );
554 if ( pAction
&& mpOwnDoc
)
556 SCTAB nTab
= pAction
->GetBigRange().MakeRange().aStart
.Tab();
557 mpOwnDoc
->GetName( nTab
, aString
);
563 String
ScConflictsDlg::GetActionString( const ScChangeAction
* pAction
, ScDocument
* pDoc
)
567 DBG_ASSERT( pAction
, "ScConflictsDlg::GetActionString(): pAction is null!" );
568 DBG_ASSERT( pDoc
, "ScConflictsDlg::GetActionString(): pDoc is null!" );
569 if ( pAction
&& pDoc
)
572 pAction
->GetDescription( aDesc
, pDoc
, TRUE
, false );
576 String aUser
= pAction
->GetUser();
577 aUser
.EraseLeadingAndTrailingChars();
578 if ( aUser
.Len() == 0 )
580 aUser
= maStrUnknownUser
;
585 DateTime aDateTime
= pAction
->GetDateTime();
586 aString
+= ScGlobal::pLocaleData
->getDate( aDateTime
);
588 aString
+= ScGlobal::pLocaleData
->getTime( aDateTime
, FALSE
);
595 void ScConflictsDlg::HandleListBoxSelection( bool bSelectHandle
)
597 SvLBoxEntry
* pSelEntry
= maLbConflicts
.GetCurEntry();
600 pSelEntry
= maLbConflicts
.FirstSelected();
607 SvLBoxEntry
* pRootEntry
= maLbConflicts
.GetRootLevelParent( pSelEntry
);
612 maLbConflicts
.SelectAll( FALSE
);
614 if ( !maLbConflicts
.IsSelected( pRootEntry
) )
616 maLbConflicts
.Select( pRootEntry
);
618 SvLBoxEntry
* pEntry
= maLbConflicts
.FirstChild( pRootEntry
);
621 if ( !maLbConflicts
.IsSelected( pEntry
) )
623 maLbConflicts
.Select( pEntry
);
625 pEntry
= maLbConflicts
.NextSibling( pEntry
);
630 IMPL_LINK( ScConflictsDlg
, SelectHandle
, SvxRedlinTable
*, EMPTYARG
)
632 if ( mbInSelectHdl
|| mbInDeselectHdl
)
637 mbInSelectHdl
= true;
638 HandleListBoxSelection( true );
639 maSelectionTimer
.Start();
640 mbInSelectHdl
= false;
645 IMPL_LINK( ScConflictsDlg
, DeselectHandle
, SvxRedlinTable
*, EMPTYARG
)
647 if ( mbInDeselectHdl
|| mbInSelectHdl
)
652 mbInDeselectHdl
= true;
653 HandleListBoxSelection( false );
654 mbInDeselectHdl
= false;
659 IMPL_LINK( ScConflictsDlg
, UpdateSelectionHdl
, Timer
*, EMPTYARG
)
661 if ( !mpViewData
|| !mpOwnDoc
)
666 ScTabView
* pTabView
= reinterpret_cast< ScTabView
* >( mpViewData
->GetView() );
667 pTabView
->DoneBlockMode();
668 BOOL bContMark
= FALSE
;
669 SvLBoxEntry
* pEntry
= maLbConflicts
.FirstSelected();
672 if ( pEntry
!= maLbConflicts
.GetRootLevelParent( pEntry
) )
674 RedlinData
* pUserData
= static_cast< RedlinData
* >( pEntry
->GetUserData() );
677 ScChangeAction
* pAction
= static_cast< ScChangeAction
* >( pUserData
->pData
);
678 if ( pAction
&& ( pAction
->GetType() != SC_CAT_DELETE_TABS
) &&
679 ( pAction
->IsClickable() || pAction
->IsVisible() ) )
681 const ScBigRange
& rBigRange
= ( static_cast< const ScChangeAction
* >( pAction
) )->GetBigRange();
682 if ( rBigRange
.IsValid( mpOwnDoc
) )
684 BOOL bSetCursor
= !maLbConflicts
.NextSelected( pEntry
);
685 pTabView
->MarkRange( rBigRange
.MakeRange(), bSetCursor
, bContMark
);
691 pEntry
= maLbConflicts
.NextSelected( pEntry
);
697 void ScConflictsDlg::SetConflictAction( SvLBoxEntry
* pRootEntry
, ScConflictAction eConflictAction
)
699 RedlinData
* pUserData
= static_cast< RedlinData
* >( pRootEntry
? pRootEntry
->GetUserData() : NULL
);
700 ScConflictsListEntry
* pConflictEntry
= static_cast< ScConflictsListEntry
* >( pUserData
? pUserData
->pData
: NULL
);
701 if ( pConflictEntry
)
703 pConflictEntry
->meConflictAction
= eConflictAction
;
707 void ScConflictsDlg::KeepHandler( bool bMine
)
709 SvLBoxEntry
* pEntry
= maLbConflicts
.FirstSelected();
710 SvLBoxEntry
* pRootEntry
= ( pEntry
? maLbConflicts
.GetRootLevelParent( pEntry
) : NULL
);
715 SetPointer( Pointer( POINTER_WAIT
) );
716 ScConflictAction eConflictAction
= ( bMine
? SC_CONFLICT_ACTION_KEEP_MINE
: SC_CONFLICT_ACTION_KEEP_OTHER
);
717 SetConflictAction( pRootEntry
, eConflictAction
);
718 maLbConflicts
.RemoveEntry( pRootEntry
);
719 SetPointer( Pointer( POINTER_ARROW
) );
720 if ( maLbConflicts
.GetEntryCount() == 0 )
726 void ScConflictsDlg::KeepAllHandler( bool bMine
)
728 SvLBoxEntry
* pEntry
= maLbConflicts
.First();
729 SvLBoxEntry
* pRootEntry
= ( pEntry
? maLbConflicts
.GetRootLevelParent( pEntry
) : NULL
);
734 SetPointer( Pointer( POINTER_WAIT
) );
735 ScConflictAction eConflictAction
= ( bMine
? SC_CONFLICT_ACTION_KEEP_MINE
: SC_CONFLICT_ACTION_KEEP_OTHER
);
738 SetConflictAction( pRootEntry
, eConflictAction
);
739 pRootEntry
= maLbConflicts
.NextSibling( pRootEntry
);
741 maLbConflicts
.SetUpdateMode( FALSE
);
742 maLbConflicts
.Clear();
743 maLbConflicts
.SetUpdateMode( TRUE
);
744 SetPointer( Pointer( POINTER_ARROW
) );
748 IMPL_LINK( ScConflictsDlg
, KeepMineHandle
, void*, EMPTYARG
)
755 IMPL_LINK( ScConflictsDlg
, KeepOtherHandle
, void*, EMPTYARG
)
757 KeepHandler( false );
762 IMPL_LINK( ScConflictsDlg
, KeepAllMineHandle
, void*, EMPTYARG
)
764 KeepAllHandler( true );
769 IMPL_LINK( ScConflictsDlg
, KeepAllOthersHandle
, void*, EMPTYARG
)
771 KeepAllHandler( false );
776 void lcl_MoveControlX( Window
& rWindow
, long nDelta
)
778 Point
aPos( rWindow
.GetPosPixel() );
780 rWindow
.SetPosPixel( aPos
);
783 void lcl_MoveControlY( Window
& rWindow
, long nDelta
)
785 Point
aPos( rWindow
.GetPosPixel() );
787 rWindow
.SetPosPixel( aPos
);
790 void lcl_ChangeControlWidth( Window
& rWindow
, long nDelta
)
792 Size
aSize( rWindow
.GetSizePixel() );
793 aSize
.Width() += nDelta
;
794 rWindow
.SetSizePixel( aSize
);
797 void lcl_ChangeControlHeight( Window
& rWindow
, long nDelta
)
799 Size
aSize( rWindow
.GetSizePixel() );
800 aSize
.Height() += nDelta
;
801 rWindow
.SetSizePixel( aSize
);
804 void ScConflictsDlg::Resize()
806 Size
aSize( GetSizePixel() );
807 long nDeltaWidth
= aSize
.Width() - maDialogSize
.Width();
808 long nDeltaHeight
= aSize
.Height() - maDialogSize
.Height();
809 maDialogSize
= aSize
;
811 lcl_ChangeControlWidth( maFtConflicts
, nDeltaWidth
);
813 lcl_ChangeControlWidth( maLbConflicts
, nDeltaWidth
);
814 lcl_ChangeControlHeight( maLbConflicts
, nDeltaHeight
);
816 lcl_MoveControlX( maBtnKeepMine
, nDeltaWidth
/ 2 );
817 lcl_MoveControlY( maBtnKeepMine
, nDeltaHeight
);
819 lcl_MoveControlX( maBtnKeepOther
, nDeltaWidth
/ 2 );
820 lcl_MoveControlY( maBtnKeepOther
, nDeltaHeight
);
822 lcl_MoveControlY( maFlConflicts
, nDeltaHeight
);
823 lcl_ChangeControlWidth( maFlConflicts
, nDeltaWidth
);
825 lcl_MoveControlX( maBtnKeepAllMine
, nDeltaWidth
);
826 lcl_MoveControlY( maBtnKeepAllMine
, nDeltaHeight
);
828 lcl_MoveControlX( maBtnKeepAllOthers
, nDeltaWidth
);
829 lcl_MoveControlY( maBtnKeepAllOthers
, nDeltaHeight
);
831 lcl_MoveControlX( maBtnCancel
, nDeltaWidth
);
832 lcl_MoveControlY( maBtnCancel
, nDeltaHeight
);
834 lcl_MoveControlX( maBtnHelp
, nDeltaWidth
);
835 lcl_MoveControlY( maBtnHelp
, nDeltaHeight
);
838 void ScConflictsDlg::UpdateView()
840 ScConflictsList::iterator aEndItr
= mrConflictsList
.end();
841 for ( ScConflictsList::iterator aItr
= mrConflictsList
.begin(); aItr
!= aEndItr
; ++aItr
)
843 ScConflictsListEntry
* pConflictEntry
= &(*aItr
);
844 if ( pConflictEntry
&& pConflictEntry
->meConflictAction
== SC_CONFLICT_ACTION_NONE
)
846 RedlinData
* pRootUserData
= new RedlinData();
847 pRootUserData
->pData
= static_cast< void* >( pConflictEntry
);
848 SvLBoxEntry
* pRootEntry
= maLbConflicts
.InsertEntry( GetConflictString( *aItr
), pRootUserData
);
850 ScChangeActionList::const_iterator aEndShared
= aItr
->maSharedActions
.end();
851 for ( ScChangeActionList::const_iterator aItrShared
= aItr
->maSharedActions
.begin(); aItrShared
!= aEndShared
; ++aItrShared
)
853 ScChangeAction
* pAction
= mpSharedTrack
->GetAction( *aItrShared
);
856 // only display shared top content entries
857 if ( pAction
->GetType() == SC_CAT_CONTENT
)
859 ScChangeActionContent
* pNextContent
= ( dynamic_cast< ScChangeActionContent
* >( pAction
) )->GetNextContent();
860 if ( pNextContent
&& aItr
->HasSharedAction( pNextContent
->GetActionNumber() ) )
866 String
aString( GetActionString( pAction
, mpSharedDoc
) );
867 maLbConflicts
.InsertEntry( aString
, static_cast< RedlinData
* >( NULL
), pRootEntry
);
871 ScChangeActionList::const_iterator aEndOwn
= aItr
->maOwnActions
.end();
872 for ( ScChangeActionList::const_iterator aItrOwn
= aItr
->maOwnActions
.begin(); aItrOwn
!= aEndOwn
; ++aItrOwn
)
874 ScChangeAction
* pAction
= mpOwnTrack
->GetAction( *aItrOwn
);
877 // only display own top content entries
878 if ( pAction
->GetType() == SC_CAT_CONTENT
)
880 ScChangeActionContent
* pNextContent
= ( dynamic_cast< ScChangeActionContent
* >( pAction
) )->GetNextContent();
881 if ( pNextContent
&& aItr
->HasOwnAction( pNextContent
->GetActionNumber() ) )
887 String
aString( GetActionString( pAction
, mpOwnDoc
) );
888 RedlinData
* pUserData
= new RedlinData();
889 pUserData
->pData
= static_cast< void* >( pAction
);
890 maLbConflicts
.InsertEntry( aString
, pUserData
, pRootEntry
);
894 maLbConflicts
.Expand( pRootEntry
);