[Libreoffice-commits] core.git: Branch 'feature/gsoc-basic-ide-completion-and-other-bits' - basic/source include/basic

Gergo Mocsi gmocsi91 at gmail.com
Sun Sep 15 03:54:07 PDT 2013


 basic/source/classes/codecompletecache.cxx |   17 +++++++++++++++++
 basic/source/classes/sbxmod.cxx            |    4 ++--
 basic/source/comp/dim.cxx                  |    6 ++++--
 include/basic/codecompletecache.hxx        |    2 ++
 4 files changed, 25 insertions(+), 4 deletions(-)

New commits:
commit 9dfcb24d5ec5d38d2362297d62dec46ae02d2359
Author: Gergo Mocsi <gmocsi91 at gmail.com>
Date:   Fri Sep 13 18:02:09 2013 +0200

    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

diff --git a/basic/source/classes/codecompletecache.cxx b/basic/source/classes/codecompletecache.cxx
index aad0e4f..71de600 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 567d26f..d62b400 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 64d0565..c213919 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 e85b0d8..6dc389a 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


More information about the Libreoffice-commits mailing list