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 .
20 #ifndef INCLUDED_XMLOFF_SOURCE_TEXT_XMLREDLINEEXPORT_HXX
21 #define INCLUDED_XMLOFF_SOURCE_TEXT_XMLREDLINEEXPORT_HXX
23 #include <com/sun/star/uno/Reference.h>
24 #include <com/sun/star/uno/Sequence.h>
31 namespace com::sun::star
{
32 namespace beans
{ class XPropertySet
; }
33 namespace beans
{ struct PropertyValue
; }
34 namespace text
{ class XText
; }
35 namespace text
{ class XTextContent
; }
36 namespace text
{ class XTextSection
; }
39 // store a list of redline properties
40 typedef ::std::vector
<
41 css::uno::Reference
<css::beans::XPropertySet
> > ChangesVectorType
;
43 // store a list of redline properties for each XText
45 css::uno::Reference
< css::text::XText
>,
46 std::unique_ptr
<ChangesVectorType
> > ChangesMapType
;
50 * This class handles the export of redline portions.
51 * It is to be called from XMLTextParagraphExport.
53 class XMLRedlineExport
55 const OUString sDeletion
;
56 const OUString sFormatChange
;
57 const OUString sInsertion
;
62 // handling of change recording:
64 // To support change tracking in headers and footers we need to
65 // write these changes separately. To do this, we record the
66 // changes for headers and footers. For the main document body, we
67 // get the complete list of changes from the document, which
68 // should be much more efficient than recording all of those.
70 ChangesMapType aChangeMap
; /// map of recorded changes
72 /// list of current changes; is NULL or points to member of aChangeMap
73 ChangesVectorType
* pCurrentChangesList
;
77 explicit XMLRedlineExport(SvXMLExport
& rExp
);
83 /// PropertySet of RedlinePortion
84 const css::uno::Reference
<css::beans::XPropertySet
> & rPropSet
,
87 /// export the list of changes (complete list minus recorded changed)
88 void ExportChangesList(bool bAutoStyles
);
90 /// export the list of changes (recorded changes for this XText only)
91 void ExportChangesList(
92 const css::uno::Reference
<css::text::XText
> & rText
,
95 /// set the current XText for which changes should be recorded.
96 /// An empty XText means: don't record changes
98 const css::uno::Reference
<css::text::XText
> & rText
);
100 /// Do not record changes.
101 /// Same as SetCurrentXText(Reference<XText>) with empty argument.
102 void SetCurrentXText();
104 /// export redline marks which start or end at start nodes,
105 /// i.e. that include the complete paragraph/table/section
106 void ExportStartOrEndRedline(
107 const css::uno::Reference
<
108 css::beans::XPropertySet
> & rPropSet
,
109 bool bStart
); /// start or end of text entity (e.g. paragraph)?
111 /// convenience method, calls XPropertySet-version of this method
112 void ExportStartOrEndRedline(
113 /// XTextContent; must also be an XPropertySet
114 const css::uno::Reference
<css::text::XTextContent
> & rContent
,
117 /// convenience method, calls XPropertySet-version of this method
118 void ExportStartOrEndRedline(
119 /// XTextSection; must also be an XPropertySet
120 const css::uno::Reference
<css::text::XTextSection
> & rSection
,
125 /// export the change mark contained in the text body
126 void ExportChangeInline(
127 /// PropertySet of RedlinePortion
128 const css::uno::Reference
<css::beans::XPropertySet
> & rPropSet
);
130 /// export the auto styles used in this change
131 void ExportChangeAutoStyle(
132 /// PropertySet of RedlinePortion
133 const css::uno::Reference
<css::beans::XPropertySet
> & rPropSet
);
135 /// export the changes list (<text:tracked-changes>)
136 void ExportChangesListElements();
138 /// export the auto styles needed by the changes list
139 void ExportChangesListAutoStyles();
141 /// export the changed-region element
142 void ExportChangedRegion(
143 const css::uno::Reference
<css::beans::XPropertySet
> & rPropSet
);
145 /// export a change-info element (from a PropertySet)
146 void ExportChangeInfo(
147 const css::uno::Reference
<css::beans::XPropertySet
> & rPropSet
);
149 /// export a change-info element (from PropertyValues)
150 void ExportChangeInfo(
151 const css::uno::Sequence
<css::beans::PropertyValue
> & rValues
);
153 /// convert the change type from API to XML names
154 OUString
const & ConvertTypeName(const OUString
& sApiName
);
157 static OUString
GetRedlineID(
158 const css::uno::Reference
<css::beans::XPropertySet
> & rPropSet
);
160 /// write a comment string as sequence of <text:p> elements
161 void WriteComment(const OUString
& rComment
);
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */