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 <cppuhelper/supportsservice.hxx>
22 #include <DrawController.hxx>
23 #include <SdUnoSlideView.hxx>
25 #include <SlideSorter.hxx>
26 #include <controller/SlideSorterController.hxx>
27 #include <controller/SlsPageSelector.hxx>
28 #include <controller/SlsCurrentSlideManager.hxx>
29 #include <model/SlsPageEnumerationProvider.hxx>
30 #include <model/SlideSorterModel.hxx>
31 #include <model/SlsPageDescriptor.hxx>
33 #include <com/sun/star/beans/XPropertySet.hpp>
35 using namespace ::com::sun::star
;
36 using namespace ::com::sun::star::uno
;
40 SdUnoSlideView::SdUnoSlideView (
41 slidesorter::SlideSorter
& rSlideSorter
) throw()
42 : DrawSubControllerInterfaceBase(m_aMutex
),
43 mrSlideSorter(rSlideSorter
)
47 SdUnoSlideView::~SdUnoSlideView() throw()
51 //----- XSelectionSupplier ----------------------------------------------------
53 sal_Bool SAL_CALL
SdUnoSlideView::select (const Any
& aSelection
)
55 slidesorter::controller::SlideSorterController
& rSlideSorterController
56 = mrSlideSorter
.GetController();
57 slidesorter::controller::PageSelector
& rSelector (rSlideSorterController
.GetPageSelector());
58 rSelector
.DeselectAllPages();
59 Sequence
<Reference
<drawing::XDrawPage
> > xPages
;
60 aSelection
>>= xPages
;
61 const sal_uInt32 nCount
= xPages
.getLength();
62 for (sal_uInt32 nIndex
=0; nIndex
<nCount
; ++nIndex
)
64 Reference
<beans::XPropertySet
> xSet (xPages
[nIndex
], UNO_QUERY
);
69 Any aNumber
= xSet
->getPropertyValue("Number");
70 sal_Int32 nPageNumber
= 0;
71 aNumber
>>= nPageNumber
;
72 nPageNumber
-=1; // Transform 1-based page numbers to 0-based ones.
73 rSelector
.SelectPage(nPageNumber
);
75 catch (const RuntimeException
&)
84 Any SAL_CALL
SdUnoSlideView::getSelection()
88 slidesorter::model::PageEnumeration
aSelectedPages (
89 slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
90 mrSlideSorter
.GetModel()));
91 int nSelectedPageCount (
92 mrSlideSorter
.GetController().GetPageSelector().GetSelectedPageCount());
94 Sequence
<Reference
<XInterface
> > aPages(nSelectedPageCount
);
96 while (aSelectedPages
.HasMoreElements() && nIndex
<nSelectedPageCount
)
98 slidesorter::model::SharedPageDescriptor
pDescriptor (aSelectedPages
.GetNextElement());
99 aPages
[nIndex
++] = pDescriptor
->GetPage()->getUnoPage();
106 void SAL_CALL
SdUnoSlideView::addSelectionChangeListener (
107 const css::uno::Reference
<css::view::XSelectionChangeListener
>&)
110 void SAL_CALL
SdUnoSlideView::removeSelectionChangeListener (
111 const css::uno::Reference
<css::view::XSelectionChangeListener
>&)
114 //----- XDrawView -------------------------------------------------------------
116 void SAL_CALL
SdUnoSlideView::setCurrentPage (
117 const css::uno::Reference
<css::drawing::XDrawPage
>& rxDrawPage
)
119 Reference
<beans::XPropertySet
> xProperties (rxDrawPage
, UNO_QUERY
);
120 if (xProperties
.is())
122 sal_uInt16
nPageNumber(0);
123 if (xProperties
->getPropertyValue("Number") >>= nPageNumber
)
125 mrSlideSorter
.GetController().GetCurrentSlideManager()->SwitchCurrentSlide(
131 css::uno::Reference
<css::drawing::XDrawPage
> SAL_CALL
132 SdUnoSlideView::getCurrentPage()
134 return mrSlideSorter
.GetController().GetCurrentSlideManager()->GetCurrentSlide()->GetXDrawPage();
137 //----- XFastPropertySet ------------------------------------------------------
139 void SdUnoSlideView::setFastPropertyValue (
143 throw beans::UnknownPropertyException( OUString::number(nHandle
), static_cast<cppu::OWeakObject
*>(this));
146 Any SAL_CALL
SdUnoSlideView::getFastPropertyValue (
149 if( nHandle
!= DrawController::PROPERTY_VIEWOFFSET
)
150 throw beans::UnknownPropertyException( OUString::number(nHandle
), static_cast<cppu::OWeakObject
*>(this));
156 OUString SAL_CALL
SdUnoSlideView::getImplementationName( )
158 return OUString( "com.sun.star.comp.sd.SdUnoSlideView" );
161 sal_Bool SAL_CALL
SdUnoSlideView::supportsService( const OUString
& ServiceName
)
163 return cppu::supportsService( this, ServiceName
);
166 Sequence
< OUString
> SAL_CALL
SdUnoSlideView::getSupportedServiceNames( )
168 OUString
aSN( "com.sun.star.presentation.SlidesView" );
169 uno::Sequence
< OUString
> aSeq( &aSN
, 1 );
173 } // end of namespace sd
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */