[Libreoffice-commits] core.git: 3 commits - package/inc package/source writerperfect/source
package/inc/ZipPackage.hxx | 14 package/inc/zipfileaccess.hxx |1 package/source/zippackage/ZipPackage.cxx| 25 --- package/source/zippackage/zipfileaccess.cxx |4 - writerperfect/source/common/WPXSvStream.cxx | 90 +++- 5 files changed, 44 insertions(+), 90 deletions(-) New commits: commit c20db8735e3f30cf61940e8c1da739efcb00ae22 Author: David Tardon dtar...@redhat.com Date: Thu Jan 16 16:37:57 2014 +0100 Revert impl. enumeration for ZipPackage This reverts commit 5b2cca80eeb2c8ee210820cc8ed95e5d69214807. Also reverts commit 86a5053df0d755d10121d65c533f3d327340a0fd. diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx index 1a0bb30..3631799 100644 --- a/package/inc/ZipPackage.hxx +++ b/package/inc/ZipPackage.hxx @@ -19,9 +19,8 @@ #ifndef _ZIP_PACKAGE_HXX #define _ZIP_PACKAGE_HXX -#include cppuhelper/implbase8.hxx +#include cppuhelper/implbase7.hxx #include com/sun/star/lang/XInitialization.hpp -#include com/sun/star/container/XEnumerationAccess.hpp #include com/sun/star/container/XHierarchicalNameAccess.hpp #include com/sun/star/lang/XSingleServiceFactory.hpp #include com/sun/star/util/XChangesBatch.hpp @@ -64,13 +63,12 @@ enum InitialisationMode e_IMode_XStream }; -class ZipPackage : public cppu::WeakImplHelper8 +class ZipPackage : public cppu::WeakImplHelper7 com::sun::star::lang::XInitialization, com::sun::star::lang::XSingleServiceFactory, com::sun::star::lang::XUnoTunnel, com::sun::star::lang::XServiceInfo, - com::sun::star::container::XEnumerationAccess, com::sun::star::container::XHierarchicalNameAccess, com::sun::star::util::XChangesBatch, com::sun::star::beans::XPropertySet @@ -143,14 +141,6 @@ public: // XInitialization virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence ::com::sun::star::uno::Any aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); -// XEnumerationAccess -virtual ::com::sun::star::uno::Reference ::com::sun::star::container::XEnumeration SAL_CALL createEnumeration() -throw(::com::sun::star::uno::RuntimeException); -// XElementType -virtual ::com::sun::star::uno::Type SAL_CALL getElementType() -throw(::com::sun::star::uno::RuntimeException); -virtual sal_Bool SAL_CALL hasElements() -throw(::com::sun::star::uno::RuntimeException); // XHierarchicalNameAccess virtual ::com::sun::star::uno::Any SAL_CALL getByHierarchicalName( const OUString aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index bf0e026..f20b1f0 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -66,7 +66,6 @@ #include osl/time.h #include com/sun/star/io/XAsyncOutputMonitor.hpp -#include cassert #include cstring #include memory #include vector @@ -778,30 +777,6 @@ void SAL_CALL ZipPackage::initialize( const uno::Sequence Any aArguments ) } } -::com::sun::star::uno::Reference ::com::sun::star::container::XEnumeration SAL_CALL ZipPackage::createEnumeration() -throw( RuntimeException ) -{ -assert(m_pRootFolder); - -return m_pRootFolder-createEnumeration(); -} - -::com::sun::star::uno::Type SAL_CALL ZipPackage::getElementType() -throw( RuntimeException ) -{ -assert(m_pRootFolder); - -return m_pRootFolder-getElementType(); -} - -sal_Bool SAL_CALL ZipPackage::hasElements() -throw( RuntimeException ) -{ -assert(m_pRootFolder); - -return m_pRootFolder-hasElements(); -} - Any SAL_CALL ZipPackage::getByHierarchicalName( const OUString aName ) throw( NoSuchElementException, RuntimeException ) { commit 04a9214fbf6da2ec9fa36fca4bb949d8f712c982 Author: David Tardon dtar...@redhat.com Date: Thu Jan 16 13:22:26 2014 +0100 css::packages::Packages is a wrong choice Change-Id: I7d27e7f320633c176fb9fb0a5f64e891fff6c4d7 diff --git a/writerperfect/source/common/WPXSvStream.cxx b/writerperfect/source/common/WPXSvStream.cxx index 0084ec3..6bb14d2 100644 --- a/writerperfect/source/common/WPXSvStream.cxx +++ b/writerperfect/source/common/WPXSvStream.cxx @@ -9,13 +9,11 @@ #include WPXSvStream.hxx -#include com/sun/star/container/XEnumerationAccess.hpp -#include com/sun/star/container/XHierarchicalNameAccess.hpp -#include com/sun/star/container/XNamed.hpp -#include com/sun/star/io/XActiveDataSink.hpp +#include com/sun/star/packages/zip/XZipFileAccess2.hpp #include com/sun/star/uno/Any.hxx #include comphelper/processfactory.hxx +#include
[Libreoffice-commits] core.git: 3 commits - package/inc package/source writerperfect/source
package/inc/ZipPackage.hxx | 14 + package/source/zippackage/ZipPackage.cxx| 25 ++ writerperfect/source/common/WPXSvStream.cxx | 299 +++- 3 files changed, 326 insertions(+), 12 deletions(-) New commits: commit 723863ff26f46e294adde61009b85f6f0e28b5b0 Author: David Tardon dtar...@redhat.com Date: Wed Jan 15 21:15:28 2014 +0100 finish zip support in WPXSvInputStream Change-Id: I48017873991abdc054e8be93912f2b2f5ae4383f diff --git a/writerperfect/source/common/WPXSvStream.cxx b/writerperfect/source/common/WPXSvStream.cxx index 9bc6984..0084ec3 100644 --- a/writerperfect/source/common/WPXSvStream.cxx +++ b/writerperfect/source/common/WPXSvStream.cxx @@ -9,7 +9,10 @@ #include WPXSvStream.hxx +#include com/sun/star/container/XEnumerationAccess.hpp #include com/sun/star/container/XHierarchicalNameAccess.hpp +#include com/sun/star/container/XNamed.hpp +#include com/sun/star/io/XActiveDataSink.hpp #include com/sun/star/uno/Any.hxx #include comphelper/processfactory.hxx @@ -86,9 +89,9 @@ const rtl::OUString concatPath(const rtl::OUString lhs, const rtl::OUString rh return lhs + / + rhs; } -struct StreamData +struct OLEStreamData { -explicit StreamData(const rtl::OString rName); +explicit OLEStreamData(const rtl::OString rName); SotStorageStreamRefWrapper stream; @@ -136,12 +139,12 @@ private: public: SotStorageRefWrapper mxRootStorage; // root storage of the OLE2 OLEStorageMap_t maStorageMap; // map of all sub storages by name -::std::vector StreamData maStreams; // list of streams and their names +::std::vector OLEStreamData maStreams; // list of streams and their names NameMap_t maNameMap; // map of stream names to indexes (into @c maStreams) bool mbInitialized; }; -StreamData::StreamData(const rtl::OString rName) +OLEStreamData::OLEStreamData(const rtl::OString rName) : stream() , name(rName) { @@ -202,7 +205,7 @@ void OLEStorageImpl::traverse(const SotStorageRef rStorage, const rtl::OUString { if (aIt-IsStream()) { - maStreams.push_back(StreamData(rtl::OUStringToOString(aIt-GetName(), RTL_TEXTENCODING_UTF8))); + maStreams.push_back(OLEStreamData(rtl::OUStringToOString(aIt-GetName(), RTL_TEXTENCODING_UTF8))); maNameMap[concatPath(rPath, aIt-GetName())] = maStreams.size() - 1; } else if (aIt-IsStorage()) @@ -243,6 +246,162 @@ SotStorageStreamRef OLEStorageImpl::createStream(const rtl::OUString rPath) } +namespace +{ + +struct ZipStreamData +{ +explicit ZipStreamData(const rtl::OString rName); + +ReferenceXInputStream xStream; + +/** Name of the stream. + * + * This is not @c rtl::OUString, because we need to be able to + * produce const char* from it. + */ +rtl::OString aName; +}; + +typedef boost::unordered_maprtl::OUString, ReferenceXInputStream, rtl::OUStringHash ZipStorageMap_t; + +/** Representation of a Zip storage. + * + * This is quite similar to OLEStorageImpl, except that we do not need + * to keep all storages (folders) open. + */ +struct ZipStorageImpl +{ +ZipStorageImpl(const Referencecontainer::XHierarchicalNameAccess rxRoot); + +/** Initialize for access. + * + * This creates a bidirectional map of stream names to their + * indexes (index of a stream is determined by deep-first + * traversal). + */ +void initialize(); + +ReferenceXInputStream getStream(const rtl::OUString rPath); +ReferenceXInputStream getStream(std::size_t nId); + +private: +void traverse(const Referencecontainer::XEnumeration rxEnum, const rtl::OUString rPath); + +ReferenceXInputStream createStream(const rtl::OUString rPath); + +public: +Referencecontainer::XHierarchicalNameAccess mxRoot; // root of the Zip +::std::vector ZipStreamData maStreams; // list of streams and their names +NameMap_t maNameMap; // map of stream names to indexes (into @c maStreams) +bool mbInitialized; +}; + +ZipStreamData::ZipStreamData(const rtl::OString rName) +: xStream() +, aName(rName) +{ +} + +ZipStorageImpl::ZipStorageImpl(const Referencecontainer::XHierarchicalNameAccess rxRoot) +: mxRoot(rxRoot) +, maStreams() +, maNameMap() +, mbInitialized(false) +{ +assert(mxRoot.is()); +} + +void ZipStorageImpl::initialize() +{ +const Referencecontainer::XEnumerationAccess xEnum(mxRoot, UNO_QUERY); + +if (xEnum.is()) +traverse(xEnum-createEnumeration(), ); + +mbInitialized = true; +} + +ReferenceXInputStream ZipStorageImpl::getStream(const rtl::OUString rPath) +{ +NameMap_t::iterator aIt = maNameMap.find(rPath); + +// For the while don't return stream in this situation. +// Later, given how libcdr's zip stream implementation behaves, +// return the first stream in the storage if there is one. +if (maNameMap.end() == aIt) +return