[Libreoffice-commits] core.git: desktop/source dtrans/source editeng/source

Michael Weghorn m.weghorn at posteo.de
Fri Dec 12 00:08:42 PST 2014


 desktop/source/deployment/registry/component/dp_component.cxx |    2 +-
 desktop/source/pkgchk/unopkg/unopkg_app.cxx                   |    3 +--
 dtrans/source/win32/workbench/XTDo.cxx                        |    2 +-
 editeng/source/editeng/editdoc.cxx                            |    3 +--
 editeng/source/editeng/impedit2.cxx                           |    3 +--
 editeng/source/editeng/impedit4.cxx                           |    3 +--
 editeng/source/items/xmlcnitm.cxx                             |    3 +--
 editeng/source/outliner/outliner.cxx                          |    3 +--
 8 files changed, 8 insertions(+), 14 deletions(-)

New commits:
commit 04b183a9bc792a53a9f081353a79486faa4f3872
Author: Michael Weghorn <m.weghorn at posteo.de>
Date:   Thu Dec 11 23:32:12 2014 +0100

    fdo#39440 reduce scope of local variables
    
    This addresses some cppcheck warnings.
    
    Change-Id: Ifbc5a7a562e714f48dcfd51a75e9a4e0bfcde81c
    Reviewed-on: https://gerrit.libreoffice.org/13443
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx
index 5c13755..26018f4 100644
--- a/desktop/source/deployment/registry/component/dp_component.cxx
+++ b/desktop/source/deployment/registry/component/dp_component.cxx
@@ -1307,10 +1307,10 @@ BackendImpl::ComponentPackageImpl::isRegistered_(
     if (m_registered == REG_UNINIT)
     {
         m_registered = REG_NOT_REGISTERED;
-        bool bAmbiguousComponentName = false;
         const Reference<registry::XSimpleRegistry> xRDB( getRDB() );
         if (xRDB.is())
         {
+            bool bAmbiguousComponentName = false;
             // lookup rdb for location URL:
             const Reference<registry::XRegistryKey> xRootKey(
                 xRDB->getRootKey() );
diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
index 04dcac8..5bef9ed 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
@@ -187,7 +187,6 @@ extern "C" DESKTOP_DLLPUBLIC int unopkg_main()
     bool option_verbose = false;
     bool option_bundled = false;
     bool option_suppressLicense = false;
-    bool subcmd_add = false;
     bool subcmd_gui = false;
     OUString logFile;
     OUString repository;
@@ -239,7 +238,7 @@ extern "C" DESKTOP_DLLPUBLIC int unopkg_main()
         osl_getCommandArg( nPos, &subCommand.pData );
         ++nPos;
         subCommand = subCommand.trim();
-        subcmd_add = subCommand == "add";
+        bool subcmd_add = subCommand == "add";
         subcmd_gui = subCommand == "gui";
 
         // sun-command options and packages:
diff --git a/dtrans/source/win32/workbench/XTDo.cxx b/dtrans/source/win32/workbench/XTDo.cxx
index 83b4464..8961285 100644
--- a/dtrans/source/win32/workbench/XTDo.cxx
+++ b/dtrans/source/win32/workbench/XTDo.cxx
@@ -127,12 +127,12 @@ STDMETHODIMP CXTDataObject::GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium
         return E_INVALIDARG;
 
     HRESULT hr = E_FAIL;
-    char    pBuff[] = "Test OleClipboard";
 
     if ( CF_TEXT == pFormatetc->cfFormat )
     {
         CHGlobalHelper hGlobHlp( TRUE );
 
+        char    pBuff[] = "Test OleClipboard";
         hGlobHlp.Write( pBuff, sizeof( pBuff ), NULL );
 
         pmedium->tymed          = TYMED_HGLOBAL;
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 9e2e29f..85419c6 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -1434,7 +1434,6 @@ void ContentNode::CollapsAttribs( sal_Int32 nIndex, sal_Int32 nDeleted, SfxItemP
     // Since features are treated differently than normal character attributes,
     // can also the order of the start list be change!
     bool bResort = false;
-    bool bDelAttr = false;
     sal_Int32 nEndChanges = nIndex+nDeleted;
 
     sal_Int32 nAttr = 0;
@@ -1442,7 +1441,7 @@ void ContentNode::CollapsAttribs( sal_Int32 nIndex, sal_Int32 nDeleted, SfxItemP
     EditCharAttrib* pAttrib = GetAttrib(rAttribs, nAttr);
     while ( pAttrib )
     {
-        bDelAttr = false;
+        bool bDelAttr = false;
         if ( pAttrib->GetEnd() >= nIndex )
         {
             // Move all Attribute behind the insert point...
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index db8fe9c..1e2c2fc 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -3002,13 +3002,12 @@ EditPaM ImpEditEngine::GetPaM( Point aDocPos, bool bSmart )
     OSL_ENSURE( GetUpdateMode(), "Must not be reached when Update=FALSE: GetPaM" );
 
     long nY = 0;
-    long nTmpHeight;
     EditPaM aPaM;
     sal_Int32 nPortion;
     for ( nPortion = 0; nPortion < GetParaPortions().Count(); nPortion++ )
     {
         ParaPortion* pPortion = GetParaPortions()[nPortion];
-        nTmpHeight = pPortion->GetHeight();     // should also be correct for !bVisible!
+        const long nTmpHeight = pPortion->GetHeight();     // should also be correct for !bVisible!
         nY += nTmpHeight;
         if ( nY > aDocPos.Y() )
         {
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index dd5c2f0..f75d85c 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -2079,12 +2079,11 @@ void ImpEditEngine::AddPortionIterated(
                     pFieldAttr->GetStart() != pFieldAttr->GetEnd() &&
                     pFieldAttr->Which() == EE_FEATURE_FIELD;
             sal_Int32 nEndField = bIsField ? pFieldAttr->GetEnd() : USHRT_MAX;
-            bool bIsEndField = false;
             do
             {
                 aCursor = CursorRight( aCursor);
                 //determine whether a field and has been reached
-                bIsEndField = nEndField == aCursor.GetIndex();
+                bool bIsEndField = nEndField == aCursor.GetIndex();
                 //search for a new field attribute
                 const EditCharAttrib* _pFieldAttr = aCursor.GetNode()->GetCharAttribs().
                                                         FindFeature( aCursor.GetIndex() );
diff --git a/editeng/source/items/xmlcnitm.cxx b/editeng/source/items/xmlcnitm.cxx
index 4a98330..631de1a 100644
--- a/editeng/source/items/xmlcnitm.cxx
+++ b/editeng/source/items/xmlcnitm.cxx
@@ -120,7 +120,6 @@ bool SvXMLAttrContainerItem::PutValue( const com::sun::star::uno::Any& rVal, sal
             const OUString* pNames = aNameSequence.getConstArray();
             const sal_Int32 nCount = aNameSequence.getLength();
             Any aAny;
-            AttributeData* pData;
             sal_Int32 nAttr;
 
             for( nAttr = 0; nAttr < nCount; nAttr++ )
@@ -131,7 +130,7 @@ bool SvXMLAttrContainerItem::PutValue( const com::sun::star::uno::Any& rVal, sal
                 if( aAny.getValue() == NULL || aAny.getValueType() != cppu::UnoType<AttributeData>::get() )
                     return false;
 
-                pData = (AttributeData*)aAny.getValue();
+                AttributeData* pData = (AttributeData*)aAny.getValue();
                 sal_Int32 pos = aName.indexOf( ':' );
                 if( pos != -1 )
                 {
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 154be10..1f870bc 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -613,7 +613,6 @@ void Outliner::SetText( const OutlinerParaObject& rPObj )
 
 void Outliner::AddText( const OutlinerParaObject& rPObj )
 {
-    Paragraph* pPara;
 
     bool bUpdate = pEditEngine->GetUpdateMode();
     pEditEngine->SetUpdateMode( false );
@@ -635,7 +634,7 @@ void Outliner::AddText( const OutlinerParaObject& rPObj )
 
     for( sal_Int32 n = 0; n < rPObj.Count(); n++ )
     {
-        pPara = new Paragraph( rPObj.GetParagraphData(n) );
+        Paragraph* pPara = new Paragraph( rPObj.GetParagraphData(n) );
         pParaList->Append(pPara);
         sal_Int32 nP = nPara+n;
         DBG_ASSERT(pParaList->GetAbsPos(pPara)==nP,"AddText:Out of sync");


More information about the Libreoffice-commits mailing list