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