From 0c2933d0a3ebd6074b89369df653538511363abb Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sat, 6 Aug 2022 13:18:55 +0200 Subject: make IsInHeaderFooter take a SwNode, not an SwNodeIndex as part of the process of hiding the internals of SwPosition Change-Id: Ic9e7e3fd121a86d8b84536157b6d6b204627f758 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137905 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/core/crsr/bookmark.cxx | 2 +- sw/source/core/doc/DocumentContentOperationsManager.cxx | 2 +- sw/source/core/doc/DocumentLayoutManager.cxx | 2 +- sw/source/core/doc/doc.cxx | 2 +- sw/source/core/doc/doclay.cxx | 4 ++-- sw/source/core/docnode/section.cxx | 2 +- sw/source/core/frmedt/fecopy.cxx | 2 +- sw/source/core/frmedt/fefly1.cxx | 2 +- sw/source/core/frmedt/feshview.cxx | 4 ++-- sw/source/core/layout/frmtool.cxx | 4 ++-- sw/source/core/text/EnhancedPDFExportHelper.cxx | 8 +++----- sw/source/core/txtnode/ndtxt.cxx | 2 +- sw/source/core/txtnode/thints.cxx | 2 +- sw/source/core/unocore/unoredline.cxx | 2 +- sw/source/filter/html/swhtml.cxx | 2 +- sw/source/filter/xml/xmltble.cxx | 3 +-- sw/source/filter/xml/xmltexti.cxx | 2 +- 17 files changed, 22 insertions(+), 25 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/crsr/bookmark.cxx b/sw/source/core/crsr/bookmark.cxx index 3bb2f2eb90e1..573b64602aab 100644 --- a/sw/source/core/crsr/bookmark.cxx +++ b/sw/source/core/crsr/bookmark.cxx @@ -490,7 +490,7 @@ namespace sw::mark bool Bookmark::IsInContent() const { SwDoc& rDoc( GetMarkPos().GetDoc() ); - return !rDoc.IsInHeaderFooter( GetMarkPos().nNode ); + return !rDoc.IsInHeaderFooter( GetMarkPos().GetNode() ); } uno::Reference< rdf::XMetadatable > Bookmark::MakeUnoObject() diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index b95740932b07..bf117aa93603 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -3190,7 +3190,7 @@ SwDrawFrameFormat* DocumentContentOperationsManager::InsertDrawObj( // allow drawing objects in header/footer, but control objects aren't allowed in header/footer. if( pChkIdx != nullptr && ::CheckControlLayer( &rDrawObj ) - && m_rDoc.IsInHeaderFooter( *pChkIdx ) ) + && m_rDoc.IsInHeaderFooter( pChkIdx->GetNode() ) ) { // apply at-page anchor format eAnchorId = RndStdIds::FLY_AT_PAGE; diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx index 2857a9afa17e..c56bda3e01a9 100644 --- a/sw/source/core/doc/DocumentLayoutManager.cxx +++ b/sw/source/core/doc/DocumentLayoutManager.cxx @@ -344,7 +344,7 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat( bMayNotCopy = bCheckControlLayer && ((RndStdIds::FLY_AT_PARA == rNewAnchor.GetAnchorId()) || (RndStdIds::FLY_AT_FLY == rNewAnchor.GetAnchorId()) || (RndStdIds::FLY_AT_CHAR == rNewAnchor.GetAnchorId())) && - pCAnchor && m_rDoc.IsInHeaderFooter(pCAnchor->nNode); + pCAnchor && m_rDoc.IsInHeaderFooter(pCAnchor->GetNode()); } // just return if we can't copy this diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 82eb590258ef..7db7ede0fa2f 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1604,7 +1604,7 @@ bool SwDoc::ConvertFieldsToText(SwRootFrame const& rLayout) if (!bSkip) { - bool bInHeaderFooter = IsInHeaderFooter(SwNodeIndex(*pTextField->GetpTextNode())); + bool bInHeaderFooter = IsInHeaderFooter(*pTextField->GetpTextNode()); const SwFormatField& rFormatField = pTextField->GetFormatField(); const SwField* pField = rFormatField.GetField(); diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 9e545a654660..d0d480ff5fd6 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -1547,14 +1547,14 @@ void SwDoc::SetAllUniqueFlyNames() } } -bool SwDoc::IsInHeaderFooter( const SwNodeIndex& rIdx ) const +bool SwDoc::IsInHeaderFooter( const SwNode& rIdx ) const { // That can also be a Fly in a Fly in the Header. // Is also used by sw3io, to determine if a Redline object is // in the Header or Footer. // Because Redlines are also attached to Start and EndNode, // the Index must not necessarily be from a ContentNode. - SwNode* pNd = &rIdx.GetNode(); + const SwNode* pNd = &rIdx; const SwNode* pFlyNd = pNd->FindFlyStartNode(); while( pFlyNd ) { diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 6b543c801bdc..ff6edad6cf1b 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -966,7 +966,7 @@ bool SwSectionFormat::IsInContent() const { SwNodeIndex const*const pIdx = GetContent(false).GetContentIdx(); OSL_ENSURE(pIdx, "SwSectionFormat::IsInContent: no index?"); - return pIdx == nullptr || !GetDoc()->IsInHeaderFooter(*pIdx); + return pIdx == nullptr || !GetDoc()->IsInHeaderFooter(pIdx->GetNode()); } // n.b.: if the section format represents an index, then there is both a diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index 2a23f31eb3bc..a6b95b39515b 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -762,7 +762,7 @@ namespace { { SwPosition* pPos = rPaM.GetPoint(); // allow shapes (no controls) in header/footer - if(RES_DRAWFRMFMT == pCpyFormat->Which() && rDoc.IsInHeaderFooter(pPos->nNode)) + if(RES_DRAWFRMFMT == pCpyFormat->Which() && rDoc.IsInHeaderFooter(pPos->GetNode())) { const SdrObject *pCpyObj = pCpyFormat->FindSdrObject(); if(pCpyObj && CheckControlLayer(pCpyObj)) diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index d5a9f30e7e33..3e414cc5458d 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -228,7 +228,7 @@ bool sw_ChkAndSetNewAnchor( #if OSL_DEBUG_LEVEL > 0 OSL_ENSURE( !(nNew == RndStdIds::FLY_AT_PAGE && (RndStdIds::FLY_AT_PARA==nOld || RndStdIds::FLY_AT_CHAR==nOld || RndStdIds::FLY_AS_CHAR==nOld ) && - pDoc->IsInHeaderFooter( rOldAnch.GetContentAnchor()->nNode )), + pDoc->IsInHeaderFooter( rOldAnch.GetContentAnchor()->GetNode() )), "forbidden anchor change in Head/Foot." ); #endif diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index 49e7f99fd562..f32645ae8316 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -1490,7 +1490,7 @@ bool SwFEShell::ShouldObjectBeSelected(const Point& rPt) if (pContact && !pContact->ObjAnchoredAtPage() ) { const SwPosition& rPos = pContact->GetContentAnchor(); - bool bInHdrFtr = GetDoc()->IsInHeaderFooter( rPos.nNode ); + bool bInHdrFtr = GetDoc()->IsInHeaderFooter( rPos.GetNode() ); if (IsHeaderFooterEdit() != bInHdrFtr) { bRet = false; @@ -1931,7 +1931,7 @@ bool SwFEShell::ImpEndCreate() // anchor in header/footer also not allowed. if( bCharBound ) - bCharBound = !GetDoc()->IsInHeaderFooter( aPos.nNode ); + bCharBound = !GetDoc()->IsInHeaderFooter( aPos.GetNode() ); if( bCharBound ) { diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 255b965d8ccc..d2dfacf52f34 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1385,9 +1385,9 @@ void AppendAllObjs(const SwFrameFormats* pTable, const SwFrame* pSib) // frames nor objects which are anchored to character bounds. if ((rAnch.GetAnchorId() != RndStdIds::FLY_AT_PAGE) && (rAnch.GetAnchorId() != RndStdIds::FLY_AS_CHAR)) { - auto pContentAnchor = rAnch.GetContentAnchor(); + const SwPosition* pContentAnchor = rAnch.GetContentAnchor(); // formats in header/footer have no dependencies - if(pContentAnchor && pFormat->GetDoc()->IsInHeaderFooter(pContentAnchor->nNode)) + if(pContentAnchor && pFormat->GetDoc()->IsInHeaderFooter(pContentAnchor->GetNode())) pFormat->MakeFrames(); else vFormatsToConnect.push_back(pFormat); diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index af66250c3393..29f60bdcfdb3 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -1682,8 +1682,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() if ( !bIntern || -1 != nDestId ) { // #i44368# Links in Header/Footer - const SwPosition aPos( *pTNd ); - const bool bHeaderFooter = pDoc->IsInHeaderFooter( aPos.nNode ); + const bool bHeaderFooter = pDoc->IsInHeaderFooter( *pTNd ); // Create links for all selected rectangles: const size_t nNumOfRects = aTmp.size(); @@ -1796,7 +1795,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() if (RndStdIds::FLY_AT_PAGE != rAnch.GetAnchorId()) { const SwPosition* pPosition = rAnch.GetContentAnchor(); - if ( pPosition && pDoc->IsInHeaderFooter( pPosition->nNode ) ) + if ( pPosition && pDoc->IsInHeaderFooter( pPosition->GetNode() ) ) { const SwTextNode* pTNd = pPosition->GetNode().GetTextNode(); if ( pTNd ) @@ -1888,8 +1887,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() const sal_Int32 nDestId = pPDFExtOutDevData->CreateDest(aRect, nDestPageNum); // #i44368# Links in Header/Footer - const SwPosition aPos( *pTNd ); - const bool bHeaderFooter = pDoc->IsInHeaderFooter( aPos.nNode ); + const bool bHeaderFooter = pDoc->IsInHeaderFooter( *pTNd ); // Create links for all selected rectangles: const size_t nNumOfRects = aTmp.size(); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 1a18a1cdcbf2..37ab4ecf8799 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -5339,7 +5339,7 @@ bool SwTextNode::IsInUndo() const bool SwTextNode::IsInContent() const { - return !GetDoc().IsInHeaderFooter( SwNodeIndex(*this) ); + return !GetDoc().IsInHeaderFooter( *this ); } void SwTextNode::TriggerNodeUpdate(const sw::LegacyModifyHint& rHint) diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 4312c08dff95..65a6dba259c7 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1406,7 +1406,7 @@ bool SwTextNode::InsertHint( SwTextAttr * const pAttr, const SetAttrMode nMode ) // OD 26.06.2003 - allow drawing objects in header/footer. // But don't allow control objects in header/footer if( RES_DRAWFRMFMT == pFormat->Which() && - pDoc->IsInHeaderFooter( pFormat->GetAnchor().GetContentAnchor()->nNode ) ) + pDoc->IsInHeaderFooter( pFormat->GetAnchor().GetContentAnchor()->GetNode() ) ) { bool bCheckControlLayer = false; pFormat->CallSwClientNotify(sw::CheckDrawFrameFormatLayerHint(&bCheckControlLayer)); diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index 10da49719cd6..71d3ba36cbfd 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -272,7 +272,7 @@ uno::Any SwXRedlinePortion::GetPropertyValue( std::u16string_view rPropertyName } else if (rPropertyName == u"" UNO_NAME_IS_IN_HEADER_FOOTER) { - aRet <<= rRedline.GetDoc().IsInHeaderFooter( rRedline.GetPoint()->nNode ); + aRet <<= rRedline.GetDoc().IsInHeaderFooter( rRedline.GetPoint()->GetNode() ); } else if (rPropertyName == u"" UNO_NAME_MERGE_LAST_PARA) { diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 0ebe4a93c675..a15d23317dab 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -1510,7 +1510,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken ) case HtmlTokenId::LINEFEEDCHAR: if( m_pPam->GetPoint()->GetContentIndex() ) AppendTextNode(); - if (!m_xTable && !m_xDoc->IsInHeaderFooter(m_pPam->GetPoint()->nNode)) + if (!m_xTable && !m_xDoc->IsInHeaderFooter(m_pPam->GetPoint()->GetNode())) { NewAttr(m_xAttrTab, &m_xAttrTab->pBreak, SvxFormatBreakItem(SvxBreak::PageBefore, RES_BREAK)); EndAttr( m_xAttrTab->pBreak, false ); diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx index 81528e5b8c2f..da4b0473f4ad 100644 --- a/sw/source/filter/xml/xmltble.cxx +++ b/sw/source/filter/xml/xmltble.cxx @@ -1196,7 +1196,6 @@ void SwXMLTextParagraphExport::exportTable( OSL_ENSURE( pTableNd, "table node missing" ); if( bAutoStyles ) { - SwNodeIndex aIdx( *pTableNd ); // AUTOSTYLES: Optimization: Do not export table autostyle if // we are currently exporting the content.xml stuff and // the table is located in header/footer: @@ -1204,7 +1203,7 @@ void SwXMLTextParagraphExport::exportTable( // ALL flags are set at the same time. const bool bExportStyles = bool( GetExport().getExportFlags() & SvXMLExportFlags::STYLES ); if (!isAutoStylesCollected() - && (bExportStyles || !pFormat->GetDoc()->IsInHeaderFooter(aIdx))) + && (bExportStyles || !pFormat->GetDoc()->IsInHeaderFooter(*pTableNd))) { maTableNodes.push_back(pTableNd); m_TableFormats.emplace(pTableNd, ::std::make_pair(SwXMLTextParagraphExport::FormatMap(), SwXMLTextParagraphExport::FormatMap())); diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx index 64be72d6146c..448ea1b79043 100644 --- a/sw/source/filter/xml/xmltexti.cxx +++ b/sw/source/filter/xml/xmltexti.cxx @@ -179,7 +179,7 @@ bool SwXMLTextImportHelper::IsInHeaderFooter() const SAL_WARN_IF(!pTextCursor, "sw.uno", "SwXTextCursor missing"); SwDoc *pDoc = pTextCursor ? pTextCursor->GetDoc() : nullptr; - return pDoc && pDoc->IsInHeaderFooter( pTextCursor->GetPaM()->GetPoint()->nNode ); + return pDoc && pDoc->IsInHeaderFooter( pTextCursor->GetPaM()->GetPoint()->GetNode() ); } static SwOLENode *lcl_GetOLENode( const SwFrameFormat *pFrameFormat ) -- cgit