tdf#93077 - basic dialog localization issues.

Don't remove non-existent languages to clean the dialog.
Avoid crashing when adding languages to a non-localized dialog.

Change-Id: Ie356177e00e56c214727d513ae0ce6d62d32591c
Reviewed-on: https://gerrit.libreoffice.org/17929
Tested-by: Jenkins <ci@libreoffice.org>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/basctl/source/dlged/managelang.cxx b/basctl/source/dlged/managelang.cxx
index 998a688..bde64e2 100644
--- a/basctl/source/dlged/managelang.cxx
+++ b/basctl/source/dlged/managelang.cxx
@@ -149,12 +149,19 @@ IMPL_LINK_NOARG(ManageLanguageDialog, AddHdl)
    ScopedVclPtrInstance< SetDefaultLanguageDialog > aDlg( this, m_xLocalizationMgr );
    if ( RET_OK == aDlg->Execute() )
    {
        // add new locales
        Sequence< Locale > aLocaleSeq = aDlg->GetLocales();
        m_xLocalizationMgr->handleAddLocales( aLocaleSeq );
        // update listbox
        ClearLanguageBox();
        FillLanguageBox();
        if (!m_xLocalizationMgr->isLibraryLocalized())
        {
            SAL_WARN("basctl.basicide", "Adding langs to non-localized library tdf#93077");
        }
        else
        {
            // add new locales
            Sequence< Locale > aLocaleSeq = aDlg->GetLocales();
            m_xLocalizationMgr->handleAddLocales( aLocaleSeq );
            // update listbox
            ClearLanguageBox();
            FillLanguageBox();
        }

        if (SfxBindings* pBindings = GetBindingsPtr())
            pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
@@ -277,16 +284,17 @@ void SetDefaultLanguageDialog::FillLanguageBox()
{
    // fill list with all languages
    m_pLanguageLB->SetLanguageList( SvxLanguageListFlags::ALL, false );
    // remove the already localized languages
    Sequence< Locale > aLocaleSeq = m_xLocalizationMgr->getStringResourceManager()->getLocales();
    const Locale* pLocale = aLocaleSeq.getConstArray();
    sal_Int32 i, nCount = aLocaleSeq.getLength();
    for ( i = 0;  i < nCount;  ++i )
        m_pLanguageLB->RemoveLanguage( LanguageTag::convertToLanguageType( pLocale[i] ) );

    // fill checklistbox if not in default mode
    if ( m_xLocalizationMgr->isLibraryLocalized() )
    {
        // remove the already localized languages
        Sequence< Locale > aLocaleSeq = m_xLocalizationMgr->getStringResourceManager()->getLocales();
        const Locale* pLocale = aLocaleSeq.getConstArray();
        sal_Int32 i, nCount = aLocaleSeq.getLength();
        for ( i = 0;  i < nCount;  ++i )
            m_pLanguageLB->RemoveLanguage( LanguageTag::convertToLanguageType( pLocale[i] ) );

        // fill checklistbox if not in default mode
        sal_uInt16 j, nCount_ = m_pLanguageLB->GetEntryCount();
        for ( j = 0;  j < nCount_;  ++j )
        {