summaryrefslogtreecommitdiff
path: root/sc/source/ui/unoobj
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-01-15 09:09:22 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-01-16 11:05:47 +0100
commitd08425c14b29bbac9f33c234f89b451388cd1d7c (patch)
treefa441dcaa912692c2e10f6189337446147400bfd /sc/source/ui/unoobj
parent4c9caae6c8ab608688a68be2c81bde2dd40315b7 (diff)
use unique_ptr in sc
Change-Id: If64b50919002f1f7376602f6e9cfb24e2184263b Reviewed-on: https://gerrit.libreoffice.org/66417 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/ui/unoobj')
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx65
1 files changed, 30 insertions, 35 deletions
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 998e4c968d58..faf6c2b2b96e 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -5599,49 +5599,44 @@ uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFil
uno::Reference<sheet::XCellRangeAddressable> xAddr( xObject, uno::UNO_QUERY );
ScDocShell* pDocSh = GetDocShell();
- if ( pDocSh && xAddr.is() )
+ if ( !pDocSh || !xAddr.is() )
{
- //! check if xObject is in the same document
+ OSL_FAIL("no document or no area");
+ return nullptr;
+ }
- ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh); //! instead from object?
+ //! check if xObject is in the same document
- ScQueryParam aParam = pNew->GetParam();
- aParam.bHasHeader = true;
+ std::unique_ptr<ScFilterDescriptor> pNew(new ScFilterDescriptor(pDocSh)); //! instead from object?
- table::CellRangeAddress aDataAddress(xAddr->getRangeAddress());
- aParam.nCol1 = static_cast<SCCOL>(aDataAddress.StartColumn);
- aParam.nRow1 = static_cast<SCROW>(aDataAddress.StartRow);
- aParam.nCol2 = static_cast<SCCOL>(aDataAddress.EndColumn);
- aParam.nRow2 = static_cast<SCROW>(aDataAddress.EndRow);
- aParam.nTab = aDataAddress.Sheet;
+ ScQueryParam aParam = pNew->GetParam();
+ aParam.bHasHeader = true;
- ScDocument& rDoc = pDocSh->GetDocument();
- if (rDoc.CreateQueryParam(aRange, aParam))
- {
- // FilterDescriptor contains the counted fields inside the area
- SCCOLROW nFieldStart = aParam.bByRow ?
- static_cast<SCCOLROW>(aDataAddress.StartColumn) :
- static_cast<SCCOLROW>(aDataAddress.StartRow);
- SCSIZE nCount = aParam.GetEntryCount();
- for (SCSIZE i=0; i<nCount; i++)
- {
- ScQueryEntry& rEntry = aParam.GetEntry(i);
- if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
- rEntry.nField -= nFieldStart;
- }
+ table::CellRangeAddress aDataAddress(xAddr->getRangeAddress());
+ aParam.nCol1 = static_cast<SCCOL>(aDataAddress.StartColumn);
+ aParam.nRow1 = static_cast<SCROW>(aDataAddress.StartRow);
+ aParam.nCol2 = static_cast<SCCOL>(aDataAddress.EndColumn);
+ aParam.nRow2 = static_cast<SCROW>(aDataAddress.EndRow);
+ aParam.nTab = aDataAddress.Sheet;
- pNew->SetParam( aParam );
- return pNew;
- }
- else
- {
- delete pNew;
- return nullptr;
- }
+ ScDocument& rDoc = pDocSh->GetDocument();
+ if (!rDoc.CreateQueryParam(aRange, aParam))
+ return nullptr;
+
+ // FilterDescriptor contains the counted fields inside the area
+ SCCOLROW nFieldStart = aParam.bByRow ?
+ static_cast<SCCOLROW>(aDataAddress.StartColumn) :
+ static_cast<SCCOLROW>(aDataAddress.StartRow);
+ SCSIZE nCount = aParam.GetEntryCount();
+ for (SCSIZE i=0; i<nCount; i++)
+ {
+ ScQueryEntry& rEntry = aParam.GetEntry(i);
+ if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
+ rEntry.nField -= nFieldStart;
}
- OSL_FAIL("no document or no area");
- return nullptr;
+ pNew->SetParam( aParam );
+ return pNew.release();
}
// XSubTotalSource