sw/source/core/inc/txttypes.hxx |  141 ++++++++++++++++++++++------------------
 sw/source/core/text/porlin.hxx  |   16 ----
 sw/source/core/text/xmldump.cxx |    3 
 3 files changed, 79 insertions(+), 81 deletions(-)

New commits:
commit 8977ade85a2869ce3bc69c62689ff4548303bdb1
Author:     Mike Kaganski <[email protected]>
AuthorDate: Fri Jan 19 14:35:46 2024 +0600
Commit:     Mike Kaganski <[email protected]>
CommitDate: Fri Jan 19 10:56:37 2024 +0100

    Pack group bits in PortionType, and make last 5 bits designate an index
    
    Also mark the items that create some doubt - if they need PORGRP_TOXREF
    bit set; or was that just an accident, when adding elements to the enum
    without knowing that bits have significance. These items were added in:
    
    * Meta:           commit b01573861cdcb32619c7745055e14823b865a12d
      CWS-TOOLING: integrate CWS odfmetadata3 (2009-09-11)
    
    * Bookmark:       commit 4ce8120f1e53f7b81e653b01d141643013bc69ab
      tdf#45589 sw: create and paint text portions for bookmarks (2020-01-30)
    
    * ContentControl: commit 8c632d8a837cc722c6e7b3b400f6d97edf9f9800
      sw content controls: add initial layout support (2022-04-05)
    
    Change-Id: Idc976d0d479020b3d4f88d7143a5ded36b6e1365
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162295
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/sw/source/core/inc/txttypes.hxx b/sw/source/core/inc/txttypes.hxx
index f6db070fa436..551c501d6910 100644
--- a/sw/source/core/inc/txttypes.hxx
+++ b/sw/source/core/inc/txttypes.hxx
@@ -29,25 +29,26 @@ constexpr sal_uInt16 PORGRP_GLUE      = 0x0400;
 constexpr sal_uInt16 PORGRP_FIX       = 0x0200;
 constexpr sal_uInt16 PORGRP_TAB       = 0x0100;
 // Small special groups
