LibreOffice Module sd (master) 1
SlsPageDescriptor.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21
22#include <sdpage.hxx>
23
24using namespace ::com::sun::star::uno;
25using namespace ::com::sun::star;
26
27namespace sd::slidesorter::model {
28
30 const Reference<drawing::XDrawPage>& rxPage,
31 SdPage* pPage,
32 const sal_Int32 nIndex)
33 : mpPage(pPage),
34 mxPage(rxPage),
35 mpMasterPage(nullptr),
37 maVisualState(nIndex),
38 mbIsSelected(false),
39 mbWasSelected(false),
40 mbIsVisible(false),
41 mbIsFocused(false),
42 mbIsCurrent(false),
43 mbIsMouseOver(false),
44 mbHasTransition(false)
45{
46 assert(mpPage);
47 assert(mpPage == SdPage::getImplementation(rxPage));
48 if (mpPage != nullptr)
49 {
50 if (mpPage->TRG_HasMasterPage())
51 mpMasterPage = &mpPage->TRG_GetMasterPage();
52 if (mpPage->getTransitionType() > 0)
53 mbHasTransition = true;
54 }
55}
56
57PageDescriptor::~PageDescriptor()
58{
59}
60
61void PageDescriptor::SetPageIndex (const sal_Int32 nNewIndex)
62{
63 mnIndex = nNewIndex;
64 maVisualState.mnPageId = nNewIndex;
65}
66
67bool PageDescriptor::UpdateMasterPage()
68{
69 const SdrPage* pMaster = nullptr;
70 if (mpPage!=nullptr && mpPage->TRG_HasMasterPage())
71 pMaster = &mpPage->TRG_GetMasterPage();
72 if (mpMasterPage != pMaster)
73 {
74 mpMasterPage = pMaster;
75 return true;
76 }
77 else
78 return false;
79}
80
81bool PageDescriptor::UpdateTransitionFlag()
82{
83 bool bHasSlideTransition (false);
84 if (mpPage != nullptr)
85 bHasSlideTransition = mpPage->getTransitionType() > 0;
86 if (bHasSlideTransition != mbHasTransition)
87 {
88 mbHasTransition = bHasSlideTransition;
89 return true;
90 }
91 else
92 return false;
93}
94
95bool PageDescriptor::HasState (const State eState) const
96{
97 switch (eState)
98 {
99 case ST_Visible:
100 return mbIsVisible;
101
102 case ST_Selected:
103 return mbIsSelected;
104
105 case ST_WasSelected:
106 return mbWasSelected;
107
108 case ST_Focused:
109 return mbIsFocused;
110
111 case ST_MouseOver:
112 return mbIsMouseOver;
113
114 case ST_Current:
115 return mbIsCurrent;
116
117 case ST_Excluded:
118 return mpPage!=nullptr && mpPage->IsExcluded();
119
120 default:
121 assert(false);
122 return false;
123 }
124}
125
126bool PageDescriptor::SetState (const State eState, const bool bNewStateValue)
127{
128 bool bModified (false);
129 switch (eState)
130 {
131 case ST_Visible:
132 bModified = (bNewStateValue!=mbIsVisible);
133 if (bModified)
134 mbIsVisible = bNewStateValue;
135 break;
136
137 case ST_Selected:
138 bModified = (bNewStateValue!=mbIsSelected);
139 if (bModified)
140 mbIsSelected = bNewStateValue;
141 break;
142
143 case ST_WasSelected:
144 bModified = (bNewStateValue!=mbWasSelected);
145 if (bModified)
146 mbWasSelected = bNewStateValue;
147 break;
148
149 case ST_Focused:
150 bModified = (bNewStateValue!=mbIsFocused);
151 if (bModified)
152 mbIsFocused = bNewStateValue;
153 break;
154
155 case ST_MouseOver:
156 bModified = (bNewStateValue!=mbIsMouseOver);
157 if (bModified)
158 mbIsMouseOver = bNewStateValue;
159 break;
160
161 case ST_Current:
162 bModified = (bNewStateValue!=mbIsCurrent);
163 if (bModified)
164 mbIsCurrent = bNewStateValue;
165 break;
166
167 case ST_Excluded:
168 // This is a state of the page and has to be handled differently
169 // from the view-only states.
170 if (mpPage != nullptr)
171 if (bNewStateValue != mpPage->IsExcluded())
172 {
173 mpPage->SetExcluded(bNewStateValue);
174 bModified = true;
175 }
176 break;
177 }
178
179 return bModified;
180}
181
182bool PageDescriptor::GetCoreSelection()
183{
184 if (mpPage!=nullptr && mpPage->IsSelected() != mbIsSelected)
185 return SetState(ST_Selected, !mbIsSelected);
186 else
187 return false;
188}
189
190void PageDescriptor::SetCoreSelection()
191{
192 if (mpPage != nullptr)
193 if (HasState(ST_Selected))
194 mpPage->SetSelected(true);
195 else
196 mpPage->SetSelected(false);
197 else
198 {
199 assert(mpPage!=nullptr);
200 }
201}
202
203::tools::Rectangle PageDescriptor::GetBoundingBox() const
204{
205 ::tools::Rectangle aBox (maBoundingBox);
206 const Point aOffset (maVisualState.GetLocationOffset());
207 aBox.Move(aOffset.X(), aOffset.Y());
208 return aBox;
209}
210
211Point PageDescriptor::GetLocation (const bool bIgnoreOffset) const
212{
213 if (bIgnoreOffset)
214 return maBoundingBox.TopLeft();
215 else
216 return maBoundingBox.TopLeft() + maVisualState.GetLocationOffset();
217}
218
219void PageDescriptor::SetBoundingBox (const ::tools::Rectangle& rBoundingBox)
220{
221 maBoundingBox = rBoundingBox;
222}
223
224} // end of namespace ::sd::slidesorter::model
225
226/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FPDF_PAGE mpPage
bool mbIsSelected
constexpr tools::Long Y() const
constexpr tools::Long X() const
static SdPage * getImplementation(const css::uno::Reference< css::drawing::XDrawPage > &xPage)
returns the SdPage implementation for the given XDrawPage or 0 if not available
Definition: sdpage.cxx:2682
PageDescriptor(const css::uno::Reference< css::drawing::XDrawPage > &rxPage, SdPage *pPage, const sal_Int32 nIndex)
Create a PageDescriptor for the given SdPage object.
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
sal_Int32 nIndex
sal_uInt32 mnIndex