include/sfx2/basedlgs.hxx | 2 sfx2/source/dialog/basedlgs.cxx | 2 sw/inc/swabstdlg.hxx | 2 sw/source/ui/chrdlg/tblnumfm.cxx | 2 sw/source/ui/dbui/dbinsdlg.cxx | 610 +++++++++++------------- sw/source/ui/dialog/swdlgfact.cxx | 12 sw/source/ui/dialog/swdlgfact.hxx | 10 sw/source/uibase/inc/dbinsdlg.hxx | 94 +-- sw/source/uibase/inc/numfmtlb.hxx | 48 + sw/source/uibase/inc/tblnumfm.hxx | 2 sw/source/uibase/utlui/numfmtlb.cxx | 316 ++++++++++++ sw/uiconfig/swriter/ui/insertdbcolumnsdialog.ui | 157 ++++-- vcl/unx/gtk3/gtk3gtkinst.cxx | 16 13 files changed, 862 insertions(+), 411 deletions(-)
New commits: commit 6d2014175122020f08b301f7213a228082f9c98a Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Mar 1 15:29:39 2019 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Mar 1 22:24:31 2019 +0100 weld SwInsertDBColAutoPilot Change-Id: I5e46a88de2ff11ecd38667338b84babee24a2a11 Reviewed-on: https://gerrit.libreoffice.org/68591 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx index 45120686ca96..fc0a436301c3 100644 --- a/include/sfx2/basedlgs.hxx +++ b/include/sfx2/basedlgs.hxx @@ -230,7 +230,7 @@ private: const SfxItemSet* m_pInputSet; public: - SfxSingleTabDialogController(weld::Window *pParent, const SfxItemSet& rOptionsSet, + SfxSingleTabDialogController(weld::Widget* pParent, const SfxItemSet& rOptionsSet, const OUString& rUIXMLDescription = OUString("sfx/ui/singletabdialog.ui"), const OString& rID = OString("SingleTabDialog")); diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx index a1e6bb7ddf6f..74e7e3a00844 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -844,7 +844,7 @@ IMPL_STATIC_LINK_NOARG(SfxDialogController, InstallLOKNotifierHdl, void*, vcl::I return SfxViewShell::Current(); } -SfxSingleTabDialogController::SfxSingleTabDialogController(weld::Window *pParent, const SfxItemSet& rSet, +SfxSingleTabDialogController::SfxSingleTabDialogController(weld::Widget *pParent, const SfxItemSet& rSet, const OUString& rUIXMLDescription, const OString& rID) : SfxDialogController(pParent, rUIXMLDescription, rID) , m_pInputSet(&rSet) diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index 7f0b059bb0a4..0eac3d69da38 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -362,7 +362,7 @@ class SwAbstractDialogFactory public: static SwAbstractDialogFactory* Create(); - virtual VclPtr<SfxAbstractDialog> CreateNumFormatDialog(weld::Window* pParent, const SfxItemSet& rAttr) = 0; + virtual VclPtr<SfxAbstractDialog> CreateNumFormatDialog(weld::Widget* pParent, const SfxItemSet& rAttr) = 0; virtual VclPtr<SfxAbstractDialog> CreateSwDropCapsDialog(weld::Window* pParent, const SfxItemSet& rSet) = 0; virtual VclPtr<SfxAbstractDialog> CreateSwBackgroundDialog(weld::Window* pParent, const SfxItemSet& rSet) = 0; diff --git a/sw/source/ui/chrdlg/tblnumfm.cxx b/sw/source/ui/chrdlg/tblnumfm.cxx index d790a7e7d03d..4ac2af9e7883 100644 --- a/sw/source/ui/chrdlg/tblnumfm.cxx +++ b/sw/source/ui/chrdlg/tblnumfm.cxx @@ -27,7 +27,7 @@ #include <svl/itemset.hxx> #include <sfx2/tabdlg.hxx> -SwNumFormatDlg::SwNumFormatDlg(weld::Window* pParent, const SfxItemSet& rSet) +SwNumFormatDlg::SwNumFormatDlg(weld::Widget* pParent, const SfxItemSet& rSet) : SfxSingleTabDialogController(pParent, rSet, "cui/ui/formatnumberdialog.ui", "FormatNumberDialog") { // Create TabPage diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index aa5cca460593..7eb2341dc3f7 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -182,48 +182,43 @@ SwInsertDBColAutoPilot::SwInsertDBColAutoPilot( SwView& rView, Reference<XDataSource> const & xDataSource, Reference<sdbcx::XColumnsSupplier> const & xColSupp, const SwDBData& rData ) - : SfxModalDialog(rView.GetWindow(), "InsertDbColumnsDialog", - "modules/swriter/ui/insertdbcolumnsdialog.ui") + : SfxDialogController(rView.GetWindow()->GetFrameWeld(), "modules/swriter/ui/insertdbcolumnsdialog.ui", "InsertDbColumnsDialog") , ConfigItem("Office.Writer/InsertData/DataSet", ConfigItemMode::NONE) , aDBData(rData) , sNoTmpl(SwResId(SW_STR_NONE)) , pView(&rView) + , m_xRbAsTable(m_xBuilder->weld_radio_button("astable")) + , m_xRbAsField(m_xBuilder->weld_radio_button("asfields")) + , m_xRbAsText(m_xBuilder->weld_radio_button("astext")) + , m_xHeadFrame(m_xBuilder->weld_frame("dbframe")) + , m_xLbTableDbColumn(m_xBuilder->weld_tree_view("tabledbcols")) + , m_xLbTextDbColumn(m_xBuilder->weld_tree_view("tabletxtcols")) + , m_xFormatFrame(m_xBuilder->weld_frame("formatframe")) + , m_xRbDbFormatFromDb(m_xBuilder->weld_radio_button("fromdatabase")) + , m_xRbDbFormatFromUsr(m_xBuilder->weld_radio_button("userdefined")) + , m_xLbDbFormatFromUsr(new SwNumFormatListBox(m_xBuilder->weld_combo_box("numformat"))) + , m_xIbDbcolToEdit(m_xBuilder->weld_button("toedit")) + , m_xEdDbText(m_xBuilder->weld_text_view("textview")) + , m_xFtDbParaColl(m_xBuilder->weld_label("parastylelabel")) + , m_xLbDbParaColl(m_xBuilder->weld_combo_box("parastyle")) + , m_xIbDbcolAllTo(m_xBuilder->weld_button("oneright")) + , m_xIbDbcolOneTo(m_xBuilder->weld_button("allright")) + , m_xIbDbcolOneFrom(m_xBuilder->weld_button("oneleft")) + , m_xIbDbcolAllFrom(m_xBuilder->weld_button("allleft")) + , m_xFtTableCol(m_xBuilder->weld_label("tablecolft")) + , m_xLbTableCol(m_xBuilder->weld_tree_view("tablecols")) + , m_xCbTableHeadon(m_xBuilder->weld_check_button("tableheading")) + , m_xRbHeadlColnms(m_xBuilder->weld_radio_button("columnname")) + , m_xRbHeadlEmpty(m_xBuilder->weld_radio_button("rowonly")) + , m_xPbTableFormat(m_xBuilder->weld_button("tableformat")) + , m_xPbTableAutofmt(m_xBuilder->weld_button("autoformat")) { - get(m_pRbAsTable, "astable"); - get(m_pRbAsField, "asfields"); - get(m_pRbAsText, "astext"); - get(m_pHeadFrame, "dbframe"); - get(m_pLbTableDbColumn, "tabledbcols"); - get(m_pLbTextDbColumn, "tabletxtcols"); - m_pLbTableDbColumn->SetDropDownLineCount(8); - m_pLbTextDbColumn->SetDropDownLineCount(8); - get(m_pFormatFrame, "formatframe"); - get(m_pRbDbFormatFromDb, "fromdatabase"); - get(m_pRbDbFormatFromUsr, "userdefined"); - get(m_pLbDbFormatFromUsr, "numformat"); - aOldNumFormatLnk = m_pLbDbFormatFromUsr->GetSelectHdl(); - get(m_pIbDbcolToEdit, "toedit"); - get(m_pEdDbText, "textview"); - m_pEdDbText->set_width_request(m_pEdDbText->approximate_char_width() * 46); - get(m_pFtDbParaColl, "parastylelabel"); - get(m_pLbDbParaColl, "parastyle"); - m_pLbDbParaColl->SetStyle(m_pLbDbParaColl->GetStyle() | WB_SORT); - get(m_pIbDbcolAllTo, "oneright"); - get(m_pIbDbcolOneTo, "allright"); - get(m_pIbDbcolOneFrom, "oneleft"); - get(m_pIbDbcolAllFrom, "allleft"); - get(m_pFtTableCol, "tablecolft"); - get(m_pLbTableCol, "tablecols"); - m_pLbTableCol->SetDropDownLineCount(8); - get(m_pCbTableHeadon, "tableheading"); - get(m_pRbHeadlColnms, "columnname"); - get(m_pRbHeadlEmpty, "rowonly"); - get(m_pPbTableFormat, "tableformat"); - get(m_pPbTableAutofmt, "autoformat"); - - nGBFormatLen = m_pFormatFrame->get_label().getLength(); - - if(xColSupp.is()) + m_xEdDbText->set_size_request(m_xEdDbText->get_approximate_digit_width() * 40, -1); + m_xLbDbParaColl->make_sorted(); + + nGBFormatLen = m_xFormatFrame->get_label().getLength(); + + if (xColSupp.is()) { SwWrtShell& rSh = pView->GetWrtShell(); SvNumberFormatter* pNumFormatr = rSh.GetNumberFormatter(); @@ -327,268 +322,245 @@ SwInsertDBColAutoPilot::SwInsertDBColAutoPilot( SwView& rView, { SfxStyleSheetBasePool* pPool = pView->GetDocShell()->GetStyleSheetPool(); pPool->SetSearchMask( SfxStyleFamily::Para ); - m_pLbDbParaColl->InsertEntry( sNoTmpl ); + m_xLbDbParaColl->append_text( sNoTmpl ); const SfxStyleSheetBase* pBase = pPool->First(); while( pBase ) { - m_pLbDbParaColl->InsertEntry( pBase->GetName() ); + m_xLbDbParaColl->append_text( pBase->GetName() ); pBase = pPool->Next(); } - m_pLbDbParaColl->SelectEntryPos( 0 ); + m_xLbDbParaColl->set_active( 0 ); } // when the cursor is inside of a table, table must NEVER be selectable if( pView->GetWrtShell().GetTableFormat() ) { - m_pRbAsTable->Enable( false ); - m_pRbAsField->Check(); - m_pRbDbFormatFromDb->Check(); + m_xRbAsTable->set_sensitive( false ); + m_xRbAsField->set_active(true); + m_xRbDbFormatFromDb->set_active(true); } else { - m_pRbAsTable->Check(); - m_pRbDbFormatFromDb->Check(); - m_pIbDbcolOneFrom->Enable( false ); - m_pIbDbcolAllFrom->Enable( false ); + m_xRbAsTable->set_active(true); + m_xRbDbFormatFromDb->set_active(true); + m_xIbDbcolOneFrom->set_sensitive( false ); + m_xIbDbcolAllFrom->set_sensitive( false ); } // by default, select header button - m_pRbHeadlColnms->Check(); - m_pRbHeadlEmpty->Check(false); + m_xRbHeadlColnms->set_active(true); + m_xRbHeadlEmpty->set_active(false); - m_pRbAsTable->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, PageHdl )); - m_pRbAsField->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, PageHdl )); - m_pRbAsText->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, PageHdl )); + m_xRbAsTable->connect_clicked( LINK(this, SwInsertDBColAutoPilot, PageHdl )); + m_xRbAsField->connect_clicked( LINK(this, SwInsertDBColAutoPilot, PageHdl )); + m_xRbAsText->connect_clicked( LINK(this, SwInsertDBColAutoPilot, PageHdl )); - m_pRbDbFormatFromDb->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, DBFormatHdl )); - m_pRbDbFormatFromUsr->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, DBFormatHdl )); + m_xRbDbFormatFromDb->connect_clicked( LINK(this, SwInsertDBColAutoPilot, DBFormatHdl )); + m_xRbDbFormatFromUsr->connect_clicked( LINK(this, SwInsertDBColAutoPilot, DBFormatHdl )); - m_pPbTableFormat->SetClickHdl(LINK(this, SwInsertDBColAutoPilot, TableFormatHdl )); - m_pPbTableAutofmt->SetClickHdl(LINK(this, SwInsertDBColAutoPilot, AutoFormatHdl )); + m_xPbTableFormat->connect_clicked(LINK(this, SwInsertDBColAutoPilot, TableFormatHdl )); + m_xPbTableAutofmt->connect_clicked(LINK(this, SwInsertDBColAutoPilot, AutoFormatHdl )); - m_pIbDbcolAllTo->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl )); - m_pIbDbcolOneTo->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl )); - m_pIbDbcolOneFrom->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl )); - m_pIbDbcolAllFrom->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl )); - m_pIbDbcolToEdit->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl )); + m_xIbDbcolAllTo->connect_clicked( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl )); + m_xIbDbcolOneTo->connect_clicked( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl )); + m_xIbDbcolOneFrom->connect_clicked( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl )); + m_xIbDbcolAllFrom->connect_clicked( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl )); + m_xIbDbcolToEdit->connect_clicked( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl )); - m_pCbTableHeadon->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, HeaderHdl )); - m_pRbHeadlColnms->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, HeaderHdl )); - m_pRbHeadlEmpty->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, HeaderHdl )); + m_xCbTableHeadon->connect_clicked( LINK(this, SwInsertDBColAutoPilot, HeaderHdl )); + m_xRbHeadlColnms->connect_clicked( LINK(this, SwInsertDBColAutoPilot, HeaderHdl )); + m_xRbHeadlEmpty->connect_clicked( LINK(this, SwInsertDBColAutoPilot, HeaderHdl )); - m_pLbTextDbColumn->SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl )); - m_pLbTableDbColumn->SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl )); - m_pLbDbFormatFromUsr->SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl )); - m_pLbTableCol->SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl )); + m_xLbTextDbColumn->connect_changed( LINK( this, SwInsertDBColAutoPilot, TVSelectHdl )); + m_xLbTableDbColumn->connect_changed( LINK( this, SwInsertDBColAutoPilot, TVSelectHdl )); + m_xLbDbFormatFromUsr->connect_changed( LINK( this, SwInsertDBColAutoPilot, CBSelectHdl )); + m_xLbTableCol->connect_changed( LINK( this, SwInsertDBColAutoPilot, TVSelectHdl )); - m_pLbTextDbColumn->SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot, DblClickHdl )); - m_pLbTableDbColumn->SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot, DblClickHdl )); - m_pLbTableCol->SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot, DblClickHdl )); + m_xLbTextDbColumn->connect_row_activated( LINK( this, SwInsertDBColAutoPilot, DblClickHdl )); + m_xLbTableDbColumn->connect_row_activated( LINK( this, SwInsertDBColAutoPilot, DblClickHdl )); + m_xLbTableCol->connect_row_activated( LINK( this, SwInsertDBColAutoPilot, DblClickHdl )); for( size_t n = 0; n < aDBColumns.size(); ++n ) { const OUString& rS = aDBColumns[ n ]->sColumn; - m_pLbTableDbColumn->InsertEntry( rS, static_cast<sal_Int32>(n) ); - m_pLbTextDbColumn->InsertEntry( rS, static_cast<sal_Int32>(n) ); + m_xLbTableDbColumn->append_text(rS); + m_xLbTextDbColumn->append_text(rS); } - m_pLbTextDbColumn->SelectEntryPos( 0 ); - m_pLbTableDbColumn->SelectEntryPos( 0 ); + m_xLbTextDbColumn->select(0); + m_xLbTableDbColumn->select(0); // read configuration Load(); // lock size to widest config - m_pHeadFrame->set_width_request(m_pHeadFrame->get_preferred_size().Width()); + m_xHeadFrame->set_size_request(m_xHeadFrame->get_preferred_size().Width(), -1); // initialise Controls: - PageHdl( m_pRbAsTable->IsChecked() ? m_pRbAsTable : m_pRbAsField ); + PageHdl(m_xRbAsTable->get_active() ? *m_xRbAsTable : *m_xRbAsField); } SwInsertDBColAutoPilot::~SwInsertDBColAutoPilot() { - disposeOnce(); -} - -void SwInsertDBColAutoPilot::dispose() -{ - pTableSet.reset(); - pRep.reset(); - - m_xTAutoFormat.reset(); - m_pRbAsTable.clear(); - m_pRbAsField.clear(); - m_pRbAsText.clear(); - m_pHeadFrame.clear(); - m_pLbTableDbColumn.clear(); - m_pLbTextDbColumn.clear(); - m_pFormatFrame.clear(); - m_pRbDbFormatFromDb.clear(); - m_pRbDbFormatFromUsr.clear(); - m_pLbDbFormatFromUsr.clear(); - m_pIbDbcolToEdit.clear(); - m_pEdDbText.clear(); - m_pFtDbParaColl.clear(); - m_pLbDbParaColl.clear(); - m_pIbDbcolAllTo.clear(); - m_pIbDbcolOneTo.clear(); - m_pIbDbcolOneFrom.clear(); - m_pIbDbcolAllFrom.clear(); - m_pFtTableCol.clear(); - m_pLbTableCol.clear(); - m_pCbTableHeadon.clear(); - m_pRbHeadlColnms.clear(); - m_pRbHeadlEmpty.clear(); - m_pPbTableFormat.clear(); - m_pPbTableAutofmt.clear(); - SfxModalDialog::dispose(); } -IMPL_LINK( SwInsertDBColAutoPilot, PageHdl, Button*, pButton, void ) +IMPL_LINK( SwInsertDBColAutoPilot, PageHdl, weld::Button&, rButton, void ) { - bool bShowTable = pButton == m_pRbAsTable; - - m_pHeadFrame->set_label(MnemonicGenerator::EraseAllMnemonicChars(pButton->GetText())); - - m_pLbTextDbColumn->Show( !bShowTable ); - m_pIbDbcolToEdit->Show( !bShowTable ); - m_pEdDbText->Show( !bShowTable ); - m_pFtDbParaColl->Show( !bShowTable ); - m_pLbDbParaColl->Show( !bShowTable ); - - m_pLbTableDbColumn->Show( bShowTable ); - m_pIbDbcolAllTo->Show( bShowTable ); - m_pIbDbcolOneTo->Show( bShowTable ); - m_pIbDbcolOneFrom->Show( bShowTable ); - m_pIbDbcolAllFrom->Show( bShowTable ); - m_pFtTableCol->Show( bShowTable ); - m_pLbTableCol->Show( bShowTable ); - m_pCbTableHeadon->Show( bShowTable ); - m_pRbHeadlColnms->Show( bShowTable ); - m_pRbHeadlEmpty->Show( bShowTable ); - m_pPbTableFormat->Show( bShowTable ); - m_pPbTableAutofmt->Show( bShowTable ); + bool bShowTable = &rButton == m_xRbAsTable.get(); + + m_xHeadFrame->set_label(MnemonicGenerator::EraseAllMnemonicChars(rButton.get_label().replace('_', '~'))); + + m_xLbTextDbColumn->show( !bShowTable ); + m_xIbDbcolToEdit->show( !bShowTable ); + m_xEdDbText->show( !bShowTable ); + m_xFtDbParaColl->show( !bShowTable ); + m_xLbDbParaColl->show( !bShowTable ); + + m_xLbTableDbColumn->show( bShowTable ); + m_xIbDbcolAllTo->show( bShowTable ); + m_xIbDbcolOneTo->show( bShowTable ); + m_xIbDbcolOneFrom->show( bShowTable ); + m_xIbDbcolAllFrom->show( bShowTable ); + m_xFtTableCol->show( bShowTable ); + m_xLbTableCol->show( bShowTable ); + m_xCbTableHeadon->show( bShowTable ); + m_xRbHeadlColnms->show( bShowTable ); + m_xRbHeadlEmpty->show( bShowTable ); + m_xPbTableFormat->show( bShowTable ); + m_xPbTableAutofmt->show( bShowTable ); if( bShowTable ) - m_pPbTableFormat->Enable( 0 != m_pLbTableCol->GetEntryCount() ); + m_xPbTableFormat->set_sensitive( 0 != m_xLbTableCol->n_children() ); - SelectHdl( bShowTable ? *m_pLbTableDbColumn : *m_pLbTextDbColumn ); + TVSelectHdl( bShowTable ? *m_xLbTableDbColumn : *m_xLbTextDbColumn ); } -IMPL_LINK( SwInsertDBColAutoPilot, DBFormatHdl, Button*, pButton, void ) +IMPL_LINK( SwInsertDBColAutoPilot, DBFormatHdl, weld::Button&, rButton, void ) { - ListBox& rBox = m_pRbAsTable->IsChecked() - ? ( nullptr == m_pLbTableCol->GetEntryData( 0 ) - ? *m_pLbTableDbColumn - : *m_pLbTableCol ) - : *m_pLbTextDbColumn; + weld::TreeView& rBox = m_xRbAsTable->get_active() + ? ( m_xLbTableCol->get_id(0).isEmpty() + ? *m_xLbTableDbColumn + : *m_xLbTableCol ) + : *m_xLbTextDbColumn; - SwInsDBColumn aSrch( rBox.GetSelectedEntry() ); + SwInsDBColumn aSrch(rBox.get_selected_text()); SwInsDBColumns::const_iterator it = aDBColumns.find( &aSrch ); - bool bFromDB = m_pRbDbFormatFromDb == pButton; + bool bFromDB = m_xRbDbFormatFromDb.get() == &rButton; (*it)->bIsDBFormat = bFromDB; - m_pLbDbFormatFromUsr->Enable( !bFromDB ); + m_xLbDbFormatFromUsr->set_sensitive( !bFromDB ); } -IMPL_LINK( SwInsertDBColAutoPilot, TableToFromHdl, Button*, pButton, void ) +IMPL_LINK( SwInsertDBColAutoPilot, TableToFromHdl, weld::Button&, rButton, void ) { bool bChgEnable = true, bEnableTo = true, bEnableFrom = true; - m_pLbTableDbColumn->SetUpdateMode( false ); - m_pLbTableCol->SetUpdateMode( false ); - if( pButton == m_pIbDbcolAllTo ) + if( &rButton == m_xIbDbcolAllTo.get() ) { bEnableTo = false; - sal_Int32 n, nInsPos = m_pLbTableCol->GetSelectedEntryPos(), - nCnt = m_pLbTableDbColumn->GetEntryCount(); - if( LISTBOX_APPEND == nInsPos ) + sal_Int32 n, nInsPos = m_xLbTableCol->get_selected_index(), + nCnt = m_xLbTableDbColumn->n_children(); + + m_xLbTableDbColumn->unselect_all(); + + m_xLbTableDbColumn->freeze(); + m_xLbTableCol->freeze(); + + if (nInsPos == -1) for( n = 0; n < nCnt; ++n ) - m_pLbTableCol->InsertEntry( m_pLbTableDbColumn->GetEntry( n ) ); + m_xLbTableCol->append_text(m_xLbTableDbColumn->get_text(n)); else for( n = 0; n < nCnt; ++n, ++nInsPos ) - m_pLbTableCol->InsertEntry( m_pLbTableDbColumn->GetEntry( n ), nInsPos ); - m_pLbTableDbColumn->Clear(); - m_pLbTableCol->SelectEntryPos( nInsPos ); - m_pLbTableDbColumn->SelectEntryPos( LISTBOX_APPEND ); + m_xLbTableCol->insert_text(nInsPos, m_xLbTableDbColumn->get_text(n)); + m_xLbTableDbColumn->clear(); + + m_xLbTableDbColumn->thaw(); + m_xLbTableCol->thaw(); + + m_xLbTableCol->select(nInsPos); } - else if( pButton == m_pIbDbcolOneTo && - LISTBOX_ENTRY_NOTFOUND != m_pLbTableDbColumn->GetSelectedEntryPos() ) + else if( &rButton == m_xIbDbcolOneTo.get() && + m_xLbTableDbColumn->get_selected_index() != -1 ) { - sal_Int32 nInsPos = m_pLbTableCol->GetSelectedEntryPos(), - nDelPos = m_pLbTableDbColumn->GetSelectedEntryPos(), - nTopPos = m_pLbTableDbColumn->GetTopEntry(); - m_pLbTableCol->InsertEntry( m_pLbTableDbColumn->GetEntry( nDelPos ), nInsPos ); - m_pLbTableDbColumn->RemoveEntry( nDelPos ); - - m_pLbTableCol->SelectEntryPos( nInsPos ); - if( nDelPos >= m_pLbTableDbColumn->GetEntryCount() ) - nDelPos = m_pLbTableDbColumn->GetEntryCount() - 1; - m_pLbTableDbColumn->SelectEntryPos( nDelPos ); - m_pLbTableDbColumn->SetTopEntry( nTopPos ); - - bEnableTo = 0 != m_pLbTableDbColumn->GetEntryCount(); + sal_Int32 nInsPos = m_xLbTableCol->get_selected_index(), + nDelPos = m_xLbTableDbColumn->get_selected_index(); + m_xLbTableCol->insert_text(nInsPos, m_xLbTableDbColumn->get_text(nDelPos)); + m_xLbTableDbColumn->remove(nDelPos); + + m_xLbTableCol->select(nInsPos); + if (nDelPos >= m_xLbTableDbColumn->n_children()) + nDelPos = m_xLbTableDbColumn->n_children() - 1; + m_xLbTableDbColumn->select(nDelPos); + + bEnableTo = 0 != m_xLbTableDbColumn->n_children(); } - else if( pButton == m_pIbDbcolOneFrom ) + else if( &rButton == m_xIbDbcolOneFrom.get() ) { - if( LISTBOX_ENTRY_NOTFOUND != m_pLbTableCol->GetSelectedEntryPos() ) + if (m_xLbTableCol->get_selected_index() != -1) { sal_Int32 nInsPos, - nDelPos = m_pLbTableCol->GetSelectedEntryPos(), - nTopPos = m_pLbTableCol->GetTopEntry(); + nDelPos = m_xLbTableCol->get_selected_index(); // look for the right InsertPos!! - SwInsDBColumn aSrch( m_pLbTableCol->GetEntry( nDelPos ) ); + SwInsDBColumn aSrch(m_xLbTableCol->get_text(nDelPos)); SwInsDBColumns::const_iterator it = aDBColumns.find( &aSrch ); if( it == aDBColumns.begin() || (it+1) == aDBColumns.end() ) nInsPos = it - aDBColumns.begin(); else { - nInsPos = LISTBOX_ENTRY_NOTFOUND; + nInsPos = -1; while( ++it != aDBColumns.end() && - LISTBOX_ENTRY_NOTFOUND == (nInsPos = m_pLbTableDbColumn-> - GetEntryPos( (*it)->sColumn )) ) + -1 == (nInsPos = m_xLbTableDbColumn-> + find_text( (*it)->sColumn )) ) ; } - m_pLbTableDbColumn->InsertEntry( aSrch.sColumn, nInsPos ); - m_pLbTableCol->RemoveEntry( nDelPos ); + m_xLbTableDbColumn->insert_text(nInsPos, aSrch.sColumn); + m_xLbTableCol->remove( nDelPos ); - if( nInsPos >= m_pLbTableDbColumn->GetEntryCount() ) - nInsPos = m_pLbTableDbColumn->GetEntryCount() - 1; - m_pLbTableDbColumn->SelectEntryPos( nInsPos ); + if (nInsPos >= m_xLbTableDbColumn->n_children()) + nInsPos = m_xLbTableDbColumn->n_children() - 1; + m_xLbTableDbColumn->select(nInsPos); - if( nDelPos >= m_pLbTableCol->GetEntryCount() ) - nDelPos = m_pLbTableCol->GetEntryCount() - 1; - m_pLbTableCol->SelectEntryPos( nDelPos ); - m_pLbTableCol->SetTopEntry( nTopPos ); + if (nDelPos >= m_xLbTableCol->n_children()) + nDelPos = m_xLbTableCol->n_children() - 1; + m_xLbTableCol->select(nDelPos); } else - bEnableTo = 0 != m_pLbTableDbColumn->GetEntryCount(); + bEnableTo = 0 != m_xLbTableDbColumn->n_children(); - bEnableFrom = 0 != m_pLbTableCol->GetEntryCount(); + bEnableFrom = 0 != m_xLbTableCol->n_children(); } - else if( pButton == m_pIbDbcolAllFrom ) + else if( &rButton == m_xIbDbcolAllFrom.get() ) { bEnableFrom = false; - m_pLbTableDbColumn->Clear(); - m_pLbTableCol->Clear(); - for( size_t n = 0; n < aDBColumns.size(); ++n ) - m_pLbTableDbColumn->InsertEntry( aDBColumns[ n ]->sColumn, - static_cast<sal_Int32>(n) ); - m_pLbTableDbColumn->SelectEntryPos( 0 ); + m_xLbTableDbColumn->freeze(); + m_xLbTableCol->freeze(); + + m_xLbTableDbColumn->clear(); + m_xLbTableCol->clear(); + for (size_t n = 0; n < aDBColumns.size(); ++n) + m_xLbTableDbColumn->append_text(aDBColumns[n]->sColumn); + + m_xLbTableDbColumn->thaw(); + m_xLbTableCol->thaw(); + + m_xLbTableDbColumn->select(0); } - else if( pButton == m_pIbDbcolToEdit ) + else if( &rButton == m_xIbDbcolToEdit.get() ) { bChgEnable = false; // move data to Edit: - OUString aField( m_pLbTextDbColumn->GetSelectedEntry() ); + OUString aField(m_xLbTextDbColumn->get_selected_text()); if( !aField.isEmpty() ) { - OUString aStr( m_pEdDbText->GetText() ); - sal_Int32 nPos = static_cast<sal_Int32>(m_pEdDbText->GetSelection().Min()); - const sal_Int32 nSel = static_cast<sal_Int32>(m_pEdDbText->GetSelection().Max()) - nPos; + OUString aStr( m_xEdDbText->get_text() ); + int nStartPos, nEndPos; + m_xEdDbText->get_selection_bounds(nStartPos, nEndPos); + sal_Int32 nPos = std::min(nStartPos, nEndPos); + sal_Int32 nMax = std::max(nStartPos, nEndPos); + const sal_Int32 nSel = nMax - nPos; if( nSel ) // first delete the existing selection aStr = aStr.replaceAt( nPos, nSel, "" ); @@ -610,44 +582,42 @@ IMPL_LINK( SwInsertDBColAutoPilot, TableToFromHdl, Button*, pButton, void ) } } - m_pEdDbText->SetText( aStr.replaceAt( nPos, 0, aField ) ); + m_xEdDbText->set_text( aStr.replaceAt( nPos, 0, aField ) ); nPos += aField.getLength(); - m_pEdDbText->SetSelection( Selection( nPos )); + m_xEdDbText->select_region(nPos, nPos); } } if( bChgEnable ) { - m_pIbDbcolOneTo->Enable( bEnableTo ); - m_pIbDbcolAllTo->Enable( bEnableTo ); - m_pIbDbcolOneFrom->Enable( bEnableFrom ); - m_pIbDbcolAllFrom->Enable( bEnableFrom ); + m_xIbDbcolOneTo->set_sensitive( bEnableTo ); + m_xIbDbcolAllTo->set_sensitive( bEnableTo ); + m_xIbDbcolOneFrom->set_sensitive( bEnableFrom ); + m_xIbDbcolAllFrom->set_sensitive( bEnableFrom ); - m_pRbDbFormatFromDb->Enable( false ); - m_pRbDbFormatFromUsr->Enable( false ); - m_pLbDbFormatFromUsr->Enable( false ); + m_xRbDbFormatFromDb->set_sensitive( false ); + m_xRbDbFormatFromUsr->set_sensitive( false ); + m_xLbDbFormatFromUsr->set_sensitive( false ); - m_pPbTableFormat->Enable( bEnableFrom ); + m_xPbTableFormat->set_sensitive( bEnableFrom ); } - m_pLbTableDbColumn->SetUpdateMode( true ); - m_pLbTableCol->SetUpdateMode( true ); } -IMPL_LINK( SwInsertDBColAutoPilot, DblClickHdl, ListBox&, rBox, void ) +IMPL_LINK(SwInsertDBColAutoPilot, DblClickHdl, weld::TreeView&, rBox, void) { - Button* pButton = nullptr; - if( &rBox == m_pLbTextDbColumn ) - pButton = m_pIbDbcolToEdit; - else if( &rBox == m_pLbTableDbColumn && m_pIbDbcolOneTo->IsEnabled() ) - pButton = m_pIbDbcolOneTo; - else if( &rBox == m_pLbTableCol && m_pIbDbcolOneFrom->IsEnabled() ) - pButton = m_pIbDbcolOneFrom; - - if( pButton ) - TableToFromHdl( pButton ); + weld::Button* pButton = nullptr; + if( &rBox == m_xLbTextDbColumn.get() ) + pButton = m_xIbDbcolToEdit.get(); + else if( &rBox == m_xLbTableDbColumn.get() && m_xIbDbcolOneTo->get_sensitive() ) + pButton = m_xIbDbcolOneTo.get(); + else if( &rBox == m_xLbTableCol.get() && m_xIbDbcolOneFrom->get_sensitive() ) + pButton = m_xIbDbcolOneFrom.get(); + + if (pButton) + TableToFromHdl(*pButton); } -IMPL_LINK_NOARG(SwInsertDBColAutoPilot, TableFormatHdl, Button*, void) +IMPL_LINK_NOARG(SwInsertDBColAutoPilot, TableFormatHdl, weld::Button&, void) { SwWrtShell& rSh = pView->GetWrtShell(); bool bNewSet = false; @@ -727,7 +697,7 @@ IMPL_LINK_NOARG(SwInsertDBColAutoPilot, TableFormatHdl, Button*, void) ::GetHtmlMode( pView->GetDocShell() ))); } - sal_Int32 nCols = m_pLbTableCol->GetEntryCount(); + sal_Int32 nCols = m_xLbTableCol->n_children(); if (nCols != pRep->GetAllColCount() && nCols > 0) { // Number of columns has changed: then the TabCols have to be adjusted @@ -754,7 +724,7 @@ IMPL_LINK_NOARG(SwInsertDBColAutoPilot, TableFormatHdl, Button*, void) SwAbstractDialogFactory& rFact = swui::GetFactory(); - ScopedVclPtr<SfxAbstractTabDialog> pDlg(rFact.CreateSwTableTabDlg(GetFrameWeld(), pTableSet.get(), &rSh)); + ScopedVclPtr<SfxAbstractTabDialog> pDlg(rFact.CreateSwTableTabDlg(m_xDialog.get(), pTableSet.get(), &rSh)); if( RET_OK == pDlg->Execute() ) pTableSet->Put( *pDlg->GetOutputItemSet() ); else if( bNewSet ) @@ -764,83 +734,89 @@ IMPL_LINK_NOARG(SwInsertDBColAutoPilot, TableFormatHdl, Button*, void) } } -IMPL_LINK( SwInsertDBColAutoPilot, AutoFormatHdl, Button*, pButton, void ) +IMPL_LINK_NOARG(SwInsertDBColAutoPilot, AutoFormatHdl, weld::Button&, void) { SwAbstractDialogFactory& rFact = swui::GetFactory(); - ScopedVclPtr<AbstractSwAutoFormatDlg> pDlg(rFact.CreateSwAutoFormatDlg(pButton->GetFrameWeld(), pView->GetWrtShellPtr(), false, m_xTAutoFormat.get())); + ScopedVclPtr<AbstractSwAutoFormatDlg> pDlg(rFact.CreateSwAutoFormatDlg(m_xDialog.get(), pView->GetWrtShellPtr(), false, m_xTAutoFormat.get())); if( RET_OK == pDlg->Execute()) m_xTAutoFormat.reset(pDlg->FillAutoFormatOfIndex()); } -IMPL_LINK( SwInsertDBColAutoPilot, SelectHdl, ListBox&, rBox, void ) +IMPL_LINK(SwInsertDBColAutoPilot, TVSelectHdl, weld::TreeView&, rBox, void) { - ListBox* pGetBox = &rBox == m_pLbDbFormatFromUsr - ? ( m_pRbAsTable->IsChecked() - ? ( nullptr == m_pLbTableCol->GetEntryData( 0 ) - ? m_pLbTableDbColumn.get() - : m_pLbTableCol.get() ) - : m_pLbTextDbColumn.get() ) - : &rBox; - - SwInsDBColumn aSrch( pGetBox->GetSelectedEntry() ); + weld::TreeView* pGetBox = &rBox; + + SwInsDBColumn aSrch(pGetBox->get_selected_text()); SwInsDBColumns::const_iterator it = aDBColumns.find( &aSrch ); - if( &rBox == m_pLbDbFormatFromUsr ) + // set the selected FieldName at the FormatGroupBox, so that + // it's clear what field is configured by the format! + OUString sText( m_xFormatFrame->get_label().copy( 0, nGBFormatLen )); + if( aSrch.sColumn.isEmpty() ) { - if( !aSrch.sColumn.isEmpty() ) - { - aOldNumFormatLnk.Call( rBox ); - (*it)->nUsrNumFormat = m_pLbDbFormatFromUsr->GetFormat(); - } + m_xRbDbFormatFromDb->set_sensitive( false ); + m_xRbDbFormatFromUsr->set_sensitive( false ); + m_xLbDbFormatFromUsr->set_sensitive( false ); } else { - // set the selected FieldName at the FormatGroupBox, so that - // it's clear what field is configured by the format! - OUString sText( m_pFormatFrame->get_label().copy( 0, nGBFormatLen )); - if( aSrch.sColumn.isEmpty() ) + bool bEnableFormat = (*it)->bHasFormat; + m_xRbDbFormatFromDb->set_sensitive( bEnableFormat ); + m_xRbDbFormatFromUsr->set_sensitive( bEnableFormat ); + + if( bEnableFormat ) { - m_pRbDbFormatFromDb->Enable( false ); - m_pRbDbFormatFromUsr->Enable( false ); - m_pLbDbFormatFromUsr->Enable( false ); + sText += " (" + aSrch.sColumn + ")"; } - else - { - bool bEnableFormat = (*it)->bHasFormat; - m_pRbDbFormatFromDb->Enable( bEnableFormat ); - m_pRbDbFormatFromUsr->Enable( bEnableFormat ); - if( bEnableFormat ) - { - sText += " (" + aSrch.sColumn + ")"; - } - - bool bIsDBFormat = (*it)->bIsDBFormat; - m_pRbDbFormatFromDb->Check( bIsDBFormat ); - m_pRbDbFormatFromUsr->Check( !bIsDBFormat ); - m_pLbDbFormatFromUsr->Enable( !bIsDBFormat ); - if( !bIsDBFormat ) - m_pLbDbFormatFromUsr->SetDefFormat( (*it)->nUsrNumFormat ); - } + bool bIsDBFormat = (*it)->bIsDBFormat; + m_xRbDbFormatFromDb->set_active( bIsDBFormat ); + m_xRbDbFormatFromUsr->set_active( !bIsDBFormat ); + m_xLbDbFormatFromUsr->set_sensitive( !bIsDBFormat ); + if( !bIsDBFormat ) + m_xLbDbFormatFromUsr->SetDefFormat( (*it)->nUsrNumFormat ); + } - m_pFormatFrame->set_label(sText); + m_xFormatFrame->set_label(sText); + if (m_xLbTableCol->n_children()) + { // to know later on, what ListBox was the "active", a Flag // is remembered in the 1st entry - void* pPtr = &rBox == m_pLbTableCol ? m_pLbTableCol.get() : nullptr; - m_pLbTableCol->SetEntryData( 0, pPtr ); + if (&rBox == m_xLbTableCol.get()) + m_xLbTableCol->set_id(0, "tablecols"); + else + m_xLbTableCol->set_id(0, OUString()); + } +} + +IMPL_LINK_NOARG(SwInsertDBColAutoPilot, CBSelectHdl, weld::ComboBox&, void) +{ + weld::TreeView* pGetBox = m_xRbAsTable->get_active() + ? ( m_xLbTableCol->get_id(0).isEmpty() + ? m_xLbTableDbColumn.get() + : m_xLbTableCol.get() ) + : m_xLbTextDbColumn.get(); + + SwInsDBColumn aSrch(pGetBox->get_selected_text()); + SwInsDBColumns::const_iterator it = aDBColumns.find( &aSrch ); + + if( !aSrch.sColumn.isEmpty() ) + { + m_xLbDbFormatFromUsr->CallSelectHdl(); + (*it)->nUsrNumFormat = m_xLbDbFormatFromUsr->GetFormat(); } } -IMPL_LINK( SwInsertDBColAutoPilot, HeaderHdl, Button*, pButton, void ) +IMPL_LINK( SwInsertDBColAutoPilot, HeaderHdl, weld::Button&, rButton, void ) { - if( pButton == m_pCbTableHeadon ) + if (&rButton == m_xCbTableHeadon.get()) { - bool bEnable = m_pCbTableHeadon->IsChecked(); + bool bEnable = m_xCbTableHeadon->get_active(); - m_pRbHeadlColnms->Enable( bEnable ); - m_pRbHeadlEmpty->Enable( bEnable ); + m_xRbHeadlColnms->set_sensitive( bEnable ); + m_xRbHeadlEmpty->set_sensitive( bEnable ); } } @@ -966,7 +942,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, if( bUndo ) rSh.StartUndo(); - bool bAsTable = m_pRbAsTable->IsChecked(); + bool bAsTable = m_xRbAsTable->get_active(); SvNumberFormatter& rNumFormatr = *rSh.GetNumberFormatter(); if( rSh.HasSelection() ) @@ -990,9 +966,9 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, { rSh.DoUndo( false ); - sal_Int32 nCols = m_pLbTableCol->GetEntryCount(); + sal_Int32 nCols = m_xLbTableCol->n_children(); sal_Int32 nRows = 0; - if( m_pCbTableHeadon->IsChecked() ) + if( m_xCbTableHeadon->get_active() ) nRows++; if( pSelection ) @@ -1004,7 +980,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, std::vector<SwInsDBColumn*> aColFields; for( sal_Int32 n = 0; n < nCols; ++n ) { - SwInsDBColumn aSrch( m_pLbTableCol->GetEntry( n ) ); + SwInsDBColumn aSrch(m_xLbTableCol->get_text(n)); SwInsDBColumns::const_iterator it = aDBColumns.find( &aSrch ); if (it != aDBColumns.end()) aColFields.push_back(it->get()); @@ -1041,11 +1017,11 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, bool bIsAutoUpdateCells = rSh.IsAutoUpdateCells(); rSh.SetAutoUpdateCells( false ); - if( m_pCbTableHeadon->IsChecked() ) + if( m_xCbTableHeadon->get_active() ) { for( sal_Int32 n = 0; n < nCols; ++n ) { - if( m_pRbHeadlColnms->IsChecked() ) + if( m_xRbHeadlColnms->get_active() ) { rSh.SwEditShell::Insert2( aColFields[ n ]->sColumn ); } @@ -1188,7 +1164,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, else // add data as fields/text { DB_Columns aColArr; - if( SplitTextToColArr( m_pEdDbText->GetText(), aColArr, m_pRbAsField->IsChecked() ) ) + if( SplitTextToColArr( m_xEdDbText->get_text(), aColArr, m_xRbAsField->get_active() ) ) { // now for each data set, we can iterate over the array // and add the data @@ -1205,7 +1181,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, SwTextFormatColl* pColl = nullptr; { - const OUString sTmplNm( m_pLbDbParaColl->GetSelectedEntry() ); + const OUString sTmplNm(m_xLbDbParaColl->get_active_text()); if( sNoTmpl != sTmplNm ) { pColl = rSh.FindTextFormatCollByName( sTmplNm ); @@ -1397,7 +1373,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, else if( i+1 >= rSelection.getLength() ) break; - if( m_pRbAsField->IsChecked() ) + if( m_xRbAsField->get_active() ) rSh.Insert( aNxtDBField ); if( !rSh.IsSttPara() ) @@ -1567,26 +1543,26 @@ void SwInsertDBColAutoPilot::ImplCommit() pValues[0].Value <<= aDBData.sDataSource; pValues[1].Value <<= aDBData.sCommand; pValues[2].Value <<= aDBData.nCommandType; - pValues[3].Value <<= m_pEdDbText->GetText(); + pValues[3].Value <<= m_xEdDbText->get_text(); OUString sTmp; - const sal_Int32 nCnt = m_pLbTableCol->GetEntryCount(); + const sal_Int32 nCnt = m_xLbTableCol->n_children(); for( sal_Int32 n = 0; n < nCnt; ++n ) - sTmp += m_pLbTableCol->GetEntry(n) + "\x0a"; + sTmp += m_xLbTableCol->get_text(n) + "\x0a"; if (!sTmp.isEmpty()) pValues[4].Value <<= sTmp; - if( sNoTmpl != (sTmp = m_pLbDbParaColl->GetSelectedEntry()) ) + if( sNoTmpl != (sTmp = m_xLbDbParaColl->get_active_text()) ) pValues[5].Value <<= sTmp; if (m_xTAutoFormat) pValues[6].Value <<= m_xTAutoFormat->GetName(); - pValues[7].Value <<= m_pRbAsTable->IsChecked(); - pValues[8].Value <<= m_pRbAsField->IsChecked(); - pValues[9].Value <<= m_pCbTableHeadon->IsChecked(); - pValues[10].Value <<= m_pRbHeadlEmpty->IsChecked(); + pValues[7].Value <<= m_xRbAsTable->get_active(); + pValues[8].Value <<= m_xRbAsField->get_active(); + pValues[9].Value <<= m_xCbTableHeadon->get_active(); + pValues[10].Value <<= m_xRbHeadlEmpty->get_active(); SetSetProperties(OUString(), aValues); @@ -1735,28 +1711,28 @@ void SwInsertDBColAutoPilot::Load() do { const OUString sEntry( sTmp.getToken( 0, '\x0a', n ) ); //preselect column - if they still exist! - if(m_pLbTableDbColumn->GetEntryPos(sEntry) != LISTBOX_ENTRY_NOTFOUND) + if (m_xLbTableDbColumn->find_text(sEntry) != -1) { - m_pLbTableCol->InsertEntry( sEntry ); - m_pLbTableDbColumn->RemoveEntry( sEntry ); + m_xLbTableCol->append_text(sEntry); + m_xLbTableDbColumn->remove_text(sEntry); } } while( n>=0 ); - if( !m_pLbTableDbColumn->GetEntryCount() ) + if (!m_xLbTableDbColumn->n_children()) { - m_pIbDbcolAllTo->Enable( false ); - m_pIbDbcolOneTo->Enable( false ); + m_xIbDbcolAllTo->set_sensitive( false ); + m_xIbDbcolOneTo->set_sensitive( false ); } - m_pIbDbcolOneFrom->Enable(); - m_pIbDbcolAllFrom->Enable(); + m_xIbDbcolOneFrom->set_sensitive(true); + m_xIbDbcolAllFrom->set_sensitive(true); } - m_pEdDbText->SetText( pNewData->sEdit ); + m_xEdDbText->set_text( pNewData->sEdit ); sTmp = pNewData->sTmplNm; if( !sTmp.isEmpty() ) - m_pLbDbParaColl->SelectEntry( sTmp ); + m_xLbDbParaColl->set_active_text(sTmp); else - m_pLbDbParaColl->SelectEntryPos( 0 ); + m_xLbDbParaColl->set_active(0); m_xTAutoFormat.reset(); sTmp = pNewData->sTAutoFormatNm; @@ -1773,14 +1749,14 @@ void SwInsertDBColAutoPilot::Load() } } - m_pRbAsTable->Check( pNewData->bIsTable ); - m_pRbAsField->Check( pNewData->bIsField ); - m_pRbAsText->Check( !pNewData->bIsTable && !pNewData->bIsField ); + m_xRbAsTable->set_active( pNewData->bIsTable ); + m_xRbAsField->set_active( pNewData->bIsField ); + m_xRbAsText->set_active( !pNewData->bIsTable && !pNewData->bIsField ); - m_pCbTableHeadon->Check( pNewData->bIsHeadlineOn ); - m_pRbHeadlColnms->Check( !pNewData->bIsEmptyHeadln ); - m_pRbHeadlEmpty->Check( pNewData->bIsEmptyHeadln ); - HeaderHdl(m_pCbTableHeadon); + m_xCbTableHeadon->set_active( pNewData->bIsHeadlineOn ); + m_xRbHeadlColnms->set_active( !pNewData->bIsEmptyHeadln ); + m_xRbHeadlEmpty->set_active( pNewData->bIsEmptyHeadln ); + HeaderHdl(*m_xCbTableHeadon); // now copy the user defined Numberformat strings to the // Shell. Then only these are available as ID @@ -1811,8 +1787,8 @@ void SwInsertDBColAutoPilot::Load() } // when the cursor is inside of a table, table must NEVER be selectable - if( !m_pRbAsTable->IsEnabled() && m_pRbAsTable->IsChecked() ) - m_pRbAsField->Check(); + if( !m_xRbAsTable->get_sensitive() && m_xRbAsTable->get_active() ) + m_xRbAsField->set_active(true); break; } } diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index b60c775de055..378850eec989 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -166,7 +166,10 @@ short AbstractSwConvertTableDlg_Impl::Execute() return m_xDlg->run(); } -IMPL_ABSTDLG_BASE(AbstractSwInsertDBColAutoPilot_Impl); +short AbstractSwInsertDBColAutoPilot_Impl::Execute() +{ + return m_xDlg->run(); +} short AbstractDropDownFieldDialog_Impl::Execute() { @@ -359,7 +362,7 @@ void AbstractSwInsertDBColAutoPilot_Impl::DataToDoc( const uno::Sequence< uno::A uno::Reference< sdbc::XResultSet > xResultSet) { #if HAVE_FEATURE_DBCONNECTIVITY - pDlg->DataToDoc(rSelection, rxSource, xConnection, xResultSet); + m_xDlg->DataToDoc(rSelection, rxSource, xConnection, xResultSet); #else (void) rSelection; (void) rxSource; @@ -762,7 +765,7 @@ VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwBackgroundDialog return VclPtr<SwAbstractSfxController_Impl>::Create(std::make_unique<SwBackgroundDlg>(pParent, rSet)); } -VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateNumFormatDialog(weld::Window* pParent, const SfxItemSet& rSet) +VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateNumFormatDialog(weld::Widget* pParent, const SfxItemSet& rSet) { return VclPtr<SwAbstractSfxController_Impl>::Create(std::make_unique<SwNumFormatDlg>(pParent, rSet)); } @@ -818,8 +821,7 @@ VclPtr<AbstractSwInsertDBColAutoPilot> SwAbstractDialogFactory_Impl::CreateSwIns const SwDBData& rData) { #if HAVE_FEATURE_DBCONNECTIVITY - VclPtr<SwInsertDBColAutoPilot> pDlg = VclPtr<SwInsertDBColAutoPilot>::Create( rView, rxSource, xColSupp, rData ); - return VclPtr<AbstractSwInsertDBColAutoPilot_Impl>::Create( pDlg ); + return VclPtr<AbstractSwInsertDBColAutoPilot_Impl>::Create(std::make_unique<SwInsertDBColAutoPilot>(rView, rxSource, xColSupp, rData)); #else (void) rView; (void) rxSource; diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 9888b1632dc4..ee6e32ccb306 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -271,7 +271,13 @@ public: class AbstractSwInsertDBColAutoPilot_Impl : public AbstractSwInsertDBColAutoPilot { - DECL_ABSTDLG_BASE( AbstractSwInsertDBColAutoPilot_Impl,SwInsertDBColAutoPilot) + std::unique_ptr<SwInsertDBColAutoPilot> m_xDlg; +public: + explicit AbstractSwInsertDBColAutoPilot_Impl(std::unique_ptr<SwInsertDBColAutoPilot> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; virtual void DataToDoc( const css::uno::Sequence< css::uno::Any >& rSelection, css::uno::Reference< css::sdbc::XDataSource> rxSource, css::uno::Reference< css::sdbc::XConnection> xConnection, @@ -576,7 +582,7 @@ class SwAbstractDialogFactory_Impl : public SwAbstractDialogFactory public: virtual ~SwAbstractDialogFactory_Impl() {} - virtual VclPtr<SfxAbstractDialog> CreateNumFormatDialog(weld::Window* pParent, const SfxItemSet& rAttr) override; + virtual VclPtr<SfxAbstractDialog> CreateNumFormatDialog(weld::Widget* pParent, const SfxItemSet& rAttr) override; virtual VclPtr<SfxAbstractDialog> CreateSwDropCapsDialog(weld::Window* pParent, const SfxItemSet& rSet) override; virtual VclPtr<SfxAbstractDialog> CreateSwBackgroundDialog(weld::Window* pParent, const SfxItemSet& rSet) override; virtual VclPtr<AbstractSwWordCountFloatDlg> CreateSwWordCountDialog(SfxBindings* pBindings, diff --git a/sw/source/uibase/inc/dbinsdlg.hxx b/sw/source/uibase/inc/dbinsdlg.hxx index dd5b52e1b4bd..37053e036596 100644 --- a/sw/source/uibase/inc/dbinsdlg.hxx +++ b/sw/source/uibase/inc/dbinsdlg.hxx @@ -20,12 +20,7 @@ #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_DBINSDLG_HXX #define INCLUDED_SW_SOURCE_UIBASE_INC_DBINSDLG_HXX -#include <vcl/button.hxx> -#include <vcl/fixed.hxx> -#include <vcl/edit.hxx> -#include <vcl/layout.hxx> -#include <vcl/lstbox.hxx> -#include <svtools/svmedit.hxx> +#include <vcl/weld.hxx> #include <sfx2/basedlgs.hxx> #include <unotools/configitem.hxx> #include "numfmtlb.hxx" @@ -81,45 +76,11 @@ class SwInsDBColumns : public o3tl::sorted_vector<std::unique_ptr<SwInsDBColumn> { }; -class SwInsertDBColAutoPilot : public SfxModalDialog, public utl::ConfigItem +class SwInsertDBColAutoPilot : public SfxDialogController, public utl::ConfigItem { - VclPtr<RadioButton> m_pRbAsTable; - VclPtr<RadioButton> m_pRbAsField; - VclPtr<RadioButton> m_pRbAsText; - - VclPtr<VclFrame> m_pHeadFrame; - - VclPtr<ListBox> m_pLbTableDbColumn; - VclPtr<ListBox> m_pLbTextDbColumn; - - VclPtr<VclFrame> m_pFormatFrame; - VclPtr<RadioButton> m_pRbDbFormatFromDb; - VclPtr<RadioButton> m_pRbDbFormatFromUsr; - VclPtr<NumFormatListBox> m_pLbDbFormatFromUsr; - - // Page Text/Field - VclPtr<PushButton> m_pIbDbcolToEdit; - VclPtr<VclMultiLineEdit> m_pEdDbText; - VclPtr<FixedText> m_pFtDbParaColl; - VclPtr<ListBox> m_pLbDbParaColl; - - // Page Table - VclPtr<PushButton> m_pIbDbcolAllTo; - VclPtr<PushButton> m_pIbDbcolOneTo; - VclPtr<PushButton> m_pIbDbcolOneFrom; - VclPtr<PushButton> m_pIbDbcolAllFrom; - VclPtr<FixedText> m_pFtTableCol; - VclPtr<ListBox> m_pLbTableCol; - VclPtr<CheckBox> m_pCbTableHeadon; - VclPtr<RadioButton> m_pRbHeadlColnms; - VclPtr<RadioButton> m_pRbHeadlEmpty; - VclPtr<PushButton> m_pPbTableFormat; - VclPtr<PushButton> m_pPbTableAutofmt; - SwInsDBColumns aDBColumns; const SwDBData aDBData; - Link<ListBox&,void> aOldNumFormatLnk; OUString const sNoTmpl; SwView* pView; @@ -129,14 +90,48 @@ class SwInsertDBColAutoPilot : public SfxModalDialog, public utl::ConfigItem std::unique_ptr<SwTableRep> pRep; sal_Int32 nGBFormatLen; - DECL_LINK( PageHdl, Button*, void ); - DECL_LINK( AutoFormatHdl, Button*, void ); - DECL_LINK( TableFormatHdl, Button*, void ); - DECL_LINK( DBFormatHdl, Button*, void ); - DECL_LINK( TableToFromHdl, Button*, void ); - DECL_LINK( SelectHdl, ListBox&, void ); - DECL_LINK( DblClickHdl, ListBox&, void ); - DECL_LINK( HeaderHdl, Button*, void ); + std::unique_ptr<weld::RadioButton> m_xRbAsTable; + std::unique_ptr<weld::RadioButton> m_xRbAsField; + std::unique_ptr<weld::RadioButton> m_xRbAsText; + + std::unique_ptr<weld::Frame> m_xHeadFrame; + + std::unique_ptr<weld::TreeView> m_xLbTableDbColumn; + std::unique_ptr<weld::TreeView> m_xLbTextDbColumn; + + std::unique_ptr<weld::Frame> m_xFormatFrame; + std::unique_ptr<weld::RadioButton> m_xRbDbFormatFromDb; + std::unique_ptr<weld::RadioButton> m_xRbDbFormatFromUsr; + std::unique_ptr<SwNumFormatListBox> m_xLbDbFormatFromUsr; + + // Page Text/Field + std::unique_ptr<weld::Button> m_xIbDbcolToEdit; + std::unique_ptr<weld::TextView> m_xEdDbText; + std::unique_ptr<weld::Label> m_xFtDbParaColl; + std::unique_ptr<weld::ComboBox> m_xLbDbParaColl; + + // Page Table + std::unique_ptr<weld::Button> m_xIbDbcolAllTo; + std::unique_ptr<weld::Button> m_xIbDbcolOneTo; + std::unique_ptr<weld::Button> m_xIbDbcolOneFrom; + std::unique_ptr<weld::Button> m_xIbDbcolAllFrom; + std::unique_ptr<weld::Label> m_xFtTableCol; + std::unique_ptr<weld::TreeView> m_xLbTableCol; + std::unique_ptr<weld::CheckButton> m_xCbTableHeadon; + std::unique_ptr<weld::RadioButton> m_xRbHeadlColnms; + std::unique_ptr<weld::RadioButton> m_xRbHeadlEmpty; + std::unique_ptr<weld::Button> m_xPbTableFormat; + std::unique_ptr<weld::Button> m_xPbTableAutofmt; + + DECL_LINK( PageHdl, weld::Button&, void ); + DECL_LINK( AutoFormatHdl, weld::Button&, void ); + DECL_LINK( TableFormatHdl, weld::Button&, void ); + DECL_LINK( DBFormatHdl, weld::Button&, void ); + DECL_LINK( TableToFromHdl, weld::Button&, void ); + DECL_LINK( TVSelectHdl, weld::TreeView&, void ); + DECL_LINK( CBSelectHdl, weld::ComboBox&, void ); + DECL_LINK( DblClickHdl, weld::TreeView&, void ); + DECL_LINK( HeaderHdl, weld::Button&, void ); bool SplitTextToColArr( const OUString& rText, DB_Columns& rColArr, bool bInsField ); virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override; @@ -153,7 +148,6 @@ public: const SwDBData& rData ); virtual ~SwInsertDBColAutoPilot() override; - virtual void dispose() override; void DataToDoc( const css::uno::Sequence< css::uno::Any >& rSelection, css::uno::Reference< css::sdbc::XDataSource> const & rxSource, diff --git a/sw/source/uibase/inc/numfmtlb.hxx b/sw/source/uibase/inc/numfmtlb.hxx index 1a392230a8d3..ce6a8ad622c7 100644 --- a/sw/source/uibase/inc/numfmtlb.hxx +++ b/sw/source/uibase/inc/numfmtlb.hxx @@ -39,7 +39,6 @@ class SW_DLLPUBLIC NumFormatListBox : public ListBox DECL_DLLPRIVATE_LINK( SelectHdl, ListBox&, void ); - SAL_DLLPRIVATE static double GetDefValue(const SvNumFormatType nFormatType); SAL_DLLPRIVATE void Init(); public: @@ -64,6 +63,53 @@ public: void SetShowLanguageControl(bool bSet){bShowLanguageControl = bSet;} + SAL_DLLPRIVATE static double GetDefValue(const SvNumFormatType nFormatType); +}; + +class SW_DLLPUBLIC SwNumFormatListBox +{ + SvNumFormatType nCurrFormatType; + bool mbCurrFormatTypeNeedsInit; + sal_Int32 nStdEntry; + bool bOneArea; + sal_uInt32 nDefFormat; + LanguageType eCurLanguage; + bool bShowLanguageControl; //determine whether the language control has + //to be shown in the number format dialog + bool bUseAutomaticLanguage;//determine whether language is automatically assigned + + std::unique_ptr<weld::ComboBox> mxControl; + + DECL_DLLPRIVATE_LINK( SelectHdl, weld::ComboBox&, void ); + + SAL_DLLPRIVATE void Init(); + +public: + SwNumFormatListBox(std::unique_ptr<weld::ComboBox> xControl); + + ~SwNumFormatListBox(); + + void clear(); + + void SetOneArea(bool bOnlyOne) { bOneArea = bOnlyOne; } + + void SetFormatType(const SvNumFormatType nFormatType); + SvNumFormatType GetFormatType() const { return nCurrFormatType; } + void SetDefFormat(const sal_uInt32 nDefFormat); + sal_uInt32 GetFormat() const; + + LanguageType GetCurLanguage() const { return eCurLanguage;} + void SetLanguage(LanguageType eSet) { eCurLanguage = eSet;} + + void SetAutomaticLanguage(bool bSet){bUseAutomaticLanguage = bSet;} + bool IsAutomaticLanguage()const {return bUseAutomaticLanguage;} + + void SetShowLanguageControl(bool bSet){bShowLanguageControl = bSet;} + + void CallSelectHdl(); + + void set_sensitive(bool bSensitive) { mxControl->set_sensitive(bSensitive); } + void connect_changed(const Link<weld::ComboBox&, void>& rLink) { mxControl->connect_changed(rLink); } }; #endif diff --git a/sw/source/uibase/inc/tblnumfm.hxx b/sw/source/uibase/inc/tblnumfm.hxx index 58a8e9621ab1..300688b92994 100644 --- a/sw/source/uibase/inc/tblnumfm.hxx +++ b/sw/source/uibase/inc/tblnumfm.hxx @@ -27,7 +27,7 @@ class SfxItemSet; class SwNumFormatDlg : public SfxSingleTabDialogController { public: - SwNumFormatDlg(weld::Window* pParent, const SfxItemSet& rSet); + SwNumFormatDlg(weld::Widget* pParent, const SfxItemSet& rSet); }; #endif diff --git a/sw/source/uibase/utlui/numfmtlb.cxx b/sw/source/uibase/utlui/numfmtlb.cxx index c9189fed183f..d1748e953da9 100644 --- a/sw/source/uibase/utlui/numfmtlb.cxx +++ b/sw/source/uibase/utlui/numfmtlb.cxx @@ -454,4 +454,320 @@ void NumFormatListBox::Clear() nCurrFormatType = SvNumFormatType::ALL; } +SwNumFormatListBox::SwNumFormatListBox(std::unique_ptr<weld::ComboBox> xControl) + : nCurrFormatType(SvNumFormatType::ALL) + , mbCurrFormatTypeNeedsInit(true) + , nStdEntry(0) + , bOneArea(false) + , nDefFormat(0) + , bShowLanguageControl(false) + , bUseAutomaticLanguage(true) + , mxControl(std::move(xControl)) +{ + Init(); +} + +void SwNumFormatListBox::Init() +{ + SwView *pView = GetActiveView(); + + if (pView) + eCurLanguage = pView->GetWrtShell().GetCurLang(); + else + eCurLanguage = SvtSysLocale().GetLanguageTag().getLanguageType(); + + SetFormatType(SvNumFormatType::NUMBER); + SetDefFormat(nDefFormat); + + mxControl->connect_changed(LINK(this, SwNumFormatListBox, SelectHdl)); +} + +SwNumFormatListBox::~SwNumFormatListBox() +{ +} + +void SwNumFormatListBox::SetFormatType(const SvNumFormatType nFormatType) +{ + if (!mbCurrFormatTypeNeedsInit && + (nCurrFormatType & nFormatType)) // there are mixed formats, like for example DateTime + return; + + SwView *pView = GetActiveView(); + OSL_ENSURE(pView, "no view found"); + if(!pView) + return; + SwWrtShell &rSh = pView->GetWrtShell(); + SvNumberFormatter* pFormatter = rSh.GetNumberFormatter(); + + clear(); // Remove all entries from the Listbox + + NfIndexTableOffset eOffsetStart = NF_NUMBER_START; + NfIndexTableOffset eOffsetEnd = NF_NUMBER_START; + + switch( nFormatType ) + { + case SvNumFormatType::NUMBER: + eOffsetStart=NF_NUMBER_START; + eOffsetEnd=NF_NUMBER_END; + break; + + case SvNumFormatType::PERCENT: + eOffsetStart=NF_PERCENT_START; + eOffsetEnd=NF_PERCENT_END; + break; + + case SvNumFormatType::CURRENCY: + eOffsetStart=NF_CURRENCY_START; + eOffsetEnd=NF_CURRENCY_END; + break; + + case SvNumFormatType::DATETIME: + eOffsetStart=NF_DATE_START; + eOffsetEnd=NF_TIME_END; + break; + + case SvNumFormatType::DATE: + eOffsetStart=NF_DATE_START; + eOffsetEnd=NF_DATE_END; + break; + + case SvNumFormatType::TIME: + eOffsetStart=NF_TIME_START; + eOffsetEnd=NF_TIME_END; + break; + + case SvNumFormatType::SCIENTIFIC: + eOffsetStart=NF_SCIENTIFIC_START; + eOffsetEnd=NF_SCIENTIFIC_END; + break; + + case SvNumFormatType::FRACTION: + eOffsetStart=NF_FRACTION_START; + eOffsetEnd=NF_FRACTION_END; + break; + + case SvNumFormatType::LOGICAL: + eOffsetStart=NF_BOOLEAN; + eOffsetEnd=NF_BOOLEAN; + break; + + case SvNumFormatType::TEXT: + eOffsetStart=NF_TEXT; + eOffsetEnd=NF_TEXT; + break; + + case SvNumFormatType::ALL: + eOffsetStart=NF_NUMERIC_START; + eOffsetEnd = NfIndexTableOffset( NF_INDEX_TABLE_ENTRIES - 1 ); + break; + + default: + OSL_FAIL("what a format?"); + break; + } + + const SvNumberformat* pFormat; + sal_Int32 i = 0; + Color* pCol; + double fVal = NumFormatListBox::GetDefValue(nFormatType); + OUString sValue; + + const sal_uInt32 nSysNumFormat = pFormatter->GetFormatIndex( + NF_NUMBER_SYSTEM, eCurLanguage ); + const sal_uInt32 nSysShortDateFormat = pFormatter->GetFormatIndex( + NF_DATE_SYSTEM_SHORT, eCurLanguage ); + const sal_uInt32 nSysLongDateFormat = pFormatter->GetFormatIndex( + NF_DATE_SYSTEM_LONG, eCurLanguage ); + + for( long nIndex = eOffsetStart; nIndex <= eOffsetEnd; ++nIndex ) + { + const sal_uInt32 nFormat = pFormatter->GetFormatIndex( + static_cast<NfIndexTableOffset>(nIndex), eCurLanguage ); + pFormat = pFormatter->GetEntry( nFormat ); + + if( nFormat == pFormatter->GetFormatIndex( NF_NUMBER_STANDARD, + eCurLanguage ) + || const_cast<SvNumberformat*>(pFormat)->GetOutputString( fVal, sValue, &pCol ) + || nFormatType == SvNumFormatType::UNDEFINED ) + { + sValue = pFormat->GetFormatstring(); + } + else if( nFormatType == SvNumFormatType::TEXT ) + { + pFormatter->GetOutputString( "\"ABC\"", nFormat, sValue, &pCol); + } + + if (nFormat != nSysNumFormat && + nFormat != nSysShortDateFormat && + nFormat != nSysLongDateFormat) + { + mxControl->append(OUString::number(nFormat), sValue); + + if( nFormat == pFormatter->GetStandardFormat( + nFormatType, eCurLanguage ) ) + nStdEntry = i; + ++i; + } + } + + mxControl->append_text(SwResId(STR_DEFINE_NUMBERFORMAT)); + + mxControl->set_active(nStdEntry); + + nCurrFormatType = nFormatType; + mbCurrFormatTypeNeedsInit = false; + +} + +void SwNumFormatListBox::SetDefFormat(const sal_uInt32 nDefaultFormat) +{ + if (nDefaultFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) + { + nDefFormat = nDefaultFormat; + return; + } + + SwView *pView = GetActiveView(); + OSL_ENSURE(pView, "no view found"); + if(!pView) + return; + SwWrtShell &rSh = pView->GetWrtShell(); + SvNumberFormatter* pFormatter = rSh.GetNumberFormatter(); + + SvNumFormatType nType = pFormatter->GetType(nDefaultFormat); + + SetFormatType(nType); + + sal_uInt32 nFormat = pFormatter->GetFormatForLanguageIfBuiltIn(nDefaultFormat, eCurLanguage); + + for (sal_Int32 i = 0, nCount = mxControl->get_count(); i < nCount; ++i) + { + if (nFormat == mxControl->get_id(i).toUInt32()) + { + mxControl->set_active(i); + nStdEntry = i; + nDefFormat = GetFormat(); + return; + } + } + + // No entry found: + OUString sValue; + Color* pCol = nullptr; + + if (nType == SvNumFormatType::TEXT) + { + pFormatter->GetOutputString("\"ABC\"", nDefaultFormat, sValue, &pCol); + } + else + { + pFormatter->GetOutputString(NumFormatListBox::GetDefValue(nType), nDefaultFormat, sValue, &pCol); + } + + sal_Int32 nPos = 0; + while (mxControl->get_id(nPos).toUInt32() == NUMBERFORMAT_ENTRY_NOT_FOUND) + nPos++; + + if ( lcl_isSystemFormat(nDefaultFormat, pFormatter, eCurLanguage) ) + { + sValue += SwResId(RID_STR_SYSTEM); + } + + mxControl->insert_text(nPos, sValue); // Insert as first numeric entry + mxControl->set_id(nPos, OUString::number(nDefaultFormat)); + mxControl->set_active(nPos); + nDefFormat = GetFormat(); +} + +sal_uInt32 SwNumFormatListBox::GetFormat() const +{ + return mxControl->get_active_id().toUInt32(); +} + +void SwNumFormatListBox::CallSelectHdl() +{ + const sal_Int32 nPos = mxControl->get_active(); + OUString sDefine(SwResId( STR_DEFINE_NUMBERFORMAT )); + SwView *pView = GetActiveView(); + + if( !pView || nPos != mxControl->get_count() - 1 || + mxControl->get_text(nPos) != sDefine ) + return; + + SwWrtShell &rSh = pView->GetWrtShell(); + SvNumberFormatter* pFormatter = rSh.GetNumberFormatter(); + + SfxItemSet aCoreSet( + rSh.GetAttrPool(), + svl::Items< + SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, + SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA, + SID_ATTR_NUMBERFORMAT_NOLANGUAGE, + SID_ATTR_NUMBERFORMAT_NOLANGUAGE, + SID_ATTR_NUMBERFORMAT_ADD_AUTO, + SID_ATTR_NUMBERFORMAT_ADD_AUTO>{}); + + double fValue = NumFormatListBox::GetDefValue(nCurrFormatType); + + sal_uInt32 nFormat = pFormatter->GetStandardFormat( nCurrFormatType, eCurLanguage); + aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, nFormat )); + + aCoreSet.Put( SvxNumberInfoItem( pFormatter, fValue, + SID_ATTR_NUMBERFORMAT_INFO ) ); + + if( (SvNumFormatType::DATE | SvNumFormatType::TIME) & nCurrFormatType ) + aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, bOneArea)); + + aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_NOLANGUAGE, !bShowLanguageControl)); + aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ADD_AUTO, bUseAutomaticLanguage)); + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateNumFormatDialog(mxControl.get(), aCoreSet)); + + if (RET_OK == pDlg->Execute()) + { + const SfxPoolItem* pItem = pView->GetDocShell()-> + GetItem( SID_ATTR_NUMBERFORMAT_INFO ); + + if( pItem ) + { + for ( sal_uInt32 key : static_cast<const SvxNumberInfoItem*>(pItem)->GetDelFormats() ) + pFormatter->DeleteEntry( key ); + } + + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + if( SfxItemState::SET == pOutSet->GetItemState( + SID_ATTR_NUMBERFORMAT_VALUE, false, &pItem )) + { + sal_uInt32 nNumberFormat = static_cast<const SfxUInt32Item*>(pItem)->GetValue(); + // oj #105473# change order of calls + const SvNumberformat* pFormat = pFormatter->GetEntry(nNumberFormat); + if( pFormat ) + eCurLanguage = pFormat->GetLanguage(); + // SetDefFormat uses eCurLanguage to look for if this format already in the list + SetDefFormat(nNumberFormat); + } + if( bShowLanguageControl && SfxItemState::SET == pOutSet->GetItemState( + SID_ATTR_NUMBERFORMAT_ADD_AUTO, false, &pItem )) + { + bUseAutomaticLanguage = static_cast<const SfxBoolItem*>(pItem)->GetValue(); + } + } + else + SetDefFormat(nFormat); + +} + +IMPL_LINK_NOARG(SwNumFormatListBox, SelectHdl, weld::ComboBox&, void) +{ + CallSelectHdl(); +} + +void SwNumFormatListBox::clear() +{ + mxControl->clear(); + mbCurrFormatTypeNeedsInit = true; + nCurrFormatType = SvNumFormatType::ALL; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/uiconfig/swriter/ui/insertdbcolumnsdialog.ui b/sw/uiconfig/swriter/ui/insertdbcolumnsdialog.ui index d632c097b58a..64cf47db949c 100644 --- a/sw/uiconfig/swriter/ui/insertdbcolumnsdialog.ui +++ b/sw/uiconfig/swriter/ui/insertdbcolumnsdialog.ui @@ -1,39 +1,68 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="sw"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkImage" id="image1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="pixbuf">sw/res/one_right.png</property> + <property name="icon_name">sw/res/one_right.png</property> </object> <object class="GtkImage" id="image2"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="pixbuf">sw/res/all_right.png</property> + <property name="icon_name">sw/res/all_right.png</property> </object> <object class="GtkImage" id="image3"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="pixbuf">sw/res/one_left.png</property> + <property name="icon_name">sw/res/one_left.png</property> </object> <object class="GtkImage" id="image4"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="pixbuf">sw/res/all_left.png</property> + <property name="icon_name">sw/res/all_left.png</property> </object> <object class="GtkImage" id="image5"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="pixbuf">sw/res/one_right.png</property> + <property name="icon_name">sw/res/one_right.png</property> + </object> + <object class="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkTreeStore" id="liststore2"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkTreeStore" id="liststore3"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> </object> <object class="GtkDialog" id="InsertDbColumnsDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="insertdbcolumnsdialog|InsertDbColumnsDialog">Insert Database Columns</property> <property name="resizable">False</property> + <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> @@ -112,10 +141,10 @@ <object class="GtkLabel" id="label1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="insertdbcolumnsdialog|label1">Insert data as:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">grid3</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -138,7 +167,6 @@ <property name="xalign">0</property> <property name="active">True</property> <property name="draw_indicator">True</property> - <property name="group">asfields</property> </object> <packing> <property name="left_attach">0</property> @@ -154,7 +182,7 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <property name="group">astext</property> + <property name="group">astable</property> </object> <packing> <property name="left_attach">1</property> @@ -215,10 +243,10 @@ <object class="GtkLabel" id="label4"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="insertdbcolumnsdialog|label4">Database _columns</property> <property name="use_underline">True</property> <property name="mnemonic_widget">box2</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -229,10 +257,10 @@ <object class="GtkLabel" id="tablecolft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="insertdbcolumnsdialog|tablecolft">Tab_le column(s)</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">tablecols:border</property> + <property name="mnemonic_widget">tablecols</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">2</property> @@ -328,14 +356,37 @@ <property name="vexpand">True</property> <property name="orientation">vertical</property> <child> - <object class="GtkTreeView" id="tablecols:border"> + <object class="GtkScrolledWindow"> + <property name="visible">True</property> <property name="can_focus">True</property> - <property name="no_show_all">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <property name="show_expanders">False</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="treeview-selection2"/> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="tablecols"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="headers_visible">False</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="treeview-selection1"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn1"> + <child> + <object class="GtkCellRendererText" id="cellrenderertext1"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> @@ -352,7 +403,7 @@ <property name="vexpand">True</property> <property name="shadow_type">in</property> <child> - <object class="GtkTextView" id="textview:border"> + <object class="GtkTextView" id="textview"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> @@ -380,14 +431,37 @@ <property name="vexpand">True</property> <property name="orientation">vertical</property> <child> - <object class="GtkTreeView" id="tabledbcols:border"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <property name="show_expanders">False</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="treeview-selection4"/> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="tabledbcols"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore2</property> + <property name="headers_visible">False</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="treeview-selection2"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn2"> + <child> + <object class="GtkCellRendererText" id="cellrenderertext2"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> @@ -397,14 +471,37 @@ </packing> </child> <child> - <object class="GtkTreeView" id="tabletxtcols:border"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <property name="show_expanders">False</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="treeview-selection3"/> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="tabletxtcols"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore3</property> + <property name="headers_visible">False</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="treeview-selection3"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn3"> + <child> + <object class="GtkCellRendererText" id="cellrenderertext3"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> @@ -493,7 +590,6 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <property name="group">rowonly</property> </object> <packing> <property name="left_attach">0</property> @@ -547,10 +643,10 @@ <object class="GtkLabel" id="parastylelabel"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="insertdbcolumnsdialog|parastylelabel">Paragraph _style:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">parastyle</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -595,7 +691,6 @@ <property name="xalign">0</property> <property name="active">True</property> <property name="draw_indicator">True</property> - <property name="group">userdefined</property> </object> <packing> <property name="left_attach">0</property> @@ -622,7 +717,7 @@ </packing> </child> <child> - <object class="swlo-NumFormatListBox" id="numformat"> + <object class="GtkComboBoxText" id="numformat"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="margin_left">12</property> diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 8d9ac7f0e434..222bd915008e 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -6965,6 +6965,22 @@ public: return gtk_adjustment_get_page_size(m_pVAdjustment); } + virtual void show() override + { + GtkWidget* pParent = gtk_widget_get_parent(m_pWidget); + if (GTK_IS_SCROLLED_WINDOW(pParent)) + gtk_widget_show(pParent); + gtk_widget_show(m_pWidget); + } + + virtual void hide() override + { + GtkWidget* pParent = gtk_widget_get_parent(m_pWidget); + if (GTK_IS_SCROLLED_WINDOW(pParent)) + gtk_widget_hide(pParent); + gtk_widget_hide(m_pWidget); + } + virtual ~GtkInstanceTextView() override { g_signal_handler_disconnect(m_pVAdjustment, m_nVAdjustChangedSignalId); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits