diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-06-23 11:51:32 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-06-25 20:26:38 +0200 |
commit | 82cb3eb7389b4ff9b3254f8370379cf6fd81322f (patch) | |
tree | 46be9261bcd7a23bb24f85daecfddaf04b2f9881 /svx/source/inc | |
parent | 8f2e93183b22f44a9682ac6644d1626bfb89b516 (diff) |
weld NavigatorTree
Change-Id: I019021fa5a522b1238d74702c9222afdfd7540c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96961
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx/source/inc')
-rw-r--r-- | svx/source/inc/filtnav.hxx | 2 | ||||
-rw-r--r-- | svx/source/inc/fmexch.hxx | 33 | ||||
-rw-r--r-- | svx/source/inc/fmexpl.hxx | 101 | ||||
-rw-r--r-- | svx/source/inc/fmshimp.hxx | 12 |
4 files changed, 77 insertions, 71 deletions
diff --git a/svx/source/inc/filtnav.hxx b/svx/source/inc/filtnav.hxx index f0cda9a442a0..71c4708045c2 100644 --- a/svx/source/inc/filtnav.hxx +++ b/svx/source/inc/filtnav.hxx @@ -214,7 +214,7 @@ inline bool OFilterItemExchange::hasFormat( const DataFlavorExVector& _rFormats class OFilterExchangeHelper : public OLocalExchangeHelper { public: - OFilterExchangeHelper(vcl::Window* _pDragSource) : OLocalExchangeHelper(_pDragSource) { } + OFilterExchangeHelper() : OLocalExchangeHelper() { } OFilterItemExchange* operator->() const { return static_cast<OFilterItemExchange*>(m_xTransferable.get()); } diff --git a/svx/source/inc/fmexch.hxx b/svx/source/inc/fmexch.hxx index 4bffa6c185d0..9916abc32efc 100644 --- a/svx/source/inc/fmexch.hxx +++ b/svx/source/inc/fmexch.hxx @@ -30,6 +30,7 @@ #include <com/sun/star/form/XForms.hpp> #include <rtl/ref.hxx> #include <tools/link.hxx> +#include <vcl/weld.hxx> #include <vcl/window.hxx> #include <svx/svxdllapi.h> @@ -38,14 +39,10 @@ class SvTreeListBox; namespace svxform { - - - typedef ::std::set< SvTreeListEntry* > ListBoxEntrySet; - + typedef ::std::set<std::unique_ptr<weld::TreeIter>> ListBoxEntrySet; //= OLocalExchange - - class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) OLocalExchange : public TransferableHelper + class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) OLocalExchange : public TransferDataContainer { private: Link<OLocalExchange&,void> m_aClipboardListener; @@ -64,8 +61,9 @@ namespace svxform bool isDragging() const { return m_bDragging; } bool isClipboardOwner() const { return m_bClipboardOwner; } + void setDragging(bool bDragging); void startDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions, const GrantAccess& ); - void copyToClipboard( vcl::Window* _pWindow, const GrantAccess& ); + void copyToClipboard(const GrantAccess&); void setClipboardListener( const Link<OLocalExchange&,void>& _rListener ) { m_aClipboardListener = _rListener; } @@ -83,7 +81,7 @@ namespace svxform private: // don't allow this base class method to be called from outside - using TransferableHelper::StartDrag; + using TransferDataContainer::StartDrag; }; @@ -93,16 +91,15 @@ namespace svxform class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) OLocalExchangeHelper { protected: - VclPtr<vcl::Window> m_pDragSource; rtl::Reference<OLocalExchange> m_xTransferable; public: - OLocalExchangeHelper( vcl::Window* _pDragSource ); + OLocalExchangeHelper(); virtual ~OLocalExchangeHelper(); void prepareDrag( ); - void startDrag( sal_Int8 nDragSourceActions ); + void startDrag(vcl::Window* pDragSource, sal_Int8 nDragSourceActions); void copyToClipboard( ) const; bool isDragSource() const { return m_xTransferable.is() && m_xTransferable->isDragging(); } @@ -135,7 +132,7 @@ namespace svxform m_xFormsRoot; // the root of the forms collection where the entries we represent reside // this uniquely identifies the page and the document - SvTreeListEntry* m_pFocusEntry; + bool m_bFocusEntry; protected: // updates m_aCurrentFormats with all formats we currently could supply @@ -151,8 +148,8 @@ namespace svxform inline const DataFlavorExVector& GetDataFlavorExVector() const; - void addSelectedEntry( SvTreeListEntry* _pEntry ); - void setFocusEntry( SvTreeListEntry* _pFocusEntry ); + void addSelectedEntry(std::unique_ptr<weld::TreeIter> xEntry); + void setFocusEntry(bool _bFocusEntry); /** notifies the data transfer object that a certain entry has been removed from the owning tree @@ -162,18 +159,18 @@ namespace svxform @param _pEntry @return the number of entries remaining in the selection. */ - size_t onEntryRemoved( SvTreeListEntry* _pEntry ); + size_t onEntryRemoved(weld::TreeView* pView, weld::TreeIter* _pEntry); void setFormsRoot( const css::uno::Reference< css::form::XForms >& _rxFormsRoot ) { m_xFormsRoot = _rxFormsRoot; } - void buildPathFormat(SvTreeListBox const * pTreeBox, SvTreeListEntry const * pRoot); + void buildPathFormat(const weld::TreeView* pTreeBox, const weld::TreeIter* pRoot); // assembles m_aControlPaths from m_aSelectedEntries // (it is assumed that the entries are sorted in m_aSelectedEntries with respect to the neighbor relationship) - void buildListFromPath(SvTreeListBox const * pTreeBox, SvTreeListEntry* pRoot); + void buildListFromPath(const weld::TreeView* pTreeBox, weld::TreeIter* pRoot); // The reverse way: throws everything out of m_aSelectedEntries and rebuilds it using m_aControlPaths void addHiddenControlsFormat(const css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >& seqInterfaces); @@ -218,7 +215,7 @@ namespace svxform class OControlExchangeHelper : public OLocalExchangeHelper { public: - OControlExchangeHelper(vcl::Window* _pDragSource) : OLocalExchangeHelper(_pDragSource) { } + OControlExchangeHelper() : OLocalExchangeHelper() { } OControlExchange* operator->() const { return static_cast< OControlExchange* >( m_xTransferable.get() ); } OControlExchange& operator*() const { return *static_cast< OControlExchange* >( m_xTransferable.get() ); } diff --git a/svx/source/inc/fmexpl.hxx b/svx/source/inc/fmexpl.hxx index 4d18c2783ef8..6c1022a8dfd4 100644 --- a/svx/source/inc/fmexpl.hxx +++ b/svx/source/inc/fmexpl.hxx @@ -37,8 +37,6 @@ #include <com/sun/star/beans/XPropertyChangeListener.hpp> #include <com/sun/star/container/XIndexContainer.hpp> -#include <vcl/treelistbox.hxx> - #include <svx/fmview.hxx> #include "fmexch.hxx" @@ -134,7 +132,7 @@ private: css::uno::Reference< css::container::XChild > m_xChild; protected: - Image m_aNormalImage; + OUString m_aNormalImage; OUString aText; std::unique_ptr<FmEntryDataList> @@ -153,7 +151,7 @@ public: void SetText( const OUString& rText ){ aText = rText; } void SetParent( FmEntryData* pParentData ){ pParent = pParentData; } - const Image& GetNormalImage() const { return m_aNormalImage; } + const OUString& GetNormalImage() const { return m_aNormalImage; } const OUString& GetText() const { return aText; } FmEntryData* GetParent() const { return pParent; } @@ -242,7 +240,7 @@ class FmControlData : public FmEntryData { css::uno::Reference< css::form::XFormComponent > m_xFormComponent; - Image GetImage() const; + OUString GetImage() const; public: @@ -359,50 +357,61 @@ namespace svxform virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; }; + class NavigatorTree; + + class NavigatorTreeDropTarget : public DropTargetHelper + { + private: + NavigatorTree& m_rTreeView; - typedef std::set<SvTreeListEntry*> SvLBoxEntrySortedArray; + virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; + virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; - class NavigatorTree : public SvTreeListBox, public SfxListener + public: + NavigatorTreeDropTarget(NavigatorTree& rTreeView); + }; + + typedef std::set<std::unique_ptr<weld::TreeIter>> SvLBoxEntrySortedArray; + + class NavigatorTree final : public SfxListener { + std::unique_ptr<weld::TreeView> m_xTreeView; + NavigatorTreeDropTarget m_aDropTargetHelper; + enum DROP_ACTION { DA_SCROLLUP, DA_SCROLLDOWN, DA_EXPANDNODE }; enum SELDATA_ITEMS { SDI_DIRTY, SDI_ALL, SDI_NORMALIZED, SDI_NORMALIZED_FORMARK }; - // when dropping I want to be able to scroll and to expand folders, for this: - AutoTimer m_aDropActionTimer; Timer m_aSynchronizeTimer; // the meta-data about my current selection SvLBoxEntrySortedArray m_arrCurrentSelection; // the entries which, in the view, are currently marked as "cut" (painted semi-transparent) ListBoxEntrySet m_aCutEntries; - ::svxform::OControlExchangeHelper m_aControlExchange; + ::svxform::OControlExchangeHelper m_aControlExchange; std::unique_ptr<NavigatorTreeModel> m_pNavModel; - SvTreeListEntry* m_pRootEntry; - SvTreeListEntry* m_pEditEntry; + std::unique_ptr<weld::TreeIter> m_xRootEntry; + std::unique_ptr<weld::TreeIter> m_xEditEntry; ImplSVEvent * nEditEvent; SELDATA_ITEMS m_sdiState; - Point m_aTimerTriggered; // the position at which the DropTimer was switched on - DROP_ACTION m_aDropActionType; sal_uInt16 m_nSelectLock; sal_uInt16 m_nFormsSelected; sal_uInt16 m_nControlsSelected; sal_uInt16 m_nHiddenControls; // (the number is included in m_nControlsSelected) - unsigned short m_aTimerCounter; - bool m_bDragDataDirty : 1; // ditto bool m_bPrevSelectionMixed : 1; bool m_bRootSelected : 1; bool m_bInitialUpdate : 1; // am I the first time in the UpdateContent? bool m_bKeyboardCut : 1; + bool m_bEditing : 1; - FmControlData* NewControl( const OUString& rServiceName, SvTreeListEntry const * pParentEntry, bool bEditName ); - void NewForm( SvTreeListEntry const * pParentEntry ); - SvTreeListEntry* Insert( FmEntryData* pEntryData, sal_uLong nRelPos ); + FmControlData* NewControl(const OUString& rServiceName, const weld::TreeIter& rParentEntry, bool bEditName); + void NewForm(const weld::TreeIter& rParentEntry); + std::unique_ptr<weld::TreeIter> Insert(FmEntryData* pEntryData, int nRelPos); void Remove( FmEntryData* pEntryData ); @@ -437,27 +446,29 @@ namespace svxform void UnlockSelectionHandling() { --m_nSelectLock; } bool IsSelectionHandlingLocked() const { return m_nSelectLock>0; } + bool IsEditingActive() const { return m_bEditing; } + static bool IsHiddenControl(FmEntryData const * pEntryData); + DECL_LINK( KeyInputHdl, const KeyEvent&, bool ); + DECL_LINK( PopupMenuHdl, const CommandEvent&, bool ); + + DECL_LINK(EditingEntryHdl, const weld::TreeIter&, bool); + typedef std::pair<const weld::TreeIter&, OUString> IterString; + DECL_LINK(EditedEntryHdl, const IterString&, bool); + DECL_LINK( OnEdit, void*, void ); - DECL_LINK( OnDropActionTimer, Timer*, void ); - DECL_LINK( OnEntrySelDesel, SvTreeListBox*, void ); + DECL_LINK( OnEntrySelDesel, weld::TreeView&, void ); DECL_LINK( OnSynchronizeTimer, Timer*, void ); DECL_LINK( OnClipboardAction, OLocalExchange&, void ); - protected: - virtual void Command( const CommandEvent& rEvt ) override; - - 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; + DECL_LINK( DragBeginHdl, bool&, bool ); public: - NavigatorTree(vcl::Window* pParent ); + NavigatorTree(std::unique_ptr<weld::TreeView> xTreeView); virtual ~NavigatorTree() override; - virtual void dispose() override; void Clear(); void UpdateContent( FmFormShell* pFormShell ); @@ -465,31 +476,28 @@ namespace svxform void MarkViewObj( FmControlData const * pControlData ); void UnmarkAllViewObj(); - static bool IsFormEntry( SvTreeListEntry const * pEntry ); - static bool IsFormComponentEntry( SvTreeListEntry const * pEntry ); + void GrabFocus() { m_xTreeView->grab_focus(); } + + bool IsFormEntry(const weld::TreeIter& rEntry); + bool IsFormComponentEntry(const weld::TreeIter& rEntry); OUString GenerateName( FmEntryData const * pEntryData ); NavigatorTreeModel* GetNavModel() const { return m_pNavModel.get(); } - SvTreeListEntry* FindEntry( FmEntryData* pEntryData ); + std::unique_ptr<weld::TreeIter> FindEntry(FmEntryData* pEntryData); - virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ) override; - virtual bool Select( SvTreeListEntry* pEntry, bool bSelect=true ) override; - virtual bool EditingEntry( SvTreeListEntry* pEntry, Selection& ) override; virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; - virtual void KeyInput( const KeyEvent& rKEvt ) override; - virtual void ModelHasRemoved( SvTreeListEntry* _pEntry ) override; + weld::TreeView& get_widget() { return *m_xTreeView; } - using SvTreeListBox::Insert; - using SvTreeListBox::ExecuteDrop; - using SvTreeListBox::Select; + sal_Int8 AcceptDrop(const AcceptDropEvent& rEvt); + sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt); private: - sal_Int8 implAcceptDataTransfer( const DataFlavorExVector& _rFlavors, sal_Int8 _nAction, SvTreeListEntry* _pTargetEntry, bool _bDnD ); + sal_Int8 implAcceptDataTransfer( const DataFlavorExVector& _rFlavors, sal_Int8 _nAction, weld::TreeIter* _pTargetEntry, bool _bDnD ); sal_Int8 implExecuteDataTransfer( const OControlTransferData& _rData, sal_Int8 _nAction, const Point& _rDropPos, bool _bDnD ); - sal_Int8 implExecuteDataTransfer( const OControlTransferData& _rData, sal_Int8 _nAction, SvTreeListEntry* _pTargetEntry, bool _bDnD ); + sal_Int8 implExecuteDataTransfer( const OControlTransferData& _rData, sal_Int8 _nAction, weld::TreeIter* _pTargetEntry, bool _bDnD ); // check if a cut, copy, or drag operation can be started in the current situation bool implAllowExchange( sal_Int8 _nAction, bool* _pHasNonHidden = nullptr ); @@ -499,6 +507,8 @@ namespace svxform // fills m_aControlExchange in preparation of a DnD or clipboard operation bool implPrepareExchange( sal_Int8 _nAction ); + void ModelHasRemoved(weld::TreeIter* _pEntry); + void doPaste(); void doCopy(); void doCut(); @@ -510,10 +520,10 @@ namespace svxform class NavigatorFrame : public SfxDockingWindow, public SfxControllerItem { private: - VclPtr< ::svxform::NavigatorTree> m_pNavigatorTree; + std::unique_ptr<NavigatorTree> m_xNavigatorTree; +// VclPtr< ::svxform::NavigatorTree> m_pNavigatorTree; protected: - virtual void Resize() override; virtual bool Close() override; virtual void GetFocus() override; virtual Size CalcDockingSize( SfxChildAlignment ) override; @@ -540,11 +550,8 @@ namespace svxform SfxChildWinInfo *pInfo ); SFX_DECL_CHILDWINDOW( NavigatorFrameManager ); }; - - } - #endif // INCLUDED_SVX_SOURCE_INC_FMEXPL_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmshimp.hxx b/svx/source/inc/fmshimp.hxx index 8bba0fbefe20..b36ff93b8cfd 100644 --- a/svx/source/inc/fmshimp.hxx +++ b/svx/source/inc/fmshimp.hxx @@ -34,8 +34,6 @@ #include <com/sun/star/beans/XPropertyChangeListener.hpp> #include <com/sun/star/beans/PropertyChangeEvent.hpp> #include <com/sun/star/form/runtime/FeatureState.hpp> -#include <vcl/builder.hxx> -#include <vcl/menu.hxx> #include <vcl/timer.hxx> #include <vcl/window.hxx> #include <sfx2/shell.hxx> @@ -87,6 +85,10 @@ namespace o3tl { template<> struct typed_flags<LoadFormsFlags> : is_typed_flags<LoadFormsFlags, 0x0003> {}; } +namespace weld { + class Menu; +} + // a class iterating through all fields of a form which are bound to a field // sub forms are ignored, grid columns (where the grid is a direct child of the form) are included class FmXBoundFormFieldIterator : public ::comphelper::IndexAccessIterator @@ -404,13 +406,13 @@ public: SAL_DLLPRIVATE void startFiltering_Lock(); SAL_DLLPRIVATE void stopFiltering_Lock(bool bSave); - // a menu that contains all ControlConversion entries - SAL_DLLPRIVATE static std::unique_ptr<VclBuilder> GetConversionMenu_Lock(); + // fills rMenu to be a menu that contains all ControlConversion entries + SAL_DLLPRIVATE static void GetConversionMenu_Lock(weld::Menu& rMenu); /// checks whether a given control conversion slot can be applied to the current selection SAL_DLLPRIVATE bool canConvertCurrentSelectionToControl_Lock(const OString& rIdent); /// enables or disables all conversion slots in a menu, according to the current selection - SAL_DLLPRIVATE void checkControlConversionSlotsForCurrentSelection_Lock(Menu& rMenu); + SAL_DLLPRIVATE void checkControlConversionSlotsForCurrentSelection_Lock(weld::Menu& rMenu); /// executes a control conversion slot for a given object SAL_DLLPRIVATE bool executeControlConversionSlot_Lock(const css::uno::Reference< css::form::XFormComponent >& _rxObject, const OString& rIdent); /** executes a control conversion slot for the current selection |