SvxFirstLineIndentItem firstLine(aAttrSet.Get(RES_MARGIN_FIRSTLINE));
SvxTextLeftMarginItem leftMargin(aAttrSet.Get(RES_MARGIN_TEXTLEFT)); short aOldFirstLineOfst = firstLine.ResolveTextFirstLineOffset({});
if (aOldFirstLineOfst > 0)
{
firstLine.SetTextFirstLineOffset(SvxIndentValue::zero());
bResult = true;
} elseif (aOldFirstLineOfst < 0)
{ // this used to call SetLeft() but this should be the same result
firstLine.SetTextFirstLineOffset(SvxIndentValue::zero());
leftMargin.SetTextLeft(
SvxIndentValue::twips(leftMargin.ResolveTextLeft({}) + aOldFirstLineOfst));
bResult = true;
} elseif (leftMargin.GetTextLeft().m_dValue != 0.0)
{
leftMargin.SetTextLeft(SvxIndentValue::zero());
bResult = true;
}
if (bResult)
{
aAttrSet.Put(firstLine);
aAttrSet.Put(leftMargin);
SetAttrSet(aAttrSet);
}
return bResult;
}
/** Description: Erase the line. */
void SwWrtShell::DelLine()
{
SwActContext aActContext(this);
ResetCursorStack(); // remember the old cursor
Push();
ClearMark();
SwCursorShell::LeftMargin();
SetMark();
SwCursorShell::RightMargin();
// #i4032# Don't actually call a 'delete' if we // changed the table cell, compare DelRight(). const SwStartNode * pSNdOld = pWasInTableNd ?
GetCursor()->GetPointNode().FindTableBoxStartNode() :
nullptr;
// If the cursor is at the beginning of a paragraph, try to step // backwards. On failure we are done. bool bDoSomething = SwCursorShell::Left(1,SwCursorSkipMode::Chars);
if (bDoSomething)
{ // If the cursor entered or left a table (or both) we are done. const SwTableNode* pIsInTableNd = SwCursorShell::IsCursorInTable();
bDoSomething = pIsInTableNd == pWasInTableNd;
OpenMark();
SwCursorShell::Right(1,SwCursorSkipMode::Chars);
SwCursorShell::SwapPam();
bSwap = true;
} else
{ // If we are just to the right to a fieldmark, then remove it completely const SwPosition* pCurPos = GetCursor()->GetPoint();
SwPosition aPrevChar(*pCurPos->GetContentNode(), pCurPos->GetContentIndex() - 1);
sw::mark::Fieldmark* pFm = getIDocumentMarkAccess()->getFieldmarkAt(aPrevChar); if (pFm && pFm->GetMarkEnd() == *pCurPos)
{
mxDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr);
IDocumentMarkAccess::DeleteFieldmarkCommand(*pFm);
getIDocumentMarkAccess()->deleteMark(pFm);
mxDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::EMPTY, nullptr); returntrue;
}
// If we are deleting a variation selector, we want to delete the // whole sequence.
sal_uInt32 nCode = GetChar(false); if ( rtl::isSurrogate( nCode ) )
{
OUString sStr = GetSelText();
nCode = sStr.iterateCodePoints( &o3tl::temporary(sal_Int32(0)) );
}
bool SwWrtShell::DelRight(boolconst isReplaceHeuristic)
{ // Will be or'ed, if a tableselection exists; // will here be implemented on SelectionType::Table bool bRet = false;
SelectionType nSelection = GetSelectionType(); if(nSelection & SelectionType::TableCell)
nSelection = SelectionType::Table; if(nSelection & SelectionType::Text)
nSelection = SelectionType::Text;
switch( nSelection & ~SelectionType::Ornament & ~SelectionType::Media )
{ case SelectionType::PostIt: case SelectionType::Text: case SelectionType::Table: case SelectionType::NumberList: // If a selection exists, erase it. if( IsSelection() )
{ if( !IsBlockMode() || HasSelection() )
{ //OS: And once again Basic: SwActContext must be //leaved before EnterStdMode !
{
SwActContext aActContext(this);
ResetCursorStack(); Delete(isReplaceHeuristic);
UpdateAttr();
} if( IsBlockMode() )
{
NormalizePam();
ClearMark();
EnterBlockMode();
} else
EnterStdMode();
bRet = true; break;
} else
EnterStdMode();
}
if (SwCursorShell::IsEndPara())
{ // Start/EndAllAction to avoid cursor flickering
UnoActionContext c(GetDoc());
const SwTableNode* pWasInTableNd = IsCursorInTable(); // #108049# Save the startnode of the current cell const SwStartNode* pSNdOld = pWasInTableNd ?
GetCursor()->GetPointNode().FindTableBoxStartNode() : nullptr;
SwTextNode* pOldTextNode = GetCursor()->GetPointNode().GetTextNode(); bool bCheckDelFull = SelectionType::Text & nSelection && SwCursorShell::IsSttPara(); bool bDelFull = false; bool bDoNothing = false;
// #i41424# Introduced a couple of // Push()-Pop() pairs here. The reason for this is that a // Right()-Left() combination does not make sure, that // the cursor will be in its initial state, because there // may be a numbering in front of the next paragraph.
SwCursorShell::Push();
if (SwCursorShell::Right(1, SwCursorSkipMode::Chars))
{ const SwTableNode* pCurrTableNd = IsCursorInTable();
bDelFull = bCheckDelFull && pCurrTableNd && pCurrTableNd != pWasInTableNd; if (!bDelFull && (IsCursorInTable() || (pCurrTableNd != pWasInTableNd)))
{ // #108049# Save the startnode of the current cell. // May be different to pSNdOld as we have moved. const SwStartNode* pSNdNew = pCurrTableNd ?
GetCursor()->GetPointNode().FindTableBoxStartNode() : nullptr;
// tdf#115132 Only keep cursor position instead of deleting // if we have moved to a different cell
bDoNothing = pSNdOld != pSNdNew;
}
}
if (pOldTextNode && pNewTextNode && pNewTextNode != pOldTextNode)
{
SwRootFrame* pLayout = mxDoc->getIDocumentLayoutAccess().GetCurrentLayout(); if (pLayout)
{ auto pOldFrame = static_cast<SwTextFrame*>(pOldTextNode->getLayoutFrame(pLayout)); auto pNewFrame = static_cast<SwTextFrame*>(pNewTextNode->getLayoutFrame(pLayout)); if (pOldFrame && pNewFrame && pOldFrame->HasSplitFlyDrawObjs() && pNewFrame->HasSplitFlyDrawObjs())
{ // We have a selection where both the old and the new position is an anchor // for a potentially split fly. Don't allow join of the nodes in this case, // since the layout supports multiple anchors for one split fly, but it // doesn't support the usage of the same anchor for multiple split flys.
bDoNothing = true;
}
}
}
if (bDelFull || bDoNothing) break;
}
{ // If we are just ahead of a fieldmark, then remove it completely
sw::mark::Fieldmark *const pFm = getIDocumentMarkAccess()->getFieldmarkAt(*GetCursor()->GetPoint()); if (pFm && pFm->GetMarkStart() == *GetCursor()->GetPoint())
{
mxDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr);
IDocumentMarkAccess::DeleteFieldmarkCommand(*pFm);
getIDocumentMarkAccess()->deleteMark(pFm);
mxDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::EMPTY, nullptr);
bRet = true; break;
}
}
case SelectionType::Frame: case SelectionType::Graphic: case SelectionType::Ole: case SelectionType::DrawObject: case SelectionType::DrawObjectEditMode: case SelectionType::DbForm:
{ // Group deletion of the object and its comment together // (also as-character anchor conversion at track changes)
mxDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr);
// #108205# Remember object's position.
Point aTmpPt = GetObjRect().TopLeft();
// Remember the anchor of the selected object before deletion.
std::optional<SwPosition> oAnchor;
RndStdIds eAnchorId = RndStdIds::FLY_AT_PARA;
SwFlyFrame* pFly = GetSelectedFlyFrame();
SwFrameFormat* pFormat = nullptr; if (pFly)
{
pFormat = pFly->GetFormat(); if (pFormat)
{
eAnchorId = pFormat->GetAnchor().GetAnchorId(); // to-character anchor conversion at track changes if ( IsRedlineOn() && (eAnchorId != RndStdIds::FLY_AS_CHAR &&
eAnchorId != RndStdIds::FLY_AT_CHAR) )
{
SfxItemSetFixed<RES_ANCHOR, RES_ANCHOR> aSet(GetAttrPool());
GetFlyFrameAttr(aSet);
SwFormatAnchor aAnch(RndStdIds::FLY_AT_CHAR);
aSet.Put(aAnch);
SetFlyFrameAttr(aSet);
eAnchorId = pFormat->GetAnchor().GetAnchorId();
} if ((eAnchorId == RndStdIds::FLY_AS_CHAR || eAnchorId == RndStdIds::FLY_AT_CHAR)
&& pFormat->GetAnchor().GetAnchorNode())
{
oAnchor.emplace(*pFormat->GetAnchor().GetContentAnchor()); // set cursor before the anchor point if ( IsRedlineOn() )
*GetCurrentShellCursor().GetPoint() = *oAnchor;
}
}
}
// track changes: create redline at anchor point of the image to record the deletion if ( IsRedlineOn() && oAnchor && SelectionType::Graphic & nSelection && pFormat &&
( eAnchorId == RndStdIds::FLY_AT_CHAR || eAnchorId == RndStdIds::FLY_AS_CHAR ) )
{
sal_Int32 nRedlineLength = 1; // create a double CH_TXT_TRACKED_DUMMY_CHAR anchor point of the image to record the // deletion, if needed (otherwise use the existing anchor point of the image anchored // *as* character) if ( eAnchorId == RndStdIds::FLY_AT_CHAR )
{
nRedlineLength = 2;
LeaveSelFrameMode();
UnSelectFrame();
RedlineFlags eOld = GetRedlineFlags();
SetRedlineFlags( eOld | RedlineFlags::Ignore );
Insert( OUStringChar(CH_TXT_TRACKED_DUMMY_CHAR) +
OUStringChar(CH_TXT_TRACKED_DUMMY_CHAR) );
SwFormatAnchor anchor(RndStdIds::FLY_AT_CHAR);
SwCursorShell::Left(1, SwCursorSkipMode::Chars);
anchor.SetAnchor(GetCursor()->GetPoint());
GetDoc()->SetAttr(anchor, *pFormat);
SetRedlineFlags( eOld );
SwCursorShell::Left(1, SwCursorSkipMode::Chars);
}
OpenMark();
SwCursorShell::Right(nRedlineLength, SwCursorSkipMode::Chars);
bRet = Delete(false);
CloseMark( bRet );
} else
DelSelectedObj();
if (oAnchor)
{
SwTextNode* pTextNode = oAnchor->GetNode().GetTextNode(); if (pTextNode)
{ const SwTextField* pField(
pTextNode->GetFieldTextAttrAt(oAnchor->GetContentIndex(), ::sw::GetTextAttrMode::Default)); if (pField
&& dynamic_cast<const SwPostItField*>(pField->GetFormatField().GetField()))
{ // Remove the comment of the deleted object.
*GetCurrentShellCursor().GetPoint() = *oAnchor;
DelRight();
}
}
}
// All erase operations should work with Find instead with // Nxt-/PrvDelim, because the latter works with Wrap Around // -- that's probably not wished.
bool SwWrtShell::DelToEndOfSentence()
{ if(IsEndOfDoc()) returnfalse;
OpenMark(); bool bRet(false); // fdo#60967: special case that is documented in help: delete // paragraph following table if cursor is at end of last cell in table if (IsEndOfTable())
{
Push();
ClearMark(); if (SwCursorShell::Right(1,SwCursorSkipMode::Chars))
{
SetMark(); if (!IsEndPara()) // can only be at the end if it's empty
{ // for an empty paragraph this would actually select the _next_
SwCursorShell::MovePara(GoCurrPara, fnParaEnd);
} if (!IsEndOfDoc()) // do not delete last paragraph in body text
{
bRet = DelFullPara();
}
}
Pop(SwCursorShell::PopMode::DeleteCurrent);
} else
{
bRet = FwdSentence_() && Delete(false);
}
CloseMark( bRet ); return bRet;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.