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