bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / unoidl / SdUnoSlideView.cxx
bloba2758fb9071832e1ebe40801158c8240486c26cd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
32 #include <sdpage.hxx>
33 #include <com/sun/star/beans/XPropertySet.hpp>
35 using namespace ::com::sun::star;
36 using namespace ::com::sun::star::uno;
38 namespace sd {
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);
65 if (xSet.is())
67 try
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&)
81 return true;
84 Any SAL_CALL SdUnoSlideView::getSelection()
86 Any aResult;
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);
95 int nIndex = 0;
96 while (aSelectedPages.HasMoreElements() && nIndex<nSelectedPageCount)
98 slidesorter::model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
99 aPages[nIndex++] = pDescriptor->GetPage()->getUnoPage();
101 aResult <<= aPages;
103 return aResult;
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(
126 nPageNumber-1);
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 (
140 sal_Int32 nHandle,
141 const Any&)
143 throw beans::UnknownPropertyException( OUString::number(nHandle), static_cast<cppu::OWeakObject*>(this));
146 Any SAL_CALL SdUnoSlideView::getFastPropertyValue (
147 sal_Int32 nHandle)
149 if( nHandle != DrawController::PROPERTY_VIEWOFFSET )
150 throw beans::UnknownPropertyException( OUString::number(nHandle), static_cast<cppu::OWeakObject*>(this));
152 return Any();
155 // XServiceInfo
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 );
170 return aSeq;
173 } // end of namespace sd
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */