/src/libreoffice/sd/source/ui/unoidl/SdUnoSlideView.cxx
Line | Count | Source (jump to first uncovered line) |
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 | | |
20 | | #include <cppuhelper/supportsservice.hxx> |
21 | | |
22 | | #include <DrawController.hxx> |
23 | | #include <SdUnoSlideView.hxx> |
24 | | |
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/SlsPageDescriptor.hxx> |
31 | | #include <sdpage.hxx> |
32 | | #include <com/sun/star/beans/XPropertySet.hpp> |
33 | | |
34 | | using namespace ::com::sun::star; |
35 | | using namespace ::com::sun::star::uno; |
36 | | |
37 | | namespace sd { |
38 | | |
39 | | SdUnoSlideView::SdUnoSlideView ( |
40 | | slidesorter::SlideSorter& rSlideSorter) noexcept |
41 | 0 | : mrSlideSorter(rSlideSorter) |
42 | 0 | { |
43 | 0 | } Unexecuted instantiation: sd::SdUnoSlideView::SdUnoSlideView(sd::slidesorter::SlideSorter&) Unexecuted instantiation: sd::SdUnoSlideView::SdUnoSlideView(sd::slidesorter::SlideSorter&) |
44 | | |
45 | | SdUnoSlideView::~SdUnoSlideView() noexcept |
46 | 0 | { |
47 | 0 | } |
48 | | |
49 | | //----- XSelectionSupplier ---------------------------------------------------- |
50 | | |
51 | | sal_Bool SAL_CALL SdUnoSlideView::select (const Any& aSelection) |
52 | 0 | { |
53 | 0 | slidesorter::controller::SlideSorterController& rSlideSorterController |
54 | 0 | = mrSlideSorter.GetController(); |
55 | 0 | slidesorter::controller::PageSelector& rSelector (rSlideSorterController.GetPageSelector()); |
56 | 0 | rSelector.DeselectAllPages(); |
57 | 0 | Sequence<Reference<drawing::XDrawPage> > xPages; |
58 | 0 | aSelection >>= xPages; |
59 | 0 | for (const auto& rPage : xPages) |
60 | 0 | { |
61 | 0 | Reference<beans::XPropertySet> xSet (rPage, UNO_QUERY); |
62 | 0 | if (xSet.is()) |
63 | 0 | { |
64 | 0 | try |
65 | 0 | { |
66 | 0 | Any aNumber = xSet->getPropertyValue(u"Number"_ustr); |
67 | 0 | sal_Int32 nPageNumber = 0; |
68 | 0 | aNumber >>= nPageNumber; |
69 | 0 | nPageNumber -=1; // Transform 1-based page numbers to 0-based ones. |
70 | 0 | rSelector.SelectPage(nPageNumber); |
71 | 0 | } |
72 | 0 | catch (const RuntimeException&) |
73 | 0 | { |
74 | 0 | } |
75 | 0 | } |
76 | 0 | } |
77 | |
|
78 | 0 | return true; |
79 | 0 | } |
80 | | |
81 | | Any SAL_CALL SdUnoSlideView::getSelection() |
82 | 0 | { |
83 | 0 | Any aResult; |
84 | |
|
85 | 0 | slidesorter::model::PageEnumeration aSelectedPages ( |
86 | 0 | slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration( |
87 | 0 | mrSlideSorter.GetModel())); |
88 | 0 | int nSelectedPageCount ( |
89 | 0 | mrSlideSorter.GetController().GetPageSelector().GetSelectedPageCount()); |
90 | |
|
91 | 0 | Sequence<Reference<XInterface> > aPages(nSelectedPageCount); |
92 | 0 | auto aPagesRange = asNonConstRange(aPages); |
93 | 0 | int nIndex = 0; |
94 | 0 | while (aSelectedPages.HasMoreElements() && nIndex<nSelectedPageCount) |
95 | 0 | { |
96 | 0 | slidesorter::model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement()); |
97 | 0 | aPagesRange[nIndex++] = pDescriptor->GetPage()->getUnoPage(); |
98 | 0 | } |
99 | 0 | aResult <<= aPages; |
100 | |
|
101 | 0 | return aResult; |
102 | 0 | } |
103 | | |
104 | | void SAL_CALL SdUnoSlideView::addSelectionChangeListener ( |
105 | | const css::uno::Reference<css::view::XSelectionChangeListener>&) |
106 | 0 | {} |
107 | | |
108 | | void SAL_CALL SdUnoSlideView::removeSelectionChangeListener ( |
109 | | const css::uno::Reference<css::view::XSelectionChangeListener>&) |
110 | 0 | {} |
111 | | |
112 | | //----- XDrawView ------------------------------------------------------------- |
113 | | |
114 | | void SAL_CALL SdUnoSlideView::setCurrentPage ( |
115 | | const css::uno::Reference<css::drawing::XDrawPage>& rxDrawPage) |
116 | 0 | { |
117 | 0 | Reference<beans::XPropertySet> xProperties (rxDrawPage, UNO_QUERY); |
118 | 0 | if (xProperties.is()) |
119 | 0 | { |
120 | 0 | sal_uInt16 nPageNumber(0); |
121 | 0 | if (xProperties->getPropertyValue(u"Number"_ustr) >>= nPageNumber) |
122 | 0 | { |
123 | 0 | mrSlideSorter.GetController().GetCurrentSlideManager().SwitchCurrentSlide( |
124 | 0 | nPageNumber-1); |
125 | 0 | } |
126 | 0 | } |
127 | 0 | } |
128 | | |
129 | | css::uno::Reference<css::drawing::XDrawPage > SAL_CALL |
130 | | SdUnoSlideView::getCurrentPage() |
131 | 0 | { |
132 | 0 | return mrSlideSorter.GetController().GetCurrentSlideManager().GetCurrentSlide()->GetXDrawPage(); |
133 | 0 | } |
134 | | |
135 | | //----- XFastPropertySet ------------------------------------------------------ |
136 | | |
137 | | void SdUnoSlideView::setFastPropertyValue ( |
138 | | sal_Int32 nHandle, |
139 | | const Any&) |
140 | 0 | { |
141 | 0 | throw beans::UnknownPropertyException( OUString::number(nHandle), static_cast<cppu::OWeakObject*>(this)); |
142 | 0 | } |
143 | | |
144 | | Any SAL_CALL SdUnoSlideView::getFastPropertyValue ( |
145 | | sal_Int32 nHandle) |
146 | 0 | { |
147 | 0 | if( nHandle != DrawController::PROPERTY_VIEWOFFSET ) |
148 | 0 | throw beans::UnknownPropertyException( OUString::number(nHandle), static_cast<cppu::OWeakObject*>(this)); |
149 | | |
150 | 0 | return Any(); |
151 | 0 | } |
152 | | |
153 | | // XServiceInfo |
154 | | OUString SAL_CALL SdUnoSlideView::getImplementationName( ) |
155 | 0 | { |
156 | 0 | return u"com.sun.star.comp.sd.SdUnoSlideView"_ustr; |
157 | 0 | } |
158 | | |
159 | | sal_Bool SAL_CALL SdUnoSlideView::supportsService( const OUString& ServiceName ) |
160 | 0 | { |
161 | 0 | return cppu::supportsService( this, ServiceName ); |
162 | 0 | } |
163 | | |
164 | | Sequence< OUString > SAL_CALL SdUnoSlideView::getSupportedServiceNames( ) |
165 | 0 | { |
166 | 0 | return { u"com.sun.star.presentation.SlidesView"_ustr }; |
167 | 0 | } |
168 | | |
169 | | } // end of namespace sd |
170 | | |
171 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |