summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-07-05 18:08:54 +0300
committerAndras Timar <andras.timar@collabora.com>2023-07-31 21:40:10 +0200
commitec6e624f70334bf926e85f7d1f4ffaaecda7cc2a (patch)
treebb5a4bc26e309fff0f6823c29476458414396f41
parentb1b23af1108dfd1d460e1508ad1421b53cb5bff4 (diff)
tdf#155462: fix the scrollbar tooltip text
Over the time when it was completely unused, it regressed in a couple of aspects: 1. It got assembled in incorrect order: instead of appending chapter, it got prepended in commit 832e5aadbff006ec24959162c29756fe2b1982be (Related: fdo#38838 remove UniString::SearchAndReplaceAll, 2013-10-08); 2. It started to show chapters, only when the respective heading are at the very top of screen, and show only page elsewhere, likely in commit 835cd06a047717dfe5e0f117959f3c042e13b21b (tdf#38093 Writer outline folding - outline visibility and on canvas ui, 2020-07-30), where a call to SwNode::FindOutlineNodeOfLevel was replaced with SwOutlineNodes::Seek_Entry in SwCursorShell::GetContentAtPos. Change-Id: I3f427f7ecb3b6c58a441220c555b22e765a533c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154077 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 7e997097eb0e36bbb6f1eb8519acfc4e8eb6337a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154174 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154166 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r--sw/inc/crsrsh.hxx11
-rw-r--r--sw/source/core/crsr/crstrvl.cxx13
-rw-r--r--sw/source/uibase/uiview/viewport.cxx8
3 files changed, 20 insertions, 12 deletions
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 83fe5fec632d..639b29f3ed98 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -87,15 +87,16 @@ enum class IsAttrAtPos
ContentCheck = 0x0400,
SmartTag = 0x0800,
FormControl = 0x1000,
- TableRedline = 0x2000
+ TableRedline = 0x2000,
#ifdef DBG_UTIL
- ,CurrAttrs = 0x4000 ///< only for debugging
- ,TableBoxValue = 0x8000 ///< only for debugging
+ CurrAttrs = 0x4000, ///< only for debugging
+ TableBoxValue = 0x8000, ///< only for debugging
#endif
- , ContentControl = 0x10000
+ ContentControl = 0x10000,
+ AllowContaining = 0x20000, // With Outline, finds an outline node for non-outline position
};
namespace o3tl {
- template<> struct typed_flags<IsAttrAtPos> : is_typed_flags<IsAttrAtPos, 0x1ffff> {};
+ template<> struct typed_flags<IsAttrAtPos> : is_typed_flags<IsAttrAtPos, 0x3ffff> {};
}
struct SwContentAtPos
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 67093bd9577d..69b4e96caade 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1466,8 +1466,17 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
&& !rNds.GetOutLineNds().empty() )
{
// only for nodes in outline nodes
- SwOutlineNodes::size_type nPos;
- if(rNds.GetOutLineNds().Seek_Entry(pTextNd, &nPos))
+ SwOutlineNodes::size_type nPos = 0;
+ bool bFoundOutline = rNds.GetOutLineNds().Seek_Entry(pTextNd, &nPos);
+ if (!bFoundOutline && nPos && (IsAttrAtPos::AllowContaining & rContentAtPos.eContentAtPos))
+ {
+ // nPos points to the first found outline node not before pTextNd, or to end();
+ // when bFoundOutline is false, and nPos is not 0, it means that there were
+ // outline nodes before pTextNd, and nPos-1 points to the last of those.
+ pTextNd = rNds.GetOutLineNds()[nPos - 1]->GetTextNode();
+ bFoundOutline = true;
+ }
+ if (bFoundOutline)
{
rContentAtPos.eContentAtPos = IsAttrAtPos::Outline;
rContentAtPos.sStr = sw::GetExpandTextMerged(GetLayout(), *pTextNd, true, false, ExpandMode::ExpandFootnote);
diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx
index 6727e6f76980..74f547bb2624 100644
--- a/sw/source/uibase/uiview/viewport.cxx
+++ b/sw/source/uibase/uiview/viewport.cxx
@@ -714,16 +714,14 @@ IMPL_LINK(SwView, VertScrollHdl, weld::Scrollbar&, rScrollbar, void)
aRect.SetBottom( aRect.Top() );
OUString sPageStr( GetPageStr( nPhNum, nVirtNum, sDisplay ));
- SwContentAtPos aCnt( IsAttrAtPos::Outline );
+ SwContentAtPos aCnt(IsAttrAtPos::Outline | IsAttrAtPos::AllowContaining);
bool bSuccess = m_pWrtShell->GetContentAtPos(aPos, aCnt);
if (bSuccess && !aCnt.sStr.isEmpty())
{
- sPageStr += " - ";
sal_Int32 nChunkLen = std::min<sal_Int32>(aCnt.sStr.getLength(), 80);
std::u16string_view sChunk = aCnt.sStr.subView(0, nChunkLen);
- sPageStr = sChunk + sPageStr;
- sPageStr = sPageStr.replace('\t', ' ');
- sPageStr = sPageStr.replace(0x0a, ' ');
+ sPageStr = sPageStr + " - " + sChunk;
+ sPageStr = sPageStr.replace('\t', ' ').replace(0x0a, ' ');
}
Help::ShowQuickHelp(m_pVScrollbar, aRect, sPageStr,