diff options
-rw-r--r-- | xmloff/source/text/XMLChangeImportContext.cxx | 154 | ||||
-rw-r--r-- | xmloff/source/text/XMLChangeImportContext.hxx | 124 | ||||
-rw-r--r-- | xmloff/source/text/XMLRedlineExport.cxx | 316 | ||||
-rw-r--r-- | xmloff/source/text/XMLRedlineExport.hxx | 49 | ||||
-rw-r--r-- | xmloff/source/text/XMLSectionImportContext.cxx | 21 | ||||
-rw-r--r-- | xmloff/source/text/makefile.mk | 6 | ||||
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 63 | ||||
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 18 | ||||
-rw-r--r-- | xmloff/source/text/txtparai.cxx | 101 | ||||
-rw-r--r-- | xmloff/source/text/txtsecte.cxx | 38 |
10 files changed, 671 insertions, 219 deletions
diff --git a/xmloff/source/text/XMLChangeImportContext.cxx b/xmloff/source/text/XMLChangeImportContext.cxx new file mode 100644 index 000000000000..96770c5bed2d --- /dev/null +++ b/xmloff/source/text/XMLChangeImportContext.cxx @@ -0,0 +1,154 @@ +/************************************************************************* + * + * $RCSfile: XMLChangeImportContext.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2001-01-19 18:38:06 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLCHANGEIMPORTCONTEXT_HXX +#include "XMLChangeImportContext.hxx" +#endif + +#ifndef _COM_SUN_STAR_TEXT_XTEXTRANGE_HPP_ +#include <com/sun/star/text/XTextRange.hpp> +#endif + +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +#ifndef _XMLOFF_XMLIMP_HXX +#include "xmlimp.hxx" +#endif + +#ifndef _XMLOFF_XMLNMSPE_HXX +#include "xmlnmspe.hxx" +#endif + +#ifndef _XMLOFF_NMSPMAP_HXX +#include "nmspmap.hxx" +#endif + +#ifndef _XMLOFF_XMLKYWD_HXX +#include "xmlkywd.hxx" +#endif + +using ::rtl::OUString; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::text::XTextRange; +using ::com::sun::star::xml::sax::XAttributeList; + +TYPEINIT1( XMLChangeImportContext, SvXMLImportContext ); + +XMLChangeImportContext::XMLChangeImportContext( + SvXMLImport& rImport, + sal_Int16 nPrefix, + const OUString& rLocalName, + sal_Bool bStart, + sal_Bool bEnd, + sal_Bool bOutsideOfParagraph) : + SvXMLImportContext(rImport, nPrefix, rLocalName), + bIsStart(bStart), + bIsEnd(bEnd), + bIsOutsideOfParagraph(bOutsideOfParagraph) +{ + DBG_ASSERT(bStart || bEnd, "Must be either start, end, or both!"); +} + +XMLChangeImportContext::~XMLChangeImportContext() +{ +} + +void XMLChangeImportContext::StartElement( + const Reference<XAttributeList>& xAttrList) +{ + sal_Int16 nLength = xAttrList->getLength(); + for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++) + { + OUString sLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), + &sLocalName ); + if ( (XML_NAMESPACE_TEXT == nPrefix) && + (sLocalName.equalsAsciiL(sXML_change_id, + sizeof(sXML_change_id)-1)) ) + { + // Id found! Now call RedlineImportHelper + + // prepare parameters + UniReference<XMLTextImportHelper> rHelper = + GetImport().GetTextImport(); + OUString& rID = xAttrList->getValueByIndex(nAttr); + + // call for bStart and bEnd (may both be true) + if (bIsStart) + rHelper->RedlineSetCursor(rID,sal_True,bIsOutsideOfParagraph); + if (bIsEnd) + rHelper->RedlineSetCursor(rID,sal_False,bIsOutsideOfParagraph); + + // outside of paragraph and still open? set open redline ID + if (bIsStart) + { + if (bIsOutsideOfParagraph || !bIsEnd) + rHelper->SetOpenRedlineId(rID); + else + rHelper->ResetOpenRedlineId(); + } + } + // else: ignore + } +} diff --git a/xmloff/source/text/XMLChangeImportContext.hxx b/xmloff/source/text/XMLChangeImportContext.hxx new file mode 100644 index 000000000000..2757bd44d5ce --- /dev/null +++ b/xmloff/source/text/XMLChangeImportContext.hxx @@ -0,0 +1,124 @@ +/************************************************************************* + * + * $RCSfile: XMLChangeImportContext.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2001-01-19 18:38:06 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLCHANGEIMPORTCONTEXT_HXX +#define _XMLOFF_XMLCHANGEIMPORTCONTEXT_HXX + + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif + + +namespace com { namespace sun { namespace star { + namespace xml { namespace sax { + class XAttributeList; + } } +} } } +namespace rtl { + class OUString; +} + + + +/** + * import change tracking/redlining markers + * <text:change>, <text:change-start>, <text:change-end> + */ +class XMLChangeImportContext : public SvXMLImportContext +{ + sal_Bool bIsStart; + sal_Bool bIsEnd; + sal_Bool bIsOutsideOfParagraph; + +public: + + TYPEINFO(); + + /** + * import a change mark + * (<text:change>, <text:change-start>, <text:change-end>) + * Note: a <text:change> mark denotes start and end of a change + * simultaniously, so both bIsStart and bIsEnd parameters would + * be set true. + */ + XMLChangeImportContext( + SvXMLImport& rImport, + sal_Int16 nPrefix, + const ::rtl::OUString& rLocalName, + sal_Bool bIsStart, /// mark start of a change + sal_Bool bIsEnd, /// mark end of a change + /// true if change mark is encountered outside of a paragraph + /// (usually before a section or table) + sal_Bool bIsOutsideOfParagraph = sal_False); + + ~XMLChangeImportContext(); + + virtual void StartElement( + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList> & xAttrList); +}; + +#endif diff --git a/xmloff/source/text/XMLRedlineExport.cxx b/xmloff/source/text/XMLRedlineExport.cxx index 31cd194b2686..5dffa8a9ff70 100644 --- a/xmloff/source/text/XMLRedlineExport.cxx +++ b/xmloff/source/text/XMLRedlineExport.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLRedlineExport.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: dvo $ $Date: 2001-01-12 14:35:03 $ + * last change: $Author: dvo $ $Date: 2001-01-19 18:38:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,10 +79,30 @@ #include <com/sun/star/beans/XPropertySet.hpp> #endif +#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_ +#include <com/sun/star/container/XEnumerationAccess.hpp> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATION_HPP_ +#include <com/sun/star/beans/XEnumeration.hpp> +#endif + +#ifndef _COM_SUN_STAR_DOCUMENT_XREDLINESSUPPLIER_HPP_ +#include <com/sun/star/document/XRedlinesSupplier.hpp> +#endif + #ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_ #include <com/sun/star/text/XText.hpp> #endif +#ifndef _COM_SUN_STAR_TEXT_XTEXTCONTENT_HPP_ +#include <com/sun/star/text/XTextContent.hpp> +#endif + +#ifndef _COM_SUN_STAR_TEXT_XTEXTSECTION_HPP_ +#include <com/sun/star/text/XTextSection.hpp> +#endif + #ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_ #include <com/sun/star/util/DateTime.hpp> #endif @@ -108,7 +128,12 @@ using namespace ::com::sun::star; using ::com::sun::star::beans::PropertyValue; using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::document::XRedlinesSupplier; +using ::com::sun::star::container::XEnumerationAccess; +using ::com::sun::star::container::XEnumeration; using ::com::sun::star::text::XText; +using ::com::sun::star::text::XTextContent; +using ::com::sun::star::text::XTextSection; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; @@ -132,61 +157,126 @@ XMLRedlineExport::XMLRedlineExport(SvXMLExport& rExp) : sRedlineDateTime(RTL_CONSTASCII_USTRINGPARAM("RedlineDateTime")), sRedlineSuccessorData(RTL_CONSTASCII_USTRINGPARAM("RedlineSuccessorData")), sRedlineType(RTL_CONSTASCII_USTRINGPARAM("RedlineType")), + sRedlineText(RTL_CONSTASCII_USTRINGPARAM("RedlineText")), sStyle(RTL_CONSTASCII_USTRINGPARAM("Style")), sTextTable(RTL_CONSTASCII_USTRINGPARAM("TextTable")), sUnknownChange(RTL_CONSTASCII_USTRINGPARAM("UnknownChange")), sChangePrefix(RTL_CONSTASCII_USTRINGPARAM("ct")), + sStartRedline(RTL_CONSTASCII_USTRINGPARAM("StartRedline")), + sEndRedline(RTL_CONSTASCII_USTRINGPARAM("EndRedline")), + sRedlineIdentifier(RTL_CONSTASCII_USTRINGPARAM("RedlineIdentifier")), rExport(rExp), aChangesList() { } + XMLRedlineExport::~XMLRedlineExport() { } + void XMLRedlineExport::ExportChange( const Reference<XPropertySet> & rPropSet, sal_Bool bAutoStyle) { + if (!bAutoStyle) + { + ExportChangeInline(rPropSet); + } +} + + +void XMLRedlineExport::ExportChangesList(sal_Bool bAutoStyle) +{ if (bAutoStyle) { - CollectChange(rPropSet); + ExportChangesListAutoStyles(); } else { - ExportChangeInline(rPropSet); + ExportChangesListElements(); } } -void XMLRedlineExport::CollectChange( - const Reference<XPropertySet> & rPropSet) + +void XMLRedlineExport::ExportChangesListElements() { - // collect change in the big list - aChangesList.push_back(rPropSet); + // get redlines (aka tracked changes) from the model + Reference<XRedlinesSupplier> xSupplier(rExport.GetModel(), uno::UNO_QUERY); + if (xSupplier.is()) + { + Reference<XEnumerationAccess> aEnumAccess = xSupplier->getRedlines(); + + // only export if we actually have redlines + if (aEnumAccess->hasElements()) + { + // changes container element + SvXMLElementExport aChanges(rExport, XML_NAMESPACE_TEXT, + sXML_tracked_changes, + sal_True, sal_True); + + // get enumeration and iterate over elements + Reference<XEnumeration> aEnum = aEnumAccess->createEnumeration(); + while (aEnum->hasMoreElements()) + { + Any aAny = aEnum->nextElement(); + Reference<XPropertySet> xPropSet; + aAny >>= xPropSet; + + DBG_ASSERT(xPropSet.is(), + "can't get XPropertySet; skipping Redline"); + if (xPropSet.is()) + { + // and finally, export change + ExportChangedRegion(xPropSet); + } + // else: no XPropertySet -> no export + } + } + // else: no redlines -> no export + } + // else: no XRedlineSupplier -> no export } -void XMLRedlineExport::ExportChangesList() +void XMLRedlineExport::ExportChangesListAutoStyles() { - // write changes list only if we have redlines - if (aChangesList.size() > 0) + // get redlines (aka tracked changes) from the model + Reference<XRedlinesSupplier> xSupplier(rExport.GetModel(), uno::UNO_QUERY); + if (xSupplier.is()) { - // changes container element - SvXMLElementExport aChanges(rExport, XML_NAMESPACE_TEXT, - sXML_tracked_changes, sal_True, sal_True); - - // iterate over all changes and call ExportChangeRegion, the - // discard changes lists - ChangesListType::iterator aEnd = aChangesList.end(); - for(ChangesListType::iterator aIter = aChangesList.begin(); - aIter != aEnd; - aIter++) + Reference<XEnumerationAccess> aEnumAccess = xSupplier->getRedlines(); + + // only export if we actually have redlines + if (aEnumAccess->hasElements()) { - ExportChangedRegion(*aIter); + // get enumeration and iterate over elements + Reference<XEnumeration> aEnum = aEnumAccess->createEnumeration(); + while (aEnum->hasMoreElements()) + { + Any aAny = aEnum->nextElement(); + Reference<XPropertySet> xPropSet; + aAny >>= xPropSet; + + DBG_ASSERT(xPropSet.is(), + "can't get XPropertySet; skipping Redline"); + if (xPropSet.is()) + { + // get XText for export of redline auto styles + aAny = xPropSet->getPropertyValue(sRedlineText); + Reference<XText> xText; + aAny >>= xText; + if (xText.is()) + { + // export the auto styles + rExport.GetTextParagraphExport()-> + collectTextAutoStyles(xText); + // default parameters: bProgress, bExportParagraph ??? + } + } + } } - aChangesList.clear(); } - // else: no redlines -> no export } void XMLRedlineExport::ExportChangeInline( @@ -224,73 +314,55 @@ void XMLRedlineExport::ExportChangeInline( void XMLRedlineExport::ExportChangedRegion( const Reference<XPropertySet> & rPropSet) { - // determine collapsed, start, end - Any aAny = rPropSet->getPropertyValue(sIsCollapsed); - sal_Bool bCollapsed = *(sal_Bool *)aAny.getValue(); - aAny = rPropSet->getPropertyValue(sIsStart); - sal_Bool bStart = *(sal_Bool *)aAny.getValue(); + // export changed-region element (with change-ID) + rExport.AddAttribute(XML_NAMESPACE_TEXT, sXML_id, GetRedlineID(rPropSet) ); + SvXMLElementExport aChangedRegion(rExport, XML_NAMESPACE_TEXT, + sXML_changed_region, sal_True, sal_True); - // only export changed-region once per change - if (bStart || bCollapsed) + // scope for (first) change element { - // export changed-region element (with change-ID) - rExport.AddAttribute(XML_NAMESPACE_TEXT, sXML_id, - GetRedlineID(rPropSet) ); - SvXMLElementExport aChangedRegion(rExport, XML_NAMESPACE_TEXT, - sXML_changed_region, - sal_True, sal_True); - - // scope for change element + Any aAny = rPropSet->getPropertyValue(sRedlineType); + OUString sType; + aAny >>= sType; + SvXMLElementExport aChange(rExport, XML_NAMESPACE_TEXT, + ConvertTypeName(sType), sal_True, sal_True); + + ExportChangeInfo(rPropSet); + + // get XText from the redline and export (if the XText exists) + aAny = rPropSet->getPropertyValue(sRedlineText); + Reference<XText> xText; + aAny >>= xText; + if (xText.is()) { - Any aAny = rPropSet->getPropertyValue(sRedlineType); - OUString sType; - aAny >>= sType; - SvXMLElementExport aChange(rExport, XML_NAMESPACE_TEXT, - ConvertTypeName(sType), - sal_True, sal_True); - - ExportChangeInfo(rPropSet); - - // if the region is collapsed, we need to export it's content - if (bCollapsed) - { - // get XText from the redline text portion - Reference<XText> xText(rPropSet, uno::UNO_QUERY); - if (xText.is()) - { - rExport.GetTextParagraphExport()-> - collectTextAutoStyles(xText); - // default parameters: bProgress, bExportParagraph ??? - rExport.GetTextParagraphExport()->exportText(xText); - // default parameters: bProgress, bExportParagraph ??? - } - // else: no text, no export. Bummer! - } - // else: not collapsed: content will be exported inline + rExport.GetTextParagraphExport()->exportText(xText); + // default parameters: bProgress, bExportParagraph ??? } + // else: no text interface -> content is inline and will + // be exported there + } - // changed change? Hierarchical changes can onl be two levels - // deep. Here we check for the second level. - Any aAny = rPropSet->getPropertyValue(sRedlineSuccessorData); - Sequence<PropertyValue> aSuccessorData; - aAny >>= aSuccessorData; + // changed change? Hierarchical changes can onl be two levels + // deep. Here we check for the second level. + Any aAny = rPropSet->getPropertyValue(sRedlineSuccessorData); + Sequence<PropertyValue> aSuccessorData; + aAny >>= aSuccessorData; - // if we actually got a hierarchical change, make element and - // process change info - if (aSuccessorData.getLength() > 0) - { - // The only change that can be "undone" is an insertion - - // after all, you can't re-insert an deletion, but you can - // delete an insertion. This assumption is asserted in - // ExportChangeInfo(Sequence<PropertyValue>&). - SvXMLElementExport aSecondChangeElem( - rExport, XML_NAMESPACE_TEXT, sXML_insertion, - sal_True, sal_True); - - ExportChangeInfo(aSuccessorData); - } + // if we actually got a hierarchical change, make element and + // process change info + if (aSuccessorData.getLength() > 0) + { + // The only change that can be "undone" is an insertion - + // after all, you can't re-insert an deletion, but you can + // delete an insertion. This assumption is asserted in + // ExportChangeInfo(Sequence<PropertyValue>&). + SvXMLElementExport aSecondChangeElem( + rExport, XML_NAMESPACE_TEXT, sXML_insertion, + sal_True, sal_True); + + ExportChangeInfo(aSuccessorData); } - // else: region end: don't export + // else: no hierarchical change } @@ -317,14 +389,10 @@ const OUString XMLRedlineExport::ConvertTypeName( } -/* - * Create a Redline-ID - */ +/** Create a Redline-ID */ const OUString XMLRedlineExport::GetRedlineID( const Reference<XPropertySet> & rPropSet) { - OUString sRedlineIdentifier( - RTL_CONSTASCII_USTRINGPARAM("RedlineIdentifier")); Any aAny = rPropSet->getPropertyValue(sRedlineIdentifier); OUString sTmp; aAny >>= sTmp; @@ -418,4 +486,74 @@ void XMLRedlineExport::ExportChangeInfo( sXML_change_info, sal_True, sal_True); } +void XMLRedlineExport::ExportStartOrEndRedline( + const Reference<XPropertySet> & rPropSet, + sal_Bool bStart) +{ + // get appropriate (start or end) property + Any aAny = + rPropSet->getPropertyValue(bStart ? sStartRedline : sEndRedline); + Sequence<PropertyValue> aValues; + aAny >>= aValues; + + // seek for redline ID + sal_Int32 nLength = aValues.getLength(); + for(sal_Int32 i = 0; i < nLength; i++) + { + if (sRedlineIdentifier.equals(aValues[i].Name)) + { + OUString sId; + aValues[i].Value >>= sId; + + // TODO: use GetRedlineID or elimiate that function + OUStringBuffer sBuffer(sChangePrefix); + sBuffer.append(sId); + + rExport.AddAttribute(XML_NAMESPACE_TEXT, sXML_change_id, + sBuffer.makeStringAndClear()); + + // export the element + // (whitespace because we're not inside paragraphs) + SvXMLElementExport aChangeElem( + rExport, XML_NAMESPACE_TEXT, + bStart ? sXML_change_start : sXML_change_end, + sal_True, sal_True); + + // and break out of loop, in case a second RedlineIdentifier Value + break; + } + // else: ignore Value + } +} + +void XMLRedlineExport::ExportStartOrEndRedline( + const Reference<XTextContent> & rContent, + sal_Bool bStart) +{ + Reference<XPropertySet> xPropSet(rContent, uno::UNO_QUERY); + if (xPropSet.is()) + { + ExportStartOrEndRedline(xPropSet, bStart); + } + else + { + DBG_ERROR("XPropertySet expected"); + } +} + +void XMLRedlineExport::ExportStartOrEndRedline( + const Reference<XTextSection> & rSection, + sal_Bool bStart) +{ + Reference<XPropertySet> xPropSet(rSection, uno::UNO_QUERY); + if (xPropSet.is()) + { + ExportStartOrEndRedline(xPropSet, bStart); + } + else + { + DBG_ERROR("XPropertySet expected"); + } +} + diff --git a/xmloff/source/text/XMLRedlineExport.hxx b/xmloff/source/text/XMLRedlineExport.hxx index d6e62d8cb2b1..688e2257ffb0 100644 --- a/xmloff/source/text/XMLRedlineExport.hxx +++ b/xmloff/source/text/XMLRedlineExport.hxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLRedlineExport.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: dvo $ $Date: 2001-01-12 14:35:03 $ + * last change: $Author: dvo $ $Date: 2001-01-19 18:38:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -78,6 +78,8 @@ class SvXMLExport; namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } namespace beans { struct PropertyValue; } + namespace text { class XTextContent; } + namespace text { class XTextSection; } } } } namespace rtl { class OUString; @@ -106,10 +108,15 @@ class XMLRedlineExport const ::rtl::OUString sRedlineComment; const ::rtl::OUString sRedlineDateTime; const ::rtl::OUString sRedlineSuccessorData; + const ::rtl::OUString sRedlineText; const ::rtl::OUString sRedlineType; const ::rtl::OUString sStyle; const ::rtl::OUString sTextTable; const ::rtl::OUString sUnknownChange; + const ::rtl::OUString sStartRedline; + const ::rtl::OUString sEndRedline; + const ::rtl::OUString sRedlineIdentifier; + const ::rtl::OUString sChangePrefix; @@ -133,24 +140,44 @@ public: /// if (bAutoStyle) CollectChange(..) else ExoirtChangeInline(...) sal_Bool bAutoStyle); + /// export the list of changes + void ExportChangesList(sal_Bool bAutoStyles); - /// put a RedlinePortion into the list of changes - void CollectChange( + /// export the change mark contained in the text body + void ExportChangeInline( /// PropertySet of RedlinePortion const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> & rPropSet); - /// process the list of changes that have been previously - /// registered using the CollectChange() method - void ExportChangesList(); + /// export redline marks which start or end at start nodes, + /// i.e. that include the complete paragraph/table/section + void ExportStartOrEndRedline( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & rPropSet, + sal_Bool bStart); /// start or end of text entity (e.g. paragraph)? - /// export the change mark contained in the text body - void ExportChangeInline( - /// PropertySet of RedlinePortion + /// convenience method, calls XPropertySet-version of this method + void ExportStartOrEndRedline( + /// XTextContent; must also be an XPropertySet const ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet> & rPropSet); + ::com::sun::star::text::XTextContent> & rContent, + sal_Bool bStart); + + /// convenience method, calls XPropertySet-version of this method + void ExportStartOrEndRedline( + /// XTextSection; must also be an XPropertySet + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextSection> & rSection, + sal_Bool bStart); private: + + /// export the changes list (<text:tracked-changes>) + void ExportChangesListElements(); + + /// export the auto styles needed by the changes list + void ExportChangesListAutoStyles(); + /// export the changed-region element void ExportChangedRegion( const ::com::sun::star::uno::Reference< diff --git a/xmloff/source/text/XMLSectionImportContext.cxx b/xmloff/source/text/XMLSectionImportContext.cxx index 77bf4cc86272..9ace387f252b 100644 --- a/xmloff/source/text/XMLSectionImportContext.cxx +++ b/xmloff/source/text/XMLSectionImportContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLSectionImportContext.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: dvo $ $Date: 2001-01-02 14:41:38 $ + * last change: $Author: dvo $ $Date: 2001-01-19 18:38:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -258,12 +258,17 @@ void XMLSectionImportContext::StartElement( } } - // insert X, <paragraph>, X; then insert - // section over the first X character, and delete the - // last paragraph (and X) when closing a section. + // insert marker, <paragraph>, marker; then insert + // section over the first marker character, and delete the + // last paragraph (and marker) when closing a section. Reference<XTextRange> xStart = rHelper->GetCursor()->getStart(); - OUString sMarkerString(RTL_CONSTASCII_USTRINGPARAM("X")); +#ifdef PRODUCT + static const sal_Char sMarker[] = " "; +#else + static const sal_Char sMarker[] = "X"; +#endif + OUString sMarkerString(RTL_CONSTASCII_USTRINGPARAM(sMarker)); rHelper->InsertString(sMarkerString); rHelper->InsertControlCharacter( ControlCharacter::APPEND_PARAGRAPH ); @@ -284,6 +289,10 @@ void XMLSectionImportContext::StartElement( // and delete first marker (in section) rHelper->GetText()->insertString( rHelper->GetCursorAsRange(), sEmpty, sal_True); + + // finally, check for redlines that should start at + // the section start node + rHelper->RedlineAdjustStartNodeCursor(sal_True); // start ??? } } } diff --git a/xmloff/source/text/makefile.mk b/xmloff/source/text/makefile.mk index 3fbd8b999b43..b75c0271ffb6 100644 --- a/xmloff/source/text/makefile.mk +++ b/xmloff/source/text/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.17 $ +# $Revision: 1.18 $ # -# last change: $Author: dvo $ $Date: 2001-01-10 20:51:01 $ +# last change: $Author: dvo $ $Date: 2001-01-19 18:38:06 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -96,6 +96,7 @@ CXXFILES = \ XMLChangedRegionImportContext.cxx \ XMLChangeElementImportContext.cxx \ XMLChangeInfoContext.cxx \ + XMLChangeImportContext.cxx \ XMLFootnoteBodyImportContext.cxx \ XMLFootnoteConfigurationImportContext.cxx \ XMLFootnoteImportContext.cxx \ @@ -167,6 +168,7 @@ SLOFILES = \ $(SLO)$/XMLChangedRegionImportContext.obj \ $(SLO)$/XMLChangeElementImportContext.obj \ $(SLO)$/XMLChangeInfoContext.obj \ + $(SLO)$/XMLChangeImportContext.obj \ $(SLO)$/XMLFootnoteBodyImportContext.obj \ $(SLO)$/XMLFootnoteConfigurationImportContext.obj \ $(SLO)$/XMLFootnoteImportContext.obj \ diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 6bd6ca9d7951..5e5b6fb180c3 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtimp.cxx,v $ * - * $Revision: 1.40 $ + * $Revision: 1.41 $ * - * last change: $Author: dvo $ $Date: 2001-01-15 17:19:31 $ + * last change: $Author: dvo $ $Date: 2001-01-19 18:38:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -188,6 +188,9 @@ #ifndef _XMLOFF_XMLTRACKEDCHANGESIMPORTCONTEXT_HXX #include "XMLTrackedChangesImportContext.hxx" #endif +#ifndef _XMLOFF_XMLCHANGEIMPORTCONTEXT_HXX +#include "XMLChangeImportContext.hxx" +#endif using namespace ::rtl; using namespace ::std; @@ -228,6 +231,9 @@ static __FAR_DATA SvXMLTokenMapEntry aTextElemTokenMap[] = { XML_NAMESPACE_TEXT, sXML_bibliography, XML_TOK_TEXT_BIBLIOGRAPHY_INDEX }, { XML_NAMESPACE_TEXT, sXML_index_title, XML_TOK_TEXT_INDEX_TITLE }, { XML_NAMESPACE_TEXT, sXML_tracked_changes, XML_TOK_TEXT_TRACKED_CHANGES }, + { XML_NAMESPACE_TEXT, sXML_change_start, XML_TOK_TEXT_CHANGE_START }, + { XML_NAMESPACE_TEXT, sXML_change_end, XML_TOK_TEXT_CHANGE_END }, + { XML_NAMESPACE_TEXT, sXML_change, XML_TOK_TEXT_CHANGE }, XML_TOKEN_MAP_END }; @@ -394,9 +400,9 @@ static __FAR_DATA SvXMLTokenMapEntry aTextPElemTokenMap[] = { XML_NAMESPACE_TEXT, sXML_sheet_name, XML_TOK_TEXT_SHEET_NAME }, // redlining (aka change tracking) - { XML_NAMESPACE_TEXT, sXML_change_start, XML_TOK_TEXT_CHANGE_START }, - { XML_NAMESPACE_TEXT, sXML_change_end , XML_TOK_TEXT_CHANGE_END }, - { XML_NAMESPACE_TEXT, sXML_change, XML_TOK_TEXT_CHANGE }, + { XML_NAMESPACE_TEXT, sXML_change_start, XML_TOK_TEXTP_CHANGE_START }, + { XML_NAMESPACE_TEXT, sXML_change_end , XML_TOK_TEXTP_CHANGE_END }, + { XML_NAMESPACE_TEXT, sXML_change, XML_TOK_TEXTP_CHANGE }, XML_TOKEN_MAP_END }; @@ -1049,7 +1055,8 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( const SvXMLTokenMap& rTokenMap = GetTextElemTokenMap(); sal_Bool bOrdered = sal_False; sal_Bool bHeading = sal_False; - switch( rTokenMap.Get( nPrefix, rLocalName ) ) + sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); + switch( nToken ) { case XML_TOK_TEXT_H: bHeading = sal_True; @@ -1193,6 +1200,16 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( rLocalName); break; + case XML_TOK_TEXT_CHANGE: + case XML_TOK_TEXT_CHANGE_START: + case XML_TOK_TEXT_CHANGE_END: + pContext = new XMLChangeImportContext( + rImport, nPrefix, rLocalName, + (XML_TOK_TEXT_CHANGE_END != nToken), + (XML_TOK_TEXT_CHANGE_START != nToken), + sal_True); + break; + default: if( XML_TEXT_TYPE_BODY == eType || XML_TEXT_TYPE_TEXTBOX == eType ) { @@ -1205,6 +1222,14 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( // if( !pContext ) // pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + // handle open redlines + if ( (XML_TOK_TEXT_CHANGE != nToken) && + (XML_TOK_TEXT_CHANGE_END != nToken) && + (XML_TOK_TEXT_CHANGE_START != nToken) ) + { + ResetOpenRedlineId(); + } + return pContext; } @@ -1470,7 +1495,7 @@ void XMLTextImportHelper::RedlineAdd( } Reference<XTextCursor> XMLTextImportHelper::RedlineCreateText( - Reference<XTextCursor> xOldCursor, + Reference<XTextCursor> & rOldCursor, const OUString& rId) { // dummy implementation: do nothing @@ -1481,7 +1506,29 @@ Reference<XTextCursor> XMLTextImportHelper::RedlineCreateText( void XMLTextImportHelper::RedlineSetCursor( const OUString& rId, sal_Bool bStart, - Reference<XTextRange> & rRange) + sal_Bool bIsOutsideOfParagraph) +{ + // dummy implementation: do nothing +} + +void XMLTextImportHelper::RedlineAdjustStartNodeCursor( + sal_Bool bStart) { // dummy implementation: do nothing } + +OUString XMLTextImportHelper::GetOpenRedlineId() +{ + return sOpenRedlineIdentifier; +} + +void XMLTextImportHelper::SetOpenRedlineId( ::rtl::OUString& rId) +{ + sOpenRedlineIdentifier = rId; +} + +void XMLTextImportHelper::ResetOpenRedlineId() +{ + OUString sEmpty; + SetOpenRedlineId(sEmpty); +} diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 171784872719..72280da4f94c 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtparae.cxx,v $ * - * $Revision: 1.46 $ + * $Revision: 1.47 $ * - * last change: $Author: mib $ $Date: 2001-01-19 08:44:50 $ + * last change: $Author: dvo $ $Date: 2001-01-19 18:38:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1055,7 +1055,15 @@ void XMLTextParagraphExport::exportTextContentEnumeration( aPrevNumInfo, aNextNumInfo, bAutoStyles ); + // export start + end redlines (for wholly redlined tables) + if (! bAutoStyles) + pRedlineExport->ExportStartOrEndRedline(xTxtCntnt, sal_True); + exportTable( xTxtCntnt, bAutoStyles, bProgress ); + + if (! bAutoStyles) + pRedlineExport->ExportStartOrEndRedline(xTxtCntnt, sal_False); + bHasContent = sal_True; } else if( xServiceInfo->supportsService( sTextFrameService ) ) @@ -1285,7 +1293,7 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( else if (sType.equals(sRedline)) { // disable change tracking until implemented properly: - // pRedlineExport->ExportChange(xPropSet, bAutoStyles); + pRedlineExport->ExportChange(xPropSet, bAutoStyles); } else DBG_ERROR("unknown text portion type"); @@ -2289,10 +2297,10 @@ void XMLTextParagraphExport::exportTextDeclarations() pFieldExport->ExportFieldDeclarations(); } -void XMLTextParagraphExport::exportTrackedChanges() +void XMLTextParagraphExport::exportTrackedChanges(sal_Bool bAutoStyles) { // disable change tracking until implemented properly: - // pRedlineExport->ExportChangesList(); + pRedlineExport->ExportChangesList( bAutoStyles ); } void XMLTextParagraphExport::exportTextAutoStyles() diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index 733e4267d03c..3aa98cd7d7af 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtparai.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: dvo $ $Date: 2001-01-10 20:51:01 $ + * last change: $Author: dvo $ $Date: 2001-01-19 18:38:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -139,6 +139,9 @@ #ifndef _XMLOFF_XMLEVENTSIMPORTCONTEXT_HXX #include "XMLEventsImportContext.hxx" #endif +#ifndef _XMLOFF_XMLCHANGEIMPORTCONTEXT_HXX +#include "XMLChangeImportContext.hxx" +#endif using namespace ::rtl; using namespace ::com::sun::star; @@ -1383,13 +1386,13 @@ void XMLAlphaIndexMarkImportContext_Impl::ProcessAttribute( { if (XML_NAMESPACE_TEXT == nNamespace) { - if (sLocalName.equalsAsciiL(sXML_key1, sizeof(sXML_key1))) + if (sLocalName.equalsAsciiL(sXML_key1, sizeof(sXML_key1)-1)) { Any aAny; aAny <<= sValue; rPropSet->setPropertyValue(sPrimaryKey, aAny); } - else if (sLocalName.equalsAsciiL(sXML_key2, sizeof(sXML_key2))) + else if (sLocalName.equalsAsciiL(sXML_key2, sizeof(sXML_key2)-1)) { Any aAny; aAny <<= sValue; @@ -1411,83 +1414,6 @@ void XMLAlphaIndexMarkImportContext_Impl::ProcessAttribute( // --------------------------------------------------------------------- -/** - * import change tracking/redlining markers - * <text:change>, <text:change-start>, <text:change-end> - */ -class XMLChangeImportContext : public SvXMLImportContext -{ - sal_Bool bStart; - sal_Bool bEnd; - -public: - - TYPEINFO(); - - XMLChangeImportContext(SvXMLImport& rImport, - sal_Int16 nPrefix, - const OUString& rLocalName, - enum XMLTextPElemTokens nToken); - - ~XMLChangeImportContext(); - - virtual void StartElement( - const Reference<xml::sax::XAttributeList> & xAttrList); -}; - -TYPEINIT1( XMLChangeImportContext, SvXMLImportContext ); - -XMLChangeImportContext::XMLChangeImportContext( - SvXMLImport& rImport, - sal_Int16 nPrefix, - const OUString& rLocalName, - enum XMLTextPElemTokens nToken) : - SvXMLImportContext(rImport, nPrefix, rLocalName), - bStart( (XML_TOK_TEXT_CHANGE == nToken) || - (XML_TOK_TEXT_CHANGE_START == nToken)), - bEnd( (XML_TOK_TEXT_CHANGE == nToken) || - (XML_TOK_TEXT_CHANGE_END == nToken)) -{ -} - -XMLChangeImportContext::~XMLChangeImportContext() -{ -} - -void XMLChangeImportContext::StartElement( - const Reference<xml::sax::XAttributeList>& xAttrList) -{ - sal_Int16 nLength = xAttrList->getLength(); - for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++) - { - OUString sLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). - GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), - &sLocalName ); - if ( (XML_NAMESPACE_TEXT == nPrefix) && - (sLocalName.equalsAsciiL(sXML_change_id, - sizeof(sXML_change_id)-1)) ) - { - // Id found! Now call RedlineImportHelper - - // prepare parameters - OUString& rID = xAttrList->getValueByIndex(nAttr); - UniReference<XMLTextImportHelper> rHelper = - GetImport().GetTextImport(); - Reference<XTextRange> & rPos = rHelper->GetCursor()->getStart(); - - // call for bStart and bEnd (may both be true) - if (bStart) - rHelper->RedlineSetCursor(rID, sal_True, rPos); - if (bEnd) - rHelper->RedlineSetCursor(rID, sal_False, rPos); - } - // else: ignore - } -} - -// --------------------------------------------------------------------- - TYPEINIT1( XMLImpSpanContext_Impl, SvXMLImportContext ); XMLImpSpanContext_Impl::XMLImpSpanContext_Impl( @@ -1726,11 +1652,14 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext( rHints); break; - case XML_TOK_TEXT_CHANGE_START: - case XML_TOK_TEXT_CHANGE_END: - case XML_TOK_TEXT_CHANGE: - pContext = new XMLChangeImportContext(rImport, nPrefix, rLocalName, - (enum XMLTextPElemTokens)nToken); + case XML_TOK_TEXTP_CHANGE_START: + case XML_TOK_TEXTP_CHANGE_END: + case XML_TOK_TEXTP_CHANGE: + pContext = new XMLChangeImportContext( + rImport, nPrefix, rLocalName, + (nToken != XML_TOK_TEXTP_CHANGE_END), + (nToken != XML_TOK_TEXTP_CHANGE_START), + sal_False); break; default: diff --git a/xmloff/source/text/txtsecte.cxx b/xmloff/source/text/txtsecte.cxx index a23d8da35989..88f2592e559b 100644 --- a/xmloff/source/text/txtsecte.cxx +++ b/xmloff/source/text/txtsecte.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtsecte.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: dvo $ $Date: 2000-11-30 16:46:20 $ + * last change: $Author: dvo $ $Date: 2001-01-19 18:38:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -160,6 +160,10 @@ #include "XMLSectionExport.hxx" #endif +#ifndef _XMLOFF_XMLREDLINEEXPORT_HXX +#include "XMLRedlineExport.hxx" +#endif + using namespace ::com::sun::star; using namespace ::com::sun::star::text; using namespace ::com::sun::star::uno; @@ -274,23 +278,33 @@ void XMLTextParagraphExport::exportListAndSectionChange( // close all elements of aOld ... // (order: newest to oldest) - vector<Reference<XTextSection> > ::iterator aOldForward = - aOldStack.begin(); - while ((aOldForward != aOldStack.end()) && - (*aOldForward != *aOld)) - { - pSectionExport->ExportSectionEnd(*aOldForward, bAutoStyles); - aOldForward++; - } - if (aOldForward != aOldStack.end()) + if (aOld != aOldStack.rend()) { - pSectionExport->ExportSectionEnd(*aOldForward, bAutoStyles); + vector<Reference<XTextSection> > ::iterator aOldForward = + aOldStack.begin(); + while ((aOldForward != aOldStack.end()) && + (*aOldForward != *aOld)) + { + pRedlineExport->ExportStartOrEndRedline(*aOldForward, + sal_False); + pSectionExport->ExportSectionEnd(*aOldForward, + bAutoStyles); + aOldForward++; + } + if (aOldForward != aOldStack.end()) + { + pRedlineExport->ExportStartOrEndRedline(*aOldForward, + sal_False); + pSectionExport->ExportSectionEnd(*aOldForward, + bAutoStyles); + } } // ...then open all of aNew // (order: oldest to newest) while (aNew != aNewStack.rend()) { + pRedlineExport->ExportStartOrEndRedline(*aNew, sal_True); pSectionExport->ExportSectionStart(*aNew, bAutoStyles); aNew++; } |