Assert downcast

In this case it should be guaranteed that pField is a pointer to
SwGetRefField by:

else if (pField->GetTypeId() == SwFieldTypesEnum::GetRef)

To follow best practice to allow some diagnostic in debug mode,
assert(dynamic_cast) before using static_cast to downcast.

Change-Id: Ib2c6fb4259b66d5059f1886e23d05fc1c2aa3682
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137578
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Jim Raykowski 2022-07-28 08:33:37 -08:00 committed by Mike Kaganski
parent c2746a6656
commit be32cb9210

View file

@ -683,6 +683,7 @@ void SwContentType::FillMemberList(bool* pbContentChanged)
}
else if (pField->GetTypeId() == SwFieldTypesEnum::GetRef)
{
assert(dynamic_cast<const SwGetRefField*>(pField));
const SwGetRefField* pRefField(static_cast<const SwGetRefField*>(pField));
if (pRefField->IsRefToHeadingCrossRefBookmark() ||
pRefField->IsRefToNumItemCrossRefBookmark())