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 "PresenterNotesView.hxx"
28cdf0e10cSrcweir #include "PresenterButton.hxx"
29cdf0e10cSrcweir #include "PresenterCanvasHelper.hxx"
30cdf0e10cSrcweir #include "PresenterGeometryHelper.hxx"
31cdf0e10cSrcweir #include "PresenterPaintManager.hxx"
32cdf0e10cSrcweir #include "PresenterScrollBar.hxx"
33cdf0e10cSrcweir #include "PresenterTextView.hxx"
34cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleTextType.hpp>
35cdf0e10cSrcweir #include <com/sun/star/awt/Key.hpp>
36cdf0e10cSrcweir #include <com/sun/star/awt/KeyModifier.hpp>
37cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
38cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
39cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp>
40cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
41cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XPane.hpp>
42cdf0e10cSrcweir #include <com/sun/star/lang/XServiceName.hpp>
43cdf0e10cSrcweir #include <com/sun/star/presentation/XPresentationPage.hpp>
44cdf0e10cSrcweir #include <com/sun/star/rendering/CompositeOperation.hpp>
45cdf0e10cSrcweir #include <com/sun/star/rendering/XSpriteCanvas.hpp>
46cdf0e10cSrcweir #include <com/sun/star/text/XTextRange.hpp>
47cdf0e10cSrcweir #include <com/sun/star/util/XChangesBatch.hpp>
48cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
49cdf0e10cSrcweir #include <boost/bind.hpp>
50cdf0e10cSrcweir #include <set>
51cdf0e10cSrcweir
52cdf0e10cSrcweir using namespace ::com::sun::star;
53cdf0e10cSrcweir using namespace ::com::sun::star::uno;
54cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
55cdf0e10cSrcweir using ::rtl::OUString;
56cdf0e10cSrcweir
57cdf0e10cSrcweir #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
58cdf0e10cSrcweir
59cdf0e10cSrcweir static const sal_Int32 gnSpaceBelowSeparator (10);
60cdf0e10cSrcweir static const sal_Int32 gnSpaceAboveSeparator (10);
61cdf0e10cSrcweir static const sal_Int32 gnPartHeight (128);
62cdf0e10cSrcweir /** Maximal size of memory used for bitmaps which show the notes text.
63cdf0e10cSrcweir */
64cdf0e10cSrcweir static const sal_Int32 gnMaximalCacheSize (8*1024*1024);
65cdf0e10cSrcweir static const double gnLineScrollFactor (1.2);
66cdf0e10cSrcweir
67cdf0e10cSrcweir namespace sdext { namespace presenter {
68cdf0e10cSrcweir
69cdf0e10cSrcweir //===== PresenterNotesView ====================================================
70cdf0e10cSrcweir
PresenterNotesView(const Reference<XComponentContext> & rxComponentContext,const Reference<XResourceId> & rxViewId,const Reference<frame::XController> & rxController,const::rtl::Reference<PresenterController> & rpPresenterController)71cdf0e10cSrcweir PresenterNotesView::PresenterNotesView (
72cdf0e10cSrcweir const Reference<XComponentContext>& rxComponentContext,
73cdf0e10cSrcweir const Reference<XResourceId>& rxViewId,
74cdf0e10cSrcweir const Reference<frame::XController>& rxController,
75cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController)
76cdf0e10cSrcweir : PresenterNotesViewInterfaceBase(m_aMutex),
77cdf0e10cSrcweir mxViewId(rxViewId),
78cdf0e10cSrcweir mpPresenterController(rpPresenterController),
79cdf0e10cSrcweir mxCanvas(),
80cdf0e10cSrcweir mxCurrentNotesPage(),
81cdf0e10cSrcweir mpScrollBar(),
82cdf0e10cSrcweir mxToolBarWindow(),
83cdf0e10cSrcweir mxToolBarCanvas(),
84cdf0e10cSrcweir mpToolBar(),
85cdf0e10cSrcweir mpCloseButton(),
86cdf0e10cSrcweir maSeparatorColor(0xffffff),
87cdf0e10cSrcweir mnSeparatorYLocation(0),
88cdf0e10cSrcweir maTextBoundingBox(),
89cdf0e10cSrcweir mpBackground(),
90cdf0e10cSrcweir mnTop(0),
91cdf0e10cSrcweir mpFont(),
92cdf0e10cSrcweir mpTextView()
93cdf0e10cSrcweir {
94cdf0e10cSrcweir try
95cdf0e10cSrcweir {
96cdf0e10cSrcweir Reference<XControllerManager> xCM (rxController, UNO_QUERY_THROW);
97cdf0e10cSrcweir Reference<XConfigurationController> xCC (xCM->getConfigurationController(), UNO_QUERY_THROW);
98cdf0e10cSrcweir Reference<XPane> xPane (xCC->getResource(rxViewId->getAnchor()), UNO_QUERY_THROW);
99cdf0e10cSrcweir
100cdf0e10cSrcweir mxParentWindow = xPane->getWindow();
101cdf0e10cSrcweir mxCanvas = xPane->getCanvas();
102cdf0e10cSrcweir mpTextView.reset(new PresenterTextView(
103cdf0e10cSrcweir rxComponentContext,
104cdf0e10cSrcweir mxCanvas,
105cdf0e10cSrcweir mpPresenterController->GetPaintManager()->GetInvalidator(mxParentWindow)));
106cdf0e10cSrcweir
107cdf0e10cSrcweir const OUString sResourceURL (mxViewId->getResourceURL());
108cdf0e10cSrcweir mpFont.reset(new PresenterTheme::FontDescriptor(
109cdf0e10cSrcweir rpPresenterController->GetViewFont(sResourceURL)));
110cdf0e10cSrcweir maSeparatorColor = mpFont->mnColor;
111cdf0e10cSrcweir mpTextView->SetFont(mpFont);
112cdf0e10cSrcweir
113cdf0e10cSrcweir CreateToolBar(rxComponentContext, rpPresenterController);
114cdf0e10cSrcweir
115cdf0e10cSrcweir mpCloseButton = PresenterButton::Create(
116cdf0e10cSrcweir rxComponentContext,
117cdf0e10cSrcweir mpPresenterController,
118cdf0e10cSrcweir mpPresenterController->GetTheme(),
119cdf0e10cSrcweir mxParentWindow,
120cdf0e10cSrcweir mxCanvas,
121cdf0e10cSrcweir A2S("NotesViewCloser"));
122cdf0e10cSrcweir
123cdf0e10cSrcweir if (mxParentWindow.is())
124cdf0e10cSrcweir {
125cdf0e10cSrcweir mxParentWindow->addWindowListener(this);
126cdf0e10cSrcweir mxParentWindow->addPaintListener(this);
127cdf0e10cSrcweir mxParentWindow->addKeyListener(this);
128cdf0e10cSrcweir mxParentWindow->setVisible(sal_True);
129cdf0e10cSrcweir }
130cdf0e10cSrcweir
131cdf0e10cSrcweir mpScrollBar = new PresenterVerticalScrollBar(
132cdf0e10cSrcweir rxComponentContext,
133cdf0e10cSrcweir mxParentWindow,
134cdf0e10cSrcweir mpPresenterController->GetPaintManager(),
135cdf0e10cSrcweir ::boost::bind(&PresenterNotesView::SetTop, this, _1));
136cdf0e10cSrcweir mpScrollBar->SetBackground(
137cdf0e10cSrcweir mpPresenterController->GetViewBackground(mxViewId->getResourceURL()));
138cdf0e10cSrcweir
139cdf0e10cSrcweir mpScrollBar->SetCanvas(mxCanvas);
140cdf0e10cSrcweir
141cdf0e10cSrcweir Layout();
142cdf0e10cSrcweir }
143cdf0e10cSrcweir catch (RuntimeException&)
144cdf0e10cSrcweir {
145cdf0e10cSrcweir PresenterNotesView::disposing();
146cdf0e10cSrcweir throw;
147cdf0e10cSrcweir }
148cdf0e10cSrcweir }
149cdf0e10cSrcweir
150cdf0e10cSrcweir
151cdf0e10cSrcweir
152cdf0e10cSrcweir
~PresenterNotesView(void)153cdf0e10cSrcweir PresenterNotesView::~PresenterNotesView (void)
154cdf0e10cSrcweir {
155cdf0e10cSrcweir }
156cdf0e10cSrcweir
157cdf0e10cSrcweir
158cdf0e10cSrcweir
159cdf0e10cSrcweir
disposing(void)160cdf0e10cSrcweir void SAL_CALL PresenterNotesView::disposing (void)
161cdf0e10cSrcweir {
162cdf0e10cSrcweir if (mxParentWindow.is())
163cdf0e10cSrcweir {
164cdf0e10cSrcweir mxParentWindow->removeWindowListener(this);
165cdf0e10cSrcweir mxParentWindow->removePaintListener(this);
166cdf0e10cSrcweir mxParentWindow->removeKeyListener(this);
167cdf0e10cSrcweir mxParentWindow = NULL;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir // Dispose tool bar.
171cdf0e10cSrcweir {
172cdf0e10cSrcweir Reference<XComponent> xComponent (static_cast<XWeak*>(mpToolBar.get()), UNO_QUERY);
173cdf0e10cSrcweir mpToolBar = NULL;
174cdf0e10cSrcweir if (xComponent.is())
175cdf0e10cSrcweir xComponent->dispose();
176cdf0e10cSrcweir }
177cdf0e10cSrcweir {
178cdf0e10cSrcweir Reference<XComponent> xComponent (mxToolBarCanvas, UNO_QUERY);
179cdf0e10cSrcweir mxToolBarCanvas = NULL;
180cdf0e10cSrcweir if (xComponent.is())
181cdf0e10cSrcweir xComponent->dispose();
182cdf0e10cSrcweir }
183cdf0e10cSrcweir {
184cdf0e10cSrcweir Reference<XComponent> xComponent (mxToolBarWindow, UNO_QUERY);
185cdf0e10cSrcweir mxToolBarWindow = NULL;
186cdf0e10cSrcweir if (xComponent.is())
187cdf0e10cSrcweir xComponent->dispose();
188cdf0e10cSrcweir }
189cdf0e10cSrcweir
190cdf0e10cSrcweir // Dispose close button
191cdf0e10cSrcweir {
192cdf0e10cSrcweir Reference<XComponent> xComponent (static_cast<XWeak*>(mpCloseButton.get()), UNO_QUERY);
193cdf0e10cSrcweir mpCloseButton = NULL;
194cdf0e10cSrcweir if (xComponent.is())
195cdf0e10cSrcweir xComponent->dispose();
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
198cdf0e10cSrcweir // Create the tool bar.
199cdf0e10cSrcweir
200cdf0e10cSrcweir mpScrollBar = NULL;
201cdf0e10cSrcweir
202cdf0e10cSrcweir mxViewId = NULL;
203cdf0e10cSrcweir }
204cdf0e10cSrcweir
205cdf0e10cSrcweir
206cdf0e10cSrcweir
207cdf0e10cSrcweir
CreateToolBar(const css::uno::Reference<css::uno::XComponentContext> & rxContext,const::rtl::Reference<PresenterController> & rpPresenterController)208cdf0e10cSrcweir void PresenterNotesView::CreateToolBar (
209cdf0e10cSrcweir const css::uno::Reference<css::uno::XComponentContext>& rxContext,
210cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController)
211cdf0e10cSrcweir {
212cdf0e10cSrcweir if (rpPresenterController.get() == NULL)
213cdf0e10cSrcweir return;
214cdf0e10cSrcweir
215cdf0e10cSrcweir Reference<drawing::XPresenterHelper> xPresenterHelper (
216cdf0e10cSrcweir rpPresenterController->GetPresenterHelper());
217cdf0e10cSrcweir if ( ! xPresenterHelper.is())
218cdf0e10cSrcweir return;
219cdf0e10cSrcweir
220cdf0e10cSrcweir // Create a new window as container of the tool bar.
221cdf0e10cSrcweir mxToolBarWindow = xPresenterHelper->createWindow(
222cdf0e10cSrcweir mxParentWindow,
223cdf0e10cSrcweir sal_False,
224cdf0e10cSrcweir sal_True,
225cdf0e10cSrcweir sal_False,
226cdf0e10cSrcweir sal_False);
227cdf0e10cSrcweir mxToolBarCanvas = xPresenterHelper->createSharedCanvas (
228cdf0e10cSrcweir Reference<rendering::XSpriteCanvas>(mxCanvas, UNO_QUERY),
229cdf0e10cSrcweir mxParentWindow,
230cdf0e10cSrcweir mxCanvas,
231cdf0e10cSrcweir mxParentWindow,
232cdf0e10cSrcweir mxToolBarWindow);
233cdf0e10cSrcweir
234cdf0e10cSrcweir // Create the tool bar.
235cdf0e10cSrcweir mpToolBar = new PresenterToolBar(
236cdf0e10cSrcweir rxContext,
237cdf0e10cSrcweir mxToolBarWindow,
238cdf0e10cSrcweir mxToolBarCanvas,
239cdf0e10cSrcweir rpPresenterController,
240cdf0e10cSrcweir PresenterToolBar::Left);
241cdf0e10cSrcweir mpToolBar->Initialize(
242cdf0e10cSrcweir A2S("PresenterScreenSettings/ToolBars/NotesToolBar"));
243cdf0e10cSrcweir }
244cdf0e10cSrcweir
245cdf0e10cSrcweir
246cdf0e10cSrcweir
247cdf0e10cSrcweir
SetSlide(const Reference<drawing::XDrawPage> & rxNotesPage)248cdf0e10cSrcweir void PresenterNotesView::SetSlide (const Reference<drawing::XDrawPage>& rxNotesPage)
249cdf0e10cSrcweir {
250cdf0e10cSrcweir static const ::rtl::OUString sNotesShapeName (
251cdf0e10cSrcweir A2S("com.sun.star.presentation.NotesShape"));
252cdf0e10cSrcweir static const ::rtl::OUString sTextShapeName (
253cdf0e10cSrcweir A2S("com.sun.star.drawing.TextShape"));
254cdf0e10cSrcweir
255cdf0e10cSrcweir Reference<container::XIndexAccess> xIndexAccess (rxNotesPage, UNO_QUERY);
256cdf0e10cSrcweir if (xIndexAccess.is())
257cdf0e10cSrcweir {
258cdf0e10cSrcweir ::rtl::OUString sText;
259cdf0e10cSrcweir
260cdf0e10cSrcweir // Iterate over all shapes and find the one that holds the text.
261cdf0e10cSrcweir sal_Int32 nCount (xIndexAccess->getCount());
262cdf0e10cSrcweir for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
263cdf0e10cSrcweir {
264cdf0e10cSrcweir
265cdf0e10cSrcweir Reference<lang::XServiceName> xServiceName (
266cdf0e10cSrcweir xIndexAccess->getByIndex(nIndex), UNO_QUERY);
267cdf0e10cSrcweir if (xServiceName.is()
268cdf0e10cSrcweir && xServiceName->getServiceName().equals(sNotesShapeName))
269cdf0e10cSrcweir {
270cdf0e10cSrcweir Reference<text::XTextRange> xText (xServiceName, UNO_QUERY);
271cdf0e10cSrcweir if (xText.is())
272cdf0e10cSrcweir {
273cdf0e10cSrcweir sText += xText->getString();
274cdf0e10cSrcweir }
275cdf0e10cSrcweir }
276cdf0e10cSrcweir else
277cdf0e10cSrcweir {
278cdf0e10cSrcweir Reference<drawing::XShapeDescriptor> xShapeDescriptor (
279cdf0e10cSrcweir xIndexAccess->getByIndex(nIndex), UNO_QUERY);
280cdf0e10cSrcweir if (xShapeDescriptor.is())
281cdf0e10cSrcweir {
282cdf0e10cSrcweir ::rtl::OUString sType (xShapeDescriptor->getShapeType());
283cdf0e10cSrcweir if (sType.equals(sNotesShapeName) || sType.equals(sTextShapeName))
284cdf0e10cSrcweir {
285cdf0e10cSrcweir Reference<text::XTextRange> xText (
286cdf0e10cSrcweir xIndexAccess->getByIndex(nIndex), UNO_QUERY);
287cdf0e10cSrcweir if (xText.is())
288cdf0e10cSrcweir {
289cdf0e10cSrcweir sText += xText->getString();
290cdf0e10cSrcweir mpTextView->SetText(Reference<text::XText>(xText, UNO_QUERY));
291cdf0e10cSrcweir }
292cdf0e10cSrcweir }
293cdf0e10cSrcweir }
294cdf0e10cSrcweir }
295cdf0e10cSrcweir }
296cdf0e10cSrcweir
297cdf0e10cSrcweir Layout();
298cdf0e10cSrcweir
299cdf0e10cSrcweir if (mpScrollBar.get() != NULL)
300cdf0e10cSrcweir {
301cdf0e10cSrcweir mpScrollBar->SetThumbPosition(0, false);
302cdf0e10cSrcweir UpdateScrollBar();
303cdf0e10cSrcweir }
304cdf0e10cSrcweir
305cdf0e10cSrcweir Invalidate();
306cdf0e10cSrcweir }
307cdf0e10cSrcweir }
308cdf0e10cSrcweir
309cdf0e10cSrcweir
310cdf0e10cSrcweir
311cdf0e10cSrcweir
312cdf0e10cSrcweir //----- lang::XEventListener -------------------------------------------------
313cdf0e10cSrcweir
disposing(const lang::EventObject & rEventObject)314cdf0e10cSrcweir void SAL_CALL PresenterNotesView::disposing (const lang::EventObject& rEventObject)
315cdf0e10cSrcweir throw (RuntimeException)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir if (rEventObject.Source == mxParentWindow)
318cdf0e10cSrcweir mxParentWindow = NULL;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir
321cdf0e10cSrcweir
322cdf0e10cSrcweir
323cdf0e10cSrcweir
324cdf0e10cSrcweir //----- XWindowListener -------------------------------------------------------
325cdf0e10cSrcweir
windowResized(const awt::WindowEvent & rEvent)326cdf0e10cSrcweir void SAL_CALL PresenterNotesView::windowResized (const awt::WindowEvent& rEvent)
327cdf0e10cSrcweir throw (RuntimeException)
328cdf0e10cSrcweir {
329cdf0e10cSrcweir (void)rEvent;
330cdf0e10cSrcweir Layout();
331cdf0e10cSrcweir }
332cdf0e10cSrcweir
333cdf0e10cSrcweir
334cdf0e10cSrcweir
335cdf0e10cSrcweir
windowMoved(const awt::WindowEvent & rEvent)336cdf0e10cSrcweir void SAL_CALL PresenterNotesView::windowMoved (const awt::WindowEvent& rEvent)
337cdf0e10cSrcweir throw (RuntimeException)
338cdf0e10cSrcweir {
339cdf0e10cSrcweir (void)rEvent;
340cdf0e10cSrcweir }
341cdf0e10cSrcweir
342cdf0e10cSrcweir
343cdf0e10cSrcweir
344cdf0e10cSrcweir
windowShown(const lang::EventObject & rEvent)345cdf0e10cSrcweir void SAL_CALL PresenterNotesView::windowShown (const lang::EventObject& rEvent)
346cdf0e10cSrcweir throw (RuntimeException)
347cdf0e10cSrcweir {
348cdf0e10cSrcweir (void)rEvent;
349cdf0e10cSrcweir }
350cdf0e10cSrcweir
351cdf0e10cSrcweir
352cdf0e10cSrcweir
353cdf0e10cSrcweir
windowHidden(const lang::EventObject & rEvent)354cdf0e10cSrcweir void SAL_CALL PresenterNotesView::windowHidden (const lang::EventObject& rEvent)
355cdf0e10cSrcweir throw (RuntimeException)
356cdf0e10cSrcweir {
357cdf0e10cSrcweir (void)rEvent;
358cdf0e10cSrcweir }
359cdf0e10cSrcweir
360cdf0e10cSrcweir
361cdf0e10cSrcweir
362cdf0e10cSrcweir
363cdf0e10cSrcweir //----- XPaintListener --------------------------------------------------------
364cdf0e10cSrcweir
windowPaint(const awt::PaintEvent & rEvent)365cdf0e10cSrcweir void SAL_CALL PresenterNotesView::windowPaint (const awt::PaintEvent& rEvent)
366cdf0e10cSrcweir throw (RuntimeException)
367cdf0e10cSrcweir {
368cdf0e10cSrcweir ThrowIfDisposed();
369cdf0e10cSrcweir
370cdf0e10cSrcweir if ( ! mbIsPresenterViewActive)
371cdf0e10cSrcweir return;
372cdf0e10cSrcweir
373cdf0e10cSrcweir ::osl::MutexGuard aSolarGuard (::osl::Mutex::getGlobalMutex());
374cdf0e10cSrcweir Paint(rEvent.UpdateRect);
375cdf0e10cSrcweir }
376cdf0e10cSrcweir
377cdf0e10cSrcweir
378cdf0e10cSrcweir
379cdf0e10cSrcweir
380cdf0e10cSrcweir //----- XResourceId -----------------------------------------------------------
381cdf0e10cSrcweir
getResourceId(void)382cdf0e10cSrcweir Reference<XResourceId> SAL_CALL PresenterNotesView::getResourceId (void)
383cdf0e10cSrcweir throw (RuntimeException)
384cdf0e10cSrcweir {
385cdf0e10cSrcweir return mxViewId;
386cdf0e10cSrcweir }
387cdf0e10cSrcweir
388cdf0e10cSrcweir
389cdf0e10cSrcweir
390cdf0e10cSrcweir
isAnchorOnly(void)391cdf0e10cSrcweir sal_Bool SAL_CALL PresenterNotesView::isAnchorOnly (void)
392cdf0e10cSrcweir throw (RuntimeException)
393cdf0e10cSrcweir {
394cdf0e10cSrcweir return false;
395cdf0e10cSrcweir }
396cdf0e10cSrcweir
397cdf0e10cSrcweir
398cdf0e10cSrcweir
399cdf0e10cSrcweir
400cdf0e10cSrcweir //----- XDrawView -------------------------------------------------------------
401cdf0e10cSrcweir
setCurrentPage(const Reference<drawing::XDrawPage> & rxSlide)402cdf0e10cSrcweir void SAL_CALL PresenterNotesView::setCurrentPage (const Reference<drawing::XDrawPage>& rxSlide)
403cdf0e10cSrcweir throw (RuntimeException)
404cdf0e10cSrcweir {
405cdf0e10cSrcweir // Get the associated notes page.
406cdf0e10cSrcweir mxCurrentNotesPage = NULL;
407cdf0e10cSrcweir try
408cdf0e10cSrcweir {
409cdf0e10cSrcweir Reference<presentation::XPresentationPage> xPresentationPage(rxSlide, UNO_QUERY);
410cdf0e10cSrcweir if (xPresentationPage.is())
411cdf0e10cSrcweir mxCurrentNotesPage = xPresentationPage->getNotesPage();
412cdf0e10cSrcweir }
413cdf0e10cSrcweir catch (RuntimeException&)
414cdf0e10cSrcweir {
415cdf0e10cSrcweir }
416cdf0e10cSrcweir
417cdf0e10cSrcweir SetSlide(mxCurrentNotesPage);
418cdf0e10cSrcweir }
419cdf0e10cSrcweir
420cdf0e10cSrcweir
421cdf0e10cSrcweir
422cdf0e10cSrcweir
getCurrentPage(void)423cdf0e10cSrcweir Reference<drawing::XDrawPage> SAL_CALL PresenterNotesView::getCurrentPage (void)
424cdf0e10cSrcweir throw (RuntimeException)
425cdf0e10cSrcweir {
426cdf0e10cSrcweir return NULL;
427cdf0e10cSrcweir }
428cdf0e10cSrcweir
429cdf0e10cSrcweir
430cdf0e10cSrcweir
431cdf0e10cSrcweir
432cdf0e10cSrcweir //----- XKeyListener ----------------------------------------------------------
433cdf0e10cSrcweir
keyPressed(const awt::KeyEvent & rEvent)434cdf0e10cSrcweir void SAL_CALL PresenterNotesView::keyPressed (const awt::KeyEvent& rEvent)
435cdf0e10cSrcweir throw (RuntimeException)
436cdf0e10cSrcweir {
437cdf0e10cSrcweir switch (rEvent.KeyCode)
438cdf0e10cSrcweir {
439cdf0e10cSrcweir case awt::Key::A:
440cdf0e10cSrcweir Scroll(-gnLineScrollFactor * mpFont->mnSize);
441cdf0e10cSrcweir break;
442cdf0e10cSrcweir
443cdf0e10cSrcweir case awt::Key::Y:
444cdf0e10cSrcweir case awt::Key::Z:
445cdf0e10cSrcweir Scroll(+gnLineScrollFactor * mpFont->mnSize);
446cdf0e10cSrcweir break;
447cdf0e10cSrcweir
448cdf0e10cSrcweir case awt::Key::S:
449cdf0e10cSrcweir ChangeFontSize(-1);
450cdf0e10cSrcweir break;
451cdf0e10cSrcweir
452cdf0e10cSrcweir case awt::Key::G:
453cdf0e10cSrcweir ChangeFontSize(+1);
454cdf0e10cSrcweir break;
455cdf0e10cSrcweir
456cdf0e10cSrcweir case awt::Key::H:
457cdf0e10cSrcweir if (mpTextView)
458cdf0e10cSrcweir mpTextView->MoveCaret(
459cdf0e10cSrcweir -1,
460cdf0e10cSrcweir (rEvent.Modifiers == awt::KeyModifier::SHIFT)
461cdf0e10cSrcweir ? cssa::AccessibleTextType::CHARACTER
462cdf0e10cSrcweir : cssa::AccessibleTextType::WORD);
463cdf0e10cSrcweir break;
464cdf0e10cSrcweir
465cdf0e10cSrcweir case awt::Key::L:
466cdf0e10cSrcweir if (mpTextView)
467cdf0e10cSrcweir mpTextView->MoveCaret(
468cdf0e10cSrcweir +1,
469cdf0e10cSrcweir (rEvent.Modifiers == awt::KeyModifier::SHIFT)
470cdf0e10cSrcweir ? cssa::AccessibleTextType::CHARACTER
471cdf0e10cSrcweir : cssa::AccessibleTextType::WORD);
472cdf0e10cSrcweir break;
473cdf0e10cSrcweir }
474cdf0e10cSrcweir }
475cdf0e10cSrcweir
476cdf0e10cSrcweir
477cdf0e10cSrcweir
478cdf0e10cSrcweir
keyReleased(const awt::KeyEvent & rEvent)479cdf0e10cSrcweir void SAL_CALL PresenterNotesView::keyReleased (const awt::KeyEvent& rEvent)
480cdf0e10cSrcweir throw (RuntimeException)
481cdf0e10cSrcweir {
482cdf0e10cSrcweir (void)rEvent;
483cdf0e10cSrcweir }
484cdf0e10cSrcweir
485cdf0e10cSrcweir
486cdf0e10cSrcweir
487cdf0e10cSrcweir
488cdf0e10cSrcweir //-----------------------------------------------------------------------------
489cdf0e10cSrcweir
Layout(void)490cdf0e10cSrcweir void PresenterNotesView::Layout (void)
491cdf0e10cSrcweir {
492cdf0e10cSrcweir if ( ! mxParentWindow.is())
493cdf0e10cSrcweir return;
494cdf0e10cSrcweir
495cdf0e10cSrcweir awt::Rectangle aWindowBox (mxParentWindow->getPosSize());
496cdf0e10cSrcweir geometry::RealRectangle2D aNewTextBoundingBox (0,0,aWindowBox.Width, aWindowBox.Height);
497cdf0e10cSrcweir
498cdf0e10cSrcweir // Size the tool bar and the horizontal separator above it.
499cdf0e10cSrcweir if (mxToolBarWindow.is())
500cdf0e10cSrcweir {
501cdf0e10cSrcweir const geometry::RealSize2D aToolBarSize (mpToolBar->GetMinimalSize());
502cdf0e10cSrcweir const sal_Int32 nToolBarHeight = sal_Int32(aToolBarSize.Height + 0.5);
503cdf0e10cSrcweir mxToolBarWindow->setPosSize(0, aWindowBox.Height - nToolBarHeight,
504cdf0e10cSrcweir sal_Int32(aToolBarSize.Width + 0.5), nToolBarHeight,
505cdf0e10cSrcweir awt::PosSize::POSSIZE);
506cdf0e10cSrcweir aNewTextBoundingBox.Y2 -= nToolBarHeight;
507cdf0e10cSrcweir
508cdf0e10cSrcweir mnSeparatorYLocation = aWindowBox.Height - nToolBarHeight - gnSpaceBelowSeparator;
509cdf0e10cSrcweir aNewTextBoundingBox.Y2 = mnSeparatorYLocation - gnSpaceAboveSeparator;
510cdf0e10cSrcweir
511cdf0e10cSrcweir // Place the close button.
512cdf0e10cSrcweir if (mpCloseButton.get() != NULL)
513cdf0e10cSrcweir mpCloseButton->SetCenter(geometry::RealPoint2D(
514cdf0e10cSrcweir (aWindowBox.Width + aToolBarSize.Width) / 2,
515cdf0e10cSrcweir aWindowBox.Height - aToolBarSize.Height/2));
516cdf0e10cSrcweir }
517cdf0e10cSrcweir
518cdf0e10cSrcweir // Check whether the vertical scroll bar is necessary.
519cdf0e10cSrcweir if (mpScrollBar.get() != NULL)
520cdf0e10cSrcweir {
521cdf0e10cSrcweir bool bShowVerticalScrollbar (false);
522cdf0e10cSrcweir try
523cdf0e10cSrcweir {
524cdf0e10cSrcweir const double nTextBoxHeight (aNewTextBoundingBox.Y2 - aNewTextBoundingBox.Y1);
525cdf0e10cSrcweir const double nHeight (mpTextView->GetTotalTextHeight());
526cdf0e10cSrcweir if (nHeight > nTextBoxHeight)
527cdf0e10cSrcweir {
528cdf0e10cSrcweir bShowVerticalScrollbar = true;
529cdf0e10cSrcweir aNewTextBoundingBox.X2 -= mpScrollBar->GetSize();
530cdf0e10cSrcweir }
531cdf0e10cSrcweir mpScrollBar->SetTotalSize(nHeight);
532cdf0e10cSrcweir }
533cdf0e10cSrcweir catch(beans::UnknownPropertyException&)
534cdf0e10cSrcweir {
535cdf0e10cSrcweir OSL_ASSERT(false);
536cdf0e10cSrcweir }
537cdf0e10cSrcweir
538cdf0e10cSrcweir mpScrollBar->SetVisible(bShowVerticalScrollbar);
539cdf0e10cSrcweir mpScrollBar->SetPosSize(
540cdf0e10cSrcweir geometry::RealRectangle2D(
541cdf0e10cSrcweir aNewTextBoundingBox.X2,
542cdf0e10cSrcweir aNewTextBoundingBox.X1,
543cdf0e10cSrcweir aNewTextBoundingBox.X2 + mpScrollBar->GetSize(),
544cdf0e10cSrcweir aNewTextBoundingBox.Y2));
545cdf0e10cSrcweir if ( ! bShowVerticalScrollbar)
546cdf0e10cSrcweir mpScrollBar->SetThumbPosition(0, false);
547cdf0e10cSrcweir
548cdf0e10cSrcweir UpdateScrollBar();
549cdf0e10cSrcweir }
550cdf0e10cSrcweir
551cdf0e10cSrcweir // Has the text area has changed it position or size?
552cdf0e10cSrcweir if (aNewTextBoundingBox.X1 != maTextBoundingBox.X1
553cdf0e10cSrcweir || aNewTextBoundingBox.Y1 != maTextBoundingBox.Y1
554cdf0e10cSrcweir || aNewTextBoundingBox.X2 != maTextBoundingBox.X2
555cdf0e10cSrcweir || aNewTextBoundingBox.Y2 != maTextBoundingBox.Y2)
556cdf0e10cSrcweir {
557cdf0e10cSrcweir maTextBoundingBox = aNewTextBoundingBox;
558cdf0e10cSrcweir
559cdf0e10cSrcweir mpTextView->SetLocation(
560cdf0e10cSrcweir geometry::RealPoint2D(
561cdf0e10cSrcweir aNewTextBoundingBox.X1,
562cdf0e10cSrcweir aNewTextBoundingBox.Y1));
563cdf0e10cSrcweir mpTextView->SetSize(
564cdf0e10cSrcweir geometry::RealSize2D(
565cdf0e10cSrcweir aNewTextBoundingBox.X2 - aNewTextBoundingBox.X1,
566cdf0e10cSrcweir aNewTextBoundingBox.Y2 - aNewTextBoundingBox.Y1));
567cdf0e10cSrcweir }
568cdf0e10cSrcweir }
569cdf0e10cSrcweir
570cdf0e10cSrcweir
571cdf0e10cSrcweir
572cdf0e10cSrcweir
Paint(const awt::Rectangle & rUpdateBox)573cdf0e10cSrcweir void PresenterNotesView::Paint (const awt::Rectangle& rUpdateBox)
574cdf0e10cSrcweir {
575cdf0e10cSrcweir if ( ! mxParentWindow.is())
576cdf0e10cSrcweir return;
577cdf0e10cSrcweir if ( ! mxCanvas.is())
578cdf0e10cSrcweir return;
579cdf0e10cSrcweir
580cdf0e10cSrcweir if (mpBackground.get() == NULL)
581cdf0e10cSrcweir mpBackground = mpPresenterController->GetViewBackground(mxViewId->getResourceURL());
582cdf0e10cSrcweir
583cdf0e10cSrcweir if (rUpdateBox.Y < maTextBoundingBox.Y2
584cdf0e10cSrcweir && rUpdateBox.X < maTextBoundingBox.X2)
585cdf0e10cSrcweir {
586cdf0e10cSrcweir PaintText(rUpdateBox);
587cdf0e10cSrcweir }
588cdf0e10cSrcweir
589cdf0e10cSrcweir mpTextView->Paint(rUpdateBox);
590cdf0e10cSrcweir
591cdf0e10cSrcweir if (rUpdateBox.Y + rUpdateBox.Height > maTextBoundingBox.Y2)
592cdf0e10cSrcweir {
593cdf0e10cSrcweir PaintToolBar(rUpdateBox);
594cdf0e10cSrcweir }
595cdf0e10cSrcweir }
596cdf0e10cSrcweir
597cdf0e10cSrcweir
598cdf0e10cSrcweir
599cdf0e10cSrcweir
PaintToolBar(const awt::Rectangle & rUpdateBox)600cdf0e10cSrcweir void PresenterNotesView::PaintToolBar (const awt::Rectangle& rUpdateBox)
601cdf0e10cSrcweir {
602cdf0e10cSrcweir awt::Rectangle aWindowBox (mxParentWindow->getPosSize());
603cdf0e10cSrcweir
604cdf0e10cSrcweir rendering::ViewState aViewState (
605cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,0, 0,1,0),
606cdf0e10cSrcweir NULL);
607cdf0e10cSrcweir rendering::RenderState aRenderState(
608cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,0, 0,1,0),
609cdf0e10cSrcweir NULL,
610cdf0e10cSrcweir Sequence<double>(4),
611cdf0e10cSrcweir rendering::CompositeOperation::SOURCE);
612cdf0e10cSrcweir
613cdf0e10cSrcweir if (mpBackground.get() != NULL)
614cdf0e10cSrcweir {
615cdf0e10cSrcweir // Paint the background.
616cdf0e10cSrcweir mpPresenterController->GetCanvasHelper()->Paint(
617cdf0e10cSrcweir mpBackground,
618cdf0e10cSrcweir mxCanvas,
619cdf0e10cSrcweir rUpdateBox,
620cdf0e10cSrcweir awt::Rectangle(0,sal_Int32(maTextBoundingBox.Y2),aWindowBox.Width,aWindowBox.Height),
621cdf0e10cSrcweir awt::Rectangle());
622cdf0e10cSrcweir }
623cdf0e10cSrcweir
624cdf0e10cSrcweir // Paint the horizontal separator.
625cdf0e10cSrcweir OSL_ASSERT(mxViewId.is());
626cdf0e10cSrcweir PresenterCanvasHelper::SetDeviceColor(aRenderState, maSeparatorColor);
627cdf0e10cSrcweir
628cdf0e10cSrcweir mxCanvas->drawLine(
629cdf0e10cSrcweir geometry::RealPoint2D(0,mnSeparatorYLocation),
630cdf0e10cSrcweir geometry::RealPoint2D(aWindowBox.Width,mnSeparatorYLocation),
631cdf0e10cSrcweir aViewState,
632cdf0e10cSrcweir aRenderState);
633cdf0e10cSrcweir }
634cdf0e10cSrcweir
635cdf0e10cSrcweir
636cdf0e10cSrcweir
637cdf0e10cSrcweir
PaintText(const awt::Rectangle & rUpdateBox)638cdf0e10cSrcweir void PresenterNotesView::PaintText (const awt::Rectangle& rUpdateBox)
639cdf0e10cSrcweir {
640cdf0e10cSrcweir const awt::Rectangle aBox (PresenterGeometryHelper::Intersection(rUpdateBox,
641cdf0e10cSrcweir PresenterGeometryHelper::ConvertRectangle(maTextBoundingBox)));
642cdf0e10cSrcweir
643cdf0e10cSrcweir if (aBox.Width <= 0 || aBox.Height <= 0)
644cdf0e10cSrcweir return;
645cdf0e10cSrcweir
646cdf0e10cSrcweir rendering::ViewState aViewState (
647cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,0, 0,1,0),
648cdf0e10cSrcweir PresenterGeometryHelper::CreatePolygon(aBox, mxCanvas->getDevice()));
649cdf0e10cSrcweir rendering::RenderState aRenderState(
650cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,0, 0,1,0),
651cdf0e10cSrcweir NULL,
652cdf0e10cSrcweir Sequence<double>(3),
653cdf0e10cSrcweir rendering::CompositeOperation::SOURCE);
654cdf0e10cSrcweir
655cdf0e10cSrcweir if (mpBackground.get() != NULL)
656cdf0e10cSrcweir {
657cdf0e10cSrcweir // Paint the background.
658cdf0e10cSrcweir mpPresenterController->GetCanvasHelper()->Paint(
659cdf0e10cSrcweir mpBackground,
660cdf0e10cSrcweir mxCanvas,
661cdf0e10cSrcweir rUpdateBox,
662cdf0e10cSrcweir aBox,
663cdf0e10cSrcweir awt::Rectangle());
664cdf0e10cSrcweir }
665cdf0e10cSrcweir
666cdf0e10cSrcweir Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
667cdf0e10cSrcweir if (xSpriteCanvas.is())
668cdf0e10cSrcweir xSpriteCanvas->updateScreen(sal_False);
669cdf0e10cSrcweir }
670cdf0e10cSrcweir
671cdf0e10cSrcweir
672cdf0e10cSrcweir
673cdf0e10cSrcweir
Invalidate(void)674cdf0e10cSrcweir void PresenterNotesView::Invalidate (void)
675cdf0e10cSrcweir {
676cdf0e10cSrcweir mpPresenterController->GetPaintManager()->Invalidate(
677cdf0e10cSrcweir mxParentWindow,
678cdf0e10cSrcweir PresenterGeometryHelper::ConvertRectangle(maTextBoundingBox));
679cdf0e10cSrcweir }
680cdf0e10cSrcweir
681cdf0e10cSrcweir
682cdf0e10cSrcweir
683cdf0e10cSrcweir
Scroll(const double rnDistance)684cdf0e10cSrcweir void PresenterNotesView::Scroll (const double rnDistance)
685cdf0e10cSrcweir {
686cdf0e10cSrcweir try
687cdf0e10cSrcweir {
688cdf0e10cSrcweir mnTop += rnDistance;
689cdf0e10cSrcweir mpTextView->SetOffset(0, mnTop);
690cdf0e10cSrcweir
691cdf0e10cSrcweir UpdateScrollBar();
692cdf0e10cSrcweir Invalidate();
693cdf0e10cSrcweir }
694cdf0e10cSrcweir catch (beans::UnknownPropertyException&)
695cdf0e10cSrcweir {}
696cdf0e10cSrcweir }
697cdf0e10cSrcweir
698cdf0e10cSrcweir
699cdf0e10cSrcweir
700cdf0e10cSrcweir
SetTop(const double nTop)701cdf0e10cSrcweir void PresenterNotesView::SetTop (const double nTop)
702cdf0e10cSrcweir {
703cdf0e10cSrcweir try
704cdf0e10cSrcweir {
705cdf0e10cSrcweir mnTop = nTop;
706cdf0e10cSrcweir mpTextView->SetOffset(0, mnTop);
707cdf0e10cSrcweir
708cdf0e10cSrcweir UpdateScrollBar();
709cdf0e10cSrcweir Invalidate();
710cdf0e10cSrcweir }
711cdf0e10cSrcweir catch (beans::UnknownPropertyException&)
712cdf0e10cSrcweir {}
713cdf0e10cSrcweir }
714cdf0e10cSrcweir
715cdf0e10cSrcweir
716cdf0e10cSrcweir
717cdf0e10cSrcweir
ChangeFontSize(const sal_Int32 nSizeChange)718cdf0e10cSrcweir void PresenterNotesView::ChangeFontSize (const sal_Int32 nSizeChange)
719cdf0e10cSrcweir {
720cdf0e10cSrcweir const sal_Int32 nNewSize (mpFont->mnSize + nSizeChange);
721cdf0e10cSrcweir if (nNewSize > 5)
722cdf0e10cSrcweir {
723cdf0e10cSrcweir mpFont->mnSize = nNewSize;
724cdf0e10cSrcweir mpFont->mxFont = NULL;
725cdf0e10cSrcweir mpTextView->SetFont(mpFont);
726cdf0e10cSrcweir
727cdf0e10cSrcweir Layout();
728cdf0e10cSrcweir UpdateScrollBar();
729cdf0e10cSrcweir Invalidate();
730cdf0e10cSrcweir
731cdf0e10cSrcweir // Write the new font size to the configuration to make it persistent.
732cdf0e10cSrcweir try
733cdf0e10cSrcweir {
734cdf0e10cSrcweir const OUString sStyleName (mpPresenterController->GetTheme()->GetStyleName(
735cdf0e10cSrcweir mxViewId->getResourceURL()));
736cdf0e10cSrcweir ::boost::shared_ptr<PresenterConfigurationAccess> pConfiguration (
737cdf0e10cSrcweir mpPresenterController->GetTheme()->GetNodeForViewStyle(
738cdf0e10cSrcweir sStyleName,
739cdf0e10cSrcweir PresenterConfigurationAccess::READ_WRITE));
740cdf0e10cSrcweir if (pConfiguration.get()==NULL || ! pConfiguration->IsValid())
741cdf0e10cSrcweir return;
742cdf0e10cSrcweir
743cdf0e10cSrcweir pConfiguration->GoToChild(A2S("Font"));
744cdf0e10cSrcweir pConfiguration->SetProperty(A2S("Size"), Any((sal_Int32)(nNewSize+0.5)));
745cdf0e10cSrcweir pConfiguration->CommitChanges();
746cdf0e10cSrcweir }
747cdf0e10cSrcweir catch (Exception&)
748cdf0e10cSrcweir {
749cdf0e10cSrcweir OSL_ASSERT(false);
750cdf0e10cSrcweir }
751cdf0e10cSrcweir }
752cdf0e10cSrcweir }
753cdf0e10cSrcweir
754cdf0e10cSrcweir
755cdf0e10cSrcweir
756cdf0e10cSrcweir
GetTextView(void) const757cdf0e10cSrcweir ::boost::shared_ptr<PresenterTextView> PresenterNotesView::GetTextView (void) const
758cdf0e10cSrcweir {
759cdf0e10cSrcweir return mpTextView;
760cdf0e10cSrcweir }
761cdf0e10cSrcweir
762cdf0e10cSrcweir
763cdf0e10cSrcweir
764cdf0e10cSrcweir
UpdateScrollBar(void)765cdf0e10cSrcweir void PresenterNotesView::UpdateScrollBar (void)
766cdf0e10cSrcweir {
767cdf0e10cSrcweir if (mpScrollBar.get() != NULL)
768cdf0e10cSrcweir {
769cdf0e10cSrcweir try
770cdf0e10cSrcweir {
771cdf0e10cSrcweir mpScrollBar->SetTotalSize(mpTextView->GetTotalTextHeight());
772cdf0e10cSrcweir }
773cdf0e10cSrcweir catch(beans::UnknownPropertyException&)
774cdf0e10cSrcweir {
775cdf0e10cSrcweir OSL_ASSERT(false);
776cdf0e10cSrcweir }
777cdf0e10cSrcweir
778cdf0e10cSrcweir mpScrollBar->SetLineHeight(mpFont->mnSize*1.2);
779cdf0e10cSrcweir mpScrollBar->SetThumbPosition(mnTop, false);
780cdf0e10cSrcweir
781cdf0e10cSrcweir mpScrollBar->SetThumbSize(maTextBoundingBox.Y2 - maTextBoundingBox.Y1);
782cdf0e10cSrcweir mpScrollBar->CheckValues();
783cdf0e10cSrcweir }
784cdf0e10cSrcweir }
785cdf0e10cSrcweir
786cdf0e10cSrcweir
787cdf0e10cSrcweir
788cdf0e10cSrcweir
ThrowIfDisposed(void)789cdf0e10cSrcweir void PresenterNotesView::ThrowIfDisposed (void)
790cdf0e10cSrcweir throw (::com::sun::star::lang::DisposedException)
791cdf0e10cSrcweir {
792cdf0e10cSrcweir if (rBHelper.bDisposed || rBHelper.bInDispose)
793cdf0e10cSrcweir {
794cdf0e10cSrcweir throw lang::DisposedException (
795cdf0e10cSrcweir A2S("PresenterNotesView object has already been disposed"),
796cdf0e10cSrcweir static_cast<uno::XWeak*>(this));
797cdf0e10cSrcweir }
798cdf0e10cSrcweir }
799cdf0e10cSrcweir
800cdf0e10cSrcweir
801cdf0e10cSrcweir
802cdf0e10cSrcweir
803cdf0e10cSrcweir } } // end of namespace ::sdext::presenter
804