summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2009-06-03 11:26:39 +0000
committerKurt Zenker <kz@openoffice.org>2009-06-03 11:26:39 +0000
commit65d3b7eea08aeb5bb6b510d683a1de602fc856cc (patch)
tree20d65f8e4aa9d14aa9e589f5b9ef9947ebb9f568 /package
parent3dc749116026183c4af40e4d3982387de9fab953 (diff)
CWS-TOOLING: integrate CWS os128
2009-04-22 12:58:26 +0200 b_michaelsen r271093 : #i101084# using the frames enumeration for other SwXFrames-queries; also added a complex test to ensure the behavior to be the same 2009-04-20 14:53:03 +0200 mav r270987 : #i101219# adjust the testcases to test memory cache and temporary file cache 2009-04-20 14:52:09 +0200 mav r270986 : #i101219#,#i99077# use memory to cache data; no precopying on commit 2009-04-20 14:39:21 +0200 mav r270984 : #i101219# use memory to cache data 2009-04-20 14:39:08 +0200 mav r270983 : #i101219# use memory to cache data 2009-04-20 14:38:45 +0200 mav r270982 : #i101219# use memory to cache data 2009-04-17 07:37:52 +0200 os r270912 : CWS-TOOLING: rebase CWS os128 to trunk@270723 (milestone: DEV300:m46) 2009-04-15 14:54:18 +0200 b_michaelsen r270845 : #i101084# using frame enumerations for paragraph export for better performance 2009-04-15 14:52:54 +0200 b_michaelsen r270843 : #i101084# implemented XEnumerationAccess interface on framesets 2009-04-03 17:08:10 +0200 mav r270504 : #i100722# do not compress streams of known compressed types per default 2009-04-03 13:49:50 +0200 os r270484 : resync error fixed 2009-04-03 12:55:32 +0200 mav r270470 : #i100722# do not compress streams of known compressed types per default 2009-04-03 10:00:58 +0200 os r270463 : resync error fixed 2009-04-03 09:52:53 +0200 os r270462 : resync error fixed 2009-04-03 09:10:14 +0200 os r270449 : #i99568# string compare operator of hash_map changed 2009-04-03 09:03:49 +0200 os r270446 : #i100683# normalize file URLs 2009-04-02 11:09:27 +0200 os r270381 : #i100683# making URLs relative without file access 2009-04-02 09:04:42 +0200 os r270366 : CWS-TOOLING: rebase CWS os128 to trunk@270033 (milestone: DEV300:m45) 2009-03-31 08:08:37 +0200 os r270258 : #i100683# reducing calls to URIHelper::simpleNormalizeMakeRelative() 2009-03-19 17:06:22 +0100 os r269756 : #i99568# XTolerantMultiPropertySet activated 2009-03-16 11:46:14 +0100 os r269517 : wrong commit to #i97471# removed 2009-03-16 11:36:50 +0100 os r269514 : #i97471# SwDrawTextShell::Init(): mouse double click and key input in group objects at the same time: prevent crash 2009-03-13 11:08:54 +0100 os r269464 : #i99568# static SfxItemPropertySet 2009-03-13 11:03:22 +0100 os r269463 : #i99568# static SfxItemPropertySet 2009-03-11 12:59:27 +0100 os r269320 : #i99568# WhichId of properties handled from ScDocOptionsObj added 2009-03-06 09:09:58 +0100 os r268972 : #i99568# SfxItemPropertySet improvements 2009-03-05 20:54:43 +0100 os r268942 : #i99568# Sfx/SvxItemPropertySet improvements 2009-03-05 20:19:52 +0100 os r268941 : #i99568# SfxItemPropertySet improvements 2009-03-05 20:05:03 +0100 os r268940 : #i99568# SfxItemPropertySet improvements 2009-03-05 18:54:47 +0100 os r268936 : #i99568# Sfx/SvxItemPropertySet improvements 2009-03-05 17:51:38 +0100 os r268931 : #i99568# Sfx/SvxItemPropertySet improvements 2009-03-05 17:33:03 +0100 os r268930 : #i99568# Sfx/SvxItemPropertySet improvements 2009-03-05 15:53:00 +0100 os r268920 : #i99568# Sfx/SvxItemPropertySet improvements 2009-03-05 15:52:50 +0100 os r268919 : #i99568# Sfx/SvxItemPropertySet improvements 2009-03-05 15:50:41 +0100 os r268918 : #i99568# Sfx/SvxItemPropertySet improvements 2009-03-05 15:41:04 +0100 os r268916 : #i99568# Sfx/SvxItemPropertySet improvements 2009-03-05 15:40:40 +0100 os r268915 : #i99568# Sfx/SvxItemPropertySet improvements 2009-03-05 10:16:20 +0100 os r268881 : #i99568# Sfx/SvxItemPropertySet improvements 2009-03-05 10:15:55 +0100 os r268880 : #i99568# Sfx/SvxItemPropertySet improvements 2009-03-03 08:40:09 +0100 os r268704 : ScTableSheetObj::GetItemPropertyMap fixed 2009-03-03 07:50:00 +0100 os r268703 : SfxItemProperty set as pointer 2009-03-03 07:49:46 +0100 os r268702 : SfxItemProperty set as pointer 2009-03-02 08:15:37 +0100 os r268631 : minor fix 2009-03-02 07:58:38 +0100 os r268630 : minor fix 2009-02-27 13:03:25 +0100 os r268584 : exports 2009-02-27 11:17:04 +0100 os r268567 : debug code removed 2009-02-27 11:04:07 +0100 os r268565 : duplicate return removed 2009-02-27 10:17:37 +0100 os r268558 : syntax fixed 2009-02-27 09:56:14 +0100 os r268554 : #i99568# type mix fixed 2009-02-27 09:40:56 +0100 os r268553 : #i99568# exports changes reverted 2009-02-25 12:50:54 +0100 os r268433 : #i99568# SfxItemPropertySet rework 2009-02-25 12:13:39 +0100 os r268432 : #i99568# SfxItemPropertySet rework 2009-02-25 12:12:47 +0100 os r268431 : #i99568# SfxItemPropertySet rework 2009-02-25 12:10:27 +0100 os r268430 : #i99568# SfxItemPropertySet rework 2009-02-25 12:09:36 +0100 os r268429 : #i99568# SfxItemPropertySet rework 2009-02-25 12:07:39 +0100 os r268428 : #i99568# SfxItemPropertySet rework 2009-02-25 11:59:35 +0100 os r268427 : #i99568# SfxItemPropertySet rework 2009-02-25 11:52:52 +0100 os r268425 : #i99568# SfxItemPropertySet rework 2009-02-25 11:49:17 +0100 os r268424 : #i99568# SfxItemPropertySet rework 2009-02-25 11:45:17 +0100 os r268423 : #i99568# SfxItemPropertySet rework 2009-02-11 11:39:04 +0100 os r267587 : #i57008# use registration of index marks at SwUnoCallback
Diffstat (limited to 'package')
-rw-r--r--package/inc/ZipFile.hxx2
-rw-r--r--package/qa/storages/StorageUnitTest.java9
-rw-r--r--package/qa/storages/Test01.java18
-rw-r--r--package/qa/storages/Test02.java11
-rw-r--r--package/qa/storages/Test03.java33
-rw-r--r--package/qa/storages/Test04.java33
-rw-r--r--package/qa/storages/Test05.java42
-rw-r--r--package/qa/storages/Test07.java24
-rw-r--r--package/qa/storages/Test08.java16
-rw-r--r--package/qa/storages/Test09.java14
-rw-r--r--package/qa/storages/Test10.java25
-rw-r--r--package/qa/storages/Test11.java28
-rw-r--r--package/qa/storages/Test12.java25
-rw-r--r--package/qa/storages/Test13.java31
-rw-r--r--package/qa/storages/Test18.java172
-rw-r--r--package/qa/storages/TestHelper.java93
-rw-r--r--package/qa/storages/makefile.mk1
-rw-r--r--package/source/xstor/owriteablestream.cxx560
-rw-r--r--package/source/xstor/owriteablestream.hxx14
-rw-r--r--package/source/xstor/xstorage.cxx6
-rw-r--r--package/source/zipapi/XFileStream.cxx2
-rw-r--r--package/source/zipapi/XUnbufferedStream.cxx4
-rw-r--r--package/source/zipapi/ZipFile.cxx13
-rw-r--r--package/source/zipapi/ZipOutputStream.cxx13
-rw-r--r--package/source/zippackage/ZipPackageFolder.cxx15
25 files changed, 1024 insertions, 180 deletions
diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx
index 4eef944a935b..287b899f7ab0 100644
--- a/package/inc/ZipFile.hxx
+++ b/package/inc/ZipFile.hxx
@@ -131,7 +131,7 @@ public:
sal_Bool bDecrypt)
throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException);
- static void StaticGetCipher ( const vos::ORef < EncryptionData > & xEncryptionData, rtlCipher &rCipher );
+ static sal_Bool StaticGetCipher ( const vos::ORef < EncryptionData > & xEncryptionData, rtlCipher &rCipher, sal_Bool bDecode );
static void StaticFillHeader ( const vos::ORef < EncryptionData > & rData,
sal_Int32 nSize,
diff --git a/package/qa/storages/StorageUnitTest.java b/package/qa/storages/StorageUnitTest.java
index 7e8caa314e96..2ebfb2967e1d 100644
--- a/package/qa/storages/StorageUnitTest.java
+++ b/package/qa/storages/StorageUnitTest.java
@@ -84,6 +84,7 @@ public class StorageUnitTest extends ComplexTestCase
"ExecuteTest15",
"ExecuteTest16",
"ExecuteTest17",
+ "ExecuteTest18",
"ExecuteRegressionTest_114358",
"ExecuteRegressionTest_i29169",
"ExecuteRegressionTest_i30400",
@@ -97,7 +98,8 @@ public class StorageUnitTest extends ComplexTestCase
"ExecuteRegressionTest_i59886",
"ExecuteRegressionTest_i61909",
"ExecuteRegressionTest_i84234",
- "ExecuteRegressionTest_125919"};
+ "ExecuteRegressionTest_125919"
+ };
}
public String getTestObjectName()
@@ -234,6 +236,11 @@ public class StorageUnitTest extends ComplexTestCase
assure( "Test17 failed!", aTest.test() );
}
+ public void ExecuteTest18()
+ {
+ StorageTest aTest = new Test18( m_xMSF, m_xStorageFactory, log );
+ assure( "Test18 failed!", aTest.test() );
+ }
public void ExecuteRegressionTest_114358()
{
diff --git a/package/qa/storages/Test01.java b/package/qa/storages/Test01.java
index e1a78fd85763..a793a2fd5809 100644
--- a/package/qa/storages/Test01.java
+++ b/package/qa/storages/Test01.java
@@ -58,6 +58,18 @@ public class Test01 implements StorageTest {
return false;
}
+ byte pBigBytes[] = new byte[33000];
+ for ( int nInd = 0; nInd < 33000; nInd++ )
+ pBigBytes[nInd] = (byte)( nInd % 128 );
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "BigSubStream2", "MediaType2", false, pBigBytes ) )
+ return false;
+
byte pBytes1[] = { 1, 1, 1, 1, 1 };
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
@@ -136,6 +148,12 @@ public class Test01 implements StorageTest {
if ( !m_aTestHelper.checkStorageProperties( xResultSubStorage, "MediaType4", false, ElementModes.READ ) )
return false;
+ if ( !m_aTestHelper.checkStream( xResultSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
+ if ( !m_aTestHelper.checkStream( xResultSubStorage, "BigSubStream2", "MediaType2", false, pBigBytes ) )
+ return false;
+
if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream1", "MediaType1", true, pBytes1 ) )
return false;
diff --git a/package/qa/storages/Test02.java b/package/qa/storages/Test02.java
index 729cdd27fa11..668efbe6a509 100644
--- a/package/qa/storages/Test02.java
+++ b/package/qa/storages/Test02.java
@@ -60,6 +60,14 @@ public class Test02 implements StorageTest {
return false;
}
+ byte pBigBytes[] = new byte[33000];
+ for ( int nInd = 0; nInd < 33000; nInd++ )
+ pBigBytes[nInd] = (byte)( nInd % 128 );
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
byte pBytes1[] = { 1, 1, 1, 1, 1 };
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
@@ -136,6 +144,9 @@ public class Test02 implements StorageTest {
if ( !m_aTestHelper.checkStorageProperties( xResultSubStorage, "MediaType3", false, ElementModes.READ ) )
return false;
+ if ( !m_aTestHelper.checkStream( xResultSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream1", "MediaType1", true, pBytes1 ) )
return false;
diff --git a/package/qa/storages/Test03.java b/package/qa/storages/Test03.java
index 80259500778b..353cd4df8d14 100644
--- a/package/qa/storages/Test03.java
+++ b/package/qa/storages/Test03.java
@@ -52,6 +52,18 @@ public class Test03 implements StorageTest {
return false;
}
+ byte pBigBytes[] = new byte[33000];
+ for ( int nInd = 0; nInd < 33000; nInd++ )
+ pBigBytes[nInd] = (byte)( nInd % 128 );
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "BigSubStream2", "MediaType2", false, pBigBytes ) )
+ return false;
+
byte pBytes1[] = { 1, 1, 1, 1, 1 };
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
@@ -140,15 +152,24 @@ public class Test03 implements StorageTest {
// check that root storage contents are represented correctly
String sRootCont[] = xRootNameAccess.getElementNames();
- if ( sRootCont.length != 2 )
+ if ( sRootCont.length != 3 )
{
m_aTestHelper.Error( "Root storage contains wrong amount of children!" );
return false;
}
- if ( !( sRootCont[0].equals( "SubStorage1" ) && sRootCont[1].equals( "SubStream1" )
- || sRootCont[0].equals( "SubStream1" ) && sRootCont[1].equals( "SubStorage1" ) )
- || !( xRootNameAccess.hasByName( "SubStream1" ) && xRootNameAccess.hasByName( "SubStorage1" ) ) )
+ int nFlag = 0;
+ for ( int nInd = 0; nInd < sRootCont.length; nInd++ )
+ {
+ if ( sRootCont[nInd].equals( "SubStorage1" ) )
+ nFlag |= 1;
+ else if ( sRootCont[nInd].equals( "SubStream1" ) )
+ nFlag |= 2;
+ else if ( sRootCont[nInd].equals( "BigSubStream1" ) )
+ nFlag |= 4;
+ }
+
+ if ( nFlag != 7 || !( xRootNameAccess.hasByName( "BigSubStream1" ) && xRootNameAccess.hasByName( "SubStream1" ) && xRootNameAccess.hasByName( "SubStorage1" ) ) )
{
m_aTestHelper.Error( "Root storage contains wrong list of children!" );
return false;
@@ -169,9 +190,9 @@ public class Test03 implements StorageTest {
return false;
}
- if ( !xChildAccess.hasByName( "SubStream2" )
+ if ( !( xChildAccess.hasByName( "SubStream2" ) && xChildAccess.hasByName( "BigSubStream2" ) )
|| !xResultSubStorage.isStreamElement( "SubStream2" )
- || xResultSubStorage.isStorageElement( "SubStream2" ) )
+ || !xResultSubStorage.isStreamElement( "BigSubStream2" ) )
{
m_aTestHelper.Error( "'SubStream2' can not be detected as child stream element of 'SubStorage1'!" );
return false;
diff --git a/package/qa/storages/Test04.java b/package/qa/storages/Test04.java
index 6c6dedee1817..81f770f8ff9a 100644
--- a/package/qa/storages/Test04.java
+++ b/package/qa/storages/Test04.java
@@ -63,6 +63,14 @@ public class Test04 implements StorageTest {
return false;
}
+ byte pBigBytes[] = new byte[33000];
+ for ( int nInd = 0; nInd < 33000; nInd++ )
+ pBigBytes[nInd] = (byte)( nInd % 128 );
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage1, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
byte pBytes1[] = { 1, 1, 1, 1, 1 };
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
@@ -79,6 +87,10 @@ public class Test04 implements StorageTest {
return false;
}
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage2, "BigSubStream2", "MediaType2", false, pBigBytes ) )
+ return false;
+
byte pBytes2[] = { 2, 2, 2, 2, 2 };
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
@@ -158,6 +170,15 @@ public class Test04 implements StorageTest {
if ( !m_aTestHelper.moveElementTo( xTempSubStorage1, "SubStream1", xTempFileStorage ) )
return false;
+ if ( !m_aTestHelper.copyElementTo( xTempSubStorage1, "BigSubStream1", xTempFileStorage ) )
+ return false;
+
+ if ( !m_aTestHelper.renameElement( xTempFileStorage, "BigSubStream1", "BigSubStream1_copy" ) )
+ return false;
+
+ if ( !m_aTestHelper.moveElementTo( xTempSubStorage1, "BigSubStream1", xTempFileStorage ) )
+ return false;
+
if ( !m_aTestHelper.commitStorage( xTempFileStorage ) )
return false;
@@ -212,15 +233,27 @@ public class Test04 implements StorageTest {
if ( !m_aTestHelper.checkStream( xResStorage, "SubStream1", "MediaType1", true, pBytes1 ) )
return false;
+ if ( !m_aTestHelper.checkStream( xResStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
if ( !m_aTestHelper.checkStream( xResStorage, "SubStream1_copy", "MediaType1", true, pBytes1 ) )
return false;
+ if ( !m_aTestHelper.checkStream( xResStorage, "BigSubStream1_copy", "MediaType1", true, pBigBytes ) )
+ return false;
+
if ( !m_aTestHelper.checkStream( xResSubStorage1, "SubStream1", "MediaType1", true, pBytes1 ) )
return false;
+ if ( !m_aTestHelper.checkStream( xResSubStorage1, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
if ( !m_aTestHelper.checkStream( xResSubStorage2, "SubStream2", "MediaType2", false, pBytes2 ) )
return false;
+ if ( !m_aTestHelper.checkStream( xResSubStorage2, "BigSubStream2", "MediaType2", false, pBigBytes ) )
+ return false;
+
// the storage must be disposed before removing
if ( !m_aTestHelper.disposeStorage( xResSubStorage2 ) )
return false;
diff --git a/package/qa/storages/Test05.java b/package/qa/storages/Test05.java
index bea3d3cccbd0..adf943c6ef12 100644
--- a/package/qa/storages/Test05.java
+++ b/package/qa/storages/Test05.java
@@ -72,6 +72,17 @@ public class Test05 implements StorageTest {
return false;
}
+ byte pBigBytes[] = new byte[33000];
+ for ( int nInd = 0; nInd < 33000; nInd++ )
+ pBigBytes[nInd] = (byte)( nInd % 128 );
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xSubSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xSubSubStorage, "BigSubStream2", "MediaType2", false, pBigBytes ) )
+ return false;
byte pBytes1[] = { 1, 1, 1, 1, 1 };
@@ -126,27 +137,40 @@ public class Test05 implements StorageTest {
XStream xSubStream1 = m_aTestHelper.OpenStream( xSubSubStorage,
"SubStream1",
ElementModes.WRITE | ElementModes.NOCREATE );
+ XStream xBigSubStream1 = m_aTestHelper.OpenStream( xSubSubStorage,
+ "BigSubStream1",
+ ElementModes.WRITE | ElementModes.NOCREATE );
XStream xSubStream2 = m_aTestHelper.OpenStream( xSubSubStorage,
"SubStream2",
ElementModes.READ | ElementModes.NOCREATE );
- if ( xSubStream1 == null || xSubStream2 == null )
+ XStream xBigSubStream2 = m_aTestHelper.OpenStream( xSubSubStorage,
+ "BigSubStream2",
+ ElementModes.READ | ElementModes.NOCREATE );
+
+ if ( xSubStream1 == null || xBigSubStream1 == null || xSubStream2 == null || xBigSubStream2 == null )
return false;
// it should be possible to have more then one copy of stream for reading
XStream xSubStream2clone = m_aTestHelper.OpenStream( xSubSubStorage,
"SubStream2",
ElementModes.READ | ElementModes.NOCREATE );
- if ( xSubStream2 == null )
+ XStream xBigSubStream2clone = m_aTestHelper.OpenStream( xSubSubStorage,
+ "BigSubStream2",
+ ElementModes.READ | ElementModes.NOCREATE );
+ if ( xSubStream2clone == null || xBigSubStream2clone == null )
return false;
- // so now the first stream can not be open neither for reading nor for writing
+ // so now the first streams can not be open neither for reading nor for writing
if ( !m_aTestHelper.cantOpenStream( xSubSubStorage, "SubStream1", ElementModes.WRITE )
- || !m_aTestHelper.cantOpenStream( xSubSubStorage, "SubStream1", ElementModes.READ ) )
+ || !m_aTestHelper.cantOpenStream( xSubSubStorage, "SubStream1", ElementModes.READ )
+ || !m_aTestHelper.cantOpenStream( xSubSubStorage, "BigSubStream1", ElementModes.WRITE )
+ || !m_aTestHelper.cantOpenStream( xSubSubStorage, "BigSubStream1", ElementModes.READ ) )
return false;
- // the second stream can not be open for writing
- if ( !m_aTestHelper.cantOpenStream( xSubSubStorage, "SubStream2", ElementModes.WRITE ) )
+ // the second streams can not be open for writing
+ if ( !m_aTestHelper.cantOpenStream( xSubSubStorage, "SubStream2", ElementModes.WRITE )
+ || !m_aTestHelper.cantOpenStream( xSubSubStorage, "BigSubStream2", ElementModes.WRITE ) )
return false;
@@ -249,9 +273,15 @@ public class Test05 implements StorageTest {
if ( !m_aTestHelper.checkStream( xResSubSubStorage, "SubStream1", "MediaType1", true, pBytes1 ) )
return false;
+ if ( !m_aTestHelper.checkStream( xResSubSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
if ( !m_aTestHelper.checkStream( xResSubSubStorage, "SubStream2", "MediaType2", false, pBytes2 ) )
return false;
+ if ( !m_aTestHelper.checkStream( xResSubSubStorage, "BigSubStream2", "MediaType2", false, pBigBytes ) )
+ return false;
+
// dispose used storages to free resources
if ( !m_aTestHelper.disposeStorage( xResultStorage ) )
return false;
diff --git a/package/qa/storages/Test07.java b/package/qa/storages/Test07.java
index 31907a92bb01..970c6f13ec09 100644
--- a/package/qa/storages/Test07.java
+++ b/package/qa/storages/Test07.java
@@ -48,10 +48,18 @@ public class Test07 implements StorageTest {
return false;
}
+ byte pBigBytes[] = new byte[33000];
+ for ( int nInd = 0; nInd < 33000; nInd++ )
+ pBigBytes[nInd] = (byte)( nInd % 128 );
+
byte pBytes1[] = { 1, 1, 1, 1, 1 };
String sPass1 = "12345";
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "BigSubStream1", "MediaType1", true, pBigBytes, sPass1 ) )
+ return false;
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "SubStream1", "MediaType1", true, pBytes1, sPass1 ) )
return false;
@@ -59,6 +67,10 @@ public class Test07 implements StorageTest {
String sPass2 = "54321";
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "BigSubStream2", "MediaType2", false, pBigBytes, sPass2 ) )
+ return false;
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "SubStream2", "MediaType2", false, pBytes2, sPass2 ) )
return false;
@@ -112,15 +124,27 @@ public class Test07 implements StorageTest {
if ( !m_aTestHelper.checkEncrStream( xResultStorage, "SubStream1", "MediaType1", pBytes1, sPass1 ) )
return false;
+ if ( !m_aTestHelper.checkEncrStream( xResultStorage, "BigSubStream1", "MediaType1", pBigBytes, sPass1 ) )
+ return false;
+
if ( !m_aTestHelper.checkEncrStream( xResultStorage, "SubStream2", "MediaType2", pBytes2, sPass2 ) )
return false;
+ if ( !m_aTestHelper.checkEncrStream( xResultStorage, "BigSubStream2", "MediaType2", pBigBytes, sPass2 ) )
+ return false;
+
if ( !m_aTestHelper.checkEncrStream( x2CopyStorage, "SubStream1", "MediaType1", pBytes1, sPass1 ) )
return false;
+ if ( !m_aTestHelper.checkEncrStream( x2CopyStorage, "BigSubStream1", "MediaType1", pBigBytes, sPass1 ) )
+ return false;
+
if ( !m_aTestHelper.checkEncrStream( x2CopyStorage, "SubStream2", "MediaType2", pBytes2, sPass2 ) )
return false;
+ if ( !m_aTestHelper.checkEncrStream( x2CopyStorage, "BigSubStream2", "MediaType2", pBigBytes, sPass2 ) )
+ return false;
+
// dispose used storages to free resources
if ( !m_aTestHelper.disposeStorage( xResultStorage ) )
return false;
diff --git a/package/qa/storages/Test08.java b/package/qa/storages/Test08.java
index e476397c8cd5..5e024db588c8 100644
--- a/package/qa/storages/Test08.java
+++ b/package/qa/storages/Test08.java
@@ -74,17 +74,25 @@ public class Test08 implements StorageTest {
return false;
}
+ byte pBigBytes[] = new byte[33000];
+ for ( int nInd = 0; nInd < 33000; nInd++ )
+ pBigBytes[nInd] = (byte)( nInd % 128 );
+
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
// the stream will be encrypted with common password
byte pBytes1[] = { 1, 1, 1, 1, 1 };
if ( !m_aTestHelper.WBToSubstrOfEncr( xTempSubStorage, "SubStream1", "MediaType1", true, pBytes1, true ) )
return false;
+ if ( !m_aTestHelper.WBToSubstrOfEncr( xTempSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes, true ) )
+ return false;
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
// the stream will not be encrypted
byte pBytes2[] = { 2, 2, 2, 2, 2 };
if ( !m_aTestHelper.WBToSubstrOfEncr( xTempSubStorage, "SubStream2", "MediaType2", false, pBytes2, false ) )
return false;
+ if ( !m_aTestHelper.WBToSubstrOfEncr( xTempSubStorage, "BigSubStream2", "MediaType2", false, pBigBytes, false ) )
+ return false;
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
// the stream will be compressed with own password
@@ -94,6 +102,8 @@ public class Test08 implements StorageTest {
// the stream will not be encrypted
if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempSubStorage, "SubStream3", "MediaType3", false, pBytes3, sPass2 ) )
return false;
+ if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempSubStorage, "BigSubStream3", "MediaType3", false, pBigBytes, sPass2 ) )
+ return false;
// set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage,
@@ -190,13 +200,19 @@ public class Test08 implements StorageTest {
if ( !m_aTestHelper.checkEncrStream( xResultSubStorage, "SubStream1", "MediaType1", pBytes1, sPass1 ) )
return false;
+ if ( !m_aTestHelper.checkEncrStream( xResultSubStorage, "BigSubStream1", "MediaType1", pBigBytes, sPass1 ) )
+ return false;
if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream2", "MediaType2", false, pBytes2 ) )
return false;
+ if ( !m_aTestHelper.checkStream( xResultSubStorage, "BigSubStream2", "MediaType2", false, pBigBytes ) )
+ return false;
// the common root storage password should allow to open this stream
if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream3", "MediaType3", true, pBytes3 ) )
return false;
+ if ( !m_aTestHelper.checkStream( xResultSubStorage, "BigSubStream3", "MediaType3", true, pBigBytes ) )
+ return false;
// dispose used storages to free resources
if ( !m_aTestHelper.disposeStorage( xResultStorage ) )
diff --git a/package/qa/storages/Test09.java b/package/qa/storages/Test09.java
index a8140369e564..2ce2dfb1e484 100644
--- a/package/qa/storages/Test09.java
+++ b/package/qa/storages/Test09.java
@@ -45,11 +45,16 @@ public class Test09 implements StorageTest {
String sPass1 = "123";
String sPass2 = "321";
byte pBytes[] = { 1, 1, 1, 1, 1 };
+ byte pBigBytes[] = new byte[33000];
+ for ( int nInd = 0; nInd < 33000; nInd++ )
+ pBigBytes[nInd] = (byte)( nInd % 128 );
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
// the stream will not be encrypted
if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "SubStream1", "MediaType1", false, pBytes, sPass1 ) )
return false;
+ if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "BigSubStream1", "MediaType1", false, pBigBytes, sPass1 ) )
+ return false;
// create temporary file
String sTempFileURL = m_aTestHelper.CreateTempFile( m_xMSF );
@@ -84,6 +89,13 @@ public class Test09 implements StorageTest {
else if ( nResult == -1 )
return true; // tested optional feature is not supported
+ // change password of the substream of new storage based on file
+ nResult = m_aTestHelper.ChangeStreamPass( xTempFileStorage, "BigSubStream1", sPass1, sPass2 );
+ if ( nResult == 0 )
+ return false; // test failed
+ else if ( nResult == -1 )
+ return true; // tested optional feature is not supported
+
if ( !m_aTestHelper.commitStorage( xTempFileStorage ) )
return false;
@@ -107,6 +119,8 @@ public class Test09 implements StorageTest {
if ( !m_aTestHelper.checkEncrStream( xResultStorage, "SubStream1", "MediaType1", pBytes, sPass2 ) )
return false;
+ if ( !m_aTestHelper.checkEncrStream( xResultStorage, "BigSubStream1", "MediaType1", pBigBytes, sPass2 ) )
+ return false;
// dispose used storages to free resources
if ( !m_aTestHelper.disposeStorage( xResultStorage ) )
diff --git a/package/qa/storages/Test10.java b/package/qa/storages/Test10.java
index a1114b45c6b8..162daa5abe29 100644
--- a/package/qa/storages/Test10.java
+++ b/package/qa/storages/Test10.java
@@ -43,12 +43,20 @@ public class Test10 implements StorageTest {
return false;
}
+ byte pBigBytes[] = new byte[33000];
+ for ( int nInd = 0; nInd < 33000; nInd++ )
+ pBigBytes[nInd] = (byte)( nInd % 128 );
+
byte pBytes1[] = { 1, 1, 1, 1, 1 };
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
if ( !m_aTestHelper.WriteBytesToSubstream( xTempStorage, "SubStream1", "MediaType1", true, pBytes1 ) )
return false;
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
// open a new substorage
XStorage xTempSubStorage = m_aTestHelper.openSubStorage( xTempStorage,
@@ -66,6 +74,10 @@ public class Test10 implements StorageTest {
if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "SubStream2", "MediaType2", true, pBytes2 ) )
return false;
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "BigSubStream2", "MediaType2", true, pBigBytes ) )
+ return false;
+
// set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage,
"MediaType3",
@@ -120,9 +132,16 @@ public class Test10 implements StorageTest {
if ( !m_aTestHelper.InternalCheckStream( xClonedSubStream, "SubStream1", "MediaType1", true, pBytes1, true ) )
return false;
+ XStream xClonedBigSubStream = m_aTestHelper.cloneSubStream( xTempStorage, "BigSubStream1" );
+ if ( !m_aTestHelper.InternalCheckStream( xClonedBigSubStream, "BigSubStream1", "MediaType1", true, pBigBytes, true ) )
+ return false;
+
if ( !m_aTestHelper.disposeStream( xClonedSubStream, "SubStream1" ) )
return false;
+ if ( !m_aTestHelper.disposeStream( xClonedBigSubStream, "BigSubStream1" ) )
+ return false;
+
// ==============================
// commit substorage and check cloning
// ==============================
@@ -143,6 +162,9 @@ public class Test10 implements StorageTest {
if ( !m_aTestHelper.checkStream( xClonedSubStorage, "SubStream2", "MediaType2", true, pBytes2 ) )
return false;
+ if ( !m_aTestHelper.checkStream( xClonedSubStorage, "BigSubStream2", "MediaType2", true, pBigBytes ) )
+ return false;
+
XStorage xCloneOfRoot = m_aTestHelper.cloneStorage( m_xStorageFactory, xTempStorage );
if ( xCloneOfRoot == null )
{
@@ -195,6 +217,9 @@ public class Test10 implements StorageTest {
if ( !m_aTestHelper.checkStream( xSubStorageOfClone, "SubStream2", "MediaType2", true, pBytes2 ) )
return false;
+ if ( !m_aTestHelper.checkStream( xSubStorageOfClone, "BigSubStream2", "MediaType2", true, pBigBytes ) )
+ return false;
+
return true;
}
catch( Exception e )
diff --git a/package/qa/storages/Test11.java b/package/qa/storages/Test11.java
index a7949f79e7cc..198fa41fe588 100644
--- a/package/qa/storages/Test11.java
+++ b/package/qa/storages/Test11.java
@@ -44,6 +44,10 @@ public class Test11 implements StorageTest {
return false;
}
+ byte pBigBytes[] = new byte[33000];
+ for ( int nInd = 0; nInd < 33000; nInd++ )
+ pBigBytes[nInd] = (byte)( nInd % 128 );
+
String sPass1 = "111111111";
byte pBytes1[] = { 1, 1, 1, 1, 1 };
@@ -51,6 +55,10 @@ public class Test11 implements StorageTest {
if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "SubStream1", "MediaType1", true, pBytes1, sPass1 ) )
return false;
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "BigSubStream1", "MediaType1", true, pBigBytes, sPass1 ) )
+ return false;
+
// open a new substorage
XStorage xTempSubStorage = m_aTestHelper.openSubStorage( xTempStorage,
"SubStorage1",
@@ -68,6 +76,10 @@ public class Test11 implements StorageTest {
if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempSubStorage, "SubStream2", "MediaType2", true, pBytes2, sPass2 ) )
return false;
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempSubStorage, "BigSubStream2", "MediaType2", true, pBigBytes, sPass2 ) )
+ return false;
+
// set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage,
"MediaType3",
@@ -122,9 +134,16 @@ public class Test11 implements StorageTest {
if ( !m_aTestHelper.InternalCheckStream( xClonedSubStream, "SubStream1", "MediaType1", true, pBytes1, true ) )
return false;
+ XStream xClonedBigSubStream = m_aTestHelper.cloneEncrSubStream( xTempStorage, "BigSubStream1", sPass1 );
+ if ( !m_aTestHelper.InternalCheckStream( xClonedBigSubStream, "BigSubStream1", "MediaType1", true, pBigBytes, true ) )
+ return false;
+
if ( !m_aTestHelper.disposeStream( xClonedSubStream, "SubStream1" ) )
return false;
+ if ( !m_aTestHelper.disposeStream( xClonedBigSubStream, "BigSubStream1" ) )
+ return false;
+
// ==============================
// commit substorage and check cloning
// ==============================
@@ -145,6 +164,9 @@ public class Test11 implements StorageTest {
if ( !m_aTestHelper.checkEncrStream( xClonedSubStorage, "SubStream2", "MediaType2", pBytes2, sPass2 ) )
return false;
+ if ( !m_aTestHelper.checkEncrStream( xClonedSubStorage, "BigSubStream2", "MediaType2", pBigBytes, sPass2 ) )
+ return false;
+
// ==============================
// commit the root storage and check cloning
// ==============================
@@ -165,6 +187,9 @@ public class Test11 implements StorageTest {
if ( !m_aTestHelper.checkEncrStream( xCloneOfRoot, "SubStream1", "MediaType1", pBytes1, sPass1 ) )
return false;
+ if ( !m_aTestHelper.checkEncrStream( xCloneOfRoot, "BigSubStream1", "MediaType1", pBigBytes, sPass1 ) )
+ return false;
+
XStorage xSubStorageOfClone = xCloneOfRoot.openStorageElement( "SubStorage1", ElementModes.READ );
if ( xSubStorageOfClone == null )
{
@@ -178,6 +203,9 @@ public class Test11 implements StorageTest {
if ( !m_aTestHelper.checkEncrStream( xSubStorageOfClone, "SubStream2", "MediaType2", pBytes2, sPass2 ) )
return false;
+ if ( !m_aTestHelper.checkEncrStream( xSubStorageOfClone, "BigSubStream2", "MediaType2", pBigBytes, sPass2 ) )
+ return false;
+
return true;
}
catch( Exception e )
diff --git a/package/qa/storages/Test12.java b/package/qa/storages/Test12.java
index 89d88819b79e..05928cf76b0d 100644
--- a/package/qa/storages/Test12.java
+++ b/package/qa/storages/Test12.java
@@ -60,12 +60,20 @@ public class Test12 implements StorageTest {
return false;
}
+ byte pBigBytes[] = new byte[33000];
+ for ( int nInd = 0; nInd < 33000; nInd++ )
+ pBigBytes[nInd] = (byte)( nInd % 128 );
+
byte pBytes1[] = { 1, 1, 1, 1, 1 };
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "SubStream1", "MediaType1", true, pBytes1 ) )
return false;
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
// set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage,
"MediaType2",
@@ -96,7 +104,7 @@ public class Test12 implements StorageTest {
// check substorage
// ================================================
- if ( !checkSubStorages( xTempStorage, pBytes1 ) )
+ if ( !checkSubStorages( xTempStorage, pBytes1, pBigBytes ) )
return false;
// dispose used storage to free resources
@@ -118,7 +126,7 @@ public class Test12 implements StorageTest {
if ( !m_aTestHelper.checkStorageProperties( xResWriteStorage, "MediaType2", true, ElementModes.WRITE ) )
return false;
- if( !checkSubStorages( xResWriteStorage, pBytes1 ) )
+ if( !checkSubStorages( xResWriteStorage, pBytes1, pBigBytes ) )
return false;
// try to open for writing after opening for reading
@@ -137,6 +145,9 @@ public class Test12 implements StorageTest {
if ( !m_aTestHelper.checkStream( xResWSubStorage, "SubStream1", "MediaType1", true, pBytes1 ) )
return false;
+ if ( !m_aTestHelper.checkStream( xResWSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
// dispose used storage to free resources
if ( !m_aTestHelper.disposeStorage( xResWriteStorage ) )
return false;
@@ -171,7 +182,7 @@ public class Test12 implements StorageTest {
if ( !m_aTestHelper.checkStorageProperties( xResultStorage, "MediaType2", true, ElementModes.READ ) )
return false;
- if( !checkSubStorages( xResultStorage, pBytes1 ) )
+ if( !checkSubStorages( xResultStorage, pBytes1, pBigBytes ) )
return false;
return true;
@@ -183,7 +194,7 @@ public class Test12 implements StorageTest {
}
}
- private boolean checkSubStorages( XStorage xStorage, byte[] pBytes1 )
+ private boolean checkSubStorages( XStorage xStorage, byte[] pBytes1, byte[] pBigBytes )
{
XStorage xReadSubStorage1 = m_aTestHelper.openSubStorage( xStorage,
"SubStorage1",
@@ -208,9 +219,15 @@ public class Test12 implements StorageTest {
if ( !m_aTestHelper.checkStream( xReadSubStorage1, "SubStream1", "MediaType1", true, pBytes1 ) )
return false;
+ if ( !m_aTestHelper.checkStream( xReadSubStorage1, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
if ( !m_aTestHelper.checkStream( xReadSubStorage2, "SubStream1", "MediaType1", true, pBytes1 ) )
return false;
+ if ( !m_aTestHelper.checkStream( xReadSubStorage2, "BigSubStream1", "MediaType1", true, pBigBytes ) )
+ return false;
+
if ( !m_aTestHelper.disposeStorage( xReadSubStorage1 ) )
return false;
diff --git a/package/qa/storages/Test13.java b/package/qa/storages/Test13.java
index bec101914259..e8b05264f44d 100644
--- a/package/qa/storages/Test13.java
+++ b/package/qa/storages/Test13.java
@@ -44,6 +44,9 @@ public class Test13 implements StorageTest {
String aSubStream1Path = aStreamPrefix + "SubStream1";
String aSubStream2Path = aStreamPrefix + "SubStream2";
String aSubStream3Path = aStreamPrefix + "SubStream3";
+ String aBigSubStream1Path = aStreamPrefix + "BigSubStream1";
+ String aBigSubStream2Path = aStreamPrefix + "BigSubStream2";
+ String aBigSubStream3Path = aStreamPrefix + "BigSubStream3";
String sTempFileURL = m_aTestHelper.CreateTempFile( m_xMSF );
if ( sTempFileURL == null || sTempFileURL == "" )
@@ -65,12 +68,18 @@ public class Test13 implements StorageTest {
return false;
}
+ byte pBigBytes[] = new byte[33000];
+ for ( int nInd = 0; nInd < 33000; nInd++ )
+ pBigBytes[nInd] = (byte)( nInd % 128 );
+
byte pBytes1[] = { 1, 1, 1, 1, 1 };
// open a new substream hierarchically, set "MediaType" and "Compressed" properties to it, write some bytes
// and commit
if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream1Path, "MediaType1", true, pBytes1, true ) )
return false;
+ if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream1Path, "MediaType1", true, pBigBytes, true ) )
+ return false;
byte pBytes2[] = { 2, 2, 2, 2, 2 };
@@ -78,11 +87,15 @@ public class Test13 implements StorageTest {
// and commit
if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream2Path, "MediaType2", false, pBytes2, true ) )
return false;
+ if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream2Path, "MediaType2", false, pBigBytes, true ) )
+ return false;
// open a new substream hierarchically, set "MediaType" and "Compressed" properties to it, write some bytes
// and don't commit
if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream3Path, "MediaType2", false, pBytes2, false ) )
return false;
+ if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream3Path, "MediaType2", false, pBigBytes, false ) )
+ return false;
// set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempFileStorage,
@@ -120,21 +133,35 @@ public class Test13 implements StorageTest {
if ( !m_aTestHelper.checkStreamH( xTempFileStorage, aSubStream1Path, "MediaType1", true, pBytes1 ) )
return false;
+ if ( !m_aTestHelper.checkStreamH( xTempFileStorage, aBigSubStream1Path, "MediaType1", true, pBigBytes ) )
+ return false;
+
if ( !m_aTestHelper.checkStreamH( xTempFileStorage, aSubStream2Path, "MediaType2", false, pBytes2 ) )
return false;
+ if ( !m_aTestHelper.checkStreamH( xTempFileStorage, aBigSubStream2Path, "MediaType2", false, pBigBytes ) )
+ return false;
+
if ( !m_aTestHelper.cantOpenStreamH( xTempFileStorage, aSubStream3Path, ElementModes.READ ) )
return false;
+ if ( !m_aTestHelper.cantOpenStreamH( xTempFileStorage, aBigSubStream3Path, ElementModes.READ ) )
+ return false;
+
// open existing substream hierarchically, set "MediaType" and "Compressed" properties to it, write some bytes
// and commit
if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream1Path, "MediaType3", true, pBytes2, true ) )
return false;
+ if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream1Path, "MediaType3", true, pBigBytes, true ) )
+ return false;
+
// open existing substream hierarchically, set "MediaType" and "Compressed" properties to it, write some bytes
// and don't commit
if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream2Path, "MediaType3", true, pBytes1, false ) )
return false;
+ if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream2Path, "MediaType3", true, pBigBytes, false ) )
+ return false;
// commit the root storage so the contents must be stored now
if ( !m_aTestHelper.commitStorage( xTempFileStorage ) )
@@ -164,9 +191,11 @@ public class Test13 implements StorageTest {
if ( !m_aTestHelper.checkStreamH( xResultStorage, aSubStream1Path, "MediaType3", true, pBytes2 ) )
return false;
+ if ( !m_aTestHelper.checkStreamH( xResultStorage, aBigSubStream1Path, "MediaType3", true, pBigBytes ) )
+ return false;
// the following stream was not commited last time, so the last change must be lost
- if ( !m_aTestHelper.checkStreamH( xResultStorage, aSubStream2Path, "MediaType2", false, pBytes2 ) )
+ if ( !m_aTestHelper.checkStreamH( xResultStorage, aBigSubStream2Path, "MediaType2", false, pBigBytes ) )
return false;
// dispose used storages to free resources
diff --git a/package/qa/storages/Test18.java b/package/qa/storages/Test18.java
new file mode 100644
index 000000000000..335a230027ce
--- /dev/null
+++ b/package/qa/storages/Test18.java
@@ -0,0 +1,172 @@
+package complex.storages;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+import com.sun.star.embed.*;
+
+import share.LogWriter;
+import complex.storages.TestHelper;
+import complex.storages.StorageTest;
+
+public class Test18 implements StorageTest {
+
+ XMultiServiceFactory m_xMSF;
+ XSingleServiceFactory m_xStorageFactory;
+ TestHelper m_aTestHelper;
+
+ public Test18( XMultiServiceFactory xMSF, XSingleServiceFactory xStorageFactory, LogWriter aLogWriter )
+ {
+ m_xMSF = xMSF;
+ m_xStorageFactory = xStorageFactory;
+ m_aTestHelper = new TestHelper( aLogWriter, "Test18: " );
+ }
+
+ public boolean test()
+ {
+ try
+ {
+ // test the default value of Compressed property
+ String sTempFileURL = m_aTestHelper.CreateTempFile( m_xMSF );
+ if ( sTempFileURL == null || sTempFileURL == "" )
+ {
+ m_aTestHelper.Error( "No valid temporary file was created!" );
+ return false;
+ }
+
+ // create temporary storage based on arbitrary medium
+ // after such a storage is closed it is lost
+ Object oTempStorage = m_xStorageFactory.createInstance();
+ XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ if ( xTempStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create temporary storage representation!" );
+ return false;
+ }
+
+ // open a new substorage
+ XStorage xTempSubStorage = m_aTestHelper.openSubStorage( xTempStorage,
+ "SubStorage1",
+ ElementModes.WRITE );
+ if ( xTempSubStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create substorage!" );
+ return false;
+ }
+
+ byte pBytes1[] = { 1, 1, 1, 1, 1 };
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstreamDefaultCompressed( xTempSubStorage, "SubStream1", "image/jpeg", pBytes1 ) )
+ return false;
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstreamDefaultCompressed( xTempSubStorage, "SubStream2", "image/png", pBytes1 ) )
+ return false;
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstreamDefaultCompressed( xTempSubStorage, "SubStream3", "image/gif", pBytes1 ) )
+ return false;
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstreamDefaultCompressed( xTempSubStorage, "SubStream4", "MediaType1", pBytes1 ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage,
+ "MediaType3",
+ true,
+ ElementModes.WRITE ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempSubStorage,
+ "MediaType4",
+ false,
+ ElementModes.WRITE ) )
+ return false;
+
+ // create temporary storage based on a previously created temporary file
+ Object pArgs[] = new Object[2];
+ pArgs[0] = (Object) sTempFileURL;
+ pArgs[1] = new Integer( ElementModes.WRITE );
+
+ Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
+ if ( xTempFileStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create storage based on temporary file!" );
+ return false;
+ }
+
+ // copy xTempStorage to xTempFileStorage
+ // xTempFileStorage will be automatically commited
+ if ( !m_aTestHelper.copyStorage( xTempStorage, xTempFileStorage ) )
+ return false;
+
+ // dispose used storages to free resources
+ if ( !m_aTestHelper.disposeStorage( xTempStorage ) || !m_aTestHelper.disposeStorage( xTempFileStorage ) )
+ return false;
+
+ // ================================================
+ // now check all the written and copied information
+ // ================================================
+
+ // the temporary file must not be locked any more after storage disposing
+ pArgs[1] = new Integer( ElementModes.WRITE );
+ Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage );
+ if ( xResultStorage == null )
+ {
+ m_aTestHelper.Error( "Can't reopen storage based on temporary file!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkStorageProperties( xResultStorage, "MediaType3", true, ElementModes.WRITE ) )
+ return false;
+
+ // open existing substorage
+ XStorage xResultSubStorage = m_aTestHelper.openSubStorage( xResultStorage,
+ "SubStorage1",
+ ElementModes.READ );
+ if ( xResultSubStorage == null )
+ {
+ m_aTestHelper.Error( "Can't open existing substorage!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkStorageProperties( xResultSubStorage, "MediaType4", false, ElementModes.READ ) )
+ return false;
+
+ if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream1", "image/jpeg", false, pBytes1 ) )
+ return false;
+
+ if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream2", "image/png", false, pBytes1 ) )
+ return false;
+
+ if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream3", "image/gif", false, pBytes1 ) )
+ return false;
+
+ if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream4", "MediaType1", true, pBytes1 ) )
+ return false;
+
+ // dispose used storages to free resources
+ if ( !m_aTestHelper.disposeStorage( xResultStorage ) )
+ return false;
+
+ return true;
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Exception: " + e );
+ return false;
+ }
+ }
+
+}
+
diff --git a/package/qa/storages/TestHelper.java b/package/qa/storages/TestHelper.java
index a6a05603ac1b..dc28786513b1 100644
--- a/package/qa/storages/TestHelper.java
+++ b/package/qa/storages/TestHelper.java
@@ -96,6 +96,99 @@ public class TestHelper {
return true;
}
+ public boolean WriteBytesToSubstreamDefaultCompressed( XStorage xStorage,
+ String sStreamName,
+ String sMediaType,
+ byte[] pBytes )
+ {
+ // open substream element
+ XStream xSubStream = null;
+ try
+ {
+ Object oSubStream = xStorage.openStreamElement( sStreamName, ElementModes.WRITE );
+ xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ if ( xSubStream == null )
+ {
+ Error( "Can't create substream '" + sStreamName + "'!" );
+ return false;
+ }
+ }
+ catch( Exception e )
+ {
+ Error( "Can't create substream '" + sStreamName + "', exception : " + e + "!" );
+ return false;
+ }
+
+ // get output stream of substream
+ XOutputStream xOutput = xSubStream.getOutputStream();
+ if ( xOutput == null )
+ {
+ Error( "Can't get XOutputStream implementation from substream '" + sStreamName + "'!" );
+ return false;
+ }
+
+ // get XTrucate implementation from output stream
+ XTruncate xTruncate = (XTruncate) UnoRuntime.queryInterface( XTruncate.class, xOutput );
+ if ( xTruncate == null )
+ {
+ Error( "Can't get XTruncate implementation from substream '" + sStreamName + "'!" );
+ return false;
+ }
+
+ // write requested byte sequence
+ try
+ {
+ xTruncate.truncate();
+ xOutput.writeBytes( pBytes );
+ }
+ catch( Exception e )
+ {
+ Error( "Can't write to stream '" + sStreamName + "', exception: " + e );
+ return false;
+ }
+
+ // get access to the XPropertySet interface
+ XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xSubStream );
+ if ( xPropSet == null )
+ {
+ Error( "Can't get XPropertySet implementation from substream '" + sStreamName + "'!" );
+ return false;
+ }
+
+ // set properties to the stream
+ // do not set the compressed property
+ try
+ {
+ xPropSet.setPropertyValue( "MediaType", sMediaType );
+ }
+ catch( Exception e )
+ {
+ Error( "Can't set properties to substream '" + sStreamName + "', exception: " + e );
+ return false;
+ }
+
+ // check size property of the stream
+ try
+ {
+ int nSize = AnyConverter.toInt( xPropSet.getPropertyValue( "Size" ) );
+ if ( nSize != pBytes.length )
+ {
+ Error( "The 'Size' property of substream '" + sStreamName + "' contains wrong value!" );
+ return false;
+ }
+ }
+ catch( Exception e )
+ {
+ Error( "Can't get 'Size' property from substream '" + sStreamName + "', exception: " + e );
+ return false;
+ }
+
+ // free the stream resources, garbage collector may remove the object too late
+ if ( !disposeStream( xSubStream, sStreamName ) )
+ return false;
+
+ return true;
+ }
public boolean WriteBytesToSubstream( XStorage xStorage,
String sStreamName,
diff --git a/package/qa/storages/makefile.mk b/package/qa/storages/makefile.mk
index a8a5bbf8219e..81cacb939510 100644
--- a/package/qa/storages/makefile.mk
+++ b/package/qa/storages/makefile.mk
@@ -64,6 +64,7 @@ JAVAFILES =\
Test15.java\
Test16.java\
Test17.java\
+ Test18.java\
RegressionTest_114358.java\
RegressionTest_i29169.java\
RegressionTest_i30400.java\
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index b3b9ec6affa2..079b23d7c17a 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -58,10 +58,42 @@
#include <rtl/digest.h>
#include <rtl/logfile.hxx>
+// since the copying uses 32000 blocks usually, it makes sense to have a smaller size
+#define MAX_STORCACHE_SIZE 30000
+
using namespace ::com::sun::star;
//-----------------------------------------------
+uno::Sequence< sal_Int8 > MakeKeyFromPass( ::rtl::OUString aPass, sal_Bool bUseUTF )
+{
+ // MS_1252 encoding was used for SO60 document format password encoding,
+ // this encoding supports only a minor subset of nonascii characters,
+ // but for compatibility reasons it has to be used for old document formats
+
+ ::rtl::OString aByteStrPass;
+ if ( bUseUTF )
+ aByteStrPass = ::rtl::OUStringToOString( aPass, RTL_TEXTENCODING_UTF8 );
+ else
+ aByteStrPass = ::rtl::OUStringToOString( aPass, RTL_TEXTENCODING_MS_1252 );
+
+ sal_uInt8 pBuffer[RTL_DIGEST_LENGTH_SHA1];
+ rtlDigestError nError = rtl_digest_SHA1( aByteStrPass.getStr(),
+ aByteStrPass.getLength(),
+ pBuffer,
+ RTL_DIGEST_LENGTH_SHA1 );
+
+ if ( nError != rtl_Digest_E_None )
+ throw uno::RuntimeException();
+
+ return uno::Sequence< sal_Int8 >( (sal_Int8*)pBuffer, RTL_DIGEST_LENGTH_SHA1 );
+
+}
+
+// ================================================================
+namespace
+{
+//-----------------------------------------------
void SetEncryptionKeyProperty_Impl( const uno::Reference< beans::XPropertySet >& xPropertySet,
const uno::Sequence< sal_Int8 >& aKey )
{
@@ -142,7 +174,6 @@ sal_Bool KillFile( const ::rtl::OUString& aURL, const uno::Reference< lang::XMul
const sal_Int32 n_ConstBufferSize = 32000;
//-----------------------------------------------
-
::rtl::OUString GetNewTempFileURL( const uno::Reference< lang::XMultiServiceFactory > xFactory )
{
::rtl::OUString aTempURL;
@@ -169,31 +200,16 @@ const sal_Int32 n_ConstBufferSize = 32000;
return aTempURL;
}
-uno::Sequence< sal_Int8 > MakeKeyFromPass( ::rtl::OUString aPass, sal_Bool bUseUTF )
+//-----------------------------------------------
+uno::Reference< io::XStream > CreateMemoryStream( const uno::Reference< lang::XMultiServiceFactory >& xFactory )
{
- // MS_1252 encoding was used for SO60 document format password encoding,
- // this encoding supports only a minor subset of nonascii characters,
- // but for compatibility reasons it has to be used for old document formats
-
- ::rtl::OString aByteStrPass;
- if ( bUseUTF )
- aByteStrPass = ::rtl::OUStringToOString( aPass, RTL_TEXTENCODING_UTF8 );
- else
- aByteStrPass = ::rtl::OUStringToOString( aPass, RTL_TEXTENCODING_MS_1252 );
-
- sal_uInt8 pBuffer[RTL_DIGEST_LENGTH_SHA1];
- rtlDigestError nError = rtl_digest_SHA1( aByteStrPass.getStr(),
- aByteStrPass.getLength(),
- pBuffer,
- RTL_DIGEST_LENGTH_SHA1 );
-
- if ( nError != rtl_Digest_E_None )
+ if ( !xFactory.is() )
throw uno::RuntimeException();
- return uno::Sequence< sal_Int8 >( (sal_Int8*)pBuffer, RTL_DIGEST_LENGTH_SHA1 );
-
+ return uno::Reference< io::XStream >( xFactory->createInstance ( ::rtl::OUString::createFromAscii( "com.sun.star.comp.MemoryStream" ) ), uno::UNO_QUERY_THROW );
}
+} // anonymous namespace
// ================================================================
//-----------------------------------------------
@@ -203,6 +219,7 @@ OWriteStream_Impl::OWriteStream_Impl( OStorage_Impl* pParent,
const uno::Reference< lang::XMultiServiceFactory >& xFactory,
sal_Bool bForceEncrypted,
sal_Int16 nStorageType,
+ sal_Bool bDefaultCompress,
const uno::Reference< io::XInputStream >& xRelInfoStream )
: m_pAntiImpl( NULL )
, m_bHasDataToFlush( sal_False )
@@ -213,6 +230,7 @@ OWriteStream_Impl::OWriteStream_Impl( OStorage_Impl* pParent,
, m_bForceEncrypted( bForceEncrypted )
, m_bUseCommonPass( !bForceEncrypted && nStorageType == PACKAGE_STORAGE )
, m_bHasCachedPassword( sal_False )
+, m_bCompressedSetExplicit( !bDefaultCompress )
, m_xPackage( xPackage )
, m_bHasInsertedStreamOptimization( sal_False )
, m_nStorageType( nStorageType )
@@ -238,6 +256,36 @@ OWriteStream_Impl::~OWriteStream_Impl()
KillFile( m_aTempURL, GetServiceFactory() );
m_aTempURL = ::rtl::OUString();
}
+
+ CleanCacheStream();
+}
+
+//-----------------------------------------------
+void OWriteStream_Impl::CleanCacheStream()
+{
+ if ( m_xCacheStream.is() )
+ {
+ try
+ {
+ uno::Reference< io::XInputStream > xInputCache = m_xCacheStream->getInputStream();
+ if ( xInputCache.is() )
+ xInputCache->closeInput();
+ }
+ catch( uno::Exception& )
+ {}
+
+ try
+ {
+ uno::Reference< io::XOutputStream > xOutputCache = m_xCacheStream->getOutputStream();
+ if ( xOutputCache.is() )
+ xOutputCache->closeOutput();
+ }
+ catch( uno::Exception& )
+ {}
+
+ m_xCacheStream = uno::Reference< io::XStream >();
+ m_xCacheSeek = uno::Reference< io::XSeekable >();
+ }
}
//-----------------------------------------------
@@ -269,7 +317,7 @@ sal_Bool OWriteStream_Impl::IsEncrypted()
if ( m_bForceEncrypted || m_bHasCachedPassword )
return sal_True;
- if ( m_aTempURL.getLength() )
+ if ( m_aTempURL.getLength() || m_xCacheStream.is() )
return sal_False;
GetStreamProperties();
@@ -330,7 +378,7 @@ void OWriteStream_Impl::SetDecrypted()
GetStreamProperties();
// let the stream be modified
- GetFilledTempFile();
+ FillTempGetFileName();
m_bHasDataToFlush = sal_True;
// remove encryption
@@ -355,7 +403,7 @@ void OWriteStream_Impl::SetEncryptedWithPass( const ::rtl::OUString& aPass )
GetStreamProperties();
// let the stream be modified
- GetFilledTempFile();
+ FillTempGetFileName();
m_bHasDataToFlush = sal_True;
// introduce encryption info
@@ -412,14 +460,14 @@ uno::Reference< lang::XMultiServiceFactory > OWriteStream_Impl::GetServiceFactor
}
//-----------------------------------------------
-::rtl::OUString OWriteStream_Impl::GetFilledTempFile()
+::rtl::OUString OWriteStream_Impl::GetFilledTempFileIfNo( const uno::Reference< io::XInputStream >& xStream )
{
if ( !m_aTempURL.getLength() )
{
- m_aTempURL = GetNewTempFileURL( GetServiceFactory() );
+ ::rtl::OUString aTempURL = GetNewTempFileURL( GetServiceFactory() );
try {
- if ( m_aTempURL )
+ if ( aTempURL && xStream.is() )
{
uno::Reference < ucb::XSimpleFileAccess > xTempAccess(
GetServiceFactory()->createInstance (
@@ -430,64 +478,155 @@ uno::Reference< lang::XMultiServiceFactory > OWriteStream_Impl::GetServiceFactor
throw uno::RuntimeException(); // TODO:
- // in case of new inserted package stream it is possible that input stream still was not set
- uno::Reference< io::XInputStream > xOrigStream = m_xPackageStream->getDataStream();
- if ( xOrigStream.is() )
+ uno::Reference< io::XOutputStream > xTempOutStream = xTempAccess->openFileWrite( aTempURL );
+ if ( xTempOutStream.is() )
{
- uno::Reference< io::XOutputStream > xTempOutStream = xTempAccess->openFileWrite( m_aTempURL );
- if ( xTempOutStream.is() )
- {
- // copy stream contents to the file
- ::comphelper::OStorageHelper::CopyInputToOutput( xOrigStream, xTempOutStream );
- xTempOutStream->closeOutput();
- xTempOutStream = uno::Reference< io::XOutputStream >();
- }
- else
- throw io::IOException(); // TODO:
+ // the current position of the original stream should be still OK, copy further
+ ::comphelper::OStorageHelper::CopyInputToOutput( xStream, xTempOutStream );
+ xTempOutStream->closeOutput();
+ xTempOutStream = uno::Reference< io::XOutputStream >();
}
+ else
+ throw io::IOException(); // TODO:
}
}
catch( packages::WrongPasswordException& )
{
- KillFile( m_aTempURL, GetServiceFactory() );
- m_aTempURL = ::rtl::OUString();
-
+ KillFile( aTempURL, GetServiceFactory() );
throw;
}
catch( uno::Exception& )
{
- KillFile( m_aTempURL, GetServiceFactory() );
- m_aTempURL = ::rtl::OUString();
+ KillFile( aTempURL, GetServiceFactory() );
}
+
+ if ( aTempURL.getLength() )
+ CleanCacheStream();
+
+ m_aTempURL = aTempURL;
}
return m_aTempURL;
}
//-----------------------------------------------
-uno::Reference< io::XStream > OWriteStream_Impl::GetTempFileAsStream()
+::rtl::OUString OWriteStream_Impl::FillTempGetFileName()
{
- uno::Reference< io::XStream > xTempStream;
+ // should try to create cache first, if the amount of contents is too big, the temp file should be taken
+ if ( !m_xCacheStream.is() && !m_aTempURL.getLength() )
+ {
+ uno::Reference< io::XInputStream > xOrigStream = m_xPackageStream->getDataStream();
+ if ( !xOrigStream.is() )
+ {
+ // in case of new inserted package stream it is possible that input stream still was not set
+ uno::Reference< io::XStream > xCacheStream = CreateMemoryStream( GetServiceFactory() );
+ OSL_ENSURE( xCacheStream.is(), "If the stream can not be created an exception must be thrown!\n" );
+ m_xCacheSeek.set( xCacheStream, uno::UNO_QUERY_THROW );
+ m_xCacheStream = xCacheStream;
+ }
+ else
+ {
+ sal_Int32 nRead = 0;
+ uno::Sequence< sal_Int8 > aData( MAX_STORCACHE_SIZE + 1 );
+ nRead = xOrigStream->readBytes( aData, MAX_STORCACHE_SIZE + 1 );
+ if ( aData.getLength() > nRead )
+ aData.realloc( nRead );
- if ( !m_aTempURL.getLength() )
- m_aTempURL = GetFilledTempFile();
+ if ( nRead && nRead <= MAX_STORCACHE_SIZE )
+ {
+ uno::Reference< io::XStream > xCacheStream = CreateMemoryStream( GetServiceFactory() );
+ OSL_ENSURE( xCacheStream.is(), "If the stream can not be created an exception must be thrown!\n" );
+
+ uno::Reference< io::XOutputStream > xOutStream( xCacheStream->getOutputStream(), uno::UNO_SET_THROW );
+ xOutStream->writeBytes( aData );
+ m_xCacheSeek.set( xCacheStream, uno::UNO_QUERY_THROW );
+ m_xCacheStream = xCacheStream;
+ m_xCacheSeek->seek( 0 );
+ }
+ else if ( nRead && !m_aTempURL.getLength() )
+ {
+ m_aTempURL = GetNewTempFileURL( GetServiceFactory() );
- uno::Reference < ucb::XSimpleFileAccess > xTempAccess(
- GetServiceFactory()->createInstance (
- ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ),
- uno::UNO_QUERY );
+ try {
+ if ( m_aTempURL.getLength() )
+ {
+ uno::Reference < ucb::XSimpleFileAccess > xTempAccess(
+ GetServiceFactory()->createInstance (
+ ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ),
+ uno::UNO_QUERY );
- if ( !xTempAccess.is() )
- throw uno::RuntimeException(); // TODO:
+ if ( !xTempAccess.is() )
+ throw uno::RuntimeException(); // TODO:
- try
- {
- xTempStream = xTempAccess->openFileReadWrite( m_aTempURL );
+
+ uno::Reference< io::XOutputStream > xTempOutStream = xTempAccess->openFileWrite( m_aTempURL );
+ if ( xTempOutStream.is() )
+ {
+ // copy stream contents to the file
+ xTempOutStream->writeBytes( aData );
+
+ // the current position of the original stream should be still OK, copy further
+ ::comphelper::OStorageHelper::CopyInputToOutput( xOrigStream, xTempOutStream );
+ xTempOutStream->closeOutput();
+ xTempOutStream = uno::Reference< io::XOutputStream >();
+ }
+ else
+ throw io::IOException(); // TODO:
+ }
+ }
+ catch( packages::WrongPasswordException& )
+ {
+ KillFile( m_aTempURL, GetServiceFactory() );
+ m_aTempURL = ::rtl::OUString();
+
+ throw;
+ }
+ catch( uno::Exception& )
+ {
+ KillFile( m_aTempURL, GetServiceFactory() );
+ m_aTempURL = ::rtl::OUString();
+ }
+ }
+ }
}
- catch( uno::Exception& )
+
+ return m_aTempURL;
+}
+
+//-----------------------------------------------
+uno::Reference< io::XStream > OWriteStream_Impl::GetTempFileAsStream()
+{
+ uno::Reference< io::XStream > xTempStream;
+
+ if ( !m_xCacheStream.is() )
{
+ if ( !m_aTempURL.getLength() )
+ m_aTempURL = FillTempGetFileName();
+
+ if ( m_aTempURL.getLength() )
+ {
+ // the temporary file is not used if the cache is used
+ uno::Reference < ucb::XSimpleFileAccess > xTempAccess(
+ GetServiceFactory()->createInstance (
+ ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ),
+ uno::UNO_QUERY );
+
+ if ( !xTempAccess.is() )
+ throw uno::RuntimeException(); // TODO:
+
+ try
+ {
+ xTempStream = xTempAccess->openFileReadWrite( m_aTempURL );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
}
+ if ( m_xCacheStream.is() )
+ xTempStream = m_xCacheStream;
+
// the method must always return a stream
// in case the stream can not be open
// an exception should be thrown
@@ -502,25 +641,35 @@ uno::Reference< io::XInputStream > OWriteStream_Impl::GetTempFileAsInputStream()
{
uno::Reference< io::XInputStream > xInputStream;
- if ( !m_aTempURL.getLength() )
- m_aTempURL = GetFilledTempFile();
+ if ( !m_xCacheStream.is() )
+ {
+ if ( !m_aTempURL.getLength() )
+ m_aTempURL = FillTempGetFileName();
- uno::Reference < ucb::XSimpleFileAccess > xTempAccess(
- GetServiceFactory()->createInstance (
- ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ),
- uno::UNO_QUERY );
+ if ( m_aTempURL.getLength() )
+ {
+ // the temporary file is not used if the cache is used
+ uno::Reference < ucb::XSimpleFileAccess > xTempAccess(
+ GetServiceFactory()->createInstance (
+ ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ),
+ uno::UNO_QUERY );
- if ( !xTempAccess.is() )
- throw uno::RuntimeException(); // TODO:
+ if ( !xTempAccess.is() )
+ throw uno::RuntimeException(); // TODO:
- try
- {
- xInputStream = xTempAccess->openFileRead( m_aTempURL );
- }
- catch( uno::Exception& )
- {
+ try
+ {
+ xInputStream = xTempAccess->openFileRead( m_aTempURL );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
}
+ if ( m_xCacheStream.is() )
+ xInputStream = m_xCacheStream->getInputStream();
+
// the method must always return a stream
// in case the stream can not be open
// an exception should be thrown
@@ -534,29 +683,54 @@ uno::Reference< io::XInputStream > OWriteStream_Impl::GetTempFileAsInputStream()
void OWriteStream_Impl::CopyTempFileToOutput( uno::Reference< io::XOutputStream > xOutStream )
{
OSL_ENSURE( xOutStream.is(), "The stream must be specified!\n" );
- OSL_ENSURE( m_aTempURL.getLength(), "The temporary must exist!\n" );
-
- uno::Reference < ucb::XSimpleFileAccess > xTempAccess(
- GetServiceFactory()->createInstance (
- ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ),
- uno::UNO_QUERY );
-
- if ( !xTempAccess.is() )
- throw uno::RuntimeException(); // TODO:
+ OSL_ENSURE( m_aTempURL.getLength() || m_xCacheStream.is(), "The temporary must exist!\n" );
uno::Reference< io::XInputStream > xTempInStream;
- try
+
+ if ( m_xCacheStream.is() )
{
- xTempInStream = xTempAccess->openFileRead( m_aTempURL );
+ if ( !m_xCacheSeek.is() )
+ throw uno::RuntimeException();
+ sal_Int64 nPos = m_xCacheSeek->getPosition();
+
+ try
+ {
+ m_xCacheSeek->seek( 0 );
+ uno::Reference< io::XInputStream > xTempInp = m_xCacheStream->getInputStream();
+ if ( xTempInp.is() )
+ ::comphelper::OStorageHelper::CopyInputToOutput( xTempInStream, xOutStream );
+ }
+ catch( uno::Exception& )
+ {
+ m_xCacheSeek->seek( nPos );
+ throw io::IOException(); //TODO:
+ }
+
+ m_xCacheSeek->seek( nPos );
}
- catch( uno::Exception& )
+ else if ( m_aTempURL.getLength() )
{
- }
+ uno::Reference < ucb::XSimpleFileAccess > xTempAccess(
+ GetServiceFactory()->createInstance (
+ ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ),
+ uno::UNO_QUERY );
- if ( !xTempInStream.is() )
- throw io::IOException(); //TODO:
+ if ( !xTempAccess.is() )
+ throw uno::RuntimeException(); // TODO:
+
+ try
+ {
+ xTempInStream = xTempAccess->openFileRead( m_aTempURL );
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ if ( !xTempInStream.is() )
+ throw io::IOException(); //TODO:
- ::comphelper::OStorageHelper::CopyInputToOutput( xTempInStream, xOutStream );
+ ::comphelper::OStorageHelper::CopyInputToOutput( xTempInStream, xOutStream );
+ }
}
// =================================================================================================
@@ -576,7 +750,7 @@ void OWriteStream_Impl::InsertStreamDirectly( const uno::Reference< io::XInputSt
if ( m_bHasDataToFlush )
throw io::IOException();
- OSL_ENSURE( !m_aTempURL.getLength(), "The temporary must not exist!\n" );
+ OSL_ENSURE( !m_aTempURL.getLength() && !m_xCacheStream.is(), "The temporary must not exist!\n" );
// use new file as current persistent representation
// the new file will be removed after it's stream is closed
@@ -624,7 +798,10 @@ void OWriteStream_Impl::InsertStreamDirectly( const uno::Reference< io::XInputSt
}
if ( bCompressedIsSet )
- xPropertySet->setPropertyValue( aComprPropName, uno::makeAny( (sal_Bool)bCompressed ) );
+ {
+ xPropertySet->setPropertyValue( aComprPropName, uno::makeAny( (sal_Bool)bCompressed ) );
+ m_bCompressedSetExplicit = sal_True;
+ }
if ( m_bUseCommonPass )
{
@@ -655,34 +832,57 @@ void OWriteStream_Impl::Commit()
return;
uno::Reference< packages::XDataSinkEncrSupport > xNewPackageStream;
+ uno::Sequence< uno::Any > aSeq( 1 );
+ aSeq[0] <<= sal_False;
- OSL_ENSURE( m_bHasInsertedStreamOptimization || m_aTempURL.getLength(), "The temporary must exist!\n" );
- if ( m_aTempURL.getLength() )
+ if ( m_xCacheStream.is() )
{
- uno::Reference < io::XOutputStream > xTempOut(
- GetServiceFactory()->createInstance (
- ::rtl::OUString::createFromAscii( "com.sun.star.io.TempFile" ) ),
- uno::UNO_QUERY );
- uno::Reference < io::XInputStream > xTempIn( xTempOut, uno::UNO_QUERY );
+ uno::Reference< io::XInputStream > xInStream( m_xCacheStream->getInputStream(), uno::UNO_SET_THROW );
- if ( !xTempOut.is() || !xTempIn.is() )
- throw io::IOException();
+ xNewPackageStream = uno::Reference< packages::XDataSinkEncrSupport >(
+ m_xPackage->createInstanceWithArguments( aSeq ),
+ uno::UNO_QUERY_THROW );
+
+ xNewPackageStream->setDataStream( xInStream );
+
+ m_xCacheStream = uno::Reference< io::XStream >();
+ m_xCacheSeek = uno::Reference< io::XSeekable >();
+
+ if ( m_pAntiImpl )
+ m_pAntiImpl->DeInit();
+ }
+ else if ( m_aTempURL.getLength() )
+ {
+ uno::Reference < ucb::XSimpleFileAccess > xTempAccess(
+ GetServiceFactory()->createInstance (
+ ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ),
+ uno::UNO_QUERY );
+
+ if ( !xTempAccess.is() )
+ throw uno::RuntimeException(); // TODO:
+
+ uno::Reference< io::XInputStream > xInStream;
+ try
+ {
+ xInStream = xTempAccess->openFileRead( m_aTempURL );
+ }
+ catch( uno::Exception& )
+ {
+ }
- // Copy temporary file to a new one
- CopyTempFileToOutput( xTempOut );
- xTempOut->closeOutput();
+ if ( !xInStream.is() )
+ throw io::IOException();
- uno::Sequence< uno::Any > aSeq( 1 );
- aSeq[0] <<= sal_False;
xNewPackageStream = uno::Reference< packages::XDataSinkEncrSupport >(
m_xPackage->createInstanceWithArguments( aSeq ),
- uno::UNO_QUERY );
- if ( !xNewPackageStream.is() )
- throw uno::RuntimeException();
+ uno::UNO_QUERY_THROW );
+
+ // TODO/NEW: Let the temporary file be removed after commit
+ xNewPackageStream->setDataStream( xInStream );
+ m_aTempURL = ::rtl::OUString();
- // use new file as current persistent representation
- // the new file will be removed after it's stream is closed
- xNewPackageStream->setDataStream( xTempIn );
+ if ( m_pAntiImpl )
+ m_pAntiImpl->DeInit();
}
else // if ( m_bHasInsertedStreamOptimization )
{
@@ -746,7 +946,13 @@ void OWriteStream_Impl::Revert()
if ( !m_bHasDataToFlush )
return; // nothing to do
- OSL_ENSURE( m_aTempURL.getLength(), "The temporary must exist!\n" );
+ OSL_ENSURE( m_aTempURL.getLength() || m_xCacheStream.is(), "The temporary must exist!\n" );
+
+ if ( m_xCacheStream.is() )
+ {
+ m_xCacheStream = uno::Reference< io::XStream >();
+ m_xCacheSeek = uno::Reference< io::XSeekable >();
+ }
if ( m_aTempURL.getLength() )
{
@@ -1071,7 +1277,7 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream( sal_Int32 nStreamMod
// the stream must be resaved with new password encryption
if ( nStreamMode & embed::ElementModes::WRITE )
{
- GetFilledTempFile();
+ FillTempGetFileName();
m_bHasDataToFlush = sal_True;
// TODO/LATER: should the notification be done?
@@ -1149,7 +1355,7 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream_Impl( sal_Int32 nStre
if ( ( nStreamMode & embed::ElementModes::READWRITE ) == embed::ElementModes::READ )
{
uno::Reference< io::XInputStream > xInStream;
- if ( m_aTempURL.getLength() )
+ if ( m_xCacheStream.is() || m_aTempURL.getLength() )
xInStream = GetTempFileAsInputStream(); //TODO:
else
xInStream = m_xPackageStream->getDataStream();
@@ -1170,7 +1376,7 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream_Impl( sal_Int32 nStre
}
else if ( ( nStreamMode & embed::ElementModes::READWRITE ) == embed::ElementModes::SEEKABLEREAD )
{
- if ( !m_aTempURL.getLength() && !( m_xPackageStream->getDataStream().is() ) )
+ if ( !m_xCacheStream.is() && !m_aTempURL.getLength() && !( m_xPackageStream->getDataStream().is() ) )
{
// The stream does not exist in the storage
throw io::IOException();
@@ -1202,10 +1408,12 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream_Impl( sal_Int32 nStre
if ( ( nStreamMode & embed::ElementModes::TRUNCATE ) == embed::ElementModes::TRUNCATE )
{
if ( m_aTempURL.getLength() )
+ {
KillFile( m_aTempURL, GetServiceFactory() );
-
- // open new empty temp file
- m_aTempURL = GetNewTempFileURL( GetServiceFactory() );
+ m_aTempURL = ::rtl::OUString();
+ }
+ if ( m_xCacheStream.is() )
+ CleanCacheStream();
m_bHasDataToFlush = sal_True;
@@ -1213,11 +1421,13 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream_Impl( sal_Int32 nStre
if ( m_pParent )
m_pParent->m_bIsModified = sal_True;
- xStream = GetTempFileAsStream();
+ xStream = CreateMemoryStream( GetServiceFactory() );
+ m_xCacheSeek.set( xStream, uno::UNO_QUERY_THROW );
+ m_xCacheStream = xStream;
}
else if ( !m_bHasInsertedStreamOptimization )
{
- if ( !m_aTempURL.getLength() && !( m_xPackageStream->getDataStream().is() ) )
+ if ( !m_aTempURL.getLength() && !m_xCacheStream.is() && !( m_xPackageStream->getDataStream().is() ) )
{
// The stream does not exist in the storage
m_bHasDataToFlush = sal_True;
@@ -1572,6 +1782,7 @@ OWriteStream::OWriteStream( OWriteStream_Impl* pImpl, sal_Bool bTransacted )
: m_pImpl( pImpl )
, m_bInStreamDisconnected( sal_False )
, m_bInitOnDemand( sal_True )
+, m_nInitPosition( 0 )
, m_bTransacted( bTransacted )
{
OSL_ENSURE( pImpl, "No base implementation!\n" );
@@ -1588,6 +1799,7 @@ OWriteStream::OWriteStream( OWriteStream_Impl* pImpl, uno::Reference< io::XStrea
: m_pImpl( pImpl )
, m_bInStreamDisconnected( sal_False )
, m_bInitOnDemand( sal_False )
+, m_nInitPosition( 0 )
, m_bTransacted( bTransacted )
{
OSL_ENSURE( pImpl && xStream.is(), "No base implementation!\n" );
@@ -1631,6 +1843,21 @@ OWriteStream::~OWriteStream()
}
//-----------------------------------------------
+void OWriteStream::DeInit()
+{
+ if ( !m_pImpl )
+ return; // do nothing
+
+ if ( m_xSeekable.is() )
+ m_nInitPosition = m_xSeekable->getPosition();
+
+ m_xInStream = uno::Reference< io::XInputStream >();
+ m_xOutStream = uno::Reference< io::XOutputStream >();
+ m_xSeekable = uno::Reference< io::XSeekable >();
+ m_bInitOnDemand = sal_True;
+}
+
+//-----------------------------------------------
void OWriteStream::CheckInitOnDemand()
{
if ( !m_pImpl )
@@ -1642,11 +1869,12 @@ void OWriteStream::CheckInitOnDemand()
uno::Reference< io::XStream > xStream = m_pImpl->GetTempFileAsStream();
if ( xStream.is() )
{
- m_xInStream = xStream->getInputStream();
- m_xOutStream = xStream->getOutputStream();
- m_xSeekable = uno::Reference< io::XSeekable >( xStream, uno::UNO_QUERY );
- OSL_ENSURE( m_xInStream.is() && m_xOutStream.is() && m_xSeekable.is(), "Stream implementation is incomplete!\n" );
+ m_xInStream.set( xStream->getInputStream(), uno::UNO_SET_THROW );
+ m_xOutStream.set( xStream->getOutputStream(), uno::UNO_SET_THROW );
+ m_xSeekable.set( xStream, uno::UNO_QUERY_THROW );
+ m_xSeekable->seek( m_nInitPosition );
+ m_nInitPosition = 0;
m_bInitOnDemand = sal_False;
}
}
@@ -2072,11 +2300,54 @@ void SAL_CALL OWriteStream::writeBytes( const uno::Sequence< sal_Int8 >& aData )
{
::osl::ResettableMutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
- CheckInitOnDemand();
+ // the write method makes initialization itself, since it depends from the aData length
+ // NO CheckInitOnDemand()!
if ( !m_pImpl )
throw lang::DisposedException();
+ if ( !m_bInitOnDemand )
+ {
+ if ( !m_xOutStream.is() || !m_xSeekable.is())
+ throw io::NotConnectedException();
+
+ if ( m_pImpl->m_xCacheStream.is() )
+ {
+ // check whether the cache should be turned off
+ sal_Int64 nPos = m_xSeekable->getPosition();
+ if ( nPos + aData.getLength() > MAX_STORCACHE_SIZE )
+ {
+ // disconnect the cache and copy the data to the temporary file
+ m_xSeekable->seek( 0 );
+
+ // it is enough to copy the cached stream, the cache should already contain everything
+ if ( m_pImpl->GetFilledTempFileIfNo( m_xInStream ).getLength() )
+ {
+ DeInit();
+ // the last position is known and it is differs from the current stream position
+ m_nInitPosition = nPos;
+ }
+ }
+ }
+ }
+
+ if ( m_bInitOnDemand )
+ {
+ RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OWriteStream::CheckInitOnDemand, initializing" );
+ uno::Reference< io::XStream > xStream = m_pImpl->GetTempFileAsStream();
+ if ( xStream.is() )
+ {
+ m_xInStream.set( xStream->getInputStream(), uno::UNO_SET_THROW );
+ m_xOutStream.set( xStream->getOutputStream(), uno::UNO_SET_THROW );
+ m_xSeekable.set( xStream, uno::UNO_QUERY_THROW );
+ m_xSeekable->seek( m_nInitPosition );
+
+ m_nInitPosition = 0;
+ m_bInitOnDemand = sal_False;
+ }
+ }
+
+
if ( !m_xOutStream.is() )
throw io::NotConnectedException();
@@ -2735,11 +3006,35 @@ void SAL_CALL OWriteStream::setPropertyValue( const ::rtl::OUString& aPropertyNa
throw lang::DisposedException();
m_pImpl->GetStreamProperties();
+ ::rtl::OUString aCompressedString( RTL_CONSTASCII_USTRINGPARAM( "Compressed" ) );
+ ::rtl::OUString aMediaTypeString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) );
+ if ( m_pData->m_nStorageType == PACKAGE_STORAGE && aPropertyName.equals( aMediaTypeString ) )
+ {
+ // if the "Compressed" property is not set explicitly, the MediaType can change the default value
+ sal_Bool bCompressedValueFromType = sal_True;
+ ::rtl::OUString aType;
+ aValue >>= aType;
- if ( ( m_pData->m_nStorageType == PACKAGE_STORAGE || m_pData->m_nStorageType == OFOPXML_STORAGE )
- && aPropertyName.equalsAscii( "MediaType" )
- || aPropertyName.equalsAscii( "Compressed" ) )
+ if ( !m_pImpl->m_bCompressedSetExplicit )
+ {
+ if ( aType.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "image/jpeg" ) ) )
+ || aType.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "image/png" ) ) )
+ || aType.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "image/gif" ) ) ) )
+ bCompressedValueFromType = sal_False;
+ }
+
+ for ( sal_Int32 nInd = 0; nInd < m_pImpl->m_aProps.getLength(); nInd++ )
+ {
+ if ( aPropertyName.equals( m_pImpl->m_aProps[nInd].Name ) )
+ m_pImpl->m_aProps[nInd].Value = aValue;
+ else if ( !m_pImpl->m_bCompressedSetExplicit && aCompressedString.equals( m_pImpl->m_aProps[nInd].Name ) )
+ m_pImpl->m_aProps[nInd].Value <<= bCompressedValueFromType;
+ }
+ }
+ else if ( m_pData->m_nStorageType == PACKAGE_STORAGE && aPropertyName.equalsAscii( "Compressed" ) )
{
+ // if the "Compressed" property is not set explicitly, the MediaType can change the default value
+ m_pImpl->m_bCompressedSetExplicit = sal_True;
for ( sal_Int32 nInd = 0; nInd < m_pImpl->m_aProps.getLength(); nInd++ )
{
if ( aPropertyName.equals( m_pImpl->m_aProps[nInd].Name ) )
@@ -2771,6 +3066,15 @@ void SAL_CALL OWriteStream::setPropertyValue( const ::rtl::OUString& aPropertyNa
else
throw lang::IllegalArgumentException(); //TODO
}
+ else if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ && ( aPropertyName.equalsAscii( "MediaType" ) || aPropertyName.equalsAscii( "Compressed" ) ) )
+ {
+ for ( sal_Int32 nInd = 0; nInd < m_pImpl->m_aProps.getLength(); nInd++ )
+ {
+ if ( aPropertyName.equals( m_pImpl->m_aProps[nInd].Name ) )
+ m_pImpl->m_aProps[nInd].Value = aValue;
+ }
+ }
else if ( m_pData->m_nStorageType == OFOPXML_STORAGE && aPropertyName.equalsAscii( "RelationsInfoStream" ) )
{
uno::Reference< io::XInputStream > xInRelStream;
diff --git a/package/source/xstor/owriteablestream.hxx b/package/source/xstor/owriteablestream.hxx
index e9b10ce8ebc0..a3ee6d91862e 100644
--- a/package/source/xstor/owriteablestream.hxx
+++ b/package/source/xstor/owriteablestream.hxx
@@ -34,7 +34,6 @@
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XStream.hpp>
-#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/io/XTruncate.hpp>
#include <com/sun/star/packages/XDataSinkEncrSupport.hpp>
@@ -106,6 +105,9 @@ struct OWriteStream_Impl : public PreCreationStruct
OWriteStream* m_pAntiImpl;
::rtl::OUString m_aTempURL;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > m_xCacheStream;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable > m_xCacheSeek;
+
InputStreamsList_Impl m_aInputStreamsList;
sal_Bool m_bHasDataToFlush; // only modified elements will be sent to the original content
@@ -125,6 +127,8 @@ struct OWriteStream_Impl : public PreCreationStruct
sal_Bool m_bHasCachedPassword;
::rtl::OUString m_aPass;
+ sal_Bool m_bCompressedSetExplicit;
+
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > m_xPackage;
sal_Bool m_bHasInsertedStreamOptimization;
@@ -145,7 +149,8 @@ struct OWriteStream_Impl : public PreCreationStruct
private:
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > GetServiceFactory();
- ::rtl::OUString GetFilledTempFile();
+ ::rtl::OUString GetFilledTempFileIfNo( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xStream );
+ ::rtl::OUString FillTempGetFileName();
::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > GetTempFileAsStream();
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > GetTempFileAsInputStream();
@@ -169,11 +174,14 @@ public:
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory,
sal_Bool bForceEncrypted,
sal_Int16 nStorageType,
+ sal_Bool bDefaultCompress,
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xRelInfoStream =
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >() );
~OWriteStream_Impl();
+ void CleanCacheStream();
+
sal_Bool UsesCommonPass_Impl() { return m_bUseCommonPass; }
sal_Bool HasTempFile_Impl() { return ( m_aTempURL.getLength() != 0 ); }
sal_Bool IsTransacted();
@@ -279,6 +287,7 @@ protected:
sal_Bool m_bInStreamDisconnected;
sal_Bool m_bInitOnDemand;
+ sal_Int64 m_nInitPosition;
sal_Bool m_bTransacted;
@@ -298,6 +307,7 @@ public:
virtual ~OWriteStream();
void CheckInitOnDemand();
+ void DeInit();
// XInterface
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index 0d0b011aec35..3705e560890c 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -1384,7 +1384,7 @@ SotElement_Impl* OStorage_Impl::InsertStream( ::rtl::OUString aName, sal_Bool bE
// the mode is not needed for storage stream internal implementation
SotElement_Impl* pNewElement = InsertElement( aName, sal_False );
- pNewElement->m_pStream = new OWriteStream_Impl( this, xPackageSubStream, m_xPackage, m_xFactory, bEncr, m_nStorageType );
+ pNewElement->m_pStream = new OWriteStream_Impl( this, xPackageSubStream, m_xPackage, m_xFactory, bEncr, m_nStorageType, sal_True );
m_aChildrenList.push_back( pNewElement );
m_bIsModified = sal_True;
@@ -1425,7 +1425,7 @@ SotElement_Impl* OStorage_Impl::InsertRawStream( ::rtl::OUString aName, const un
// the mode is not needed for storage stream internal implementation
SotElement_Impl* pNewElement = InsertElement( aName, sal_False );
- pNewElement->m_pStream = new OWriteStream_Impl( this, xPackageSubStream, m_xPackage, m_xFactory, sal_True, m_nStorageType );
+ pNewElement->m_pStream = new OWriteStream_Impl( this, xPackageSubStream, m_xPackage, m_xFactory, sal_True, m_nStorageType, sal_False );
// the stream is inserted and must be treated as a commited one
pNewElement->m_pStream->SetToBeCommited();
@@ -1564,7 +1564,7 @@ void OStorage_Impl::OpenSubStream( SotElement_Impl* pElement )
throw uno::RuntimeException(); // TODO
// the stream can never be inserted here, because inserted stream element holds the stream till commit or destruction
- pElement->m_pStream = new OWriteStream_Impl( this, xPackageSubStream, m_xPackage, m_xFactory, sal_False, m_nStorageType, GetRelInfoStreamForName( pElement->m_aOriginalName ) );
+ pElement->m_pStream = new OWriteStream_Impl( this, xPackageSubStream, m_xPackage, m_xFactory, sal_False, m_nStorageType, sal_False, GetRelInfoStreamForName( pElement->m_aOriginalName ) );
}
}
diff --git a/package/source/zipapi/XFileStream.cxx b/package/source/zipapi/XFileStream.cxx
index 220c7e8f1b0e..09df729809d4 100644
--- a/package/source/zipapi/XFileStream.cxx
+++ b/package/source/zipapi/XFileStream.cxx
@@ -84,7 +84,7 @@ XFileStream::XFileStream( ZipEntry & rEntry,
if ( bHaveEncryptData )
{
if ( !bNewRawStream )
- ZipFile::StaticGetCipher ( rData, maCipher );
+ ZipFile::StaticGetCipher ( rData, maCipher, sal_True );
else
{
// Put in the EncryptedDataHeader
diff --git a/package/source/zipapi/XUnbufferedStream.cxx b/package/source/zipapi/XUnbufferedStream.cxx
index ff8a085e6b8d..cb99c085bc28 100644
--- a/package/source/zipapi/XUnbufferedStream.cxx
+++ b/package/source/zipapi/XUnbufferedStream.cxx
@@ -93,7 +93,7 @@ XUnbufferedStream::XUnbufferedStream( ZipEntry & rEntry,
sal_Bool bMustDecrypt = ( nStreamMode == UNBUFF_STREAM_DATA && bHaveEncryptData && bIsEncrypted ) ? sal_True : sal_False;
if ( bMustDecrypt )
- ZipFile::StaticGetCipher ( rData, maCipher );
+ ZipFile::StaticGetCipher ( rData, maCipher, sal_True );
if ( bHaveEncryptData && mbWrappedRaw && bIsEncrypted )
{
// if we have the data needed to decrypt it, but didn't want it decrypted (or
@@ -147,7 +147,7 @@ XUnbufferedStream::XUnbufferedStream( const Reference < XInputStream >& xRawStre
mnZipEnd = mnZipCurrent + mnZipSize;
- ZipFile::StaticGetCipher ( rData, maCipher );
+ ZipFile::StaticGetCipher ( rData, maCipher, sal_True );
}
XUnbufferedStream::~XUnbufferedStream()
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 291357c1adb2..0be136e75d6f 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -127,8 +127,9 @@ void ZipFile::setInputStream ( Reference < XInputStream > xNewStream )
aGrabber.setInputStream ( xStream );
}
-void ZipFile::StaticGetCipher ( const ORef < EncryptionData > & xEncryptionData, rtlCipher &rCipher )
+sal_Bool ZipFile::StaticGetCipher ( const ORef < EncryptionData > & xEncryptionData, rtlCipher &rCipher, sal_Bool bDecode )
{
+ sal_Bool bResult = sal_False;
if ( ! xEncryptionData.isEmpty() )
{
Sequence < sal_uInt8 > aDerivedKey (16);
@@ -144,13 +145,17 @@ void ZipFile::StaticGetCipher ( const ORef < EncryptionData > & xEncryptionData,
xEncryptionData->nIterationCount );
rCipher = rtl_cipher_create (rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeStream);
- aResult = rtl_cipher_init( rCipher, rtl_Cipher_DirectionDecode,
+ aResult = rtl_cipher_init( rCipher, bDecode ? rtl_Cipher_DirectionDecode : rtl_Cipher_DirectionEncode,
aDerivedKey.getConstArray(),
aDerivedKey.getLength(),
reinterpret_cast < const sal_uInt8 * > ( xEncryptionData->aInitVector.getConstArray() ),
xEncryptionData->aInitVector.getLength());
OSL_ASSERT (aResult == rtl_Cipher_E_None);
+
+ bResult = ( aResult == rtl_Cipher_E_None );
}
+
+ return bResult;
}
void ZipFile::StaticFillHeader ( const ORef < EncryptionData > & rData,
@@ -335,7 +340,7 @@ sal_Bool ZipFile::StaticHasValidPassword( const Sequence< sal_Int8 > &aReadBuffe
// make a temporary cipher
rtlCipher aCipher;
- StaticGetCipher ( rData, aCipher );
+ StaticGetCipher ( rData, aCipher, sal_True );
Sequence < sal_Int8 > aDecryptBuffer ( nSize );
rtlDigest aDigest = rtl_digest_createSHA1();
@@ -434,7 +439,7 @@ Reference < XInputStream > ZipFile::createMemoryStream(
if ( bMustDecrypt )
{
- StaticGetCipher ( rData, aCipher );
+ StaticGetCipher ( rData, aCipher, sal_True );
aDecryptBuffer.realloc ( nSize );
}
diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx
index a1504f0aa526..8954db47d63c 100644
--- a/package/source/zipapi/ZipOutputStream.cxx
+++ b/package/source/zipapi/ZipOutputStream.cxx
@@ -36,6 +36,7 @@
#include <EncryptionData.hxx>
#include <PackageConstants.hxx>
#include <ZipEntry.hxx>
+#include <ZipFile.hxx>
#ifndef _VOS_REF_H_
#include <vos/ref.hxx>
#endif
@@ -103,15 +104,9 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
if (bEncrypt)
{
bEncryptCurrentEntry = sal_True;
- rtlCipherError aResult;
-
- aCipher = rtl_cipher_create ( rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeStream);
- aResult = rtl_cipher_init( aCipher, rtl_Cipher_DirectionEncode,
- reinterpret_cast < const sal_uInt8 * > (xEncryptData->aKey.getConstArray() ),
- xEncryptData->aKey.getLength(),
- reinterpret_cast < const sal_uInt8 * > ( xEncryptData->aInitVector.getConstArray() ),
- xEncryptData->aInitVector.getLength());
- OSL_ASSERT( aResult == rtl_Cipher_E_None );
+
+ ZipFile::StaticGetCipher( xEncryptData, aCipher, sal_False );
+
aDigest = rtl_digest_createSHA1();
mnDigested = 0;
rEntry.nFlag |= 1 << 4;
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index 1d5e900e28fe..8e0c8718dbfb 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -449,25 +449,16 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
if ( bToBeEncrypted && !bTransportOwnEncrStreamAsRaw )
{
Sequence < sal_uInt8 > aSalt ( 16 ), aVector ( 8 );
- Sequence < sal_Int8 > aKey ( 16 );
rtl_random_getBytes ( rRandomPool, aSalt.getArray(), 16 );
rtl_random_getBytes ( rRandomPool, aVector.getArray(), 8 );
sal_Int32 nIterationCount = 1024;
- if ( pStream->HasOwnKey() )
- rtl_digest_PBKDF2 ( reinterpret_cast < sal_uInt8 * > (aKey.getArray()), 16,
- reinterpret_cast < const sal_uInt8 * > (pStream->getKey().getConstArray()), pStream->getKey().getLength(),
- reinterpret_cast < const sal_uInt8 * > ( aSalt.getConstArray() ), 16,
- nIterationCount );
- else
- rtl_digest_PBKDF2 ( reinterpret_cast < sal_uInt8 * > (aKey.getArray()), 16,
- reinterpret_cast < const sal_uInt8 * > (rEncryptionKey.getConstArray()), rEncryptionKey.getLength(),
- reinterpret_cast < const sal_uInt8 * > ( aSalt.getConstArray() ), 16,
- nIterationCount );
+ if ( !pStream->HasOwnKey() )
+ pStream->setKey ( rEncryptionKey );
+
pStream->setInitialisationVector ( aVector );
pStream->setSalt ( aSalt );
pStream->setIterationCount ( nIterationCount );
- pStream->setKey ( aKey );
}
// last property is digest, which is inserted later if we didn't have