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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jul 25 12:56:57 UTC 2018


 sw/source/filter/ww8/ww8scan.cxx |   16 +++++++++-------
 sw/source/filter/ww8/ww8scan.hxx |    5 ++---
 2 files changed, 11 insertions(+), 10 deletions(-)

New commits:
commit 8b8fb4ac654c8f847c35b93d701ba3475662ea69
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Jul 25 12:23:43 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Jul 25 14:56:34 2018 +0200

    convert pFontA to std::vector
    
    Change-Id: I8045047a963930c4a0dca2d1eaa0dcb6362b8e53
    Reviewed-on: https://gerrit.libreoffice.org/57971
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index fa0c778ac906..97be35a40288 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -7171,7 +7171,6 @@ namespace
 }
 
 WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib const & rFib )
-    : pFontA(nullptr), nMax(0)
 {
     // Attention: MacWord-Documents have their Fontnames
     // always in ANSI, even if eStructCharSet == CHARSET_MAC !!
@@ -7199,10 +7198,11 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib const & rFib )
 
     ww::WordVersion eVersion = rFib.GetFIBVersion();
 
+    sal_uInt16 nMax(0);
     if( eVersion >= ww::eWW8 )
     {
         // bVer8: read the count of strings in nMax
-        rSt.ReadUInt16( nMax );
+        rSt.ReadUInt16(nMax);
     }
 
     // Ver8:  skip undefined uint16
@@ -7224,11 +7224,11 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib const & rFib )
         nMax = std::min(nMax, nCalcMax);
     }
 
-    if( nMax )
+    if (nMax)
     {
         // allocate Index Array
-        pFontA.reset( new WW8_FFN[ nMax ] );
-        WW8_FFN* p = pFontA.get();
+        m_aFontA.resize(nMax);
+        WW8_FFN* p = m_aFontA.data();
 
         if( eVersion <= ww::eWW2 )
         {
@@ -7426,14 +7426,16 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib const & rFib )
             nMax = std::min(nMax, nValidFonts);
         }
     }
+    m_aFontA.resize(nMax);
+    m_aFontA.shrink_to_fit();
 }
 
 const WW8_FFN* WW8Fonts::GetFont( sal_uInt16 nNum ) const
 {
-    if( !pFontA || nNum >= nMax )
+    if (nNum >= m_aFontA.size())
         return nullptr;
 
-    return &pFontA[ nNum ];
+    return &m_aFontA[nNum];
 }
 
 // Search after a header/footer for a index in the ww list from header/footer
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index b7ec4eaac322..4297be8c6382 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -1581,13 +1581,12 @@ private:
     WW8Fonts(const WW8Fonts&) = delete;
     WW8Fonts& operator=(const WW8Fonts&) = delete;
 
-    std::unique_ptr<WW8_FFN[]> pFontA;    // Array of Pointers to Font Description
-    sal_uInt16 nMax;        // Array-Size
+    std::vector<WW8_FFN> m_aFontA; // Array of Pointers to Font Description
 
 public:
     WW8Fonts( SvStream& rSt, WW8Fib const & rFib );
     const WW8_FFN* GetFont( sal_uInt16 nNum ) const;
-    sal_uInt16 GetMax() const { return nMax; }
+    sal_uInt16 GetMax() const { return m_aFontA.size(); }
 };
 
 typedef sal_uInt8 HdFtFlags;


More information about the Libreoffice-commits mailing list