sw/source/core/crsr/crstrvl.cxx              |    6 ++----
 sw/source/core/doc/DocumentFieldsManager.cxx |    8 ++++----
 sw/source/core/doc/doc.cxx                   |    2 +-
 sw/source/core/doc/docfld.cxx                |   10 +++++-----
 sw/source/core/fields/docufld.cxx            |    4 ++--
 sw/source/core/fields/expfld.cxx             |    2 +-
 sw/source/core/inc/docfld.hxx                |    3 ++-
 7 files changed, 17 insertions(+), 18 deletions(-)

New commits:
commit e83daa9ff1d4d41ef7ac7b13fe7ab1dc0bd82f68
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Mon Aug 15 08:17:13 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Aug 15 09:16:04 2022 +0200

    pass content offset into FieldsToCalc instead of SwContentIndex
    
    part of the process of hiding the internals of SwPosition
    
    Change-Id: I76aee9e18f37f70648c181af0c2bbc4d4f2dfd2a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138264
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 33446ad5d628..5fe7ef36dabc 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -662,15 +662,13 @@ lcl_FindField(bool & o_rFound, SetGetExpFields const& 
rSrtLst,
         sal_Int32 const nContentOffset)
 {
     std::optional<SetGetExpField> oSrch;
-    std::optional<SwContentIndex> oIndex;
     if (-1 == nContentOffset)
     {
-        oSrch.emplace(rPos.GetNode(), pTextField, &rPos.nContent);
+        oSrch.emplace(rPos.GetNode(), pTextField, rPos.GetContentIndex());
     }
     else
     {
-        oIndex.emplace(rPos.GetNode().GetContentNode(), nContentOffset);
-        oSrch.emplace(rPos.GetNode(), pTextField, &*oIndex);
+        oSrch.emplace(rPos.GetNode(), pTextField, nContentOffset);
     }
 
     if (rPos.GetNodeIndex() < 
pTextNode->GetNodes().GetEndOfExtras().GetIndex())
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx 
b/sw/source/core/doc/DocumentFieldsManager.cxx
index a9b22abe92d6..e7ef745bb803 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -728,7 +728,7 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* 
pHt )
                             {
                                 FieldsToCalc( *pCalc, SetGetExpField(
                                         aPos.GetNode(), 
pFormatField->GetTextField(),
-                                        &aPos.nContent, 
pFrame->GetPhyPageNum()),
+                                        aPos.GetContentIndex(), 
pFrame->GetPhyPageNum()),
                                     pLayout);
                             }
                             else
@@ -741,7 +741,7 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* 
pHt )
                         SwFrame const*const pFrame2 = 
::sw::FindNeighbourFrameForNode(rTextNd);
                         FieldsToCalc( *pCalc,
                             SetGetExpField(rTextNd, 
pFormatField->GetTextField(),
-                                nullptr,
+                                std::nullopt,
                                 pFrame2 ? pFrame2->GetPhyPageNum() : 0),
                             pLayout);
                     }
@@ -804,7 +804,7 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* 
pHt )
                                 if( GetBodyTextNode( m_rDoc, aPos, *pFrame ) )
                                 {
                                     FieldsToCalc(*pCalc, 
SetGetExpField(aPos.GetNode(),
-                                            nullptr, nullptr, 
pFrame->GetPhyPageNum()),
+                                            nullptr, std::nullopt, 
pFrame->GetPhyPageNum()),
                                         pLayout);
                                 }
                                 else
