diff options
Diffstat (limited to 'sd/source/ui/slidesorter/shell')
-rw-r--r-- | sd/source/ui/slidesorter/shell/SlideSorter.cxx | 651 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/shell/SlideSorterChildWindow.cxx | 66 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/shell/SlideSorterChildWindow.src | 52 | ||||
-rwxr-xr-x | sd/source/ui/slidesorter/shell/SlideSorterService.cxx | 648 | ||||
-rwxr-xr-x | sd/source/ui/slidesorter/shell/SlideSorterService.hxx | 216 | ||||
-rwxr-xr-x | sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx | 778 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/shell/makefile.mk | 55 |
7 files changed, 2466 insertions, 0 deletions
diff --git a/sd/source/ui/slidesorter/shell/SlideSorter.cxx b/sd/source/ui/slidesorter/shell/SlideSorter.cxx new file mode 100644 index 000000000000..768dd5f9458a --- /dev/null +++ b/sd/source/ui/slidesorter/shell/SlideSorter.cxx @@ -0,0 +1,651 @@ +/************************************************************************* + * + * 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 "SlideSorterChildWindow.hrc" +#include "SlideSorterViewShell.hxx" +#include "controller/SlideSorterController.hxx" +#include "controller/SlsScrollBarManager.hxx" +#include "view/SlideSorterView.hxx" +#include "model/SlideSorterModel.hxx" + +#include "glob.hrc" +#include "DrawController.hxx" +#include "ViewShellBase.hxx" +#include "ViewShellManager.hxx" +#include "Window.hxx" + +#include <vcl/scrbar.hxx> +#include <vcl/svapp.hxx> + +#include <sfx2/dispatch.hxx> +#include "sdresid.hxx" + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star; + + +namespace sd { namespace slidesorter { + +namespace { +class ContentWindow : public ::sd::Window +{ +public: + ContentWindow(::Window& rParent, SlideSorter& rSlideSorter); + ~ContentWindow (void); + void SetCurrentFunction (const FunctionReference& rpFunction); + virtual void Paint(const Rectangle& rRect); + virtual void KeyInput (const KeyEvent& rEvent); + virtual void MouseMove (const MouseEvent& rEvent); + virtual void MouseButtonUp (const MouseEvent& rEvent); + virtual void MouseButtonDown (const MouseEvent& rEvent); + virtual void Command (const CommandEvent& rEvent); + virtual long Notify (NotifyEvent& rEvent); + +private: + SlideSorter& mrSlideSorter; + FunctionReference mpCurrentFunction; +}; +} + + + + +//===== SlideSorter =========================================================== + +::boost::shared_ptr<SlideSorter> SlideSorter::CreateSlideSorter( + ViewShell& rViewShell, + const ::boost::shared_ptr<sd::Window>& rpContentWindow, + const ::boost::shared_ptr<ScrollBar>& rpHorizontalScrollBar, + const ::boost::shared_ptr<ScrollBar>& rpVerticalScrollBar, + const ::boost::shared_ptr<ScrollBarBox>& rpScrollBarBox) +{ + ::boost::shared_ptr<SlideSorter> pSlideSorter( + new SlideSorter( + rViewShell, + rpContentWindow, + rpHorizontalScrollBar, + rpVerticalScrollBar, + rpScrollBarBox)); + pSlideSorter->Init(); + return pSlideSorter; +} + + + + +::boost::shared_ptr<SlideSorter> SlideSorter::CreateSlideSorter ( + ViewShellBase& rBase, + ViewShell* pViewShell, + ::Window& rParentWindow) +{ + ::boost::shared_ptr<SlideSorter> pSlideSorter( + new SlideSorter( + rBase, + pViewShell, + rParentWindow)); + pSlideSorter->Init(); + return pSlideSorter; +} + + + + +SlideSorter::SlideSorter ( + ViewShell& rViewShell, + const ::boost::shared_ptr<sd::Window>& rpContentWindow, + const ::boost::shared_ptr<ScrollBar>& rpHorizontalScrollBar, + const ::boost::shared_ptr<ScrollBar>& rpVerticalScrollBar, + const ::boost::shared_ptr<ScrollBarBox>& rpScrollBarBox) + : mbIsValid(false), + mpSlideSorterController(), + mpSlideSorterModel(), + mpSlideSorterView(), + mxControllerWeak(), + mpViewShell(&rViewShell), + mpViewShellBase(&rViewShell.GetViewShellBase()), + mpContentWindow(rpContentWindow), + mpHorizontalScrollBar(rpHorizontalScrollBar), + mpVerticalScrollBar(rpVerticalScrollBar), + mpScrollBarBox(rpScrollBarBox), + mbLayoutPending(true) +{ +} + + + + +SlideSorter::SlideSorter ( + ViewShellBase& rBase, + ViewShell* pViewShell, + ::Window& rParentWindow) + : mbIsValid(false), + mpSlideSorterController(), + mpSlideSorterModel(), + mpSlideSorterView(), + mxControllerWeak(), + mpViewShell(pViewShell), + mpViewShellBase(&rBase), + mpContentWindow(new ContentWindow(rParentWindow,*this )), + mpHorizontalScrollBar(new ScrollBar(&rParentWindow,WinBits(WB_HSCROLL | WB_DRAG))), + mpVerticalScrollBar(new ScrollBar(&rParentWindow,WinBits(WB_VSCROLL | WB_DRAG))), + mpScrollBarBox(new ScrollBarBox(&rParentWindow)), + mbLayoutPending(true) +{ +} + + + + +void SlideSorter::Init (void) +{ + if (mpViewShellBase != NULL) + mxControllerWeak = mpViewShellBase->GetController(); + + CreateModelViewController (); + + SetupListeners (); + + // Initialize the window. + ::sd::Window* pWindow = GetActiveWindow(); + if (pWindow != NULL) + { + ::Window* pParentWindow = pWindow->GetParent(); + if (pParentWindow != NULL) + pParentWindow->SetBackground(Wallpaper()); + pWindow->SetBackground(Wallpaper()); + pWindow->SetViewOrigin (Point(0,0)); + // We do our own scrolling while dragging a page selection. + pWindow->SetUseDropScroll (false); + // Change the winbits so that the active window accepts the focus. + pWindow->SetStyle ((pWindow->GetStyle() & ~WB_DIALOGCONTROL) | WB_TABSTOP); + pWindow->Hide(); + + // Set view pointer of base class. + SetupControls(pParentWindow); + + mbIsValid = true; + } +} + + + + +SlideSorter::~SlideSorter (void) +{ + mbIsValid = false; + + ReleaseListeners(); + + // Reset the auto pointers explicitly to control the order of destruction. + mpSlideSorterController.reset(); + mpSlideSorterView.reset(); + mpSlideSorterModel.reset(); + + mpHorizontalScrollBar.reset(); + mpVerticalScrollBar.reset(); + mpScrollBarBox.reset(); + mpContentWindow.reset(); +} + + + + +bool SlideSorter::IsValid (void) const +{ + return mbIsValid; +} + + + + +::boost::shared_ptr<ScrollBar> SlideSorter::GetVerticalScrollBar (void) const +{ + return mpVerticalScrollBar; +} + + + + + +::boost::shared_ptr<ScrollBar> SlideSorter::GetHorizontalScrollBar (void) const +{ + return mpHorizontalScrollBar; +} + + + + +::boost::shared_ptr<ScrollBarBox> SlideSorter::GetScrollBarFiller (void) const +{ + return mpScrollBarBox; +} + + + + +model::SlideSorterModel& SlideSorter::GetModel (void) const +{ + OSL_ASSERT(mpSlideSorterModel.get()!=NULL); + return *mpSlideSorterModel; +} + + + + +view::SlideSorterView& SlideSorter::GetView (void) const +{ + OSL_ASSERT(mpSlideSorterView.get()!=NULL); + return *mpSlideSorterView; +} + + + + +controller::SlideSorterController& SlideSorter::GetController (void) const +{ + OSL_ASSERT(mpSlideSorterController.get()!=NULL); + return *mpSlideSorterController; +} + + + + +Reference<frame::XController> SlideSorter::GetXController (void) const +{ + Reference<frame::XController> xController(mxControllerWeak); + return xController; +} + + + + +void SlideSorter::Paint (const Rectangle& rRepaintArea) +{ + GetController().Paint( + rRepaintArea, + GetContentWindow().get()); +} + + + + +::boost::shared_ptr<sd::Window> SlideSorter::GetContentWindow (void) const +{ + return mpContentWindow; +} + + + + +::sd::Window* SlideSorter::GetActiveWindow (void) const +{ + if (mpViewShell != NULL) + return mpViewShell->GetActiveWindow(); + else + return mpContentWindow.get(); +} + + + + +ViewShellBase* SlideSorter::GetViewShellBase (void) const +{ + return mpViewShellBase; +} + + + + +ViewShell* SlideSorter::GetViewShell (void) const +{ + return mpViewShell; +} + + + + +void SlideSorter::SetupControls (::Window* ) +{ + GetVerticalScrollBar()->Show(); + mpSlideSorterController->GetScrollBarManager().LateInitialization(); +} + + + + +void SlideSorter::SetupListeners (void) +{ + ::sd::Window* pWindow = GetActiveWindow(); + if (pWindow != NULL) + { + ::Window* pParentWindow = pWindow->GetParent(); + if (pParentWindow != NULL) + pParentWindow->AddEventListener( + LINK( + mpSlideSorterController.get(), + controller::SlideSorterController, + WindowEventHandler)); + pWindow->AddEventListener( + LINK( + mpSlideSorterController.get(), + controller::SlideSorterController, + WindowEventHandler)); + } + Application::AddEventListener( + LINK( + mpSlideSorterController.get(), + controller::SlideSorterController, + WindowEventHandler)); + + mpSlideSorterController->GetScrollBarManager().Connect(); +} + + + + +void SlideSorter::ReleaseListeners (void) +{ + mpSlideSorterController->GetScrollBarManager().Disconnect(); + + ::sd::Window* pWindow = GetActiveWindow(); + if (pWindow != NULL) + { + + pWindow->RemoveEventListener( + LINK(mpSlideSorterController.get(), + controller::SlideSorterController, + WindowEventHandler)); + + ::Window* pParentWindow = pWindow->GetParent(); + if (pParentWindow != NULL) + pParentWindow->RemoveEventListener( + LINK(mpSlideSorterController.get(), + controller::SlideSorterController, + WindowEventHandler)); + } + Application::RemoveEventListener( + LINK(mpSlideSorterController.get(), + controller::SlideSorterController, + WindowEventHandler)); +} + + + + +void SlideSorter::CreateModelViewController (void) +{ + mpSlideSorterModel.reset(CreateModel()); + DBG_ASSERT (mpSlideSorterModel.get()!=NULL, + "Can not create model for slide browser"); + + mpSlideSorterView.reset(CreateView()); + DBG_ASSERT (mpSlideSorterView.get()!=NULL, + "Can not create view for slide browser"); + + mpSlideSorterController.reset(CreateController()); + DBG_ASSERT (mpSlideSorterController.get()!=NULL, + "Can not create controller for slide browser"); + mpSlideSorterController->Init(); +} + + + + +model::SlideSorterModel* SlideSorter::CreateModel (void) +{ + // Get pointers to the document. + ViewShellBase* pViewShellBase = GetViewShellBase(); + if (pViewShellBase != NULL) + { + OSL_ASSERT (pViewShellBase->GetDocument() != NULL); + + return new model::SlideSorterModel(*this); + } + else + return NULL; +} + + + + +view::SlideSorterView* SlideSorter::CreateView (void) +{ + return new view::SlideSorterView (*this); +} + + + + +controller::SlideSorterController* SlideSorter::CreateController (void) +{ + controller::SlideSorterController* pController + = new controller::SlideSorterController (*this); + return pController; +} + + + + +void SlideSorter::ArrangeGUIElements ( + const Point& rOffset, + const Size& rSize) +{ + Point aOrigin (rOffset); + + if (rSize.Width()!=0 && rSize.Height()!=0) + { + // Prevent untimely redraws while the view is not yet correctly + // resized. + mpSlideSorterView->LockRedraw (TRUE); + if (GetActiveWindow() != NULL) + GetActiveWindow()->EnablePaint (FALSE); + + // maAllWindowRectangle = + mpSlideSorterController->Resize (Rectangle(aOrigin, rSize)); + + if (GetActiveWindow() != NULL) + GetActiveWindow()->EnablePaint (TRUE); + + mbLayoutPending = false; + mpSlideSorterView->LockRedraw (FALSE); + } + else + { + // maAllWindowRectangle = Rectangle(); + } +} + + + + +SvBorder SlideSorter::GetBorder (void) +{ + SvBorder aBorder; + + ::boost::shared_ptr<ScrollBar> pScrollBar = GetVerticalScrollBar(); + if (pScrollBar.get() != NULL && pScrollBar->IsVisible()) + aBorder.Right() = pScrollBar->GetOutputSizePixel().Width(); + + pScrollBar = GetHorizontalScrollBar(); + if (pScrollBar.get() != NULL && pScrollBar->IsVisible()) + aBorder.Bottom() = pScrollBar->GetOutputSizePixel().Height(); + + return aBorder; +} + + + + +bool SlideSorter::RelocateToWindow (::Window* pParentWindow) +{ + ReleaseListeners(); + + if (mpViewShell != NULL) + mpViewShell->ViewShell::RelocateToParentWindow(pParentWindow); + + SetupControls(mpViewShell->GetParentWindow()); + SetupListeners(); + + // For accessibility we have to shortly hide the content window. This + // triggers the construction of a new accessibility object for the new + // view shell. (One is created earlier while the construtor of the base + // class is executed. At that time the correct accessibility object can + // not be constructed.) + if (mpContentWindow.get() !=NULL) + { + mpContentWindow->Hide(); + mpContentWindow->Show(); + } + + return true; +} + + + + +void SlideSorter::SetCurrentFunction (const FunctionReference& rpFunction) +{ + if (GetViewShell() != NULL) + { + GetViewShell()->SetCurrentFunction(rpFunction); + GetViewShell()->SetOldFunction(rpFunction); + } + else + { + ::boost::shared_ptr<ContentWindow> pWindow + = ::boost::dynamic_pointer_cast<ContentWindow>(GetContentWindow()); + if (pWindow.get() != NULL) + pWindow->SetCurrentFunction(rpFunction); + } +} + + + + +//===== ContentWindow ========================================================= + +namespace { + +ContentWindow::ContentWindow( + ::Window& rParent, + SlideSorter& rSlideSorter) + : ::sd::Window(&rParent), + mrSlideSorter(rSlideSorter), + mpCurrentFunction() +{ + SetDialogControlFlags(GetDialogControlFlags() & ~WINDOW_DLGCTRL_WANTFOCUS); + SetStyle(GetStyle() | WB_NOPOINTERFOCUS); +} + + + + +ContentWindow::~ContentWindow (void) +{ +} + + + + +void ContentWindow::SetCurrentFunction (const FunctionReference& rpFunction) +{ + mpCurrentFunction = rpFunction; +} + + + + +void ContentWindow::Paint (const Rectangle& rRect) +{ + mrSlideSorter.Paint(rRect); +} + + + + +void ContentWindow::KeyInput (const KeyEvent& rEvent) +{ + if (mpCurrentFunction.is()) + mpCurrentFunction->KeyInput(rEvent); +} + + + + +void ContentWindow::MouseMove (const MouseEvent& rEvent) +{ + if (mpCurrentFunction.is()) + mpCurrentFunction->MouseMove(rEvent); +} + + + + +void ContentWindow::MouseButtonUp(const MouseEvent& rEvent) +{ + if (mpCurrentFunction.is()) + mpCurrentFunction->MouseButtonUp(rEvent); +} + + + + +void ContentWindow::MouseButtonDown(const MouseEvent& rEvent) +{ + if (mpCurrentFunction.is()) + mpCurrentFunction->MouseButtonDown(rEvent); +} + + + + +void ContentWindow::Command(const CommandEvent& rEvent) +{ + if (mpCurrentFunction.is()) + mpCurrentFunction->Command(rEvent); +} + + + + +long ContentWindow::Notify (NotifyEvent& rEvent) +{ + (void)rEvent; + return 0; +} + + + + +} // end of anonymous namespace + + +} } // end of namespace ::sd::slidesorter diff --git a/sd/source/ui/slidesorter/shell/SlideSorterChildWindow.cxx b/sd/source/ui/slidesorter/shell/SlideSorterChildWindow.cxx new file mode 100644 index 000000000000..985fb72b38a5 --- /dev/null +++ b/sd/source/ui/slidesorter/shell/SlideSorterChildWindow.cxx @@ -0,0 +1,66 @@ +/************************************************************************* + * + * 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 "SlideSorterChildWindow.hxx" + +#include "app.hrc" +#include "sfx2/app.hxx" +#include <sfx2/dockwin.hxx> + +#include "SlideSorter.hxx" + +namespace sd { namespace slidesorter { + +SlideSorterChildWindow::SlideSorterChildWindow ( + ::Window* pParentWindow, + USHORT nId, + SfxBindings* pBindings, + SfxChildWinInfo* pInfo) + : SfxChildWindow (pParentWindow, nId) +{ + pWindow = new SlideSorter ( + pBindings, + this, + pParentWindow); + eChildAlignment = SFX_ALIGN_LEFT; + static_cast<SfxDockingWindow*>(pWindow)->Initialize (pInfo); + // SetHideNotDelete (TRUE); +} + + + + +SlideSorterChildWindow::~SlideSorterChildWindow (void) +{} + + +SFX_IMPL_DOCKINGWINDOW(SlideSorterChildWindow, SID_SLIDE_BROWSER) + +} } // end of namespace ::sd::slidesorter diff --git a/sd/source/ui/slidesorter/shell/SlideSorterChildWindow.src b/sd/source/ui/slidesorter/shell/SlideSorterChildWindow.src new file mode 100644 index 000000000000..829b18d63a97 --- /dev/null +++ b/sd/source/ui/slidesorter/shell/SlideSorterChildWindow.src @@ -0,0 +1,52 @@ +/************************************************************************* + * + * 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 "app.hrc" +#include "SlideSorterChildWindow.hrc" + +DockingWindow FLT_WIN_SLIDE_BROWSER +{ + HelpID = SID_SLIDE_BROWSER; + Border = TRUE ; + Hide = FALSE ; + SVLook = TRUE ; + Sizeable = TRUE ; + Moveable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + Dockable = TRUE ; + EnableResizing = TRUE ; + Size = MAP_APPFONT ( 140 , 120 ) ; + Text = "Slide Browser" ; + + Control TOOLPANEL + { + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( 69, 150 ) ; + Border = FALSE; + }; +}; diff --git a/sd/source/ui/slidesorter/shell/SlideSorterService.cxx b/sd/source/ui/slidesorter/shell/SlideSorterService.cxx new file mode 100755 index 000000000000..787086b4596e --- /dev/null +++ b/sd/source/ui/slidesorter/shell/SlideSorterService.cxx @@ -0,0 +1,648 @@ +/************************************************************************* + * + * 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 "SlideSorterService.hxx" +#include "controller/SlideSorterController.hxx" +#include "controller/SlsProperties.hxx" +#include "controller/SlsCurrentSlideManager.hxx" +#include "model/SlideSorterModel.hxx" +#include "model/SlsPageDescriptor.hxx" +#include "view/SlideSorterView.hxx" +#include "DrawController.hxx" +#include <toolkit/helper/vclunohelper.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> +#include <cppuhelper/proptypehlp.hxx> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::drawing::framework; +using ::rtl::OUString; +using ::sd::slidesorter::view::SlideSorterView; + +namespace sd { namespace slidesorter { + +namespace { + enum Properties + { + PropertyDocumentSlides, + PropertyHighlightCurrentSlide, + PropertyShowSelection, + PropertyCenterSelection, + PropertySuspendPreviewUpdatesDuringFullScreenPresentation, + PropertyOrientationVertical + }; +} + + + + +//===== Service =============================================================== + +Reference<XInterface> SAL_CALL SlideSorterService_createInstance ( + const Reference<XComponentContext>& rxContext) +{ + return Reference<XInterface>(static_cast<drawing::XDrawView*>(new SlideSorterService(rxContext))); +} + + + + +::rtl::OUString SlideSorterService_getImplementationName (void) throw(RuntimeException) +{ + return OUString::createFromAscii("com.sun.star.comp.Draw.SlideSorter"); +} + + + + +Sequence<rtl::OUString> SAL_CALL SlideSorterService_getSupportedServiceNames (void) + throw (RuntimeException) +{ + static const ::rtl::OUString sServiceName( + ::rtl::OUString::createFromAscii("com.sun.star.drawing.SlideSorter")); + return Sequence<rtl::OUString>(&sServiceName, 1); +} + + + + +//===== SlideSorterService ========================================================== + +SlideSorterService::SlideSorterService (const Reference<XComponentContext>& rxContext) + : SlideSorterServiceInterfaceBase(m_aMutex), + mpSlideSorter(), + mxParentWindow() +{ + (void)rxContext; +} + + + + +SlideSorterService::~SlideSorterService (void) +{ +} + + + + +void SAL_CALL SlideSorterService::disposing (void) +{ + mpSlideSorter.reset(); + + if (mxParentWindow.is()) + { + mxParentWindow->removeWindowListener(this); + } +} + + + + +//----- XInitialization ------------------------------------------------------- + +void SAL_CALL SlideSorterService::initialize (const Sequence<Any>& rArguments) + throw (Exception, RuntimeException) +{ + ThrowIfDisposed(); + + if (rArguments.getLength() == 3) + { + try + { + mxViewId = Reference<XResourceId>(rArguments[0], UNO_QUERY_THROW); + + // Get the XController. + Reference<frame::XController> xController (rArguments[1], UNO_QUERY_THROW); + + // Tunnel through the controller to obtain a ViewShellBase. + ViewShellBase* pBase = NULL; + Reference<lang::XUnoTunnel> xTunnel (xController, UNO_QUERY_THROW); + ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>( + xTunnel->getSomething(sd::DrawController::getUnoTunnelId())); + if (pController != NULL) + pBase = pController->GetViewShellBase(); + + // Get the parent window. + mxParentWindow = Reference<awt::XWindow>(rArguments[2], UNO_QUERY_THROW); + ::Window* pParentWindow = VCLUnoHelper::GetWindow(mxParentWindow); + + mxParentWindow->addWindowListener(this); + + if (pBase != NULL && pParentWindow!=NULL) + mpSlideSorter = SlideSorter::CreateSlideSorter( + *pBase, + NULL, + *pParentWindow); + + Resize(); + } + catch (RuntimeException&) + { + throw; + } + } + else + { + throw RuntimeException( + OUString::createFromAscii("SlideSorterService: invalid number of arguments"), + static_cast<drawing::XDrawView*>(this)); + } +} + + + + +//----- XView ----------------------------------------------------------------- + +Reference<XResourceId> SAL_CALL SlideSorterService::getResourceId (void) + throw (RuntimeException) +{ + return mxViewId; +} + + + + +sal_Bool SAL_CALL SlideSorterService::isAnchorOnly (void) + throw (RuntimeException) +{ + return sal_False; +} + + + + +//----- XWindowListener ------------------------------------------------------- + +void SAL_CALL SlideSorterService::windowResized (const awt::WindowEvent& rEvent) + throw (RuntimeException) +{ + (void)rEvent; + ThrowIfDisposed(); + + Resize(); +} + + + + + +void SAL_CALL SlideSorterService::windowMoved (const awt::WindowEvent& rEvent) + throw (RuntimeException) +{ + (void)rEvent; +} + + + + +void SAL_CALL SlideSorterService::windowShown (const lang::EventObject& rEvent) + throw (RuntimeException) +{ + (void)rEvent; + ThrowIfDisposed(); + Resize(); +} + + + + +void SAL_CALL SlideSorterService::windowHidden (const lang::EventObject& rEvent) + throw (RuntimeException) +{ + (void)rEvent; + ThrowIfDisposed(); +} + + + + +//----- lang::XEventListener -------------------------------------------------- + +void SAL_CALL SlideSorterService::disposing (const lang::EventObject& rEvent) + throw (RuntimeException) +{ + if (rEvent.Source == mxParentWindow) + mxParentWindow = NULL; +} + + + + +//----- XDrawView ------------------------------------------------------------- + +void SAL_CALL SlideSorterService::setCurrentPage(const Reference<drawing::XDrawPage>& rxSlide) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL) + mpSlideSorter->GetController().GetCurrentSlideManager()->CurrentSlideHasChanged( + mpSlideSorter->GetModel().GetIndex(rxSlide)); +} + + + + +Reference<drawing::XDrawPage> SAL_CALL SlideSorterService::getCurrentPage (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL) + return mpSlideSorter->GetController().GetCurrentSlideManager()->GetCurrentSlide()->GetXDrawPage(); + else + return NULL; +} + + + + +//----- attributes ------------------------------------------------------------ + + +Reference<container::XIndexAccess> SAL_CALL SlideSorterService::getDocumentSlides (void) + throw (RuntimeException) +{ + return mpSlideSorter->GetModel().GetDocumentSlides(); +} + + + + +void SAL_CALL SlideSorterService::setDocumentSlides ( + const Reference<container::XIndexAccess >& rxSlides) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid()) + mpSlideSorter->GetController().SetDocumentSlides(rxSlides); +} + + + + +sal_Bool SAL_CALL SlideSorterService::getIsHighlightCurrentSlide (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid()) + return false; + else + return mpSlideSorter->GetController().GetProperties()->IsHighlightCurrentSlide(); +} + + + + +void SAL_CALL SlideSorterService::setIsHighlightCurrentSlide (sal_Bool bValue) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid()) + { + mpSlideSorter->GetController().GetProperties()->SetHighlightCurrentSlide(bValue); + controller::SlideSorterController::ModelChangeLock aLock (mpSlideSorter->GetController()); + mpSlideSorter->GetController().HandleModelChange(); + } +} + + + + +sal_Bool SAL_CALL SlideSorterService::getIsShowSelection (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid()) + return false; + else + return mpSlideSorter->GetController().GetProperties()->IsShowSelection(); +} + + + + +void SAL_CALL SlideSorterService::setIsShowSelection (sal_Bool bValue) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid()) + mpSlideSorter->GetController().GetProperties()->SetShowSelection(bValue); +} + + + + +sal_Bool SAL_CALL SlideSorterService::getIsShowFocus (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid()) + return false; + else + return mpSlideSorter->GetController().GetProperties()->IsShowFocus(); +} + + + + +void SAL_CALL SlideSorterService::setIsShowFocus (sal_Bool bValue) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid()) + mpSlideSorter->GetController().GetProperties()->SetShowFocus(bValue); +} + + + + +sal_Bool SAL_CALL SlideSorterService::getIsCenterSelection (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid()) + return false; + else + return mpSlideSorter->GetController().GetProperties()->IsCenterSelection(); +} + + + + +void SAL_CALL SlideSorterService::setIsCenterSelection (sal_Bool bValue) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid()) + mpSlideSorter->GetController().GetProperties()->SetCenterSelection(bValue); +} + + + + +sal_Bool SAL_CALL SlideSorterService::getIsSuspendPreviewUpdatesDuringFullScreenPresentation (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid()) + return true; + else + return mpSlideSorter->GetController().GetProperties() + ->IsSuspendPreviewUpdatesDuringFullScreenPresentation(); +} + + + + +void SAL_CALL SlideSorterService::setIsSuspendPreviewUpdatesDuringFullScreenPresentation ( + sal_Bool bValue) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid()) + mpSlideSorter->GetController().GetProperties() + ->SetSuspendPreviewUpdatesDuringFullScreenPresentation(bValue); +} + + + + +sal_Bool SAL_CALL SlideSorterService::getIsOrientationVertical (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid()) + return true; + else + return mpSlideSorter->GetView().GetOrientation() == SlideSorterView::VERTICAL; +} + + + + +void SAL_CALL SlideSorterService::setIsOrientationVertical (sal_Bool bValue) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid()) + mpSlideSorter->GetView().SetOrientation(bValue + ? SlideSorterView::VERTICAL + : SlideSorterView::HORIZONTAL); +} + + + + +sal_Bool SAL_CALL SlideSorterService::getIsSmoothScrolling (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid()) + return false; + else + return mpSlideSorter->GetController().GetProperties()->IsSmoothSelectionScrolling(); +} + + + + +void SAL_CALL SlideSorterService::setIsSmoothScrolling (sal_Bool bValue) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid()) + mpSlideSorter->GetController().GetProperties()->SetSmoothSelectionScrolling(bValue); +} + + + + +util::Color SAL_CALL SlideSorterService::getBackgroundColor (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid()) + return util::Color(); + else + return util::Color( + mpSlideSorter->GetController().GetProperties()->GetBackgroundColor().GetColor()); +} + + + + +void SAL_CALL SlideSorterService::setBackgroundColor (util::Color aBackgroundColor) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid()) + mpSlideSorter->GetController().GetProperties()->SetBackgroundColor( + Color(aBackgroundColor)); +} + + + + +util::Color SAL_CALL SlideSorterService::getTextColor (void) + throw (css::uno::RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid()) + return util::Color(); + else + return util::Color( + mpSlideSorter->GetController().GetProperties()->GetTextColor().GetColor()); +} + + + + +void SAL_CALL SlideSorterService::setTextColor (util::Color aTextColor) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid()) + mpSlideSorter->GetController().GetProperties()->SetTextColor( + Color(aTextColor)); +} + + + + +util::Color SAL_CALL SlideSorterService::getSelectionColor (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid()) + return util::Color(); + else + return util::Color( + mpSlideSorter->GetController().GetProperties()->GetSelectionColor().GetColor()); +} + + + + +void SAL_CALL SlideSorterService::setSelectionColor (util::Color aSelectionColor) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid()) + mpSlideSorter->GetController().GetProperties()->SetSelectionColor( + Color(aSelectionColor)); +} + + + + +util::Color SAL_CALL SlideSorterService::getHighlightColor (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid()) + return util::Color(); + else + return util::Color( + mpSlideSorter->GetController().GetProperties()->GetHighlightColor().GetColor()); +} + + + + +void SAL_CALL SlideSorterService::setHighlightColor (util::Color aHighlightColor) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid()) + mpSlideSorter->GetController().GetProperties()->SetHighlightColor( + Color(aHighlightColor)); +} + + + +sal_Bool SAL_CALL SlideSorterService::getIsUIReadOnly (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid()) + return true; + else + return mpSlideSorter->GetController().GetProperties()->IsUIReadOnly(); +} + + + + +void SAL_CALL SlideSorterService::setIsUIReadOnly (sal_Bool bIsUIReadOnly) + throw (RuntimeException) +{ + ThrowIfDisposed(); + if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid()) + mpSlideSorter->GetController().GetProperties()->SetUIReadOnly( + bIsUIReadOnly); +} + + + + +//----------------------------------------------------------------------------- + +void SlideSorterService::Resize (void) +{ + if (mxParentWindow.is()) + { + awt::Rectangle aWindowBox = mxParentWindow->getPosSize(); + mpSlideSorter->ArrangeGUIElements( + Point(0,0), + Size(aWindowBox.Width, aWindowBox.Height)); + } +} + + + + +void SlideSorterService::ThrowIfDisposed (void) + throw (::com::sun::star::lang::DisposedException) +{ + if (SlideSorterServiceInterfaceBase::rBHelper.bDisposed || SlideSorterServiceInterfaceBase::rBHelper.bInDispose) + { + throw lang::DisposedException ( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "SlideSorterService object has already been disposed")), + static_cast<drawing::XDrawView*>(this)); + } +} + + +} } // end of namespace ::sd::presenter + diff --git a/sd/source/ui/slidesorter/shell/SlideSorterService.hxx b/sd/source/ui/slidesorter/shell/SlideSorterService.hxx new file mode 100755 index 000000000000..9af239c64fd1 --- /dev/null +++ b/sd/source/ui/slidesorter/shell/SlideSorterService.hxx @@ -0,0 +1,216 @@ +/************************************************************************* + * + * 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_SERVICE_HXX +#define SD_SLIDESORTER_SLIDE_SORTER_SERVICE_HXX + +#include "SlideSorter.hxx" + +#include "tools/PropertySet.hxx" +#include <com/sun/star/awt/XWindowListener.hpp> +#include <com/sun/star/drawing/SlideSorter.hpp> +#include <com/sun/star/drawing/XDrawView.hpp> +#include <com/sun/star/drawing/framework/XView.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase3.hxx> +#include <cppuhelper/propshlp.hxx> +#include <boost/noncopyable.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/scoped_ptr.hpp> + +namespace css = ::com::sun::star; + +namespace sd { namespace slidesorter { + +namespace { + typedef ::cppu::WeakComponentImplHelper3 < + css::drawing::XSlideSorterBase, + css::lang::XInitialization, + css::awt::XWindowListener + > SlideSorterServiceInterfaceBase; +} + + +/** Implementation of the com.sun.star.drawing.SlideSorter service. +*/ +class SlideSorterService + : private ::boost::noncopyable, + protected ::cppu::BaseMutex, + public SlideSorterServiceInterfaceBase +{ +public: + explicit SlideSorterService ( + const css::uno::Reference<css::uno::XComponentContext>& rxContext); + virtual ~SlideSorterService (void); + virtual void SAL_CALL disposing (void); + + + // XInitialization + + virtual void SAL_CALL initialize (const css::uno::Sequence<css::uno::Any>& rArguments) + throw (css::uno::Exception, css::uno::RuntimeException); + + + // XResourceId + + css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId (void) + throw (css::uno::RuntimeException); + + sal_Bool SAL_CALL isAnchorOnly (void) + throw (css::uno::RuntimeException); + + + // XWindowListener + + virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent) + throw (css::uno::RuntimeException); + + + // lang::XEventListener + virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent) + throw (css::uno::RuntimeException); + + + // XDrawView + + virtual void SAL_CALL setCurrentPage( + const css::uno::Reference<css::drawing::XDrawPage>& rxSlide) + throw (css::uno::RuntimeException); + + virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void) + throw (css::uno::RuntimeException); + + + // Attributes + + virtual css::uno::Reference<css::container::XIndexAccess> SAL_CALL getDocumentSlides (void) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setDocumentSlides ( + const css::uno::Reference<css::container::XIndexAccess >& rxSlides) + throw (css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL getIsHighlightCurrentSlide (void) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setIsHighlightCurrentSlide (::sal_Bool bIsHighlightCurrentSlide) + throw (css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL getIsShowSelection (void) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setIsShowSelection (sal_Bool bIsShowSelection) + throw (css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL getIsCenterSelection (void) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setIsCenterSelection (sal_Bool bIsCenterSelection) + throw (css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL getIsSuspendPreviewUpdatesDuringFullScreenPresentation (void) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setIsSuspendPreviewUpdatesDuringFullScreenPresentation ( + sal_Bool bIsSuspendPreviewUpdatesDuringFullScreenPresentation) + throw (css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL getIsOrientationVertical (void) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setIsOrientationVertical (sal_Bool bIsOrientationVertical) + throw (css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL getIsSmoothScrolling (void) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setIsSmoothScrolling (sal_Bool bIsOrientationVertical) + throw (css::uno::RuntimeException); + + virtual css::util::Color SAL_CALL getBackgroundColor (void) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setBackgroundColor (css::util::Color aBackgroundColor) + throw (css::uno::RuntimeException); + + virtual css::util::Color SAL_CALL getTextColor (void) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setTextColor (css::util::Color aTextColor) + throw (css::uno::RuntimeException); + + virtual css::util::Color SAL_CALL getSelectionColor (void) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setSelectionColor (css::util::Color aSelectionColor) + throw (css::uno::RuntimeException); + + virtual css::util::Color SAL_CALL getHighlightColor (void) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setHighlightColor (css::util::Color aHighlightColor) + throw (css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL getIsUIReadOnly (void) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setIsUIReadOnly (sal_Bool bIsUIReadOnly) + throw (css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL getIsShowFocus (void) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setIsShowFocus (sal_Bool bIsShowFocus) + throw (css::uno::RuntimeException); + +private: + ::boost::shared_ptr<SlideSorter> mpSlideSorter; + css::uno::Reference<css::drawing::framework::XResourceId> mxViewId; + css::uno::Reference<css::awt::XWindow> mxParentWindow; + ::boost::scoped_ptr<cppu::IPropertyArrayHelper> mpPropertyArrayHelper; + + void Resize (void); + + /** This method throws a DisposedException when the object has already been + disposed. + */ + void ThrowIfDisposed (void) throw (css::lang::DisposedException); +}; + +} } // end of namespace ::sd::slidesorter + +#endif diff --git a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx new file mode 100755 index 000000000000..86ec4002cd02 --- /dev/null +++ b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx @@ -0,0 +1,778 @@ +/************************************************************************* + * + * 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 "SlideSorterViewShell.hxx" +#include "ViewShellImplementation.hxx" + +#include "SlideSorter.hxx" +#include "controller/SlideSorterController.hxx" +#include "controller/SlsClipboard.hxx" +#include "controller/SlsFocusManager.hxx" +#include "controller/SlsScrollBarManager.hxx" +#include "controller/SlsPageSelector.hxx" +#include "controller/SlsSlotManager.hxx" +#include "controller/SlsCurrentSlideManager.hxx" +#include "controller/SlsSelectionManager.hxx" +#include "view/SlideSorterView.hxx" +#include "view/SlsLayouter.hxx" +#include "model/SlideSorterModel.hxx" +#include "model/SlsPageEnumeration.hxx" +#include "model/SlsPageDescriptor.hxx" +#include "framework/FrameworkHelper.hxx" +#include "ViewShellBase.hxx" +#include "drawdoc.hxx" +#include "app.hrc" +#include "glob.hrc" +#include "sdattr.hrc" +#include "sdresid.hxx" +#include "AccessibleSlideSorterView.hxx" +#include "DrawDocShell.hxx" +#include "FrameView.hxx" +#include "SdUnoSlideView.hxx" +#include "ViewShellManager.hxx" +#include "Window.hxx" +#include <sfx2/app.hxx> +#include <sfx2/msg.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/request.hxx> +#include <svx/svxids.hrc> +#include <com/sun/star/drawing/framework/XControllerManager.hpp> +#include <com/sun/star/drawing/framework/ResourceId.hpp> +#include <cppuhelper/bootstrap.hxx> +#include <comphelper/processfactory.hxx> + +using namespace ::sd::slidesorter; +#define SlideSorterViewShell +#include "sdslots.hxx" + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::drawing::framework; + +using ::sd::framework::FrameworkHelper; + +namespace sd { namespace slidesorter { + + +SFX_IMPL_INTERFACE(SlideSorterViewShell, SfxShell, SdResId(STR_SLIDESORTERVIEWSHELL)) +{ +} + + + +TYPEINIT1(SlideSorterViewShell, ViewShell); + + + +::boost::shared_ptr<SlideSorterViewShell> SlideSorterViewShell::Create ( + SfxViewFrame* pFrame, + ViewShellBase& rViewShellBase, + ::Window* pParentWindow, + FrameView* pFrameViewArgument) +{ + ::boost::shared_ptr<SlideSorterViewShell> pViewShell; + try + { + pViewShell.reset( + new SlideSorterViewShell(pFrame,rViewShellBase,pParentWindow,pFrameViewArgument)); + pViewShell->Initialize(); + if (pViewShell->mpSlideSorter.get() == NULL) + pViewShell.reset(); + } + catch(Exception&) + { + pViewShell.reset(); + } + return pViewShell; +} + + + + +SlideSorterViewShell::SlideSorterViewShell ( + SfxViewFrame* pFrame, + ViewShellBase& rViewShellBase, + ::Window* pParentWindow, + FrameView* pFrameViewArgument) + : ViewShell (pFrame, pParentWindow, rViewShellBase), + mpSlideSorter() +{ + meShellType = ST_SLIDE_SORTER; + + SetPool( &GetDoc()->GetPool() ); + SetUndoManager( GetDoc()->GetDocSh()->GetUndoManager() ); + + if (pFrameViewArgument != NULL) + mpFrameView = pFrameViewArgument; + else + mpFrameView = new FrameView(GetDoc()); + GetFrameView()->Connect(); + + SetName (String (RTL_CONSTASCII_USTRINGPARAM("SlideSorterViewShell"))); + + pParentWindow->SetStyle(pParentWindow->GetStyle() | WB_DIALOGCONTROL); +} + + + + +SlideSorterViewShell::~SlideSorterViewShell (void) +{ + DisposeFunctions(); + + try + { + ::sd::Window* pWindow = GetActiveWindow(); + if (pWindow!=NULL) + { + ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XComponent> xComponent ( + pWindow->GetAccessible(false), + ::com::sun::star::uno::UNO_QUERY); + if (xComponent.is()) + xComponent->dispose(); + } + } + catch( ::com::sun::star::uno::Exception& e ) + { + (void)e; + DBG_ERROR("sd::SlideSorterViewShell::~SlideSorterViewShell(), exception caught!" ); + } +} + + + + + +void SlideSorterViewShell::Initialize (void) +{ + mpSlideSorter = SlideSorter::CreateSlideSorter( + *this, + mpContentWindow, + mpHorizontalScrollBar, + mpVerticalScrollBar, + mpScrollBarBox); + mpView = &mpSlideSorter->GetView(); + + // For accessibility we have to shortly hide the content window. + // This triggers the construction of a new accessibility object for + // the new view shell. (One is created earlier while the construtor + // of the base class is executed. At that time the correct + // accessibility object can not be constructed.) + ::Window* pWindow = mpSlideSorter->GetActiveWindow(); + if (pWindow != NULL) + { + pWindow->Hide(); + pWindow->Show(); + } +} + + + + +void SlideSorterViewShell::Init (bool bIsMainViewShell) +{ + ViewShell::Init(bIsMainViewShell); + + mpSlideSorter->GetModel().UpdatePageList(); + + if (mpContentWindow.get() != NULL) + mpContentWindow->SetViewShell(this); +} + + + + +SlideSorterViewShell* SlideSorterViewShell::GetSlideSorter (ViewShellBase& rBase) +{ + SlideSorterViewShell* pViewShell = NULL; + + // Test the center, left, and then the right pane for showing a slide sorter. + ::rtl::OUString aPaneURLs[] = { + FrameworkHelper::msCenterPaneURL, + FrameworkHelper::msFullScreenPaneURL, + FrameworkHelper::msLeftImpressPaneURL, + FrameworkHelper::msRightPaneURL, + ::rtl::OUString()}; + + try + { + ::boost::shared_ptr<FrameworkHelper> pFrameworkHelper (FrameworkHelper::Instance(rBase)); + if (pFrameworkHelper->IsValid()) + for (int i=0; pViewShell==NULL && aPaneURLs[i].getLength()>0; ++i) + { + pViewShell = dynamic_cast<SlideSorterViewShell*>( + pFrameworkHelper->GetViewShell(aPaneURLs[i]).get()); + } + } + catch (RuntimeException&) + {} + + return pViewShell; +} + + + + +Reference<drawing::XDrawSubController> SlideSorterViewShell::CreateSubController (void) +{ + Reference<drawing::XDrawSubController> xSubController; + + if (IsMainViewShell()) + { + // Create uno controller for the main view shell. + xSubController = Reference<drawing::XDrawSubController>( + new SdUnoSlideView ( + GetViewShellBase().GetDrawController(), + *mpSlideSorter, + *GetView())); + } + + return xSubController; +} + + + + +/** If there is a valid controller then create a new instance of + <type>AccessibleSlideSorterView</type>. Otherwise delegate this call + to the base class to return a default object (probably an empty + reference). +*/ +::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible> + SlideSorterViewShell::CreateAccessibleDocumentView (::sd::Window* pWindow) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + + // When the view is not set then the initialization is not yet complete + // and we can not yet provide an accessibility object. + if (mpView == NULL) + return NULL; + + return new ::accessibility::AccessibleSlideSorterView ( + *mpSlideSorter.get(), + pWindow->GetAccessibleParentWindow()->GetAccessible(), + pWindow); +} + + + + +SlideSorter& SlideSorterViewShell::GetSlideSorter (void) const +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + return *mpSlideSorter; +} + + + + +bool SlideSorterViewShell::RelocateToParentWindow (::Window* pParentWindow) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + return mpSlideSorter->RelocateToWindow(pParentWindow); +} + + + + +SfxUndoManager* SlideSorterViewShell::ImpGetUndoManager (void) const +{ + SfxShell* pObjectBar = GetViewShellBase().GetViewShellManager()->GetTopShell(); + if (pObjectBar != NULL) + { + // When it exists then return the undo manager of the currently + // active object bar. The object bar is missing when the + // SlideSorterViewShell is not the main view shell. + return pObjectBar->GetUndoManager(); + } + else + { + // Return the undo manager of this shell when there is no object or + // tool bar. + return const_cast<SlideSorterViewShell*>(this)->GetUndoManager(); + } +} + + + + +void SlideSorterViewShell::GetFocus (void) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().GetFocusManager().ShowFocus(); +} + + + + +void SlideSorterViewShell::LoseFocus (void) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().GetFocusManager().HideFocus(); +} + + + + +SdPage* SlideSorterViewShell::getCurrentPage(void) const +{ + // since SlideSorterViewShell::GetActualPage() currently also + // returns master pages, which is a wrong behaviour for GetActualPage(), + // we can just use that for now + return const_cast<SlideSorterViewShell*>(this)->GetActualPage(); +} + + + + +SdPage* SlideSorterViewShell::GetActualPage (void) +{ + SdPage* pCurrentPage = NULL; + + // 1. Try to get the current page from the view shell in the center pane + // (if we are that not ourself). + if ( ! IsMainViewShell()) + { + ::boost::shared_ptr<ViewShell> pMainViewShell = GetViewShellBase().GetMainViewShell(); + if (pMainViewShell.get() != NULL) + pCurrentPage = pMainViewShell->GetActualPage(); + } + + if (pCurrentPage == NULL) + { + model::SharedPageDescriptor pDescriptor ( + mpSlideSorter->GetController().GetCurrentSlideManager()->GetCurrentSlide()); + if (pDescriptor.get() != NULL) + pCurrentPage = pDescriptor->GetPage(); + } + + return pCurrentPage; +} + + + + +void SlideSorterViewShell::GetMenuState ( SfxItemSet& rSet) +{ + ViewShell::GetMenuState(rSet); + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().GetSlotManager()->GetMenuState(rSet); +} + + + + +void SlideSorterViewShell::GetClipboardState ( SfxItemSet& rSet) +{ + ViewShell::GetMenuState(rSet); + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().GetSlotManager()->GetClipboardState(rSet); +} + + + + +void SlideSorterViewShell::ExecCtrl (SfxRequest& rRequest) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().ExecCtrl(rRequest); +} + + + + +void SlideSorterViewShell::GetCtrlState (SfxItemSet& rSet) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().GetCtrlState(rSet); +} + + + + +void SlideSorterViewShell::FuSupport (SfxRequest& rRequest) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().FuSupport(rRequest); +} + + + + +/** We have to handle those slot calls here that need to have access to + private or protected members and methods of this class. +*/ +void SlideSorterViewShell::FuTemporary (SfxRequest& rRequest) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + switch (rRequest.GetSlot()) + { + case SID_MODIFYPAGE: + { + SdPage* pCurrentPage = GetActualPage(); + if (pCurrentPage != NULL) + mpImpl->ProcessModifyPageSlot ( + rRequest, + pCurrentPage, + mpSlideSorter->GetModel().GetPageType()); + Cancel(); + rRequest.Done (); + } + break; + + default: + mpSlideSorter->GetController().FuTemporary(rRequest); + break; + } +} + + + + +void SlideSorterViewShell::GetStatusBarState (SfxItemSet& rSet) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().GetStatusBarState(rSet); +} + + + + +void SlideSorterViewShell::FuPermanent (SfxRequest& rRequest) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().FuPermanent(rRequest); +} + + + + +void SlideSorterViewShell::GetAttrState (SfxItemSet& rSet) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().GetAttrState(rSet); +} + + + + +void SlideSorterViewShell::ExecStatusBar (SfxRequest& rRequest) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().ExecStatusBar(rRequest); +} + + + + +void SlideSorterViewShell::PrePaint() +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + if (mpSlideSorter.get() != NULL) + mpSlideSorter->GetController().PrePaint(); +} + + + + +void SlideSorterViewShell::Paint ( + const Rectangle& rBBox, + ::sd::Window* pWindow) +{ + SetActiveWindow (pWindow); + OSL_ASSERT(mpSlideSorter.get()!=NULL); + if (mpSlideSorter.get() != NULL) + mpSlideSorter->GetController().Paint(rBBox,pWindow); +} + + + + +void SlideSorterViewShell::ArrangeGUIElements (void) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->ArrangeGUIElements( + maViewPos, + maViewSize); +} + + + + +SvBorder SlideSorterViewShell::GetBorder (bool ) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + return mpSlideSorter->GetBorder(); +} + + + + +void SlideSorterViewShell::Command ( + const CommandEvent& rEvent, + ::sd::Window* pWindow) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + if ( ! mpSlideSorter->GetController().Command (rEvent, pWindow)) + ViewShell::Command (rEvent, pWindow); +} + + + + +void SlideSorterViewShell::ReadFrameViewData (FrameView* pFrameView) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + if (pFrameView != NULL) + { + view::SlideSorterView& rView (mpSlideSorter->GetView()); + + USHORT nSlidesPerRow (pFrameView->GetSlidesPerRow()); + if (nSlidesPerRow == 0 || ! IsMainViewShell()) + { + // When a value of 0 (automatic) is given or the the slide + // sorter is displayed in a side pane then we ignore the value + // of the frame view and adapt the number of columns + // automatically to the window width. + rView.GetLayouter().SetColumnCount(1,5); + } + else + rView.GetLayouter().SetColumnCount(nSlidesPerRow,nSlidesPerRow); + mpSlideSorter->GetController().Rearrange(true); + + // DrawMode for 'main' window + if (GetActiveWindow()->GetDrawMode() != pFrameView->GetDrawMode() ) + GetActiveWindow()->SetDrawMode( pFrameView->GetDrawMode() ); + } +} + + + + +void SlideSorterViewShell::WriteFrameViewData() +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + if (mpFrameView != NULL) + { + view::SlideSorterView& rView (mpSlideSorter->GetView()); + mpFrameView->SetSlidesPerRow((USHORT)rView.GetLayouter().GetColumnCount()); + + // DrawMode for 'main' window + if( mpFrameView->GetDrawMode() != GetActiveWindow()->GetDrawMode() ) + mpFrameView->SetDrawMode( GetActiveWindow()->GetDrawMode() ); + + SdPage* pActualPage = GetActualPage(); + if (pActualPage != NULL) + { + // The slide sorter is not expected to switch the current page + // other then by double clicks. That is handled seperatly. + // mpFrameView->SetSelectedPage((pActualPage->GetPageNum()- 1) / 2); + } + else + { + // We have no current page to set but at least we can make sure + // that the index of the frame view has a legal value. + if (mpFrameView->GetSelectedPage() >= mpSlideSorter->GetModel().GetPageCount()) + mpFrameView->SetSelectedPage((USHORT)mpSlideSorter->GetModel().GetPageCount()-1); + } + } +} + + + + +void SlideSorterViewShell::SetZoom (long int ) +{ + // Ignored. + // The zoom scale is adapted internally to fit a number of columns in + // the window. +} + +void SlideSorterViewShell::SetZoomRect (const Rectangle& rZoomRect) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + Size aPageSize (mpSlideSorter->GetView().GetPageBoundingBox( + 0, + view::SlideSorterView::CS_MODEL, + view::SlideSorterView::BBT_SHAPE).GetSize()); + + Rectangle aRect(rZoomRect); + + if (aRect.GetWidth() < aPageSize.Width()) + { + long nWidthDiff = (aPageSize.Width() - aRect.GetWidth()) / 2; + + aRect.Left() -= nWidthDiff; + aRect.Right() += nWidthDiff; + + if (aRect.Left() < 0) + { + aRect.SetPos(Point(0, aRect.Top())); + } + } + + if (aRect.GetHeight() < aPageSize.Height()) + { + long nHeightDiff = (aPageSize.Height() - aRect.GetHeight()) / 2; + + aRect.Top() -= nHeightDiff; + aRect.Bottom() += nHeightDiff; + + if (aRect.Top() < 0) + { + aRect.SetPos(Point(aRect.Left(), 0)); + } + } + + ViewShell::SetZoomRect(aRect); + + // #106268# + GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM ); + GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); +} + + + + +void SlideSorterViewShell::UpdateScrollBars (void) +{ + // Do not call the overwritten method of the base class: We do all the + // scroll bar setup by ourselves. + mpSlideSorter->GetController().GetScrollBarManager().UpdateScrollBars (false); +} + + + + +void SlideSorterViewShell::StartDrag ( + const Point& rDragPt, + ::Window* pWindow ) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().GetClipboard().StartDrag ( + rDragPt, + pWindow); +} + + + + +void SlideSorterViewShell::DragFinished ( + sal_Int8 nDropAction) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().GetClipboard().DragFinished (nDropAction); +} + + + + +sal_Int8 SlideSorterViewShell::AcceptDrop ( + const AcceptDropEvent& rEvt, + DropTargetHelper& rTargetHelper, + ::sd::Window* pTargetWindow, + USHORT nPage, + USHORT nLayer) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + return mpSlideSorter->GetController().GetClipboard().AcceptDrop ( + rEvt, + rTargetHelper, + pTargetWindow, + nPage, + nLayer); +} + + + + +sal_Int8 SlideSorterViewShell::ExecuteDrop ( + const ExecuteDropEvent& rEvt, + DropTargetHelper& rTargetHelper, + ::sd::Window* pTargetWindow, + USHORT nPage, + USHORT nLayer) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + return mpSlideSorter->GetController().GetClipboard().ExecuteDrop ( + rEvt, + rTargetHelper, + pTargetWindow, + nPage, + nLayer); +} + + + + +::boost::shared_ptr<SlideSorterViewShell::PageSelection> + SlideSorterViewShell::GetPageSelection (void) const +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + return mpSlideSorter->GetController().GetPageSelector().GetPageSelection(); +} + + + + +void SlideSorterViewShell::SetPageSelection ( + const ::boost::shared_ptr<PageSelection>& rSelection) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().GetPageSelector().SetPageSelection(rSelection); +} + + + + +void SlideSorterViewShell::AddSelectionChangeListener ( + const Link& rCallback) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().GetSelectionManager()->AddSelectionChangeListener(rCallback); +} + + + + +void SlideSorterViewShell::RemoveSelectionChangeListener ( + const Link& rCallback) +{ + OSL_ASSERT(mpSlideSorter.get()!=NULL); + mpSlideSorter->GetController().GetSelectionManager()->RemoveSelectionChangeListener(rCallback); +} + + + +} } // end of namespace ::sd::slidesorter diff --git a/sd/source/ui/slidesorter/shell/makefile.mk b/sd/source/ui/slidesorter/shell/makefile.mk new file mode 100644 index 000000000000..94209c34dc2b --- /dev/null +++ b/sd/source/ui/slidesorter/shell/makefile.mk @@ -0,0 +1,55 @@ +#************************************************************************* +# +# 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. +# +#************************************************************************* + +PRJ=..$/..$/..$/.. + +PROJECTPCH=sd +PROJECTPCHSOURCE=$(PRJ)$/util$/sd +PRJNAME=sd +TARGET=slsshell +ENABLE_EXCEPTIONS=TRUE +AUTOSEG=true +PRJINC=..$/.. + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES = \ + $(SLO)$/SlideSorter.obj \ + $(SLO)$/SlideSorterService.obj \ + $(SLO)$/SlideSorterViewShell.obj + +EXCEPTIONSFILES= + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + |