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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include <comphelper/serviceinfohelper.hxx>
28 
29 #include "SdUnoOutlineView.hxx"
30 
31 #include "DrawController.hxx"
32 #include "OutlineViewShell.hxx"
33 #include "sdpage.hxx"
34 #include "unopage.hxx"
35 
36 #include <cppuhelper/proptypehlp.hxx>
37 #include <svx/unopage.hxx>
38 #include <vos/mutex.hxx>
39 #include <vcl/svapp.hxx>
40 
41 using ::rtl::OUString;
42 using namespace ::vos;
43 using namespace ::cppu;
44 using namespace ::com::sun::star;
45 using namespace ::com::sun::star::uno;
46 
47 
48 
49 namespace sd {
50 
SdUnoOutlineView(DrawController & rController,OutlineViewShell & rViewShell,View & rView)51 SdUnoOutlineView::SdUnoOutlineView(
52     DrawController& rController,
53     OutlineViewShell& rViewShell,
54     View& rView) throw()
55     :	DrawSubControllerInterfaceBase(m_aMutex),
56         mrController(rController),
57         mrOutlineViewShell(rViewShell),
58         mrView(rView)
59 {
60 }
61 
62 
63 
64 
~SdUnoOutlineView(void)65 SdUnoOutlineView::~SdUnoOutlineView (void) throw()
66 {
67 }
68 
69 
70 
71 
disposing(void)72 void SAL_CALL SdUnoOutlineView::disposing (void)
73 {
74 }
75 
76 
77 
78 
79 //----- XSelectionSupplier ----------------------------------------------------
80 
select(const Any &)81 sal_Bool SAL_CALL SdUnoOutlineView::select( const Any&  )
82 	throw(lang::IllegalArgumentException, RuntimeException)
83 {
84 	// todo: add selections for text ranges
85 	return sal_False;
86 }
87 
88 
89 
getSelection()90 Any SAL_CALL SdUnoOutlineView::getSelection()
91 	throw(RuntimeException)
92 {
93 	Any aAny;
94 	return aAny;
95 }
96 
97 
98 
addSelectionChangeListener(const css::uno::Reference<css::view::XSelectionChangeListener> & rxListener)99 void SAL_CALL SdUnoOutlineView::addSelectionChangeListener (
100     const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
101     throw(css::uno::RuntimeException)
102 {
103     (void)rxListener;
104 }
105 
106 
107 
108 
removeSelectionChangeListener(const css::uno::Reference<css::view::XSelectionChangeListener> & rxListener)109 void SAL_CALL SdUnoOutlineView::removeSelectionChangeListener (
110     const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
111     throw(css::uno::RuntimeException)
112 {
113     (void)rxListener;
114 }
115 
116 
117 
118 
119 //----- XDrawView -------------------------------------------------------------
120 
121 
setCurrentPage(const Reference<drawing::XDrawPage> & xPage)122 void SAL_CALL SdUnoOutlineView::setCurrentPage (
123     const Reference< drawing::XDrawPage >& xPage)
124 	throw(RuntimeException)
125 {
126     SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation( xPage );
127     SdrPage *pSdrPage = pDrawPage ? pDrawPage->GetSdrPage() : NULL;
128 
129     if (pSdrPage != NULL)
130         mrOutlineViewShell.SetCurrentPage(dynamic_cast<SdPage*>(pSdrPage));
131 }
132 
133 
134 
135 
getCurrentPage(void)136 Reference< drawing::XDrawPage > SAL_CALL SdUnoOutlineView::getCurrentPage (void)
137 	throw(RuntimeException)
138 {
139 	Reference<drawing::XDrawPage>  xPage;
140 
141     SdPage* pPage = mrOutlineViewShell.getCurrentPage();
142     if (pPage != NULL)
143         xPage = Reference<drawing::XDrawPage>::query(pPage->getUnoPage());
144 
145 	return xPage;
146 }
147 
148 
149 
150 /*
151 // Return sal_True, value change
152 sal_Bool SdUnoOutlineView::convertFastPropertyValue (
153 	Any & rConvertedValue,
154 	Any & rOldValue,
155 	sal_Int32 nHandle,
156 	const Any& rValue)
157     throw ( com::sun::star::lang::IllegalArgumentException)
158 {
159     sal_Bool bResult = sal_False;
160 
161 	switch( nHandle )
162 	{
163 		case DrawController::PROPERTY_CURRENTPAGE:
164 			{
165 				Reference< drawing::XDrawPage > xOldPage( getCurrentPage() );
166 				Reference< drawing::XDrawPage > xNewPage;
167 				::cppu::convertPropertyValue( xNewPage, rValue );
168 				if( xOldPage != xNewPage )
169 				{
170 					rConvertedValue <<= xNewPage;
171 					rOldValue <<= xOldPage;
172 					bResult = sal_True;
173 				}
174 			}
175             break;
176 
177 		default:
178             break;
179 	}
180 
181     return bResult;
182 }
183 */
184 
185 
setFastPropertyValue(sal_Int32 nHandle,const Any & rValue)186 void SdUnoOutlineView::setFastPropertyValue (
187 	sal_Int32 nHandle,
188         const Any& rValue)
189     throw(css::beans::UnknownPropertyException,
190         css::beans::PropertyVetoException,
191         css::lang::IllegalArgumentException,
192         css::lang::WrappedTargetException,
193         css::uno::RuntimeException)
194 {
195 	switch( nHandle )
196 	{
197         case DrawController::PROPERTY_CURRENTPAGE:
198         {
199             Reference< drawing::XDrawPage > xPage;
200             rValue >>= xPage;
201             setCurrentPage( xPage );
202         }
203         break;
204 
205         default:
206             throw beans::UnknownPropertyException();
207 	}
208 }
209 
210 
211 
212 
disposing(const::com::sun::star::lang::EventObject &)213 void SAL_CALL SdUnoOutlineView::disposing (const ::com::sun::star::lang::EventObject& )
214     throw (::com::sun::star::uno::RuntimeException)
215 {
216 }
217 
218 
219 
220 
getFastPropertyValue(sal_Int32 nHandle)221 Any SAL_CALL SdUnoOutlineView::getFastPropertyValue (
222     sal_Int32 nHandle)
223     throw(css::beans::UnknownPropertyException,
224         css::lang::WrappedTargetException,
225         css::uno::RuntimeException)
226 {
227     Any aValue;
228 
229     switch( nHandle )
230     {
231         case DrawController::PROPERTY_CURRENTPAGE:
232         {
233             SdPage* pPage = const_cast<OutlineViewShell&>(mrOutlineViewShell).GetActualPage();
234             if (pPage != NULL)
235                 aValue <<= pPage->getUnoPage();
236         }
237         break;
238 		case DrawController::PROPERTY_VIEWOFFSET:
239 			break;
240 
241         default:
242             throw beans::UnknownPropertyException();
243     }
244 
245     return aValue;
246 }
247 
248 
249 // XServiceInfo
getImplementationName()250 OUString SAL_CALL SdUnoOutlineView::getImplementationName(  ) throw (RuntimeException)
251 {
252 	return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sd.SdUnoOutlineView") );
253 }
254 
supportsService(const OUString & ServiceName)255 sal_Bool SAL_CALL SdUnoOutlineView::supportsService( const OUString& ServiceName ) throw (RuntimeException)
256 {
257 	return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
258 }
259 
getSupportedServiceNames()260 Sequence< OUString > SAL_CALL SdUnoOutlineView::getSupportedServiceNames(  ) throw (RuntimeException)
261 {
262 	OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlineView") );
263 	uno::Sequence< OUString > aSeq( &aSN, 1 );
264 	return aSeq;
265 }
266 
267 } // end of namespace sd
268