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 65 66 // XSlidePreviewCache 67 68 virtual void SAL_CALL setDocumentSlides ( 69 const css::uno::Reference<css::container::XIndexAccess>& rxSlides, 70 const css::uno::Reference<css::uno::XInterface>& rxDocument); 71 72 virtual void SAL_CALL setVisibleRange ( 73 sal_Int32 nFirstVisibleSlideIndex, 74 sal_Int32 nLastVisibleSlideIndex); 75 76 virtual void SAL_CALL setPreviewSize ( 77 const css::geometry::IntegerSize2D& rSize); 78 79 virtual css::uno::Reference<css::rendering::XBitmap> SAL_CALL 80 getSlidePreview ( 81 sal_Int32 nSlideIndex, 82 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas); 83 84 virtual void SAL_CALL addPreviewCreationNotifyListener ( 85 const css::uno::Reference<css::drawing::XSlidePreviewCacheListener>& rxListener); 86 87 virtual void SAL_CALL removePreviewCreationNotifyListener ( 88 const css::uno::Reference<css::drawing::XSlidePreviewCacheListener>& rxListener); 89 90 virtual void SAL_CALL pause (void); 91 92 virtual void SAL_CALL resume (void); 93 94 private: 95 css::uno::Reference<css::uno::XComponentContext> mxComponentContext; 96 class PresenterCacheContext; 97 Size maPreviewSize; 98 ::boost::shared_ptr<PresenterCacheContext> mpCacheContext; 99 ::boost::shared_ptr<sd::slidesorter::cache::PageCache> mpCache; 100 101 /** This method throws a DisposedException when the object has already been 102 disposed. 103 */ 104 void ThrowIfDisposed (void); 105 }; 106 107 } } // end of namespace ::sd::presenter 108 109 #endif 110