[Libreoffice-commits] core.git: sw/inc sw/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Mon Jan 6 22:16:02 UTC 2020


 sw/inc/AccessibilityCheckStrings.hrc         |   32 +++++++++++++++++++
 sw/source/core/access/AccessibilityCheck.cxx |   44 ++++++++++-----------------
 2 files changed, 49 insertions(+), 27 deletions(-)

New commits:
commit b993458b3fb02ef8a840001cddc2c84741edb25f
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Jan 6 19:24:26 2020 +0100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Jan 6 23:15:28 2020 +0100

    acc. check: move accessibility check strings to own file
    
    Change-Id: I455b6f77f75dd3190939c17bf5ffc362030efdbd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86290
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc
new file mode 100644
index 000000000000..ade032e13554
--- /dev/null
+++ b/sw/inc/AccessibilityCheckStrings.hrc
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_SW_INC_ACCESSIBILITY_CHECK_STRINGS_HRC
+#define INCLUDED_SW_INC_ACCESSIBILITY_CHECK_STRINGS_HRC
+
+#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
+
+#define STR_NO_ALT                      NC_("STR_NO_ALT", "No alt text for graphic '%OBJECT_NAME%'")
+#define STR_TABLE_MERGE_SPLIT           NC_("STR_TABLE_MERGE_SPLIT", "Table '%OBJECT_NAME%' contains merges or splits")
+#define STR_FAKE_NUMBERING              NC_("STR_FAKE_NUMBERING", "Fake numbering '%NUMBERING%'")
+#define STR_HYPERLINK_TEXT_IS_LINK      NC_("STR_HYPERLINK_TEXT_IS_LINK", "Hyperlink text is the same as the link address '%LINK%'")
+#define STR_TEXT_CONTRAST               NC_("STR_TEXT_CONTRAST", "Text contrast is too low.")
+#define STR_TEXT_BLINKING               NC_("STR_TEXT_BLINKING", "Blinking text.")
+#define STR_AVOID_FOOTNOTES             NC_("STR_AVOID_FOOTNOTES", "Avoid footnotes.")
+#define STR_AVOID_ENDNOTES              NC_("STR_AVOID_ENDNOTES", "Avoid endnotes.")
+#define STR_HEADINGS_NOT_IN_ORDER       NC_("STR_HEADINGS_NOT_IN_ORDER", "Headings not in order.")
+
+#define STR_DOCUMENT_DEFAULT_LANGUAGE   NC_("STR_DOCUMENT_DEFAULT_LANGUAGE", "Document default language is not set")
+#define STR_STYLE_NO_LANGUAGE           NC_("STR_STYLE_NO_LANGUAGE", "Style '%STYLE_NAME%' has no language set")
+#define STR_DOCUMENT_TITLE              NC_("STR_DOCUMENT_TITLE", "Document title is not set")
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx
index 5aee7b69c682..6f17ded00dc6 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -10,6 +10,7 @@
 
 #include <AccessibilityCheck.hxx>
 #include <AccessibilityIssue.hxx>
+#include <AccessibilityCheckStrings.hrc>
 #include <ndgrf.hxx>
 #include <ndole.hxx>
 #include <ndtxt.hxx>
@@ -33,20 +34,6 @@ namespace sw
 {
 namespace
 {
-// TODO move these to string file and look for a better name.
-OUString sNoAlt("No alt text for graphic '%OBJECT_NAME%'");
-OUString sTableMergeSplit("Table '%OBJECT_NAME%' contains merges or splits");
-OUString sFakeNumbering("Fake numbering '%NUMBERING%'");
-OUString sHyperlinkTextIsLink("Hyperlink text is the same as the link address '%LINK%'");
-OUString sDocumentDefaultLanguage("Document default language is not set");
-OUString sStyleNoLanguage("Style '%STYLE_NAME%' has no language set");
-OUString sDocumentTitle("Document title is not set");
-OUString sTextContrast("Text contrast is too low.");
-OUString sTextBlinking("Blinking text.");
-OUString sAvoidFootnotes("Avoid footnotes.");
-OUString sAvoidEndnotes("Avoid endnotes.");
-OUString sHeadingsOrder("Headings not in order.");
-
 std::shared_ptr<sw::AccessibilityIssue>
 lclAddIssue(svx::AccessibilityIssueCollection& rIssueCollection, OUString const& rText,
             svx::AccessibilityIssueID eIssue = svx::AccessibilityIssueID::UNSPECIFIED)
@@ -94,7 +81,7 @@ class NoTextNodeAltTextCheck : public NodeCheck
         {
             OUString sName = pNoTextNode->GetFlyFormat()->GetName();
 
-            OUString sIssueText = sNoAlt.replaceAll("%OBJECT_NAME%", sName);
+            OUString sIssueText = SwResId(STR_NO_ALT).replaceAll("%OBJECT_NAME%", sName);
 
             auto pIssue = lclAddIssue(m_rIssueCollection, sIssueText);
 
@@ -138,7 +125,7 @@ private:
     {
         const SwTableFormat* pFormat = rTable.GetFrameFormat();
         OUString sName = pFormat->GetName();
-        OUString sIssueText = sTableMergeSplit.replaceAll("%OBJECT_NAME%", sName);
+        OUString sIssueText = SwResId(STR_TABLE_MERGE_SPLIT).replaceAll("%OBJECT_NAME%", sName);
         auto pIssue = lclAddIssue(m_rIssueCollection, sIssueText);
         pIssue->setDoc(pDoc);
         pIssue->setIssueObject(IssueObject::TABLE);
@@ -242,7 +229,8 @@ public:
                         && pPreviousTextNode->GetText().startsWith(rPair.first))
                     {
                         OUString sNumbering = rPair.first + " " + rPair.second + "...";
-                        OUString sIssueText = sFakeNumbering.replaceAll("%NUMBERING%", sNumbering);
+                        OUString sIssueText
+                            = SwResId(STR_FAKE_NUMBERING).replaceAll("%NUMBERING%", sNumbering);
                         lclAddIssue(m_rIssueCollection, sIssueText);
                     }
                 }
@@ -267,7 +255,8 @@ private:
                 OUString sText = xTextRange->getString();
                 if (INetURLObject(sText) == INetURLObject(sHyperlink))
                 {
-                    OUString sIssueText = sHyperlinkTextIsLink.replaceFirst("%LINK%", sHyperlink);
+                    OUString sIssueText
+                        = SwResId(STR_HYPERLINK_TEXT_IS_LINK).replaceFirst("%LINK%", sHyperlink);
                     lclAddIssue(m_rIssueCollection, sIssueText);
                 }
             }
@@ -399,7 +388,7 @@ private:
             double fContrastRatio = calculateContrastRatio(aForegroundColor, aBackgroundColor);
             if (fContrastRatio < 4.5)
             {
-                lclAddIssue(m_rIssueCollection, sTextContrast);
+                lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_CONTRAST));
             }
         }
     }
