26#include <com/sun/star/uno/Any.h>
29#include <com/sun/star/uno/Exception.hpp>
30#include <com/sun/star/lang/XMultiServiceFactory.hpp>
31#include <com/sun/star/beans/PropertyValue.hpp>
32#include <com/sun/star/beans/XPropertySet.hpp>
33#include <com/sun/star/configuration/theDefaultProvider.hpp>
34#include <com/sun/star/container/XNameAccess.hpp>
58 if (
sFilterName.equalsIgnoreAsciiCaseAscii( *pPtr ) )
68 if ( !lExtensionList.empty() )
70 aShortName = lExtensionList[ 0 ];
71 if ( aShortName.startsWith(
"*." ) )
72 aShortName = aShortName.replaceAt( 0, 2,
u"" );
89static Reference< XInterface >
openConfig(
const char* sPackage)
91 Reference< XComponentContext > xContext(
93 Reference< XInterface > xCfg;
97 Reference< XMultiServiceFactory > xConfigProvider = theDefaultProvider::get( xContext );
99 PropertyValue aParam ;
102 aParam.Name =
"nodepath";
103 if (rtl_str_compareIgnoreAsciiCase(sPackage,
"types") == 0)
104 aParam.Value <<= OUString(
"/org.openoffice.TypeDetection.Types/Types" );
105 if (rtl_str_compareIgnoreAsciiCase(sPackage,
"filters") == 0)
106 aParam.Value <<= OUString(
"/org.openoffice.TypeDetection.GraphicFilter/Filters" );
107 Sequence< Any > lParams{
Any(aParam) };
110 xCfg = xConfigProvider->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationAccess", lParams);
122 static constexpr OUStringLiteral STYPE (
u"Type" );
123 static constexpr OUStringLiteral SUINAME (
u"UIName" );
124 static constexpr OUStringLiteral SFLAGS (
u"Flags" );
125 static constexpr OUStringLiteral SMEDIATYPE (
u"MediaType" );
126 static constexpr OUStringLiteral SEXTENSIONS (
u"Extensions" );
127 static constexpr OUStringLiteral SFORMATNAME (
u"FormatName" );
128 static constexpr OUStringLiteral SREALFILTERNAME (
u"RealFilterName" );
131 Reference< XNameAccess > xTypeAccess (
openConfig(
"types" ), UNO_QUERY );
132 Reference< XNameAccess > xFilterAccess(
openConfig(
"filters"), UNO_QUERY );
134 if ( !(xTypeAccess.is() && xFilterAccess.is()) )
137 const Sequence< OUString > lAllFilter = xFilterAccess->getElementNames();
139 for (
const OUString& sInternalFilterName : lAllFilter )
141 Reference< XPropertySet > xFilterSet;
142 xFilterAccess->getByName( sInternalFilterName ) >>= xFilterSet;
143 if (!xFilterSet.is())
149 xFilterSet->getPropertyValue(STYPE) >>= aEntry.
sType;
150 xFilterSet->getPropertyValue(SUINAME) >>= aEntry.
sUIName;
151 xFilterSet->getPropertyValue(SREALFILTERNAME) >>= aEntry.
sFilterType;
152 Sequence< OUString > lFlags;
153 xFilterSet->getPropertyValue(SFLAGS) >>= lFlags;
154 if (lFlags.getLength()!=1 || lFlags[0].isEmpty())
163 OUString sFormatName;
164 xFilterSet->getPropertyValue(SFORMATNAME) >>= sFormatName;
167 Reference< XPropertySet > xTypeSet;
168 xTypeAccess->getByName( aEntry.
sType ) >>= xTypeSet;
172 xTypeSet->getPropertyValue(SMEDIATYPE) >>= aEntry.
sMediaType;
173 css::uno::Sequence<OUString> tmp;
174 if (xTypeSet->getPropertyValue(SEXTENSIONS) >>= tmp)
175 aEntry.
lExtensionList = comphelper::sequenceToContainer<std::vector<OUString>>(tmp);
180 if (aExtension.isEmpty())
189 if (!( aEntry.
nFlags & 3 ))
218 "svm",
"1",
"SVMETAFILE",
219 "svm",
"2",
"SVMETAFILE",
231 "webp",
"1",
"SVIWEBP",
232 "webp",
"2",
"SVEWEBP",
243 OUString sExtension( OUString::createFromAscii( *pPtr++ ) );
247 aEntry.
sType = sExtension;
250 OString sFlags( *pPtr++ );
251 aEntry.
nFlags = sFlags.toInt32();
253 OUString sUserData( OUString::createFromAscii( *pPtr ) );
280 return aImport[ nFormat ].sFilterName;
287 for (
auto const& elem :
aImport)
289 if ( elem.sUIName.equalsIgnoreAsciiCase( rFormatName ) )
300 for (
auto const& elem :
aImport)
302 for ( OUString
const & s : elem.lExtensionList )
304 if ( s.equalsIgnoreAsciiCase( rExt ) )
317 if ( elem.GetShortName().equalsIgnoreAsciiCase( rShortName ) )
327 for (
auto const& elem :
aImport)
329 if ( elem.sType.equalsIgnoreAsciiCase( rType ) )
339 return aImport[ nFormat ].sUIName;
346 return aImport[ nFormat ].sMediaType;
353 return aImport[ nFormat ].GetShortName();
360 return aImport[ nFormat ].lExtensionList[ nEntry ];
367 return aImport[ nFormat ].sType;
374 return aImport[ nFormat ].sFilterType;
389 return aExport[ nFormat ].sFilterName;
396 for (
auto const& elem :
aExport)
398 if ( elem.sUIName.equalsIgnoreAsciiCase( rFormatName ) )
408 for (
auto const& elem :
aExport)
410 if ( elem.sMediaType.equalsIgnoreAsciiCase( rMediaType ) )
422 if ( elem.GetShortName().equalsIgnoreAsciiCase( rShortName ) )
432 for (
auto const& elem :
aExport)
434 if ( elem.sType.equalsIgnoreAsciiCase( rType ) )
444 return aExport[ nFormat ].sUIName;
451 return aExport[ nFormat ].sMediaType;
458 return aExport[ nFormat ].GetShortName();
465 return aExport[ nFormat ].lExtensionList[ nEntry ];
472 return aExport[ nFormat ].sInternalFilterName;
486 return (nFormat <
aExport.size()) &&
aExport[ nFormat ].bIsPixelFormat;
static Reference< XInterface > openConfig(const char *sPackage)
helper to open the configuration root of the underlying config package
bool IsExportPixelFormat(sal_uInt16 nFormat)
sal_uInt16 GetExportFormatNumberForShortName(std::u16string_view rShortName)
OUString GetImportFormatName(sal_uInt16 nFormat)
sal_uInt16 GetImportFormatNumber(std::u16string_view rFormatName)
sal_uInt16 GetExportFormatNumber(std::u16string_view rFormatName)
sal_uInt16 GetImportFormatNumberForShortName(std::u16string_view rShortName)
FilterConfigCache(bool bUseConfig)
OUString GetExportWildcard(sal_uInt16 nFormat, sal_Int32 nEntry)
OUString GetImportFormatShortName(sal_uInt16 nFormat)
sal_uInt16 GetImportFormatNumberForExtension(std::u16string_view rExt)
get the index of the filter that matches this extension
OUString GetImportWildcard(sal_uInt16 nFormat, sal_Int32 nEntry)
OUString GetImportFilterTypeName(sal_uInt16 nFormat)
OUString GetExportFilterName(sal_uInt16 nFormat)
static const char * InternalFilterListForSvxLight[]
OUString GetExportFormatShortName(sal_uInt16 nFormat)
OUString GetExportFormatName(sal_uInt16 nFormat)
OUString GetExportFormatExtension(sal_uInt16 nFormat, sal_Int32 nEntry=0)
OUString GetImportFilterName(sal_uInt16 nFormat)
sal_uInt16 GetExportFormatNumberForTypeName(std::u16string_view rType)
std::vector< FilterConfigCacheEntry > aExport
sal_uInt16 GetExportFormatNumberForMediaType(std::u16string_view rMediaType)
sal_uInt16 GetImportFormatNumberForTypeName(std::u16string_view rType)
OUString GetImportFormatExtension(sal_uInt16 nFormat, sal_Int32 nEntry=0)
OUString GetImportFilterType(sal_uInt16 nFormat)
OUString GetExportFormatMediaType(sal_uInt16 nFormat)
OUString GetImportFormatMediaType(sal_uInt16 nFormat)
std::vector< FilterConfigCacheEntry > aImport
OUString GetExportInternalFilterName(sal_uInt16 nFormat)
#define GRFILTER_FORMAT_NOTFOUND
Reference< XComponentContext > getProcessComponentContext()
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
static const char * InternalPixelFilterNameList[]
OUString sInternalFilterName
void CreateFilterName(const OUString &rUserDataEntry)
std::vector< OUString > lExtensionList