1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SD_SLIDESORTER_PAGE_DESCRIPTOR_HXX
25 #define SD_SLIDESORTER_PAGE_DESCRIPTOR_HXX
26 
27 #include "model/SlsVisualState.hxx"
28 #include <com/sun/star/drawing/XDrawPage.hpp>
29 #include <tools/gen.hxx>
30 #include <tools/link.hxx>
31 #include <vcl/bitmap.hxx>
32 #include <sfx2/viewfrm.hxx>
33 
34 #include <memory>
35 #include <boost/enable_shared_from_this.hpp>
36 #include <boost/scoped_ptr.hpp>
37 
38 
39 class SdPage;
40 class SdrPage;
41 
42 namespace sd { namespace slidesorter { namespace model {
43 
44 class SlideRenderer;
45 
46 namespace css = ::com::sun::star;
47 
48 /** Each PageDescriptor object represents the preview of one draw page,
49     slide, or master page of a Draw or Impress document as they are displayed
50     in the slide sorter.  This class gives access to some associated
51     information like prerendered preview or position on the screen.
52 
53     <p>Bounding boxes of page objects come in four varieties:
54     Model and screen/pixel coordinates and the bounding boxes of the actual
55     page objects and the larger bounding boxes that include page names and
56     fade symbol.</p>
57 */
58 class PageDescriptor
59     : public ::boost::enable_shared_from_this<PageDescriptor>
60 {
61 public:
62     /** Create a PageDescriptor for the given SdPage object.
63         @param rxPage
64             The page that is represented by the new PageDescriptor object.
65         @param pPage
66             The page pointer can in some situations not be detected from
67             rxPage, e.g. after undo of page deletion.  Therefore supply it
68             seperately.
69         @param nIndex
70             This index is displayed in the view as page number.  It is not
71             necessaryily the page index (not even when you add or subtract 1
72             or use (x-1)/2 magic).
73     */
74     PageDescriptor (
75         const css::uno::Reference<css::drawing::XDrawPage>& rxPage,
76         SdPage* pPage,
77         const sal_Int32 nIndex);
78 
79     ~PageDescriptor (void);
80 
81     /** Return the page that is represented by the descriptor as SdPage pointer .
82     */
83     SdPage* GetPage (void) const;
84 
85     /** Return the page that is represented by the descriptor as XDrawPage reference.
86     */
87     css::uno::Reference<css::drawing::XDrawPage> GetXDrawPage (void) const;
88 
89     /** Returns the index of the page as it is displayed in the view as page
90         number.  The value may differ from the index returned by the
91         XDrawPage when there are hidden slides and the XIndexAccess used to
92         access the model filters them out.
93     */
94     sal_Int32 GetPageIndex (void) const;
95     void SetPageIndex (const sal_Int32 nIndex);
96 
97     bool UpdateMasterPage (void);
98     bool UpdateTransitionFlag (void);
99 
100     enum State { ST_Visible, ST_Selected, ST_WasSelected,
101                  ST_Focused, ST_MouseOver, ST_Current, ST_Excluded };
102 
103     bool HasState (const State eState) const;
104 
105     bool SetState (const State eState, const bool bStateValue);
106 
107     /** Set the internal mbIsSelected flag to the selection state of the
108         page.  Use this method to synchronize a page descriptor with the
109         page it describes and determine whether a redraw to update the
110         selection indicator is necessary.
111         @return
112             When the two selection states were different <TRUE/> is
113             returned.  When they were the same this method returns
114             <FALSE/>.
115     */
116     bool GetCoreSelection (void);
117 
118     /** Set the selection flags of the SdPage objects to the corresponding
119         selection states of the page descriptors.
120     */
121     void SetCoreSelection (void);
122 
123     VisualState& GetVisualState (void);
124 
125     Rectangle GetBoundingBox (void) const;
126     Point GetLocation (const bool bIgnoreLocation = false) const;
127     void SetBoundingBox (const Rectangle& rBoundingBox);
128 
129 private:
130 	SdPage* mpPage;
131     css::uno::Reference<css::drawing::XDrawPage> mxPage;
132 	SdrPage const* mpMasterPage;
133 
134     /** This index is displayed as page number in the view.  It may or may
135         not be the actual page index.
136     */
137     sal_Int32 mnIndex;
138 
139     Rectangle maBoundingBox;
140     VisualState maVisualState;
141 
142     bool mbIsSelected : 1;
143     bool mbWasSelected : 1;
144     bool mbIsVisible : 1;
145     bool mbIsFocused : 1;
146     bool mbIsCurrent : 1;
147     bool mbIsMouseOver : 1;
148     bool mbHasTransition : 1;
149 
150 
151     // Do not use the copy constructor operator.  It is not implemented.
152     PageDescriptor (const PageDescriptor& rDescriptor);
153 
154     // Do not use the assignment operator.  It is not implemented
155     // (mrPage can not be assigned).
156     PageDescriptor& operator= (const PageDescriptor& rDescriptor);
157 };
158 
159 } } } // end of namespace ::sd::slidesorter::model
160 
161 #endif
162