summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-08-23 13:57:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-08-23 15:19:43 +0200
commit0925dc81415276932aef66107b2d924b22c02d1e (patch)
tree3ea39ece7f2491b99a102b51a9395cbf5cc70ed9 /sw
parentfc10c4a3a7700fc96890149ae9095206b5e67685 (diff)
Use more SwPosition::Adjust
to keep the internal fields of SwPosition in sync. Change-Id: I9a9889a819a3998aa4ff2188a2dc3e0cb2ec6888 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138727 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/shells/textfld.cxx3
-rw-r--r--sw/source/uibase/shells/textsh1.cxx4
-rw-r--r--sw/source/uibase/uiview/viewling.cxx11
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx2
-rw-r--r--sw/source/uibase/wrtsh/delete.cxx3
5 files changed, 11 insertions, 12 deletions
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index fb1f00490391..d06acdcfb730 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -957,8 +957,7 @@ void SwTextShell::StateField( SfxItemSet &rSet )
if ((!pFieldBM || pFieldBM->GetFieldname() != ODF_FORMTEXT)
&& aCursorPos.GetContentIndex() > 0)
{
- SwPosition aPos(aCursorPos);
- --aPos.nContent;
+ SwPosition aPos(*aCursorPos.GetContentNode(), aCursorPos.GetContentIndex() - 1);
pFieldBM = GetShell().getIDocumentMarkAccess()->getFieldmarkFor(aPos);
}
if (pFieldBM && pFieldBM->GetFieldname() == ODF_FORMTEXT &&
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index d5aff9eaa278..647ef76ade64 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1453,7 +1453,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
sw::mark::IFieldmark* pFieldBM = GetShell().getIDocumentMarkAccess()->getFieldmarkFor(aPos);
if ( !pFieldBM )
{
- --aPos.nContent;
+ aPos.AdjustContent(-1);
pFieldBM = GetShell().getIDocumentMarkAccess()->getFieldmarkFor(aPos);
}
@@ -2198,7 +2198,7 @@ void SwTextShell::GetState( SfxItemSet &rSet )
sw::mark::IFieldmark* pFieldBM = GetShell().getIDocumentMarkAccess()->getFieldmarkFor(aPos);
if ( !pFieldBM && aPos.GetContentIndex() > 0)
{
- --aPos.nContent;
+ aPos.AdjustContent(-1);
pFieldBM = GetShell().getIDocumentMarkAccess()->getFieldmarkFor(aPos);
}
if ( pFieldBM && (pFieldBM->GetFieldname() == ODF_FORMDROPDOWN || pFieldBM->GetFieldname() == ODF_FORMDATE) )
diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx
index c98e9056bfc1..45b1851ad3c5 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -186,10 +186,11 @@ void SwView::ExecLingu(SfxRequest &rReq)
// check for unexpected error case
OSL_ENSURE(pTextNode && pTextNode->GetText().getLength() >= nPointIndex,
"text missing: corrupted node?" );
- if (!pTextNode || pTextNode->GetText().getLength() < nPointIndex)
- nPointIndex = 0;
// restore cursor to its original position
- m_pWrtShell->GetCursor()->GetPoint()->nContent.Assign( pTextNode, nPointIndex );
+ if (!pTextNode || pTextNode->GetText().getLength() < nPointIndex)
+ m_pWrtShell->GetCursor()->GetPoint()->Assign( aPointNodeIndex );
+ else
+ m_pWrtShell->GetCursor()->GetPoint()->Assign( *pTextNode, nPointIndex );
}
// enable all, restore view and cursor position
@@ -511,8 +512,8 @@ void SwView::InsertThesaurusSynonym( const OUString &rSynonmText, const OUString
// adjust existing selection
SwPaM *pCursor = m_pWrtShell->GetCursor();
- pCursor->GetPoint()->nContent -= nRight;
- pCursor->GetMark()->nContent += nLeft;
+ pCursor->GetPoint()->AdjustContent(-nRight);
+ pCursor->GetMark()->AdjustContent(nLeft);
}
m_pWrtShell->Insert( rSynonmText );
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index d5a685c87349..4c67a45cdcf8 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3332,7 +3332,7 @@ void SwXTextDocument::executeFromFieldEvent(const StringMap& aArguments)
sw::mark::IFieldmark* pFieldBM = m_pDocShell->GetWrtShell()->getIDocumentMarkAccess()->getFieldmarkFor(aPos);
if ( !pFieldBM )
{
- --aPos.nContent;
+ aPos.AdjustContent(-1);
pFieldBM = m_pDocShell->GetWrtShell()->getIDocumentMarkAccess()->getFieldmarkFor(aPos);
}
if (pFieldBM && pFieldBM->GetFieldname() == ODF_FORMDROPDOWN)
diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx
index 12a2f35b583a..4351f6f6acbb 100644
--- a/sw/source/uibase/wrtsh/delete.cxx
+++ b/sw/source/uibase/wrtsh/delete.cxx
@@ -242,8 +242,7 @@ bool SwWrtShell::DelLeft()
{
// If we are just to the right to a fieldmark, then remove it completely
const SwPosition* pCurPos = GetCursor()->GetPoint();
- SwPosition aPrevChar(*pCurPos);
- --aPrevChar.nContent;
+ SwPosition aPrevChar(*pCurPos->GetContentNode(), pCurPos->GetContentIndex() - 1);
sw::mark::IFieldmark* pFm = getIDocumentMarkAccess()->getFieldmarkAt(aPrevChar);
if (pFm && pFm->GetMarkEnd() == *pCurPos)
{