Line data Source code
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/SlideSorterModel.hxx"
31 : #include "model/SlsPageDescriptor.hxx"
32 : #include "sdpage.hxx"
33 : #include <com/sun/star/beans/XPropertySet.hpp>
34 :
35 : using namespace ::com::sun::star;
36 : using namespace ::com::sun::star::uno;
37 :
38 : namespace sd {
39 :
40 0 : SdUnoSlideView::SdUnoSlideView (
41 : slidesorter::SlideSorter& rSlideSorter) throw()
42 : : DrawSubControllerInterfaceBase(m_aMutex),
43 0 : mrSlideSorter(rSlideSorter)
44 : {
45 0 : }
46 :
47 0 : SdUnoSlideView::~SdUnoSlideView (void) throw()
48 : {
49 0 : }
50 :
51 : //----- XSelectionSupplier ----------------------------------------------------
52 :
53 0 : sal_Bool SAL_CALL SdUnoSlideView::select (const Any& aSelection)
54 : throw(lang::IllegalArgumentException, RuntimeException, std::exception)
55 : {
56 0 : bool bOk = true;
57 :
58 : slidesorter::controller::SlideSorterController& rSlideSorterController
59 0 : = mrSlideSorter.GetController();
60 0 : slidesorter::controller::PageSelector& rSelector (rSlideSorterController.GetPageSelector());
61 0 : rSelector.DeselectAllPages();
62 0 : Sequence<Reference<drawing::XDrawPage> > xPages;
63 0 : aSelection >>= xPages;
64 0 : const sal_uInt32 nCount = xPages.getLength();
65 0 : for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
66 : {
67 0 : Reference<beans::XPropertySet> xSet (xPages[nIndex], UNO_QUERY);
68 0 : if (xSet.is())
69 : {
70 : try
71 : {
72 0 : Any aNumber = xSet->getPropertyValue("Number");
73 0 : sal_Int32 nPageNumber = 0;
74 0 : aNumber >>= nPageNumber;
75 0 : nPageNumber -=1; // Transform 1-based page numbers to 0-based ones.
76 0 : rSelector.SelectPage(nPageNumber);
77 : }
78 0 : catch (const RuntimeException&)
79 : {
80 : }
81 : }
82 0 : }
83 :
84 0 : return bOk;
85 : }
86 :
87 0 : Any SAL_CALL SdUnoSlideView::getSelection (void)
88 : throw(RuntimeException, std::exception)
89 : {
90 0 : Any aResult;
91 :
92 : slidesorter::model::PageEnumeration aSelectedPages (
93 : slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
94 0 : mrSlideSorter.GetModel()));
95 : int nSelectedPageCount (
96 0 : mrSlideSorter.GetController().GetPageSelector().GetSelectedPageCount());
97 :
98 0 : Sequence<Reference<XInterface> > aPages(nSelectedPageCount);
99 0 : int nIndex = 0;
100 0 : while (aSelectedPages.HasMoreElements() && nIndex<nSelectedPageCount)
101 : {
102 0 : slidesorter::model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
103 0 : aPages[nIndex++] = pDescriptor->GetPage()->getUnoPage();
104 0 : }
105 0 : aResult <<= aPages;
106 :
107 0 : return aResult;
108 : }
109 :
110 0 : void SAL_CALL SdUnoSlideView::addSelectionChangeListener (
111 : const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
112 : throw(css::uno::RuntimeException, std::exception)
113 : {
114 : (void)rxListener;
115 0 : }
116 :
117 0 : void SAL_CALL SdUnoSlideView::removeSelectionChangeListener (
118 : const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
119 : throw(css::uno::RuntimeException, std::exception)
120 : {
121 : (void)rxListener;
122 0 : }
123 :
124 : //----- XDrawView -------------------------------------------------------------
125 :
126 0 : void SAL_CALL SdUnoSlideView::setCurrentPage (
127 : const css::uno::Reference<css::drawing::XDrawPage>& rxDrawPage)
128 : throw(css::uno::RuntimeException, std::exception)
129 : {
130 0 : Reference<beans::XPropertySet> xProperties (rxDrawPage, UNO_QUERY);
131 0 : if (xProperties.is())
132 : {
133 0 : sal_uInt16 nPageNumber(0);
134 0 : if (xProperties->getPropertyValue("Number") >>= nPageNumber)
135 : {
136 0 : mrSlideSorter.GetController().GetCurrentSlideManager()->SwitchCurrentSlide(
137 : nPageNumber-1,
138 0 : true);
139 : }
140 0 : }
141 0 : }
142 :
143 : css::uno::Reference<css::drawing::XDrawPage > SAL_CALL
144 0 : SdUnoSlideView::getCurrentPage (void)
145 : throw(css::uno::RuntimeException, std::exception)
146 : {
147 0 : return mrSlideSorter.GetController().GetCurrentSlideManager()->GetCurrentSlide()->GetXDrawPage();
148 : }
149 :
150 : //----- XFastPropertySet ------------------------------------------------------
151 :
152 0 : void SdUnoSlideView::setFastPropertyValue (
153 : sal_Int32 nHandle,
154 : const Any& rValue)
155 : throw(css::beans::UnknownPropertyException,
156 : css::beans::PropertyVetoException,
157 : css::lang::IllegalArgumentException,
158 : css::lang::WrappedTargetException,
159 : css::uno::RuntimeException, std::exception)
160 : {
161 : (void)nHandle;
162 : (void)rValue;
163 :
164 0 : throw beans::UnknownPropertyException();
165 : }
166 :
167 0 : Any SAL_CALL SdUnoSlideView::getFastPropertyValue (
168 : sal_Int32 nHandle)
169 : throw(css::beans::UnknownPropertyException,
170 : css::lang::WrappedTargetException,
171 : css::uno::RuntimeException, std::exception)
172 : {
173 : (void)nHandle;
174 :
175 0 : if( nHandle != DrawController::PROPERTY_VIEWOFFSET )
176 0 : throw beans::UnknownPropertyException();
177 :
178 0 : return Any();
179 : }
180 :
181 : // XServiceInfo
182 0 : OUString SAL_CALL SdUnoSlideView::getImplementationName( ) throw (RuntimeException, std::exception)
183 : {
184 0 : return OUString( "com.sun.star.comp.sd.SdUnoSlideView" );
185 : }
186 :
187 0 : sal_Bool SAL_CALL SdUnoSlideView::supportsService( const OUString& ServiceName ) throw (RuntimeException, std::exception)
188 : {
189 0 : return cppu::supportsService( this, ServiceName );
190 : }
191 :
192 0 : Sequence< OUString > SAL_CALL SdUnoSlideView::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
193 : {
194 0 : OUString aSN( "com.sun.star.presentation.SlidesView" );
195 0 : uno::Sequence< OUString > aSeq( &aSN, 1 );
196 0 : return aSeq;
197 : }
198 :
199 114 : } // end of namespace sd
200 :
201 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|