[ooo-build-commit] Branch 'ooo/master' - 2 commits - accessibility/inc accessibility/source extensions/source forms/source package/inc package/qa package/source

Jan Holesovsky kendy at kemper.freedesktop.org
Wed Jun 3 17:13:57 PDT 2009


 accessibility/inc/accessibility/extended/accessiblelistboxentry.hxx |   12 
 accessibility/source/extended/accessiblelistboxentry.cxx            |   11 
 extensions/source/bibliography/bibload.cxx                          |    2 
 extensions/source/plugin/base/plcom.cxx                             |    5 
 extensions/source/plugin/inc/plugin/plcom.hxx                       |    2 
 extensions/source/plugin/unx/npwrap.cxx                             |   14 
 extensions/source/plugin/unx/sysplug.cxx                            |    2 
 forms/source/richtext/richtextunowrapper.cxx                        |   11 
 package/inc/ZipFile.hxx                                             |    2 
 package/qa/storages/StorageUnitTest.java                            |    9 
 package/qa/storages/Test01.java                                     |   20 
 package/qa/storages/Test02.java                                     |   11 
 package/qa/storages/Test03.java                                     |   33 
 package/qa/storages/Test04.java                                     |   33 
 package/qa/storages/Test05.java                                     |   42 
 package/qa/storages/Test07.java                                     |   24 
 package/qa/storages/Test08.java                                     |   18 
 package/qa/storages/Test09.java                                     |   16 
 package/qa/storages/Test10.java                                     |   25 
 package/qa/storages/Test11.java                                     |   28 
 package/qa/storages/Test12.java                                     |   25 
 package/qa/storages/Test13.java                                     |   33 
 package/qa/storages/Test18.java                                     |  172 +++
 package/qa/storages/TestHelper.java                                 |   93 +
 package/qa/storages/makefile.mk                                     |    1 
 package/source/xstor/owriteablestream.cxx                           |  560 +++++++---
 package/source/xstor/owriteablestream.hxx                           |   14 
 package/source/xstor/xstorage.cxx                                   |    6 
 package/source/zipapi/XFileStream.cxx                               |    2 
 package/source/zipapi/XUnbufferedStream.cxx                         |    4 
 package/source/zipapi/ZipFile.cxx                                   |   13 
 package/source/zipapi/ZipOutputStream.cxx                           |   13 
 package/source/zippackage/ZipPackageFolder.cxx                      |   15 
 33 files changed, 1054 insertions(+), 217 deletions(-)

New commits:
commit fe82e17082f38ba8bf964fa1a79859095e7f581a
Author: Kurt Zenker <kz at openoffice.org>
Date:   Wed Jun 3 15:45:09 2009 +0000

    CWS-TOOLING: integrate CWS vcl101
    2009-04-30 16:05:34 +0200 pl  r271420 : #i95591# need a poll timer so XtTimers work properly
    2009-04-30 11:25:52 +0200 hdu  r271406 : #i100929# avoid unneeded colormap reallocation
    2009-04-30 11:21:16 +0200 hdu  r271405 : #i100929# use improved SetDrawable() also for salframe updates
    2009-04-30 11:12:41 +0200 hdu  r271404 : i100929# invalidate cached renderpic also for changed vdev
    2009-04-29 14:31:40 +0200 hdu  r271375 : i100929# use cached renderpic also for alpha-rect/bitmap drawing
    2009-04-29 14:16:51 +0200 hdu  r271370 : i100929# notify only GtkSalFrame's valid X11SalFrames
    2009-04-29 13:58:10 +0200 hdu  r271369 : i100929# notify GtkSalFrame's X11SalGraphics that their drawables will become obsolete
    2009-04-29 13:53:48 +0200 hdu  r271367 : #i100929# release cached renderpic whenever the corresponding drawable changes
    2009-04-28 11:56:07 +0200 pl  r271317 : fix a snafu
    2009-04-27 16:52:29 +0200 hdu  r271293 : #i100000# WAE fix for debug=true compilation
    2009-04-27 12:38:11 +0200 hdu  r271260 : #i101367# disable vdev mapmode when measuring pixel size
    2009-04-27 12:28:37 +0200 hdu  r271259 : #i101367# speedup svclcanvas::CanvasBitmapHelper::getSize()
    2009-04-23 15:11:25 +0200 hdu  r271175 : #i91685# ignore trailing space in last cell
    2009-04-23 12:55:14 +0200 pl  r271156 : #i101032# check for empty bitmap
    2009-04-23 11:04:50 +0200 pl  r271144 : #101184# add a paranoia check
    2009-04-21 19:12:25 +0200 pl  r271055 : #i101184# add: recognize added/removed monitors in xinerama configuration for gtk plugin (thanks cmc)
    2009-04-21 17:04:44 +0200 pl  r271046 : #i101089# remove unused method (thanks cmc)
    2009-04-21 16:41:38 +0200 hdu  r271042 : #i99842# set text decoration color
    2009-04-20 22:57:37 +0200 pl  r271015 : #i101063# fix warnings
    2009-04-20 22:55:39 +0200 pl  r271014 : #i101063# fix warnings
    2009-04-20 11:35:24 +0200 hdu  r270968 : #i1001102# remove dependency to psprint module
    2009-04-20 11:31:08 +0200 hdu  r270967 : #i100929# keep cached render Picture in X11SalGraphics removes
    2009-04-20 11:24:57 +0200 hdu  r270966 : #i100929# cache render Picture in X11SalGraphics
    2009-04-18 14:53:22 +0200 hdu  r270959 : CWS-TOOLING: rebase CWS vcl101 to trunk at 270723 (milestone: DEV300:m46)
    2009-04-17 12:00:50 +0200 hdu  r270934 : #i100951# b2d-polygon clipping handles bezier-segments nowadays => performance opt possible
    2009-04-17 11:50:49 +0200 hdu  r270933 : #i100922# count b2d-polypoly-points to avoid priority-queue reallocations
    2009-04-17 11:07:03 +0200 hdu  r270930 : #i101145# match dpi-sanity check with gnome-UI (thanks Caolan!)
    2009-04-17 10:44:41 +0200 hdu  r270929 : #i100603# dingbats-encoded PDF-builtin fonts are symbol fonts too
    2009-04-17 10:36:10 +0200 hdu  r270928 : #i101145# check sanity of resolution reported by Xft-dpi (thanks CMC!)
    2009-04-08 13:53:35 +0200 hdu  r270644 : #i100951# avoid expensive calls to basegfx::tools::clipPolygonOnRange() if possible
    2009-04-08 13:19:26 +0200 hdu  r270637 : #i100922# prevent needless stl::priority_queue reallacations by reserving
    2009-04-08 11:14:30 +0200 hdu  r270627 : #i100929# use X11SalGraphics::GetXRenderPicture() also for text drawing
    2009-04-08 10:00:42 +0200 hdu  r270620 : #i100929# add and use X11SalGraphics::GetXRenderPicture() for polygon drawing
    2009-04-06 15:52:47 +0200 hdu  r270563 : #i100885# add and use AquaSalGraphics::copyResolution() to speed up virdev creation
    2009-04-02 14:39:06 +0200 pl  r270408 : #i95873# do not set LD_LIBRARY_PATH for external apps
    2009-03-31 18:43:19 +0200 pl  r270292 : #i99783# transparency of closer image changed to mask in the meantime
    2009-03-27 15:42:37 +0100 hdu  r270158 : #i100591# fix binary search in dingbats encoding converter
    2009-03-27 13:06:34 +0100 hdu  r270151 : #i100603# only PDF builtin text fonts use WinAnsiEncoding
    2009-03-27 12:05:35 +0100 hdu  r270147 : #i100603# use correct encoding for all PDF builtin fonts
    2009-03-27 09:04:07 +0100 hdu  r270133 : #i100603# use proper encoding for PDF builtin symbol fonts
    2009-03-26 17:19:38 +0100 hdu  r270090 : #i100591# support RTL_TEXTENCODING_ADOBE_DINGBATS encoding
    2009-03-25 09:02:18 +0100 hdu  r269995 : #i100521# prefer osl_getAsciiFunctionSymbol() when dynloading SAGE and extra USER32 symbols
    2009-03-25 08:55:49 +0100 hdu  r269994 : #i100521# prefer osl_getAsciiFunctionSymbol() when dynloading LUNA symbols
    2009-03-24 16:15:54 +0100 hdu  r269965 : #i100521# prefer osl_getAsciiFunctionSymbol() when dynloading vclplugin symbols
    2009-03-24 16:10:29 +0100 hdu  r269963 : #i100521# prefer osl_getAsciiFunctionSymbol() when dynloading USP symbols
    2009-03-24 15:54:30 +0100 hdu  r269962 : #i100521# prefer osl_getAsciiFunctionSymbol() when dynloading xrender symbols
    2009-03-24 10:46:55 +0100 hdu  r269920 : #i100506# fix WAE build breakers on unxsols4 for debug=true
    2009-03-23 16:36:43 +0100 hdu  r269884 : #159477# fix crash for PDFs with big zlib-chunks
    2009-03-20 17:36:56 +0100 pl  r269821 : #i96568# add recent files to mac quickstarter
    2009-03-20 14:39:41 +0100 pl  r269809 : #i35482# no HC mode detection, automatically done in independent part
    2009-03-19 20:01:37 +0100 pl  r269768 : #i95591# do not reuse UnxPloginComm because of connection loss problems
    2009-03-19 18:08:23 +0100 pl  r269765 : #i95588# change default visibility that was ignored everywhere but unix anyway

diff --git a/accessibility/inc/accessibility/extended/accessiblelistboxentry.hxx b/accessibility/inc/accessibility/extended/accessiblelistboxentry.hxx
index f839fcb..ba22b3b 100644
--- a/accessibility/inc/accessibility/extended/accessiblelistboxentry.hxx
+++ b/accessibility/inc/accessibility/extended/accessiblelistboxentry.hxx
@@ -97,18 +97,6 @@ namespace accessibility
                                             m_aParent;
 
     private:
-        /** notifies all listeners that this object has changed
-            @param	_nEventId
-                is the event id
-            @param	_aOldValue
-                is the old value
-            @param	_aNewValue
-                is the new value
-        */
-        void	NotifyAccessibleEvent( sal_Int16 _nEventId,
-                                       const ::com::sun::star::uno::Any& _aOldValue,
-                                       const ::com::sun::star::uno::Any& _aNewValue );
-
         Rectangle				GetBoundingBox_Impl() const;
         Rectangle				GetBoundingBoxOnScreen_Impl() const;
         sal_Bool				IsAlive_Impl() const;
diff --git a/accessibility/source/extended/accessiblelistboxentry.cxx b/accessibility/source/extended/accessiblelistboxentry.cxx
index 6417b07..151283c 100644
--- a/accessibility/source/extended/accessiblelistboxentry.cxx
+++ b/accessibility/source/extended/accessiblelistboxentry.cxx
@@ -118,17 +118,6 @@ namespace accessibility
     }
 
     // -----------------------------------------------------------------------------
-    void AccessibleListBoxEntry::NotifyAccessibleEvent( sal_Int16 _nEventId,
-                                                   const ::com::sun::star::uno::Any& _aOldValue,
-                                                   const ::com::sun::star::uno::Any& _aNewValue )
-    {
-        Reference< uno::XInterface > xSource( *this );
-        AccessibleEventObject aEventObj( xSource, _nEventId, _aNewValue, _aOldValue );
-
-        if (m_nClientId)
-            comphelper::AccessibleEventNotifier::addEvent( m_nClientId, aEventObj );
-    }
-    // -----------------------------------------------------------------------------
     Rectangle AccessibleListBoxEntry::GetBoundingBox_Impl() const
     {
         Rectangle aRect;
diff --git a/extensions/source/plugin/base/plcom.cxx b/extensions/source/plugin/base/plcom.cxx
index 2b24610..d8c900f 100644
--- a/extensions/source/plugin/base/plcom.cxx
+++ b/extensions/source/plugin/base/plcom.cxx
@@ -42,11 +42,12 @@
 #include <tools/fsys.hxx>
 #include <plugin/impl.hxx>
 
-PluginComm::PluginComm( const ::rtl::OString& rLibName ) :
+PluginComm::PluginComm( const ::rtl::OString& rLibName, bool bReusable ) :
         m_nRefCount( 0 ),
         m_aLibName( rLibName )
 {
-    PluginManager::get().getPluginComms().push_back( this );
+    if( bReusable )
+        PluginManager::get().getPluginComms().push_back( this );
 }
 
 PluginComm::~PluginComm()
diff --git a/extensions/source/plugin/inc/plugin/plcom.hxx b/extensions/source/plugin/inc/plugin/plcom.hxx
index 1459e4f..a3395d1 100644
--- a/extensions/source/plugin/inc/plugin/plcom.hxx
+++ b/extensions/source/plugin/inc/plugin/plcom.hxx
@@ -42,7 +42,7 @@ protected:
     ::rtl::OString				m_aLibName;
     std::list< String >			m_aFilesToDelete;
 public:
-    PluginComm( const ::rtl::OString& rLibName );
+    PluginComm( const ::rtl::OString& rLibName, bool bReusable = true );
     virtual ~PluginComm();
 
     int getRefCount() { return m_nRefCount; }
diff --git a/extensions/source/plugin/unx/npwrap.cxx b/extensions/source/plugin/unx/npwrap.cxx
index 3fff84e..0500ea0 100644
--- a/extensions/source/plugin/unx/npwrap.cxx
+++ b/extensions/source/plugin/unx/npwrap.cxx
@@ -262,6 +262,17 @@ static GSourceFuncs aXtEventFuncs =
   NULL
 };
 
+static gboolean pollXtTimerCallback(gpointer)
+{
+    for(int i = 0; i < 5; i++)
+    {
+        if( (XtAppPending(app_context) & (XtIMAll & ~XtIMXEvent)) == 0 )
+            break;
+        XtAppProcessEvent(app_context, XtIMAll & ~XtIMXEvent);
+    }
+    return TRUE;
+}
+
 static gboolean prepareWakeupEvent( GSource*, gint* )
 {
     struct pollfd aPoll = { wakeup_fd[0], POLLIN, 0 };
@@ -411,6 +422,7 @@ int main( int argc, char **argv)
     aXtPollDesc.revents = 0;
     g_source_add_poll( pXTSource, &aXtPollDesc );
     
+    gint xt_polling_timer_id = g_timeout_add( 25, pollXtTimerCallback, NULL);
     // Initialize wakeup events listener
     GSource *pWakeupSource = g_source_new( &aWakeupEventFuncs, sizeof(GSource) );
     if ( pWakeupSource == NULL )
@@ -473,6 +485,8 @@ int main( int argc, char **argv)
 
     medDebug( 1, "left plugin app main loop\n" );
 
+    g_source_remove(xt_polling_timer_id);
+    
     pNP_Shutdown();
     medDebug( 1, "NP_Shutdown done\n" );
     osl_unloadModule( pPluginLib );
diff --git a/extensions/source/plugin/unx/sysplug.cxx b/extensions/source/plugin/unx/sysplug.cxx
index 4adaace..c82fe1b 100644
--- a/extensions/source/plugin/unx/sysplug.cxx
+++ b/extensions/source/plugin/unx/sysplug.cxx
@@ -50,7 +50,7 @@ UnxPluginComm::UnxPluginComm(
                              int nDescriptor1,
                              int nDescriptor2
                              ) :
-        PluginComm( ::rtl::OUStringToOString( library, osl_getThreadTextEncoding() ) ),
+        PluginComm( ::rtl::OUStringToOString( library, osl_getThreadTextEncoding() ), false ),
         PluginConnector( nDescriptor2 )
 {
     char pDesc[32];
commit 956307d1af91f037f023e429114e953dba1df8b3
Author: Kurt Zenker <kz at openoffice.org>
Date:   Wed Jun 3 11:26:39 2009 +0000

    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 at 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 at 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

diff --git a/extensions/source/bibliography/bibload.cxx b/extensions/source/bibliography/bibload.cxx
index 3a57b40..7c611b3 100644
--- a/extensions/source/bibliography/bibload.cxx
+++ b/extensions/source/bibliography/bibload.cxx
@@ -692,7 +692,7 @@ sal_Bool BibliographyLoader::hasElements(void) throw ( RuntimeException )
 Reference< XPropertySetInfo >  BibliographyLoader::getPropertySetInfo(void) throw
                                             ( RuntimeException )
 {
-    static SfxItemPropertyMap aBibProps_Impl[] =
+    static SfxItemPropertyMapEntry aBibProps_Impl[] =
     {
         { MAP_CHAR_LEN("BibliographyDataFieldNames"), 0, &::getCppuType((Sequence<PropertyValue>*)0), PropertyAttribute::READONLY, 0},
         {0,0,0,0,0,0}
diff --git a/forms/source/richtext/richtextunowrapper.cxx b/forms/source/richtext/richtextunowrapper.cxx
index 205e102..cfe1d3e 100644
--- a/forms/source/richtext/richtextunowrapper.cxx
+++ b/forms/source/richtext/richtextunowrapper.cxx
@@ -37,6 +37,7 @@
 /** === end UNO includes === **/
 #include <svx/unofored.hxx>
 #include <svx/editview.hxx>
+#include <svx/unoipset.hxx>
 
 //........................................................................
 namespace frm
@@ -51,10 +52,10 @@ namespace frm
     //====================================================================
     namespace
     {
-        const SfxItemPropertyMap* getTextEnginePropertyMap()
+        const SvxItemPropertySet* getTextEnginePropertySet()
         {
             // Propertymap fuer einen Outliner Text
-            static const SfxItemPropertyMap aTextEnginePropertyMap[] =
+            static const SfxItemPropertyMapEntry aTextEnginePropertyMap[] =
             {
                 SVX_UNOEDIT_CHAR_PROPERTIES,
                 SVX_UNOEDIT_FONT_PROPERTIES,
@@ -63,8 +64,8 @@ namespace frm
                 { MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType( static_cast< const Reference< XNameContainer >* >( NULL ) ), 0, 0 },
                 { NULL, 0, 0, NULL, 0, 0 }
             };
-
-            return aTextEnginePropertyMap;
+            static SvxItemPropertySet aTextEnginePropertySet( aTextEnginePropertyMap );
+            return &aTextEnginePropertySet;
         }
     }
 
@@ -73,7 +74,7 @@ namespace frm
     //====================================================================
     //--------------------------------------------------------------------
     ORichTextUnoWrapper::ORichTextUnoWrapper( EditEngine& _rEngine, IEngineTextChangeListener* _pTextChangeListener )
-        :SvxUnoText( getTextEnginePropertyMap() )
+        :SvxUnoText( getTextEnginePropertySet() )
     {
         SetEditSource( new RichTextEditSource( _rEngine, _pTextChangeListener ) );
     }
diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx
index 4baf6e1..7f01e7c 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 0be7e1e..fa0638c 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 e8b6e2b..b722c3a 100644
--- a/package/qa/storages/Test01.java
+++ b/package/qa/storages/Test01.java
@@ -57,7 +57,19 @@ public class Test01 implements StorageTest {
                 m_aTestHelper.Error( "Can't create substorage!" );
                 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 a8baf07..2da897a 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 8429cda..01b9039 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 4b07c04..2f8ba73 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 4fcc70c..6d90cf9 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 f21bc52..b0edaa5 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 a95e4a2..ecf28c4 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,7 +102,9 @@ 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,
                                                             "MediaType4",
@@ -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 c626283..8d867a4 100644
--- a/package/qa/storages/Test09.java
+++ b/package/qa/storages/Test09.java
@@ -45,12 +45,17 @@ 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 );
             if ( sTempFileURL == null || sTempFileURL == "" )
@@ -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 025b756..35c3e6e 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 13ca6fb..5663c1e 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 59c8b94..6db2561 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 2dffe52..6e8c8a4 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 0000000..a79e2d3
--- /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 0554b70..0c1580f 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 a8a5bbf..81cacb9 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 87918c5..bab0ddc 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,8 +946,14 @@ 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() )
     {
         KillFile( m_aTempURL, GetServiceFactory() );
@@ -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 5281b00..b291525 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
@@ -124,6 +126,8 @@ struct OWriteStream_Impl : public PreCreationStruct
     sal_Bool m_bUseCommonPass;
     sal_Bool m_bHasCachedPassword;
     ::rtl::OUString m_aPass;
+    
+    sal_Bool m_bCompressedSetExplicit;
 
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > m_xPackage;
 
@@ -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,10 +174,13 @@ 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 ); }
@@ -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 263ed59..8f9719f 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 55e34b3..2742dad 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 0bda8a3..0b14d6c 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 9f426ea..28c4080 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 1614580..9995c29 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 334a07f..0330261 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


More information about the ooo-build-commit mailing list