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 <cppuhelper/supportsservice.hxx>
30 #include <comphelper/processfactory.hxx>
37 using ::com::sun::star::uno::Reference
;
38 using ::com::sun::star::uno::XInterface
;
39 using ::com::sun::star::uno::UNO_QUERY
;
40 using ::com::sun::star::uno::UNO_QUERY_THROW
;
41 using ::com::sun::star::uno::UNO_SET_THROW
;
42 using ::com::sun::star::uno::Exception
;
43 using ::com::sun::star::uno::RuntimeException
;
44 using ::com::sun::star::uno::Any
;
45 using ::com::sun::star::uno::makeAny
;
46 using ::com::sun::star::uno::Sequence
;
47 using ::com::sun::star::uno::Type
;
48 using ::com::sun::star::uno::XComponentContext
;
49 using ::com::sun::star::lang::XMultiServiceFactory
;
50 using ::com::sun::star::awt::XControl
;
51 using ::com::sun::star::awt::XTabControllerModel
;
52 using ::com::sun::star::awt::XControlContainer
;
53 using ::com::sun::star::lang::XServiceInfo
;
54 using ::com::sun::star::form::runtime::FormController
;
56 using namespace ::com::sun::star
;
59 //= LegacyFormController
61 typedef ::cppu::WeakImplHelper2
< form::XFormController
63 > LegacyFormController_Base
;
64 /** is an implementation of the legacy form controller service, namely css.form.FormController, supporting the
65 css.form.XFormController interface.
67 This legacy API is superseded by css.form.runtime.(X)FormController, and though we migrated all OOo-internal
68 usage of this old API, their might be clients external to OOo still using it (though this is rather unlikely).
70 class LegacyFormController
: public LegacyFormController_Base
73 static Reference
< XInterface
> Create( const Reference
< XMultiServiceFactory
>& _rxFactory
)
75 return *( new LegacyFormController( comphelper::getComponentContext(_rxFactory
) ) );
79 LegacyFormController( const Reference
< XComponentContext
>& _rxContext
)
80 :m_xDelegator( FormController::create(_rxContext
) )
84 // form::XFormController
85 virtual Reference
< XControl
> SAL_CALL
getCurrentControl( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
86 virtual void SAL_CALL
addActivateListener( const Reference
< form::XFormControllerListener
>& l
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
87 virtual void SAL_CALL
removeActivateListener( const Reference
< form::XFormControllerListener
>& l
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
89 // awt::XTabController
90 virtual void SAL_CALL
setModel( const Reference
< XTabControllerModel
>& Model
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
91 virtual Reference
< XTabControllerModel
> SAL_CALL
getModel( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
92 virtual void SAL_CALL
setContainer( const Reference
< XControlContainer
>& Container
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
93 virtual Reference
< XControlContainer
> SAL_CALL
getContainer( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
94 virtual Sequence
< Reference
< XControl
> > SAL_CALL
getControls( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
95 virtual void SAL_CALL
autoTabOrder( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
96 virtual void SAL_CALL
activateTabOrder( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
97 virtual void SAL_CALL
activateFirst( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
98 virtual void SAL_CALL
activateLast( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
101 virtual OUString SAL_CALL
getImplementationName( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
102 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
103 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
106 const Reference
< form::runtime::XFormController
> m_xDelegator
;
110 Reference
< XControl
> SAL_CALL
LegacyFormController::getCurrentControl( ) throw (RuntimeException
, std::exception
)
112 return m_xDelegator
->getCurrentControl();
116 void SAL_CALL
LegacyFormController::addActivateListener( const Reference
< form::XFormControllerListener
>& _listener
) throw (RuntimeException
, std::exception
)
118 m_xDelegator
->addActivateListener( _listener
);
122 void SAL_CALL
LegacyFormController::removeActivateListener( const Reference
< form::XFormControllerListener
>& _listener
) throw (RuntimeException
, std::exception
)
124 m_xDelegator
->removeActivateListener( _listener
);
128 void SAL_CALL
LegacyFormController::setModel( const Reference
< XTabControllerModel
>& _model
) throw (RuntimeException
, std::exception
)
130 m_xDelegator
->setModel( _model
);
134 Reference
< XTabControllerModel
> SAL_CALL
LegacyFormController::getModel( ) throw (RuntimeException
, std::exception
)
136 return m_xDelegator
->getModel();
140 void SAL_CALL
LegacyFormController::setContainer( const Reference
< XControlContainer
>& _container
) throw (RuntimeException
, std::exception
)
142 m_xDelegator
->setContainer( _container
);
146 Reference
< XControlContainer
> SAL_CALL
LegacyFormController::getContainer( ) throw (RuntimeException
, std::exception
)
148 return m_xDelegator
->getContainer();
152 Sequence
< Reference
< XControl
> > SAL_CALL
LegacyFormController::getControls( ) throw (RuntimeException
, std::exception
)
154 return m_xDelegator
->getControls();
158 void SAL_CALL
LegacyFormController::autoTabOrder( ) throw (RuntimeException
, std::exception
)
160 m_xDelegator
->autoTabOrder();
164 void SAL_CALL
LegacyFormController::activateTabOrder( ) throw (RuntimeException
, std::exception
)
166 m_xDelegator
->activateTabOrder();
170 void SAL_CALL
LegacyFormController::activateFirst( ) throw (RuntimeException
, std::exception
)
172 m_xDelegator
->activateFirst();
176 void SAL_CALL
LegacyFormController::activateLast( ) throw (RuntimeException
, std::exception
)
178 m_xDelegator
->activateLast();
182 OUString SAL_CALL
LegacyFormController::getImplementationName( ) throw (RuntimeException
, std::exception
)
184 return OUString( "org.openoffice.comp.svx.LegacyFormController" );
187 sal_Bool SAL_CALL
LegacyFormController::supportsService( const OUString
& _serviceName
) throw (RuntimeException
, std::exception
)
189 return cppu::supportsService(this, _serviceName
);
192 Sequence
< OUString
> SAL_CALL
LegacyFormController::getSupportedServiceNames( ) throw (RuntimeException
, std::exception
)
194 Sequence
< OUString
> aServices(2);
195 aServices
.getArray()[0] = "com.sun.star.form.FormController";
196 aServices
.getArray()[1] = "com.sun.star.awt.control.TabController";
200 } // namespace svxform
202 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
203 LegacyFormController_NewInstance_Impl( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> & _rxORB
)
204 throw (css::uno::Exception
)
206 return ::svxform::LegacyFormController::Create( _rxORB
);
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */