diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-05-26 21:28:34 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-05-27 10:03:43 +0200 |
commit | f46ece5419e4981793189c00b27a6065fcbfaa60 (patch) | |
tree | 815f8d454fb12959e8967043df27eb204709ddd4 /extensions/source | |
parent | 28fc6e2d66e166d354bbe99861f35e12978bcd97 (diff) |
weld FormLinkDialog
Change-Id: I440089f650aea87eab21c148e713a8716e55f2bb
Reviewed-on: https://gerrit.libreoffice.org/73002
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'extensions/source')
-rw-r--r-- | extensions/source/propctrlr/MasterDetailLinkDialog.cxx | 7 | ||||
-rw-r--r-- | extensions/source/propctrlr/formcomponenthandler.cxx | 6 | ||||
-rw-r--r-- | extensions/source/propctrlr/formlinkdialog.cxx | 182 | ||||
-rw-r--r-- | extensions/source/propctrlr/formlinkdialog.hxx | 40 |
4 files changed, 95 insertions, 140 deletions
diff --git a/extensions/source/propctrlr/MasterDetailLinkDialog.cxx b/extensions/source/propctrlr/MasterDetailLinkDialog.cxx index 00814017184b..4df51cddcd39 100644 --- a/extensions/source/propctrlr/MasterDetailLinkDialog.cxx +++ b/extensions/source/propctrlr/MasterDetailLinkDialog.cxx @@ -17,10 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <toolkit/helper/vclunohelper.hxx> #include <sal/log.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/PropertyValue.hpp> +#include <vcl/svapp.hxx> #include "MasterDetailLinkDialog.hxx" #include "formlinkdialog.hxx" #include "pcrservices.hxx" @@ -102,8 +102,9 @@ namespace pcr svt::OGenericUnoDialog::Dialog MasterDetailLinkDialog::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent) { - return svt::OGenericUnoDialog::Dialog(VclPtr<FormLinkDialog>::Create(VCLUnoHelper::GetWindow(rParent),m_xDetail,m_xMaster, m_aContext - ,m_sExplanation,m_sDetailLabel,m_sMasterLabel)); + return svt::OGenericUnoDialog::Dialog(std::make_unique<FormLinkDialog>(Application::GetFrameWeld(rParent), m_xDetail, + m_xMaster, m_aContext, m_sExplanation, + m_sDetailLabel, m_sMasterLabel)); } void MasterDetailLinkDialog::implInitialize(const Any& _rValue) diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index c30f404bc037..edfb90cfa5f3 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -2673,13 +2673,11 @@ namespace pcr if ( !xDetailForm.is() || !xMasterForm.is() ) return false; - - ScopedVclPtrInstance< FormLinkDialog > aDialog( impl_getDefaultDialogParent_nothrow(), m_xComponent, xMasterProp, m_xContext ); + FormLinkDialog aDialog(impl_getDefaultDialogFrame_nothrow(), m_xComponent, xMasterProp, m_xContext); _rClearBeforeDialog.clear(); - return ( RET_OK == aDialog->Execute() ); + return ( RET_OK == aDialog.run() ); } - bool FormComponentPropertyHandler::impl_dialogFormatting_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const { bool bChanged = false; diff --git a/extensions/source/propctrlr/formlinkdialog.cxx b/extensions/source/propctrlr/formlinkdialog.cxx index e52ab453d168..3a400f0c8e0d 100644 --- a/extensions/source/propctrlr/formlinkdialog.cxx +++ b/extensions/source/propctrlr/formlinkdialog.cxx @@ -60,18 +60,18 @@ namespace pcr //= FieldLinkRow - class FieldLinkRow : public TabPage + class FieldLinkRow { private: - VclPtr<ComboBox> m_pDetailColumn; - VclPtr<ComboBox> m_pMasterColumn; + std::unique_ptr<weld::ComboBox> m_xDetailColumn; + std::unique_ptr<weld::ComboBox> m_xMasterColumn; Link<FieldLinkRow&,void> m_aLinkChangeHandler; public: - explicit FieldLinkRow( vcl::Window* _pParent ); - virtual ~FieldLinkRow() override; - virtual void dispose() override; + FieldLinkRow(std::unique_ptr<weld::ComboBox> xDetailColumn, + std::unique_ptr<weld::ComboBox> xMasterColumn); + void SetLinkChangeHandler( const Link<FieldLinkRow&,void>& _rHdl ) { m_aLinkChangeHandler = _rHdl; } @@ -88,132 +88,103 @@ namespace pcr void fillList( LinkParticipant _eWhich, const Sequence< OUString >& _rFieldNames ); + void Show() + { + m_xDetailColumn->show(); + m_xMasterColumn->show(); + } + private: - DECL_LINK( OnFieldNameChanged, Edit&, void ); + DECL_LINK( OnFieldNameChanged, weld::ComboBox&, void ); }; - FieldLinkRow::FieldLinkRow( vcl::Window* _pParent ) - :TabPage( _pParent, "FieldLinkRow", "modules/spropctrlr/ui/fieldlinkrow.ui" ) + FieldLinkRow::FieldLinkRow(std::unique_ptr<weld::ComboBox> xDetailColumn, + std::unique_ptr<weld::ComboBox> xMasterColumn) + : m_xDetailColumn(std::move(xDetailColumn)) + , m_xMasterColumn(std::move(xMasterColumn)) { - get(m_pDetailColumn, "detailCombobox"); - get(m_pMasterColumn, "masterCombobox"); - - m_pDetailColumn->SetDropDownLineCount( 10 ); - m_pMasterColumn->SetDropDownLineCount( 10 ); - - m_pDetailColumn->SetModifyHdl( LINK( this, FieldLinkRow, OnFieldNameChanged ) ); - m_pMasterColumn->SetModifyHdl( LINK( this, FieldLinkRow, OnFieldNameChanged ) ); - } - - FieldLinkRow::~FieldLinkRow() - { - disposeOnce(); - } - - void FieldLinkRow::dispose() - { - m_pDetailColumn.clear(); - m_pMasterColumn.clear(); - TabPage::dispose(); + m_xDetailColumn->connect_changed( LINK( this, FieldLinkRow, OnFieldNameChanged ) ); + m_xMasterColumn->connect_changed( LINK( this, FieldLinkRow, OnFieldNameChanged ) ); } void FieldLinkRow::fillList( LinkParticipant _eWhich, const Sequence< OUString >& _rFieldNames ) { - ComboBox* pBox = ( _eWhich == eDetailField ) ? m_pDetailColumn.get() : m_pMasterColumn.get(); + weld::ComboBox* pBox = ( _eWhich == eDetailField ) ? m_xDetailColumn.get() : m_xMasterColumn.get(); const OUString* pFieldName = _rFieldNames.getConstArray(); const OUString* pFieldNameEnd = pFieldName + _rFieldNames.getLength(); for ( ; pFieldName != pFieldNameEnd; ++pFieldName ) - pBox->InsertEntry( *pFieldName ); + pBox->append_text( *pFieldName ); } - bool FieldLinkRow::GetFieldName( LinkParticipant _eWhich, OUString& /* [out] */ _rName ) const { - const ComboBox* pBox = ( _eWhich == eDetailField ) ? m_pDetailColumn : m_pMasterColumn; - _rName = pBox->GetText(); + const weld::ComboBox* pBox = ( _eWhich == eDetailField ) ? m_xDetailColumn.get() : m_xMasterColumn.get(); + _rName = pBox->get_active_text(); return !_rName.isEmpty(); } - void FieldLinkRow::SetFieldName( LinkParticipant _eWhich, const OUString& _rName ) { - ComboBox* pBox = ( _eWhich == eDetailField ) ? m_pDetailColumn.get() : m_pMasterColumn.get(); - pBox->SetText( _rName ); + weld::ComboBox* pBox = ( _eWhich == eDetailField ) ? m_xDetailColumn.get() : m_xMasterColumn.get(); + pBox->set_entry_text( _rName ); } - - IMPL_LINK_NOARG( FieldLinkRow, OnFieldNameChanged, Edit&, void ) + IMPL_LINK_NOARG( FieldLinkRow, OnFieldNameChanged, weld::ComboBox&, void ) { m_aLinkChangeHandler.Call( *this ); } - VCL_BUILDER_FACTORY(FieldLinkRow) - //= FormLinkDialog - FormLinkDialog::FormLinkDialog( vcl::Window* _pParent, const Reference< XPropertySet >& _rxDetailForm, + FormLinkDialog::FormLinkDialog(weld::Window* _pParent, const Reference< XPropertySet >& _rxDetailForm, const Reference< XPropertySet >& _rxMasterForm, const Reference< XComponentContext >& _rxContext, const OUString& _sExplanation, const OUString& _sDetailLabel, const OUString& _sMasterLabel) - :ModalDialog( _pParent, "FormLinks", "modules/spropctrlr/ui/formlinksdialog.ui" ) - ,m_aRow1 ( VclPtr<FieldLinkRow>::Create( get<VclVBox>("box") ) ) - ,m_aRow2 ( VclPtr<FieldLinkRow>::Create( get<VclVBox>("box") ) ) - ,m_aRow3 ( VclPtr<FieldLinkRow>::Create( get<VclVBox>("box") ) ) - ,m_aRow4 ( VclPtr<FieldLinkRow>::Create( get<VclVBox>("box") ) ) - ,m_xContext ( _rxContext ) - ,m_xDetailForm( _rxDetailForm ) - ,m_xMasterForm( _rxMasterForm ) - ,m_sDetailLabel(_sDetailLabel) - ,m_sMasterLabel(_sMasterLabel) + : GenericDialogController(_pParent, "modules/spropctrlr/ui/formlinksdialog.ui", "FormLinks") + , m_xContext ( _rxContext ) + , m_xDetailForm( _rxDetailForm ) + , m_xMasterForm( _rxMasterForm ) + , m_sDetailLabel(_sDetailLabel) + , m_sMasterLabel(_sMasterLabel) + , m_xExplanation(m_xBuilder->weld_label("explanationLabel")) + , m_xDetailLabel(m_xBuilder->weld_label("detailLabel")) + , m_xMasterLabel(m_xBuilder->weld_label("masterLabel")) + , m_xRow1(std::make_unique<FieldLinkRow>(m_xBuilder->weld_combo_box("detailCombobox1"), + m_xBuilder->weld_combo_box("masterCombobox1"))) + , m_xRow2(std::make_unique<FieldLinkRow>(m_xBuilder->weld_combo_box("detailCombobox2"), + m_xBuilder->weld_combo_box("masterCombobox2"))) + , m_xRow3(std::make_unique<FieldLinkRow>(m_xBuilder->weld_combo_box("detailCombobox3"), + m_xBuilder->weld_combo_box("masterCombobox3"))) + , m_xRow4(std::make_unique<FieldLinkRow>(m_xBuilder->weld_combo_box("detailCombobox4"), + m_xBuilder->weld_combo_box("masterCombobox4"))) + , m_xOK(m_xBuilder->weld_button("ok")) + , m_xSuggest(m_xBuilder->weld_button("suggestButton")) { - get(m_pExplanation, "explanationLabel"); - get(m_pDetailLabel, "detailLabel"); - get(m_pMasterLabel, "masterLabel"); - get(m_pOK, "ok"); - get(m_pSuggest, "suggestButton"); - m_aRow1->Show(); - m_aRow2->Show(); - m_aRow3->Show(); - m_aRow4->Show(); - set_width_request(600); + m_xRow1->Show(); + m_xRow2->Show(); + m_xRow3->Show(); + m_xRow4->Show(); + m_xDialog->set_size_request(600, -1); if ( !_sExplanation.isEmpty() ) - m_pExplanation->SetText(_sExplanation); + m_xExplanation->set_label(_sExplanation); - m_pSuggest->SetClickHdl ( LINK( this, FormLinkDialog, OnSuggest ) ); - m_aRow1->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) ); - m_aRow2->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) ); - m_aRow3->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) ); - m_aRow4->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) ); + m_xSuggest->connect_clicked(LINK(this, FormLinkDialog, OnSuggest)); + m_xRow1->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) ); + m_xRow2->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) ); + m_xRow3->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) ); + m_xRow4->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) ); - PostUserEvent( LINK( this, FormLinkDialog, OnInitialize ), nullptr, true ); + Application::PostUserEvent(LINK(this, FormLinkDialog, OnInitialize)); updateOkButton(); } - - FormLinkDialog::~FormLinkDialog( ) + FormLinkDialog::~FormLinkDialog() { - disposeOnce(); - } - - void FormLinkDialog::dispose( ) - { - m_pExplanation.clear(); - m_pDetailLabel.clear(); - m_pMasterLabel.clear(); - m_pOK.clear(); - m_pSuggest.clear(); - - m_aRow1.disposeAndClear(); - m_aRow2.disposeAndClear(); - m_aRow3.disposeAndClear(); - m_aRow4.disposeAndClear(); - - ModalDialog::dispose(); } void FormLinkDialog::commitLinkPairs() @@ -223,7 +194,7 @@ namespace pcr std::vector< OUString > aMasterFields; aMasterFields.reserve( 4 ); const FieldLinkRow* aRows[] = { - m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get() + m_xRow1.get(), m_xRow2.get(), m_xRow3.get(), m_xRow4.get() }; for (const FieldLinkRow* aRow : aRows) @@ -254,10 +225,9 @@ namespace pcr } } - - short FormLinkDialog::Execute() + short FormLinkDialog::run() { - short nResult = ModalDialog::Execute(); + short nResult = GenericDialogController::run(); if ( RET_OK == nResult ) commitLinkPairs(); @@ -265,7 +235,6 @@ namespace pcr return nResult; } - void FormLinkDialog::initializeFieldLists() { Sequence< OUString > sDetailFields; @@ -275,7 +244,7 @@ namespace pcr getFormFields( m_xMasterForm, sMasterFields ); FieldLinkRow* aRows[] = { - m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get() + m_xRow1.get(), m_xRow2.get(), m_xRow3.get(), m_xRow4.get() }; for (FieldLinkRow* aRow : aRows) { @@ -298,7 +267,7 @@ namespace pcr } sDetailType = m_sDetailLabel; } - m_pDetailLabel->SetText( sDetailType ); + m_xDetailLabel->set_label( sDetailType ); // label for the master form OUString sMasterType = getFormDataSourceType( m_xMasterForm ); @@ -310,10 +279,9 @@ namespace pcr } sMasterType = m_sMasterLabel; } - m_pMasterLabel->SetText( sMasterType ); + m_xMasterLabel->set_label( sMasterType ); } - void FormLinkDialog::initializeFieldRowsFrom( std::vector< OUString >& _rDetailFields, std::vector< OUString >& _rMasterFields ) { // our UI does allow 4 fields max @@ -321,7 +289,7 @@ namespace pcr _rMasterFields.resize( 4 ); FieldLinkRow* aRows[] = { - m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get() + m_xRow1.get(), m_xRow2.get(), m_xRow3.get(), m_xRow4.get() }; for ( sal_Int32 i = 0; i < 4; ++i ) { @@ -366,7 +334,7 @@ namespace pcr bool bEnable = true; const FieldLinkRow* aRows[] = { - m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get() + m_xRow1.get(), m_xRow2.get(), m_xRow3.get(), m_xRow4.get() }; for ( sal_Int32 i = 0; ( i < 4 ) && bEnable; ++i ) @@ -378,10 +346,9 @@ namespace pcr bEnable = false; } - m_pOK->Enable( bEnable ); + m_xOK->set_sensitive(bEnable); } - OUString FormLinkDialog::getFormDataSourceType( const Reference< XPropertySet >& _rxForm ) { OUString sReturn; @@ -408,7 +375,6 @@ namespace pcr return sReturn; } - void FormLinkDialog::getFormFields( const Reference< XPropertySet >& _rxForm, Sequence< OUString >& /* [out] */ _rNames ) const { _rNames.realloc( 0 ); @@ -417,7 +383,7 @@ namespace pcr OUString sCommand; try { - WaitObject aWaitCursor( const_cast< FormLinkDialog* >( this ) ); + weld::WaitObject aWaitCursor(m_xDialog.get()); OSL_ENSURE( _rxForm.is(), "FormLinkDialog::getFormFields: invalid form!" ); @@ -455,11 +421,10 @@ namespace pcr SQLContext aContext; aContext.Message = sErrorMessage; aContext.NextException = aErrorInfo.get(); - ::dbtools::showError( aContext, VCLUnoHelper::GetInterface( const_cast< FormLinkDialog* >( this ) ), m_xContext ); + ::dbtools::showError(aContext, m_xDialog->GetXWindow(), m_xContext); } } - void FormLinkDialog::ensureFormConnection( const Reference< XPropertySet >& _rxFormProps, Reference< XConnection >& /* [out] */ _rxConnection ) const { OSL_PRECOND( _rxFormProps.is(), "FormLinkDialog::ensureFormConnection: invalid form!" ); @@ -641,7 +606,7 @@ namespace pcr bEnable = ( m_aRelationMasterColumns.size() <= 4 ); } - m_pSuggest->Enable( bEnable ); + m_xSuggest->set_sensitive(bEnable); } catch( const Exception& ) { @@ -649,19 +614,16 @@ namespace pcr } } - - IMPL_LINK_NOARG( FormLinkDialog, OnSuggest, Button*, void ) + IMPL_LINK_NOARG( FormLinkDialog, OnSuggest, weld::Button&, void ) { initializeFieldRowsFrom( m_aRelationDetailColumns, m_aRelationMasterColumns ); } - IMPL_LINK_NOARG( FormLinkDialog, OnFieldChanged, FieldLinkRow&, void ) { updateOkButton(); } - IMPL_LINK_NOARG( FormLinkDialog, OnInitialize, void*, void ) { initializeColumnLabels(); diff --git a/extensions/source/propctrlr/formlinkdialog.hxx b/extensions/source/propctrlr/formlinkdialog.hxx index 867c16ab9fdb..45d669137120 100644 --- a/extensions/source/propctrlr/formlinkdialog.hxx +++ b/extensions/source/propctrlr/formlinkdialog.hxx @@ -20,9 +20,7 @@ #ifndef INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HXX #define INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HXX -#include <vcl/dialog.hxx> -#include <vcl/fixed.hxx> -#include <vcl/button.hxx> +#include <vcl/weld.hxx> #include <com/sun/star/form/XForm.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -35,25 +33,13 @@ namespace pcr { - - class FieldLinkRow; //= FormLinkDialog - class FormLinkDialog : public ModalDialog + class FormLinkDialog : public weld::GenericDialogController { private: - VclPtr<FixedText> m_pExplanation; - VclPtr<FixedText> m_pDetailLabel; - VclPtr<FixedText> m_pMasterLabel; - VclPtr<FieldLinkRow> m_aRow1; - VclPtr<FieldLinkRow> m_aRow2; - VclPtr<FieldLinkRow> m_aRow3; - VclPtr<FieldLinkRow> m_aRow4; - VclPtr<OKButton> m_pOK; - VclPtr<PushButton> m_pSuggest; - css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::beans::XPropertySet > @@ -67,9 +53,19 @@ namespace pcr OUString m_sDetailLabel; OUString m_sMasterLabel; + std::unique_ptr<weld::Label> m_xExplanation; + std::unique_ptr<weld::Label> m_xDetailLabel; + std::unique_ptr<weld::Label> m_xMasterLabel; + std::unique_ptr<FieldLinkRow> m_xRow1; + std::unique_ptr<FieldLinkRow> m_xRow2; + std::unique_ptr<FieldLinkRow> m_xRow3; + std::unique_ptr<FieldLinkRow> m_xRow4; + std::unique_ptr<weld::Button> m_xOK; + std::unique_ptr<weld::Button> m_xSuggest; + public: FormLinkDialog( - vcl::Window* _pParent, + weld::Window* _pParent, const css::uno::Reference< css::beans::XPropertySet >& _rxDetailForm, const css::uno::Reference< css::beans::XPropertySet >& _rxMasterForm, const css::uno::Reference< css::uno::XComponentContext >& _rxContext, @@ -77,14 +73,14 @@ namespace pcr const OUString& _sDetailLabel = OUString(), const OUString& _sMasterLabel = OUString() ); - virtual ~FormLinkDialog( ) override; - virtual void dispose() override; + + virtual ~FormLinkDialog() override; // Dialog overridables - virtual short Execute() override; + virtual short run() override; private: - DECL_LINK( OnSuggest, Button*, void ); + DECL_LINK( OnSuggest, weld::Button&, void ); DECL_LINK( OnFieldChanged, FieldLinkRow&, void ); DECL_LINK( OnInitialize, void*, void); @@ -129,10 +125,8 @@ namespace pcr ); }; - } // namespace pcr - #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |