tdf#120703: partially revert commit 85456fae54029edd26df2277a9eec5e2fe3d9739
... to take into account possible differences of results of dynamic_cast
vs static_cast; the change casts dynamically, as before the commit, and
only adds asserts on the result of the cast.
Thanks to sberg for pointing my mistake out!
Change-Id: Ib77d443e5a858e744f369f58542de603f948fd1c
Reviewed-on: https://gerrit.libreoffice.org/70274
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index 533029f..b92d9bb 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -396,8 +396,8 @@
uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getModel());
if (xSidebar.is())
{
assert(dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get()));
auto pSidebar = static_cast<sfx2::sidebar::SidebarController*>(xSidebar.get());
auto pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get());
assert(pSidebar);
sfx2::sidebar::SidebarController::registerSidebarForFrame(pSidebar, this);
pSidebar->updateModel(getModel());
css::lang::EventObject aEvent;
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index 06e870d..acfb123 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -852,8 +852,8 @@
m_xUndoManager );
bool bChanged = false;
assert(dynamic_cast<ChartModel*>(getModel().get()));
ChartModel* pModel = static_cast<ChartModel*>(getModel().get());
ChartModel* pModel = dynamic_cast<ChartModel*>(getModel().get());
assert(pModel);
if ( eObjectType == OBJECTTYPE_LEGEND )
bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning( *pModel, false , true );
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index 3136192..a32e8dd 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -527,9 +527,8 @@
out << "0";
break;
case codemaker::UnoType::Sort::Enum:
assert(dynamic_cast<unoidl::EnumTypeEntity*>(ent.get()));
out << codemaker::cpp::scopedCppName(n.toUtf8()) << "_"
<< (static_cast<unoidl::EnumTypeEntity*>(ent.get())->
<< (dynamic_cast<unoidl::EnumTypeEntity&>(*ent.get()).
getMembers()[0].name);
break;
case codemaker::UnoType::Sort::String:
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 5f165aa..4900c4d 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -4483,9 +4483,8 @@
break;
case SC_CAT_MOVE:
{
assert(dynamic_cast<const ScChangeActionMove*>(pAction)
&& "ScChangeTrack::Clone: pMove is null!");
auto pMove = static_cast<const ScChangeActionMove*>(pAction);
auto pMove = dynamic_cast<const ScChangeActionMove*>(pAction);
assert(pMove && "ScChangeTrack::Clone: pMove is null!");
pClonedAction = new ScChangeActionMove(
pAction->GetActionNumber(),
diff --git a/sc/source/ui/pagedlg/areasdlg.cxx b/sc/source/ui/pagedlg/areasdlg.cxx
index de01966..2555287 100644
--- a/sc/source/ui/pagedlg/areasdlg.cxx
+++ b/sc/source/ui/pagedlg/areasdlg.cxx
@@ -124,9 +124,8 @@
get(pBtnCancel,"cancel");
ScTabViewShell* pScViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
SfxObjectShell* pSfxObjSh = SfxObjectShell::Current();
assert(dynamic_cast<ScDocShell*>(pSfxObjSh) && "Current DocumentShell not found :-(");
ScDocShell* pScDocSh = static_cast<ScDocShell*>(pSfxObjSh);
ScDocShell* pScDocSh = dynamic_cast<ScDocShell*>(SfxObjectShell::Current());
assert(pScDocSh && "Current DocumentShell not found :-(");
pDoc = &pScDocSh->GetDocument();
diff --git a/sw/source/core/crsr/annotationmark.cxx b/sw/source/core/crsr/annotationmark.cxx
index 7ba754b..4a54c39 100644
--- a/sw/source/core/crsr/annotationmark.cxx
+++ b/sw/source/core/crsr/annotationmark.cxx
@@ -56,9 +56,9 @@
SwTextField *const pTextField = pTextNode->GetFieldTextAttrAt(
GetMarkEnd().nContent.GetIndex()-1, true);
assert(pTextField != nullptr);
const SwField* pField = pTextField->GetFormatField().GetField();
assert(dynamic_cast<const SwPostItField*>(pField));
const SwPostItField* pPostItField = static_cast<const SwPostItField*>(pField);
auto pPostItField
= dynamic_cast<const SwPostItField*>(pTextField->GetFormatField().GetField());
assert(pPostItField);
// use the annotation mark's name as the annotation name, if
// - the annotation field has an empty annotation name or
// - the annotation mark's name differs (on mark creation a name clash had been detected)
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index cb7ec4c..87d6ca5 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -582,9 +582,8 @@
const sal_Int32 nLen = static_cast<sal_Int32>(std::max<sal_Int32>( 0, ( (*End()) - 1 - nIdx ) ));
const OUString aNewFieldContent = GetTextNode().GetExpandText(nullptr, nIdx, nLen);
const SwField* pField = GetFormatField().GetField();
assert(dynamic_cast<const SwInputField*>(pField));
const SwInputField* pInputField = static_cast<const SwInputField*>(pField);
auto pInputField = dynamic_cast<const SwInputField*>(GetFormatField().GetField());
assert(pInputField);
const_cast<SwInputField*>(pInputField)->applyFieldContent( aNewFieldContent );
// trigger update of fields for scenarios in which the Input Field's content is part of e.g. a table formula
GetTextNode().GetDoc()->getIDocumentFieldsAccess().GetUpdateFields().SetFieldsDirty(true);
@@ -624,9 +623,8 @@
::sw::mark::IMark* SwTextAnnotationField::GetAnnotationMark() const
{
const SwField* pField = GetFormatField().GetField();
assert(dynamic_cast<const SwPostItField*>(pField));
const SwPostItField* pPostItField = static_cast<const SwPostItField*>(pField);
auto pPostItField = dynamic_cast<const SwPostItField*>(GetFormatField().GetField());
assert(pPostItField);
SwDoc* pDoc = static_cast<const SwPostItFieldType*>(pPostItField->GetTyp())->GetDoc();
assert(pDoc != nullptr);
diff --git a/unodevtools/source/skeletonmaker/cpptypemaker.cxx b/unodevtools/source/skeletonmaker/cpptypemaker.cxx
index 1e9d459..5f9ed15 100644
--- a/unodevtools/source/skeletonmaker/cpptypemaker.cxx
+++ b/unodevtools/source/skeletonmaker/cpptypemaker.cxx
@@ -64,10 +64,10 @@
if (defaultvalue && referenceType == 16) {
if (sort == codemaker::UnoType::Sort::Enum) {
assert(dynamic_cast<unoidl::EnumTypeEntity *>(entity.get()));
auto pEnumTypeEntity(dynamic_cast<unoidl::EnumTypeEntity *>(entity.get()));
assert(pEnumTypeEntity);
o << nucleus.copy(nucleus.lastIndexOf('.') + 1) << "_"
<< static_cast<unoidl::EnumTypeEntity*>(entity.get())->
getMembers()[0].name;
<< pEnumTypeEntity->getMembers()[0].name;
}
return;
}
@@ -927,11 +927,11 @@
o << "; construction methods:\n";
printConstructors(o, options, manager, nucleus);
}
assert(dynamic_cast<unoidl::SingleInterfaceBasedServiceEntity*>(entity.get()));
generateDocumentation(
o, options, manager,
static_cast<unoidl::SingleInterfaceBasedServiceEntity*>(
entity.get())->getBase().toUtf8(),
dynamic_cast<unoidl::SingleInterfaceBasedServiceEntity&>(*entity.get())
.getBase()
.toUtf8(),
delegate);
break;
diff --git a/winaccessibility/source/service/AccFrameEventListener.cxx b/winaccessibility/source/service/AccFrameEventListener.cxx
index cf1968d..04a1a63 100644
--- a/winaccessibility/source/service/AccFrameEventListener.cxx
+++ b/winaccessibility/source/service/AccFrameEventListener.cxx
@@ -85,8 +85,8 @@
{
XAccessible* pAcc = xChild.get();
assert(dynamic_cast<VCLXWindow*>(m_xAccessible.get()));
VCLXWindow* pvclwindow = static_cast<VCLXWindow*>(m_xAccessible.get());
VCLXWindow* pvclwindow = dynamic_cast<VCLXWindow*>(m_xAccessible.get());
assert(pvclwindow);
const SystemEnvData* systemdata
= pvclwindow->GetWindow()->GetSystemData();