1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include "fmservs.hxx"
23 #include <com/sun/star/form/XFormController.hpp>
24 #include <com/sun/star/form/runtime/FormController.hpp>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <cppuhelper/implbase2.hxx>
29 #include <comphelper/processfactory.hxx>
31 //........................................................................
34 //........................................................................
36 using ::com::sun::star::uno::Reference
;
37 using ::com::sun::star::uno::XInterface
;
38 using ::com::sun::star::uno::UNO_QUERY
;
39 using ::com::sun::star::uno::UNO_QUERY_THROW
;
40 using ::com::sun::star::uno::UNO_SET_THROW
;
41 using ::com::sun::star::uno::Exception
;
42 using ::com::sun::star::uno::RuntimeException
;
43 using ::com::sun::star::uno::Any
;
44 using ::com::sun::star::uno::makeAny
;
45 using ::com::sun::star::uno::Sequence
;
46 using ::com::sun::star::uno::Type
;
47 using ::com::sun::star::uno::XComponentContext
;
48 using ::com::sun::star::lang::XMultiServiceFactory
;
49 using ::com::sun::star::awt::XControl
;
50 using ::com::sun::star::awt::XTabControllerModel
;
51 using ::com::sun::star::awt::XControlContainer
;
52 using ::com::sun::star::lang::XServiceInfo
;
53 using ::com::sun::star::form::runtime::FormController
;
55 using namespace ::com::sun::star
;
57 //====================================================================
58 //= LegacyFormController
59 //====================================================================
60 typedef ::cppu::WeakImplHelper2
< form::XFormController
62 > LegacyFormController_Base
;
63 /** is an implementation of the legacy form controller service, namely css.form.FormController, supporting the
64 css.form.XFormController interface.
66 This legacy API is superseded by css.form.runtime.(X)FormController, and though we migrated all OOo-internal
67 usage of this old API, their might be clients external to OOo still using it (though this is rather unlikely).
69 class LegacyFormController
: public LegacyFormController_Base
72 static Reference
< XInterface
> Create( const Reference
< XMultiServiceFactory
>& _rxFactory
)
74 return *( new LegacyFormController( comphelper::getComponentContext(_rxFactory
) ) );
78 LegacyFormController( const Reference
< XComponentContext
>& _rxContext
)
79 :m_xDelegator( FormController::create(_rxContext
) )
83 // form::XFormController
84 virtual Reference
< XControl
> SAL_CALL
getCurrentControl( ) throw (RuntimeException
);
85 virtual void SAL_CALL
addActivateListener( const Reference
< form::XFormControllerListener
>& l
) throw (RuntimeException
);
86 virtual void SAL_CALL
removeActivateListener( const Reference
< form::XFormControllerListener
>& l
) throw (RuntimeException
);
88 // awt::XTabController
89 virtual void SAL_CALL
setModel( const Reference
< XTabControllerModel
>& Model
) throw (RuntimeException
);
90 virtual Reference
< XTabControllerModel
> SAL_CALL
getModel( ) throw (RuntimeException
);
91 virtual void SAL_CALL
setContainer( const Reference
< XControlContainer
>& Container
) throw (RuntimeException
);
92 virtual Reference
< XControlContainer
> SAL_CALL
getContainer( ) throw (RuntimeException
);
93 virtual Sequence
< Reference
< XControl
> > SAL_CALL
getControls( ) throw (RuntimeException
);
94 virtual void SAL_CALL
autoTabOrder( ) throw (RuntimeException
);
95 virtual void SAL_CALL
activateTabOrder( ) throw (RuntimeException
);
96 virtual void SAL_CALL
activateFirst( ) throw (RuntimeException
);
97 virtual void SAL_CALL
activateLast( ) throw (RuntimeException
);
100 virtual OUString SAL_CALL
getImplementationName( ) throw (RuntimeException
);
101 virtual ::sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw (RuntimeException
);
102 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw (RuntimeException
);
105 const Reference
< form::runtime::XFormController
> m_xDelegator
;
108 //--------------------------------------------------------------------
109 Reference
< XControl
> SAL_CALL
LegacyFormController::getCurrentControl( ) throw (RuntimeException
)
111 return m_xDelegator
->getCurrentControl();
114 //--------------------------------------------------------------------
115 void SAL_CALL
LegacyFormController::addActivateListener( const Reference
< form::XFormControllerListener
>& _listener
) throw (RuntimeException
)
117 m_xDelegator
->addActivateListener( _listener
);
120 //--------------------------------------------------------------------
121 void SAL_CALL
LegacyFormController::removeActivateListener( const Reference
< form::XFormControllerListener
>& _listener
) throw (RuntimeException
)
123 m_xDelegator
->removeActivateListener( _listener
);
126 //--------------------------------------------------------------------
127 void SAL_CALL
LegacyFormController::setModel( const Reference
< XTabControllerModel
>& _model
) throw (RuntimeException
)
129 m_xDelegator
->setModel( _model
);
132 //--------------------------------------------------------------------
133 Reference
< XTabControllerModel
> SAL_CALL
LegacyFormController::getModel( ) throw (RuntimeException
)
135 return m_xDelegator
->getModel();
138 //--------------------------------------------------------------------
139 void SAL_CALL
LegacyFormController::setContainer( const Reference
< XControlContainer
>& _container
) throw (RuntimeException
)
141 m_xDelegator
->setContainer( _container
);
144 //--------------------------------------------------------------------
145 Reference
< XControlContainer
> SAL_CALL
LegacyFormController::getContainer( ) throw (RuntimeException
)
147 return m_xDelegator
->getContainer();
150 //--------------------------------------------------------------------
151 Sequence
< Reference
< XControl
> > SAL_CALL
LegacyFormController::getControls( ) throw (RuntimeException
)
153 return m_xDelegator
->getControls();
156 //--------------------------------------------------------------------
157 void SAL_CALL
LegacyFormController::autoTabOrder( ) throw (RuntimeException
)
159 m_xDelegator
->autoTabOrder();
162 //--------------------------------------------------------------------
163 void SAL_CALL
LegacyFormController::activateTabOrder( ) throw (RuntimeException
)
165 m_xDelegator
->activateTabOrder();
168 //--------------------------------------------------------------------
169 void SAL_CALL
LegacyFormController::activateFirst( ) throw (RuntimeException
)
171 m_xDelegator
->activateFirst();
174 //--------------------------------------------------------------------
175 void SAL_CALL
LegacyFormController::activateLast( ) throw (RuntimeException
)
177 m_xDelegator
->activateLast();
180 //--------------------------------------------------------------------
181 OUString SAL_CALL
LegacyFormController::getImplementationName( ) throw (RuntimeException
)
183 return OUString( "org.openoffice.comp.svx.LegacyFormController" );
186 //--------------------------------------------------------------------
187 ::sal_Bool SAL_CALL
LegacyFormController::supportsService( const OUString
& _serviceName
) throw (RuntimeException
)
189 Sequence
< OUString
> aServices( getSupportedServiceNames() );
190 const OUString
* pServices
= aServices
.getConstArray();
191 for ( sal_Int32 i
= 0; i
< aServices
.getLength(); ++i
, ++pServices
)
192 if( pServices
->equals( _serviceName
) )
197 //--------------------------------------------------------------------
198 Sequence
< OUString
> SAL_CALL
LegacyFormController::getSupportedServiceNames( ) throw (RuntimeException
)
200 Sequence
< OUString
> aServices(2);
201 aServices
.getArray()[0] = OUString( "com.sun.star.form.FormController" );
202 aServices
.getArray()[1] = OUString("com.sun.star.awt.control.TabController");
206 //........................................................................
207 } // namespace svxform
208 //........................................................................
210 //------------------------------------------------------------------
211 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
212 LegacyFormController_NewInstance_Impl( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> & _rxORB
)
214 return ::svxform::LegacyFormController::Create( _rxORB
);
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */