Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


Hi,
It would be great if I could get some advice on how to move forward on
removing more of the boost dependency.

Originally I was working on this:
[bug 93243] replace boost::bind with C++11 lambdas

Line 18: sc/source/filter/excel/excimp8.cxx
    std::for_each(maFilters.begin(),maFilters.end(),
        boost::bind(&XclImpAutoFilterData::Apply,_1));

Searching the code I hav found examples where this type of for_each
loop is replaced by a simple for loop:

    for( const auto& rFilterPtr : maFilters )
        rFilterPtr->Apply();

This requires some additional modificatioins to the code which can be
seen in the attached patch.

The question which is left is what to do with what the function below
should return:

XclImpAutoFilterData* XclImpAutoFilterBuffer::GetByTab( SCTAB nTab )

Should i modify it to return XclImpAutoFilterSharePtr instead?
Am I on the right track in general?

Thanks for the help!

/Albert
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index eba2d5c..5718d42 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -846,7 +846,7 @@ void XclImpAutoFilterData::EnableRemoveFilter()
 void XclImpAutoFilterBuffer::Insert( RootData* pRoot, const ScRange& rRange)
 {
     if( !GetByTab( rRange.aStart.Tab() ) )
-        maFilters.push_back( new XclImpAutoFilterData( pRoot, rRange) );
+        maFilters.push_back( XclImpAutoFilterSharePtr(new XclImpAutoFilterData( pRoot, rRange) ));
 }
 
 void XclImpAutoFilterBuffer::AddAdvancedRange( const ScRange& rRange )
@@ -865,17 +865,17 @@ void XclImpAutoFilterBuffer::AddExtractPos( const ScRange& rRange )
 
 void XclImpAutoFilterBuffer::Apply()
 {
-    std::for_each(maFilters.begin(),maFilters.end(),
-        boost::bind(&XclImpAutoFilterData::Apply,_1));
+    for( const auto& rFilterPtr : maFilters )
+        rFilterPtr->Apply();
 }
 
 XclImpAutoFilterData* XclImpAutoFilterBuffer::GetByTab( SCTAB nTab )
 {
-    boost::ptr_vector<XclImpAutoFilterData>::iterator it;
+    std::vector<XclImpAutoFilterSharePtr>::iterator it;
     for( it = maFilters.begin(); it != maFilters.end(); ++it )
     {
         if( it->Tab() == nTab )
-            return &(*it);
+            return &XclImpAutoFilterSharePtr(*it);
     }
     return NULL;
 }
diff --git a/sc/source/filter/inc/excimp8.hxx b/sc/source/filter/inc/excimp8.hxx
index e50cfd4..a3bfc8a 100644
--- a/sc/source/filter/inc/excimp8.hxx
+++ b/sc/source/filter/inc/excimp8.hxx
@@ -22,7 +22,8 @@
 
 #include <string.h>
 
-#include <boost/ptr_container/ptr_vector.hpp>
+//#include <boost/shared_ptr.hpp>
+//#include <boost/ptr_container/ptr_vector.hpp>
 
 #include "imp_op.hxx"
 #include "root.hxx"
@@ -123,8 +124,8 @@ public:
     XclImpAutoFilterData*       GetByTab( SCTAB nTab );
 
 private:
-
-    boost::ptr_vector<XclImpAutoFilterData> maFilters;
+    typedef std::shared_ptr<XclImpAutoFilterData> XclImpAutoFilterSharePtr;
+    std::vector<XclImpAutoFilterSharePtr> maFilters;
 };
 
 #endif

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.