diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-11-12 17:04:46 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-11-12 20:51:37 +0100 |
commit | e7051ed1ee5995860f18145b725c71a873ed60f2 (patch) | |
tree | 20a88512495a21137f3309bd198ec200f25128aa /xmloff | |
parent | 03edebda393ea684803b7a0da72f33655bdc24d1 (diff) |
rename now it does more than just sort
Change-Id: Ia0adffc592105efeeebfeb8fc67570d3f6d844f1
Reviewed-on: https://gerrit.libreoffice.org/82544
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/draw/shapeimport.cxx | 58 | ||||
-rw-r--r-- | xmloff/source/draw/ximp3dscene.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/draw/ximpgrp.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/draw/ximppage.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextShapeImportHelper.cxx | 4 |
5 files changed, 38 insertions, 36 deletions
diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx index 2f8faf02ae30..59d08cacfed1 100644 --- a/xmloff/source/draw/shapeimport.cxx +++ b/xmloff/source/draw/shapeimport.cxx @@ -47,7 +47,7 @@ #include <map> #include <vector> -class ShapeSortContext; +class ShapeGroupContext; using namespace ::std; using namespace ::com::sun::star; @@ -91,7 +91,7 @@ struct XMLShapeImportPageContextImpl struct XMLShapeImportHelperImpl { // context for sorting shapes - std::shared_ptr<ShapeSortContext> mpSortContext; + std::shared_ptr<ShapeGroupContext> mpGroupContext; std::vector<ConnectionHint> maConnections; @@ -114,7 +114,7 @@ XMLShapeImportHelper::XMLShapeImportHelper( : mpImpl( new XMLShapeImportHelperImpl ), mrImporter( rImporter ) { - mpImpl->mpSortContext = nullptr; + mpImpl->mpGroupContext = nullptr; // #88546# init to sal_False mpImpl->mbHandleProgressBar = false; @@ -705,7 +705,9 @@ struct ZOrderHint bool operator<(const ZOrderHint& rComp) const { return nShould < rComp.nShould; } }; -class ShapeSortContext +// a) handle z-order of group contents after it has been imported +// b) apply group events over group contents after it has been imported +class ShapeGroupContext { public: uno::Reference< drawing::XShapes > mxShapes; @@ -714,21 +716,21 @@ public: vector<ZOrderHint> maUnsortedList; sal_Int32 mnCurrentZ; - std::shared_ptr<ShapeSortContext> mpParentContext; + std::shared_ptr<ShapeGroupContext> mpParentContext; - ShapeSortContext( uno::Reference< drawing::XShapes > const & rShapes, std::shared_ptr<ShapeSortContext> pParentContext ); + ShapeGroupContext( uno::Reference< drawing::XShapes > const & rShapes, std::shared_ptr<ShapeGroupContext> pParentContext ); - void popGroupAndSort(); + void popGroupAndPostProcess(); private: void moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos ); }; -ShapeSortContext::ShapeSortContext( uno::Reference< drawing::XShapes > const & rShapes, std::shared_ptr<ShapeSortContext> pParentContext ) +ShapeGroupContext::ShapeGroupContext( uno::Reference< drawing::XShapes > const & rShapes, std::shared_ptr<ShapeGroupContext> pParentContext ) : mxShapes( rShapes ), mnCurrentZ( 0 ), mpParentContext( std::move(pParentContext) ) { } -void ShapeSortContext::moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos ) +void ShapeGroupContext::moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos ) { uno::Any aAny( mxShapes->getByIndex( nSourcePos ) ); uno::Reference< beans::XPropertySet > xPropSet; @@ -759,7 +761,7 @@ void ShapeSortContext::moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos ) } // sort shapes -void ShapeSortContext::popGroupAndSort() +void ShapeGroupContext::popGroupAndPostProcess() { if (!maEventData.empty()) { @@ -865,33 +867,33 @@ void ShapeSortContext::popGroupAndSort() maZOrderList.clear(); } -void XMLShapeImportHelper::pushGroupForSorting( uno::Reference< drawing::XShapes >& rShapes ) +void XMLShapeImportHelper::pushGroupForPostProcessing( uno::Reference< drawing::XShapes >& rShapes ) { - mpImpl->mpSortContext = std::make_shared<ShapeSortContext>( rShapes, mpImpl->mpSortContext ); + mpImpl->mpGroupContext = std::make_shared<ShapeGroupContext>( rShapes, mpImpl->mpGroupContext ); } void XMLShapeImportHelper::addShapeEvents(SdXMLEventContextData& rData) { - if (mpImpl->mpSortContext && mpImpl->mpSortContext->mxShapes == rData.mxShape) + if (mpImpl->mpGroupContext && mpImpl->mpGroupContext->mxShapes == rData.mxShape) { // tdf#127791 wait until a group is popped to set its event data so // that the events are applied to all its children, which are not available // at the start of the group tag - mpImpl->mpSortContext->maEventData.push_back(rData); + mpImpl->mpGroupContext->maEventData.push_back(rData); } else rData.ApplyProperties(); } -void XMLShapeImportHelper::popGroupAndSort() +void XMLShapeImportHelper::popGroupAndPostProcess() { - SAL_WARN_IF( !mpImpl->mpSortContext, "xmloff", "No context to sort!" ); - if( !mpImpl->mpSortContext ) + SAL_WARN_IF( !mpImpl->mpGroupContext, "xmloff", "No context to sort!" ); + if( !mpImpl->mpGroupContext ) return; try { - mpImpl->mpSortContext->popGroupAndSort(); + mpImpl->mpGroupContext->popGroupAndPostProcess(); } catch( const uno::Exception& ) { @@ -899,51 +901,51 @@ void XMLShapeImportHelper::popGroupAndSort() } // put parent on top and drop current context, we are done - mpImpl->mpSortContext = mpImpl->mpSortContext->mpParentContext; + mpImpl->mpGroupContext = mpImpl->mpGroupContext->mpParentContext; } void XMLShapeImportHelper::shapeWithZIndexAdded( css::uno::Reference< css::drawing::XShape > const & xShape, sal_Int32 nZIndex ) { - if( mpImpl->mpSortContext) + if( mpImpl->mpGroupContext) { ZOrderHint aNewHint; - aNewHint.nIs = mpImpl->mpSortContext->mnCurrentZ++; + aNewHint.nIs = mpImpl->mpGroupContext->mnCurrentZ++; aNewHint.nShould = nZIndex; aNewHint.xShape = xShape; if( nZIndex == -1 ) { // don't care, so add to unsorted list - mpImpl->mpSortContext->maUnsortedList.push_back(aNewHint); + mpImpl->mpGroupContext->maUnsortedList.push_back(aNewHint); } else { // insert into sort list - mpImpl->mpSortContext->maZOrderList.push_back(aNewHint); + mpImpl->mpGroupContext->maZOrderList.push_back(aNewHint); } } } void XMLShapeImportHelper::shapeRemoved(const uno::Reference<drawing::XShape>& xShape) { - auto it = std::find_if(mpImpl->mpSortContext->maZOrderList.begin(), mpImpl->mpSortContext->maZOrderList.end(), [&xShape](const ZOrderHint& rHint) + auto it = std::find_if(mpImpl->mpGroupContext->maZOrderList.begin(), mpImpl->mpGroupContext->maZOrderList.end(), [&xShape](const ZOrderHint& rHint) { return rHint.xShape == xShape; }); - if (it == mpImpl->mpSortContext->maZOrderList.end()) + if (it == mpImpl->mpGroupContext->maZOrderList.end()) // Part of the unsorted list, nothing to do. return; sal_Int32 nZIndex = it->nIs; - for (it = mpImpl->mpSortContext->maZOrderList.begin(); it != mpImpl->mpSortContext->maZOrderList.end();) + for (it = mpImpl->mpGroupContext->maZOrderList.begin(); it != mpImpl->mpGroupContext->maZOrderList.end();) { if (it->nIs == nZIndex) { // This is xShape: remove it and adjust the max of indexes // accordingly. - it = mpImpl->mpSortContext->maZOrderList.erase(it); - mpImpl->mpSortContext->mnCurrentZ--; + it = mpImpl->mpGroupContext->maZOrderList.erase(it); + mpImpl->mpGroupContext->mnCurrentZ--; continue; } else if (it->nIs > nZIndex) diff --git a/xmloff/source/draw/ximp3dscene.cxx b/xmloff/source/draw/ximp3dscene.cxx index cef9a89e74a8..9a2843dcc37e 100644 --- a/xmloff/source/draw/ximp3dscene.cxx +++ b/xmloff/source/draw/ximp3dscene.cxx @@ -124,7 +124,7 @@ void SdXML3DSceneShapeContext::StartElement(const uno::Reference< xml::sax::XAtt mxChildren.set( mxShape, uno::UNO_QUERY ); if( mxChildren.is() ) - GetImport().GetShapeImport()->pushGroupForSorting( mxChildren ); + GetImport().GetShapeImport()->pushGroupForPostProcessing( mxChildren ); SetLayer(); @@ -162,7 +162,7 @@ void SdXML3DSceneShapeContext::EndElement() } if( mxChildren.is() ) - GetImport().GetShapeImport()->popGroupAndSort(); + GetImport().GetShapeImport()->popGroupAndPostProcess(); // call parent SdXMLShapeContext::EndElement(); diff --git a/xmloff/source/draw/ximpgrp.cxx b/xmloff/source/draw/ximpgrp.cxx index 29a3041494c5..549782fa41c0 100644 --- a/xmloff/source/draw/ximpgrp.cxx +++ b/xmloff/source/draw/ximpgrp.cxx @@ -89,7 +89,7 @@ void SdXMLGroupShapeContext::StartElement(const uno::Reference< xml::sax::XAttri mxChildren.set( mxShape, uno::UNO_QUERY ); if( mxChildren.is() ) - GetImport().GetShapeImport()->pushGroupForSorting( mxChildren ); + GetImport().GetShapeImport()->pushGroupForPostProcessing( mxChildren ); } GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); @@ -98,7 +98,7 @@ void SdXMLGroupShapeContext::StartElement(const uno::Reference< xml::sax::XAttri void SdXMLGroupShapeContext::EndElement() { if( mxChildren.is() ) - GetImport().GetShapeImport()->popGroupAndSort(); + GetImport().GetShapeImport()->popGroupAndPostProcess(); SdXMLShapeContext::EndElement(); } diff --git a/xmloff/source/draw/ximppage.cxx b/xmloff/source/draw/ximppage.cxx index 5681095d0944..af7fcdde026c 100644 --- a/xmloff/source/draw/ximppage.cxx +++ b/xmloff/source/draw/ximppage.cxx @@ -237,7 +237,7 @@ SdXMLGenericPageContext::~SdXMLGenericPageContext() void SdXMLGenericPageContext::StartElement( const Reference< css::xml::sax::XAttributeList >& ) { - GetImport().GetShapeImport()->pushGroupForSorting( mxShapes ); + GetImport().GetShapeImport()->pushGroupForPostProcessing( mxShapes ); if( GetImport().IsFormsSupported() ) GetImport().GetFormImport()->startPage( Reference< drawing::XDrawPage >::query( mxShapes ) ); @@ -279,7 +279,7 @@ SvXMLImportContextRef SdXMLGenericPageContext::CreateChildContext( sal_uInt16 nP void SdXMLGenericPageContext::EndElement() { - GetImport().GetShapeImport()->popGroupAndSort(); + GetImport().GetShapeImport()->popGroupAndPostProcess(); if( GetImport().IsFormsSupported() ) GetImport().GetFormImport()->endPage(); diff --git a/xmloff/source/text/XMLTextShapeImportHelper.cxx b/xmloff/source/text/XMLTextShapeImportHelper.cxx index cbac12006d95..89aefdb50a4f 100644 --- a/xmloff/source/text/XMLTextShapeImportHelper.cxx +++ b/xmloff/source/text/XMLTextShapeImportHelper.cxx @@ -54,14 +54,14 @@ XMLTextShapeImportHelper::XMLTextShapeImportHelper( if( xDPS.is() ) { Reference < XShapes > xShapes = xDPS->getDrawPage(); - pushGroupForSorting( xShapes ); + pushGroupForPostProcessing( xShapes ); } } XMLTextShapeImportHelper::~XMLTextShapeImportHelper() { - popGroupAndSort(); + popGroupAndPostProcess(); } void XMLTextShapeImportHelper::addShape( |