bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / text / XMLRedlineExport.hxx
blobf0a43958fe65eb320aac3ac9901ec811b5f3554d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <rtl/ustrbuf.hxx>
24 #include <com/sun/star/uno/Reference.h>
25 #include <com/sun/star/uno/Sequence.h>
27 #include <list>
28 #include <map>
30 class SvXMLExport;
31 namespace com { namespace sun { namespace 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; }
37 } } }
39 // store a list of redline properties
40 typedef ::std::list<
41 ::com::sun::star::uno::Reference<
42 ::com::sun::star::beans::XPropertySet> > ChangesListType;
44 // store a list of redline properties for each XText
45 typedef ::std::map<
46 ::com::sun::star::uno::Reference< ::com::sun::star::text::XText>,
47 ChangesListType* > ChangesMapType;
50 /**
51 * This class handles the export of redline portions.
52 * It is to be called from XMLTextParagraphExport.
54 class XMLRedlineExport
56 const OUString sDelete;
57 const OUString sDeletion;
58 const OUString sFormat;
59 const OUString sFormatChange;
60 const OUString sInsert;
61 const OUString sInsertion;
62 const OUString sIsCollapsed;
63 const OUString sIsStart;
64 const OUString sRedlineAuthor;
65 const OUString sRedlineComment;
66 const OUString sRedlineDateTime;
67 const OUString sRedlineSuccessorData;
68 const OUString sRedlineText;
69 const OUString sRedlineType;
70 const OUString sUnknownChange;
71 const OUString sStartRedline;
72 const OUString sEndRedline;
73 const OUString sRedlineIdentifier;
74 const OUString sIsInHeaderFooter;
75 const OUString sRecordChanges;
76 const OUString sMergeLastPara;
78 const OUString sChangePrefix;
80 SvXMLExport& rExport;
83 // handling of change recording:
85 // To support change tracking in headers and footers we need to
86 // write these changes separately. To do this, we record the
87 // changes for headers and footers. For the main document body, we
88 // get the complete list of changes from the document, which
89 // should be much more efficient than recording all of those.
91 ChangesMapType aChangeMap; /// map of recorded changes
93 /// list of current changes; is NULL or points to member of aChangeMap
94 ChangesListType* pCurrentChangesList;
97 public:
98 XMLRedlineExport(SvXMLExport& rExp);
100 ~XMLRedlineExport();
102 /// export a change
103 void ExportChange(
104 /// PropertySet of RedlinePortion
105 const ::com::sun::star::uno::Reference<
106 ::com::sun::star::beans::XPropertySet> & rPropSet,
107 bool bAutoStyle);
109 /// export the list of changes (complete list minus recorded changed)
110 void ExportChangesList(bool bAutoStyles);
112 /// export the list of changes (recorded changes for this XText only)
113 void ExportChangesList(
114 const ::com::sun::star::uno::Reference<
115 ::com::sun::star::text::XText> & rText,
116 bool bAutoStyles);
118 /// set the current XText for which changes should be recorded.
119 /// An empty XText means: don't record changes
120 void SetCurrentXText(
121 const ::com::sun::star::uno::Reference<
122 ::com::sun::star::text::XText> & rText);
124 /// Do not record changes.
125 /// Same as SetCurrentXText(Reference<XText>) with empty argument.
126 void SetCurrentXText();
128 /// export redline marks which start or end at start nodes,
129 /// i.e. that include the complete paragraph/table/section
130 void ExportStartOrEndRedline(
131 const ::com::sun::star::uno::Reference<
132 ::com::sun::star::beans::XPropertySet> & rPropSet,
133 bool bStart); /// start or end of text entity (e.g. paragraph)?
135 /// convenience method, calls XPropertySet-version of this method
136 void ExportStartOrEndRedline(
137 /// XTextContent; must also be an XPropertySet
138 const ::com::sun::star::uno::Reference<
139 ::com::sun::star::text::XTextContent> & rContent,
140 bool bStart);
142 /// convenience method, calls XPropertySet-version of this method
143 void ExportStartOrEndRedline(
144 /// XTextSection; must also be an XPropertySet
145 const ::com::sun::star::uno::Reference<
146 ::com::sun::star::text::XTextSection> & rSection,
147 bool bStart);
149 private:
151 /// export the change mark contained in the text body
152 void ExportChangeInline(
153 /// PropertySet of RedlinePortion
154 const ::com::sun::star::uno::Reference<
155 ::com::sun::star::beans::XPropertySet> & rPropSet);
157 /// export the auto styles used in this change
158 void ExportChangeAutoStyle(
159 /// PropertySet of RedlinePortion
160 const ::com::sun::star::uno::Reference<
161 ::com::sun::star::beans::XPropertySet> & rPropSet);
163 /// export the changes list (<text:tracked-changes>)
164 void ExportChangesListElements();
166 /// export the auto styles needed by the changes list
167 void ExportChangesListAutoStyles();
169 /// export the changed-region element
170 void ExportChangedRegion(
171 const ::com::sun::star::uno::Reference<
172 ::com::sun::star::beans::XPropertySet> & rPropSet);
174 /// export an change-info element (from a PropertySet)
175 void ExportChangeInfo(
176 const ::com::sun::star::uno::Reference<
177 ::com::sun::star::beans::XPropertySet> & rPropSet);
179 /// export an change-info element (from PropertyValues)
180 void ExportChangeInfo(
181 const ::com::sun::star::uno::Sequence<
182 ::com::sun::star::beans::PropertyValue> & rValues);
184 /// convert the change type from API to XML names
185 const OUString ConvertTypeName(const OUString& sApiName);
187 /// Get ID string!
188 const OUString GetRedlineID(
189 const ::com::sun::star::uno::Reference<
190 ::com::sun::star::beans::XPropertySet> & rPropSet);
192 /// write a comment string as sequence of <text:p> elements
193 void WriteComment(const OUString& rComment);
196 #endif
198 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */