diff options
Diffstat (limited to 'sw/source/ui/fldui')
-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 f65abe0bdf7a..dd5e7046728d 100644 --- a/sw/source/ui/fldui/flddb.cxx +++ b/sw/source/ui/fldui/flddb.cxx @@ -303,12 +303,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 b35a12b77516..c9e07406ad5c 100644 --- a/sw/source/ui/fldui/flddinf.cxx +++ b/sw/source/ui/fldui/flddinf.cxx @@ -101,10 +101,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(); @@ -313,12 +316,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) { @@ -369,10 +377,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 0b18e0d41e89..910587943607 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -332,9 +332,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 @@ -470,9 +476,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() ) @@ -956,7 +967,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) { |