[Libreoffice-commits] core.git: basic/source desktop/source extensions/source filter/source l10ntools/source onlineupdate/source oox/source rsc/source sal/osl sal/qa sc/qa sc/source

Noel Grandin noelgrandin at gmail.com
Sun Oct 11 23:53:20 PDT 2015


 basic/source/uno/namecont.cxx                           |   20 +---
 desktop/source/migration/services/wordbookmigration.cxx |   12 --
 extensions/source/config/ldap/ldapaccess.cxx            |    5 -
 filter/source/graphicfilter/epict/epict.cxx             |    3 
 filter/source/svg/svgexport.cxx                         |    2 
 l10ntools/source/xmlparse.cxx                           |    5 -
 onlineupdate/source/libmar/sign/mar_sign.c              |    3 
 onlineupdate/source/libmar/sign/nss_secutil.c           |    2 
 onlineupdate/source/libmar/src/mar_create.c             |    3 
 onlineupdate/source/update/src/mar_create.c             |    3 
 onlineupdate/source/update/updater/nsWindowsRestart.cxx |    2 
 oox/source/export/chartexport.cxx                       |    2 
 rsc/source/parser/rscinit.cxx                           |   58 ++++--------
 sal/osl/unx/nlsupport.cxx                               |    3 
 sal/qa/osl/file/osl_File.cxx                            |   40 ++++----
 sc/qa/unit/ucalc.cxx                                    |    7 -
 sc/source/core/data/document.cxx                        |    6 -
 sc/source/core/data/table1.cxx                          |    3 
 sc/source/core/data/table2.cxx                          |    6 -
 sc/source/core/tool/interpr2.cxx                        |    2 
 sc/source/filter/excel/excimp8.cxx                      |    5 -
 sc/source/filter/xml/XMLStylesExportHelper.cxx          |   76 ++++++++--------
 22 files changed, 117 insertions(+), 151 deletions(-)

New commits:
commit ccc5ea08d64c38a9ce925d448c3010aca19ed35c
Author: Noel Grandin <noelgrandin at gmail.com>
Date:   Mon Oct 12 07:45:01 2015 +0200

    cppcheck:variableScope
    
    Change-Id: I037feb335499629300309851dcda3bb661f03d4f
    Reviewed-on: https://gerrit.libreoffice.org/19316
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index 9c2d29d..a9e2c0e 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -3225,22 +3225,20 @@ Sequence< Type > SfxLibrary::getTypes()
     throw( RuntimeException, std::exception )
 {
     static OTypeCollection * s_pTypes_NameContainer = 0;
+    if( !s_pTypes_NameContainer )
     {
+        MutexGuard aGuard( Mutex::getGlobalMutex() );
         if( !s_pTypes_NameContainer )
         {
-            MutexGuard aGuard( Mutex::getGlobalMutex() );
-            if( !s_pTypes_NameContainer )
-            {
-                static OTypeCollection s_aTypes_NameContainer(
-                    cppu::UnoType<XNameContainer>::get(),
-                    cppu::UnoType<XContainer>::get(),
-                    cppu::UnoType<XChangesNotifier>::get(),
-                    OComponentHelper::getTypes() );
-                s_pTypes_NameContainer = &s_aTypes_NameContainer;
-            }
+            static OTypeCollection s_aTypes_NameContainer(
+                cppu::UnoType<XNameContainer>::get(),
+                cppu::UnoType<XContainer>::get(),
+                cppu::UnoType<XChangesNotifier>::get(),
+                OComponentHelper::getTypes() );
+            s_pTypes_NameContainer = &s_aTypes_NameContainer;
         }
-        return s_pTypes_NameContainer->getTypes();
     }
+    return s_pTypes_NameContainer->getTypes();
 }
 
 
diff --git a/desktop/source/migration/services/wordbookmigration.cxx b/desktop/source/migration/services/wordbookmigration.cxx
index 0f4427c..768d517 100644
--- a/desktop/source/migration/services/wordbookmigration.cxx
+++ b/desktop/source/migration/services/wordbookmigration.cxx
@@ -146,15 +146,11 @@ namespace migration
 #define MAX_HEADER_LENGTH 16
 bool IsUserWordbook( const OUString& rFile )
 {
-    static const sal_Char*      pVerStr2    = "WBSWG2";
-    static const sal_Char*      pVerStr5    = "WBSWG5";
-    static const sal_Char*      pVerStr6    = "WBSWG6";
-    static const sal_Char*      pVerOOo7    = "OOoUserDict1";
-
     bool bRet = false;
     SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( OUString(rFile), STREAM_STD_READ );
     if ( pStream && !pStream->GetError() )
     {
+        static const sal_Char*      pVerOOo7    = "OOoUserDict1";
         sal_Size nSniffPos = pStream->Tell();
         static sal_Size nVerOOo7Len = sal::static_int_cast< sal_Size >(strlen( pVerOOo7 ));
         sal_Char pMagicHeader[MAX_HEADER_LENGTH];
@@ -172,9 +168,9 @@ bool IsUserWordbook( const OUString& rFile )
                 {
                    pStream->Read(pMagicHeader, nLen);
                    pMagicHeader[nLen] = '\0';
-                    if ( !strcmp(pMagicHeader, pVerStr2)
-                     ||  !strcmp(pMagicHeader, pVerStr5)
-                     ||  !strcmp(pMagicHeader, pVerStr6) )
+                    if ( !strcmp(pMagicHeader, "WBSWG2")
+                     ||  !strcmp(pMagicHeader, "WBSWG5")
+                     ||  !strcmp(pMagicHeader, "WBSWG6") )
                     bRet = true;
                 }
             }
diff --git a/extensions/source/config/ldap/ldapaccess.cxx b/extensions/source/config/ldap/ldapaccess.cxx
index e62d0b2..0e25c62 100644
--- a/extensions/source/config/ldap/ldapaccess.cxx
+++ b/extensions/source/config/ldap/ldapaccess.cxx
@@ -66,8 +66,7 @@ static void checkLdapReturnCode(const sal_Char *aOperation,
 {
     if (aRetCode == LDAP_SUCCESS) { return ; }
 
-    static const sal_Char *kNoSpecificMessage = "No additional information" ;
-    OUStringBuffer message ;
+    OUStringBuffer message;
 
     if (aOperation != NULL)
     {
@@ -89,7 +88,7 @@ static void checkLdapReturnCode(const sal_Char *aOperation,
         // This call is thus disabled for the moment.
         //ldap_memfree(stub) ;
     }
-    else { message.appendAscii(kNoSpecificMessage) ; }
+    else { message.appendAscii("No additional information") ; }
     message.append(")") ;
     throw ldap::LdapGenericException(message.makeStringAndClear(),
                                      NULL, aRetCode) ;
diff --git a/filter/source/graphicfilter/epict/epict.cxx b/filter/source/graphicfilter/epict/epict.cxx
index 267488b..27c9d97 100644
--- a/filter/source/graphicfilter/epict/epict.cxx
+++ b/filter/source/graphicfilter/epict/epict.cxx
@@ -872,7 +872,7 @@ void PictWriter::WriteOpcode_BitsRect(const Point & rPoint, const Size & rSize,
     sal_uLong   nWidth, nHeight, nDstRowBytes, nx, nc, ny, nCount, nColTabSize, i;
     sal_uLong   nDstRowPos, nEqu3, nPos, nDstMapPos;
     sal_uInt16  nBitsPerPixel, nPackType;
-    sal_uInt8   *pComp[4], *pTemp;
+    sal_uInt8   *pComp[4];
     sal_uInt8    nEquData = 0;
     sal_uInt8    nFlagCounterByte, nRed, nGreen, nBlue;
 
@@ -1149,6 +1149,7 @@ void PictWriter::WriteOpcode_BitsRect(const Point & rPoint, const Size & rSize,
         // loop through rows:
         for ( ny = 0; ny < nHeight; ny++ )
         {
+            sal_uInt8* pTemp;
             // read line ny of source into the buffer:
             switch ( nBitsPerPixel )
             {
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index fbef0ea..071b7a7 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -1025,7 +1025,6 @@ bool SVGFilter::implGenerateMetaData()
                             bool bPageNumberVisibility    = false;    // default: hidden
                             bool bDateTimeVisibility      = true;     // default: visible
                             bool bFooterVisibility        = true;     // default: visible
-                            bool bDateTimeFixed           = true;     // default: fixed
 
                             /*
                              *  Page Number Field
@@ -1042,6 +1041,7 @@ bool SVGFilter::implGenerateMetaData()
                             xPropSet->getPropertyValue( "IsDateTimeVisible" ) >>= bDateTimeVisibility;
                             if( bDateTimeVisibility ) // visibility default value: 'visible'
                             {
+                                bool bDateTimeFixed           = true;     // default: fixed
                                 xPropSet->getPropertyValue( "IsDateTimeFixed" ) >>= bDateTimeFixed;
                                 if( bDateTimeFixed ) // we are interested only in the field text not in the date/time format
                                 {
diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx
index 00c05cf..becad85 100644
--- a/l10ntools/source/xmlparse.cxx
+++ b/l10ntools/source/xmlparse.cxx
@@ -431,7 +431,6 @@ XMLFile& XMLFile::operator=(const XMLFile& rObj)
 
 void XMLFile::SearchL10NElements( XMLChildNode *pCur, int nPos )
 {
-    bool bInsert = true;
     if ( !pCur )
         SearchL10NElements( this  );
     else
@@ -453,6 +452,7 @@ void XMLFile::SearchL10NElements( XMLChildNode *pCur, int nPos )
             break;
             case XML_NODE_TYPE_ELEMENT:
             {
+                bool bInsert = true;
                 XMLElement *pElement = static_cast<XMLElement*>(pCur);
                 const OString sName(pElement->GetName().toAsciiLowerCase());
                 OString sLanguage, sTmpStrVal, sOldref;
@@ -507,7 +507,6 @@ bool XMLFile::CheckExportStatus( XMLParentNode *pCur )
 {
     static bool bStatusExport = true;
 
-    bool bInsert = true;
     if ( !pCur )
         CheckExportStatus( this );
     else {
@@ -532,7 +531,7 @@ bool XMLFile::CheckExportStatus( XMLParentNode *pCur )
                 {
                     if ( pElement->GetAttributeList())
                     {
-                        for (size_t j = 0 , cnt = pElement->GetAttributeList()->size(); j < cnt && bInsert; ++j)
+                        for (size_t j = 0 , cnt = pElement->GetAttributeList()->size(); j < cnt; ++j)
                         {
                             const OString tmpStr((*pElement->GetAttributeList())[j]->GetName());
                             if (tmpStr.equalsIgnoreAsciiCase("STATUS"))
diff --git a/onlineupdate/source/libmar/sign/mar_sign.c b/onlineupdate/source/libmar/sign/mar_sign.c
index 4a5fe87..3e7ef20 100644
--- a/onlineupdate/source/libmar/sign/mar_sign.c
+++ b/onlineupdate/source/libmar/sign/mar_sign.c
@@ -159,13 +159,12 @@ WriteAndUpdateSignatures(FILE *fpDest, void *buffer,
 void
 AdjustIndexContentOffsets(char *indexBuf, uint32_t indexLength, uint32_t offsetAmount)
 {
-  uint32_t *offsetToContent;
   char *indexBufLoc = indexBuf;
 
   /* Consume the index and adjust each index by the specified amount */
   while (indexBufLoc != (indexBuf + indexLength)) {
     /* Adjust the offset */
-    offsetToContent = (uint32_t *)indexBufLoc;
+    uint32_t* offsetToContent = (uint32_t *)indexBufLoc;
     *offsetToContent = ntohl(*offsetToContent);
     *offsetToContent += offsetAmount;
     *offsetToContent = htonl(*offsetToContent);
diff --git a/onlineupdate/source/libmar/sign/nss_secutil.c b/onlineupdate/source/libmar/sign/nss_secutil.c
index 01aa573..2fa53e7 100644
--- a/onlineupdate/source/libmar/sign/nss_secutil.c
+++ b/onlineupdate/source/libmar/sign/nss_secutil.c
@@ -25,7 +25,6 @@ static char consoleName[] =  {
 #if defined(_WINDOWS)
 static char * quiet_fgets (char *buf, int length, FILE *input)
 {
-  int c;
   char *end = buf;
 
   /* fflush (input); */
@@ -37,6 +36,7 @@ static char * quiet_fgets (char *buf, int length, FILE *input)
 
   while (1)
   {
+    int c;
 #if defined (_WIN32_WCE)
     c = getchar();      /* gets a character from stdin */
 #else
diff --git a/onlineupdate/source/libmar/src/mar_create.c b/onlineupdate/source/libmar/src/mar_create.c
index a87e937..c874b44 100644
--- a/onlineupdate/source/libmar/src/mar_create.c
+++ b/onlineupdate/source/libmar/src/mar_create.c
@@ -198,7 +198,6 @@ refresh_product_info_block(const char *path,
   uint32_t numSignatures, additionalBlockSize, additionalBlockID,
     offsetAdditionalBlocks, numAdditionalBlocks, i;
   int additionalBlocks, hasSignatureBlock;
-  int64_t oldPos;
 
   rv = get_mar_file_info(path,
                          &hasSignatureBlock,
@@ -230,7 +229,7 @@ refresh_product_info_block(const char *path,
 
   for (i = 0; i < numAdditionalBlocks; ++i) {
     /* Get the position of the start of this block */
-    oldPos = ftello(fp);
+    int64_t oldPos = ftello(fp);
 
     /* Read the additional block size */
     if (fread(&additionalBlockSize,
diff --git a/onlineupdate/source/update/src/mar_create.c b/onlineupdate/source/update/src/mar_create.c
index a87e937..c874b44 100644
--- a/onlineupdate/source/update/src/mar_create.c
+++ b/onlineupdate/source/update/src/mar_create.c
@@ -198,7 +198,6 @@ refresh_product_info_block(const char *path,
   uint32_t numSignatures, additionalBlockSize, additionalBlockID,
     offsetAdditionalBlocks, numAdditionalBlocks, i;
   int additionalBlocks, hasSignatureBlock;
-  int64_t oldPos;
 
   rv = get_mar_file_info(path,
                          &hasSignatureBlock,
@@ -230,7 +229,7 @@ refresh_product_info_block(const char *path,
 
   for (i = 0; i < numAdditionalBlocks; ++i) {
     /* Get the position of the start of this block */
-    oldPos = ftello(fp);
+    int64_t oldPos = ftello(fp);
 
     /* Read the additional block size */
     if (fread(&additionalBlockSize,
diff --git a/onlineupdate/source/update/updater/nsWindowsRestart.cxx b/onlineupdate/source/update/updater/nsWindowsRestart.cxx
index fbc9b86..27fe249 100644
--- a/onlineupdate/source/update/updater/nsWindowsRestart.cxx
+++ b/onlineupdate/source/update/updater/nsWindowsRestart.cxx
@@ -304,7 +304,6 @@ private:
  */
 static int ArgStrLen(const wchar_t *s)
 {
-  int backslashes = 0;
   int i = wcslen(s);
   BOOL hasDoubleQuote = wcschr(s, L'"') != nullptr;
   // Only add doublequotes if the string contains a space or a tab
@@ -315,6 +314,7 @@ static int ArgStrLen(const wchar_t *s)
   }
 
   if (hasDoubleQuote) {
+    int backslashes = 0;
     while (*s) {
       if (*s == '\\') {
         ++backslashes;
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 9546787..ecf16b7 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -842,13 +842,13 @@ void ChartExport::exportChart( Reference< css::chart::XChartDocument > xChartDoc
 
     // get Properties of ChartDocument
     bool bHasMainTitle = false;
-    bool bHasSubTitle = false;
     bool bHasLegend = false;
     Reference< beans::XPropertySet > xDocPropSet( xChartDoc, uno::UNO_QUERY );
     if( xDocPropSet.is())
     {
         try
         {
+            bool bHasSubTitle = false;
             Any aAny( xDocPropSet->getPropertyValue(
                 OUString(  "HasMainTitle" )));
             aAny >>= bHasMainTitle;
diff --git a/rsc/source/parser/rscinit.cxx b/rsc/source/parser/rscinit.cxx
index 6f9cb40..f78ed7f 100644
--- a/rsc/source/parser/rscinit.cxx
+++ b/rsc/source/parser/rscinit.cxx
@@ -82,21 +82,8 @@ void RscTypCont::Init()
     RscTop   *  pClassKeyCode;
     RscTop   *  pLangClassKeyCode;
     RscTop   *  pClassAccelItem;
-    RscTop   *  pClassAccel;
-    RscTop   *  pClassMenuItem;
-    RscTop   *  pClassMenu;
-    RscTop   *  pClassSplitWindow;
-    RscTop   *  pClassSpinButton;
     RscTop   *  pClassSpinField;
-    RscTop   *  pClassNumericField;
-    RscTop   *  pClassMetricField;
-    RscTop   *  pClassDockingWindow;
-    RscTop   *  pClassToolBoxItem;
-    RscTop   *  pClassToolBox;
-    RscTop   *  pClassFixedLine;
-    RscTop *    pClassSfxStyleFamilyItem;
-    RscTop *    pClassSfxTemplateDialog;
-    RscTop *    pClassSfxSlotInfo;
+    RscTop   *  pClassAccel;
 
     Atom        nId;
 
@@ -393,11 +380,11 @@ void RscTypCont::Init()
     pClassAccelItem->SetVariable( nId, pClassAccel, NULL, VAR_SVDYNAMIC,
                                ACCELITEM_ACCEL );
 
-    pClassMenuItem = InitClassMenuItem( pClassMgr, pClassBitmap,
+    RscTop* pClassMenuItem = InitClassMenuItem( pClassMgr, pClassBitmap,
                                         pLangClassKeyCode );
     pRoot->Insert( pClassMenuItem );
 
-    pClassMenu = InitClassMenu( pClassMgr, pClassMenuItem );
+    RscTop* pClassMenu = InitClassMenu( pClassMgr, pClassMenuItem );
     pRoot->Insert( pClassMenu );
 
     // pClassMenu is only completely defined here
@@ -406,12 +393,12 @@ void RscTypCont::Init()
                                  RSC_MENUITEM_MENU );
 }
 {
-    pClassSplitWindow = InitClassSplitWindow( pClassWindow );
+    RscTop* pClassSplitWindow = InitClassSplitWindow( pClassWindow );
     pRoot->Insert( pClassSplitWindow );
 
     // initialize class
     nId = pHS->getID( "SpinButton" );
-    pClassSpinButton = new RscClass( nId, RSC_SPINBUTTON, pClassControl );
+    RscTop*  pClassSpinButton = new RscClass( nId, RSC_SPINBUTTON, pClassControl );
     pClassSpinButton->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType );
     aNmTb.Put( nId, CLASSNAME, pClassSpinButton );
     {
@@ -434,38 +421,37 @@ void RscTypCont::Init()
 }
 {
     { // hand-made multiple inheritance
-    RscTop * pClassTmp = InitClassNumericFormatter( pClassSpinField );
-    aBaseLst.push_back( pClassTmp );
+        RscTop* pClassTmp = InitClassNumericFormatter( pClassSpinField );
+        aBaseLst.push_back( pClassTmp );
 
-    pClassNumericField = InitClassNumericField( pClassTmp );
-    pRoot->Insert( pClassNumericField );
+        RscTop* pClassNumericField = InitClassNumericField( pClassTmp );
+        pRoot->Insert( pClassNumericField );
     }
     { // hand-made multiple inheritance
-    RscTop * pClassTmp = InitClassNumericFormatter( pClassSpinField );
-    aBaseLst.push_back( pClassTmp );
-    pClassTmp = InitClassMetricFormatter( pClassTmp, pFieldUnits );
-    aBaseLst.push_back( pClassTmp );
+        RscTop* pClassTmp = InitClassNumericFormatter( pClassSpinField );
+        aBaseLst.push_back( pClassTmp );
+        pClassTmp = InitClassMetricFormatter( pClassTmp, pFieldUnits );
+        aBaseLst.push_back( pClassTmp );
 
-    pClassMetricField = InitClassMetricField( pClassTmp );
-    pRoot->Insert( pClassMetricField );
+        RscTop* pClassMetricField = InitClassMetricField( pClassTmp );
+        pRoot->Insert( pClassMetricField );
     }
 }
 {
-    pClassDockingWindow = InitClassDockingWindow( pClassWindow, pMapUnit );
+    RscTop* pClassDockingWindow = InitClassDockingWindow( pClassWindow, pMapUnit );
     pRoot->Insert( pClassDockingWindow );
 
-    pClassToolBoxItem = InitClassToolBoxItem( pClassMgr, pClassBitmap,
+    RscTop* pClassToolBoxItem = InitClassToolBoxItem( pClassMgr, pClassBitmap,
                                               pClassImage, pTriState );
     pRoot->Insert( pClassToolBoxItem );
 
-    pClassToolBox = InitClassToolBox( pClassDockingWindow, pClassToolBoxItem,
+    RscTop* pClassToolBox = InitClassToolBox( pClassDockingWindow, pClassToolBoxItem,
                                       pClassImageList );
     pRoot->Insert( pClassToolBox );
 
     // initialize class
     nId = pHS->getID( "FixedLine" );
-    pClassFixedLine =
-          new RscClass( nId, RSC_FIXEDLINE, pClassControl );
+    RscTop* pClassFixedLine = new RscClass( nId, RSC_FIXEDLINE, pClassControl );
     pClassFixedLine->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType );
 
     INS_WINBIT(pClassFixedLine,Vert)
@@ -473,17 +459,17 @@ void RscTypCont::Init()
     aNmTb.Put( nId, CLASSNAME, pClassFixedLine );
     pRoot->Insert( pClassFixedLine );
 
-    pClassSfxStyleFamilyItem = InitClassSfxStyleFamilyItem( pClassMgr,
+    RscTop* pClassSfxStyleFamilyItem = InitClassSfxStyleFamilyItem( pClassMgr,
                                                    pClassBitmap,
                                                    pClassImage,
                                                    pLangStringLongTupelList );
     pRoot->Insert( pClassSfxStyleFamilyItem );
 
-    pClassSfxTemplateDialog = InitClassSfxTemplateDialog( pClassMgr,
+    RscTop* pClassSfxTemplateDialog = InitClassSfxTemplateDialog( pClassMgr,
                                                   pClassSfxStyleFamilyItem );
     pRoot->Insert( pClassSfxTemplateDialog );
 
-    pClassSfxSlotInfo = InitClassSfxSlotInfo( pClassMgr );
+    RscTop* pClassSfxSlotInfo = InitClassSfxSlotInfo( pClassMgr );
     pRoot->Insert( pClassSfxSlotInfo );
 }
 
diff --git a/sal/osl/unx/nlsupport.cxx b/sal/osl/unx/nlsupport.cxx
index 0f6d28c..6a322d8 100644
--- a/sal/osl/unx/nlsupport.cxx
+++ b/sal/osl/unx/nlsupport.cxx
@@ -789,7 +789,6 @@ rtl_TextEncoding osl_getTextEncodingFromLocale( rtl_Locale * pLocale )
 {
     const _pair *language = 0;
     char locale_buf[64] = "";
-    char *cp;
 
     /* default to process locale if pLocale == NULL */
     if( NULL == pLocale )
@@ -808,7 +807,7 @@ rtl_TextEncoding osl_getTextEncodingFromLocale( rtl_Locale * pLocale )
              *  e.g. de.ISO8859-15 or de.ISO8859-15 at euro which strongly indicates what
              *  charset to use
              */
-            cp = strrchr( locale_buf, '.' );
+            char* cp = strrchr( locale_buf, '.' );
 
             if( NULL != cp )
             {
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index a99cc15..90b9765 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -1566,32 +1566,32 @@ namespace osl_FileStatus
 
         void check_FileType(osl::FileStatus const& _rFileStatus )
         {
-            bool bOK = false;
-                if ( _rFileStatus.isValid(osl_FileStatus_Mask_FileName))
+            if ( _rFileStatus.isValid(osl_FileStatus_Mask_FileName))
+            {
+                rtl::OUString suFilename = _rFileStatus.getFileName();
+
+                if ( _rFileStatus.isValid(osl_FileStatus_Mask_Type))
                 {
-                    rtl::OUString suFilename = _rFileStatus.getFileName();
+                    osl::FileStatus::Type eType = _rFileStatus.getFileType();
+                    bool bOK = false;
 
-                    if ( _rFileStatus.isValid(osl_FileStatus_Mask_Type))
+                    if ( compareFileName( suFilename, aTmpName2) )
                     {
-                        osl::FileStatus::Type eType = _rFileStatus.getFileType();
-
-                        if ( compareFileName( suFilename, aTmpName2) )
-                        {
-                            // regular
-                            bOK = ( eType == osl::FileStatus::Regular );
-                        }
-                        if ( compareFileName( suFilename, aTmpName1) )
-                        {
-                            // directory
-                            bOK = ( eType == ::osl::FileStatus::Directory );
-                        }
+                        // regular
+                        bOK = ( eType == osl::FileStatus::Regular );
+                    }
+                    if ( compareFileName( suFilename, aTmpName1) )
+                    {
+                        // directory
+                        bOK = ( eType == ::osl::FileStatus::Directory );
+                    }
 
-                        CPPUNIT_ASSERT_MESSAGE( "test for getFileType function: ",
-                                     bOK );
-        }
+                    CPPUNIT_ASSERT_MESSAGE( "test for getFileType function: ",
+                                 bOK );
                 }
-                // LLA: it's not a bug, if a FileStatus not exist, so no else
             }
+            // LLA: it's not a bug, if a FileStatus not exist, so no else
+        }
 
         void getFileType_002()
         {
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 0dda665..9e5e577 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1216,17 +1216,14 @@ void Test::testValueIterator()
     for (SCCOL i = 1; i <= 3; ++i)
         m_pDoc->SetValue(ScAddress(i,2,0), i);
 
-    double fVal;
-    sal_uInt16 nErr;
-
     {
         const double aChecks[] = { 1.0, 2.0, 3.0 };
         size_t nCheckLen = SAL_N_ELEMENTS(aChecks);
-
         ScValueIterator aIter(m_pDoc, ScRange(1,2,0,3,2,0));
         bool bHas = false;
-
         size_t nCheckPos = 0;
+        double fVal;
+        sal_uInt16 nErr;
         for (bHas = aIter.GetFirst(fVal, nErr); bHas; bHas = aIter.GetNext(fVal, nErr), ++nCheckPos)
         {
             CPPUNIT_ASSERT_MESSAGE("Iteration longer than expected.", nCheckPos < nCheckLen);
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 8fafa7b..221c1d6 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -5798,10 +5798,9 @@ void ScDocument::UpdStlShtPtrsFrmNms()
     ScDocumentPool* pPool = xPoolHelper->GetDocPool();
 
     sal_uInt32 nCount = pPool->GetItemCount2(ATTR_PATTERN);
-    ScPatternAttr* pPattern;
     for (sal_uInt32 i=0; i<nCount; i++)
     {
-        pPattern = const_cast<ScPatternAttr*>(static_cast<const ScPatternAttr*>(pPool->GetItem2(ATTR_PATTERN, i)));
+        ScPatternAttr* pPattern = const_cast<ScPatternAttr*>(static_cast<const ScPatternAttr*>(pPool->GetItem2(ATTR_PATTERN, i)));
         if (pPattern)
             pPattern->UpdateStyleSheet(this);
     }
@@ -5813,10 +5812,9 @@ void ScDocument::StylesToNames()
     ScDocumentPool* pPool = xPoolHelper->GetDocPool();
 
     sal_uInt32 nCount = pPool->GetItemCount2(ATTR_PATTERN);
-    ScPatternAttr* pPattern;
     for (sal_uInt32 i=0; i<nCount; i++)
     {
-        pPattern = const_cast<ScPatternAttr*>(static_cast<const ScPatternAttr*>(pPool->GetItem2(ATTR_PATTERN, i)));
+        ScPatternAttr* pPattern = const_cast<ScPatternAttr*>(static_cast<const ScPatternAttr*>(pPool->GetItem2(ATTR_PATTERN, i)));
         if (pPattern)
             pPattern->StyleToName();
     }
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 3ad5b2f..df81cfd 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1800,7 +1800,6 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, d
     if (!aCell.hasString())
         return;
 
-    bool bFormula = false;  //TODO: pass as parameter
     long nPixel = aCol[rCol].GetTextWidth(nRow);
 
     // Width already calculated in Idle-Handler ?
@@ -1808,7 +1807,7 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, d
     {
         ScNeededSizeOptions aOptions;
         aOptions.bTotalSize  = true;
-        aOptions.bFormula    = bFormula;
+        aOptions.bFormula    = false; //TODO: pass as parameter
         aOptions.bSkipMerged = false;
 
         Fraction aZoom(1,1);
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 1b6a5bc..b4f143e 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -931,8 +931,6 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
 
 void ScTable::TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SCROW nRow1, SCROW nRow2)
 {
-    bool bCloneCaption = true;
-
     sc::CellNoteStoreType::const_iterator itBlk = aCol[nCol].maCellNotes.begin(), itBlkEnd = aCol[nCol].maCellNotes.end();
 
     // Locate the top row position.
@@ -979,7 +977,7 @@ void ScTable::TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SC
                         ScPostIt* pNote = *itData;
                         if (pNote)
                         {
-                            ScPostIt* pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), *pTransClip->pDocument, aDestPos, bCloneCaption );
+                            ScPostIt* pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), *pTransClip->pDocument, aDestPos, true );
                             pTransClip->pDocument->SetNote(aDestPos, pClonedNote);
                         }
                     }
@@ -996,7 +994,7 @@ void ScTable::TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SC
                         ScPostIt* pNote = *itData;
                         if (pNote)
                         {
-                            ScPostIt* pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), *pTransClip->pDocument, aDestPos, bCloneCaption );
+                            ScPostIt* pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), *pTransClip->pDocument, aDestPos, true );
                             pTransClip->pDocument->SetNote(aDestPos, pClonedNote);
                         }
                     }
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 0c0001b..5a59e5c 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -1742,9 +1742,9 @@ bool ScInterpreter::RateIteration( double fNper, double fPayment, double fPv,
     if (fNper == ::rtl::math::round( fNper, 0, rtl_math_RoundingMode_Corrected ))
     { // Nper is an integer value
         fX = fGuess;
-        double fPowN, fPowNminus1;  // for (1.0+fX)^Nper and (1.0+fX)^(Nper-1)
         while (!bFound && nCount < nIterationsMax)
         {
+            double fPowN, fPowNminus1;  // for (1.0+fX)^Nper and (1.0+fX)^(Nper-1)
             fPowNminus1 = pow( 1.0+fX, fNper-1.0);
             fPowN = fPowNminus1 * (1.0+fX);
             if (rtl::math::approxEqual( fabs(fX), 0.0))
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index e1ecf4b..73e02d7 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -637,8 +637,7 @@ void XclImpAutoFilterData::ReadAutoFilter(
 
     sal_uInt8   nType, nOper, nBoolErr, nVal;
     sal_Int32   nRK;
-    double  fVal;
-    bool bIgnore;
+    double      fVal;
 
     sal_uInt8 nStrLen[2] = { 0, 0 };
     ScQueryEntry aEntries[2];
@@ -647,7 +646,7 @@ void XclImpAutoFilterData::ReadAutoFilter(
     {
         ScQueryEntry& rEntry = aEntries[nE];
         ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
-        bIgnore = false;
+        bool bIgnore = false;
 
         nType = rStrm.ReaduInt8();
         nOper = rStrm.ReaduInt8();
diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx
index ae59270..0ac150c 100644
--- a/sc/source/filter/xml/XMLStylesExportHelper.cxx
+++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx
@@ -594,53 +594,53 @@ void ScRowFormatRanges::AddRange(ScMyRowFormatRange& rFormatRange)
         return;
     sal_Int32 nPrevIndex = -1;
     bool bPrevAutoStyle = true;
+
+    sal_uInt32 nPrevStartCol(rFormatRange.nStartColumn);
+    OSL_ENSURE( static_cast<size_t>(nPrevStartCol) < pColDefaults->size(), "nPrevStartCol out of bounds");
+    sal_uInt32 nRepeat;
+    if (static_cast<size_t>(nPrevStartCol) < pColDefaults->size())
     {
-        sal_uInt32 nPrevStartCol(rFormatRange.nStartColumn);
-        OSL_ENSURE( static_cast<size_t>(nPrevStartCol) < pColDefaults->size(), "nPrevStartCol out of bounds");
-        sal_uInt32 nRepeat;
-        if (static_cast<size_t>(nPrevStartCol) < pColDefaults->size())
+        nRepeat = (*pColDefaults)[nPrevStartCol].nRepeat;
+        nPrevIndex = (*pColDefaults)[nPrevStartCol].nIndex;
+        bPrevAutoStyle = (*pColDefaults)[nPrevStartCol].bIsAutoStyle;
+    }
+    else
+    {
+        /* Again, this is to prevent out-of-bounds accesses, so FIXME
+         * elsewhere! */
+        if (pColDefaults->empty())
         {
-            nRepeat = (*pColDefaults)[nPrevStartCol].nRepeat;
-            nPrevIndex = (*pColDefaults)[nPrevStartCol].nIndex;
-            bPrevAutoStyle = (*pColDefaults)[nPrevStartCol].bIsAutoStyle;
+            nRepeat = 1;
+            nPrevIndex = -1;
+            bPrevAutoStyle = false;
         }
         else
         {
-            /* Again, this is to prevent out-of-bounds accesses, so FIXME
-             * elsewhere! */
-            if (pColDefaults->empty())
-            {
-                nRepeat = 1;
-                nPrevIndex = -1;
-                bPrevAutoStyle = false;
-            }
-            else
-            {
-                nRepeat = (*pColDefaults)[pColDefaults->size()-1].nRepeat;
-                nPrevIndex = (*pColDefaults)[pColDefaults->size()-1].nIndex;
-                bPrevAutoStyle = (*pColDefaults)[pColDefaults->size()-1].bIsAutoStyle;
-            }
+            nRepeat = (*pColDefaults)[pColDefaults->size()-1].nRepeat;
+            nPrevIndex = (*pColDefaults)[pColDefaults->size()-1].nIndex;
+            bPrevAutoStyle = (*pColDefaults)[pColDefaults->size()-1].bIsAutoStyle;
         }
-        sal_uInt32 nEnd = nPrevStartCol + rFormatRange.nRepeatColumns;
-        for(sal_uInt32 i = nPrevStartCol + nRepeat; i < nEnd && i < pColDefaults->size(); i += (*pColDefaults)[i].nRepeat)
+    }
+    sal_uInt32 nEnd = nPrevStartCol + rFormatRange.nRepeatColumns;
+    for(sal_uInt32 i = nPrevStartCol + nRepeat; i < nEnd && i < pColDefaults->size(); i += (*pColDefaults)[i].nRepeat)
+    {
+        OSL_ENSURE(sal_uInt32(nPrevStartCol + nRepeat) <= nEnd, "something wents wrong");
+        if ((nPrevIndex != (*pColDefaults)[i].nIndex) ||
+            (bPrevAutoStyle != (*pColDefaults)[i].bIsAutoStyle))
         {
-            OSL_ENSURE(sal_uInt32(nPrevStartCol + nRepeat) <= nEnd, "something wents wrong");
-            if ((nPrevIndex != (*pColDefaults)[i].nIndex) ||
-                (bPrevAutoStyle != (*pColDefaults)[i].bIsAutoStyle))
-            {
-                AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange);
-                nPrevStartCol = i;
-                nRepeat = (*pColDefaults)[i].nRepeat;
-                nPrevIndex = (*pColDefaults)[i].nIndex;
-                bPrevAutoStyle = (*pColDefaults)[i].bIsAutoStyle;
-            }
-            else
-                nRepeat += (*pColDefaults)[i].nRepeat;
+            AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange);
+            nPrevStartCol = i;
+            nRepeat = (*pColDefaults)[i].nRepeat;
+            nPrevIndex = (*pColDefaults)[i].nIndex;
+            bPrevAutoStyle = (*pColDefaults)[i].bIsAutoStyle;
         }
-        if (sal_uInt32(nPrevStartCol + nRepeat) > nEnd)
-            nRepeat = nEnd - nPrevStartCol;
-        AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange);
+        else
+            nRepeat += (*pColDefaults)[i].nRepeat;
     }
+    if (sal_uInt32(nPrevStartCol + nRepeat) > nEnd)
+        nRepeat = nEnd - nPrevStartCol;
+    AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange);
+
 }
 
 bool ScRowFormatRanges::GetNext(ScMyRowFormatRange& aFormatRange)


More information about the Libreoffice-commits mailing list