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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri May 10 06:17:06 UTC 2019


 sc/inc/editutil.hxx                 |    6 +++---
 sc/source/core/data/column2.cxx     |   12 ++++++------
 sc/source/core/data/documen2.cxx    |    4 ++--
 sc/source/core/data/documen8.cxx    |   11 +++++------
 sc/source/core/tool/editutil.cxx    |   18 +++++++++---------
 sc/source/filter/excel/xehelper.cxx |    4 ++--
 sc/source/filter/excel/xlroot.cxx   |    4 ++--
 sc/source/ui/app/inputwin.cxx       |    8 ++++----
 sc/source/ui/pagedlg/tphfedit.cxx   |    6 +++---
 sc/source/ui/view/gridwin4.cxx      |    6 +++---
 sc/source/ui/view/output2.cxx       |   18 ++++++++++--------
 sc/source/ui/view/preview.cxx       |    7 +++----
 12 files changed, 52 insertions(+), 52 deletions(-)

New commits:
commit c302027510adb13a2d34d863e417460375588c4b
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu May 9 14:44:02 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri May 10 08:16:31 2019 +0200

    pass SfxItemSet by unique_ptr to ScEditEngineDefaulter
    
    Change-Id: I2bcfb87f687355a66a8a855b2858220cf1fefd39
    Reviewed-on: https://gerrit.libreoffice.org/72043
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index a6d96ef73c49..f2b7ae0a01a4 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -134,7 +134,7 @@ public:
     void            SetDefaults( const SfxItemSet& rDefaults, bool bRememberCopy = true );
 
                     /// Becomes the owner of the SfxItemSet
-    void            SetDefaults( SfxItemSet* pDefaults );
+    void            SetDefaults( std::unique_ptr<SfxItemSet> pDefaults );
 
                     /// Set the item in the default ItemSet which is created
                     /// if it doesn't exist yet.
@@ -151,7 +151,7 @@ public:
                         const SfxItemSet& rDefaults, bool bRememberCopy = true );
                     /// Current defaults are not applied, new defaults are applied
     void            SetTextNewDefaults( const EditTextObject& rTextObject,
-                        SfxItemSet* pDefaults );
+                        std::unique_ptr<SfxItemSet> pDefaults );
 
                     /// Overwritten method to be able to apply defaults already set
     void            SetText( const OUString& rText );
@@ -160,7 +160,7 @@ public:
                         const SfxItemSet& rDefaults );
                     /// Current defaults are not applied, new defaults are applied
     void            SetTextNewDefaults( const OUString& rText,
-                        SfxItemSet* pDefaults );
+                        std::unique_ptr<SfxItemSet> pDefaults );
 
                     /// Paragraph attributes that are not defaults are copied to
                     /// character attributes and all paragraph attributes reset
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 4e75b4f3bd0f..d1654ac7e49e 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -376,17 +376,17 @@ long ScColumn::GetNeededSize(
         pDev->SetMapMode( aHMMMode );
         pEngine->SetRefDevice( pDev );
         pDocument->ApplyAsianEditSettings( *pEngine );
-        SfxItemSet* pSet = new SfxItemSet( pEngine->GetEmptyItemSet() );
+        std::unique_ptr<SfxItemSet> pSet(new SfxItemSet( pEngine->GetEmptyItemSet() ));
         if ( ScStyleSheet* pPreviewStyle = pDocument->GetPreviewCellStyle( nCol, nRow, nTab ) )
         {
             std::unique_ptr<ScPatternAttr> pPreviewPattern(new ScPatternAttr( *pPattern ));
             pPreviewPattern->SetStyleSheet(pPreviewStyle);
-            pPreviewPattern->FillEditItemSet( pSet, pCondSet );
+            pPreviewPattern->FillEditItemSet( pSet.get(), pCondSet );
         }
         else
         {
             SfxItemSet* pFontSet = pDocument->GetPreviewFont( nCol, nRow, nTab );
-            pPattern->FillEditItemSet( pSet, pFontSet ? pFontSet : pCondSet );
+            pPattern->FillEditItemSet( pSet.get(), pFontSet ? pFontSet : pCondSet );
         }
 //          no longer needed, are set with the text (is faster)
 //          pEngine->SetDefaults( pSet );
@@ -437,7 +437,7 @@ long ScColumn::GetNeededSize(
 
         if (aCell.meType == CELLTYPE_EDIT)
         {
-            pEngine->SetTextNewDefaults(*aCell.mpEditText, pSet);
+            pEngine->SetTextNewDefaults(*aCell.mpEditText, std::move(pSet));
         }
         else
         {
@@ -448,9 +448,9 @@ long ScColumn::GetNeededSize(
                 rOptions.bFormula);
 
             if (!aString.isEmpty())
-                pEngine->SetTextNewDefaults(aString, pSet);
+                pEngine->SetTextNewDefaults(aString, std::move(pSet));
             else
-                pEngine->SetDefaults(pSet);
+                pEngine->SetDefaults(std::move(pSet));
         }
 
         bool bEngineVertical = pEngine->IsVertical();
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 0892025b242a..2ffbd7806549 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -452,9 +452,9 @@ ScNoteEditEngine& ScDocument::GetNoteEngine()
         mpNoteEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM));
         ApplyAsianEditSettings( *mpNoteEngine );
         const SfxItemSet& rItemSet = GetDefPattern()->GetItemSet();
-        SfxItemSet* pEEItemSet = new SfxItemSet( mpNoteEngine->GetEmptyItemSet() );
+        std::unique_ptr<SfxItemSet> pEEItemSet(new SfxItemSet( mpNoteEngine->GetEmptyItemSet() ));
         ScPatternAttr::FillToEditItemSet( *pEEItemSet, rItemSet );
-        mpNoteEngine->SetDefaults( pEEItemSet );      // edit engine takes ownership
+        mpNoteEngine->SetDefaults( std::move(pEEItemSet) );      // edit engine takes ownership
     }
     return *mpNoteEngine;
 }
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index a118285c2533..aefbcb293d70 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -1267,19 +1267,19 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, Transliteratio
 
                     // defaults from cell attributes must be set so right language is used
                     const ScPatternAttr* pPattern = GetPattern( nCol, nRow, nTab );
-                    SfxItemSet* pDefaults = new SfxItemSet( pEngine->GetEmptyItemSet() );
+                    std::unique_ptr<SfxItemSet> pDefaults(new SfxItemSet( pEngine->GetEmptyItemSet() ));
                     if ( ScStyleSheet* pPreviewStyle = GetPreviewCellStyle( nCol, nRow, nTab ) )
                     {
                         std::unique_ptr<ScPatternAttr> pPreviewPattern(new ScPatternAttr( *pPattern ));
                         pPreviewPattern->SetStyleSheet(pPreviewStyle);
-                        pPreviewPattern->FillEditItemSet( pDefaults );
+                        pPreviewPattern->FillEditItemSet( pDefaults.get() );
                     }
                     else
                     {
                         SfxItemSet* pFontSet = GetPreviewFont( nCol, nRow, nTab );
-                        pPattern->FillEditItemSet( pDefaults, pFontSet );
+                        pPattern->FillEditItemSet( pDefaults.get(), pFontSet );
                     }
-                    pEngine->SetDefaults( pDefaults );
+                    pEngine->SetDefaults( std::move(pDefaults) );
                     if (aCell.meType == CELLTYPE_STRING)
                         pEngine->SetText(aCell.mpString->getString());
                     else if (aCell.mpEditText)
@@ -1301,8 +1301,7 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, Transliteratio
                         if ( aTester.NeedsObject() )
                         {
                             // remove defaults (paragraph attributes) before creating text object
-                            SfxItemSet* pEmpty = new SfxItemSet( pEngine->GetEmptyItemSet() );
-                            pEngine->SetDefaults( pEmpty );
+                            pEngine->SetDefaults( std::make_unique<SfxItemSet>( pEngine->GetEmptyItemSet() ) );
 
                             // The cell will take ownership of the text object instance.
                             SetEditText(ScAddress(nCol,nRow,nTab), pEngine->CreateTextObject());
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index 17f8b9c8dbfb..aa18f4a7c800 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -508,11 +508,11 @@ void ScEditEngineDefaulter::SetDefaults( const SfxItemSet& rSet, bool bRememberC
         EnableUndo( true );
 }
 
-void ScEditEngineDefaulter::SetDefaults( SfxItemSet* pSet )
+void ScEditEngineDefaulter::SetDefaults( std::unique_ptr<SfxItemSet> pSet )
 {
     if ( bDeleteDefaults )
         delete pDefaults;
-    pDefaults = pSet;
+    pDefaults = pSet.release();
     bDeleteDefaults = true;
     if ( pDefaults )
         SetDefaults( *pDefaults, false );
@@ -564,13 +564,13 @@ void ScEditEngineDefaulter::SetTextNewDefaults( const EditTextObject& rTextObjec
 }
 
 void ScEditEngineDefaulter::SetTextNewDefaults( const EditTextObject& rTextObject,
-            SfxItemSet* pSet )
+            std::unique_ptr<SfxItemSet> pSet )
 {
     bool bUpdateMode = GetUpdateMode();
     if ( bUpdateMode )
         SetUpdateMode( false );
     EditEngine::SetText( rTextObject );
-    SetDefaults( pSet );
+    SetDefaults( std::move(pSet) );
     if ( bUpdateMode )
         SetUpdateMode( true );
 }
@@ -600,13 +600,13 @@ void ScEditEngineDefaulter::SetTextNewDefaults( const OUString& rText,
 }
 
 void ScEditEngineDefaulter::SetTextNewDefaults( const OUString& rText,
-            SfxItemSet* pSet )
+            std::unique_ptr<SfxItemSet> pSet )
 {
     bool bUpdateMode = GetUpdateMode();
     if ( bUpdateMode )
         SetUpdateMode( false );
     EditEngine::SetText( rText );
-    SetDefaults( pSet );
+    SetDefaults( std::move(pSet) );
     if ( bUpdateMode )
         SetUpdateMode( true );
 }
@@ -712,9 +712,9 @@ ScTabEditEngine::ScTabEditEngine( const ScPatternAttr& rPattern,
 void ScTabEditEngine::Init( const ScPatternAttr& rPattern )
 {
     SetRefMapMode(MapMode(MapUnit::Map100thMM));
-    SfxItemSet* pEditDefaults = new SfxItemSet( GetEmptyItemSet() );
-    rPattern.FillEditItemSet( pEditDefaults );
-    SetDefaults( pEditDefaults );
+    auto pEditDefaults = std::make_unique<SfxItemSet>( GetEmptyItemSet() );
+    rPattern.FillEditItemSet( pEditDefaults.get() );
+    SetDefaults( std::move(pEditDefaults) );
     // we have no StyleSheets for text
     SetControlWord( GetControlWord() & ~EEControlBits::RTFSTYLESHEETS );
 }
diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx
index c4e67e5f57c2..ff6cb41ab301 100644
--- a/sc/source/filter/excel/xehelper.cxx
+++ b/sc/source/filter/excel/xehelper.cxx
@@ -578,9 +578,9 @@ XclExpStringRef XclExpStringHelper::CreateCellString(
 
     // default items
     const SfxItemSet& rItemSet = pCellAttr ? pCellAttr->GetItemSet() : rRoot.GetDoc().GetDefPattern()->GetItemSet();
-    SfxItemSet* pEEItemSet = new SfxItemSet( rEE.GetEmptyItemSet() );
+    auto pEEItemSet = std::make_unique<SfxItemSet>( rEE.GetEmptyItemSet() );
     ScPatternAttr::FillToEditItemSet( *pEEItemSet, rItemSet );
-    rEE.SetDefaults( pEEItemSet );      // edit engine takes ownership
+    rEE.SetDefaults( std::move(pEEItemSet) );      // edit engine takes ownership
 
     // create the string
     rEE.SetText(rEditText);
diff --git a/sc/source/filter/excel/xlroot.cxx b/sc/source/filter/excel/xlroot.cxx
index 977f848061d6..a1cdf88b5f45 100644
--- a/sc/source/filter/excel/xlroot.cxx
+++ b/sc/source/filter/excel/xlroot.cxx
@@ -384,14 +384,14 @@ ScHeaderEditEngine& XclRoot::GetHFEditEngine() const
         rEE.SetControlWord( rEE.GetControlWord() & ~EEControlBits::ALLOWBIGOBJS );
 
         // set Calc header/footer defaults
-        SfxItemSet* pEditSet = new SfxItemSet( rEE.GetEmptyItemSet() );
+        auto pEditSet = std::make_unique<SfxItemSet>( rEE.GetEmptyItemSet() );
         SfxItemSet aItemSet( *GetDoc().GetPool(), svl::Items<ATTR_PATTERN_START, ATTR_PATTERN_END>{} );
         ScPatternAttr::FillToEditItemSet( *pEditSet, aItemSet );
         // FillToEditItemSet() adjusts font height to 1/100th mm, we need twips
         pEditSet->Put( aItemSet.Get( ATTR_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT) );
         pEditSet->Put( aItemSet.Get( ATTR_CJK_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK) );
         pEditSet->Put( aItemSet.Get( ATTR_CTL_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL) );
-        rEE.SetDefaults( pEditSet );    // takes ownership
+        rEE.SetDefaults( std::move(pEditSet) );    // takes ownership
    }
     return *mrData.mxHFEditEngine;
 }
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index a54332c9a4af..031546dc0f78 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1233,14 +1233,14 @@ void ScTextWnd::InitEditEngine()
     UpdateAutoCorrFlag();
 
     {
-        SfxItemSet* pSet = new SfxItemSet( mpEditEngine->GetEmptyItemSet() );
+        auto pSet = std::make_unique<SfxItemSet>( mpEditEngine->GetEmptyItemSet() );
         EditEngine::SetFontInfoInItemSet( *pSet, aTextFont );
         lcl_ExtendEditFontAttribs( *pSet );
         // turn off script spacing to match DrawText output
         pSet->Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) );
         if ( bIsRTL )
             lcl_ModifyRTLDefaults( *pSet );
-        mpEditEngine->SetDefaults( pSet );
+        mpEditEngine->SetDefaults( std::move(pSet) );
     }
 
     // If the Cell contains URLFields, they need to be taken over into the entry row,
@@ -1756,12 +1756,12 @@ void ScTextWnd::MakeDialogEditView()
     mpEditEngine->SetWordDelimiters( mpEditEngine->GetWordDelimiters() + "=" );
     mpEditEngine->SetPaperSize( Size( bIsRTL ? USHRT_MAX : THESIZE, 300 ) );
 
-    SfxItemSet* pSet = new SfxItemSet( mpEditEngine->GetEmptyItemSet() );
+    auto pSet = std::make_unique<SfxItemSet>( mpEditEngine->GetEmptyItemSet() );
     EditEngine::SetFontInfoInItemSet( *pSet, aTextFont );
     lcl_ExtendEditFontAttribs( *pSet );
     if ( bIsRTL )
         lcl_ModifyRTLDefaults( *pSet );
-    mpEditEngine->SetDefaults( pSet );
+    mpEditEngine->SetDefaults( std::move(pSet) );
     mpEditEngine->SetUpdateMode( true );
 
     mpEditView = std::make_unique<EditView>(mpEditEngine.get(), this);
diff --git a/sc/source/ui/pagedlg/tphfedit.cxx b/sc/source/ui/pagedlg/tphfedit.cxx
index 8f647e26e579..dfd7f893b0a8 100644
--- a/sc/source/ui/pagedlg/tphfedit.cxx
+++ b/sc/source/ui/pagedlg/tphfedit.cxx
@@ -178,8 +178,8 @@ std::unique_ptr<EditTextObject> ScEditWindow::CreateTextObject()
 
 void ScEditWindow::SetFont( const ScPatternAttr& rPattern )
 {
-    SfxItemSet* pSet = new SfxItemSet( pEdEngine->GetEmptyItemSet() );
-    rPattern.FillEditItemSet( pSet );
+    auto pSet = std::make_unique<SfxItemSet>( pEdEngine->GetEmptyItemSet() );
+    rPattern.FillEditItemSet( pSet.get() );
     //  FillEditItemSet adjusts font height to 1/100th mm,
     //  but for header/footer twips is needed, as in the PatternAttr:
     pSet->Put( rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT) );
@@ -187,7 +187,7 @@ void ScEditWindow::SetFont( const ScPatternAttr& rPattern )
     pSet->Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL) );
     if (mbRTL)
         pSet->Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
-    pEdEngine->SetDefaults( pSet );
+    pEdEngine->SetDefaults( std::move(pSet) );
 }
 
 void ScEditWindow::SetText( const EditTextObject& rTextObject )
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 1acd0e11eabd..663ce00737ca 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1385,10 +1385,10 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
             //  use EditEngine to draw mixed-script string
             pEditEng.reset(new ScEditEngineDefaulter( EditEngine::CreatePool(), true ));
             pEditEng->SetRefMapMode(rRenderContext.GetMapMode());
-            SfxItemSet* pEditDefaults = new SfxItemSet( pEditEng->GetEmptyItemSet() );
-            rDefPattern.FillEditItemSet( pEditDefaults );
+            auto pEditDefaults = std::make_unique<SfxItemSet>( pEditEng->GetEmptyItemSet() );
+            rDefPattern.FillEditItemSet( pEditDefaults.get() );
             pEditDefaults->Put( SvxColorItem( COL_LIGHTGRAY, EE_CHAR_COLOR ) );
-            pEditEng->SetDefaults( pEditDefaults );
+            pEditEng->SetDefaults( std::move(pEditDefaults) );
         }
 
         sal_uInt16 nCount = sal::static_int_cast<sal_uInt16>( pPageData->GetCount() );
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 3aaaaccd4f15..ab88adfc265c 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -2406,8 +2406,8 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool bUseStyleColor)
     bool bCellContrast = bUseStyleColor &&
             Application::GetSettings().GetStyleSettings().GetHighContrastMode();
 
-    SfxItemSet* pSet = new SfxItemSet( mpEngine->GetEmptyItemSet() );
-    mpPattern->FillEditItemSet( pSet, mpCondSet );
+    auto pSet = std::make_unique<SfxItemSet>( mpEngine->GetEmptyItemSet() );
+    mpPattern->FillEditItemSet( pSet.get(), mpCondSet );
     if ( mpPreviewFontSet )
     {
         const SfxPoolItem* pItem;
@@ -2424,7 +2424,8 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool bUseStyleColor)
             pSet->Put(*pItem);
         }
     }
-    mpEngine->SetDefaults( pSet );
+    bool bParaHyphenate = pSet->Get(EE_PARA_HYPHENATE).GetValue();
+    mpEngine->SetDefaults( std::move(pSet) );
     mpOldPattern = mpPattern;
     mpOldCondSet = mpCondSet;
     mpOldPreviewFontSet = mpPreviewFontSet;
@@ -2436,7 +2437,7 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool bUseStyleColor)
         nControl &= ~EEControlBits::ONECHARPERLINE;
     mpEngine->SetControlWord( nControl );
 
-    if ( !mbHyphenatorSet && pSet->Get(EE_PARA_HYPHENATE).GetValue() )
+    if ( !mbHyphenatorSet && bParaHyphenate )
     {
         //  set hyphenator the first time it is needed
         css::uno::Reference<css::linguistic2::XHyphenator> xXHyphenator( LinguMgr::GetHyphenator() );
@@ -4573,8 +4574,8 @@ void ScOutputData::DrawRotated(bool bPixelToLogic)
                             // StringDiffer doesn't look at hyphenate, language items
                             if ( pPattern != pOldPattern || pCondSet != pOldCondSet )
                             {
-                                SfxItemSet* pSet = new SfxItemSet( pEngine->GetEmptyItemSet() );
-                                pPattern->FillEditItemSet( pSet, pCondSet );
+                                auto pSet = std::make_unique<SfxItemSet>( pEngine->GetEmptyItemSet() );
+                                pPattern->FillEditItemSet( pSet.get(), pCondSet );
 
                                                                     // adjustment for EditEngine
                                 SvxAdjust eSvxAdjust = SvxAdjust::Left;
@@ -4583,7 +4584,8 @@ void ScOutputData::DrawRotated(bool bPixelToLogic)
                                 // adjustment for bBreak is omitted here
                                 pSet->Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) );
 
-                                pEngine->SetDefaults( pSet );
+                                bool bParaHyphenate = pSet->Get(EE_PARA_HYPHENATE).GetValue();
+                                pEngine->SetDefaults( std::move(pSet) );
                                 pOldPattern = pPattern;
                                 pOldCondSet = pCondSet;
 
@@ -4594,7 +4596,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic)
                                     nControl &= ~EEControlBits::ONECHARPERLINE;
                                 pEngine->SetControlWord( nControl );
 
-                                if ( !bHyphenatorSet && pSet->Get(EE_PARA_HYPHENATE).GetValue() )
+                                if ( !bHyphenatorSet && bParaHyphenate )
                                 {
                                     //  set hyphenator the first time it is needed
                                     css::uno::Reference<css::linguistic2::XHyphenator> xXHyphenator( LinguMgr::GetHyphenator() );
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index 905ccf43612b..fab83e4f7249 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -507,11 +507,10 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
                 new ScEditEngineDefaulter(EditEngine::CreatePool(), true));
 
             pEditEng->SetRefMapMode(aMMMode);
-            SfxItemSet* pEditDefaults = new SfxItemSet( pEditEng->GetEmptyItemSet() );
-            rDefPattern.FillEditItemSet(pEditDefaults);
-            pEditEng->SetDefaults(pEditDefaults);
-
+            auto pEditDefaults = std::make_unique<SfxItemSet>( pEditEng->GetEmptyItemSet() );
+            rDefPattern.FillEditItemSet(pEditDefaults.get());
             pEditDefaults->Put(SvxColorItem(COL_LIGHTGRAY, EE_CHAR_COLOR));
+            pEditEng->SetDefaults(std::move(pEditDefaults));
 
             OUString aEmptyMsg;
             if (mbHasEmptyRangeTable)


More information about the Libreoffice-commits mailing list