/* -*- 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 "abpfinalpage.hxx" #include "addresssettings.hxx" #include "abspilot.hxx" #include #include #include #include #include #include #include namespace abp { using namespace ::svt; using namespace ::utl; static std::shared_ptr lcl_getBaseFilter() { std::shared_ptr pFilter = SfxFilter::GetFilterByName("StarOffice XML (Base)"); OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!"); return pFilter; } FinalPage::FinalPage(weld::Container* pPage, OAddressBookSourcePilot* pWizard) : AddressBookSourcePage(pPage, pWizard, "modules/sabpilot/ui/datasourcepage.ui", "DataSourcePage") , m_xLocation(new SvtURLBox(m_xBuilder->weld_combo_box("location"))) , m_xBrowse(m_xBuilder->weld_button("browse")) , m_xRegisterName(m_xBuilder->weld_check_button("available")) , m_xEmbed(m_xBuilder->weld_check_button("embed")) , m_xNameLabel(m_xBuilder->weld_label("nameft")) , m_xLocationLabel(m_xBuilder->weld_label("locationft")) , m_xName(m_xBuilder->weld_entry("name")) , m_xDuplicateNameError(m_xBuilder->weld_label("warning")) { m_xLocation->SetSmartProtocol(INetProtocol::File); m_xLocation->DisableHistory(); m_xLocationController.reset( new svx::DatabaseLocationInputController(pWizard->getORB(), *m_xLocation, *m_xBrowse, *pWizard->getDialog()) ); m_xName->connect_changed( LINK(this, FinalPage, OnEntryNameModified) ); m_xLocation->connect_changed( LINK(this, FinalPage, OnComboNameModified) ); m_xRegisterName->connect_clicked( LINK( this, FinalPage, OnRegister ) ); m_xRegisterName->set_active(true); m_xEmbed->connect_clicked( LINK( this, FinalPage, OnEmbed ) ); m_xEmbed->set_active(true); } FinalPage::~FinalPage() { m_xLocationController.reset(); } bool FinalPage::isValidName() const { OUString sCurrentName(m_xName->get_text()); if (sCurrentName.isEmpty()) // the name must not be empty return false; if ( m_aInvalidDataSourceNames.find( sCurrentName ) != m_aInvalidDataSourceNames.end() ) // there already is a data source with this name return false; return true; } void FinalPage::setFields() { AddressSettings& rSettings = getSettings(); INetURLObject aURL( rSettings.sDataSourceName ); if( aURL.GetProtocol() == INetProtocol::NotValid ) { OUString sPath = SvtPathOptions().GetWorkPath(); sPath += "/" + rSettings.sDataSourceName; std::shared_ptr pFilter = lcl_getBaseFilter(); if ( pFilter ) { OUString sExt = pFilter->GetDefaultExtension(); sPath += sExt.getToken(1,'*'); } aURL.SetURL(sPath); } OSL_ENSURE( aURL.GetProtocol() != INetProtocol::NotValid ,"No valid file name!"); rSettings.sDataSourceName = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ); m_xLocationController->setURL( rSettings.sDataSourceName ); OUString sName = aURL.getName( ); sal_Int32 nPos = sName.indexOf(aURL.GetFileExtension()); if ( nPos != -1 ) { sName = sName.replaceAt(nPos-1, 4, ""); } m_xName->set_text(sName); OnRegister(*m_xRegisterName); } void FinalPage::initializePage() { AddressBookSourcePage::initializePage(); setFields(); } bool FinalPage::commitPage( ::vcl::WizardTypes::CommitPageReason _eReason ) { if (!AddressBookSourcePage::commitPage(_eReason)) return false; if ( ( ::vcl::WizardTypes::eTravelBackward != _eReason ) && ( !m_xLocationController->prepareCommit() ) ) return false; AddressSettings& rSettings = getSettings(); rSettings.sDataSourceName = m_xLocationController->getURL(); rSettings.bRegisterDataSource = m_xRegisterName->get_active(); if ( rSettings.bRegisterDataSource ) rSettings.sRegisteredDataSourceName = m_xName->get_text(); rSettings.bEmbedDataSource = m_xEmbed->get_active(); return true; } void FinalPage::Activate() { AddressBookSourcePage::Activate(); // get the names of all data sources ODataSourceContext aContext( getORB() ); aContext.getDataSourceNames( m_aInvalidDataSourceNames ); // give the name edit the focus m_xLocation->grab_focus(); // default the finish button getDialog()->defaultButton( WizardButtonFlags::FINISH ); OnEmbed(*m_xEmbed); } void FinalPage::Deactivate() { AddressBookSourcePage::Deactivate(); // default the "next" button, again getDialog()->defaultButton( WizardButtonFlags::NEXT ); // disable the finish button getDialog()->enableButtons( WizardButtonFlags::FINISH, false ); } bool FinalPage::canAdvance() const { return false; } void FinalPage::implCheckName() { bool bValidName = isValidName(); bool bEmptyName = m_xName->get_text().isEmpty(); bool bEmptyLocation = m_xLocation->get_active_text().isEmpty(); // enable or disable the finish button getDialog()->enableButtons( WizardButtonFlags::FINISH, !bEmptyLocation && (!m_xRegisterName->get_active() || bValidName) ); // show the error message for an invalid name m_xDuplicateNameError->set_visible(!bValidName && !bEmptyName); } IMPL_LINK_NOARG( FinalPage, OnEntryNameModified, weld::Entry&, void ) { implCheckName(); } IMPL_LINK_NOARG( FinalPage, OnComboNameModified, weld::ComboBox&, void ) { implCheckName(); } IMPL_LINK_NOARG(FinalPage, OnRegister, weld::Button&, void) { bool bEnable = m_xRegisterName->get_active(); m_xNameLabel->set_sensitive(bEnable); m_xName->set_sensitive(bEnable); implCheckName(); } IMPL_LINK_NOARG(FinalPage, OnEmbed, weld::Button&, void) { bool bEmbed = m_xEmbed->get_active(); m_xLocationLabel->set_sensitive(!bEmbed); m_xLocation->set_sensitive(!bEmbed); m_xBrowse->set_sensitive(!bEmbed); } } // namespace abp /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ imo/mimo-6-4'>distro/mimo/mimo-6-4 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2013-12-16Clean-up uno/lbnames.hStephan Bergmann
2013-12-09fdo#54938: Convert sc to use cppu::supportsServiceMarcos Paulo de Souza
2013-11-19remove most use of RTL_CONSTASCII_USTRINGPARAM macroNoel Grandin
2013-10-22Bin comments that claim to say why some header is includedTor Lillqvist
2013-10-20drop unnecessary tools/string includesCaolán McNamara
2013-09-22add mode lines to new files (and idls) since last runCaolán McNamara
2013-09-19On linux, the entry library name is 'libOpenCL.so'.Kohei Yoshida
2013-09-19Add a quick test code to detect available OpenCL platforms.Kohei Yoshida
2013-07-26targetted clean of redundant header piece from 62badf3828Michael Meeks
2013-04-22Move to MPLv2 license headers, with ESC decision and author's permission.Michael Meeks
2013-04-07mass removal of rtl:: prefixes for O(U)String*Luboš Luňák
2012-12-25Get rid of (most uses of) GUITor Lillqvist
2012-12-10Replacing '__LOADONCALLAPI' with 'SAL_CALL' definitionChristos Strubulis
2012-12-10some Python 3.3 port (not important for LO 4.0)László Németh
2012-12-04re-base on ALv2 code. Includes:Michael Meeks
2012-08-07Remove commented out codeThomas Arnhold
2012-07-31remove commented out SV_DECL_OBJARRMichael Stahl
2012-06-21re-base on ALv2 code.Michael Meeks
2012-06-21re-base on ALv2 code.Michael Meeks
2012-06-20Convert SV_DECL_PTRARR_DEL(XResultListenerArr_Impl) to ptr_vectorNoel Grandin
2012-05-25Renamed calc_Text_text_csv_StarCalc type to generic_Text.Kohei Yoshida