[Libreoffice-commits] core.git: include/xmloff sc/source xmloff/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Nov 12 19:53:36 UTC 2019


 include/xmloff/shapeimport.hxx                  |    7 +-
 sc/source/filter/xml/xmlsubti.cxx               |    2 
 sc/source/filter/xml/xmltabi.cxx                |    2 
 xmloff/source/draw/shapeimport.cxx              |   58 ++++++++++++------------
 xmloff/source/draw/ximp3dscene.cxx              |    4 -
 xmloff/source/draw/ximpgrp.cxx                  |    4 -
 xmloff/source/draw/ximppage.cxx                 |    4 -
 xmloff/source/text/XMLTextShapeImportHelper.cxx |    4 -
 8 files changed, 44 insertions(+), 41 deletions(-)

New commits:
commit e7051ed1ee5995860f18145b725c71a873ed60f2
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Nov 12 17:04:46 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Nov 12 20:51:37 2019 +0100

    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 at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/xmloff/shapeimport.hxx b/include/xmloff/shapeimport.hxx
index a20154a70387..12fe2aea6b08 100644
--- a/include/xmloff/shapeimport.hxx
+++ b/include/xmloff/shapeimport.hxx
@@ -311,9 +311,10 @@ public:
     // tdf#127791 help function for group shape events
     void addShapeEvents(SdXMLEventContextData& rData);
 
-    // helper functions for z-order sorting
-    void pushGroupForSorting( css::uno::Reference< css::drawing::XShapes >& rShapes );
-    void popGroupAndSort();
+    // helper functions processing groups after their component shapes are collected
+    // e.g. for z-order sorting or adding events to the group
+    void pushGroupForPostProcessing( css::uno::Reference< css::drawing::XShapes >& rShapes );
+    void popGroupAndPostProcess();
 
     void shapeWithZIndexAdded( css::uno::Reference< css::drawing::XShape > const & rShape,
                                sal_Int32 nZIndex );
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index dfb058cd2580..9d0e55bfbbe4 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -234,7 +234,7 @@ uno::Reference< drawing::XShapes > const & ScMyTables::GetCurrentXShapes()
     {
         xShapes = GetCurrentXDrawPage();
         rImport.GetShapeImport()->startPage(xShapes);
-        rImport.GetShapeImport()->pushGroupForSorting ( xShapes );
+        rImport.GetShapeImport()->pushGroupForPostProcessing ( xShapes );
         nCurrentXShapes = sal::static_int_cast<sal_Int16>(maCurrentCellPos.Tab());
     }
     return xShapes;
diff --git a/sc/source/filter/xml/xmltabi.cxx b/sc/source/filter/xml/xmltabi.cxx
index 367fe65efb2f..a8e5b99a2756 100644
--- a/sc/source/filter/xml/xmltabi.cxx
+++ b/sc/source/filter/xml/xmltabi.cxx
@@ -405,7 +405,7 @@ void SAL_CALL ScXMLTableContext::endFastElement(sal_Int32 /*nElement*/)
     {
         if (rTables.HasXShapes())
         {
-            rImport.GetShapeImport()->popGroupAndSort();
+            rImport.GetShapeImport()->popGroupAndPostProcess();
             uno::Reference < drawing::XShapes > xTempShapes(rTables.GetCurrentXShapes());
             rImport.GetShapeImport()->endPage(xTempShapes);
         }
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(


More information about the Libreoffice-commits mailing list