From 1e2682235cded9a7cd90e55f0bfc60a1285e9a46 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 18 Apr 2019 19:25:06 +0200 Subject: WIP: Further preparations for deeper Item changes (1) Migrated all still existing binary load/save stuff in SfxPoolItem to legacy files. Isolated from Item implementations. Adapted all usages. No more methods Create/Store needed, also GetVersion removed (2) Removed operator= for SfxPoolItem. Adapted all usages. Goal ist to handle Items more as Objects ('Object-Oriented') in the sense to move/handle instances, not to copy one instance over another one (which is more and more problematic with hard to copy content as UNO API stuff or similar). This lead to much more usages of std::shared_ptr which correlates well with future plans fr Items (see dev branch). Next logic step will be to also remove copy constructor Linux build and corrections done Fixed Writer test and removed unused defines Fixed another unused m,acro Started to unify the AutoFormat stuff Changes to OUString constructor usages, tests completely No idea why, but SfxStringItem constructor which takes a OUString& now insists of not getting ::OUString's handed in - changed all 'SfxStringItem.*OUString.*".*"' accordingly Change-Id: Ibed7358b18fb019994a7490332b9d797a6694c29 Reviewed-on: https://gerrit.libreoffice.org/71075 Tested-by: Jenkins Reviewed-by: Armin Le Grand --- sw/source/uibase/shells/textsh.cxx | 54 +++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 21 deletions(-) (limited to 'sw/source/uibase/shells/textsh.cxx') diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx index 3b7b5d41d57e..20fad8442156 100644 --- a/sw/source/uibase/shells/textsh.cxx +++ b/sw/source/uibase/shells/textsh.cxx @@ -905,21 +905,26 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq ) rSh.GetCurAttr( aSet ); SvtScriptType nScript = rSh.GetScriptType(); - SvxFontItem aFont( RES_CHRATR_FONT ); + std::shared_ptr aFont(std::make_shared(RES_CHRATR_FONT)); { SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() ); aSetItem.GetItemSet().Put( aSet, false ); const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript ); if( pI ) - aFont = *static_cast(pI); + { + aFont.reset(static_cast(pI->Clone())); + } else - aFont = static_cast( + { + aFont.reset(static_cast( aSet.Get( GetWhichOfScript( RES_CHRATR_FONT, - SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) ))); + SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) )).Clone())); + } + if (aFontName.isEmpty()) - aFontName = aFont.GetFamilyName(); + aFontName = aFont->GetFamilyName(); } vcl::Font aNewFont(aFontName, Size(1,1)); // Size only because CTOR. @@ -934,7 +939,7 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq ) if( aFontName.isEmpty() && !sSymbolFont.isEmpty() ) aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) ); else - aAllSet.Put( SfxStringItem( SID_FONT_NAME, aFont.GetFamilyName() ) ); + aAllSet.Put( SfxStringItem( SID_FONT_NAME, aFont->GetFamilyName() ) ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); ScopedVclPtr pDlg(pFact->CreateCharMapDialog(GetView().GetFrameWeld(), aAllSet, true)); @@ -961,11 +966,15 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq ) aSetItem.GetItemSet().Put( aSet, false ); const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript ); if( pI ) - aFont = *static_cast(pI); + { + aFont.reset(static_cast(pI->Clone())); + } else - aFont = static_cast(aSet.Get( GetWhichOfScript( + { + aFont.reset(static_cast(aSet.Get( GetWhichOfScript( RES_CHRATR_FONT, - SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) ))); + SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) )).Clone())); + } } // Insert character. @@ -974,11 +983,11 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq ) // #108876# a font attribute has to be set always due to a guessed script type if( !aNewFont.GetFamilyName().isEmpty() ) { - SvxFontItem aNewFontItem( aFont ); - aNewFontItem.SetFamilyName( aNewFont.GetFamilyName() ); - aNewFontItem.SetFamily( aNewFont.GetFamilyType()); - aNewFontItem.SetPitch( aNewFont.GetPitch()); - aNewFontItem.SetCharSet( aNewFont.GetCharSet() ); + std::shared_ptr aNewFontItem(static_cast(aFont->Clone())); + aNewFontItem->SetFamilyName( aNewFont.GetFamilyName() ); + aNewFontItem->SetFamily( aNewFont.GetFamilyType()); + aNewFontItem->SetPitch( aNewFont.GetPitch()); + aNewFontItem->SetCharSet( aNewFont.GetCharSet() ); SfxItemSet aRestoreSet( GetPool(), svl::ItemsSetWhich(RES_CHRATR_FONT); + aSet.Put( *aNewFontItem ); } if( SvtScriptType::ASIAN & nScript ) { aRestoreSet.Put( aSet.Get( RES_CHRATR_CJK_FONT ) ); - aNewFontItem.SetWhich(RES_CHRATR_CJK_FONT); - aSet.Put( aNewFontItem ); + aNewFontItem->SetWhich(RES_CHRATR_CJK_FONT); + aSet.Put( *aNewFontItem ); } if( SvtScriptType::COMPLEX & nScript ) { aRestoreSet.Put( aSet.Get( RES_CHRATR_CTL_FONT ) ); - aNewFontItem.SetWhich(RES_CHRATR_CTL_FONT); - aSet.Put( aNewFontItem ); + aNewFontItem->SetWhich(RES_CHRATR_CTL_FONT); + aSet.Put( *aNewFontItem ); } rSh.SetMark(); @@ -1020,7 +1029,10 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq ) rSh.ClearMark(); rSh.UpdateAttr(); - aFont = aNewFontItem; + + // Why was this done? aFont is not used anymore below, we are not + // in a loop and it's a local variable...? + // aFont = aNewFontItem; } rSh.EndAllAction(); -- cgit