diff options
-rw-r--r-- | extras/source/glade/libreoffice-catalog.xml.in | 4 | ||||
-rwxr-xr-x | solenv/bin/native-code.py | 1 | ||||
-rw-r--r-- | sw/source/ui/fldui/flddinf.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/fldui/flddinf.hxx | 1 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldfunc.cxx | 515 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldfunc.hxx | 82 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldpage.cxx | 38 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldpage.hxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/cctrl/actctrl.cxx | 19 | ||||
-rw-r--r-- | sw/source/uibase/inc/actctrl.hxx | 15 | ||||
-rw-r--r-- | sw/source/uibase/inc/condedit.hxx | 4 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/fldfuncpage.ui | 232 |
12 files changed, 468 insertions, 454 deletions
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> |