[Libreoffice-commits] core.git: writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 30 08:06:38 UTC 2019


 writerfilter/source/rtftok/rtfcontrolwords.cxx |    2 -
 writerfilter/source/rtftok/rtfcontrolwords.hxx |   29 ++++++++++++++++++++-----
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |    4 +--
 writerfilter/source/rtftok/rtftokenizer.cxx    |   17 ++++++--------
 4 files changed, 35 insertions(+), 17 deletions(-)

New commits:
commit a16372dba916d3179a70434e4d26af13c2f1b540
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Jan 29 21:18:17 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jan 30 09:06:12 2019 +0100

    writerfilter: make members private in RTFSymbol
    
    Change-Id: I8f608908689d9ebe2027bc36bf71b8cf84a016dc
    Reviewed-on: https://gerrit.libreoffice.org/67095
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/writerfilter/source/rtftok/rtfcontrolwords.cxx b/writerfilter/source/rtftok/rtfcontrolwords.cxx
index 684cedeb5637..0f958577cfe3 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.cxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.cxx
@@ -1845,7 +1845,7 @@ int nRTFControlWords = SAL_N_ELEMENTS(aRTFControlWords);
 
 bool RTFSymbol::operator<(const RTFSymbol& rOther) const
 {
-    return std::strcmp(sKeyword, rOther.sKeyword) < 0;
+    return std::strcmp(m_sKeyword, rOther.m_sKeyword) < 0;
 }
 
 RTFMathSymbol const aRTFMathControlWords[] = {
diff --git a/writerfilter/source/rtftok/rtfcontrolwords.hxx b/writerfilter/source/rtftok/rtfcontrolwords.hxx
index e638d9a9a359..c9ba4bbbafab 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.hxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.hxx
@@ -1990,13 +1990,32 @@ enum RTFControlTypes
 };
 
 /// Represents an RTF Control Word
-struct RTFSymbol
+class RTFSymbol
 {
-    const char* sKeyword;
-    int nControlType;
-    RTFKeyword nIndex;
+    const char* m_sKeyword;
+    int m_nControlType;
+    RTFKeyword m_nIndex;
 
-    int nDefValue; //For most of the ControlWords, default is 0.
+    int m_nDefValue; ///< Most of the control words default to 0.
+
+public:
+    RTFSymbol() = default;
+    RTFSymbol(const char* sKeyword, int nControlType = 0, RTFKeyword nIndex = RTF_invalid,
+              int nDefValue = 0)
+        : m_sKeyword(sKeyword)
+        , m_nControlType(nControlType)
+        , m_nIndex(nIndex)
+        , m_nDefValue(nDefValue)
+    {
+    }
+
+    const char* GetKeyword() const { return m_sKeyword; }
+
+    int GetControlType() const { return m_nControlType; }
+
+    RTFKeyword GetIndex() const { return m_nIndex; }
+
+    int GetDefValue() const { return m_nDefValue; }
 
     bool operator<(const RTFSymbol& rOther) const;
 };
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 41b638b5acc4..5926db0dccf6 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -209,8 +209,8 @@ const char* keywordToString(RTFKeyword nKeyword)
 {
     for (int i = 0; i < nRTFControlWords; i++)
     {
-        if (nKeyword == aRTFControlWords[i].nIndex)
-            return aRTFControlWords[i].sKeyword;
+        if (nKeyword == aRTFControlWords[i].GetIndex())
+            return aRTFControlWords[i].GetKeyword();
     }
     return nullptr;
 }
diff --git a/writerfilter/source/rtftok/rtftokenizer.cxx b/writerfilter/source/rtftok/rtftokenizer.cxx
index 310adc82db23..cccf47ef5978 100644
--- a/writerfilter/source/rtftok/rtftokenizer.cxx
+++ b/writerfilter/source/rtftok/rtftokenizer.cxx
@@ -270,8 +270,7 @@ RTFError RTFTokenizer::dispatchKeyword(OString const& rKeyword, bool bParam, int
     SAL_INFO("writerfilter.rtf", OSL_THIS_FUNC << ": keyword '\\" << rKeyword << "' with param? "
                                                << (bParam ? 1 : 0) << " param val: '"
                                                << (bParam ? nParam : 0) << "'");
-    RTFSymbol aSymbol;
-    aSymbol.sKeyword = rKeyword.getStr();
+    RTFSymbol aSymbol(rKeyword.getStr());
     auto low = std::lower_bound(s_aRTFControlWords.begin(), s_aRTFControlWords.end(), aSymbol);
     int i = low - s_aRTFControlWords.begin();
     if (low == s_aRTFControlWords.end() || aSymbol < *low)
@@ -283,35 +282,35 @@ RTFError RTFTokenizer::dispatchKeyword(OString const& rKeyword, bool bParam, int
     }
 
     RTFError ret;
-    switch (s_aRTFControlWords[i].nControlType)
+    switch (s_aRTFControlWords[i].GetControlType())
     {
         case CONTROL_FLAG:
             // flags ignore any parameter by definition
-            ret = m_rImport.dispatchFlag(s_aRTFControlWords[i].nIndex);
+            ret = m_rImport.dispatchFlag(s_aRTFControlWords[i].GetIndex());
             if (ret != RTFError::OK)
                 return ret;
             break;
         case CONTROL_DESTINATION:
             // same for destinations
-            ret = m_rImport.dispatchDestination(s_aRTFControlWords[i].nIndex);
+            ret = m_rImport.dispatchDestination(s_aRTFControlWords[i].GetIndex());
             if (ret != RTFError::OK)
                 return ret;
             break;
         case CONTROL_SYMBOL:
             // and symbols
-            ret = m_rImport.dispatchSymbol(s_aRTFControlWords[i].nIndex);
+            ret = m_rImport.dispatchSymbol(s_aRTFControlWords[i].GetIndex());
             if (ret != RTFError::OK)
                 return ret;
             break;
         case CONTROL_TOGGLE:
-            ret = m_rImport.dispatchToggle(s_aRTFControlWords[i].nIndex, bParam, nParam);
+            ret = m_rImport.dispatchToggle(s_aRTFControlWords[i].GetIndex(), bParam, nParam);
             if (ret != RTFError::OK)
                 return ret;
             break;
         case CONTROL_VALUE:
             if (!bParam)
-                nParam = s_aRTFControlWords[i].nDefValue;
-            ret = m_rImport.dispatchValue(s_aRTFControlWords[i].nIndex, nParam);
+                nParam = s_aRTFControlWords[i].GetDefValue();
+            ret = m_rImport.dispatchValue(s_aRTFControlWords[i].GetIndex(), nParam);
             if (ret != RTFError::OK)
                 return ret;
             break;


More information about the Libreoffice-commits mailing list