59#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
64#include <svx/svxids.hrc>
66#include <rtl/ustring.hxx>
78class TemporarySlideTrackingDeactivator
81 explicit TemporarySlideTrackingDeactivator (SlideSorterController& rController)
84 mrController.GetVisibleAreaManager().IsCurrentSlideTrackingActive())
87 mrController.GetVisibleAreaManager().DeactivateCurrentSlideTracking();
89 ~TemporarySlideTrackingDeactivator()
92 mrController.GetVisibleAreaManager().ActivateCurrentSlideTracking();
106 std::shared_ptr<ViewShell> pMainViewShell)
139 mnDragFinishedUserEventId(nullptr)
157 if (pViewShell !=
nullptr)
237 if (nInsertPosition >= 0)
250 sal_Int32 nInsertPosition = -1;
260 std::shared_ptr<controller::InsertionIndicatorHandler> pInsertionIndicatorHandler (
262 if (pInsertionIndicatorHandler->IsActive())
265 nInsertPosition = pInsertionIndicatorHandler->GetInsertionPageIndex();
286 return nInsertPosition;
294 sal_uInt16 nInsertIndex (rModel.
GetCoreIndex(nInsertPosition));
295 sal_Int32 nInsertPageCount (0);
298 const std::vector<OUString> &rBookmarkList = pClipTransferable->
GetPageBookmarks();
301 nInsertPageCount =
static_cast<sal_uInt16
>(rBookmarkList.size());
320 if (pDataDoc!=
nullptr
325 bMergeMasterPages = (pDataDoc != rModel.
GetDocument());
328 std::vector<OUString>(),
341 return nInsertPageCount;
350 for (sal_Int32
i=0;
i<nPageCount;
i++)
370 std::vector<OUString> aBookmarkList;
380 sal_Int32 nUniqueID = 0;
386 const OUString sOrigName = pDescriptor->GetPage()->GetName();
389 OUString sUniqueName;
390 bool bUnique =
false;
393 sUniqueName = sOrigName +
"_clipboard" + OUString::number(nUniqueID++);
396 pDescriptor->GetPage()->SetName(sUniqueName);
400 aBookmarkList.push_back(pDescriptor->GetPage()->GetName());
408 ::std::vector<TransferableData::Representative> aRepresentatives;
409 aRepresentatives.reserve(3);
410 std::shared_ptr<cache::PageCache> pPreviewCache (
415 if ( ! pDescriptor || pDescriptor->GetPage()==
nullptr)
417 BitmapEx aPreview (pPreviewCache->GetPreviewBitmap(pDescriptor->GetPage(),
false));
418 aRepresentatives.emplace_back(
421 if (aRepresentatives.size() >= 3)
425 if (aBookmarkList.empty())
432 std::move(aRepresentatives));
435 SD_MOD()->pTransferDrag = pTransferable.get();
437 SD_MOD()->pTransferClip = pTransferable.get();
442 pTransferable->GetWorkDocument()->GetDocSh()
443 ->FillTransferableObjectDescriptor (*pObjDesc);
445 if (pDataDocSh !=
nullptr)
449 if (pActionWindow ==
nullptr)
452 if (pViewShell !=
nullptr)
456 assert(pActionWindow);
458 pTransferable->SetStartPos (pActionWindow->
PixelToLogic(
460 pTransferable->SetObjectDescriptor (std::move(pObjDesc));
463 TemporarySlideTrackingDeactivator aDeactivator (
mrController);
464 pTransferable->SetPageBookmarks (std::move(aBookmarkList), !bDrag);
473 pTransferable->CopyToClipboard (pActionWindow);
484 if (pTreeListBoxTransferable ==
nullptr)
490 if (pViewShell ==
nullptr)
496 if (pSlideSorterViewShell ==
nullptr)
503 if ( ! aDataHelper.
GetINetBookmark(SotClipboardFormatId::NETSCAPE_BOOKMARK, aINetBookmark))
505 const OUString sURL (aINetBookmark.
GetURL());
506 const sal_Int32
nIndex (sURL.indexOf(
'#'));
509 OUString sBookmark (sURL.copy(
nIndex+1));
513 if (pTransferableDocument ==
nullptr)
515 bool bIsMasterPage =
false;
516 const sal_uInt16 nPageIndex (pTransferableDocument->
GetPageByName(sBookmark, bIsMasterPage));
521 ::std::vector<TransferableData::Representative> aRepresentatives;
522 aRepresentatives.reserve(1);
523 std::shared_ptr<cache::PageCache> pPreviewCache (
526 if ( ! pDescriptor || pDescriptor->GetPage()==
nullptr)
528 BitmapEx aPreview (pPreviewCache->GetPreviewBitmap(pDescriptor->GetPage(),
false));
529 aRepresentatives.emplace_back(
540 std::shared_ptr<SdTransferable::UserData> pNewTransferable =
541 std::make_shared<TransferableData>(
542 pSlideSorterViewShell,
543 std::move(aRepresentatives));
548 std::vector<OUString> aPageBookmarks { sBookmark };
555 return pNewTransferable;
559 return std::shared_ptr<SdTransferable::UserData>();
563 const Point& rPosition,
580 reinterpret_cast<void*
>(nDropAction));
586 const sal_Int8 nDropAction (
static_cast<sal_Int8>(
reinterpret_cast<sal_IntPtr
>(pUserData)));
588 mnDragFinishedUserEventId =
nullptr;
593 pFunction->NotifyDragFinished();
597 && ! maPagesToRemove.empty())
602 for (
const auto& rpDraggedPage : maPagesToRemove)
608 mxUndoContext.reset();
609 mxSelectionObserverContext.reset();
614 DropTargetHelper& rTargetHelper,
635 if (pDragTransferable !=
nullptr
638 & css::datatransfer::dnd::DNDConstants::ACTION_DEFAULT) != 0)
652 if (pSelectionFunction !=
nullptr)
682 DropTargetHelper& rTargetHelper,
697 const Point aEventModelPosition (
699 const sal_Int32 nXOffset (std::abs (pDragTransferable->
GetStartPos().
X()
700 - aEventModelPosition.
X()));
701 const sal_Int32 nYOffset (std::abs (pDragTransferable->
GetStartPos().
Y()
702 - aEventModelPosition.
Y()));
705 || ( nXOffset >= 2 && nYOffset >= 2 );
707 std::shared_ptr<InsertionIndicatorHandler> pInsertionIndicatorHandler(
710 pInsertionIndicatorHandler->UpdatePosition(aEventModelPosition, rEvent.
mnAction);
757 std::shared_ptr<TransferableData> pSlideSorterTransferable (
759 assert(pSlideSorterTransferable);
760 if (pSlideSorterTransferable
771 pFunction->NotifyDragFinished();
798 std::shared_ptr<TransferableData> pSlideSorterTransferable (
800 if (pSlideSorterTransferable
820 const sal_Int32 nInsertionIndex (
824 if (nInsertionIndex >= 0)
833 if (pDragTransferable ==
nullptr)
846 if (pPageObjsTransferable !=
nullptr)
854 const Point& rPosition,
855 const void* pDropEvent,
856 DropTargetHelper& rTargetHelper,
868 std::shared_ptr<DrawViewShell> pDrawViewShell;
870 pDrawViewShell = std::dynamic_pointer_cast<DrawViewShell>(
872 if (pDrawViewShell !=
nullptr
885 nPage = pDescriptor->GetPageIndex();
895 nResult = pDrawViewShell->AcceptDrop(
904 nResult = pDrawViewShell->ExecuteDrop(
SlideSorterController & mrController
const bool mbIsCurrentSlideTrackingActive
SlideSorter & mrSlideSorter
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
const OUString & GetURL() const
OUString GetURLNoPass(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
constexpr tools::Long Y() const
constexpr tools::Long X() const
SAL_DLLPRIVATE bool InsertBookmarkAsPage(const std::vector< OUString > &rBookmarkList, std::vector< OUString > *pExchangeList, bool bLink, bool bReplace, sal_uInt16 nPgPos, bool bNoDialogs, ::sd::DrawDocShell *pBookmarkDocSh, bool bCopy, bool bMergeMasterPages, bool bPreservePageNames)
Insert pages into this document.
SAL_DLLPRIVATE void CreatingDataObj(SdTransferable *pTransferable)
SAL_DLLPRIVATE sal_uInt16 GetPageByName(std::u16string_view rPgName, bool &rbIsMasterPage) const
Return the first page that has the given name.
SAL_DLLPRIVATE::sd::DrawDocShell * GetDocSh() const
SAL_DLLPRIVATE SdDrawDocument * AllocSdDrawDocument() const
sal_uInt16 GetSdPageCount(PageKind ePgKind) const
bool IsInsertBefore() const
::sd::DrawDocShell & GetDocShell() const
::sd::ViewShell * GetViewShellForDocShell(::sd::DrawDocShell &rDocShell)
Return the view shell that is linked to the given doc shell.
const SfxObjectShellRef & GetDocShell() const
bool IsPageTransferable() const
const ::sd::View * GetView() const
void SetWorkDocument(const SdDrawDocument *pWorkDoc)
const Point & GetStartPos() const
bool HasPageBookmarks() const
::sd::DrawDocShell * GetPageDocShell() const
const std::vector< OUString > & GetPageBookmarks() const
SdDrawDocument * GetSourceDoc() const
bool HasSourceDoc(const SdDrawDocument *pDoc) const
void SetView(const ::sd::View *pView)
void SetPageBookmarks(std::vector< OUString > &&rPageBookmarks, bool bPersistent)
virtual void BrkAction() override
bool DoesMakePageObjectsNamesUnique() const
void DoMakePageObjectsNamesUnique(bool bDo)
bool IsUndoEnabled() const
void Invalidate(sal_uInt16 nId)
const INetURLObject & GetURLObject() const
SfxMedium * GetMedium() const
sal_uInt16 GetSlot() const
void Done(bool bRemove=false)
bool GetINetBookmark(SotClipboardFormatId nFormat, INetBookmark &rBmk) const
bool IsPageNameUnique(std::u16string_view rPagName) const
checks, if the given name is a unique name for an existing slide
bool IsNewPageNameValid(OUString &rInOutPageName, bool bResetStringIfStandardName=false)
checks, if the given name is a valid new name for a slide
SdDrawDocument * GetDoc()
Handle clipboard related tasks for the draw view.
void HandlePageDrop(const SdTransferable &rTransferable)
Handle the drop of a drag-and-drop action where the transferable contains a set of pages.
std::shared_ptr< ViewShell > GetMainViewShell() const
Return the main view shell stacked on the called ViewShellBase object.
Base class of the stacked shell hierarchy.
const rtl::Reference< FuPoor > & GetCurrentFunction() const
::sd::Window * GetActiveWindow() const
The active window is usually the mpContentWindow.
::sd::View * GetView() const
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
An SdWindow contains the actual working area of ViewShell.
SD_DLLPUBLIC SlideSorter & GetSlideSorter() const
static SD_DLLPUBLIC SlideSorterViewShell * GetSlideSorter(ViewShellBase &rBase)
Return a slide sorter that is currently displayed in one of the panes that belong to the given ViewSh...
Show previews for all the slides in a document and allow the user to insert or delete slides and modi...
ViewShell * GetViewShell() const
Return the view shell that was given at construction.
const VclPtr< sd::Window > & GetContentWindow() const
Return the content window.
model::SlideSorterModel & GetModel() const
view::SlideSorterView & GetView() const
UndoContext(SdDrawDocument *pDocument, std::shared_ptr< ViewShell > pMainViewShell)
SdDrawDocument * mpDocument
std::shared_ptr< ViewShell > mpMainViewShell
PageList maPagesToRemove
Remember the pages that are dragged to another document or to another place in the same document so t...
virtual sal_uInt16 DetermineInsertPosition() override
Return an index of a page after which the pages of the transferable are to be inserted into the targe...
void HandleSlotCall(SfxRequest &rRequest)
With the current implementation the forwarded calls to the current function will come back eventually...
SlideSorterController & mrController
void StartDrag(const Point &rDragPt, vcl::Window *pWindow)
void DragFinished(sal_Int8 nDropAction)
sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt, DropTargetHelper &rTargetHelper, ::sd::Window *pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer)
std::unique_ptr< UndoContext > mxUndoContext
void SelectPageRange(sal_Int32 nFirstIndex, sal_Int32 nPageCount)
Select a range of pages of the model.
DropCommand
This method contains the code for AcceptDrop() and ExecuteDrop() shapes.
sal_Int32 PasteTransferable(sal_Int32 nInsertPosition)
Paste the pages of the transferable of the sd module at the given position.
virtual ~Clipboard() override
void CreateSlideTransferable(vcl::Window *pWindow, bool bDrag)
bool IsInsertionTrivial(SdTransferable const *pTransferable, const sal_Int8 nDndAction) const
Return whether the insertion defined by the transferable is trivial, ie would not change either sourc...
SD_DLLPUBLIC void DoPaste()
SlideSorter & mrSlideSorter
sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt, DropTargetHelper &rTargetHelper, ::sd::Window *pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer)
DropType
Return <TRUE> when the current transferable in the current state of the slidesorter is acceptable to ...
DropType IsDropAccepted() const
sal_Int32 GetInsertionPosition()
Determine the position of where to insert the pages in the current transferable of the sd module.
SD_DLLPUBLIC void DoCopy()
Clipboard(SlideSorter &rSlideSorter)
ImplSVEvent * mnDragFinishedUserEventId
sal_Int8 ExecuteOrAcceptShapeDrop(DropCommand eCommand, const Point &rPosition, const void *pDropEvent, DropTargetHelper &rTargetHelper, ::sd::Window *pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer)
std::unique_ptr< SelectionObserver::Context, o3tl::default_delete< SelectionObserver::Context > > mxSelectionObserverContext
static std::shared_ptr< SdTransferable::UserData > CreateTransferableUserData(SdTransferable *pTransferable)
Create a slide sorter transferable from the given sd transferable.
bool IsFocusShowing() const
Return <TRUE> when the focus indicator is currently shown.
sal_Int32 GetFocusedPageIndex() const
Return the index of the page that currently has the focus as it is accepted by the slide sorter model...
A sub-controller that handles page selection of the slide browser.
SD_DLLPUBLIC void DeselectAllPages()
void SelectPage(int nPageIndex)
Select the specified descriptor.
void MouseDragged(const AcceptDropEvent &rEvent, const sal_Int8 nDragAction)
Use this little class instead of calling StartObservation and EndObservation directly so that EndObse...
Create an object of this inner class to prevent updates due to model changes.
void HandleModelChange()
Handle a change of the model, that is, handle the removal and insertion of whole pages or a change of...
::rtl::Reference< SelectionFunction > GetCurrentSelectionFunction() const
When the current function of the view shell is the slide sorter selection function then return a refe...
FocusManager & GetFocusManager()
std::shared_ptr< CurrentSlideManager > const & GetCurrentSlideManager() const
std::shared_ptr< SelectionManager > const & GetSelectionManager() const
SD_DLLPUBLIC PageSelector & GetPageSelector()
std::shared_ptr< InsertionIndicatorHandler > const & GetInsertionIndicatorHandler() const
static rtl::Reference< SdTransferable > CreateTransferable(SdDrawDocument *pSrcDoc, SlideSorterViewShell *pViewShell, ::std::vector< TransferableData::Representative > &&rRepresentatives)
static std::shared_ptr< TransferableData > GetFromTransferable(const SdTransferable *pTransferable)
static PageEnumeration CreateSelectedPagesEnumeration(const SlideSorterModel &rModel)
The returned enumeration of slides iterates over the currently selected slides of the given model.
Public class of page enumerations that delegates its calls to an implementation object that can filte...
virtual SharedPageDescriptor GetNextElement() override
Return the next element of the enumeration.
virtual bool HasMoreElements() const override
Return <TRUE> when the enumeration has more elements, i.e.
virtual void Rewind() override
Rewind the enumeration so that the next call to GetNextElement() will return its first element.
The model of the slide sorter gives access to the slides that are to be displayed in the slide sorter...
SdDrawDocument * GetDocument()
This method is present to let the view create a ShowView for displaying slides.
sal_Int32 GetPageCount() const
Return the number of slides in the document regardless of whether they are visible or not or whether ...
EditMode GetEditMode() const
SharedPageDescriptor GetPageDescriptor(const sal_Int32 nPageIndex, const bool bCreate=true) const
Return a page descriptor for the page with the specified index.
sal_uInt16 GetCoreIndex(const sal_Int32 nIndex) const
Return an index for accessing an SdrModel that corresponds to the given SlideSorterModel index.
sal_Int32 GetPageIndexAtPoint(const Point &rPosition) const
Return the index of the page that is rendered at the given position.
std::shared_ptr< cache::PageCache > const & GetPreviewCache()
Point PixelToLogic(const Point &rDevicePt) const
Point GetPointerPosPixel()
weld::Window * GetFrameWeld() const
virtual std::shared_ptr< SfxDialogController > GetController() override
#define LINK(Instance, Class, Member)
IMPL_LINK(SlideSorterController, ApplicationEventHandler, VclSimpleEvent &, rEvent, void)
std::shared_ptr< PageDescriptor > SharedPageDescriptor
OUString SdResId(TranslateId aId)
const css::datatransfer::dnd::DropTargetDragEvent maDragEvent