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 : OSL_ASSERT(pDescriptor);
69 0 : }
70 0 : }
71 :
72 :
73 :
74 :
75 0 : bool ViewCacheContext::IsIdle (void)
76 : {
77 0 : sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(mrSlideSorter.GetContentWindow().get()));
78 0 : if (nIdleState == tools::IdleDetection::IDET_IDLE)
79 0 : return true;
80 : else
81 0 : return false;
82 : }
83 :
84 :
85 :
86 :
87 0 : bool ViewCacheContext::IsVisible (cache::CacheKey aKey)
88 : {
89 0 : const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey));
90 0 : return pDescriptor && pDescriptor->HasState(model::PageDescriptor::ST_Visible);
91 : }
92 :
93 :
94 :
95 :
96 0 : const SdrPage* ViewCacheContext::GetPage (cache::CacheKey aKey)
97 : {
98 0 : return static_cast<const SdrPage*>(aKey);
99 : }
100 :
101 :
102 :
103 :
104 0 : ::boost::shared_ptr<std::vector<cache::CacheKey> > ViewCacheContext::GetEntryList (bool bVisible)
105 : {
106 0 : ::boost::shared_ptr<std::vector<cache::CacheKey> > pKeys (new std::vector<cache::CacheKey>());
107 :
108 : model::PageEnumeration aPageEnumeration (
109 : bVisible
110 : ? model::PageEnumerationProvider::CreateVisiblePagesEnumeration(mrModel)
111 0 : : model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
112 :
113 0 : while (aPageEnumeration.HasMoreElements())
114 : {
115 0 : model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement());
116 0 : pKeys->push_back(pDescriptor->GetPage());
117 0 : }
118 :
119 0 : return pKeys;
120 : }
121 :
122 :
123 :
124 :
125 0 : sal_Int32 ViewCacheContext::GetPriority (cache::CacheKey aKey)
126 : {
127 0 : return - (static_cast<const SdrPage*>(aKey)->GetPageNum()-1) / 2;
128 : }
129 :
130 :
131 :
132 :
133 0 : model::SharedPageDescriptor ViewCacheContext::GetDescriptor (cache::CacheKey aKey)
134 : {
135 0 : sal_uInt16 nPageIndex ((static_cast<const SdrPage*>(aKey)->GetPageNum() - 1) / 2);
136 0 : return mrModel.GetPageDescriptor(nPageIndex);
137 : }
138 :
139 :
140 :
141 :
142 0 : ::com::sun::star::uno::Reference<com::sun::star::uno::XInterface> ViewCacheContext::GetModel (void)
143 : {
144 0 : if (mrModel.GetDocument() == NULL)
145 0 : return NULL;
146 : else
147 0 : return mrModel.GetDocument()->getUnoModel();
148 : }
149 :
150 : } } } // end of namespace ::sd::slidesorter::view
151 :
152 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|