[Libreoffice-commits] core.git: include/svl svl/qa svl/source

Laurent BP laurent.balland-poirier at laposte.net
Wed Nov 1 14:32:35 UTC 2017


 include/svl/zformat.hxx         |    2 ++
 svl/qa/unit/svl.cxx             |   24 ++++++++++++++++++++++++
 svl/source/numbers/zformat.cxx  |   11 +++++++++++
 svl/source/numbers/zforscan.hxx |    4 ++++
 4 files changed, 41 insertions(+)

New commits:
commit f04c354a8288e2f60685e55cf89e5e580beb1c1a
Author: Laurent BP <laurent.balland-poirier at laposte.net>
Date:   Sun Oct 22 19:38:19 2017 +0200

    QA test of StandardColor
    
    Change-Id: Ib5b414d533ea3dcce55f4e6a02f329e98acf6e83
    Reviewed-on: https://gerrit.libreoffice.org/43791
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx
index 3148e89df8a3..882082a6313e 100644
--- a/include/svl/zformat.hxx
+++ b/include/svl/zformat.hxx
@@ -475,6 +475,8 @@ public:
 
     const NfKeywordTable & GetKeywords() const;
     const ::std::vector<OUString> & GetEnglishKeywords() const;
+    const ::std::vector<Color> & GetStandardColor() const;
+    size_t GetMaxDefaultColors() const;
 
 private:
     ImpSvNumFor NumFor[4];          // Array for the 4 subformats
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index db3c1c35d699..558047bec5a2 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -37,6 +37,7 @@
 #include <svl/zformat.hxx>
 #include <svl/sharedstringpool.hxx>
 #include <svl/sharedstring.hxx>
+#include <tools/color.hxx>
 #include <unotools/syslocale.hxx>
 
 #include <memory>
@@ -65,6 +66,7 @@ public:
     void testIsNumberFormat();
     void testUserDefinedNumberFormats();
     void testNfEnglishKeywordsIntegrity();
+    void testStandardColorIntegrity();
 
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(testNumberFormat);
@@ -78,6 +80,7 @@ public:
     CPPUNIT_TEST(testIsNumberFormat);
     CPPUNIT_TEST(testUserDefinedNumberFormats);
     CPPUNIT_TEST(testNfEnglishKeywordsIntegrity);
+    CPPUNIT_TEST(testStandardColorIntegrity);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1451,6 +1454,27 @@ void Test::testNfEnglishKeywordsIntegrity()
     CPPUNIT_ASSERT_EQUAL( sEnglishKeywords[NF_KEY_THAI_T], OUString("t") );
 }
 
+void Test::testStandardColorIntegrity()
+{
+    SvNumberFormatter aFormatter(m_xContext, LANGUAGE_ENGLISH_US);
+    const SvNumberformat* pNumberFormat = aFormatter.GetEntry(0);
+    const ::std::vector<Color> & aStandardColors = pNumberFormat->GetStandardColor();
+    const size_t nMaxDefaultColors = pNumberFormat->GetMaxDefaultColors();
+    CPPUNIT_ASSERT_EQUAL( nMaxDefaultColors, size_t(NF_KEY_LASTCOLOR) - size_t(NF_KEY_FIRSTCOLOR) + 1 );
+    CPPUNIT_ASSERT_EQUAL( nMaxDefaultColors, aStandardColors.size() );
+    // Colors must follow same order as in sEnglishKeyword
+    CPPUNIT_ASSERT_EQUAL( aStandardColors[0].GetColor(), COL_BLACK );
+    CPPUNIT_ASSERT_EQUAL( aStandardColors[1].GetColor(), COL_LIGHTBLUE );
+    CPPUNIT_ASSERT_EQUAL( aStandardColors[2].GetColor(), COL_LIGHTGREEN );
+    CPPUNIT_ASSERT_EQUAL( aStandardColors[3].GetColor(), COL_LIGHTCYAN );
+    CPPUNIT_ASSERT_EQUAL( aStandardColors[4].GetColor(), COL_LIGHTRED );
+    CPPUNIT_ASSERT_EQUAL( aStandardColors[5].GetColor(), COL_LIGHTMAGENTA );
+    CPPUNIT_ASSERT_EQUAL( aStandardColors[6].GetColor(), COL_BROWN );
+    CPPUNIT_ASSERT_EQUAL( aStandardColors[7].GetColor(), COL_GRAY );
+    CPPUNIT_ASSERT_EQUAL( aStandardColors[8].GetColor(), COL_YELLOW );
+    CPPUNIT_ASSERT_EQUAL( aStandardColors[9].GetColor(), COL_WHITE );
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 29d66a073d4f..1f2012f998ca 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -5531,9 +5531,20 @@ const NfKeywordTable & SvNumberformat::GetKeywords() const
 {
     return rScan.GetKeywords();
 }
+
 const ::std::vector<OUString> & SvNumberformat::GetEnglishKeywords() const
 {
     return ImpSvNumberformatScan::GetEnglishKeywords();
 }
 
+const ::std::vector<Color> & SvNumberformat::GetStandardColor() const
+{
+    return ImpSvNumberformatScan::GetStandardColor();
+}
+
+size_t SvNumberformat::GetMaxDefaultColors() const
+{
+    return ImpSvNumberformatScan::GetMaxDefaultColors();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/numbers/zforscan.hxx b/svl/source/numbers/zforscan.hxx
index 37c59c5010be..fe08984e5c77 100644
--- a/svl/source/numbers/zforscan.hxx
+++ b/svl/source/numbers/zforscan.hxx
@@ -87,6 +87,10 @@ public:
         {
             return StandardColor;
         }
+    static size_t GetMaxDefaultColors()
+        {
+            return NF_MAX_DEFAULT_COLORS;
+        }
 
     const Date& GetNullDate() const           { return maNullDate; }
     const OUString& GetStandardName() const


More information about the Libreoffice-commits mailing list