summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2023-02-07 23:17:17 -0900
committerJim Raykowski <raykowj@gmail.com>2023-02-10 17:07:50 +0000
commit5bc7cb77df839f7dd3cc7d444490aaf50ebccdc6 (patch)
treec8a580e36b60296121c348ff06f535bb4be4be63
parent208a4ecafafa97ea7fcc5a135fa8160e91ea0a74 (diff)
tdf#153205 related: Fix selection problems caused by cursor shell
push pop during insert state update This patch renames the SelectHiddenRange function to IsInHiddenRange and modifies it to take a bool argument that when true selects the hidden range if the current cursor position is in a hidden range. When the argument is false, the hidden range is not selected if the current cursor position is in a hidden range. This makes using cursor push pop unnecessary when all that is wanted to know is if the current cursor position is in a hidden range. Change-Id: I622dfaf8e73c5b432bb74a48d36433ff755542b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146725 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Jim Raykowski <raykowj@gmail.com>
-rw-r--r--sw/inc/crsrsh.hxx6
-rw-r--r--sw/source/core/crsr/crsrsh.cxx15
-rw-r--r--sw/source/core/text/EnhancedPDFExportHelper.cxx6
-rw-r--r--sw/source/uibase/shells/textsh.cxx9
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx9
5 files changed, 19 insertions, 26 deletions
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index efc8aa1eec49..8eac979b5617 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -851,9 +851,9 @@ public:
bool bColumnChange();
static void FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection);
static void FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn);
- // If the current cursor position is inside a hidden range, the hidden range
- // is selected and true is returned:
- bool SelectHiddenRange();
+ // If the current cursor position is inside a hidden range true is returned. If bSelect is
+ // true, the hidden range is selected. If bSelect is false, the hidden range is not selected.
+ bool IsInHiddenRange(const bool bSelect);
// remove all invalid cursors
void ClearUpCursors();
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index bc78d12cb594..6aef2801b0b7 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -3453,9 +3453,9 @@ bool SwCursorShell::IsInRightToLeftText() const
return SvxFrameDirection::Vertical_LR_TB == nDir || SvxFrameDirection::Horizontal_RL_TB == nDir;
}
-/// If the current cursor position is inside a hidden range, the hidden range
-/// is selected.
-bool SwCursorShell::SelectHiddenRange()
+/// If the current cursor position is inside a hidden range true is returned. If bSelect is
+/// true, the hidden range is selected. If bSelect is false, the hidden range is not selected.
+bool SwCursorShell::IsInHiddenRange(const bool bSelect)
{
bool bRet = false;
if ( !GetViewOptions()->IsShowHiddenChar() && !m_pCurrentCursor->HasMark() )
@@ -3472,9 +3472,12 @@ bool SwCursorShell::SelectHiddenRange()
SwScriptInfo::GetBoundsOfHiddenRange( *pNode, nPos, nHiddenStart, nHiddenEnd );
if ( COMPLETE_STRING != nHiddenStart )
{
- // make selection:
- m_pCurrentCursor->SetMark();
- m_pCurrentCursor->GetMark()->SetContent(nHiddenEnd);
+ if (bSelect)
+ {
+ // make selection:
+ m_pCurrentCursor->SetMark();
+ m_pCurrentCursor->GetMark()->SetContent(nHiddenEnd);
+ }
bRet = true;
}
}
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index c869413c3164..9e7a01c60a7f 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -274,7 +274,7 @@ bool lcl_TryMoveToNonHiddenField(SwEditShell& rShell, const SwTextNode& rNd, con
// 3. Check for hidden text attribute
if(rNd.IsHidden())
return false;
- if(!rShell.GotoFormatField(rField) || rShell.SelectHiddenRange())
+ if(!rShell.GotoFormatField(rField) || rShell.IsInHiddenRange(/*bSelect=*/false))
{
rShell.SwCursorShell::ClearMark();
return false;
@@ -1673,7 +1673,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
// 3. Check for hidden text attribute
if ( !pTNd->IsHidden() &&
mrSh.GotoINetAttr( p->rINetAttr ) &&
- !mrSh.SelectHiddenRange() )
+ !mrSh.IsInHiddenRange(/*bSelect=*/false) )
{
// Select the hyperlink:
mrSh.SwCursorShell::Right( 1, SwCursorSkipMode::Chars );
@@ -1991,7 +1991,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
// 1. Check if the whole paragraph is hidden
// 2. Check for hidden text attribute
- if (rTNd.GetTextNode()->IsHidden() || mrSh.SelectHiddenRange()
+ if (rTNd.GetTextNode()->IsHidden() || mrSh.IsInHiddenRange(/*bSelect=*/false)
|| (mrSh.GetLayout()->IsHideRedlines()
&& sw::IsFootnoteDeleted(pDoc->getIDocumentRedlineAccess(), *pTextFootnote)))
{
diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx
index af047adc2d19..06f338f290dc 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -605,14 +605,7 @@ void SwTextShell::StateInsert( SfxItemSet &rSet )
SvtModuleOptions aMOpt;
SfxObjectCreateMode eCreateMode =
GetView().GetDocShell()->GetCreateMode();
-
- bool bCursorInHidden = false;
- if( !rSh.HasMark() )
- {
- rSh.Push();
- bCursorInHidden = rSh.SelectHiddenRange();
- rSh.Pop();
- }
+ const bool bCursorInHidden = rSh.IsInHiddenRange(/*bSelect=*/false);
while ( nWhich )
{
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index a13cda9bb3d3..8b6b3b225113 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -233,7 +233,7 @@ void SwWrtShell::Insert( const OUString &rStr )
bCallIns = m_bIns /*|| bHasSel*/;
bool bDeleted = false;
- if( bHasSel || ( !m_bIns && SelectHiddenRange() ) )
+ if( bHasSel || ( !m_bIns && IsInHiddenRange(/*bSelect=*/true) ) )
{
// Only here parenthesizing, because the normal
// insert is already in parentheses at Editshell.
@@ -2046,11 +2046,8 @@ bool SwWrtShell::Pop(SwCursorShell::PopMode const eDelete, ::std::optional<SwCal
bool bRet = SwCursorShell::Pop(eDelete, roLink);
if( bRet && IsSelection() )
{
- if (!IsAddMode())
- {
- m_fnSetCursor = &SwWrtShell::SetCursorKillSel;
- m_fnKillSel = &SwWrtShell::ResetSelect;
- }
+ m_fnSetCursor = &SwWrtShell::SetCursorKillSel;
+ m_fnKillSel = &SwWrtShell::ResetSelect;
}
return bRet;
}