[Libreoffice-commits] core.git: sw/inc sw/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 23 12:37:30 UTC 2021


 sw/inc/docary.hxx              |    5 ++---
 sw/source/core/undo/unattr.cxx |    2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

New commits:
commit 639e52064260bc47698078a4319e59fe4b54db62
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jun 23 09:56:10 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jun 23 14:36:45 2021 +0200

    simplify SwFormatsModifyBase::ContainsFormat
    
    can just call IsAlive
    
    Change-Id: I7cd3b33520261b68d549783cabd5cf3f6f4847a3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117696
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 9ce149d7de89..49d1a7c368a7 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -164,9 +164,8 @@ public:
 
     /// check if given format is contained here
     /// @precond pFormat must not have been deleted
-    bool ContainsFormat(SwFormat const*const pFormat) const {
-        Value p = dynamic_cast<Value>(const_cast<SwFormat*>(pFormat));
-        return p != nullptr && SwVectorModifyBase<Value>::IsAlive(p);
+    bool ContainsFormat(Value pFormat) const {
+        return SwVectorModifyBase<Value>::IsAlive(pFormat);
     }
 
     // Override return type to reduce casting
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index a4c1aaec54d9..208f54cc7eb2 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -139,7 +139,7 @@ void SwUndoFormatAttr::Init( const SwFormat & rFormat )
                 m_nNodeIndex = pTable->GetTabSortBoxes()[ 0 ]->GetSttNd()
                                ->FindTableNode()->GetIndex();
             }
-        } else if (pDoc->GetSections().ContainsFormat(&rFormat)) {
+        } else if (dynamic_cast<const SwSectionFormat*>(&rFormat)) {
             m_nNodeIndex = rFormat.GetContent().GetContentIdx()->GetIndex();
         } else if ( dynamic_cast< const SwTableBoxFormat* >( &rFormat ) !=  nullptr ) {
             SwTableBox * pTableBox = SwIterator<SwTableBox,SwFormat>( rFormat ).First();


More information about the Libreoffice-commits mailing list