summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-03-10 16:19:19 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-03-11 01:16:33 +0000
commitffe060e954d172f8603a4e9f625445e49132c7bf (patch)
tree4a939673cd597c0812261fe28da2103526ac51a2 /sc
parentd59358ee28f0cd3e1eb56a0a923f165304fc17c9 (diff)
V668 no sense in testing the result of new against null
Change-Id: I7783d96e40de7a8df794f143d2c7830bf3314218
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/tool/chartarr.cxx235
-rw-r--r--sc/source/core/tool/chgtrack.cxx16
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx7
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocument.cxx2
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx13
5 files changed, 127 insertions, 146 deletions
diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx
index c92977fe0cca..33cbddbde7ad 100644
--- a/sc/source/core/tool/chartarr.cxx
+++ b/sc/source/core/tool/chartarr.cxx
@@ -39,14 +39,11 @@ ScMemChart::ScMemChart(SCCOL nCols, SCROW nRows)
nColCnt = nCols;
pData = new double[nColCnt * nRowCnt];
- if (pData)
- {
- double *pFill = pData;
+ double *pFill = pData;
- for (SCCOL i = 0; i < nColCnt; i++)
- for (SCROW j = 0; j < nRowCnt; j++)
- *(pFill ++) = 0.0;
- }
+ for (SCCOL i = 0; i < nColCnt; i++)
+ for (SCROW j = 0; j < nRowCnt; j++)
+ *(pFill ++) = 0.0;
pColText = new OUString[nColCnt];
pRowText = new OUString[nRowCnt];
@@ -238,71 +235,69 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
// Data
ScMemChart* pMemChart = new ScMemChart( nColCount, nRowCount );
- if (pMemChart)
+
+ if ( bValidData )
{
- if ( bValidData )
+ bool bCalcAsShown = pDocument->GetDocOptions().IsCalcAsShown();
+ for (nCol=0; nCol<nColCount; nCol++)
{
- bool bCalcAsShown = pDocument->GetDocOptions().IsCalcAsShown();
- for (nCol=0; nCol<nColCount; nCol++)
+ for (nRow=0; nRow<nRowCount; nRow++)
{
- for (nRow=0; nRow<nRowCount; nRow++)
- {
- // DBL_MIN is a Hack for Chart to recognize empty cells.
- ScAddress aPos(aCols[nCol], aRows[nRow], nTab1);
- double nVal = getCellValue(*pDocument, aPos, DBL_MIN, bCalcAsShown);
- pMemChart->SetData(nCol, nRow, nVal);
- }
+ // DBL_MIN is a Hack for Chart to recognize empty cells.
+ ScAddress aPos(aCols[nCol], aRows[nRow], nTab1);
+ double nVal = getCellValue(*pDocument, aPos, DBL_MIN, bCalcAsShown);
+ pMemChart->SetData(nCol, nRow, nVal);
}
}
- else
- {
- // Flag marking data as invalid?
- for (nCol=0; nCol<nColCount; nCol++)
- for (nRow=0; nRow<nRowCount; nRow++)
- pMemChart->SetData( nCol, nRow, DBL_MIN );
- }
+ }
+ else
+ {
+ // Flag marking data as invalid?
+ for (nCol=0; nCol<nColCount; nCol++)
+ for (nRow=0; nRow<nRowCount; nRow++)
+ pMemChart->SetData( nCol, nRow, DBL_MIN );
+ }
- // Column Header
+ // Column Header
- for (nCol=0; nCol<nColCount; nCol++)
+ for (nCol=0; nCol<nColCount; nCol++)
+ {
+ OUString aString;
+ if (HasColHeaders())
+ aString = pDocument->GetString(aCols[nCol], nStrRow, nTab1);
+ if (aString.isEmpty())
{
- OUString aString;
- if (HasColHeaders())
- aString = pDocument->GetString(aCols[nCol], nStrRow, nTab1);
- if (aString.isEmpty())
- {
- OUStringBuffer aBuf;
- aBuf.append(ScGlobal::GetRscString(STR_COLUMN));
- aBuf.append(' ');
+ OUStringBuffer aBuf;
+ aBuf.append(ScGlobal::GetRscString(STR_COLUMN));
+ aBuf.append(' ');
- ScAddress aPos( aCols[ nCol ], 0, 0 );
- aBuf.append(aPos.Format(SCA_VALID_COL, NULL));
+ ScAddress aPos( aCols[ nCol ], 0, 0 );
+ aBuf.append(aPos.Format(SCA_VALID_COL, NULL));
- aString = aBuf.makeStringAndClear();
- }
- pMemChart->SetColText( nCol, aString);
+ aString = aBuf.makeStringAndClear();
}
+ pMemChart->SetColText( nCol, aString);
+ }
- // Row Header
+ // Row Header
- for (nRow=0; nRow<nRowCount; nRow++)
+ for (nRow=0; nRow<nRowCount; nRow++)
+ {
+ OUString aString;
+ if (HasRowHeaders())
{
- OUString aString;
- if (HasRowHeaders())
- {
- ScAddress aAddr( nStrCol, aRows[nRow], nTab1 );
- aString = pDocument->GetString(nStrCol, aRows[nRow], nTab1);
- }
- if (aString.isEmpty())
- {
- OUStringBuffer aBuf;
- aBuf.append(ScGlobal::GetRscString(STR_ROW));
- aBuf.append(' ');
- aBuf.append(static_cast<sal_Int32>(aRows[nRow]+1));
- aString = aBuf.makeStringAndClear();
- }
- pMemChart->SetRowText( nRow, aString);
+ ScAddress aAddr( nStrCol, aRows[nRow], nTab1 );
+ aString = pDocument->GetString(nStrCol, aRows[nRow], nTab1);
}
+ if (aString.isEmpty())
+ {
+ OUStringBuffer aBuf;
+ aBuf.append(ScGlobal::GetRscString(STR_ROW));
+ aBuf.append(' ');
+ aBuf.append(static_cast<sal_Int32>(aRows[nRow]+1));
+ aString = aBuf.makeStringAndClear();
+ }
+ pMemChart->SetRowText( nRow, aString);
}
return pMemChart;
@@ -334,29 +329,14 @@ ScMemChart* ScChartArray::CreateMemChartMulti()
// Data
ScMemChart* pMemChart = new ScMemChart( nColCount, nRowCount );
- if (pMemChart)
+
+ SCSIZE nCol = 0;
+ SCSIZE nRow = 0;
+ bool bCalcAsShown = pDocument->GetDocOptions().IsCalcAsShown();
+ sal_uLong nIndex = 0;
+ if (bValidData)
{
- SCSIZE nCol = 0;
- SCSIZE nRow = 0;
- bool bCalcAsShown = pDocument->GetDocOptions().IsCalcAsShown();
- sal_uLong nIndex = 0;
- if (bValidData)
- {
- for ( nCol = 0; nCol < nColCount; nCol++ )
- {
- for ( nRow = 0; nRow < nRowCount; nRow++, nIndex++ )
- {
- double nVal = DBL_MIN; // Hack for Chart to recognize empty cells
- const ScAddress* pPos = GetPositionMap()->GetPosition( nIndex );
- if (pPos)
- // otherwise: Gap
- nVal = getCellValue(*pDocument, *pPos, DBL_MIN, bCalcAsShown);
-
- pMemChart->SetData(nCol, nRow, nVal);
- }
- }
- }
- else
+ for ( nCol = 0; nCol < nColCount; nCol++ )
{
for ( nRow = 0; nRow < nRowCount; nRow++, nIndex++ )
{
@@ -369,57 +349,70 @@ ScMemChart* ScChartArray::CreateMemChartMulti()
pMemChart->SetData(nCol, nRow, nVal);
}
}
+ }
+ else
+ {
+ for ( nRow = 0; nRow < nRowCount; nRow++, nIndex++ )
+ {
+ double nVal = DBL_MIN; // Hack for Chart to recognize empty cells
+ const ScAddress* pPos = GetPositionMap()->GetPosition( nIndex );
+ if (pPos)
+ // otherwise: Gap
+ nVal = getCellValue(*pDocument, *pPos, DBL_MIN, bCalcAsShown);
- //TODO: Label when gaps
+ pMemChart->SetData(nCol, nRow, nVal);
+ }
+ }
- // Column header
+ //TODO: Label when gaps
- SCCOL nPosCol = 0;
- for ( nCol = 0; nCol < nColCount; nCol++ )
- {
- OUString aString;
- const ScAddress* pPos = GetPositionMap()->GetColHeaderPosition( static_cast<SCCOL>(nCol) );
- if ( HasColHeaders() && pPos )
- aString = pDocument->GetString(pPos->Col(), pPos->Row(), pPos->Tab());
+ // Column header
- if (aString.isEmpty())
- {
- OUStringBuffer aBuf(ScGlobal::GetRscString(STR_COLUMN));
- aBuf.append(' ');
- if ( pPos )
- nPosCol = pPos->Col() + 1;
- else
- nPosCol++;
- ScAddress aPos( nPosCol - 1, 0, 0 );
- aBuf.append(aPos.Format(SCA_VALID_COL, NULL));
- aString = aBuf.makeStringAndClear();
- }
- pMemChart->SetColText( nCol, aString);
+ SCCOL nPosCol = 0;
+ for ( nCol = 0; nCol < nColCount; nCol++ )
+ {
+ OUString aString;
+ const ScAddress* pPos = GetPositionMap()->GetColHeaderPosition( static_cast<SCCOL>(nCol) );
+ if ( HasColHeaders() && pPos )
+ aString = pDocument->GetString(pPos->Col(), pPos->Row(), pPos->Tab());
+
+ if (aString.isEmpty())
+ {
+ OUStringBuffer aBuf(ScGlobal::GetRscString(STR_COLUMN));
+ aBuf.append(' ');
+ if ( pPos )
+ nPosCol = pPos->Col() + 1;
+ else
+ nPosCol++;
+ ScAddress aPos( nPosCol - 1, 0, 0 );
+ aBuf.append(aPos.Format(SCA_VALID_COL, NULL));
+ aString = aBuf.makeStringAndClear();
}
+ pMemChart->SetColText( nCol, aString);
+ }
- // Row header
+ // Row header
- SCROW nPosRow = 0;
- for ( nRow = 0; nRow < nRowCount; nRow++ )
- {
- OUString aString;
- const ScAddress* pPos = GetPositionMap()->GetRowHeaderPosition( nRow );
- if ( HasRowHeaders() && pPos )
- aString = pDocument->GetString(pPos->Col(), pPos->Row(), pPos->Tab());
+ SCROW nPosRow = 0;
+ for ( nRow = 0; nRow < nRowCount; nRow++ )
+ {
+ OUString aString;
+ const ScAddress* pPos = GetPositionMap()->GetRowHeaderPosition( nRow );
+ if ( HasRowHeaders() && pPos )
+ aString = pDocument->GetString(pPos->Col(), pPos->Row(), pPos->Tab());
- if (aString.isEmpty())
- {
- OUStringBuffer aBuf(ScGlobal::GetRscString(STR_ROW));
- aBuf.append(' ');
- if ( pPos )
- nPosRow = pPos->Row() + 1;
- else
- nPosRow++;
- aBuf.append(static_cast<sal_Int32>(nPosRow));
- aString = aBuf.makeStringAndClear();
- }
- pMemChart->SetRowText( nRow, aString);
+ if (aString.isEmpty())
+ {
+ OUStringBuffer aBuf(ScGlobal::GetRscString(STR_ROW));
+ aBuf.append(' ');
+ if ( pPos )
+ nPosRow = pPos->Row() + 1;
+ else
+ nPosRow++;
+ aBuf.append(static_cast<sal_Int32>(nPosRow));
+ aString = aBuf.makeStringAndClear();
}
+ pMemChart->SetRowText( nRow, aString);
}
return pMemChart;
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 957196008b9c..029d5028b332 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -4415,16 +4415,12 @@ sal_uLong ScChangeTrack::AddLoadedGenerated(
const ScCellValue& rNewCell, const ScBigRange& aBigRange, const OUString& sNewValue )
{
ScChangeActionContent* pAct = new ScChangeActionContent( --nGeneratedMin, rNewCell, aBigRange, pDoc, sNewValue );
- if ( pAct )
- {
- if ( pFirstGeneratedDelContent )
- pFirstGeneratedDelContent->pPrev = pAct;
- pAct->pNext = pFirstGeneratedDelContent;
- pFirstGeneratedDelContent = pAct;
- aGeneratedMap.insert( ::std::make_pair( pAct->GetActionNumber(), pAct ) );
- return pAct->GetActionNumber();
- }
- return 0;
+ if ( pFirstGeneratedDelContent )
+ pFirstGeneratedDelContent->pPrev = pAct;
+ pAct->pNext = pFirstGeneratedDelContent;
+ pFirstGeneratedDelContent = pAct;
+ aGeneratedMap.insert( ::std::make_pair( pAct->GetActionNumber(), pAct ) );
+ return pAct->GetActionNumber();
}
void ScChangeTrack::AppendCloned( ScChangeAction* pAppend )
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index b488821faee0..e6d7e3df0f6d 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3465,11 +3465,8 @@ void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape,
{
bIsChart = true;
SvXMLAttributeList* pAttrList = new SvXMLAttributeList();
- if ( pAttrList )
- {
- pAttrList->AddAttribute(
- GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken( XML_NOTIFY_ON_UPDATE_OF_RANGES ) ), sRanges );
- }
+ pAttrList->AddAttribute(
+ GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken( XML_NOTIFY_ON_UPDATE_OF_RANGES ) ), sRanges );
GetShapeExport()->exportShape( xShape, XMLShapeExportFlags::NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList );
}
}
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index fb17833245ae..b671c795d584 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -1195,7 +1195,7 @@ uno::Reference<XAccessibleRelationSet> ScChildrenShapes::GetRelationSet(const Sc
{
utl::AccessibleRelationSetHelper* pRelationSet = new utl::AccessibleRelationSetHelper();
- if(pData && pRelationSet && mpAccessibleDocument)
+ if (pData && mpAccessibleDocument)
{
uno::Reference<XAccessible> xAccessible = mpAccessibleDocument->GetAccessibleSpreadsheet(); // should be the current table
if (pData->pRelationCell && xAccessible.is())
diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
index f57792315988..c366349add68 100644
--- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
@@ -140,20 +140,15 @@ ScNotesChildren::~ScNotesChildren()
::accessibility::AccessibleTextHelper* ScNotesChildren::CreateTextHelper(const OUString& rString, const Rectangle& rVisRect, const ScAddress& aCellPos, bool bMarkNote, sal_Int32 nChildOffset) const
{
- ::accessibility::AccessibleTextHelper* pTextHelper = NULL;
-
::std::unique_ptr < ScAccessibleTextData > pAccessiblePreviewHeaderCellTextData
(new ScAccessibleNoteTextData(mpViewShell, rString, aCellPos, bMarkNote));
::std::unique_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(std::move(pAccessiblePreviewHeaderCellTextData)));
- pTextHelper = new ::accessibility::AccessibleTextHelper(std::move(pEditSource));
+ ::accessibility::AccessibleTextHelper* pTextHelper = new ::accessibility::AccessibleTextHelper(std::move(pEditSource));
- if (pTextHelper)
- {
- pTextHelper->SetEventSource(mpAccDoc);
- pTextHelper->SetStartIndex(nChildOffset);
- pTextHelper->SetOffset(rVisRect.TopLeft());
- }
+ pTextHelper->SetEventSource(mpAccDoc);
+ pTextHelper->SetStartIndex(nChildOffset);
+ pTextHelper->SetOffset(rVisRect.TopLeft());
return pTextHelper;
}