1*c142477cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c142477cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c142477cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c142477cSAndrew Rist  * distributed with this work for additional information
6*c142477cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c142477cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c142477cSAndrew Rist  * "License"); you may not use this file except in compliance
9*c142477cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c142477cSAndrew Rist  *
11*c142477cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c142477cSAndrew Rist  *
13*c142477cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c142477cSAndrew Rist  * software distributed under the License is distributed on an
15*c142477cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c142477cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c142477cSAndrew Rist  * specific language governing permissions and limitations
18*c142477cSAndrew Rist  * under the License.
19*c142477cSAndrew Rist  *
20*c142477cSAndrew Rist  *************************************************************/
21*c142477cSAndrew Rist 
22*c142477cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sdext.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "PresenterController.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "PresenterAccessibility.hxx"
30cdf0e10cSrcweir #include "PresenterAnimator.hxx"
31cdf0e10cSrcweir #include "PresenterCanvasHelper.hxx"
32cdf0e10cSrcweir #include "PresenterCurrentSlideObserver.hxx"
33cdf0e10cSrcweir #include "PresenterFrameworkObserver.hxx"
34cdf0e10cSrcweir #include "PresenterHelper.hxx"
35cdf0e10cSrcweir #include "PresenterNotesView.hxx"
36cdf0e10cSrcweir #include "PresenterPaintManager.hxx"
37cdf0e10cSrcweir #include "PresenterPaneAnimator.hxx"
38cdf0e10cSrcweir #include "PresenterPaneBase.hxx"
39cdf0e10cSrcweir #include "PresenterPaneContainer.hxx"
40cdf0e10cSrcweir #include "PresenterPaneBorderPainter.hxx"
41cdf0e10cSrcweir #include "PresenterTheme.hxx"
42cdf0e10cSrcweir #include "PresenterViewFactory.hxx"
43cdf0e10cSrcweir #include "PresenterWindowManager.hxx"
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
46cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp>
47cdf0e10cSrcweir #include <com/sun/star/awt/Key.hpp>
48cdf0e10cSrcweir #include <com/sun/star/awt/KeyModifier.hpp>
49cdf0e10cSrcweir #include <com/sun/star/awt/MouseButton.hpp>
50cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp>
51cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp>
52cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawView.hpp>
53cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
54cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp>
55cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ResourceId.hpp>
56cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp>
57cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
58cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
59cdf0e10cSrcweir #include <com/sun/star/presentation/XPresentation.hpp>
60cdf0e10cSrcweir #include <com/sun/star/presentation/XPresentationSupplier.hpp>
61cdf0e10cSrcweir #include <com/sun/star/rendering/CompositeOperation.hpp>
62cdf0e10cSrcweir #include <com/sun/star/rendering/TextDirection.hpp>
63cdf0e10cSrcweir 
64cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
65cdf0e10cSrcweir #include <boost/bind.hpp>
66cdf0e10cSrcweir 
67cdf0e10cSrcweir using namespace ::com::sun::star;
68cdf0e10cSrcweir using namespace ::com::sun::star::uno;
69cdf0e10cSrcweir using namespace ::com::sun::star::presentation;
70cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
71cdf0e10cSrcweir using ::rtl::OUString;
72cdf0e10cSrcweir using ::rtl::OUStringBuffer;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir namespace {
75cdf0e10cSrcweir     const sal_Int32 ResourceActivationEventType = 0;
76cdf0e10cSrcweir     const sal_Int32 ResourceDeactivationEventType = 1;
77cdf0e10cSrcweir     const sal_Int32 ConfigurationUpdateEndEventType = 2;
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 
81cdf0e10cSrcweir #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 
84cdf0e10cSrcweir namespace sdext { namespace presenter {
85cdf0e10cSrcweir 
86cdf0e10cSrcweir PresenterController::InstanceContainer PresenterController::maInstances;
87cdf0e10cSrcweir 
Instance(const css::uno::Reference<css::frame::XFrame> & rxFrame)88cdf0e10cSrcweir ::rtl::Reference<PresenterController> PresenterController::Instance (
89cdf0e10cSrcweir     const css::uno::Reference<css::frame::XFrame>& rxFrame)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir     InstanceContainer::const_iterator iInstance (maInstances.find(rxFrame));
92cdf0e10cSrcweir     if (iInstance != maInstances.end())
93cdf0e10cSrcweir         return iInstance->second;
94cdf0e10cSrcweir     else
95cdf0e10cSrcweir         return ::rtl::Reference<PresenterController>();
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 
PresenterController(const Reference<XComponentContext> & rxContext,const Reference<frame::XController> & rxController,const Reference<presentation::XSlideShowController> & rxSlideShowController,const rtl::Reference<PresenterPaneContainer> & rpPaneContainer,const Reference<XResourceId> & rxMainPaneId)101cdf0e10cSrcweir PresenterController::PresenterController (
102cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext,
103cdf0e10cSrcweir     const Reference<frame::XController>& rxController,
104cdf0e10cSrcweir     const Reference<presentation::XSlideShowController>& rxSlideShowController,
105cdf0e10cSrcweir     const rtl::Reference<PresenterPaneContainer>& rpPaneContainer,
106cdf0e10cSrcweir     const Reference<XResourceId>& rxMainPaneId)
107cdf0e10cSrcweir     : PresenterControllerInterfaceBase(m_aMutex),
108cdf0e10cSrcweir       mxComponentContext(rxContext),
109cdf0e10cSrcweir       mxController(rxController),
110cdf0e10cSrcweir       mxConfigurationController(),
111cdf0e10cSrcweir       mxSlideShowController(rxSlideShowController),
112cdf0e10cSrcweir       mxMainPaneId(rxMainPaneId),
113cdf0e10cSrcweir       mpPaneContainer(rpPaneContainer),
114cdf0e10cSrcweir       mnCurrentSlideIndex(-1),
115cdf0e10cSrcweir       mxCurrentSlide(),
116cdf0e10cSrcweir       mxNextSlide(),
117cdf0e10cSrcweir       mpWindowManager(new PresenterWindowManager(rxContext,mpPaneContainer,this)),
118cdf0e10cSrcweir       mpCurrentPaneAnimation(),
119cdf0e10cSrcweir       mnWindowBackgroundColor(0x00ffffff),
120cdf0e10cSrcweir       mpTheme(),
121cdf0e10cSrcweir       mxMainWindow(),
122cdf0e10cSrcweir       mpPaneBorderPainter(),
123cdf0e10cSrcweir       mpAnimator(new PresenterAnimator()),
124cdf0e10cSrcweir       mpCanvasHelper(new PresenterCanvasHelper()),
125cdf0e10cSrcweir       mxPresenterHelper(),
126cdf0e10cSrcweir       mpPaintManager(),
127cdf0e10cSrcweir       mnPendingSlideNumber(-1),
128cdf0e10cSrcweir       mxUrlTransformer(),
129cdf0e10cSrcweir       mpAccessibleObject(),
130cdf0e10cSrcweir       mbIsAccessibilityActive(false)
131cdf0e10cSrcweir {
132cdf0e10cSrcweir     OSL_ASSERT(mxController.is());
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     if ( ! mxSlideShowController.is())
135cdf0e10cSrcweir         throw new lang::IllegalArgumentException(
136cdf0e10cSrcweir             A2S("missing slide show controller"),
137cdf0e10cSrcweir             static_cast<XWeak*>(this),
138cdf0e10cSrcweir             2);
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     new PresenterCurrentSlideObserver(this,rxSlideShowController);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     // Listen for configuration changes.
143cdf0e10cSrcweir     Reference<XControllerManager> xCM (mxController, UNO_QUERY_THROW);
144cdf0e10cSrcweir     mxConfigurationController = xCM->getConfigurationController();
145cdf0e10cSrcweir     if (mxConfigurationController.is())
146cdf0e10cSrcweir     {
147cdf0e10cSrcweir         mxConfigurationController->addConfigurationChangeListener(
148cdf0e10cSrcweir             this,
149cdf0e10cSrcweir             A2S("ResourceActivation"),
150cdf0e10cSrcweir             Any(ResourceActivationEventType));
151cdf0e10cSrcweir         mxConfigurationController->addConfigurationChangeListener(
152cdf0e10cSrcweir             this,
153cdf0e10cSrcweir             A2S("ResourceDeactivation"),
154cdf0e10cSrcweir             Any(ResourceDeactivationEventType));
155cdf0e10cSrcweir         mxConfigurationController->addConfigurationChangeListener(
156cdf0e10cSrcweir             this,
157cdf0e10cSrcweir             A2S("ConfigurationUpdateEnd"),
158cdf0e10cSrcweir             Any(ConfigurationUpdateEndEventType));
159cdf0e10cSrcweir     }
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     // Listen for the frame being activated.
162cdf0e10cSrcweir     Reference<frame::XFrame> xFrame (mxController->getFrame());
163cdf0e10cSrcweir     if (xFrame.is())
164cdf0e10cSrcweir         xFrame->addFrameActionListener(this);
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     // Create the border painter.
167cdf0e10cSrcweir     mpPaneBorderPainter = new PresenterPaneBorderPainter(rxContext);
168cdf0e10cSrcweir     mpWindowManager->SetPaneBorderPainter(mpPaneBorderPainter);
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     // Create an object that is able to load the bitmaps in a format that is
171cdf0e10cSrcweir     // supported by the canvas.
172cdf0e10cSrcweir     Reference<lang::XMultiComponentFactory> xFactory (
173cdf0e10cSrcweir         rxContext->getServiceManager(), UNO_QUERY);
174cdf0e10cSrcweir     if ( ! xFactory.is())
175cdf0e10cSrcweir         return;
176cdf0e10cSrcweir     mxPresenterHelper = Reference<drawing::XPresenterHelper>(
177cdf0e10cSrcweir         xFactory->createInstanceWithContext(
178cdf0e10cSrcweir             A2S("com.sun.star.drawing.PresenterHelper"),
179cdf0e10cSrcweir             rxContext),
180cdf0e10cSrcweir         UNO_QUERY_THROW);
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     if (mxSlideShowController.is())
183cdf0e10cSrcweir     {
184cdf0e10cSrcweir         mxSlideShowController->activate();
185cdf0e10cSrcweir         Reference<beans::XPropertySet> xProperties (mxSlideShowController, UNO_QUERY);
186cdf0e10cSrcweir         if (xProperties.is())
187cdf0e10cSrcweir         {
188cdf0e10cSrcweir             Reference<awt::XWindow> xWindow (
189cdf0e10cSrcweir                 xProperties->getPropertyValue(A2S("ParentWindow")), UNO_QUERY);
190cdf0e10cSrcweir             if (xWindow.is())
191cdf0e10cSrcweir                 xWindow->addKeyListener(this);
192cdf0e10cSrcweir         }
193cdf0e10cSrcweir     }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     UpdateCurrentSlide(0);
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     maInstances[mxController->getFrame()] = this;
198cdf0e10cSrcweir 
199cdf0e10cSrcweir     // Create a URLTransformer.
200cdf0e10cSrcweir     if (xFactory.is())
201cdf0e10cSrcweir     {
202cdf0e10cSrcweir         mxUrlTransformer = Reference<util::XURLTransformer>(
203cdf0e10cSrcweir             xFactory->createInstanceWithContext(
204cdf0e10cSrcweir                 A2S("com.sun.star.util.URLTransformer"),
205cdf0e10cSrcweir                 mxComponentContext),
206cdf0e10cSrcweir             UNO_QUERY);
207cdf0e10cSrcweir     }
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 
~PresenterController(void)213cdf0e10cSrcweir PresenterController::~PresenterController (void)
214cdf0e10cSrcweir {
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 
disposing(void)220cdf0e10cSrcweir void PresenterController::disposing (void)
221cdf0e10cSrcweir {
222cdf0e10cSrcweir     maInstances.erase(mxController->getFrame());
223cdf0e10cSrcweir 
224cdf0e10cSrcweir     if (mxMainWindow.is())
225cdf0e10cSrcweir     {
226cdf0e10cSrcweir         mxMainWindow->removeKeyListener(this);
227cdf0e10cSrcweir         mxMainWindow->removeFocusListener(this);
228cdf0e10cSrcweir         mxMainWindow->removeMouseListener(this);
229cdf0e10cSrcweir         mxMainWindow->removeMouseMotionListener(this);
230cdf0e10cSrcweir         mxMainWindow = NULL;
231cdf0e10cSrcweir     }
232cdf0e10cSrcweir     if (mxConfigurationController.is())
233cdf0e10cSrcweir         mxConfigurationController->removeConfigurationChangeListener(this);
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     Reference<XComponent> xWindowManagerComponent (
236cdf0e10cSrcweir         static_cast<XWeak*>(mpWindowManager.get()), UNO_QUERY);
237cdf0e10cSrcweir     mpWindowManager = NULL;
238cdf0e10cSrcweir     if (xWindowManagerComponent.is())
239cdf0e10cSrcweir         xWindowManagerComponent->dispose();
240cdf0e10cSrcweir 
241cdf0e10cSrcweir     if (mxController.is())
242cdf0e10cSrcweir     {
243cdf0e10cSrcweir         Reference<frame::XFrame> xFrame (mxController->getFrame());
244cdf0e10cSrcweir         if (xFrame.is())
245cdf0e10cSrcweir             xFrame->removeFrameActionListener(this);
246cdf0e10cSrcweir         mxController = NULL;
247cdf0e10cSrcweir     }
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     mxComponentContext = NULL;
250cdf0e10cSrcweir     mxConfigurationController = NULL;
251cdf0e10cSrcweir     mxSlideShowController = NULL;
252cdf0e10cSrcweir     mxMainPaneId = NULL;
253cdf0e10cSrcweir     mpPaneContainer = NULL;
254cdf0e10cSrcweir     mnCurrentSlideIndex = -1;
255cdf0e10cSrcweir     mxCurrentSlide = NULL;
256cdf0e10cSrcweir     mxNextSlide = NULL;
257cdf0e10cSrcweir     mpCurrentPaneAnimation.reset();
258cdf0e10cSrcweir     mpTheme.reset();
259cdf0e10cSrcweir     {
260cdf0e10cSrcweir         Reference<lang::XComponent> xComponent (
261cdf0e10cSrcweir             static_cast<XWeak*>(mpPaneBorderPainter.get()), UNO_QUERY);
262cdf0e10cSrcweir         mpPaneBorderPainter = NULL;
263cdf0e10cSrcweir         if (xComponent.is())
264cdf0e10cSrcweir             xComponent->dispose();
265cdf0e10cSrcweir     }
266cdf0e10cSrcweir     mpAnimator.reset();
267cdf0e10cSrcweir     mpCanvasHelper.reset();
268cdf0e10cSrcweir     {
269cdf0e10cSrcweir         Reference<lang::XComponent> xComponent (mxPresenterHelper, UNO_QUERY);
270cdf0e10cSrcweir         mxPresenterHelper = NULL;
271cdf0e10cSrcweir         if (xComponent.is())
272cdf0e10cSrcweir             xComponent->dispose();
273cdf0e10cSrcweir     }
274cdf0e10cSrcweir     mpPaintManager.reset();
275cdf0e10cSrcweir     mnPendingSlideNumber = -1;
276cdf0e10cSrcweir     {
277cdf0e10cSrcweir         Reference<lang::XComponent> xComponent (mxUrlTransformer, UNO_QUERY);
278cdf0e10cSrcweir         mxUrlTransformer = NULL;
279cdf0e10cSrcweir         if (xComponent.is())
280cdf0e10cSrcweir             xComponent->dispose();
281cdf0e10cSrcweir     }
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 
UpdateCurrentSlide(const sal_Int32 nOffset)287cdf0e10cSrcweir void PresenterController::UpdateCurrentSlide (const sal_Int32 nOffset)
288cdf0e10cSrcweir {
289cdf0e10cSrcweir     GetSlides(nOffset);
290cdf0e10cSrcweir     UpdatePaneTitles();
291cdf0e10cSrcweir     UpdateViews();
292cdf0e10cSrcweir 
293cdf0e10cSrcweir     // Update the accessibility object.
294cdf0e10cSrcweir     if (IsAccessibilityActive())
295cdf0e10cSrcweir     {
296cdf0e10cSrcweir         sal_Int32 nSlideCount (0);
297cdf0e10cSrcweir         Reference<container::XIndexAccess> xIndexAccess(mxSlideShowController, UNO_QUERY);
298cdf0e10cSrcweir         if (xIndexAccess.is())
299cdf0e10cSrcweir             nSlideCount = xIndexAccess->getCount();
300cdf0e10cSrcweir         mpAccessibleObject->NotifyCurrentSlideChange(mnCurrentSlideIndex, nSlideCount);
301cdf0e10cSrcweir     }
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 
GetSlides(const sal_Int32 nOffset)307cdf0e10cSrcweir void PresenterController::GetSlides (const sal_Int32 nOffset)
308cdf0e10cSrcweir {
309cdf0e10cSrcweir     if ( ! mxSlideShowController.is())
310cdf0e10cSrcweir         return;
311cdf0e10cSrcweir 
312cdf0e10cSrcweir     // Get the current slide from the slide show controller.
313cdf0e10cSrcweir     mxCurrentSlide = NULL;
314cdf0e10cSrcweir     Reference<container::XIndexAccess> xIndexAccess(mxSlideShowController, UNO_QUERY);
315cdf0e10cSrcweir     sal_Int32 nSlideIndex = -1;
316cdf0e10cSrcweir     try
317cdf0e10cSrcweir     {
318cdf0e10cSrcweir         nSlideIndex = mxSlideShowController->getCurrentSlideIndex() + nOffset;
319cdf0e10cSrcweir         if (mxSlideShowController->isPaused())
320cdf0e10cSrcweir             nSlideIndex = -1;
321cdf0e10cSrcweir 
322cdf0e10cSrcweir         if (xIndexAccess.is() && nSlideIndex>=0)
323cdf0e10cSrcweir         {
324cdf0e10cSrcweir             if (nSlideIndex < xIndexAccess->getCount())
325cdf0e10cSrcweir             {
326cdf0e10cSrcweir                 mnCurrentSlideIndex = nSlideIndex;
327cdf0e10cSrcweir                 mxCurrentSlide = Reference<drawing::XDrawPage>(
328cdf0e10cSrcweir                     xIndexAccess->getByIndex(nSlideIndex), UNO_QUERY);
329cdf0e10cSrcweir             }
330cdf0e10cSrcweir         }
331cdf0e10cSrcweir     }
332cdf0e10cSrcweir     catch (RuntimeException&)
333cdf0e10cSrcweir     {
334cdf0e10cSrcweir     }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir     // Get the next slide.
337cdf0e10cSrcweir     mxNextSlide = NULL;
338cdf0e10cSrcweir     try
339cdf0e10cSrcweir     {
340cdf0e10cSrcweir         const sal_Int32 nNextSlideIndex (mxSlideShowController->getNextSlideIndex()+nOffset);
341cdf0e10cSrcweir         if (nNextSlideIndex >= 0)
342cdf0e10cSrcweir         {
343cdf0e10cSrcweir             if (xIndexAccess.is())
344cdf0e10cSrcweir             {
345cdf0e10cSrcweir                 if (nNextSlideIndex < xIndexAccess->getCount())
346cdf0e10cSrcweir                     mxNextSlide = Reference<drawing::XDrawPage>(
347cdf0e10cSrcweir                         xIndexAccess->getByIndex(nNextSlideIndex), UNO_QUERY);
348cdf0e10cSrcweir             }
349cdf0e10cSrcweir         }
350cdf0e10cSrcweir     }
351cdf0e10cSrcweir     catch (RuntimeException&)
352cdf0e10cSrcweir     {
353cdf0e10cSrcweir     }
354cdf0e10cSrcweir }
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 
UpdatePaneTitles(void)359cdf0e10cSrcweir void PresenterController::UpdatePaneTitles (void)
360cdf0e10cSrcweir {
361cdf0e10cSrcweir     if ( ! mxSlideShowController.is())
362cdf0e10cSrcweir         return;
363cdf0e10cSrcweir 
364cdf0e10cSrcweir     // Get placeholders and their values.
365cdf0e10cSrcweir     const OUString sCurrentSlideNumberPlaceholder (A2S("CURRENT_SLIDE_NUMBER"));
366cdf0e10cSrcweir     const OUString sCurrentSlideNamePlaceholder (A2S("CURRENT_SLIDE_NAME"));
367cdf0e10cSrcweir     const OUString sSlideCountPlaceholder (A2S("SLIDE_COUNT"));
368cdf0e10cSrcweir 
369cdf0e10cSrcweir     // Get string for slide count.
370cdf0e10cSrcweir     OUString sSlideCount (A2S("---"));
371cdf0e10cSrcweir     Reference<container::XIndexAccess> xIndexAccess(mxSlideShowController, UNO_QUERY);
372cdf0e10cSrcweir     if (xIndexAccess.is())
373cdf0e10cSrcweir         sSlideCount = OUString::valueOf(xIndexAccess->getCount());
374cdf0e10cSrcweir 
375cdf0e10cSrcweir     // Get string for current slide index.
376cdf0e10cSrcweir     OUString sCurrentSlideNumber (OUString::valueOf(mnCurrentSlideIndex + 1));
377cdf0e10cSrcweir 
378cdf0e10cSrcweir     // Get name of the current slide.
379cdf0e10cSrcweir     OUString sCurrentSlideName;
380cdf0e10cSrcweir     Reference<container::XNamed> xNamedSlide (mxCurrentSlide, UNO_QUERY);
381cdf0e10cSrcweir     if (xNamedSlide.is())
382cdf0e10cSrcweir         sCurrentSlideName = xNamedSlide->getName();
383cdf0e10cSrcweir     Reference<beans::XPropertySet> xSlideProperties (mxCurrentSlide, UNO_QUERY);
384cdf0e10cSrcweir     if (xSlideProperties.is())
385cdf0e10cSrcweir     {
386cdf0e10cSrcweir         try
387cdf0e10cSrcweir         {
388cdf0e10cSrcweir             OUString sName;
389cdf0e10cSrcweir             if (xSlideProperties->getPropertyValue(A2S("LinkDisplayName")) >>= sName)
390cdf0e10cSrcweir             {
391cdf0e10cSrcweir                 // Find out whether the name of the current slide has been
392cdf0e10cSrcweir                 // automatically created or has been set by the user.
393cdf0e10cSrcweir                 if (sName != sCurrentSlideName)
394cdf0e10cSrcweir                     sCurrentSlideName = sName;
395cdf0e10cSrcweir             }
396cdf0e10cSrcweir         }
397cdf0e10cSrcweir         catch (beans::UnknownPropertyException&)
398cdf0e10cSrcweir         {
399cdf0e10cSrcweir         }
400cdf0e10cSrcweir     }
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     // Replace the placeholders with their current values.
403cdf0e10cSrcweir     PresenterPaneContainer::PaneList::const_iterator iPane;
404cdf0e10cSrcweir     for (iPane=mpPaneContainer->maPanes.begin(); iPane!=mpPaneContainer->maPanes.end(); ++iPane)
405cdf0e10cSrcweir     {
406cdf0e10cSrcweir         OSL_ASSERT((*iPane).get() != NULL);
407cdf0e10cSrcweir 
408cdf0e10cSrcweir         OUString sTemplate (IsAccessibilityActive()
409cdf0e10cSrcweir             ? (*iPane)->msAccessibleTitleTemplate
410cdf0e10cSrcweir             : (*iPane)->msTitleTemplate);
411cdf0e10cSrcweir         if (sTemplate.getLength() <= 0)
412cdf0e10cSrcweir             continue;
413cdf0e10cSrcweir 
414cdf0e10cSrcweir         OUStringBuffer sResult;
415cdf0e10cSrcweir         sResult.ensureCapacity(sTemplate.getLength());
416cdf0e10cSrcweir 
417cdf0e10cSrcweir         sal_Int32 nIndex (0);
418cdf0e10cSrcweir         while (true)
419cdf0e10cSrcweir         {
420cdf0e10cSrcweir             sal_Int32 nStartIndex = sTemplate.indexOf('%', nIndex);
421cdf0e10cSrcweir             if (nStartIndex < 0)
422cdf0e10cSrcweir             {
423cdf0e10cSrcweir                 // Add the remaining part of the string.
424cdf0e10cSrcweir                 sResult.append(sTemplate.copy(nIndex, sTemplate.getLength()-nIndex));
425cdf0e10cSrcweir                 break;
426cdf0e10cSrcweir             }
427cdf0e10cSrcweir             else
428cdf0e10cSrcweir             {
429cdf0e10cSrcweir                 // Add the part preceding the next %.
430cdf0e10cSrcweir                 sResult.append(sTemplate.copy(nIndex, nStartIndex-nIndex));
431cdf0e10cSrcweir 
432cdf0e10cSrcweir                 // Get the placeholder
433cdf0e10cSrcweir                 ++nIndex;
434cdf0e10cSrcweir                 ++nStartIndex;
435cdf0e10cSrcweir                 const sal_Int32 nEndIndex (sTemplate.indexOf('%', nStartIndex+1));
436cdf0e10cSrcweir                 const OUString sPlaceholder (sTemplate.copy(nStartIndex, nEndIndex-nStartIndex));
437cdf0e10cSrcweir                 nIndex = nEndIndex+1;
438cdf0e10cSrcweir 
439cdf0e10cSrcweir                 // Replace the placeholder with its current value.
440cdf0e10cSrcweir                 if (sPlaceholder == sCurrentSlideNumberPlaceholder)
441cdf0e10cSrcweir                     sResult.append(sCurrentSlideNumber);
442cdf0e10cSrcweir                 else if (sPlaceholder == sCurrentSlideNamePlaceholder)
443cdf0e10cSrcweir                     sResult.append(sCurrentSlideName);
444cdf0e10cSrcweir                 else if (sPlaceholder == sSlideCountPlaceholder)
445cdf0e10cSrcweir                     sResult.append(sSlideCount);
446cdf0e10cSrcweir             }
447cdf0e10cSrcweir         }
448cdf0e10cSrcweir 
449cdf0e10cSrcweir         (*iPane)->msTitle = sResult.makeStringAndClear();
450cdf0e10cSrcweir         if ((*iPane)->mxPane.is())
451cdf0e10cSrcweir             (*iPane)->mxPane->SetTitle((*iPane)->msTitle);
452cdf0e10cSrcweir     }
453cdf0e10cSrcweir }
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 
UpdateViews(void)458cdf0e10cSrcweir void PresenterController::UpdateViews (void)
459cdf0e10cSrcweir {
460cdf0e10cSrcweir     // Tell all views about the slides they should display.
461cdf0e10cSrcweir     PresenterPaneContainer::PaneList::const_iterator iPane;
462cdf0e10cSrcweir     for (iPane=mpPaneContainer->maPanes.begin(); iPane!=mpPaneContainer->maPanes.end(); ++iPane)
463cdf0e10cSrcweir     {
464cdf0e10cSrcweir         Reference<drawing::XDrawView> xDrawView ((*iPane)->mxView, UNO_QUERY);
465cdf0e10cSrcweir         if (xDrawView.is())
466cdf0e10cSrcweir             xDrawView->setCurrentPage(mxCurrentSlide);
467cdf0e10cSrcweir     }
468cdf0e10cSrcweir }
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 
473cdf0e10cSrcweir SharedBitmapDescriptor
GetViewBackground(const::rtl::OUString & rsViewURL) const474cdf0e10cSrcweir     PresenterController::GetViewBackground (const ::rtl::OUString& rsViewURL) const
475cdf0e10cSrcweir {
476cdf0e10cSrcweir     if (mpTheme.get() != NULL)
477cdf0e10cSrcweir     {
478cdf0e10cSrcweir         const OUString sStyleName (mpTheme->GetStyleName(rsViewURL));
479cdf0e10cSrcweir         return mpTheme->GetBitmap(sStyleName, A2S("Background"));
480cdf0e10cSrcweir     }
481cdf0e10cSrcweir     return SharedBitmapDescriptor();
482cdf0e10cSrcweir }
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 
487cdf0e10cSrcweir PresenterTheme::SharedFontDescriptor
GetViewFont(const::rtl::OUString & rsViewURL) const488cdf0e10cSrcweir     PresenterController::GetViewFont (const ::rtl::OUString& rsViewURL) const
489cdf0e10cSrcweir {
490cdf0e10cSrcweir     if (mpTheme.get() != NULL)
491cdf0e10cSrcweir     {
492cdf0e10cSrcweir         const OUString sStyleName (mpTheme->GetStyleName(rsViewURL));
493cdf0e10cSrcweir         return mpTheme->GetFont(sStyleName);
494cdf0e10cSrcweir     }
495cdf0e10cSrcweir     return PresenterTheme::SharedFontDescriptor();
496cdf0e10cSrcweir }
497cdf0e10cSrcweir 
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 
500cdf0e10cSrcweir 
GetTheme(void) const501cdf0e10cSrcweir ::boost::shared_ptr<PresenterTheme> PresenterController::GetTheme (void) const
502cdf0e10cSrcweir {
503cdf0e10cSrcweir     return mpTheme;
504cdf0e10cSrcweir }
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 
GetWindowManager(void) const509cdf0e10cSrcweir ::rtl::Reference<PresenterWindowManager> PresenterController::GetWindowManager (void) const
510cdf0e10cSrcweir {
511cdf0e10cSrcweir     return mpWindowManager;
512cdf0e10cSrcweir }
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 
517cdf0e10cSrcweir Reference<presentation::XSlideShowController>
GetSlideShowController(void) const518cdf0e10cSrcweir     PresenterController::GetSlideShowController(void) const
519cdf0e10cSrcweir {
520cdf0e10cSrcweir     return mxSlideShowController;
521cdf0e10cSrcweir }
522cdf0e10cSrcweir 
523cdf0e10cSrcweir 
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 
GetPaneContainer(void) const526cdf0e10cSrcweir rtl::Reference<PresenterPaneContainer> PresenterController::GetPaneContainer (void) const
527cdf0e10cSrcweir {
528cdf0e10cSrcweir     return mpPaneContainer;
529cdf0e10cSrcweir }
530cdf0e10cSrcweir 
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 
533cdf0e10cSrcweir 
GetPaneBorderPainter(void) const534cdf0e10cSrcweir ::rtl::Reference<PresenterPaneBorderPainter> PresenterController::GetPaneBorderPainter (void) const
535cdf0e10cSrcweir {
536cdf0e10cSrcweir     return mpPaneBorderPainter;
537cdf0e10cSrcweir }
538cdf0e10cSrcweir 
539cdf0e10cSrcweir 
540cdf0e10cSrcweir 
541cdf0e10cSrcweir 
GetAnimator(void) const542cdf0e10cSrcweir ::boost::shared_ptr<PresenterAnimator> PresenterController::GetAnimator (void) const
543cdf0e10cSrcweir {
544cdf0e10cSrcweir     return mpAnimator;
545cdf0e10cSrcweir }
546cdf0e10cSrcweir 
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 
549cdf0e10cSrcweir 
GetCanvasHelper(void) const550cdf0e10cSrcweir ::boost::shared_ptr<PresenterCanvasHelper> PresenterController::GetCanvasHelper (void) const
551cdf0e10cSrcweir {
552cdf0e10cSrcweir     return mpCanvasHelper;
553cdf0e10cSrcweir }
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 
GetPresenterHelper(void) const558cdf0e10cSrcweir Reference<drawing::XPresenterHelper> PresenterController::GetPresenterHelper (void) const
559cdf0e10cSrcweir {
560cdf0e10cSrcweir     return mxPresenterHelper;
561cdf0e10cSrcweir }
562cdf0e10cSrcweir 
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 
565cdf0e10cSrcweir 
GetPaintManager(void) const566cdf0e10cSrcweir ::boost::shared_ptr<PresenterPaintManager> PresenterController::GetPaintManager (void) const
567cdf0e10cSrcweir {
568cdf0e10cSrcweir     return mpPaintManager;
569cdf0e10cSrcweir }
570cdf0e10cSrcweir 
571cdf0e10cSrcweir 
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 
HideSlideSorter(void)574cdf0e10cSrcweir void PresenterController::HideSlideSorter (void)
575cdf0e10cSrcweir {
576cdf0e10cSrcweir     if (mpCurrentPaneAnimation.get() != NULL)
577cdf0e10cSrcweir     {
578cdf0e10cSrcweir         mpCurrentPaneAnimation->HidePane();
579cdf0e10cSrcweir         mpCurrentPaneAnimation.reset();
580cdf0e10cSrcweir     }
581cdf0e10cSrcweir }
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 
584cdf0e10cSrcweir 
585cdf0e10cSrcweir 
ShowView(const OUString & rsViewURL)586cdf0e10cSrcweir void PresenterController::ShowView (const OUString& rsViewURL)
587cdf0e10cSrcweir {
588cdf0e10cSrcweir     PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
589cdf0e10cSrcweir         mpPaneContainer->FindViewURL(rsViewURL));
590cdf0e10cSrcweir     if (pDescriptor.get() != NULL)
591cdf0e10cSrcweir     {
592cdf0e10cSrcweir         pDescriptor->mbIsActive = true;
593cdf0e10cSrcweir         mxConfigurationController->requestResourceActivation(
594cdf0e10cSrcweir             pDescriptor->mxPaneId,
595cdf0e10cSrcweir             ResourceActivationMode_ADD);
596cdf0e10cSrcweir         mxConfigurationController->requestResourceActivation(
597cdf0e10cSrcweir             ResourceId::createWithAnchor(
598cdf0e10cSrcweir                 mxComponentContext,
599cdf0e10cSrcweir                 rsViewURL,
600cdf0e10cSrcweir                 pDescriptor->mxPaneId),
601cdf0e10cSrcweir             ResourceActivationMode_REPLACE);
602cdf0e10cSrcweir     }
603cdf0e10cSrcweir }
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 
607cdf0e10cSrcweir 
HideView(const OUString & rsViewURL)608cdf0e10cSrcweir void PresenterController::HideView (const OUString& rsViewURL)
609cdf0e10cSrcweir {
610cdf0e10cSrcweir     PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
611cdf0e10cSrcweir         mpPaneContainer->FindViewURL(rsViewURL));
612cdf0e10cSrcweir     if (pDescriptor.get() != NULL)
613cdf0e10cSrcweir     {
614cdf0e10cSrcweir         mxConfigurationController->requestResourceDeactivation(
615cdf0e10cSrcweir             ResourceId::createWithAnchor(
616cdf0e10cSrcweir                 mxComponentContext,
617cdf0e10cSrcweir                 rsViewURL,
618cdf0e10cSrcweir                 pDescriptor->mxPaneId));
619cdf0e10cSrcweir     }
620cdf0e10cSrcweir }
621cdf0e10cSrcweir 
622cdf0e10cSrcweir 
623cdf0e10cSrcweir 
624cdf0e10cSrcweir 
IsViewVisible(const OUString & rsViewURL) const625cdf0e10cSrcweir bool PresenterController::IsViewVisible (const OUString& rsViewURL) const
626cdf0e10cSrcweir {
627cdf0e10cSrcweir    PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
628cdf0e10cSrcweir         mpPaneContainer->FindViewURL(rsViewURL));
629cdf0e10cSrcweir     if (pDescriptor.get() != NULL)
630cdf0e10cSrcweir     {
631cdf0e10cSrcweir         return mxConfigurationController->getResource(
632cdf0e10cSrcweir             ResourceId::createWithAnchor(
633cdf0e10cSrcweir                 mxComponentContext,
634cdf0e10cSrcweir                 rsViewURL,
635cdf0e10cSrcweir                 pDescriptor->mxPaneId)).is();
636cdf0e10cSrcweir     }
637cdf0e10cSrcweir     return false;
638cdf0e10cSrcweir }
639cdf0e10cSrcweir 
640cdf0e10cSrcweir 
641cdf0e10cSrcweir 
642cdf0e10cSrcweir 
DispatchUnoCommand(const OUString & rsCommand) const643cdf0e10cSrcweir void PresenterController::DispatchUnoCommand (const OUString& rsCommand) const
644cdf0e10cSrcweir {
645cdf0e10cSrcweir     if ( ! mxUrlTransformer.is())
646cdf0e10cSrcweir         return;
647cdf0e10cSrcweir 
648cdf0e10cSrcweir     util::URL aURL;
649cdf0e10cSrcweir     aURL.Complete = rsCommand;
650cdf0e10cSrcweir     mxUrlTransformer->parseStrict(aURL);
651cdf0e10cSrcweir 
652cdf0e10cSrcweir     Reference<frame::XDispatch> xDispatch (GetDispatch(aURL));
653cdf0e10cSrcweir     if ( ! xDispatch.is())
654cdf0e10cSrcweir         return;
655cdf0e10cSrcweir 
656cdf0e10cSrcweir     xDispatch->dispatch(aURL, Sequence<beans::PropertyValue>());
657cdf0e10cSrcweir }
658cdf0e10cSrcweir 
659cdf0e10cSrcweir 
660cdf0e10cSrcweir 
661cdf0e10cSrcweir 
GetDispatch(const util::URL & rURL) const662cdf0e10cSrcweir Reference<css::frame::XDispatch> PresenterController::GetDispatch (const util::URL& rURL) const
663cdf0e10cSrcweir {
664cdf0e10cSrcweir     if ( ! mxController.is())
665cdf0e10cSrcweir         return NULL;
666cdf0e10cSrcweir 
667cdf0e10cSrcweir     Reference<frame::XDispatchProvider> xDispatchProvider (mxController->getFrame(), UNO_QUERY);
668cdf0e10cSrcweir     if ( ! xDispatchProvider.is())
669cdf0e10cSrcweir         return NULL;
670cdf0e10cSrcweir 
671cdf0e10cSrcweir     return xDispatchProvider->queryDispatch(
672cdf0e10cSrcweir         rURL,
673cdf0e10cSrcweir         OUString(),
674cdf0e10cSrcweir         frame::FrameSearchFlag::SELF);
675cdf0e10cSrcweir }
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 
678cdf0e10cSrcweir 
679cdf0e10cSrcweir 
CreateURLFromString(const::rtl::OUString & rsURL) const680cdf0e10cSrcweir util::URL PresenterController::CreateURLFromString (const ::rtl::OUString& rsURL) const
681cdf0e10cSrcweir {
682cdf0e10cSrcweir     util::URL aURL;
683cdf0e10cSrcweir 
684cdf0e10cSrcweir     if (mxUrlTransformer.is())
685cdf0e10cSrcweir     {
686cdf0e10cSrcweir         aURL.Complete = rsURL;
687cdf0e10cSrcweir         mxUrlTransformer->parseStrict(aURL);
688cdf0e10cSrcweir     }
689cdf0e10cSrcweir 
690cdf0e10cSrcweir     return aURL;
691cdf0e10cSrcweir }
692cdf0e10cSrcweir 
693cdf0e10cSrcweir 
694cdf0e10cSrcweir 
695cdf0e10cSrcweir 
696cdf0e10cSrcweir Reference<drawing::framework::XConfigurationController>
GetConfigurationController(void) const697cdf0e10cSrcweir     PresenterController::GetConfigurationController (void) const
698cdf0e10cSrcweir {
699cdf0e10cSrcweir     return mxConfigurationController;
700cdf0e10cSrcweir }
701cdf0e10cSrcweir 
702cdf0e10cSrcweir 
703cdf0e10cSrcweir 
704cdf0e10cSrcweir 
GetCurrentSlide(void) const705cdf0e10cSrcweir Reference<drawing::XDrawPage> PresenterController::GetCurrentSlide (void) const
706cdf0e10cSrcweir {
707cdf0e10cSrcweir     return mxCurrentSlide;
708cdf0e10cSrcweir }
709cdf0e10cSrcweir 
710cdf0e10cSrcweir 
711cdf0e10cSrcweir 
712cdf0e10cSrcweir 
GetAccessible(void) const713cdf0e10cSrcweir ::rtl::Reference<PresenterAccessible> PresenterController::GetAccessible (void) const
714cdf0e10cSrcweir {
715cdf0e10cSrcweir     return mpAccessibleObject;
716cdf0e10cSrcweir }
717cdf0e10cSrcweir 
718cdf0e10cSrcweir 
719cdf0e10cSrcweir 
720cdf0e10cSrcweir 
SetAccessibilityActiveState(const bool bIsActive)721cdf0e10cSrcweir void PresenterController::SetAccessibilityActiveState (const bool bIsActive)
722cdf0e10cSrcweir {
723cdf0e10cSrcweir     if ( mbIsAccessibilityActive != bIsActive)
724cdf0e10cSrcweir     {
725cdf0e10cSrcweir         mbIsAccessibilityActive = bIsActive;
726cdf0e10cSrcweir         UpdatePaneTitles();
727cdf0e10cSrcweir     }
728cdf0e10cSrcweir }
729cdf0e10cSrcweir 
730cdf0e10cSrcweir 
731cdf0e10cSrcweir 
732cdf0e10cSrcweir 
IsAccessibilityActive(void) const733cdf0e10cSrcweir bool PresenterController::IsAccessibilityActive (void) const
734cdf0e10cSrcweir {
735cdf0e10cSrcweir     return mbIsAccessibilityActive;
736cdf0e10cSrcweir }
737cdf0e10cSrcweir 
738cdf0e10cSrcweir 
739cdf0e10cSrcweir 
740cdf0e10cSrcweir 
HandleMouseClick(const awt::MouseEvent & rEvent)741cdf0e10cSrcweir void PresenterController::HandleMouseClick (const awt::MouseEvent& rEvent)
742cdf0e10cSrcweir {
743cdf0e10cSrcweir     if (mxSlideShowController.is())
744cdf0e10cSrcweir     {
745cdf0e10cSrcweir         switch (rEvent.Buttons)
746cdf0e10cSrcweir         {
747cdf0e10cSrcweir             case awt::MouseButton::LEFT:
748cdf0e10cSrcweir                 if (rEvent.Modifiers == awt::KeyModifier::MOD2)
749cdf0e10cSrcweir                     mxSlideShowController->gotoNextSlide();
750cdf0e10cSrcweir                 else
751cdf0e10cSrcweir                     mxSlideShowController->gotoNextEffect();
752cdf0e10cSrcweir                 break;
753cdf0e10cSrcweir 
754cdf0e10cSrcweir             case awt::MouseButton::RIGHT:
755cdf0e10cSrcweir                 mxSlideShowController->gotoPreviousSlide();
756cdf0e10cSrcweir                 break;
757cdf0e10cSrcweir 
758cdf0e10cSrcweir             default:
759cdf0e10cSrcweir                 // Other or multiple buttons.
760cdf0e10cSrcweir                 break;
761cdf0e10cSrcweir         }
762cdf0e10cSrcweir     }
763cdf0e10cSrcweir }
764cdf0e10cSrcweir 
765cdf0e10cSrcweir 
766cdf0e10cSrcweir 
767cdf0e10cSrcweir 
RequestViews(const bool bIsSlideSorterActive,const bool bIsNotesViewActive,const bool bIsHelpViewActive)768cdf0e10cSrcweir void PresenterController::RequestViews (
769cdf0e10cSrcweir     const bool bIsSlideSorterActive,
770cdf0e10cSrcweir     const bool bIsNotesViewActive,
771cdf0e10cSrcweir     const bool bIsHelpViewActive)
772cdf0e10cSrcweir {
773cdf0e10cSrcweir     PresenterPaneContainer::PaneList::const_iterator iPane;
774cdf0e10cSrcweir     PresenterPaneContainer::PaneList::const_iterator iEnd (mpPaneContainer->maPanes.end());
775cdf0e10cSrcweir     for (iPane=mpPaneContainer->maPanes.begin(); iPane!=iEnd; ++iPane)
776cdf0e10cSrcweir     {
777cdf0e10cSrcweir         bool bActivate (true);
778cdf0e10cSrcweir         const OUString sViewURL ((*iPane)->msViewURL);
779cdf0e10cSrcweir         if (sViewURL == PresenterViewFactory::msNotesViewURL)
780cdf0e10cSrcweir         {
781cdf0e10cSrcweir             bActivate = bIsNotesViewActive && !bIsSlideSorterActive && !bIsHelpViewActive;
782cdf0e10cSrcweir         }
783cdf0e10cSrcweir         else if (sViewURL == PresenterViewFactory::msSlideSorterURL)
784cdf0e10cSrcweir         {
785cdf0e10cSrcweir             bActivate = bIsSlideSorterActive;
786cdf0e10cSrcweir         }
787cdf0e10cSrcweir         else if (sViewURL == PresenterViewFactory::msCurrentSlidePreviewViewURL
788cdf0e10cSrcweir             || sViewURL == PresenterViewFactory::msNextSlidePreviewViewURL)
789cdf0e10cSrcweir         {
790cdf0e10cSrcweir             bActivate = !bIsSlideSorterActive && ! bIsHelpViewActive;
791cdf0e10cSrcweir         }
792cdf0e10cSrcweir         else if (sViewURL == PresenterViewFactory::msToolBarViewURL)
793cdf0e10cSrcweir         {
794cdf0e10cSrcweir             bActivate = true;
795cdf0e10cSrcweir         }
796cdf0e10cSrcweir         else if (sViewURL == PresenterViewFactory::msHelpViewURL)
797cdf0e10cSrcweir         {
798cdf0e10cSrcweir             bActivate = bIsHelpViewActive;
799cdf0e10cSrcweir         }
800cdf0e10cSrcweir 
801cdf0e10cSrcweir         if (bActivate)
802cdf0e10cSrcweir             ShowView(sViewURL);
803cdf0e10cSrcweir         else
804cdf0e10cSrcweir             HideView(sViewURL);
805cdf0e10cSrcweir     }
806cdf0e10cSrcweir }
807cdf0e10cSrcweir 
808cdf0e10cSrcweir 
809cdf0e10cSrcweir 
810cdf0e10cSrcweir 
811cdf0e10cSrcweir //----- XConfigurationChangeListener ------------------------------------------
812cdf0e10cSrcweir 
notifyConfigurationChange(const ConfigurationChangeEvent & rEvent)813cdf0e10cSrcweir void SAL_CALL PresenterController::notifyConfigurationChange (
814cdf0e10cSrcweir     const ConfigurationChangeEvent& rEvent)
815cdf0e10cSrcweir     throw (RuntimeException)
816cdf0e10cSrcweir {
817cdf0e10cSrcweir     ThrowIfDisposed();
818cdf0e10cSrcweir 
819cdf0e10cSrcweir     sal_Int32 nType (0);
820cdf0e10cSrcweir     if ( ! (rEvent.UserData >>= nType))
821cdf0e10cSrcweir         return;
822cdf0e10cSrcweir 
823cdf0e10cSrcweir     switch (nType)
824cdf0e10cSrcweir     {
825cdf0e10cSrcweir         case ResourceActivationEventType:
826cdf0e10cSrcweir             if (rEvent.ResourceId->compareTo(mxMainPaneId) == 0)
827cdf0e10cSrcweir             {
828cdf0e10cSrcweir                 InitializeMainPane(Reference<XPane>(rEvent.ResourceObject,UNO_QUERY));
829cdf0e10cSrcweir             }
830cdf0e10cSrcweir             else if (rEvent.ResourceId->isBoundTo(mxMainPaneId,AnchorBindingMode_DIRECT))
831cdf0e10cSrcweir             {
832cdf0e10cSrcweir                 // A pane bound to the main pane has been created and is
833cdf0e10cSrcweir                 // stored in the pane container.
834cdf0e10cSrcweir                 Reference<XPane> xPane (rEvent.ResourceObject,UNO_QUERY);
835cdf0e10cSrcweir                 if (xPane.is())
836cdf0e10cSrcweir                 {
837cdf0e10cSrcweir                     PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
838cdf0e10cSrcweir                         mpPaneContainer->FindPaneId(xPane->getResourceId()));
839cdf0e10cSrcweir 
840cdf0e10cSrcweir                     // When there is a call out anchor location set then tell the
841cdf0e10cSrcweir                     // window about it.
842cdf0e10cSrcweir                     if (pDescriptor->mbHasCalloutAnchor)
843cdf0e10cSrcweir                         pDescriptor->mxPane->SetCalloutAnchor(
844cdf0e10cSrcweir                             pDescriptor->maCalloutAnchorLocation);
845cdf0e10cSrcweir                 }
846cdf0e10cSrcweir             }
847cdf0e10cSrcweir             else if (rEvent.ResourceId->isBoundTo(mxMainPaneId,AnchorBindingMode_INDIRECT))
848cdf0e10cSrcweir             {
849cdf0e10cSrcweir                 // A view bound to one of the panes has been created and is
850cdf0e10cSrcweir                 // stored in the pane container along with its pane.
851cdf0e10cSrcweir                 Reference<XView> xView (rEvent.ResourceObject,UNO_QUERY);
852cdf0e10cSrcweir                 if (xView.is())
853cdf0e10cSrcweir                 {
854cdf0e10cSrcweir                     SharedBitmapDescriptor pViewBackground(
855cdf0e10cSrcweir                         GetViewBackground(xView->getResourceId()->getResourceURL()));
856cdf0e10cSrcweir                     mpPaneContainer->StoreView(xView, pViewBackground);
857cdf0e10cSrcweir                     UpdateViews();
858cdf0e10cSrcweir                     mpWindowManager->NotifyViewCreation(xView);
859cdf0e10cSrcweir                 }
860cdf0e10cSrcweir             }
861cdf0e10cSrcweir             break;
862cdf0e10cSrcweir 
863cdf0e10cSrcweir         case ResourceDeactivationEventType:
864cdf0e10cSrcweir             if (rEvent.ResourceId->isBoundTo(mxMainPaneId,AnchorBindingMode_INDIRECT))
865cdf0e10cSrcweir             {
866cdf0e10cSrcweir                 // If this is a view then remove it from the pane container.
867cdf0e10cSrcweir                 Reference<XView> xView (rEvent.ResourceObject,UNO_QUERY);
868cdf0e10cSrcweir                 if (xView.is())
869cdf0e10cSrcweir                 {
870cdf0e10cSrcweir                     PresenterPaneContainer::SharedPaneDescriptor pDescriptor(
871cdf0e10cSrcweir                         mpPaneContainer->RemoveView(xView));
872cdf0e10cSrcweir 
873cdf0e10cSrcweir                     // A possibly opaque view has been removed.  Update()
874cdf0e10cSrcweir                     // updates the clip polygon.
875cdf0e10cSrcweir                     mpWindowManager->Update();
876cdf0e10cSrcweir                     // Request the repainting of the area previously
877cdf0e10cSrcweir                     // occupied by the view.
878cdf0e10cSrcweir                     if (pDescriptor.get() != NULL)
879cdf0e10cSrcweir                         GetPaintManager()->Invalidate(pDescriptor->mxBorderWindow);
880cdf0e10cSrcweir                 }
881cdf0e10cSrcweir             }
882cdf0e10cSrcweir             break;
883cdf0e10cSrcweir 
884cdf0e10cSrcweir         case ConfigurationUpdateEndEventType:
885cdf0e10cSrcweir             if (IsAccessibilityActive())
886cdf0e10cSrcweir             {
887cdf0e10cSrcweir                 mpAccessibleObject->UpdateAccessibilityHierarchy();
888cdf0e10cSrcweir                 UpdateCurrentSlide(0);
889cdf0e10cSrcweir             }
890cdf0e10cSrcweir             break;
891cdf0e10cSrcweir     }
892cdf0e10cSrcweir }
893cdf0e10cSrcweir 
894cdf0e10cSrcweir 
895cdf0e10cSrcweir 
896cdf0e10cSrcweir 
897cdf0e10cSrcweir //----- XEventListener --------------------------------------------------------
898cdf0e10cSrcweir 
disposing(const lang::EventObject & rEvent)899cdf0e10cSrcweir void SAL_CALL PresenterController::disposing (
900cdf0e10cSrcweir     const lang::EventObject& rEvent)
901cdf0e10cSrcweir     throw (RuntimeException)
902cdf0e10cSrcweir {
903cdf0e10cSrcweir     if (rEvent.Source == mxController)
904cdf0e10cSrcweir         mxController = NULL;
905cdf0e10cSrcweir     else if (rEvent.Source == mxConfigurationController)
906cdf0e10cSrcweir         mxConfigurationController = NULL;
907cdf0e10cSrcweir     else if (rEvent.Source == mxSlideShowController)
908cdf0e10cSrcweir         mxSlideShowController = NULL;
909cdf0e10cSrcweir     else if (rEvent.Source == mxMainWindow)
910cdf0e10cSrcweir         mxMainWindow = NULL;
911cdf0e10cSrcweir }
912cdf0e10cSrcweir 
913cdf0e10cSrcweir 
914cdf0e10cSrcweir 
915cdf0e10cSrcweir 
916cdf0e10cSrcweir //----- XFrameActionListener --------------------------------------------------
917cdf0e10cSrcweir 
frameAction(const frame::FrameActionEvent & rEvent)918cdf0e10cSrcweir void SAL_CALL PresenterController::frameAction (
919cdf0e10cSrcweir     const frame::FrameActionEvent& rEvent)
920cdf0e10cSrcweir     throw (RuntimeException)
921cdf0e10cSrcweir {
922cdf0e10cSrcweir     if (rEvent.Action == frame::FrameAction_FRAME_ACTIVATED)
923cdf0e10cSrcweir     {
924cdf0e10cSrcweir         if (mxSlideShowController.is())
925cdf0e10cSrcweir             mxSlideShowController->activate();
926cdf0e10cSrcweir     }
927cdf0e10cSrcweir }
928cdf0e10cSrcweir 
929cdf0e10cSrcweir 
930cdf0e10cSrcweir 
931cdf0e10cSrcweir 
932cdf0e10cSrcweir //----- XKeyListener ----------------------------------------------------------
933cdf0e10cSrcweir 
keyPressed(const awt::KeyEvent & rEvent)934cdf0e10cSrcweir void SAL_CALL PresenterController::keyPressed (const awt::KeyEvent& rEvent)
935cdf0e10cSrcweir     throw (RuntimeException)
936cdf0e10cSrcweir {
937cdf0e10cSrcweir     // Tell all views about the unhandled key event.
938cdf0e10cSrcweir     PresenterPaneContainer::PaneList::const_iterator iPane;
939cdf0e10cSrcweir     for (iPane=mpPaneContainer->maPanes.begin(); iPane!=mpPaneContainer->maPanes.end(); ++iPane)
940cdf0e10cSrcweir     {
941cdf0e10cSrcweir         if ( ! (*iPane)->mbIsActive)
942cdf0e10cSrcweir             continue;
943cdf0e10cSrcweir 
944cdf0e10cSrcweir         Reference<awt::XKeyListener> xKeyListener ((*iPane)->mxView, UNO_QUERY);
945cdf0e10cSrcweir         if (xKeyListener.is())
946cdf0e10cSrcweir             xKeyListener->keyPressed(rEvent);
947cdf0e10cSrcweir     }
948cdf0e10cSrcweir }
949cdf0e10cSrcweir 
950cdf0e10cSrcweir 
951cdf0e10cSrcweir 
952cdf0e10cSrcweir 
keyReleased(const awt::KeyEvent & rEvent)953cdf0e10cSrcweir void SAL_CALL PresenterController::keyReleased (const awt::KeyEvent& rEvent)
954cdf0e10cSrcweir     throw (RuntimeException)
955cdf0e10cSrcweir {
956cdf0e10cSrcweir     if (rEvent.Source != mxMainWindow)
957cdf0e10cSrcweir         return;
958cdf0e10cSrcweir 
959cdf0e10cSrcweir     switch (rEvent.KeyCode)
960cdf0e10cSrcweir     {
961cdf0e10cSrcweir         case awt::Key::ESCAPE:
962cdf0e10cSrcweir         case awt::Key::SUBTRACT:
963cdf0e10cSrcweir         {
964cdf0e10cSrcweir 			if( mxController.is() )
965cdf0e10cSrcweir 			{
966cdf0e10cSrcweir 				Reference< XPresentationSupplier > xPS( mxController->getModel(), UNO_QUERY );
967cdf0e10cSrcweir 				if( xPS.is() )
968cdf0e10cSrcweir 				{
969cdf0e10cSrcweir 					Reference< XPresentation > xP( xPS->getPresentation() );
970cdf0e10cSrcweir 					if( xP.is() )
971cdf0e10cSrcweir 						xP->end();
972cdf0e10cSrcweir 				}
973cdf0e10cSrcweir 			}
974cdf0e10cSrcweir         }
975cdf0e10cSrcweir         break;
976cdf0e10cSrcweir 
977cdf0e10cSrcweir         case awt::Key::PAGEDOWN:
978cdf0e10cSrcweir             if (mxSlideShowController.is())
979cdf0e10cSrcweir             {
980cdf0e10cSrcweir                 if (rEvent.Modifiers == awt::KeyModifier::MOD2)
981cdf0e10cSrcweir                     mxSlideShowController->gotoNextSlide();
982cdf0e10cSrcweir                 else
983cdf0e10cSrcweir                     mxSlideShowController->gotoNextEffect();
984cdf0e10cSrcweir             }
985cdf0e10cSrcweir             break;
986cdf0e10cSrcweir 
987cdf0e10cSrcweir         case awt::Key::RIGHT:
988cdf0e10cSrcweir         case awt::Key::SPACE:
989cdf0e10cSrcweir         case awt::Key::DOWN:
990cdf0e10cSrcweir         case awt::Key::N:
991cdf0e10cSrcweir             if (mxSlideShowController.is())
992cdf0e10cSrcweir             {
993cdf0e10cSrcweir                 mxSlideShowController->gotoNextEffect();
994cdf0e10cSrcweir             }
995cdf0e10cSrcweir             break;
996cdf0e10cSrcweir 
997cdf0e10cSrcweir         case awt::Key::LEFT:
998cdf0e10cSrcweir         case awt::Key::PAGEUP:
999cdf0e10cSrcweir             if (mxSlideShowController.is())
1000cdf0e10cSrcweir             {
1001cdf0e10cSrcweir                 if (rEvent.Modifiers == awt::KeyModifier::MOD2)
1002cdf0e10cSrcweir                     mxSlideShowController->gotoPreviousSlide();
1003cdf0e10cSrcweir                 else
1004cdf0e10cSrcweir                     mxSlideShowController->gotoPreviousEffect();
1005cdf0e10cSrcweir             }
1006cdf0e10cSrcweir             break;
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir         case awt::Key::UP:
1009cdf0e10cSrcweir         case awt::Key::P:
1010cdf0e10cSrcweir         case awt::Key::BACKSPACE:
1011cdf0e10cSrcweir             if (mxSlideShowController.is())
1012cdf0e10cSrcweir             {
1013cdf0e10cSrcweir                 mxSlideShowController->gotoPreviousEffect();
1014cdf0e10cSrcweir             }
1015cdf0e10cSrcweir             break;
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir         case awt::Key::HOME:
1018cdf0e10cSrcweir             if (mxSlideShowController.is())
1019cdf0e10cSrcweir             {
1020cdf0e10cSrcweir                 mxSlideShowController->gotoFirstSlide();
1021cdf0e10cSrcweir             }
1022cdf0e10cSrcweir             break;
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir         case awt::Key::END:
1025cdf0e10cSrcweir             if (mxSlideShowController.is())
1026cdf0e10cSrcweir             {
1027cdf0e10cSrcweir                 mxSlideShowController->gotoLastSlide();
1028cdf0e10cSrcweir             }
1029cdf0e10cSrcweir             break;
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir         case awt::Key::W:
1032cdf0e10cSrcweir         case awt::Key::COMMA:
1033cdf0e10cSrcweir             if (mxSlideShowController.is())
1034cdf0e10cSrcweir             {
1035cdf0e10cSrcweir                 if (mxSlideShowController->isPaused())
1036cdf0e10cSrcweir                     mxSlideShowController->resume();
1037cdf0e10cSrcweir                 else
1038cdf0e10cSrcweir                     mxSlideShowController->blankScreen(0x00ffffff);
1039cdf0e10cSrcweir             }
1040cdf0e10cSrcweir             break;
1041cdf0e10cSrcweir 
1042cdf0e10cSrcweir         case awt::Key::B:
1043cdf0e10cSrcweir         case awt::Key::POINT:
1044cdf0e10cSrcweir             if (mxSlideShowController.is())
1045cdf0e10cSrcweir             {
1046cdf0e10cSrcweir                 if (mxSlideShowController->isPaused())
1047cdf0e10cSrcweir                     mxSlideShowController->resume();
1048cdf0e10cSrcweir                 else
1049cdf0e10cSrcweir                     mxSlideShowController->blankScreen(0x00000000);
1050cdf0e10cSrcweir             }
1051cdf0e10cSrcweir             break;
1052cdf0e10cSrcweir 
1053cdf0e10cSrcweir         case awt::Key::NUM0:
1054cdf0e10cSrcweir         case awt::Key::NUM1:
1055cdf0e10cSrcweir         case awt::Key::NUM2:
1056cdf0e10cSrcweir         case awt::Key::NUM3:
1057cdf0e10cSrcweir         case awt::Key::NUM4:
1058cdf0e10cSrcweir         case awt::Key::NUM5:
1059cdf0e10cSrcweir         case awt::Key::NUM6:
1060cdf0e10cSrcweir         case awt::Key::NUM7:
1061cdf0e10cSrcweir         case awt::Key::NUM8:
1062cdf0e10cSrcweir         case awt::Key::NUM9:
1063cdf0e10cSrcweir             HandleNumericKeyPress(rEvent.KeyCode-awt::Key::NUM0, rEvent.Modifiers);
1064cdf0e10cSrcweir             break;
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir         case awt::Key::RETURN:
1067cdf0e10cSrcweir             if (mnPendingSlideNumber > 0)
1068cdf0e10cSrcweir             {
1069cdf0e10cSrcweir                 if (mxSlideShowController.is())
1070cdf0e10cSrcweir                     mxSlideShowController->gotoSlideIndex(mnPendingSlideNumber - 1);
1071cdf0e10cSrcweir                 mnPendingSlideNumber = -1;
1072cdf0e10cSrcweir             }
1073cdf0e10cSrcweir             else
1074cdf0e10cSrcweir             {
1075cdf0e10cSrcweir                 if (mxSlideShowController.is())
1076cdf0e10cSrcweir                     mxSlideShowController->gotoNextEffect();
1077cdf0e10cSrcweir             }
1078cdf0e10cSrcweir 
1079cdf0e10cSrcweir             break;
1080cdf0e10cSrcweir 
1081cdf0e10cSrcweir         case awt::Key::F1:
1082cdf0e10cSrcweir             // Toggle the help view.
1083cdf0e10cSrcweir             if (mpWindowManager.get() != NULL)
1084cdf0e10cSrcweir             {
1085cdf0e10cSrcweir                 if (mpWindowManager->GetViewMode() != PresenterWindowManager::VM_Help)
1086cdf0e10cSrcweir                     mpWindowManager->SetViewMode(PresenterWindowManager::VM_Help);
1087cdf0e10cSrcweir                 else
1088cdf0e10cSrcweir                     mpWindowManager->SetHelpViewState(false);
1089cdf0e10cSrcweir             }
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir             break;
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir         default:
1094cdf0e10cSrcweir             // Tell all views about the unhandled key event.
1095cdf0e10cSrcweir             PresenterPaneContainer::PaneList::const_iterator iPane;
1096cdf0e10cSrcweir             for (iPane=mpPaneContainer->maPanes.begin(); iPane!=mpPaneContainer->maPanes.end(); ++iPane)
1097cdf0e10cSrcweir             {
1098cdf0e10cSrcweir                 if ( ! (*iPane)->mbIsActive)
1099cdf0e10cSrcweir                     continue;
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir                 Reference<awt::XKeyListener> xKeyListener ((*iPane)->mxView, UNO_QUERY);
1102cdf0e10cSrcweir                 if (xKeyListener.is())
1103cdf0e10cSrcweir                     xKeyListener->keyReleased(rEvent);
1104cdf0e10cSrcweir             }
1105cdf0e10cSrcweir             break;
1106cdf0e10cSrcweir     }
1107cdf0e10cSrcweir }
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir 
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir 
HandleNumericKeyPress(const sal_Int32 nKey,const sal_Int32 nModifiers)1112cdf0e10cSrcweir void PresenterController::HandleNumericKeyPress (
1113cdf0e10cSrcweir     const sal_Int32 nKey,
1114cdf0e10cSrcweir     const sal_Int32 nModifiers)
1115cdf0e10cSrcweir {
1116cdf0e10cSrcweir     switch (nModifiers)
1117cdf0e10cSrcweir     {
1118cdf0e10cSrcweir         case 0:
1119cdf0e10cSrcweir             if (mnPendingSlideNumber == -1)
1120cdf0e10cSrcweir                 mnPendingSlideNumber = 0;
1121cdf0e10cSrcweir             UpdatePendingSlideNumber(mnPendingSlideNumber * 10 + nKey);
1122cdf0e10cSrcweir             break;
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir         case awt::KeyModifier::MOD1:
1125cdf0e10cSrcweir             // Ctrl-1, Ctrl-2, and Ctrl-3 are used to switch between views
1126cdf0e10cSrcweir             // (slide view, notes view, normal)
1127cdf0e10cSrcweir             mnPendingSlideNumber = -1;
1128cdf0e10cSrcweir             if (mpWindowManager.get() == NULL)
1129cdf0e10cSrcweir                 return;
1130cdf0e10cSrcweir             switch(nKey)
1131cdf0e10cSrcweir             {
1132cdf0e10cSrcweir                 case 1:
1133cdf0e10cSrcweir                     mpWindowManager->SetViewMode(PresenterWindowManager::VM_Standard);
1134cdf0e10cSrcweir                     break;
1135cdf0e10cSrcweir                 case 2:
1136cdf0e10cSrcweir                     mpWindowManager->SetViewMode(PresenterWindowManager::VM_Notes);
1137cdf0e10cSrcweir                     break;
1138cdf0e10cSrcweir                 case 3:
1139cdf0e10cSrcweir                     mpWindowManager->SetViewMode(PresenterWindowManager::VM_SlideOverview);
1140cdf0e10cSrcweir                     break;
1141cdf0e10cSrcweir                 default:
1142cdf0e10cSrcweir                     // Ignore unsupported key.
1143cdf0e10cSrcweir                     break;
1144cdf0e10cSrcweir             }
1145cdf0e10cSrcweir 
1146cdf0e10cSrcweir         default:
1147cdf0e10cSrcweir             // Ignore unsupported modifiers.
1148cdf0e10cSrcweir             break;
1149cdf0e10cSrcweir     }
1150cdf0e10cSrcweir }
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir 
1155cdf0e10cSrcweir //----- XFocusListener --------------------------------------------------------
1156cdf0e10cSrcweir 
focusGained(const css::awt::FocusEvent & rEvent)1157cdf0e10cSrcweir void SAL_CALL PresenterController::focusGained (const css::awt::FocusEvent& rEvent)
1158cdf0e10cSrcweir     throw (css::uno::RuntimeException)
1159cdf0e10cSrcweir {
1160cdf0e10cSrcweir     (void)rEvent;
1161cdf0e10cSrcweir }
1162cdf0e10cSrcweir 
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir 
focusLost(const css::awt::FocusEvent & rEvent)1166cdf0e10cSrcweir void SAL_CALL PresenterController::focusLost (const css::awt::FocusEvent& rEvent)
1167cdf0e10cSrcweir     throw (css::uno::RuntimeException)
1168cdf0e10cSrcweir {
1169cdf0e10cSrcweir     (void)rEvent;
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir 
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir 
1175cdf0e10cSrcweir //----- XMouseListener --------------------------------------------------------
1176cdf0e10cSrcweir 
mousePressed(const css::awt::MouseEvent & rEvent)1177cdf0e10cSrcweir void SAL_CALL PresenterController::mousePressed (const css::awt::MouseEvent& rEvent)
1178cdf0e10cSrcweir     throw (css::uno::RuntimeException)
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir     (void)rEvent;
1181cdf0e10cSrcweir     if (mxMainWindow.is())
1182cdf0e10cSrcweir         mxMainWindow->setFocus();
1183cdf0e10cSrcweir }
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir 
mouseReleased(const css::awt::MouseEvent & rEvent)1188cdf0e10cSrcweir void SAL_CALL PresenterController::mouseReleased (const css::awt::MouseEvent& rEvent)
1189cdf0e10cSrcweir     throw (css::uno::RuntimeException)
1190cdf0e10cSrcweir {
1191cdf0e10cSrcweir     (void)rEvent;
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir 
1196cdf0e10cSrcweir 
mouseEntered(const css::awt::MouseEvent & rEvent)1197cdf0e10cSrcweir void SAL_CALL PresenterController::mouseEntered (const css::awt::MouseEvent& rEvent)
1198cdf0e10cSrcweir     throw (css::uno::RuntimeException)
1199cdf0e10cSrcweir {
1200cdf0e10cSrcweir     (void)rEvent;
1201cdf0e10cSrcweir }
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir 
1205cdf0e10cSrcweir 
mouseExited(const css::awt::MouseEvent & rEvent)1206cdf0e10cSrcweir void SAL_CALL PresenterController::mouseExited (const css::awt::MouseEvent& rEvent)
1207cdf0e10cSrcweir     throw (css::uno::RuntimeException)
1208cdf0e10cSrcweir {
1209cdf0e10cSrcweir     (void)rEvent;
1210cdf0e10cSrcweir }
1211cdf0e10cSrcweir 
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir 
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir //----- XMouseMotionListener --------------------------------------------------
1216cdf0e10cSrcweir 
mouseMoved(const css::awt::MouseEvent & rEvent)1217cdf0e10cSrcweir void SAL_CALL PresenterController::mouseMoved (const css::awt::MouseEvent& rEvent)
1218cdf0e10cSrcweir     throw (css::uno::RuntimeException)
1219cdf0e10cSrcweir {
1220cdf0e10cSrcweir     (void)rEvent;
1221cdf0e10cSrcweir }
1222cdf0e10cSrcweir 
1223cdf0e10cSrcweir 
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir 
mouseDragged(const css::awt::MouseEvent & rEvent)1226cdf0e10cSrcweir void SAL_CALL PresenterController::mouseDragged (const css::awt::MouseEvent& rEvent)
1227cdf0e10cSrcweir     throw (css::uno::RuntimeException)
1228cdf0e10cSrcweir {
1229cdf0e10cSrcweir     (void)rEvent;
1230cdf0e10cSrcweir }
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir 
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir //-----------------------------------------------------------------------------
1236cdf0e10cSrcweir 
InitializeMainPane(const Reference<XPane> & rxPane)1237cdf0e10cSrcweir void PresenterController::InitializeMainPane (const Reference<XPane>& rxPane)
1238cdf0e10cSrcweir {
1239cdf0e10cSrcweir     if ( ! rxPane.is())
1240cdf0e10cSrcweir         return;
1241cdf0e10cSrcweir 
1242cdf0e10cSrcweir     mpAccessibleObject = new PresenterAccessible(
1243cdf0e10cSrcweir         mxComponentContext,
1244cdf0e10cSrcweir         this,
1245cdf0e10cSrcweir         rxPane);
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir     LoadTheme(rxPane);
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir     // Main pane has been created and is now observed by the window
1250cdf0e10cSrcweir     // manager.
1251cdf0e10cSrcweir     mpWindowManager->SetParentPane(rxPane);
1252cdf0e10cSrcweir     mpWindowManager->SetTheme(mpTheme);
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir     if (mpPaneBorderPainter.get() != NULL)
1255cdf0e10cSrcweir         mpPaneBorderPainter->SetTheme(mpTheme);
1256cdf0e10cSrcweir 
1257cdf0e10cSrcweir     // Add key listener
1258cdf0e10cSrcweir     mxMainWindow = rxPane->getWindow();
1259cdf0e10cSrcweir     if (mxMainWindow.is())
1260cdf0e10cSrcweir     {
1261cdf0e10cSrcweir         mxMainWindow->addKeyListener(this);
1262cdf0e10cSrcweir         mxMainWindow->addFocusListener(this);
1263cdf0e10cSrcweir         mxMainWindow->addMouseListener(this);
1264cdf0e10cSrcweir         mxMainWindow->addMouseMotionListener(this);
1265cdf0e10cSrcweir     }
1266cdf0e10cSrcweir     Reference<XPane2> xPane2 (rxPane, UNO_QUERY);
1267cdf0e10cSrcweir     if (xPane2.is())
1268cdf0e10cSrcweir         xPane2->setVisible(sal_True);
1269cdf0e10cSrcweir 
1270cdf0e10cSrcweir     mpPaintManager.reset(new PresenterPaintManager(mxMainWindow, mxPresenterHelper, mpPaneContainer));
1271cdf0e10cSrcweir 
1272cdf0e10cSrcweir     mxCanvas = Reference<rendering::XSpriteCanvas>(rxPane->getCanvas(), UNO_QUERY);
1273cdf0e10cSrcweir 
1274cdf0e10cSrcweir     if (mxSlideShowController.is())
1275cdf0e10cSrcweir         mxSlideShowController->activate();
1276cdf0e10cSrcweir 
1277cdf0e10cSrcweir     UpdateCurrentSlide(0);
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir 
1280cdf0e10cSrcweir 
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir 
LoadTheme(const Reference<XPane> & rxPane)1283cdf0e10cSrcweir void PresenterController::LoadTheme (const Reference<XPane>& rxPane)
1284cdf0e10cSrcweir {
1285cdf0e10cSrcweir     // Create (load) the current theme.
1286cdf0e10cSrcweir     if (rxPane.is())
1287cdf0e10cSrcweir         mpTheme.reset(new PresenterTheme(mxComponentContext, OUString(), rxPane->getCanvas()));
1288cdf0e10cSrcweir }
1289cdf0e10cSrcweir 
1290cdf0e10cSrcweir 
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir 
GetSlideAspectRatio(void) const1293cdf0e10cSrcweir double PresenterController::GetSlideAspectRatio (void) const
1294cdf0e10cSrcweir {
1295cdf0e10cSrcweir     double nSlideAspectRatio (28.0/21.0);
1296cdf0e10cSrcweir 
1297cdf0e10cSrcweir     try
1298cdf0e10cSrcweir     {
1299cdf0e10cSrcweir         if (mxController.is())
1300cdf0e10cSrcweir         {
1301cdf0e10cSrcweir             Reference<drawing::XDrawPagesSupplier> xSlideSupplier (
1302cdf0e10cSrcweir                 mxController->getModel(), UNO_QUERY_THROW);
1303cdf0e10cSrcweir             Reference<drawing::XDrawPages> xSlides (xSlideSupplier->getDrawPages());
1304cdf0e10cSrcweir             if (xSlides.is() && xSlides->getCount()>0)
1305cdf0e10cSrcweir             {
1306cdf0e10cSrcweir                 Reference<beans::XPropertySet> xProperties(xSlides->getByIndex(0),UNO_QUERY_THROW);
1307cdf0e10cSrcweir                 sal_Int32 nWidth (28000);
1308cdf0e10cSrcweir                 sal_Int32 nHeight (21000);
1309cdf0e10cSrcweir                 if ((xProperties->getPropertyValue(OUString::createFromAscii("Width")) >>= nWidth)
1310cdf0e10cSrcweir                     && (xProperties->getPropertyValue(OUString::createFromAscii("Height")) >>= nHeight)
1311cdf0e10cSrcweir                     && nHeight > 0)
1312cdf0e10cSrcweir                 {
1313cdf0e10cSrcweir                     nSlideAspectRatio = double(nWidth) / double(nHeight);
1314cdf0e10cSrcweir                 }
1315cdf0e10cSrcweir             }
1316cdf0e10cSrcweir         }
1317cdf0e10cSrcweir     }
1318cdf0e10cSrcweir     catch (RuntimeException&)
1319cdf0e10cSrcweir     {
1320cdf0e10cSrcweir         OSL_ASSERT(false);
1321cdf0e10cSrcweir     }
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir     return nSlideAspectRatio;
1324cdf0e10cSrcweir }
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir 
UpdatePendingSlideNumber(const sal_Int32 nPendingSlideNumber)1329cdf0e10cSrcweir void PresenterController::UpdatePendingSlideNumber (const sal_Int32 nPendingSlideNumber)
1330cdf0e10cSrcweir {
1331cdf0e10cSrcweir     mnPendingSlideNumber = nPendingSlideNumber;
1332cdf0e10cSrcweir 
1333cdf0e10cSrcweir     if (mpTheme.get() == NULL)
1334cdf0e10cSrcweir         return;
1335cdf0e10cSrcweir 
1336cdf0e10cSrcweir     if ( ! mxMainWindow.is())
1337cdf0e10cSrcweir         return;
1338cdf0e10cSrcweir 
1339cdf0e10cSrcweir     PresenterTheme::SharedFontDescriptor pFont (
1340cdf0e10cSrcweir         mpTheme->GetFont(A2S("PendingSlideNumberFont")));
1341cdf0e10cSrcweir     if (pFont.get() == NULL)
1342cdf0e10cSrcweir         return;
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir     pFont->PrepareFont(Reference<rendering::XCanvas>(mxCanvas, UNO_QUERY));
1345cdf0e10cSrcweir     if ( ! pFont->mxFont.is())
1346cdf0e10cSrcweir         return;
1347cdf0e10cSrcweir 
1348cdf0e10cSrcweir     const OUString sText (OUString::valueOf(mnPendingSlideNumber));
1349cdf0e10cSrcweir     rendering::StringContext aContext (sText, 0, sText.getLength());
1350cdf0e10cSrcweir     Reference<rendering::XTextLayout> xLayout (
1351cdf0e10cSrcweir         pFont->mxFont->createTextLayout(
1352cdf0e10cSrcweir             aContext,
1353cdf0e10cSrcweir             rendering::TextDirection::WEAK_LEFT_TO_RIGHT,
1354cdf0e10cSrcweir             0));
1355cdf0e10cSrcweir }
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir 
1358cdf0e10cSrcweir 
1359cdf0e10cSrcweir 
ThrowIfDisposed(void) const1360cdf0e10cSrcweir void PresenterController::ThrowIfDisposed (void) const
1361cdf0e10cSrcweir     throw (::com::sun::star::lang::DisposedException)
1362cdf0e10cSrcweir {
1363cdf0e10cSrcweir 	if (rBHelper.bDisposed || rBHelper.bInDispose)
1364cdf0e10cSrcweir 	{
1365cdf0e10cSrcweir         throw lang::DisposedException (
1366cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM(
1367cdf0e10cSrcweir                 "PresenterController object has already been disposed")),
1368cdf0e10cSrcweir             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
1369cdf0e10cSrcweir     }
1370cdf0e10cSrcweir }
1371cdf0e10cSrcweir 
1372cdf0e10cSrcweir 
1373cdf0e10cSrcweir } } // end of namespace ::sdext::presenter
1374cdf0e10cSrcweir 
1375