[Libreoffice-commits] core.git: vcl/source vcl/unx vcl/win

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Jul 16 09:22:51 UTC 2018


 vcl/source/edit/textdata.cxx             |   13 ++++++-------
 vcl/source/edit/textdoc.cxx              |    4 ++--
 vcl/source/edit/textundo.cxx             |   20 ++++++++++----------
 vcl/source/edit/vclmedit.cxx             |    9 +++------
 vcl/source/filter/igif/decode.cxx        |   24 +++++++++++-------------
 vcl/source/filter/igif/decode.hxx        |   10 +++++-----
 vcl/source/gdi/impvect.cxx               |   12 +++++-------
 vcl/source/window/menufloatingwindow.cxx |   27 +++++++++++++--------------
 vcl/source/window/winproc.cxx            |    8 ++++----
 vcl/unx/generic/print/bitmap_gfx.cxx     |   22 +++++++++-------------
 vcl/win/gdi/salfont.cxx                  |    2 +-
 11 files changed, 69 insertions(+), 82 deletions(-)

New commits:
commit 311131fca0242e9465f03b6b1267906790a385c8
Author:     Jochen Nitschke <j.nitschke+logerrit at ok.de>
AuthorDate: Mon Jul 16 09:53:56 2018 +0200
Commit:     Jochen Nitschke <j.nitschke+logerrit at ok.de>
CommitDate: Mon Jul 16 11:22:30 2018 +0200

    cppcheck: useInitializationList in vcl
    
    reorder members of GIFLZWDecompressor to ease initialization.
    use rtl_allocateZeroMemory in ImplVectMap to avoid memset in ctor.
    
    Change-Id: Icfcfe73ec7e52988036995d8dbc604361aee893b
    Reviewed-on: https://gerrit.libreoffice.org/57481
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Jenkins
    Reviewed-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>

diff --git a/vcl/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx
index 6f048175b5f2..95136829cdbe 100644
--- a/vcl/source/edit/textdata.cxx
+++ b/vcl/source/edit/textdata.cxx
@@ -266,9 +266,9 @@ TEParaPortions::~TEParaPortions()
 }
 
 IdleFormatter::IdleFormatter()
+    : mpView(nullptr)
+    , mnRestarts(0)
 {
-    mpView = nullptr;
-    mnRestarts = 0;
     SetPriority(TaskPriority::HIGH_IDLE);
 }
 
@@ -314,12 +314,11 @@ TextHint::TextHint( SfxHintId Id, sal_uLong nValue ) : SfxHint( Id ), mnValue(nV
 }
 
 TEIMEInfos::TEIMEInfos( const TextPaM& rPos, const OUString& rOldTextAfterStartPos )
-: aOldTextAfterStartPos( rOldTextAfterStartPos )
+    : aOldTextAfterStartPos(rOldTextAfterStartPos)
+    , aPos(rPos)
+    , nLen(0)
+    , bWasCursorOverwrite(false)
 {
-    aPos = rPos;
-    nLen = 0;
-    pAttribs = nullptr;
-    bWasCursorOverwrite = false;
 }
 
 TEIMEInfos::~TEIMEInfos()
diff --git a/vcl/source/edit/textdoc.cxx b/vcl/source/edit/textdoc.cxx
index 52cb9562cdb8..68fa2e8f7398 100644
--- a/vcl/source/edit/textdoc.cxx
+++ b/vcl/source/edit/textdoc.cxx
@@ -43,8 +43,8 @@ TextCharAttrib::TextCharAttrib( const TextCharAttrib& rTextCharAttrib )
 }
 
 TextCharAttribList::TextCharAttribList()
+    : mbHasEmptyAttribs(false)
 {
-    mbHasEmptyAttribs = false;
 }
 
 TextCharAttribList::~TextCharAttribList()
@@ -380,8 +380,8 @@ void TextNode::Append( const TextNode& rNode )
 }
 
 TextDoc::TextDoc()
+    : mnLeftMargin(0)
 {
-    mnLeftMargin = 0;
 };
 
 TextDoc::~TextDoc()
