sw/source/filter/ww8/sprmids.hxx |   46 ++++++++++++++-------------------------
 sw/source/filter/ww8/ww8scan.cxx |    3 --
 2 files changed, 18 insertions(+), 31 deletions(-)

New commits:
commit 0d45380c99c7200075d01860a2315d0ddb450f1c
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Jul 17 15:56:48 2020 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sat Jul 18 01:23:37 2020 +0200

    Drop macros in sprm definition
    
    Change-Id: I8f65a39d72bb06ed20bea352f5ce1d8ae43d305e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98984
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/source/filter/ww8/sprmids.hxx b/sw/source/filter/ww8/sprmids.hxx
index 47f2cb8a70b6..ac1d33cf8a80 100644
--- a/sw/source/filter/ww8/sprmids.hxx
+++ b/sw/source/filter/ww8/sprmids.hxx
@@ -258,38 +258,26 @@ enum class SPRA
     operand_varlen_6 = 6,
     operand_3b_7 = 7
 };
-
-#define SPRM_PART(num, mask, shift) ((static_cast<sal_uInt16>(num) & mask) << 
shift)
-#define SPRM(ispmd, fSpec, sgc, spra)                                          
                    \
-    SPRM_PART(ispmd, 0x01FF, 0) + SPRM_PART(fSpec, 0x0001, 9) + SPRM_PART(sgc, 
0x0007, 10)         \
-        + SPRM_PART(spra, 0x0007, 13)
+template <SPRA spra> constexpr int spraLen(); // no definition
+template <> constexpr int spraLen<SPRA::operand_toggle_1b_0>() { return 1; }
+template <> constexpr int spraLen<SPRA::operand_1b_1>() { return 1; }
+template <> constexpr int spraLen<SPRA::operand_2b_2>() { return 2; }
+template <> constexpr int spraLen<SPRA::operand_4b_3>() { return 4; }
+template <> constexpr int spraLen<SPRA::operand_2b_4>() { return 2; }
+template <> constexpr int spraLen<SPRA::operand_2b_5>() { return 2; }
+template <> constexpr int spraLen<SPRA::operand_varlen_6>() { return 0; } // 
variable
+template <> constexpr int spraLen<SPRA::operand_3b_7>() { return 3; }
 
 template <int ispmd, int fSpec, SGC sgc, SPRA spra> struct sprm
 {
-    static constexpr sal_uInt16 val = SPRM(ispmd, fSpec, sgc, spra);
-    static constexpr int len()
-    {
-        switch (spra)
-        {
-            case SPRA::operand_toggle_1b_0:
-            case SPRA::operand_1b_1:
-                return 1;
-            case SPRA::operand_2b_2:
-            case SPRA::operand_2b_4:
-            case SPRA::operand_2b_5:
-                return 2;
-            case SPRA::operand_4b_3:
-                return 4;
-            case SPRA::operand_varlen_6:
-                return 0; // variable
-            case SPRA::operand_3b_7:
-                return 3;
-            default:
-                assert(false);
-                return 0;
-        }
-    }
-    static constexpr bool varlen() { return (spra == SPRA::operand_varlen_6); }
+    static_assert((ispmd & 0x01FF) == ispmd);
+    static_assert((fSpec & 0x0001) == fSpec);
+    static_assert((static_cast<sal_uInt16>(sgc) & 0x0007) == 
static_cast<sal_uInt16>(sgc));
+    static_assert((static_cast<sal_uInt16>(spra) & 0x0007) == 
static_cast<sal_uInt16>(spra));
+    static constexpr sal_uInt16 val = ispmd + (fSpec << 9) + 
(static_cast<sal_uInt16>(sgc) << 10)
+                                      + (static_cast<sal_uInt16>(spra) << 13);
+    static constexpr int len = spraLen<spra>();
+    static constexpr bool varlen = spra == SPRA::operand_varlen_6;
 };
 
 template <int ispmd, int fSpec, SPRA spra> using sprmPar = sprm<ispmd, fSpec, 
SGC::paragraph, spra>;
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index f34dae669b3e..b30618d17a8c 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -435,8 +435,7 @@ void wwSprmSearcher::patchCJKVariant()
 
 template <class Sprm> static constexpr SprmInfoRow InfoRow()
 {
-    return { Sprm::val,
-             { Sprm::len(), Sprm::varlen() ? wwSprmParser::L_VAR : 
wwSprmParser::L_FIX } };
+    return { Sprm::val, { Sprm::len, Sprm::varlen ? wwSprmParser::L_VAR : 
wwSprmParser::L_FIX } };
 }
 
 const wwSprmSearcher *wwSprmParser::GetWW8SprmSearcher()
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to