1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include "precompiled_sd.hxx" 29 30 #include "SlsViewCacheContext.hxx" 31 32 #include "SlideSorter.hxx" 33 #include "model/SlideSorterModel.hxx" 34 #include "model/SlsPageDescriptor.hxx" 35 #include "model/SlsPageEnumerationProvider.hxx" 36 #include "view/SlideSorterView.hxx" 37 #include "sdpage.hxx" 38 #include "Window.hxx" 39 #include "drawdoc.hxx" 40 #include "tools/IdleDetection.hxx" 41 #include <svx/svdpage.hxx> 42 #include <svx/sdr/contact/viewcontact.hxx> 43 #include <vcl/window.hxx> 44 #include <svx/sdr/contact/objectcontact.hxx> 45 46 namespace sd { namespace slidesorter { namespace view { 47 48 49 ViewCacheContext::ViewCacheContext (SlideSorter& rSlideSorter) 50 : mrModel(rSlideSorter.GetModel()), 51 mrSlideSorter(rSlideSorter) 52 { 53 } 54 55 56 57 58 ViewCacheContext::~ViewCacheContext (void) 59 { 60 } 61 62 63 64 65 void ViewCacheContext::NotifyPreviewCreation ( 66 cache::CacheKey aKey, 67 const Bitmap&) 68 { 69 const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey)); 70 if (pDescriptor.get() != NULL) 71 { 72 // Force a repaint that will trigger their re-creation. 73 mrSlideSorter.GetView().RequestRepaint(pDescriptor); 74 } 75 else 76 { 77 OSL_ASSERT(pDescriptor); 78 } 79 } 80 81 82 83 84 bool ViewCacheContext::IsIdle (void) 85 { 86 sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(mrSlideSorter.GetContentWindow().get())); 87 if (nIdleState == tools::IdleDetection::IDET_IDLE) 88 return true; 89 else 90 return false; 91 } 92 93 94 95 96 bool ViewCacheContext::IsVisible (cache::CacheKey aKey) 97 { 98 const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey)); 99 return pDescriptor && pDescriptor->HasState(model::PageDescriptor::ST_Visible); 100 } 101 102 103 104 105 const SdrPage* ViewCacheContext::GetPage (cache::CacheKey aKey) 106 { 107 return static_cast<const SdrPage*>(aKey); 108 } 109 110 111 112 113 ::boost::shared_ptr<std::vector<cache::CacheKey> > ViewCacheContext::GetEntryList (bool bVisible) 114 { 115 ::boost::shared_ptr<std::vector<cache::CacheKey> > pKeys (new std::vector<cache::CacheKey>()); 116 117 model::PageEnumeration aPageEnumeration ( 118 bVisible 119 ? model::PageEnumerationProvider::CreateVisiblePagesEnumeration(mrModel) 120 : model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel)); 121 122 while (aPageEnumeration.HasMoreElements()) 123 { 124 model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement()); 125 pKeys->push_back(pDescriptor->GetPage()); 126 } 127 128 return pKeys; 129 } 130 131 132 133 134 sal_Int32 ViewCacheContext::GetPriority (cache::CacheKey aKey) 135 { 136 return - (static_cast<const SdrPage*>(aKey)->GetPageNum()-1) / 2; 137 } 138 139 140 141 142 model::SharedPageDescriptor ViewCacheContext::GetDescriptor (cache::CacheKey aKey) 143 { 144 sal_uInt16 nPageIndex ((static_cast<const SdrPage*>(aKey)->GetPageNum() - 1) / 2); 145 return mrModel.GetPageDescriptor(nPageIndex); 146 } 147 148 149 150 151 ::com::sun::star::uno::Reference<com::sun::star::uno::XInterface> ViewCacheContext::GetModel (void) 152 { 153 if (mrModel.GetDocument() == NULL) 154 return NULL; 155 else 156 return mrModel.GetDocument()->getUnoModel(); 157 } 158 159 } } } // end of namespace ::sd::slidesorter::view 160