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

Renamed calc_Text_text_csv_StarCalc type to generic_Text.

Change-Id: Ica6aef56733c7c71568e37166a2f78d6aa05a118
üst 8b8e2454
......@@ -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\
......
......@@ -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
......
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
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
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
......@@ -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>
<node oor:name="calc_Text_txt_csv_StarCalc" oor:op="replace" >
<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="PreferredFilter"><value>Text - txt - csv (StarCalc)</value></prop>
<prop oor:name="UIName">
<value>Text - txt - csv (StarOffice Calc)</value>
<value>Text</value>
</prop>
<prop oor:name="ClipboardFormat"/>
</node>
......@@ -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/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());
+ }
}
//*******************************************
......@@ -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 }
};
}
......
......@@ -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 );
}
......
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