summaryrefslogtreecommitdiff
path: root/sw/inc/docary.hxx
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-05-02 22:45:48 +0200
committerMichael Stahl <mstahl@redhat.com>2017-05-03 14:07:10 +0200
commit01575a06725648188d51de90323a6f1da97ef7a9 (patch)
tree7178d456f9fac91138e14a4ff7ae8cc8eea7fd15 /sw/inc/docary.hxx
parent389203a02b36734b6c1b3a73991c43aa43708ac8 (diff)
tdf#88555 sw: remove dynamic_cast from SwFrameFormats::Contains
This is a bad idea as the function is sometimes used to check if a SwFrameFormat has been deleted, which can happen in Undo, and for SwCallMouseEvent before commit 32403675bf9d2d0380956f9a82da71593edbb53c Replace with ContainsFormat() and IsAlive(), and don't require a non-const SwFrameFormat parameter. Change-Id: I87ede94dfbfe7f6985f13faab4c156015c3a5fc0
Diffstat (limited to 'sw/inc/docary.hxx')
-rw-r--r--sw/inc/docary.hxx14
1 files changed, 6 insertions, 8 deletions
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 6d25e85dcc74..10e41d68f901 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -225,7 +225,7 @@ public:
// Get the iterator of the exact object (includes pointer!),
// e.g for position with std::distance.
- // There is also Contains, if you don't need the position.
+ // There is also ContainsFormat, if you don't need the position.
const_iterator find( const value_type& x ) const;
// As this array is non-unique related to type and name,
@@ -253,8 +253,11 @@ public:
virtual size_t GetFormatCount() const override { return m_Array.size(); }
virtual SwFormat* GetFormat(size_t idx) const override { return operator[]( idx ); }
- bool Contains( const value_type& x ) const;
- inline bool Contains( const SwFormat* p ) const;
+ /// fast check if given format is contained here
+ /// @precond pFormat must not have been deleted
+ bool ContainsFormat(SwFrameFormat const* pFormat) const;
+ /// not so fast check that given format is still alive (i.e. contained here)
+ bool IsAlive(SwFrameFormat const*) const;
void DeleteAndDestroyAll( bool keepDefault = false );
@@ -262,11 +265,6 @@ public:
void newDefault( const_iterator const& position );
};
-inline bool SwFrameFormats::Contains( const SwFormat* p ) const
-{
- value_type p2 = dynamic_cast<value_type>(const_cast<SwFormat*>( p ));
- return p2 != nullptr && this->Contains( p2 );
-}
/// Unsorted, undeleting SwFrameFormat vector
class SwFrameFormatsV : public SwFormatsModifyBase<SwFrameFormat*>