[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/sfx2 sfx2/source

Muhammet Kara (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 28 22:05:51 UTC 2019


 include/sfx2/strings.hrc             |   29 +++++++++++++
 sfx2/source/doc/autoredactdialog.cxx |   73 +++++++++++++++++++----------------
 2 files changed, 69 insertions(+), 33 deletions(-)

New commits:
commit 1f97392db369df7914c3ff2b94b0d80f1673211d
Author:     Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Mon Aug 26 17:51:19 2019 +0300
Commit:     Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Thu Aug 29 00:05:17 2019 +0200

    Make temp strings localizable in AutoRedactDialog
    
    Change-Id: Ic7136408b5b66ba437df92fe96d2852ae512cda0
    Reviewed-on: https://gerrit.libreoffice.org/78154
    Tested-by: Jenkins
    Reviewed-by: Muhammet Kara <muhammet.kara at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/78159
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>

diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc
index 373ca649fa48..3c7a9da9a5a0 100644
--- a/include/sfx2/strings.hrc
+++ b/include/sfx2/strings.hrc
@@ -183,6 +183,35 @@
 #define STR_WELCOME_LINE1                       NC_("STR_WELCOME_LINE1", "Welcome to %PRODUCTNAME.")
 #define STR_WELCOME_LINE2                       NC_("STR_WELCOME_LINE2", "Drop a document here or pick an app from the left side to create one.")
 
+// Translators: Target types in Auto-redaction dialog
+#define STR_REDACTION_TARGET_TYPE_TEXT          NC_("STR_REDACTION_TARGET_TYPE_TEXT", "Text")
+#define STR_REDACTION_TARGET_TYPE_REGEX         NC_("STR_REDACTION_TARGET_TYPE_REGEX", "Regex")
+#define STR_REDACTION_TARGET_TYPE_PREDEF        NC_("STR_REDACTION_TARGET_TYPE_PREDEF", "Predefined")
+#define STR_REDACTION_TARGET_TYPE_UNKNOWN       NC_("STR_REDACTION_TARGET_TYPE_UNKNOWN", "Unknown")
+
+// Translators: Column headers in Auto-redaction dialog's targets list
+#define STR_REDACTION_TARGET_NAME               NC_("STR_REDACTION_TARGET_NAME", "Target Name")
+#define STR_REDACTION_TYPE                      NC_("STR_REDACTION_TYPE", "Type")
+#define STR_REDACTION_CONTENT                   NC_("STR_REDACTION_CONTENT", "Content")
+#define STR_REDACTION_CASE_SENSITIVE            NC_("STR_REDACTION_CASE_SENSITIVE", "Case Sensitive")
+#define STR_REDACTION_WHOLE_WORDS               NC_("STR_REDACTION_WHOLE_WORDS", "Whole Words")
+
+// Translators: Values for the Case Sensitive and the Whole Words columns in Auto-redaction dialog
+#define STR_REDACTION_YES                       NC_("STR_REDACTION_YES", "Yes")
+#define STR_REDACTION_NO                        NC_("STR_REDACTION_NO", "No")
+
+// Translators: Misc strings of the Auto Redaction dialog
+#define STR_REDACTION_TARGET                    NC_("STR_REDACTION_TARGET", "Target")
+#define STR_REDACTION_LOAD_TARGETS              NC_("STR_REDACTION_LOAD_TARGETS", "Load Targets")
+#define STR_REDACTION_SAVE_TARGETS              NC_("STR_REDACTION_SAVE_TARGETS", "Save Targets")
+#define STR_REDACTION_FIELDS_REQUIRED           NC_("STR_REDACTION_FIELDS_REQUIRED", "All fields are required")
+#define STR_REDACTION_TARGET_NAME_CLASH         NC_("STR_REDACTION_TARGET_NAME_CLASH", "There is already a target with this name")
+#define STR_REDACTION_MULTI_EDIT                NC_("STR_REDACTION_MULTI_EDIT", "You have selected multiple targets, but only one target can be edited at once.")
+#define STR_REDACTION_MULTI_DELETE              NC_("STR_REDACTION_MULTI_DELETE", "Are you sure you would like to delete $(TARGETSCOUNT) targets at once?")
+#define STR_REDACTION_JSON_FILE_FILTER          NC_("STR_REDACTION_JSON_FILE_FILTER", "Target Set (*.json)")
+#define STR_REDACTION_EDIT_TARGET               NC_("STR_REDACTION_EDIT_TARGET", "Edit Target")
+#define STR_REDACTION_TARGET_ADD_ERROR          NC_("STR_REDACTION_TARGET_ADD_ERROR", "An error occurred while adding new target. Please report this incident.")
+
 #define STR_SFX_FILEDLG_ACTUALVERSION           NC_("STR_SFX_FILEDLG_ACTUALVERSION", "Current version")
 #define STR_SFX_EXPLORERFILE_EXPORT             NC_("STR_SFX_EXPLORERFILE_EXPORT", "Export")
 #define STR_SFX_EXPLORERFILE_INSERT             NC_("STR_SFX_EXPLORERFILE_INSERT", "Insert")
diff --git a/sfx2/source/doc/autoredactdialog.cxx b/sfx2/source/doc/autoredactdialog.cxx
index b7cd1ce67f56..3fb9d6e03c7d 100644
--- a/sfx2/source/doc/autoredactdialog.cxx
+++ b/sfx2/source/doc/autoredactdialog.cxx
@@ -36,6 +36,8 @@
 
 #include <boost/property_tree/json_parser.hpp>
 
+#define FILEDIALOG_FILTER_JSON "*.json"
+
 int TargetsTable::GetRowByTargetName(const OUString& sName)
 {
     for (int i = 0, nCount = m_xControl->n_children(); i < nCount; ++i)
@@ -68,21 +70,21 @@ namespace
 {
 OUString getTypeName(RedactionTargetType nType)
 {
-    OUString sTypeName("Unknown");
+    OUString sTypeName(SfxResId(STR_REDACTION_TARGET_TYPE_UNKNOWN));
 
     switch (nType)
     {
         case RedactionTargetType::REDACTION_TARGET_TEXT:
-            sTypeName = "Text";
+            sTypeName = SfxResId(STR_REDACTION_TARGET_TYPE_TEXT);
             break;
         case RedactionTargetType::REDACTION_TARGET_REGEX:
-            sTypeName = "Regex";
+            sTypeName = SfxResId(STR_REDACTION_TARGET_TYPE_REGEX);
             break;
         case RedactionTargetType::REDACTION_TARGET_PREDEFINED:
-            sTypeName = "Predefined";
+            sTypeName = SfxResId(STR_REDACTION_TARGET_TYPE_PREDEF);
             break;
         case RedactionTargetType::REDACTION_TARGET_UNKNOWN:
-            sTypeName = "Unknown";
+            sTypeName = SfxResId(STR_REDACTION_TARGET_TYPE_UNKNOWN);
             break;
     }
 
@@ -141,8 +143,11 @@ void TargetsTable::InsertTarget(RedactionTarget* pTarget)
     m_xControl->append(OUString::number(reinterpret_cast<sal_Int64>(pTarget)), pTarget->sName);
     m_xControl->set_text(nRow, getTypeName(pTarget->sType), 1);
     m_xControl->set_text(nRow, sContent, 2);
-    m_xControl->set_text(nRow, pTarget->bCaseSensitive ? OUString("Yes") : OUString("No"), 3);
-    m_xControl->set_text(nRow, pTarget->bWholeWords ? OUString("Yes") : OUString("No"), 4);
+    m_xControl->set_text(
+        nRow, pTarget->bCaseSensitive ? SfxResId(STR_REDACTION_YES) : SfxResId(STR_REDACTION_NO),
+        3);
+    m_xControl->set_text(
+        nRow, pTarget->bWholeWords ? SfxResId(STR_REDACTION_YES) : SfxResId(STR_REDACTION_NO), 4);
 }
 
 void TargetsTable::SelectByName(const OUString& sName)
@@ -164,8 +169,7 @@ RedactionTarget* TargetsTable::GetTargetByName(const OUString& sName)
 
 OUString TargetsTable::GetNameProposal()
 {
-    //TODO: Define a translatable string
-    OUString sDefaultTargetName("Target");
+    OUString sDefaultTargetName(SfxResId(STR_REDACTION_TARGET));
     sal_Int32 nHighestTargetId = 0;
     for (int i = 0, nCount = m_xControl->n_children(); i < nCount; ++i)
     {
@@ -195,21 +199,25 @@ void TargetsTable::setRowData(const int& nRowIndex, const RedactionTarget* pTarg
     m_xControl->set_text(nRowIndex, pTarget->sName, 0);
     m_xControl->set_text(nRowIndex, getTypeName(pTarget->sType), 1);
     m_xControl->set_text(nRowIndex, sContent, 2);
-    m_xControl->set_text(nRowIndex, pTarget->bCaseSensitive ? OUString("Yes") : OUString("No"), 3);
-    m_xControl->set_text(nRowIndex, pTarget->bWholeWords ? OUString("Yes") : OUString("No"), 4);
+    m_xControl->set_text(
+        nRowIndex,
+        pTarget->bCaseSensitive ? SfxResId(STR_REDACTION_YES) : SfxResId(STR_REDACTION_NO), 3);
+    m_xControl->set_text(
+        nRowIndex, pTarget->bWholeWords ? SfxResId(STR_REDACTION_YES) : SfxResId(STR_REDACTION_NO),
+        4);
 }
 
 IMPL_LINK_NOARG(SfxAutoRedactDialog, Load, weld::Button&, void)
 {
     //Load a targets list from a previously saved file (a json file?)
     // ask for filename, where we should load the new config data from
-    StartFileDialog(StartFileDialogType::Open, "Load Targets");
+    StartFileDialog(StartFileDialogType::Open, SfxResId(STR_REDACTION_LOAD_TARGETS));
 }
 
 IMPL_LINK_NOARG(SfxAutoRedactDialog, Save, weld::Button&, void)
 {
     //Allow saving the targets into a file
-    StartFileDialog(StartFileDialogType::SaveAs, "Save Targets");
+    StartFileDialog(StartFileDialogType::SaveAs, SfxResId(STR_REDACTION_SAVE_TARGETS));
 }
 
 IMPL_LINK_NOARG(SfxAutoRedactDialog, AddHdl, weld::Button&, void)
@@ -230,9 +238,9 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, AddHdl, weld::Button&, void)
             || aAddTargetDialog.getContent().isEmpty())
         {
             bIncomplete = true;
-            std::unique_ptr<weld::MessageDialog> xBox(
-                Application::CreateMessageDialog(getDialog(), VclMessageType::Warning,
-                                                 VclButtonsType::Ok, "All fields are required"));
+            std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(
+                getDialog(), VclMessageType::Warning, VclButtonsType::Ok,
+                SfxResId(STR_REDACTION_FIELDS_REQUIRED)));
             xBox->run();
         }
         else if (m_xTargetsBox->GetTargetByName(aAddTargetDialog.getName()))
@@ -240,7 +248,7 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, AddHdl, weld::Button&, void)
             bIncomplete = true;
             std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(
                 getDialog(), VclMessageType::Warning, VclButtonsType::Ok,
-                "There is already a target with this name"));
+                SfxResId(STR_REDACTION_TARGET_NAME_CLASH)));
             xBox->run();
         }
 