@@ -816,7 +816,7 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* 
pHt )
                     {
                         // create index to determine the TextNode
                         SwFrame const*const pFrame2 = 
::sw::FindNeighbourFrameForNode(*pTableNd);
-                        FieldsToCalc(*pCalc, SetGetExpField(*pTableNd, 
nullptr, nullptr,
+                        FieldsToCalc(*pCalc, SetGetExpField(*pTableNd, 
nullptr, std::nullopt,
                                 pFrame2 ? pFrame2->GetPhyPageNum() : 0),
                             pLayout);
                     }
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 0909e632ba74..6a82869b619b 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -468,7 +468,7 @@ namespace {
 struct PostItField_ : public SetGetExpField
 {
     PostItField_( const SwNode& rNd, const SwTextField* pField )
-        : SetGetExpField( rNd, pField, nullptr ) {}
+        : SetGetExpField( rNd, pField, std::nullopt ) {}
 
     sal_uInt16 GetPageNo( const StringRangeEnumerator &rRangeEnum,
             const o3tl::sorted_vector< sal_Int32 > &rPossiblePages,
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index 8f50b72ced7b..f6f9cc210824 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -67,15 +67,15 @@ using namespace ::com::sun::star::uno;
 SetGetExpField::SetGetExpField(
     const SwNode& rNdIdx,
     const SwTextField* pField,
-    const SwContentIndex* pIdx,
+    std::optional<sal_Int32> oContentIdx,
     sal_uInt16 const nPageNumber)
     : m_nPageNumber(nPageNumber)
 {
     m_eSetGetExpFieldType = TEXTFIELD;
     m_CNTNT.pTextField = pField;
     m_nNode = rNdIdx.GetIndex();
-    if( pIdx )
-        m_nContent = pIdx->GetIndex();
+    if( oContentIdx )
+        m_nContent = *oContentIdx;
     else if( pField )
         m_nContent = pField->GetStart();
     else
@@ -1090,7 +1090,7 @@ void SwDocUpdateField::GetBodyNode( const SwTextField& 
rTField, SwFieldIds nFiel
         }
         if( (pFrame != nullptr) || bIsInBody )
         {
-            pNew.reset(new SetGetExpField(rTextNd, &rTField, nullptr,
+            pNew.reset(new SetGetExpField(rTextNd, &rTField, std::nullopt,
                 pFrame ? pFrame->GetPhyPageNum() : 0));
         }
     }
@@ -1100,7 +1100,7 @@ void SwDocUpdateField::GetBodyNode( const SwTextField& 
rTField, SwFieldIds nFiel
         SwPosition aPos( rDoc.GetNodes().GetEndOfPostIts() );
         bool const bResult = GetBodyTextNode( rDoc, aPos, *pFrame );
         OSL_ENSURE(bResult, "where is the Field");
-        pNew.reset(new SetGetExpField(aPos.GetNode(), &rTField, &aPos.nContent,
+        pNew.reset(new SetGetExpField(aPos.GetNode(), &rTField, 
aPos.GetContentIndex(),
             pFrame->GetPhyPageNum()));
     }
 
diff --git a/sw/source/core/fields/docufld.cxx 
b/sw/source/core/fields/docufld.cxx
index 76e32a6aeb73..c52a26373d95 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -2260,7 +2260,7 @@ bool SwRefPageGetFieldType::MakeSetList(SetGetExpFields& 
rTmpLst,
                 bool const bResult = GetBodyTextNode( m_rDoc, aPos, *pFrame );
                 OSL_ENSURE(bResult, "where is the Field?");
                 pNew.reset( new SetGetExpField( aPos.GetNode(), pTField,
-                                            &aPos.nContent ) );
+                                            aPos.GetContentIndex() ) );
             }
 
             rTmpLst.insert( std::move(pNew) );
@@ -2388,7 +2388,7 @@ void SwRefPageGetField::ChangeExpansion(const SwFrame& 
rFrame,
     if(!pTextNode)
         return;
 
-    SetGetExpField aEndField( aPos.GetNode(), pField, &aPos.nContent );
+    SetGetExpField aEndField( aPos.GetNode(), pField, aPos.GetContentIndex() );
 
     SetGetExpFields::const_iterator itLast = aTmpLst.lower_bound( &aEndField );
 
diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx
index 6923eb6ae5f6..d79f46ad09f3 100644
--- a/sw/source/core/fields/expfld.cxx
+++ b/sw/source/core/fields/expfld.cxx
@@ -374,7 +374,7 @@ void SwGetExpField::ChangeExpansion( const SwFrame& rFrame, 
const SwTextField& r
     SwRootFrame const& rLayout(*rFrame.getRootFrame());
     OUString & rExpand(rLayout.IsHideRedlines() ? m_sExpandRLHidden : 
m_sExpand);
     // here a page number is needed to sort correctly
-    SetGetExpField aEndField(aPos.GetNode(), &rField, &aPos.nContent, 
rFrame.GetPhyPageNum());
+    SetGetExpField aEndField(aPos.GetNode(), &rField, aPos.GetContentIndex(), 
rFrame.GetPhyPageNum());
     if(GetSubType() & nsSwGetSetExpType::GSE_STRING)
     {
         SwHashTable<HashStr> aHashTable(0);
diff --git a/sw/source/core/inc/docfld.hxx b/sw/source/core/inc/docfld.hxx
index 8cc339accb01..a96dccabdc1b 100644
--- a/sw/source/core/inc/docfld.hxx
+++ b/sw/source/core/inc/docfld.hxx
@@ -26,6 +26,7 @@
 #include <IMark.hxx>
 #include <o3tl/sorted_vector.hxx>
 #include <memory>
+#include <optional>
 
 class SwTextField;
 class SwContentIndex;
@@ -66,7 +67,7 @@ class SetGetExpField
 
 public:
     SetGetExpField( const SwNode& rNd, const SwTextField* pField = nullptr,
-                    const SwContentIndex* pIdx = nullptr,
+                    std::optional<sal_Int32> oContentIdx = std::nullopt,
                     sal_uInt16 nPageNumber = 0);
 
     SetGetExpField( const SwNode& rNd, const SwTextINetFormat& rINet );

Reply via email to