diff options
Diffstat (limited to 'cui/source/options/dbregister.cxx')
-rw-r--r-- | cui/source/options/dbregister.cxx | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/cui/source/options/dbregister.cxx b/cui/source/options/dbregister.cxx index 80f26c2bd893..6aa9213efd92 100644 --- a/cui/source/options/dbregister.cxx +++ b/cui/source/options/dbregister.cxx @@ -29,6 +29,7 @@ #include <tools/debug.hxx> #include <strings.hrc> #include <bitmaps.hlst> +#include <utility> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <svl/itemset.hxx> @@ -36,6 +37,7 @@ #include <dialmgr.hxx> #include "dbregisterednamesconfig.hxx" #include <svx/databaseregistrationui.hxx> +#include <o3tl/string_view.hxx> #define COL_TYPE 0 @@ -43,15 +45,13 @@ namespace svx { -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::ui::dialogs; -using namespace ::com::sun::star::uno; using namespace ::svt; // class RegistrationItemSetHolder ------------------------------------------------- -RegistrationItemSetHolder::RegistrationItemSetHolder( const SfxItemSet& _rMasterSet ) - :m_aRegistrationItems( _rMasterSet ) +RegistrationItemSetHolder::RegistrationItemSetHolder( SfxItemSet _aMasterSet ) + :m_aRegistrationItems(std::move( _aMasterSet )) { DbRegisteredNamesConfig::GetOptions( m_aRegistrationItems ); } @@ -120,7 +120,7 @@ DbRegistrationOptionsPage::DbRegistrationOptionsPage(weld::Container* pPage, wel DbRegistrationOptionsPage::~DbRegistrationOptionsPage() { for (int i = 0, nCount = m_xPathBox->n_children(); i < nCount; ++i ) - delete reinterpret_cast<DatabaseRegistration*>(m_xPathBox->get_id(i).toInt64()); + delete weld::fromId<DatabaseRegistration*>(m_xPathBox->get_id(i)); } std::unique_ptr<SfxTabPage> DbRegistrationOptionsPage::Create( weld::Container* pPage, weld::DialogController* pController, @@ -129,6 +129,16 @@ std::unique_ptr<SfxTabPage> DbRegistrationOptionsPage::Create( weld::Container* return std::make_unique<DbRegistrationOptionsPage>(pPage, pController, *rAttrSet); } +OUString DbRegistrationOptionsPage::GetAllStrings() +{ + OUString sAllStrings; + + if (const auto& pString = m_xBuilder->weld_label("label1")) + sAllStrings += pString->get_label() + " "; + + return sAllStrings.replaceAll("_", ""); +} + bool DbRegistrationOptionsPage::FillItemSet( SfxItemSet* rCoreSet ) { // the settings for the single drivers @@ -137,7 +147,7 @@ bool DbRegistrationOptionsPage::FillItemSet( SfxItemSet* rCoreSet ) int nCount = m_xPathBox->n_children(); for (int i = 0; i < nCount; ++i) { - DatabaseRegistration* pRegistration = reinterpret_cast<DatabaseRegistration*>(m_xPathBox->get_id(i).toInt64()); + DatabaseRegistration* pRegistration = weld::fromId<DatabaseRegistration*>(m_xPathBox->get_id(i)); if ( pRegistration && !pRegistration->sLocation.isEmpty() ) { OUString sName(m_xPathBox->get_text(i, 0)); @@ -179,11 +189,11 @@ void DbRegistrationOptionsPage::Reset( const SfxItemSet* rSet ) // restore column width std::vector<int> aWidths { - aUserData.getToken(0, ';', nIdx).toInt32() + o3tl::toInt32(o3tl::getToken(aUserData, 0, ';', nIdx)) }; m_xPathBox->set_column_fixed_widths(aWidths); // restore sort direction - bool bUp = aUserData.getToken(0, ';', nIdx).toInt32() != 0; + bool bUp = o3tl::toInt32(o3tl::getToken(aUserData, 0, ';', nIdx)) != 0; m_xPathBox->set_sort_order(bUp); m_xPathBox->set_sort_indicator(bUp ? TRISTATE_TRUE : TRISTATE_FALSE, COL_TYPE); } @@ -225,7 +235,7 @@ IMPL_LINK_NOARG(DbRegistrationOptionsPage, EditHdl, weld::Button&, void) if (nEntry == -1) return; - DatabaseRegistration* pOldRegistration = reinterpret_cast<DatabaseRegistration*>(m_xPathBox->get_id(nEntry).toInt64()); + DatabaseRegistration* pOldRegistration = weld::fromId<DatabaseRegistration*>(m_xPathBox->get_id(nEntry)); if (!pOldRegistration || pOldRegistration->bReadOnly) return; @@ -250,7 +260,7 @@ IMPL_LINK( DbRegistrationOptionsPage, HeaderSelect_Impl, int, nCol, void ) IMPL_LINK_NOARG(DbRegistrationOptionsPage, PathSelect_Impl, weld::TreeView&, void) { - DatabaseRegistration* pRegistration = reinterpret_cast<DatabaseRegistration*>(m_xPathBox->get_selected_id().toInt64()); + DatabaseRegistration* pRegistration = weld::fromId<DatabaseRegistration*>(m_xPathBox->get_selected_id()); bool bReadOnly = true; if (pRegistration) @@ -264,7 +274,7 @@ IMPL_LINK_NOARG(DbRegistrationOptionsPage, PathSelect_Impl, weld::TreeView&, voi void DbRegistrationOptionsPage::insertNewEntry(const OUString& _sName,const OUString& _sLocation, const bool _bReadOnly) { - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(new DatabaseRegistration(_sLocation, _bReadOnly)))); + OUString sId(weld::toId(new DatabaseRegistration(_sLocation, _bReadOnly))); m_xPathBox->insert(nullptr, -1, &_sName, &sId, nullptr, nullptr, false, m_xIter.get()); if (_bReadOnly) @@ -278,7 +288,10 @@ void DbRegistrationOptionsPage::openLinkDialog(const OUString& sOldName, const O ODocumentLinkDialog aDlg(GetFrameWeld(), nEntry == -1); aDlg.setLink(sOldName, sOldLocation); - aDlg.setNameValidator(LINK( this, DbRegistrationOptionsPage, NameValidator ) ); + + // tdf#149195: control the name (ie check duplicate) only if new entry case + if (nEntry == -1) + aDlg.setNameValidator(LINK( this, DbRegistrationOptionsPage, NameValidator ) ); if (aDlg.run() != RET_OK) return; @@ -289,7 +302,7 @@ void DbRegistrationOptionsPage::openLinkDialog(const OUString& sOldName, const O { if (nEntry != -1) { - delete reinterpret_cast<DatabaseRegistration*>(m_xPathBox->get_id(nEntry).toInt64()); + delete weld::fromId<DatabaseRegistration*>(m_xPathBox->get_id(nEntry)); m_xPathBox->remove(nEntry); } insertNewEntry( sNewName, sNewLocation, false ); |