Kaydet (Commit) 99cecd1f authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

use StartExecuteAsync in basctl

Change-Id: Id24d03631ff60305525835144ad543d5dcb2064f
Reviewed-on: https://gerrit.libreoffice.org/65709
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 6aaed7c5
...@@ -739,9 +739,12 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) ...@@ -739,9 +739,12 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
case SID_BASICIDE_MANAGE_LANG: case SID_BASICIDE_MANAGE_LANG:
{ {
ScopedVclPtrInstance< ManageLanguageDialog > aDlg(pCurWin, m_pCurLocalizationMgr); std::shared_ptr<SfxRequest> pRequest(new SfxRequest(rReq));
aDlg->Execute(); rReq.Ignore(); // the 'old' request is not relevant any more
rReq.Done(); auto pDlg = VclPtr<ManageLanguageDialog>::Create(pCurWin, m_pCurLocalizationMgr);
pDlg->StartExecuteAsync([=](sal_Int32 /*nResult*/){
pRequest->Done();
});
} }
break; break;
......
...@@ -72,7 +72,7 @@ void Organize( sal_Int16 tabId ) ...@@ -72,7 +72,7 @@ void Organize( sal_Int16 tabId )
aDesc = pCurWin->CreateEntryDescriptor(); aDesc = pCurWin->CreateEntryDescriptor();
vcl::Window* pParent = Application::GetDefDialogParent(); vcl::Window* pParent = Application::GetDefDialogParent();
ScopedVclPtrInstance<OrganizeDialog>(pParent, tabId, aDesc)->Execute(); VclPtr<OrganizeDialog>::Create(pParent, tabId, aDesc)->StartExecuteAsync(nullptr);
} }
bool IsValidSbxName( const OUString& rName ) bool IsValidSbxName( const OUString& rName )
......
...@@ -742,20 +742,19 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void) ...@@ -742,20 +742,19 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void)
m_xBasicBox->get_selected(m_xBasicBoxIter.get()); m_xBasicBox->get_selected(m_xBasicBoxIter.get());
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get()); EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
VclPtrInstance< OrganizeDialog > pDlg( nullptr, 0, aDesc ); //TODO VclPtrInstance< OrganizeDialog > pDlg( nullptr, 0, aDesc ); //TODO
sal_uInt16 nRet = pDlg->Execute(); pDlg->StartExecuteAsync([=](sal_Int32 nRet){
pDlg.reset(); if ( nRet ) // not only closed
{
if ( nRet ) // not only closed m_xDialog->response(Macro_Edit);
{ return;
m_xDialog->response(Macro_Edit); }
return;
}
Shell* pShell = GetShell(); Shell* pShell = GetShell();
if ( pShell && pShell->IsAppBasicModified() ) if ( pShell && pShell->IsAppBasicModified() )
bForceStoreBasic = true; bForceStoreBasic = true;
m_xBasicBox->UpdateEntries(); m_xBasicBox->UpdateEntries();
});
} }
} }
......
...@@ -831,240 +831,243 @@ void LibPage::InsertLib() ...@@ -831,240 +831,243 @@ void LibPage::InsertLib()
if ( aExtension != aLibExtension && aExtension != aContExtension ) if ( aExtension != aLibExtension && aExtension != aContExtension )
pLibDlg->EnableReference(false); pLibDlg->EnableReference(false);
if ( !pLibDlg->Execute() ) pLibDlg->StartExecuteAsync([=](sal_Int32 nResult)
return;
bool bChanges = false;
sal_uLong nNewPos = m_pLibBox->GetEntryCount();
bool bRemove = false;
bool bReplace = pLibDlg->IsReplace();
bool bReference = pLibDlg->IsReference();
for ( sal_uLong nLib = 0; nLib < pLibDlg->GetLibBox().GetEntryCount(); nLib++ )
{
if ( pLibDlg->GetLibBox().IsChecked( nLib ) )
{ {
SvTreeListEntry* pEntry = pLibDlg->GetLibBox().GetEntry( nLib ); if (!nResult )
DBG_ASSERT( pEntry, "Entry?!" ); return;
OUString aLibName( SvTabListBox::GetEntryText( pEntry, 0 ) );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); bool bChanges = false;
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY ); sal_uLong nNewPos = m_pLibBox->GetEntryCount();
bool bRemove = false;
// check, if the library is already existing bool bReplace = pLibDlg->IsReplace();
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) ) || bool bReference = pLibDlg->IsReference();
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) ) ) for ( sal_uLong nLib = 0; nLib < pLibDlg->GetLibBox().GetEntryCount(); nLib++ )
{ {
if ( bReplace ) if ( pLibDlg->GetLibBox().IsChecked( nLib ) )
{ {
// check, if the library is the Standard library SvTreeListEntry* pEntry = pLibDlg->GetLibBox().GetEntry( nLib );
if ( aLibName == "Standard" ) DBG_ASSERT( pEntry, "Entry?!" );
OUString aLibName( SvTabListBox::GetEntryText( pEntry, 0 ) );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
// check, if the library is already existing
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) ) )
{ {
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(), if ( bReplace )
VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_REPLACESTDLIB))); {
xErrorBox->run(); // check, if the library is the Standard library
continue; if ( aLibName == "Standard" )
} {
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
// check, if the library is readonly and not a link VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_REPLACESTDLIB)));
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) && !xModLibContainer->isLibraryLink( aLibName ) ) || xErrorBox->run();
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) && !xDlgLibContainer->isLibraryLink( aLibName ) ) ) continue;
{ }
OUString aErrStr( IDEResId(RID_STR_REPLACELIB) );
aErrStr = aErrStr.replaceAll("XX", aLibName) + "\n" + IDEResId(RID_STR_LIBISREADONLY);
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
VclMessageType::Warning, VclButtonsType::Ok, aErrStr));
xErrorBox->run();
continue;
}
// remove existing libraries // check, if the library is readonly and not a link
bRemove = true; if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) && !xModLibContainer->isLibraryLink( aLibName ) ) ||
} ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) && !xDlgLibContainer->isLibraryLink( aLibName ) ) )
else {
{ OUString aErrStr( IDEResId(RID_STR_REPLACELIB) );
OUString aErrStr; aErrStr = aErrStr.replaceAll("XX", aLibName) + "\n" + IDEResId(RID_STR_LIBISREADONLY);
if ( bReference ) std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
aErrStr = IDEResId(RID_STR_REFNOTPOSSIBLE); VclMessageType::Warning, VclButtonsType::Ok, aErrStr));
else xErrorBox->run();
aErrStr = IDEResId(RID_STR_IMPORTNOTPOSSIBLE); continue;
aErrStr = aErrStr.replaceAll("XX", aLibName) + "\n" +IDEResId(RID_STR_SBXNAMEALLREADYUSED); }
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
VclMessageType::Warning, VclButtonsType::Ok, aErrStr));
xErrorBox->run();
continue;
}
}
// check, if the library is password protected // remove existing libraries
bool bOK = false; bRemove = true;
OUString aPassword; }
if ( xModLibContImport.is() && xModLibContImport->hasByName( aLibName ) ) else
{ {
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContImport, UNO_QUERY ); OUString aErrStr;
if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) && !bReference ) if ( bReference )
{ aErrStr = IDEResId(RID_STR_REFNOTPOSSIBLE);
bOK = QueryPassword( xModLibContImp, aLibName, aPassword, true, true ); else
aErrStr = IDEResId(RID_STR_IMPORTNOTPOSSIBLE);
aErrStr = aErrStr.replaceAll("XX", aLibName) + "\n" +IDEResId(RID_STR_SBXNAMEALLREADYUSED);
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
VclMessageType::Warning, VclButtonsType::Ok, aErrStr));
xErrorBox->run();
continue;
}
}
if ( !bOK ) // check, if the library is password protected
bool bOK = false;
OUString aPassword;
if ( xModLibContImport.is() && xModLibContImport->hasByName( aLibName ) )
{ {
OUString aErrStr( IDEResId(RID_STR_NOIMPORT) ); Reference< script::XLibraryContainerPassword > xPasswd( xModLibContImport, UNO_QUERY );
aErrStr = aErrStr.replaceAll("XX", aLibName); if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) && !bReference )
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(), {
VclMessageType::Warning, VclButtonsType::Ok, aErrStr)); bOK = QueryPassword( xModLibContImp, aLibName, aPassword, true, true );
xErrorBox->run();
continue;
}
}
}
// remove existing libraries if ( !bOK )
if ( bRemove ) {
{ OUString aErrStr( IDEResId(RID_STR_NOIMPORT) );
// remove listbox entry aErrStr = aErrStr.replaceAll("XX", aLibName);
SvTreeListEntry* pEntry_ = m_pLibBox->FindEntry( aLibName ); std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
if ( pEntry_ ) VclMessageType::Warning, VclButtonsType::Ok, aErrStr));
m_pLibBox->SvTreeListBox::GetModel()->Remove( pEntry_ ); xErrorBox->run();
continue;
// remove module library }
if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) ) }
xModLibContainer->removeLibrary( aLibName ); }
// remove dialog library
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
xDlgLibContainer->removeLibrary( aLibName );
}
// copy module library // remove existing libraries
if ( xModLibContImport.is() && xModLibContImport->hasByName( aLibName ) && xModLibContainer.is() && !xModLibContainer->hasByName( aLibName ) ) if ( bRemove )
{
Reference< container::XNameContainer > xModLib;
if ( bReference )
{
// storage URL
INetURLObject aModStorageURLObj( aModURLObj );
if ( aExtension == aContExtension )
{ {
sal_Int32 nCount = aModStorageURLObj.getSegmentCount(); // remove listbox entry
aModStorageURLObj.insertName( aLibName, false, nCount-1 ); SvTreeListEntry* pEntry_ = m_pLibBox->FindEntry( aLibName );
aModStorageURLObj.setExtension( aLibExtension ); if ( pEntry_ )
aModStorageURLObj.setFinalSlash(); m_pLibBox->SvTreeListBox::GetModel()->Remove( pEntry_ );
// remove module library
if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
xModLibContainer->removeLibrary( aLibName );
// remove dialog library
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
xDlgLibContainer->removeLibrary( aLibName );
} }
OUString aModStorageURL( aModStorageURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
// create library link // copy module library
xModLib.set( xModLibContainer->createLibraryLink( aLibName, aModStorageURL, true ), UNO_QUERY); if ( xModLibContImport.is() && xModLibContImport->hasByName( aLibName ) && xModLibContainer.is() && !xModLibContainer->hasByName( aLibName ) )
}
else
{
// create library
xModLib = xModLibContainer->createLibrary( aLibName );
if ( xModLib.is() )
{ {
// get import library Reference< container::XNameContainer > xModLib;
Reference< container::XNameContainer > xModLibImport; if ( bReference )
Any aElement = xModLibContImport->getByName( aLibName );
aElement >>= xModLibImport;
if ( xModLibImport.is() )
{ {
// load library // storage URL
if ( !xModLibContImport->isLibraryLoaded( aLibName ) ) INetURLObject aModStorageURLObj( aModURLObj );
xModLibContImport->loadLibrary( aLibName ); if ( aExtension == aContExtension )
// copy all modules
Sequence< OUString > aModNames = xModLibImport->getElementNames();
sal_Int32 nModCount = aModNames.getLength();
const OUString* pModNames = aModNames.getConstArray();
for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
{ {
OUString aModName( pModNames[ i ] ); sal_Int32 nCount = aModStorageURLObj.getSegmentCount();
Any aElement_ = xModLibImport->getByName( aModName ); aModStorageURLObj.insertName( aLibName, false, nCount-1 );
xModLib->insertByName( aModName, aElement_ ); aModStorageURLObj.setExtension( aLibExtension );
aModStorageURLObj.setFinalSlash();
} }
OUString aModStorageURL( aModStorageURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
// set password // create library link
if ( bOK ) xModLib.set( xModLibContainer->createLibraryLink( aLibName, aModStorageURL, true ), UNO_QUERY);
}
else
{
// create library
xModLib = xModLibContainer->createLibrary( aLibName );
if ( xModLib.is() )
{ {
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY ); // get import library
if ( xPasswd.is() ) Reference< container::XNameContainer > xModLibImport;
Any aElement = xModLibContImport->getByName( aLibName );
aElement >>= xModLibImport;
if ( xModLibImport.is() )
{ {
try // load library
if ( !xModLibContImport->isLibraryLoaded( aLibName ) )
xModLibContImport->loadLibrary( aLibName );
// copy all modules
Sequence< OUString > aModNames = xModLibImport->getElementNames();
sal_Int32 nModCount = aModNames.getLength();
const OUString* pModNames = aModNames.getConstArray();
for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
{ {
xPasswd->changeLibraryPassword( aLibName, OUString(), aPassword ); OUString aModName( pModNames[ i ] );
Any aElement_ = xModLibImport->getByName( aModName );
xModLib->insertByName( aModName, aElement_ );
} }
catch (...)
// set password
if ( bOK )
{ {
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
if ( xPasswd.is() )
{
try
{
xPasswd->changeLibraryPassword( aLibName, OUString(), aPassword );
}
catch (...)
{
}
}
} }
} }
} }
} }
} }
}
}
// copy dialog library // copy dialog library
if ( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aLibName ) && xDlgLibContainer.is() && !xDlgLibContainer->hasByName( aLibName ) ) if ( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aLibName ) && xDlgLibContainer.is() && !xDlgLibContainer->hasByName( aLibName ) )
{
Reference< container::XNameContainer > xDlgLib;
if ( bReference )
{
// storage URL
INetURLObject aDlgStorageURLObj( aDlgURLObj );
if ( aExtension == aContExtension )
{ {
sal_Int32 nCount = aDlgStorageURLObj.getSegmentCount(); Reference< container::XNameContainer > xDlgLib;
aDlgStorageURLObj.insertName( aLibName, false, nCount - 1 ); if ( bReference )
aDlgStorageURLObj.setExtension( aLibExtension ); {
aDlgStorageURLObj.setFinalSlash(); // storage URL
} INetURLObject aDlgStorageURLObj( aDlgURLObj );
OUString aDlgStorageURL( aDlgStorageURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); if ( aExtension == aContExtension )
{
// create library link sal_Int32 nCount = aDlgStorageURLObj.getSegmentCount();
xDlgLib.set( xDlgLibContainer->createLibraryLink( aLibName, aDlgStorageURL, true ), UNO_QUERY); aDlgStorageURLObj.insertName( aLibName, false, nCount - 1 );
} aDlgStorageURLObj.setExtension( aLibExtension );
else aDlgStorageURLObj.setFinalSlash();
{ }
// create library OUString aDlgStorageURL( aDlgStorageURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
xDlgLib = xDlgLibContainer->createLibrary( aLibName );
if ( xDlgLib.is() )
{
// get import library
Reference< container::XNameContainer > xDlgLibImport;
Any aElement = xDlgLibContImport->getByName( aLibName );
aElement >>= xDlgLibImport;
if ( xDlgLibImport.is() ) // create library link
xDlgLib.set( xDlgLibContainer->createLibraryLink( aLibName, aDlgStorageURL, true ), UNO_QUERY);
}
else
{ {
// load library // create library
if ( !xDlgLibContImport->isLibraryLoaded( aLibName ) ) xDlgLib = xDlgLibContainer->createLibrary( aLibName );
xDlgLibContImport->loadLibrary( aLibName ); if ( xDlgLib.is() )
// copy all dialogs
Sequence< OUString > aDlgNames = xDlgLibImport->getElementNames();
sal_Int32 nDlgCount = aDlgNames.getLength();
const OUString* pDlgNames = aDlgNames.getConstArray();
for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
{ {
OUString aDlgName( pDlgNames[ i ] ); // get import library
Any aElement_ = xDlgLibImport->getByName( aDlgName ); Reference< container::XNameContainer > xDlgLibImport;
xDlgLib->insertByName( aDlgName, aElement_ ); Any aElement = xDlgLibContImport->getByName( aLibName );
aElement >>= xDlgLibImport;
if ( xDlgLibImport.is() )
{
// load library
if ( !xDlgLibContImport->isLibraryLoaded( aLibName ) )
xDlgLibContImport->loadLibrary( aLibName );
// copy all dialogs
Sequence< OUString > aDlgNames = xDlgLibImport->getElementNames();
sal_Int32 nDlgCount = aDlgNames.getLength();
const OUString* pDlgNames = aDlgNames.getConstArray();
for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
{
OUString aDlgName( pDlgNames[ i ] );
Any aElement_ = xDlgLibImport->getByName( aDlgName );
xDlgLib->insertByName( aDlgName, aElement_ );
}
}
} }
} }
} }
// insert listbox entry
ImpInsertLibEntry( aLibName, m_pLibBox->GetEntryCount() );
bChanges = true;
} }
} }
// insert listbox entry SvTreeListEntry* pFirstNew = m_pLibBox->GetEntry( nNewPos );
ImpInsertLibEntry( aLibName, m_pLibBox->GetEntryCount() ); if ( pFirstNew )
bChanges = true; m_pLibBox->SetCurEntry( pFirstNew );
}
}
SvTreeListEntry* pFirstNew = m_pLibBox->GetEntry( nNewPos ); if ( bChanges )
if ( pFirstNew ) MarkDocumentModified( m_aCurDocument );
m_pLibBox->SetCurEntry( pFirstNew ); });
if ( bChanges )
MarkDocumentModified( m_aCurDocument );
} }
void LibPage::Export() void LibPage::Export()
......
...@@ -145,19 +145,21 @@ void ManageLanguageDialog::ClearLanguageBox() ...@@ -145,19 +145,21 @@ void ManageLanguageDialog::ClearLanguageBox()
IMPL_LINK_NOARG(ManageLanguageDialog, AddHdl, Button*, void) IMPL_LINK_NOARG(ManageLanguageDialog, AddHdl, Button*, void)
{ {
ScopedVclPtrInstance< SetDefaultLanguageDialog > aDlg( this, m_xLocalizationMgr ); VclPtr< SetDefaultLanguageDialog > pDlg = VclPtr<SetDefaultLanguageDialog>::Create(this, m_xLocalizationMgr);
if ( aDlg->Execute() == RET_OK ) pDlg->StartExecuteAsync([pDlg,this](sal_Int32 nResult)
{ {
// add new locales if (!nResult )
Sequence< Locale > aLocaleSeq = aDlg->GetLocales(); return;
m_xLocalizationMgr->handleAddLocales( aLocaleSeq ); // add new locales
// update listbox Sequence< Locale > aLocaleSeq = pDlg->GetLocales();
ClearLanguageBox(); m_xLocalizationMgr->handleAddLocales( aLocaleSeq );
FillLanguageBox(); // update listbox
ClearLanguageBox();
if (SfxBindings* pBindings = GetBindingsPtr()) FillLanguageBox();
pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
} if (SfxBindings* pBindings = GetBindingsPtr())
pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
});
} }
IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl, Button*, void) IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl, Button*, void)
......
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