1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <model/SlsVisualState.hxx>
23 #include <tools/gen.hxx>
24 #include <com/sun/star/uno/Reference.hxx>
28 namespace com::sun::star::drawing
{ class XDrawPage
; }
33 namespace sd::slidesorter::model
{
35 /** Each PageDescriptor object represents the preview of one draw page,
36 slide, or master page of a Draw or Impress document as they are displayed
37 in the slide sorter. This class gives access to some associated
38 information like prerendered preview or position on the screen.
40 <p>Bounding boxes of page objects come in four varieties:
41 Model and screen/pixel coordinates and the bounding boxes of the actual
42 page objects and the larger bounding boxes that include page names and
46 : public ::std::enable_shared_from_this
<PageDescriptor
>
49 /** Create a PageDescriptor for the given SdPage object.
51 The page that is represented by the new PageDescriptor object.
53 The page pointer can in some situations not be detected from
54 rxPage, e.g. after undo of page deletion. Therefore supply it
57 This index is displayed in the view as page number. It is not
58 necessarily the page index (not even when you add or subtract 1
59 or use (x-1)/2 magic).
62 const css::uno::Reference
<css::drawing::XDrawPage
>& rxPage
,
64 const sal_Int32 nIndex
);
68 /** Return the page that is represented by the descriptor as SdPage pointer .
70 SdPage
* GetPage() const { return mpPage
;}
72 /** Return the page that is represented by the descriptor as XDrawPage reference.
74 const css::uno::Reference
<css::drawing::XDrawPage
>& GetXDrawPage() const { return mxPage
;}
76 /** Returns the index of the page as it is displayed in the view as page
77 number. The value may differ from the index returned by the
78 XDrawPage when there are hidden slides and the XIndexAccess used to
79 access the model filters them out.
81 sal_Int32
GetPageIndex() const { return mnIndex
;}
82 void SetPageIndex (const sal_Int32 nIndex
);
84 bool UpdateMasterPage();
85 bool UpdateTransitionFlag();
87 enum State
{ ST_Visible
, ST_Selected
, ST_WasSelected
,
88 ST_Focused
, ST_MouseOver
, ST_Current
, ST_Excluded
};
90 bool HasState (const State eState
) const;
92 bool SetState (const State eState
, const bool bStateValue
);
94 /** Set the internal mbIsSelected flag to the selection state of the
95 page. Use this method to synchronize a page descriptor with the
96 page it describes and determine whether a redraw to update the
97 selection indicator is necessary.
99 When the two selection states were different <TRUE/> is
100 returned. When they were the same this method returns
103 bool GetCoreSelection();
105 /** Set the selection flags of the SdPage objects to the corresponding
106 selection states of the page descriptors.
108 void SetCoreSelection();
110 VisualState
& GetVisualState() { return maVisualState
;}
112 ::tools::Rectangle
GetBoundingBox() const;
113 Point
GetLocation (const bool bIgnoreLocation
) const;
114 void SetBoundingBox (const ::tools::Rectangle
& rBoundingBox
);
118 css::uno::Reference
<css::drawing::XDrawPage
> mxPage
;
119 SdrPage
const* mpMasterPage
;
121 /** This index is displayed as page number in the view. It may or may
122 not be the actual page index.
126 ::tools::Rectangle maBoundingBox
;
127 VisualState maVisualState
;
129 bool mbIsSelected
: 1;
130 bool mbWasSelected
: 1;
131 bool mbIsVisible
: 1;
132 bool mbIsFocused
: 1;
133 bool mbIsCurrent
: 1;
134 bool mbIsMouseOver
: 1;
135 bool mbHasTransition
: 1;
137 PageDescriptor (const PageDescriptor
& rDescriptor
) = delete;
139 PageDescriptor
& operator= (const PageDescriptor
& rDescriptor
) = delete;
142 } // end of namespace ::sd::slidesorter::model
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */