sw/source/core/unocore/unotext.cxx |   21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

New commits:
commit 9bd14aef0895e7d3cc709f96bc7b284877b35576
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Sep 14 15:42:53 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Sep 14 19:01:45 2023 +0200

    remove some unnecessary dynamic_cast
    
    Change-Id: Ic2ce9ec8fbe9e61216f8785e7ebfb4a0377b3328
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156923
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/unocore/unotext.cxx 
b/sw/source/core/unocore/unotext.cxx
index 8f9be32e5fe4..f0d6c05b1693 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1651,23 +1651,22 @@ SwXText::convertToTextFrame(
     }
     oAnchorCheckPam.reset(); // clear SwIndex before deleting nodes
 
-    const uno::Reference<text::XTextFrame> xNewFrame(
-            SwXTextFrame::CreateXTextFrame(*m_pImpl->m_pDoc, nullptr));
-    SwXTextFrame& rNewFrame = dynamic_cast<SwXTextFrame&>(*xNewFrame);
+    const rtl::Reference<SwXTextFrame> xNewFrame =
+            SwXTextFrame::CreateXTextFrame(*m_pImpl->m_pDoc, nullptr);
     try
     {
         for (const beans::PropertyValue& rValue : rFrameProperties)
         {
-            rNewFrame.SwXFrame::setPropertyValue(rValue.Name, rValue.Value);
+            xNewFrame->SwXFrame::setPropertyValue(rValue.Name, rValue.Value);
         }
 
         {   // has to be in a block to remove the SwIndexes before
             // DelFullPara is called
             const uno::Reference< text::XTextRange> xInsertTextRange =
                 new SwXTextRange(*pStartPam, this);
-            assert(rNewFrame.IsDescriptor());
-            rNewFrame.attachToRange(xInsertTextRange, pStartPam.get());
-            assert(!rNewFrame.getName().isEmpty());
+            assert(xNewFrame->IsDescriptor());
+            xNewFrame->attachToRange(xInsertTextRange, pStartPam.get());
+            assert(!xNewFrame->getName().isEmpty());
         }
 
         SwTextNode *const pTextNode(pStartPam->GetPointNode().GetTextNode());
@@ -1680,10 +1679,10 @@ SwXText::convertToTextFrame(
                 if (aMovePam.Move( fnMoveForward, GoInContent ))
                 {
                     // move the anchor to the next paragraph
-                    SwFormatAnchor 
aNewAnchor(rNewFrame.GetFrameFormat()->GetAnchor());
+                    SwFormatAnchor 
aNewAnchor(xNewFrame->GetFrameFormat()->GetAnchor());
                     aNewAnchor.SetAnchor( aMovePam.Start() );
                     m_pImpl->m_pDoc->SetAttr(
-                        aNewAnchor, *rNewFrame.GetFrameFormat() );
+                        aNewAnchor, *xNewFrame->GetFrameFormat() );
 
                     // also move frames anchored to us
                     for (size_t i = 0; i < 
m_pImpl->m_pDoc->GetSpzFrameFormats()->size(); ++i)
@@ -1736,11 +1735,11 @@ SwXText::convertToTextFrame(
         sMessage = rRuntime.Message;
         bRuntimeException = true;
     }
-    xRet = xNewFrame;
+    xRet = static_cast<SwXFrame*>(xNewFrame.get());
     if (bParaBeforeInserted || bParaAfterInserted)
     {
         const rtl::Reference<SwXTextCursor> xFrameTextCursor =
-            rNewFrame.createXTextCursor();
+            xNewFrame->createXTextCursor();
         if (bParaBeforeInserted)
         {
             // todo: remove paragraph before frame

Reply via email to