merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / unoidl / SdUnoOutlineView.cxx
blob9a102892b4ebe1299be3faffb586c5848de38d38
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SdUnoOutlineView.cxx,v $
10 * $Revision: 1.21 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "SdUnoOutlineView.hxx"
36 #include "DrawController.hxx"
37 #include "OutlineViewShell.hxx"
38 #include "sdpage.hxx"
39 #include "unopage.hxx"
41 #include <cppuhelper/proptypehlp.hxx>
42 #include <svx/unopage.hxx>
43 #include <vos/mutex.hxx>
44 #include <vcl/svapp.hxx>
46 using ::rtl::OUString;
47 using namespace ::vos;
48 using namespace ::cppu;
49 using namespace ::com::sun::star;
50 using namespace ::com::sun::star::uno;
54 namespace sd {
56 SdUnoOutlineView::SdUnoOutlineView(
57 DrawController& rController,
58 OutlineViewShell& rViewShell,
59 View& rView) throw()
60 : DrawSubControllerInterfaceBase(m_aMutex),
61 mrController(rController),
62 mrOutlineViewShell(rViewShell),
63 mrView(rView)
70 SdUnoOutlineView::~SdUnoOutlineView (void) throw()
77 void SAL_CALL SdUnoOutlineView::disposing (void)
84 //----- XSelectionSupplier ----------------------------------------------------
86 sal_Bool SAL_CALL SdUnoOutlineView::select( const Any& )
87 throw(lang::IllegalArgumentException, RuntimeException)
89 // todo: add selections for text ranges
90 return sal_False;
95 Any SAL_CALL SdUnoOutlineView::getSelection()
96 throw(RuntimeException)
98 Any aAny;
99 return aAny;
104 void SAL_CALL SdUnoOutlineView::addSelectionChangeListener (
105 const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
106 throw(css::uno::RuntimeException)
108 (void)rxListener;
114 void SAL_CALL SdUnoOutlineView::removeSelectionChangeListener (
115 const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
116 throw(css::uno::RuntimeException)
118 (void)rxListener;
124 //----- XDrawView -------------------------------------------------------------
127 void SAL_CALL SdUnoOutlineView::setCurrentPage (
128 const Reference< drawing::XDrawPage >& xPage)
129 throw(RuntimeException)
131 SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation( xPage );
132 SdrPage *pSdrPage = pDrawPage ? pDrawPage->GetSdrPage() : NULL;
134 if (pSdrPage != NULL)
135 mrOutlineViewShell.SetCurrentPage(dynamic_cast<SdPage*>(pSdrPage));
141 Reference< drawing::XDrawPage > SAL_CALL SdUnoOutlineView::getCurrentPage (void)
142 throw(RuntimeException)
144 Reference<drawing::XDrawPage> xPage;
146 SdPage* pPage = mrOutlineViewShell.getCurrentPage();
147 if (pPage != NULL)
148 xPage = Reference<drawing::XDrawPage>::query(pPage->getUnoPage());
150 return xPage;
156 // Return sal_True, value change
157 sal_Bool SdUnoOutlineView::convertFastPropertyValue (
158 Any & rConvertedValue,
159 Any & rOldValue,
160 sal_Int32 nHandle,
161 const Any& rValue)
162 throw ( com::sun::star::lang::IllegalArgumentException)
164 sal_Bool bResult = sal_False;
166 switch( nHandle )
168 case DrawController::PROPERTY_CURRENTPAGE:
170 Reference< drawing::XDrawPage > xOldPage( getCurrentPage() );
171 Reference< drawing::XDrawPage > xNewPage;
172 ::cppu::convertPropertyValue( xNewPage, rValue );
173 if( xOldPage != xNewPage )
175 rConvertedValue <<= xNewPage;
176 rOldValue <<= xOldPage;
177 bResult = sal_True;
180 break;
182 default:
183 break;
186 return bResult;
191 void SdUnoOutlineView::setFastPropertyValue (
192 sal_Int32 nHandle,
193 const Any& rValue)
194 throw(css::beans::UnknownPropertyException,
195 css::beans::PropertyVetoException,
196 css::lang::IllegalArgumentException,
197 css::lang::WrappedTargetException,
198 css::uno::RuntimeException)
200 switch( nHandle )
202 case DrawController::PROPERTY_CURRENTPAGE:
204 Reference< drawing::XDrawPage > xPage;
205 rValue >>= xPage;
206 setCurrentPage( xPage );
208 break;
210 default:
211 throw beans::UnknownPropertyException();
218 void SAL_CALL SdUnoOutlineView::disposing (const ::com::sun::star::lang::EventObject& )
219 throw (::com::sun::star::uno::RuntimeException)
226 Any SAL_CALL SdUnoOutlineView::getFastPropertyValue (
227 sal_Int32 nHandle)
228 throw(css::beans::UnknownPropertyException,
229 css::lang::WrappedTargetException,
230 css::uno::RuntimeException)
232 Any aValue;
234 switch( nHandle )
236 case DrawController::PROPERTY_CURRENTPAGE:
238 SdPage* pPage = const_cast<OutlineViewShell&>(mrOutlineViewShell).GetActualPage();
239 if (pPage != NULL)
240 aValue <<= pPage->getUnoPage();
242 break;
244 default:
245 throw beans::UnknownPropertyException();
248 return aValue;
254 } // end of namespace sd