diff options
-rw-r--r-- | sw/source/ui/fldui/flddb.cxx | 12 | ||||
-rw-r--r-- | sw/source/ui/fldui/flddinf.cxx | 22 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldref.cxx | 21 |
3 files changed, 44 insertions, 11 deletions
diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx index 01b9065cd36e..937c2b265c71 100644 --- a/sw/source/ui/fldui/flddb.cxx +++ b/sw/source/ui/fldui/flddb.cxx @@ -299,12 +299,18 @@ void SwFieldDBPage::TypeHdl(const weld::TreeView* pBox) OUString sColumnName; if (nTypeId == SwFieldTypesEnum::Database) { - aData = static_cast<SwDBField*>(GetCurField())->GetDBData(); - sColumnName = static_cast<SwDBFieldType*>(GetCurField()->GetTyp())->GetColumnName(); + if (auto const*const pField = dynamic_cast<SwDBField*>(GetCurField())) + { + aData = pField->GetDBData(); + sColumnName = static_cast<SwDBFieldType*>(GetCurField()->GetTyp())->GetColumnName(); + } } else { - aData = static_cast<SwDBNameInfField*>(GetCurField())->GetDBData(pSh->GetDoc()); + if (auto *const pField = dynamic_cast<SwDBNameInfField*>(GetCurField())) + { + aData = pField->GetDBData(pSh->GetDoc()); + } } m_xDatabaseTLB->Select(aData.sDataSource, aData.sCommand, sColumnName); } diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx index 92d263a6efd1..4fe4d8b41aaa 100644 --- a/sw/source/ui/fldui/flddinf.cxx +++ b/sw/source/ui/fldui/flddinf.cxx @@ -99,10 +99,13 @@ void SwFieldDokInfPage::Reset(const SfxItemSet* ) if (IsFieldEdit()) { const SwField* pCurField = GetCurField(); - nSubType = static_cast<const SwDocInfoField*>(pCurField)->GetSubType() & 0xff; + nSubType = pCurField->GetSubType() & 0xff; if( nSubType == DI_CUSTOM ) { - m_sOldCustomFieldName = static_cast<const SwDocInfoField*>(pCurField)->GetName(); + if (auto const pField = dynamic_cast<SwDocInfoField const*>(pCurField)) + { + m_sOldCustomFieldName = pField->GetName(); + } } m_xFormatLB->SetAutomaticLanguage(pCurField->IsAutomaticLanguage()); SwWrtShell *pSh = GetWrtShell(); @@ -311,12 +314,17 @@ IMPL_LINK_NOARG(SwFieldDokInfPage, SubTypeHdl, weld::TreeView&, void) bEnable = true; } - sal_uInt32 nFormat = IsFieldEdit() ? static_cast<SwDocInfoField*>(GetCurField())->GetFormat() : 0; + sal_uInt32 nFormat = 0; - sal_uInt16 nOldSubType = IsFieldEdit() ? (static_cast<SwDocInfoField*>(GetCurField())->GetSubType() & 0xff00) : 0; + sal_uInt16 nOldSubType = 0; if (IsFieldEdit()) { + if (auto const pField = dynamic_cast<SwDocInfoField const*>(GetCurField())) + { + nFormat = pField->GetFormat(); + nOldSubType = pField->GetSubType() & 0xff00; + } nPos = m_xSelectionLB->get_selected_index(); if (nPos != -1) { @@ -367,10 +375,14 @@ sal_Int32 SwFieldDokInfPage::FillSelectionLB(sal_uInt16 nSubType) sal_uInt16 nSize = 0; sal_Int32 nSelPos = -1; - sal_uInt16 nExtSubType = IsFieldEdit() ? (static_cast<SwDocInfoField*>(GetCurField())->GetSubType() & 0xff00) : 0; + sal_uInt16 nExtSubType = 0; if (IsFieldEdit()) { + if (auto const pField = dynamic_cast<SwDocInfoField const*>(GetCurField())) + { + nExtSubType = pField->GetSubType() & 0xff00; + } m_xFixedCB->set_active((nExtSubType & DI_SUB_FIXED) != 0); nExtSubType = ((nExtSubType & ~DI_SUB_FIXED) >> 8) - 1; } diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index 95935b115177..2b29583e7c8a 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -330,9 +330,15 @@ IMPL_LINK_NOARG(SwFieldRefPage, TypeHdl, weld::TreeView&, void) break; case REF_SEQUENCEFLD: - sName = static_cast<SwGetRefField*>(GetCurField())->GetSetRefName(); + { + SwGetRefField const*const pRefField(dynamic_cast<SwGetRefField*>(GetCurField())); + if (pRefField) + { + sName = pRefField->GetSetRefName(); + } nFlag = REFFLDFLAG; break; + } } if (m_xTypeLB->find_text(sName) == -1) // reference to deleted mark @@ -468,9 +474,14 @@ void SwFieldRefPage::UpdateSubType(const OUString& filterString) SwWrtShell *pSh = GetWrtShell(); if(!pSh) pSh = ::GetActiveWrtShell(); - SwGetRefField* pRefField = static_cast<SwGetRefField*>(GetCurField()); + SwGetRefField const*const pRefField(dynamic_cast<SwGetRefField*>(GetCurField())); const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + if (!pRefField) + { + return; + } + OUString sOldSel; // #i83479# if ( m_xSelectionLB->get_visible() ) @@ -950,7 +961,11 @@ bool SwFieldRefPage::FillItemSet(SfxItemSet* ) } } - SwGetRefField* pRefField = static_cast<SwGetRefField*>(GetCurField()); + SwGetRefField const*const pRefField(dynamic_cast<SwGetRefField*>(GetCurField())); + if (!pRefField) + { + return false; + } if (REFFLDFLAG & nTypeId) { |