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