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 @@
#include <com/sun/star/container/XChild.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/lang/XUnoTunnel.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <ZipEntry.hxx>
#include <cppuhelper/implbase5.hxx>
#include <vector>
typedef void* rtlRandomPool;
class ZipOutputStream;
class ZipPackageFolder;
class ZipPackageEntry : public cppu::WeakImplHelper5
......@@ -40,15 +46,18 @@ class ZipPackageEntry : public cppu::WeakImplHelper5
>
{
protected:
css::uno::Reference< css::uno::XComponentContext > m_xContext;
OUString msName;
bool mbIsFolder:1;
bool mbAllowRemoveOnInsert:1;
// com::sun::star::uno::Reference < com::sun::star::container::XNameContainer > xParent;
OUString msMediaType;
ZipPackageFolder* mpParent;
sal_Int32 m_nFormat;
public:
ZipEntry aEntry;
ZipPackageEntry ( bool bNewFolder = false );
ZipPackageEntry();
virtual ~ZipPackageEntry( void );
const OUString& GetMediaType () const { return msMediaType; }
......@@ -58,6 +67,12 @@ public:
const ZipPackageFolder* GetParent () const { return mpParent; }
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 )
{
// xParent.clear();
......
......@@ -28,20 +28,8 @@
#include <cppuhelper/implbase2.hxx>
#include <vector>
namespace com { namespace sun { namespace star {
namespace beans
{
struct PropertyValue;
}
namespace packages
{
class ContentInfo;
}
} } }
class ZipOutputStream;
struct ZipEntry;
typedef void* rtlRandomPool;
class ZipPackageFolder : public cppu::ImplInheritanceHelper2
<
......@@ -51,14 +39,12 @@ class ZipPackageFolder : public cppu::ImplInheritanceHelper2
>
{
private:
css::uno::Reference< css::uno::XComponentContext> m_xContext;
ContentHash maContents;
sal_Int32 m_nFormat;
OUString m_sVersion;
public:
ZipPackageFolder( css::uno::Reference< css::uno::XComponentContext> xContext,
ZipPackageFolder( const css::uno::Reference < css::uno::XComponentContext >& xContext,
sal_Int32 nFormat,
bool bAllowRemoveOnInsert );
virtual ~ZipPackageFolder();
......@@ -80,7 +66,13 @@ public:
static ::com::sun::star::uno::Sequence < sal_Int8 > static_getImplementationId();
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
void saveContents(
......
......@@ -48,7 +48,6 @@ class ZipPackageStream : public cppu::ImplInheritanceHelper2
{
private:
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;
bool m_bToBeCompressed, m_bToBeEncrypted, m_bHaveOwnKey, m_bIsEncrypted;
......@@ -140,9 +139,10 @@ public:
void CloseOwnStreamIfAny();
ZipPackageStream ( ZipPackage & rNewPackage,
const ::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext >& xContext,
bool bAllowRemoveOnInsert );
ZipPackageStream( ZipPackage & rNewPackage,
const css::uno::Reference < css::uno::XComponentContext >& xContext,
sal_Int32 nFormat,
bool bAllowRemoveOnInsert );
virtual ~ZipPackageStream( void );
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > GetRawEncrStreamNoHeaderCopy();
......@@ -150,6 +150,11 @@ public:
bool bAddHeaderForEncr );
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);
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawData()
......
......@@ -556,7 +556,7 @@ void ZipPackage::getZipFileContents()
{
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->setZipEntryOnLoading( rEntry );
pPkgStream->setName( sTemp );
......@@ -942,7 +942,7 @@ sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName )
uno::Reference< XInterface > SAL_CALL ZipPackage::createInstance()
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;
}
......@@ -954,9 +954,9 @@ uno::Reference< XInterface > SAL_CALL ZipPackage::createInstanceWithArguments( c
if ( aArguments.getLength() )
aArguments[0] >>= bArg;
if ( bArg )
xRef = *new ZipPackageFolder ( m_xContext, m_nFormat, m_bAllowRemoveOnInsert );
xRef = *new ZipPackageFolder( m_xContext, m_nFormat, m_bAllowRemoveOnInsert );
else
xRef = *new ZipPackageStream ( *this, m_xContext, m_bAllowRemoveOnInsert );
xRef = *new ZipPackageStream( *this, m_xContext, m_nFormat, m_bAllowRemoveOnInsert );
return xRef;
}
......
......@@ -40,9 +40,8 @@ using namespace com::sun::star::packages::zip::ZipConstants;
#define THROW_WHERE ""
#endif
ZipPackageEntry::ZipPackageEntry ( bool bNewFolder )
: mbIsFolder ( bNewFolder )
, mbAllowRemoveOnInsert( true )
ZipPackageEntry::ZipPackageEntry()
: mbIsFolder( false )
, mpParent ( NULL )
{
}
......
......@@ -69,9 +69,9 @@ namespace { struct lcl_CachedImplId : public rtl::Static< cppu::OImplementationI
ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage,
const uno::Reference< XComponentContext >& xContext,
sal_Int32 nFormat,
bool bAllowRemoveOnInsert )
: m_xContext( xContext )
, m_rZipPackage( rNewPackage )
: m_rZipPackage( rNewPackage )
, m_bToBeCompressed ( true )
, m_bToBeEncrypted ( false )
, m_bHaveOwnKey ( false )
......@@ -88,10 +88,9 @@ ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage,
, m_bFromManifest( false )
, m_bUseWinEncoding( false )
{
OSL_ENSURE( m_xContext.is(), "No factory is provided to ZipPackageStream!\n" );
this->mbAllowRemoveOnInsert = bAllowRemoveOnInsert;
m_xContext = xContext;
m_nFormat = nFormat;
mbAllowRemoveOnInsert = bAllowRemoveOnInsert;
SetFolder ( false );
aEntry.nVersion = -1;
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