@@ -261,7 +269,7 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, AddHdl, weld::Button&, void)
     {
         std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(
             getDialog(), VclMessageType::Warning, VclButtonsType::Ok,
-            "An error occured while adding new target. Please report this incidence."));
+            SfxResId(STR_REDACTION_TARGET_ADD_ERROR)));
         xBox->run();
         delete redactiontarget;
     }
@@ -278,11 +286,10 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, EditHdl, weld::Button&, void)
     // Only one entry should be selected for editing
     if (m_xTargetsBox->get_selected_rows().size() > 1)
     {
-        OUString sMsg(
-            "You have selected multiple targets, but only one target can be edited at once.");
         //Warn the user about multiple selections
-        std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(
-            getDialog(), VclMessageType::Error, VclButtonsType::Ok, sMsg));
+        std::unique_ptr<weld::MessageDialog> xBox(
+            Application::CreateMessageDialog(getDialog(), VclMessageType::Error, VclButtonsType::Ok,
+                                             SfxResId(STR_REDACTION_MULTI_EDIT)));
         xBox->run();
         return;
     }
@@ -309,9 +316,9 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, EditHdl, weld::Button&, void)
             || aEditTargetDialog.getContent().isEmpty())
         {
             bIncomplete = true;
-            std::unique_ptr<weld::MessageDialog> xBox(
-                Application::CreateMessageDialog(getDialog(), VclMessageType::Warning,
-                                                 VclButtonsType::Ok, "All fields are required"));
+            std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(
+                getDialog(), VclMessageType::Warning, VclButtonsType::Ok,
+                SfxResId(STR_REDACTION_FIELDS_REQUIRED)));
             xBox->run();
         }
         else if (aEditTargetDialog.getName() != pTarget->sName
@@ -320,7 +327,7 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, EditHdl, weld::Button&, void)
             bIncomplete = true;
             std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(
                 getDialog(), VclMessageType::Warning, VclButtonsType::Ok,
-                "There is already a target with this name"));
+                SfxResId(STR_REDACTION_TARGET_NAME_CLASH)));
             xBox->run();
         }
 
@@ -347,8 +354,8 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, DeleteHdl, weld::Button&, void)
 
     if (aSelectedRows.size() > 1)
     {
-        OUString sMsg("Are you sure you would like to delete "
-                      + OUString::number(aSelectedRows.size()) + " targets at once?");
+        OUString sMsg(SfxResId(STR_REDACTION_MULTI_DELETE)
+                          .replaceFirst("$(TARGETSCOUNT)", OUString::number(aSelectedRows.size())));
         //Warn the user about multiple deletions
         std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(
             getDialog(), VclMessageType::Question, VclButtonsType::OkCancel, sMsg));
@@ -492,7 +499,7 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, SaveHdl, sfx2::FileDialogHelper*, void)
 void SfxAutoRedactDialog::StartFileDialog(StartFileDialogType nType, const OUString& rTitle)
 {
     OUString aFilterAllStr(SfxResId(STR_SFX_FILTERNAME_ALL));
-    OUString aFilterCfgStr("Target Set (*.json)");
+    OUString aFilterJsonStr(SfxResId(STR_REDACTION_JSON_FILE_FILTER));
 
     bool bSave = nType == StartFileDialogType::SaveAs;
     short nDialogType = bSave ? css::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION
@@ -501,8 +508,8 @@ void SfxAutoRedactDialog::StartFileDialog(StartFileDialogType nType, const OUStr
 
     m_pFileDlg->SetTitle(rTitle);
     m_pFileDlg->AddFilter(aFilterAllStr, FILEDIALOG_FILTER_ALL);
-    m_pFileDlg->AddFilter(aFilterCfgStr, "*.json");
-    m_pFileDlg->SetCurrentFilter(aFilterCfgStr);
+    m_pFileDlg->AddFilter(aFilterJsonStr, FILEDIALOG_FILTER_JSON);
+    m_pFileDlg->SetCurrentFilter(aFilterJsonStr);
 
     Link<sfx2::FileDialogHelper*, void> aDlgClosedLink
         = bSave ? LINK(this, SfxAutoRedactDialog, SaveHdl)
@@ -522,7 +529,7 @@ void SfxAutoRedactDialog::addTarget(RedactionTarget* pTarget)
     {
         std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(
             getDialog(), VclMessageType::Warning, VclButtonsType::Ok,
-            "An error occurred while adding new target. Please report this incident."));
+            SfxResId(STR_REDACTION_TARGET_ADD_ERROR)));
         xBox->run();
         delete pTarget;
     }
@@ -757,7 +764,7 @@ SfxAddTargetDialog::SfxAddTargetDialog(weld::Window* pParent, const OUString& sN
     m_xCaseSensitive->set_active(bCaseSensitive);
     m_xWholeWords->set_active(bWholeWords);
 
-    set_title("Edit Target");
+    set_title(SfxResId(STR_REDACTION_EDIT_TARGET));
 }
 
 RedactionTargetType SfxAddTargetDialog::getType() const


More information about the Libreoffice-commits mailing list