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

fdo#52451: Ensure that the extension for text is .txt from writer.

Added a preferred extension property to the filter which overwrites
one(s) given by the default file format type associated with it.

Normally this property is not used for the majority of the filters,
but for plain text filters, we need to use .txt when saving from
writer whereas we do .csv from calc.

Change-Id: I3453ad084e4379e5cc1101daeb9d2c3ddd919e92
üst 601bfe2c
......@@ -69,6 +69,7 @@
#define PROPNAME_USERDATA "UserData"
#define PROPNAME_TEMPLATENAME "TemplateName"
#define PROPNAME_FILEFORMATVERSION "FileFormatVersion"
#define PROPNAME_FILESAVEEXTENSION "FileSaveExtension"
/** @short used to identify a frame loader or detect service item
property against the configuration API and can be used
......
......@@ -1834,6 +1834,7 @@ CacheItem FilterCache::impl_loadItem(const css::uno::Reference< css::container::
aItem[PROPNAME_UICOMPONENT ] = xItem->getByName(PROPNAME_UICOMPONENT );
aItem[PROPNAME_FILTERSERVICE ] = xItem->getByName(PROPNAME_FILTERSERVICE );
aItem[PROPNAME_DOCUMENTSERVICE ] = xItem->getByName(PROPNAME_DOCUMENTSERVICE );
aItem[PROPNAME_FILESAVEEXTENSION] = xItem->getByName(PROPNAME_FILESAVEEXTENSION);
// special handling for flags! Convert it from a list of names to its
// int representation ...
......
......@@ -4,6 +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="FileSaveExtension"><value>*.txt</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>
......
......@@ -4,6 +4,7 @@
<prop oor:name="FilterService"/>
<prop oor:name="UserData"><value></value></prop>
<prop oor:name="FileFormatVersion"><value>0</value></prop>
<prop oor:name="FileSaveExtension"><value>*.csv</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>
......
......@@ -4,6 +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="FileSaveExtension"><value>*.txt</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>
......
......@@ -68,6 +68,9 @@
</prop>
<prop oor:name="UIName" oor:localized="true" oor:type="xs:string">
<info><desc>Localized name of the filter, whch can be shown at the UI.</desc></info>
</prop>
<prop oor:name="FileSaveExtension" oor:type="xs:string" oor:nillable="true">
<info><desc>Extension to use when exporting content using this filter. When this value is not given, it is inferred from the Type associated with this filter.</desc></info>
</prop>
</group>
</templates>
......
......@@ -979,6 +979,12 @@ void SfxFilterContainer::ReadSingleFilter_Impl(
{
lFilterProperties[nFilterProperty].Value >>= sServiceName;
}
else if (lFilterProperties[nFilterProperty].Name == "FileSaveExtension")
{
// Extension preferred by the filter. This takes precedence
// over those that are given in the file format type.
lFilterProperties[nFilterProperty].Value >>= sExtension;
}
else if ( lFilterProperties[nFilterProperty].Name == "Type" )
{
lFilterProperties[nFilterProperty].Value >>= sType;
......@@ -1015,9 +1021,12 @@ void SfxFilterContainer::ReadSingleFilter_Impl(
}
else if ( lTypeProperties[nTypeProperty].Name == "Extensions" )
{
::com::sun::star::uno::Sequence< ::rtl::OUString > lExtensions;
lTypeProperties[nTypeProperty].Value >>= lExtensions;
sExtension = implc_convertStringlistToString( lExtensions, ';', DEFINE_CONST_UNICODE("*.") );
if (sExtension.isEmpty())
{
::com::sun::star::uno::Sequence< ::rtl::OUString > lExtensions;
lTypeProperties[nTypeProperty].Value >>= lExtensions;
sExtension = implc_convertStringlistToString( lExtensions, ';', DEFINE_CONST_UNICODE("*.") );
}
}
else if ( lTypeProperties[nTypeProperty].Name == "URLPattern" )
{
......
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