merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / slidesorter / view / SlsViewCacheContext.cxx
blobb2f4f5874a5614d3c8a7c868eea323c437a33ee0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlsViewCacheContext.cxx,v $
11 * $Revision: 1.6 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "precompiled_sd.hxx"
36 #include "SlsViewCacheContext.hxx"
38 #include "model/SlideSorterModel.hxx"
39 #include "model/SlsPageDescriptor.hxx"
40 #include "model/SlsPageEnumerationProvider.hxx"
41 #include "view/SlideSorterView.hxx"
42 #include "view/SlsPageObjectViewObjectContact.hxx"
43 #include "sdpage.hxx"
44 #include "Window.hxx"
45 #include "drawdoc.hxx"
46 #include "tools/IdleDetection.hxx"
47 #include <svx/svdpage.hxx>
48 #include <svx/sdr/contact/viewcontact.hxx>
49 #include <vcl/window.hxx>
50 #include <svx/sdr/contact/objectcontact.hxx>
52 namespace sd { namespace slidesorter { namespace view {
55 ViewCacheContext::ViewCacheContext (
56 model::SlideSorterModel& rModel,
57 SlideSorterView& rView)
58 : mrModel(rModel),
59 mrView(rView)
66 ViewCacheContext::~ViewCacheContext (void)
73 void ViewCacheContext::NotifyPreviewCreation (
74 cache::CacheKey aKey,
75 const ::boost::shared_ptr<BitmapEx>& rPreview)
77 (void)rPreview;
78 const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey));
79 if (pDescriptor.get() != NULL)
81 // Use direct view-invalidate here and no ActionChanged() at the VC
82 // since the VC is a PageObjectViewObjectContact and in its ActionChanged()
83 // implementation invalidates the cache entry again.
84 view::PageObjectViewObjectContact* pContact = pDescriptor->GetViewObjectContact();
85 if (pContact != NULL)
86 pContact->GetObjectContact().InvalidatePartOfView(pContact->getObjectRange());
88 else
90 OSL_ASSERT(pDescriptor.get() != NULL);
97 bool ViewCacheContext::IsIdle (void)
99 sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(mrView.GetWindow()));
100 if (nIdleState == tools::IdleDetection::IDET_IDLE)
101 return true;
102 else
103 return false;
109 bool ViewCacheContext::IsVisible (cache::CacheKey aKey)
111 return GetDescriptor(aKey)->IsVisible();
117 const SdrPage* ViewCacheContext::GetPage (cache::CacheKey aKey)
119 return static_cast<const SdrPage*>(aKey);
125 ::boost::shared_ptr<std::vector<cache::CacheKey> > ViewCacheContext::GetEntryList (bool bVisible)
127 ::boost::shared_ptr<std::vector<cache::CacheKey> > pKeys (new std::vector<cache::CacheKey>());
129 model::PageEnumeration aPageEnumeration (
130 bVisible
131 ? model::PageEnumerationProvider::CreateVisiblePagesEnumeration(mrModel)
132 : model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
134 while (aPageEnumeration.HasMoreElements())
136 model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement());
137 pKeys->push_back(pDescriptor->GetPage());
140 return pKeys;
146 sal_Int32 ViewCacheContext::GetPriority (cache::CacheKey aKey)
148 return - (static_cast<const SdrPage*>(aKey)->GetPageNum()-1) / 2;
154 model::SharedPageDescriptor ViewCacheContext::GetDescriptor (cache::CacheKey aKey)
156 sal_uInt16 nPageIndex ((static_cast<const SdrPage*>(aKey)->GetPageNum() - 1) / 2);
157 return mrModel.GetPageDescriptor(nPageIndex);
163 ::com::sun::star::uno::Reference<com::sun::star::uno::XInterface> ViewCacheContext::GetModel (void)
165 if (mrModel.GetDocument() == NULL)
166 return NULL;
167 else
168 return mrModel.GetDocument()->getUnoModel();
171 } } } // end of namespace ::sd::slidesorter::view