diff --git a/vcl/source/edit/textundo.cxx b/vcl/source/edit/textundo.cxx
index e5b3d0165517..724745cf08d0 100644
--- a/vcl/source/edit/textundo.cxx
+++ b/vcl/source/edit/textundo.cxx
@@ -135,11 +135,11 @@ void TextUndo::SetSelection( const TextSelection& rSel )
 }
 
 TextUndoDelPara::TextUndoDelPara( TextEngine* pTextEngine, TextNode* pNode, sal_uInt32 nPara )
-                    : TextUndo( pTextEngine )
+    : TextUndo( pTextEngine )
+    , mbDelObject( true)
+    , mnPara( nPara )
+    , mpNode( pNode )
 {
-    mpNode = pNode;
-    mnPara = nPara;
-    mbDelObject = true;
 }
 
 TextUndoDelPara::~TextUndoDelPara()
@@ -187,10 +187,10 @@ OUString TextUndoDelPara::GetComment () const
 }
 
 TextUndoConnectParas::TextUndoConnectParas( TextEngine* pTextEngine, sal_uInt32 nPara, sal_Int32 nPos )
-                    :   TextUndo( pTextEngine )
+    : TextUndo( pTextEngine )
+    , mnPara( nPara )
+    , mnSepPos( nPos )
 {
-    mnPara = nPara;
-    mnSepPos = nPos;
 }
 
 TextUndoConnectParas::~TextUndoConnectParas()
@@ -215,10 +215,10 @@ OUString TextUndoConnectParas::GetComment () const
 }
 
 TextUndoSplitPara::TextUndoSplitPara( TextEngine* pTextEngine, sal_uInt32 nPara, sal_Int32 nPos )
-                    : TextUndo( pTextEngine )
+    : TextUndo( pTextEngine )
+    , mnPara( nPara )
+    , mnSepPos ( nPos )
 {
-    mnPara = nPara;
-    mnSepPos = nPos;
 }
 
 TextUndoSplitPara::~TextUndoSplitPara()
diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx
index 18a48eddb933..e9629d7f9967 100644
--- a/vcl/source/edit/vclmedit.cxx
+++ b/vcl/source/edit/vclmedit.cxx
@@ -105,13 +105,10 @@ public:
 };
 
 ImpVclMEdit::ImpVclMEdit( VclMultiLineEdit* pEdt, WinBits nWinStyle )
-    :mpHScrollBar(nullptr)
-    ,mpVScrollBar(nullptr)
-    ,mpScrollBox(nullptr)
+    : pVclMultiLineEdit(pEdt)
+    , mpTextWindow(VclPtr<TextWindow>::Create(pEdt))
+    , mnTextWidth(0)
 {
-    pVclMultiLineEdit = pEdt;
-    mnTextWidth = 0;
-    mpTextWindow = VclPtr<TextWindow>::Create( pEdt );
     mpTextWindow->Show();
     InitFromStyle( nWinStyle );
     StartListening( *mpTextWindow->GetTextEngine() );
diff --git a/vcl/source/filter/igif/decode.cxx b/vcl/source/filter/igif/decode.cxx
index 63d8b9136116..7e136d1e3f20 100644
--- a/vcl/source/filter/igif/decode.cxx
+++ b/vcl/source/filter/igif/decode.cxx
@@ -29,28 +29,26 @@ struct GIFLZWTableEntry
 };
 
 GIFLZWDecompressor::GIFLZWDecompressor(sal_uInt8 cDataSize)
-    : pBlockBuf(nullptr)
+    : pTable(new GIFLZWTableEntry[4098])
+    , pOutBufData(pOutBuf.data() + 4096)
+    , pBlockBuf(nullptr)
     , nInputBitsBuf(0)
-    , nOutBufDataLen(0)
-    , nInputBitsBufSize(0)
     , bEOIFound(false)
     , nDataSize(cDataSize)
     , nBlockBufSize(0)
     , nBlockBufPos(0)
