34#include <tools/datetime.hxx>
51using ::com::sun::star::text::XTextCursor;
52using ::com::sun::star::text::XTextRange;
53using ::com::sun::star::text::XWordCursor;
54using ::com::sun::star::lang::XUnoTunnel;
55using ::com::sun::star::beans::XPropertySet;
56using ::com::sun::star::beans::XPropertySetInfo;
63 OTextCursorHelper *
const pXCursor =
64 dynamic_cast<OTextCursorHelper*
>(rCursor.get());
65 OSL_ENSURE( pXCursor,
"OTextCursorHelper missing" );
66 return pXCursor ? pXCursor->GetDoc() :
nullptr;
72 OSL_ENSURE(pXRange,
"missing SwXTextRange for XTextRange");
75 return pXRange ? &pXRange->
GetDoc() :
nullptr;
88class XTextRangeOrNodeIndexPosition
90 Reference<XTextRange> m_xRange;
91 std::optional<SwNodeIndex> m_oIndex;
94 XTextRangeOrNodeIndexPosition();
96 void Set( Reference<XTextRange>
const & rRange );
98 void SetAsNodeIndex( Reference<XTextRange>
const & rRange );
103 bool IsValid()
const;
108XTextRangeOrNodeIndexPosition::XTextRangeOrNodeIndexPosition()
112void XTextRangeOrNodeIndexPosition::Set( Reference<XTextRange>
const & rRange )
114 m_xRange = rRange->getStart();
118void XTextRangeOrNodeIndexPosition::Set(
SwNode const & rIndex )
125void XTextRangeOrNodeIndexPosition::SetAsNodeIndex(
126 Reference<XTextRange>
const & rRange )
140 OSL_ENSURE(bSuccess,
"illegal range");
143 Set(aPaM.GetPoint()->GetNode());
147XTextRangeOrNodeIndexPosition::CopyPositionInto(
SwPosition& rPos,
SwDoc & rDoc)
149 OSL_ENSURE(IsValid(),
"Can't get Position");
152 if (!m_oIndex.has_value())
156 OSL_ENSURE(bSuccess,
"illegal range");
158 rPos = *aUnoPaM.GetPoint();
166SwDoc* XTextRangeOrNodeIndexPosition::GetDoc()
168 OSL_ENSURE(IsValid(),
"Can't get Doc");
170 return m_oIndex.has_value() ? &m_oIndex->GetNodes().GetDoc() :
lcl_GetDocViaTunnel(m_xRange);
173bool XTextRangeOrNodeIndexPosition::IsValid()
const
175 return m_xRange.is() || m_oIndex.has_value();
214 bMergeLastParagraph( false ),
215 pContentIndex(nullptr),
216 pNextRedline(nullptr),
217 bNeedsAdjustment( false )
232 SvXMLImport & rImport,
233 bool bNoRedlinesPlease,
234 const Reference<XPropertySet> & rModel,
235 const Reference<XPropertySet> & rImportInfo )
240 m_bIgnoreRedlines(bNoRedlinesPlease),
241 m_xModelPropertySet(rModel),
242 m_xImportInfoPropertySet(rImportInfo)
245 bool bHandleShowChanges =
true;
246 bool bHandleRecordChanges =
true;
247 bool bHandleProtectionKey =
true;
250 Reference<XPropertySetInfo> xInfo =
253 bHandleShowChanges = ! xInfo->hasPropertyByName(
g_sShowChanges );
273 if( bHandleRecordChanges )
290 OSL_FAIL(
"forgotten RedlineInfo; now inserted");
299 OSL_FAIL(
"RedlineInfo without adjustment; now inserted");
308 OSL_FAIL(
"incomplete redline (maybe file was corrupt); "
318 bool bHandleShowChanges =
true;
319 bool bHandleRecordChanges =
true;
320 bool bHandleProtectionKey =
true;
323 Reference<XPropertySetInfo> xInfo =
326 bHandleShowChanges = ! xInfo->hasPropertyByName(
g_sShowChanges );
337 if ( bHandleShowChanges )
350 if ( bHandleRecordChanges )
356 if ( bHandleProtectionKey )
361 catch (
const uno::RuntimeException &)
363 SAL_WARN(
"sw",
"potentially benign ordering issue during shutdown" );
368 std::u16string_view rType,
370 const OUString& rAuthor,
371 const OUString& rComment,
372 const util::DateTime& rDateTime,
386 eType = RedlineType::Insert;
390 eType = RedlineType::Delete;
394 eType = RedlineType::Format;
423 for( pInfoChain = itPair.first->second;
432 Reference<XTextCursor>
const & xOldCursor,
435 Reference<XTextCursor> xReturn;
449 SAL_WARN(
"sw",
"no SwDoc => cannot create section.");
474 xReturn =
static_cast<text::XWordCursor*
>(pXCursor.get());
484 Reference<XTextRange>
const & rRange,
485 bool bIsOutsideOfParagraph)
493 if (bIsOutsideOfParagraph)
569 if (rRedlineSection.GetIndex() <= rPos.GetIndex()
570 && rPos.GetIndex() <= rRedlineSection.EndOfSectionIndex())
575 for (
SwStartNode const* pStartNode = rPos.StartOfSectionNode();
576 pStartNode !=
nullptr && pStartNode->GetIndex() !=
SwNodeOffset(0);
577 pStartNode = pStartNode->StartOfSectionNode())
579 switch (pStartNode->GetStartNodeType())
587 SwFrameFormat const*
const pFormat(pStartNode->GetFlyFormat());
590 if (rAnchor.
GetAnchorId() == RndStdIds::FLY_AT_PAGE)
594 else if (rAnchor.
GetAnchorId() == RndStdIds::FLY_AT_FLY)
611 for (
SwTextFootnote const*
const pFootnote : rRedlineSection.GetDoc().GetFootnoteIdxs())
613 if (pStartNode == pFootnote->GetStartNode()->GetNode().GetStartNode())
635 OSL_ENSURE(
nullptr != pRedlineInfo,
"need redline info");
636 OSL_ENSURE(
IsReady(pRedlineInfo),
"redline info not complete yet!");
650 SAL_WARN(
"sw",
"no SwDoc => cannot insert redline.");
687 && pTempNode->
GetText().isEmpty()
693 if (RedlineType::Delete == pRedlineInfo->
eType)
714 SAL_WARN(
"sw.xml",
"Recursive change tracking, removing");
733 std::vector<const SwRangeRedline*> aSwapRedlines;
734 if ( RedlineType::Delete == pRedlineInfo->
eType )
741 aSwapRedlines.push_back(pRedline2);
757 if( nPoint < pRedlineInfo->pContentIndex->GetIndex() ||
761 SAL_WARN(
"sw",
"Recursive change tracking");
769 for (
auto i = aSwapRedlines.rbegin();
i != aSwapRedlines.rend(); ++
i)
782 std::size_t nAuthorId = (
nullptr == pDoc) ? 0 :
799 (RedlineType::Delete == pRedlineInfo->
eType) &&
825 const Sequence<sal_Int8> & rKey )
const SvXMLImport & m_rImport
constexpr OUStringLiteral g_sShowChanges
static SwDoc * lcl_GetDocViaTunnel(Reference< XTextCursor > const &rCursor)
static auto RecursiveContains(SwStartNode const &rRedlineSection, SwNode const &rPos) -> bool
recursively check if rPos or its anchor (if in fly or footnote) is in redline section
constexpr OUStringLiteral g_sRedlineProtectionKey
constexpr OUStringLiteral g_sRecordChanges
void SetMonth(sal_uInt16 nNewMonth)
void SetYear(sal_Int16 nNewYear)
void SetDay(sal_uInt16 nNewDay)
virtual void DeleteSection(SwNode *pNode)=0
Delete section containing the node.
virtual void DeleteRange(SwPaM &)=0
Delete a range SwFlyFrameFormat.
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
virtual const SwRedlineTable & GetRedlineTable() const =0
virtual std::size_t InsertRedlineAuthor(const OUString &rAuthor)=0
virtual AppendResult AppendRedline(SwRangeRedline *pNewRedl, bool bCallDelete)=0
Append a new redline.
virtual const SwRangeRedline * GetRedline(const SwPosition &rPos, SwRedlineTable::size_type *pFndPos) const =0
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
RedlineInfo * pNextRedline
XTextRangeOrNodeIndexPosition aAnchorStart
XTextRangeOrNodeIndexPosition aAnchorEnd
SwNodeIndex * pContentIndex
IDocumentContentOperations const & getIDocumentContentOperations() const
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
::sw::DocumentRedlineManager const & GetDocumentRedlineManager() const
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Marks a node in the document model.
SwNodeOffset GetIndex() const
Base class of the Writer document model elements.
SwStartNode * GetStartNode()
SwNodeOffset EndOfSectionIndex() const
std::vector< SwFrameFormat * > const & GetAnchoredFlys() const
const SwEndNode * EndOfSectionNode() const
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
SwStartNode * MakeTextSection(const SwNode &rWhere, SwStartNodeType eSttNdTyp, SwTextFormatColl *pColl)
SwNode & GetEndOfRedlines() const
Section for all Redlines.
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.
const SwPosition * GetPoint() const
const SwPosition * Start() const
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
void SetContentIdx(const SwNodeIndex &)
void Remove(size_type nPos)
vector_type::size_type size_type
Starts a section of nodes in the document model.
Represents the style of a paragraph.
SwTextNode is a paragraph in the document model.
SwpHints * GetpSwpHints()
const OUString & GetText() const
SwXRedlineText provides an XText which may be used to write directly into a redline node.
css::uno::Sequence< sal_Int8 > m_aProtectionKey
~XMLRedlineImportHelper()
void SetProtectionKey(const css::uno::Sequence< sal_Int8 > &rKey)
SwRedlineData * ConvertRedline(RedlineInfo *pRedline, SwDoc *pDoc)
css::uno::Reference< css::text::XTextCursor > CreateRedlineTextSection(css::uno::Reference< css::text::XTextCursor > const &xOldCursor, const OUString &rId)
void SetCursor(const OUString &rId, bool bStart, css::uno::Reference< css::text::XTextRange > const &rRange, bool bIsOutsideOfParagraph)
void Add(std::u16string_view rType, const OUString &rId, const OUString &rAuthor, const OUString &rComment, const css::util::DateTime &rDateTime, bool bMergeLastParagraph)
css::uno::Reference< css::beans::XPropertySet > m_xModelPropertySet
static bool IsReady(const RedlineInfo *pRedline)
const OUString m_sFormatChange
const OUString m_sDeletion
css::uno::Reference< css::beans::XPropertySet > m_xImportInfoPropertySet
void AdjustStartNodeCursor(const OUString &rId)
Adjust the start (end) position for a redline that begins in a start node.
void InsertIntoDocument(RedlineInfo *pRedline)
const OUString m_sInsertion
void SetShowChanges(bool bShowChanges)
void SetRecordChanges(bool bRecordChanges)
XMLRedlineImportHelper(SvXMLImport &rImport, bool bIgnoreRedlines, const css::uno::Reference< css::beans::XPropertySet > &rModel, const css::uno::Reference< css::beans::XPropertySet > &rImportInfoSet)
RedlineMapType m_aRedlineMap
void SetHideRedlines(bool const bHideRedlines)
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName) override
std::deque< AttacherIndex_Impl > aIndex
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange, ::sw::TextRangeMode const eMode)
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
bool CheckNodesRange(const SwNode &rStt, const SwNode &rEnd, bool bChkSection)
Check if the given range is inside one of the defined top-level sections.
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
@ RES_POOLCOLL_STANDARD
Standard.
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.
SwNodeOffset GetNodeIndex() const