1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SD_PRESENTER_PRESENTER_PREVIEW_CACHE_HXX
29 #define SD_PRESENTER_PRESENTER_PREVIEW_CACHE_HXX
30 
31 #include <com/sun/star/drawing/XSlidePreviewCache.hpp>
32 #include <com/sun/star/lang/XInitialization.hpp>
33 #include <com/sun/star/uno/XComponentContext.hpp>
34 #include "cache/SlsPageCache.hxx"
35 #include <cppuhelper/compbase2.hxx>
36 #include <cppuhelper/basemutex.hxx>
37 #include <boost/noncopyable.hpp>
38 #include <boost/shared_ptr.hpp>
39 
40 namespace css = ::com::sun::star;
41 
42 namespace sd { namespace presenter {
43 
44 namespace {
45     typedef ::cppu::WeakComponentImplHelper2<
46         css::lang::XInitialization,
47         css::drawing::XSlidePreviewCache
48     > PresenterPreviewCacheInterfaceBase;
49 }
50 
51 /** Uno API wrapper around the slide preview cache.
52 */
53 class PresenterPreviewCache
54     : private ::boost::noncopyable,
55       private ::cppu::BaseMutex,
56       public PresenterPreviewCacheInterfaceBase
57 {
58 public:
59     PresenterPreviewCache (const css::uno::Reference<css::uno::XComponentContext>& rxContext);
60     virtual ~PresenterPreviewCache (void);
61 
62     // XInitialize
63 
64     /** Accepts no arguments.  All values that are necessary to set up a
65         preview cache can be provided via methods.
66     */
67     virtual void SAL_CALL initialize (const css::uno::Sequence<css::uno::Any>& rArguments)
68         throw(css::uno::Exception,css::uno::RuntimeException);
69 
70 
71     // XSlidePreviewCache
72 
73     virtual void SAL_CALL setDocumentSlides (
74         const css::uno::Reference<css::container::XIndexAccess>& rxSlides,
75         const css::uno::Reference<css::uno::XInterface>& rxDocument)
76         throw (css::uno::RuntimeException);
77 
78     virtual void SAL_CALL setVisibleRange (
79         sal_Int32 nFirstVisibleSlideIndex,
80         sal_Int32 nLastVisibleSlideIndex)
81         throw (css::uno::RuntimeException);
82 
83     virtual void SAL_CALL setPreviewSize (
84         const css::geometry::IntegerSize2D& rSize)
85         throw (css::uno::RuntimeException);
86 
87     virtual css::uno::Reference<css::rendering::XBitmap> SAL_CALL
88         getSlidePreview (
89             sal_Int32 nSlideIndex,
90             const css::uno::Reference<css::rendering::XCanvas>& rxCanvas)
91         throw (css::uno::RuntimeException);
92 
93     virtual void SAL_CALL addPreviewCreationNotifyListener (
94         const css::uno::Reference<css::drawing::XSlidePreviewCacheListener>& rxListener)
95         throw (css::uno::RuntimeException);
96 
97     virtual void SAL_CALL removePreviewCreationNotifyListener (
98         const css::uno::Reference<css::drawing::XSlidePreviewCacheListener>& rxListener)
99         throw (css::uno::RuntimeException);
100 
101     virtual void SAL_CALL pause (void)
102         throw (css::uno::RuntimeException);
103 
104     virtual void SAL_CALL resume (void)
105         throw (css::uno::RuntimeException);
106 
107 private:
108     css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
109     class PresenterCacheContext;
110     Size maPreviewSize;
111     ::boost::shared_ptr<PresenterCacheContext> mpCacheContext;
112     ::boost::shared_ptr<sd::slidesorter::cache::PageCache> mpCache;
113 
114     /** This method throws a DisposedException when the object has already been
115         disposed.
116     */
117     void ThrowIfDisposed (void) throw (css::lang::DisposedException);
118 };
119 
120 } } // end of namespace ::sd::presenter
121 
122 #endif
123