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 .
21 #include <comphelper/serviceinfohelper.hxx>
23 #include "DrawController.hxx"
24 #include "SdUnoSlideView.hxx"
26 #include "SlideSorter.hxx"
27 #include "controller/SlideSorterController.hxx"
28 #include "controller/SlsPageSelector.hxx"
29 #include "controller/SlsCurrentSlideManager.hxx"
30 #include "model/SlsPageEnumerationProvider.hxx"
31 #include "model/SlideSorterModel.hxx"
32 #include "model/SlsPageDescriptor.hxx"
34 #include <com/sun/star/beans/XPropertySet.hpp>
37 using namespace ::com::sun::star
;
38 using namespace ::com::sun::star::uno
;
43 SdUnoSlideView::SdUnoSlideView (
44 slidesorter::SlideSorter
& rSlideSorter
) throw()
45 : DrawSubControllerInterfaceBase(m_aMutex
),
46 mrSlideSorter(rSlideSorter
)
53 SdUnoSlideView::~SdUnoSlideView (void) throw()
60 //----- XSelectionSupplier ----------------------------------------------------
62 sal_Bool SAL_CALL
SdUnoSlideView::select (const Any
& aSelection
)
63 throw(lang::IllegalArgumentException
, RuntimeException
)
67 slidesorter::controller::SlideSorterController
& rSlideSorterController
68 = mrSlideSorter
.GetController();
69 slidesorter::controller::PageSelector
& rSelector (rSlideSorterController
.GetPageSelector());
70 rSelector
.DeselectAllPages();
71 Sequence
<Reference
<drawing::XDrawPage
> > xPages
;
72 aSelection
>>= xPages
;
73 const sal_uInt32 nCount
= xPages
.getLength();
74 for (sal_uInt32 nIndex
=0; nIndex
<nCount
; ++nIndex
)
76 Reference
<beans::XPropertySet
> xSet (xPages
[nIndex
], UNO_QUERY
);
81 Any aNumber
= xSet
->getPropertyValue("Number");
82 sal_Int32 nPageNumber
= 0;
83 aNumber
>>= nPageNumber
;
84 nPageNumber
-=1; // Transform 1-based page numbers to 0-based ones.
85 rSelector
.SelectPage(nPageNumber
);
87 catch (const RuntimeException
&)
99 Any SAL_CALL
SdUnoSlideView::getSelection (void)
100 throw(RuntimeException
)
104 slidesorter::model::PageEnumeration
aSelectedPages (
105 slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
106 mrSlideSorter
.GetModel()));
107 int nSelectedPageCount (
108 mrSlideSorter
.GetController().GetPageSelector().GetSelectedPageCount());
110 Sequence
<Reference
<XInterface
> > aPages(nSelectedPageCount
);
112 while (aSelectedPages
.HasMoreElements() && nIndex
<nSelectedPageCount
)
114 slidesorter::model::SharedPageDescriptor
pDescriptor (aSelectedPages
.GetNextElement());
115 aPages
[nIndex
++] = pDescriptor
->GetPage()->getUnoPage();
125 void SAL_CALL
SdUnoSlideView::addSelectionChangeListener (
126 const css::uno::Reference
<css::view::XSelectionChangeListener
>& rxListener
)
127 throw(css::uno::RuntimeException
)
135 void SAL_CALL
SdUnoSlideView::removeSelectionChangeListener (
136 const css::uno::Reference
<css::view::XSelectionChangeListener
>& rxListener
)
137 throw(css::uno::RuntimeException
)
145 //----- XDrawView -------------------------------------------------------------
147 void SAL_CALL
SdUnoSlideView::setCurrentPage (
148 const css::uno::Reference
<css::drawing::XDrawPage
>& rxDrawPage
)
149 throw(css::uno::RuntimeException
)
151 Reference
<beans::XPropertySet
> xProperties (rxDrawPage
, UNO_QUERY
);
152 if (xProperties
.is())
154 sal_uInt16
nPageNumber(0);
155 if (xProperties
->getPropertyValue("Number") >>= nPageNumber
)
157 mrSlideSorter
.GetController().GetCurrentSlideManager()->SwitchCurrentSlide(
167 css::uno::Reference
<css::drawing::XDrawPage
> SAL_CALL
168 SdUnoSlideView::getCurrentPage (void)
169 throw(css::uno::RuntimeException
)
171 return mrSlideSorter
.GetController().GetCurrentSlideManager()->GetCurrentSlide()->GetXDrawPage();
177 //----- XFastPropertySet ------------------------------------------------------
179 void SdUnoSlideView::setFastPropertyValue (
182 throw(css::beans::UnknownPropertyException
,
183 css::beans::PropertyVetoException
,
184 css::lang::IllegalArgumentException
,
185 css::lang::WrappedTargetException
,
186 css::uno::RuntimeException
)
191 throw beans::UnknownPropertyException();
197 Any SAL_CALL
SdUnoSlideView::getFastPropertyValue (
199 throw(css::beans::UnknownPropertyException
,
200 css::lang::WrappedTargetException
,
201 css::uno::RuntimeException
)
205 if( nHandle
!= DrawController::PROPERTY_VIEWOFFSET
)
206 throw beans::UnknownPropertyException();
213 OUString SAL_CALL
SdUnoSlideView::getImplementationName( ) throw (RuntimeException
)
215 return OUString( "com.sun.star.comp.sd.SdUnoSlideView" );
218 sal_Bool SAL_CALL
SdUnoSlideView::supportsService( const OUString
& ServiceName
) throw (RuntimeException
)
220 return comphelper::ServiceInfoHelper::supportsService( ServiceName
, getSupportedServiceNames() );
223 Sequence
< OUString
> SAL_CALL
SdUnoSlideView::getSupportedServiceNames( ) throw (RuntimeException
)
225 OUString
aSN( "com.sun.star.presentation.SlidesView" );
226 uno::Sequence
< OUString
> aSeq( &aSN
, 1 );
230 } // end of namespace sd
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */