dbaccess/source/ui/app/DocumentInfoPreview.cxx | 2 - include/editeng/editeng.hxx | 2 - sc/inc/editutil.hxx | 16 ++++++---- sc/source/core/data/column2.cxx | 14 ++++---- sc/source/core/data/documen2.cxx | 6 +-- sc/source/core/data/documen8.cxx | 10 +++--- sc/source/core/tool/editutil.cxx | 40 +++++++++++++++---------- sc/source/ui/Accessibility/AccessibleText.cxx | 14 ++++---- sc/source/ui/dbgui/csvgrid.cxx | 32 ++++++++++---------- sc/source/ui/unoobj/textuno.cxx | 26 ++++++++-------- sc/source/ui/view/editsh.cxx | 5 +-- sc/source/ui/view/gridwin.cxx | 8 ++--- sc/source/ui/view/printfun.cxx | 8 ++--- sc/source/ui/view/viewfun4.cxx | 6 +-- sd/source/ui/func/fuinsfil.cxx | 4 +- sd/source/ui/view/NotesPanelView.cxx | 2 - sw/source/uibase/docvw/AnnotationWin2.cxx | 4 +- 17 files changed, 107 insertions(+), 92 deletions(-)
New commits: commit fa706421c9a981df11814cd845fe901181c49974 Author: Mike Kaganski <[email protected]> AuthorDate: Fri Nov 15 13:04:58 2024 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Sat Nov 23 16:05:36 2024 +0100 Avoid new string allocations, when only checking if empty Change-Id: I35a44dedd27b5c3470ed035e64ec0461d8d0cbdf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177074 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins diff --git a/dbaccess/source/ui/app/DocumentInfoPreview.cxx b/dbaccess/source/ui/app/DocumentInfoPreview.cxx index ed7f9f862c97..f12de3fbe515 100644 --- a/dbaccess/source/ui/app/DocumentInfoPreview.cxx +++ b/dbaccess/source/ui/app/DocumentInfoPreview.cxx @@ -119,7 +119,7 @@ namespace void ODocumentInfoPreview::insertEntry( std::u16string_view title, OUString const & value) { - if (!m_xEditEngine->GetText().isEmpty()) { + if (m_xEditEngine->HasText()) { m_xEditEngine->QuickInsertText(u" "_ustr, InsertAtEnd(*m_xEditEngine)); } diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx index f78aefc5cffa..ef1ec563d3b5 100644 --- a/include/editeng/editeng.hxx +++ b/include/editeng/editeng.hxx @@ -194,7 +194,6 @@ private: SAL_DLLPRIVATE void HandleBeginPasteOrDrop(PasteOrDropInfos& rInfos); SAL_DLLPRIVATE void HandleEndPasteOrDrop(PasteOrDropInfos& rInfos); - SAL_DLLPRIVATE bool HasText() const; SAL_DLLPRIVATE const EditSelectionEngine& GetSelectionEngine() const; SAL_DLLPRIVATE void SetInSelectionMode(bool b); @@ -278,6 +277,7 @@ public: SAL_DLLPRIVATE void SetMinColumnWrapHeight(tools::Long nVal); + bool HasText() const; OUString GetText( LineEnd eEnd = LINEEND_LF ) const; OUString GetText( const ESelection& rSelection ) const; sal_Int32 GetTextLen() const; diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx index 2e1b14c39a47..89d2ffc11af3 100644 --- a/sc/source/ui/unoobj/textuno.cxx +++ b/sc/source/ui/unoobj/textuno.cxx @@ -825,7 +825,7 @@ SvxTextForwarder* ScCellTextData::GetTextForwarder() // Note: CppunitTest_sc_macros_test testTdf116127 will fail if // pEditEngine->SetTextNewDefaults() is passed an empty string // and pEditEngine->GetText() is empty string. - if (!aText.isEmpty() || !pEditEngine->GetText().isEmpty()) + if (!aText.isEmpty() || pEditEngine->HasText()) pEditEngine->SetTextNewDefaults(aText, std::move(pDefaults)); else pEditEngine->SetDefaults(std::move(pDefaults)); diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx index ce39cd33d9a9..3fa202c29a3f 100644 --- a/sc/source/ui/view/editsh.cxx +++ b/sc/source/ui/view/editsh.cxx @@ -347,10 +347,9 @@ void ScEditShell::Execute( SfxRequest& rReq ) EditView* pActiveView = pHdl->GetActiveView(); if( pActiveView ) { - OUString sInput = rEngine.GetText(); ESelection aSel( pActiveView->GetSelection() ); - if( aSel.HasRange() ) - sInput = pActiveView->GetSelected(); + OUString sInput(aSel.HasRange() ? pActiveView->GetSelected() + : rEngine.GetText()); if( aSel.nStartPos > aSel.nEndPos ) aSel.nEndPos = aSel.nStartPos; diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx index 8b67b00424b1..46253dad1467 100644 --- a/sd/source/ui/func/fuinsfil.cxx +++ b/sd/source/ui/func/fuinsfil.cxx @@ -441,7 +441,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium) ErrCode nErr = aOutliner.Read( *pStream, pMedium->GetBaseURL(), nFormat, mpDocSh->GetHeaderAttributes() ); - if (nErr || aOutliner.GetEditEngine().GetText().isEmpty()) + if (nErr || !aOutliner.GetEditEngine().HasText()) { std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(mpWindow->GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, SdResId(STR_READ_DATA_ERROR))); @@ -586,7 +586,7 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium) ErrCode nErr = aOutliner.Read(*pStream, pMedium->GetBaseURL(), nFormat, mpDocSh->GetHeaderAttributes()); - if (nErr || aOutliner.GetEditEngine().GetText().isEmpty()) + if (nErr || !aOutliner.GetEditEngine().HasText()) { std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(mpWindow->GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, SdResId(STR_READ_DATA_ERROR))); diff --git a/sd/source/ui/view/NotesPanelView.cxx b/sd/source/ui/view/NotesPanelView.cxx index 05ef63aeb3fd..037fb0809cf5 100644 --- a/sd/source/ui/view/NotesPanelView.cxx +++ b/sd/source/ui/view/NotesPanelView.cxx @@ -214,7 +214,7 @@ void NotesPanelView::onLoseFocus() SdrTextObj* pNotesTextObj = getNotesTextObj(); if (pNotesTextObj) { - if (maOutliner.GetEditEngine().GetText().getLength() == 0) + if (!maOutliner.GetEditEngine().HasText()) { // if the notes are empty restore the placeholder text and state. SdPage* pPage = dynamic_cast<SdPage*>(pNotesTextObj->getSdrPageFromSdrObject()); diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx index b3634148e7fe..4979045c48dd 100644 --- a/sw/source/uibase/docvw/AnnotationWin2.cxx +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -1026,7 +1026,7 @@ void SwAnnotationWin::DeactivatePostIt() if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) GetOutlinerView()->SetBackgroundColor(COL_TRANSPARENT); - if (!mnDeleteEventId && !IsReadOnlyOrProtected() && mpOutliner->GetEditEngine().GetText().isEmpty()) + if (!mnDeleteEventId && !IsReadOnlyOrProtected() && !mpOutliner->GetEditEngine().HasText()) { mnDeleteEventId = Application::PostUserEvent( LINK( this, SwAnnotationWin, DeleteHdl), nullptr, true ); } @@ -1059,7 +1059,7 @@ void SwAnnotationWin::ExecuteCommand(sal_uInt16 nSlot) const bool bReply = nSlot == FN_REPLY; // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note // will be created - if (!mrMgr.IsAnswer() && !mpOutliner->GetEditEngine().GetText().isEmpty()) + if (!mrMgr.IsAnswer() && mpOutliner->GetEditEngine().HasText()) { OutlinerParaObject aPara(GetOutlinerView()->GetEditView().CreateTextObject()); mrMgr.RegisterAnswer(aPara); commit ee331d51c84b0d6fcbd65810843ab6c836d9dea9 Author: Mike Kaganski <[email protected]> AuthorDate: Fri Nov 15 12:43:10 2024 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Sat Nov 23 16:05:27 2024 +0100 Reduce copying of ScEditEngineDefaulter's SfxItemSet Change-Id: Ifea96f2cf586b4e5b63761e2f03944dade764430 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177073 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx index 247f1cc783ae..0173b4aa7f26 100644 --- a/sc/inc/editutil.hxx +++ b/sc/inc/editutil.hxx @@ -130,8 +130,8 @@ public: ScEditEngineDefaulter( const ScEditEngineDefaulter& rOrg ); virtual ~ScEditEngineDefaulter() override; - /// Creates a copy of SfxItemSet if bRememberCopy set - void SetDefaults( const SfxItemSet& rDefaults, bool bRememberCopy = true ); + /// Creates a copy of SfxItemSet + void SetDefaults( const SfxItemSet& rDefaults ); /// Becomes the owner of the SfxItemSet void SetDefaults( std::unique_ptr<SfxItemSet> pDefaults ); @@ -148,13 +148,15 @@ public: void SetTextCurrentDefaults( const EditTextObject& rTextObject ); /// Current defaults are not applied, new defaults are applied void SetTextNewDefaults( const EditTextObject& rTextObject, - const SfxItemSet& rDefaults, bool bRememberCopy = true ); + std::unique_ptr<SfxItemSet> pDefaults ); + /// New defaults are applied, but not stored + void SetTextTempDefaults( const EditTextObject& rTextObject, + const SfxItemSet& rDefaults ); /// SetText and apply defaults already set void SetTextCurrentDefaults( const OUString& rText ); /// Current defaults are not applied, new defaults are applied - void SetTextNewDefaults( const OUString& rText, - const SfxItemSet& rDefaults ); + void SetTextNewDefaults( const OUString& rText, std::unique_ptr<SfxItemSet> pDefaults ); /// Paragraph attributes that are not defaults are copied to /// character attributes and all paragraph attributes reset @@ -163,6 +165,10 @@ public: /// Re-apply existing defaults if set, same as in SetText, /// but without EnableUndo/SetUpdateMode. void RepeatDefaults(); + +private: + /// Apply the passed defaults, without storing them + void ApplyDefaults(const SfxItemSet& rNewSet); }; // for field commands (or just fields?) in a table diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index e99933785860..e0e5505da9aa 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -415,22 +415,22 @@ tools::Long ScColumn::GetNeededSize( pDev->SetMapMode( aHMMMode ); pEngine->SetRefDevice( pDev ); rDocument.ApplyAsianEditSettings( *pEngine ); - SfxItemSet aSet( pEngine->GetEmptyItemSet() ); + auto pSet = std::make_unique<SfxItemSet>(pEngine->GetEmptyItemSet()); if ( ScStyleSheet* pPreviewStyle = rDocument.GetPreviewCellStyle( nCol, nRow, nTab ) ) { ScPatternAttr aPreviewPattern( *pPattern ); aPreviewPattern.SetStyleSheet(pPreviewStyle); - aPreviewPattern.FillEditItemSet( &aSet, pCondSet ); + aPreviewPattern.FillEditItemSet(pSet.get(), pCondSet); } else { SfxItemSet* pFontSet = rDocument.GetPreviewFont( nCol, nRow, nTab ); - pPattern->FillEditItemSet( &aSet, pFontSet ? pFontSet : pCondSet ); + pPattern->FillEditItemSet(pSet.get(), pFontSet ? pFontSet : pCondSet); } // no longer needed, are set with the text (is faster) // pEngine->SetDefaults( pSet ); - if ( aSet.Get(EE_PARA_HYPHENATE).GetValue() ) { + if ( pSet->Get(EE_PARA_HYPHENATE).GetValue() ) { css::uno::Reference<css::linguistic2::XHyphenator> xXHyphenator( LinguMgr::GetHyphenator() ); pEngine->SetHyphenator( xXHyphenator ); @@ -483,7 +483,7 @@ tools::Long ScColumn::GetNeededSize( if (aCell.getType() == CELLTYPE_EDIT) { - pEngine->SetTextNewDefaults(*aCell.getEditText(), std::move(aSet)); + pEngine->SetTextNewDefaults(*aCell.getEditText(), std::move(pSet)); } else { @@ -493,9 +493,9 @@ tools::Long ScColumn::GetNeededSize( rOptions.bFormula); if (!aString.isEmpty()) - pEngine->SetTextNewDefaults(aString, std::move(aSet)); + pEngine->SetTextNewDefaults(aString, std::move(pSet)); else - pEngine->SetDefaults(std::move(aSet)); + pEngine->SetDefaults(std::move(pSet)); } bool bEngineVertical = pEngine->IsEffectivelyVertical(); diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index dc6441a3e29b..225eac4502c2 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -519,9 +519,9 @@ ScNoteEditEngine& ScDocument::GetNoteEngine() mpNoteEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM)); ApplyAsianEditSettings( *mpNoteEngine ); const SfxItemSet& rItemSet(getCellAttributeHelper().getDefaultCellAttribute().GetItemSet()); - SfxItemSet aEEItemSet( mpNoteEngine->GetEmptyItemSet() ); - ScPatternAttr::FillToEditItemSet( aEEItemSet, rItemSet ); - mpNoteEngine->SetDefaults( std::move(aEEItemSet) ); // edit engine takes ownership + auto pEEItemSet = std::make_unique<SfxItemSet>(mpNoteEngine->GetEmptyItemSet()); + ScPatternAttr::FillToEditItemSet(*pEEItemSet, rItemSet); + 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 5fb5eec14acc..75a3763f6fcc 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -1246,19 +1246,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 aDefaults( pEngine->GetEmptyItemSet() ); + auto pDefaults = std::make_unique<SfxItemSet>( pEngine->GetEmptyItemSet() ); if ( ScStyleSheet* pPreviewStyle = GetPreviewCellStyle( nCol, nRow, nTab ) ) { ScPatternAttr aPreviewPattern( *pPattern ); aPreviewPattern.SetStyleSheet(pPreviewStyle); - aPreviewPattern.FillEditItemSet( &aDefaults ); + aPreviewPattern.FillEditItemSet(pDefaults.get()); } else { SfxItemSet* pFontSet = GetPreviewFont( nCol, nRow, nTab ); - pPattern->FillEditItemSet( &aDefaults, pFontSet ); + pPattern->FillEditItemSet(pDefaults.get(), pFontSet); } - pEngine->SetDefaults( std::move(aDefaults) ); + pEngine->SetDefaults(std::move(pDefaults)); if (aCell.getType() == CELLTYPE_STRING) pEngine->SetTextCurrentDefaults(aCell.getSharedString()->getString()); else if (aCell.getEditText()) @@ -1280,7 +1280,7 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, Transliteratio if ( aTester.NeedsObject() ) { // remove defaults (paragraph attributes) before creating text object - pEngine->SetDefaults( std::make_unique<SfxItemSet>( pEngine->GetEmptyItemSet() ) ); + pEngine->SetDefaults(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 3c3dac0ee4e9..69eb8a1a8181 100644 --- a/sc/source/core/tool/editutil.cxx +++ b/sc/source/core/tool/editutil.cxx @@ -562,13 +562,8 @@ ScEditEngineDefaulter::~ScEditEngineDefaulter() { } -void ScEditEngineDefaulter::SetDefaults( const SfxItemSet& rSet, bool bRememberCopy ) +void ScEditEngineDefaulter::ApplyDefaults(const SfxItemSet& rNewSet) { - if ( bRememberCopy ) - { - m_pDefaults = std::make_unique<SfxItemSet>( rSet ); - } - const SfxItemSet& rNewSet = bRememberCopy ? *m_pDefaults : rSet; bool bUndo = IsUndoEnabled(); EnableUndo( false ); bool bUpdateMode = SetUpdateLayout( false ); @@ -583,11 +578,16 @@ void ScEditEngineDefaulter::SetDefaults( const SfxItemSet& rSet, bool bRememberC EnableUndo( true ); } +void ScEditEngineDefaulter::SetDefaults(const SfxItemSet& rSet) +{ + SetDefaults(std::make_unique<SfxItemSet>(rSet)); +} + void ScEditEngineDefaulter::SetDefaults( std::unique_ptr<SfxItemSet> pSet ) { m_pDefaults = std::move(pSet); if ( m_pDefaults ) - SetDefaults( *m_pDefaults, false ); + ApplyDefaults(*m_pDefaults); } void ScEditEngineDefaulter::SetDefaultItem( const SfxPoolItem& rItem ) @@ -597,7 +597,7 @@ void ScEditEngineDefaulter::SetDefaultItem( const SfxPoolItem& rItem ) m_pDefaults = std::make_unique<SfxItemSet>( GetEmptyItemSet() ); } m_pDefaults->Put( rItem ); - SetDefaults( *m_pDefaults, false ); + ApplyDefaults(*m_pDefaults); } const SfxItemSet& ScEditEngineDefaulter::GetDefaults() @@ -614,17 +614,27 @@ void ScEditEngineDefaulter::SetTextCurrentDefaults( const EditTextObject& rTextO bool bUpdateMode = SetUpdateLayout( false ); SetText( rTextObject ); if ( m_pDefaults ) - SetDefaults( *m_pDefaults, false ); + ApplyDefaults(*m_pDefaults); + if ( bUpdateMode ) + SetUpdateLayout( true ); +} + +void ScEditEngineDefaulter::SetTextNewDefaults(const EditTextObject& rTextObject, + std::unique_ptr<SfxItemSet> pDefaults) +{ + bool bUpdateMode = SetUpdateLayout( false ); + SetText( rTextObject ); + SetDefaults(std::move(pDefaults)); if ( bUpdateMode ) SetUpdateLayout( true ); } -void ScEditEngineDefaulter::SetTextNewDefaults( const EditTextObject& rTextObject, - const SfxItemSet& rSet, bool bRememberCopy ) +void ScEditEngineDefaulter::SetTextTempDefaults(const EditTextObject& rTextObject, + const SfxItemSet& rSet) { bool bUpdateMode = SetUpdateLayout( false ); SetText( rTextObject ); - SetDefaults( rSet, bRememberCopy ); + ApplyDefaults(rSet); if ( bUpdateMode ) SetUpdateLayout( true ); } @@ -634,17 +644,17 @@ void ScEditEngineDefaulter::SetTextCurrentDefaults( const OUString& rText ) bool bUpdateMode = SetUpdateLayout( false ); SetText( rText ); if ( m_pDefaults ) - SetDefaults( *m_pDefaults, false ); + ApplyDefaults(*m_pDefaults); if ( bUpdateMode ) SetUpdateLayout( true ); } void ScEditEngineDefaulter::SetTextNewDefaults( const OUString& rText, - const SfxItemSet& rSet ) + std::unique_ptr<SfxItemSet> pDefaults ) { bool bUpdateMode = SetUpdateLayout( false ); SetText( rText ); - SetDefaults( rSet ); + SetDefaults(std::move(pDefaults)); if ( bUpdateMode ) SetUpdateLayout( true ); } diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx index 3413772e4707..98a69698f5fe 100644 --- a/sc/source/ui/Accessibility/AccessibleText.cxx +++ b/sc/source/ui/Accessibility/AccessibleText.cxx @@ -1143,15 +1143,15 @@ SvxTextForwarder* ScAccessibleHeaderTextData::GetTextForwarder() pCellAttributeDefault = &pTmp->getDefaultCellAttribute(); } - SfxItemSet aDefaults( pHdrEngine->GetEmptyItemSet() ); - pCellAttributeDefault->FillEditItemSet( &aDefaults ); + auto pDefaults = std::make_unique<SfxItemSet>(pHdrEngine->GetEmptyItemSet()); + pCellAttributeDefault->FillEditItemSet(pDefaults.get()); // FillEditItemSet adjusts font height to 1/100th mm, // but for header/footer twips is needed, as in the PatternAttr: - aDefaults.Put( pCellAttributeDefault->GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT) ); - aDefaults.Put( pCellAttributeDefault->GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK) ); - aDefaults.Put( pCellAttributeDefault->GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL) ); - aDefaults.Put( SvxAdjustItem( meAdjust, EE_PARA_JUST ) ); - pHdrEngine->SetDefaults( aDefaults ); + pDefaults->Put( pCellAttributeDefault->GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT) ); + pDefaults->Put( pCellAttributeDefault->GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK) ); + pDefaults->Put( pCellAttributeDefault->GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL) ); + pDefaults->Put( SvxAdjustItem( meAdjust, EE_PARA_JUST ) ); + pHdrEngine->SetDefaults(std::move(pDefaults)); ScHeaderFieldData aData; if (mpViewShell) diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx index 869dde5ca95b..fde4197b9ac8 100644 --- a/sc/source/ui/dbgui/csvgrid.cxx +++ b/sc/source/ui/dbgui/csvgrid.cxx @@ -285,37 +285,37 @@ void ScCsvGrid::InitFonts() ::GetDefaultFonts( aLatinItem, aAsianItem, aComplexItem ); // create item set for defaults - SfxItemSet aDefSet( mpEditEngine->GetEmptyItemSet() ); - EditEngine::SetFontInfoInItemSet( aDefSet, maMonoFont ); - aDefSet.Put( aAsianItem ); - aDefSet.Put( aComplexItem ); + auto pDefSet = std::make_unique<SfxItemSet>(mpEditEngine->GetEmptyItemSet()); + EditEngine::SetFontInfoInItemSet(*pDefSet, maMonoFont); + pDefSet->Put(aAsianItem); + pDefSet->Put(aComplexItem); // set Asian/Complex font size to height of character in Latin font sal_uLong nFontHt = static_cast< sal_uLong >( maMonoFont.GetFontSize().Height() ); - aDefSet.Put( SvxFontHeightItem( nFontHt, 100, EE_CHAR_FONTHEIGHT_CJK ) ); - aDefSet.Put( SvxFontHeightItem( nFontHt, 100, EE_CHAR_FONTHEIGHT_CTL ) ); + pDefSet->Put(SvxFontHeightItem(nFontHt, 100, EE_CHAR_FONTHEIGHT_CJK)); + pDefSet->Put(SvxFontHeightItem(nFontHt, 100, EE_CHAR_FONTHEIGHT_CTL)); // copy other items from default font - const SfxPoolItem& rWeightItem = aDefSet.Get( EE_CHAR_WEIGHT ); + const SfxPoolItem& rWeightItem = pDefSet->Get(EE_CHAR_WEIGHT); std::unique_ptr<SfxPoolItem> pNewItem(rWeightItem.Clone()); pNewItem->SetWhich(EE_CHAR_WEIGHT_CJK); - aDefSet.Put( *pNewItem ); + pDefSet->Put(*pNewItem); pNewItem->SetWhich(EE_CHAR_WEIGHT_CTL); - aDefSet.Put( *pNewItem ); - const SfxPoolItem& rItalicItem = aDefSet.Get( EE_CHAR_ITALIC ); + pDefSet->Put(*pNewItem); + const SfxPoolItem& rItalicItem = pDefSet->Get(EE_CHAR_ITALIC); pNewItem.reset(rItalicItem.Clone()); pNewItem->SetWhich(EE_CHAR_ITALIC_CJK); - aDefSet.Put( *pNewItem ); + pDefSet->Put(*pNewItem); pNewItem->SetWhich(EE_CHAR_ITALIC_CTL); - aDefSet.Put( *pNewItem ); - const SfxPoolItem& rLangItem = aDefSet.Get( EE_CHAR_LANGUAGE ); + pDefSet->Put(*pNewItem); + const SfxPoolItem& rLangItem = pDefSet->Get(EE_CHAR_LANGUAGE); pNewItem.reset(rLangItem.Clone()); pNewItem->SetWhich(EE_CHAR_LANGUAGE_CJK); - aDefSet.Put( *pNewItem ); + pDefSet->Put(*pNewItem); pNewItem->SetWhich(EE_CHAR_LANGUAGE_CTL); - aDefSet.Put( *pNewItem ); + pDefSet->Put(*pNewItem); - mpEditEngine->SetDefaults( aDefSet ); + mpEditEngine->SetDefaults(std::move(pDefSet)); InvalidateGfx(); } diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx index 30b67d411f9f..2e1b14c39a47 100644 --- a/sc/source/ui/unoobj/textuno.cxx +++ b/sc/source/ui/unoobj/textuno.cxx @@ -190,14 +190,14 @@ SvxTextForwarder* ScHeaderFooterTextData::GetTextForwarder() pCellAttributeDefault = &pTmp->getDefaultCellAttribute(); } - SfxItemSet aDefaults( pHdrEngine->GetEmptyItemSet() ); - pCellAttributeDefault->FillEditItemSet( &aDefaults ); + auto pDefaults = std::make_unique<SfxItemSet>(pHdrEngine->GetEmptyItemSet()); + pCellAttributeDefault->FillEditItemSet(pDefaults.get()); // FillEditItemSet adjusts font height to 1/100th mm, // but for header/footer twips is needed, as in the PatternAttr: - aDefaults.Put( pCellAttributeDefault->GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT) ); - aDefaults.Put( pCellAttributeDefault->GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK) ) ; - aDefaults.Put( pCellAttributeDefault->GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL) ); - pHdrEngine->SetDefaults( aDefaults ); + pDefaults->Put( pCellAttributeDefault->GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT) ); + pDefaults->Put( pCellAttributeDefault->GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK) ) ; + pDefaults->Put( pCellAttributeDefault->GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL) ); + pHdrEngine->SetDefaults(std::move(pDefaults)); ScHeaderFieldData aData; ScHeaderFooterTextObj::FillDummyFieldData( aData ); @@ -799,19 +799,19 @@ SvxTextForwarder* ScCellTextData::GetTextForwarder() { ScDocument& rDoc = pDocShell->GetDocument(); - SfxItemSet aDefaults( pEditEngine->GetEmptyItemSet() ); + auto pDefaults = std::make_unique<SfxItemSet>(pEditEngine->GetEmptyItemSet()); if( const ScPatternAttr* pPattern = rDoc.GetPattern( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab() ) ) { - pPattern->FillEditItemSet( &aDefaults ); - pPattern->FillEditParaItems( &aDefaults ); // including alignment etc. (for reading) + pPattern->FillEditItemSet(pDefaults.get()); + pPattern->FillEditParaItems(pDefaults.get()); // including alignment etc. (for reading) } ScRefCellValue aCell(rDoc, aCellPos); if (aCell.getType() == CELLTYPE_EDIT) { const EditTextObject* pObj = aCell.getEditText(); - pEditEngine->SetTextNewDefaults(*pObj, aDefaults); + pEditEngine->SetTextNewDefaults(*pObj, std::move(pDefaults)); } else { @@ -826,9 +826,9 @@ SvxTextForwarder* ScCellTextData::GetTextForwarder() // pEditEngine->SetTextNewDefaults() is passed an empty string // and pEditEngine->GetText() is empty string. if (!aText.isEmpty() || !pEditEngine->GetText().isEmpty()) - pEditEngine->SetTextNewDefaults(aText, aDefaults); + pEditEngine->SetTextNewDefaults(aText, std::move(pDefaults)); else - pEditEngine->SetDefaults(aDefaults); + pEditEngine->SetDefaults(std::move(pDefaults)); } } diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 81c8a67e0ad6..5bb1f8f4c3fb 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -5792,10 +5792,10 @@ std::shared_ptr<ScFieldEditEngine> createEditEngine( ScDocShell* pDocSh, const S ScSizeDeviceProvider aProv(pDocSh); pEngine->SetRefDevice(aProv.GetDevice()); pEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM)); - SfxItemSet aDefault = pEngine->GetEmptyItemSet(); - rPat.FillEditItemSet(&aDefault); - aDefault.Put( SvxAdjustItem(toSvxAdjust(rPat), EE_PARA_JUST) ); - pEngine->SetDefaults(aDefault); + auto pDefault = std::make_unique<SfxItemSet>(pEngine->GetEmptyItemSet()); + rPat.FillEditItemSet(pDefault.get()); + pDefault->Put(SvxAdjustItem(toSvxAdjust(rPat), EE_PARA_JUST)); + pEngine->SetDefaults(std::move(pDefault)); return pEngine; } diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index ec1458323e9c..898bf636ff14 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -782,7 +782,7 @@ tools::Long ScPrintFunc::TextHeight( const EditTextObject* pObject ) if (!pObject) return 0; - pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false ); + pEditEngine->SetTextTempDefaults(*pObject, *pEditDefaults); return static_cast<tools::Long>(pEditEngine->GetTextHeight()); } @@ -1877,7 +1877,7 @@ void ScPrintFunc::PrintHF( tools::Long nPageNo, bool bHeader, tools::Long nStart if (pObject) { pEditDefaults->Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) ); - pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false ); + pEditEngine->SetTextTempDefaults(*pObject, *pEditDefaults); Point aDraw = aStart; tools::Long nDif = aPaperSize.Height() - static_cast<tools::Long>(pEditEngine->GetTextHeight()); if (nDif > 0) @@ -1891,7 +1891,7 @@ void ScPrintFunc::PrintHF( tools::Long nPageNo, bool bHeader, tools::Long nStart if (pObject) { pEditDefaults->Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) ); - pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false ); + pEditEngine->SetTextTempDefaults(*pObject, *pEditDefaults); Point aDraw = aStart; tools::Long nDif = aPaperSize.Height() - static_cast<tools::Long>(pEditEngine->GetTextHeight()); if (nDif > 0) @@ -1905,7 +1905,7 @@ void ScPrintFunc::PrintHF( tools::Long nPageNo, bool bHeader, tools::Long nStart if (pObject) { pEditDefaults->Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) ); - pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false ); + pEditEngine->SetTextTempDefaults(*pObject, *pEditDefaults); Point aDraw = aStart; tools::Long nDif = aPaperSize.Height() - static_cast<tools::Long>(pEditEngine->GetTextHeight()); if (nDif > 0) diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx index 835c526f7f0b..0edb654f2249 100644 --- a/sc/source/ui/view/viewfun4.cxx +++ b/sc/source/ui/view/viewfun4.cxx @@ -362,12 +362,12 @@ void ScViewFunc::DoThesaurus() pThesaurusEngine->SetRefDevice(GetViewData().GetActiveWin()->GetOutDev()); pThesaurusEngine->SetSpeller(xSpeller); MakeEditView(pThesaurusEngine.get(), nCol, nRow ); - SfxItemSet aEditDefaults(pThesaurusEngine->GetEmptyItemSet()); const ScPatternAttr* pPattern = rDoc.GetPattern(nCol, nRow, nTab); if (pPattern) { - pPattern->FillEditItemSet( &aEditDefaults ); - pThesaurusEngine->SetDefaults( aEditDefaults ); + auto pEditDefaults = std::make_unique<SfxItemSet>(pThesaurusEngine->GetEmptyItemSet()); + pPattern->FillEditItemSet(pEditDefaults.get()); + pThesaurusEngine->SetDefaults(std::move(pEditDefaults)); } if (aOldText.getType() == CELLTYPE_EDIT)
