Kaydet (Commit) 9fd89a59 authored tarafından Łukasz Hryniuk's avatar Łukasz Hryniuk Kaydeden (comit) Noel Grandin

fdo#39440 reduce scope of local variables

Beside scope changes, it fixes lack of initialization in a few places.

Change-Id: Ia09fdb9845d8ac17256330a5ec5168401c84f0f2
Reviewed-on: https://gerrit.libreoffice.org/13755Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst a527ad98
......@@ -49,14 +49,14 @@ bool eliminate( Matrix& matrix,
const BaseType& minPivot )
{
BaseType temp;
int max, i, j, k; /* *must* be signed, when looping like: j>=0 ! */
/* i, j, k *must* be signed, when looping like: j>=0 ! */
/* eliminate below main diagonal */
for(i=0; i<cols-1; ++i)
for(int i=0; i<cols-1; ++i)
{
/* find best pivot */
max = i;
for(j=i+1; j<rows; ++j)
int max = i;
for(int j=i+1; j<rows; ++j)
if( fabs(matrix[ j*cols + i ]) > fabs(matrix[ max*cols + i ]) )
max = j;
......@@ -65,7 +65,7 @@ bool eliminate( Matrix& matrix,
return false; /* pivot too small! */
/* interchange rows 'max' and 'i' */
for(k=0; k<cols; ++k)
for(int k=0; k<cols; ++k)
{
temp = matrix[ i*cols + k ];
matrix[ i*cols + k ] = matrix[ max*cols + k ];
......@@ -73,8 +73,8 @@ bool eliminate( Matrix& matrix,
}
/* eliminate column */
for(j=i+1; j<rows; ++j)
for(k=cols-1; k>=i; --k)
for(int j=i+1; j<rows; ++j)
for(int k=cols-1; k>=i; --k)
matrix[ j*cols + k ] -= matrix[ i*cols + k ] *
matrix[ j*cols + i ] / matrix[ i*cols + i ];
}
......@@ -110,13 +110,13 @@ bool substitute( const Matrix& matrix,
Vector& result )
{
BaseType temp;
int j,k; /* *must* be signed, when looping like: j>=0 ! */
/* j, k *must* be signed, when looping like: j>=0 ! */
/* substitute backwards */
for(j=rows-1; j>=0; --j)
for(int j=rows-1; j>=0; --j)
{
temp = 0.0;
for(k=j+1; k<cols-1; ++k)
for(int k=j+1; k<cols-1; ++k)
temp += matrix[ j*cols + k ] * result[k];
if( matrix[ j*cols + j ] == 0.0 )
......
......@@ -287,13 +287,13 @@ void DrawCommandDispatch::execute( const OUString& rCommand, const Sequence< bea
ChartDrawMode eDrawMode = CHARTDRAW_SELECT;
SdrObjKind eKind = OBJ_NONE;
bool bCreate = false;
sal_uInt16 nFeatureId = 0;
OUString aBaseCommand;
OUString aCustomShapeType;
if ( parseCommandURL( rCommand, &nFeatureId, &aBaseCommand, &aCustomShapeType ) )
{
bool bCreate = false;
m_nFeatureId = nFeatureId;
m_aCustomShapeType = aCustomShapeType;
......
......@@ -136,7 +136,6 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
, bool bSearchForParallelAxisIfNothingIsFound )
{
sal_Int32 nNumberFormatKey(0);
bool bNumberFormatKeyFoundViaAttachedData = false;
sal_Int32 nAxisIndex = 0;
sal_Int32 nDimensionIndex = 1;
AxisHelper::getIndicesForAxis( xAxis, xCorrespondingCoordinateSystem, nDimensionIndex, nAxisIndex );
......@@ -235,6 +234,7 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
{
typedef ::std::map< sal_Int32, sal_Int32 > tNumberformatFrequency;
tNumberformatFrequency aKeyMap;
bool bNumberFormatKeyFoundViaAttachedData = false;
try
{
......
......@@ -1297,11 +1297,10 @@ bool lcl_moveSeriesOrCheckIfMoveIsAllowed(
{
uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
//find position of series.
bool bFound = false;
if( xGivenDataSeries.is() && xCooSysContainer.is() )
{
//find position of series.
bool bFound = false;
uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
for( sal_Int32 nCS = 0; !bFound && nCS < aCooSysList.getLength(); ++nCS )
......
......@@ -1179,10 +1179,10 @@ SfxItemSet* OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId )
pRet->Put(aOptSet);
utl::MiscCfg aMisc;
const SfxPoolItem* pItem;
SfxViewFrame* pViewFrame = SfxViewFrame::Current();
if ( pViewFrame )
{
const SfxPoolItem* pItem = NULL;
SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
// miscellaneous - Year2000
......@@ -1229,11 +1229,11 @@ SfxItemSet* OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId )
aHyphen.GetMinLead() = (sal_uInt8)nMinLead;
aHyphen.GetMinTrail() = (sal_uInt8)nMinTrail;
const SfxPoolItem* pItem;
SfxPoolItem* pClone;
SfxViewFrame* pViewFrame = SfxViewFrame::Current();
if ( pViewFrame )
{
const SfxPoolItem* pItem = NULL;
SfxPoolItem* pClone = NULL;
SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_LANGUAGE, pItem))
pRet->Put(SfxUInt16Item(SID_ATTR_LANGUAGE, static_cast<const SvxLanguageItem*>(pItem)->GetLanguage()));
......@@ -1312,7 +1312,7 @@ void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet
case SID_GENERAL_OPTIONS:
{
utl::MiscCfg aMisc;
const SfxPoolItem* pItem;
const SfxPoolItem* pItem = NULL;
SfxItemSet aOptSet(SfxGetpApp()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER );
aOptSet.Put(rSet);
if(aOptSet.Count())
......@@ -1386,7 +1386,7 @@ void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet
void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet)
{
bool bSaveSpellCheck = false;
const SfxPoolItem* pItem;
const SfxPoolItem* pItem = NULL;
if ( SfxItemState::SET == rSet.GetItemState( SID_SPELL_MODIFIED, false, &pItem ) )
{
......@@ -1407,7 +1407,7 @@ void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet)
if ( pViewFrame )
{
SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
pItem = 0;
pItem = NULL;
if(SfxItemState::SET == rSet.GetItemState( SID_ATTR_LANGUAGE, false, &pItem ))
{
pDispatch->Execute(pItem->Which(), SfxCallMode::ASYNCHRON, pItem, 0L);
......
......@@ -306,10 +306,10 @@ sal_Int32 ReadThroughComponent(
if ( xStorage.is() )
{
uno::Reference< io::XStream > xDocStream;
bool bEncrypted = false;
try
{
bool bEncrypted = false;
// open stream (and set parser input)
OUString sStreamName = OUString::createFromAscii(pStreamName);
if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) )
......
......@@ -1669,12 +1669,11 @@ OUString OFieldDescControl::getControlDefault( const OFieldDescription* _pFieldD
if ( bCheck )
{
sal_uInt32 nFormatKey;
bool bTextFormat = false;
try
{
double nValue = 0.0;
bTextFormat = isTextFormat(_pFieldDescr,nFormatKey);
bool bTextFormat = isTextFormat(_pFieldDescr,nFormatKey);
if ( _pFieldDescr->GetControlDefault() >>= sDefault )
{
if ( !bTextFormat )
......
......@@ -85,9 +85,9 @@ SvTreeListEntry* OTableWindowListBox::GetEntryFromText( const OUString& rEntryTe
OJoinDesignView* pView = m_pTabWin->getDesignView();
OJoinController& rController = pView->getController();
bool bCase = false;
try
{
bool bCase = false;
Reference<XConnection> xConnection = rController.getConnection();
if(xConnection.is())
{
......
......@@ -1167,13 +1167,13 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou
}
++nRowCount;
bool bInsertAutoIncrement = true;
ODatabaseExport::TPositions::const_iterator aPosIter = aColumnMapping.begin();
ODatabaseExport::TPositions::const_iterator aPosEnd = aColumnMapping.end();
aCopyEvent.Error.clear();
try
{
bool bInsertAutoIncrement = true;
// notify listeners
m_aCopyTableListeners.notifyEach( &XCopyTableListener::copyingRow, aCopyEvent );
......
......@@ -2690,7 +2690,6 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent )
void Desktop::OpenSplashScreen()
{
const CommandLineArgs &rCmdLine = GetCommandLineArgs();
bool bVisible = false;
// Show intro only if this is normal start (e.g. no server, no quickstart, no printing )
if ( !rCmdLine.IsInvisible() &&
!rCmdLine.IsHeadless() &&
......@@ -2726,7 +2725,7 @@ void Desktop::OpenSplashScreen()
if ( rCmdLine.HasSplashPipe() )
aSplashService = "com.sun.star.office.PipeSplashScreen";
bVisible = true;
bool bVisible = true;
Sequence< Any > aSeq( 2 );
aSeq[0] <<= bVisible;
aSeq[1] <<= aAppName;
......
......@@ -680,7 +680,6 @@ Reference<css::deployment::XPackage> ExtensionManager::addExtension(
Reference<css::deployment::XPackage> xExtensionBackup;
uno::Any excOccurred2;
bool bUserDisabled = false;
bool bCanInstall = doChecksForAddExtension(
xPackageManager,
properties,
......@@ -690,6 +689,7 @@ Reference<css::deployment::XPackage> ExtensionManager::addExtension(
xOldExtension );
{
bool bUserDisabled = false;
// In this garded section (getMutex) we must not use the argument xCmdEnv
// because it may bring up dialogs (XInteractionHandler::handle) this
//may potententially deadlock. See issue
......
......@@ -454,12 +454,12 @@ void SvxRTFParser::ReadColorTable()
void SvxRTFParser::ReadFontTable()
{
int nToken;
int nToken = 0;
int _nOpenBrakets = 1; // the first was already detected earlier!!
vcl::Font* pFont = new vcl::Font();
short nFontNo(0), nInsFontNo (0);
OUString sAltNm, sFntNm;
bool bIsAltFntNm = false, bCheckNewFont;
bool bIsAltFntNm = false;
rtl_TextEncoding nSystemChar = lcl_GetDefaultTextEncodingForRTF();
pFont->SetCharSet( nSystemChar );
......@@ -467,7 +467,7 @@ void SvxRTFParser::ReadFontTable()
while( _nOpenBrakets && IsParserWorking() )
{
bCheckNewFont = false;
bool bCheckNewFont = false;
switch( ( nToken = GetNextToken() ))
{
case '}':
......@@ -601,7 +601,7 @@ void SvxRTFParser::ReadOLEData()
OUString& SvxRTFParser::GetTextToEndGroup( OUString& rStr )
{
rStr.clear();
int _nOpenBrakets = 1, nToken; // the first was already detected earlier!!
int _nOpenBrakets = 1, nToken = 0; // the first was already detected earlier!!
while( _nOpenBrakets && IsParserWorking() )
{
......@@ -661,7 +661,7 @@ util::DateTime SvxRTFParser::GetDateTimeStamp( )
void SvxRTFParser::ReadInfo( const sal_Char* pChkForVerNo )
{
int _nOpenBrakets = 1, nToken; // the first was already detected earlier!!
int _nOpenBrakets = 1, nToken = 0; // the first was already detected earlier!!
DBG_ASSERT(m_xDocProps.is(),
"SvxRTFParser::ReadInfo: no DocumentProperties");
OUString sStr, sComment;
......
......@@ -335,7 +335,6 @@ void PictWriter::WritePolygon(const Polygon & rPoly)
{
sal_uInt16 nDataSize,i,nSize;
short nMinX = 0, nMinY = 0, nMaxX = 0, nMaxY = 0;
short nx,ny;
Polygon aPoly(rPoly);
nSize=aPoly.GetSize();
......@@ -354,8 +353,8 @@ void PictWriter::WritePolygon(const Polygon & rPoly)
aSrcMapMode,
aTargetMapMode );
nx = (short) aPoint.X();
ny = (short) aPoint.Y();
short nx = (short) aPoint.X();
short ny = (short) aPoint.Y();
if ( i==0 || nMinX>nx )
nMinX=nx;
......@@ -1308,21 +1307,18 @@ void PictWriter::SetAttrForText()
void PictWriter::WriteTextArray(Point & rPoint, const OUString& rString, const long* pDXAry)
{
bool bDelta;
Point aPt;
if ( pDXAry == NULL )
WriteOpcode_Text( rPoint, rString, false );
else
{
bDelta = false;
bool bDelta = false;
sal_Int32 nLen = rString.getLength();
for ( sal_Int32 i = 0; i < nLen; i++ )
{
sal_Unicode c = rString[ i ];
if ( c && ( c != 0x20 ) )
{
aPt = rPoint;
Point aPt = rPoint;
if ( i > 0 )
aPt.X() += pDXAry[ i - 1 ];
......
......@@ -543,9 +543,6 @@ void SAL_CALL ToolbarsMenuController::statusChanged( const FeatureStateEvent& Ev
OUString aFeatureURL( Event.FeatureURL.Complete );
// All other status events will be processed here
bool bSetCheckmark = false;
bool bCheckmark = false;
osl::ClearableMutexGuard aLock( m_aMutex );
Reference< css::awt::XPopupMenu > xPopupMenu( m_xPopupMenu );
aLock.clear();
......@@ -560,6 +557,8 @@ void SAL_CALL ToolbarsMenuController::statusChanged( const FeatureStateEvent& Ev
if (!pVCLPopupMenu)
return;
bool bSetCheckmark = false;
bool bCheckmark = false;
for ( sal_uInt16 i = 0; i < pVCLPopupMenu->GetItemCount(); i++ )
{
sal_uInt16 nId = pVCLPopupMenu->GetItemId( i );
......
......@@ -283,7 +283,6 @@ void HelpLinker::initIndexerPreProcessor()
*/
void HelpLinker::link() throw(HelpProcessingException, BasicCodeTagger::TaggerException)
{
bool bIndexForExtension = true;
if( bExtensionMode )
{
......@@ -337,6 +336,7 @@ void HelpLinker::link() throw(HelpProcessingException, BasicCodeTagger::TaggerEx
// catch HelpProcessingException to avoid locking data bases
try
{
bool bIndexForExtension = true;
// lastly, initialize the indexBuilder
if ( (!bExtensionMode || bIndexForExtension) && !helpFiles.empty())
initIndexerPreProcessor();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment