summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/source/core/inc/frame.hxx8
-rw-r--r--sw/source/core/layout/fly.cxx45
-rw-r--r--sw/source/core/layout/ssfrm.cxx11
-rw-r--r--sw/source/core/layout/wsfrm.cxx1
4 files changed, 36 insertions, 29 deletions
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index 9d3ca61708de..7ecbefc600a9 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -32,6 +32,8 @@
#include <com/sun/star/style/TabStop.hpp>
#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <memory>
+
class SwLayoutFrame;
class SwRootFrame;
class SwPageFrame;
@@ -378,7 +380,7 @@ class SW_DLLPUBLIC SwFrame : public SwFrameAreaDefinition, public SwClient, publ
SwPageFrame* ImplFindPageFrame();
protected:
- SwSortedObjs* mpDrawObjs; // draw objects, can be 0
+ std::unique_ptr<SwSortedObjs> m_pDrawObjs; // draw objects, can be null
SwFrameType mnFrameType; //Who am I?
bool mbInDtor : 1;
@@ -524,8 +526,8 @@ public:
// work with chain of FlyFrames
void AppendFly( SwFlyFrame *pNew );
void RemoveFly( SwFlyFrame *pToRemove );
- const SwSortedObjs *GetDrawObjs() const { return mpDrawObjs; }
- SwSortedObjs *GetDrawObjs() { return mpDrawObjs; }
+ const SwSortedObjs *GetDrawObjs() const { return m_pDrawObjs.get(); }
+ SwSortedObjs *GetDrawObjs() { return m_pDrawObjs.get(); }
// #i28701# - change purpose of method and adjust its name
void InvalidateObjs( const bool _bNoInvaOfAsCharAnchoredObjs = true );
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index b4d05f138fbf..0daef994f355 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -2007,9 +2007,11 @@ void SwFlyFrame::Cut()
void SwFrame::AppendFly( SwFlyFrame *pNew )
{
- if ( !mpDrawObjs )
- mpDrawObjs = new SwSortedObjs();
- mpDrawObjs->Insert( *pNew );
+ if (!m_pDrawObjs)
+ {
+ m_pDrawObjs.reset(new SwSortedObjs());
+ }
+ m_pDrawObjs->Insert( *pNew );
pNew->ChgAnchorFrame( this );
// Register at the page
@@ -2049,9 +2051,11 @@ void SwFrame::RemoveFly( SwFlyFrame *pToRemove )
}
}
- mpDrawObjs->Remove( *pToRemove );
- if ( !mpDrawObjs->size() )
- DELETEZ( mpDrawObjs );
+ m_pDrawObjs->Remove(*pToRemove);
+ if (!m_pDrawObjs->size())
+ {
+ m_pDrawObjs.reset();
+ }
pToRemove->ChgAnchorFrame( nullptr );
@@ -2061,7 +2065,7 @@ void SwFrame::RemoveFly( SwFlyFrame *pToRemove )
void SwFrame::AppendDrawObj( SwAnchoredObject& _rNewObj )
{
- assert(!mpDrawObjs || mpDrawObjs->is_sorted());
+ assert(!m_pDrawObjs || m_pDrawObjs->is_sorted());
if ( dynamic_cast<const SwAnchoredDrawObject*>( &_rNewObj) == nullptr )
{
@@ -2072,19 +2076,21 @@ void SwFrame::AppendDrawObj( SwAnchoredObject& _rNewObj )
if ( dynamic_cast<const SwDrawVirtObj*>(_rNewObj.GetDrawObj()) == nullptr &&
_rNewObj.GetAnchorFrame() && _rNewObj.GetAnchorFrame() != this )
{
- assert(!mpDrawObjs || mpDrawObjs->is_sorted());
+ assert(!m_pDrawObjs || m_pDrawObjs->is_sorted());
// perform disconnect from layout, if 'master' drawing object is appended
// to a new frame.
static_cast<SwDrawContact*>(::GetUserCall( _rNewObj.GetDrawObj() ))->
DisconnectFromLayout( false );
- assert(!mpDrawObjs || mpDrawObjs->is_sorted());
+ assert(!m_pDrawObjs || m_pDrawObjs->is_sorted());
}
if ( _rNewObj.GetAnchorFrame() != this )
{
- if ( !mpDrawObjs )
- mpDrawObjs = new SwSortedObjs();
- mpDrawObjs->Insert( _rNewObj );
+ if (!m_pDrawObjs)
+ {
+ m_pDrawObjs.reset(new SwSortedObjs());
+ }
+ m_pDrawObjs->Insert(_rNewObj);
_rNewObj.ChgAnchorFrame( this );
}
@@ -2110,7 +2116,7 @@ void SwFrame::AppendDrawObj( SwAnchoredObject& _rNewObj )
}
//The layer is part of the key used to sort the obj, so update
//its position if the layer changed.
- mpDrawObjs->Update(_rNewObj);
+ m_pDrawObjs->Update(_rNewObj);
}
}
@@ -2135,7 +2141,7 @@ void SwFrame::AppendDrawObj( SwAnchoredObject& _rNewObj )
}
}
- assert(!mpDrawObjs || mpDrawObjs->is_sorted());
+ assert(!m_pDrawObjs || m_pDrawObjs->is_sorted());
}
void SwFrame::RemoveDrawObj( SwAnchoredObject& _rToRemoveObj )
@@ -2154,13 +2160,14 @@ void SwFrame::RemoveDrawObj( SwAnchoredObject& _rToRemoveObj )
if ( pPage && pPage->GetSortedObjs() )
pPage->RemoveDrawObjFromPage( _rToRemoveObj );
- mpDrawObjs->Remove( _rToRemoveObj );
- if ( !mpDrawObjs->size() )
- DELETEZ( mpDrawObjs );
-
+ m_pDrawObjs->Remove(_rToRemoveObj);
+ if (!m_pDrawObjs->size())
+ {
+ m_pDrawObjs.reset();
+ }
_rToRemoveObj.ChgAnchorFrame( nullptr );
- assert(!mpDrawObjs || mpDrawObjs->is_sorted());
+ assert(!m_pDrawObjs || m_pDrawObjs->is_sorted());
}
void SwFrame::InvalidateObjs( const bool _bNoInvaOfAsCharAnchoredObjs )
diff --git a/sw/source/core/layout/ssfrm.cxx b/sw/source/core/layout/ssfrm.cxx
index 9934d1c4b4dd..180ceba1ff9c 100644
--- a/sw/source/core/layout/ssfrm.cxx
+++ b/sw/source/core/layout/ssfrm.cxx
@@ -338,11 +338,11 @@ void SwFrame::DestroyImpl()
}
}
- if( mpDrawObjs )
+ if (m_pDrawObjs)
{
- for ( size_t i = mpDrawObjs->size(); i; )
+ for (size_t i = m_pDrawObjs->size(); i; )
{
- SwAnchoredObject* pAnchoredObj = (*mpDrawObjs)[--i];
+ SwAnchoredObject* pAnchoredObj = (*m_pDrawObjs)[--i];
if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
{
SwFrame::DestroyFrame(static_cast<SwFlyFrame*>(pAnchoredObj));
@@ -360,8 +360,7 @@ void SwFrame::DestroyImpl()
}
}
}
- delete mpDrawObjs;
- mpDrawObjs = nullptr;
+ m_pDrawObjs.reset();
}
}
@@ -371,7 +370,7 @@ SwFrame::~SwFrame()
assert(!IsDeleteForbidden()); // check that it's not deleted while deletes are forbidden
#if OSL_DEBUG_LEVEL > 0
// JP 15.10.2001: for detection of access to deleted frames
- mpDrawObjs = reinterpret_cast<SwSortedObjs*>(0x33333333);
+ mpRoot = reinterpret_cast<SwRootFrame*>(0x33333333);
#endif
}
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index be7264c424e0..5b85b69a4b27 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -297,7 +297,6 @@ SwFrame::SwFrame( SwModify *pMod, SwFrame* pSib )
mpUpper(nullptr),
mpNext(nullptr),
mpPrev(nullptr),
- mpDrawObjs(nullptr),
mnFrameType(SwFrameType::None),
mbInDtor(false),
mbInvalidR2L(true),