xref: /AOO41X/main/svx/source/form/legacyformcontroller.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3*cdf0e10cSrcweir  *
4*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
5*cdf0e10cSrcweir  *
6*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
7*cdf0e10cSrcweir  *
8*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
9*cdf0e10cSrcweir  *
10*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
11*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
12*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
13*cdf0e10cSrcweir  *
14*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
15*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
18*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
19*cdf0e10cSrcweir  *
20*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
21*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
22*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
23*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
24*cdf0e10cSrcweir  *
25*cdf0e10cSrcweir ************************************************************************/
26*cdf0e10cSrcweir 
27*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
28*cdf0e10cSrcweir #include "precompiled_svx.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "fmservs.hxx"
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir /** === begin UNO includes === **/
33*cdf0e10cSrcweir #include <com/sun/star/form/XFormController.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/form/runtime/XFormController.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
37*cdf0e10cSrcweir /** === end UNO includes === **/
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir //........................................................................
42*cdf0e10cSrcweir namespace svxform
43*cdf0e10cSrcweir {
44*cdf0e10cSrcweir //........................................................................
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir 	/** === begin UNO using === **/
47*cdf0e10cSrcweir 	using ::com::sun::star::uno::Reference;
48*cdf0e10cSrcweir 	using ::com::sun::star::uno::XInterface;
49*cdf0e10cSrcweir 	using ::com::sun::star::uno::UNO_QUERY;
50*cdf0e10cSrcweir 	using ::com::sun::star::uno::UNO_QUERY_THROW;
51*cdf0e10cSrcweir 	using ::com::sun::star::uno::UNO_SET_THROW;
52*cdf0e10cSrcweir 	using ::com::sun::star::uno::Exception;
53*cdf0e10cSrcweir 	using ::com::sun::star::uno::RuntimeException;
54*cdf0e10cSrcweir 	using ::com::sun::star::uno::Any;
55*cdf0e10cSrcweir 	using ::com::sun::star::uno::makeAny;
56*cdf0e10cSrcweir 	using ::com::sun::star::uno::Sequence;
57*cdf0e10cSrcweir 	using ::com::sun::star::uno::Type;
58*cdf0e10cSrcweir     using ::com::sun::star::lang::XMultiServiceFactory;
59*cdf0e10cSrcweir     using ::com::sun::star::awt::XControl;
60*cdf0e10cSrcweir     using ::com::sun::star::awt::XTabControllerModel;
61*cdf0e10cSrcweir     using ::com::sun::star::awt::XControlContainer;
62*cdf0e10cSrcweir     using ::com::sun::star::lang::XServiceInfo;
63*cdf0e10cSrcweir 	/** === end UNO using === **/
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir     using namespace ::com::sun::star;
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 	//====================================================================
68*cdf0e10cSrcweir 	//= LegacyFormController
69*cdf0e10cSrcweir 	//====================================================================
70*cdf0e10cSrcweir     typedef ::cppu::WeakImplHelper2 <   form::XFormController
71*cdf0e10cSrcweir                                     ,   XServiceInfo
72*cdf0e10cSrcweir                                     >   LegacyFormController_Base;
73*cdf0e10cSrcweir     /** is an implementation of the legacy form controller service, namely css.form.FormController, supporting the
74*cdf0e10cSrcweir         css.form.XFormController interface.
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir         This legacy API is superseded by css.form.runtime.(X)FormController, and though we migrated all OOo-internal
77*cdf0e10cSrcweir         usage of this old API, their might be clients external to OOo still using it (though this is rather unlikely).
78*cdf0e10cSrcweir     */
79*cdf0e10cSrcweir     class LegacyFormController : public LegacyFormController_Base
80*cdf0e10cSrcweir     {
81*cdf0e10cSrcweir     public:
82*cdf0e10cSrcweir         static Reference< XInterface > Create( const Reference< XMultiServiceFactory >& _rxFactory )
83*cdf0e10cSrcweir         {
84*cdf0e10cSrcweir             return *( new LegacyFormController( _rxFactory ) );
85*cdf0e10cSrcweir         }
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir     protected:
88*cdf0e10cSrcweir         LegacyFormController( const Reference< XMultiServiceFactory >& _rxFactory )
89*cdf0e10cSrcweir             :m_xDelegator( _rxFactory->createInstance( FM_FORM_CONTROLLER ), UNO_QUERY_THROW )
90*cdf0e10cSrcweir         {
91*cdf0e10cSrcweir         }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir         // form::XFormController
94*cdf0e10cSrcweir         virtual Reference< XControl > SAL_CALL getCurrentControl(  ) throw (RuntimeException);
95*cdf0e10cSrcweir         virtual void SAL_CALL addActivateListener( const Reference< form::XFormControllerListener >& l ) throw (RuntimeException);
96*cdf0e10cSrcweir         virtual void SAL_CALL removeActivateListener( const Reference< form::XFormControllerListener >& l ) throw (RuntimeException);
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir         // awt::XTabController
99*cdf0e10cSrcweir         virtual void SAL_CALL setModel( const Reference< XTabControllerModel >& Model ) throw (RuntimeException);
100*cdf0e10cSrcweir         virtual Reference< XTabControllerModel > SAL_CALL getModel(  ) throw (RuntimeException);
101*cdf0e10cSrcweir         virtual void SAL_CALL setContainer( const Reference< XControlContainer >& Container ) throw (RuntimeException);
102*cdf0e10cSrcweir         virtual Reference< XControlContainer > SAL_CALL getContainer(  ) throw (RuntimeException);
103*cdf0e10cSrcweir         virtual Sequence< Reference< XControl > > SAL_CALL getControls(  ) throw (RuntimeException);
104*cdf0e10cSrcweir         virtual void SAL_CALL autoTabOrder(  ) throw (RuntimeException);
105*cdf0e10cSrcweir         virtual void SAL_CALL activateTabOrder(  ) throw (RuntimeException);
106*cdf0e10cSrcweir         virtual void SAL_CALL activateFirst(  ) throw (RuntimeException);
107*cdf0e10cSrcweir         virtual void SAL_CALL activateLast(  ) throw (RuntimeException);
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir         // XServiceInfo
110*cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (RuntimeException);
111*cdf0e10cSrcweir         virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException);
112*cdf0e10cSrcweir         virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (RuntimeException);
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     private:
115*cdf0e10cSrcweir         const Reference< form::runtime::XFormController >   m_xDelegator;
116*cdf0e10cSrcweir     };
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     //--------------------------------------------------------------------
119*cdf0e10cSrcweir     Reference< XControl > SAL_CALL LegacyFormController::getCurrentControl(  ) throw (RuntimeException)
120*cdf0e10cSrcweir     {
121*cdf0e10cSrcweir         return m_xDelegator->getCurrentControl();
122*cdf0e10cSrcweir     }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     //--------------------------------------------------------------------
125*cdf0e10cSrcweir     void SAL_CALL LegacyFormController::addActivateListener( const Reference< form::XFormControllerListener >& _listener ) throw (RuntimeException)
126*cdf0e10cSrcweir     {
127*cdf0e10cSrcweir         m_xDelegator->addActivateListener( _listener );
128*cdf0e10cSrcweir     }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir     //--------------------------------------------------------------------
131*cdf0e10cSrcweir     void SAL_CALL LegacyFormController::removeActivateListener( const Reference< form::XFormControllerListener >& _listener ) throw (RuntimeException)
132*cdf0e10cSrcweir     {
133*cdf0e10cSrcweir         m_xDelegator->removeActivateListener( _listener );
134*cdf0e10cSrcweir     }
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir     //--------------------------------------------------------------------
137*cdf0e10cSrcweir     void SAL_CALL LegacyFormController::setModel( const Reference< XTabControllerModel >& _model ) throw (RuntimeException)
138*cdf0e10cSrcweir     {
139*cdf0e10cSrcweir         m_xDelegator->setModel( _model );
140*cdf0e10cSrcweir     }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir     //--------------------------------------------------------------------
143*cdf0e10cSrcweir     Reference< XTabControllerModel > SAL_CALL LegacyFormController::getModel(  ) throw (RuntimeException)
144*cdf0e10cSrcweir     {
145*cdf0e10cSrcweir         return m_xDelegator->getModel();
146*cdf0e10cSrcweir     }
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir     //--------------------------------------------------------------------
149*cdf0e10cSrcweir     void SAL_CALL LegacyFormController::setContainer( const Reference< XControlContainer >& _container ) throw (RuntimeException)
150*cdf0e10cSrcweir     {
151*cdf0e10cSrcweir         m_xDelegator->setContainer( _container );
152*cdf0e10cSrcweir     }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir     //--------------------------------------------------------------------
155*cdf0e10cSrcweir     Reference< XControlContainer > SAL_CALL LegacyFormController::getContainer(  ) throw (RuntimeException)
156*cdf0e10cSrcweir     {
157*cdf0e10cSrcweir         return m_xDelegator->getContainer();
158*cdf0e10cSrcweir     }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir     //--------------------------------------------------------------------
161*cdf0e10cSrcweir     Sequence< Reference< XControl > > SAL_CALL LegacyFormController::getControls(  ) throw (RuntimeException)
162*cdf0e10cSrcweir     {
163*cdf0e10cSrcweir         return m_xDelegator->getControls();
164*cdf0e10cSrcweir     }
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     //--------------------------------------------------------------------
167*cdf0e10cSrcweir     void SAL_CALL LegacyFormController::autoTabOrder(  ) throw (RuntimeException)
168*cdf0e10cSrcweir     {
169*cdf0e10cSrcweir         m_xDelegator->autoTabOrder();
170*cdf0e10cSrcweir     }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     //--------------------------------------------------------------------
173*cdf0e10cSrcweir     void SAL_CALL LegacyFormController::activateTabOrder(  ) throw (RuntimeException)
174*cdf0e10cSrcweir     {
175*cdf0e10cSrcweir         m_xDelegator->activateTabOrder();
176*cdf0e10cSrcweir     }
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir     //--------------------------------------------------------------------
179*cdf0e10cSrcweir     void SAL_CALL LegacyFormController::activateFirst(  ) throw (RuntimeException)
180*cdf0e10cSrcweir     {
181*cdf0e10cSrcweir         m_xDelegator->activateFirst();
182*cdf0e10cSrcweir     }
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir     //--------------------------------------------------------------------
185*cdf0e10cSrcweir     void SAL_CALL LegacyFormController::activateLast(  ) throw (RuntimeException)
186*cdf0e10cSrcweir     {
187*cdf0e10cSrcweir         m_xDelegator->activateLast();
188*cdf0e10cSrcweir     }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir     //--------------------------------------------------------------------
191*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL LegacyFormController::getImplementationName(  ) throw (RuntimeException)
192*cdf0e10cSrcweir     {
193*cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.svx.LegacyFormController" ) );
194*cdf0e10cSrcweir     }
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir     //--------------------------------------------------------------------
197*cdf0e10cSrcweir     ::sal_Bool SAL_CALL LegacyFormController::supportsService( const ::rtl::OUString& _serviceName ) throw (RuntimeException)
198*cdf0e10cSrcweir     {
199*cdf0e10cSrcweir         Sequence< ::rtl::OUString > aServices( getSupportedServiceNames() );
200*cdf0e10cSrcweir         const ::rtl::OUString* pServices = aServices.getConstArray();
201*cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < aServices.getLength(); ++i, ++pServices )
202*cdf0e10cSrcweir             if( pServices->equals( _serviceName ) )
203*cdf0e10cSrcweir                 return sal_True;
204*cdf0e10cSrcweir         return sal_False;
205*cdf0e10cSrcweir     }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir     //--------------------------------------------------------------------
208*cdf0e10cSrcweir     Sequence< ::rtl::OUString > SAL_CALL LegacyFormController::getSupportedServiceNames(  ) throw (RuntimeException)
209*cdf0e10cSrcweir     {
210*cdf0e10cSrcweir         Sequence< ::rtl::OUString > aServices(2);
211*cdf0e10cSrcweir         aServices.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) );
212*cdf0e10cSrcweir         aServices.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.awt.control.TabController");
213*cdf0e10cSrcweir         return aServices;
214*cdf0e10cSrcweir     }
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir //........................................................................
217*cdf0e10cSrcweir } // namespace svxform
218*cdf0e10cSrcweir //........................................................................
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir //------------------------------------------------------------------
221*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
222*cdf0e10cSrcweir     LegacyFormController_NewInstance_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB )
223*cdf0e10cSrcweir {
224*cdf0e10cSrcweir     return ::svxform::LegacyFormController::Create( _rxORB );
225*cdf0e10cSrcweir }
226*cdf0e10cSrcweir 
227