[Libreoffice-commits] core.git: 3 commits - compilerplugins/clang extensions/source sc/source sd/source

Stephan Bergmann sbergman at redhat.com
Wed Jan 29 06:43:00 PST 2014


 compilerplugins/clang/implicitboolconversion.cxx              |   16 ++++++++++
 extensions/source/abpilot/fieldmappingimpl.cxx                |    2 -
 sc/source/core/data/attrib.cxx                                |    2 -
 sc/source/filter/excel/xestyle.cxx                            |    4 +-
 sd/source/core/sdpage2.cxx                                    |    4 +-
 sd/source/ui/slidesorter/controller/SlideSorterController.cxx |   12 ++-----
 sd/source/ui/view/drviewsf.cxx                                |    8 ++---
 sd/source/ui/view/drviewsg.cxx                                |    2 -
 sd/source/ui/view/outlnvsh.cxx                                |    2 -
 9 files changed, 32 insertions(+), 20 deletions(-)

New commits:
commit 81760e2702568ed02f06dbf4639e9218df8aeb2e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jan 29 15:42:04 2014 +0100

    implicitboolconversion: also warn about redundant explicit casts
    
    Change-Id: Ib89b4c12d2cdca873a9fe9a509d7a123977652a7

diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx
index e939295..ae26e01 100644
--- a/compilerplugins/clang/implicitboolconversion.cxx
+++ b/compilerplugins/clang/implicitboolconversion.cxx
@@ -521,6 +521,22 @@ bool ImplicitBoolConversion::VisitImplicitCastExpr(
         } else {
             nested.top().push_back(expr);
         }
+    } else {
+        ExplicitCastExpr const * sub = dyn_cast<ExplicitCastExpr>(
+            expr->getSubExpr()->IgnoreParenImpCasts());
+        if (sub != nullptr
+            && (sub->getSubExpr()->IgnoreParenImpCasts()->getType().IgnoreParens()
+                == expr->getType().IgnoreParens())
+            && isBool(sub->getSubExpr()->IgnoreParenImpCasts()))
+        {
+            report(
+                DiagnosticsEngine::Warning,
+                "explicit conversion (%0) from %1 to %2 implicitly cast back to %3",
+                expr->getLocStart())
+                << sub->getCastKindName()
+                << sub->getSubExpr()->IgnoreParenImpCasts()->getType()
+                << sub->getType() << expr->getType() << expr->getSourceRange();
+        }
     }
     return true;
 }
commit dfe30f1e3bc4720054c6ca3bc9813b9a1881084f
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jan 29 15:41:07 2014 +0100

    Remove some redundant casts
    
    Change-Id: I03317f55f5e08b131302190f34169054bacbeb28

diff --git a/extensions/source/abpilot/fieldmappingimpl.cxx b/extensions/source/abpilot/fieldmappingimpl.cxx
index 497a7d29..db33064 100644
--- a/extensions/source/abpilot/fieldmappingimpl.cxx
+++ b/extensions/source/abpilot/fieldmappingimpl.cxx
@@ -89,7 +89,7 @@ namespace abp
                                                            // the parent window
                                                            xDialogParent,
                                                            _rxDataSource,
-                                                           (sal_Bool)_rSettings.bRegisterDataSource ? _rSettings.sRegisteredDataSourceName : _rSettings.sDataSourceName,
+                                                           _rSettings.bRegisterDataSource ? _rSettings.sRegisteredDataSourceName : _rSettings.sDataSourceName,
                                                            // the table to use
                                                            _rSettings.sSelectedTable,
                                                            sTitle);
diff --git a/sc/source/core/data/attrib.cxx b/sc/source/core/data/attrib.cxx
index 5b86434..da9a3e4 100644
--- a/sc/source/core/data/attrib.cxx
+++ b/sc/source/core/data/attrib.cxx
@@ -1078,7 +1078,7 @@ bool ScDoubleItem::operator==( const SfxPoolItem& rItem ) const
 {
     OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
     const ScDoubleItem& _rItem = (const ScDoubleItem&)rItem;
-    return int(nValue == _rItem.nValue);
+    return nValue == _rItem.nValue;
 }
 
 //------------------------------------------------------------------------
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 59603eb..f5c45d5 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -1405,7 +1405,7 @@ bool XclExpCellAlign::FillFromItemSet(
             bUsed |= ScfTools::CheckItem( rItemSet, ATTR_INDENT, bStyle );
 
             // shrink to fit
-            mbShrink = GETITEMVALUE( rItemSet, SfxBoolItem, ATTR_SHRINKTOFIT, sal_Bool );
+            mbShrink = GETITEM( rItemSet, SfxBoolItem, ATTR_SHRINKTOFIT ).GetValue();
             bUsed |= ScfTools::CheckItem( rItemSet, ATTR_SHRINKTOFIT, bStyle );
 
             // CTL text direction
@@ -1421,7 +1421,7 @@ bool XclExpCellAlign::FillFromItemSet(
             bUsed |= ScfTools::CheckItem( rItemSet, ATTR_VER_JUSTIFY, bStyle );
 
             // stacked/rotation
-            bool bStacked = GETITEMVALUE( rItemSet, SfxBoolItem, ATTR_STACKED, sal_Bool );
+            bool bStacked = GETITEM( rItemSet, SfxBoolItem, ATTR_STACKED ).GetValue();
             bUsed |= ScfTools::CheckItem( rItemSet, ATTR_STACKED, bStyle );
             if( bStacked )
             {
diff --git a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx
index faa1c92..9f0d2b1 100644
--- a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx
+++ b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx
@@ -727,14 +727,10 @@ void SlideSorterController::GetCtrlState (SfxItemSet& rSet)
                     break;
             }
 
-            rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_COLOR,
-                    (sal_Bool)(nQuality==0)));
-            rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_GRAYSCALE,
-                    (sal_Bool)(nQuality==1)));
-            rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_BLACKWHITE,
-                    (sal_Bool)(nQuality==2)));
-            rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_CONTRAST,
-                    (sal_Bool)(nQuality==3)));
+            rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_COLOR, nQuality==0));
+            rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_GRAYSCALE, nQuality==1));
+            rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_BLACKWHITE, nQuality==2));
+            rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_CONTRAST, nQuality==3));
         }
     }
 
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 4032e6f..3f8fb7b 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -193,10 +193,10 @@ void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
         SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTPUT_QUALITY_CONTRAST ) )
     {
         const sal_uLong nMode = (sal_Int32)GetActiveWindow()->GetDrawMode();
-        rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_COLOR, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_COLOR == nMode) ) );
-        rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_GRAYSCALE, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_GRAYSCALE == nMode) ) );
-        rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_BLACKWHITE, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_BLACKWHITE == nMode) ) );
-        rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_CONTRAST, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_CONTRAST == nMode) ) );
+        rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_COLOR, (sal_uLong)OUTPUT_DRAWMODE_COLOR == nMode ) );
+        rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_GRAYSCALE, (sal_uLong)OUTPUT_DRAWMODE_GRAYSCALE == nMode ) );
+        rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_BLACKWHITE, (sal_uLong)OUTPUT_DRAWMODE_BLACKWHITE == nMode ) );
+        rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_CONTRAST, (sal_uLong)OUTPUT_DRAWMODE_CONTRAST == nMode ) );
     }
 
     if ( SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN) )
diff --git a/sd/source/ui/view/drviewsg.cxx b/sd/source/ui/view/drviewsg.cxx
index 9d93955..5b3e401 100644
--- a/sd/source/ui/view/drviewsg.cxx
+++ b/sd/source/ui/view/drviewsg.cxx
@@ -233,7 +233,7 @@ void DrawViewShell::GetOptionsBarState( SfxItemSet& rSet )
     rSet.Put( SfxBoolItem( SID_SNAP_POINTS, mpDrawView->IsOPntSnap() ) );
 
     rSet.Put( SfxBoolItem( SID_QUICKEDIT, mpDrawView->IsQuickTextEditMode() ) );
-    rSet.Put( SfxBoolItem( SID_PICK_THROUGH, (sal_Bool)
+    rSet.Put( SfxBoolItem( SID_PICK_THROUGH,
                 mpDrawView->GetModel()->IsPickThroughTransparentTextFrames() ) );
 
     rSet.Put( SfxBoolItem( SID_DOUBLECLICK_TEXTEDIT, mpFrameView->IsDoubleClickTextEdit() ) );
diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx
index 5a73099..c0e7ecd 100644
--- a/sd/source/ui/view/outlnvsh.cxx
+++ b/sd/source/ui/view/outlnvsh.cxx
@@ -1252,7 +1252,7 @@ void OutlineViewShell::ReadFrameViewData(FrameView* pView)
 {
     ::Outliner* pOutl = pOlView->GetOutliner();
 
-    pOutl->SetFlatMode( static_cast<bool>(pView->IsNoAttribs()) );
+    pOutl->SetFlatMode( pView->IsNoAttribs() );
 
     sal_uLong nCntrl = pOutl->GetControlWord();
 
commit c36e48ec319f2d8ea841ee0ae9627e8076bff4bf
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jan 29 13:24:31 2014 +0100

    This has only converted the condition of ?: to sal_Int32
    
    ...not the resulting value, since 6625989ee1188285c453b99aa13fac8e0cd74ca6
    "INTEGRATION: CWS impressodf12," but is unnecessary anyway.
    
    Change-Id: I2a20e3f0a71693ce4cdd4c1b48952761e59c9ff5

diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index b352788..0f7f7cf 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -173,9 +173,9 @@ void SdPage::SetPresentationLayout(const OUString& rLayoutName,
                 for (sal_Int16 i = -1; i < 9; i++)
                 {
                     aOldFullName = aOldLayoutName + " " +
-                                OUString::number( (sal_Int32) (i <= 0 ) ? 1 : i + 1 );
+                                OUString::number( (i <= 0 ) ? 1 : i + 1 );
                     aFullName = maLayoutName + " " +
-                                OUString::number( (sal_Int32) (i <= 0 ) ? 1 : i + 1);
+                                OUString::number( (i <= 0 ) ? 1 : i + 1);
                     pSheet = pStShPool->Find(aOldFullName, SD_STYLE_FAMILY_MASTERPAGE);
                     DBG_ASSERT(pSheet, "Old outline style sheet not found");
                     aOldOutlineStyles.push_back(pSheet);


More information about the Libreoffice-commits mailing list