[Libreoffice-commits] core.git: 2 commits - sc/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Apr 10 06:42:49 UTC 2018


 sc/source/filter/xml/xmlexprt.cxx  |   77 ++++++++++++++++++-------------------
 sc/source/filter/xml/xmlexprt.hxx  |   22 +++++-----
 sc/source/ui/docshell/docsh3.cxx   |    5 --
 sc/source/ui/docshell/docsh4.cxx   |   11 ++---
 sc/source/ui/docshell/docshimp.hxx |   15 +------
 5 files changed, 59 insertions(+), 71 deletions(-)

New commits:
commit 7418f8f331c4a7d5195bb90d6a9025fb69fa816e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Apr 9 13:55:18 2018 +0200

    loplugin:useuniqueptr in DocShell_Impl
    
    Change-Id: I171dbce9ad9790e887a6618812eadfb746dee42f
    Reviewed-on: https://gerrit.libreoffice.org/52646
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index cc262620741c..e59bf0ea2d3c 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -451,10 +451,9 @@ SfxPrinter* ScDocShell::GetPrinter(bool bCreateIfNotExist)
 
 void ScDocShell::UpdateFontList()
 {
-    delete pImpl->pFontList;
     // pImpl->pFontList = new FontList( GetPrinter(), Application::GetDefaultDevice() );
-    pImpl->pFontList = new FontList(GetRefDevice(), nullptr);
-    SvxFontListItem aFontListItem( pImpl->pFontList, SID_ATTR_CHAR_FONTLIST );
+    pImpl->pFontList.reset(new FontList(GetRefDevice(), nullptr));
+    SvxFontListItem aFontListItem( pImpl->pFontList.get(), SID_ATTR_CHAR_FONTLIST );
     PutItem( aFontListItem );
 
     CalcOutputFactor();
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index c5d96d47b00b..8a4c6c9d8d77 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -763,15 +763,14 @@ void ScDocShell::Execute( SfxRequest& rReq )
                         : sfx2::DocumentInserter::Mode::Merge};
                     // start file dialog asynchronous
                     pImpl->bIgnoreLostRedliningWarning = true;
-                    delete pImpl->pRequest;
-                    pImpl->pRequest = new SfxRequest( rReq );
-                    delete pImpl->pDocInserter;
+                    pImpl->pRequest.reset(new SfxRequest( rReq ));
+                    pImpl->pDocInserter.reset();
 
                     ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
                     vcl::Window* pParent = pViewSh ? pViewSh->GetDialogParent() : nullptr;
 
-                    pImpl->pDocInserter = new ::sfx2::DocumentInserter(pParent ? pParent->GetFrameWeld() : nullptr,
-                        ScDocShell::Factory().GetFactoryName(), mode );
+                    pImpl->pDocInserter.reset( new ::sfx2::DocumentInserter(pParent ? pParent->GetFrameWeld() : nullptr,
+                        ScDocShell::Factory().GetFactoryName(), mode ) );
                     pImpl->pDocInserter->StartExecuteModal( LINK( this, ScDocShell, DialogClosedHdl ) );
                     return ;
                 }
@@ -1990,7 +1989,7 @@ void ScDocShell::GetState( SfxItemSet &rSet )
                 break;
 
             case SID_ATTR_CHAR_FONTLIST:
-                rSet.Put( SvxFontListItem( pImpl->pFontList, nWhich ) );
+                rSet.Put( SvxFontListItem( pImpl->pFontList.get(), nWhich ) );
                 break;
 
             case SID_NOTEBOOKBAR:
diff --git a/sc/source/ui/docshell/docshimp.hxx b/sc/source/ui/docshell/docshimp.hxx
index 9acec21110b7..9a451d802fb0 100644
--- a/sc/source/ui/docshell/docshimp.hxx
+++ b/sc/source/ui/docshell/docshimp.hxx
@@ -26,23 +26,14 @@
 struct DocShell_Impl
 {
     bool                    bIgnoreLostRedliningWarning;
-    FontList*               pFontList;
-    sfx2::DocumentInserter* pDocInserter;
-    SfxRequest*             pRequest;
+    std::unique_ptr<FontList>               pFontList;
+    std::unique_ptr<sfx2::DocumentInserter> pDocInserter;
+    std::unique_ptr<SfxRequest>             pRequest;
 
     DocShell_Impl() :
           bIgnoreLostRedliningWarning( false )
-        , pFontList( nullptr )
-        , pDocInserter( nullptr )
-        , pRequest( nullptr )
     {}
 
-    ~DocShell_Impl()
-    {
-        delete pFontList;
-        delete pDocInserter;
-        delete pRequest;
-    }
 };
 
 #endif
commit bd8dc772588b52f95b8682f6ec800bd8f2c58ec3
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Apr 9 13:55:03 2018 +0200

    loplugin:useuniqueptr in ScXMLExport
    
    Change-Id: I9f1fd5e008c1969d8f1d1d3668c64ddc31b5dc83
    Reviewed-on: https://gerrit.libreoffice.org/52645
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 1289cd238473..ec0833019240 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -360,17 +360,17 @@ ScXMLExport::ScXMLExport(
 {
     if (getExportFlags() & SvXMLExportFlags::CONTENT)
     {
-        pGroupColumns = new ScMyOpenCloseColumnRowGroup(*this, XML_TABLE_COLUMN_GROUP);
-        pGroupRows = new ScMyOpenCloseColumnRowGroup(*this, XML_TABLE_ROW_GROUP);
-        pColumnStyles = new ScColumnStyles();
-        pRowStyles = new ScRowStyles();
-        pRowFormatRanges = new ScRowFormatRanges();
-        pMergedRangesContainer = new ScMyMergedRangesContainer();
-        pValidationsContainer = new ScMyValidationsContainer();
+        pGroupColumns.reset( new ScMyOpenCloseColumnRowGroup(*this, XML_TABLE_COLUMN_GROUP) );
+        pGroupRows.reset( new ScMyOpenCloseColumnRowGroup(*this, XML_TABLE_ROW_GROUP) );
+        pColumnStyles.reset( new ScColumnStyles() );
+        pRowStyles.reset( new ScRowStyles() );
+        pRowFormatRanges.reset( new ScRowFormatRanges() );
+        pMergedRangesContainer.reset( new ScMyMergedRangesContainer() );
+        pValidationsContainer.reset( new ScMyValidationsContainer() );
         mpCellsItr.reset(new ScMyNotEmptyCellsIterator(*this));
-        pDefaults = new ScMyDefaultStyles;
+        pDefaults.reset( new ScMyDefaultStyles );
     }
-    pCellStyles = new ScFormatRangeStyles();
+    pCellStyles.reset( new ScFormatRangeStyles() );
 
     // document is not set here - create ScChangeTrackingExportHelper later
 
@@ -419,17 +419,17 @@ ScXMLExport::ScXMLExport(
 
 ScXMLExport::~ScXMLExport()
 {
-        delete pGroupColumns;
-        delete pGroupRows;
-        delete pColumnStyles;
-        delete pRowStyles;
-        delete pCellStyles;
-        delete pRowFormatRanges;
-        delete pMergedRangesContainer;
-        delete pValidationsContainer;
-        delete pChangeTrackingExportHelper;
-        delete pDefaults;
-        delete pNumberFormatAttributesExportHelper;
+    pGroupColumns.reset();
+    pGroupRows.reset();
+    pColumnStyles.reset();
+    pRowStyles.reset();
+    pCellStyles.reset();
+    pRowFormatRanges.reset();
+    pMergedRangesContainer.reset();
+    pValidationsContainer.reset();
+    pChangeTrackingExportHelper.reset();
+    pDefaults.reset();
+    pNumberFormatAttributesExportHelper.reset();
 }
 
 void ScXMLExport::SetSourceStream( const uno::Reference<io::XInputStream>& xNewStream )
@@ -1487,10 +1487,9 @@ void ScXMLExport::OpenRow(const sal_Int32 nTable, const sal_Int32 nStartRow, con
                 {
                     if (nRow < nEndRow)
                     {
-                        ScRowFormatRanges* pTempRowFormatRanges = new ScRowFormatRanges(pRowFormatRanges);
+                        ScRowFormatRanges* pTempRowFormatRanges = new ScRowFormatRanges(pRowFormatRanges.get());
                         OpenAndCloseRow(nPrevIndex, nRow - nEqualRows, nEqualRows, bPrevHidden, bPrevFiltered);
-                        delete pRowFormatRanges;
-                        pRowFormatRanges = pTempRowFormatRanges;
+                        pRowFormatRanges.reset(pTempRowFormatRanges);
                     }
                     else
                         OpenAndCloseRow(nPrevIndex, nRow - nEqualRows, nEqualRows, bPrevHidden, bPrevFiltered);
@@ -1549,7 +1548,7 @@ void ScXMLExport::ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32
     ScXMLCachedRowAttrAccess aRowAttr(pDoc);
     if (nStartRow == nEndRow)
     {
-        pCellStyles->GetFormatRanges(nStartCol, nEndCol, nStartRow, nSheet, pRowFormatRanges);
+        pCellStyles->GetFormatRanges(nStartCol, nEndCol, nStartRow, nSheet, pRowFormatRanges.get());
         if (nOpenRow == - 1)
             OpenRow(nSheet, nStartRow, 1, aRowAttr);
         WriteRowContent();
@@ -1559,7 +1558,7 @@ void ScXMLExport::ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32
     {
         if (nOpenRow > -1)
         {
-            pCellStyles->GetFormatRanges(nStartCol, pSharedData->GetLastColumn(nSheet), nStartRow, nSheet, pRowFormatRanges);
+            pCellStyles->GetFormatRanges(nStartCol, pSharedData->GetLastColumn(nSheet), nStartRow, nSheet, pRowFormatRanges.get());
             WriteRowContent();
             CloseRow(nStartRow);
             sal_Int32 nRows(1);
@@ -1567,7 +1566,7 @@ void ScXMLExport::ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32
             while (nRows < nTotalRows)
             {
                 pRowFormatRanges->Clear();
-                pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges);
+                pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges.get());
                 sal_Int32 nMaxRows = pRowFormatRanges->GetMaxRows();
                 OSL_ENSURE(nMaxRows, "something wents wrong");
                 if (nMaxRows >= nTotalRows - nRows)
@@ -1581,7 +1580,7 @@ void ScXMLExport::ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32
                     nRows += nMaxRows;
                 }
                 if (!pRowFormatRanges->GetSize())
-                    pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges);
+                    pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges.get());
                 WriteRowContent();
                 CloseRow(nStartRow + nRows - 1);
             }
@@ -1589,7 +1588,7 @@ void ScXMLExport::ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32
                 CloseRow(nStartRow);
             OpenRow(nSheet, nEndRow, 1, aRowAttr);
             pRowFormatRanges->Clear();
-            pCellStyles->GetFormatRanges(0, nEndCol, nEndRow, nSheet, pRowFormatRanges);
+            pCellStyles->GetFormatRanges(0, nEndCol, nEndRow, nSheet, pRowFormatRanges.get());
             WriteRowContent();
         }
         else
@@ -1598,7 +1597,7 @@ void ScXMLExport::ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32
             sal_Int32 nTotalRows(nEndRow - nStartRow + 1 - 1);
             while (nRows < nTotalRows)
             {
-                pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges);
+                pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges.get());
                 sal_Int32 nMaxRows = pRowFormatRanges->GetMaxRows();
                 if (nMaxRows >= nTotalRows - nRows)
                 {
@@ -1611,13 +1610,13 @@ void ScXMLExport::ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32
                     nRows += nMaxRows;
                 }
                 if (!pRowFormatRanges->GetSize())
-                    pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges);
+                    pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges.get());
                 WriteRowContent();
                 CloseRow(nStartRow + nRows - 1);
             }
             OpenRow(nSheet, nEndRow, 1, aRowAttr);
             pRowFormatRanges->Clear();
-            pCellStyles->GetFormatRanges(0, nEndCol, nEndRow, nSheet, pRowFormatRanges);
+            pCellStyles->GetFormatRanges(0, nEndCol, nEndRow, nSheet, pRowFormatRanges.get());
             WriteRowContent();
         }
     }
@@ -1680,8 +1679,8 @@ void ScXMLExport::FillColumnRowGroups()
         {
             ScOutlineArray& rCols(pOutlineTable->GetColArray());
             ScOutlineArray& rRows(pOutlineTable->GetRowArray());
-            FillFieldGroup(&rCols, pGroupColumns);
-            FillFieldGroup(&rRows, pGroupRows);
+            FillFieldGroup(&rCols, pGroupColumns.get());
+            FillFieldGroup(&rRows, pGroupRows.get());
             pSharedData->SetLastColumn(nCurrentTable, pGroupColumns->GetLast());
             pSharedData->SetLastRow(nCurrentTable, pGroupRows->GetLast());
         }
@@ -1914,7 +1913,7 @@ void ScXMLExport::ExportContent_()
         mpCellsItr->Clear();
         mpCellsItr->SetShapes( pSharedData->GetShapesContainer() );
         mpCellsItr->SetNoteShapes( pSharedData->GetNoteShapes() );
-        mpCellsItr->SetMergedRanges( pMergedRangesContainer );
+        mpCellsItr->SetMergedRanges( pMergedRangesContainer.get() );
         mpCellsItr->SetAreaLinks( &aAreaLinks );
         mpCellsItr->SetEmptyDatabaseRanges( &aEmptyRanges );
         mpCellsItr->SetDetectiveObj( pSharedData->GetDetectiveObjContainer() );
@@ -2967,7 +2966,7 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const uno::Reference<sheet::XSpre
     if (bHasRowHeader)
         pSharedData->SetLastRow(nTable, aRowHeaderRange.aEnd.Row());
     pDefaults->FillDefaultStyles(nTable, pSharedData->GetLastRow(nTable),
-        pSharedData->GetLastColumn(nTable), pCellStyles, pDoc);
+        pSharedData->GetLastColumn(nTable), pCellStyles.get(), pDoc);
     pRowFormatRanges->SetColDefaults(&pDefaults->GetColDefaults());
     pCellStyles->SetColDefaults(&pDefaults->GetColDefaults());
     ExportColumns(nTable, aColumnHeaderRange, bHasColumnHeader);
@@ -2975,7 +2974,7 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const uno::Reference<sheet::XSpre
     sal_Int32 nEqualCells(0);
     ScMyCell aCell;
     ScMyCell aPrevCell;
-    while (mpCellsItr->GetNext(aCell, pCellStyles))
+    while (mpCellsItr->GetNext(aCell, pCellStyles.get()))
     {
         if (bIsFirst)
         {
@@ -4968,8 +4967,8 @@ XMLShapeExport* ScXMLExport::CreateShapeExport()
 XMLNumberFormatAttributesExportHelper* ScXMLExport::GetNumberFormatAttributesExportHelper()
 {
     if (!pNumberFormatAttributesExportHelper)
-        pNumberFormatAttributesExportHelper = new XMLNumberFormatAttributesExportHelper(GetNumberFormatsSupplier(), *this );
-    return pNumberFormatAttributesExportHelper;
+        pNumberFormatAttributesExportHelper.reset(new XMLNumberFormatAttributesExportHelper(GetNumberFormatsSupplier(), *this ));
+    return pNumberFormatAttributesExportHelper.get();
 }
 
 void ScXMLExport::CollectUserDefinedNamespaces(const SfxItemPool* pPool, sal_uInt16 nAttrib)
@@ -5082,7 +5081,7 @@ void SAL_CALL ScXMLExport::setSourceDocument( const uno::Reference<lang::XCompon
         throw lang::IllegalArgumentException();
 
     // create ScChangeTrackingExportHelper after document is known
-    pChangeTrackingExportHelper = new ScChangeTrackingExportHelper(*this);
+    pChangeTrackingExportHelper.reset(new ScChangeTrackingExportHelper(*this));
 
     // Set the document's storage grammar corresponding to the ODF version that
     // is to be written.
diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx
index cb2c5df7c758..6107aa86d102 100644
--- a/sc/source/filter/xml/xmlexprt.hxx
+++ b/sc/source/filter/xml/xmlexprt.hxx
@@ -90,24 +90,24 @@ class ScXMLExport : public SvXMLExport
     rtl::Reference < SvXMLExportPropertyMapper >  xColumnStylesExportPropertySetMapper;
     rtl::Reference < SvXMLExportPropertyMapper >  xRowStylesExportPropertySetMapper;
     rtl::Reference < SvXMLExportPropertyMapper >  xTableStylesExportPropertySetMapper;
-    XMLNumberFormatAttributesExportHelper* pNumberFormatAttributesExportHelper;
+    std::unique_ptr<XMLNumberFormatAttributesExportHelper> pNumberFormatAttributesExportHelper;
     typedef std::unordered_map<sal_Int32, sal_Int32>  NumberFormatIndexMap;
     NumberFormatIndexMap                aNumFmtIndexMap;
     ScMySharedData*                     pSharedData;
-    ScColumnStyles*                     pColumnStyles;
-    ScRowStyles*                        pRowStyles;
-    ScFormatRangeStyles*                pCellStyles;
-    ScRowFormatRanges*                  pRowFormatRanges;
+    std::unique_ptr<ScColumnStyles>                     pColumnStyles;
+    std::unique_ptr<ScRowStyles>                        pRowStyles;
+    std::unique_ptr<ScFormatRangeStyles>                pCellStyles;
+    std::unique_ptr<ScRowFormatRanges>                  pRowFormatRanges;
     std::vector<OUString>               aTableStyles;
     ScRange                             aRowHeaderRange;
-    ScMyOpenCloseColumnRowGroup*        pGroupColumns;
-    ScMyOpenCloseColumnRowGroup*        pGroupRows;
-    ScMyDefaultStyles*                  pDefaults;
+    std::unique_ptr<ScMyOpenCloseColumnRowGroup>        pGroupColumns;
+    std::unique_ptr<ScMyOpenCloseColumnRowGroup>        pGroupRows;
+    std::unique_ptr<ScMyDefaultStyles>                  pDefaults;
     const ScMyCell*                     pCurrentCell;
 
-    ScMyMergedRangesContainer*  pMergedRangesContainer;
-    ScMyValidationsContainer*   pValidationsContainer;
-    ScChangeTrackingExportHelper*   pChangeTrackingExportHelper;
+    std::unique_ptr<ScMyMergedRangesContainer>  pMergedRangesContainer;
+    std::unique_ptr<ScMyValidationsContainer>   pValidationsContainer;
+    std::unique_ptr<ScChangeTrackingExportHelper> pChangeTrackingExportHelper;
     const OUString         sLayerID;
     OUString               sExternalRefTabStyleName;
     OUString               sAttrName;


More information about the Libreoffice-commits mailing list