summaryrefslogtreecommitdiff
path: root/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx')
-rw-r--r--[-rwxr-xr-x]sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx145
1 files changed, 104 insertions, 41 deletions
diff --git a/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx b/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx
index f5864c3307a1..7b2ca60cb4f0 100755..100644
--- a/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx
@@ -33,8 +33,8 @@
#include "controller/SlsPageSelector.hxx"
#include "controller/SlideSorterController.hxx"
#include "controller/SlsCurrentSlideManager.hxx"
+#include "controller/SlsFocusManager.hxx"
#include "view/SlideSorterView.hxx"
-#include "view/SlsPageObjectViewObjectContact.hxx"
#include "ViewShellBase.hxx"
#include "ViewShell.hxx"
#include "DrawViewShell.hxx"
@@ -47,13 +47,18 @@ 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()
+ mpCurrentSlide(),
+ maSwitchPageDelayTimer()
{
+ maSwitchPageDelayTimer.SetTimeout(100);
+ maSwitchPageDelayTimer.SetTimeoutHdl(LINK(this,CurrentSlideManager,SwitchPageCallback));
}
@@ -66,7 +71,22 @@ CurrentSlideManager::~CurrentSlideManager (void)
-void CurrentSlideManager::CurrentSlideHasChanged (const sal_Int32 nSlideIndex)
+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)
{
@@ -75,8 +95,11 @@ void CurrentSlideManager::CurrentSlideHasChanged (const sal_Int32 nSlideIndex)
// Update the selection.
mrSlideSorter.GetController().GetPageSelector().DeselectAllPages();
- if (mpCurrentSlide.get() != NULL)
+ if (mpCurrentSlide)
+ {
mrSlideSorter.GetController().GetPageSelector().SelectPage(mpCurrentSlide);
+ mrSlideSorter.GetController().GetFocusManager().SetFocusedPage(mpCurrentSlide);
+ }
}
}
@@ -86,10 +109,7 @@ void CurrentSlideManager::CurrentSlideHasChanged (const sal_Int32 nSlideIndex)
void CurrentSlideManager::ReleaseCurrentSlide (void)
{
if (mpCurrentSlide.get() != NULL)
- {
- mpCurrentSlide->SetIsCurrentPage(false);
- mrSlideSorter.GetView().RequestRepaint(mpCurrentSlide);
- }
+ mrSlideSorter.GetView().SetState(mpCurrentSlide, PageDescriptor::ST_Current, false);
mpCurrentSlide.reset();
mnCurrentSlideIndex = -1;
@@ -117,48 +137,64 @@ void CurrentSlideManager::AcquireCurrentSlide (const sal_Int32 nSlideIndex)
// document.
mpCurrentSlide = mrSlideSorter.GetModel().GetPageDescriptor(mnCurrentSlideIndex);
if (mpCurrentSlide.get() != NULL)
- {
- mpCurrentSlide->SetIsCurrentPage(true);
- mrSlideSorter.GetView().RequestRepaint(mpCurrentSlide);
- }
+ mrSlideSorter.GetView().SetState(mpCurrentSlide, PageDescriptor::ST_Current, true);
}
}
-void CurrentSlideManager::SwitchCurrentSlide (const sal_Int32 nSlideIndex)
+void CurrentSlideManager::SwitchCurrentSlide (
+ const sal_Int32 nSlideIndex,
+ const bool bUpdateSelection)
{
- SwitchCurrentSlide(mrSlideSorter.GetModel().GetPageDescriptor(nSlideIndex));
+ SwitchCurrentSlide(mrSlideSorter.GetModel().GetPageDescriptor(nSlideIndex), bUpdateSelection);
}
-void CurrentSlideManager::SwitchCurrentSlide (const SharedPageDescriptor& rpDescriptor)
+void CurrentSlideManager::SwitchCurrentSlide (
+ const SharedPageDescriptor& rpDescriptor,
+ const bool bUpdateSelection)
{
- if (rpDescriptor.get() != NULL)
+ if (rpDescriptor.get() != NULL && mpCurrentSlide!=rpDescriptor)
{
- mpCurrentSlide = rpDescriptor;
- mnCurrentSlideIndex = (rpDescriptor->GetPage()->GetPageNum()-1)/2;
+ 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<USHORT>(mnCurrentSlideIndex));
+ mrSlideSorter.GetController().GetPageSelector().SetCoreSelection();
}
- else
+
+ // 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)
{
- // 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.
- SetCurrentSlideAtViewShellBase(rpDescriptor);
- SetCurrentSlideAtXController(rpDescriptor);
+ mrSlideSorter.GetController().GetPageSelector().DeselectAllPages();
+ mrSlideSorter.GetController().GetPageSelector().SelectPage(rpDescriptor);
}
+ mrSlideSorter.GetController().GetFocusManager().SetFocusedPage(rpDescriptor);
}
}
@@ -180,19 +216,26 @@ void CurrentSlideManager::SetCurrentSlideAtViewShellBase (const SharedPageDescri
pDrawViewShell->SwitchPage(nPageNumber);
pDrawViewShell->GetPageTabControl()->SetCurPageId(nPageNumber+1);
}
- /*
- else
+ }
+}
+
+
+
+
+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)
{
- presenter::PresenterViewShell* pPresenterViewShell
- = dynamic_cast<presenter::PresenterViewShell*>(pBase->GetMainViewShell());
- if (pPresenterViewShell != NULL)
- {
- pPresenterViewShell->SetCurrentSlide(
- Reference<drawing::XDrawPage>(
- rpDescriptor->GetPage()->getUnoPage(), UNO_QUERY));
- }
+ USHORT nPageNumber = (rpDescriptor->GetPage()->GetPageNum()-1)/2;
+ pDrawViewShell->GetPageTabControl()->SetCurPageId(nPageNumber+1);
}
- */
}
}
@@ -215,7 +258,7 @@ void CurrentSlideManager::SetCurrentSlideAtXController (const SharedPageDescript
aPage);
}
}
- catch (beans::UnknownPropertyException aException)
+ catch (Exception aException)
{
// 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,
@@ -246,11 +289,31 @@ void CurrentSlideManager::HandleModelChange (void)
{
if (mnCurrentSlideIndex >= 0)
{
- mpCurrentSlide = mrSlideSorter.GetModel().GetPageDescriptor(
- mnCurrentSlideIndex);
+ mpCurrentSlide = mrSlideSorter.GetModel().GetPageDescriptor(mnCurrentSlideIndex);
if (mpCurrentSlide.get() != NULL)
- mpCurrentSlide->SetIsCurrentPage(true);
+ 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