Issue 11704 - storeToUrl(L"private:stream") holds on to stream
Summary: storeToUrl(L"private:stream") holds on to stream
Status: CLOSED FIXED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC Windows XP
: P3 Trivial
Target Milestone: ---
Assignee: mikhail.voytenko
QA Contact: issues@api
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-21 05:38 UTC by Unknown
Modified: 2013-02-24 21:07 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Unknown 2003-02-21 05:38:06 UTC
We have a requirement to store documents to memory instead of to a file. For 
this purpose we are passing in a custom memory stream object to the storeToURL
() function as follows: 

        Sequence<::com::sun::star::beans::PropertyValue> aArgs(1); 

        ::com::sun::star::beans::PropertyValue* pArg = aArgs.getArray(); 
        pArg[0].Name = L"OutputStream"; 
        pArg[0].Value <<= CreateMemStream()->getOutputStream(); // XStream 
object returns XOutputStream 

        xStorable->storeToURL(L"private:stream", aArgs); 

The ref count on the stream object remains at 2. 
This seems to make OO.o unstable and causes it to crash later on (not the case 
with storing to a file). 

This was originally posted to 'dev@api.openoffice.org' with one response from 
Michael Hoennig [mi@sun.com]:
"Does it still crash when the stream is closed after storeToUrl() using 
XOutputStream::closeOutput()?  But I think it should not.  Would you file an 
issue about this in IssueZilla?"

Please note, Michael Hoennig's response did not resolve this issue because 
OO.o never calls XOutputStream::closeOutput()
Comment 1 ooo 2003-02-26 09:28:31 UTC
implementation issue
Comment 2 Mathias_Bauer 2003-02-27 12:18:51 UTC
Target adjusted
Comment 3 Mathias_Bauer 2003-03-03 12:42:22 UTC
I'm not sure where the superfluous reference is kept, perhaps in
SfxMedium?
Comment 4 mikhail.voytenko 2003-03-03 12:53:14 UTC
I will investigate the refcounting problem.
As for XOutputStream::closeOutput(), 
the caller of StoreToURL should call this method after saving to the
stream.
Comment 5 mikhail.voytenko 2003-03-05 08:35:17 UTC
A temporary ItemSet created by SfxBaseModel was not deleted.
Comment 6 mikhail.voytenko 2003-04-03 07:15:19 UTC
The following script can be used for testing but the file pathes
should be adjusted. The result of the macro is the NewFile opened for
editing.
Before the bug was fixed this file could not be opened for editing
since the stream that holt the lock was not released.

REM  *****  BASIC  *****

Sub Main

REM PLEASE ADJUST THE PATHES
ExistingFile = "file:///d:/OLE_TEST/test.sxw"
NewFile = "file:///d:/temp.sxw"

Dim aPropArray(0) as Object
aPropArray(0) = CreateUnoStruct("com.sun.star.beans.PropertyValue")
aPropArray(0).Name = "MacroExecutionMode"
aPropArray(0).Value = 0

oDoc = StarDesktop.loadComponentFromURL( ExistingFile, "_blank", 0,
aPropArray() )

oFileAcc = createUnoService ( "com.sun.star.ucb.SimpleFileAccess" )
xStream = oFileAcc.openFileWrite ( NewFile )

Dim aPArray(1) as Object
aPArray(0) = CreateUnoStruct("com.sun.star.beans.PropertyValue")
aPArray(0).Name = "InteractionHandler"
aPArray(0).Value = createUnoService(
"com.sun.star.task.InteractionHandler" )
aPArray(1) = CreateUnoStruct("com.sun.star.beans.PropertyValue")
aPArray(1).Name = "OutputStream"
aPArray(1).Value = xStream

oDoc.storeToURL( "private:stream", aPArray() )

xStream.closeOutput()
oDoc.close( true )

oDocNew = StarDesktop.loadComponentFromURL( NewFile, "_blank", 0,
aPropArray() )

End Sub
Comment 7 mikhail.voytenko 2003-04-29 08:34:27 UTC
Ok in m12s1