Skip to content

Commit 429d26a

Browse files
committed
Simplify a bit
Change-Id: Ia1c142d9841075f307fba69f79999697992a5c5d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153735 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]>
1 parent 8863ca2 commit 429d26a

File tree

1 file changed

+20
-58
lines changed

1 file changed

+20
-58
lines changed

sw/inc/node.hxx

Lines changed: 20 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,15 @@ public:
184184
inline SwSectionNode *GetSectionNode();
185185
inline const SwSectionNode *GetSectionNode() const;
186186

187-
inline bool IsStartNode() const;
188-
inline bool IsContentNode() const;
189-
inline bool IsEndNode() const;
190-
inline bool IsTextNode() const;
191-
inline bool IsTableNode() const;
192-
inline bool IsSectionNode() const;
193-
inline bool IsOLENode() const;
194-
inline bool IsNoTextNode() const;
195-
inline bool IsGrfNode() const;
187+
bool IsStartNode() const { return bool(SwNodeType::Start & m_nNodeType); }
188+
bool IsContentNode() const { return bool(SwNodeType::ContentMask & m_nNodeType); }
189+
bool IsEndNode() const { return SwNodeType::End == m_nNodeType; }
190+
bool IsTextNode() const { return SwNodeType::Text == m_nNodeType; }
191+
bool IsTableNode() const { return SwNodeType::Table == m_nNodeType; }
192+
bool IsSectionNode() const { return SwNodeType::Section == m_nNodeType; }
193+
bool IsOLENode() const { return SwNodeType::Ole == m_nNodeType; }
194+
bool IsNoTextNode() const { return bool(SwNodeType::NoTextMask & m_nNodeType); }
195+
bool IsGrfNode() const { return SwNodeType::Grf == m_nNodeType; }
196196

197197
/**
198198
Checks if this node is in redlines.
@@ -633,80 +633,43 @@ private:
633633

634634
inline SwEndNode *SwNode::GetEndNode()
635635
{
636-
return SwNodeType::End == m_nNodeType ? static_cast<SwEndNode*>(this) : nullptr;
636+
return IsEndNode() ? static_cast<SwEndNode*>(this) : nullptr;
637637
}
638638
inline const SwEndNode *SwNode::GetEndNode() const
639639
{
640-
return SwNodeType::End == m_nNodeType ? static_cast<const SwEndNode*>(this) : nullptr;
640+
return IsEndNode() ? static_cast<const SwEndNode*>(this) : nullptr;
641641
}
642642
inline SwStartNode *SwNode::GetStartNode()
643643
{
644-
return SwNodeType::Start & m_nNodeType ? static_cast<SwStartNode*>(this) : nullptr;
644+
return IsStartNode() ? static_cast<SwStartNode*>(this) : nullptr;
645645
}
646646
inline const SwStartNode *SwNode::GetStartNode() const
647647
{
648-
return SwNodeType::Start & m_nNodeType ? static_cast<const SwStartNode*>(this) : nullptr;
648+
return IsStartNode() ? static_cast<const SwStartNode*>(this) : nullptr;
649649
}
650650
inline SwTableNode *SwNode::GetTableNode()
651651
{
652-
return SwNodeType::Table == m_nNodeType ? static_cast<SwTableNode*>(this) : nullptr;
652+
return IsTableNode() ? static_cast<SwTableNode*>(this) : nullptr;
653653
}
654654
inline const SwTableNode *SwNode::GetTableNode() const
655655
{
656-
return SwNodeType::Table == m_nNodeType ? static_cast<const SwTableNode*>(this) : nullptr;
656+
return IsTableNode() ? static_cast<const SwTableNode*>(this) : nullptr;
657657
}
658658
inline SwSectionNode *SwNode::GetSectionNode()
659659
{
660-
return SwNodeType::Section == m_nNodeType ? static_cast<SwSectionNode*>(this) : nullptr;
660+
return IsSectionNode() ? static_cast<SwSectionNode*>(this) : nullptr;
661661
}
662662
inline const SwSectionNode *SwNode::GetSectionNode() const
663663
{
664-
return SwNodeType::Section == m_nNodeType ? static_cast<const SwSectionNode*>(this) : nullptr;
664+
return IsSectionNode() ? static_cast<const SwSectionNode*>(this) : nullptr;
665665
}
666666
inline SwContentNode *SwNode::GetContentNode()
667667
{
668-
return SwNodeType::ContentMask & m_nNodeType ? static_cast<SwContentNode*>(this) : nullptr;
668+
return IsContentNode() ? static_cast<SwContentNode*>(this) : nullptr;
669669
}
670670
inline const SwContentNode *SwNode::GetContentNode() const
671671
{
672-
return SwNodeType::ContentMask & m_nNodeType ? static_cast<const SwContentNode*>(this) : nullptr;
673-
}
674-
675-
inline bool SwNode::IsStartNode() const
676-
{
677-
return bool(SwNodeType::Start & m_nNodeType);
678-
}
679-
inline bool SwNode::IsContentNode() const
680-
{
681-
return bool(SwNodeType::ContentMask & m_nNodeType);
682-
}
683-
inline bool SwNode::IsEndNode() const
684-
{
685-
return SwNodeType::End == m_nNodeType;
686-
}
687-
inline bool SwNode::IsTextNode() const
688-
{
689-
return SwNodeType::Text == m_nNodeType;
690-
}
691-
inline bool SwNode::IsTableNode() const
692-
{
693-
return SwNodeType::Table == m_nNodeType;
694-
}
695-
inline bool SwNode::IsSectionNode() const
696-
{
697-
return SwNodeType::Section == m_nNodeType;
698-
}
699-
inline bool SwNode::IsNoTextNode() const
700-
{
701-
return bool(SwNodeType::NoTextMask & m_nNodeType);
702-
}
703-
inline bool SwNode::IsOLENode() const
704-
{
705-
return SwNodeType::Ole == m_nNodeType;
706-
}
707-
inline bool SwNode::IsGrfNode() const
708-
{
709-
return SwNodeType::Grf == m_nNodeType;
672+
return IsContentNode() ? static_cast<const SwContentNode*>(this) : nullptr;
710673
}
711674

712675
inline const SwStartNode* SwNode::FindSttNodeByType( SwStartNodeType eTyp ) const
@@ -727,8 +690,7 @@ inline SwNodeOffset SwNode::StartOfSectionIndex() const
727690
}
728691
inline SwNodeOffset SwNode::EndOfSectionIndex() const
729692
{
730-
const SwStartNode* pStNd = IsStartNode() ? static_cast<const SwStartNode*>(this) : m_pStartOfSection;
731-
return pStNd->m_pEndOfSection->GetIndex();
693+
return EndOfSectionNode()->GetIndex();
732694
}
733695
inline const SwEndNode* SwNode::EndOfSectionNode() const
734696
{

0 commit comments

Comments
 (0)