summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiddhant Chaudhary <urssidd@gmail.com>2022-03-29 19:06:09 +0530
committerHossein <hossein@libreoffice.org>2022-06-20 15:46:48 +0200
commitff9ff6018bea7c1a4524c8edca8ef554c74e4b3f (patch)
tree36fd1121fc2312bd6b8dc8483ecd4ffcc0137ec8
parentdf0d25d440aad265b3cb3555632bf19f74f47330 (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>
-rw-r--r--static/CustomTarget_emscripten_fs_image.mk1
-rw-r--r--uui/inc/strings.hrc7
-rw-r--r--uui/source/iahndl-locking.cxx15
-rw-r--r--uui/source/openlocked.cxx63
-rw-r--r--uui/source/openlocked.hxx31
-rw-r--r--vcl/UIConfig_vcl.mk1
-rw-r--r--vcl/uiconfig/ui/openlockedquerybox.ui270
7 files changed, 354 insertions, 34 deletions
diff --git a/static/CustomTarget_emscripten_fs_image.mk b/static/CustomTarget_emscripten_fs_image.mk
index 8166802858e5..a82d51d94db5 100644
--- a/static/CustomTarget_emscripten_fs_image.mk
+++ b/static/CustomTarget_emscripten_fs_image.mk
@@ -1076,6 +1076,7 @@ gb_emscripten_fs_image_files := \
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/vcl/ui/menutogglebutton3.ui \
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/vcl/ui/menutogglebutton4.ui \
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/vcl/ui/printdialog.ui \
+ $(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/vcl/ui/openlockedquerybox.ui \
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/vcl/ui/printerdevicepage.ui \
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/vcl/ui/printerpaperpage.ui \
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/vcl/ui/printerpropertiesdialog.ui \
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: */
diff --git a/vcl/UIConfig_vcl.mk b/vcl/UIConfig_vcl.mk
index 703cef1e6e1c..10a823cc87b2 100644
--- a/vcl/UIConfig_vcl.mk
+++ b/vcl/UIConfig_vcl.mk
@@ -29,6 +29,7 @@ $(eval $(call gb_UIConfig_add_uifiles,vcl,\
vcl/uiconfig/ui/querydialog \
vcl/uiconfig/ui/screenshotparent \
vcl/uiconfig/ui/wizard \
+ vcl/uiconfig/ui/openlockedquerybox \
))
$(eval $(call gb_UIConfig_add_a11yerrors_uifiles,vcl,\
diff --git a/vcl/uiconfig/ui/openlockedquerybox.ui b/vcl/uiconfig/ui/openlockedquerybox.ui
new file mode 100644
index 000000000000..6405faab53e3
--- /dev/null
+++ b/vcl/uiconfig/ui/openlockedquerybox.ui
@@ -0,0 +1,270 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2 -->
+<interface domain="vcl">
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkDialog" id="OpenLockedQueryBox">
+ <property name="can-focus">False</property>
+ <property name="border-width">6</property>
+ <property name="title" translatable="yes" context="openlockedquerybox|OpenLockedQueryBox">Document in Use</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="destroy-with-parent">True</property>
+ <property name="type-hint">dialog</property>
+ <property name="urgency-hint">True</property>
+ <property name="gravity">north</property>
+ <child type="titlebar">
+ <placeholder/>
+ </child>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="VerticalBox">
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="ButtonContainer">
+ <property name="can-focus">False</property>
+ <property name="layout-style">end</property>
+ <child>
+ <object class="GtkButton" id="open">
+ <property name="label" translatable="yes" context="stock">_Open</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
+ <property name="use-underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel">
+ <property name="label" translatable="yes" context="stock">_Cancel</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="use-underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack-type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="MainPanel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="spacing">24</property>
+ <child>
+ <object class="GtkImage" id="questionmark">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">start</property>
+ <property name="margin-start">24</property>
+ <property name="margin-top">70</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="questionmark-atkobject">
+ <property name="AtkObject::accessible-name" translatable="yes" context="openlockedquerybox|questionmark">Question mark image</property>
+ <property name="AtkObject::accessible-description" translatable="yes" context="openlockedquerybox|questionmark">Question mark icon for dialog box.</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <!-- n-columns=2 n-rows=4 -->
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="margin-end">6</property>
+ <property name="margin-top">6</property>
+ <property name="row-spacing">18</property>
+ <property name="column-spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="messagetext">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes" context="openlockedquerybox|messagetext">This file has been locked by another user.</property>
+ <property name="width-chars">0</property>
+ <property name="max-width-chars">0</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="messagetext-atkobject">
+ <property name="AtkObject::accessible-role">static</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="ReadOnlyMessage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="valign">start</property>
+ <property name="label" translatable="yes" context="openlockedquerybox|ReadOnlyMessage">You can open it read only and
+receive a notification if ready.</property>
+ <property name="xalign">0</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="ReadOnlyMessage-atkobject">
+ <property name="AtkObject::accessible-role">static</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="OpenCopyMessage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes" context="openlockedquerybox|OpenCopyMessage">You can open a copy on your
+local system.</property>
+ <property name="xalign">0</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="OpenCopyMessage-atkobject">
+ <property name="AtkObject::accessible-role">static</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkExpander" id="moredetailsexpander">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="resize-toplevel">True</property>
+ <child>
+ <object class="GtkLabel" id="hiddentext">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="margin-top">10</property>
+ <property name="xalign">0</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="hiddentext-atkobject">
+ <property name="AtkObject::accessible-role">static</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="expandertext">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes" context="openlockedquerybox|expandertext">_More Details</property>
+ <property name="use-underline">True</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">3</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="opencopy">
+ <property name="label" translatable="yes" context="stock">Open Co_py</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="use-underline">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">3</property>
+ <child>
+ <object class="GtkButton" id="readonly">
+ <property name="label" translatable="yes" context="stock">Open _R/O</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="use-underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="notify">
+ <property name="label" translatable="yes" context="stock">_Notify</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
+ <property name="use-underline">True</property>
+ <property name="draw-indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="OpenLockedQueryBox-atkobject">
+ <property name="AtkObject::accessible-description" translatable="yes" context="openlockedquerybox|OpenLockedQueryBox">Displays information about locked files and further steps to take when opening a locked file.</property>
+ </object>
+ </child>
+ </object>
+</interface>