diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-04-18 16:49:26 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-04-27 12:41:14 +0200 |
commit | 56dd851cfc77c362c3db5c0aae4a490c7f6782cc (patch) | |
tree | 0f5f6564e0b9af8123f4cebfe9a2f55c1bbbba57 /sc/source | |
parent | 6afbe153ffd4cab27f0a7bb77f71f25923dc2e43 (diff) |
weld cluster of change tracking dialogs
Change-Id: I42ca7acb41699df91b91a9f59fc68cd30972a397
Reviewed-on: https://gerrit.libreoffice.org/70988
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/docshell/docsh3.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/inc/acredlin.hxx | 66 | ||||
-rw-r--r-- | sc/source/ui/inc/conflictsdlg.hxx | 46 | ||||
-rw-r--r-- | sc/source/ui/inc/highred.hxx | 36 | ||||
-rw-r--r-- | sc/source/ui/inc/reffact.hxx | 86 | ||||
-rw-r--r-- | sc/source/ui/inc/simpref.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/acredlin.cxx | 1014 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/conflictsdlg.cxx | 308 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/highred.cxx | 221 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/simpref.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/view/reffact.cxx | 60 | ||||
-rw-r--r-- | sc/source/ui/view/tabview3.cxx | 24 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh4.cxx | 11 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshc.cxx | 14 |
14 files changed, 900 insertions, 1003 deletions
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index 0c8e93cd857e..060dc50f36ad 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -1199,10 +1199,10 @@ bool ScDocShell::MergeSharedDocument( ScDocShell* pSharedDocShell ) while ( bLoop ) { bLoop = false; - ScopedVclPtrInstance< ScConflictsDlg > aDlg( GetActiveDialogParent(), GetViewData(), &rSharedDoc, aConflictsList ); - if ( aDlg->Execute() == RET_CANCEL ) + vcl::Window* pWin = GetActiveDialogParent(); + ScConflictsDlg aDlg(pWin ? pWin->GetFrameWeld() : nullptr, GetViewData(), &rSharedDoc, aConflictsList); + if (aDlg.run() == RET_CANCEL) { - vcl::Window* pWin = GetActiveDialogParent(); std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, VclMessageType::Question, VclButtonsType::YesNo, ScResId(STR_DOC_WILLNOTBESAVED))); diff --git a/sc/source/ui/inc/acredlin.hxx b/sc/source/ui/inc/acredlin.hxx index fd8e19f8f24f..a92d4d2a1c58 100644 --- a/sc/source/ui/inc/acredlin.hxx +++ b/sc/source/ui/inc/acredlin.hxx @@ -45,17 +45,12 @@ public: bool bIsAcceptable; }; -class ScAcceptChgDlg final : public SfxModelessDialog +class ScAcceptChgDlg final : public SfxModelessDialogController { Idle aSelectionIdle; Idle aReOpenIdle; - VclPtr<PopupMenu> m_xPopup; - VclPtr<SvxAcceptChgCtr> m_pAcceptChgCtr; ScViewData* pViewData; ScDocument* pDoc; - VclPtr<SvxTPFilter> pTPFilter; - VclPtr<SvxTPView> pTPView; - VclPtr<SvxRedlinTable> pTheView; // #i48648 now SvHeaderTabListBox ScRangeList aRangeList; ScChangeViewSettings aChangeViewSet; OUString aStrInsertCols; @@ -82,6 +77,14 @@ class ScAcceptChgDlg final : public SfxModelessDialog bool bHasFilterEntry:1; bool bUseColor:1; + SvxTPFilter* pTPFilter; + SvxTPView* pTPView; + SvxRedlinTable* pTheView; // #i48648 now SvHeaderTabListBox + + std::unique_ptr<weld::Container> m_xContentArea; + std::unique_ptr<weld::Menu> m_xPopup; + std::unique_ptr<SvxAcceptChgCtr> m_xAcceptChgCtr; + void Init(); DECL_LINK( FilterHandle, SvxTPFilter*, void ); @@ -90,15 +93,16 @@ class ScAcceptChgDlg final : public SfxModelessDialog DECL_LINK( AcceptHandle, SvxTPView*, void ); DECL_LINK( RejectAllHandle, SvxTPView*, void ); DECL_LINK( AcceptAllHandle, SvxTPView*, void ); - DECL_LINK( ExpandingHandle, SvTreeListBox*, bool ); - DECL_LINK( SelectHandle, SvTreeListBox*, void ); + DECL_LINK( ExpandingHandle, const weld::TreeIter&, bool ); + DECL_LINK( SelectHandle, weld::TreeView&, void ); DECL_LINK( RefInfoHandle, const OUString*, void ); DECL_LINK( UpdateSelectionHdl, Timer*, void ); DECL_LINK( ChgTrackModHdl, ScChangeTrack&, void ); - DECL_LINK( CommandHdl, SvSimpleTable*, void ); + DECL_LINK( CommandHdl, const CommandEvent&, bool ); DECL_LINK( ReOpenTimerHdl, Timer*, void ); - DECL_LINK( ColCompareHdl, const SvSortData*, sal_Int32 ); + + int ColCompareHdl(const weld::TreeIter& rLeft, const weld::TreeIter& rRight) const; void RejectFiltered(); void AcceptFiltered(); @@ -107,31 +111,32 @@ class ScAcceptChgDlg final : public SfxModelessDialog OUString* MakeTypeString(ScChangeActionType eType); - SvTreeListEntry* AppendChangeAction( - const ScChangeAction* pScChangeAction, - SvTreeListEntry* pParent=nullptr,bool bDelMaster = false, + std::unique_ptr<weld::TreeIter> AppendChangeAction( + const ScChangeAction* pScChangeAction, bool bCreateOnDamend, + const weld::TreeIter* pParent = nullptr, bool bDelMaster = false, bool bDisabled = false); - SvTreeListEntry* AppendFilteredAction( + std::unique_ptr<weld::TreeIter> AppendFilteredAction( const ScChangeAction* pScChangeAction,ScChangeActionState eState, - SvTreeListEntry* pParent = nullptr,bool bDelMaster = false, + bool bCreateOnDemand, + const weld::TreeIter* pParent = nullptr, bool bDelMaster = false, bool bDisabled = false); - SvTreeListEntry* InsertChangeActionContent(const ScChangeActionContent* pScChangeAction, - SvTreeListEntry* pParent,sal_uLong nSpecial); + std::unique_ptr<weld::TreeIter> InsertChangeActionContent(const ScChangeActionContent* pScChangeAction, + const weld::TreeIter& rParent, sal_uLong nSpecial); - void GetDependents( const ScChangeAction* pScChangeAction, - ScChangeActionMap& aActionMap, - SvTreeListEntry* pEntry); + void GetDependents(const ScChangeAction* pScChangeAction, + ScChangeActionMap& aActionMap, + const weld::TreeIter& rEntry); - bool InsertContentChildren( ScChangeActionMap* pActionMap, SvTreeListEntry* pParent ); + bool InsertContentChildren(ScChangeActionMap* pActionMap, const weld::TreeIter& rParent); - bool InsertAcceptedORejected(SvTreeListEntry* pParent); + bool InsertAcceptedORejected(const weld::TreeIter& rParent); - bool InsertDeletedChildren( const ScChangeAction* pChangeAction, ScChangeActionMap* pActionMap, - SvTreeListEntry* pParent); + bool InsertDeletedChildren(const ScChangeAction* pChangeAction, ScChangeActionMap* pActionMap, + const weld::TreeIter& rParent); - bool InsertChildren( ScChangeActionMap* pActionMap, SvTreeListEntry* pParent ); + bool InsertChildren(ScChangeActionMap* pActionMap, const weld::TreeIter& rParent); void AppendChanges(const ScChangeTrack* pChanges,sal_uLong nStartAction, sal_uLong nEndAction); @@ -142,20 +147,17 @@ class ScAcceptChgDlg final : public SfxModelessDialog void ClearView(); bool Expand(const ScChangeTrack* pChanges,const ScChangeAction* pScChangeAction, - SvTreeListEntry* pEntry, bool bFilter = false); + const weld::TreeIter& rEntry, bool bFilter = false); public: - ScAcceptChgDlg( SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pParent, - ScViewData* ptrViewData); - - virtual ~ScAcceptChgDlg() override; - virtual void dispose() override; + ScAcceptChgDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + ScViewData* ptrViewData); + virtual ~ScAcceptChgDlg() override; void ReInit(ScViewData* ptrViewData); void Initialize (SfxChildWinInfo* pInfo); virtual void FillInfo(SfxChildWinInfo&) const override; - }; #endif // INCLUDED_SC_SOURCE_UI_INC_ACREDLIN_HXX diff --git a/sc/source/ui/inc/conflictsdlg.hxx b/sc/source/ui/inc/conflictsdlg.hxx index 818023d75269..433d4584b140 100644 --- a/sc/source/ui/inc/conflictsdlg.hxx +++ b/sc/source/ui/inc/conflictsdlg.hxx @@ -111,50 +111,46 @@ public: // class ScConflictsDlg -class ScConflictsDlg : public ModalDialog +class ScConflictsDlg : public weld::GenericDialogController { private: - VclPtr<SvSimpleTableContainer> m_pLbConflictsContainer; - VclPtr<SvxRedlinTable> m_pLbConflicts; - VclPtr<PushButton> m_pBtnKeepMine; - VclPtr<PushButton> m_pBtnKeepOther; - VclPtr<PushButton> m_pBtnKeepAllMine; - VclPtr<PushButton> m_pBtnKeepAllOthers; + OUString const maStrTitleConflict; + OUString const maStrUnknownUser; - OUString const maStrTitleConflict; - OUString const maStrUnknownUser; - - ScViewData* const mpViewData; + ScViewData* const mpViewData; ScDocument* mpOwnDoc; ScChangeTrack* mpOwnTrack; - ScDocument* const mpSharedDoc; + ScDocument* const mpSharedDoc; ScChangeTrack* mpSharedTrack; ScConflictsList& mrConflictsList; Idle maSelectionIdle; bool mbInSelectHdl; - bool mbInDeselectHdl; + + std::unique_ptr<weld::Button> m_xBtnKeepMine; + std::unique_ptr<weld::Button> m_xBtnKeepOther; + std::unique_ptr<weld::Button> m_xBtnKeepAllMine; + std::unique_ptr<weld::Button> m_xBtnKeepAllOthers; + std::unique_ptr<SvxRedlinTable> m_xLbConflicts; OUString GetConflictString( const ScConflictsListEntry& rConflictEntry ); - OUString GetActionString( const ScChangeAction* pAction, ScDocument* pDoc ); - void HandleListBoxSelection( bool bSelectHandle ); + void SetActionString(const ScChangeAction* pAction, ScDocument* pDoc, weld::TreeIter& rEntry); + void HandleListBoxSelection(); - static void SetConflictAction( const SvTreeListEntry* pRootEntry, ScConflictAction eConflictAction ); + void SetConflictAction(const weld::TreeIter& rRootEntry, ScConflictAction eConflictAction); void KeepHandler( bool bMine ); void KeepAllHandler( bool bMine ); - DECL_LINK( SelectHandle, SvTreeListBox*, void ); - DECL_LINK( DeselectHandle, SvTreeListBox*, void ); + DECL_LINK( SelectHandle, weld::TreeView&, void ); DECL_LINK( UpdateSelectionHdl, Timer*, void ); - DECL_LINK( KeepMineHandle, Button*, void ); - DECL_LINK( KeepOtherHandle, Button*, void ); - DECL_LINK( KeepAllMineHandle, Button*, void ); - DECL_LINK( KeepAllOthersHandle, Button*, void ); + DECL_LINK( KeepMineHandle, weld::Button&, void ); + DECL_LINK( KeepOtherHandle, weld::Button&, void ); + DECL_LINK( KeepAllMineHandle, weld::Button&, void ); + DECL_LINK( KeepAllOthersHandle, weld::Button&, void ); public: - ScConflictsDlg( vcl::Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList ); - virtual ~ScConflictsDlg() override; - virtual void dispose() override; + ScConflictsDlg(weld::Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList); + virtual ~ScConflictsDlg() override; void UpdateView(); }; diff --git a/sc/source/ui/inc/highred.hxx b/sc/source/ui/inc/highred.hxx index 1a4c595a0cb8..ffb504cdf633 100644 --- a/sc/source/ui/inc/highred.hxx +++ b/sc/source/ui/inc/highred.hxx @@ -29,42 +29,44 @@ class ScViewData; class ScDocument; -class ScHighlightChgDlg : public ScAnyRefDlg +class ScHighlightChgDlg : public ScAnyRefDlgController { private: - VclPtr<CheckBox> m_pHighlightBox; - VclPtr<SvxTPFilter> m_pFilterCtr; - VclPtr<CheckBox> m_pCbAccept; - VclPtr<CheckBox> m_pCbReject; - VclPtr<OKButton> m_pOkButton; - - VclPtr<formula::RefEdit> m_pEdAssign; - VclPtr<formula::RefButton> m_pRbAssign; - ScViewData* pViewData; ScDocument* pDoc; ScChangeViewSettings aChangeViewSet; + std::unique_ptr<weld::CheckButton> m_xHighlightBox; + std::unique_ptr<weld::CheckButton> m_xCbAccept; + std::unique_ptr<weld::CheckButton> m_xCbReject; + std::unique_ptr<weld::Button> m_xOkButton; + + std::unique_ptr<formula::WeldRefEdit> m_xEdAssign; + std::unique_ptr<formula::WeldRefButton> m_xRbAssign; + + std::unique_ptr<weld::Container> m_xBox; + + std::unique_ptr<SvxTPFilter> m_xFilterCtr; + void Init(); DECL_LINK( RefHandle, SvxTPFilter*, void ); - DECL_LINK( HighlightHandle, Button*, void ); - DECL_LINK( OKBtnHdl, Button*, void ); + DECL_LINK( HighlightHandle, weld::Button&, void ); + DECL_LINK( OKBtnHdl, weld::Button&, void ); protected: virtual void RefInputDone( bool bForced = false ) override; public: - ScHighlightChgDlg( SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pParent, - ScViewData* ptrViewData); + ScHighlightChgDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + ScViewData* ptrViewData); - virtual ~ScHighlightChgDlg() override; - virtual void dispose() override; + virtual ~ScHighlightChgDlg() override; virtual void SetActive() override; virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) override; - virtual bool Close() override; + virtual void Close() override; virtual bool IsRefInputMode() const override; }; diff --git a/sc/source/ui/inc/reffact.hxx b/sc/source/ui/inc/reffact.hxx index 61ec9321a9ad..eac1e2aa3ad2 100644 --- a/sc/source/ui/inc/reffact.hxx +++ b/sc/source/ui/inc/reffact.hxx @@ -33,30 +33,19 @@ SFX_DECL_CHILDWINDOW_WITHID(Class); \ }; -#define DECL_WRAPPER_WITHID_CONTROLLER(Class) \ - class Class : public SfxChildWindow \ - { \ - public: \ - Class( vcl::Window*, sal_uInt16, SfxBindings*, const SfxChildWinInfo* ); \ - static std::unique_ptr<SfxChildWindow> CreateImpl(vcl::Window *pParent, sal_uInt16 nId, \ - SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \ - static void RegisterChildWindow (bool bVisible=false, SfxModule *pMod=nullptr, SfxChildWindowFlags nFlags=SfxChildWindowFlags::NONE); \ - static sal_uInt16 GetChildWindowId ();\ - }; - -DECL_WRAPPER_WITHID_CONTROLLER(ScNameDlgWrapper) -DECL_WRAPPER_WITHID_CONTROLLER(ScNameDefDlgWrapper) -DECL_WRAPPER_WITHID_CONTROLLER(ScSolverDlgWrapper) -DECL_WRAPPER_WITHID_CONTROLLER(ScOptSolverDlgWrapper) +DECL_WRAPPER_WITHID(ScNameDlgWrapper) +DECL_WRAPPER_WITHID(ScNameDefDlgWrapper) +DECL_WRAPPER_WITHID(ScSolverDlgWrapper) +DECL_WRAPPER_WITHID(ScOptSolverDlgWrapper) DECL_WRAPPER_WITHID(ScXMLSourceDlgWrapper) DECL_WRAPPER_WITHID(ScPivotLayoutWrapper) -DECL_WRAPPER_WITHID_CONTROLLER(ScTabOpDlgWrapper) -DECL_WRAPPER_WITHID_CONTROLLER(ScFilterDlgWrapper) -DECL_WRAPPER_WITHID_CONTROLLER(ScSpecialFilterDlgWrapper) -DECL_WRAPPER_WITHID_CONTROLLER(ScDbNameDlgWrapper) -DECL_WRAPPER_WITHID_CONTROLLER(ScConsolidateDlgWrapper) -DECL_WRAPPER_WITHID_CONTROLLER(ScPrintAreasDlgWrapper) -DECL_WRAPPER_WITHID_CONTROLLER(ScColRowNameRangesDlgWrapper) +DECL_WRAPPER_WITHID(ScTabOpDlgWrapper) +DECL_WRAPPER_WITHID(ScFilterDlgWrapper) +DECL_WRAPPER_WITHID(ScSpecialFilterDlgWrapper) +DECL_WRAPPER_WITHID(ScDbNameDlgWrapper) +DECL_WRAPPER_WITHID(ScConsolidateDlgWrapper) +DECL_WRAPPER_WITHID(ScPrintAreasDlgWrapper) +DECL_WRAPPER_WITHID(ScColRowNameRangesDlgWrapper) DECL_WRAPPER_WITHID(ScFormulaDlgWrapper) DECL_WRAPPER_WITHID(ScHighlightChgDlgWrapper) DECL_WRAPPER_WITHID(ScCondFormatDlgWrapper) @@ -159,41 +148,38 @@ private: ScFourierAnalysisDialogWrapper() = delete; }; -class ScAcceptChgDlgWrapper: public SfxChildWindow +class ScAcceptChgDlgWrapper : public SfxChildWindow { - public: - ScAcceptChgDlgWrapper( vcl::Window*, - sal_uInt16, - SfxBindings*, - SfxChildWinInfo* ); +public: + ScAcceptChgDlgWrapper( vcl::Window*, + sal_uInt16, + SfxBindings*, + SfxChildWinInfo* ); - SFX_DECL_CHILDWINDOW_WITHID(Class); + SFX_DECL_CHILDWINDOW_WITHID(Class); - void ReInitDlg(); + void ReInitDlg(); }; class ScSimpleRefDlgWrapper: public SfxChildWindow { - public: - ScSimpleRefDlgWrapper( vcl::Window*, - sal_uInt16, - SfxBindings*, - SfxChildWinInfo* ); - - static std::unique_ptr<SfxChildWindow> CreateImpl(vcl::Window *pParent, sal_uInt16 nId, - SfxBindings *pBindings, SfxChildWinInfo* pInfo); - static void RegisterChildWindow(bool bVisible=false, SfxModule *pMod=nullptr, SfxChildWindowFlags nFlags=SfxChildWindowFlags::NONE); - static sal_uInt16 GetChildWindowId(); - - static void SetDefaultPosSize(Point aPos, Size aSize); - void SetRefString(const OUString& rStr); - void SetCloseHdl( const Link<const OUString*,void>& rLink ); - void SetUnoLinks( const Link<const OUString&,void>& rDone, const Link<const OUString&,void>& rAbort, - const Link<const OUString&,void>& rChange ); - void SetFlags( bool bCloseOnButtonUp, bool bSingleCell, bool bMultiSelection ); - static void SetAutoReOpen(bool bFlag); - - void StartRefInput(); +public: + ScSimpleRefDlgWrapper(vcl::Window*, + sal_uInt16, + SfxBindings*, + SfxChildWinInfo*); + + SFX_DECL_CHILDWINDOW_WITHID(Class); + + static void SetDefaultPosSize(Point aPos, Size aSize); + void SetRefString(const OUString& rStr); + void SetCloseHdl( const Link<const OUString*,void>& rLink ); + void SetUnoLinks( const Link<const OUString&,void>& rDone, const Link<const OUString&,void>& rAbort, + const Link<const OUString&,void>& rChange ); + void SetFlags( bool bCloseOnButtonUp, bool bSingleCell, bool bMultiSelection ); + static void SetAutoReOpen(bool bFlag); + + void StartRefInput(); }; class SC_DLLPUBLIC ScValidityRefChildWin : public SfxChildWindow diff --git a/sc/source/ui/inc/simpref.hxx b/sc/source/ui/inc/simpref.hxx index a69330fbf55b..7920005ac437 100644 --- a/sc/source/ui/inc/simpref.hxx +++ b/sc/source/ui/inc/simpref.hxx @@ -35,6 +35,7 @@ private: ScRange theCurArea; bool bCloseFlag; + bool bAutoReOpen; bool bCloseOnButtonUp; bool bSingleCell; bool bMultiSelection; @@ -67,6 +68,7 @@ public: void StartRefInput(); void SetRefString(const OUString &rStr); + virtual void FillInfo(SfxChildWinInfo&) const override; void SetCloseHdl( const Link<const OUString*,void>& rLink ); void SetUnoLinks( const Link<const OUString&,void>& rDone, const Link<const OUString&,void>& rAbort, diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx index 00b841ed4bc5..54b029509c7b 100644 --- a/sc/source/ui/miscdlgs/acredlin.cxx +++ b/sc/source/ui/miscdlgs/acredlin.cxx @@ -69,104 +69,92 @@ ScRedlinData::~ScRedlinData() // class ScAcceptChgDlg -ScAcceptChgDlg::ScAcceptChgDlg(SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pParent, +ScAcceptChgDlg::ScAcceptChgDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, ScViewData* ptrViewData) - : SfxModelessDialog(pB, pCW, pParent, - "AcceptRejectChangesDialog", "svx/ui/acceptrejectchangesdialog.ui"), - aSelectionIdle("ScAcceptChgDlg SelectionIdle"), - aReOpenIdle("ScAcceptChgDlg ReOpenIdle"), - m_xPopup(get_menu("calcmenu")), - pViewData ( ptrViewData ), - pDoc ( ptrViewData->GetDocument() ), - aStrInsertCols (ScResId(STR_CHG_INSERT_COLS)), - aStrInsertRows (ScResId(STR_CHG_INSERT_ROWS)), - aStrInsertTabs (ScResId(STR_CHG_INSERT_TABS)), - aStrDeleteCols (ScResId(STR_CHG_DELETE_COLS)), - aStrDeleteRows (ScResId(STR_CHG_DELETE_ROWS)), - aStrDeleteTabs (ScResId(STR_CHG_DELETE_TABS)), - aStrMove (ScResId(STR_CHG_MOVE)), - aStrContent (ScResId(STR_CHG_CONTENT)), - aStrReject (ScResId(STR_CHG_REJECT)), - aStrAllAccepted (ScResId(STR_CHG_ACCEPTED)), - aStrAllRejected (ScResId(STR_CHG_REJECTED)), - aStrNoEntry (ScResId(STR_CHG_NO_ENTRY)), - aStrContentWithChild (ScResId(STR_CHG_CONTENT_WITH_CHILD)), - aStrChildContent (ScResId(STR_CHG_CHILD_CONTENT)), - aStrChildOrgContent (ScResId(STR_CHG_CHILD_ORGCONTENT)), - aStrEmpty (ScResId(STR_CHG_EMPTY)), - aUnknown("Unknown"), - bIgnoreMsg(false), - bNoSelection(false), - bHasFilterEntry(false), - bUseColor(false) + : SfxModelessDialogController(pB, pCW, pParent, + "svx/ui/acceptrejectchangesdialog.ui", "AcceptRejectChangesDialog") + , aSelectionIdle("ScAcceptChgDlg SelectionIdle") + , aReOpenIdle("ScAcceptChgDlg ReOpenIdle") + , pViewData( ptrViewData ) + , pDoc( ptrViewData->GetDocument() ) + , aStrInsertCols(ScResId(STR_CHG_INSERT_COLS)) + , aStrInsertRows(ScResId(STR_CHG_INSERT_ROWS)) + , aStrInsertTabs(ScResId(STR_CHG_INSERT_TABS)) + , aStrDeleteCols(ScResId(STR_CHG_DELETE_COLS)) + , aStrDeleteRows(ScResId(STR_CHG_DELETE_ROWS)) + , aStrDeleteTabs(ScResId(STR_CHG_DELETE_TABS)) + , aStrMove(ScResId(STR_CHG_MOVE)) + , aStrContent(ScResId(STR_CHG_CONTENT)) + , aStrReject(ScResId(STR_CHG_REJECT)) + , aStrAllAccepted(ScResId(STR_CHG_ACCEPTED)) + , aStrAllRejected(ScResId(STR_CHG_REJECTED)) + , aStrNoEntry(ScResId(STR_CHG_NO_ENTRY)) + , aStrContentWithChild(ScResId(STR_CHG_CONTENT_WITH_CHILD)) + , aStrChildContent(ScResId(STR_CHG_CHILD_CONTENT)) + , aStrChildOrgContent(ScResId(STR_CHG_CHILD_ORGCONTENT)) + , aStrEmpty(ScResId(STR_CHG_EMPTY)) + , aUnknown("Unknown") + , bIgnoreMsg(false) + , bNoSelection(false) + , bHasFilterEntry(false) + , bUseColor(false) + , m_xContentArea(m_xDialog->weld_content_area()) + , m_xPopup(m_xBuilder->weld_menu("calcmenu")) { - m_pAcceptChgCtr = VclPtr<SvxAcceptChgCtr>::Create(get_content_area(), this); + m_xAcceptChgCtr.reset(new SvxAcceptChgCtr(m_xContentArea.get(), m_xBuilder.get())); nAcceptCount=0; nRejectCount=0; aReOpenIdle.SetInvokeHandler(LINK( this, ScAcceptChgDlg, ReOpenTimerHdl )); - pTPFilter=m_pAcceptChgCtr->GetFilterPage(); - pTPView=m_pAcceptChgCtr->GetViewPage(); - pTheView=pTPView->GetTableControl(); + pTPFilter = m_xAcceptChgCtr->GetFilterPage(); + pTPView = m_xAcceptChgCtr->GetViewPage(); + pTheView = pTPView->GetTableControl(); + pTheView->SetCalcView(); aSelectionIdle.SetInvokeHandler(LINK( this, ScAcceptChgDlg, UpdateSelectionHdl )); aSelectionIdle.SetDebugName( "ScAcceptChgDlg aSelectionIdle" ); pTPFilter->SetReadyHdl(LINK( this, ScAcceptChgDlg, FilterHandle )); pTPFilter->SetRefHdl(LINK( this, ScAcceptChgDlg, RefHandle )); pTPFilter->HideRange(false); - pTPView->InsertCalcHeader(); pTPView->SetRejectClickHdl( LINK( this, ScAcceptChgDlg,RejectHandle)); pTPView->SetAcceptClickHdl( LINK(this, ScAcceptChgDlg, AcceptHandle)); pTPView->SetRejectAllClickHdl( LINK( this, ScAcceptChgDlg,RejectAllHandle)); pTPView->SetAcceptAllClickHdl( LINK(this, ScAcceptChgDlg, AcceptAllHandle)); - pTheView->SetCalcView(); - pTheView->SetStyle(pTheView->GetStyle()|WB_HASLINES|WB_CLIPCHILDREN|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL); - pTheView->SetExpandingHdl( LINK(this, ScAcceptChgDlg, ExpandingHandle)); - pTheView->SetSelectHdl( LINK(this, ScAcceptChgDlg, SelectHandle)); - pTheView->SetDeselectHdl( LINK(this, ScAcceptChgDlg, SelectHandle)); - pTheView->SetCommandHdl( LINK(this, ScAcceptChgDlg, CommandHdl)); - pTheView->SetColCompareHdl( LINK(this, ScAcceptChgDlg,ColCompareHdl)); - pTheView->SetSelectionMode(SelectionMode::Multiple); - pTheView->SetHighlightRange(1); + + weld::TreeView& rTreeView = pTheView->GetWidget(); + rTreeView.connect_expanding(LINK(this, ScAcceptChgDlg, ExpandingHandle)); + rTreeView.connect_changed(LINK(this, ScAcceptChgDlg, SelectHandle)); + rTreeView.connect_popup_menu(LINK(this, ScAcceptChgDlg, CommandHdl)); + rTreeView.set_sort_func([this](const weld::TreeIter& rLeft, const weld::TreeIter& rRight){ + return ColCompareHdl(rLeft, rRight); + }); + rTreeView.set_selection_mode(SelectionMode::Multiple); Init(); UpdateView(); - SvTreeListEntry* pEntry=pTheView->First(); - if(pEntry!=nullptr) - { - pTheView->Select(pEntry); - } -} -ScAcceptChgDlg::~ScAcceptChgDlg() -{ - disposeOnce(); + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + if (rTreeView.get_iter_first(*xEntry)) + rTreeView.select(*xEntry); } -void ScAcceptChgDlg::dispose() +ScAcceptChgDlg::~ScAcceptChgDlg() { ClearView(); ScChangeTrack* pChanges=pDoc->GetChangeTrack(); - if(pChanges!=nullptr) + if (pChanges) { Link<ScChangeTrack&,void> aLink; pChanges->SetModifiedLink(aLink); } - - m_xPopup.clear(); - m_pAcceptChgCtr.disposeAndClear(); - pTPFilter.clear(); - pTPView.clear(); - pTheView.clear(); - SfxModelessDialog::dispose(); } void ScAcceptChgDlg::ReInit(ScViewData* ptrViewData) { pViewData=ptrViewData; - if(pViewData!=nullptr) + if (pViewData) pDoc=ptrViewData->GetDocument(); else pDoc=nullptr; @@ -212,10 +200,22 @@ void ScAcceptChgDlg::Init() aChangeViewSet.AdjustDateMode( *pDoc ); pTPFilter->CheckDate(aChangeViewSet.HasDate()); - pTPFilter->SetFirstDate(aChangeViewSet.GetTheFirstDateTime()); - pTPFilter->SetFirstTime(aChangeViewSet.GetTheFirstDateTime()); - pTPFilter->SetLastDate(aChangeViewSet.GetTheLastDateTime()); - pTPFilter->SetLastTime(aChangeViewSet.GetTheLastDateTime()); + + DateTime aEmpty(DateTime::EMPTY); + + DateTime aDateTime(aChangeViewSet.GetTheFirstDateTime()); + if (aDateTime != aEmpty) + { + pTPFilter->SetFirstDate(aDateTime); + pTPFilter->SetFirstTime(aDateTime); + } + aDateTime = aChangeViewSet.GetTheLastDateTime(); + if (aDateTime != aEmpty) + { + pTPFilter->SetLastDate(aDateTime); + pTPFilter->SetLastTime(aDateTime); + } + pTPFilter->SetDateMode(static_cast<sal_uInt16>(aChangeViewSet.GetTheDateMode())); pTPFilter->CheckComment(aChangeViewSet.HasComment()); pTPFilter->SetComment(aChangeViewSet.GetTheComment()); @@ -273,10 +273,10 @@ void ScAcceptChgDlg::ClearView() { nAcceptCount=0; nRejectCount=0; - pTheView->SetUpdateMode(false); - - pTheView->Clear(); - pTheView->SetUpdateMode(true); + weld::TreeView& rTreeView = pTheView->GetWidget(); + rTreeView.freeze(); + rTreeView.clear(); + rTreeView.thaw(); } OUString* ScAcceptChgDlg::MakeTypeString(ScChangeActionType eType) @@ -348,16 +348,14 @@ bool ScAcceptChgDlg::IsValidAction(const ScChangeAction* pScChangeAction) return bFlag; } -SvTreeListEntry* ScAcceptChgDlg::AppendChangeAction( - const ScChangeAction* pScChangeAction, - SvTreeListEntry* pParent, bool bDelMaster,bool bDisabled) +std::unique_ptr<weld::TreeIter> ScAcceptChgDlg::AppendChangeAction( + const ScChangeAction* pScChangeAction, bool bCreateOnDemand, + const weld::TreeIter* pParent, bool bDelMaster, bool bDisabled) { ScChangeTrack* pChanges=pDoc->GetChangeTrack(); if(pScChangeAction==nullptr || pChanges==nullptr) return nullptr; - SvTreeListEntry* pEntry=nullptr; - bool bFlag = false; ScRange aRef=pScChangeAction->GetBigRange().MakeRange(); @@ -470,47 +468,44 @@ SvTreeListEntry* ScAcceptChgDlg::AppendChangeAction( } } - if(!bFlag&& bUseColor&& pParent==nullptr) + weld::TreeView& rTreeView = pTheView->GetWidget(); + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + OUString sString(aBuf.makeStringAndClear()); + OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pNewData.release()))); + rTreeView.insert(pParent, -1, &sString, &sId, nullptr, nullptr, nullptr, bCreateOnDemand, xEntry.get()); + if (!bFlag && bUseColor && !pParent) { - pEntry = pTheView->InsertEntry( - aBuf.makeStringAndClear(), std::move(pNewData), COL_LIGHTBLUE, pParent, TREELIST_APPEND); + rTreeView.set_font_color(*xEntry, COL_LIGHTBLUE); } - else if(bFlag&& bUseColor&& pParent!=nullptr) + else if (bFlag && bUseColor && pParent) { - pEntry = pTheView->InsertEntry( - aBuf.makeStringAndClear(), std::move(pNewData), COL_GREEN, pParent, TREELIST_APPEND); - SvTreeListEntry* pExpEntry=pParent; + rTreeView.set_font_color(*xEntry, COL_GREEN); - while(pExpEntry!=nullptr && !pTheView->IsExpanded(pExpEntry)) - { - SvTreeListEntry* pTmpEntry=pTheView->GetParent(pExpEntry); + std::unique_ptr<weld::TreeIter> xExpEntry(rTreeView.make_iterator(pParent)); - if(pTmpEntry!=nullptr) pTheView->Expand(pExpEntry); + while (!rTreeView.get_row_expanded(*xExpEntry)) + { + if (rTreeView.get_iter_depth(*xExpEntry)) + rTreeView.expand_row(*xExpEntry); - pExpEntry=pTmpEntry; + if (!rTreeView.iter_parent(*xExpEntry)) + break; } } - else - { - pEntry = pTheView->InsertEntry( - aBuf.makeStringAndClear(), std::move(pNewData), pParent, TREELIST_APPEND); - } - return pEntry; + return xEntry; } -SvTreeListEntry* ScAcceptChgDlg::AppendFilteredAction( +std::unique_ptr<weld::TreeIter> ScAcceptChgDlg::AppendFilteredAction( const ScChangeAction* pScChangeAction, ScChangeActionState eState, - SvTreeListEntry* pParent, bool bDelMaster, bool bDisabled) + bool bCreateOnDemand, + const weld::TreeIter* pParent, bool bDelMaster, bool bDisabled) { - ScChangeTrack* pChanges=pDoc->GetChangeTrack(); if(pScChangeAction==nullptr || pChanges==nullptr) return nullptr; bool bIsGenerated = pChanges->IsGenerated(pScChangeAction->GetActionNumber()); - SvTreeListEntry* pEntry=nullptr; - bool bFlag = false; ScRange aRef=pScChangeAction->GetBigRange().MakeRange(); @@ -536,12 +531,11 @@ SvTreeListEntry* ScAcceptChgDlg::AppendFilteredAction( bFlag = true; } + std::unique_ptr<weld::TreeIter> xEntry; if(bFlag) { - - OUString aRefStr; ScChangeActionType eType=pScChangeAction->GetType(); - OUString aString; + OUString aActionString; OUString aDesc; std::unique_ptr<ScRedlinData> pNewData(new ScRedlinData); @@ -559,20 +553,20 @@ SvTreeListEntry* ScAcceptChgDlg::AppendFilteredAction( { if(pScChangeAction->IsDialogParent()) { - aString=aStrContentWithChild; + aActionString=aStrContentWithChild; pNewData->nInfo=RD_SPECIAL_VISCONTENT; pNewData->bIsRejectable=false; pNewData->bIsAcceptable=false; } else { - aString=*MakeTypeString(eType); + aActionString=*MakeTypeString(eType); pScChangeAction->GetDescription( aDesc, pDoc, true); } } else { - aString=*MakeTypeString(eType); + aActionString=*MakeTypeString(eType); if(bDelMaster) { @@ -585,45 +579,40 @@ SvTreeListEntry* ScAcceptChgDlg::AppendFilteredAction( } - aString += "\t"; - pScChangeAction->GetRefString(aRefStr, pDoc, true); - aString += aRefStr + "\t"; - - if(!bIsGenerated) - { - aString += aUser - + "\t" - + ScGlobal::pLocaleData->getDate(aDateTime) - + " " - + ScGlobal::pLocaleData->getTime(aDateTime) - + "\t"; - } - else - { - aString += "\t"; - aString += "\t"; - } OUString aComment = pScChangeAction->GetComment().replaceAll("\n", ""); - if (!aDesc.isEmpty()) { aComment += " (" + aDesc + ")"; } if (pTheView->IsValidComment(aComment)) { - aString+=aComment; - pEntry=pTheView->InsertEntry(aString,std::move(pNewData),pParent,TREELIST_APPEND); + weld::TreeView& rTreeView = pTheView->GetWidget(); + xEntry = rTreeView.make_iterator(); + OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pNewData.release()))); + rTreeView.insert(pParent, -1, &aActionString, &sId, nullptr, nullptr, nullptr, bCreateOnDemand, xEntry.get()); + + OUString aRefStr; + pScChangeAction->GetRefString(aRefStr, pDoc, true); + rTreeView.set_text(*xEntry, aRefStr, 1); + + if (!bIsGenerated) + { + rTreeView.set_text(*xEntry, aUser, 2); + OUString sDate = ScGlobal::pLocaleData->getDate(aDateTime) + " " + ScGlobal::pLocaleData->getTime(aDateTime); + rTreeView.set_text(*xEntry, sDate, 3); + } + + rTreeView.set_text(*xEntry, aComment, 4); } } - return pEntry; + return xEntry; } -SvTreeListEntry* ScAcceptChgDlg::InsertChangeActionContent(const ScChangeActionContent* pScChangeAction, - SvTreeListEntry* pParent, sal_uLong nSpecial) +std::unique_ptr<weld::TreeIter> ScAcceptChgDlg::InsertChangeActionContent(const ScChangeActionContent* pScChangeAction, + const weld::TreeIter& rParent, sal_uLong nSpecial) { ScChangeTrack* pChanges=pDoc->GetChangeTrack(); - SvTreeListEntry* pEntry=nullptr; if(pScChangeAction==nullptr || pChanges==nullptr) return nullptr; @@ -727,23 +716,27 @@ SvTreeListEntry* ScAcceptChgDlg::InsertChangeActionContent(const ScChangeActionC pNewData->nCol = aRef.aStart.Col(); pNewData->nTable= aRef.aStart.Tab(); + weld::TreeView& rTreeView = pTheView->GetWidget(); + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pNewData.release()))); + rTreeView.insert(&rParent, -1, &aString, &sId, nullptr, nullptr, nullptr, false, xEntry.get()); if (pTheView->IsValidComment(aComment) && bFlag) - { bHasFilterEntry=true; - pEntry=pTheView->InsertEntry(aString,std::move(pNewData),pParent); - } else - pEntry=pTheView->InsertEntry(aString,std::move(pNewData),COL_LIGHTBLUE,pParent); - return pEntry; + { + rTreeView.set_font_color(*xEntry, COL_LIGHTBLUE); + } + return xEntry; } void ScAcceptChgDlg::UpdateView() { - SvTreeListEntry* pParent=nullptr; + std::unique_ptr<weld::TreeIter> xParent; ScChangeTrack* pChanges=nullptr; const ScChangeAction* pScChangeAction=nullptr; - SetPointer(PointerStyle::Wait); - pTheView->SetUpdateMode(false); + m_xDialog->set_busy_cursor(true); + weld::TreeView& rTreeView = pTheView->GetWidget(); + rTreeView.freeze(); bool bFilterFlag = pTPFilter->IsDate() || pTPFilter->IsRange() || pTPFilter->IsAuthor() || pTPFilter->IsComment(); @@ -760,45 +753,41 @@ void ScAcceptChgDlg::UpdateView() while(pScChangeAction!=nullptr) { bHasFilterEntry=false; - switch(pScChangeAction->GetState()) + switch (pScChangeAction->GetState()) { case SC_CAS_VIRGIN: - if(pScChangeAction->IsDialogRoot()) + if (pScChangeAction->IsDialogRoot()) { - if(pScChangeAction->IsDialogParent()) - pParent=AppendChangeAction(pScChangeAction); + bool bOnDemandChildren = !bFilterFlag && pScChangeAction->IsDialogParent(); + if (pScChangeAction->IsDialogParent()) + xParent = AppendChangeAction(pScChangeAction, bOnDemandChildren); else - pParent=AppendFilteredAction(pScChangeAction,SC_CAS_VIRGIN); + xParent = AppendFilteredAction(pScChangeAction, SC_CAS_VIRGIN, bOnDemandChildren); } else - pParent=nullptr; + xParent.reset(); bTheFlag=true; break; case SC_CAS_ACCEPTED: - pParent=nullptr; + xParent.reset(); nAcceptCount++; break; case SC_CAS_REJECTED: - pParent=nullptr; + xParent.reset(); nRejectCount++; break; } - if(pParent!=nullptr && pScChangeAction->IsDialogParent()) + if (xParent && pScChangeAction->IsDialogParent() && bFilterFlag) { - if(!bFilterFlag) - pParent->EnableChildrenOnDemand(); - else - { - bool bTestFlag = bHasFilterEntry; - bHasFilterEntry=false; - if(Expand(pChanges,pScChangeAction,pParent,!bTestFlag)&&!bTestFlag) - pTheView->RemoveEntry(pParent); - } + bool bTestFlag = bHasFilterEntry; + bHasFilterEntry=false; + if (Expand(pChanges, pScChangeAction, *xParent, !bTestFlag) && !bTestFlag) + rTreeView.remove(*xParent); } pScChangeAction=pScChangeAction->GetNext(); @@ -812,33 +801,21 @@ void ScAcceptChgDlg::UpdateView() pTPView->EnableReject(bTheFlag); pTPView->EnableRejectAll(bTheFlag); - if(nAcceptCount>0) - { - pParent=pTheView->InsertEntry( - aStrAllAccepted, std::unique_ptr<RedlinData>(), - static_cast< SvTreeListEntry * >(nullptr)); - pParent->EnableChildrenOnDemand(); - } - if(nRejectCount>0) - { - pParent=pTheView->InsertEntry( - aStrAllRejected, std::unique_ptr<RedlinData>(), - static_cast< SvTreeListEntry * >(nullptr)); - pParent->EnableChildrenOnDemand(); - } - pTheView->SetUpdateMode(true); - SetPointer(PointerStyle::Arrow); - SvTreeListEntry* pEntry=pTheView->First(); - if(pEntry!=nullptr) - pTheView->Select(pEntry); + if (nAcceptCount>0) + rTreeView.insert(nullptr, -1, &aStrAllAccepted, nullptr, nullptr, nullptr, nullptr, true, nullptr); + if (nRejectCount>0) + rTreeView.insert(nullptr, -1, &aStrAllRejected, nullptr, nullptr, nullptr, nullptr, true, nullptr); + rTreeView.thaw(); + m_xDialog->set_busy_cursor(false); + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + if (rTreeView.get_iter_first(*xEntry)) + rTreeView.select(*xEntry); } IMPL_LINK_NOARG(ScAcceptChgDlg, RefHandle, SvxTPFilter*, void) { sal_uInt16 nId =ScSimpleRefDlgWrapper::GetChildWindowId(); - ScSimpleRefDlgWrapper::SetDefaultPosSize(GetPosPixel(),GetSizePixel()); - SC_MOD()->SetRefDialog( nId, true ); SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); @@ -851,44 +828,30 @@ IMPL_LINK_NOARG(ScAcceptChgDlg, RefHandle, SvxTPFilter*, void) pWnd->SetCloseHdl(LINK( this, ScAcceptChgDlg,RefInfoHandle)); pWnd->SetRefString(pTPFilter->GetRange()); ScSimpleRefDlgWrapper::SetAutoReOpen(false); - vcl::Window* pWin=pWnd->GetWindow(); - pWin->SetPosSizePixel(GetPosPixel(),GetSizePixel()); - Hide(); - pWin->SetText(GetText()); + auto xWin = pWnd->GetController(); + m_xDialog->hide(); + xWin->set_title(m_xDialog->get_title()); pWnd->StartRefInput(); } } IMPL_LINK( ScAcceptChgDlg, RefInfoHandle, const OUString*, pResult, void) { - sal_uInt16 nId; + sal_uInt16 nId = ScAcceptChgDlgWrapper::GetChildWindowId(); ScSimpleRefDlgWrapper::SetAutoReOpen(true); SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); - if(pResult!=nullptr) + if (pResult) { pTPFilter->SetRange(*pResult); FilterHandle(pTPFilter); - nId = ScSimpleRefDlgWrapper::GetChildWindowId(); - ScSimpleRefDlgWrapper* pWnd = static_cast<ScSimpleRefDlgWrapper*>(pViewFrm->GetChildWindow( nId )); - - if(pWnd!=nullptr) - { - vcl::Window* pWin=pWnd->GetWindow(); - Size aWinSize=pWin->GetSizePixel(); - aWinSize.setWidth(GetSizePixel().Width() ); - SetPosSizePixel(pWin->GetPosPixel(),aWinSize); - Invalidate(); - } - nId = ScAcceptChgDlgWrapper::GetChildWindowId(); - pViewFrm->ShowChildWindow( nId ); + pViewFrm->ShowChildWindow(nId); } else { - nId = ScAcceptChgDlgWrapper::GetChildWindowId(); - pViewFrm->SetChildWindow( nId, false ); + pViewFrm->SetChildWindow(nId, false); } } @@ -905,29 +868,25 @@ IMPL_LINK( ScAcceptChgDlg, FilterHandle, SvxTPFilter*, pRef, void ) IMPL_LINK( ScAcceptChgDlg, RejectHandle, SvxTPView*, pRef, void ) { - SetPointer(PointerStyle::Wait); + m_xDialog->set_busy_cursor(true); bIgnoreMsg=true; ScChangeTrack* pChanges=pDoc->GetChangeTrack(); if(pRef!=nullptr) { - SvTreeListEntry* pEntry=pTheView->FirstSelected(); - while(pEntry!=nullptr) - { - ScRedlinData *pEntryData=static_cast<ScRedlinData *>(pEntry->GetUserData()); - if(pEntryData!=nullptr) + weld::TreeView& rTreeView = pTheView->GetWidget(); + rTreeView.selected_foreach([this, pChanges, &rTreeView](weld::TreeIter& rEntry){ + ScRedlinData *pEntryData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(rEntry).toInt64()); + if (pEntryData) { - ScChangeAction* pScChangeAction= - static_cast<ScChangeAction*>(pEntryData->pData); - - if(pScChangeAction->GetType()==SC_CAT_INSERT_TABS) + ScChangeAction* pScChangeAction= static_cast<ScChangeAction*>(pEntryData->pData); + if (pScChangeAction->GetType()==SC_CAT_INSERT_TABS) pViewData->SetTabNo(0); - pChanges->Reject(pScChangeAction); } - pEntry = pTheView->NextSelected(pEntry); - } + return false; + }); ScDocShell* pDocSh=pViewData->GetDocShell(); pDocSh->PostPaintExtras(); pDocSh->PostPaintGridAll(); @@ -936,23 +895,23 @@ IMPL_LINK( ScAcceptChgDlg, RejectHandle, SvxTPView*, pRef, void ) ClearView(); UpdateView(); } - SetPointer(PointerStyle::Arrow); + + m_xDialog->set_busy_cursor(false); bIgnoreMsg=false; } IMPL_LINK( ScAcceptChgDlg, AcceptHandle, SvxTPView*, pRef, void ) { - SetPointer(PointerStyle::Wait); + m_xDialog->set_busy_cursor(true); ScChangeTrack* pChanges=pDoc->GetChangeTrack(); bIgnoreMsg=true; if(pRef!=nullptr) { - SvTreeListEntry* pEntry=pTheView->FirstSelected(); - while(pEntry!=nullptr) - { - ScRedlinData *pEntryData=static_cast<ScRedlinData *>(pEntry->GetUserData()); - if(pEntryData!=nullptr) + weld::TreeView& rTreeView = pTheView->GetWidget(); + rTreeView.selected_foreach([pChanges, &rTreeView](weld::TreeIter& rEntry) { + ScRedlinData *pEntryData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(rEntry).toInt64()); + if (pEntryData) { ScChangeAction* pScChangeAction= static_cast<ScChangeAction*>(pEntryData->pData); @@ -966,8 +925,8 @@ IMPL_LINK( ScAcceptChgDlg, AcceptHandle, SvxTPView*, pRef, void ) else pChanges->Accept(pScChangeAction); } - pEntry = pTheView->NextSelected(pEntry); - } + return false; + }); ScDocShell* pDocSh=pViewData->GetDocShell(); pDocSh->PostPaintExtras(); pDocSh->PostPaintGridAll(); @@ -975,7 +934,7 @@ IMPL_LINK( ScAcceptChgDlg, AcceptHandle, SvxTPView*, pRef, void ) ClearView(); UpdateView(); } - SetPointer(PointerStyle::Arrow); + m_xDialog->set_busy_cursor(false); bIgnoreMsg=false; } @@ -1020,7 +979,7 @@ void ScAcceptChgDlg::AcceptFiltered() IMPL_LINK_NOARG(ScAcceptChgDlg, RejectAllHandle, SvxTPView*, void) { - SetPointer(PointerStyle::Wait); + m_xDialog->set_busy_cursor(true); bIgnoreMsg=true; ScChangeTrack* pChanges=pDoc->GetChangeTrack(); if(pChanges!=nullptr) @@ -1040,14 +999,14 @@ IMPL_LINK_NOARG(ScAcceptChgDlg, RejectAllHandle, SvxTPView*, void) ClearView(); UpdateView(); } - SetPointer(PointerStyle::Arrow); + m_xDialog->set_busy_cursor(false); bIgnoreMsg=false; } IMPL_LINK_NOARG(ScAcceptChgDlg, AcceptAllHandle, SvxTPView*, void) { - SetPointer(PointerStyle::Wait); + m_xDialog->set_busy_cursor(true); bIgnoreMsg=true; ScChangeTrack* pChanges=pDoc->GetChangeTrack(); @@ -1066,27 +1025,29 @@ IMPL_LINK_NOARG(ScAcceptChgDlg, AcceptAllHandle, SvxTPView*, void) UpdateView(); } bIgnoreMsg=false; - SetPointer(PointerStyle::Arrow); + + m_xDialog->set_busy_cursor(false); } -IMPL_LINK_NOARG(ScAcceptChgDlg, SelectHandle, SvTreeListBox*, void) +IMPL_LINK_NOARG(ScAcceptChgDlg, SelectHandle, weld::TreeView&, void) { - if(!bNoSelection) + if (!bNoSelection) aSelectionIdle.Start(); bNoSelection=false; } -void ScAcceptChgDlg::GetDependents( const ScChangeAction* pScChangeAction, - ScChangeActionMap& aActionMap, - SvTreeListEntry* pEntry) +void ScAcceptChgDlg::GetDependents(const ScChangeAction* pScChangeAction, + ScChangeActionMap& aActionMap, + const weld::TreeIter& rEntry) { ScChangeTrack* pChanges=pDoc->GetChangeTrack(); - SvTreeListEntry* pParent=pTheView->GetParent(pEntry); - if(pParent!=nullptr) + weld::TreeView& rTreeView = pTheView->GetWidget(); + std::unique_ptr<weld::TreeIter> xParent(rTreeView.make_iterator(&rEntry)); + if (rTreeView.iter_parent(*xParent)) { - ScRedlinData *pParentData=static_cast<ScRedlinData *>(pParent->GetUserData()); + ScRedlinData *pParentData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(*xParent).toInt64()); ScChangeAction* pParentAction=static_cast<ScChangeAction*>(pParentData->pData); if(pParentAction!=pScChangeAction) @@ -1101,10 +1062,11 @@ void ScAcceptChgDlg::GetDependents( const ScChangeAction* pScChangeAction, aActionMap, pScChangeAction->IsMasterDelete() ); } -bool ScAcceptChgDlg::InsertContentChildren(ScChangeActionMap* pActionMap,SvTreeListEntry* pParent) +bool ScAcceptChgDlg::InsertContentChildren(ScChangeActionMap* pActionMap, const weld::TreeIter& rParent) { bool bTheTestFlag = true; - ScRedlinData *pEntryData=static_cast<ScRedlinData *>(pParent->GetUserData()); + weld::TreeView& rTreeView = pTheView->GetWidget(); + ScRedlinData *pEntryData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(rParent).toInt64()); const ScChangeAction* pScChangeAction = static_cast<ScChangeAction*>(pEntryData->pData); bool bParentInserted = false; // If the parent is a MatrixOrigin then place it in the right order before @@ -1119,7 +1081,6 @@ bool ScAcceptChgDlg::InsertContentChildren(ScChangeActionMap* pActionMap,SvTreeL const_cast<ScChangeAction*>( pScChangeAction ) ) ); bParentInserted = true; } - SvTreeListEntry* pEntry=nullptr; ScChangeActionMap::iterator itChangeAction = std::find_if(pActionMap->begin(), pActionMap->end(), [](const std::pair<sal_uLong, ScChangeAction*>& rEntry) { return rEntry.second->GetState() == SC_CAS_VIRGIN; }); @@ -1127,14 +1088,14 @@ bool ScAcceptChgDlg::InsertContentChildren(ScChangeActionMap* pActionMap,SvTreeL if( itChangeAction == pActionMap->end() ) return true; - SvTreeListEntry* pOriginal = InsertChangeActionContent( + std::unique_ptr<weld::TreeIter> xOriginal = InsertChangeActionContent( dynamic_cast<const ScChangeActionContent*>( itChangeAction->second ), - pParent, RD_SPECIAL_CONTENT ); + rParent, RD_SPECIAL_CONTENT ); - if(pOriginal!=nullptr) + if (xOriginal) { bTheTestFlag=false; - ScRedlinData *pParentData=static_cast<ScRedlinData *>(pOriginal->GetUserData()); + ScRedlinData *pParentData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(*xOriginal).toInt64()); pParentData->pData=const_cast<ScChangeAction *>(pScChangeAction); pParentData->nActionNo=pScChangeAction->GetActionNumber(); pParentData->bIsAcceptable=pScChangeAction->IsRejectable(); // select old value @@ -1145,10 +1106,11 @@ bool ScAcceptChgDlg::InsertContentChildren(ScChangeActionMap* pActionMap,SvTreeL { if( itChangeAction->second->GetState() == SC_CAS_VIRGIN ) { - pEntry = InsertChangeActionContent( dynamic_cast<const ScChangeActionContent*>( itChangeAction->second ), - pParent, RD_SPECIAL_NONE ); + std::unique_ptr<weld::TreeIter> xEntry = + InsertChangeActionContent( dynamic_cast<const ScChangeActionContent*>( itChangeAction->second ), + rParent, RD_SPECIAL_NONE ); - if(pEntry!=nullptr) + if (xEntry) bTheTestFlag=false; } ++itChangeAction; @@ -1156,13 +1118,14 @@ bool ScAcceptChgDlg::InsertContentChildren(ScChangeActionMap* pActionMap,SvTreeL if ( !bParentInserted ) { - pEntry=InsertChangeActionContent(static_cast<const ScChangeActionContent*>( - pScChangeAction),pParent,RD_SPECIAL_NONE); + std::unique_ptr<weld::TreeIter> xEntry = + InsertChangeActionContent(static_cast<const ScChangeActionContent*>( + pScChangeAction),rParent,RD_SPECIAL_NONE); - if(pEntry!=nullptr) + if (xEntry) { bTheTestFlag=false; - ScRedlinData *pParentData=static_cast<ScRedlinData *>(pEntry->GetUserData()); + ScRedlinData *pParentData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(*xEntry).toInt64()); pParentData->pData=const_cast<ScChangeAction *>(pScChangeAction); pParentData->nActionNo=pScChangeAction->GetActionNumber(); pParentData->bIsAcceptable=pScChangeAction->IsClickable(); @@ -1172,16 +1135,16 @@ bool ScAcceptChgDlg::InsertContentChildren(ScChangeActionMap* pActionMap,SvTreeL } return bTheTestFlag; - } -bool ScAcceptChgDlg::InsertAcceptedORejected(SvTreeListEntry* pParent) +bool ScAcceptChgDlg::InsertAcceptedORejected(const weld::TreeIter& rParent) { ScChangeTrack* pChanges=pDoc->GetChangeTrack(); bool bTheTestFlag = true; ScChangeActionState eState = SC_CAS_VIRGIN; - OUString aString = pTheView->GetEntryText(pParent); + weld::TreeView& rTreeView = pTheView->GetWidget(); + OUString aString = rTreeView.get_text(rParent, 0); OUString a2String = aString.copy(0, aStrAllAccepted.getLength()); if (a2String == aStrAllAccepted) eState=SC_CAS_ACCEPTED; @@ -1192,90 +1155,91 @@ bool ScAcceptChgDlg::InsertAcceptedORejected(SvTreeListEntry* pParent) eState=SC_CAS_REJECTED; } - ScChangeAction* pScChangeAction=pChanges->GetFirst(); - while(pScChangeAction!=nullptr) + ScChangeAction* pScChangeAction = pChanges->GetFirst(); + while (pScChangeAction) { - if(pScChangeAction->GetState()==eState && - AppendFilteredAction(pScChangeAction,eState,pParent)!=nullptr) + if (pScChangeAction->GetState()==eState && + AppendFilteredAction(pScChangeAction, eState, false, &rParent)) bTheTestFlag=false; pScChangeAction=pScChangeAction->GetNext(); } return bTheTestFlag; } -bool ScAcceptChgDlg::InsertChildren(ScChangeActionMap* pActionMap,SvTreeListEntry* pParent) +bool ScAcceptChgDlg::InsertChildren(ScChangeActionMap* pActionMap, const weld::TreeIter& rParent) { ScChangeTrack* pChanges=pDoc->GetChangeTrack(); bool bTheTestFlag = true; for( const auto& rChangeAction : *pActionMap ) { - SvTreeListEntry* pEntry=AppendChangeAction( rChangeAction.second, pParent, false, true ); + std::unique_ptr<weld::TreeIter> xEntry = AppendChangeAction(rChangeAction.second, false, &rParent, false, true); - if(pEntry!=nullptr) + if (xEntry) { bTheTestFlag=false; - ScRedlinData *pEntryData=static_cast<ScRedlinData *>(pEntry->GetUserData()); + weld::TreeView& rTreeView = pTheView->GetWidget(); + ScRedlinData *pEntryData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(*xEntry).toInt64()); pEntryData->bIsRejectable=false; pEntryData->bIsAcceptable=false; pEntryData->bDisabled=true; - if( rChangeAction.second->IsDialogParent() ) - Expand( pChanges, rChangeAction.second, pEntry ); + if (rChangeAction.second->IsDialogParent()) + Expand(pChanges, rChangeAction.second, *xEntry); } } return bTheTestFlag; } bool ScAcceptChgDlg::InsertDeletedChildren(const ScChangeAction* pScChangeAction, - ScChangeActionMap* pActionMap,SvTreeListEntry* pParent) + ScChangeActionMap* pActionMap, const weld::TreeIter& rParent) { ScChangeTrack* pChanges=pDoc->GetChangeTrack(); bool bTheTestFlag = true; - SvTreeListEntry* pEntry=nullptr; + std::unique_ptr<weld::TreeIter> xEntry; for( const auto& rChangeAction : *pActionMap ) { if( pScChangeAction != rChangeAction.second ) - pEntry = AppendChangeAction( rChangeAction.second, pParent, false, true ); + xEntry = AppendChangeAction(rChangeAction.second, false, &rParent, false, true); else - pEntry = AppendChangeAction( rChangeAction.second, pParent, true, true ); + xEntry = AppendChangeAction(rChangeAction.second, false, &rParent, true, true); - if(pEntry!=nullptr) + if (xEntry) { - ScRedlinData *pEntryData=static_cast<ScRedlinData *>(pEntry->GetUserData()); + weld::TreeView& rTreeView = pTheView->GetWidget(); + ScRedlinData *pEntryData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(*xEntry).toInt64()); pEntryData->bIsRejectable=false; pEntryData->bIsAcceptable=false; pEntryData->bDisabled=true; bTheTestFlag=false; - if( rChangeAction.second->IsDialogParent() ) - Expand( pChanges, rChangeAction.second, pEntry ); + if (rChangeAction.second->IsDialogParent()) + Expand(pChanges, rChangeAction.second, *xEntry); } } return bTheTestFlag; } -bool ScAcceptChgDlg::Expand( - const ScChangeTrack* pChanges, const ScChangeAction* pScChangeAction, - SvTreeListEntry* pEntry, bool bFilter) +bool ScAcceptChgDlg::Expand(const ScChangeTrack* pChanges, const ScChangeAction* pScChangeAction, + const weld::TreeIter& rEntry, bool bFilter) { bool bTheTestFlag = true; - if(pChanges!=nullptr &&pEntry!=nullptr &&pScChangeAction!=nullptr) + if (pChanges && pScChangeAction) { ScChangeActionMap aActionMap; - GetDependents( pScChangeAction, aActionMap, pEntry ); + GetDependents(pScChangeAction, aActionMap, rEntry); switch(pScChangeAction->GetType()) { case SC_CAT_CONTENT: { - InsertContentChildren( &aActionMap, pEntry ); + InsertContentChildren(&aActionMap, rEntry); bTheTestFlag=!bHasFilterEntry; break; } @@ -1283,14 +1247,14 @@ bool ScAcceptChgDlg::Expand( case SC_CAT_DELETE_ROWS: case SC_CAT_DELETE_TABS: { - InsertDeletedChildren( pScChangeAction, &aActionMap, pEntry ); + InsertDeletedChildren(pScChangeAction, &aActionMap, rEntry); bTheTestFlag=!bHasFilterEntry; break; } default: { if(!bFilter) - bTheTestFlag = InsertChildren( &aActionMap, pEntry ); + bTheTestFlag = InsertChildren(&aActionMap, rEntry); break; } } @@ -1299,65 +1263,61 @@ bool ScAcceptChgDlg::Expand( return bTheTestFlag; } -IMPL_LINK( ScAcceptChgDlg, ExpandingHandle, SvTreeListBox*, pTable, bool ) +IMPL_LINK(ScAcceptChgDlg, ExpandingHandle, const weld::TreeIter&, rEntry, bool) { ScChangeTrack* pChanges=pDoc->GetChangeTrack(); - SetPointer(PointerStyle::Wait); - if(pTable!=nullptr && pChanges!=nullptr) + if (pChanges) { + m_xDialog->set_busy_cursor(true); ScChangeActionMap aActionMap; - SvTreeListEntry* pEntry=pTheView->GetHdlEntry(); - if(pEntry!=nullptr) + weld::TreeView& rTreeView = pTheView->GetWidget(); + ScRedlinData *pEntryData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(rEntry).toInt64()); + if (!rTreeView.iter_has_child(rEntry)) { - ScRedlinData *pEntryData=static_cast<ScRedlinData *>(pEntry->GetUserData()); + bool bTheTestFlag = true; - if(pEntry->HasChildrenOnDemand()) + if (pEntryData) { - bool bTheTestFlag = true; - pEntry->EnableChildrenOnDemand(false); - SvTreeListEntry* pChildEntry = pTheView->FirstChild(pEntry); - if (pChildEntry) - pTheView->RemoveEntry(pChildEntry); - - if(pEntryData!=nullptr) - { - ScChangeAction* pScChangeAction=static_cast<ScChangeAction*>(pEntryData->pData); + ScChangeAction* pScChangeAction=static_cast<ScChangeAction*>(pEntryData->pData); - GetDependents( pScChangeAction, aActionMap, pEntry ); + GetDependents(pScChangeAction, aActionMap, rEntry); - switch(pScChangeAction->GetType()) + switch (pScChangeAction->GetType()) + { + case SC_CAT_CONTENT: { - case SC_CAT_CONTENT: - { - bTheTestFlag = InsertContentChildren( &aActionMap, pEntry ); - break; - } - case SC_CAT_DELETE_COLS: - case SC_CAT_DELETE_ROWS: - case SC_CAT_DELETE_TABS: - { - bTheTestFlag = InsertDeletedChildren( pScChangeAction, &aActionMap, pEntry ); - break; - } - default: - { - bTheTestFlag = InsertChildren( &aActionMap, pEntry ); - break; - } + bTheTestFlag = InsertContentChildren( &aActionMap, rEntry ); + break; + } + case SC_CAT_DELETE_COLS: + case SC_CAT_DELETE_ROWS: + case SC_CAT_DELETE_TABS: + { + bTheTestFlag = InsertDeletedChildren( pScChangeAction, &aActionMap, rEntry ); + break; + } + default: + { + bTheTestFlag = InsertChildren( &aActionMap, rEntry ); + break; } - aActionMap.clear(); - - } - else - { - bTheTestFlag=InsertAcceptedORejected(pEntry); } - if(bTheTestFlag) pTheView->InsertEntry(aStrNoEntry,nullptr,COL_GRAY,pEntry); - } + aActionMap.clear(); + } + else + { + bTheTestFlag = InsertAcceptedORejected(rEntry); + } + if (bTheTestFlag) + { + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + rTreeView.insert(&rEntry, -1, &aStrNoEntry, nullptr, nullptr, nullptr, nullptr, false, xEntry.get()); + rTreeView.set_font_color(*xEntry, COL_GRAY); + } } + m_xDialog->set_busy_cursor(false); } - SetPointer(PointerStyle::Arrow); return true; } @@ -1366,9 +1326,10 @@ void ScAcceptChgDlg::AppendChanges(const ScChangeTrack* pChanges,sal_uLong nStar { if(pChanges!=nullptr) { - SvTreeListEntry* pParent=nullptr; - SetPointer(PointerStyle::Wait); - pTheView->SetUpdateMode(false); + std::unique_ptr<weld::TreeIter> xParent; + m_xDialog->set_busy_cursor(true); + weld::TreeView& rTreeView = pTheView->GetWidget(); + rTreeView.freeze(); bool bTheFlag = false; @@ -1382,45 +1343,41 @@ void ScAcceptChgDlg::AppendChanges(const ScChangeTrack* pChanges,sal_uLong nStar const ScChangeAction* pScChangeAction=pChanges->GetAction(i); if(pScChangeAction==nullptr) continue; - switch(pScChangeAction->GetState()) + switch (pScChangeAction->GetState()) { case SC_CAS_VIRGIN: - if(pScChangeAction->IsDialogRoot()) + if (pScChangeAction->IsDialogRoot()) { - if(pScChangeAction->IsDialogParent()) - pParent=AppendChangeAction(pScChangeAction); + bool bOnDemandChildren = !bFilterFlag && pScChangeAction->IsDialogParent(); + if (pScChangeAction->IsDialogParent()) + xParent = AppendChangeAction(pScChangeAction, bOnDemandChildren); else - pParent=AppendFilteredAction(pScChangeAction,SC_CAS_VIRGIN); + xParent = AppendFilteredAction(pScChangeAction, SC_CAS_VIRGIN, bOnDemandChildren); } else - pParent=nullptr; + xParent.reset(); bTheFlag=true; break; case SC_CAS_ACCEPTED: - pParent=nullptr; + xParent.reset(); nAcceptCount++; break; case SC_CAS_REJECTED: - pParent=nullptr; + xParent.reset(); nRejectCount++; break; } - if(pParent!=nullptr && pScChangeAction->IsDialogParent()) + if (xParent && pScChangeAction->IsDialogParent() && bFilterFlag) { - if(!bFilterFlag) - pParent->EnableChildrenOnDemand(); - else - { - bool bTestFlag = bHasFilterEntry; - bHasFilterEntry = false; - if(Expand(pChanges,pScChangeAction,pParent,!bTestFlag)&&!bTestFlag) - pTheView->RemoveEntry(pParent); - } + bool bTestFlag = bHasFilterEntry; + bHasFilterEntry = false; + if (Expand(pChanges,pScChangeAction,*xParent,!bTestFlag)&&!bTestFlag) + rTreeView.remove(*xParent); } } @@ -1432,66 +1389,69 @@ void ScAcceptChgDlg::AppendChanges(const ScChangeTrack* pChanges,sal_uLong nStar pTPView->EnableReject(bTheFlag); pTPView->EnableRejectAll(bTheFlag); - pTheView->SetUpdateMode(true); - SetPointer(PointerStyle::Arrow); + rTreeView.thaw(); + m_xDialog->set_busy_cursor(false); } } void ScAcceptChgDlg::RemoveEntries(sal_uLong nStartAction,sal_uLong nEndAction) { - - pTheView->SetUpdateMode(false); - - SvTreeListEntry* pEntry=pTheView->GetCurEntry(); + weld::TreeView& rTreeView = pTheView->GetWidget(); + rTreeView.freeze(); ScRedlinData *pEntryData=nullptr; + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + if (rTreeView.get_cursor(xEntry.get())) + pEntryData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(*xEntry).toInt64()); - if(pEntry!=nullptr) - pEntryData=static_cast<ScRedlinData *>(pEntry->GetUserData()); + rTreeView.get_iter_first(*xEntry); sal_uLong nAction=0; - if(pEntryData!=nullptr) + if (pEntryData) nAction=pEntryData->nActionNo; - if(nAction>=nStartAction && nAction<=nEndAction) - pTheView->SetCurEntry(pTheView->GetModel()->GetEntry(0)); + if (nAction>=nStartAction && nAction<=nEndAction) + rTreeView.set_cursor(*xEntry); + std::vector<OUString> aIdsToRemove; - // MUST do it backwards, don't delete parents before children and GPF - pEntry=pTheView->Last(); - while(pEntry!=nullptr) + do { - bool bRemove = false; - pEntryData=static_cast<ScRedlinData *>(pEntry->GetUserData()); - if(pEntryData!=nullptr) + OUString sId(rTreeView.get_id(*xEntry)); + pEntryData = reinterpret_cast<ScRedlinData *>(sId.toInt64()); + if (pEntryData) { - nAction=pEntryData->nActionNo; - - if(nStartAction<=nAction && nAction<=nEndAction) bRemove=true; - + nAction = pEntryData->nActionNo; + if (nStartAction <= nAction && nAction <= nEndAction) + aIdsToRemove.push_back(sId); } - SvTreeListEntry* pPrevEntry = pTheView->Prev(pEntry); - - if(bRemove) - pTheView->RemoveEntry(pEntry); - - pEntry=pPrevEntry; } - pTheView->SetUpdateMode(true); + while (rTreeView.iter_next(*xEntry)); + + // MUST do it backwards, don't delete parents before children and GPF + for (auto it = aIdsToRemove.rbegin(); it != aIdsToRemove.rend(); ++it) + rTreeView.remove_id(*it); + rTreeView.thaw(); } void ScAcceptChgDlg::UpdateEntries(const ScChangeTrack* pChgTrack, sal_uLong nStartAction,sal_uLong nEndAction) { - pTheView->SetUpdateMode(false); + weld::TreeView& rTreeView = pTheView->GetWidget(); + rTreeView.freeze(); + + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + std::unique_ptr<weld::TreeIter> xLastEntry(rTreeView.make_iterator()); + std::unique_ptr<weld::TreeIter> xNextEntry(rTreeView.make_iterator()); + + bool bEntry = rTreeView.get_iter_first(*xEntry); + bool bLastEntry = false; - SvTreeListEntry* pEntry=pTheView->First(); - SvTreeListEntry* pLastEntry=nullptr; - while(pEntry!=nullptr) + while (bEntry) { bool bRemove = false; - ScRedlinData *pEntryData=static_cast<ScRedlinData *>(pEntry->GetUserData()); - if(pEntryData!=nullptr) + ScRedlinData *pEntryData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(*xEntry).toInt64()); + if (pEntryData) { ScChangeAction* pScChangeAction= static_cast<ScChangeAction*>(pEntryData->pData); @@ -1501,37 +1461,42 @@ void ScAcceptChgDlg::UpdateEntries(const ScChangeTrack* pChgTrack, sal_uLong nSt if(nStartAction<=nAction && nAction<=nEndAction) bRemove=true; } - SvTreeListEntry* pNextEntry; - if(bRemove) + bool bNextEntry; + if (bRemove) { - pTheView->RemoveEntry(pEntry); + rTreeView.remove(*xEntry); - if(pLastEntry==nullptr) pLastEntry=pTheView->First(); - if(pLastEntry!=nullptr) + if (!bLastEntry) + bLastEntry = rTreeView.get_iter_first(*xLastEntry); + if (bLastEntry) { - pNextEntry=pTheView->Next(pLastEntry); - - if(pNextEntry==nullptr) + rTreeView.copy_iterator(*xLastEntry, *xNextEntry); + bNextEntry = rTreeView.iter_next(*xNextEntry); + if (!bNextEntry) { - pNextEntry=pLastEntry; - pLastEntry=nullptr; + rTreeView.copy_iterator(*xLastEntry, *xNextEntry); + bLastEntry = false; } } else - pNextEntry=nullptr; - + bNextEntry = false; } else { - pLastEntry = pEntry; - pNextEntry = pTheView->Next(pEntry); + rTreeView.copy_iterator(*xEntry, *xLastEntry); + bLastEntry = true; + + rTreeView.copy_iterator(*xEntry, *xNextEntry); + bNextEntry = rTreeView.iter_next(*xNextEntry); } - pEntry=pNextEntry; + + rTreeView.copy_iterator(*xNextEntry, *xEntry); + bEntry = bNextEntry; } AppendChanges(pChgTrack,nStartAction,nEndAction); - pTheView->SetUpdateMode(true); + rTreeView.thaw(); } IMPL_LINK( ScAcceptChgDlg, ChgTrackModHdl, ScChangeTrack&, rChgTrack, void) @@ -1569,10 +1534,11 @@ IMPL_LINK( ScAcceptChgDlg, ChgTrackModHdl, ScChangeTrack&, rChgTrack, void) aMsgQueue.clear(); } + IMPL_LINK_NOARG(ScAcceptChgDlg, ReOpenTimerHdl, Timer *, void) { ScSimpleRefDlgWrapper::SetAutoReOpen(true); - m_pAcceptChgCtr->ShowFilterPage(); + m_xAcceptChgCtr->ShowFilterPage(); RefHandle(nullptr); } @@ -1582,14 +1548,13 @@ IMPL_LINK_NOARG(ScAcceptChgDlg, UpdateSelectionHdl, Timer *, void) bool bAcceptFlag = true; bool bRejectFlag = true; - bool bContMark = false; pTabView->DoneBlockMode(); // clears old marking - SvTreeListEntry* pEntry = pTheView->FirstSelected(); - while( pEntry ) - { - ScRedlinData* pEntryData = static_cast<ScRedlinData*>(pEntry->GetUserData()); - if( pEntryData ) + weld::TreeView& rTreeView = pTheView->GetWidget(); + std::vector<const ScChangeAction*> aActions; + rTreeView.selected_foreach([&rTreeView, &bAcceptFlag, &bRejectFlag, &aActions](weld::TreeIter& rEntry){ + ScRedlinData* pEntryData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(rEntry).toInt64()); + if (pEntryData) { bRejectFlag &= pEntryData->bIsRejectable; bAcceptFlag &= pEntryData->bIsAcceptable; @@ -1598,13 +1563,7 @@ IMPL_LINK_NOARG(ScAcceptChgDlg, UpdateSelectionHdl, Timer *, void) if( pScChangeAction && (pScChangeAction->GetType() != SC_CAT_DELETE_TABS) && (!pEntryData->bDisabled || pScChangeAction->IsVisible()) ) { - const ScBigRange& rBigRange = pScChangeAction->GetBigRange(); - if( rBigRange.IsValid( pDoc ) && IsActive() ) - { - bool bSetCursor = !pTheView->NextSelected( pEntry ); - pTabView->MarkRange( rBigRange.MakeRange(), bSetCursor, bContMark ); - bContMark = true; - } + aActions.push_back(pScChangeAction); } } else @@ -1612,8 +1571,19 @@ IMPL_LINK_NOARG(ScAcceptChgDlg, UpdateSelectionHdl, Timer *, void) bAcceptFlag = false; bRejectFlag = false; } + return false; + }); - pEntry = pTheView->NextSelected( pEntry ); + bool bContMark = false; + for (size_t i = 0, nCount = aActions.size(); i < nCount; ++i) + { + const ScBigRange& rBigRange = aActions[i]->GetBigRange(); + if (rBigRange.IsValid(pDoc) && m_xDialog->has_toplevel_focus()) + { + bool bSetCursor = i == nCount - 1; + pTabView->MarkRange(rBigRange.MakeRange(), bSetCursor, bContMark); + bContMark = true; + } } ScChangeTrack* pChanges = pDoc->GetChangeTrack(); @@ -1622,83 +1592,58 @@ IMPL_LINK_NOARG(ScAcceptChgDlg, UpdateSelectionHdl, Timer *, void) pTPView->EnableReject( bRejectFlag && bEnable ); } -IMPL_LINK_NOARG(ScAcceptChgDlg, CommandHdl, SvSimpleTable*, void) +IMPL_LINK(ScAcceptChgDlg, CommandHdl, const CommandEvent&, rCEvt, bool) { + if (rCEvt.GetCommand() != CommandEventId::ContextMenu) + return false; - const CommandEvent aCEvt(pTheView->GetCommandEvent()); - - if(aCEvt.GetCommand()==CommandEventId::ContextMenu) - { - m_xPopup->SetMenuFlags(MenuFlags::HideDisabledEntries); - - SvTreeListEntry* pEntry=pTheView->GetCurEntry(); - if(pEntry!=nullptr) - { - pTheView->Select(pEntry); - } - else - { - m_xPopup->Deactivate(); - } - - const sal_uInt16 nSubSortId = m_xPopup->GetItemId("calcsort"); - PopupMenu *pSubMenu = m_xPopup->GetPopupMenu(nSubSortId); - const sal_uInt16 nActionId = pSubMenu->GetItemId("calcaction"); + weld::TreeView& rTreeView = pTheView->GetWidget(); + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + bool bEntry = rTreeView.get_cursor(xEntry.get()); + if (bEntry) + rTreeView.select(*xEntry); - sal_uInt16 nSortedCol = pTheView->GetSortedCol(); - if (nSortedCol != 0xFFFF) - pSubMenu->CheckItem(nActionId + nSortedCol); + int nSortedCol = rTreeView.get_sort_column(); + for (sal_Int32 i = 0; i < 5; ++i) + m_xPopup->set_active(OString("calcsort") + OString::number(i), i == nSortedCol); - const sal_uInt16 nEditId = m_xPopup->GetItemId("calcedit"); + m_xPopup->set_sensitive("calcedit", false); - m_xPopup->EnableItem(nEditId, false); - - if(pDoc->IsDocEditable() && pEntry!=nullptr) + if (pDoc->IsDocEditable() && bEntry) + { + ScRedlinData *pEntryData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(*xEntry).toInt64()); + if (pEntryData) { - ScRedlinData *pEntryData=static_cast<ScRedlinData *>(pEntry->GetUserData()); - if(pEntryData!=nullptr) - { - ScChangeAction* pScChangeAction= - static_cast<ScChangeAction*>(pEntryData->pData); - if (pScChangeAction!=nullptr && !pTheView->GetParent(pEntry)) - m_xPopup->EnableItem(nEditId); - } + ScChangeAction* pScChangeAction = static_cast<ScChangeAction*>(pEntryData->pData); + if (pScChangeAction && !rTreeView.get_iter_depth(*xEntry)) + m_xPopup->set_sensitive("calcedit", true); } + } - sal_uInt16 nCommand = m_xPopup->Execute(this, GetPointerPosPixel()); + OString sCommand = m_xPopup->popup_at_rect(&rTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1))); - if(nCommand) + if (!sCommand.isEmpty()) + { + if (sCommand == "calcedit") { - if (nCommand == nEditId) + if (bEntry) { - if(pEntry!=nullptr) + ScRedlinData *pEntryData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(*xEntry).toInt64()); + if (pEntryData) { - ScRedlinData *pEntryData=static_cast<ScRedlinData *>(pEntry->GetUserData()); - if(pEntryData!=nullptr) - { - ScChangeAction* pScChangeAction= - static_cast<ScChangeAction*>(pEntryData->pData); - - pViewData->GetDocShell()->ExecuteChangeCommentDialog(pScChangeAction, GetFrameWeld(), false); - } + ScChangeAction* pScChangeAction = static_cast<ScChangeAction*>(pEntryData->pData); + pViewData->GetDocShell()->ExecuteChangeCommentDialog(pScChangeAction, m_xDialog.get(), false); } } - else - { - bool bSortDir = pTheView->GetSortDirection(); - sal_uInt16 nDialogCol = nCommand - nActionId; - if(nSortedCol==nDialogCol) bSortDir=!bSortDir; - pTheView->SortByCol(nDialogCol,bSortDir); - /* - 0, sort by action - 1, sort by position - 2, sort by author - 3, sort by date - 4, sort by comment - */ - } + } + else + { + int nDialogCol = sCommand.copy(8).toInt32(); + pTheView->HeaderBarClick(nDialogCol); } } + + return true; } namespace @@ -1732,41 +1677,64 @@ namespace } } -void ScAcceptChgDlg::Initialize(SfxChildWinInfo *pInfo) +void ScAcceptChgDlg::Initialize(SfxChildWinInfo* pInfo) { OUString aStr; if (pInfo && !pInfo->aExtraString.isEmpty()) aStr = lcl_StripAcceptChgDat(pInfo->aExtraString); - SfxModelessDialog::Initialize(pInfo); + SfxModelessDialogController::Initialize(pInfo); - if ( !aStr.isEmpty()) + if (!aStr.isEmpty()) { - sal_uInt16 nCount=static_cast<sal_uInt16>(aStr.toInt32()); - - for(sal_uInt16 i=0;i<nCount;i++) + int nCount = aStr.toInt32(); + if (nCount > 2) { - sal_Int32 n1 = aStr.indexOf(';'); - aStr = aStr.copy( n1+1 ); - pTheView->SetTab(i, static_cast<sal_uInt16>(aStr.toInt32()), MapUnit::MapPixel); + std::vector<int> aEndPos; + + for (int i = 0; i < nCount; ++i) + { + sal_Int32 n1 = aStr.indexOf(';'); + aStr = aStr.copy( n1+1 ); + aEndPos.push_back(aStr.toInt32()); + } + + std::vector<int> aWidths; + for (int i = 1; i < nCount; ++i) + aWidths.push_back(aEndPos[i] - aEndPos[i - 1]); + + // turn column end points back to column widths, ignoring the small + // value used for the the expander column + weld::TreeView& rTreeView = pTheView->GetWidget(); + rTreeView.set_column_fixed_widths(aWidths); } } } void ScAcceptChgDlg::FillInfo(SfxChildWinInfo& rInfo) const { - SfxModelessDialog::FillInfo(rInfo); + SfxModelessDialogController::FillInfo(rInfo); //remove any old one before adding a new one lcl_StripAcceptChgDat(rInfo.aExtraString); rInfo.aExtraString += "AcceptChgDat:("; - sal_uInt16 nCount=pTheView->TabCount(); + const int nTabCount = 5; - rInfo.aExtraString += OUString::number(nCount); + rInfo.aExtraString += OUString::number(nTabCount); rInfo.aExtraString += ";"; - for(sal_uInt16 i=0;i<nCount;i++) + + weld::TreeView& rTreeView = pTheView->GetWidget(); + std::vector<int> aWidths; + // turn column widths back into column end points for compatibility + // with how they used to be stored, including a small value for the + // expander column + aWidths.push_back(rTreeView.get_checkbox_column_width()); + for (int i = 0; i < nTabCount - 1; ++i) + aWidths.push_back(aWidths.back() + rTreeView.get_column_width(i)); + + for (auto a : aWidths) { - rInfo.aExtraString += OUString::number(pTheView->GetTab(i)); + rInfo.aExtraString += OUString::number(a); rInfo.aExtraString += ";"; } rInfo.aExtraString += ")"; @@ -1775,77 +1743,55 @@ void ScAcceptChgDlg::FillInfo(SfxChildWinInfo& rInfo) const #define CALC_DATE 3 #define CALC_POS 1 -IMPL_LINK( ScAcceptChgDlg, ColCompareHdl, const SvSortData*, pSortData, sal_Int32 ) +int ScAcceptChgDlg::ColCompareHdl(const weld::TreeIter& rLeft, const weld::TreeIter& rRight) const { + weld::TreeView& rTreeView = pTheView->GetWidget(); + sal_Int32 nCompare = 0; - SCCOL nSortCol= static_cast<SCCOL>(pTheView->GetSortedCol()); + SCCOL nSortCol= rTreeView.get_sort_column(); - if(pSortData) + if (CALC_DATE == nSortCol) { - SvTreeListEntry* pLeft = const_cast<SvTreeListEntry*>(pSortData->pLeft ); - SvTreeListEntry* pRight = const_cast<SvTreeListEntry*>(pSortData->pRight ); - - if(CALC_DATE==nSortCol) + RedlinData *pLeftData = reinterpret_cast<RedlinData*>(rTreeView.get_id(rLeft).toInt64()); + RedlinData *pRightData = reinterpret_cast<RedlinData*>(rTreeView.get_id(rRight).toInt64()); + if (pLeftData && pRightData) { - RedlinData *pLeftData=static_cast<RedlinData *>(pLeft->GetUserData()); - RedlinData *pRightData=static_cast<RedlinData *>(pRight->GetUserData()); - - if(pLeftData!=nullptr && pRightData!=nullptr) - { - if(pLeftData->aDateTime < pRightData->aDateTime) - nCompare = -1; - else if(pLeftData->aDateTime > pRightData->aDateTime) - nCompare = 1; - return nCompare; - } + if(pLeftData->aDateTime < pRightData->aDateTime) + nCompare = -1; + else if(pLeftData->aDateTime > pRightData->aDateTime) + nCompare = 1; + return nCompare; } - else if(CALC_POS==nSortCol) + } + else if (CALC_POS == nSortCol) + { + ScRedlinData *pLeftData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(rLeft).toInt64()); + ScRedlinData *pRightData = reinterpret_cast<ScRedlinData*>(rTreeView.get_id(rRight).toInt64()); + if (pLeftData && pRightData) { - ScRedlinData *pLeftData=static_cast<ScRedlinData *>(pLeft->GetUserData()); - ScRedlinData *pRightData=static_cast<ScRedlinData *>(pRight->GetUserData()); + nCompare = 1; - if(pLeftData!=nullptr && pRightData!=nullptr) + if(pLeftData->nTable < pRightData->nTable) + nCompare = -1; + else if(pLeftData->nTable == pRightData->nTable) { - nCompare = 1; - - if(pLeftData->nTable < pRightData->nTable) + if(pLeftData->nRow < pRightData->nRow) nCompare = -1; - else if(pLeftData->nTable == pRightData->nTable) + else if(pLeftData->nRow == pRightData->nRow) { - if(pLeftData->nRow < pRightData->nRow) + if(pLeftData->nCol < pRightData->nCol) nCompare = -1; - else if(pLeftData->nRow == pRightData->nRow) - { - if(pLeftData->nCol < pRightData->nCol) - nCompare = -1; - else if(pLeftData->nCol == pRightData->nCol) - nCompare = 0; - } + else if(pLeftData->nCol == pRightData->nCol) + nCompare = 0; } - - return nCompare; } - } - - SvLBoxItem* pLeftItem = pTheView->GetEntryAtPos( pLeft, static_cast<sal_uInt16>(nSortCol)); - SvLBoxItem* pRightItem = pTheView->GetEntryAtPos( pRight, static_cast<sal_uInt16>(nSortCol)); - if(pLeftItem != nullptr && pRightItem != nullptr) - { - SvLBoxItemType nLeftKind = pLeftItem->GetType(); - SvLBoxItemType nRightKind = pRightItem->GetType(); - - if (nRightKind == SvLBoxItemType::String && - nLeftKind == SvLBoxItemType::String) - { - nCompare = ScGlobal::GetCaseCollator()->compareString( - static_cast<SvLBoxString*>(pLeftItem)->GetText(), - static_cast<SvLBoxString*>(pRightItem)->GetText()); - } + return nCompare; } - } - return nCompare; + + return ScGlobal::GetCaseCollator()->compareString(rTreeView.get_text(rLeft, nSortCol), + rTreeView.get_text(rRight, nSortCol)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/miscdlgs/conflictsdlg.cxx b/sc/source/ui/miscdlgs/conflictsdlg.cxx index 0f5286d4ddda..95e2a285c381 100644 --- a/sc/source/ui/miscdlgs/conflictsdlg.cxx +++ b/sc/source/ui/miscdlgs/conflictsdlg.cxx @@ -329,27 +329,24 @@ void ScConflictsResolver::HandleAction( ScChangeAction* pAction, bool bIsSharedA // class ScConflictsDlg -ScConflictsDlg::ScConflictsDlg( vcl::Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList ) - :ModalDialog( pParent, "ConflictsDialog", "modules/scalc/ui/conflictsdialog.ui" ) - ,m_pLbConflictsContainer ( get<SvSimpleTableContainer>("container") ) - ,m_pLbConflicts ( VclPtr<SvxRedlinTable>::Create(*m_pLbConflictsContainer) ) - ,maStrTitleConflict ( ScResId( STR_TITLE_CONFLICT ) ) - ,maStrUnknownUser ( ScResId( STR_UNKNOWN_USER_CONFLICT ) ) - ,mpViewData ( pViewData ) - ,mpOwnDoc ( nullptr ) - ,mpOwnTrack ( nullptr ) - ,mpSharedDoc ( pSharedDoc ) - ,mpSharedTrack ( nullptr ) - ,mrConflictsList ( rConflictsList ) - ,maSelectionIdle ( "ScConflictsDlg SelectionIdle" ) - ,mbInSelectHdl ( false ) - ,mbInDeselectHdl ( false ) +ScConflictsDlg::ScConflictsDlg(weld::Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList) + : GenericDialogController(pParent, "modules/scalc/ui/conflictsdialog.ui", "ConflictsDialog") + , maStrTitleConflict ( ScResId( STR_TITLE_CONFLICT ) ) + , maStrUnknownUser ( ScResId( STR_UNKNOWN_USER_CONFLICT ) ) + , mpViewData ( pViewData ) + , mpOwnDoc ( nullptr ) + , mpOwnTrack ( nullptr ) + , mpSharedDoc ( pSharedDoc ) + , mpSharedTrack ( nullptr ) + , mrConflictsList ( rConflictsList ) + , maSelectionIdle ( "ScConflictsDlg SelectionIdle" ) + , mbInSelectHdl ( false ) + , m_xBtnKeepMine(m_xBuilder->weld_button("keepmine")) + , m_xBtnKeepOther(m_xBuilder->weld_button("keepother")) + , m_xBtnKeepAllMine(m_xBuilder->weld_button("keepallmine")) + , m_xBtnKeepAllOthers(m_xBuilder->weld_button("keepallothers")) + , m_xLbConflicts(new SvxRedlinTable(m_xBuilder->weld_tree_view("container"), nullptr)) { - get(m_pBtnKeepMine, "keepmine"); - get(m_pBtnKeepOther, "keepother"); - get(m_pBtnKeepAllMine, "keepallmine"); - get(m_pBtnKeepAllOthers, "keepallothers"); - OSL_ENSURE( mpViewData, "ScConflictsDlg CTOR: mpViewData is null!" ); mpOwnDoc = ( mpViewData ? mpViewData->GetDocument() : nullptr ); OSL_ENSURE( mpOwnDoc, "ScConflictsDlg CTOR: mpOwnDoc is null!" ); @@ -359,57 +356,36 @@ ScConflictsDlg::ScConflictsDlg( vcl::Window* pParent, ScViewData* pViewData, ScD mpSharedTrack = ( mpSharedDoc ? mpSharedDoc->GetChangeTrack() : nullptr ); OSL_ENSURE( mpSharedTrack, "ScConflictsDlg CTOR: mpSharedTrack is null!" ); - SetMinOutputSizePixel( GetSizePixel() ); - - long const nTabs[] = { 10, 216, 266 }; - m_pLbConflicts->SetTabs( SAL_N_ELEMENTS(nTabs), nTabs ); + weld::TreeView& rTreeView = m_xLbConflicts->GetWidget(); - OUString aTab('\t'); - OUString aHeader( maStrTitleConflict ); - aHeader += aTab; - aHeader += ScResId( STR_TITLE_AUTHOR ); - aHeader += aTab; - aHeader += ScResId( STR_TITLE_DATE ); - m_pLbConflicts->InsertHeaderEntry( aHeader, HEADERBAR_APPEND, HeaderBarItemBits::LEFT | HeaderBarItemBits::LEFTIMAGE ); + auto nDigitWidth = rTreeView.get_approximate_digit_width(); + std::vector<int> aWidths; + aWidths.push_back(nDigitWidth * 60); + aWidths.push_back(nDigitWidth * 20); + rTreeView.set_column_fixed_widths(aWidths); - m_pLbConflicts->SetStyle( m_pLbConflicts->GetStyle() | WB_HASLINES | WB_CLIPCHILDREN | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HSCROLL ); - m_pLbConflicts->SetSelectionMode( SelectionMode::Multiple ); - m_pLbConflicts->SetHighlightRange(); + rTreeView.set_selection_mode(SelectionMode::Multiple); + rTreeView.set_size_request(-1, rTreeView.get_height_rows(16)); maSelectionIdle.SetInvokeHandler( LINK( this, ScConflictsDlg, UpdateSelectionHdl ) ); maSelectionIdle.SetDebugName( "ScConflictsDlg maSelectionIdle" ); - m_pLbConflicts->SetSelectHdl( LINK( this, ScConflictsDlg, SelectHandle ) ); - m_pLbConflicts->SetDeselectHdl( LINK( this, ScConflictsDlg, DeselectHandle ) ); + rTreeView.connect_changed(LINK(this, ScConflictsDlg, SelectHandle)); - m_pBtnKeepMine->SetClickHdl( LINK( this, ScConflictsDlg, KeepMineHandle ) ); - m_pBtnKeepOther->SetClickHdl( LINK( this, ScConflictsDlg, KeepOtherHandle ) ); - m_pBtnKeepAllMine->SetClickHdl( LINK( this, ScConflictsDlg, KeepAllMineHandle ) ); - m_pBtnKeepAllOthers->SetClickHdl( LINK( this, ScConflictsDlg, KeepAllOthersHandle ) ); + m_xBtnKeepMine->connect_clicked( LINK( this, ScConflictsDlg, KeepMineHandle ) ); + m_xBtnKeepOther->connect_clicked( LINK( this, ScConflictsDlg, KeepOtherHandle ) ); + m_xBtnKeepAllMine->connect_clicked( LINK( this, ScConflictsDlg, KeepAllMineHandle ) ); + m_xBtnKeepAllOthers->connect_clicked( LINK( this, ScConflictsDlg, KeepAllOthersHandle ) ); UpdateView(); - SvTreeListEntry* pEntry = m_pLbConflicts->First(); - if ( pEntry != nullptr ) - { - m_pLbConflicts->Select( pEntry ); - } + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + if (rTreeView.get_iter_first(*xEntry)) + rTreeView.select(*xEntry); } ScConflictsDlg::~ScConflictsDlg() { - disposeOnce(); -} - -void ScConflictsDlg::dispose() -{ - m_pLbConflictsContainer.clear(); - m_pLbConflicts.disposeAndClear(); - m_pBtnKeepMine.clear(); - m_pBtnKeepOther.clear(); - m_pBtnKeepAllMine.clear(); - m_pBtnKeepAllOthers.clear(); - ModalDialog::dispose(); } OUString ScConflictsDlg::GetConflictString( const ScConflictsListEntry& rConflictEntry ) @@ -427,97 +403,72 @@ OUString ScConflictsDlg::GetConflictString( const ScConflictsListEntry& rConflic return aString; } -OUString ScConflictsDlg::GetActionString( const ScChangeAction* pAction, ScDocument* pDoc ) +void ScConflictsDlg::SetActionString(const ScChangeAction* pAction, ScDocument* pDoc, weld::TreeIter& rEntry) { - OUString aString; - OSL_ENSURE( pAction, "ScConflictsDlg::GetActionString(): pAction is null!" ); OSL_ENSURE( pDoc, "ScConflictsDlg::GetActionString(): pDoc is null!" ); - if ( pAction && pDoc ) + if (pAction && pDoc) { + weld::TreeView& rTreeView = m_xLbConflicts->GetWidget(); OUString aDesc; pAction->GetDescription(aDesc, pDoc, true, false); - aString += aDesc; - aString += "\t"; + rTreeView.set_text(rEntry, aDesc, 0); OUString aUser = comphelper::string::strip(pAction->GetUser(), ' '); if ( aUser.isEmpty() ) { aUser = maStrUnknownUser; } - aString += aUser; - aString += "\t"; + rTreeView.set_text(rEntry, aUser, 1); DateTime aDateTime = pAction->GetDateTime(); - aString += ScGlobal::pLocaleData->getDate( aDateTime ); + OUString aString = ScGlobal::pLocaleData->getDate( aDateTime ); aString += " "; aString += ScGlobal::pLocaleData->getTime( aDateTime, false ); - aString += "\t"; + rTreeView.set_text(rEntry, aString, 2); } - - return aString; } -void ScConflictsDlg::HandleListBoxSelection( bool bSelectHandle ) +void ScConflictsDlg::HandleListBoxSelection() { - SvTreeListEntry* pSelEntry = m_pLbConflicts->GetCurEntry(); - if ( !pSelEntry ) - { - pSelEntry = m_pLbConflicts->FirstSelected(); - } - if ( !pSelEntry ) - { + weld::TreeView& rTreeView = m_xLbConflicts->GetWidget(); + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + bool bSelEntry = rTreeView.get_cursor(xEntry.get()); + if (!bSelEntry) + bSelEntry = rTreeView.get_selected(xEntry.get()); + if (!bSelEntry) return; - } - SvTreeListEntry* pRootEntry = m_pLbConflicts->GetRootLevelParent( pSelEntry ); - if ( pRootEntry ) + bool bSelectHandle = rTreeView.is_selected(*xEntry); + + while (rTreeView.get_iter_depth(*xEntry)) + rTreeView.iter_parent(*xEntry); + + if (bSelectHandle) + rTreeView.unselect_all(); + if (!rTreeView.is_selected(*xEntry)) + rTreeView.select(*xEntry); + if (rTreeView.iter_children(*xEntry)) { - if ( bSelectHandle ) - { - m_pLbConflicts->SelectAll( false ); - } - if ( !m_pLbConflicts->IsSelected( pRootEntry ) ) + do { - m_pLbConflicts->Select( pRootEntry ); - } - SvTreeListEntry* pEntry = m_pLbConflicts->FirstChild( pRootEntry ); - while ( pEntry ) - { - if ( !m_pLbConflicts->IsSelected( pEntry ) ) - { - m_pLbConflicts->Select( pEntry ); - } - pEntry = pEntry->NextSibling(); - } + if (!rTreeView.is_selected(*xEntry)) + rTreeView.select(*xEntry); + } while (rTreeView.iter_next_sibling(*xEntry)); } } -IMPL_LINK_NOARG(ScConflictsDlg, SelectHandle, SvTreeListBox*, void) +IMPL_LINK_NOARG(ScConflictsDlg, SelectHandle, weld::TreeView&, void) { - if ( mbInSelectHdl || mbInDeselectHdl ) - { + if (mbInSelectHdl) return; - } mbInSelectHdl = true; - HandleListBoxSelection( true ); + HandleListBoxSelection(); maSelectionIdle.Start(); mbInSelectHdl = false; } -IMPL_LINK_NOARG(ScConflictsDlg, DeselectHandle, SvTreeListBox*, void) -{ - if ( mbInDeselectHdl || mbInSelectHdl ) - { - return; - } - - mbInDeselectHdl = true; - HandleListBoxSelection( false ); - mbInDeselectHdl = false; -} - IMPL_LINK_NOARG(ScConflictsDlg, UpdateSelectionHdl, Timer *, void) { if ( !mpViewData || !mpOwnDoc ) @@ -527,36 +478,44 @@ IMPL_LINK_NOARG(ScConflictsDlg, UpdateSelectionHdl, Timer *, void) ScTabView* pTabView = mpViewData->GetView(); pTabView->DoneBlockMode(); - bool bContMark = false; - SvTreeListEntry* pEntry = m_pLbConflicts->FirstSelected(); - while ( pEntry ) - { - if ( pEntry != m_pLbConflicts->GetRootLevelParent( pEntry ) ) + + std::vector<const ScChangeAction*> aActions; + + weld::TreeView& rTreeView = m_xLbConflicts->GetWidget(); + rTreeView.selected_foreach([&rTreeView, &aActions](weld::TreeIter& rEntry){ + if (rTreeView.get_iter_depth(rEntry)) { - RedlinData* pUserData = static_cast< RedlinData* >( pEntry->GetUserData() ); - if ( pUserData ) + RedlinData* pUserData = reinterpret_cast<RedlinData*>(rTreeView.get_id(rEntry).toInt64()); + if (pUserData) { ScChangeAction* pAction = static_cast< ScChangeAction* >( pUserData->pData ); if ( pAction && ( pAction->GetType() != SC_CAT_DELETE_TABS ) && ( pAction->IsClickable() || pAction->IsVisible() ) ) { - const ScBigRange& rBigRange = static_cast< const ScChangeAction* >( pAction )->GetBigRange(); - if ( rBigRange.IsValid( mpOwnDoc ) ) - { - bool bSetCursor = !m_pLbConflicts->NextSelected( pEntry ); - pTabView->MarkRange( rBigRange.MakeRange(), bSetCursor, bContMark ); - bContMark = true; - } + aActions.push_back(pAction); } } } - pEntry = m_pLbConflicts->NextSelected( pEntry ); + return false; + }); + + bool bContMark = false; + for (size_t i = 0, nCount = aActions.size(); i < nCount; ++i) + { + const ScBigRange& rBigRange = aActions[i]->GetBigRange(); + if (rBigRange.IsValid(mpOwnDoc)) + { + bool bSetCursor = i == nCount - 1; + pTabView->MarkRange(rBigRange.MakeRange(), bSetCursor, bContMark); + bContMark = true; + } } } -void ScConflictsDlg::SetConflictAction( const SvTreeListEntry* pRootEntry, ScConflictAction eConflictAction ) +void ScConflictsDlg::SetConflictAction(const weld::TreeIter& rRootEntry, ScConflictAction eConflictAction) { - RedlinData* pUserData = static_cast< RedlinData* >( pRootEntry ? pRootEntry->GetUserData() : nullptr ); + weld::TreeView& rTreeView = m_xLbConflicts->GetWidget(); + RedlinData* pUserData = reinterpret_cast<RedlinData*>(rTreeView.get_id(rRootEntry).toInt64()); ScConflictsListEntry* pConflictEntry = static_cast< ScConflictsListEntry* >( pUserData ? pUserData->pData : nullptr ); if ( pConflictEntry ) { @@ -564,76 +523,86 @@ void ScConflictsDlg::SetConflictAction( const SvTreeListEntry* pRootEntry, ScCon } } -void ScConflictsDlg::KeepHandler( bool bMine ) +void ScConflictsDlg::KeepHandler(bool bMine) { - SvTreeListEntry* pEntry = m_pLbConflicts->FirstSelected(); - SvTreeListEntry* pRootEntry = ( pEntry ? m_pLbConflicts->GetRootLevelParent( pEntry ) : nullptr ); - if ( !pRootEntry ) - { + weld::TreeView& rTreeView = m_xLbConflicts->GetWidget(); + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + if (!rTreeView.get_selected(xEntry.get())) return; - } - SetPointer( PointerStyle::Wait ); + + while (rTreeView.get_iter_depth(*xEntry)) + rTreeView.iter_parent(*xEntry); + + m_xDialog->set_busy_cursor(true); ScConflictAction eConflictAction = ( bMine ? SC_CONFLICT_ACTION_KEEP_MINE : SC_CONFLICT_ACTION_KEEP_OTHER ); - SetConflictAction( pRootEntry, eConflictAction ); - m_pLbConflicts->RemoveEntry( pRootEntry ); - SetPointer( PointerStyle::Arrow ); - if ( m_pLbConflicts->GetEntryCount() == 0 ) - { - EndDialog( RET_OK ); - } + SetConflictAction(*xEntry, eConflictAction); + rTreeView.remove(*xEntry); + m_xDialog->set_busy_cursor(false); + if (rTreeView.n_children() == 0) + m_xDialog->response(RET_OK); } void ScConflictsDlg::KeepAllHandler( bool bMine ) { - SvTreeListEntry* pEntry = m_pLbConflicts->First(); - SvTreeListEntry* pRootEntry = ( pEntry ? m_pLbConflicts->GetRootLevelParent( pEntry ) : nullptr ); - if ( !pRootEntry ) - { + weld::TreeView& rTreeView = m_xLbConflicts->GetWidget(); + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + if (!rTreeView.get_iter_first(*xEntry)) return; - } - SetPointer( PointerStyle::Wait ); + + while (rTreeView.get_iter_depth(*xEntry)) + rTreeView.iter_parent(*xEntry); + + m_xDialog->set_busy_cursor(true); + ScConflictAction eConflictAction = ( bMine ? SC_CONFLICT_ACTION_KEEP_MINE : SC_CONFLICT_ACTION_KEEP_OTHER ); - while ( pRootEntry ) + do { - SetConflictAction( pRootEntry, eConflictAction ); - pRootEntry = pRootEntry->NextSibling(); - } - m_pLbConflicts->SetUpdateMode( false ); - m_pLbConflicts->Clear(); - m_pLbConflicts->SetUpdateMode( true ); - SetPointer( PointerStyle::Arrow ); - EndDialog( RET_OK ); + SetConflictAction(*xEntry, eConflictAction); + } while (rTreeView.iter_next_sibling(*xEntry)); + + rTreeView.freeze(); + rTreeView.clear(); + rTreeView.thaw(); + + m_xDialog->set_busy_cursor(false); + + m_xDialog->response(RET_OK); } -IMPL_LINK_NOARG(ScConflictsDlg, KeepMineHandle, Button*, void) +IMPL_LINK_NOARG(ScConflictsDlg, KeepMineHandle, weld::Button&, void) { KeepHandler( true ); } -IMPL_LINK_NOARG(ScConflictsDlg, KeepOtherHandle, Button*, void) +IMPL_LINK_NOARG(ScConflictsDlg, KeepOtherHandle, weld::Button&, void) { KeepHandler( false ); } -IMPL_LINK_NOARG(ScConflictsDlg, KeepAllMineHandle, Button*, void) +IMPL_LINK_NOARG(ScConflictsDlg, KeepAllMineHandle, weld::Button&, void) { KeepAllHandler( true ); } -IMPL_LINK_NOARG(ScConflictsDlg, KeepAllOthersHandle, Button*, void) +IMPL_LINK_NOARG(ScConflictsDlg, KeepAllOthersHandle, weld::Button&, void) { KeepAllHandler( false ); } void ScConflictsDlg::UpdateView() { + weld::TreeView& rTreeView = m_xLbConflicts->GetWidget(); for ( ScConflictsListEntry& rConflictEntry : mrConflictsList ) { if (rConflictEntry.meConflictAction == SC_CONFLICT_ACTION_NONE) { std::unique_ptr<RedlinData> pRootUserData(new RedlinData()); pRootUserData->pData = static_cast<void*>(&rConflictEntry); - SvTreeListEntry* pRootEntry = m_pLbConflicts->InsertEntry( GetConflictString( rConflictEntry ), std::move(pRootUserData) ); + OUString sString(GetConflictString(rConflictEntry)); + OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pRootUserData.release()))); + std::unique_ptr<weld::TreeIter> xRootEntry(rTreeView.make_iterator()); + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + rTreeView.insert(nullptr, -1, &sString, &sId, nullptr, nullptr, nullptr, false, xRootEntry.get()); for ( auto& aSharedAction : rConflictEntry.maSharedActions ) { @@ -650,8 +619,8 @@ void ScConflictsDlg::UpdateView() } } - OUString aString( GetActionString( pAction, mpSharedDoc ) ); - m_pLbConflicts->InsertEntry( aString, std::unique_ptr<RedlinData>(), pRootEntry ); + rTreeView.insert(xRootEntry.get(), -1, nullptr, nullptr, nullptr, nullptr, nullptr, false, xEntry.get()); + SetActionString(pAction, mpSharedDoc, *xEntry); } } @@ -670,14 +639,15 @@ void ScConflictsDlg::UpdateView() } } - OUString aString( GetActionString( pAction, mpOwnDoc ) ); std::unique_ptr<RedlinData> pUserData(new RedlinData()); pUserData->pData = static_cast< void* >( pAction ); - m_pLbConflicts->InsertEntry( aString, std::move(pUserData), pRootEntry ); + OUString aId(OUString::number(reinterpret_cast<sal_Int64>(pUserData.release()))); + rTreeView.insert(xRootEntry.get(), -1, nullptr, &aId, nullptr, nullptr, nullptr, false, xEntry.get()); + SetActionString(pAction, mpOwnDoc, *xEntry); } } - m_pLbConflicts->Expand( pRootEntry ); + rTreeView.expand_row(*xRootEntry); } } } diff --git a/sc/source/ui/miscdlgs/highred.cxx b/sc/source/ui/miscdlgs/highred.cxx index c59dfc73012a..b75201ce8f63 100644 --- a/sc/source/ui/miscdlgs/highred.cxx +++ b/sc/source/ui/miscdlgs/highred.cxx @@ -28,29 +28,28 @@ // class ScHighlightChgDlg -ScHighlightChgDlg::ScHighlightChgDlg( SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pParent, - ScViewData* ptrViewData) - : ScAnyRefDlg(pB, pCW, pParent, "ShowChangesDialog", - "modules/scalc/ui/showchangesdialog.ui") +ScHighlightChgDlg::ScHighlightChgDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + ScViewData* ptrViewData) + : ScAnyRefDlgController(pB, pCW, pParent, "modules/scalc/ui/showchangesdialog.ui", "ShowChangesDialog") , pViewData(ptrViewData) , pDoc(ptrViewData->GetDocument()) + , m_xHighlightBox(m_xBuilder->weld_check_button("showchanges")) + , m_xCbAccept(m_xBuilder->weld_check_button("showaccepted")) + , m_xCbReject(m_xBuilder->weld_check_button("showrejected")) + , m_xOkButton(m_xBuilder->weld_button("ok")) + , m_xEdAssign(new formula::WeldRefEdit(m_xBuilder->weld_entry("range"))) + , m_xRbAssign(new formula::WeldRefButton(m_xBuilder->weld_button("rangeref"))) + , m_xBox(m_xBuilder->weld_container("box")) + , m_xFilterCtr(new SvxTPFilter(m_xBox.get())) { - m_pFilterCtr = VclPtr<SvxTPFilter>::Create(get<VclContainer>("box")); - get(m_pHighlightBox, "showchanges"); - get(m_pCbAccept, "showaccepted"); - get(m_pCbReject, "showrejected"); - get(m_pEdAssign, "range"); - m_pEdAssign->SetReferences(this, m_pFilterCtr->get<vcl::Window>("range")); - m_pEdAssign->SetSizePixel(m_pEdAssign->get_preferred_size()); - get(m_pRbAssign, "rangeref"); - m_pRbAssign->SetReferences(this, m_pEdAssign); - get(m_pOkButton, "ok"); - - m_pOkButton->SetClickHdl(LINK( this, ScHighlightChgDlg, OKBtnHdl)); - m_pHighlightBox->SetClickHdl(LINK( this, ScHighlightChgDlg, HighlightHandle )); - m_pFilterCtr->SetRefHdl(LINK( this, ScHighlightChgDlg, RefHandle )); - m_pFilterCtr->HideRange(false); - m_pFilterCtr->Show(); + m_xEdAssign->SetReferences(this, nullptr); + m_xRbAssign->SetReferences(this, m_xEdAssign.get()); + + m_xOkButton->connect_clicked(LINK( this, ScHighlightChgDlg, OKBtnHdl)); + m_xHighlightBox->connect_clicked(LINK( this, ScHighlightChgDlg, HighlightHandle )); + m_xFilterCtr->SetRefHdl(LINK( this, ScHighlightChgDlg, RefHandle )); + m_xFilterCtr->HideRange(false); + m_xFilterCtr->Show(); SetDispatcherLock( true ); Init(); @@ -58,20 +57,7 @@ ScHighlightChgDlg::ScHighlightChgDlg( SfxBindings* pB, SfxChildWindow* pCW, vcl: ScHighlightChgDlg::~ScHighlightChgDlg() { - disposeOnce(); -} - -void ScHighlightChgDlg::dispose() -{ SetDispatcherLock( false ); - m_pFilterCtr.disposeAndClear(); - m_pHighlightBox.clear(); - m_pCbAccept.clear(); - m_pCbReject.clear(); - m_pOkButton.clear(); - m_pEdAssign.clear(); - m_pRbAssign.clear(); - ScAnyRefDlg::dispose(); } void ScHighlightChgDlg::Init() @@ -82,81 +68,92 @@ void ScHighlightChgDlg::Init() if(pChanges!=nullptr) { aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser()); - m_pFilterCtr->ClearAuthors(); + m_xFilterCtr->ClearAuthors(); const std::set<OUString>& rUserColl = pChanges->GetUserCollection(); for (const auto& rItem : rUserColl) - m_pFilterCtr->InsertAuthor(rItem); + m_xFilterCtr->InsertAuthor(rItem); } ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings(); if(pViewSettings!=nullptr) aChangeViewSet=*pViewSettings; - m_pHighlightBox->Check(aChangeViewSet.ShowChanges()); - m_pFilterCtr->CheckDate(aChangeViewSet.HasDate()); - m_pFilterCtr->SetFirstDate(aChangeViewSet.GetTheFirstDateTime()); - m_pFilterCtr->SetFirstTime(aChangeViewSet.GetTheFirstDateTime()); - m_pFilterCtr->SetLastDate(aChangeViewSet.GetTheLastDateTime()); - m_pFilterCtr->SetLastTime(aChangeViewSet.GetTheLastDateTime()); - m_pFilterCtr->SetDateMode(static_cast<sal_uInt16>(aChangeViewSet.GetTheDateMode())); - m_pFilterCtr->CheckAuthor(aChangeViewSet.HasAuthor()); - m_pFilterCtr->CheckComment(aChangeViewSet.HasComment()); - m_pFilterCtr->SetComment(aChangeViewSet.GetTheComment()); - - m_pCbAccept->Check(aChangeViewSet.IsShowAccepted()); - m_pCbReject->Check(aChangeViewSet.IsShowRejected()); + m_xHighlightBox->set_active(aChangeViewSet.ShowChanges()); + m_xFilterCtr->CheckDate(aChangeViewSet.HasDate()); + + DateTime aEmpty(DateTime::EMPTY); + + DateTime aDateTime(aChangeViewSet.GetTheFirstDateTime()); + if (aDateTime != aEmpty) + { + m_xFilterCtr->SetFirstDate(aDateTime); + m_xFilterCtr->SetFirstTime(aDateTime); + } + aDateTime = aChangeViewSet.GetTheLastDateTime(); + if (aDateTime != aEmpty) + { + m_xFilterCtr->SetLastDate(aDateTime); + m_xFilterCtr->SetLastTime(aDateTime); + } + + m_xFilterCtr->SetDateMode(static_cast<sal_uInt16>(aChangeViewSet.GetTheDateMode())); + m_xFilterCtr->CheckAuthor(aChangeViewSet.HasAuthor()); + m_xFilterCtr->CheckComment(aChangeViewSet.HasComment()); + m_xFilterCtr->SetComment(aChangeViewSet.GetTheComment()); + + m_xCbAccept->set_active(aChangeViewSet.IsShowAccepted()); + m_xCbReject->set_active(aChangeViewSet.IsShowRejected()); OUString aString=aChangeViewSet.GetTheAuthorToShow(); if(!aString.isEmpty()) { - m_pFilterCtr->SelectAuthor(aString); + m_xFilterCtr->SelectAuthor(aString); } else { - m_pFilterCtr->SelectedAuthorPos(0); + m_xFilterCtr->SelectedAuthorPos(0); } - m_pFilterCtr->CheckRange(aChangeViewSet.HasRange()); + m_xFilterCtr->CheckRange(aChangeViewSet.HasRange()); if ( !aChangeViewSet.GetTheRangeList().empty() ) { const ScRange & rRangeEntry = aChangeViewSet.GetTheRangeList().front(); OUString aRefStr(rRangeEntry.Format(ScRefFlags::RANGE_ABS_3D, pDoc)); - m_pFilterCtr->SetRange(aRefStr); + m_xFilterCtr->SetRange(aRefStr); } - m_pFilterCtr->Enable(); - HighlightHandle(m_pHighlightBox); + m_xFilterCtr->Enable(true); + HighlightHandle(*m_xHighlightBox); } // Set the reference to a cell range selected with the mouse. This is then // shown as the new selection in the reference field. - void ScHighlightChgDlg::SetReference( const ScRange& rRef, ScDocument* pDocP ) { - if ( m_pEdAssign->IsVisible() ) + if (m_xEdAssign->GetWidget()->get_visible()) { if ( rRef.aStart != rRef.aEnd ) - RefInputStart(m_pEdAssign); + RefInputStart(m_xEdAssign.get()); OUString aRefStr(rRef.Format(ScRefFlags::RANGE_ABS_3D, pDocP, pDocP->GetAddressConvention())); - m_pEdAssign->SetRefString( aRefStr ); - m_pFilterCtr->SetRange(aRefStr); + m_xEdAssign->SetRefString( aRefStr ); + m_xFilterCtr->SetRange(aRefStr); } } -bool ScHighlightChgDlg::Close() +void ScHighlightChgDlg::Close() { - return DoClose( ScHighlightChgDlgWrapper::GetChildWindowId() ); + DoClose( ScHighlightChgDlgWrapper::GetChildWindowId() ); } void ScHighlightChgDlg::RefInputDone( bool bForced) { - ScAnyRefDlg::RefInputDone(bForced); - if(bForced || !m_pRbAssign->IsVisible()) + ScAnyRefDlgController::RefInputDone(bForced); + if (bForced || !m_xRbAssign->GetWidget()->get_visible()) { - m_pFilterCtr->SetRange(m_pEdAssign->GetText()); - m_pFilterCtr->SetFocusToRange(); - m_pEdAssign->Hide(); - m_pRbAssign->Hide(); + m_xFilterCtr->SetRange(m_xEdAssign->GetText()); + m_xFilterCtr->SetFocusToRange(); + m_xEdAssign->GetWidget()->hide(); + m_xRbAssign->GetWidget()->hide(); } } @@ -166,25 +163,22 @@ void ScHighlightChgDlg::SetActive() bool ScHighlightChgDlg::IsRefInputMode() const { - return m_pEdAssign->IsVisible(); + return m_xEdAssign->GetWidget()->get_visible(); } -IMPL_LINK( ScHighlightChgDlg, HighlightHandle, Button*, pCb, void ) +IMPL_LINK_NOARG(ScHighlightChgDlg, HighlightHandle, weld::Button&, void) { - if(pCb!=nullptr) + if (m_xHighlightBox->get_active()) + { + m_xFilterCtr->Enable(true); + m_xCbAccept->set_sensitive(true); + m_xCbReject->set_sensitive(true); + } + else { - if(m_pHighlightBox->IsChecked()) - { - m_pFilterCtr->Enable(); - m_pCbAccept->Enable(); - m_pCbReject->Enable(); - } - else - { - m_pFilterCtr->Disable(); - m_pCbAccept->Disable(); - m_pCbReject->Disable(); - } + m_xFilterCtr->Enable(false); + m_xCbAccept->set_sensitive(false); + m_xCbReject->set_sensitive(false); } } @@ -193,43 +187,40 @@ IMPL_LINK( ScHighlightChgDlg, RefHandle, SvxTPFilter*, pRef, void ) if(pRef!=nullptr) { SetDispatcherLock( true ); - m_pEdAssign->Show(); - m_pRbAssign->Show(); - m_pEdAssign->SetText(m_pFilterCtr->GetRange()); - m_pEdAssign->GrabFocus(); - ScAnyRefDlg::RefInputStart(m_pEdAssign, m_pRbAssign); + m_xEdAssign->GetWidget()->show(); + m_xRbAssign->GetWidget()->show(); + m_xEdAssign->SetText(m_xFilterCtr->GetRange()); + m_xEdAssign->GrabFocus(); + ScAnyRefDlgController::RefInputStart(m_xEdAssign.get(), m_xRbAssign.get()); } } -IMPL_LINK( ScHighlightChgDlg, OKBtnHdl, Button*, pOKBtn, void ) +IMPL_LINK_NOARG(ScHighlightChgDlg, OKBtnHdl, weld::Button&, void) { - if (pOKBtn == m_pOkButton) - { - aChangeViewSet.SetShowChanges(m_pHighlightBox->IsChecked()); - aChangeViewSet.SetHasDate(m_pFilterCtr->IsDate()); - SvxRedlinDateMode eMode = m_pFilterCtr->GetDateMode(); - aChangeViewSet.SetTheDateMode( eMode ); - Date aFirstDate( m_pFilterCtr->GetFirstDate() ); - tools::Time aFirstTime( m_pFilterCtr->GetFirstTime() ); - Date aLastDate( m_pFilterCtr->GetLastDate() ); - tools::Time aLastTime( m_pFilterCtr->GetLastTime() ); - aChangeViewSet.SetTheFirstDateTime( DateTime( aFirstDate, aFirstTime ) ); - aChangeViewSet.SetTheLastDateTime( DateTime( aLastDate, aLastTime ) ); - aChangeViewSet.SetHasAuthor(m_pFilterCtr->IsAuthor()); - aChangeViewSet.SetTheAuthorToShow(m_pFilterCtr->GetSelectedAuthor()); - aChangeViewSet.SetHasRange(m_pFilterCtr->IsRange()); - aChangeViewSet.SetShowAccepted(m_pCbAccept->IsChecked()); - aChangeViewSet.SetShowRejected(m_pCbReject->IsChecked()); - aChangeViewSet.SetHasComment(m_pFilterCtr->IsComment()); - aChangeViewSet.SetTheComment(m_pFilterCtr->GetComment()); - ScRangeList aLocalRangeList; - aLocalRangeList.Parse(m_pFilterCtr->GetRange(), pDoc); - aChangeViewSet.SetTheRangeList(aLocalRangeList); - aChangeViewSet.AdjustDateMode( *pDoc ); - pDoc->SetChangeViewSettings(aChangeViewSet); - pViewData->GetDocShell()->PostPaintGridAll(); - Close(); - } + aChangeViewSet.SetShowChanges(m_xHighlightBox->get_active()); + aChangeViewSet.SetHasDate(m_xFilterCtr->IsDate()); + SvxRedlinDateMode eMode = m_xFilterCtr->GetDateMode(); + aChangeViewSet.SetTheDateMode( eMode ); + Date aFirstDate( m_xFilterCtr->GetFirstDate() ); + tools::Time aFirstTime( m_xFilterCtr->GetFirstTime() ); + Date aLastDate( m_xFilterCtr->GetLastDate() ); + tools::Time aLastTime( m_xFilterCtr->GetLastTime() ); + aChangeViewSet.SetTheFirstDateTime( DateTime( aFirstDate, aFirstTime ) ); + aChangeViewSet.SetTheLastDateTime( DateTime( aLastDate, aLastTime ) ); + aChangeViewSet.SetHasAuthor(m_xFilterCtr->IsAuthor()); + aChangeViewSet.SetTheAuthorToShow(m_xFilterCtr->GetSelectedAuthor()); + aChangeViewSet.SetHasRange(m_xFilterCtr->IsRange()); + aChangeViewSet.SetShowAccepted(m_xCbAccept->get_active()); + aChangeViewSet.SetShowRejected(m_xCbReject->get_active()); + aChangeViewSet.SetHasComment(m_xFilterCtr->IsComment()); + aChangeViewSet.SetTheComment(m_xFilterCtr->GetComment()); + ScRangeList aLocalRangeList; + aLocalRangeList.Parse(m_xFilterCtr->GetRange(), pDoc); + aChangeViewSet.SetTheRangeList(aLocalRangeList); + aChangeViewSet.AdjustDateMode( *pDoc ); + pDoc->SetChangeViewSettings(aChangeViewSet); + pViewData->GetDocShell()->PostPaintGridAll(); + response(RET_OK); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/miscdlgs/simpref.cxx b/sc/source/ui/miscdlgs/simpref.cxx index 6260b51bdfb3..0f39e4cc6073 100644 --- a/sc/source/ui/miscdlgs/simpref.cxx +++ b/sc/source/ui/miscdlgs/simpref.cxx @@ -23,6 +23,7 @@ ScSimpleRefDlg::ScSimpleRefDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent) : ScAnyRefDlgController(pB, pCW, pParent, "modules/scalc/ui/simplerefdialog.ui", "SimpleRefDialog") + , bAutoReOpen(true) , bCloseOnButtonUp(false) , bSingleCell(false) , bMultiSelection(false) @@ -45,6 +46,12 @@ ScSimpleRefDlg::~ScSimpleRefDlg() SetDispatcherLock( false ); // deactivate modal mode } +void ScSimpleRefDlg::FillInfo(SfxChildWinInfo& rWinInfo) const +{ + ScAnyRefDlgController::FillInfo(rWinInfo); + rWinInfo.bVisible = bAutoReOpen; +} + void ScSimpleRefDlg::SetRefString(const OUString &rStr) { m_xEdAssign->SetText(rStr); @@ -158,6 +165,7 @@ void ScSimpleRefDlg::RefInputDone( bool bForced) IMPL_LINK_NOARG(ScSimpleRefDlg, OkBtnHdl, weld::Button&, void) { + bAutoReOpen = false; OUString aResult=m_xEdAssign->GetText(); aCloseHdl.Call(&aResult); Link<const OUString&,void> aUnoLink = aDoneHdl; // stack var because this is deleted in DoClose @@ -167,6 +175,7 @@ IMPL_LINK_NOARG(ScSimpleRefDlg, OkBtnHdl, weld::Button&, void) IMPL_LINK_NOARG(ScSimpleRefDlg, CancelBtnHdl, weld::Button&, void) { + bAutoReOpen = false; OUString aResult=m_xEdAssign->GetText(); aCloseHdl.Call(nullptr); Link<const OUString&,void> aUnoLink = aAbortedHdl; // stack var because this is deleted in DoClose diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx index 88b19814d453..cb743915f43a 100644 --- a/sc/source/ui/view/reffact.cxx +++ b/sc/source/ui/view/reffact.cxx @@ -32,23 +32,23 @@ #include <scres.hrc> #include <validate.hxx> -SFX_IMPL_CHILDWINDOW_WITHID(ScNameDlgWrapper, FID_DEFINE_NAME) -SFX_IMPL_CHILDWINDOW_WITHID(ScNameDefDlgWrapper, FID_ADD_NAME ) -SFX_IMPL_CHILDWINDOW_WITHID(ScSolverDlgWrapper, SID_OPENDLG_SOLVE ) -SFX_IMPL_CHILDWINDOW_WITHID(ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER ) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScNameDlgWrapper, FID_DEFINE_NAME) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScNameDefDlgWrapper, FID_ADD_NAME ) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScSolverDlgWrapper, SID_OPENDLG_SOLVE ) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER ) SFX_IMPL_MODELESSDIALOG_WITHID(ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE) SFX_IMPL_MODELESSDIALOG_WITHID(ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE ) -SFX_IMPL_CHILDWINDOW_WITHID(ScTabOpDlgWrapper, SID_OPENDLG_TABOP ) -SFX_IMPL_CHILDWINDOW_WITHID(ScFilterDlgWrapper, SID_FILTER ) -SFX_IMPL_CHILDWINDOW_WITHID(ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER ) -SFX_IMPL_CHILDWINDOW_WITHID(ScDbNameDlgWrapper, SID_DEFINE_DBNAME ) -SFX_IMPL_CHILDWINDOW_WITHID(ScConsolidateDlgWrapper, SID_OPENDLG_CONSOLIDATE) -SFX_IMPL_CHILDWINDOW_WITHID(ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA ) -SFX_IMPL_CHILDWINDOW_WITHID(ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES ) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScTabOpDlgWrapper, SID_OPENDLG_TABOP ) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScFilterDlgWrapper, SID_FILTER ) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER ) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScDbNameDlgWrapper, SID_DEFINE_DBNAME ) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScConsolidateDlgWrapper, SID_OPENDLG_CONSOLIDATE) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA ) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES ) SFX_IMPL_MODELESSDIALOG_WITHID(ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION ) -SFX_IMPL_MODELESSDIALOG_WITHID(ScAcceptChgDlgWrapper, FID_CHG_ACCEPT ) -SFX_IMPL_MODELESSDIALOG_WITHID(ScHighlightChgDlgWrapper, FID_CHG_SHOW ) -SFX_IMPL_CHILDWINDOW_WITHID(ScSimpleRefDlgWrapper, WID_SIMPLE_REF ) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScAcceptChgDlgWrapper, FID_CHG_ACCEPT) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScHighlightChgDlgWrapper, FID_CHG_SHOW ) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScSimpleRefDlgWrapper, WID_SIMPLE_REF ) SFX_IMPL_MODELESSDIALOG_WITHID(ScCondFormatDlgWrapper, WID_CONDFRMT_REF ) SFX_IMPL_CHILDWINDOW_WITHID(ScValidityRefChildWin, SID_VALIDITY_REFERENCE) @@ -256,24 +256,24 @@ void ScSimpleRefDlgWrapper::StartRefInput() // ScAcceptChgDlgWrapper //FIXME: should be moved into ViewShell -ScAcceptChgDlgWrapper::ScAcceptChgDlgWrapper( vcl::Window* pParentP, +ScAcceptChgDlgWrapper::ScAcceptChgDlgWrapper(vcl::Window* pParentP, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo ) : SfxChildWindow( pParentP, nId ) { - ScTabViewShell* pViewShell = - dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); - OSL_ENSURE( pViewShell, "missing view shell :-(" ); - if (pViewShell) - { - SetWindow( VclPtr<ScAcceptChgDlg>::Create( pBindings, this, pParentP, &pViewShell->GetViewData() ) ); - static_cast<ScAcceptChgDlg*>(GetWindow())->Initialize( pInfo ); - } - else - SetWindow( nullptr ); - if (pViewShell && !GetWindow()) - pViewShell->GetViewFrame()->SetChildWindow( nId, false ); + ScTabViewShell* pViewShell = + dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); + OSL_ENSURE( pViewShell, "missing view shell :-(" ); + if (pViewShell) + { + SetController(std::make_shared<ScAcceptChgDlg>(pBindings, this, pParentP->GetFrameWeld(), &pViewShell->GetViewData())); + static_cast<ScAcceptChgDlg*>(GetController().get())->Initialize( pInfo ); + } + else + SetController( nullptr ); + if (pViewShell && !GetController()) + pViewShell->GetViewFrame()->SetChildWindow( nId, false ); } void ScAcceptChgDlgWrapper::ReInitDlg() @@ -282,15 +282,15 @@ void ScAcceptChgDlgWrapper::ReInitDlg() dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); OSL_ENSURE( pViewShell, "missing view shell :-(" ); - if(GetWindow() && pViewShell) + if (GetController() && pViewShell) { - static_cast<ScAcceptChgDlg*>(GetWindow())->ReInit(&pViewShell->GetViewData()); + static_cast<ScAcceptChgDlg*>(GetController().get())->ReInit(&pViewShell->GetViewData()); } } // ScHighlightChgDlgWrapper -IMPL_CHILD_CTOR( ScHighlightChgDlgWrapper, FID_CHG_SHOW ) +IMPL_CONTROLLER_CHILD_CTOR(ScHighlightChgDlgWrapper, FID_CHG_SHOW) namespace { diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 4e94cabc67df..0eebfb583d2f 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -848,19 +848,19 @@ void ScTabView::RemoveHintWindow() } // find window that should not be over the cursor -static vcl::Window* lcl_GetCareWin(SfxViewFrame* pViewFrm) +static weld::Window* lcl_GetCareWin(SfxViewFrame* pViewFrm) { //! also spelling ??? (then set the member variables when calling) // search & replace - if ( pViewFrm->HasChildWindow(SID_SEARCH_DLG) ) + if (pViewFrm->HasChildWindow(SID_SEARCH_DLG)) { SfxChildWindow* pChild = pViewFrm->GetChildWindow(SID_SEARCH_DLG); if (pChild) { - vcl::Window* pWin = pChild->GetWindow(); - if (pWin && pWin->IsVisible()) - return pWin; + auto xDlgController = pChild->GetController(); + if (xDlgController && xDlgController->getDialog()->get_visible()) + return xDlgController->getDialog(); } } @@ -870,9 +870,9 @@ static vcl::Window* lcl_GetCareWin(SfxViewFrame* pViewFrm) SfxChildWindow* pChild = pViewFrm->GetChildWindow(FID_CHG_ACCEPT); if (pChild) { - vcl::Window* pWin = pChild->GetWindow(); - if (pWin && pWin->IsVisible()) - return pWin; + auto xDlgController = pChild->GetController(); + if (xDlgController && xDlgController->getDialog()->get_visible()) + return xDlgController->getDialog(); } } @@ -940,16 +940,18 @@ void ScTabView::AlignToCursor( SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, if ( eMode == SC_FOLLOW_JUMP ) { - vcl::Window* pCare = lcl_GetCareWin( aViewData.GetViewShell()->GetViewFrame() ); + weld::Window* pCare = lcl_GetCareWin( aViewData.GetViewShell()->GetViewFrame() ); if (pCare) { bool bLimit = false; tools::Rectangle aDlgPixel; Size aWinSize; vcl::Window* pWin = GetActiveWin(); - if (pWin) + weld::Window* pFrame = pWin ? pWin->GetFrameWeld() : nullptr; + int x, y, width, height; + if (pFrame && pCare->get_extents_relative_to(*pFrame, x, y, width, height)) { - aDlgPixel = pCare->GetWindowExtentsRelative( pWin ); + aDlgPixel = tools::Rectangle(Point(x, y), Size(width, height)); aWinSize = pWin->GetOutputSizePixel(); // dos the dialog cover the GridWin? if ( aDlgPixel.Right() >= 0 && aDlgPixel.Left() < aWinSize.Width() ) diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index 7282fcbac4ea..46259a8f12a3 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -1154,10 +1154,8 @@ void ScTabViewShell::StartSimpleRefDialog( pWnd->SetRefString( rInitVal ); pWnd->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection ); ScSimpleRefDlgWrapper::SetAutoReOpen( false ); - if (vcl::Window* pWin = pWnd->GetWindow()) - pWin->SetText( rTitle ); - if (auto pWin = pWnd->GetController()) - pWin->set_title(rTitle); + if (auto xWin = pWnd->GetController()) + xWin->set_title(rTitle); pWnd->StartRefInput(); } } @@ -1170,11 +1168,6 @@ void ScTabViewShell::StopSimpleRefDialog() ScSimpleRefDlgWrapper* pWnd = static_cast<ScSimpleRefDlgWrapper*>(pViewFrm->GetChildWindow( nId )); if (pWnd) { - if (vcl::Window* pWin = pWnd->GetWindow()) - { - if (pWin->IsSystemWindow()) - static_cast<SystemWindow*>(pWin)->Close(); // calls abort handler - } if (auto pWin = pWnd->GetController()) pWin->response(RET_CLOSE); } diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index 5aecdbd97733..25d555c76aad 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -173,14 +173,6 @@ VclPtr<SfxModelessDialog> ScTabViewShell::CreateRefDialog( } break; - case FID_CHG_SHOW: - { - // dialog checks, what is in the cell - - pResult = VclPtr<ScHighlightChgDlg>::Create( pB, pCW, pParent, &GetViewData() ); - } - break; - case WID_CONDFRMT_REF: { bool bFound = false; @@ -480,6 +472,12 @@ std::unique_ptr<SfxModelessDialogController> ScTabViewShell::CreateRefDialogCont xResult.reset(new ScOptSolverDlg(pB, pCW, pParent, rViewData.GetDocShell(), aCurPos)); break; } + case FID_CHG_SHOW: + { + // dialog checks, what is in the cell + xResult.reset(new ScHighlightChgDlg(pB, pCW, pParent, &GetViewData())); + break; + } } if (xResult) |