34 #include <tools/datetime.hxx>
48 using ::com::sun::star::text::XTextCursor;
49 using ::com::sun::star::text::XTextRange;
50 using ::com::sun::star::text::XWordCursor;
51 using ::com::sun::star::lang::XUnoTunnel;
52 using ::com::sun::star::beans::XPropertySet;
53 using ::com::sun::star::beans::XPropertySetInfo;
60 Reference<XUnoTunnel> xTunnel( rCursor, UNO_QUERY);
61 OSL_ENSURE(xTunnel.is(),
"missing XUnoTunnel for XTextCursor");
63 comphelper::getFromUnoTunnel<OTextCursorHelper>(xTunnel);
64 OSL_ENSURE( pXCursor,
"OTextCursorHelper missing" );
65 return pXCursor ? pXCursor->GetDoc() :
nullptr;
70 Reference<XUnoTunnel> xTunnel(rRange, UNO_QUERY);
71 OSL_ENSURE(xTunnel.is(),
"missing XUnoTunnel for XTextRange");
73 comphelper::getFromUnoTunnel<SwXTextRange>(xTunnel);
76 return pXRange ? &pXRange->
GetDoc() :
nullptr;
89 class XTextRangeOrNodeIndexPosition
91 Reference<XTextRange> m_xRange;
92 std::unique_ptr<SwNodeIndex> m_pIndex;
95 XTextRangeOrNodeIndexPosition();
97 void Set( Reference<XTextRange>
const & rRange );
99 void SetAsNodeIndex( Reference<XTextRange>
const & rRange );
104 bool IsValid()
const;
109 XTextRangeOrNodeIndexPosition::XTextRangeOrNodeIndexPosition()
113 void XTextRangeOrNodeIndexPosition::Set( Reference<XTextRange>
const & rRange )
115 m_xRange = rRange->getStart();
119 void XTextRangeOrNodeIndexPosition::Set(
SwNodeIndex const & rIndex )
126 void XTextRangeOrNodeIndexPosition::SetAsNodeIndex(
127 Reference<XTextRange>
const & rRange )
141 OSL_ENSURE(bSuccess,
"illegal range");
144 Set(aPaM.GetPoint()->nNode);
148 XTextRangeOrNodeIndexPosition::CopyPositionInto(
SwPosition& rPos,
SwDoc & rDoc)
150 OSL_ENSURE(IsValid(),
"Can't get Position");
153 if (
nullptr == m_pIndex)
157 OSL_ENSURE(bSuccess,
"illegal range");
159 rPos = *aUnoPaM.GetPoint();
163 rPos.
nNode = *m_pIndex;
169 SwDoc* XTextRangeOrNodeIndexPosition::GetDoc()
171 OSL_ENSURE(IsValid(),
"Can't get Doc");
173 return (
nullptr != m_pIndex) ? &m_pIndex->GetNodes().GetDoc() :
lcl_GetDocViaTunnel(m_xRange);
176 bool XTextRangeOrNodeIndexPosition::IsValid()
const
178 return ( m_xRange.is() || (m_pIndex !=
nullptr) );
217 bMergeLastParagraph(
false ),
218 pContentIndex(nullptr),
219 pNextRedline(nullptr),
220 bNeedsAdjustment(
false )
236 bool bNoRedlinesPlease,
243 m_bIgnoreRedlines(bNoRedlinesPlease),
244 m_xModelPropertySet(rModel),
245 m_xImportInfoPropertySet(rImportInfo)
248 bool bHandleShowChanges =
true;
249 bool bHandleRecordChanges =
true;
250 bool bHandleProtectionKey =
true;
253 Reference<XPropertySetInfo> xInfo =
256 bHandleShowChanges = ! xInfo->hasPropertyByName( g_sShowChanges );
257 bHandleRecordChanges = ! xInfo->hasPropertyByName( g_sRecordChanges );
258 bHandleProtectionKey = ! xInfo->hasPropertyByName( g_sRedlineProtectionKey );
276 if( bHandleRecordChanges )
293 OSL_FAIL(
"forgotten RedlineInfo; now inserted");
302 OSL_FAIL(
"RedlineInfo without adjustment; now inserted");
311 OSL_FAIL(
"incomplete redline (maybe file was corrupt); "
317 m_aRedlineMap.clear();
321 bool bHandleShowChanges =
true;
322 bool bHandleRecordChanges =
true;
323 bool bHandleProtectionKey =
true;
326 Reference<XPropertySetInfo> xInfo =
329 bHandleShowChanges = ! xInfo->hasPropertyByName( g_sShowChanges );
330 bHandleRecordChanges = ! xInfo->hasPropertyByName( g_sRecordChanges );
331 bHandleProtectionKey = ! xInfo->hasPropertyByName( g_sRedlineProtectionKey );
340 if ( bHandleShowChanges )
353 if ( bHandleRecordChanges )
359 if ( bHandleProtectionKey )
364 catch (
const uno::RuntimeException &)
366 SAL_WARN(
"sw",
"potentially benign ordering issue during shutdown" );
371 std::u16string_view rType,
373 const OUString& rAuthor,
374 const OUString& rComment,
375 const util::DateTime& rDateTime,
389 eType = RedlineType::Insert;
393 eType = RedlineType::Delete;
397 eType = RedlineType::Format;
409 pInfo->
eType = eType;
426 for( pInfoChain = itPair.first->second;
435 Reference<XTextCursor>
const & xOldCursor,
438 Reference<XTextCursor> xReturn;
452 SAL_WARN(
"sw",
"no SwDoc => cannot create section.");
466 aFind->second->pContentIndex =
new SwNodeIndex(aIndex);
477 xReturn =
static_cast<text::XWordCursor*
>(pXCursor.get());
487 Reference<XTextRange>
const & rRange,
488 bool bIsOutsideOfParagraph)
496 if (bIsOutsideOfParagraph)
571 OSL_ENSURE(
nullptr != pRedlineInfo,
"need redline info");
572 OSL_ENSURE(
IsReady(pRedlineInfo),
"redline info not complete yet!");
586 SAL_WARN(
"sw",
"no SwDoc => cannot insert redline.");
592 pRedlineInfo->
aAnchorStart.CopyPositionInto(*aPaM.GetPoint(), *pDoc);
594 pRedlineInfo->
aAnchorEnd.CopyPositionInto(*aPaM.GetPoint(), *pDoc);
597 if (*aPaM.GetPoint() == *aPaM.GetMark())
610 if( !aPaM.HasMark() && (pRedlineInfo->
pContentIndex ==
nullptr) )
617 aPaM.GetMark()->nNode,
623 && pTempNode->
GetText().isEmpty()
629 if (RedlineType::Delete == pRedlineInfo->
eType)
641 SwPaM aDel( aIdx, aEnd );
660 std::vector<const SwRangeRedline*> aSwapRedlines;
661 if ( RedlineType::Delete == pRedlineInfo->
eType )
668 aSwapRedlines.push_back(pRedline2);
677 *(pRedline->
GetMark()) = *aPaM.GetMark();
683 SwNodeOffset nPoint = aPaM.GetPoint()->nNode.GetIndex();
684 if( nPoint < pRedlineInfo->pContentIndex->GetIndex() ||
688 SAL_WARN(
"sw",
"Recursive change tracking");
696 for (
auto i = aSwapRedlines.rbegin();
i != aSwapRedlines.rend(); ++
i)
709 std::size_t nAuthorId = (
nullptr == pDoc) ? 0 :
726 (RedlineType::Delete == pRedlineInfo->
eType) &&
752 const Sequence<sal_Int8> & rKey )
~XMLRedlineImportHelper()
const SwEndNode * EndOfSectionNode() const
Starts a section of nodes in the document model.
const OUString m_sInsertion
SwNodeOffset EndOfSectionIndex() const
Represents the style of a paragraph.
Marks a position in the document model.
constexpr OUStringLiteral g_sShowChanges
void SetContentIdx(const SwNodeIndex *)
const OUString & GetText() const
SwpHints * GetpSwpHints()
virtual AppendResult AppendRedline(SwRangeRedline *pNewRedl, bool bCallDelete)=0
Append a new redline.
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
css::uno::Sequence< sal_Int8 > m_aProtectionKey
std::unique_ptr< sal_Int32[]> pData
const SwPosition * GetMark() const
XMLRedlineImportHelper(SvXMLImport &rImport, bool bIgnoreRedlines, const css::uno::Reference< css::beans::XPropertySet > &rModel, const css::uno::Reference< css::beans::XPropertySet > &rImportInfoSet)
void Remove(size_type nPos)
RedlineInfo * pNextRedline
virtual void DeleteRange(SwPaM &)=0
Delete a range SwFlyFrameFormat.
::sw::DocumentRedlineManager const & GetDocumentRedlineManager() const
static bool IsReady(const RedlineInfo *pRedline)
IDocumentContentOperations const & getIDocumentContentOperations() const
void SetRecordChanges(bool bRecordChanges)
void SetProtectionKey(const css::uno::Sequence< sal_Int8 > &rKey)
RedlineMapType m_aRedlineMap
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
void SetShowChanges(bool bShowChanges)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
constexpr OUStringLiteral g_sRecordChanges
void SetYear(sal_Int16 nNewYear)
bool CheckNodesRange(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, bool bChkSection)
Check if the given range is inside one of the defined top-level sections.
std::vector< SwFrameFormat * > const & GetAnchoredFlys() const
SwNodeOffset GetIndex() const
css::uno::Reference< css::text::XTextCursor > CreateRedlineTextSection(css::uno::Reference< css::text::XTextCursor > const &xOldCursor, const OUString &rId)
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
SwStartNode * MakeTextSection(const SwNodeIndex &rWhere, SwStartNodeType eSttNdTyp, SwTextFormatColl *pColl)
XTextRangeOrNodeIndexPosition aAnchorEnd
PaM is Point and Mark: a selection of the document model.
static SwDoc * lcl_GetDocViaTunnel(Reference< XTextCursor > const &rCursor)
css::uno::Reference< css::beans::XPropertySet > m_xImportInfoPropertySet
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
void SetDay(sal_uInt16 nNewDay)
SwXRedlineText provides an XText which may be used to write directly into a redline node...
SwIndex & Assign(SwIndexReg *, sal_Int32)
SwContentNode * GetContentNode()
vector_type::size_type size_type
void SetHideRedlines(bool const bHideRedlines)
Marks a node in the document model.
virtual std::size_t InsertRedlineAuthor(const OUString &rAuthor)=0
const SwPosition * Start() const
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange,::sw::TextRangeMode const eMode)
const OUString m_sFormatChange
void SetCursor(const OUString &rId, bool bStart, css::uno::Reference< css::text::XTextRange > const &rRange, bool bIsOutsideOfParagraph)
virtual const SwRangeRedline * GetRedline(const SwPosition &rPos, SwRedlineTable::size_type *pFndPos) const =0
void AdjustStartNodeCursor(const OUString &rId)
Adjust the start (end) position for a redline that begins in a start node.
SwTextNode is a paragraph in the document model.
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
std::deque< AttacherIndex_Impl > aIndex
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
const OUString m_sDeletion
const SvXMLImport & m_rImport
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
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
SwRedlineData * ConvertRedline(RedlineInfo *pRedline, SwDoc *pDoc)
XTextRangeOrNodeIndexPosition aAnchorStart
#define SAL_WARN(area, stream)
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
virtual const SwRedlineTable & GetRedlineTable() const =0
SwNode & GetEndOfRedlines() const
Section for all Redlines.
SwDoc * GetDocFromXMLImport(SvXMLImport const &)
SwNodeIndex * pContentIndex
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName) override
void InsertIntoDocument(RedlineInfo *pRedline)
void SetMonth(sal_uInt16 nNewMonth)
constexpr OUStringLiteral g_sRedlineProtectionKey
bool m_bDetectedRangeSegmentation false
Base class of the Writer document model elements.