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::beans::XPropertySet;
55using ::com::sun::star::beans::XPropertySetInfo;
62 OTextCursorHelper *
const pXCursor =
63 dynamic_cast<OTextCursorHelper*
>(rCursor.get());
64 OSL_ENSURE( pXCursor,
"OTextCursorHelper missing" );
65 return pXCursor ? pXCursor->GetDoc() :
nullptr;
71 OSL_ENSURE(pXRange,
"missing SwXTextRange for XTextRange");
74 return pXRange ? &pXRange->
GetDoc() :
nullptr;
87class XTextRangeOrNodeIndexPosition
89 Reference<XTextRange> m_xRange;
90 std::optional<SwNodeIndex> m_oIndex;
93 XTextRangeOrNodeIndexPosition();
95 void Set( Reference<XTextRange>
const & rRange );
97 void SetAsNodeIndex( Reference<XTextRange>
const & rRange );
102 bool IsValid()
const;
107XTextRangeOrNodeIndexPosition::XTextRangeOrNodeIndexPosition()
111void XTextRangeOrNodeIndexPosition::Set( Reference<XTextRange>
const & rRange )
113 m_xRange = rRange->getStart();
117void XTextRangeOrNodeIndexPosition::Set(
SwNode const & rIndex )
124void XTextRangeOrNodeIndexPosition::SetAsNodeIndex(
125 Reference<XTextRange>
const & rRange )
139 OSL_ENSURE(bSuccess,
"illegal range");
142 Set(aPaM.GetPoint()->GetNode());
146XTextRangeOrNodeIndexPosition::CopyPositionInto(
SwPosition& rPos,
SwDoc & rDoc)
148 OSL_ENSURE(IsValid(),
"Can't get Position");
151 if (!m_oIndex.has_value())
155 OSL_ENSURE(bSuccess,
"illegal range");
157 rPos = *aUnoPaM.GetPoint();
165SwDoc* XTextRangeOrNodeIndexPosition::GetDoc()
167 OSL_ENSURE(IsValid(),
"Can't get Doc");
169 return m_oIndex.has_value() ? &m_oIndex->GetNodes().GetDoc() :
lcl_GetDocViaTunnel(m_xRange);
172bool XTextRangeOrNodeIndexPosition::IsValid()
const
174 return m_xRange.is() || m_oIndex.has_value();
213 bMergeLastParagraph( false ),
214 pContentIndex(nullptr),
215 pNextRedline(nullptr),
216 bNeedsAdjustment( false )
231 SvXMLImport & rImport,
232 bool bNoRedlinesPlease,
233 const Reference<XPropertySet> & rModel,
234 const Reference<XPropertySet> & rImportInfo )
239 m_bIgnoreRedlines(bNoRedlinesPlease),
240 m_xModelPropertySet(rModel),
241 m_xImportInfoPropertySet(rImportInfo)
244 bool bHandleShowChanges =
true;
245 bool bHandleRecordChanges =
true;
246 bool bHandleProtectionKey =
true;
249 Reference<XPropertySetInfo> xInfo =
252 bHandleShowChanges = ! xInfo->hasPropertyByName(
g_sShowChanges );
272 if( bHandleRecordChanges )
289 OSL_FAIL(
"forgotten RedlineInfo; now inserted");
298 OSL_FAIL(
"RedlineInfo without adjustment; now inserted");
307 OSL_FAIL(
"incomplete redline (maybe file was corrupt); "
317 bool bHandleShowChanges =
true;
318 bool bHandleRecordChanges =
true;
319 bool bHandleProtectionKey =
true;
322 Reference<XPropertySetInfo> xInfo =
325 bHandleShowChanges = ! xInfo->hasPropertyByName(
g_sShowChanges );
336 if ( bHandleShowChanges )
349 if ( bHandleRecordChanges )
355 if ( bHandleProtectionKey )
360 catch (
const uno::RuntimeException &)
362 SAL_WARN(
"sw",
"potentially benign ordering issue during shutdown" );
367 std::u16string_view rType,
369 const OUString& rAuthor,
370 const OUString& rComment,
371 const util::DateTime& rDateTime,
385 eType = RedlineType::Insert;
389 eType = RedlineType::Delete;
393 eType = RedlineType::Format;
422 for( pInfoChain = itPair.first->second;
431 Reference<XTextCursor>
const & xOldCursor,
434 Reference<XTextCursor> xReturn;
448 SAL_WARN(
"sw",
"no SwDoc => cannot create section.");
473 xReturn =
static_cast<text::XWordCursor*
>(pXCursor.get());
483 Reference<XTextRange>
const & rRange,
484 bool bIsOutsideOfParagraph)
492 if (bIsOutsideOfParagraph)
568 if (rRedlineSection.GetIndex() <= rPos.GetIndex()
569 && rPos.GetIndex() <= rRedlineSection.EndOfSectionIndex())
574 for (
SwStartNode const* pStartNode = rPos.StartOfSectionNode();
575 pStartNode !=
nullptr && pStartNode->GetIndex() !=
SwNodeOffset(0);
576 pStartNode = pStartNode->StartOfSectionNode())
578 switch (pStartNode->GetStartNodeType())
586 SwFrameFormat const*
const pFormat(pStartNode->GetFlyFormat());
589 if (rAnchor.
GetAnchorId() == RndStdIds::FLY_AT_PAGE)
593 else if (rAnchor.
GetAnchorId() == RndStdIds::FLY_AT_FLY)
610 for (
SwTextFootnote const*
const pFootnote : rRedlineSection.GetDoc().GetFootnoteIdxs())
612 if (pStartNode == pFootnote->GetStartNode()->GetNode().GetStartNode())
634 OSL_ENSURE(
nullptr != pRedlineInfo,
"need redline info");
635 OSL_ENSURE(
IsReady(pRedlineInfo),
"redline info not complete yet!");
649 SAL_WARN(
"sw",
"no SwDoc => cannot insert redline.");
686 && pTempNode->
GetText().isEmpty()
692 if (RedlineType::Delete == pRedlineInfo->
eType)
713 SAL_WARN(
"sw.xml",
"Recursive change tracking, removing");
732 std::vector<const SwRangeRedline*> aSwapRedlines;
733 if ( RedlineType::Delete == pRedlineInfo->
eType )
740 aSwapRedlines.push_back(pRedline2);
756 if( nPoint < pRedlineInfo->pContentIndex->GetIndex() ||
760 SAL_WARN(
"sw",
"Recursive change tracking");
768 for (
auto i = aSwapRedlines.rbegin();
i != aSwapRedlines.rend(); ++
i)
781 std::size_t nAuthorId = (
nullptr == pDoc) ? 0 :
798 (RedlineType::Delete == pRedlineInfo->
eType) &&
824 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