extras/source/glade/libreoffice-catalog.xml.in | 7 sc/inc/scabstdlg.hxx | 2 sc/qa/uitest/calc_tests6/autoFormat.py | 10 sc/source/ui/attrdlg/scdlgfact.cxx | 17 sc/source/ui/attrdlg/scdlgfact.hxx | 10 sc/source/ui/inc/autofmt.hxx | 12 sc/source/ui/inc/scuiautofmt.hxx | 49 +- sc/source/ui/miscdlgs/autofmt.cxx | 40 - sc/source/ui/miscdlgs/scuiautofmt.cxx | 215 ++++------ sc/source/ui/view/cellsh3.cxx | 4 sc/uiconfig/scalc/ui/autoformattable.ui | 235 ++++++----- solenv/bin/native-code.py | 2 sw/source/ui/fldui/flddinf.cxx | 6 sw/source/ui/fldui/flddinf.hxx | 1 sw/source/ui/fldui/fldfunc.cxx | 515 +++++++++++-------------- sw/source/ui/fldui/fldfunc.hxx | 82 +-- sw/source/ui/fldui/fldpage.cxx | 38 + sw/source/ui/fldui/fldpage.hxx | 5 sw/source/uibase/cctrl/actctrl.cxx | 19 sw/source/uibase/inc/actctrl.hxx | 15 sw/source/uibase/inc/condedit.hxx | 4 sw/uiconfig/swriter/ui/fldfuncpage.ui | 232 ++++++----- 22 files changed, 778 insertions(+), 742 deletions(-)
New commits: commit 43fd682ea227bbe82f0abf756213cf88b2826183 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Sat Mar 16 17:58:16 2019 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sat Mar 16 22:17:19 2019 +0100 weld SwFieldFuncPage Change-Id: I5b098eecb7318ab64dcafff3ce1ef0fa34536f50 Reviewed-on: https://gerrit.libreoffice.org/69346 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index d1583ef900ef..5af0548a670c 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -365,10 +365,6 @@ generic-name="Condition Edit" parent="GtkEntry" icon-name="widget-gtk-textentry"/> - <glade-widget-class title="Return Action Edit" name="swlo-ReturnActionEdit" - generic-name="Return Action Edit" parent="GtkEntry" - icon-name="widget-gtk-textentry"/> - <glade-widget-class title="Text View" name="sclo-ScEditWindow" generic-name="Text View" parent="GtkTextView" icon-name="widget-gtk-textentry"/> diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index 506ac91d760a..88942fe07037 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -465,7 +465,6 @@ custom_widgets = [ 'RefButton', 'RefEdit', 'ReplaceEdit', - 'ReturnActionEdit', 'RowEdit', 'RubyEdit', 'RubyPreview', diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx index c412a4045e0a..13659f395655 100644 --- a/sw/source/ui/fldui/flddinf.cxx +++ b/sw/source/ui/fldui/flddinf.cxx @@ -52,6 +52,12 @@ void FillFieldSelect(ListBox& rListBox) rListBox.InsertEntry(SwResId(FLD_SELECT[i])); } +void FillFieldSelect(weld::TreeView& rListBox) +{ + for (size_t i = 0; i < SAL_N_ELEMENTS(FLD_SELECT); ++i) + rListBox.append_text(SwResId(FLD_SELECT[i])); +} + SwFieldDokInfPage::SwFieldDokInfPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet) : SwFieldPage(pParent, "FieldDocInfoPage", "modules/swriter/ui/flddocinfopage.ui", pCoreSet) diff --git a/sw/source/ui/fldui/flddinf.hxx b/sw/source/ui/fldui/flddinf.hxx index 2347a6d15611..d583f53fd88e 100644 --- a/sw/source/ui/fldui/flddinf.hxx +++ b/sw/source/ui/fldui/flddinf.hxx @@ -72,6 +72,7 @@ public: }; void FillFieldSelect(ListBox& rListBox); +void FillFieldSelect(weld::TreeView& rListBox); #endif diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx index 92bcf82a5a52..9c18d44126b2 100644 --- a/sw/source/ui/fldui/fldfunc.cxx +++ b/sw/source/ui/fldui/fldfunc.cxx @@ -38,58 +38,52 @@ using namespace ::com::sun::star; -SwFieldFuncPage::SwFieldFuncPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet) - : SwFieldPage(pParent, "FieldFuncPage", - "modules/swriter/ui/fldfuncpage.ui", pCoreSet) +SwFieldFuncPage::SwFieldFuncPage(TabPageParent pParent, const SfxItemSet *const pCoreSet) + : SwFieldPage(pParent, "modules/swriter/ui/fldfuncpage.ui", "FieldFuncPage", pCoreSet) , nOldFormat(0) , bDropDownLBChanged(false) + , m_xTypeLB(m_xBuilder->weld_tree_view("type")) + , m_xSelectionLB(m_xBuilder->weld_tree_view("select")) + , m_xFormat(m_xBuilder->weld_widget("formatframe")) + , m_xFormatLB(m_xBuilder->weld_tree_view("format")) + , m_xNameFT(m_xBuilder->weld_label("nameft")) + , m_xNameED(new SwConditionEdit(m_xBuilder->weld_entry("condFunction"))) + , m_xValueGroup(m_xBuilder->weld_widget("valuegroup")) + , m_xValueFT(m_xBuilder->weld_label("valueft")) + , m_xValueED(m_xBuilder->weld_entry("value")) + , m_xCond1FT(m_xBuilder->weld_label("cond1ft")) + , m_xCond1ED(new SwConditionEdit(m_xBuilder->weld_entry("cond1"))) + , m_xCond2FT(m_xBuilder->weld_label("cond2ft")) + , m_xCond2ED(new SwConditionEdit(m_xBuilder->weld_entry("cond2"))) + , m_xMacroBT(m_xBuilder->weld_button("macro")) + , m_xListGroup(m_xBuilder->weld_widget("listgroup")) + , m_xListItemFT(m_xBuilder->weld_label("itemft")) + , m_xListItemED(m_xBuilder->weld_entry("item")) + , m_xListAddPB(m_xBuilder->weld_button("add")) + , m_xListItemsFT(m_xBuilder->weld_label("listitemft")) + , m_xListItemsLB(m_xBuilder->weld_tree_view("listitems")) + , m_xListRemovePB(m_xBuilder->weld_button("remove")) + , m_xListUpPB(m_xBuilder->weld_button("up")) + , m_xListDownPB(m_xBuilder->weld_button("down")) + , m_xListNameFT(m_xBuilder->weld_label("listnameft")) + , m_xListNameED(m_xBuilder->weld_entry("listname")) { - get(m_pTypeLB, "type"); - get(m_pFormat, "formatframe"); - get(m_pSelectionLB, "select"); - FillFieldSelect(*m_pSelectionLB); - get(m_pFormatLB, "format"); - FillFieldSelect(*m_pFormatLB); - get(m_pNameFT, "nameft"); - get(m_pNameED, "condFunction"); - get(m_pValueGroup, "valuegroup"); - get(m_pValueFT, "valueft"); - get(m_pValueED, "value"); - get(m_pCond1FT, "cond1ft"); - get(m_pCond1ED, "cond1"); - get(m_pCond2FT, "cond2ft"); - get(m_pCond2ED, "cond2"); - get(m_pMacroBT, "macro"); - - get(m_pListGroup, "listgroup"); - get(m_pListItemFT, "itemft"); - get(m_pListItemED, "item"); - get(m_pListAddPB, "add"); - get(m_pListItemsFT, "listitemft"); - get(m_pListItemsLB, "listitems"); - m_pListItemsLB->SetDropDownLineCount(5); - m_pListItemsLB->set_width_request(m_pListItemED->GetOptimalSize().Width()); - get(m_pListRemovePB, "remove"); - get(m_pListUpPB, "up"); - get(m_pListDownPB, "down"); - get(m_pListNameFT, "listnameft"); - get(m_pListNameED, "listname"); - - long nHeight = m_pTypeLB->GetTextHeight() * 20; - m_pTypeLB->set_height_request(nHeight); - m_pFormatLB->set_height_request(nHeight); - - long nWidth = m_pTypeLB->LogicToPixel(Size(FIELD_COLUMN_WIDTH, 0), MapMode(MapUnit::MapAppFont)).Width(); - m_pTypeLB->set_width_request(nWidth); - m_pFormatLB->set_width_request(nWidth); - - m_pNameED->SetModifyHdl(LINK(this, SwFieldFuncPage, ModifyHdl)); - - m_sOldValueFT = m_pValueFT->GetText(); - m_sOldNameFT = m_pNameFT->GetText(); - - m_pCond1ED->ShowBrackets(false); - m_pCond2ED->ShowBrackets(false); + FillFieldSelect(*m_xSelectionLB); + FillFieldSelect(*m_xFormatLB); + m_xListItemsLB->set_size_request(m_xListItemED->get_preferred_size().Width(), -1); + + auto nWidth = m_xTypeLB->get_approximate_digit_width() * FIELD_COLUMN_WIDTH / 8; + auto nHeight = m_xTypeLB->get_height_rows(20); + m_xTypeLB->set_size_request(nWidth, nHeight); + m_xFormatLB->set_size_request(nWidth, nHeight); + + m_xNameED->connect_changed(LINK(this, SwFieldFuncPage, ModifyHdl)); + + m_sOldValueFT = m_xValueFT->get_label(); + m_sOldNameFT = m_xNameFT->get_label(); + + m_xCond1ED->ShowBrackets(false); + m_xCond2ED->ShowBrackets(false); } SwFieldFuncPage::~SwFieldFuncPage() @@ -97,45 +91,13 @@ SwFieldFuncPage::~SwFieldFuncPage() disposeOnce(); } -void SwFieldFuncPage::dispose() -{ - m_pTypeLB.clear(); - m_pSelectionLB.clear(); - m_pFormat.clear(); - m_pFormatLB.clear(); - m_pNameFT.clear(); - m_pNameED.clear(); - m_pValueGroup.clear(); - m_pValueFT.clear(); - m_pValueED.clear(); - m_pCond1FT.clear(); - m_pCond1ED.clear(); - m_pCond2FT.clear(); - m_pCond2ED.clear(); - m_pMacroBT.clear(); - m_pListGroup.clear(); - m_pListItemFT.clear(); - m_pListItemED.clear(); - m_pListAddPB.clear(); - m_pListItemsFT.clear(); - m_pListItemsLB.clear(); - m_pListRemovePB.clear(); - m_pListUpPB.clear(); - m_pListDownPB.clear(); - m_pListNameFT.clear(); - m_pListNameED.clear(); - SwFieldPage::dispose(); -} - void SwFieldFuncPage::Reset(const SfxItemSet* ) { - SavePos(m_pTypeLB); + SavePos(*m_xTypeLB); Init(); // general initialisation - m_pTypeLB->SetUpdateMode(false); - m_pTypeLB->Clear(); - - sal_Int32 nPos; + m_xTypeLB->freeze(); + m_xTypeLB->clear(); if (!IsFieldEdit()) { @@ -146,15 +108,13 @@ void SwFieldFuncPage::Reset(const SfxItemSet* ) for(sal_uInt16 i = rRg.nStart; i < rRg.nEnd; ++i) { const sal_uInt16 nTypeId = SwFieldMgr::GetTypeId(i); - nPos = m_pTypeLB->InsertEntry(SwFieldMgr::GetTypeStr(i)); - m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId)); + m_xTypeLB->append(OUString::number(nTypeId), SwFieldMgr::GetTypeStr(i)); } } else { const sal_uInt16 nTypeId = GetCurField()->GetTypeId(); - nPos = m_pTypeLB->InsertEntry(SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId))); - m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId)); + m_xTypeLB->append(OUString::number(nTypeId), SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId))); if (nTypeId == TYP_MACROFLD) { @@ -162,25 +122,23 @@ void SwFieldFuncPage::Reset(const SfxItemSet* ) } } - // select old Pos - RestorePos(m_pTypeLB); - - m_pTypeLB->SetDoubleClickHdl (LINK(this, SwFieldFuncPage, ListBoxInsertHdl)); - m_pTypeLB->SetSelectHdl (LINK(this, SwFieldFuncPage, TypeHdl)); - m_pSelectionLB->SetSelectHdl (LINK(this, SwFieldFuncPage, SelectHdl)); - m_pSelectionLB->SetDoubleClickHdl (LINK(this, SwFieldFuncPage, InsertMacroHdl)); - m_pFormatLB->SetDoubleClickHdl (LINK(this, SwFieldFuncPage, ListBoxInsertHdl)); - m_pMacroBT->SetClickHdl (LINK(this, SwFieldFuncPage, MacroHdl)); - Link<Button*,void> aListModifyLk( LINK(this, SwFieldFuncPage, ListModifyButtonHdl)); - m_pListAddPB->SetClickHdl(aListModifyLk); - m_pListRemovePB->SetClickHdl(aListModifyLk); - m_pListUpPB->SetClickHdl(aListModifyLk); - m_pListDownPB->SetClickHdl(aListModifyLk); - m_pListItemED->SetReturnActionLink(LINK(this, SwFieldFuncPage, ListModifyReturnActionHdl)); - Link<Edit&,void> aListEnableLk = LINK(this, SwFieldFuncPage, ListEnableHdl); - m_pListItemED->SetModifyHdl(aListEnableLk); - m_pListItemsLB->SetSelectHdl(LINK(this, SwFieldFuncPage, ListEnableListBoxHdl)); - + m_xTypeLB->connect_row_activated(LINK(this, SwFieldFuncPage, TreeViewInsertHdl)); + m_xTypeLB->connect_changed(LINK(this, SwFieldFuncPage, TypeHdl)); + m_xSelectionLB->connect_changed(LINK(this, SwFieldFuncPage, SelectHdl)); + m_xSelectionLB->connect_row_activated(LINK(this, SwFieldFuncPage, InsertMacroHdl)); + m_xFormatLB->connect_row_activated(LINK(this, SwFieldFuncPage, TreeViewInsertHdl)); + m_xMacroBT->connect_clicked(LINK(this, SwFieldFuncPage, MacroHdl)); + Link<weld::Button&,void> aListModifyLk( LINK(this, SwFieldFuncPage, ListModifyButtonHdl)); + m_xListAddPB->connect_clicked(aListModifyLk); + m_xListRemovePB->connect_clicked(aListModifyLk); + m_xListUpPB->connect_clicked(aListModifyLk); + m_xListDownPB->connect_clicked(aListModifyLk); + m_xListItemED->connect_activate(LINK(this, SwFieldFuncPage, ListModifyReturnActionHdl)); + Link<weld::Entry&,void> aListEnableLk = LINK(this, SwFieldFuncPage, ListEnableHdl); + m_xListItemED->connect_changed(aListEnableLk); + m_xListItemsLB->connect_changed(LINK(this, SwFieldFuncPage, ListEnableListBoxHdl)); + + int nSelect = -1; if( !IsRefresh() ) { const OUString sUserData = GetUserData(); @@ -190,25 +148,34 @@ void SwFieldFuncPage::Reset(const SfxItemSet* ) const sal_uInt16 nVal = static_cast< sal_uInt16 >(sUserData.getToken(0, ';', nIdx).toInt32()); if(nVal != USHRT_MAX) { - for(sal_Int32 i = 0; i < m_pTypeLB->GetEntryCount(); i++) - if(nVal == static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(i)))) + for (sal_Int32 i = 0, nEntryCount = m_xTypeLB->n_children(); i < nEntryCount; ++i) + { + if (nVal == m_xTypeLB->get_id(i).toUInt32()) { - m_pTypeLB->SelectEntryPos(i); + nSelect = i; break; } + } } } } - TypeHdl(*m_pTypeLB); - m_pTypeLB->SetUpdateMode(true); + m_xTypeLB->thaw(); + if (nSelect != -1) + m_xTypeLB->select(nSelect); + else + { + // select old Pos + RestorePos(*m_xTypeLB); + } + TypeHdl(*m_xTypeLB); if (IsFieldEdit()) { - m_pNameED->SaveValue(); - m_pValueED->SaveValue(); - m_pCond1ED->SaveValue(); - m_pCond2ED->SaveValue(); + m_xNameED->save_value(); + m_xValueED->save_value(); + m_xCond1ED->save_value(); + m_xCond2ED->save_value(); nOldFormat = GetCurField()->GetFormat(); } } @@ -222,46 +189,46 @@ static const char* FMT_MARK_ARY[] = FMT_MARK_OLE }; -IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, ListBox&, void) +IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void) { // save old ListBoxPos const sal_Int32 nOld = GetTypeSel(); // current ListBoxPos - SetTypeSel(m_pTypeLB->GetSelectedEntryPos()); + SetTypeSel(m_xTypeLB->get_selected_index()); - if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND) + if(GetTypeSel() == -1) { SetTypeSel(0); - m_pTypeLB->SelectEntryPos(0); + m_xTypeLB->select(0); } if (nOld == GetTypeSel()) return; - const sal_uInt16 nTypeId = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(GetTypeSel()))); + const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); // fill Selection-Listbox UpdateSubType(); // fill Format-Listbox - m_pFormatLB->Clear(); + m_xFormatLB->clear(); const sal_uInt16 nSize = GetFieldMgr().GetFormatCount(nTypeId, IsFieldDlgHtmlMode()); for (sal_uInt16 i = 0; i < nSize; i++) { - sal_Int32 nPos = m_pFormatLB->InsertEntry(GetFieldMgr().GetFormatStr(nTypeId, i)); - m_pFormatLB->SetEntryData( nPos, reinterpret_cast<void*>(GetFieldMgr().GetFormatId( nTypeId, i )) ); + m_xFormatLB->append(OUString::number(GetFieldMgr().GetFormatId(nTypeId, i)), + GetFieldMgr().GetFormatStr(nTypeId, i)); } if (nSize) { if (IsFieldEdit() && nTypeId == TYP_JUMPEDITFLD) - m_pFormatLB->SelectEntry(SwResId(FMT_MARK_ARY[GetCurField()->GetFormat()])); + m_xFormatLB->select_text(SwResId(FMT_MARK_ARY[GetCurField()->GetFormat()])); - if (!m_pFormatLB->GetSelectedEntryCount()) - m_pFormatLB->SelectEntryPos(0); + if (m_xFormatLB->get_selected_index() == -1) + m_xFormatLB->select(0); } bool bValue = false, bName = false, bMacro = false, bInsert = true; @@ -271,18 +238,18 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, ListBox&, void) bool bDropDown = TYP_DROPDOWN == nTypeId; bool bCondTextField = TYP_CONDTXTFLD == nTypeId; - m_pCond1FT->Show(!bDropDown && bCondTextField); - m_pCond1ED->Show(!bDropDown && bCondTextField); - m_pCond2FT->Show(!bDropDown && bCondTextField); - m_pCond2ED->Show(!bDropDown && bCondTextField); - m_pValueGroup->Show(!bDropDown && !bCondTextField); - m_pMacroBT->Show(!bDropDown); - m_pNameED->Show(!bDropDown); - m_pNameFT->Show(!bDropDown); + m_xCond1FT->set_visible(!bDropDown && bCondTextField); + m_xCond1ED->set_visible(!bDropDown && bCondTextField); + m_xCond2FT->set_visible(!bDropDown && bCondTextField); + m_xCond2ED->set_visible(!bDropDown && bCondTextField); + m_xValueGroup->set_visible(!bDropDown && !bCondTextField); + m_xMacroBT->set_visible(!bDropDown); + m_xNameED->set_visible(!bDropDown); + m_xNameFT->set_visible(!bDropDown); - m_pListGroup->Show(bDropDown); + m_xListGroup->set_visible(bDropDown); - m_pNameED->SetDropEnable(false); + m_xNameED->SetDropEnable(false); if (IsFieldEdit()) { @@ -291,32 +258,32 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, ListBox&, void) const SwDropDownField* pDrop = static_cast<const SwDropDownField*>(GetCurField()); uno::Sequence<OUString> aItems = pDrop->GetItemSequence(); const OUString* pArray = aItems.getConstArray(); - m_pListItemsLB->Clear(); - for(sal_Int32 i = 0; i < aItems.getLength(); i++) - m_pListItemsLB->InsertEntry(pArray[i]); - m_pListItemsLB->SelectEntry(pDrop->GetSelectedItem()); - m_pListNameED->SetText(pDrop->GetPar2()); - m_pListNameED->SaveValue(); + m_xListItemsLB->clear(); + for (sal_Int32 i = 0; i < aItems.getLength(); i++) + m_xListItemsLB->append_text(pArray[i]); + m_xListItemsLB->select_text(pDrop->GetSelectedItem()); + m_xListNameED->set_text(pDrop->GetPar2()); + m_xListNameED->save_value(); bDropDownLBChanged = false; } else { - m_pNameED->SetText(GetCurField()->GetPar1()); - m_pValueED->SetText(GetCurField()->GetPar2()); + m_xNameED->set_text(GetCurField()->GetPar1()); + m_xValueED->set_text(GetCurField()->GetPar2()); } } else { - m_pNameED->SetText(OUString()); - m_pValueED->SetText(OUString()); + m_xNameED->set_text(OUString()); + m_xValueED->set_text(OUString()); } if(bDropDown) - ListEnableHdl(*m_pListItemED); + ListEnableHdl(*m_xListItemED); - if (m_pNameFT->GetText() != m_sOldNameFT) - m_pNameFT->SetText(m_sOldNameFT); - if (m_pValueFT->GetText() != m_sOldValueFT) - m_pValueFT->SetText(m_sOldValueFT); + if (m_xNameFT->get_label() != m_sOldNameFT) + m_xNameFT->set_label(m_sOldNameFT); + if (m_xValueFT->get_label() != m_sOldValueFT) + m_xValueFT->set_label(m_sOldValueFT); switch (nTypeId) { @@ -327,76 +294,76 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, ListBox&, void) else bInsert = false; - m_pNameFT->SetText(SwResId(STR_MACNAME)); - m_pValueFT->SetText(SwResId(STR_PROMPT)); - m_pNameED->SetText(GetFieldMgr().GetMacroName()); - m_pNameED->SetAccessibleName(m_pNameFT->GetText()); - m_pValueED->SetAccessibleName(m_pValueFT->GetText()); + m_xNameFT->set_label(SwResId(STR_MACNAME)); + m_xValueFT->set_label(SwResId(STR_PROMPT)); + m_xNameED->set_text(GetFieldMgr().GetMacroName()); + m_xNameED->set_accessible_name(m_xNameFT->get_label()); + m_xValueED->set_accessible_name(m_xValueFT->get_label()); break; case TYP_HIDDENPARAFLD: - m_pNameFT->SetText(SwResId(STR_COND)); - m_pNameED->SetDropEnable(true); + m_xNameFT->set_label(SwResId(STR_COND)); + m_xNameED->SetDropEnable(true); bName = true; - m_pNameED->SetAccessibleName(m_pNameFT->GetText()); - m_pValueED->SetAccessibleName(m_pValueFT->GetText()); + m_xNameED->set_accessible_name(m_xNameFT->get_label()); + m_xValueED->set_accessible_name(m_xValueFT->get_label()); break; case TYP_HIDDENTXTFLD: { - m_pNameFT->SetText(SwResId(STR_COND)); - m_pNameED->SetDropEnable(true); - m_pValueFT->SetText(SwResId(STR_INSTEXT)); + m_xNameFT->set_label(SwResId(STR_COND)); + m_xNameED->SetDropEnable(true); + m_xValueFT->set_label(SwResId(STR_INSTEXT)); SwWrtShell* pSh = GetActiveWrtShell(); if (!IsFieldEdit() && pSh ) - m_pValueED->SetText(pSh->GetSelText()); + m_xValueED->set_text(pSh->GetSelText()); bName = bValue = true; - m_pNameED->SetAccessibleName(m_pNameFT->GetText()); - m_pValueED->SetAccessibleName(m_pValueFT->GetText()); + m_xNameED->set_accessible_name(m_xNameFT->get_label()); + m_xValueED->set_accessible_name(m_xValueFT->get_label()); } break; case TYP_CONDTXTFLD: - m_pNameFT->SetText(SwResId(STR_COND)); - m_pNameED->SetDropEnable(true); + m_xNameFT->set_label(SwResId(STR_COND)); + m_xNameED->SetDropEnable(true); if (IsFieldEdit()) { sal_Int32 nIdx{ 0 }; - m_pCond1ED->SetText(GetCurField()->GetPar2().getToken(0, '|', nIdx)); - m_pCond2ED->SetText(GetCurField()->GetPar2().getToken(0, '|', nIdx)); + m_xCond1ED->set_text(GetCurField()->GetPar2().getToken(0, '|', nIdx)); + m_xCond2ED->set_text(GetCurField()->GetPar2().getToken(0, '|', nIdx)); } bName = bValue = true; - m_pNameED->SetAccessibleName(m_pNameFT->GetText()); - m_pValueED->SetAccessibleName(m_pValueFT->GetText()); + m_xNameED->set_accessible_name(m_xNameFT->get_label()); + m_xValueED->set_accessible_name(m_xValueFT->get_label()); break; case TYP_JUMPEDITFLD: - m_pNameFT->SetText(SwResId(STR_JUMPEDITFLD)); - m_pValueFT->SetText(SwResId(STR_PROMPT)); + m_xNameFT->set_label(SwResId(STR_JUMPEDITFLD)); + m_xValueFT->set_label(SwResId(STR_PROMPT)); bName = bValue = true; - m_pNameED->SetAccessibleName(m_pNameFT->GetText()); - m_pValueED->SetAccessibleName(m_pValueFT->GetText()); + m_xNameED->set_accessible_name(m_xNameFT->get_label()); + m_xValueED->set_accessible_name(m_xValueFT->get_label()); break; case TYP_INPUTFLD: - m_pValueFT->SetText(SwResId(STR_PROMPT)); + m_xValueFT->set_label(SwResId(STR_PROMPT)); bValue = true; - m_pNameED->SetAccessibleName(m_pNameFT->GetText()); - m_pValueED->SetAccessibleName(m_pValueFT->GetText()); + m_xNameED->set_accessible_name(m_xNameFT->get_label()); + m_xValueED->set_accessible_name(m_xValueFT->get_label()); break; case TYP_COMBINED_CHARS: { - m_pNameFT->SetText(SwResId(STR_COMBCHRS_FT)); - m_pNameED->SetDropEnable(true); + m_xNameFT->set_label(SwResId(STR_COMBCHRS_FT)); + m_xNameED->SetDropEnable(true); bName = true; - const sal_Int32 nLen = m_pNameED->GetText().getLength(); + const sal_Int32 nLen = m_xNameED->get_text().getLength(); if( !nLen || nLen > MAX_COMBINED_CHARACTERS ) bInsert = false; - m_pNameED->SetAccessibleName(m_pNameFT->GetText()); - m_pValueED->SetAccessibleName(m_pValueFT->GetText()); + m_xNameED->set_accessible_name(m_xNameFT->get_label()); + m_xValueED->set_accessible_name(m_xValueFT->get_label()); } break; case TYP_DROPDOWN : @@ -405,129 +372,126 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, ListBox&, void) break; } - m_pSelectionLB->Hide(); + m_xSelectionLB->hide(); - m_pFormat->Enable(bFormat); - m_pNameFT->Enable(bName); - m_pNameED->Enable(bName); - m_pValueGroup->Enable(bValue); - m_pMacroBT->Enable(bMacro); + m_xFormat->set_sensitive(bFormat); + m_xNameFT->set_sensitive(bName); + m_xNameED->set_sensitive(bName); + m_xValueGroup->set_sensitive(bValue); + m_xMacroBT->set_sensitive(bMacro); EnableInsert( bInsert ); - } -IMPL_LINK_NOARG(SwFieldFuncPage, SelectHdl, ListBox&, void) +IMPL_LINK_NOARG(SwFieldFuncPage, SelectHdl, weld::TreeView&, void) { - const sal_uInt16 nTypeId = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(GetTypeSel()))); + const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); if( TYP_MACROFLD == nTypeId ) - m_pNameED->SetText( m_pSelectionLB->GetSelectedEntry() ); + m_xNameED->set_text( m_xSelectionLB->get_selected_text() ); } -IMPL_LINK_NOARG(SwFieldFuncPage, InsertMacroHdl, ListBox&, void) +IMPL_LINK_NOARG(SwFieldFuncPage, InsertMacroHdl, weld::TreeView&, void) { - SelectHdl(*m_pSelectionLB); + SelectHdl(*m_xSelectionLB); InsertHdl(nullptr); } -IMPL_LINK( SwFieldFuncPage, ListModifyButtonHdl, Button*, pControl, void) +IMPL_LINK(SwFieldFuncPage, ListModifyButtonHdl, weld::Button&, rControl, void) { - ListModifyHdl(pControl); + ListModifyHdl(&rControl); } -IMPL_LINK( SwFieldFuncPage, ListModifyReturnActionHdl, ReturnActionEdit&, rControl, void) + +IMPL_LINK(SwFieldFuncPage, ListModifyReturnActionHdl, weld::Entry&, rControl, bool) { ListModifyHdl(&rControl); + return true; } -void SwFieldFuncPage::ListModifyHdl(Control const * pControl) + +void SwFieldFuncPage::ListModifyHdl(const weld::Widget* pControl) { - m_pListItemsLB->SetUpdateMode(false); - if(pControl == m_pListAddPB || - (pControl == m_pListItemED && m_pListAddPB->IsEnabled())) + if (pControl == m_xListAddPB.get() || + (pControl == m_xListItemED.get() && m_xListAddPB->get_sensitive())) { - const OUString sEntry(m_pListItemED->GetText()); - m_pListItemsLB->InsertEntry(sEntry); - m_pListItemsLB->SelectEntry(sEntry); + const OUString sEntry(m_xListItemED->get_text()); + m_xListItemsLB->append_text(sEntry); + m_xListItemsLB->select_text(sEntry); } - else if(m_pListItemsLB->GetSelectedEntryCount()) + else if (m_xListItemsLB->get_selected_index() != -1) { - sal_Int32 nSelPos = m_pListItemsLB->GetSelectedEntryPos(); - if(pControl == m_pListRemovePB) + sal_Int32 nSelPos = m_xListItemsLB->get_selected_index(); + if (pControl == m_xListRemovePB.get()) { - m_pListItemsLB->RemoveEntry(nSelPos); - m_pListItemsLB->SelectEntryPos(nSelPos ? nSelPos - 1 : 0); + m_xListItemsLB->remove(nSelPos); + m_xListItemsLB->select(nSelPos ? nSelPos - 1 : 0); } - else if(pControl == m_pListUpPB) + else if (pControl == m_xListUpPB.get()) { if(nSelPos) { - const OUString sEntry = m_pListItemsLB->GetSelectedEntry(); - m_pListItemsLB->RemoveEntry(nSelPos); + const OUString sEntry = m_xListItemsLB->get_selected_text(); + m_xListItemsLB->remove(nSelPos); nSelPos--; - m_pListItemsLB->InsertEntry(sEntry, nSelPos); - m_pListItemsLB->SelectEntryPos(nSelPos); + m_xListItemsLB->insert_text(nSelPos, sEntry); + m_xListItemsLB->select(nSelPos); } } - else if(pControl == m_pListDownPB) + else if (pControl == m_xListDownPB.get()) { - if(nSelPos < m_pListItemsLB->GetEntryCount() - 1) + if( nSelPos < m_xListItemsLB->n_children() - 1) { - const OUString sEntry = m_pListItemsLB->GetSelectedEntry(); - m_pListItemsLB->RemoveEntry(nSelPos); + const OUString sEntry = m_xListItemsLB->get_selected_text(); + m_xListItemsLB->remove(nSelPos); nSelPos++; - m_pListItemsLB->InsertEntry(sEntry, nSelPos); - m_pListItemsLB->SelectEntryPos(nSelPos); + m_xListItemsLB->insert_text(nSelPos, sEntry); + m_xListItemsLB->select(nSelPos); } } } bDropDownLBChanged = true; - m_pListItemsLB->SetUpdateMode(true); - ListEnableHdl(*m_pListItemED); + ListEnableHdl(*m_xListItemED); } -IMPL_LINK_NOARG(SwFieldFuncPage, ListEnableListBoxHdl, ListBox&, void) +IMPL_LINK_NOARG(SwFieldFuncPage, ListEnableListBoxHdl, weld::TreeView&, void) { - ListEnableHdl(*m_pListItemED); + ListEnableHdl(*m_xListItemED); } -IMPL_LINK_NOARG(SwFieldFuncPage, ListEnableHdl, Edit&, void) + +IMPL_LINK_NOARG(SwFieldFuncPage, ListEnableHdl, weld::Entry&, void) { //enable "Add" button when text is in the Edit that's not already member of the box - m_pListAddPB->Enable(!m_pListItemED->GetText().isEmpty() && - LISTBOX_ENTRY_NOTFOUND == m_pListItemsLB->GetEntryPos(m_pListItemED->GetText())); - bool bEnableButtons = m_pListItemsLB->GetSelectedEntryCount() > 0; - m_pListRemovePB->Enable(bEnableButtons); - m_pListUpPB->Enable(bEnableButtons && (m_pListItemsLB->GetSelectedEntryPos() > 0)); - m_pListDownPB->Enable(bEnableButtons && - (m_pListItemsLB->GetSelectedEntryPos() < (m_pListItemsLB->GetEntryCount() - 1))); + m_xListAddPB->set_sensitive(!m_xListItemED->get_text().isEmpty() && + -1 == m_xListItemsLB->find_text(m_xListItemED->get_text())); + bool bEnableButtons = m_xListItemsLB->get_selected_index() != -1; + m_xListRemovePB->set_sensitive(bEnableButtons); + m_xListUpPB->set_sensitive(bEnableButtons && (m_xListItemsLB->get_selected_index() > 0)); + m_xListDownPB->set_sensitive(bEnableButtons && + (m_xListItemsLB->get_selected_index() < (m_xListItemsLB->n_children() - 1))); } // renew types in SelectionBox void SwFieldFuncPage::UpdateSubType() { - const sal_uInt16 nTypeId = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(GetTypeSel()))); + const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); // fill Selection-Listbox - m_pSelectionLB->SetUpdateMode(false); - m_pSelectionLB->Clear(); + m_xSelectionLB->freeze(); + m_xSelectionLB->clear(); std::vector<OUString> aLst; GetFieldMgr().GetSubTypes(nTypeId, aLst); const size_t nCount = aLst.size(); - for(size_t i = 0; i < nCount; ++i) - { - size_t nPos = m_pSelectionLB->InsertEntry(aLst[i]); - m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i)); - } + for (size_t i = 0; i < nCount; ++i) + m_xSelectionLB->append(OUString::number(i), aLst[i]); + m_xSelectionLB->thaw(); bool bEnable = nCount != 0; - m_pSelectionLB->Enable( bEnable ); + m_xSelectionLB->set_sensitive( bEnable ); if (bEnable) - { - m_pSelectionLB->SelectEntryPos(0); - } + m_xSelectionLB->select(0); if (nTypeId == TYP_MACROFLD) { @@ -535,17 +499,15 @@ void SwFieldFuncPage::UpdateSubType() if (bHasMacro) { - m_pNameED->SetText(GetFieldMgr().GetMacroName()); - m_pValueGroup->Enable(); + m_xNameED->set_text(GetFieldMgr().GetMacroName()); + m_xValueGroup->set_sensitive(true); } EnableInsert(bHasMacro); } - - m_pSelectionLB->SetUpdateMode(true); } // call MacroBrowser, fill Listbox with Macros -IMPL_LINK_NOARG( SwFieldFuncPage, MacroHdl, Button *, void) +IMPL_LINK_NOARG( SwFieldFuncPage, MacroHdl, weld::Button&, void) { if (GetFieldMgr().ChooseMacro(GetDialogFrameWeld())) UpdateSubType(); @@ -553,23 +515,23 @@ IMPL_LINK_NOARG( SwFieldFuncPage, MacroHdl, Button *, void) bool SwFieldFuncPage::FillItemSet(SfxItemSet* ) { - const sal_uInt16 nTypeId = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(GetTypeSel()))); + const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); sal_uInt16 nSubType = 0; - const sal_Int32 nEntryPos = m_pFormatLB->GetSelectedEntryPos(); - const sal_uLong nFormat = (nEntryPos == LISTBOX_ENTRY_NOTFOUND) - ? 0 : reinterpret_cast<sal_uLong>(m_pFormatLB->GetEntryData(nEntryPos)); + const sal_Int32 nEntryPos = m_xFormatLB->get_selected_index(); + const sal_uLong nFormat = (nEntryPos == -1) + ? 0 : m_xFormatLB->get_id(nEntryPos).toUInt32(); - OUString aVal(m_pValueED->GetText()); - OUString aName(m_pNameED->GetText()); + OUString aVal(m_xValueED->get_text()); + OUString aName(m_xNameED->get_text()); switch(nTypeId) { case TYP_INPUTFLD: nSubType = INP_TXT; // to prevent removal of CR/LF restore old content - if(!m_pNameED->IsModified() && IsFieldEdit()) + if (!m_xNameED->get_value_changed_from_saved() && IsFieldEdit()) aName = GetCurField()->GetPar1(); break; @@ -580,16 +542,16 @@ bool SwFieldFuncPage::FillItemSet(SfxItemSet* ) break; case TYP_CONDTXTFLD: - aVal = m_pCond1ED->GetText() + "|" + m_pCond2ED->GetText(); + aVal = m_xCond1ED->get_text() + "|" + m_xCond2ED->get_text(); break; case TYP_DROPDOWN : { - aName = m_pListNameED->GetText(); - for(sal_Int32 i = 0; i < m_pListItemsLB->GetEntryCount(); i++) + aName = m_xListNameED->get_text(); + for (sal_Int32 i = 0, nEntryCount = m_xListItemsLB->n_children(); i < nEntryCount; ++i) { if(i) aVal += OUStringLiteral1(DB_DELIM); - aVal += m_pListItemsLB->GetEntry(i); + aVal += m_xListItemsLB->get_text(i); } } break; @@ -598,18 +560,18 @@ bool SwFieldFuncPage::FillItemSet(SfxItemSet* ) } if (!IsFieldEdit() || - m_pNameED->IsValueChangedFromSaved() || - m_pValueED->IsValueChangedFromSaved() || - m_pCond1ED->IsValueChangedFromSaved() || - m_pCond2ED->IsValueChangedFromSaved() || - m_pListNameED->IsValueChangedFromSaved() || + m_xNameED->get_value_changed_from_saved() || + m_xValueED->get_value_changed_from_saved() || + m_xCond1ED->get_value_changed_from_saved() || + m_xCond2ED->get_value_changed_from_saved() || + m_xListNameED->get_value_changed_from_saved() || bDropDownLBChanged || nOldFormat != nFormat) { InsertField( nTypeId, nSubType, aName, aVal, nFormat ); } - ModifyHdl(*m_pNameED); // enable/disable Insert if applicable + ModifyHdl(m_xNameED->get_widget()); // enable/disable Insert if applicable return false; } @@ -617,7 +579,7 @@ bool SwFieldFuncPage::FillItemSet(SfxItemSet* ) VclPtr<SfxTabPage> SwFieldFuncPage::Create( TabPageParent pParent, const SfxItemSet *const pAttrSet) { - return VclPtr<SwFieldFuncPage>::Create( pParent.pParent, pAttrSet ); + return VclPtr<SwFieldFuncPage>::Create( pParent, pAttrSet ); } sal_uInt16 SwFieldFuncPage::GetGroup() @@ -627,20 +589,19 @@ sal_uInt16 SwFieldFuncPage::GetGroup() void SwFieldFuncPage::FillUserData() { - const sal_Int32 nEntryPos = m_pTypeLB->GetSelectedEntryPos(); - const sal_uInt16 nTypeSel = ( LISTBOX_ENTRY_NOTFOUND == nEntryPos ) + const sal_Int32 nEntryPos = m_xTypeLB->get_selected_index(); + const sal_uInt16 nTypeSel = ( -1 == nEntryPos ) ? USHRT_MAX - : sal::static_int_cast< sal_uInt16 > - (reinterpret_cast< sal_uIntPtr >(m_pTypeLB->GetEntryData( nEntryPos ))); + : m_xTypeLB->get_id(nEntryPos).toUInt32(); SetUserData(USER_DATA_VERSION ";" + OUString::number( nTypeSel )); } -IMPL_LINK_NOARG(SwFieldFuncPage, ModifyHdl, Edit&, void) +IMPL_LINK_NOARG(SwFieldFuncPage, ModifyHdl, weld::Entry&, void) { - const sal_Int32 nLen = m_pNameED->GetText().getLength(); + const sal_Int32 nLen = m_xNameED->get_text().getLength(); bool bEnable = true; - sal_uInt16 nTypeId = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(GetTypeSel()))); + sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); if( TYP_COMBINED_CHARS == nTypeId && (!nLen || nLen > MAX_COMBINED_CHARACTERS )) diff --git a/sw/source/ui/fldui/fldfunc.hxx b/sw/source/ui/fldui/fldfunc.hxx index 086f369960d6..4013a94e9ddc 100644 --- a/sw/source/ui/fldui/fldfunc.hxx +++ b/sw/source/ui/fldui/fldfunc.hxx @@ -31,52 +31,52 @@ class SwFieldFuncPage : public SwFieldPage { - VclPtr<ListBox> m_pTypeLB; - VclPtr<ListBox> m_pSelectionLB; - VclPtr<VclContainer> m_pFormat; - VclPtr<ListBox> m_pFormatLB; - VclPtr<FixedText> m_pNameFT; - VclPtr<ConditionEdit> m_pNameED; - VclPtr<VclContainer> m_pValueGroup; - VclPtr<FixedText> m_pValueFT; - VclPtr<Edit> m_pValueED; - VclPtr<FixedText> m_pCond1FT; - VclPtr<ConditionEdit> m_pCond1ED; - VclPtr<FixedText> m_pCond2FT; - VclPtr<ConditionEdit> m_pCond2ED; - VclPtr<PushButton> m_pMacroBT; - - //controls of "Input list" - VclPtr<VclContainer> m_pListGroup; - VclPtr<FixedText> m_pListItemFT; - VclPtr<ReturnActionEdit> m_pListItemED; - VclPtr<PushButton> m_pListAddPB; - VclPtr<FixedText> m_pListItemsFT; - VclPtr<ListBox> m_pListItemsLB; - VclPtr<PushButton> m_pListRemovePB; - VclPtr<PushButton> m_pListUpPB; - VclPtr<PushButton> m_pListDownPB; - VclPtr<FixedText> m_pListNameFT; - VclPtr<Edit> m_pListNameED; - OUString m_sOldValueFT; OUString m_sOldNameFT; sal_uLong nOldFormat; bool bDropDownLBChanged; - DECL_LINK( TypeHdl, ListBox&, void ); - DECL_LINK( SelectHdl, ListBox&, void ); - DECL_LINK( InsertMacroHdl, ListBox&, void ); - DECL_LINK( ModifyHdl, Edit&, void ); - DECL_LINK( ListModifyReturnActionHdl, ReturnActionEdit&, void ); - DECL_LINK( ListModifyButtonHdl, Button*, void ); - DECL_LINK( ListEnableHdl, Edit&, void ); - DECL_LINK( ListEnableListBoxHdl, ListBox&, void ); - void ListModifyHdl(Control const *); + std::unique_ptr<weld::TreeView> m_xTypeLB; + std::unique_ptr<weld::TreeView> m_xSelectionLB; + std::unique_ptr<weld::Widget> m_xFormat; + std::unique_ptr<weld::TreeView> m_xFormatLB; + std::unique_ptr<weld::Label> m_xNameFT; + std::unique_ptr<SwConditionEdit> m_xNameED; + std::unique_ptr<weld::Widget> m_xValueGroup; + std::unique_ptr<weld::Label> m_xValueFT; + std::unique_ptr<weld::Entry> m_xValueED; + std::unique_ptr<weld::Label> m_xCond1FT; + std::unique_ptr<SwConditionEdit> m_xCond1ED; + std::unique_ptr<weld::Label> m_xCond2FT; + std::unique_ptr<SwConditionEdit> m_xCond2ED; + std::unique_ptr<weld::Button> m_xMacroBT; + + //controls of "Input list" + std::unique_ptr<weld::Widget> m_xListGroup; + std::unique_ptr<weld::Label> m_xListItemFT; + std::unique_ptr<weld::Entry> m_xListItemED; + std::unique_ptr<weld::Button> m_xListAddPB; + std::unique_ptr<weld::Label> m_xListItemsFT; + std::unique_ptr<weld::TreeView> m_xListItemsLB; + std::unique_ptr<weld::Button> m_xListRemovePB; + std::unique_ptr<weld::Button> m_xListUpPB; + std::unique_ptr<weld::Button> m_xListDownPB; + std::unique_ptr<weld::Label> m_xListNameFT; + std::unique_ptr<weld::Entry> m_xListNameED; + + DECL_LINK( TypeHdl, weld::TreeView&, void ); + DECL_LINK( SelectHdl, weld::TreeView&, void ); + DECL_LINK( InsertMacroHdl, weld::TreeView&, void ); + DECL_LINK( ModifyHdl, weld::Entry&, void ); + DECL_LINK( ListModifyReturnActionHdl, weld::Entry&, bool ); + DECL_LINK( ListModifyButtonHdl, weld::Button&, void ); + DECL_LINK( ListEnableHdl, weld::Entry&, void ); + DECL_LINK( ListEnableListBoxHdl, weld::TreeView&, void ); + void ListModifyHdl(const weld::Widget*); // select Macro - DECL_LINK( MacroHdl, Button *, void ); + DECL_LINK( MacroHdl, weld::Button&, void ); void UpdateSubType(); @@ -84,10 +84,8 @@ protected: virtual sal_uInt16 GetGroup() override; public: - SwFieldFuncPage(vcl::Window* pParent, const SfxItemSet* pSet); - - virtual ~SwFieldFuncPage() override; - virtual void dispose() override; + SwFieldFuncPage(TabPageParent pParent, const SfxItemSet* pSet); + virtual ~SwFieldFuncPage() override; static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet* rAttrSet); diff --git a/sw/source/ui/fldui/fldpage.cxx b/sw/source/ui/fldui/fldpage.cxx index 1cc166356c24..8c961cd6fe30 100644 --- a/sw/source/ui/fldui/fldpage.cxx +++ b/sw/source/ui/fldui/fldpage.cxx @@ -57,6 +57,21 @@ SwFieldPage::SwFieldPage(vcl::Window *pParent, const OString& rID, { } +SwFieldPage::SwFieldPage(TabPageParent pParent, const OUString& rUIXMLDescription, + const OString& rID, const SfxItemSet *pAttrSet) + : SfxTabPage(pParent, rUIXMLDescription, rID, pAttrSet) + , m_pCurField(nullptr) + , m_pWrtShell(nullptr) + , m_nTypeSel(LISTBOX_ENTRY_NOTFOUND) + , m_nSelectionSel(LISTBOX_ENTRY_NOTFOUND) + , m_bFieldEdit(false) + , m_bInsert(true) + , m_bFieldDlgHtmlMode(false) + , m_bRefresh(false) + , m_bFirstHTMLInit(true) +{ +} + SwFieldPage::~SwFieldPage() { } @@ -291,6 +306,16 @@ void SwFieldPage::SavePos( const ListBox* pLst1 ) m_aLstStrArr[ 2 ].clear(); } +void SwFieldPage::SavePos( const weld::TreeView& rLst1 ) +{ + if (rLst1.n_children()) + m_aLstStrArr[ 0 ] = rLst1.get_selected_text(); + else + m_aLstStrArr[ 0 ].clear(); + m_aLstStrArr[ 1 ].clear(); + m_aLstStrArr[ 2 ].clear(); +} + void SwFieldPage::RestorePos(ListBox* pLst1) { sal_Int32 nPos = 0; @@ -300,6 +325,14 @@ void SwFieldPage::RestorePos(ListBox* pLst1) pLst1->SelectEntryPos( nPos ); } +void SwFieldPage::RestorePos(weld::TreeView& rLst1) +{ + sal_Int32 nPos = 0; + if (rLst1.n_children() && !m_aLstStrArr[ 0 ].isEmpty() && + -1 != ( nPos = rLst1.find_text(m_aLstStrArr[ 0 ] ) ) ) + rLst1.select( nPos ); +} + // Insert new fields IMPL_LINK( SwFieldPage, TreeListBoxInsertHdl, SvTreeListBox*, pBtn, bool ) { @@ -312,6 +345,11 @@ IMPL_LINK( SwFieldPage, ListBoxInsertHdl, ListBox&, rBox, void ) InsertHdl(&rBox); } +IMPL_LINK( SwFieldPage, TreeViewInsertHdl, weld::TreeView&, rBox, void ) +{ + InsertHdl(&rBox); +} + void SwFieldPage::InsertHdl(void* pBtn) { SwFieldDlg *pDlg = static_cast<SwFieldDlg*>(GetTabDialog()); diff --git a/sw/source/ui/fldui/fldpage.hxx b/sw/source/ui/fldui/fldpage.hxx index 4fa6c41dbf08..650989d51f01 100644 --- a/sw/source/ui/fldui/fldpage.hxx +++ b/sw/source/ui/fldui/fldpage.hxx @@ -55,13 +55,16 @@ protected: SwWrtShell* GetWrtShell() { return m_pWrtShell;} DECL_LINK( ListBoxInsertHdl, ListBox&, void ); + DECL_LINK( TreeViewInsertHdl, weld::TreeView&, void ); DECL_LINK( TreeListBoxInsertHdl, SvTreeListBox*, bool ); DECL_LINK( NumFormatHdl, ListBox&, void ); void InsertHdl(void *); void Init(); void SavePos( const ListBox* pLst1); + void SavePos( const weld::TreeView& rLst1); void RestorePos( ListBox* pLst1 ); + void RestorePos( weld::TreeView& rLst1 ); void EnableInsert(bool bEnable); bool IsFieldEdit() const { return m_bFieldEdit; } @@ -79,6 +82,8 @@ protected: public: SwFieldPage(vcl::Window *pParent, const OString& rID, const OUString& rUIXMLDescription, const SfxItemSet *pAttrSet); + SwFieldPage(TabPageParent pParent, const OUString& rUIXMLDescription, + const OString& rID, const SfxItemSet *pAttrSet); virtual ~SwFieldPage() override; diff --git a/sw/source/uibase/cctrl/actctrl.cxx b/sw/source/uibase/cctrl/actctrl.cxx index 92f97a00f5e2..6f3a286521b3 100644 --- a/sw/source/uibase/cctrl/actctrl.cxx +++ b/sw/source/uibase/cctrl/actctrl.cxx @@ -54,23 +54,4 @@ bool NumEditAction::EventNotify( NotifyEvent& rNEvt ) return bHandled; } -void ReturnActionEdit::KeyInput( const KeyEvent& rEvt) -{ - const vcl::KeyCode aKeyCode = rEvt.GetKeyCode(); - const sal_uInt16 nModifier = aKeyCode.GetModifier(); - if( aKeyCode.GetCode() == KEY_RETURN && - !nModifier) - { - aReturnActionLink.Call(*this); - } - else - Edit::KeyInput(rEvt); -} - -extern "C" SAL_DLLPUBLIC_EXPORT void makeReturnActionEdit(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap) -{ - BuilderUtils::ensureDefaultWidthChars(rMap); - rRet = VclPtr<ReturnActionEdit>::Create(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/actctrl.hxx b/sw/source/uibase/inc/actctrl.hxx index 87ef21e61859..93dae6f72f99 100644 --- a/sw/source/uibase/inc/actctrl.hxx +++ b/sw/source/uibase/inc/actctrl.hxx @@ -39,21 +39,6 @@ public: void SetActionHdl( const Link<NumEditAction&,void>& rLink ) { aActionLink = rLink;} }; -// call a link when KEY_RETURN is pressed -class SW_DLLPUBLIC ReturnActionEdit : public Edit -{ - Link<ReturnActionEdit&,void> aReturnActionLink; -public: - ReturnActionEdit(vcl::Window* pParent, WinBits nStyle) - : Edit(pParent, nStyle) - { - } - virtual void KeyInput( const KeyEvent& ) override; - - void SetReturnActionLink(const Link<ReturnActionEdit&,void>& rLink) - { aReturnActionLink = rLink;} -}; - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/condedit.hxx b/sw/source/uibase/inc/condedit.hxx index 81716bda93f0..b433129dd49d 100644 --- a/sw/source/uibase/inc/condedit.hxx +++ b/sw/source/uibase/inc/condedit.hxx @@ -70,7 +70,11 @@ public: OUString get_text() const { return m_xControl->get_text(); } void set_text(const OUString& rText) { m_xControl->set_text(rText); } + void set_visible(bool bVisible) { m_xControl->set_visible(bVisible); } + void set_accessible_name(const OUString& rName) { m_xControl->set_accessible_name(rName); } bool get_sensitive() const { return m_xControl->get_sensitive(); } + void save_value() { m_xControl->save_value(); } + bool get_value_changed_from_saved() const { return m_xControl->get_value_changed_from_saved(); } void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); } void connect_changed(const Link<weld::Entry&, void>& rLink) { m_xControl->connect_changed(rLink); } void hide() { m_xControl->hide(); } diff --git a/sw/uiconfig/swriter/ui/fldfuncpage.ui b/sw/uiconfig/swriter/ui/fldfuncpage.ui index b8ba4c084ccc..99fbf069c27e 100644 --- a/sw/uiconfig/swriter/ui/fldfuncpage.ui +++ b/sw/uiconfig/swriter/ui/fldfuncpage.ui @@ -1,7 +1,31 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> <interface domain="sw"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> + <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="GtkBox" id="FieldFuncPage"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -22,14 +46,37 @@ <property name="hexpand">True</property> <property name="top_padding">6</property> <child> - <object class="GtkTreeView" id="type: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-selection1"/> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="type"> + <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> </child> @@ -39,9 +86,9 @@ <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="fldfuncpage|label1">_Type</property> <property name="use_underline">True</property> + <property name="xalign">0</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -68,16 +115,37 @@ <property name="hexpand">True</property> <property name="top_padding">6</property> <child> - <object class="GtkTreeView" id="select: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="model">liststore1</property> - <property name="search_column">0</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="select"> + <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> </child> @@ -87,9 +155,9 @@ <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="fldfuncpage|label4">S_elect</property> <property name="use_underline">True</property> + <property name="xalign">0</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -116,15 +184,37 @@ <property name="hexpand">True</property> <property name="top_padding">6</property> <child> - <object class="GtkTreeView" id="format: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="model">liststore1</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="format"> + <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> </child> @@ -134,9 +224,9 @@ <object class="GtkLabel" id="label2"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="fldfuncpage|label2">F_ormat</property> <property name="use_underline">True</property> + <property name="xalign">0</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -153,8 +243,8 @@ <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="row_spacing">12</property> <property name="hexpand">True</property> + <property name="row_spacing">12</property> <child> <object class="GtkButton" id="macro"> <property name="label" translatable="yes" context="fldfuncpage|macro">_Macro...</property> @@ -167,30 +257,26 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">5</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> <object class="GtkGrid" id="valuegroup"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="row_spacing">6</property> <property name="hexpand">True</property> + <property name="row_spacing">6</property> <child> <object class="GtkLabel" id="valueft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="fldfuncpage|valueft">_Value</property> <property name="use_underline">True</property> <property name="mnemonic_widget">value</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -198,106 +284,93 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> + <property name="activates_default">True</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> <object class="GtkGrid" id="grid3"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="row_spacing">6</property> <property name="hexpand">True</property> + <property name="row_spacing">6</property> <child> <object class="GtkLabel" id="nameft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="fldfuncpage|nameft">Na_me</property> <property name="use_underline">True</property> <property name="mnemonic_widget">condFunction</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="swlo-ConditionEdit" id="condFunction"> + <object class="GtkEntry" id="condFunction"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> + <property name="activates_default">True</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> <object class="GtkGrid" id="grid4"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="row_spacing">6</property> <property name="hexpand">True</property> + <property name="row_spacing">6</property> <child> <object class="GtkLabel" id="cond1ft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="fldfuncpage|cond1ft">Then</property> <property name="use_underline">True</property> <property name="mnemonic_widget">cond1</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="swlo-ConditionEdit" id="cond1"> + <object class="GtkEntry" id="cond1"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> + <property name="activates_default">True</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -309,37 +382,32 @@ <object class="GtkLabel" id="cond2ft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="fldfuncpage|cond2ft">Else</property> <property name="use_underline">True</property> <property name="mnemonic_widget">cond2</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="swlo-ConditionEdit" id="cond2"> + <object class="GtkEntry" id="cond2"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> + <property name="activates_default">True</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">4</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -351,43 +419,38 @@ <object class="GtkGrid" id="grid9"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="row_spacing">6</property> <property name="hexpand">True</property> + <property name="row_spacing">6</property> <child> <object class="GtkLabel" id="itemft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="fldfuncpage|itemft">It_em</property> <property name="use_underline">True</property> <property name="mnemonic_widget">item</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="swlo-ReturnActionEdit" id="item"> + <object class="GtkEntry" id="item"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> + <property name="activates_default">True</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -402,8 +465,6 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -415,20 +476,18 @@ <object class="GtkLabel" id="listitemft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="fldfuncpage|listitemft">Items on _list</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">listitems:border</property> + <property name="mnemonic_widget">listitems</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="GtkTreeView" id="listitems:border"> + <object class="GtkTreeView" id="listitems"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> @@ -440,8 +499,6 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -499,8 +556,6 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -512,16 +567,14 @@ <object class="GtkLabel" id="listnameft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="fldfuncpage|listnameft">Na_me</property> <property name="use_underline">True</property> <property name="mnemonic_widget">listname</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -529,36 +582,29 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> + <property name="activates_default">True</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> @@ -569,18 +615,12 @@ </packing> </child> </object> - <object class="GtkTreeStore" id="liststore1"> - <columns> - <!-- column-name gchararray1 --> - <column type="gchararray"/> - </columns> - </object> <object class="GtkSizeGroup" id="sizegroup1"> <property name="mode">both</property> <widgets> - <widget name="type:border"/> - <widget name="select:border"/> - <widget name="format:border"/> + <widget name="type"/> + <widget name="select"/> + <widget name="format"/> </widgets> </object> </interface> commit 338e562639f947f9aa5fcd7340fe87a57b0f3601 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Mar 11 14:55:23 2019 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sat Mar 16 22:17:05 2019 +0100 weld ScAutoFormatDlg Change-Id: I700034eefe9fb25ee331645283bd3611c88faf5b Reviewed-on: https://gerrit.libreoffice.org/69052 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index a420ad7f9864..d1583ef900ef 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -189,9 +189,6 @@ <glade-widget-class title="Table Preview" name="swuilo-AutoFmtPreview" generic-name="Table Preview Window" parent="GtkDrawingArea" icon-name="widget-gtk-drawingarea"/> - <glade-widget-class title="Calc Table Preview" name="sclo-ScAutoFmtPreview" - generic-name="Calc Table Preview Window" parent="GtkDrawingArea" - icon-name="widget-gtk-drawingarea"/> <glade-widget-class title="Extension List" name="deploymentgui-ExtensionBox" generic-name="Extensions List" parent="GtkDrawingArea" icon-name="widget-gtk-drawingarea"/> diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx index 3c6812562c48..4a5d326049a1 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -400,7 +400,7 @@ public: virtual VclPtr<AbstractScTextImportOptionsDlg> CreateScTextImportOptionsDlg(weld::Window* pParent) = 0; - virtual VclPtr<AbstractScAutoFormatDlg> CreateScAutoFormatDlg(vcl::Window* pParent, + virtual VclPtr<AbstractScAutoFormatDlg> CreateScAutoFormatDlg(weld::Window* pParent, ScAutoFormat* pAutoFormat, const ScAutoFormatData* pSelFormatData, ScViewData *pViewData) = 0; diff --git a/sc/qa/uitest/calc_tests6/autoFormat.py b/sc/qa/uitest/calc_tests6/autoFormat.py index e5ecb485e935..c38165f36c36 100644 --- a/sc/qa/uitest/calc_tests6/autoFormat.py +++ b/sc/qa/uitest/calc_tests6/autoFormat.py @@ -32,9 +32,8 @@ class autoFormat(UITestCase): alignmentcb = xDialog.getChild("alignmentcb") autofitcb = xDialog.getChild("autofitcb") - props = {"TEXT": "Financial"} - actionProps = mkPropertyValues(props) - formatlb.executeAction("SELECT", actionProps) + entry = formatlb.getChild("7") #Financial + entry.executeAction("SELECT", tuple()) numformatcb.executeAction("CLICK", tuple()) bordercb.executeAction("CLICK", tuple()) fontcb.executeAction("CLICK", tuple()) @@ -57,9 +56,8 @@ class autoFormat(UITestCase): alignmentcb = xDialog.getChild("alignmentcb") autofitcb = xDialog.getChild("autofitcb") - props = {"TEXT": "Financial"} - actionProps = mkPropertyValues(props) - formatlb.executeAction("SELECT", actionProps) + entry = formatlb.getChild("7") #Financial + entry.executeAction("SELECT", tuple()) self.assertEqual(get_state_as_dict(numformatcb)["Selected"], "false") self.assertEqual(get_state_as_dict(bordercb)["Selected"], "false") self.assertEqual(get_state_as_dict(fontcb)["Selected"], "false") diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index 86d8966b0409..88a153120400 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -71,7 +71,11 @@ #include <conditio.hxx> IMPL_ABSTDLG_BASE(AbstractScImportAsciiDlg_Impl); -IMPL_ABSTDLG_BASE(AbstractScAutoFormatDlg_Impl); + +short AbstractScAutoFormatDlg_Impl::Execute() +{ + return m_xDlg->run(); +} short AbstractScColRowLabelDlg_Impl::Execute() { @@ -269,15 +273,15 @@ void AbstractScImportAsciiDlg_Impl::SaveParameters() sal_uInt16 AbstractScAutoFormatDlg_Impl::GetIndex() const { - return pDlg->GetIndex(); + return m_xDlg->GetIndex(); } OUString AbstractScAutoFormatDlg_Impl::GetCurrFormatName() { - return pDlg->GetCurrFormatName(); + return m_xDlg->GetCurrFormatName(); } -bool AbstractScColRowLabelDlg_Impl::IsCol() +bool AbstractScColRowLabelDlg_Impl::IsCol() { return m_xDlg->IsCol(); } @@ -763,13 +767,12 @@ VclPtr<AbstractScTextImportOptionsDlg> ScAbstractDialogFactory_Impl::CreateScTex return VclPtr<AbstractScTextImportOptionsDlg_Impl>::Create(std::make_unique<ScTextImportOptionsDlg>(pParent)); } -VclPtr<AbstractScAutoFormatDlg> ScAbstractDialogFactory_Impl::CreateScAutoFormatDlg(vcl::Window* pParent, +VclPtr<AbstractScAutoFormatDlg> ScAbstractDialogFactory_Impl::CreateScAutoFormatDlg(weld::Window* pParent, ScAutoFormat* pAutoFormat, const ScAutoFormatData* pSelFormatData, ScViewData *pViewData) { - VclPtr<ScAutoFormatDlg> pDlg = VclPtr<ScAutoFormatDlg>::Create(pParent, pAutoFormat, pSelFormatData, pViewData); - return VclPtr<AbstractScAutoFormatDlg_Impl>::Create(pDlg); + return VclPtr<AbstractScAutoFormatDlg_Impl>::Create(std::make_unique<ScAutoFormatDlg>(pParent, pAutoFormat, pSelFormatData, pViewData)); } VclPtr<AbstractScColRowLabelDlg> ScAbstractDialogFactory_Impl::CreateScColRowLabelDlg(weld::Window* pParent, diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index 471d22a9e8cb..c752101f82af 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -105,7 +105,13 @@ class AbstractScImportAsciiDlg_Impl : public AbstractScImportAsciiDlg class AbstractScAutoFormatDlg_Impl : public AbstractScAutoFormatDlg { - DECL_ABSTDLG_BASE(AbstractScAutoFormatDlg_Impl, ScAutoFormatDlg) + std::unique_ptr<ScAutoFormatDlg> m_xDlg; +public: + explicit AbstractScAutoFormatDlg_Impl(std::unique_ptr<ScAutoFormatDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; virtual sal_uInt16 GetIndex() const override; virtual OUString GetCurrFormatName() override; }; @@ -586,7 +592,7 @@ public: virtual VclPtr<AbstractScTextImportOptionsDlg> CreateScTextImportOptionsDlg(weld::Window* pParent) override; - virtual VclPtr<AbstractScAutoFormatDlg> CreateScAutoFormatDlg(vcl::Window* pParent, + virtual VclPtr<AbstractScAutoFormatDlg> CreateScAutoFormatDlg(weld::Window* pParent, ScAutoFormat* pAutoFormat, const ScAutoFormatData* pSelFormatData, ScViewData *pViewData) override; diff --git a/sc/source/ui/inc/autofmt.hxx b/sc/source/ui/inc/autofmt.hxx index 723e1ba555f9..84a29c6b6d19 100644 --- a/sc/source/ui/inc/autofmt.hxx +++ b/sc/source/ui/inc/autofmt.hxx @@ -22,7 +22,7 @@ #include <svx/framelinkarray.hxx> #include <scdllapi.h> -#include <vcl/window.hxx> +#include <vcl/customweld.hxx> namespace com { namespace sun { namespace star { namespace i18n { class XBreakIterator; } } } } @@ -33,13 +33,13 @@ class SvNumberFormatter; class VirtualDevice; class ScViewData; -class SC_DLLPUBLIC ScAutoFmtPreview : public vcl::Window +class SC_DLLPUBLIC ScAutoFmtPreview : public weld::CustomWidgetController { public: - ScAutoFmtPreview(vcl::Window* pParent); + ScAutoFmtPreview(); void DetectRTL(const ScViewData *pViewData); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; virtual ~ScAutoFmtPreview() override; - virtual void dispose() override; void NotifyChange( ScAutoFormatData* pNewData ); @@ -85,8 +85,8 @@ private: SAL_DLLPRIVATE void DrawString(vcl::RenderContext& rRenderContext, size_t nCol, size_t nRow); SAL_DLLPRIVATE void DrawBackground(vcl::RenderContext& rRenderContext); - SAL_DLLPRIVATE void MakeFonts(sal_uInt16 nIndex, vcl::Font& rFont, - vcl::Font& rCJKFont, vcl::Font& rCTLFont ); + SAL_DLLPRIVATE void MakeFonts(vcl::RenderContext const& rRenderContext, sal_uInt16 nIndex, + vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont); }; #endif // INCLUDED_SC_SOURCE_UI_INC_AUTOFMT_HXX diff --git a/sc/source/ui/inc/scuiautofmt.hxx b/sc/source/ui/inc/scuiautofmt.hxx index a00beb1e68de..6ddaf400ac94 100644 --- a/sc/source/ui/inc/scuiautofmt.hxx +++ b/sc/source/ui/inc/scuiautofmt.hxx @@ -18,35 +18,23 @@ */ #ifndef INCLUDED_SC_SOURCE_UI_INC_SCUIAUTOFMT_HXX #define INCLUDED_SC_SOURCE_UI_INC_SCUIAUTOFMT_HXX + +#include <vcl/customweld.hxx> #include "autofmt.hxx" -class ScAutoFormatDlg : public ModalDialog +class ScAutoFormatDlg : public weld::GenericDialogController { public: - ScAutoFormatDlg(vcl::Window* pParent, + ScAutoFormatDlg(weld::Window* pParent, ScAutoFormat* pAutoFormat, const ScAutoFormatData* pSelFormatData, const ScViewData *pViewData); virtual ~ScAutoFormatDlg() override; - virtual void dispose() override; sal_uInt16 GetIndex() const { return nIndex; } OUString GetCurrFormatName(); private: - VclPtr<ListBox> m_pLbFormat; - VclPtr<ScAutoFmtPreview> m_pWndPreview; - VclPtr<OKButton> m_pBtnOk; - VclPtr<CancelButton> m_pBtnCancel; - VclPtr<PushButton> m_pBtnAdd; - VclPtr<PushButton> m_pBtnRemove; - VclPtr<PushButton> m_pBtnRename; - VclPtr<CheckBox> m_pBtnNumFormat; - VclPtr<CheckBox> m_pBtnBorder; - VclPtr<CheckBox> m_pBtnFont; - VclPtr<CheckBox> m_pBtnPattern; - VclPtr<CheckBox> m_pBtnAlignment; - VclPtr<CheckBox> m_pBtnAdjust; OUString const aStrTitle; OUString const aStrLabel; OUString const aStrClose; @@ -59,16 +47,31 @@ private: bool bCoreDataChanged; bool bFmtInserted; + ScAutoFmtPreview m_aWndPreview; + std::unique_ptr<weld::TreeView> m_xLbFormat; + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Button> m_xBtnCancel; + std::unique_ptr<weld::Button> m_xBtnAdd; + std::unique_ptr<weld::Button> m_xBtnRemove; + std::unique_ptr<weld::Button> m_xBtnRename; + std::unique_ptr<weld::CheckButton> m_xBtnNumFormat; + std::unique_ptr<weld::CheckButton> m_xBtnBorder; + std::unique_ptr<weld::CheckButton> m_xBtnFont; + std::unique_ptr<weld::CheckButton> m_xBtnPattern; + std::unique_ptr<weld::CheckButton> m_xBtnAlignment; + std::unique_ptr<weld::CheckButton> m_xBtnAdjust; + std::unique_ptr<weld::CustomWeld> m_xWndPreview; + void Init (); void UpdateChecks (); - DECL_LINK( CheckHdl, Button*, void ); - DECL_LINK( AddHdl, Button*, void ); - DECL_LINK( RemoveHdl, Button*, void ); - DECL_LINK( SelFmtHdl, ListBox&, void ); - DECL_LINK( CloseHdl, Button *, void ); - DECL_LINK( DblClkHdl, ListBox&, void ); - DECL_LINK( RenameHdl, Button*, void ); + DECL_LINK( CheckHdl, weld::ToggleButton&, void ); + DECL_LINK( AddHdl, weld::Button&, void ); + DECL_LINK( RemoveHdl, weld::Button&, void ); + DECL_LINK( SelFmtHdl, weld::TreeView&, void ); + DECL_LINK( CloseHdl, weld::Button&, void ); + DECL_LINK( DblClkHdl, weld::TreeView&, void ); + DECL_LINK( RenameHdl, weld::Button&, void ); }; #endif diff --git a/sc/source/ui/miscdlgs/autofmt.cxx b/sc/source/ui/miscdlgs/autofmt.cxx index e031ccbca417..a64104548f2b 100644 --- a/sc/source/ui/miscdlgs/autofmt.cxx +++ b/sc/source/ui/miscdlgs/autofmt.cxx @@ -49,10 +49,8 @@ // ScAutoFmtPreview -ScAutoFmtPreview::ScAutoFmtPreview(vcl::Window* pParent) - : Window(pParent) - , pCurData(nullptr) - , aVD(*this) +ScAutoFmtPreview::ScAutoFmtPreview() + : pCurData(nullptr) , bFitWidth(false) , mbRTL(false) , aStrJan(ScResId(STR_JAN)) @@ -67,11 +65,16 @@ ScAutoFmtPreview::ScAutoFmtPreview(vcl::Window* pParent) Init(); } -VCL_BUILDER_FACTORY(ScAutoFmtPreview) +void ScAutoFmtPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ + aVD.disposeAndReset(VclPtr<VirtualDevice>::Create(pDrawingArea->get_ref_device())); + CustomWidgetController::SetDrawingArea(pDrawingArea); +} void ScAutoFmtPreview::Resize() { - aPrvSize = Size(GetSizePixel().Width() - 6, GetSizePixel().Height() - 30); + Size aSize(GetOutputSizePixel()); + aPrvSize = Size(aSize.Width() - 6, aSize.Height() - 30); mnLabelColWidth = (aPrvSize.Width() - 4) / 4 - 12; mnDataColWidth1 = (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 3; mnDataColWidth2 = (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 4; @@ -81,13 +84,6 @@ void ScAutoFmtPreview::Resize() ScAutoFmtPreview::~ScAutoFmtPreview() { - disposeOnce(); -} - -void ScAutoFmtPreview::dispose() -{ - pNumFmt.reset(); - vcl::Window::dispose(); } static void lcl_SetFontProperties( @@ -105,12 +101,12 @@ static void lcl_SetFontProperties( rFont.SetItalic ( rPostureItem.GetValue() ); } -void ScAutoFmtPreview::MakeFonts( sal_uInt16 nIndex, vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont ) +void ScAutoFmtPreview::MakeFonts(vcl::RenderContext const& rRenderContext, sal_uInt16 nIndex, vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont) { if ( pCurData ) { - rFont = rCJKFont = rCTLFont = GetFont(); - Size aFontSize( rFont.GetFontSize().Width(), 10 * GetDPIScaleFactor() ); + rFont = rCJKFont = rCTLFont = rRenderContext.GetFont(); + Size aFontSize(rFont.GetFontSize().Width(), 10 * rRenderContext.GetDPIScaleFactor()); const SvxFontItem* pFontItem = pCurData->GetItem( nIndex, ATTR_FONT ); const SvxWeightItem* pWeightItem = pCurData->GetItem( nIndex, ATTR_FONT_WEIGHT ); @@ -134,7 +130,7 @@ void ScAutoFmtPreview::MakeFonts( sal_uInt16 nIndex, vcl::Font& rFont, vcl::Font Color aColor( pColorItem->GetValue() ); if( aColor == COL_TRANSPARENT ) - aColor = GetSettings().GetStyleSettings().GetWindowTextColor(); + aColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor(); #define SETONALLFONTS( MethodName, Value ) \ rFont.MethodName( Value ); rCJKFont.MethodName( Value ); rCTLFont.MethodName( Value ); @@ -263,7 +259,7 @@ void ScAutoFmtPreview::DrawString(vcl::RenderContext& rRenderContext, size_t nCo vcl::Font aFont, aCJKFont, aCTLFont; Size theMaxStrSize; - MakeFonts( nFmtIndex, aFont, aCJKFont, aCTLFont ); + MakeFonts(rRenderContext, nFmtIndex, aFont, aCJKFont, aCTLFont); theMaxStrSize = Size(basegfx::fround(cellRange.getWidth()), basegfx::fround(cellRange.getHeight())); theMaxStrSize.AdjustWidth( -(FRAME_OFFSET) ); @@ -413,9 +409,7 @@ void ScAutoFmtPreview::PaintCells(vcl::RenderContext& rRenderContext) void ScAutoFmtPreview::Init() { - SetBorderStyle( WindowBorderStyle::MONO ); maArray.Initialize( 5, 5 ); -// maArray.SetUseDiagDoubleClipping( false ); mnLabelColWidth = 0; mnDataColWidth1 = 0; mnDataColWidth2 = 0; @@ -491,14 +485,15 @@ void ScAutoFmtPreview::NotifyChange( ScAutoFormatData* pNewData ) CalcCellArray( bFitWidth ); CalcLineMap(); - Invalidate(tools::Rectangle(Point(0,0), GetSizePixel())); + Invalidate(); } void ScAutoFmtPreview::DoPaint(vcl::RenderContext& rRenderContext) { + rRenderContext.Push(PushFlags::ALL); DrawModeFlags nOldDrawMode = aVD->GetDrawMode(); - Size aWndSize(GetSizePixel()); + Size aWndSize(GetOutputSizePixel()); vcl::Font aFont(aVD->GetFont()); Color aBackCol(rRenderContext.GetSettings().GetStyleSettings().GetWindowColor()); tools::Rectangle aRect(Point(), aWndSize); @@ -521,6 +516,7 @@ void ScAutoFmtPreview::DoPaint(vcl::RenderContext& rRenderContext) aPos.setX( -aPos.X() ); rRenderContext.DrawOutDev(aPos, aWndSize, Point(), aWndSize, *aVD); aVD->SetDrawMode(nOldDrawMode); + rRenderContext.Pop(); } void ScAutoFmtPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/) diff --git a/sc/source/ui/miscdlgs/scuiautofmt.cxx b/sc/source/ui/miscdlgs/scuiautofmt.cxx index 4593ef712e17..fa5ced63c8b2 100644 --- a/sc/source/ui/miscdlgs/scuiautofmt.cxx +++ b/sc/source/ui/miscdlgs/scuiautofmt.cxx @@ -37,12 +37,11 @@ // AutoFormat-Dialog: -ScAutoFormatDlg::ScAutoFormatDlg(vcl::Window* pParent, +ScAutoFormatDlg::ScAutoFormatDlg(weld::Window* pParent, ScAutoFormat* pAutoFormat, const ScAutoFormatData* pSelFormatData, const ScViewData *pViewData) - : ModalDialog(pParent, "AutoFormatTableDialog", - "modules/scalc/ui/autoformattable.ui") + : GenericDialogController(pParent, "modules/scalc/ui/autoformattable.ui", "AutoFormatTableDialog") , aStrTitle(ScResId(STR_ADD_AUTOFORMAT_TITLE)) , aStrLabel(ScResId(STR_ADD_AUTOFORMAT_LABEL)) , aStrClose(ScResId(STR_BTN_AUTOFORMAT_CLOSE)) @@ -53,83 +52,69 @@ ScAutoFormatDlg::ScAutoFormatDlg(vcl::Window* pParent, , nIndex(0) , bCoreDataChanged(false) , bFmtInserted(false) + , m_xLbFormat(m_xBuilder->weld_tree_view("formatlb")) + , m_xBtnOk(m_xBuilder->weld_button("ok")) + , m_xBtnCancel(m_xBuilder->weld_button("cancel")) + , m_xBtnAdd(m_xBuilder->weld_button("add")) + , m_xBtnRemove(m_xBuilder->weld_button("remove")) + , m_xBtnRename(m_xBuilder->weld_button("rename")) + , m_xBtnNumFormat(m_xBuilder->weld_check_button("numformatcb")) + , m_xBtnBorder(m_xBuilder->weld_check_button("bordercb")) + , m_xBtnFont(m_xBuilder->weld_check_button("fontcb")) + , m_xBtnPattern(m_xBuilder->weld_check_button("patterncb")) + , m_xBtnAlignment(m_xBuilder->weld_check_button("alignmentcb")) + , m_xBtnAdjust(m_xBuilder->weld_check_button("autofitcb")) + , m_xWndPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aWndPreview)) { - get(m_pLbFormat, "formatlb"); - get(m_pWndPreview, "preview"); - m_pWndPreview->DetectRTL(pViewData); - get(m_pBtnOk, "ok"); - get(m_pBtnCancel, "cancel"); - get(m_pBtnAdd, "add"); - get(m_pBtnRemove, "remove"); - get(m_pBtnRename, "rename"); - get(m_pBtnNumFormat, "numformatcb"); - get(m_pBtnBorder, "bordercb"); - get(m_pBtnFont, "fontcb"); - get(m_pBtnPattern, "patterncb"); - get(m_pBtnAlignment, "alignmentcb"); - get(m_pBtnAdjust, "autofitcb"); + m_aWndPreview.DetectRTL(pViewData); + + const int nWidth = m_xLbFormat->get_approximate_digit_width() * 32; + const int nHeight = m_xLbFormat->get_height_rows(8); + m_xLbFormat->set_size_request(nWidth, nHeight); + m_xWndPreview->set_size_request(nWidth, nHeight); Init(); ScAutoFormat::iterator it = pFormat->begin(); - m_pWndPreview->NotifyChange(it->second.get()); + m_aWndPreview.NotifyChange(it->second.get()); } ScAutoFormatDlg::~ScAutoFormatDlg() { - disposeOnce(); -} - -void ScAutoFormatDlg::dispose() -{ - m_pLbFormat.clear(); - m_pWndPreview.clear(); - m_pBtnOk.clear(); - m_pBtnCancel.clear(); - m_pBtnAdd.clear(); - m_pBtnRemove.clear(); - m_pBtnRename.clear(); - m_pBtnNumFormat.clear(); - m_pBtnBorder.clear(); - m_pBtnFont.clear(); - m_pBtnPattern.clear(); - m_pBtnAlignment.clear(); - m_pBtnAdjust.clear(); - ModalDialog::dispose(); } void ScAutoFormatDlg::Init() { - m_pLbFormat->SetSelectHdl( LINK( this, ScAutoFormatDlg, SelFmtHdl ) ); - m_pBtnNumFormat->SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); - m_pBtnBorder->SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); - m_pBtnFont->SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); - m_pBtnPattern->SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); - m_pBtnAlignment->SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); - m_pBtnAdjust->SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); - m_pBtnAdd->SetClickHdl ( LINK( this, ScAutoFormatDlg, AddHdl ) ); - m_pBtnRemove->SetClickHdl ( LINK( this, ScAutoFormatDlg, RemoveHdl ) ); - m_pBtnOk->SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) ); - m_pBtnCancel->SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) ); - m_pBtnRename->SetClickHdl ( LINK( this, ScAutoFormatDlg, RenameHdl ) ); - m_pLbFormat->SetDoubleClickHdl( LINK( this, ScAutoFormatDlg, DblClkHdl ) ); + m_xLbFormat->connect_changed( LINK( this, ScAutoFormatDlg, SelFmtHdl ) ); + m_xBtnNumFormat->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) ); + m_xBtnBorder->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) ); + m_xBtnFont->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) ); + m_xBtnPattern->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) ); + m_xBtnAlignment->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) ); + m_xBtnAdjust->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) ); + m_xBtnAdd->connect_clicked ( LINK( this, ScAutoFormatDlg, AddHdl ) ); + m_xBtnRemove->connect_clicked ( LINK( this, ScAutoFormatDlg, RemoveHdl ) ); + m_xBtnOk->connect_clicked ( LINK( this, ScAutoFormatDlg, CloseHdl ) ); + m_xBtnCancel->connect_clicked ( LINK( this, ScAutoFormatDlg, CloseHdl ) ); + m_xBtnRename->connect_clicked ( LINK( this, ScAutoFormatDlg, RenameHdl ) ); + m_xLbFormat->connect_row_activated( LINK( this, ScAutoFormatDlg, DblClkHdl ) ); for (const auto& rEntry : *pFormat) - m_pLbFormat->InsertEntry(rEntry.second->GetName()); + m_xLbFormat->append_text(rEntry.second->GetName()); if (pFormat->size() == 1) - m_pBtnRemove->Disable(); + m_xBtnRemove->set_sensitive(false); - m_pLbFormat->SelectEntryPos( 0 ); - m_pBtnRename->Disable(); - m_pBtnRemove->Disable(); + m_xLbFormat->select(0); + m_xBtnRename->set_sensitive(false); + m_xBtnRemove->set_sensitive(false); nIndex = 0; UpdateChecks(); if ( !pSelFmtData ) { - m_pBtnAdd->Disable(); - m_pBtnRemove->Disable(); + m_xBtnAdd->set_sensitive(false); + m_xBtnRemove->set_sensitive(false); bFmtInserted = true; } } @@ -138,63 +123,63 @@ void ScAutoFormatDlg::UpdateChecks() { const ScAutoFormatData* pData = pFormat->findByIndex(nIndex); - m_pBtnNumFormat->Check( pData->GetIncludeValueFormat() ); - m_pBtnBorder->Check( pData->GetIncludeFrame() ); - m_pBtnFont->Check( pData->GetIncludeFont() ); - m_pBtnPattern->Check( pData->GetIncludeBackground() ); - m_pBtnAlignment->Check( pData->GetIncludeJustify() ); - m_pBtnAdjust->Check( pData->GetIncludeWidthHeight() ); + m_xBtnNumFormat->set_active( pData->GetIncludeValueFormat() ); + m_xBtnBorder->set_active( pData->GetIncludeFrame() ); + m_xBtnFont->set_active( pData->GetIncludeFont() ); + m_xBtnPattern->set_active( pData->GetIncludeBackground() ); + m_xBtnAlignment->set_active( pData->GetIncludeJustify() ); + m_xBtnAdjust->set_active( pData->GetIncludeWidthHeight() ); } // Handler: -IMPL_LINK( ScAutoFormatDlg, CloseHdl, Button *, pBtn, void ) +IMPL_LINK(ScAutoFormatDlg, CloseHdl, weld::Button&, rBtn, void) { - if (pBtn == m_pBtnOk || pBtn == m_pBtnCancel) + if (&rBtn == m_xBtnOk.get() || &rBtn == m_xBtnCancel.get()) { if ( bCoreDataChanged ) ScGlobal::GetOrCreateAutoFormat()->Save(); - EndDialog( (pBtn == m_pBtnOk) ? RET_OK : RET_CANCEL ); + m_xDialog->response( (&rBtn == m_xBtnOk.get()) ? RET_OK : RET_CANCEL ); } } -IMPL_LINK_NOARG(ScAutoFormatDlg, DblClkHdl, ListBox&, void) +IMPL_LINK_NOARG(ScAutoFormatDlg, DblClkHdl, weld::TreeView&, void) { if ( bCoreDataChanged ) ScGlobal::GetOrCreateAutoFormat()->Save(); - EndDialog( RET_OK ); + m_xDialog->response( RET_OK ); } -IMPL_LINK( ScAutoFormatDlg, CheckHdl, Button *, pBtn, void ) +IMPL_LINK(ScAutoFormatDlg, CheckHdl, weld::ToggleButton&, rBtn, void) { ScAutoFormatData* pData = pFormat->findByIndex(nIndex); - bool bCheck = static_cast<CheckBox*>(pBtn)->IsChecked(); + bool bCheck = rBtn.get_active(); - if ( pBtn == m_pBtnNumFormat ) + if (&rBtn == m_xBtnNumFormat.get()) pData->SetIncludeValueFormat( bCheck ); - else if ( pBtn == m_pBtnBorder ) + else if (&rBtn == m_xBtnBorder.get()) pData->SetIncludeFrame( bCheck ); - else if ( pBtn == m_pBtnFont ) + else if (&rBtn == m_xBtnFont.get()) pData->SetIncludeFont( bCheck ); - else if ( pBtn == m_pBtnPattern ) + else if (&rBtn == m_xBtnPattern.get()) pData->SetIncludeBackground( bCheck ); - else if ( pBtn == m_pBtnAlignment ) + else if (&rBtn == m_xBtnAlignment.get()) pData->SetIncludeJustify( bCheck ); - else if ( pBtn == m_pBtnAdjust ) + else if (&rBtn == m_xBtnAdjust.get()) pData->SetIncludeWidthHeight( bCheck ); if ( !bCoreDataChanged ) { - m_pBtnCancel->SetText( aStrClose ); + m_xBtnCancel->set_label(aStrClose); bCoreDataChanged = true; } - m_pWndPreview->NotifyChange( pData ); + m_aWndPreview.NotifyChange( pData ); } -IMPL_LINK_NOARG(ScAutoFormatDlg, AddHdl, Button*, void) +IMPL_LINK_NOARG(ScAutoFormatDlg, AddHdl, weld::Button&, void) { if ( !bFmtInserted && pSelFmtData ) { @@ -204,7 +189,7 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, AddHdl, Button*, void) while ( !bOk ) { - ScStringInputDlg aDlg(GetFrameWeld(), aStrTitle, aStrLabel, aFormatName, + ScStringInputDlg aDlg(m_xDialog.get(), aStrTitle, aStrLabel, aFormatName, HID_SC_ADD_AUTOFMT, HID_SC_AUTOFMT_NAME); if (aDlg.run() == RET_OK) ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits