1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <com/sun/star/uno/Reference.h>
23 #include <com/sun/star/uno/Sequence.h>
29 namespace com::sun::star
{
30 namespace beans
{ class XPropertySet
; }
31 namespace beans
{ struct PropertyValue
; }
32 namespace text
{ class XText
; }
33 namespace text
{ class XTextContent
; }
34 namespace text
{ class XTextSection
; }
37 // store a list of redline properties
38 typedef ::std::vector
<
39 css::uno::Reference
<css::beans::XPropertySet
> > ChangesVectorType
;
41 // store a list of redline properties for each XText
43 css::uno::Reference
< css::text::XText
>,
44 ChangesVectorType
> ChangesMapType
;
48 * This class handles the export of redline portions.
49 * It is to be called from XMLTextParagraphExport.
51 class XMLRedlineExport
53 const OUString sDeletion
;
54 const OUString sFormatChange
;
55 const OUString sInsertion
;
60 // handling of change recording:
62 // To support change tracking in headers and footers we need to
63 // write these changes separately. To do this, we record the
64 // changes for headers and footers. For the main document body, we
65 // get the complete list of changes from the document, which
66 // should be much more efficient than recording all of those.
68 ChangesMapType aChangeMap
; /// map of recorded changes
70 /// list of current changes; is NULL or points to member of aChangeMap
71 ChangesVectorType
* pCurrentChangesList
;
75 explicit XMLRedlineExport(SvXMLExport
& rExp
);
81 /// PropertySet of RedlinePortion
82 const css::uno::Reference
<css::beans::XPropertySet
> & rPropSet
,
85 /// export the list of changes (complete list minus recorded changed)
86 void ExportChangesList(bool bAutoStyles
);
88 /// export the list of changes (recorded changes for this XText only)
89 void ExportChangesList(
90 const css::uno::Reference
<css::text::XText
> & rText
,
93 /// set the current XText for which changes should be recorded.
94 /// An empty XText means: don't record changes
96 const css::uno::Reference
<css::text::XText
> & rText
);
98 /// Do not record changes.
99 /// Same as SetCurrentXText(Reference<XText>) with empty argument.
100 void SetCurrentXText();
102 /// export redline marks which start or end at start nodes,
103 /// i.e. that include the complete paragraph/table/section
104 void ExportStartOrEndRedline(
105 const css::uno::Reference
<
106 css::beans::XPropertySet
> & rPropSet
,
107 bool bStart
); /// start or end of text entity (e.g. paragraph)?
109 /// convenience method, calls XPropertySet-version of this method
110 void ExportStartOrEndRedline(
111 /// XTextContent; must also be an XPropertySet
112 const css::uno::Reference
<css::text::XTextContent
> & rContent
,
115 /// convenience method, calls XPropertySet-version of this method
116 void ExportStartOrEndRedline(
117 /// XTextSection; must also be an XPropertySet
118 const css::uno::Reference
<css::text::XTextSection
> & rSection
,
123 /// export the change mark contained in the text body
124 void ExportChangeInline(
125 /// PropertySet of RedlinePortion
126 const css::uno::Reference
<css::beans::XPropertySet
> & rPropSet
);
128 /// export the auto styles used in this change
129 void ExportChangeAutoStyle(
130 /// PropertySet of RedlinePortion
131 const css::uno::Reference
<css::beans::XPropertySet
> & rPropSet
);
133 /// export the changes list (<text:tracked-changes>)
134 void ExportChangesListElements();
136 /// export the auto styles needed by the changes list
137 void ExportChangesListAutoStyles();
139 /// export the changed-region element
140 void ExportChangedRegion(
141 const css::uno::Reference
<css::beans::XPropertySet
> & rPropSet
);
143 /// export a change-info element (from a PropertySet)
144 void ExportChangeInfo(
145 const css::uno::Reference
<css::beans::XPropertySet
> & rPropSet
);
147 /// export a change-info element (from PropertyValues)
148 void ExportChangeInfo(
149 const css::uno::Sequence
<css::beans::PropertyValue
> & rValues
);
151 /// convert the change type from API to XML names
152 OUString
const & ConvertTypeName(std::u16string_view sApiName
);
155 static OUString
GetRedlineID(
156 const css::uno::Reference
<css::beans::XPropertySet
> & rPropSet
);
158 /// write a comment string as sequence of <text:p> elements
159 void WriteComment(std::u16string_view rComment
);
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */