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>
56 "egi",
"icd",
"ipd",
"ipx",
"ipb",
"epb",
"epg",
57 "epp",
"ira",
"era",
"itg",
"exp",
nullptr
67 if (
sFilterName.equalsIgnoreAsciiCaseAscii( *pPtr ) )
75 if (
sFilterName.equalsIgnoreAsciiCaseAscii( *pPtr ) )
82 if (
sFilterName.equalsIgnoreAsciiCaseAscii( *pPtr ) )
93 if ( !lExtensionList.empty() )
95 aShortName = lExtensionList[ 0 ];
96 if ( aShortName.startsWith(
"*." ) )
97 aShortName = aShortName.replaceAt( 0, 2,
"" );
114 static Reference< XInterface >
openConfig(
const char* sPackage)
118 Reference< XInterface > xCfg;
122 Reference< XMultiServiceFactory > xConfigProvider = theDefaultProvider::get( xContext );
124 Sequence< Any > lParams(1);
125 PropertyValue aParam ;
128 aParam.Name =
"nodepath";
129 if (rtl_str_compareIgnoreAsciiCase(sPackage,
"types") == 0)
130 aParam.Value <<= OUString(
"/org.openoffice.TypeDetection.Types/Types" );
131 if (rtl_str_compareIgnoreAsciiCase(sPackage,
"filters") == 0)
132 aParam.Value <<= OUString(
"/org.openoffice.TypeDetection.GraphicFilter/Filters" );
133 lParams[0] <<= aParam;
136 xCfg = xConfigProvider->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationAccess", lParams);
148 OUString
const STYPE (
"Type" );
149 OUString
const SUINAME (
"UIName" );
150 OUString
const SFLAGS (
"Flags" );
151 OUString
const SMEDIATYPE (
"MediaType" );
152 OUString
const SEXTENSIONS (
"Extensions" );
153 OUString
const SFORMATNAME (
"FormatName" );
154 OUString
const SREALFILTERNAME (
"RealFilterName" );
160 if ( !(xTypeAccess.is() && xFilterAccess.is()) )
165 for (
const OUString& sInternalFilterName : lAllFilter )
168 xFilterAccess->getByName( sInternalFilterName ) >>= xFilterSet;
169 if (!xFilterSet.is())
175 xFilterSet->getPropertyValue(STYPE) >>= aEntry.
sType;
176 xFilterSet->getPropertyValue(SUINAME) >>= aEntry.
sUIName;
177 xFilterSet->getPropertyValue(SREALFILTERNAME) >>= aEntry.
sFilterType;
179 xFilterSet->getPropertyValue(SFLAGS) >>= lFlags;
180 if (lFlags.getLength()!=1 || lFlags[0].isEmpty())
187 OUString sFormatName;
188 xFilterSet->getPropertyValue(SFORMATNAME) >>= sFormatName;
192 xTypeAccess->getByName( aEntry.
sType ) >>= xTypeSet;
196 xTypeSet->getPropertyValue(SMEDIATYPE) >>= aEntry.
sMediaType;
197 css::uno::Sequence<OUString> tmp;
198 if (xTypeSet->getPropertyValue(SEXTENSIONS) >>= tmp)
204 if (aExtension.getLength() != 3)
213 if (!( aEntry.
nFlags & 3 ))
244 "svm",
"1",
"SVMETAFILE",
245 "svm",
"2",
"SVMETAFILE",
268 OUString sExtension( OUString::createFromAscii( *pPtr++ ) );
272 aEntry.
sType = sExtension;
275 OString sFlags( *pPtr++ );
276 aEntry.
nFlags = sFlags.toInt32();
278 OUString sUserData( OUString::createFromAscii( *pPtr ) );
305 return aImport[ nFormat ].sFilterName;
312 for (
auto const& elem :
aImport)
314 if ( elem.sUIName.equalsIgnoreAsciiCase( rFormatName ) )
325 for (
auto const& elem :
aImport)
327 for ( OUString
const & s : elem.lExtensionList )
329 if ( s.equalsIgnoreAsciiCase( rExt ) )
342 if ( elem.GetShortName().equalsIgnoreAsciiCase( rShortName ) )
352 for (
auto const& elem :
aImport)
354 if ( elem.sType.equalsIgnoreAsciiCase( rType ) )
364 return aImport[ nFormat ].sUIName;
378 return aImport[ nFormat ].GetShortName();
385 return aImport[ nFormat ].lExtensionList[ nEntry ];
399 return aImport[ nFormat ].sFilterType;
408 return aExport[nFormat].sExternalFilterName;
413 return aImport[nFormat].sExternalFilterName;
421 if ( !aWildcard.isEmpty() )
422 aWildcard = aWildcard.replaceAt( 0, 0,
"*." );
428 return (nFormat <
aImport.size()) &&
aImport[ nFormat ].bIsInternalFilter;
434 return aExport[ nFormat ].sFilterName;
441 for (
auto const& elem :
aExport)
443 if ( elem.sUIName.equalsIgnoreAsciiCase( rFormatName ) )
453 for (
auto const& elem :
aExport)
455 if ( elem.sMediaType.equalsIgnoreAsciiCase( rMediaType ) )
467 if ( elem.GetShortName().equalsIgnoreAsciiCase( rShortName ) )
477 for (
auto const& elem :
aExport)
479 if ( elem.sType.equalsIgnoreAsciiCase( rType ) )
489 return aExport[ nFormat ].sUIName;
503 return aExport[ nFormat ].GetShortName();
510 return aExport[ nFormat ].lExtensionList[ nEntry ];
517 return aExport[ nFormat ].sInternalFilterName;
524 if ( !aWildcard.isEmpty() )
525 aWildcard = aWildcard.replaceAt( 0, 0,
"*." );
531 return (nFormat <
aExport.size()) &&
aExport[ nFormat ].bIsInternalFilter;
536 return (nFormat <
aExport.size()) &&
aExport[ nFormat ].bIsPixelFormat;
OUString GetExternalFilterName(sal_uInt16 nFormat, bool bExport)
OUString GetImportFormatExtension(sal_uInt16 nFormat, sal_Int32 nEntry=0)
OUString GetExportFormatName(sal_uInt16 nFormat)
sal_uInt16 GetImportFormatNumberForTypeName(std::u16string_view rType)
OUString GetImportFilterName(sal_uInt16 nFormat)
static const char * ExternalPixelFilterNameList[]
sal_uInt16 GetExportFormatNumberForTypeName(std::u16string_view rType)
sal_uInt16 GetImportFormatNumberForExtension(std::u16string_view rExt)
get the index of the filter that matches this extension
OUString GetExportFormatExtension(sal_uInt16 nFormat, sal_Int32 nEntry=0)
OUString GetExportInternalFilterName(sal_uInt16 nFormat)
DstType sequenceToContainer(const css::uno::Sequence< SrcType > &i_Sequence)
sal_uInt16 GetImportFormatNumberForShortName(std::u16string_view rShortName)
OUString GetImportFilterType(sal_uInt16 nFormat)
bool IsExportPixelFormat(sal_uInt16 nFormat)
OUString GetImportFormatShortName(sal_uInt16 nFormat)
OUString GetExportWildcard(sal_uInt16 nFormat, sal_Int32 nEntry)
std::vector< FilterConfigCacheEntry > aExport
FilterConfigCache(bool bUseConfig)
OUString GetImportFormatMediaType(sal_uInt16 nFormat)
static const char * InternalVectorFilterNameList[]
sal_uInt16 GetExportFormatNumber(std::u16string_view rFormatName)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
OUString GetImportFilterTypeName(sal_uInt16 nFormat)
sal_uInt16 GetImportFormatNumber(std::u16string_view rFormatName)
static const char * InternalPixelFilterNameList[]
OUString GetImportFormatName(sal_uInt16 nFormat)
std::vector< OUString > lExtensionList
void CreateFilterName(const OUString &rUserDataEntry)
bool IsImportInternalFilter(sal_uInt16 nFormat)
OUString GetExportFormatMediaType(sal_uInt16 nFormat)
OUString sInternalFilterName
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
std::vector< FilterConfigCacheEntry > aImport
Reference< XComponentContext > getProcessComponentContext()
OUString GetExportFilterName(sal_uInt16 nFormat)
sal_uInt16 GetExportFormatNumberForMediaType(std::u16string_view rMediaType)
static Reference< XInterface > openConfig(const char *sPackage)
helper to open the configuration root of the underlying config package
OUString GetExportFormatShortName(sal_uInt16 nFormat)
if(!pCandidateA->getEnd().equal(pCandidateB->getStart()))
sal_uInt16 GetExportFormatNumberForShortName(std::u16string_view rShortName)
bool IsExportInternalFilter(sal_uInt16 nFormat)
static const char * InternalFilterListForSvxLight[]
OUString GetImportWildcard(sal_uInt16 nFormat, sal_Int32 nEntry)
#define GRFILTER_FORMAT_NOTFOUND
OUString sExternalFilterName