Line data Source code
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 :
20 : #include "SlsViewCacheContext.hxx"
21 :
22 : #include "SlideSorter.hxx"
23 : #include "model/SlideSorterModel.hxx"
24 : #include "model/SlsPageDescriptor.hxx"
25 : #include "model/SlsPageEnumerationProvider.hxx"
26 : #include "view/SlideSorterView.hxx"
27 : #include "sdpage.hxx"
28 : #include "Window.hxx"
29 : #include "drawdoc.hxx"
30 : #include "tools/IdleDetection.hxx"
31 : #include <svx/svdpage.hxx>
32 : #include <svx/sdr/contact/viewcontact.hxx>
33 : #include <vcl/window.hxx>
34 : #include <svx/sdr/contact/objectcontact.hxx>
35 :
36 : namespace sd { namespace slidesorter { namespace view {
37 :
38 112 : ViewCacheContext::ViewCacheContext (SlideSorter& rSlideSorter)
39 112 : : mrModel(rSlideSorter.GetModel()),
40 224 : mrSlideSorter(rSlideSorter)
41 : {
42 112 : }
43 :
44 224 : ViewCacheContext::~ViewCacheContext (void)
45 : {
46 224 : }
47 :
48 181 : void ViewCacheContext::NotifyPreviewCreation (
49 : cache::CacheKey aKey,
50 : const Bitmap&)
51 : {
52 181 : const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey));
53 181 : if (pDescriptor.get() != NULL)
54 : {
55 : // Force a repaint that will trigger their re-creation.
56 181 : mrSlideSorter.GetView().RequestRepaint(pDescriptor);
57 : }
58 : else
59 : {
60 : // It is OK when a preview was created for a page that is not
61 : // currently displayed because both normal and master pages are
62 : // kept in the same cache.
63 181 : }
64 181 : }
65 :
66 181 : bool ViewCacheContext::IsIdle (void)
67 : {
68 181 : sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(mrSlideSorter.GetContentWindow().get()));
69 181 : if (nIdleState == tools::IdleDetection::IDET_IDLE)
70 181 : return true;
71 : else
72 0 : return false;
73 : }
74 :
75 1174 : bool ViewCacheContext::IsVisible (cache::CacheKey aKey)
76 : {
77 1174 : const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey));
78 1174 : return pDescriptor && pDescriptor->HasState(model::PageDescriptor::ST_Visible);
79 : }
80 :
81 3943 : const SdrPage* ViewCacheContext::GetPage (cache::CacheKey aKey)
82 : {
83 3943 : return static_cast<const SdrPage*>(aKey);
84 : }
85 :
86 0 : ::boost::shared_ptr<std::vector<cache::CacheKey> > ViewCacheContext::GetEntryList (bool bVisible)
87 : {
88 0 : ::boost::shared_ptr<std::vector<cache::CacheKey> > pKeys (new std::vector<cache::CacheKey>());
89 :
90 : model::PageEnumeration aPageEnumeration (
91 : bVisible
92 : ? model::PageEnumerationProvider::CreateVisiblePagesEnumeration(mrModel)
93 0 : : model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
94 :
95 0 : while (aPageEnumeration.HasMoreElements())
96 : {
97 0 : model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement());
98 0 : pKeys->push_back(pDescriptor->GetPage());
99 0 : }
100 :
101 0 : return pKeys;
102 : }
103 :
104 1191 : sal_Int32 ViewCacheContext::GetPriority (cache::CacheKey aKey)
105 : {
106 1191 : return - (static_cast<const SdrPage*>(aKey)->GetPageNum()-1) / 2;
107 : }
108 :
109 1355 : model::SharedPageDescriptor ViewCacheContext::GetDescriptor (cache::CacheKey aKey)
110 : {
111 1355 : sal_uInt16 nPageIndex ((static_cast<const SdrPage*>(aKey)->GetPageNum() - 1) / 2);
112 1355 : return mrModel.GetPageDescriptor(nPageIndex);
113 : }
114 :
115 122 : ::com::sun::star::uno::Reference<com::sun::star::uno::XInterface> ViewCacheContext::GetModel (void)
116 : {
117 122 : if (mrModel.GetDocument() == NULL)
118 0 : return NULL;
119 : else
120 122 : return mrModel.GetDocument()->getUnoModel();
121 : }
122 :
123 114 : } } } // end of namespace ::sd::slidesorter::view
124 :
125 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|