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: SdUnoSlideView.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 "SdUnoSlideView.hxx"
35 #include "SlideSorter.hxx"
36 #include "controller/SlideSorterController.hxx"
37 #include "controller/SlsPageSelector.hxx"
38 #include "controller/SlsSelectionManager.hxx"
39 #include "model/SlsPageEnumerationProvider.hxx"
40 #include "model/SlideSorterModel.hxx"
41 #include "model/SlsPageDescriptor.hxx"
43 #include <com/sun/star/beans/XPropertySet.hpp>
45 using namespace ::com::sun::star
;
46 using namespace ::com::sun::star::uno
;
51 SdUnoSlideView::SdUnoSlideView (
52 DrawController
& rController
,
53 slidesorter::SlideSorter
& rSlideSorter
,
55 : DrawSubControllerInterfaceBase(m_aMutex
),
56 mrController(rController
),
57 mrSlideSorter(rSlideSorter
),
65 SdUnoSlideView::~SdUnoSlideView (void) throw()
72 //----- XSelectionSupplier ----------------------------------------------------
74 sal_Bool SAL_CALL
SdUnoSlideView::select (const Any
& aSelection
)
75 throw(lang::IllegalArgumentException
, RuntimeException
)
79 slidesorter::controller::SlideSorterController
& rSlideSorterController
80 = mrSlideSorter
.GetController();
81 slidesorter::controller::PageSelector
& rSelector (rSlideSorterController
.GetPageSelector());
82 rSelector
.DeselectAllPages();
83 Sequence
<Reference
<drawing::XDrawPage
> > xPages
;
84 aSelection
>>= xPages
;
85 const sal_uInt32 nCount
= xPages
.getLength();
86 for (sal_uInt32 nIndex
=0; nIndex
<nCount
; ++nIndex
)
88 Reference
<beans::XPropertySet
> xSet (xPages
[nIndex
], UNO_QUERY
);
93 Any aNumber
= xSet
->getPropertyValue(
94 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Number")));
95 sal_Int32 nPageNumber
= 0;
96 aNumber
>>= nPageNumber
;
97 nPageNumber
-=1; // Transform 1-based page numbers to 0-based ones.
98 rSelector
.SelectPage(nPageNumber
);
100 catch(RuntimeException e
)
105 rSlideSorterController
.GetSelectionManager()->MakeSelectionVisible();
113 Any SAL_CALL
SdUnoSlideView::getSelection (void)
114 throw(RuntimeException
)
118 slidesorter::model::PageEnumeration
aSelectedPages (
119 slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
120 mrSlideSorter
.GetModel()));
121 int nSelectedPageCount (
122 mrSlideSorter
.GetController().GetPageSelector().GetSelectedPageCount());
124 Sequence
<Reference
<XInterface
> > aPages(nSelectedPageCount
);
126 while (aSelectedPages
.HasMoreElements() && nIndex
<nSelectedPageCount
)
128 slidesorter::model::SharedPageDescriptor
pDescriptor (aSelectedPages
.GetNextElement());
129 aPages
[nIndex
++] = pDescriptor
->GetPage()->getUnoPage();
139 void SAL_CALL
SdUnoSlideView::addSelectionChangeListener (
140 const css::uno::Reference
<css::view::XSelectionChangeListener
>& rxListener
)
141 throw(css::uno::RuntimeException
)
149 void SAL_CALL
SdUnoSlideView::removeSelectionChangeListener (
150 const css::uno::Reference
<css::view::XSelectionChangeListener
>& rxListener
)
151 throw(css::uno::RuntimeException
)
159 //----- XDrawView -------------------------------------------------------------
161 void SAL_CALL
SdUnoSlideView::setCurrentPage (
162 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>& )
163 throw(::com::sun::star::uno::RuntimeException
)
170 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
> SAL_CALL
171 SdUnoSlideView::getCurrentPage (void)
172 throw(::com::sun::star::uno::RuntimeException
)
174 return Reference
<drawing::XDrawPage
>();
180 //----- XFastPropertySet ------------------------------------------------------
182 void SdUnoSlideView::setFastPropertyValue (
185 throw(css::beans::UnknownPropertyException
,
186 css::beans::PropertyVetoException
,
187 css::lang::IllegalArgumentException
,
188 css::lang::WrappedTargetException
,
189 css::uno::RuntimeException
)
194 throw beans::UnknownPropertyException();
200 Any SAL_CALL
SdUnoSlideView::getFastPropertyValue (
202 throw(css::beans::UnknownPropertyException
,
203 css::lang::WrappedTargetException
,
204 css::uno::RuntimeException
)
208 throw beans::UnknownPropertyException();
215 void SdUnoSlideView::FillPropertyTable (
216 ::std::vector< ::com::sun::star::beans::Property>& )
223 sal_Bool SAL_CALL SdUnoSlideView::convertFastPropertyValue(
224 ::com::sun::star::uno::Any & ,
225 ::com::sun::star::uno::Any & ,
227 const ::com::sun::star::uno::Any& )
228 throw (::com::sun::star::lang::IllegalArgumentException)
236 void SAL_CALL SdUnoSlideView::setFastPropertyValue_NoBroadcast(
238 const ::com::sun::star::uno::Any& )
239 throw (::com::sun::star::uno::Exception)
246 void SAL_CALL SdUnoSlideView::getFastPropertyValue( ::com::sun::star::uno::Any&, sal_Int32 ) const
252 } // end of namespace sd