diff options
author | Armin Le Grand <Armin.Le.Grand@me.com> | 2019-04-18 19:25:06 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2019-04-25 19:59:04 +0200 |
commit | 1e2682235cded9a7cd90e55f0bfc60a1285e9a46 (patch) | |
tree | 17457bc49d6faf37270c8a481b94765f58a5f434 /sw/source/uibase/shells/textsh.cxx | |
parent | 5e4c1e6ba425ce0b75864e4584a846957b032e61 (diff) |
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 <Armin.Le.Grand@me.com>
Diffstat (limited to 'sw/source/uibase/shells/textsh.cxx')
-rw-r--r-- | sw/source/uibase/shells/textsh.cxx | 54 |
1 files changed, 33 insertions, 21 deletions
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<SvxFontItem> aFont(std::make_shared<SvxFontItem>(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<const SvxFontItem*>(pI); + { + aFont.reset(static_cast<SvxFontItem*>(pI->Clone())); + } else - aFont = static_cast<const SvxFontItem&>( + { + aFont.reset(static_cast<SvxFontItem*>( 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<SfxAbstractDialog> 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<const SvxFontItem*>(pI); + { + aFont.reset(static_cast<SvxFontItem*>(pI->Clone())); + } else - aFont = static_cast<const SvxFontItem&>(aSet.Get( GetWhichOfScript( + { + aFont.reset(static_cast<SvxFontItem*>(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<SvxFontItem> aNewFontItem(static_cast<SvxFontItem*>(aFont->Clone())); + aNewFontItem->SetFamilyName( aNewFont.GetFamilyName() ); + aNewFontItem->SetFamily( aNewFont.GetFamilyType()); + aNewFontItem->SetPitch( aNewFont.GetPitch()); + aNewFontItem->SetCharSet( aNewFont.GetCharSet() ); SfxItemSet aRestoreSet( GetPool(), svl::Items<RES_CHRATR_FONT, RES_CHRATR_FONT, RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT, @@ -988,20 +997,20 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq ) if( SvtScriptType::LATIN & nScript ) { aRestoreSet.Put( aSet.Get( RES_CHRATR_FONT ) ); - aNewFontItem.SetWhich(RES_CHRATR_FONT); - aSet.Put( aNewFontItem ); + aNewFontItem->SetWhich(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(); |