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

Caolán McNamara caolanm at redhat.com
Mon May 11 01:46:32 PDT 2015


 editeng/source/editeng/impedit2.cxx      |    1 -
 sw/source/core/text/itrpaint.cxx         |    6 ------
 sw/source/core/text/porglue.cxx          |    4 ++--
 sw/source/core/text/porlay.cxx           |    6 +++---
 sw/source/core/text/txtfld.cxx           |    4 ++--
 sw/source/core/text/txtftn.cxx           |    2 +-
 sw/source/filter/ww8/rtfexport.cxx       |    2 +-
 sw/source/filter/ww8/wrtw8num.cxx        |    2 +-
 sw/source/filter/ww8/ww8par.cxx          |    2 +-
 sw/source/filter/ww8/ww8par3.cxx         |    4 ++--
 sw/source/filter/ww8/ww8par5.cxx         |    2 +-
 sw/source/uibase/docvw/edtwin.cxx        |   10 +++++-----
 sw/source/uibase/uno/unotxdoc.cxx        |    2 +-
 vcl/source/window/accel.cxx              |    4 ++--
 vcl/source/window/menu.cxx               |   12 ++++++------
 vcl/source/window/menubarwindow.cxx      |    2 +-
 vcl/source/window/menufloatingwindow.cxx |    2 +-
 17 files changed, 30 insertions(+), 37 deletions(-)

New commits:
commit 2db379e22a7854dc16cc0066af70f16d5662d7e8
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon May 11 09:18:16 2015 +0100

    cppcheck: cstyleCast
    
    Change-Id: Id3ffa264ba7990b53d264745eaf0726f1468577b

diff --git a/sw/source/core/text/porglue.cxx b/sw/source/core/text/porglue.cxx
index a0e5af1..bcad1eb 100644
--- a/sw/source/core/text/porglue.cxx
+++ b/sw/source/core/text/porglue.cxx
@@ -169,7 +169,7 @@ void SwMarginPortion::AdjustRight( const SwLineLayout *pCurr )
     {
 
         // 1) We search for the left Glue
-        SwLinePortion *pPos = (SwLinePortion*)this;
+        SwLinePortion *pPos = this;
         SwGluePortion *pLeft = 0;
         while( pPos )
         {
@@ -254,7 +254,7 @@ void SwMarginPortion::AdjustRight( const SwLineLayout *pCurr )
             }
         }
         // If no left Glue remaines we set the break condition.
-        pRight = pLeft ? pLeft : (SwGluePortion*)this;
+        pRight = pLeft ? pLeft : this;
     }
 }
 
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 0fad655..a450b2a 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -139,7 +139,7 @@ SwLinePortion *SwLineLayout::Insert( SwLinePortion *pIns )
     {
         if( GetLen() )
         {
-            pPortion = new SwTxtPortion( *(SwLinePortion*)this );
+            pPortion = new SwTxtPortion(*this);
             if( IsBlinking() && pBlink )
             {
                 SetBlinking( false );
@@ -161,7 +161,7 @@ SwLinePortion *SwLineLayout::Append( SwLinePortion *pIns )
     // First attribute change: copy mass and length from *pIns into the first
     // text portion
     if( !pPortion )
-        pPortion = new SwTxtPortion( *(SwLinePortion*)this );
+        pPortion = new SwTxtPortion(*this);
     // Call with scope or we'll end up with recursion!
     return pPortion->SwLinePortion::Append( pIns );
 }
@@ -184,7 +184,7 @@ SwMarginPortion *SwLineLayout::CalcLeftMargin()
     SwMarginPortion *pLeft = (GetPortion() && GetPortion()->IsMarginPortion()) ?
         static_cast<SwMarginPortion *>(GetPortion()) : 0;
     if( !GetPortion() )
-         SetPortion( new SwTxtPortion( *(SwLinePortion*)this ) );
+         SetPortion(new SwTxtPortion(*this));
     if( !pLeft )
     {
         pLeft = new SwMarginPortion( 0 );
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index 5741651..39bbdc9 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -72,7 +72,7 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf,
                                                 const SwTxtAttr *pHint ) const
 {
     SwExpandPortion *pRet = 0;
-    SwFrm *pFrame = (SwFrm*)pFrm;
+    SwFrm *pFrame = pFrm;
     SwField *pFld = const_cast<SwField*>(pHint->GetFmtFld().GetField());
     const bool bName = rInf.GetOpt().IsFldName();
 
@@ -478,7 +478,7 @@ SwNumberPortion *SwTxtFormatter::NewNumberPortion( SwTxtFormatInfo &rInf ) const
 
         if( SVX_NUM_BITMAP == rNumFmt.GetNumberingType() )
         {
-            pRet = new SwGrfNumPortion( (SwFrm*)GetTxtFrm(),
+            pRet = new SwGrfNumPortion( const_cast<SwTxtFrm*>(GetTxtFrm()),
                                         pTxtNd->GetLabelFollowedBy(),
                                         rNumFmt.GetBrush(),
                                         rNumFmt.GetGraphicOrientation(),
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index 9505b64..f5be1d3 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -812,7 +812,7 @@ SwFtnPortion *SwTxtFormatter::NewFtnPortion( SwTxtFormatInfo &rInf,
         sal_uInt16 nOldReal = pCurr->GetRealHeight();
         sal_uInt16 nOldAscent = pCurr->GetAscent();
         sal_uInt16 nOldHeight = pCurr->Height();
-        ((SwTxtFormatter*)this)->CalcRealHeight();
+        CalcRealHeight();
         nReal = pCurr->GetRealHeight();
         if( nReal < nOldReal )
             nReal = nOldReal;
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index e49d52e..718d552 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -209,7 +209,7 @@ void RtfExport::BuildNumbering()
         SwNumRule* pRule;
         --n;
         if (n == rListTbl.size())
-            pRule = (SwNumRule*)m_pDoc->GetOutlineNumRule();
+            pRule = m_pDoc->GetOutlineNumRule();
         else
         {
             pRule = rListTbl[ n ];
diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
index 106df44..bc14531 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -95,7 +95,7 @@ sal_uInt16 MSWordExportBase::GetId( const SwNumRule& rNumRule )
         if ( !bOutlineRuleAdded )
         {
             // still need to paste the OutlineRule
-            SwNumRule* pR = (SwNumRule*)m_pDoc->GetOutlineNumRule();
+            SwNumRule* pR = m_pDoc->GetOutlineNumRule();
             m_pUsedNumTbl->push_back( pR );
         }
     }
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index ebf8095..95f0f30 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4046,7 +4046,7 @@ bool SwWW8ImplReader::ReadText(long nStartCp, long nTextLen, ManTypes nType)
             if(m_pAktItemSet && !pFmt)
             {
                 OUString sPrefix(OUStringBuffer("WW8Dropcap").append(m_nDropCap++).makeStringAndClear());
-                pNewSwCharFmt = m_rDoc.MakeCharFmt(sPrefix, (SwCharFmt*)m_rDoc.GetDfltCharFmt());
+                pNewSwCharFmt = m_rDoc.MakeCharFmt(sPrefix, m_rDoc.GetDfltCharFmt());
                  m_pAktItemSet->ClearItem(RES_CHRATR_ESCAPEMENT);
                 pNewSwCharFmt->SetFmtAttr( *m_pAktItemSet );
             }
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index b269ecc..63c84f0 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -1053,7 +1053,7 @@ void WW8ListManager::AdjustLVL( sal_uInt8 nLevel, SwNumRule& rNumRule,
                                   + "z" + OUString::number( nLevel ) );
 
             // const Wegcasten
-            pFmt = rDoc.MakeCharFmt(aName, (SwCharFmt*)rDoc.GetDfltCharFmt());
+            pFmt = rDoc.MakeCharFmt(aName, rDoc.GetDfltCharFmt());
             bNewCharFmtCreated = true;
             // Attribute reinsetzen
             pFmt->SetFmtAttr( *pThisLevelItemSet );
@@ -1080,7 +1080,7 @@ void WW8ListManager::AdjustLVL( sal_uInt8 nLevel, SwNumRule& rNumRule,
             const OUString aName( (!sPrefix.isEmpty() ? sPrefix : rNumRule.GetName())
                                   + "z" + OUString::number( nLevel ) );
 
-            pFmt = rDoc.MakeCharFmt(aName, (SwCharFmt*)rDoc.GetDfltCharFmt());
+            pFmt = rDoc.MakeCharFmt(aName, rDoc.GetDfltCharFmt());
             bNewCharFmtCreated = true;
             rCharFmt[ nLevel ] = pFmt;
             aNumFmt.SetCharFmt( pFmt );
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 0d11bd9..1192fd4 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -2654,7 +2654,7 @@ void SwWW8ImplReader::Read_SubF_Ruby( WW8ReadFieldParams& rReadParam)
             //Take this as the base name
             SwStyleNameMapper::FillUIName(RES_POOLCHR_RUBYTEXT,aNm);
             aNm+=OUString::number(m_aRubyCharFmts.size()+1);
-            pFmt = m_rDoc.MakeCharFmt(aNm,(SwCharFmt*)m_rDoc.GetDfltCharFmt());
+            pFmt = m_rDoc.MakeCharFmt(aNm, m_rDoc.GetDfltCharFmt());
             SvxFontHeightItem aHeightItem(nFontSize*10, 100, RES_CHRATR_FONTSIZE);
             SvxFontItem aFontItem(FAMILY_DONTKNOW,sFontName,
                 OUString(), PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, RES_CHRATR_FONT);
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index df4cf18..663395e 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -5394,15 +5394,15 @@ void SwEditWin::Command( const CommandEvent& rCEvt )
         case COMMAND_PREPARERECONVERSION:
         if( rSh.HasSelection() )
         {
-            SwPaM *pCrsr = (SwPaM*)rSh.GetCrsr();
+            SwPaM *pCrsr = rSh.GetCrsr();
 
             if( rSh.IsMultiSelection() )
             {
-                if( pCrsr && !pCrsr->HasMark() &&
-                pCrsr->GetPoint() == pCrsr->GetMark() )
+                if (pCrsr && !pCrsr->HasMark() &&
+                    pCrsr->GetPoint() == pCrsr->GetMark())
                 {
-                rSh.GoPrevCrsr();
-                pCrsr = (SwPaM*)rSh.GetCrsr();
+                    rSh.GoPrevCrsr();
+                    pCrsr = rSh.GetCrsr();
                 }
 
                 // Cancel all selections other than the last selected one.
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 59c5230..c86e8d1 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -2189,7 +2189,7 @@ Reference< XNameAccess >  SwXTextDocument::getLinks() throw( RuntimeException, s
     if(!pxLinkTargetSupplier)
     {
         pxLinkTargetSupplier = new Reference< XNameAccess > ;
-        (*pxLinkTargetSupplier) = new SwXLinkTargetSupplier(*(SwXTextDocument*)this);
+        (*pxLinkTargetSupplier) = new SwXLinkTargetSupplier(*this);
     }
     return (*pxLinkTargetSupplier);
 }
diff --git a/vcl/source/window/accel.cxx b/vcl/source/window/accel.cxx
index 99fea09..5f8dc36 100644
--- a/vcl/source/window/accel.cxx
+++ b/vcl/source/window/accel.cxx
@@ -261,7 +261,7 @@ Accelerator::Accelerator( const Accelerator& rAccel ) :
 
     ImplInit();
     mpData = new ImplAccelData;
-    ImplCopyData( *((ImplAccelData*)(rAccel.mpData)) );
+    ImplCopyData(*rAccel.mpData);
 }
 
 Accelerator::Accelerator( const ResId& rResId )
@@ -399,7 +399,7 @@ Accelerator& Accelerator::operator=( const Accelerator& rAccel )
     // delete and copy tables
     ImplDeleteData();
     mpData->maKeyMap.clear();
-    ImplCopyData( *((ImplAccelData*)(rAccel.mpData)) );
+    ImplCopyData(*rAccel.mpData);
 
     return *this;
 }
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 3560c6c..8a40d84 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2584,7 +2584,7 @@ bool MenuBar::HandleMenuActivateEvent( Menu *pMenu ) const
     {
         ImplMenuDelData aDelData( this );
 
-        pMenu->pStartedFrom = (Menu*)this;
+        pMenu->pStartedFrom = const_cast<MenuBar*>(this);
         pMenu->bInCallback = true;
         pMenu->Activate();
 
@@ -2600,7 +2600,7 @@ bool MenuBar::HandleMenuDeActivateEvent( Menu *pMenu ) const
     {
         ImplMenuDelData aDelData( this );
 
-        pMenu->pStartedFrom = (Menu*)this;
+        pMenu->pStartedFrom = const_cast<MenuBar*>(this);
         pMenu->bInCallback = true;
         pMenu->Deactivate();
         if( !aDelData.isDeleted() )
@@ -2612,7 +2612,7 @@ bool MenuBar::HandleMenuDeActivateEvent( Menu *pMenu ) const
 bool MenuBar::HandleMenuHighlightEvent( Menu *pMenu, sal_uInt16 nHighlightEventId ) const
 {
     if( !pMenu )
-        pMenu = ((Menu*) this)->ImplFindMenu( nHighlightEventId );
+        pMenu = const_cast<MenuBar*>(this)->ImplFindMenu(nHighlightEventId);
     if( pMenu )
     {
         ImplMenuDelData aDelData( pMenu );
@@ -2624,7 +2624,7 @@ bool MenuBar::HandleMenuHighlightEvent( Menu *pMenu, sal_uInt16 nHighlightEventI
         {
             pMenu->mnHighlightedItemPos = pMenu->GetItemPos( nHighlightEventId );
             pMenu->nSelectedId = nHighlightEventId;
-            pMenu->pStartedFrom = (Menu*)this;
+            pMenu->pStartedFrom = const_cast<MenuBar*>(this);
             pMenu->ImplCallHighlight( pMenu->mnHighlightedItemPos );
         }
         return true;
@@ -2636,11 +2636,11 @@ bool MenuBar::HandleMenuHighlightEvent( Menu *pMenu, sal_uInt16 nHighlightEventI
 bool MenuBar::HandleMenuCommandEvent( Menu *pMenu, sal_uInt16 nCommandEventId ) const
 {
     if( !pMenu )
-        pMenu = ((Menu*) this)->ImplFindMenu( nCommandEventId );
+        pMenu = const_cast<MenuBar*>(this)->ImplFindMenu(nCommandEventId);
     if( pMenu )
     {
         pMenu->nSelectedId = nCommandEventId;
-        pMenu->pStartedFrom = (Menu*)this;
+        pMenu->pStartedFrom = const_cast<MenuBar*>(this);
         pMenu->ImplSelect();
         return true;
     }
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 9acf9f7..6a8de20 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -793,7 +793,7 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu )
                         n = 0;
                 }
 
-                MenuItemData* pData = (MenuItemData*)pMenu->GetItemList()->GetDataFromPos( n );
+                MenuItemData* pData = pMenu->GetItemList()->GetDataFromPos( n );
                 if ( ( pData->eType != MenuItemType::SEPARATOR ) && pMenu->ImplIsVisible( n ) )
                 {
                     bool bDoSelect = true;
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index 247821c..d188bca 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -898,7 +898,7 @@ void MenuFloatingWindow::ImplCursorUpDown( bool bUp, bool bHomeEnd )
             }
         }
 
-        MenuItemData* pData = (MenuItemData*)pMenu->GetItemList()->GetDataFromPos( n );
+        MenuItemData* pData = pMenu->GetItemList()->GetDataFromPos( n );
         if ( ( pData->bEnabled || !rSettings.GetSkipDisabledInMenus() )
               && ( pData->eType != MenuItemType::SEPARATOR ) && pMenu->ImplIsVisible( n ) && pMenu->ImplIsSelectable( n ) )
         {
commit 951b128011db6bdf1050485b461d9af84a2ae367
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon May 11 09:16:17 2015 +0100

    cppcheck: unreadVariable
    
    Change-Id: I7af3807a4390e3b2f1bd9373feb937b6ff3dea7a

diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index ca975a3..0010e72 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -3537,7 +3537,6 @@ EditSelection ImpEditEngine::InsertText( uno::Reference< datatransfer::XTransfer
                     OUString aText;
                     aData >>= aText;
                     aNewSelection = ImpInsertText( rPaM, aText );
-                       bDone = true;
                 }
                 catch( ... )
                 {
diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index 2583b4e..760b663 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -515,7 +515,6 @@ void SwTxtPainter::CheckSpecialUnderline( const SwLinePortion* pPor,
     }
 
     const sal_Int32 nIndx = GetInfo().GetIdx();
-    long nUnderStart = 0;
     long nUnderEnd = 0;
     const size_t nCnt = aUnderMulti.GetRangeCount();
 
@@ -527,17 +526,12 @@ void SwTxtPainter::CheckSpecialUnderline( const SwLinePortion* pPor,
             nUnderEnd = rRange.Max();
         else if( nIndx >= rRange.Min() )
         {
-            nUnderStart = rRange.Min();
             nUnderEnd = rRange.Max();
         }
         else
             break;
     }
 
-    // restrict start and end to current line
-    if ( GetStart() > nUnderStart )
-        nUnderStart = GetStart();
-
     if ( GetEnd() && GetEnd() <= nUnderEnd )
         nUnderEnd = GetEnd() - 1;
 


More information about the Libreoffice-commits mailing list