22 #include <libxml/xmlwriter.h>
26 #include <osl/diagnose.h>
27 #include <rtl/ustrbuf.hxx>
32 #include <UndoManager.hxx>
47 #include <strings.hrc>
59 for(
size_t n = 0;
n < rSpzArr.
size(); ++
n )
63 if (pAnchor->
GetAnchorId() == RndStdIds::FLY_AT_CHAR)
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);
101 assert(!pNode->IsEndNode());
102 if (pNode->IsStartNode())
104 i = pNode->EndOfSectionIndex();
106 else if (pNode->IsTextNode())
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);
179 bool bCalledByTableCpy )
189 m_bJoinNext(
false ),
190 m_bTableDelLastNd(
false ),
192 m_bDelFullPara( bFullPara ),
193 m_bResetPgDesc(
false ),
194 m_bResetPgBrk(
false ),
195 m_bFromTableCopy( bCalledByTableCpy )
221 OSL_ENSURE( rPam.
HasMark(),
"PaM without Mark" );
247 SwTextNode *pSttTextNd =
nullptr, *pEndTextNd =
nullptr;
260 bool bMoveNds = *pStt != *pEnd
263 if( pSttTextNd && pEndTextNd && pSttTextNd != pEndTextNd )
274 if( pEndTextNd->HasSwAttrSet() )
277 if( SfxItemState::SET == pEndTextNd->GetpSwAttrSet()->GetItemState(
280 if( pEndTextNd->HasSwAttrSet() &&
281 SfxItemState::SET == pEndTextNd->GetpSwAttrSet()->GetItemState(
289 if( pEnd == rPam.
GetPoint() && ( !bFullPara || pSttTextNd || pEndTextNd ) )
292 if( !pSttTextNd && !pEndTextNd )
307 if( !bFullPara && !pEndTextNd &&
321 ( (pTmpNd = rDocNds[ aRg.
aEnd.
GetIndex()+1 ])->IsEndNode() &&
351 ( (pTmpNd = rDocNds[ aRg.
aStart.
GetIndex()-1 ])->IsSectionNode() &&
379 else if (pSttTextNd && (pEndTextNd || pSttTextNd->
GetText().getLength()))
389 if( pSttTextNd && pEndTextNd )
419 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)
492 pEndTextNd->
GetText().getLength(), true );
505 bool emptied = !
m_aEndStr->isEmpty() && !pEndTextNd->
Len();
530 *pEnd = rDelPam.
End();
532 if( pStt->
nNode != pEnd->nNode ||
554 if( !pDelTextNd )
return false;
574 const bool bSaved =
FillSaveData( rDelPam, aTmpSav,
false );
618 for ( sal_uInt16
n = 0;
n < rHistory.
Count();
n++)
620 OUString aDescr = rHistory[
n]->GetDescription();
622 if (!aDescr.isEmpty())
662 static OUString
lcl_DenotedPortion(std::u16string_view rStr, sal_Int32 nStart, sal_Int32 nEnd,
bool bQuoted)
666 auto nCount = nEnd - nStart;
697 assert(!
"unexpected special character");
702 aResult = aRewriter.
Apply(aResult);
706 aResult =
SwResId(STR_START_QUOTE) +
707 rStr.substr(nStart,
nCount) +
711 aResult = rStr.substr(nStart,
nCount);
719 OUStringBuffer aResult;
724 sal_Int32 nStart = 0;
727 for( sal_Int32
i = 0;
i < rStr.getLength();
i++)
731 if (cLast != rStr[i])
757 return aResult.makeStringAndClear();
774 OUString sTmp = aRewriter.
Apply(
SwResId(STR_TABLE_NAME));
787 aStr =
SwResId(STR_PARAGRAPH_UNDO);
791 std::optional<OUString> aTmpStr;
811 aStr = aRewriter.
Apply(aStr);
823 if( rSpzArr.
empty() )
829 for(
size_t n = 0;
n < rSpzArr.
size(); ++
n )
831 pFormat = rSpzArr[
n];
833 if (pAnchor->
GetAnchorId() == RndStdIds::FLY_AT_PARA)
856 SwNode* pInsNd = &aIdx.GetNode();
857 SwNode* pMovedNode =
nullptr;
864 if( pInsNd->IsTableNode() )
874 if( pInsNd->IsContentNode() )
923 assert(ins.getLength() ==
m_aEndStr->getLength());
929 else if (
m_aSttStr && bNodeMove && pInsNd ==
nullptr)
934 if (m_nSttContent < pNd->GetText().
getLength())
1006 if (pTextNd !=
nullptr)
1008 if( pTextNd->HasSwAttrSet() && bNodeMove && !
m_aEndStr )
1011 if( pTextNd->GetpSwpHints() )
1012 pTextNd->ClearSwpHintsArr(
true );
1017 pTextNd->SetInSwUndo(
true);
1020 pTextNd->SetInSwUndo(
false);
1021 assert(ins.getLength() ==
m_aSttStr->getLength());
1034 if( m_nSetPos < m_pHistory->
Count() )
1057 static_cast<SwContentNode*>(pNode)->ResetAttr( nStt, nEnd );
1059 static_cast<SwTableNode*>(pNode)->GetTable().GetFrameFormat()->ResetFormatAttr( nStt, nEnd );
1065 assert(&aIdx.GetNode() == pInsNd);
1074 SwTextNode * pFirstMergedDeletedTextNode(
nullptr);
1079 bool bNonMerged(
false);
1080 std::vector<SwTextFrame*> frames;
1084 if (pFrame->getRootFrame()->HasMergedParas())
1086 frames.push_back(pFrame);
1101 pFrame->RegisterToNode(*pFirstMergedDeletedTextNode);
1102 assert(pFrame->GetMergedPara());
1103 assert(!bNonMerged);
1105 delFullParaEndNode = pFirstMergedDeletedTextNode->
GetIndex();
1142 ? delFullParaEndNode
1157 assert(&aIdx.GetNode() == pInsNd);
1158 SwPaM tmp(aIdx, aIdx);
1173 OSL_ENSURE(bSuccess,
1174 "SwUndoDelete::Redo: used to have redline data, but now none?");
1199 OSL_ENSURE( rPam.
HasMark(),
"PaM without Mark" );
1215 OSL_ENSURE( rPam.
HasMark(),
"PaM without Mark" );
1287 assert(!
"dead code");
1328 (
void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwUndoDelete"));
1329 (
void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
1332 (
void)xmlTextWriterEndElement(pWriter);
const SwEndNode * EndOfSectionNode() const
SwPaM & AddUndoRedoPaM(::sw::UndoRedoContext &, bool const bCorrToContent=false) const
Represents the visualization of a paragraph.
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
SwNode & GetNode(bool bPoint=true) const
bool GoInContent(SwPaM &rPam, SwMoveFnCollection const &fnMove)
SwNodeOffset EndOfSectionIndex() const
static OUString GetPlaceHolder(SwUndoArg eId)
Marks a position in the document model.
void DelBookmarks(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, std::vector< SaveBookmark > *pSaveBkmk, const SwIndex *pSttIdx, const SwIndex *pEndIdx)
bool IsSectionNode() const
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
std::unique_ptr< SwHistory > m_pHistory
SwNodes const & GetUndoNodes() const
virtual void RedoImpl(::sw::UndoRedoContext &) override
void DelFrames(SwRootFrame const *pLayout=nullptr)
Method deletes all views of document for the node.
const OUString & GetText() const
virtual sal_uInt16 ResetAllAttr() override
SwpHints * GetpSwpHints()
std::unique_ptr< SwNodeIndex > m_pMvStt
virtual sal_Int32 Len() const override
const SwPosition * GetMark() const
void dumpAsXml(xmlTextWriterPtr pWriter) const override
bool SaveContent(const SwPosition *pStt, const SwPosition *pEnd, SwTextNode *pSttTextNd, SwTextNode *pEndTextNd)
static void lcl_MakeAutoFrames(const SwFrameFormats &rSpzArr, SwNodeOffset nMovedIndex)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
#define CH_TXTATR_NEWLINE
IDocumentUndoRedo & GetIDocumentUndoRedo()
std::optional< OUString > m_aEndStr
IDocumentContentOperations const & getIDocumentContentOperations() const
#define CH_TXT_ATR_FORMELEMENT
void Copy_(const SwNodeRange &rRg, const SwNodeIndex &rInsPos, bool bNewFrames=true) const
SwTableFormat * GetFrameFormat()
const SwFrameFormats * GetSpzFrameFormats() const
static SwTextNode * FindFirstAndNextNode(SwDoc &rDoc, SwUndRng const &rRange, SwRedlineSaveDatas const &rRedlineSaveData, SwTextNode *&o_rpFirstMergedDeletedTextNode)
virtual SwRewriter GetRewriter() const override
Returns rewriter for this undo object.
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
OUString SwResId(TranslateId aId)
#define CH_TXTATR_BREAKWORD
bool isLetterNumeric(const OUString &rStr, sal_Int32 nPos) const
SwTableNode * GetTableNode()
SwUndoDelete(SwPaM &, bool bFullPara=false, bool bCalledByTableCpy=false)
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
const SwTextFormatColl * GetDfltTextFormatColl() const
#define CH_TXT_ATR_INPUTFIELDSTART
const SwTable & GetTable() const
static bool CanRedlineGroup(SwRedlineSaveDatas &rCurr, const SwRedlineSaveDatas &rCheck, bool bCurrIsEnd)
SwNodeOffset GetIndex() const
virtual ~SwUndoDelete() override
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
virtual void RepeatImpl(::sw::RepeatContext &) override
void SetTableName(const OUString &rName)
bool IsContentNode() const
PaM is Point and Mark: a selection of the document model.
const SwAttrSet * GetpSwAttrSet() const
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
::sw::UndoManager & GetUndoManager()
void DeRegister()
deregister the currently registered History
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
const SwStartNode * StartOfSectionNode() const
const SwPosition * GetPoint() const
void DelContentIndex(const SwPosition &pMark, const SwPosition &pPoint, DelContentType nDelContentType=DelContentType::AllMask)
SwIndex & Assign(SwIndexReg *, sal_Int32)
OUString Apply(const OUString &rStr) const
static void SetSaveData(SwDoc &rDoc, SwRedlineSaveDatas &rSData)
static SwRewriter lcl_RewriterFromHistory(SwHistory &rHistory)
virtual bool DeleteRedline(const SwPaM &rPam, bool bSaveInUndo, RedlineType nDelType)=0
SwNodeOffset GetIndex() const
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
static void lcl_ReAnchorAtContentFlyFrames(const SwFrameFormats &rSpzArr, const SwPosition &rPos, SwNodeOffset nOldIdx)
static void DelFullParaMoveFrames(SwDoc &rDoc, SwUndRng const &rRange, SwRedlineSaveDatas const &rRedlineSaveData)
Marks a character position inside a document model node.
#define CH_TXT_ATR_FIELDSTART
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Marks a node in the document model.
bool HasSwAttrSet() const
enumrange< T >::Iterator end(enumrange< T >)
const SwPosition * Start() const
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
virtual bool IsIgnoreRedline() const =0
static OUString lcl_DenotedPortion(std::u16string_view rStr, sal_Int32 nStart, sal_Int32 nEnd, bool bQuoted)
void EraseText(const SwIndex &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 SwIndex &rIdx, const SwInsertFlags nMode=SwInsertFlags::DEFAULT)
insert text content
void ClearSwpHintsArr(bool bDelFields)
SwTextNode is a paragraph in the document model.
#define CH_TXT_ATR_INPUTFIELDEND
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
virtual bool SetAttr(const SfxPoolItem &)
made virtual
void SetPaM(SwPaM &, bool bCorrToContent=false) const
void RecreateStartTextFrames(SwTextNode &rNode)
OUString ShortenString(const OUString &rStr, sal_Int32 nLength, const OUString &rFillStr)
Shortens a string to a maximum length.
Blocks grouping undo actions together into an SfxListUndoAction.
bool CanGrouping(SwDoc &, const SwPaM &)
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
virtual bool DelFullPara(SwPaM &)=0
Delete full paragraphs.
sal_Int32 GetIndex() const
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
const SwPosition * End() const
void PaMCorrAbs(const SwPaM &rRange, const SwPosition &rNewPos)
Function declarations so that everything below the CursorShell can move the Cursor once in a while...
void Delete(const SwNodeIndex &rPos, SwNodeOffset nNodes=SwNodeOffset(1))
delete nodes
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
double getLength(const B2DPolygon &rCandidate)
static bool lcl_IsSpecialCharacter(sal_Unicode nChar)
#define CH_TXT_ATR_FIELDEND
SwMoveFnCollection const & fnMoveBackward
SwNodeOffset Count() const
virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart)=0
Split a node at rPos (implemented only for TextNode).
SwNodeOffset m_nReplaceDummy
struct _xmlTextWriter * xmlTextWriterPtr
bool IsFlySelectedByCursor(SwDoc const &rDoc, SwPosition const &rStart, SwPosition const &rEnd)
check at-char and at-para flys in rDoc
std::unique_ptr< SwRedlineSaveDatas > m_pRedlSaveData
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
static bool FillSaveData(const SwPaM &rRange, SwRedlineSaveDatas &rSData, bool bDelRange=true, bool bCopyNext=true)
OUString DenoteSpecialCharacters(const OUString &rStr, bool bQuoted)
Denotes special characters in a string.
virtual const SwRedlineTable & GetRedlineTable() const =0
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart
#define CH_TXT_ATR_FIELDSEP
virtual bool DeleteAndJoin(SwPaM &)=0
complete delete of a given PaM
std::optional< OUString > m_aSttStr
CharClass & GetAppCharClass()
void Move(sal_uInt16 nPos, SwHistory *pIns, sal_uInt16 const nStart=0)
virtual void UndoImpl(::sw::UndoRedoContext &) override
const int nUndoStringLength
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwTextNode * MakeTextNode(const SwNodeIndex &rWhere, SwTextFormatColl *pColl, bool bNewFrames=true)
Implementations of "Make...Node" are in the given .cxx-files.
bool MoveNodes(const SwNodeRange &, SwNodes &rNodes, const SwNodeIndex &, bool bNewFrames=true)
move the node pointer
bool m_bDetectedRangeSegmentation false
Base class of the Writer document model elements.
SwTextFormatColl * GetTextColl() const