Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / svx / source / form / legacyformcontroller.cxx
blob1fefcb2a9c48cf6083c856907c57dfe8f98c679d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
29 #include "fmservs.hxx"
31 /** === begin UNO includes === **/
32 #include <com/sun/star/form/XFormController.hpp>
33 #include <com/sun/star/form/runtime/XFormController.hpp>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 /** === end UNO includes === **/
38 #include <cppuhelper/implbase2.hxx>
40 //........................................................................
41 namespace svxform
43 //........................................................................
45 /** === begin UNO using === **/
46 using ::com::sun::star::uno::Reference;
47 using ::com::sun::star::uno::XInterface;
48 using ::com::sun::star::uno::UNO_QUERY;
49 using ::com::sun::star::uno::UNO_QUERY_THROW;
50 using ::com::sun::star::uno::UNO_SET_THROW;
51 using ::com::sun::star::uno::Exception;
52 using ::com::sun::star::uno::RuntimeException;
53 using ::com::sun::star::uno::Any;
54 using ::com::sun::star::uno::makeAny;
55 using ::com::sun::star::uno::Sequence;
56 using ::com::sun::star::uno::Type;
57 using ::com::sun::star::lang::XMultiServiceFactory;
58 using ::com::sun::star::awt::XControl;
59 using ::com::sun::star::awt::XTabControllerModel;
60 using ::com::sun::star::awt::XControlContainer;
61 using ::com::sun::star::lang::XServiceInfo;
62 /** === end UNO using === **/
64 using namespace ::com::sun::star;
66 //====================================================================
67 //= LegacyFormController
68 //====================================================================
69 typedef ::cppu::WeakImplHelper2 < form::XFormController
70 , XServiceInfo
71 > LegacyFormController_Base;
72 /** is an implementation of the legacy form controller service, namely css.form.FormController, supporting the
73 css.form.XFormController interface.
75 This legacy API is superseded by css.form.runtime.(X)FormController, and though we migrated all OOo-internal
76 usage of this old API, their might be clients external to OOo still using it (though this is rather unlikely).
78 class LegacyFormController : public LegacyFormController_Base
80 public:
81 static Reference< XInterface > Create( const Reference< XMultiServiceFactory >& _rxFactory )
83 return *( new LegacyFormController( _rxFactory ) );
86 protected:
87 LegacyFormController( const Reference< XMultiServiceFactory >& _rxFactory )
88 :m_xDelegator( _rxFactory->createInstance( FM_FORM_CONTROLLER ), UNO_QUERY_THROW )
92 // form::XFormController
93 virtual Reference< XControl > SAL_CALL getCurrentControl( ) throw (RuntimeException);
94 virtual void SAL_CALL addActivateListener( const Reference< form::XFormControllerListener >& l ) throw (RuntimeException);
95 virtual void SAL_CALL removeActivateListener( const Reference< form::XFormControllerListener >& l ) throw (RuntimeException);
97 // awt::XTabController
98 virtual void SAL_CALL setModel( const Reference< XTabControllerModel >& Model ) throw (RuntimeException);
99 virtual Reference< XTabControllerModel > SAL_CALL getModel( ) throw (RuntimeException);
100 virtual void SAL_CALL setContainer( const Reference< XControlContainer >& Container ) throw (RuntimeException);
101 virtual Reference< XControlContainer > SAL_CALL getContainer( ) throw (RuntimeException);
102 virtual Sequence< Reference< XControl > > SAL_CALL getControls( ) throw (RuntimeException);
103 virtual void SAL_CALL autoTabOrder( ) throw (RuntimeException);
104 virtual void SAL_CALL activateTabOrder( ) throw (RuntimeException);
105 virtual void SAL_CALL activateFirst( ) throw (RuntimeException);
106 virtual void SAL_CALL activateLast( ) throw (RuntimeException);
108 // XServiceInfo
109 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException);
110 virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException);
111 virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException);
113 private:
114 const Reference< form::runtime::XFormController > m_xDelegator;
117 //--------------------------------------------------------------------
118 Reference< XControl > SAL_CALL LegacyFormController::getCurrentControl( ) throw (RuntimeException)
120 return m_xDelegator->getCurrentControl();
123 //--------------------------------------------------------------------
124 void SAL_CALL LegacyFormController::addActivateListener( const Reference< form::XFormControllerListener >& _listener ) throw (RuntimeException)
126 m_xDelegator->addActivateListener( _listener );
129 //--------------------------------------------------------------------
130 void SAL_CALL LegacyFormController::removeActivateListener( const Reference< form::XFormControllerListener >& _listener ) throw (RuntimeException)
132 m_xDelegator->removeActivateListener( _listener );
135 //--------------------------------------------------------------------
136 void SAL_CALL LegacyFormController::setModel( const Reference< XTabControllerModel >& _model ) throw (RuntimeException)
138 m_xDelegator->setModel( _model );
141 //--------------------------------------------------------------------
142 Reference< XTabControllerModel > SAL_CALL LegacyFormController::getModel( ) throw (RuntimeException)
144 return m_xDelegator->getModel();
147 //--------------------------------------------------------------------
148 void SAL_CALL LegacyFormController::setContainer( const Reference< XControlContainer >& _container ) throw (RuntimeException)
150 m_xDelegator->setContainer( _container );
153 //--------------------------------------------------------------------
154 Reference< XControlContainer > SAL_CALL LegacyFormController::getContainer( ) throw (RuntimeException)
156 return m_xDelegator->getContainer();
159 //--------------------------------------------------------------------
160 Sequence< Reference< XControl > > SAL_CALL LegacyFormController::getControls( ) throw (RuntimeException)
162 return m_xDelegator->getControls();
165 //--------------------------------------------------------------------
166 void SAL_CALL LegacyFormController::autoTabOrder( ) throw (RuntimeException)
168 m_xDelegator->autoTabOrder();
171 //--------------------------------------------------------------------
172 void SAL_CALL LegacyFormController::activateTabOrder( ) throw (RuntimeException)
174 m_xDelegator->activateTabOrder();
177 //--------------------------------------------------------------------
178 void SAL_CALL LegacyFormController::activateFirst( ) throw (RuntimeException)
180 m_xDelegator->activateFirst();
183 //--------------------------------------------------------------------
184 void SAL_CALL LegacyFormController::activateLast( ) throw (RuntimeException)
186 m_xDelegator->activateLast();
189 //--------------------------------------------------------------------
190 ::rtl::OUString SAL_CALL LegacyFormController::getImplementationName( ) throw (RuntimeException)
192 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.svx.LegacyFormController" ) );
195 //--------------------------------------------------------------------
196 ::sal_Bool SAL_CALL LegacyFormController::supportsService( const ::rtl::OUString& _serviceName ) throw (RuntimeException)
198 Sequence< ::rtl::OUString > aServices( getSupportedServiceNames() );
199 const ::rtl::OUString* pServices = aServices.getConstArray();
200 for ( sal_Int32 i = 0; i < aServices.getLength(); ++i, ++pServices )
201 if( pServices->equals( _serviceName ) )
202 return sal_True;
203 return sal_False;
206 //--------------------------------------------------------------------
207 Sequence< ::rtl::OUString > SAL_CALL LegacyFormController::getSupportedServiceNames( ) throw (RuntimeException)
209 Sequence< ::rtl::OUString > aServices(2);
210 aServices.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) );
211 aServices.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.control.TabController") );
212 return aServices;
215 //........................................................................
216 } // namespace svxform
217 //........................................................................
219 //------------------------------------------------------------------
220 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
221 LegacyFormController_NewInstance_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB )
223 return ::svxform::LegacyFormController::Create( _rxORB );
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */