tdf#145919 Localize strings in Graphics Test dialog

but not in the saved log file

Change-Id: I65c580e7b8762b654f1812c96bc53841b882a960
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128087
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc
index fd91ae8..92e9cb7 100644
--- a/cui/inc/strings.hrc
+++ b/cui/inc/strings.hrc
@@ -396,4 +396,7 @@

#define RID_CUISTR_OLE_INSERT                       NC_("RID_SVXSTR_OLE_INSERT", "Inserting OLE object...")

#define RID_CUISTR_CLICK_RESULT                     NC_("RID_CUISTR_CLICK_RESULT", "(Click on any test to view its resultant bitmap image)")
#define RID_CUISTR_ZIPFAIL                          NC_("RID_CUISTR_ZIPFAIL", "Creation of Zip file failed!")
#define RID_CUISTR_SAVED                            NC_("RID_CUISTR_SAVED", "The results have been successfully saved in the file 'GraphicTestResults.zip'!")
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/dialogs/GraphicTestsDialog.cxx b/cui/source/dialogs/GraphicTestsDialog.cxx
index 555ef3b..c6232c2 100644
--- a/cui/source/dialogs/GraphicTestsDialog.cxx
+++ b/cui/source/dialogs/GraphicTestsDialog.cxx
@@ -14,6 +14,11 @@
#include <unotools/ZipPackageHelper.hxx>
#include <GraphicsTestsDialog.hxx>
#include <vcl/test/GraphicsRenderTests.hxx>
#include <svl/svlresid.hxx>
#include <svl/svl.hrc>

#include <dialmgr.hxx>
#include <strings.hrc>

GraphicTestEntry::GraphicTestEntry(weld::Container* pParent, weld::Dialog* pDialog,
                                   OUString aTestName, OUString aTestStatus, Bitmap aTestBitmap)
@@ -28,17 +33,18 @@ GraphicTestEntry::GraphicTestEntry(weld::Container* pParent, weld::Dialog* pDial
    m_xTestButton->set_label(aTestStatus);
    m_xTestButton->set_tooltip_text(aTestName);
    m_xTestButton->set_background(
        aTestStatus == "PASSED"
        aTestStatus == SvlResId(GRTSTR_PASSED)
            ? COL_LIGHTGREEN
            : aTestStatus == "QUIRKY" ? COL_YELLOW
                                      : aTestStatus == "FAILED" ? COL_LIGHTRED : COL_LIGHTGRAY);
            : aTestStatus == SvlResId(GRTSTR_QUIRKY)
                  ? COL_YELLOW
                  : aTestStatus == SvlResId(GRTSTR_FAILED) ? COL_LIGHTRED : COL_LIGHTGRAY);
    m_xTestButton->connect_clicked(LINK(this, GraphicTestEntry, HandleResultViewRequest));
    m_xContainer->show();
}

IMPL_LINK(GraphicTestEntry, HandleResultViewRequest, weld::Button&, rButton, void)
{
    if (rButton.get_label() == "SKIPPED")
    if (rButton.get_label() == SvlResId(GRTSTR_SKIPPED))
    {
        return;
    }
@@ -64,14 +70,14 @@ short GraphicsTestsDialog::run()
{
    GraphicsRenderTests aTestObject;
    aTestObject.run(true);
    OUString aResultLog = aTestObject.getResultString()
                          + "\n(Click on any test to view its resultant bitmap image)";
    OUString aResultLog
        = aTestObject.getResultString(true) + "\n" + CuiResId(RID_CUISTR_CLICK_RESULT);
    m_xResultLog->set_text(aResultLog);
    sal_Int32 nTestNumber = 0;
    for (const VclTestResult& test : aTestObject.getTestResults())
    for (VclTestResult& test : aTestObject.getTestResults())
    {
        auto xGpTest = std::make_unique<GraphicTestEntry>(m_xContainerBox.get(), m_xDialog.get(),
                                                          test.getTestName(), test.getStatus(),
                                                          test.getTestName(), test.getStatus(true),
                                                          test.getBitmap());
        m_xContainerBox->reorder_child(xGpTest->get_widget(), nTestNumber++);
        m_xGraphicTestEntries.push_back(std::move(xGpTest));
@@ -92,13 +98,11 @@ IMPL_LINK_NOARG(GraphicsTestsDialog, HandleDownloadRequest, weld::Button&, void)
    {
        std::unique_ptr<weld::MessageDialog> xBox(
            Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning,
                                             VclButtonsType::Ok, "Creation of Zip file failed!"));
                                             VclButtonsType::Ok, CuiResId(RID_CUISTR_ZIPFAIL)));
        xBox->run();
        return;
    }
    FileExportedDialog aDialog(
        m_xDialog.get(),
        "The results have been successfully saved in the file 'GraphicTestResults.zip' !");
    FileExportedDialog aDialog(m_xDialog.get(), CuiResId(RID_CUISTR_SAVED));
    aDialog.run();
}

diff --git a/include/svl/svl.hrc b/include/svl/svl.hrc
index f1f6075..2052273 100644
--- a/include/svl/svl.hrc
+++ b/include/svl/svl.hrc
@@ -26,6 +26,12 @@
#define STR_SVT_MIMETYPE_CNT_FSYSBOX            NC_("STR_SVT_MIMETYPE_CNT_FSYSBOX", "Workplace")
#define STR_FILECTRL_BUTTONTEXT                 NC_("STR_FILECTRL_BUTTONTEXT", "Browse...")

// tdf#145919 localizable strings to be shared in vcl and cui modules
#define GRTSTR_PASSED                               NC_("GRTSTR_PASSED", "PASSED")
#define GRTSTR_QUIRKY                               NC_("GRTSTR_QUIRKY", "QUIRKY")
#define GRTSTR_FAILED                               NC_("GRTSTR_FAILED", "FAILED")
#define GRTSTR_SKIPPED                              NC_("GRTSTR_SKIPPED", "SKIPPED")

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/test/GraphicsRenderTests.hxx b/include/vcl/test/GraphicsRenderTests.hxx
index 3002dfe..014f0d7 100644
--- a/include/vcl/test/GraphicsRenderTests.hxx
+++ b/include/vcl/test/GraphicsRenderTests.hxx
@@ -31,7 +31,7 @@ public:
    {
    }
    const OUString& getTestName() const { return m_aTestName; }
    const OUString& getStatus() const { return m_aTestStatus; }
    OUString getStatus(bool bLocalize = false);
    const Bitmap& getBitmap() const { return m_aResultantBitmap; }
};

@@ -157,7 +157,7 @@ class VCL_PLUGIN_PUBLIC GraphicsRenderTests

public:
    std::vector<VclTestResult>& getTestResults();
    OUString getResultString();
    OUString getResultString(bool bLocalize = false);
    void run(bool storeResultBitmap = false);

    GraphicsRenderTests()
diff --git a/vcl/backendtest/GraphicsRenderTests.cxx b/vcl/backendtest/GraphicsRenderTests.cxx
index 554d73f..efa3c28 100644
--- a/vcl/backendtest/GraphicsRenderTests.cxx
+++ b/vcl/backendtest/GraphicsRenderTests.cxx
@@ -9,6 +9,8 @@
 */

#include <test/outputdevice.hxx>
#include <svl/svlresid.hxx>
#include <svl/svl.hrc>
#include <unotools/bootstrap.hxx>
#include <vcl/test/GraphicsRenderTests.hxx>
#include <vcl/graphicfilter.hxx>
@@ -16,6 +18,7 @@

#include <svdata.hxx>
#include <salinst.hxx>
#include <strings.hrc>

#include <unordered_map>

@@ -27,6 +30,31 @@
     && aOutDevTest.getRenderBackendName() != "genpsp"                                             \
     && aOutDevTest.getRenderBackendName() != "win")

