22#include <libxml/xmlwriter.h>
26#include <osl/diagnose.h>
27#include <rtl/ustrbuf.hxx>
32#include <UndoManager.hxx>
59 for(
size_t n = 0;
n < rSpzArr.
size(); ++
n )
63 if (pAnchor->
GetAnchorId() == RndStdIds::FLY_AT_CHAR)
66 if( pAnchorNode && nMovedIndex == pAnchorNode->
GetIndex() )
79 for (
size_t i = 0;
i < rRedlineSaveData.
size(); ++
i)
81 auto const& rRedline(rRedlineSaveData[
i]);
86 && rRedline.GetType() == RedlineType::Delete)
88 nEndOfRedline = rRedline.m_nEndNode;
89 o_rpFirstMergedDeletedTextNode = rDoc.
GetNodes()[rRedline.m_nSttNode]->GetTextNode();
96 assert(o_rpFirstMergedDeletedTextNode);
124 SwTextNode * pFirstMergedDeletedTextNode(
nullptr);
126 rRedlineSaveData, pFirstMergedDeletedTextNode);
130 std::vector<SwTextFrame*> frames;
134 if (pFrame->getRootFrame()->HasMergedParas())
136 assert(pFrame->GetMergedPara());
137 assert(pFrame->GetMergedPara()->pFirstNode == pFirstMergedDeletedTextNode);
138 assert(pNextNode->
GetIndex() <= pFrame->GetMergedPara()->pLastNode->GetIndex());
139 frames.push_back(pFrame);
147 pFrame->RegisterToNode(*pNextNode,
true);
180 bool bCalledByTableCpy )
190 m_bJoinNext( false ),
191 m_bTableDelLastNd( false ),
193 m_bDelFullPara( bFullPara ),
194 m_bResetPgDesc( false ),
195 m_bResetPgBrk( false ),
196 m_bFromTableCopy( bCalledByTableCpy )
197 , m_DeleteFlags(flags)
218 auto [pStt, pEnd] = rPam.
StartEnd();
223 OSL_ENSURE( rPam.
HasMark(),
"PaM without Mark" );
251 SwTextNode *pSttTextNd =
nullptr, *pEndTextNd =
nullptr;
264 bool bMoveNds = *pStt != *pEnd
267 if( pSttTextNd && pEndTextNd && pSttTextNd != pEndTextNd )
278 if( pEndTextNd->HasSwAttrSet() )
281 if( SfxItemState::SET == pEndTextNd->GetpSwAttrSet()->GetItemState(
284 if( pEndTextNd->HasSwAttrSet() &&
285 SfxItemState::SET == pEndTextNd->GetpSwAttrSet()->GetItemState(
293 if( pEnd == rPam.
GetPoint() && ( !bFullPara || pSttTextNd || pEndTextNd ) )
296 if( !pSttTextNd && !pEndTextNd )
310 if( !bFullPara && !pEndTextNd &&
324 ( (pTmpNd = rDocNds[ aRg.
aEnd.
GetIndex()+1 ])->IsEndNode() &&
354 ( (pTmpNd = rDocNds[ aRg.
aStart.
GetIndex()-1 ])->IsSectionNode() &&
382 else if (pSttTextNd && (pEndTextNd || pSttTextNd->
GetText().getLength()))
392 if( pSttTextNd && pEndTextNd )
422 if( !pSttTextNd && !pEndTextNd )
452 0, pSttTextNd->
GetText().getLength(),
true );
457 sal_Int32 nLen = (bOneNode
459 : pSttTextNd->
GetText().getLength())
470 bool emptied( !
m_aSttStr->isEmpty() && !pSttTextNd->
Len() );
471 if (!bOneNode || emptied)
474 ? pSttTextNd->CreateUndoForDelete()
475 : pSttTextNd->CreateUndo();
492 pEndTextNd->
GetText().getLength(),
true );
505 bool emptied = !
m_aEndStr->isEmpty() && !pEndTextNd->
Len();
508 ? pEndTextNd->CreateUndoForDelete()
509 : pEndTextNd->CreateUndo();
529 auto [pStt, pEnd] = rDelPam.
StartEnd();
531 if( pStt->GetNode() != pEnd->GetNode() ||
532 pStt->GetContentIndex()+1 != pEnd->GetContentIndex() ||
553 if( !pDelTextNd )
return false;
573 const bool bSaved =
FillSaveData( rDelPam, aTmpSav,
false );
617 for ( sal_uInt16
n = 0;
n < rHistory.
Count();
n++)
619 OUString aDescr = rHistory[
n]->GetDescription();
621 if (!aDescr.isEmpty())
661static OUString
lcl_DenotedPortion(std::u16string_view rStr, sal_Int32 nStart, sal_Int32 nEnd,
bool bQuoted)
665 auto nCount = nEnd - nStart;
696 assert(!
"unexpected special character");
701 aResult = aRewriter.
Apply(aResult);
705 aResult =
SwResId(STR_START_QUOTE) +
706 rStr.substr(nStart,
nCount) +
710 aResult = rStr.substr(nStart,
nCount);
718 OUStringBuffer aResult;
723 sal_Int32 nStart = 0;
726 for(
size_t i = 0;
i <
aStr.size();
i++)
730 if (cLast !=
aStr[
i])
756 return aResult.makeStringAndClear();
773 OUString sTmp = aRewriter.
Apply(
SwResId(STR_TABLE_NAME));
790 std::optional<OUString> aTmpStr;
822 if( rSpzArr.
empty() )
827 for(
size_t n = 0;
n < rSpzArr.
size(); ++
n )
829 pFormat = rSpzArr[
n];
831 if (pAnchor->
GetAnchorId() == RndStdIds::FLY_AT_PARA)
834 if( pAnchorNode && nOldIdx == pAnchorNode->
GetIndex() )
855 SwNode* pMovedNode =
nullptr;
921 assert(ins.getLength() ==
m_aEndStr->getLength());
927 else if (
m_aSttStr && bNodeMove && pInsNd ==
nullptr)
932 if (m_nSttContent < pNd->GetText().getLength())
986 aPos.
Assign( aCopyIndex );
1004 if (pTextNd !=
nullptr)
1019 assert(ins.getLength() ==
m_aSttStr->getLength());
1032 if( m_nSetPos < m_pHistory->
Count() )
1055 static_cast<SwContentNode*
>(pNode)->ResetAttr( nStt, nEnd );
1063 assert(&aIdx.
GetNode() == pInsNd);
1072 SwTextNode * pFirstMergedDeletedTextNode(
nullptr);
1077 bool bNonMerged(
false);
1078 std::vector<SwTextFrame*> frames;
1082 if (pFrame->getRootFrame()->HasMergedParas())
1084 frames.push_back(pFrame);
1099 pFrame->RegisterToNode(*pFirstMergedDeletedTextNode);
1100 assert(pFrame->GetMergedPara());
1101 assert(!bNonMerged);
1103 delFullParaEndNode = pFirstMergedDeletedTextNode->
GetIndex();
1140 ? delFullParaEndNode
1155 assert(&aIdx.
GetNode() == pInsNd);
1156 SwPaM tmp(aIdx, aIdx);
1171 OSL_ENSURE(bSuccess,
1172 "SwUndoDelete::Redo: used to have redline data, but now none?");
1197 OSL_ENSURE( rPam.
HasMark(),
"PaM without Mark" );
1217 OSL_ENSURE( rPam.
HasMark(),
"PaM without Mark" );
1294 assert(!
"dead code");
1336 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwUndoDelete"));
1337 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
1340 (void)xmlTextWriterEndElement(pWriter);
struct _xmlTextWriter * xmlTextWriterPtr
@ ArtificialSelection
keyboard delete, artificial selection, avoid deleting flys
OUString ShortenString(const OUString &rStr, sal_Int32 nLength, std::u16string_view aFillStr)
Shortens a string to a maximum length.
const int nUndoStringLength
bool isLetterNumeric(const OUString &rStr, sal_Int32 nPos) const
virtual bool DeleteAndJoin(SwPaM &, SwDeleteFlags flags=SwDeleteFlags::Default)=0
complete delete of a given PaM
virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart)=0
Split a node at rPos (implemented only for TextNode).
virtual bool DelFullPara(SwPaM &)=0
Delete full paragraphs.
virtual bool IsIgnoreRedline() const =0
virtual bool DeleteRedline(const SwPaM &rPam, bool bSaveInUndo, RedlineType nDelType)=0
virtual const SwRedlineTable & GetRedlineTable() const =0
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Marks a character position inside a document model content node (SwContentNode)
bool HasSwAttrSet() const
virtual bool SetAttr(const SfxPoolItem &)
made virtual
const SwAttrSet * GetpSwAttrSet() const
IDocumentContentOperations const & getIDocumentContentOperations() const
IDocumentUndoRedo & GetIDocumentUndoRedo()
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
const SwTextFormatColl * GetDfltTextFormatColl() const
const SwFrameFormats * GetSpzFrameFormats() const
::sw::UndoManager & GetUndoManager()
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
void Move(sal_uInt16 nPos, SwHistory *pIns, sal_uInt16 const nStart=0)
Marks a node in the document model.
const SwNodes & GetNodes() const
SwNodeOffset GetIndex() const
Base class of the Writer document model elements.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwNodeOffset GetIndex() const
bool IsContentNode() const
bool IsSectionNode() const
const SwStartNode * StartOfSectionNode() const
SwNodeOffset EndOfSectionIndex() const
SwContentNode * GetContentNode()
SwTableNode * GetTableNode()
const SwEndNode * EndOfSectionNode() const
SwTextNode * MakeTextNode(SwNode &rWhere, SwTextFormatColl *pColl, bool bNewFrames=true)
Implementations of "Make...Node" are in the given .cxx-files.
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
bool MoveNodes(const SwNodeRange &, SwNodes &rNodes, SwNode &rPos, bool bNewFrames=true)
move the node pointer
void Delete(const SwNodeIndex &rPos, SwNodeOffset nNodes=SwNodeOffset(1))
void Copy_(const SwNodeRange &rRg, SwNode &rInsPos, bool bNewFrames=true) const
SwNodeOffset Count() const
PaM is Point and Mark: a selection of the document model.
const SwPosition * GetMark() const
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
std::pair< const SwPosition *, const SwPosition * > StartEnd() const
Because sometimes the cost of the operator<= can add up.
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
const SwPosition * End() const
const SwPosition * GetPoint() const
const SwPosition * Start() const
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
void AddRule(SwUndoArg eWhat, const OUString &rWith)
static OUString GetPlaceHolder(SwUndoArg eId)
OUString Apply(const OUString &rStr) const
const SwTable & GetTable() const
void DelFrames(SwRootFrame const *pLayout=nullptr)
Method deletes all views of document for the node.
SwTableFormat * GetFrameFormat()
Represents the visualization of a paragraph.
SwTextNode is a paragraph in the document model.
virtual sal_Int32 Len() const override
void ClearSwpHintsArr(bool bDelFields)
void EraseText(const SwContentIndex &rIdx, const sal_Int32 nCount=SAL_MAX_INT32, const SwInsertFlags nMode=SwInsertFlags::DEFAULT)
delete text content ATTENTION: must not be called with a range that overlaps the start of an attribut...
OUString InsertText(const OUString &rStr, const SwContentIndex &rIdx, const SwInsertFlags nMode=SwInsertFlags::DEFAULT)
insert text content
SwpHints * GetpSwpHints()
const OUString & GetText() const
SwTextFormatColl * GetTextColl() const
virtual sal_uInt16 ResetAllAttr() override
void SetInSwUndo(bool bInUndo)
SwPaM & AddUndoRedoPaM(::sw::UndoRedoContext &, bool const bCorrToContent=false) const
void SetPaM(SwPaM &, bool bCorrToContent=false) const
SwDeleteFlags m_DeleteFlags
virtual void RedoImpl(::sw::UndoRedoContext &) override
void dumpAsXml(xmlTextWriterPtr pWriter) const override
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd
bool SaveContent(const SwPosition *pStt, const SwPosition *pEnd, SwTextNode *pSttTextNd, SwTextNode *pEndTextNd)
virtual void RepeatImpl(::sw::RepeatContext &) override
std::optional< SwNodeIndex > m_oMvStt
std::unique_ptr< SwRedlineSaveDatas > m_pRedlSaveData
virtual SwRewriter GetRewriter() const override
Returns rewriter for this undo object.
virtual ~SwUndoDelete() override
SwUndoDelete(SwPaM &, SwDeleteFlags flags, bool bFullPara=false, bool bCalledByTableCpy=false)
virtual void UndoImpl(::sw::UndoRedoContext &) override
std::optional< OUString > m_aEndStr
SwNodeOffset m_nReplaceDummy
void SetTableName(const OUString &rName)
std::optional< OUString > m_aSttStr
bool CanGrouping(SwDoc &, const SwPaM &)
void DelContentIndex(const SwPosition &pMark, const SwPosition &pPoint, DelContentType nDelContentType=DelContentType::AllMask)
std::unique_ptr< SwHistory > m_pHistory
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
static bool FillSaveData(const SwPaM &rRange, SwRedlineSaveDatas &rSData, bool bDelRange=true, bool bCopyNext=true)
static void SetSaveData(SwDoc &rDoc, SwRedlineSaveDatas &rSData)
static bool CanRedlineGroup(SwRedlineSaveDatas &rCurr, const SwRedlineSaveDatas &rCheck, bool bCurrIsEnd)
void DeRegister()
deregister the currently registered History
Blocks grouping undo actions together into an SfxListUndoAction.
SwNodes const & GetUndoNodes() const
void DelBookmarks(SwNode &rStt, const SwNode &rEnd, std::vector< SaveBookmark > *pSaveBkmk, std::optional< sal_Int32 > oStartContentIdx, std::optional< sal_Int32 > oEndContentIdx)
void PaMCorrAbs(const SwPaM &rRange, const SwPosition &rNewPos)
Function declarations so that everything below the CursorShell can move the Cursor once in a while.
#define CH_TXT_ATR_FIELDSEP
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
#define CH_TXT_ATR_INPUTFIELDSTART
#define CH_TXT_ATR_FORMELEMENT
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
#define CH_TXT_ATR_INPUTFIELDEND
#define CH_TXT_ATR_FIELDEND
#define CH_TXTATR_NEWLINE
#define CH_TXT_ATR_FIELDSTART
#define CH_TXTATR_BREAKWORD
CharClass & GetAppCharClass()
void RecreateStartTextFrames(SwTextNode &rNode)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
bool GoInContent(SwPaM &rPam, SwMoveFnCollection const &fnMove)
SwMoveFnCollection const & fnMoveBackward
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
@ RES_POOLCOLL_STANDARD
Standard.
Marks a position in the document model.
void Adjust(SwNodeOffset nDelta)
Adjust node position, and resets content position to zero.
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
void SetContent(sal_Int32 nContentIndex)
Set content index, only valid to call this if the position points to a SwContentNode subclass.
SwNodeOffset GetNodeIndex() const
sal_Int32 GetContentIndex() const
OUString SwResId(TranslateId aId)
static SwRewriter lcl_RewriterFromHistory(SwHistory &rHistory)
static OUString lcl_DenotedPortion(std::u16string_view rStr, sal_Int32 nStart, sal_Int32 nEnd, bool bQuoted)
static void lcl_ReAnchorAtContentFlyFrames(const SwFrameFormats &rSpzArr, const SwPosition &rPos, SwNodeOffset nOldIdx)
static void DelFullParaMoveFrames(SwDoc &rDoc, SwUndRng const &rRange, SwRedlineSaveDatas const &rRedlineSaveData)
static SwTextNode * FindFirstAndNextNode(SwDoc &rDoc, SwUndRng const &rRange, SwRedlineSaveDatas const &rRedlineSaveData, SwTextNode *&o_rpFirstMergedDeletedTextNode)
OUString DenoteSpecialCharacters(std::u16string_view aStr, bool bQuoted)
Denotes special characters in a string.
static bool lcl_IsSpecialCharacter(sal_Unicode nChar)
static void lcl_MakeAutoFrames(const SwFrameFormats &rSpzArr, SwNodeOffset nMovedIndex)
bool IsFlySelectedByCursor(SwDoc const &rDoc, SwPosition const &rStart, SwPosition const &rEnd)
check at-char and at-para flys in rDoc