https://bz.apache.org/ooo/show_bug.cgi?id=117672
[email protected] changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |ms_interoperability Latest|--- |4.2.0-dev Confirmation in| | CC| |[email protected] --- Comment #4 from [email protected] --- Still exists in the latest Git. The content type passed to this method in main/oox/source/core/filterdetect.cxx OUString FilterDetectDocHandler::getFilterNameFromContentType( const OUString& rContentType ) const is always "application/xml", while we are expecting "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" and the like. Where is it being passed from?? --snip-- #0 oox::core::FilterDetectDocHandler::getFilterNameFromContentType(rtl::OUString const&) const (this=<optimized out>, rContentType=...) at source/core/filterdetect.cxx:166 #1 0x000000080e7109d8 in oox::core::FilterDetectDocHandler::parseContentTypesDefault(oox::AttributeList const&) (this=this@entry=0x80ae71f80, rAttribs=...) at source/core/filterdetect.cxx:205 #2 0x000000080e710787 in oox::core::FilterDetectDocHandler::startFastElement(int, com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> const&) (this=0x80ae71f80, nElement=<optimized out>, rAttribs=<optimized out>) at source/core/filterdetect.cxx:100 --snip-- So this: ---snip--- 95 // cases for [Content_Types].xml 96 case PC_TOKEN( Types ): 97 break; 98 case PC_TOKEN( Default ): 99 if( !maContextStack.empty() && (maContextStack.back() == PC_TOKEN( Types )) ) 100 parseContentTypesDefault( aAttribs ); 101 break; 102 case PC_TOKEN( Override ): 103 if( !maContextStack.empty() && (maContextStack.back() == PC_TOKEN( Types )) ) 104 parseContentTypesOverride( aAttribs ); 105 break; ---snip--- calls this: ---snip--- 196 void FilterDetectDocHandler::parseContentTypesDefault( const AttributeList& rAttribs ) 197 { 198 // only if no overridden part name found 199 if( mrFilterName.getLength() == 0 ) 200 { 201 // check if target path ends with extension 202 OUString aExtension = rAttribs.getString( XML_Extension, OUString() ); 203 sal_Int32 nExtPos = maTargetPath.getLength() - aExtension.getLength(); 204 if( (nExtPos > 0) && (maTargetPath[ nExtPos - 1 ] == '.') && maTargetPath.match( aExtension, nExtPos ) ) 205 mrFilterName = getFilterNameFromContentType( rAttribs.getString( XML_ContentType, OUString() ) ); 206 } 207 } ---snip--- So the "application/xml" being passed to getFilterNameFromContentType() comes from the "ContentType" attribute of the "Default" element in [Content_Types].xml. But why is "Default" being used and not "Override" on line 102? Because this method always fails: ---snip--- 209 void FilterDetectDocHandler::parseContentTypesOverride( const AttributeList& rAttribs ) 210 { 211 if( rAttribs.getString( XML_PartName, OUString() ).equals( maTargetPath ) ) 212 mrFilterName = getFilterNameFromContentType( rAttribs.getString( XML_ContentType, OUString() ) ); 213 } ---snip--- because "maTargetPath" is "//xl/workbook.xml" instead of "/xl/workbook.xml" and so it never matches the "PartName" attribute of "/xl/workbook.xml", because when it got initialized by this method, a leading slash was prefixed: ---snip--- 157 void FilterDetectDocHandler::parseRelationship( const AttributeList& rAttribs ) 158 { 159 OUString aType = rAttribs.getString( XML_Type, OUString() ); 160 if( aType.equalsAscii( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" ) ) 161 maTargetPath = OUString( sal_Unicode( '/' ) ) + rAttribs.getString( XML_Target, OUString() ); 162 } ---snip--- and the bad file's _rels/.rels contained a "Target" attribute that had a leading slash already: <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="/xl/workbook.xml" Id="Rfd55d326fad84da6" /> In normal XSLX files, "Target" never has a leading slash. I don't think this file is valid, but Excel apparently accepts it, so we should too. As a workaround, we can check for a leading slash and not prefix another if it is already present. A patch that does that, gets the file to successfully open :-). -- You are receiving this mail because: You are the assignee for the issue. You are on the CC list for the issue.
