1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlsSelectionCommand.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "precompiled_sd.hxx"
33 #include "SlsSelectionCommand.hxx"
35 #include "controller/SlsCurrentSlideManager.hxx"
36 #include "model/SlideSorterModel.hxx"
37 #include "model/SlsPageDescriptor.hxx"
41 namespace sd
{ namespace slidesorter
{ namespace controller
{
45 SelectionCommand::SelectionCommand (
46 PageSelector
& rSelector
,
47 const ::boost::shared_ptr
<CurrentSlideManager
>& rpCurrentSlideManager
,
48 const model::SlideSorterModel
& rModel
)
49 : mrPageSelector(rSelector
),
50 mpCurrentSlideManager(rpCurrentSlideManager
),
53 mnCurrentPageIndex(-1)
60 void SelectionCommand::AddSlides (
61 const ::boost::shared_ptr
<PageSelector::PageSelection
>& rpSelection
)
63 PageSelector::PageSelection::iterator iPage
= rpSelection
->begin();
64 PageSelector::PageSelection::iterator iEnd
= rpSelection
->end();
65 for (; iPage
!=iEnd
; ++iPage
)
66 AddSlide(((*iPage
)->GetPageNum()-1)/2);
72 void SelectionCommand::AddSlide (USHORT nPageIndex
)
74 maPagesToSelect
.push_back(nPageIndex
);
80 void SelectionCommand::SetCurrentSlide (USHORT nPageIndex
)
82 mnCurrentPageIndex
= nPageIndex
;
88 void SelectionCommand::operator() (void)
90 OSL_ASSERT(mpCurrentSlideManager
.get()!=NULL
);
92 mrPageSelector
.DeselectAllPages();
94 if (mnCurrentPageIndex
>= 0)
95 mpCurrentSlideManager
->SwitchCurrentSlide(mnCurrentPageIndex
);
97 PageList::iterator iPage
= maPagesToSelect
.begin();
98 PageList::iterator iEnd
= maPagesToSelect
.end();
99 for (; iPage
!=iEnd
; ++iPage
)
101 sal_Int32
nIndex (*iPage
);
103 mrPageSelector
.SelectPage(mrModel
.GetPageDescriptor(nIndex
));
108 } } } // end of namespace sd::slidesorter::controller