diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-02-26 12:17:45 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-02-28 16:16:24 +0100 |
commit | 5325ce6a3c791bd4a5ee6e71f95a403562ca811c (patch) | |
tree | 6ba582c0887875ceb039b617d1b9344801b2c69c /sc/source/ui/inc | |
parent | 6a3e04abd653cb86550b911b62ca54e2942f957a (diff) |
weld calc navigator
note: non-standard dnd via parent so the treeview triggers the dnd but doesn't
itself strictly speaking drive the dnd, see copying a range from the navigator
where the calc main edit window shows the outline where the copy of the range
from the calc main window will go
Change-Id: Ideecbe779e3d9bb5b392357a93ec25f625180ba8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89597
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source/ui/inc')
-rw-r--r-- | sc/source/ui/inc/content.hxx | 85 | ||||
-rw-r--r-- | sc/source/ui/inc/navipi.hxx | 164 |
2 files changed, 91 insertions, 158 deletions
diff --git a/sc/source/ui/inc/content.hxx b/sc/source/ui/inc/content.hxx index ce290d824c9a..3411d9438228 100644 --- a/sc/source/ui/inc/content.hxx +++ b/sc/source/ui/inc/content.hxx @@ -20,15 +20,16 @@ #ifndef INCLUDED_SC_SOURCE_UI_INC_CONTENT_HXX #define INCLUDED_SC_SOURCE_UI_INC_CONTENT_HXX -#include <vcl/treelistbox.hxx> +#include <vcl/weld.hxx> #include <address.hxx> #include <tools/solar.h> #include <o3tl/enumarray.hxx> -class ScNavigatorDlg; +class ScAreaLink; +class ScLinkTransferObj; class ScDocument; class ScDocShell; -class ScAreaLink; +class ScNavigatorDlg; enum class ScContentId { ROOT, TABLE, RANGENAME, DBAREA, @@ -38,10 +39,13 @@ enum class ScContentId { const sal_uLong SC_CONTENT_NOCHILD = ~0UL; -class ScContentTree : public SvTreeListBox +class ScContentTree { + std::unique_ptr<weld::TreeView> m_xTreeView; + std::unique_ptr<weld::TreeIter> m_xScratchIter; + rtl::Reference<ScLinkTransferObj> m_xTransferObj; VclPtr<ScNavigatorDlg> pParentWindow; - o3tl::enumarray<ScContentId, SvTreeListEntry*> pRootNodes; + o3tl::enumarray<ScContentId, std::unique_ptr<weld::TreeIter>> m_aRootNodes; ScContentId nRootType; // set as Root OUString aManualDoc; // Switched in Navigator (Title) bool bHiddenDoc; // Hidden active? @@ -49,7 +53,9 @@ class ScContentTree : public SvTreeListBox OUString aHiddenTitle; // for display ScDocument* pHiddenDocument; // temporary bool bisInNavigatoeDlg; + bool m_bFreeze; OUString sKeyString; + ImplSVEvent* m_nAsyncMouseReleaseId; o3tl::enumarray<ScContentId, sal_uInt16> pPosList; // for the sequence @@ -84,49 +90,62 @@ class ScContentTree : public SvTreeListBox @param rnRootIndex Root index of specified entry is returned. @param rnChildIndex Index of the entry inside its root is returned (or SC_CONTENT_NOCHILD if entry is root). @param pEntry The entry to examine. */ - void GetEntryIndexes( ScContentId& rnRootIndex, sal_uLong& rnChildIndex, SvTreeListEntry* pEntry ) const; + void GetEntryIndexes(ScContentId& rnRootIndex, sal_uLong& rnChildIndex, weld::TreeIter* pEntry) const; /** Returns the child index of the specified listbox entry. @param pEntry The entry to examine or NULL for the selected entry. @return Index of the entry inside its root or SC_CONTENT_NOCHILD if entry is root. */ - sal_uLong GetChildIndex( SvTreeListEntry* pEntry ) const; - - void DoDrag(); + sal_uLong GetChildIndex(weld::TreeIter* pEntry) const; ScDocument* GetSourceDocument(); - DECL_LINK( ContentDoubleClickHdl, SvTreeListBox*, bool ); - DECL_LINK( ExecDragHdl, void*, void ); - -protected: + void freeze() + { + m_xTreeView->freeze(); + m_bFreeze = true; + } - using SvTreeListBox::ExecuteDrop; + void thaw() + { + m_xTreeView->thaw(); + m_bFreeze = false; + } - virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; - virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; - virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override; - virtual void DragFinished( sal_Int8 nAction ) override; + void LaunchAsyncStoreNavigatorSettings(); - virtual void Command( const CommandEvent& rCEvt ) override; - virtual void RequestHelp( const HelpEvent& rHEvt ) override; - virtual void InitEntry(SvTreeListEntry*,const OUString&,const Image&,const Image&) override; + DECL_LINK(ContentDoubleClickHdl, weld::TreeView&, bool); + DECL_LINK(MouseReleaseHdl, const MouseEvent&, bool); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(AsyncStoreNavigatorSettings, void*, void); + DECL_LINK(CommandHdl, const CommandEvent&, bool); + DECL_LINK(DragBeginHdl, bool&, bool); public: - ScContentTree(vcl::Window* pParent, ScNavigatorDlg* pNavigatorDlg); - virtual ~ScContentTree() override; - virtual void dispose() override; - - OUString getAltLongDescText(SvTreeListEntry* pEntry, bool isAltText) const; - OUString GetEntryAltText( SvTreeListEntry* pEntry ) const override; - OUString GetEntryLongDescription( SvTreeListEntry* pEntry ) const override; + ScContentTree(std::unique_ptr<weld::TreeView> xTreeView, ScNavigatorDlg* pNavigatorDlg); + ~ScContentTree(); - void ObjectFresh( ScContentId nType, const SvTreeListEntry* pEntry = nullptr); + void ObjectFresh(ScContentId nType, const weld::TreeIter* pEntry = nullptr); void SetNavigatorDlgFlag(bool isInNavigateDlg){ bisInNavigatoeDlg=isInNavigateDlg;}; - virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; - virtual void KeyInput( const KeyEvent& rKEvt ) override; - virtual Size GetOptimalSize() const override; - void InitWindowBits( bool bButtons ); + void set_selection_mode(SelectionMode eMode) + { + m_xTreeView->set_selection_mode(eMode); + } + + void set_size_request(int nWidth, int nHeight) + { + m_xTreeView->set_size_request(nWidth, nHeight); + } + + void hide() + { + m_xTreeView->hide(); + } + + void show() + { + m_xTreeView->show(); + } void Refresh( ScContentId nType = ScContentId::ROOT ); diff --git a/sc/source/ui/inc/navipi.hxx b/sc/source/ui/inc/navipi.hxx index 6db896fafe5d..4a6c3ea92d0a 100644 --- a/sc/source/ui/inc/navipi.hxx +++ b/sc/source/ui/inc/navipi.hxx @@ -21,15 +21,11 @@ #define INCLUDED_SC_SOURCE_UI_INC_NAVIPI_HXX #include <vector> -#include <vcl/toolbox.hxx> -#include <vcl/field.hxx> -#include <vcl/lstbox.hxx> #include <vcl/idle.hxx> #include <svl/lstner.hxx> #include <sfx2/childwin.hxx> #include <svx/sidebar/PanelLayout.hxx> #include "content.hxx" -#include <vcl/vclmedit.hxx> class SfxPoolItem; class ScTabViewShell; @@ -48,20 +44,21 @@ enum NavListMode { NAV_LMODE_NONE = 0x4000, NAV_LMODE_AREAS = 0x2000, NAV_LMODE_SCENARIOS = 0x400 }; -class ScScenarioListBox : public ListBox +class ScScenarioWindow { public: - explicit ScScenarioListBox( ScScenarioWindow& rParent ); - virtual ~ScScenarioListBox() override; - - void UpdateEntries( const std::vector<OUString> &aNewEntryList ); - -protected: - virtual void Select() override; - virtual void DoubleClick() override; - virtual bool EventNotify( NotifyEvent& rNEvt ) override; + ScScenarioWindow(weld::Builder& rBuilder, const OUString& rQH_List, const OUString& rQH_Comment); + ~ScScenarioWindow(); + void NotifyState(const SfxPoolItem* pState); + void SetComment(const OUString& rComment) + { + m_xEdComment->set_text(rComment); + } private: + std::unique_ptr<weld::TreeView> m_xLbScenario; + std::unique_ptr<weld::TextView> m_xEdComment; + struct ScenarioEntry { OUString maName; @@ -72,102 +69,25 @@ private: }; typedef ::std::vector< ScenarioEntry > ScenarioList; -private: - const ScenarioEntry* GetSelectedScenarioEntry() const; - - void ExecuteScenarioSlot( sal_uInt16 nSlotId ); - void SelectScenario(); - void EditScenario(); - void DeleteScenario(); - -private: - ScScenarioWindow& mrParent; - ScenarioList maEntries; -}; - -class ScScenarioWindow : public vcl::Window -{ -public: - ScScenarioWindow(vcl::Window* pParent, const OUString& rQH_List, const OUString& rQH_Comment); - virtual ~ScScenarioWindow() override; - virtual void dispose() override; - void NotifyState(const SfxPoolItem* pState); - void SetComment(const OUString& rComment) - { - aEdComment->SetText(rComment); - } - -protected: - virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; - virtual void Resize() override; - -private: - VclPtr<ScScenarioListBox> aLbScenario; - VclPtr<VclMultiLineEdit> aEdComment; -}; + ScenarioList m_aEntries; -class ColumnEdit : public SpinField -{ -public: - ColumnEdit(Window* pParent, WinBits nWinBits); - ~ColumnEdit() override; - void SetNavigatorDlg(ScNavigatorDlg *pNaviDlg) - { - xDlg = pNaviDlg; - } - SCCOL GetCol() const { return nCol; } - void SetCol( SCCOL nColNo ); - -protected: - virtual bool EventNotify( NotifyEvent& rNEvt ) override; - virtual void LoseFocus() override; - virtual void Up() override; - virtual void Down() override; - virtual void First() override; - virtual void Last() override; - virtual void dispose() override; - -private: - VclPtr<ScNavigatorDlg> xDlg; - SCCOL nCol; - - void EvalText(); - void ExecuteCol(); - static SCCOL AlphaToNum ( const ScDocument& rDoc, OUString& rStr ); - static SCCOL NumStrToAlpha ( OUString& rStr ); - static SCCOL NumToAlpha ( SCCOL nColNo, OUString& rStr ); -}; - -class RowEdit : public NumericField -{ -public: - RowEdit(Window* pParent, WinBits nWinBits); - ~RowEdit() override; - void SetNavigatorDlg(ScNavigatorDlg *pNaviDlg) - { - xDlg = pNaviDlg; - } - SCROW GetRow() const { return static_cast<SCROW>(GetValue()); } - void SetRow(SCROW nRow) { SetValue(nRow); } - -protected: - virtual bool EventNotify( NotifyEvent& rNEvt ) override; - virtual Size GetOptimalSize() const override; - virtual void LoseFocus() override; - virtual void dispose() override; - -private: - VclPtr<ScNavigatorDlg> xDlg; + void UpdateEntries(const std::vector<OUString> &rNewEntryList); + void SelectScenario(); + void ExecuteScenarioSlot(sal_uInt16 nSlotId); + void EditScenario(); + void DeleteScenario(); + const ScenarioEntry* GetSelectedScenarioEntry() const; - void ExecuteRow(); + DECL_LINK(SelectHdl, weld::TreeView&, void); + DECL_LINK(DoubleClickHdl, weld::TreeView&, bool); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(ContextMenuHdl, const CommandEvent&, bool); }; class ScNavigatorDlg : public PanelLayout, public SfxListener { friend class ScNavigatorControllerItem; friend class ScNavigatorDialogWrapper; -friend class ColumnEdit; -friend class RowEdit; friend class ScContentTree; private: @@ -175,32 +95,24 @@ private: SfxBindings& rBindings; // must be first member - VclPtr<ColumnEdit> aEdCol; - VclPtr<RowEdit> aEdRow; - VclPtr<ToolBox> aTbxCmd; - VclPtr<vcl::Window> aContentBox; - VclPtr<ScContentTree> aLbEntries; - VclPtr<vcl::Window> aScenarioBox; - VclPtr<ScScenarioWindow> aWndScenarios; - VclPtr<ListBox> aLbDocuments; + std::unique_ptr<weld::SpinButton> m_xEdCol; + std::unique_ptr<weld::SpinButton> m_xEdRow; + std::unique_ptr<weld::Toolbar> m_xTbxCmd1; + std::unique_ptr<weld::Toolbar> m_xTbxCmd2; + std::unique_ptr<ScContentTree> m_xLbEntries; + std::unique_ptr<weld::Widget> m_xScenarioBox; + std::unique_ptr<ScScenarioWindow> m_xWndScenarios; + std::unique_ptr<weld::ComboBox> m_xLbDocuments; + std::unique_ptr<weld::Menu> m_xDragModeMenu; Size aExpandedSize; Idle aContentIdle; - OUString const aStrDragMode; - OUString const aStrDisplay; OUString aStrActive; OUString aStrNotActive; OUString aStrHidden; OUString const aStrActiveWin; - sal_uInt16 nZoomId; - sal_uInt16 nChangeRootId; - sal_uInt16 nDragModeId; - sal_uInt16 nScenarioId; - sal_uInt16 nDownId; - sal_uInt16 nUpId; - sal_uInt16 nDataId; std::unique_ptr<ScArea> pMarkArea; ScViewData* pViewData; @@ -213,9 +125,14 @@ private: std::array<std::unique_ptr<ScNavigatorControllerItem>,CTRL_ITEMS> mvBoundItems; DECL_LINK(TimeHdl, Timer*, void); - DECL_LINK(DocumentSelectHdl, ListBox&, void); - DECL_LINK(ToolBoxSelectHdl, ToolBox*, void); - DECL_LINK(ToolBoxDropdownClickHdl, ToolBox*, void); + DECL_LINK(DocumentSelectHdl, weld::ComboBox&, void); + DECL_LINK(ExecuteRowHdl, weld::Entry&, bool); + DECL_LINK(ExecuteColHdl, weld::Entry&, bool); + DECL_LINK(ToolBoxSelectHdl, const OString&, void); + DECL_LINK(ToolBoxDropdownClickHdl, const OString&, void); + DECL_LINK(MenuSelectHdl, const OString&, void); + DECL_LINK(FormatRowOutputHdl, weld::SpinButton&, void); + DECL_LINK(ParseRowInputHdl, int*, bool); void UpdateButtons(); void SetCurrentCell( SCCOL nCol, SCROW Row ); @@ -245,9 +162,6 @@ private: void SetDropMode(sal_uInt16 nNew); sal_uInt16 GetDropMode() const { return nDropMode; } - const OUString& GetStrDragMode() const { return aStrDragMode; } - const OUString& GetStrDisplay() const { return aStrDisplay; } - void MarkDataArea (); void UnmarkDataArea (); void StartOfDataArea (); |