1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include "XMLRedlineExport.hxx"
27 #include <tools/debug.hxx>
28 #include <rtl/ustring.hxx>
29 #include <rtl/ustrbuf.hxx>
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <com/sun/star/beans/UnknownPropertyException.hpp>
32 #include <com/sun/star/container/XEnumerationAccess.hpp>
33 
34 #include <com/sun/star/container/XEnumeration.hpp>
35 #include <com/sun/star/document/XRedlinesSupplier.hpp>
36 #include <com/sun/star/text/XText.hpp>
37 #include <com/sun/star/text/XTextContent.hpp>
38 #include <com/sun/star/text/XTextSection.hpp>
39 #include <com/sun/star/util/DateTime.hpp>
40 #include <xmloff/xmltoken.hxx>
41 #include "xmloff/xmlnmspe.hxx"
42 #include <xmloff/xmlexp.hxx>
43 #include <xmloff/xmluconv.hxx>
44 
45 
46 using namespace ::com::sun::star;
47 using namespace ::xmloff::token;
48 
49 using ::com::sun::star::beans::PropertyValue;
50 using ::com::sun::star::beans::XPropertySet;
51 using ::com::sun::star::beans::UnknownPropertyException;
52 using ::com::sun::star::document::XRedlinesSupplier;
53 using ::com::sun::star::container::XEnumerationAccess;
54 using ::com::sun::star::container::XEnumeration;
55 using ::com::sun::star::text::XText;
56 using ::com::sun::star::text::XTextContent;
57 using ::com::sun::star::text::XTextSection;
58 using ::com::sun::star::uno::Any;
59 using ::com::sun::star::uno::Reference;
60 using ::com::sun::star::uno::Sequence;
61 using ::com::sun::star::util::DateTime;
62 using ::rtl::OUString;
63 using ::rtl::OUStringBuffer;
64 using ::std::list;
65 
66 
XMLRedlineExport(SvXMLExport & rExp)67 XMLRedlineExport::XMLRedlineExport(SvXMLExport& rExp)
68 :	sDelete(RTL_CONSTASCII_USTRINGPARAM("Delete"))
69 ,	sDeletion(GetXMLToken(XML_DELETION))
70 ,	sFormat(RTL_CONSTASCII_USTRINGPARAM("Format"))
71 ,	sFormatChange(GetXMLToken(XML_FORMAT_CHANGE))
72 ,	sInsert(RTL_CONSTASCII_USTRINGPARAM("Insert"))
73 ,	sInsertion(GetXMLToken(XML_INSERTION))
74 ,	sIsCollapsed(RTL_CONSTASCII_USTRINGPARAM("IsCollapsed"))
75 ,	sIsStart(RTL_CONSTASCII_USTRINGPARAM("IsStart"))
76 ,	sRedlineAuthor(RTL_CONSTASCII_USTRINGPARAM("RedlineAuthor"))
77 ,	sRedlineComment(RTL_CONSTASCII_USTRINGPARAM("RedlineComment"))
78 ,	sRedlineDateTime(RTL_CONSTASCII_USTRINGPARAM("RedlineDateTime"))
79 ,	sRedlineSuccessorData(RTL_CONSTASCII_USTRINGPARAM("RedlineSuccessorData"))
80 ,	sRedlineText(RTL_CONSTASCII_USTRINGPARAM("RedlineText"))
81 ,	sRedlineType(RTL_CONSTASCII_USTRINGPARAM("RedlineType"))
82 ,	sStyle(RTL_CONSTASCII_USTRINGPARAM("Style"))
83 ,	sTextTable(RTL_CONSTASCII_USTRINGPARAM("TextTable"))
84 ,	sUnknownChange(RTL_CONSTASCII_USTRINGPARAM("UnknownChange"))
85 ,	sStartRedline(RTL_CONSTASCII_USTRINGPARAM("StartRedline"))
86 ,	sEndRedline(RTL_CONSTASCII_USTRINGPARAM("EndRedline"))
87 ,	sRedlineIdentifier(RTL_CONSTASCII_USTRINGPARAM("RedlineIdentifier"))
88 ,	sIsInHeaderFooter(RTL_CONSTASCII_USTRINGPARAM("IsInHeaderFooter"))
89 ,	sRedlineProtectionKey(RTL_CONSTASCII_USTRINGPARAM("RedlineProtectionKey"))
90 ,	sRecordChanges(RTL_CONSTASCII_USTRINGPARAM("RecordChanges"))
91 ,	sMergeLastPara(RTL_CONSTASCII_USTRINGPARAM("MergeLastPara"))
92 ,	sChangePrefix(RTL_CONSTASCII_USTRINGPARAM("ct"))
93 ,	rExport(rExp)
94 ,	pCurrentChangesList(NULL)
95 {
96 }
97 
98 
~XMLRedlineExport()99 XMLRedlineExport::~XMLRedlineExport()
100 {
101 	// delete changes lists
102 	for( ChangesMapType::iterator aIter = aChangeMap.begin();
103 		 aIter != aChangeMap.end();
104 		 aIter++ )
105 	{
106 		delete aIter->second;
107 	}
108 	aChangeMap.clear();
109 }
110 
111 
ExportChange(const Reference<XPropertySet> & rPropSet,sal_Bool bAutoStyle)112 void XMLRedlineExport::ExportChange(
113 	const Reference<XPropertySet> & rPropSet,
114 	sal_Bool bAutoStyle)
115 {
116 	if (bAutoStyle)
117 	{
118         // For the headers/footers, we have to collect the autostyles
119         // here.  For the general case, however, it's better to collet
120         // the autostyles by iterating over the global redline
121         // list. So that's what we do: Here, we collect autostyles
122         // only if we have no current list of changes. For the
123         // main-document case, the autostyles are collected in
124         // ExportChangesListAutoStyles().
125         if (pCurrentChangesList != NULL)
126             ExportChangeAutoStyle(rPropSet);
127 	}
128 	else
129 	{
130 		ExportChangeInline(rPropSet);
131 	}
132 }
133 
134 
ExportChangesList(sal_Bool bAutoStyles)135 void XMLRedlineExport::ExportChangesList(sal_Bool bAutoStyles)
136 {
137 	if (bAutoStyles)
138 	{
139 		ExportChangesListAutoStyles();
140 	}
141 	else
142 	{
143 		ExportChangesListElements();
144 	}
145 }
146 
147 
ExportChangesList(const Reference<XText> & rText,sal_Bool bAutoStyles)148 void XMLRedlineExport::ExportChangesList(
149 	const Reference<XText> & rText,
150 	sal_Bool bAutoStyles)
151 {
152     // in the header/footer case, auto styles are collected from the
153     // inline change elements.
154     if (bAutoStyles)
155         return;
156 
157 	// look for changes list for this XText
158 	ChangesMapType::iterator aFind = aChangeMap.find(rText);
159 	if (aFind != aChangeMap.end())
160 	{
161 		ChangesListType* pChangesList = aFind->second;
162 
163 		// export only if changes are found
164 		if (pChangesList->size() > 0)
165 		{
166 			// changes container element
167 			SvXMLElementExport aChanges(rExport, XML_NAMESPACE_TEXT,
168 										XML_TRACKED_CHANGES,
169 										sal_True, sal_True);
170 
171 			// iterate over changes list
172 			for( ChangesListType::iterator aIter = pChangesList->begin();
173 				 aIter != pChangesList->end();
174 				 aIter++ )
175 			{
176                 ExportChangedRegion( *aIter );
177 			}
178 		}
179 		// else: changes list empty -> ignore
180 	}
181 	// else: no changes list found -> empty
182 }
183 
SetCurrentXText(const Reference<XText> & rText)184 void XMLRedlineExport::SetCurrentXText(
185 	const Reference<XText> & rText)
186 {
187 	if (rText.is())
188 	{
189 		// look for appropriate list in map; use the found one, or create new
190 		ChangesMapType::iterator aIter = aChangeMap.find(rText);
191 		if (aIter == aChangeMap.end())
192 		{
193 			ChangesListType* pList = new ChangesListType;
194 			aChangeMap[rText] = pList;
195 			pCurrentChangesList = pList;
196 		}
197 		else
198 			pCurrentChangesList = aIter->second;
199 	}
200 	else
201 	{
202 		// don't record changes
203 		SetCurrentXText();
204 	}
205 }
206 
SetCurrentXText()207 void XMLRedlineExport::SetCurrentXText()
208 {
209 	pCurrentChangesList = NULL;
210 }
211 
212 
ExportChangesListElements()213 void XMLRedlineExport::ExportChangesListElements()
214 {
215 	// get redlines (aka tracked changes) from the model
216 	Reference<XRedlinesSupplier> xSupplier(rExport.GetModel(), uno::UNO_QUERY);
217 	if (xSupplier.is())
218 	{
219 		Reference<XEnumerationAccess> aEnumAccess = xSupplier->getRedlines();
220 
221 		// redline protection key
222 		Reference<XPropertySet> aDocPropertySet( rExport.GetModel(),
223 												 uno::UNO_QUERY );
224 		// redlining enabled?
225 		sal_Bool bEnabled = *(sal_Bool*)aDocPropertySet->getPropertyValue(
226 												sRecordChanges ).getValue();
227 
228 		// only export if we have redlines or attributes
229 		if ( aEnumAccess->hasElements() || bEnabled )
230 		{
231 
232 			// export only if we have changes, but tracking is not enabled
233 			if ( !bEnabled != !aEnumAccess->hasElements() )
234 			{
235 				rExport.AddAttribute(
236 					XML_NAMESPACE_TEXT, XML_TRACK_CHANGES,
237 					bEnabled ? XML_TRUE : XML_FALSE );
238 			}
239 
240 			// changes container element
241 			SvXMLElementExport aChanges(rExport, XML_NAMESPACE_TEXT,
242 										XML_TRACKED_CHANGES,
243 										sal_True, sal_True);
244 
245 			// get enumeration and iterate over elements
246 			Reference<XEnumeration> aEnum = aEnumAccess->createEnumeration();
247 			while (aEnum->hasMoreElements())
248 			{
249 				Any aAny = aEnum->nextElement();
250 				Reference<XPropertySet> xPropSet;
251 				aAny >>= xPropSet;
252 
253 				DBG_ASSERT(xPropSet.is(),
254 						   "can't get XPropertySet; skipping Redline");
255 				if (xPropSet.is())
256 				{
257 					// export only if not in header or footer
258 					// (those must be exported with their XText)
259 					aAny = xPropSet->getPropertyValue(sIsInHeaderFooter);
260 					if (! *(sal_Bool*)aAny.getValue())
261 					{
262 						// and finally, export change
263 						ExportChangedRegion(xPropSet);
264 					}
265 				}
266 				// else: no XPropertySet -> no export
267 			}
268 		}
269 		// else: no redlines -> no export
270 	}
271 	// else: no XRedlineSupplier -> no export
272 }
273 
ExportChangeAutoStyle(const Reference<XPropertySet> & rPropSet)274 void XMLRedlineExport::ExportChangeAutoStyle(
275 	const Reference<XPropertySet> & rPropSet)
276 {
277 	// record change (if changes should be recorded)
278 	if (NULL != pCurrentChangesList)
279 	{
280 		// put redline in list if it's collapsed or the redline start
281 		Any aIsStart = rPropSet->getPropertyValue(sIsStart);
282 		Any aIsCollapsed = rPropSet->getPropertyValue(sIsCollapsed);
283 
284 		if ( *(sal_Bool*)aIsStart.getValue() ||
285 			 *(sal_Bool*)aIsCollapsed.getValue() )
286 			pCurrentChangesList->push_back(rPropSet);
287 	}
288 
289 	// get XText for export of redline auto styles
290 	Any aAny = rPropSet->getPropertyValue(sRedlineText);
291 	Reference<XText> xText;
292 	aAny >>= xText;
293 	if (xText.is())
294 	{
295 		// export the auto styles
296 		rExport.GetTextParagraphExport()->collectTextAutoStyles(xText);
297 	}
298 }
299 
ExportChangesListAutoStyles()300 void XMLRedlineExport::ExportChangesListAutoStyles()
301 {
302 	// get redlines (aka tracked changes) from the model
303 	Reference<XRedlinesSupplier> xSupplier(rExport.GetModel(), uno::UNO_QUERY);
304 	if (xSupplier.is())
305 	{
306 		Reference<XEnumerationAccess> aEnumAccess = xSupplier->getRedlines();
307 
308 		// only export if we actually have redlines
309 		if (aEnumAccess->hasElements())
310 		{
311 			// get enumeration and iterate over elements
312 			Reference<XEnumeration> aEnum = aEnumAccess->createEnumeration();
313 			while (aEnum->hasMoreElements())
314 			{
315 				Any aAny = aEnum->nextElement();
316 				Reference<XPropertySet> xPropSet;
317 				aAny >>= xPropSet;
318 
319 				DBG_ASSERT(xPropSet.is(),
320 						   "can't get XPropertySet; skipping Redline");
321 				if (xPropSet.is())
322 				{
323 
324                     // export only if not in header or footer
325                     // (those must be exported with their XText)
326                     aAny = xPropSet->getPropertyValue(sIsInHeaderFooter);
327                     if (! *(sal_Bool*)aAny.getValue())
328 					{
329                         ExportChangeAutoStyle(xPropSet);
330                     }
331 				}
332 			}
333 		}
334 	}
335 }
336 
ExportChangeInline(const Reference<XPropertySet> & rPropSet)337 void XMLRedlineExport::ExportChangeInline(
338 	const Reference<XPropertySet> & rPropSet)
339 {
340 	// determine element name (depending on collapsed, start/end)
341 	enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
342 	Any aAny = rPropSet->getPropertyValue(sIsCollapsed);
343 	sal_Bool bCollapsed = *(sal_Bool *)aAny.getValue();
344 	sal_Bool bStart = sal_True;	// ignored if bCollapsed = sal_True
345 	if (bCollapsed)
346 	{
347 		eElement = XML_CHANGE;
348 	}
349 	else
350 	{
351 		aAny = rPropSet->getPropertyValue(sIsStart);
352 		bStart = *(sal_Bool *)aAny.getValue();
353 		eElement = bStart ? XML_CHANGE_START : XML_CHANGE_END;
354 	}
355 
356 	if (XML_TOKEN_INVALID != eElement)
357 	{
358 		// we always need the ID
359 		rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_CHANGE_ID,
360 							 GetRedlineID(rPropSet));
361 
362 		// export the element (no whitespace because we're in the text body)
363 		SvXMLElementExport aChangeElem(rExport, XML_NAMESPACE_TEXT,
364 									   eElement, sal_False, sal_False);
365 	}
366 }
367 
368 
ExportChangedRegion(const Reference<XPropertySet> & rPropSet)369 void XMLRedlineExport::ExportChangedRegion(
370 	const Reference<XPropertySet> & rPropSet)
371 {
372 	// Redline-ID
373     rExport.AddAttributeIdLegacy(XML_NAMESPACE_TEXT, GetRedlineID(rPropSet));
374 
375     // merge-last-paragraph
376     Any aAny = rPropSet->getPropertyValue(sMergeLastPara);
377     if( ! *(sal_Bool*)aAny.getValue() )
378         rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_MERGE_LAST_PARAGRAPH,
379                              XML_FALSE);
380 
381     // export change region element
382 	SvXMLElementExport aChangedRegion(rExport, XML_NAMESPACE_TEXT,
383 									  XML_CHANGED_REGION, sal_True, sal_True);
384 
385 
386 	// scope for (first) change element
387 	{
388 		aAny = rPropSet->getPropertyValue(sRedlineType);
389 		OUString sType;
390 		aAny >>= sType;
391 		SvXMLElementExport aChange(rExport, XML_NAMESPACE_TEXT,
392 								   ConvertTypeName(sType), sal_True, sal_True);
393 
394 		ExportChangeInfo(rPropSet);
395 
396 		// get XText from the redline and export (if the XText exists)
397 		aAny = rPropSet->getPropertyValue(sRedlineText);
398 		Reference<XText> xText;
399 		aAny >>= xText;
400 		if (xText.is())
401 		{
402 			rExport.GetTextParagraphExport()->exportText(xText);
403 			// default parameters: bProgress, bExportParagraph ???
404 		}
405 		// else: no text interface -> content is inline and will
406 		//       be exported there
407 	}
408 
409 	// changed change? Hierarchical changes can onl be two levels
410 	// deep. Here we check for the second level.
411 	aAny = rPropSet->getPropertyValue(sRedlineSuccessorData);
412 	Sequence<PropertyValue> aSuccessorData;
413 	aAny >>= aSuccessorData;
414 
415 	// if we actually got a hierarchical change, make element and
416 	// process change info
417 	if (aSuccessorData.getLength() > 0)
418 	{
419 		// The only change that can be "undone" is an insertion -
420 		// after all, you can't re-insert an deletion, but you can
421 		// delete an insertion. This assumption is asserted in
422 		// ExportChangeInfo(Sequence<PropertyValue>&).
423 		SvXMLElementExport aSecondChangeElem(
424 			rExport, XML_NAMESPACE_TEXT, XML_INSERTION,
425 			sal_True, sal_True);
426 
427 		ExportChangeInfo(aSuccessorData);
428 	}
429 	// else: no hierarchical change
430 }
431 
432 
ConvertTypeName(const OUString & sApiName)433 const OUString XMLRedlineExport::ConvertTypeName(
434 	const OUString& sApiName)
435 {
436 	if (sApiName == sDelete)
437 	{
438 		return sDeletion;
439 	}
440 	else if (sApiName == sInsert)
441 	{
442 		return sInsertion;
443 	}
444 	else if (sApiName == sFormat)
445 	{
446 		return sFormatChange;
447 	}
448 	else
449 	{
450 		DBG_ERROR("unknown redline type");
451 		return sUnknownChange;
452 	}
453 }
454 
455 
456 /** Create a Redline-ID */
GetRedlineID(const Reference<XPropertySet> & rPropSet)457 const OUString XMLRedlineExport::GetRedlineID(
458 	const Reference<XPropertySet> & rPropSet)
459 {
460 	Any aAny = rPropSet->getPropertyValue(sRedlineIdentifier);
461 	OUString sTmp;
462 	aAny >>= sTmp;
463 
464 	OUStringBuffer sBuf(sChangePrefix);
465 	sBuf.append(sTmp);
466 	return sBuf.makeStringAndClear();
467 }
468 
469 
ExportChangeInfo(const Reference<XPropertySet> & rPropSet)470 void XMLRedlineExport::ExportChangeInfo(
471 	const Reference<XPropertySet> & rPropSet)
472 {
473 
474 	SvXMLElementExport aChangeInfo(rExport, XML_NAMESPACE_OFFICE,
475 								   XML_CHANGE_INFO, sal_True, sal_True);
476 
477 	Any aAny = rPropSet->getPropertyValue(sRedlineAuthor);
478 	OUString sTmp;
479 	aAny >>= sTmp;
480 	if (sTmp.getLength() > 0)
481 	{
482 		SvXMLElementExport aCreatorElem( rExport, XML_NAMESPACE_DC,
483 										  XML_CREATOR, sal_True,
484 										  sal_False );
485 		rExport.Characters(sTmp);
486 	}
487 
488 	aAny = rPropSet->getPropertyValue(sRedlineDateTime);
489 	util::DateTime aDateTime;
490 	aAny >>= aDateTime;
491 	{
492 		OUStringBuffer sBuf;
493 		rExport.GetMM100UnitConverter().convertDateTime(sBuf, aDateTime);
494 		SvXMLElementExport aDateElem( rExport, XML_NAMESPACE_DC,
495 										  XML_DATE, sal_True,
496 										  sal_False );
497 		rExport.Characters(sBuf.makeStringAndClear());
498 	}
499 
500 	// comment as <text:p> sequence
501 	aAny = rPropSet->getPropertyValue(sRedlineComment);
502 	aAny >>= sTmp;
503     WriteComment( sTmp );
504 }
505 
ExportChangeInfo(const Sequence<PropertyValue> & rPropertyValues)506 void XMLRedlineExport::ExportChangeInfo(
507 	const Sequence<PropertyValue> & rPropertyValues)
508 {
509     OUString sComment;
510 
511 	sal_Int32 nCount = rPropertyValues.getLength();
512 	for(sal_Int32 i = 0; i < nCount; i++)
513 	{
514 		const PropertyValue& rVal = rPropertyValues[i];
515 
516 		if( rVal.Name.equals(sRedlineAuthor) )
517 		{
518 			OUString sTmp;
519 			rVal.Value >>= sTmp;
520 			if (sTmp.getLength() > 0)
521 			{
522 				rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_CHG_AUTHOR, sTmp);
523 			}
524 		}
525         else if( rVal.Name.equals(sRedlineComment) )
526         {
527             rVal.Value >>= sComment;
528         }
529 		else if( rVal.Name.equals(sRedlineDateTime) )
530 		{
531 			util::DateTime aDateTime;
532 			rVal.Value >>= aDateTime;
533 			OUStringBuffer sBuf;
534 			rExport.GetMM100UnitConverter().convertDateTime(sBuf, aDateTime);
535 			rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_CHG_DATE_TIME,
536 								 sBuf.makeStringAndClear());
537 		}
538 		else if( rVal.Name.equals(sRedlineType) )
539 		{
540 			// check if this is an insertion; cf. comment at calling location
541 			OUString sTmp;
542 			rVal.Value >>= sTmp;
543 			DBG_ASSERT(sTmp.equals(sInsert),
544 					   "hierarchical change must be insertion");
545 		}
546 		// else: unknown value -> ignore
547 	}
548 
549 	// finally write element
550 	SvXMLElementExport aChangeInfo(rExport, XML_NAMESPACE_OFFICE,
551 								   XML_CHANGE_INFO, sal_True, sal_True);
552 
553     WriteComment( sComment );
554 }
555 
ExportStartOrEndRedline(const Reference<XPropertySet> & rPropSet,sal_Bool bStart)556 void XMLRedlineExport::ExportStartOrEndRedline(
557 	const Reference<XPropertySet> & rPropSet,
558 	sal_Bool bStart)
559 {
560     if( ! rPropSet.is() )
561         return;
562 
563 	// get appropriate (start or end) property
564 	Any aAny;
565     try
566     {
567         aAny = rPropSet->getPropertyValue(bStart ? sStartRedline : sEndRedline);
568     }
569     catch( UnknownPropertyException e )
570     {
571         // If we don't have the property, there's nothing to do.
572         return;
573     }
574 
575 	Sequence<PropertyValue> aValues;
576 	aAny >>= aValues;
577     const PropertyValue* pValues = aValues.getConstArray();
578 
579 	// seek for redline properties
580     sal_Bool bIsCollapsed = sal_False;
581     sal_Bool bIsStart = sal_True;
582     OUString sId;
583     sal_Bool bIdOK = sal_False; // have we seen an ID?
584 	sal_Int32 nLength = aValues.getLength();
585 	for(sal_Int32 i = 0; i < nLength; i++)
586 	{
587 		if (sRedlineIdentifier.equals(pValues[i].Name))
588 		{
589 			pValues[i].Value >>= sId;
590             bIdOK = sal_True;
591         }
592         else if (sIsCollapsed.equals(pValues[i].Name))
593         {
594             bIsCollapsed = *(sal_Bool*)pValues[i].Value.getValue();
595         }
596         else if (sIsStart.equals(pValues[i].Name))
597         {
598             bIsStart = *(sal_Bool*)pValues[i].Value.getValue();
599         }
600     }
601 
602     if( bIdOK )
603     {
604         DBG_ASSERT( sId.getLength() > 0, "Redlines must have IDs" );
605 
606         // TODO: use GetRedlineID or elimiate that function
607         OUStringBuffer sBuffer(sChangePrefix);
608         sBuffer.append(sId);
609 
610         rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_CHANGE_ID,
611                              sBuffer.makeStringAndClear());
612 
613         // export the element
614         // (whitespace because we're not inside paragraphs)
615         SvXMLElementExport aChangeElem(
616             rExport, XML_NAMESPACE_TEXT,
617             bIsCollapsed ? XML_CHANGE :
618                 ( bIsStart ? XML_CHANGE_START : XML_CHANGE_END ),
619             sal_True, sal_True);
620     }
621 }
622 
ExportStartOrEndRedline(const Reference<XTextContent> & rContent,sal_Bool bStart)623 void XMLRedlineExport::ExportStartOrEndRedline(
624 	const Reference<XTextContent> & rContent,
625 	sal_Bool bStart)
626 {
627 	Reference<XPropertySet> xPropSet(rContent, uno::UNO_QUERY);
628 	if (xPropSet.is())
629 	{
630 		ExportStartOrEndRedline(xPropSet, bStart);
631 	}
632 	else
633 	{
634 		DBG_ERROR("XPropertySet expected");
635 	}
636 }
637 
ExportStartOrEndRedline(const Reference<XTextSection> & rSection,sal_Bool bStart)638 void XMLRedlineExport::ExportStartOrEndRedline(
639 	const Reference<XTextSection> & rSection,
640 	sal_Bool bStart)
641 {
642 	Reference<XPropertySet> xPropSet(rSection, uno::UNO_QUERY);
643 	if (xPropSet.is())
644 	{
645 		ExportStartOrEndRedline(xPropSet, bStart);
646 	}
647 	else
648 	{
649 		DBG_ERROR("XPropertySet expected");
650 	}
651 }
652 
WriteComment(const OUString & rComment)653 void XMLRedlineExport::WriteComment(const OUString& rComment)
654 {
655 	if (rComment.getLength() > 0)
656 	{
657 		// iterate over all string-pieces separated by return (0x0a) and
658 		// put each inside a paragraph element.
659 		SvXMLTokenEnumerator aEnumerator(rComment, sal_Char(0x0a));
660 		OUString aSubString;
661 		while (aEnumerator.getNextToken(aSubString))
662 		{
663 			SvXMLElementExport aParagraph(
664 				rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False);
665 			rExport.Characters(aSubString);
666 		}
667 	}
668 }
669