1*c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*c45d927aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*c45d927aSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*c45d927aSAndrew Rist * distributed with this work for additional information
6*c45d927aSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*c45d927aSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*c45d927aSAndrew Rist * "License"); you may not use this file except in compliance
9*c45d927aSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*c45d927aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*c45d927aSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*c45d927aSAndrew Rist * software distributed under the License is distributed on an
15*c45d927aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c45d927aSAndrew Rist * KIND, either express or implied. See the License for the
17*c45d927aSAndrew Rist * specific language governing permissions and limitations
18*c45d927aSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*c45d927aSAndrew Rist *************************************************************/
21*c45d927aSAndrew Rist
22*c45d927aSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef SD_TASKPANE_SLIDE_SORTER_CACHE_DISPLAY_HXX
25cdf0e10cSrcweir #define SD_TASKPANE_SLIDE_SORTER_CACHE_DISPLAY_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir // Uncomment the define below to activate the slide sorter cache display in
28cdf0e10cSrcweir // the task pane. Visible slide previews are displayed as large rectangles,
29cdf0e10cSrcweir // off-screen previews as smaller rectangles. The color shows the state:
30cdf0e10cSrcweir // green for no action, different shades of yellow for a request being in
31cdf0e10cSrcweir // the queue, pink for currently being rendered. A diagonal line indicates
32cdf0e10cSrcweir // that the preview is not up-to-date.
33cdf0e10cSrcweir #ifdef DEBUG
34cdf0e10cSrcweir //#define USE_SLIDE_SORTER_CACHE_DISPLAY
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir
37cdf0e10cSrcweir
38cdf0e10cSrcweir #ifdef USE_SLIDE_SORTER_CACHE_DISPLAY
39cdf0e10cSrcweir #include <taskpane/TaskPaneTreeNode.hxx>
40cdf0e10cSrcweir
41cdf0e10cSrcweir #include <map>
42cdf0e10cSrcweir #include <vector>
43cdf0e10cSrcweir #include <memory>
44cdf0e10cSrcweir
45cdf0e10cSrcweir class Window;
46cdf0e10cSrcweir
47cdf0e10cSrcweir #include "svx/svdpage.hxx"
48cdf0e10cSrcweir #include "drawdoc.hxx"
49cdf0e10cSrcweir
50cdf0e10cSrcweir
51cdf0e10cSrcweir namespace sd { namespace toolpanel {
52cdf0e10cSrcweir
53cdf0e10cSrcweir class TreeNode;
54cdf0e10cSrcweir
55cdf0e10cSrcweir /** This panel demonstrates how to create a panel for the task pane.
56cdf0e10cSrcweir */
57cdf0e10cSrcweir class SlideSorterCacheDisplay
58cdf0e10cSrcweir : public TreeNode
59cdf0e10cSrcweir {
60cdf0e10cSrcweir public:
61cdf0e10cSrcweir SlideSorterCacheDisplay (const SdDrawDocument* pDocument);
62cdf0e10cSrcweir virtual ~SlideSorterCacheDisplay (void);
63cdf0e10cSrcweir
64cdf0e10cSrcweir void SetParentWindow (::Window* pParentWindow);
65cdf0e10cSrcweir
66cdf0e10cSrcweir virtual void Paint (const Rectangle& rBoundingBox);
67cdf0e10cSrcweir virtual void Resize (void);
68cdf0e10cSrcweir
69cdf0e10cSrcweir static SlideSorterCacheDisplay* Instance (const SdDrawDocument* pDocument);
70cdf0e10cSrcweir
71cdf0e10cSrcweir void SetPageCount (sal_Int32 nPageCount);
72cdf0e10cSrcweir enum PageStatus {
73cdf0e10cSrcweir NONE,
74cdf0e10cSrcweir IN_QUEUE_PRIORITY_0,
75cdf0e10cSrcweir IN_QUEUE_PRIORITY_1,
76cdf0e10cSrcweir IN_QUEUE_PRIORITY_2,
77cdf0e10cSrcweir RENDERING
78cdf0e10cSrcweir };
79cdf0e10cSrcweir void SetPageStatus (sal_Int32 nPageIndex, PageStatus eStatus);
80cdf0e10cSrcweir void SetPageVisibility (sal_Int32 nPageIndex, bool bVisible);
81cdf0e10cSrcweir void SetUpToDate (sal_Int32 nPageIndex, bool bUpToDate);
82cdf0e10cSrcweir
83cdf0e10cSrcweir virtual Size GetPreferredSize (void);
84cdf0e10cSrcweir virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeigh);
85cdf0e10cSrcweir virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth);
86cdf0e10cSrcweir virtual ::Window* GetWindow (void);
87cdf0e10cSrcweir virtual bool IsResizable (void);
88cdf0e10cSrcweir virtual bool IsExpandable (void) const;
89cdf0e10cSrcweir virtual bool IsExpanded (void) const;
90cdf0e10cSrcweir
91cdf0e10cSrcweir private:
92cdf0e10cSrcweir static ::std::map<const SdDrawDocument*, SlideSorterCacheDisplay*> maDisplays;
93cdf0e10cSrcweir static void AddInstance (const SdDrawDocument* pDocument, SlideSorterCacheDisplay* pControl);
94cdf0e10cSrcweir static void RemoveInstance (SlideSorterCacheDisplay* pControl);
95cdf0e10cSrcweir
96cdf0e10cSrcweir ::Window* mpWindow;
97cdf0e10cSrcweir sal_Int32 mnPageCount;
98cdf0e10cSrcweir sal_Int32 mnColumnCount;
99cdf0e10cSrcweir sal_Int32 mnRowCount;
100cdf0e10cSrcweir Size maCellSize;
101cdf0e10cSrcweir sal_Int32 mnHorizontalBorder;
102cdf0e10cSrcweir sal_Int32 mnVerticalBorder;
103cdf0e10cSrcweir sal_Int32 mnHorizontalGap;
104cdf0e10cSrcweir sal_Int32 mnVerticalGap;
105cdf0e10cSrcweir
106cdf0e10cSrcweir class PageDescriptor
107cdf0e10cSrcweir {
108cdf0e10cSrcweir public:
109cdf0e10cSrcweir PageStatus meStatus;
110cdf0e10cSrcweir bool mbVisible;
111cdf0e10cSrcweir bool mbUpToDate;
112cdf0e10cSrcweir };
113cdf0e10cSrcweir typedef ::std::vector<PageDescriptor> PageDescriptorList;
114cdf0e10cSrcweir PageDescriptorList maPageDescriptors;
115cdf0e10cSrcweir
116cdf0e10cSrcweir Rectangle GetPageBox (sal_Int32 nPageIndex);
117cdf0e10cSrcweir
118cdf0e10cSrcweir void ProvideSize (sal_Int32 nPageIndex);
119cdf0e10cSrcweir
120cdf0e10cSrcweir void PaintPage (sal_Int32 nPageIndex);
121cdf0e10cSrcweir };
122cdf0e10cSrcweir
123cdf0e10cSrcweir } } // end of namespace ::sd::toolpanel
124cdf0e10cSrcweir
125cdf0e10cSrcweir namespace {
126cdf0e10cSrcweir
SscdSetStatus(const SdrPage * pPage,::sd::toolpanel::SlideSorterCacheDisplay::PageStatus eStatus)127cdf0e10cSrcweir void SscdSetStatus (const SdrPage* pPage,
128cdf0e10cSrcweir ::sd::toolpanel::SlideSorterCacheDisplay::PageStatus eStatus)
129cdf0e10cSrcweir {
130cdf0e10cSrcweir ::sd::toolpanel::SlideSorterCacheDisplay* pDisplay
131cdf0e10cSrcweir = ::sd::toolpanel::SlideSorterCacheDisplay::Instance(
132cdf0e10cSrcweir dynamic_cast<SdDrawDocument*>(pPage->GetModel()));
133cdf0e10cSrcweir if (pDisplay != NULL)
134cdf0e10cSrcweir pDisplay->SetPageStatus((pPage->GetPageNum()-1)/2, eStatus);
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
SscdSetRequestClass(const SdrPage * pPage,sal_Int32 nClass)137cdf0e10cSrcweir void SscdSetRequestClass (const SdrPage* pPage, sal_Int32 nClass)
138cdf0e10cSrcweir {
139cdf0e10cSrcweir sd::toolpanel::SlideSorterCacheDisplay::PageStatus eStatus;
140cdf0e10cSrcweir switch (nClass)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir case 0:
143cdf0e10cSrcweir eStatus = ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_0; break;
144cdf0e10cSrcweir case 1:
145cdf0e10cSrcweir eStatus = ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_1; break;
146cdf0e10cSrcweir case 2:
147cdf0e10cSrcweir eStatus = ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_2; break;
148cdf0e10cSrcweir default:
149cdf0e10cSrcweir eStatus = ::sd::toolpanel::SlideSorterCacheDisplay::NONE; break;
150cdf0e10cSrcweir }
151cdf0e10cSrcweir SscdSetStatus(pPage,eStatus);
152cdf0e10cSrcweir }
153cdf0e10cSrcweir
SscdSetVisibility(const SdrModel * pModel,sal_Int32 nIndex,bool bVisible)154cdf0e10cSrcweir void SscdSetVisibility (const SdrModel* pModel, sal_Int32 nIndex, bool bVisible)
155cdf0e10cSrcweir {
156cdf0e10cSrcweir ::sd::toolpanel::SlideSorterCacheDisplay* pDisplay
157cdf0e10cSrcweir = ::sd::toolpanel::SlideSorterCacheDisplay::Instance(
158cdf0e10cSrcweir dynamic_cast<const SdDrawDocument*>(pModel));
159cdf0e10cSrcweir if (pDisplay != NULL)
160cdf0e10cSrcweir pDisplay->SetPageVisibility(nIndex, bVisible);
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir
164cdf0e10cSrcweir
SscdSetUpToDate(const SdrPage * pPage,bool bUpToDate)165cdf0e10cSrcweir void SscdSetUpToDate (const SdrPage* pPage, bool bUpToDate)
166cdf0e10cSrcweir {
167cdf0e10cSrcweir ::sd::toolpanel::SlideSorterCacheDisplay* pDisplay
168cdf0e10cSrcweir = ::sd::toolpanel::SlideSorterCacheDisplay::Instance(
169cdf0e10cSrcweir dynamic_cast<const SdDrawDocument*>(pPage->GetModel()));
170cdf0e10cSrcweir if (pDisplay != NULL)
171cdf0e10cSrcweir pDisplay->SetUpToDate((pPage->GetPageNum()-1)/2, bUpToDate);
172cdf0e10cSrcweir }
173cdf0e10cSrcweir
174cdf0e10cSrcweir
175cdf0e10cSrcweir
176cdf0e10cSrcweir #define SSCD_SET_REQUEST_CLASS(Page,RequestClass) \
177cdf0e10cSrcweir SscdSetRequestClass(Page,RequestClass)
178cdf0e10cSrcweir #define SSCD_SET_STATUS(RequestData,Status) \
179cdf0e10cSrcweir SscdSetStatus(RequestData,::sd::toolpanel::SlideSorterCacheDisplay::Status)
180cdf0e10cSrcweir #define SSCD_SET_VISIBILITY(Model,Index,Visible) \
181cdf0e10cSrcweir SscdSetVisibility(Model,Index,Visible)
182cdf0e10cSrcweir #define SSCD_SET_UPTODATE(Page,UpToDate) \
183cdf0e10cSrcweir SscdSetUpToDate(Page,UpToDate)
184cdf0e10cSrcweir
185cdf0e10cSrcweir
186cdf0e10cSrcweir }
187cdf0e10cSrcweir
188cdf0e10cSrcweir #else
189cdf0e10cSrcweir
190cdf0e10cSrcweir #define SSCD_SET_REQUEST_CLASS(Page,RequestClass)
191cdf0e10cSrcweir #define SSCD_SET_STATUS(RequestData,Status)
192cdf0e10cSrcweir #define SSCD_SET_VISIBILITY(Model,Index,Visible)
193cdf0e10cSrcweir #define SSCD_SET_UPTODATE(Page,UpToDate)
194cdf0e10cSrcweir
195cdf0e10cSrcweir #endif
196cdf0e10cSrcweir
197cdf0e10cSrcweir #endif
198