Kaydet (Commit) 1b3122a1 authored tarafından Matúš Kukan's avatar Matúš Kukan

package: Add pure virtual ZipPackageEntry::saveChild()

..and adapt what needs to be changed.
So that, we can kill at least some usages of horrible ContentInfo struct.

Change-Id: I32d41f3b8ce2dfb65f0d1df18a540a3f67dcab6d
üst 152c4afe
...@@ -21,13 +21,19 @@ ...@@ -21,13 +21,19 @@
#include <com/sun/star/container/XChild.hpp> #include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <ZipEntry.hxx> #include <ZipEntry.hxx>
#include <cppuhelper/implbase5.hxx> #include <cppuhelper/implbase5.hxx>
#include <vector>
typedef void* rtlRandomPool;
class ZipOutputStream;
class ZipPackageFolder; class ZipPackageFolder;
class ZipPackageEntry : public cppu::WeakImplHelper5 class ZipPackageEntry : public cppu::WeakImplHelper5
...@@ -40,15 +46,18 @@ class ZipPackageEntry : public cppu::WeakImplHelper5 ...@@ -40,15 +46,18 @@ class ZipPackageEntry : public cppu::WeakImplHelper5
> >
{ {
protected: protected:
css::uno::Reference< css::uno::XComponentContext > m_xContext;
OUString msName; OUString msName;
bool mbIsFolder:1; bool mbIsFolder:1;
bool mbAllowRemoveOnInsert:1; bool mbAllowRemoveOnInsert:1;
// com::sun::star::uno::Reference < com::sun::star::container::XNameContainer > xParent; // com::sun::star::uno::Reference < com::sun::star::container::XNameContainer > xParent;
OUString msMediaType; OUString msMediaType;
ZipPackageFolder* mpParent; ZipPackageFolder* mpParent;
sal_Int32 m_nFormat;
public: public:
ZipEntry aEntry; ZipEntry aEntry;
ZipPackageEntry ( bool bNewFolder = false ); ZipPackageEntry();
virtual ~ZipPackageEntry( void ); virtual ~ZipPackageEntry( void );
const OUString& GetMediaType () const { return msMediaType; } const OUString& GetMediaType () const { return msMediaType; }
...@@ -58,6 +67,12 @@ public: ...@@ -58,6 +67,12 @@ public:
const ZipPackageFolder* GetParent () const { return mpParent; } const ZipPackageFolder* GetParent () const { return mpParent; }
void SetFolder ( bool bSetFolder ) { mbIsFolder = bSetFolder; } void SetFolder ( bool bSetFolder ) { mbIsFolder = bSetFolder; }
virtual bool saveChild( const OUString &rPath,
std::vector < css::uno::Sequence < css::beans::PropertyValue > > &rManList,
ZipOutputStream & rZipOut,
const css::uno::Sequence < sal_Int8 >& rEncryptionKey,
const rtlRandomPool &rRandomPool ) = 0;
void clearParent ( void ) void clearParent ( void )
{ {
// xParent.clear(); // xParent.clear();
......
...@@ -28,20 +28,8 @@ ...@@ -28,20 +28,8 @@
#include <cppuhelper/implbase2.hxx> #include <cppuhelper/implbase2.hxx>
#include <vector> #include <vector>
namespace com { namespace sun { namespace star {
namespace beans
{
struct PropertyValue;
}
namespace packages
{
class ContentInfo;
}
} } }
class ZipOutputStream; class ZipOutputStream;
struct ZipEntry; struct ZipEntry;
typedef void* rtlRandomPool;
class ZipPackageFolder : public cppu::ImplInheritanceHelper2 class ZipPackageFolder : public cppu::ImplInheritanceHelper2
< <
...@@ -51,14 +39,12 @@ class ZipPackageFolder : public cppu::ImplInheritanceHelper2 ...@@ -51,14 +39,12 @@ class ZipPackageFolder : public cppu::ImplInheritanceHelper2
> >
{ {
private: private:
css::uno::Reference< css::uno::XComponentContext> m_xContext;
ContentHash maContents; ContentHash maContents;
sal_Int32 m_nFormat;
OUString m_sVersion; OUString m_sVersion;
public: public:
ZipPackageFolder( css::uno::Reference< css::uno::XComponentContext> xContext, ZipPackageFolder( const css::uno::Reference < css::uno::XComponentContext >& xContext,
sal_Int32 nFormat, sal_Int32 nFormat,
bool bAllowRemoveOnInsert ); bool bAllowRemoveOnInsert );
virtual ~ZipPackageFolder(); virtual ~ZipPackageFolder();
...@@ -80,7 +66,13 @@ public: ...@@ -80,7 +66,13 @@ public:
static ::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 setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; }
void setRemoveOnInsertMode_Impl( bool bRemove ) { this->mbAllowRemoveOnInsert = bRemove; } void setRemoveOnInsertMode_Impl( bool bRemove ) { mbAllowRemoveOnInsert = bRemove; }
virtual bool saveChild( const OUString &rPath,
std::vector < css::uno::Sequence < css::beans::PropertyValue > > &rManList,
ZipOutputStream & rZipOut,
const css::uno::Sequence < sal_Int8 >& rEncryptionKey,
const rtlRandomPool &rRandomPool ) SAL_OVERRIDE;
// Recursive functions // Recursive functions
void saveContents( void saveContents(
......
...@@ -48,7 +48,6 @@ class ZipPackageStream : public cppu::ImplInheritanceHelper2 ...@@ -48,7 +48,6 @@ class ZipPackageStream : public cppu::ImplInheritanceHelper2
{ {
private: private:
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > m_xStream; com::sun::star::uno::Reference < com::sun::star::io::XInputStream > m_xStream;
const ::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_xContext;
ZipPackage &m_rZipPackage; ZipPackage &m_rZipPackage;
bool m_bToBeCompressed, m_bToBeEncrypted, m_bHaveOwnKey, m_bIsEncrypted; bool m_bToBeCompressed, m_bToBeEncrypted, m_bHaveOwnKey, m_bIsEncrypted;
...@@ -140,9 +139,10 @@ public: ...@@ -140,9 +139,10 @@ public:
void CloseOwnStreamIfAny(); void CloseOwnStreamIfAny();
ZipPackageStream ( ZipPackage & rNewPackage, ZipPackageStream( ZipPackage & rNewPackage,
const ::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext >& xContext, const css::uno::Reference < css::uno::XComponentContext >& xContext,
bool bAllowRemoveOnInsert ); sal_Int32 nFormat,
bool bAllowRemoveOnInsert );
virtual ~ZipPackageStream( void ); virtual ~ZipPackageStream( void );
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > GetRawEncrStreamNoHeaderCopy(); ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > GetRawEncrStreamNoHeaderCopy();
...@@ -150,6 +150,11 @@ public: ...@@ -150,6 +150,11 @@ public:
bool bAddHeaderForEncr ); bool bAddHeaderForEncr );
bool ParsePackageRawStream(); bool ParsePackageRawStream();
virtual bool saveChild( const OUString &rPath,
std::vector < css::uno::Sequence < css::beans::PropertyValue > > &rManList,
ZipOutputStream & rZipOut,
const css::uno::Sequence < sal_Int8 >& rEncryptionKey,
const rtlRandomPool &rRandomPool ) SAL_OVERRIDE;
void setZipEntryOnLoading( const ZipEntry &rInEntry); void setZipEntryOnLoading( const ZipEntry &rInEntry);
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawData() ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawData()
......
...@@ -556,7 +556,7 @@ void ZipPackage::getZipFileContents() ...@@ -556,7 +556,7 @@ void ZipPackage::getZipFileContents()
{ {
nStreamIndex++; nStreamIndex++;
sTemp = rName.copy( nStreamIndex, rName.getLength() - nStreamIndex ); sTemp = rName.copy( nStreamIndex, rName.getLength() - nStreamIndex );
pPkgStream = new ZipPackageStream( *this, m_xContext, m_bAllowRemoveOnInsert ); pPkgStream = new ZipPackageStream( *this, m_xContext, m_nFormat, m_bAllowRemoveOnInsert );
pPkgStream->SetPackageMember( true ); pPkgStream->SetPackageMember( true );
pPkgStream->setZipEntryOnLoading( rEntry ); pPkgStream->setZipEntryOnLoading( rEntry );
pPkgStream->setName( sTemp ); pPkgStream->setName( sTemp );
...@@ -942,7 +942,7 @@ sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName ) ...@@ -942,7 +942,7 @@ sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName )
uno::Reference< XInterface > SAL_CALL ZipPackage::createInstance() uno::Reference< XInterface > SAL_CALL ZipPackage::createInstance()
throw( Exception, RuntimeException, std::exception ) throw( Exception, RuntimeException, std::exception )
{ {
uno::Reference < XInterface > xRef = *( new ZipPackageStream ( *this, m_xContext, m_bAllowRemoveOnInsert ) ); uno::Reference < XInterface > xRef = *( new ZipPackageStream( *this, m_xContext, m_nFormat, m_bAllowRemoveOnInsert ) );
return xRef; return xRef;
} }
...@@ -954,9 +954,9 @@ uno::Reference< XInterface > SAL_CALL ZipPackage::createInstanceWithArguments( c ...@@ -954,9 +954,9 @@ uno::Reference< XInterface > SAL_CALL ZipPackage::createInstanceWithArguments( c
if ( aArguments.getLength() ) if ( aArguments.getLength() )
aArguments[0] >>= bArg; aArguments[0] >>= bArg;
if ( bArg ) if ( bArg )
xRef = *new ZipPackageFolder ( m_xContext, m_nFormat, m_bAllowRemoveOnInsert ); xRef = *new ZipPackageFolder( m_xContext, m_nFormat, m_bAllowRemoveOnInsert );
else else
xRef = *new ZipPackageStream ( *this, m_xContext, m_bAllowRemoveOnInsert ); xRef = *new ZipPackageStream( *this, m_xContext, m_nFormat, m_bAllowRemoveOnInsert );
return xRef; return xRef;
} }
......
...@@ -40,9 +40,8 @@ using namespace com::sun::star::packages::zip::ZipConstants; ...@@ -40,9 +40,8 @@ using namespace com::sun::star::packages::zip::ZipConstants;
#define THROW_WHERE "" #define THROW_WHERE ""
#endif #endif
ZipPackageEntry::ZipPackageEntry ( bool bNewFolder ) ZipPackageEntry::ZipPackageEntry()
: mbIsFolder ( bNewFolder ) : mbIsFolder( false )
, mbAllowRemoveOnInsert( true )
, mpParent ( NULL ) , mpParent ( NULL )
{ {
} }
......
...@@ -69,9 +69,9 @@ namespace { struct lcl_CachedImplId : public rtl::Static< cppu::OImplementationI ...@@ -69,9 +69,9 @@ namespace { struct lcl_CachedImplId : public rtl::Static< cppu::OImplementationI
ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage, ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage,
const uno::Reference< XComponentContext >& xContext, const uno::Reference< XComponentContext >& xContext,
sal_Int32 nFormat,
bool bAllowRemoveOnInsert ) bool bAllowRemoveOnInsert )
: m_xContext( xContext ) : m_rZipPackage( rNewPackage )
, m_rZipPackage( rNewPackage )
, m_bToBeCompressed ( true ) , m_bToBeCompressed ( true )
, m_bToBeEncrypted ( false ) , m_bToBeEncrypted ( false )
, m_bHaveOwnKey ( false ) , m_bHaveOwnKey ( false )
...@@ -88,10 +88,9 @@ ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage, ...@@ -88,10 +88,9 @@ ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage,
, m_bFromManifest( false ) , m_bFromManifest( false )
, m_bUseWinEncoding( false ) , m_bUseWinEncoding( false )
{ {
OSL_ENSURE( m_xContext.is(), "No factory is provided to ZipPackageStream!\n" ); m_xContext = xContext;
m_nFormat = nFormat;
this->mbAllowRemoveOnInsert = bAllowRemoveOnInsert; mbAllowRemoveOnInsert = bAllowRemoveOnInsert;
SetFolder ( false ); SetFolder ( false );
aEntry.nVersion = -1; aEntry.nVersion = -1;
aEntry.nFlag = 0; aEntry.nFlag = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment