summaryrefslogtreecommitdiff
path: root/sd/source/ui/inc/sdtreelb.hxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-02-19 13:22:19 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-02-26 17:24:59 +0100
commit42f281c56e0c06327fa382c0984ecf2e8c21e414 (patch)
treee6b7a627d8d2ed88b43cf4d624efd47da6f3b36d /sd/source/ui/inc/sdtreelb.hxx
parent96513a30a8c5782444ffb5691bbed13bd61114d9 (diff)
weld impress navigator
complicated by the effort to keep the non-standard behaviour of commit f3c68cdf8f6a0273c62b493552f78af0138a44e8 Date: Wed Feb 21 17:27:53 2018 +0100 tdf#115873 sd navigator: allow selecting but not focusing on objects and the self-dnd code Change-Id: I29c224739463d1d44690f30ed29db3fe2b16b4a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89045 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd/source/ui/inc/sdtreelb.hxx')
-rw-r--r--sd/source/ui/inc/sdtreelb.hxx383
1 files changed, 149 insertions, 234 deletions
diff --git a/sd/source/ui/inc/sdtreelb.hxx b/sd/source/ui/inc/sdtreelb.hxx
index dce6c27e11a2..c2b3e96cd681 100644
--- a/sd/source/ui/inc/sdtreelb.hxx
+++ b/sd/source/ui/inc/sdtreelb.hxx
@@ -22,7 +22,6 @@
#include <pres.hxx>
#include <sddllapi.h>
-#include <vcl/treelistbox.hxx>
#include <vcl/weld.hxx>
#include <svl/urlbmk.hxx>
#include <tools/ref.hxx>
@@ -52,260 +51,59 @@ namespace svt {
class AcceleratorExecute;
}
-/**
- * Effect-Tab-Dialog
- */
-class SD_DLLPUBLIC SdPageObjsTLB final : public SvTreeListBox
+class SdPageObjsTLVDropTarget : public DropTargetHelper
{
- static bool SAL_DLLPRIVATE bIsInDrag; ///< static, in the case the navigator is deleted in ExecuteDrag
-
- ::std::unique_ptr< ::svt::AcceleratorExecute> m_pAccel;
-
-public:
-
- // nested class to implement the TransferableHelper
- class SAL_DLLPRIVATE SdPageObjsTransferable : public SdTransferable
- {
- public:
- SdPageObjsTransferable(
- SdPageObjsTLB& rParent,
- const INetBookmark& rBookmark,
- ::sd::DrawDocShell& rDocShell,
- NavigatorDragType eDragType );
- ::sd::DrawDocShell& GetDocShell() const { return mrDocShell;}
- NavigatorDragType GetDragType() const { return meDragType;}
-
- static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
- static SdPageObjsTransferable* getImplementation( const css::uno::Reference< css::uno::XInterface >& rxData ) throw();
- /** Return a temporary transferable data flavor that is used
- internally in the navigator for reordering entries. Its
- lifetime ends with the office application.
- */
- static SotClipboardFormatId GetListBoxDropFormatId();
-
- private:
- /** Temporary drop flavor id that is used internally in the
- navigator.
- */
- static SotClipboardFormatId mnListBoxDropFormatId;
-
- SdPageObjsTLB& mrParent;
- INetBookmark const maBookmark;
- ::sd::DrawDocShell& mrDocShell;
- NavigatorDragType const meDragType;
- virtual ~SdPageObjsTransferable() override;
-
- virtual void AddSupportedFormats() override;
- virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
- virtual void DragFinished( sal_Int8 nDropAction ) override;
-
- virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override;
- };
-
- friend class SdPageObjsTLB::SdPageObjsTransferable;
-
- /** Determine whether the specified page belongs to the current show
- which is either the standard show or a custom show.
- @param pPage
- Pointer to the page for which to check whether it belongs to the
- show.
- @return
- Returns <FALSE/> if there is no custom show or if the current
- show does not contain the specified page at least once.
- */
- bool PageBelongsToCurrentShow (const SdPage* pPage) const;
-
private:
+ weld::TreeView& m_rTreeView;
- VclPtr<SdNavigatorWin> mpNavigator;
- const SdDrawDocument* mpDoc;
- SdDrawDocument* mpBookmarkDoc;
- SfxMedium* mpMedium;
- SfxMedium* mpOwnMedium;
- Image const maImgOle;
- Image const maImgGraphic;
- bool mbLinkableSelected;
- OUString maDocName;
- ::sd::DrawDocShellRef mxBookmarkDocShRef; ///< for the loading of bookmarks
- std::vector<OUString> maTreeItem;
- bool mbSaveTreeItemState;
- OUString maSelectionEntryText;
-
- // DragSourceHelper
- virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override;
-
- // DropTargetHelper
- virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
- virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
-
- virtual void RequestingChildren( SvTreeListEntry* pParent ) override;
-
- void DoDrag();
- void OnDragFinished();
-
- /** Return the name of the object. When the object has no user supplied
- name and the bCreate flag is <TRUE/> then a name is created
- automatically. Additionally the mbShowAllShapes flag is taken into
- account when there is no user supplied name. When this flag is
- <FALSE/> then no name is created.
- @param pObject
- When this is NULL then an empty string is returned, regardless
- of the value of bCreate.
- @param bCreate
- This flag controls for objects without user supplied name
- whether a name is created. When a name is created then this
- name is not stored in the object.
- */
- OUString GetObjectName (
- const SdrObject* pObject,
- const bool bCreate = true) const;
- void CloseBookmarkDoc();
- DECL_LINK(ExecDragHdl, void*, void);
-
- /** Handle the reordering of entries in the navigator. This method
- reorders both the involved shapes in their page as well as the
- associated list box entries.
- */
- virtual TriState NotifyMoving(
- SvTreeListEntry* pTarget,
- SvTreeListEntry* pEntry,
- SvTreeListEntry*& rpNewParent,
- sal_uLong& rNewChildPos) override;
-
- using Window::GetDropTarget;
- virtual SvTreeListEntry* GetDropTarget (const Point& rLocation) override;
- virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&) override;
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
public:
+ SdPageObjsTLVDropTarget(weld::TreeView& rTreeView);
+};
- SdPageObjsTLB(vcl::Window* pParent, WinBits nStyle);
- virtual ~SdPageObjsTLB() override;
- virtual void dispose() override;
-
- // helper function for GetEntryAltText and GetEntryLongDescription
- OUString getAltLongDescText( SvTreeListEntry* pEntry , bool isAltText) const;
- OUString GetEntryAltText( SvTreeListEntry* pEntry ) const override;
- OUString GetEntryLongDescription( SvTreeListEntry* pEntry ) const override;
- virtual void SelectHdl() override;
- virtual void KeyInput( const KeyEvent& rKEvt ) override;
- void MouseButtonDown(const MouseEvent& rMEvt) override;
-
- void SetViewFrame( const SfxViewFrame* pViewFrame );
-
- void Fill( const SdDrawDocument*, bool bAllPages, const OUString& rDocName );
- void Fill( const SdDrawDocument*, SfxMedium* pSfxMedium, const OUString& rDocName );
- void SetShowAllShapes (const bool bShowAllShapes, const bool bFill);
- bool GetShowAllShapes() const { return mbShowAllShapes;}
- bool IsNavigationGrabsFocus() const { return mbNavigationGrabsFocus; }
- bool IsEqualToDoc( const SdDrawDocument* pInDoc );
- /// Visits rList recursively and tries to advance pEntry accordingly.
- bool IsEqualToShapeList(SvTreeListEntry*& pEntry, const SdrObjList& rList,
- const OUString& rListName);
- bool HasSelectedChildren( const OUString& rName );
- bool SelectEntry( const OUString& rName );
- OUString GetSelectedEntry() const;
-
- //Mark Current Entry
- void SetSdNavigator(SdNavigatorWin* pNavigator);
-
- void Clear();
- void SetSaveTreeItemStateFlag(bool bState){mbSaveTreeItemState = bState;}
- void SaveExpandedTreeItemState(SvTreeListEntry* pEntry, std::vector<OUString>& vectTreeItem);
-
- SdDrawDocument* GetBookmarkDoc(SfxMedium* pMedium = nullptr);
-
- bool IsLinkableSelected() const { return mbLinkableSelected; }
-
- static bool IsInDrag();
- using SvTreeListBox::ExecuteDrop;
-
- using SvTreeListBox::SelectEntry;
+class SD_DLLPUBLIC SdPageObjsTLV
+{
+private:
+ static bool SAL_DLLPRIVATE bIsInDrag; ///< static, in the case the navigator is deleted in ExecuteDrag
- /** Return the view shell that is linked to the given doc shell.
- Call this method when the there is a chance that the doc shell
- has been disconnected from the view shell (but not the other
- way round.)
- @return
- May return <NULL/> when the link between view shell and
- doc shell has been severed.
- */
- static ::sd::ViewShell* GetViewShellForDocShell (::sd::DrawDocShell &rDocShell);
+ std::unique_ptr<weld::TreeView> m_xTreeView;
+ std::unique_ptr<SdPageObjsTLVDropTarget> m_xDropTargetHelper;
+ std::unique_ptr<::svt::AcceleratorExecute> m_xAccel;
+ VclPtr<SdNavigatorWin> m_xNavigator;
+ const SdDrawDocument* m_pDoc;
+ SdDrawDocument* m_pBookmarkDoc;
+ SfxMedium* m_pMedium;
+ SfxMedium* m_pOwnMedium;
+ bool m_bLinkableSelected;
+ bool m_bShowAllShapes;
-private:
- /** This flag controls whether all shapes are shown as children of pages
- and group shapes or only the named shapes.
- */
- bool mbShowAllShapes;
/** This flag controls whether to show all pages.
*/
- bool mbShowAllPages;
+ bool m_bShowAllPages;
+
/**
* If changing the selection should also result in navigating to the
* relevant shape.
*/
- bool mbSelectionHandlerNavigates;
+ bool m_bSelectionHandlerNavigates;
+
/**
* If navigation should not only select the relevant shape but also change
* focus to it.
*/
- bool mbNavigationGrabsFocus;
+ bool m_bNavigationGrabsFocus;
- /** Return <TRUE/> when the current transferable may be dropped at the
- given list box entry.
- */
- bool IsDropAllowed (SvTreeListEntry const * pEntry);
+ SelectionMode m_eSelectionMode;
- /** This inner class is defined in sdtreelb.cxx and is basically a
- container for the icons used in the list box for the entries.
- */
- class SAL_DLLPRIVATE IconProvider;
+ ImplSVEvent* m_nSelectEventId;
+ ImplSVEvent* m_nRowActivateEventId;
- /** Add one list box entry for the parent of the given shapes and one child entry for
- each of the given shapes.
- @param rList
- The container of shapes that are to be inserted.
- @param pShape
- The parent shape or NULL when the parent is a page.
- @param rsName
- The name to be displayed for the new parent node.
- @param bIsExcluded
- Some pages can be excluded (from the show?).
- @param pParentEntry
- The parent entry of the new parent entry.
- @param rIconProvider
- Icons used to visualize the different shape and page types.
- */
- void AddShapeList (
- const SdrObjList& rList,
- SdrObject* pShape,
- const OUString& rsName,
- const bool bIsExcluded,
- SvTreeListEntry* pParentEntry,
- const IconProvider& rIconProvider);
-
- /** Add the given object to a transferable object so that the object can
- be dragged and dropped without having a name.
- */
- void AddShapeToTransferable (
- SdTransferable& rTransferable,
- SdrObject& rObject) const;
-};
-
-class SD_DLLPUBLIC SdPageObjsTLV
-{
-private:
- std::unique_ptr<weld::TreeView> m_xTreeView;
- std::unique_ptr<::svt::AcceleratorExecute> m_xAccel;
- const SdDrawDocument* m_pDoc;
- SdDrawDocument* m_pBookmarkDoc;
- SfxMedium* m_pMedium;
- bool m_bLinkableSelected;
- /** This flag controls whether to show all pages.
- */
- bool m_bShowAllPages;
OUString m_aDocName;
::sd::DrawDocShellRef m_xBookmarkDocShRef; ///< for the loading of bookmarks
Link<weld::TreeView&, void> m_aChangeHdl;
+ Link<weld::TreeView&, bool> m_aRowActivatedHdl;
/** Return the name of the object. When the object has no user supplied
name and the bCreate flag is <TRUE/> then a name is created
@@ -315,13 +113,24 @@ private:
@param pObject
When this is NULL then an empty string is returned, regardless
of the value of bCreate.
+ @param bCreate
+ This flag controls for objects without user supplied name
+ whether a name is created. When a name is created then this
+ name is not stored in the object.
*/
- static OUString GetObjectName (const SdrObject* pObject);
+ OUString GetObjectName (
+ const SdrObject* pObject,
+ const bool bCreate = true) const;
void CloseBookmarkDoc();
DECL_LINK(RequestingChildrenHdl, const weld::TreeIter&, bool);
DECL_LINK(SelectHdl, weld::TreeView&, void);
+ DECL_LINK(AsyncSelectHdl, void*, void);
+ DECL_LINK(RowActivatedHdl, weld::TreeView&, bool);
+ DECL_LINK(AsyncRowActivatedHdl, void*, void);
+ DECL_LINK(DragBeginHdl, weld::TreeView&, bool);
+ DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
/** Determine whether the specified page belongs to the current show
which is either the standard show or a custom show.
@@ -334,6 +143,12 @@ private:
*/
bool PageBelongsToCurrentShow (const SdPage* pPage) const;
+ bool DoDrag();
+ static void OnDragFinished();
+
+ // DragSourceHelper
+ bool StartDrag();
+
public:
SdPageObjsTLV(std::unique_ptr<weld::TreeView> xTreeview);
@@ -349,6 +164,11 @@ public:
m_xTreeView->show();
}
+ void grab_focus()
+ {
+ m_xTreeView->grab_focus();
+ }
+
void set_size_request(int nWidth, int nHeight)
{
m_xTreeView->set_size_request(nWidth, nHeight);
@@ -359,6 +179,11 @@ public:
return m_xTreeView->get_approximate_digit_width();
}
+ DECL_LINK(MousePressHdl, const MouseEvent&, bool);
+ DECL_LINK(MouseReleaseHdl, const MouseEvent&, bool);
+
+ void Select();
+
int get_height_rows(int nRows) const
{
return m_xTreeView->get_height_rows(nRows);
@@ -366,9 +191,21 @@ public:
void set_selection_mode(SelectionMode eMode)
{
+ m_eSelectionMode = eMode;
m_xTreeView->set_selection_mode(eMode);
}
+ SelectionMode get_selection_mode() const
+ {
+ return m_eSelectionMode;
+ }
+
+ void connect_row_activated(const Link<weld::TreeView&, bool>& rLink)
+ {
+ m_aRowActivatedHdl = rLink;
+ }
+
+ bool HasSelectedChildren(const OUString& rName);
bool SelectEntry(const OUString& rName);
OUString get_selected_text() const
@@ -381,6 +218,11 @@ public:
return m_xTreeView->get_selected(nullptr);
}
+ int count_selected_rows() const
+ {
+ return m_xTreeView->count_selected_rows();
+ }
+
void connect_changed(const Link<weld::TreeView&, void>& rLink)
{
m_aChangeHdl = rLink;
@@ -413,9 +255,30 @@ public:
void SetViewFrame(const SfxViewFrame* pViewFrame);
- void Fill(const SdDrawDocument*, const OUString& rDocName);
+ void Fill(const SdDrawDocument*, bool bAllPages, const OUString& rDocName);
void Fill(const SdDrawDocument*, SfxMedium* pSfxMedium, const OUString& rDocName);
+ void SetShowAllShapes (const bool bShowAllShapes, const bool bFill);
+ bool GetShowAllShapes() const { return m_bShowAllShapes; }
+
+ bool IsNavigationGrabsFocus() const { return m_bNavigationGrabsFocus; }
+ bool IsEqualToDoc(const SdDrawDocument* pInDoc);
+ /// Visits rList recursively and tries to advance rEntry accordingly.
+ bool IsEqualToShapeList(std::unique_ptr<weld::TreeIter>& rEntry, const SdrObjList& rList,
+ const OUString& rListName);
+
+ static bool IsInDrag();
+
+ /** Return the view shell that is linked to the given doc shell.
+ Call this method when the there is a chance that the doc shell
+ has been disconnected from the view shell (but not the other
+ way round.)
+ @return
+ May return <NULL/> when the link between view shell and
+ doc shell has been severed.
+ */
+ static ::sd::ViewShell* GetViewShellForDocShell (::sd::DrawDocShell &rDocShell);
+
/** Add one list box entry for the parent of the given shapes and one child entry for
each of the given shapes.
@param rList
@@ -436,13 +299,20 @@ public:
const bool bIsExcluded,
const weld::TreeIter* pParentEntry);
+ /** Add the given object to a transferable object so that the object can
+ be dragged and dropped without having a name.
+ */
+ void AddShapeToTransferable (
+ SdTransferable& rTransferable,
+ SdrObject& rObject) const;
+
/** return selected entries
nDepth == 0 -> pages
nDepth == 1 -> objects */
std::vector<OUString> GetSelectEntryList(const int nDepth) const;
- SdDrawDocument* GetBookmarkDoc();
+ SdDrawDocument* GetBookmarkDoc(SfxMedium* pMedium = nullptr);
bool IsLinkableSelected() const { return m_bLinkableSelected; }
@@ -456,10 +326,55 @@ public:
m_xTreeView->insert(pParent, -1, &rName, &rId, nullptr, nullptr, &rExpander, false, pEntry);
}
+ //Mark Current Entry
+ void SetSdNavigator(SdNavigatorWin* pNavigator);
+
void clear()
{
m_xTreeView->clear();
}
+
+ // nested class to implement the TransferableHelper
+ class SAL_DLLPRIVATE SdPageObjsTransferable : public SdTransferable
+ {
+ public:
+ SdPageObjsTransferable(
+ const INetBookmark& rBookmark,
+ ::sd::DrawDocShell& rDocShell,
+ NavigatorDragType eDragType );
+ ::sd::DrawDocShell& GetDocShell() const { return mrDocShell;}
+ NavigatorDragType GetDragType() const { return meDragType;}
+
+ static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
+ static SdPageObjsTransferable* getImplementation( const css::uno::Reference< css::uno::XInterface >& rxData ) throw();
+ /** Return a temporary transferable data flavor that is used
+ internally in the navigator for reordering entries. Its
+ lifetime ends with the office application.
+ */
+ static SotClipboardFormatId GetListBoxDropFormatId();
+
+ private:
+ /** Temporary drop flavor id that is used internally in the
+ navigator.
+ */
+ static SotClipboardFormatId mnListBoxDropFormatId;
+
+ INetBookmark const maBookmark;
+ ::sd::DrawDocShell& mrDocShell;
+ NavigatorDragType const meDragType;
+ virtual ~SdPageObjsTransferable() override;
+
+ virtual void AddSupportedFormats() override;
+ virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
+ virtual void DragFinished( sal_Int8 nDropAction ) override;
+
+ virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override;
+ };
+
+ friend class SdPageObjsTLV::SdPageObjsTransferable;
+
+private:
+ rtl::Reference<SdPageObjsTransferable> m_xHelper;
};
#endif // INCLUDED_SD_SOURCE_UI_INC_SDTREELB_HXX