1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #include "precompiled_sd.hxx"
25
26 #include <comphelper/serviceinfohelper.hxx>
27
28 #include "DrawController.hxx"
29 #include "SdUnoSlideView.hxx"
30
31 #include "SlideSorter.hxx"
32 #include "controller/SlideSorterController.hxx"
33 #include "controller/SlsPageSelector.hxx"
34 #include "controller/SlsCurrentSlideManager.hxx"
35 #include "model/SlsPageEnumerationProvider.hxx"
36 #include "model/SlideSorterModel.hxx"
37 #include "model/SlsPageDescriptor.hxx"
38 #include "sdpage.hxx"
39 #include <com/sun/star/beans/XPropertySet.hpp>
40
41 using ::rtl::OUString;
42
43 using namespace ::com::sun::star;
44 using namespace ::com::sun::star::uno;
45
46 namespace sd {
47
48
SdUnoSlideView(DrawController & rController,slidesorter::SlideSorter & rSlideSorter,View & rView)49 SdUnoSlideView::SdUnoSlideView (
50 DrawController& rController,
51 slidesorter::SlideSorter& rSlideSorter,
52 View& rView) throw()
53 : DrawSubControllerInterfaceBase(m_aMutex),
54 mrController(rController),
55 mrSlideSorter(rSlideSorter),
56 mrView(rView)
57 {
58 }
59
60
61
62
~SdUnoSlideView(void)63 SdUnoSlideView::~SdUnoSlideView (void) throw()
64 {
65 }
66
67
68
69
70 //----- XSelectionSupplier ----------------------------------------------------
71
select(const Any & aSelection)72 sal_Bool SAL_CALL SdUnoSlideView::select (const Any& aSelection)
73 throw(lang::IllegalArgumentException, RuntimeException)
74 {
75 bool bOk = true;
76
77 slidesorter::controller::SlideSorterController& rSlideSorterController
78 = mrSlideSorter.GetController();
79 slidesorter::controller::PageSelector& rSelector (rSlideSorterController.GetPageSelector());
80 rSelector.DeselectAllPages();
81 Sequence<Reference<drawing::XDrawPage> > xPages;
82 aSelection >>= xPages;
83 const sal_uInt32 nCount = xPages.getLength();
84 for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
85 {
86 Reference<beans::XPropertySet> xSet (xPages[nIndex], UNO_QUERY);
87 if (xSet.is())
88 {
89 try
90 {
91 Any aNumber = xSet->getPropertyValue(
92 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Number")));
93 sal_Int32 nPageNumber = 0;
94 aNumber >>= nPageNumber;
95 nPageNumber -=1; // Transform 1-based page numbers to 0-based ones.
96 rSelector.SelectPage(nPageNumber);
97 }
98 catch(RuntimeException e)
99 {
100 }
101 }
102 }
103
104 return bOk;
105 }
106
107
108
109
getSelection(void)110 Any SAL_CALL SdUnoSlideView::getSelection (void)
111 throw(RuntimeException)
112 {
113 Any aResult;
114
115 slidesorter::model::PageEnumeration aSelectedPages (
116 slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
117 mrSlideSorter.GetModel()));
118 int nSelectedPageCount (
119 mrSlideSorter.GetController().GetPageSelector().GetSelectedPageCount());
120
121 Sequence<Reference<XInterface> > aPages(nSelectedPageCount);
122 int nIndex = 0;
123 while (aSelectedPages.HasMoreElements() && nIndex<nSelectedPageCount)
124 {
125 slidesorter::model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
126 aPages[nIndex++] = pDescriptor->GetPage()->getUnoPage();
127 }
128 aResult <<= aPages;
129
130 return aResult;
131 }
132
133
134
135
addSelectionChangeListener(const css::uno::Reference<css::view::XSelectionChangeListener> & rxListener)136 void SAL_CALL SdUnoSlideView::addSelectionChangeListener (
137 const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
138 throw(css::uno::RuntimeException)
139 {
140 (void)rxListener;
141 }
142
143
144
145
removeSelectionChangeListener(const css::uno::Reference<css::view::XSelectionChangeListener> & rxListener)146 void SAL_CALL SdUnoSlideView::removeSelectionChangeListener (
147 const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
148 throw(css::uno::RuntimeException)
149 {
150 (void)rxListener;
151 }
152
153
154
155
156 //----- XDrawView -------------------------------------------------------------
157
setCurrentPage(const css::uno::Reference<css::drawing::XDrawPage> & rxDrawPage)158 void SAL_CALL SdUnoSlideView::setCurrentPage (
159 const css::uno::Reference<css::drawing::XDrawPage>& rxDrawPage)
160 throw(css::uno::RuntimeException)
161 {
162 Reference<beans::XPropertySet> xProperties (rxDrawPage, UNO_QUERY);
163 if (xProperties.is())
164 {
165 sal_uInt16 nPageNumber(0);
166 if (xProperties->getPropertyValue(::rtl::OUString::createFromAscii("Number")) >>= nPageNumber)
167 {
168 mrSlideSorter.GetController().GetCurrentSlideManager()->SwitchCurrentSlide(
169 nPageNumber-1,
170 true);
171 }
172 }
173 }
174
175
176
177
178 css::uno::Reference<css::drawing::XDrawPage > SAL_CALL
getCurrentPage(void)179 SdUnoSlideView::getCurrentPage (void)
180 throw(css::uno::RuntimeException)
181 {
182 return mrSlideSorter.GetController().GetCurrentSlideManager()->GetCurrentSlide()->GetXDrawPage();
183 }
184
185
186
187
188 //----- XFastPropertySet ------------------------------------------------------
189
setFastPropertyValue(sal_Int32 nHandle,const Any & rValue)190 void SdUnoSlideView::setFastPropertyValue (
191 sal_Int32 nHandle,
192 const Any& rValue)
193 throw(css::beans::UnknownPropertyException,
194 css::beans::PropertyVetoException,
195 css::lang::IllegalArgumentException,
196 css::lang::WrappedTargetException,
197 css::uno::RuntimeException)
198 {
199 (void)nHandle;
200 (void)rValue;
201
202 throw beans::UnknownPropertyException();
203 }
204
205
206
207
getFastPropertyValue(sal_Int32 nHandle)208 Any SAL_CALL SdUnoSlideView::getFastPropertyValue (
209 sal_Int32 nHandle)
210 throw(css::beans::UnknownPropertyException,
211 css::lang::WrappedTargetException,
212 css::uno::RuntimeException)
213 {
214 (void)nHandle;
215
216 if( nHandle != DrawController::PROPERTY_VIEWOFFSET )
217 throw beans::UnknownPropertyException();
218
219 return Any();
220 }
221
222
223 // XServiceInfo
getImplementationName()224 OUString SAL_CALL SdUnoSlideView::getImplementationName( ) throw (RuntimeException)
225 {
226 return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sd.SdUnoSlideView") );
227 }
228
supportsService(const OUString & ServiceName)229 sal_Bool SAL_CALL SdUnoSlideView::supportsService( const OUString& ServiceName ) throw (RuntimeException)
230 {
231 return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
232 }
233
getSupportedServiceNames()234 Sequence< OUString > SAL_CALL SdUnoSlideView::getSupportedServiceNames( ) throw (RuntimeException)
235 {
236 OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SlidesView") );
237 uno::Sequence< OUString > aSeq( &aSN, 1 );
238 return aSeq;
239 }
240
241
242 /*
243 void SdUnoSlideView::FillPropertyTable (
244 ::std::vector< ::com::sun::star::beans::Property>& )
245 {
246 }
247
248
249
250
251 sal_Bool SAL_CALL SdUnoSlideView::convertFastPropertyValue(
252 ::com::sun::star::uno::Any & ,
253 ::com::sun::star::uno::Any & ,
254 sal_Int32 ,
255 const ::com::sun::star::uno::Any& )
256 throw (::com::sun::star::lang::IllegalArgumentException)
257 {
258 return sal_False;
259 }
260
261
262
263
264 void SAL_CALL SdUnoSlideView::setFastPropertyValue_NoBroadcast(
265 sal_Int32 ,
266 const ::com::sun::star::uno::Any& )
267 throw (::com::sun::star::uno::Exception)
268 {
269 }
270
271
272
273
274 void SAL_CALL SdUnoSlideView::getFastPropertyValue( ::com::sun::star::uno::Any&, sal_Int32 ) const
275 {
276 }
277
278 */
279
280 } // end of namespace sd
281