diff options
Diffstat (limited to 'sd/source/ui/slidesorter/controller/SlideSorterController.cxx')
-rw-r--r--[-rwxr-xr-x] | sd/source/ui/slidesorter/controller/SlideSorterController.cxx | 334 |
1 files changed, 232 insertions, 102 deletions
diff --git a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx index 69c2a02ddc24..8018c71e2b88 100755..100644 --- a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx +++ b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx @@ -39,17 +39,22 @@ #include "SlsSelectionCommand.hxx" #include "controller/SlsAnimator.hxx" #include "controller/SlsClipboard.hxx" +#include "controller/SlsInsertionIndicatorHandler.hxx" #include "controller/SlsScrollBarManager.hxx" -#include "controller/SlsPageObjectFactory.hxx" #include "controller/SlsSelectionManager.hxx" #include "controller/SlsSlotManager.hxx" +#include "controller/SlsTransferable.hxx" +#include "controller/SlsVisibleAreaManager.hxx" #include "model/SlideSorterModel.hxx" #include "model/SlsPageEnumerationProvider.hxx" #include "model/SlsPageDescriptor.hxx" #include "view/SlideSorterView.hxx" #include "view/SlsLayouter.hxx" -#include "view/SlsViewOverlay.hxx" #include "view/SlsFontProvider.hxx" +#include "view/SlsPageObjectLayouter.hxx" +#include "view/SlsPageObjectPainter.hxx" +#include "view/SlsTheme.hxx" +#include "view/SlsToolTip.hxx" #include "cache/SlsPageCache.hxx" #include "cache/SlsPageCacheManager.hxx" @@ -91,12 +96,12 @@ #include <com/sun/star/drawing/XDrawPages.hpp> #include <com/sun/star/accessibility/AccessibleEventId.hpp> - using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::sd::slidesorter::model; using namespace ::sd::slidesorter::view; using namespace ::sd::slidesorter::controller; +using namespace ::basegfx; namespace sd { namespace slidesorter { namespace controller { @@ -112,9 +117,12 @@ SlideSorterController::SlideSorterController (SlideSorter& rSlideSorter) mpScrollBarManager(), mpCurrentSlideManager(), mpSelectionManager(), + mpInsertionIndicatorHandler(new InsertionIndicatorHandler(rSlideSorter)), mpAnimator(new Animator(rSlideSorter)), + mpVisibleAreaManager(new VisibleAreaManager(rSlideSorter)), mpListener(), mnModelChangeLockCount(0), + mbIsForcedRearrangePending(false), mbPreModelChangeDone(false), mbPostModelChangePending(false), maSelectionBeforeSwitch(), @@ -122,12 +130,11 @@ SlideSorterController::SlideSorterController (SlideSorter& rSlideSorter) mpEditModeChangeMasterPage(NULL), maTotalWindowArea(), mnPaintEntranceCount(0), - mbIsContextMenuOpen(false), - mpProperties(new Properties()) + mbIsContextMenuOpen(false) { - ::sd::Window* pWindow = mrSlideSorter.GetActiveWindow(); - OSL_ASSERT(pWindow!=NULL); - if (pWindow != NULL) + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + OSL_ASSERT(pWindow); + if (pWindow) { // The whole background is painted by the view and controls. ::Window* pParentWindow = pWindow->GetParent(); @@ -136,22 +143,10 @@ SlideSorterController::SlideSorterController (SlideSorter& rSlideSorter) // Connect the view with the window that has been created by our base // class. - pWindow->SetBackground (Wallpaper()); - mrView.AddWindowToPaintView(pWindow); - mrView.SetActualWin(pWindow); - pWindow->SetCenterAllowed (false); - pWindow->SetViewSize (mrView.GetModelArea().GetSize()); - pWindow->EnableRTL(FALSE); - - // Reinitialize colors in Properties with window specific values. - mpProperties->SetBackgroundColor( - pWindow->GetSettings().GetStyleSettings().GetWindowColor()); - mpProperties->SetTextColor( - pWindow->GetSettings().GetStyleSettings().GetWindowTextColor()); - mpProperties->SetSelectionColor( - pWindow->GetSettings().GetStyleSettings().GetMenuHighlightColor()); - mpProperties->SetHighlightColor( - pWindow->GetSettings().GetStyleSettings().GetMenuHighlightColor()); + pWindow->SetBackground(Wallpaper()); + pWindow->SetCenterAllowed(false); + pWindow->SetMapMode(MapMode(MAP_PIXEL)); + pWindow->SetViewSize(mrView.GetModelArea().GetSize()); } } @@ -160,8 +155,6 @@ SlideSorterController::SlideSorterController (SlideSorter& rSlideSorter) void SlideSorterController::Init (void) { - mrView.HandleModelChange(); - mpCurrentSlideManager.reset(new CurrentSlideManager(mrSlideSorter)); mpPageSelector.reset(new PageSelector(mrSlideSorter)); mpFocusManager.reset(new FocusManager(mrSlideSorter)); @@ -181,7 +174,7 @@ void SlideSorterController::Init (void) mpListener = new Listener(mrSlideSorter); - mpPageSelector->UpdateAllPages(); + mpPageSelector->GetCoreSelection(); GetSelectionManager()->SelectionHasChanged(); } @@ -210,17 +203,48 @@ SlideSorterController::~SlideSorterController (void) +void SlideSorterController::Dispose (void) +{ + mpInsertionIndicatorHandler->End(Animator::AM_Immediate); + mpSelectionManager.reset(); + mpAnimator->Dispose(); +} + + + + model::SharedPageDescriptor SlideSorterController::GetPageAt ( - const Point& aPixelPosition) + const Point& aWindowPosition) { - sal_Int32 nHitPageIndex (mrView.GetPageIndexAtPoint(aPixelPosition)); + sal_Int32 nHitPageIndex (mrView.GetPageIndexAtPoint(aWindowPosition)); model::SharedPageDescriptor pDescriptorAtPoint; if (nHitPageIndex >= 0) + { pDescriptorAtPoint = mrModel.GetPageDescriptor(nHitPageIndex); + // Depending on a property we may have to check that the mouse is no + // just over the page object but over the preview area. + 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(aWindowPosition)) + { + pDescriptorAtPoint.reset(); + } + } + } + return pDescriptorAtPoint; } + + + PageSelector& SlideSorterController::GetPageSelector (void) { OSL_ASSERT(mpPageSelector.get()!=NULL); @@ -284,10 +308,11 @@ ScrollBarManager& SlideSorterController::GetScrollBarManager (void) -void SlideSorterController::PrePaint() +::boost::shared_ptr<InsertionIndicatorHandler> + SlideSorterController::GetInsertionIndicatorHandler (void) const { - // forward VCLs PrePaint window event to DrawingLayer - mrView.PrePaint(); + OSL_ASSERT(mpInsertionIndicatorHandler.get()!=NULL); + return mpInsertionIndicatorHandler; } @@ -297,16 +322,12 @@ void SlideSorterController::Paint ( const Rectangle& rBBox, ::Window* pWindow) { - // if (mnPaintEntranceCount == 0) + if (mnPaintEntranceCount == 0) { ++mnPaintEntranceCount; try { - if (GetSelectionManager()->IsMakeSelectionVisiblePending()) - GetSelectionManager()->MakeSelectionVisible(); - - mrView.SetApplicationDocumentColor(GetProperties()->GetBackgroundColor()); mrView.CompleteRedraw(pWindow, Region(rBBox), 0); } catch (const Exception&) @@ -394,50 +415,64 @@ bool SlideSorterController::Command ( else nPopupId = RID_SLIDE_SORTER_MASTER_NOSEL_POPUP; } - + ::boost::scoped_ptr<InsertionIndicatorHandler::ForceShowContext> pContext; if (pPage == NULL) { // When there is no selection, then we show the insertion // indicator so that the user knows where a page insertion // would take place. - mrView.GetOverlay().GetInsertionIndicatorOverlay().SetPosition( - pWindow->PixelToLogic(rEvent.GetMousePosPixel())); - mrView.GetOverlay().GetInsertionIndicatorOverlay().setVisible(true); + mpInsertionIndicatorHandler->Start(false); + mpInsertionIndicatorHandler->UpdateIndicatorIcon( + dynamic_cast<Transferable*>(SD_MOD()->pTransferClip)); + mpInsertionIndicatorHandler->UpdatePosition( + pWindow->PixelToLogic(rEvent.GetMousePosPixel()), + InsertionIndicatorHandler::MoveMode); + pContext.reset(new InsertionIndicatorHandler::ForceShowContext( + mpInsertionIndicatorHandler)); } pWindow->ReleaseMouse(); + + Point aMenuLocation (0,0); if (rEvent.IsMouseEvent()) { - mbIsContextMenuOpen = true; - if (pViewShell != NULL) - { - SfxDispatcher* pDispatcher = pViewShell->GetDispatcher(); - if (pDispatcher != NULL) - pDispatcher->ExecutePopup(SdResId(nPopupId)); - } + // We have to explicitly specify the location of the menu + // when the slide sorter is placed in an undocked child + // menu. But when it is docked it does not hurt, so we + // specify the location always. + aMenuLocation = rEvent.GetMousePosPixel(); } else { // The event is not a mouse event. Use the center of the // focused page as top left position of the context menu. - if (pPage != NULL) + model::SharedPageDescriptor pDescriptor ( + GetFocusManager().GetFocusedPageDescriptor()); + if (pDescriptor.get() != NULL) { - model::SharedPageDescriptor pDescriptor ( - GetFocusManager().GetFocusedPageDescriptor()); - if (pDescriptor.get() != NULL) - { - Rectangle aBBox (mrView.GetPageBoundingBox ( + Rectangle aBBox ( + mrView.GetLayouter().GetPageObjectLayouter()->GetBoundingBox ( pDescriptor, - view::SlideSorterView::CS_SCREEN, - view::SlideSorterView::BBT_SHAPE)); - Point aPosition (aBBox.Center()); - mbIsContextMenuOpen = true; - if (pViewShell != NULL) - pViewShell->GetViewFrame()->GetDispatcher()->ExecutePopup( - SdResId(nPopupId), - pWindow, - &aPosition); - } + PageObjectLayouter::PageObject, + PageObjectLayouter::ModelCoordinateSystem)); + aMenuLocation = aBBox.Center(); + } + } + + mbIsContextMenuOpen = true; + if (pViewShell != NULL) + { + SfxDispatcher* pDispatcher = pViewShell->GetDispatcher(); + if (pDispatcher != NULL) + { + pDispatcher->ExecutePopup( + SdResId(nPopupId), + pWindow, + &aMenuLocation); + mrSlideSorter.GetView().UpdatePageUnderMouse(false); + ::rtl::Reference<SelectionFunction> pFunction(GetCurrentSelectionFunction()); + if (pFunction.is()) + pFunction->ResetMouseAnchor(); } } mbIsContextMenuOpen = false; @@ -447,19 +482,44 @@ bool SlideSorterController::Command ( // it is hidden, so that a pending slide insertion slot call // finds the right place to insert a new slide. GetSelectionManager()->SetInsertionPosition( - mrView.GetOverlay().GetInsertionIndicatorOverlay().GetInsertionPageIndex()); - mrView.GetOverlay().GetInsertionIndicatorOverlay().setVisible(false); + GetInsertionIndicatorHandler()->GetInsertionPageIndex()); } + pContext.reset(); bEventHasBeenHandled = true; } break; case COMMAND_WHEEL: { - // We ignore zooming with control+mouse wheel. const CommandWheelData* pData = rEvent.GetWheelData(); - if (pData!=NULL && pData->IsMod1()) - bEventHasBeenHandled = true; + if (pData == NULL) + return false; + if (pData->IsMod1()) + { + // We do not support zooming with control+mouse wheel. + return false; + } + // Determine whether to scroll horizontally or vertically. This + // depends on the orientation of the scroll bar and the + // IsHoriz() flag of the event. + if ((mrSlideSorter.GetView().GetOrientation()==view::Layouter::HORIZONTAL) + == pData->IsHorz()) + { + GetScrollBarManager().Scroll( + ScrollBarManager::Orientation_Vertical, + ScrollBarManager::Unit_Slide, + -pData->GetNotchDelta()); + } + else + { + GetScrollBarManager().Scroll( + ScrollBarManager::Orientation_Horizontal, + ScrollBarManager::Unit_Slide, + -pData->GetNotchDelta()); + } + mrSlideSorter.GetView().UpdatePageUnderMouse(rEvent.GetMousePosPixel(), false); + + bEventHasBeenHandled = true; } break; } @@ -482,7 +542,9 @@ void SlideSorterController::UnlockModelChange (void) { mnModelChangeLockCount -= 1; if (mnModelChangeLockCount==0 && mbPostModelChangePending) + { PostModelChange(); + } } @@ -499,11 +561,9 @@ void SlideSorterController::PreModelChange (void) mrSlideSorter.GetViewShell()->Broadcast( ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START)); - mpPageSelector->PrepareModelChange(); GetCurrentSlideManager()->PrepareModelChange(); - ::sd::Window* pWindow = mrSlideSorter.GetActiveWindow(); - if (pWindow != NULL) + if (mrSlideSorter.GetContentWindow()) mrView.PreModelChange(); mbPostModelChangePending = true; @@ -517,8 +577,8 @@ void SlideSorterController::PostModelChange (void) mbPostModelChangePending = false; mrModel.Resync(); - ::sd::Window* pWindow = mrSlideSorter.GetActiveWindow(); - if (pWindow != NULL) + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + if (pWindow) { GetCurrentSlideManager()->HandleModelChange(); @@ -530,11 +590,9 @@ void SlideSorterController::PostModelChange (void) // The visibility of the scroll bars may have to be changed. Then // the size of the view has to change, too. Let Rearrange() handle // that. - Rearrange(); + Rearrange(mbIsForcedRearrangePending); } - mpPageSelector->HandleModelChange (); - if (mrSlideSorter.GetViewShell() != NULL) mrSlideSorter.GetViewShell()->Broadcast( ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END)); @@ -564,23 +622,36 @@ IMPL_LINK(SlideSorterController, WindowEventHandler, VclWindowEvent*, pEvent) if (pEvent != NULL) { ::Window* pWindow = pEvent->GetWindow(); - ::sd::Window* pActiveWindow = mrSlideSorter.GetActiveWindow(); + SharedSdWindow pActiveWindow (mrSlideSorter.GetContentWindow()); switch (pEvent->GetId()) { case VCLEVENT_WINDOW_ACTIVATE: case VCLEVENT_WINDOW_SHOW: - if (pActiveWindow != NULL && pWindow == pActiveWindow->GetParent()) + if (pActiveWindow && pWindow == pActiveWindow->GetParent()) mrView.RequestRepaint(); break; + case VCLEVENT_WINDOW_HIDE: + if (pActiveWindow && pWindow == pActiveWindow->GetParent()) + mrView.SetPageUnderMouse(SharedPageDescriptor()); + break; + case VCLEVENT_WINDOW_GETFOCUS: - if (pActiveWindow != NULL && pWindow == pActiveWindow) - GetFocusManager().ShowFocus(false); + if (pActiveWindow) + if (pWindow == pActiveWindow.get()) + GetFocusManager().ShowFocus(false); break; case VCLEVENT_WINDOW_LOSEFOCUS: - if (pActiveWindow != NULL && pWindow == pActiveWindow) + if (pActiveWindow && pWindow == pActiveWindow.get()) + { GetFocusManager().HideFocus(); + mrView.GetToolTip().Hide(); + + // Select the current slide so that it is properly + // visualized when the focus is moved to the edit view. + GetPageSelector().SelectPage(GetCurrentSlideManager()->GetCurrentSlide()); + } break; case VCLEVENT_APPLICATION_DATACHANGED: @@ -601,6 +672,11 @@ IMPL_LINK(SlideSorterController, WindowEventHandler, VclWindowEvent*, pEvent) // When the system font has changed a layout has to be done. mrView.Resize(); FontProvider::Instance().Invalidate(); + + // Update theme colors. + mrSlideSorter.GetProperties()->HandleDataChangeEvent(); + mrSlideSorter.GetTheme()->Update(mrSlideSorter.GetProperties()); + mrView.HandleDataChangeEvent(); } break; @@ -639,10 +715,9 @@ void SlideSorterController::GetCtrlState (SfxItemSet& rSet) ||rSet.GetItemState(SID_OUTPUT_QUALITY_BLACKWHITE)==SFX_ITEM_AVAILABLE ||rSet.GetItemState(SID_OUTPUT_QUALITY_CONTRAST)==SFX_ITEM_AVAILABLE) { - ::sd::Window* pWindow = mrSlideSorter.GetActiveWindow(); - if (pWindow != NULL) + if (mrSlideSorter.GetContentWindow()) { - ULONG nMode = pWindow->GetDrawMode(); + ULONG nMode = mrSlideSorter.GetContentWindow()->GetDrawMode(); UINT16 nQuality = 0; switch (nMode) @@ -715,7 +790,7 @@ void SlideSorterController::ExecStatusBar (SfxRequest& ) void SlideSorterController::UpdateAllPages (void) { // Do a redraw. - mrView.InvalidateAllWin(); + mrSlideSorter.GetContentWindow()->Invalidate(); } @@ -741,20 +816,35 @@ Rectangle SlideSorterController::Rearrange (bool bForce) { Rectangle aNewContentArea (maTotalWindowArea); - ::boost::shared_ptr<sd::Window> pWindow = mrSlideSorter.GetContentWindow(); - if (pWindow.get() != NULL) + if (aNewContentArea.IsEmpty()) + return aNewContentArea; + + if (mnModelChangeLockCount>0) { + mbIsForcedRearrangePending |= bForce; + return aNewContentArea; + } + else + mbIsForcedRearrangePending = false; + + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + if (pWindow) + { + if (bForce) + mrView.UpdateOrientation(); + // Place the scroll bars. - aNewContentArea = GetScrollBarManager().PlaceScrollBars(maTotalWindowArea); + aNewContentArea = GetScrollBarManager().PlaceScrollBars( + maTotalWindowArea, + mrView.GetOrientation() != view::Layouter::VERTICAL, + mrView.GetOrientation() != view::Layouter::HORIZONTAL); bool bSizeHasChanged (false); // Only when bForce is not true we have to test for a size change in // order to determine whether the window and the view have to be resized. if ( ! bForce) { - Rectangle aCurrentContentArea ( - pWindow->GetPosPixel(), - pWindow->GetOutputSizePixel()); + Rectangle aCurrentContentArea (pWindow->GetPosPixel(), pWindow->GetOutputSizePixel()); bSizeHasChanged = (aNewContentArea != aCurrentContentArea); } if (bForce || bSizeHasChanged) @@ -767,6 +857,11 @@ Rectangle SlideSorterController::Rearrange (bool bForce) // Adapt the scroll bars to the new zoom factor of the browser // window and the arrangement of the page objects. GetScrollBarManager().UpdateScrollBars(false, !bForce); + + // Keep the current slide in the visible area. + GetVisibleAreaManager().RequestCurrentSlideVisible(); + + mrView.RequestRepaint(); } return aNewContentArea; @@ -784,6 +879,15 @@ FunctionReference SlideSorterController::CreateSelectionFunction (SfxRequest& rR +::rtl::Reference<SelectionFunction> SlideSorterController::GetCurrentSelectionFunction (void) +{ + FunctionReference pFunction (mrSlideSorter.GetViewShell()->GetCurrentFunction()); + return ::rtl::Reference<SelectionFunction>(dynamic_cast<SelectionFunction*>(pFunction.get())); +} + + + + void SlideSorterController::PrepareEditModeChange (void) { // Before we throw away the page descriptors we prepare for selecting @@ -887,8 +991,8 @@ void SlideSorterController::PageNameHasChanged (int nPageIndex, const String& rs // that of the name change. do { - ::sd::Window* pWindow = mrSlideSorter.GetActiveWindow(); - if (pWindow == NULL) + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + if ( ! pWindow) break; ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > @@ -937,14 +1041,6 @@ bool SlideSorterController::IsContextMenuOpen (void) const -::boost::shared_ptr<Properties> SlideSorterController::GetProperties (void) const -{ - return mpProperties; -} - - - - void SlideSorterController::SetDocumentSlides (const Reference<container::XIndexAccess>& rxSlides) { if (mrModel.GetDocumentSlides() != rxSlides) @@ -954,6 +1050,11 @@ void SlideSorterController::SetDocumentSlides (const Reference<container::XIndex mrModel.SetDocumentSlides(rxSlides); mrView.Layout(); + + // Select just the current slide. + PageSelector::BroadcastLock aBroadcastLock (*mpPageSelector); + mpPageSelector->DeselectAllPages(); + mpPageSelector->SelectPage(mpCurrentSlideManager->GetCurrentSlide()); } } @@ -968,6 +1069,35 @@ void SlideSorterController::SetDocumentSlides (const Reference<container::XIndex +VisibleAreaManager& SlideSorterController::GetVisibleAreaManager (void) const +{ + OSL_ASSERT(mpVisibleAreaManager); + return *mpVisibleAreaManager; +} + + + + +void SlideSorterController::CheckForMasterPageAssignment (void) +{ + if (mrModel.GetPageCount()%2==0) + return; + PageEnumeration aAllPages (PageEnumerationProvider::CreateAllPagesEnumeration(mrModel)); + while (aAllPages.HasMoreElements()) + { + SharedPageDescriptor pDescriptor (aAllPages.GetNextElement()); + if (pDescriptor->UpdateMasterPage()) + { + mrView.GetPreviewCache()->InvalidatePreviewBitmap ( + pDescriptor->GetPage(), + true); + } + } +} + + + + //===== SlideSorterController::ModelChangeLock ================================ SlideSorterController::ModelChangeLock::ModelChangeLock ( |