summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-09-13 18:02:09 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-09-13 18:06:46 +0200
commit9dfcb24d5ec5d38d2362297d62dec46ae02d2359 (patch)
treed754ce1a6dd8da57060b92152d84628192238b11
parentea87494f8ec7f7995dc9050a3147529b096f8f56 (diff)
GSOC work, shorthand fot "com.sun.star"
I've applied a shorthand for "com.sun.star" when using the extended types: - css.XSomething ("css" == "com.sun.star" ) - or simply leave it out (like ui.dialogs.XFilePicker instead of com.sun.star.ui.dialogs.XFilePicker) The function which does the substitution is called: CodeCompleteOptions::AddUnoPrefix(). Change-Id: Ib0b9970d9d36237aa81123a82ad0c04c0af91a03
-rw-r--r--basic/source/classes/codecompletecache.cxx17
-rw-r--r--basic/source/classes/sbxmod.cxx4
-rw-r--r--basic/source/comp/dim.cxx6
-rw-r--r--include/basic/codecompletecache.hxx2
4 files changed, 25 insertions, 4 deletions
diff --git a/basic/source/classes/codecompletecache.cxx b/basic/source/classes/codecompletecache.cxx
index aad0e4fcd622..71de600c0af0 100644
--- a/basic/source/classes/codecompletecache.cxx
+++ b/basic/source/classes/codecompletecache.cxx
@@ -97,6 +97,23 @@ void CodeCompleteOptions::SetAutoCorrectOn( const bool& b )
theCodeCompleteOptions::get().bIsAutoCorrectOn = b;
}
+OUString CodeCompleteOptions::AddUnoPrefix( const OUString& sTypeName )
+{
+ OUString sNewTypeName = sTypeName;
+ if( sNewTypeName.toAsciiLowerCase().startsWith("css.") )
+ {//enables shorthand "css" instead of "com.sun.star"
+ sNewTypeName = sNewTypeName.replaceFirst("css","com.sun.star");
+ }
+ else
+ {
+ if( !sNewTypeName.toAsciiLowerCase().startsWith("com.sun.star.") )
+ {//if "com.sun.star" left out, add it
+ sNewTypeName = OUString("com.sun.star.") + sTypeName;
+ }
+ }
+ return sNewTypeName;
+}
+
std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache)
{
aStream << "Global variables" << std::endl;
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 567d26fa0993..d62b4001ef77 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -1796,7 +1796,7 @@ 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(), pParser->aGblStrings.Find(pSymDef->GetTypeId()) );
+ aCache.InsertGlobalVar( pSymDef->GetName(), CodeCompleteOptions::AddUnoPrefix(pParser->aGblStrings.Find(pSymDef->GetTypeId())) );
SbiSymPool& pChildPool = pSymDef->GetPool();
for(sal_uInt16 j = 0; j < pChildPool.GetSize(); ++j )
@@ -1804,7 +1804,7 @@ void SbModule::GetCodeCompleteDataFromParse(CodeCompleteDataCache& aCache)
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(), pParser->aGblStrings.Find(pChildSymDef->GetTypeId()) );
+ aCache.InsertLocalVar( pSymDef->GetName(), pChildSymDef->GetName(), CodeCompleteOptions::AddUnoPrefix(pParser->aGblStrings.Find(pChildSymDef->GetTypeId())) );
}
}
delete pParser;
diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx
index 64d056534c8f..c2139196310d 100644
--- a/basic/source/comp/dim.cxx
+++ b/basic/source/comp/dim.cxx
@@ -29,6 +29,7 @@
#include "com/sun/star/reflection/XIdlMethod.hpp"
#include "com/sun/star/uno/Exception.hpp"
#include <basic/codecompletecache.hxx>
+#include <iostream>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -1333,6 +1334,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 );
@@ -1342,14 +1344,14 @@ bool SbiParser::IsUnoInterface(const OUString& sTypeName)
{
return false;
}
- Reference< reflection::XIdlClass > xClass = xRefl->forName(sTypeName);
+ Reference< reflection::XIdlClass > xClass = xRefl->forName(sNewTypeName);
if( xClass != NULL )
{
return true;
}
return false;
}
- catch(const Exception& ex)
+ catch( const Exception& ex )
{
OSL_FAIL("Could not create reflection.CoreReflection.");
}
diff --git a/include/basic/codecompletecache.hxx b/include/basic/codecompletecache.hxx
index e85b0d8b599c..6dc389ad9d67 100644
--- a/include/basic/codecompletecache.hxx
+++ b/include/basic/codecompletecache.hxx
@@ -69,6 +69,8 @@ public:
static bool IsAutoCorrectOn();
static void SetAutoCorrectOn( const bool& b );
+
+ static OUString AddUnoPrefix( const OUString& sTypeName );
};
class BASIC_DLLPUBLIC CodeCompleteDataCache