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