sw/source/core/fields/reffld.cxx | 21 +++++---------------- sw/uiconfig/swriter/ui/fldrefpage.ui | 2 +- 2 files changed, 6 insertions(+), 17 deletions(-)
New commits: commit 60c111838da81697a49b3011eebe8b1e05ad08bb Author: Skyler Grey <skyler.g...@collabora.com> AuthorDate: Tue Oct 24 10:19:52 2023 +0000 Commit: Skyler Grey <skyler.g...@collabora.com> CommitDate: Wed Oct 25 16:36:51 2023 +0200 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/+/158382 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 3a7bc4ae4e70..1f8aae4e3506 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -1385,8 +1385,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; @@ -1435,6 +1433,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); @@ -1500,10 +1500,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) { @@ -1517,8 +1514,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]); } @@ -1580,20 +1575,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 635cbb35fb41..8592211ef10e 100644 --- a/sw/uiconfig/swriter/ui/fldrefpage.ui +++ b/sw/uiconfig/swriter/ui/fldrefpage.ui @@ -201,7 +201,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>