basctl/sdi/baside.sdi | 13 ++++++----- basctl/source/basicide/baside2.cxx | 20 +++++++++++++++++- basctl/source/basicide/baside2b.cxx | 20 ++++++++++-------- basic/source/classes/codecompletecache.cxx | 32 +++++++++++++++++++++++++++++ basic/source/classes/sbxmod.cxx | 1 basic/source/comp/dim.cxx | 16 +++++++++++--- basic/source/inc/codegen.hxx | 1 include/basic/codecompletecache.hxx | 21 ++++++++++++++++++- 8 files changed, 104 insertions(+), 20 deletions(-)
New commits: commit 93c8f072caddd6434558aa11cdd7e981c3d1030a Author: Gergo Mocsi <gmocs...@gmail.com> Date: Tue Jul 23 12:42:37 2013 +0200 GSOC work, code complete option, menu entry fixes Menu entry is added under View->Enable Code Completition when in Experimental mode. Fixed the call of funtion SbModule::GetCodeCompleteDataFromParse() to be called only when code completition is enabled. Replaced the occurences of SvtMiscOptions to CodeCompleteOptions. Change-Id: If0520123ab5f612d7d24fb98f8e9bf6881af76cb diff --git a/basctl/sdi/baside.sdi b/basctl/sdi/baside.sdi index 7dfe68a..42873f6 100644 --- a/basctl/sdi/baside.sdi +++ b/basctl/sdi/baside.sdi @@ -35,6 +35,13 @@ shell basctl_Shell StateMethod = GetState; ExecMethod = ExecuteCurrent; ] + + SID_BASICIDE_CODECOMPLETITION + [ + StateMethod = GetState; + ExecMethod = ExecuteCurrent; + ] + SID_BASICIDE_HIDECURPAGE [ ExecMethod = ExecuteCurrent; @@ -138,12 +145,6 @@ shell basctl_Shell StateMethod = GetState; ] - SID_BASICIDE_CODECOMPLETITION - [ - ExecMethod = ExecuteCurrent; - StateMethod = GetState; - ] - SID_BASICIDE_LIBSELECTED [ ExecMethod = ExecuteGlobal; diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 4fc6674..1fff14a 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -52,6 +52,8 @@ #include <toolkit/helper/vclunohelper.hxx> #include <vcl/msgbox.hxx> #include <cassert> +#include <basic/codecompletecache.hxx> +#include <svtools/miscopt.hxx> namespace basctl { @@ -1011,7 +1013,8 @@ void ModulWindow::ExecuteCommand (SfxRequest& rReq) break; case SID_BASICIDE_CODECOMPLETITION: { - std::cerr << "code completition enabled" << std::endl; + SFX_REQUEST_ARG(rReq, pItem, SfxBoolItem, rReq.GetSlot(), false); + CodeCompleteOptions::SetCodeCompleteOn( pItem && pItem->GetValue() ); } break; case SID_CUT: @@ -1160,6 +1163,21 @@ void ModulWindow::GetState( SfxItemSet &rSet ) rSet.Put(SfxBoolItem(nWh, bSourceLinesEnabled)); break; } + case SID_BASICIDE_CODECOMPLETITION: + { + SvtMiscOptions aMiscOptions; + if( aMiscOptions.IsExperimentalMode() ) + { + rSet.Put(SfxBoolItem( nWh, CodeCompleteOptions::IsCodeCompleteOn() )); + std::cerr <<"code complete set to: " << CodeCompleteOptions::IsCodeCompleteOn() << std::endl; + } + else + { + rSet.Put( SfxVisibilityItem(nWh, false) ); + //CodeCompleteOptions::SetCodeCompleteOn( false ); + } + } + break; } } } diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 0dddf7f..8c5f6212 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -48,7 +48,6 @@ #include <vcl/help.hxx> #include <vector> -#include <svtools/miscopt.hxx> #include "com/sun/star/reflection/XIdlReflection.hpp" #include <comphelper/namedvaluecollection.hxx> #include <comphelper/processfactory.hxx> @@ -486,7 +485,6 @@ bool EditorWindow::ImpCanModify() void EditorWindow::KeyInput( const KeyEvent& rKEvt ) { - SvtMiscOptions aMiscOptions; if ( !pEditView ) // Happens in Win95 return; @@ -501,7 +499,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) // see if there is an accelerator to be processed first bool bDone = SfxViewShell::Current()->KeyInput( rKEvt ); - if( rKEvt.GetKeyCode().GetCode() == KEY_POINT && aMiscOptions.IsExperimentalMode() ) + if( rKEvt.GetKeyCode().GetCode() == KEY_POINT && CodeCompleteOptions::IsCodeCompleteOn() ) { rModulWindow.UpdateModule(); TextSelection aSel = GetEditView()->GetSelection(); @@ -829,14 +827,20 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { ParagraphInsertedDeleted( rTextHint.GetValue(), true ); DoDelayedSyntaxHighlight( rTextHint.GetValue() ); - rModulWindow.UpdateModule(); - aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars()); + if( CodeCompleteOptions::IsCodeCompleteOn() ) + { + rModulWindow.UpdateModule(); + aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars()); + } } else if( rTextHint.GetId() == TEXT_HINT_PARAREMOVED ) { ParagraphInsertedDeleted( rTextHint.GetValue(), false ); - rModulWindow.UpdateModule(); - aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars()); + if( CodeCompleteOptions::IsCodeCompleteOn() ) + { + rModulWindow.UpdateModule(); + aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars()); + } } else if( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED ) { @@ -850,7 +854,7 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) pBindings->Invalidate( SID_COPY ); } } - else if( rTextHint.GetId() == TEXT_HINT_MODIFIED ) + else if( rTextHint.GetId() == TEXT_HINT_MODIFIED && CodeCompleteOptions::IsCodeCompleteOn() ) { rModulWindow.UpdateModule(); aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars()); diff --git a/basic/source/classes/codecompletecache.cxx b/basic/source/classes/codecompletecache.cxx index 6281133..77a0204 100644 --- a/basic/source/classes/codecompletecache.cxx +++ b/basic/source/classes/codecompletecache.cxx @@ -19,10 +19,42 @@ #include <basic/codecompletecache.hxx> #include <iostream> +#include <rtl/instance.hxx> const OUString CodeCompleteDataCache::GLOB_KEY = OUString("global key"); const OUString CodeCompleteDataCache::NOT_FOUND = OUString("not found"); +namespace +{ + class theCodeCompleteOptions: public ::rtl::Static< CodeCompleteOptions, theCodeCompleteOptions >{}; +} + +CodeCompleteOptions::CodeCompleteOptions() +: bIsCodeCompleteOn( false ) +{ +} + +bool CodeCompleteOptions::IsCodeCompleteOn() +{ + /*if( !theCodeCompleteOptions::get().aMiscOptions.IsExperimentalMode() ) + return false; + else*/ + return theCodeCompleteOptions::get().aMiscOptions.IsExperimentalMode() && theCodeCompleteOptions::get().bIsCodeCompleteOn; +} + +void CodeCompleteOptions::SetCodeCompleteOn( const bool& b ) +{ + if( !theCodeCompleteOptions::get().aMiscOptions.IsExperimentalMode() ) + theCodeCompleteOptions::get().bIsCodeCompleteOn = false; + else + theCodeCompleteOptions::get().bIsCodeCompleteOn = b; +} + +bool CodeCompleteOptions::IsExtendedTypeDeclaration() +{ + return CodeCompleteOptions::IsCodeCompleteOn(); +} + std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache) { for( CodeCompleteVarScopes::const_iterator aIt = aCache.aVarScopes.begin(); aIt != aCache.aVarScopes.end(); ++aIt ) diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index f09291d..8182f6e 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -1783,7 +1783,6 @@ IMPL_LINK( ErrorHdlResetter, BasicErrorHdl, StarBASIC *, /*pBasic*/) CodeCompleteDataCache SbModule::GetCodeCompleteDataFromParse() { CodeCompleteDataCache aCache; - ErrorHdlResetter aErrHdl; SbxBase::ResetError(); diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx index 8da4d1e..9a030cc 100644 --- a/basic/source/comp/dim.cxx +++ b/basic/source/comp/dim.cxx @@ -28,6 +28,7 @@ #include "com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp" #include "com/sun/star/reflection/XIdlMethod.hpp" #include "com/sun/star/uno/Exception.hpp" +#include <basic/codecompletecache.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -207,7 +208,7 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic ) bool bSwitchPool = false; bool bPersistantGlobal = false; SbiToken eFirstTok = eCurTok; - SvtMiscOptions aMiscOptions; + if( pProc && ( eCurTok == GLOBAL || eCurTok == PUBLIC || eCurTok == PRIVATE ) ) Error( SbERR_NOT_IN_SUBR, eCurTok ); if( eCurTok == PUBLIC || eCurTok == GLOBAL ) @@ -404,9 +405,18 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic ) if( !bCompatible && !pDef->IsNew() ) { OUString aTypeName( aGblStrings.Find( pDef->GetTypeId() ) ); - if( rTypeArray->Find( aTypeName, SbxCLASS_OBJECT ) == NULL && (aMiscOptions.IsExperimentalMode() && !IsUnoInterface(aTypeName))) + /*std::cerr <<"CodeCompleteOptions::IsExtendedTypeDeclaration():" << CodeCompleteOptions::IsExtendedTypeDeclaration() << std::endl; + std::cerr << "IsUnoInterface("<<aTypeName<<"):"<< IsUnoInterface(aTypeName) << std::endl; + std::cerr << "finally: " << (CodeCompleteOptions::IsExtendedTypeDeclaration() && !IsUnoInterface(aTypeName)) << std::endl;*/ + if( rTypeArray->Find( aTypeName, SbxCLASS_OBJECT ) == NULL ) { - Error( SbERR_UNDEF_TYPE, aTypeName ); + if(!CodeCompleteOptions::IsExtendedTypeDeclaration()) + Error( SbERR_UNDEF_TYPE, aTypeName ); + else + { + if(!IsUnoInterface(aTypeName)) + Error( SbERR_UNDEF_TYPE, aTypeName ); + } } } diff --git a/basic/source/inc/codegen.hxx b/basic/source/inc/codegen.hxx index f253719..c2478d7 100644 --- a/basic/source/inc/codegen.hxx +++ b/basic/source/inc/codegen.hxx @@ -24,6 +24,7 @@ class SbiParser; class SbModule; #include "opcodes.hxx" #include "buffer.hxx" +#include <basic/codecompletecache.hxx> class SbiCodeGen { SbiParser* pParser; // for error messages, line, column etc. diff --git a/include/basic/codecompletecache.hxx b/include/basic/codecompletecache.hxx index a1428e3..9033b89 100644 --- a/include/basic/codecompletecache.hxx +++ b/include/basic/codecompletecache.hxx @@ -26,12 +26,31 @@ #include <boost/utility.hpp> #include <boost/unordered_map.hpp> #include <rtl/ustring.hxx> +#include <svtools/miscopt.hxx> typedef boost::unordered_map< OUString, OUString, OUStringHash > CodeCompleteVarTypes; /* variable name, type */ typedef boost::unordered_map< OUString, CodeCompleteVarTypes, OUStringHash > CodeCompleteVarScopes; /* procedure, CodeCompleteVarTypes */ +class BASIC_DLLPUBLIC CodeCompleteOptions +{ +/* + * class to store basic code completition + * options + * */ +private: + bool bIsCodeCompleteOn; + SvtMiscOptions aMiscOptions; + +public: + CodeCompleteOptions(); + + static bool IsCodeCompleteOn(); + static void SetCodeCompleteOn( const bool& b ); + static bool IsExtendedTypeDeclaration(); +}; + class BASIC_DLLPUBLIC CodeCompleteDataCache { /* @@ -48,7 +67,7 @@ public: CodeCompleteDataCache(){} virtual ~CodeCompleteDataCache(){} - friend std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache); + friend BASIC_DLLPUBLIC std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache); void SetVars( const CodeCompleteVarScopes& aScopes ); const CodeCompleteVarScopes& GetVars() const; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits