Skip to content

Commit

Permalink
move SwVirtPageNumInfo to SfxHint
Browse files Browse the repository at this point in the history
- also remove now obsolete GetInfo overrides

Change-Id: Iaac75ed2e53daead06242ce4620fd2b879909e02
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155061
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
  • Loading branch information
bjoernmichaelsen committed Aug 3, 2023
1 parent eef0c5d commit 7f85415
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 62 deletions.
2 changes: 0 additions & 2 deletions compilerplugins/clang/unusedmethods.results
Original file line number Diff line number Diff line change
Expand Up @@ -1934,8 +1934,6 @@ include/svl/typedwhich.hxx:31
TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwUINumRuleItem, derived_type>, int>::type)
include/svl/typedwhich.hxx:31
TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwUpdateAttr, derived_type>, int>::type)
include/svl/typedwhich.hxx:31
TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwVirtPageNumInfo, derived_type>, int>::type)
include/svl/typedwhich.hxx:31
TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwWrtShellItem, derived_type>, int>::type)
include/svl/typedwhich.hxx:31
Expand Down
1 change: 1 addition & 0 deletions include/svl/hint.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ enum class SfxHintId {
SwDocPosUpdate,
SwDocPosUpdateAtIndex,
SwTableHeadingChange,
SwVirtPageNumHint,

ThisIsAnSdrHint
};
Expand Down
1 change: 0 additions & 1 deletion svl/source/items/poolitem.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@
// class SwTableFormulaUpdate : public SwMsgPoolItem
// class SwAutoFormatGetDocNode: public SwMsgPoolItem
// class SwAttrSetChg: public SwMsgPoolItem
// class SwVirtPageNumInfo: public SwMsgPoolItem
// class SwFindNearestNode : public SwMsgPoolItem
// class SwStringMsgPoolItem : public SwMsgPoolItem
// class SwFormatDrop: public SfxPoolItem, public SwClient
Expand Down
3 changes: 1 addition & 2 deletions sw/inc/hintids.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class SwTransparencyGrf;
class SwFormatRuby;
class SwTableFormulaUpdate;
class SwAutoFormatGetDocNode;
class SwVirtPageNumInfo;
class VirtPageNumHint;
class SwFindNearestNode;
class SwFltAnchor;
class SwFltTOX;
Expand Down Expand Up @@ -433,7 +433,6 @@ constexpr TypedWhichId<SwAttrSetChg> RES_ATTRSET_CHG(169);
constexpr TypedWhichId<SwUpdateAttr> RES_UPDATE_ATTR(170);
constexpr TypedWhichId<SwAutoFormatGetDocNode> RES_AUTOFMT_DOCNODE(176);
constexpr TypedWhichId<SwMsgPoolItem> RES_HIDDENPARA_PRINT(178);
constexpr TypedWhichId<SwVirtPageNumInfo> RES_VIRTPAGENUM_INFO(180);
constexpr TypedWhichId<SwPtrMsgPoolItem> RES_REMOVE_UNO_OBJECT(181);
// empty
constexpr TypedWhichId<SwFindNearestNode> RES_FINDNEARESTNODE(184);
Expand Down
42 changes: 26 additions & 16 deletions sw/inc/hints.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,32 @@ class TableHeadingChange final: public SfxHint
public:
TableHeadingChange() : SfxHint(SfxHintId::SwTableHeadingChange) {};
};
class VirtPageNumHint final: public SfxHint
{
const SwPageFrame* m_pPage;
const SwPageFrame* m_pOrigPage;
const SwFrame* m_pFrame;
bool m_bFound;
/** Multiple attributes can be attached to a single paragraph / table
The frame, in the end, has to decide which attribute takes effect and which physical page it involves */
public:
VirtPageNumHint(const SwPageFrame* pPg);
const SwPageFrame* GetPage() const
{ return m_pPage; }
const SwPageFrame* GetOrigPage() const
{ return m_pOrigPage; }
const SwFrame* GetFrame() const
{ return m_pFrame; }
void SetInfo(const SwPageFrame* pPg, const SwFrame *pF)
{ m_pFrame = pF; m_pPage = pPg; }
void SetFound()
{
assert(!m_bFound);
m_bFound = true;
}
bool IsFound()
{ return m_bFound; }
};
}

class SwUpdateAttr final : public SwMsgPoolItem
Expand Down Expand Up @@ -359,22 +385,6 @@ public:
#endif
};

class SwVirtPageNumInfo final : public SwMsgPoolItem
{
const SwPageFrame *m_pPage;
const SwPageFrame *m_pOrigPage;
const SwFrame *m_pFrame;
/** Multiple attributes can be attached to a single paragraph / table
The frame, in the end, has to decide which attribute takes effect and which physical page it involves */
public:
SwVirtPageNumInfo( const SwPageFrame *pPg );

const SwPageFrame *GetPage() const { return m_pPage; }
const SwPageFrame *GetOrigPage() const { return m_pOrigPage;}
const SwFrame *GetFrame() const { return m_pFrame; }
void SetInfo( const SwPageFrame *pPg,
const SwFrame *pF ) { m_pFrame = pF; m_pPage = pPg; }
};

class SwFindNearestNode final : public SwMsgPoolItem
{
Expand Down
14 changes: 9 additions & 5 deletions sw/source/core/attr/hints.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ RedlineUnDelText::RedlineUnDelText(sal_Int32 const nS, sal_Int32 const nL)
{
}

VirtPageNumHint::VirtPageNumHint(const SwPageFrame* pPg):
SfxHint(SfxHintId::SwVirtPageNumHint),
m_pPage(nullptr),
m_pOrigPage(pPg),
m_pFrame(nullptr),
m_bFound(false)
{
}

} // namespace sw

SwUpdateAttr::SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW )
Expand Down Expand Up @@ -159,11 +168,6 @@ const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
}
#endif

SwVirtPageNumInfo::SwVirtPageNumInfo( const SwPageFrame *pPg ) :
SwMsgPoolItem( RES_VIRTPAGENUM_INFO ), m_pPage( nullptr ), m_pOrigPage( pPg ), m_pFrame( nullptr )
{
}

SwFindNearestNode::SwFindNearestNode( const SwNode& rNd )
: SwMsgPoolItem( RES_FINDNEARESTNODE ), m_pNode( &rNd ), m_pFound( nullptr )
{
Expand Down
6 changes: 4 additions & 2 deletions sw/source/core/inc/pagefrm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class SwAttrSetChg;
namespace vcl { class Font; }
class SwSortedObjs;
class SwAnchoredObject;
class SwVirtPageNumInfo;
namespace sw {
class VirtPageNumHint;
}

enum class SwPageFrameInvFlags : sal_uInt8
{
Expand Down Expand Up @@ -351,7 +353,7 @@ public:
const SwHeaderFrame* GetHeaderFrame() const;
const SwFooterFrame* GetFooterFrame() const;

bool UpdateVirtPageNumInfo(SwVirtPageNumInfo& rHint, const SwFrame* pFrame) const;
void UpdateVirtPageNumInfo(sw::VirtPageNumHint& rHint, const SwFrame* pFrame) const;

void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override;
};
Expand Down
1 change: 0 additions & 1 deletion sw/source/core/inc/tabfrm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public:
inline SwTabFrame *GetFollow();
SwTabFrame* FindMaster( bool bFirstMaster = false ) const;

virtual bool GetInfo( SfxPoolItem &rHint ) const override;
virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&,
SwPrintData const*const pPrintData = nullptr ) const override;
virtual void CheckDirection( bool bVert ) override;
Expand Down
1 change: 0 additions & 1 deletion sw/source/core/inc/txtfrm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ public:
SwRect GetPaintSwRect();
virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&,
SwPrintData const*const pPrintData = nullptr ) const override;
virtual bool GetInfo( SfxPoolItem & ) const override;

/**
* Layout oriented cursor travelling:
Expand Down
6 changes: 3 additions & 3 deletions sw/source/core/layout/pagechg.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2598,21 +2598,21 @@ const SwFooterFrame* SwPageFrame::GetFooterFrame() const
return nullptr;
}

bool SwPageFrame::UpdateVirtPageNumInfo(SwVirtPageNumInfo& rHint, const SwFrame* pFrame) const
void SwPageFrame::UpdateVirtPageNumInfo(sw::VirtPageNumHint& rHint, const SwFrame* pFrame) const
{
assert(!rHint.IsFound());
if(this == rHint.GetOrigPage() && !pFrame->GetPrev())
{
// Should be the one (can temporarily be different, should we be concerned about this possibility?)
rHint.SetFound();
rHint.SetInfo(this, pFrame);
return false;
}
if(GetPhyPageNum() < rHint.GetOrigPage()->GetPhyPageNum() &&
(!rHint.GetPage() || GetPhyPageNum() > rHint.GetPage()->GetPhyPageNum()))
{
// This could be the one.
rHint.SetInfo(this, pFrame);
}
return true;
}

void SwPageFrame::dumpAsXml(xmlTextWriterPtr writer) const
Expand Down
19 changes: 8 additions & 11 deletions sw/source/core/layout/tabfrm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3512,6 +3512,14 @@ void SwTabFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
HandleTableHeadlineChange();
return;
}
else if(rHint.GetId() == SfxHintId::SwVirtPageNumHint)
{
auto& rVirtPageNumHint = const_cast<sw::VirtPageNumHint&>(static_cast<const sw::VirtPageNumHint&>(rHint));
if(!IsInDocBody() || IsFollow() || rVirtPageNumHint.IsFound())
return;
if(const SwPageFrame* pPage = FindPageFrame())
pPage->UpdateVirtPageNumInfo(rVirtPageNumHint, this);
}
else if (rHint.GetId() != SfxHintId::SwLegacyModify)
return;
auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
Expand Down Expand Up @@ -3638,17 +3646,6 @@ void SwTabFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
}
}

bool SwTabFrame::GetInfo(SfxPoolItem& rHint) const
{
if(RES_VIRTPAGENUM_INFO == rHint.Which() && IsInDocBody() && !IsFollow())
{
SwVirtPageNumInfo& rInfo = static_cast<SwVirtPageNumInfo&>(rHint);
if(const SwPageFrame* pPage = FindPageFrame())
return pPage->UpdateVirtPageNumInfo(rInfo, this);
}
return true;
}

SwFrame *SwTabFrame::FindLastContentOrTable()
{
SwFrame *pRet = m_pLower;
Expand Down
14 changes: 7 additions & 7 deletions sw/source/core/layout/trvlfrm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1839,15 +1839,15 @@ sal_uInt16 SwFrame::GetVirtPageNum() const

if ( pDesc->GetNumOffset() && pDesc->GetDefinedIn() )
{
const sw::BroadcastingModify *pMod = pDesc->GetDefinedIn();
SwVirtPageNumInfo aInfo( pPage );
pMod->GetInfo( aInfo );
if ( aInfo.GetPage() )
auto pMod = const_cast<sw::BroadcastingModify*>(pDesc->GetDefinedIn());
sw::VirtPageNumHint aHint(pPage);
pMod->CallSwClientNotify(aHint);
if(aHint.GetPage())
{
if( !pVirtPage || aInfo.GetPage()->GetPhyPageNum() > pVirtPage->GetPhyPageNum() )
if(!pVirtPage || aHint.GetPage()->GetPhyPageNum() > pVirtPage->GetPhyPageNum())
{
pVirtPage = aInfo.GetPage();
pFrame = aInfo.GetFrame();
pVirtPage = aHint.GetPage();
pFrame = aHint.GetFrame();
}
}
}
Expand Down
20 changes: 9 additions & 11 deletions sw/source/core/text/txtfrm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2125,6 +2125,15 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
InvalidateRange(SwCharRange(nIndex, TextFrameIndex(1)));
return;
}
else if (rHint.GetId() == SfxHintId::SwVirtPageNumHint)
{
auto& rVirtPageNumHint = const_cast<sw::VirtPageNumHint&>(static_cast<const sw::VirtPageNumHint&>(rHint));
if(!IsInDocBody() || IsFollow() || rVirtPageNumHint.IsFound())
return;
if(const SwPageFrame* pPage = FindPageFrame())
pPage->UpdateVirtPageNumInfo(rVirtPageNumHint, this);
return;
}
else if (auto const pHt = dynamic_cast<sw::MoveText const*>(&rHint))
{
pMoveText = pHt;
Expand Down Expand Up @@ -2746,17 +2755,6 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
CalcFootnoteFlag();
}

bool SwTextFrame::GetInfo(SfxPoolItem& rHint) const
{
if(RES_VIRTPAGENUM_INFO == rHint.Which() && IsInDocBody() && !IsFollow())
{
SwVirtPageNumInfo& rInfo = static_cast<SwVirtPageNumInfo&>(rHint);
if(const SwPageFrame* pPage = FindPageFrame())
return pPage->UpdateVirtPageNumInfo(rInfo, this);
}
return true;
}

void SwTextFrame::PrepWidows( const sal_uInt16 nNeed, bool bNotify )
{
OSL_ENSURE(GetFollow() && nNeed, "+SwTextFrame::Prepare: lost all friends");
Expand Down

0 comments on commit 7f85415

Please sign in to comment.