[Libreoffice-commits] core.git: 2 commits - oox/source xmlhelp/source

Michael Stahl mstahl at redhat.com
Tue Oct 27 13:41:15 UTC 2015


 oox/source/drawingml/effectproperties.cxx        |   16 +++-
 oox/source/drawingml/effectproperties.hxx        |   13 ++-
 oox/source/drawingml/effectpropertiescontext.cxx |   32 ++++----
 oox/source/drawingml/shape.cxx                   |    7 -
 xmlhelp/source/cxxhelp/provider/content.cxx      |    6 -
 xmlhelp/source/cxxhelp/provider/urlparameter.cxx |   84 ++---------------------
 xmlhelp/source/cxxhelp/provider/urlparameter.hxx |    1 
 7 files changed, 52 insertions(+), 107 deletions(-)

New commits:
commit fe546a9a3180c87ce6b400ea1f69b483b952d72b
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Oct 22 21:21:15 2015 +0200

    oox: replace boost::ptr_vector with std::vector<std::unique_ptr>
    
    With one additional m_Effects.clear() in EffectProperties::assignUsed()
    to make it idempotent like it was before and avoid duplicating elements.
    
    Change-Id: I105535a2a250e682a5d6976e0c7f74374b1f31ac

diff --git a/oox/source/drawingml/effectproperties.cxx b/oox/source/drawingml/effectproperties.cxx
index 3fd3882..3ec31e0 100644
--- a/oox/source/drawingml/effectproperties.cxx
+++ b/oox/source/drawingml/effectproperties.cxx
@@ -14,6 +14,7 @@
 #include "oox/token/tokens.hxx"
 
 #include <basegfx/numeric/ftools.hxx>
+#include <o3tl/make_unique.hxx>
 
 namespace oox {
 namespace drawingml {
@@ -28,14 +29,22 @@ void EffectShadowProperties::assignUsed(const EffectShadowProperties& rSourcePro
 void EffectProperties::assignUsed( const EffectProperties& rSourceProps )
 {
     maShadow.assignUsed(rSourceProps.maShadow);
-    if( rSourceProps.maEffects.size() > 0 )
-        maEffects = rSourceProps.maEffects;
+    if (!rSourceProps.m_Effects.empty())
+    {
+        m_Effects.clear();
+        m_Effects.reserve(rSourceProps.m_Effects.size());
+        for (auto const& it : rSourceProps.m_Effects)
+        {
+            m_Effects.push_back(o3tl::make_unique<Effect>(*it));
+        }
+    }
 }
 
 void EffectProperties::pushToPropMap( PropertyMap& rPropMap,
         const GraphicHelper& rGraphicHelper ) const
 {
-    for( boost::ptr_vector< Effect >::const_iterator it = maEffects.begin(); it != maEffects.end(); ++it )
+    for (auto const& it : m_Effects)
+    {
         if( it->msName == "outerShdw" )
         {
             sal_Int32 nAttrDir = 0, nAttrDist = 0;
@@ -59,6 +68,7 @@ void EffectProperties::pushToPropMap( PropertyMap& rPropMap,
             rPropMap.setProperty( PROP_ShadowColor, it->moColor.getColor(rGraphicHelper ) );
             rPropMap.setProperty( PROP_ShadowTransparence, it->moColor.getTransparency());
         }
+    }
 }
 
 css::beans::PropertyValue Effect::getEffect()
diff --git a/oox/source/drawingml/effectproperties.hxx b/oox/source/drawingml/effectproperties.hxx
index 4256b8d..9089e1d 100644
--- a/oox/source/drawingml/effectproperties.hxx
+++ b/oox/source/drawingml/effectproperties.hxx
@@ -10,11 +10,12 @@
 #ifndef INCLUDED_OOX_DRAWINGML_EFFECTPROPERTIES_HXX
 #define INCLUDED_OOX_DRAWINGML_EFFECTPROPERTIES_HXX
 
-#include <map>
 #include <oox/drawingml/color.hxx>
 #include <oox/helper/propertymap.hxx>
 
-#include <boost/ptr_container/ptr_vector.hpp>
+#include <memory>
+#include <vector>
+#include <map>
 
 namespace oox {
 namespace drawingml {
@@ -44,7 +45,13 @@ struct EffectProperties
     EffectShadowProperties maShadow;
 
     /** Stores all effect properties, including those not supported by core yet */
-    boost::ptr_vector< Effect > maEffects;
+    std::vector<std::unique_ptr<Effect>> m_Effects;
+
+    EffectProperties() {}
+    EffectProperties(EffectProperties const& rOther)
+    {
+        assignUsed(rOther);
+    }
 
     /** Overwrites all members that are explicitly set in rSourceProps. */
     void                assignUsed( const EffectProperties& rSourceProps );
diff --git a/oox/source/drawingml/effectpropertiescontext.cxx b/oox/source/drawingml/effectpropertiescontext.cxx
index d1d0cd9..3f79cb7 100644
--- a/oox/source/drawingml/effectpropertiescontext.cxx
+++ b/oox/source/drawingml/effectpropertiescontext.cxx
@@ -13,6 +13,8 @@
 #include "drawingml/fillpropertiesgroupcontext.hxx"
 #include "oox/helper/attributelist.hxx"
 
+#include <o3tl/make_unique.hxx>
+
 using namespace ::oox::core;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::xml::sax;
@@ -70,28 +72,28 @@ void EffectPropertiesContext::saveUnsupportedAttribs( Effect& rEffect, const Att
 
 ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
 {
-    sal_Int32 nPos = mrEffectProperties.maEffects.size();
-    mrEffectProperties.maEffects.push_back( new Effect() );
+    sal_Int32 nPos = mrEffectProperties.m_Effects.size();
+    mrEffectProperties.m_Effects.push_back(o3tl::make_unique<Effect>());
     switch( nElement )
     {
         case A_TOKEN( outerShdw ):
         {
-            mrEffectProperties.maEffects[nPos].msName = "outerShdw";
-            saveUnsupportedAttribs( mrEffectProperties.maEffects[nPos], rAttribs );
+            mrEffectProperties.m_Effects[nPos]->msName = "outerShdw";
+            saveUnsupportedAttribs(*mrEffectProperties.m_Effects[nPos], rAttribs);
 
             mrEffectProperties.maShadow.moShadowDist = rAttribs.getInteger( XML_dist, 0 );
             mrEffectProperties.maShadow.moShadowDir = rAttribs.getInteger( XML_dir, 0 );
-            return new ColorContext( *this, mrEffectProperties.maEffects[nPos].moColor );
+            return new ColorContext(*this, mrEffectProperties.m_Effects[nPos]->moColor);
         }
         break;
         case A_TOKEN( innerShdw ):
         {
-            mrEffectProperties.maEffects[nPos].msName = "innerShdw";
-            saveUnsupportedAttribs( mrEffectProperties.maEffects[nPos], rAttribs );
+            mrEffectProperties.m_Effects[nPos]->msName = "innerShdw";
+            saveUnsupportedAttribs(*mrEffectProperties.m_Effects[nPos], rAttribs);
 
             mrEffectProperties.maShadow.moShadowDist = rAttribs.getInteger( XML_dist, 0 );
             mrEffectProperties.maShadow.moShadowDir = rAttribs.getInteger( XML_dir, 0 );
-            return new ColorContext( *this, mrEffectProperties.maEffects[nPos].moColor );
+            return new ColorContext(*this, mrEffectProperties.m_Effects[nPos]->moColor);
         }
         break;
         case A_TOKEN( glow ):
@@ -100,20 +102,20 @@ ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement,
         case A_TOKEN( blur ):
         {
             if( nElement == A_TOKEN( glow ) )
-                mrEffectProperties.maEffects[nPos].msName = "glow";
+                mrEffectProperties.m_Effects[nPos]->msName = "glow";
             else if( nElement == A_TOKEN( softEdge ) )
-                mrEffectProperties.maEffects[nPos].msName = "softEdge";
+                mrEffectProperties.m_Effects[nPos]->msName = "softEdge";
             else if( nElement == A_TOKEN( reflection ) )
-                mrEffectProperties.maEffects[nPos].msName = "reflection";
+                mrEffectProperties.m_Effects[nPos]->msName = "reflection";
             else if( nElement == A_TOKEN( blur ) )
-                mrEffectProperties.maEffects[nPos].msName = "blur";
-            saveUnsupportedAttribs( mrEffectProperties.maEffects[nPos], rAttribs );
-            return new ColorContext( *this, mrEffectProperties.maEffects[nPos].moColor );
+                mrEffectProperties.m_Effects[nPos]->msName = "blur";
+            saveUnsupportedAttribs(*mrEffectProperties.m_Effects[nPos], rAttribs);
+            return new ColorContext(*this, mrEffectProperties.m_Effects[nPos]->moColor);
         }
         break;
     }
 
-    mrEffectProperties.maEffects.pop_back();
+    mrEffectProperties.m_Effects.pop_back();
     return 0;
 }
 
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 04ca3a1..c7728bb 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -953,12 +953,11 @@ Reference< XShape > Shape::createAndInsert(
             }
 
             // store unsupported effect attributes in the grab bag
-            if( aEffectProperties.maEffects.size() > 0 )
+            if (!aEffectProperties.m_Effects.empty())
             {
-                Sequence< PropertyValue > aEffects( aEffectProperties.maEffects.size() );
+                Sequence<PropertyValue> aEffects(aEffectProperties.m_Effects.size());
                 sal_uInt32 i = 0;
-                for( boost::ptr_vector< Effect >::iterator it = aEffectProperties.maEffects.begin();
-                        it != aEffectProperties.maEffects.end(); ++it )
+                for (auto const& it : aEffectProperties.m_Effects)
                 {
                     PropertyValue aEffect = it->getEffect();
                     if( !aEffect.Name.isEmpty() )
commit 03802af730d37ca4ca2a42d78906b713f39bb9e2
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Oct 26 18:10:33 2015 +0100

    xmlhelp: apparently "picture.jar" hasn't existed for a long time
    
    Change-Id: I9ac46ffcf21e8af2cb3b92d4068981cafb271ebc

diff --git a/xmlhelp/source/cxxhelp/provider/content.cxx b/xmlhelp/source/cxxhelp/provider/content.cxx
index 922f996..5604ee1 100644
--- a/xmlhelp/source/cxxhelp/provider/content.cxx
+++ b/xmlhelp/source/cxxhelp/provider/content.cxx
@@ -421,11 +421,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
         else if ( rProp.Name == "IsErrorDocument" )
             xRow->appendBoolean( rProp, m_aURLParameter.isErrorDocument() );
         else if ( rProp.Name == "MediaType" )
-            if( m_aURLParameter.isPicture() )
-                xRow->appendString(
-                    rProp,
-                    OUString( "image/gif" ) );
-            else if( m_aURLParameter.isActive() )
+            if( m_aURLParameter.isActive() )
                 xRow->appendString(
                     rProp,
                     OUString( "text/plain" ) );
diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
index 72a57d1..a716d12 100644
--- a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
+++ b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
@@ -396,60 +396,16 @@ void URLParameter::open( const Command& aCommand,
     if( ! xDataSink.is() )
         return;
 
-    if( isPicture() )
+    // a standard document or else an active help text, plug in the new input stream
+    InputStreamTransformer* p = new InputStreamTransformer( this,m_pDatabases,isRoot() );
+    try
     {
-        Reference< XInputStream > xStream;
-        Reference< XHierarchicalNameAccess > xNA =
-            m_pDatabases->jarFile( OUString( "picture.jar" ),
-                                   get_language() );
-
-        OUString path = get_path();
-        if( xNA.is() )
-        {
-            try
-            {
-                Any aEntry = xNA->getByHierarchicalName( path );
-                Reference< XActiveDataSink > xSink;
-                if( ( aEntry >>= xSink ) && xSink.is() )
-                    xStream = xSink->getInputStream();
-            }
-            catch ( NoSuchElementException & )
-            {
-            }
-        }
-        if( xStream.is() )
-        {
-            sal_Int32 ret;
-            Sequence< sal_Int8 > aSeq( 4096 );
-            while( true )
-            {
-                try
-                {
-                    ret = xStream->readBytes( aSeq,4096 );
-                    xDataSink->writeBytes( aSeq );
-                    if( ret < 4096 )
-                        break;
-                }
-                catch( const Exception& )
-                {
-                    break;
-                }
-            }
-        }
+        xDataSink->writeBytes( Sequence< sal_Int8 >( p->getData(),p->getLen() ) );
     }
-    else
+    catch( const Exception& )
     {
-        // a standard document or else an active help text, plug in the new input stream
-        InputStreamTransformer* p = new InputStreamTransformer( this,m_pDatabases,isRoot() );
-        try
-        {
-            xDataSink->writeBytes( Sequence< sal_Int8 >( p->getData(),p->getLen() ) );
-        }
-        catch( const Exception& )
-        {
-        }
-        delete p;
     }
+    delete p;
     xDataSink->closeOutput();
 }
 
@@ -464,32 +420,8 @@ void URLParameter::open( const Command& aCommand,
     (void)CommandId;
     (void)Environment;
 
-    if( isPicture() )
-    {
-        Reference< XInputStream > xStream;
-        Reference< XHierarchicalNameAccess > xNA =
-            m_pDatabases->jarFile( OUString( "picture.jar" ),
-                                   get_language() );
-
-        OUString path = get_path();
-        if( xNA.is() )
-        {
-            try
-            {
-                Any aEntry = xNA->getByHierarchicalName( path );
-                Reference< XActiveDataSink > xSink;
-                if( ( aEntry >>= xSink ) && xSink.is() )
-                    xStream = xSink->getInputStream();
-            }
-            catch ( NoSuchElementException & )
-            {
-            }
-        }
-        xDataSink->setInputStream( turnToSeekable(xStream) );
-    }
-    else
-        // a standard document or else an active help text, plug in the new input stream
-        xDataSink->setInputStream( new InputStreamTransformer( this,m_pDatabases,isRoot() ) );
+    // a standard document or else an active help text, plug in the new input stream
+    xDataSink->setInputStream( new InputStreamTransformer( this,m_pDatabases,isRoot() ) );
 }
 
 
diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.hxx b/xmlhelp/source/cxxhelp/provider/urlparameter.hxx
index a35e941..a20c7a2 100644
--- a/xmlhelp/source/cxxhelp/provider/urlparameter.hxx
+++ b/xmlhelp/source/cxxhelp/provider/urlparameter.hxx
@@ -116,7 +116,6 @@ namespace chelp {
                       Databases* pDatabases )
             throw( com::sun::star::ucb::IllegalIdentifierException );
 
-        bool isPicture() const { return m_aModule == "picture"; }
         bool isActive() const { return !m_aActive.isEmpty() && m_aActive == "true"; }
         bool isQuery() const { return m_aId.isEmpty() && !m_aQuery.isEmpty(); }
         bool isFile() const { return !m_aId.isEmpty(); }


More information about the Libreoffice-commits mailing list