summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authornpower Developer <npower@openoffice.org>2010-04-08 16:44:03 +0100
committernpower Developer <npower@openoffice.org>2010-04-08 16:44:03 +0100
commitec5477e395c58fbb2bdb2a3ea993e12a286d0aa3 (patch)
tree27a55199f56f2984278fe9cd27d18536924d9a08 /basic
parent708b462a826eef5634275fa0400ec003c310619f (diff)
parent6b9635f6b2d62537052bdc11ec84247d3bc72832 (diff)
npower13_objectmodule: merge heads ( from merge to DEV300_m75 )
Diffstat (limited to 'basic')
-rw-r--r--basic/source/app/app.cxx35
-rwxr-xr-x[-rw-r--r--]basic/source/classes/sbunoobj.cxx97
-rw-r--r--basic/source/inc/sbunoobj.hxx18
-rw-r--r--basic/source/runtime/wnt-mingw.s46
4 files changed, 138 insertions, 58 deletions
diff --git a/basic/source/app/app.cxx b/basic/source/app/app.cxx
index f0cd1ed3f751..fd613a81673f 100644
--- a/basic/source/app/app.cxx
+++ b/basic/source/app/app.cxx
@@ -191,41 +191,6 @@ BOOL IsTTSignatureForUnicodeTextfile( String aLine )
BasicApp aBasicApp; // Application instance
-static const char * const components[] =
-{
- SAL_MODULENAME( "ucb1" ) // KSO, ABI
- , SAL_MODULENAME( "ucpfile1" )
- , "configmgr2.uno" SAL_DLLEXTENSION
- , "sax.uno" SAL_DLLEXTENSION
- , "stocservices.uno" SAL_DLLEXTENSION
- , SAL_MODULENAME( "fileacc" )
- , SAL_MODULENAME( "mcnttype" ) // Clipboard Ask Oliver Braun
- , "i18npool.uno" SAL_DLLEXTENSION
- // Reading of files in specific encodings like UTF-8 using
- // createUnoService( "com.sun.star.io.TextInputStream" ) and such
- , "textinstream.uno" SAL_DLLEXTENSION
- , "textoutstream.uno" SAL_DLLEXTENSION
- , "introspection.uno" SAL_DLLEXTENSION
- , "reflection.uno" SAL_DLLEXTENSION
- // RemoteUno
- , "connector.uno" SAL_DLLEXTENSION
- , "bridgefac.uno" SAL_DLLEXTENSION
- , "remotebridge.uno" SAL_DLLEXTENSION
-#ifdef SAL_UNX
-#ifdef QUARTZ
- , SVLIBRARY( "dtransaqua" ) // Mac OS X Aqua uses a dedicated libdtransaqua
-#else
- , SVLIBRARY( "dtransX11" ) // OBR
-#endif
-#endif
-#ifdef SAL_W32
- , SAL_MODULENAME( "sysdtrans" )
- , SAL_MODULENAME( "ftransl" )
- , SAL_MODULENAME( "dnd" )
-#endif
- , 0
-};
-
uno::Reference< XContentProviderManager > InitializeUCB( void )
{
uno::Reference< XMultiServiceFactory > xSMgr;
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index ba54fabd3a3c..1e278bf583a7 100644..100755
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -103,6 +103,7 @@ TYPEINIT1(SbUnoObject,SbxObject)
TYPEINIT1(SbUnoClass,SbxObject)
TYPEINIT1(SbUnoService,SbxObject)
TYPEINIT1(SbUnoServiceCtor,SbxMethod)
+TYPEINIT1(SbUnoSingleton,SbxObject)
typedef WeakImplHelper1< XAllListener > BasicAllListenerHelper;
@@ -3299,6 +3300,18 @@ SbxVariable* SbUnoClass::Find( const XubString& rName, SbxClassType t )
pRes->PutObject( xWrapper );
}
}
+
+ // An UNO singleton?
+ if( !pRes )
+ {
+ SbUnoSingleton* pUnoSingleton = findUnoSingleton( aNewName );
+ if( pUnoSingleton )
+ {
+ pRes = new SbxVariable( SbxVARIANT );
+ SbxObjectRef xWrapper = (SbxObject*)pUnoSingleton;
+ pRes->PutObject( xWrapper );
+ }
+ }
}
}
@@ -3579,6 +3592,90 @@ SbxInfo* SbUnoServiceCtor::GetInfo()
}
+SbUnoSingleton* findUnoSingleton( const String& rName )
+{
+ SbUnoSingleton* pSbUnoSingleton = NULL;
+
+ Reference< XHierarchicalNameAccess > xTypeAccess = getTypeProvider_Impl();
+ if( xTypeAccess->hasByHierarchicalName( rName ) )
+ {
+ Any aRet = xTypeAccess->getByHierarchicalName( rName );
+ Reference< XTypeDescription > xTypeDesc;
+ aRet >>= xTypeDesc;
+
+ if( xTypeDesc.is() )
+ {
+ TypeClass eTypeClass = xTypeDesc->getTypeClass();
+ if( eTypeClass == TypeClass_SINGLETON )
+ {
+ Reference< XSingletonTypeDescription > xSingletonTypeDesc( xTypeDesc, UNO_QUERY );
+ if( xSingletonTypeDesc.is() )
+ pSbUnoSingleton = new SbUnoSingleton( rName, xSingletonTypeDesc );
+ }
+ }
+ }
+ return pSbUnoSingleton;
+}
+
+SbUnoSingleton::SbUnoSingleton( const String& aName_,
+ const Reference< XSingletonTypeDescription >& xSingletonTypeDesc )
+ : SbxObject( aName_ )
+ , m_xSingletonTypeDesc( xSingletonTypeDesc )
+{
+ SbxVariableRef xGetMethodRef =
+ new SbxMethod( String( RTL_CONSTASCII_USTRINGPARAM( "get" ) ), SbxOBJECT );
+ QuickInsert( (SbxVariable*)xGetMethodRef );
+}
+
+void SbUnoSingleton::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
+ const SfxHint& rHint, const TypeId& rHintType )
+{
+ const SbxHint* pHint = PTR_CAST(SbxHint,&rHint);
+ if( pHint )
+ {
+ SbxVariable* pVar = pHint->GetVar();
+ SbxArray* pParams = pVar->GetParameters();
+ UINT32 nParamCount = pParams ? ((UINT32)pParams->Count() - 1) : 0;
+ UINT32 nAllowedParamCount = 1;
+
+ Reference < XComponentContext > xContextToUse;
+ if( nParamCount > 0 )
+ {
+ // Check if first parameter is a context and use it then
+ Reference < XComponentContext > xFirstParamContext;
+ Any aArg1 = sbxToUnoValue( pParams->Get( 1 ) );
+ if( (aArg1 >>= xFirstParamContext) && xFirstParamContext.is() )
+ xContextToUse = xFirstParamContext;
+ }
+
+ if( !xContextToUse.is() )
+ {
+ Reference < XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
+ xContextToUse.set( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" )) ), UNO_QUERY_THROW );
+ --nAllowedParamCount;
+ }
+
+ if( nParamCount > nAllowedParamCount )
+ {
+ StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ return;
+ }
+
+ Any aRetAny;
+ if( xContextToUse.is() )
+ {
+ String aSingletonName( RTL_CONSTASCII_USTRINGPARAM("/singletons/") );
+ aSingletonName += GetName();
+ Reference < XInterface > xRet;
+ xContextToUse->getValueByName( aSingletonName ) >>= xRet;
+ aRetAny <<= xRet;
+ }
+ unoToSbxValue( pVar, aRetAny );
+ }
+ else
+ SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
+}
+
//========================================================================
//========================================================================
diff --git a/basic/source/inc/sbunoobj.hxx b/basic/source/inc/sbunoobj.hxx
index d96edd1bc298..2d9836e3530e 100644
--- a/basic/source/inc/sbunoobj.hxx
+++ b/basic/source/inc/sbunoobj.hxx
@@ -41,6 +41,7 @@
#include <com/sun/star/script/XInvocation.hpp>
#include <com/sun/star/reflection/XIdlClass.hpp>
#include <com/sun/star/reflection/XServiceTypeDescription2.hpp>
+#include <com/sun/star/reflection/XSingletonTypeDescription.hpp>
#include <rtl/ustring.hxx>
class SbUnoObject: public SbxObject
@@ -226,6 +227,23 @@ public:
};
+// Wrapper for UNO Singleton
+class SbUnoSingleton : public SbxObject
+{
+ const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XSingletonTypeDescription > m_xSingletonTypeDesc;
+
+public:
+ TYPEINFO();
+ SbUnoSingleton( const String& aName_,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XSingletonTypeDescription >& xSingletonTypeDesc );
+
+ void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& );
+};
+SV_DECL_IMPL_REF(SbUnoSingleton);
+
+SbUnoSingleton* findUnoSingleton( const String& rName );
+
+
// #105565 Special Object to wrap a strongly typed Uno Any
class SbUnoAnyObject: public SbxObject
{
diff --git a/basic/source/runtime/wnt-mingw.s b/basic/source/runtime/wnt-mingw.s
index 878a2791c3e7..1168804102d0 100644
--- a/basic/source/runtime/wnt-mingw.s
+++ b/basic/source/runtime/wnt-mingw.s
@@ -1,28 +1,28 @@
#*************************************************************************
#
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
#*************************************************************************
# Anmerkungen