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