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_SLIDE_PREVIEW_HXX
25 #define SD_PRESENTER_SLIDE_PREVIEW_HXX
26 
27 #include "PreviewRenderer.hxx"
28 #include <com/sun/star/drawing/XDrawPage.hpp>
29 #include <com/sun/star/drawing/XSlideRenderer.hpp>
30 #include <com/sun/star/lang/XInitialization.hpp>
31 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
32 #include <cppuhelper/basemutex.hxx>
33 #include <cppuhelper/compbase2.hxx>
34 #include <boost/noncopyable.hpp>
35 
36 namespace css = ::com::sun::star;
37 
38 namespace sd { namespace presenter {
39 
40 namespace {
41     typedef ::cppu::WeakComponentImplHelper2 <
42         css::drawing::XSlideRenderer,
43         css::lang::XInitialization
44     > SlideRendererInterfaceBase;
45 }
46 
47 
48 /** Render single slides into bitmaps.
49 */
50 class SlideRenderer
51     : private ::boost::noncopyable,
52       protected ::cppu::BaseMutex,
53       public SlideRendererInterfaceBase
54 {
55 public:
56     explicit SlideRenderer (const css::uno::Reference<css::uno::XComponentContext>& rxContext);
57     virtual ~SlideRenderer (void);
58     virtual void SAL_CALL disposing (void);
59 
60 
61     // XInitialization
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     // XSlideRenderer
68 
69     virtual css::uno::Reference<css::awt::XBitmap> SAL_CALL createPreview (
70         const ::css::uno::Reference<css::drawing::XDrawPage>& rxSlide,
71         const css::awt::Size& rMaximumPreviewPixelSize,
72         sal_Int16 nSuperSampleFactor)
73         throw (css::uno::RuntimeException);
74 
75     virtual css::uno::Reference<css::rendering::XBitmap> SAL_CALL createPreviewForCanvas (
76         const ::css::uno::Reference<css::drawing::XDrawPage>& rxSlide,
77         const css::awt::Size& rMaximumPreviewPixelSize,
78         sal_Int16 nSuperSampleFactor,
79         const ::css::uno::Reference<css::rendering::XCanvas>& rxCanvas)
80         throw (css::uno::RuntimeException);
81 
82     virtual css::awt::Size SAL_CALL calculatePreviewSize (
83         double nSlideAspectRatio,
84         const css::awt::Size& rMaximumPreviewPixelSize)
85         throw (css::uno::RuntimeException);
86 
87 private:
88     PreviewRenderer maPreviewRenderer;
89 
90     BitmapEx CreatePreview (
91         const ::css::uno::Reference<css::drawing::XDrawPage>& rxSlide,
92         const css::awt::Size& rMaximumPreviewPixelSize,
93         sal_Int16 nSuperSampleFactor)
94         throw (css::uno::RuntimeException);
95 
96     /** This method throws a DisposedException when the object has already been
97         disposed.
98     */
99     void ThrowIfDisposed (void) throw (css::lang::DisposedException);
100 };
101 
102 } } // end of namespace ::sd::presenter
103 
104 #endif
105