Branch libreoffice-5-0-4
[LibreOffice.git] / sd / source / ui / unoidl / SdUnoOutlineView.cxx
blob6068012cca77fef4e9a567627318cb5cdba571cc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "SdUnoOutlineView.hxx"
22 #include "DrawController.hxx"
23 #include "OutlineViewShell.hxx"
24 #include "sdpage.hxx"
25 #include "unopage.hxx"
27 #include <cppuhelper/proptypehlp.hxx>
28 #include <cppuhelper/supportsservice.hxx>
29 #include <svx/unopage.hxx>
30 #include <osl/mutex.hxx>
31 #include <vcl/svapp.hxx>
33 using namespace ::cppu;
34 using namespace ::com::sun::star;
35 using namespace ::com::sun::star::uno;
37 namespace sd {
39 SdUnoOutlineView::SdUnoOutlineView(
40 OutlineViewShell& rViewShell) throw()
41 : DrawSubControllerInterfaceBase(m_aMutex),
42 mrOutlineViewShell(rViewShell)
46 SdUnoOutlineView::~SdUnoOutlineView() throw()
50 void SAL_CALL SdUnoOutlineView::disposing()
54 //----- XSelectionSupplier ----------------------------------------------------
56 sal_Bool SAL_CALL SdUnoOutlineView::select( const Any& )
57 throw(lang::IllegalArgumentException, RuntimeException, std::exception)
59 // todo: add selections for text ranges
60 return sal_False;
63 Any SAL_CALL SdUnoOutlineView::getSelection()
64 throw(RuntimeException, std::exception)
66 Any aAny;
67 return aAny;
70 void SAL_CALL SdUnoOutlineView::addSelectionChangeListener (
71 const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
72 throw(css::uno::RuntimeException, std::exception)
74 (void)rxListener;
77 void SAL_CALL SdUnoOutlineView::removeSelectionChangeListener (
78 const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
79 throw(css::uno::RuntimeException, std::exception)
81 (void)rxListener;
84 //----- XDrawView -------------------------------------------------------------
85 void SAL_CALL SdUnoOutlineView::setCurrentPage (
86 const Reference< drawing::XDrawPage >& xPage)
87 throw(RuntimeException, std::exception)
89 SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation( xPage );
90 SdrPage *pSdrPage = pDrawPage ? pDrawPage->GetSdrPage() : NULL;
91 SdPage *pSdPage = dynamic_cast<SdPage*>(pSdrPage);
93 if (pSdPage != NULL)
94 mrOutlineViewShell.SetCurrentPage(pSdPage);
97 Reference< drawing::XDrawPage > SAL_CALL SdUnoOutlineView::getCurrentPage()
98 throw(RuntimeException, std::exception)
100 Reference<drawing::XDrawPage> xPage;
102 SdPage* pPage = mrOutlineViewShell.getCurrentPage();
103 if (pPage != NULL)
104 xPage = Reference<drawing::XDrawPage>::query(pPage->getUnoPage());
106 return xPage;
109 void SdUnoOutlineView::setFastPropertyValue (
110 sal_Int32 nHandle,
111 const Any& rValue)
112 throw(css::beans::UnknownPropertyException,
113 css::beans::PropertyVetoException,
114 css::lang::IllegalArgumentException,
115 css::lang::WrappedTargetException,
116 css::uno::RuntimeException, std::exception)
118 switch( nHandle )
120 case DrawController::PROPERTY_CURRENTPAGE:
122 Reference< drawing::XDrawPage > xPage;
123 rValue >>= xPage;
124 setCurrentPage( xPage );
126 break;
128 default:
129 throw beans::UnknownPropertyException();
133 Any SAL_CALL SdUnoOutlineView::getFastPropertyValue (
134 sal_Int32 nHandle)
135 throw(css::beans::UnknownPropertyException,
136 css::lang::WrappedTargetException,
137 css::uno::RuntimeException, std::exception)
139 Any aValue;
141 switch( nHandle )
143 case DrawController::PROPERTY_CURRENTPAGE:
145 SdPage* pPage = const_cast<OutlineViewShell&>(mrOutlineViewShell).GetActualPage();
146 if (pPage != NULL)
147 aValue <<= pPage->getUnoPage();
149 break;
150 case DrawController::PROPERTY_VIEWOFFSET:
151 break;
153 default:
154 throw beans::UnknownPropertyException();
157 return aValue;
160 // XServiceInfo
161 OUString SAL_CALL SdUnoOutlineView::getImplementationName( ) throw (RuntimeException, std::exception)
163 return OUString("com.sun.star.comp.sd.SdUnoOutlineView");
166 sal_Bool SAL_CALL SdUnoOutlineView::supportsService( const OUString& ServiceName ) throw (RuntimeException, std::exception)
168 return cppu::supportsService( this, ServiceName );
171 Sequence< OUString > SAL_CALL SdUnoOutlineView::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
173 OUString aSN( "com.sun.star.presentation.OutlineView" );
174 uno::Sequence< OUString > aSeq( &aSN, 1 );
175 return aSeq;
178 } // end of namespace sd
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */