diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-04-04 23:45:11 +0300 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-04-05 08:33:33 +0200 |
commit | 7327260de3c0c627e62f7c3fddbe3d71ea88e88f (patch) | |
tree | 363e7e71702b0f13d4c9b1b4c89d4533ede74619 /sw | |
parent | 5d0700bd3afef6d39b63fe813aaa0ac856ff5785 (diff) |
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>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/crsr/annotationmark.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/txtnode/atrfld.cxx | 10 |
2 files changed, 7 insertions, 9 deletions
diff --git a/sw/source/core/crsr/annotationmark.cxx b/sw/source/core/crsr/annotationmark.cxx index 7ba754b1d931..4a54c3970897 100644 --- a/sw/source/core/crsr/annotationmark.cxx +++ b/sw/source/core/crsr/annotationmark.cxx @@ -56,9 +56,9 @@ namespace sw { namespace mark 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 cb7ec4c52323..87d6ca5a4ae2 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -582,9 +582,8 @@ void SwTextInputField::UpdateFieldContent() 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 @@ SwTextAnnotationField::~SwTextAnnotationField() ::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); |