diff --git a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx index c32e814f8768..e5a78bd1caac 100644 --- a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx +++ b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx @@ -230,8 +230,24 @@ model::SharedPageDescriptor SlideSorterController::GetPageAt ( sal_Int32 nHitPageIndex (mrView.GetPageIndexAtPoint(aPixelPosition)); model::SharedPageDescriptor pDescriptorAtPoint; if (nHitPageIndex >= 0) + { pDescriptorAtPoint = mrModel.GetPageDescriptor(nHitPageIndex); + if (pDescriptorAtPoint + && mrSlideSorter.GetProperties()->IsOnlyPreviewTriggersMouseOver() + && ! pDescriptorAtPoint->HasState(PageDescriptor::ST_Selected)) + { + // Make sure that the mouse is over the preview area. + if ( ! mrView.GetLayouter().GetPageObjectLayouter()->GetBoundingBox( + pDescriptorAtPoint, + view::PageObjectLayouter::Preview, + view::PageObjectLayouter::WindowCoordinateSystem).IsInside(aPixelPosition)) + { + pDescriptorAtPoint.reset(); + } + } + } + return pDescriptorAtPoint; } diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx index 453c1e69e81c..3213a3ce1bdc 100644 --- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx +++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx @@ -528,13 +528,6 @@ sal_Int8 Clipboard::AcceptDrop ( sal_Int8 nResult = DND_ACTION_NONE; const Clipboard::DropType eDropType (IsDropAccepted()); - if (eDropType != DT_NONE) - { - FunctionReference rFunction (mrSlideSorter.GetViewShell()->GetCurrentFunction()); - SelectionFunction* pSelectionFunction = dynamic_cast(rFunction.get()); - if (pSelectionFunction != NULL) - pSelectionFunction->MouseDragged(rEvent); - } switch (eDropType) { @@ -559,9 +552,10 @@ sal_Int8 Clipboard::AcceptDrop ( // Show the insertion marker and the substitution for a drop. Point aPosition = pTargetWindow->PixelToLogic (rEvent.maPosPixel); - mrController.GetInsertionIndicatorHandler()->UpdatePosition( - aPosition, - rEvent.maDragEvent.DropAction); + SelectionFunction* pSelectionFunction = dynamic_cast( + mrSlideSorter.GetViewShell()->GetCurrentFunction().get()); + if (pSelectionFunction != NULL) + pSelectionFunction->MouseDragged(rEvent, nResult); // Scroll the window when the mouse reaches the window border. // mrController.GetScrollBarManager().AutoScroll (rEvent.maPosPixel); @@ -617,7 +611,6 @@ sal_Int8 Clipboard::ExecuteDrop ( aEventModelPosition, rEvent.mnAction); USHORT nIndex = DetermineInsertPosition(*pDragTransferable); - mrController.GetInsertionIndicatorHandler()->End(); if (bContinue) { @@ -650,6 +643,7 @@ sal_Int8 Clipboard::ExecuteDrop ( nResult = rEvent.mnAction; } } + mrController.GetInsertionIndicatorHandler()->End(); // Notify the receiving selection function that drag-and-drop is // finished and the substitution handler can be released. diff --git a/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx b/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx index 2d0d79483d19..21b3f3f5b942 100644 --- a/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx +++ b/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx @@ -241,5 +241,4 @@ void DragAndDropContext::SetTargetSlideSorter ( } - } } } // end of namespace ::sd::slidesorter::controller diff --git a/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx b/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx index d29748d01ae1..6b6c8916ebf7 100644 --- a/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx +++ b/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx @@ -98,6 +98,9 @@ void InsertionIndicatorHandler::End (void) GetInsertAnimator()->Reset(); mbIsActive = false; + maInsertPosition = view::InsertPosition(); + meMode = UnknownMode; + mpInsertionIndicatorOverlay->Hide(); } @@ -116,12 +119,12 @@ void InsertionIndicatorHandler::UpdateIndicatorIcon (const Transferable* pTransf InsertionIndicatorHandler::Mode InsertionIndicatorHandler::GetModeFromDndAction ( const sal_Int8 nDndAction) { - switch (nDndAction & (ACTION_COPY | ACTION_MOVE | ACTION_LINK)) - { - case ACTION_COPY: return CopyMode; - case ACTION_MOVE: return MoveMode; - default: return UnknownMode; - } + if ((nDndAction & ACTION_MOVE) != 0) + return MoveMode; + else if ((nDndAction & ACTION_COPY) != 0) + return CopyMode; + else + return UnknownMode; } @@ -184,7 +187,8 @@ void InsertionIndicatorHandler::SetPosition ( if (maInsertPosition != aInsertPosition || meMode != eMode - || ! mpInsertionIndicatorOverlay->IsVisible()) + // || ! mpInsertionIndicatorOverlay->IsVisible() + ) { maInsertPosition = aInsertPosition; meMode = eMode; diff --git a/sd/source/ui/slidesorter/controller/SlsProperties.cxx b/sd/source/ui/slidesorter/controller/SlsProperties.cxx index 48cc8a705cde..81aa9f0f3160 100644 --- a/sd/source/ui/slidesorter/controller/SlsProperties.cxx +++ b/sd/source/ui/slidesorter/controller/SlsProperties.cxx @@ -47,7 +47,8 @@ Properties::Properties (void) maTextColor(Application::GetSettings().GetStyleSettings().GetActiveTextColor()), maSelectionColor(Application::GetSettings().GetStyleSettings().GetHighlightColor()), maHighlightColor(Application::GetSettings().GetStyleSettings().GetMenuHighlightColor()), - mbIsUIReadOnly(false) + mbIsUIReadOnly(false), + mbIsOnlyPreviewTriggersMouseOver(true) { } @@ -245,4 +246,20 @@ void Properties::SetUIReadOnly (const bool bIsUIReadOnly) } + + +bool Properties::IsOnlyPreviewTriggersMouseOver (void) const +{ + return mbIsOnlyPreviewTriggersMouseOver; +} + + + + +void Properties::SetOnlyPreviewTriggersMouseOver (const bool bFlag) +{ + mbIsOnlyPreviewTriggersMouseOver = bFlag; +} + + } } } // end of namespace ::sd::slidesorter::controller diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx index ea4f10e14107..02d484e7223e 100644 --- a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx @@ -194,14 +194,11 @@ public: EventDescriptor ( sal_uInt32 nEventType, - const MouseEvent& rEvent, + const Point& rMousePosition, SlideSorter& rSlideSorter); EventDescriptor ( const KeyEvent& rEvent, SlideSorter& rSlideSorter); - EventDescriptor ( - const AcceptDropEvent& rEvent, - SlideSorter& rSlideSorter); EventDescriptor (const EventDescriptor& rDescriptor); void SetDragMode (const InsertionIndicatorHandler::Mode eMode); @@ -262,7 +259,7 @@ BOOL SelectionFunction::MouseButtonDown (const MouseEvent& rEvent) aMDPos = rEvent.GetPosPixel(); mbProcessingMouseButtonDown = true; - mpWindow->CaptureMouse(); + // mpWindow->CaptureMouse(); ProcessMouseEvent(BUTTON_DOWN, rEvent); @@ -312,9 +309,6 @@ BOOL SelectionFunction::MouseButtonUp (const MouseEvent& rEvent) { mrController.GetScrollBarManager().StopAutoScroll (); - // #95491# remember button state for creation of own MouseEvents - SetMouseButtonCode (rEvent.GetButtons()); - ProcessMouseEvent(BUTTON_UP, rEvent); mbProcessingMouseButtonDown = false; @@ -326,8 +320,12 @@ BOOL SelectionFunction::MouseButtonUp (const MouseEvent& rEvent) -void SelectionFunction::MouseDragged (const AcceptDropEvent& rEvent) +void SelectionFunction::MouseDragged ( + const AcceptDropEvent& rEvent, + const sal_Int8 nDragAction) { + const InsertionIndicatorHandler::Mode eMode ( + InsertionIndicatorHandler::GetModeFromDndAction(nDragAction));//rEvent.mnAction)); if (rEvent.mbLeaving) { if (mpDragAndDropContext) @@ -346,14 +344,12 @@ void SelectionFunction::MouseDragged (const AcceptDropEvent& rEvent) mrController.GetInsertionIndicatorHandler()->Start( pDragTransferable != NULL && pDragTransferable->GetView()==&mrSlideSorter.GetView()); - mpDragAndDropContext->UpdatePosition( - rEvent.maPosPixel, - InsertionIndicatorHandler::GetModeFromDndAction(rEvent.mnAction)); + mpDragAndDropContext->UpdatePosition(rEvent.maPosPixel, eMode); } // 1. Compute some frequently used values relating to the event. ::std::auto_ptr pEventDescriptor ( - new EventDescriptor(rEvent, mrSlideSorter)); + new EventDescriptor(MOUSE_DRAG, rEvent.maPosPixel, mrSlideSorter)); // 2. Detect whether we are dragging pages or dragging a selection rectangle. if (mpDragAndDropContext) @@ -362,8 +358,7 @@ void SelectionFunction::MouseDragged (const AcceptDropEvent& rEvent) pEventDescriptor->mnEventCode |= MULTI_SELECTOR; // 3. Set the drag mode. - pEventDescriptor->SetDragMode( - InsertionIndicatorHandler::GetModeFromDndAction(rEvent.mnAction)); + pEventDescriptor->SetDragMode(eMode); // 4. Process the event. if ( ! ProcessEvent(*pEventDescriptor)) @@ -687,6 +682,14 @@ void SelectionFunction::StartDrag ( const Point& rMousePosition, const InsertionIndicatorHandler::Mode eMode) { + // Do not start a drag-and-drop operation when one is already active. + // (when dragging pages from one document into another, pressing a + // modifier key can trigger a MouseMotion event in the originating + // window (focus still in there). Together with the mouse button pressed + // (drag-and-drop is active) this triggers the start of drag-and-drop.) + if (SD_MOD()->pTransferDrag != NULL) + return; + if ( ! mrSlideSorter.GetProperties()->IsUIReadOnly()) { if (mrSlideSorter.GetViewShell() != NULL) @@ -817,7 +820,7 @@ void SelectionFunction::ProcessMouseEvent (sal_uInt32 nEventType, const MouseEve // 1. Compute some frequently used values relating to the event. ::std::auto_ptr pEventDescriptor ( - new EventDescriptor(nEventType, rEvent, mrSlideSorter)); + new EventDescriptor(nEventType, rEvent.GetPosPixel(), mrSlideSorter)); // 2. Compute a numerical code that describes the event and that is used // for fast look-up of the associated reaction. @@ -1016,11 +1019,9 @@ void SelectionFunction::ProcessEventWhileDragActive (EventDescriptor& rDescripto // The substitution is visible. Handle events accordingly. if (Match(rDescriptor.mnEventCode, MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK)) { - if ((rDescriptor.mnEventCode & CONTROL_MODIFIER) != 0) - StartDrag(rDescriptor.maMousePosition, InsertionIndicatorHandler::CopyMode); - mpDragAndDropContext->UpdatePosition( - rDescriptor.maMousePosition, - rDescriptor.meDragMode); + // mpDragAndDropContext->UpdatePosition( + // rDescriptor.maMousePosition, + // rDescriptor.meDragMode); } else if (Match(rDescriptor.mnEventCode, MOUSE_DRAG)) { @@ -1176,6 +1177,10 @@ void SelectionFunction::ProcessMouseMotionEvent (const EventDescriptor& rDescrip { switch (rDescriptor.mnEventCode) { + case ANY_MODIFIER(MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE): + SetCurrentPage(rDescriptor.mpHitDescriptor); + // Fallthrough + // A mouse motion without visible substitution starts that. case ANY_MODIFIER(MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE): StartDrag( @@ -1305,19 +1310,16 @@ void SelectionFunction::ProcessButtonClick ( SelectionFunction::EventDescriptor::EventDescriptor ( sal_uInt32 nEventType, - const MouseEvent& rEvent, + const Point& rMousePosition, SlideSorter& rSlideSorter) - : maMousePosition(), + : maMousePosition(rMousePosition), maMouseModelPosition(), mpHitDescriptor(), mpHitPage(), mnEventCode(nEventType), mnButtonIndex(-1) { - SharedSdWindow pWindow (rSlideSorter.GetContentWindow()); - - maMousePosition = rEvent.GetPosPixel(); - maMouseModelPosition = pWindow->PixelToLogic(maMousePosition); + maMouseModelPosition = rSlideSorter.GetContentWindow()->PixelToLogic(maMousePosition); mpHitDescriptor = rSlideSorter.GetController().GetPageAt(maMousePosition); if (mpHitDescriptor) { @@ -1359,33 +1361,6 @@ SelectionFunction::EventDescriptor::EventDescriptor ( -SelectionFunction::EventDescriptor::EventDescriptor ( - const AcceptDropEvent& rEvent, - SlideSorter& rSlideSorter) - : maMousePosition(rEvent.maPosPixel), - maMouseModelPosition(), - mpHitDescriptor(), - mpHitPage(), - mnEventCode(MOUSE_DRAG), - mnButtonIndex(-1), - meDragMode(InsertionIndicatorHandler::MoveMode), - mbMakeSelectionVisible(true) -{ - SharedSdWindow pWindow (rSlideSorter.GetContentWindow()); - - maMouseModelPosition = pWindow->PixelToLogic(maMousePosition); - model::SharedPageDescriptor pHitDescriptor ( - rSlideSorter.GetController().GetPageAt(maMousePosition)); - if (pHitDescriptor.get() != NULL) - { - mpHitDescriptor = pHitDescriptor; - mpHitPage = pHitDescriptor->GetPage(); - } -} - - - - SelectionFunction::EventDescriptor::EventDescriptor (const EventDescriptor& rDescriptor) : maMousePosition(rDescriptor.maMousePosition), maMouseModelPosition(rDescriptor.maMouseModelPosition), diff --git a/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx b/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx index ef5b07d8d670..db72a7e54deb 100644 --- a/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx +++ b/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx @@ -114,7 +114,8 @@ public: SlideSorter& GetSlideSorter (void) const; /** Return the descriptor of the page that is rendered under the - given position. + given position. This takes the IsOnlyPreviewTriggersMouseOver + property into account. @return Returns a pointer to a page descriptor instead of a reference because when no page is found at the position diff --git a/sd/source/ui/slidesorter/inc/controller/SlsProperties.hxx b/sd/source/ui/slidesorter/inc/controller/SlsProperties.hxx index 15aa980aaca5..d850d1779c51 100644 --- a/sd/source/ui/slidesorter/inc/controller/SlsProperties.hxx +++ b/sd/source/ui/slidesorter/inc/controller/SlsProperties.hxx @@ -117,6 +117,13 @@ public: bool IsUIReadOnly (void) const; void SetUIReadOnly (const bool bIsUIReadOnly); + /** The mouse over effect (and whether a mouse motion starts a multi + selection or a drag-and-drop) can be triggered by just the preview + area or the whole page object area. + */ + bool IsOnlyPreviewTriggersMouseOver (void) const; + void SetOnlyPreviewTriggersMouseOver (const bool bFlag); + private: bool mbIsHighlightCurrentSlide; bool mbIsShowSelection; @@ -129,6 +136,7 @@ private: Color maSelectionColor; Color maHighlightColor; bool mbIsUIReadOnly; + bool mbIsOnlyPreviewTriggersMouseOver; }; } } } // end of namespace ::sd::slidesorter::controller diff --git a/sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx b/sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx index 8a354697ceff..71315adbbb1c 100644 --- a/sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx +++ b/sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx @@ -94,7 +94,9 @@ public: */ virtual bool cancel(); - void MouseDragged (const AcceptDropEvent& rEvent); + void MouseDragged ( + const AcceptDropEvent& rEvent, + const sal_Int8 nDragAction); /** Turn of substitution display and insertion indicator. */