diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-06-15 11:27:51 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-06-16 15:46:16 +0200 |
commit | 765d91d84a423bdeab71c36117df764014683ba6 (patch) | |
tree | 5b926ae02d8e3ff81e75878e413717400838ddcd | |
parent | 9d4c5e2fab7490928937332a335e0a52ad4a95cb (diff) |
weld SwCharURLPage
Change-Id: I5263147c2dd15e6cab5b405d1680c2a3778137a6
Reviewed-on: https://gerrit.libreoffice.org/55861
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/source/ui/chrdlg/chardlg.cxx | 145 | ||||
-rw-r--r-- | sw/source/uibase/inc/chrdlg.hxx | 38 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/charurlpage.ui | 22 |
3 files changed, 96 insertions, 109 deletions
diff --git a/sw/source/ui/chrdlg/chardlg.cxx b/sw/source/ui/chrdlg/chardlg.cxx index 8680340f7819..ce27eae7dcfa 100644 --- a/sw/source/ui/chrdlg/chardlg.cxx +++ b/sw/source/ui/chrdlg/chardlg.cxx @@ -131,23 +131,21 @@ void SwCharDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) } } -SwCharURLPage::SwCharURLPage(vcl::Window* pParent, const SfxItemSet& rCoreSet) - : SfxTabPage(pParent, "CharURLPage", "modules/swriter/ui/charurlpage.ui", &rCoreSet) +SwCharURLPage::SwCharURLPage(TabPageParent pParent, const SfxItemSet& rCoreSet) + : SfxTabPage(pParent, "modules/swriter/ui/charurlpage.ui", "CharURLPage", &rCoreSet) , pINetItem(nullptr) , bModified(false) - + , m_xURLED(m_xBuilder->weld_entry("urled")) + , m_xTextFT(m_xBuilder->weld_label("textft")) + , m_xTextED(m_xBuilder->weld_entry("texted")) + , m_xNameED(m_xBuilder->weld_entry("nameed")) + , m_xTargetFrameLB(m_xBuilder->weld_combo_box_text("targetfrmlb")) + , m_xURLPB(m_xBuilder->weld_button("urlpb")) + , m_xEventPB(m_xBuilder->weld_button("eventpb")) + , m_xVisitedLB(m_xBuilder->weld_combo_box_text("visitedlb")) + , m_xNotVisitedLB(m_xBuilder->weld_combo_box_text("unvisitedlb")) + , m_xCharStyleContainer(m_xBuilder->weld_widget("charstyle")) { - get(m_pURLED, "urled"); - get(m_pTextFT, "textft"); - get(m_pTextED, "texted"); - get(m_pNameED, "nameed"); - get(m_pTargetFrameLB, "targetfrmlb"); - get(m_pURLPB, "urlpb"); - get(m_pEventPB, "eventpb"); - get(m_pVisitedLB, "visitedlb"); - get(m_pNotVisitedLB, "unvisitedlb"); - get(m_pCharStyleContainer, "charstyle"); - const SfxPoolItem* pItem; SfxObjectShell* pShell; if(SfxItemState::SET == rCoreSet.GetItemState(SID_HTML_MODE, false, &pItem) || @@ -155,31 +153,28 @@ SwCharURLPage::SwCharURLPage(vcl::Window* pParent, const SfxItemSet& rCoreSet) nullptr != (pItem = pShell->GetItem(SID_HTML_MODE)))) { sal_uInt16 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); - if(HTMLMODE_ON & nHtmlMode) - m_pCharStyleContainer->Hide(); + if (HTMLMODE_ON & nHtmlMode) + m_xCharStyleContainer->hide(); } - m_pURLPB->SetClickHdl (LINK( this, SwCharURLPage, InsertFileHdl)); - m_pEventPB->SetClickHdl(LINK( this, SwCharURLPage, EventHdl )); + m_xURLPB->connect_clicked(LINK( this, SwCharURLPage, InsertFileHdl)); + m_xEventPB->connect_clicked(LINK( this, SwCharURLPage, EventHdl)); SwView *pView = ::GetActiveView(); - ::FillCharStyleListBox(*m_pVisitedLB, pView->GetDocShell()); - ::FillCharStyleListBox(*m_pNotVisitedLB, pView->GetDocShell()); - m_pVisitedLB->SelectEntryPos(m_pVisitedLB->GetEntryPos(reinterpret_cast<void*>(RES_POOLCHR_INET_VISIT))); - m_pVisitedLB->SaveValue(); - m_pNotVisitedLB->SelectEntryPos(m_pNotVisitedLB->GetEntryPos(reinterpret_cast<void*>(RES_POOLCHR_INET_NORMAL))); - m_pNotVisitedLB->SaveValue(); + ::FillCharStyleListBox(*m_xVisitedLB, pView->GetDocShell()); + ::FillCharStyleListBox(*m_xNotVisitedLB, pView->GetDocShell()); + m_xVisitedLB->set_active_id(OUString::number(RES_POOLCHR_INET_VISIT)); + m_xVisitedLB->save_value(); + m_xNotVisitedLB->set_active_id(OUString::number(RES_POOLCHR_INET_NORMAL)); + m_xNotVisitedLB->save_value(); std::unique_ptr<TargetList> pList( new TargetList ); SfxFrame::GetDefaultTargetList(*pList); - if ( !pList->empty() ) - { - size_t nCount = pList->size(); - for ( size_t i = 0; i < nCount; i++ ) - { - m_pTargetFrameLB->InsertEntry( pList->at( i ) ); - } + size_t nCount = pList->size(); + for (size_t i = 0; i < nCount; ++i) + { + m_xTargetFrameLB->append_text(pList->at(i)); } } @@ -191,29 +186,20 @@ SwCharURLPage::~SwCharURLPage() void SwCharURLPage::dispose() { delete pINetItem; - m_pURLED.clear(); - m_pTextFT.clear(); - m_pTextED.clear(); - m_pNameED.clear(); - m_pTargetFrameLB.clear(); - m_pURLPB.clear(); - m_pEventPB.clear(); - m_pVisitedLB.clear(); - m_pNotVisitedLB.clear(); - m_pCharStyleContainer.clear(); SfxTabPage::dispose(); } void SwCharURLPage::Reset(const SfxItemSet* rSet) { const SfxPoolItem* pItem; - if ( SfxItemState::SET == rSet->GetItemState( RES_TXTATR_INETFMT, false, &pItem ) ) + if (SfxItemState::SET == rSet->GetItemState(RES_TXTATR_INETFMT, false, &pItem)) { const SwFormatINetFormat* pINetFormat = static_cast<const SwFormatINetFormat*>( pItem); - m_pURLED->SetText(INetURLObject::decode(pINetFormat->GetValue(), + m_xURLED->set_text(INetURLObject::decode(pINetFormat->GetValue(), INetURLObject::DecodeMechanism::Unambiguous)); - m_pURLED->SaveValue(); - m_pNameED->SetText(pINetFormat->GetName()); + m_xURLED->save_value(); + m_xNameED->set_text(pINetFormat->GetName()); + m_xNameED->save_value(); OUString sEntry = pINetFormat->GetVisitedFormat(); if (sEntry.isEmpty()) @@ -221,7 +207,7 @@ void SwCharURLPage::Reset(const SfxItemSet* rSet) OSL_ENSURE( false, "<SwCharURLPage::Reset(..)> - missing visited character format at hyperlink attribute" ); SwStyleNameMapper::FillUIName(RES_POOLCHR_INET_VISIT, sEntry); } - m_pVisitedLB->SelectEntry( sEntry ); + m_xVisitedLB->set_active_text(sEntry); sEntry = pINetFormat->GetINetFormat(); if (sEntry.isEmpty()) @@ -229,29 +215,29 @@ void SwCharURLPage::Reset(const SfxItemSet* rSet) OSL_ENSURE( false, "<SwCharURLPage::Reset(..)> - missing unvisited character format at hyperlink attribute" ); SwStyleNameMapper::FillUIName(RES_POOLCHR_INET_NORMAL, sEntry); } - m_pNotVisitedLB->SelectEntry(sEntry); + m_xNotVisitedLB->set_active_text(sEntry); - m_pTargetFrameLB->SetText(pINetFormat->GetTargetFrame()); - m_pVisitedLB-> SaveValue(); - m_pNotVisitedLB->SaveValue(); - m_pTargetFrameLB-> SaveValue(); + m_xTargetFrameLB->set_entry_text(pINetFormat->GetTargetFrame()); + m_xVisitedLB->save_value(); + m_xNotVisitedLB->save_value(); + m_xTargetFrameLB->save_value(); pINetItem = new SvxMacroItem(FN_INET_FIELD_MACRO); if( pINetFormat->GetMacroTable() ) - pINetItem->SetMacroTable( *pINetFormat->GetMacroTable() ); + pINetItem->SetMacroTable(*pINetFormat->GetMacroTable()); } - if(SfxItemState::SET == rSet->GetItemState(FN_PARAM_SELECTION, false, &pItem)) + if (SfxItemState::SET == rSet->GetItemState(FN_PARAM_SELECTION, false, &pItem)) { - m_pTextED->SetText(static_cast<const SfxStringItem*>(pItem)->GetValue()); - m_pTextFT->Enable( false ); - m_pTextED->Enable( false ); + m_xTextED->set_text(static_cast<const SfxStringItem*>(pItem)->GetValue()); + m_xTextFT->set_sensitive(false); + m_xTextED->set_sensitive(false); } } bool SwCharURLPage::FillItemSet(SfxItemSet* rSet) { - OUString sURL = m_pURLED->GetText(); - if(!sURL.isEmpty()) + OUString sURL = m_xURLED->get_text(); + if (!sURL.isEmpty()) { sURL = URIHelper::SmartRel2Abs(INetURLObject(), sURL, Link<OUString *, bool>(), false ); // #i100683# file URLs should be normalized in the UI @@ -259,62 +245,61 @@ bool SwCharURLPage::FillItemSet(SfxItemSet* rSet) sURL = URIHelper::simpleNormalizedMakeRelative(OUString(), sURL); } - SwFormatINetFormat aINetFormat(sURL, m_pTargetFrameLB->GetText()); - aINetFormat.SetName(m_pNameED->GetText()); - bool bURLModified = m_pURLED->IsValueChangedFromSaved(); - bool bNameModified = m_pNameED->IsModified(); - bool bTargetModified = m_pTargetFrameLB->IsValueChangedFromSaved(); + SwFormatINetFormat aINetFormat(sURL, m_xTargetFrameLB->get_active_text()); + aINetFormat.SetName(m_xNameED->get_text()); + bool bURLModified = m_xURLED->get_value_changed_from_saved(); + bool bNameModified = m_xNameED->get_value_changed_from_saved(); + bool bTargetModified = m_xTargetFrameLB->get_value_changed_from_saved(); bModified = bURLModified || bNameModified || bTargetModified; // set valid settings first - OUString sEntry = m_pVisitedLB->GetSelectedEntry(); + OUString sEntry = m_xVisitedLB->get_active_text(); sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sEntry, SwGetPoolIdFromName::ChrFmt); aINetFormat.SetVisitedFormatAndId( sEntry, nId ); - sEntry = m_pNotVisitedLB->GetSelectedEntry(); + sEntry = m_xNotVisitedLB->get_active_text(); nId = SwStyleNameMapper::GetPoolIdFromUIName( sEntry, SwGetPoolIdFromName::ChrFmt); aINetFormat.SetINetFormatAndId( sEntry, nId ); - if( pINetItem && !pINetItem->GetMacroTable().empty() ) - aINetFormat.SetMacroTable( &pINetItem->GetMacroTable() ); + if (pINetItem && !pINetItem->GetMacroTable().empty()) + aINetFormat.SetMacroTable(&pINetItem->GetMacroTable()); - if(m_pVisitedLB->IsValueChangedFromSaved()) + if (m_xVisitedLB->get_value_changed_from_saved()) bModified = true; - if(m_pNotVisitedLB->IsValueChangedFromSaved()) + if (m_xNotVisitedLB->get_value_changed_from_saved()) bModified = true; - if(m_pTextED->IsModified()) + if (bNameModified) { bModified = true; - rSet->Put(SfxStringItem(FN_PARAM_SELECTION, m_pTextED->GetText())); + rSet->Put(SfxStringItem(FN_PARAM_SELECTION, m_xTextED->get_text())); } if(bModified) rSet->Put(aINetFormat); return bModified; } -VclPtr<SfxTabPage> SwCharURLPage::Create( TabPageParent pParent, - const SfxItemSet* rAttrSet ) +VclPtr<SfxTabPage> SwCharURLPage::Create(TabPageParent pParent, const SfxItemSet* rAttrSet) { - return VclPtr<SwCharURLPage>::Create( pParent.pParent, *rAttrSet ); + return VclPtr<SwCharURLPage>::Create(pParent, *rAttrSet); } -IMPL_LINK_NOARG(SwCharURLPage, InsertFileHdl, Button*, void) +IMPL_LINK_NOARG(SwCharURLPage, InsertFileHdl, weld::Button&, void) { FileDialogHelper aDlgHelper(TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, GetFrameWeld()); if( aDlgHelper.Execute() == ERRCODE_NONE ) { - Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker(); - m_pURLED->SetText(xFP->getSelectedFiles().getConstArray()[0]); + Reference<XFilePicker3> xFP = aDlgHelper.GetFilePicker(); + m_xURLED->set_text(xFP->getSelectedFiles().getConstArray()[0]); } } -IMPL_LINK_NOARG(SwCharURLPage, EventHdl, Button*, void) +IMPL_LINK_NOARG(SwCharURLPage, EventHdl, weld::Button&, void) { - bModified |= SwMacroAssignDlg::INetFormatDlg( this, - ::GetActiveView()->GetWrtShell(), pINetItem ); + bModified |= SwMacroAssignDlg::INetFormatDlg(this, + ::GetActiveView()->GetWrtShell(), pINetItem); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/chrdlg.hxx b/sw/source/uibase/inc/chrdlg.hxx index 15e86bc789a1..10d00c645105 100644 --- a/sw/source/uibase/inc/chrdlg.hxx +++ b/sw/source/uibase/inc/chrdlg.hxx @@ -55,32 +55,30 @@ public: class SwCharURLPage : public SfxTabPage { - VclPtr<Edit> m_pURLED; - VclPtr<FixedText> m_pTextFT; - VclPtr<Edit> m_pTextED; - VclPtr<Edit> m_pNameED; - VclPtr<ComboBox> m_pTargetFrameLB; - VclPtr<PushButton> m_pURLPB; - VclPtr<PushButton> m_pEventPB; - VclPtr<ListBox> m_pVisitedLB; - VclPtr<ListBox> m_pNotVisitedLB; - - VclPtr<VclContainer> m_pCharStyleContainer; - SvxMacroItem* pINetItem; bool bModified; - DECL_LINK(InsertFileHdl, Button*, void); - DECL_LINK(EventHdl, Button*, void); + std::unique_ptr<weld::Entry> m_xURLED; + std::unique_ptr<weld::Label> m_xTextFT; + std::unique_ptr<weld::Entry> m_xTextED; + std::unique_ptr<weld::Entry> m_xNameED; + std::unique_ptr<weld::ComboBoxText> m_xTargetFrameLB; + std::unique_ptr<weld::Button> m_xURLPB; + std::unique_ptr<weld::Button> m_xEventPB; + std::unique_ptr<weld::ComboBoxText> m_xVisitedLB; + std::unique_ptr<weld::ComboBoxText> m_xNotVisitedLB; + std::unique_ptr<weld::Widget> m_xCharStyleContainer; + + DECL_LINK(InsertFileHdl, weld::Button&, void); + DECL_LINK(EventHdl, weld::Button&, void); public: - SwCharURLPage( vcl::Window* pParent, - const SfxItemSet& rSet ); + SwCharURLPage(TabPageParent pParent, const SfxItemSet& rSet); - virtual ~SwCharURLPage() override; - virtual void dispose() override; - static VclPtr<SfxTabPage> Create( TabPageParent pParent, - const SfxItemSet* rAttrSet); + virtual ~SwCharURLPage() override; + virtual void dispose() override; + static VclPtr<SfxTabPage> Create(TabPageParent pParent, + const SfxItemSet* rAttrSet); virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; diff --git a/sw/uiconfig/swriter/ui/charurlpage.ui b/sw/uiconfig/swriter/ui/charurlpage.ui index 39cfc547c1bc..9bf5cb3879bc 100644 --- a/sw/uiconfig/swriter/ui/charurlpage.ui +++ b/sw/uiconfig/swriter/ui/charurlpage.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="sw"> <requires lib="gtk+" version="3.18"/> <object class="GtkBox" id="CharURLPage"> @@ -31,10 +31,10 @@ <object class="GtkLabel" id="label36"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="charurlpage|label36">URL:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">urled</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -45,10 +45,10 @@ <object class="GtkLabel" id="label37"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="charurlpage|label37">Name:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">nameed</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -59,10 +59,10 @@ <object class="GtkLabel" id="textft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="charurlpage|textft">Text:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">texted</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -73,10 +73,10 @@ <object class="GtkLabel" id="label39"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="charurlpage|label39">Target frame:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">targetfrmlb</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -101,6 +101,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> + <property name="activates_default">True</property> <property name="width_chars">32</property> </object> <packing> @@ -112,6 +113,7 @@ <object class="GtkEntry" id="nameed"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="width_chars">32</property> </object> <packing> @@ -123,6 +125,7 @@ <object class="GtkEntry" id="texted"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="width_chars">32</property> </object> <packing> @@ -151,6 +154,7 @@ <child internal-child="entry"> <object class="GtkEntry" id="comboboxtext-entry"> <property name="can_focus">False</property> + <property name="activates_default">True</property> </object> </child> </object> @@ -217,10 +221,10 @@ <object class="GtkLabel" id="label34"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="charurlpage|label34">Visited links:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">visitedlb</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -231,10 +235,10 @@ <object class="GtkLabel" id="label10"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="charurlpage|label10">Unvisited links:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">unvisitedlb</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -242,7 +246,7 @@ </packing> </child> <child> - <object class="GtkComboBox" id="visitedlb"> + <object class="GtkComboBoxText" id="visitedlb"> <property name="visible">True</property> <property name="can_focus">False</property> </object> @@ -252,7 +256,7 @@ </packing> </child> <child> - <object class="GtkComboBox" id="unvisitedlb"> + <object class="GtkComboBoxText" id="unvisitedlb"> <property name="visible">True</property> <property name="can_focus">False</property> </object> |