1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SD_PRESENTER_PRESENTER_PREVIEW_CACHE_HXX
25 #define SD_PRESENTER_PRESENTER_PREVIEW_CACHE_HXX
26 
27 #include <com/sun/star/drawing/XSlidePreviewCache.hpp>
28 #include <com/sun/star/lang/XInitialization.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include "cache/SlsPageCache.hxx"
31 #include <cppuhelper/compbase2.hxx>
32 #include <cppuhelper/basemutex.hxx>
33 #include <boost/noncopyable.hpp>
34 #include <boost/shared_ptr.hpp>
35 
36 namespace css = ::com::sun::star;
37 
38 namespace sd { namespace presenter {
39 
40 namespace {
41     typedef ::cppu::WeakComponentImplHelper2<
42         css::lang::XInitialization,
43         css::drawing::XSlidePreviewCache
44     > PresenterPreviewCacheInterfaceBase;
45 }
46 
47 /** Uno API wrapper around the slide preview cache.
48 */
49 class PresenterPreviewCache
50     : private ::boost::noncopyable,
51       private ::cppu::BaseMutex,
52       public PresenterPreviewCacheInterfaceBase
53 {
54 public:
55     PresenterPreviewCache (const css::uno::Reference<css::uno::XComponentContext>& rxContext);
56     virtual ~PresenterPreviewCache (void);
57 
58     // XInitialize
59 
60     /** Accepts no arguments.  All values that are necessary to set up a
61         preview cache can be provided via methods.
62     */
63     virtual void SAL_CALL initialize (const css::uno::Sequence<css::uno::Any>& rArguments)
64         throw(css::uno::Exception,css::uno::RuntimeException);
65 
66 
67     // XSlidePreviewCache
68 
69     virtual void SAL_CALL setDocumentSlides (
70         const css::uno::Reference<css::container::XIndexAccess>& rxSlides,
71         const css::uno::Reference<css::uno::XInterface>& rxDocument)
72         throw (css::uno::RuntimeException);
73 
74     virtual void SAL_CALL setVisibleRange (
75         sal_Int32 nFirstVisibleSlideIndex,
76         sal_Int32 nLastVisibleSlideIndex)
77         throw (css::uno::RuntimeException);
78 
79     virtual void SAL_CALL setPreviewSize (
80         const css::geometry::IntegerSize2D& rSize)
81         throw (css::uno::RuntimeException);
82 
83     virtual css::uno::Reference<css::rendering::XBitmap> SAL_CALL
84         getSlidePreview (
85             sal_Int32 nSlideIndex,
86             const css::uno::Reference<css::rendering::XCanvas>& rxCanvas)
87         throw (css::uno::RuntimeException);
88 
89     virtual void SAL_CALL addPreviewCreationNotifyListener (
90         const css::uno::Reference<css::drawing::XSlidePreviewCacheListener>& rxListener)
91         throw (css::uno::RuntimeException);
92 
93     virtual void SAL_CALL removePreviewCreationNotifyListener (
94         const css::uno::Reference<css::drawing::XSlidePreviewCacheListener>& rxListener)
95         throw (css::uno::RuntimeException);
96 
97     virtual void SAL_CALL pause (void)
98         throw (css::uno::RuntimeException);
99 
100     virtual void SAL_CALL resume (void)
101         throw (css::uno::RuntimeException);
102 
103 private:
104     css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
105     class PresenterCacheContext;
106     Size maPreviewSize;
107     ::boost::shared_ptr<PresenterCacheContext> mpCacheContext;
108     ::boost::shared_ptr<sd::slidesorter::cache::PageCache> mpCache;
109 
110     /** This method throws a DisposedException when the object has already been
111         disposed.
112     */
113     void ThrowIfDisposed (void) throw (css::lang::DisposedException);
114 };
115 
116 } } // end of namespace ::sd::presenter
117 
118 #endif
119