bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / slidesorter / model / SlsPageDescriptor.cxx
blob56a9cd847505b3883b70b2f157597aab411f09fb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <model/SlsPageDescriptor.hxx>
22 #include <sdpage.hxx>
23 #include <drawdoc.hxx>
25 #include <svx/svdopage.hxx>
26 #include <svx/svdpagv.hxx>
27 #include <svx/sdr/contact/viewcontact.hxx>
28 #include <svx/sdr/contact/viewobjectcontact.hxx>
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star;
33 namespace sd { namespace slidesorter { namespace model {
35 PageDescriptor::PageDescriptor (
36 const Reference<drawing::XDrawPage>& rxPage,
37 SdPage* pPage,
38 const sal_Int32 nIndex)
39 : mpPage(pPage),
40 mxPage(rxPage),
41 mpMasterPage(nullptr),
42 mnIndex(nIndex),
43 maBoundingBox(),
44 maVisualState(nIndex),
45 mbIsSelected(false),
46 mbWasSelected(false),
47 mbIsVisible(false),
48 mbIsFocused(false),
49 mbIsCurrent(false),
50 mbIsMouseOver(false),
51 mbHasTransition(false)
53 assert(mpPage);
54 assert(mpPage == SdPage::getImplementation(rxPage));
55 if (mpPage != nullptr)
57 if (mpPage->TRG_HasMasterPage())
58 mpMasterPage = &mpPage->TRG_GetMasterPage();
59 if (mpPage->getTransitionType() > 0)
60 mbHasTransition = true;
64 PageDescriptor::~PageDescriptor()
68 void PageDescriptor::SetPageIndex (const sal_Int32 nNewIndex)
70 mnIndex = nNewIndex;
71 maVisualState.mnPageId = nNewIndex;
74 bool PageDescriptor::UpdateMasterPage()
76 const SdrPage* pMaster = nullptr;
77 if (mpPage!=nullptr && mpPage->TRG_HasMasterPage())
78 pMaster = &mpPage->TRG_GetMasterPage();
79 if (mpMasterPage != pMaster)
81 mpMasterPage = pMaster;
82 return true;
84 else
85 return false;
88 bool PageDescriptor::UpdateTransitionFlag()
90 bool bHasSlideTransition (false);
91 if (mpPage != nullptr)
92 bHasSlideTransition = mpPage->getTransitionType() > 0;
93 if (bHasSlideTransition != mbHasTransition)
95 mbHasTransition = bHasSlideTransition;
96 return true;
98 else
99 return false;
102 bool PageDescriptor::HasState (const State eState) const
104 switch (eState)
106 case ST_Visible:
107 return mbIsVisible;
109 case ST_Selected:
110 return mbIsSelected;
112 case ST_WasSelected:
113 return mbWasSelected;
115 case ST_Focused:
116 return mbIsFocused;
118 case ST_MouseOver:
119 return mbIsMouseOver;
121 case ST_Current:
122 return mbIsCurrent;
124 case ST_Excluded:
125 return mpPage!=nullptr && mpPage->IsExcluded();
127 default:
128 assert(false);
129 return false;
133 bool PageDescriptor::SetState (const State eState, const bool bNewStateValue)
135 bool bModified (false);
136 switch (eState)
138 case ST_Visible:
139 bModified = (bNewStateValue!=mbIsVisible);
140 if (bModified)
141 mbIsVisible = bNewStateValue;
142 break;
144 case ST_Selected:
145 bModified = (bNewStateValue!=mbIsSelected);
146 if (bModified)
147 mbIsSelected = bNewStateValue;
148 break;
150 case ST_WasSelected:
151 bModified = (bNewStateValue!=mbWasSelected);
152 if (bModified)
153 mbWasSelected = bNewStateValue;
154 break;
156 case ST_Focused:
157 bModified = (bNewStateValue!=mbIsFocused);
158 if (bModified)
159 mbIsFocused = bNewStateValue;
160 break;
162 case ST_MouseOver:
163 bModified = (bNewStateValue!=mbIsMouseOver);
164 if (bModified)
165 mbIsMouseOver = bNewStateValue;
166 break;
168 case ST_Current:
169 bModified = (bNewStateValue!=mbIsCurrent);
170 if (bModified)
171 mbIsCurrent = bNewStateValue;
172 break;
174 case ST_Excluded:
175 // This is a state of the page and has to be handled differently
176 // from the view-only states.
177 if (mpPage != nullptr)
178 if (bNewStateValue != mpPage->IsExcluded())
180 mpPage->SetExcluded(bNewStateValue);
181 bModified = true;
183 break;
186 return bModified;
189 bool PageDescriptor::GetCoreSelection()
191 if (mpPage!=nullptr && mpPage->IsSelected() != mbIsSelected)
192 return SetState(ST_Selected, !mbIsSelected);
193 else
194 return false;
197 void PageDescriptor::SetCoreSelection()
199 if (mpPage != nullptr)
200 if (HasState(ST_Selected))
201 mpPage->SetSelected(true);
202 else
203 mpPage->SetSelected(false);
204 else
206 assert(mpPage!=nullptr);
210 ::tools::Rectangle PageDescriptor::GetBoundingBox() const
212 ::tools::Rectangle aBox (maBoundingBox);
213 const Point aOffset (maVisualState.GetLocationOffset());
214 aBox.Move(aOffset.X(), aOffset.Y());
215 return aBox;
218 Point PageDescriptor::GetLocation (const bool bIgnoreOffset) const
220 if (bIgnoreOffset)
221 return maBoundingBox.TopLeft();
222 else
223 return maBoundingBox.TopLeft() + maVisualState.GetLocationOffset();
226 void PageDescriptor::SetBoundingBox (const ::tools::Rectangle& rBoundingBox)
228 maBoundingBox = rBoundingBox;
231 } } } // end of namespace ::sd::slidesorter::model
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */