LibreOffice Module sd (master) 1
SlsViewCacheContext.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21
22#include <SlideSorter.hxx>
27#include <sdpage.hxx>
28#include <Window.hxx>
29#include <drawdoc.hxx>
31#include <svx/svdpage.hxx>
32
33namespace sd::slidesorter::view {
34
36 : mrModel(rSlideSorter.GetModel()),
37 mrSlideSorter(rSlideSorter)
38{
39}
40
42{
43}
44
46{
47 const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey));
48 if (pDescriptor)
49 {
50 // Force a repaint that will trigger their re-creation.
52 }
53 else
54 {
55 // It is OK when a preview was created for a page that is not
56 // currently displayed because both normal and master pages are
57 // kept in the same cache.
58 }
59}
60
62{
64 return nIdleState == tools::IdleState::Idle;
65}
66
68{
69 const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey));
70 return pDescriptor && pDescriptor->HasState(model::PageDescriptor::ST_Visible);
71}
72
74{
75 return aKey;
76}
77
78std::shared_ptr<std::vector<cache::CacheKey> > ViewCacheContext::GetEntryList (bool bVisible)
79{
80 auto pKeys = std::make_shared<std::vector<cache::CacheKey>>();
81
82 model::PageEnumeration aPageEnumeration (
86
87 while (aPageEnumeration.HasMoreElements())
88 {
89 model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement());
90 pKeys->push_back(pDescriptor->GetPage());
91 }
92
93 return pKeys;
94}
95
97{
98 return - (aKey->GetPageNum()-1) / 2;
99}
100
102{
103 sal_uInt16 nPageIndex ((aKey->GetPageNum() - 1) / 2);
104 return mrModel.GetPageDescriptor(nPageIndex);
105}
106
107css::uno::Reference<css::uno::XInterface> ViewCacheContext::GetModel()
108{
109 if (mrModel.GetDocument() == nullptr)
110 return nullptr;
111 else
112 return mrModel.GetDocument()->getUnoModel();
113}
114
115} // end of namespace ::sd::slidesorter::view
116
117/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ChartModel & mrModel
SlideSorter & mrSlideSorter
css::uno::Reference< css::uno::XInterface > const & getUnoModel()
sal_uInt16 GetPageNum() const
Show previews for all the slides in a document and allow the user to insert or delete slides and modi...
Definition: SlideSorter.hxx:62
const VclPtr< sd::Window > & GetContentWindow() const
Return the content window.
Definition: SlideSorter.hxx:99
view::SlideSorterView & GetView() const
static PageEnumeration CreateAllPagesEnumeration(const SlideSorterModel &rModel)
The returned enumeration of slides iterates over all slides of the given model.
static PageEnumeration CreateVisiblePagesEnumeration(const SlideSorterModel &rModel)
The returned enumeration of slides iterates over the slides (partially) inside the visible area.
Public class of page enumerations that delegates its calls to an implementation object that can filte...
SdDrawDocument * GetDocument()
This method is present to let the view create a ShowView for displaying slides.
SharedPageDescriptor GetPageDescriptor(const sal_Int32 nPageIndex, const bool bCreate=true) const
Return a page descriptor for the page with the specified index.
model::SharedPageDescriptor GetDescriptor(cache::CacheKey aKey)
virtual const SdrPage * GetPage(cache::CacheKey aKey) override
Return the page associated with the given key.
virtual void NotifyPreviewCreation(cache::CacheKey aKey) override
This method is called when the asynchronous creation of a preview has been finished.
virtual bool IsVisible(cache::CacheKey aKey) override
This method is used to determine whether a page is currently visible or not.
virtual css::uno::Reference< css::uno::XInterface > GetModel() override
Return the model to which the pages belong for which the called cache manages the previews.
virtual sal_Int32 GetPriority(cache::CacheKey aKey) override
Return the priority that defines the order in which previews are created for different keys/pages.
virtual std::shared_ptr< std::vector< cache::CacheKey > > GetEntryList(bool bVisible) override
This method is used when the request queue is filled.
virtual bool IsIdle() override
Called to determine whether the system is idle and a preview can be created without annoying the user...
static IdleState GetIdleState(const vcl::Window *pWindow)
Determine whether the system is idle.
std::shared_ptr< PageDescriptor > SharedPageDescriptor
@ Idle
When GetIdleState() returns this value, then the system is idle.
bool bVisible