/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ #ifndef INCLUDED_SW_INC_UNDOBJ_HXX #define INCLUDED_SW_INC_UNDOBJ_HXX
class SwHistory; class SwPaM; struct SwPosition; class SwDoc; class SwTextFormatColl; class SwFrameFormat; class SwFormatAnchor; class SwNode; class SwRedlineData; class SwRedlineSaveDatas; enumclass RedlineFlags; enumclass RndStdIds; typedefstruct _xmlTextWriter* xmlTextWriterPtr;
namespace sw { class UndoRedoContext; class RepeatContext;
}
class SW_DLLPUBLIC SwUndo
: public SfxUndoAction
{
SwUndoId const m_nId;
RedlineFlags m_nOrigRedlineFlags;
ViewShellId m_nViewShellId; bool m_isRepeatIgnored; ///< for multi-selection, only repeat 1st selection
@return the rewriter for this object
*/ virtual SwRewriter GetRewriter() const;
// the 4 methods that derived classes have to override // base implementation does nothing virtualvoid RepeatImpl( ::sw::RepeatContext & ); public: // should not be public, but ran into trouble in untbl.cxx virtualvoid UndoImpl( ::sw::UndoRedoContext & ) = 0; virtualvoid RedoImpl( ::sw::UndoRedoContext & ) = 0;
private: /// Try to obtain the view shell ID of the current view. static ViewShellId CreateViewShellId(const SwDoc& rDoc); // SfxUndoAction virtualvoid Undo() override; virtualvoid Redo() override; virtualvoid UndoWithContext(SfxUndoContext &) override; virtualvoid RedoWithContext(SfxUndoContext &) override; virtualvoid Repeat(SfxRepeatTarget &) override; virtualbool CanRepeat(SfxRepeatTarget &) const override;
The textual comment is created from the resource string corresponding to this object's ID. The rewriter of this object is applied to the resource string to get the final comment.
@return textual comment for this undo object
*/ virtual OUString GetComment() const override;
/// See SfxUndoAction::GetViewShellId().
ViewShellId GetViewShellId() const override;
// UndoObject remembers which mode was turned on. // In Undo/Redo/Repeat this remembered mode is switched on.
RedlineFlags GetRedlineFlags() const { return m_nOrigRedlineFlags; } void SetRedlineFlags( RedlineFlags eMode ) { m_nOrigRedlineFlags = eMode; }
/// will DelContentIndex destroy a frame anchored at character at rAnchorPos? bool IsDestroyFrameAnchoredAtChar(SwPosition const & rAnchorPos,
SwPosition const & rStart, SwPosition const & rEnd,
DelContentType const nDelContentType = DelContentType::AllMask); /// is a fly anchored at paragraph at rAnchorPos selected? bool IsSelectFrameAnchoredAtPara(SwPosition const & rAnchorPos,
SwPosition const & rStart, SwPosition const & rEnd,
DelContentType const nDelContentType = DelContentType::AllMask); /// check at-char and at-para flys in rDoc bool IsFlySelectedByCursor(SwDoc const & rDoc,
SwPosition const & rStart, SwPosition const & rEnd);
// This class has to be inherited into an Undo-object if it saves content // for Redo/Undo... class SwUndoSaveContent
{ protected:
std::unique_ptr<SwHistory> m_pHistory;
// Needed for deletion of content. For Redo content is moved into the // UndoNodesArray. These methods always create a new node to insert // content. So the attributes do not get expanded. // MoveTo: moves from the NodesArray into the UndoNodesArray. // MoveFrom: moves from the UndoNodesArray into the NodesArray. staticvoid MoveToUndoNds( SwPaM& rPam,
SwNodeIndex* pNodeIdx,
SwNodeOffset* pEndNdIdx = nullptr ); staticvoid MoveFromUndoNds( SwDoc& rDoc, SwNodeOffset nNodeIdx,
SwPosition& rInsPos, const SwNodeOffset* pEndNdIdx = nullptr, bool bForceCreateFrames = false);
// These two methods save and restore the Point of PaM. // If the point cannot be moved, a "backup" is created on the previous node. // Either way, it will not be moved by inserting at its original position. static ::std::optional<SwNodeIndex> MovePtBackward(SwPaM& rPam); staticvoid MovePtForward(SwPaM& rPam, ::std::optional<SwNodeIndex> && oMvBkwrd);
// Before moving stuff into UndoNodes-Array care has to be taken that // the content-bearing attributes are removed from the nodes-array. void DelContentIndex( const SwPosition& pMark, const SwPosition& pPoint,
DelContentType nDelContentType = DelContentType::AllMask );
// Save a complete section in nodes-array. class SwUndoSaveSection : private SwUndoSaveContent
{
std::optional<SwNodeIndex> m_oMovedStart;
std::unique_ptr<SwRedlineSaveDatas> m_pRedlineSaveData;
SwNodeOffset m_nMoveLen; // Index into UndoNodes-Array.
SwNodeOffset m_nStartPos;
// This class saves the PaM as sal_uInt16's and is able to restore it // into a PaM. class SwUndRng
{ public:
SwNodeOffset m_nSttNode, m_nEndNode;
sal_Int32 m_nSttContent, m_nEndContent;
// base class for insertion of Document, Glossaries and Copy class SwUndoInserts : public SwUndo, public SwUndRng, private SwUndoSaveContent
{
SwTextFormatColl *m_pTextFormatColl, *m_pLastNodeColl;
std::optional<std::vector<SwFrameFormat*>> m_pFrameFormats;
std::vector< std::shared_ptr<SwUndoInsLayFormat> > m_FlyUndos;
std::unique_ptr<SwRedlineData> m_pRedlineData;
SwNodeOffset m_nDeleteTextNodes;
SwNodeOffset m_nNodeDiff; /// start of Content in UndoNodes for Redo
std::optional<SwNodeIndex> m_oUndoNodeIndex;
sal_uInt16 m_nSetPos; // Start in the history list.
/// Undo for Insert -> Text from file. class SwUndoInsDoc final : public SwUndoInserts
{ public:
SwUndoInsDoc( const SwPaM& );
};
/// Undo for copying from part of a document and then inserting that text, as opposed to inserting /// it from a file or clipboard. class SwUndoCpyDoc final : public SwUndoInserts
{ public:
SwUndoCpyDoc( const SwPaM& );
};
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.