42#include <bitmaps.hlst>
48#include <com/sun/star/embed/XEmbedPersist.hpp>
49#include <com/sun/star/embed/XEmbeddedObject.hpp>
50#include <com/sun/star/frame/Desktop.hpp>
88 maBookmark(
std::move( aBookmark )),
89 mrDocShell( rDocShell ),
90 meDragType( eDragType )
100 AddFormat(SotClipboardFormatId::NETSCAPE_BOOKMARK);
101 AddFormat(SotClipboardFormatId::TREELISTBOX);
102 AddFormat(GetListBoxDropFormatId());
110 case SotClipboardFormatId::NETSCAPE_BOOKMARK:
111 SetINetBookmark( maBookmark, rFlavor );
114 case SotClipboardFormatId::TREELISTBOX:
116 css::uno::Any aTreeListBoxData;
117 SetAny(aTreeListBoxData);
142 return mnListBoxDropFormatId;
150 bool bChildren =
false;
154 std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator());
167 std::unique_ptr<weld::TreeIter> xParent(
m_xTreeView->make_iterator(&rEntry));
168 while (!bChildren &&
m_xTreeView->iter_parent(*xParent))
169 bChildren =
m_xTreeView->iter_compare(*xParent, *xEntry) == 0;
184 const bool bShowAllShapes,
185 const bool bFillList)
203 std::u16string_view rListName)
209 if (rListName !=
aName)
225 if (!aObjectName.isEmpty())
232 if (aObjectName !=
aName)
273 std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator());
278 sal_uInt16 nPage = 0;
281 while( nPage < nMaxPages )
284 if (pPage->
GetPageKind() == eDrawViewShellPageKind)
302 if (rCEvt.GetCommand() == CommandEventId::ContextMenu)
307 if (std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator());
308 rCEvt.IsMouseEvent() &&
m_xTreeView->get_dest_row_at_pos(
309 rCEvt.GetMousePosPixel(), xEntry.get(),
false))
335 std::unique_ptr<weld::TreeIter> xCursor(
m_xTreeView->make_iterator());
375 rUnsetDragIcon =
false;
383 std::unique_ptr<weld::TreeIter> xSource(rTreeView.
make_iterator());
387 std::unique_ptr<weld::TreeIter> xSourceParent(rTreeView.
make_iterator(xSource.get()));
388 bool bSourceHasParent = rTreeView.
iter_parent(*xSourceParent);
390 if (!bSourceHasParent)
393 SdrObject* pSourceObject = weld::fromId<SdrObject*>(rTreeView.
get_id(*xSource));
394 if (pSourceObject ==
reinterpret_cast<SdrObject*
>(1))
395 pSourceObject =
nullptr;
430 if (pViewShell ==
nullptr)
432 OSL_ASSERT(pViewShell!=
nullptr);
436 if (pView ==
nullptr)
438 OSL_ASSERT(pView!=
nullptr);
446 std::unique_ptr<weld::TreeIter> xEntry =
m_xTreeView->make_iterator();
447 bool bUserData =
m_xTreeView->get_cursor(xEntry.get());
450 sal_Int64 nUserData = bUserData ?
m_xTreeView->get_id(*xEntry).toInt64() : 0;
488 : DropTargetHelper(rTreeView.get_drop_target())
489 , m_rTreeView(rTreeView)
490 , m_pSdrView(nullptr)
562 if (nIterCompare == 0)
570 if (pSourceObject ==
reinterpret_cast<SdrObject*
>(1))
571 pSourceObject =
nullptr;
572 if (pTargetObject ==
reinterpret_cast<SdrObject*
>(1))
573 pTargetObject =
nullptr;
575 if (pTargetObject !=
nullptr && pSourceObject !=
nullptr &&
m_pSdrView)
603 if (pSourceParentObject ==
reinterpret_cast<SdrObject*
>(1))
614 if (pTargetParentObject ==
reinterpret_cast<SdrObject*
>(1))
636 bool bIsDescriptorFillingPending (
true);
639 if (pOleObject !=
nullptr && pOleObject->
GetObjRef().is())
644 uno::Reference< embed::XEmbedPersist > xPersObj (pOleObject->
GetObjRef(), uno::UNO_QUERY );
645 if (xPersObj.is() && xPersObj->hasEntry())
652 bIsDescriptorFillingPending =
false;
655 catch( uno::Exception& )
661 if (bIsDescriptorFillingPending && pDocShell!=
nullptr)
667 pObjectDescriptor->maDragStartPos = aDragPos;
668 if (pDocShell !=
nullptr)
671 pObjectDescriptor->maDisplayName.clear();
681 if (pViewShell !=
nullptr)
688 uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext());
690 uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(xContext);
692 if ( ! xDesktop.is())
695 uno::Reference<container::XIndexAccess> xFrameAccess = xDesktop->getFrames();
696 if ( ! xFrameAccess.is())
701 uno::Reference<frame::XFrame>
xFrame;
707 if (pController ==
nullptr)
710 if (pBase ==
nullptr)
715 const std::shared_ptr<sd::ViewShell> pViewShell (pBase->
GetMainViewShell());
717 return pViewShell.get();
720 catch (uno::Exception &)
729 : m_xTreeView(
std::move(xTreeView))
730 , m_xScratchIter(m_xTreeView->make_iterator())
732 , m_xAccel(::
svt::AcceleratorExecute::createAcceleratorHelper())
733 , m_pNavigator(nullptr)
735 , m_pBookmarkDoc(nullptr)
737 , m_pOwnMedium(nullptr)
738 , m_bLinkableSelected(false)
739 , m_bShowAllShapes(false)
740 , m_bOrderFrontToBack(false)
741 , m_bShowAllPages(false)
742 , m_bSelectionHandlerNavigates(false)
743 , m_bNavigationGrabsFocus(true)
745 , m_nSelectEventId(nullptr)
746 , m_nRowActivateEventId(nullptr)
765 m_xTreeView->grab_focus();
766 std::unique_ptr<weld::TreeIter> xEntry(
static_cast<weld::TreeIter*
>(
p));
767 m_xTreeView->start_editing(*xEntry);
782 if (m_xTreeView->get_text(rIterString.first) == rIterString.second)
786 if (rIterString.second.isEmpty() || m_pDoc->GetObj(rIterString.second))
788 std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator(&rIterString.first));
794 const auto& rEntryId = m_xTreeView->get_id(rIterString.first);
795 if (rEntryId.toInt64() == 1)
802 SdPage* pPage = pViewShell->GetActualPage();
803 pPage->
SetName(rIterString.second);
807 else if (
SdrObject* pCursorEntryObject = weld::fromId<SdrObject*>(rEntryId))
810 pCursorEntryObject->SetName(rIterString.second);
818 if (m_nSelectEventId)
826 if (m_nRowActivateEventId)
869 aURL +=
"#" + sSelectedEntry;
885 m_xTreeView->enable_drag_source(xHelper, nDNDActions);
890 m_nRowActivateEventId =
nullptr;
891 m_aRowActivatedHdl.Call(*m_xTreeView);
896 const bool bCreate)
const
906 aRet = pOleObj->GetPersistName();
914 aRet =
SdResId(STR_NAVIGATOR_SHAPE_BASE_NAME) +
" (" +
pObject->TakeObjNameSingul() +
")";
915 aRet = aRet.replaceFirst(
"%1", OUString::number(
pObject->GetOrdNum() + 1));
926 int nListDepth =
m_xTreeView->get_iter_depth(rEntry);
927 if (nListDepth == nDepth)
937 std::vector<OUString> vEntryIds;
995 VclMessageType::Warning, VclButtonsType::Ok,
SdResId(STR_READ_DATA_ERROR)));
1009 if (!m_xTreeView->iter_has_child(rFileEntry))
1011 if (GetBookmarkDoc())
1015 OUString sImgPage(BMP_PAGE);
1016 OUString sImgPageObjs(BMP_PAGEOBJS);
1017 OUString sImgObjects(BMP_OBJECTS);
1018 OUString sImgOle(BMP_OLE);
1019 OUString sImgGraphic(BMP_GRAPHIC);
1024 sal_uInt16 nPage = 0;
1025 const sal_uInt16 nMaxPages = m_pBookmarkDoc->GetPageCount();
1027 std::unique_ptr<weld::TreeIter> xPageEntry;
1028 while (nPage < nMaxPages)
1030 SdPage* pPage =
static_cast<SdPage*
>(m_pBookmarkDoc->GetPage(nPage));
1033 OUString
sId(OUString::number(1));
1034 m_xTreeView->insert(&rFileEntry, -1, &pPage->
GetName(), &
sId,
1035 nullptr,
nullptr,
false, m_xScratchIter.get());
1036 m_xTreeView->set_image(*m_xScratchIter, sImgPage);
1040 xPageEntry = m_xTreeView->make_iterator(&rFileEntry);
1041 (void)m_xTreeView->iter_children(*xPageEntry);
1044 (
void)m_xTreeView->iter_next_sibling(*xPageEntry);
1050 pObj = aIter.
Next();
1051 OUString
aStr( GetObjectName( pObj ) );
1052 if( !
aStr.isEmpty() )
1056 m_xTreeView->insert(xPageEntry.get(), -1, &
aStr,
nullptr,
1057 nullptr,
nullptr,
false, m_xScratchIter.get());
1058 m_xTreeView->set_image(*m_xScratchIter, sImgOle);
1062 m_xTreeView->insert(xPageEntry.get(), -1, &
aStr,
nullptr,
1063 nullptr,
nullptr,
false, m_xScratchIter.get());
1064 m_xTreeView->set_image(*m_xScratchIter, sImgGraphic);
1068 m_xTreeView->insert(xPageEntry.get(), -1, &
aStr,
nullptr,
1069 nullptr,
nullptr,
false, m_xScratchIter.get());
1070 m_xTreeView->set_image(*m_xScratchIter, sImgObjects);
1074 if (m_xTreeView->iter_has_child(*xPageEntry))
1076 m_xTreeView->set_image(*xPageEntry, sImgPageObjs);
1095 SAL_WARN_IF(!xViewShell,
"sd",
"null pBaseViewFrame");
1096 const css::uno::Reference< css::frame::XFrame >
xFrame = xViewShell ? xViewShell->GetViewFrame()->GetFrame().GetFrameInterface() :
nullptr;
1097 m_xAccel->init(::comphelper::getProcessComponentContext(),
xFrame);
1137 bool bBelongsToShow =
true;
1144 if (pShowList !=
nullptr)
1147 pCustomShow = (*pShowList)[nCurrentShowIndex].get();
1151 if (pCustomShow !=
nullptr)
1153 bBelongsToShow =
false;
1154 size_t nPageCount = pCustomShow->
PagesVector().size();
1155 for (
size_t i=0;
i<nPageCount && !bBelongsToShow;
i++)
1157 bBelongsToShow =
true;
1161 return bBelongsToShow;
1167 const OUString& rsName,
1168 const bool bIsExcluded,
1171 OUString aIcon(BMP_PAGE);
1173 aIcon = BMP_PAGE_EXCLUDED;
1174 else if (pShape !=
nullptr)
1177 OUString aUserData(
"1");
1178 if (pShape !=
nullptr)
1181 std::unique_ptr<weld::TreeIter> xEntry =
m_xTreeView->make_iterator();
1182 InsertEntry(pParentEntry, aUserData, rsName, aIcon, xEntry.get());
1192 OSL_ASSERT(pObj!=
nullptr);
1198 if( !
aStr.isEmpty() )
1228 m_xTreeView->set_image(*xEntry, BMP_PAGEOBJS_EXCLUDED);
1239 OUString aSelection =
m_xTreeView->get_selected_text();
1248 sal_uInt16 nPage = 0;
1252 if (!pDrawViewShell)
1256 while( nPage < nMaxPages )
1270 bPageExcluded |= !bPageBelongsToShow;
1283 while( nPage < nMaxMasterPages )
1290 if (!aSelection.isEmpty())
1295 m_xTreeView->select(rEntry);
1307 const OUString& rDocName )
1315 OUString
sId(OUString::number(1));
1326 bool bFound =
false;
1330 std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator());
1358 if (weld::fromId<SdrObject*>(
m_xTreeView->get_id(rEntry)) == pObj)
1362 if (!m_xTreeView->has_focus() && m_xTreeView->get_selected_rows().empty())
1363 m_xTreeView->set_cursor(rEntry);
1364 m_xTreeView->select(rEntry);
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetURLNoPass(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
sal_uInt16 GetCurPos() const
PageVec & PagesVector()
Provides a direct access to the collection of the SdPage objects.
SAL_DLLPRIVATE const sd::PresentationSettings & getPresentationSettings() const
SAL_DLLPRIVATE::sd::DrawDocShell * GetDocSh() const
sal_uInt16 GetSdPageCount(PageKind ePgKind) const
NavigatorDragType GetNavigatorDragType()
DragType is set on dependence if a Drag is even possible.
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
ExecuteDrop-Event.
SdPageObjsTLVDropTarget(weld::TreeView &rTreeView)
weld::TreeView & m_rTreeView
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
AcceptDrop-Event.
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
virtual ~SdPageObjsTransferable() override
virtual void DragFinished(sal_Int8 nDropAction) override
SdPageObjsTransferable(INetBookmark aBookmark, ::sd::DrawDocShell &rDocShell, NavigatorDragType eDragType)
static SdPageObjsTransferable * getImplementation(const css::uno::Reference< css::uno::XInterface > &rxData) noexcept
virtual void AddSupportedFormats() override
static SotClipboardFormatId GetListBoxDropFormatId()
Return a temporary transferable data flavor that is used internally in the navigator for reordering e...
static SotClipboardFormatId mnListBoxDropFormatId
Temporary drop flavor id that is used internally in the navigator.
bool IsEqualToDoc(const SdDrawDocument *pInDoc)
Checks if the pages (PageKind::Standard) of a doc and the objects on the pages are identical to the T...
::sd::DrawDocShellRef m_xBookmarkDocShRef
for the loading of bookmarks
SdDrawDocument * m_pBookmarkDoc
std::unique_ptr< weld::TreeView > m_xTreeView
void Fill(const SdDrawDocument *, bool bAllPages, const OUString &rDocName)
Fill TreeLB with pages and objects.
void SetShowAllShapes(const bool bShowAllShapes, const bool bFill)
SdPageObjsTLV(std::unique_ptr< weld::TreeView > xTreeview)
OUString get_cursor_text() const
bool IsEditingActive() const
void SetViewFrame(const SfxViewFrame *pViewFrame)
const SdDrawDocument * m_pDoc
void AddShapeToTransferable(SdTransferable &rTransferable, const SdrObject &rObject) const
Add the given object to a transferable object so that the object can be dragged and dropped without h...
bool StartDrag()
StartDrag-Request.
SdNavigatorWin * m_pNavigator
Link< const CommandEvent &, bool > m_aPopupMenuHdl
bool m_bNavigationGrabsFocus
If navigation should not only select the relevant shape but also change focus to it.
void SetSdNavigator(SdNavigatorWin *pNavigator)
bool PageBelongsToCurrentShow(const SdPage *pPage) const
Determine whether the specified page belongs to the current show which is either the standard show or...
ImplSVEvent * m_nRowActivateEventId
OUString GetObjectName(const SdrObject *pObject, const bool bCreate=true) const
Return the name of the object.
std::unique_ptr<::svt::AcceleratorExecute > m_xAccel
bool IsEqualToShapeList(std::unique_ptr< weld::TreeIter > &rEntry, const SdrObjList &rList, std::u16string_view rListName)
Visits rList recursively and tries to advance rEntry accordingly.
void SetOrderFrontToBack(const bool bOrderFrontToBack)
::sd::ViewShell * GetViewShellForDocShell(::sd::DrawDocShell &rDocShell)
Return the view shell that is linked to the given doc shell.
static bool SAL_DLLPRIVATE bIsInDrag
static, in the case the navigator is deleted in ExecuteDrag
std::unique_ptr< weld::TreeIter > m_xScratchIter
static void OnDragFinished()
void InsertEntry(const OUString &rName, const OUString &rExpander)
std::vector< OUString > GetSelectedEntryIds() const
Link< weld::TreeView &, bool > m_aRowActivatedHdl
std::unique_ptr< SdPageObjsTLVDropTarget > m_xDropTargetHelper
bool m_bSelectionHandlerNavigates
If changing the selection should also result in navigating to the relevant shape.
ImplSVEvent * m_nSelectEventId
SdDrawDocument * GetBookmarkDoc(SfxMedium *pMedium=nullptr)
Checks if it is a draw file and opens the BookmarkDoc depending of the provided Docs.
bool m_bShowAllPages
This flag controls whether to show all pages.
void CloseBookmarkDoc()
Close and delete bookmark document.
rtl::Reference< SdPageObjsTransferable > m_xHelper
std::vector< OUString > GetSelectEntryList(const int nDepth) const
return selected entries nDepth == 0 -> pages nDepth == 1 -> objects
Link< weld::TreeView &, void > m_aChangeHdl
Link< const KeyEvent &, bool > m_aKeyPressHdl
bool HasSelectedChildren(std::u16string_view rName)
void AddShapeList(const SdrObjList &rList, const SdrObject *pShape, const OUString &rsName, const bool bIsExcluded, const weld::TreeIter *pParentEntry)
Add one list box entry for the parent of the given shapes and one child entry for each of the given s...
Link< const MouseEvent &, bool > m_aMouseReleaseHdl
bool SelectEntry(std::u16string_view rName)
select an entry in TreeLB
PageKind GetPageKind() const
const OUString & GetName() const
void SetName(const OUString &rName)
Set the name of the page and broadcast a model change.
void SetStartPos(const Point &rStartPos)
virtual void DragFinished(sal_Int8 nDropAction) override
void SetObjectDescriptor(std::unique_ptr< TransferableObjectDescriptor > pObjDesc)
void PutMarkedBehindObj(const SdrObject *pRefObj)
void PutMarkedInFrontOfObj(const SdrObject *pRefObj)
void UnmarkAllObj(SdrPageView const *pPV=nullptr)
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
const SdrPage * GetMasterPage(sal_uInt16 nPgNum) const
sal_uInt16 GetMasterPageCount() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
sal_uInt16 GetPageCount() const
virtual void NbcInsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
bool HasObjectNavigationOrder() const
virtual rtl::Reference< SdrObject > NbcRemoveObject(size_t nObjNum)
virtual SdrInventor GetObjInventor() const
sal_uInt32 GetOrdNum() const
virtual SdrObjList * GetSubList() const
virtual const tools::Rectangle & GetCurrentBoundRect() const
bool IsGroupObject() const
virtual SdrObjKind GetObjIdentifier() const
SdrPage * getSdrPageFromSdrObject() const
sal_Int64 GetAspect() const
css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef() const
const Graphic * GetGraphic() const
SdrPageView * GetSdrPageView() const
const INetURLObject & GetURLObject() const
const OUString & GetName() const
const OUString & GetPhysicalName() const
void FillTransferableObjectDescriptor(TransferableObjectDescriptor &rDesc) const
SfxMedium * GetMedium() const
static SotClipboardFormatId GetFormat(const css::datatransfer::DataFlavor &rFlavor)
static SotClipboardFormatId RegisterFormatMimeType(const OUString &rMimeType)
static void FillTransferableObjectDescriptor(TransferableObjectDescriptor &rDesc, const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, const Graphic *pGraphic, sal_Int64 nAspect)
The DrawController is the UNO controller for Impress and Draw.
ViewShellBase * GetViewShellBase()
Return a pointer to the ViewShellBase object that the DrawController is connected to.
sd::ViewShell * GetViewShell()
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
PageKind GetPageKind() const
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
static ViewShellBase * GetViewShellBase(SfxViewFrame const *pFrame)
When given a view frame this static method returns the corresponding sd::ViewShellBase object.
std::shared_ptr< ViewShell > GetMainViewShell() const
Return the main view shell stacked on the called ViewShellBase object.
DrawDocShell * GetDocShell() const
Base class of the stacked shell hierarchy.
::sd::View * GetView() const
SdrView * GetDrawView() const
sal_uInt16 GetCode() const
virtual std::unique_ptr< TreeIter > make_iterator(const TreeIter *pOrig=nullptr) const=0
virtual bool get_selected(TreeIter *pIter) const=0
virtual int get_iter_index_in_parent(const TreeIter &rIter) const=0
virtual TreeView * get_drag_source() const=0
virtual bool get_dest_row_at_pos(const Point &rPos, weld::TreeIter *pResult, bool bDnDMode, bool bAutoScroll=true)=0
virtual bool iter_parent(TreeIter &rIter) const=0
virtual int iter_compare(const TreeIter &a, const TreeIter &b) const=0
virtual bool iter_previous_sibling(TreeIter &rIter) const=0
virtual void set_cursor(int pos)=0
virtual int get_iter_depth(const TreeIter &rIter) const=0
virtual void move_subtree(TreeIter &rNode, const TreeIter *pNewParent, int nIndexInNewParent)=0
virtual OUString get_id(int pos) const=0
#define DBG_ASSERT(sCon, aError)
ScXMLEditAttributeMap::Entry const aEntries[]
EmbeddedObjectRef * pObject
Reference< XInterface > xTarget
constexpr sal_uInt16 KEY_RETURN
#define LINK(Instance, Class, Member)
#define SAL_WARN_IF(condition, area, stream)
OUString toId(const void *pValue)
@ NAVIGATOR_DRAGTYPE_LINK
OUString SdResId(TranslateId aId)
IMPL_LINK_NOARG(SdPageObjsTLV, MouseReleaseHdl, const MouseEvent &, bool)
IMPL_LINK(SdPageObjsTLV, CommandHdl, const CommandEvent &, rCEvt, bool)
Reference< XController > xController
Reference< XFrame > xFrame
#define DND_ACTION_COPYMOVE