Kaydet (Commit) 96c82514 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

fdo#60562: List *all* format types that we support and rank them all properly.

I did my best to check each and every one of them and rank them to the
best of my ability.  Any mistakes are to be fixed as they are discovered.

Note that while working on this, I've noticed that we don't actually have
any real type detection codes for many of these format types, especially
the graphic file formats.  If we ever have trouble loading any file type,
check if it's caused by not having any detection code for it, and if so,
we should write one for that file type.  That said, my casual tests on
loading graphic files didn't cause any trouble.

Change-Id: I1398cbb72b2d4ccf75434a9aa0d2a5c5d17bdaad
üst c9fbcaa0
...@@ -127,11 +127,23 @@ int getFlatTypeRank(const rtl::OUString& rType) ...@@ -127,11 +127,23 @@ int getFlatTypeRank(const rtl::OUString& rType)
// List formats from more complex to less complex. // List formats from more complex to less complex.
// TODO: Add more. // TODO: Add more.
static const char* ranks[] = { static const char* ranks[] = {
// Compressed XML
// Compressed XML (ODF XML zip formats)
"writer8_template", "writer8_template",
"writer8", "writer8",
"calc8_template", "calc8_template",
"calc8", "calc8",
"impress8_template",
"impress8",
"draw8_template",
"draw8",
"chart8",
"math8",
"writerglobal8",
"writerweb8_writer_template",
"StarBase",
// Compressed XML (OOXML)
"writer_OOXML_Text_Template", "writer_OOXML_Text_Template",
"writer_OOXML", "writer_OOXML",
"writer_MS_Word_2007_Template", "writer_MS_Word_2007_Template",
...@@ -140,6 +152,28 @@ int getFlatTypeRank(const rtl::OUString& rType) ...@@ -140,6 +152,28 @@ int getFlatTypeRank(const rtl::OUString& rType)
"Office Open XML Spreadsheet", "Office Open XML Spreadsheet",
"MS Excel 2007 XML Template", "MS Excel 2007 XML Template",
"MS Excel 2007 XML", "MS Excel 2007 XML",
"MS PowerPoint 2007 XML Template",
"MS PowerPoint 2007 XML AutoPlay",
"MS PowerPoint 2007 XML",
// Compressed XML (Uniform/Unified Office Format)
"Unified_Office_Format_text",
"Unified_Office_Format_spreadsheet",
"Unified_Office_Format_presentation",
// Compressed XML (StarOffice XML zip formats)
"calc_StarOffice_XML_Calc",
"calc_StarOffice_XML_Calc_Template",
"chart_StarOffice_XML_Chart",
"draw_StarOffice_XML_Draw",
"draw_StarOffice_XML_Draw_Template",
"impress_StarOffice_XML_Impress",
"impress_StarOffice_XML_Impress_Template",
"math_StarOffice_XML_Math",
"writer_StarOffice_XML_Writer",
"writer_StarOffice_XML_Writer_Template",
"writer_globaldocument_StarOffice_XML_Writer_GlobalDocument",
"writer_web_StarOffice_XML_Writer_Web_Template",
// Compressed text // Compressed text
"pdf_Portable_Document_Format", "pdf_Portable_Document_Format",
...@@ -164,24 +198,83 @@ int getFlatTypeRank(const rtl::OUString& rType) ...@@ -164,24 +198,83 @@ int getFlatTypeRank(const rtl::OUString& rType)
"calc_MS_Excel_40_VorlageTemplate", "calc_MS_Excel_40_VorlageTemplate",
"calc_MS_Excel_40", "calc_MS_Excel_40",
"calc_Pocket_Excel_File", "calc_Pocket_Excel_File",
"impress_MS_PowerPoint_97_Vorlage",
"impress_MS_PowerPoint_97_AutoPlay",
"impress_MS_PowerPoint_97",
"calc_Lotus", "calc_Lotus",
"calc_QPro", "calc_QPro",
"calc_SYLK", "calc_SYLK",
"calc_DIF", "calc_DIF",
"calc_dBase", "calc_dBase",
// Binary (raster and vector image files)
"emf_MS_Windows_Metafile",
"wmf_MS_Windows_Metafile",
"met_OS2_Metafile",
"svm_StarView_Metafile",
"sgv_StarDraw_20",
"tif_Tag_Image_File",
"tga_Truevision_TARGA",
"sgf_StarOffice_Writer_SGF",
"ras_Sun_Rasterfile",
"psd_Adobe_Photoshop",
"png_Portable_Network_Graphic",
"jpg_JPEG",
"gif_Graphics_Interchange",
"bmp_MS_Windows",
"pcx_Zsoft_Paintbrush",
"pct_Mac_Pict",
"pcd_Photo_CD_Base",
"pcd_Photo_CD_Base4",
"pcd_Photo_CD_Base16",
"impress_CGM_Computer_Graphics_Metafile", // There is binary and ascii variants ?
"draw_WordPerfect_Graphics",
"draw_Visio_Document",
"draw_Publisher_Document",
"draw_Corel_Presentation_Exchange",
"draw_CorelDraw_Document",
"writer_LotusWordPro_Document",
"writer_MIZI_Hwp_97", // Hanword (Hancom Office)
// Non-compressed XML // Non-compressed XML
"writer_ODT_FlatXML", "writer_ODT_FlatXML",
"calc_ODS_FlatXML", "calc_ODS_FlatXML",
"impress_ODP_FlatXML",
"draw_ODG_FlatXML",
"calc_MS_Excel_2003_XML", "calc_MS_Excel_2003_XML",
"writer_MS_Word_2003_XML", "writer_MS_Word_2003_XML",
"writer_DocBook_File", "writer_DocBook_File",
"XHTML_File", "XHTML_File",
"svg_Scalable_Vector_Graphics",
"math_MathML_XML_Math",
// Non-compressed text // Non-compressed text
"dxf_AutoCAD_Interchange",
"eps_Encapsulated_PostScript",
"pbm_Portable_Bitmap", // There is 'raw' and 'ascii' variants.
"ppm_Portable_Pixelmap", // There is 'raw' and 'ascii' variants.
"pgm_Portable_Graymap", // There is 'raw' and 'ascii' variants.
"xpm_XPM",
"xbm_X_Consortium",
"writer_Rich_Text_Format", "writer_Rich_Text_Format",
"writer_web_HTML_help",
"generic_HTML", "generic_HTML",
"generic_Text"
"generic_Text", // Plain text (catch all)
// Anything ranked lower than generic_Text will never be used during
// type detection (since generic_Text catches all).
// Export only
"writer_layout_dump_xml",
"pwp_PlaceWare",
"graphic_SWF",
"graphic_HTML",
// Internal use only
"StarBaseReportChart",
"StarBaseReport",
"math_MathType_3x", // MathType equation embedded in Word doc.
}; };
size_t n = SAL_N_ELEMENTS(ranks); size_t n = SAL_N_ELEMENTS(ranks);
...@@ -832,7 +925,7 @@ void TypeDetection::impl_getPreselection( ...@@ -832,7 +925,7 @@ void TypeDetection::impl_getPreselection(
++pFlatIt ) ++pFlatIt )
{ {
const FlatDetectionInfo& aFlatTypeInfo = *pFlatIt; const FlatDetectionInfo& aFlatTypeInfo = *pFlatIt;
::rtl::OUString sFlatType = aFlatTypeInfo.sType; OUString sFlatType = aFlatTypeInfo.sType;
if (!impl_validateAndSetTypeOnDescriptor(rDescriptor, sFlatType)) if (!impl_validateAndSetTypeOnDescriptor(rDescriptor, sFlatType))
continue; continue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment