merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / text / XMLRedlineExport.hxx
blob1a51e71fae65e2b5feb4b745a41fcbcbf8979652
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLRedlineExport.hxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _XMLOFF_XMLREDLINEEXPORT_HXX
32 #define _XMLOFF_XMLREDLINEEXPORT_HXX
34 #include <rtl/ustrbuf.hxx>
35 #include <com/sun/star/uno/Reference.h>
36 #include <com/sun/star/uno/Sequence.h>
38 #include <list>
39 #include <map>
40 #include <set>
42 class SvXMLExport;
43 namespace com { namespace sun { namespace star {
44 namespace beans { class XPropertySet; }
45 namespace beans { struct PropertyValue; }
46 namespace text { class XText; }
47 namespace text { class XTextContent; }
48 namespace text { class XTextSection; }
49 } } }
50 namespace rtl {
51 class OUString;
52 class OUStringBuffer;
55 // store a list of redline properties
56 typedef ::std::list<
57 ::com::sun::star::uno::Reference<
58 ::com::sun::star::beans::XPropertySet> > ChangesListType;
60 // store a list of redline properties for each XText
61 typedef ::std::map<
62 ::com::sun::star::uno::Reference< ::com::sun::star::text::XText>,
63 ChangesListType* > ChangesMapType;
66 /**
67 * This class handles the export of redline portions.
68 * It is to be called from XMLTextParagraphExport.
70 class XMLRedlineExport
72 const ::rtl::OUString sDelete;
73 const ::rtl::OUString sDeletion;
74 const ::rtl::OUString sFormat;
75 const ::rtl::OUString sFormatChange;
76 const ::rtl::OUString sInsert;
77 const ::rtl::OUString sInsertion;
78 const ::rtl::OUString sIsCollapsed;
79 const ::rtl::OUString sIsStart;
80 const ::rtl::OUString sRedlineAuthor;
81 const ::rtl::OUString sRedlineComment;
82 const ::rtl::OUString sRedlineDateTime;
83 const ::rtl::OUString sRedlineSuccessorData;
84 const ::rtl::OUString sRedlineText;
85 const ::rtl::OUString sRedlineType;
86 const ::rtl::OUString sStyle;
87 const ::rtl::OUString sTextTable;
88 const ::rtl::OUString sUnknownChange;
89 const ::rtl::OUString sStartRedline;
90 const ::rtl::OUString sEndRedline;
91 const ::rtl::OUString sRedlineIdentifier;
92 const ::rtl::OUString sIsInHeaderFooter;
93 const ::rtl::OUString sRedlineProtectionKey;
94 const ::rtl::OUString sRecordChanges;
95 const ::rtl::OUString sMergeLastPara;
97 const ::rtl::OUString sChangePrefix;
99 SvXMLExport& rExport;
102 // handling of change recording:
104 // To support change tracking in headers and footers we need to
105 // write these changes separately. To do this, we record the
106 // changes for headers and footers. For the main document body, we
107 // get the complete list of changes from the document, which
108 // should be much more efficient than recording all of those.
110 ChangesMapType aChangeMap; /// map of recorded changes
112 /// list of current changes; is NULL or points to member of aChangeMap
113 ChangesListType* pCurrentChangesList;
116 public:
117 XMLRedlineExport(SvXMLExport& rExp);
119 ~XMLRedlineExport();
121 /// export a change
122 void ExportChange(
123 /// PropertySet of RedlinePortion
124 const ::com::sun::star::uno::Reference<
125 ::com::sun::star::beans::XPropertySet> & rPropSet,
126 sal_Bool bAutoStyle);
128 /// export the list of changes (complete list minus recorded changed)
129 void ExportChangesList(sal_Bool bAutoStyles);
131 /// export the list of changes (recorded changes for this XText only)
132 void ExportChangesList(
133 const ::com::sun::star::uno::Reference<
134 ::com::sun::star::text::XText> & rText,
135 sal_Bool bAutoStyles);
137 /// set the current XText for which changes should be recorded.
138 /// An empty XText means: don't record changes
139 void SetCurrentXText(
140 const ::com::sun::star::uno::Reference<
141 ::com::sun::star::text::XText> & rText);
143 /// Do not record changes.
144 /// Same as SetCurrentXText(Reference<XText>) with empty argument.
145 void SetCurrentXText();
147 /// export redline marks which start or end at start nodes,
148 /// i.e. that include the complete paragraph/table/section
149 void ExportStartOrEndRedline(
150 const ::com::sun::star::uno::Reference<
151 ::com::sun::star::beans::XPropertySet> & rPropSet,
152 sal_Bool bStart); /// start or end of text entity (e.g. paragraph)?
154 /// convenience method, calls XPropertySet-version of this method
155 void ExportStartOrEndRedline(
156 /// XTextContent; must also be an XPropertySet
157 const ::com::sun::star::uno::Reference<
158 ::com::sun::star::text::XTextContent> & rContent,
159 sal_Bool bStart);
161 /// convenience method, calls XPropertySet-version of this method
162 void ExportStartOrEndRedline(
163 /// XTextSection; must also be an XPropertySet
164 const ::com::sun::star::uno::Reference<
165 ::com::sun::star::text::XTextSection> & rSection,
166 sal_Bool bStart);
168 private:
170 /// export the change mark contained in the text body
171 void ExportChangeInline(
172 /// PropertySet of RedlinePortion
173 const ::com::sun::star::uno::Reference<
174 ::com::sun::star::beans::XPropertySet> & rPropSet);
176 /// export the auto styles used in this change
177 void ExportChangeAutoStyle(
178 /// PropertySet of RedlinePortion
179 const ::com::sun::star::uno::Reference<
180 ::com::sun::star::beans::XPropertySet> & rPropSet);
182 /// export the changes list (<text:tracked-changes>)
183 void ExportChangesListElements();
185 /// export the auto styles needed by the changes list
186 void ExportChangesListAutoStyles();
188 /// export the changed-region element
189 void ExportChangedRegion(
190 const ::com::sun::star::uno::Reference<
191 ::com::sun::star::beans::XPropertySet> & rPropSet);
193 /// export an change-info element (from a PropertySet)
194 void ExportChangeInfo(
195 const ::com::sun::star::uno::Reference<
196 ::com::sun::star::beans::XPropertySet> & rPropSet);
198 /// export an change-info element (from PropertyValues)
199 void ExportChangeInfo(
200 const ::com::sun::star::uno::Sequence<
201 ::com::sun::star::beans::PropertyValue> & rValues);
203 /// convert the change type from API to XML names
204 const ::rtl::OUString ConvertTypeName(const ::rtl::OUString& sApiName);
206 /// Get ID string!
207 const ::rtl::OUString GetRedlineID(
208 const ::com::sun::star::uno::Reference<
209 ::com::sun::star::beans::XPropertySet> & rPropSet);
211 /// write a comment string as sequence of <text:p> elements
212 void WriteComment(const ::rtl::OUString& rComment);
215 #endif