sw/source/uibase/inc/content.hxx   |    2 +-
 sw/source/uibase/inc/swcont.hxx    |    4 ++--
 sw/source/uibase/utlui/content.cxx |   29 ++++++++++++++++++-----------
 3 files changed, 21 insertions(+), 14 deletions(-)

New commits:
commit c81f4a4ecbfa7dc97d8c28b5ec5f00d1d561b6bb
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Sun Apr 24 12:07:35 2022 -0800
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Fri Apr 29 22:43:38 2022 +0200

    tdf#143569 SwNavigator: Make Headings entries from headings in frames
    
    be in document layout order, not alphabetical order
    
    Change-Id: I75328311a7ddbda1eb050135709da20fed5d054a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133359
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>

diff --git a/sw/source/uibase/inc/content.hxx b/sw/source/uibase/inc/content.hxx
index 2d6ac1a7d925..0acc45197e76 100644
--- a/sw/source/uibase/inc/content.hxx
+++ b/sw/source/uibase/inc/content.hxx
@@ -46,7 +46,7 @@ class SwOutlineContent final : public SwContent
                             SwOutlineNodes::size_type nArrPos,
                             sal_uInt8 nLevel,
                             bool bMove,
-                            tools::Long nYPos) :
+                            double nYPos) :
             SwContent(pCnt, rName, nYPos),
             m_nOutlinePos(nArrPos), m_nOutlineLevel(nLevel), 
m_bIsMoveable(bMove) {}
 
diff --git a/sw/source/uibase/inc/swcont.hxx b/sw/source/uibase/inc/swcont.hxx
index a965b0fadbc6..77b9d5656030 100644
--- a/sw/source/uibase/inc/swcont.hxx
+++ b/sw/source/uibase/inc/swcont.hxx
@@ -75,13 +75,13 @@ class SwContent : public SwTypeNumber
 {
     const SwContentType*    m_pParent;
     OUString                m_sContentName;
-    tools::Long                    m_nYPosition;
+    double m_nYPosition;
         // some subclasses appear to use this for a tools/gen.hxx-style
         // geometric Y position, while e.g. SwOutlineContent wants to store
         // the index in its subtree
     bool                    m_bInvisible;
 public:
-        SwContent(const SwContentType* pCnt, const OUString& rName, 
tools::Long nYPos );
+        SwContent(const SwContentType* pCnt, const OUString& rName, double 
nYPos);
 
     virtual bool            IsProtect() const;
     const SwContentType*    GetParent() const {return m_pParent;}
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index e9d4468d1df7..3cb1fd4aede2 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -183,7 +183,7 @@ namespace
 
 // Content, contains names and reference at the content type.
 
-SwContent::SwContent(const SwContentType* pCnt, const OUString& rName, 
tools::Long nYPos) :
+SwContent::SwContent(const SwContentType* pCnt, const OUString& rName, double 
nYPos) :
     SwTypeNumber(CTYPE_CNT),
     m_pParent(pCnt),
     m_sContentName(rName),
@@ -424,23 +424,30 @@ void SwContentType::FillMemberList(bool* pbContentChanged)
     {
         case ContentTypeId::OUTLINE   :
         {
-            const size_t nOutlineCount =
-                
m_pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount();
+            const SwNodeOffset nEndOfExtrasIndex = 
m_pWrtShell->GetNodes().GetEndOfExtras().GetIndex();
+            // provide for up to 99999 outline nodes in frames to be sorted in 
document layout order
+            double nOutlinesInFramesIndexAdjustment = 0.00001;
+            const SwOutlineNodes& 
rOutlineNodes(m_pWrtShell->GetNodes().GetOutLineNds());
+            const size_t nOutlineCount = rOutlineNodes.size();
 
             for (size_t i = 0; i < nOutlineCount; ++i)
             {
-                const sal_uInt8 nLevel = 
m_pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineLevel(i);
-                if (nLevel >= m_nOutlineLevel || 
!m_pWrtShell->getIDocumentOutlineNodesAccess()->
-                        isOutlineInLayout(i, *m_pWrtShell->GetLayout()))
+                SwTextNode* pNode = rOutlineNodes[i]->GetTextNode();
+                const sal_uInt8 nLevel = pNode->GetAttrOutlineLevel() - 1;
+                if (nLevel >= m_nOutlineLevel || 
!pNode->getLayoutFrame(m_pWrtShell->GetLayout()))
                     continue;
-                tools::Long nYPos = m_bAlphabeticSort ? 0 : getYPos(
-                            
*m_pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNode(i));
+                double nYPos = m_bAlphabeticSort ? 0 : 
static_cast<double>(getYPos(*pNode));
+                if (nEndOfExtrasIndex >= pNode->GetIndex() && 
pNode->GetFlyFormat())
+                {
+                    nYPos += nOutlinesInFramesIndexAdjustment;
+                    nOutlinesInFramesIndexAdjustment += 0.00001;
+                }
                 OUString aEntry(comphelper::string::stripStart(
-                                    
m_pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(
-                                        i, m_pWrtShell->GetLayout(), true, 
false, false), ' '));
+                                
m_pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(
+                                i, m_pWrtShell->GetLayout(), true, false, 
false), ' '));
                 aEntry = SwNavigationPI::CleanEntry(aEntry);
                 auto pCnt(make_unique<SwOutlineContent>(this, aEntry, i, 
nLevel,
-                                                        
m_pWrtShell->IsOutlineMovable( i ), nYPos));
+                                                        
m_pWrtShell->IsOutlineMovable(i), nYPos));
                 m_pMember->insert(std::move(pCnt));
             }
 

Reply via email to