used more TypeWhichId to avoid casting

Change-Id: Icd281619c1d86506d5f248234562a7cf2c5ead77
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196903
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2026-01-10 12:15:32 +01:00
parent 06ec063412
commit 558a189c7c
32 changed files with 41 additions and 63 deletions
+1 -2
View File
@@ -73,8 +73,7 @@ void SvxSearchFormatDialog::PageCreated(const OUString& rId, SfxTabPage& rPage)
const FontList* pApm_pFontList = nullptr;
if (SfxObjectShell* pSh = SfxObjectShell::Current())
{
const SvxFontListItem* pFLItem = static_cast<const SvxFontListItem*>(
pSh->GetItem( SID_ATTR_CHAR_FONTLIST ));
const SvxFontListItem* pFLItem = pSh->GetItem( SID_ATTR_CHAR_FONTLIST );
if ( pFLItem )
pApm_pFontList = pFLItem->GetFontList();
}
+3 -4
View File
@@ -349,12 +349,11 @@ const FontList* SvxCharNamePage::GetFontList() const
/* #110771# SvxFontListItem::GetFontList can return NULL */
if (SfxObjectShell* pDocSh = SfxObjectShell::Current())
{
const SfxPoolItem* pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
const SvxFontListItem* pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
if ( pItem != nullptr )
{
DBG_ASSERT(nullptr != static_cast<const SvxFontListItem*>(pItem)->GetFontList(),
"Where is the font list?");
m_pImpl->m_pFontList = static_cast<const SvxFontListItem*>(pItem )->GetFontList()->Clone();
DBG_ASSERT(nullptr != pItem->GetFontList(), "Where is the font list?");
m_pImpl->m_pFontList = pItem->GetFontList()->Clone();
}
}
if(!m_pImpl->m_pFontList)
+1 -2
View File
@@ -764,8 +764,7 @@ IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl, ValueSet*, void)
if (SfxObjectShell* pCurDocShell = SfxObjectShell::Current())
{
const SvxFontListItem* pFontListItem =
static_cast<const SvxFontListItem*>( pCurDocShell
->GetItem( SID_ATTR_CHAR_FONTLIST ));
pCurDocShell->GetItem( SID_ATTR_CHAR_FONTLIST );
pList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
}
}
+2 -4
View File
@@ -1392,8 +1392,7 @@ const vcl::Font* FindFont(std::u16string_view rFontName)
SfxObjectShell* pDocSh = SfxObjectShell::Current();
if (!pDocSh)
return nullptr;
const SvxFontListItem* pFonts
= static_cast<const SvxFontListItem*>(pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST));
const SvxFontListItem* pFonts = pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST);
const FontList* pList = pFonts ? pFonts->GetFontList() : nullptr;
if (pList && !rFontName.empty())
if (sal_Handle hMetric = pList->GetFirstFontMetric(rFontName))
@@ -6457,8 +6456,7 @@ static char* getFonts (const char* pCommand, const bool bBloatWithRepeatedSizes)
SfxObjectShell* pDocSh = SfxObjectShell::Current();
if (!pDocSh)
return nullptr;
const SvxFontListItem* pFonts = static_cast<const SvxFontListItem*>(
pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST));
const SvxFontListItem* pFonts = pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST);
const FontList* pList = pFonts ? pFonts->GetFontList() : nullptr;
if (!bBloatWithRepeatedSizes)
+2 -1
View File
@@ -67,6 +67,7 @@ class SvxWeightItem;
class SvxWidowsItem;
class SvxWordLineModeItem;
class SvxScriptHintItem;
class SvxFontListItem;
/*
These SID_SVX_START entries came from include/svx/svxids.hrc, avoid
@@ -95,7 +96,7 @@ class SvxScriptHintItem;
#define SID_ATTR_CHAR_CASEMAP TypedWhichId<SvxCaseMapItem>( SID_SVX_START + 19 )
#define SID_ATTR_CHAR_LANGUAGE TypedWhichId<SvxLanguageItem>( SID_SVX_START + 20 )
#define SID_ATTR_CHAR_ESCAPEMENT TypedWhichId<SvxEscapementItem>( SID_SVX_START + 21 )
#define SID_ATTR_CHAR_FONTLIST ( SID_SVX_START + 22 )
#define SID_ATTR_CHAR_FONTLIST TypedWhichId<SvxFontListItem>( SID_SVX_START + 22 )
#define SID_ATTR_BORDER_OUTER TypedWhichId<SvxBoxItem>( SID_SVX_START + 24 )
#define SID_ATTR_BORDER_SHADOW TypedWhichId<SvxShadowItem>( SID_SVX_START + 25 )
#define SID_ATTR_PARA_ADJUST TypedWhichId<SvxAdjustItem>( SID_SVX_START + 27 )
+1 -2
View File
@@ -718,8 +718,7 @@ void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unico
const FontList* pFontList = nullptr;
if( SfxObjectShell* pDocShell = GetDocShell() )
{
if( const SvxFontListItem* pInfoItem = static_cast< const SvxFontListItem* >(
pDocShell->GetItem( SID_ATTR_CHAR_FONTLIST ) ) )
if( const SvxFontListItem* pInfoItem = pDocShell->GetItem( SID_ATTR_CHAR_FONTLIST ) )
pFontList = pInfoItem->GetFontList();
}
+1 -2
View File
@@ -220,8 +220,7 @@ void XclImpFont::SetFontData( const XclFontData& rFontData, bool bHasCharSet )
{
if( ScDocShell* pDocShell = GetDocShell() )
{
if( const SvxFontListItem* pInfoItem = static_cast< const SvxFontListItem* >(
pDocShell->GetItem( SID_ATTR_CHAR_FONTLIST ) ) )
if( const SvxFontListItem* pInfoItem = pDocShell->GetItem( SID_ATTR_CHAR_FONTLIST ) )
{
if( const FontList* pFontList = pInfoItem->GetFontList() )
{
+2 -2
View File
@@ -87,11 +87,11 @@ void ScAttrDlg::PageCreated(const OUString& rPageId, SfxTabPage& rTabPage)
}
else if (rPageId == "font" && pDocSh)
{
const SfxPoolItem* pInfoItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
const SvxFontListItem* pInfoItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
SAL_WARN_IF(!pInfoItem, "sc.ui", "we should have a FontListItem normally here");
if (pInfoItem)
{
aSet.Put (SvxFontListItem(static_cast<const SvxFontListItem*>(pInfoItem)->GetFontList(), SID_ATTR_CHAR_FONTLIST ));
aSet.Put (SvxFontListItem(pInfoItem->GetFontList(), SID_ATTR_CHAR_FONTLIST ));
rTabPage.PageCreated(aSet);
}
}
+1 -2
View File
@@ -855,8 +855,7 @@ void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq )
{
if (SfxObjectShell* pObjSh = SfxObjectShell::Current())
{
const SvxFontListItem* pFontListItem = static_cast< const SvxFontListItem* >
( pObjSh->GetItem( SID_ATTR_CHAR_FONTLIST ) );
const SvxFontListItem* pFontListItem = pObjSh->GetItem( SID_ATTR_CHAR_FONTLIST );
const FontList* pFontList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
pOutView->GetEditView().ChangeFontSize( nSlot == SID_GROW_FONT_SIZE, pFontList );
mrViewData.GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
+1 -2
View File
@@ -54,8 +54,7 @@ void ScCharDlg::PageCreated(const OUString& rId, SfxTabPage &rPage)
SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
if (rId == "font")
{
SvxFontListItem aItem(*static_cast<const SvxFontListItem*>(
( m_rDocShell.GetItem( SID_ATTR_CHAR_FONTLIST) ) ) );
SvxFontListItem aItem(* m_rDocShell.GetItem( SID_ATTR_CHAR_FONTLIST) );
aSet.Put (SvxFontListItem( aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
rPage.PageCreated(aSet);
+3 -5
View File
@@ -131,12 +131,11 @@ void ScStyleDlg::PageCreated(const OUString& rPageId, SfxTabPage& rTabPage)
}
else if (rPageId == "font")
{
const SfxPoolItem* pInfoItem
= pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
const SvxFontListItem* pInfoItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
OSL_ENSURE( pInfoItem, "FontListItem not found!" );
aSet.Put (SvxFontListItem(static_cast<const SvxFontListItem&>(*pInfoItem).GetFontList(), SID_ATTR_CHAR_FONTLIST));
aSet.Put (SvxFontListItem(pInfoItem->GetFontList(), SID_ATTR_CHAR_FONTLIST));
rTabPage.PageCreated(aSet);
}
else if (rPageId == "background")
@@ -230,8 +229,7 @@ void ScDrawStyleDlg::PageCreated(const OUString& rPageId, SfxTabPage& rTabPage)
{
if (SfxObjectShell* pDocSh = SfxObjectShell::Current())
{
SvxFontListItem aItem(*static_cast<const SvxFontListItem*>(
pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST)));
SvxFontListItem aItem(*pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST));
aSet.Put(SvxFontListItem(aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
}
+1 -2
View File
@@ -1248,8 +1248,7 @@ void ScEditShell::ExecuteAttr(SfxRequest& rReq)
case SID_SHRINK_FONT_SIZE:
{
SfxObjectShell* pObjSh = SfxObjectShell::Current();
const SvxFontListItem* pFontListItem = static_cast<const SvxFontListItem*>
(pObjSh ? pObjSh->GetItem(SID_ATTR_CHAR_FONTLIST) : nullptr);
const SvxFontListItem* pFontListItem = (pObjSh ? pObjSh->GetItem(SID_ATTR_CHAR_FONTLIST) : nullptr);
const FontList* pFontList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
pEditView->ChangeFontSize( nSlot == SID_GROW_FONT_SIZE, pFontList );
rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
@@ -271,9 +271,9 @@ SdFontPropertyBox::SdFontPropertyBox(weld::Label* pLabel, weld::Container* pPare
if (SfxObjectShell* pDocSh = SfxObjectShell::Current())
{
auto pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
const SvxFontListItem* pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
if (pItem)
pFontList = static_cast<const SvxFontListItem*>(pItem)->GetFontList();
pFontList = pItem->GetFontList();
}
if (!pFontList)
+1 -1
View File
@@ -58,7 +58,7 @@ void SdCharDlg::PageCreated(const OUString& rId, SfxTabPage &rPage)
SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
if (rId == "font")
{
SvxFontListItem aItem(* static_cast<const SvxFontListItem*>( rDocShell.GetItem( SID_ATTR_CHAR_FONTLIST) ) );
SvxFontListItem aItem(* rDocShell.GetItem( SID_ATTR_CHAR_FONTLIST) );
aSet.Put (SvxFontListItem( aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
rPage.PageCreated(aSet);
+1 -1
View File
@@ -262,7 +262,7 @@ void SdPresLayoutTemplateDlg::PageCreated(const OUString& rId, SfxTabPage &rPage
}
else if (rId == "font")
{
SvxFontListItem aItem(*static_cast<const SvxFontListItem*>(mpDocShell->GetItem( SID_ATTR_CHAR_FONTLIST) ) );
SvxFontListItem aItem(*mpDocShell->GetItem( SID_ATTR_CHAR_FONTLIST) );
aSet.Put (SvxFontListItem( aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
rPage.PageCreated(aSet);
}
+1 -2
View File
@@ -128,8 +128,7 @@ void SdTabTemplateDlg::PageCreated(const OUString& rId, SfxTabPage &rPage)
}
else if (rId == "font")
{
SvxFontListItem aItem(*static_cast<const SvxFontListItem*>(
rDocShell.GetItem( SID_ATTR_CHAR_FONTLIST) ) );
SvxFontListItem aItem(*rDocShell.GetItem( SID_ATTR_CHAR_FONTLIST));
aSet.Put (SvxFontListItem( aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
rPage.PageCreated(aSet);
+1 -1
View File
@@ -471,7 +471,7 @@ void TextObjectBar::Execute(SfxRequest& rReq)
case SID_GROW_FONT_SIZE:
case SID_SHRINK_FONT_SIZE:
{
const SvxFontListItem* pFonts = static_cast<const SvxFontListItem*>(mrViewShell.GetDocSh()->GetItem( SID_ATTR_CHAR_FONTLIST ));
const SvxFontListItem* pFonts = mrViewShell.GetDocSh()->GetItem( SID_ATTR_CHAR_FONTLIST );
const FontList* pFontList = pFonts ? pFonts->GetFontList(): nullptr;
if( pFontList )
{
+1 -1
View File
@@ -4534,7 +4534,7 @@ void DrawViewShell::ExecChar( SfxRequest &rReq )
case SID_SHRINK_FONT_SIZE:
case SID_GROW_FONT_SIZE:
{
const SvxFontListItem* pFonts = dynamic_cast<const SvxFontListItem*>(GetDocSh()->GetItem( SID_ATTR_CHAR_FONTLIST ) );
const SvxFontListItem* pFonts = GetDocSh()->GetItem( SID_ATTR_CHAR_FONTLIST );
const FontList* pFontList = pFonts ? pFonts->GetFontList() : nullptr;
if( pFontList )
{
+1 -1
View File
@@ -613,7 +613,7 @@ namespace svx
void FmTextControlShell::executeAttributeDialog( AttributeSet _eSet, SfxRequest& rReq )
{
const SvxFontListItem* pFontList = dynamic_cast<const SvxFontListItem*>( m_pViewFrame->GetObjectShell()->GetItem( SID_ATTR_CHAR_FONTLIST ) );
const SvxFontListItem* pFontList = m_pViewFrame->GetObjectShell()->GetItem( SID_ATTR_CHAR_FONTLIST );
DBG_ASSERT( pFontList, "FmTextControlShell::executeAttributeDialog: no font list item!" );
if ( !pFontList )
return;
+1 -1
View File
@@ -815,7 +815,7 @@ void OutlineTypeMgr::ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt1
{
if (SfxObjectShell* pCurDocShell = SfxObjectShell::Current())
{
const SvxFontListItem* pFontListItem = static_cast<const SvxFontListItem*>(pCurDocShell->GetItem(SID_ATTR_CHAR_FONTLIST));
const SvxFontListItem* pFontListItem = pCurDocShell->GetItem(SID_ATTR_CHAR_FONTLIST);
pList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
}
}
+1 -2
View File
@@ -1659,8 +1659,7 @@ static bool lcl_GetDocFontList(const FontList** ppFontList, SvxFontNameBox_Base&
const SvxFontListItem* pFontListItem = nullptr;
if ( pDocSh )
pFontListItem =
static_cast<const SvxFontListItem*>(pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ));
pFontListItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
else
{
::std::unique_ptr<FontList> aFontList(new FontList(Application::GetDefaultDevice()));
+1 -3
View File
@@ -891,9 +891,7 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam)
{
if (SwDocShell* pShell = rDoc.GetDocShell())
{
const SvxFontListItem* pFontListItem =
static_cast<const SvxFontListItem* >(
pShell->GetItem( SID_ATTR_CHAR_FONTLIST ));
const SvxFontListItem* pFontListItem = pShell->GetItem( SID_ATTR_CHAR_FONTLIST );
const FontList* pList = pFontListItem->GetFontList();
vcl::Font aFont(pList->Get(
+1 -2
View File
@@ -2000,8 +2000,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
if (!sBulletFontName.isEmpty() && pLclDocShell)
{
const SvxFontListItem* pFontListItem =
static_cast<const SvxFontListItem* >(pLclDocShell
->GetItem( SID_ATTR_CHAR_FONTLIST ));
pLclDocShell->GetItem( SID_ATTR_CHAR_FONTLIST );
const FontList* pList = pFontListItem->GetFontList();
vcl::Font aFont(pList->Get(sBulletFontName, WEIGHT_NORMAL, ITALIC_NONE));
aFormat.SetBulletFont(&aFont);
+1 -1
View File
@@ -1758,7 +1758,7 @@ void SwXStyle::SetPropertyValue<FN_UNO_NUM_RULES>(const SfxItemPropertyMapEntry&
{
if (SwDocShell* pShell = m_pDoc->GetDocShell())
{
const auto pFontListItem(static_cast<const SvxFontListItem*>(pShell->GetItem(SID_ATTR_CHAR_FONTLIST)));
const SvxFontListItem* pFontListItem(pShell->GetItem(SID_ATTR_CHAR_FONTLIST));
const auto pList(pFontListItem->GetFontList());
vcl::Font aFont(pList->Get(rBulletName.toString(), WEIGHT_NORMAL, ITALIC_NONE));
aFormat.SetBulletFont(&aFont);
+1 -2
View File
@@ -1106,8 +1106,7 @@ const FontList *SwCSS1Parser::GetFontList() const
SwDocShell *pDocSh = m_pDoc->GetDocShell();
if( pDocSh )
{
const SvxFontListItem *pFListItem =
static_cast<const SvxFontListItem *>(pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST));
const SvxFontListItem *pFListItem = pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST);
if( pFListItem )
pFList = pFListItem->GetFontList();
}
+1 -2
View File
@@ -3856,8 +3856,7 @@ void SwHTMLParser::NewFontAttr( HtmlTokenId nToken )
SwDocShell *pDocSh = m_xDoc->GetDocShell();
if( pDocSh )
{
const SvxFontListItem *pFListItem =
static_cast<const SvxFontListItem *>(pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST));
const SvxFontListItem *pFListItem = pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST);
if( pFListItem )
pFList = pFListItem->GetFontList();
}
+1 -2
View File
@@ -88,8 +88,7 @@ void SwCharDlg::PageCreated(const OUString& rId, SfxTabPage &rPage)
SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
if (rId == "font")
{
SvxFontListItem aFontListItem( *static_cast<const SvxFontListItem*>(
( m_rView.GetDocShell()->GetItem( SID_ATTR_CHAR_FONTLIST ) ) ) );
SvxFontListItem aFontListItem( *m_rView.GetDocShell()->GetItem( SID_ATTR_CHAR_FONTLIST ) );
aSet.Put (SvxFontListItem( aFontListItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
if(m_nDialogMode != SwCharDlgMode::Draw && m_nDialogMode != SwCharDlgMode::Ann)
aSet.Put (SfxUInt32Item(SID_FLAG_TYPE,SVX_PREVIEW_CHARACTER));
+1 -2
View File
@@ -311,8 +311,7 @@ void SwTemplateDlgController::PageCreated(const OUString& rId, SfxTabPage &rPage
{
if (SwView* pView = GetActiveView())
{
SvxFontListItem aFontListItem( *static_cast<const SvxFontListItem*>(pView->
GetDocShell()->GetItem( SID_ATTR_CHAR_FONTLIST ) ) );
SvxFontListItem aFontListItem( *(pView->GetDocShell()->GetItem( SID_ATTR_CHAR_FONTLIST )) );
aSet.Put (SvxFontListItem( aFontListItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
sal_uInt32 nFlags = 0;
+2 -2
View File
@@ -60,12 +60,12 @@ void SwWatermarkDialog::InitFields()
{
// Update font list
SfxObjectShell* pDocSh = SfxObjectShell::Current();
const SfxPoolItem* pFontItem;
const SvxFontListItem* pFontItem;
const FontList* pFontList = nullptr;
std::unique_ptr<FontList> xFontList;
if ( pDocSh && ( ( pFontItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ) ) != nullptr ) )
pFontList = static_cast<const SvxFontListItem*>( pFontItem )->GetFontList();
pFontList = pFontItem->GetFontList();
if (!pFontList)
{
+1 -1
View File
@@ -952,7 +952,7 @@ void SwSrcEditWindow::SetFont()
sFontName = aFont.GetFamilyName();
}
const SvxFontListItem* pFontListItem =
static_cast<const SvxFontListItem* >(m_pSrcView->GetDocShell()->GetItem( SID_ATTR_CHAR_FONTLIST ));
m_pSrcView->GetDocShell()->GetItem( SID_ATTR_CHAR_FONTLIST );
const FontList* pList = pFontListItem->GetFontList();
vcl::Font aFont(pList->Get(sFontName, WEIGHT_NORMAL, ITALIC_NONE));
+1 -2
View File
@@ -229,8 +229,7 @@ void SwAnnotationShell::Exec( SfxRequest &rReq )
case FN_SHRINK_FONT_SIZE:
{
const SfxObjectShell* pObjSh = SfxObjectShell::Current();
const SvxFontListItem* pFontListItem = static_cast<const SvxFontListItem*>
(pObjSh ? pObjSh->GetItem(SID_ATTR_CHAR_FONTLIST) : nullptr);
const SvxFontListItem* pFontListItem = (pObjSh ? pObjSh->GetItem(SID_ATTR_CHAR_FONTLIST) : nullptr);
const FontList* pFontList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
pOLV->GetEditView().ChangeFontSize( nSlot == FN_GROW_FONT_SIZE, pFontList );
}
+1 -2
View File
@@ -649,8 +649,7 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
case FN_SHRINK_FONT_SIZE:
{
const SfxObjectShell* pObjSh = SfxObjectShell::Current();
const SvxFontListItem* pFontListItem = static_cast< const SvxFontListItem* >
(pObjSh ? pObjSh->GetItem(SID_ATTR_CHAR_FONTLIST) : nullptr);
const SvxFontListItem* pFontListItem = (pObjSh ? pObjSh->GetItem(SID_ATTR_CHAR_FONTLIST) : nullptr);
const FontList* pFontList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
pOLV->GetEditView().ChangeFontSize( nSlot == FN_GROW_FONT_SIZE, pFontList );
}