[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 2 commits - sdext/source sd/source

Michael Meeks michael at kemper.freedesktop.org
Thu Dec 8 13:28:54 PST 2011


 sd/source/ui/app/optsitem.cxx                       |   15 +++
 sd/source/ui/inc/optsitem.hxx                       |    4 -
 sd/source/ui/inc/slideshow.hxx                      |    2 
 sd/source/ui/slideshow/SlideShowRestarter.cxx       |   20 +----
 sd/source/ui/slideshow/SlideShowRestarter.hxx       |    4 -
 sd/source/ui/slideshow/slideshow.cxx                |   26 +++++-
 sdext/source/presenter/PresenterController.cxx      |   16 ++++
 sdext/source/presenter/PresenterController.hxx      |    4 +
 sdext/source/presenter/PresenterProtocolHandler.cxx |    2 
 sdext/source/presenter/PresenterScreen.cxx          |   78 +++++++++++++-------
 sdext/source/presenter/PresenterScreen.hxx          |   11 ++
 11 files changed, 134 insertions(+), 48 deletions(-)

New commits:
commit 202fca9d1534a500ed84dcd4b1e31355a49c4404
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Thu Dec 8 19:44:51 2011 +0000

    Fix misc. bugs in presenter view switch screen feature: make it work.

diff --git a/sd/source/ui/inc/slideshow.hxx b/sd/source/ui/inc/slideshow.hxx
index 4915bf6..486b402 100644
--- a/sd/source/ui/inc/slideshow.hxx
+++ b/sd/source/ui/inc/slideshow.hxx
@@ -63,6 +63,7 @@ class CommandEvent;
 class Rectangle;
 class Window;
 class SfxRequest;
+class WorkWindow;
 
 // TODO: Remove
 #define PAGE_NO_END         65535
@@ -205,6 +206,7 @@ private:
     void ThrowIfDisposed() throw (::com::sun::star::uno::RuntimeException);
 
     void CreateController( ViewShell* pViewSh, ::sd::View* pView, ::Window* pParentWindow );
+    WorkWindow *GetWorkWindow();
 
     // default: disabled copy/assignment
     SlideShow(const SlideShow&);
diff --git a/sd/source/ui/slideshow/SlideShowRestarter.cxx b/sd/source/ui/slideshow/SlideShowRestarter.cxx
index 536b1a6..b017ce8 100644
--- a/sd/source/ui/slideshow/SlideShowRestarter.cxx
+++ b/sd/source/ui/slideshow/SlideShowRestarter.cxx
@@ -58,22 +58,19 @@ SlideShowRestarter::SlideShowRestarter (
 {
 }
 
-
-
-
 SlideShowRestarter::~SlideShowRestarter (void)
 {
 }
 
-
-
-
-void SlideShowRestarter::Restart (void)
+void SlideShowRestarter::Restart (bool bForce)
 {
     // Prevent multiple and concurrently restarts.
     if (mnEventId != 0)
         return;
 
+    if (bForce)
+        mnDisplayCount = 0;
+
     // Remember the current slide in order to restore it after the slide
     // show has been restarted.
     if (mpSlideShow.is())
@@ -90,9 +87,6 @@ void SlideShowRestarter::Restart (void)
         LINK(this, SlideShowRestarter, EndPresentation));
 }
 
-
-
-
 sal_Int32 SlideShowRestarter::GetDisplayCount (void)
 {
     const Reference<XComponentContext> xContext (
@@ -111,9 +105,6 @@ sal_Int32 SlideShowRestarter::GetDisplayCount (void)
     return xIndexAccess->getCount();
 }
 
-
-
-
 IMPL_LINK(SlideShowRestarter, EndPresentation, void*, EMPTYARG)
 {
     mnEventId = 0;
@@ -158,9 +149,6 @@ IMPL_LINK(SlideShowRestarter, EndPresentation, void*, EMPTYARG)
     return 0;
 }
 
-
-
-
 void SlideShowRestarter::StartPresentation (void)
 {
     if (mpDispatcher == NULL && mpViewShellBase!=NULL)
diff --git a/sd/source/ui/slideshow/SlideShowRestarter.hxx b/sd/source/ui/slideshow/SlideShowRestarter.hxx
index 2f5badb..0828176 100644
--- a/sd/source/ui/slideshow/SlideShowRestarter.hxx
+++ b/sd/source/ui/slideshow/SlideShowRestarter.hxx
@@ -62,8 +62,10 @@ public:
 
     /** Restarting the slide show is an asynchronous multi step process
         which is started by calling this method.
+        @param bForce
+           Used to force a re-start, even if the display count is unchanged.
     */
-    void Restart (void);
+    void Restart (bool bForce);
 
 private:
     sal_Int32 mnEventId;
diff --git a/sd/source/ui/slideshow/slideshow.cxx b/sd/source/ui/slideshow/slideshow.cxx
index edb9bb2..ca480f5 100644
--- a/sd/source/ui/slideshow/slideshow.cxx
+++ b/sd/source/ui/slideshow/slideshow.cxx
@@ -97,13 +97,15 @@ namespace {
               mpRestarter(new SlideShowRestarter(rpSlideShow, pViewShellBase))
         {}
 
+        void Restart(bool bForce)
+        {
+            mpRestarter->Restart(bForce);
+        }
 
         virtual void DataChanged (const DataChangedEvent& rEvent)
         {
             if (rEvent.GetType() == DATACHANGED_DISPLAY)
-            {
-                mpRestarter->Restart();
-            }
+                Restart(false);
         }
 
     private:
@@ -555,6 +557,11 @@ void SAL_CALL SlideShow::setPropertyValue( const OUString& aPropertyName, const
 
             SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
             pOptions->SetDisplay( nDisplay );
+
+            FullScreenWorkWindow *pWin = dynamic_cast<FullScreenWorkWindow *>(GetWorkWindow());
+            if( !pWin )
+                return;
+            pWin->Restart(true);
         }
         break;
     }
@@ -674,6 +681,19 @@ void SAL_CALL SlideShow::start() throw(RuntimeException)
 
 // --------------------------------------------------------------------
 
+WorkWindow *SlideShow::GetWorkWindow()
+{
+    if( !mpFullScreenViewShellBase )
+        return NULL;
+
+    PresentationViewShell* pShell = dynamic_cast<PresentationViewShell*>(mpFullScreenViewShellBase->GetMainViewShell().get());
+
+    if( !pShell || !pShell->GetViewFrame() )
+        return NULL;
+
+    return dynamic_cast<WorkWindow*>(pShell->GetViewFrame()->GetTopFrame().GetWindow().GetParent());
+}
+
 void SAL_CALL SlideShow::end() throw(RuntimeException)
 {
     SolarMutexGuard aGuard;
diff --git a/sdext/source/presenter/PresenterController.cxx b/sdext/source/presenter/PresenterController.cxx
index 89c767d..d6a50f5 100644
--- a/sdext/source/presenter/PresenterController.cxx
+++ b/sdext/source/presenter/PresenterController.cxx
@@ -35,6 +35,7 @@
 #include "PresenterCurrentSlideObserver.hxx"
 #include "PresenterFrameworkObserver.hxx"
 #include "PresenterHelper.hxx"
+#include "PresenterScreen.hxx"
 #include "PresenterNotesView.hxx"
 #include "PresenterPaintManager.hxx"
 #include "PresenterPaneAnimator.hxx"
@@ -102,12 +103,14 @@ PresenterController::InstanceContainer PresenterController::maInstances;
 
 
 PresenterController::PresenterController (
+    const css::uno::WeakReference<css::lang::XEventListener> &rxScreen,
     const Reference<XComponentContext>& rxContext,
     const Reference<frame::XController>& rxController,
     const Reference<presentation::XSlideShowController>& rxSlideShowController,
     const rtl::Reference<PresenterPaneContainer>& rpPaneContainer,
     const Reference<XResourceId>& rxMainPaneId)
     : PresenterControllerInterfaceBase(m_aMutex),
+      mxScreen(rxScreen),
       mxComponentContext(rxContext),
       mxController(rxController),
       mxConfigurationController(),
@@ -1346,6 +1349,19 @@ void PresenterController::ThrowIfDisposed (void) const
     }
 }
 
+void PresenterController::SwitchMonitors (void)
+{
+    Reference<lang::XEventListener> xScreen( mxScreen );
+    if (!xScreen.is())
+        return;
+
+    PresenterScreen *pScreen = dynamic_cast<PresenterScreen *>(xScreen.get());
+    if (!pScreen)
+        return;
+
+    pScreen->SwitchMonitors();
+}
+
 
 } } // end of namespace ::sdext::presenter
 
diff --git a/sdext/source/presenter/PresenterController.hxx b/sdext/source/presenter/PresenterController.hxx
index 895df7a..c9f1f16 100644
--- a/sdext/source/presenter/PresenterController.hxx
+++ b/sdext/source/presenter/PresenterController.hxx
@@ -70,6 +70,7 @@ class PresenterPaneAnimator;
 class PresenterPaneContainer;
 class PresenterPaneBorderPainter;
 class PresenterTheme;
+class PresenterScreen;
 class PresenterWindowManager;
 
 namespace {
@@ -97,6 +98,7 @@ public:
         const css::uno::Reference<css::frame::XFrame>& rxFrame);
 
     PresenterController (
+        const css::uno::WeakReference<css::lang::XEventListener> &rxScreen,
         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
         const css::uno::Reference<css::frame::XController>& rxController,
         const css::uno::Reference<css::presentation::XSlideShowController>& rxSlideShowController,
@@ -126,6 +128,7 @@ public:
     double GetSlideAspectRatio (void) const;
     void ShowView (const ::rtl::OUString& rsViewURL);
     void HideView (const ::rtl::OUString& rsViewURL);
+    void SwitchMonitors (void);
     void DispatchUnoCommand (const ::rtl::OUString& rsCommand) const;
     css::uno::Reference<css::frame::XDispatch> GetDispatch (
         const css::util::URL& rURL) const;
@@ -211,6 +214,7 @@ private:
     typedef ::std::map<css::uno::Reference<css::frame::XFrame>,rtl::Reference<PresenterController> > InstanceContainer;
     static InstanceContainer maInstances;
 
+    css::uno::WeakReference<css::lang::XEventListener> mxScreen;
     css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
     css::uno::Reference<css::rendering::XSpriteCanvas> mxCanvas;
     css::uno::Reference<css::frame::XController> mxController;
diff --git a/sdext/source/presenter/PresenterProtocolHandler.cxx b/sdext/source/presenter/PresenterProtocolHandler.cxx
index 46668b3..eb9b3b1 100644
--- a/sdext/source/presenter/PresenterProtocolHandler.cxx
+++ b/sdext/source/presenter/PresenterProtocolHandler.cxx
@@ -613,7 +613,7 @@ SwitchMonitorCommand::SwitchMonitorCommand (
 
 void SwitchMonitorCommand::Execute (void)
 {
-//    fprintf (stderr, "Switch monitor !\n");
+    mpPresenterController->SwitchMonitors();
 }
 
 //===== SetNotesViewCommand ===================================================
diff --git a/sdext/source/presenter/PresenterScreen.cxx b/sdext/source/presenter/PresenterScreen.cxx
index d0872e4..f904ab1 100644
--- a/sdext/source/presenter/PresenterScreen.cxx
+++ b/sdext/source/presenter/PresenterScreen.cxx
@@ -451,6 +451,7 @@ void PresenterScreen::InitializePresenterScreen (void)
                 SetupConfiguration(xContext, xMainPaneId);
 
                 mpPresenterController = new PresenterController(
+                    css::uno::WeakReference<css::lang::XEventListener>(this),
                     xContext,
                     mxController,
                     xSlideShowController,
@@ -476,8 +477,43 @@ void PresenterScreen::InitializePresenterScreen (void)
     }
 }
 
+css::uno::Reference<css::beans::XPropertySet> PresenterScreen::GetDisplayAccess() const
+{
+    Reference<XComponentContext> xContext (mxContextWeak);
+    Reference<lang::XMultiComponentFactory> xFactory (xContext->getServiceManager(), UNO_QUERY_THROW);
+    return Reference<beans::XPropertySet>( xFactory->createInstanceWithContext(A2S("com.sun.star.awt.DisplayAccess"), xContext), UNO_QUERY_THROW);
+}
+
+void PresenterScreen::SwitchMonitors()
+{
+    try {
+        Reference<XPresentationSupplier> xPS ( mxModel, UNO_QUERY_THROW);
+        Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
+
+        sal_Int32 nDefaultDisplay = 0;
+        sal_Int32 nScreen = GetScreenNumber (xPresentation);
+
+        if (nScreen == -1) // only a single display somehow
+            return;
+
+        sal_Int32 nNewScreen = GetPresenterScreenFromScreen (nScreen);
 
+        Reference<beans::XPropertySet> xDisplayProperties = GetDisplayAccess();
+        xDisplayProperties->getPropertyValue(A2S("DefaultDisplay")) >>= nDefaultDisplay;
 
+        if (nNewScreen == nDefaultDisplay)
+            nNewScreen = 0; // screen zero is best == the primary display
+        else
+            nNewScreen++;
+
+        // Set the new presentation display
+        Reference<beans::XPropertySet> xProperties (xPresentation, UNO_QUERY_THROW);
+        uno::Any aDisplay;
+        aDisplay <<= nNewScreen;
+        xProperties->setPropertyValue(A2S("Display"), aDisplay);
+    } catch (const uno::Exception &e) {
+    }
+}
 
 sal_Int32 PresenterScreen::GetScreenNumber (
     const Reference<presentation::XPresentation2>& rxPresentation) const
@@ -496,19 +532,7 @@ sal_Int32 PresenterScreen::GetScreenNumber (
         if ( ! (xProperties->getPropertyValue(A2S("Display")) >>= nDisplayNumber))
             return -1;
 
-        Reference<XComponentContext> xContext (mxContextWeak);
-        if ( ! xContext.is())
-            return -1;
-        Reference<lang::XMultiComponentFactory> xFactory (
-            xContext->getServiceManager(), UNO_QUERY);
-        if ( ! xFactory.is())
-            return -1;
-        Reference<beans::XPropertySet> xDisplayProperties (
-            xFactory->createInstanceWithContext(A2S("com.sun.star.awt.DisplayAccess"),xContext),
-            UNO_QUERY);
-        if  ( ! xDisplayProperties.is())
-            return -1;
-
+        Reference<beans::XPropertySet> xDisplayProperties = GetDisplayAccess();
         if (nDisplayNumber > 0)
         {
             nScreenNumber = nDisplayNumber - 1;
@@ -535,6 +559,7 @@ sal_Int32 PresenterScreen::GetScreenNumber (
             // presentation spans all available screens.  The presenter
             // screen is shown only when a special flag in the configuration
             // is set.
+            Reference<XComponentContext> xContext (mxContextWeak);
             PresenterConfigurationAccess aConfiguration (
                 xContext,
                 OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Office.extension.PresenterScreen/")),
@@ -560,21 +585,12 @@ sal_Int32 PresenterScreen::GetScreenNumber (
 }
 
 
-
-
-Reference<drawing::framework::XResourceId> PresenterScreen::GetMainPaneId (
-    const Reference<presentation::XPresentation2>& rxPresentation) const
+sal_Int32 PresenterScreen::GetPresenterScreenFromScreen( sal_Int32 nPresentationScreen ) const
 {
-    // A negative value means that the presentation spans all available
-    // displays.  That leaves no room for the presenter.
-    const sal_Int32 nScreenNumber(GetScreenNumber(rxPresentation));
-    if (nScreenNumber < 0)
-        return NULL;
-
     // Setup the resource id of the full screen background pane so that
     // it is displayed on another screen than the presentation.
     sal_Int32 nPresenterScreenNumber (1);
-    switch (nScreenNumber)
+    switch (nPresentationScreen)
     {
         case 0:
             nPresenterScreenNumber = 1;
@@ -591,6 +607,20 @@ Reference<drawing::framework::XResourceId> PresenterScreen::GetMainPaneId (
             nPresenterScreenNumber = 0;
             break;
     }
+    return nPresenterScreenNumber;
+}
+
+
+Reference<drawing::framework::XResourceId> PresenterScreen::GetMainPaneId (
+    const Reference<presentation::XPresentation2>& rxPresentation) const
+{
+    // A negative value means that the presentation spans all available
+    // displays.  That leaves no room for the presenter.
+    const sal_Int32 nScreenNumber(GetScreenNumber(rxPresentation));
+    if (nScreenNumber < 0)
+        return NULL;
+
+    sal_Int32 nPresenterScreenNumber = GetPresenterScreenFromScreen (nScreenNumber);
 
     return ResourceId::create(
         Reference<XComponentContext>(mxContextWeak),
diff --git a/sdext/source/presenter/PresenterScreen.hxx b/sdext/source/presenter/PresenterScreen.hxx
index 7096c9f..d9bfac7 100644
--- a/sdext/source/presenter/PresenterScreen.hxx
+++ b/sdext/source/presenter/PresenterScreen.hxx
@@ -137,6 +137,9 @@ public:
     */
     void RequestShutdownPresenterScreen (void);
 
+    /** Switch / converse monitors between presenter view and slide output
+     */
+    void SwitchMonitors (void);
 
     // XEventListener
 
@@ -228,7 +231,7 @@ private:
         const double nRight,
         const double nBottom);
 
-    /** Return the screen number on which to display the presenter screen.
+    /** Return the screen number on which to display the presentation itself
         @return
             Returns -1 when the presenter screen can or shall not be
             displayed.
@@ -236,11 +239,17 @@ private:
     sal_Int32 GetScreenNumber (
         const css::uno::Reference<css::presentation::XPresentation2>& rxPresentation) const;
 
+    sal_Int32 GetPresenterScreenFromScreen( sal_Int32 nPresentationScreen ) const;
+
     /** Create a resource id for the full screen background pane so that it
         is displayed on another screen than the full screen presentation.
     */
     css::uno::Reference<css::drawing::framework::XResourceId> GetMainPaneId (
         const css::uno::Reference<css::presentation::XPresentation2>& rxPresentation) const;
+
+    /** Gets the display access property bag
+     */
+    css::uno::Reference<css::beans::XPropertySet> GetDisplayAccess () const;
 };
 
 } }
commit b60260eaf8211ab1dbe5af0a57523321d66b0db1
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Thu Dec 8 19:41:50 2011 +0000

    de-inline display fetch/set functions to assist in debugging

diff --git a/sd/source/ui/app/optsitem.cxx b/sd/source/ui/app/optsitem.cxx
index b3b8cd7..99b9442 100644
--- a/sd/source/ui/app/optsitem.cxx
+++ b/sd/source/ui/app/optsitem.cxx
@@ -1586,4 +1586,19 @@ void SdOptions::StoreConfig( sal_uLong nOptionsRange )
         SdOptionsPrint::Store();
 }
 
+sal_Int32 SdOptionsMisc::GetDisplay() const
+{
+    Init();
+    return mnDisplay;
+}
+
+void SdOptionsMisc::SetDisplay( sal_Int32 nDisplay )
+{
+    if( mnDisplay != nDisplay )
+    {
+        OptionsChanged();
+        mnDisplay = nDisplay;
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/optsitem.hxx b/sd/source/ui/inc/optsitem.hxx
index 8eb5ae6..0cd66e1 100644
--- a/sd/source/ui/inc/optsitem.hxx
+++ b/sd/source/ui/inc/optsitem.hxx
@@ -329,8 +329,8 @@ public:
     sal_Bool    IsPreviewChangedEffects() const { Init(); return bPreviewChangedEffects; }
     sal_Bool    IsPreviewTransitions() const { Init(); return bPreviewTransitions; }
 
-    sal_Int32   GetDisplay() const { Init(); return mnDisplay; }
-    void        SetDisplay( sal_Int32 nDisplay = 0 ) { if( mnDisplay != nDisplay ) { OptionsChanged(); mnDisplay = nDisplay; } }
+    sal_Int32   GetDisplay() const;
+    void        SetDisplay( sal_Int32 nDisplay = 0 );
 
     sal_Int32 GetPresentationPenColor() const { Init(); return mnPenColor; }
     void      SetPresentationPenColor( sal_Int32 nPenColor ) { if( mnPenColor != nPenColor ) { OptionsChanged(); mnPenColor = nPenColor; } }


More information about the Libreoffice-commits mailing list