Issue 121982 - Loading with "private:stream" ignores filter settings on the media descriptor
Summary: Loading with "private:stream" ignores filter settings on the media descriptor
Status: CONFIRMED
Alias: None
Product: General
Classification: Code
Component: scripting (show other issues)
Version: 3.4.0
Hardware: All All
: P3 Normal (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-31 12:38 UTC by Ariel Constenla-Haile
Modified: 2013-07-09 14:23 UTC (History)
3 users (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 Ariel Constenla-Haile 2013-03-31 12:38:20 UTC
Loading a component using the URL "private:stream" seems to ignore the "FilterName", and loads always as plain text in Writer.

Example code:

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

Option Explicit

Sub Main
Dim sContent$
sContent = "<?xml version=""1.0"" encoding=""UTF-8""?>" + Chr(13) + _
"<svg xmlns=""http://www.w3.org/2000/svg"" version=""1.1"">" + Chr(13) + _
"<circle cx=""100"" cy=""50"" r=""40"" stroke=""black"" stroke-width=""2"" fill=""red"" />" + Chr(13) + _
"</svg>"

Dim nLen%
nLen = Len(sContent)
Dim aBytes%(nLen-1)
Dim n%
For n = 0 To nLen-1
aBytes(n) = Asc(Mid(sContent,n+1,1))		
Next

Dim oTempFile as Object
oTempFile = CreateUnoService("com.sun.star.io.TempFile")

Dim oOut as Object
oOut = oTempFile.getOutputStream()
oOut.writeBytes(aBytes)
oOut.flush()
oOut.closeOutput()
	
Dim oIn as Object
oIn = oTempFile.getInputStream()
	
Dim oMediaDesc(1) as new com.sun.star.beans.PropertyValue
oMediaDesc(0).Name = "InputStream"
oMediaDesc(0).Value = oIn
oMediaDesc(1).Name = "FilterName"
oMediaDesc(1).Value = "SVG - Scalable Vector Graphics"

Dim oDoc
oDoc = StarDesktop.loadComponentFromURL("private:stream","_blank",0,oMediaDesc)
End Sub
Comment 1 Oliver Brinzing 2013-03-31 12:47:26 UTC
.
Comment 2 Oliver Brinzing 2013-03-31 12:54:54 UTC
another strange private:stream bug:
https://issues.apache.org/ooo/show_bug.cgi?id=119935
private:stream - load component from ByteArray crashes aoo
Comment 3 Ariel Constenla-Haile 2013-03-31 13:15:08 UTC
(In reply to comment #2)
> another strange private:stream bug:
> https://issues.apache.org/ooo/show_bug.cgi?id=119935
> private:stream - load component from ByteArray crashes aoo

I did a Basic version of the Java code, and does not crash; strage. Ill attach the example on the other bug.
Comment 4 hanya 2013-07-08 17:40:03 UTC
In LoadEnv::impl_detectTypeAndFilter method, type detection  
is started by calling the following method: 
XTypeDetection xDetect->queryTypeByDescriptor(lDescriptor, sal_True) 
The second parameter specifies to detect deeply, so always deep detection is chosen.

First, the filter name passed is used to get internal file type. 
But the mode is always deep detection, so the additional detection is proceeded.
Type detection component for svg file is com.sun.star.comp.draw.FormatDetector.
In SdFilterDetect::detect method, if URL (private:stream in this case) 
is not starting with "private:factory/", SfxMedium is initialized with 
the passed URL. And the passed input stream is not used.
So the problem is the stream is ignored in this case.
Comment 5 hanya 2013-07-09 14:23:19 UTC
> SfxMedium is initialized with 
> the passed URL. And the passed input stream is not used.
> So the problem is the stream is ignored in this case.
This is wrong, it is initialized with transformed values.