OUString VclTestResult::getStatus(bool bLocalize)
{ // tdf#145919 localize for UI but not in the log file
    if (bLocalize)
    {
        if (m_aTestStatus == "PASSED")
        {
            return SvlResId(GRTSTR_PASSED);
        }
        else if (m_aTestStatus == "QUIRKY")
        {
            return SvlResId(GRTSTR_QUIRKY);
        }
        else if (m_aTestStatus == "FAILED")
        {
            return SvlResId(GRTSTR_FAILED);
        }
        else
        {
            return SvlResId(GRTSTR_SKIPPED);
        }
    }
    else
        return m_aTestStatus;
}

namespace
{
void exportBitmapExToImage(OUString const& rImageName, const BitmapEx& rBitmapEx)
@@ -2336,10 +2364,10 @@ void GraphicsRenderTests::appendTestResult(OUString aTestName, OUString aTestSta

std::vector<VclTestResult>& GraphicsRenderTests::getTestResults() { return m_aTestResult; }

OUString GraphicsRenderTests::getResultString()
OUString GraphicsRenderTests::getResultString(bool bLocalize)
{
    std::vector<int> testResults(4);
    for (const VclTestResult& test : m_aTestResult)
    for (VclTestResult& test : m_aTestResult)
    {
        if (test.getStatus() == "PASSED")
        {
@@ -2358,11 +2386,25 @@ OUString GraphicsRenderTests::getResultString()
            testResults[3]++;
        }
    }
    OUString resultString = "Graphics Backend used: " + m_aCurGraphicsBackend
                            + "\nPassed Tests : " + OUString::number(testResults[0])
                            + "\nQuirky Tests : " + OUString::number(testResults[1])
                            + "\nFailed Tests : " + OUString::number(testResults[2])
                            + "\nSkipped Tests : " + OUString::number(testResults[3]) + "\n";
    // tdf#145919 localize for UI but not in the log file
    OUString resultString;
    if (bLocalize)
    {
        resultString
            = VclResId(STR_GBU).replaceFirst("%1", m_aCurGraphicsBackend) + "\n"
              + VclResId(STR_PASSED).replaceFirst("%1", OUString::number(testResults[0])) + "\n"
              + VclResId(STR_QUIRKY).replaceFirst("%1", OUString::number(testResults[1])) + "\n"
              + VclResId(STR_FAILED).replaceFirst("%1", OUString::number(testResults[2])) + "\n"
              + VclResId(STR_SKIPPED).replaceFirst("%1", OUString::number(testResults[3])) + "\n";
    }
    else
    {
        resultString = "Graphics Backend used: " + m_aCurGraphicsBackend
                       + "\nPassed Tests: " + OUString::number(testResults[0])
                       + "\nQuirky Tests: " + OUString::number(testResults[1])
                       + "\nFailed Tests: " + OUString::number(testResults[2])
                       + "\nSkipped Tests: " + OUString::number(testResults[3]) + "\n";
    }
    return resultString;
}

diff --git a/vcl/inc/strings.hrc b/vcl/inc/strings.hrc
index b960748..3346292 100644
--- a/vcl/inc/strings.hrc
+++ b/vcl/inc/strings.hrc
@@ -140,6 +140,11 @@

#define KEY_VERSION_CHECK                            NC_("KEY_VERSION_CHECK", "Warning: Not all of the imported EPS graphics could be saved at level1\nas some are at a higher level!")

#define STR_GBU                                     NC_("STR_GBU", "Graphics Backend used: %1")
#define STR_PASSED                                  NC_("STR_PASSED", "Passed Tests: %1")
#define STR_QUIRKY                                  NC_("STR_QUIRKY", "Quirky Tests: %1")
#define STR_FAILED                                  NC_("STR_FAILED", "Failed Tests: %1")
#define STR_SKIPPED                                 NC_("STR_SKIPPED", "Skipped Tests: %1")
#endif // INCLUDED_VCL_INC_STRINGS_HRC

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */