incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1167327 - in /incubator/ooo/trunk/main: filter/source/config/fragments/types/ sc/source/ui/unoobj/
Date Fri, 09 Sep 2011 18:51:56 GMT
Author: erack
Date: Fri Sep  9 18:51:55 2011
New Revision: 1167327

URL: http://svn.apache.org/viewvc?rev=1167327&view=rev
Log:
calc67: #i117735# use calc FormatDetector for XLS again, handle Excel 2003 XML directly in
XLS detection

# User Niklas Nebel <nn@openoffice.org>

Modified:
    incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_40.xcu
    incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_40_VorlageTemplate.xcu
    incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_5095.xcu
    incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_5095_VorlageTemplate.xcu
    incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_95.xcu
    incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_95_VorlageTemplate.xcu
    incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_97.xcu
    incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_97_VorlageTemplate.xcu
    incubator/ooo/trunk/main/sc/source/ui/unoobj/scdetect.cxx

Modified: incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_40.xcu
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_40.xcu?rev=1167327&r1=1167326&r2=1167327&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_40.xcu (original)
+++ incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_40.xcu Fri
Sep  9 18:51:55 2011
@@ -1,5 +1,5 @@
 	<node oor:name="calc_MS_Excel_40" oor:op="replace" >
-		<prop oor:name="DetectService"><value>com.sun.star.comp.oox.xls.BiffDetector</value></prop>
+		<prop oor:name="DetectService"><value>com.sun.star.comp.calc.FormatDetector</value></prop>
 		<prop oor:name="URLPattern"/>
 		<prop oor:name="Extensions"><value>xls xlw xlc xlm</value></prop>
 		<prop oor:name="MediaType"><value>application/vnd.ms-excel</value></prop>

Modified: incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_40_VorlageTemplate.xcu
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_40_VorlageTemplate.xcu?rev=1167327&r1=1167326&r2=1167327&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_40_VorlageTemplate.xcu
(original)
+++ incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_40_VorlageTemplate.xcu
Fri Sep  9 18:51:55 2011
@@ -1,5 +1,5 @@
 	<node oor:name="calc_MS_Excel_40_VorlageTemplate" oor:op="replace" >
-		<prop oor:name="DetectService"><value>com.sun.star.comp.oox.xls.BiffDetector</value></prop>
+		<prop oor:name="DetectService"><value>com.sun.star.comp.calc.FormatDetector</value></prop>
 		<prop oor:name="URLPattern"/>
 		<prop oor:name="Extensions"><value>xlt</value></prop>
 		<prop oor:name="MediaType"><value>application/vnd.ms-excel</value></prop>

Modified: incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_5095.xcu
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_5095.xcu?rev=1167327&r1=1167326&r2=1167327&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_5095.xcu (original)
+++ incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_5095.xcu Fri
Sep  9 18:51:55 2011
@@ -1,5 +1,5 @@
 	<node oor:name="calc_MS_Excel_5095" oor:op="replace" >
-		<prop oor:name="DetectService"><value>com.sun.star.comp.oox.xls.BiffDetector</value></prop>
+		<prop oor:name="DetectService"><value>com.sun.star.comp.calc.FormatDetector</value></prop>
 		<prop oor:name="URLPattern"/>
 		<prop oor:name="Extensions"><value>xls xlc xlm xlw</value></prop>
 		<prop oor:name="MediaType"><value>application/vnd.ms-excel</value></prop>

Modified: incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_5095_VorlageTemplate.xcu
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_5095_VorlageTemplate.xcu?rev=1167327&r1=1167326&r2=1167327&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_5095_VorlageTemplate.xcu
(original)
+++ incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_5095_VorlageTemplate.xcu
Fri Sep  9 18:51:55 2011
@@ -1,5 +1,5 @@
 	<node oor:name="calc_MS_Excel_5095_VorlageTemplate" oor:op="replace" >
-		<prop oor:name="DetectService"><value>com.sun.star.comp.oox.xls.BiffDetector</value></prop>
+		<prop oor:name="DetectService"><value>com.sun.star.comp.calc.FormatDetector</value></prop>
 		<prop oor:name="URLPattern"/>
 		<prop oor:name="Extensions"><value>xlt</value></prop>
 		<prop oor:name="MediaType"><value>application/vnd.ms-excel</value></prop>

Modified: incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_95.xcu
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_95.xcu?rev=1167327&r1=1167326&r2=1167327&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_95.xcu (original)
+++ incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_95.xcu Fri
Sep  9 18:51:55 2011
@@ -1,5 +1,5 @@
 	<node oor:name="calc_MS_Excel_95" oor:op="replace" >
-		<prop oor:name="DetectService"><value>com.sun.star.comp.oox.xls.BiffDetector</value></prop>
+		<prop oor:name="DetectService"><value>com.sun.star.comp.calc.FormatDetector</value></prop>
 		<prop oor:name="URLPattern"/>
 		<prop oor:name="Extensions"><value>xls xlc xlm xlw</value></prop>
 		<prop oor:name="MediaType"><value>application/vnd.ms-excel</value></prop>

Modified: incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_95_VorlageTemplate.xcu
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_95_VorlageTemplate.xcu?rev=1167327&r1=1167326&r2=1167327&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_95_VorlageTemplate.xcu
(original)
+++ incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_95_VorlageTemplate.xcu
Fri Sep  9 18:51:55 2011
@@ -1,5 +1,5 @@
 	<node oor:name="calc_MS_Excel_95_VorlageTemplate" oor:op="replace" >
-		<prop oor:name="DetectService"><value>com.sun.star.comp.oox.xls.BiffDetector</value></prop>
+		<prop oor:name="DetectService"><value>com.sun.star.comp.calc.FormatDetector</value></prop>
 		<prop oor:name="URLPattern"/>
 		<prop oor:name="Extensions"><value>xlt</value></prop>
 		<prop oor:name="MediaType"><value>application/vnd.ms-excel</value></prop>

Modified: incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_97.xcu
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_97.xcu?rev=1167327&r1=1167326&r2=1167327&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_97.xcu (original)
+++ incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_97.xcu Fri
Sep  9 18:51:55 2011
@@ -1,5 +1,5 @@
 	<node oor:name="calc_MS_Excel_97" oor:op="replace" >
-		<prop oor:name="DetectService"><value>com.sun.star.comp.oox.xls.BiffDetector</value></prop>
+		<prop oor:name="DetectService"><value>com.sun.star.comp.calc.FormatDetector</value></prop>
 		<prop oor:name="URLPattern"/>
 		<prop oor:name="Extensions"><value>xls xlc xlm xlw</value></prop>
 		<prop oor:name="MediaType"><value>application/vnd.ms-excel</value></prop>

Modified: incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_97_VorlageTemplate.xcu
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_97_VorlageTemplate.xcu?rev=1167327&r1=1167326&r2=1167327&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_97_VorlageTemplate.xcu
(original)
+++ incubator/ooo/trunk/main/filter/source/config/fragments/types/calc_MS_Excel_97_VorlageTemplate.xcu
Fri Sep  9 18:51:55 2011
@@ -1,5 +1,5 @@
 	<node oor:name="calc_MS_Excel_97_VorlageTemplate" oor:op="replace" >
-		<prop oor:name="DetectService"><value>com.sun.star.comp.oox.xls.BiffDetector</value></prop>
+		<prop oor:name="DetectService"><value>com.sun.star.comp.calc.FormatDetector</value></prop>
 		<prop oor:name="URLPattern"/>
 		<prop oor:name="Extensions"><value>xlt</value></prop>
 		<prop oor:name="MediaType"><value>application/vnd.ms-excel</value></prop>

Modified: incubator/ooo/trunk/main/sc/source/ui/unoobj/scdetect.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/unoobj/scdetect.cxx?rev=1167327&r1=1167326&r2=1167327&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/unoobj/scdetect.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/unoobj/scdetect.cxx Fri Sep  9 18:51:55 2011
@@ -117,6 +117,7 @@ static const sal_Char __FAR_DATA pFilter
 static const sal_Char __FAR_DATA pFilterEx95Temp[]	= "MS Excel 95 Vorlage/Template";
 static const sal_Char __FAR_DATA pFilterExcel97[]	= "MS Excel 97";
 static const sal_Char __FAR_DATA pFilterEx97Temp[]	= "MS Excel 97 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilterExcelXML[]  = "MS Excel 2003 XML";
 static const sal_Char __FAR_DATA pFilterDBase[]		= "dBase";
 static const sal_Char __FAR_DATA pFilterDif[]		= "DIF";
 static const sal_Char __FAR_DATA pFilterSylk[]		= "SYLK";
@@ -159,6 +160,35 @@ static sal_Bool lcl_MayBeAscii( SvStream
 	return nMask != 0;
 }
 
+static const SfxFilter* lcl_DetectExcelXML( SvStream& rStream, SfxFilterMatcher&
rMatcher )
+{
+    const SfxFilter* pFound = NULL;
+    rStream.Seek(STREAM_SEEK_TO_BEGIN);
+
+    const size_t nBufSize = 4000;
+    sal_uInt8 aBuffer[ nBufSize ];
+    sal_uLong nBytesRead = rStream.Read( aBuffer, nBufSize );
+    sal_uLong nXMLStart = 0;
+
+    // Skip UTF-8 BOM if present.
+    // No need to handle UTF-16 etc (also rejected in XMLFilterDetect).
+    if ( nBytesRead >= 3 && aBuffer[0] == 0xEF && aBuffer[1] == 0xBB &&
aBuffer[2] == 0xBF )
+        nXMLStart = 3;
+
+    if ( nBytesRead >= nXMLStart + 5 && rtl_compareMemory( aBuffer+nXMLStart,
"<?xml", 5 ) == 0 )
+    {
+        // Be consistent with XMLFilterDetect service: Check for presence of "Workbook" in
XML file.
+
+        rtl::OString aTryStr( "Workbook" );
+        rtl::OString aFileString(reinterpret_cast<const sal_Char*>(aBuffer), nBytesRead);
+
+        if (aFileString.indexOf(aTryStr) >= 0)
+            pFound = rMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterExcelXML)
);
+    }
+
+    return pFound;
+}
+
 static sal_Bool lcl_MayBeDBase( SvStream& rStream )
 {
     // Look for dbf marker, see connectivity/source/inc/dbase/DTable.hxx
@@ -754,7 +784,11 @@ static sal_Bool lcl_IsAnyXMLFilter( cons
                                 }
                                 else if ( bIsXLS && bMaybeText )
                                 {
-                                    pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterAscii)
);
+                                    // Detect Excel 2003 XML here only if XLS was preselected.
+                                    // The configured detection for Excel 2003 XML is still
in XMLFilterDetect.
+                                    pFilter = lcl_DetectExcelXML( rStr, aMatcher );
+                                    if (!pFilter)
+                                        pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterAscii)
);
                                     bFakeXLS = true;
                                 }
                                 else if ( aHeader.CompareTo( "{\\rtf", 5 ) == COMPARE_EQUAL
)



Mime
View raw message