[Libreoffice-commits] core.git: sw/inc sw/source
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Tue Feb 14 18:12:29 UTC 2017
sw/inc/frmfmt.hxx | 14 +++++---------
sw/source/core/draw/dcontact.cxx | 11 +++++++++++
sw/source/core/layout/atrfrm.cxx | 16 ++--------------
sw/source/core/layout/fly.cxx | 19 ++++++++++++-------
sw/source/core/unocore/unoframe.cxx | 19 +++++++++++--------
sw/source/filter/ww8/ww8graf.cxx | 17 +++++++++--------
6 files changed, 50 insertions(+), 46 deletions(-)
New commits:
commit 3acdc0a0fca421addde76da36b156af70c234939
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Tue Feb 14 19:09:30 2017 +0100
Revert commits that caused instability on the Linux debug tinderbox
Revert "DYING_FLYFRAMEFORMAT not needed anymore"
This reverts commit 837545feb63f31095d69d006aeda520637c3bc8c.
Revert "give SwFlyDrawContact a clear owner: SwFlyFrameFormat"
This reverts commit 4ae93f7d3b063d13ff757884444a468212227ef9.
diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index 9d40d96..b55ca5d 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -174,15 +174,11 @@ public:
// The FlyFrame-Format
-class SdrModel;
-class SwFlyDrawContact;
-
class SW_DLLPUBLIC SwFlyFrameFormat: public SwFrameFormat
{
friend class SwDoc;
OUString msTitle;
OUString msDesc;
- std::unique_ptr<SwFlyDrawContact> m_pContact;
/** Both not existent.
it stores the previous position of Prt rectangle from RequestObjectResize
@@ -194,13 +190,12 @@ class SW_DLLPUBLIC SwFlyFrameFormat: public SwFrameFormat
SwFlyFrameFormat &operator=( const SwFlyFrameFormat &rCpy ) = delete;
protected:
- SwFlyFrameFormat(SwAttrPool& rPool, const OUString& rFormatNm, SwFrameFormat* pDrvdFrame);
+ SwFlyFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm,
+ SwFrameFormat *pDrvdFrame )
+ : SwFrameFormat( rPool, rFormatNm, pDrvdFrame, RES_FLYFRMFMT )
+ {}
public:
- SwFlyDrawContact* GetContact()
- { return m_pContact.get(); };
- void InitContact(SdrModel* pSdrModel);
- void ClearContact();
virtual ~SwFlyFrameFormat() override;
/// Creates the views.
@@ -262,6 +257,7 @@ namespace sw
{
enum class DrawFrameFormatHintId {
DYING,
+ DYING_FLYFRAMEFORMAT, /* possibly can be merged with DYING, if all client handle it and handle it the same */
PREPPASTING,
PREP_INSERT_FLY,
PREP_DELETE_FLY,
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 9a4c78e..6d2c08b 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -594,6 +594,17 @@ void SwFlyDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint
{
pKillDrawHint->m_rpContact = this;
}
+ else if (auto pDrawFrameFormatHint = dynamic_cast<const sw::DrawFrameFormatHint*>(&rHint))
+ {
+ switch(pDrawFrameFormatHint->m_eId)
+ {
+ case sw::DrawFrameFormatHintId::DYING_FLYFRAMEFORMAT:
+ delete this;
+ break;
+ default:
+ ;
+ }
+ }
}
// SwDrawContact
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 01c5923..1b420b7 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -2866,20 +2866,6 @@ void SwFrameFormats::dumpAsXml(xmlTextWriterPtr pWriter, const char* pName) cons
IMPL_FIXEDMEMPOOL_NEWDEL( SwFlyFrameFormat )
-SwFlyFrameFormat::SwFlyFrameFormat(SwAttrPool& rPool, const OUString& rFormatNm, SwFrameFormat* pDrvdFrame)
- : SwFrameFormat(rPool, rFormatNm, pDrvdFrame, RES_FLYFRMFMT)
- , m_pContact(nullptr)
-{}
-
-void SwFlyFrameFormat::InitContact(SdrModel* pSdrModel)
-{
- m_pContact = std::unique_ptr<SwFlyDrawContact>(new SwFlyDrawContact(this, pSdrModel));
-}
-void SwFlyFrameFormat::ClearContact()
-{
- m_pContact.reset(nullptr);
-}
-
SwFlyFrameFormat::~SwFlyFrameFormat()
{
SwIterator<SwFlyFrame,SwFormat> aIter( *this );
@@ -2889,6 +2875,8 @@ SwFlyFrameFormat::~SwFlyFrameFormat()
{
SwFrame::DestroyFrame(pLast);
} while( nullptr != ( pLast = aIter.Next() ));
+
+ CallSwClientNotify(sw::DrawFrameFormatHint(sw::DrawFrameFormatHintId::DYING_FLYFRAMEFORMAT));
}
/// Creates the Frames if the format describes a paragraph-bound frame.
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 6e8cf94..55f1ac2 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -397,21 +397,25 @@ void SwFlyFrame::InitDrawObj()
// need to create a new Ref, else we create the Contact now.
IDocumentDrawModelAccess& rIDDMA = GetFormat()->getIDocumentDrawModelAccess();
- if(!GetFormat()->GetContact())
+ SwFlyDrawContact *pContact = SwIterator<SwFlyDrawContact,SwFormat>( *GetFormat() ).First();
+ if ( !pContact )
{
// #i52858# - method name changed
- GetFormat()->InitContact(rIDDMA.GetOrCreateDrawModel());
+ pContact = new SwFlyDrawContact( GetFormat(),
+ rIDDMA.GetOrCreateDrawModel() );
}
- OSL_ENSURE(GetFormat()->GetContact(), "InitDrawObj failed");
+ OSL_ENSURE( pContact, "InitDrawObj failed" );
// OD 2004-03-22 #i26791#
- SetDrawObj( *(CreateNewRef( GetFormat()->GetContact() )) );
+ SetDrawObj( *(CreateNewRef( pContact )) );
// Set the right Layer
// OD 2004-01-19 #110582#
+ SdrLayerID nHeavenId = rIDDMA.GetHeavenId();
+ SdrLayerID nHellId = rIDDMA.GetHellId();
// OD 2004-03-22 #i26791#
- GetVirtDrawObj()->SetLayer(GetFormat()->GetOpaque().GetValue()
- ? rIDDMA.GetHeavenId()
- : rIDDMA.GetHellId());
+ GetVirtDrawObj()->SetLayer( GetFormat()->GetOpaque().GetValue()
+ ? nHeavenId
+ : nHellId );
}
void SwFlyFrame::FinitDrawObj()
@@ -455,6 +459,7 @@ void SwFlyFrame::FinitDrawObj()
pContact->GetMaster()->SetUserCall(nullptr);
GetVirtDrawObj()->SetUserCall(nullptr); // Else calls delete of the ContactObj
delete GetVirtDrawObj(); // Deregisters itself at the Master
+ delete pContact; // Destroys the Master itself
}
void SwFlyFrame::ChainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow )
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 580522e..4101171 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1360,20 +1360,23 @@ void SwXFrame::SetSelection(SwPaM& rCopySource)
SdrObject *SwXFrame::GetOrCreateSdrObject(SwFlyFrameFormat &rFormat)
{
SdrObject* pObject = rFormat.FindSdrObject();
- if(!pObject)
+ if( !pObject )
{
- SwDoc* pDoc = rFormat.GetDoc();
+ SwDoc *pDoc = rFormat.GetDoc();
// #i52858# - method name changed
SwDrawModel* pDrawModel = pDoc->getIDocumentDrawModelAccess().GetOrCreateDrawModel();
- rFormat.InitContact(pDrawModel);
- pObject = rFormat.GetContact()->GetMaster();
+ SwFlyDrawContact* pContactObject
+ = new SwFlyDrawContact( &rFormat, pDrawModel );
+ pObject = pContactObject->GetMaster();
const ::SwFormatSurround& rSurround = rFormat.GetSurround();
- pObject->SetLayer((SURROUND_THROUGHT == rSurround.GetSurround() && !rFormat.GetOpaque().GetValue())
- ? pDoc->getIDocumentDrawModelAccess().GetHellId()
- : pDoc->getIDocumentDrawModelAccess().GetHeavenId());
- pDrawModel->GetPage(0)->InsertObject(pObject);
+ pObject->SetLayer(
+ ( SURROUND_THROUGHT == rSurround.GetSurround() &&
+ !rFormat.GetOpaque().GetValue() ) ? pDoc->getIDocumentDrawModelAccess().GetHellId()
+ : pDoc->getIDocumentDrawModelAccess().GetHeavenId() );
+ pDrawModel->GetPage(0)->InsertObject( pObject );
}
+
return pObject;
}
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 279960f..3bd7449 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -2131,18 +2131,19 @@ SwWW8ImplReader::SetAttributesAtGrfNode(SvxMSDffImportRec const*const pRecord,
}
}
-SdrObject* SwWW8ImplReader::CreateContactObject(SwFrameFormat* pFormat)
+SdrObject* SwWW8ImplReader::CreateContactObject(SwFrameFormat* pFlyFormat)
{
- if(pFormat)
+ if (pFlyFormat)
{
- SdrObject* pNewObject = m_bNewDoc ? nullptr : pFormat->FindRealSdrObject();
+ SdrObject* pNewObject = m_bNewDoc ? nullptr : pFlyFormat->FindRealSdrObject();
if (!pNewObject)
- pNewObject = pFormat->FindSdrObject();
- SwFlyFrameFormat* pFlyFormat(nullptr);
- if (!pNewObject && (pFlyFormat = dynamic_cast<SwFlyFrameFormat*>(pFormat)))
+ pNewObject = pFlyFormat->FindSdrObject();
+ if (!pNewObject && dynamic_cast< const SwFlyFrameFormat *>( pFlyFormat ) != nullptr)
{
- pFlyFormat->InitContact(m_pDrawModel);
- pNewObject = pFlyFormat->GetContact()->GetMaster();
+ SwFlyDrawContact* pContactObject
+ = new SwFlyDrawContact(static_cast<SwFlyFrameFormat*>(pFlyFormat),
+ m_pDrawModel);
+ pNewObject = pContactObject->GetMaster();
}
return pNewObject;
}
More information about the Libreoffice-commits
mailing list