Kaydet (Commit) 7327260d authored tarafından Mike Kaganski's avatar Mike Kaganski Kaydeden (comit) Stephan Bergmann

tdf#120703: partially revert commit 85456fae

... 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: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 5d0700bd
...@@ -396,8 +396,8 @@ void SAL_CALL ChartController::attachFrame( ...@@ -396,8 +396,8 @@ void SAL_CALL ChartController::attachFrame(
uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getModel()); uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getModel());
if (xSidebar.is()) if (xSidebar.is())
{ {
assert(dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get())); auto pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get());
auto pSidebar = static_cast<sfx2::sidebar::SidebarController*>(xSidebar.get()); assert(pSidebar);
sfx2::sidebar::SidebarController::registerSidebarForFrame(pSidebar, this); sfx2::sidebar::SidebarController::registerSidebarForFrame(pSidebar, this);
pSidebar->updateModel(getModel()); pSidebar->updateModel(getModel());
css::lang::EventObject aEvent; css::lang::EventObject aEvent;
......
...@@ -852,8 +852,8 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) ...@@ -852,8 +852,8 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
m_xUndoManager ); m_xUndoManager );
bool bChanged = false; bool bChanged = false;
assert(dynamic_cast<ChartModel*>(getModel().get())); ChartModel* pModel = dynamic_cast<ChartModel*>(getModel().get());
ChartModel* pModel = static_cast<ChartModel*>(getModel().get()); assert(pModel);
if ( eObjectType == OBJECTTYPE_LEGEND ) if ( eObjectType == OBJECTTYPE_LEGEND )
bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning( *pModel, false , true ); bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning( *pModel, false , true );
......
...@@ -527,9 +527,8 @@ void CppuType::dumpInitializer( ...@@ -527,9 +527,8 @@ void CppuType::dumpInitializer(
out << "0"; out << "0";
break; break;
case codemaker::UnoType::Sort::Enum: case codemaker::UnoType::Sort::Enum:
assert(dynamic_cast<unoidl::EnumTypeEntity*>(ent.get()));
out << codemaker::cpp::scopedCppName(n.toUtf8()) << "_" out << codemaker::cpp::scopedCppName(n.toUtf8()) << "_"
<< (static_cast<unoidl::EnumTypeEntity*>(ent.get())-> << (dynamic_cast<unoidl::EnumTypeEntity&>(*ent.get()).
getMembers()[0].name); getMembers()[0].name);
break; break;
case codemaker::UnoType::Sort::String: case codemaker::UnoType::Sort::String:
......
...@@ -4483,9 +4483,8 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const ...@@ -4483,9 +4483,8 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const
break; break;
case SC_CAT_MOVE: case SC_CAT_MOVE:
{ {
assert(dynamic_cast<const ScChangeActionMove*>(pAction) auto pMove = dynamic_cast<const ScChangeActionMove*>(pAction);
&& "ScChangeTrack::Clone: pMove is null!"); assert(pMove && "ScChangeTrack::Clone: pMove is null!");
auto pMove = static_cast<const ScChangeActionMove*>(pAction);
pClonedAction = new ScChangeActionMove( pClonedAction = new ScChangeActionMove(
pAction->GetActionNumber(), pAction->GetActionNumber(),
......
...@@ -124,9 +124,8 @@ ScPrintAreasDlg::ScPrintAreasDlg( SfxBindings* pB, SfxChildWindow* pCW, vcl::Win ...@@ -124,9 +124,8 @@ ScPrintAreasDlg::ScPrintAreasDlg( SfxBindings* pB, SfxChildWindow* pCW, vcl::Win
get(pBtnCancel,"cancel"); get(pBtnCancel,"cancel");
ScTabViewShell* pScViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); ScTabViewShell* pScViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
SfxObjectShell* pSfxObjSh = SfxObjectShell::Current(); ScDocShell* pScDocSh = dynamic_cast<ScDocShell*>(SfxObjectShell::Current());
assert(dynamic_cast<ScDocShell*>(pSfxObjSh) && "Current DocumentShell not found :-("); assert(pScDocSh && "Current DocumentShell not found :-(");
ScDocShell* pScDocSh = static_cast<ScDocShell*>(pSfxObjSh);
pDoc = &pScDocSh->GetDocument(); pDoc = &pScDocSh->GetDocument();
......
...@@ -56,9 +56,9 @@ namespace sw { namespace mark ...@@ -56,9 +56,9 @@ namespace sw { namespace mark
SwTextField *const pTextField = pTextNode->GetFieldTextAttrAt( SwTextField *const pTextField = pTextNode->GetFieldTextAttrAt(
GetMarkEnd().nContent.GetIndex()-1, true); GetMarkEnd().nContent.GetIndex()-1, true);
assert(pTextField != nullptr); assert(pTextField != nullptr);
const SwField* pField = pTextField->GetFormatField().GetField(); auto pPostItField
assert(dynamic_cast<const SwPostItField*>(pField)); = dynamic_cast<const SwPostItField*>(pTextField->GetFormatField().GetField());
const SwPostItField* pPostItField = static_cast<const SwPostItField*>(pField); assert(pPostItField);
// use the annotation mark's name as the annotation name, if // use the annotation mark's name as the annotation name, if
// - the annotation field has an empty annotation name or // - the annotation field has an empty annotation name or
// - the annotation mark's name differs (on mark creation a name clash had been detected) // - the annotation mark's name differs (on mark creation a name clash had been detected)
......
...@@ -582,9 +582,8 @@ void SwTextInputField::UpdateFieldContent() ...@@ -582,9 +582,8 @@ void SwTextInputField::UpdateFieldContent()
const sal_Int32 nLen = static_cast<sal_Int32>(std::max<sal_Int32>( 0, ( (*End()) - 1 - nIdx ) )); 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 OUString aNewFieldContent = GetTextNode().GetExpandText(nullptr, nIdx, nLen);
const SwField* pField = GetFormatField().GetField(); auto pInputField = dynamic_cast<const SwInputField*>(GetFormatField().GetField());
assert(dynamic_cast<const SwInputField*>(pField)); assert(pInputField);
const SwInputField* pInputField = static_cast<const SwInputField*>(pField);
const_cast<SwInputField*>(pInputField)->applyFieldContent( aNewFieldContent ); 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 // 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); GetTextNode().GetDoc()->getIDocumentFieldsAccess().GetUpdateFields().SetFieldsDirty(true);
...@@ -624,9 +623,8 @@ SwTextAnnotationField::~SwTextAnnotationField() ...@@ -624,9 +623,8 @@ SwTextAnnotationField::~SwTextAnnotationField()
::sw::mark::IMark* SwTextAnnotationField::GetAnnotationMark() const ::sw::mark::IMark* SwTextAnnotationField::GetAnnotationMark() const
{ {
const SwField* pField = GetFormatField().GetField(); auto pPostItField = dynamic_cast<const SwPostItField*>(GetFormatField().GetField());
assert(dynamic_cast<const SwPostItField*>(pField)); assert(pPostItField);
const SwPostItField* pPostItField = static_cast<const SwPostItField*>(pField);
SwDoc* pDoc = static_cast<const SwPostItFieldType*>(pPostItField->GetTyp())->GetDoc(); SwDoc* pDoc = static_cast<const SwPostItFieldType*>(pPostItField->GetTyp())->GetDoc();
assert(pDoc != nullptr); assert(pDoc != nullptr);
......
...@@ -64,10 +64,10 @@ static void printType( ...@@ -64,10 +64,10 @@ static void printType(
if (defaultvalue && referenceType == 16) { if (defaultvalue && referenceType == 16) {
if (sort == codemaker::UnoType::Sort::Enum) { 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) << "_" o << nucleus.copy(nucleus.lastIndexOf('.') + 1) << "_"
<< static_cast<unoidl::EnumTypeEntity*>(entity.get())-> << pEnumTypeEntity->getMembers()[0].name;
getMembers()[0].name;
} }
return; return;
} }
...@@ -927,11 +927,11 @@ void generateDocumentation(std::ostream & o, ...@@ -927,11 +927,11 @@ void generateDocumentation(std::ostream & o,
o << "; construction methods:\n"; o << "; construction methods:\n";
printConstructors(o, options, manager, nucleus); printConstructors(o, options, manager, nucleus);
} }
assert(dynamic_cast<unoidl::SingleInterfaceBasedServiceEntity*>(entity.get()));
generateDocumentation( generateDocumentation(
o, options, manager, o, options, manager,
static_cast<unoidl::SingleInterfaceBasedServiceEntity*>( dynamic_cast<unoidl::SingleInterfaceBasedServiceEntity&>(*entity.get())
entity.get())->getBase().toUtf8(), .getBase()
.toUtf8(),
delegate); delegate);
break; break;
......
...@@ -85,8 +85,8 @@ void AccFrameEventListener::HandleChildChangedEvent(Any oldValue, Any newValue) ...@@ -85,8 +85,8 @@ void AccFrameEventListener::HandleChildChangedEvent(Any oldValue, Any newValue)
{ {
XAccessible* pAcc = xChild.get(); XAccessible* pAcc = xChild.get();
assert(dynamic_cast<VCLXWindow*>(m_xAccessible.get())); VCLXWindow* pvclwindow = dynamic_cast<VCLXWindow*>(m_xAccessible.get());
VCLXWindow* pvclwindow = static_cast<VCLXWindow*>(m_xAccessible.get()); assert(pvclwindow);
const SystemEnvData* systemdata const SystemEnvData* systemdata
= pvclwindow->GetWindow()->GetSystemData(); = pvclwindow->GetWindow()->GetSystemData();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment