34 #include <tools/datetime.hxx>
47 using ::com::sun::star::text::XTextCursor;
48 using ::com::sun::star::text::XTextRange;
49 using ::com::sun::star::text::XWordCursor;
50 using ::com::sun::star::lang::XUnoTunnel;
51 using ::com::sun::star::beans::XPropertySet;
52 using ::com::sun::star::beans::XPropertySetInfo;
59 Reference<XUnoTunnel> xTunnel( rCursor, UNO_QUERY);
60 OSL_ENSURE(xTunnel.is(),
"missing XUnoTunnel for XTextCursor");
62 ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xTunnel);
63 OSL_ENSURE( pXCursor,
"OTextCursorHelper missing" );
64 return pXCursor ? pXCursor->GetDoc() :
nullptr;
69 Reference<XUnoTunnel> xTunnel(rRange, UNO_QUERY);
70 OSL_ENSURE(xTunnel.is(),
"missing XUnoTunnel for XTextRange");
72 ::sw::UnoTunnelGetImplementation<SwXTextRange>(xTunnel);
75 return pXRange ? &pXRange->
GetDoc() :
nullptr;
88 class XTextRangeOrNodeIndexPosition
90 Reference<XTextRange> xRange;
91 std::unique_ptr<SwNodeIndex> pIndex;
94 XTextRangeOrNodeIndexPosition();
96 void Set( Reference<XTextRange>
const & rRange );
98 void SetAsNodeIndex( Reference<XTextRange>
const & rRange );
103 bool IsValid()
const;
108 XTextRangeOrNodeIndexPosition::XTextRangeOrNodeIndexPosition()
112 void XTextRangeOrNodeIndexPosition::Set( Reference<XTextRange>
const & rRange )
114 xRange = rRange->getStart();
118 void XTextRangeOrNodeIndexPosition::Set(
SwNodeIndex const & rIndex )
125 void XTextRangeOrNodeIndexPosition::SetAsNodeIndex(
126 Reference<XTextRange>
const & rRange )
140 OSL_ENSURE(bSuccess,
"illegal range");
143 Set(aPaM.GetPoint()->nNode);
147 XTextRangeOrNodeIndexPosition::CopyPositionInto(
SwPosition& rPos,
SwDoc & rDoc)
149 OSL_ENSURE(IsValid(),
"Can't get Position");
152 if (
nullptr == pIndex)
156 OSL_ENSURE(bSuccess,
"illegal range");
158 rPos = *aUnoPaM.GetPoint();
162 rPos.
nNode = *pIndex;
168 SwDoc* XTextRangeOrNodeIndexPosition::GetDoc()
170 OSL_ENSURE(IsValid(),
"Can't get Doc");
175 bool XTextRangeOrNodeIndexPosition::IsValid()
const
177 return ( xRange.is() || (pIndex !=
nullptr) );
219 bMergeLastParagraph( false ),
222 pContentIndex(nullptr),
223 pNextRedline(nullptr),
224 bNeedsAdjustment( false )
240 bool bNoRedlinesPlease,
249 m_bIgnoreRedlines(bNoRedlinesPlease),
250 m_xModelPropertySet(rModel),
251 m_xImportInfoPropertySet(rImportInfo)
254 bool bHandleShowChanges =
true;
255 bool bHandleRecordChanges =
true;
256 bool bHandleProtectionKey =
true;
259 Reference<XPropertySetInfo> xInfo =
262 bHandleShowChanges = ! xInfo->hasPropertyByName( g_sShowChanges );
263 bHandleRecordChanges = ! xInfo->hasPropertyByName( g_sRecordChanges );
264 bHandleProtectionKey = ! xInfo->hasPropertyByName( g_sRedlineProtectionKey );
282 if( bHandleRecordChanges )
299 OSL_FAIL(
"forgotten RedlineInfo; now inserted");
308 OSL_FAIL(
"RedlineInfo without adjustment; now inserted");
317 OSL_FAIL(
"incomplete redline (maybe file was corrupt); "
323 m_aRedlineMap.clear();
327 bool bHandleShowChanges =
true;
328 bool bHandleRecordChanges =
true;
329 bool bHandleProtectionKey =
true;
332 Reference<XPropertySetInfo> xInfo =
335 bHandleShowChanges = ! xInfo->hasPropertyByName( g_sShowChanges );
336 bHandleRecordChanges = ! xInfo->hasPropertyByName( g_sRecordChanges );
337 bHandleProtectionKey = ! xInfo->hasPropertyByName( g_sRedlineProtectionKey );
346 if ( bHandleShowChanges )
359 if ( bHandleRecordChanges )
365 if ( bHandleProtectionKey )
370 catch (
const uno::RuntimeException &)
372 SAL_WARN(
"sw",
"potentially benign ordering issue during shutdown" );
377 std::u16string_view rType,
379 const OUString& rAuthor,
380 const OUString& rComment,
381 const util::DateTime& rDateTime,
395 eType = RedlineType::Insert;
399 eType = RedlineType::Delete;
403 eType = RedlineType::Format;
415 pInfo->
eType = eType;
432 for( pInfoChain = itPair.first->second;
441 Reference<XTextCursor>
const & xOldCursor,
444 Reference<XTextCursor> xReturn;
458 SAL_WARN(
"sw",
"no SwDoc => cannot create section.");
472 aFind->second->pContentIndex =
new SwNodeIndex(aIndex);
483 xReturn =
static_cast<text::XWordCursor*
>(pXCursor);
493 Reference<XTextRange>
const & rRange,
494 bool bIsOutsideOfParagraph)
502 if (bIsOutsideOfParagraph)
577 OSL_ENSURE(
nullptr != pRedlineInfo,
"need redline info");
578 OSL_ENSURE(
IsReady(pRedlineInfo),
"redline info not complete yet!");
592 SAL_WARN(
"sw",
"no SwDoc => cannot insert redline.");
598 pRedlineInfo->
aAnchorStart.CopyPositionInto(*aPaM.GetPoint(), *pDoc);
600 pRedlineInfo->
aAnchorEnd.CopyPositionInto(*aPaM.GetPoint(), *pDoc);
603 if (*aPaM.GetPoint() == *aPaM.GetMark())
616 if( !aPaM.HasMark() && (pRedlineInfo->
pContentIndex ==
nullptr) )
623 aPaM.GetMark()->nNode,
629 && pTempNode->
GetText().isEmpty()
635 if (RedlineType::Delete == pRedlineInfo->
eType)
647 SwPaM aDel( aIdx, aEnd );
667 *(pRedline->
GetMark()) = *aPaM.GetMark();
673 sal_uLong nPoint = aPaM.GetPoint()->nNode.GetIndex();
674 if( nPoint < pRedlineInfo->pContentIndex->GetIndex() ||
677 #if OSL_DEBUG_LEVEL > 1
679 OSL_FAIL(
"Recursive change tracking" );
696 std::size_t nAuthorId = (
nullptr == pDoc) ? 0 :
713 (RedlineType::Delete == pRedlineInfo->
eType) &&
739 const Sequence<sal_Int8> & rKey )
~XMLRedlineImportHelper()
const SwEndNode * EndOfSectionNode() const
Starts a section of nodes in the document model.
const OUString m_sInsertion
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()
std::unique_ptr< ContentProperties > pData
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
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)
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)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
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)
sal_uLong GetIndex() const
constexpr OUStringLiteral g_sRecordChanges
std::vector< SwFrameFormat * > const * GetAnchoredFlys() const
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.
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)
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
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()
void SetHideRedlines(bool const bHideRedlines)
Marks a node in the document model.
virtual std::size_t InsertRedlineAuthor(const OUString &rAuthor)=0
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)
void AdjustStartNodeCursor(const OUString &rId)
Adjust the start (end) position for a redline that begins in a start node.
sal_uLong EndOfSectionIndex() const
SwTextNode is a paragraph in the document model.
SwUnoCursor & GetCursor()
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.
SwNode & GetEndOfRedlines() const
Section for all Redlines.
SwDoc * GetDocFromXMLImport(SvXMLImport const &)
SwNodeIndex * pContentIndex
void InsertIntoDocument(RedlineInfo *pRedline)
void SetMonth(sal_uInt16 nNewMonth)
constexpr OUStringLiteral g_sRedlineProtectionKey
Base class of the Writer document model elements.
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)