diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-09-25 11:51:18 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-09-26 13:20:30 +0200 |
commit | 5c485d1e9a14696922e0a4bbdecef8e8e8b6c6c0 (patch) | |
tree | 2db26d4ecd5b71d367ef17c92244b0a5f5a6b149 | |
parent | e412401edcf0a979f9f19c051990c0fb08987048 (diff) |
weld SwAutoMarkDlg_Impl
Change-Id: I64fc2b503f76b61ea8c2f26c8170c72611935131
Reviewed-on: https://gerrit.libreoffice.org/79533
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | solenv/sanitizers/ui/modules/swriter.suppr | 10 | ||||
-rw-r--r-- | sw/inc/strings.hrc | 10 | ||||
-rw-r--r-- | sw/source/ui/index/cnttab.cxx | 114 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/createautomarkdialog.ui | 126 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 1 |
5 files changed, 69 insertions, 192 deletions
diff --git a/solenv/sanitizers/ui/modules/swriter.suppr b/solenv/sanitizers/ui/modules/swriter.suppr index 369da76a8c4a..8fd62f49ff80 100644 --- a/solenv/sanitizers/ui/modules/swriter.suppr +++ b/solenv/sanitizers/ui/modules/swriter.suppr @@ -29,15 +29,6 @@ sw/uiconfig/swriter/ui/conditionpage.ui://GtkComboBoxText[@id='filter'] no-label sw/uiconfig/swriter/ui/converttexttable.ui://GtkLabel[@id='label4'] orphan-label sw/uiconfig/swriter/ui/createaddresslist.ui://GtkEntry[@id='SETNO-nospin'] no-labelled-by sw/uiconfig/swriter/ui/createaddresslist.ui://GtkSpinButton[@id='SETNO'] no-labelled-by -sw/uiconfig/swriter/ui/createautomarkdialog.ui://GtkLabel[@id='searchterm'] orphan-label -sw/uiconfig/swriter/ui/createautomarkdialog.ui://GtkLabel[@id='alternative'] orphan-label -sw/uiconfig/swriter/ui/createautomarkdialog.ui://GtkLabel[@id='key1'] orphan-label -sw/uiconfig/swriter/ui/createautomarkdialog.ui://GtkLabel[@id='key2'] orphan-label -sw/uiconfig/swriter/ui/createautomarkdialog.ui://GtkLabel[@id='comment'] orphan-label -sw/uiconfig/swriter/ui/createautomarkdialog.ui://GtkLabel[@id='casesensitive'] orphan-label -sw/uiconfig/swriter/ui/createautomarkdialog.ui://GtkLabel[@id='wordonly'] orphan-label -sw/uiconfig/swriter/ui/createautomarkdialog.ui://GtkLabel[@id='yes'] orphan-label -sw/uiconfig/swriter/ui/createautomarkdialog.ui://GtkLabel[@id='no'] orphan-label sw/uiconfig/swriter/ui/customizeaddrlistdialog.ui://GtkButton[@id='down'] button-no-label sw/uiconfig/swriter/ui/customizeaddrlistdialog.ui://GtkButton[@id='up'] button-no-label sw/uiconfig/swriter/ui/editsectiondialog.ui://GtkEntry[@id='curname'] no-labelled-by @@ -252,7 +243,6 @@ sw/uiconfig/swriter/ui/tocstylespage.ui://GtkButton[@id='assign'] button-no-labe sw/uiconfig/swriter/ui/tablecolumnpage.ui://GtkButton[@id='back'] button-no-label sw/uiconfig/swriter/ui/tablecolumnpage.ui://GtkButton[@id='next'] button-no-label sw/uiconfig/swriter/ui/tablepreviewdialog.ui://GtkLabel[@id='description'] orphan-label -sw/uiconfig/swriter/ui/tablepreviewdialog.ui://GtkDrawingArea[@id='beamer'] no-labelled-by sw/uiconfig/swriter/ui/tabletextflowpage.ui://GtkSpinButton[@id='pagenonf'] missing-label-for sw/uiconfig/swriter/ui/tabletextflowpage.ui://GtkLabel[@id='label39'] orphan-label sw/uiconfig/swriter/ui/textgridpage.ui://GtkLabel[@id='labelFT_CHARRANGE'] orphan-label diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index 010d7e662724..6cb4b8256fab 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -1365,6 +1365,16 @@ #define STR_OPT_PREVIEW_DELETED NC_("optredlinepage|deletedpreview", "Delete") #define STR_OPT_PREVIEW_CHANGED NC_("optredlinepage|changedpreview", "Attributes") +#define STR_AUTOMARK_SEARCHTERM NC_("createautomarkdialog|searchterm", "Search term") +#define STR_AUTOMARK_ALTERNATIVE NC_("createautomarkdialog|alternative", "Alternative entry") +#define STR_AUTOMARK_KEY1 NC_("createautomarkdialog|key1", "1st key") +#define STR_AUTOMARK_KEY2 NC_("createautomarkdialog|key2", "2nd key") +#define STR_AUTOMARK_COMMENT NC_("createautomarkdialog|comment", "Comment") +#define STR_AUTOMARK_CASESENSITIVE NC_("createautomarkdialog|casesensitive", "Match case") +#define STR_AUTOMARK_WORDONLY NC_("createautomarkdialog|wordonly", "Word only") +#define STR_AUTOMARK_YES NC_("createautomarkdialog|yes", "Yes") +#define STR_AUTOMARK_NO NC_("createautomarkdialog|no", "No") + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index d0b8a25c2d62..e402eccf0513 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -41,6 +41,7 @@ #include <com/sun/star/ui/dialogs/XFilePicker3.hpp> #include <com/sun/star/ui/dialogs/XFilterManager.hpp> #include <svtools/indexentryres.hxx> +#include <toolkit/helper/vclunohelper.hxx> #include <editeng/unolingu.hxx> #include <column.hxx> #include <fmtfsize.hxx> @@ -172,7 +173,7 @@ protected: std::vector<long> GetOptimalColWidths() const; public: - SwEntryBrowseBox(vcl::Window* pParent, VclBuilderContainer* pBuilder); + SwEntryBrowseBox(const css::uno::Reference<css::awt::XWindow> &rParent); virtual ~SwEntryBrowseBox() override; virtual void dispose() override; void ReadEntries(SvStream& rInStr); @@ -185,23 +186,21 @@ public: virtual Size GetOptimalSize() const override; }; -class SwAutoMarkDlg_Impl : public ModalDialog +class SwAutoMarkDlg_Impl : public weld::GenericDialogController { - VclPtr<OKButton> m_pOKPB; - - VclPtr<SwEntryBrowseBox> m_pEntriesBB; - OUString sAutoMarkURL; - bool bCreateMode; - DECL_LINK(OkHdl, Button*, void); + std::unique_ptr<weld::Button> m_xOKPB; + std::unique_ptr<weld::Container> m_xTable; + css::uno::Reference<css::awt::XWindow> m_xTableCtrlParent; + VclPtr<SwEntryBrowseBox> m_xEntriesBB; + + DECL_LINK(OkHdl, weld::Button&, void); public: - SwAutoMarkDlg_Impl(vcl::Window* pParent, const OUString& rAutoMarkURL, + SwAutoMarkDlg_Impl(weld::Window* pParent, const OUString& rAutoMarkURL, bool bCreate); virtual ~SwAutoMarkDlg_Impl() override; - virtual void dispose() override; - }; sal_uInt16 CurTOXType::GetFlatIndex() const @@ -1373,9 +1372,8 @@ IMPL_LINK(SwTOXSelectTabPage, MenuExecuteHdl, const OString&, rIdent, void) return; } - VclPtrInstance<SwAutoMarkDlg_Impl> pAutoMarkDlg(nullptr, sAutoMarkURL, bNew); - - if( RET_OK != pAutoMarkDlg->Execute() && bNew ) + SwAutoMarkDlg_Impl aAutoMarkDlg(GetDialogFrameWeld(), sAutoMarkURL, bNew); + if (RET_OK != aAutoMarkDlg.run() && bNew) sAutoMarkURL = sSaveAutoMarkURL; } } @@ -3555,8 +3553,8 @@ void SwTOXStylesTabPage::Modify() #define ITEM_CASE 6 #define ITEM_WORDONLY 7 -SwEntryBrowseBox::SwEntryBrowseBox(vcl::Window* pParent, VclBuilderContainer* pBuilder) - : SwEntryBrowseBox_Base( pParent, EditBrowseBoxFlags::NONE, WB_TABSTOP | WB_BORDER, +SwEntryBrowseBox::SwEntryBrowseBox(const css::uno::Reference<css::awt::XWindow> &rParent) + : SwEntryBrowseBox_Base(VCLUnoHelper::GetWindow(rParent), EditBrowseBoxFlags::NONE, WB_TABSTOP | WB_BORDER, BrowserMode::KEEPHIGHLIGHT | BrowserMode::COLUMNSELECTION | BrowserMode::MULTISELECTION | @@ -3570,15 +3568,15 @@ SwEntryBrowseBox::SwEntryBrowseBox(vcl::Window* pParent, VclBuilderContainer* pB , m_nCurrentRow(0) , m_bModified(false) { - m_sSearch = pBuilder->get<vcl::Window>("searchterm")->GetText(); - m_sAlternative = pBuilder->get<vcl::Window>("alternative")->GetText(); - m_sPrimKey = pBuilder->get<vcl::Window>("key1")->GetText(); - m_sSecKey = pBuilder->get<vcl::Window>("key2")->GetText(); - m_sComment = pBuilder->get<vcl::Window>("comment")->GetText(); - m_sCaseSensitive = pBuilder->get<vcl::Window>("casesensitive")->GetText(); - m_sWordOnly = pBuilder->get<vcl::Window>("wordonly")->GetText(); - m_sYes = pBuilder->get<vcl::Window>("yes")->GetText(); - m_sNo = pBuilder->get<vcl::Window>("no")->GetText(); + m_sSearch = SwResId(STR_AUTOMARK_SEARCHTERM); + m_sAlternative = SwResId(STR_AUTOMARK_ALTERNATIVE); + m_sPrimKey = SwResId(STR_AUTOMARK_KEY1); + m_sSecKey = SwResId(STR_AUTOMARK_KEY2); + m_sComment = SwResId(STR_AUTOMARK_COMMENT); + m_sCaseSensitive = SwResId(STR_AUTOMARK_CASESENSITIVE); + m_sWordOnly = SwResId(STR_AUTOMARK_WORDONLY); + m_sYes = SwResId(STR_AUTOMARK_YES); + m_sNo = SwResId(STR_AUTOMARK_NO); m_aCellCheckBox->GetBox().EnableTriState(false); m_xController = new ::svt::EditCellController(m_aCellEdit.get()); @@ -3628,17 +3626,13 @@ void SwEntryBrowseBox::Resize() { SwEntryBrowseBox_Base::Resize(); - Dialog *pDlg = GetParentDialog(); - if (pDlg && pDlg->isCalculatingInitialLayoutSize()) - { - long nWidth = GetSizePixel().Width(); - std::vector<long> aWidths = GetOptimalColWidths(); - long nNaturalWidth(std::accumulate(aWidths.begin(), aWidths.end(), 0)); - long nExcess = ((nWidth - nNaturalWidth) / aWidths.size()) - 1; + long nWidth = GetSizePixel().Width(); + std::vector<long> aWidths = GetOptimalColWidths(); + long nNaturalWidth(std::accumulate(aWidths.begin(), aWidths.end(), 0)); + long nExcess = ((nWidth - nNaturalWidth) / aWidths.size()) - 1; - for (size_t i = 0; i < aWidths.size(); ++i) - SetColumnWidth(i+1, aWidths[i] + nExcess); - } + for (size_t i = 0; i < aWidths.size(); ++i) + SetColumnWidth(i+1, aWidths[i] + nExcess); } std::vector<long> SwEntryBrowseBox::GetOptimalColWidths() const @@ -3882,52 +3876,50 @@ bool SwEntryBrowseBox::IsModified()const return pController->IsModified(); } -SwAutoMarkDlg_Impl::SwAutoMarkDlg_Impl(vcl::Window* pParent, const OUString& rAutoMarkURL, +SwAutoMarkDlg_Impl::SwAutoMarkDlg_Impl(weld::Window* pParent, const OUString& rAutoMarkURL, bool bCreate) - : ModalDialog(pParent, "CreateAutomarkDialog", - "modules/swriter/ui/createautomarkdialog.ui") + : GenericDialogController(pParent, "modules/swriter/ui/createautomarkdialog.ui", "CreateAutomarkDialog") , sAutoMarkURL(rAutoMarkURL) , bCreateMode(bCreate) + , m_xOKPB(m_xBuilder->weld_button("ok")) + , m_xTable(m_xBuilder->weld_container("area")) + , m_xTableCtrlParent(m_xTable->CreateChildFrame()) + , m_xEntriesBB(VclPtr<SwEntryBrowseBox>::Create(m_xTableCtrlParent)) { - get(m_pOKPB, "ok"); - m_pEntriesBB = VclPtr<SwEntryBrowseBox>::Create(get<VclContainer>("area"), this); - m_pEntriesBB->set_expand(true); - m_pEntriesBB->Show(); - m_pOKPB->SetClickHdl(LINK(this, SwAutoMarkDlg_Impl, OkHdl)); + m_xEntriesBB->Show(); + m_xOKPB->connect_clicked(LINK(this, SwAutoMarkDlg_Impl, OkHdl)); - SetText(GetText() + ": " + sAutoMarkURL); + m_xDialog->set_title(m_xDialog->get_title() + ": " + sAutoMarkURL); bool bError = false; if( bCreateMode ) - m_pEntriesBB->RowInserted(0); + m_xEntriesBB->RowInserted(0); else { SfxMedium aMed( sAutoMarkURL, StreamMode::STD_READ ); if( aMed.GetInStream() && !aMed.GetInStream()->GetError() ) - m_pEntriesBB->ReadEntries( *aMed.GetInStream() ); + m_xEntriesBB->ReadEntries( *aMed.GetInStream() ); else bError = true; } - if(bError) - EndDialog(); -} + Size aPrefSize = m_xEntriesBB->GetOptimalSize(); + m_xTable->set_size_request(aPrefSize.Width(), aPrefSize.Height()); -SwAutoMarkDlg_Impl::~SwAutoMarkDlg_Impl() -{ - disposeOnce(); + if (bError) + m_xDialog->response(RET_CANCEL); } -void SwAutoMarkDlg_Impl::dispose() +SwAutoMarkDlg_Impl::~SwAutoMarkDlg_Impl() { - m_pEntriesBB.disposeAndClear(); - m_pOKPB.clear(); - ModalDialog::dispose(); + m_xEntriesBB.disposeAndClear(); + m_xTableCtrlParent->dispose(); + m_xTableCtrlParent.clear(); } -IMPL_LINK_NOARG(SwAutoMarkDlg_Impl, OkHdl, Button*, void) +IMPL_LINK_NOARG(SwAutoMarkDlg_Impl, OkHdl, weld::Button&, void) { bool bError = false; - if(m_pEntriesBB->IsModified() || bCreateMode) + if (m_xEntriesBB->IsModified() || bCreateMode) { SfxMedium aMed( sAutoMarkURL, bCreateMode ? StreamMode::WRITE @@ -3936,14 +3928,14 @@ IMPL_LINK_NOARG(SwAutoMarkDlg_Impl, OkHdl, Button*, void) pStrm->SetStreamCharSet( RTL_TEXTENCODING_MS_1253 ); if( !pStrm->GetError() ) { - m_pEntriesBB->WriteEntries( *pStrm ); + m_xEntriesBB->WriteEntries( *pStrm ); aMed.Commit(); } else bError = true; } - if( !bError ) - EndDialog(RET_OK); + if (!bError) + m_xDialog->response(RET_OK); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/uiconfig/swriter/ui/createautomarkdialog.ui b/sw/uiconfig/swriter/ui/createautomarkdialog.ui index 811feddb960c..991901b7b9b5 100644 --- a/sw/uiconfig/swriter/ui/createautomarkdialog.ui +++ b/sw/uiconfig/swriter/ui/createautomarkdialog.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="GtkDialog" id="CreateAutomarkDialog"> @@ -7,7 +7,11 @@ <property name="border_width">6</property> <property name="title" translatable="yes" context="createautomarkdialog|CreateAutomarkDialog">Edit Concordance File</property> <property name="resizable">False</property> + <property name="modal">True</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> @@ -90,126 +94,6 @@ <property name="can_focus">False</property> <property name="orientation">vertical</property> <child> - <object class="GtkBox" id="box3"> - <property name="can_focus">False</property> - <property name="no_show_all">True</property> - <property name="spacing">6</property> - <child> - <object class="GtkLabel" id="searchterm"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="createautomarkdialog|searchterm">Search term</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="alternative"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="createautomarkdialog|alternative">Alternative entry</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="key1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="createautomarkdialog|key1">1st key</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="key2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="createautomarkdialog|key2">2nd key</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">3</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="comment"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="createautomarkdialog|comment">Comment</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">4</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="casesensitive"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="createautomarkdialog|casesensitive">Match case</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">5</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="wordonly"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="createautomarkdialog|wordonly">Word only</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">6</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="yes"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="createautomarkdialog|yes">Yes</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">7</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="no"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="createautomarkdialog|no">No</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">8</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> <placeholder/> </child> </object> diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 49e856a9c111..27620413ed5a 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -2734,6 +2734,7 @@ public: gtk_widget_set_hexpand(pWindow, true); gtk_widget_set_vexpand(pWindow, true); gtk_widget_realize(pWindow); + gtk_widget_set_can_focus(pWindow, true); g_object_unref(pWindow); xEmbedWindow->Show(); |