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