28#include <com/sun/star/drawing/XDrawPage.hpp>
29#include <osl/diagnose.h>
45 const Reference<container::XIndexAccess>& rxSlides,
46 const Reference<XInterface>& rxDocument);
48 const sal_Int32 nFirstVisibleSlideIndex,
49 const sal_Int32 nLastVisibleSlideIndex);
56 virtual bool IsIdle()
override;
61 virtual css::uno::Reference<css::uno::XInterface>
GetModel()
override;
68 typedef ::std::vector<css::uno::Reference<css::drawing::XSlidePreviewCacheListener> >
ListenerContainer;
77 : maPreviewSize(
Size(200,200)),
91 if (rArguments.hasElements())
96 return "com.sun.star.comp.Draw.PresenterPreviewCache";
104 return {
"com.sun.star.drawing.PresenterPreviewCache"};
110 const Reference<container::XIndexAccess>& rxSlides,
111 const Reference<XInterface>& rxDocument)
120 sal_Int32 nFirstVisibleSlideIndex,
121 sal_Int32 nLastVisibleSlideIndex)
126 mpCacheContext->SetVisibleSlideRange (nFirstVisibleSlideIndex, nLastVisibleSlideIndex);
130 const css::geometry::IntegerSize2D& rSize)
133 OSL_ASSERT(
mpCache !=
nullptr);
140 sal_Int32 nSlideIndex,
141 const Reference<rendering::XCanvas>& rxCanvas)
150 if (pPage ==
nullptr)
159 aPreview)->getUNOBitmap();
163 const Reference<drawing::XSlidePreviewCacheListener>& rxListener)
172 const css::uno::Reference<css::drawing::XSlidePreviewCacheListener>& rxListener)
181 OSL_ASSERT(
mpCache !=
nullptr);
188 OSL_ASSERT(
mpCache !=
nullptr);
196 throw lang::DisposedException (
"PresenterPreviewCache object has already been disposed",
197 static_cast<uno::XWeak*
>(
this));
204 : mnFirstVisibleSlideIndex(-1),
205 mnLastVisibleSlideIndex(-1)
210 const Reference<container::XIndexAccess>& rxSlides,
211 const Reference<XInterface>& rxDocument)
214 mxDocument = rxDocument;
215 mnFirstVisibleSlideIndex = -1;
216 mnLastVisibleSlideIndex = -1;
220 const sal_Int32 nFirstVisibleSlideIndex,
221 const sal_Int32 nLastVisibleSlideIndex)
223 if (nFirstVisibleSlideIndex > nLastVisibleSlideIndex || nFirstVisibleSlideIndex<0)
225 mnFirstVisibleSlideIndex = -1;
226 mnLastVisibleSlideIndex = -1;
230 mnFirstVisibleSlideIndex = nFirstVisibleSlideIndex;
231 mnLastVisibleSlideIndex = nLastVisibleSlideIndex;
233 if (mxSlides.is() && mnLastVisibleSlideIndex >= mxSlides->getCount())
234 mnLastVisibleSlideIndex = mxSlides->getCount() - 1;
238 const Reference<drawing::XSlidePreviewCacheListener>& rxListener)
240 maListeners.push_back(rxListener);
244 const Reference<drawing::XSlidePreviewCacheListener>& rxListener)
246 auto iListener = std::find(maListeners.begin(), maListeners.end(), rxListener);
247 if (iListener != maListeners.end())
248 maListeners.erase(iListener);
256 if ( ! mxSlides.is())
258 const sal_Int32
nCount(mxSlides->getCount());
260 if (aKey == GetPage(
nIndex))
271 if (mnFirstVisibleSlideIndex < 0)
273 for (sal_Int32
nIndex=mnFirstVisibleSlideIndex;
nIndex<=mnLastVisibleSlideIndex; ++
nIndex)
287std::shared_ptr<std::vector<CacheKey> >
290 auto pKeys = std::make_shared<std::vector<CacheKey>>();
292 if ( ! mxSlides.is())
295 const sal_Int32 nFirstIndex (
bVisible ? mnFirstVisibleSlideIndex : 0);
296 const sal_Int32 nLastIndex (
bVisible ? mnLastVisibleSlideIndex : mxSlides->getCount()-1);
303 pKeys->push_back(GetPage(
nIndex));
311 if ( ! mxSlides.is())
314 const sal_Int32
nCount (mxSlides->getCount());
316 for (sal_Int32
nIndex=mnFirstVisibleSlideIndex;
nIndex<=mnLastVisibleSlideIndex; ++
nIndex)
317 if (aKey == GetPage(
nIndex))
321 if (aKey == GetPage(
nIndex))
333 const sal_Int32 nSlideIndex)
const
335 if ( ! mxSlides.is())
337 if (nSlideIndex < 0 || nSlideIndex >= mxSlides->getCount())
340 Reference<drawing::XDrawPage> xSlide (mxSlides->getByIndex(nSlideIndex), UNO_QUERY);
346 const sal_Int32 nIndex)
353 rxListener->notifyPreviewCreation(
nIndex);
355 catch (lang::DisposedException&)
357 RemovePreviewCreationNotifyListener(rxListener);
365extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
367 css::uno::Sequence<css::uno::Any>
const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_Draw_PresenterPreviewCache_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
static bool HasFastScale()
static SdPage * getImplementation(const css::uno::Reference< css::drawing::XDrawPage > &xPage)
returns the SdPage implementation for the given XDrawPage or 0 if not available
static BitmapSharedPtr createBitmap(const CanvasSharedPtr &, const ::BitmapEx &rBmpEx)
static CanvasSharedPtr createCanvas(const css::uno::Reference< css::rendering::XCanvas > &xCanvas)
const SdrPage * GetPage(const sal_Int32 nSlideIndex) const
virtual bool IsVisible(CacheKey aKey) override
void AddPreviewCreationNotifyListener(const Reference< drawing::XSlidePreviewCacheListener > &rxListener)
::std::vector< css::uno::Reference< css::drawing::XSlidePreviewCacheListener > > ListenerContainer
Reference< XInterface > mxDocument
void RemovePreviewCreationNotifyListener(const Reference< drawing::XSlidePreviewCacheListener > &rxListener)
void SetDocumentSlides(const Reference< container::XIndexAccess > &rxSlides, const Reference< XInterface > &rxDocument)
virtual sal_Int32 GetPriority(CacheKey aKey) override
virtual css::uno::Reference< css::uno::XInterface > GetModel() override
void CallListeners(const sal_Int32 nSlideIndex)
void SetVisibleSlideRange(const sal_Int32 nFirstVisibleSlideIndex, const sal_Int32 nLastVisibleSlideIndex)
ListenerContainer maListeners
Reference< container::XIndexAccess > mxSlides
virtual std::shared_ptr< std::vector< CacheKey > > GetEntryList(bool bVisible) override
sal_Int32 mnFirstVisibleSlideIndex
virtual void NotifyPreviewCreation(CacheKey aKey) override
sal_Int32 mnLastVisibleSlideIndex
virtual bool IsIdle() override
Uno API wrapper around the slide preview cache.
virtual void SAL_CALL setVisibleRange(sal_Int32 nFirstVisibleSlideIndex, sal_Int32 nLastVisibleSlideIndex) override
OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
Accepts no arguments.
std::shared_ptr< sd::slidesorter::cache::PageCache > mpCache
virtual ~PresenterPreviewCache() override
virtual void SAL_CALL setDocumentSlides(const css::uno::Reference< css::container::XIndexAccess > &rxSlides, const css::uno::Reference< css::uno::XInterface > &rxDocument) override
std::shared_ptr< PresenterCacheContext > mpCacheContext
virtual void SAL_CALL setPreviewSize(const css::geometry::IntegerSize2D &rSize) override
virtual void SAL_CALL pause() override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Reference< css::rendering::XBitmap > SAL_CALL getSlidePreview(sal_Int32 nSlideIndex, const css::uno::Reference< css::rendering::XCanvas > &rxCanvas) override
virtual void SAL_CALL addPreviewCreationNotifyListener(const css::uno::Reference< css::drawing::XSlidePreviewCacheListener > &rxListener) override
virtual void SAL_CALL resume() override
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
virtual void SAL_CALL removePreviewCreationNotifyListener(const css::uno::Reference< css::drawing::XSlidePreviewCacheListener > &rxListener) override
std::shared_ptr< Canvas > CanvasSharedPtr
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
std::shared_ptr< T > make_shared(Args &&... args)