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"
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
,
38 const sal_Int32 nIndex
)
44 maVisualState(nIndex
),
51 mbHasTransition(false)
54 OSL_ASSERT(mpPage
== SdPage::getImplementation(rxPage
));
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
)
71 maVisualState
.mnPageId
= nNewIndex
;
74 bool PageDescriptor::UpdateMasterPage()
76 const SdrPage
* pMaster
= NULL
;
77 if (mpPage
!=NULL
&& mpPage
->TRG_HasMasterPage())
78 pMaster
= &mpPage
->TRG_GetMasterPage();
79 if (mpMasterPage
!= pMaster
)
81 mpMasterPage
= pMaster
;
88 bool PageDescriptor::UpdateTransitionFlag()
90 bool bHasSlideTransition (false);
92 bHasSlideTransition
= mpPage
->getTransitionType() > 0;
93 if (bHasSlideTransition
!= mbHasTransition
)
95 mbHasTransition
= bHasSlideTransition
;
102 bool PageDescriptor::HasState (const State eState
) const
113 return mbWasSelected
;
119 return mbIsMouseOver
;
125 return mpPage
!=NULL
&& mpPage
->IsExcluded();
133 bool PageDescriptor::SetState (const State eState
, const bool bNewStateValue
)
135 bool bModified (false);
139 bModified
= (bNewStateValue
!=mbIsVisible
);
141 mbIsVisible
= bNewStateValue
;
145 bModified
= (bNewStateValue
!=mbIsSelected
);
147 mbIsSelected
= bNewStateValue
;
151 bModified
= (bNewStateValue
!=mbWasSelected
);
153 mbWasSelected
= bNewStateValue
;
157 bModified
= (bNewStateValue
!=mbIsFocused
);
159 mbIsFocused
= bNewStateValue
;
163 bModified
= (bNewStateValue
!=mbIsMouseOver
);
165 mbIsMouseOver
= bNewStateValue
;
169 bModified
= (bNewStateValue
!=mbIsCurrent
);
171 mbIsCurrent
= bNewStateValue
;
175 // This is a state of the page and has to be handled differently
176 // from the view-only states.
178 if (bNewStateValue
!= mpPage
->IsExcluded())
180 mpPage
->SetExcluded(bNewStateValue
);
187 maVisualState
.UpdateVisualState(*this);
191 bool PageDescriptor::GetCoreSelection()
193 if (mpPage
!=NULL
&& mpPage
->IsSelected() != mbIsSelected
)
194 return SetState(ST_Selected
, !mbIsSelected
);
199 void PageDescriptor::SetCoreSelection()
202 if (HasState(ST_Selected
))
203 mpPage
->SetSelected(true);
205 mpPage
->SetSelected(false);
208 OSL_ASSERT(mpPage
!=NULL
);
212 Rectangle
PageDescriptor::GetBoundingBox() const
214 Rectangle
aBox (maBoundingBox
);
215 const Point
aOffset (maVisualState
.GetLocationOffset());
216 aBox
.Move(aOffset
.X(), aOffset
.Y());
220 Point
PageDescriptor::GetLocation (const bool bIgnoreOffset
) const
223 return maBoundingBox
.TopLeft();
225 return maBoundingBox
.TopLeft() + maVisualState
.GetLocationOffset();
228 void PageDescriptor::SetBoundingBox (const Rectangle
& rBoundingBox
)
230 maBoundingBox
= rBoundingBox
;
233 } } } // end of namespace ::sd::slidesorter::model
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */