sw/source/filter/ww8/ww8scan.cxx |  116 +++++++++++++++++++--------------------
 sw/source/filter/ww8/ww8scan.hxx |   72 ++++++++++++------------
 2 files changed, 94 insertions(+), 94 deletions(-)

New commits:
commit 6624721b3226ace33f5032b1c1ce595c19f1915c
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Mon Mar 28 08:34:26 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Mar 28 10:20:20 2022 +0200

    sw: WW8PLCFpcd, WW8PLCFpcd_Iter, WW8PLCFspecial and WW8PLCFx
    
    See tdf#94879 for motivation.
    
    Change-Id: I6c65fc584292f95bbf7ab24c5d94a41c2fa7576a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132161
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index cab948131d65..1c6df69dc0dd 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -2137,7 +2137,7 @@ sal_Int32 WW8ScannerBase::WW8ReadString( SvStream& rStrm, 
OUString& rStr,
 
 WW8PLCFspecial::WW8PLCFspecial(SvStream* pSt, sal_uInt32 nFilePos,
     sal_uInt32 nPLCF, sal_uInt32 nStruct)
-    : nIdx(0), nStru(nStruct)
+    : m_nIdx(0), m_nStru(nStruct)
 {
     const sal_uInt32 nValidMin=4;
 
@@ -2150,23 +2150,23 @@ WW8PLCFspecial::WW8PLCFspecial(SvStream* pSt, 
sal_uInt32 nFilePos,
     nPLCF = bValid ? std::min(nRemainingSize, static_cast<std::size_t>(nPLCF)) 
: nValidMin;
 
     // Pointer to Pos- and Struct-array
-    pPLCF_PosArray.reset( new sal_Int32[ ( nPLCF + 3 ) / 4 ] );
-    pPLCF_PosArray[0] = 0;
+    m_pPLCF_PosArray.reset( new sal_Int32[ ( nPLCF + 3 ) / 4 ] );
+    m_pPLCF_PosArray[0] = 0;
 
-    nPLCF = bValid ? pSt->ReadBytes(pPLCF_PosArray.get(), nPLCF) : nValidMin;
+    nPLCF = bValid ? pSt->ReadBytes(m_pPLCF_PosArray.get(), nPLCF) : nValidMin;
 
     nPLCF = std::max(nPLCF, nValidMin);
 
-    nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
+    m_nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
 #ifdef OSL_BIGENDIAN
     for( nIdx = 0; nIdx <= nIMax; nIdx++ )
         pPLCF_PosArray[nIdx] = OSL_SWAPDWORD( pPLCF_PosArray[nIdx] );
     nIdx = 0;
 #endif // OSL_BIGENDIAN
     if( nStruct ) // Pointer to content array
-        pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&pPLCF_PosArray[nIMax + 
1]);
+        m_pPLCF_Contents = 
reinterpret_cast<sal_uInt8*>(&m_pPLCF_PosArray[m_nIMax + 1]);
     else
-        pPLCF_Contents = nullptr;                         // no content
+        m_pPLCF_Contents = nullptr;                         // no content
 
     pSt->Seek(nOldPos);
 }
@@ -2177,33 +2177,33 @@ WW8PLCFspecial::WW8PLCFspecial(SvStream* pSt, 
sal_uInt32 nFilePos,
 // the position nPos.
 bool WW8PLCFspecial::SeekPos(tools::Long nP)
 {
-    if( nP < pPLCF_PosArray[0] )
+    if( nP < m_pPLCF_PosArray[0] )
     {
-        nIdx = 0;
+        m_nIdx = 0;
         return false;   // Not found: nP less than smallest entry
     }
 
     // Search from beginning?
-    if ((nIdx < 1) || (nP < pPLCF_PosArray[nIdx - 1]))
-        nIdx = 1;
+    if ((m_nIdx < 1) || (nP < m_pPLCF_PosArray[m_nIdx - 1]))
+        m_nIdx = 1;
 
-    tools::Long nI   = nIdx;
-    tools::Long nEnd = nIMax;
+    tools::Long nI   = m_nIdx;
+    tools::Long nEnd = m_nIMax;
 
-    for(int n = (1==nIdx ? 1 : 2); n; --n )
+    for(int n = (1==m_nIdx ? 1 : 2); n; --n )
     {
         for( ; nI <=nEnd; ++nI)
         {                                   // search with an index that is 
incremented by 1
-            if( nP < pPLCF_PosArray[nI] )
+            if( nP < m_pPLCF_PosArray[nI] )
             {                               // found position
-                nIdx = nI - 1;              // nI - 1 is the correct index
+                m_nIdx = nI - 1;              // nI - 1 is the correct index
                 return true;                // done
             }
         }
         nI   = 1;
-        nEnd = nIdx-1;
+        nEnd = m_nIdx-1;
     }
-    nIdx = nIMax;               // not found, greater than all entries
+    m_nIdx = m_nIMax;               // not found, greater than all entries
     return false;
 }
 
@@ -2212,49 +2212,49 @@ bool WW8PLCFspecial::SeekPos(tools::Long nP)
 // Is used for fields and bookmarks.
 bool WW8PLCFspecial::SeekPosExact(tools::Long nP)
 {
-    if( nP < pPLCF_PosArray[0] )
+    if( nP < m_pPLCF_PosArray[0] )
     {
-        nIdx = 0;
+        m_nIdx = 0;
         return false;       // Not found: nP less than smallest entry
     }
     // Search from beginning?
-    if( nP <=pPLCF_PosArray[nIdx] )
-        nIdx = 0;
+    if( nP <=m_pPLCF_PosArray[m_nIdx] )
+        m_nIdx = 0;
 
-    tools::Long nI   = nIdx ? nIdx-1 : 0;
-    tools::Long nEnd = nIMax;
+    tools::Long nI   = m_nIdx ? m_nIdx-1 : 0;
+    tools::Long nEnd = m_nIMax;
 
-    for(int n = (0==nIdx ? 1 : 2); n; --n )
+    for(int n = (0==m_nIdx ? 1 : 2); n; --n )
     {
         for( ; nI < nEnd; ++nI)
         {
-            if( nP <=pPLCF_PosArray[nI] )
+            if( nP <=m_pPLCF_PosArray[nI] )
             {                           // found position
-                nIdx = nI;              // nI is the correct index
+                m_nIdx = nI;              // nI is the correct index
                 return true;            // done
             }
         }
         nI   = 0;
-        nEnd = nIdx;
+        nEnd = m_nIdx;
     }
-    nIdx = nIMax;               // Not found, greater than all entries
+    m_nIdx = m_nIMax;               // Not found, greater than all entries
     return false;
 }
 
 bool WW8PLCFspecial::Get(WW8_CP& rPos, void*& rpValue) const
 {
-    return GetData( nIdx, rPos, rpValue );
+    return GetData( m_nIdx, rPos, rpValue );
 }
 
 bool WW8PLCFspecial::GetData(tools::Long nInIdx, WW8_CP& rPos, void*& rpValue) 
const
 {
-    if ( nInIdx >= nIMax )
+    if ( nInIdx >= m_nIMax )
     {
         rPos = WW8_CP_MAX;
         return false;
     }
-    rPos = pPLCF_PosArray[nInIdx];
-    rpValue = pPLCF_Contents ? static_cast<void*>(&pPLCF_Contents[nInIdx * 
nStru]) : nullptr;
+    rPos = m_pPLCF_PosArray[nInIdx];
+    rpValue = m_pPLCF_Contents ? static_cast<void*>(&m_pPLCF_Contents[nInIdx * 
m_nStru]) : nullptr;
     return true;
 }
 
@@ -2374,7 +2374,7 @@ namespace
 
 void WW8PLCFpcd::TruncToSortedRange()
 {
-    nIMax = ::TruncToSortedRange(pPLCF_PosArray.get(), nIMax);
+    m_nIMax = ::TruncToSortedRange(m_pPLCF_PosArray.get(), m_nIMax);
 }
 
 void WW8PLCF::TruncToSortedRange()
@@ -2525,7 +2525,7 @@ WW8_CP WW8PLCF::Where() const
 
 WW8PLCFpcd::WW8PLCFpcd(SvStream* pSt, sal_uInt32 nFilePos,
     sal_uInt32 nPLCF, sal_uInt32 nStruct)
-    : nStru( nStruct )
+    : m_nStru( nStruct )
 {
     const sal_uInt32 nValidMin=4;
 
@@ -2537,20 +2537,20 @@ WW8PLCFpcd::WW8PLCFpcd(SvStream* pSt, sal_uInt32 
nFilePos,
         bValid = false;
     nPLCF = bValid ? std::min(nRemainingSize, static_cast<std::size_t>(nPLCF)) 
: nValidMin;
 
-    pPLCF_PosArray.reset( new WW8_CP[ ( nPLCF + 3 ) / 4 ] );    // Pointer to 
Pos-array
-    pPLCF_PosArray[0] = 0;
+    m_pPLCF_PosArray.reset( new WW8_CP[ ( nPLCF + 3 ) / 4 ] );    // Pointer 
to Pos-array
+    m_pPLCF_PosArray[0] = 0;
 
-    nPLCF = bValid ? pSt->ReadBytes(pPLCF_PosArray.get(), nPLCF) : nValidMin;
+    nPLCF = bValid ? pSt->ReadBytes(m_pPLCF_PosArray.get(), nPLCF) : nValidMin;
     nPLCF = std::max(nPLCF, nValidMin);
 
-    nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
+    m_nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
 #ifdef OSL_BIGENDIAN
     for( tools::Long nI = 0; nI <= nIMax; nI++ )
       pPLCF_PosArray[nI] = OSL_SWAPDWORD( pPLCF_PosArray[nI] );
 #endif // OSL_BIGENDIAN
 
     // Pointer to content array
-    pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&pPLCF_PosArray[nIMax + 1]);
+    m_pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&m_pPLCF_PosArray[m_nIMax 
+ 1]);
     TruncToSortedRange();
 
     pSt->Seek( nOldPos );
@@ -2558,7 +2558,7 @@ WW8PLCFpcd::WW8PLCFpcd(SvStream* pSt, sal_uInt32 nFilePos,
 
 // If nStartPos < 0, the first element of PLCFs will be taken
 WW8PLCFpcd_Iter::WW8PLCFpcd_Iter( WW8PLCFpcd& rPLCFpcd, tools::Long nStartPos )
-    :rPLCF( rPLCFpcd ), nIdx( 0 )
+    :m_rPLCF( rPLCFpcd ), m_nIdx( 0 )
 {
     if( nStartPos >= 0 )
         SeekPos( nStartPos );
@@ -2568,54 +2568,54 @@ bool WW8PLCFpcd_Iter::SeekPos(tools::Long nPos)
 {
     tools::Long nP = nPos;
 
-    if( nP < rPLCF.pPLCF_PosArray[0] )
+    if( nP < m_rPLCF.m_pPLCF_PosArray[0] )
     {
-        nIdx = 0;
+        m_nIdx = 0;
         return false;       // not found: nPos less than smallest entry
     }
     // Search from beginning?
-    if ((nIdx < 1) || (nP < rPLCF.pPLCF_PosArray[nIdx - 1]))
-        nIdx = 1;
+    if ((m_nIdx < 1) || (nP < m_rPLCF.m_pPLCF_PosArray[m_nIdx - 1]))
+        m_nIdx = 1;
 
-    tools::Long nI   = nIdx;
-    tools::Long nEnd = rPLCF.nIMax;
+    tools::Long nI   = m_nIdx;
+    tools::Long nEnd = m_rPLCF.m_nIMax;
 
-    for(int n = (1==nIdx ? 1 : 2); n; --n )
+    for(int n = (1==m_nIdx ? 1 : 2); n; --n )
     {
         for( ; nI <=nEnd; ++nI)
         {                               // search with an index that is 
incremented by 1
-            if( nP < rPLCF.pPLCF_PosArray[nI] )
+            if( nP < m_rPLCF.m_pPLCF_PosArray[nI] )
             {                           // found position
-                nIdx = nI - 1;          // nI - 1 is the correct index
+                m_nIdx = nI - 1;          // nI - 1 is the correct index
                 return true;            // done
             }
         }
         nI   = 1;
-        nEnd = nIdx-1;
+        nEnd = m_nIdx-1;
     }
-    nIdx = rPLCF.nIMax;         // not found, greater than all entries
+    m_nIdx = m_rPLCF.m_nIMax;         // not found, greater than all entries
     return false;
 }
 
 bool WW8PLCFpcd_Iter::Get(WW8_CP& rStart, WW8_CP& rEnd, void*& rpValue) const
 {
-    if( nIdx >= rPLCF.nIMax )
+    if( m_nIdx >= m_rPLCF.m_nIMax )
     {
         rStart = rEnd = WW8_CP_MAX;
         return false;
     }
-    rStart = rPLCF.pPLCF_PosArray[nIdx];
-    rEnd = rPLCF.pPLCF_PosArray[nIdx + 1];
-    rpValue = static_cast<void*>(&rPLCF.pPLCF_Contents[nIdx * rPLCF.nStru]);
+    rStart = m_rPLCF.m_pPLCF_PosArray[m_nIdx];
+    rEnd = m_rPLCF.m_pPLCF_PosArray[m_nIdx + 1];
+    rpValue = static_cast<void*>(&m_rPLCF.m_pPLCF_Contents[m_nIdx * 
m_rPLCF.m_nStru]);
     return true;
 }
 
 sal_Int32 WW8PLCFpcd_Iter::Where() const
 {
-    if ( nIdx >= rPLCF.nIMax )
+    if ( m_nIdx >= m_rPLCF.m_nIMax )
         return SAL_MAX_INT32;
 
-    return rPLCF.pPLCF_PosArray[nIdx];
+    return m_rPLCF.m_pPLCF_PosArray[m_nIdx];
 }
 
 bool WW8PLCFx_Fc_FKP::WW8Fkp::Entry::operator<
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index 4e80e882902e..79ecd2083a0a 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -220,11 +220,11 @@ struct WW8PLCFxSave1
 class WW8PLCFspecial        // iterator for PLCFs
 {
 private:
-    std::unique_ptr<sal_Int32[]> pPLCF_PosArray;  ///< pointer to Pos-array 
and to the whole structure
-    sal_uInt8*  pPLCF_Contents;  ///< pointer to content-array-part of 
Pos-array
-    tools::Long nIMax;             ///< number of elements
-    tools::Long nIdx;              ///< marker where we currently are
-    sal_uInt32 nStru;
+    std::unique_ptr<sal_Int32[]> m_pPLCF_PosArray;  ///< pointer to Pos-array 
and to the whole structure
+    sal_uInt8*  m_pPLCF_Contents;  ///< pointer to content-array-part of 
Pos-array
+    tools::Long m_nIMax;             ///< number of elements
+    tools::Long m_nIdx;              ///< marker where we currently are
+    sal_uInt32 m_nStru;
 
     WW8PLCFspecial(const WW8PLCFspecial&) = delete;
     WW8PLCFspecial& operator=(const WW8PLCFspecial&) = delete;
@@ -232,29 +232,29 @@ private:
 public:
     WW8PLCFspecial(SvStream* pSt, sal_uInt32 nFilePos, sal_uInt32 nPLCF,
         sal_uInt32 nStruct);
-    tools::Long GetIdx() const { return nIdx; }
-    void SetIdx( tools::Long nI ) { nIdx = nI; }
-    tools::Long GetIMax() const { return nIMax; }
+    tools::Long GetIdx() const { return m_nIdx; }
+    void SetIdx( tools::Long nI ) { m_nIdx = nI; }
+    tools::Long GetIMax() const { return m_nIMax; }
     bool SeekPos(tools::Long nPos);            // walks over FC- or CP-value
                                         // resp. next biggest value
     bool SeekPosExact(tools::Long nPos);
     sal_Int32 Where() const
-        { return ( nIdx >= nIMax ) ? SAL_MAX_INT32 : pPLCF_PosArray[nIdx]; }
+        { return ( m_nIdx >= m_nIMax ) ? SAL_MAX_INT32 : 
m_pPLCF_PosArray[m_nIdx]; }
     bool Get(WW8_CP& rStart, void*& rpValue) const;
     bool GetData(tools::Long nIdx, WW8_CP& rPos, void*& rpValue) const;
 
     const void* GetData( tools::Long nInIdx ) const
     {
-        return ( nInIdx >= nIMax ) ? nullptr
-            : static_cast<const void*>(&pPLCF_Contents[nInIdx * nStru]);
+        return ( nInIdx >= m_nIMax ) ? nullptr
+            : static_cast<const void*>(&m_pPLCF_Contents[nInIdx * m_nStru]);
     }
     sal_Int32 GetPos( tools::Long nInIdx ) const
-        { return ( nInIdx >= nIMax ) ? SAL_MAX_INT32 : pPLCF_PosArray[nInIdx]; 
}
+        { return ( nInIdx >= m_nIMax ) ? SAL_MAX_INT32 : 
m_pPLCF_PosArray[nInIdx]; }
 
     void advance()
     {
-        if (nIdx <= nIMax)
-            ++nIdx;
+        if (m_nIdx <= m_nIMax)
+            ++m_nIdx;
     }
 };
 
@@ -341,10 +341,10 @@ class WW8PLCFpcd
 {
     friend class WW8PLCFpcd_Iter;
 
-    std::unique_ptr<WW8_CP[]> pPLCF_PosArray;  // pointer to Pos-array and the 
whole structure
-    sal_uInt8*  pPLCF_Contents;  // pointer to content-array-part of Pos-array
-    sal_Int32 nIMax;
-    sal_uInt32 nStru;
+    std::unique_ptr<WW8_CP[]> m_pPLCF_PosArray;  // pointer to Pos-array and 
the whole structure
+    sal_uInt8*  m_pPLCF_Contents;  // pointer to content-array-part of 
Pos-array
+    sal_Int32 m_nIMax;
+    sal_uInt32 m_nStru;
 
     WW8PLCFpcd(const WW8PLCFpcd&) = delete;
     WW8PLCFpcd& operator=(const WW8PLCFpcd&) = delete;
@@ -360,24 +360,24 @@ public:
 class WW8PLCFpcd_Iter
 {
 private:
-    WW8PLCFpcd& rPLCF;
-    tools::Long nIdx;
+    WW8PLCFpcd& m_rPLCF;
+    tools::Long m_nIdx;
 
     WW8PLCFpcd_Iter(const WW8PLCFpcd_Iter&) = delete;
     WW8PLCFpcd_Iter& operator=(const WW8PLCFpcd_Iter&) = delete;
 
 public:
     WW8PLCFpcd_Iter( WW8PLCFpcd& rPLCFpcd, tools::Long nStartPos = -1 );
-    tools::Long GetIdx() const { return nIdx; }
-    void SetIdx( tools::Long nI ) { nIdx = nI; }
-    tools::Long GetIMax() const { return rPLCF.nIMax; }
+    tools::Long GetIdx() const { return m_nIdx; }
+    void SetIdx( tools::Long nI ) { m_nIdx = nI; }
+    tools::Long GetIMax() const { return m_rPLCF.m_nIMax; }
     bool SeekPos(tools::Long nPos);
     sal_Int32 Where() const;
     bool Get(WW8_CP& rStart, WW8_CP& rEnd, void*& rpValue) const;
     void advance()
     {
-        if( nIdx < rPLCF.nIMax )
-            ++nIdx;
+        if( m_nIdx < m_rPLCF.m_nIMax )
+            ++m_nIdx;
     }
 };
 
@@ -394,9 +394,9 @@ class WW8PLCFx              // virtual iterator for Piece 
Table Exceptions
 {
 private:
     const WW8Fib& mrFib;
-    bool bIsSprm;           // PLCF of Sprms or other stuff ( Footnote, ... )
-    WW8_FC nStartFc;
-    bool bDirty;
+    bool m_bIsSprm;           // PLCF of Sprms or other stuff ( Footnote, ... )
+    WW8_FC m_nStartFc;
+    bool m_bDirty;
 
     WW8PLCFx(const WW8PLCFx&) = delete;
     WW8PLCFx& operator=(const WW8PLCFx&) = delete;
@@ -404,13 +404,13 @@ private:
 public:
     WW8PLCFx(const WW8Fib& rFib, bool bSprm)
         : mrFib(rFib)
-        , bIsSprm(bSprm)
-        , nStartFc(-1)
-        , bDirty(false)
+        , m_bIsSprm(bSprm)
+        , m_nStartFc(-1)
+        , m_bDirty(false)
     {
     }
     virtual ~WW8PLCFx() {}
-    bool IsSprm() const { return bIsSprm; }
+    bool IsSprm() const { return m_bIsSprm; }
     virtual sal_uInt32 GetIdx() const = 0;
     virtual void SetIdx(sal_uInt32 nIdx) = 0;
     virtual sal_uInt32 GetIdx2() const;
@@ -425,10 +425,10 @@ public:
     virtual void Restore( const WW8PLCFxSave1& rSave );
     ww::WordVersion GetFIBVersion() const;
     const WW8Fib& GetFIB() const { return mrFib; }
-    void SetStartFc( WW8_FC nFc ) { nStartFc = nFc; }
-    WW8_FC GetStartFc() const { return nStartFc; }
-    void SetDirty(bool bIn) {bDirty=bIn;}
-    bool GetDirty() const {return bDirty;}
+    void SetStartFc( WW8_FC nFc ) { m_nStartFc = nFc; }
+    WW8_FC GetStartFc() const { return m_nStartFc; }
+    void SetDirty(bool bIn) {m_bDirty=bIn;}
+    bool GetDirty() const {return m_bDirty;}
 };
 
 class WW8PLCFx_PCDAttrs : public WW8PLCFx

Reply via email to