21#include <osl/diagnose.h>
44 auto aItr = std::find(
maOwnActions.cbegin(), aEnd, nOwnAction);
52 return std::any_of(rConflictsList.begin(), rConflictsList.end(),
58 auto aEnd = rConflictsList.end();
59 auto aItr = std::find_if(rConflictsList.begin(), aEnd,
60 [nSharedAction](
ScConflictsListEntry& rConflict) { return rConflict.HasSharedAction( nSharedAction ); });
70 auto aEnd = rConflictsList.end();
71 auto aItr = std::find_if(rConflictsList.begin(), aEnd,
87 for (
auto aItr = rActionList.begin(); aItr != rActionList.end(); )
89 ScChangeActionMergeMap::iterator aItrMap = pMergeMap->find( *aItr );
90 if ( aItrMap != pMergeMap->end() )
92 *aItr = aItrMap->second;
97 aItr = rActionList.erase( aItr );
98 OSL_FAIL(
"ScConflictsListHelper::Transform_Impl: erased action from conflicts list!" );
106 for (
auto& rConflictEntry : rConflictsList )
124 ,mnStartShared( nStartShared )
125 ,mnEndShared( nEndShared )
126 ,mnStartOwn( nStartOwn )
128 ,mrConflictsList( rConflictsList )
143 if (std::any_of( rConflict.maSharedActions.cbegin(), rConflict.maSharedActions.cend(), doActionsIntersect ))
146 if (std::any_of( rConflict.maOwnActions.cbegin(), rConflict.maOwnActions.cend(), doActionsIntersect ))
173 for (
auto& rOwnAction : rOwnActions )
198 bool bReturn =
false;
202 std::vector<sal_uLong> aOwnActions;
210 pOwnAction = pOwnAction->
GetNext();
213 if ( !aOwnActions.empty() )
216 for (
const auto& aOwnAction : aOwnActions )
226 pSharedAction = pSharedAction->
GetNext();
235 ,mrConflictsList ( rConflictsList )
237 OSL_ENSURE(
mpTrack,
"ScConflictsResolver CTOR: mpTrack is null!" );
241 bool bHandleContentAction,
bool bHandleNonContentAction )
248 if ( bIsSharedAction )
252 if ( pConflictEntry )
259 if ( bHandleContentAction )
266 if ( bHandleNonContentAction )
278 if ( pConflictEntry )
285 if ( bHandleContentAction )
293 if ( bHandleNonContentAction )
304 if ( bHandleContentAction )
311 if ( bHandleNonContentAction )
323 : GenericDialogController(pParent,
"modules/scalc/ui/conflictsdialog.ui",
"ConflictsDialog")
324 , maStrUnknownUser (
ScResId( STR_UNKNOWN_USER_CONFLICT ) )
325 , mpViewData ( pViewData )
326 , mpOwnDoc ( nullptr )
327 , mpOwnTrack ( nullptr )
328 , mpSharedDoc ( pSharedDoc )
329 , mpSharedTrack ( nullptr )
330 , mrConflictsList ( rConflictsList )
331 , maSelectionIdle (
"ScConflictsDlg maSelectionIdle" )
332 , mbInSelectHdl ( false )
333 , m_xBtnKeepMine(m_xBuilder->weld_button(
"keepmine"))
334 , m_xBtnKeepOther(m_xBuilder->weld_button(
"keepother"))
335 , m_xBtnKeepAllMine(m_xBuilder->weld_button(
"keepallmine"))
336 , m_xBtnKeepAllOthers(m_xBuilder->weld_button(
"keepallothers"))
337 , m_xLbConflicts(new
SvxRedlinTable(m_xBuilder->weld_tree_view(
"container"), nullptr))
339 OSL_ENSURE(
mpViewData,
"ScConflictsDlg CTOR: mpViewData is null!" );
341 OSL_ENSURE(
mpOwnDoc,
"ScConflictsDlg CTOR: mpOwnDoc is null!" );
343 OSL_ENSURE(
mpOwnTrack,
"ScConflictsDlg CTOR: mpOwnTrack is null!" );
344 OSL_ENSURE(
mpSharedDoc,
"ScConflictsDlg CTOR: mpSharedDoc is null!" );
346 OSL_ENSURE(
mpSharedTrack,
"ScConflictsDlg CTOR: mpSharedTrack is null!" );
351 std::vector<int> aWidths
353 o3tl::narrowing<int>(nDigitWidth * 60),
354 o3tl::narrowing<int>(nDigitWidth * 20)
372 std::unique_ptr<weld::TreeIter> xEntry(rTreeView.
make_iterator());
374 rTreeView.
select(*xEntry);
398 OSL_ENSURE( pAction,
"ScConflictsDlg::GetActionString(): pAction is null!" );
399 OSL_ENSURE( pDoc,
"ScConflictsDlg::GetActionString(): pDoc is null!" );
400 if (!pAction || !pDoc)
405 rTreeView.
set_text(rEntry, aDesc, 0);
408 if ( aUser.isEmpty() )
412 rTreeView.
set_text(rEntry, aUser, 1);
417 rTreeView.
set_text(rEntry, aString, 2);
423 std::unique_ptr<weld::TreeIter> xEntry(rTreeView.
make_iterator());
424 bool bSelEntry = rTreeView.
get_cursor(xEntry.get());
430 bool bSelectHandle = rTreeView.
is_selected(*xEntry);
438 rTreeView.
select(*xEntry);
444 rTreeView.
select(*xEntry);
454 mbInSelectHdl =
true;
455 HandleListBoxSelection();
456 maSelectionIdle.Start();
457 mbInSelectHdl =
false;
462 if ( !mpViewData || !mpOwnDoc )
467 ScTabView* pTabView = mpViewData->GetView();
470 std::vector<const ScChangeAction*> aActions;
476 RedlinData* pUserData = weld::fromId<RedlinData*>(rTreeView.get_id(rEntry));
479 ScChangeAction* pAction = static_cast< ScChangeAction* >( pUserData->pData );
480 if ( pAction && ( pAction->GetType() != SC_CAT_DELETE_TABS ) &&
481 ( pAction->IsClickable() || pAction->IsVisible() ) )
483 aActions.push_back(pAction);
490 bool bContMark =
false;
491 for (
size_t i = 0, nCount = aActions.size(); i < nCount; ++i)
493 const ScBigRange& rBigRange = aActions[
i]->GetBigRange();
494 if (rBigRange.
IsValid(*mpOwnDoc))
496 bool bSetCursor =
i ==
nCount - 1;
497 pTabView->MarkRange(rBigRange.
MakeRange( *mpOwnDoc ), bSetCursor, bContMark);
506 RedlinData* pUserData = weld::fromId<RedlinData*>(rTreeView.
get_id(rRootEntry));
508 if ( pConflictEntry )
517 std::unique_ptr<weld::TreeIter> xEntry(rTreeView.
make_iterator());
527 rTreeView.
remove(*xEntry);
536 std::unique_ptr<weld::TreeIter> xEntry(rTreeView.
make_iterator());
567 KeepHandler(
false );
572 KeepAllHandler(
true );
577 KeepAllHandler(
false );
587 std::unique_ptr<RedlinData> pRootUserData(
new RedlinData());
588 pRootUserData->pData =
static_cast<void*
>(&rConflictEntry);
591 std::unique_ptr<weld::TreeIter> xRootEntry(rTreeView.
make_iterator());
592 std::unique_ptr<weld::TreeIter> xEntry(rTreeView.
make_iterator());
593 rTreeView.
insert(
nullptr, -1, &sString, &
sId,
nullptr,
nullptr,
false, xRootEntry.get());
595 for (
const auto& aSharedAction : rConflictEntry.maSharedActions )
604 if ( pNextContent && rConflictEntry.HasSharedAction( pNextContent->
GetActionNumber() ) )
610 rTreeView.
insert(xRootEntry.get(), -1,
nullptr,
nullptr,
nullptr,
nullptr,
false, xEntry.get());
615 for (
const auto& aOwnAction : rConflictEntry.maOwnActions )
624 if ( pNextContent && rConflictEntry.HasOwnAction( pNextContent->
GetActionNumber() ) )
630 std::unique_ptr<RedlinData> pUserData(
new RedlinData());
631 pUserData->pData =
static_cast< void*
>( pAction );
632 OUString aId(
weld::toId(pUserData.release()));
633 rTreeView.
insert(xRootEntry.get(), -1,
nullptr, &aId,
nullptr,
nullptr,
false, xEntry.get());
OUString getDate(const Date &rDate) const
OUString getTime(const tools::Time &rTime, bool bSec=true, bool b100Sec=false) const
bool Intersects(const ScBigRange &) const
do two ranges overlap?
bool IsValid(const ScDocument &rDoc) const
ScRange MakeRange(const ScDocument &rDoc) const
ScChangeActionContent * GetNextContent() const
ScBigRange & GetBigRange()
sal_uLong GetActionNumber() const
ScChangeActionType GetType() const
virtual OUString GetDescription(ScDocument &rDoc, bool bSplitRange=false, bool bWarning=true) const
ScChangeAction * GetNext() const
SC_DLLPUBLIC DateTime GetDateTime() const
const OUString & GetUser() const
SC_DLLPUBLIC ScChangeAction * GetAction(sal_uLong nAction) const
bool Reject(ScChangeAction *, ScChangeActionMap *, bool bRecursion)
ScConflictsList & mrConflictsList
std::unique_ptr< SvxRedlinTable > m_xLbConflicts
void SetConflictAction(const weld::TreeIter &rRootEntry, ScConflictAction eConflictAction)
ScConflictsDlg(weld::Window *pParent, ScViewData *pViewData, ScDocument *pSharedDoc, ScConflictsList &rConflictsList)
ScChangeTrack * mpSharedTrack
OUString maStrUnknownUser
std::unique_ptr< weld::Button > m_xBtnKeepAllMine
std::unique_ptr< weld::Button > m_xBtnKeepMine
OUString GetConflictString(const ScConflictsListEntry &rConflictEntry)
ScDocument *const mpSharedDoc
void SetActionString(const ScChangeAction *pAction, ScDocument *pDoc, const weld::TreeIter &rEntry)
void KeepHandler(bool bMine)
void KeepAllHandler(bool bMine)
ScViewData *const mpViewData
void HandleListBoxSelection()
std::unique_ptr< weld::Button > m_xBtnKeepAllOthers
virtual ~ScConflictsDlg() override
ScChangeTrack * mpOwnTrack
std::unique_ptr< weld::Button > m_xBtnKeepOther
ScConflictsList & mrConflictsList
ScConflictsListEntry * GetIntersectingEntry(const ScChangeAction *pAction) const
ScConflictsListEntry & GetEntry(sal_uLong nSharedAction, const std::vector< sal_uLong > &rOwnActions)
static bool DoActionsIntersect(const ScChangeAction *pAction1, const ScChangeAction *pAction2)
ScConflictsFinder(ScChangeTrack *pTrack, sal_uLong nStartShared, sal_uLong nEndShared, sal_uLong nStartOwn, sal_uLong nEndOwn, ScConflictsList &rConflictsList)
static void TransformConflictsList(ScConflictsList &rConflictsList, ScChangeActionMergeMap *pSharedMap, ScChangeActionMergeMap *pOwnMap)
static void Transform_Impl(std::vector< sal_uLong > &rActionList, ScChangeActionMergeMap *pMergeMap)
static bool HasOwnAction(ScConflictsList &rConflictsList, sal_uLong nOwnAction)
static ScConflictsListEntry * GetSharedActionEntry(ScConflictsList &rConflictsList, sal_uLong nSharedAction)
static ScConflictsListEntry * GetOwnActionEntry(ScConflictsList &rConflictsList, sal_uLong nOwnAction)
ScConflictsList & mrConflictsList
void HandleAction(ScChangeAction *pAction, bool bIsSharedAction, bool bHandleContentAction, bool bHandleNonContentAction)
ScConflictsResolver(ScChangeTrack *pTrack, ScConflictsList &rConflictsList)
ScChangeTrack * GetChangeTrack() const
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
static SC_DLLPUBLIC const LocaleDataWrapper & getLocaleData()
void DoneBlockMode(bool bContinue=false)
ScDocument & GetDocument() const
void SetInvokeHandler(const Link< Timer *, void > &rLink)
std::shared_ptr< weld::Dialog > m_xDialog
virtual std::unique_ptr< TreeIter > make_iterator(const TreeIter *pOrig=nullptr) const=0
virtual bool get_selected(TreeIter *pIter) const=0
virtual void expand_row(const TreeIter &rIter)=0
virtual void set_text(int row, const OUString &rText, int col=-1)=0
virtual int n_children() const=0
virtual void set_selection_mode(SelectionMode eMode)=0
virtual void insert(const TreeIter *pParent, int pos, const OUString *pStr, const OUString *pId, const OUString *pIconName, VirtualDevice *pImageSurface, bool bChildrenOnDemand, TreeIter *pRet)=0
virtual void selected_foreach(const std::function< bool(TreeIter &)> &func)=0
void connect_changed(const Link< TreeView &, void > &rLink)
virtual bool get_iter_first(TreeIter &rIter) const=0
virtual bool is_selected(int pos) const=0
virtual int get_height_rows(int nRows) const=0
virtual void remove(int pos)=0
virtual bool iter_next_sibling(TreeIter &rIter) const=0
virtual void select(int pos)=0
virtual bool iter_parent(TreeIter &rIter) const=0
virtual void set_column_fixed_widths(const std::vector< int > &rWidths)=0
virtual bool iter_children(TreeIter &rIter) const=0
virtual bool get_cursor(TreeIter *pIter) const=0
virtual int get_iter_depth(const TreeIter &rIter) const=0
virtual OUString get_id(int pos) const=0
IMPL_LINK_NOARG(ScConflictsDlg, SelectHandle, weld::TreeView &, void)
@ SC_CONFLICT_ACTION_NONE
@ SC_CONFLICT_ACTION_KEEP_MINE
@ SC_CONFLICT_ACTION_KEEP_OTHER
::std::vector< ScConflictsListEntry > ScConflictsList
std::unordered_map< sal_uLong, sal_uLong > ScChangeActionMergeMap
#define LINK(Instance, Class, Member)
OString strip(const OString &rIn, char c)
OUString toId(const void *pValue)
OUString ScResId(TranslateId aId)
bool HasOwnAction(sal_uLong nOwnAction) const
bool HasSharedAction(sal_uLong nSharedAction) const
std::vector< sal_uLong > maOwnActions
ScConflictAction meConflictAction
std::vector< sal_uLong > maSharedActions