sw/source/writerfilter/rtftok/rtfdispatchsymbol.cxx |    6 +--
 sw/source/writerfilter/rtftok/rtfdispatchvalue.cxx  |    9 ++--
 sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx   |   40 ++++++++++----------
 sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx   |    5 +-
 sw/source/writerfilter/rtftok/rtfsdrimport.cxx      |    2 -
 sw/source/writerfilter/rtftok/rtfsprm.cxx           |   12 +++---
 sw/source/writerfilter/rtftok/rtfsprm.hxx           |   12 +++---
 7 files changed, 45 insertions(+), 41 deletions(-)

New commits:
commit ea329851db40d1b3530f9b9227e2cb59299b6fe2
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Jun 22 14:00:33 2025 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sun Jun 22 12:25:11 2025 +0200

    Rename RTFOverwrite enum and its elements
    
    The previous naming was confusing to me. E.g., the "NO_APPEND" looked
    as if "there should be no append", when in fact, it was the opposite.
    
    The new scheme is positive in all actions, hopefully less confusing.
    
    Change-Id: I97129de94bc0cad66abda0a23304ee2e2aad507c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186791
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/source/writerfilter/rtftok/rtfdispatchsymbol.cxx 
b/sw/source/writerfilter/rtftok/rtfdispatchsymbol.cxx
index 4b2e785b2e7a..9a3ca31c127a 100644
--- a/sw/source/writerfilter/rtftok/rtfdispatchsymbol.cxx
+++ b/sw/source/writerfilter/rtftok/rtfdispatchsymbol.cxx
@@ -255,7 +255,7 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword 
nKeyword)
                 // OOXMLFastContextHandlerTextTableRow::handleGridAfter().
                 auto pXValue = new 
RTFValue(m_aStates.top().getTableRowWidthAfter());
                 
m_aStates.top().getTableRowSprms().set(NS_ooxml::LN_CT_TblGridBase_gridCol, 
pXValue,
-                                                       
RTFOverwrite::NO_APPEND);
+                                                       
RTFConflictPolicy::Append);
                 dispatchSymbol(RTFKeyword::CELL);
                 // Adjust total width, which is done in the                  
m_nTopLevelCurrentCellX += m_aStates.top().getTableRowWidthAfter();
@@ -288,7 +288,7 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword 
nKeyword)
                         auto pTypeValue = new 
RTFValue(NS_ooxml::LN_Value_ST_Border_none);
                         auto pSizeValue = new RTFValue(0);
                         putNestedSprm(rCurrentCellSprms, 
NS_ooxml::LN_CT_TcPrBase_tcBorders,
-                                      aBorderIds[i], pBorderValue, 
RTFOverwrite::YES);
+                                      aBorderIds[i], pBorderValue, 
RTFConflictPolicy::Overwrite);
                         RTFSprms* pAttributes = &getLastAttributes(
                             rCurrentCellSprms, 
NS_ooxml::LN_CT_TcPrBase_tcBorders);
                         if (pAttributes)
@@ -359,7 +359,7 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword 
nKeyword)
                 auto pXValue = new RTFValue(nXValueLast + m_nCellxMax - 
m_nTopLevelCurrentCellX);
                 
m_aStates.top().getTableRowSprms().eraseLast(NS_ooxml::LN_CT_TblGridBase_gridCol);
                 
m_aStates.top().getTableRowSprms().set(NS_ooxml::LN_CT_TblGridBase_gridCol, 
pXValue,
-                                                       
RTFOverwrite::NO_APPEND);
+                                                       
RTFConflictPolicy::Append);
                 m_nTopLevelCurrentCellX = m_nCellxMax;
             }
 
diff --git a/sw/source/writerfilter/rtftok/rtfdispatchvalue.cxx 
b/sw/source/writerfilter/rtftok/rtfdispatchvalue.cxx
index a5999fbcde25..3ec8542e644f 100644
--- a/sw/source/writerfilter/rtftok/rtfdispatchvalue.cxx
+++ b/sw/source/writerfilter/rtftok/rtfdispatchvalue.cxx
@@ -429,7 +429,7 @@ bool RTFDocumentImpl::dispatchTableValue(RTFKeyword 
nKeyword, int nParam)
             rCurrentCellX = nParam;
             auto pXValue = new RTFValue(nCellX);
             
m_aStates.top().getTableRowSprms().set(NS_ooxml::LN_CT_TblGridBase_gridCol, 
pXValue,
-                                                   RTFOverwrite::NO_APPEND);
+                                                   RTFConflictPolicy::Append);
             if (Destination::NESTEDTABLEPROPERTIES == 
m_aStates.top().getDestination())
             {
                 m_nNestedCells++;
@@ -846,7 +846,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword 
nKeyword, int nParam)
                 aRunPropsSprms.set(NS_ooxml::LN_EG_RPrBase_rFonts, new 
RTFValue(aFontAttributes));
                 m_aStates.top().getTableSprms().set(NS_ooxml::LN_CT_Lvl_rPr,
                                                     new RTFValue(RTFSprms(), 
aRunPropsSprms),
-                                                    RTFOverwrite::NO_APPEND);
+                                                    RTFConflictPolicy::Append);
             }
             else
             {
@@ -1168,7 +1168,8 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword 
nKeyword, int nParam)
                 // case when old-style paragraph numbering is already
                 // tokenized.
                 putNestedSprm(m_aStates.top().getParagraphSprms(), 
NS_ooxml::LN_CT_PPrBase_numPr,
-                              NS_ooxml::LN_CT_NumPr_numId, pIntValue, 
RTFOverwrite::YES_PREPEND);
+                              NS_ooxml::LN_CT_NumPr_numId, pIntValue,
+                              RTFConflictPolicy::ReplaceAtStart);
             }
         }
         break;
@@ -1753,7 +1754,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword 
nKeyword, int nParam)
             // So set the direct formatting to zero, if we don't have such 
direct formatting yet.
             putNestedAttribute(m_aStates.top().getParagraphSprms(), 
NS_ooxml::LN_CT_PPrBase_ind,
                                NS_ooxml::LN_CT_Ind_firstLine, new RTFValue(0),
-                               RTFOverwrite::NO_IGNORE);
+                               RTFConflictPolicy::Ignore);
         }
         break;
         case RTFKeyword::RI:
diff --git a/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx 
b/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx
index 6a2477036778..ba3b85c390ef 100644
--- a/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx
+++ b/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx
@@ -97,7 +97,7 @@ Id getParagraphBorder(sal_uInt32 nIndex)
 }
 
 void putNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId, const 
RTFValue::Pointer_t& pValue,
-                        RTFOverwrite eOverwrite, bool bAttribute)
+                        RTFConflictPolicy ePolicy, bool bAttribute)
 {
     RTFValue::Pointer_t pParent = rSprms.find(nParent, /*bFirst=*/true, 
/*bForWrite=*/true);
     if (!pParent)
@@ -110,17 +110,17 @@ void putNestedAttribute(RTFSprms& rSprms, Id nParent, Id 
nId, const RTFValue::Po
             aAttributes.set(NS_ooxml::LN_CT_Shd_fill, new 
RTFValue(sal_uInt32(COL_AUTO)));
         }
         auto pParentValue = new RTFValue(aAttributes);
-        rSprms.set(nParent, pParentValue, eOverwrite);
+        rSprms.set(nParent, pParentValue, ePolicy);
         pParent = pParentValue;
     }
     RTFSprms& rAttributes = (bAttribute ? pParent->getAttributes() : 
pParent->getSprms());
-    rAttributes.set(nId, pValue, eOverwrite);
+    rAttributes.set(nId, pValue, ePolicy);
 }
 
 void putNestedSprm(RTFSprms& rSprms, Id nParent, Id nId, const 
RTFValue::Pointer_t& pValue,
-                   RTFOverwrite eOverwrite)
+                   RTFConflictPolicy ePolicy)
 {
-    putNestedAttribute(rSprms, nParent, nId, pValue, eOverwrite, false);
+    putNestedAttribute(rSprms, nParent, nId, pValue, ePolicy, false);
 }
 
 RTFValue::Pointer_t getNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId)
@@ -205,7 +205,7 @@ void putBorderProperty(RTFStack& aStates, Id nId, const 
RTFValue::Pointer_t& pVa
             aAttributes.set(NS_ooxml::LN_CT_Border_val,
                             new RTFValue(NS_ooxml::LN_Value_ST_Border_none));
             putNestedSprm(aStates.top().getParagraphSprms(), 
NS_ooxml::LN_CT_PrBase_pBdr, nBorder,
-                          new RTFValue(aAttributes, aSprms), 
RTFOverwrite::YES);
+                          new RTFValue(aAttributes, aSprms), 
RTFConflictPolicy::Overwrite);
         }
     }
 
@@ -1920,7 +1920,7 @@ void RTFDocumentImpl::resetTableRowProperties()
 {
     m_aStates.top().getTableRowSprms() = m_aDefaultState.getTableRowSprms();
     
m_aStates.top().getTableRowSprms().set(NS_ooxml::LN_CT_TblGridBase_gridCol, new 
RTFValue(-1),
-                                           RTFOverwrite::NO_APPEND);
+                                           RTFConflictPolicy::Append);
     m_aStates.top().getTableRowAttributes() = 
m_aDefaultState.getTableRowAttributes();
     if (Destination::NESTEDTABLEPROPERTIES == m_aStates.top().getDestination())
     {
@@ -2404,7 +2404,7 @@ RTFError RTFDocumentImpl::beforePopState(RTFParserState& 
rState)
         case Destination::LISTENTRY:
             for (const auto& rListLevelEntry : rState.getListLevelEntries())
                 rState.getTableSprms().set(rListLevelEntry.first, 
rListLevelEntry.second,
-                                           RTFOverwrite::NO_APPEND);
+                                           RTFConflictPolicy::Append);
             break;
         case Destination::FIELDINSTRUCTION:
         {
@@ -2681,7 +2681,7 @@ RTFError RTFDocumentImpl::beforePopState(RTFParserState& 
rState)
                 = new 
RTFValue(m_aStates.top().getCurrentDestinationText()->makeStringAndClear());
             // OOXML puts these into a LN_CT_FFData_ddList but FFDataHandler 
should handle this too
             m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFDDList_listEntry, pValue,
-                                  RTFOverwrite::NO_APPEND);
+                                  RTFConflictPolicy::Append);
         }
         break;
         case Destination::DATAFIELD:
@@ -3392,7 +3392,7 @@ void RTFDocumentImpl::afterPopState(RTFParserState& 
rState)
         {
             auto pValue = new RTFValue(rState.getTableAttributes(), 
rState.getTableSprms());
             m_aListTableSprms.set(NS_ooxml::LN_CT_Numbering_abstractNum, 
pValue,
-                                  RTFOverwrite::NO_APPEND);
+                                  RTFConflictPolicy::Append);
             m_aListTable[rState.getCurrentListIndex()] = pValue;
             m_nListLevel = -1;
             m_aInvalidListTableFirstIndents[rState.getCurrentListIndex()]
@@ -3448,13 +3448,13 @@ void RTFDocumentImpl::afterPopState(RTFParserState& 
rState)
                 
aAbstractAttributes.set(NS_ooxml::LN_CT_AbstractNum_abstractNumId, pIdValue);
                 auto pLevelValue = new RTFValue(aLevelAttributes, aLevelSprms);
                 aAbstractSprms.set(NS_ooxml::LN_CT_AbstractNum_lvl, 
pLevelValue,
-                                   RTFOverwrite::NO_APPEND);
+                                   RTFConflictPolicy::Append);
 
                 RTFSprms aListTableSprms;
                 auto pAbstractValue = new RTFValue(aAbstractAttributes, 
aAbstractSprms);
                 // It's important that Numbering_abstractNum and Numbering_num 
never overwrites previous values.
                 aListTableSprms.set(NS_ooxml::LN_CT_Numbering_abstractNum, 
pAbstractValue,
-                                    RTFOverwrite::NO_APPEND);
+                                    RTFConflictPolicy::Append);
 
                 // Numbering
                 RTFSprms aNumberingAttributes;
@@ -3463,7 +3463,7 @@ void RTFDocumentImpl::afterPopState(RTFParserState& 
rState)
                 aNumberingSprms.set(NS_ooxml::LN_CT_Num_abstractNumId, 
pIdValue);
                 auto pNumberingValue = new RTFValue(aNumberingAttributes, 
aNumberingSprms);
                 aListTableSprms.set(NS_ooxml::LN_CT_Numbering_num, 
pNumberingValue,
-                                    RTFOverwrite::NO_APPEND);
+                                    RTFConflictPolicy::Append);
 
                 // Table
                 RTFSprms aListTableAttributes;
@@ -3478,9 +3478,11 @@ void RTFDocumentImpl::afterPopState(RTFParserState& 
rState)
 
                 // Use it
                 putNestedSprm(m_aStates.top().getParagraphSprms(), 
NS_ooxml::LN_CT_PPrBase_numPr,
-                              NS_ooxml::LN_CT_NumPr_ilvl, pIlvlValue, 
RTFOverwrite::YES_PREPEND);
+                              NS_ooxml::LN_CT_NumPr_ilvl, pIlvlValue,
+                              RTFConflictPolicy::ReplaceAtStart);
                 putNestedSprm(m_aStates.top().getParagraphSprms(), 
NS_ooxml::LN_CT_PPrBase_numPr,
-                              NS_ooxml::LN_CT_NumPr_numId, pIdValue, 
RTFOverwrite::YES_PREPEND);
+                              NS_ooxml::LN_CT_NumPr_numId, pIdValue,
+                              RTFConflictPolicy::ReplaceAtStart);
             }
         }
         break;
@@ -3511,7 +3513,7 @@ void RTFDocumentImpl::afterPopState(RTFParserState& 
rState)
                 auto pValue = new RTFValue(rState.getTableAttributes(), 
rState.getTableSprms());
                 if (m_aStates.top().getDestination() != Destination::LFOLEVEL)
                     
m_aStates.top().getListLevelEntries().set(NS_ooxml::LN_CT_AbstractNum_lvl,
-                                                              pValue, 
RTFOverwrite::NO_APPEND);
+                                                              pValue, 
RTFConflictPolicy::Append);
                 else
                     
m_aStates.top().getTableSprms().set(NS_ooxml::LN_CT_NumLvl_lvl, pValue);
             }
@@ -3524,7 +3526,7 @@ void RTFDocumentImpl::afterPopState(RTFParserState& 
rState)
 
                 auto pValue = new RTFValue(rState.getTableAttributes(), 
rState.getTableSprms());
                 
m_aStates.top().getTableSprms().set(NS_ooxml::LN_CT_Num_lvlOverride, pValue,
-                                                    RTFOverwrite::NO_APPEND);
+                                                    RTFConflictPolicy::Append);
             }
             break;
         // list override table
@@ -3541,7 +3543,7 @@ void RTFDocumentImpl::afterPopState(RTFParserState& 
rState)
                 {
                     auto pValue = new RTFValue(rState.getTableAttributes(), 
rState.getTableSprms());
                     m_aListTableSprms.set(NS_ooxml::LN_CT_Numbering_num, 
pValue,
-                                          RTFOverwrite::NO_APPEND);
+                                          RTFConflictPolicy::Append);
                     m_aListOverrideTable[rState.getCurrentListOverrideIndex()]
                         = rState.getCurrentListIndex();
                 }
@@ -3653,7 +3655,7 @@ void RTFDocumentImpl::afterPopState(RTFParserState& 
rState)
                     aSprms.set(NS_ooxml::LN_CT_NumPicBullet_pict, new 
RTFValue(0));
                     auto pValue = new RTFValue(aAttributes, aSprms);
                     
m_aListTableSprms.set(NS_ooxml::LN_CT_Numbering_numPicBullet, pValue,
-                                          RTFOverwrite::NO_APPEND);
+                                          RTFConflictPolicy::Append);
                 }
             }
             break;
diff --git a/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx 
b/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx
index fe0a960c8fb0..e3aa4c5ba558 100644
--- a/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx
+++ b/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx
@@ -665,10 +665,11 @@ public:
 
 void putBorderProperty(RTFStack& aStates, Id nId, const RTFValue::Pointer_t& 
pValue);
 void putNestedSprm(RTFSprms& rSprms, Id nParent, Id nId, const 
RTFValue::Pointer_t& pValue,
-                   RTFOverwrite eOverwrite = RTFOverwrite::NO_APPEND);
+                   RTFConflictPolicy ePolicy = RTFConflictPolicy::Append);
 Id getParagraphBorder(sal_uInt32 nIndex);
 void putNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId, const 
RTFValue::Pointer_t& pValue,
-                        RTFOverwrite eOverwrite = RTFOverwrite::YES, bool 
bAttribute = true);
+                        RTFConflictPolicy ePolicy = 
RTFConflictPolicy::Overwrite,
+                        bool bAttribute = true);
 bool eraseNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId);
 
 /// Looks up the nParent then the nested nId attribute in rSprms.
diff --git a/sw/source/writerfilter/rtftok/rtfsdrimport.cxx 
b/sw/source/writerfilter/rtftok/rtfsdrimport.cxx
index 09aabf47fd1c..bef7a6ade9d2 100644
--- a/sw/source/writerfilter/rtftok/rtfsdrimport.cxx
+++ b/sw/source/writerfilter/rtftok/rtfsdrimport.cxx
@@ -859,7 +859,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, 
ShapeOrPict const shap
                     aPathAttributes.set(NS_ooxml::LN_CT_Point2D_x, new 
RTFValue(nX));
                     aPathAttributes.set(NS_ooxml::LN_CT_Point2D_y, new 
RTFValue(nY));
                     aPolygonSprms.set(NS_ooxml::LN_CT_WrapPath_lineTo,
-                                      new RTFValue(aPathAttributes), 
RTFOverwrite::NO_APPEND);
+                                      new RTFValue(aPathAttributes), 
RTFConflictPolicy::Append);
                 }
             } while (nCharIndex >= 0);
             rShape.getWrapPolygonSprms() = std::move(aPolygonSprms);
diff --git a/sw/source/writerfilter/rtftok/rtfsprm.cxx 
b/sw/source/writerfilter/rtftok/rtfsprm.cxx
index f61ffb957240..8549d54e41e3 100644
--- a/sw/source/writerfilter/rtftok/rtfsprm.cxx
+++ b/sw/source/writerfilter/rtftok/rtfsprm.cxx
@@ -93,19 +93,19 @@ RTFValue::Pointer_t RTFSprms::find(Id nKeyword, bool 
bFirst, bool bForWrite)
     return RTFValue::Pointer_t{};
 }
 
-void RTFSprms::set(Id nKeyword, const RTFValue::Pointer_t& pValue, 
RTFOverwrite eOverwrite)
+void RTFSprms::set(Id nKeyword, const RTFValue::Pointer_t& pValue, 
RTFConflictPolicy ePolicy)
 {
     ensureCopyBeforeWrite();
 
-    switch (eOverwrite)
+    switch (ePolicy)
     {
-        case RTFOverwrite::YES_PREPEND:
+        case RTFConflictPolicy::ReplaceAtStart:
         {
             std::erase_if(*m_pSprms, RTFSprms_compare{ nKeyword });
             m_pSprms->emplace(m_pSprms->cbegin(), nKeyword, pValue);
             break;
         }
-        case RTFOverwrite::YES:
+        case RTFConflictPolicy::Overwrite:
         {
             auto it
                 = std::find_if(m_pSprms->begin(), m_pSprms->end(), 
RTFSprms_compare{ nKeyword });
@@ -115,13 +115,13 @@ void RTFSprms::set(Id nKeyword, const 
RTFValue::Pointer_t& pValue, RTFOverwrite
                 m_pSprms->emplace_back(nKeyword, pValue);
             break;
         }
-        case RTFOverwrite::NO_IGNORE:
+        case RTFConflictPolicy::Ignore:
         {
             if (std::none_of(m_pSprms->cbegin(), m_pSprms->cend(), 
RTFSprms_compare{ nKeyword }))
                 m_pSprms->emplace_back(nKeyword, pValue);
             break;
         }
-        case RTFOverwrite::NO_APPEND:
+        case RTFConflictPolicy::Append:
         {
             m_pSprms->emplace_back(nKeyword, pValue);
             break;
diff --git a/sw/source/writerfilter/rtftok/rtfsprm.hxx 
b/sw/source/writerfilter/rtftok/rtfsprm.hxx
index c493fd6e3d4a..275048b4abc1 100644
--- a/sw/source/writerfilter/rtftok/rtfsprm.hxx
+++ b/sw/source/writerfilter/rtftok/rtfsprm.hxx
@@ -26,12 +26,12 @@ class RTFSprmsImpl : public RTFSprmsImplBase, public 
virtual SvRefBase
 {
 };
 
-enum class RTFOverwrite
+enum class RTFConflictPolicy
 {
-    YES, ///< Yes, if an existing key is found, overwrite it.
-    NO_APPEND, ///< No, always append the value to the end of the list.
-    NO_IGNORE, ///< No, if the key is already in the list, then ignore, 
otherwise append.
-    YES_PREPEND ///< Yes, always prepend the value to the start of the list 
and remove existing entries.
+    Overwrite, ///< If an existing key is found, overwrite it in place.
+    Append, ///< Always append the value to the end of the list.
+    Ignore, ///< If the key is already in the list, then ignore, otherwise 
append.
+    ReplaceAtStart, ///< Always prepend the value to the start of the list and 
remove existing entries.
 };
 
 /// A list of RTFSprm with a copy constructor that performs a deep copy.
@@ -53,7 +53,7 @@ public:
     RTFValue::Pointer_t find(Id nKeyword, bool bFirst = true, bool bForWrite = 
false);
     /// Does the same as ->push_back(), except that it can overwrite or ignore 
existing entries.
     void set(Id nKeyword, const RTFValue::Pointer_t& pValue,
-             RTFOverwrite eOverwrite = RTFOverwrite::YES);
+             RTFConflictPolicy ePolicy = RTFConflictPolicy::Overwrite);
     bool erase(Id nKeyword);
     void eraseLast(Id nKeyword);
     /// Removes elements which are already in the reference set.

Reply via email to