/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include "adminpages.hxx" #include #include #include #include #include #include #include #include #include "dsselect.hxx" #include "odbcconfig.hxx" #include "optionalboolitem.hxx" #include #include #include #include #include namespace dbaui { using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdbc; ISaveValueWrapper::~ISaveValueWrapper() { } OGenericAdministrationPage::OGenericAdministrationPage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OUString& rId, const SfxItemSet& rAttrSet) : SfxTabPage(pPage, pController, rUIXMLDescription, rId, &rAttrSet) , m_abEnableRoadmap(false) , m_pAdminDialog(nullptr) , m_pItemSetHelper(nullptr) { SetExchangeSupport(); m_xContainer->set_size_request(m_xContainer->get_approximate_digit_width() * WIZARD_PAGE_X, m_xContainer->get_text_height() * WIZARD_PAGE_Y); } DeactivateRC OGenericAdministrationPage::DeactivatePage(SfxItemSet* _pSet) { if (_pSet) { if (!prepareLeave()) return DeactivateRC::KeepPage; FillItemSet(_pSet); } return DeactivateRC::LeavePage; } void OGenericAdministrationPage::Reset(const SfxItemSet* _rCoreAttrs) { implInitControls(*_rCoreAttrs, false); } void OGenericAdministrationPage::Activate() { BuilderPage::Activate(); OSL_ENSURE(m_pItemSetHelper,"NO ItemSetHelper set!"); if ( m_pItemSetHelper ) ActivatePage(*m_pItemSetHelper->getOutputSet()); } void OGenericAdministrationPage::ActivatePage(const SfxItemSet& _rSet) { implInitControls(_rSet, true); } void OGenericAdministrationPage::getFlags(const SfxItemSet& _rSet, bool& _rValid, bool& _rReadonly) { const SfxBoolItem* pInvalid = _rSet.GetItem(DSID_INVALID_SELECTION); _rValid = !pInvalid || !pInvalid->GetValue(); const SfxBoolItem* pReadonly = _rSet.GetItem(DSID_READONLY); _rReadonly = !_rValid || (pReadonly && pReadonly->GetValue()); } IMPL_LINK(OGenericAdministrationPage, OnControlModified, weld::Widget*, pCtrl, void) { callModifiedHdl(pCtrl); } IMPL_LINK(OGenericAdministrationPage, OnControlModifiedButtonClick, weld::Toggleable&, rCtrl, void) { callModifiedHdl(&rCtrl); } IMPL_LINK(OGenericAdministrationPage, OnControlEntryModifyHdl, weld::Entry&, rCtrl, void) { callModifiedHdl(&rCtrl); } IMPL_LINK(OGenericAdministrationPage, OnControlSpinButtonModifyHdl, weld::SpinButton&, rCtrl, void) { callModifiedHdl(&rCtrl); } bool OGenericAdministrationPage::getSelectedDataSource(OUString& _sReturn, OUString const & _sCurr) { // collect all ODBC data source names std::set aOdbcDatasources; OOdbcEnumeration aEnumeration; if (!aEnumeration.isLoaded()) { // show an error message OUString sError(DBA_RES(STR_COULD_NOT_LOAD_ODBC_LIB)); sError = sError.replaceFirst("#lib#", aEnumeration.getLibraryName()); std::unique_ptr xDialog(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, sError)); xDialog->run(); return false; } else { aEnumeration.getDatasourceNames(aOdbcDatasources); // execute the select dialog ODatasourceSelectDialog aSelector(GetFrameWeld(), aOdbcDatasources); if (!_sCurr.isEmpty()) aSelector.Select(_sCurr); if (RET_OK == aSelector.run()) _sReturn = aSelector.GetSelected(); } return true; } void OGenericAdministrationPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) { // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) bool bValid, bReadonly; getFlags(_rSet, bValid, bReadonly); std::vector< std::unique_ptr > aControlList; if ( _bSaveValue ) { fillControls(aControlList); for( const auto& pValueWrapper : aControlList ) { pValueWrapper->SaveValue(); } } if ( bReadonly ) { fillWindows(aControlList); for( const auto& pValueWrapper : aControlList ) { pValueWrapper->Disable(); } } } void OGenericAdministrationPage::initializePage() { OSL_ENSURE(m_pItemSetHelper,"NO ItemSetHelper set!"); if ( m_pItemSetHelper ) Reset(m_pItemSetHelper->getOutputSet()); } bool OGenericAdministrationPage::commitPage( ::vcl::WizardTypes::CommitPageReason ) { return true; } bool OGenericAdministrationPage::canAdvance() const { return true; } void OGenericAdministrationPage::fillBool( SfxItemSet& _rSet, const weld::CheckButton* pCheckBox, sal_uInt16 _nID, bool bOptionalBool, bool& _bChangedSomething, bool _bRevertValue ) { if (!(pCheckBox && pCheckBox->get_state_changed_from_saved())) return; bool bValue = pCheckBox->get_active(); if ( _bRevertValue ) bValue = !bValue; if (bOptionalBool) { OptionalBoolItem aValue( _nID ); if ( pCheckBox->get_state() != TRISTATE_INDET ) aValue.SetValue( bValue ); _rSet.Put( aValue ); } else _rSet.Put( SfxBoolItem( _nID, bValue ) ); _bChangedSomething = true; } void OGenericAdministrationPage::fillInt32(SfxItemSet& _rSet, const weld::SpinButton* pEdit, TypedWhichId _nID, bool& _bChangedSomething) { if (pEdit && pEdit->get_value_changed_from_saved()) { _rSet.Put(SfxInt32Item(_nID, pEdit->get_value())); _bChangedSomething = true; } } void OGenericAdministrationPage::fillString(SfxItemSet& _rSet, const weld::Entry* pEdit, TypedWhichId _nID, bool& _bChangedSomething) { if (pEdit && pEdit->get_value_changed_from_saved()) { _rSet.Put(SfxStringItem(_nID, pEdit->get_text().trim())); _bChangedSomething = true; } } void OGenericAdministrationPage::fillString(SfxItemSet& _rSet, const dbaui::OConnectionURLEdit* pEdit, TypedWhichId _nID, bool& _bChangedSomething) { if (pEdit && pEdit->get_value_changed_from_saved()) { _rSet.Put(SfxStringItem(_nID, pEdit->GetText().trim())); _bChangedSomething = true; } } IMPL_LINK_NOARG(OGenericAdministrationPage, OnTestConnectionButtonClickHdl, weld::Button&, void) { OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); bool bSuccess = false; if ( !m_pAdminDialog ) return; m_pAdminDialog->saveDatasource(); OGenericAdministrationPage::implInitControls(*m_pItemSetHelper->getOutputSet(), true); bool bShowMessage = true; try { std::pair< Reference,bool> aConnectionPair = m_pAdminDialog->createConnection(); bShowMessage = aConnectionPair.second; bSuccess = aConnectionPair.first.is(); ::comphelper::disposeComponent(aConnectionPair.first); } catch(Exception&) { } if ( bShowMessage ) { MessageType eImage = MessageType::Info; OUString aMessage,sTitle; sTitle = DBA_RES(STR_CONNECTION_TEST); if ( bSuccess ) { aMessage = DBA_RES(STR_CONNECTION_SUCCESS); } else { eImage = MessageType::Error; aMessage = DBA_RES(STR_CONNECTION_NO_SUCCESS); } OSQLMessageBox aMsg(GetFrameWeld(), sTitle, aMessage, MessBoxStyle::Ok, eImage); aMsg.run(); } if ( !bSuccess ) m_pAdminDialog->clearPassword(); } } // namespace dbaui /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ iley LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
4-12
AgeCommit message (Expand)Author
rename intern->internalNoel Grandin
2023-04-11tdf#150477: Change "Slide" to "Page" in Draw status barBaole Fang
2023-04-10Drop SvStream::WriteCharPtrMike Kaganski
2023-04-10Use more *string_viewMike Kaganski
2023-04-09new loplugin:unnecessarygetstrNoel Grandin
2023-04-08use shared_ptr for model::Theme instead of unique_ptrTomaž Vajngerl
2023-04-07tdf#154437: Check "Page" instead of "Slide" in Draw renameBaole Fang
2023-04-06sd: fix crash in DrawViewShell::ExecCtrlXisco Fauli
2023-04-06Missing XServiceInfoStephan Bergmann
2023-04-05fix leaks when using tools::JsonWriterNoel Grandin
2023-04-05vcl,sw,sd: PDF/UA export: produce better /CT for SdrMediaObjMichael Stahl
2023-04-05avmedia,*: guess the mime type of media files based on file nameMichael Stahl
2023-04-02Avoid conversions between OUString and OString in VCLMike Kaganski
2023-04-01use more XVclWindowPeerNoel Grandin
2023-03-30loplugin:stringadd in sd/sdextNoel Grandin
2023-03-26tdf#90407 Change the auto-fit alg. to match better with OOXMLTomaž Vajngerl
2023-03-22vcl,drawinglayer,svx,sw,sd: PDF/UA export: Annot StructElem for SdrMediaObjMichael Stahl
2023-03-22sd: PDF export: produce annotations for shapes before painting shapesMichael Stahl
2023-03-20vcl,sd,sw: PDF/UA export: add Alt text to SdrMediaObj media shapesMichael Stahl
2023-03-19MCGR: Model data changes for ColorStepsArmin Le Grand (allotropia)
2023-03-15tdf#88205: Adapt uses of css::uno::Sequence to use initializer_list ctorYousef_Rabia
2023-03-14elide some temporary OStringsNoel Grandin
2023-03-14sd: fix crash in ViewTabBar::dispose()Miklos Vajna
2023-03-10improve loplugin:unnecessarylockingNoel Grandin
2023-03-09Wrong value for VT_UI4 (sd/propread)Julien Nabet
2023-03-08oox, sd: fix ever-increasing chart IDs when exporting to PPTXMiklos Vajna
2023-03-08Simplify usage of BinaryDataContainerMike Kaganski
2023-03-07lok: form controls: rendering and mouse event forwardingMarco Cecchetti
2023-03-07clang-tidy dead-storeNoel Grandin
2023-03-07no need to allocate these separatelyNoel Grandin
2023-03-07no need to allocate these separatelyNoel Grandin
2023-03-03Related: tdf#94319 object pasted in draw/impress is always centeredCaolán McNamara
2023-03-03Revert "BaseMutex->std::mutex in AccessibleSlideSorterView"Noel Grandin
2023-03-02BaseMutex->std::mutex in SlideShowListenerProxyNoel Grandin
2023-03-02BaseMutex->std::mutex in AccessibleSlideSorterViewNoel Grandin
2023-03-02BaseMutex->std::mutex in DrawSubControllerInterfaceBaseNoel Grandin
2023-03-01create a default theme when SdrPage and SdrModel are createdTomaž Vajngerl
2023-02-28tdf#148966: pptx: workaround for multiline fields followed by linebreaksSarper Akdemir
2023-02-27return by ref from SdrGlobalDataNoel Grandin
2023-02-24BaseMutex->std::mutex in SdStyleSheetNoel Grandin
2023-02-24BaseMutex->std::mutex in sd::tools::PropertySetNoel Grandin
2023-02-23related tdf#148966: rework sdr compatibility flagsSarper Akdemir
2023-02-21osl::Mutex->std::mutex in PresenterTimerNoel Grandin
2023-02-20osl::Mutex->std::mutex in SdXCustomPresentationNoel Grandin
2023-02-19osl::Mutex->std::mutex in BitmapCacheNoel Grandin