include/xmloff/txtparae.hxx | 31 - sw/source/filter/xml/xmlexp.cxx | 2 sw/source/filter/xml/xmlfmte.cxx | 3 xmloff/source/text/XMLRedlineExport.cxx | 418 ------------------------- xmloff/source/text/XMLRedlineExport.hxx | 43 -- xmloff/source/text/XMLTextMasterPageExport.cxx | 1 xmloff/source/text/txtparae.cxx | 370 ---------------------- 7 files changed, 19 insertions(+), 849 deletions(-)
New commits: commit 1668fda4bfd7d2681b440497da2ab37f45cf47b8 Author: Rosemary Sebastian <rosemarys...@gmail.com> Date: Thu Jun 23 09:56:09 2016 +0530 Clean up code Change-Id: Ib44e072f42620a9b17e813996a4ea817cb280da4 diff --git a/include/xmloff/txtparae.hxx b/include/xmloff/txtparae.hxx index ce851f8..92fae21 100644 --- a/include/xmloff/txtparae.hxx +++ b/include/xmloff/txtparae.hxx @@ -250,8 +250,7 @@ public: void exportUndoTextRangeEnumeration( const css::uno::Reference< css::container::XEnumeration > & rRangeEnum, const sal_uInt32& rParaIdx, - bool bAutoStyles, bool bProgress, - bool bPrvChrIsSpc = true ); + bool bAutoStyles ); void exportTextRangeEnumeration( const css::uno::Reference< css::container::XEnumeration > & rRangeEnum, bool bAutoStyles, bool bProgress, @@ -277,7 +276,7 @@ protected: void exportUndoText( const css::uno::Reference < css::text::XText > & rText, - bool bAutoStyles, bool bProgress, bool bExportParagraph, TextPNS eExtensionNS = TextPNS::ODF ); + bool bAutoStyles, bool bProgress ); void exportText( const css::uno::Reference < @@ -293,11 +292,7 @@ protected: const css::uno::Reference< css::container::XEnumeration > & rContentEnum, bool bAutoStyles, const css::uno::Reference< css::text::XTextSection > & rBaseSection, - bool bProgress, - bool bExportParagraph = true, - const css::uno::Reference< css::beans::XPropertySet > *pRangePropSet = nullptr, - bool bExportLevels = true, - TextPNS eExtensionNS = TextPNS::ODF); + bool bProgress); bool exportTextContentEnumeration( const css::uno::Reference< css::container::XEnumeration > & rContentEnum, bool bAutoStyles, @@ -311,9 +306,7 @@ protected: const css::uno::Reference< css::text::XTextContent > & rTextContent, const sal_uInt32& rParaIdx, bool bAutoStyles, bool bProgress, - bool bExportParagraph, - MultiPropertySetHelper& rPropSetHelper, - TextPNS eExtensionNS = TextPNS::ODF); + MultiPropertySetHelper& rPropSetHelper); void exportParagraph( const css::uno::Reference< css::text::XTextContent > & rTextContent, bool bAutoStyles, bool bProgress, @@ -498,15 +491,6 @@ public: /// export all declarations void exportUsedDeclarations(); - /// Export the list of change information (enclosed by <tracked-changes>) - /// (or the necessary automatic styles) - void exportTrackedChanges(bool bAutoStyle); - - /// Export the list of change information (enclosed by <tracked-changes>) - /// (or the necessary automatic styles) - void exportTrackedChanges(const css::uno::Reference< css::text::XText > & rText, - bool bAutoStyle ); - /// Record tracked changes for this particular XText /// (empty reference stop recording) /// This should be used if tracked changes for e.g. footers are to @@ -569,12 +553,11 @@ public: } // This method exports the given XText - void exportUndoText( + void exportTrackedChanges( const css::uno::Reference< css::text::XText > & rText, - bool bIsProgress = false, - bool bExportParagraph = true, TextPNS eExtensionNS = TextPNS::ODF) + bool bIsProgress = false) { - exportUndoText( rText, false, bIsProgress, bExportParagraph, eExtensionNS ); + exportUndoText( rText, false, bIsProgress ); } void exportText( diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index 2812ec5..f9f2d40 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -497,7 +497,7 @@ void SwXMLExport::ExportUndo_() true, true ); Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY ); Reference < XText > xText = xTextDoc->getText(); - GetTextParagraphExport()->exportUndoText( xText, bShowProgress ); + GetTextParagraphExport()->exportTrackedChanges( xText, bShowProgress ); } namespace diff --git a/sw/source/filter/xml/xmlfmte.cxx b/sw/source/filter/xml/xmlfmte.cxx index 312b8b2..5247201 100644 --- a/sw/source/filter/xml/xmlfmte.cxx +++ b/sw/source/filter/xml/xmlfmte.cxx @@ -201,9 +201,6 @@ void SwXMLExport::ExportAutoStyles_() if( !(getExportFlags() & SvXMLExportFlags::STYLES) ) GetTextParagraphExport()->exportUsedDeclarations(); - if( getExportFlags() & SvXMLExportFlags::UNDO ) - GetTextParagraphExport()->exportTrackedChanges( true ); - // exported in ExportContent_ if( getExportFlags() & SvXMLExportFlags::CONTENT ) { diff --git a/xmloff/source/text/XMLRedlineExport.cxx b/xmloff/source/text/XMLRedlineExport.cxx index f4f270b..1013281 100644 --- a/xmloff/source/text/XMLRedlineExport.cxx +++ b/xmloff/source/text/XMLRedlineExport.cxx @@ -111,80 +111,6 @@ void XMLRedlineExport::ExportUndoChange( { ExportUndoChangeInfo(rPropSet, rParaIdx); } - -} - -void XMLRedlineExport::ExportChange( - const Reference<XPropertySet> & rPropSet, - bool bAutoStyle) -{ - if (bAutoStyle) - { - // For the headers/footers, we have to collect the autostyles - // here. For the general case, however, it's better to collect - // the autostyles by iterating over the global redline - // list. So that's what we do: Here, we collect autostyles - // only if we have no current list of changes. For the - // main-document case, the autostyles are collected in - // ExportChangesListAutoStyles(). - if (pCurrentChangesList != nullptr) - ExportChangeAutoStyle(rPropSet); - } - else - { - ExportChangeInline(rPropSet); - } - -} - - -void XMLRedlineExport::ExportChangesList(bool bAutoStyles) -{ - if (bAutoStyles) - { - ExportChangesListAutoStyles(); - } - else - { - ExportChangesListElements(); - } -} - - -void XMLRedlineExport::ExportChangesList( - const Reference<XText> & rText, - bool bAutoStyles) -{ - // in the header/footer case, auto styles are collected from the - // inline change elements. - if (bAutoStyles) - return; - - // look for changes list for this XText - ChangesMapType::iterator aFind = aChangeMap.find(rText); - if (aFind != aChangeMap.end()) - { - ChangesListType* pChangesList = aFind->second; - - // export only if changes are found - if (pChangesList->size() > 0) - { - // changes container element - SvXMLElementExport aChanges(rExport, XML_NAMESPACE_TEXT, - XML_TRACKED_CHANGES, - true, true); - - // iterate over changes list - for( ChangesListType::iterator aIter = pChangesList->begin(); - aIter != pChangesList->end(); - ++aIter ) - { - ExportChangedRegion( *aIter ); - } - } - // else: changes list empty -> ignore - } - // else: no changes list found -> empty } void XMLRedlineExport::SetCurrentXText( @@ -215,130 +141,6 @@ void XMLRedlineExport::SetCurrentXText() pCurrentChangesList = nullptr; } -void XMLRedlineExport::ExportChangesListElements() -{ - // get redlines (aka tracked changes) from the model - Reference<XRedlinesSupplier> xSupplier(rExport.GetModel(), uno::UNO_QUERY); - if (xSupplier.is()) - { - Reference<XEnumerationAccess> aEnumAccess = xSupplier->getRedlines(); - - // redline protection key - Reference<XPropertySet> aDocPropertySet( rExport.GetModel(), - uno::UNO_QUERY ); - // redlining enabled? - bool bEnabled = *static_cast<sal_Bool const *>(aDocPropertySet->getPropertyValue( - sRecordChanges ).getValue()); - - // only export if we have redlines or attributes - if ( aEnumAccess->hasElements() || bEnabled ) - { - - // export only if we have changes, but tracking is not enabled - if ( !bEnabled != !aEnumAccess->hasElements() ) - { - rExport.AddAttribute( - XML_NAMESPACE_TEXT, XML_TRACK_CHANGES, - bEnabled ? XML_TRUE : XML_FALSE ); - } - - // changes container element - SvXMLElementExport aChanges(rExport, XML_NAMESPACE_TEXT, - XML_TRACKED_CHANGES, - true, 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()) - { - // export only if not in header or footer - // (those must be exported with their XText) - aAny = xPropSet->getPropertyValue(sIsInHeaderFooter); - if (! *static_cast<sal_Bool const *>(aAny.getValue())) - { - // and finally, export change - ExportChangedRegion(xPropSet); - } - } - // else: no XPropertySet -> no export - } - } - // else: no redlines -> no export - } - // else: no XRedlineSupplier -> no export -} - -void XMLRedlineExport::ExportChangeAutoStyle( - const Reference<XPropertySet> & rPropSet) -{ - // record change (if changes should be recorded) - if (nullptr != pCurrentChangesList) - { - // put redline in list if it's collapsed or the redline start - Any aIsStart = rPropSet->getPropertyValue(sIsStart); - Any aIsCollapsed = rPropSet->getPropertyValue(sIsCollapsed); - - if ( *static_cast<sal_Bool const *>(aIsStart.getValue()) || - *static_cast<sal_Bool const *>(aIsCollapsed.getValue()) ) - pCurrentChangesList->push_back(rPropSet); - } - - // get XText for export of redline auto styles - Any aAny = rPropSet->getPropertyValue(sRedlineText); - Reference<XText> xText; - aAny >>= xText; - if (xText.is()) - { - // export the auto styles - rExport.GetTextParagraphExport()->collectTextAutoStyles(xText); - } -} - -void XMLRedlineExport::ExportChangesListAutoStyles() -{ - // 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()) - { - // 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()) - { - - // export only if not in header or footer - // (those must be exported with their XText) - aAny = xPropSet->getPropertyValue(sIsInHeaderFooter); - if (! *static_cast<sal_Bool const *>(aAny.getValue())) - { - ExportChangeAutoStyle(xPropSet); - } - } - } - } - } -} - void XMLRedlineExport::ExportUndoChangeInline( const Reference<XPropertySet> & rPropSet, const sal_uInt32& rParaIdx) { @@ -388,126 +190,6 @@ void XMLRedlineExport::ExportUndoChangeInline( } } -void XMLRedlineExport::ExportChangeInline( - const Reference<XPropertySet> & rPropSet) -{ - // determine element name (depending on collapsed, start/end) - enum XMLTokenEnum eElement = XML_TOKEN_INVALID; - Any aAny = rPropSet->getPropertyValue(sIsCollapsed); - bool bCollapsed = *static_cast<sal_Bool const *>(aAny.getValue()); - if (bCollapsed) - { - eElement = XML_CHANGE; - } - else - { - aAny = rPropSet->getPropertyValue(sIsStart); - const bool bStart = *static_cast<sal_Bool const *>(aAny.getValue()); - eElement = bStart ? XML_CHANGE_START : XML_CHANGE_END; - } - - if (XML_TOKEN_INVALID != eElement) - { - // we always need the ID - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_CHANGE_ID, - GetRedlineID(rPropSet)); - - // export the element (no whitespace because we're in the text body) - SvXMLElementExport aChangeElem(rExport, XML_NAMESPACE_TEXT, - eElement, false, false); - } -} - - -void XMLRedlineExport::ExportChangedRegion( - const Reference<XPropertySet> & rPropSet) -{ - // Redline-ID - rExport.AddAttributeIdLegacy(XML_NAMESPACE_TEXT, GetRedlineID(rPropSet)); - - // merge-last-paragraph - Any aAny = rPropSet->getPropertyValue(sMergeLastPara); - if( ! *static_cast<sal_Bool const *>(aAny.getValue()) ) - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_MERGE_LAST_PARAGRAPH, - XML_FALSE); - - // export change region element - SvXMLElementExport aChangedRegion(rExport, XML_NAMESPACE_TEXT, - XML_CHANGED_REGION, true, true); - - - // scope for (first) change element - { - aAny = rPropSet->getPropertyValue(sRedlineType); - OUString sType; - aAny >>= sType; - - sal_uInt32 nParagraphIdx = 2, nCharStart, nCharEnd; - rPropSet->getPropertyValue(sRedlineUndoStart) >>= nCharStart; - rPropSet->getPropertyValue(sRedlineUndoEnd) >>= nCharEnd; - - XMLTokenEnum eUndoType = XML_PARAGRAPH; - OUString sUndoType; - aAny = rPropSet->getPropertyValue(sRedlineUndoType); - aAny >>= sUndoType; - - if( sUndoType == "text" ) - eUndoType = XML_TEXT; - if(eUndoType == XML_PARAGRAPH) - { - rExport.AddAttribute(XML_NAMESPACE_C, XML_START, "/" + rtl::OUString::number(nParagraphIdx)); - rExport.AddAttribute(XML_NAMESPACE_DC, XML_TYPE, XML_PARAGRAPH); - } - else - { - rExport.AddAttribute(XML_NAMESPACE_C, XML_START, "/" + rtl::OUString::number(nParagraphIdx) + "/" + rtl::OUString::number(nCharStart)); - if( sType == sInsert || sType == sFormat ) - rExport.AddAttribute(XML_NAMESPACE_C, XML_END, "/" + rtl::OUString::number(nParagraphIdx) + "/" + rtl::OUString::number(nCharEnd)); - if( sType != sFormat ) - rExport.AddAttribute(XML_NAMESPACE_DC, XML_TYPE, XML_TEXT); - } - SvXMLElementExport aChange(rExport, XML_NAMESPACE_TEXT, - ConvertTypeName(sType), true, 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()) - { - 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. - 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, XML_INSERTION, - true, true); - - ExportChangeInfo(aSuccessorData); - } - // else: no hierarchical change -} - - const OUString XMLRedlineExport::ConvertTypeName( const OUString& sApiName) { @@ -530,20 +212,6 @@ const OUString XMLRedlineExport::ConvertTypeName( } } - -/** Create a Redline-ID */ -const OUString XMLRedlineExport::GetRedlineID( - const Reference<XPropertySet> & rPropSet) -{ - Any aAny = rPropSet->getPropertyValue(sRedlineIdentifier); - OUString sTmp; - aAny >>= sTmp; - - OUStringBuffer sBuf(sChangePrefix); - sBuf.append(sTmp); - return sBuf.makeStringAndClear(); -} - void XMLRedlineExport::ExportUndoChangeInfo( const Reference<XPropertySet> & rPropSet, const sal_uInt32& rParaIdx) { @@ -574,92 +242,6 @@ void XMLRedlineExport::ExportUndoChangeInfo( } } -void XMLRedlineExport::ExportChangeInfo( - const Reference<XPropertySet> & rPropSet) -{ - - SvXMLElementExport aChangeInfo(rExport, XML_NAMESPACE_OFFICE, - XML_CHANGE_INFO, true, true); - - Any aAny = rPropSet->getPropertyValue(sRedlineAuthor); - OUString sTmp; - aAny >>= sTmp; - if (!sTmp.isEmpty()) - { - SvXMLElementExport aCreatorElem( rExport, XML_NAMESPACE_DC, - XML_CREATOR, true, - false ); - rExport.Characters(sTmp); - } - - aAny = rPropSet->getPropertyValue(sRedlineDateTime); - util::DateTime aDateTime; - aAny >>= aDateTime; - { - OUStringBuffer sBuf; - ::sax::Converter::convertDateTime(sBuf, aDateTime, nullptr); - SvXMLElementExport aDateElem( rExport, XML_NAMESPACE_DC, - XML_DATE, true, - false ); - rExport.Characters(sBuf.makeStringAndClear()); - } - - // comment as <text:p> sequence - aAny = rPropSet->getPropertyValue(sRedlineComment); - aAny >>= sTmp; - WriteComment( sTmp ); -} - -void XMLRedlineExport::ExportChangeInfo( - const Sequence<PropertyValue> & rPropertyValues) -{ - OUString sComment; - - sal_Int32 nCount = rPropertyValues.getLength(); - for(sal_Int32 i = 0; i < nCount; i++) - { - const PropertyValue& rVal = rPropertyValues[i]; - - if( rVal.Name.equals(sRedlineAuthor) ) - { - OUString sTmp; - rVal.Value >>= sTmp; - if (!sTmp.isEmpty()) - { - rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_CHG_AUTHOR, sTmp); - } - } - else if( rVal.Name.equals(sRedlineComment) ) - { - rVal.Value >>= sComment; - } - else if( rVal.Name.equals(sRedlineDateTime) ) - { - util::DateTime aDateTime; - rVal.Value >>= aDateTime; - OUStringBuffer sBuf; - ::sax::Converter::convertDateTime(sBuf, aDateTime, nullptr); - rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_CHG_DATE_TIME, - sBuf.makeStringAndClear()); - } - else if( rVal.Name.equals(sRedlineType) ) - { - // check if this is an insertion; cf. comment at calling location - OUString sTmp; - rVal.Value >>= sTmp; - DBG_ASSERT(sTmp.equals(sInsert), - "hierarchical change must be insertion"); - } - // else: unknown value -> ignore - } - - // finally write element - SvXMLElementExport aChangeInfo(rExport, XML_NAMESPACE_OFFICE, - XML_CHANGE_INFO, true, true); - - WriteComment( sComment ); -} - void XMLRedlineExport::ExportStartOrEndRedline( const Reference<XPropertySet> & rPropSet, bool bStart) diff --git a/xmloff/source/text/XMLRedlineExport.hxx b/xmloff/source/text/XMLRedlineExport.hxx index bac2901..bc86667 100644 --- a/xmloff/source/text/XMLRedlineExport.hxx +++ b/xmloff/source/text/XMLRedlineExport.hxx @@ -109,19 +109,6 @@ public: const sal_uInt32& rParaIdx, bool bAutoStyle); - void ExportChange( - /// PropertySet of RedlinePortion - const css::uno::Reference<css::beans::XPropertySet> & rPropSet, - bool bAutoStyle); - - /// export the list of changes (complete list minus recorded changed) - void ExportChangesList(bool bAutoStyles); - - /// export the list of changes (recorded changes for this XText only) - void ExportChangesList( - const css::uno::Reference<css::text::XText> & rText, - bool bAutoStyles); - /// set the current XText for which changes should be recorded. /// An empty XText means: don't record changes void SetCurrentXText( @@ -156,43 +143,13 @@ private: /// PropertySet of RedlinePortion const css::uno::Reference<css::beans::XPropertySet> & rPropSet, const sal_uInt32& rParaIdx); - void ExportChangeInline( - /// PropertySet of RedlinePortion - const css::uno::Reference<css::beans::XPropertySet> & rPropSet); - - /// export the auto styles used in this change - void ExportChangeAutoStyle( - /// PropertySet of RedlinePortion - const css::uno::Reference<css::beans::XPropertySet> & rPropSet); - - /// 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 css::uno::Reference<css::beans::XPropertySet> & rPropSet); - /// export an change-info element (from a PropertySet) void ExportUndoChangeInfo( const css::uno::Reference<css::beans::XPropertySet> & rPropSet, const sal_uInt32& rParaIdx); - void ExportChangeInfo( - const css::uno::Reference<css::beans::XPropertySet> & rPropSet); - - /// export an change-info element (from PropertyValues) - void ExportChangeInfo( - const css::uno::Sequence<css::beans::PropertyValue> & rValues); - /// convert the change type from API to XML names const OUString ConvertTypeName(const OUString& sApiName); - /// Get ID string! - const OUString GetRedlineID( - const css::uno::Reference<css::beans::XPropertySet> & rPropSet); - /// write a comment string as sequence of <text:p> elements void WriteComment(const OUString& rComment); }; diff --git a/xmloff/source/text/XMLTextMasterPageExport.cxx b/xmloff/source/text/XMLTextMasterPageExport.cxx index a5ad798..a2ce2c1 100644 --- a/xmloff/source/text/XMLTextMasterPageExport.cxx +++ b/xmloff/source/text/XMLTextMasterPageExport.cxx @@ -74,6 +74,7 @@ void XMLTextMasterPageExport::exportHeaderFooterContent( // tracked changes (end of XText) GetExport().GetTextParagraphExport()->recordTrackedChangesNoXText(); + GetExport().GetTextParagraphExport()->exportTrackedChanges( rText ); } void XMLTextMasterPageExport::exportMasterPageContent( diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 6687c73..c51bd8e 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -1632,9 +1632,7 @@ bool XMLTextParagraphExport::collectTextAutoStylesOptimized( bool bIsProgress ) void XMLTextParagraphExport::exportUndoText( const Reference < XText > & rText, bool bAutoStyles, - bool bIsProgress, - bool bExportParagraph, - TextPNS eExtensionNS) + bool bIsProgress) { if( bAutoStyles ) GetExport().GetShapeExport(); // make sure the graphics styles family @@ -1644,14 +1642,10 @@ void XMLTextParagraphExport::exportUndoText( Reference < XPropertySet > xPropertySet( rText, UNO_QUERY ); Reference < XTextSection > xBaseSection; - // #97718# footnotes don't supply paragraph enumerations in some cases - // This is always a bug, but at least we don't want to crash. DBG_ASSERT( xParaEnum.is(), "We need a paragraph enumeration" ); if( ! xParaEnum.is() ) return; - bool bExportLevels = true; - if (xPropertySet.is()) { Reference < XPropertySetInfo > xInfo ( xPropertySet->getPropertySetInfo() ); @@ -1662,21 +1656,6 @@ void XMLTextParagraphExport::exportUndoText( { xPropertySet->getPropertyValue(sTextSection) >>= xBaseSection ; } - -/* #i35937# - // for applications that use the outliner we need to check if - // the current text object needs the level information exported - if( !bAutoStyles ) - { - // fixme: move string to class member, couldn't do now because - // of no incompatible build - OUString sHasLevels( "HasLevels" ); - if (xInfo->hasPropertyByName( sHasLevels ) ) - { - xPropertySet->getPropertyValue(sHasLevels) >>= bExportLevels; - } - } -*/ } } @@ -1684,8 +1663,7 @@ void XMLTextParagraphExport::exportUndoText( // exporting the text content enumeration if( !bAutoStyles && (pRedlineExport != nullptr) ) pRedlineExport->ExportStartOrEndRedline( xPropertySet, true ); - exportUndoTextContentEnumeration( xParaEnum, bAutoStyles, xBaseSection, - bIsProgress, bExportParagraph, nullptr, bExportLevels, eExtensionNS ); + exportUndoTextContentEnumeration( xParaEnum, bAutoStyles, xBaseSection, bIsProgress); if( !bAutoStyles && (pRedlineExport != nullptr) ) pRedlineExport->ExportStartOrEndRedline( xPropertySet, false ); } @@ -1787,20 +1765,13 @@ bool XMLTextParagraphExport::exportUndoTextContentEnumeration( const Reference < XEnumeration > & rContEnum, bool bAutoStyles, const Reference < XTextSection > & rBaseSection, - bool bIsProgress, - bool bExportParagraph, - const Reference < XPropertySet > *pRangePropSet, - bool bExportLevels, TextPNS eExtensionNS ) + bool bIsProgress) { DBG_ASSERT( rContEnum.is(), "No enumeration to export!" ); bool bHasMoreElements = rContEnum->hasMoreElements(); if( !bHasMoreElements ) return false; - XMLTextNumRuleInfo aPrevNumInfo; - XMLTextNumRuleInfo aNextNumInfo; - - bool bHasContent = false; Reference<XTextSection> xCurrentTextSection(rBaseSection); MultiPropertySetHelper aPropSetHelper( @@ -1826,46 +1797,15 @@ bool XMLTextParagraphExport::exportUndoTextContentEnumeration( Reference<XServiceInfo> xServiceInfo( xTxtCntnt, UNO_QUERY ); if( xServiceInfo->supportsService( sParagraphService ) ) { - if( bExportLevels ) - { - if( bAutoStyles ) - { - exportListAndSectionChange( xCurrentTextSection, xTxtCntnt, - aPrevNumInfo, aNextNumInfo, - bAutoStyles ); - } - else - { - /* Pass list auto style pool to <XMLTextNumRuleInfo> instance - Pass info about request to export <text:number> element - to <XMLTextNumRuleInfo> instance (#i69627#) - */ - aNextNumInfo.Set( xTxtCntnt, - GetExport().writeOutlineStyleAsNormalListStyle(), - GetListAutoStylePool(), - GetExport().exportTextNumberElement() ); - - exportListAndSectionChange( xCurrentTextSection, aPropSetHelper, - TEXT_SECTION, xTxtCntnt, - aPrevNumInfo, aNextNumInfo, - bAutoStyles ); - } - } - // if we found a mute section: skip all section content if (pSectionExport->IsMuteSection(xCurrentTextSection)) { - // Make sure headings are exported anyway. - if( !bAutoStyles ) - pSectionExport->ExportMasterDocHeadingDummies(); - while (rContEnum->hasMoreElements() && pSectionExport->IsInSection( xCurrentTextSection, xTxtCntnt, true )) { xTxtCntnt.set(rContEnum->nextElement(), uno::UNO_QUERY); aPropSetHelper.resetValues(); - aNextNumInfo.Reset(); } // the first non-mute element still needs to be processed bHoldElement = @@ -1875,80 +1815,11 @@ bool XMLTextParagraphExport::exportUndoTextContentEnumeration( else { setParaIdx(getParaIdx() + 1); - exportUndoParagraph( xTxtCntnt, getParaIdx(), bAutoStyles, bIsProgress, - bExportParagraph, aPropSetHelper, eExtensionNS ); - } - bHasContent = true; - } - else if( xServiceInfo->supportsService( sTableService ) ) - { - if( !bAutoStyles ) - { - aNextNumInfo.Reset(); - } - - exportListAndSectionChange( xCurrentTextSection, xTxtCntnt, - aPrevNumInfo, aNextNumInfo, - bAutoStyles ); - - if (! pSectionExport->IsMuteSection(xCurrentTextSection)) - { - // export start + end redlines (for wholly redlined tables) - if ((! bAutoStyles) && (nullptr != pRedlineExport)) - pRedlineExport->ExportStartOrEndRedline(xTxtCntnt, true); - - exportTable( xTxtCntnt, bAutoStyles, bIsProgress ); - - if ((! bAutoStyles) && (nullptr != pRedlineExport)) - pRedlineExport->ExportStartOrEndRedline(xTxtCntnt, false); - } - else if( !bAutoStyles ) - { - // Make sure headings are exported anyway. - pSectionExport->ExportMasterDocHeadingDummies(); + exportUndoParagraph( xTxtCntnt, getParaIdx(), bAutoStyles, bIsProgress, aPropSetHelper ); } - - bHasContent = true; - } - else if( xServiceInfo->supportsService( sTextFrameService ) ) - { - exportTextFrame( xTxtCntnt, bAutoStyles, bIsProgress, true, pRangePropSet ); - } - else if( xServiceInfo->supportsService( sTextGraphicService ) ) - { - exportTextGraphic( xTxtCntnt, bAutoStyles, pRangePropSet ); - } - else if( xServiceInfo->supportsService( sTextEmbeddedService ) ) - { - exportTextEmbedded( xTxtCntnt, bAutoStyles, pRangePropSet ); - } - else if( xServiceInfo->supportsService( sShapeService ) ) - { - exportShape( xTxtCntnt, bAutoStyles, pRangePropSet ); } - else - { - DBG_ASSERT( !xTxtCntnt.is(), "unknown text content" ); - } - - if( !bAutoStyles ) - { - aPrevNumInfo = aNextNumInfo; - } - bHasMoreElements = rContEnum->hasMoreElements(); } - - if( bExportLevels && bHasContent && !bAutoStyles ) - { - aNextNumInfo.Reset(); - - // close open lists and sections; no new styles - exportListAndSectionChange( xCurrentTextSection, rBaseSection, - aPrevNumInfo, aNextNumInfo, - bAutoStyles ); - } - return true; } @@ -2122,11 +1993,9 @@ bool XMLTextParagraphExport::exportTextContentEnumeration( void XMLTextParagraphExport::exportUndoParagraph( const Reference < XTextContent > & rTextContent, const sal_uInt32& rParaIdx, - bool bAutoStyles, bool bIsProgress, bool bExportParagraph, - MultiPropertySetHelper& rPropSetHelper, TextPNS eExtensionNS) + bool bAutoStyles, bool bIsProgress, + MultiPropertySetHelper& rPropSetHelper) { - sal_Int16 nOutlineLevel = -1; - if( bIsProgress ) { ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper(); @@ -2141,185 +2010,6 @@ void XMLTextParagraphExport::exportUndoParagraph( if( !rPropSetHelper.checkedProperties() ) rPropSetHelper.hasProperties( xPropSet->getPropertySetInfo() ); -// if( xMultiPropSet.is() ) -// rPropSetHelper.getValues( xMultiPropSet ); -// else -// rPropSetHelper.getValues( xPropSet ); - - if( bExportParagraph ) - { - if( bAutoStyles ) - { - Add( XML_STYLE_FAMILY_TEXT_PARAGRAPH, rPropSetHelper, xPropSet ); - } - else - { - // xml:id for RDF metadata - GetExport().AddAttributeXmlId(rTextContent); - GetExport().AddAttributesRDFa(rTextContent); - - OUString sStyle; - if( rPropSetHelper.hasProperty( PARA_STYLE_NAME ) ) - { - if( xMultiPropSet.is() ) - rPropSetHelper.getValue( PARA_STYLE_NAME, - xMultiPropSet ) >>= sStyle; - else - rPropSetHelper.getValue( PARA_STYLE_NAME, - xPropSet ) >>= sStyle; - } - - if( rTextContent.is() ) - { - const OUString& rIdentifier = GetExport().getInterfaceToIdentifierMapper().getIdentifier( rTextContent ); - if( !rIdentifier.isEmpty() ) - { - // FIXME: this is just temporary until EditEngine - // paragraphs implement XMetadatable. - // then that must be used and not the mapper, because - // when both can be used we get two xml:id! - uno::Reference<rdf::XMetadatable> const xMeta(rTextContent, - uno::UNO_QUERY); - OSL_ENSURE(!xMeta.is(), "paragraph that implements " - "XMetadatable used in interfaceToIdentifierMapper?"); - GetExport().AddAttributeIdLegacy(XML_NAMESPACE_TEXT, - rIdentifier); - } - } - - OUString sAutoStyle( sStyle ); - sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet, sStyle ); - if( !sAutoStyle.isEmpty() ) - GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, - GetExport().EncodeStyleName( sAutoStyle ) ); - - if( rPropSetHelper.hasProperty( PARA_CONDITIONAL_STYLE_NAME ) ) - { - OUString sCondStyle; - if( xMultiPropSet.is() ) - rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME, - xMultiPropSet ) >>= sCondStyle; - else - rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME, - xPropSet ) >>= sCondStyle; - if( sCondStyle != sStyle ) - { - sCondStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet, - sCondStyle ); - if( !sCondStyle.isEmpty() ) - GetExport().AddAttribute( XML_NAMESPACE_TEXT, - XML_COND_STYLE_NAME, - GetExport().EncodeStyleName( sCondStyle ) ); - } - } - - if( rPropSetHelper.hasProperty( PARA_OUTLINE_LEVEL ) ) - { - if( xMultiPropSet.is() ) - rPropSetHelper.getValue( PARA_OUTLINE_LEVEL, - xMultiPropSet ) >>= nOutlineLevel; - else - rPropSetHelper.getValue( PARA_OUTLINE_LEVEL, - xPropSet ) >>= nOutlineLevel; - - if( 0 < nOutlineLevel ) - { - OUStringBuffer sTmp; - sTmp.append( sal_Int32( nOutlineLevel) ); - GetExport().AddAttribute( XML_NAMESPACE_TEXT, - XML_OUTLINE_LEVEL, - sTmp.makeStringAndClear() ); - - if( rPropSetHelper.hasProperty( NUMBERING_IS_NUMBER ) ) - { - bool bIsNumber = false; - if( xMultiPropSet.is() ) - rPropSetHelper.getValue( - NUMBERING_IS_NUMBER, xMultiPropSet ) >>= bIsNumber; - else - rPropSetHelper.getValue( - NUMBERING_IS_NUMBER, xPropSet ) >>= bIsNumber; - - OUString sListStyleName; - if( xMultiPropSet.is() ) - rPropSetHelper.getValue( - PARA_NUMBERING_STYLENAME, xMultiPropSet ) >>= sListStyleName; - else - rPropSetHelper.getValue( - PARA_NUMBERING_STYLENAME, xPropSet ) >>= sListStyleName; - - bool bAssignedtoOutlineStyle = false; - { - Reference< XChapterNumberingSupplier > xCNSupplier( GetExport().GetModel(), UNO_QUERY ); - - OUString sOutlineName; - if (xCNSupplier.is()) - { - Reference< XIndexReplace > xNumRule ( xCNSupplier->getChapterNumberingRules() ); - DBG_ASSERT( xNumRule.is(), "no chapter numbering rules" ); - - if (xNumRule.is()) - { - Reference< XPropertySet > xNumRulePropSet( xNumRule, UNO_QUERY ); - xNumRulePropSet->getPropertyValue( - "Name" ) >>= sOutlineName; - bAssignedtoOutlineStyle = ( sListStyleName == sOutlineName ); - } - } - } - - if( ! bIsNumber && bAssignedtoOutlineStyle ) - GetExport().AddAttribute( XML_NAMESPACE_TEXT, - XML_IS_LIST_HEADER, - XML_TRUE ); - } - - { - bool bIsRestartNumbering = false; - - Reference< XPropertySetInfo > - xPropSetInfo(xMultiPropSet.is() ? - xMultiPropSet->getPropertySetInfo(): - xPropSet->getPropertySetInfo()); - - if (xPropSetInfo-> - hasPropertyByName("ParaIsNumberingRestart")) - { - xPropSet->getPropertyValue("ParaIsNumberingRestart") - >>= bIsRestartNumbering; - } - - if (bIsRestartNumbering) - { - GetExport().AddAttribute(XML_NAMESPACE_TEXT, - XML_RESTART_NUMBERING, - XML_TRUE); - - if (xPropSetInfo-> - hasPropertyByName("NumberingStartValue")) - { - sal_Int32 nStartValue = 0; - - xPropSet->getPropertyValue("NumberingStartValue") - >>= nStartValue; - - OUStringBuffer sTmpStartValue; - - sTmpStartValue.append(nStartValue); - - GetExport(). - AddAttribute(XML_NAMESPACE_TEXT, - XML_START_VALUE, - sTmpStartValue. - makeStringAndClear()); - } - } - } - } - } - } - } - Reference < XEnumerationAccess > xEA( rTextContent, UNO_QUERY ); Reference < XEnumeration > xTextEnum; xTextEnum = xEA->createEnumeration(); @@ -2362,20 +2052,10 @@ void XMLTextParagraphExport::exportUndoParagraph( xContentEnum, bAutoStyles, xSection, bIsProgress ); if ( bHasPortions ) - exportUndoTextRangeEnumeration( xTextEnum, rParaIdx, bAutoStyles, bIsProgress ); + exportUndoTextRangeEnumeration( xTextEnum, rParaIdx, bAutoStyles ); } else - { - bool bPrevCharIsSpace = true; - enum XMLTokenEnum eElem = - 0 < nOutlineLevel ? XML_H : XML_P; - if( bHasContentEnum ) - bPrevCharIsSpace = !exportUndoTextContentEnumeration( - xContentEnum, bAutoStyles, xSection, - bIsProgress ); - exportUndoTextRangeEnumeration( xTextEnum, rParaIdx, bAutoStyles, bIsProgress, - bPrevCharIsSpace ); - } + exportUndoTextRangeEnumeration( xTextEnum, rParaIdx, bAutoStyles ); } void XMLTextParagraphExport::exportParagraph( @@ -2641,20 +2321,8 @@ void XMLTextParagraphExport::exportParagraph( void XMLTextParagraphExport::exportUndoTextRangeEnumeration( const Reference < XEnumeration > & rTextEnum, const sal_uInt32& rParaIdx, - bool bAutoStyles, bool bIsProgress, - bool bPrvChrIsSpc ) + bool bAutoStyles ) { - static const char sMeta[] = "InContentMetadata"; - static const char sFieldMarkName[] = "__FieldMark_"; - static const char sAnnotation[] = "Annotation"; - static const char sAnnotationEnd[] = "AnnotationEnd"; - - bool bPrevCharIsSpace = bPrvChrIsSpc; - - /* This is used for exporting to strict OpenDocument 1.2, in which case traditional - * bookmarks are used instead of fieldmarks. */ - FieldmarkType openFieldMark = NONE; - while( rTextEnum->hasMoreElements() ) { Reference<XPropertySet> xPropSet(rTextEnum->nextElement(), UNO_QUERY); @@ -2673,9 +2341,6 @@ void XMLTextParagraphExport::exportUndoTextRangeEnumeration( } } } - -// now that there are nested enumerations for meta(-field), this may be valid! -// DBG_ASSERT( !bOpenRuby, "Red Alert: Ruby still open!" ); } void XMLTextParagraphExport::exportTextRangeEnumeration( @@ -2778,8 +2443,7 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( } else if (sType.equals(sRedline)) { - if (nullptr != pRedlineExport) - pRedlineExport->ExportChange(xPropSet, bAutoStyles); + continue; } else if (sType.equals(sRuby)) { @@ -4096,20 +3760,6 @@ void XMLTextParagraphExport::exportUsedDeclarations() pFieldExport->SetExportOnlyUsedFieldDeclarations( false/*bOnlyUsed*/ ); } -void XMLTextParagraphExport::exportTrackedChanges(bool bAutoStyles) -{ - if (nullptr != pRedlineExport) - pRedlineExport->ExportChangesList( bAutoStyles ); -} - -void XMLTextParagraphExport::exportTrackedChanges( - const Reference<XText> & rText, - bool bAutoStyle) -{ - if (nullptr != pRedlineExport) - pRedlineExport->ExportChangesList(rText, bAutoStyle); -} - void XMLTextParagraphExport::recordTrackedChangesForXText( const Reference<XText> & rText ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits