diff options
author | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2020-11-16 22:17:07 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2020-11-17 07:48:44 +0100 |
commit | 47527821f32f9b5890b39b4031f5962f5cb46646 (patch) | |
tree | 73a22a0ff570c3a99443e134b86a94ff84197d7d /sw | |
parent | c867cbaaac420ee9469230ccf21810ef0fb2c402 (diff) |
SwGrfNode: Remove graphic arrived hack
Change-Id: Ib8fb5b223a1b3cc05a75ecfcc7c763bbb3928fae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105965
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/crsrsh.hxx | 2 | ||||
-rw-r--r-- | sw/inc/hintids.hxx | 1 | ||||
-rw-r--r-- | sw/inc/hints.hxx | 8 | ||||
-rw-r--r-- | sw/inc/viewsh.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/crsr/crsrsh.cxx | 23 | ||||
-rw-r--r-- | sw/source/core/doc/notxtfrm.cxx | 61 | ||||
-rw-r--r-- | sw/source/core/graphic/ndgrf.cxx | 19 | ||||
-rw-r--r-- | sw/source/core/inc/notxtfrm.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/view/viewsh.cxx | 17 |
9 files changed, 69 insertions, 64 deletions
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index 7eb1a2d0273b..572afdfd4f51 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -291,7 +291,7 @@ protected: SAL_DLLPRIVATE void UpdateMarkedListLevel(); protected: - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; + virtual void SwClientNotify(const SwModify&, const SfxHint&) override; public: SwCursorShell( SwDoc& rDoc, vcl::Window *pWin, const SwViewOption *pOpt ); diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index 1cfba494d9e6..04a162acd745 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -424,7 +424,6 @@ constexpr TypedWhichId<SwMsgPoolItem> RES_TBLHEADLINECHG (170); constexpr TypedWhichId<SwAutoFormatGetDocNode> RES_AUTOFMT_DOCNODE (171); constexpr TypedWhichId<SwMsgPoolItem> RES_SECTION_HIDDEN (172); constexpr TypedWhichId<SwMsgPoolItem> RES_SECTION_NOT_HIDDEN (173); -constexpr TypedWhichId<SwMsgPoolItem> RES_GRAPHIC_ARRIVED (174); constexpr TypedWhichId<SwMsgPoolItem> RES_GRAPHIC_PIECE_ARRIVED (175); constexpr TypedWhichId<SwMsgPoolItem> RES_HIDDENPARA_PRINT (176); constexpr TypedWhichId<SwVirtPageNumInfo> RES_VIRTPAGENUM_INFO (178); diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx index 68e783d919d2..51a048a271b7 100644 --- a/sw/inc/hints.hxx +++ b/sw/inc/hints.hxx @@ -139,6 +139,14 @@ public: class GrfRereadAndInCacheHint final : public SfxHint { }; + +class PreGraphicArrivedHint final : public SfxHint +{ +}; + +class PostGraphicArrivedHint final : public SfxHint +{ +}; } class SwUpdateAttr final : public SwMsgPoolItem diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index e5a6ae810a49..071c60d11bd3 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -566,6 +566,7 @@ public: void setOutputToWindow(bool bOutputToWindow); bool isOutputToWindow() const; + void OnGraphicArrived(const SwRect&); virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; }; diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 2ba78302aa28..cdb72eec46e9 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -73,6 +73,7 @@ #include <wrtsh.hxx> #include <undobj.hxx> #include <boost/property_tree/json_parser.hpp> +#include <hints.hxx> using namespace com::sun::star; using namespace util; @@ -2471,14 +2472,19 @@ SwContentFrame *SwCursorShell::GetCurrFrame( const bool bCalcFrame ) const @param pOld ??? @param pNew ??? */ -void SwCursorShell::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) +void SwCursorShell::SwClientNotify(const SwModify&, const SfxHint& rHint) { - const sal_uInt16 nWhich = pOld ? - pOld->Which() : - pNew ? - pNew->Which() : - sal::static_int_cast<sal_uInt16>(RES_MSG_BEGIN); - + if(dynamic_cast<const sw::PostGraphicArrivedHint*>(&rHint) && m_aGrfArrivedLnk.IsSet()) + { + m_aGrfArrivedLnk.Call(*this); + return; + } + auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint); + if(!pLegacy) + return; + auto nWhich = pLegacy->GetWhich(); + if(!nWhich) + nWhich = sal::static_int_cast<sal_uInt16>(RES_MSG_BEGIN); if( m_bCallChgLnk && ( nWhich < RES_MSG_BEGIN || nWhich >= RES_MSG_END || nWhich == RES_FMT_CHG || nWhich == RES_UPDATE_ATTR || @@ -2489,8 +2495,7 @@ void SwCursorShell::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) // not need to send the expensive RES_FMT_CHG in Insert. CallChgLnk(); - if( m_aGrfArrivedLnk.IsSet() && - ( RES_GRAPHIC_ARRIVED == nWhich || RES_GRAPHIC_SWAPIN == nWhich )) + if(m_aGrfArrivedLnk.IsSet() && RES_GRAPHIC_SWAPIN == nWhich) m_aGrfArrivedLnk.Call( *this ); } diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 47054a8df949..8bf008297233 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -720,6 +720,21 @@ void SwNoTextFrame::ClearCache() } } +void SwNoTextFrame::OnGraphicArrived() +{ + if(GetNode()->GetNodeType() != SwNodeType::Grf) + { + InvalidatePrt(); + SetCompletePaint(); + return; + } + SwGrfNode* pNd = static_cast<SwGrfNode*>(GetNode()); + ClearCache(); + auto pVSh = pNd->GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell(); + if(pVSh) + pVSh->OnGraphicArrived(getFrameArea()); +} + void SwNoTextFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) { if(dynamic_cast<const sw::GrfRereadAndInCacheHint*>(&rHint)) @@ -731,6 +746,11 @@ void SwNoTextFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint } return; } + if(dynamic_cast<const sw::PreGraphicArrivedHint*>(&rHint)) + { + OnGraphicArrived(); + return; + } auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint); if(!pLegacy) return; @@ -739,7 +759,6 @@ void SwNoTextFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint // #i73788# // no <SwContentFrame::Modify(..)> for RES_LINKED_GRAPHIC_STREAM_ARRIVED if ( RES_GRAPHIC_PIECE_ARRIVED != nWhich && - RES_GRAPHIC_ARRIVED != nWhich && RES_LINKED_GRAPHIC_STREAM_ARRIVED != nWhich ) { SwContentFrame::SwClientNotify(rModify, rHint); @@ -749,6 +768,11 @@ void SwNoTextFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint switch( nWhich ) { + case RES_GRAPHIC_PIECE_ARRIVED: + case RES_LINKED_GRAPHIC_STREAM_ARRIVED: + OnGraphicArrived(); + return; + case RES_OBJECTDYING: break; @@ -808,41 +832,6 @@ void SwNoTextFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint } break; - case RES_GRAPHIC_PIECE_ARRIVED: - case RES_GRAPHIC_ARRIVED: - // i73788# - handle RES_LINKED_GRAPHIC_STREAM_ARRIVED as RES_GRAPHIC_ARRIVED - case RES_LINKED_GRAPHIC_STREAM_ARRIVED: - if ( GetNode()->GetNodeType() == SwNodeType::Grf ) - { - bComplete = false; - SwGrfNode* pNd = static_cast<SwGrfNode*>( GetNode()); - - ClearCache(); - - SwRect aRect( getFrameArea() ); - - SwViewShell *pVSh = pNd->GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell(); - if( !pVSh ) - break; - - for(SwViewShell& rShell : pVSh->GetRingContainer()) - { - CurrShell aCurr( &rShell ); - if( rShell.IsPreview() ) - { - if( rShell.GetWin() ) - ::RepaintPagePreview( &rShell, aRect ); - } - else if ( rShell.VisArea().IsOver( aRect ) && - OUTDEV_WINDOW == rShell.GetOut()->GetOutDevType() ) - { - // invalidate instead of painting - rShell.GetWin()->Invalidate( aRect.SVRect() ); - } - } - } - break; - default: if ( !pLegacy->m_pNew || !isGRFATR(nWhich) ) return; diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx index bac1994401e4..ab4057eaebf9 100644 --- a/sw/source/core/graphic/ndgrf.cxx +++ b/sw/source/core/graphic/ndgrf.cxx @@ -362,23 +362,8 @@ void SwGrfNode::SetGraphic(const Graphic& rGraphic) void SwGrfNode::TriggerGraphicArrived() { - const SwMsgPoolItem aMsgHint(RES_GRAPHIC_ARRIVED); - // FIXME: instead of hacking the notification to only handle specific clients. - // this should have been implemented cleanly with two hints, e.g. - // RES_GRAPHIC_ARRIVED_PREP and RES_GRAPHIC_ARRIVED. - LockModify(); - { - SwIterator<sw::BroadcastingModify,SwGrfNode> aIter(*this); - for(sw::BroadcastingModify* pLast = aIter.First(); pLast; pLast = aIter.Next()) - if(dynamic_cast<const SwContentFrame*>(pLast) == nullptr) - pLast->SwClientNotifyCall(*this, sw::LegacyModifyHint(&aMsgHint, &aMsgHint)); - } - { - SwIterator<SwContentFrame,SwGrfNode> aIter(*this); - for(SwContentFrame* pLast = aIter.First(); pLast; pLast = aIter.Next()) - pLast->SwClientNotifyCall(*this, sw::LegacyModifyHint(&aMsgHint, &aMsgHint)); - } - UnlockModify(); + CallSwClientNotify(sw::PreGraphicArrivedHint()); + CallSwClientNotify(sw::PostGraphicArrivedHint()); } const Graphic& SwGrfNode::GetGrf(bool bWait) const diff --git a/sw/source/core/inc/notxtfrm.hxx b/sw/source/core/inc/notxtfrm.hxx index 9300639ad6d2..4e67a5479561 100644 --- a/sw/source/core/inc/notxtfrm.hxx +++ b/sw/source/core/inc/notxtfrm.hxx @@ -55,6 +55,7 @@ private: // MM02 std::unique_ptr<sdr::contact::ViewContact> mpViewContact; sdr::contact::ViewContact& GetViewContact() const; + void OnGraphicArrived(); protected: virtual void MakeAll(vcl::RenderContext* pRenderContext) override; diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 049ef9742cc1..12e67ef4e901 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -2531,6 +2531,23 @@ Size SwViewShell::GetPageSize( sal_uInt16 nPageNum, bool bSkipEmptyPages ) const return aSize; } +void SwViewShell::OnGraphicArrived(const SwRect& rRect) +{ + for(SwViewShell& rShell : GetRingContainer()) + { + CurrShell aCurr(&rShell); + if(rShell.IsPreview()) + { + if(rShell.GetWin()) + ::RepaintPagePreview(&rShell, rRect); + } + else if(rShell.VisArea().IsOver(rRect) && OUTDEV_WINDOW == rShell.GetOut()->GetOutDevType()) + { + // invalidate instead of painting + rShell.GetWin()->Invalidate(rRect.SVRect()); + } + } +} // #i12836# enhanced pdf export sal_Int32 SwViewShell::GetPageNumAndSetOffsetForPDF( OutputDevice& rOut, const SwRect& rRect ) const { |