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 #ifndef SD_TASKPANE_SLIDE_SORTER_CACHE_DISPLAY_HXX 29 #define SD_TASKPANE_SLIDE_SORTER_CACHE_DISPLAY_HXX 30 31 // Uncomment the define below to activate the slide sorter cache display in 32 // the task pane. Visible slide previews are displayed as large rectangles, 33 // off-screen previews as smaller rectangles. The color shows the state: 34 // green for no action, different shades of yellow for a request being in 35 // the queue, pink for currently being rendered. A diagonal line indicates 36 // that the preview is not up-to-date. 37 #ifdef DEBUG 38 //#define USE_SLIDE_SORTER_CACHE_DISPLAY 39 #endif 40 41 42 #ifdef USE_SLIDE_SORTER_CACHE_DISPLAY 43 #include <taskpane/TaskPaneTreeNode.hxx> 44 45 #include <map> 46 #include <vector> 47 #include <memory> 48 49 class Window; 50 51 #include "svx/svdpage.hxx" 52 #include "drawdoc.hxx" 53 54 55 namespace sd { namespace toolpanel { 56 57 class TreeNode; 58 59 /** This panel demonstrates how to create a panel for the task pane. 60 */ 61 class SlideSorterCacheDisplay 62 : public TreeNode 63 { 64 public: 65 SlideSorterCacheDisplay (const SdDrawDocument* pDocument); 66 virtual ~SlideSorterCacheDisplay (void); 67 68 void SetParentWindow (::Window* pParentWindow); 69 70 virtual void Paint (const Rectangle& rBoundingBox); 71 virtual void Resize (void); 72 73 static SlideSorterCacheDisplay* Instance (const SdDrawDocument* pDocument); 74 75 void SetPageCount (sal_Int32 nPageCount); 76 enum PageStatus { 77 NONE, 78 IN_QUEUE_PRIORITY_0, 79 IN_QUEUE_PRIORITY_1, 80 IN_QUEUE_PRIORITY_2, 81 RENDERING 82 }; 83 void SetPageStatus (sal_Int32 nPageIndex, PageStatus eStatus); 84 void SetPageVisibility (sal_Int32 nPageIndex, bool bVisible); 85 void SetUpToDate (sal_Int32 nPageIndex, bool bUpToDate); 86 87 virtual Size GetPreferredSize (void); 88 virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeigh); 89 virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); 90 virtual ::Window* GetWindow (void); 91 virtual bool IsResizable (void); 92 virtual bool IsExpandable (void) const; 93 virtual bool IsExpanded (void) const; 94 95 private: 96 static ::std::map<const SdDrawDocument*, SlideSorterCacheDisplay*> maDisplays; 97 static void AddInstance (const SdDrawDocument* pDocument, SlideSorterCacheDisplay* pControl); 98 static void RemoveInstance (SlideSorterCacheDisplay* pControl); 99 100 ::Window* mpWindow; 101 sal_Int32 mnPageCount; 102 sal_Int32 mnColumnCount; 103 sal_Int32 mnRowCount; 104 Size maCellSize; 105 sal_Int32 mnHorizontalBorder; 106 sal_Int32 mnVerticalBorder; 107 sal_Int32 mnHorizontalGap; 108 sal_Int32 mnVerticalGap; 109 110 class PageDescriptor 111 { 112 public: 113 PageStatus meStatus; 114 bool mbVisible; 115 bool mbUpToDate; 116 }; 117 typedef ::std::vector<PageDescriptor> PageDescriptorList; 118 PageDescriptorList maPageDescriptors; 119 120 Rectangle GetPageBox (sal_Int32 nPageIndex); 121 122 void ProvideSize (sal_Int32 nPageIndex); 123 124 void PaintPage (sal_Int32 nPageIndex); 125 }; 126 127 } } // end of namespace ::sd::toolpanel 128 129 namespace { 130 131 void SscdSetStatus (const SdrPage* pPage, 132 ::sd::toolpanel::SlideSorterCacheDisplay::PageStatus eStatus) 133 { 134 ::sd::toolpanel::SlideSorterCacheDisplay* pDisplay 135 = ::sd::toolpanel::SlideSorterCacheDisplay::Instance( 136 dynamic_cast<SdDrawDocument*>(pPage->GetModel())); 137 if (pDisplay != NULL) 138 pDisplay->SetPageStatus((pPage->GetPageNum()-1)/2, eStatus); 139 } 140 141 void SscdSetRequestClass (const SdrPage* pPage, sal_Int32 nClass) 142 { 143 sd::toolpanel::SlideSorterCacheDisplay::PageStatus eStatus; 144 switch (nClass) 145 { 146 case 0: 147 eStatus = ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_0; break; 148 case 1: 149 eStatus = ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_1; break; 150 case 2: 151 eStatus = ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_2; break; 152 default: 153 eStatus = ::sd::toolpanel::SlideSorterCacheDisplay::NONE; break; 154 } 155 SscdSetStatus(pPage,eStatus); 156 } 157 158 void SscdSetVisibility (const SdrModel* pModel, sal_Int32 nIndex, bool bVisible) 159 { 160 ::sd::toolpanel::SlideSorterCacheDisplay* pDisplay 161 = ::sd::toolpanel::SlideSorterCacheDisplay::Instance( 162 dynamic_cast<const SdDrawDocument*>(pModel)); 163 if (pDisplay != NULL) 164 pDisplay->SetPageVisibility(nIndex, bVisible); 165 } 166 167 168 169 void SscdSetUpToDate (const SdrPage* pPage, bool bUpToDate) 170 { 171 ::sd::toolpanel::SlideSorterCacheDisplay* pDisplay 172 = ::sd::toolpanel::SlideSorterCacheDisplay::Instance( 173 dynamic_cast<const SdDrawDocument*>(pPage->GetModel())); 174 if (pDisplay != NULL) 175 pDisplay->SetUpToDate((pPage->GetPageNum()-1)/2, bUpToDate); 176 } 177 178 179 180 #define SSCD_SET_REQUEST_CLASS(Page,RequestClass) \ 181 SscdSetRequestClass(Page,RequestClass) 182 #define SSCD_SET_STATUS(RequestData,Status) \ 183 SscdSetStatus(RequestData,::sd::toolpanel::SlideSorterCacheDisplay::Status) 184 #define SSCD_SET_VISIBILITY(Model,Index,Visible) \ 185 SscdSetVisibility(Model,Index,Visible) 186 #define SSCD_SET_UPTODATE(Page,UpToDate) \ 187 SscdSetUpToDate(Page,UpToDate) 188 189 190 } 191 192 #else 193 194 #define SSCD_SET_REQUEST_CLASS(Page,RequestClass) 195 #define SSCD_SET_STATUS(RequestData,Status) 196 #define SSCD_SET_VISIBILITY(Model,Index,Visible) 197 #define SSCD_SET_UPTODATE(Page,UpToDate) 198 199 #endif 200 201 #endif 202