GSOC work, Extended types correction
Stucts can be autocompleted when extended types disabled. Created two functions to make the code brighter. They extract the methods/fields from an XIdlClass and return them in a std::vector<OUString>. I had to modify file basic/source/comp/dim.cxx, to check on UNO types when code completition is on. Change-Id: Id93a6fe896424efb7868f6102985f59fb419b17e
This commit is contained in:
@@ -53,6 +53,7 @@ class SvxSearchItem;
|
|||||||
|
|
||||||
#include <vcl/textdata.hxx>
|
#include <vcl/textdata.hxx>
|
||||||
#include <basic/codecompletecache.hxx>
|
#include <basic/codecompletecache.hxx>
|
||||||
|
#include "com/sun/star/reflection/XIdlClass.hpp"
|
||||||
|
|
||||||
namespace com { namespace sun { namespace star { namespace beans {
|
namespace com { namespace sun { namespace star { namespace beans {
|
||||||
class XMultiPropertySet;
|
class XMultiPropertySet;
|
||||||
@@ -119,6 +120,8 @@ private:
|
|||||||
CodeCompleteDataCache aCodeCompleteCache;
|
CodeCompleteDataCache aCodeCompleteCache;
|
||||||
boost::scoped_ptr< CodeCompleteWindow > pCodeCompleteWnd;
|
boost::scoped_ptr< CodeCompleteWindow > pCodeCompleteWnd;
|
||||||
OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number
|
OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number
|
||||||
|
std::vector< OUString > GetXIdlClassMethods( ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > xClass ) const;
|
||||||
|
std::vector< OUString > GetXIdlClassFields( ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > xClass ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Paint( const Rectangle& );
|
virtual void Paint( const Rectangle& );
|
||||||
|
@@ -510,10 +510,11 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
|
|
||||||
if( pCodeCompleteWnd->IsVisible() && CodeCompleteOptions::IsCodeCompleteOn() )
|
if( pCodeCompleteWnd->IsVisible() && CodeCompleteOptions::IsCodeCompleteOn() )
|
||||||
{
|
{
|
||||||
std::cerr << "EditorWindow::KeyInput" << std::endl;
|
//std::cerr << "EditorWindow::KeyInput" << std::endl;
|
||||||
pCodeCompleteWnd->GetListBox()->KeyInput(rKEvt);
|
pCodeCompleteWnd->GetListBox()->KeyInput(rKEvt);
|
||||||
if( rKEvt.GetKeyCode().GetCode() == KEY_UP
|
if( rKEvt.GetKeyCode().GetCode() == KEY_UP
|
||||||
|| rKEvt.GetKeyCode().GetCode() == KEY_DOWN )
|
|| rKEvt.GetKeyCode().GetCode() == KEY_DOWN
|
||||||
|
|| rKEvt.GetKeyCode().GetCode() == KEY_TAB )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -672,7 +673,8 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( rKEvt.GetKeyCode().GetCode() == KEY_POINT && CodeCompleteOptions::IsCodeCompleteOn() )
|
if( rKEvt.GetKeyCode().GetCode() == KEY_POINT &&
|
||||||
|
(CodeCompleteOptions::IsCodeCompleteOn() || CodeCompleteOptions::IsExtendedTypeDeclaration()) )
|
||||||
{
|
{
|
||||||
rModulWindow.UpdateModule();
|
rModulWindow.UpdateModule();
|
||||||
rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(aCodeCompleteCache);
|
rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(aCodeCompleteCache);
|
||||||
@@ -688,7 +690,10 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
for ( size_t i = 0; i < aPortions.size(); i++ )
|
for ( size_t i = 0; i < aPortions.size(); i++ )
|
||||||
{
|
{
|
||||||
HighlightPortion& r = aPortions[i];
|
HighlightPortion& r = aPortions[i];
|
||||||
if( r.tokenType == 1 ) // extract the identifers(methods, base variable)
|
if( r.tokenType == 1 || r.tokenType == 9) // extract the identifers(methods, base variable)
|
||||||
|
/* an example: Dim aLocVar2 as com.sun.star.beans.PropertyValue
|
||||||
|
* here, aLocVar2.Name, and PropertyValue's Name field is treated as a keyword(?!)
|
||||||
|
* */
|
||||||
aVect.push_back( aLine.copy(r.nBegin, r.nEnd - r.nBegin) );
|
aVect.push_back( aLine.copy(r.nBegin, r.nEnd - r.nBegin) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -716,39 +721,51 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
while( j != aVect.size() )
|
while( j != aVect.size() )
|
||||||
{
|
{
|
||||||
sMethName = aVect[j];
|
sMethName = aVect[j];
|
||||||
|
Reference< reflection::XIdlField> xField = xClass->getField( sMethName );
|
||||||
|
if( xField != NULL )
|
||||||
|
{
|
||||||
|
xClass = xField->getType();
|
||||||
|
if( xClass == NULL )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( CodeCompleteOptions::IsExtendedTypeDeclaration() )
|
||||||
|
{
|
||||||
Reference< reflection::XIdlMethod> xMethod = xClass->getMethod( sMethName );
|
Reference< reflection::XIdlMethod> xMethod = xClass->getMethod( sMethName );
|
||||||
if( xMethod != NULL ) //method OK
|
if( xMethod != NULL ) //method OK
|
||||||
{
|
{
|
||||||
xClass = xMethod->getReturnType();
|
xClass = xMethod->getReturnType();
|
||||||
if( xClass == NULL )
|
if( xClass == NULL )
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{//nothing to reflect
|
||||||
bReflect = false;
|
bReflect = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{// no extended types allowed
|
||||||
|
bReflect = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
if( bReflect )
|
if( bReflect )
|
||||||
{
|
{
|
||||||
Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods();
|
std::vector< OUString > aEntryVect;//entries to be inserted into the list
|
||||||
Sequence< Reference< reflection::XIdlField > > aFields = xClass->getFields();
|
std::vector< OUString > aMethVect = GetXIdlClassMethods(xClass);//methods
|
||||||
std::vector< OUString > aEntryVect;
|
std::vector< OUString > aFieldVect = GetXIdlClassFields(xClass);//fields
|
||||||
|
aEntryVect.insert(aEntryVect.end(), aFieldVect.begin(), aFieldVect.end() );
|
||||||
if( aMethods.getLength() != 0 )
|
if( CodeCompleteOptions::IsExtendedTypeDeclaration() )
|
||||||
{
|
{// if extended types on, reflect classes, else just the structs (XIdlClass without methods)
|
||||||
for(sal_Int32 l = 0; l < aMethods.getLength(); ++l)
|
aEntryVect.insert(aEntryVect.end(), aMethVect.begin(), aMethVect.end() );
|
||||||
{
|
|
||||||
aEntryVect.push_back(OUString(aMethods[l]->getName()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( aFields.getLength() != 0 )
|
|
||||||
{
|
|
||||||
for(sal_Int32 l = 0; l < aFields.getLength(); ++l)
|
|
||||||
{
|
|
||||||
aEntryVect.push_back(OUString(aFields[l]->getName()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if( aEntryVect.size() > 0 )
|
if( aEntryVect.size() > 0 )
|
||||||
{
|
{
|
||||||
@@ -772,7 +789,6 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
pCodeCompleteWnd->ResizeListBox();
|
pCodeCompleteWnd->ResizeListBox();
|
||||||
pCodeCompleteWnd->SelectFirstEntry();
|
pCodeCompleteWnd->SelectFirstEntry();
|
||||||
pEditView->GetWindow()->GrabFocus();
|
pEditView->GetWindow()->GrabFocus();
|
||||||
//pEditView->EnableCursor( true );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -822,6 +838,34 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector< OUString > EditorWindow::GetXIdlClassMethods( Reference< reflection::XIdlClass > xClass ) const
|
||||||
|
{
|
||||||
|
Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods();
|
||||||
|
std::vector< OUString > aRetVect;
|
||||||
|
if( aMethods.getLength() != 0 )
|
||||||
|
{
|
||||||
|
for(sal_Int32 l = 0; l < aMethods.getLength(); ++l)
|
||||||
|
{
|
||||||
|
aRetVect.push_back(OUString(aMethods[l]->getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return aRetVect;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector< OUString > EditorWindow::GetXIdlClassFields( Reference< reflection::XIdlClass > xClass ) const
|
||||||
|
{
|
||||||
|
Sequence< Reference< reflection::XIdlField > > aFields = xClass->getFields();
|
||||||
|
std::vector< OUString > aRetVect;
|
||||||
|
if( aFields.getLength() != 0 )
|
||||||
|
{
|
||||||
|
for(sal_Int32 l = 0; l < aFields.getLength(); ++l)
|
||||||
|
{
|
||||||
|
aRetVect.push_back(OUString(aFields[l]->getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return aRetVect;
|
||||||
|
}
|
||||||
|
|
||||||
void EditorWindow::Paint( const Rectangle& rRect )
|
void EditorWindow::Paint( const Rectangle& rRect )
|
||||||
{
|
{
|
||||||
if ( !pEditEngine ) // We need it now at latest
|
if ( !pEditEngine ) // We need it now at latest
|
||||||
@@ -2620,7 +2664,7 @@ void CodeCompleteListBox::SetVisibleEntries()
|
|||||||
|
|
||||||
void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
|
void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
|
||||||
{
|
{
|
||||||
std::cerr << "CodeCompleteListBox::KeyInput" << std::endl;
|
//std::cerr << "CodeCompleteListBox::KeyInput" << std::endl;
|
||||||
sal_Unicode aChar = rKeyEvt.GetKeyCode().GetCode();
|
sal_Unicode aChar = rKeyEvt.GetKeyCode().GetCode();
|
||||||
if( ( aChar >= KEY_A ) && ( aChar <= KEY_Z ) )
|
if( ( aChar >= KEY_A ) && ( aChar <= KEY_Z ) )
|
||||||
{
|
{
|
||||||
@@ -2654,13 +2698,9 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
|
|||||||
InsertSelectedEntry();
|
InsertSelectedEntry();
|
||||||
break;
|
break;
|
||||||
case KEY_UP: case KEY_DOWN:
|
case KEY_UP: case KEY_DOWN:
|
||||||
std::cerr << "up/down ke in CodeCompleteListBox::KeyInput" << std::endl;
|
//std::cerr << "up/down ke in CodeCompleteListBox::KeyInput" << std::endl;
|
||||||
//GrabFocus();
|
|
||||||
NotifyEvent nEvt( EVENT_KEYINPUT, NULL, &rKeyEvt );
|
NotifyEvent nEvt( EVENT_KEYINPUT, NULL, &rKeyEvt );
|
||||||
PreNotify(nEvt);
|
PreNotify(nEvt);
|
||||||
//pCodeCompleteWindow->pParent->GrabFocus();
|
|
||||||
//SetVisibleEntries();
|
|
||||||
//pCodeCompleteWindow->pParent->GrabFocus();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -405,12 +405,9 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
|
|||||||
if( !bCompatible && !pDef->IsNew() )
|
if( !bCompatible && !pDef->IsNew() )
|
||||||
{
|
{
|
||||||
OUString aTypeName( aGblStrings.Find( pDef->GetTypeId() ) );
|
OUString aTypeName( aGblStrings.Find( pDef->GetTypeId() ) );
|
||||||
/*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 )
|
if( rTypeArray->Find( aTypeName, SbxCLASS_OBJECT ) == NULL )
|
||||||
{
|
{
|
||||||
if(!CodeCompleteOptions::IsExtendedTypeDeclaration())
|
if(!CodeCompleteOptions::IsCodeCompleteOn())
|
||||||
Error( SbERR_UNDEF_TYPE, aTypeName );
|
Error( SbERR_UNDEF_TYPE, aTypeName );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user