[Libreoffice-commits] .: 7 commits - filter/Configuration_filter.mk filter/Library_textfd.mk filter/Module_filter.mk filter/qa filter/source filter/type-detection-debug.diff postprocess/packcomponents qadevOOo/tests Repository.mk scp2/source sc/qa sc/source sc/workben
Kohei Yoshida
kohei at kemper.freedesktop.org
Thu May 24 23:04:57 PDT 2012
Repository.mk | 1
filter/Configuration_filter.mk | 8
filter/Library_textfd.mk | 58 +++
filter/Module_filter.mk | 1
filter/qa/complex/filter/detection/typeDetection/TypeDetection.java | 6
filter/qa/complex/filter/detection/typeDetection/files.csv | 34 +-
filter/qa/complex/filter/detection/typeDetection/preselectedFilter.csv | 10
filter/qa/complex/filter/detection/typeDetection/preselectedType.csv | 6
filter/qa/complex/filter/detection/typeDetection/serviceName.csv | 4
filter/source/config/cache/typedetection.cxx | 23 +
filter/source/config/fragments/filters/Text.xcu | 2
filter/source/config/fragments/filters/Text__StarWriter_Web_.xcu | 2
filter/source/config/fragments/filters/Text___txt___csv__StarCalc_.xcu | 2
filter/source/config/fragments/filters/Text__encoded___StarWriter_GlobalDocument_.xcu | 2
filter/source/config/fragments/filters/Text__encoded___StarWriter_Web_.xcu | 2
filter/source/config/fragments/types/calc_Text_txt_csv_StarCalc.xcu | 12
filter/source/config/fragments/types/generic_Text.xcu | 11
filter/source/config/fragments/types/writer_Text.xcu | 12
filter/source/textfilterdetect/fdcomp.cxx | 72 ++++
filter/source/textfilterdetect/filterdetect.cxx | 169 ++++++++++
filter/source/textfilterdetect/filterdetect.hxx | 83 ++++
filter/source/textfilterdetect/textfd.component | 36 ++
filter/type-detection-debug.diff | 135 +++++++
postprocess/packcomponents/makefile.mk | 1
qadevOOo/tests/java/mod/_fwl/TypeDetection.java | 2
sc/qa/unit/subsequent_filters-test.cxx | 2
sc/source/ui/vba/vbaworkbooks.cxx | 5
sc/workben/dpcache/perf-test |binary
scp2/source/ooo/file_library_ooo.scp | 1
29 files changed, 633 insertions(+), 69 deletions(-)
New commits:
commit f0cb3e97d2f9b5592837903d8d8ed8aaeb130c55
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri May 25 01:39:52 2012 -0400
Removed writer_Text type; combined it with generic_Text.
Change-Id: Id7d5744af4800ef5ac6bd70b97f79a76299a2e6b
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index 4709bc2..0c22296 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -328,7 +328,7 @@ $(call filter_Configuration_add_types,fcfg_langpack,fcfg_writer_types.xcu,filter
writer_MS_Works_Document \
writer_T602_Document \
writer_LotusWordPro_Document \
- writer_Text \
+ generic_Text \
writer_Text_encoded \
writer_MIZI_Hwp_97 \
writer_StarOffice_XML_Writer_Template \
@@ -394,7 +394,7 @@ $(call filter_Configuration_add_ui_filters,fcfg_langpack,filter/source/config/fr
# fcfg_web
$(call filter_Configuration_add_types,fcfg_langpack,fcfg_web_types.xcu,filter/source/config/fragments/types,\
generic_HTML \
- writer_Text \
+ generic_Text \
writer_web_HTML_help \
writer_StarOffice_XML_Writer \
writer_web_StarOffice_XML_Writer_Web_Template \
@@ -427,7 +427,6 @@ $(call filter_Configuration_add_ui_filters,fcfg_langpack,filter/source/config/fr
# fcfg_global
$(call filter_Configuration_add_types,fcfg_langpack,fcfg_global_types.xcu,filter/source/config/fragments/types,\
generic_Text \
- writer_Text \
writer_StarOffice_XML_Writer \
writer_globaldocument_StarOffice_XML_Writer_GlobalDocument \
pdf_Portable_Document_Format \
@@ -456,6 +455,7 @@ $(call filter_Configuration_add_ui_filters,fcfg_langpack,filter/source/config/fr
$(call filter_Configuration_add_types,fcfg_langpack,fcfg_calc_types.xcu,filter/source/config/fragments/types,\
calc_DIF \
generic_HTML \
+ generic_Text \
calc_Lotus \
calc_QPro \
calc_MS_Excel_40 \
diff --git a/filter/qa/complex/filter/detection/typeDetection/TypeDetection.java b/filter/qa/complex/filter/detection/typeDetection/TypeDetection.java
index f706c41..d8e98a8 100644
--- a/filter/qa/complex/filter/detection/typeDetection/TypeDetection.java
+++ b/filter/qa/complex/filter/detection/typeDetection/TypeDetection.java
@@ -100,7 +100,7 @@ import util.utils;
* Example:
*
* Writer6_1;Writer/Writer6.sxw;writer_StarOffice_XML_Writer;writer_StarOffice_XML_Writer
- * text1;Writer/Text.txt;writer_Text_encoded:writer_Text;writer_Text_encoded:writer_Text
+ * text1;Writer/Text.txt;writer_Text_encoded:generic_Text;writer_Text_encoded:generic_Text
*
* The first example shows you the following:
* <code>Writer6_1</code> is a free chosen name
@@ -110,10 +110,10 @@ import util.utils;
* this file
*
* The second example displays two document types for <code>XInputStream</CODE>
- * (<code>writer_Text_encoded</CODE> and <code>writer_Text</CODE>. This two
+ * (<code>writer_Text_encoded</CODE> and <code>generic_Text</CODE>. This two
* document types are listed by a colon ':' as separator. This is needed because
* XInputStream can detect a text file as writer_Text_encoded as well as
- * writer_Text.
+ * generic_Text.
* <p>
*
* <H3><A name="preselectedFilter.csv"</a>
diff --git a/filter/qa/complex/filter/detection/typeDetection/files.csv b/filter/qa/complex/filter/detection/typeDetection/files.csv
index f5dafdd..9a3cb3b 100644
--- a/filter/qa/complex/filter/detection/typeDetection/files.csv
+++ b/filter/qa/complex/filter/detection/typeDetection/files.csv
@@ -10,7 +10,7 @@ fileAlias;fileURL;defaultFileType;streamFileType
# W R I T E R D O C U M E N T S
#################################
rtf1;Writer/AoE2a.rtf;writer_Rich_Text_Format;writer_Rich_Text_Format;writer_Rich_Text_Format
-text1;Writer/Text_DOS.txt;writer_Text_encoded:writer_Text;writer_Text_encoded:writer_Text
+text1;Writer/Text_DOS.txt;writer_Text_encoded:generic_Text;writer_Text_encoded:generic_Text
Word2000_document;Writer/Word2000.doc;writer_MS_Word_97;writer_MS_Word_97
Word2000_template;Writer/Word2000_template.dot;writer_MS_Word_97_Vorlage;writer_MS_Word_97_Vorlage
Word6_document;Writer/Word6.doc;writer_MS_WinWord_60;writer_MS_WinWord_60
@@ -29,24 +29,24 @@ Writer5_template;Writer/Writer5_template.vor;writer_StarWriter_50_VorlageTemplat
Writer6_document;Writer/Writer6.sxw;writer_StarOffice_XML_Writer;writer_StarOffice_XML_Writer
Writer6_template;Writer/Writer6_template.stw;writer_StarOffice_XML_Writer_Template;writer_StarOffice_XML_Writer
Writer6_html;Writer/WriterWeb.html;generic_HTML;generic_HTML
-ApiPro3;Writer/AmiPro_3x.sam;writer_Text_encoded:writer_Text;writer_Text_encoded:writer_Text
-Applix;Writer/Applix.aw;writer_Text_encoded:writer_Text;writer_Text_encoded:writer_Text
-Text2;Writer/Counterstrike I.txt;writer_Text_encoded:writer_Text;writer_Text_encoded:writer_Text
-FrameMake_document;Writer/FrameMaker.mif;writer_Text_encoded:writer_Text;writer_Text_encoded:writer_Text
-WordPro_Hangul;Writer/HangulWordPro.hwp;writer_Text_encoded:writer_Text;writer_Text_encoded:writer_Text
+ApiPro3;Writer/AmiPro_3x.sam;writer_Text_encoded:generic_Text;writer_Text_encoded:generic_Text
+Applix;Writer/Applix.aw;writer_Text_encoded:generic_Text;writer_Text_encoded:generic_Text
+Text2;Writer/Counterstrike I.txt;writer_Text_encoded:generic_Text;writer_Text_encoded:generic_Text
+FrameMake_document;Writer/FrameMaker.mif;writer_Text_encoded:generic_Text;writer_Text_encoded:generic_Text
+WordPro_Hangul;Writer/HangulWordPro.hwp;writer_Text_encoded:generic_Text;writer_Text_encoded:generic_Text
Ichitaro;Writer/Ichitaro.jtd;writer_JustSystem_Ichitaro_10;writer_JustSystem_Ichitaro_10
-MacWord5_document;Writer/MacWord_5.mcw;writer_Text_encoded:writer_Text;writer_Text_encoded:writer_Text
+MacWord5_document;Writer/MacWord_5.mcw;writer_Text_encoded:generic_Text;writer_Text_encoded:generic_Text
rtf2;Writer/RTF.rtf;writer_Rich_Text_Format;writer_Rich_Text_Format
wps2000_document;Writer/WPS_2000.wps;writer_WPSSystem_WPS2000_10;writer_WPSSystem_WPS2000_10
-WinWord2_document;Writer/WinWord_2x.doc;writer_Text_encoded:writer_Text;writer_Text_encoded:writer_Text
+WinWord2_document;Writer/WinWord_2x.doc;writer_Text_encoded:generic_Text;writer_Text_encoded:generic_Text
WinWord6_95_document;Writer/WinWord_6_95.doc;writer_MS_WinWord_60;writer_MS_WinWord_60
WinWord97_2000_XP_document;Writer/Winword_97_2000_xp.doc;writer_MS_Word_97;writer_MS_Word_97
-WordPerfect;Writer/WordPerfect.wpd;writer_Text_encoded:writer_Text;writer_Text_encoded:writer_Text
-csv2;Writer/Text_CSV.txt;writer_Text_encoded:writer_Text;writer_Text_encoded:writer_Text
+WordPerfect;Writer/WordPerfect.wpd;writer_Text_encoded:generic_Text;writer_Text_encoded:generic_Text
+csv2;Writer/Text_CSV.txt;writer_Text_encoded:generic_Text;writer_Text_encoded:generic_Text
###################################
# C A L C D O C U M E N T S
##################################
-csv1;Calc/Text_CSV.csv;generic_Text;writer_Text_encoded:writer_Text
+csv1;Calc/Text_CSV.csv;generic_Text;writer_Text_encoded:generic_Text
Calc1;Calc/Calc1.SDC;calc_StarCalc_10;calc_StarCalc_10
Calc2_document;Calc/Calc3.SDC;calc_StarCalc_30_VorlageTemplate;calc_StarCalc_30
Calc2_template;Calc/Calc3.vor;calc_StarCalc_30;calc_StarCalc_30
@@ -56,7 +56,7 @@ Calc5_document;Calc/Calc5.sdc;calc_StarCalc_50;calc_StarCalc_50
Calc5_template;Calc/Calc5.vor;calc_StarCalc_50_VorlageTemplate;calc_StarCalc_50
Calc6_document;Calc/Calc_6.stc;calc_StarOffice_XML_Calc;calc_StarOffice_XML_Calc
Calc6_template;Calc/Calc_6.sxc;calc_StarOffice_XML_Calc_Template;calc_StarOffice_XML_Calc
-dif;Calc/DIF.DIF;calc_DIF;writer_Text_encoded:writer_Text
+dif;Calc/DIF.DIF;calc_DIF;writer_Text_encoded:generic_Text
Excel2;Calc/Excel2.XLS;calc_MS_Excel_40;calc_MS_Excel_40
Excel3;Calc/Excel3.XLS;calc_MS_Excel_40;calc_MS_Excel_40
Excel4_document;Calc/Excel4.XLS;calc_MS_Excel_40;calc_MS_Excel_40
@@ -99,19 +99,19 @@ Impress5_template;Impress/imp9.vor;impress_StarImpress_50_Vorlage;impress_StarIm
# G R A P H I C S
######################################################
bitmap;Graphics/pic.bmp;bmp_MS_Windows;bmp_MS_Windows
-emf;Graphics/pic.emf;emf_MS_Windows_Metafile;emf_MS_Windows_Metafile:writer_Text_encoded:writer_Text
+emf;Graphics/pic.emf;emf_MS_Windows_Metafile;emf_MS_Windows_Metafile:writer_Text_encoded:generic_Text
eps;Graphics/pic.eps;eps_Encapsulated_PostScript;eps_Encapsulated_PostScript
gif;Graphics/pic.gif;gif_Graphics_Interchange;gif_Graphics_Interchange
jpg;Graphics/pic.jpg;jpg_JPEG;jpg_JPEG
-met;Graphics/pic.met;met_OS2_Metafile;met_OS2_Metafile:writer_Text_encoded:writer_Text
+met;Graphics/pic.met;met_OS2_Metafile;met_OS2_Metafile:writer_Text_encoded:generic_Text
pbm;Graphics/pic.pbm;pbm_Portable_Bitmap;pbm_Portable_Bitmap
pct;Graphics/pic.pct;pct_Mac_Pict;pct_Mac_Pict
pgm;Graphics/pic.pgm;pgm_Portable_Graymap;pgm_Portable_Graymap
png;Graphics/pic.png;png_Portable_Network_Graphic;png_Portable_Network_Graphic
ppm;Graphics/pic.ppm;ppm_Portable_Pixelmap;ppm_Portable_Pixelmap
ras;Graphics/pic.ras;ras_Sun_Rasterfile;ras_Sun_Rasterfile
-svm;Graphics/pic.svm;svm_StarView_Metafile;svm_StarView_Metafile:writer_Text_encoded:writer_Text
-tif;Graphics/pic.tif;tif_Tag_Image_File;tif_Tag_Image_File:writer_Text_encoded:writer_Text
-wmf;Graphics/pic.wmf;wmf_MS_Windows_Metafile;wmf_MS_Windows_Metafile:writer_Text_encoded:writer_Text
+svm;Graphics/pic.svm;svm_StarView_Metafile;svm_StarView_Metafile:writer_Text_encoded:generic_Text
+tif;Graphics/pic.tif;tif_Tag_Image_File;tif_Tag_Image_File:writer_Text_encoded:generic_Text
+wmf;Graphics/pic.wmf;wmf_MS_Windows_Metafile;wmf_MS_Windows_Metafile:writer_Text_encoded:generic_Text
diff --git a/filter/qa/complex/filter/detection/typeDetection/preselectedFilter.csv b/filter/qa/complex/filter/detection/typeDetection/preselectedFilter.csv
index 827e1ee..c7055a2 100644
--- a/filter/qa/complex/filter/detection/typeDetection/preselectedFilter.csv
+++ b/filter/qa/complex/filter/detection/typeDetection/preselectedFilter.csv
@@ -1,6 +1,6 @@
fileAlias;FilterName;FilterOptions;FilterData;expectedFileType
-text1;%SO6productname %SO6formatversion Textdokument;;;writer_Text_encoded:writer_Text
-csv1;%SO6productname %SO6formatversion Textdokument;;;writer_Text_encoded:writer_Text
+text1;%SO6productname %SO6formatversion Textdokument;;;writer_Text_encoded:generic_Text
+csv1;%SO6productname %SO6formatversion Textdokument;;;writer_Text_encoded:generic_Text
csv1;Text - txt - csv (StarCalc);;;generic_Text
-csv2;%SO6productname %SO6formatversion Textdokument;;;writer_Text_encoded:writer_Text
+csv2;%SO6productname %SO6formatversion Textdokument;;;writer_Text_encoded:generic_Text
csv2;Text - txt - csv (StarCalc);;;generic_Text
diff --git a/filter/qa/complex/filter/detection/typeDetection/preselectedType.csv b/filter/qa/complex/filter/detection/typeDetection/preselectedType.csv
index 701db33..ec6a6d8 100644
--- a/filter/qa/complex/filter/detection/typeDetection/preselectedType.csv
+++ b/filter/qa/complex/filter/detection/typeDetection/preselectedType.csv
@@ -1,6 +1,6 @@
fileAlias;preselectFileType;expectFileType
-csv1;writer_Text;writer_Text_encoded:writer_Text
+csv1;generic_Text;writer_Text_encoded:generic_Text
csv1;generic_Text;generic_Text
#csv2;writer_Text_encoded
#csv2;generic_Text
-text1;writer_Text_encoded;writer_Text_encoded:writer_Text
\ No newline at end of file
+text1;writer_Text_encoded;writer_Text_encoded:generic_Text
\ No newline at end of file
diff --git a/filter/source/config/fragments/filters/Text.xcu b/filter/source/config/fragments/filters/Text.xcu
index ac11931..4a703d3 100644
--- a/filter/source/config/fragments/filters/Text.xcu
+++ b/filter/source/config/fragments/filters/Text.xcu
@@ -4,7 +4,7 @@
<prop oor:name="FilterService"/>
<prop oor:name="UserData"><value>TEXT</value></prop>
<prop oor:name="FileFormatVersion"><value>0</value></prop>
- <prop oor:name="Type"><value>writer_Text</value></prop>
+ <prop oor:name="Type"><value>generic_Text</value></prop>
<prop oor:name="TemplateName"/>
<prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop>
</node>
diff --git a/filter/source/config/fragments/filters/Text__StarWriter_Web_.xcu b/filter/source/config/fragments/filters/Text__StarWriter_Web_.xcu
index 5161a52..29ad18a 100644
--- a/filter/source/config/fragments/filters/Text__StarWriter_Web_.xcu
+++ b/filter/source/config/fragments/filters/Text__StarWriter_Web_.xcu
@@ -4,7 +4,7 @@
<prop oor:name="FilterService"/>
<prop oor:name="UserData"><value>TEXT</value></prop>
<prop oor:name="FileFormatVersion"><value>0</value></prop>
- <prop oor:name="Type"><value>writer_Text</value></prop>
+ <prop oor:name="Type"><value>generic_Text</value></prop>
<prop oor:name="TemplateName"/>
<prop oor:name="DocumentService"><value>com.sun.star.text.WebDocument</value></prop>
</node>
diff --git a/filter/source/config/fragments/filters/Text__encoded___StarWriter_GlobalDocument_.xcu b/filter/source/config/fragments/filters/Text__encoded___StarWriter_GlobalDocument_.xcu
index 2c39de8..d4fd201 100644
--- a/filter/source/config/fragments/filters/Text__encoded___StarWriter_GlobalDocument_.xcu
+++ b/filter/source/config/fragments/filters/Text__encoded___StarWriter_GlobalDocument_.xcu
@@ -4,7 +4,7 @@
<prop oor:name="FilterService"/>
<prop oor:name="UserData"><value>TEXT_DLG</value></prop>
<prop oor:name="FileFormatVersion"><value>0</value></prop>
- <prop oor:name="Type"><value>writer_Text</value></prop>
+ <prop oor:name="Type"><value>generic_Text</value></prop>
<prop oor:name="TemplateName"/>
<prop oor:name="DocumentService"><value>com.sun.star.text.GlobalDocument</value></prop>
</node>
diff --git a/filter/source/config/fragments/filters/Text__encoded___StarWriter_Web_.xcu b/filter/source/config/fragments/filters/Text__encoded___StarWriter_Web_.xcu
index f8ced30..b347977 100644
--- a/filter/source/config/fragments/filters/Text__encoded___StarWriter_Web_.xcu
+++ b/filter/source/config/fragments/filters/Text__encoded___StarWriter_Web_.xcu
@@ -4,7 +4,7 @@
<prop oor:name="FilterService"/>
<prop oor:name="UserData"><value>TEXT_DLG</value></prop>
<prop oor:name="FileFormatVersion"><value>0</value></prop>
- <prop oor:name="Type"><value>writer_Text</value></prop>
+ <prop oor:name="Type"><value>generic_Text</value></prop>
<prop oor:name="TemplateName"/>
<prop oor:name="DocumentService"><value>com.sun.star.text.WebDocument</value></prop>
</node>
diff --git a/filter/source/config/fragments/types/writer_Text.xcu b/filter/source/config/fragments/types/writer_Text.xcu
deleted file mode 100644
index 014c73d..0000000
--- a/filter/source/config/fragments/types/writer_Text.xcu
+++ /dev/null
@@ -1,12 +0,0 @@
- <node oor:name="writer_Text" oor:op="replace" >
- <prop oor:name="DetectService"><value>com.sun.star.text.FormatDetector</value></prop>
- <prop oor:name="URLPattern"/>
- <prop oor:name="Extensions"><value>txt</value></prop>
- <prop oor:name="MediaType"><value>text/plain</value></prop>
- <prop oor:name="Preferred"><value>true</value></prop>
- <prop oor:name="PreferredFilter"><value>Text</value></prop>
- <prop oor:name="UIName">
- <value>Text</value>
- </prop>
- <prop oor:name="ClipboardFormat"/>
- </node>
diff --git a/qadevOOo/tests/java/mod/_fwl/TypeDetection.java b/qadevOOo/tests/java/mod/_fwl/TypeDetection.java
index 4a298e8..989f4c5 100644
--- a/qadevOOo/tests/java/mod/_fwl/TypeDetection.java
+++ b/qadevOOo/tests/java/mod/_fwl/TypeDetection.java
@@ -143,7 +143,7 @@ public class TypeDetection extends TestCase {
NamedValue[] querySequenze = new NamedValue[1];
NamedValue query = new NamedValue();
query.Name = "Name";
- query.Value = "writer_Text";
+ query.Value = "generic_Text";
querySequenze[0] = query;
diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx
index 2d2b042..00461b1 100644
--- a/sc/source/ui/vba/vbaworkbooks.cxx
+++ b/sc/source/ui/vba/vbaworkbooks.cxx
@@ -194,10 +194,9 @@ ScVbaWorkbooks::isTextFile( const rtl::OUString& sType )
// b) a csv file
// c) unknown
// returning true basically means treat this like a csv file
- const static rtl::OUString txtType( RTL_CONSTASCII_USTRINGPARAM("writer_Text" ) );
- const static rtl::OUString csvType("generic_Text");
+ const static rtl::OUString txtType("generic_Text");
const static rtl::OUString encodedTxtType( RTL_CONSTASCII_USTRINGPARAM("writer_Text_encoded" ) );
- return sType.equals( txtType ) || sType.equals( csvType ) || sType.isEmpty() || sType.equals( encodedTxtType );
+ return sType.equals( txtType ) || sType.isEmpty() || sType.equals( encodedTxtType );
}
bool
commit d6b68db264930528cf7ba3111f6f664fca10cfe3
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri May 25 01:18:42 2012 -0400
Renamed calc_Text_text_csv_StarCalc type to generic_Text.
Change-Id: Ica6aef56733c7c71568e37166a2f78d6aa05a118
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index f143840..4709bc2 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -426,6 +426,7 @@ $(call filter_Configuration_add_ui_filters,fcfg_langpack,filter/source/config/fr
# fcfg_global
$(call filter_Configuration_add_types,fcfg_langpack,fcfg_global_types.xcu,filter/source/config/fragments/types,\
+ generic_Text \
writer_Text \
writer_StarOffice_XML_Writer \
writer_globaldocument_StarOffice_XML_Writer_GlobalDocument \
@@ -468,7 +469,6 @@ $(call filter_Configuration_add_types,fcfg_langpack,fcfg_calc_types.xcu,filter/s
writer_Rich_Text_Format \
calc_SYLK \
calc_StarOffice_XML_Calc \
- calc_Text_txt_csv_StarCalc \
calc_StarOffice_XML_Calc_Template \
pdf_Portable_Document_Format \
calc_dBase\
diff --git a/filter/qa/complex/filter/detection/typeDetection/files.csv b/filter/qa/complex/filter/detection/typeDetection/files.csv
index eaad74e..f5dafdd 100644
--- a/filter/qa/complex/filter/detection/typeDetection/files.csv
+++ b/filter/qa/complex/filter/detection/typeDetection/files.csv
@@ -46,7 +46,7 @@ csv2;Writer/Text_CSV.txt;writer_Text_encoded:writer_Text;writer_Text_encoded:wri
###################################
# C A L C D O C U M E N T S
##################################
-csv1;Calc/Text_CSV.csv;calc_Text_txt_csv_StarCalc;writer_Text_encoded:writer_Text
+csv1;Calc/Text_CSV.csv;generic_Text;writer_Text_encoded:writer_Text
Calc1;Calc/Calc1.SDC;calc_StarCalc_10;calc_StarCalc_10
Calc2_document;Calc/Calc3.SDC;calc_StarCalc_30_VorlageTemplate;calc_StarCalc_30
Calc2_template;Calc/Calc3.vor;calc_StarCalc_30;calc_StarCalc_30
diff --git a/filter/qa/complex/filter/detection/typeDetection/preselectedFilter.csv b/filter/qa/complex/filter/detection/typeDetection/preselectedFilter.csv
index 71370e0..827e1ee 100644
--- a/filter/qa/complex/filter/detection/typeDetection/preselectedFilter.csv
+++ b/filter/qa/complex/filter/detection/typeDetection/preselectedFilter.csv
@@ -1,6 +1,6 @@
fileAlias;FilterName;FilterOptions;FilterData;expectedFileType
text1;%SO6productname %SO6formatversion Textdokument;;;writer_Text_encoded:writer_Text
csv1;%SO6productname %SO6formatversion Textdokument;;;writer_Text_encoded:writer_Text
-csv1;Text - txt - csv (StarCalc);;;calc_Text_txt_csv_StarCalc
+csv1;Text - txt - csv (StarCalc);;;generic_Text
csv2;%SO6productname %SO6formatversion Textdokument;;;writer_Text_encoded:writer_Text
-csv2;Text - txt - csv (StarCalc);;;calc_Text_txt_csv_StarCalc
+csv2;Text - txt - csv (StarCalc);;;generic_Text
diff --git a/filter/qa/complex/filter/detection/typeDetection/preselectedType.csv b/filter/qa/complex/filter/detection/typeDetection/preselectedType.csv
index 7fa0c24..701db33 100644
--- a/filter/qa/complex/filter/detection/typeDetection/preselectedType.csv
+++ b/filter/qa/complex/filter/detection/typeDetection/preselectedType.csv
@@ -1,6 +1,6 @@
fileAlias;preselectFileType;expectFileType
csv1;writer_Text;writer_Text_encoded:writer_Text
-csv1;calc_Text_txt_csv_StarCalc;calc_Text_txt_csv_StarCalc
+csv1;generic_Text;generic_Text
#csv2;writer_Text_encoded
-#csv2;calc_Text_txt_csv_StarCalc
+#csv2;generic_Text
text1;writer_Text_encoded;writer_Text_encoded:writer_Text
\ No newline at end of file
diff --git a/filter/qa/complex/filter/detection/typeDetection/serviceName.csv b/filter/qa/complex/filter/detection/typeDetection/serviceName.csv
index 744a5ac..34f941a 100644
--- a/filter/qa/complex/filter/detection/typeDetection/serviceName.csv
+++ b/filter/qa/complex/filter/detection/typeDetection/serviceName.csv
@@ -1,6 +1,6 @@
fileAlias;serviceName;expectedType
text1;com.sun.star.text.FormatDetector
csv1;com.sun.star.text.FormatDetector;writer_Text_encoded
-csv1;com.sun.star.comp.calc.FormatDetector;calc_Text_txt_csv_StarCalc
+csv1;com.sun.star.comp.filters.PlainTextFilterDetect;generic_Text
csv2;com.sun.star.text.FormatDetector;writer_Text_encoded
-csv2;com.sun.star.comp.calc.FormatDetector;calc_Text_txt_csv_StarCalc
+csv2;com.sun.star.comp.filters.PlainTextFilterDetect;generic_Text
diff --git a/filter/source/config/fragments/filters/Text___txt___csv__StarCalc_.xcu b/filter/source/config/fragments/filters/Text___txt___csv__StarCalc_.xcu
index 69b4ff7..f15fe5a 100644
--- a/filter/source/config/fragments/filters/Text___txt___csv__StarCalc_.xcu
+++ b/filter/source/config/fragments/filters/Text___txt___csv__StarCalc_.xcu
@@ -4,7 +4,7 @@
<prop oor:name="FilterService"/>
<prop oor:name="UserData"><value></value></prop>
<prop oor:name="FileFormatVersion"><value>0</value></prop>
- <prop oor:name="Type"><value>calc_Text_txt_csv_StarCalc</value></prop>
+ <prop oor:name="Type"><value>generic_Text</value></prop>
<prop oor:name="TemplateName"/>
<prop oor:name="DocumentService"><value>com.sun.star.sheet.SpreadsheetDocument</value></prop>
</node>
diff --git a/filter/source/config/fragments/types/calc_Text_txt_csv_StarCalc.xcu b/filter/source/config/fragments/types/calc_Text_txt_csv_StarCalc.xcu
deleted file mode 100644
index 0d51558..0000000
--- a/filter/source/config/fragments/types/calc_Text_txt_csv_StarCalc.xcu
+++ /dev/null
@@ -1,12 +0,0 @@
- <node oor:name="calc_Text_txt_csv_StarCalc" oor:op="replace" >
- <prop oor:name="DetectService"><value>com.sun.star.comp.filters.PlainTextFilterDetect</value></prop>
- <prop oor:name="URLPattern"/>
- <prop oor:name="Extensions"><value>csv txt</value></prop>
- <prop oor:name="MediaType"><value>text/plain</value></prop>
- <prop oor:name="Preferred"><value>false</value></prop>
- <prop oor:name="PreferredFilter"><value>Text - txt - csv (StarCalc)</value></prop>
- <prop oor:name="UIName">
- <value>Text - txt - csv (StarOffice Calc)</value>
- </prop>
- <prop oor:name="ClipboardFormat"/>
- </node>
diff --git a/filter/source/config/fragments/types/generic_Text.xcu b/filter/source/config/fragments/types/generic_Text.xcu
new file mode 100644
index 0000000..de25022
--- /dev/null
+++ b/filter/source/config/fragments/types/generic_Text.xcu
@@ -0,0 +1,11 @@
+ <node oor:name="generic_Text" oor:op="replace" >
+ <prop oor:name="DetectService"><value>com.sun.star.comp.filters.PlainTextFilterDetect</value></prop>
+ <prop oor:name="URLPattern"/>
+ <prop oor:name="Extensions"><value>csv txt</value></prop>
+ <prop oor:name="MediaType"><value>text/plain</value></prop>
+ <prop oor:name="Preferred"><value>false</value></prop>
+ <prop oor:name="UIName">
+ <value>Text</value>
+ </prop>
+ <prop oor:name="ClipboardFormat"/>
+ </node>
diff --git a/filter/source/textfilterdetect/filterdetect.cxx b/filter/source/textfilterdetect/filterdetect.cxx
index 9cb9405..7dd2ddd 100644
--- a/filter/source/textfilterdetect/filterdetect.cxx
+++ b/filter/source/textfilterdetect/filterdetect.cxx
@@ -88,7 +88,7 @@ rtl::OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::Proper
}
}
- if (aType == "calc_Text_txt_csv_StarCalc")
+ if (aType == "generic_Text")
{
// Generic text type. Decide which filter to use based on the
// document service first, then on extension if that's not available.
diff --git a/filter/type-detection-debug.diff b/filter/type-detection-debug.diff
new file mode 100644
index 0000000..84fc5dc
--- /dev/null
+++ b/filter/type-detection-debug.diff
@@ -0,0 +1,135 @@
+diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx
+index cac9b14..f24198b 100644
+--- a/filter/source/config/cache/typedetection.cxx
++++ b/filter/source/config/cache/typedetection.cxx
+@@ -43,6 +43,49 @@
+ #include <tools/urlobj.hxx>
+ #include <unotools/localfilehelper.hxx>
+
++
++#include <stdio.h>
++#include <string>
++#include <sys/time.h>
++
++namespace {
++
++class stack_printer
++{
++public:
++ explicit stack_printer(const char* msg) :
++ msMsg(msg)
++ {
++ fprintf(stdout, "%s: --begin\n", msMsg.c_str());
++ mfStartTime = getTime();
++ }
++
++ ~stack_printer()
++ {
++ double fEndTime = getTime();
++ fprintf(stdout, "%s: --end (duration: %g sec)\n", msMsg.c_str(), (fEndTime-mfStartTime));
++ }
++
++ void printTime(int line) const
++ {
++ double fEndTime = getTime();
++ fprintf(stdout, "%s: --(%d) (duration: %g sec)\n", msMsg.c_str(), line, (fEndTime-mfStartTime));
++ }
++
++private:
++ double getTime() const
++ {
++ timeval tv;
++ gettimeofday(&tv, NULL);
++ return tv.tv_sec + tv.tv_usec / 1000000.0;
++ }
++
++ ::std::string msMsg;
++ double mfStartTime;
++};
++
++}
++
+ //_______________________________________________
+ // namespace
+
+@@ -108,6 +151,21 @@ TypeDetection::~TypeDetection()
+
+ namespace {
+
++void print(const FlatDetection& rFD, const char* msg)
++{
++ fprintf(stdout, "--- %s\n", msg);
++ FlatDetection::const_iterator i = rFD.begin(), iend = rFD.end();
++ for (; i != iend; ++i)
++ {
++ const FlatDetectionInfo& r = *i;
++ fprintf(stdout, " * type = '%s' match by extension = %d match by pattern = %d pre-selected as type = %d pre-selected as filter = %d pre-selected as doc service = %d\n",
++ rtl::OUStringToOString(r.sType, RTL_TEXTENCODING_UTF8).getStr(),
++ r.bMatchByExtension, r.bMatchByPattern, r.bPreselectedAsType,
++ r.bPreselectedByFilter, r.bPreselectedByDocumentService);
++ }
++ fprintf(stdout, "---\n");
++}
++
+ /**
+ * Types with matching extension come first, then types that are supported
+ * by the document service come next.
+@@ -129,6 +187,7 @@ struct SortByPriority : public std::binary_function<FlatDetectionInfo, FlatDetec
+ sal_Bool bAllowDeep )
+ throw (css::uno::RuntimeException)
+ {
++ stack_printer __stack_printer__("filter/config/TypeDetection::queryTypeByDescriptor");
+ // make the descriptor more useable :-)
+ ::comphelper::MediaDescriptor stlDescriptor(lDescriptor);
+
+@@ -164,16 +223,21 @@ struct SortByPriority : public std::binary_function<FlatDetectionInfo, FlatDetec
+ FlatDetection lFlatTypes;
+ impl_getPreselection(aURL, stlDescriptor, lFlatTypes);
+
++ print(lFlatTypes, "pre-selection");
++
+ //*******************************************
+ // get all types, which match to the given descriptor
+ // That can be true by: extensions/url pattern/mime type etcpp.
+ m_rCache->detectFlatForURL(aURL, lFlatTypes);
+
++ print(lFlatTypes, "flat by url");
++
+ aLock.clear();
+ // <- SAFE ----------------------------------
+
+ // Properly prioritize all candidate types.
+ lFlatTypes.sort(SortByPriority());
++ print(lFlatTypes, "sorted by priority");
+
+ ::rtl::OUString sType ;
+ ::rtl::OUString sLastChance;
+@@ -190,8 +254,16 @@ struct SortByPriority : public std::binary_function<FlatDetectionInfo, FlatDetec
+ // stream failed by e.g. an IO exception ...
+ OUStringList lUsedDetectors;
+ if (lFlatTypes.size()>0)
++ {
+ sType = impl_detectTypeFlatAndDeep(stlDescriptor, lFlatTypes, bAllowDeep, lUsedDetectors, sLastChance);
+
++ {
++ rtl::OUString aFilter = stlDescriptor.getUnpackedValueOrDefault(comphelper::MediaDescriptor::PROP_FILTERNAME(), rtl::OUString());
++ fprintf(stdout, "TypeDetection::queryTypeByDescriptor: filter = '%s' type = '%s' (flat and deep)\n",
++ rtl::OUStringToOString(aFilter, RTL_TEXTENCODING_UTF8).getStr(), rtl::OUStringToOString(sType, RTL_TEXTENCODING_UTF8).getStr());
++ }
++ }
++
+ //*******************************************
+ // if no flat detected (nor preselected!) type could be
+ // verified and no error occurred during creation of
+@@ -203,6 +275,11 @@ struct SortByPriority : public std::binary_function<FlatDetectionInfo, FlatDetec
+ )
+ {
+ sType = impl_detectTypeDeepOnly(stlDescriptor, lUsedDetectors);
++ {
++ rtl::OUString aFilter = stlDescriptor.getUnpackedValueOrDefault(comphelper::MediaDescriptor::PROP_FILTERNAME(), rtl::OUString());
++ fprintf(stdout, "TypeDetection::queryTypeByDescriptor: filter = '%s' type = '%s' (deep only)\n",
++ rtl::OUStringToOString(aFilter, RTL_TEXTENCODING_UTF8).getStr(), rtl::OUStringToOString(sType, RTL_TEXTENCODING_UTF8).getStr());
++ }
+ }
+
+ //*******************************************
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index e6ec96b..68b5bf0 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -72,7 +72,7 @@ FileFormat aFileFormats[] = {
{ "ods" , "calc8", "", ODS_FORMAT_TYPE },
{ "xls" , "MS Excel 97", "calc_MS_EXCEL_97", XLS_FORMAT_TYPE },
{ "xlsx", "Calc MS Excel 2007 XML" , "MS Excel 2007 XML", XLSX_FORMAT_TYPE },
- { "csv" , "Text - txt - csv (StarCalc)", "calc_Text_txt_csv_StarCalc", CSV_FORMAT_TYPE }
+ { "csv" , "Text - txt - csv (StarCalc)", "generic_Text", CSV_FORMAT_TYPE }
};
}
diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx
index 9466200..2d2b042 100644
--- a/sc/source/ui/vba/vbaworkbooks.cxx
+++ b/sc/source/ui/vba/vbaworkbooks.cxx
@@ -195,7 +195,7 @@ ScVbaWorkbooks::isTextFile( const rtl::OUString& sType )
// c) unknown
// returning true basically means treat this like a csv file
const static rtl::OUString txtType( RTL_CONSTASCII_USTRINGPARAM("writer_Text" ) );
- const static rtl::OUString csvType( RTL_CONSTASCII_USTRINGPARAM("calc_Text_txt_csv_StarCalc" ) );
+ const static rtl::OUString csvType("generic_Text");
const static rtl::OUString encodedTxtType( RTL_CONSTASCII_USTRINGPARAM("writer_Text_encoded" ) );
return sType.equals( txtType ) || sType.equals( csvType ) || sType.isEmpty() || sType.equals( encodedTxtType );
}
diff --git a/sc/workben/dpcache/perf-test b/sc/workben/dpcache/perf-test
new file mode 100755
index 0000000..b6a6629
Binary files /dev/null and b/sc/workben/dpcache/perf-test differ
commit 8b8e24544793f4ec6f61edb7ce8ac10bf6bb0981
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri May 25 00:22:58 2012 -0400
Do the real detection work for plain text & forgot to add a makefile.
Change-Id: I95edb869b00764464d91e1f396da1bb648b74515
diff --git a/filter/Library_textfd.mk b/filter/Library_textfd.mk
new file mode 100644
index 0000000..ac7303a
--- /dev/null
+++ b/filter/Library_textfd.mk
@@ -0,0 +1,58 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License or as specified alternatively below. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Initial Developer of the Original Code is
+# Kohei Yoshida <kohei.yoshida at suse.com>
+# Portions created by the Initial Developer are Copyright (C) 2011 the
+# Initial Developer. All Rights Reserved.
+#
+# Major Contributor(s):
+#
+# For minor contributions see the git repository.
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+#*************************************************************************
+
+$(eval $(call gb_Library_Library,textfd))
+
+$(eval $(call gb_Library_set_componentfile,textfd,filter/source/textfilterdetect/textfd))
+
+$(eval $(call gb_Library_use_api,textfd,\
+ udkapi \
+ offapi \
+))
+
+$(eval $(call gb_Library_set_include,textfd,\
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_Library_use_libraries,textfd,\
+ ucbhelper \
+ cppuhelper \
+ cppu \
+ sal \
+ tl \
+ $(gb_STDLIBS) \
+))
+
+$(eval $(call gb_Library_add_exception_objects,textfd,\
+ filter/source/textfilterdetect/fdcomp \
+ filter/source/textfilterdetect/filterdetect \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/filter/source/textfilterdetect/filterdetect.cxx b/filter/source/textfilterdetect/filterdetect.cxx
index 55bfd0a..9cb9405 100644
--- a/filter/source/textfilterdetect/filterdetect.cxx
+++ b/filter/source/textfilterdetect/filterdetect.cxx
@@ -27,49 +27,98 @@
*/
#include "filterdetect.hxx"
+
+#include "tools/urlobj.hxx"
+
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#define WRITER_TEXT_FILTER "Text"
+#define CALC_TEXT_FILTER "Text - txt - csv (StarCalc)"
+
using namespace ::com::sun::star;
+namespace {
+
+void setFilter(uno::Sequence<beans::PropertyValue>& rProps, sal_Int32 nPos, const rtl::OUString& rFilter)
+{
+ if (nPos >= 0)
+ rProps[nPos].Value <<= rFilter;
+ else
+ {
+ sal_Int32 n = rProps.getLength();
+ rProps.realloc(n+1);
+ rProps[n].Name = "FilterName";
+ rProps[n].Value <<= rFilter;
+ }
+}
+
+}
+
PlainTextFilterDetect::PlainTextFilterDetect(const uno::Reference<lang::XMultiServiceFactory> &xMSF) :
mxMSF(xMSF) {}
PlainTextFilterDetect::~PlainTextFilterDetect() {}
-rtl::OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyValue>& aArguments) throw (uno::RuntimeException)
+rtl::OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyValue>& lDescriptor) throw (uno::RuntimeException)
{
+ rtl::OUString aType;
+ rtl::OUString aDocService;
+ rtl::OUString aExt;
+
+ sal_Int32 nFilter = -1;
+
+ for (sal_Int32 i = 0, n = lDescriptor.getLength(); i < n; ++i)
+ {
+ if (lDescriptor[i].Name == "TypeName")
+ lDescriptor[i].Value >>= aType;
+ else if (lDescriptor[i].Name == "FilterName")
+ nFilter = i;
+ else if (lDescriptor[i].Name == "DocumentService")
+ lDescriptor[i].Value >>= aDocService;
+ else if (lDescriptor[i].Name == "URL")
+ {
+ rtl::OUString aURL;
+ lDescriptor[i].Value >>= aURL;
+
+ // Get the file name extension.
+ INetURLObject aParser(aURL);
+ aExt = aParser.getExtension(
+ INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET);
+ aExt = aExt.toAsciiLowerCase();
+ }
+ }
+
+ if (aType == "calc_Text_txt_csv_StarCalc")
+ {
+ // Generic text type. Decide which filter to use based on the
+ // document service first, then on extension if that's not available.
+
+ if (aDocService == "com.sun.star.sheet.SpreadsheetDocument")
+ // Open it in Calc.
+ setFilter(lDescriptor, nFilter, CALC_TEXT_FILTER);
+ else if (aDocService == "com.sun.star.text.TextDocument")
+ // Open it in Writer.
+ setFilter(lDescriptor, nFilter, WRITER_TEXT_FILTER);
+ else if (aExt == "csv")
+ setFilter(lDescriptor, nFilter, CALC_TEXT_FILTER);
+ else if (aExt == "txt")
+ setFilter(lDescriptor, nFilter, WRITER_TEXT_FILTER);
+ else
+ // No clue. Open it in Writer by default.
+ setFilter(lDescriptor, nFilter, WRITER_TEXT_FILTER);
+
+ return aType;
+ }
+
+ // failed!
return rtl::OUString();
}
// XInitialization
-void SAL_CALL PlainTextFilterDetect::initialize(const uno::Sequence<uno::Any>& aArguments)
+void SAL_CALL PlainTextFilterDetect::initialize(const uno::Sequence<uno::Any>& /*aArguments*/)
throw (uno::Exception, uno::RuntimeException)
{
- uno::Sequence<beans::PropertyValue> aAnySeq;
- sal_Int32 nLength = aArguments.getLength();
- if (nLength && (aArguments[0] >>= aAnySeq))
- {
- const beans::PropertyValue * pValue = aAnySeq.getConstArray();
- for (sal_Int32 i = 0, n = aAnySeq.getLength(); i < n; ++i)
- {
- if (pValue[i].Name == "Type")
- {
- fprintf(stdout, "PlainTextFilterDetect::initialize: type = '%s'\n",
- rtl::OUStringToOString(pValue[i].Value.get<rtl::OUString>(), RTL_TEXTENCODING_UTF8).getStr());
- }
- else if (pValue[i].Name == "UserData")
- {
- fprintf(stdout, "PlainTextFilterDetect::initialize: user data = '%s'\n",
- rtl::OUStringToOString(pValue[i].Value.get<rtl::OUString>(), RTL_TEXTENCODING_UTF8).getStr());
- }
- else if (pValue[i].Name == "TemplateName")
- {
- fprintf(stdout, "PlainTextFilterDetect::initialize: template name = '%s'\n",
- rtl::OUStringToOString(pValue[i].Value.get<rtl::OUString>(), RTL_TEXTENCODING_UTF8).getStr());
- }
- }
- }
}
rtl::OUString PlainTextFilterDetect_getImplementationName()
commit 427b50c05f18de474dd5b88b705951240335beac
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Thu May 24 23:14:02 2012 -0400
Use the new plain text type detection service for text/csv type.
Change-Id: I50d5cee6302e8d6b4b329e30b7a5ce47b47bc945
diff --git a/filter/source/config/fragments/types/calc_Text_txt_csv_StarCalc.xcu b/filter/source/config/fragments/types/calc_Text_txt_csv_StarCalc.xcu
index 7087172..0d51558 100644
--- a/filter/source/config/fragments/types/calc_Text_txt_csv_StarCalc.xcu
+++ b/filter/source/config/fragments/types/calc_Text_txt_csv_StarCalc.xcu
@@ -1,5 +1,5 @@
<node oor:name="calc_Text_txt_csv_StarCalc" oor:op="replace" >
- <prop oor:name="DetectService"><value>com.sun.star.comp.calc.FormatDetector</value></prop>
+ <prop oor:name="DetectService"><value>com.sun.star.comp.filters.PlainTextFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>csv txt</value></prop>
<prop oor:name="MediaType"><value>text/plain</value></prop>
diff --git a/postprocess/packcomponents/makefile.mk b/postprocess/packcomponents/makefile.mk
index f4be7f2..3ee6612 100644
--- a/postprocess/packcomponents/makefile.mk
+++ b/postprocess/packcomponents/makefile.mk
@@ -57,6 +57,7 @@ my_components = \
component/filter/source/placeware/placeware \
component/filter/source/svg/svgfilter \
component/filter/source/t602/t602filter \
+ component/filter/source/textfilterdetect/textfd \
component/filter/source/xmlfilteradaptor/xmlfa \
component/filter/source/xmlfilterdetect/xmlfd \
component/filter/source/xsltdialog/xsltdlg \
diff --git a/scp2/source/ooo/file_library_ooo.scp b/scp2/source/ooo/file_library_ooo.scp
index f229e84..0b4a78e 100644
--- a/scp2/source/ooo/file_library_ooo.scp
+++ b/scp2/source/ooo/file_library_ooo.scp
@@ -1398,6 +1398,7 @@ STD_LIB_FILE( gid_File_Lib_Xsltdlg, xsltdlg )
STD_LIB_FILE( gid_File_Lib_Xsltfilter, xsltfilter )
STD_LIB_FILE( gid_File_Lib_Xmlfa, xmlfa )
STD_LIB_FILE( gid_File_Lib_Xmlfd, xmlfd )
+STD_LIB_FILE( gid_File_Lib_Textfd, textfd )
STD_LIB_FILE( gid_File_Lib_Odfflatxml, odfflatxml )
#ifdef SOLAR_JAVA
commit a0b640bd1816bc464961c85eb2d1de405cd50d1c
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Thu May 24 22:36:09 2012 -0400
Initial skeleton code for plain text filter detection service.
Right now it will always fail.
Change-Id: I50011bbf7ce59c3b299d23e688dd1af87bcafeb6
diff --git a/Repository.mk b/Repository.mk
index 3f641d6..a7d7e53 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -335,6 +335,7 @@ $(eval $(call gb_Helper_register_libraries,OOOLIBS, \
swui \
t602filter \
textconversiondlgs \
+ textfd \
tk \
tl \
unordf \
diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk
index 03f13e2..922d4f5 100644
--- a/filter/Module_filter.mk
+++ b/filter/Module_filter.mk
@@ -60,6 +60,7 @@ $(eval $(call gb_Module_add_targets,filter,\
Library_placeware \
Library_svgfilter \
Library_t602filter \
+ Library_textfd \
Library_xmlfa \
Library_xmlfd \
Library_xsltdlg \
diff --git a/filter/source/textfilterdetect/fdcomp.cxx b/filter/source/textfilterdetect/fdcomp.cxx
new file mode 100644
index 0000000..6be78b3
--- /dev/null
+++ b/filter/source/textfilterdetect/fdcomp.cxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Kohei Yoshida <kohei.yoshida at suse.com>
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <stdio.h>
+
+#include <osl/mutex.hxx>
+#include <osl/thread.h>
+#include <cppuhelper/factory.hxx>
+
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+#include "filterdetect.hxx"
+
+using namespace ::cppu;
+using namespace com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
+extern "C" {
+
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
+ const sal_Char* pImplName, void* pServiceManager, void* /* pRegistryKey */ )
+{
+ void* pRet = NULL;
+ rtl::OUString implName = rtl::OUString::createFromAscii(pImplName);
+ if (pServiceManager && implName == PlainTextFilterDetect_getImplementationName())
+ {
+ uno::Reference<lang::XSingleServiceFactory> xFactory(
+ createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ implName,
+ PlainTextFilterDetect_createInstance, PlainTextFilterDetect_getSupportedServiceNames()));
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/textfilterdetect/filterdetect.cxx b/filter/source/textfilterdetect/filterdetect.cxx
new file mode 100644
index 0000000..55bfd0a
--- /dev/null
+++ b/filter/source/textfilterdetect/filterdetect.cxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Kohei Yoshida <kohei.yoshida at suse.com>
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "filterdetect.hxx"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+using namespace ::com::sun::star;
+
+PlainTextFilterDetect::PlainTextFilterDetect(const uno::Reference<lang::XMultiServiceFactory> &xMSF) :
+ mxMSF(xMSF) {}
+
+PlainTextFilterDetect::~PlainTextFilterDetect() {}
+
+rtl::OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyValue>& aArguments) throw (uno::RuntimeException)
+{
+ return rtl::OUString();
+}
+
+// XInitialization
+
+void SAL_CALL PlainTextFilterDetect::initialize(const uno::Sequence<uno::Any>& aArguments)
+ throw (uno::Exception, uno::RuntimeException)
+{
+ uno::Sequence<beans::PropertyValue> aAnySeq;
+ sal_Int32 nLength = aArguments.getLength();
+ if (nLength && (aArguments[0] >>= aAnySeq))
+ {
+ const beans::PropertyValue * pValue = aAnySeq.getConstArray();
+ for (sal_Int32 i = 0, n = aAnySeq.getLength(); i < n; ++i)
+ {
+ if (pValue[i].Name == "Type")
+ {
+ fprintf(stdout, "PlainTextFilterDetect::initialize: type = '%s'\n",
+ rtl::OUStringToOString(pValue[i].Value.get<rtl::OUString>(), RTL_TEXTENCODING_UTF8).getStr());
+ }
+ else if (pValue[i].Name == "UserData")
+ {
+ fprintf(stdout, "PlainTextFilterDetect::initialize: user data = '%s'\n",
+ rtl::OUStringToOString(pValue[i].Value.get<rtl::OUString>(), RTL_TEXTENCODING_UTF8).getStr());
+ }
+ else if (pValue[i].Name == "TemplateName")
+ {
+ fprintf(stdout, "PlainTextFilterDetect::initialize: template name = '%s'\n",
+ rtl::OUStringToOString(pValue[i].Value.get<rtl::OUString>(), RTL_TEXTENCODING_UTF8).getStr());
+ }
+ }
+ }
+}
+
+rtl::OUString PlainTextFilterDetect_getImplementationName()
+{
+ return rtl::OUString("com.sun.star.comp.filters.PlainTextFilterDetect");
+}
+
+sal_Bool PlainTextFilterDetect_supportsService(const rtl::OUString& ServiceName)
+{
+ return ServiceName == "com.sun.star.document.ExtendedTypeDetection" ||
+ ServiceName == "com.sun.star.comp.filters.PlainTextFilterDetect";
+}
+
+uno::Sequence<rtl::OUString> PlainTextFilterDetect_getSupportedServiceNames()
+{
+ uno::Sequence<rtl::OUString> aRet(2);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = "com.sun.star.document.ExtendedTypeDetection";
+ pArray[1] = "com.sun.star.comp.filters.PlainTextFilterDetect";
+ return aRet;
+}
+
+uno::Reference<uno::XInterface> PlainTextFilterDetect_createInstance(
+ const uno::Reference<lang::XMultiServiceFactory> & rSMgr)
+{
+ return (cppu::OWeakObject*) new PlainTextFilterDetect(rSMgr);
+}
+
+// XServiceInfo
+rtl::OUString SAL_CALL PlainTextFilterDetect::getImplementationName()
+ throw (uno::RuntimeException)
+{
+ return PlainTextFilterDetect_getImplementationName();
+}
+
+sal_Bool SAL_CALL PlainTextFilterDetect::supportsService(const rtl::OUString& rServiceName)
+ throw (uno::RuntimeException)
+{
+ return PlainTextFilterDetect_supportsService(rServiceName);
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL PlainTextFilterDetect::getSupportedServiceNames()
+ throw (uno::RuntimeException)
+{
+ return PlainTextFilterDetect_getSupportedServiceNames();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/textfilterdetect/filterdetect.hxx b/filter/source/textfilterdetect/filterdetect.hxx
new file mode 100644
index 0000000..7f3ad15
--- /dev/null
+++ b/filter/source/textfilterdetect/filterdetect.hxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __FILTER_TEXTFILTERDETECT_FILTERDETECT_HXX__
+#define __FILTER_TEXTFILTERDETECT_FILTERDETECT_HXX__
+
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <cppuhelper/implbase3.hxx>
+
+class PlainTextFilterDetect : public cppu::WeakImplHelper3<
+ com::sun::star::document::XExtendedFilterDetection,
+ com::sun::star::lang::XInitialization,
+ com::sun::star::lang::XServiceInfo>
+{
+ com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> mxMSF;
+
+public:
+
+ PlainTextFilterDetect (const com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> &xMSF);
+ virtual ~PlainTextFilterDetect();
+
+ // XExtendedFilterDetection
+
+ virtual ::rtl::OUString SAL_CALL detect(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& lDescriptor)
+ throw( com::sun::star::uno::RuntimeException );
+
+ // XInitialization
+
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence<com::sun::star::uno::Any>& aArguments)
+ throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw (com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
+ throw (com::sun::star::uno::RuntimeException);
+
+ virtual com::sun::star::uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames()
+ throw (com::sun::star::uno::RuntimeException);
+};
+
+rtl::OUString PlainTextFilterDetect_getImplementationName();
+
+sal_Bool PlainTextFilterDetect_supportsService(const rtl::OUString& ServiceName);
+
+com::sun::star::uno::Sequence<rtl::OUString> PlainTextFilterDetect_getSupportedServiceNames();
+
+com::sun::star::uno::Reference<com::sun::star::uno::XInterface>
+PlainTextFilterDetect_createInstance(const com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory>& rSMgr);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/textfilterdetect/textfd.component b/filter/source/textfilterdetect/textfd.component
new file mode 100644
index 0000000..e1708e7
--- /dev/null
+++ b/filter/source/textfilterdetect/textfd.component
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+* Version: MPL 1.1 / GPLv3+ / LGPLv3+
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License or as specified alternatively below. You may obtain a copy of
+* the License at http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Initial Developer of the Original Code is
+* Kohei Yoshida <kohei.yoshida at suse.com> (Initial Developer)
+* Portions created by the Initial Developer are Copyright (C) 2011 the
+* Initial Developer. All Rights Reserved.
+*
+* Major Contributor(s):
+*
+* For minor contributions see the git repository.
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+* instead of those above.
+**************************************************************************-->
+
+<component loader="com.sun.star.loader.SharedLibrary"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.filters.PlainTextFilterDetect">
+ <service name="com.sun.star.document.ExtendedTypeDetection"/>
+ </implementation>
+</component>
commit 6e82a984a3bfbdaef405e445c6c6e345682920ee
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Thu May 24 21:21:31 2012 -0400
Patterns should precede extensions.
Change-Id: Ib401fb6287efda68d07732382fc814961138d8a9
diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx
index cac9b14..303ebfc 100644
--- a/filter/source/config/cache/typedetection.cxx
+++ b/filter/source/config/cache/typedetection.cxx
@@ -109,13 +109,16 @@ TypeDetection::~TypeDetection()
namespace {
/**
- * Types with matching extension come first, then types that are supported
- * by the document service come next.
+ * Types with matching pattern first, then extension, then types that are
+ * supported by the document service come next.
*/
struct SortByPriority : public std::binary_function<FlatDetectionInfo, FlatDetectionInfo, bool>
{
bool operator() (const FlatDetectionInfo& r1, const FlatDetectionInfo& r2) const
{
+ if (r1.bMatchByPattern != r2.bMatchByPattern)
+ return r1.bMatchByPattern;
+
if (r1.bMatchByExtension != r2.bMatchByExtension)
return r1.bMatchByExtension;
commit cc0b7db44ea58f9395d0d89a0f2bdac32a272eb7
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Thu May 24 21:14:40 2012 -0400
Prioritize candidate types by extension first, then by document service.
This unfortunately breaks plain text format detection for writer, but I'll
get to that next.
Change-Id: I70382529596dbc3e3af4935d6e98ad6d58bb4d91
diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx
index 0b7a887..cac9b14 100644
--- a/filter/source/config/cache/typedetection.cxx
+++ b/filter/source/config/cache/typedetection.cxx
@@ -106,7 +106,24 @@ TypeDetection::~TypeDetection()
// <- SAFE
}
+namespace {
+/**
+ * Types with matching extension come first, then types that are supported
+ * by the document service come next.
+ */
+struct SortByPriority : public std::binary_function<FlatDetectionInfo, FlatDetectionInfo, bool>
+{
+ bool operator() (const FlatDetectionInfo& r1, const FlatDetectionInfo& r2) const
+ {
+ if (r1.bMatchByExtension != r2.bMatchByExtension)
+ return r1.bMatchByExtension;
+
+ return r1.bPreselectedByDocumentService;
+ }
+};
+
+}
::rtl::OUString SAL_CALL TypeDetection::queryTypeByDescriptor(css::uno::Sequence< css::beans::PropertyValue >& lDescriptor,
sal_Bool bAllowDeep )
@@ -155,6 +172,9 @@ TypeDetection::~TypeDetection()
aLock.clear();
// <- SAFE ----------------------------------
+ // Properly prioritize all candidate types.
+ lFlatTypes.sort(SortByPriority());
+
::rtl::OUString sType ;
::rtl::OUString sLastChance;
More information about the Libreoffice-commits
mailing list