summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
Diffstat (limited to 'basic')
-rw-r--r--basic/source/classes/codecompletecache.cxx83
-rw-r--r--basic/source/classes/sbxmod.cxx8
-rw-r--r--basic/source/comp/dim.cxx31
3 files changed, 86 insertions, 36 deletions
diff --git a/basic/source/classes/codecompletecache.cxx b/basic/source/classes/codecompletecache.cxx
index 71de600c0af0..ee5bd08d703e 100644
--- a/basic/source/classes/codecompletecache.cxx
+++ b/basic/source/classes/codecompletecache.cxx
@@ -21,6 +21,22 @@
#include <iostream>
#include <rtl/instance.hxx>
#include <officecfg/Office/BasicIDE.hxx>
+#include "com/sun/star/reflection/XIdlReflection.hpp"
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/configurationhelper.hxx>
+#include "com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp"
+#include "com/sun/star/reflection/XIdlMethod.hpp"
+#include "com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp"
+#include "com/sun/star/reflection/XTypeDescription.hpp"
+#include "com/sun/star/reflection/TypeDescriptionSearchDepth.hpp"
+#include "com/sun/star/uno/Exception.hpp"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/TypeClass.hpp"
+#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
namespace
{
@@ -97,21 +113,70 @@ void CodeCompleteOptions::SetAutoCorrectOn( const bool& b )
theCodeCompleteOptions::get().bIsAutoCorrectOn = b;
}
-OUString CodeCompleteOptions::AddUnoPrefix( const OUString& sTypeName )
+OUString CodeCompleteOptions::GetUnoType( const OUString& sTypeName )
{
+ //returns the fully qualified UNO type name if exsists, else empty string
OUString sNewTypeName = sTypeName;
if( sNewTypeName.toAsciiLowerCase().startsWith("css.") )
- {//enables shorthand "css" instead of "com.sun.star"
- sNewTypeName = sNewTypeName.replaceFirst("css","com.sun.star");
- }
- else
+ //enables shorthand "css" instead of "com.sun.star"
+ sNewTypeName = sNewTypeName.replaceFirst("css.","");
+ //if "com.sun.star" or any of it left out, add it
+ else if( sNewTypeName.toAsciiLowerCase().startsWith("com.sun.star.") )
+ sNewTypeName = sNewTypeName.replaceFirst("com.sun.star.","");
+
+ else if( sNewTypeName.toAsciiLowerCase().startsWith("sun.star.") )
+ sNewTypeName = sNewTypeName.replaceFirst("sun.star.","");
+
+ else if( sNewTypeName.toAsciiLowerCase().startsWith("star.") )
+ sNewTypeName = sNewTypeName.replaceFirst("star.","");
+
+ try
{
- if( !sNewTypeName.toAsciiLowerCase().startsWith("com.sun.star.") )
- {//if "com.sun.star" left out, add it
- sNewTypeName = OUString("com.sun.star.") + sTypeName;
+ Reference< container::XHierarchicalNameAccess > xAccess;
+ Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
+ if( xContext.is() )
+ {
+ xContext->getValueByName(
+ OUString( "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) )
+ >>= xAccess;
+ OSL_ENSURE( xAccess.is(), "### TypeDescriptionManager singleton not accessible!?" );
}
+ if( xAccess.is() )
+ {
+ uno::Sequence< uno::TypeClass > aParams(3);
+ aParams[0] = uno::TypeClass_INTERFACE;
+ aParams[1] = uno::TypeClass_STRUCT;
+ aParams[2] = uno::TypeClass_ENUM;
+ Reference< reflection::XTypeDescriptionEnumeration > sxEnum;
+ Reference< reflection::XTypeDescriptionEnumerationAccess> xTypeEnumAccess( xAccess, UNO_QUERY );
+ if ( xTypeEnumAccess.is() )
+ {
+ try
+ {
+ sxEnum = xTypeEnumAccess->createTypeDescriptionEnumeration(
+ "com.sun.star", aParams, reflection::TypeDescriptionSearchDepth_INFINITE );
+
+ Reference< reflection::XTypeDescription > xDesc = sxEnum->nextTypeDescription();
+ //check the modules
+ while( sxEnum->hasMoreElements() )
+ {
+ if( xDesc->getName().endsWithIgnoreAsciiCase(sNewTypeName) )
+ {
+ return xDesc->getName();
+ }
+
+ xDesc = sxEnum->nextTypeDescription();
+ }
+ }
+ catch( const Exception& ex ) { return OUString(""); }
+ }
+ }
+ }
+ catch( const Exception& ex )
+ {
+ OSL_FAIL("Could not create com.sun.star.reflection.TypeDescriptionManager");
}
- return sNewTypeName;
+ return OUString("");
}
std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache)
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index d62b4001ef77..c011d51e951d 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -1795,16 +1795,16 @@ void SbModule::GetCodeCompleteDataFromParse(CodeCompleteDataCache& aCache)
{
SbiSymDef* pSymDef = pPool->Get(i);
//std::cerr << "i: " << i << ", type: " << pSymDef->GetType() << "; name:" << pSymDef->GetName() << std::endl;
- if( (pSymDef->GetType() != SbxEMPTY) || (pSymDef->GetType() != SbxNULL) )
- aCache.InsertGlobalVar( pSymDef->GetName(), CodeCompleteOptions::AddUnoPrefix(pParser->aGblStrings.Find(pSymDef->GetTypeId())) );
+ if( ((pSymDef->GetType() != SbxEMPTY) || (pSymDef->GetType() != SbxNULL))/* && !CodeCompleteOptions::GetUnoType(pParser->aGblStrings.Find(pSymDef->GetTypeId())).isEmpty() */)
+ aCache.InsertGlobalVar( pSymDef->GetName(), CodeCompleteOptions::GetUnoType(pParser->aGblStrings.Find(pSymDef->GetTypeId())) );
SbiSymPool& pChildPool = pSymDef->GetPool();
for(sal_uInt16 j = 0; j < pChildPool.GetSize(); ++j )
{
SbiSymDef* pChildSymDef = pChildPool.Get(j);
//std::cerr << "j: " << j << ", type: " << pChildSymDef->GetType() << "; name:" << pChildSymDef->GetName() << std::endl;
- if( (pChildSymDef->GetType() != SbxEMPTY) || (pChildSymDef->GetType() != SbxNULL) )
- aCache.InsertLocalVar( pSymDef->GetName(), pChildSymDef->GetName(), CodeCompleteOptions::AddUnoPrefix(pParser->aGblStrings.Find(pChildSymDef->GetTypeId())) );
+ if( ((pChildSymDef->GetType() != SbxEMPTY) || (pChildSymDef->GetType() != SbxNULL))/* && !CodeCompleteOptions::GetUnoType(pParser->aGblStrings.Find(pSymDef->GetTypeId())).isEmpty() */)
+ aCache.InsertLocalVar( pSymDef->GetName(), pChildSymDef->GetName(), CodeCompleteOptions::GetUnoType(pParser->aGblStrings.Find(pChildSymDef->GetTypeId())) );
}
}
delete pParser;
diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx
index c2139196310d..baa6ebcd151d 100644
--- a/basic/source/comp/dim.cxx
+++ b/basic/source/comp/dim.cxx
@@ -21,13 +21,19 @@
#include "sbcomp.hxx"
#include "sbunoobj.hxx"
#include <svtools/miscopt.hxx>
-#include "com/sun/star/reflection/XIdlReflection.hpp"
+/*#include "com/sun/star/reflection/XIdlReflection.hpp"
#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/configurationhelper.hxx>
#include "com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp"
#include "com/sun/star/reflection/XIdlMethod.hpp"
+#include "com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp"
+#include "com/sun/star/reflection/XTypeDescription.hpp"
+#include "com/sun/star/reflection/TypeDescriptionSearchDepth.hpp"
#include "com/sun/star/uno/Exception.hpp"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/TypeClass.hpp"
+#include "com/sun/star/container/XHierarchicalNameAccess.hpp"*/
#include <basic/codecompletecache.hxx>
#include <iostream>
@@ -1334,28 +1340,7 @@ void SbiParser::DefStatic( bool bPrivate )
bool SbiParser::IsUnoInterface(const OUString& sTypeName)
{
- OUString sNewTypeName = CodeCompleteOptions::AddUnoPrefix( sTypeName );
- try
- {
- Reference< lang::XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), UNO_SET_THROW );
- Reference< reflection::XIdlReflection > xRefl( xFactory->createInstance("com.sun.star.reflection.CoreReflection"), UNO_QUERY_THROW );
- //DBG_ASSERT(xRefl.Is(), "No reflection class!"); ???
- if( !xRefl.is() )
- {
- return false;
- }
- Reference< reflection::XIdlClass > xClass = xRefl->forName(sNewTypeName);
- if( xClass != NULL )
- {
- return true;
- }
- return false;
- }
- catch( const Exception& ex )
- {
- OSL_FAIL("Could not create reflection.CoreReflection.");
- }
- return false;
+ return !CodeCompleteOptions::GetUnoType( sTypeName ).isEmpty();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */