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

Mario J. Rugiero mrugiero at gmail.com
Fri Oct 30 06:05:27 UTC 2015


 xmloff/inc/pch/precompiled_xo.hxx       |    1 
 xmloff/source/chart/SchXMLExport.cxx    |   17 ++--------------
 xmloff/source/core/RDFaExportHelper.cxx |   14 ++++++-------
 xmloff/source/core/RDFaImportHelper.cxx |   33 +++++++-------------------------
 xmloff/source/forms/layerimport.cxx     |   15 +++++---------
 5 files changed, 24 insertions(+), 56 deletions(-)

New commits:
commit f53343320101bfe650f5fe2cdf95f94995778037
Author: Mario J. Rugiero <mrugiero at gmail.com>
Date:   Fri Oct 30 00:26:23 2015 -0300

    xmloff tree cleanup
    
    - Replaces for_each(*.begin(), *.end(), ...) by its range based for loop equivalents.
    - Replaces boost::bind calls by C++11 lambdas.
    - Cleans a few hacks made to workaround boost::bind limitations.
    
    Change-Id: Ie88cc651a2a835b03d5037e54e2a61ca93866310
    Reviewed-on: https://gerrit.libreoffice.org/19678
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/xmloff/inc/pch/precompiled_xo.hxx b/xmloff/inc/pch/precompiled_xo.hxx
index b78a28a..f11c370 100644
--- a/xmloff/inc/pch/precompiled_xo.hxx
+++ b/xmloff/inc/pch/precompiled_xo.hxx
@@ -31,7 +31,6 @@
 #include <basegfx/tuple/b3dtuple.hxx>
 #include <basegfx/vector/b2dvector.hxx>
 #include <basegfx/vector/b3dvector.hxx>
-#include <boost/bind.hpp>
 #include <boost/iterator_adaptors.hpp>
 #include <boost/noncopyable.hpp>
 #include <boost/ptr_container/ptr_vector.hpp>
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 568e3e9..ed226f5 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -713,18 +713,6 @@ struct lcl_TableData
     ::std::vector< sal_Int32 > aHiddenColumns;
 };
 
-// ::std::bind2nd( ::std::mem_fun_ref( &T::resize ), nSize ) does not work
-template< class T >
-    struct lcl_resize
-    {
-        lcl_resize( typename T::size_type nSize, typename T::value_type fDefaultValue ) : m_nSize( nSize ), m_fDefaultValue( fDefaultValue ) {}
-        void operator()( T & t )
-        { t.resize( m_nSize, m_fDefaultValue ); }
-    private:
-        typename T::size_type m_nSize;
-        typename T::value_type m_fDefaultValue;
-    };
-
 typedef ::std::map< sal_Int32, SchXMLExportHelper_Impl::tLabelValuesDataPair >
     lcl_DataSequenceMap;
 
@@ -818,8 +806,9 @@ lcl_TableData lcl_getDataForLocalTable(
         aResult.aDataInRows.resize( nNumRows );
         double fNan = 0.0;
         ::rtl::math::setNan( &fNan );
-        ::std::for_each( aResult.aDataInRows.begin(), aResult.aDataInRows.end(),
-                         lcl_resize< t2DNumberContainer::value_type >( nNumColumns, fNan ));
+
+        for (auto& aData: aResult.aDataInRows)
+            aData.resize(nNumColumns, fNan);
         aResult.aColumnDescriptions.resize( nNumColumns );
         aResult.aComplexColumnDescriptions.realloc( nNumColumns );
         aResult.aRowDescriptions.resize( nNumRows );
diff --git a/xmloff/source/core/RDFaExportHelper.cxx b/xmloff/source/core/RDFaExportHelper.cxx
index a2dd4001..bfce904 100644
--- a/xmloff/source/core/RDFaExportHelper.cxx
+++ b/xmloff/source/core/RDFaExportHelper.cxx
@@ -38,7 +38,6 @@
 
 #include <rtl/ustrbuf.hxx>
 
-#include <boost/bind.hpp>
 #include <boost/iterator_adaptors.hpp>
 #ifndef BOOST_ITERATOR_ADAPTOR_DWA053000_HPP_ // from iterator_adaptors.hpp
 // N.B.: the check for the header guard _of a specific version of boost_
@@ -166,16 +165,17 @@ RDFaExportHelper::AddRDFa(
                 xContent->getValue());
         }
 
+        auto aStatementToCURIE = [this](rdf::Statement const& aStatement) {
+            return makeCURIE(&this->m_rExport, aStatement.Predicate);
+        };
         OUStringBuffer property;
         ::comphelper::intersperse(
-            ::boost::make_transform_iterator(rStatements.begin(),
-                ::boost::bind(&makeCURIE, &m_rExport,
-                    ::boost::bind(&rdf::Statement::Predicate, _1))),
-            // argh, this must be the same type :(
+            ::boost::make_transform_iterator(
+                rStatements.begin(),
+                aStatementToCURIE),
             ::boost::make_transform_iterator(
                 rStatements.end(),
-                ::boost::bind(&makeCURIE, &m_rExport,
-                    ::boost::bind(&rdf::Statement::Predicate, _1))),
+                aStatementToCURIE),
             ::comphelper::OUStringBufferAppender(property),
             OUString(" "));
 
diff --git a/xmloff/source/core/RDFaImportHelper.cxx b/xmloff/source/core/RDFaImportHelper.cxx
index ac2738a..d2705e5 100644
--- a/xmloff/source/core/RDFaImportHelper.cxx
+++ b/xmloff/source/core/RDFaImportHelper.cxx
@@ -30,7 +30,6 @@
 
 #include <rtl/ustring.hxx>
 
-#include <boost/bind.hpp>
 #include <boost/iterator_adaptors.hpp>
 #ifndef BOOST_ITERATOR_ADAPTOR_DWA053000_HPP_ // from iterator_adaptors.hpp
 // N.B.: the check for the header guard _of a specific version of boost_
@@ -312,18 +311,6 @@ RDFaInserter::MakeResource( OUString const & i_rResource)
     }
 }
 
-/** i wrote this because c++ implementations cannot agree on which variant
-    of boost::bind and std::mem_fun_ref applied to Reference::is compiles */
-class ref_is_null :
-    public ::std::unary_function<bool, const uno::Reference<rdf::XURI> & >
-{
-public:
-    bool operator() (const uno::Reference<rdf::XURI> & i_rRef)
-    {
-        return !i_rRef.is();
-    }
-};
-
 void RDFaInserter::InsertRDFaEntry(
     struct RDFaEntry const & i_rEntry)
 {
@@ -341,22 +328,18 @@ void RDFaInserter::InsertRDFaEntry(
 
     predicates.reserve(i_rEntry.m_xRDFaAttributes->m_Properties.size());
 
+    auto aPropertyToXURI = [this](OUString const& aProperty) { return this->MakeURI(aProperty); };
+    // Store as variable so the type matches in both calls.
+
     ::std::remove_copy_if(
         ::boost::make_transform_iterator(
             i_rEntry.m_xRDFaAttributes->m_Properties.begin(),
-            ::boost::bind(&RDFaInserter::MakeURI, this, _1)),
-        // argh, this must be the same type :(
+            aPropertyToXURI),
         ::boost::make_transform_iterator(
             i_rEntry.m_xRDFaAttributes->m_Properties.end(),
-            ::boost::bind(&RDFaInserter::MakeURI, this, _1)),
+            aPropertyToXURI),
         ::std::back_inserter(predicates),
-        ref_is_null() );
-        // compiles only on wntmsci12
-//        ::boost::bind( ::std::logical_not<sal_Bool>(), ::boost::bind<sal_Bool>(&uno::Reference<rdf::XURI>::is, _1)));
-        // compiles on unxsoli4, wntsci12, but not unxlngi6
-//        ::boost::bind( ::std::logical_not<sal_Bool>(), ::boost::bind<sal_Bool, com::sun::star::uno::Reference<rdf::XURI> >(&uno::Reference<rdf::XURI>::is, _1)));
-        // compiles on unxsoli4, unxlngi6, but not wntsci12
-//        ::std::not1( ::std::mem_fun_ref(&uno::Reference<rdf::XURI>::is)) );
+        [this](uno::Reference<rdf::XURI> const& arRef) { return !arRef.is(); } );
 
     if (predicates.empty())
     {
@@ -467,8 +450,8 @@ void RDFaImportHelper::InsertRDFa(
     SAL_WARN_IF(!xRepository.is(), "xmloff.core", "InsertRDFa: no DocumentRepository?");
     if (!xRepository.is()) return;
     RDFaInserter inserter(GetImport().GetComponentContext(), xRepository);
-    ::std::for_each(m_RDFaEntries.begin(), m_RDFaEntries.end(),
-        ::boost::bind(&RDFaInserter::InsertRDFaEntry, &inserter, _1));
+    for (const auto& RDFaEntry : m_RDFaEntries)
+        inserter.InsertRDFaEntry(RDFaEntry);
 }
 
 } // namespace xmloff
diff --git a/xmloff/source/forms/layerimport.cxx b/xmloff/source/forms/layerimport.cxx
index 453c490..97f4592 100644
--- a/xmloff/source/forms/layerimport.cxx
+++ b/xmloff/source/forms/layerimport.cxx
@@ -580,17 +580,14 @@ void OFormLayerXMLImport_Impl::documentDone( )
     }
 
     // process XForms-bindings; call registerXFormsValueBinding for each
-    std::for_each( m_aXFormsValueBindings.begin(),
-                   m_aXFormsValueBindings.end(),
-                   std::bind( bindXFormsValueBinding, rImport.GetModel(), std::placeholders::_1 ) );
+    for (auto& aXFormsValueBinding : m_aXFormsValueBindings)
+        bindXFormsValueBinding(rImport.GetModel(), aXFormsValueBinding);
     // same for list bindings
-    std::for_each( m_aXFormsListBindings.begin(),
-                   m_aXFormsListBindings.end(),
-                   std::bind( bindXFormsListBinding, rImport.GetModel(), std::placeholders::_1 ) );
+    for (auto& aXFormsListBindings : m_aXFormsListBindings)
+        bindXFormsListBinding(rImport.GetModel(), aXFormsListBindings);
     // same for submissions
-    std::for_each( m_aXFormsSubmissions.begin(),
-                   m_aXFormsSubmissions.end(),
-                   std::bind( bindXFormsSubmission, rImport.GetModel(), std::placeholders::_1 ) );
+    for (auto& aXFormsSubmission : m_aXFormsSubmissions)
+        bindXFormsSubmission(rImport.GetModel(), aXFormsSubmission);
 }
 
 }   // namespace xmloff


More information about the Libreoffice-commits mailing list