sw/source/core/fields/reffld.cxx | 21 +++++---------------- sw/uiconfig/swriter/ui/fldrefpage.ui | 2 +- 2 files changed, 6 insertions(+), 17 deletions(-)
New commits: commit 3e6d4a563f390638b285254d2128466b56ce03ba Author: Skyler Grey <[email protected]> AuthorDate: Tue Oct 24 10:19:52 2023 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Mon Oct 30 20:11:31 2023 +0100 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 <[email protected]> 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 diff --git a/sw/uiconfig/swriter/ui/fldrefpage.ui b/sw/uiconfig/swriter/ui/fldrefpage.ui index 549a7a6e6f9a..8398e0a2ccf8 100644 --- a/sw/uiconfig/swriter/ui/fldrefpage.ui +++ b/sw/uiconfig/swriter/ui/fldrefpage.ui @@ -202,7 +202,7 @@ <property name="baseline-position">top</property> <child> <object class="GtkCheckButton" id="stylereffrombottomcheckbox"> - <property name="label" translatable="yes" context="fldrefpage|stylerefflags|label1">Search from bottom to top</property> + <property name="label" translatable="yes" context="fldrefpage|stylerefflags|label1">Search this page from bottom to top</property> <property name="visible">True</property> <property name="can-focus">True</property> <property name="receives-default">False</property>
