xref: /AOO41X/main/sd/source/ui/unoidl/SdUnoSlideView.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "precompiled_sd.hxx"
29 
30 #include <comphelper/serviceinfohelper.hxx>
31 
32 #include "DrawController.hxx"
33 #include "SdUnoSlideView.hxx"
34 
35 #include "SlideSorter.hxx"
36 #include "controller/SlideSorterController.hxx"
37 #include "controller/SlsPageSelector.hxx"
38 #include "controller/SlsCurrentSlideManager.hxx"
39 #include "model/SlsPageEnumerationProvider.hxx"
40 #include "model/SlideSorterModel.hxx"
41 #include "model/SlsPageDescriptor.hxx"
42 #include "sdpage.hxx"
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 
45 using ::rtl::OUString;
46 
47 using namespace ::com::sun::star;
48 using namespace ::com::sun::star::uno;
49 
50 namespace sd {
51 
52 
53 SdUnoSlideView::SdUnoSlideView (
54     DrawController& rController,
55     slidesorter::SlideSorter& rSlideSorter,
56     View& rView) throw()
57     : DrawSubControllerInterfaceBase(m_aMutex),
58       mrController(rController),
59       mrSlideSorter(rSlideSorter),
60       mrView(rView)
61 {
62 }
63 
64 
65 
66 
67 SdUnoSlideView::~SdUnoSlideView (void) throw()
68 {
69 }
70 
71 
72 
73 
74 //----- XSelectionSupplier ----------------------------------------------------
75 
76 sal_Bool SAL_CALL SdUnoSlideView::select (const Any& aSelection)
77       throw(lang::IllegalArgumentException, RuntimeException)
78 {
79     bool bOk = true;
80 
81     slidesorter::controller::SlideSorterController& rSlideSorterController
82         = mrSlideSorter.GetController();
83     slidesorter::controller::PageSelector& rSelector (rSlideSorterController.GetPageSelector());
84     rSelector.DeselectAllPages();
85     Sequence<Reference<drawing::XDrawPage> > xPages;
86     aSelection >>= xPages;
87     const sal_uInt32 nCount = xPages.getLength();
88     for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
89     {
90         Reference<beans::XPropertySet> xSet (xPages[nIndex], UNO_QUERY);
91         if (xSet.is())
92         {
93             try
94             {
95                 Any aNumber = xSet->getPropertyValue(
96                     ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Number")));
97                 sal_Int32 nPageNumber = 0;
98                 aNumber >>= nPageNumber;
99                 nPageNumber -=1; // Transform 1-based page numbers to 0-based ones.
100                 rSelector.SelectPage(nPageNumber);
101             }
102             catch(RuntimeException e)
103             {
104             }
105         }
106     }
107 
108     return bOk;
109 }
110 
111 
112 
113 
114 Any SAL_CALL SdUnoSlideView::getSelection (void)
115       throw(RuntimeException)
116 {
117     Any aResult;
118 
119     slidesorter::model::PageEnumeration aSelectedPages (
120         slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
121             mrSlideSorter.GetModel()));
122     int nSelectedPageCount (
123         mrSlideSorter.GetController().GetPageSelector().GetSelectedPageCount());
124 
125     Sequence<Reference<XInterface> > aPages(nSelectedPageCount);
126     int nIndex = 0;
127     while (aSelectedPages.HasMoreElements() && nIndex<nSelectedPageCount)
128     {
129         slidesorter::model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
130         aPages[nIndex++] = pDescriptor->GetPage()->getUnoPage();
131     }
132     aResult <<= aPages;
133 
134     return aResult;
135 }
136 
137 
138 
139 
140 void SAL_CALL SdUnoSlideView::addSelectionChangeListener (
141     const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
142     throw(css::uno::RuntimeException)
143 {
144     (void)rxListener;
145 }
146 
147 
148 
149 
150 void SAL_CALL SdUnoSlideView::removeSelectionChangeListener (
151     const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
152     throw(css::uno::RuntimeException)
153 {
154     (void)rxListener;
155 }
156 
157 
158 
159 
160 //----- XDrawView -------------------------------------------------------------
161 
162 void SAL_CALL SdUnoSlideView::setCurrentPage (
163     const css::uno::Reference<css::drawing::XDrawPage>& rxDrawPage)
164     throw(css::uno::RuntimeException)
165 {
166     Reference<beans::XPropertySet> xProperties (rxDrawPage, UNO_QUERY);
167     if (xProperties.is())
168     {
169         sal_uInt16 nPageNumber(0);
170         if (xProperties->getPropertyValue(::rtl::OUString::createFromAscii("Number")) >>= nPageNumber)
171         {
172             mrSlideSorter.GetController().GetCurrentSlideManager()->SwitchCurrentSlide(
173                 nPageNumber-1,
174                 true);
175         }
176     }
177 }
178 
179 
180 
181 
182 css::uno::Reference<css::drawing::XDrawPage > SAL_CALL
183     SdUnoSlideView::getCurrentPage (void)
184     throw(css::uno::RuntimeException)
185 {
186     return mrSlideSorter.GetController().GetCurrentSlideManager()->GetCurrentSlide()->GetXDrawPage();
187 }
188 
189 
190 
191 
192 //----- XFastPropertySet ------------------------------------------------------
193 
194 void SdUnoSlideView::setFastPropertyValue (
195 	sal_Int32 nHandle,
196         const Any& rValue)
197     throw(css::beans::UnknownPropertyException,
198         css::beans::PropertyVetoException,
199         css::lang::IllegalArgumentException,
200         css::lang::WrappedTargetException,
201         css::uno::RuntimeException)
202 {
203     (void)nHandle;
204     (void)rValue;
205 
206 	throw beans::UnknownPropertyException();
207 }
208 
209 
210 
211 
212 Any SAL_CALL SdUnoSlideView::getFastPropertyValue (
213     sal_Int32 nHandle)
214     throw(css::beans::UnknownPropertyException,
215         css::lang::WrappedTargetException,
216         css::uno::RuntimeException)
217 {
218     (void)nHandle;
219 
220 	if( nHandle != DrawController::PROPERTY_VIEWOFFSET )
221 		throw beans::UnknownPropertyException();
222 
223 	return Any();
224 }
225 
226 
227 // XServiceInfo
228 OUString SAL_CALL SdUnoSlideView::getImplementationName(  ) throw (RuntimeException)
229 {
230 	return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sd.SdUnoSlideView") );
231 }
232 
233 sal_Bool SAL_CALL SdUnoSlideView::supportsService( const OUString& ServiceName ) throw (RuntimeException)
234 {
235 	return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
236 }
237 
238 Sequence< OUString > SAL_CALL SdUnoSlideView::getSupportedServiceNames(  ) throw (RuntimeException)
239 {
240 	OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SlidesView") );
241 	uno::Sequence< OUString > aSeq( &aSN, 1 );
242 	return aSeq;
243 }
244 
245 
246 /*
247 void SdUnoSlideView::FillPropertyTable (
248     ::std::vector< ::com::sun::star::beans::Property>& )
249 {
250 }
251 
252 
253 
254 
255 sal_Bool SAL_CALL SdUnoSlideView::convertFastPropertyValue(
256     ::com::sun::star::uno::Any & ,
257     ::com::sun::star::uno::Any & ,
258     sal_Int32 ,
259     const ::com::sun::star::uno::Any&  )
260     throw (::com::sun::star::lang::IllegalArgumentException)
261 {
262     return sal_False;
263 }
264 
265 
266 
267 
268 void SAL_CALL SdUnoSlideView::setFastPropertyValue_NoBroadcast(
269     sal_Int32 ,
270     const ::com::sun::star::uno::Any&  )
271     throw (::com::sun::star::uno::Exception)
272 {
273 }
274 
275 
276 
277 
278 void SAL_CALL SdUnoSlideView::getFastPropertyValue( ::com::sun::star::uno::Any&, sal_Int32  ) const
279 {
280 }
281 
282 */
283 
284 } // end of namespace sd
285