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_svx.hxx" 26 27 #include "fmservs.hxx" 28 29 /** === begin UNO includes === **/ 30 #include <com/sun/star/form/XFormController.hpp> 31 #include <com/sun/star/form/runtime/XFormController.hpp> 32 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 33 #include <com/sun/star/lang/XServiceInfo.hpp> 34 /** === end UNO includes === **/ 35 36 #include <cppuhelper/implbase2.hxx> 37 38 //........................................................................ 39 namespace svxform 40 { 41 //........................................................................ 42 43 /** === begin UNO using === **/ 44 using ::com::sun::star::uno::Reference; 45 using ::com::sun::star::uno::XInterface; 46 using ::com::sun::star::uno::UNO_QUERY; 47 using ::com::sun::star::uno::UNO_QUERY_THROW; 48 using ::com::sun::star::uno::UNO_SET_THROW; 49 using ::com::sun::star::uno::Exception; 50 using ::com::sun::star::uno::RuntimeException; 51 using ::com::sun::star::uno::Any; 52 using ::com::sun::star::uno::makeAny; 53 using ::com::sun::star::uno::Sequence; 54 using ::com::sun::star::uno::Type; 55 using ::com::sun::star::lang::XMultiServiceFactory; 56 using ::com::sun::star::awt::XControl; 57 using ::com::sun::star::awt::XTabControllerModel; 58 using ::com::sun::star::awt::XControlContainer; 59 using ::com::sun::star::lang::XServiceInfo; 60 /** === end UNO using === **/ 61 62 using namespace ::com::sun::star; 63 64 //==================================================================== 65 //= LegacyFormController 66 //==================================================================== 67 typedef ::cppu::WeakImplHelper2 < form::XFormController 68 , XServiceInfo 69 > LegacyFormController_Base; 70 /** is an implementation of the legacy form controller service, namely css.form.FormController, supporting the 71 css.form.XFormController interface. 72 73 This legacy API is superseded by css.form.runtime.(X)FormController, and though we migrated all OOo-internal 74 usage of this old API, their might be clients external to OOo still using it (though this is rather unlikely). 75 */ 76 class LegacyFormController : public LegacyFormController_Base 77 { 78 public: Create(const Reference<XMultiServiceFactory> & _rxFactory)79 static Reference< XInterface > Create( const Reference< XMultiServiceFactory >& _rxFactory ) 80 { 81 return *( new LegacyFormController( _rxFactory ) ); 82 } 83 84 protected: LegacyFormController(const Reference<XMultiServiceFactory> & _rxFactory)85 LegacyFormController( const Reference< XMultiServiceFactory >& _rxFactory ) 86 :m_xDelegator( _rxFactory->createInstance( FM_FORM_CONTROLLER ), UNO_QUERY_THROW ) 87 { 88 } 89 90 // form::XFormController 91 virtual Reference< XControl > SAL_CALL getCurrentControl( ) throw (RuntimeException); 92 virtual void SAL_CALL addActivateListener( const Reference< form::XFormControllerListener >& l ) throw (RuntimeException); 93 virtual void SAL_CALL removeActivateListener( const Reference< form::XFormControllerListener >& l ) throw (RuntimeException); 94 95 // awt::XTabController 96 virtual void SAL_CALL setModel( const Reference< XTabControllerModel >& Model ) throw (RuntimeException); 97 virtual Reference< XTabControllerModel > SAL_CALL getModel( ) throw (RuntimeException); 98 virtual void SAL_CALL setContainer( const Reference< XControlContainer >& Container ) throw (RuntimeException); 99 virtual Reference< XControlContainer > SAL_CALL getContainer( ) throw (RuntimeException); 100 virtual Sequence< Reference< XControl > > SAL_CALL getControls( ) throw (RuntimeException); 101 virtual void SAL_CALL autoTabOrder( ) throw (RuntimeException); 102 virtual void SAL_CALL activateTabOrder( ) throw (RuntimeException); 103 virtual void SAL_CALL activateFirst( ) throw (RuntimeException); 104 virtual void SAL_CALL activateLast( ) throw (RuntimeException); 105 106 // XServiceInfo 107 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException); 108 virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); 109 virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); 110 111 private: 112 const Reference< form::runtime::XFormController > m_xDelegator; 113 }; 114 115 //-------------------------------------------------------------------- getCurrentControl()116 Reference< XControl > SAL_CALL LegacyFormController::getCurrentControl( ) throw (RuntimeException) 117 { 118 return m_xDelegator->getCurrentControl(); 119 } 120 121 //-------------------------------------------------------------------- addActivateListener(const Reference<form::XFormControllerListener> & _listener)122 void SAL_CALL LegacyFormController::addActivateListener( const Reference< form::XFormControllerListener >& _listener ) throw (RuntimeException) 123 { 124 m_xDelegator->addActivateListener( _listener ); 125 } 126 127 //-------------------------------------------------------------------- removeActivateListener(const Reference<form::XFormControllerListener> & _listener)128 void SAL_CALL LegacyFormController::removeActivateListener( const Reference< form::XFormControllerListener >& _listener ) throw (RuntimeException) 129 { 130 m_xDelegator->removeActivateListener( _listener ); 131 } 132 133 //-------------------------------------------------------------------- setModel(const Reference<XTabControllerModel> & _model)134 void SAL_CALL LegacyFormController::setModel( const Reference< XTabControllerModel >& _model ) throw (RuntimeException) 135 { 136 m_xDelegator->setModel( _model ); 137 } 138 139 //-------------------------------------------------------------------- getModel()140 Reference< XTabControllerModel > SAL_CALL LegacyFormController::getModel( ) throw (RuntimeException) 141 { 142 return m_xDelegator->getModel(); 143 } 144 145 //-------------------------------------------------------------------- setContainer(const Reference<XControlContainer> & _container)146 void SAL_CALL LegacyFormController::setContainer( const Reference< XControlContainer >& _container ) throw (RuntimeException) 147 { 148 m_xDelegator->setContainer( _container ); 149 } 150 151 //-------------------------------------------------------------------- getContainer()152 Reference< XControlContainer > SAL_CALL LegacyFormController::getContainer( ) throw (RuntimeException) 153 { 154 return m_xDelegator->getContainer(); 155 } 156 157 //-------------------------------------------------------------------- getControls()158 Sequence< Reference< XControl > > SAL_CALL LegacyFormController::getControls( ) throw (RuntimeException) 159 { 160 return m_xDelegator->getControls(); 161 } 162 163 //-------------------------------------------------------------------- autoTabOrder()164 void SAL_CALL LegacyFormController::autoTabOrder( ) throw (RuntimeException) 165 { 166 m_xDelegator->autoTabOrder(); 167 } 168 169 //-------------------------------------------------------------------- activateTabOrder()170 void SAL_CALL LegacyFormController::activateTabOrder( ) throw (RuntimeException) 171 { 172 m_xDelegator->activateTabOrder(); 173 } 174 175 //-------------------------------------------------------------------- activateFirst()176 void SAL_CALL LegacyFormController::activateFirst( ) throw (RuntimeException) 177 { 178 m_xDelegator->activateFirst(); 179 } 180 181 //-------------------------------------------------------------------- activateLast()182 void SAL_CALL LegacyFormController::activateLast( ) throw (RuntimeException) 183 { 184 m_xDelegator->activateLast(); 185 } 186 187 //-------------------------------------------------------------------- getImplementationName()188 ::rtl::OUString SAL_CALL LegacyFormController::getImplementationName( ) throw (RuntimeException) 189 { 190 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.svx.LegacyFormController" ) ); 191 } 192 193 //-------------------------------------------------------------------- supportsService(const::rtl::OUString & _serviceName)194 ::sal_Bool SAL_CALL LegacyFormController::supportsService( const ::rtl::OUString& _serviceName ) throw (RuntimeException) 195 { 196 Sequence< ::rtl::OUString > aServices( getSupportedServiceNames() ); 197 const ::rtl::OUString* pServices = aServices.getConstArray(); 198 for ( sal_Int32 i = 0; i < aServices.getLength(); ++i, ++pServices ) 199 if( pServices->equals( _serviceName ) ) 200 return sal_True; 201 return sal_False; 202 } 203 204 //-------------------------------------------------------------------- getSupportedServiceNames()205 Sequence< ::rtl::OUString > SAL_CALL LegacyFormController::getSupportedServiceNames( ) throw (RuntimeException) 206 { 207 Sequence< ::rtl::OUString > aServices(2); 208 aServices.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) ); 209 aServices.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.awt.control.TabController"); 210 return aServices; 211 } 212 213 //........................................................................ 214 } // namespace svxform 215 //........................................................................ 216 217 //------------------------------------------------------------------ 218 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL LegacyFormController_NewInstance_Impl(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & _rxORB)219 LegacyFormController_NewInstance_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB ) 220 { 221 return ::svxform::LegacyFormController::Create( _rxORB ); 222 } 223 224