diff options
Diffstat (limited to 'sd/source/ui/slidesorter')
15 files changed, 301 insertions, 70 deletions
diff --git a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx index 390ade9c7a7e..153ec43a1ad6 100644 --- a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx +++ b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx @@ -43,7 +43,7 @@ #include "controller/SlsScrollBarManager.hxx" #include "controller/SlsSelectionManager.hxx" #include "controller/SlsSlotManager.hxx" -#include "controller/SlsTransferable.hxx" +#include "controller/SlsTransferableData.hxx" #include "controller/SlsVisibleAreaManager.hxx" #include "model/SlideSorterModel.hxx" #include "model/SlsPageEnumerationProvider.hxx" @@ -427,8 +427,7 @@ bool SlideSorterController::Command ( // indicator so that the user knows where a page insertion // would take place. mpInsertionIndicatorHandler->Start(false); - mpInsertionIndicatorHandler->UpdateIndicatorIcon( - dynamic_cast<Transferable*>(SD_MOD()->pTransferClip)); + mpInsertionIndicatorHandler->UpdateIndicatorIcon(SD_MOD()->pTransferClip); mpInsertionIndicatorHandler->UpdatePosition( pWindow->PixelToLogic(rEvent.GetMousePosPixel()), InsertionIndicatorHandler::MoveMode); diff --git a/sd/source/ui/slidesorter/controller/SlsAnimator.cxx b/sd/source/ui/slidesorter/controller/SlsAnimator.cxx index 28756b3766d9..dfc672e33802 100755 --- a/sd/source/ui/slidesorter/controller/SlsAnimator.cxx +++ b/sd/source/ui/slidesorter/controller/SlsAnimator.cxx @@ -303,7 +303,7 @@ IMPL_LINK(Animator, TimeoutHandler, Timer*, EMPTYARG) // Unlock the draw lock. This should lead to a repaint. mpDrawLock.reset(); - if (maAnimations.size() > 0) + if (!maAnimations.empty()) RequestNextFrame(); return 0; diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx index 823112166bf4..4545e371ea37 100755 --- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx +++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx @@ -44,11 +44,12 @@ #include "controller/SlsScrollBarManager.hxx" #include "controller/SlsFocusManager.hxx" #include "controller/SlsSelectionManager.hxx" -#include "controller/SlsTransferable.hxx" +#include "controller/SlsTransferableData.hxx" #include "controller/SlsSelectionObserver.hxx" #include "cache/SlsPageCache.hxx" #include "ViewShellBase.hxx" +#include "View.hxx" #include "DrawViewShell.hxx" #include "Window.hxx" #include "fupoor.hxx" @@ -69,6 +70,7 @@ #include "drawdoc.hxx" #include "DrawDocShell.hxx" #include "sdpage.hxx" +#include "sdtreelb.hxx" #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> #include <sfx2/request.hxx> @@ -82,9 +84,12 @@ #include <rtl/ustring.hxx> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> +#include <boost/bind.hpp> + namespace sd { namespace slidesorter { namespace controller { + class Clipboard::UndoContext { public: @@ -412,7 +417,7 @@ void Clipboard::CreateSlideTransferable ( // previews are included into the transferable so that an insertion // indicator can be rendered. aSelectedPages.Rewind(); - ::std::vector<Transferable::Representative> aRepresentatives; + ::std::vector<TransferableData::Representative> aRepresentatives; aRepresentatives.reserve(3); ::boost::shared_ptr<cache::PageCache> pPreviewCache ( mrSlideSorter.GetView().GetPreviewCache()); @@ -422,7 +427,7 @@ void Clipboard::CreateSlideTransferable ( if ( ! pDescriptor || pDescriptor->GetPage()==NULL) continue; Bitmap aPreview (pPreviewCache->GetPreviewBitmap(pDescriptor->GetPage(), false)); - aRepresentatives.push_back(Transferable::Representative( + aRepresentatives.push_back(TransferableData::Representative( aPreview, pDescriptor->HasState(model::PageDescriptor::ST_Excluded))); if (aRepresentatives.size() >= 3) @@ -433,7 +438,7 @@ void Clipboard::CreateSlideTransferable ( { mrSlideSorter.GetView().BrkAction(); SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument(); - SdTransferable* pTransferable = new Transferable ( + SdTransferable* pTransferable = TransferableData::CreateTransferable ( pDocument, NULL, sal_False, @@ -491,6 +496,95 @@ void Clipboard::CreateSlideTransferable ( +::boost::shared_ptr<SdTransferable::UserData> Clipboard::CreateTransferableUserData (SdTransferable* pTransferable) +{ + do + { + SdPageObjsTLB::SdPageObjsTransferable* pTreeListBoxTransferable + = dynamic_cast<SdPageObjsTLB::SdPageObjsTransferable*>(pTransferable); + if (pTreeListBoxTransferable == NULL) + break; + + // Find view shell for the document of the transferable. + ::sd::ViewShell* pViewShell + = SdPageObjsTLB::GetViewShellForDocShell(pTreeListBoxTransferable->GetDocShell()); + if (pViewShell == NULL) + break; + + // Find slide sorter for the document of the transferable. + SlideSorterViewShell* pSlideSorterViewShell + = SlideSorterViewShell::GetSlideSorter(pViewShell->GetViewShellBase()); + if (pSlideSorterViewShell == NULL) + break; + SlideSorter& rSlideSorter (pSlideSorterViewShell->GetSlideSorter()); + + // Get bookmark from transferable. + TransferableDataHelper aDataHelper (pTransferable); + INetBookmark aINetBookmark; + if ( ! aDataHelper.GetINetBookmark(SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark)) + break; + const rtl::OUString sURL (aINetBookmark.GetURL()); + const sal_Int32 nIndex (sURL.indexOf((sal_Unicode)'#')); + if (nIndex == -1) + break; + String sBookmark (sURL.copy(nIndex+1)); + + // Make sure that the bookmark points to a page. + SdDrawDocument* pTransferableDocument = rSlideSorter.GetModel().GetDocument(); + if (pTransferableDocument == NULL) + break; + sal_Bool bIsMasterPage = sal_False; + const sal_uInt16 nPageIndex (pTransferableDocument->GetPageByName(sBookmark, bIsMasterPage)); + if (nPageIndex == SDRPAGE_NOTFOUND) + break; + + // Create preview. + ::std::vector<TransferableData::Representative> aRepresentatives; + aRepresentatives.reserve(1); + ::boost::shared_ptr<cache::PageCache> pPreviewCache ( + rSlideSorter.GetView().GetPreviewCache()); + model::SharedPageDescriptor pDescriptor (rSlideSorter.GetModel().GetPageDescriptor((nPageIndex-1)/2)); + if ( ! pDescriptor || pDescriptor->GetPage()==NULL) + break; + Bitmap aPreview (pPreviewCache->GetPreviewBitmap(pDescriptor->GetPage(), false)); + aRepresentatives.push_back(TransferableData::Representative( + aPreview, + pDescriptor->HasState(model::PageDescriptor::ST_Excluded))); + + // Remember the page in maPagesToRemove so that it can be removed + // when drag and drop action is "move". + Clipboard& rOtherClipboard (pSlideSorterViewShell->GetSlideSorter().GetController().GetClipboard()); + rOtherClipboard.maPagesToRemove.clear(); + rOtherClipboard.maPagesToRemove.push_back(pDescriptor->GetPage()); + + // Create the new transferable. + ::boost::shared_ptr<SdTransferable::UserData> pNewTransferable ( + new TransferableData( + pSlideSorterViewShell, + aRepresentatives)); + pTransferable->SetWorkDocument( dynamic_cast<SdDrawDocument*>( + pTreeListBoxTransferable->GetSourceDoc()->AllocModel())); + // pTransferable->SetView(&mrSlideSorter.GetView()); + + // Set page bookmark list. + List aPageBookmarks; + aPageBookmarks.Insert(new String(sBookmark)); + pTransferable->SetPageBookmarks(aPageBookmarks, false); + + // Replace the view referenced by the transferable with the + // corresponding slide sorter view. + pTransferable->SetView(&pSlideSorterViewShell->GetSlideSorter().GetView()); + + return pNewTransferable; + } + while (false); + + return ::boost::shared_ptr<SdTransferable::UserData>(); +} + + + + void Clipboard::StartDrag ( const Point& rPosition, ::Window* pWindow) @@ -510,9 +604,7 @@ void Clipboard::StartDrag ( void Clipboard::DragFinished (sal_Int8 nDropAction) { - SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; - if (pDragTransferable != NULL) - pDragTransferable->SetView (NULL); + // SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; if (mnDragFinishedUserEventId == 0) { @@ -590,11 +682,12 @@ sal_Int8 Clipboard::AcceptDrop ( { sal_Int8 nAction (DND_ACTION_NONE); - const Clipboard::DropType eDropType (IsDropAccepted()); + const Clipboard::DropType eDropType (IsDropAccepted(rTargetHelper)); switch (eDropType) { case DT_PAGE: + case DT_PAGE_FROM_NAVIGATOR: { // Accept a drop. nAction = rEvent.mnAction; @@ -602,7 +695,7 @@ sal_Int8 Clipboard::AcceptDrop ( // Use the copy action when the drop action is the default, i.e. not // explicitly set to move or link, and when the source and // target models are not the same. - const SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; + SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; if (pDragTransferable != NULL && pDragTransferable->IsPageTransferable() && ((rEvent.maDragEvent.DropAction @@ -612,13 +705,12 @@ sal_Int8 Clipboard::AcceptDrop ( { nAction = DND_ACTION_COPY; } - else if (mrController.GetInsertionIndicatorHandler()->IsInsertionTrivial(nAction)) + else if (IsInsertionTrivial(pDragTransferable, nAction)) { nAction = DND_ACTION_NONE; } // Show the insertion marker and the substitution for a drop. - Point aPosition = pTargetWindow->PixelToLogic (rEvent.maPosPixel); SelectionFunction* pSelectionFunction = dynamic_cast<SelectionFunction*>( mrSlideSorter.GetViewShell()->GetCurrentFunction().get()); if (pSelectionFunction != NULL) @@ -641,6 +733,7 @@ sal_Int8 Clipboard::AcceptDrop ( break; default: + case DT_NONE: nAction = DND_ACTION_NONE; break; } @@ -660,12 +753,14 @@ sal_Int8 Clipboard::ExecuteDrop ( { sal_Int8 nResult = DND_ACTION_NONE; mpUndoContext.reset(); + const Clipboard::DropType eDropType (IsDropAccepted(rTargetHelper)); - switch (IsDropAccepted()) + switch (eDropType) { case DT_PAGE: + case DT_PAGE_FROM_NAVIGATOR: { - const SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; + SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; const Point aEventModelPosition ( pTargetWindow->PixelToLogic (rEvent.maPosPixel)); const sal_Int32 nXOffset (labs (pDragTransferable->GetStartPos().X() @@ -684,7 +779,7 @@ sal_Int8 Clipboard::ExecuteDrop ( // Do not process the insertion when it is trivial, // i.e. would insert pages at their original place. - if (pInsertionIndicatorHandler->IsInsertionTrivial(rEvent.mnAction)) + if (IsInsertionTrivial(pDragTransferable, rEvent.mnAction)) bContinue = false; // Tell the insertion indicator handler to hide before the model @@ -713,6 +808,19 @@ sal_Int8 Clipboard::ExecuteDrop ( // well as the ones above. } + // When the pages originated in another slide sorter then + // only that is notified automatically about the drag + // operation being finished. Because the target slide sorter + // has be notified, too, add a callback for that. + ::boost::shared_ptr<TransferableData> pSlideSorterTransferable ( + TransferableData::GetFromTransferable(pDragTransferable)); + BOOST_ASSERT(pSlideSorterTransferable); + if (pSlideSorterTransferable + && pSlideSorterTransferable->GetSourceViewShell() != mrSlideSorter.GetViewShell()) + { + DragFinished(nResult); + } + // Notify the receiving selection function that drag-and-drop is // finished and the substitution handler can be released. ::rtl::Reference<SelectionFunction> pFunction ( @@ -732,7 +840,9 @@ sal_Int8 Clipboard::ExecuteDrop ( nPage, nLayer); break; + default: + case DT_NONE: break; } @@ -742,6 +852,21 @@ sal_Int8 Clipboard::ExecuteDrop ( +bool Clipboard::IsInsertionTrivial ( + SdTransferable* pTransferable, + const sal_Int8 nDndAction) const +{ + ::boost::shared_ptr<TransferableData> pSlideSorterTransferable ( + TransferableData::GetFromTransferable(pTransferable)); + if (pSlideSorterTransferable + && pSlideSorterTransferable->GetSourceViewShell() != mrSlideSorter.GetViewShell()) + return false; + return mrController.GetInsertionIndicatorHandler()->IsInsertionTrivial(nDndAction); +} + + + + void Clipboard::Abort (void) { if (mpSelectionObserverContext) @@ -797,25 +922,26 @@ sal_uInt16 Clipboard::InsertSlides ( -Clipboard::DropType Clipboard::IsDropAccepted (void) const +Clipboard::DropType Clipboard::IsDropAccepted (DropTargetHelper&) const { - DropType eResult (DT_NONE); - const SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; - if (pDragTransferable != NULL) + if (pDragTransferable == NULL) + return DT_NONE; + + if (pDragTransferable->IsPageTransferable()) { - if (pDragTransferable->IsPageTransferable()) - { - if (mrSlideSorter.GetModel().GetEditMode() != EM_MASTERPAGE) - eResult = DT_PAGE; - } + if (mrSlideSorter.GetModel().GetEditMode() != EM_MASTERPAGE) + return DT_PAGE; else - { - eResult = DT_SHAPE; - } + return DT_NONE; } - return eResult; + const SdPageObjsTLB::SdPageObjsTransferable* pPageObjsTransferable + = dynamic_cast<const SdPageObjsTLB::SdPageObjsTransferable*>(pDragTransferable); + if (pPageObjsTransferable != NULL) + return DT_PAGE_FROM_NAVIGATOR; + + return DT_SHAPE; } diff --git a/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx b/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx index 76a5f583f4a5..b55c2c261645 100644 --- a/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx +++ b/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx @@ -39,10 +39,12 @@ #include "controller/SlsProperties.hxx" #include "controller/SlsSelectionFunction.hxx" #include "controller/SlsSelectionManager.hxx" -#include "controller/SlsTransferable.hxx" +#include "controller/SlsClipboard.hxx" +#include "controller/SlsTransferableData.hxx" #include "DrawDocShell.hxx" #include "drawdoc.hxx" #include "app.hrc" +#include "sdtreelb.hxx" #include <sfx2/bindings.hxx> #include <boost/bind.hpp> @@ -58,8 +60,19 @@ DragAndDropContext::DragAndDropContext (SlideSorter& rSlideSorter) if (rSlideSorter.GetModel().GetEditMode() != EM_PAGE) return; - rSlideSorter.GetController().GetInsertionIndicatorHandler()->UpdateIndicatorIcon( - dynamic_cast<Transferable*>(SD_MOD()->pTransferDrag)); + // For poperly handling transferables created by the navigator we + // need additional information. For this a user data object is + // created that contains the necessary information. + SdTransferable* pTransferable = SD_MOD()->pTransferDrag; + SdPageObjsTLB::SdPageObjsTransferable* pTreeListBoxTransferable + = dynamic_cast<SdPageObjsTLB::SdPageObjsTransferable*>(pTransferable); + if (pTreeListBoxTransferable!=NULL && !TransferableData::GetFromTransferable(pTransferable)) + { + pTransferable->AddUserData( + rSlideSorter.GetController().GetClipboard().CreateTransferableUserData(pTransferable)); + } + + rSlideSorter.GetController().GetInsertionIndicatorHandler()->UpdateIndicatorIcon(pTransferable); } diff --git a/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx b/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx index 882adab932a8..d663d106f6bf 100644 --- a/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx +++ b/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx @@ -120,7 +120,7 @@ void InsertionIndicatorHandler::ForceEnd (void) -void InsertionIndicatorHandler::UpdateIndicatorIcon (const Transferable* pTransferable) +void InsertionIndicatorHandler::UpdateIndicatorIcon (const SdTransferable* pTransferable) { mpInsertionIndicatorOverlay->Create(pTransferable); maIconSize = mpInsertionIndicatorOverlay->GetSize(); diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx index fc5687e0afc0..938289046043 100644 --- a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx @@ -32,7 +32,7 @@ #include "SlideSorter.hxx" #include "SlideSorterViewShell.hxx" #include "SlsDragAndDropContext.hxx" -#include "controller/SlsTransferable.hxx" +#include "controller/SlsTransferableData.hxx" #include "controller/SlideSorterController.hxx" #include "controller/SlsPageSelector.hxx" #include "controller/SlsFocusManager.hxx" diff --git a/sd/source/ui/slidesorter/controller/SlsTransferable.cxx b/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx index 1f03c70759b6..682b4c7f741c 100755 --- a/sd/source/ui/slidesorter/controller/SlsTransferable.cxx +++ b/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx @@ -28,21 +28,48 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sd.hxx" -#include "controller/SlsTransferable.hxx" +#include "controller/SlsTransferableData.hxx" #include "SlideSorterViewShell.hxx" #include "View.hxx" namespace sd { namespace slidesorter { namespace controller { -Transferable::Transferable ( +SdTransferable* TransferableData::CreateTransferable ( SdDrawDocument* pSrcDoc, ::sd::View* pWorkView, sal_Bool bInitOnGetData, SlideSorterViewShell* pViewShell, const ::std::vector<Representative>& rRepresentatives) - : SdTransferable (pSrcDoc, pWorkView, bInitOnGetData), - mpViewShell(pViewShell), +{ + SdTransferable* pTransferable = new SdTransferable (pSrcDoc, pWorkView, bInitOnGetData); + ::boost::shared_ptr<TransferableData> pData (new TransferableData(pViewShell, rRepresentatives)); + pTransferable->AddUserData(pData); + return pTransferable; +} + + + + +::boost::shared_ptr<TransferableData> TransferableData::GetFromTransferable (const SdTransferable* pTransferable) +{ + ::boost::shared_ptr<TransferableData> pData; + for (sal_Int32 nIndex=0,nCount=pTransferable->GetUserDataCount(); nIndex<nCount; ++nIndex) + { + pData = ::boost::dynamic_pointer_cast<TransferableData>(pTransferable->GetUserData(nIndex)); + if (pData) + return pData; + } + return ::boost::shared_ptr<TransferableData>(); +} + + + + +TransferableData::TransferableData ( + SlideSorterViewShell* pViewShell, + const ::std::vector<Representative>& rRepresentatives) + : mpViewShell(pViewShell), maRepresentatives(rRepresentatives) { if (mpViewShell != NULL) @@ -52,7 +79,7 @@ Transferable::Transferable ( -Transferable::~Transferable (void) +TransferableData::~TransferableData (void) { if (mpViewShell != NULL) EndListening(*mpViewShell); @@ -61,16 +88,28 @@ Transferable::~Transferable (void) -void Transferable::DragFinished (sal_Int8 nDropAction) +void TransferableData::DragFinished (sal_Int8 nDropAction) { if (mpViewShell != NULL) mpViewShell->DragFinished(nDropAction); + /* + for (CallbackContainer::const_iterator + iCallback(maDragFinishCallbacks.begin()), + iEnd(maDragFinishCallbacks.end()); + iCallback!=iEnd; + ++iCallback) + { + if (*iCallback) + (*iCallback)(nDropAction); + } + maDragFinishCallbacks.clear(); + */ } -void Transferable::Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint) +void TransferableData::Notify (SfxBroadcaster&, const SfxHint& rHint) { if (rHint.ISA(SfxSimpleHint) && mpViewShell!=NULL) { @@ -85,17 +124,22 @@ void Transferable::Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint) mpViewShell = NULL; } } - - SdTransferable::Notify(rBroadcaster, rHint); } -const ::std::vector<Transferable::Representative>& Transferable::GetRepresentatives (void) const +const ::std::vector<TransferableData::Representative>& TransferableData::GetRepresentatives (void) const { return maRepresentatives; } + + +SlideSorterViewShell* TransferableData::GetSourceViewShell (void) const +{ + return mpViewShell; +} + } } } // end of namespace ::sd::slidesorter::controller diff --git a/sd/source/ui/slidesorter/controller/makefile.mk b/sd/source/ui/slidesorter/controller/makefile.mk index 460ef16ed3f1..18479cc86aa0 100755 --- a/sd/source/ui/slidesorter/controller/makefile.mk +++ b/sd/source/ui/slidesorter/controller/makefile.mk @@ -60,7 +60,7 @@ SLOFILES = \ $(SLO)$/SlsSelectionManager.obj \ $(SLO)$/SlsSelectionObserver.obj \ $(SLO)$/SlsSlotManager.obj \ - $(SLO)$/SlsTransferable.obj \ + $(SLO)$/SlsTransferableData.obj \ $(SLO)$/SlsVisibleAreaManager.obj # --- Tagets ------------------------------------------------------- diff --git a/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx index 1bf5b8eae177..622bed457464 100755 --- a/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx +++ b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx @@ -30,6 +30,8 @@ #include "ViewClipboard.hxx" #include "controller/SlsSelectionObserver.hxx" +#include "sdxfer.hxx" + #include <sal/types.h> #include <tools/solar.h> #include <svx/svdpage.hxx> @@ -58,6 +60,8 @@ namespace sd { namespace slidesorter { namespace model { class PageDescriptor; } } } +namespace { class NavigatorDropEvent; } + namespace sd { namespace slidesorter { namespace controller { class SlideSorterController; @@ -69,6 +73,12 @@ public: Clipboard (SlideSorter& rSlideSorter); ~Clipboard (void); + /** Create a slide sorter transferable from the given sd + transferable. The returned transferable is set up with all + information necessary so that it can be dropped on a slide sorter. + */ + ::boost::shared_ptr<SdTransferable::UserData> CreateTransferableUserData (SdTransferable* pTransferable); + void HandleSlotCall (SfxRequest& rRequest); void DoCut (::Window* pWindow = 0); @@ -189,8 +199,8 @@ private: transferable is not accepted. The reason is the missing implementation of proper handling master pages copy-and-paste. */ - enum DropType { DT_PAGE, DT_SHAPE, DT_NONE }; - DropType IsDropAccepted (void) const; + enum DropType { DT_PAGE, DT_PAGE_FROM_NAVIGATOR, DT_SHAPE, DT_NONE }; + DropType IsDropAccepted (DropTargetHelper& rTargetHelper) const; /** This method contains the code for AcceptDrop() and ExecuteDrop() shapes. There are only minor differences for the two cases at this level. @@ -221,10 +231,19 @@ private: sal_uInt16 nPage, sal_uInt16 nLayer); + /** Return whether the insertion defined by the transferable is + trivial, ie would not change either source nor target document. + */ + bool IsInsertionTrivial ( + SdTransferable* pTransferable, + const sal_Int8 nDndAction) const; + /** Asynchronous part of DragFinished. The argument is the sal_Int8 nDropAction, disguised as void*. */ DECL_LINK(ProcessDragFinished, void*); + + DECL_LINK(ExecuteNavigatorDrop, NavigatorDropEvent*); }; } } } // end of namespace ::sd::slidesorter::controller diff --git a/sd/source/ui/slidesorter/inc/controller/SlsInsertionIndicatorHandler.hxx b/sd/source/ui/slidesorter/inc/controller/SlsInsertionIndicatorHandler.hxx index e257c5729b10..1492e707d42d 100644 --- a/sd/source/ui/slidesorter/inc/controller/SlsInsertionIndicatorHandler.hxx +++ b/sd/source/ui/slidesorter/inc/controller/SlsInsertionIndicatorHandler.hxx @@ -31,6 +31,8 @@ #include "view/SlsInsertAnimator.hxx" #include "view/SlsLayouter.hxx" +#include "sdxfer.hxx" + namespace sd { namespace slidesorter { class SlideSorter; } } namespace sd { namespace slidesorter { namespace model { @@ -83,7 +85,7 @@ public: /** Update the indicator icon from the current transferable (from the clipboard or an active drag and drop operation.) */ - void UpdateIndicatorIcon (const Transferable* pTransferable); + void UpdateIndicatorIcon (const SdTransferable* pTransferable); /** Set the position of the insertion marker to the given coordinates. */ diff --git a/sd/source/ui/slidesorter/inc/controller/SlsTransferable.hxx b/sd/source/ui/slidesorter/inc/controller/SlsTransferableData.hxx index c0a09e73bfe9..775e759f891a 100644 --- a/sd/source/ui/slidesorter/inc/controller/SlsTransferable.hxx +++ b/sd/source/ui/slidesorter/inc/controller/SlsTransferableData.hxx @@ -25,10 +25,12 @@ * ************************************************************************/ -#ifndef SD_SLIDESORTER_TRANSFERABLE_HXX -#define SD_SLIDESORTER_TRANSFERABLE_HXX +#ifndef SD_SLIDESORTER_TRANSFERABLE_DATA_HXX +#define SD_SLIDESORTER_TRANSFERABLE_DATA_HXX #include "sdxfer.hxx" +#include <boost/function.hpp> +#include <vector> class SdDrawDocument; namespace sd { namespace slidesorter { @@ -37,12 +39,12 @@ class SlideSorterViewShell; namespace sd { namespace slidesorter { namespace controller { - -/** This class exists to have DragFinished call the correct object: the - SlideSorterViewShell instead of the old SlideView. +/** Represent previews and other information so that they can be + attached to an existing transferable. */ -class Transferable - : public SdTransferable +class TransferableData + : public SdTransferable::UserData, + public SfxListener { public: class Representative @@ -61,23 +63,32 @@ public: bool mbIsExcluded; }; - - Transferable ( + static SdTransferable* CreateTransferable ( SdDrawDocument* pSrcDoc, ::sd::View* pWorkView, sal_Bool bInitOnGetData, SlideSorterViewShell* pViewShell, - const ::std::vector<Representative>& rRepresentatives); + const ::std::vector<TransferableData::Representative>& rRepresentatives); - virtual ~Transferable (void); + static ::boost::shared_ptr<TransferableData> GetFromTransferable (const SdTransferable* pTransferable); + + TransferableData ( + SlideSorterViewShell* pViewShell, + const ::std::vector<TransferableData::Representative>& rRepresentatives); + ~TransferableData (void); virtual void DragFinished (sal_Int8 nDropAction); const ::std::vector<Representative>& GetRepresentatives (void) const; + /** Return the view shell for which the transferable was created. + */ + SlideSorterViewShell* GetSourceViewShell (void) const; + private: SlideSorterViewShell* mpViewShell; const ::std::vector<Representative> maRepresentatives; + typedef ::std::vector<boost::function<void(sal_uInt8)> > CallbackContainer; virtual void Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint); }; diff --git a/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx b/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx index f28287b15a0e..8840f3732367 100644 --- a/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx +++ b/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx @@ -258,6 +258,8 @@ public: ButtonBar& GetButtonBar (void) const; ToolTip& GetToolTip (void) const; + virtual void DragFinished (sal_Int8 nDropAction); + protected: virtual void Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint); diff --git a/sd/source/ui/slidesorter/inc/view/SlsInsertionIndicatorOverlay.hxx b/sd/source/ui/slidesorter/inc/view/SlsInsertionIndicatorOverlay.hxx index a9a640d978cf..a48d5fe9986a 100644 --- a/sd/source/ui/slidesorter/inc/view/SlsInsertionIndicatorOverlay.hxx +++ b/sd/source/ui/slidesorter/inc/view/SlsInsertionIndicatorOverlay.hxx @@ -30,7 +30,8 @@ #include "model/SlsSharedPageDescriptor.hxx" #include "view/SlsILayerPainter.hxx" -#include "controller/SlsTransferable.hxx" +#include "controller/SlsTransferableData.hxx" +#include "sdxfer.hxx" #include <tools/gen.hxx> #include <vcl/bitmapex.hxx> @@ -71,7 +72,7 @@ public: virtual void SetLayerInvalidator (const SharedILayerInvalidator& rpInvalidator); - void Create (const controller::Transferable* pTransferable); + void Create (const SdTransferable* pTransferable); /** Given a position in model coordinates this method calculates the insertion marker both as an index in the document and as a location @@ -110,7 +111,7 @@ private: OutputDevice& rContent, const Size aPreviewSize, const sal_Int32 nOffset, - const ::std::vector<controller::Transferable::Representative>& rPages) const; + const ::std::vector<controller::TransferableData::Representative>& rPages) const; void PaintPageCount ( OutputDevice& rDevice, const sal_Int32 nSelectionCount, @@ -120,7 +121,7 @@ private: scaled down previews of some of the selected pages. */ void Create ( - const ::std::vector<controller::Transferable::Representative>& rPages, + const ::std::vector<controller::TransferableData::Representative>& rPages, const sal_Int32 nSelectionCount); }; diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/sd/source/ui/slidesorter/view/SlideSorterView.cxx index 728eff5ee384..58d3b1167fb5 100644 --- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx +++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx @@ -43,6 +43,7 @@ #include "view/SlsToolTip.hxx" #include "controller/SlideSorterController.hxx" #include "controller/SlsProperties.hxx" +#include "controller/SlsClipboard.hxx" #include "model/SlideSorterModel.hxx" #include "model/SlsPageEnumerationProvider.hxx" #include "model/SlsPageDescriptor.hxx" @@ -177,7 +178,6 @@ SlideSorterView::SlideSorterView (SlideSorter& rSlideSorter) // Hide the page that contains the page objects. SetPageVisible (sal_False); - // Register the background painter on level 1 to avoid the creation of a // background buffer. mpLayeredDevice->RegisterPainter(mpBackgroundPainter, 1); @@ -901,6 +901,16 @@ ToolTip& SlideSorterView::GetToolTip (void) const +void SlideSorterView::DragFinished (sal_Int8 nDropAction) +{ + mrSlideSorter.GetController().GetClipboard().DragFinished(nDropAction); + + View::DragFinished(nDropAction); +} + + + + void SlideSorterView::Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint) { ::sd::DrawDocShell* pDocShell = mrModel.GetDocument()->GetDocSh(); diff --git a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx index abaa5a43b215..6b5620655dbe 100644 --- a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx +++ b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx @@ -103,11 +103,15 @@ InsertionIndicatorOverlay::~InsertionIndicatorOverlay (void) -void InsertionIndicatorOverlay::Create (const controller::Transferable* pTransferable) +void InsertionIndicatorOverlay::Create (const SdTransferable* pTransferable) { if (pTransferable == NULL) return; + ::boost::shared_ptr<controller::TransferableData> pData ( + controller::TransferableData::GetFromTransferable(pTransferable)); + if ( ! pData) + return; sal_Int32 nSelectionCount (0); if (pTransferable->HasPageBookmarks()) nSelectionCount = pTransferable->GetPageBookmarks().Count(); @@ -121,14 +125,14 @@ void InsertionIndicatorOverlay::Create (const controller::Transferable* pTransfe nSelectionCount = pDataDocument->GetSdPageCount(PK_STANDARD); } } - Create(pTransferable->GetRepresentatives(), nSelectionCount); + Create(pData->GetRepresentatives(), nSelectionCount); } void InsertionIndicatorOverlay::Create ( - const ::std::vector<controller::Transferable::Representative>& rRepresentatives, + const ::std::vector<controller::TransferableData::Representative>& rRepresentatives, const sal_Int32 nSelectionCount) { view::Layouter& rLayouter (mrSlideSorter.GetView().GetLayouter()); @@ -196,7 +200,7 @@ Point InsertionIndicatorOverlay::PaintRepresentatives ( OutputDevice& rContent, const Size aPreviewSize, const sal_Int32 nOffset, - const ::std::vector<controller::Transferable::Representative>& rRepresentatives) const + const ::std::vector<controller::TransferableData::Representative>& rRepresentatives) const { const Point aOffset (0,rRepresentatives.size()==1 ? -nOffset : 0); |