xref: /trunk/main/sd/source/ui/unoidl/SdUnoOutlineView.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 // 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 {
83     // todo: add selections for text ranges
84     return sal_False;
85 }
86 
87 
88 
getSelection()89 Any SAL_CALL SdUnoOutlineView::getSelection()
90 {
91     Any aAny;
92     return aAny;
93 }
94 
95 
96 
addSelectionChangeListener(const css::uno::Reference<css::view::XSelectionChangeListener> & rxListener)97 void SAL_CALL SdUnoOutlineView::addSelectionChangeListener (
98     const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
99 {
100     (void)rxListener;
101 }
102 
103 
104 
105 
removeSelectionChangeListener(const css::uno::Reference<css::view::XSelectionChangeListener> & rxListener)106 void SAL_CALL SdUnoOutlineView::removeSelectionChangeListener (
107     const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
108 {
109     (void)rxListener;
110 }
111 
112 
113 
114 
115 //----- XDrawView -------------------------------------------------------------
116 
117 
setCurrentPage(const Reference<drawing::XDrawPage> & xPage)118 void SAL_CALL SdUnoOutlineView::setCurrentPage (
119     const Reference< drawing::XDrawPage >& xPage)
120 {
121     SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation( xPage );
122     SdrPage *pSdrPage = pDrawPage ? pDrawPage->GetSdrPage() : NULL;
123 
124     if (pSdrPage != NULL)
125         mrOutlineViewShell.SetCurrentPage(dynamic_cast<SdPage*>(pSdrPage));
126 }
127 
128 
129 
130 
getCurrentPage(void)131 Reference< drawing::XDrawPage > SAL_CALL SdUnoOutlineView::getCurrentPage (void)
132 {
133     Reference<drawing::XDrawPage>  xPage;
134 
135     SdPage* pPage = mrOutlineViewShell.getCurrentPage();
136     if (pPage != NULL)
137         xPage = Reference<drawing::XDrawPage>::query(pPage->getUnoPage());
138 
139     return xPage;
140 }
141 
142 
143 
144 /*
145 // Return sal_True, value change
146 sal_Bool SdUnoOutlineView::convertFastPropertyValue (
147     Any & rConvertedValue,
148     Any & rOldValue,
149     sal_Int32 nHandle,
150     const Any& rValue)
151     throw ( com::sun::star::lang::IllegalArgumentException)
152 {
153     sal_Bool bResult = sal_False;
154 
155     switch( nHandle )
156     {
157         case DrawController::PROPERTY_CURRENTPAGE:
158             {
159                 Reference< drawing::XDrawPage > xOldPage( getCurrentPage() );
160                 Reference< drawing::XDrawPage > xNewPage;
161                 ::cppu::convertPropertyValue( xNewPage, rValue );
162                 if( xOldPage != xNewPage )
163                 {
164                     rConvertedValue <<= xNewPage;
165                     rOldValue <<= xOldPage;
166                     bResult = sal_True;
167                 }
168             }
169             break;
170 
171         default:
172             break;
173     }
174 
175     return bResult;
176 }
177 */
178 
179 
setFastPropertyValue(sal_Int32 nHandle,const Any & rValue)180 void SdUnoOutlineView::setFastPropertyValue (
181     sal_Int32 nHandle,
182         const Any& rValue)
183 {
184     switch( nHandle )
185     {
186         case DrawController::PROPERTY_CURRENTPAGE:
187         {
188             Reference< drawing::XDrawPage > xPage;
189             rValue >>= xPage;
190             setCurrentPage( xPage );
191         }
192         break;
193 
194         default:
195             throw beans::UnknownPropertyException();
196     }
197 }
198 
199 
200 
201 
disposing(const::com::sun::star::lang::EventObject &)202 void SAL_CALL SdUnoOutlineView::disposing (const ::com::sun::star::lang::EventObject& )
203 {
204 }
205 
206 
207 
208 
getFastPropertyValue(sal_Int32 nHandle)209 Any SAL_CALL SdUnoOutlineView::getFastPropertyValue (
210     sal_Int32 nHandle)
211 {
212     Any aValue;
213 
214     switch( nHandle )
215     {
216         case DrawController::PROPERTY_CURRENTPAGE:
217         {
218             SdPage* pPage = const_cast<OutlineViewShell&>(mrOutlineViewShell).GetActualPage();
219             if (pPage != NULL)
220                 aValue <<= pPage->getUnoPage();
221         }
222         break;
223         case DrawController::PROPERTY_VIEWOFFSET:
224             break;
225 
226         default:
227             throw beans::UnknownPropertyException();
228     }
229 
230     return aValue;
231 }
232 
233 
234 // XServiceInfo
getImplementationName()235 OUString SAL_CALL SdUnoOutlineView::getImplementationName(  )
236 {
237     return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sd.SdUnoOutlineView") );
238 }
239 
supportsService(const OUString & ServiceName)240 sal_Bool SAL_CALL SdUnoOutlineView::supportsService( const OUString& ServiceName )
241 {
242     return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
243 }
244 
getSupportedServiceNames()245 Sequence< OUString > SAL_CALL SdUnoOutlineView::getSupportedServiceNames(  )
246 {
247     OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlineView") );
248     uno::Sequence< OUString > aSeq( &aSN, 1 );
249     return aSeq;
250 }
251 
252 } // end of namespace sd
253