1c142477cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3c142477cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4c142477cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5c142477cSAndrew Rist * distributed with this work for additional information
6c142477cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7c142477cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8c142477cSAndrew Rist * "License"); you may not use this file except in compliance
9c142477cSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11c142477cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13c142477cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14c142477cSAndrew Rist * software distributed under the License is distributed on an
15c142477cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c142477cSAndrew Rist * KIND, either express or implied. See the License for the
17c142477cSAndrew Rist * specific language governing permissions and limitations
18c142477cSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20c142477cSAndrew Rist *************************************************************/
21c142477cSAndrew Rist
22c142477cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sdext.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "PresenterSlideSorter.hxx"
28cdf0e10cSrcweir #include "PresenterButton.hxx"
29cdf0e10cSrcweir #include "PresenterCanvasHelper.hxx"
30cdf0e10cSrcweir #include "PresenterGeometryHelper.hxx"
31cdf0e10cSrcweir #include "PresenterHelper.hxx"
32cdf0e10cSrcweir #include "PresenterPaintManager.hxx"
33cdf0e10cSrcweir #include "PresenterPaneBase.hxx"
34cdf0e10cSrcweir #include "PresenterScrollBar.hxx"
35cdf0e10cSrcweir #include "PresenterUIPainter.hxx"
36cdf0e10cSrcweir #include "PresenterWindowManager.hxx"
37cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
38cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp>
39cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
40cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp>
41cdf0e10cSrcweir #include <com/sun/star/drawing/XSlideSorterBase.hpp>
42cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
43cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp>
44cdf0e10cSrcweir #include <com/sun/star/rendering/CompositeOperation.hpp>
45cdf0e10cSrcweir #include <com/sun/star/rendering/TextDirection.hpp>
46cdf0e10cSrcweir #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
47cdf0e10cSrcweir #include <com/sun/star/util/Color.hpp>
48cdf0e10cSrcweir #include <algorithm>
49cdf0e10cSrcweir #include <math.h>
50cdf0e10cSrcweir #include <boost/bind.hpp>
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 namespace {
60cdf0e10cSrcweir const static sal_Int32 gnVerticalGap (10);
61cdf0e10cSrcweir const static sal_Int32 gnVerticalBorder (10);
62cdf0e10cSrcweir const static sal_Int32 gnHorizontalGap (10);
63cdf0e10cSrcweir const static sal_Int32 gnHorizontalBorder (10);
64cdf0e10cSrcweir
65cdf0e10cSrcweir const static double gnMinimalPreviewWidth (200);
66cdf0e10cSrcweir const static double gnPreferredPreviewWidth (300);
67cdf0e10cSrcweir const static double gnMaximalPreviewWidth (400);
68cdf0e10cSrcweir const static sal_Int32 gnPreferredColumnCount (6);
69cdf0e10cSrcweir const static double gnMinimalHorizontalPreviewGap(15);
70cdf0e10cSrcweir const static double gnPreferredHorizontalPreviewGap(25);
71cdf0e10cSrcweir const static double gnMaximalHorizontalPreviewGap(50);
72cdf0e10cSrcweir const static double gnMinimalVerticalPreviewGap(15);
73cdf0e10cSrcweir const static double gnPreferredVerticalPreviewGap(25);
74cdf0e10cSrcweir const static double gnMaximalVerticalPreviewGap(50);
75cdf0e10cSrcweir
76cdf0e10cSrcweir const static sal_Int32 gnHorizontalLabelBorder (3);
77cdf0e10cSrcweir const static sal_Int32 gnHorizontalLabelPadding (5);
78cdf0e10cSrcweir
79cdf0e10cSrcweir const static sal_Int32 gnVerticalButtonPadding (gnVerticalGap);
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
82cdf0e10cSrcweir namespace sdext { namespace presenter {
83cdf0e10cSrcweir
84cdf0e10cSrcweir namespace {
round(const double nValue)85cdf0e10cSrcweir sal_Int32 round (const double nValue) { return sal::static_int_cast<sal_Int32>(0.5 + nValue); }
floor(const double nValue)86cdf0e10cSrcweir sal_Int32 floor (const double nValue) { return sal::static_int_cast<sal_Int32>(nValue); }
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
89cdf0e10cSrcweir
90cdf0e10cSrcweir
91cdf0e10cSrcweir //===== PresenterSlideSorter::Layout ==========================================
92cdf0e10cSrcweir
93cdf0e10cSrcweir class PresenterSlideSorter::Layout
94cdf0e10cSrcweir {
95cdf0e10cSrcweir public:
96cdf0e10cSrcweir enum Orientation { Horizontal, Vertical };
97cdf0e10cSrcweir Layout (
98cdf0e10cSrcweir const Orientation eOrientation,
99cdf0e10cSrcweir const ::rtl::Reference<PresenterScrollBar>& rpHorizontalScrollBar,
100cdf0e10cSrcweir const ::rtl::Reference<PresenterScrollBar>& rpVerticalScrollBar);
101cdf0e10cSrcweir
102cdf0e10cSrcweir void Update (const geometry::RealRectangle2D& rBoundingBox, const double nSlideAspectRatio);
103cdf0e10cSrcweir void SetupVisibleArea (void);
104cdf0e10cSrcweir void UpdateScrollBars (void);
105cdf0e10cSrcweir bool IsScrollBarNeeded (const sal_Int32 nSlideCount);
106cdf0e10cSrcweir geometry::RealPoint2D GetLocalPosition (const geometry::RealPoint2D& rWindowPoint) const;
107cdf0e10cSrcweir geometry::RealPoint2D GetWindowPosition(const geometry::RealPoint2D& rLocalPoint) const;
108cdf0e10cSrcweir sal_Int32 GetColumn (const geometry::RealPoint2D& rLocalPoint,
109cdf0e10cSrcweir const bool bReturnInvalidValue = false) const;
110cdf0e10cSrcweir sal_Int32 GetRow (const geometry::RealPoint2D& rLocalPoint,
111cdf0e10cSrcweir const bool bReturnInvalidValue = false) const;
112cdf0e10cSrcweir sal_Int32 GetSlideIndexForPosition (const css::geometry::RealPoint2D& rPoint) const;
113cdf0e10cSrcweir css::geometry::RealPoint2D GetPoint (
114cdf0e10cSrcweir const sal_Int32 nSlideIndex,
115cdf0e10cSrcweir const sal_Int32 nRelativeHorizontalPosition,
116cdf0e10cSrcweir const sal_Int32 nRelativeVerticalPosition) const;
117cdf0e10cSrcweir css::awt::Rectangle GetBoundingBox (const sal_Int32 nSlideIndex) const;
118cdf0e10cSrcweir void ForAllVisibleSlides (const ::boost::function<void(sal_Int32)>& rAction);
119cdf0e10cSrcweir sal_Int32 GetFirstVisibleSlideIndex (void) const;
120cdf0e10cSrcweir sal_Int32 GetLastVisibleSlideIndex (void) const;
121cdf0e10cSrcweir bool SetHorizontalOffset (const double nOffset);
122cdf0e10cSrcweir bool SetVerticalOffset (const double nOffset);
123cdf0e10cSrcweir Orientation GetOrientation (void) const;
124cdf0e10cSrcweir
125cdf0e10cSrcweir css::geometry::RealRectangle2D maBoundingBox;
126cdf0e10cSrcweir css::geometry::IntegerSize2D maPreviewSize;
127cdf0e10cSrcweir sal_Int32 mnHorizontalOffset;
128cdf0e10cSrcweir sal_Int32 mnVerticalOffset;
129cdf0e10cSrcweir sal_Int32 mnHorizontalGap;
130cdf0e10cSrcweir sal_Int32 mnVerticalGap;
131cdf0e10cSrcweir sal_Int32 mnHorizontalBorder;
132cdf0e10cSrcweir sal_Int32 mnVerticalBorder;
133cdf0e10cSrcweir sal_Int32 mnRowCount;
134cdf0e10cSrcweir sal_Int32 mnColumnCount;
135cdf0e10cSrcweir sal_Int32 mnSlideCount;
136cdf0e10cSrcweir sal_Int32 mnSlideIndexAtMouse;
137cdf0e10cSrcweir sal_Int32 mnFirstVisibleColumn;
138cdf0e10cSrcweir sal_Int32 mnLastVisibleColumn;
139cdf0e10cSrcweir sal_Int32 mnFirstVisibleRow;
140cdf0e10cSrcweir sal_Int32 mnLastVisibleRow;
141cdf0e10cSrcweir
142cdf0e10cSrcweir private:
143cdf0e10cSrcweir Orientation meOrientation;
144cdf0e10cSrcweir ::rtl::Reference<PresenterScrollBar> mpHorizontalScrollBar;
145cdf0e10cSrcweir ::rtl::Reference<PresenterScrollBar> mpVerticalScrollBar;
146cdf0e10cSrcweir
147cdf0e10cSrcweir sal_Int32 GetIndex (const sal_Int32 nRow, const sal_Int32 nColumn) const;
148cdf0e10cSrcweir sal_Int32 GetRow (const sal_Int32 nSlideIndex) const;
149cdf0e10cSrcweir sal_Int32 GetColumn (const sal_Int32 nSlideIndex) const;
150cdf0e10cSrcweir };
151cdf0e10cSrcweir
152cdf0e10cSrcweir
153cdf0e10cSrcweir
154cdf0e10cSrcweir
155cdf0e10cSrcweir //==== PresenterSlideSorter::MouseOverManager =================================
156cdf0e10cSrcweir
157cdf0e10cSrcweir class PresenterSlideSorter::MouseOverManager
158cdf0e10cSrcweir : ::boost::noncopyable
159cdf0e10cSrcweir {
160cdf0e10cSrcweir public:
161cdf0e10cSrcweir MouseOverManager (
162cdf0e10cSrcweir const Reference<container::XIndexAccess>& rxSlides,
163cdf0e10cSrcweir const ::boost::shared_ptr<PresenterTheme>& rpTheme,
164cdf0e10cSrcweir const Reference<awt::XWindow>& rxInvalidateTarget,
165cdf0e10cSrcweir const ::boost::shared_ptr<PresenterPaintManager>& rpPaintManager);
166cdf0e10cSrcweir ~MouseOverManager (void);
167cdf0e10cSrcweir
168cdf0e10cSrcweir void Paint (
169cdf0e10cSrcweir const sal_Int32 nSlideIndex,
170cdf0e10cSrcweir const Reference<rendering::XCanvas>& rxCanvas,
171cdf0e10cSrcweir const Reference<rendering::XPolyPolygon2D>& rxClip);
172cdf0e10cSrcweir
173cdf0e10cSrcweir void SetSlide (
174cdf0e10cSrcweir const sal_Int32 nSlideIndex,
175cdf0e10cSrcweir const awt::Rectangle& rBox);
176cdf0e10cSrcweir
177cdf0e10cSrcweir private:
178cdf0e10cSrcweir Reference<rendering::XCanvas> mxCanvas;
179cdf0e10cSrcweir const Reference<container::XIndexAccess> mxSlides;
180cdf0e10cSrcweir SharedBitmapDescriptor mpLeftLabelBitmap;
181cdf0e10cSrcweir SharedBitmapDescriptor mpCenterLabelBitmap;
182cdf0e10cSrcweir SharedBitmapDescriptor mpRightLabelBitmap;
183cdf0e10cSrcweir PresenterTheme::SharedFontDescriptor mpFont;
184cdf0e10cSrcweir sal_Int32 mnSlideIndex;
185cdf0e10cSrcweir awt::Rectangle maSlideBoundingBox;
186cdf0e10cSrcweir OUString msText;
187cdf0e10cSrcweir Reference<rendering::XBitmap> mxBitmap;
188cdf0e10cSrcweir Reference<awt::XWindow> mxInvalidateTarget;
189cdf0e10cSrcweir ::boost::shared_ptr<PresenterPaintManager> mpPaintManager;
190cdf0e10cSrcweir
191cdf0e10cSrcweir void SetCanvas (
192cdf0e10cSrcweir const Reference<rendering::XCanvas>& rxCanvas);
193cdf0e10cSrcweir /** Create a bitmap that shows the given text and is not wider than the
194cdf0e10cSrcweir given maximal width.
195cdf0e10cSrcweir */
196cdf0e10cSrcweir Reference<rendering::XBitmap> CreateBitmap (
197cdf0e10cSrcweir const OUString& rsText,
198cdf0e10cSrcweir const sal_Int32 nMaximalWidth) const;
199cdf0e10cSrcweir void Invalidate (void);
200cdf0e10cSrcweir geometry::IntegerSize2D CalculateLabelSize (
201cdf0e10cSrcweir const OUString& rsText) const;
202cdf0e10cSrcweir OUString GetFittingText (const OUString& rsText, const double nMaximalWidth) const;
203cdf0e10cSrcweir void PaintButtonBackground (
204cdf0e10cSrcweir const Reference<rendering::XBitmapCanvas>& rxCanvas,
205cdf0e10cSrcweir const geometry::IntegerSize2D& rSize) const;
206cdf0e10cSrcweir };
207cdf0e10cSrcweir
208cdf0e10cSrcweir
209cdf0e10cSrcweir
210cdf0e10cSrcweir
211cdf0e10cSrcweir //==== PresenterSlideSorter::CurrentSlideFrameRenderer ========================
212cdf0e10cSrcweir
213cdf0e10cSrcweir class PresenterSlideSorter::CurrentSlideFrameRenderer
214cdf0e10cSrcweir {
215cdf0e10cSrcweir public:
216cdf0e10cSrcweir CurrentSlideFrameRenderer (
217cdf0e10cSrcweir const css::uno::Reference<css::uno::XComponentContext>& rxContext,
218cdf0e10cSrcweir const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
219cdf0e10cSrcweir ~CurrentSlideFrameRenderer (void);
220cdf0e10cSrcweir
221cdf0e10cSrcweir void PaintCurrentSlideFrame (
222cdf0e10cSrcweir const awt::Rectangle& rSlideBoundingBox,
223cdf0e10cSrcweir const Reference<rendering::XCanvas>& rxCanvas,
224cdf0e10cSrcweir const geometry::RealRectangle2D& rClipBox);
225cdf0e10cSrcweir
226cdf0e10cSrcweir /** Enlarge the given rectangle to include the current slide indicator.
227cdf0e10cSrcweir */
228cdf0e10cSrcweir awt::Rectangle GetBoundingBox (
229cdf0e10cSrcweir const awt::Rectangle& rSlideBoundingBox);
230cdf0e10cSrcweir
231cdf0e10cSrcweir private:
232cdf0e10cSrcweir SharedBitmapDescriptor mpTopLeft;
233cdf0e10cSrcweir SharedBitmapDescriptor mpTop;
234cdf0e10cSrcweir SharedBitmapDescriptor mpTopRight;
235cdf0e10cSrcweir SharedBitmapDescriptor mpLeft;
236cdf0e10cSrcweir SharedBitmapDescriptor mpRight;
237cdf0e10cSrcweir SharedBitmapDescriptor mpBottomLeft;
238cdf0e10cSrcweir SharedBitmapDescriptor mpBottom;
239cdf0e10cSrcweir SharedBitmapDescriptor mpBottomRight;
240cdf0e10cSrcweir sal_Int32 mnTopFrameSize;
241cdf0e10cSrcweir sal_Int32 mnLeftFrameSize;
242cdf0e10cSrcweir sal_Int32 mnRightFrameSize;
243cdf0e10cSrcweir sal_Int32 mnBottomFrameSize;
244cdf0e10cSrcweir
245cdf0e10cSrcweir void PaintBitmapOnce(
246cdf0e10cSrcweir const css::uno::Reference<css::rendering::XBitmap>& rxBitmap,
247cdf0e10cSrcweir const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
248cdf0e10cSrcweir const Reference<rendering::XPolyPolygon2D>& rxClip,
249cdf0e10cSrcweir const double nX,
250cdf0e10cSrcweir const double nY);
251cdf0e10cSrcweir void PaintBitmapTiled(
252cdf0e10cSrcweir const css::uno::Reference<css::rendering::XBitmap>& rxBitmap,
253cdf0e10cSrcweir const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
254cdf0e10cSrcweir const geometry::RealRectangle2D& rClipBox,
255cdf0e10cSrcweir const double nX,
256cdf0e10cSrcweir const double nY,
257cdf0e10cSrcweir const double nWidth,
258cdf0e10cSrcweir const double nHeight);
259cdf0e10cSrcweir };
260cdf0e10cSrcweir
261cdf0e10cSrcweir
262cdf0e10cSrcweir
263cdf0e10cSrcweir
264cdf0e10cSrcweir //===== PresenterSlideSorter ==================================================
265cdf0e10cSrcweir
PresenterSlideSorter(const Reference<uno::XComponentContext> & rxContext,const Reference<XResourceId> & rxViewId,const Reference<frame::XController> & rxController,const::rtl::Reference<PresenterController> & rpPresenterController)266cdf0e10cSrcweir PresenterSlideSorter::PresenterSlideSorter (
267cdf0e10cSrcweir const Reference<uno::XComponentContext>& rxContext,
268cdf0e10cSrcweir const Reference<XResourceId>& rxViewId,
269cdf0e10cSrcweir const Reference<frame::XController>& rxController,
270cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController)
271cdf0e10cSrcweir : PresenterSlideSorterInterfaceBase(m_aMutex),
272cdf0e10cSrcweir mxComponentContext(rxContext),
273cdf0e10cSrcweir mxViewId(rxViewId),
274cdf0e10cSrcweir mxPane(),
275cdf0e10cSrcweir mxCanvas(),
276cdf0e10cSrcweir mxWindow(),
277cdf0e10cSrcweir mpPresenterController(rpPresenterController),
278cdf0e10cSrcweir mxSlideShowController(mpPresenterController->GetSlideShowController()),
279cdf0e10cSrcweir mxPreviewCache(),
280cdf0e10cSrcweir mbIsPaintPending(true),
281cdf0e10cSrcweir mbIsLayoutPending(true),
282cdf0e10cSrcweir mpLayout(),
283cdf0e10cSrcweir mpHorizontalScrollBar(),
284cdf0e10cSrcweir mpVerticalScrollBar(),
285cdf0e10cSrcweir mpCloseButton(),
286cdf0e10cSrcweir mpMouseOverManager(),
287cdf0e10cSrcweir mnSlideIndexMousePressed(-1),
288cdf0e10cSrcweir mnCurrentSlideIndex(-1),
289cdf0e10cSrcweir mnSeparatorY(0),
290cdf0e10cSrcweir maSeparatorColor(0x00ffffff),
291cdf0e10cSrcweir maCloseButtonCenter(),
292cdf0e10cSrcweir maCurrentSlideFrameBoundingBox(),
293cdf0e10cSrcweir mpCurrentSlideFrameRenderer(),
294cdf0e10cSrcweir mxPreviewFrame()
295cdf0e10cSrcweir {
296cdf0e10cSrcweir if ( ! rxContext.is()
297cdf0e10cSrcweir || ! rxViewId.is()
298cdf0e10cSrcweir || ! rxController.is()
299cdf0e10cSrcweir || rpPresenterController.get()==NULL)
300cdf0e10cSrcweir {
301cdf0e10cSrcweir throw lang::IllegalArgumentException();
302cdf0e10cSrcweir }
303cdf0e10cSrcweir
304cdf0e10cSrcweir if ( ! mxSlideShowController.is())
305cdf0e10cSrcweir throw RuntimeException();
306cdf0e10cSrcweir
307cdf0e10cSrcweir try
308cdf0e10cSrcweir {
309cdf0e10cSrcweir // Get pane and window.
310cdf0e10cSrcweir Reference<XControllerManager> xCM (rxController, UNO_QUERY_THROW);
311cdf0e10cSrcweir Reference<XConfigurationController> xCC (
312cdf0e10cSrcweir xCM->getConfigurationController(), UNO_QUERY_THROW);
313cdf0e10cSrcweir Reference<lang::XMultiComponentFactory> xFactory (
314cdf0e10cSrcweir mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
315cdf0e10cSrcweir
316cdf0e10cSrcweir mxPane = Reference<XPane>(xCC->getResource(rxViewId->getAnchor()), UNO_QUERY_THROW);
317cdf0e10cSrcweir mxWindow = mxPane->getWindow();
318cdf0e10cSrcweir
319cdf0e10cSrcweir // Add window listener.
320cdf0e10cSrcweir mxWindow->addWindowListener(this);
321cdf0e10cSrcweir mxWindow->addPaintListener(this);
322cdf0e10cSrcweir mxWindow->addMouseListener(this);
323cdf0e10cSrcweir mxWindow->addMouseMotionListener(this);
324cdf0e10cSrcweir mxWindow->setVisible(sal_True);
325cdf0e10cSrcweir
326cdf0e10cSrcweir // Remember the current slide.
327cdf0e10cSrcweir mnCurrentSlideIndex = mxSlideShowController->getCurrentSlideIndex();
328cdf0e10cSrcweir
329cdf0e10cSrcweir // Set the orientation.
330cdf0e10cSrcweir const bool bIsVertical (true);
331cdf0e10cSrcweir
332cdf0e10cSrcweir // Create the scroll bar.
333cdf0e10cSrcweir if (bIsVertical)
334cdf0e10cSrcweir mpVerticalScrollBar = ::rtl::Reference<PresenterScrollBar>(
335cdf0e10cSrcweir new PresenterVerticalScrollBar(
336cdf0e10cSrcweir rxContext,
337cdf0e10cSrcweir mxWindow,
338cdf0e10cSrcweir mpPresenterController->GetPaintManager(),
339cdf0e10cSrcweir ::boost::bind(&PresenterSlideSorter::SetVerticalOffset,this,_1)));
340cdf0e10cSrcweir else
341cdf0e10cSrcweir mpHorizontalScrollBar = ::rtl::Reference<PresenterScrollBar>(
342cdf0e10cSrcweir new PresenterHorizontalScrollBar(
343cdf0e10cSrcweir rxContext,
344cdf0e10cSrcweir mxWindow,
345cdf0e10cSrcweir mpPresenterController->GetPaintManager(),
346cdf0e10cSrcweir ::boost::bind(&PresenterSlideSorter::SetHorizontalOffset,this,_1)));
347cdf0e10cSrcweir mpCloseButton = PresenterButton::Create(
348cdf0e10cSrcweir rxContext,
349cdf0e10cSrcweir mpPresenterController,
350cdf0e10cSrcweir mpPresenterController->GetTheme(),
351cdf0e10cSrcweir mxWindow,
352cdf0e10cSrcweir mxCanvas,
353cdf0e10cSrcweir A2S("SlideSorterCloser"));
354cdf0e10cSrcweir
355cdf0e10cSrcweir if (mpPresenterController->GetTheme().get() != NULL)
356cdf0e10cSrcweir {
357cdf0e10cSrcweir PresenterTheme::SharedFontDescriptor pFont (
358cdf0e10cSrcweir mpPresenterController->GetTheme()->GetFont(A2S("ButtonFont")));
359cdf0e10cSrcweir if (pFont.get() != NULL)
360cdf0e10cSrcweir maSeparatorColor = pFont->mnColor;
361cdf0e10cSrcweir }
362cdf0e10cSrcweir
363cdf0e10cSrcweir // Create the layout.
364cdf0e10cSrcweir mpLayout.reset(new Layout(
365cdf0e10cSrcweir Layout::Vertical,
366cdf0e10cSrcweir mpHorizontalScrollBar,
367cdf0e10cSrcweir mpVerticalScrollBar));
368cdf0e10cSrcweir
369cdf0e10cSrcweir // Create the preview cache.
370cdf0e10cSrcweir mxPreviewCache = Reference<drawing::XSlidePreviewCache>(
371cdf0e10cSrcweir xFactory->createInstanceWithContext(
372cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.drawing.PresenterPreviewCache"),
373cdf0e10cSrcweir mxComponentContext),
374cdf0e10cSrcweir UNO_QUERY_THROW);
375cdf0e10cSrcweir Reference<container::XIndexAccess> xSlides (mxSlideShowController, UNO_QUERY);
376cdf0e10cSrcweir mxPreviewCache->setDocumentSlides(xSlides, rxController->getModel());
377cdf0e10cSrcweir mxPreviewCache->addPreviewCreationNotifyListener(this);
378cdf0e10cSrcweir if (xSlides.is())
379cdf0e10cSrcweir {
380cdf0e10cSrcweir mpLayout->mnSlideCount = xSlides->getCount();
381cdf0e10cSrcweir }
382cdf0e10cSrcweir
383cdf0e10cSrcweir // Create the mouse over manager.
384cdf0e10cSrcweir mpMouseOverManager.reset(new MouseOverManager(
385cdf0e10cSrcweir Reference<container::XIndexAccess>(mxSlideShowController, UNO_QUERY),
386cdf0e10cSrcweir mpPresenterController->GetTheme(),
387cdf0e10cSrcweir mxWindow,
388cdf0e10cSrcweir mpPresenterController->GetPaintManager()));
389cdf0e10cSrcweir
390cdf0e10cSrcweir // Listen for changes of the current slide.
391cdf0e10cSrcweir Reference<beans::XPropertySet> xControllerProperties (rxController, UNO_QUERY_THROW);
392cdf0e10cSrcweir xControllerProperties->addPropertyChangeListener(
393cdf0e10cSrcweir OUString::createFromAscii("CurrentPage"),
394cdf0e10cSrcweir this);
395cdf0e10cSrcweir
396cdf0e10cSrcweir // Move the current slide in the center of the window.
397cdf0e10cSrcweir const awt::Rectangle aCurrentSlideBBox (mpLayout->GetBoundingBox(mnCurrentSlideIndex));
398cdf0e10cSrcweir const awt::Rectangle aWindowBox (mxWindow->getPosSize());
399cdf0e10cSrcweir SetHorizontalOffset(aCurrentSlideBBox.X - aWindowBox.Width/2.0);
400cdf0e10cSrcweir }
401cdf0e10cSrcweir catch (RuntimeException&)
402cdf0e10cSrcweir {
403cdf0e10cSrcweir disposing();
404cdf0e10cSrcweir throw;
405cdf0e10cSrcweir }
406cdf0e10cSrcweir }
407cdf0e10cSrcweir
408cdf0e10cSrcweir
409cdf0e10cSrcweir
410cdf0e10cSrcweir
~PresenterSlideSorter(void)411cdf0e10cSrcweir PresenterSlideSorter::~PresenterSlideSorter (void)
412cdf0e10cSrcweir {
413cdf0e10cSrcweir }
414cdf0e10cSrcweir
415cdf0e10cSrcweir
416cdf0e10cSrcweir
417cdf0e10cSrcweir
disposing(void)418cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::disposing (void)
419cdf0e10cSrcweir {
420cdf0e10cSrcweir mxComponentContext = NULL;
421cdf0e10cSrcweir mxViewId = NULL;
422cdf0e10cSrcweir mxPane = NULL;
423cdf0e10cSrcweir
424cdf0e10cSrcweir if (mpVerticalScrollBar.is())
425cdf0e10cSrcweir {
426cdf0e10cSrcweir Reference<lang::XComponent> xComponent (
427cdf0e10cSrcweir static_cast<XWeak*>(mpVerticalScrollBar.get()), UNO_QUERY);
428cdf0e10cSrcweir mpVerticalScrollBar = NULL;
429cdf0e10cSrcweir if (xComponent.is())
430cdf0e10cSrcweir xComponent->dispose();
431cdf0e10cSrcweir }
432cdf0e10cSrcweir if (mpHorizontalScrollBar.is())
433cdf0e10cSrcweir {
434cdf0e10cSrcweir Reference<lang::XComponent> xComponent (
435cdf0e10cSrcweir static_cast<XWeak*>(mpHorizontalScrollBar.get()), UNO_QUERY);
436cdf0e10cSrcweir mpHorizontalScrollBar = NULL;
437cdf0e10cSrcweir if (xComponent.is())
438cdf0e10cSrcweir xComponent->dispose();
439cdf0e10cSrcweir }
440cdf0e10cSrcweir if (mpCloseButton.is())
441cdf0e10cSrcweir {
442cdf0e10cSrcweir Reference<lang::XComponent> xComponent (
443cdf0e10cSrcweir static_cast<XWeak*>(mpCloseButton.get()), UNO_QUERY);
444cdf0e10cSrcweir mpCloseButton = NULL;
445cdf0e10cSrcweir if (xComponent.is())
446cdf0e10cSrcweir xComponent->dispose();
447cdf0e10cSrcweir }
448cdf0e10cSrcweir
449cdf0e10cSrcweir if (mxCanvas.is())
450cdf0e10cSrcweir {
451cdf0e10cSrcweir Reference<lang::XComponent> xComponent (mxCanvas, UNO_QUERY);
452cdf0e10cSrcweir if (xComponent.is())
453cdf0e10cSrcweir xComponent->removeEventListener(static_cast<awt::XWindowListener*>(this));
454cdf0e10cSrcweir mxCanvas = NULL;
455cdf0e10cSrcweir }
456cdf0e10cSrcweir mpPresenterController = NULL;
457cdf0e10cSrcweir mxSlideShowController = NULL;
458cdf0e10cSrcweir mpLayout.reset();
459cdf0e10cSrcweir mpMouseOverManager.reset();
460cdf0e10cSrcweir
461cdf0e10cSrcweir if (mxPreviewCache.is())
462cdf0e10cSrcweir {
463cdf0e10cSrcweir mxPreviewCache->removePreviewCreationNotifyListener(this);
464cdf0e10cSrcweir
465cdf0e10cSrcweir Reference<XComponent> xComponent (mxPreviewCache, UNO_QUERY);
466cdf0e10cSrcweir mxPreviewCache = NULL;
467cdf0e10cSrcweir if (xComponent.is())
468cdf0e10cSrcweir xComponent->dispose();
469cdf0e10cSrcweir }
470cdf0e10cSrcweir
471cdf0e10cSrcweir if (mxWindow.is())
472cdf0e10cSrcweir {
473cdf0e10cSrcweir mxWindow->removeWindowListener(this);
474cdf0e10cSrcweir mxWindow->removePaintListener(this);
475cdf0e10cSrcweir mxWindow->removeMouseListener(this);
476cdf0e10cSrcweir mxWindow->removeMouseMotionListener(this);
477cdf0e10cSrcweir }
478cdf0e10cSrcweir }
479cdf0e10cSrcweir
480cdf0e10cSrcweir
481cdf0e10cSrcweir
482cdf0e10cSrcweir
SetActiveState(const bool bIsActive)483cdf0e10cSrcweir void PresenterSlideSorter::SetActiveState (const bool bIsActive)
484cdf0e10cSrcweir {
485cdf0e10cSrcweir (void)bIsActive;
486cdf0e10cSrcweir }
487cdf0e10cSrcweir
488cdf0e10cSrcweir
489cdf0e10cSrcweir
490cdf0e10cSrcweir
491cdf0e10cSrcweir //----- lang::XEventListener --------------------------------------------------
492cdf0e10cSrcweir
disposing(const lang::EventObject & rEventObject)493cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::disposing (const lang::EventObject& rEventObject)
494cdf0e10cSrcweir throw (RuntimeException)
495cdf0e10cSrcweir {
496cdf0e10cSrcweir if (rEventObject.Source == mxWindow)
497cdf0e10cSrcweir {
498cdf0e10cSrcweir mxWindow = NULL;
499cdf0e10cSrcweir dispose();
500cdf0e10cSrcweir }
501cdf0e10cSrcweir else if (rEventObject.Source == mxPreviewCache)
502cdf0e10cSrcweir {
503cdf0e10cSrcweir mxPreviewCache = NULL;
504cdf0e10cSrcweir dispose();
505cdf0e10cSrcweir }
506cdf0e10cSrcweir else if (rEventObject.Source == mxCanvas)
507cdf0e10cSrcweir {
508cdf0e10cSrcweir mxCanvas = NULL;
509cdf0e10cSrcweir if (mpHorizontalScrollBar.is())
510cdf0e10cSrcweir mpHorizontalScrollBar->SetCanvas(NULL);
511cdf0e10cSrcweir mbIsLayoutPending = true;
512cdf0e10cSrcweir mbIsPaintPending = true;
513cdf0e10cSrcweir
514cdf0e10cSrcweir mpPresenterController->GetPaintManager()->Invalidate(mxWindow);
515cdf0e10cSrcweir }
516cdf0e10cSrcweir }
517cdf0e10cSrcweir
518cdf0e10cSrcweir
519cdf0e10cSrcweir
520cdf0e10cSrcweir
521cdf0e10cSrcweir //----- XWindowListener -------------------------------------------------------
522cdf0e10cSrcweir
windowResized(const awt::WindowEvent & rEvent)523cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::windowResized (const awt::WindowEvent& rEvent)
524cdf0e10cSrcweir throw (uno::RuntimeException)
525cdf0e10cSrcweir {
526cdf0e10cSrcweir (void)rEvent;
527cdf0e10cSrcweir ThrowIfDisposed();
528cdf0e10cSrcweir mbIsLayoutPending = true;
529cdf0e10cSrcweir mpPresenterController->GetPaintManager()->Invalidate(mxWindow);
530cdf0e10cSrcweir }
531cdf0e10cSrcweir
532cdf0e10cSrcweir
533cdf0e10cSrcweir
534cdf0e10cSrcweir
windowMoved(const awt::WindowEvent & rEvent)535cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::windowMoved (const awt::WindowEvent& rEvent)
536cdf0e10cSrcweir throw (uno::RuntimeException)
537cdf0e10cSrcweir {
538cdf0e10cSrcweir (void)rEvent;
539cdf0e10cSrcweir ThrowIfDisposed();
540cdf0e10cSrcweir }
541cdf0e10cSrcweir
542cdf0e10cSrcweir
543cdf0e10cSrcweir
544cdf0e10cSrcweir
windowShown(const lang::EventObject & rEvent)545cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::windowShown (const lang::EventObject& rEvent)
546cdf0e10cSrcweir throw (uno::RuntimeException)
547cdf0e10cSrcweir {
548cdf0e10cSrcweir (void)rEvent;
549cdf0e10cSrcweir ThrowIfDisposed();
550cdf0e10cSrcweir mbIsLayoutPending = true;
551cdf0e10cSrcweir mpPresenterController->GetPaintManager()->Invalidate(mxWindow);
552cdf0e10cSrcweir }
553cdf0e10cSrcweir
554cdf0e10cSrcweir
555cdf0e10cSrcweir
556cdf0e10cSrcweir
windowHidden(const lang::EventObject & rEvent)557cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::windowHidden (const lang::EventObject& rEvent)
558cdf0e10cSrcweir throw (uno::RuntimeException)
559cdf0e10cSrcweir {
560cdf0e10cSrcweir (void)rEvent;
561cdf0e10cSrcweir ThrowIfDisposed();
562cdf0e10cSrcweir }
563cdf0e10cSrcweir
564cdf0e10cSrcweir
565cdf0e10cSrcweir
566cdf0e10cSrcweir
567cdf0e10cSrcweir //----- XPaintListener --------------------------------------------------------
568cdf0e10cSrcweir
windowPaint(const css::awt::PaintEvent & rEvent)569cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::windowPaint (const css::awt::PaintEvent& rEvent)
570cdf0e10cSrcweir throw (RuntimeException)
571cdf0e10cSrcweir {
572cdf0e10cSrcweir (void)rEvent;
573cdf0e10cSrcweir
574cdf0e10cSrcweir // Deactivated views must not be painted.
575cdf0e10cSrcweir if ( ! mbIsPresenterViewActive)
576cdf0e10cSrcweir return;
577cdf0e10cSrcweir
578cdf0e10cSrcweir Paint(rEvent.UpdateRect);
579cdf0e10cSrcweir
580cdf0e10cSrcweir Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
581cdf0e10cSrcweir if (xSpriteCanvas.is())
582cdf0e10cSrcweir xSpriteCanvas->updateScreen(sal_False);
583cdf0e10cSrcweir }
584cdf0e10cSrcweir
585cdf0e10cSrcweir
586cdf0e10cSrcweir
587cdf0e10cSrcweir
588cdf0e10cSrcweir //----- XMouseListener --------------------------------------------------------
589cdf0e10cSrcweir
mousePressed(const css::awt::MouseEvent & rEvent)590cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::mousePressed (const css::awt::MouseEvent& rEvent)
591cdf0e10cSrcweir throw(css::uno::RuntimeException)
592cdf0e10cSrcweir {
593cdf0e10cSrcweir const geometry::RealPoint2D aPosition (rEvent.X, rEvent.Y);
594cdf0e10cSrcweir mnSlideIndexMousePressed = mpLayout->GetSlideIndexForPosition(aPosition);
595cdf0e10cSrcweir }
596cdf0e10cSrcweir
597cdf0e10cSrcweir
598cdf0e10cSrcweir
599cdf0e10cSrcweir
mouseReleased(const css::awt::MouseEvent & rEvent)600cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::mouseReleased (const css::awt::MouseEvent& rEvent)
601cdf0e10cSrcweir throw(css::uno::RuntimeException)
602cdf0e10cSrcweir {
603cdf0e10cSrcweir const geometry::RealPoint2D aPosition (rEvent.X, rEvent.Y);
604cdf0e10cSrcweir const sal_Int32 nSlideIndex (mpLayout->GetSlideIndexForPosition(aPosition));
605cdf0e10cSrcweir
606cdf0e10cSrcweir if (nSlideIndex == mnSlideIndexMousePressed && mnSlideIndexMousePressed >= 0)
607cdf0e10cSrcweir {
608cdf0e10cSrcweir switch (rEvent.ClickCount)
609cdf0e10cSrcweir {
610cdf0e10cSrcweir case 1:
611cdf0e10cSrcweir default:
612cdf0e10cSrcweir GotoSlide(nSlideIndex);
613cdf0e10cSrcweir break;
614cdf0e10cSrcweir
615cdf0e10cSrcweir case 2:
616cdf0e10cSrcweir OSL_ASSERT(mpPresenterController.get()!=NULL);
617cdf0e10cSrcweir OSL_ASSERT(mpPresenterController->GetWindowManager().get()!=NULL);
618cdf0e10cSrcweir mpPresenterController->GetWindowManager()->SetSlideSorterState(false);
619cdf0e10cSrcweir GotoSlide(nSlideIndex);
620cdf0e10cSrcweir break;
621cdf0e10cSrcweir }
622cdf0e10cSrcweir }
623cdf0e10cSrcweir }
624cdf0e10cSrcweir
625cdf0e10cSrcweir
626cdf0e10cSrcweir
627cdf0e10cSrcweir
mouseEntered(const css::awt::MouseEvent & rEvent)628cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::mouseEntered (const css::awt::MouseEvent& rEvent)
629cdf0e10cSrcweir throw(css::uno::RuntimeException)
630cdf0e10cSrcweir {
631cdf0e10cSrcweir (void)rEvent;
632cdf0e10cSrcweir }
633cdf0e10cSrcweir
634cdf0e10cSrcweir
635cdf0e10cSrcweir
636cdf0e10cSrcweir
mouseExited(const css::awt::MouseEvent & rEvent)637cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::mouseExited (const css::awt::MouseEvent& rEvent)
638cdf0e10cSrcweir throw(css::uno::RuntimeException)
639cdf0e10cSrcweir {
640cdf0e10cSrcweir (void)rEvent;
641cdf0e10cSrcweir mnSlideIndexMousePressed = -1;
642cdf0e10cSrcweir if (mpMouseOverManager.get() != NULL)
643cdf0e10cSrcweir mpMouseOverManager->SetSlide(mnSlideIndexMousePressed, awt::Rectangle(0,0,0,0));
644cdf0e10cSrcweir }
645cdf0e10cSrcweir
646cdf0e10cSrcweir
647cdf0e10cSrcweir
648cdf0e10cSrcweir
649cdf0e10cSrcweir //----- XMouseMotionListener --------------------------------------------------
650cdf0e10cSrcweir
mouseMoved(const css::awt::MouseEvent & rEvent)651cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::mouseMoved (const css::awt::MouseEvent& rEvent)
652cdf0e10cSrcweir throw (css::uno::RuntimeException)
653cdf0e10cSrcweir {
654cdf0e10cSrcweir if (mpMouseOverManager.get() != NULL)
655cdf0e10cSrcweir {
656cdf0e10cSrcweir const geometry::RealPoint2D aPosition (rEvent.X, rEvent.Y);
657cdf0e10cSrcweir sal_Int32 nSlideIndex (mpLayout->GetSlideIndexForPosition(aPosition));
658cdf0e10cSrcweir
659cdf0e10cSrcweir if (nSlideIndex < 0)
660cdf0e10cSrcweir mnSlideIndexMousePressed = -1;
661cdf0e10cSrcweir
662cdf0e10cSrcweir if (nSlideIndex < 0)
663cdf0e10cSrcweir {
664cdf0e10cSrcweir mpMouseOverManager->SetSlide(nSlideIndex, awt::Rectangle(0,0,0,0));
665cdf0e10cSrcweir }
666cdf0e10cSrcweir else
667cdf0e10cSrcweir {
668cdf0e10cSrcweir mpMouseOverManager->SetSlide(
669cdf0e10cSrcweir nSlideIndex,
670cdf0e10cSrcweir mpLayout->GetBoundingBox(nSlideIndex));
671cdf0e10cSrcweir }
672cdf0e10cSrcweir }
673cdf0e10cSrcweir }
674cdf0e10cSrcweir
675cdf0e10cSrcweir
676cdf0e10cSrcweir
677cdf0e10cSrcweir
mouseDragged(const css::awt::MouseEvent & rEvent)678cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::mouseDragged (const css::awt::MouseEvent& rEvent)
679cdf0e10cSrcweir throw (css::uno::RuntimeException)
680cdf0e10cSrcweir {
681cdf0e10cSrcweir (void)rEvent;
682cdf0e10cSrcweir }
683cdf0e10cSrcweir
684cdf0e10cSrcweir
685cdf0e10cSrcweir
686cdf0e10cSrcweir
687cdf0e10cSrcweir //----- XResourceId -----------------------------------------------------------
688cdf0e10cSrcweir
getResourceId(void)689cdf0e10cSrcweir Reference<XResourceId> SAL_CALL PresenterSlideSorter::getResourceId (void)
690cdf0e10cSrcweir throw (RuntimeException)
691cdf0e10cSrcweir {
692cdf0e10cSrcweir ThrowIfDisposed();
693cdf0e10cSrcweir return mxViewId;
694cdf0e10cSrcweir }
695cdf0e10cSrcweir
696cdf0e10cSrcweir
697cdf0e10cSrcweir
698cdf0e10cSrcweir
isAnchorOnly(void)699cdf0e10cSrcweir sal_Bool SAL_CALL PresenterSlideSorter::isAnchorOnly (void)
700cdf0e10cSrcweir throw (RuntimeException)
701cdf0e10cSrcweir {
702cdf0e10cSrcweir return false;
703cdf0e10cSrcweir }
704cdf0e10cSrcweir
705cdf0e10cSrcweir
706cdf0e10cSrcweir
707cdf0e10cSrcweir
708cdf0e10cSrcweir //----- XPropertyChangeListener -----------------------------------------------
709cdf0e10cSrcweir
propertyChange(const css::beans::PropertyChangeEvent & rEvent)710cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::propertyChange (
711cdf0e10cSrcweir const css::beans::PropertyChangeEvent& rEvent)
712cdf0e10cSrcweir throw(css::uno::RuntimeException)
713cdf0e10cSrcweir {
714cdf0e10cSrcweir (void)rEvent;
715cdf0e10cSrcweir }
716cdf0e10cSrcweir
717cdf0e10cSrcweir
718cdf0e10cSrcweir
719cdf0e10cSrcweir
720cdf0e10cSrcweir //----- XSlidePreviewCacheListener --------------------------------------------
721cdf0e10cSrcweir
notifyPreviewCreation(sal_Int32 nSlideIndex)722cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::notifyPreviewCreation (
723cdf0e10cSrcweir sal_Int32 nSlideIndex)
724cdf0e10cSrcweir throw(css::uno::RuntimeException)
725cdf0e10cSrcweir {
726cdf0e10cSrcweir OSL_ASSERT(mpLayout.get()!=NULL);
727cdf0e10cSrcweir
728cdf0e10cSrcweir awt::Rectangle aBBox (mpLayout->GetBoundingBox(nSlideIndex));
729cdf0e10cSrcweir mpPresenterController->GetPaintManager()->Invalidate(mxWindow, aBBox, true);
730cdf0e10cSrcweir }
731cdf0e10cSrcweir
732cdf0e10cSrcweir
733cdf0e10cSrcweir
734cdf0e10cSrcweir
735cdf0e10cSrcweir //----- XDrawView -------------------------------------------------------------
736cdf0e10cSrcweir
setCurrentPage(const Reference<drawing::XDrawPage> & rxSlide)737cdf0e10cSrcweir void SAL_CALL PresenterSlideSorter::setCurrentPage (const Reference<drawing::XDrawPage>& rxSlide)
738cdf0e10cSrcweir throw (RuntimeException)
739cdf0e10cSrcweir {
740cdf0e10cSrcweir (void)rxSlide;
741cdf0e10cSrcweir
742cdf0e10cSrcweir ThrowIfDisposed();
743cdf0e10cSrcweir ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
744cdf0e10cSrcweir
745cdf0e10cSrcweir if (mxSlideShowController.is())
746cdf0e10cSrcweir {
747cdf0e10cSrcweir const sal_Int32 nNewCurrentSlideIndex (mxSlideShowController->getCurrentSlideIndex());
748cdf0e10cSrcweir if (nNewCurrentSlideIndex != mnCurrentSlideIndex)
749cdf0e10cSrcweir {
750cdf0e10cSrcweir mnCurrentSlideIndex = nNewCurrentSlideIndex;
751cdf0e10cSrcweir
752cdf0e10cSrcweir // Request a repaint of the previous current slide to hide its
753cdf0e10cSrcweir // current slide indicator.
754cdf0e10cSrcweir mpPresenterController->GetPaintManager()->Invalidate(
755cdf0e10cSrcweir mxWindow,
756cdf0e10cSrcweir maCurrentSlideFrameBoundingBox);
757cdf0e10cSrcweir
758cdf0e10cSrcweir // Request a repaint of the new current slide to show its
759cdf0e10cSrcweir // current slide indicator.
760cdf0e10cSrcweir maCurrentSlideFrameBoundingBox = mpCurrentSlideFrameRenderer->GetBoundingBox(
761cdf0e10cSrcweir mpLayout->GetBoundingBox(mnCurrentSlideIndex));
762cdf0e10cSrcweir mpPresenterController->GetPaintManager()->Invalidate(
763cdf0e10cSrcweir mxWindow,
764cdf0e10cSrcweir maCurrentSlideFrameBoundingBox);
765cdf0e10cSrcweir }
766cdf0e10cSrcweir }
767cdf0e10cSrcweir }
768cdf0e10cSrcweir
769cdf0e10cSrcweir
770cdf0e10cSrcweir
771cdf0e10cSrcweir
getCurrentPage(void)772cdf0e10cSrcweir Reference<drawing::XDrawPage> SAL_CALL PresenterSlideSorter::getCurrentPage (void)
773cdf0e10cSrcweir throw (RuntimeException)
774cdf0e10cSrcweir {
775cdf0e10cSrcweir ThrowIfDisposed();
776cdf0e10cSrcweir return NULL;
777cdf0e10cSrcweir }
778cdf0e10cSrcweir
779cdf0e10cSrcweir
780cdf0e10cSrcweir
781cdf0e10cSrcweir
782cdf0e10cSrcweir //-----------------------------------------------------------------------------
783cdf0e10cSrcweir
UpdateLayout(void)784cdf0e10cSrcweir void PresenterSlideSorter::UpdateLayout (void)
785cdf0e10cSrcweir {
786cdf0e10cSrcweir if ( ! mxWindow.is())
787cdf0e10cSrcweir return;
788cdf0e10cSrcweir
789cdf0e10cSrcweir mbIsLayoutPending = false;
790cdf0e10cSrcweir mbIsPaintPending = true;
791cdf0e10cSrcweir
792cdf0e10cSrcweir const awt::Rectangle aWindowBox (mxWindow->getPosSize());
793cdf0e10cSrcweir awt::Rectangle aCenterBox (aWindowBox);
794cdf0e10cSrcweir sal_Int32 nLeftBorderWidth (aWindowBox.X);
795cdf0e10cSrcweir
796cdf0e10cSrcweir // Get border width.
797cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor pPane (
798cdf0e10cSrcweir mpPresenterController->GetPaneContainer()->FindViewURL(
799cdf0e10cSrcweir mxViewId->getResourceURL()));
800cdf0e10cSrcweir do
801cdf0e10cSrcweir {
802cdf0e10cSrcweir if (pPane.get() == NULL)
803cdf0e10cSrcweir break;
804cdf0e10cSrcweir if ( ! pPane->mxPane.is())
805cdf0e10cSrcweir break;
806cdf0e10cSrcweir
807cdf0e10cSrcweir Reference<drawing::framework::XPaneBorderPainter> xBorderPainter (
808cdf0e10cSrcweir pPane->mxPane->GetPaneBorderPainter());
809cdf0e10cSrcweir if ( ! xBorderPainter.is())
810cdf0e10cSrcweir break;
811cdf0e10cSrcweir aCenterBox = xBorderPainter->addBorder (
812cdf0e10cSrcweir mxViewId->getAnchor()->getResourceURL(),
813cdf0e10cSrcweir awt::Rectangle(0, 0, aWindowBox.Width, aWindowBox.Height),
814cdf0e10cSrcweir drawing::framework::BorderType_INNER_BORDER);
815cdf0e10cSrcweir }
816cdf0e10cSrcweir while(false);
817cdf0e10cSrcweir
818cdf0e10cSrcweir // Place vertical separator.
819cdf0e10cSrcweir mnSeparatorY = aWindowBox.Height - mpCloseButton->GetSize().Height - gnVerticalButtonPadding;
820cdf0e10cSrcweir
821cdf0e10cSrcweir PlaceCloseButton(pPane, aWindowBox, nLeftBorderWidth);
822cdf0e10cSrcweir
823cdf0e10cSrcweir geometry::RealRectangle2D aUpperBox(
824cdf0e10cSrcweir gnHorizontalBorder,
825cdf0e10cSrcweir gnVerticalBorder,
826cdf0e10cSrcweir aWindowBox.Width - 2*gnHorizontalBorder,
827cdf0e10cSrcweir mnSeparatorY - gnVerticalGap);
828cdf0e10cSrcweir
829cdf0e10cSrcweir // Determine whether the scroll bar has to be displayed.
830cdf0e10cSrcweir aUpperBox = PlaceScrollBars(aUpperBox);
831cdf0e10cSrcweir
832cdf0e10cSrcweir mpLayout->Update(aUpperBox, GetSlideAspectRatio());
833cdf0e10cSrcweir mpLayout->SetupVisibleArea();
834cdf0e10cSrcweir mpLayout->UpdateScrollBars();
835cdf0e10cSrcweir
836cdf0e10cSrcweir // Tell the preview cache about some of the values.
837cdf0e10cSrcweir mxPreviewCache->setPreviewSize(mpLayout->maPreviewSize);
838cdf0e10cSrcweir mxPreviewCache->setVisibleRange(
839cdf0e10cSrcweir mpLayout->GetFirstVisibleSlideIndex(),
840cdf0e10cSrcweir mpLayout->GetLastVisibleSlideIndex());
841cdf0e10cSrcweir
842cdf0e10cSrcweir // Clear the frame polygon so that it is re-created on the next paint.
843cdf0e10cSrcweir mxPreviewFrame = NULL;
844cdf0e10cSrcweir }
845cdf0e10cSrcweir
846cdf0e10cSrcweir
847cdf0e10cSrcweir
848cdf0e10cSrcweir
PlaceScrollBars(const geometry::RealRectangle2D & rUpperBox)849cdf0e10cSrcweir geometry::RealRectangle2D PresenterSlideSorter::PlaceScrollBars (
850cdf0e10cSrcweir const geometry::RealRectangle2D& rUpperBox)
851cdf0e10cSrcweir {
852cdf0e10cSrcweir mpLayout->Update(rUpperBox, GetSlideAspectRatio());
853cdf0e10cSrcweir bool bIsScrollBarNeeded (false);
854cdf0e10cSrcweir Reference<container::XIndexAccess> xSlides (mxSlideShowController, UNO_QUERY_THROW);
855cdf0e10cSrcweir if (xSlides.is())
856cdf0e10cSrcweir bIsScrollBarNeeded = mpLayout->IsScrollBarNeeded(xSlides->getCount());
857cdf0e10cSrcweir
858cdf0e10cSrcweir if (mpLayout->GetOrientation() == Layout::Vertical)
859cdf0e10cSrcweir {
860cdf0e10cSrcweir if (mpVerticalScrollBar.get() != NULL)
861cdf0e10cSrcweir {
862cdf0e10cSrcweir if (bIsScrollBarNeeded)
863cdf0e10cSrcweir {
864cdf0e10cSrcweir // Place vertical scroll bar at right border.
865cdf0e10cSrcweir mpVerticalScrollBar->SetPosSize(geometry::RealRectangle2D(
866cdf0e10cSrcweir rUpperBox.X2 - mpVerticalScrollBar->GetSize(),
867cdf0e10cSrcweir rUpperBox.Y1,
868cdf0e10cSrcweir rUpperBox.X2,
869cdf0e10cSrcweir rUpperBox.Y2));
870cdf0e10cSrcweir mpVerticalScrollBar->SetVisible(true);
871cdf0e10cSrcweir
872cdf0e10cSrcweir // Reduce area covered by the scroll bar from the available
873cdf0e10cSrcweir // space.
874cdf0e10cSrcweir return geometry::RealRectangle2D(
875cdf0e10cSrcweir rUpperBox.X1,
876cdf0e10cSrcweir rUpperBox.Y1,
877cdf0e10cSrcweir rUpperBox.X2 - mpVerticalScrollBar->GetSize() - gnHorizontalGap,
878cdf0e10cSrcweir rUpperBox.Y2);
879cdf0e10cSrcweir }
880cdf0e10cSrcweir else
881cdf0e10cSrcweir mpVerticalScrollBar->SetVisible(false);
882cdf0e10cSrcweir }
883cdf0e10cSrcweir }
884cdf0e10cSrcweir else
885cdf0e10cSrcweir {
886cdf0e10cSrcweir if (mpHorizontalScrollBar.get() != NULL)
887cdf0e10cSrcweir {
888cdf0e10cSrcweir if (bIsScrollBarNeeded)
889cdf0e10cSrcweir {
890cdf0e10cSrcweir // Place horixontal scroll bar at the bottom.
891cdf0e10cSrcweir mpHorizontalScrollBar->SetPosSize(geometry::RealRectangle2D(
892cdf0e10cSrcweir rUpperBox.X1,
893cdf0e10cSrcweir rUpperBox.Y2 - mpHorizontalScrollBar->GetSize(),
894cdf0e10cSrcweir rUpperBox.X2,
895cdf0e10cSrcweir rUpperBox.Y2));
896cdf0e10cSrcweir mpHorizontalScrollBar->SetVisible(true);
897cdf0e10cSrcweir
898cdf0e10cSrcweir // Reduce area covered by the scroll bar from the available
899cdf0e10cSrcweir // space.
900cdf0e10cSrcweir return geometry::RealRectangle2D(
901cdf0e10cSrcweir rUpperBox.X1,
902cdf0e10cSrcweir rUpperBox.Y1,
903cdf0e10cSrcweir rUpperBox.X2,
904cdf0e10cSrcweir rUpperBox.Y2 - mpHorizontalScrollBar->GetSize() - gnVerticalGap);
905cdf0e10cSrcweir }
906cdf0e10cSrcweir else
907cdf0e10cSrcweir mpHorizontalScrollBar->SetVisible(false);
908cdf0e10cSrcweir }
909cdf0e10cSrcweir }
910cdf0e10cSrcweir
911cdf0e10cSrcweir return rUpperBox;
912cdf0e10cSrcweir }
913cdf0e10cSrcweir
914cdf0e10cSrcweir
915cdf0e10cSrcweir
916cdf0e10cSrcweir
PlaceCloseButton(const PresenterPaneContainer::SharedPaneDescriptor & rpPane,const awt::Rectangle & rCenterBox,const sal_Int32 nLeftBorderWidth)917cdf0e10cSrcweir void PresenterSlideSorter::PlaceCloseButton (
918cdf0e10cSrcweir const PresenterPaneContainer::SharedPaneDescriptor& rpPane,
919cdf0e10cSrcweir const awt::Rectangle& rCenterBox,
920cdf0e10cSrcweir const sal_Int32 nLeftBorderWidth)
921cdf0e10cSrcweir {
922cdf0e10cSrcweir // Place button. When the callout is near the center then the button is
923cdf0e10cSrcweir // centered over the callout. Otherwise it is centered with respect to
924cdf0e10cSrcweir // the whole window.
925cdf0e10cSrcweir sal_Int32 nCloseButtonCenter (rCenterBox.Width/2);
926cdf0e10cSrcweir if (rpPane.get() != NULL && rpPane->mxPane.is())
927cdf0e10cSrcweir {
928cdf0e10cSrcweir const sal_Int32 nCalloutCenter (rpPane->mxPane->GetCalloutAnchor().X - nLeftBorderWidth);
929cdf0e10cSrcweir const sal_Int32 nDistanceFromWindowCenter (abs(nCalloutCenter - rCenterBox.Width/2));
930cdf0e10cSrcweir const sal_Int32 nButtonWidth (mpCloseButton->GetSize().Width);
931cdf0e10cSrcweir const static sal_Int32 nMaxDistanceForCalloutCentering (nButtonWidth * 2);
932cdf0e10cSrcweir if (nDistanceFromWindowCenter < nMaxDistanceForCalloutCentering)
933cdf0e10cSrcweir {
934cdf0e10cSrcweir if (nCalloutCenter < nButtonWidth/2)
935cdf0e10cSrcweir nCloseButtonCenter = nButtonWidth/2;
936cdf0e10cSrcweir else if (nCalloutCenter > rCenterBox.Width-nButtonWidth/2)
937cdf0e10cSrcweir nCloseButtonCenter = rCenterBox.Width-nButtonWidth/2;
938cdf0e10cSrcweir else
939cdf0e10cSrcweir nCloseButtonCenter = nCalloutCenter;
940cdf0e10cSrcweir }
941cdf0e10cSrcweir }
942cdf0e10cSrcweir mpCloseButton->SetCenter(geometry::RealPoint2D(
943cdf0e10cSrcweir nCloseButtonCenter,
944cdf0e10cSrcweir rCenterBox.Height - mpCloseButton->GetSize().Height/ 2));
945cdf0e10cSrcweir }
946cdf0e10cSrcweir
947cdf0e10cSrcweir
948cdf0e10cSrcweir
949cdf0e10cSrcweir
ClearBackground(const Reference<rendering::XCanvas> & rxCanvas,const awt::Rectangle & rUpdateBox)950cdf0e10cSrcweir void PresenterSlideSorter::ClearBackground (
951cdf0e10cSrcweir const Reference<rendering::XCanvas>& rxCanvas,
952cdf0e10cSrcweir const awt::Rectangle& rUpdateBox)
953cdf0e10cSrcweir {
954cdf0e10cSrcweir OSL_ASSERT(rxCanvas.is());
955cdf0e10cSrcweir
956cdf0e10cSrcweir const awt::Rectangle aWindowBox (mxWindow->getPosSize());
957cdf0e10cSrcweir mpPresenterController->GetCanvasHelper()->Paint(
958cdf0e10cSrcweir mpPresenterController->GetViewBackground(mxViewId->getResourceURL()),
959cdf0e10cSrcweir rxCanvas,
960cdf0e10cSrcweir rUpdateBox,
961cdf0e10cSrcweir awt::Rectangle(0,0,aWindowBox.Width,aWindowBox.Height),
962cdf0e10cSrcweir awt::Rectangle());
963cdf0e10cSrcweir }
964cdf0e10cSrcweir
965cdf0e10cSrcweir
966cdf0e10cSrcweir
967cdf0e10cSrcweir
GetSlideAspectRatio(void) const968cdf0e10cSrcweir double PresenterSlideSorter::GetSlideAspectRatio (void) const
969cdf0e10cSrcweir {
970cdf0e10cSrcweir double nSlideAspectRatio (28.0/21.0);
971cdf0e10cSrcweir
972cdf0e10cSrcweir try
973cdf0e10cSrcweir {
974cdf0e10cSrcweir Reference<container::XIndexAccess> xSlides(mxSlideShowController, UNO_QUERY_THROW);
975cdf0e10cSrcweir if (mxSlideShowController.is() && xSlides->getCount()>0)
976cdf0e10cSrcweir {
977cdf0e10cSrcweir Reference<beans::XPropertySet> xProperties(xSlides->getByIndex(0),UNO_QUERY_THROW);
978cdf0e10cSrcweir sal_Int32 nWidth (28000);
979cdf0e10cSrcweir sal_Int32 nHeight (21000);
980cdf0e10cSrcweir if ((xProperties->getPropertyValue(OUString::createFromAscii("Width")) >>= nWidth)
981cdf0e10cSrcweir && (xProperties->getPropertyValue(OUString::createFromAscii("Height")) >>= nHeight)
982cdf0e10cSrcweir && nHeight > 0)
983cdf0e10cSrcweir {
984cdf0e10cSrcweir nSlideAspectRatio = double(nWidth) / double(nHeight);
985cdf0e10cSrcweir }
986cdf0e10cSrcweir }
987cdf0e10cSrcweir }
988cdf0e10cSrcweir catch (RuntimeException&)
989cdf0e10cSrcweir {
990cdf0e10cSrcweir OSL_ASSERT(false);
991cdf0e10cSrcweir }
992cdf0e10cSrcweir
993cdf0e10cSrcweir return nSlideAspectRatio;
994cdf0e10cSrcweir }
995cdf0e10cSrcweir
996cdf0e10cSrcweir
997cdf0e10cSrcweir
998cdf0e10cSrcweir
GetPreview(const sal_Int32 nSlideIndex)999cdf0e10cSrcweir Reference<rendering::XBitmap> PresenterSlideSorter::GetPreview (const sal_Int32 nSlideIndex)
1000cdf0e10cSrcweir {
1001cdf0e10cSrcweir if (nSlideIndex < 0 || nSlideIndex>=mpLayout->mnSlideCount)
1002cdf0e10cSrcweir return NULL;
1003cdf0e10cSrcweir else if (mxPane.is())
1004cdf0e10cSrcweir return mxPreviewCache->getSlidePreview(nSlideIndex, mxPane->getCanvas());
1005cdf0e10cSrcweir else
1006cdf0e10cSrcweir return NULL;
1007cdf0e10cSrcweir }
1008cdf0e10cSrcweir
1009cdf0e10cSrcweir
1010cdf0e10cSrcweir
1011cdf0e10cSrcweir
PaintPreview(const Reference<rendering::XCanvas> & rxCanvas,const css::awt::Rectangle & rUpdateBox,const sal_Int32 nSlideIndex)1012cdf0e10cSrcweir void PresenterSlideSorter::PaintPreview (
1013cdf0e10cSrcweir const Reference<rendering::XCanvas>& rxCanvas,
1014cdf0e10cSrcweir const css::awt::Rectangle& rUpdateBox,
1015cdf0e10cSrcweir const sal_Int32 nSlideIndex)
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir OSL_ASSERT(rxCanvas.is());
1018cdf0e10cSrcweir
1019cdf0e10cSrcweir geometry::IntegerSize2D aSize (mpLayout->maPreviewSize);
1020cdf0e10cSrcweir
1021cdf0e10cSrcweir if (PresenterGeometryHelper::AreRectanglesDisjoint(
1022cdf0e10cSrcweir rUpdateBox,
1023cdf0e10cSrcweir mpLayout->GetBoundingBox(nSlideIndex)))
1024cdf0e10cSrcweir {
1025cdf0e10cSrcweir return;
1026cdf0e10cSrcweir }
1027cdf0e10cSrcweir
1028cdf0e10cSrcweir Reference<rendering::XBitmap> xPreview (GetPreview(nSlideIndex));
1029cdf0e10cSrcweir
1030cdf0e10cSrcweir const geometry::RealPoint2D aTopLeft (
1031cdf0e10cSrcweir mpLayout->GetWindowPosition(
1032cdf0e10cSrcweir mpLayout->GetPoint(nSlideIndex, -1, -1)));
1033cdf0e10cSrcweir
1034cdf0e10cSrcweir // Create clip rectangle as intersection of the current update area and
1035cdf0e10cSrcweir // the bounding box of all previews.
1036cdf0e10cSrcweir geometry::RealRectangle2D aBoundingBox (mpLayout->maBoundingBox);
1037cdf0e10cSrcweir aBoundingBox.Y2 += 1;
1038cdf0e10cSrcweir const geometry::RealRectangle2D aClipBox (
1039cdf0e10cSrcweir PresenterGeometryHelper::Intersection(
1040cdf0e10cSrcweir PresenterGeometryHelper::ConvertRectangle(rUpdateBox),
1041cdf0e10cSrcweir aBoundingBox));
1042cdf0e10cSrcweir Reference<rendering::XPolyPolygon2D> xClip (
1043cdf0e10cSrcweir PresenterGeometryHelper::CreatePolygon(aClipBox, rxCanvas->getDevice()));
1044cdf0e10cSrcweir
1045cdf0e10cSrcweir const rendering::ViewState aViewState (geometry::AffineMatrix2D(1,0,0, 0,1,0), xClip);
1046cdf0e10cSrcweir
1047cdf0e10cSrcweir
1048cdf0e10cSrcweir rendering::RenderState aRenderState (
1049cdf0e10cSrcweir geometry::AffineMatrix2D(
1050cdf0e10cSrcweir 1, 0, aTopLeft.X,
1051cdf0e10cSrcweir 0, 1, aTopLeft.Y),
1052cdf0e10cSrcweir NULL,
1053cdf0e10cSrcweir Sequence<double>(4),
1054cdf0e10cSrcweir rendering::CompositeOperation::SOURCE);
1055cdf0e10cSrcweir
1056cdf0e10cSrcweir
1057cdf0e10cSrcweir // Emphasize the current slide.
1058cdf0e10cSrcweir if (nSlideIndex == mnCurrentSlideIndex)
1059cdf0e10cSrcweir {
1060cdf0e10cSrcweir if (mpCurrentSlideFrameRenderer.get() != NULL)
1061cdf0e10cSrcweir {
1062cdf0e10cSrcweir const awt::Rectangle aSlideBoundingBox(
1063cdf0e10cSrcweir sal::static_int_cast<sal_Int32>(0.5 + aTopLeft.X),
1064cdf0e10cSrcweir sal::static_int_cast<sal_Int32>(0.5 + aTopLeft.Y),
1065cdf0e10cSrcweir aSize.Width,
1066cdf0e10cSrcweir aSize.Height);
1067cdf0e10cSrcweir maCurrentSlideFrameBoundingBox
1068cdf0e10cSrcweir = mpCurrentSlideFrameRenderer->GetBoundingBox(aSlideBoundingBox);
1069cdf0e10cSrcweir mpCurrentSlideFrameRenderer->PaintCurrentSlideFrame (
1070cdf0e10cSrcweir aSlideBoundingBox,
1071cdf0e10cSrcweir mxCanvas,
1072cdf0e10cSrcweir aClipBox);
1073cdf0e10cSrcweir }
1074cdf0e10cSrcweir }
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir // Paint the preview.
1077cdf0e10cSrcweir if (xPreview.is())
1078cdf0e10cSrcweir {
1079cdf0e10cSrcweir aSize = xPreview->getSize();
1080cdf0e10cSrcweir if (aSize.Width > 0 && aSize.Height > 0)
1081cdf0e10cSrcweir {
1082cdf0e10cSrcweir rxCanvas->drawBitmap(xPreview, aViewState, aRenderState);
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir }
1085cdf0e10cSrcweir
1086cdf0e10cSrcweir // Create a polygon that is used to paint a frame around previews. Its
1087cdf0e10cSrcweir // coordinates are chosen in the local coordinate system of a preview.
1088cdf0e10cSrcweir if ( ! mxPreviewFrame.is())
1089cdf0e10cSrcweir mxPreviewFrame = PresenterGeometryHelper::CreatePolygon(
1090cdf0e10cSrcweir awt::Rectangle(-1, -1, aSize.Width+2, aSize.Height+2),
1091cdf0e10cSrcweir rxCanvas->getDevice());
1092cdf0e10cSrcweir
1093cdf0e10cSrcweir // Paint a border around the preview.
1094cdf0e10cSrcweir if (mxPreviewFrame.is())
1095cdf0e10cSrcweir {
1096cdf0e10cSrcweir const geometry::RealRectangle2D aBox (0, 0, aSize.Width, aSize.Height);
1097cdf0e10cSrcweir const util::Color aFrameColor (0x00000000);
1098cdf0e10cSrcweir PresenterCanvasHelper::SetDeviceColor(aRenderState, aFrameColor);
1099cdf0e10cSrcweir rxCanvas->drawPolyPolygon(mxPreviewFrame, aViewState, aRenderState);
1100cdf0e10cSrcweir }
1101cdf0e10cSrcweir
1102cdf0e10cSrcweir // Paint mouse over effect.
1103cdf0e10cSrcweir mpMouseOverManager->Paint(nSlideIndex, mxCanvas, xClip);
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir
1106cdf0e10cSrcweir
1107cdf0e10cSrcweir
1108cdf0e10cSrcweir
Paint(const awt::Rectangle & rUpdateBox)1109cdf0e10cSrcweir void PresenterSlideSorter::Paint (const awt::Rectangle& rUpdateBox)
1110cdf0e10cSrcweir {
1111cdf0e10cSrcweir const bool bCanvasChanged ( ! mxCanvas.is());
1112cdf0e10cSrcweir if ( ! ProvideCanvas())
1113cdf0e10cSrcweir return;
1114cdf0e10cSrcweir
1115cdf0e10cSrcweir if (mpLayout->mnRowCount<=0 || mpLayout->mnColumnCount<=0)
1116cdf0e10cSrcweir {
1117cdf0e10cSrcweir OSL_ASSERT(mpLayout->mnRowCount>0 || mpLayout->mnColumnCount>0);
1118cdf0e10cSrcweir return;
1119cdf0e10cSrcweir }
1120cdf0e10cSrcweir
1121cdf0e10cSrcweir mbIsPaintPending = false;
1122cdf0e10cSrcweir
1123cdf0e10cSrcweir ClearBackground(mxCanvas, rUpdateBox);
1124cdf0e10cSrcweir
1125cdf0e10cSrcweir // Give the canvas to the controls.
1126cdf0e10cSrcweir if (bCanvasChanged)
1127cdf0e10cSrcweir {
1128cdf0e10cSrcweir if (mpHorizontalScrollBar.is())
1129cdf0e10cSrcweir mpHorizontalScrollBar->SetCanvas(mxCanvas);
1130cdf0e10cSrcweir if (mpVerticalScrollBar.is())
1131cdf0e10cSrcweir mpVerticalScrollBar->SetCanvas(mxCanvas);
1132cdf0e10cSrcweir if (mpCloseButton.is())
1133cdf0e10cSrcweir mpCloseButton->SetCanvas(mxCanvas, mxWindow);
1134cdf0e10cSrcweir }
1135cdf0e10cSrcweir
1136cdf0e10cSrcweir // Now that the controls have a canvas we can do the layouting.
1137cdf0e10cSrcweir if (mbIsLayoutPending)
1138cdf0e10cSrcweir UpdateLayout();
1139cdf0e10cSrcweir
1140cdf0e10cSrcweir // Paint the horizontal separator.
1141cdf0e10cSrcweir rendering::RenderState aRenderState (geometry::AffineMatrix2D(1,0,0, 0,1,0),
1142cdf0e10cSrcweir NULL, Sequence<double>(4), rendering::CompositeOperation::SOURCE);
1143cdf0e10cSrcweir PresenterCanvasHelper::SetDeviceColor(aRenderState, maSeparatorColor);
1144cdf0e10cSrcweir mxCanvas->drawLine(
1145cdf0e10cSrcweir geometry::RealPoint2D(0, mnSeparatorY),
1146cdf0e10cSrcweir geometry::RealPoint2D(mxWindow->getPosSize().Width, mnSeparatorY),
1147cdf0e10cSrcweir rendering::ViewState(geometry::AffineMatrix2D(1,0,0, 0,1,0), NULL),
1148cdf0e10cSrcweir aRenderState);
1149cdf0e10cSrcweir
1150cdf0e10cSrcweir // Paint the slides.
1151cdf0e10cSrcweir if ( ! PresenterGeometryHelper::AreRectanglesDisjoint(
1152cdf0e10cSrcweir rUpdateBox,
1153cdf0e10cSrcweir PresenterGeometryHelper::ConvertRectangle(mpLayout->maBoundingBox)))
1154cdf0e10cSrcweir {
1155cdf0e10cSrcweir mpLayout->ForAllVisibleSlides(
1156cdf0e10cSrcweir ::boost::bind(&PresenterSlideSorter::PaintPreview, this, mxCanvas, rUpdateBox, _1));
1157cdf0e10cSrcweir }
1158cdf0e10cSrcweir
1159cdf0e10cSrcweir Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
1160cdf0e10cSrcweir if (xSpriteCanvas.is())
1161cdf0e10cSrcweir xSpriteCanvas->updateScreen(sal_False);
1162cdf0e10cSrcweir }
1163cdf0e10cSrcweir
1164cdf0e10cSrcweir
1165cdf0e10cSrcweir
1166cdf0e10cSrcweir
SetHorizontalOffset(const double nXOffset)1167cdf0e10cSrcweir void PresenterSlideSorter::SetHorizontalOffset (const double nXOffset)
1168cdf0e10cSrcweir {
1169cdf0e10cSrcweir if (mpLayout->SetHorizontalOffset(nXOffset))
1170cdf0e10cSrcweir {
1171cdf0e10cSrcweir mxPreviewCache->setVisibleRange(
1172cdf0e10cSrcweir mpLayout->GetFirstVisibleSlideIndex(),
1173cdf0e10cSrcweir mpLayout->GetLastVisibleSlideIndex());
1174cdf0e10cSrcweir
1175cdf0e10cSrcweir mpPresenterController->GetPaintManager()->Invalidate(mxWindow);
1176cdf0e10cSrcweir }
1177cdf0e10cSrcweir }
1178cdf0e10cSrcweir
1179cdf0e10cSrcweir
1180cdf0e10cSrcweir
1181cdf0e10cSrcweir
SetVerticalOffset(const double nYOffset)1182cdf0e10cSrcweir void PresenterSlideSorter::SetVerticalOffset (const double nYOffset)
1183cdf0e10cSrcweir {
1184cdf0e10cSrcweir if (mpLayout->SetVerticalOffset(nYOffset))
1185cdf0e10cSrcweir {
1186cdf0e10cSrcweir mxPreviewCache->setVisibleRange(
1187cdf0e10cSrcweir mpLayout->GetFirstVisibleSlideIndex(),
1188cdf0e10cSrcweir mpLayout->GetLastVisibleSlideIndex());
1189cdf0e10cSrcweir
1190cdf0e10cSrcweir mpPresenterController->GetPaintManager()->Invalidate(mxWindow);
1191cdf0e10cSrcweir }
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir
1194cdf0e10cSrcweir
1195cdf0e10cSrcweir
1196cdf0e10cSrcweir
GotoSlide(const sal_Int32 nSlideIndex)1197cdf0e10cSrcweir void PresenterSlideSorter::GotoSlide (const sal_Int32 nSlideIndex)
1198cdf0e10cSrcweir {
1199cdf0e10cSrcweir mxSlideShowController->gotoSlideIndex(nSlideIndex);
1200cdf0e10cSrcweir mpPresenterController->HideSlideSorter();
1201cdf0e10cSrcweir }
1202cdf0e10cSrcweir
1203cdf0e10cSrcweir
1204cdf0e10cSrcweir
1205cdf0e10cSrcweir
ProvideCanvas(void)1206cdf0e10cSrcweir bool PresenterSlideSorter::ProvideCanvas (void)
1207cdf0e10cSrcweir {
1208cdf0e10cSrcweir if ( ! mxCanvas.is())
1209cdf0e10cSrcweir {
1210cdf0e10cSrcweir if (mxPane.is())
1211cdf0e10cSrcweir mxCanvas = mxPane->getCanvas();
1212cdf0e10cSrcweir
1213cdf0e10cSrcweir // Register as event listener so that we are informed when the
1214cdf0e10cSrcweir // canvas is disposed (and we have to fetch another one).
1215cdf0e10cSrcweir Reference<lang::XComponent> xComponent (mxCanvas, UNO_QUERY);
1216cdf0e10cSrcweir if (xComponent.is())
1217cdf0e10cSrcweir xComponent->addEventListener(static_cast<awt::XWindowListener*>(this));
1218cdf0e10cSrcweir
1219cdf0e10cSrcweir // Tell the scrollbar about the canvas.
1220cdf0e10cSrcweir if (mpHorizontalScrollBar.is())
1221cdf0e10cSrcweir mpHorizontalScrollBar->SetCanvas(mxCanvas);
1222cdf0e10cSrcweir
1223cdf0e10cSrcweir mpCurrentSlideFrameRenderer.reset(
1224cdf0e10cSrcweir new CurrentSlideFrameRenderer(mxComponentContext, mxCanvas));
1225cdf0e10cSrcweir }
1226cdf0e10cSrcweir return mxCanvas.is();
1227cdf0e10cSrcweir }
1228cdf0e10cSrcweir
1229cdf0e10cSrcweir
1230cdf0e10cSrcweir
1231cdf0e10cSrcweir
ThrowIfDisposed(void)1232cdf0e10cSrcweir void PresenterSlideSorter::ThrowIfDisposed (void)
1233cdf0e10cSrcweir throw (lang::DisposedException)
1234cdf0e10cSrcweir {
1235cdf0e10cSrcweir if (rBHelper.bDisposed || rBHelper.bInDispose)
1236cdf0e10cSrcweir {
1237cdf0e10cSrcweir throw lang::DisposedException (
1238cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM(
1239cdf0e10cSrcweir "PresenterSlideSorter has been already disposed")),
1240cdf0e10cSrcweir const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
1241cdf0e10cSrcweir }
1242cdf0e10cSrcweir }
1243cdf0e10cSrcweir
1244cdf0e10cSrcweir
1245cdf0e10cSrcweir
1246cdf0e10cSrcweir
1247cdf0e10cSrcweir //===== PresenterSlideSorter::Layout ==========================================
1248cdf0e10cSrcweir
Layout(const Orientation eOrientation,const::rtl::Reference<PresenterScrollBar> & rpHorizontalScrollBar,const::rtl::Reference<PresenterScrollBar> & rpVerticalScrollBar)1249cdf0e10cSrcweir PresenterSlideSorter::Layout::Layout (
1250cdf0e10cSrcweir const Orientation eOrientation,
1251cdf0e10cSrcweir const ::rtl::Reference<PresenterScrollBar>& rpHorizontalScrollBar,
1252cdf0e10cSrcweir const ::rtl::Reference<PresenterScrollBar>& rpVerticalScrollBar)
1253cdf0e10cSrcweir : maBoundingBox(),
1254cdf0e10cSrcweir maPreviewSize(),
1255cdf0e10cSrcweir mnHorizontalOffset(0),
1256cdf0e10cSrcweir mnVerticalOffset(0),
1257cdf0e10cSrcweir mnHorizontalGap(0),
1258cdf0e10cSrcweir mnVerticalGap(0),
1259cdf0e10cSrcweir mnHorizontalBorder(0),
1260cdf0e10cSrcweir mnVerticalBorder(0),
1261cdf0e10cSrcweir mnRowCount(1),
1262cdf0e10cSrcweir mnColumnCount(1),
1263cdf0e10cSrcweir mnSlideCount(0),
1264cdf0e10cSrcweir mnSlideIndexAtMouse(-1),
1265cdf0e10cSrcweir mnFirstVisibleColumn(-1),
1266cdf0e10cSrcweir mnLastVisibleColumn(-1),
1267cdf0e10cSrcweir mnFirstVisibleRow(-1),
1268cdf0e10cSrcweir mnLastVisibleRow(-1),
1269cdf0e10cSrcweir meOrientation(eOrientation),
1270cdf0e10cSrcweir mpHorizontalScrollBar(rpHorizontalScrollBar),
1271cdf0e10cSrcweir mpVerticalScrollBar(rpVerticalScrollBar)
1272cdf0e10cSrcweir {
1273cdf0e10cSrcweir }
1274cdf0e10cSrcweir
1275cdf0e10cSrcweir
1276cdf0e10cSrcweir
1277cdf0e10cSrcweir
Update(const geometry::RealRectangle2D & rBoundingBox,const double nSlideAspectRatio)1278cdf0e10cSrcweir void PresenterSlideSorter::Layout::Update (
1279cdf0e10cSrcweir const geometry::RealRectangle2D& rBoundingBox,
1280cdf0e10cSrcweir const double nSlideAspectRatio)
1281cdf0e10cSrcweir {
1282cdf0e10cSrcweir maBoundingBox = rBoundingBox;
1283cdf0e10cSrcweir
1284cdf0e10cSrcweir mnHorizontalBorder = gnHorizontalBorder;
1285cdf0e10cSrcweir mnVerticalBorder = gnVerticalBorder;
1286cdf0e10cSrcweir
1287cdf0e10cSrcweir const double nWidth (rBoundingBox.X2 - rBoundingBox.X1 - 2*mnHorizontalBorder);
1288cdf0e10cSrcweir const double nHeight (rBoundingBox.Y2 - rBoundingBox.Y1 - 2*mnVerticalBorder);
1289cdf0e10cSrcweir if (nWidth<=0 || nHeight<=0)
1290cdf0e10cSrcweir return;
1291cdf0e10cSrcweir
1292cdf0e10cSrcweir double nPreviewWidth;
1293cdf0e10cSrcweir
1294cdf0e10cSrcweir // Determine column count, preview width, and horizontal gap (borders
1295cdf0e10cSrcweir // are half the gap). Try to use the preferred values. Try more to
1296cdf0e10cSrcweir // stay in the valid intervalls. This last constraint may be not
1297*86e1cf34SPedro Giffuni // fulfilled in some cases.
1298cdf0e10cSrcweir const double nElementWidth = nWidth / gnPreferredColumnCount;
1299cdf0e10cSrcweir if (nElementWidth < gnMinimalPreviewWidth + gnMinimalHorizontalPreviewGap)
1300cdf0e10cSrcweir {
1301cdf0e10cSrcweir // The preferred column count is too large.
1302cdf0e10cSrcweir // Can we use the preferred preview width?
1303cdf0e10cSrcweir if (nWidth - gnMinimalHorizontalPreviewGap >= gnPreferredPreviewWidth)
1304cdf0e10cSrcweir {
1305cdf0e10cSrcweir // Yes.
1306cdf0e10cSrcweir nPreviewWidth = gnPreferredPreviewWidth;
1307cdf0e10cSrcweir mnColumnCount = floor((nWidth+gnPreferredHorizontalPreviewGap)
1308cdf0e10cSrcweir / (nPreviewWidth+gnPreferredHorizontalPreviewGap));
1309cdf0e10cSrcweir mnHorizontalGap = round((nWidth - mnColumnCount*nPreviewWidth) / mnColumnCount);
1310cdf0e10cSrcweir }
1311cdf0e10cSrcweir else
1312cdf0e10cSrcweir {
1313cdf0e10cSrcweir // No. Set the column count to 1 and adapt preview width and
1314cdf0e10cSrcweir // gap.
1315cdf0e10cSrcweir mnColumnCount = 1;
1316cdf0e10cSrcweir mnHorizontalGap = floor(gnMinimalHorizontalPreviewGap);
1317cdf0e10cSrcweir if (nWidth - gnMinimalHorizontalPreviewGap >= gnPreferredPreviewWidth)
1318cdf0e10cSrcweir nPreviewWidth = nWidth - gnMinimalHorizontalPreviewGap;
1319cdf0e10cSrcweir else
1320cdf0e10cSrcweir nPreviewWidth = ::std::max(gnMinimalPreviewWidth, nWidth-mnHorizontalGap);
1321cdf0e10cSrcweir }
1322cdf0e10cSrcweir }
1323cdf0e10cSrcweir else if (nElementWidth > gnMaximalPreviewWidth + gnMaximalHorizontalPreviewGap)
1324cdf0e10cSrcweir {
1325cdf0e10cSrcweir // The preferred column count is too small.
1326cdf0e10cSrcweir nPreviewWidth = gnPreferredPreviewWidth;
1327cdf0e10cSrcweir mnColumnCount = floor((nWidth+gnPreferredHorizontalPreviewGap)
1328cdf0e10cSrcweir / (nPreviewWidth+gnPreferredHorizontalPreviewGap));
1329cdf0e10cSrcweir mnHorizontalGap = round((nWidth - mnColumnCount*nPreviewWidth) / mnColumnCount);
1330cdf0e10cSrcweir }
1331cdf0e10cSrcweir else
1332cdf0e10cSrcweir {
1333cdf0e10cSrcweir // The preferred column count is possible. Determine gap and
1334cdf0e10cSrcweir // preview width.
1335cdf0e10cSrcweir mnColumnCount = gnPreferredColumnCount;
1336cdf0e10cSrcweir if (nElementWidth - gnPreferredPreviewWidth < gnMinimalHorizontalPreviewGap)
1337cdf0e10cSrcweir {
1338cdf0e10cSrcweir // Use the minimal gap and adapt the preview width.
1339cdf0e10cSrcweir mnHorizontalGap = floor(gnMinimalHorizontalPreviewGap);
1340cdf0e10cSrcweir nPreviewWidth = (nWidth - mnColumnCount*mnHorizontalGap) / mnColumnCount;
1341cdf0e10cSrcweir }
1342cdf0e10cSrcweir else if (nElementWidth - gnPreferredPreviewWidth <= gnMaximalHorizontalPreviewGap)
1343cdf0e10cSrcweir {
1344cdf0e10cSrcweir // Use the maximal gap and adapt the preview width.
1345cdf0e10cSrcweir mnHorizontalGap = round(gnMaximalHorizontalPreviewGap);
1346cdf0e10cSrcweir nPreviewWidth = (nWidth - mnColumnCount*mnHorizontalGap) / mnColumnCount;
1347cdf0e10cSrcweir }
1348cdf0e10cSrcweir else
1349cdf0e10cSrcweir {
1350cdf0e10cSrcweir // Use the preferred preview width and adapt the gap.
1351cdf0e10cSrcweir nPreviewWidth = gnPreferredPreviewWidth;
1352cdf0e10cSrcweir mnHorizontalGap = round((nWidth - mnColumnCount*nPreviewWidth) / mnColumnCount);
1353cdf0e10cSrcweir }
1354cdf0e10cSrcweir }
1355cdf0e10cSrcweir
1356cdf0e10cSrcweir // Now determine the row count, preview height, and vertical gap.
1357cdf0e10cSrcweir const double nPreviewHeight = nPreviewWidth / nSlideAspectRatio;
1358cdf0e10cSrcweir mnRowCount = ::std::max(
1359cdf0e10cSrcweir sal_Int32(1),
1360cdf0e10cSrcweir sal_Int32(ceil((nHeight+gnPreferredVerticalPreviewGap)
1361cdf0e10cSrcweir / (nPreviewHeight + gnPreferredVerticalPreviewGap))));
1362cdf0e10cSrcweir mnVerticalGap = round(gnPreferredVerticalPreviewGap);
1363cdf0e10cSrcweir
1364cdf0e10cSrcweir maPreviewSize = geometry::IntegerSize2D(floor(nPreviewWidth), floor(nPreviewHeight));
1365cdf0e10cSrcweir
1366cdf0e10cSrcweir // Reset the offset.
1367cdf0e10cSrcweir if (meOrientation == Horizontal)
1368cdf0e10cSrcweir {
1369cdf0e10cSrcweir mnVerticalOffset = round(-(nHeight
1370cdf0e10cSrcweir - mnRowCount*maPreviewSize.Height - (mnRowCount-1)*mnVerticalGap)
1371cdf0e10cSrcweir / 2);
1372cdf0e10cSrcweir mnHorizontalOffset = 0;
1373cdf0e10cSrcweir }
1374cdf0e10cSrcweir else
1375cdf0e10cSrcweir {
1376cdf0e10cSrcweir mnVerticalOffset = 0;
1377cdf0e10cSrcweir mnHorizontalOffset = round(-(nWidth
1378cdf0e10cSrcweir - mnColumnCount*maPreviewSize.Width
1379cdf0e10cSrcweir - (mnColumnCount-1)*mnHorizontalGap)
1380cdf0e10cSrcweir / 2);
1381cdf0e10cSrcweir }
1382cdf0e10cSrcweir }
1383cdf0e10cSrcweir
1384cdf0e10cSrcweir
1385cdf0e10cSrcweir
1386cdf0e10cSrcweir
SetupVisibleArea(void)1387cdf0e10cSrcweir void PresenterSlideSorter::Layout::SetupVisibleArea (void)
1388cdf0e10cSrcweir {
1389cdf0e10cSrcweir geometry::RealPoint2D aPoint (GetLocalPosition(
1390cdf0e10cSrcweir geometry::RealPoint2D(maBoundingBox.X1, maBoundingBox.Y1)));
1391cdf0e10cSrcweir if (meOrientation == Horizontal)
1392cdf0e10cSrcweir {
1393cdf0e10cSrcweir mnFirstVisibleColumn = ::std::max(sal_Int32(0), GetColumn(aPoint));
1394cdf0e10cSrcweir mnFirstVisibleRow = 0;
1395cdf0e10cSrcweir }
1396cdf0e10cSrcweir else
1397cdf0e10cSrcweir {
1398cdf0e10cSrcweir mnFirstVisibleColumn = 0;
1399cdf0e10cSrcweir mnFirstVisibleRow = ::std::max(sal_Int32(0), GetRow(aPoint));
1400cdf0e10cSrcweir }
1401cdf0e10cSrcweir
1402cdf0e10cSrcweir aPoint = GetLocalPosition(geometry::RealPoint2D( maBoundingBox.X2, maBoundingBox.Y2));
1403cdf0e10cSrcweir if (meOrientation == Horizontal)
1404cdf0e10cSrcweir {
1405cdf0e10cSrcweir mnLastVisibleColumn = GetColumn(aPoint, true);
1406cdf0e10cSrcweir mnLastVisibleRow = mnRowCount - 1;
1407cdf0e10cSrcweir }
1408cdf0e10cSrcweir else
1409cdf0e10cSrcweir {
1410cdf0e10cSrcweir mnLastVisibleColumn = mnColumnCount - 1;
1411cdf0e10cSrcweir mnLastVisibleRow = GetRow(aPoint, true);
1412cdf0e10cSrcweir }
1413cdf0e10cSrcweir }
1414cdf0e10cSrcweir
1415cdf0e10cSrcweir
1416cdf0e10cSrcweir
1417cdf0e10cSrcweir
IsScrollBarNeeded(const sal_Int32 nSlideCount)1418cdf0e10cSrcweir bool PresenterSlideSorter::Layout::IsScrollBarNeeded (const sal_Int32 nSlideCount)
1419cdf0e10cSrcweir {
1420cdf0e10cSrcweir geometry::RealPoint2D aBottomRight;
1421cdf0e10cSrcweir if (GetOrientation() == Layout::Vertical)
1422cdf0e10cSrcweir aBottomRight = GetPoint(
1423cdf0e10cSrcweir mnColumnCount * (GetRow(nSlideCount)+1) - 1, +1, +1);
1424cdf0e10cSrcweir else
1425cdf0e10cSrcweir aBottomRight = GetPoint(
1426cdf0e10cSrcweir mnRowCount * (GetColumn(nSlideCount)+1) - 1, +1, +1);
1427cdf0e10cSrcweir return aBottomRight.X > maBoundingBox.X2-maBoundingBox.X1
1428cdf0e10cSrcweir || aBottomRight.Y > maBoundingBox.Y2-maBoundingBox.Y1;
1429cdf0e10cSrcweir }
1430cdf0e10cSrcweir
1431cdf0e10cSrcweir
1432cdf0e10cSrcweir
1433cdf0e10cSrcweir
GetLocalPosition(const geometry::RealPoint2D & rWindowPoint) const1434cdf0e10cSrcweir geometry::RealPoint2D PresenterSlideSorter::Layout::GetLocalPosition(
1435cdf0e10cSrcweir const geometry::RealPoint2D& rWindowPoint) const
1436cdf0e10cSrcweir {
1437cdf0e10cSrcweir return css::geometry::RealPoint2D(
1438cdf0e10cSrcweir rWindowPoint.X - maBoundingBox.X1 + mnHorizontalOffset,
1439cdf0e10cSrcweir rWindowPoint.Y - maBoundingBox.Y1 + mnVerticalOffset);
1440cdf0e10cSrcweir }
1441cdf0e10cSrcweir
1442cdf0e10cSrcweir
1443cdf0e10cSrcweir
1444cdf0e10cSrcweir
GetWindowPosition(const geometry::RealPoint2D & rLocalPoint) const1445cdf0e10cSrcweir geometry::RealPoint2D PresenterSlideSorter::Layout::GetWindowPosition(
1446cdf0e10cSrcweir const geometry::RealPoint2D& rLocalPoint) const
1447cdf0e10cSrcweir {
1448cdf0e10cSrcweir return css::geometry::RealPoint2D(
1449cdf0e10cSrcweir rLocalPoint.X - mnHorizontalOffset + maBoundingBox.X1,
1450cdf0e10cSrcweir rLocalPoint.Y - mnVerticalOffset + maBoundingBox.Y1);
1451cdf0e10cSrcweir }
1452cdf0e10cSrcweir
1453cdf0e10cSrcweir
1454cdf0e10cSrcweir
1455cdf0e10cSrcweir
GetColumn(const css::geometry::RealPoint2D & rLocalPoint,const bool bReturnInvalidValue) const1456cdf0e10cSrcweir sal_Int32 PresenterSlideSorter::Layout::GetColumn (
1457cdf0e10cSrcweir const css::geometry::RealPoint2D& rLocalPoint,
1458cdf0e10cSrcweir const bool bReturnInvalidValue) const
1459cdf0e10cSrcweir {
1460cdf0e10cSrcweir const sal_Int32 nColumn(floor(
1461cdf0e10cSrcweir (rLocalPoint.X + mnHorizontalGap/2.0) / (maPreviewSize.Width+mnHorizontalGap)));
1462cdf0e10cSrcweir if (bReturnInvalidValue
1463cdf0e10cSrcweir || (nColumn>=mnFirstVisibleColumn && nColumn<=mnLastVisibleColumn))
1464cdf0e10cSrcweir {
1465cdf0e10cSrcweir return nColumn;
1466cdf0e10cSrcweir }
1467cdf0e10cSrcweir else
1468cdf0e10cSrcweir return -1;
1469cdf0e10cSrcweir }
1470cdf0e10cSrcweir
1471cdf0e10cSrcweir
1472cdf0e10cSrcweir
1473cdf0e10cSrcweir
GetRow(const css::geometry::RealPoint2D & rLocalPoint,const bool bReturnInvalidValue) const1474cdf0e10cSrcweir sal_Int32 PresenterSlideSorter::Layout::GetRow (
1475cdf0e10cSrcweir const css::geometry::RealPoint2D& rLocalPoint,
1476cdf0e10cSrcweir const bool bReturnInvalidValue) const
1477cdf0e10cSrcweir {
1478cdf0e10cSrcweir const sal_Int32 nRow (floor(
1479cdf0e10cSrcweir (rLocalPoint.Y + mnVerticalGap/2.0) / (maPreviewSize.Height+mnVerticalGap)));
1480cdf0e10cSrcweir if (bReturnInvalidValue
1481cdf0e10cSrcweir || (nRow>=mnFirstVisibleRow && nRow<=mnLastVisibleRow))
1482cdf0e10cSrcweir {
1483cdf0e10cSrcweir return nRow;
1484cdf0e10cSrcweir }
1485cdf0e10cSrcweir else
1486cdf0e10cSrcweir return -1;
1487cdf0e10cSrcweir }
1488cdf0e10cSrcweir
1489cdf0e10cSrcweir
1490cdf0e10cSrcweir
1491cdf0e10cSrcweir
GetSlideIndexForPosition(const css::geometry::RealPoint2D & rWindowPoint) const1492cdf0e10cSrcweir sal_Int32 PresenterSlideSorter::Layout::GetSlideIndexForPosition (
1493cdf0e10cSrcweir const css::geometry::RealPoint2D& rWindowPoint) const
1494cdf0e10cSrcweir {
1495cdf0e10cSrcweir if ( ! PresenterGeometryHelper::IsInside(maBoundingBox, rWindowPoint))
1496cdf0e10cSrcweir return -1;
1497cdf0e10cSrcweir
1498cdf0e10cSrcweir const css::geometry::RealPoint2D aLocalPosition (GetLocalPosition(rWindowPoint));
1499cdf0e10cSrcweir const sal_Int32 nColumn (GetColumn(aLocalPosition));
1500cdf0e10cSrcweir const sal_Int32 nRow (GetRow(aLocalPosition));
1501cdf0e10cSrcweir
1502cdf0e10cSrcweir if (nColumn < 0 || nRow < 0)
1503cdf0e10cSrcweir return -1;
1504cdf0e10cSrcweir else
1505cdf0e10cSrcweir {
1506cdf0e10cSrcweir sal_Int32 nIndex (GetIndex(nRow, nColumn));
1507cdf0e10cSrcweir if (nIndex >= mnSlideCount)
1508cdf0e10cSrcweir return -1;
1509cdf0e10cSrcweir else
1510cdf0e10cSrcweir return nIndex;
1511cdf0e10cSrcweir }
1512cdf0e10cSrcweir }
1513cdf0e10cSrcweir
1514cdf0e10cSrcweir
1515cdf0e10cSrcweir
1516cdf0e10cSrcweir
GetPoint(const sal_Int32 nSlideIndex,const sal_Int32 nRelativeHorizontalPosition,const sal_Int32 nRelativeVerticalPosition) const1517cdf0e10cSrcweir geometry::RealPoint2D PresenterSlideSorter::Layout::GetPoint (
1518cdf0e10cSrcweir const sal_Int32 nSlideIndex,
1519cdf0e10cSrcweir const sal_Int32 nRelativeHorizontalPosition,
1520cdf0e10cSrcweir const sal_Int32 nRelativeVerticalPosition) const
1521cdf0e10cSrcweir {
1522cdf0e10cSrcweir sal_Int32 nColumn (GetColumn(nSlideIndex));
1523cdf0e10cSrcweir sal_Int32 nRow (GetRow(nSlideIndex));
1524cdf0e10cSrcweir
1525cdf0e10cSrcweir geometry::RealPoint2D aPosition (
1526cdf0e10cSrcweir mnHorizontalBorder + nColumn*(maPreviewSize.Width+mnHorizontalGap),
1527cdf0e10cSrcweir mnVerticalBorder + nRow*(maPreviewSize.Height+mnVerticalGap));
1528cdf0e10cSrcweir
1529cdf0e10cSrcweir if (nRelativeHorizontalPosition >= 0)
1530cdf0e10cSrcweir {
1531cdf0e10cSrcweir if (nRelativeHorizontalPosition > 0)
1532cdf0e10cSrcweir aPosition.X += maPreviewSize.Width;
1533cdf0e10cSrcweir else
1534cdf0e10cSrcweir aPosition.X += maPreviewSize.Width / 2.0;
1535cdf0e10cSrcweir }
1536cdf0e10cSrcweir if (nRelativeVerticalPosition >= 0)
1537cdf0e10cSrcweir {
1538cdf0e10cSrcweir if (nRelativeVerticalPosition > 0)
1539cdf0e10cSrcweir aPosition.Y += maPreviewSize.Height;
1540cdf0e10cSrcweir else
1541cdf0e10cSrcweir aPosition.Y += maPreviewSize.Height / 2.0;
1542cdf0e10cSrcweir }
1543cdf0e10cSrcweir
1544cdf0e10cSrcweir return aPosition;
1545cdf0e10cSrcweir }
1546cdf0e10cSrcweir
1547cdf0e10cSrcweir
1548cdf0e10cSrcweir
1549cdf0e10cSrcweir
GetBoundingBox(const sal_Int32 nSlideIndex) const1550cdf0e10cSrcweir awt::Rectangle PresenterSlideSorter::Layout::GetBoundingBox (const sal_Int32 nSlideIndex) const
1551cdf0e10cSrcweir {
1552cdf0e10cSrcweir const geometry::RealPoint2D aWindowPosition(GetWindowPosition(GetPoint(nSlideIndex, -1, -1)));
1553cdf0e10cSrcweir return PresenterGeometryHelper::ConvertRectangle(
1554cdf0e10cSrcweir geometry::RealRectangle2D(
1555cdf0e10cSrcweir aWindowPosition.X,
1556cdf0e10cSrcweir aWindowPosition.Y,
1557cdf0e10cSrcweir aWindowPosition.X + maPreviewSize.Width,
1558cdf0e10cSrcweir aWindowPosition.Y + maPreviewSize.Height));
1559cdf0e10cSrcweir }
1560cdf0e10cSrcweir
1561cdf0e10cSrcweir
1562cdf0e10cSrcweir
1563cdf0e10cSrcweir
ForAllVisibleSlides(const::boost::function<void (sal_Int32)> & rAction)1564cdf0e10cSrcweir void PresenterSlideSorter::Layout::ForAllVisibleSlides (const ::boost::function<void(sal_Int32)>& rAction)
1565cdf0e10cSrcweir {
1566cdf0e10cSrcweir for (sal_Int32 nRow=mnFirstVisibleRow; nRow<=mnLastVisibleRow; ++nRow)
1567cdf0e10cSrcweir {
1568cdf0e10cSrcweir for (sal_Int32 nColumn=mnFirstVisibleColumn; nColumn<=mnLastVisibleColumn; ++nColumn)
1569cdf0e10cSrcweir {
1570cdf0e10cSrcweir const sal_Int32 nSlideIndex (GetIndex(nRow, nColumn));
1571cdf0e10cSrcweir if (nSlideIndex >= mnSlideCount)
1572cdf0e10cSrcweir return;
1573cdf0e10cSrcweir rAction(nSlideIndex);
1574cdf0e10cSrcweir }
1575cdf0e10cSrcweir }
1576cdf0e10cSrcweir }
1577cdf0e10cSrcweir
1578cdf0e10cSrcweir
1579cdf0e10cSrcweir
1580cdf0e10cSrcweir
GetFirstVisibleSlideIndex(void) const1581cdf0e10cSrcweir sal_Int32 PresenterSlideSorter::Layout::GetFirstVisibleSlideIndex (void) const
1582cdf0e10cSrcweir {
1583cdf0e10cSrcweir return GetIndex(mnFirstVisibleRow, mnFirstVisibleColumn);
1584cdf0e10cSrcweir }
1585cdf0e10cSrcweir
1586cdf0e10cSrcweir
1587cdf0e10cSrcweir
1588cdf0e10cSrcweir
GetLastVisibleSlideIndex(void) const1589cdf0e10cSrcweir sal_Int32 PresenterSlideSorter::Layout::GetLastVisibleSlideIndex (void) const
1590cdf0e10cSrcweir {
1591cdf0e10cSrcweir return ::std::min(
1592cdf0e10cSrcweir GetIndex(mnLastVisibleRow, mnLastVisibleColumn),
1593cdf0e10cSrcweir mnSlideCount);
1594cdf0e10cSrcweir }
1595cdf0e10cSrcweir
1596cdf0e10cSrcweir
1597cdf0e10cSrcweir
1598cdf0e10cSrcweir
SetHorizontalOffset(const double nOffset)1599cdf0e10cSrcweir bool PresenterSlideSorter::Layout::SetHorizontalOffset (const double nOffset)
1600cdf0e10cSrcweir {
1601cdf0e10cSrcweir if (mnHorizontalOffset != nOffset)
1602cdf0e10cSrcweir {
1603cdf0e10cSrcweir mnHorizontalOffset = round(nOffset);
1604cdf0e10cSrcweir SetupVisibleArea();
1605cdf0e10cSrcweir UpdateScrollBars();
1606cdf0e10cSrcweir return true;
1607cdf0e10cSrcweir }
1608cdf0e10cSrcweir else
1609cdf0e10cSrcweir return false;
1610cdf0e10cSrcweir }
1611cdf0e10cSrcweir
1612cdf0e10cSrcweir
1613cdf0e10cSrcweir
1614cdf0e10cSrcweir
SetVerticalOffset(const double nOffset)1615cdf0e10cSrcweir bool PresenterSlideSorter::Layout::SetVerticalOffset (const double nOffset)
1616cdf0e10cSrcweir {
1617cdf0e10cSrcweir if (mnVerticalOffset != nOffset)
1618cdf0e10cSrcweir {
1619cdf0e10cSrcweir mnVerticalOffset = round(nOffset);
1620cdf0e10cSrcweir SetupVisibleArea();
1621cdf0e10cSrcweir UpdateScrollBars();
1622cdf0e10cSrcweir return true;
1623cdf0e10cSrcweir }
1624cdf0e10cSrcweir else
1625cdf0e10cSrcweir return false;
1626cdf0e10cSrcweir }
1627cdf0e10cSrcweir
1628cdf0e10cSrcweir
1629cdf0e10cSrcweir
1630cdf0e10cSrcweir
1631cdf0e10cSrcweir PresenterSlideSorter::Layout::Orientation
GetOrientation(void) const1632cdf0e10cSrcweir PresenterSlideSorter::Layout::GetOrientation (void) const
1633cdf0e10cSrcweir {
1634cdf0e10cSrcweir return meOrientation;
1635cdf0e10cSrcweir }
1636cdf0e10cSrcweir
1637cdf0e10cSrcweir
1638cdf0e10cSrcweir
1639cdf0e10cSrcweir
UpdateScrollBars(void)1640cdf0e10cSrcweir void PresenterSlideSorter::Layout::UpdateScrollBars (void)
1641cdf0e10cSrcweir {
1642cdf0e10cSrcweir sal_Int32 nTotalColumnCount (0);
1643cdf0e10cSrcweir sal_Int32 nTotalRowCount (0);
1644cdf0e10cSrcweir if (meOrientation == Horizontal)
1645cdf0e10cSrcweir {
1646cdf0e10cSrcweir nTotalColumnCount = sal_Int32(ceil(double(mnSlideCount) / double(mnRowCount)));
1647cdf0e10cSrcweir nTotalRowCount = mnRowCount;
1648cdf0e10cSrcweir }
1649cdf0e10cSrcweir else
1650cdf0e10cSrcweir {
1651cdf0e10cSrcweir nTotalColumnCount = mnColumnCount;
1652cdf0e10cSrcweir nTotalRowCount = sal_Int32(ceil(double(mnSlideCount) / double(mnColumnCount)));
1653cdf0e10cSrcweir }
1654cdf0e10cSrcweir
1655cdf0e10cSrcweir if (mpHorizontalScrollBar.get() != NULL)
1656cdf0e10cSrcweir {
1657cdf0e10cSrcweir mpHorizontalScrollBar->SetTotalSize(
1658cdf0e10cSrcweir nTotalColumnCount * maPreviewSize.Width
1659cdf0e10cSrcweir + (nTotalColumnCount-1) * mnHorizontalGap
1660cdf0e10cSrcweir + 2*mnHorizontalBorder);
1661cdf0e10cSrcweir mpHorizontalScrollBar->SetThumbPosition(mnHorizontalOffset, false);
1662cdf0e10cSrcweir mpHorizontalScrollBar->SetThumbSize(maBoundingBox.X2 - maBoundingBox.X1 + 1);
1663cdf0e10cSrcweir mpHorizontalScrollBar->SetLineHeight(maPreviewSize.Width);
1664cdf0e10cSrcweir }
1665cdf0e10cSrcweir if (mpVerticalScrollBar.get() != NULL)
1666cdf0e10cSrcweir {
1667cdf0e10cSrcweir mpVerticalScrollBar->SetTotalSize(
1668cdf0e10cSrcweir nTotalRowCount * maPreviewSize.Height
1669cdf0e10cSrcweir + (nTotalRowCount-1) * mnVerticalGap
1670cdf0e10cSrcweir + 2*mnVerticalGap);
1671cdf0e10cSrcweir mpVerticalScrollBar->SetThumbPosition(mnVerticalOffset, false);
1672cdf0e10cSrcweir mpVerticalScrollBar->SetThumbSize(maBoundingBox.Y2 - maBoundingBox.Y1 + 1);
1673cdf0e10cSrcweir mpVerticalScrollBar->SetLineHeight(maPreviewSize.Height);
1674cdf0e10cSrcweir }
1675cdf0e10cSrcweir
1676cdf0e10cSrcweir
1677cdf0e10cSrcweir
1678cdf0e10cSrcweir // No place yet for the vertical scroll bar.
1679cdf0e10cSrcweir }
1680cdf0e10cSrcweir
1681cdf0e10cSrcweir
1682cdf0e10cSrcweir
1683cdf0e10cSrcweir
GetIndex(const sal_Int32 nRow,const sal_Int32 nColumn) const1684cdf0e10cSrcweir sal_Int32 PresenterSlideSorter::Layout::GetIndex (
1685cdf0e10cSrcweir const sal_Int32 nRow,
1686cdf0e10cSrcweir const sal_Int32 nColumn) const
1687cdf0e10cSrcweir {
1688cdf0e10cSrcweir if (meOrientation == Horizontal)
1689cdf0e10cSrcweir return nColumn * mnRowCount + nRow;
1690cdf0e10cSrcweir else
1691cdf0e10cSrcweir return nRow * mnColumnCount + nColumn;
1692cdf0e10cSrcweir }
1693cdf0e10cSrcweir
1694cdf0e10cSrcweir
1695cdf0e10cSrcweir
1696cdf0e10cSrcweir
GetRow(const sal_Int32 nSlideIndex) const1697cdf0e10cSrcweir sal_Int32 PresenterSlideSorter::Layout::GetRow (const sal_Int32 nSlideIndex) const
1698cdf0e10cSrcweir {
1699cdf0e10cSrcweir if (meOrientation == Horizontal)
1700cdf0e10cSrcweir return nSlideIndex % mnRowCount;
1701cdf0e10cSrcweir else
1702cdf0e10cSrcweir return nSlideIndex / mnColumnCount;
1703cdf0e10cSrcweir }
1704cdf0e10cSrcweir
1705cdf0e10cSrcweir
1706cdf0e10cSrcweir
1707cdf0e10cSrcweir
GetColumn(const sal_Int32 nSlideIndex) const1708cdf0e10cSrcweir sal_Int32 PresenterSlideSorter::Layout::GetColumn (const sal_Int32 nSlideIndex) const
1709cdf0e10cSrcweir {
1710cdf0e10cSrcweir if (meOrientation == Horizontal)
1711cdf0e10cSrcweir return nSlideIndex / mnRowCount;
1712cdf0e10cSrcweir else
1713cdf0e10cSrcweir return nSlideIndex % mnColumnCount;
1714cdf0e10cSrcweir }
1715cdf0e10cSrcweir
1716cdf0e10cSrcweir
1717cdf0e10cSrcweir
1718cdf0e10cSrcweir
1719cdf0e10cSrcweir //===== PresenterSlideSorter::MouseOverManager ================================
1720cdf0e10cSrcweir
MouseOverManager(const Reference<container::XIndexAccess> & rxSlides,const::boost::shared_ptr<PresenterTheme> & rpTheme,const Reference<awt::XWindow> & rxInvalidateTarget,const::boost::shared_ptr<PresenterPaintManager> & rpPaintManager)1721cdf0e10cSrcweir PresenterSlideSorter::MouseOverManager::MouseOverManager (
1722cdf0e10cSrcweir const Reference<container::XIndexAccess>& rxSlides,
1723cdf0e10cSrcweir const ::boost::shared_ptr<PresenterTheme>& rpTheme,
1724cdf0e10cSrcweir const Reference<awt::XWindow>& rxInvalidateTarget,
1725cdf0e10cSrcweir const ::boost::shared_ptr<PresenterPaintManager>& rpPaintManager)
1726cdf0e10cSrcweir : mxCanvas(),
1727cdf0e10cSrcweir mxSlides(rxSlides),
1728cdf0e10cSrcweir mpLeftLabelBitmap(),
1729cdf0e10cSrcweir mpCenterLabelBitmap(),
1730cdf0e10cSrcweir mpRightLabelBitmap(),
1731cdf0e10cSrcweir mpFont(),
1732cdf0e10cSrcweir mnSlideIndex(-1),
1733cdf0e10cSrcweir maSlideBoundingBox(),
1734cdf0e10cSrcweir mxInvalidateTarget(rxInvalidateTarget),
1735cdf0e10cSrcweir mpPaintManager(rpPaintManager)
1736cdf0e10cSrcweir {
1737cdf0e10cSrcweir if (rpTheme.get()!=NULL)
1738cdf0e10cSrcweir {
1739cdf0e10cSrcweir ::boost::shared_ptr<PresenterBitmapContainer> pBitmaps (rpTheme->GetBitmapContainer());
1740cdf0e10cSrcweir if (pBitmaps.get() != NULL)
1741cdf0e10cSrcweir {
1742cdf0e10cSrcweir mpLeftLabelBitmap = pBitmaps->GetBitmap(A2S("LabelLeft"));
1743cdf0e10cSrcweir mpCenterLabelBitmap = pBitmaps->GetBitmap(A2S("LabelCenter"));
1744cdf0e10cSrcweir mpRightLabelBitmap = pBitmaps->GetBitmap(A2S("LabelRight"));
1745cdf0e10cSrcweir }
1746cdf0e10cSrcweir
1747cdf0e10cSrcweir mpFont = rpTheme->GetFont(A2S("SlideSorterLabelFont"));
1748cdf0e10cSrcweir }
1749cdf0e10cSrcweir }
1750cdf0e10cSrcweir
1751cdf0e10cSrcweir
1752cdf0e10cSrcweir
1753cdf0e10cSrcweir
~MouseOverManager(void)1754cdf0e10cSrcweir PresenterSlideSorter::MouseOverManager::~MouseOverManager (void)
1755cdf0e10cSrcweir {
1756cdf0e10cSrcweir }
1757cdf0e10cSrcweir
1758cdf0e10cSrcweir
1759cdf0e10cSrcweir
1760cdf0e10cSrcweir
Paint(const sal_Int32 nSlideIndex,const Reference<rendering::XCanvas> & rxCanvas,const Reference<rendering::XPolyPolygon2D> & rxClip)1761cdf0e10cSrcweir void PresenterSlideSorter::MouseOverManager::Paint (
1762cdf0e10cSrcweir const sal_Int32 nSlideIndex,
1763cdf0e10cSrcweir const Reference<rendering::XCanvas>& rxCanvas,
1764cdf0e10cSrcweir const Reference<rendering::XPolyPolygon2D>& rxClip)
1765cdf0e10cSrcweir {
1766cdf0e10cSrcweir if (nSlideIndex != mnSlideIndex)
1767cdf0e10cSrcweir return;
1768cdf0e10cSrcweir
1769cdf0e10cSrcweir if (mxCanvas != rxCanvas)
1770cdf0e10cSrcweir SetCanvas(rxCanvas);
1771cdf0e10cSrcweir if (rxCanvas != NULL)
1772cdf0e10cSrcweir {
1773cdf0e10cSrcweir if ( ! mxBitmap.is())
1774cdf0e10cSrcweir mxBitmap = CreateBitmap(msText, maSlideBoundingBox.Width);
1775cdf0e10cSrcweir if (mxBitmap.is())
1776cdf0e10cSrcweir {
1777cdf0e10cSrcweir geometry::IntegerSize2D aSize (mxBitmap->getSize());
1778cdf0e10cSrcweir const double nXOffset (maSlideBoundingBox.X
1779cdf0e10cSrcweir + (maSlideBoundingBox.Width - aSize.Width) / 2.0);
1780cdf0e10cSrcweir const double nYOffset (maSlideBoundingBox.Y
1781cdf0e10cSrcweir + (maSlideBoundingBox.Height - aSize.Height) / 2.0);
1782cdf0e10cSrcweir rxCanvas->drawBitmap(
1783cdf0e10cSrcweir mxBitmap,
1784cdf0e10cSrcweir rendering::ViewState(
1785cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,0, 0,1,0),
1786cdf0e10cSrcweir rxClip),
1787cdf0e10cSrcweir rendering::RenderState(
1788cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,nXOffset, 0,1,nYOffset),
1789cdf0e10cSrcweir NULL,
1790cdf0e10cSrcweir Sequence<double>(4),
1791cdf0e10cSrcweir rendering::CompositeOperation::SOURCE));
1792cdf0e10cSrcweir }
1793cdf0e10cSrcweir }
1794cdf0e10cSrcweir }
1795cdf0e10cSrcweir
1796cdf0e10cSrcweir
1797cdf0e10cSrcweir
1798cdf0e10cSrcweir
SetCanvas(const Reference<rendering::XCanvas> & rxCanvas)1799cdf0e10cSrcweir void PresenterSlideSorter::MouseOverManager::SetCanvas (
1800cdf0e10cSrcweir const Reference<rendering::XCanvas>& rxCanvas)
1801cdf0e10cSrcweir {
1802cdf0e10cSrcweir mxCanvas = rxCanvas;
1803cdf0e10cSrcweir if (mpFont.get() != NULL)
1804cdf0e10cSrcweir mpFont->PrepareFont(Reference<rendering::XCanvas>(mxCanvas, UNO_QUERY));
1805cdf0e10cSrcweir }
1806cdf0e10cSrcweir
1807cdf0e10cSrcweir
1808cdf0e10cSrcweir
1809cdf0e10cSrcweir
SetSlide(const sal_Int32 nSlideIndex,const awt::Rectangle & rBox)1810cdf0e10cSrcweir void PresenterSlideSorter::MouseOverManager::SetSlide (
1811cdf0e10cSrcweir const sal_Int32 nSlideIndex,
1812cdf0e10cSrcweir const awt::Rectangle& rBox)
1813cdf0e10cSrcweir {
1814cdf0e10cSrcweir if (mnSlideIndex == nSlideIndex)
1815cdf0e10cSrcweir return;
1816cdf0e10cSrcweir
1817cdf0e10cSrcweir mnSlideIndex = -1;
1818cdf0e10cSrcweir Invalidate();
1819cdf0e10cSrcweir
1820cdf0e10cSrcweir maSlideBoundingBox = rBox;
1821cdf0e10cSrcweir mnSlideIndex = nSlideIndex;
1822cdf0e10cSrcweir
1823cdf0e10cSrcweir if (nSlideIndex >= 0)
1824cdf0e10cSrcweir {
1825cdf0e10cSrcweir if (mxSlides.get() != NULL)
1826cdf0e10cSrcweir {
1827cdf0e10cSrcweir msText = OUString();
1828cdf0e10cSrcweir
1829cdf0e10cSrcweir Reference<beans::XPropertySet> xSlideProperties(mxSlides->getByIndex(nSlideIndex), UNO_QUERY);
1830cdf0e10cSrcweir if (xSlideProperties.is())
1831cdf0e10cSrcweir xSlideProperties->getPropertyValue(A2S("LinkDisplayName")) >>= msText;
1832cdf0e10cSrcweir
1833cdf0e10cSrcweir if (msText.getLength() == 0)
1834cdf0e10cSrcweir msText = A2S("Slide ") + OUString::valueOf(nSlideIndex + 1);
1835cdf0e10cSrcweir }
1836cdf0e10cSrcweir }
1837cdf0e10cSrcweir else
1838cdf0e10cSrcweir {
1839cdf0e10cSrcweir msText = OUString();
1840cdf0e10cSrcweir }
1841cdf0e10cSrcweir mxBitmap = NULL;
1842cdf0e10cSrcweir
1843cdf0e10cSrcweir Invalidate();
1844cdf0e10cSrcweir }
1845cdf0e10cSrcweir
1846cdf0e10cSrcweir
1847cdf0e10cSrcweir
1848cdf0e10cSrcweir
CreateBitmap(const OUString & rsText,const sal_Int32 nMaximalWidth) const1849cdf0e10cSrcweir Reference<rendering::XBitmap> PresenterSlideSorter::MouseOverManager::CreateBitmap (
1850cdf0e10cSrcweir const OUString& rsText,
1851cdf0e10cSrcweir const sal_Int32 nMaximalWidth) const
1852cdf0e10cSrcweir {
1853cdf0e10cSrcweir if ( ! mxCanvas.is())
1854cdf0e10cSrcweir return NULL;
1855cdf0e10cSrcweir
1856cdf0e10cSrcweir if (mpFont.get()==NULL || !mpFont->mxFont.is())
1857cdf0e10cSrcweir return NULL;
1858cdf0e10cSrcweir
1859cdf0e10cSrcweir // Long text has to be shortened.
1860cdf0e10cSrcweir const OUString sText (GetFittingText(rsText, nMaximalWidth
1861cdf0e10cSrcweir - 2*gnHorizontalLabelBorder
1862cdf0e10cSrcweir - 2*gnHorizontalLabelPadding));
1863cdf0e10cSrcweir
1864cdf0e10cSrcweir // Determine the size of the label. Its height is defined by the
1865cdf0e10cSrcweir // bitmaps that are used to paints its background. The width is defined
1866cdf0e10cSrcweir // by the text.
1867cdf0e10cSrcweir geometry::IntegerSize2D aLabelSize (CalculateLabelSize(sText));
1868cdf0e10cSrcweir
1869cdf0e10cSrcweir // Create a new bitmap that will contain the complete label.
1870cdf0e10cSrcweir Reference<rendering::XBitmap> xBitmap (
1871cdf0e10cSrcweir mxCanvas->getDevice()->createCompatibleAlphaBitmap(aLabelSize));
1872cdf0e10cSrcweir
1873cdf0e10cSrcweir if ( ! xBitmap.is())
1874cdf0e10cSrcweir return NULL;
1875cdf0e10cSrcweir
1876cdf0e10cSrcweir Reference<rendering::XBitmapCanvas> xBitmapCanvas (xBitmap, UNO_QUERY);
1877cdf0e10cSrcweir if ( ! xBitmapCanvas.is())
1878cdf0e10cSrcweir return NULL;
1879cdf0e10cSrcweir
1880cdf0e10cSrcweir // Paint the background.
1881cdf0e10cSrcweir PaintButtonBackground(xBitmapCanvas, aLabelSize);
1882cdf0e10cSrcweir
1883cdf0e10cSrcweir // Paint the text.
1884cdf0e10cSrcweir if (sText.getLength() > 0)
1885cdf0e10cSrcweir {
1886cdf0e10cSrcweir
1887cdf0e10cSrcweir const rendering::StringContext aContext (sText, 0, sText.getLength());
1888cdf0e10cSrcweir const Reference<rendering::XTextLayout> xLayout (mpFont->mxFont->createTextLayout(
1889cdf0e10cSrcweir aContext, rendering::TextDirection::WEAK_LEFT_TO_RIGHT,0));
1890cdf0e10cSrcweir const geometry::RealRectangle2D aTextBBox (xLayout->queryTextBounds());
1891cdf0e10cSrcweir
1892cdf0e10cSrcweir const double nXOffset = (aLabelSize.Width - aTextBBox.X2 + aTextBBox.X1) / 2;
1893cdf0e10cSrcweir const double nYOffset = aLabelSize.Height
1894cdf0e10cSrcweir - (aLabelSize.Height - aTextBBox.Y2 + aTextBBox.Y1)/2 - aTextBBox.Y2;
1895cdf0e10cSrcweir
1896cdf0e10cSrcweir const rendering::ViewState aViewState(
1897cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,0, 0,1,0),
1898cdf0e10cSrcweir NULL);
1899cdf0e10cSrcweir
1900cdf0e10cSrcweir rendering::RenderState aRenderState (
1901cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,nXOffset, 0,1,nYOffset),
1902cdf0e10cSrcweir NULL,
1903cdf0e10cSrcweir Sequence<double>(4),
1904cdf0e10cSrcweir rendering::CompositeOperation::SOURCE);
1905cdf0e10cSrcweir PresenterCanvasHelper::SetDeviceColor(aRenderState, mpFont->mnColor);
1906cdf0e10cSrcweir
1907cdf0e10cSrcweir xBitmapCanvas->drawText(
1908cdf0e10cSrcweir aContext,
1909cdf0e10cSrcweir mpFont->mxFont,
1910cdf0e10cSrcweir aViewState,
1911cdf0e10cSrcweir aRenderState,
1912cdf0e10cSrcweir rendering::TextDirection::WEAK_LEFT_TO_RIGHT);
1913cdf0e10cSrcweir }
1914cdf0e10cSrcweir
1915cdf0e10cSrcweir return xBitmap;
1916cdf0e10cSrcweir }
1917cdf0e10cSrcweir
1918cdf0e10cSrcweir
1919cdf0e10cSrcweir
1920cdf0e10cSrcweir
GetFittingText(const OUString & rsText,const double nMaximalWidth) const1921cdf0e10cSrcweir OUString PresenterSlideSorter::MouseOverManager::GetFittingText (
1922cdf0e10cSrcweir const OUString& rsText,
1923cdf0e10cSrcweir const double nMaximalWidth) const
1924cdf0e10cSrcweir {
1925cdf0e10cSrcweir const double nTextWidth (
1926cdf0e10cSrcweir PresenterCanvasHelper::GetTextSize(mpFont->mxFont, rsText).Width);
1927cdf0e10cSrcweir if (nTextWidth > nMaximalWidth)
1928cdf0e10cSrcweir {
1929cdf0e10cSrcweir // Text is too wide. Shorten it by removing characters from the end
1930cdf0e10cSrcweir // and replacing them by ellipses.
1931cdf0e10cSrcweir
1932cdf0e10cSrcweir // Guess a start value of the final string length.
1933cdf0e10cSrcweir double nBestWidth (0);
1934cdf0e10cSrcweir OUString sBestCandidate;
1935cdf0e10cSrcweir sal_Int32 nLength (round(rsText.getLength() * nMaximalWidth / nTextWidth));
1936cdf0e10cSrcweir const OUString sEllipses (A2S("..."));
1937cdf0e10cSrcweir while (true)
1938cdf0e10cSrcweir {
1939cdf0e10cSrcweir const OUString sCandidate (rsText.copy(0,nLength) + sEllipses);
1940cdf0e10cSrcweir const double nWidth (
1941cdf0e10cSrcweir PresenterCanvasHelper::GetTextSize(mpFont->mxFont, sCandidate).Width);
1942cdf0e10cSrcweir if (nWidth > nMaximalWidth)
1943cdf0e10cSrcweir {
1944cdf0e10cSrcweir // Candidate still too wide, shorten it.
1945cdf0e10cSrcweir nLength -= 1;
1946cdf0e10cSrcweir if (nLength <= 0)
1947cdf0e10cSrcweir break;
1948cdf0e10cSrcweir }
1949cdf0e10cSrcweir else if (nWidth < nMaximalWidth)
1950cdf0e10cSrcweir {
1951cdf0e10cSrcweir // Candidate short enough.
1952cdf0e10cSrcweir if (nWidth > nBestWidth)
1953cdf0e10cSrcweir {
1954cdf0e10cSrcweir // Best length so far.
1955cdf0e10cSrcweir sBestCandidate = sCandidate;
1956cdf0e10cSrcweir nBestWidth = nWidth;
1957cdf0e10cSrcweir nLength += 1;
1958cdf0e10cSrcweir if (nLength >= rsText.getLength())
1959cdf0e10cSrcweir break;
1960cdf0e10cSrcweir }
1961cdf0e10cSrcweir else
1962cdf0e10cSrcweir break;
1963cdf0e10cSrcweir }
1964cdf0e10cSrcweir else
1965cdf0e10cSrcweir {
1966cdf0e10cSrcweir // Candidate is exactly as long as it may be. Use it
1967cdf0e10cSrcweir // without looking any further.
1968cdf0e10cSrcweir sBestCandidate = sCandidate;
1969cdf0e10cSrcweir break;
1970cdf0e10cSrcweir }
1971cdf0e10cSrcweir }
1972cdf0e10cSrcweir return sBestCandidate;
1973cdf0e10cSrcweir }
1974cdf0e10cSrcweir else
1975cdf0e10cSrcweir return rsText;
1976cdf0e10cSrcweir }
1977cdf0e10cSrcweir
1978cdf0e10cSrcweir
1979cdf0e10cSrcweir
1980cdf0e10cSrcweir
CalculateLabelSize(const OUString & rsText) const1981cdf0e10cSrcweir geometry::IntegerSize2D PresenterSlideSorter::MouseOverManager::CalculateLabelSize (
1982cdf0e10cSrcweir const OUString& rsText) const
1983cdf0e10cSrcweir {
1984cdf0e10cSrcweir // Height is specified by the label bitmaps.
1985cdf0e10cSrcweir sal_Int32 nHeight (32);
1986cdf0e10cSrcweir if (mpCenterLabelBitmap.get() != NULL)
1987cdf0e10cSrcweir {
1988cdf0e10cSrcweir Reference<rendering::XBitmap> xBitmap (mpCenterLabelBitmap->GetNormalBitmap());
1989cdf0e10cSrcweir if (xBitmap.is())
1990cdf0e10cSrcweir nHeight = xBitmap->getSize().Height;
1991cdf0e10cSrcweir }
1992cdf0e10cSrcweir
1993cdf0e10cSrcweir // Width is specified by text width and maximal width.
1994cdf0e10cSrcweir const geometry::RealSize2D aTextSize (
1995cdf0e10cSrcweir PresenterCanvasHelper::GetTextSize(mpFont->mxFont, rsText));
1996cdf0e10cSrcweir
1997cdf0e10cSrcweir const sal_Int32 nWidth (round(aTextSize.Width + 2*gnHorizontalLabelPadding));
1998cdf0e10cSrcweir
1999cdf0e10cSrcweir return geometry::IntegerSize2D(nWidth, nHeight);
2000cdf0e10cSrcweir }
2001cdf0e10cSrcweir
2002cdf0e10cSrcweir
2003cdf0e10cSrcweir
2004cdf0e10cSrcweir
PaintButtonBackground(const Reference<rendering::XBitmapCanvas> & rxCanvas,const geometry::IntegerSize2D & rSize) const2005cdf0e10cSrcweir void PresenterSlideSorter::MouseOverManager::PaintButtonBackground (
2006cdf0e10cSrcweir const Reference<rendering::XBitmapCanvas>& rxCanvas,
2007cdf0e10cSrcweir const geometry::IntegerSize2D& rSize) const
2008cdf0e10cSrcweir {
2009cdf0e10cSrcweir // Get the bitmaps for painting the label background.
2010cdf0e10cSrcweir Reference<rendering::XBitmap> xLeftLabelBitmap;
2011cdf0e10cSrcweir if (mpLeftLabelBitmap.get() != NULL)
2012cdf0e10cSrcweir xLeftLabelBitmap = mpLeftLabelBitmap->GetNormalBitmap();
2013cdf0e10cSrcweir
2014cdf0e10cSrcweir Reference<rendering::XBitmap> xCenterLabelBitmap;
2015cdf0e10cSrcweir if (mpCenterLabelBitmap.get() != NULL)
2016cdf0e10cSrcweir xCenterLabelBitmap = mpCenterLabelBitmap->GetNormalBitmap();
2017cdf0e10cSrcweir
2018cdf0e10cSrcweir Reference<rendering::XBitmap> xRightLabelBitmap;
2019cdf0e10cSrcweir if (mpRightLabelBitmap.get() != NULL)
2020cdf0e10cSrcweir xRightLabelBitmap = mpRightLabelBitmap->GetNormalBitmap();
2021cdf0e10cSrcweir
2022cdf0e10cSrcweir PresenterUIPainter::PaintHorizontalBitmapComposite (
2023cdf0e10cSrcweir Reference<rendering::XCanvas>(rxCanvas, UNO_QUERY),
2024cdf0e10cSrcweir awt::Rectangle(0,0, rSize.Width,rSize.Height),
2025cdf0e10cSrcweir awt::Rectangle(0,0, rSize.Width,rSize.Height),
2026cdf0e10cSrcweir xLeftLabelBitmap,
2027cdf0e10cSrcweir xCenterLabelBitmap,
2028cdf0e10cSrcweir xRightLabelBitmap);
2029cdf0e10cSrcweir }
2030cdf0e10cSrcweir
2031cdf0e10cSrcweir
2032cdf0e10cSrcweir
2033cdf0e10cSrcweir
Invalidate(void)2034cdf0e10cSrcweir void PresenterSlideSorter::MouseOverManager::Invalidate (void)
2035cdf0e10cSrcweir {
2036cdf0e10cSrcweir if (mpPaintManager.get() != NULL)
2037cdf0e10cSrcweir mpPaintManager->Invalidate(mxInvalidateTarget, maSlideBoundingBox, true);
2038cdf0e10cSrcweir }
2039cdf0e10cSrcweir
2040cdf0e10cSrcweir
2041cdf0e10cSrcweir
2042cdf0e10cSrcweir
2043cdf0e10cSrcweir //===== PresenterSlideSorter::CurrentSlideFrameRenderer =======================
2044cdf0e10cSrcweir
CurrentSlideFrameRenderer(const css::uno::Reference<css::uno::XComponentContext> & rxContext,const css::uno::Reference<css::rendering::XCanvas> & rxCanvas)2045cdf0e10cSrcweir PresenterSlideSorter::CurrentSlideFrameRenderer::CurrentSlideFrameRenderer (
2046cdf0e10cSrcweir const css::uno::Reference<css::uno::XComponentContext>& rxContext,
2047cdf0e10cSrcweir const css::uno::Reference<css::rendering::XCanvas>& rxCanvas)
2048cdf0e10cSrcweir : mpTopLeft(),
2049cdf0e10cSrcweir mpTop(),
2050cdf0e10cSrcweir mpTopRight(),
2051cdf0e10cSrcweir mpLeft(),
2052cdf0e10cSrcweir mpRight(),
2053cdf0e10cSrcweir mpBottomLeft(),
2054cdf0e10cSrcweir mpBottom(),
2055cdf0e10cSrcweir mpBottomRight(),
2056cdf0e10cSrcweir mnTopFrameSize(0),
2057cdf0e10cSrcweir mnLeftFrameSize(0),
2058cdf0e10cSrcweir mnRightFrameSize(0),
2059cdf0e10cSrcweir mnBottomFrameSize(0)
2060cdf0e10cSrcweir {
2061cdf0e10cSrcweir PresenterConfigurationAccess aConfiguration (
2062cdf0e10cSrcweir rxContext,
206379e0a548SAriel Constenla-Haile OUString::createFromAscii("/org.openoffice.Office.PresenterScreen/"),
2064cdf0e10cSrcweir PresenterConfigurationAccess::READ_ONLY);
2065cdf0e10cSrcweir Reference<container::XHierarchicalNameAccess> xBitmaps (
2066cdf0e10cSrcweir aConfiguration.GetConfigurationNode(
2067cdf0e10cSrcweir A2S("PresenterScreenSettings/SlideSorter/CurrentSlideBorderBitmaps")),
2068cdf0e10cSrcweir UNO_QUERY);
2069cdf0e10cSrcweir if ( ! xBitmaps.is())
2070cdf0e10cSrcweir return;
2071cdf0e10cSrcweir
2072cdf0e10cSrcweir PresenterBitmapContainer aContainer (
2073cdf0e10cSrcweir A2S("PresenterScreenSettings/SlideSorter/CurrentSlideBorderBitmaps"),
2074cdf0e10cSrcweir ::boost::shared_ptr<PresenterBitmapContainer>(),
2075cdf0e10cSrcweir rxContext,
207679e0a548SAriel Constenla-Haile rxCanvas);
2077cdf0e10cSrcweir
2078cdf0e10cSrcweir mpTopLeft = aContainer.GetBitmap(A2S("TopLeft"));
2079cdf0e10cSrcweir mpTop = aContainer.GetBitmap(A2S("Top"));
2080cdf0e10cSrcweir mpTopRight = aContainer.GetBitmap(A2S("TopRight"));
2081cdf0e10cSrcweir mpLeft = aContainer.GetBitmap(A2S("Left"));
2082cdf0e10cSrcweir mpRight = aContainer.GetBitmap(A2S("Right"));
2083cdf0e10cSrcweir mpBottomLeft = aContainer.GetBitmap(A2S("BottomLeft"));
2084cdf0e10cSrcweir mpBottom = aContainer.GetBitmap(A2S("Bottom"));
2085cdf0e10cSrcweir mpBottomRight = aContainer.GetBitmap(A2S("BottomRight"));
2086cdf0e10cSrcweir
2087cdf0e10cSrcweir // Determine size of frame.
2088cdf0e10cSrcweir if (mpTop.get() != NULL)
2089cdf0e10cSrcweir mnTopFrameSize = mpTop->mnHeight;
2090cdf0e10cSrcweir if (mpLeft.get() != NULL)
2091cdf0e10cSrcweir mnLeftFrameSize = mpLeft->mnWidth;
2092cdf0e10cSrcweir if (mpRight.get() != NULL)
2093cdf0e10cSrcweir mnRightFrameSize = mpRight->mnWidth;
2094cdf0e10cSrcweir if (mpBottom.get() != NULL)
2095cdf0e10cSrcweir mnBottomFrameSize = mpBottom->mnHeight;
2096cdf0e10cSrcweir
2097cdf0e10cSrcweir if (mpTopLeft.get() != NULL)
2098cdf0e10cSrcweir {
2099cdf0e10cSrcweir mnTopFrameSize = ::std::max(mnTopFrameSize, mpTopLeft->mnHeight);
2100cdf0e10cSrcweir mnLeftFrameSize = ::std::max(mnLeftFrameSize, mpTopLeft->mnWidth);
2101cdf0e10cSrcweir }
2102cdf0e10cSrcweir if (mpTopRight.get() != NULL)
2103cdf0e10cSrcweir {
2104cdf0e10cSrcweir mnTopFrameSize = ::std::max(mnTopFrameSize, mpTopRight->mnHeight);
2105cdf0e10cSrcweir mnRightFrameSize = ::std::max(mnRightFrameSize, mpTopRight->mnWidth);
2106cdf0e10cSrcweir }
2107cdf0e10cSrcweir if (mpBottomLeft.get() != NULL)
2108cdf0e10cSrcweir {
2109cdf0e10cSrcweir mnLeftFrameSize = ::std::max(mnLeftFrameSize, mpBottomLeft->mnWidth);
2110cdf0e10cSrcweir mnBottomFrameSize = ::std::max(mnBottomFrameSize, mpBottomLeft->mnHeight);
2111cdf0e10cSrcweir }
2112cdf0e10cSrcweir if (mpBottomRight.get() != NULL)
2113cdf0e10cSrcweir {
2114cdf0e10cSrcweir mnRightFrameSize = ::std::max(mnRightFrameSize, mpBottomRight->mnWidth);
2115cdf0e10cSrcweir mnBottomFrameSize = ::std::max(mnBottomFrameSize, mpBottomRight->mnHeight);
2116cdf0e10cSrcweir }
2117cdf0e10cSrcweir }
2118cdf0e10cSrcweir
2119cdf0e10cSrcweir
2120cdf0e10cSrcweir
2121cdf0e10cSrcweir
~CurrentSlideFrameRenderer(void)2122cdf0e10cSrcweir PresenterSlideSorter::CurrentSlideFrameRenderer::~CurrentSlideFrameRenderer (void)
2123cdf0e10cSrcweir {
2124cdf0e10cSrcweir }
2125cdf0e10cSrcweir
2126cdf0e10cSrcweir
2127cdf0e10cSrcweir
2128cdf0e10cSrcweir
PaintCurrentSlideFrame(const awt::Rectangle & rSlideBoundingBox,const Reference<rendering::XCanvas> & rxCanvas,const geometry::RealRectangle2D & rClipBox)2129cdf0e10cSrcweir void PresenterSlideSorter::CurrentSlideFrameRenderer::PaintCurrentSlideFrame (
2130cdf0e10cSrcweir const awt::Rectangle& rSlideBoundingBox,
2131cdf0e10cSrcweir const Reference<rendering::XCanvas>& rxCanvas,
2132cdf0e10cSrcweir const geometry::RealRectangle2D& rClipBox)
2133cdf0e10cSrcweir {
2134cdf0e10cSrcweir if ( ! rxCanvas.is())
2135cdf0e10cSrcweir return;
2136cdf0e10cSrcweir
2137cdf0e10cSrcweir const Reference<rendering::XPolyPolygon2D> xClip (
2138cdf0e10cSrcweir PresenterGeometryHelper::CreatePolygon(rClipBox, rxCanvas->getDevice()));
2139cdf0e10cSrcweir
2140cdf0e10cSrcweir if (mpTop.get() != NULL)
2141cdf0e10cSrcweir {
2142cdf0e10cSrcweir PaintBitmapTiled(
2143cdf0e10cSrcweir mpTop->GetNormalBitmap(),
2144cdf0e10cSrcweir rxCanvas,
2145cdf0e10cSrcweir rClipBox,
2146cdf0e10cSrcweir rSlideBoundingBox.X,
2147cdf0e10cSrcweir rSlideBoundingBox.Y - mpTop->mnHeight,
2148cdf0e10cSrcweir rSlideBoundingBox.Width,
2149cdf0e10cSrcweir mpTop->mnHeight);
2150cdf0e10cSrcweir }
2151cdf0e10cSrcweir if (mpLeft.get() != NULL)
2152cdf0e10cSrcweir {
2153cdf0e10cSrcweir PaintBitmapTiled(
2154cdf0e10cSrcweir mpLeft->GetNormalBitmap(),
2155cdf0e10cSrcweir rxCanvas,
2156cdf0e10cSrcweir rClipBox,
2157cdf0e10cSrcweir rSlideBoundingBox.X - mpLeft->mnWidth,
2158cdf0e10cSrcweir rSlideBoundingBox.Y,
2159cdf0e10cSrcweir mpLeft->mnWidth,
2160cdf0e10cSrcweir rSlideBoundingBox.Height);
2161cdf0e10cSrcweir }
2162cdf0e10cSrcweir if (mpRight.get() != NULL)
2163cdf0e10cSrcweir {
2164cdf0e10cSrcweir PaintBitmapTiled(
2165cdf0e10cSrcweir mpRight->GetNormalBitmap(),
2166cdf0e10cSrcweir rxCanvas,
2167cdf0e10cSrcweir rClipBox,
2168cdf0e10cSrcweir rSlideBoundingBox.X + rSlideBoundingBox.Width,
2169cdf0e10cSrcweir rSlideBoundingBox.Y,
2170cdf0e10cSrcweir mpRight->mnWidth,
2171cdf0e10cSrcweir rSlideBoundingBox.Height);
2172cdf0e10cSrcweir }
2173cdf0e10cSrcweir if (mpBottom.get() != NULL)
2174cdf0e10cSrcweir {
2175cdf0e10cSrcweir PaintBitmapTiled(
2176cdf0e10cSrcweir mpBottom->GetNormalBitmap(),
2177cdf0e10cSrcweir rxCanvas,
2178cdf0e10cSrcweir rClipBox,
2179cdf0e10cSrcweir rSlideBoundingBox.X,
2180cdf0e10cSrcweir rSlideBoundingBox.Y + rSlideBoundingBox.Height,
2181cdf0e10cSrcweir rSlideBoundingBox.Width,
2182cdf0e10cSrcweir mpBottom->mnHeight);
2183cdf0e10cSrcweir }
2184cdf0e10cSrcweir if (mpTopLeft.get() != NULL)
2185cdf0e10cSrcweir {
2186cdf0e10cSrcweir PaintBitmapOnce(
2187cdf0e10cSrcweir mpTopLeft->GetNormalBitmap(),
2188cdf0e10cSrcweir rxCanvas,
2189cdf0e10cSrcweir xClip,
2190cdf0e10cSrcweir rSlideBoundingBox.X - mpTopLeft->mnWidth,
2191cdf0e10cSrcweir rSlideBoundingBox.Y - mpTopLeft->mnHeight);
2192cdf0e10cSrcweir }
2193cdf0e10cSrcweir if (mpTopRight.get() != NULL)
2194cdf0e10cSrcweir {
2195cdf0e10cSrcweir PaintBitmapOnce(
2196cdf0e10cSrcweir mpTopRight->GetNormalBitmap(),
2197cdf0e10cSrcweir rxCanvas,
2198cdf0e10cSrcweir xClip,
2199cdf0e10cSrcweir rSlideBoundingBox.X + rSlideBoundingBox.Width,
2200cdf0e10cSrcweir rSlideBoundingBox.Y - mpTopLeft->mnHeight);
2201cdf0e10cSrcweir }
2202cdf0e10cSrcweir if (mpBottomLeft.get() != NULL)
2203cdf0e10cSrcweir {
2204cdf0e10cSrcweir PaintBitmapOnce(
2205cdf0e10cSrcweir mpBottomLeft->GetNormalBitmap(),
2206cdf0e10cSrcweir rxCanvas,
2207cdf0e10cSrcweir xClip,
2208cdf0e10cSrcweir rSlideBoundingBox.X - mpBottomLeft->mnWidth,
2209cdf0e10cSrcweir rSlideBoundingBox.Y + rSlideBoundingBox.Height);
2210cdf0e10cSrcweir }
2211cdf0e10cSrcweir if (mpBottomRight.get() != NULL)
2212cdf0e10cSrcweir {
2213cdf0e10cSrcweir PaintBitmapOnce(
2214cdf0e10cSrcweir mpBottomRight->GetNormalBitmap(),
2215cdf0e10cSrcweir rxCanvas,
2216cdf0e10cSrcweir xClip,
2217cdf0e10cSrcweir rSlideBoundingBox.X + rSlideBoundingBox.Width,
2218cdf0e10cSrcweir rSlideBoundingBox.Y + rSlideBoundingBox.Height);
2219cdf0e10cSrcweir }
2220cdf0e10cSrcweir }
2221cdf0e10cSrcweir
2222cdf0e10cSrcweir
2223cdf0e10cSrcweir
2224cdf0e10cSrcweir
GetBoundingBox(const awt::Rectangle & rSlideBoundingBox)2225cdf0e10cSrcweir awt::Rectangle PresenterSlideSorter::CurrentSlideFrameRenderer::GetBoundingBox (
2226cdf0e10cSrcweir const awt::Rectangle& rSlideBoundingBox)
2227cdf0e10cSrcweir {
2228cdf0e10cSrcweir return awt::Rectangle(
2229cdf0e10cSrcweir rSlideBoundingBox.X - mnLeftFrameSize,
2230cdf0e10cSrcweir rSlideBoundingBox.Y - mnTopFrameSize,
2231cdf0e10cSrcweir rSlideBoundingBox.Width + mnLeftFrameSize + mnRightFrameSize,
2232cdf0e10cSrcweir rSlideBoundingBox.Height + mnTopFrameSize + mnBottomFrameSize);
2233cdf0e10cSrcweir }
2234cdf0e10cSrcweir
2235cdf0e10cSrcweir
2236cdf0e10cSrcweir
2237cdf0e10cSrcweir
PaintBitmapOnce(const css::uno::Reference<css::rendering::XBitmap> & rxBitmap,const css::uno::Reference<css::rendering::XCanvas> & rxCanvas,const Reference<rendering::XPolyPolygon2D> & rxClip,const double nX,const double nY)2238cdf0e10cSrcweir void PresenterSlideSorter::CurrentSlideFrameRenderer::PaintBitmapOnce(
2239cdf0e10cSrcweir const css::uno::Reference<css::rendering::XBitmap>& rxBitmap,
2240cdf0e10cSrcweir const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
2241cdf0e10cSrcweir const Reference<rendering::XPolyPolygon2D>& rxClip,
2242cdf0e10cSrcweir const double nX,
2243cdf0e10cSrcweir const double nY)
2244cdf0e10cSrcweir {
2245cdf0e10cSrcweir OSL_ASSERT(rxCanvas.is());
2246cdf0e10cSrcweir if ( ! rxBitmap.is())
2247cdf0e10cSrcweir return;
2248cdf0e10cSrcweir
2249cdf0e10cSrcweir const rendering::ViewState aViewState(
2250cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,0, 0,1,0),
2251cdf0e10cSrcweir rxClip);
2252cdf0e10cSrcweir
2253cdf0e10cSrcweir const rendering::RenderState aRenderState (
2254cdf0e10cSrcweir geometry::AffineMatrix2D(
2255cdf0e10cSrcweir 1, 0, nX,
2256cdf0e10cSrcweir 0, 1, nY),
2257cdf0e10cSrcweir NULL,
2258cdf0e10cSrcweir Sequence<double>(4),
2259cdf0e10cSrcweir rendering::CompositeOperation::SOURCE);
2260cdf0e10cSrcweir
2261cdf0e10cSrcweir rxCanvas->drawBitmap(
2262cdf0e10cSrcweir rxBitmap,
2263cdf0e10cSrcweir aViewState,
2264cdf0e10cSrcweir aRenderState);
2265cdf0e10cSrcweir }
2266cdf0e10cSrcweir
2267cdf0e10cSrcweir
2268cdf0e10cSrcweir
2269cdf0e10cSrcweir
PaintBitmapTiled(const css::uno::Reference<css::rendering::XBitmap> & rxBitmap,const css::uno::Reference<css::rendering::XCanvas> & rxCanvas,const geometry::RealRectangle2D & rClipBox,const double nX0,const double nY0,const double nWidth,const double nHeight)2270cdf0e10cSrcweir void PresenterSlideSorter::CurrentSlideFrameRenderer::PaintBitmapTiled(
2271cdf0e10cSrcweir const css::uno::Reference<css::rendering::XBitmap>& rxBitmap,
2272cdf0e10cSrcweir const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
2273cdf0e10cSrcweir const geometry::RealRectangle2D& rClipBox,
2274cdf0e10cSrcweir const double nX0,
2275cdf0e10cSrcweir const double nY0,
2276cdf0e10cSrcweir const double nWidth,
2277cdf0e10cSrcweir const double nHeight)
2278cdf0e10cSrcweir {
2279cdf0e10cSrcweir OSL_ASSERT(rxCanvas.is());
2280cdf0e10cSrcweir if ( ! rxBitmap.is())
2281cdf0e10cSrcweir return;
2282cdf0e10cSrcweir
2283cdf0e10cSrcweir geometry::IntegerSize2D aSize (rxBitmap->getSize());
2284cdf0e10cSrcweir
2285cdf0e10cSrcweir const rendering::ViewState aViewState(
2286cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,0, 0,1,0),
2287cdf0e10cSrcweir PresenterGeometryHelper::CreatePolygon(
2288cdf0e10cSrcweir PresenterGeometryHelper::Intersection(
2289cdf0e10cSrcweir rClipBox,
2290cdf0e10cSrcweir geometry::RealRectangle2D(nX0,nY0,nX0+nWidth,nY0+nHeight)),
2291cdf0e10cSrcweir rxCanvas->getDevice()));
2292cdf0e10cSrcweir
2293cdf0e10cSrcweir rendering::RenderState aRenderState (
2294cdf0e10cSrcweir geometry::AffineMatrix2D(
2295cdf0e10cSrcweir 1, 0, nX0,
2296cdf0e10cSrcweir 0, 1, nY0),
2297cdf0e10cSrcweir NULL,
2298cdf0e10cSrcweir Sequence<double>(4),
2299cdf0e10cSrcweir rendering::CompositeOperation::SOURCE);
2300cdf0e10cSrcweir
2301cdf0e10cSrcweir const double nX1 = nX0 + nWidth;
2302cdf0e10cSrcweir const double nY1 = nY0 + nHeight;
2303cdf0e10cSrcweir for (double nY=nY0; nY<nY1; nY+=aSize.Height)
2304cdf0e10cSrcweir for (double nX=nX0; nX<nX1; nX+=aSize.Width)
2305cdf0e10cSrcweir {
2306cdf0e10cSrcweir aRenderState.AffineTransform.m02 = nX;
2307cdf0e10cSrcweir aRenderState.AffineTransform.m12 = nY;
2308cdf0e10cSrcweir rxCanvas->drawBitmap(
2309cdf0e10cSrcweir rxBitmap,
2310cdf0e10cSrcweir aViewState,
2311cdf0e10cSrcweir aRenderState);
2312cdf0e10cSrcweir }
2313cdf0e10cSrcweir }
2314cdf0e10cSrcweir
2315cdf0e10cSrcweir } } // end of namespace ::sdext::presenter
2316