+    , nClearCode(1 << nDataSize)
+    , nEOICode(nClearCode + 1)
+    , nTableSize(nEOICode + 1)
+    , nCodeSize(nDataSize + 1)
+    , nOldCode(0xffff)
+    , nOutBufDataLen(0)
+    , nInputBitsBufSize(0)
 {
-    nClearCode = 1 << nDataSize;
-    nEOICode = nClearCode + 1;
-    nTableSize = nEOICode + 1;
-    nCodeSize = nDataSize + 1;
-    nOldCode = 0xffff;
-    pOutBufData = pOutBuf.data() + 4096;
-
-    pTable.reset( new GIFLZWTableEntry[ 4098 ] );
-
     for (sal_uInt16 i = 0; i < nTableSize; ++i)
     {
         pTable[i].pPrev = nullptr;
-        pTable[i].pFirst = pTable.get() + i;
+        pTable[i].pFirst = &pTable[i];
         pTable[i].nData = static_cast<sal_uInt8>(i);
     }
 
diff --git a/vcl/source/filter/igif/decode.hxx b/vcl/source/filter/igif/decode.hxx
index fb9d65527264..f1b92475de40 100644
--- a/vcl/source/filter/igif/decode.hxx
+++ b/vcl/source/filter/igif/decode.hxx
@@ -35,17 +35,17 @@ class GIFLZWDecompressor
     sal_uInt8*              pOutBufData;
     sal_uInt8*              pBlockBuf;
     sal_uLong               nInputBitsBuf;
-    sal_uInt16              nTableSize;
+    bool                    bEOIFound;
+    sal_uInt8               nDataSize;
+    sal_uInt8               nBlockBufSize;
+    sal_uInt8               nBlockBufPos;
     sal_uInt16              nClearCode;
     sal_uInt16              nEOICode;
+    sal_uInt16              nTableSize;
     sal_uInt16              nCodeSize;
     sal_uInt16              nOldCode;
     sal_uInt16              nOutBufDataLen;
     sal_uInt16              nInputBitsBufSize;
-    bool                    bEOIFound;
-    sal_uInt8               nDataSize;
-    sal_uInt8               nBlockBufSize;
-    sal_uInt8               nBlockBufPos;
 
     bool                AddToTable(sal_uInt16 nPrevCode, sal_uInt16 nCodeFirstData);
     bool                ProcessOneCode();
diff --git a/vcl/source/gdi/impvect.cxx b/vcl/source/gdi/impvect.cxx
index 94680d99255d..0c6acb105fda 100644
--- a/vcl/source/gdi/impvect.cxx
+++ b/vcl/source/gdi/impvect.cxx
@@ -204,15 +204,13 @@ public:
 };
 
 ImplVectMap::ImplVectMap( long nWidth, long nHeight ) :
