summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorFrank Schönheit <fs@openoffice.org>2002-03-04 13:01:11 +0000
committerFrank Schönheit <fs@openoffice.org>2002-03-04 13:01:11 +0000
commit9c126f8e94cbfed032b96f73611551424068d37e (patch)
treea75ab3711811f93d1dc345587fd747397a9aac38 /forms
parent388f54a5f8b14e97f093463498dcccb3367c4181 (diff)
#97083# preparing migration of the registration process to the OFormsModule class - sample implementation already done for ODatabaseForm
Diffstat (limited to 'forms')
-rw-r--r--forms/source/component/DatabaseForm.cxx92
-rw-r--r--forms/source/component/DatabaseForm.hxx17
-rw-r--r--forms/source/misc/services.cxx91
3 files changed, 154 insertions, 46 deletions
diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index 47cfc0630203..75fb8dbafad9 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DatabaseForm.cxx,v $
*
- * $Revision: 1.42 $
+ * $Revision: 1.43 $
*
- * last change: $Author: fs $ $Date: 2002-01-09 15:30:36 $
+ * last change: $Author: fs $ $Date: 2002-03-04 14:01:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -242,6 +242,9 @@
#ifndef _UNTOOLS_UCBSTREAMHELPER_HXX
#include <unotools/ucbstreamhelper.hxx>
#endif
+#ifndef FORMS_MODULE_HXX
+#include "formsmodule.hxx"
+#endif
// compatiblity: DatabaseCursorType is dead, but for compatiblity reasons we still have to write it ...
namespace com {
@@ -289,6 +292,12 @@ using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::data;
using namespace ::com::sun::star::util;
+//--------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_ODatabaseForm()
+{
+ static ::frm::OMultiInstanceAutoRegistration< ::frm::ODatabaseForm > aAutoRegistration;
+}
+
//.........................................................................
namespace frm
{
@@ -686,9 +695,9 @@ void OFormSubmitResetThread::processEvent(
//==================================================================
//------------------------------------------------------------------
-InterfaceRef SAL_CALL ODatabaseForm_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
+Reference< XInterface > SAL_CALL ODatabaseForm::Create( const Reference< XMultiServiceFactory >& _rxFactory )
{
- return *(new ODatabaseForm(_rxFactory));
+ return *( new ODatabaseForm( _rxFactory ) );
}
//------------------------------------------------------------------------------
@@ -1972,8 +1981,8 @@ void ODatabaseForm::fillProperties(
DECL_IFACE_PROP3(ACTIVE_CONNECTION, XConnection, BOUND, TRANSIENT, MAYBEVOID);
DECL_PROP1(NAME, ::rtl::OUString, BOUND);
- DECL_PROP1(MASTERFIELDS, StringSequence, BOUND);
- DECL_PROP1(DETAILFIELDS, StringSequence, BOUND);
+ DECL_PROP1(MASTERFIELDS, Sequence< ::rtl::OUString >, BOUND);
+ DECL_PROP1(DETAILFIELDS, Sequence< ::rtl::OUString >, BOUND);
DECL_PROP2(DATASOURCE, ::rtl::OUString, BOUND, CONSTRAINED);
DECL_PROP3(CYCLE, TabulatorCycle, BOUND, MAYBEVOID, MAYBEDEFAULT);
DECL_PROP1(NAVIGATION, NavigationBarMode, BOUND);
@@ -4034,34 +4043,77 @@ void SAL_CALL ODatabaseForm::clearParameters() throw( SQLException, RuntimeExcep
// com::sun::star::lang::XServiceInfo
//------------------------------------------------------------------------------
-::rtl::OUString SAL_CALL ODatabaseForm::getImplementationName() throw( RuntimeException )
+::rtl::OUString SAL_CALL ODatabaseForm::getImplementationName_Static()
{
return DATABASEFORM_IMPLEMENTATION_NAME;
}
//------------------------------------------------------------------------------
-StringSequence SAL_CALL ODatabaseForm::getSupportedServiceNames() throw( RuntimeException )
+Sequence< ::rtl::OUString > SAL_CALL ODatabaseForm::getCompatibleServiceNames_Static()
{
- StringSequence aServices;
- Reference<com::sun::star::lang::XServiceInfo> xInfo;
+ Sequence< ::rtl::OUString > aServices( 1 );
+ ::rtl::OUString* pServices = aServices.getArray();
+
+ *pServices++ = FRM_COMPONENT_FORM;
+
+ return aServices;
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ODatabaseForm::getCurrentServiceNames_Static()
+{
+ Sequence< ::rtl::OUString > aServices( 5 );
+ ::rtl::OUString* pServices = aServices.getArray();
+
+ *pServices++ = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponent");
+ *pServices++ = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponents");
+ *pServices++ = FRM_SUN_COMPONENT_FORM;
+ *pServices++ = FRM_SUN_COMPONENT_HTMLFORM;
+ *pServices++ = FRM_SUN_COMPONENT_DATAFORM;
+
+ return aServices;
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ODatabaseForm::getSupportedServiceNames_Static()
+{
+ return ::comphelper::concatSequences(
+ getCurrentServiceNames_Static(),
+ getCompatibleServiceNames_Static()
+ );
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseForm::getImplementationName() throw( RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ODatabaseForm::getSupportedServiceNames() throw( RuntimeException )
+{
+ // the services of our aggregate
+ Sequence< ::rtl::OUString > aServices;
+ Reference< XServiceInfo > xInfo;
if (query_aggregation(m_xAggregate, xInfo))
aServices = xInfo->getSupportedServiceNames();
- sal_Int32 nOldLen = aServices.getLength();
- aServices.realloc(nOldLen + 6);
- ::rtl::OUString* pAdditionalServices = aServices.getArray() + nOldLen;
- *pAdditionalServices++ = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponent");
- *pAdditionalServices++ = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponents");
- *pAdditionalServices++ = FRM_SUN_COMPONENT_FORM;
- *pAdditionalServices++ = FRM_SUN_COMPONENT_HTMLFORM;
- *pAdditionalServices++ = FRM_SUN_COMPONENT_DATAFORM;
- return aServices;
+ // concat with out own services
+ return ::comphelper::concatSequences(
+ getCurrentServiceNames_Static(),
+ aServices
+ );
+ // use getCurrentXXX instead of getSupportedXXX, because at runtime, we do not want to have
+ // the compatible names
+ // This is maily to be consistent with the implementation before fixing #97083#, though the
+ // better solution _may_ be to return the compatible names at runtime, too
+ // 04.03.2002 - fs@openoffice.org
}
//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::supportsService(const ::rtl::OUString& ServiceName) throw( RuntimeException )
{
- StringSequence aSupported(getSupportedServiceNames());
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
const ::rtl::OUString* pArray = aSupported.getConstArray();
for( sal_Int32 i = 0; i < aSupported.getLength(); ++i, ++pArray )
if( pArray->equals(ServiceName) )
diff --git a/forms/source/component/DatabaseForm.hxx b/forms/source/component/DatabaseForm.hxx
index e04b1ecebb2b..bb9b397f1c81 100644
--- a/forms/source/component/DatabaseForm.hxx
+++ b/forms/source/component/DatabaseForm.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DatabaseForm.hxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: fs $ $Date: 2001-10-22 15:25:58 $
+ * last change: $Author: fs $ $Date: 2002-03-04 14:01:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -282,8 +282,8 @@ class ODatabaseForm :public OFormComponents
::osl::Mutex m_aResetSafety;
::com::sun::star::uno::Any m_aCycle;
::com::sun::star::uno::Any m_aIgnoreResult; // set when we are a subform and our master form positioned on a new row
- StringSequence m_aMasterFields;
- StringSequence m_aDetailFields;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aMasterFields;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aDetailFields;
::std::vector<bool> m_aParameterVisited;
// the object doin' most of the work - an SDB-rowset
@@ -475,7 +475,14 @@ public:
// com::sun::star::lang::XServiceInfo
virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw(::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
- virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // com::sun::star::lang::XServiceInfo - static version
+ static ::rtl::OUString SAL_CALL getImplementationName_Static();
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static();
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getCurrentServiceNames_Static();
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getCompatibleServiceNames_Static();
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODatabaseForm::Create( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory );
// com::sun::star::io::XPersistObject
virtual ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException);
diff --git a/forms/source/misc/services.cxx b/forms/source/misc/services.cxx
index 5bed07b736ec..a5d51803386f 100644
--- a/forms/source/misc/services.cxx
+++ b/forms/source/misc/services.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: services.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: fs $ $Date: 2001-07-23 06:26:58 $
+ * last change: $Author: fs $ $Date: 2002-03-04 13:57:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,12 +62,19 @@
#ifndef _FRM_SERVICES_HXX_
#include "services.hxx"
#endif
+#ifndef FORMS_MODULE_HXX
+#include "formsmodule.hxx"
+#endif
//... namespace frm .......................................................
namespace frm
{
//.........................................................................
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
IMPLEMENT_CONSTASCII_USTRING(AWT_CONTROL_TEXTFIELD, "com.sun.star.awt.TextField");
IMPLEMENT_CONSTASCII_USTRING(VCL_CONTROL_EDIT, "stardiv.vcl.control.Edit");
@@ -199,7 +206,6 @@ IMPLEMENT_CONSTASCII_USTRING(FRM_SUN_CONTROL_FORMATTEDFIELD, "com.sun.star.form.
IMPLEMENT_CONSTASCII_USTRING(FRM_SUN_FORMS_COLLECTION, "com.sun.star.form.Forms");
-IMPLEMENT_CONSTASCII_USTRING(FRM_DATA_ENGINE, "com.sun.star.data.DatabaseEngine");
IMPLEMENT_CONSTASCII_USTRING(FRM_NUMBER_FORMATTER, "com.sun.star.util.NumberFormatter");
IMPLEMENT_CONSTASCII_USTRING(FRM_NUMBER_FORMATS_SUPPLIER, "com.sun.star.util.NumberFormatsSupplier");
@@ -234,7 +240,7 @@ namespace starlang = ::com::sun::star::lang;
//.......................................................................................
#define DECLARE_SERVICE_INFO(classImplName) \
namespace frm { \
- extern staruno::Reference<staruno::XInterface> SAL_CALL classImplName##_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (staruno::RuntimeException); \
+ extern Reference<XInterface> SAL_CALL classImplName##_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory) throw (RuntimeException); \
}
//---------------------------------------------------------------------------------------
@@ -281,24 +287,23 @@ DECLARE_SERVICE_INFO(OFormattedFieldWrapper);
// the object was instantiated and the stream contains a FormattedModel, it switches permanently to
// formatted.)
namespace frm { \
- extern staruno::Reference<staruno::XInterface> SAL_CALL OFormattedFieldWrapper_CreateInstance_ForceFormatted(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (staruno::RuntimeException); \
+ extern Reference<XInterface> SAL_CALL OFormattedFieldWrapper_CreateInstance_ForceFormatted(const Reference<XMultiServiceFactory>& _rxFactory) throw (RuntimeException); \
}
DECLARE_SERVICE_INFO(OFormsCollection)
-DECLARE_SERVICE_INFO(ODatabaseForm)
//---------------------------------------------------------------------------------------
-static staruno::Sequence< ::rtl::OUString > s_aClassImplementationNames;
-static staruno::Sequence<staruno::Sequence< ::rtl::OUString > > s_aClassServiceNames;
-static staruno::Sequence<sal_Int64> s_aFactories;
+static Sequence< ::rtl::OUString > s_aClassImplementationNames;
+static Sequence<Sequence< ::rtl::OUString > > s_aClassServiceNames;
+static Sequence<sal_Int64> s_aFactories;
// need to use sal_Int64 instead of ComponentInstantiation, as ComponentInstantiation has no cppuType, so
// it can't be used with sequences
//---------------------------------------------------------------------------------------
void registerClassInfo(
::rtl::OUString _rClassImplName, // the ImplName of the class
- const staruno::Sequence< ::rtl::OUString >& _rServiceNames, // the services supported by this class
+ const Sequence< ::rtl::OUString >& _rServiceNames, // the services supported by this class
::cppu::ComponentInstantiation _pCreateFunction // the method for instantiating such a class
)
{
@@ -360,7 +365,7 @@ void ensureClassInfos()
if (s_aClassImplementationNames.getLength())
// nothing to do
return;
- staruno::Sequence< ::rtl::OUString > aServices;
+ Sequence< ::rtl::OUString > aServices;
// ========================================================================
// = ControlModels
@@ -454,17 +459,15 @@ void ensureClassInfos()
// ========================================================================
// = various
REGISTER_CLASS1(OFormsCollection, FRM_SUN_FORMS_COLLECTION);
- REGISTER_CLASS4(ODatabaseForm, FRM_COMPONENT_FORM, FRM_SUN_COMPONENT_FORM, FRM_SUN_COMPONENT_HTMLFORM, FRM_SUN_COMPONENT_DATAFORM);
-
}
//---------------------------------------------------------------------------------------
-void registerServiceProvider(const ::rtl::OUString& _rServiceImplName, const staruno::Sequence< ::rtl::OUString >& _rServices, starregistry::XRegistryKey* _pKey)
+void registerServiceProvider(const ::rtl::OUString& _rServiceImplName, const Sequence< ::rtl::OUString >& _rServices, starregistry::XRegistryKey* _pKey)
{
::rtl::OUString sMainKeyName = ::rtl::OUString::createFromAscii("/");
sMainKeyName += _rServiceImplName;
sMainKeyName += ::rtl::OUString::createFromAscii("/UNO/SERVICES");
- staruno::Reference<starregistry::XRegistryKey> xNewKey = _pKey->createKey(sMainKeyName);
+ Reference<starregistry::XRegistryKey> xNewKey = _pKey->createKey(sMainKeyName);
OSL_ENSURE(xNewKey.is(), "forms::registerProvider : could not create a registry key !");
if (!xNewKey.is())
return;
@@ -479,6 +482,20 @@ extern "C"
{
//---------------------------------------------------------------------------------------
+void SAL_CALL createRegistryInfo_ODatabaseForm();
+
+//---------------------------------------------------------------------------------------
+void SAL_CALL createRegistryInfo_FORMS()
+{
+ static sal_Bool bInit = sal_False;
+ if (!bInit)
+ {
+ createRegistryInfo_ODatabaseForm();
+ bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
void SAL_CALL component_getImplementationEnvironment(const sal_Char** _ppEnvTypeName, uno_Environment** _ppEnv)
{
*_ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
@@ -491,6 +508,18 @@ sal_Bool SAL_CALL component_writeInfo(void* _pServiceManager, starregistry::XReg
{
try
{
+ //
+ // the real way - use the OModule
+ createRegistryInfo_FORMS();
+ if ( !::frm::OFormsModule::writeComponentInfos(
+ static_cast<XMultiServiceFactory*>( _pServiceManager ),
+ static_cast<XRegistryKey*>( _pRegistryKey ) )
+ )
+ return sal_False;
+
+ //
+ // a lot of stuff which is implemented "manually" here in this file
+
// collect the class infos
ensureClassInfos();
@@ -501,7 +530,7 @@ sal_Bool SAL_CALL component_writeInfo(void* _pServiceManager, starregistry::XReg
// loop through the sequences and register the service providers
const ::rtl::OUString* pClasses = s_aClassImplementationNames.getConstArray();
- const staruno::Sequence< ::rtl::OUString >* pServices = s_aClassServiceNames.getConstArray();
+ const Sequence< ::rtl::OUString >* pServices = s_aClassServiceNames.getConstArray();
for (sal_Int32 i=0; i<nClasses; ++i, ++pClasses, ++pServices)
registerServiceProvider(*pClasses, *pServices, _pRegistryKey);
@@ -509,6 +538,7 @@ sal_Bool SAL_CALL component_writeInfo(void* _pServiceManager, starregistry::XReg
s_aClassImplementationNames.realloc(0);
s_aClassServiceNames.realloc(0);
s_aFactories.realloc(0);
+
return sal_True;
}
catch (starregistry::InvalidRegistryException &)
@@ -523,11 +553,13 @@ sal_Bool SAL_CALL component_writeInfo(void* _pServiceManager, starregistry::XReg
}
//---------------------------------------------------------------------------------------
-void* SAL_CALL component_getFactory(const sal_Char* _pImplName, starlang::XMultiServiceFactory* _pServiceManager, void* /*_pRegistryKey*/)
+void* SAL_CALL component_getFactory(const sal_Char* _pImplName, XMultiServiceFactory* _pServiceManager, void* /*_pRegistryKey*/)
{
- if (!_pServiceManager)
+ if (!_pServiceManager || !_pImplName)
return NULL;
+ //
+ // a lot of stuff which is implemented "manually" here in this file
void* pRet = NULL;
// collect the class infos
@@ -541,7 +573,7 @@ void* SAL_CALL component_getFactory(const sal_Char* _pImplName, starlang::XMulti
// loop through the sequences and register the service providers
const ::rtl::OUString* pClasses = s_aClassImplementationNames.getConstArray();
- const staruno::Sequence< ::rtl::OUString >* pServices = s_aClassServiceNames.getConstArray();
+ const Sequence< ::rtl::OUString >* pServices = s_aClassServiceNames.getConstArray();
const sal_Int64* pFunctionsAsInts = s_aFactories.getConstArray();
for (sal_Int32 i=0; i<nClasses; ++i, ++pClasses, ++pServices, ++pFunctionsAsInts)
@@ -551,7 +583,7 @@ void* SAL_CALL component_getFactory(const sal_Char* _pImplName, starlang::XMulti
::cppu::ComponentInstantiation aCurrentCreateFunction =
reinterpret_cast< ::cppu::ComponentInstantiation>(*pFunctionsAsInts);
- staruno::Reference<starlang::XSingleServiceFactory> xFactory(
+ Reference<XSingleServiceFactory> xFactory(
::cppu::createSingleFactory(
_pServiceManager,
*pClasses,
@@ -568,8 +600,25 @@ void* SAL_CALL component_getFactory(const sal_Char* _pImplName, starlang::XMulti
}
}
+ //
+ // the real way - use the OModule
+ if ( !pRet )
+ {
+ createRegistryInfo_FORMS();
+ {
+ // let the module look for the component
+ Reference< XInterface > xRet;
+ xRet = ::frm::OFormsModule::getComponentFactory(
+ ::rtl::OUString::createFromAscii( _pImplName ),
+ static_cast< XMultiServiceFactory* >( _pServiceManager ) );
+
+ if ( xRet.is() )
+ xRet->acquire();
+ pRet = xRet.get();
+ }
+ }
+
return pRet;
}
}
-