Kaydet (Commit) ac476e78 authored tarafından Norbert Thiebaud's avatar Norbert Thiebaud

basic: clean-up String from eventatt.cxx

Change-Id: I78f39310dbb0a024af4268f503a6150451f12778
üst bbf1bcd9
...@@ -98,13 +98,12 @@ void SFURL_firing_impl( const ScriptEvent& aScriptEvent, Any* pRet, const Refere ...@@ -98,13 +98,12 @@ void SFURL_firing_impl( const ScriptEvent& aScriptEvent, Any* pRet, const Refere
comphelper::getProcessComponentContext() ); comphelper::getProcessComponentContext() );
Reference< provider::XScriptProviderFactory > xFactory( Reference< provider::XScriptProviderFactory > xFactory(
xContext->getValueByName( xContext->getValueByName(
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory")) ), OUString("/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory")), UNO_QUERY );
UNO_QUERY );
OSL_ENSURE( xFactory.is(), "SFURL_firing_impl: failed to get master script provider factory" ); OSL_ENSURE( xFactory.is(), "SFURL_firing_impl: failed to get master script provider factory" );
if ( xFactory.is() ) if ( xFactory.is() )
{ {
Any aCtx; Any aCtx;
aCtx <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")); aCtx <<= OUString("user");
xScriptProvider.set( xFactory->createScriptProvider( aCtx ), UNO_QUERY ); xScriptProvider.set( xFactory->createScriptProvider( aCtx ), UNO_QUERY );
} }
} }
...@@ -201,13 +200,13 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any ...@@ -201,13 +200,13 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any
if( aScriptEvent.ScriptType.compareToAscii( "StarBasic" ) == 0 ) if( aScriptEvent.ScriptType.compareToAscii( "StarBasic" ) == 0 )
{ {
// Full qualified name? // Full qualified name?
String aMacro( aScriptEvent.ScriptCode ); OUString aMacro( aScriptEvent.ScriptCode );
String aLibName; OUString aLibName;
String aLocation; OUString aLocation;
if( comphelper::string::getTokenCount(aMacro, '.') == 3 ) if( comphelper::string::getTokenCount(aMacro, '.') == 3 )
{ {
sal_uInt16 nLast = 0; sal_Int32 nLast = 0;
::rtl::OUString aFullLibName = aMacro.GetToken( 0, '.', nLast ); ::rtl::OUString aFullLibName = aMacro.getToken( (sal_Int32)0, (sal_Unicode)'.', nLast );
sal_Int32 nIndex = aFullLibName.indexOf( (sal_Unicode)':' ); sal_Int32 nIndex = aFullLibName.indexOf( (sal_Unicode)':' );
if (nIndex >= 0) if (nIndex >= 0)
...@@ -216,8 +215,8 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any ...@@ -216,8 +215,8 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any
aLibName = aFullLibName.copy( nIndex + 1 ); aLibName = aFullLibName.copy( nIndex + 1 );
} }
String aModul = aMacro.GetToken( 0, '.', nLast ); OUString aModul = aMacro.getToken( (sal_Int32)0, (sal_Unicode)'.', nLast );
aMacro.Erase( 0, nLast ); aMacro = aMacro.copy( nLast , aMacro.getLength());
} }
SbxObject* p = maBasicRef; SbxObject* p = maBasicRef;
...@@ -234,8 +233,8 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any ...@@ -234,8 +233,8 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any
} }
else if( pParent ) else if( pParent )
{ {
String aName = p->GetName(); OUString aName = p->GetName();
if( aName.EqualsAscii("Standard") ) if( aName.equalsAscii("Standard") )
{ {
// Own basic is doc standard lib // Own basic is doc standard lib
xDocStandardBasic = (StarBASIC*)p; xDocStandardBasic = (StarBASIC*)p;
...@@ -249,13 +248,18 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any ...@@ -249,13 +248,18 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any
bool bSearchLib = true; bool bSearchLib = true;
StarBASICRef xLibSearchBasic; StarBASICRef xLibSearchBasic;
if( aLocation.EqualsAscii("application") ) if( aLocation.equalsAscii("application") )
{
xLibSearchBasic = xAppStandardBasic; xLibSearchBasic = xAppStandardBasic;
else if( aLocation.EqualsAscii("document") ) }
else if( aLocation.equalsAscii("document") )
{
xLibSearchBasic = xDocStandardBasic; xLibSearchBasic = xDocStandardBasic;
}
else else
{
bSearchLib = false; bSearchLib = false;
}
SbxVariable* pMethVar = NULL; SbxVariable* pMethVar = NULL;
// Be still tolerant and make default search if no search basic exists // Be still tolerant and make default search if no search basic exists
if( bSearchLib && xLibSearchBasic.Is() ) if( bSearchLib && xLibSearchBasic.Is() )
...@@ -276,7 +280,7 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any ...@@ -276,7 +280,7 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any
} }
if( pBasic ) if( pBasic )
{ {
String aName = pBasic->GetName(); OUString aName = pBasic->GetName();
if( aName == aLibName ) if( aName == aLibName )
{ {
// Search only in the lib, not automatically in application basic // Search only in the lib, not automatically in application basic
...@@ -292,15 +296,16 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any ...@@ -292,15 +296,16 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any
// Default: Be tolerant and search everywhere // Default: Be tolerant and search everywhere
if( (!pMethVar || !pMethVar->ISA(SbMethod)) && maBasicRef.Is() ) if( (!pMethVar || !pMethVar->ISA(SbMethod)) && maBasicRef.Is() )
{
pMethVar = maBasicRef->FindQualified( aMacro, SbxCLASS_DONTCARE ); pMethVar = maBasicRef->FindQualified( aMacro, SbxCLASS_DONTCARE );
}
SbMethod* pMeth = PTR_CAST(SbMethod,pMethVar); SbMethod* pMeth = PTR_CAST(SbMethod,pMethVar);
if( !pMeth ) if( !pMeth )
{
return; return;
}
// Setup parameters // Setup parameters
SbxArrayRef xArray; SbxArrayRef xArray;
String aTmp;
sal_Int32 nCnt = aScriptEvent.Arguments.getLength(); sal_Int32 nCnt = aScriptEvent.Arguments.getLength();
if( nCnt ) if( nCnt )
{ {
...@@ -317,17 +322,20 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any ...@@ -317,17 +322,20 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any
// Call method // Call method
SbxVariableRef xValue = pRet ? new SbxVariable : 0; SbxVariableRef xValue = pRet ? new SbxVariable : 0;
if( xArray.Is() ) if( xArray.Is() )
{
pMeth->SetParameters( xArray ); pMeth->SetParameters( xArray );
}
pMeth->Call( xValue ); pMeth->Call( xValue );
if( pRet ) if( pRet )
{
*pRet = sbxToUnoValue( xValue ); *pRet = sbxToUnoValue( xValue );
}
pMeth->SetParameters( NULL ); pMeth->SetParameters( NULL );
} }
else // scripting framework script else // scripting framework script
{ {
//callBasic via scripting framework //callBasic via scripting framework
SFURL_firing_impl( aScriptEvent, pRet, m_xModel ); SFURL_firing_impl( aScriptEvent, pRet, m_xModel );
} }
} }
...@@ -453,17 +461,18 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit ...@@ -453,17 +461,18 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit
} }
// Create new uno dialog // Create new uno dialog
Reference< XNameContainer > xDialogModel( xMSF->createInstance Reference< XNameContainer > xDialogModel( xMSF->createInstance(
( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), ::rtl::OUString("com.sun.star.awt.UnoControlDialogModel")), UNO_QUERY );
UNO_QUERY );
if( !xDialogModel.is() ) if( !xDialogModel.is() )
{
return; return;
}
Reference< XInputStreamProvider > xISP; Reference< XInputStreamProvider > xISP;
aAnyISP >>= xISP; aAnyISP >>= xISP;
if( !xISP.is() ) if( !xISP.is() )
{
return; return;
}
Reference< XComponentContext > xContext( Reference< XComponentContext > xContext(
comphelper::getComponentContext( xMSF ) ); comphelper::getComponentContext( xMSF ) );
...@@ -477,15 +486,15 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit ...@@ -477,15 +486,15 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit
bool bDecoration = true; bool bDecoration = true;
try try
{ {
::rtl::OUString aDecorationPropName(RTL_CONSTASCII_USTRINGPARAM("Decoration")); OUString aDecorationPropName("Decoration");
Any aDecorationAny = xDlgModPropSet->getPropertyValue( aDecorationPropName ); Any aDecorationAny = xDlgModPropSet->getPropertyValue( aDecorationPropName );
aDecorationAny >>= bDecoration; aDecorationAny >>= bDecoration;
if( !bDecoration ) if( !bDecoration )
{ {
xDlgModPropSet->setPropertyValue( aDecorationPropName, makeAny( true ) ); xDlgModPropSet->setPropertyValue( aDecorationPropName, makeAny( true ) );
::rtl::OUString aTitlePropName(RTL_CONSTASCII_USTRINGPARAM("Title")); OUString aTitlePropName("Title");
xDlgModPropSet->setPropertyValue( aTitlePropName, makeAny( ::rtl::OUString() ) ); xDlgModPropSet->setPropertyValue( aTitlePropName, makeAny( OUString() ) );
} }
} }
catch(const UnknownPropertyException& ) catch(const UnknownPropertyException& )
...@@ -501,15 +510,15 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit ...@@ -501,15 +510,15 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit
// If we found the dialog then it belongs to the Search basic // If we found the dialog then it belongs to the Search basic
if ( !pFoundBasic ) if ( !pFoundBasic )
{ {
Reference< frame::XDesktop > xDesktop( xMSF->createInstance Reference< frame::XDesktop > xDesktop( xMSF->createInstance(OUString("com.sun.star.frame.Desktop")), UNO_QUERY);
( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ),
UNO_QUERY );
Reference< container::XEnumeration > xModels; Reference< container::XEnumeration > xModels;
if ( xDesktop.is() ) if ( xDesktop.is() )
{ {
Reference< container::XEnumerationAccess > xComponents( xDesktop->getComponents(), UNO_QUERY ); Reference< container::XEnumerationAccess > xComponents( xDesktop->getComponents(), UNO_QUERY );
if ( xComponents.is() ) if ( xComponents.is() )
{
xModels.set( xComponents->createEnumeration(), UNO_QUERY ); xModels.set( xComponents->createEnumeration(), UNO_QUERY );
}
if ( xModels.is() ) if ( xModels.is() )
{ {
while ( xModels->hasMoreElements() ) while ( xModels->hasMoreElements() )
...@@ -519,7 +528,9 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit ...@@ -519,7 +528,9 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit
{ {
BasicManager* pMgr = basic::BasicManagerRepository::getDocumentBasicManager( xNextModel ); BasicManager* pMgr = basic::BasicManagerRepository::getDocumentBasicManager( xNextModel );
if ( pMgr ) if ( pMgr )
{
aDlgLibAny = implFindDialogLibForDialogBasic( aAnyISP, pMgr->GetLib(0), pFoundBasic ); aDlgLibAny = implFindDialogLibForDialogBasic( aAnyISP, pMgr->GetLib(0), pFoundBasic );
}
if ( aDlgLibAny.hasValue() ) if ( aDlgLibAny.hasValue() )
{ {
bDocDialog = true; bDocDialog = true;
...@@ -532,14 +543,20 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit ...@@ -532,14 +543,20 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit
} }
} }
if ( pFoundBasic ) if ( pFoundBasic )
{
bDocDialog = pFoundBasic->IsDocBasic(); bDocDialog = pFoundBasic->IsDocBasic();
}
Reference< XScriptListener > xScriptListener = new BasicScriptListener_Impl( GetSbData()->pInst->GetBasic(), xModel ); Reference< XScriptListener > xScriptListener = new BasicScriptListener_Impl( GetSbData()->pInst->GetBasic(), xModel );
Sequence< Any > aArgs( 4 ); Sequence< Any > aArgs( 4 );
if( bDocDialog ) if( bDocDialog )
{
aArgs[ 0 ] <<= xModel; aArgs[ 0 ] <<= xModel;
}
else else
{
aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); aArgs[ 0 ] <<= uno::Reference< uno::XInterface >();
}
aArgs[ 1 ] <<= xInput; aArgs[ 1 ] <<= xInput;
aArgs[ 2 ] = aDlgLibAny; aArgs[ 2 ] = aDlgLibAny;
aArgs[ 3 ] <<= xScriptListener; aArgs[ 3 ] <<= xScriptListener;
...@@ -547,8 +564,8 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit ...@@ -547,8 +564,8 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit
Reference< XControl > xCntrl; Reference< XControl > xCntrl;
try try
{ {
Reference< XDialogProvider > xDlgProv( xMSF->createInstanceWithArguments( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.scripting.DialogProvider" ) ), aArgs ), UNO_QUERY ); Reference< XDialogProvider > xDlgProv( xMSF->createInstanceWithArguments(OUString("com.sun.star.comp.scripting.DialogProvider" ), aArgs ), UNO_QUERY );
xCntrl.set( xDlgProv->createDialog( rtl::OUString() ), UNO_QUERY_THROW ); xCntrl.set( xDlgProv->createDialog(OUString() ), UNO_QUERY_THROW );
// Add dialog model to dispose vector // Add dialog model to dispose vector
Reference< XComponent > xDlgComponent( xCntrl->getModel(), UNO_QUERY ); Reference< XComponent > xDlgComponent( xCntrl->getModel(), UNO_QUERY );
GetSbData()->pInst->getComponentVector().push_back( xDlgComponent ); GetSbData()->pInst->getComponentVector().push_back( xDlgComponent );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment