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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri May 28 15:30:50 UTC 2021


 sc/source/core/data/stlpool.cxx |   61 +++++++++++++++++++---------------------
 sw/source/ui/chrdlg/chardlg.cxx |    8 ++---
 sw/source/ui/dbui/dbinsdlg.cxx  |   44 ++++++++++++++--------------
 sw/source/ui/frmdlg/frmpage.cxx |    8 ++---
 sw/source/uibase/app/applab.cxx |    3 +
 sw/source/uibase/app/docsh2.cxx |    5 +--
 6 files changed, 63 insertions(+), 66 deletions(-)

New commits:
commit 9b81036c87b52edc2ce44813b31be425bc12ee1d
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri May 28 10:18:15 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri May 28 17:30:07 2021 +0200

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

diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx
index 8248218b14c3..51e7f6c09e1c 100644
--- a/sc/source/core/data/stlpool.cxx
+++ b/sc/source/core/data/stlpool.cxx
@@ -217,13 +217,12 @@ void ScStyleSheetPool::CreateStandardStyles()
     const OUString  aHelpFile;//which text???
     SfxItemSet*     pSet            = nullptr;
     SfxItemSet*     pHFSet          = nullptr;
-    SvxSetItem*     pHFSetItem      = nullptr;
     std::unique_ptr<ScEditEngineDefaulter> pEdEngine(new ScEditEngineDefaulter( EditEngine::CreatePool().get(), true ));
     pEdEngine->SetUpdateMode( false );
     std::unique_ptr<EditTextObject> pEmptyTxtObj = pEdEngine->CreateTextObject();
     std::unique_ptr<EditTextObject> pTxtObj;
-    std::unique_ptr<ScPageHFItem> pHeaderItem(new ScPageHFItem( ATTR_PAGE_HEADERRIGHT ));
-    std::unique_ptr<ScPageHFItem> pFooterItem(new ScPageHFItem( ATTR_PAGE_FOOTERRIGHT ));
+    ScPageHFItem aHeaderItem( ATTR_PAGE_HEADERRIGHT );
+    ScPageHFItem aFooterItem( ATTR_PAGE_FOOTERRIGHT );
     ScStyleSheet*   pSheet          = nullptr;
     ::editeng::SvxBorderLine    aBorderLine     ( &aColBlack, DEF_LINE_WIDTH_2 );
     SvxBoxItem      aBoxItem        ( ATTR_BORDER );
@@ -276,12 +275,11 @@ void ScStyleSheetPool::CreateStandardStyles()
     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_PAGE_STD );
 
     // distance to header/footer for the sheet
-    pHFSetItem = new SvxSetItem( pSet->Get( ATTR_PAGE_HEADERSET ) );
-    pHFSetItem->SetWhich(ATTR_PAGE_HEADERSET);
-    pSet->Put( *pHFSetItem );
-    pHFSetItem->SetWhich(ATTR_PAGE_FOOTERSET);
-    pSet->Put( *pHFSetItem );
-    delete pHFSetItem;
+    SvxSetItem aHFSetItem = pSet->Get( ATTR_PAGE_HEADERSET );
+    aHFSetItem.SetWhich(ATTR_PAGE_HEADERSET);
+    pSet->Put( aHFSetItem );
+    aHFSetItem.SetWhich(ATTR_PAGE_FOOTERSET);
+    pSet->Put( aHFSetItem );
 
     // Header:
     // [empty][\sheet\][empty]
@@ -289,10 +287,10 @@ void ScStyleSheetPool::CreateStandardStyles()
     pEdEngine->SetTextCurrentDefaults(EMPTY_OUSTRING);
     pEdEngine->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection() );
     pTxtObj = pEdEngine->CreateTextObject();
-    pHeaderItem->SetLeftArea  ( *pEmptyTxtObj );
-    pHeaderItem->SetCenterArea( *pTxtObj );
-    pHeaderItem->SetRightArea ( *pEmptyTxtObj );
-    pSet->Put( *pHeaderItem );
+    aHeaderItem.SetLeftArea  ( *pEmptyTxtObj );
+    aHeaderItem.SetCenterArea( *pTxtObj );
+    aHeaderItem.SetRightArea ( *pEmptyTxtObj );
+    pSet->Put( aHeaderItem );
 
     // Footer:
     // [empty][Page \STR_PAGE\][empty]
@@ -302,10 +300,10 @@ void ScStyleSheetPool::CreateStandardStyles()
     nStrLen = aStr.getLength();
     pEdEngine->QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(0,nStrLen,0,nStrLen) );
     pTxtObj = pEdEngine->CreateTextObject();
-    pFooterItem->SetLeftArea  ( *pEmptyTxtObj );
-    pFooterItem->SetCenterArea( *pTxtObj );
-    pFooterItem->SetRightArea ( *pEmptyTxtObj );
-    pSet->Put( *pFooterItem );
+    aFooterItem.SetLeftArea  ( *pEmptyTxtObj );
+    aFooterItem.SetCenterArea( *pTxtObj );
+    aFooterItem.SetRightArea ( *pEmptyTxtObj );
+    pSet->Put( aFooterItem );
 
     // 2. Report
 
@@ -329,17 +327,16 @@ void ScStyleSheetPool::CreateStandardStyles()
     aBoxInfoItem.SetTable( false );
     aBoxInfoItem.SetDist ( true );
 
-    pHFSetItem = new SvxSetItem( pSet->Get( ATTR_PAGE_HEADERSET ) );
-    pHFSet = &(pHFSetItem->GetItemSet());
+    SvxSetItem aHFSetItem2 = pSet->Get( ATTR_PAGE_HEADERSET );
+    pHFSet = &(aHFSetItem2.GetItemSet());
 
     pHFSet->Put( SvxBrushItem( COL_LIGHTGRAY, ATTR_BACKGROUND ) );
     pHFSet->Put( aBoxItem );
     pHFSet->Put( aBoxInfoItem );
-    pHFSetItem->SetWhich(ATTR_PAGE_HEADERSET);
-    pSet->Put( *pHFSetItem );
-    pHFSetItem->SetWhich(ATTR_PAGE_FOOTERSET);
-    pSet->Put( *pHFSetItem );
-    delete pHFSetItem;
+    aHFSetItem2.SetWhich(ATTR_PAGE_HEADERSET);
+    pSet->Put( aHFSetItem2 );
+    aHFSetItem2.SetWhich(ATTR_PAGE_FOOTERSET);
+    pSet->Put( aHFSetItem2 );
 
     // Footer:
     // [\TABLE\ (\DATA\)][empty][\DATE\, \TIME\]
@@ -349,16 +346,16 @@ void ScStyleSheetPool::CreateStandardStyles()
     pEdEngine->QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), ESelection(0,2,0,2) );
     pEdEngine->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection() );
     pTxtObj = pEdEngine->CreateTextObject();
-    pHeaderItem->SetLeftArea( *pTxtObj );
-    pHeaderItem->SetCenterArea( *pEmptyTxtObj );
+    aHeaderItem.SetLeftArea( *pTxtObj );
+    aHeaderItem.SetCenterArea( *pEmptyTxtObj );
     aStr = ", ";
     pEdEngine->SetTextCurrentDefaults( aStr );
     pEdEngine->QuickInsertField( SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD), ESelection(0,2,0,2) );
     pEdEngine->QuickInsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SvxDateType::Var), EE_FEATURE_FIELD),
                                     ESelection() );
     pTxtObj = pEdEngine->CreateTextObject();
-    pHeaderItem->SetRightArea( *pTxtObj );
-    pSet->Put( *pHeaderItem );
+    aHeaderItem.SetRightArea( *pTxtObj );
+    pSet->Put( aHeaderItem );
 
     // Footer:
     // [empty][Page: \PAGE\ / \PAGE\][empty]
@@ -371,10 +368,10 @@ void ScStyleSheetPool::CreateStandardStyles()
     pEdEngine->QuickInsertField( SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD), ESelection(0,nStrLen2,0,nStrLen2) );
     pEdEngine->QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(0,nStrLen,0,nStrLen) );
     pTxtObj = pEdEngine->CreateTextObject();
-    pFooterItem->SetLeftArea  ( *pEmptyTxtObj );
-    pFooterItem->SetCenterArea( *pTxtObj );
-    pFooterItem->SetRightArea ( *pEmptyTxtObj );
-    pSet->Put( *pFooterItem );
+    aFooterItem.SetLeftArea  ( *pEmptyTxtObj );
+    aFooterItem.SetCenterArea( *pTxtObj );
+    aFooterItem.SetRightArea ( *pEmptyTxtObj );
+    pSet->Put( aFooterItem );
 
     bHasStandardStyles = true;
 }
diff --git a/sw/source/ui/chrdlg/chardlg.cxx b/sw/source/ui/chrdlg/chardlg.cxx
index 4b4eeb094982..f81bfa7c13b3 100644
--- a/sw/source/ui/chrdlg/chardlg.cxx
+++ b/sw/source/ui/chrdlg/chardlg.cxx
@@ -177,14 +177,14 @@ SwCharURLPage::SwCharURLPage(weld::Container* pPage, weld::DialogController* pCo
     m_xNotVisitedLB->set_active_id(OUString::number(RES_POOLCHR_INET_NORMAL));
     m_xNotVisitedLB->save_value();
 
-    std::unique_ptr<TargetList> pList( new TargetList );
-    SfxFrame::GetDefaultTargetList(*pList);
+    TargetList aList;
+    SfxFrame::GetDefaultTargetList(aList);
 
     m_xTargetFrameLB->freeze();
-    size_t nCount = pList->size();
+    size_t nCount = aList.size();
     for (size_t i = 0; i < nCount; ++i)
     {
-        m_xTargetFrameLB->append_text(pList->at(i));
+        m_xTargetFrameLB->append_text(aList.at(i));
     }
     m_xTargetFrameLB->thaw();
 }
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index 5f30ef971191..50a7d212b42d 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -1596,20 +1596,20 @@ void SwInsertDBColAutoPilot::Load()
         pDataSourceProps[2] >>= nCommandType;
         if(sSource == aDBData.sDataSource && sCommand == aDBData.sCommand)
         {
-            std::unique_ptr<DB_ColumnConfigData> pNewData(new DB_ColumnConfigData);
+            DB_ColumnConfigData aNewData;
 
-            pDataSourceProps[3] >>= pNewData->sEdit;
-            pDataSourceProps[4] >>= pNewData->sTableList;
-            pDataSourceProps[5] >>= pNewData->sTmplNm;
-            pDataSourceProps[6] >>= pNewData->sTAutoFormatNm;
+            pDataSourceProps[3] >>= aNewData.sEdit;
+            pDataSourceProps[4] >>= aNewData.sTableList;
+            pDataSourceProps[5] >>= aNewData.sTmplNm;
+            pDataSourceProps[6] >>= aNewData.sTAutoFormatNm;
             if(pDataSourceProps[7].hasValue())
-                pNewData->bIsTable = *o3tl::doAccess<bool>(pDataSourceProps[7]);
+                aNewData.bIsTable = *o3tl::doAccess<bool>(pDataSourceProps[7]);
             if(pDataSourceProps[8].hasValue())
-                 pNewData->bIsField = *o3tl::doAccess<bool>(pDataSourceProps[8]);
+                 aNewData.bIsField = *o3tl::doAccess<bool>(pDataSourceProps[8]);
             if(pDataSourceProps[9].hasValue())
-                 pNewData->bIsHeadlineOn = *o3tl::doAccess<bool>(pDataSourceProps[9]);
+                 aNewData.bIsHeadlineOn = *o3tl::doAccess<bool>(pDataSourceProps[9]);
             if(pDataSourceProps[10].hasValue())
-                 pNewData->bIsEmptyHeadln = *o3tl::doAccess<bool>(pDataSourceProps[10]);
+                 aNewData.bIsEmptyHeadln = *o3tl::doAccess<bool>(pDataSourceProps[10]);
 
             const OUString sSubNodeName(nodeName + "/ColumnSet/");
             const Sequence <OUString> aSubNames = GetNodeNames(sSubNodeName);
@@ -1659,9 +1659,9 @@ void SwInsertDBColAutoPilot::Load()
                 pInsDBColumn->nUsrNumFormat = rNFormatr.GetEntryKey( pInsDBColumn->sUsrNumFormat,
                                                         pInsDBColumn->eUsrNumFormatLng );
 
-                pNewData->aDBColumns.insert(std::move(pInsDBColumn));
+                aNewData.aDBColumns.insert(std::move(pInsDBColumn));
             }
-            OUString sTmp( pNewData->sTableList );
+            OUString sTmp( aNewData.sTableList );
             if( !sTmp.isEmpty() )
             {
                 sal_Int32 n = 0;
@@ -1683,16 +1683,16 @@ void SwInsertDBColAutoPilot::Load()
                 m_xIbDbcolOneFrom->set_sensitive(true);
                 m_xIbDbcolAllFrom->set_sensitive(true);
             }
-            m_xEdDbText->set_text( pNewData->sEdit );
+            m_xEdDbText->set_text( aNewData.sEdit );
 
-            sTmp = pNewData->sTmplNm;
+            sTmp = aNewData.sTmplNm;
             if( !sTmp.isEmpty() )
                 m_xLbDbParaColl->set_active_text(sTmp);
             else
                 m_xLbDbParaColl->set_active(0);
 
             m_xTAutoFormat.reset();
-            sTmp = pNewData->sTAutoFormatNm;
+            sTmp = aNewData.sTAutoFormatNm;
             if( !sTmp.isEmpty() )
             {
                 // then load the AutoFormat file and look for Autoformat first
@@ -1706,13 +1706,13 @@ void SwInsertDBColAutoPilot::Load()
                     }
             }
 
-            m_xRbAsTable->set_active( pNewData->bIsTable );
-            m_xRbAsField->set_active( pNewData->bIsField );
-            m_xRbAsText->set_active( !pNewData->bIsTable && !pNewData->bIsField );
+            m_xRbAsTable->set_active( aNewData.bIsTable );
+            m_xRbAsField->set_active( aNewData.bIsField );
+            m_xRbAsText->set_active( !aNewData.bIsTable && !aNewData.bIsField );
 
-            m_xCbTableHeadon->set_active( pNewData->bIsHeadlineOn );
-            m_xRbHeadlColnms->set_active( !pNewData->bIsEmptyHeadln );
-            m_xRbHeadlEmpty->set_active( pNewData->bIsEmptyHeadln );
+            m_xCbTableHeadon->set_active( aNewData.bIsHeadlineOn );
+            m_xRbHeadlColnms->set_active( !aNewData.bIsEmptyHeadln );
+            m_xRbHeadlEmpty->set_active( aNewData.bIsEmptyHeadln );
             HeaderHdl(*m_xCbTableHeadon);
 
             // now copy the user defined Numberformat strings to the
@@ -1720,9 +1720,9 @@ void SwInsertDBColAutoPilot::Load()
             for( size_t n = 0; n < aDBColumns.size() ; ++n )
             {
                 SwInsDBColumn& rSet = *aDBColumns[ n ];
-                for( size_t m = 0; m < pNewData->aDBColumns.size() ; ++m )
+                for( size_t m = 0; m < aNewData.aDBColumns.size() ; ++m )
                 {
-                    SwInsDBColumn& rGet = *pNewData->aDBColumns[ m ];
+                    SwInsDBColumn& rGet = *aNewData.aDBColumns[ m ];
                     if(rGet.sColumn == rSet.sColumn)
                     {
                         if( rGet.bHasFormat && !rGet.bIsDBFormat )
diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index 00dbc8c0e03e..c42ce8dbf4fd 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -2697,12 +2697,12 @@ void SwFrameURLPage::Reset( const SfxItemSet *rSet )
     const SfxPoolItem* pItem;
     if ( SfxItemState::SET == rSet->GetItemState( SID_DOCFRAME, true, &pItem))
     {
-        std::unique_ptr<TargetList> pList(new TargetList);
-        SfxFrame::GetDefaultTargetList(*pList);
-        size_t nCount = pList->size();
+        TargetList aList;
+        SfxFrame::GetDefaultTargetList(aList);
+        size_t nCount = aList.size();
         for (size_t i = 0; i < nCount; ++i)
         {
-            m_xFrameCB->append_text(pList->at(i));
+            m_xFrameCB->append_text(aList.at(i));
         }
     }
 
diff --git a/sw/source/uibase/app/applab.cxx b/sw/source/uibase/app/applab.cxx
index 1cb48c0f1135..8c6a450737de 100644
--- a/sw/source/uibase/app/applab.cxx
+++ b/sw/source/uibase/app/applab.cxx
@@ -264,7 +264,8 @@ void SwModule::InsertLab(SfxRequest& rReq, bool bLabel)
         pSh->ChgPageDesc( 0, aDesc );
 
         // Insert frame
-        std::unique_ptr<SwFieldMgr> pFieldMgr(new SwFieldMgr);
+        std::optional<SwFieldMgr> pFieldMgr;
+        pFieldMgr.emplace();
         pFieldMgr->SetEvalExpFields(false);
 
         // Prepare border template
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 54fa22ae795d..30b31f90cdc7 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -1125,12 +1125,11 @@ void SwDocShell::Execute(SfxRequest& rReq)
                                 //search for the view that created the call
                                 if(pViewShell->GetObjectShell() == this && pViewShell->GetDispatcher())
                                 {
-                                    std::unique_ptr<SfxFrameItem> pFrameItem(new SfxFrameItem( SID_DOCFRAME,
-                                                        pViewShell->GetViewFrame() ));
+                                    SfxFrameItem aFrameItem( SID_DOCFRAME, pViewShell->GetViewFrame() );
                                     SfxDispatcher* pDispatch = pViewShell->GetDispatcher();
                                     pDispatch->ExecuteList(SID_OPENDOC,
                                         SfxCallMode::ASYNCHRON,
-                                        { &aName, &aReferer, pFrameItem.get() });
+                                        { &aName, &aReferer, &aFrameItem });
                                     break;
                                 }
                                 pViewShell = SfxViewShell::GetNext(*pViewShell);


More information about the Libreoffice-commits mailing list