summaryrefslogtreecommitdiff
path: root/sdext
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2011-12-08 19:44:51 +0000
committerMichael Meeks <michael.meeks@suse.com>2011-12-08 19:45:40 +0000
commitf1db9ee6c3c6d5be103608379c97d9ec8c865b0d (patch)
tree059ee58246b2b37940c359c48efa6d9bee1f9f4d /sdext
parentd122fd76eb450a423503c97916edfeb0cb69a42a (diff)
Fix misc. bugs in presenter view switch screen feature: make it work.
Diffstat (limited to 'sdext')
-rw-r--r--sdext/source/presenter/PresenterController.cxx16
-rw-r--r--sdext/source/presenter/PresenterController.hxx4
-rw-r--r--sdext/source/presenter/PresenterProtocolHandler.cxx2
-rw-r--r--sdext/source/presenter/PresenterScreen.cxx78
-rw-r--r--sdext/source/presenter/PresenterScreen.hxx11
5 files changed, 85 insertions, 26 deletions
diff --git a/sdext/source/presenter/PresenterController.cxx b/sdext/source/presenter/PresenterController.cxx
index 89c767d64f8f..d6a50f596f89 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 895df7ab7a66..c9f1f16b3592 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 46668b30ae9b..eb9b3b199efc 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 d0872e468679..f904ab122fd9 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 7096c9f72fe6..d9bfac7a69cc 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;
};
} }