[Libreoffice-commits] core.git: chart2/source comphelper/source connectivity/source l10ntools/source registry/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri May 28 07:45:38 UTC 2021


 chart2/source/controller/drawinglayer/ViewElementListProvider.cxx |   12 +-
 chart2/source/view/main/ChartView.cxx                             |   37 +++---
 chart2/source/view/main/VButton.cxx                               |   10 -
 comphelper/source/misc/backupfilehelper.cxx                       |   56 +++++-----
 connectivity/source/drivers/jdbc/Object.cxx                       |   16 +-
 l10ntools/source/helpex.cxx                                       |    4 
 l10ntools/source/helpmerge.cxx                                    |    6 -
 l10ntools/source/lngmerge.cxx                                     |    6 -
 registry/source/regimpl.cxx                                       |    8 -
 9 files changed, 77 insertions(+), 78 deletions(-)

New commits:
commit 164fecadfde2569cb5324017d9bf22e2963008b3
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu May 27 19:53:24 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri May 28 09:44:57 2021 +0200

    no need to allocate these on the heap
    
    Change-Id: Ic1a1577ed837d3fa2b7b99474f4cee30300628f6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116290
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
index f4f5ecfbd9d6..2f037e767f18 100644
--- a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
+++ b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
@@ -155,26 +155,26 @@ Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, co
     rtl::Reference<SdrPage> pPage = new SdrPage( *pModel, false );
     pPage->SetSize(Size(1000,1000));
     pModel->InsertPage( pPage.get(), 0 );
-    std::unique_ptr<SdrView> pView(new SdrView(*pModel, pVDev));
-    pView->hideMarkHandles();
-    SdrPageView* pPageView = pView->ShowSdrPage(pPage.get());
+    SdrView aView(*pModel, pVDev);
+    aView.hideMarkHandles();
+    SdrPageView* pPageView = aView.ShowSdrPage(pPage.get());
 
     // directly clone to target SdrModel
     pObj = pObj->CloneSdrObject(*pModel);
 
     pPage->NbcInsertObject(pObj);
-    pView->MarkObj(pObj,pPageView);
+    aView.MarkObj(pObj,pPageView);
     if( pSymbolShapeProperties )
         pObj->SetMergedItemSet(*pSymbolShapeProperties);
 
-    GDIMetaFile aMeta(pView->GetMarkedObjMetaFile());
+    GDIMetaFile aMeta(aView.GetMarkedObjMetaFile());
 
     Graphic aGraph(aMeta);
     Size aSize = pObj->GetSnapRect().GetSize();
     aGraph.SetPrefSize(aSize);
     aGraph.SetPrefMapMode(MapMode(MapUnit::Map100thMM));
 
-    pView->UnmarkAll();
+    aView.UnmarkAll();
     pObj=pPage->RemoveObject(0);
     SdrObject::Free( pObj );
 
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 387fa2ae8b40..143d0bcfc798 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2269,19 +2269,19 @@ void lcl_createButtons(const uno::Reference<drawing::XShapes>& xPageShapes,
         const css::uno::Sequence<chart2::data::PivotTableFieldEntry> aPivotFieldEntries = xPivotTableDataProvider->getPageFields();
         for (css::chart2::data::PivotTableFieldEntry const & rPageFieldEntry : aPivotFieldEntries)
         {
-            std::unique_ptr<VButton> pButton(new VButton);
-            pButton->init(xPageShapes, xShapeFactory);
+            VButton aButton;
+            aButton.init(xPageShapes, xShapeFactory);
             awt::Point aNewPosition(rRemainingSpace.X + x + 100, rRemainingSpace.Y + 100);
             sal_Int32 nDimensionIndex = rPageFieldEntry.DimensionIndex;
             OUString aFieldOutputDescription = xPivotTableDataProvider->getFieldOutputDescription(nDimensionIndex);
-            pButton->setLabel(rPageFieldEntry.Name + " | " + aFieldOutputDescription);
-            pButton->setCID("FieldButton.Page." + OUString::number(nDimensionIndex));
-            pButton->setPosition(aNewPosition);
-            pButton->setSize(aSize);
+            aButton.setLabel(rPageFieldEntry.Name + " | " + aFieldOutputDescription);
+            aButton.setCID("FieldButton.Page." + OUString::number(nDimensionIndex));
+            aButton.setPosition(aNewPosition);
+            aButton.setSize(aSize);
             if (rPageFieldEntry.HasHiddenMembers)
-                pButton->setArrowColor(Color(0x0000FF));
+                aButton.setArrowColor(Color(0x0000FF));
 
-            pButton->createShapes(xModelPage);
+            aButton.createShapes(xModelPage);
             x += aSize.Width + 100;
         }
         rRemainingSpace.Y += (aSize.Height + 100 + 100);
@@ -2297,23 +2297,22 @@ void lcl_createButtons(const uno::Reference<drawing::XShapes>& xPageShapes,
     const css::uno::Sequence<chart2::data::PivotTableFieldEntry> aPivotFieldEntries = xPivotTableDataProvider->getRowFields();
     for (css::chart2::data::PivotTableFieldEntry const & rRowFieldEntry : aPivotFieldEntries)
     {
-
-        std::unique_ptr<VButton> pButton(new VButton);
-        pButton->init(xPageShapes, xShapeFactory);
+        VButton aButton;
+        aButton.init(xPageShapes, xShapeFactory);
         awt::Point aNewPosition(rRemainingSpace.X + x + 100,
                                 rRemainingSpace.Y + rRemainingSpace.Height - aSize.Height - 100);
-        pButton->setLabel(rRowFieldEntry.Name);
-        pButton->setCID("FieldButton.Row." + OUString::number(rRowFieldEntry.DimensionIndex));
-        pButton->setPosition(aNewPosition);
-        pButton->setSize(aSize);
+        aButton.setLabel(rRowFieldEntry.Name);
+        aButton.setCID("FieldButton.Row." + OUString::number(rRowFieldEntry.DimensionIndex));
+        aButton.setPosition(aNewPosition);
+        aButton.setSize(aSize);
         if ( rRowFieldEntry.Name == "Data" )
         {
-            pButton->setBGColor( Color(0x00F6F6F6) );
-            pButton->showArrow( false );
+            aButton.setBGColor( Color(0x00F6F6F6) );
+            aButton.showArrow( false );
         }
         else if (rRowFieldEntry.HasHiddenMembers)
-            pButton->setArrowColor(Color(0x0000FF));
-        pButton->createShapes(xModelPage);
+            aButton.setArrowColor(Color(0x0000FF));
+        aButton.createShapes(xModelPage);
         x += aSize.Width + 100;
     }
     rRemainingSpace.Height -= (aSize.Height + 100 + 100);
diff --git a/chart2/source/view/main/VButton.cxx b/chart2/source/view/main/VButton.cxx
index a628899c04e5..2e20d97110f8 100644
--- a/chart2/source/view/main/VButton.cxx
+++ b/chart2/source/view/main/VButton.cxx
@@ -95,10 +95,10 @@ void VButton::createShapes(const uno::Reference<beans::XPropertySet>& xTextProp)
 {
     ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory);
 
-    std::unique_ptr<tNameSequence> pPropNames(new tNameSequence);
-    std::unique_ptr<tAnySequence> pPropValues(new tAnySequence);
+    tNameSequence aPropNames;
+    tAnySequence aPropValues;
 
-    PropertyMapper::getTextLabelMultiPropertyLists(xTextProp, *pPropNames, *pPropValues);
+    PropertyMapper::getTextLabelMultiPropertyLists(xTextProp, aPropNames, aPropValues);
 
     m_xShape.set(pShapeFactory->createGroup2D(m_xTarget, m_sCID), uno::UNO_QUERY);
     m_xShape->setPosition(m_aPosition);
@@ -124,10 +124,10 @@ void VButton::createShapes(const uno::Reference<beans::XPropertySet>& xTextProp)
 
     aTextValueMap["Name"] <<= m_sCID; //CID OUString
 
-    PropertyMapper::getMultiPropertyListsFromValueMap(*pPropNames, *pPropValues, aTextValueMap);
+    PropertyMapper::getMultiPropertyListsFromValueMap(aPropNames, aPropValues, aTextValueMap);
 
     uno::Reference<drawing::XShape> xEntry
-        = pShapeFactory->createText(xContainer, m_sLabel, *pPropNames, *pPropValues, uno::Any());
+        = pShapeFactory->createText(xContainer, m_sLabel, aPropNames, aPropValues, uno::Any());
 
     if (xEntry.is())
     {
diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx
index 5cdf2bf6dc7f..0f3759a81952 100644
--- a/comphelper/source/misc/backupfilehelper.cxx
+++ b/comphelper/source/misc/backupfilehelper.cxx
@@ -850,10 +850,10 @@ namespace
                 sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE];
                 sal_uInt64 nBytesTransfer(0);
                 sal_uInt64 nSize(getPackFileSize());
-                std::unique_ptr< z_stream > zstream(new z_stream);
-                memset(zstream.get(), 0, sizeof(*zstream));
+                z_stream zstream;
+                memset(&zstream, 0, sizeof(zstream));
 
-                if (Z_OK == deflateInit(zstream.get(), Z_BEST_COMPRESSION))
+                if (Z_OK == deflateInit(&zstream, Z_BEST_COMPRESSION))
                 {
                     // set offset in source file - when this is zero, a new file is to be added
                     if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
@@ -869,16 +869,16 @@ namespace
                                 break;
                             }
 
-                            zstream->avail_in = nToTransfer;
-                            zstream->next_in = reinterpret_cast<unsigned char*>(aArray);
+                            zstream.avail_in = nToTransfer;
+                            zstream.next_in = reinterpret_cast<unsigned char*>(aArray);
 
                             do {
-                                zstream->avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE;
-                                zstream->next_out = reinterpret_cast<unsigned char*>(aBuffer);
+                                zstream.avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE;
+                                zstream.next_out = reinterpret_cast<unsigned char*>(aBuffer);
 #if !defined Z_PREFIX
-                                const sal_Int64 nRetval(deflate(zstream.get(), nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH));
+                                const sal_Int64 nRetval(deflate(&zstream, nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH));
 #else
-                                const sal_Int64 nRetval(z_deflate(zstream.get(), nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH));
+                                const sal_Int64 nRetval(z_deflate(&zstream, nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH));
 #endif
                                 if (Z_STREAM_ERROR == nRetval)
                                 {
@@ -886,14 +886,14 @@ namespace
                                 }
                                 else
                                 {
-                                    const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream->avail_out);
+                                    const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream.avail_out);
 
                                     if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aBuffer), nAvailable, &nBytesTransfer) || nBytesTransfer != nAvailable)
                                     {
                                         bOkay = false;
                                     }
                                 }
-                            } while (bOkay && 0 == zstream->avail_out);
+                            } while (bOkay && 0 == zstream.avail_out);
 
                             if (!bOkay)
                             {
@@ -904,9 +904,9 @@ namespace
                         }
 
 #if !defined Z_PREFIX
-                        deflateEnd(zstream.get());
+                        deflateEnd(&zstream);
 #else
-                        z_deflateEnd(zstream.get());
+                        z_deflateEnd(&zstream);
 #endif
                     }
                 }
@@ -914,9 +914,9 @@ namespace
                 maFile->close();
 
                 // get compressed size and add to entry
-                if (mnFullFileSize == mnPackFileSize && mnFullFileSize == zstream->total_in)
+                if (mnFullFileSize == mnPackFileSize && mnFullFileSize == zstream.total_in)
                 {
-                    mnPackFileSize = zstream->total_out;
+                    mnPackFileSize = zstream.total_out;
                 }
 
                 return (0 == nSize);
@@ -933,10 +933,10 @@ namespace
                 sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE];
                 sal_uInt64 nBytesTransfer(0);
                 sal_uInt64 nSize(getPackFileSize());
-                std::unique_ptr< z_stream > zstream(new z_stream);
-                memset(zstream.get(), 0, sizeof(*zstream));
+                z_stream zstream;
+                memset(&zstream, 0, sizeof(zstream));
 
-                if (Z_OK == inflateInit(zstream.get()))
+                if (Z_OK == inflateInit(&zstream))
                 {
                     // set offset in source file - when this is zero, a new file is to be added
                     if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
@@ -952,16 +952,16 @@ namespace
                                 break;
                             }
 
-                            zstream->avail_in = nToTransfer;
-                            zstream->next_in = reinterpret_cast<unsigned char*>(aArray);
+                            zstream.avail_in = nToTransfer;
+                            zstream.next_in = reinterpret_cast<unsigned char*>(aArray);
 
                             do {
-                                zstream->avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE;
-                                zstream->next_out = reinterpret_cast<unsigned char*>(aBuffer);
+                                zstream.avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE;
+                                zstream.next_out = reinterpret_cast<unsigned char*>(aBuffer);
 #if !defined Z_PREFIX
-                                const sal_Int64 nRetval(inflate(zstream.get(), Z_NO_FLUSH));
+                                const sal_Int64 nRetval(inflate(&zstream, Z_NO_FLUSH));
 #else
-                                const sal_Int64 nRetval(z_inflate(zstream.get(), Z_NO_FLUSH));
+                                const sal_Int64 nRetval(z_inflate(&zstream, Z_NO_FLUSH));
 #endif
                                 if (Z_STREAM_ERROR == nRetval)
                                 {
@@ -969,14 +969,14 @@ namespace
                                 }
                                 else
                                 {
-                                    const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream->avail_out);
+                                    const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream.avail_out);
 
                                     if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aBuffer), nAvailable, &nBytesTransfer) || nBytesTransfer != nAvailable)
                                     {
                                         bOkay = false;
                                     }
                                 }
-                            } while (bOkay && 0 == zstream->avail_out);
+                            } while (bOkay && 0 == zstream.avail_out);
 
                             if (!bOkay)
                             {
@@ -987,9 +987,9 @@ namespace
                         }
 
 #if !defined Z_PREFIX
-                        deflateEnd(zstream.get());
+                        deflateEnd(&zstream);
 #else
-                        z_deflateEnd(zstream.get());
+                        z_deflateEnd(&zstream);
 #endif
                     }
                 }
diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx
index 479699750e07..b2dd83168e5e 100644
--- a/connectivity/source/drivers/jdbc/Object.cxx
+++ b/connectivity/source/drivers/jdbc/Object.cxx
@@ -170,22 +170,22 @@ namespace
 
         if ( _pEnvironment->IsInstanceOf( jThrow, java_sql_SQLException_BASE::st_getMyClass() ) )
         {
-            std::unique_ptr< java_sql_SQLException_BASE > pException( new java_sql_SQLException_BASE( _pEnvironment, jThrow ) );
-            _out_rException = SQLException( pException->getMessage(), _rxContext,
-                pException->getSQLState(), pException->getErrorCode(), Any() );
+            java_sql_SQLException_BASE aException( _pEnvironment, jThrow );
+            _out_rException = SQLException( aException.getMessage(), _rxContext,
+                aException.getSQLState(), aException.getErrorCode(), Any() );
             return true;
         }
         else if ( _pEnvironment->IsInstanceOf( jThrow, java_lang_Throwable::st_getMyClass() ) )
         {
-            std::unique_ptr< java_lang_Throwable > pThrow( new java_lang_Throwable( _pEnvironment, jThrow ) );
+            java_lang_Throwable aThrow( _pEnvironment, jThrow );
 #if OSL_DEBUG_LEVEL > 0
-            pThrow->printStackTrace();
+            aThrow.printStackTrace();
 #endif
-            OUString sMessage = pThrow->getMessage();
+            OUString sMessage = aThrow.getMessage();
             if ( sMessage.isEmpty() )
-                sMessage = pThrow->getLocalizedMessage();
+                sMessage = aThrow.getLocalizedMessage();
             if(  sMessage.isEmpty() )
-                sMessage = pThrow->toString();
+                sMessage = aThrow.toString();
             _out_rException = SQLException( sMessage, _rxContext, OUString(), -1, Any() );
             return true;
         }
diff --git a/l10ntools/source/helpex.cxx b/l10ntools/source/helpex.cxx
index b5f622b5c6ea..c81fce12ca74 100644
--- a/l10ntools/source/helpex.cxx
+++ b/l10ntools/source/helpex.cxx
@@ -120,11 +120,11 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
         else
         {
             HelpParser aParser( aArgs.m_sInputFile );
-            std::unique_ptr<XMLFile> xmlfile(new XMLFile( OString('0') ));
+            XMLFile xmlfile( OString('0') );
             hasNoError =
                 HelpParser::CreatePO(
                     aArgs.m_sOutputFile, aArgs.m_sInputFile,
-                    xmlfile.get(), "help" );
+                    &xmlfile, "help" );
         }
     }
     catch (std::exception& e)
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index 8fed8ffcb452..460acb50b253 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -148,13 +148,13 @@ bool HelpParser::Merge( const OString &rDestinationFile,
 
     //TODO: explicit BOM handling?
 
-    std::unique_ptr<XMLFile> xmlfile(new XMLFile( OString('0') ));
-    if (!aParser.Execute( sHelpFile, xmlfile.get()))
+    XMLFile xmlfile( OString('0') );
+    if (!aParser.Execute( sHelpFile, &xmlfile))
     {
         SAL_WARN("l10ntools", "could not parse " << sHelpFile);
         return false;
     }
-    MergeSingleFile( xmlfile.get() , pMergeDataFile , rLanguage , rDestinationFile );
+    MergeSingleFile( &xmlfile , pMergeDataFile , rLanguage , rDestinationFile );
     return true;
 }
 
diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx
index f0cdaa3ffb25..33794a377c2b 100644
--- a/l10ntools/source/lngmerge.cxx
+++ b/l10ntools/source/lngmerge.cxx
@@ -168,9 +168,9 @@ void LngParser::Merge(
         OString sID( sGroup );
         std::size_t nLastLangPos = 0;
 
-        std::unique_ptr<ResData> pResData( new ResData( sID, sSource ) );
-        pResData->sResTyp = "LngText";
-        MergeEntrys *pEntrys = aMergeDataFile.GetMergeEntrys( pResData.get() );
+        ResData aResData( sID, sSource );
+        aResData.sResTyp = "LngText";
+        MergeEntrys *pEntrys = aMergeDataFile.GetMergeEntrys( &aResData );
         // read languages
         bGroup = false;
 
diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 6201a38c7662..5976d0a1a219 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -855,11 +855,11 @@ RegError ORegistry::loadKey(RegKeyHandle hKey, const OUString& regFileName,
 {
     ORegKey* pKey = static_cast< ORegKey* >(hKey);
 
-    std::unique_ptr< ORegistry > pReg (new ORegistry());
-    RegError _ret = pReg->initRegistry(regFileName, RegAccessMode::READONLY);
+    ORegistry aReg;
+    RegError _ret = aReg.initRegistry(regFileName, RegAccessMode::READONLY);
     if (_ret != RegError::NO_ERROR)
         return _ret;
-    ORegKey* pRootKey = pReg->getRootKey();
+    ORegKey* pRootKey = aReg.getRootKey();
 
     REG_GUARD(m_mutex);
 
@@ -889,7 +889,7 @@ RegError ORegistry::loadKey(RegKeyHandle hKey, const OUString& regFileName,
     }
 
     rStoreDir = OStoreDirectory();
-    (void) pReg->releaseKey(pRootKey);
+    (void) aReg.releaseKey(pRootKey);
     return _ret;
 }
 


More information about the Libreoffice-commits mailing list