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 .
20 #include <model/SlsPageDescriptor.hxx>
24 using namespace ::com::sun::star::uno
;
25 using namespace ::com::sun::star
;
27 namespace sd::slidesorter::model
{
29 PageDescriptor::PageDescriptor (
30 const Reference
<drawing::XDrawPage
>& rxPage
,
32 const sal_Int32 nIndex
)
35 mpMasterPage(nullptr),
37 maVisualState(nIndex
),
44 mbHasTransition(false)
47 assert(mpPage
== SdPage::getImplementation(rxPage
));
48 if (mpPage
!= nullptr)
50 if (mpPage
->TRG_HasMasterPage())
51 mpMasterPage
= &mpPage
->TRG_GetMasterPage();
52 if (mpPage
->getTransitionType() > 0)
53 mbHasTransition
= true;
57 PageDescriptor::~PageDescriptor()
61 void PageDescriptor::SetPageIndex (const sal_Int32 nNewIndex
)
64 maVisualState
.mnPageId
= nNewIndex
;
67 bool PageDescriptor::UpdateMasterPage()
69 const SdrPage
* pMaster
= nullptr;
70 if (mpPage
!=nullptr && mpPage
->TRG_HasMasterPage())
71 pMaster
= &mpPage
->TRG_GetMasterPage();
72 if (mpMasterPage
!= pMaster
)
74 mpMasterPage
= pMaster
;
81 bool PageDescriptor::UpdateTransitionFlag()
83 bool bHasSlideTransition (false);
84 if (mpPage
!= nullptr)
85 bHasSlideTransition
= mpPage
->getTransitionType() > 0;
86 if (bHasSlideTransition
!= mbHasTransition
)
88 mbHasTransition
= bHasSlideTransition
;
95 bool PageDescriptor::HasState (const State eState
) const
106 return mbWasSelected
;
112 return mbIsMouseOver
;
118 return mpPage
!=nullptr && mpPage
->IsExcluded();
126 bool PageDescriptor::SetState (const State eState
, const bool bNewStateValue
)
128 bool bModified (false);
132 bModified
= (bNewStateValue
!=mbIsVisible
);
134 mbIsVisible
= bNewStateValue
;
138 bModified
= (bNewStateValue
!=mbIsSelected
);
140 mbIsSelected
= bNewStateValue
;
144 bModified
= (bNewStateValue
!=mbWasSelected
);
146 mbWasSelected
= bNewStateValue
;
150 bModified
= (bNewStateValue
!=mbIsFocused
);
152 mbIsFocused
= bNewStateValue
;
156 bModified
= (bNewStateValue
!=mbIsMouseOver
);
158 mbIsMouseOver
= bNewStateValue
;
162 bModified
= (bNewStateValue
!=mbIsCurrent
);
164 mbIsCurrent
= bNewStateValue
;
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())
173 mpPage
->SetExcluded(bNewStateValue
);
182 bool PageDescriptor::GetCoreSelection()
184 if (mpPage
!=nullptr && mpPage
->IsSelected() != mbIsSelected
)
185 return SetState(ST_Selected
, !mbIsSelected
);
190 void PageDescriptor::SetCoreSelection()
192 if (mpPage
!= nullptr)
193 if (HasState(ST_Selected
))
194 mpPage
->SetSelected(true);
196 mpPage
->SetSelected(false);
199 assert(mpPage
!=nullptr);
203 ::tools::Rectangle
PageDescriptor::GetBoundingBox() const
205 ::tools::Rectangle
aBox (maBoundingBox
);
206 const Point
aOffset (maVisualState
.GetLocationOffset());
207 aBox
.Move(aOffset
.X(), aOffset
.Y());
211 Point
PageDescriptor::GetLocation (const bool bIgnoreOffset
) const
214 return maBoundingBox
.TopLeft();
216 return maBoundingBox
.TopLeft() + maVisualState
.GetLocationOffset();
219 void PageDescriptor::SetBoundingBox (const ::tools::Rectangle
& rBoundingBox
)
221 maBoundingBox
= rBoundingBox
;
224 } // end of namespace ::sd::slidesorter::model
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */