diff options
author | Siddhant Chaudhary <urssidd@gmail.com> | 2022-03-29 19:06:09 +0530 |
---|---|---|
committer | Hossein <hossein@libreoffice.org> | 2022-06-20 15:46:48 +0200 |
commit | ff9ff6018bea7c1a4524c8edca8ef554c74e4b3f (patch) | |
tree | 36fd1121fc2312bd6b8dc8483ecd4ffcc0137ec8 /uui | |
parent | df0d25d440aad265b3cb3555632bf19f74f47330 (diff) |
tdf#141026 Put user and computer name into collapsed section
This patch hides away the file name and the name of the user when the
user tries to open a locked file. This improves privacy, as discussed in
the bug report.
The .ui file for the new dialog box is
`vcl/uiconfig/ui/openlockedquerybox.ui`. The source files
`openlocked.hxx` and `openlocked.cxx` have been changed to implement
the new dialog. The old string template `STR_OPENLOCKED_MSG` has been
deleted to hide away the private data, and a new string template
`STR_OPENLOCKED_HIDDEN_DATA` has been added; the latter will be hidden
inside the expander dialog. Finally, corresponding changes in the
makefiles have been made to let the makefiles know about the UI file.
Change-Id: I3cc9d2f6e2d9bc43857c80662e2a405aacd7fc70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132342
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
Diffstat (limited to 'uui')
-rw-r--r-- | uui/inc/strings.hrc | 7 | ||||
-rw-r--r-- | uui/source/iahndl-locking.cxx | 15 | ||||
-rw-r--r-- | uui/source/openlocked.cxx | 63 | ||||
-rw-r--r-- | uui/source/openlocked.hxx | 31 |
4 files changed, 82 insertions, 34 deletions
diff --git a/uui/inc/strings.hrc b/uui/inc/strings.hrc index e5af3465b557..98bd94ef8484 100644 --- a/uui/inc/strings.hrc +++ b/uui/inc/strings.hrc @@ -47,12 +47,7 @@ #define STR_LOCKFAILED_OPENREADONLY_BTN NC_("STR_LOCKFAILED_OPENREADONLY_BTN", "Open ~Read-Only") #define STR_LOCKFAILED_OPENREADONLY_NOTIFY_BTN NC_("STR_LOCKFAILED_OPENREADONLY_NOTIFY_BTN", "~Notify") -#define STR_OPENLOCKED_TITLE NC_("STR_OPENLOCKED_TITLE", "Document in Use") -#define STR_OPENLOCKED_MSG NC_("STR_OPENLOCKED_MSG", "Document file '$(ARG1)' is locked for editing by:\n\n$(ARG2)\n\nOpen document read-only or open a copy of the document for editing.\nSelect Notify to open read-only and get notified when the document becomes editable.$(ARG3)") -#define STR_OPENLOCKED_ALLOWIGNORE_MSG NC_("STR_OPENLOCKED_ALLOWIGNORE_MSG", "\nYou may also ignore the file locking and open the document for editing.") -#define STR_OPENLOCKED_OPENREADONLY_BTN NC_("STR_OPENLOCKED_OPENREADONLY_BTN", "Open ~Read-Only") -#define STR_OPENLOCKED_OPENREADONLY_NOTIFY_BTN NC_("STR_OPENLOCKED_OPENREADONLY_NOTIFY_BTN", "~Notify") -#define STR_OPENLOCKED_OPENCOPY_BTN NC_("STR_OPENLOCKED_OPENCOPY_BTN", "Open ~Copy") +#define STR_OPENLOCKED_HIDDEN_DATA NC_("STR_OPENLOCKED_HIDDEN_DATA", "Document Name: $(ARG1)\nUser Name: $(ARG2)") #define STR_UNKNOWNUSER NC_("STR_UNKNOWNUSER", "Unknown User") #define STR_FILECHANGED_TITLE NC_("STR_FILECHANGED_TITLE", "Document Has Been Changed by Others") diff --git a/uui/source/iahndl-locking.cxx b/uui/source/iahndl-locking.cxx index 64af0961d48a..b1f55dd85667 100644 --- a/uui/source/iahndl-locking.cxx +++ b/uui/source/iahndl-locking.cxx @@ -107,6 +107,7 @@ handleLockedDocumentRequest_( std::locale aResLocale = Translate::Create("uui"); OUString aMessage; + OUString aHiddenData; std::vector< OUString > aArguments { aDocumentURL }; bool bAllowOverride = xRetry.is() && officecfg::Office::Common::Misc::AllowOverrideLocking::get(); @@ -117,14 +118,12 @@ handleLockedDocumentRequest_( aArguments.push_back( !aInfo.isEmpty() ? aInfo : Translate::get( STR_UNKNOWNUSER, aResLocale) ); - aArguments.push_back( bAllowOverride - ? Translate::get( STR_OPENLOCKED_ALLOWIGNORE_MSG, aResLocale ) - : "" ); - aMessage = Translate::get(STR_OPENLOCKED_MSG, aResLocale); - aMessage = UUIInteractionHelper::replaceMessageWithArguments( - aMessage, aArguments ); - OpenLockedQueryBox aDialog(pParent, aResLocale, aMessage, bAllowOverride); + aHiddenData = Translate::get(STR_OPENLOCKED_HIDDEN_DATA, aResLocale); + aHiddenData = UUIInteractionHelper::replaceMessageWithArguments( + aHiddenData, aArguments ); + + vcl::OpenLockedQueryBox aDialog(pParent, aHiddenData, bAllowOverride); nResult = aDialog.run(); } else if ( nMode == UUI_DOC_SAVE_LOCK ) @@ -137,7 +136,7 @@ handleLockedDocumentRequest_( aResLocale); aMessage = UUIInteractionHelper::replaceMessageWithArguments( aMessage, aArguments ); - + TryLaterQueryBox aDialog(pParent, aResLocale, aMessage, bAllowOverride); nResult = aDialog.run(); } diff --git a/uui/source/openlocked.cxx b/uui/source/openlocked.cxx index a0284b194b14..453022b912ab 100644 --- a/uui/source/openlocked.cxx +++ b/uui/source/openlocked.cxx @@ -20,23 +20,60 @@ #include <strings.hrc> #include "openlocked.hxx" #include <officecfg/Office/Common.hxx> -#include <unotools/resmgr.hxx> -#include <vcl/stdtext.hxx> -#include <vcl/svapp.hxx> +#include <vcl/weldutils.hxx> -OpenLockedQueryBox::OpenLockedQueryBox(weld::Window* pParent, const std::locale& rResLocale, const OUString& rMessage, bool bEnableOverride) - : m_xQueryBox(Application::CreateMessageDialog(pParent, VclMessageType::Question, VclButtonsType::NONE, rMessage)) +using namespace vcl; + +IMPL_LINK(OpenLockedQueryBox, ClickHdl, weld::Button&, rButton, void) { - m_xQueryBox->set_title(Translate::get(STR_OPENLOCKED_TITLE, rResLocale)); - m_xQueryBox->add_button(Translate::get(STR_OPENLOCKED_OPENREADONLY_BTN, rResLocale), RET_YES); - m_xQueryBox->add_button(Translate::get(STR_OPENLOCKED_OPENREADONLY_NOTIFY_BTN, rResLocale), RET_RETRY); - m_xQueryBox->add_button(Translate::get(STR_OPENLOCKED_OPENCOPY_BTN, rResLocale), RET_NO); - if (bEnableOverride && officecfg::Office::Common::Misc::AllowOverrideLocking::get()) + if (&rButton == mxOpenReadOnlyBtn.get()) + { + if (mxNotifyBtn->get_active()) + m_xDialog->response(RET_RETRY); + else + m_xDialog->response(RET_YES); + } + else if (&rButton == mxOpenCopyBtn.get()) + { + m_xDialog->response(RET_NO); + } + else if (&rButton == mxOpenBtn.get()) + { + m_xDialog->response(RET_IGNORE); + } + else if (&rButton == mxCancelBtn.get()) { - // Present option to ignore the (stale?) lock file and open the document - m_xQueryBox->add_button(Translate::get(STR_ALREADYOPEN_OPEN_BTN, rResLocale), RET_IGNORE); + m_xDialog->response(RET_CANCEL); } - m_xQueryBox->add_button(GetStandardText(StandardButtonType::Cancel), RET_CANCEL); +} + +OpenLockedQueryBox::OpenLockedQueryBox(weld::Window* pParent, const OUString& rHiddenData, bool bEnableOverride) + : GenericDialogController(pParent, "vcl/ui/openlockedquerybox.ui", "OpenLockedQueryBox") + , mxQuestionMarkImage(m_xBuilder->weld_image("questionmark")) + , mxOpenReadOnlyBtn(m_xBuilder->weld_button("readonly")) + , mxOpenCopyBtn(m_xBuilder->weld_button("opencopy")) + , mxOpenBtn(m_xBuilder->weld_button("open")) + , mxCancelBtn(m_xBuilder->weld_button("cancel")) + , mxNotifyBtn(m_xBuilder->weld_check_button("notify")) + , mxHiddenText(m_xBuilder->weld_label("hiddentext")) +{ + //set up the image + mxQuestionMarkImage->set_from_icon_name(u"vcl/res/help.png"); + + //setup click hdl + mxOpenReadOnlyBtn->connect_clicked(LINK(this, OpenLockedQueryBox, ClickHdl)); + mxOpenCopyBtn->connect_clicked(LINK(this, OpenLockedQueryBox, ClickHdl)); + mxOpenBtn->connect_clicked(LINK(this, OpenLockedQueryBox, ClickHdl)); + mxCancelBtn->connect_clicked(LINK(this, OpenLockedQueryBox, ClickHdl)); + + if (!(bEnableOverride && officecfg::Office::Common::Misc::AllowOverrideLocking::get())) + { + //disable option to ignore the (stale?) lock file and open the document + mxOpenBtn->set_sensitive(false); + } + + mxHiddenText->set_label(rHiddenData); + m_xDialog->set_centered_on_parent(true); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/uui/source/openlocked.hxx b/uui/source/openlocked.hxx index 178269a62b35..90357651f30d 100644 --- a/uui/source/openlocked.hxx +++ b/uui/source/openlocked.hxx @@ -20,15 +20,32 @@ #include <vcl/weld.hxx> -class OpenLockedQueryBox +namespace vcl { -private: - std::unique_ptr<weld::MessageDialog> m_xQueryBox; +class OpenLockedQueryBox; +} +namespace vcl +{ +class OpenLockedQueryBox final : public weld::GenericDialogController +{ public: - OpenLockedQueryBox(weld::Window* pParent, const std::locale& rResLocale, - const OUString& rMessage, bool bEnableOverride); - short run() { return m_xQueryBox->run(); } -}; + OpenLockedQueryBox(weld::Window* pParent, const OUString& rHiddenData, bool bEnableOverride); + +private: + std::unique_ptr<weld::Image> mxQuestionMarkImage; + + std::unique_ptr<weld::Button> mxOpenReadOnlyBtn; + std::unique_ptr<weld::Button> mxOpenCopyBtn; + std::unique_ptr<weld::Button> mxOpenBtn; + std::unique_ptr<weld::Button> mxCancelBtn; + + std::unique_ptr<weld::CheckButton> mxNotifyBtn; + std::unique_ptr<weld::Label> mxHiddenText; + + DECL_LINK(ClickHdl, weld::Button&, void); + DECL_LINK(ToggleHdl, weld::Toggleable&, void); +}; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |