LibreOffice Module sd (master) 1
SdUnoSlideView.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21
22#include <DrawController.hxx>
23#include <SdUnoSlideView.hxx>
24
25#include <SlideSorter.hxx>
31#include <sdpage.hxx>
32#include <com/sun/star/beans/XPropertySet.hpp>
33
34using namespace ::com::sun::star;
35using namespace ::com::sun::star::uno;
36
37namespace sd {
38
40 slidesorter::SlideSorter& rSlideSorter) noexcept
41 : mrSlideSorter(rSlideSorter)
42{
43}
44
46{
47}
48
49//----- XSelectionSupplier ----------------------------------------------------
50
51sal_Bool SAL_CALL SdUnoSlideView::select (const Any& aSelection)
52{
55 slidesorter::controller::PageSelector& rSelector (rSlideSorterController.GetPageSelector());
56 rSelector.DeselectAllPages();
57 Sequence<Reference<drawing::XDrawPage> > xPages;
58 aSelection >>= xPages;
59 for (const auto& rPage : std::as_const(xPages))
60 {
61 Reference<beans::XPropertySet> xSet (rPage, UNO_QUERY);
62 if (xSet.is())
63 {
64 try
65 {
66 Any aNumber = xSet->getPropertyValue("Number");
67 sal_Int32 nPageNumber = 0;
68 aNumber >>= nPageNumber;
69 nPageNumber -=1; // Transform 1-based page numbers to 0-based ones.
70 rSelector.SelectPage(nPageNumber);
71 }
72 catch (const RuntimeException&)
73 {
74 }
75 }
76 }
77
78 return true;
79}
80
82{
83 Any aResult;
84
88 int nSelectedPageCount (
90
91 Sequence<Reference<XInterface> > aPages(nSelectedPageCount);
92 auto aPagesRange = asNonConstRange(aPages);
93 int nIndex = 0;
94 while (aSelectedPages.HasMoreElements() && nIndex<nSelectedPageCount)
95 {
96 slidesorter::model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
97 aPagesRange[nIndex++] = pDescriptor->GetPage()->getUnoPage();
98 }
99 aResult <<= aPages;
100
101 return aResult;
102}
103
105 const css::uno::Reference<css::view::XSelectionChangeListener>&)
106{}
107
109 const css::uno::Reference<css::view::XSelectionChangeListener>&)
110{}
111
112//----- XDrawView -------------------------------------------------------------
113
115 const css::uno::Reference<css::drawing::XDrawPage>& rxDrawPage)
116{
117 Reference<beans::XPropertySet> xProperties (rxDrawPage, UNO_QUERY);
118 if (xProperties.is())
119 {
120 sal_uInt16 nPageNumber(0);
121 if (xProperties->getPropertyValue("Number") >>= nPageNumber)
122 {
123 mrSlideSorter.GetController().GetCurrentSlideManager()->SwitchCurrentSlide(
124 nPageNumber-1);
125 }
126 }
127}
128
129css::uno::Reference<css::drawing::XDrawPage > SAL_CALL
131{
132 return mrSlideSorter.GetController().GetCurrentSlideManager()->GetCurrentSlide()->GetXDrawPage();
133}
134
135//----- XFastPropertySet ------------------------------------------------------
136
138 sal_Int32 nHandle,
139 const Any&)
140{
141 throw beans::UnknownPropertyException( OUString::number(nHandle), static_cast<cppu::OWeakObject*>(this));
142}
143
145 sal_Int32 nHandle)
146{
148 throw beans::UnknownPropertyException( OUString::number(nHandle), static_cast<cppu::OWeakObject*>(this));
149
150 return Any();
151}
152
153// XServiceInfo
155{
156 return "com.sun.star.comp.sd.SdUnoSlideView";
157}
158
159sal_Bool SAL_CALL SdUnoSlideView::supportsService( const OUString& ServiceName )
160{
161 return cppu::supportsService( this, ServiceName );
162}
163
164Sequence< OUString > SAL_CALL SdUnoSlideView::getSupportedServiceNames( )
165{
166 return { "com.sun.star.presentation.SlidesView" };
167}
168
169} // end of namespace sd
170
171/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SlideSorter & mrSlideSorter
virtual ~SdUnoSlideView() noexcept override
SdUnoSlideView(slidesorter::SlideSorter &rSlideSorter) noexcept
slidesorter::SlideSorter & mrSlideSorter
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL removeSelectionChangeListener(const css::uno::Reference< css::view::XSelectionChangeListener > &rxListener) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL addSelectionChangeListener(const css::uno::Reference< css::view::XSelectionChangeListener > &rxListener) override
virtual void SAL_CALL setCurrentPage(const css::uno::Reference< css::drawing::XDrawPage > &xPage) override
virtual sal_Bool SAL_CALL select(const css::uno::Any &aSelection) override
virtual css::uno::Any SAL_CALL getSelection() override
virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getCurrentPage() override
virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) override
virtual void SAL_CALL setFastPropertyValue(sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Show previews for all the slides in a document and allow the user to insert or delete slides and modi...
Definition: SlideSorter.hxx:62
SD_DLLPUBLIC controller::SlideSorterController & GetController() const
model::SlideSorterModel & GetModel() const
A sub-controller that handles page selection of the slide browser.
void SelectPage(int nPageIndex)
Select the specified descriptor.
std::shared_ptr< CurrentSlideManager > const & GetCurrentSlideManager() const
static PageEnumeration CreateSelectedPagesEnumeration(const SlideSorterModel &rModel)
The returned enumeration of slides iterates over the currently selected slides of the given model.
Public class of page enumerations that delegates its calls to an implementation object that can filte...
virtual SharedPageDescriptor GetNextElement() override
Return the next element of the enumeration.
virtual bool HasMoreElements() const override
Return <TRUE> when the enumeration has more elements, i.e.
sal_Int32 nIndex
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
std::shared_ptr< PageDescriptor > SharedPageDescriptor
sal_Int32 nHandle
unsigned char sal_Bool