scdetect.cxx (cdf0e10c) scdetect.cxx (fd9eb3f2)
1/*************************************************************************
2 *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
6 *
7 * OpenOffice.org - a multi-platform office productivity suite
8 *

--- 103 unchanged lines hidden (view full) ---

112static const sal_Char __FAR_DATA pFilterExcel4[] = "MS Excel 4.0";
113static const sal_Char __FAR_DATA pFilterEx4Temp[] = "MS Excel 4.0 Vorlage/Template";
114static const sal_Char __FAR_DATA pFilterExcel5[] = "MS Excel 5.0/95";
115static const sal_Char __FAR_DATA pFilterEx5Temp[] = "MS Excel 5.0/95 Vorlage/Template";
116static const sal_Char __FAR_DATA pFilterExcel95[] = "MS Excel 95";
117static const sal_Char __FAR_DATA pFilterEx95Temp[] = "MS Excel 95 Vorlage/Template";
118static const sal_Char __FAR_DATA pFilterExcel97[] = "MS Excel 97";
119static const sal_Char __FAR_DATA pFilterEx97Temp[] = "MS Excel 97 Vorlage/Template";
1/*************************************************************************
2 *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
6 *
7 * OpenOffice.org - a multi-platform office productivity suite
8 *

--- 103 unchanged lines hidden (view full) ---

112static const sal_Char __FAR_DATA pFilterExcel4[] = "MS Excel 4.0";
113static const sal_Char __FAR_DATA pFilterEx4Temp[] = "MS Excel 4.0 Vorlage/Template";
114static const sal_Char __FAR_DATA pFilterExcel5[] = "MS Excel 5.0/95";
115static const sal_Char __FAR_DATA pFilterEx5Temp[] = "MS Excel 5.0/95 Vorlage/Template";
116static const sal_Char __FAR_DATA pFilterExcel95[] = "MS Excel 95";
117static const sal_Char __FAR_DATA pFilterEx95Temp[] = "MS Excel 95 Vorlage/Template";
118static const sal_Char __FAR_DATA pFilterExcel97[] = "MS Excel 97";
119static const sal_Char __FAR_DATA pFilterEx97Temp[] = "MS Excel 97 Vorlage/Template";
120static const sal_Char __FAR_DATA pFilterExcelXML[] = "MS Excel 2003 XML";
120static const sal_Char __FAR_DATA pFilterDBase[] = "dBase";
121static const sal_Char __FAR_DATA pFilterDif[] = "DIF";
122static const sal_Char __FAR_DATA pFilterSylk[] = "SYLK";
123static const sal_Char __FAR_DATA pFilterHtml[] = "HTML (StarCalc)";
124static const sal_Char __FAR_DATA pFilterHtmlWeb[] = "calc_HTML_WebQuery";
125static const sal_Char __FAR_DATA pFilterRtf[] = "Rich Text Format (StarCalc)";
126
127

--- 26 unchanged lines hidden (view full) ---

154 nMask &= 0xff00;
155 if (!(nVal & 0xff00))
156 nMask &= 0x00ff;
157 }
158
159 return nMask != 0;
160}
161
121static const sal_Char __FAR_DATA pFilterDBase[] = "dBase";
122static const sal_Char __FAR_DATA pFilterDif[] = "DIF";
123static const sal_Char __FAR_DATA pFilterSylk[] = "SYLK";
124static const sal_Char __FAR_DATA pFilterHtml[] = "HTML (StarCalc)";
125static const sal_Char __FAR_DATA pFilterHtmlWeb[] = "calc_HTML_WebQuery";
126static const sal_Char __FAR_DATA pFilterRtf[] = "Rich Text Format (StarCalc)";
127
128

--- 26 unchanged lines hidden (view full) ---

155 nMask &= 0xff00;
156 if (!(nVal & 0xff00))
157 nMask &= 0x00ff;
158 }
159
160 return nMask != 0;
161}
162
163static const SfxFilter* lcl_DetectExcelXML( SvStream& rStream, SfxFilterMatcher& rMatcher )
164{
165 const SfxFilter* pFound = NULL;
166 rStream.Seek(STREAM_SEEK_TO_BEGIN);
167
168 const size_t nBufSize = 4000;
169 sal_uInt8 aBuffer[ nBufSize ];
170 sal_uLong nBytesRead = rStream.Read( aBuffer, nBufSize );
171 sal_uLong nXMLStart = 0;
172
173 // Skip UTF-8 BOM if present.
174 // No need to handle UTF-16 etc (also rejected in XMLFilterDetect).
175 if ( nBytesRead >= 3 && aBuffer[0] == 0xEF && aBuffer[1] == 0xBB && aBuffer[2] == 0xBF )
176 nXMLStart = 3;
177
178 if ( nBytesRead >= nXMLStart + 5 && rtl_compareMemory( aBuffer+nXMLStart, "<?xml", 5 ) == 0 )
179 {
180 // Be consistent with XMLFilterDetect service: Check for presence of "Workbook" in XML file.
181
182 rtl::OString aTryStr( "Workbook" );
183 rtl::OString aFileString(reinterpret_cast<const sal_Char*>(aBuffer), nBytesRead);
184
185 if (aFileString.indexOf(aTryStr) >= 0)
186 pFound = rMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterExcelXML) );
187 }
188
189 return pFound;
190}
191
162static sal_Bool lcl_MayBeDBase( SvStream& rStream )
163{
164 // Look for dbf marker, see connectivity/source/inc/dbase/DTable.hxx
165 // DBFType for values.
166 const sal_uInt8 nValidMarks[] = {
167 0x03, 0x04, 0x05, 0x30, 0x43, 0xB3, 0x83, 0x8b, 0x8e, 0xf5 };
168 sal_uInt8 nMark;
169 rStream.Seek(STREAM_SEEK_TO_BEGIN);

--- 579 unchanged lines hidden (view full) ---

749 {
750 pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterHtmlWeb) );
751 if ( bIsXLS )
752 bFakeXLS = true;
753 }
754 }
755 else if ( bIsXLS && bMaybeText )
756 {
192static sal_Bool lcl_MayBeDBase( SvStream& rStream )
193{
194 // Look for dbf marker, see connectivity/source/inc/dbase/DTable.hxx
195 // DBFType for values.
196 const sal_uInt8 nValidMarks[] = {
197 0x03, 0x04, 0x05, 0x30, 0x43, 0xB3, 0x83, 0x8b, 0x8e, 0xf5 };
198 sal_uInt8 nMark;
199 rStream.Seek(STREAM_SEEK_TO_BEGIN);

--- 579 unchanged lines hidden (view full) ---

779 {
780 pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterHtmlWeb) );
781 if ( bIsXLS )
782 bFakeXLS = true;
783 }
784 }
785 else if ( bIsXLS && bMaybeText )
786 {
757 pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterAscii) );
787 // Detect Excel 2003 XML here only if XLS was preselected.
788 // The configured detection for Excel 2003 XML is still in XMLFilterDetect.
789 pFilter = lcl_DetectExcelXML( rStr, aMatcher );
790 if (!pFilter)
791 pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterAscii) );
758 bFakeXLS = true;
759 }
760 else if ( aHeader.CompareTo( "{\\rtf", 5 ) == COMPARE_EQUAL )
761 {
762 // test for RTF
763 pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterRtf) );
764 }
765 else if ( pPreselectedFilter->GetName().EqualsAscii(pFilterDBase) && lcl_MayBeDBase( rStr ) )

--- 149 unchanged lines hidden ---
792 bFakeXLS = true;
793 }
794 else if ( aHeader.CompareTo( "{\\rtf", 5 ) == COMPARE_EQUAL )
795 {
796 // test for RTF
797 pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterRtf) );
798 }
799 else if ( pPreselectedFilter->GetName().EqualsAscii(pFilterDBase) && lcl_MayBeDBase( rStr ) )

--- 149 unchanged lines hidden ---