diff options
author | Skyler Grey <skyler.grey@collabora.com> | 2023-10-24 10:19:52 +0000 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-10-30 20:11:31 +0100 |
commit | 3e6d4a563f390638b285254d2128466b56ce03ba (patch) | |
tree | a73c5ae362c2e33eaf6670777b57d2876567f218 /sw/source | |
parent | 2ddd1378fc232fbc1d5162f2c44ecf71c6725732 (diff) |
Improve STYLE_FROM_BOTTOM compatability with Word
From my testing in Word, it doesn't honor the "search from bottom" flag
when it is in the body, only in marginals. Additionally, it doesn't
continue searching in the opposite order if the referenced content is
not found on the current page, instead it searches in the same order as
it would normally (i.e. pages above then pages below). This commit
changes the behavior and UI of our from bottom flag to match.
Change-Id: Id991c92b9aeaa054b136f7a3d9c7c8ea0026e514
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158452
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/fields/reffld.cxx | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index c92d4b6d37bb..f034b1b52b5b 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -1384,8 +1384,6 @@ SwTextNode* SwGetRefFieldType::FindAnchor(SwDoc* pDoc, const OUString& rRefMark, case REF_STYLE: if (!pSelf) break; - bool bFlagFromBottom = (nFlags & REFFLDFLAG_STYLE_FROM_BOTTOM) == REFFLDFLAG_STYLE_FROM_BOTTOM; - const SwNodes& nodes = pDoc->GetNodes(); StyleRefElementType elementType = StyleRefElementType::Default; @@ -1434,6 +1432,8 @@ SwTextNode* SwGetRefFieldType::FindAnchor(SwDoc* pDoc, const OUString& rRefMark, // For marginals, styleref tries to act on the current page first // 1. Get the page we're on, search it from top to bottom + bool bFlagFromBottom = (nFlags & REFFLDFLAG_STYLE_FROM_BOTTOM) == REFFLDFLAG_STYLE_FROM_BOTTOM; + Point aPt; std::pair<Point, bool> const tmp(aPt, false); @@ -1499,10 +1499,7 @@ SwTextNode* SwGetRefFieldType::FindAnchor(SwDoc* pDoc, const OUString& rRefMark, if (beforeStart) { - if (bFlagFromBottom) - pSearchThird.push_front(nodes[n]); - else - pSearchSecond.push_front(nodes[n]); + pSearchSecond.push_front(nodes[n]); } else if (beforeEnd) { @@ -1516,8 +1513,6 @@ SwTextNode* SwGetRefFieldType::FindAnchor(SwDoc* pDoc, const OUString& rRefMark, beforeEnd = false; } } - else if (bFlagFromBottom) - pSearchSecond.push_back(nodes[n]); else pSearchThird.push_back(nodes[n]); } @@ -1579,20 +1574,14 @@ SwTextNode* SwGetRefFieldType::FindAnchor(SwDoc* pDoc, const OUString& rRefMark, { if (beforeElement) { - if (bFlagFromBottom) - pSearchSecond.push_front(nodes[n]); - else - pSearchFirst.push_front(nodes[n]); + pSearchFirst.push_front(nodes[n]); if (*pReference == *nodes[n]) { beforeElement = false; } } - else if (bFlagFromBottom) - pSearchFirst.push_back(nodes[n]); - else - pSearchSecond.push_back(nodes[n]); + pSearchSecond.push_back(nodes[n]); } // 1. Search up until we hit the top of the document |