26#include <osl/diagnose.h>
63 std::optional<OUString> aResult;
81 aResult = sText.copy(nStart,
nLength);
108 m_nNode( rNd.GetIndex() ), m_nContent(nCnt), m_nLen(nL),
109 m_bIsWordDelim( bWDelim ), m_bIsAppend( false )
111 , m_nInsertFlags(nInsertFlags)
118 m_nNode( rNd.GetIndex() ), m_nContent(0), m_nLen(1),
119 m_bIsWordDelim( false ), m_bIsAppend( true )
139 (*maUndoText) += OUStringChar(cIns);
163 if( !rTable.
empty() )
329 OSL_ENSURE( pTextNode,
"where is my textnode ?" );
333 assert(ins.getLength() ==
maText->getLength());
415 nullptr,
nullptr, nullptr );
435 static_cast<SwOLENode*
>(pCNd)->GetAspect() ),
449 std::optional<OUString>
aStr;
495 Impl(
SwPaM const& rPam, OUString aIns,
bool const bRegExp);
507 OUString
const& rIns,
bool const bRegExp)
529 OUString
const& sOld, OUString
const& sNew)
544 else if (1 == occurrences)
581 SwPaM const& rPam, OUString aIns,
bool const bRegExp)
582 : m_sIns(
std::move( aIns ))
587 auto [pStt, pEnd] = rPam.
StartEnd();
596 OSL_ENSURE( pNd,
"Dude, where's my TextNode?" );
609 pNd->
GetText().getLength(),
true );
621 pNext->
GetText().getLength(),
true );
636 : pEnd->GetContentIndex();
647 OSL_ENSURE( pNd,
"Dude, where's my TextNode?" );
652 if ((1 == m_sIns.getLength()) && (1 == m_sOld.getLength()))
655 pACEWord->
CheckChar( aPos, m_sOld[ 0 ] );
664 rPam.
GetPoint()->
Assign( m_nSttNd - m_nOffset, m_nSttNd == m_nEndNd ? m_nEndCnt : pNd->
Len());
668 assert(ret); (void)ret;
669 if (m_nSttNd != m_nEndNd)
676 pNd = pDoc->
GetNodes()[ m_nSttNd - m_nOffset ]->GetTextNode();
677 OSL_ENSURE( pNd,
"Dude, where's my TextNode?" );
682 assert(m_nSttCnt + m_sOld.getLength() <= pNd->
Len());
683 SwPosition aPos(*pNd, m_nSttCnt + m_sOld.getLength());
685 pNd->RestoreMetadata(m_pMetadataUndoEnd);
686 pNd = pDoc->
GetNodes()[ m_nSttNd - m_nOffset ]->GetTextNode();
688 pNd->RestoreMetadata(m_pMetadataUndoStart);
696 m_pHistory->TmpRollback( pDoc, m_nSetPos,
false );
700 if( m_nSetPos < m_pHistory->
Count() )
704 aHstr.
Move( 0, m_pHistory.get(), m_nSetPos );
705 m_pHistory->Rollback( pDoc );
706 m_pHistory->Move( 0, &aHstr );
710 m_pHistory->Rollback( pDoc );
733 auto xSave = std::make_unique<SwHistory>();
734 std::swap(m_pHistory, xSave);
737 m_nSetPos = m_pHistory->Count();
739 std::swap(xSave, m_pHistory);
740 m_pHistory->Move(0, xSave.get());
746 m_nSetPos = m_pHistory->Count();
783 std::optional<Graphic> oOldGrf(
moGraphic);
784 std::optional<OUString> aOldNm =
maNm;
795 pGrfNd->
ReRead( OUString(), OUString(), oOldGrf ? &*oOldGrf :
nullptr );
835 OUString aNumberSeparator,
837 const sal_uInt16 nInitId,
838 OUString aCharacterStyle,
839 const bool bCpyBorder,
842 m_sText(
std::move( aText )),
843 m_sSeparator(
std::move( aSeparator )),
844 m_sNumberSeparator(
std::move( aNumberSeparator )),
845 m_sCharacterStyle(
std::move( aCharacterStyle )),
846 m_nFieldId( nInitId ),
850 m_bCopyBorder( bCpyBorder )
853 OBJECT.pUndoFly =
nullptr;
854 OBJECT.pUndoAttr =
nullptr;
865 delete NODE.pUndoInsNd;
874 OSL_ENSURE(
OBJECT.pUndoAttr &&
OBJECT.pUndoFly,
"Pointer not initialized" );
882 OBJECT.pUndoAttr->UndoImpl(rContext);
883 OBJECT.pUndoFly->UndoImpl(rContext);
890 else if(
NODE.nNode )
895 rDoc.
GetNodes()[
NODE.nNode-1]->StartOfSectionIndex()]->GetTableNode();
913 OSL_ENSURE(
OBJECT.pUndoAttr &&
OBJECT.pUndoFly,
"Pointer not initialized" );
921 OBJECT.pUndoFly->RedoImpl(rContext);
922 OBJECT.pUndoAttr->RedoImpl(rContext);
934 else if(
NODE.pUndoInsNd )
939 rDoc.
GetNodes()[
NODE.nNode-1]->StartOfSectionIndex()]->GetTableNode();
943 NODE.pUndoInsNd->UndoImpl(rContext);
944 delete NODE.pUndoInsNd;
945 NODE.pUndoInsNd =
nullptr;
973 if( pCnt &&
nullptr != ( pFly = pCnt->
FindFlyFrame() ) )
OUString DenoteSpecialCharacters(std::u16string_view aStr, bool bQuoted=true)
Denotes special characters in a string.
OUString ShortenString(const OUString &rStr, sal_Int32 nLength, std::u16string_view aFillStr)
Shortens a string to a maximum length.
const int nUndoStringLength
virtual bool AppendTextNode(SwPosition &rPos)=0
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 SwFlyFrameFormat * InsertGraphic(const SwPaM &rRg, const OUString &rGrfName, const OUString &rFltName, const Graphic *pGraphic, const SfxItemSet *pFlyAttrSet, const SfxItemSet *pGrfAttrSet, SwFrameFormat *)=0
Insert graphic or formula.
virtual bool DelFullPara(SwPaM &)=0
Delete full paragraphs.
virtual bool ReplaceRange(SwPaM &rPam, const OUString &rNewStr, const bool bRegExReplace)=0
Replace selected range in a TextNode with string.
virtual SwFlyFrameFormat * InsertEmbObject(const SwPaM &rRg, const svt::EmbeddedObjectRef &xObj, SfxItemSet *pFlyAttrSet)=0
Insert OLE-objects.
virtual bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND)=0
Insert string into existing text node at position rRg.Point().
virtual SdrLayerID GetHellId() const =0
virtual SdrLayerID GetInvisibleHellId() const =0
virtual SdrLayerID GetHeavenId() const =0
virtual SdrLayerID GetInvisibleHeavenId() const =0
virtual const SwRootFrame * GetCurrentLayout() const =0
virtual bool IsRedlineOn() const =0
Query if redlining is on.
virtual bool DeleteRedline(const SwPaM &rPam, bool bSaveInUndo, RedlineType nDelType)=0
static bool IsRedlineOn(const RedlineFlags eM)
virtual std::size_t GetRedlineAuthor()=0
virtual bool SplitRedline(const SwPaM &rPam)=0
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
virtual const SwRedlineTable & GetRedlineTable() const =0
virtual AppendResult AppendRedline(SwRangeRedline *pNewRedl, bool bCallDelete)=0
Append a new redline.
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
virtual SdrLayerID GetLayer() const
virtual void SetLayer(SdrLayerID nLayer)
const SwMirrorGrf & GetMirrorGrf(bool=true) const
void CheckChar(const SwPosition &rPos, sal_Unicode cChar)
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
bool HasSwAttrSet() const
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
virtual bool SetAttr(const SfxPoolItem &)
made virtual
const SwAttrSet * GetpSwAttrSet() const
SwAutoCorrExceptWord * GetAutoCorrExceptWord()
SwFlyFrameFormat * InsertLabel(const SwLabelType eType, const OUString &rText, const OUString &rSeparator, const OUString &rNumberingSeparator, const bool bBefore, const sal_uInt16 nId, const SwNodeOffset nIdx, const OUString &rCharacterStyle, const bool bCpyBrd)
void UpdateRsid(const SwPaM &rRg, sal_Int32 nLen)
Set the rsid of the next nLen symbols of rRg to the current session number.
IDocumentContentOperations const & getIDocumentContentOperations() const
IDocumentUndoRedo & GetIDocumentUndoRedo()
void SetAutoCorrExceptWord(std::unique_ptr< SwAutoCorrExceptWord > pNew)
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
general base class for all free-flowing frames
virtual const SwFlyFrameFormat * GetFormat() const override
const SwNodeIndex * GetContentIdx() const
SwFlyFrame * FindFlyFrame()
const Graphic & GetGrf(bool bWait=false) const
bool GetFileFilterNms(OUString *pFileNm, OUString *pFilterNm) const
bool IsGrfLink() const
Query link-data.
bool ReRead(const OUString &rGrfName, const OUString &rFltName, const Graphic *pGraphic=nullptr, bool bModify=true)
Re-read in case graphic was not OK.
void Move(sal_uInt16 nPos, SwHistory *pIns, sal_uInt16 const nStart=0)
Marks a node in the document model.
SwNodeOffset GetIndex() const
Base class of the Writer document model elements.
SwFrameFormat * GetFlyFormat() const
If node is in a fly return the respective format.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwNodeOffset GetIndex() const
SwTableNode * FindTableNode()
Search table node, in which it is.
SwContentNode * GetContentNode()
SwNodeType GetNodeType() const
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
void Delete(const SwNodeIndex &rPos, SwNodeOffset nNodes=SwNodeOffset(1))
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
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.
SwContentNode * GetPointContentNode() const
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
const SwPosition * End() const
const SwPosition * GetPoint() const
void AddRule(SwUndoArg eWhat, const OUString &rWith)
const SwTable & GetTable() const
SwTableFormat * GetFrameFormat()
SwTextNode is a paragraph in the document model.
void DeleteAttributes(const sal_uInt16 nWhich, const sal_Int32 nStart, const sal_Int32 nEnd=0)
delete all attributes of type nWhich at nStart (opt. end nEnd)
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
struct SwUndoInsertLabel::@5::@8 NODE
OUString m_sNumberSeparator
virtual ~SwUndoInsertLabel() override
void SetFlys(SwFrameFormat &rOldFly, SfxItemSet const &rChgSet, SwFrameFormat &rNewFly)
virtual void RedoImpl(::sw::UndoRedoContext &) override
static SwRewriter CreateRewriter(const OUString &rStr)
virtual SwRewriter GetRewriter() const override
Returns the rewriter of this undo object.
virtual void UndoImpl(::sw::UndoRedoContext &) override
virtual void RepeatImpl(::sw::RepeatContext &) override
SwUndoInsertLabel(const SwLabelType eTyp, OUString rText, OUString aSeparator, OUString aNumberSeparator, const bool bBefore, const sal_uInt16 nId, OUString aCharacterStyle, const bool bCpyBrd, const SwDoc *pDoc)
void SetDrawObj(SdrLayerID nLayerId)
struct SwUndoInsertLabel::@5::@7 OBJECT
OUString m_sCharacterStyle
Typing one or more characters to a single paragraph.
std::optional< OUString > maText
const SwInsertFlags m_nInsertFlags
virtual void RedoImpl(::sw::UndoRedoContext &) override
virtual SwRewriter GetRewriter() const override
Returns rewriter for this undo object.
virtual ~SwUndoInsert() override
std::optional< OUString > maUndoText
std::optional< SwNodeIndex > m_oUndoNodeIndex
start of Content in UndoNodes for Redo
virtual void UndoImpl(::sw::UndoRedoContext &) override
virtual void RepeatImpl(::sw::RepeatContext &) override
bool IsIndependent(const SwUndoInsert &rOther) const
bool CanGrouping(sal_Unicode cIns)
void Init(const SwNode &rNode)
SwUndoInsert(const SwNode &rNode, sal_Int32 nContent, sal_Int32 nLen, const SwInsertFlags nInsertFlags, bool bWDelim=true)
std::optional< OUString > GetTextFromDoc() const
std::unique_ptr< SwRedlineData > m_pRedlData
virtual void UndoImpl(::sw::UndoRedoContext &) override
void SaveGraphicData(const SwGrfNode &)
std::optional< Graphic > moGraphic
virtual ~SwUndoReRead() override
std::optional< OUString > maFltr
void SetAndSave(::sw::UndoRedoContext &)
virtual void RedoImpl(::sw::UndoRedoContext &) override
std::optional< OUString > maNm
SwUndoReRead(const SwPaM &rPam, const SwGrfNode &pGrfNd)
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd
void SetEnd(SwPaM const &rPam)
void RedoImpl(::sw::UndoRedoContext &)
OUString const & GetIns() const
OUString const & GetOld() const
void UndoImpl(::sw::UndoRedoContext &)
Impl(SwPaM const &rPam, OUString aIns, bool const bRegExp)
virtual SwRewriter GetRewriter() const override
Returns the rewriter of this undo object.
virtual void RedoImpl(::sw::UndoRedoContext &) override
SwUndoReplace(SwPaM const &rPam, OUString const &rInsert, bool const bRegExp)
std::unique_ptr< Impl > m_pImpl
virtual ~SwUndoReplace() override
virtual void UndoImpl(::sw::UndoRedoContext &) override
void SetEnd(const SwPaM &rPam)
static void MoveFromUndoNds(SwDoc &rDoc, SwNodeOffset nNodeIdx, SwPosition &rInsPos, const SwNodeOffset *pEndNdIdx=nullptr, bool bForceCreateFrames=false)
void DelContentIndex(const SwPosition &pMark, const SwPosition &pPoint, DelContentType nDelContentType=DelContentType::AllMask)
static void MoveToUndoNds(SwPaM &rPam, SwNodeIndex *pNodeIdx, SwNodeOffset *pEndNdIdx=nullptr)
std::unique_ptr< SwHistory > m_pHistory
static bool MovePtBackward(SwPaM &rPam)
static void MovePtForward(SwPaM &rPam, bool bMvBkwrd)
void SetRedlineFlags(RedlineFlags eMode)
RedlineFlags GetRedlineFlags() const
static void RemoveIdxFromRange(SwPaM &rPam, bool bMoveNext)
OUString CreateUniqueObjectName()
bool StoreEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, OUString &rName, bool bCopy, const OUString &rSrcShellID, const OUString &rDestShellID)
css::uno::Reference< css::embed::XEmbeddedObject > GetEmbeddedObject(const OUString &, OUString const *pBaseURL=nullptr)
Blocks grouping undo actions together into an SfxListUndoAction.
virtual SwCursor & CreateNewShellCursor()=0
IShellCursorSupplier & GetCursorSupplier()
void SetSelections(SwFrameFormat *const pSelFormat, SdrMarkList *const pMarkList)
const EnumerationType m_eType
constexpr TypedWhichId< SvxFormatKeepItem > RES_KEEP(116)
constexpr TypedWhichId< SwFormatAutoFormat > RES_TXTATR_AUTOFMT(50)
constexpr TypedWhichId< SwFormatCharFormat > RES_TXTATR_CHARFMT(52)
CharClass & GetAppCharClass()
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
SwMoveFnCollection const & fnMoveBackward
Marks a position in the document model.
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.
const SwContentNode * GetContentNode() const
SwNodeOffset GetNodeIndex() const
sal_Int32 GetContentIndex() const
void AdjustContent(sal_Int32 nDelta)
Adjust content index, only valid to call this if the position points to a SwContentNode subclass.
OUString SwResId(TranslateId aId)
SwRewriter MakeUndoReplaceRewriter(sal_uLong const occurrences, OUString const &sOld, OUString const &sNew)