[Libreoffice-commits] core.git: 3 commits - include/xmloff package/inc package/source qadevOOo/runner xmloff/source

Stephan Bergmann sbergman at redhat.com
Mon Mar 10 00:59:35 PDT 2014


 include/xmloff/PropertySetInfoHash.hxx             |   59 --------------------
 include/xmloff/PropertySetInfoKey.hxx              |   61 ---------------------
 include/xmloff/SinglePropertySetInfoCache.hxx      |   21 +++----
 package/inc/ZipPackageFolder.hxx                   |    2 
 package/inc/ZipPackageStream.hxx                   |    2 
 package/source/zippackage/ZipPackageFolder.cxx     |   10 +--
 package/source/zippackage/ZipPackageStream.cxx     |   11 +--
 qadevOOo/runner/util/dbg.java                      |   23 -------
 xmloff/source/style/SinglePropertySetInfoCache.cxx |   51 ++++-------------
 xmloff/source/style/xmlexppr.cxx                   |   51 ++++-------------
 10 files changed, 46 insertions(+), 245 deletions(-)

New commits:
commit 1349f49a72be947aa708e7bcbc7de773894c5684
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Mar 10 08:58:16 2014 +0100

    Use cppu::OImplementationId for XUnoTunnel IDs
    
    Change-Id: I564ec761b7a7b3488682acfb3aff56beb3f68213

diff --git a/package/inc/ZipPackageFolder.hxx b/package/inc/ZipPackageFolder.hxx
index db0a6aa..251c934 100644
--- a/package/inc/ZipPackageFolder.hxx
+++ b/package/inc/ZipPackageFolder.hxx
@@ -74,7 +74,7 @@ public:
         throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
 
     static void copyZipEntry( ZipEntry &rDest, const ZipEntry &rSource);
-    static const ::com::sun::star::uno::Sequence < sal_Int8 >& static_getImplementationId();
+    static ::com::sun::star::uno::Sequence < sal_Int8 > static_getImplementationId();
 
     void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; }
     void setRemoveOnInsertMode_Impl( sal_Bool bRemove ) { this->mbAllowRemoveOnInsert = bRemove; }
diff --git a/package/inc/ZipPackageStream.hxx b/package/inc/ZipPackageStream.hxx
index 1e25d12..56ed22c 100644
--- a/package/inc/ZipPackageStream.hxx
+++ b/package/inc/ZipPackageStream.hxx
@@ -155,7 +155,7 @@ public:
     ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawData()
         throw(::com::sun::star::uno::RuntimeException);
 
-    static const ::com::sun::star::uno::Sequence < sal_Int8 >& static_getImplementationId();
+    static ::com::sun::star::uno::Sequence < sal_Int8 > static_getImplementationId();
 
     // XActiveDataSink
     virtual void SAL_CALL setInputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& aStream )
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index d4d1374..b71d34a 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -28,6 +28,7 @@
 #include <com/sun/star/packages/zip/ZipConstants.hpp>
 #include <com/sun/star/embed/StorageFormats.hpp>
 #include <cppuhelper/supportsservice.hxx>
+#include <cppuhelper/typeprovider.hxx>
 #include <osl/diagnose.h>
 #include <osl/time.h>
 #include <rtl/digest.h>
@@ -57,7 +58,7 @@ using namespace ::com::sun::star;
 #define THROW_WHERE ""
 #endif
 
-namespace { struct lcl_CachedImplId : public rtl::Static< uno::Sequence < sal_Int8 >, lcl_CachedImplId > {}; }
+namespace { struct lcl_CachedImplId : public rtl::Static< cppu::OImplementationId, lcl_CachedImplId > {}; }
 
 ZipPackageFolder::ZipPackageFolder ( sal_Int32 nFormat,
                                      sal_Bool bAllowRemoveOnInsert )
@@ -74,9 +75,6 @@ ZipPackageFolder::ZipPackageFolder ( sal_Int32 nFormat,
     aEntry.nCompressedSize = 0;
     aEntry.nSize        = 0;
     aEntry.nOffset      = -1;
-    uno::Sequence < sal_Int8 > &rCachedImplId = lcl_CachedImplId::get();
-    if ( !rCachedImplId.getLength() )
-        rCachedImplId = getImplementationId();
 }
 
 ZipPackageFolder::~ZipPackageFolder()
@@ -178,9 +176,9 @@ void ZipPackageFolder::copyZipEntry( ZipEntry &rDest, const ZipEntry &rSource)
     rDest.nExtraLen         = rSource.nExtraLen;
 }
 
-const ::com::sun::star::uno::Sequence < sal_Int8 >& ZipPackageFolder::static_getImplementationId()
+::com::sun::star::uno::Sequence < sal_Int8 > ZipPackageFolder::static_getImplementationId()
 {
-    return lcl_CachedImplId::get();
+    return lcl_CachedImplId::get().getImplementationId();
 }
 
     // XNameContainer
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index d635576..02e8047 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -42,6 +42,7 @@
 #include <comphelper/seekableinput.hxx>
 #include <comphelper/storagehelper.hxx>
 #include <cppuhelper/supportsservice.hxx>
+#include <cppuhelper/typeprovider.hxx>
 
 #include <rtl/instance.hxx>
 
@@ -60,11 +61,11 @@ using namespace cppu;
 #define THROW_WHERE ""
 #endif
 
-namespace { struct lcl_CachedImplId : public rtl::Static< Sequence < sal_Int8 >, lcl_CachedImplId > {}; }
+namespace { struct lcl_CachedImplId : public rtl::Static< cppu::OImplementationId, lcl_CachedImplId > {}; }
 
-const ::com::sun::star::uno::Sequence < sal_Int8 >& ZipPackageStream::static_getImplementationId()
+::com::sun::star::uno::Sequence < sal_Int8 > ZipPackageStream::static_getImplementationId()
 {
-    return lcl_CachedImplId::get();
+    return lcl_CachedImplId::get().getImplementationId();
 }
 
 ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage,
@@ -103,10 +104,6 @@ ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage,
     aEntry.nOffset      = -1;
     aEntry.nPathLen     = -1;
     aEntry.nExtraLen    = -1;
-
-    Sequence < sal_Int8 > &rCachedImplId = lcl_CachedImplId::get();
-    if ( !rCachedImplId.getLength() )
-        rCachedImplId = getImplementationId();
 }
 
 ZipPackageStream::~ZipPackageStream( void )
commit ddc9595b3145e7af0958b52f47bf80bddf877a8e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Mar 10 08:15:48 2014 +0100

    Remove unused util.dbg.getImplID
    
    Change-Id: I2c662698146120924e8d3807547727d62155b024

diff --git a/qadevOOo/runner/util/dbg.java b/qadevOOo/runner/util/dbg.java
index 9530746..43a2566 100644
--- a/qadevOOo/runner/util/dbg.java
+++ b/qadevOOo/runner/util/dbg.java
@@ -309,27 +309,4 @@ public class dbg {
         if (notSupportedServices)
             System.out.println(str);
     }
-
-    /**
-     * Get the unique implementation id of a UNO object.
-     * @param xTarget An implementation of a UNO object.
-     * @return The implementation id.
-     */
-    public static String getImplID( XInterface xTarget ) {
-    String str = "";
-    XTypeProvider xTypeProvider = UnoRuntime.queryInterface( XTypeProvider.class, xTarget);
-            if( xTypeProvider != null ) {
-        byte[] id = xTypeProvider.getImplementationId();
-        str = "ImplementationID: ";
-        for (int i=0; i<id.length;i++) {
-            Byte b = new Byte(id[i]);
-            str += b.intValue();
-        }
-            } else {
-        str = "No Implementation ID available";
-    }
-    return str;
-    }
-
-
 }
commit db5c67e1006664916b7b4c8881d21cf096333ee7
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Mar 7 23:39:25 2014 +0100

    Keying on XTypeProvider::getImplementationId is unnecessary here
    
    ...given that cases where "every instance of getPropertySetInfo returns a new
    object [...] must not be cached" anyway, so just key on the XPropertySetInfo
    instances.
    
    Change-Id: I11f0a1fe030226d1d26d6b6e6a2654f4511fdce8

diff --git a/include/xmloff/PropertySetInfoHash.hxx b/include/xmloff/PropertySetInfoHash.hxx
deleted file mode 100644
index 4f987ca..0000000
--- a/include/xmloff/PropertySetInfoHash.hxx
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#ifndef INCLUDED_XMLOFF_PROPERTYSETINFOHASH_HXX
-#define INCLUDED_XMLOFF_PROPERTYSETINFOHASH_HXX
-
-#include <xmloff/PropertySetInfoKey.hxx>
-
-#include <string.h>
-#include <memory>
-
-struct PropertySetInfoHash
-{
-    inline size_t operator()( const PropertySetInfoKey& r ) const;
-    inline bool operator()( const PropertySetInfoKey& r1,
-                               const PropertySetInfoKey& r2 ) const;
-};
-
-inline size_t PropertySetInfoHash::operator()(
-        const PropertySetInfoKey& r ) const
-{
-    const sal_Int32* pBytesAsInt32Array =
-        (const sal_Int32*)r.aImplementationId.getConstArray();
-    sal_Int32 nId32 =   pBytesAsInt32Array[0] ^
-                        pBytesAsInt32Array[1] ^
-                        pBytesAsInt32Array[2] ^
-                        pBytesAsInt32Array[3];
-    return (size_t)nId32 ^ (size_t)r.xPropInfo.get();
-}
-
-inline bool PropertySetInfoHash::operator()(
-        const PropertySetInfoKey& r1,
-        const PropertySetInfoKey& r2 ) const
-{
-    if( r1.xPropInfo != r2.xPropInfo )
-        return false;
-
-    const sal_Int8* pId1 = r1.aImplementationId.getConstArray();
-    const sal_Int8* pId2 = r2.aImplementationId.getConstArray();
-    return memcmp( pId1, pId2, 16 * sizeof( sal_Int8 ) ) == 0;
-}
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/xmloff/PropertySetInfoKey.hxx b/include/xmloff/PropertySetInfoKey.hxx
deleted file mode 100644
index ab55c74..0000000
--- a/include/xmloff/PropertySetInfoKey.hxx
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#ifndef INCLUDED_XMLOFF_PROPERTYSETINFOKEY_HXX
-#define INCLUDED_XMLOFF_PROPERTYSETINFOKEY_HXX
-
-#include <osl/diagnose.h>
-#include <com/sun/star/uno/Sequence.hxx>
-
-namespace com { namespace sun { namespace star {
-    namespace beans { class XPropertySetInfo; }
-} } }
-
-
-struct PropertySetInfoKey
-{
-    ::com::sun::star::uno::Reference <
-        ::com::sun::star::beans::XPropertySetInfo > xPropInfo;
-    ::com::sun::star::uno::Sequence < sal_Int8 > aImplementationId;
-
-    inline PropertySetInfoKey();
-    inline PropertySetInfoKey(
-            const ::com::sun::star::uno::Reference <
-                    ::com::sun::star::beans::XPropertySetInfo >& rPropInfo,
-            const ::com::sun::star::uno::Sequence < sal_Int8 >& rImplId );
-};
-
-inline PropertySetInfoKey::PropertySetInfoKey()
-{
-    OSL_ENSURE( aImplementationId.getLength()==16, "illegal constructor call" );
-}
-
-inline PropertySetInfoKey::PropertySetInfoKey(
-        const ::com::sun::star::uno::Reference <
-            ::com::sun::star::beans::XPropertySetInfo >& rPropInfo,
-        const ::com::sun::star::uno::Sequence < sal_Int8 >& rImplId ) :
-    xPropInfo( rPropInfo ),
-    aImplementationId( rImplId )
-{
-    OSL_ENSURE( rPropInfo.is(), "prop info missing" );
-    OSL_ENSURE( aImplementationId.getLength()==16, "invalid implementation id" );
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/xmloff/SinglePropertySetInfoCache.hxx b/include/xmloff/SinglePropertySetInfoCache.hxx
index 55c37aa..85ff232 100644
--- a/include/xmloff/SinglePropertySetInfoCache.hxx
+++ b/include/xmloff/SinglePropertySetInfoCache.hxx
@@ -20,23 +20,19 @@
 #ifndef INCLUDED_XMLOFF_SINGLEPROPERTYSETINFOCACHE_HXX
 #define INCLUDED_XMLOFF_SINGLEPROPERTYSETINFOCACHE_HXX
 
-#include <com/sun/star/beans/XPropertySet.hpp>
+#include <sal/config.h>
 
-#include <boost/unordered_map.hpp>
-#include <xmloff/PropertySetInfoHash.hxx>
+#include <map>
 
-typedef boost::unordered_map
-<
-    PropertySetInfoKey,
-    sal_Bool,
-    PropertySetInfoHash,
-    PropertySetInfoHash
->
-SinglePropertySetInfoMap_Impl;
+#include <com/sun/star/beans/XPropertySet.hpp>
 
-class SinglePropertySetInfoCache : private SinglePropertySetInfoMap_Impl
+class SinglePropertySetInfoCache
 {
+    typedef std::map<css::uno::Reference<css::beans::XPropertySetInfo>, bool>
+        Map;
+
     OUString sName;
+    Map map_;
 
 public:
 
@@ -48,6 +44,7 @@ public:
                 ::com::sun::star::beans::XPropertySet >& rPropSet,
             ::com::sun::star::uno::Reference<
                 ::com::sun::star::beans::XPropertySetInfo >& rPropSetInfo );
+
     inline sal_Bool hasProperty(
             const ::com::sun::star::uno::Reference<
                 ::com::sun::star::beans::XPropertySet>& rPropSet );
diff --git a/xmloff/source/style/SinglePropertySetInfoCache.cxx b/xmloff/source/style/SinglePropertySetInfoCache.cxx
index 701d686..aa9a0d0 100644
--- a/xmloff/source/style/SinglePropertySetInfoCache.cxx
+++ b/xmloff/source/style/SinglePropertySetInfoCache.cxx
@@ -17,12 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <com/sun/star/lang/XTypeProvider.hpp>
 #include <cppuhelper/weakref.hxx>
 #include <xmloff/SinglePropertySetInfoCache.hxx>
 
 using namespace ::com::sun::star::uno;
-using ::com::sun::star::lang::XTypeProvider;
 using ::com::sun::star::beans::XPropertySet;
 using ::com::sun::star::beans::XPropertySetInfo;
 
@@ -32,46 +30,23 @@ sal_Bool SinglePropertySetInfoCache::hasProperty(
 {
     if( !rPropSetInfo.is() )
         rPropSetInfo = rPropSet->getPropertySetInfo();
-    sal_Bool bRet = sal_False, bValid = sal_False;
-    Reference < XTypeProvider > xTypeProv( rPropSet, UNO_QUERY );
-    Sequence< sal_Int8 > aImplId;
-    if( xTypeProv.is() )
+    Map::iterator aIter = map_.find( rPropSetInfo );
+    if( aIter != map_.end() )
     {
-        aImplId = xTypeProv->getImplementationId();
-        if( aImplId.getLength() == 16 )
-        {
-            // The key must not be created outside this block, because it
-            // keeps a reference to the property set info.
-            PropertySetInfoKey aKey( rPropSetInfo, aImplId );
-            iterator aIter = find( aKey );
-            if( aIter != end() )
-            {
-                bRet = (*aIter).second;
-                bValid = sal_True;
-            }
-        }
+        return (*aIter).second;
     }
-    if( !bValid )
+    bool bRet = rPropSetInfo->hasPropertyByName( sName );
+    // Check whether the property set info is destroyed if it is assigned to a
+    // weak reference only; if it is destroyed, then every instance of
+    // getPropertySetInfo returns a new object; Such property set infos must not
+    // be cached:
+    WeakReference < XPropertySetInfo > xWeakInfo( rPropSetInfo );
+    rPropSetInfo = 0;
+    rPropSetInfo = xWeakInfo;
+    if( rPropSetInfo.is() )
     {
-        bRet = rPropSetInfo->hasPropertyByName( sName );
-        if( xTypeProv.is() && aImplId.getLength() == 16 )
-        {
-            // Check whether the property set info is destroyed if it is
-            // assigned to a weak reference only. If it is destroyed, then
-            // every instance of getPropertySetInfo returns a new object.
-            // Such property set infos must not be cached.
-            WeakReference < XPropertySetInfo > xWeakInfo( rPropSetInfo );
-            rPropSetInfo = 0;
-            rPropSetInfo = xWeakInfo;
-            if( rPropSetInfo.is() )
-            {
-                PropertySetInfoKey aKey( rPropSetInfo, aImplId );
-                value_type aValue( aKey, bRet );
-                insert( aValue );
-            }
-        }
+        map_.insert(Map::value_type(rPropSetInfo, bRet));
     }
-
     return bRet;
 }
 
diff --git a/xmloff/source/style/xmlexppr.cxx b/xmloff/source/style/xmlexppr.cxx
index bddd6eb..8c48229 100644
--- a/xmloff/source/style/xmlexppr.cxx
+++ b/xmloff/source/style/xmlexppr.cxx
@@ -21,13 +21,12 @@
 #include <com/sun/star/xml/AttributeData.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/beans/XPropertyState.hpp>
-#include <com/sun/star/lang/XTypeProvider.hpp>
 #include <com/sun/star/beans/XMultiPropertySet.hpp>
 #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp>
 #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
 #include <rtl/ustrbuf.hxx>
 #include <list>
-#include <boost/unordered_map.hpp>
+#include <map>
 
 #include <xmloff/xmlexppr.hxx>
 #include <xmloff/xmltoken.hxx>
@@ -36,7 +35,6 @@
 #include <xmloff/xmlnmspe.hxx>
 #include <xmloff/xmlexp.hxx>
 #include <xmloff/xmlprmap.hxx>
-#include <xmloff/PropertySetInfoHash.hxx>
 
 using namespace ::std;
 using namespace ::com::sun::star;
@@ -510,7 +508,7 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
 
 struct SvXMLExportPropertyMapper::Impl
 {
-    typedef boost::unordered_map<PropertySetInfoKey, FilterPropertiesInfo_Impl*, PropertySetInfoHash, PropertySetInfoHash> CacheType;
+    typedef std::map<css::uno::Reference<css::beans::XPropertySetInfo>, FilterPropertiesInfo_Impl*> CacheType;
     CacheType maCache;
 
     UniReference<SvXMLExportPropertyMapper> mxNextMapper;
@@ -585,21 +583,9 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter(
 
     FilterPropertiesInfo_Impl *pFilterInfo = 0;
 
-    Reference < XTypeProvider > xTypeProv( xPropSet, UNO_QUERY );
-    Sequence< sal_Int8 > aImplId;
-    if( xTypeProv.is() )
-    {
-        aImplId = xTypeProv->getImplementationId();
-        if( aImplId.getLength() == 16 )
-        {
-            // The key must not be created outside this block, because it
-            // keeps a reference to the property set info.
-            PropertySetInfoKey aKey( xInfo, aImplId );
-            Impl::CacheType::iterator aIter = mpImpl->maCache.find(aKey);
-            if (aIter != mpImpl->maCache.end())
-                pFilterInfo = (*aIter).second;
-        }
-    }
+    Impl::CacheType::iterator aIter = mpImpl->maCache.find(xInfo);
+    if (aIter != mpImpl->maCache.end())
+        pFilterInfo = (*aIter).second;
 
     sal_Bool bDelInfo = sal_False;
     if( !pFilterInfo )
@@ -625,28 +611,19 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter(
             }
         }
 
-        if( xTypeProv.is() && aImplId.getLength() == 16 )
+        // Check whether the property set info is destroyed if it is assigned to
+        // a weak reference only; If it is destroyed, then every instance of
+        // getPropertySetInfo returns a new object; such property set infos must
+        // not be cached:
+        WeakReference < XPropertySetInfo > xWeakInfo( xInfo );
+        xInfo = 0;
+        xInfo = xWeakInfo;
+        if( xInfo.is() )
         {
-            // Check whether the property set info is destroyed if it is
-            // assigned to a weak reference only. If it is destroyed, then
-            // every instance of getPropertySetInfo returns a new object.
-            // Such property set infos must not be cached.
-            WeakReference < XPropertySetInfo > xWeakInfo( xInfo );
-            xInfo = 0;
-            xInfo = xWeakInfo;
-            if( xInfo.is() )
-            {
-                PropertySetInfoKey aKey( xInfo, aImplId );
-                mpImpl->maCache.insert(Impl::CacheType::value_type(aKey, pFilterInfo));
-            }
-            else
-                bDelInfo = true;
+            mpImpl->maCache.insert(Impl::CacheType::value_type(xInfo, pFilterInfo));
         }
         else
-        {
-            OSL_FAIL("here is no TypeProvider or the ImplId is wrong");
             bDelInfo = true;
-        }
     }
 
     if( pFilterInfo->GetPropertyCount() )


More information about the Libreoffice-commits mailing list