include/sfx2/dinfdlg.hxx | 19 +++++ sfx2/source/dialog/dinfdlg.cxx | 115 ++++++++++++++++++++--------------- sw/source/ui/frmdlg/cption.cxx | 7 ++ sw/source/uibase/inc/cption.hxx | 1 sw/source/uibase/uiview/viewdlg2.cxx | 11 ++- vcl/jsdialog/enabled.cxx | 7 +- 6 files changed, 106 insertions(+), 54 deletions(-)
New commits: commit 9a0a7ae8f62cc8233b71057caa6bc88c69ee94a1 Author: Skyler Grey <skyler.g...@collabora.com> AuthorDate: Fri Aug 19 12:23:20 2022 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Sun Nov 20 15:34:05 2022 +0100 Make the insert caption dialog an async jsdialog - Using StartExecuteAsync instead of Execute to execute the dialog makes it run asyncly - We need to add a handler for the OK button, otherwise the event won't be fired when it's clicked. There seem to be varying names for this throughout the codebase, I've chosen OKHdl as it's short, appears to be relatively common and fits well with the existing OptionHdl and CaptionHdl that the other buttons on the dialog use - Lastly, we need to enable the JSDialog builder in vcl/jsdialog/enabled.cxx so that the dialog becomes a JSDialog Still TODO: - Convert the dialogs that open when you press "auto" or "options" buttons (will be in a followup review) Change-Id: Ieabbc4e69c4aa065506f7dc6c823d83e4d784c2f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138313 Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142988 Tested-by: Jenkins diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx index 01ebc9d685c4..8b3c14afe0a6 100644 --- a/sw/source/ui/frmdlg/cption.cxx +++ b/sw/source/ui/frmdlg/cption.cxx @@ -138,6 +138,7 @@ SwCaptionDialog::SwCaptionDialog(weld::Window *pParent, SwView &rV) m_xSepEdit->connect_changed(aLk); m_xFormatBox->connect_changed(LINK(this, SwCaptionDialog, SelectListBoxHdl)); + m_xOKButton->connect_clicked(LINK(this, SwCaptionDialog, OKHdl)); m_xOptionButton->connect_clicked(LINK(this, SwCaptionDialog, OptionHdl)); m_xAutoCaptionButton->connect_clicked(LINK(this, SwCaptionDialog, CaptionHdl)); m_xAutoCaptionButton->set_accessible_description(SwResId(STR_A11Y_DESC_AUTO)); @@ -267,6 +268,12 @@ SwCaptionDialog::SwCaptionDialog(weld::Window *pParent, SwView &rV) DrawSample(); } +IMPL_LINK_NOARG(SwCaptionDialog, OKHdl, weld::Button&, void) +{ + Apply(); + m_xDialog->response(RET_OK); +} + void SwCaptionDialog::Apply() { InsCaptionOpt aOpt; diff --git a/sw/source/uibase/inc/cption.hxx b/sw/source/uibase/inc/cption.hxx index 0a7bc9ef64c7..5ff685a8cedf 100644 --- a/sw/source/uibase/inc/cption.hxx +++ b/sw/source/uibase/inc/cption.hxx @@ -64,6 +64,7 @@ class SwCaptionDialog final : public SfxDialogController DECL_LINK(ModifyComboHdl, weld::ComboBox&, void); DECL_LINK(OptionHdl, weld::Button&, void); DECL_LINK(CaptionHdl, weld::Button&, void); + DECL_LINK(OKHdl, weld::Button&, void); void Apply(); diff --git a/sw/source/uibase/uiview/viewdlg2.cxx b/sw/source/uibase/uiview/viewdlg2.cxx index eed4eddcc064..19678d38fdcb 100644 --- a/sw/source/uibase/uiview/viewdlg2.cxx +++ b/sw/source/uibase/uiview/viewdlg2.cxx @@ -46,15 +46,18 @@ using namespace css; -void SwView::ExecDlgExt(SfxRequest const &rReq) +void SwView::ExecDlgExt(SfxRequest const& rReq) { - switch ( rReq.GetSlot() ) + switch (rReq.GetSlot()) { case FN_INSERT_CAPTION: { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - ScopedVclPtr<VclAbstractDialog> pDialog(pFact->CreateSwCaptionDialog(GetFrameWeld(), *this )); - pDialog->Execute(); + VclPtr<VclAbstractDialog> pDialog( + pFact->CreateSwCaptionDialog(GetFrameWeld(), *this)); + pDialog->StartExecuteAsync([pDialog](sal_Int32) { + pDialog->disposeOnce(); + }); break; } case SID_INSERT_SIGNATURELINE: diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index 6923056183af..89b50c96fab1 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -69,7 +69,8 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool bMobile) || rUIFile == u"sfx/ui/documentpropertiesdialog.ui" || rUIFile == u"sfx/ui/custominfopage.ui" || rUIFile == u"sfx/ui/cmisinfopage.ui" || rUIFile == u"sfx/ui/descriptioninfopage.ui" || rUIFile == u"sfx/ui/documentinfopage.ui" - || rUIFile == u"sfx/ui/linefragment.ui" || rUIFile == u"sfx/ui/editdurationdialog.ui") + || rUIFile == u"sfx/ui/linefragment.ui" || rUIFile == u"sfx/ui/editdurationdialog.ui" + || rUIFile == u"modules/swriter/ui/insertcaption.ui") { return true; } commit 930b96dee6250eb8d51f25e2e1020bd1e028db03 Author: NickWingate <nick.wing...@collabora.com> AuthorDate: Tue Aug 9 10:54:40 2022 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Sun Nov 20 15:33:51 2022 +0100 Enable File Properties for JSDialogs - Disable security tab as protect/password subdialog not fully async-ed - Disable custom property tab as still unstable - Hide Digital signatures button - Make duration dialog async - Set location as file name Signed-off-by: NickWingate <nick.wing...@collabora.com> Change-Id: I5843bb7737af8dd6b7d3af273ddd8997f2e35e10 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138010 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142987 Tested-by: Jenkins diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx index fc7ebbfd4f2d..7cbf5433eaa7 100644 --- a/include/sfx2/dinfdlg.hxx +++ b/include/sfx2/dinfdlg.hxx @@ -274,11 +274,28 @@ public: ~CustomPropertiesTimeField(); }; +class DurationDialog_Impl : public weld::GenericDialogController +{ + std::unique_ptr<weld::CheckButton> m_xNegativeCB; + std::unique_ptr<weld::SpinButton> m_xYearNF; + std::unique_ptr<weld::SpinButton> m_xMonthNF; + std::unique_ptr<weld::SpinButton> m_xDayNF; + std::unique_ptr<weld::SpinButton> m_xHourNF; + std::unique_ptr<weld::SpinButton> m_xMinuteNF; + std::unique_ptr<weld::SpinButton> m_xSecondNF; + std::unique_ptr<weld::SpinButton> m_xMSecondNF; + +public: + DurationDialog_Impl(weld::Widget* pParent, const css::util::Duration& rDuration); + css::util::Duration GetDuration() const; +}; + class CustomPropertiesDurationField { css::util::Duration m_aDuration; std::unique_ptr<weld::Entry> m_xEntry; std::unique_ptr<weld::Button> m_xEditButton; + std::shared_ptr<DurationDialog_Impl> m_xDurationDialog; DECL_LINK(ClickHdl, weld::Button&, void); public: @@ -289,6 +306,8 @@ public: const css::util::Duration& GetDuration() const { return m_aDuration; } void set_visible(bool bVisible); + + ~CustomPropertiesDurationField(); }; class CustomPropertiesYesNoButton diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index eec2e4ca980d..3dd14c423af7 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -38,6 +38,7 @@ #include <sal/log.hxx> #include <osl/diagnose.h> #include <osl/file.hxx> +#include <comphelper/lok.hxx> #include <memory> @@ -708,6 +709,8 @@ SfxDocumentPage::SfxDocumentPage(weld::Container* pPage, weld::DialogController* ImplCheckPasswordState(); m_xChangePassBtn->connect_clicked( LINK( this, SfxDocumentPage, ChangePassHdl ) ); m_xSignatureBtn->connect_clicked( LINK( this, SfxDocumentPage, SignatureHdl ) ); + if (comphelper::LibreOfficeKit::isActive()) + m_xSignatureBtn->hide(); m_xDeleteBtn->connect_clicked( LINK( this, SfxDocumentPage, DeleteHdl ) ); m_xImagePreferredDpiCheckButton->connect_toggled(LINK(this, SfxDocumentPage, ImagePreferredDPICheckBoxClicked)); @@ -983,26 +986,36 @@ void SfxDocumentPage::Reset( const SfxItemSet* rSet ) m_xShowTypeFT->set_label( aDescription ); // determine location - aURL.SetSmartURL( aFile); - if ( aURL.GetProtocol() == INetProtocol::File ) + // online we don't know file location so we just set it as the name + if (comphelper::LibreOfficeKit::isActive()) { - INetURLObject aPath( aURL ); - aPath.setFinalSlash(); - aPath.removeSegment(); - // we know it's a folder -> don't need the final slash, but it's better for WB_PATHELLIPSIS - aPath.removeFinalSlash(); - OUString aText( aPath.PathToFileName() ); //! (pb) MaxLen? - m_xFileValEd->set_label(aText); - OUString aURLStr; - osl::FileBase::getFileURLFromSystemPath(aText, aURLStr); - m_xFileValEd->set_uri(aURLStr); + m_xFileValEd->set_label(aName); + m_xFileValEd->set_uri(aName); } - else if (aURL.GetProtocol() != INetProtocol::PrivSoffice) + else { - m_xFileValEd->set_label(aURL.GetPartBeforeLastName()); - m_xFileValEd->set_uri(m_xFileValEd->get_label()); + aURL.SetSmartURL( aFile); + if ( aURL.GetProtocol() == INetProtocol::File ) + { + INetURLObject aPath( aURL ); + aPath.setFinalSlash(); + aPath.removeSegment(); + // we know it's a folder -> don't need the final slash, but it's better for WB_PATHELLIPSIS + aPath.removeFinalSlash(); + OUString aText( aPath.PathToFileName() ); //! (pb) MaxLen? + m_xFileValEd->set_label(aText); + OUString aURLStr; + osl::FileBase::getFileURLFromSystemPath(aText, aURLStr); + m_xFileValEd->set_uri(aURLStr); + } + else if (aURL.GetProtocol() != INetProtocol::PrivSoffice) + { + m_xFileValEd->set_label(aURL.GetPartBeforeLastName()); + m_xFileValEd->set_uri(m_xFileValEd->get_label()); + } } + // handle access data bool bUseUserData = rInfoItem.IsUseUserData(); const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() ); @@ -1156,12 +1169,21 @@ SfxDocumentInfoDialog::SfxDocumentInfoDialog(weld::Window* pParent, const SfxIte // Property Pages AddTabPage("general", SfxDocumentPage::Create, nullptr); AddTabPage("description", SfxDocumentDescPage::Create, nullptr); - AddTabPage("customprops", SfxCustomPropertiesPage::Create, nullptr); + + if (!comphelper::LibreOfficeKit::isActive()) + AddTabPage("customprops", SfxCustomPropertiesPage::Create, nullptr); + else + RemoveTabPage("customprops"); + if (rInfoItem.isCmisDocument()) AddTabPage("cmisprops", SfxCmisPropertiesPage::Create, nullptr); else RemoveTabPage("cmisprops"); - AddTabPage("security", SfxSecurityPage::Create, nullptr); + // Disable security page for online as not fully asynced yet + if (!comphelper::LibreOfficeKit::isActive()) + AddTabPage("security", SfxSecurityPage::Create, nullptr); + else + RemoveTabPage("security"); } void SfxDocumentInfoDialog::PageCreated(const OString& rId, SfxTabPage &rPage) @@ -1191,25 +1213,6 @@ CustomPropertiesYesNoButton::~CustomPropertiesYesNoButton() { } -namespace { - -class DurationDialog_Impl : public weld::GenericDialogController -{ - std::unique_ptr<weld::CheckButton> m_xNegativeCB; - std::unique_ptr<weld::SpinButton> m_xYearNF; - std::unique_ptr<weld::SpinButton> m_xMonthNF; - std::unique_ptr<weld::SpinButton> m_xDayNF; - std::unique_ptr<weld::SpinButton> m_xHourNF; - std::unique_ptr<weld::SpinButton> m_xMinuteNF; - std::unique_ptr<weld::SpinButton> m_xSecondNF; - std::unique_ptr<weld::SpinButton> m_xMSecondNF; - -public: - DurationDialog_Impl(weld::Widget* pParent, const util::Duration& rDuration); - util::Duration GetDuration() const; -}; - -} DurationDialog_Impl::DurationDialog_Impl(weld::Widget* pParent, const util::Duration& rDuration) : GenericDialogController(pParent, "sfx/ui/editdurationdialog.ui", "EditDurationDialog") @@ -1277,9 +1280,20 @@ void CustomPropertiesDurationField::SetDuration( const util::Duration& rDuration IMPL_LINK(CustomPropertiesDurationField, ClickHdl, weld::Button&, rButton, void) { - DurationDialog_Impl aDurationDlg(&rButton, GetDuration()); - if (aDurationDlg.run() == RET_OK) - SetDuration(aDurationDlg.GetDuration()); + m_xDurationDialog = std::make_shared<DurationDialog_Impl>(&rButton, GetDuration()); + weld::DialogController::runAsync(m_xDurationDialog, [&](sal_Int32 response) + { + if (response == RET_OK) + { + SetDuration(m_xDurationDialog->GetDuration()); + } + }); +} + +CustomPropertiesDurationField::~CustomPropertiesDurationField() +{ + if (m_xDurationDialog) + m_xDurationDialog->response(RET_CANCEL); } namespace @@ -1524,16 +1538,19 @@ void CustomPropertiesWindow::CreateNewLine() m_aCustomPropertiesLines.emplace_back( pNewLine ); - // for ui-testing. Distinguish the elements in the lines - sal_uInt16 nSize = m_aCustomPropertiesLines.size(); - pNewLine->m_xNameBox->set_buildable_name( - pNewLine->m_xNameBox->get_buildable_name() + OString::number(nSize)); - pNewLine->m_xTypeBox->set_buildable_name( - pNewLine->m_xTypeBox->get_buildable_name() + OString::number(nSize)); - pNewLine->m_xValueEdit->set_buildable_name( - pNewLine->m_xValueEdit->get_buildable_name() + OString::number(nSize)); - pNewLine->m_xRemoveButton->set_buildable_name( - pNewLine->m_xRemoveButton->get_buildable_name() + OString::number(nSize)); + // this breaks online's jsdialogbuilder + if (!comphelper::LibreOfficeKit::isActive()){ + // for ui-testing. Distinguish the elements in the lines + sal_uInt16 nSize = m_aCustomPropertiesLines.size(); + pNewLine->m_xNameBox->set_buildable_name( + pNewLine->m_xNameBox->get_buildable_name() + OString::number(nSize)); + pNewLine->m_xTypeBox->set_buildable_name( + pNewLine->m_xTypeBox->get_buildable_name() + OString::number(nSize)); + pNewLine->m_xValueEdit->set_buildable_name( + pNewLine->m_xValueEdit->get_buildable_name() + OString::number(nSize)); + pNewLine->m_xRemoveButton->set_buildable_name( + pNewLine->m_xRemoveButton->get_buildable_name() + OString::number(nSize)); + } pNewLine->DoTypeHdl(*pNewLine->m_xTypeBox); } diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index 6cad5ecad14e..6923056183af 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -65,7 +65,11 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool bMobile) || rUIFile == u"modules/swriter/ui/contentcontroldlg.ui" || rUIFile == u"modules/swriter/ui/contentcontrollistitemdlg.ui" || rUIFile == u"modules/swriter/ui/splittable.ui" - || rUIFile == u"cui/ui/splitcellsdialog.ui") + || rUIFile == u"cui/ui/splitcellsdialog.ui" + || rUIFile == u"sfx/ui/documentpropertiesdialog.ui" + || rUIFile == u"sfx/ui/custominfopage.ui" || rUIFile == u"sfx/ui/cmisinfopage.ui" + || rUIFile == u"sfx/ui/descriptioninfopage.ui" || rUIFile == u"sfx/ui/documentinfopage.ui" + || rUIFile == u"sfx/ui/linefragment.ui" || rUIFile == u"sfx/ui/editdurationdialog.ui") { return true; }