diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-01-28 20:53:50 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-01-28 20:53:50 +0100 |
commit | 0e1042f42101dd2a7407a38d204de6f4de28890a (patch) | |
tree | 9e9f67205cd5b72f1031721273e1534a3a1e5b0f /sd/source/ui/slidesorter/controller | |
parent | 8377f5594498d5378d67c8a3e06b5e14b0051fb4 (diff) |
replace obsolete "master" branch with README that points at new repoHEADmaster-deletedmaster
Diffstat (limited to 'sd/source/ui/slidesorter/controller')
27 files changed, 0 insertions, 11436 deletions
diff --git a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx deleted file mode 100644 index 984d01663..000000000 --- a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx +++ /dev/null @@ -1,1134 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "controller/SlideSorterController.hxx" - -#include "SlideSorter.hxx" -#include "controller/SlsPageSelector.hxx" -#include "controller/SlsSelectionFunction.hxx" -#include "controller/SlsProperties.hxx" -#include "controller/SlsCurrentSlideManager.hxx" -#include "SlsListener.hxx" -#include "controller/SlsFocusManager.hxx" -#include "SlsSelectionCommand.hxx" -#include "controller/SlsAnimator.hxx" -#include "controller/SlsClipboard.hxx" -#include "controller/SlsInsertionIndicatorHandler.hxx" -#include "controller/SlsScrollBarManager.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/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" - -#include "drawdoc.hxx" -#include "DrawViewShell.hxx" -#include "TextLogger.hxx" -#include "ViewShellBase.hxx" -#include "Window.hxx" -#include "FrameView.hxx" -#include "DrawDocShell.hxx" -#include "sdpage.hxx" -#include "res_bmp.hrc" -#include "sdresid.hxx" -#include "strings.hrc" -#include "app.hrc" -#include "glob.hrc" -#include "sdmod.hxx" -#include "sdxfer.hxx" -#include "FrameView.hxx" -#include "ViewShellHint.hxx" -#include "AccessibleSlideSorterView.hxx" -#include "AccessibleSlideSorterObject.hxx" - -#include <vcl/window.hxx> -#include <svx/svdopage.hxx> -#include <svx/svxids.hrc> -#include <svx/ruler.hxx> -#include <svx/zoomitem.hxx> -#include <svtools/tabbar.hxx> -#include <sfx2/request.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/dispatch.hxx> -#include <tools/link.hxx> -#include <vcl/svapp.hxx> - -#include <com/sun/star/lang/XComponent.hpp> -#include <com/sun/star/drawing/XMasterPagesSupplier.hpp> -#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> -#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 { - - -SlideSorterController::SlideSorterController (SlideSorter& rSlideSorter) - : mrSlideSorter(rSlideSorter), - mrModel(mrSlideSorter.GetModel()), - mrView(mrSlideSorter.GetView()), - mpPageSelector(), - mpFocusManager(), - mpSlotManager(), - mpClipboard(), - 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(), - mnCurrentPageBeforeSwitch(0), - mpEditModeChangeMasterPage(NULL), - maTotalWindowArea(), - mnPaintEntranceCount(0), - mbIsContextMenuOpen(false) -{ - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - OSL_ASSERT(pWindow); - if (pWindow) - { - // The whole background is painted by the view and controls. - ::Window* pParentWindow = pWindow->GetParent(); - OSL_ASSERT(pParentWindow!=NULL); - pParentWindow->SetBackground (Wallpaper()); - - // Connect the view with the window that has been created by our base - // class. - pWindow->SetBackground(Wallpaper()); - pWindow->SetCenterAllowed(false); - pWindow->SetMapMode(MapMode(MAP_PIXEL)); - pWindow->SetViewSize(mrView.GetModelArea().GetSize()); - } -} - - - - -void SlideSorterController::Init (void) -{ - mpCurrentSlideManager.reset(new CurrentSlideManager(mrSlideSorter)); - mpPageSelector.reset(new PageSelector(mrSlideSorter)); - mpFocusManager.reset(new FocusManager(mrSlideSorter)); - mpSlotManager.reset(new SlotManager(mrSlideSorter)); - mpClipboard.reset(new Clipboard(mrSlideSorter)); - mpScrollBarManager.reset(new ScrollBarManager(mrSlideSorter)); - mpSelectionManager.reset(new SelectionManager(mrSlideSorter)); - - mpScrollBarManager->LateInitialization(); - - // Create the selection function. - SfxRequest aRequest ( - SID_OBJECT_SELECT, - 0, - mrModel.GetDocument()->GetItemPool()); - mrSlideSorter.SetCurrentFunction(CreateSelectionFunction(aRequest)); - - mpListener = new Listener(mrSlideSorter); - - mpPageSelector->GetCoreSelection(); - GetSelectionManager()->SelectionHasChanged(); -} - - - - -SlideSorterController::~SlideSorterController (void) -{ - try - { - uno::Reference<lang::XComponent> xComponent ( - static_cast<XWeak*>(mpListener.get()), uno::UNO_QUERY); - if (xComponent.is()) - xComponent->dispose(); - } - catch( uno::Exception& e ) - { - (void)e; - OSL_FAIL( "sd::SlideSorterController::~SlideSorterController(), exception caught!" ); - } - - // dispose should have been called by now so that nothing is to be done - // to shut down cleanly. -} - - - - -void SlideSorterController::Dispose (void) -{ - mpInsertionIndicatorHandler->End(Animator::AM_Immediate); - mpSelectionManager.reset(); - mpAnimator->Dispose(); -} - - - - -model::SharedPageDescriptor SlideSorterController::GetPageAt ( - const Point& aWindowPosition) -{ - 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); - return *mpPageSelector.get(); -} - - - - -FocusManager& SlideSorterController::GetFocusManager (void) -{ - OSL_ASSERT(mpFocusManager.get()!=NULL); - return *mpFocusManager.get(); -} - - - - -Clipboard& SlideSorterController::GetClipboard (void) -{ - OSL_ASSERT(mpClipboard.get()!=NULL); - return *mpClipboard.get(); -} - - - - -ScrollBarManager& SlideSorterController::GetScrollBarManager (void) -{ - OSL_ASSERT(mpScrollBarManager.get()!=NULL); - return *mpScrollBarManager.get(); -} - - - - -::boost::shared_ptr<CurrentSlideManager> SlideSorterController::GetCurrentSlideManager (void) const -{ - OSL_ASSERT(mpCurrentSlideManager.get()!=NULL); - return mpCurrentSlideManager; -} - - - - -::boost::shared_ptr<SlotManager> SlideSorterController::GetSlotManager (void) const -{ - OSL_ASSERT(mpSlotManager.get()!=NULL); - return mpSlotManager; -} - - - - -::boost::shared_ptr<SelectionManager> SlideSorterController::GetSelectionManager (void) const -{ - OSL_ASSERT(mpSelectionManager.get()!=NULL); - return mpSelectionManager; -} - - - - -::boost::shared_ptr<InsertionIndicatorHandler> - SlideSorterController::GetInsertionIndicatorHandler (void) const -{ - OSL_ASSERT(mpInsertionIndicatorHandler.get()!=NULL); - return mpInsertionIndicatorHandler; -} - - - - -void SlideSorterController::Paint ( - const Rectangle& rBBox, - ::Window* pWindow) -{ - if (mnPaintEntranceCount == 0) - { - ++mnPaintEntranceCount; - - try - { - mrView.CompleteRedraw(pWindow, Region(rBBox), 0); - } - catch (const Exception&) - { - // Ignore all exceptions. - } - - --mnPaintEntranceCount; - } -} - - - - -void SlideSorterController::FuTemporary (SfxRequest& rRequest) -{ - mpSlotManager->FuTemporary (rRequest); -} - - - - -void SlideSorterController::FuPermanent (SfxRequest &rRequest) -{ - mpSlotManager->FuPermanent (rRequest); -} - - - - -void SlideSorterController::FuSupport (SfxRequest &rRequest) -{ - mpSlotManager->FuSupport (rRequest); -} - - - - -bool SlideSorterController::Command ( - const CommandEvent& rEvent, - ::sd::Window* pWindow) -{ - bool bEventHasBeenHandled = false; - - if (pWindow == NULL) - return false; - - ViewShell* pViewShell = mrSlideSorter.GetViewShell(); - if (pViewShell == NULL) - return false; - - switch (rEvent.GetCommand()) - { - case COMMAND_CONTEXTMENU: - { - SdPage* pPage = NULL; - sal_uInt16 nPopupId; - - model::PageEnumeration aSelectedPages ( - PageEnumerationProvider::CreateSelectedPagesEnumeration(mrModel)); - if (aSelectedPages.HasMoreElements()) - pPage = aSelectedPages.GetNextElement()->GetPage(); - - // Choose the popup menu depending on a) the type of the main - // view shell, b) the edit mode, and c) on whether the selection - // is empty or not. - ViewShell::ShellType eMainViewShellType (ViewShell::ST_NONE); - ::boost::shared_ptr<ViewShell> pMainViewShell ( - pViewShell->GetViewShellBase().GetMainViewShell()); - if (pMainViewShell.get() != NULL) - eMainViewShellType = pMainViewShell->GetShellType(); - switch (eMainViewShellType) - { - case ViewShell::ST_DRAW: - if (pPage != NULL) - nPopupId = RID_SLIDE_SORTER_DRAW_SEL_POPUP; - else - nPopupId = RID_SLIDE_SORTER_DRAW_NOSEL_POPUP; - break; - - default: - if (mrModel.GetEditMode() == EM_PAGE) - if (pPage != NULL) - nPopupId = RID_SLIDE_SORTER_IMPRESS_SEL_POPUP; - else - nPopupId = RID_SLIDE_SORTER_IMPRESS_NOSEL_POPUP; - else - if (pPage != NULL) - nPopupId = RID_SLIDE_SORTER_MASTER_SEL_POPUP; - 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. - 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()) - { - // 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. - model::SharedPageDescriptor pDescriptor ( - GetFocusManager().GetFocusedPageDescriptor()); - if (pDescriptor.get() != NULL) - { - Rectangle aBBox ( - mrView.GetLayouter().GetPageObjectLayouter()->GetBoundingBox ( - pDescriptor, - 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; - if (pPage == NULL) - { - // Remember the position of the insertion indicator before - // it is hidden, so that a pending slide insertion slot call - // finds the right place to insert a new slide. - GetSelectionManager()->SetInsertionPosition( - GetInsertionIndicatorHandler()->GetInsertionPageIndex()); - } - pContext.reset(); - bEventHasBeenHandled = true; - } - break; - - case COMMAND_WHEEL: - { - const CommandWheelData* pData = rEvent.GetWheelData(); - 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; - } - - return bEventHasBeenHandled; -} - - - - -void SlideSorterController::LockModelChange (void) -{ - mnModelChangeLockCount += 1; -} - - - - -void SlideSorterController::UnlockModelChange (void) -{ - mnModelChangeLockCount -= 1; - if (mnModelChangeLockCount==0 && mbPostModelChangePending) - { - PostModelChange(); - } -} - - - - -void SlideSorterController::PreModelChange (void) -{ - // Prevent PreModelChange to execute more than once per model lock. - if (mbPostModelChangePending) - return; - mbPreModelChangeDone = true; - - if (mrSlideSorter.GetViewShell() != NULL) - mrSlideSorter.GetViewShell()->Broadcast( - ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START)); - - GetCurrentSlideManager()->PrepareModelChange(); - - if (mrSlideSorter.GetContentWindow()) - mrView.PreModelChange(); - - mbPostModelChangePending = true; -} - - - - -void SlideSorterController::PostModelChange (void) -{ - mbPostModelChangePending = false; - mrModel.Resync(); - - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - if (pWindow) - { - GetCurrentSlideManager()->HandleModelChange(); - - mrView.PostModelChange (); - - pWindow->SetViewOrigin (Point (0,0)); - pWindow->SetViewSize (mrView.GetModelArea().GetSize()); - - // 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(mbIsForcedRearrangePending); - } - - if (mrSlideSorter.GetViewShell() != NULL) - mrSlideSorter.GetViewShell()->Broadcast( - ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END)); -} - - - - -void SlideSorterController::HandleModelChange (void) -{ - // Ignore this call when the document is not in a valid state, i.e. has - // not the same number of regular and notes pages. - bool bIsDocumentValid = (mrModel.GetDocument()->GetPageCount() % 2 == 1); - - if (bIsDocumentValid) - { - ModelChangeLock aLock (*this); - PreModelChange(); - } -} - - - - -IMPL_LINK(SlideSorterController, WindowEventHandler, VclWindowEvent*, pEvent) -{ - if (pEvent != NULL) - { - ::Window* pWindow = pEvent->GetWindow(); - SharedSdWindow pActiveWindow (mrSlideSorter.GetContentWindow()); - switch (pEvent->GetId()) - { - case VCLEVENT_WINDOW_ACTIVATE: - case VCLEVENT_WINDOW_SHOW: - 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) - if (pWindow == pActiveWindow.get()) - GetFocusManager().ShowFocus(false); - break; - - case VCLEVENT_WINDOW_LOSEFOCUS: - 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: - { - // Invalidate the preview cache. - cache::PageCacheManager::Instance()->InvalidateAllCaches(); - - // Update the draw mode. - sal_uLong nDrawMode (Application::GetSettings().GetStyleSettings().GetHighContrastMode() - ? ViewShell::OUTPUT_DRAWMODE_CONTRAST - : ViewShell::OUTPUT_DRAWMODE_COLOR); - if (mrSlideSorter.GetViewShell() != NULL) - mrSlideSorter.GetViewShell()->GetFrameView()->SetDrawMode(nDrawMode); - if (pActiveWindow != NULL) - pActiveWindow->SetDrawMode(nDrawMode); - mrView.HandleDrawModeChange(); - - // 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; - - default: - break; - } - } - - return sal_True; -} - - - - -void SlideSorterController::GetCtrlState (SfxItemSet& rSet) -{ - if (rSet.GetItemState(SID_RELOAD) != SFX_ITEM_UNKNOWN) - { - // "Letzte Version" vom SFx en/disablen lassen - SfxViewFrame* pSlideViewFrame = SfxViewFrame::Current(); - DBG_ASSERT(pSlideViewFrame!=NULL, - "SlideSorterController::GetCtrlState: ViewFrame not found"); - if (pSlideViewFrame) - { - pSlideViewFrame->GetSlotState (SID_RELOAD, NULL, &rSet); - } - else // MI sagt: kein MDIFrame --> disablen - { - rSet.DisableItem(SID_RELOAD); - } - } - - // Output quality. - if (rSet.GetItemState(SID_OUTPUT_QUALITY_COLOR)==SFX_ITEM_AVAILABLE - ||rSet.GetItemState(SID_OUTPUT_QUALITY_GRAYSCALE)==SFX_ITEM_AVAILABLE - ||rSet.GetItemState(SID_OUTPUT_QUALITY_BLACKWHITE)==SFX_ITEM_AVAILABLE - ||rSet.GetItemState(SID_OUTPUT_QUALITY_CONTRAST)==SFX_ITEM_AVAILABLE) - { - if (mrSlideSorter.GetContentWindow()) - { - sal_uLong nMode = mrSlideSorter.GetContentWindow()->GetDrawMode(); - sal_uInt16 nQuality = 0; - - switch (nMode) - { - case ViewShell::OUTPUT_DRAWMODE_COLOR: - nQuality = 0; - break; - case ViewShell::OUTPUT_DRAWMODE_GRAYSCALE: - nQuality = 1; - break; - case ViewShell::OUTPUT_DRAWMODE_BLACKWHITE: - nQuality = 2; - break; - case ViewShell::OUTPUT_DRAWMODE_CONTRAST: - nQuality = 3; - break; - } - - rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_COLOR, - (sal_Bool)(nQuality==0))); - rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_GRAYSCALE, - (sal_Bool)(nQuality==1))); - rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_BLACKWHITE, - (sal_Bool)(nQuality==2))); - rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_CONTRAST, - (sal_Bool)(nQuality==3))); - } - } - - if (rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN) == SFX_ITEM_AVAILABLE) - { - rSet.Put (SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN, sal_True)); - } -} - - - - -void SlideSorterController::GetStatusBarState (SfxItemSet& rSet) -{ - mpSlotManager->GetStatusBarState (rSet); -} - - - - -void SlideSorterController::ExecCtrl (SfxRequest& rRequest) -{ - mpSlotManager->ExecCtrl (rRequest); -} - - - - -void SlideSorterController::GetAttrState (SfxItemSet& rSet) -{ - mpSlotManager->GetAttrState (rSet); -} - - - - -void SlideSorterController::ExecStatusBar (SfxRequest& ) -{ -} - - - - -void SlideSorterController::UpdateAllPages (void) -{ - // Do a redraw. - mrSlideSorter.GetContentWindow()->Invalidate(); -} - - - - -Rectangle SlideSorterController::Resize (const Rectangle& rAvailableSpace) -{ - Rectangle aContentArea (rAvailableSpace); - - if (maTotalWindowArea != rAvailableSpace) - { - maTotalWindowArea = rAvailableSpace; - aContentArea = Rearrange(true); - } - - return aContentArea; -} - - - - -Rectangle SlideSorterController::Rearrange (bool bForce) -{ - Rectangle aNewContentArea (maTotalWindowArea); - - 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, - 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()); - bSizeHasChanged = (aNewContentArea != aCurrentContentArea); - } - if (bForce || bSizeHasChanged) - { - // The browser window gets the remaining space. - pWindow->SetPosSizePixel (aNewContentArea.TopLeft(), aNewContentArea.GetSize()); - mrView.Resize(); - } - - // 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; -} - - - - -FunctionReference SlideSorterController::CreateSelectionFunction (SfxRequest& rRequest) -{ - FunctionReference xFunc( SelectionFunction::Create(mrSlideSorter, rRequest) ); - return xFunc; -} - - - - -::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 - // descriptors in the other mode and for restoring the current - // selection when switching back to the current mode. - if (mrModel.GetEditMode() == EM_PAGE) - { - maSelectionBeforeSwitch.clear(); - - // Search for the first selected page and determine the master page - // used by its page object. It will be selected after the switch. - // In the same loop the current selection is stored. - PageEnumeration aSelectedPages ( - PageEnumerationProvider::CreateSelectedPagesEnumeration(mrModel)); - while (aSelectedPages.HasMoreElements()) - { - SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement()); - SdPage* pPage = pDescriptor->GetPage(); - // Remember the master page of the first selected descriptor. - if (pPage!=NULL && mpEditModeChangeMasterPage==NULL) - mpEditModeChangeMasterPage = &static_cast<SdPage&>( - pPage->TRG_GetMasterPage()); - - maSelectionBeforeSwitch.push_back(pPage); - } - - // Remember the current page. - if (mrSlideSorter.GetViewShell() != NULL) - mnCurrentPageBeforeSwitch = (mrSlideSorter.GetViewShell()->GetViewShellBase() - .GetMainViewShell()->GetActualPage()->GetPageNum()-1)/2; - } -} - - - - -bool SlideSorterController::ChangeEditMode (EditMode eEditMode) -{ - bool bResult (false); - if (mrModel.GetEditMode() != eEditMode) - { - ModelChangeLock aLock (*this); - PreModelChange(); - // Do the actual edit mode switching. - bResult = mrModel.SetEditMode(eEditMode); - if (bResult) - HandleModelChange(); - } - return bResult; -} - - - - -void SlideSorterController::FinishEditModeChange (void) -{ - if (mrModel.GetEditMode() == EM_MASTERPAGE) - { - // Search for the master page that was determined in - // PrepareEditModeChange() and make it the current page. - PageEnumeration aAllPages (PageEnumerationProvider::CreateAllPagesEnumeration(mrModel)); - while (aAllPages.HasMoreElements()) - { - SharedPageDescriptor pDescriptor (aAllPages.GetNextElement()); - if (pDescriptor->GetPage() == mpEditModeChangeMasterPage) - { - GetCurrentSlideManager()->SwitchCurrentSlide(pDescriptor); - break; - } - } - } - else - { - SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(mnCurrentPageBeforeSwitch)); - GetCurrentSlideManager()->SwitchCurrentSlide(pDescriptor); - - // Restore the selection. - ::std::vector<SdPage*>::iterator iPage; - for (iPage=maSelectionBeforeSwitch.begin(); - iPage!=maSelectionBeforeSwitch.end(); - ++iPage) - { - mpPageSelector->SelectPage(*iPage); - } - maSelectionBeforeSwitch.clear( ); - } - mpEditModeChangeMasterPage = NULL; -} - - - - -void SlideSorterController::PageNameHasChanged (int nPageIndex, const String& rsOldName) -{ - // Request a repaint for the page object whose name has changed. - model::SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nPageIndex)); - if (pDescriptor.get() != NULL) - mrView.RequestRepaint(pDescriptor); - - // Get a pointer to the corresponding accessible object and notify - // that of the name change. - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - if ( ! pWindow) - return; - - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > - xAccessible (pWindow->GetAccessible(sal_False)); - if ( ! xAccessible.is()) - return; - - // Now comes a small hack. We assume that the accessible object is - // an instantiation of AccessibleSlideSorterView and cast it to that - // class. The cleaner alternative to this cast would be a new member - // in which we would store the last AccessibleSlideSorterView object - // created by SlideSorterViewShell::CreateAccessibleDocumentView(). - // But then there is no guaranty that the accessible object obtained - // from the window really is that instance last created by - // CreateAccessibleDocumentView(). - // However, the dynamic cast together with the check of the result - // being NULL should be safe enough. - ::accessibility::AccessibleSlideSorterView* pAccessibleView - = dynamic_cast< ::accessibility::AccessibleSlideSorterView*>(xAccessible.get()); - if (pAccessibleView == NULL) - return; - - ::accessibility::AccessibleSlideSorterObject* pChild - = pAccessibleView->GetAccessibleChildImplementation(nPageIndex); - if (pChild == NULL || pChild->GetPage() == NULL) - return; - - ::rtl::OUString sOldName (rsOldName); - ::rtl::OUString sNewName (pChild->GetPage()->GetName()); - pChild->FireAccessibleEvent( - ::com::sun::star::accessibility::AccessibleEventId::NAME_CHANGED, - makeAny(sOldName), - makeAny(sNewName)); -} - - - - -bool SlideSorterController::IsContextMenuOpen (void) const -{ - return mbIsContextMenuOpen; -} - - - - -void SlideSorterController::SetDocumentSlides (const Reference<container::XIndexAccess>& rxSlides) -{ - if (mrModel.GetDocumentSlides() != rxSlides) - { - ModelChangeLock aLock (*this); - PreModelChange(); - - mrModel.SetDocumentSlides(rxSlides); - mrView.Layout(); - - // Select just the current slide. - PageSelector::BroadcastLock aBroadcastLock (*mpPageSelector); - mpPageSelector->DeselectAllPages(); - mpPageSelector->SelectPage(mpCurrentSlideManager->GetCurrentSlide()); - } -} - - - - -::boost::shared_ptr<Animator> SlideSorterController::GetAnimator (void) const -{ - return mpAnimator; -} - - - - -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 ( - SlideSorterController& rController) - : mpController(&rController) -{ - mpController->LockModelChange(); -} - - - - -SlideSorterController::ModelChangeLock::~ModelChangeLock (void) -{ - Release(); -} - - - - -void SlideSorterController::ModelChangeLock::Release (void) -{ - if (mpController != NULL) - { - mpController->UnlockModelChange(); - mpController = NULL; - } -} - -} } } // end of namespace ::sd::slidesorter - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsAnimationFunction.cxx b/sd/source/ui/slidesorter/controller/SlsAnimationFunction.cxx deleted file mode 100644 index ae84a40c0..000000000 --- a/sd/source/ui/slidesorter/controller/SlsAnimationFunction.cxx +++ /dev/null @@ -1,294 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" -#include "controller/SlsAnimationFunction.hxx" -#include "model/SlsPageDescriptor.hxx" -#include "view/SlideSorterView.hxx" - - -#include <osl/diagnose.hxx> -#include <rtl/math.hxx> - -namespace sd { namespace slidesorter { namespace controller { - - -double AnimationFunction::Linear (const double nTime) -{ - OSL_ASSERT(nTime>=0.0 && nTime<=1.0); - return nTime; -} - - - - -double AnimationFunction::FastInSlowOut_Sine (const double nTime) -{ - OSL_ASSERT(nTime>=0.0 && nTime<=1.0); - - const double nResult (sin(nTime * M_PI/2)); - - OSL_ASSERT(nResult>=0.0 && nResult<=1.0); - return nResult; -} - - - - -double AnimationFunction::FastInSlowOut_Root (const double nTime) -{ - OSL_ASSERT(nTime>=0.0 && nTime<=1.0); - - const double nResult (sqrt(nTime)); - - OSL_ASSERT(nResult>=0.0 && nResult<=1.0); - return nResult; -} - - - - -double AnimationFunction::SlowInSlowOut_0to0_Sine (const double nTime) -{ - OSL_ASSERT(nTime>=0.0 && nTime<=1.0); - - const double nResult (sin(nTime * M_PI)); - - OSL_ASSERT(nResult>=0.0 && nResult<=1.0); - return nResult; -} - - - - -double AnimationFunction::Vibrate_Sine (const double nTime) -{ - return sin(nTime*M_PI*8); -} - - - - -Point AnimationFunction::ScalePoint (const Point& rPoint, const double nTime) -{ - return Point( - sal_Int32(::rtl::math::round(rPoint.X() * nTime)), - sal_Int32(::rtl::math::round(rPoint.Y() * nTime))); -} - - - - -double AnimationFunction::Blend ( - const double nStartValue, - const double nEndValue, - const double nTime) -{ - return nStartValue*(1-nTime) + nEndValue*nTime; -} - - - - -void AnimationFunction::ApplyVisualStateChange ( - const model::SharedPageDescriptor& rpDescriptor, - view::SlideSorterView& rView, - const double nTime) -{ - if (rpDescriptor) - { - rpDescriptor->GetVisualState().SetVisualStateBlend(nTime); - rView.RequestRepaint(rpDescriptor); - } -} - - - - -void AnimationFunction::ApplyLocationOffsetChange ( - const model::SharedPageDescriptor& rpDescriptor, - view::SlideSorterView& rView, - const Point aLocationOffset) -{ - if (rpDescriptor) - { - const Rectangle aOldBoundingBox(rpDescriptor->GetBoundingBox()); - rpDescriptor->GetVisualState().SetLocationOffset(aLocationOffset); - rView.RequestRepaint(aOldBoundingBox); - rView.RequestRepaint(rpDescriptor); - } -} - - - - -void AnimationFunction::ApplyButtonAlphaChange( - const model::SharedPageDescriptor& rpDescriptor, - view::SlideSorterView& rView, - const double nButtonAlpha, - const double nButtonBarAlpha) -{ - if (rpDescriptor) - { - rpDescriptor->GetVisualState().SetButtonAlpha(nButtonAlpha); - rpDescriptor->GetVisualState().SetButtonBarAlpha(nButtonBarAlpha); - rView.RequestRepaint(rpDescriptor); - } -} - - - - -//===== AnimationBezierFunction =============================================== - -AnimationBezierFunction::AnimationBezierFunction ( - const double nX1, - const double nY1, - const double nX2, - const double nY2) - : mnX1(nX1), - mnY1(nY1), - mnX2(nX2), - mnY2(nY2) -{ -} - - - - -AnimationBezierFunction::AnimationBezierFunction ( - const double nX1, - const double nY1) - : mnX1(nX1), - mnY1(nY1), - mnX2(1-nY1), - mnY2(1-nX1) -{ -} - - - - -::basegfx::B2DPoint AnimationBezierFunction::operator() (const double nT) -{ - return ::basegfx::B2DPoint( - EvaluateComponent(nT, mnX1, mnX2), - EvaluateComponent(nT, mnY1, mnY2)); -} - - - - -double AnimationBezierFunction::EvaluateComponent ( - const double nT, - const double nV1, - const double nV2) -{ - const double nS (1-nT); - - // While the control point values 1 and 2 are explicitly given the start - // and end values are implicitly given. - const double nV0 (0); - const double nV3 (1); - - const double nV01 (nS*nV0 + nT*nV1); - const double nV12 (nS*nV1 + nT*nV2); - const double nV23 (nS*nV2 + nT*nV3); - - const double nV012 (nS*nV01 + nT*nV12); - const double nV123 (nS*nV12 + nT*nV23); - - const double nV0123 (nS*nV012 + nT*nV123); - - return nV0123; -} - - - - -//===== AnimationParametricFunction =========================================== - -AnimationParametricFunction::AnimationParametricFunction (const ParametricFunction& rFunction) - : maY() -{ - const sal_Int32 nSampleCount (64); - - // Sample the given parametric function. - ::std::vector<basegfx::B2DPoint> aPoints; - aPoints.reserve(nSampleCount); - for (sal_Int32 nIndex=0; nIndex<nSampleCount; ++nIndex) - { - const double nT (nIndex/double(nSampleCount-1)); - aPoints.push_back(basegfx::B2DPoint(rFunction(nT))); - } - - // Interpolate at evenly spaced points. - maY.clear(); - maY.reserve(nSampleCount); - double nX0 (aPoints[0].getX()); - double nY0 (aPoints[0].getY()); - double nX1 (aPoints[1].getX()); - double nY1 (aPoints[1].getY()); - sal_Int32 nIndex (1); - for (sal_Int32 nIndex2=0; nIndex2<nSampleCount; ++nIndex2) - { - const double nX (nIndex2 / double(nSampleCount-1)); - while (nX > nX1 && nIndex<nSampleCount) - { - nX0 = nX1; - nY0 = nY1; - nX1 = aPoints[nIndex].getX(); - nY1 = aPoints[nIndex].getY(); - ++nIndex; - } - const double nU ((nX-nX1) / (nX0 - nX1)); - const double nY (nY0*nU + nY1*(1-nU)); - maY.push_back(nY); - } -} - - - - -double AnimationParametricFunction::operator() (const double nX) -{ - const sal_Int32 nIndex0 (static_cast<sal_Int32>(nX * maY.size())); - const double nX0 (nIndex0 / double(maY.size()-1)); - const sal_uInt32 nIndex1 (nIndex0 + 1); - const double nX1 (nIndex1 / double(maY.size()-1)); - - if (nIndex0<=0) - return maY[0]; - else if (sal_uInt32(nIndex0)>=maY.size() || nIndex1>=maY.size()) - return maY[maY.size()-1]; - - const double nU ((nX-nX1) / (nX0 - nX1)); - return maY[nIndex0]*nU + maY[nIndex1]*(1-nU); -} - - -} } } // end of namespace ::sd::slidesorter::controller diff --git a/sd/source/ui/slidesorter/controller/SlsAnimator.cxx b/sd/source/ui/slidesorter/controller/SlsAnimator.cxx deleted file mode 100644 index 74f9fc2c2..000000000 --- a/sd/source/ui/slidesorter/controller/SlsAnimator.cxx +++ /dev/null @@ -1,398 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" -#include "controller/SlsAnimator.hxx" -#include "view/SlideSorterView.hxx" -#include "View.hxx" -#include <boost/bind.hpp> - -namespace sd { namespace slidesorter { namespace controller { - -namespace { - static const sal_Int32 gnResolution = 25; -} -/** Handle one animation function by using a timer for frequent calls to - the animations operator(). -*/ -class Animator::Animation -{ -public: - Animation ( - const Animator::AnimationFunctor& rAnimation, - const double nStartOffset, - const double nDuration, - const double nGlobalTime, - const Animator::AnimationId nAnimationId, - const Animator::FinishFunctor& rFinishFunctor); - ~Animation (void); - /** Run next animation step. If animation has reached its end it is - expired. - */ - bool Run (const double nGlobalTime); - - /** Typically called when an animation has finished, but also from - Animator::Disposed(). The finish functor is called and the - animation is marked as expired to prevent another run. - */ - void Expire (void); - bool IsExpired (void); - - Animator::AnimationFunctor maAnimation; - Animator::FinishFunctor maFinishFunctor; - const Animator::AnimationId mnAnimationId; - const double mnDuration; - const double mnEnd; - const double mnGlobalTimeAtStart; - bool mbIsExpired; -}; - - - - -Animator::Animator (SlideSorter& rSlideSorter) - : mrSlideSorter(rSlideSorter), - maTimer(), - mbIsDisposed(false), - maAnimations(), - maElapsedTime(), - mpDrawLock(), - mnNextAnimationId(0) -{ - maTimer.SetTimeout(gnResolution); - maTimer.SetTimeoutHdl(LINK(this,Animator,TimeoutHandler)); -} - - - - -Animator::~Animator (void) -{ - if ( ! mbIsDisposed) - { - OSL_ASSERT(mbIsDisposed); - Dispose(); - } -} - - - - -void Animator::Dispose (void) -{ - mbIsDisposed = true; - - AnimationList aCopy (maAnimations); - AnimationList::const_iterator iAnimation; - for (iAnimation=aCopy.begin(); iAnimation!=aCopy.end(); ++iAnimation) - (*iAnimation)->Expire(); - - maTimer.Stop(); - if (mpDrawLock) - { - mpDrawLock->Dispose(); - mpDrawLock.reset(); - } -} - - - - -Animator::AnimationId Animator::AddAnimation ( - const AnimationFunctor& rAnimation, - const sal_Int32 nStartOffset, - const sal_Int32 nDuration, - const FinishFunctor& rFinishFunctor) -{ - // When the animator is already disposed then ignore this call - // silently (well, we show an assertion, but do not throw an exception.) - OSL_ASSERT( ! mbIsDisposed); - if (mbIsDisposed) - return -1; - - boost::shared_ptr<Animation> pAnimation ( - new Animation( - rAnimation, - nStartOffset / 1000.0, - nDuration / 1000.0, - maElapsedTime.getElapsedTime(), - ++mnNextAnimationId, - rFinishFunctor)); - maAnimations.push_back(pAnimation); - - RequestNextFrame(); - - return pAnimation->mnAnimationId; -} - - - - -Animator::AnimationId Animator::AddInfiniteAnimation ( - const AnimationFunctor& rAnimation, - const double nDelta) -{ - (void)nDelta; - - // When the animator is already disposed then ignore this call - // silently (well, we show an assertion, but do not throw an exception.) - OSL_ASSERT( ! mbIsDisposed); - if (mbIsDisposed) - return -1; - - boost::shared_ptr<Animation> pAnimation ( - new Animation( - rAnimation, - 0, - -1, - maElapsedTime.getElapsedTime(), - mnNextAnimationId++, - FinishFunctor())); - maAnimations.push_back(pAnimation); - - RequestNextFrame(); - - return pAnimation->mnAnimationId; -} - - - - -void Animator::RemoveAnimation (const Animator::AnimationId nId) -{ - OSL_ASSERT( ! mbIsDisposed); - - const AnimationList::iterator iAnimation (::std::find_if( - maAnimations.begin(), - maAnimations.end(), - ::boost::bind( - ::std::equal_to<Animator::AnimationId>(), - nId, - ::boost::bind(&Animation::mnAnimationId, _1)))); - if (iAnimation != maAnimations.end()) - { - OSL_ASSERT((*iAnimation)->mnAnimationId == nId); - (*iAnimation)->Expire(); - maAnimations.erase(iAnimation); - } - - if (maAnimations.empty()) - { - // Reset the animation id when we can. - mnNextAnimationId = 0; - - // No more animations => we do not have to suppress painting - // anymore. - mpDrawLock.reset(); - } -} - - - - -void Animator::RemoveAllAnimations (void) -{ - ::std::for_each( - maAnimations.begin(), - maAnimations.end(), - ::boost::bind( - &Animation::Expire, - _1)); - maAnimations.clear(); - mnNextAnimationId = 0; - - // No more animations => we do not have to suppress painting - // anymore. - mpDrawLock.reset(); -} - - - - -bool Animator::ProcessAnimations (const double nTime) -{ - bool bExpired (false); - - OSL_ASSERT( ! mbIsDisposed); - if (mbIsDisposed) - return bExpired; - - - AnimationList aCopy (maAnimations); - AnimationList::const_iterator iAnimation; - for (iAnimation=aCopy.begin(); iAnimation!=aCopy.end(); ++iAnimation) - { - bExpired |= (*iAnimation)->Run(nTime); - } - - return bExpired; -} - - - - -void Animator::CleanUpAnimationList (void) -{ - OSL_ASSERT( ! mbIsDisposed); - if (mbIsDisposed) - return; - - AnimationList aActiveAnimations; - - AnimationList::const_iterator iAnimation; - for (iAnimation=maAnimations.begin(); iAnimation!=maAnimations.end(); ++iAnimation) - { - if ( ! (*iAnimation)->IsExpired()) - aActiveAnimations.push_back(*iAnimation); - } - - maAnimations.swap(aActiveAnimations); -} - - - - -void Animator::RequestNextFrame (const double nFrameStart) -{ - (void)nFrameStart; - if ( ! maTimer.IsActive()) - { - // Prevent redraws except for the ones in TimeoutHandler. While the - // Animator is active it will schedule repaints regularly. Repaints - // in between would only lead to visual artifacts. - mpDrawLock.reset(new view::SlideSorterView::DrawLock(mrSlideSorter)); - maTimer.Start(); - } -} - - - - -IMPL_LINK(Animator, TimeoutHandler, Timer*, EMPTYARG) -{ - if (mbIsDisposed) - return 0; - - if (ProcessAnimations(maElapsedTime.getElapsedTime())) - CleanUpAnimationList(); - - // Unlock the draw lock. This should lead to a repaint. - mpDrawLock.reset(); - - if (maAnimations.size() > 0) - RequestNextFrame(); - - return 0; -} - - - - -//===== Animator::Animation =================================================== - -Animator::Animation::Animation ( - const Animator::AnimationFunctor& rAnimation, - const double nStartOffset, - const double nDuration, - const double nGlobalTime, - const Animator::AnimationId nId, - const Animator::FinishFunctor& rFinishFunctor) - : maAnimation(rAnimation), - maFinishFunctor(rFinishFunctor), - mnAnimationId(nId), - mnDuration(nDuration), - mnEnd(nGlobalTime + nDuration + nStartOffset), - mnGlobalTimeAtStart(nGlobalTime + nStartOffset), - mbIsExpired(false) -{ - Run(nGlobalTime); -} - - - - -Animator::Animation::~Animation (void) -{ -} - - - - -bool Animator::Animation::Run (const double nGlobalTime) -{ - if ( ! mbIsExpired) - { - if (mnDuration > 0) - { - if (nGlobalTime >= mnEnd) - { - maAnimation(1.0); - Expire(); - } - else if (nGlobalTime >= mnGlobalTimeAtStart) - { - maAnimation((nGlobalTime - mnGlobalTimeAtStart) / mnDuration); - } - } - else if (mnDuration < 0) - { - // Animations without end have to be expired by their owner. - maAnimation(nGlobalTime); - } - } - - return mbIsExpired; -} - - - - -void Animator::Animation::Expire (void) -{ - if ( ! mbIsExpired) - { - mbIsExpired = true; - if (maFinishFunctor) - maFinishFunctor(); - } -} - - - - -bool Animator::Animation::IsExpired (void) -{ - return mbIsExpired; -} - - - - -} } } // end of namespace ::sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx deleted file mode 100644 index 10e9a8fdd..000000000 --- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx +++ /dev/null @@ -1,892 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "controller/SlsClipboard.hxx" - -#include "SlideSorterViewShell.hxx" -#include "SlideSorter.hxx" -#include "model/SlideSorterModel.hxx" -#include "model/SlsPageDescriptor.hxx" -#include "model/SlsPageEnumerationProvider.hxx" -#include "view/SlideSorterView.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 "controller/SlsTransferable.hxx" -#include "controller/SlsSelectionObserver.hxx" -#include "cache/SlsPageCache.hxx" - -#include "ViewShellBase.hxx" -#include "DrawViewShell.hxx" -#include "Window.hxx" -#include "fupoor.hxx" -#include "fuzoom.hxx" -#include "fucushow.hxx" -#include "fusldlg.hxx" -#include "fuexpand.hxx" -#include "fusumry.hxx" -#include "app.hrc" -#include "glob.hrc" -#include "strings.hrc" -#include "sdresid.hxx" -#include "sdxfer.hxx" -#include "sdmod.hxx" -#include "sddll.hxx" -#include "ins_paste.hxx" -#include "drawdoc.hxx" -#include "DrawDocShell.hxx" -#include "sdpage.hxx" - -#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> -#include <sfx2/request.hxx> -#include <sfx2/viewfrm.hxx> -#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> -#include <osl/mutex.hxx> -#include <vcl/svapp.hxx> - -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()), - mrSlideSorter(rSlideSorter), - mrController(mrSlideSorter.GetController()), - maPagesToRemove(), - maPagesToSelect(), - mbUpdateSelectionPending(false), - mpUndoContext(), - mpSelectionObserverContext(), - mnDragFinishedUserEventId(0) -{ -} - - - - -Clipboard::~Clipboard (void) -{ - if (mnDragFinishedUserEventId != 0) - Application::RemoveUserEvent(mnDragFinishedUserEventId); -} - - - - -/** With the current implementation the forwarded calls to the current - function will come back eventually to call the local Do(Cut|Copy|Paste) - methods. A shortcut is possible but would be an unclean hack. -*/ -void Clipboard::HandleSlotCall (SfxRequest& rRequest) -{ - ViewShell* pViewShell = mrSlideSorter.GetViewShell(); - FunctionReference xFunc; - if (pViewShell != NULL) - xFunc = pViewShell->GetCurrentFunction(); - switch (rRequest.GetSlot()) - { - case SID_CUT: - if (mrSlideSorter.GetModel().GetEditMode() != EM_MASTERPAGE) - { - if(xFunc.is()) - xFunc->DoCut(); - else - DoCut(); - } - rRequest.Done(); - break; - - case SID_COPY: - if (mrSlideSorter.GetModel().GetEditMode() != EM_MASTERPAGE) - { - if(xFunc.is()) - xFunc->DoCopy(); - else - DoCopy(); - } - rRequest.Done(); - break; - - case SID_PASTE: - // Prevent redraws while inserting pages from the clipboard - // because the intermediate inconsistent state might lead to - // a crash. - if (mrSlideSorter.GetModel().GetEditMode() != EM_MASTERPAGE) - { - view::SlideSorterView::DrawLock aLock (mrSlideSorter); - SelectionObserver::Context aContext (mrSlideSorter); - if(xFunc.is()) - xFunc->DoPaste(); - else - DoPaste(); - } - rRequest.Done(); - break; - - case SID_DELETE: - DoDelete(); - rRequest.Done(); - break; - } -} - - - - -void Clipboard::DoCut (::Window* pWindow) -{ - if (mrSlideSorter.GetModel().GetPageCount() > 1) - { - DoCopy(pWindow); - DoDelete(pWindow); - } -} - - - - -void Clipboard::DoDelete (::Window* ) -{ - if (mrSlideSorter.GetModel().GetPageCount() > 1) - { - mrController.GetSelectionManager()->DeleteSelectedPages(); - } -} - - - - -void Clipboard::DoCopy (::Window* pWindow ) -{ - CreateSlideTransferable( pWindow, sal_False ); -} - - - - -void Clipboard::DoPaste (::Window* pWindow) -{ - SdTransferable* pClipTransferable = SD_MOD()->pTransferClip; - - if (pClipTransferable!=NULL && pClipTransferable->IsPageTransferable()) - { - sal_Int32 nInsertPosition = GetInsertionPosition(pWindow); - - if (nInsertPosition >= 0) - { - // Paste the pages from the clipboard. - sal_Int32 nInsertPageCount = PasteTransferable(nInsertPosition); - // Select the pasted pages and make the first of them the - // current page. - mrSlideSorter.GetContentWindow()->GrabFocus(); - SelectPageRange(nInsertPosition, nInsertPageCount); - } - } -} - - - - -sal_Int32 Clipboard::GetInsertionPosition (::Window* pWindow) -{ - sal_Int32 nInsertPosition = -1; - - // Determine the insertion position: - // a) When the insertion indicator is visible, then at that position. - // b) When the focus indicator is visible, then before or after the - // focused page, depending on user input to a dialog. - // c) When there is a selection but no focus, then after the - // selection. - // d) After the last page when there is no selection and no focus. - - ::boost::shared_ptr<controller::InsertionIndicatorHandler> pInsertionIndicatorHandler ( - mrController.GetInsertionIndicatorHandler()); - if (pInsertionIndicatorHandler->IsActive()) - { - // 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) - { - nInsertPosition = mrController.GetFocusManager().GetFocusedPageIndex(); - if ( ! aDialog.IsInsertBefore()) - nInsertPosition ++; - } - } - - return nInsertPosition; -} - - - - -sal_Int32 Clipboard::PasteTransferable (sal_Int32 nInsertPosition) -{ - SdTransferable* pClipTransferable = SD_MOD()->pTransferClip; - 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 = (sal_uInt16) rBookmarkList.Count(); - rModel.GetDocument()->InsertBookmarkAsPage( - const_cast<List*>(&rBookmarkList), - NULL, - sal_False, - sal_False, - nInsertIndex, - sal_False, - pClipTransferable->GetPageDocShell(), - sal_True, - bMergeMasterPages, - sal_False); - } - else - { - SfxObjectShell* pShell = pClipTransferable->GetDocShell(); - DrawDocShell* pDataDocSh = (DrawDocShell*)pShell; - SdDrawDocument* pDataDoc = pDataDocSh->GetDoc(); - - if (pDataDoc!=NULL - && pDataDoc->GetSdPageCount(PK_STANDARD)) - { - const SolarMutexGuard aGuard; - - bMergeMasterPages = (pDataDoc != rModel.GetDocument()); - nInsertPageCount = pDataDoc->GetSdPageCount( PK_STANDARD ); - rModel.GetDocument()->InsertBookmarkAsPage( - NULL, - NULL, - sal_False, - sal_False, - nInsertIndex, - sal_False, - pDataDocSh, - sal_True, - bMergeMasterPages, - sal_False); - } - } - mrController.HandleModelChange(); - return nInsertPageCount; -} - - - - -void Clipboard::SelectPageRange (sal_Int32 nFirstIndex, sal_Int32 nPageCount) -{ - // Select the newly inserted pages. That are the nInsertPageCount pages - // after the nInsertIndex position. - PageSelector& rSelector (mrController.GetPageSelector()); - rSelector.DeselectAllPages(); - for (sal_uInt16 i=0; i<nPageCount; i++) - { - model::SharedPageDescriptor pDescriptor ( - mrSlideSorter.GetModel().GetPageDescriptor(nFirstIndex + i)); - if (pDescriptor.get() != NULL) - { - rSelector.SelectPage(pDescriptor); - // The first page of the new selection is made the current page. - if (i == 0) - { - mrController.GetCurrentSlideManager()->SwitchCurrentSlide(pDescriptor); - } - } - } -} - - - - -void Clipboard::CreateSlideTransferable ( - ::Window* pWindow, - bool bDrag) -{ - List aBookmarkList; - - // Insert all selected pages into a bookmark list and remember them in - // maPagesToRemove for possible later removal. - model::PageEnumeration aSelectedPages - (model::PageEnumerationProvider::CreateSelectedPagesEnumeration( - mrSlideSorter.GetModel())); - while (aSelectedPages.HasMoreElements()) - { - model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement()); - aBookmarkList.Insert ( - new String(pDescriptor->GetPage()->GetName()), - LIST_APPEND); - 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(); - SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument(); - SdTransferable* pTransferable = new Transferable ( - pDocument, - NULL, - sal_False, - dynamic_cast<SlideSorterViewShell*>(mrSlideSorter.GetViewShell()), - aRepresentatives); - - if (bDrag) - SD_MOD()->pTransferDrag = pTransferable; - else - SD_MOD()->pTransferClip = pTransferable; - - pDocument->CreatingDataObj (pTransferable); - pTransferable->SetWorkDocument( dynamic_cast<SdDrawDocument*>(pDocument->AllocModel()) ); - pDocument->CreatingDataObj (NULL); - TransferableObjectDescriptor aObjDesc; - pTransferable->GetWorkDocument()->GetDocSh() - ->FillTransferableObjectDescriptor (aObjDesc); - - if (pDocument->GetDocSh() != NULL) - aObjDesc.maDisplayName = pDocument->GetDocSh() - ->GetMedium()->GetURLObject().GetURLNoPass(); - - ::Window* pActionWindow = pWindow; - if (pActionWindow == NULL) - { - ViewShell* pViewShell = mrSlideSorter.GetViewShell(); - if (pViewShell != NULL) - pActionWindow = pViewShell->GetActiveWindow(); - } - - pTransferable->SetStartPos (pActionWindow->PixelToLogic( - pActionWindow->GetPointerPosPixel())); - pTransferable->SetObjectDescriptor (aObjDesc); - pTransferable->SetPageBookmarks (aBookmarkList, !bDrag); - - for (void* p=aBookmarkList.First(); p!=NULL; p=aBookmarkList.Next()) - delete static_cast<String*>(p); - - if (bDrag) - { - pTransferable->SetView (&mrSlideSorter.GetView()); - sal_Int8 nDragSourceActions (DND_ACTION_COPY); - // The move action is available only when not all pages would be - // moved. Otherwise an empty document would remain. Crash. - sal_Int32 nRemainingPages = mrSlideSorter.GetModel().GetPageCount() - aBookmarkList.Count(); - if (nRemainingPages > 0) - nDragSourceActions |= DND_ACTION_MOVE; - pTransferable->StartDrag (pActionWindow, nDragSourceActions); - } - else - pTransferable->CopyToClipboard (pActionWindow); - } -} - - - - -void Clipboard::StartDrag ( - const Point& rPosition, - ::Window* pWindow) -{ - maPagesToRemove.clear(); - maPagesToSelect.clear(); - mbUpdateSelectionPending = false; - CreateSlideTransferable(pWindow, sal_True); - - mrController.GetInsertionIndicatorHandler()->UpdatePosition( - rPosition, - InsertionIndicatorHandler::UnknownMode); -} - - - - -void Clipboard::DragFinished (sal_Int8 nDropAction) -{ - 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()) - { - // Remove the pages that have been moved to another place (possibly - // in the same document.) - rSelector.DeselectAllPages(); - PageList::iterator aDraggedPage; - for (aDraggedPage=maPagesToRemove.begin(); - aDraggedPage!=maPagesToRemove.end(); - ++aDraggedPage) - { - rSelector.SelectPage(*aDraggedPage); - } - mrController.GetSelectionManager()->DeleteSelectedPages(); - } - mpUndoContext.reset(); - mpSelectionObserverContext.reset(); - - return 1; -} - - - - -void Clipboard::SelectPages (void) -{ - PageSelector& rSelector (mrController.GetPageSelector()); - - // Select the dropped pages. - PageList::iterator iPage; - rSelector.DeselectAllPages(); - for (iPage=maPagesToSelect.begin(); iPage!=maPagesToSelect.end(); ++iPage) - { - rSelector.SelectPage(*iPage); - } -} - - - - -sal_Int8 Clipboard::AcceptDrop ( - const AcceptDropEvent& rEvent, - DropTargetHelper& rTargetHelper, - ::sd::Window* pTargetWindow, - sal_uInt16 nPage, - sal_uInt16 nLayer) -{ - sal_Int8 nAction (DND_ACTION_NONE); - - const Clipboard::DropType eDropType (IsDropAccepted()); - - switch (eDropType) - { - case DT_PAGE: - { - // Accept a drop. - 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 - // target models are not the same. - const SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; - if (pDragTransferable != NULL - && pDragTransferable->IsPageTransferable() - && ((rEvent.maDragEvent.DropAction - & ::com::sun::star::datatransfer::dnd::DNDConstants::ACTION_DEFAULT) != 0) - && (mrSlideSorter.GetModel().GetDocument()->GetDocSh() - != pDragTransferable->GetPageDocShell())) - { - nAction = DND_ACTION_COPY; - } - else if (mrController.GetInsertionIndicatorHandler()->IsInsertionTrivial(nAction)) - { - nAction = DND_ACTION_NONE; - } - - // Show the insertion marker and the substitution for a drop. - 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); - } - break; - - case DT_SHAPE: - nAction = ExecuteOrAcceptShapeDrop( - DC_ACCEPT, - rEvent.maPosPixel, - &rEvent, - rTargetHelper, - pTargetWindow, - nPage, - nLayer); - break; - - default: - nAction = DND_ACTION_NONE; - break; - } - - return nAction; -} - - - - -sal_Int8 Clipboard::ExecuteDrop ( - const ExecuteDropEvent& rEvent, - DropTargetHelper& rTargetHelper, - ::sd::Window* pTargetWindow, - sal_uInt16 nPage, - sal_uInt16 nLayer) -{ - sal_Int8 nResult = DND_ACTION_NONE; - mpUndoContext.reset(); - - switch (IsDropAccepted()) - { - case DT_PAGE: - { - const SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; - const Point aEventModelPosition ( - pTargetWindow->PixelToLogic (rEvent.maPosPixel)); - 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. - 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); - - // 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; - - case DT_SHAPE: - nResult = ExecuteOrAcceptShapeDrop( - DC_EXECUTE, - rEvent.maPosPixel, - &rEvent, - rTargetHelper, - pTargetWindow, - nPage, - nLayer); - break; - default: - break; - } - - return nResult; -} - - - - -void Clipboard::Abort (void) -{ - 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. - const sal_Int32 nInsertionIndex ( - mrController.GetInsertionIndicatorHandler()->GetInsertionPageIndex()); - - // Convert to insertion index to that of an SdModel. - if (nInsertionIndex >= 0) - return mrSlideSorter.GetModel().GetCoreIndex(nInsertionIndex); - else - return 0; -} - - - - -sal_uInt16 Clipboard::InsertSlides ( - const SdTransferable& rTransferable, - sal_uInt16 nInsertPosition) -{ - sal_uInt16 nInsertedPageCount = ViewClipboard::InsertSlides ( - rTransferable, - nInsertPosition); - - // Remember the inserted pages so that they can be selected when the - // operation is finished. - 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); - - return nInsertedPageCount; -} - - - - -Clipboard::DropType Clipboard::IsDropAccepted (void) const -{ - DropType eResult (DT_NONE); - - const SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; - if (pDragTransferable != NULL) - { - if (pDragTransferable->IsPageTransferable()) - { - if (mrSlideSorter.GetModel().GetEditMode() != EM_MASTERPAGE) - eResult = DT_PAGE; - } - else - { - eResult = DT_SHAPE; - } - } - - return eResult; -} - - - - -sal_Int8 Clipboard::ExecuteOrAcceptShapeDrop ( - DropCommand eCommand, - const Point& rPosition, - const void* pDropEvent, - DropTargetHelper& rTargetHelper, - ::sd::Window* pTargetWindow, - sal_uInt16 nPage, - sal_uInt16 nLayer) -{ - sal_Int8 nResult = 0; - - // The dropping of a shape is accepted or executed only when there is - // DrawViewShell available to which we can forward this call. This has - // technical reasons: The actual code to accept or execute a shape drop - // is implemented in the ViewShell class and uses the page view of the - // main edit view. This is not possible without a DrawViewShell. - ::boost::shared_ptr<DrawViewShell> pDrawViewShell; - if (mrSlideSorter.GetViewShell() != NULL) - pDrawViewShell = ::boost::dynamic_pointer_cast<DrawViewShell>( - mrSlideSorter.GetViewShell()->GetViewShellBase().GetMainViewShell()); - if (pDrawViewShell.get() != NULL - && (pDrawViewShell->GetShellType() == ViewShell::ST_IMPRESS - || pDrawViewShell->GetShellType() == ViewShell::ST_DRAW)) - { - // The drop is only accepted or executed when it takes place over a - // page object. Therefore we replace a missing page number by the - // number of the page under the mouse. - if (nPage == SDRPAGE_NOTFOUND) - { - model::SharedPageDescriptor pDescriptor ( - mrSlideSorter.GetModel().GetPageDescriptor( - mrSlideSorter.GetView().GetPageIndexAtPoint(rPosition))); - if (pDescriptor) - nPage = pDescriptor->GetPageIndex(); - } - - // Now comes the code that is different for the Execute and Accept: - // We simply forward the call to the AcceptDrop() or ExecuteDrop() - // methods of the DrawViewShell in the center pane. - if (nPage != SDRPAGE_NOTFOUND) - switch (eCommand) - { - case DC_ACCEPT: - nResult = pDrawViewShell->AcceptDrop( - *reinterpret_cast<const AcceptDropEvent*>(pDropEvent), - rTargetHelper, - pTargetWindow, - nPage, - nLayer); - break; - - case DC_EXECUTE: - nResult = pDrawViewShell->ExecuteDrop( - *reinterpret_cast<const ExecuteDropEvent*>(pDropEvent), - rTargetHelper, - pTargetWindow, - nPage, - nLayer); - break; - } - } - - return nResult; -} - - - -} } } // end of namespace ::sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsCommand.hxx b/sd/source/ui/slidesorter/controller/SlsCommand.hxx deleted file mode 100644 index d6dee9911..000000000 --- a/sd/source/ui/slidesorter/controller/SlsCommand.hxx +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_SLIDESORTER_COMMAND_HXX -#define SD_SLIDESORTER_COMMAND_HXX - -namespace sd { namespace slidesorter { namespace controller { - -/** Base class for command objects. It specifies the interface for commands - whose execution can be scheduled via the SlotManager. -*/ -class Command -{ -public: - virtual ~Command (void) {}; - virtual void operator() (void) = 0; -}; - -} } } // end of namespace sd::slidesorter::controller - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx b/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx deleted file mode 100644 index 8cd692418..000000000 --- a/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx +++ /dev/null @@ -1,322 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "SlideSorter.hxx" -#include "model/SlideSorterModel.hxx" -#include "model/SlsPageDescriptor.hxx" -#include "controller/SlsPageSelector.hxx" -#include "controller/SlideSorterController.hxx" -#include "controller/SlsCurrentSlideManager.hxx" -#include "controller/SlsFocusManager.hxx" -#include "view/SlideSorterView.hxx" -#include "ViewShellBase.hxx" -#include "ViewShell.hxx" -#include "DrawViewShell.hxx" -#include "sdpage.hxx" -#include "FrameView.hxx" -#include <com/sun/star/beans/XPropertySet.hpp> - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; - -using namespace ::sd::slidesorter::model; - - -namespace sd { namespace slidesorter { namespace controller { - - -CurrentSlideManager::CurrentSlideManager (SlideSorter& rSlideSorter) - : mrSlideSorter(rSlideSorter), - mnCurrentSlideIndex(-1), - mpCurrentSlide(), - maSwitchPageDelayTimer() -{ - maSwitchPageDelayTimer.SetTimeout(100); - maSwitchPageDelayTimer.SetTimeoutHdl(LINK(this,CurrentSlideManager,SwitchPageCallback)); -} - - - - -CurrentSlideManager::~CurrentSlideManager (void) -{ -} - - - - -void CurrentSlideManager::NotifyCurrentSlideChange (const SdPage* pPage) -{ - if (pPage != NULL) - NotifyCurrentSlideChange( - mrSlideSorter.GetModel().GetIndex( - Reference<drawing::XDrawPage>( - const_cast<SdPage*>(pPage)->getUnoPage(), - UNO_QUERY))); - else - NotifyCurrentSlideChange(-1); -} - - - - -void CurrentSlideManager::NotifyCurrentSlideChange (const sal_Int32 nSlideIndex) -{ - if (mnCurrentSlideIndex != nSlideIndex) - { - ReleaseCurrentSlide(); - AcquireCurrentSlide(nSlideIndex); - - // Update the selection. - mrSlideSorter.GetController().GetPageSelector().DeselectAllPages(); - if (mpCurrentSlide) - { - mrSlideSorter.GetController().GetPageSelector().SelectPage(mpCurrentSlide); - mrSlideSorter.GetController().GetFocusManager().SetFocusedPage(mpCurrentSlide); - } - } -} - - - - -void CurrentSlideManager::ReleaseCurrentSlide (void) -{ - if (mpCurrentSlide.get() != NULL) - mrSlideSorter.GetView().SetState(mpCurrentSlide, PageDescriptor::ST_Current, false); - - mpCurrentSlide.reset(); - mnCurrentSlideIndex = -1; -} - - - - -bool CurrentSlideManager::IsCurrentSlideIsValid (void) -{ - return mnCurrentSlideIndex >= 0 && mnCurrentSlideIndex<mrSlideSorter.GetModel().GetPageCount(); -} - - - - -void CurrentSlideManager::AcquireCurrentSlide (const sal_Int32 nSlideIndex) -{ - mnCurrentSlideIndex = nSlideIndex; - - if (IsCurrentSlideIsValid()) - { - // Get a descriptor for the XDrawPage reference. Note that the - // given XDrawPage may or may not be member of the slide sorter - // document. - mpCurrentSlide = mrSlideSorter.GetModel().GetPageDescriptor(mnCurrentSlideIndex); - if (mpCurrentSlide.get() != NULL) - mrSlideSorter.GetView().SetState(mpCurrentSlide, PageDescriptor::ST_Current, true); - } -} - - - - -void CurrentSlideManager::SwitchCurrentSlide ( - const sal_Int32 nSlideIndex, - const bool bUpdateSelection) -{ - SwitchCurrentSlide(mrSlideSorter.GetModel().GetPageDescriptor(nSlideIndex), bUpdateSelection); -} - - - - -void CurrentSlideManager::SwitchCurrentSlide ( - const SharedPageDescriptor& rpDescriptor, - const bool bUpdateSelection) -{ - if (rpDescriptor.get() != NULL && mpCurrentSlide!=rpDescriptor) - { - ReleaseCurrentSlide(); - AcquireCurrentSlide((rpDescriptor->GetPage()->GetPageNum()-1)/2); - - ViewShell* pViewShell = mrSlideSorter.GetViewShell(); - if (pViewShell != NULL && pViewShell->IsMainViewShell()) - { - // The slide sorter is the main view. - FrameView* pFrameView = pViewShell->GetFrameView(); - if (pFrameView != NULL) - pFrameView->SetSelectedPage(sal::static_int_cast<sal_uInt16>(mnCurrentSlideIndex)); - mrSlideSorter.GetController().GetPageSelector().SetCoreSelection(); - } - - // We do not tell the XController/ViewShellBase about the new - // slide right away. This is done asynchronously after a short - // delay to allow for more slide switches in the slide sorter. - // This goes under the assumption that slide switching inside - // the slide sorter is fast (no expensive redraw of the new page - // (unless the preview of the new slide is not yet preset)) and - // that slide switching in the edit view is slow (all shapes of - // the new slide have to be repainted.) - maSwitchPageDelayTimer.Start(); - - // We have to store the (index of the) new current slide at - // the tab control because there are other asynchronous - // notifications of the slide switching that otherwise - // overwrite the correct value. - SetCurrentSlideAtTabControl(mpCurrentSlide); - - if (bUpdateSelection) - { - mrSlideSorter.GetController().GetPageSelector().DeselectAllPages(); - mrSlideSorter.GetController().GetPageSelector().SelectPage(rpDescriptor); - } - mrSlideSorter.GetController().GetFocusManager().SetFocusedPage(rpDescriptor); - } -} - - - - -void CurrentSlideManager::SetCurrentSlideAtViewShellBase (const SharedPageDescriptor& rpDescriptor) -{ - OSL_ASSERT(rpDescriptor.get() != NULL); - - ViewShellBase* pBase = mrSlideSorter.GetViewShellBase(); - if (pBase != NULL) - { - DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>( - pBase->GetMainViewShell().get()); - if (pDrawViewShell != NULL) - { - sal_uInt16 nPageNumber = (rpDescriptor->GetPage()->GetPageNum()-1)/2; - pDrawViewShell->SwitchPage(nPageNumber); - pDrawViewShell->GetPageTabControl()->SetCurPageId(nPageNumber+1); - } - } -} - - - - -void CurrentSlideManager::SetCurrentSlideAtTabControl (const SharedPageDescriptor& rpDescriptor) -{ - OSL_ASSERT(rpDescriptor.get() != NULL); - - ViewShellBase* pBase = mrSlideSorter.GetViewShellBase(); - if (pBase != NULL) - { - ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( - ::boost::dynamic_pointer_cast<DrawViewShell>(pBase->GetMainViewShell())); - if (pDrawViewShell) - { - sal_uInt16 nPageNumber = (rpDescriptor->GetPage()->GetPageNum()-1)/2; - pDrawViewShell->GetPageTabControl()->SetCurPageId(nPageNumber+1); - } - } -} - - - - -void CurrentSlideManager::SetCurrentSlideAtXController (const SharedPageDescriptor& rpDescriptor) -{ - OSL_ASSERT(rpDescriptor.get() != NULL); - - try - { - Reference<beans::XPropertySet> xSet (mrSlideSorter.GetXController(), UNO_QUERY); - if (xSet.is()) - { - Any aPage; - aPage <<= rpDescriptor->GetPage()->getUnoPage(); - xSet->setPropertyValue ( - String::CreateFromAscii("CurrentPage"), - aPage); - } - } - catch (const Exception&) - { - // We have not been able to set the current page at the main view. - // This is sad but still leaves us in a valid state. Therefore, - // this exception is silently ignored. - } -} - - - - -SharedPageDescriptor CurrentSlideManager::GetCurrentSlide (void) -{ - return mpCurrentSlide; -} - - - - -void CurrentSlideManager::PrepareModelChange (void) -{ - mpCurrentSlide.reset(); -} - - - - -void CurrentSlideManager::HandleModelChange (void) -{ - if (mnCurrentSlideIndex >= 0) - { - mpCurrentSlide = mrSlideSorter.GetModel().GetPageDescriptor(mnCurrentSlideIndex); - if (mpCurrentSlide.get() != NULL) - mrSlideSorter.GetView().SetState(mpCurrentSlide, PageDescriptor::ST_Current, true); - } -} - - - - -IMPL_LINK(CurrentSlideManager, SwitchPageCallback, void*, EMPTYARG) -{ - if (mpCurrentSlide) - { - // Set current page. At the moment we have to do this in two - // different ways. The UNO way is the preferable one but, alas, - // it does not work always correctly (after some kinds of model - // changes). Therefore, we call DrawViewShell::SwitchPage(), - // too. - ViewShell* pViewShell = mrSlideSorter.GetViewShell(); - if (pViewShell==NULL || ! pViewShell->IsMainViewShell()) - SetCurrentSlideAtViewShellBase(mpCurrentSlide); - SetCurrentSlideAtXController(mpCurrentSlide); - } - - return 1; -} - -} } } // end of namespace ::sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx b/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx deleted file mode 100644 index 2ed5ed39b..000000000 --- a/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx +++ /dev/null @@ -1,199 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "SlsDragAndDropContext.hxx" - -#include "SlideSorter.hxx" -#include "model/SlideSorterModel.hxx" -#include "model/SlsPageEnumerationProvider.hxx" -#include "view/SlideSorterView.hxx" -#include "controller/SlideSorterController.hxx" -#include "controller/SlsInsertionIndicatorHandler.hxx" -#include "controller/SlsScrollBarManager.hxx" -#include "controller/SlsProperties.hxx" -#include "controller/SlsSelectionFunction.hxx" -#include "controller/SlsSelectionManager.hxx" -#include "controller/SlsTransferable.hxx" -#include "DrawDocShell.hxx" -#include "drawdoc.hxx" -#include "app.hrc" -#include <sfx2/bindings.hxx> -#include <boost/bind.hpp> - -namespace sd { namespace slidesorter { namespace controller { - -DragAndDropContext::DragAndDropContext (SlideSorter& rSlideSorter) - : mpTargetSlideSorter(&rSlideSorter), - mnInsertionIndex(-1) -{ - ::std::vector<const SdPage*> aPages; - - // No Drag-and-Drop for master pages. - if (rSlideSorter.GetModel().GetEditMode() != EM_PAGE) - return; - - rSlideSorter.GetController().GetInsertionIndicatorHandler()->UpdateIndicatorIcon( - dynamic_cast<Transferable*>(SD_MOD()->pTransferDrag)); -} - - - - -DragAndDropContext::~DragAndDropContext (void) -{ - SetTargetSlideSorter (NULL, Point(0,0), InsertionIndicatorHandler::UnknownMode, false); -} - - - - -void DragAndDropContext::GetPagesFromBookmarks ( - ::std::vector<const SdPage*>& rPages, - sal_Int32& rnSelectionCount, - DrawDocShell* pDocShell, - const List& rBookmarks) const -{ - if (pDocShell == NULL) - return; - - const SdDrawDocument* pDocument = pDocShell->GetDoc(); - if (pDocument == NULL) - return; - - for (sal_uLong nIndex=0,nCount=rBookmarks.Count(); nIndex<nCount; ++nIndex) - { - const String sPageName (*static_cast<String*>(rBookmarks.GetObject(nIndex))); - sal_Bool bIsMasterPage (sal_False); - const sal_uInt16 nPageIndex (pDocument->GetPageByName(sPageName, bIsMasterPage)); - if (nPageIndex == SDRPAGE_NOTFOUND) - continue; - - const SdPage* pPage = dynamic_cast<const SdPage*>(pDocument->GetPage(nPageIndex)); - if (pPage != NULL) - rPages.push_back(pPage); - } - rnSelectionCount = rBookmarks.Count(); -} - - - - -void DragAndDropContext::GetPagesFromSelection ( - ::std::vector<const SdPage*>& rPages, - sal_Int32& rnSelectionCount, - model::PageEnumeration& rSelection) const -{ - // Show a new substitution for the selected page objects. - rnSelectionCount = 0; - - while (rSelection.HasMoreElements()) - { - model::SharedPageDescriptor pDescriptor (rSelection.GetNextElement()); - if (rPages.size() < 3) - rPages.push_back(pDescriptor->GetPage()); - ++rnSelectionCount; - } -} - - - - -void DragAndDropContext::Dispose (void) -{ - mnInsertionIndex = -1; -} - - - - -void DragAndDropContext::UpdatePosition ( - const Point& rMousePosition, - const InsertionIndicatorHandler::Mode eMode, - const bool bAllowAutoScroll) -{ - if (mpTargetSlideSorter == NULL) - return; - - if (mpTargetSlideSorter->GetProperties()->IsUIReadOnly()) - return; - - // Convert window coordinates into model coordinates (we need the - // window coordinates for auto-scrolling because that remains - // constant while scrolling.) - SharedSdWindow pWindow (mpTargetSlideSorter->GetContentWindow()); - const Point aMouseModelPosition (pWindow->PixelToLogic(rMousePosition)); - ::boost::shared_ptr<InsertionIndicatorHandler> pInsertionIndicatorHandler ( - mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler()); - - if ( ! (bAllowAutoScroll - && mpTargetSlideSorter->GetController().GetScrollBarManager().AutoScroll( - rMousePosition, - ::boost::bind( - &DragAndDropContext::UpdatePosition, this, rMousePosition, eMode, false)))) - { - pInsertionIndicatorHandler->UpdatePosition(aMouseModelPosition, eMode); - - // Remember the new insertion index. - mnInsertionIndex = pInsertionIndicatorHandler->GetInsertionPageIndex(); - if (pInsertionIndicatorHandler->IsInsertionTrivial(mnInsertionIndex, eMode)) - mnInsertionIndex = -1; - } -} - - - - -void DragAndDropContext::SetTargetSlideSorter ( - SlideSorter* pSlideSorter, - const Point aMousePosition, - const InsertionIndicatorHandler::Mode eMode, - const bool bIsOverSourceView) -{ - if (mpTargetSlideSorter != NULL) - { - mpTargetSlideSorter->GetController().GetScrollBarManager().StopAutoScroll(); - mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler()->End( - Animator::AM_Animated); - } - - mpTargetSlideSorter = pSlideSorter; - - if (mpTargetSlideSorter != NULL) - { - mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler()->Start( - bIsOverSourceView); - mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler()->UpdatePosition( - aMousePosition, - eMode); - - } -} - - -} } } // end of namespace ::sd::slidesorter::controller diff --git a/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.hxx b/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.hxx deleted file mode 100644 index 434771ae6..000000000 --- a/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.hxx +++ /dev/null @@ -1,100 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_SLIDESORTER_SUBSTITUTION_HANDLER_HXX -#define SD_SLIDESORTER_SUBSTITUTION_HANDLER_HXX - -#include <tools/gen.hxx> - -#include "model/SlsSharedPageDescriptor.hxx" -#include "controller/SlsInsertionIndicatorHandler.hxx" -#include <vector> - - -namespace sd { namespace slidesorter { -class SlideSorter; -} } - - - -namespace sd { namespace slidesorter { namespace controller { - -/** A DragAndDropContext object handles an active drag and drop operation. - When the mouse is moved from one slide sorter window to another the - target SlideSorter object is exchanged accordingly. -*/ -class DragAndDropContext -{ -public: - /** Create a substitution display of the currently selected pages or, - when provided, the pages in the transferable. - */ - DragAndDropContext (SlideSorter& rSlideSorter); - ~DragAndDropContext (void); - - /** Call this method (for example as reaction to ESC key press) to avoid - processing (ie moving or inserting) the substition when the called - DragAndDropContext object is destroyed. - */ - void Dispose (void); - - /** Move the substitution display by the distance the mouse has - travelled since the last call to this method or to - CreateSubstitution(). The given point becomes the new anchor. - */ - void UpdatePosition ( - const Point& rMousePosition, - const InsertionIndicatorHandler::Mode eMode, - const bool bAllowAutoScroll = true); - - void SetTargetSlideSorter ( - SlideSorter* pSlideSorter = NULL, - const Point aMousePosition = Point(0,0), - const InsertionIndicatorHandler::Mode eMode = InsertionIndicatorHandler::UnknownMode, - const bool bIsOverSourceView = false); - -private: - SlideSorter* mpTargetSlideSorter; - model::SharedPageDescriptor mpHitDescriptor; - sal_Int32 mnInsertionIndex; - - void GetPagesFromBookmarks ( - ::std::vector<const SdPage*>& rPages, - sal_Int32& rnSelectionCount, - DrawDocShell* pDocShell, - const List& rBookmarks) const; - void GetPagesFromSelection ( - ::std::vector<const SdPage*>& rPages, - sal_Int32& rnSelectionCount, - model::PageEnumeration& rSelection) const; -}; - - - -} } } // end of namespace ::sd::slidesorter::controller - -#endif diff --git a/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx b/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx deleted file mode 100644 index 6f67c8188..000000000 --- a/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx +++ /dev/null @@ -1,384 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" -#include "controller/SlsFocusManager.hxx" - -#include "SlideSorter.hxx" -#include "PaneDockingWindow.hxx" -#include "controller/SlideSorterController.hxx" -#include "controller/SlsCurrentSlideManager.hxx" -#include "controller/SlsVisibleAreaManager.hxx" -#include "model/SlideSorterModel.hxx" -#include "model/SlsPageDescriptor.hxx" -#include "view/SlideSorterView.hxx" -#include "view/SlsLayouter.hxx" -#include <vcl/toolbox.hxx> - -#include "Window.hxx" -#include "sdpage.hxx" - -#define UNIFY_FOCUS_AND_CURRENT_PAGE - -namespace sd { namespace slidesorter { namespace controller { - -FocusManager::FocusManager (SlideSorter& rSlideSorter) - : mrSlideSorter(rSlideSorter), - mnPageIndex(0), - mbPageIsFocused(false), - mbIsVerticalWrapActive(false) -{ - if (mrSlideSorter.GetModel().GetPageCount() > 0) - mnPageIndex = 0; -} - - - - -FocusManager::~FocusManager (void) -{ -} - - - - -void FocusManager::MoveFocus (FocusMoveDirection eDirection) -{ - if (mnPageIndex >= 0 && mbPageIsFocused) - { - HideFocusIndicator (GetFocusedPageDescriptor()); - - const sal_Int32 nColumnCount (mrSlideSorter.GetView().GetLayouter().GetColumnCount()); - const sal_Int32 nPageCount (mrSlideSorter.GetModel().GetPageCount()); - switch (eDirection) - { - case FMD_NONE: - // Nothing to be done. - break; - - case FMD_LEFT: - if (mnPageIndex > 0) - mnPageIndex -= 1; - else if (mbIsVerticalWrapActive) - mnPageIndex = nPageCount-1; - break; - - case FMD_RIGHT: - if (mnPageIndex < nPageCount-1) - mnPageIndex += 1; - else if (mbIsVerticalWrapActive) - mnPageIndex = 0; - break; - - case FMD_UP: - { - const sal_Int32 nCandidate (mnPageIndex - nColumnCount); - if (nCandidate < 0) - { - if (mbIsVerticalWrapActive) - { - // Wrap arround to the bottom row or the one above - // and go to the correct column. - const sal_Int32 nLastIndex (nPageCount-1); - const sal_Int32 nLastColumn (nLastIndex % nColumnCount); - const sal_Int32 nCurrentColumn (mnPageIndex%nColumnCount); - if (nLastColumn >= nCurrentColumn) - { - // The last row contains the current column. - mnPageIndex = nLastIndex - (nLastColumn-nCurrentColumn); - } - else - { - // Only the second to last row contains the current column. - mnPageIndex = nLastIndex - nLastColumn - - nColumnCount - + nCurrentColumn; - } - } - } - else - { - // Move the focus the previous row. - mnPageIndex = nCandidate; - } - } - break; - - case FMD_DOWN: - { - const sal_Int32 nCandidate (mnPageIndex + nColumnCount); - if (nCandidate >= nPageCount) - { - if (mbIsVerticalWrapActive) - { - // Wrap arround to the correct column. - mnPageIndex = mnPageIndex % nColumnCount; - } - else - { - // Do not move the focus. - } - } - else - { - // Move the focus to the next row. - mnPageIndex = nCandidate; - } - } - break; - } - - if (mnPageIndex < 0) - { - OSL_ASSERT(mnPageIndex>=0); - mnPageIndex = 0; - } - else if (mnPageIndex >= nPageCount) - { - OSL_ASSERT(mnPageIndex<nPageCount); - mnPageIndex = nPageCount - 1; - } - - if (mbPageIsFocused) - { - ShowFocusIndicator(GetFocusedPageDescriptor(), true); - } - } -} - - - - -void FocusManager::ShowFocus (const bool bScrollToFocus) -{ - mbPageIsFocused = true; - ShowFocusIndicator(GetFocusedPageDescriptor(), bScrollToFocus); -} - - - - -void FocusManager::HideFocus (void) -{ - mbPageIsFocused = false; - HideFocusIndicator(GetFocusedPageDescriptor()); -} - - - - -bool FocusManager::ToggleFocus (void) -{ - if (mnPageIndex >= 0) - { - if (mbPageIsFocused) - HideFocus (); - else - ShowFocus (); - } - return mbPageIsFocused; -} - - - - -bool FocusManager::HasFocus (void) const -{ - return mrSlideSorter.GetContentWindow()->HasFocus(); -} - - - - -model::SharedPageDescriptor FocusManager::GetFocusedPageDescriptor (void) const -{ - return mrSlideSorter.GetModel().GetPageDescriptor(mnPageIndex); -} - - - - -sal_Int32 FocusManager::GetFocusedPageIndex (void) const -{ - return mnPageIndex; -} - - -void FocusManager::SetFocusedPage (const model::SharedPageDescriptor& rpDescriptor) -{ - if (rpDescriptor.get() != NULL) - { - FocusHider aFocusHider (*this); - mnPageIndex = (rpDescriptor->GetPage()->GetPageNum()-1)/2; - } -} - - - - -void FocusManager::SetFocusedPage (sal_Int32 nPageIndex) -{ - FocusHider aFocusHider (*this); - mnPageIndex = nPageIndex; -} - - - - -void FocusManager::SetFocusedPageToCurrentPage (void) -{ - SetFocusedPage(mrSlideSorter.GetController().GetCurrentSlideManager()->GetCurrentSlide()); -} - - - - -bool FocusManager::IsFocusShowing (void) const -{ - return HasFocus() && mbPageIsFocused; -} - - - - -void FocusManager::HideFocusIndicator (const model::SharedPageDescriptor& rpDescriptor) -{ - if (rpDescriptor.get() != NULL) - { - mrSlideSorter.GetView().SetState(rpDescriptor, model::PageDescriptor::ST_Focused, false); - } -} - - - - -void FocusManager::ShowFocusIndicator ( - const model::SharedPageDescriptor& rpDescriptor, - const bool bScrollToFocus) -{ - if (rpDescriptor.get() != NULL) - { - mrSlideSorter.GetView().SetState(rpDescriptor, model::PageDescriptor::ST_Focused, true); - - if (bScrollToFocus) - { - // Scroll the focused page object into the visible area and repaint - // it, so that the focus indicator becomes visible. - mrSlideSorter.GetController().GetVisibleAreaManager().RequestVisible(rpDescriptor,true); - } - mrSlideSorter.GetView().RequestRepaint(rpDescriptor); - - NotifyFocusChangeListeners(); - } -} - - - - -void FocusManager::AddFocusChangeListener (const Link& rListener) -{ - if (::std::find (maFocusChangeListeners.begin(), maFocusChangeListeners.end(), rListener) - == maFocusChangeListeners.end()) - { - maFocusChangeListeners.push_back (rListener); - } -} - - - - -void FocusManager::RemoveFocusChangeListener (const Link& rListener) -{ - maFocusChangeListeners.erase ( - ::std::find (maFocusChangeListeners.begin(), maFocusChangeListeners.end(), rListener)); -} - - - - -void FocusManager::SetFocusToToolBox (void) -{ - HideFocus(); - - if (mrSlideSorter.GetViewShell() != NULL) - { - ::Window* pParentWindow = mrSlideSorter.GetViewShell()->GetParentWindow(); - DockingWindow* pDockingWindow = NULL; - while (pParentWindow!=NULL && pDockingWindow==NULL) - { - pDockingWindow = dynamic_cast<DockingWindow*>(pParentWindow); - pParentWindow = pParentWindow->GetParent(); - } - if (pDockingWindow) - { - PaneDockingWindow* pPaneDockingWindow = dynamic_cast<PaneDockingWindow*>(pDockingWindow); - if (pPaneDockingWindow != NULL) - pPaneDockingWindow->GetToolBox().GrabFocus(); - } - } -} - - - - -void FocusManager::NotifyFocusChangeListeners (void) const -{ - // Create a copy of the listener list to be safe when that is modified. - ::std::vector<Link> aListeners (maFocusChangeListeners); - - // Tell the slection change listeners that the selection has changed. - ::std::vector<Link>::iterator iListener (aListeners.begin()); - ::std::vector<Link>::iterator iEnd (aListeners.end()); - for (; iListener!=iEnd; ++iListener) - { - iListener->Call(NULL); - } -} - - - - -FocusManager::FocusHider::FocusHider (FocusManager& rManager) -: mbFocusVisible(rManager.IsFocusShowing()) -, mrManager(rManager) -{ - mrManager.HideFocus(); -} - - - - -FocusManager::FocusHider::~FocusHider (void) -{ - if (mbFocusVisible) - mrManager.ShowFocus(); -} - -} } } // end of namespace ::sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsHideSlideFunction.cxx b/sd/source/ui/slidesorter/controller/SlsHideSlideFunction.cxx deleted file mode 100644 index 71bf69410..000000000 --- a/sd/source/ui/slidesorter/controller/SlsHideSlideFunction.cxx +++ /dev/null @@ -1,174 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "SlsHideSlideFunction.hxx" - -#include "SlideSorter.hxx" -#include "model/SlsPageEnumerationProvider.hxx" -#include "model/SlsPageDescriptor.hxx" -#include "view/SlideSorterView.hxx" - -#include "app.hrc" -#include "drawdoc.hxx" -#include "sdpage.hxx" -#include "ViewShell.hxx" - -#include <sfx2/viewfrm.hxx> -#include <sfx2/bindings.hxx> -#include <sfx2/request.hxx> -#include <svx/svxids.hrc> - -namespace sd { namespace slidesorter { namespace controller { - -TYPEINIT1(HideSlideFunction, SlideFunction); - -HideSlideFunction::HideSlideFunction ( - SlideSorter& rSlideSorter, - SfxRequest& rRequest) - : SlideFunction( rSlideSorter, rRequest), - mrSlideSorter(rSlideSorter) -{ -} - - - - -HideSlideFunction::~HideSlideFunction (void) -{ -} - - - - -FunctionReference HideSlideFunction::Create ( - SlideSorter& rSlideSorter, - SfxRequest& rRequest ) -{ - FunctionReference xFunc( new HideSlideFunction( rSlideSorter, rRequest ) ); - xFunc->DoExecute(rRequest); - return xFunc; -} - - - - -void HideSlideFunction::DoExecute (SfxRequest& rRequest) -{ - SlideFunction::DoExecute(rRequest); - - model::PageEnumeration aSelectedPages ( - model::PageEnumerationProvider::CreateSelectedPagesEnumeration(mrSlideSorter.GetModel())); - - ExclusionState eState (UNDEFINED); - - switch (rRequest.GetSlot()) - { - case SID_HIDE_SLIDE: - eState = EXCLUDED; - break; - - case SID_SHOW_SLIDE: - eState = INCLUDED; - break; - - default: - eState = UNDEFINED; - break; - } - - if (eState != UNDEFINED) - { - // Set status at the selected pages. - aSelectedPages.Rewind (); - while (aSelectedPages.HasMoreElements()) - { - model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement()); - static_cast<view::SlideSorterView*>(mpView)->SetState( - pDescriptor, - model::PageDescriptor::ST_Excluded, - eState==EXCLUDED); - } - } - - SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings(); - rBindings.Invalidate (SID_PRESENTATION); - rBindings.Invalidate (SID_REHEARSE_TIMINGS); - rBindings.Invalidate (SID_HIDE_SLIDE); - rBindings.Invalidate (SID_SHOW_SLIDE); - mpDoc->SetChanged(); -} - - - - -HideSlideFunction::ExclusionState HideSlideFunction::GetExclusionState ( - model::PageEnumeration& rPageSet) -{ - ExclusionState eState (UNDEFINED); - sal_Bool bState; - - // Get toggle state of the selected pages. - while (rPageSet.HasMoreElements() && eState!=MIXED) - { - bState = rPageSet.GetNextElement()->GetPage()->IsExcluded(); - switch (eState) - { - case UNDEFINED: - // Use the first selected page to set the inital value. - eState = bState ? EXCLUDED : INCLUDED; - break; - - case EXCLUDED: - // The pages before where all not part of the show, - // this one is. - if ( ! bState) - eState = MIXED; - break; - - case INCLUDED: - // The pages before where all part of the show, - // this one is not. - if (bState) - eState = MIXED; - break; - - case MIXED: - default: - // No need to change anything. - break; - } - } - - return eState; -} - -} } } // end of namespace ::sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsHideSlideFunction.hxx b/sd/source/ui/slidesorter/controller/SlsHideSlideFunction.hxx deleted file mode 100644 index 9fb32c2c0..000000000 --- a/sd/source/ui/slidesorter/controller/SlsHideSlideFunction.hxx +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_SLIDESORTER_HIDE_SLIDE_FUNCTION_HXX -#define SD_SLIDESORTER_HIDE_SLIDE_FUNCTION_HXX - -#include "controller/SlsSlideFunction.hxx" -#include "model/SlsPageEnumeration.hxx" - - -namespace sd { namespace slidesorter { namespace controller { - -/** Toggle the hidden flag of the selected slides. - When the selected pages have not all the same state they will all set to - hidden. When all selected pages have the same state this state is - toggled for all of them -*/ -class HideSlideFunction - : public SlideFunction -{ -public: - TYPEINFO(); - - virtual ~HideSlideFunction (void); - - static FunctionReference Create( SlideSorter& rSlideSorter, SfxRequest& rRequest ); - virtual void DoExecute( SfxRequest& rReq ); - - // The state of a set of slides with respect to being excluded from the - // slide show. - enum ExclusionState {UNDEFINED, EXCLUDED, INCLUDED, MIXED}; - - /** Return for the given set of slides whether they included are - excluded from the slide show. - */ - static ExclusionState GetExclusionState (model::PageEnumeration& rPageSet); - -protected: - HideSlideFunction ( - SlideSorter& rSlideSorter, - SfxRequest& rRequest); - - SlideSorter& mrSlideSorter; -}; - -} } } // end of namespace ::sd::slidesorter::controller - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx b/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx deleted file mode 100644 index b39bb106a..000000000 --- a/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx +++ /dev/null @@ -1,327 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "controller/SlsInsertionIndicatorHandler.hxx" -#include "controller/SlsProperties.hxx" -#include "view/SlideSorterView.hxx" -#include "view/SlsLayouter.hxx" -#include "view/SlsInsertionIndicatorOverlay.hxx" -#include "model/SlideSorterModel.hxx" -#include "model/SlsPageEnumerationProvider.hxx" -#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> - -#include "SlideSorter.hxx" - -using namespace ::com::sun::star::datatransfer::dnd::DNDConstants; - -namespace sd { namespace slidesorter { namespace controller { - - -InsertionIndicatorHandler::InsertionIndicatorHandler (SlideSorter& rSlideSorter) - : mrSlideSorter(rSlideSorter), - mpInsertAnimator(), - mpInsertionIndicatorOverlay(new view::InsertionIndicatorOverlay(rSlideSorter)), - maInsertPosition(), - meMode(MoveMode), - mbIsActive(false), - mbIsReadOnly(mrSlideSorter.GetModel().IsReadOnly()), - mbIsOverSourceView(true), - maIconSize(0,0), - mbIsForcedShow(false) -{ -} - - - - -InsertionIndicatorHandler::~InsertionIndicatorHandler (void) -{ -} - - - - -void InsertionIndicatorHandler::Start (const bool bIsOverSourceView) -{ - if (mbIsActive) - { - OSL_ASSERT(!mbIsActive); - } - - mbIsReadOnly = mrSlideSorter.GetModel().IsReadOnly(); - if (mbIsReadOnly) - return; - - mbIsActive = true; - mbIsOverSourceView = bIsOverSourceView; -} - - - - -void InsertionIndicatorHandler::End (const controller::Animator::AnimationMode eMode) -{ - if (mbIsForcedShow || ! mbIsActive || mbIsReadOnly) - return; - - GetInsertAnimator()->Reset(eMode); - - mbIsActive = false; - // maInsertPosition = view::InsertPosition(); - meMode = UnknownMode; - - mpInsertionIndicatorOverlay->Hide(); - mpInsertionIndicatorOverlay.reset(new view::InsertionIndicatorOverlay(mrSlideSorter)); -} - - - - -void InsertionIndicatorHandler::ForceShow (void) -{ - mbIsForcedShow = true; -} - - - - -void InsertionIndicatorHandler::ForceEnd (void) -{ - mbIsForcedShow = false; - End(Animator::AM_Immediate); -} - - - - -void InsertionIndicatorHandler::UpdateIndicatorIcon (const Transferable* pTransferable) -{ - mpInsertionIndicatorOverlay->Create(pTransferable); - maIconSize = mpInsertionIndicatorOverlay->GetSize(); -} - - - - -InsertionIndicatorHandler::Mode InsertionIndicatorHandler::GetModeFromDndAction ( - const sal_Int8 nDndAction) -{ - if ((nDndAction & ACTION_MOVE) != 0) - return MoveMode; - else if ((nDndAction & ACTION_COPY) != 0) - return CopyMode; - else - return UnknownMode; -} - - - - -void InsertionIndicatorHandler::UpdatePosition ( - const Point& rMouseModelPosition, - const Mode eMode) -{ - if ( ! mbIsActive) - return; - - if (mbIsReadOnly) - return; - - SetPosition(rMouseModelPosition, eMode); -} - - - - -void InsertionIndicatorHandler::UpdatePosition ( - const Point& rMouseModelPosition, - const sal_Int8 nDndAction) -{ - UpdatePosition(rMouseModelPosition, GetModeFromDndAction(nDndAction)); -} - - - - -bool InsertionIndicatorHandler::IsActive (void) const -{ - return mbIsActive; -} - - - - -sal_Int32 InsertionIndicatorHandler::GetInsertionPageIndex (void) const -{ - if (mbIsReadOnly) - return -1; - else - return maInsertPosition.GetIndex(); -} - - - - -void InsertionIndicatorHandler::SetPosition ( - const Point& rPoint, - const Mode eMode) -{ - view::Layouter& rLayouter (mrSlideSorter.GetView().GetLayouter()); - - const view::InsertPosition aInsertPosition (rLayouter.GetInsertPosition( - rPoint, - maIconSize, - mrSlideSorter.GetModel())); - - static sal_Int32 TargetIndex (1); - if (aInsertPosition.GetIndex() == TargetIndex) - { - const view::InsertPosition aPosition (rLayouter.GetInsertPosition( - rPoint, - maIconSize, - mrSlideSorter.GetModel())); - const view::InsertPosition aPosition2 (rLayouter.GetInsertPosition( - rPoint, - maIconSize, - mrSlideSorter.GetModel())); - } - - if (maInsertPosition != aInsertPosition - || meMode != eMode - // || ! mpInsertionIndicatorOverlay->IsVisible() - ) - { - maInsertPosition = aInsertPosition; - meMode = eMode; - mbIsInsertionTrivial = IsInsertionTrivial(maInsertPosition.GetIndex(), eMode); - if (maInsertPosition.GetIndex()>=0 && ! mbIsInsertionTrivial) - { - mpInsertionIndicatorOverlay->SetLocation(maInsertPosition.GetLocation()); - - GetInsertAnimator()->SetInsertPosition(maInsertPosition); - mpInsertionIndicatorOverlay->Show(); - } - else - { - GetInsertAnimator()->Reset(Animator::AM_Animated); - mpInsertionIndicatorOverlay->Hide(); - } - } -} - - - - -::boost::shared_ptr<view::InsertAnimator> InsertionIndicatorHandler::GetInsertAnimator (void) -{ - if ( ! mpInsertAnimator) - mpInsertAnimator.reset(new view::InsertAnimator(mrSlideSorter)); - return mpInsertAnimator; -} - - - - -bool InsertionIndicatorHandler::IsInsertionTrivial ( - const sal_Int32 nInsertionIndex, - const Mode eMode) const -{ - if (eMode == CopyMode) - return false; - else if (eMode == UnknownMode) - return true; - - if ( ! mbIsOverSourceView) - return false; - - // Iterate over all selected pages and check whether there are - // holes. While we do this we remember the indices of the first and - // last selected page as preparation for the next step. - sal_Int32 nCurrentIndex = -1; - sal_Int32 nFirstIndex = -1; - sal_Int32 nLastIndex = -1; - model::PageEnumeration aSelectedPages ( - model::PageEnumerationProvider::CreateSelectedPagesEnumeration( - mrSlideSorter.GetModel())); - while (aSelectedPages.HasMoreElements()) - { - model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement()); - - // Get the page number and compare it to the last one. - const sal_Int32 nPageNumber (pDescriptor->GetPageIndex()); - if (nCurrentIndex>=0 && nPageNumber>(nCurrentIndex+1)) - return false; - else - nCurrentIndex = nPageNumber; - - // Remember indices of the first and last page of the selection. - if (nFirstIndex == -1) - nFirstIndex = nPageNumber; - nLastIndex = nPageNumber; - } - - // When we come here then the selection has no holes. We still have - // to check that the insertion position is not directly in front or - // directly behind the selection and thus moving the selection there - // would not change the model. - if (nInsertionIndex<nFirstIndex || nInsertionIndex>(nLastIndex+1)) - return false; - - return true; -} - - - - -bool InsertionIndicatorHandler::IsInsertionTrivial (const sal_Int8 nDndAction) -{ - return IsInsertionTrivial(GetInsertionPageIndex(), GetModeFromDndAction(nDndAction)); -} - - - - -//===== InsertionIndicatorHandler::ForceShowContext =========================== - -InsertionIndicatorHandler::ForceShowContext::ForceShowContext ( - const ::boost::shared_ptr<InsertionIndicatorHandler>& rpHandler) - : mpHandler(rpHandler) -{ - mpHandler->ForceShow(); -} - - - - -InsertionIndicatorHandler::ForceShowContext::~ForceShowContext (void) -{ - mpHandler->ForceEnd(); -} - -} } } // end of namespace ::sd::slidesorter::controller diff --git a/sd/source/ui/slidesorter/controller/SlsListener.cxx b/sd/source/ui/slidesorter/controller/SlsListener.cxx deleted file mode 100644 index 7c2d905a1..000000000 --- a/sd/source/ui/slidesorter/controller/SlsListener.cxx +++ /dev/null @@ -1,701 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "SlsListener.hxx" - -#include "SlideSorter.hxx" -#include "SlideSorterViewShell.hxx" -#include "ViewShellHint.hxx" -#include "controller/SlideSorterController.hxx" -#include "controller/SlsPageSelector.hxx" -#include "controller/SlsCurrentSlideManager.hxx" -#include "controller/SlsSelectionManager.hxx" -#include "controller/SlsSelectionObserver.hxx" -#include "model/SlideSorterModel.hxx" -#include "model/SlsPageEnumerationProvider.hxx" -#include "view/SlideSorterView.hxx" -#include "cache/SlsPageCache.hxx" -#include "cache/SlsPageCacheManager.hxx" -#include "drawdoc.hxx" -#include "DrawDocShell.hxx" - -#include "glob.hrc" -#include "ViewShellBase.hxx" -#include "ViewShellManager.hxx" -#include "FrameView.hxx" -#include "EventMultiplexer.hxx" -#include <com/sun/star/document/XEventBroadcaster.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/frame/FrameActionEvent.hpp> -#include <com/sun/star/frame/FrameAction.hpp> -#include <sfx2/viewfrm.hxx> -#include <tools/diagnose_ex.h> - - -using namespace ::com::sun::star::accessibility; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star; - -namespace sd { namespace slidesorter { namespace controller { - - -Listener::Listener ( - SlideSorter& rSlideSorter) - : ListenerInterfaceBase(maMutex), - mrSlideSorter(rSlideSorter), - mrController(mrSlideSorter.GetController()), - mpBase(mrSlideSorter.GetViewShellBase()), - mbListeningToDocument (false), - mbListeningToUNODocument (false), - mbListeningToController (false), - mbListeningToFrame (false), - mbIsMainViewChangePending(false), - mxControllerWeak(), - mxFrameWeak(), - mpModelChangeLock() -{ - StartListening(*mrSlideSorter.GetModel().GetDocument()); - StartListening(*mrSlideSorter.GetModel().GetDocument()->GetDocSh()); - mbListeningToDocument = true; - - // Connect to the UNO document. - Reference<document::XEventBroadcaster> xBroadcaster ( - mrSlideSorter.GetModel().GetDocument()->getUnoModel(), uno::UNO_QUERY); - if (xBroadcaster.is()) - { - xBroadcaster->addEventListener (this); - mbListeningToUNODocument = true; - } - - // Listen for disposing events from the document. - Reference<XComponent> xComponent (xBroadcaster, UNO_QUERY); - if (xComponent.is()) - xComponent->addEventListener ( - Reference<lang::XEventListener>( - static_cast<XWeak*>(this), UNO_QUERY)); - - // Connect to the frame to listen for controllers being exchanged. - bool bIsMainViewShell (false); - ViewShell* pViewShell = mrSlideSorter.GetViewShell(); - if (pViewShell != NULL) - bIsMainViewShell = pViewShell->IsMainViewShell(); - if ( ! bIsMainViewShell) - { - // Listen to changes of certain properties. - Reference<frame::XFrame> xFrame; - Reference<frame::XController> xController (mrSlideSorter.GetXController()); - if (xController.is()) - xFrame = xController->getFrame(); - mxFrameWeak = xFrame; - if (xFrame.is()) - { - xFrame->addFrameActionListener ( - Reference<frame::XFrameActionListener>( - static_cast<XWeak*>(this), UNO_QUERY)); - mbListeningToFrame = true; - } - - // Connect to the current controller. - ConnectToController (); - } - - // Listen for hints of the MainViewShell as well. If that is not yet - // present then the EventMultiplexer will tell us when it is available. - if (mpBase != NULL) - { - ViewShell* pMainViewShell = mpBase->GetMainViewShell().get(); - if (pMainViewShell != NULL - && pMainViewShell!=pViewShell) - { - StartListening(*pMainViewShell); - } - - Link aLink (LINK(this, Listener, EventMultiplexerCallback)); - mpBase->GetEventMultiplexer()->AddEventListener( - aLink, - tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED - | tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED - | tools::EventMultiplexerEvent::EID_CONTROLLER_ATTACHED - | tools::EventMultiplexerEvent::EID_CONTROLLER_DETACHED - | tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED); - } -} - - - - -Listener::~Listener (void) -{ - DBG_ASSERT( !mbListeningToDocument && !mbListeningToUNODocument && !mbListeningToFrame, - "sd::Listener::~Listener(), disposing() was not called, ask DBO!" ); -} - - - - -void Listener::ReleaseListeners (void) -{ - if (mbListeningToDocument) - { - EndListening(*mrSlideSorter.GetModel().GetDocument()->GetDocSh()); - EndListening(*mrSlideSorter.GetModel().GetDocument()); - mbListeningToDocument = false; - } - - if (mbListeningToUNODocument) - { - Reference<document::XEventBroadcaster> xBroadcaster ( - mrSlideSorter.GetModel().GetDocument()->getUnoModel(), UNO_QUERY); - if (xBroadcaster.is()) - xBroadcaster->removeEventListener (this); - - // Remove the dispose listener. - Reference<XComponent> xComponent (xBroadcaster, UNO_QUERY); - if (xComponent.is()) - xComponent->removeEventListener ( - Reference<lang::XEventListener>( - static_cast<XWeak*>(this), UNO_QUERY)); - - mbListeningToUNODocument = false; - } - - if (mbListeningToFrame) - { - // Listen to changes of certain properties. - Reference<frame::XFrame> xFrame (mxFrameWeak); - if (xFrame.is()) - { - xFrame->removeFrameActionListener ( - Reference<frame::XFrameActionListener>( - static_cast<XWeak*>(this), UNO_QUERY)); - mbListeningToFrame = false; - } - } - - DisconnectFromController (); - - if (mpBase != NULL) - { - Link aLink (LINK(this, Listener, EventMultiplexerCallback)); - mpBase->GetEventMultiplexer()->RemoveEventListener( - aLink, - tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED - | tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED - | tools::EventMultiplexerEvent::EID_CONTROLLER_ATTACHED - | tools::EventMultiplexerEvent::EID_CONTROLLER_DETACHED - | tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED); - } -} - - - - -void Listener::ConnectToController (void) -{ - ViewShell* pShell = mrSlideSorter.GetViewShell(); - - // Register at the controller of the main view shell (if we are that not - // ourself). - if (pShell==NULL || ! pShell->IsMainViewShell()) - { - Reference<frame::XController> xController (mrSlideSorter.GetXController()); - - // Listen to changes of certain properties. - Reference<beans::XPropertySet> xSet (xController, UNO_QUERY); - if (xSet.is()) - { - try - { - xSet->addPropertyChangeListener(String::CreateFromAscii("CurrentPage"), this); - } - catch (beans::UnknownPropertyException&) - { - DBG_UNHANDLED_EXCEPTION(); - } - try - { - xSet->addPropertyChangeListener(String::CreateFromAscii("IsMasterPageMode"), this); - } - catch (beans::UnknownPropertyException&) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - - // Listen for disposing events. - Reference<XComponent> xComponent (xController, UNO_QUERY); - if (xComponent.is()) - { - xComponent->addEventListener ( - Reference<lang::XEventListener>(static_cast<XWeak*>(this), UNO_QUERY)); - - mxControllerWeak = xController; - mbListeningToController = true; - } - } -} - - - - -void Listener::DisconnectFromController (void) -{ - if (mbListeningToController) - { - Reference<frame::XController> xController = mxControllerWeak; - Reference<beans::XPropertySet> xSet (xController, UNO_QUERY); - try - { - // Remove the property listener. - if (xSet.is()) - { - xSet->removePropertyChangeListener ( - String::CreateFromAscii("CurrentPage"), - this); - xSet->removePropertyChangeListener ( - String::CreateFromAscii("IsMasterPageMode"), - this); - } - - // Remove the dispose listener. - Reference<XComponent> xComponent (xController, UNO_QUERY); - if (xComponent.is()) - xComponent->removeEventListener ( - Reference<lang::XEventListener>( - static_cast<XWeak*>(this), UNO_QUERY)); - } - catch (beans::UnknownPropertyException&) - { - DBG_UNHANDLED_EXCEPTION(); - } - - mbListeningToController = false; - mxControllerWeak = Reference<frame::XController>(); - } -} - - - - -void Listener::Notify ( - SfxBroadcaster& rBroadcaster, - const SfxHint& rHint) -{ - if (rHint.ISA(SdrHint)) - { - SdrHint& rSdrHint (*PTR_CAST(SdrHint,&rHint)); - switch (rSdrHint.GetKind()) - { - case HINT_PAGEORDERCHG: - if (&rBroadcaster == mrSlideSorter.GetModel().GetDocument()) - HandleModelChange(rSdrHint.GetPage()); - break; - - default: - break; - } - } - else if (rHint.ISA(ViewShellHint)) - { - ViewShellHint& rViewShellHint (*PTR_CAST(ViewShellHint,&rHint)); - switch (rViewShellHint.GetHintId()) - { - case ViewShellHint::HINT_PAGE_RESIZE_START: - // Initiate a model change but do nothing (well, not much) - // until we are told that all slides have been resized. - mpModelChangeLock.reset(new SlideSorterController::ModelChangeLock(mrController)); - mrController.HandleModelChange(); - break; - - case ViewShellHint::HINT_PAGE_RESIZE_END: - // All slides have been resized. The model has to be updated. - mpModelChangeLock.reset(); - break; - - case ViewShellHint::HINT_CHANGE_EDIT_MODE_START: - mrController.PrepareEditModeChange(); - break; - - case ViewShellHint::HINT_CHANGE_EDIT_MODE_END: - mrController.FinishEditModeChange(); - break; - - case ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START: - mpModelChangeLock.reset(new SlideSorterController::ModelChangeLock(mrController)); - break; - - case ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END: - mpModelChangeLock.reset(); - break; - } - } - else if (rHint.ISA(SfxSimpleHint)) - { - SfxSimpleHint& rSfxSimpleHint (*PTR_CAST(SfxSimpleHint,&rHint)); - switch (rSfxSimpleHint.GetId()) - { - case SFX_HINT_DOCCHANGED: - mrController.CheckForMasterPageAssignment(); - break; - } - } -} - - - - -IMPL_LINK(Listener, EventMultiplexerCallback, ::sd::tools::EventMultiplexerEvent*, pEvent) -{ - switch (pEvent->meEventId) - { - case tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED: - { - if (mpBase != NULL) - { - ViewShell* pMainViewShell = mpBase->GetMainViewShell().get(); - if (pMainViewShell != NULL) - EndListening(*pMainViewShell); - } - } - break; - - - case tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED: - mbIsMainViewChangePending = true; - break; - - case tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED: - if (mbIsMainViewChangePending && mpBase != NULL) - { - mbIsMainViewChangePending = false; - ViewShell* pMainViewShell = mpBase->GetMainViewShell().get(); - if (pMainViewShell != NULL - && pMainViewShell!=mrSlideSorter.GetViewShell()) - { - StartListening (*pMainViewShell); - } - } - break; - - case tools::EventMultiplexerEvent::EID_CONTROLLER_ATTACHED: - { - ConnectToController(); - // mrController.GetPageSelector().GetCoreSelection(); - UpdateEditMode(); - } - break; - - - case tools::EventMultiplexerEvent::EID_CONTROLLER_DETACHED: - DisconnectFromController(); - break; - - case tools::EventMultiplexerEvent::EID_SHAPE_CHANGED: - case tools::EventMultiplexerEvent::EID_SHAPE_INSERTED: - case tools::EventMultiplexerEvent::EID_SHAPE_REMOVED: - HandleShapeModification(static_cast<const SdrPage*>(pEvent->mpUserData)); - break; - - default: - break; - } - - return 0; -} - - - - -//===== lang::XEventListener ================================================ - -void SAL_CALL Listener::disposing ( - const lang::EventObject& rEventObject) - throw (RuntimeException) -{ - if ((mbListeningToDocument || mbListeningToUNODocument) - && mrSlideSorter.GetModel().GetDocument()!=NULL - && rEventObject.Source - == mrSlideSorter.GetModel().GetDocument()->getUnoModel()) - { - mbListeningToDocument = false; - mbListeningToUNODocument = false; - } - else if (mbListeningToController) - { - Reference<frame::XController> xController (mxControllerWeak); - if (rEventObject.Source == xController) - { - mbListeningToController = false; - } - } -} - - - - -//===== document::XEventListener ============================================ - -void SAL_CALL Listener::notifyEvent ( - const document::EventObject& ) - throw (RuntimeException) -{ -} - - - - -//===== beans::XPropertySetListener ========================================= - -void SAL_CALL Listener::propertyChange ( - const PropertyChangeEvent& rEvent) - throw (RuntimeException) -{ - ThrowIfDisposed(); - - static const ::rtl::OUString sCurrentPagePropertyName ( - RTL_CONSTASCII_USTRINGPARAM("CurrentPage")); - static const ::rtl::OUString sEditModePropertyName ( - RTL_CONSTASCII_USTRINGPARAM("IsMasterPageMode")); - - if (rEvent.PropertyName.equals(sCurrentPagePropertyName)) - { - Any aCurrentPage = rEvent.NewValue; - Reference<beans::XPropertySet> xPageSet (aCurrentPage, UNO_QUERY); - if (xPageSet.is()) - { - try - { - Any aPageNumber = xPageSet->getPropertyValue ( - String(RTL_CONSTASCII_USTRINGPARAM("Number"))); - sal_Int32 nCurrentPage = 0; - aPageNumber >>= nCurrentPage; - mrController.GetPageSelector().GetCoreSelection(); - // The selection is already set but we call SelectPage() - // nevertheless in order to make the new current page the - // last recently selected page of the PageSelector. This is - // used when making the selection visible. - mrController.GetPageSelector().SelectPage(nCurrentPage-1); - mrController.GetCurrentSlideManager()->NotifyCurrentSlideChange(nCurrentPage-1); - } - catch (beans::UnknownPropertyException&) - { - DBG_UNHANDLED_EXCEPTION(); - } - catch (lang::DisposedException&) - { - // Something is already disposed. There is not much we can - // do, except not to crash. - } - } - } - else if (rEvent.PropertyName.equals (sEditModePropertyName)) - { - sal_Bool bIsMasterPageMode = sal_False; - rEvent.NewValue >>= bIsMasterPageMode; - mrController.ChangeEditMode ( - bIsMasterPageMode ? EM_MASTERPAGE : EM_PAGE); - } -} - - - - -//===== frame::XFrameActionListener ========================================== - -void SAL_CALL Listener::frameAction (const frame::FrameActionEvent& rEvent) - throw (::com::sun::star::uno::RuntimeException) -{ - switch (rEvent.Action) - { - case frame::FrameAction_COMPONENT_DETACHING: - DisconnectFromController(); - break; - - case frame::FrameAction_COMPONENT_REATTACHED: - { - ConnectToController(); - mrController.GetPageSelector().GetCoreSelection(); - UpdateEditMode(); - } - break; - - default: - break; - } -} - - - - -//===== accessibility::XAccessibleEventListener ============================== - -void SAL_CALL Listener::notifyEvent ( - const AccessibleEventObject& ) - throw (RuntimeException) -{ -} - - - - -void SAL_CALL Listener::disposing (void) -{ - ReleaseListeners(); -} - - - - -void Listener::UpdateEditMode (void) -{ - // When there is a new controller then the edit mode may have changed at - // the same time. - Reference<frame::XController> xController (mxControllerWeak); - Reference<beans::XPropertySet> xSet (xController, UNO_QUERY); - bool bIsMasterPageMode = false; - if (xSet != NULL) - { - try - { - Any aValue (xSet->getPropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsMasterPageMode")))); - aValue >>= bIsMasterPageMode; - } - catch (beans::UnknownPropertyException&) - { - // When the property is not supported then the master page mode - // is not supported, too. - bIsMasterPageMode = false; - } - } - mrController.ChangeEditMode ( - bIsMasterPageMode ? EM_MASTERPAGE : EM_PAGE); -} - - - -void Listener::HandleModelChange (const SdrPage* pPage) -{ - // Notify model and selection observer about the page. The return value - // of the model call acts as filter as to which events to pass to the - // selection observer. - if (mrSlideSorter.GetModel().NotifyPageEvent(pPage)) - { - // The page of the hint belongs (or belonged) to the model. - - // Tell the cache manager that the preview bitmaps for a deleted - // page can be removed from all caches. - if (pPage!=NULL && ! pPage->IsInserted()) - cache::PageCacheManager::Instance()->ReleasePreviewBitmap(pPage); - - mrController.GetSelectionManager()->GetSelectionObserver()->NotifyPageEvent(pPage); - } - - // Tell the controller about the model change only when the document is - // in a sane state, not just in the middle of a larger change. - SdDrawDocument* pDocument (mrSlideSorter.GetModel().GetDocument()); - if (pDocument != NULL - && pDocument->GetMasterSdPageCount(PK_STANDARD) == pDocument->GetMasterSdPageCount(PK_NOTES)) - { - // A model change can make updates of some text fields necessary - // (like page numbers and page count.) Invalidate all previews in - // the cache to cope with this. Doing this on demand would be a - // nice optimization. - cache::PageCacheManager::Instance()->InvalidateAllPreviewBitmaps(pDocument->getUnoModel()); - - mrController.HandleModelChange(); - } -} - - - -void Listener::HandleShapeModification (const SdrPage* pPage) -{ - if (pPage == NULL) - return; - - // Invalidate the preview of the page (in all slide sorters that display - // it.) - ::boost::shared_ptr<cache::PageCacheManager> pCacheManager (cache::PageCacheManager::Instance()); - if ( ! pCacheManager) - return; - SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument(); - if (pDocument == NULL) - { - OSL_ASSERT(pDocument!=NULL); - return; - } - pCacheManager->InvalidatePreviewBitmap(pDocument->getUnoModel(), pPage); - mrSlideSorter.GetView().GetPreviewCache()->RequestPreviewBitmap(pPage); - - // When the page is a master page then invalidate the previews of all - // pages that are linked to this master page. - if (pPage->IsMasterPage()) - { - for (sal_uInt16 nIndex=0,nCount=pDocument->GetSdPageCount(PK_STANDARD); - nIndex<nCount; - ++nIndex) - { - const SdPage* pCandidate = pDocument->GetSdPage(nIndex, PK_STANDARD); - if (pCandidate!=NULL && pCandidate->TRG_HasMasterPage()) - { - if (&pCandidate->TRG_GetMasterPage() == pPage) - pCacheManager->InvalidatePreviewBitmap(pDocument->getUnoModel(), pCandidate); - } - else - { - OSL_ASSERT(pCandidate!=NULL && pCandidate->TRG_HasMasterPage()); - } - } - } -} - - - - -void Listener::ThrowIfDisposed (void) - throw (::com::sun::star::lang::DisposedException) -{ - if (rBHelper.bDisposed || rBHelper.bInDispose) - { - throw lang::DisposedException ( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "SlideSorterController object has already been disposed")), - static_cast<uno::XWeak*>(this)); - } -} - - - - -} } } // end of namespace ::sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsListener.hxx b/sd/source/ui/slidesorter/controller/SlsListener.hxx deleted file mode 100644 index 28248c291..000000000 --- a/sd/source/ui/slidesorter/controller/SlsListener.hxx +++ /dev/null @@ -1,197 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_SLIDESORTER_SLIDE_SORTER_LISTENER_HXX -#define SD_SLIDESORTER_SLIDE_SORTER_LISTENER_HXX - -#include "MutexOwner.hxx" -#include "controller/SlideSorterController.hxx" -#include <com/sun/star/document/XEventListener.hpp> -#include <com/sun/star/beans/XPropertyChangeListener.hpp> -#include <com/sun/star/accessibility/XAccessibleEventListener.hpp> -#include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/frame/XFrameActionListener.hpp> -#include <cppuhelper/compbase4.hxx> - -#include <svl/lstner.hxx> -#include <tools/link.hxx> -#include <boost/shared_ptr.hpp> - -namespace sd { -class ViewShellBase; -} - -namespace sd { namespace tools { -class EventMultiplexerEvent; -} } - -namespace sd { namespace slidesorter { -class SlideSorter; -} } - - -namespace sd { namespace slidesorter { namespace controller { - -typedef cppu::WeakComponentImplHelper4< - ::com::sun::star::document::XEventListener, - ::com::sun::star::beans::XPropertyChangeListener, - ::com::sun::star::accessibility::XAccessibleEventListener, - ::com::sun::star::frame::XFrameActionListener - > ListenerInterfaceBase; - -class SlideSorterController; - -/** Listen for events of various types and sources and react to them. This - class is a part of the controller. - - When the view shell in the center pane is replaced by another the - associated controller is replaced as well. Therefore we have to - register at the frame and on certain FrameActionEvents to stop listening - to the old controller and register as listener at the new one. -*/ -class Listener - : protected MutexOwner, - public ListenerInterfaceBase, - public SfxListener -{ -public: - Listener (SlideSorter& rSlideSorter); - virtual ~Listener (void); - - /** Connect to the current controller of the view shell as listener. - This method is called once during initialization and every time a - FrameActionEvent signals the current controller being exchanged. - When the connection is successfull then the flag - mbListeningToController is set to <TRUE/>. - */ - void ConnectToController (void); - - /** Disconnect from the current controller of the view shell as - listener. This method is called once during initialization and - every time a FrameActionEvent signals the current controller being - exchanged. When this method terminates then mbListeningToController - is <FALSE/>. - */ - void DisconnectFromController (void); - - virtual void Notify ( - SfxBroadcaster& rBroadcaster, - const SfxHint& rHint); - - //===== lang::XEventListener ============================================ - virtual void SAL_CALL - disposing (const ::com::sun::star::lang::EventObject& rEventObject) - throw (::com::sun::star::uno::RuntimeException); - - - //===== document::XEventListener ======================================== - virtual void SAL_CALL - notifyEvent ( - const ::com::sun::star::document::EventObject& rEventObject) - throw (::com::sun::star::uno::RuntimeException); - - //===== beans::XPropertySetListener ===================================== - virtual void SAL_CALL - propertyChange ( - const com::sun::star::beans::PropertyChangeEvent& rEvent) - throw (::com::sun::star::uno::RuntimeException); - - //===== accessibility::XAccessibleEventListener ========================== - virtual void SAL_CALL - notifyEvent ( - const ::com::sun::star::accessibility::AccessibleEventObject& - rEvent) - throw (::com::sun::star::uno::RuntimeException); - - //===== frame::XFrameActionListener ====================================== - /** For certain actions the listener connects to a new controller of the - frame it is listening to. This usually happens when the view shell - in the center pane is replaced by another view shell. - */ - virtual void SAL_CALL - frameAction (const ::com::sun::star::frame::FrameActionEvent& rEvent) - throw (::com::sun::star::uno::RuntimeException); - - virtual void SAL_CALL disposing (void); - -private: - SlideSorter& mrSlideSorter; - SlideSorterController& mrController; - ViewShellBase* mpBase; - - /// Remember whether we are listening to the document. - bool mbListeningToDocument; - /// Remember whether we are listening to the UNO document. - bool mbListeningToUNODocument; - /// Remember whether we are listening to the UNO controller. - bool mbListeningToController; - /// Remember whether we are listening to the frame. - bool mbListeningToFrame; - bool mbIsMainViewChangePending; - - ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XController> mxControllerWeak; - ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XFrame> mxFrameWeak; - - /** This object is used to lock the model between some - events. It is refernce counted in order to cope with events that - are expected but never sent. - */ - ::boost::shared_ptr<SlideSorterController::ModelChangeLock> mpModelChangeLock; - - void ReleaseListeners (void); - - /** Called when the edit mode has changed. Update model accordingly. - */ - void UpdateEditMode (void); - - /** Handle a change in the order of slides or when the set of slides has - changed, i.e. a slide has been created. - */ - void HandleModelChange (const SdrPage* pPage); - - /** Handle a modification to a shape on the given page. When this is a - regular page then update its preview. When it is a master page then - additionally update the previews of all pages linked to it. - */ - void HandleShapeModification (const SdrPage* pPage); - - /** This method throws a DisposedException when the object has already been - disposed. - */ - void ThrowIfDisposed (void) - throw (::com::sun::star::lang::DisposedException); - - DECL_LINK(EventMultiplexerCallback, tools::EventMultiplexerEvent*); -}; - -} } } // end of namespace ::sd::slidesorter::controller - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsPageObjectFactory.cxx b/sd/source/ui/slidesorter/controller/SlsPageObjectFactory.cxx deleted file mode 100644 index 7e49d884b..000000000 --- a/sd/source/ui/slidesorter/controller/SlsPageObjectFactory.cxx +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "controller/SlsPageObjectFactory.hxx" - -#include "view/SlsPageObject.hxx" -#include "view/SlsPageObjectViewContact.hxx" -#include "view/SlsPageObjectViewObjectContact.hxx" - -#include "sdpage.hxx" - - -namespace sd { namespace slidesorter { namespace controller { - - -PageObjectFactory::PageObjectFactory ( - const ::boost::shared_ptr<cache::PageCache>& rpCache, - const ::boost::shared_ptr<controller::Properties>& rpProperties) - : mpPageCache(rpCache), - mpProperties(rpProperties) -{ -} - - - - -PageObjectFactory::~PageObjectFactory (void) -{ -} - - - - -view::PageObject* PageObjectFactory::CreatePageObject ( - SdPage* pPage, - const model::SharedPageDescriptor& rpDescriptor) const -{ - return new view::PageObject( - Rectangle (Point(0,0), pPage->GetSize()), - pPage, - rpDescriptor); -} - - - - -::sdr::contact::ViewContact* - PageObjectFactory::CreateViewContact ( - view::PageObject* pPageObject, - const model::SharedPageDescriptor& rpDescriptor) const -{ - return new view::PageObjectViewContact ( - *pPageObject, - rpDescriptor); -} - - - - -::sdr::contact::ViewObjectContact* - PageObjectFactory::CreateViewObjectContact ( - ::sdr::contact::ObjectContact& rObjectContact, - ::sdr::contact::ViewContact& rViewContact) const -{ - return new view::PageObjectViewObjectContact ( - rObjectContact, - rViewContact, - mpPageCache, - mpProperties); -} - - -} } } // end of namespace ::sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx b/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx deleted file mode 100644 index a9545b089..000000000 --- a/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx +++ /dev/null @@ -1,491 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "controller/SlsPageSelector.hxx" - -#include "SlideSorter.hxx" -#include "SlideSorterViewShell.hxx" -#include "controller/SlideSorterController.hxx" -#include "controller/SlsSelectionManager.hxx" -#include "controller/SlsAnimator.hxx" -#include "controller/SlsCurrentSlideManager.hxx" -#include "controller/SlsVisibleAreaManager.hxx" -#include "model/SlsPageDescriptor.hxx" -#include "model/SlsPageEnumerationProvider.hxx" -#include "model/SlideSorterModel.hxx" -#include "view/SlideSorterView.hxx" - -#include "sdpage.hxx" -#include "ViewShell.hxx" -#include "DrawViewShell.hxx" -#include "ViewShellBase.hxx" -#include <com/sun/star/drawing/XDrawView.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <boost/bind.hpp> - - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::sd::slidesorter::model; -using namespace ::sd::slidesorter::view; - - -namespace sd { namespace slidesorter { namespace controller { - -PageSelector::PageSelector (SlideSorter& rSlideSorter) - : mrModel(rSlideSorter.GetModel()), - mrSlideSorter(rSlideSorter), - mrController(mrSlideSorter.GetController()), - mnSelectedPageCount(0), - mnBroadcastDisableLevel(0), - mbSelectionChangeBroadcastPending(false), - mpMostRecentlySelectedPage(), - mpSelectionAnchor(), - mpCurrentPage(), - mnUpdateLockCount(0), - mbIsUpdateCurrentPagePending(false) -{ - CountSelectedPages (); -} - - - - -void PageSelector::SelectAllPages (void) -{ - VisibleAreaManager::TemporaryDisabler aDisabler (mrSlideSorter); - PageSelector::UpdateLock aLock (*this); - - int nPageCount = mrModel.GetPageCount(); - for (int nPageIndex=0; nPageIndex<nPageCount; nPageIndex++) - SelectPage(nPageIndex); -} - - - - -void PageSelector::DeselectAllPages (void) -{ - VisibleAreaManager::TemporaryDisabler aDisabler (mrSlideSorter); - PageSelector::UpdateLock aLock (*this); - - int nPageCount = mrModel.GetPageCount(); - for (int nPageIndex=0; nPageIndex<nPageCount; nPageIndex++) - DeselectPage(nPageIndex); - - DBG_ASSERT (mnSelectedPageCount==0, - "PageSelector::DeselectAllPages: the selected pages counter is not 0"); - mnSelectedPageCount = 0; - mpSelectionAnchor.reset(); -} - - - - -void PageSelector::GetCoreSelection (void) -{ - PageSelector::UpdateLock aLock (*this); - - bool bSelectionHasChanged (true); - mnSelectedPageCount = 0; - model::PageEnumeration aAllPages ( - model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel)); - while (aAllPages.HasMoreElements()) - { - model::SharedPageDescriptor pDescriptor (aAllPages.GetNextElement()); - if (pDescriptor->GetCoreSelection()) - { - mrSlideSorter.GetController().GetVisibleAreaManager().RequestVisible(pDescriptor); - mrSlideSorter.GetView().RequestRepaint(pDescriptor); - bSelectionHasChanged = true; - } - - if (pDescriptor->HasState(PageDescriptor::ST_Selected)) - mnSelectedPageCount++; - } - - if (bSelectionHasChanged) - { - if (mnBroadcastDisableLevel > 0) - mbSelectionChangeBroadcastPending = true; - else - mrController.GetSelectionManager()->SelectionHasChanged(); - } -} - - - - -void PageSelector::SetCoreSelection (void) -{ - model::PageEnumeration aAllPages ( - model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel)); - while (aAllPages.HasMoreElements()) - { - model::SharedPageDescriptor pDescriptor (aAllPages.GetNextElement()); - pDescriptor->SetCoreSelection(); - } -} - - - - -void PageSelector::SelectPage (int nPageIndex) -{ - SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nPageIndex)); - if (pDescriptor.get() != NULL) - SelectPage(pDescriptor); -} - - - - -void PageSelector::SelectPage (const SdPage* pPage) -{ - const sal_Int32 nPageIndex (mrModel.GetIndex(pPage)); - SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nPageIndex)); - if (pDescriptor.get()!=NULL && pDescriptor->GetPage()==pPage) - SelectPage(pDescriptor); -} - - - - -void PageSelector::SelectPage (const SharedPageDescriptor& rpDescriptor) -{ - if (rpDescriptor.get()!=NULL - && mrSlideSorter.GetView().SetState(rpDescriptor, PageDescriptor::ST_Selected, true)) - { - ++mnSelectedPageCount; - mrSlideSorter.GetController().GetVisibleAreaManager().RequestVisible(rpDescriptor,true); - mrSlideSorter.GetView().RequestRepaint(rpDescriptor); - - mpMostRecentlySelectedPage = rpDescriptor; - if (mpSelectionAnchor == NULL) - mpSelectionAnchor = rpDescriptor; - - if (mnBroadcastDisableLevel > 0) - mbSelectionChangeBroadcastPending = true; - else - mrController.GetSelectionManager()->SelectionHasChanged(); - UpdateCurrentPage(); - - CheckConsistency(); - } -} - - - - -void PageSelector::DeselectPage ( - int nPageIndex, - const bool bUpdateCurrentPage) -{ - model::SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nPageIndex)); - if (pDescriptor.get() != NULL) - DeselectPage(pDescriptor, bUpdateCurrentPage); -} - - - - -void PageSelector::DeselectPage ( - const SdPage* pPage, - const bool bUpdateCurrentPage) -{ - const sal_Int32 nPageIndex (mrModel.GetIndex(pPage)); - SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nPageIndex)); - if (pDescriptor.get()!=NULL && pDescriptor->GetPage()==pPage) - DeselectPage(pDescriptor, bUpdateCurrentPage); -} - - - - -void PageSelector::DeselectPage ( - const SharedPageDescriptor& rpDescriptor, - const bool bUpdateCurrentPage) -{ - if (rpDescriptor.get()!=NULL - && mrSlideSorter.GetView().SetState(rpDescriptor, PageDescriptor::ST_Selected, false)) - { - --mnSelectedPageCount; - mrSlideSorter.GetController().GetVisibleAreaManager().RequestVisible(rpDescriptor); - mrSlideSorter.GetView().RequestRepaint(rpDescriptor); - if (mpMostRecentlySelectedPage == rpDescriptor) - mpMostRecentlySelectedPage.reset(); - if (mnBroadcastDisableLevel > 0) - mbSelectionChangeBroadcastPending = true; - else - mrController.GetSelectionManager()->SelectionHasChanged(); - if (bUpdateCurrentPage) - UpdateCurrentPage(); - - CheckConsistency(); - } -} - - - - -void PageSelector::CheckConsistency (void) const -{ - int nSelectionCount (0); - for (int nPageIndex=0,nPageCount=mrModel.GetPageCount(); nPageIndex<nPageCount; nPageIndex++) - { - SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nPageIndex)); - assert(pDescriptor); - if (pDescriptor->HasState(PageDescriptor::ST_Selected)) - ++nSelectionCount; - } - if (nSelectionCount!=mnSelectedPageCount) - { - assert(nSelectionCount==mnSelectedPageCount); - } -} - - - - -bool PageSelector::IsPageSelected (int nPageIndex) -{ - SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nPageIndex)); - if (pDescriptor.get() != NULL) - return pDescriptor->HasState(PageDescriptor::ST_Selected); - else - return false; -} - - - - -int PageSelector::GetPageCount (void) const -{ - return mrModel.GetPageCount(); -} - - - - -int PageSelector::GetSelectedPageCount (void) const -{ - return mnSelectedPageCount; -} - - - - -SharedPageDescriptor PageSelector::GetSelectionAnchor (void) const -{ - return mpSelectionAnchor; -} - - - - -void PageSelector::CountSelectedPages (void) -{ - mnSelectedPageCount = 0; - model::PageEnumeration aSelectedPages ( - model::PageEnumerationProvider::CreateSelectedPagesEnumeration(mrModel)); - while (aSelectedPages.HasMoreElements()) - { - mnSelectedPageCount++; - aSelectedPages.GetNextElement(); - } -} - - - - -void PageSelector::EnableBroadcasting (void) -{ - if (mnBroadcastDisableLevel > 0) - mnBroadcastDisableLevel --; - if (mnBroadcastDisableLevel==0 && mbSelectionChangeBroadcastPending) - { - mrController.GetSelectionManager()->SelectionHasChanged(); - mbSelectionChangeBroadcastPending = false; - } -} - - - - -void PageSelector::DisableBroadcasting (void) -{ - mnBroadcastDisableLevel ++; -} - - - - -::boost::shared_ptr<PageSelector::PageSelection> PageSelector::GetPageSelection (void) const -{ - ::boost::shared_ptr<PageSelection> pSelection (new PageSelection()); - pSelection->reserve(GetSelectedPageCount()); - - int nPageCount = GetPageCount(); - for (int nIndex=0; nIndex<nPageCount; nIndex++) - { - SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nIndex)); - if (pDescriptor.get()!=NULL && pDescriptor->HasState(PageDescriptor::ST_Selected)) - pSelection->push_back(pDescriptor->GetPage()); - } - - return pSelection; -} - - - - -void PageSelector::SetPageSelection ( - const ::boost::shared_ptr<PageSelection>& rpSelection, - const bool bUpdateCurrentPage) -{ - PageSelection::const_iterator iPage; - for (iPage=rpSelection->begin(); iPage!=rpSelection->end(); ++iPage) - SelectPage(*iPage); - if (bUpdateCurrentPage) - UpdateCurrentPage(); -} - - - - -void PageSelector::UpdateCurrentPage (const bool bUpdateOnlyWhenPending) -{ - if (mnUpdateLockCount > 0) - { - mbIsUpdateCurrentPagePending = true; - return; - } - - if ( ! mbIsUpdateCurrentPagePending && bUpdateOnlyWhenPending) - return; - - mbIsUpdateCurrentPagePending = false; - - // Make the first selected page the current page. - const sal_Int32 nPageCount (GetPageCount()); - for (sal_Int32 nIndex=0; nIndex<nPageCount; ++nIndex) - { - SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nIndex)); - if (pDescriptor && pDescriptor->HasState(PageDescriptor::ST_Selected)) - { - // Switching the current slide normally sets also the selection - // to just the new current slide. To prevent that, we store - // (and at the end of this scope restore) the current selection. - ::boost::shared_ptr<PageSelection> pSelection (GetPageSelection()); - - mrController.GetCurrentSlideManager()->SwitchCurrentSlide(pDescriptor); - - // Restore the selection and prevent a recursive call to - // UpdateCurrentPage(). - SetPageSelection(pSelection, false); - return; - } - } - - // No page is selected. Do not change the current slide. -} - - - - -//===== PageSelector::UpdateLock ============================================== - -PageSelector::UpdateLock::UpdateLock (SlideSorter& rSlideSorter) - : mpSelector(&rSlideSorter.GetController().GetPageSelector()) -{ - ++mpSelector->mnUpdateLockCount; -} - - - - -PageSelector::UpdateLock::UpdateLock (PageSelector& rSelector) - : mpSelector(&rSelector) -{ - ++mpSelector->mnUpdateLockCount; -} - - - - -PageSelector::UpdateLock::~UpdateLock (void) -{ - Release(); -} - -void PageSelector::UpdateLock::Release (void) -{ - if (mpSelector != NULL) - { - --mpSelector->mnUpdateLockCount; - OSL_ASSERT(mpSelector->mnUpdateLockCount >= 0); - if (mpSelector->mnUpdateLockCount == 0) - mpSelector->UpdateCurrentPage(true); - - mpSelector = NULL; - } -} - - - - -//===== PageSelector::BroadcastLock ============================================== - -PageSelector::BroadcastLock::BroadcastLock (SlideSorter& rSlideSorter) - : mrSelector(rSlideSorter.GetController().GetPageSelector()) -{ - mrSelector.DisableBroadcasting(); -} - - - - -PageSelector::BroadcastLock::BroadcastLock (PageSelector& rSelector) - : mrSelector(rSelector) -{ - mrSelector.DisableBroadcasting(); -} - - - - -PageSelector::BroadcastLock::~BroadcastLock (void) -{ - mrSelector.EnableBroadcasting(); -} - -} } } // end of namespace ::sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsProperties.cxx b/sd/source/ui/slidesorter/controller/SlsProperties.cxx deleted file mode 100644 index fef6b6eb1..000000000 --- a/sd/source/ui/slidesorter/controller/SlsProperties.cxx +++ /dev/null @@ -1,276 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "controller/SlsProperties.hxx" -#include <vcl/svapp.hxx> - -namespace sd { namespace slidesorter { namespace controller { - -Properties::Properties (void) - : mbIsHighlightCurrentSlide(false), - mbIsShowSelection(true), - mbIsShowFocus(true), - mbIsCenterSelection(false), - mbIsSmoothSelectionScrolling(true), - mbIsSuspendPreviewUpdatesDuringFullScreenPresentation(true), - maBackgroundColor(Application::GetSettings().GetStyleSettings().GetWindowColor()), - maTextColor(Application::GetSettings().GetStyleSettings().GetActiveTextColor()), - maSelectionColor(Application::GetSettings().GetStyleSettings().GetHighlightColor()), - maHighlightColor(Application::GetSettings().GetStyleSettings().GetMenuHighlightColor()), - mbIsUIReadOnly(false), - mbIsOnlyPreviewTriggersMouseOver(true), - mbIsHighContrastModeActive( - Application::GetSettings().GetStyleSettings().GetHighContrastMode()) -{ -} - - - - -Properties::~Properties (void) -{ -} - - - - -void Properties::HandleDataChangeEvent (void) -{ - maBackgroundColor = Application::GetSettings().GetStyleSettings().GetWindowColor(); - maTextColor = Application::GetSettings().GetStyleSettings().GetActiveTextColor(); - maSelectionColor = Application::GetSettings().GetStyleSettings().GetHighlightColor(); - maHighlightColor = Application::GetSettings().GetStyleSettings().GetMenuHighlightColor(); - mbIsHighContrastModeActive - = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); -} - - - - -bool Properties::IsHighlightCurrentSlide (void) const -{ - return mbIsHighlightCurrentSlide; -} - - - - -void Properties::SetHighlightCurrentSlide (const bool bIsHighlightCurrentSlide) -{ - mbIsHighlightCurrentSlide = bIsHighlightCurrentSlide; -} - - - - -bool Properties::IsShowSelection (void) const -{ - return mbIsShowSelection; -} - - - - -void Properties::SetShowSelection (const bool bIsShowSelection) -{ - mbIsShowSelection = bIsShowSelection; -} - - - - -bool Properties::IsShowFocus (void) const -{ - return mbIsShowFocus; -} - - - - -void Properties::SetShowFocus (const bool bIsShowFocus) -{ - mbIsShowFocus = bIsShowFocus; -} - - - - -bool Properties::IsCenterSelection (void) const -{ - return mbIsCenterSelection; -} - - - - -void Properties::SetCenterSelection (const bool bIsCenterSelection) -{ - mbIsCenterSelection = bIsCenterSelection; -} - - - - -bool Properties::IsSmoothSelectionScrolling (void) const -{ - return mbIsSmoothSelectionScrolling; -} - - - - -void Properties::SetSmoothSelectionScrolling (const bool bIsSmoothSelectionScrolling) -{ - mbIsSmoothSelectionScrolling = bIsSmoothSelectionScrolling; -} - - - - -bool Properties::IsSuspendPreviewUpdatesDuringFullScreenPresentation (void) const -{ - return mbIsSuspendPreviewUpdatesDuringFullScreenPresentation; -} - - - - -void Properties::SetSuspendPreviewUpdatesDuringFullScreenPresentation (const bool bFlag) -{ - mbIsSuspendPreviewUpdatesDuringFullScreenPresentation = bFlag; -} - - - - -Color Properties::GetBackgroundColor (void) const -{ - return maBackgroundColor; -} - - - - -void Properties::SetBackgroundColor (const Color& rColor) -{ - maBackgroundColor = rColor; -} - - - -Color Properties::GetTextColor (void) const -{ - return maTextColor; -} - - - - -void Properties::SetTextColor (const Color& rColor) -{ - maTextColor = rColor; -} - - - - -Color Properties::GetSelectionColor (void) const -{ - return maSelectionColor; -} - - - - -void Properties::SetSelectionColor (const Color& rColor) -{ - maSelectionColor = rColor; -} - - - - -Color Properties::GetHighlightColor (void) const -{ - return maHighlightColor; -} - - - - -void Properties::SetHighlightColor (const Color& rColor) -{ - maHighlightColor = rColor; -} - - - - -bool Properties::IsUIReadOnly (void) const -{ - return mbIsUIReadOnly; -} - - - - -void Properties::SetUIReadOnly (const bool bIsUIReadOnly) -{ - mbIsUIReadOnly = bIsUIReadOnly; -} - - - - -bool Properties::IsOnlyPreviewTriggersMouseOver (void) const -{ - return mbIsOnlyPreviewTriggersMouseOver; -} - - - - -void Properties::SetOnlyPreviewTriggersMouseOver (const bool bFlag) -{ - mbIsOnlyPreviewTriggersMouseOver = bFlag; -} - - - - -bool Properties::IsHighContrastModeActive (void) const -{ - return mbIsHighContrastModeActive; -} - - -} } } // end of namespace ::sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx b/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx deleted file mode 100644 index 2d1cba5ce..000000000 --- a/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx +++ /dev/null @@ -1,740 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "controller/SlsScrollBarManager.hxx" - -#include "SlideSorter.hxx" -#include "controller/SlideSorterController.hxx" -#include "controller/SlsVisibleAreaManager.hxx" -#include "model/SlideSorterModel.hxx" -#include "model/SlsPageDescriptor.hxx" -#include "view/SlideSorterView.hxx" -#include "view/SlsLayouter.hxx" -#include "view/SlsTheme.hxx" -#include "Window.hxx" -#include "sdpage.hxx" - -#include <boost/limits.hpp> - -#include <vcl/scrbar.hxx> - -namespace sd { namespace slidesorter { namespace controller { - -ScrollBarManager::ScrollBarManager (SlideSorter& rSlideSorter) - : mrSlideSorter(rSlideSorter), - mpHorizontalScrollBar(mrSlideSorter.GetHorizontalScrollBar()), - mpVerticalScrollBar(mrSlideSorter.GetVerticalScrollBar()), - mnHorizontalPosition (0), - mnVerticalPosition (0), - maScrollBorder (20,20), - mnHorizontalScrollFactor (0.15), - mnVerticalScrollFactor (0.25), - mpScrollBarFiller(mrSlideSorter.GetScrollBarFiller()), - maAutoScrollTimer(), - maAutoScrollOffset(0,0), - mbIsAutoScrollActive(false), - mpContentWindow(mrSlideSorter.GetContentWindow()), - maAutoScrollFunctor() -{ - // Hide the scroll bars by default to prevent display errors while - // switching between view shells: In the short time between initiating - // such a switch and the final rearrangement of UI controls the scroll - // bars and the filler where displayed in the upper left corner of the - // ViewTabBar. - mpHorizontalScrollBar->Hide(); - mpVerticalScrollBar->Hide(); - mpScrollBarFiller->Hide(); - - maAutoScrollTimer.SetTimeout(25); - maAutoScrollTimer.SetTimeoutHdl ( - LINK(this, ScrollBarManager, AutoScrollTimeoutHandler)); -} - - - - -ScrollBarManager::~ScrollBarManager (void) -{ -} - - - - -void ScrollBarManager::LateInitialization (void) -{ -} - - - - -void ScrollBarManager::Connect (void) -{ - if (mpVerticalScrollBar != NULL) - { - mpVerticalScrollBar->SetScrollHdl ( - LINK(this, ScrollBarManager, VerticalScrollBarHandler)); - } - if (mpHorizontalScrollBar != NULL) - { - mpHorizontalScrollBar->SetScrollHdl( - LINK(this, ScrollBarManager, HorizontalScrollBarHandler)); - } -} - - - - -void ScrollBarManager::Disconnect (void) -{ - if (mpVerticalScrollBar != NULL) - { - mpVerticalScrollBar->SetScrollHdl (Link()); - } - if (mpHorizontalScrollBar != NULL) - { - mpHorizontalScrollBar->SetScrollHdl (Link()); - } -} - - - - -/** Placing the scroll bars is an iterative process. The visibility of one - scroll bar affects the remaining size and thus may lead to the other - scroll bar becoming visible. - - First we determine the visibility of the horizontal scroll bar. After - that we do the same for the vertical scroll bar. To have an initial - value for the required size we call the layouter before that. When one - of the two scroll bars is made visible then the size of the browser - window changes and a second call to the layouter becomes necessary. - That call is made anyway after this method returns. -*/ -Rectangle ScrollBarManager::PlaceScrollBars ( - const Rectangle& rAvailableArea, - const bool bIsHorizontalScrollBarAllowed, - const bool bIsVerticalScrollBarAllowed) -{ - Rectangle aRemainingSpace (DetermineScrollBarVisibilities( - rAvailableArea, - bIsHorizontalScrollBarAllowed, - bIsVerticalScrollBarAllowed)); - - if (mpHorizontalScrollBar!=NULL && mpHorizontalScrollBar->IsVisible()) - PlaceHorizontalScrollBar (rAvailableArea); - - if (mpVerticalScrollBar!=NULL && mpVerticalScrollBar->IsVisible()) - PlaceVerticalScrollBar (rAvailableArea); - - if (mpScrollBarFiller!=NULL && mpScrollBarFiller->IsVisible()) - PlaceFiller (rAvailableArea); - - return aRemainingSpace; -} - - - - -void ScrollBarManager::PlaceHorizontalScrollBar (const Rectangle& aAvailableArea) -{ - // Save the current relative position. - mnHorizontalPosition = double(mpHorizontalScrollBar->GetThumbPos()) - / double(mpHorizontalScrollBar->GetRange().Len()); - - // Place the scroll bar. - Size aScrollBarSize (mpHorizontalScrollBar->GetSizePixel()); - mpHorizontalScrollBar->SetPosSizePixel ( - Point(aAvailableArea.Left(), - aAvailableArea.Bottom()-aScrollBarSize.Height()+1), - Size (aAvailableArea.GetWidth() - GetVerticalScrollBarWidth(), - aScrollBarSize.Height())); - - // Restore the relative position. - mpHorizontalScrollBar->SetThumbPos( - (long)(0.5 + mnHorizontalPosition * mpHorizontalScrollBar->GetRange().Len())); -} - - - - -void ScrollBarManager::PlaceVerticalScrollBar (const Rectangle& aArea) -{ - const double nThumbPosition (mpVerticalScrollBar->GetThumbPos()); - - // Place the scroll bar. - Size aScrollBarSize (mpVerticalScrollBar->GetSizePixel()); - Point aPosition (aArea.Right()-aScrollBarSize.Width()+1, aArea.Top()); - Size aSize (aScrollBarSize.Width(), aArea.GetHeight() - GetHorizontalScrollBarHeight()); - mpVerticalScrollBar->SetPosSizePixel(aPosition, aSize); - - // Restore the position. - mpVerticalScrollBar->SetThumbPos(static_cast<long>(nThumbPosition)); - mnVerticalPosition = nThumbPosition / double(mpVerticalScrollBar->GetRange().Len()); -} - - - - -void ScrollBarManager::PlaceFiller (const Rectangle& aArea) -{ - mpScrollBarFiller->SetPosSizePixel( - Point( - aArea.Right()-mpVerticalScrollBar->GetSizePixel().Width()+1, - aArea.Bottom()-mpHorizontalScrollBar->GetSizePixel().Height()+1), - Size ( - mpVerticalScrollBar->GetSizePixel().Width(), - mpHorizontalScrollBar->GetSizePixel().Height())); -} - - - - -void ScrollBarManager::UpdateScrollBars (bool bResetThumbPosition, bool bUseScrolling) -{ - Rectangle aModelArea (mrSlideSorter.GetView().GetModelArea()); - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - Size aWindowModelSize (pWindow->PixelToLogic(pWindow->GetSizePixel())); - - // The horizontal scroll bar is only shown when the window is - // horizontally smaller than the view. - if (mpHorizontalScrollBar != NULL && mpHorizontalScrollBar->IsVisible()) - { - mpHorizontalScrollBar->Show(); - mpHorizontalScrollBar->SetRange ( - Range(aModelArea.Left(), aModelArea.Right())); - if (bResetThumbPosition) - { - mpHorizontalScrollBar->SetThumbPos (0); - mnHorizontalPosition = 0; - } - else - mnHorizontalPosition = - double(mpHorizontalScrollBar->GetThumbPos()) - / double(mpHorizontalScrollBar->GetRange().Len()); - - mpHorizontalScrollBar->SetVisibleSize (aWindowModelSize.Width()); - - const long nWidth (mpContentWindow->PixelToLogic( - mpContentWindow->GetSizePixel()).Width()); - // Make the line size about 10% of the visible width. - mpHorizontalScrollBar->SetLineSize (nWidth / 10); - // Make the page size about 90% of the visible width. - mpHorizontalScrollBar->SetPageSize ((nWidth * 9) / 10); - } - else - { - mnHorizontalPosition = 0; - } - - // The vertical scroll bar is always shown. - if (mpVerticalScrollBar != NULL && mpVerticalScrollBar->IsVisible()) - { - mpVerticalScrollBar->SetRange ( - Range(aModelArea.Top(), aModelArea.Bottom())); - if (bResetThumbPosition) - { - mpVerticalScrollBar->SetThumbPos (0); - mnVerticalPosition = 0; - } - else - mnVerticalPosition = - double(mpVerticalScrollBar->GetThumbPos()) - / double(mpVerticalScrollBar->GetRange().Len()); - - mpVerticalScrollBar->SetVisibleSize (aWindowModelSize.Height()); - - const long nHeight (mpContentWindow->PixelToLogic( - mpContentWindow->GetSizePixel()).Height()); - // Make the line size about 10% of the visible height. - mpVerticalScrollBar->SetLineSize (nHeight / 10); - // Make the page size about 90% of the visible height. - mpVerticalScrollBar->SetPageSize ((nHeight * 9) / 10); - } - else - { - mnVerticalPosition = 0; - } - - - double nEps (::std::numeric_limits<double>::epsilon()); - if (fabs(mnHorizontalPosition-pWindow->GetVisibleX()) > nEps - || fabs(mnVerticalPosition-pWindow->GetVisibleY()) > nEps) - { - mrSlideSorter.GetView().InvalidatePageObjectVisibilities(); - if (bUseScrolling) - pWindow->SetVisibleXY(mnHorizontalPosition, mnVerticalPosition); - else - SetWindowOrigin(mnHorizontalPosition, mnVerticalPosition); - } -} - - - - -IMPL_LINK(ScrollBarManager, VerticalScrollBarHandler, ScrollBar*, pScrollBar) -{ - if (pScrollBar!=NULL - && pScrollBar==mpVerticalScrollBar.get() - && pScrollBar->IsVisible() - && mrSlideSorter.GetContentWindow()!=NULL) - { - double nRelativePosition = double(pScrollBar->GetThumbPos()) - / double(pScrollBar->GetRange().Len()); - mrSlideSorter.GetView().InvalidatePageObjectVisibilities(); - mrSlideSorter.GetContentWindow()->SetVisibleXY(-1, nRelativePosition); - mrSlideSorter.GetController().GetVisibleAreaManager().DeactivateCurrentSlideTracking(); - } - return sal_True; -} - - - - -IMPL_LINK(ScrollBarManager, HorizontalScrollBarHandler, ScrollBar*, pScrollBar) -{ - if (pScrollBar!=NULL - && pScrollBar==mpHorizontalScrollBar.get() - && pScrollBar->IsVisible() - && mrSlideSorter.GetContentWindow()!=NULL) - { - double nRelativePosition = double(pScrollBar->GetThumbPos()) - / double(pScrollBar->GetRange().Len()); - mrSlideSorter.GetView().InvalidatePageObjectVisibilities(); - mrSlideSorter.GetContentWindow()->SetVisibleXY(nRelativePosition, -1); - mrSlideSorter.GetController().GetVisibleAreaManager().DeactivateCurrentSlideTracking(); - } - return sal_True; -} - - - - -void ScrollBarManager::SetWindowOrigin ( - double nHorizontalPosition, - double nVerticalPosition) -{ - mnHorizontalPosition = nHorizontalPosition; - mnVerticalPosition = nVerticalPosition; - - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - Size aViewSize (pWindow->GetViewSize()); - Point aOrigin ( - (long int) (mnHorizontalPosition * aViewSize.Width()), - (long int) (mnVerticalPosition * aViewSize.Height())); - - pWindow->SetWinViewPos (aOrigin); - pWindow->UpdateMapMode (); - pWindow->Invalidate (); -} - - - - -/** Determining the visibility of the scroll bars is quite complicated. The - visibility of one influences that of the other because showing a scroll - bar makes the available space smaller and may lead to the need of - displaying the other. - To solve this we test all four combinations of showing or hiding each - scroll bar and use the best one. The best one is that combination that - a) shows the least number of scroll bars with preference of showing the - vertical over showing the horizontal and - b) when not showing a scroll bar the area used by the page objects fits - into the available area in the scroll bars orientation. -*/ -Rectangle ScrollBarManager::DetermineScrollBarVisibilities ( - const Rectangle& rAvailableArea, - const bool bIsHorizontalScrollBarAllowed, - const bool bIsVerticalScrollBarAllowed) -{ - // Test which combination of scroll bars is the best. - bool bShowHorizontal = false; - bool bShowVertical = false; - if (mrSlideSorter.GetModel().GetPageCount() == 0) - { - // No pages => no scroll bars. - } - else if (TestScrollBarVisibilities(false, false, rAvailableArea)) - { - // Nothing to be done. - } - else if (bIsHorizontalScrollBarAllowed - && TestScrollBarVisibilities(true, false, rAvailableArea)) - { - bShowHorizontal = true; - } - else if (bIsVerticalScrollBarAllowed - && TestScrollBarVisibilities(false, true, rAvailableArea)) - { - bShowVertical = true; - } - else - { - bShowHorizontal = true; - bShowVertical = true; - } - - // Make the visibility of the scroll bars permanent. - mpVerticalScrollBar->Show(bShowVertical); - mpHorizontalScrollBar->Show(bShowHorizontal); - mpScrollBarFiller->Show(bShowVertical && bShowHorizontal); - - // Adapt the remaining space accordingly. - Rectangle aRemainingSpace (rAvailableArea); - if (bShowVertical) - aRemainingSpace.Right() -= mpVerticalScrollBar->GetSizePixel().Width(); - if (bShowHorizontal) - aRemainingSpace.Bottom() -= mpHorizontalScrollBar->GetSizePixel().Height(); - - return aRemainingSpace; -} - - - - -bool ScrollBarManager::TestScrollBarVisibilities ( - bool bHorizontalScrollBarVisible, - bool bVerticalScrollBarVisible, - const Rectangle& rAvailableArea) -{ - model::SlideSorterModel& rModel (mrSlideSorter.GetModel()); - - // Adapt the available size by subtracting the sizes of the scroll bars - // visible in this combination. - Size aBrowserSize (rAvailableArea.GetSize()); - if (bHorizontalScrollBarVisible) - aBrowserSize.Height() -= mpHorizontalScrollBar->GetSizePixel().Height(); - if (bVerticalScrollBarVisible) - aBrowserSize.Width() -= mpVerticalScrollBar->GetSizePixel().Width(); - - // Tell the view to rearrange its page objects and check whether the - // page objects can be shown without clipping. - bool bRearrangeSuccess (mrSlideSorter.GetView().GetLayouter().Rearrange ( - mrSlideSorter.GetView().GetOrientation(), - aBrowserSize, - rModel.GetPageDescriptor(0)->GetPage()->GetSize(), - rModel.GetPageCount())); - - if (bRearrangeSuccess) - { - Size aPageSize = mrSlideSorter.GetView().GetLayouter().GetTotalBoundingBox().GetSize(); - Size aWindowModelSize = mpContentWindow->PixelToLogic(aBrowserSize); - - // The content may be clipped, i.e. not fully visible, in one - // direction only when the scroll bar is visible in that direction. - if (aPageSize.Width() > aWindowModelSize.Width()) - if ( ! bHorizontalScrollBarVisible) - return false; - if (aPageSize.Height() > aWindowModelSize.Height()) - if ( ! bVerticalScrollBarVisible) - return false; - - return true; - } - else - return false; -} - - - - -void ScrollBarManager::SetTopLeft (const Point aNewTopLeft) -{ - if (( ! mpVerticalScrollBar - || mpVerticalScrollBar->GetThumbPos() == aNewTopLeft.Y()) - && ( ! mpHorizontalScrollBar - || mpHorizontalScrollBar->GetThumbPos() == aNewTopLeft.X())) - return; - - // Flush pending repaints before scrolling to avoid temporary artifacts. - mrSlideSorter.GetContentWindow()->Update(); - - if (mpVerticalScrollBar) - { - mpVerticalScrollBar->SetThumbPos(aNewTopLeft.Y()); - mnVerticalPosition = aNewTopLeft.Y() / double(mpVerticalScrollBar->GetRange().Len()); - } - if (mpHorizontalScrollBar) - { - mpHorizontalScrollBar->SetThumbPos(aNewTopLeft.X()); - mnHorizontalPosition = aNewTopLeft.X() / double(mpHorizontalScrollBar->GetRange().Len()); - } - - mrSlideSorter.GetContentWindow()->SetVisibleXY(mnHorizontalPosition, mnVerticalPosition); - mrSlideSorter.GetView().InvalidatePageObjectVisibilities(); -} - - - - -sal_Int32 ScrollBarManager::GetTop (void) const -{ - if (mpVerticalScrollBar != NULL) - return mpVerticalScrollBar->GetThumbPos(); - else - return 0; -} - - - - -sal_Int32 ScrollBarManager::GetLeft (void) const -{ - if (mpHorizontalScrollBar != NULL) - return mpHorizontalScrollBar->GetThumbPos(); - else - return 0; -} - - - - -int ScrollBarManager::GetVerticalScrollBarWidth (void) const -{ - if (mpVerticalScrollBar != NULL && mpVerticalScrollBar->IsVisible()) - return mpVerticalScrollBar->GetSizePixel().Width(); - else - return 0; -} - - - - -int ScrollBarManager::GetHorizontalScrollBarHeight (void) const -{ - if (mpHorizontalScrollBar != NULL && mpHorizontalScrollBar->IsVisible()) - return mpHorizontalScrollBar->GetSizePixel().Height(); - else - return 0; -} - - - - -void ScrollBarManager::CalcAutoScrollOffset (const Point& rMouseWindowPosition) -{ - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - - int nDx = 0; - int nDy = 0; - - Size aWindowSize = pWindow->GetOutputSizePixel(); - Rectangle aWindowArea (pWindow->GetPosPixel(), aWindowSize); - Rectangle aViewPixelArea ( - pWindow->LogicToPixel(mrSlideSorter.GetView().GetModelArea())); - - if (aWindowSize.Width() > maScrollBorder.Width() * 3 - && mpHorizontalScrollBar != NULL - && mpHorizontalScrollBar->IsVisible()) - { - if (rMouseWindowPosition.X() < maScrollBorder.Width() - && aWindowArea.Left() > aViewPixelArea.Left()) - { - nDx = -1 + (int)(mnHorizontalScrollFactor - * (rMouseWindowPosition.X() - maScrollBorder.Width())); - } - - if (rMouseWindowPosition.X() >= (aWindowSize.Width() - maScrollBorder.Width()) - && aWindowArea.Right() < aViewPixelArea.Right()) - { - nDx = 1 + (int)(mnHorizontalScrollFactor - * (rMouseWindowPosition.X() - aWindowSize.Width() - + maScrollBorder.Width())); - } - } - - if (aWindowSize.Height() > maScrollBorder.Height() * 3 - && aWindowSize.Height() < aViewPixelArea.GetHeight()) - { - if (rMouseWindowPosition.Y() < maScrollBorder.Height() - && aWindowArea.Top() > aViewPixelArea.Top()) - { - nDy = -1 + (int)(mnVerticalScrollFactor - * (rMouseWindowPosition.Y() - maScrollBorder.Height())); - } - - if (rMouseWindowPosition.Y() >= (aWindowSize.Height() - maScrollBorder.Height()) - && aWindowArea.Bottom() < aViewPixelArea.Bottom()) - { - nDy = 1 + (int)(mnVerticalScrollFactor - * (rMouseWindowPosition.Y() - aWindowSize.Height() - + maScrollBorder.Height())); - } - } - - maAutoScrollOffset = Size(nDx,nDy); -} - - - - -bool ScrollBarManager::AutoScroll ( - const Point& rMouseWindowPosition, - const ::boost::function<void(void)>& rAutoScrollFunctor) -{ - maAutoScrollFunctor = rAutoScrollFunctor; - CalcAutoScrollOffset(rMouseWindowPosition); - bool bResult (true); - if ( ! mbIsAutoScrollActive) - bResult = RepeatAutoScroll(); - - return bResult; -} - - - - -void ScrollBarManager::StopAutoScroll (void) -{ - maAutoScrollTimer.Stop(); - mbIsAutoScrollActive = false; -} - - - - -bool ScrollBarManager::RepeatAutoScroll (void) -{ - if (maAutoScrollOffset != Size(0,0)) - { - if (mrSlideSorter.GetViewShell() != NULL) - { - mrSlideSorter.GetViewShell()->Scroll( - maAutoScrollOffset.Width(), - maAutoScrollOffset.Height()); - mrSlideSorter.GetView().InvalidatePageObjectVisibilities(); - - if (maAutoScrollFunctor) - maAutoScrollFunctor(); - - mbIsAutoScrollActive = true; - maAutoScrollTimer.Start(); - - return true; - } - } - - maAutoScrollFunctor = ::boost::function<void(void)>(); - mbIsAutoScrollActive = false; - return false; -} - - - - -IMPL_LINK(ScrollBarManager, AutoScrollTimeoutHandler, Timer *, EMPTYARG) -{ - RepeatAutoScroll(); - - return 0; -} - - - - -void ScrollBarManager::Scroll( - const Orientation eOrientation, - const Unit eUnit, - const sal_Int32 nDistance) -{ - bool bIsVertical (false); - switch (eOrientation) - { - case Orientation_Horizontal: bIsVertical = false; break; - case Orientation_Vertical: bIsVertical = true; break; - default: - OSL_ASSERT(eOrientation==Orientation_Horizontal || eOrientation==Orientation_Vertical); - return; - } - - Point aNewTopLeft ( - mpHorizontalScrollBar ? mpHorizontalScrollBar->GetThumbPos() : 0, - mpVerticalScrollBar ? mpVerticalScrollBar->GetThumbPos() : 0); - switch (eUnit) - { - case Unit_Pixel: - if (bIsVertical) - aNewTopLeft.Y() += nDistance; - else - aNewTopLeft.X() += nDistance; - break; - - case Unit_Slide: - { - view::Layouter& rLayouter (mrSlideSorter.GetView().GetLayouter()); - - // Calculate estimate of new location. - if (bIsVertical) - aNewTopLeft.Y() += nDistance * rLayouter.GetPageObjectSize().Height(); - else - aNewTopLeft.X() += nDistance * rLayouter.GetPageObjectSize().Width(); - - // Adapt location to show whole slides. - if (bIsVertical) - if (nDistance > 0) - { - const sal_Int32 nIndex (rLayouter.GetIndexAtPoint( - Point(aNewTopLeft.X(), aNewTopLeft.Y()+mpVerticalScrollBar->GetVisibleSize()), - true)); - aNewTopLeft.Y() = rLayouter.GetPageObjectBox(nIndex,true).Bottom() - - mpVerticalScrollBar->GetVisibleSize(); - } - else - { - const sal_Int32 nIndex (rLayouter.GetIndexAtPoint( - Point(aNewTopLeft.X(), aNewTopLeft.Y()), - true)); - aNewTopLeft.Y() = rLayouter.GetPageObjectBox(nIndex,true).Top(); - } - else - if (nDistance > 0) - { - const sal_Int32 nIndex (rLayouter.GetIndexAtPoint( - Point(aNewTopLeft.X()+mpVerticalScrollBar->GetVisibleSize(), aNewTopLeft.Y()), - true)); - aNewTopLeft.X() = rLayouter.GetPageObjectBox(nIndex,true).Right() - - mpVerticalScrollBar->GetVisibleSize(); - } - else - { - const sal_Int32 nIndex (rLayouter.GetIndexAtPoint( - Point(aNewTopLeft.X(), aNewTopLeft.Y()), - true)); - aNewTopLeft.X() = rLayouter.GetPageObjectBox(nIndex,true).Left(); - } - } - } - mrSlideSorter.GetController().GetVisibleAreaManager().DeactivateCurrentSlideTracking(); - SetTopLeft(aNewTopLeft); -} - - -} } } // end of namespace ::sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionCommand.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionCommand.cxx deleted file mode 100644 index d85e80f74..000000000 --- a/sd/source/ui/slidesorter/controller/SlsSelectionCommand.cxx +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "SlsSelectionCommand.hxx" - -#include "controller/SlsCurrentSlideManager.hxx" -#include "model/SlideSorterModel.hxx" -#include "model/SlsPageDescriptor.hxx" - -#include "sdpage.hxx" - -namespace sd { namespace slidesorter { namespace controller { - - - -SelectionCommand::SelectionCommand ( - PageSelector& rSelector, - const ::boost::shared_ptr<CurrentSlideManager>& rpCurrentSlideManager, - const model::SlideSorterModel& rModel) - : mrPageSelector(rSelector), - mpCurrentSlideManager(rpCurrentSlideManager), - mrModel(rModel), - maPagesToSelect(), - mnCurrentPageIndex(-1) -{ -} - - - - -void SelectionCommand::AddSlide (sal_uInt16 nPageIndex) -{ - maPagesToSelect.push_back(nPageIndex); -} - - - - -void SelectionCommand::operator() (void) -{ - OSL_ASSERT(mpCurrentSlideManager.get()!=NULL); - - mrPageSelector.DeselectAllPages(); - - if (mnCurrentPageIndex >= 0) - mpCurrentSlideManager->SwitchCurrentSlide(mnCurrentPageIndex); - - PageList::iterator iPage = maPagesToSelect.begin(); - PageList::iterator iEnd = maPagesToSelect.end(); - for (; iPage!=iEnd; ++iPage) - { - sal_Int32 nIndex (*iPage); - if (nIndex >= 0) - mrPageSelector.SelectPage(mrModel.GetPageDescriptor(nIndex)); - } -} - - -} } } // end of namespace sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionCommand.hxx b/sd/source/ui/slidesorter/controller/SlsSelectionCommand.hxx deleted file mode 100644 index 62e0c819b..000000000 --- a/sd/source/ui/slidesorter/controller/SlsSelectionCommand.hxx +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_SLIDESORTER_SELECTION_COMMAND_HXX -#define SD_SLIDESORTER_SELECTION_COMMAND_HXX - -#include "controller/SlsPageSelector.hxx" -#include "SlsCommand.hxx" -#include <tools/solar.h> -#include <com/sun/star/drawing/XDrawPage.hpp> - -#include <boost/shared_ptr.hpp> -#include <vector> - -namespace sd { namespace slidesorter { namespace model { -class SlideSorterModel; -} } } - - -namespace sd { namespace slidesorter { namespace controller { - -class CurrentSlideManager; -class PageSelector; - -/** The SelectionCommand stores a list of pages that it will select on its - execution. Furthermore it will make a page the current page. Note that - internally pages are stored with pointers because this command is designed - to be executed after model changes where page indices may change but - page object identities remain. -*/ -class SelectionCommand - : public Command -{ -public: - /** Create a new command object that will on its exection use the given - PageSelector to select a set of pages. - */ - SelectionCommand ( - PageSelector& rSelector, - const ::boost::shared_ptr<controller::CurrentSlideManager>& rpCurrentSlideManager, - const model::SlideSorterModel& rModel); - - /** Remember the specified page to be selected when this command is - executed. - */ - void AddSlide (sal_uInt16 nPageIndex); - - /** Execute the command and select the pages added by previous calls to - AddPages() and AddPage(). - */ - virtual void operator() (void); - -private: - /// The page selector is used to select pages and set the current page. - PageSelector& mrPageSelector; - /// Used for setting the current slide. - ::boost::shared_ptr<controller::CurrentSlideManager> mpCurrentSlideManager; - /// The model is used to translate page indices into page pointers. - const model::SlideSorterModel& mrModel; - /// The list of pages to be selected when the command is executed. - typedef ::std::vector<sal_Int32> PageList; - PageList maPagesToSelect; - /** The page that will be made the current page when the command is - executed. - */ - sal_Int32 mnCurrentPageIndex; -}; - -} } } // end of namespace sd::slidesorter::controller - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx deleted file mode 100644 index 13e02cd84..000000000 --- a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx +++ /dev/null @@ -1,2027 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "controller/SlsSelectionFunction.hxx" - -#include "SlideSorter.hxx" -#include "SlideSorterViewShell.hxx" -#include "SlsDragAndDropContext.hxx" -#include "controller/SlsTransferable.hxx" -#include "controller/SlideSorterController.hxx" -#include "controller/SlsPageSelector.hxx" -#include "controller/SlsFocusManager.hxx" -#include "controller/SlsScrollBarManager.hxx" -#include "controller/SlsClipboard.hxx" -#include "controller/SlsCurrentSlideManager.hxx" -#include "controller/SlsInsertionIndicatorHandler.hxx" -#include "controller/SlsSelectionManager.hxx" -#include "controller/SlsProperties.hxx" -#include "controller/SlsProperties.hxx" -#include "controller/SlsSlotManager.hxx" -#include "controller/SlsVisibleAreaManager.hxx" -#include "model/SlideSorterModel.hxx" -#include "model/SlsPageDescriptor.hxx" -#include "model/SlsPageEnumerationProvider.hxx" -#include "view/SlideSorterView.hxx" -#include "view/SlsLayouter.hxx" -#include "view/SlsPageObjectLayouter.hxx" -#include "view/SlsButtonBar.hxx" -#include "framework/FrameworkHelper.hxx" -#include "ViewShellBase.hxx" -#include "DrawController.hxx" -#include "Window.hxx" -#include "sdpage.hxx" -#include "drawdoc.hxx" -#include "DrawDocShell.hxx" -#include "sdxfer.hxx" -#include "ViewShell.hxx" -#include "ViewShellBase.hxx" -#include "FrameView.hxx" -#include "app.hrc" -#include "sdresid.hxx" -#include "strings.hrc" -#include <vcl/sound.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/dispatch.hxx> -#include <svx/svdpagv.hxx> -#include <vcl/msgbox.hxx> -#include <svx/svxids.hrc> -#include <boost/bind.hpp> -#include <boost/optional.hpp> - -namespace { -static const sal_uInt32 SINGLE_CLICK (0x00000001); -static const sal_uInt32 DOUBLE_CLICK (0x00000002); -static const sal_uInt32 LEFT_BUTTON (0x00000010); -static const sal_uInt32 RIGHT_BUTTON (0x00000020); -static const sal_uInt32 MIDDLE_BUTTON (0x00000040); -static const sal_uInt32 BUTTON_DOWN (0x00000100); -static const sal_uInt32 BUTTON_UP (0x00000200); -static const sal_uInt32 MOUSE_MOTION (0x00000400); -static const sal_uInt32 MOUSE_DRAG (0x00000800); -// The rest leaves the lower 16 bit untouched so that it can be used with -// key codes. -static const sal_uInt32 OVER_SELECTED_PAGE (0x00010000); -static const sal_uInt32 OVER_UNSELECTED_PAGE (0x00020000); -static const sal_uInt32 OVER_FADE_INDICATOR (0x00040000); -static const sal_uInt32 OVER_BUTTON_AREA (0x00080000); -static const sal_uInt32 OVER_BUTTON (0x00100000); -static const sal_uInt32 SHIFT_MODIFIER (0x00200000); -static const sal_uInt32 CONTROL_MODIFIER (0x00400000); - -static const sal_uInt32 KEY_EVENT (0x10000000); - -// Some absent events are defined so they can be expressed explicitly. -static const sal_uInt32 NO_MODIFIER (0x00000000); -static const sal_uInt32 NOT_OVER_PAGE (0x00000000); - -// Masks -static const sal_uInt32 MODIFIER_MASK (SHIFT_MODIFIER | CONTROL_MODIFIER); -static const sal_uInt32 BUTTON_MASK (LEFT_BUTTON | RIGHT_BUTTON | MIDDLE_BUTTON); - -} // end of anonymous namespace - - - -// Define some macros to make the following switch statement more readable. -#define ANY_MODIFIER(code) \ - code|NO_MODIFIER: \ - case code|SHIFT_MODIFIER: \ - case code|CONTROL_MODIFIER - -namespace sd { namespace slidesorter { namespace controller { - -//===== SelectionFunction::EventDescriptor ==================================== - -class SelectionFunction::EventDescriptor -{ -public: - Point maMousePosition; - Point maMouseModelPosition; - model::SharedPageDescriptor mpHitDescriptor; - SdrPage* mpHitPage; - sal_uInt32 mnEventCode; - bool mbIsOverButton; - InsertionIndicatorHandler::Mode meDragMode; - bool mbMakeSelectionVisible; - bool mbIsLeaving; - - EventDescriptor ( - sal_uInt32 nEventType, - const MouseEvent& rEvent, - SlideSorter& rSlideSorter); - EventDescriptor ( - sal_uInt32 nEventType, - const AcceptDropEvent& rEvent, - const sal_Int8 nDragAction, - SlideSorter& rSlideSorter); - EventDescriptor ( - const KeyEvent& rEvent, - SlideSorter& rSlideSorter); - - void SetDragMode (const InsertionIndicatorHandler::Mode eMode); - -private: - /** Compute a numerical code that describes a mouse event and that can - be used for fast look up of the appropriate reaction. - */ - sal_uInt32 EncodeMouseEvent (const MouseEvent& rEvent) const; - - /** Compute a numerical code that describes a key event and that can - be used for fast look up of the appropriate reaction. - */ - sal_uInt32 EncodeKeyEvent (const KeyEvent& rEvent) const; - - /** Compute a numerical code that describes the current state like - whether the selection rectangle is visible or whether the page under - the mouse or the one that has the focus is selected. - */ - sal_uInt32 EncodeState (void) const; -}; - - - - -//===== SelectionFunction::ModeHandler ======================================== - -class SelectionFunction::ModeHandler -{ -public: - ModeHandler ( - SlideSorter& rSlideSorter, - SelectionFunction& rSelectionFunction, - const bool bIsMouseOverIndicatorAllowed); - virtual ~ModeHandler (void); - - virtual Mode GetMode (void) const = 0; - virtual void Abort (void) = 0; - virtual void ProcessEvent (EventDescriptor& rDescriptor); - - /** Set the selection to exactly the specified page and also set it as - the current page. - */ - void SetCurrentPage (const model::SharedPageDescriptor& rpDescriptor); - - /// Deselect all pages. - void DeselectAllPages (void); - void SelectOnePage (const model::SharedPageDescriptor& rpDescriptor); - - /** When the view on which this selection function is working is the - main view then the view is switched to the regular editing view. - */ - void SwitchView (const model::SharedPageDescriptor& rpDescriptor); - - void StartDrag ( - const Point& rMousePosition, - const InsertionIndicatorHandler::Mode eMode); - - bool IsMouseOverIndicatorAllowed (void) const; - -protected: - SlideSorter& mrSlideSorter; - SelectionFunction& mrSelectionFunction; - - virtual bool ProcessButtonDownEvent (EventDescriptor& rDescriptor); - virtual bool ProcessButtonUpEvent (EventDescriptor& rDescriptor); - virtual bool ProcessMotionEvent (EventDescriptor& rDescriptor); - virtual bool ProcessDragEvent (EventDescriptor& rDescriptor); - virtual bool HandleUnprocessedEvent (EventDescriptor& rDescriptor); - - void ReprocessEvent (EventDescriptor& rDescriptor); - -private: - const bool mbIsMouseOverIndicatorAllowed; -}; - - -/** This is the default handler for processing events. It activates the - multi selection or drag-and-drop when the right conditions are met. -*/ -class NormalModeHandler : public SelectionFunction::ModeHandler -{ -public: - NormalModeHandler ( - SlideSorter& rSlideSorter, - SelectionFunction& rSelectionFunction); - virtual ~NormalModeHandler (void); - - virtual SelectionFunction::Mode GetMode (void) const; - virtual void Abort (void); - - void ResetButtonDownLocation (void); - -protected: - virtual bool ProcessButtonDownEvent (SelectionFunction::EventDescriptor& rDescriptor); - virtual bool ProcessButtonUpEvent (SelectionFunction::EventDescriptor& rDescriptor); - virtual bool ProcessMotionEvent (SelectionFunction::EventDescriptor& rDescriptor); - virtual bool ProcessDragEvent (SelectionFunction::EventDescriptor& rDescriptor); - -private: - ::boost::optional<Point> maButtonDownLocation; - - /** Select all pages between and including the selection anchor and the - specified page. - */ - void RangeSelect (const model::SharedPageDescriptor& rpDescriptor); -}; - - -/** Handle events during a multi selection, which typically is started by - pressing the left mouse button when not over a page. -*/ -class MultiSelectionModeHandler : public SelectionFunction::ModeHandler -{ -public: - /** Start a rectangle selection at the given position. - */ - MultiSelectionModeHandler ( - SlideSorter& rSlideSorter, - SelectionFunction& rSelectionFunction, - const Point& rMouseModelPosition, - const sal_uInt32 nEventCode); - virtual ~MultiSelectionModeHandler (void); - - virtual SelectionFunction::Mode GetMode (void) const; - virtual void Abort (void); - virtual void ProcessEvent (SelectionFunction::EventDescriptor& rDescriptor); - - enum SelectionMode { SM_Normal, SM_Add, SM_Toggle }; - - void SetSelectionMode (const SelectionMode eSelectionMode); - void SetSelectionModeFromModifier (const sal_uInt32 nEventCode); - -protected: - virtual bool ProcessButtonUpEvent (SelectionFunction::EventDescriptor& rDescriptor); - virtual bool ProcessMotionEvent (SelectionFunction::EventDescriptor& rDescriptor); - virtual bool HandleUnprocessedEvent (SelectionFunction::EventDescriptor& rDescriptor); - -private: - SelectionMode meSelectionMode; - Point maSecondCorner; - Pointer maSavedPointer; - sal_Int32 mnAnchorIndex; - sal_Int32 mnSecondIndex; - view::ButtonBar::Lock maButtonBarLock; - - virtual void UpdateModelPosition (const Point& rMouseModelPosition); - virtual void UpdateSelection (void); - - /** Update the rectangle selection so that the given position becomes - the new second point of the selection rectangle. - */ - void UpdatePosition ( - const Point& rMousePosition, - const bool bAllowAutoScroll); - - void UpdateSelectionState ( - const model::SharedPageDescriptor& rpDescriptor, - const bool bIsInSelection) const; -}; - - -/** Handle events during drag-and-drop. -*/ -class DragAndDropModeHandler : public SelectionFunction::ModeHandler -{ -public: - DragAndDropModeHandler ( - SlideSorter& rSlideSorter, - SelectionFunction& rSelectionFunction, - const Point& rMousePosition, - ::Window* pWindow); - virtual ~DragAndDropModeHandler (void); - - virtual SelectionFunction::Mode GetMode (void) const; - virtual void Abort (void); - -protected: - virtual bool ProcessButtonUpEvent (SelectionFunction::EventDescriptor& rDescriptor); - virtual bool ProcessDragEvent (SelectionFunction::EventDescriptor& rDescriptor); - -private: - ::boost::scoped_ptr<DragAndDropContext> mpDragAndDropContext; -}; - - -/** Handle events while the left mouse button is pressed over the button - bar. -*/ -class ButtonModeHandler : public SelectionFunction::ModeHandler -{ -public: - ButtonModeHandler ( - SlideSorter& rSlideSorter, - SelectionFunction& rSelectionFunction); - virtual ~ButtonModeHandler (void); - virtual void Abort (void); - - virtual SelectionFunction::Mode GetMode (void) const; - -protected: - virtual bool ProcessButtonDownEvent (SelectionFunction::EventDescriptor& rDescriptor); - virtual bool ProcessButtonUpEvent (SelectionFunction::EventDescriptor& rDescriptor); - virtual bool ProcessMotionEvent (SelectionFunction::EventDescriptor& rDescriptor); -}; - - - - -//===== SelectionFunction ===================================================== - -TYPEINIT1(SelectionFunction, FuPoor); - - -SelectionFunction::SelectionFunction ( - SlideSorter& rSlideSorter, - SfxRequest& rRequest) - : FuPoor ( - rSlideSorter.GetViewShell(), - rSlideSorter.GetContentWindow().get(), - &rSlideSorter.GetView(), - rSlideSorter.GetModel().GetDocument(), - rRequest), - mrSlideSorter(rSlideSorter), - mrController(mrSlideSorter.GetController()), - mbDragSelection(false), - maInsertionMarkerBox(), - mbProcessingMouseButtonDown(false), - mnShiftKeySelectionAnchor(-1), - mpModeHandler(new NormalModeHandler(rSlideSorter, *this)) -{ -} - - - - -SelectionFunction::~SelectionFunction (void) -{ - mpModeHandler.reset(); -} - - - - -FunctionReference SelectionFunction::Create( - SlideSorter& rSlideSorter, - SfxRequest& rRequest) -{ - FunctionReference xFunc( new SelectionFunction( rSlideSorter, rRequest ) ); - return xFunc; -} - - - - -sal_Bool SelectionFunction::MouseButtonDown (const MouseEvent& rEvent) -{ - // remember button state for creation of own MouseEvents - SetMouseButtonCode (rEvent.GetButtons()); - aMDPos = rEvent.GetPosPixel(); - mbProcessingMouseButtonDown = true; - - // mpWindow->CaptureMouse(); - - ProcessMouseEvent(BUTTON_DOWN, rEvent); - - return sal_True; -} - - - - -sal_Bool SelectionFunction::MouseMove (const MouseEvent& rEvent) -{ - ProcessMouseEvent(MOUSE_MOTION, rEvent); - return sal_True; -} - - - - -sal_Bool SelectionFunction::MouseButtonUp (const MouseEvent& rEvent) -{ - mrController.GetScrollBarManager().StopAutoScroll (); - - ProcessMouseEvent(BUTTON_UP, rEvent); - - mbProcessingMouseButtonDown = false; -// mpWindow->ReleaseMouse(); - - return sal_True; -} - - - - -void SelectionFunction::NotifyDragFinished (void) -{ - SwitchToNormalMode(); -} - - - - -sal_Bool SelectionFunction::KeyInput (const KeyEvent& rEvent) -{ - view::SlideSorterView::DrawLock aDrawLock (mrSlideSorter); - PageSelector::UpdateLock aLock (mrSlideSorter); - FocusManager& rFocusManager (mrController.GetFocusManager()); - sal_Bool bResult = sal_False; - - const KeyCode& rCode (rEvent.GetKeyCode()); - switch (rCode.GetCode()) - { - case KEY_RETURN: - { - model::SharedPageDescriptor pDescriptor (rFocusManager.GetFocusedPageDescriptor()); - ViewShell* pViewShell = mrSlideSorter.GetViewShell(); - if (rFocusManager.HasFocus() && pDescriptor && pViewShell!=NULL) - { - // The Return key triggers different functions depending on - // whether the slide sorter is the main view or displayed in - // the right pane. - if (pViewShell->IsMainViewShell()) - { - mpModeHandler->SetCurrentPage(pDescriptor); - mpModeHandler->SwitchView(pDescriptor); - } - else - { - pViewShell->GetDispatcher()->Execute( - SID_INSERTPAGE, - SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD); - } - bResult = sal_True; - } - break; - } - - case KEY_TAB: - if ( ! rFocusManager.IsFocusShowing()) - { - rFocusManager.ShowFocus(); - bResult = sal_True; - } - break; - - case KEY_ESCAPE: - // When there is an active multiselection or drag-and-drop - // operation then stop that. - mpModeHandler->Abort(); - SwitchToNormalMode(); - bResult = sal_True; - break; - - case KEY_SPACE: - { - // Toggle the selection state. - model::SharedPageDescriptor pDescriptor (rFocusManager.GetFocusedPageDescriptor()); - if (pDescriptor && rCode.IsMod1()) - { - if (pDescriptor->HasState(model::PageDescriptor::ST_Selected)) - mrController.GetPageSelector().DeselectPage(pDescriptor, false); - else - mrController.GetPageSelector().SelectPage(pDescriptor); - } - bResult = sal_True; - } - break; - - - // Move the focus indicator left. - case KEY_LEFT: - MoveFocus(FocusManager::FMD_LEFT, rCode.IsShift(), rCode.IsMod1()); - bResult = sal_True; - break; - - // Move the focus indicator right. - case KEY_RIGHT: - MoveFocus(FocusManager::FMD_RIGHT, rCode.IsShift(), rCode.IsMod1()); - bResult = sal_True; - break; - - // Move the focus indicator up. - case KEY_UP: - MoveFocus(FocusManager::FMD_UP, rCode.IsShift(), rCode.IsMod1()); - bResult = sal_True; - break; - - // Move the focus indicator down. - case KEY_DOWN: - MoveFocus(FocusManager::FMD_DOWN, rCode.IsShift(), rCode.IsMod1()); - bResult = sal_True; - break; - - // Go to previous page. No wrap around. - case KEY_PAGEUP: - GotoNextPage(-1); - bResult = sal_True; - break; - - // Go to next page. No wrap around.. - case KEY_PAGEDOWN: - GotoNextPage(+1); - bResult = sal_True; - break; - - case KEY_HOME: - GotoPage(0); - bResult = sal_True; - break; - - case KEY_END: - GotoPage(mrSlideSorter.GetModel().GetPageCount()-1); - bResult = sal_True; - break; - - case KEY_DELETE: - case KEY_BACKSPACE: - { - if (mrSlideSorter.GetProperties()->IsUIReadOnly()) - break; - - mrController.GetSelectionManager()->DeleteSelectedPages(rCode.GetCode()==KEY_DELETE); - - mnShiftKeySelectionAnchor = -1; - bResult = sal_True; - } - break; - - case KEY_F10: - if (rCode.IsShift()) - { - mpModeHandler->SelectOnePage( - mrSlideSorter.GetController().GetFocusManager().GetFocusedPageDescriptor()); - } - break; - - default: - break; - } - - if ( ! bResult) - bResult = FuPoor::KeyInput(rEvent); - - return bResult; -} - - - - -void SelectionFunction::MoveFocus ( - const FocusManager::FocusMoveDirection eDirection, - const bool bIsShiftDown, - const bool bIsControlDown) -{ - // Remember the anchor of shift key multi selection. - if (bIsShiftDown) - { - if (mnShiftKeySelectionAnchor<0) - { - model::SharedPageDescriptor pFocusedDescriptor ( - mrController.GetFocusManager().GetFocusedPageDescriptor()); - mnShiftKeySelectionAnchor = pFocusedDescriptor->GetPageIndex(); - } - } - else if ( ! bIsControlDown) - ResetShiftKeySelectionAnchor(); - - mrController.GetFocusManager().MoveFocus(eDirection); - - PageSelector& rSelector (mrController.GetPageSelector()); - model::SharedPageDescriptor pFocusedDescriptor ( - mrController.GetFocusManager().GetFocusedPageDescriptor()); - if (bIsShiftDown) - { - // When shift is pressed then select all pages in the range between - // the currently and the previously focused pages, including them. - if (pFocusedDescriptor) - { - sal_Int32 nPageRangeEnd (pFocusedDescriptor->GetPageIndex()); - model::PageEnumeration aPages ( - model::PageEnumerationProvider::CreateAllPagesEnumeration( - mrSlideSorter.GetModel())); - while (aPages.HasMoreElements()) - { - model::SharedPageDescriptor pDescriptor (aPages.GetNextElement()); - if (pDescriptor) - { - const sal_Int32 nPageIndex(pDescriptor->GetPageIndex()); - if ((nPageIndex>=mnShiftKeySelectionAnchor && nPageIndex<=nPageRangeEnd) - || (nPageIndex<=mnShiftKeySelectionAnchor && nPageIndex>=nPageRangeEnd)) - { - rSelector.SelectPage(pDescriptor); - } - else - { - rSelector.DeselectPage(pDescriptor); - } - } - } - } - } - else if (bIsControlDown) - { - // When control is pressed then do not alter the selection or the - // current page, just move the focus. - } - else - { - // Without shift just select the focused page. - mpModeHandler->SelectOnePage(pFocusedDescriptor); - } -} - - - - -void SelectionFunction::Activate() -{ - FuPoor::Activate(); -} - - - - -void SelectionFunction::Deactivate() -{ - FuPoor::Deactivate(); -} - - - -void SelectionFunction::ScrollStart (void) -{ -} - - - - -void SelectionFunction::ScrollEnd (void) -{ -} - - - - -void SelectionFunction::DoCut (void) -{ - if ( ! mrSlideSorter.GetProperties()->IsUIReadOnly()) - { - mrController.GetClipboard().DoCut(); - } -} - - - - -void SelectionFunction::DoCopy (void) -{ - mrController.GetClipboard().DoCopy(); -} - - - - -void SelectionFunction::DoPaste (void) -{ - if ( ! mrSlideSorter.GetProperties()->IsUIReadOnly()) - { - mrController.GetClipboard().DoPaste(); - } -} - - - - -bool SelectionFunction::cancel (void) -{ - mrController.GetFocusManager().ToggleFocus(); - return true; -} - - - - -void SelectionFunction::GotoNextPage (int nOffset) -{ - model::SharedPageDescriptor pDescriptor - = mrController.GetCurrentSlideManager()->GetCurrentSlide(); - if (pDescriptor.get() != NULL) - { - SdPage* pPage = pDescriptor->GetPage(); - OSL_ASSERT(pPage!=NULL); - sal_Int32 nIndex = (pPage->GetPageNum()-1) / 2; - GotoPage(nIndex + nOffset); - } - ResetShiftKeySelectionAnchor(); -} - - - - -void SelectionFunction::GotoPage (int nIndex) -{ - sal_uInt16 nPageCount = (sal_uInt16)mrSlideSorter.GetModel().GetPageCount(); - - if (nIndex >= nPageCount) - nIndex = nPageCount - 1; - if (nIndex < 0) - nIndex = 0; - - mrController.GetFocusManager().SetFocusedPage(nIndex); - model::SharedPageDescriptor pNextPageDescriptor ( - mrSlideSorter.GetModel().GetPageDescriptor (nIndex)); - if (pNextPageDescriptor.get() != NULL) - mpModeHandler->SetCurrentPage(pNextPageDescriptor); - else - { - OSL_ASSERT(pNextPageDescriptor.get() != NULL); - } - ResetShiftKeySelectionAnchor(); -} - - - - -void SelectionFunction::ProcessMouseEvent (sal_uInt32 nEventType, const MouseEvent& rEvent) -{ - // #95491# remember button state for creation of own MouseEvents - SetMouseButtonCode (rEvent.GetButtons()); - - EventDescriptor aEventDescriptor (nEventType, rEvent, mrSlideSorter); - ProcessEvent(aEventDescriptor); -} - - - - -void SelectionFunction::MouseDragged ( - const AcceptDropEvent& rEvent, - const sal_Int8 nDragAction) -{ - EventDescriptor aEventDescriptor (MOUSE_DRAG, rEvent, nDragAction, mrSlideSorter); - ProcessEvent(aEventDescriptor); -} - - - - -void SelectionFunction::ProcessKeyEvent (const KeyEvent& rEvent) -{ - EventDescriptor aEventDescriptor (rEvent, mrSlideSorter); - ProcessEvent(aEventDescriptor); -} - - - - -void SelectionFunction::ProcessEvent (EventDescriptor& rDescriptor) -{ - // The call to ProcessEvent may switch to another mode handler. - // Prevent the untimely destruction of the called handler by aquiring a - // temporary reference here. - ::boost::shared_ptr<ModeHandler> pModeHandler (mpModeHandler); - pModeHandler->ProcessEvent(rDescriptor); -} - - - - -bool Match ( - const sal_uInt32 nEventCode, - const sal_uInt32 nPositivePattern) -{ - return (nEventCode & nPositivePattern)==nPositivePattern; -} - - - - -void SelectionFunction::SwitchToNormalMode (void) -{ - if (mpModeHandler->GetMode() != NormalMode) - SwitchMode(::boost::shared_ptr<ModeHandler>( - new NormalModeHandler(mrSlideSorter, *this))); -} - - - - -void SelectionFunction::SwitchToDragAndDropMode (const Point aMousePosition) -{ - if (mpModeHandler->GetMode() != DragAndDropMode) - { - SwitchMode(::boost::shared_ptr<ModeHandler>( - new DragAndDropModeHandler(mrSlideSorter, *this, aMousePosition, mpWindow))); - } -} - - - - -void SelectionFunction::SwitchToMultiSelectionMode ( - const Point aMousePosition, - const sal_uInt32 nEventCode) -{ - if (mpModeHandler->GetMode() != MultiSelectionMode) - SwitchMode(::boost::shared_ptr<ModeHandler>( - new MultiSelectionModeHandler(mrSlideSorter, *this, aMousePosition, nEventCode))); -} - - - - -bool SelectionFunction::SwitchToButtonMode (void) -{ - // Do not show the buttons for draw pages. - ::boost::shared_ptr<ViewShell> pMainViewShell (mrSlideSorter.GetViewShellBase()->GetMainViewShell()); - if (pMainViewShell - && pMainViewShell->GetShellType()!=ViewShell::ST_DRAW - && mpModeHandler->GetMode() != ButtonMode) - { - SwitchMode(::boost::shared_ptr<ModeHandler>(new ButtonModeHandler(mrSlideSorter, *this))); - return true; - } - else - return false; -} - - - - -void SelectionFunction::SwitchMode (const ::boost::shared_ptr<ModeHandler>& rpHandler) -{ - // Not all modes allow mouse over indicator. - if (mpModeHandler->IsMouseOverIndicatorAllowed() != rpHandler->IsMouseOverIndicatorAllowed()) - { - if ( ! rpHandler->IsMouseOverIndicatorAllowed()) - { - mrSlideSorter.GetView().SetPageUnderMouse(model::SharedPageDescriptor()); - mrSlideSorter.GetView().GetButtonBar().ResetPage(); - } - else - mrSlideSorter.GetView().UpdatePageUnderMouse(false); - } - - mpModeHandler = rpHandler; -} - - - - -void SelectionFunction::ResetShiftKeySelectionAnchor (void) -{ - mnShiftKeySelectionAnchor = -1; -} - - - - -void SelectionFunction::ResetMouseAnchor (void) -{ - if (mpModeHandler && mpModeHandler->GetMode() == NormalMode) - { - ::boost::shared_ptr<NormalModeHandler> pHandler ( - ::boost::dynamic_pointer_cast<NormalModeHandler>(mpModeHandler)); - if (pHandler) - pHandler->ResetButtonDownLocation(); - } -} - - - - -//===== EventDescriptor ======================================================= - -SelectionFunction::EventDescriptor::EventDescriptor ( - const sal_uInt32 nEventType, - const MouseEvent& rEvent, - SlideSorter& rSlideSorter) - : maMousePosition(rEvent.GetPosPixel()), - maMouseModelPosition(), - mpHitDescriptor(), - mpHitPage(), - mnEventCode(nEventType), - mbIsOverButton(rSlideSorter.GetView().GetButtonBar().IsMouseOverButton()), - meDragMode(InsertionIndicatorHandler::MoveMode), - mbMakeSelectionVisible(true), - mbIsLeaving(false) -{ - maMouseModelPosition = rSlideSorter.GetContentWindow()->PixelToLogic(maMousePosition); - mpHitDescriptor = rSlideSorter.GetController().GetPageAt(maMousePosition); - if (mpHitDescriptor) - { - mpHitPage = mpHitDescriptor->GetPage(); - } - - mnEventCode |= EncodeMouseEvent(rEvent); - mnEventCode |= EncodeState(); - - // Detect the mouse leaving the window. When not button is pressed then - // we can call IsLeaveWindow at the event. Otherwise we have to make an - // explicit test. - mbIsLeaving = rEvent.IsLeaveWindow() - || ! Rectangle(Point(0,0), - rSlideSorter.GetContentWindow()->GetOutputSizePixel()).IsInside(maMousePosition); -} - - - - -SelectionFunction::EventDescriptor::EventDescriptor ( - const sal_uInt32 nEventType, - const AcceptDropEvent& rEvent, - const sal_Int8 nDragAction, - SlideSorter& rSlideSorter) - : maMousePosition(rEvent.maPosPixel), - maMouseModelPosition(), - mpHitDescriptor(), - mpHitPage(), - mnEventCode(nEventType), - mbIsOverButton(rSlideSorter.GetView().GetButtonBar().IsMouseOverButton()), - meDragMode(InsertionIndicatorHandler::GetModeFromDndAction(nDragAction)), - mbMakeSelectionVisible(true), - mbIsLeaving(false) -{ - maMouseModelPosition = rSlideSorter.GetContentWindow()->PixelToLogic(maMousePosition); - mpHitDescriptor = rSlideSorter.GetController().GetPageAt(maMousePosition); - if (mpHitDescriptor) - { - mpHitPage = mpHitDescriptor->GetPage(); - } - - mnEventCode |= EncodeState(); - - // Detect the mouse leaving the window. When not button is pressed then - // we can call IsLeaveWindow at the event. Otherwise we have to make an - // explicit test. - mbIsLeaving = rEvent.mbLeaving - || ! Rectangle(Point(0,0), - rSlideSorter.GetContentWindow()->GetOutputSizePixel()).IsInside(maMousePosition); -} - - - - -SelectionFunction::EventDescriptor::EventDescriptor ( - const KeyEvent& rEvent, - SlideSorter& rSlideSorter) - : maMousePosition(), - maMouseModelPosition(), - mpHitDescriptor(), - mpHitPage(), - mnEventCode(KEY_EVENT), - mbIsOverButton(rSlideSorter.GetView().GetButtonBar().IsMouseOverButton()), - meDragMode(InsertionIndicatorHandler::MoveMode), - mbMakeSelectionVisible(true), - mbIsLeaving(false) -{ - model::SharedPageDescriptor pHitDescriptor ( - rSlideSorter.GetController().GetFocusManager().GetFocusedPageDescriptor()); - if (pHitDescriptor.get() != NULL) - { - mpHitPage = pHitDescriptor->GetPage(); - mpHitDescriptor = pHitDescriptor; - } - - mnEventCode |= EncodeKeyEvent(rEvent) | EncodeState(); -} - - - - -void SelectionFunction::EventDescriptor::SetDragMode (const InsertionIndicatorHandler::Mode eMode) -{ - meDragMode = eMode; -} - - - - -sal_uInt32 SelectionFunction::EventDescriptor::EncodeMouseEvent ( - const MouseEvent& rEvent) const -{ - // Initialize with the type of mouse event. - sal_uInt32 nEventCode (mnEventCode & (BUTTON_DOWN | BUTTON_UP | MOUSE_MOTION)); - - // Detect the affected button. - switch (rEvent.GetButtons()) - { - case MOUSE_LEFT: nEventCode |= LEFT_BUTTON; break; - case MOUSE_RIGHT: nEventCode |= RIGHT_BUTTON; break; - case MOUSE_MIDDLE: nEventCode |= MIDDLE_BUTTON; break; - } - - // Detect the number of clicks. - switch (rEvent.GetClicks()) - { - case 1: nEventCode |= SINGLE_CLICK; break; - case 2: nEventCode |= DOUBLE_CLICK; break; - } - - // Detect pressed modifier keys. - if (rEvent.IsShift()) - nEventCode |= SHIFT_MODIFIER; - if (rEvent.IsMod1()) - nEventCode |= CONTROL_MODIFIER; - - // Detect whether the mouse is over one of the active elements inside a - // page object. - if (mbIsOverButton) - nEventCode |= OVER_BUTTON; - - return nEventCode; -} - - - - -sal_uInt32 SelectionFunction::EventDescriptor::EncodeKeyEvent (const KeyEvent& rEvent) const -{ - // The key code in the lower 16 bit. - sal_uInt32 nEventCode (rEvent.GetKeyCode().GetCode()); - - // Detect pressed modifier keys. - if (rEvent.GetKeyCode().IsShift()) - nEventCode |= SHIFT_MODIFIER; - if (rEvent.GetKeyCode().IsMod1()) - nEventCode |= CONTROL_MODIFIER; - - return nEventCode; -} - - - - -sal_uInt32 SelectionFunction::EventDescriptor::EncodeState (void) const -{ - sal_uInt32 nEventCode (0); - - // Detect whether the event has happened over a page object. - if (mpHitPage!=NULL && mpHitDescriptor) - { - if (mpHitDescriptor->HasState(model::PageDescriptor::ST_Selected)) - nEventCode |= OVER_SELECTED_PAGE; - else - nEventCode |= OVER_UNSELECTED_PAGE; - - // Detect whether the mouse is over one of the active elements - // inside a page object. - if (mbIsOverButton) - nEventCode |= OVER_BUTTON; - } - - return nEventCode; -} - - - - -//===== SelectionFunction::ModeHandler ======================================== - -SelectionFunction::ModeHandler::ModeHandler ( - SlideSorter& rSlideSorter, - SelectionFunction& rSelectionFunction, - const bool bIsMouseOverIndicatorAllowed) - : mrSlideSorter(rSlideSorter), - mrSelectionFunction(rSelectionFunction), - mbIsMouseOverIndicatorAllowed(bIsMouseOverIndicatorAllowed) -{ -} - - - - -SelectionFunction::ModeHandler::~ModeHandler (void) -{ -} - - - - -void SelectionFunction::ModeHandler::ReprocessEvent (EventDescriptor& rDescriptor) -{ - mrSelectionFunction.ProcessEvent(rDescriptor); -} - - - - -void SelectionFunction::ModeHandler::ProcessEvent ( - SelectionFunction::EventDescriptor& rDescriptor) -{ - PageSelector::BroadcastLock aBroadcastLock (mrSlideSorter); - PageSelector::UpdateLock aUpdateLock (mrSlideSorter); - - bool bIsProcessed (false); - switch (rDescriptor.mnEventCode & (BUTTON_DOWN | BUTTON_UP | MOUSE_MOTION | MOUSE_DRAG)) - { - case BUTTON_DOWN: - bIsProcessed = ProcessButtonDownEvent(rDescriptor); - break; - - case BUTTON_UP: - bIsProcessed = ProcessButtonUpEvent(rDescriptor); - break; - - case MOUSE_MOTION: - bIsProcessed = ProcessMotionEvent(rDescriptor); - break; - - case MOUSE_DRAG: - bIsProcessed = ProcessDragEvent(rDescriptor); - break; - } - - if ( ! bIsProcessed) - HandleUnprocessedEvent(rDescriptor); -} - - - - -bool SelectionFunction::ModeHandler::ProcessButtonDownEvent (EventDescriptor&) -{ - return false; -} - - - - -bool SelectionFunction::ModeHandler::ProcessButtonUpEvent (EventDescriptor&) -{ - mrSelectionFunction.SwitchToNormalMode(); - return false; -} - - - - -bool SelectionFunction::ModeHandler::ProcessMotionEvent (EventDescriptor& rDescriptor) -{ - if (mbIsMouseOverIndicatorAllowed) - mrSlideSorter.GetView().UpdatePageUnderMouse( - rDescriptor.maMousePosition, - (rDescriptor.mnEventCode & LEFT_BUTTON) != 0, - true); - - if (rDescriptor.mbIsLeaving) - { - mrSelectionFunction.SwitchToNormalMode(); - mrSlideSorter.GetView().SetPageUnderMouse(model::SharedPageDescriptor()); - - return true; - } - else - return false; -} - - - - -bool SelectionFunction::ModeHandler::ProcessDragEvent (EventDescriptor&) -{ - return false; -} - - - - -bool SelectionFunction::ModeHandler::HandleUnprocessedEvent (EventDescriptor&) -{ - return false; -} - - - - -void SelectionFunction::ModeHandler::SetCurrentPage ( - const model::SharedPageDescriptor& rpDescriptor) -{ - SelectOnePage(rpDescriptor); - mrSlideSorter.GetController().GetCurrentSlideManager()->SwitchCurrentSlide(rpDescriptor); -} - - - - -void SelectionFunction::ModeHandler::DeselectAllPages (void) -{ - mrSlideSorter.GetController().GetPageSelector().DeselectAllPages(); - mrSelectionFunction.ResetShiftKeySelectionAnchor(); -} - - - - -void SelectionFunction::ModeHandler::SelectOnePage ( - const model::SharedPageDescriptor& rpDescriptor) -{ - DeselectAllPages(); - mrSlideSorter.GetController().GetPageSelector().SelectPage(rpDescriptor); -} - - - - -void SelectionFunction::ModeHandler::SwitchView (const model::SharedPageDescriptor& rpDescriptor) -{ - // Switch to the draw view. This is done only when the current - // view is the main view. - ViewShell* pViewShell = mrSlideSorter.GetViewShell(); - if (pViewShell!=NULL && pViewShell->IsMainViewShell()) - { - if (rpDescriptor.get()!=NULL && rpDescriptor->GetPage()!=NULL) - { - mrSlideSorter.GetModel().GetDocument()->SetSelected(rpDescriptor->GetPage(), sal_True); - pViewShell->GetFrameView()->SetSelectedPage( - (rpDescriptor->GetPage()->GetPageNum()-1)/2); - } - if (mrSlideSorter.GetViewShellBase() != NULL) - framework::FrameworkHelper::Instance(*mrSlideSorter.GetViewShellBase())->RequestView( - framework::FrameworkHelper::msImpressViewURL, - framework::FrameworkHelper::msCenterPaneURL); - } -} - - - - -void SelectionFunction::ModeHandler::StartDrag ( - const Point& rMousePosition, - const InsertionIndicatorHandler::Mode eMode) -{ - (void)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()) - { - mrSelectionFunction.SwitchToDragAndDropMode(rMousePosition); - } -} - - - - -bool SelectionFunction::ModeHandler::IsMouseOverIndicatorAllowed (void) const -{ - return mbIsMouseOverIndicatorAllowed; -} - - - - -//===== NormalModeHandler ===================================================== - -NormalModeHandler::NormalModeHandler ( - SlideSorter& rSlideSorter, - SelectionFunction& rSelectionFunction) - : ModeHandler(rSlideSorter, rSelectionFunction, true), - maButtonDownLocation() -{ -} - - - - -NormalModeHandler::~NormalModeHandler (void) -{ -} - - - - -SelectionFunction::Mode NormalModeHandler::GetMode (void) const -{ - return SelectionFunction::NormalMode; -} - - - - -void NormalModeHandler::Abort (void) -{ -} - - - - -bool NormalModeHandler::ProcessButtonDownEvent ( - SelectionFunction::EventDescriptor& rDescriptor) -{ - // Remember the location where the left button is pressed. With - // that we can filter away motion events that are caused by key - // presses. We also can tune the minimal motion distance that - // triggers a drag-and-drop operation. - if ((rDescriptor.mnEventCode & BUTTON_DOWN) != 0) - maButtonDownLocation = rDescriptor.maMousePosition; - - switch (rDescriptor.mnEventCode) - { - case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE: - SetCurrentPage(rDescriptor.mpHitDescriptor); - break; - - case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE: - break; - - case BUTTON_DOWN | LEFT_BUTTON | DOUBLE_CLICK | OVER_SELECTED_PAGE: - case BUTTON_DOWN | LEFT_BUTTON | DOUBLE_CLICK | OVER_UNSELECTED_PAGE: - // A double click allways shows the selected slide in the center - // pane in an edit view. - SetCurrentPage(rDescriptor.mpHitDescriptor); - SwitchView(rDescriptor.mpHitDescriptor); - break; - - case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE | SHIFT_MODIFIER: - case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE | SHIFT_MODIFIER: - // Range selection with the shift modifier. - RangeSelect(rDescriptor.mpHitDescriptor); - break; - - case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE | OVER_BUTTON: - case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE | OVER_BUTTON: - OSL_ASSERT(mrSlideSorter.GetView().GetButtonBar().IsMouseOverButton()); - - // Switch to button mode only when the buttons are visible - // (or being faded in.) - if (mrSlideSorter.GetView().GetButtonBar().IsVisible(rDescriptor.mpHitDescriptor)) - { - if (mrSelectionFunction.SwitchToButtonMode()) - ReprocessEvent(rDescriptor); - } - else - { - // When the buttons are not (yet) visible then behave like - // the left button had been clicked over any other part of - // the slide. - SetCurrentPage(rDescriptor.mpHitDescriptor); - } - break; - - // Right button for context menu. - case BUTTON_DOWN | RIGHT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE: - // Single right click and shift+F10 select as preparation to - // show the context menu. Change the selection only when the - // page under the mouse is not selected. In this case the - // selection is set to this single page. Otherwise the - // selection is not modified. - SetCurrentPage(rDescriptor.mpHitDescriptor); - rDescriptor.mbMakeSelectionVisible = false; - break; - - case BUTTON_DOWN | RIGHT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE: - // Do not change the selection. Just adjust the insertion indicator. - rDescriptor.mbMakeSelectionVisible = false; - break; - - case BUTTON_DOWN | RIGHT_BUTTON | SINGLE_CLICK | NOT_OVER_PAGE: - // Remember the current selection so that when a multi selection - // is started, we can restore the previous selection. - mrSlideSorter.GetModel().SaveCurrentSelection(); - DeselectAllPages(); - break; - - case ANY_MODIFIER(BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | NOT_OVER_PAGE): - // Remember the current selection so that when a multi selection - // is started, we can restore the previous selection. - mrSlideSorter.GetModel().SaveCurrentSelection(); - DeselectAllPages(); - break; - - default: - return false; - } - return true; -} - - - - -bool NormalModeHandler::ProcessButtonUpEvent ( - SelectionFunction::EventDescriptor& rDescriptor) -{ - bool bIsProcessed (true); - switch (rDescriptor.mnEventCode) - { - case BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE: - SetCurrentPage(rDescriptor.mpHitDescriptor); - break; - - // Multi selection with the control modifier. - case BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE | CONTROL_MODIFIER: - mrSlideSorter.GetController().GetPageSelector().DeselectPage( - rDescriptor.mpHitDescriptor); - break; - - case BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE | CONTROL_MODIFIER: - mrSlideSorter.GetController().GetPageSelector().SelectPage( - rDescriptor.mpHitDescriptor); - mrSlideSorter.GetView().UpdatePageUnderMouse( - rDescriptor.mpHitDescriptor, - rDescriptor.maMousePosition, - false); - break; - case BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | NOT_OVER_PAGE: - break; - - default: - bIsProcessed = false; - break; - } - mrSelectionFunction.SwitchToNormalMode(); - return bIsProcessed; -} - - - - - -bool NormalModeHandler::ProcessMotionEvent ( - SelectionFunction::EventDescriptor& rDescriptor) -{ - if (ModeHandler::ProcessMotionEvent(rDescriptor)) - return true; - - bool bIsProcessed (true); - 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): - { - if (maButtonDownLocation) - { - const sal_Int32 nDistance (maButtonDownLocation - ? ::std::max ( - abs(maButtonDownLocation->X() - rDescriptor.maMousePosition.X()), - abs(maButtonDownLocation->Y() - rDescriptor.maMousePosition.Y())) - : 0); - if (nDistance > 3) - StartDrag( - rDescriptor.maMousePosition, - (rDescriptor.mnEventCode & CONTROL_MODIFIER) != 0 - ? InsertionIndicatorHandler::CopyMode - : InsertionIndicatorHandler::MoveMode); - } - } - break; - - // A mouse motion not over a page starts a rectangle selection. - case ANY_MODIFIER(MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK | NOT_OVER_PAGE): - mrSelectionFunction.SwitchToMultiSelectionMode( - rDescriptor.maMouseModelPosition, - rDescriptor.mnEventCode); - break; - - default: - bIsProcessed = false; - break; - } - return bIsProcessed; -} - - - - -bool NormalModeHandler::ProcessDragEvent (SelectionFunction::EventDescriptor& rDescriptor) -{ - mrSelectionFunction.SwitchToDragAndDropMode(rDescriptor.maMousePosition); - ReprocessEvent(rDescriptor); - return true; -} - - - - -void NormalModeHandler::RangeSelect (const model::SharedPageDescriptor& rpDescriptor) -{ - PageSelector::UpdateLock aLock (mrSlideSorter); - PageSelector& rSelector (mrSlideSorter.GetController().GetPageSelector()); - - model::SharedPageDescriptor pAnchor (rSelector.GetSelectionAnchor()); - DeselectAllPages(); - - if (pAnchor.get() != NULL) - { - // Select all pages between the anchor and the given one, including - // the two. - const sal_uInt16 nAnchorIndex ((pAnchor->GetPage()->GetPageNum()-1) / 2); - const sal_uInt16 nOtherIndex ((rpDescriptor->GetPage()->GetPageNum()-1) / 2); - - // Iterate over all pages in the range. Start with the anchor - // page. This way the PageSelector will recognize it again as - // anchor (the first selected page after a DeselectAllPages() - // becomes the anchor.) - const sal_uInt16 nStep ((nAnchorIndex < nOtherIndex) ? +1 : -1); - sal_uInt16 nIndex (nAnchorIndex); - while (true) - { - rSelector.SelectPage(nIndex); - if (nIndex == nOtherIndex) - break; - nIndex = nIndex + nStep; - } - } -} - - - - -void NormalModeHandler::ResetButtonDownLocation (void) -{ - maButtonDownLocation = ::boost::optional<Point>(); -} - - - - -//===== MultiSelectionModeHandler ============================================= - -MultiSelectionModeHandler::MultiSelectionModeHandler ( - SlideSorter& rSlideSorter, - SelectionFunction& rSelectionFunction, - const Point& rMouseModelPosition, - const sal_uInt32 nEventCode) - : ModeHandler(rSlideSorter, rSelectionFunction, false), - meSelectionMode(SM_Normal), - maSecondCorner(rMouseModelPosition), - maSavedPointer(mrSlideSorter.GetContentWindow()->GetPointer()), - mnAnchorIndex(-1), - mnSecondIndex(-1), - maButtonBarLock(rSlideSorter) -{ - const Pointer aSelectionPointer (POINTER_TEXT); - mrSlideSorter.GetContentWindow()->SetPointer(aSelectionPointer); - SetSelectionModeFromModifier(nEventCode); -} - - - - - -MultiSelectionModeHandler::~MultiSelectionModeHandler (void) -{ - mrSlideSorter.GetContentWindow()->SetPointer(maSavedPointer); -} - - - - -SelectionFunction::Mode MultiSelectionModeHandler::GetMode (void) const -{ - return SelectionFunction::MultiSelectionMode; -} - - - - -void MultiSelectionModeHandler::Abort (void) -{ - mrSlideSorter.GetView().RequestRepaint(mrSlideSorter.GetModel().RestoreSelection()); -} - - - - -void MultiSelectionModeHandler::ProcessEvent ( - SelectionFunction::EventDescriptor& rDescriptor) -{ - // During a multi selection we do not want sudden jumps of the - // visible area caused by moving newly selected pages into view. - // Therefore disable that temporarily. The disabler object is - // released at the end of the event processing, after the focus and - // current slide have been updated. - VisibleAreaManager::TemporaryDisabler aDisabler (mrSlideSorter); - - ModeHandler::ProcessEvent(rDescriptor); -} - - - - -bool MultiSelectionModeHandler::ProcessButtonUpEvent ( - SelectionFunction::EventDescriptor& rDescriptor) -{ - if (Match(rDescriptor.mnEventCode, BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK)) - { - mrSelectionFunction.SwitchToNormalMode(); - return true; - } - else - return false; -} - - - - -bool MultiSelectionModeHandler::ProcessMotionEvent ( - SelectionFunction::EventDescriptor& rDescriptor) -{ - // The selection rectangle is visible. Handle events accordingly. - if (Match(rDescriptor.mnEventCode, MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK)) - { - SetSelectionModeFromModifier(rDescriptor.mnEventCode); - UpdatePosition(rDescriptor.maMousePosition, true); - rDescriptor.mbMakeSelectionVisible = false; - return true; - } - else - return false; -} - - - -bool MultiSelectionModeHandler::HandleUnprocessedEvent ( - SelectionFunction::EventDescriptor& rDescriptor) -{ - if ( ! ModeHandler::HandleUnprocessedEvent(rDescriptor)) - { - // If the event has not been processed then stop multi selection. - mrSelectionFunction.SwitchToNormalMode(); - ReprocessEvent(rDescriptor); - } - return true; -} - - - - -void MultiSelectionModeHandler::UpdatePosition ( - const Point& rMousePosition, - const bool bAllowAutoScroll) -{ - VisibleAreaManager::TemporaryDisabler aDisabler (mrSlideSorter); - - // Convert window coordinates into model coordinates (we need the - // window coordinates for auto-scrolling because that remains - // constant while scrolling.) - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - const Point aMouseModelPosition (pWindow->PixelToLogic(rMousePosition)); - - if ( ! (bAllowAutoScroll && mrSlideSorter.GetController().GetScrollBarManager().AutoScroll( - rMousePosition, - ::boost::bind( - &MultiSelectionModeHandler::UpdatePosition, - this, - rMousePosition, - false)))) - { - UpdateModelPosition(aMouseModelPosition); - } -} - - - - -void MultiSelectionModeHandler::SetSelectionModeFromModifier ( - const sal_uInt32 nEventCode) -{ - switch (nEventCode & MODIFIER_MASK) - { - case NO_MODIFIER: - SetSelectionMode(SM_Normal); - break; - - case SHIFT_MODIFIER: - SetSelectionMode(SM_Add); - break; - - case CONTROL_MODIFIER: - SetSelectionMode(SM_Toggle); - break; - } -} - - - - -void MultiSelectionModeHandler::SetSelectionMode (const SelectionMode eSelectionMode) -{ - if (meSelectionMode != eSelectionMode) - { - meSelectionMode = eSelectionMode; - UpdateSelection(); - } -} - - - - -void MultiSelectionModeHandler::UpdateSelectionState ( - const model::SharedPageDescriptor& rpDescriptor, - const bool bIsInSelection) const -{ - // Determine whether the page was selected before the rectangle - // selection was started. - const bool bWasSelected (rpDescriptor->HasState(model::PageDescriptor::ST_WasSelected)); - - // Combine the two selection states depending on the selection mode. - bool bSelect (false); - switch(meSelectionMode) - { - case SM_Normal: - bSelect = bIsInSelection; - break; - - case SM_Add: - bSelect = bIsInSelection || bWasSelected; - break; - - case SM_Toggle: - if (bIsInSelection) - bSelect = !bWasSelected; - else - bSelect = bWasSelected; - break; - } - - // Set the new selection state. - if (bSelect) - mrSlideSorter.GetController().GetPageSelector().SelectPage(rpDescriptor); - else - mrSlideSorter.GetController().GetPageSelector().DeselectPage(rpDescriptor); -} - - - - -void MultiSelectionModeHandler::UpdateModelPosition (const Point& rMouseModelPosition) -{ - maSecondCorner = rMouseModelPosition; - UpdateSelection(); -} - - - - -void MultiSelectionModeHandler::UpdateSelection (void) -{ - view::SlideSorterView::DrawLock aLock (mrSlideSorter); - - model::SlideSorterModel& rModel (mrSlideSorter.GetModel()); - const sal_Int32 nPageCount (rModel.GetPageCount()); - - const sal_Int32 nIndexUnderMouse ( - mrSlideSorter.GetView().GetLayouter().GetIndexAtPoint ( - maSecondCorner, - false, - false)); - if (nIndexUnderMouse>=0 && nIndexUnderMouse<nPageCount) - { - if (mnAnchorIndex < 0) - mnAnchorIndex = nIndexUnderMouse; - mnSecondIndex = nIndexUnderMouse; - - Range aRange (mnAnchorIndex, mnSecondIndex); - aRange.Justify(); - - for (sal_Int32 nIndex=0; nIndex<nPageCount; ++nIndex) - { - UpdateSelectionState(rModel.GetPageDescriptor(nIndex), aRange.IsInside(nIndex)); - } - } -} - - - - -//===== DragAndDropModeHandler ================================================ - -DragAndDropModeHandler::DragAndDropModeHandler ( - SlideSorter& rSlideSorter, - SelectionFunction& rSelectionFunction, - const Point& rMousePosition, - ::Window* pWindow) - : ModeHandler(rSlideSorter, rSelectionFunction, false) -{ - SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; - if (pDragTransferable==NULL && mrSlideSorter.GetViewShell() != NULL) - { - SlideSorterViewShell* pSlideSorterViewShell - = dynamic_cast<SlideSorterViewShell*>(mrSlideSorter.GetViewShell()); - if (pSlideSorterViewShell != NULL) - pSlideSorterViewShell->StartDrag(rMousePosition, pWindow); - pDragTransferable = SD_MOD()->pTransferDrag; - } - - mpDragAndDropContext.reset(new DragAndDropContext(mrSlideSorter)); - mrSlideSorter.GetController().GetInsertionIndicatorHandler()->Start( - pDragTransferable != NULL - && pDragTransferable->GetView()==&mrSlideSorter.GetView()); -} - - - - -DragAndDropModeHandler::~DragAndDropModeHandler (void) -{ - if (mpDragAndDropContext) - { - // Disconnect the substitution handler from this selection function. - mpDragAndDropContext->SetTargetSlideSorter(); - mpDragAndDropContext.reset(); - } - mrSlideSorter.GetController().GetInsertionIndicatorHandler()->End(Animator::AM_Animated); -} - - - - -SelectionFunction::Mode DragAndDropModeHandler::GetMode (void) const -{ - return SelectionFunction::DragAndDropMode; -} - - - - -void DragAndDropModeHandler::Abort (void) -{ - mrSlideSorter.GetController().GetClipboard().Abort(); - if (mpDragAndDropContext) - mpDragAndDropContext->Dispose(); - // mrSlideSorter.GetView().RequestRepaint(mrSlideSorter.GetModel().RestoreSelection()); -} - - - - -bool DragAndDropModeHandler::ProcessButtonUpEvent ( - SelectionFunction::EventDescriptor& rDescriptor) -{ - if (Match(rDescriptor.mnEventCode, BUTTON_UP | LEFT_BUTTON)) - { - // The following Process() call may lead to the desctruction - // of rDescriptor.mpHitDescriptor so release our reference to it. - rDescriptor.mpHitDescriptor.reset(); - mrSelectionFunction.SwitchToNormalMode(); - return true; - } - else - return false; -} - - - - -bool DragAndDropModeHandler::ProcessDragEvent (SelectionFunction::EventDescriptor& rDescriptor) -{ - OSL_ASSERT(mpDragAndDropContext); - - if (rDescriptor.mbIsLeaving) - { - mrSelectionFunction.SwitchToNormalMode(); - } - else if (mpDragAndDropContext) - { - mpDragAndDropContext->UpdatePosition( - rDescriptor.maMousePosition, - rDescriptor.meDragMode); - } - - return true; -} - - - - -//===== ButtonModeHandler ===================================================== - -ButtonModeHandler::ButtonModeHandler ( - SlideSorter& rSlideSorter, - SelectionFunction& rSelectionFunction) - : ModeHandler(rSlideSorter, rSelectionFunction, true) -{ -} - - - - -ButtonModeHandler::~ButtonModeHandler (void) -{ -} - - - - -SelectionFunction::Mode ButtonModeHandler::GetMode (void) const -{ - return SelectionFunction::ButtonMode; -} - - - - -void ButtonModeHandler::Abort (void) -{ -} - - - - -bool ButtonModeHandler::ProcessButtonDownEvent (SelectionFunction::EventDescriptor& rDescriptor) -{ - switch (rDescriptor.mnEventCode) - { - case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE | OVER_BUTTON: - case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE | OVER_BUTTON: - // Remember page and button index. When mouse button is - // released over same page and button then invoke action of that - // button. - mrSlideSorter.GetView().GetButtonBar().ProcessButtonDownEvent( - rDescriptor.mpHitDescriptor, - rDescriptor.maMouseModelPosition); - return true; - - default: - return false; - } -} - - - - -bool ButtonModeHandler::ProcessButtonUpEvent (SelectionFunction::EventDescriptor& rDescriptor) -{ - switch (rDescriptor.mnEventCode & BUTTON_MASK) - { - case LEFT_BUTTON: - mrSlideSorter.GetView().GetButtonBar().ProcessButtonUpEvent( - rDescriptor.mpHitDescriptor, - rDescriptor.maMouseModelPosition); - mrSelectionFunction.SwitchToNormalMode(); - return true; - } - - return false; -} - - - - -bool ButtonModeHandler::ProcessMotionEvent (SelectionFunction::EventDescriptor& rDescriptor) -{ - switch (rDescriptor.mnEventCode & (MOUSE_MOTION | BUTTON_MASK)) - { - case MOUSE_MOTION | LEFT_BUTTON: - mrSlideSorter.GetView().GetButtonBar().ProcessMouseMotionEvent( - rDescriptor.mpHitDescriptor, - rDescriptor.maMouseModelPosition, - true); - return true; - - case MOUSE_MOTION: - mrSlideSorter.GetView().GetButtonBar().ProcessMouseMotionEvent( - rDescriptor.mpHitDescriptor, - rDescriptor.maMouseModelPosition, - false); - return true; - } - - return false; -} - - - - -} } } // end of namespace ::sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx deleted file mode 100644 index 3d8726df6..000000000 --- a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx +++ /dev/null @@ -1,362 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "controller/SlsSelectionManager.hxx" - -#include "SlideSorter.hxx" -#include "SlsCommand.hxx" -#include "controller/SlideSorterController.hxx" -#include "controller/SlsAnimator.hxx" -#include "controller/SlsAnimationFunction.hxx" -#include "controller/SlsCurrentSlideManager.hxx" -#include "controller/SlsFocusManager.hxx" -#include "controller/SlsPageSelector.hxx" -#include "controller/SlsProperties.hxx" -#include "controller/SlsScrollBarManager.hxx" -#include "controller/SlsSlotManager.hxx" -#include "controller/SlsSelectionObserver.hxx" -#include "model/SlideSorterModel.hxx" -#include "model/SlsPageEnumerationProvider.hxx" -#include "model/SlsPageDescriptor.hxx" -#include "view/SlideSorterView.hxx" -#include "view/SlsLayouter.hxx" -#include "drawdoc.hxx" -#include "Window.hxx" -#include <svx/svxids.hrc> -#include <com/sun/star/drawing/XMasterPagesSupplier.hpp> -#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> - -#include "res_bmp.hrc" -#include "sdresid.hxx" -#include "strings.hrc" -#include "app.hrc" -#include "glob.hrc" - - -using namespace ::com::sun::star; -using namespace ::com::sun::star::drawing; -using namespace ::com::sun::star::uno; -using namespace ::sd::slidesorter::model; -using namespace ::sd::slidesorter::view; -using namespace ::sd::slidesorter::controller; - -namespace sd { namespace slidesorter { namespace controller { - - -class SelectionManager::PageInsertionListener - : public SfxListener -{ -public: - -}; - - -SelectionManager::SelectionManager (SlideSorter& rSlideSorter) - : mrSlideSorter(rSlideSorter), - mrController(rSlideSorter.GetController()), - maSelectionBeforeSwitch(), - mbIsMakeSelectionVisiblePending(true), - mnInsertionPosition(-1), - mnAnimationId(Animator::NotAnAnimationId), - maRequestedTopLeft(), - mpPageInsertionListener(), - mpSelectionObserver(new SelectionObserver(rSlideSorter)) -{ -} - - - - -SelectionManager::~SelectionManager (void) -{ - if (mnAnimationId != Animator::NotAnAnimationId) - mrController.GetAnimator()->RemoveAnimation(mnAnimationId); -} - - - - -void SelectionManager::DeleteSelectedPages (const bool bSelectFollowingPage) -{ - // Create some locks to prevent updates of the model, view, selection - // state while modifying any of them. - SlideSorterController::ModelChangeLock aLock (mrController); - SlideSorterView::DrawLock aDrawLock (mrSlideSorter); - PageSelector::UpdateLock aSelectionLock (mrSlideSorter); - - // Hide focus. - bool bIsFocusShowing = mrController.GetFocusManager().IsFocusShowing(); - if (bIsFocusShowing) - mrController.GetFocusManager().ToggleFocus(); - - // Store pointers to all selected page descriptors. This is necessary - // because the pages get deselected when the first one is deleted. - model::PageEnumeration aPageEnumeration ( - PageEnumerationProvider::CreateSelectedPagesEnumeration(mrSlideSorter.GetModel())); - ::std::vector<SdPage*> aSelectedPages; - sal_Int32 nNewCurrentSlide (-1); - while (aPageEnumeration.HasMoreElements()) - { - SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement()); - aSelectedPages.push_back(pDescriptor->GetPage()); - if (bSelectFollowingPage || nNewCurrentSlide<0) - nNewCurrentSlide = pDescriptor->GetPageIndex(); - } - if (aSelectedPages.empty()) - return; - - // Determine the slide to select (and thereby make the current slide) - // after the deletion. - if (bSelectFollowingPage) - nNewCurrentSlide -= aSelectedPages.size() - 1; - else - --nNewCurrentSlide; - - // The actual deletion of the selected pages is done in one of two - // helper functions. They are specialized for normal respectively for - // master pages. - mrSlideSorter.GetView().BegUndo (SdResId(STR_UNDO_DELETEPAGES)); - if (mrSlideSorter.GetModel().GetEditMode() == EM_PAGE) - DeleteSelectedNormalPages(aSelectedPages); - else - DeleteSelectedMasterPages(aSelectedPages); - mrSlideSorter.GetView().EndUndo (); - - mrController.HandleModelChange(); - aLock.Release(); - - // Show focus and move it to next valid location. - if (bIsFocusShowing) - mrController.GetFocusManager().ToggleFocus(); - - // Set the new current slide. - if (nNewCurrentSlide < 0) - nNewCurrentSlide = 0; - else if (nNewCurrentSlide >= mrSlideSorter.GetModel().GetPageCount()) - nNewCurrentSlide = mrSlideSorter.GetModel().GetPageCount()-1; - mrController.GetPageSelector().CountSelectedPages(); - mrController.GetPageSelector().SelectPage(nNewCurrentSlide); - mrController.GetFocusManager().SetFocusedPage(nNewCurrentSlide); -} - - - - -void SelectionManager::DeleteSelectedNormalPages (const ::std::vector<SdPage*>& rSelectedPages) -{ - // Prepare the deletion via the UNO API. - OSL_ASSERT(mrSlideSorter.GetModel().GetEditMode() == EM_PAGE); - - try - { - Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier( mrSlideSorter.GetModel().GetDocument()->getUnoModel(), UNO_QUERY_THROW ); - Reference<drawing::XDrawPages> xPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW ); - - // Iterate over all pages that where seleted when this method was called - // and delete the draw page the notes page. The iteration is done in - // reverse order so that when one slide is not deleted (to avoid an - // empty document) the remaining slide is the first one. - ::std::vector<SdPage*>::const_reverse_iterator aI; - for (aI=rSelectedPages.rbegin(); aI!=rSelectedPages.rend(); ++aI) - { - // Do not delete the last slide in the document. - if (xPages->getCount() <= 1) - break; - - const sal_uInt16 nPage (model::FromCoreIndex((*aI)->GetPageNum())); - - Reference< XDrawPage > xPage( xPages->getByIndex( nPage ), UNO_QUERY_THROW ); - xPages->remove(xPage); - } - } - catch( Exception& ) - { - OSL_FAIL("SelectionManager::DeleteSelectedNormalPages(), exception caught!"); - } -} - - - - -void SelectionManager::DeleteSelectedMasterPages (const ::std::vector<SdPage*>& rSelectedPages) -{ - // Prepare the deletion via the UNO API. - OSL_ASSERT(mrSlideSorter.GetModel().GetEditMode() == EM_MASTERPAGE); - - try - { - Reference<drawing::XMasterPagesSupplier> xDrawPagesSupplier( mrSlideSorter.GetModel().GetDocument()->getUnoModel(), UNO_QUERY_THROW ); - Reference<drawing::XDrawPages> xPages( xDrawPagesSupplier->getMasterPages(), UNO_QUERY_THROW ); - - // Iterate over all pages that where seleted when this method was called - // and delete the draw page the notes page. The iteration is done in - // reverse order so that when one slide is not deleted (to avoid an - // empty document) the remaining slide is the first one. - ::std::vector<SdPage*>::const_reverse_iterator aI; - for (aI=rSelectedPages.rbegin(); aI!=rSelectedPages.rend(); ++aI) - { - // Do not delete the last slide in the document. - if (xPages->getCount() <= 1) - break; - - const sal_uInt16 nPage (model::FromCoreIndex((*aI)->GetPageNum())); - - Reference< XDrawPage > xPage( xPages->getByIndex( nPage ), UNO_QUERY_THROW ); - xPages->remove(xPage); - } - } - catch( Exception& ) - { - OSL_FAIL("SelectionManager::DeleteSelectedMasterPages(), exception caught!"); - } -} - - - - -void SelectionManager::SelectionHasChanged (const bool bMakeSelectionVisible) -{ - if (bMakeSelectionVisible) - mbIsMakeSelectionVisiblePending = true; - - ViewShell* pViewShell = mrSlideSorter.GetViewShell(); - if (pViewShell != NULL) - { - pViewShell->Invalidate (SID_EXPAND_PAGE); - pViewShell->Invalidate (SID_SUMMARY_PAGE); - pViewShell->Invalidate(SID_SHOW_SLIDE); - pViewShell->Invalidate(SID_HIDE_SLIDE); - pViewShell->Invalidate(SID_DELETE_PAGE); - pViewShell->Invalidate(SID_DELETE_MASTER_PAGE); - pViewShell->Invalidate(SID_ASSIGN_LAYOUT); - - // StatusBar - pViewShell->Invalidate (SID_STATUS_PAGE); - pViewShell->Invalidate (SID_STATUS_LAYOUT); - - OSL_ASSERT(mrController.GetCurrentSlideManager()); - SharedPageDescriptor pDescriptor(mrController.GetCurrentSlideManager()->GetCurrentSlide()); - if (pDescriptor.get() != NULL) - pViewShell->UpdatePreview(pDescriptor->GetPage()); - - // Tell the slection change listeners that the selection has changed. - ::std::vector<Link>::iterator iListener (maSelectionChangeListeners.begin()); - ::std::vector<Link>::iterator iEnd (maSelectionChangeListeners.end()); - for (; iListener!=iEnd; ++iListener) - { - iListener->Call(NULL); - } - - // Reset the insertion position: until set again it is calculated from - // the current selection. - mnInsertionPosition = -1; - } -} - - - - -void SelectionManager::AddSelectionChangeListener (const Link& rListener) -{ - if (::std::find ( - maSelectionChangeListeners.begin(), - maSelectionChangeListeners.end(), - rListener) == maSelectionChangeListeners.end()) - { - maSelectionChangeListeners.push_back (rListener); - } -} - - - - -void SelectionManager::RemoveSelectionChangeListener(const Link&rListener) -{ - maSelectionChangeListeners.erase ( - ::std::find ( - maSelectionChangeListeners.begin(), - maSelectionChangeListeners.end(), - rListener)); -} - - - - -sal_Int32 SelectionManager::GetInsertionPosition (void) const -{ - sal_Int32 nInsertionPosition (mnInsertionPosition); - if (nInsertionPosition < 0) - { - model::PageEnumeration aSelectedPages - (model::PageEnumerationProvider::CreateSelectedPagesEnumeration( - mrSlideSorter.GetModel())); - // Initialize (for the case of an empty selection) with the position - // at the end of the document. - nInsertionPosition = mrSlideSorter.GetModel().GetPageCount(); - while (aSelectedPages.HasMoreElements()) - { - const sal_Int32 nPosition (aSelectedPages.GetNextElement()->GetPage()->GetPageNum()); - // Convert *2+1 index to straight index (n-1)/2 after the page - // (+1). - nInsertionPosition = model::FromCoreIndex(nPosition) + 1; - } - - } - return nInsertionPosition; -} - - - - -void SelectionManager::SetInsertionPosition (const sal_Int32 nInsertionPosition) -{ - if (nInsertionPosition < 0) - mnInsertionPosition = -1; - else if (nInsertionPosition > mrSlideSorter.GetModel().GetPageCount()) - { - // Assert but then ignore invalid values. - OSL_ASSERT(nInsertionPosition<=mrSlideSorter.GetModel().GetPageCount()); - return; - } - else - mnInsertionPosition = nInsertionPosition; -} - - - - -::boost::shared_ptr<SelectionObserver> SelectionManager::GetSelectionObserver (void) const -{ - return mpSelectionObserver; -} - -} } } // end of namespace ::sd::slidesorter - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionObserver.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionObserver.cxx deleted file mode 100644 index 833e7df81..000000000 --- a/sd/source/ui/slidesorter/controller/SlsSelectionObserver.cxx +++ /dev/null @@ -1,173 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "SlideSorter.hxx" -#include "controller/SlideSorterController.hxx" -#include "controller/SlsSelectionManager.hxx" -#include "controller/SlsSelectionObserver.hxx" -#include "controller/SlsPageSelector.hxx" -#include "controller/SlsFocusManager.hxx" -#include "model/SlideSorterModel.hxx" -#include "model/SlsPageDescriptor.hxx" -#include <svx/svdmodel.hxx> -#include "drawdoc.hxx" - - -namespace sd { namespace slidesorter { namespace controller { - -SelectionObserver::Context::Context (SlideSorter& rSlideSorter) - : mpSelectionObserver( - rSlideSorter.GetController().GetSelectionManager()->GetSelectionObserver()) -{ - if (mpSelectionObserver) - mpSelectionObserver->StartObservation(); -} - - - - -SelectionObserver::Context::~Context(void) -{ - if (mpSelectionObserver) - mpSelectionObserver->EndObservation(); -} - - - - -void SelectionObserver::Context::Abort(void) -{ - if (mpSelectionObserver) - { - mpSelectionObserver->AbortObservation(); - mpSelectionObserver.reset(); - } -} - - - - -//===== SelectionObserver ===================================================== - -SelectionObserver::SelectionObserver (SlideSorter& rSlideSorter) - : mrSlideSorter(rSlideSorter), - mpDocument(mrSlideSorter.GetModel().GetDocument()), - mbIsOvservationActive(false), - maInsertedPages(), - maDeletedPages() -{ -} - - - - -SelectionObserver::~SelectionObserver (void) -{ -} - - - - -void SelectionObserver::NotifyPageEvent (const SdrPage* pSdrPage) -{ - if ( ! mbIsOvservationActive) - return; - - const SdPage* pPage = dynamic_cast<const SdPage*>(pSdrPage); - if (pPage == NULL) - return; - - if (pPage->IsInserted()) - maInsertedPages.push_back(pPage); - else - { - ::std::vector<const SdPage*>::iterator iPage( - ::std::find(maInsertedPages.begin(), maInsertedPages.end(), pPage)); - if (iPage != maInsertedPages.end()) - maInsertedPages.erase(iPage); - - maDeletedPages.push_back(pPage->GetPageNum()); - } -} - - - -void SelectionObserver::StartObservation (void) -{ - OSL_ASSERT(!mbIsOvservationActive); - maInsertedPages.clear(); - maDeletedPages.clear(); - mbIsOvservationActive = true; -} - - - - -void SelectionObserver::AbortObservation (void) -{ - OSL_ASSERT(mbIsOvservationActive); - mbIsOvservationActive = false; - maInsertedPages.clear(); - maDeletedPages.clear(); -} - - - - -void SelectionObserver::EndObservation (void) -{ - OSL_ASSERT(mbIsOvservationActive); - mbIsOvservationActive = false; - - PageSelector& rSelector (mrSlideSorter.GetController().GetPageSelector()); - PageSelector::UpdateLock aUpdateLock (mrSlideSorter); - rSelector.DeselectAllPages(); - if ( ! maInsertedPages.empty()) - { - // Select the inserted pages. - for (::std::vector<const SdPage*>::const_iterator - iPage(maInsertedPages.begin()), - iEnd(maInsertedPages.end()); - iPage!=iEnd; - ++iPage) - { - rSelector.SelectPage(*iPage); - } - maInsertedPages.clear(); - } - maDeletedPages.clear(); - - aUpdateLock.Release(); - mrSlideSorter.GetController().GetFocusManager().SetFocusedPageToCurrentPage(); - -} - - - -} } } // end of namespace ::sd::slidesorter::controller diff --git a/sd/source/ui/slidesorter/controller/SlsSlideFunction.cxx b/sd/source/ui/slidesorter/controller/SlsSlideFunction.cxx deleted file mode 100644 index f53719fa0..000000000 --- a/sd/source/ui/slidesorter/controller/SlsSlideFunction.cxx +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "controller/SlsSlideFunction.hxx" - -#include "SlideSorter.hxx" -#include "controller/SlideSorterController.hxx" -#include "view/SlideSorterView.hxx" -#include "model/SlideSorterModel.hxx" - - -namespace sd { namespace slidesorter { namespace controller { - -TYPEINIT1(SlideFunction, FuPoor); - - -SlideFunction::SlideFunction ( - SlideSorter& rSlideSorter, - SfxRequest& rRequest) - : FuPoor ( - rSlideSorter.GetViewShell(), - rSlideSorter.GetContentWindow().get(), - &rSlideSorter.GetView(), - rSlideSorter.GetModel().GetDocument(), - rRequest) -{ -} - -void SlideFunction::ScrollStart (void) -{ -} - -void SlideFunction::ScrollEnd (void) -{ -} - -sal_Bool SlideFunction::MouseMove(const MouseEvent& ) -{ - return sal_False; -} - -sal_Bool SlideFunction::MouseButtonUp(const MouseEvent& ) -{ - return sal_False; - -} - -sal_Bool SlideFunction::MouseButtonDown(const MouseEvent& ) -{ - return sal_False; -} - -} } } // end of namespace ::sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx deleted file mode 100644 index cd2b1d3e9..000000000 --- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx +++ /dev/null @@ -1,1341 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include <com/sun/star/presentation/XPresentation2.hpp> - -#include <editeng/outlobj.hxx> - -#include "controller/SlsSlotManager.hxx" -#include "SlideSorter.hxx" -#include "SlideSorterViewShell.hxx" -#include "controller/SlideSorterController.hxx" -#include "controller/SlsClipboard.hxx" -#include "controller/SlsCurrentSlideManager.hxx" -#include "controller/SlsFocusManager.hxx" -#include "controller/SlsInsertionIndicatorHandler.hxx" -#include "controller/SlsPageSelector.hxx" -#include "controller/SlsSelectionFunction.hxx" -#include "controller/SlsSelectionManager.hxx" -#include "controller/SlsSelectionObserver.hxx" -#include "SlsCommand.hxx" -#include "model/SlideSorterModel.hxx" -#include "model/SlsPageEnumerationProvider.hxx" -#include "model/SlsPageDescriptor.hxx" -#include "view/SlideSorterView.hxx" -#include "view/SlsLayouter.hxx" -#include "framework/FrameworkHelper.hxx" -#include "Window.hxx" -#include "fupoor.hxx" -#include "fuzoom.hxx" -#include "fucushow.hxx" -#include "fusldlg.hxx" -#include "fuexpand.hxx" -#include "fusumry.hxx" -#include "fuscale.hxx" -#include "slideshow.hxx" -#include "app.hrc" -#include "strings.hrc" -#include "sdresid.hxx" -#include "drawdoc.hxx" -#include "DrawDocShell.hxx" -#include "ViewShellBase.hxx" -#include "ViewShellImplementation.hxx" -#include "sdattr.hxx" -#include "FrameView.hxx" -#include "zoomlist.hxx" -#include "sdpage.hxx" -#include "sdxfer.hxx" -#include "helpids.h" -#include "glob.hrc" -#include "unmodpg.hxx" -#include "DrawViewShell.hxx" - -#include <sfx2/request.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/bindings.hxx> -#include <sfx2/dispatch.hxx> -#include <svx/svxids.hrc> -#include <svx/zoomitem.hxx> -#include <svx/svxdlg.hxx> -#include <svx/dialogs.hrc> -#include <vcl/msgbox.hxx> -#include <svl/intitem.hxx> -#include <svl/whiter.hxx> -#include <svl/itempool.hxx> -#include <svl/aeitem.hxx> -#include <com/sun/star/presentation/FadeEffect.hpp> -#include <com/sun/star/drawing/XMasterPagesSupplier.hpp> -#include <com/sun/star/drawing/XDrawPages.hpp> -#include <vcl/svapp.hxx> - -#include <boost/bind.hpp> - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::presentation; - -namespace sd { namespace slidesorter { namespace controller { - -namespace { - -/** The state of a set of slides with respect to being excluded from the - slide show. -*/ -enum SlideExclusionState {UNDEFINED, EXCLUDED, INCLUDED, MIXED}; - -/** Return for the given set of slides whether they included are - excluded from the slide show. -*/ -SlideExclusionState GetSlideExclusionState (model::PageEnumeration& rPageSet); - -} // end of anonymous namespace - - - -SlotManager::SlotManager (SlideSorter& rSlideSorter) - : mrSlideSorter(rSlideSorter), - maCommandQueue() -{ -} - - - - -SlotManager::~SlotManager (void) -{ -} - - - - -void SlotManager::FuTemporary (SfxRequest& rRequest) -{ - SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument(); - - SlideSorterViewShell* pShell - = dynamic_cast<SlideSorterViewShell*>(mrSlideSorter.GetViewShell()); - if (pShell == NULL) - return; - - switch (rRequest.GetSlot()) - { - case SID_PRESENTATION: - case SID_REHEARSE_TIMINGS: - ShowSlideShow (rRequest); - pShell->Cancel(); - rRequest.Done(); - break; - - case SID_HIDE_SLIDE: - ChangeSlideExclusionState(model::SharedPageDescriptor(), true); - break; - - case SID_SHOW_SLIDE: - ChangeSlideExclusionState(model::SharedPageDescriptor(), false); - break; - - case SID_PAGES_PER_ROW: - if (rRequest.GetArgs() != NULL) - { - SFX_REQUEST_ARG(rRequest, pPagesPerRow, SfxUInt16Item, - SID_PAGES_PER_ROW, sal_False); - if (pPagesPerRow != NULL) - { - sal_Int32 nColumnCount = pPagesPerRow->GetValue(); - // Force the given number of columns by setting - // the minimal and maximal number of columns to - // the same value. - mrSlideSorter.GetView().GetLayouter().SetColumnCount ( - nColumnCount, nColumnCount); - // Force a repaint and re-layout. - pShell->ArrangeGUIElements (); - // Rearrange the UI-elements controlled by the - // controller and force a rearrangement of the - // view. - mrSlideSorter.GetController().Rearrange(true); - } - } - rRequest.Done(); - break; - - case SID_SELECTALL: - mrSlideSorter.GetController().GetPageSelector().SelectAllPages(); - rRequest.Done(); - break; - - case SID_SLIDE_TRANSITIONS_PANEL: - { - // Make the slide transition panel visible (expand it) - // in the tool pane. - if (mrSlideSorter.GetViewShellBase() != NULL) - framework::FrameworkHelper::Instance(*mrSlideSorter.GetViewShellBase()) - ->RequestTaskPanel(sd::framework::FrameworkHelper::msSlideTransitionTaskPanelURL); - rRequest.Ignore (); - break; - } - - case SID_PRESENTATION_DLG: - FuSlideShowDlg::Create ( - pShell, - mrSlideSorter.GetContentWindow().get(), - &mrSlideSorter.GetView(), - pDocument, - rRequest); - break; - - case SID_CUSTOMSHOW_DLG: - FuCustomShowDlg::Create ( - pShell, - mrSlideSorter.GetContentWindow().get(), - &mrSlideSorter.GetView(), - pDocument, - rRequest); - break; - - case SID_EXPAND_PAGE: - FuExpandPage::Create ( - pShell, - mrSlideSorter.GetContentWindow().get(), - &mrSlideSorter.GetView(), - pDocument, - rRequest); - break; - - case SID_SUMMARY_PAGE: - FuSummaryPage::Create ( - pShell, - mrSlideSorter.GetContentWindow().get(), - &mrSlideSorter.GetView(), - pDocument, - rRequest); - break; - - case SID_INSERTPAGE: - case SID_INSERT_MASTER_PAGE: - InsertSlide(rRequest); - rRequest.Done(); - break; - - case SID_DUPLICATE_PAGE: - DuplicateSelectedSlides(rRequest); - rRequest.Done(); - break; - - case SID_DELETE_PAGE: - case SID_DELETE_MASTER_PAGE: - case SID_DELETE: // we need SID_CUT to handle the delete key - // (DEL -> accelerator -> SID_CUT). - if (mrSlideSorter.GetModel().GetPageCount() > 1) - { - mrSlideSorter.GetController().GetSelectionManager()->DeleteSelectedPages(); - } - - rRequest.Done(); - break; - - case SID_RENAMEPAGE: - case SID_RENAME_MASTER_PAGE: - RenameSlide (); - rRequest.Done (); - break; - - case SID_ASSIGN_LAYOUT: - { - pShell->mpImpl->AssignLayout( rRequest, mrSlideSorter.GetModel().GetPageType() ); - rRequest.Done (); - } - break; - - default: - break; - } -} - - - - -void SlotManager::FuPermanent (SfxRequest& rRequest) -{ - ViewShell* pShell = mrSlideSorter.GetViewShell(); - if (pShell == NULL) - return; - - if(pShell->GetCurrentFunction().is()) - { - FunctionReference xEmpty; - if (pShell->GetOldFunction() == pShell->GetCurrentFunction()) - pShell->SetOldFunction(xEmpty); - - pShell->GetCurrentFunction()->Deactivate(); - pShell->SetCurrentFunction(xEmpty); - } - - switch(rRequest.GetSlot()) - { - case SID_OBJECT_SELECT: - pShell->SetCurrentFunction( SelectionFunction::Create(mrSlideSorter, rRequest) ); - rRequest.Done(); - break; - - default: - break; - } - - if(pShell->GetOldFunction().is()) - { - pShell->GetOldFunction()->Deactivate(); - FunctionReference xEmpty; - pShell->SetOldFunction(xEmpty); - } - - if(pShell->GetCurrentFunction().is()) - { - pShell->GetCurrentFunction()->Activate(); - pShell->SetOldFunction(pShell->GetCurrentFunction()); - } - - //! das ist nur bis das ENUM-Slots sind - // Invalidate( SID_OBJECT_SELECT ); -} - -void SlotManager::FuSupport (SfxRequest& rRequest) -{ - switch (rRequest.GetSlot()) - { - case SID_STYLE_FAMILY: - if (rRequest.GetArgs() != NULL) - { - SdDrawDocument* pDocument - = mrSlideSorter.GetModel().GetDocument(); - if (pDocument != NULL) - { - const SfxPoolItem& rItem ( - rRequest.GetArgs()->Get(SID_STYLE_FAMILY)); - pDocument->GetDocSh()->SetStyleFamily( - static_cast<const SfxUInt16Item&>(rItem).GetValue()); - } - } - break; - - case SID_PASTE: - { - SdTransferable* pTransferClip = SD_MOD()->pTransferClip; - if( pTransferClip ) - { - SfxObjectShell* pTransferDocShell = pTransferClip->GetDocShell(); - - DrawDocShell* pDocShell = dynamic_cast<DrawDocShell*>(pTransferDocShell); - if (pDocShell && pDocShell->GetDoc()->GetPageCount() > 1) - { - mrSlideSorter.GetController().GetClipboard().HandleSlotCall(rRequest); - break; - } - } - ViewShellBase* pBase = mrSlideSorter.GetViewShellBase(); - if (pBase != NULL) - { - ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( - ::boost::dynamic_pointer_cast<DrawViewShell>(pBase->GetMainViewShell())); - if (pDrawViewShell.get() != NULL) - pDrawViewShell->FuSupport(rRequest); - } - } - break; - - case SID_CUT: - case SID_COPY: - case SID_DELETE: - mrSlideSorter.GetController().GetClipboard().HandleSlotCall(rRequest); - break; - - case SID_DRAWINGMODE: - case SID_NOTESMODE: - case SID_HANDOUTMODE: - case SID_DIAMODE: - case SID_OUTLINEMODE: - { - ViewShellBase* pBase = mrSlideSorter.GetViewShellBase(); - if (pBase != NULL) - { - framework::FrameworkHelper::Instance(*pBase)->HandleModeChangeSlot( - rRequest.GetSlot(), rRequest); - rRequest.Done(); - } - break; - } - - case SID_UNDO: - { - SlideSorterViewShell* pViewShell - = dynamic_cast<SlideSorterViewShell*>(mrSlideSorter.GetViewShell()); - if (pViewShell != NULL) - { - view::SlideSorterView::DrawLock aDrawLock (mrSlideSorter); - SlideSorterController::ModelChangeLock aModelLock (mrSlideSorter.GetController()); - PageSelector::UpdateLock aUpdateLock (mrSlideSorter); - SelectionObserver::Context aContext (mrSlideSorter); - pViewShell->ImpSidUndo (sal_False, rRequest); - } - break; - } - - case SID_REDO: - { - SlideSorterViewShell* pViewShell - = dynamic_cast<SlideSorterViewShell*>(mrSlideSorter.GetViewShell()); - if (pViewShell != NULL) - { - view::SlideSorterView::DrawLock aDrawLock (mrSlideSorter); - SlideSorterController::ModelChangeLock aModelLock (mrSlideSorter.GetController()); - PageSelector::UpdateLock aUpdateLock (mrSlideSorter); - SelectionObserver::Context aContext (mrSlideSorter); - pViewShell->ImpSidRedo (sal_False, rRequest); - } - break; - } - - default: - break; - } -} - - - - -void SlotManager::ExecCtrl (SfxRequest& rRequest) -{ - ViewShell* pViewShell = mrSlideSorter.GetViewShell(); - sal_uInt16 nSlot = rRequest.GetSlot(); - switch (nSlot) - { - case SID_RELOAD: - { - // Undo-Manager leeren - mrSlideSorter.GetModel().GetDocument()->GetDocSh()->ClearUndoBuffer(); - - // Normale Weiterleitung an ViewFrame zur Ausfuehrung - if (pViewShell != NULL) - pViewShell->GetViewFrame()->ExecuteSlot(rRequest); - - // Muss sofort beendet werden - return; - } - - case SID_OUTPUT_QUALITY_COLOR: - case SID_OUTPUT_QUALITY_GRAYSCALE: - case SID_OUTPUT_QUALITY_BLACKWHITE: - case SID_OUTPUT_QUALITY_CONTRAST: - { - // flush page cache - if (pViewShell != NULL) - pViewShell->ExecReq (rRequest); - break; - } - - case SID_MAIL_SCROLLBODY_PAGEDOWN: - { - if (pViewShell != NULL) - pViewShell->ExecReq (rRequest); - break; - } - - case SID_OPT_LOCALE_CHANGED: - { - mrSlideSorter.GetController().UpdateAllPages(); - if (pViewShell != NULL) - pViewShell->UpdatePreview (pViewShell->GetActualPage()); - rRequest.Done(); - break; - } - - case SID_SEARCH_DLG: - // We have to handle the SID_SEARCH_DLG slot explicitly because - // in some cases (when the slide sorter is displayed in the - // center pane) we want to disable the search dialog. Therefore - // we have to handle the execution of that slot as well. - // We try to do that by forwarding the request to the view frame - // of the view shell. - if (pViewShell != NULL) - pViewShell->GetViewFrame()->ExecuteSlot(rRequest); - break; - - default: - break; - } -} - - - - -void SlotManager::GetAttrState (SfxItemSet& rSet) -{ - // Iteratate over all items. - SfxWhichIter aIter (rSet); - sal_uInt16 nWhich = aIter.FirstWhich(); - while (nWhich) - { - sal_uInt16 nSlotId (nWhich); - if (SfxItemPool::IsWhich(nWhich) && mrSlideSorter.GetViewShell()!=NULL) - nSlotId = mrSlideSorter.GetViewShell()->GetPool().GetSlotId(nWhich); - switch (nSlotId) - { - case SID_PAGES_PER_ROW: - rSet.Put ( - SfxUInt16Item ( - nSlotId, - (sal_uInt16)mrSlideSorter.GetView().GetLayouter().GetColumnCount() - ) - ); - break; - } - nWhich = aIter.NextWhich(); - } -} - -void SlotManager::GetMenuState (SfxItemSet& rSet) -{ - EditMode eEditMode = mrSlideSorter.GetModel().GetEditMode(); - ViewShell* pShell = mrSlideSorter.GetViewShell(); - DrawDocShell* pDocShell = mrSlideSorter.GetModel().GetDocument()->GetDocSh(); - - if (pShell!=NULL && pShell->GetCurrentFunction().is()) - { - sal_uInt16 nSId = pShell->GetCurrentFunction()->GetSlotID(); - - rSet.Put( SfxBoolItem( nSId, sal_True ) ); - } - rSet.Put( SfxBoolItem( SID_DRAWINGMODE, sal_False ) ); - rSet.Put( SfxBoolItem( SID_DIAMODE, sal_True ) ); - rSet.Put( SfxBoolItem( SID_OUTLINEMODE, sal_False ) ); - rSet.Put( SfxBoolItem( SID_NOTESMODE, sal_False ) ); - rSet.Put( SfxBoolItem( SID_HANDOUTMODE, sal_False ) ); - - // Vorlagenkatalog darf nicht aufgerufen werden - rSet.DisableItem(SID_STYLE_CATALOG); - - if (pShell!=NULL && pShell->IsMainViewShell()) - { - rSet.DisableItem(SID_SPELL_DIALOG); - rSet.DisableItem(SID_SEARCH_DLG); - } - - if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_EXPAND_PAGE)) - { - bool bDisable = true; - if (eEditMode == EM_PAGE) - { - // At least one of the selected pages has to contain an outline - // presentation objects in order to enable the expand page menu - // entry. - model::PageEnumeration aSelectedPages ( - model::PageEnumerationProvider::CreateSelectedPagesEnumeration( - mrSlideSorter.GetModel())); - while (aSelectedPages.HasMoreElements()) - { - SdPage* pPage = aSelectedPages.GetNextElement()->GetPage(); - SdrObject* pObj = pPage->GetPresObj(PRESOBJ_OUTLINE); - if (pObj!=NULL ) - { - if( !pObj->IsEmptyPresObj() ) - { - bDisable = false; - } - else - { - // check if the object is in edit, than its temporarely not empty - SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj ); - if( pTextObj ) - { - OutlinerParaObject* pParaObj = pTextObj->GetEditOutlinerParaObject(); - if( pParaObj ) - { - delete pParaObj; - bDisable = false; - } - } - } - } - } - } - - if (bDisable) - rSet.DisableItem (SID_EXPAND_PAGE); - } - - if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_SUMMARY_PAGE)) - { - bool bDisable = true; - if (eEditMode == EM_PAGE) - { - // At least one of the selected pages has to contain a title - // presentation objects in order to enable the summary page menu - // entry. - model::PageEnumeration aSelectedPages ( - model::PageEnumerationProvider::CreateSelectedPagesEnumeration( - mrSlideSorter.GetModel())); - while (aSelectedPages.HasMoreElements()) - { - SdPage* pPage = aSelectedPages.GetNextElement()->GetPage(); - SdrObject* pObj = pPage->GetPresObj(PRESOBJ_TITLE); - - if (pObj!=NULL && !pObj->IsEmptyPresObj()) - bDisable = false; - } - } - if (bDisable) - rSet.DisableItem (SID_SUMMARY_PAGE); - } - - // Starten der Praesentation moeglich? - if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PRESENTATION ) || - SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_REHEARSE_TIMINGS ) ) - { - sal_Bool bDisable = sal_True; - model::PageEnumeration aAllPages ( - model::PageEnumerationProvider::CreateAllPagesEnumeration(mrSlideSorter.GetModel())); - while (aAllPages.HasMoreElements()) - { - SdPage* pPage = aAllPages.GetNextElement()->GetPage(); - - if( !pPage->IsExcluded() ) - bDisable = sal_False; - } - if( bDisable || pDocShell->IsPreview()) - { - rSet.DisableItem( SID_PRESENTATION ); - rSet.DisableItem( SID_REHEARSE_TIMINGS ); - } - } - - - // Disable the rename slots when there are no or more than one slides/master - // pages selected. - if (rSet.GetItemState(SID_RENAMEPAGE) == SFX_ITEM_AVAILABLE - || rSet.GetItemState(SID_RENAME_MASTER_PAGE) == SFX_ITEM_AVAILABLE) - { - if (mrSlideSorter.GetController().GetPageSelector().GetSelectedPageCount() != 1) - { - rSet.DisableItem(SID_RENAMEPAGE); - rSet.DisableItem(SID_RENAME_MASTER_PAGE); - } - } - - if (rSet.GetItemState(SID_HIDE_SLIDE) == SFX_ITEM_AVAILABLE - || rSet.GetItemState(SID_SHOW_SLIDE) == SFX_ITEM_AVAILABLE) - { - model::PageEnumeration aSelectedPages ( - model::PageEnumerationProvider::CreateSelectedPagesEnumeration( - mrSlideSorter.GetModel())); - const SlideExclusionState eState (GetSlideExclusionState(aSelectedPages)); - switch (eState) - { - case MIXED: - // Show both entries. - break; - - case EXCLUDED: - rSet.DisableItem(SID_HIDE_SLIDE); - break; - - case INCLUDED: - rSet.DisableItem(SID_SHOW_SLIDE); - break; - - case UNDEFINED: - rSet.DisableItem(SID_HIDE_SLIDE); - rSet.DisableItem(SID_SHOW_SLIDE); - break; - } - } - - - PageKind ePageKind = mrSlideSorter.GetModel().GetPageType(); - if ((eEditMode == EM_MASTERPAGE) && (ePageKind != PK_HANDOUT)) - { - rSet.DisableItem(SID_ASSIGN_LAYOUT); - } - - if ((eEditMode == EM_MASTERPAGE) || (ePageKind==PK_NOTES)) - { - rSet.DisableItem(SID_INSERTPAGE); - } - - // Disable some slots when in master page mode. - if (eEditMode == EM_MASTERPAGE) - { - if (rSet.GetItemState(SID_INSERTPAGE) == SFX_ITEM_AVAILABLE) - rSet.DisableItem(SID_INSERTPAGE); - if (rSet.GetItemState(SID_DUPLICATE_PAGE) == SFX_ITEM_AVAILABLE) - rSet.DisableItem(SID_DUPLICATE_PAGE); - } -} - - - - -void SlotManager::GetClipboardState ( SfxItemSet& rSet) -{ - SdTransferable* pTransferClip = SD_MOD()->pTransferClip; - - if (rSet.GetItemState(SID_PASTE) == SFX_ITEM_AVAILABLE - || rSet.GetItemState(SID_PASTE_SPECIAL) == SFX_ITEM_AVAILABLE) - { - // Keine eigenen Clipboard-Daten? - if ( !pTransferClip || !pTransferClip->GetDocShell() ) - { - rSet.DisableItem(SID_PASTE); - rSet.DisableItem(SID_PASTE_SPECIAL); - } - else - { - SfxObjectShell* pTransferDocShell = pTransferClip->GetDocShell(); - - if( !pTransferDocShell || ( (DrawDocShell*) pTransferDocShell)->GetDoc()->GetPageCount() <= 1 ) - { - bool bIsPastingSupported (false); - - // No or just one page. Check if there is anything that can be - // pasted via a DrawViewShell. - ViewShellBase* pBase = mrSlideSorter.GetViewShellBase(); - if (pBase != NULL) - { - ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( - ::boost::dynamic_pointer_cast<DrawViewShell>(pBase->GetMainViewShell())); - if (pDrawViewShell.get() != NULL) - { - TransferableDataHelper aDataHelper ( - TransferableDataHelper::CreateFromSystemClipboard( - pDrawViewShell->GetActiveWindow())); - if (aDataHelper.GetFormatCount() > 0) - bIsPastingSupported = true; - } - } - - if ( ! bIsPastingSupported) - { - rSet.DisableItem(SID_PASTE); - rSet.DisableItem(SID_PASTE_SPECIAL); - } - } - } - } - - // Cut, copy and paste of master pages is not yet implemented properly - if (rSet.GetItemState(SID_COPY) == SFX_ITEM_AVAILABLE - || rSet.GetItemState(SID_PASTE) == SFX_ITEM_AVAILABLE - || rSet.GetItemState(SID_PASTE_SPECIAL) == SFX_ITEM_AVAILABLE - || rSet.GetItemState(SID_CUT) == SFX_ITEM_AVAILABLE) - { - if (mrSlideSorter.GetModel().GetEditMode() == EM_MASTERPAGE) - { - if (rSet.GetItemState(SID_CUT) == SFX_ITEM_AVAILABLE) - rSet.DisableItem(SID_CUT); - if (rSet.GetItemState(SID_COPY) == SFX_ITEM_AVAILABLE) - rSet.DisableItem(SID_COPY); - if (rSet.GetItemState(SID_PASTE) == SFX_ITEM_AVAILABLE) - rSet.DisableItem(SID_PASTE); - if (rSet.GetItemState(SID_PASTE_SPECIAL) == SFX_ITEM_AVAILABLE) - rSet.DisableItem(SID_PASTE_SPECIAL); - } - } - - // Cut, copy, and delete page are disabled when there is no selection. - if (rSet.GetItemState(SID_CUT) == SFX_ITEM_AVAILABLE - || rSet.GetItemState(SID_COPY) == SFX_ITEM_AVAILABLE - || rSet.GetItemState(SID_DELETE) == SFX_ITEM_AVAILABLE - || rSet.GetItemState(SID_DELETE_PAGE) == SFX_ITEM_AVAILABLE - || rSet.GetItemState(SID_DELETE_MASTER_PAGE) == SFX_ITEM_AVAILABLE) - { - model::PageEnumeration aSelectedPages ( - model::PageEnumerationProvider::CreateSelectedPagesEnumeration( - mrSlideSorter.GetModel())); - - // For copy to work we have to have at least one selected page. - if ( ! aSelectedPages.HasMoreElements()) - rSet.DisableItem(SID_COPY); - - bool bDisable = false; - // The operations that lead to the deletion of a page are valid if - // a) there is at least one selected page - // b) deleting the selected pages leaves at least one page in the - // document - // c) selected master pages must not be used by slides. - - // Test a). - if ( ! aSelectedPages.HasMoreElements()) - bDisable = true; - // Test b): Count the number of selected pages. It has to be less - // than the number of all pages. - else if (mrSlideSorter.GetController().GetPageSelector().GetSelectedPageCount() - >= mrSlideSorter.GetController().GetPageSelector().GetPageCount()) - bDisable = true; - // Test c): Iterate over the selected pages and look for a master - // page that is used by at least one page. - else while (aSelectedPages.HasMoreElements()) - { - SdPage* pPage = aSelectedPages.GetNextElement()->GetPage(); - int nUseCount (mrSlideSorter.GetModel().GetDocument() - ->GetMasterPageUserCount(pPage)); - if (nUseCount > 0) - { - bDisable = true; - break; - } - } - - if (bDisable) - { - rSet.DisableItem(SID_CUT); - rSet.DisableItem(SID_DELETE_PAGE); - rSet.DisableItem(SID_DELETE_MASTER_PAGE); - } - } -} - - - - -void SlotManager::GetStatusBarState (SfxItemSet& rSet) -{ - // Seitenanzeige und Layout - SdPage* pPage = NULL; - SdPage* pFirstPage = NULL; - sal_uInt16 nFirstPage; - sal_uInt16 nSelectedPages = (sal_uInt16)mrSlideSorter.GetController().GetPageSelector().GetSelectedPageCount(); - String aPageStr; - String aLayoutStr; - - if (nSelectedPages > 0) - aPageStr = String(SdResId(STR_SD_PAGE)); - - if (nSelectedPages == 1) - { - model::PageEnumeration aSelectedPages ( - model::PageEnumerationProvider::CreateSelectedPagesEnumeration( - mrSlideSorter.GetModel())); - model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement()); - if (pDescriptor) - { - pPage = pDescriptor->GetPage(); - nFirstPage = pPage->GetPageNum()/2; - pFirstPage = pPage; - - aPageStr += sal_Unicode(' '); - aPageStr += String::CreateFromInt32( nFirstPage + 1 ); - aPageStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " / " )); - aPageStr += String::CreateFromInt32( - mrSlideSorter.GetModel().GetPageCount()); - - aLayoutStr = pFirstPage->GetLayoutName(); - aLayoutStr.Erase( aLayoutStr.SearchAscii( SD_LT_SEPARATOR ) ); - } - } - - rSet.Put( SfxStringItem( SID_STATUS_PAGE, aPageStr ) ); - rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aLayoutStr ) ); - - if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOMSLIDER ) ) - { - rSet.Put( SfxVoidItem( SID_ATTR_ZOOMSLIDER ) ); - } -} - -void SlotManager::ShowSlideShow( SfxRequest& rReq) -{ - Reference< XPresentation2 > xPresentation( mrSlideSorter.GetModel().GetDocument()->getPresentation() ); - if( xPresentation.is() ) - { - if( ( SID_REHEARSE_TIMINGS != rReq.GetSlot() ) ) - xPresentation->start(); - else - xPresentation->rehearseTimings(); - } -} - -void SlotManager::RenameSlide (void) -{ - PageKind ePageKind = mrSlideSorter.GetModel().GetPageType(); - View* pDrView = &mrSlideSorter.GetView(); - - if (ePageKind==PK_STANDARD || ePageKind==PK_NOTES) - { - if ( pDrView->IsTextEdit() ) - { - pDrView->SdrEndTextEdit(); - } - - SdPage* pSelectedPage = NULL; - model::PageEnumeration aSelectedPages ( - model::PageEnumerationProvider::CreateSelectedPagesEnumeration( - mrSlideSorter.GetModel())); - if (aSelectedPages.HasMoreElements()) - pSelectedPage = aSelectedPages.GetNextElement()->GetPage(); - if (pSelectedPage != NULL) - { - String aTitle( SdResId( STR_TITLE_RENAMESLIDE ) ); - String aDescr( SdResId( STR_DESC_RENAMESLIDE ) ); - String aPageName = pSelectedPage->GetName(); - - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - DBG_ASSERT(pFact, "Dialogdiet fail!"); - AbstractSvxNameDialog* aNameDlg = pFact->CreateSvxNameDialog( - mrSlideSorter.GetContentWindow().get(), - aPageName, aDescr); - DBG_ASSERT(aNameDlg, "Dialogdiet fail!"); - aNameDlg->SetText( aTitle ); - aNameDlg->SetCheckNameHdl( LINK( this, SlotManager, RenameSlideHdl ), true ); - aNameDlg->SetEditHelpId( HID_SD_NAMEDIALOG_PAGE ); - - if( aNameDlg->Execute() == RET_OK ) - { - String aNewName; - aNameDlg->GetName( aNewName ); - if( ! aNewName.Equals( aPageName ) ) - { -#ifdef DBG_UTIL - bool bResult = -#endif - RenameSlideFromDrawViewShell( - pSelectedPage->GetPageNum()/2, aNewName ); - DBG_ASSERT( bResult, "Couldn't rename slide" ); - } - } - delete aNameDlg; - - // Tell the slide sorter about the name change (necessary for - // accessibility.) - mrSlideSorter.GetController().PageNameHasChanged( - (pSelectedPage->GetPageNum()-1)/2, aPageName); - } - } -} - -IMPL_LINK(SlotManager, RenameSlideHdl, AbstractSvxNameDialog*, pDialog) -{ - if( ! pDialog ) - return 0; - - String aNewName; - pDialog->GetName( aNewName ); - - model::SharedPageDescriptor pDescriptor ( - mrSlideSorter.GetController().GetCurrentSlideManager()->GetCurrentSlide()); - SdPage* pCurrentPage = NULL; - if (pDescriptor.get() != NULL) - pCurrentPage = pDescriptor->GetPage(); - - return ( (pCurrentPage!=NULL && aNewName.Equals( pCurrentPage->GetName() )) - || (mrSlideSorter.GetViewShell() - && mrSlideSorter.GetViewShell()->GetDocSh()->IsNewPageNameValid( aNewName ) )); -} - -bool SlotManager::RenameSlideFromDrawViewShell( sal_uInt16 nPageId, const String & rName ) -{ - sal_Bool bOutDummy; - SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument(); - if( pDocument->GetPageByName( rName, bOutDummy ) != SDRPAGE_NOTFOUND ) - return false; - - SdPage* pPageToRename = NULL; - PageKind ePageKind = mrSlideSorter.GetModel().GetPageType(); - - ::svl::IUndoManager* pManager = pDocument->GetDocSh()->GetUndoManager(); - - if( mrSlideSorter.GetModel().GetEditMode() == EM_PAGE ) - { - model::SharedPageDescriptor pDescriptor ( - mrSlideSorter.GetController().GetCurrentSlideManager()->GetCurrentSlide()); - if (pDescriptor.get() != NULL) - pPageToRename = pDescriptor->GetPage(); - - if (pPageToRename != NULL) - { - // Undo - SdPage* pUndoPage = pPageToRename; - SdrLayerAdmin & rLayerAdmin = pDocument->GetLayerAdmin(); - sal_uInt8 nBackground = rLayerAdmin.GetLayerID( String( SdResId( STR_LAYER_BCKGRND )), sal_False ); - sal_uInt8 nBgObj = rLayerAdmin.GetLayerID( String( SdResId( STR_LAYER_BCKGRNDOBJ )), sal_False ); - SetOfByte aVisibleLayers = pPageToRename->TRG_GetMasterPageVisibleLayers(); - - // (#67720#) - ModifyPageUndoAction* pAction = new ModifyPageUndoAction( - pDocument, pUndoPage, rName, pUndoPage->GetAutoLayout(), - aVisibleLayers.IsSet( nBackground ), - aVisibleLayers.IsSet( nBgObj )); - pManager->AddUndoAction( pAction ); - - // rename - pPageToRename->SetName( rName ); - - if( ePageKind == PK_STANDARD ) - { - // also rename notes-page - SdPage* pNotesPage = pDocument->GetSdPage( nPageId, PK_NOTES ); - if (pNotesPage != NULL) - pNotesPage->SetName (rName); - } - } - } - else - { - // rename MasterPage -> rename LayoutTemplate - pPageToRename = pDocument->GetMasterSdPage( nPageId, ePageKind ); - if (pPageToRename != NULL) - { - const String aOldLayoutName( pPageToRename->GetLayoutName() ); - pManager->AddUndoAction( new RenameLayoutTemplateUndoAction( pDocument, aOldLayoutName, rName ) ); - pDocument->RenameLayoutTemplate( aOldLayoutName, rName ); - } - } - - bool bSuccess = pPageToRename!=NULL && ( sal_False != rName.Equals( pPageToRename->GetName())); - - if( bSuccess ) - { - // user edited page names may be changed by the page so update control - // aTabControl.SetPageText( nPageId, rName ); - - // set document to modified state - pDocument->SetChanged( sal_True ); - - // inform navigator about change - SfxBoolItem aItem( SID_NAVIGATOR_INIT, sal_True ); - if (mrSlideSorter.GetViewShell() != NULL) - mrSlideSorter.GetViewShell()->GetDispatcher()->Execute( - SID_NAVIGATOR_INIT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L ); - } - - return bSuccess; -} - - - - -/** Insert a slide. The insertion position depends on a) the selection and - b) the mouse position when there is no selection. - - When there is a selection then insertion takes place after the last - slide of the selection. For this to work all but the last selected - slide are deselected first. - - Otherwise, when there is no selection but the insertion marker is visible - the slide is inserted at that position. The slide before that marker is - selected first. - - When both the selection and the insertion marker are not visible--can - that happen?--the new slide is inserted after the last slide. -*/ -void SlotManager::InsertSlide (SfxRequest& rRequest) -{ - const sal_Int32 nInsertionIndex (GetInsertionPosition()); - - PageSelector::BroadcastLock aBroadcastLock (mrSlideSorter); - - SdPage* pNewPage = NULL; - if (mrSlideSorter.GetModel().GetEditMode() == EM_PAGE) - { - SlideSorterViewShell* pShell = dynamic_cast<SlideSorterViewShell*>( - mrSlideSorter.GetViewShell()); - if (pShell != NULL) - { - pNewPage = pShell->CreateOrDuplicatePage ( - rRequest, - mrSlideSorter.GetModel().GetPageType(), - nInsertionIndex>=0 - ? mrSlideSorter.GetModel().GetPageDescriptor(nInsertionIndex)->GetPage() - : NULL); - } - } - else - { - // Use the API to create a new page. - SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument(); - Reference<drawing::XMasterPagesSupplier> xMasterPagesSupplier ( - pDocument->getUnoModel(), UNO_QUERY); - if (xMasterPagesSupplier.is()) - { - Reference<drawing::XDrawPages> xMasterPages ( - xMasterPagesSupplier->getMasterPages()); - if (xMasterPages.is()) - { - xMasterPages->insertNewByIndex (nInsertionIndex+1); - - // Create shapes for the default layout. - pNewPage = pDocument->GetMasterSdPage( - (sal_uInt16)(nInsertionIndex+1), PK_STANDARD); - pNewPage->CreateTitleAndLayout (sal_True,sal_True); - } - } - } - if (pNewPage == NULL) - return; - - // When a new page has been inserted then select it, make it the - // current page, and focus it. - view::SlideSorterView::DrawLock aDrawLock (mrSlideSorter); - PageSelector::UpdateLock aUpdateLock (mrSlideSorter); - mrSlideSorter.GetController().GetPageSelector().DeselectAllPages(); - mrSlideSorter.GetController().GetPageSelector().SelectPage(pNewPage); -} - - - - -void SlotManager::DuplicateSelectedSlides (SfxRequest& rRequest) -{ - // Create a list of the pages that are to be duplicated. The process of - // duplication alters the selection. - sal_Int32 nInsertPosition (0); - ::std::vector<SdPage*> aPagesToDuplicate; - model::PageEnumeration aSelectedPages ( - model::PageEnumerationProvider::CreateSelectedPagesEnumeration(mrSlideSorter.GetModel())); - while (aSelectedPages.HasMoreElements()) - { - model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement()); - if (pDescriptor && pDescriptor->GetPage()) - { - aPagesToDuplicate.push_back(pDescriptor->GetPage()); - nInsertPosition = pDescriptor->GetPage()->GetPageNum()+2; - } - } - - // Duplicate the pages in aPagesToDuplicate and collect the newly - // created pages in aPagesToSelect. - const bool bUndo (aPagesToDuplicate.size()>1 && mrSlideSorter.GetView().IsUndoEnabled()); - if (bUndo) - mrSlideSorter.GetView().BegUndo(String(SdResId(STR_INSERTPAGE))); - - ::std::vector<SdPage*> aPagesToSelect; - for(::std::vector<SdPage*>::const_iterator - iPage(aPagesToDuplicate.begin()), - iEnd(aPagesToDuplicate.end()); - iPage!=iEnd; - ++iPage, nInsertPosition+=2) - { - aPagesToSelect.push_back( - mrSlideSorter.GetViewShell()->CreateOrDuplicatePage( - rRequest, PK_STANDARD, *iPage, nInsertPosition)); - } - aPagesToDuplicate.clear(); - - if (bUndo) - mrSlideSorter.GetView().EndUndo(); - - // Set the selection to the pages in aPagesToSelect. - PageSelector& rSelector (mrSlideSorter.GetController().GetPageSelector()); - rSelector.DeselectAllPages(); - ::std::for_each ( - aPagesToSelect.begin(), - aPagesToSelect.end(), - ::boost::bind( - static_cast<void (PageSelector::*)(const SdPage*)>(&PageSelector::SelectPage), - rSelector, - _1)); -} - -void SlotManager::ExecuteCommandAsynchronously (::std::auto_ptr<Command> pCommand) -{ - // Ownership of command is (implicitely) transferred to the queue. - maCommandQueue.push(pCommand.get()); - pCommand.release(); - Application::PostUserEvent(LINK(this,SlotManager,UserEventCallback)); -} - -IMPL_LINK(SlotManager, UserEventCallback, void*, EMPTYARG) -{ - if ( ! maCommandQueue.empty()) - { - Command* pCommand = maCommandQueue.front(); - maCommandQueue.pop(); - - if (pCommand != NULL) - { - // The queue ownes the command that has just been removed from - // it. Therefore it is deleted after it has been executed. - (*pCommand)(); - delete pCommand; - } - } - - return 1; -} - - - - -void SlotManager::ChangeSlideExclusionState ( - const model::SharedPageDescriptor& rpDescriptor, - const bool bExcludeSlide) -{ - if (rpDescriptor) - { - mrSlideSorter.GetView().SetState( - rpDescriptor, - model::PageDescriptor::ST_Excluded, - bExcludeSlide); - } - else - { - model::PageEnumeration aSelectedPages ( - model::PageEnumerationProvider::CreateSelectedPagesEnumeration( - mrSlideSorter.GetModel())); - while (aSelectedPages.HasMoreElements()) - { - model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement()); - mrSlideSorter.GetView().SetState( - pDescriptor, - model::PageDescriptor::ST_Excluded, - bExcludeSlide); - } - } - - SfxBindings& rBindings (mrSlideSorter.GetViewShell()->GetViewFrame()->GetBindings()); - rBindings.Invalidate(SID_PRESENTATION); - rBindings.Invalidate(SID_REHEARSE_TIMINGS); - rBindings.Invalidate(SID_HIDE_SLIDE); - rBindings.Invalidate(SID_SHOW_SLIDE); - mrSlideSorter.GetModel().GetDocument()->SetChanged(); -} - - - - -sal_Int32 SlotManager::GetInsertionPosition (void) -{ - PageSelector& rSelector (mrSlideSorter.GetController().GetPageSelector()); - - // The insertion indicator is preferred. After all the user explicitly - // used it to define the insertion position. - if (mrSlideSorter.GetController().GetInsertionIndicatorHandler()->IsActive()) - { - // Select the page before the insertion indicator. - return mrSlideSorter.GetController().GetInsertionIndicatorHandler()->GetInsertionPageIndex() - - 1; - } - - // Is there a stored insertion position? - else if (mrSlideSorter.GetController().GetSelectionManager()->GetInsertionPosition() >= 0) - { - return mrSlideSorter.GetController().GetSelectionManager()->GetInsertionPosition() - 1; - } - - // Use the index of the last selected slide. - else if (rSelector.GetSelectedPageCount() > 0) - { - for (int nIndex=rSelector.GetPageCount()-1; nIndex>=0; --nIndex) - if (rSelector.IsPageSelected(nIndex)) - return nIndex; - - // We should never get here. - OSL_ASSERT(false); - return rSelector.GetPageCount() - 1; - } - - // Select the last page when there is at least one page. - else if (rSelector.GetPageCount() > 0) - { - return rSelector.GetPageCount() - 1; - } - - // Hope for the best that CreateOrDuplicatePage() can cope with an empty - // selection. - else - { - // We should never get here because there has to be at least one page. - OSL_ASSERT(false); - return -1; - } -} - - - - -void SlotManager::NotifyEditModeChange (void) -{ - SfxBindings& rBindings (mrSlideSorter.GetViewShell()->GetViewFrame()->GetBindings()); - rBindings.Invalidate(SID_PRESENTATION); - rBindings.Invalidate(SID_INSERTPAGE); - rBindings.Invalidate(SID_DUPLICATE_PAGE); -} - - - - -//----------------------------------------------------------------------------- - -namespace { - - - -SlideExclusionState GetSlideExclusionState (model::PageEnumeration& rPageSet) -{ - SlideExclusionState eState (UNDEFINED); - sal_Bool bState; - - // Get toggle state of the selected pages. - while (rPageSet.HasMoreElements() && eState!=MIXED) - { - bState = rPageSet.GetNextElement()->GetPage()->IsExcluded(); - switch (eState) - { - case UNDEFINED: - // Use the first selected page to set the inital value. - eState = bState ? EXCLUDED : INCLUDED; - break; - - case EXCLUDED: - // The pages before where all not part of the show, - // this one is. - if ( ! bState) - eState = MIXED; - break; - - case INCLUDED: - // The pages before where all part of the show, - // this one is not. - if (bState) - eState = MIXED; - break; - - case MIXED: - default: - // No need to change anything. - break; - } - } - - return eState; -} - -} // end of anonymous namespace - -} } } // end of namespace ::sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsTransferable.cxx b/sd/source/ui/slidesorter/controller/SlsTransferable.cxx deleted file mode 100644 index 22d33074c..000000000 --- a/sd/source/ui/slidesorter/controller/SlsTransferable.cxx +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "controller/SlsTransferable.hxx" - -#include "SlideSorterViewShell.hxx" -#include "View.hxx" - -namespace sd { namespace slidesorter { namespace controller { - -Transferable::Transferable ( - SdDrawDocument* pSrcDoc, - ::sd::View* pWorkView, - sal_Bool bInitOnGetData, - SlideSorterViewShell* pViewShell, - const ::std::vector<Representative>& rRepresentatives) - : SdTransferable (pSrcDoc, pWorkView, bInitOnGetData), - mpViewShell(pViewShell), - maRepresentatives(rRepresentatives) -{ - if (mpViewShell != NULL) - StartListening(*mpViewShell); -} - - - - -Transferable::~Transferable (void) -{ - if (mpViewShell != NULL) - EndListening(*mpViewShell); -} - - - - -void Transferable::DragFinished (sal_Int8 nDropAction) -{ - if (mpViewShell != NULL) - mpViewShell->DragFinished(nDropAction); -} - - - - -void Transferable::Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint) -{ - if (rHint.ISA(SfxSimpleHint) && mpViewShell!=NULL) - { - SfxSimpleHint& rSimpleHint (*PTR_CAST(SfxSimpleHint, &rHint)); - if (rSimpleHint.GetId() == SFX_HINT_DYING) - { - // This hint may come either from the ViewShell or from the - // document (registered by SdTransferable). We do not know - // which but both are sufficient to disconnect from the - // ViewShell. - EndListening(*mpViewShell); - mpViewShell = NULL; - } - } - - SdTransferable::Notify(rBroadcaster, rHint); -} - - - - -const ::std::vector<Transferable::Representative>& Transferable::GetRepresentatives (void) const -{ - return maRepresentatives; -} - - -} } } // end of namespace ::sd::slidesorter::controller - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx b/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx deleted file mode 100644 index f2cdd8831..000000000 --- a/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx +++ /dev/null @@ -1,305 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "controller/SlsVisibleAreaManager.hxx" -#include "controller/SlideSorterController.hxx" -#include "controller/SlsProperties.hxx" -#include "controller/SlsAnimationFunction.hxx" -#include "controller/SlsScrollBarManager.hxx" -#include "controller/SlsCurrentSlideManager.hxx" - - -namespace sd { namespace slidesorter { namespace controller { - -namespace { - class VisibleAreaScroller - { - public: - VisibleAreaScroller ( - SlideSorter& rSlideSorter, - const Point aStart, - const Point aEnd); - void operator() (const double nValue); - private: - SlideSorter& mrSlideSorter; - Point maStart; - const Point maEnd; - const ::boost::function<double(double)> maAccelerationFunction; - }; - -} // end of anonymous namespace - - - -VisibleAreaManager::VisibleAreaManager (SlideSorter& rSlideSorter) - : mrSlideSorter(rSlideSorter), - maVisibleRequests(), - mnScrollAnimationId(Animator::NotAnAnimationId), - maRequestedVisibleTopLeft(), - meRequestedAnimationMode(Animator::AM_Immediate), - mbIsCurrentSlideTrackingActive(true), - mnDisableCount(0) -{ -} - - - - -VisibleAreaManager::~VisibleAreaManager (void) -{ -} - - - - -void VisibleAreaManager::ActivateCurrentSlideTracking (void) -{ - mbIsCurrentSlideTrackingActive = true; -} - - - - -void VisibleAreaManager::DeactivateCurrentSlideTracking (void) -{ - mbIsCurrentSlideTrackingActive = false; -} - - - - -void VisibleAreaManager::RequestVisible ( - const model::SharedPageDescriptor& rpDescriptor, - const bool bForce) -{ - if (rpDescriptor) - { - if (mnDisableCount == 0) - { - maVisibleRequests.push_back( - mrSlideSorter.GetView().GetLayouter().GetPageObjectBox( - rpDescriptor->GetPageIndex(), - true)); - } - if (bForce && ! mbIsCurrentSlideTrackingActive) - ActivateCurrentSlideTracking(); - MakeVisible(); - } -} - - - - -void VisibleAreaManager::RequestCurrentSlideVisible (void) -{ - if (mbIsCurrentSlideTrackingActive && mnDisableCount==0) - RequestVisible( - mrSlideSorter.GetController().GetCurrentSlideManager()->GetCurrentSlide()); -} - - - - -void VisibleAreaManager::MakeVisible (void) -{ - if (maVisibleRequests.empty()) - return; - - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - if ( ! pWindow) - return; - const Point aCurrentTopLeft (pWindow->PixelToLogic(Point(0,0))); - - const ::boost::optional<Point> aNewVisibleTopLeft (GetRequestedTopLeft()); - maVisibleRequests.clear(); - if ( ! aNewVisibleTopLeft) - return; - - // We now know what the visible area shall be. Scroll accordingly - // unless that is not already the visible area or a running scroll - // animation has it as its target area. - if (mnScrollAnimationId!=Animator::NotAnAnimationId - && maRequestedVisibleTopLeft==aNewVisibleTopLeft) - return; - - // Stop a running animation. - if (mnScrollAnimationId != Animator::NotAnAnimationId) - mrSlideSorter.GetController().GetAnimator()->RemoveAnimation(mnScrollAnimationId); - - maRequestedVisibleTopLeft = aNewVisibleTopLeft.get(); - VisibleAreaScroller aAnimation( - mrSlideSorter, - aCurrentTopLeft, - maRequestedVisibleTopLeft); - if (meRequestedAnimationMode==Animator::AM_Animated - && mrSlideSorter.GetProperties()->IsSmoothSelectionScrolling()) - { - mnScrollAnimationId = mrSlideSorter.GetController().GetAnimator()->AddAnimation( - aAnimation, - 0, - 300); - } - else - { - // Execute the animation at its final value. - aAnimation(1.0); - } - meRequestedAnimationMode = Animator::AM_Immediate; -} - - - - -::boost::optional<Point> VisibleAreaManager::GetRequestedTopLeft (void) const -{ - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - if ( ! pWindow) - return ::boost::optional<Point>(); - - // Get the currently visible area and the model area. - const Rectangle aVisibleArea (pWindow->PixelToLogic( - Rectangle( - Point(0,0), - pWindow->GetOutputSizePixel()))); - const Rectangle aModelArea (mrSlideSorter.GetView().GetModelArea()); - - sal_Int32 nVisibleTop (aVisibleArea.Top()); - const sal_Int32 nVisibleWidth (aVisibleArea.GetWidth()); - sal_Int32 nVisibleLeft (aVisibleArea.Left()); - const sal_Int32 nVisibleHeight (aVisibleArea.GetHeight()); - - // Find the longest run of boxes whose union fits into the visible area. - Rectangle aBoundingBox; - for (::std::vector<Rectangle>::const_iterator - iBox(maVisibleRequests.begin()), - iEnd(maVisibleRequests.end()); - iBox!=iEnd; - ++iBox) - { - if (nVisibleTop+nVisibleHeight <= iBox->Bottom()) - nVisibleTop = iBox->Bottom()-nVisibleHeight; - if (nVisibleTop > iBox->Top()) - nVisibleTop = iBox->Top(); - - if (nVisibleLeft+nVisibleWidth <= iBox->Right()) - nVisibleLeft = iBox->Right()-nVisibleWidth; - if (nVisibleLeft > iBox->Left()) - nVisibleLeft = iBox->Left(); - - // Make sure the visible area does not move outside the model area. - if (nVisibleTop + nVisibleHeight > aModelArea.Bottom()) - nVisibleTop = aModelArea.Bottom() - nVisibleHeight; - if (nVisibleTop < aModelArea.Top()) - nVisibleTop = aModelArea.Top(); - - if (nVisibleLeft + nVisibleWidth > aModelArea.Right()) - nVisibleLeft = aModelArea.Right() - nVisibleWidth; - if (nVisibleLeft < aModelArea.Left()) - nVisibleLeft = aModelArea.Left(); - } - - const Point aRequestedTopLeft (nVisibleLeft, nVisibleTop); - if (aRequestedTopLeft == aVisibleArea.TopLeft()) - return ::boost::optional<Point>(); - else - return ::boost::optional<Point>(aRequestedTopLeft); -} - - - - -//===== VisibleAreaManager::TemporaryDisabler ================================= - -VisibleAreaManager::TemporaryDisabler::TemporaryDisabler (SlideSorter& rSlideSorter) - : mrVisibleAreaManager(rSlideSorter.GetController().GetVisibleAreaManager()) -{ - ++mrVisibleAreaManager.mnDisableCount; -} - - - - -VisibleAreaManager::TemporaryDisabler::~TemporaryDisabler (void) -{ - --mrVisibleAreaManager.mnDisableCount; -} - - - -//===== VerticalVisibleAreaScroller =========================================== - -namespace { - -const static sal_Int32 gnMaxScrollDistance = 300; - -VisibleAreaScroller::VisibleAreaScroller ( - SlideSorter& rSlideSorter, - const Point aStart, - const Point aEnd) - : mrSlideSorter(rSlideSorter), - maStart(aStart), - maEnd(aEnd), - maAccelerationFunction( - controller::AnimationParametricFunction( - controller::AnimationBezierFunction (0.1,0.6))) -{ - // When the distance to scroll is larger than a threshold then first - // jump to within this distance of the final value and start the - // animation from there. - if (abs(aStart.X()-aEnd.X()) > gnMaxScrollDistance) - { - if (aStart.X() < aEnd.X()) - maStart.X() = aEnd.X()-gnMaxScrollDistance; - else - maStart.X() = aEnd.X()+gnMaxScrollDistance; - } - if (abs(aStart.Y()-aEnd.Y()) > gnMaxScrollDistance) - { - if (aStart.Y() < aEnd.Y()) - maStart.Y() = aEnd.Y()-gnMaxScrollDistance; - else - maStart.Y() = aEnd.Y()+gnMaxScrollDistance; - } -} - - - - -void VisibleAreaScroller::operator() (const double nTime) -{ - const double nLocalTime (maAccelerationFunction(nTime)); - mrSlideSorter.GetController().GetScrollBarManager().SetTopLeft( - Point( - sal_Int32(0.5 + maStart.X() * (1.0 - nLocalTime) + maEnd.X() * nLocalTime), - sal_Int32 (0.5 + maStart.Y() * (1.0 - nLocalTime) + maEnd.Y() * nLocalTime))); -} - -} // end of anonymous namespace - -} } } // end of namespace ::sd::slidesorter::controller |