-constexpr sal_uInt16 PORGRP_FIXMARG   = 0x0040;
-//#define PORGRP_?  0x0020
-constexpr sal_uInt16 PORGRP_TABNOTLFT = 0x0010;
-constexpr sal_uInt16 PORGRP_TOXREF    = 0x0008;
+constexpr sal_uInt16 PORGRP_FIXMARG   = 0x0080;
+constexpr sal_uInt16 PORGRP_TABNOTLFT = 0x0040;
+constexpr sal_uInt16 PORGRP_TOXREF    = 0x0020;
+
+// five least-significant bits are just a unique index in the group
 
 enum class PortionType
 {
-    NONE        = 0x0000,
-    FlyCnt      = 0x0001,
-
-    Hole        = 0x0080,
-    TempEnd     = 0x0081,
-    Break       = 0x0082,
-    Kern        = 0x0083,
-    Arrow       = 0x0084,
-    Multi       = 0x0085,
-    HiddenText  = 0x0086,
-    ControlChar = 0x0087,
-    Bookmark    = 0x0088,
+    NONE        = 0x00,
+    FlyCnt      = 0x01,
+
+    Hole        = 0x10,
+    TempEnd     = 0x11,
+    Break       = 0x12,
+    Kern        = 0x13,
+    Arrow       = 0x14,
+    Multi       = 0x15,
+    HiddenText  = 0x16,
+    ControlChar = 0x17,
+    Bookmark    = PORGRP_TOXREF | 0x18, // Does it need PORGRP_TOXREF bit?
 
     Text              = PORGRP_TXT | 0x00,
     Lay               = PORGRP_TXT | 0x01,
@@ -57,49 +58,49 @@ enum class PortionType
     FieldMark         = PORGRP_TXT | 0x06,
     FieldFormCheckbox = PORGRP_TXT | 0x07,
 
-    Drop              = PORGRP_TXT | 0x80,
-    Tox               = PORGRP_TXT | PORGRP_TOXREF | 0x81,
-    IsoTox            = PORGRP_TXT | PORGRP_TOXREF | 0x82,
-    Ref               = PORGRP_TXT | PORGRP_TOXREF | 0x83,
-    IsoRef            = PORGRP_TXT | PORGRP_TOXREF | 0x84,
-    Meta              = PORGRP_TXT | PORGRP_TOXREF | 0x85,
-    ContentControl    = PORGRP_TXT | PORGRP_TOXREF | 0x86,
+    Drop              = PORGRP_TXT | 0x10,
+    Tox               = PORGRP_TXT | PORGRP_TOXREF | 0x11,
+    IsoTox            = PORGRP_TXT | PORGRP_TOXREF | 0x12,
+    Ref               = PORGRP_TXT | PORGRP_TOXREF | 0x13,
+    IsoRef            = PORGRP_TXT | PORGRP_TOXREF | 0x14,
+    Meta              = PORGRP_TXT | PORGRP_TOXREF | 0x15, // Does it need 
PORGRP_TOXREF bit?
+    ContentControl    = PORGRP_TXT | PORGRP_TOXREF | 0x16, // Does it need 
PORGRP_TOXREF bit?
 
-    Expand      = PORGRP_TXT | PORGRP_EXP | 0x80,
-    Blank       = PORGRP_TXT | PORGRP_EXP | 0x81,
-    PostIts     = PORGRP_TXT | PORGRP_EXP | 0x82,
+    Expand      = PORGRP_TXT | PORGRP_EXP | 0x10,
+    Blank       = PORGRP_TXT | PORGRP_EXP | 0x11,
+    PostIts     = PORGRP_TXT | PORGRP_EXP | 0x12,
 
-    Hyphen         = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x80,
-    HyphenStr      = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x81,
-    SoftHyphen     = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x82,
-    SoftHyphenStr  = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x83,
-    SoftHyphenComp = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x84,
+    Hyphen         = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x10,
+    HyphenStr      = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x11,
+    SoftHyphen     = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x12,
+    SoftHyphenStr  = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x13,
+    SoftHyphenComp = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x14,
 
-    Field       = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x80,
-    Hidden      = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x81,
-    QuoVadis    = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x82,
-    ErgoSum     = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x83,
-    Combined    = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x84,
-    Footnote    = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x85,
+    Field       = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x10,
+    Hidden      = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x11,
+    QuoVadis    = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x12,
+    ErgoSum     = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x13,
+    Combined    = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x14,
+    Footnote    = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x15,
 
-    FootnoteNum = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | PORGRP_NUMBER | 0x80,
-    Number      = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | PORGRP_NUMBER | 0x81,
-    Bullet      = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | PORGRP_NUMBER | 0x82,
-    GrfNum      = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | PORGRP_NUMBER | 0x83,
+    FootnoteNum = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | PORGRP_NUMBER | 0x10,
+    Number      = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | PORGRP_NUMBER | 0x11,
+    Bullet      = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | PORGRP_NUMBER | 0x12,
+    GrfNum      = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | PORGRP_NUMBER | 0x13,
 
-    Glue        = PORGRP_GLUE | 0x80,
+    Glue        = PORGRP_GLUE | 0x10,
 
-    Margin      = PORGRP_GLUE | PORGRP_FIXMARG | 0x80,
+    Margin      = PORGRP_GLUE | PORGRP_FIXMARG | 0x10,
 
-    Fix         = PORGRP_GLUE | PORGRP_FIX | PORGRP_FIXMARG | 0x80,
-    Fly         = PORGRP_GLUE | PORGRP_FIX | PORGRP_FIXMARG | 0x81,
+    Fix         = PORGRP_GLUE | PORGRP_FIX | PORGRP_FIXMARG | 0x10,
+    Fly         = PORGRP_GLUE | PORGRP_FIX | PORGRP_FIXMARG | 0x11,
 
     // Tabulator, not table
     Tab         = PORGRP_GLUE | PORGRP_FIX | PORGRP_TAB | PORGRP_FIXMARG | 
PORGRP_TABNOTLFT | 0x00,
 
-    TabRight    = PORGRP_GLUE | PORGRP_FIX | PORGRP_TAB | PORGRP_FIXMARG | 
PORGRP_TABNOTLFT | 0x80,
-    TabCenter   = PORGRP_GLUE | PORGRP_FIX | PORGRP_TAB | PORGRP_FIXMARG | 
PORGRP_TABNOTLFT | 0x81,
-    TabDecimal  = PORGRP_GLUE | PORGRP_FIX | PORGRP_TAB | PORGRP_FIXMARG | 
PORGRP_TABNOTLFT | 0x82,
+    TabRight    = PORGRP_GLUE | PORGRP_FIX | PORGRP_TAB | PORGRP_FIXMARG | 
PORGRP_TABNOTLFT | 0x10,
+    TabCenter   = PORGRP_GLUE | PORGRP_FIX | PORGRP_TAB | PORGRP_FIXMARG | 
PORGRP_TABNOTLFT | 0x11,
+    TabDecimal  = PORGRP_GLUE | PORGRP_FIX | PORGRP_TAB | PORGRP_FIXMARG | 
PORGRP_TABNOTLFT | 0x12,
 
     TabLeft     = PORGRP_GLUE | PORGRP_FIX | PORGRP_TAB | PORGRP_FIXMARG | 
0x00,
 };
commit 15ecd3b12b912d7e39e6b8054c12fc9f99a2b670
Author:     Mike Kaganski <[email protected]>
AuthorDate: Fri Jan 19 12:16:03 2024 +0600
Commit:     Mike Kaganski <[email protected]>
CommitDate: Fri Jan 19 10:56:29 2024 +0100

    Move bit definitions close to PortionType
    
    And make PortionType elements defined using those definitions.
    
    Change-Id: I45c2de4d965b43b84699d97f810661bea01825b8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162290
    Tested-by: Mike Kaganski <[email protected]>
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/sw/source/core/inc/txttypes.hxx b/sw/source/core/inc/txttypes.hxx
index 6b3124fb8bc6..f6db070fa436 100644
--- a/sw/source/core/inc/txttypes.hxx
+++ b/sw/source/core/inc/txttypes.hxx
@@ -19,7 +19,21 @@
 
 #pragma once
 
-/// @see PORGRP_* masks in porlin.hxx for meaning of bits!
+/// Portion groups
+constexpr sal_uInt16 PORGRP_TXT       = 0x8000;
+constexpr sal_uInt16 PORGRP_EXP       = 0x4000;
+constexpr sal_uInt16 PORGRP_FLD       = 0x2000;
+constexpr sal_uInt16 PORGRP_HYPH      = 0x1000;
+constexpr sal_uInt16 PORGRP_NUMBER    = 0x0800;
+constexpr sal_uInt16 PORGRP_GLUE      = 0x0400;
+constexpr sal_uInt16 PORGRP_FIX       = 0x0200;
+constexpr sal_uInt16 PORGRP_TAB       = 0x0100;
+// Small special groups
+constexpr sal_uInt16 PORGRP_FIXMARG   = 0x0040;
+//#define PORGRP_?  0x0020
+constexpr sal_uInt16 PORGRP_TABNOTLFT = 0x0010;
+constexpr sal_uInt16 PORGRP_TOXREF    = 0x0008;
+
 enum class PortionType
 {
     NONE        = 0x0000,
@@ -35,59 +49,59 @@ enum class PortionType
     ControlChar = 0x0087,
     Bookmark    = 0x0088,
 
-    Text        = 0x8000,
-    Lay         = 0x8001,
-    Para        = 0x8002,
-    Hanging     = 0x8004,
-    InputField  = 0x8005,
-    FieldMark   = 0x8006,
-    FieldFormCheckbox = 0x8007,
-
-    Drop        = 0x8080,
-    Tox         = 0x8089,
-    IsoTox      = 0x808a,
-    Ref         = 0x808b,
-    IsoRef      = 0x808c,
-    Meta        = 0x808d,
-    ContentControl = 0x808e,
-
-    Expand      = 0xc080,
-    Blank       = 0xc081,
-    PostIts     = 0xc082,
-
-    Hyphen         = 0xd080,
-    HyphenStr      = 0xd081,
-    SoftHyphen     = 0xd082,
-    SoftHyphenStr  = 0xd083,
-    SoftHyphenComp = 0xd084,
-
-    Field       = 0xe080,
-    Hidden      = 0xe081,
-    QuoVadis    = 0xe082,
-    ErgoSum     = 0xe083,
-    Combined    = 0xe084,
-    Footnote    = 0xe085,
-
-    FootnoteNum = 0xe880,
-    Number      = 0xe881,
-    Bullet      = 0xe882,
-    GrfNum      = 0xe883,
-
-    Glue        = 0x0480,
-
-    Margin      = 0x04c0,
-
-    Fix         = 0x06c0,
-    Fly         = 0x06c1,
+    Text              = PORGRP_TXT | 0x00,
+    Lay               = PORGRP_TXT | 0x01,
+    Para              = PORGRP_TXT | 0x02,
+    Hanging           = PORGRP_TXT | 0x04,
+    InputField        = PORGRP_TXT | 0x05,
+    FieldMark         = PORGRP_TXT | 0x06,
+    FieldFormCheckbox = PORGRP_TXT | 0x07,
+
+    Drop              = PORGRP_TXT | 0x80,
+    Tox               = PORGRP_TXT | PORGRP_TOXREF | 0x81,
+    IsoTox            = PORGRP_TXT | PORGRP_TOXREF | 0x82,
+    Ref               = PORGRP_TXT | PORGRP_TOXREF | 0x83,
+    IsoRef            = PORGRP_TXT | PORGRP_TOXREF | 0x84,
+    Meta              = PORGRP_TXT | PORGRP_TOXREF | 0x85,
+    ContentControl    = PORGRP_TXT | PORGRP_TOXREF | 0x86,
+
+    Expand      = PORGRP_TXT | PORGRP_EXP | 0x80,
+    Blank       = PORGRP_TXT | PORGRP_EXP | 0x81,
+    PostIts     = PORGRP_TXT | PORGRP_EXP | 0x82,
+
+    Hyphen         = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x80,
+    HyphenStr      = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x81,
+    SoftHyphen     = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x82,
+    SoftHyphenStr  = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x83,
+    SoftHyphenComp = PORGRP_TXT | PORGRP_EXP | PORGRP_HYPH | 0x84,
+
+    Field       = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x80,
+    Hidden      = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x81,
+    QuoVadis    = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x82,
+    ErgoSum     = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x83,
+    Combined    = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x84,
+    Footnote    = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | 0x85,
+
+    FootnoteNum = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | PORGRP_NUMBER | 0x80,
+    Number      = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | PORGRP_NUMBER | 0x81,
+    Bullet      = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | PORGRP_NUMBER | 0x82,
+    GrfNum      = PORGRP_TXT | PORGRP_EXP | PORGRP_FLD | PORGRP_NUMBER | 0x83,
+
+    Glue        = PORGRP_GLUE | 0x80,
+
+    Margin      = PORGRP_GLUE | PORGRP_FIXMARG | 0x80,
+
+    Fix         = PORGRP_GLUE | PORGRP_FIX | PORGRP_FIXMARG | 0x80,
+    Fly         = PORGRP_GLUE | PORGRP_FIX | PORGRP_FIXMARG | 0x81,
 
     // Tabulator, not table
-    Tab         = 0x0750,
+    Tab         = PORGRP_GLUE | PORGRP_FIX | PORGRP_TAB | PORGRP_FIXMARG | 
PORGRP_TABNOTLFT | 0x00,
 
-    TabRight    = 0x07d0,
-    TabCenter   = 0x07d1,
-    TabDecimal  = 0x07d2,
+    TabRight    = PORGRP_GLUE | PORGRP_FIX | PORGRP_TAB | PORGRP_FIXMARG | 
PORGRP_TABNOTLFT | 0x80,
+    TabCenter   = PORGRP_GLUE | PORGRP_FIX | PORGRP_TAB | PORGRP_FIXMARG | 
PORGRP_TABNOTLFT | 0x81,
+    TabDecimal  = PORGRP_GLUE | PORGRP_FIX | PORGRP_TAB | PORGRP_FIXMARG | 
PORGRP_TABNOTLFT | 0x82,
 
-    TabLeft     = 0x0740,
+    TabLeft     = PORGRP_GLUE | PORGRP_FIX | PORGRP_TAB | PORGRP_FIXMARG | 
0x00,
 };
 
 namespace sw
diff --git a/sw/source/core/text/porlin.hxx b/sw/source/core/text/porlin.hxx
index 50ee3ed159c1..d2298bdfb03c 100644
--- a/sw/source/core/text/porlin.hxx
+++ b/sw/source/core/text/porlin.hxx
@@ -30,22 +30,6 @@ class SwTextPaintInfo;
 class SwTextFormatInfo;
 class SwPortionHandler;
 
-/// Portion groups
-/// @see enum PortionType in txttypes.hxx
-#define PORGRP_TXT      0x8000
-#define PORGRP_EXP      0x4000
-#define PORGRP_FLD      0x2000
-#define PORGRP_HYPH     0x1000
-#define PORGRP_NUMBER   0x0800
-#define PORGRP_GLUE     0x0400
-#define PORGRP_FIX      0x0200
-#define PORGRP_TAB      0x0100
-// Small special groups
-#define PORGRP_FIXMARG  0x0040
-//#define PORGRP_?  0x0020
-#define PORGRP_TABNOTLFT 0x0010
-#define PORGRP_TOXREF   0x0008
-
 /// Base class for anything that can be part of a line in the Writer layout.
 /// Typically owned by SwLineLayout.
 class SAL_DLLPUBLIC_RTTI SwLinePortion: public SwPosSize
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index a14c5a485109..86d736a0c8b9 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -152,9 +152,8 @@ const char* sw::PortionTypeToString(PortionType nType)
 
         case PortionType::TabLeft:
             return "PortionType::TabLeft";
-        default:
-            return "Unknown";
     }
+    return "Unknown";
 }
 
 void SwFrame::dumpTopMostAsXml(xmlTextWriterPtr writer) const

Reply via email to