+    mpBuf ( static_cast<Scanline>(rtl_allocateZeroMemory(nWidth * nHeight)) ),
+    mpScan ( static_cast<Scanline*>(rtl_allocateMemory(nHeight * sizeof(Scanline))) ),
     mnWidth ( nWidth ),
     mnHeight( nHeight )
 {
     const long  nWidthAl = ( nWidth >> 2 ) + 1;
-    const long  nSize = nWidthAl * nHeight;
-    Scanline    pTmp = mpBuf = static_cast<Scanline>(rtl_allocateMemory( nSize ));
-
-    memset( mpBuf, 0, nSize );
-    mpScan = static_cast<Scanline*>(rtl_allocateMemory( nHeight * sizeof( Scanline ) ));
+    Scanline    pTmp = mpBuf;
 
     for( long nY = 0; nY < nHeight; pTmp += nWidthAl )
         mpScan[ nY++ ] = pTmp;
@@ -281,9 +279,9 @@ public:
 
 ImplChain::ImplChain() :
     mnArraySize ( 1024 ),
-    mnCount     ( 0 )
+    mnCount     ( 0 ),
+    mpCodes     ( new sal_uInt8[mnArraySize] )
 {
-    mpCodes.reset( new sal_uInt8[ mnArraySize ] );
 }
 
 void ImplChain::ImplGetSpace()
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index 62c357173adc..5ef774b617f9 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -28,22 +28,21 @@
 #include <window.h>
 
 MenuFloatingWindow::MenuFloatingWindow( Menu* pMen, vcl::Window* pParent, WinBits nStyle ) :
-    FloatingWindow( pParent, nStyle )
+    FloatingWindow( pParent, nStyle ),
+    pMenu(pMen),
+    nHighlightedItem(ITEMPOS_INVALID),
+    nMBDownPos(ITEMPOS_INVALID),
+    nScrollerHeight(0),
+    nFirstEntry(0),
+    nPosInParent(ITEMPOS_INVALID),
+    bInExecute(false),
+    bScrollMenu(false),
+    bScrollUp(false),
+    bScrollDown(false),
+    bIgnoreFirstMove(true),
+    bKeyInput(false)
 {
     mpWindowImpl->mbMenuFloatingWindow= true;
-    pMenu               = pMen;
-    pActivePopup        = nullptr;
-    bInExecute          = false;
-    bScrollMenu         = false;
-    nHighlightedItem    = ITEMPOS_INVALID;
-    nMBDownPos          = ITEMPOS_INVALID;
-    nPosInParent        = ITEMPOS_INVALID;
-    nScrollerHeight     = 0;
-    nFirstEntry         = 0;
-    bScrollUp           = false;
-    bScrollDown         = false;
-    bIgnoreFirstMove    = true;
-    bKeyInput           = false;
 
     ApplySettings(*this);
 
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index 77e11cb58097..7135321f3a78 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -1508,9 +1508,9 @@ private:
     CommandSwipeData m_aSwipeData;
 public:
     HandleSwipeEvent(vcl::Window *pWindow, const SalSwipeEvent& rEvt)
-        : HandleGestureEvent(pWindow, Point(rEvt.mnX, rEvt.mnY))
+        : HandleGestureEvent(pWindow, Point(rEvt.mnX, rEvt.mnY)),
+          m_aSwipeData(rEvt.mnVelocityX)
     {
-        m_aSwipeData = CommandSwipeData(rEvt.mnVelocityX);
     }
     virtual bool CallCommand(vcl::Window *pWindow, const Point &/*rMousePos*/) override
     {
@@ -1530,9 +1530,9 @@ private:
     CommandLongPressData m_aLongPressData;
 public:
     HandleLongPressEvent(vcl::Window *pWindow, const SalLongPressEvent& rEvt)
-        : HandleGestureEvent(pWindow, Point(rEvt.mnX, rEvt.mnY))
+        : HandleGestureEvent(pWindow, Point(rEvt.mnX, rEvt.mnY)),
+          m_aLongPressData(rEvt.mnX, rEvt.mnY)
     {
-        m_aLongPressData = CommandLongPressData(rEvt.mnX, rEvt.mnY);
     }
     virtual bool CallCommand(vcl::Window *pWindow, const Point &/*rMousePos*/) override
     {
diff --git a/vcl/unx/generic/print/bitmap_gfx.cxx b/vcl/unx/generic/print/bitmap_gfx.cxx
index b906345bafc0..b11b8a728f95 100644
--- a/vcl/unx/generic/print/bitmap_gfx.cxx
+++ b/vcl/unx/generic/print/bitmap_gfx.cxx
@@ -296,18 +296,16 @@ public:
 };
 
 LZWEncoder::LZWEncoder(osl::File* pOutputFile) :
-        Ascii85Encoder (pOutputFile)
+        Ascii85Encoder (pOutputFile),
+        mpPrefix(nullptr),
+        mnDataSize(8),
+        mnClearCode(1 << mnDataSize),
+        mnEOICode(mnClearCode + 1),
+        mnTableSize(mnEOICode + 1),
+        mnCodeSize(mnDataSize + 1),
+        mnOffset(32),       // free bits in dwShift
+        mdwShift(0)
 {
-    mnDataSize  = 8;
-
-    mnClearCode = 1 << mnDataSize;
-    mnEOICode   = mnClearCode + 1;
-    mnTableSize = mnEOICode   + 1;
-    mnCodeSize  = mnDataSize  + 1;
-
-    mnOffset    = 32;   // free bits in dwShift
-    mdwShift    = 0;
-
     for (sal_uInt32 i = 0; i < 4096; i++)
     {
         mpTable[i].mpBrother    = nullptr;
@@ -316,8 +314,6 @@ LZWEncoder::LZWEncoder(osl::File* pOutputFile) :
         mpTable[i].mnValue      = static_cast<sal_uInt8>(mpTable[i].mnCode);
     }
 
-    mpPrefix = nullptr;
-
     WriteBits( mnClearCode, mnCodeSize );
 }
 
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index e90b25363cd6..40effb6844f2 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -155,8 +155,8 @@ class WinGlyphFallbackSubstititution
 {
 public:
     explicit WinGlyphFallbackSubstititution()
+        : mhDC(GetDC(nullptr))
     {
-        mhDC = GetDC(nullptr);
     };
 
     ~WinGlyphFallbackSubstititution() override


More information about the Libreoffice-commits mailing list