xref: /trunk/main/sd/source/ui/unoidl/SdUnoSlideView.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 {
74     bool bOk = true;
75 
76     slidesorter::controller::SlideSorterController& rSlideSorterController
77         = mrSlideSorter.GetController();
78     slidesorter::controller::PageSelector& rSelector (rSlideSorterController.GetPageSelector());
79     rSelector.DeselectAllPages();
80     Sequence<Reference<drawing::XDrawPage> > xPages;
81     aSelection >>= xPages;
82     const sal_uInt32 nCount = xPages.getLength();
83     for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
84     {
85         Reference<beans::XPropertySet> xSet (xPages[nIndex], UNO_QUERY);
86         if (xSet.is())
87         {
88             try
89             {
90                 Any aNumber = xSet->getPropertyValue(
91                     ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Number")));
92                 sal_Int32 nPageNumber = 0;
93                 aNumber >>= nPageNumber;
94                 nPageNumber -=1; // Transform 1-based page numbers to 0-based ones.
95                 rSelector.SelectPage(nPageNumber);
96             }
97             catch(RuntimeException e)
98             {
99             }
100         }
101     }
102 
103     return bOk;
104 }
105 
106 
107 
108 
getSelection(void)109 Any SAL_CALL SdUnoSlideView::getSelection (void)
110 {
111     Any aResult;
112 
113     slidesorter::model::PageEnumeration aSelectedPages (
114         slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
115             mrSlideSorter.GetModel()));
116     int nSelectedPageCount (
117         mrSlideSorter.GetController().GetPageSelector().GetSelectedPageCount());
118 
119     Sequence<Reference<XInterface> > aPages(nSelectedPageCount);
120     int nIndex = 0;
121     while (aSelectedPages.HasMoreElements() && nIndex<nSelectedPageCount)
122     {
123         slidesorter::model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
124         aPages[nIndex++] = pDescriptor->GetPage()->getUnoPage();
125     }
126     aResult <<= aPages;
127 
128     return aResult;
129 }
130 
131 
132 
133 
addSelectionChangeListener(const css::uno::Reference<css::view::XSelectionChangeListener> & rxListener)134 void SAL_CALL SdUnoSlideView::addSelectionChangeListener (
135     const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
136 {
137     (void)rxListener;
138 }
139 
140 
141 
142 
removeSelectionChangeListener(const css::uno::Reference<css::view::XSelectionChangeListener> & rxListener)143 void SAL_CALL SdUnoSlideView::removeSelectionChangeListener (
144     const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
145 {
146     (void)rxListener;
147 }
148 
149 
150 
151 
152 //----- XDrawView -------------------------------------------------------------
153 
setCurrentPage(const css::uno::Reference<css::drawing::XDrawPage> & rxDrawPage)154 void SAL_CALL SdUnoSlideView::setCurrentPage (
155     const css::uno::Reference<css::drawing::XDrawPage>& rxDrawPage)
156 {
157     Reference<beans::XPropertySet> xProperties (rxDrawPage, UNO_QUERY);
158     if (xProperties.is())
159     {
160         sal_uInt16 nPageNumber(0);
161         if (xProperties->getPropertyValue(::rtl::OUString::createFromAscii("Number")) >>= nPageNumber)
162         {
163             mrSlideSorter.GetController().GetCurrentSlideManager()->SwitchCurrentSlide(
164                 nPageNumber-1,
165                 true);
166         }
167     }
168 }
169 
170 
171 
172 
173 css::uno::Reference<css::drawing::XDrawPage > SAL_CALL
getCurrentPage(void)174     SdUnoSlideView::getCurrentPage (void)
175 {
176     return mrSlideSorter.GetController().GetCurrentSlideManager()->GetCurrentSlide()->GetXDrawPage();
177 }
178 
179 
180 
181 
182 //----- XFastPropertySet ------------------------------------------------------
183 
setFastPropertyValue(sal_Int32 nHandle,const Any & rValue)184 void SdUnoSlideView::setFastPropertyValue (
185     sal_Int32 nHandle,
186         const Any& rValue)
187 {
188     (void)nHandle;
189     (void)rValue;
190 
191     throw beans::UnknownPropertyException();
192 }
193 
194 
195 
196 
getFastPropertyValue(sal_Int32 nHandle)197 Any SAL_CALL SdUnoSlideView::getFastPropertyValue (
198     sal_Int32 nHandle)
199 {
200     (void)nHandle;
201 
202     if( nHandle != DrawController::PROPERTY_VIEWOFFSET )
203         throw beans::UnknownPropertyException();
204 
205     return Any();
206 }
207 
208 
209 // XServiceInfo
getImplementationName()210 OUString SAL_CALL SdUnoSlideView::getImplementationName(  )
211 {
212     return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sd.SdUnoSlideView") );
213 }
214 
supportsService(const OUString & ServiceName)215 sal_Bool SAL_CALL SdUnoSlideView::supportsService( const OUString& ServiceName )
216 {
217     return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
218 }
219 
getSupportedServiceNames()220 Sequence< OUString > SAL_CALL SdUnoSlideView::getSupportedServiceNames(  )
221 {
222     OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SlidesView") );
223     uno::Sequence< OUString > aSeq( &aSN, 1 );
224     return aSeq;
225 }
226 
227 
228 /*
229 void SdUnoSlideView::FillPropertyTable (
230     ::std::vector< ::com::sun::star::beans::Property>& )
231 {
232 }
233 
234 
235 
236 
237 sal_Bool SAL_CALL SdUnoSlideView::convertFastPropertyValue(
238     ::com::sun::star::uno::Any & ,
239     ::com::sun::star::uno::Any & ,
240     sal_Int32 ,
241     const ::com::sun::star::uno::Any&  )
242     throw (::com::sun::star::lang::IllegalArgumentException)
243 {
244     return sal_False;
245 }
246 
247 
248 
249 
250 void SAL_CALL SdUnoSlideView::setFastPropertyValue_NoBroadcast(
251     sal_Int32 ,
252     const ::com::sun::star::uno::Any&  )
253     throw (::com::sun::star::uno::Exception)
254 {
255 }
256 
257 
258 
259 
260 void SAL_CALL SdUnoSlideView::getFastPropertyValue( ::com::sun::star::uno::Any&, sal_Int32  ) const
261 {
262 }
263 
264 */
265 
266 } // end of namespace sd
267