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

Kohei Yoshida kohei.yoshida at collabora.com
Sun Jan 8 01:48:59 UTC 2017


 package/inc/HashMaps.hxx                       |    8 ++++----
 package/inc/ZipPackageFolder.hxx               |    3 +--
 package/source/zippackage/ContentInfo.hxx      |   13 ++++++-------
 package/source/zippackage/ZipPackageFolder.cxx |   18 ++++++++++--------
 4 files changed, 21 insertions(+), 21 deletions(-)

New commits:
commit 4f24613db3fb36d9d7c97026b93819d457754d46
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Sat Jan 7 19:40:36 2017 -0500

    Rename css::packages::ContentInfo to just ZipContentInfo.
    
    And use std::unique_ptr not rtl::Reference.  This is not a UNO object
    anyway...
    
    Change-Id: If43da4f7e0f478b9ad8d62e5f43f04f035c31717
    Reviewed-on: https://gerrit.libreoffice.org/32828
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Kohei Yoshida <libreoffice at kohei.us>

diff --git a/package/inc/HashMaps.hxx b/package/inc/HashMaps.hxx
index f3d0c65..e83a948 100644
--- a/package/inc/HashMaps.hxx
+++ b/package/inc/HashMaps.hxx
@@ -23,6 +23,8 @@
 #include <rtl/ref.hxx>
 #include <unordered_map>
 
+#include <memory>
+
 struct eqFunc
 {
     bool operator()( const OUString &r1,
@@ -33,9 +35,7 @@ struct eqFunc
 };
 
 class ZipPackageFolder;
-namespace com { namespace sun { namespace star { namespace packages {
-class ContentInfo;
-} } } }
+struct ZipContentInfo;
 
 typedef std::unordered_map < OUString,
                         ZipPackageFolder *,
@@ -43,7 +43,7 @@ typedef std::unordered_map < OUString,
                         eqFunc > FolderHash;
 
 typedef std::unordered_map < OUString,
-                        rtl::Reference < css::packages::ContentInfo >,
+                        std::unique_ptr<ZipContentInfo>,
                         OUStringHash,
                         eqFunc > ContentHash;
 
diff --git a/package/inc/ZipPackageFolder.hxx b/package/inc/ZipPackageFolder.hxx
index 916c824..1b0cee3 100644
--- a/package/inc/ZipPackageFolder.hxx
+++ b/package/inc/ZipPackageFolder.hxx
@@ -59,8 +59,7 @@ public:
     void doInsertByName ( ZipPackageEntry *pEntry, bool bSetParent )
         throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, css::uno::RuntimeException);
 
-    css::packages::ContentInfo & doGetByName( const OUString& aName )
-        throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException);
+    ZipContentInfo& doGetByName( const OUString& aName );
 
     static void copyZipEntry( ZipEntry &rDest, const ZipEntry &rSource);
     static css::uno::Sequence < sal_Int8 > static_getImplementationId();
diff --git a/package/source/zippackage/ContentInfo.hxx b/package/source/zippackage/ContentInfo.hxx
index 89036874..a3e34de 100644
--- a/package/source/zippackage/ContentInfo.hxx
+++ b/package/source/zippackage/ContentInfo.hxx
@@ -24,10 +24,8 @@
 #include <ZipPackageFolder.hxx>
 #include <ZipPackageStream.hxx>
 
-namespace com { namespace sun { namespace star { namespace packages {
-class ContentInfo : public cppu::OWeakObject
+struct ZipContentInfo
 {
-public:
     css::uno::Reference < css::lang::XUnoTunnel > xTunnel;
     bool bFolder;
     union
@@ -35,19 +33,20 @@ public:
         ZipPackageFolder *pFolder;
         ZipPackageStream *pStream;
     };
-    ContentInfo ( ZipPackageStream * pNewStream )
+    ZipContentInfo ( ZipPackageStream * pNewStream )
     : xTunnel ( pNewStream )
     , bFolder ( false )
     , pStream ( pNewStream )
     {
     }
-    ContentInfo ( ZipPackageFolder * pNewFolder )
+    ZipContentInfo ( ZipPackageFolder * pNewFolder )
     : xTunnel ( pNewFolder )
     , bFolder ( true )
     , pFolder ( pNewFolder )
     {
     }
-    virtual ~ContentInfo () override
+
+    ~ZipContentInfo()
     {
         if ( bFolder )
             pFolder->clearParent();
@@ -55,7 +54,7 @@ public:
             pStream->clearParent();
     }
 };
-} } } }
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index 992f82b..22d18ce 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -37,6 +37,8 @@
 #include <EncryptedDataHeader.hxx>
 #include <rtl/instance.hxx>
 
+#include <o3tl/make_unique.hxx>
+
 using namespace com::sun::star;
 using namespace com::sun::star::packages::zip::ZipConstants;
 using namespace com::sun::star::packages::zip;
@@ -86,7 +88,7 @@ bool ZipPackageFolder::LookForUnexpectedODF12Streams( const OUString& aPath )
           ++aCI)
     {
         const OUString &rShortName = (*aCI).first;
-        const ContentInfo &rInfo = *(*aCI).second;
+        const ZipContentInfo &rInfo = *(*aCI).second;
 
         if ( rInfo.bFolder )
         {
@@ -143,7 +145,7 @@ void ZipPackageFolder::setChildStreamsTypeByExtension( const beans::StringPair&
           ++aCI)
     {
         const OUString &rShortName = (*aCI).first;
-        const ContentInfo &rInfo = *(*aCI).second;
+        const ZipContentInfo &rInfo = *(*aCI).second;
 
         if ( rInfo.bFolder )
             rInfo.pFolder->setChildStreamsTypeByExtension( aPair );
@@ -238,14 +240,14 @@ sal_Bool SAL_CALL ZipPackageFolder::hasElements(  )
     return maContents.size() > 0;
 }
     // XNameAccess
-ContentInfo& ZipPackageFolder::doGetByName( const OUString& aName )
-    throw(NoSuchElementException, WrappedTargetException, uno::RuntimeException)
+ZipContentInfo& ZipPackageFolder::doGetByName( const OUString& aName )
 {
     ContentHash::iterator aIter = maContents.find ( aName );
     if ( aIter == maContents.end())
         throw NoSuchElementException(THROW_WHERE );
-    return *(*aIter).second;
+    return *aIter->second;
 }
+
 uno::Any SAL_CALL ZipPackageFolder::getByName( const OUString& aName )
     throw(NoSuchElementException, WrappedTargetException, uno::RuntimeException, std::exception)
 {
@@ -369,7 +371,7 @@ void ZipPackageFolder::saveContents(
           ++aCI)
     {
         const OUString &rShortName = (*aCI).first;
-        const ContentInfo &rInfo = *(*aCI).second;
+        const ZipContentInfo &rInfo = *(*aCI).second;
 
         if ( !bMimeTypeStreamStored || !rShortName.equals( aMimeTypeStreamName ) )
         {
@@ -442,9 +444,9 @@ void ZipPackageFolder::doInsertByName ( ZipPackageEntry *pEntry, bool bSetParent
     try
     {
         if ( pEntry->IsFolder() )
-            maContents[pEntry->getName()] = new ContentInfo ( static_cast < ZipPackageFolder *> ( pEntry ) );
+            maContents[pEntry->getName()] = o3tl::make_unique<ZipContentInfo>(static_cast<ZipPackageFolder*>(pEntry));
         else
-            maContents[pEntry->getName()] = new ContentInfo ( static_cast < ZipPackageStream *> ( pEntry ) );
+            maContents[pEntry->getName()] = o3tl::make_unique<ZipContentInfo>(static_cast<ZipPackageStream*>(pEntry));
     }
     catch(const uno::Exception& rEx)
     {


More information about the Libreoffice-commits mailing list