summaryrefslogtreecommitdiff
path: root/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sd/source/ui/slidesorter/controller/SlsClipboard.cxx')
-rwxr-xr-x[-rw-r--r--]sd/source/ui/slidesorter/controller/SlsClipboard.cxx366
1 files changed, 240 insertions, 126 deletions
diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
index 4f1a0e35fe0c..700b3e0a605a 100644..100755
--- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
@@ -36,16 +36,18 @@
#include "model/SlsPageDescriptor.hxx"
#include "model/SlsPageEnumerationProvider.hxx"
#include "view/SlideSorterView.hxx"
-#include "view/SlsViewOverlay.hxx"
-#include "view/SlsPageObject.hxx"
+#include "view/SlsTheme.hxx"
#include "controller/SlideSorterController.hxx"
+#include "controller/SlsInsertionIndicatorHandler.hxx"
#include "controller/SlsPageSelector.hxx"
#include "controller/SlsSelectionFunction.hxx"
#include "controller/SlsCurrentSlideManager.hxx"
#include "controller/SlsScrollBarManager.hxx"
#include "controller/SlsFocusManager.hxx"
#include "controller/SlsSelectionManager.hxx"
-#include "SlsTransferable.hxx"
+#include "controller/SlsTransferable.hxx"
+#include "controller/SlsSelectionObserver.hxx"
+#include "cache/SlsPageCache.hxx"
#include "ViewShellBase.hxx"
#include "DrawViewShell.hxx"
@@ -75,6 +77,7 @@
#include <sfx2/bindings.hxx>
#include <sfx2/docfile.hxx>
#include <svx/svxids.hrc>
+#include <svx/svdstr.hrc>
#include <vcl/msgbox.hxx>
#include <tools/urlobj.hxx>
#include <rtl/ustring.hxx>
@@ -83,6 +86,43 @@
namespace sd { namespace slidesorter { namespace controller {
+class Clipboard::UndoContext
+{
+public:
+ UndoContext (
+ SdDrawDocument* pDocument,
+ const ::boost::shared_ptr<ViewShell>& rpMainViewShell,
+ const ::boost::shared_ptr<view::Theme>& rpTheme)
+ : mpDocument(pDocument),
+ mpMainViewShell(rpMainViewShell)
+ {
+ if (mpDocument!=NULL && mpDocument->IsUndoEnabled())
+ {
+ if (mpMainViewShell && mpMainViewShell->GetShellType() == ViewShell::ST_DRAW)
+ mpDocument->BegUndo(rpTheme->GetString(view::Theme::String_DragAndDropPages));
+ else
+ mpDocument->BegUndo(rpTheme->GetString(view::Theme::String_DragAndDropSlides));
+ }
+ }
+
+ ~UndoContext (void)
+ {
+ if (mpDocument!=NULL && mpDocument->IsUndoEnabled())
+ mpDocument->EndUndo();
+ if (mpMainViewShell && mpMainViewShell->GetViewFrame()!=NULL)
+ {
+ SfxBindings& rBindings = mpMainViewShell->GetViewFrame()->GetBindings();
+ rBindings.Invalidate(SID_UNDO);
+ rBindings.Invalidate(SID_REDO);
+ }
+ }
+private:
+ SdDrawDocument* mpDocument;
+ ::boost::shared_ptr<ViewShell> mpMainViewShell;
+};
+
+
+
Clipboard::Clipboard (SlideSorter& rSlideSorter)
: ViewClipboard(rSlideSorter.GetView()),
@@ -90,7 +130,10 @@ Clipboard::Clipboard (SlideSorter& rSlideSorter)
mrController(mrSlideSorter.GetController()),
maPagesToRemove(),
maPagesToSelect(),
- mbUpdateSelectionPending(false)
+ mbUpdateSelectionPending(false),
+ mpUndoContext(),
+ mpSelectionObserverContext(),
+ mnDragFinishedUserEventId(0)
{
}
@@ -99,6 +142,8 @@ Clipboard::Clipboard (SlideSorter& rSlideSorter)
Clipboard::~Clipboard (void)
{
+ if (mnDragFinishedUserEventId != 0)
+ Application::RemoveUserEvent(mnDragFinishedUserEventId);
}
@@ -144,13 +189,12 @@ void Clipboard::HandleSlotCall (SfxRequest& rRequest)
// a crash.
if (mrSlideSorter.GetModel().GetEditMode() != EM_MASTERPAGE)
{
- mrSlideSorter.GetView().LockRedraw (TRUE);
+ view::SlideSorterView::DrawLock aLock (mrSlideSorter);
+ SelectionObserver::Context aContext (mrSlideSorter);
if(xFunc.is())
xFunc->DoPaste();
else
DoPaste();
- mrController.GetSelectionManager()->MakeSelectionVisible();
- mrSlideSorter.GetView().LockRedraw(FALSE);
}
rRequest.Done();
break;
@@ -190,7 +234,7 @@ void Clipboard::DoDelete (::Window* )
void Clipboard::DoCopy (::Window* pWindow )
{
- CreateSlideTransferable( pWindow, FALSE );
+ CreateSlideTransferable( pWindow, sal_False );
}
@@ -210,7 +254,7 @@ void Clipboard::DoPaste (::Window* pWindow)
sal_Int32 nInsertPageCount = PasteTransferable(nInsertPosition);
// Select the pasted pages and make the first of them the
// current page.
- mrSlideSorter.GetView().GetWindow()->GrabFocus();
+ mrSlideSorter.GetContentWindow()->GrabFocus();
SelectPageRange(nInsertPosition, nInsertPageCount);
}
}
@@ -231,14 +275,22 @@ sal_Int32 Clipboard::GetInsertionPosition (::Window* pWindow)
// selection.
// d) After the last page when there is no selection and no focus.
- view::InsertionIndicatorOverlay& rInsertionIndicatorOverlay (
- mrSlideSorter.GetView().GetOverlay().GetInsertionIndicatorOverlay());
- if (rInsertionIndicatorOverlay.isVisible())
+ ::boost::shared_ptr<controller::InsertionIndicatorHandler> pInsertionIndicatorHandler (
+ mrController.GetInsertionIndicatorHandler());
+ if (pInsertionIndicatorHandler->IsActive())
{
- nInsertPosition = rInsertionIndicatorOverlay.GetInsertionPageIndex();
+ // Use the insertion index of an active insertion indicator.
+ nInsertPosition = pInsertionIndicatorHandler->GetInsertionPageIndex();
+ }
+ else if (mrController.GetSelectionManager()->GetInsertionPosition() >= 0)
+ {
+ // Use the insertion index of an insertion indicator that has been
+ // deactivated a short while ago.
+ nInsertPosition = mrController.GetSelectionManager()->GetInsertionPosition();
}
else if (mrController.GetFocusManager().IsFocusShowing())
{
+ // Use the focus to determine the insertion position.
SdInsertPasteDlg aDialog (pWindow);
if (aDialog.Execute() == RET_OK)
{
@@ -247,10 +299,6 @@ sal_Int32 Clipboard::GetInsertionPosition (::Window* pWindow)
nInsertPosition ++;
}
}
- else
- {
- nInsertPosition = mrController.GetSelectionManager()->GetInsertionPosition();
- }
return nInsertPosition;
}
@@ -261,27 +309,27 @@ sal_Int32 Clipboard::GetInsertionPosition (::Window* pWindow)
sal_Int32 Clipboard::PasteTransferable (sal_Int32 nInsertPosition)
{
SdTransferable* pClipTransferable = SD_MOD()->pTransferClip;
- bool bMergeMasterPages = !pClipTransferable->HasSourceDoc (
- mrSlideSorter.GetModel().GetDocument());
- USHORT nInsertIndex ((USHORT)(nInsertPosition * 2 + 1));
+ model::SlideSorterModel& rModel (mrSlideSorter.GetModel());
+ bool bMergeMasterPages = !pClipTransferable->HasSourceDoc (rModel.GetDocument());
+ sal_uInt16 nInsertIndex (rModel.GetCoreIndex(nInsertPosition));
sal_Int32 nInsertPageCount (0);
if (pClipTransferable->HasPageBookmarks())
{
const List& rBookmarkList = pClipTransferable->GetPageBookmarks();
const SolarMutexGuard aGuard;
- nInsertPageCount = (USHORT) rBookmarkList.Count();
- mrSlideSorter.GetModel().GetDocument()->InsertBookmarkAsPage(
+ nInsertPageCount = (sal_uInt16) rBookmarkList.Count();
+ rModel.GetDocument()->InsertBookmarkAsPage(
const_cast<List*>(&rBookmarkList),
NULL,
- FALSE,
- FALSE,
+ sal_False,
+ sal_False,
nInsertIndex,
- FALSE,
+ sal_False,
pClipTransferable->GetPageDocShell(),
- TRUE,
+ sal_True,
bMergeMasterPages,
- FALSE);
+ sal_False);
}
else
{
@@ -294,19 +342,19 @@ sal_Int32 Clipboard::PasteTransferable (sal_Int32 nInsertPosition)
{
const SolarMutexGuard aGuard;
- bMergeMasterPages = (pDataDoc != mrSlideSorter.GetModel().GetDocument());
+ bMergeMasterPages = (pDataDoc != rModel.GetDocument());
nInsertPageCount = pDataDoc->GetSdPageCount( PK_STANDARD );
- mrSlideSorter.GetModel().GetDocument()->InsertBookmarkAsPage(
+ rModel.GetDocument()->InsertBookmarkAsPage(
NULL,
NULL,
- FALSE,
- FALSE,
+ sal_False,
+ sal_False,
nInsertIndex,
- FALSE,
+ sal_False,
pDataDocSh,
- TRUE,
+ sal_True,
bMergeMasterPages,
- FALSE);
+ sal_False);
}
}
mrController.HandleModelChange();
@@ -322,7 +370,7 @@ void Clipboard::SelectPageRange (sal_Int32 nFirstIndex, sal_Int32 nPageCount)
// after the nInsertIndex position.
PageSelector& rSelector (mrController.GetPageSelector());
rSelector.DeselectAllPages();
- for (USHORT i=0; i<nPageCount; i++)
+ for (sal_uInt16 i=0; i<nPageCount; i++)
{
model::SharedPageDescriptor pDescriptor (
mrSlideSorter.GetModel().GetPageDescriptor(nFirstIndex + i));
@@ -333,7 +381,6 @@ void Clipboard::SelectPageRange (sal_Int32 nFirstIndex, sal_Int32 nPageCount)
if (i == 0)
{
mrController.GetCurrentSlideManager()->SwitchCurrentSlide(pDescriptor);
- mrController.GetFocusManager().SetFocusedPage(pDescriptor);
}
}
}
@@ -362,6 +409,27 @@ void Clipboard::CreateSlideTransferable (
maPagesToRemove.push_back (pDescriptor->GetPage());
}
+ // Create a small set of representatives of the selection for which
+ // previews are included into the transferable so that an insertion
+ // indicator can be rendered.
+ aSelectedPages.Rewind();
+ ::std::vector<Transferable::Representative> aRepresentatives;
+ aRepresentatives.reserve(3);
+ ::boost::shared_ptr<cache::PageCache> pPreviewCache (
+ mrSlideSorter.GetView().GetPreviewCache());
+ while (aSelectedPages.HasMoreElements())
+ {
+ model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
+ if ( ! pDescriptor || pDescriptor->GetPage()==NULL)
+ continue;
+ Bitmap aPreview (pPreviewCache->GetPreviewBitmap(pDescriptor->GetPage(), false));
+ aRepresentatives.push_back(Transferable::Representative(
+ aPreview,
+ pDescriptor->HasState(model::PageDescriptor::ST_Excluded)));
+ if (aRepresentatives.size() >= 3)
+ break;
+ }
+
if (aBookmarkList.Count() > 0)
{
mrSlideSorter.GetView().BrkAction();
@@ -369,8 +437,9 @@ void Clipboard::CreateSlideTransferable (
SdTransferable* pTransferable = new Transferable (
pDocument,
NULL,
- FALSE,
- dynamic_cast<SlideSorterViewShell*>(mrSlideSorter.GetViewShell()));
+ sal_False,
+ dynamic_cast<SlideSorterViewShell*>(mrSlideSorter.GetViewShell()),
+ aRepresentatives);
if (bDrag)
SD_MOD()->pTransferDrag = pTransferable;
@@ -424,13 +493,17 @@ void Clipboard::CreateSlideTransferable (
void Clipboard::StartDrag (
- const Point&,
+ const Point& rPosition,
::Window* pWindow)
{
maPagesToRemove.clear();
maPagesToSelect.clear();
mbUpdateSelectionPending = false;
- CreateSlideTransferable (pWindow, TRUE);
+ CreateSlideTransferable(pWindow, sal_True);
+
+ mrController.GetInsertionIndicatorHandler()->UpdatePosition(
+ rPosition,
+ InsertionIndicatorHandler::UnknownMode);
}
@@ -438,15 +511,36 @@ void Clipboard::StartDrag (
void Clipboard::DragFinished (sal_Int8 nDropAction)
{
- // Hide the substitution display and insertion indicator.
- mrSlideSorter.GetView().GetOverlay().GetSubstitutionOverlay().setVisible(false);
- mrSlideSorter.GetView().GetOverlay().GetInsertionIndicatorOverlay().setVisible(false);
-
SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag;
-
if (pDragTransferable != NULL)
pDragTransferable->SetView (NULL);
+ if (mnDragFinishedUserEventId == 0)
+ {
+ if ( ! Application::PostUserEvent(
+ mnDragFinishedUserEventId,
+ LINK(this, Clipboard, ProcessDragFinished),
+ reinterpret_cast<void*>(nDropAction)))
+ {
+ mnDragFinishedUserEventId = 0;
+ }
+ }
+}
+
+
+
+
+IMPL_LINK(Clipboard, ProcessDragFinished, void*, pUserData)
+{
+ const sal_Int8 nDropAction (static_cast<sal_Int8>(reinterpret_cast<sal_IntPtr>(pUserData)));
+
+ mnDragFinishedUserEventId = 0;
+
+ // Hide the substitution display and insertion indicator.
+ ::rtl::Reference<SelectionFunction> pFunction (mrController.GetCurrentSelectionFunction());
+ if (pFunction.is())
+ pFunction->NotifyDragFinished();
+
PageSelector& rSelector (mrController.GetPageSelector());
if ((nDropAction & DND_ACTION_MOVE) != 0
&& ! maPagesToRemove.empty())
@@ -459,12 +553,14 @@ void Clipboard::DragFinished (sal_Int8 nDropAction)
aDraggedPage!=maPagesToRemove.end();
++aDraggedPage)
{
- rSelector.SelectPage (*aDraggedPage);
+ rSelector.SelectPage(*aDraggedPage);
}
- mrController.GetSelectionManager()->DeleteSelectedPages ();
+ mrController.GetSelectionManager()->DeleteSelectedPages();
}
+ mpUndoContext.reset();
+ mpSelectionObserverContext.reset();
- SelectPages();
+ return 1;
}
@@ -490,17 +586,19 @@ sal_Int8 Clipboard::AcceptDrop (
const AcceptDropEvent& rEvent,
DropTargetHelper& rTargetHelper,
::sd::Window* pTargetWindow,
- USHORT nPage,
- USHORT nLayer)
+ sal_uInt16 nPage,
+ sal_uInt16 nLayer)
{
- sal_Int8 nResult = DND_ACTION_NONE;
+ sal_Int8 nAction (DND_ACTION_NONE);
- switch (IsDropAccepted())
+ const Clipboard::DropType eDropType (IsDropAccepted());
+
+ switch (eDropType)
{
case DT_PAGE:
{
// Accept a drop.
- nResult = rEvent.mnAction;
+ nAction = rEvent.mnAction;
// 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
@@ -513,23 +611,27 @@ sal_Int8 Clipboard::AcceptDrop (
&& (mrSlideSorter.GetModel().GetDocument()->GetDocSh()
!= pDragTransferable->GetPageDocShell()))
{
- nResult = DND_ACTION_COPY;
+ nAction = DND_ACTION_COPY;
+ }
+ else if (mrController.GetInsertionIndicatorHandler()->IsInsertionTrivial(nAction))
+ {
+ nAction = DND_ACTION_NONE;
}
// Show the insertion marker and the substitution for a drop.
Point aPosition = pTargetWindow->PixelToLogic (rEvent.maPosPixel);
- view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
- rOverlay.GetInsertionIndicatorOverlay().SetPosition (aPosition);
- rOverlay.GetInsertionIndicatorOverlay().setVisible(true);
- rOverlay.GetSubstitutionOverlay().SetPosition (aPosition);
+ SelectionFunction* pSelectionFunction = dynamic_cast<SelectionFunction*>(
+ mrSlideSorter.GetViewShell()->GetCurrentFunction().get());
+ if (pSelectionFunction != NULL)
+ pSelectionFunction->MouseDragged(rEvent, nAction);
// Scroll the window when the mouse reaches the window border.
- mrController.GetScrollBarManager().AutoScroll (rEvent.maPosPixel);
+ // mrController.GetScrollBarManager().AutoScroll (rEvent.maPosPixel);
}
break;
case DT_SHAPE:
- nResult = ExecuteOrAcceptShapeDrop(
+ nAction = ExecuteOrAcceptShapeDrop(
DC_ACCEPT,
rEvent.maPosPixel,
&rEvent,
@@ -538,11 +640,13 @@ sal_Int8 Clipboard::AcceptDrop (
nPage,
nLayer);
break;
+
default:
+ nAction = DND_ACTION_NONE;
break;
}
- return nResult;
+ return nAction;
}
@@ -552,10 +656,11 @@ sal_Int8 Clipboard::ExecuteDrop (
const ExecuteDropEvent& rEvent,
DropTargetHelper& rTargetHelper,
::sd::Window* pTargetWindow,
- USHORT nPage,
- USHORT nLayer)
+ sal_uInt16 nPage,
+ sal_uInt16 nLayer)
{
sal_Int8 nResult = DND_ACTION_NONE;
+ mpUndoContext.reset();
switch (IsDropAccepted())
{
@@ -564,54 +669,57 @@ sal_Int8 Clipboard::ExecuteDrop (
const SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag;
const Point aEventModelPosition (
pTargetWindow->PixelToLogic (rEvent.maPosPixel));
- long int nXOffset = labs (pDragTransferable->GetStartPos().X()
- - aEventModelPosition.X());
- long int nYOffset = labs (pDragTransferable->GetStartPos().Y()
- - aEventModelPosition.Y());
- const bool bContinue =
+ const sal_Int32 nXOffset (labs (pDragTransferable->GetStartPos().X()
+ - aEventModelPosition.X()));
+ const sal_Int32 nYOffset (labs (pDragTransferable->GetStartPos().Y()
+ - aEventModelPosition.Y()));
+ bool bContinue =
( pDragTransferable->GetView() != &mrSlideSorter.GetView() )
|| ( nXOffset >= 2 && nYOffset >= 2 );
+ ::boost::shared_ptr<InsertionIndicatorHandler> pInsertionIndicatorHandler(
+ mrController.GetInsertionIndicatorHandler());
// Get insertion position and then turn off the insertion indicator.
- view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
- rOverlay.GetInsertionIndicatorOverlay().SetPosition(
- aEventModelPosition);
- USHORT nIndex = DetermineInsertPosition (*pDragTransferable);
- OSL_TRACE ("Clipboard::AcceptDrop() called for index %d",
- nIndex);
- rOverlay.GetInsertionIndicatorOverlay().setVisible(false);
+ pInsertionIndicatorHandler->UpdatePosition(aEventModelPosition, rEvent.mnAction);
+ // sal_uInt16 nIndex = DetermineInsertPosition(*pDragTransferable);
+
+ // Do not process the insertion when it is trivial,
+ // i.e. would insert pages at their original place.
+ if (pInsertionIndicatorHandler->IsInsertionTrivial(rEvent.mnAction))
+ bContinue = false;
+
+ // Tell the insertion indicator handler to hide before the model
+ // is modified. Doing it later may result in page objects whose
+ // animation state is not properly reset because they are then
+ // in another run then before the model change.
+ pInsertionIndicatorHandler->End(Animator::AM_Immediate);
if (bContinue)
{
SlideSorterController::ModelChangeLock aModelChangeLock (mrController);
- if (pDragTransferable->GetView() == &mrSlideSorter.GetView()
- && rEvent.mnAction == DND_ACTION_MOVE)
- {
- // We are asked to move pages inside one view. For this we
- // call MoveSelectedPages() which is faster than going the
- // generic way.
-
- // Remember to select the moved pages afterwards.
- maPagesToRemove.swap(maPagesToSelect);
- maPagesToRemove.clear();
-
- USHORT nSdrModelIndex;
- if (nIndex != SDRPAGE_NOTFOUND)
- nSdrModelIndex = nIndex / 2 - 1;
- else
- nSdrModelIndex = SDRPAGE_NOTFOUND;
- mrController.GetSelectionManager()->MoveSelectedPages(nSdrModelIndex);
- mbUpdateSelectionPending = true;
- nResult = DND_ACTION_NONE;
- }
- else
- {
- // Handle a general drop operation.
- HandlePageDrop (*pDragTransferable);
- nResult = rEvent.mnAction;
- }
+ // Handle a general drop operation.
+ mpUndoContext.reset(new UndoContext (
+ mrSlideSorter.GetModel().GetDocument(),
+ mrSlideSorter.GetViewShell()->GetViewShellBase().GetMainViewShell(),
+ mrSlideSorter.GetTheme()));
+ mpSelectionObserverContext.reset(new SelectionObserver::Context(mrSlideSorter));
+
+ HandlePageDrop(*pDragTransferable);
+ nResult = rEvent.mnAction;
+
+ // We leave the undo context alive for when moving or
+ // copying inside one view then the actions in
+ // NotifyDragFinished should be covered as well as
+ // well as the ones above.
}
+
+ // Notify the receiving selection function that drag-and-drop is
+ // finished and the substitution handler can be released.
+ ::rtl::Reference<SelectionFunction> pFunction (
+ mrController.GetCurrentSelectionFunction());
+ if (pFunction.is())
+ pFunction->NotifyDragFinished();
}
break;
@@ -635,46 +743,52 @@ sal_Int8 Clipboard::ExecuteDrop (
-USHORT Clipboard::DetermineInsertPosition (const SdTransferable& )
+void Clipboard::Abort (void)
{
- USHORT nInsertPosition = SDRPAGE_NOTFOUND;
+ if (mpSelectionObserverContext)
+ {
+ mpSelectionObserverContext->Abort();
+ mpSelectionObserverContext.reset();
+ }
+}
+
+
+
+sal_uInt16 Clipboard::DetermineInsertPosition (const SdTransferable& )
+{
// Tell the model to move the dragged pages behind the one with the
// index nInsertionIndex which first has to be transformed into an index
// understandable by the document.
- view::InsertionIndicatorOverlay& rOverlay (
- mrSlideSorter.GetView().GetOverlay().GetInsertionIndicatorOverlay());
- sal_Int32 nInsertionIndex (rOverlay.GetInsertionPageIndex());
+ const sal_Int32 nInsertionIndex (
+ mrController.GetInsertionIndicatorHandler()->GetInsertionPageIndex());
- // The index returned by the overlay starts with 1 for the first slide.
- // This is now converted that to an SdModel index that also starts with 1.
+ // Convert to insertion index to that of an SdModel.
if (nInsertionIndex >= 0)
- nInsertPosition = (USHORT)nInsertionIndex * 2 + 1;
-
- return nInsertPosition;
+ return mrSlideSorter.GetModel().GetCoreIndex(nInsertionIndex);
+ else
+ return 0;
}
-USHORT Clipboard::InsertSlides (
+sal_uInt16 Clipboard::InsertSlides (
const SdTransferable& rTransferable,
- USHORT nInsertPosition)
+ sal_uInt16 nInsertPosition)
{
- USHORT nInsertedPageCount = ViewClipboard::InsertSlides (
+ sal_uInt16 nInsertedPageCount = ViewClipboard::InsertSlides (
rTransferable,
nInsertPosition);
// Remember the inserted pages so that they can be selected when the
// operation is finished.
- int nDocumentIndex = nInsertPosition / 2 - 1;
- for (USHORT i=1; i<=nInsertedPageCount; i++)
- {
- model::SharedPageDescriptor pDescriptor (
- mrSlideSorter.GetModel().GetPageDescriptor(nDocumentIndex + i));
- if (pDescriptor.get() != NULL)
- maPagesToSelect.push_back (pDescriptor->GetPage());
- }
+ maPagesToSelect.clear();
+ SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument();
+ if (pDocument != NULL)
+ for (sal_Int32 i=0; i<=nInsertedPageCount; i+=2)
+ maPagesToSelect.push_back(
+ dynamic_cast<SdPage*>(pDocument->GetPage(nInsertPosition+i)));
mbUpdateSelectionPending |= (nInsertedPageCount>0);
@@ -714,8 +828,8 @@ sal_Int8 Clipboard::ExecuteOrAcceptShapeDrop (
const void* pDropEvent,
DropTargetHelper& rTargetHelper,
::sd::Window* pTargetWindow,
- USHORT nPage,
- USHORT nLayer)
+ sal_uInt16 nPage,
+ sal_uInt16 nLayer)
{
sal_Int8 nResult = 0;
@@ -740,8 +854,8 @@ sal_Int8 Clipboard::ExecuteOrAcceptShapeDrop (
model::SharedPageDescriptor pDescriptor (
mrSlideSorter.GetModel().GetPageDescriptor(
mrSlideSorter.GetView().GetPageIndexAtPoint(rPosition)));
- if (pDescriptor.get() != NULL && pDescriptor->GetPage()!=NULL)
- nPage = (pDescriptor->GetPage()->GetPageNum() - 1) / 2;
+ if (pDescriptor)
+ nPage = pDescriptor->GetPageIndex();
}
// Now comes the code that is different for the Execute and Accept: