summaryrefslogtreecommitdiff
path: root/sd/source/ui/presenter
diff options
context:
space:
mode:
Diffstat (limited to 'sd/source/ui/presenter')
-rw-r--r--sd/source/ui/presenter/CanvasUpdateRequester.cxx130
-rw-r--r--sd/source/ui/presenter/CanvasUpdateRequester.hxx83
-rw-r--r--sd/source/ui/presenter/PresenterCanvas.cxx1231
-rw-r--r--sd/source/ui/presenter/PresenterCanvas.hxx447
-rw-r--r--sd/source/ui/presenter/PresenterCanvasFactory.cxx310
-rw-r--r--sd/source/ui/presenter/PresenterHelper.cxx346
-rw-r--r--sd/source/ui/presenter/PresenterHelper.hxx123
-rw-r--r--sd/source/ui/presenter/PresenterPreviewCache.cxx519
-rw-r--r--sd/source/ui/presenter/PresenterPreviewCache.hxx125
-rw-r--r--sd/source/ui/presenter/PresenterTextView.cxx648
-rw-r--r--sd/source/ui/presenter/PresenterTextView.hxx92
-rw-r--r--sd/source/ui/presenter/SlideRenderer.cxx274
-rw-r--r--sd/source/ui/presenter/SlideRenderer.hxx111
-rw-r--r--sd/source/ui/presenter/makefile.mk56
14 files changed, 4495 insertions, 0 deletions
diff --git a/sd/source/ui/presenter/CanvasUpdateRequester.cxx b/sd/source/ui/presenter/CanvasUpdateRequester.cxx
new file mode 100644
index 000000000000..ae37ff945061
--- /dev/null
+++ b/sd/source/ui/presenter/CanvasUpdateRequester.cxx
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_sd.hxx"
+
+#include "CanvasUpdateRequester.hxx"
+#include <vcl/svapp.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+namespace sd { namespace presenter {
+
+//===== CanvasUpdateRequester::Deleter ========================================
+
+class CanvasUpdateRequester::Deleter
+{
+public:
+ void operator() (CanvasUpdateRequester* pObject) { delete pObject; }
+};
+
+
+
+
+//===== CanvasUpdateRequester =================================================
+
+CanvasUpdateRequester::RequesterMap CanvasUpdateRequester::maRequesterMap;
+
+::boost::shared_ptr<CanvasUpdateRequester> CanvasUpdateRequester::Instance (
+ const Reference<rendering::XSpriteCanvas>& rxSharedCanvas)
+{
+ RequesterMap::const_iterator iRequester;
+ for (iRequester=maRequesterMap.begin(); iRequester!=maRequesterMap.end(); ++iRequester)
+ {
+ if (iRequester->first == rxSharedCanvas)
+ return iRequester->second;
+ }
+
+ // No requester for the given canvas found. Create a new one.
+ ::boost::shared_ptr<CanvasUpdateRequester> pRequester (
+ new CanvasUpdateRequester(rxSharedCanvas), Deleter());
+ maRequesterMap.push_back(RequesterMap::value_type(rxSharedCanvas,pRequester));
+ return pRequester;
+}
+
+
+
+
+CanvasUpdateRequester::CanvasUpdateRequester (
+ const Reference<rendering::XSpriteCanvas>& rxCanvas)
+ : mxCanvas(rxCanvas),
+ mnUserEventId(0),
+ mbUpdateFlag(sal_False)
+{
+ Reference<lang::XComponent> xComponent (mxCanvas, UNO_QUERY);
+ if (xComponent.is())
+ {
+ //xComponent->addEventListener(this);
+ }
+}
+
+
+
+
+CanvasUpdateRequester::~CanvasUpdateRequester (void)
+{
+ if (mnUserEventId != 0)
+ Application::RemoveUserEvent(mnUserEventId);
+}
+
+
+
+
+void CanvasUpdateRequester::RequestUpdate (const sal_Bool bUpdateAll)
+{
+ if (mnUserEventId == 0)
+ {
+ mbUpdateFlag = bUpdateAll;
+ mnUserEventId = Application::PostUserEvent(LINK(this, CanvasUpdateRequester, Callback));
+ }
+ else
+ {
+ mbUpdateFlag |= bUpdateAll;
+ }
+}
+
+
+
+IMPL_LINK(CanvasUpdateRequester, Callback, void*, EMPTYARG)
+{
+ mnUserEventId = 0;
+ if (mxCanvas.is())
+ {
+ mxCanvas->updateScreen(mbUpdateFlag);
+ mbUpdateFlag = sal_False;
+ }
+ return 0;
+}
+
+
+} } // end of namespace ::sd::presenter
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/presenter/CanvasUpdateRequester.hxx b/sd/source/ui/presenter/CanvasUpdateRequester.hxx
new file mode 100644
index 000000000000..6ea1d3a5ec0a
--- /dev/null
+++ b/sd/source/ui/presenter/CanvasUpdateRequester.hxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SD_PRESENTER_CANVAS_UPDATE_REQUESTER_HEADER
+#define SD_PRESENTER_CANVAS_UPDATE_REQUESTER_HEADER
+
+#include "precompiled_sd.hxx"
+
+#include <com/sun/star/rendering/XSpriteCanvas.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/shared_ptr.hpp>
+#include <sal/types.h>
+#include <tools/solar.h>
+#include <tools/link.hxx>
+#include <vector>
+
+namespace css = ::com::sun::star;
+
+namespace sd { namespace presenter {
+
+/** Each UpdateRequester handles update requests (calls to
+ XCanvas::updateScreen()) for one shared canvas (a canvas that has one or
+ more PresenterCanvas wrappers). Multiple calls are collected and lead
+ to a single call to updateScreen.
+*/
+class CanvasUpdateRequester : private ::boost::noncopyable
+{
+public:
+ /** Return the Canvas UpdateRequester object for the given shared
+ canvas. A new object is created when it does not already exist.
+ */
+ static ::boost::shared_ptr<CanvasUpdateRequester> Instance (
+ const css::uno::Reference<css::rendering::XSpriteCanvas>& rxCanvas);
+
+ void RequestUpdate (const sal_Bool bUpdateAll);
+
+private:
+ CanvasUpdateRequester (const css::uno::Reference<css::rendering::XSpriteCanvas>& rxCanvas);
+ ~CanvasUpdateRequester (void);
+ class Deleter; friend class Deleter;
+
+ typedef ::std::vector<
+ ::std::pair<
+ css::uno::Reference<css::rendering::XSpriteCanvas>,
+ ::boost::shared_ptr<CanvasUpdateRequester> > > RequesterMap;
+ static RequesterMap maRequesterMap;
+
+ css::uno::Reference<css::rendering::XSpriteCanvas> mxCanvas;
+ sal_uLong mnUserEventId;
+ sal_Bool mbUpdateFlag;
+ DECL_LINK(Callback, void*);
+};
+
+} } // end of namespace ::sd::presenter
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/presenter/PresenterCanvas.cxx b/sd/source/ui/presenter/PresenterCanvas.cxx
new file mode 100644
index 000000000000..f00bf1f00ab9
--- /dev/null
+++ b/sd/source/ui/presenter/PresenterCanvas.cxx
@@ -0,0 +1,1231 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_sd.hxx"
+
+#include "PresenterCanvas.hxx"
+
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolygonclipper.hxx>
+#include <basegfx/range/b2drectangle.hxx>
+#include <basegfx/tools/canvastools.hxx>
+#include <canvas/canvastools.hxx>
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/compbase1.hxx>
+#include <rtl/ref.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/window.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+namespace sd { namespace presenter {
+
+//===== Service ===============================================================
+
+Reference<XInterface> SAL_CALL PresenterCanvas_createInstance (
+ const Reference<XComponentContext>& rxContext)
+{
+ (void)rxContext;
+ return Reference<XInterface>(static_cast<XWeak*>(new PresenterCanvas()));
+}
+
+
+
+
+::rtl::OUString PresenterCanvas_getImplementationName (void) throw(RuntimeException)
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Draw.PresenterCanvasFactory"));
+}
+
+
+
+
+Sequence<rtl::OUString> SAL_CALL PresenterCanvas_getSupportedServiceNames (void)
+ throw (RuntimeException)
+{
+ static const ::rtl::OUString sServiceName(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.rendering.Canvas")));
+ return Sequence<rtl::OUString>(&sServiceName, 1);
+}
+
+
+
+
+//===== PresenterCustomSprite =================================================
+
+/** Wrapper around a sprite that is displayed on a PresenterCanvas.
+*/
+namespace {
+ typedef ::cppu::WeakComponentImplHelper1 <
+ css::rendering::XCustomSprite
+ > PresenterCustomSpriteInterfaceBase;
+}
+class PresenterCustomSprite
+ : private ::boost::noncopyable,
+ protected ::cppu::BaseMutex,
+ public PresenterCustomSpriteInterfaceBase
+{
+public:
+ PresenterCustomSprite (
+ const rtl::Reference<PresenterCanvas>& rpCanvas,
+ const Reference<rendering::XCustomSprite>& rxSprite,
+ const Reference<awt::XWindow>& rxBaseWindow,
+ const css::geometry::RealSize2D& rSpriteSize);
+ virtual ~PresenterCustomSprite (void);
+ virtual void SAL_CALL disposing (void)
+ throw (RuntimeException);
+
+ // XSprite
+
+ virtual void SAL_CALL setAlpha (double nAlpha)
+ throw (lang::IllegalArgumentException,RuntimeException);
+
+ virtual void SAL_CALL move (const geometry::RealPoint2D& rNewPos,
+ const rendering::ViewState& rViewState,
+ const rendering::RenderState& rRenderState)
+ throw (lang::IllegalArgumentException,RuntimeException);
+
+ virtual void SAL_CALL transform (const geometry::AffineMatrix2D& rTransformation)
+ throw (lang::IllegalArgumentException,RuntimeException);
+
+ virtual void SAL_CALL clip (const Reference<rendering::XPolyPolygon2D>& rClip)
+ throw (RuntimeException);
+
+ virtual void SAL_CALL setPriority (double nPriority)
+ throw (RuntimeException);
+
+ virtual void SAL_CALL show (void)
+ throw (RuntimeException);
+
+ virtual void SAL_CALL hide (void)
+ throw (RuntimeException);
+
+
+ // XCustomSprite
+
+ virtual Reference<rendering::XCanvas> SAL_CALL getContentCanvas (void)
+ throw (RuntimeException);
+
+private:
+ rtl::Reference<PresenterCanvas> mpCanvas;
+ Reference<rendering::XCustomSprite> mxSprite;
+ Reference<awt::XWindow> mxBaseWindow;
+ geometry::RealPoint2D maPosition;
+ geometry::RealSize2D maSpriteSize;
+
+ void ThrowIfDisposed (void)
+ throw (css::lang::DisposedException);
+};
+
+
+
+
+//===== PresenterCanvas =======================================================
+
+
+PresenterCanvas::PresenterCanvas (void)
+ : PresenterCanvasInterfaceBase(m_aMutex),
+ mxUpdateCanvas(),
+ mxSharedCanvas(),
+ mxSharedWindow(),
+ mxWindow(),
+ maOffset(),
+ mpUpdateRequester(),
+ maClipRectangle(),
+ mbOffsetUpdatePending(true)
+{
+}
+
+
+
+
+PresenterCanvas::PresenterCanvas (
+ const Reference<rendering::XSpriteCanvas>& rxUpdateCanvas,
+ const Reference<awt::XWindow>& rxUpdateWindow,
+ const Reference<rendering::XCanvas>& rxSharedCanvas,
+ const Reference<awt::XWindow>& rxSharedWindow,
+ const Reference<awt::XWindow>& rxWindow)
+ : PresenterCanvasInterfaceBase(m_aMutex),
+ mxUpdateCanvas(rxUpdateCanvas),
+ mxUpdateWindow(rxUpdateWindow),
+ mxSharedCanvas(rxSharedCanvas),
+ mxSharedWindow(rxSharedWindow),
+ mxWindow(rxWindow),
+ maOffset(),
+ mpUpdateRequester(),
+ maClipRectangle(),
+ mbOffsetUpdatePending(true)
+{
+ if (mxWindow.is())
+ mxWindow->addWindowListener(this);
+
+ if (mxUpdateCanvas.is())
+ mpUpdateRequester = CanvasUpdateRequester::Instance(mxUpdateCanvas);
+}
+
+
+
+
+PresenterCanvas::~PresenterCanvas (void)
+{
+}
+
+
+
+
+void SAL_CALL PresenterCanvas::disposing (void)
+ throw (css::uno::RuntimeException)
+{
+ if (mxWindow.is())
+ mxWindow->removeWindowListener(this);
+}
+
+
+
+
+//----- XInitialization -------------------------------------------------------
+
+void SAL_CALL PresenterCanvas::initialize (
+ const Sequence<Any>& rArguments)
+ throw(Exception, RuntimeException)
+{
+ if (rBHelper.bDisposed || rBHelper.bInDispose)
+ ThrowIfDisposed();
+
+ if (rArguments.getLength() == 5)
+ {
+ try
+ {
+ // First and second argument may be NULL.
+ rArguments[0] >>= mxUpdateCanvas;
+ rArguments[1] >>= mxUpdateWindow;
+
+ if ( ! (rArguments[2] >>= mxSharedWindow))
+ {
+ throw lang::IllegalArgumentException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("PresenterCanvas: invalid shared window")),
+ static_cast<XWeak*>(this),
+ 1);
+ }
+
+ if ( ! (rArguments[3] >>= mxSharedCanvas))
+ {
+ throw lang::IllegalArgumentException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("PresenterCanvas: invalid shared canvas")),
+ static_cast<XWeak*>(this),
+ 2);
+ }
+
+ if ( ! (rArguments[4] >>= mxWindow))
+ {
+ throw lang::IllegalArgumentException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("PresenterCanvas: invalid window")),
+ static_cast<XWeak*>(this),
+ 3);
+ }
+
+ mpUpdateRequester = CanvasUpdateRequester::Instance(mxUpdateCanvas);
+
+ mbOffsetUpdatePending = true;
+ if (mxWindow.is())
+ mxWindow->addWindowListener(this);
+ }
+ catch (RuntimeException&)
+ {
+ mxSharedWindow = NULL;
+ mxWindow = NULL;
+ throw;
+ }
+ }
+ else
+ {
+ throw RuntimeException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("PresenterCanvas: invalid number of arguments")),
+ static_cast<XWeak*>(this));
+ }
+}
+
+
+
+
+//----- XCanvas ---------------------------------------------------------------
+
+void SAL_CALL PresenterCanvas::clear (void)
+ throw (css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ // ToDo: Clear the area covered by the child window. A simple forward
+ // would clear the whole shared canvas.
+}
+
+
+
+
+void SAL_CALL PresenterCanvas::drawPoint (
+ const css::geometry::RealPoint2D& aPoint,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ mxSharedCanvas->drawPoint(aPoint,MergeViewState(aViewState),aRenderState);
+}
+
+
+
+
+void SAL_CALL PresenterCanvas::drawLine (
+ const css::geometry::RealPoint2D& aStartPoint,
+ const css::geometry::RealPoint2D& aEndPoint,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ mxSharedCanvas->drawLine(aStartPoint,aEndPoint,MergeViewState(aViewState),aRenderState);
+}
+
+
+
+
+void SAL_CALL PresenterCanvas::drawBezier (
+ const css::geometry::RealBezierSegment2D& aBezierSegment,
+ const css::geometry::RealPoint2D& aEndPoint,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ mxSharedCanvas->drawBezier(aBezierSegment,aEndPoint,MergeViewState(aViewState),aRenderState);
+}
+
+
+
+
+css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL PresenterCanvas::drawPolyPolygon (
+ const css::uno::Reference< css::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->drawPolyPolygon(
+ xPolyPolygon, MergeViewState(aViewState), aRenderState);
+}
+
+
+
+
+css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL PresenterCanvas::strokePolyPolygon (
+ const css::uno::Reference< css::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState,
+ const css::rendering::StrokeAttributes& aStrokeAttributes)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->strokePolyPolygon(
+ xPolyPolygon, MergeViewState(aViewState), aRenderState, aStrokeAttributes);
+}
+
+
+
+
+css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ PresenterCanvas::strokeTexturedPolyPolygon (
+ const css::uno::Reference< css::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState,
+ const css::uno::Sequence< css::rendering::Texture >& aTextures,
+ const css::rendering::StrokeAttributes& aStrokeAttributes)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->strokeTexturedPolyPolygon(
+ xPolyPolygon, MergeViewState(aViewState), aRenderState, aTextures, aStrokeAttributes);
+}
+
+
+
+
+css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ PresenterCanvas::strokeTextureMappedPolyPolygon(
+ const css::uno::Reference<css::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState,
+ const css::uno::Sequence<css::rendering::Texture>& aTextures,
+ const css::uno::Reference<css::geometry::XMapping2D>& xMapping,
+ const css::rendering::StrokeAttributes& aStrokeAttributes)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->strokeTextureMappedPolyPolygon(
+ xPolyPolygon,
+ MergeViewState(aViewState),
+ aRenderState,
+ aTextures,
+ xMapping,
+ aStrokeAttributes);
+}
+
+
+
+
+css::uno::Reference<css::rendering::XPolyPolygon2D> SAL_CALL
+ PresenterCanvas::queryStrokeShapes(
+ const css::uno::Reference<css::rendering::XPolyPolygon2D>& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState,
+ const css::rendering::StrokeAttributes& aStrokeAttributes)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->queryStrokeShapes(
+ xPolyPolygon, MergeViewState(aViewState), aRenderState, aStrokeAttributes);
+}
+
+
+
+
+css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ PresenterCanvas::fillPolyPolygon(
+ const css::uno::Reference<css::rendering::XPolyPolygon2D>& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException,
+ css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->fillPolyPolygon(
+ xPolyPolygon, MergeViewState(aViewState), aRenderState);
+}
+
+
+
+
+css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ PresenterCanvas::fillTexturedPolyPolygon(
+ const css::uno::Reference<css::rendering::XPolyPolygon2D>& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState,
+ const css::uno::Sequence<css::rendering::Texture>& xTextures)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->fillTexturedPolyPolygon(
+ xPolyPolygon, MergeViewState(aViewState), aRenderState, xTextures);
+}
+
+
+
+
+css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ PresenterCanvas::fillTextureMappedPolyPolygon(
+ const css::uno::Reference< css::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState,
+ const css::uno::Sequence< css::rendering::Texture >& xTextures,
+ const css::uno::Reference< css::geometry::XMapping2D >& xMapping)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->fillTextureMappedPolyPolygon(
+ xPolyPolygon, MergeViewState(aViewState), aRenderState, xTextures, xMapping);
+}
+
+
+
+
+css::uno::Reference<css::rendering::XCanvasFont> SAL_CALL
+ PresenterCanvas::createFont(
+ const css::rendering::FontRequest& aFontRequest,
+ const css::uno::Sequence< css::beans::PropertyValue >& aExtraFontProperties,
+ const css::geometry::Matrix2D& aFontMatrix)
+ throw (css::lang::IllegalArgumentException,
+ css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->createFont(
+ aFontRequest, aExtraFontProperties, aFontMatrix);
+}
+
+
+
+
+css::uno::Sequence<css::rendering::FontInfo> SAL_CALL
+ PresenterCanvas::queryAvailableFonts(
+ const css::rendering::FontInfo& aFilter,
+ const css::uno::Sequence< css::beans::PropertyValue >& aFontProperties)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->queryAvailableFonts(aFilter, aFontProperties);
+}
+
+
+
+
+css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ PresenterCanvas::drawText(
+ const css::rendering::StringContext& aText,
+ const css::uno::Reference< css::rendering::XCanvasFont >& xFont,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState,
+ ::sal_Int8 nTextDirection)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->drawText(
+ aText, xFont, MergeViewState(aViewState), aRenderState, nTextDirection);
+}
+
+
+
+
+css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ PresenterCanvas::drawTextLayout(
+ const css::uno::Reference< css::rendering::XTextLayout >& xLayoutetText,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->drawTextLayout(
+ xLayoutetText, MergeViewState(aViewState), aRenderState);
+}
+
+
+
+
+css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ PresenterCanvas::drawBitmap(
+ const css::uno::Reference< css::rendering::XBitmap >& xBitmap,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->drawBitmap(
+ xBitmap, MergeViewState(aViewState), aRenderState);
+}
+
+
+
+
+css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ PresenterCanvas::drawBitmapModulated(
+ const css::uno::Reference< css::rendering::XBitmap>& xBitmap,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->drawBitmapModulated(
+ xBitmap, MergeViewState(aViewState), aRenderState);
+}
+
+
+
+
+css::uno::Reference<css::rendering::XGraphicDevice> SAL_CALL
+ PresenterCanvas::getDevice (void)
+ throw (css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSharedCanvas->getDevice();
+}
+
+
+
+
+//----- XBitmapCanvas ---------------------------------------------------------
+
+void SAL_CALL PresenterCanvas::copyRect(
+ const css::uno::Reference<css::rendering::XBitmapCanvas>& rxSourceCanvas,
+ const css::geometry::RealRectangle2D& rSourceRect,
+ const css::rendering::ViewState& rSourceViewState,
+ const css::rendering::RenderState& rSourceRenderState,
+ const css::geometry::RealRectangle2D& rDestRect,
+ const css::rendering::ViewState& rDestViewState,
+ const css::rendering::RenderState& rDestRenderState)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+
+ Reference<rendering::XBitmapCanvas> xBitmapCanvas (mxSharedCanvas, UNO_QUERY);
+ if (xBitmapCanvas.is())
+ {
+ rendering::ViewState aSourceViewState (rSourceViewState);
+ if (rxSourceCanvas == Reference<rendering::XCanvas>(this))
+ aSourceViewState = MergeViewState(aSourceViewState);
+ xBitmapCanvas->copyRect(
+ rxSourceCanvas, rSourceRect, aSourceViewState, rSourceRenderState,
+ rDestRect, MergeViewState(rDestViewState), rDestRenderState);
+ }
+}
+
+
+
+
+//----- XSpriteCanvas ---------------------------------------------------------
+
+Reference<rendering::XAnimatedSprite> SAL_CALL
+ PresenterCanvas::createSpriteFromAnimation (
+ const css::uno::Reference<css::rendering::XAnimation>& rAnimation)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+
+ Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxSharedCanvas, UNO_QUERY);
+ if (xSpriteCanvas.is())
+ return xSpriteCanvas->createSpriteFromAnimation(rAnimation);
+ else
+ return NULL;
+}
+
+
+
+
+Reference<rendering::XAnimatedSprite> SAL_CALL
+ PresenterCanvas::createSpriteFromBitmaps (
+ const css::uno::Sequence<
+ css::uno::Reference< css::rendering::XBitmap > >& rAnimationBitmaps,
+ ::sal_Int8 nInterpolationMode)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+
+ Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxSharedCanvas, UNO_QUERY);
+ if (xSpriteCanvas.is())
+ return xSpriteCanvas->createSpriteFromBitmaps(rAnimationBitmaps, nInterpolationMode);
+ else
+ return NULL;
+}
+
+
+
+
+Reference<rendering::XCustomSprite> SAL_CALL
+ PresenterCanvas::createCustomSprite (
+ const css::geometry::RealSize2D& rSpriteSize)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+
+ Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxSharedCanvas, UNO_QUERY);
+ if (xSpriteCanvas.is())
+ return new PresenterCustomSprite(
+ this,
+ xSpriteCanvas->createCustomSprite(rSpriteSize),
+ mxSharedWindow,
+ rSpriteSize);
+ else if (mxUpdateCanvas.is())
+ return new PresenterCustomSprite(
+ this,
+ mxUpdateCanvas->createCustomSprite(rSpriteSize),
+ mxUpdateWindow,
+ rSpriteSize);
+ else
+ return NULL;
+}
+
+
+
+
+Reference<rendering::XSprite> SAL_CALL
+ PresenterCanvas::createClonedSprite (
+ const css::uno::Reference< css::rendering::XSprite >& rxOriginal)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+
+ Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxSharedCanvas, UNO_QUERY);
+ if (xSpriteCanvas.is())
+ return xSpriteCanvas->createClonedSprite(rxOriginal);
+ if (mxUpdateCanvas.is())
+ return mxUpdateCanvas->createClonedSprite(rxOriginal);
+ return NULL;
+}
+
+
+
+
+::sal_Bool SAL_CALL PresenterCanvas::updateScreen (::sal_Bool bUpdateAll)
+ throw (css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+
+ mbOffsetUpdatePending = true;
+ if (mpUpdateRequester.get() != NULL)
+ {
+ mpUpdateRequester->RequestUpdate(bUpdateAll);
+ return sal_True;
+ }
+ else
+ {
+ return sal_False;
+ }
+}
+
+
+
+
+//----- XEventListener --------------------------------------------------------
+
+void SAL_CALL PresenterCanvas::disposing (const css::lang::EventObject& rEvent)
+ throw (css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ if (rEvent.Source == mxWindow)
+ mxWindow = NULL;
+}
+
+
+
+
+//----- XWindowListener -------------------------------------------------------
+
+void SAL_CALL PresenterCanvas::windowResized (const css::awt::WindowEvent& rEvent)
+ throw (css::uno::RuntimeException)
+{
+ (void)rEvent;
+ ThrowIfDisposed();
+ mbOffsetUpdatePending = true;
+}
+
+
+
+
+void SAL_CALL PresenterCanvas::windowMoved (const css::awt::WindowEvent& rEvent)
+ throw (css::uno::RuntimeException)
+{
+ (void)rEvent;
+ ThrowIfDisposed();
+ mbOffsetUpdatePending = true;
+}
+
+
+
+
+void SAL_CALL PresenterCanvas::windowShown (const css::lang::EventObject& rEvent)
+ throw (css::uno::RuntimeException)
+{
+ (void)rEvent;
+ ThrowIfDisposed();
+ mbOffsetUpdatePending = true;
+}
+
+
+
+
+void SAL_CALL PresenterCanvas::windowHidden (const css::lang::EventObject& rEvent)
+ throw (css::uno::RuntimeException)
+{
+ (void)rEvent;
+ ThrowIfDisposed();
+}
+
+
+
+
+//----- XBitmap ---------------------------------------------------------------
+
+geometry::IntegerSize2D SAL_CALL PresenterCanvas::getSize (void)
+ throw (RuntimeException)
+{
+ ThrowIfDisposed();
+
+ if (mxWindow.is())
+ {
+ const awt::Rectangle aWindowBox (mxWindow->getPosSize());
+ return geometry::IntegerSize2D(aWindowBox.Width, aWindowBox.Height);
+ }
+ else
+ return geometry::IntegerSize2D(0,0);
+}
+
+
+
+
+sal_Bool SAL_CALL PresenterCanvas::hasAlpha (void)
+ throw (RuntimeException)
+{
+ Reference<rendering::XBitmap> xBitmap (mxSharedCanvas, UNO_QUERY);
+ if (xBitmap.is())
+ return xBitmap->hasAlpha();
+ else
+ return sal_False;
+}
+
+
+
+
+Reference<rendering::XBitmapCanvas> SAL_CALL PresenterCanvas::queryBitmapCanvas (void)
+ throw (RuntimeException)
+{
+ ThrowIfDisposed();
+
+ return this;
+}
+
+
+
+
+Reference<rendering::XBitmap> SAL_CALL PresenterCanvas::getScaledBitmap(
+ const css::geometry::RealSize2D& rNewSize,
+ sal_Bool bFast)
+ throw (css::uno::RuntimeException,
+ css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException)
+{
+ (void)rNewSize;
+ (void)bFast;
+
+ ThrowIfDisposed();
+
+ // Not implemented.
+
+ return NULL;
+}
+
+
+
+
+//-----------------------------------------------------------------------------
+
+rendering::ViewState PresenterCanvas::MergeViewState (
+ const rendering::ViewState& rViewState)
+{
+ // Make sure the offset is up-to-date.
+ if (mbOffsetUpdatePending)
+ maOffset = GetOffset(mxSharedWindow);
+ return MergeViewState(rViewState, maOffset);
+}
+
+
+
+
+css::rendering::ViewState PresenterCanvas::MergeViewState (
+ const css::rendering::ViewState& rViewState,
+ const css::awt::Point& rOffset)
+{
+ // Early rejects.
+ if ( ! mxSharedCanvas.is())
+ return rViewState;
+
+ Reference<rendering::XGraphicDevice> xDevice (mxSharedCanvas->getDevice());
+ if ( ! xDevice.is())
+ return rViewState;
+
+ // Create a modifiable copy of the given view state.
+ rendering::ViewState aViewState (rViewState);
+
+ // Prepare the local clip rectangle.
+ ::basegfx::B2DRectangle aWindowRange (GetClipRectangle(aViewState.AffineTransform, rOffset));
+
+ // Adapt the offset of the view state.
+ aViewState.AffineTransform.m02 += rOffset.X;
+ aViewState.AffineTransform.m12 += rOffset.Y;
+
+ // Adapt the clip polygon.
+ if ( ! aViewState.Clip.is())
+ {
+ // Cancel out the later multiplication with the view state
+ // transformation.
+ aViewState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
+ xDevice,
+ ::basegfx::B2DPolyPolygon(::basegfx::tools::createPolygonFromRect(aWindowRange)));
+ }
+ else
+ {
+ // Have to compute the intersection of the given clipping polygon in
+ // the view state and the local clip rectangle.
+
+ // Clip the view state clipping polygon against the local clip rectangle.
+ const ::basegfx::B2DPolyPolygon aClipPolygon (
+ ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(
+ aViewState.Clip));
+ const ::basegfx::B2DPolyPolygon aClippedClipPolygon (
+ ::basegfx::tools::clipPolyPolygonOnRange(
+ aClipPolygon,
+ aWindowRange,
+ true, /* bInside */
+ false /* bStroke */));
+
+ aViewState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
+ xDevice,
+ aClippedClipPolygon);
+ }
+
+ return aViewState;
+}
+
+
+
+
+awt::Point PresenterCanvas::GetOffset (const Reference<awt::XWindow>& rxBaseWindow)
+{
+ mbOffsetUpdatePending = false;
+ if (mxWindow.is() && rxBaseWindow.is())
+ {
+ ::Window* pWindow = VCLUnoHelper::GetWindow(mxWindow);
+ ::Window* pSharedWindow = VCLUnoHelper::GetWindow(rxBaseWindow);
+ if (pWindow!=NULL && pSharedWindow!=NULL)
+ {
+ Rectangle aBox = pWindow->GetWindowExtentsRelative(pSharedWindow);
+
+ // Calculate offset of this canvas with respect to the shared
+ // canvas.
+ return awt::Point(aBox.Left(), aBox.Top());
+ }
+ }
+
+ return awt::Point(0, 0);
+}
+
+
+
+
+::basegfx::B2DRectangle PresenterCanvas::GetClipRectangle (
+ const css::geometry::AffineMatrix2D& rViewTransform,
+ const awt::Point& rOffset)
+{
+ ::basegfx::B2DRectangle aClipRectangle;
+
+ ::Window* pWindow = VCLUnoHelper::GetWindow(mxWindow);
+ if (pWindow == NULL)
+ return ::basegfx::B2DRectangle();
+
+ ::Window* pSharedWindow = VCLUnoHelper::GetWindow(mxSharedWindow);
+ if (pSharedWindow == NULL)
+ return ::basegfx::B2DRectangle();
+
+ // Get the bounding box of the window and create a range in the
+ // coordinate system of the child window.
+ Rectangle aLocalClip;
+ if (maClipRectangle.Width <= 0 || maClipRectangle.Height <= 0)
+ {
+ // No clip rectangle has been set via SetClip by the pane.
+ // Use the window extents instead.
+ aLocalClip = pWindow->GetWindowExtentsRelative(pSharedWindow);
+ }
+ else
+ {
+ // Use a previously given clip rectangle.
+ aLocalClip = Rectangle(
+ maClipRectangle.X + rOffset.X,
+ maClipRectangle.Y + rOffset.Y,
+ maClipRectangle.X + maClipRectangle.Width + rOffset.X,
+ maClipRectangle.Y + maClipRectangle.Height + rOffset.Y);
+ }
+
+ // The local clip rectangle is used to clip the view state clipping
+ // polygon.
+ ::basegfx::B2DRectangle aWindowRectangle (
+ aLocalClip.Left() - rOffset.X,
+ aLocalClip.Top() - rOffset.Y,
+ aLocalClip.Right() - rOffset.X + 1,
+ aLocalClip.Bottom() - rOffset.Y + 1);
+
+ // Calculate the inverted view state transformation to cancel out a
+ // later transformation of the local clip polygon with the view state
+ // transformation.
+ ::basegfx::B2DHomMatrix aInvertedViewStateTransformation;
+ ::basegfx::unotools::homMatrixFromAffineMatrix(
+ aInvertedViewStateTransformation,
+ rViewTransform);
+ if (aInvertedViewStateTransformation.invert())
+ {
+ // Cancel out the later multiplication with the view state
+ // transformation.
+ aWindowRectangle.transform(aInvertedViewStateTransformation);
+ }
+
+ return aWindowRectangle;
+}
+
+
+
+Reference<rendering::XPolyPolygon2D> PresenterCanvas::UpdateSpriteClip (
+ const Reference<rendering::XPolyPolygon2D>& rxOriginalClip,
+ const geometry::RealPoint2D& rLocation,
+ const geometry::RealSize2D& rSize)
+{
+ (void)rSize;
+
+ // Check used resources and just return the original clip when not
+ // every one of them is available.
+ if ( ! mxWindow.is())
+ return rxOriginalClip;
+
+ Reference<rendering::XGraphicDevice> xDevice (mxSharedCanvas->getDevice());
+ if ( ! xDevice.is())
+ return rxOriginalClip;
+
+ // Determine the bounds of the clip rectangle (the window border) in the
+ // coordinate system of the sprite.
+ const awt::Rectangle aWindowBox (mxWindow->getPosSize());
+ const double nMinX (-rLocation.X);
+ const double nMinY (-rLocation.Y);
+ const double nMaxX (aWindowBox.Width-rLocation.X);
+ const double nMaxY (aWindowBox.Height-rLocation.Y);
+
+ // Create a clip polygon.
+ Reference<rendering::XPolyPolygon2D> xPolygon;
+ if (rxOriginalClip.is())
+ {
+ // Combine the original clip with the window clip.
+ const ::basegfx::B2DPolyPolygon aOriginalClip (
+ ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(rxOriginalClip));
+ ::basegfx::B2DRectangle aWindowRange (nMinX, nMinY, nMaxX, nMaxY);
+ const ::basegfx::B2DPolyPolygon aClippedClipPolygon (
+ ::basegfx::tools::clipPolyPolygonOnRange(
+ aOriginalClip,
+ aWindowRange,
+ true, /* bInside */
+ false /* bStroke */));
+ xPolygon = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
+ xDevice,
+ aClippedClipPolygon);
+ }
+ else
+ {
+ // Create a new clip polygon from the window clip rectangle.
+ Sequence<Sequence<geometry::RealPoint2D> > aPoints (1);
+ aPoints[0] = Sequence<geometry::RealPoint2D>(4);
+ aPoints[0][0] = geometry::RealPoint2D(nMinX,nMinY);
+ aPoints[0][1] = geometry::RealPoint2D(nMaxX,nMinY);
+ aPoints[0][2] = geometry::RealPoint2D(nMaxX,nMaxY);
+ aPoints[0][3] = geometry::RealPoint2D(nMinX,nMaxY);
+ Reference<rendering::XLinePolyPolygon2D> xLinePolygon(
+ xDevice->createCompatibleLinePolyPolygon(aPoints));
+ if (xLinePolygon.is())
+ xLinePolygon->setClosed(0, sal_True);
+ xPolygon = Reference<rendering::XPolyPolygon2D>(xLinePolygon, UNO_QUERY);
+ }
+
+ return xPolygon;
+}
+
+
+
+
+void PresenterCanvas::ThrowIfDisposed (void)
+ throw (css::lang::DisposedException)
+{
+ if (rBHelper.bDisposed || rBHelper.bInDispose || ! mxSharedCanvas.is())
+ {
+ throw lang::DisposedException (
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "PresenterCanvas object has already been disposed")),
+ static_cast<uno::XWeak*>(this));
+ }
+}
+
+
+
+
+//===== PresenterCustomSprite =================================================
+
+
+PresenterCustomSprite::PresenterCustomSprite (
+ const rtl::Reference<PresenterCanvas>& rpCanvas,
+ const Reference<rendering::XCustomSprite>& rxSprite,
+ const Reference<awt::XWindow>& rxBaseWindow,
+ const css::geometry::RealSize2D& rSpriteSize)
+ : PresenterCustomSpriteInterfaceBase(m_aMutex),
+ mpCanvas(rpCanvas),
+ mxSprite(rxSprite),
+ mxBaseWindow(rxBaseWindow),
+ maPosition(0,0),
+ maSpriteSize(rSpriteSize)
+{
+}
+
+
+
+
+PresenterCustomSprite::~PresenterCustomSprite (void)
+{
+}
+
+
+
+
+void SAL_CALL PresenterCustomSprite::disposing (void)
+ throw (RuntimeException)
+{
+ Reference<XComponent> xComponent (mxSprite, UNO_QUERY);
+ mxSprite = NULL;
+ if (xComponent.is())
+ xComponent->dispose();
+ mpCanvas = rtl::Reference<PresenterCanvas>();
+}
+
+
+
+
+//----- XSprite ---------------------------------------------------------------
+
+void SAL_CALL PresenterCustomSprite::setAlpha (const double nAlpha)
+ throw (lang::IllegalArgumentException,RuntimeException)
+{
+ ThrowIfDisposed();
+ mxSprite->setAlpha(nAlpha);
+}
+
+
+
+
+void SAL_CALL PresenterCustomSprite::move (
+ const geometry::RealPoint2D& rNewPos,
+ const rendering::ViewState& rViewState,
+ const rendering::RenderState& rRenderState)
+ throw (lang::IllegalArgumentException,RuntimeException)
+{
+ ThrowIfDisposed();
+ maPosition = rNewPos;
+ mxSprite->move(
+ rNewPos,
+ mpCanvas->MergeViewState(rViewState, mpCanvas->GetOffset(mxBaseWindow)),
+ rRenderState);
+ // Clip sprite against window bounds. This call is necessary because
+ // sprite clipping is done in the corrdinate system of the sprite.
+ // Therefore, after each change of the sprites location the window
+ // bounds have to be transformed into the sprites coordinate system.
+ clip(NULL);
+}
+
+
+
+
+void SAL_CALL PresenterCustomSprite::transform (const geometry::AffineMatrix2D& rTransformation)
+ throw (lang::IllegalArgumentException,RuntimeException)
+{
+ ThrowIfDisposed();
+ mxSprite->transform(rTransformation);
+}
+
+
+
+
+void SAL_CALL PresenterCustomSprite::clip (const Reference<rendering::XPolyPolygon2D>& rxClip)
+ throw (RuntimeException)
+{
+ ThrowIfDisposed();
+ // The clip region is expected in the coordinate system of the sprite.
+ // UpdateSpriteClip() integrates the window bounds, transformed into the
+ // sprites coordinate system, with the given clip.
+ mxSprite->clip(mpCanvas->UpdateSpriteClip(rxClip, maPosition, maSpriteSize));
+}
+
+
+
+
+void SAL_CALL PresenterCustomSprite::setPriority (const double nPriority)
+ throw (RuntimeException)
+{
+ ThrowIfDisposed();
+ mxSprite->setPriority(nPriority);
+}
+
+
+
+void SAL_CALL PresenterCustomSprite::show (void)
+ throw (RuntimeException)
+{
+ ThrowIfDisposed();
+ mxSprite->show();
+}
+
+
+
+
+void SAL_CALL PresenterCustomSprite::hide (void)
+ throw (RuntimeException)
+{
+ ThrowIfDisposed();
+ mxSprite->hide();
+}
+
+
+
+
+//----- XCustomSprite ---------------------------------------------------------
+
+Reference<rendering::XCanvas> PresenterCustomSprite::getContentCanvas (void)
+ throw (RuntimeException)
+{
+ ThrowIfDisposed();
+ return mxSprite->getContentCanvas();
+}
+
+
+
+
+//-----------------------------------------------------------------------------
+
+void PresenterCustomSprite::ThrowIfDisposed (void)
+ throw (css::lang::DisposedException)
+{
+ if (rBHelper.bDisposed || rBHelper.bInDispose || ! mxSprite.is())
+ {
+ throw lang::DisposedException (
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "PresenterCustomSprite object has already been disposed")),
+ static_cast<uno::XWeak*>(this));
+ }
+}
+
+
+
+
+} } // end of namespace ::sd::presenter
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/presenter/PresenterCanvas.hxx b/sd/source/ui/presenter/PresenterCanvas.hxx
new file mode 100644
index 000000000000..3d119fb01758
--- /dev/null
+++ b/sd/source/ui/presenter/PresenterCanvas.hxx
@@ -0,0 +1,447 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SD_PRESENTER_PRESENTER_CANVAS_HXX
+#define SD_PRESENTER_PRESENTER_CANVAS_HXX
+
+#include "CanvasUpdateRequester.hxx"
+#include <basegfx/range/b2drectangle.hxx>
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/XWindowListener.hpp>
+#include <com/sun/star/geometry/AffineMatrix2D.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/rendering/XSpriteCanvas.hpp>
+#include <com/sun/star/rendering/VolatileContentDestroyedException.hpp>
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/compbase4.hxx>
+#include <boost/noncopyable.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace css = ::com::sun::star;
+
+namespace sd { namespace presenter {
+
+namespace {
+ typedef ::cppu::WeakComponentImplHelper4 <
+ css::rendering::XSpriteCanvas,
+ css::rendering::XBitmap,
+ css::awt::XWindowListener,
+ css::lang::XInitialization
+ > PresenterCanvasInterfaceBase;
+}
+
+/** Wrapper around a shared canvas that forwards most of its methods to the
+ shared canvas. Most notable differences are:
+ 1. The transformation of the ViewState of forwarded calls is modified by adding
+ an offset.
+ 2. The clip polygon of the ViewState of forwarded calls is intersected
+ with a clip rectangle that can be set via SetClip().
+ 3. Calls to updateScreen() are collected. One call to the updateScreen()
+ method of the shared canvas is made asynchronously.
+
+ The canvas can use different canvases for sharing and for sprite
+ construction. This allows the shared canvas to be a canvas of sprite itself.
+*/
+class PresenterCanvas
+ : private ::boost::noncopyable,
+ private ::cppu::BaseMutex,
+ public PresenterCanvasInterfaceBase
+{
+public:
+ /** This constructor is used when a PresenterCanvas object is created as
+ a service.
+ */
+ PresenterCanvas (void);
+
+ /** This constructor is used when a PresenterCanvas object is created
+ directly, typically by the PresenterCanvasFactory.
+ @param rxUpdateCanvas
+ This canvas is used to call updateScreen() at and to create
+ sprites. In the typical case this canvas is identical to the
+ rxSharedCanvas argument.
+ @param rxUpdateWindow
+ The window that belongs to the canvas given by the
+ rxUpdateCanvas argument.
+ @param rxSharedCanvas
+ The canvas that is wrapped by the new instance of this class.
+ Typically this is a regular XSpriteCanvas and then is identical
+ to the one given by the rxUpdateCanvas argument. It may be the
+ canvas of a sprite which does not support the XSpriteCanvas
+ interface. In that case the canvas that created the sprite can
+ be given as rxUpdateCanvas argument to allow to create further
+ sprites and to have proper calls to updateScreen().
+ @param rxSharedWindow
+ The window that belongs to the canvas given by the
+ rxSharedCanvas argument.
+ @param rxWindow
+ The window that is represented by the new PresenterCanvas
+ object. It is expected to be a direct decendent of
+ rxSharedWindow. Its position inside rxSharedWindow defines the
+ offset of the canvas implemented by the new PresenterCanvas
+ object and rxSharedCanvas.
+ */
+ PresenterCanvas (
+ const css::uno::Reference<css::rendering::XSpriteCanvas>& rxUpdateCanvas,
+ const css::uno::Reference<css::awt::XWindow>& rxUpdateWindow,
+ const css::uno::Reference<css::rendering::XCanvas>& rxSharedCanvas,
+ const css::uno::Reference<css::awt::XWindow>& rxSharedWindow,
+ const css::uno::Reference<css::awt::XWindow>& rxWindow);
+ virtual ~PresenterCanvas (void);
+
+ virtual void SAL_CALL disposing (void)
+ throw (css::uno::RuntimeException);
+
+ css::awt::Point GetOffset (const css::uno::Reference<css::awt::XWindow>& rxBaseWindow);
+
+ /** Merge the given view state with the view state that translates the
+ (virtual) child canvas to the shared canvas.
+ */
+ css::rendering::ViewState MergeViewState (
+ const css::rendering::ViewState& rViewState,
+ const css::awt::Point& raOffset);
+
+ css::uno::Reference<css::rendering::XCanvas> GetSharedCanvas (void) const;
+
+ /** This method is typically called by CanvasPane objects to set the
+ repaint rectangle of a windowPaint() call as clip rectangle. When
+ no or an empty rectangle is given then the window bounds are used
+ instead.
+ @param rClipRectangle
+ A valid rectangle is used to clip the view state clip polygon.
+ When an empty rectangle is given then the view state clip
+ polygons are clipped against the window bounds.
+ */
+ void SetClip (const css::awt::Rectangle& rClipRectangle);
+
+ /** Called by custom sprites to update their clip polygon so that they
+ are clipped at the borders of the canvas. This method has to be
+ called after each change of the sprite location so that the bounds
+ of the canvas can be transformed into the coordinate system of the
+ sprite.
+ */
+ css::uno::Reference<css::rendering::XPolyPolygon2D> UpdateSpriteClip (
+ const css::uno::Reference<css::rendering::XPolyPolygon2D>& rxOriginalClip,
+ const css::geometry::RealPoint2D& rLocation,
+ const css::geometry::RealSize2D& rSize);
+
+
+ // XInitialization
+
+ virtual void SAL_CALL initialize (
+ const css::uno::Sequence<css::uno::Any>& rArguments)
+ throw(css::uno::Exception, css::uno::RuntimeException);
+
+
+ // XCanvas
+
+ virtual void SAL_CALL clear (void)
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL drawPoint (
+ const css::geometry::RealPoint2D& aPoint,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+
+ virtual void SAL_CALL drawLine (
+ const css::geometry::RealPoint2D& aStartPoint,
+ const css::geometry::RealPoint2D& aEndPoint,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+
+ virtual void SAL_CALL drawBezier (
+ const css::geometry::RealBezierSegment2D& aBezierSegment,
+ const css::geometry::RealPoint2D& aEndPoint,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL drawPolyPolygon (
+ const css::uno::Reference< css::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL strokePolyPolygon (
+ const css::uno::Reference< css::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState,
+ const css::rendering::StrokeAttributes& aStrokeAttributes)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ strokeTexturedPolyPolygon (
+ const css::uno::Reference< css::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState,
+ const css::uno::Sequence< css::rendering::Texture >& aTextures,
+ const css::rendering::StrokeAttributes& aStrokeAttributes)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ strokeTextureMappedPolyPolygon(
+ const css::uno::Reference<css::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState,
+ const css::uno::Sequence<css::rendering::Texture>& aTextures,
+ const css::uno::Reference<css::geometry::XMapping2D>& xMapping,
+ const css::rendering::StrokeAttributes& aStrokeAttributes)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XPolyPolygon2D> SAL_CALL
+ queryStrokeShapes(
+ const css::uno::Reference<css::rendering::XPolyPolygon2D>& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState,
+ const css::rendering::StrokeAttributes& aStrokeAttributes)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ fillPolyPolygon(
+ const css::uno::Reference<css::rendering::XPolyPolygon2D>& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ fillTexturedPolyPolygon(
+ const css::uno::Reference<css::rendering::XPolyPolygon2D>& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState,
+ const css::uno::Sequence<css::rendering::Texture>& xTextures)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ fillTextureMappedPolyPolygon(
+ const css::uno::Reference< css::rendering::XPolyPolygon2D >& xPolyPolygon,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState,
+ const css::uno::Sequence< css::rendering::Texture >& xTextures,
+ const css::uno::Reference< css::geometry::XMapping2D >& xMapping)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XCanvasFont> SAL_CALL
+ createFont(
+ const css::rendering::FontRequest& aFontRequest,
+ const css::uno::Sequence< css::beans::PropertyValue >& aExtraFontProperties,
+ const css::geometry::Matrix2D& aFontMatrix)
+ throw (css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Sequence<css::rendering::FontInfo> SAL_CALL
+ queryAvailableFonts(
+ const css::rendering::FontInfo& aFilter,
+ const css::uno::Sequence< css::beans::PropertyValue >& aFontProperties)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ drawText(
+ const css::rendering::StringContext& aText,
+ const css::uno::Reference< css::rendering::XCanvasFont >& xFont,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState,
+ ::sal_Int8 nTextDirection)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ drawTextLayout(
+ const css::uno::Reference< css::rendering::XTextLayout >& xLayoutetText,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ drawBitmap(
+ const css::uno::Reference< css::rendering::XBitmap >& xBitmap,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
+ drawBitmapModulated(
+ const css::uno::Reference< css::rendering::XBitmap>& xBitmap,
+ const css::rendering::ViewState& aViewState,
+ const css::rendering::RenderState& aRenderState)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XGraphicDevice> SAL_CALL
+ getDevice (void)
+ throw (css::uno::RuntimeException);
+
+
+ // XBitmapCanvas
+
+ void SAL_CALL copyRect(
+ const css::uno::Reference< css::rendering::XBitmapCanvas >& sourceCanvas,
+ const css::geometry::RealRectangle2D& sourceRect,
+ const css::rendering::ViewState& sourceViewState,
+ const css::rendering::RenderState& sourceRenderState,
+ const css::geometry::RealRectangle2D& destRect,
+ const css::rendering::ViewState& destViewState,
+ const css::rendering::RenderState& destRenderState)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException);
+
+
+ // XSpriteCanvas
+
+ css::uno::Reference< css::rendering::XAnimatedSprite > SAL_CALL
+ createSpriteFromAnimation (
+ const css::uno::Reference< css::rendering::XAnimation >& animation)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+
+ css::uno::Reference< css::rendering::XAnimatedSprite > SAL_CALL
+ createSpriteFromBitmaps (
+ const css::uno::Sequence<
+ css::uno::Reference< css::rendering::XBitmap > >& animationBitmaps,
+ ::sal_Int8 interpolationMode)
+ throw (css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException,
+ css::uno::RuntimeException);
+
+ css::uno::Reference< css::rendering::XCustomSprite > SAL_CALL
+ createCustomSprite (
+ const css::geometry::RealSize2D& spriteSize)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+
+ css::uno::Reference< css::rendering::XSprite > SAL_CALL
+ createClonedSprite (
+ const css::uno::Reference< css::rendering::XSprite >& original)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+
+ ::sal_Bool SAL_CALL updateScreen (::sal_Bool bUpdateAll)
+ throw (css::uno::RuntimeException);
+
+
+ // XEventListener
+
+ virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
+ throw (css::uno::RuntimeException);
+
+
+ // XWindowListener
+
+ virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
+ throw (css::uno::RuntimeException);
+
+
+ // XBitmap
+
+ virtual css::geometry::IntegerSize2D SAL_CALL getSize (void)
+ throw (css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL hasAlpha (void)
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XBitmapCanvas> SAL_CALL queryBitmapCanvas (void)
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XBitmap> SAL_CALL getScaledBitmap(
+ const css::geometry::RealSize2D& rNewSize,
+ sal_Bool bFast)
+ throw (css::uno::RuntimeException,
+ css::lang::IllegalArgumentException,
+ css::rendering::VolatileContentDestroyedException);
+
+private:
+ css::uno::Reference<css::rendering::XSpriteCanvas> mxUpdateCanvas;
+ css::uno::Reference<css::awt::XWindow> mxUpdateWindow;
+ css::uno::Reference<css::rendering::XCanvas> mxSharedCanvas;
+ css::uno::Reference<css::awt::XWindow> mxSharedWindow;
+
+ /** The window for which a canvas is emulated.
+ */
+ css::uno::Reference<css::awt::XWindow> mxWindow;
+
+ /** Offset of the emulated canvas with respect to the shared canvas.
+ */
+ css::awt::Point maOffset;
+
+ /** The UpdateRequester is used by updateScreen() to schedule
+ updateScreen() calls at the shared canvas.
+ */
+ ::boost::shared_ptr<CanvasUpdateRequester> mpUpdateRequester;
+
+ /** The clip rectangle as given to SetClip().
+ */
+ css::awt::Rectangle maClipRectangle;
+
+ /** When this flag is true (it is set to true after every call to
+ updateScreen()) then the next call to MergeViewState updates the
+ maOffset member. A possible optimization would set this flag only
+ to true when one of the windows between mxWindow and mxSharedWindow
+ changes its position.
+ */
+ bool mbOffsetUpdatePending;
+
+ ::basegfx::B2DRectangle GetClipRectangle (
+ const css::geometry::AffineMatrix2D& rViewTransform,
+ const css::awt::Point& rOffset);
+
+ css::rendering::ViewState MergeViewState (const css::rendering::ViewState& rViewState);
+
+ /** This method throws a DisposedException when the object has already been
+ disposed.
+ */
+ void ThrowIfDisposed (void)
+ throw (css::lang::DisposedException);
+};
+
+
+
+} } // end of namespace ::sd::presenter
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/presenter/PresenterCanvasFactory.cxx b/sd/source/ui/presenter/PresenterCanvasFactory.cxx
new file mode 100644
index 000000000000..cfb1d84ee5a3
--- /dev/null
+++ b/sd/source/ui/presenter/PresenterCanvasFactory.cxx
@@ -0,0 +1,310 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_sd.hxx"
+
+#include "presenter/PresenterCanvasFactory.hxx"
+#include "PresenterCanvas.hxx"
+
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/WindowAttribute.hpp>
+#include <com/sun/star/awt/WindowClass.hpp>
+#include <com/sun/star/awt/WindowDescriptor.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/rendering/CompositeOperation.hpp>
+#include <com/sun/star/drawing/CanvasFeature.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <comphelper/processfactory.hxx>
+#include <cppcanvas/vclfactory.hxx>
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/compbase3.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <rtl/ref.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <vcl/wrkwin.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+namespace sd { namespace presenter {
+
+//===== PresenterCanvasFactory::SharedWindowContainer =========================
+
+namespace {
+ class SharedWindowDescriptor
+ {
+ public:
+ Reference<awt::XWindow> mxSharedWindow;
+ Reference<rendering::XCanvas> mxSharedCanvas;
+ };
+}
+
+class PresenterCanvasFactory::SharedWindowContainer
+ : public ::std::vector<SharedWindowDescriptor>
+{
+public:
+ iterator FindDescriptor (const Reference<awt::XWindow>& rxWindow)
+ {
+ for (iterator iDescriptor=begin(); iDescriptor!=end(); ++iDescriptor)
+ if (iDescriptor->mxSharedWindow == rxWindow)
+ return iDescriptor;
+ return end();
+ }
+};
+
+
+
+
+//===== PresenterCanvasFactory ================================================
+
+class PresenterCanvasFactory::Deleter
+{
+public:
+ void operator() (const PresenterCanvasFactory* pObject) { delete pObject; }
+};
+
+
+::boost::shared_ptr<PresenterCanvasFactory> PresenterCanvasFactory::mpInstance;
+
+
+::boost::shared_ptr<PresenterCanvasFactory> PresenterCanvasFactory::Instance (void)
+{
+ ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
+ if (mpInstance.get() == NULL)
+ {
+ mpInstance.reset(new PresenterCanvasFactory(), PresenterCanvasFactory::Deleter());
+ }
+
+ return mpInstance;
+}
+
+
+
+
+void PresenterCanvasFactory::AddSharedWindow (
+ const Reference<awt::XWindow>& rxWindow,
+ const Reference<rendering::XCanvas>& rxCanvas)
+{
+ SharedWindowDescriptor aDescriptor;
+
+ if (mpSharedWindows->FindDescriptor(rxWindow) != mpSharedWindows->end())
+ return;
+
+ aDescriptor.mxSharedWindow = rxWindow;
+ aDescriptor.mxSharedCanvas = rxCanvas;
+
+ // Store the new shared window only when both the window and the canvas
+ // are present.
+ if (aDescriptor.mxSharedCanvas.is() && aDescriptor.mxSharedCanvas.is())
+ mpSharedWindows->push_back(aDescriptor);
+}
+
+
+
+
+void PresenterCanvasFactory::RemoveSharedWindow (const Reference<awt::XWindow>& rxWindow)
+{
+ SharedWindowContainer::iterator iDescriptor = mpSharedWindows->FindDescriptor(rxWindow);
+ if (iDescriptor != mpSharedWindows->end())
+ {
+ mpSharedWindows->erase(iDescriptor);
+ }
+}
+
+
+
+
+Reference<rendering::XCanvas> PresenterCanvasFactory::GetCanvas (
+ const css::uno::Reference<css::awt::XWindow>& rxSharedWindow,
+ const css::uno::Reference<css::awt::XWindow>& rxWindow,
+ const sal_Int16 nRequestedCanvasFeatures,
+ const rtl::OUString& rsCanvasServiceName)
+{
+ (void)nRequestedCanvasFeatures;
+
+ Reference<rendering::XCanvas> xCanvas;
+
+ if (rxSharedWindow.is() && rsCanvasServiceName.getLength()==0)
+ {
+ OSL_ASSERT(rxSharedWindow.is());
+ xCanvas = CreateSharedCanvas(rxSharedWindow, rxWindow);
+ }
+ else
+ {
+ xCanvas = CreateCanvas(rxWindow, rsCanvasServiceName);
+ }
+
+ return xCanvas;
+}
+
+
+
+
+Reference<rendering::XCanvas> PresenterCanvasFactory::CreateSharedCanvas (
+ const css::uno::Reference<css::awt::XWindow>& rxSharedWindow,
+ const css::uno::Reference<css::awt::XWindow>& rxWindow) const
+{
+ // A shared window is given. Look it up and determine which canvas
+ // to return.
+ SharedWindowContainer::iterator iDescriptor (
+ mpSharedWindows->FindDescriptor(rxSharedWindow));
+ if (iDescriptor != mpSharedWindows->end())
+ {
+ if (rxWindow == iDescriptor->mxSharedWindow || ! rxWindow.is())
+ {
+ // A shared window itself is given. Return the previously
+ // created canvas.
+ return Reference<rendering::XCanvas>(iDescriptor->mxSharedCanvas, UNO_QUERY);
+ }
+ else
+ {
+ // A true child window is given. Create a canvas wrapper.
+ return new PresenterCanvas(
+ Reference<rendering::XCanvas>(iDescriptor->mxSharedCanvas, UNO_QUERY),
+ iDescriptor->mxSharedWindow,
+ rxWindow);
+ }
+ }
+
+ return NULL;
+}
+
+
+
+
+Reference<rendering::XCanvas> PresenterCanvasFactory::CreateCanvasForSprite (
+ const css::uno::Reference<css::awt::XWindow>& rxSharedWindow,
+ const css::uno::Reference<css::awt::XWindow>& rxWindow) const
+{
+ OSL_ASSERT(rxSharedWindow.is());
+ (void)rxWindow.is();
+
+ SharedWindowContainer::iterator iDescriptor (
+ mpSharedWindows->FindDescriptor(rxSharedWindow));
+ if (iDescriptor != mpSharedWindows->end())
+ {
+ OSL_ASSERT(iDescriptor->mxSharedCanvas.is());
+ Reference<rendering::XSpriteCanvas> xSpriteCanvas(iDescriptor->mxSharedCanvas, UNO_QUERY);
+ if (xSpriteCanvas.is())
+ {
+ Reference<rendering::XCustomSprite> xSprite (
+ xSpriteCanvas->createCustomSprite(geometry::RealSize2D(10,10)));
+ if (xSprite.is())
+ {
+ return xSprite->getContentCanvas();
+ }
+ }
+ }
+ return NULL;
+}
+
+
+
+
+Reference<rendering::XCanvas> PresenterCanvasFactory::CreateCanvas (
+ const css::uno::Reference<css::awt::XWindow>& rxWindow,
+ const rtl::OUString& rsCanvasServiceName) const
+{
+ // No shared window is given or an explicit canvas service name is
+ // specified. Create a new canvas.
+ ::Window* pWindow = VCLUnoHelper::GetWindow(rxWindow);
+ if (pWindow != NULL)
+ {
+ Sequence<Any> aArg (5);
+
+ // common: first any is VCL pointer to window (for VCL canvas)
+ aArg[0] = makeAny(reinterpret_cast<sal_Int64>(pWindow));
+ aArg[1] = Any();
+ aArg[2] = makeAny(::com::sun::star::awt::Rectangle());
+ aArg[3] = makeAny(sal_False);
+ aArg[4] = makeAny(rxWindow);
+
+ Reference<lang::XMultiServiceFactory> xFactory (::comphelper::getProcessServiceFactory());
+ return Reference<rendering::XCanvas>(
+ xFactory->createInstanceWithArguments(
+ rsCanvasServiceName.getLength()>0
+ ? rsCanvasServiceName
+ : OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.rendering.VCLCanvas")),
+ aArg),
+ UNO_QUERY);
+ }
+
+ return NULL;
+}
+
+
+
+
+Reference<rendering::XCanvas> PresenterCanvasFactory::GetSharedCanvas (
+ const Reference<awt::XWindow>& rxSharedWindow)
+{
+ SharedWindowContainer::iterator iDescriptor = mpSharedWindows->FindDescriptor(rxSharedWindow);
+ if (iDescriptor != mpSharedWindows->end())
+ return Reference<rendering::XCanvas>(iDescriptor->mxSharedCanvas, UNO_QUERY);
+ else
+ return NULL;
+}
+
+
+
+
+Reference<rendering::XCanvas> PresenterCanvasFactory::GetSharedCanvas (
+ const Reference<rendering::XCanvas>& rxCanvas)
+{
+ PresenterCanvas* pCanvas = dynamic_cast<PresenterCanvas*>(rxCanvas.get());
+ if (pCanvas != NULL)
+ return pCanvas->GetSharedCanvas();
+ else
+ return NULL;
+}
+
+
+
+
+PresenterCanvasFactory::PresenterCanvasFactory (void)
+ : mpSharedWindows(new SharedWindowContainer())
+{
+}
+
+
+
+
+PresenterCanvasFactory::~PresenterCanvasFactory (void)
+{
+ mpSharedWindows.reset();
+}
+
+
+
+
+} } // end of namespace ::sd::presenter
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/presenter/PresenterHelper.cxx b/sd/source/ui/presenter/PresenterHelper.cxx
new file mode 100644
index 000000000000..f7e06c2f89ff
--- /dev/null
+++ b/sd/source/ui/presenter/PresenterHelper.cxx
@@ -0,0 +1,346 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_sd.hxx"
+
+#include "PresenterHelper.hxx"
+#include "CanvasUpdateRequester.hxx"
+#include "PresenterCanvas.hxx"
+#include <cppcanvas/vclfactory.hxx>
+#include <com/sun/star/awt/WindowAttribute.hpp>
+#include <com/sun/star/awt/WindowClass.hpp>
+#include <com/sun/star/awt/WindowDescriptor.hpp>
+#include <osl/file.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <vcl/wrkwin.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+namespace sd { namespace presenter {
+
+//===== Service ===============================================================
+
+Reference<XInterface> SAL_CALL PresenterHelperService_createInstance (
+ const Reference<XComponentContext>& rxContext)
+{
+ return Reference<XInterface>(static_cast<XWeak*>(new PresenterHelper(rxContext)));
+}
+
+
+
+
+::rtl::OUString PresenterHelperService_getImplementationName (void)
+ throw(RuntimeException)
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Draw.PresenterHelper"));
+}
+
+
+
+
+Sequence<rtl::OUString> SAL_CALL PresenterHelperService_getSupportedServiceNames (void)
+ throw (RuntimeException)
+{
+ static const ::rtl::OUString sServiceName(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.PresenterHelper")));
+ return Sequence<rtl::OUString>(&sServiceName, 1);
+}
+
+
+
+
+//===== PresenterHelper =======================================================
+
+PresenterHelper::PresenterHelper (
+ const Reference<XComponentContext>& rxContext)
+ : PresenterHelperInterfaceBase(m_aMutex),
+ mxComponentContext(rxContext)
+{
+}
+
+
+
+PresenterHelper::~PresenterHelper (void)
+{
+}
+
+
+
+
+//----- XInitialize -----------------------------------------------------------
+
+void SAL_CALL PresenterHelper::initialize (const Sequence<Any>& rArguments)
+ throw(Exception,RuntimeException)
+{
+ (void)rArguments;
+}
+
+
+
+
+//----- XPaneHelper ----------------------------------------------------
+
+Reference<awt::XWindow> SAL_CALL PresenterHelper::createWindow (
+ const Reference<awt::XWindow>& rxParentWindow,
+ sal_Bool bCreateSystemChildWindow,
+ sal_Bool bInitiallyVisible,
+ sal_Bool bEnableChildTransparentMode,
+ sal_Bool bEnableParentClip)
+ throw (css::uno::RuntimeException)
+{
+ ::Window* pParentWindow = VCLUnoHelper::GetWindow(rxParentWindow);
+
+ // Create a new window.
+ ::Window* pWindow = NULL;
+ if (bCreateSystemChildWindow)
+ {
+ pWindow = new WorkWindow(pParentWindow, WB_SYSTEMCHILDWINDOW);
+ }
+ else
+ {
+ pWindow = new ::Window(pParentWindow);
+ }
+ Reference<awt::XWindow> xWindow (pWindow->GetComponentInterface(), UNO_QUERY);
+
+ if (bEnableChildTransparentMode)
+ {
+ // Make the frame window transparent and make the parent able to
+ // draw behind it.
+ if (pParentWindow != NULL)
+ pParentWindow->EnableChildTransparentMode(sal_True);
+ }
+
+ if (pWindow != NULL)
+ {
+ pWindow->Show(bInitiallyVisible);
+
+ pWindow->SetMapMode(MAP_PIXEL);
+ pWindow->SetBackground();
+ if ( ! bEnableParentClip)
+ {
+ pWindow->SetParentClipMode(PARENTCLIPMODE_NOCLIP);
+ pWindow->SetPaintTransparent(sal_True);
+ }
+ else
+ {
+ pWindow->SetParentClipMode(PARENTCLIPMODE_CLIP);
+ pWindow->SetPaintTransparent(sal_False);
+ }
+
+ }
+
+ return xWindow;
+}
+
+
+
+
+Reference<rendering::XCanvas> SAL_CALL PresenterHelper::createSharedCanvas (
+ const Reference<rendering::XSpriteCanvas>& rxUpdateCanvas,
+ const Reference<awt::XWindow>& rxUpdateWindow,
+ const Reference<rendering::XCanvas>& rxSharedCanvas,
+ const Reference<awt::XWindow>& rxSharedWindow,
+ const Reference<awt::XWindow>& rxWindow)
+ throw (css::uno::RuntimeException)
+{
+ if ( ! rxSharedCanvas.is()
+ || ! rxSharedWindow.is()
+ || ! rxWindow.is())
+ {
+ throw RuntimeException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("illegal argument")),
+ Reference<XInterface>(static_cast<XWeak*>(this)));
+ }
+
+ if (rxWindow == rxSharedWindow)
+ return rxSharedCanvas;
+ else
+ return new PresenterCanvas(
+ rxUpdateCanvas,
+ rxUpdateWindow,
+ rxSharedCanvas,
+ rxSharedWindow,
+ rxWindow);
+}
+
+
+
+
+Reference<rendering::XCanvas> SAL_CALL PresenterHelper::createCanvas (
+ const Reference<awt::XWindow>& rxWindow,
+ sal_Int16 nRequestedCanvasFeatures,
+ const OUString& rsOptionalCanvasServiceName)
+ throw (css::uno::RuntimeException)
+{
+ (void)nRequestedCanvasFeatures;
+
+ // No shared window is given or an explicit canvas service name is
+ // specified. Create a new canvas.
+ ::Window* pWindow = VCLUnoHelper::GetWindow(rxWindow);
+ if (pWindow != NULL)
+ {
+ Sequence<Any> aArg (5);
+
+ // common: first any is VCL pointer to window (for VCL canvas)
+ aArg[0] = makeAny(reinterpret_cast<sal_Int64>(pWindow));
+ aArg[1] = Any();
+ aArg[2] = makeAny(::com::sun::star::awt::Rectangle());
+ aArg[3] = makeAny(sal_False);
+ aArg[4] = makeAny(rxWindow);
+
+ Reference<lang::XMultiServiceFactory> xFactory (
+ mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
+ return Reference<rendering::XCanvas>(
+ xFactory->createInstanceWithArguments(
+ rsOptionalCanvasServiceName.getLength()>0
+ ? rsOptionalCanvasServiceName
+ : OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.rendering.VCLCanvas")),
+ aArg),
+ UNO_QUERY);
+ }
+ else
+ throw RuntimeException();
+}
+
+
+
+
+void SAL_CALL PresenterHelper::toTop (
+ const Reference<awt::XWindow>& rxWindow)
+ throw (css::uno::RuntimeException)
+{
+ ::Window* pWindow = VCLUnoHelper::GetWindow(rxWindow);
+ if (pWindow != NULL)
+ {
+ pWindow->ToTop();
+ pWindow->SetZOrder(NULL, WINDOW_ZORDER_LAST);
+ }
+}
+
+
+
+
+Reference<rendering::XBitmap> SAL_CALL PresenterHelper::loadBitmap (
+ const OUString& rsURL,
+ const Reference<rendering::XCanvas>& rxCanvas)
+ throw (RuntimeException)
+{
+ if ( ! rxCanvas.is())
+ return NULL;
+
+ ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
+
+ if (mpGraphicFilter.get() == NULL)
+ mpGraphicFilter.reset(new GraphicFilter(sal_False));
+
+ const cppcanvas::CanvasSharedPtr pCanvas (
+ cppcanvas::VCLFactory::getInstance().createCanvas(
+ Reference<css::rendering::XBitmapCanvas>(rxCanvas,UNO_QUERY)));
+
+ if (pCanvas.get()!=NULL && rsURL.getLength()>0 && mpGraphicFilter.get()!=NULL)
+ {
+ Graphic aGraphic;
+ OUString sFileName;
+ if (osl::FileBase::getSystemPathFromFileURL(rsURL, sFileName)
+ == osl::FileBase::E_None)
+ {
+ if (mpGraphicFilter->ImportGraphic(aGraphic, rsURL) == GRFILTER_OK)
+ {
+ BitmapEx aBitmapEx (aGraphic.GetBitmapEx());
+ return cppcanvas::VCLFactory::getInstance().createBitmap(
+ pCanvas,
+ aBitmapEx)->getUNOBitmap();
+ }
+ }
+ }
+
+ return NULL;
+}
+
+
+
+
+
+void SAL_CALL PresenterHelper::captureMouse (
+ const Reference<awt::XWindow>& rxWindow)
+ throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
+
+ // Capture the mouse (if not already done.)
+ ::Window* pWindow = VCLUnoHelper::GetWindow(rxWindow);
+ if (pWindow != NULL && ! pWindow->IsMouseCaptured())
+ {
+ pWindow->CaptureMouse();
+ }
+}
+
+
+
+
+void SAL_CALL PresenterHelper::releaseMouse (const Reference<awt::XWindow>& rxWindow)
+ throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
+
+ // Release the mouse (if not already done.)
+ ::Window* pWindow = VCLUnoHelper::GetWindow(rxWindow);
+ if (pWindow != NULL && pWindow->IsMouseCaptured())
+ {
+ pWindow->ReleaseMouse();
+ }
+}
+
+
+
+
+awt::Rectangle PresenterHelper::getWindowExtentsRelative (
+ const Reference<awt::XWindow>& rxChildWindow,
+ const Reference<awt::XWindow>& rxParentWindow)
+ throw (RuntimeException)
+{
+ ::Window* pChildWindow = VCLUnoHelper::GetWindow(rxChildWindow);
+ ::Window* pParentWindow = VCLUnoHelper::GetWindow(rxParentWindow);
+ if (pChildWindow!=NULL && pParentWindow!=NULL)
+ {
+ Rectangle aBox (pChildWindow->GetWindowExtentsRelative(pParentWindow));
+ return awt::Rectangle(aBox.Left(),aBox.Top(),aBox.GetWidth(),aBox.GetHeight());
+ }
+ else
+ return awt::Rectangle();
+}
+
+
+
+} } // end of namespace ::sd::presenter
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/presenter/PresenterHelper.hxx b/sd/source/ui/presenter/PresenterHelper.hxx
new file mode 100644
index 000000000000..b3c7a336824a
--- /dev/null
+++ b/sd/source/ui/presenter/PresenterHelper.hxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SD_PRESENTER_PRESENTER_HELPER_HXX
+#define SD_PRESENTER_PRESENTER_HELPER_HXX
+
+#include <com/sun/star/drawing/XPresenterHelper.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <svtools/filter.hxx>
+#include <boost/noncopyable.hpp>
+#include <boost/scoped_ptr.hpp>
+
+namespace css = ::com::sun::star;
+
+namespace sd { namespace presenter {
+
+namespace {
+ typedef ::cppu::WeakComponentImplHelper2<
+ css::lang::XInitialization,
+ css::drawing::XPresenterHelper
+ > PresenterHelperInterfaceBase;
+}
+
+/** Implementation of the XPresenterHelper interface: functionality that can
+ not be implemented in an extension.
+*/
+ class PresenterHelper
+ : private ::boost::noncopyable,
+ private ::cppu::BaseMutex,
+ public PresenterHelperInterfaceBase
+{
+public:
+ PresenterHelper (const css::uno::Reference<css::uno::XComponentContext>& rxContext);
+ virtual ~PresenterHelper (void);
+
+ // XInitialize
+
+ virtual void SAL_CALL initialize (const css::uno::Sequence<css::uno::Any>& rArguments)
+ throw(css::uno::Exception,css::uno::RuntimeException);
+
+
+ // XPresenterHelper
+
+ virtual css::uno::Reference<css::awt::XWindow> SAL_CALL createWindow (
+ const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
+ sal_Bool bCreateSystemChildWindow,
+ sal_Bool bInitiallyVisible,
+ sal_Bool bEnableChildTransparentMode,
+ sal_Bool bEnableParentClip)
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XCanvas> SAL_CALL createSharedCanvas (
+ const css::uno::Reference<css::rendering::XSpriteCanvas>& rxUpdateCanvas,
+ const css::uno::Reference<css::awt::XWindow>& rxUpdateWindow,
+ const css::uno::Reference<css::rendering::XCanvas>& rxSharedCanvas,
+ const css::uno::Reference<css::awt::XWindow>& rxSharedWindow,
+ const css::uno::Reference<css::awt::XWindow>& rxWindow)
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XCanvas> SAL_CALL createCanvas (
+ const css::uno::Reference<css::awt::XWindow>& rxWindow,
+ sal_Int16 nRequestedCanvasFeatures,
+ const ::rtl::OUString& rsOptionalCanvasServiceName)
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL toTop (
+ const css::uno::Reference<css::awt::XWindow>& rxWindow)
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XBitmap> SAL_CALL loadBitmap (
+ const ::rtl::OUString& rsURL,
+ const css::uno::Reference<css::rendering::XCanvas>& rxCanvas)
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL captureMouse (const css::uno::Reference<css::awt::XWindow>& rxWindow)
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL releaseMouse (const css::uno::Reference<css::awt::XWindow>& rxWindow)
+ throw (css::uno::RuntimeException);
+
+ virtual css::awt::Rectangle SAL_CALL getWindowExtentsRelative (
+ const css::uno::Reference<css::awt::XWindow>& rxChildWindow,
+ const css::uno::Reference<css::awt::XWindow>& rxParentWindow)
+ throw (css::uno::RuntimeException);
+
+private:
+ css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
+ ::boost::scoped_ptr<GraphicFilter> mpGraphicFilter;
+};
+
+} } // end of namespace ::sd::presenter
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/presenter/PresenterPreviewCache.cxx b/sd/source/ui/presenter/PresenterPreviewCache.cxx
new file mode 100644
index 000000000000..1d069f40b765
--- /dev/null
+++ b/sd/source/ui/presenter/PresenterPreviewCache.cxx
@@ -0,0 +1,519 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sd.hxx"
+
+#include "precompiled_sd.hxx"
+
+#include "PresenterPreviewCache.hxx"
+
+#include "cache/SlsCacheContext.hxx"
+#include "tools/IdleDetection.hxx"
+#include "sdpage.hxx"
+#include <cppcanvas/vclfactory.hxx>
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/rendering/XBitmapCanvas.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::sd::slidesorter::cache;
+using ::rtl::OUString;
+
+namespace sd { namespace presenter {
+
+
+class PresenterPreviewCache::PresenterCacheContext : public CacheContext
+{
+public:
+ PresenterCacheContext (void);
+ virtual ~PresenterCacheContext (void);
+
+ void SetDocumentSlides (
+ const Reference<container::XIndexAccess>& rxSlides,
+ const Reference<XInterface>& rxDocument);
+ void SetVisibleSlideRange (
+ const sal_Int32 nFirstVisibleSlideIndex,
+ const sal_Int32 nLastVisibleSlideIndex);
+ const SdrPage* GetPage (const sal_Int32 nSlideIndex) const;
+ void AddPreviewCreationNotifyListener (const Reference<drawing::XSlidePreviewCacheListener>& rxListener);
+ void RemovePreviewCreationNotifyListener (const Reference<drawing::XSlidePreviewCacheListener>& rxListener);
+
+ // CacheContext
+ virtual void NotifyPreviewCreation (
+ CacheKey aKey,
+ const Bitmap& rPreview);
+ virtual bool IsIdle (void);
+ virtual bool IsVisible (CacheKey aKey);
+ virtual const SdrPage* GetPage (CacheKey aKey);
+ virtual ::boost::shared_ptr<std::vector<CacheKey> > GetEntryList (bool bVisible);
+ virtual sal_Int32 GetPriority (CacheKey aKey);
+ virtual ::com::sun::star::uno::Reference<com::sun::star::uno::XInterface> GetModel (void);
+
+private:
+ Reference<container::XIndexAccess> mxSlides;
+ Reference<XInterface> mxDocument;
+ sal_Int32 mnFirstVisibleSlideIndex;
+ sal_Int32 mnLastVisibleSlideIndex;
+ typedef ::std::vector<css::uno::Reference<css::drawing::XSlidePreviewCacheListener> > ListenerContainer;
+ ListenerContainer maListeners;
+
+ void CallListeners (const sal_Int32 nSlideIndex);
+};
+
+
+
+
+//===== Service ===============================================================
+
+Reference<XInterface> SAL_CALL PresenterPreviewCache_createInstance (
+ const Reference<XComponentContext>& rxContext)
+{
+ return Reference<XInterface>(static_cast<XWeak*>(new PresenterPreviewCache(rxContext)));
+}
+
+
+
+
+::rtl::OUString PresenterPreviewCache_getImplementationName (void) throw(RuntimeException)
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Draw.PresenterPreviewCache"));
+}
+
+
+
+
+Sequence<rtl::OUString> SAL_CALL PresenterPreviewCache_getSupportedServiceNames (void)
+ throw (RuntimeException)
+{
+ static const ::rtl::OUString sServiceName(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.PresenterPreviewCache")));
+ return Sequence<rtl::OUString>(&sServiceName, 1);
+}
+
+
+
+
+//===== PresenterPreviewCache =================================================
+
+PresenterPreviewCache::PresenterPreviewCache (const Reference<XComponentContext>& rxContext)
+ : PresenterPreviewCacheInterfaceBase(m_aMutex),
+ maPreviewSize(Size(200,200)),
+ mpCacheContext(new PresenterCacheContext()),
+ mpCache(new PageCache(maPreviewSize, false, mpCacheContext))
+{
+ (void)rxContext;
+}
+
+
+
+
+PresenterPreviewCache::~PresenterPreviewCache (void)
+{
+}
+
+
+
+
+//----- XInitialize -----------------------------------------------------------
+
+void SAL_CALL PresenterPreviewCache::initialize (const Sequence<Any>& rArguments)
+ throw(Exception, RuntimeException)
+{
+ if (rArguments.getLength() != 0)
+ throw RuntimeException();
+}
+
+
+
+
+//----- XSlidePreviewCache ----------------------------------------------------
+
+void SAL_CALL PresenterPreviewCache::setDocumentSlides (
+ const Reference<container::XIndexAccess>& rxSlides,
+ const Reference<XInterface>& rxDocument)
+ throw (RuntimeException)
+{
+ ThrowIfDisposed();
+ OSL_ASSERT(mpCacheContext.get()!=NULL);
+
+ mpCacheContext->SetDocumentSlides(rxSlides, rxDocument);
+}
+
+
+
+
+void SAL_CALL PresenterPreviewCache::setVisibleRange (
+ sal_Int32 nFirstVisibleSlideIndex,
+ sal_Int32 nLastVisibleSlideIndex)
+ throw (css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ OSL_ASSERT(mpCacheContext.get()!=NULL);
+
+ mpCacheContext->SetVisibleSlideRange (nFirstVisibleSlideIndex, nLastVisibleSlideIndex);
+}
+
+
+
+
+void SAL_CALL PresenterPreviewCache::setPreviewSize (
+ const css::geometry::IntegerSize2D& rSize)
+ throw (css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ OSL_ASSERT(mpCache.get()!=NULL);
+
+ maPreviewSize = Size(rSize.Width, rSize.Height);
+ mpCache->ChangeSize(maPreviewSize, false);
+}
+
+
+
+
+Reference<rendering::XBitmap> SAL_CALL PresenterPreviewCache::getSlidePreview (
+ sal_Int32 nSlideIndex,
+ const Reference<rendering::XCanvas>& rxCanvas)
+ throw (css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ OSL_ASSERT(mpCacheContext.get()!=NULL);
+
+ cppcanvas::BitmapCanvasSharedPtr pCanvas (
+ cppcanvas::VCLFactory::getInstance().createCanvas(
+ Reference<rendering::XBitmapCanvas>(rxCanvas, UNO_QUERY)));
+
+ const SdrPage* pPage = mpCacheContext->GetPage(nSlideIndex);
+ if (pPage == NULL)
+ throw RuntimeException();
+
+ const BitmapEx aPreview (mpCache->GetPreviewBitmap(pPage,true));
+ if (aPreview.IsEmpty())
+ return NULL;
+ else
+ return cppcanvas::VCLFactory::getInstance().createBitmap(
+ pCanvas,
+ aPreview)->getUNOBitmap();
+}
+
+
+
+
+void SAL_CALL PresenterPreviewCache::addPreviewCreationNotifyListener (
+ const Reference<drawing::XSlidePreviewCacheListener>& rxListener)
+ throw (css::uno::RuntimeException)
+{
+ if (rBHelper.bDisposed || rBHelper.bInDispose)
+ return;
+ if (rxListener.is())
+ mpCacheContext->AddPreviewCreationNotifyListener(rxListener);
+}
+
+
+
+
+void SAL_CALL PresenterPreviewCache::removePreviewCreationNotifyListener (
+ const css::uno::Reference<css::drawing::XSlidePreviewCacheListener>& rxListener)
+ throw (css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ mpCacheContext->RemovePreviewCreationNotifyListener(rxListener);
+}
+
+
+
+
+void SAL_CALL PresenterPreviewCache::pause (void)
+ throw (css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ OSL_ASSERT(mpCache.get()!=NULL);
+ mpCache->Pause();
+}
+
+
+
+
+void SAL_CALL PresenterPreviewCache::resume (void)
+ throw (css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ OSL_ASSERT(mpCache.get()!=NULL);
+ mpCache->Resume();
+}
+
+
+
+
+//-----------------------------------------------------------------------------
+
+void PresenterPreviewCache::ThrowIfDisposed (void)
+ throw (::com::sun::star::lang::DisposedException)
+{
+ if (rBHelper.bDisposed || rBHelper.bInDispose)
+ {
+ throw lang::DisposedException (
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "PresenterPreviewCache object has already been disposed")),
+ static_cast<uno::XWeak*>(this));
+ }
+}
+
+
+
+
+//===== PresenterPreviewCache::PresenterCacheContext ==========================
+
+
+PresenterPreviewCache::PresenterCacheContext::PresenterCacheContext (void)
+ : mxSlides(),
+ mxDocument(),
+ mnFirstVisibleSlideIndex(-1),
+ mnLastVisibleSlideIndex(-1),
+ maListeners()
+{
+}
+
+
+
+
+PresenterPreviewCache::PresenterCacheContext::~PresenterCacheContext (void)
+{
+}
+
+
+
+
+void PresenterPreviewCache::PresenterCacheContext::SetDocumentSlides (
+ const Reference<container::XIndexAccess>& rxSlides,
+ const Reference<XInterface>& rxDocument)
+{
+ mxSlides = rxSlides;
+ mxDocument = rxDocument;
+ mnFirstVisibleSlideIndex = -1;
+ mnLastVisibleSlideIndex = -1;
+}
+
+
+
+
+void PresenterPreviewCache::PresenterCacheContext::SetVisibleSlideRange (
+ const sal_Int32 nFirstVisibleSlideIndex,
+ const sal_Int32 nLastVisibleSlideIndex)
+{
+ if (nFirstVisibleSlideIndex > nLastVisibleSlideIndex || nFirstVisibleSlideIndex<0)
+ {
+ mnFirstVisibleSlideIndex = -1;
+ mnLastVisibleSlideIndex = -1;
+ }
+ else
+ {
+ mnFirstVisibleSlideIndex = nFirstVisibleSlideIndex;
+ mnLastVisibleSlideIndex = nLastVisibleSlideIndex;
+ }
+ if (mxSlides.is() && mnLastVisibleSlideIndex >= mxSlides->getCount())
+ mnLastVisibleSlideIndex = mxSlides->getCount() - 1;
+}
+
+
+
+
+void PresenterPreviewCache::PresenterCacheContext::AddPreviewCreationNotifyListener (
+ const Reference<drawing::XSlidePreviewCacheListener>& rxListener)
+{
+ maListeners.push_back(rxListener);
+}
+
+
+
+
+void PresenterPreviewCache::PresenterCacheContext::RemovePreviewCreationNotifyListener (
+ const Reference<drawing::XSlidePreviewCacheListener>& rxListener)
+{
+ ListenerContainer::iterator iListener;
+ for (iListener=maListeners.begin(); iListener!=maListeners.end(); ++iListener)
+ if (*iListener == rxListener)
+ {
+ maListeners.erase(iListener);
+ return;
+ }
+}
+
+
+
+
+//----- CacheContext ----------------------------------------------------------
+
+void PresenterPreviewCache::PresenterCacheContext::NotifyPreviewCreation (
+ CacheKey aKey,
+ const Bitmap& rPreview)
+{
+ (void)rPreview;
+
+ if ( ! mxSlides.is())
+ return;
+ const sal_Int32 nCount(mxSlides->getCount());
+ for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
+ if (aKey == GetPage(nIndex))
+ CallListeners(nIndex);
+}
+
+
+
+
+bool PresenterPreviewCache::PresenterCacheContext::IsIdle (void)
+{
+ return true;
+ /*
+ sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(NULL));
+ if (nIdleState == tools::IdleDetection::IDET_IDLE)
+ return true;
+ else
+ return false;
+ */
+}
+
+
+
+
+bool PresenterPreviewCache::PresenterCacheContext::IsVisible (CacheKey aKey)
+{
+ if (mnFirstVisibleSlideIndex < 0)
+ return false;
+ for (sal_Int32 nIndex=mnFirstVisibleSlideIndex; nIndex<=mnLastVisibleSlideIndex; ++nIndex)
+ {
+ const SdrPage* pPage = GetPage(nIndex);
+ if (pPage == static_cast<const SdrPage*>(aKey))
+ return true;
+ }
+ return false;
+}
+
+
+
+
+const SdrPage* PresenterPreviewCache::PresenterCacheContext::GetPage (CacheKey aKey)
+{
+ return static_cast<const SdrPage*>(aKey);
+}
+
+
+
+
+::boost::shared_ptr<std::vector<CacheKey> >
+ PresenterPreviewCache::PresenterCacheContext::GetEntryList (bool bVisible)
+{
+ ::boost::shared_ptr<std::vector<CacheKey> > pKeys (new std::vector<CacheKey>());
+
+ if ( ! mxSlides.is())
+ return pKeys;
+
+ const sal_Int32 nFirstIndex (bVisible ? mnFirstVisibleSlideIndex : 0);
+ const sal_Int32 nLastIndex (bVisible ? mnLastVisibleSlideIndex : mxSlides->getCount()-1);
+
+ if (nFirstIndex < 0)
+ return pKeys;
+
+ for (sal_Int32 nIndex=nFirstIndex; nIndex<=nLastIndex; ++nIndex)
+ {
+ pKeys->push_back(GetPage(nIndex));
+ }
+
+ return pKeys;
+}
+
+
+
+
+sal_Int32 PresenterPreviewCache::PresenterCacheContext::GetPriority (CacheKey aKey)
+{
+ if ( ! mxSlides.is())
+ return 0;
+
+ const sal_Int32 nCount (mxSlides->getCount());
+
+ for (sal_Int32 nIndex=mnFirstVisibleSlideIndex; nIndex<=mnLastVisibleSlideIndex; ++nIndex)
+ if (aKey == GetPage(nIndex))
+ return -nCount-1+nIndex;
+
+ for (sal_Int32 nIndex=0; nIndex<=nCount; ++nIndex)
+ if (aKey == GetPage(nIndex))
+ return nIndex;
+
+ return 0;
+}
+
+
+
+
+Reference<XInterface> PresenterPreviewCache::PresenterCacheContext::GetModel (void)
+{
+ return mxDocument;
+}
+
+
+
+
+//-----------------------------------------------------------------------------
+
+const SdrPage* PresenterPreviewCache::PresenterCacheContext::GetPage (
+ const sal_Int32 nSlideIndex) const
+{
+ if ( ! mxSlides.is())
+ return NULL;
+ if (nSlideIndex < 0 || nSlideIndex >= mxSlides->getCount())
+ return NULL;
+
+ Reference<drawing::XDrawPage> xSlide (mxSlides->getByIndex(nSlideIndex), UNO_QUERY);
+ const SdPage* pPage = SdPage::getImplementation(xSlide);
+ return dynamic_cast<const SdrPage*>(pPage);
+}
+
+
+
+
+void PresenterPreviewCache::PresenterCacheContext::CallListeners (
+ const sal_Int32 nIndex)
+{
+ ListenerContainer aListeners (maListeners);
+ ListenerContainer::const_iterator iListener;
+ for (iListener=aListeners.begin(); iListener!=aListeners.end(); ++iListener)
+ {
+ try
+ {
+ (*iListener)->notifyPreviewCreation(nIndex);
+ }
+ catch (lang::DisposedException&)
+ {
+ RemovePreviewCreationNotifyListener(*iListener);
+ }
+ }
+}
+
+} } // end of namespace ::sd::presenter
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/presenter/PresenterPreviewCache.hxx b/sd/source/ui/presenter/PresenterPreviewCache.hxx
new file mode 100644
index 000000000000..1601c8439316
--- /dev/null
+++ b/sd/source/ui/presenter/PresenterPreviewCache.hxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SD_PRESENTER_PRESENTER_PREVIEW_CACHE_HXX
+#define SD_PRESENTER_PRESENTER_PREVIEW_CACHE_HXX
+
+#include <com/sun/star/drawing/XSlidePreviewCache.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include "cache/SlsPageCache.hxx"
+#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/basemutex.hxx>
+#include <boost/noncopyable.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace css = ::com::sun::star;
+
+namespace sd { namespace presenter {
+
+namespace {
+ typedef ::cppu::WeakComponentImplHelper2<
+ css::lang::XInitialization,
+ css::drawing::XSlidePreviewCache
+ > PresenterPreviewCacheInterfaceBase;
+}
+
+/** Uno API wrapper around the slide preview cache.
+*/
+class PresenterPreviewCache
+ : private ::boost::noncopyable,
+ private ::cppu::BaseMutex,
+ public PresenterPreviewCacheInterfaceBase
+{
+public:
+ PresenterPreviewCache (const css::uno::Reference<css::uno::XComponentContext>& rxContext);
+ virtual ~PresenterPreviewCache (void);
+
+ // XInitialize
+
+ /** Accepts no arguments. All values that are necessary to set up a
+ preview cache can be provided via methods.
+ */
+ virtual void SAL_CALL initialize (const css::uno::Sequence<css::uno::Any>& rArguments)
+ throw(css::uno::Exception,css::uno::RuntimeException);
+
+
+ // XSlidePreviewCache
+
+ virtual void SAL_CALL setDocumentSlides (
+ const css::uno::Reference<css::container::XIndexAccess>& rxSlides,
+ const css::uno::Reference<css::uno::XInterface>& rxDocument)
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL setVisibleRange (
+ sal_Int32 nFirstVisibleSlideIndex,
+ sal_Int32 nLastVisibleSlideIndex)
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL setPreviewSize (
+ const css::geometry::IntegerSize2D& rSize)
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XBitmap> SAL_CALL
+ getSlidePreview (
+ sal_Int32 nSlideIndex,
+ const css::uno::Reference<css::rendering::XCanvas>& rxCanvas)
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL addPreviewCreationNotifyListener (
+ const css::uno::Reference<css::drawing::XSlidePreviewCacheListener>& rxListener)
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL removePreviewCreationNotifyListener (
+ const css::uno::Reference<css::drawing::XSlidePreviewCacheListener>& rxListener)
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL pause (void)
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL resume (void)
+ throw (css::uno::RuntimeException);
+
+private:
+ css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
+ class PresenterCacheContext;
+ Size maPreviewSize;
+ ::boost::shared_ptr<PresenterCacheContext> mpCacheContext;
+ ::boost::shared_ptr<sd::slidesorter::cache::PageCache> mpCache;
+
+ /** This method throws a DisposedException when the object has already been
+ disposed.
+ */
+ void ThrowIfDisposed (void) throw (css::lang::DisposedException);
+};
+
+} } // end of namespace ::sd::presenter
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/presenter/PresenterTextView.cxx b/sd/source/ui/presenter/PresenterTextView.cxx
new file mode 100644
index 000000000000..4562a477c40d
--- /dev/null
+++ b/sd/source/ui/presenter/PresenterTextView.cxx
@@ -0,0 +1,648 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_sd.hxx"
+
+#include "PresenterTextView.hxx"
+
+#include <i18npool/mslangid.hxx>
+#include <cppcanvas/vclfactory.hxx>
+#include <svl/itempool.hxx>
+#include <svl/itemset.hxx>
+#include <unotools/linguprops.hxx>
+#include <unotools/lingucfg.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editstat.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <svx/xflclit.hxx>
+#include <vcl/bitmapex.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/virdev.hxx>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/rendering/XSpriteCanvas.hpp>
+#include <com/sun/star/util/Color.hpp>
+#include <com/sun/star/i18n/ScriptType.hpp>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using ::rtl::OUString;
+
+namespace sd { namespace presenter {
+
+//===== Service ===============================================================
+
+Reference<XInterface> SAL_CALL PresenterTextViewService_createInstance (
+ const Reference<XComponentContext>& rxContext)
+{
+ return Reference<XInterface>(static_cast<XWeak*>(new PresenterTextView(rxContext)));
+}
+
+
+
+
+::rtl::OUString PresenterTextViewService_getImplementationName (void) throw(RuntimeException)
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Draw.PresenterTextView"));
+}
+
+
+
+
+Sequence<rtl::OUString> SAL_CALL PresenterTextViewService_getSupportedServiceNames (void)
+ throw (RuntimeException)
+{
+ static const ::rtl::OUString sServiceName(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.PresenterTextView")));
+ return Sequence<rtl::OUString>(&sServiceName, 1);
+}
+
+
+
+//===== PresenterTextView::Implementation =====================================
+
+class PresenterTextView::Implementation
+{
+public:
+ const OUString msTextPropertyName;
+ const OUString msBitmapPropertyName;
+ const OUString msSizePropertyName;
+ const OUString msBackgroundColorPropertyName;
+ const OUString msTextColorPropertyName;
+ const OUString msFontDescriptorPropertyName;
+ const OUString msTopPropertyName;
+ const OUString msTopRelativePropertyName;
+ const OUString msTotalHeightPropertyName;
+
+ Implementation (void);
+ ~Implementation (void);
+
+ void SetCanvas (const cppcanvas::CanvasSharedPtr& rCanvas);
+ void SetSize (const Size aSize);
+ void SetBackgroundColor (const Color aColor);
+ void SetTextColor (const Color aColor);
+ void SetFontDescriptor (const awt::FontDescriptor& rFontDescriptor);
+ sal_Int32 GetTop (void) const;
+ void SetTop (const sal_Int32 nTop);
+ void SetText (const OUString& Text);
+ sal_Int32 ParseDistance (const OUString& rsDistance) const;
+ Reference<rendering::XBitmap> GetBitmap (void);
+ sal_Int32 GetTotalHeight (void);
+
+private:
+ Reference<rendering::XBitmap> mxBitmap;
+ cppcanvas::CanvasSharedPtr mpCanvas;
+ VirtualDevice* mpOutputDevice;
+ EditEngine* mpEditEngine;
+ SfxItemPool* mpEditEngineItemPool;
+ Size maSize;
+ Color maBackgroundColor;
+ Color maTextColor;
+ String msText;
+ sal_Int32 mnTop;
+ sal_Int32 mnTotalHeight;
+
+ EditEngine * GetEditEngine (void);
+ EditEngine* CreateEditEngine (void);
+ void CheckTop (void);
+};
+
+
+
+
+//===== PresenterTextView =====================================================
+
+PresenterTextView::PresenterTextView (const Reference<XComponentContext>& rxContext)
+ : PresenterTextViewInterfaceBase(),
+ mpImplementation(new Implementation())
+{
+ (void)rxContext;
+}
+
+
+
+
+PresenterTextView::~PresenterTextView (void)
+{
+}
+
+
+
+
+void SAL_CALL PresenterTextView::disposing (void)
+{
+ mpImplementation.reset();
+}
+
+
+
+
+//----- XInitialization -------------------------------------------------------
+
+void SAL_CALL PresenterTextView::initialize (const Sequence<Any>& rArguments)
+ throw (Exception, RuntimeException)
+{
+ ThrowIfDisposed();
+
+ if (rArguments.getLength() == 1)
+ {
+ try
+ {
+ Reference<rendering::XBitmapCanvas> xCanvas (rArguments[0], UNO_QUERY_THROW);
+ if (xCanvas.is())
+ {
+ mpImplementation->SetCanvas(
+ cppcanvas::VCLFactory::getInstance().createCanvas(xCanvas));
+ }
+ }
+ catch (RuntimeException&)
+ {
+ throw;
+ }
+ }
+ else
+ {
+ throw RuntimeException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("PresenterTextView: invalid number of arguments")),
+ static_cast<XWeak*>(this));
+ }
+}
+
+
+
+
+//-----------------------------------------------------------------------------
+
+Any PresenterTextView::GetPropertyValue (const OUString& rsPropertyName)
+{
+ ThrowIfDisposed();
+
+ if (rsPropertyName == mpImplementation->msBitmapPropertyName)
+ {
+ return Any(mpImplementation->GetBitmap());
+ }
+ else if (rsPropertyName == mpImplementation->msTopPropertyName)
+ {
+ return Any(mpImplementation->GetTop());
+ }
+ else if (rsPropertyName == mpImplementation->msTotalHeightPropertyName)
+ {
+ return Any(mpImplementation->GetTotalHeight());
+ }
+
+ return Any();
+}
+
+
+
+
+Any PresenterTextView::SetPropertyValue (
+ const ::rtl::OUString& rsPropertyName,
+ const css::uno::Any& rValue)
+{
+ ThrowIfDisposed();
+
+ Any aOldValue;
+ if (rsPropertyName == mpImplementation->msTextPropertyName)
+ {
+ OUString sText;
+ if (rValue >>= sText)
+ mpImplementation->SetText(sText);
+ }
+ else if (rsPropertyName == mpImplementation->msSizePropertyName)
+ {
+ awt::Size aSize;
+ if (rValue >>= aSize)
+ mpImplementation->SetSize(Size(aSize.Width,aSize.Height));
+ }
+ else if (rsPropertyName == mpImplementation->msBackgroundColorPropertyName)
+ {
+ util::Color aColor = util::Color();
+ if (rValue >>= aColor)
+ mpImplementation->SetBackgroundColor(Color(aColor));
+ }
+ else if (rsPropertyName == mpImplementation->msTextColorPropertyName)
+ {
+ util::Color aColor = util::Color();
+ if (rValue >>= aColor)
+ mpImplementation->SetTextColor(Color(aColor));
+ }
+ else if (rsPropertyName == mpImplementation->msFontDescriptorPropertyName)
+ {
+ awt::FontDescriptor aFontDescriptor;
+ if (rValue >>= aFontDescriptor)
+ mpImplementation->SetFontDescriptor(aFontDescriptor);
+ }
+ else if (rsPropertyName == mpImplementation->msTopPropertyName)
+ {
+ sal_Int32 nTop = 0;
+ if (rValue >>= nTop)
+ mpImplementation->SetTop(nTop);
+ }
+ else if (rsPropertyName == mpImplementation->msTopRelativePropertyName)
+ {
+ OUString sDistance;
+ if (rValue >>= sDistance)
+ mpImplementation->SetTop(
+ mpImplementation->GetTop()
+ + mpImplementation->ParseDistance(sDistance));
+ }
+ return aOldValue;
+}
+
+
+
+
+void PresenterTextView::ThrowIfDisposed (void)
+ throw (::com::sun::star::lang::DisposedException)
+{
+ if (PresenterTextViewInterfaceBase::rBHelper.bDisposed
+ || PresenterTextViewInterfaceBase::rBHelper.bInDispose
+ || mpImplementation.get()==NULL)
+ {
+ throw lang::DisposedException (
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "PresenterTextView object has already been disposed")),
+ static_cast<uno::XWeak*>(this));
+ }
+}
+
+
+
+
+//===== PresenterTextView::Implementation =====================================
+
+PresenterTextView::Implementation::Implementation (void)
+ : msTextPropertyName(OUString(RTL_CONSTASCII_USTRINGPARAM("Text"))),
+ msBitmapPropertyName(OUString(RTL_CONSTASCII_USTRINGPARAM("Bitmap"))),
+ msSizePropertyName(OUString(RTL_CONSTASCII_USTRINGPARAM("Size"))),
+ msBackgroundColorPropertyName(OUString(RTL_CONSTASCII_USTRINGPARAM("BackgroundColor"))),
+ msTextColorPropertyName(OUString(RTL_CONSTASCII_USTRINGPARAM("TextColor"))),
+ msFontDescriptorPropertyName(OUString(RTL_CONSTASCII_USTRINGPARAM("FontDescriptor"))),
+ msTopPropertyName(OUString(RTL_CONSTASCII_USTRINGPARAM("Top"))),
+ msTopRelativePropertyName(OUString(RTL_CONSTASCII_USTRINGPARAM("RelativeTop"))),
+ msTotalHeightPropertyName(OUString(RTL_CONSTASCII_USTRINGPARAM("TotalHeight"))),
+ mxBitmap(),
+ mpCanvas(),
+ mpOutputDevice(new VirtualDevice(*Application::GetDefaultDevice(), 0, 0)),
+ mpEditEngine(NULL),
+ mpEditEngineItemPool(EditEngine::CreatePool()),
+ maSize(100,100),
+ maBackgroundColor(0xffffffff),
+ maTextColor(0x00000000),
+ msText(),
+ mnTop(0),
+ mnTotalHeight(-1)
+{
+ mpOutputDevice->SetMapMode(MAP_PIXEL);
+
+ GetEditEngine();
+}
+
+
+
+
+PresenterTextView::Implementation::~Implementation (void)
+{
+ delete mpEditEngine;
+ SfxItemPool::Free(mpEditEngineItemPool);
+ delete mpOutputDevice;
+}
+
+
+
+
+EditEngine * PresenterTextView::Implementation::GetEditEngine (void)
+{
+ if (mpEditEngine == NULL)
+ mpEditEngine = CreateEditEngine ();
+ return mpEditEngine;
+}
+
+
+
+
+EditEngine* PresenterTextView::Implementation::CreateEditEngine (void)
+{
+ EditEngine* pEditEngine = mpEditEngine;
+ if (pEditEngine == NULL)
+ {
+ //
+ // set fonts to be used
+ //
+ SvtLinguOptions aOpt;
+ SvtLinguConfig().GetOptions( aOpt );
+
+ struct FontDta {
+ sal_Int16 nFallbackLang;
+ sal_Int16 nLang;
+ sal_uInt16 nFontType;
+ sal_uInt16 nFontInfoId;
+ } aTable[3] =
+ {
+ // info to get western font to be used
+ { LANGUAGE_ENGLISH_US, LANGUAGE_NONE,
+ DEFAULTFONT_SERIF, EE_CHAR_FONTINFO },
+ // info to get CJK font to be used
+ { LANGUAGE_JAPANESE, LANGUAGE_NONE,
+ DEFAULTFONT_CJK_TEXT, EE_CHAR_FONTINFO_CJK },
+ // info to get CTL font to be used
+ { LANGUAGE_ARABIC_SAUDI_ARABIA, LANGUAGE_NONE,
+ DEFAULTFONT_CTL_TEXT, EE_CHAR_FONTINFO_CTL }
+ };
+ aTable[0].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN);
+ aTable[1].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN);
+ aTable[2].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
+
+ for (int i = 0; i < 3; ++i)
+ {
+ const FontDta &rFntDta = aTable[i];
+ LanguageType nLang = (LANGUAGE_NONE == rFntDta.nLang) ?
+ rFntDta.nFallbackLang : rFntDta.nLang;
+ Font aFont = Application::GetDefaultDevice()->GetDefaultFont(
+ rFntDta.nFontType, nLang, DEFAULTFONT_FLAGS_ONLYONE);
+ mpEditEngineItemPool->SetPoolDefaultItem(
+ SvxFontItem(
+ aFont.GetFamily(),
+ aFont.GetName(),
+ aFont.GetStyleName(),
+ aFont.GetPitch(),
+ aFont.GetCharSet(),
+ rFntDta.nFontInfoId));
+ }
+
+
+ pEditEngine = new EditEngine (mpEditEngineItemPool);
+
+ pEditEngine->EnableUndo (sal_True);
+ pEditEngine->SetDefTab (sal_uInt16(
+ Application::GetDefaultDevice()->GetTextWidth(
+ UniString::CreateFromAscii("XXXX"))));
+
+ pEditEngine->SetControlWord(
+ (pEditEngine->GetControlWord()
+ | EE_CNTRL_AUTOINDENTING) &
+ (~EE_CNTRL_UNDOATTRIBS) &
+ (~EE_CNTRL_PASTESPECIAL));
+
+ pEditEngine->SetWordDelimiters (
+ UniString::CreateFromAscii(" .=+-*/(){}[];\""));
+ pEditEngine->SetRefMapMode (MAP_PIXEL);
+ pEditEngine->SetPaperSize (Size(800, 0));
+ pEditEngine->EraseVirtualDevice();
+ pEditEngine->ClearModifyFlag();
+ }
+
+ return pEditEngine;
+}
+
+
+
+
+void PresenterTextView::Implementation::SetCanvas (const cppcanvas::CanvasSharedPtr& rpCanvas)
+{
+ mpCanvas = rpCanvas;
+ mxBitmap = NULL;
+}
+
+
+
+
+void PresenterTextView::Implementation::SetSize (const Size aSize)
+{
+ DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
+
+ maSize = aSize;
+ mpEditEngine->SetPaperSize(maSize);
+ mnTotalHeight = -1;
+ mxBitmap = NULL;
+}
+
+
+
+
+void PresenterTextView::Implementation::SetBackgroundColor (const Color aColor)
+{
+ maBackgroundColor = aColor;
+ mxBitmap = NULL;
+
+ DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
+ DBG_ASSERT(mpEditEngineItemPool!=NULL, "EditEngineItemPool missing");
+ mpEditEngine->SetBackgroundColor(aColor);
+ mpEditEngine->EnableAutoColor(sal_False);
+ mpEditEngine->ForceAutoColor(sal_False);
+}
+
+
+
+
+void PresenterTextView::Implementation::SetTextColor (const Color aColor)
+{
+ maTextColor = aColor;
+ mxBitmap = NULL;
+
+ DBG_ASSERT(mpEditEngineItemPool!=NULL, "EditEngineItemPool missing");
+ mpEditEngineItemPool->SetPoolDefaultItem(SvxColorItem(aColor, EE_CHAR_COLOR));
+}
+
+
+
+
+void PresenterTextView::Implementation::SetFontDescriptor (
+ const awt::FontDescriptor& rFontDescriptor)
+{
+ mxBitmap = NULL;
+
+ DBG_ASSERT(mpEditEngineItemPool!=NULL, "EditEngineItemPool missing");
+
+ const sal_Int32 nFontHeight = rFontDescriptor.Height;
+
+ SvxFontHeightItem aFontHeight(
+ Application::GetDefaultDevice()->LogicToPixel(
+ Size(0, nFontHeight), MapMode (MAP_POINT)).Height(),
+ 100,
+ EE_CHAR_FONTHEIGHT);
+ mpEditEngineItemPool->SetPoolDefaultItem( aFontHeight);
+ aFontHeight.SetWhich (EE_CHAR_FONTHEIGHT_CJK);
+ mpEditEngineItemPool->SetPoolDefaultItem( aFontHeight);
+ aFontHeight.SetWhich (EE_CHAR_FONTHEIGHT_CTL);
+ mpEditEngineItemPool->SetPoolDefaultItem( aFontHeight);
+
+ SvxFontItem aSvxFontItem (EE_CHAR_FONTINFO);
+ aSvxFontItem.SetFamilyName( rFontDescriptor.Name );
+ mpEditEngineItemPool->SetPoolDefaultItem(aSvxFontItem);
+
+ mnTotalHeight = -1;
+ mxBitmap = NULL;
+
+ CheckTop();
+ mnTotalHeight = -1;
+}
+
+
+
+
+sal_Int32 PresenterTextView::Implementation::GetTop (void) const
+{
+ return mnTop;
+}
+
+
+
+
+void PresenterTextView::Implementation::SetTop (const sal_Int32 nTop)
+{
+ if (nTop == mnTop)
+ return;
+
+ mnTop = nTop;
+ mxBitmap = NULL;
+ CheckTop();
+}
+
+
+
+
+void PresenterTextView::Implementation::SetText (const OUString& rText)
+{
+ DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
+ msText = rText;
+ mpEditEngine->SetPaperSize(maSize);
+ mnTotalHeight = -1;
+ mxBitmap = NULL;
+}
+
+
+
+
+sal_Int32 PresenterTextView::Implementation::ParseDistance (const OUString& rsDistance) const
+{
+ DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
+ sal_Int32 nDistance (0);
+ if (rsDistance.endsWithAsciiL("px", 2))
+ {
+ nDistance = rsDistance.copy(0,rsDistance.getLength()-2).toInt32();
+ }
+ else if (rsDistance.endsWithAsciiL("l", 1))
+ {
+ const sal_Int32 nLines (rsDistance.copy(0,rsDistance.getLength()-1).toInt32());
+ // Take the height of the first line as the height of every line.
+ const sal_uInt32 nFirstLineHeight (mpEditEngine->GetLineHeight(0,0));
+ nDistance = nFirstLineHeight * nLines;
+ }
+
+ return nDistance;
+}
+
+
+
+
+Reference<rendering::XBitmap> PresenterTextView::Implementation::GetBitmap (void)
+{
+ DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
+
+ if ( ! mxBitmap.is())
+ {
+ if (mpOutputDevice != NULL)
+ delete mpOutputDevice;
+ mpOutputDevice = new VirtualDevice(*Application::GetDefaultDevice(), 0, 0);
+ mpOutputDevice->SetMapMode(MAP_PIXEL);
+ mpOutputDevice->SetOutputSizePixel(maSize, sal_True);
+ mpOutputDevice->SetLineColor();
+ mpOutputDevice->SetFillColor();
+ mpOutputDevice->SetBackground(Wallpaper());
+ mpOutputDevice->Erase();
+
+ MapMode aMapMode (mpOutputDevice->GetMapMode());
+ aMapMode.SetOrigin(Point(0,0));
+ mpOutputDevice->SetMapMode(aMapMode);
+ const Rectangle aWindowBox (Point(0,0), maSize);
+ mpOutputDevice->DrawRect(aWindowBox);
+
+ mpEditEngine->Clear();
+ mpEditEngine->SetText(msText);
+ mpEditEngine->SetPaperSize(maSize);
+
+ mpEditEngine->Draw(mpOutputDevice, aWindowBox, Point(0,mnTop));
+
+ const BitmapEx aBitmap (mpOutputDevice->GetBitmapEx(Point(0,0), maSize));
+ mxBitmap = cppcanvas::VCLFactory::getInstance().createBitmap(
+ mpCanvas,
+ aBitmap
+ )->getUNOBitmap();
+ }
+ return mxBitmap;
+}
+
+
+
+
+sal_Int32 PresenterTextView::Implementation::GetTotalHeight (void)
+{
+ DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
+
+ if (mnTotalHeight < 0)
+ {
+ if ( ! mxBitmap.is())
+ GetBitmap();
+ mnTotalHeight = mpEditEngine->GetTextHeight();
+ }
+ return mnTotalHeight;
+}
+
+
+
+
+void PresenterTextView::Implementation::CheckTop (void)
+{
+ DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
+
+ if (mnTotalHeight < 0)
+ mnTotalHeight = mpEditEngine->GetTextHeight();
+ if (mpEditEngine!=NULL && mnTop >= mnTotalHeight)
+ mnTop = mnTotalHeight - mpEditEngine->GetLineHeight(0,0);
+
+ if (mnTotalHeight < maSize.Height())
+ mnTop = 0;
+
+ if (mnTotalHeight - mnTop < maSize.Height())
+ mnTop = mnTotalHeight - maSize.Height();
+
+ if (mnTop < 0)
+ mnTop = 0;
+}
+
+
+} } // end of namespace ::sd::presenter
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/presenter/PresenterTextView.hxx b/sd/source/ui/presenter/PresenterTextView.hxx
new file mode 100644
index 000000000000..e02115ac7c71
--- /dev/null
+++ b/sd/source/ui/presenter/PresenterTextView.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SD_PRESENTER_TEXT_VIEW_HXX
+#define SD_PRESENTER_TEXT_VIEW_HXX
+
+#include "tools/PropertySet.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <boost/noncopyable.hpp>
+#include <boost/scoped_ptr.hpp>
+
+namespace css = ::com::sun::star;
+
+namespace sd { namespace presenter {
+
+namespace {
+ typedef ::cppu::ImplInheritanceHelper1 <
+ tools::PropertySet,
+ css::lang::XInitialization
+ > PresenterTextViewInterfaceBase;
+}
+
+
+/** Render text into bitmaps. An edit engine is used to render the text.
+ This service is used by the presenter screen to render the notes view.
+*/
+class PresenterTextView
+ : private ::boost::noncopyable,
+ public PresenterTextViewInterfaceBase
+{
+public:
+ explicit PresenterTextView (const css::uno::Reference<css::uno::XComponentContext>& rxContext);
+ virtual ~PresenterTextView (void);
+
+ // XInitialization
+
+ virtual void SAL_CALL initialize (const css::uno::Sequence<css::uno::Any>& rArguments)
+ throw (css::uno::Exception, css::uno::RuntimeException);
+
+
+protected:
+ virtual void SAL_CALL disposing (void);
+
+ virtual css::uno::Any GetPropertyValue (
+ const ::rtl::OUString& rsPropertyName);
+ virtual css::uno::Any SetPropertyValue (
+ const ::rtl::OUString& rsPropertyName,
+ const css::uno::Any& rValue);
+
+private:
+ class Implementation;
+ ::boost::scoped_ptr<Implementation> mpImplementation;
+
+ /** This method throws a DisposedException when the object has already been
+ disposed.
+ */
+ void ThrowIfDisposed (void) throw (css::lang::DisposedException);
+};
+
+} } // end of namespace ::sd::presenter
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/presenter/SlideRenderer.cxx b/sd/source/ui/presenter/SlideRenderer.cxx
new file mode 100644
index 000000000000..148e8322b15e
--- /dev/null
+++ b/sd/source/ui/presenter/SlideRenderer.cxx
@@ -0,0 +1,274 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_sd.hxx"
+
+#include "SlideRenderer.hxx"
+#include "sdpage.hxx"
+#include <toolkit/helper/vclunohelper.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <cppcanvas/vclfactory.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+namespace sd { namespace presenter {
+
+//===== Service ===============================================================
+
+Reference<XInterface> SAL_CALL SlideRenderer_createInstance (
+ const Reference<XComponentContext>& rxContext)
+{
+ return Reference<XInterface>(static_cast<XWeak*>(new SlideRenderer(rxContext)));
+}
+
+
+
+
+::rtl::OUString SlideRenderer_getImplementationName (void) throw(RuntimeException)
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Draw.SlideRenderer"));
+}
+
+
+
+
+Sequence<rtl::OUString> SAL_CALL SlideRenderer_getSupportedServiceNames (void)
+ throw (RuntimeException)
+{
+ static const ::rtl::OUString sServiceName(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.SlideRenderer")));
+ return Sequence<rtl::OUString>(&sServiceName, 1);
+}
+
+
+
+
+//===== SlideRenderer ==========================================================
+
+SlideRenderer::SlideRenderer (const Reference<XComponentContext>& rxContext)
+ : SlideRendererInterfaceBase(m_aMutex),
+ maPreviewRenderer()
+{
+ (void)rxContext;
+}
+
+
+
+
+SlideRenderer::~SlideRenderer (void)
+{
+}
+
+
+
+
+void SAL_CALL SlideRenderer::disposing (void)
+{
+}
+
+
+
+
+//----- XInitialization -------------------------------------------------------
+
+void SAL_CALL SlideRenderer::initialize (const Sequence<Any>& rArguments)
+ throw (Exception, RuntimeException)
+{
+ ThrowIfDisposed();
+
+ if (rArguments.getLength() == 0)
+ {
+ try
+ {
+ }
+ catch (RuntimeException&)
+ {
+ throw;
+ }
+ }
+ else
+ {
+ throw RuntimeException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("SlideRenderer: invalid number of arguments")),
+ static_cast<XWeak*>(this));
+ }
+}
+
+
+
+
+//----- XSlideRenderer --------------------------------------------------------
+
+Reference<awt::XBitmap> SlideRenderer::createPreview (
+ const Reference<drawing::XDrawPage>& rxSlide,
+ const awt::Size& rMaximalSize,
+ sal_Int16 nSuperSampleFactor)
+ throw (css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ SolarMutexGuard aGuard;
+
+ return VCLUnoHelper::CreateBitmap(
+ CreatePreview(rxSlide, rMaximalSize, nSuperSampleFactor));
+}
+
+
+
+
+Reference<rendering::XBitmap> SlideRenderer::createPreviewForCanvas (
+ const Reference<drawing::XDrawPage>& rxSlide,
+ const awt::Size& rMaximalSize,
+ sal_Int16 nSuperSampleFactor,
+ const Reference<rendering::XCanvas>& rxCanvas)
+ throw (css::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ SolarMutexGuard aGuard;
+
+ cppcanvas::BitmapCanvasSharedPtr pCanvas (cppcanvas::VCLFactory::getInstance().createCanvas(
+ Reference<rendering::XBitmapCanvas>(rxCanvas, UNO_QUERY)));
+ if (pCanvas.get() != NULL)
+ return cppcanvas::VCLFactory::getInstance().createBitmap(
+ pCanvas,
+ CreatePreview(rxSlide, rMaximalSize, nSuperSampleFactor))->getUNOBitmap();
+ else
+ return NULL;
+}
+
+
+
+
+awt::Size SAL_CALL SlideRenderer::calculatePreviewSize (
+ double nSlideAspectRatio,
+ const awt::Size& rMaximalSize)
+ throw (css::uno::RuntimeException)
+{
+ if (rMaximalSize.Width <= 0
+ || rMaximalSize.Height <= 0
+ || nSlideAspectRatio <= 0)
+ {
+ return awt::Size(0,0);
+ }
+
+ const double nWindowAspectRatio (double(rMaximalSize.Width) / double(rMaximalSize.Height));
+ if (nSlideAspectRatio < nWindowAspectRatio)
+ return awt::Size(
+ sal::static_int_cast<sal_Int32>(rMaximalSize.Height * nSlideAspectRatio),
+ rMaximalSize.Height);
+ else
+ return awt::Size(
+ rMaximalSize.Width,
+ sal::static_int_cast<sal_Int32>(rMaximalSize.Width / nSlideAspectRatio));
+}
+
+
+
+
+//-----------------------------------------------------------------------------
+
+BitmapEx SlideRenderer::CreatePreview (
+ const Reference<drawing::XDrawPage>& rxSlide,
+ const awt::Size& rMaximalSize,
+ sal_Int16 nSuperSampleFactor)
+ throw (css::uno::RuntimeException)
+{
+ const SdPage* pPage = SdPage::getImplementation(rxSlide);
+ if (pPage == NULL)
+ throw lang::IllegalArgumentException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("SlideRenderer::createPreview() called with invalid slide")),
+ static_cast<XWeak*>(this),
+ 0);
+
+ // Determine the size of the current slide and its aspect ratio.
+ Size aPageSize = pPage->GetSize();
+ if (aPageSize.Height() <= 0)
+ throw lang::IllegalArgumentException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("SlideRenderer::createPreview() called with invalid size")),
+ static_cast<XWeak*>(this),
+ 1);
+
+ // Compare with the aspect ratio of the window (which rMaximalSize
+ // assumed to be) and calculate the size of the preview so that it
+ // a) will have the aspect ratio of the page and
+ // b) will be as large as possible.
+ awt::Size aPreviewSize (calculatePreviewSize(
+ double(aPageSize.Width()) / double(aPageSize.Height()),
+ rMaximalSize));
+ if (aPreviewSize.Width <= 0 || aPreviewSize.Height <= 0)
+ return BitmapEx();
+
+ // Make sure that the super sample factor has a sane value.
+ sal_Int16 nFactor (nSuperSampleFactor);
+ if (nFactor < 1)
+ nFactor = 1;
+ else if (nFactor > 10)
+ nFactor = 10;
+
+ // Create the preview. When the super sample factor n is greater than 1
+ // then a preview is created in size (n*width, n*height) and then scaled
+ // down to (width, height). This is a poor mans antialiasing for the
+ // time being. When we have true antialiasing support this workaround
+ // can be removed.
+ const Image aPreview = maPreviewRenderer.RenderPage (
+ pPage,
+ Size(aPreviewSize.Width*nFactor, aPreviewSize.Height*nFactor),
+ ::rtl::OUString());
+ if (nFactor == 1)
+ return aPreview.GetBitmapEx();
+ else
+ {
+ BitmapEx aScaledPreview = aPreview.GetBitmapEx();
+ aScaledPreview.Scale(
+ Size(aPreviewSize.Width,aPreviewSize.Height),
+ BMP_SCALE_INTERPOLATE);
+ return aScaledPreview;
+ }
+}
+
+
+
+
+void SlideRenderer::ThrowIfDisposed (void)
+ throw (::com::sun::star::lang::DisposedException)
+{
+ if (SlideRendererInterfaceBase::rBHelper.bDisposed || SlideRendererInterfaceBase::rBHelper.bInDispose)
+ {
+ throw lang::DisposedException (
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "SlideRenderer object has already been disposed")),
+ static_cast<uno::XWeak*>(this));
+ }
+}
+
+
+} } // end of namespace ::sd::presenter
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/presenter/SlideRenderer.hxx b/sd/source/ui/presenter/SlideRenderer.hxx
new file mode 100644
index 000000000000..ddeb211608f6
--- /dev/null
+++ b/sd/source/ui/presenter/SlideRenderer.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SD_PRESENTER_SLIDE_PREVIEW_HXX
+#define SD_PRESENTER_SLIDE_PREVIEW_HXX
+
+#include "PreviewRenderer.hxx"
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/drawing/XSlideRenderer.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/rendering/XSpriteCanvas.hpp>
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <boost/noncopyable.hpp>
+
+namespace css = ::com::sun::star;
+
+namespace sd { namespace presenter {
+
+namespace {
+ typedef ::cppu::WeakComponentImplHelper2 <
+ css::drawing::XSlideRenderer,
+ css::lang::XInitialization
+ > SlideRendererInterfaceBase;
+}
+
+
+/** Render single slides into bitmaps.
+*/
+class SlideRenderer
+ : private ::boost::noncopyable,
+ protected ::cppu::BaseMutex,
+ public SlideRendererInterfaceBase
+{
+public:
+ explicit SlideRenderer (const css::uno::Reference<css::uno::XComponentContext>& rxContext);
+ virtual ~SlideRenderer (void);
+ virtual void SAL_CALL disposing (void);
+
+
+ // XInitialization
+
+ virtual void SAL_CALL initialize (const css::uno::Sequence<css::uno::Any>& rArguments)
+ throw (css::uno::Exception, css::uno::RuntimeException);
+
+
+ // XSlideRenderer
+
+ virtual css::uno::Reference<css::awt::XBitmap> SAL_CALL createPreview (
+ const ::css::uno::Reference<css::drawing::XDrawPage>& rxSlide,
+ const css::awt::Size& rMaximumPreviewPixelSize,
+ sal_Int16 nSuperSampleFactor)
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::rendering::XBitmap> SAL_CALL createPreviewForCanvas (
+ const ::css::uno::Reference<css::drawing::XDrawPage>& rxSlide,
+ const css::awt::Size& rMaximumPreviewPixelSize,
+ sal_Int16 nSuperSampleFactor,
+ const ::css::uno::Reference<css::rendering::XCanvas>& rxCanvas)
+ throw (css::uno::RuntimeException);
+
+ virtual css::awt::Size SAL_CALL calculatePreviewSize (
+ double nSlideAspectRatio,
+ const css::awt::Size& rMaximumPreviewPixelSize)
+ throw (css::uno::RuntimeException);
+
+private:
+ PreviewRenderer maPreviewRenderer;
+
+ BitmapEx CreatePreview (
+ const ::css::uno::Reference<css::drawing::XDrawPage>& rxSlide,
+ const css::awt::Size& rMaximumPreviewPixelSize,
+ sal_Int16 nSuperSampleFactor)
+ throw (css::uno::RuntimeException);
+
+ /** This method throws a DisposedException when the object has already been
+ disposed.
+ */
+ void ThrowIfDisposed (void) throw (css::lang::DisposedException);
+};
+
+} } // end of namespace ::sd::presenter
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/presenter/makefile.mk b/sd/source/ui/presenter/makefile.mk
new file mode 100644
index 000000000000..fe6232098bd2
--- /dev/null
+++ b/sd/source/ui/presenter/makefile.mk
@@ -0,0 +1,56 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PROJECTPCH=sd
+PROJECTPCHSOURCE=$(PRJ)$/util$/sd
+PRJNAME=sd
+TARGET=presenter
+ENABLE_EXCEPTIONS=TRUE
+AUTOSEG=true
+PRJINC=.. ..$/slidesorter
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/CanvasUpdateRequester.obj \
+ $(SLO)$/PresenterCanvas.obj \
+ $(SLO)$/PresenterHelper.obj \
+ $(SLO)$/PresenterPreviewCache.obj \
+ $(SLO)$/PresenterTextView.obj \
+ $(SLO)$/SlideRenderer.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+