From 765d91d84a423bdeab71c36117df764014683ba6 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 15 Jun 2018 11:27:51 +0100 Subject: weld SwCharURLPage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5263147c2dd15e6cab5b405d1680c2a3778137a6 Reviewed-on: https://gerrit.libreoffice.org/55861 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sw/source/ui/chrdlg/chardlg.cxx | 145 +++++++++++++++------------------- sw/source/uibase/inc/chrdlg.hxx | 38 +++++---- sw/uiconfig/swriter/ui/charurlpage.ui | 22 +++--- 3 files changed, 96 insertions(+), 109 deletions(-) (limited to 'sw') 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(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(RES_POOLCHR_INET_VISIT))); - m_pVisitedLB->SaveValue(); - m_pNotVisitedLB->SelectEntryPos(m_pNotVisitedLB->GetEntryPos(reinterpret_cast(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 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( 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, " - 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, " - 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(pItem)->GetValue()); - m_pTextFT->Enable( false ); - m_pTextED->Enable( false ); + m_xTextED->set_text(static_cast(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(), 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 SwCharURLPage::Create( TabPageParent pParent, - const SfxItemSet* rAttrSet ) +VclPtr SwCharURLPage::Create(TabPageParent pParent, const SfxItemSet* rAttrSet) { - return VclPtr::Create( pParent.pParent, *rAttrSet ); + return VclPtr::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 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 m_pURLED; - VclPtr m_pTextFT; - VclPtr m_pTextED; - VclPtr m_pNameED; - VclPtr m_pTargetFrameLB; - VclPtr m_pURLPB; - VclPtr m_pEventPB; - VclPtr m_pVisitedLB; - VclPtr m_pNotVisitedLB; - - VclPtr m_pCharStyleContainer; - SvxMacroItem* pINetItem; bool bModified; - DECL_LINK(InsertFileHdl, Button*, void); - DECL_LINK(EventHdl, Button*, void); + std::unique_ptr m_xURLED; + std::unique_ptr m_xTextFT; + std::unique_ptr m_xTextED; + std::unique_ptr m_xNameED; + std::unique_ptr m_xTargetFrameLB; + std::unique_ptr m_xURLPB; + std::unique_ptr m_xEventPB; + std::unique_ptr m_xVisitedLB; + std::unique_ptr m_xNotVisitedLB; + std::unique_ptr 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 Create( TabPageParent pParent, - const SfxItemSet* rAttrSet); + virtual ~SwCharURLPage() override; + virtual void dispose() override; + static VclPtr 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 @@ - + @@ -31,10 +31,10 @@ True False - 1 URL: True urled + 1 0 @@ -45,10 +45,10 @@ True False - 1 Name: True nameed + 1 0 @@ -59,10 +59,10 @@ True False - 1 Text: True texted + 1 0 @@ -73,10 +73,10 @@ True False - 1 Target frame: True targetfrmlb + 1 0 @@ -101,6 +101,7 @@ True True True + True 32 @@ -112,6 +113,7 @@ True True + True 32 @@ -123,6 +125,7 @@ True True + True 32 @@ -151,6 +154,7 @@ False + True @@ -217,10 +221,10 @@ True False - 1 Visited links: True visitedlb + 1 0 @@ -231,10 +235,10 @@ True False - 1 Unvisited links: True unvisitedlb + 1 0 @@ -242,7 +246,7 @@ - + True False @@ -252,7 +256,7 @@ - + True False -- cgit