cppcheck:variableScope

Change-Id: I037feb335499629300309851dcda3bb661f03d4f
Reviewed-on: https://gerrit.libreoffice.org/19316
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Noel Grandin 2015-10-12 07:45:01 +02:00
parent 898aff0d19
commit ccc5ea08d6
22 changed files with 119 additions and 153 deletions

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -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) ;

View File

@ -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 )
{

View File

@ -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
{

View File

@ -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"))

View File

@ -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);

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -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 );
}

View File

@ -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@euro which strongly indicates what
* charset to use
*/
cp = strrchr( locale_buf, '.' );
char* cp = strrchr( locale_buf, '.' );
if( NULL != cp )
{

View File

@ -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();
// regular
bOK = ( eType == osl::FileStatus::Regular );
}
if ( compareFileName( suFilename, aTmpName1) )
{
// directory
bOK = ( eType == ::osl::FileStatus::Directory );
}
if ( compareFileName( suFilename, aTmpName2) )
{
// 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()
{

View File

@ -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);

View File

@ -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();
}

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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))

View File

@ -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();

View File

@ -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)
{
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;
}
if (sal_uInt32(nPrevStartCol + nRepeat) > nEnd)
nRepeat = nEnd - nPrevStartCol;
AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange);
}
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))
{
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;
}
if (sal_uInt32(nPrevStartCol + nRepeat) > nEnd)
nRepeat = nEnd - nPrevStartCol;
AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange);
}
bool ScRowFormatRanges::GetNext(ScMyRowFormatRange& aFormatRange)