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:
parent
972bbede6e
commit
b4319d8726
@ -53,6 +53,7 @@ class SvxSearchItem;
|
||||
|
||||
#include <vcl/textdata.hxx>
|
||||
#include <basic/codecompletecache.hxx>
|
||||
#include "com/sun/star/reflection/XIdlClass.hpp"
|
||||
|
||||
namespace com { namespace sun { namespace star { namespace beans {
|
||||
class XMultiPropertySet;
|
||||
@ -119,6 +120,8 @@ private:
|
||||
CodeCompleteDataCache aCodeCompleteCache;
|
||||
boost::scoped_ptr< CodeCompleteWindow > pCodeCompleteWnd;
|
||||
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:
|
||||
virtual void Paint( const Rectangle& );
|
||||
|
@ -510,10 +510,11 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
||||
|
||||
if( pCodeCompleteWnd->IsVisible() && CodeCompleteOptions::IsCodeCompleteOn() )
|
||||
{
|
||||
std::cerr << "EditorWindow::KeyInput" << std::endl;
|
||||
//std::cerr << "EditorWindow::KeyInput" << std::endl;
|
||||
pCodeCompleteWnd->GetListBox()->KeyInput(rKEvt);
|
||||
if( rKEvt.GetKeyCode().GetCode() == KEY_UP
|
||||
|| rKEvt.GetKeyCode().GetCode() == KEY_DOWN )
|
||||
|| rKEvt.GetKeyCode().GetCode() == KEY_DOWN
|
||||
|| rKEvt.GetKeyCode().GetCode() == KEY_TAB )
|
||||
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.GetSbModule()->GetCodeCompleteDataFromParse(aCodeCompleteCache);
|
||||
@ -688,7 +690,10 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
||||
for ( size_t i = 0; i < aPortions.size(); 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) );
|
||||
}
|
||||
|
||||
@ -716,39 +721,51 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
||||
while( j != aVect.size() )
|
||||
{
|
||||
sMethName = aVect[j];
|
||||
Reference< reflection::XIdlMethod> xMethod = xClass->getMethod( sMethName );
|
||||
if( xMethod != NULL ) //method OK
|
||||
Reference< reflection::XIdlField> xField = xClass->getField( sMethName );
|
||||
if( xField != NULL )
|
||||
{
|
||||
xClass = xMethod->getReturnType();
|
||||
xClass = xField->getType();
|
||||
if( xClass == NULL )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bReflect = false;
|
||||
break;
|
||||
if( CodeCompleteOptions::IsExtendedTypeDeclaration() )
|
||||
{
|
||||
Reference< reflection::XIdlMethod> xMethod = xClass->getMethod( sMethName );
|
||||
if( xMethod != NULL ) //method OK
|
||||
{
|
||||
xClass = xMethod->getReturnType();
|
||||
if( xClass == NULL )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{//nothing to reflect
|
||||
bReflect = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{// no extended types allowed
|
||||
bReflect = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if( bReflect )
|
||||
{
|
||||
Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods();
|
||||
Sequence< Reference< reflection::XIdlField > > aFields = xClass->getFields();
|
||||
std::vector< OUString > aEntryVect;
|
||||
|
||||
if( aMethods.getLength() != 0 )
|
||||
{
|
||||
for(sal_Int32 l = 0; l < aMethods.getLength(); ++l)
|
||||
{
|
||||
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()));
|
||||
}
|
||||
std::vector< OUString > aEntryVect;//entries to be inserted into the list
|
||||
std::vector< OUString > aMethVect = GetXIdlClassMethods(xClass);//methods
|
||||
std::vector< OUString > aFieldVect = GetXIdlClassFields(xClass);//fields
|
||||
aEntryVect.insert(aEntryVect.end(), aFieldVect.begin(), aFieldVect.end() );
|
||||
if( CodeCompleteOptions::IsExtendedTypeDeclaration() )
|
||||
{// if extended types on, reflect classes, else just the structs (XIdlClass without methods)
|
||||
aEntryVect.insert(aEntryVect.end(), aMethVect.begin(), aMethVect.end() );
|
||||
}
|
||||
if( aEntryVect.size() > 0 )
|
||||
{
|
||||
@ -772,7 +789,6 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
||||
pCodeCompleteWnd->ResizeListBox();
|
||||
pCodeCompleteWnd->SelectFirstEntry();
|
||||
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 )
|
||||
{
|
||||
if ( !pEditEngine ) // We need it now at latest
|
||||
@ -2620,7 +2664,7 @@ void CodeCompleteListBox::SetVisibleEntries()
|
||||
|
||||
void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
|
||||
{
|
||||
std::cerr << "CodeCompleteListBox::KeyInput" << std::endl;
|
||||
//std::cerr << "CodeCompleteListBox::KeyInput" << std::endl;
|
||||
sal_Unicode aChar = rKeyEvt.GetKeyCode().GetCode();
|
||||
if( ( aChar >= KEY_A ) && ( aChar <= KEY_Z ) )
|
||||
{
|
||||
@ -2654,13 +2698,9 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
|
||||
InsertSelectedEntry();
|
||||
break;
|
||||
case KEY_UP: case KEY_DOWN:
|
||||
std::cerr << "up/down ke in CodeCompleteListBox::KeyInput" << std::endl;
|
||||
//GrabFocus();
|
||||
//std::cerr << "up/down ke in CodeCompleteListBox::KeyInput" << std::endl;
|
||||
NotifyEvent nEvt( EVENT_KEYINPUT, NULL, &rKeyEvt );
|
||||
PreNotify(nEvt);
|
||||
//pCodeCompleteWindow->pParent->GrabFocus();
|
||||
//SetVisibleEntries();
|
||||
//pCodeCompleteWindow->pParent->GrabFocus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -405,12 +405,9 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
|
||||
if( !bCompatible && !pDef->IsNew() )
|
||||
{
|
||||
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(!CodeCompleteOptions::IsExtendedTypeDeclaration())
|
||||
if(!CodeCompleteOptions::IsCodeCompleteOn())
|
||||
Error( SbERR_UNDEF_TYPE, aTypeName );
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user