@@ -447,7 +436,7 @@ private:
 
             if (bBlinking)
             {
-                lclAddIssue(m_rIssueCollection, sTextBlinking);
+                lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_BLINKING));
             }
         }
     }
@@ -506,7 +495,7 @@ public:
 
             if (nLevel > nPreviousLevel && std::abs(nLevel - nPreviousLevel) > 1)
             {
-                lclAddIssue(m_rIssueCollection, sHeadingsOrder);
+                lclAddIssue(m_rIssueCollection, SwResId(STR_HEADINGS_NOT_IN_ORDER));
             }
             nPreviousLevel = nLevel;
         }
@@ -540,7 +529,7 @@ public:
         LanguageType eLanguage = rLang.GetLanguage();
         if (eLanguage == LANGUAGE_NONE)
         {
-            lclAddIssue(m_rIssueCollection, sDocumentDefaultLanguage,
+            lclAddIssue(m_rIssueCollection, SwResId(STR_DOCUMENT_DEFAULT_LANGUAGE),
                         svx::AccessibilityIssueID::DOCUMENT_LANGUAGE);
         }
         else
@@ -551,7 +540,8 @@ public:
                 if (rAttrSet.GetLanguage(false).GetLanguage() == LANGUAGE_NONE)
                 {
                     OUString sName = pTextFormatCollection->GetName();
-                    OUString sIssueText = sStyleNoLanguage.replaceAll("%STYLE_NAME%", sName);
+                    OUString sIssueText
+                        = SwResId(STR_STYLE_NO_LANGUAGE).replaceAll("%STYLE_NAME%", sName);
                     lclAddIssue(m_rIssueCollection, sIssueText,
                                 svx::AccessibilityIssueID::STYLE_LANGUAGE);
                 }
@@ -580,7 +570,7 @@ public:
             OUString sTitle = xDocumentProperties->getTitle();
             if (sTitle.isEmpty())
             {
-                lclAddIssue(m_rIssueCollection, sDocumentTitle,
+                lclAddIssue(m_rIssueCollection, SwResId(STR_DOCUMENT_TITLE),
                             svx::AccessibilityIssueID::DOCUMENT_TITLE);
             }
         }
@@ -602,11 +592,11 @@ public:
             SwFormatFootnote const& rFootnote = pTextFootnote->GetFootnote();
             if (rFootnote.IsEndNote())
             {
-                lclAddIssue(m_rIssueCollection, sAvoidEndnotes);
+                lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_ENDNOTES));
             }
             else
             {
-                lclAddIssue(m_rIssueCollection, sAvoidFootnotes);
+                lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_FOOTNOTES));
             }
         }
     }
@@ -626,7 +616,7 @@ void AccessibilityCheck::checkObject(SdrObject* pObject)
         if (sAlternative.isEmpty())
         {
             OUString sName = pObject->GetName();
-            OUString sIssueText = sNoAlt.replaceAll("%OBJECT_NAME%", sName);
+            OUString sIssueText = SwResId(STR_NO_ALT).replaceAll("%OBJECT_NAME%", sName);
             lclAddIssue(m_aIssueCollection, sIssueText);
         }
     }


More information about the Libreoffice-commits mailing list