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,
"" );
89 static Reference< XInterface >
openConfig(
const char* sPackage)
93 Reference< XInterface > xCfg;
97 Reference< XMultiServiceFactory > xConfigProvider = theDefaultProvider::get( xContext );
99 Sequence< Any > lParams(1);
100 PropertyValue aParam ;
103 aParam.Name =
"nodepath";
104 if (rtl_str_compareIgnoreAsciiCase(sPackage,
"types") == 0)
105 aParam.Value <<= OUString(
"/org.openoffice.TypeDetection.Types/Types" );
106 if (rtl_str_compareIgnoreAsciiCase(sPackage,
"filters") == 0)
107 aParam.Value <<= OUString(
"/org.openoffice.TypeDetection.GraphicFilter/Filters" );
108 lParams[0] <<= aParam;
111 xCfg = xConfigProvider->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationAccess", lParams);
123 OUString
const STYPE (
"Type" );
124 OUString
const SUINAME (
"UIName" );
125 OUString
const SFLAGS (
"Flags" );
126 OUString
const SMEDIATYPE (
"MediaType" );
127 OUString
const SEXTENSIONS (
"Extensions" );
128 OUString
const SFORMATNAME (
"FormatName" );
129 OUString
const SREALFILTERNAME (
"RealFilterName" );
135 if ( !(xTypeAccess.is() && xFilterAccess.is()) )
140 for (
const OUString& sInternalFilterName : lAllFilter )
143 xFilterAccess->getByName( sInternalFilterName ) >>= xFilterSet;
144 if (!xFilterSet.is())
150 xFilterSet->getPropertyValue(STYPE) >>= aEntry.
sType;
151 xFilterSet->getPropertyValue(SUINAME) >>= aEntry.
sUIName;
152 xFilterSet->getPropertyValue(SREALFILTERNAME) >>= aEntry.
sFilterType;
154 xFilterSet->getPropertyValue(SFLAGS) >>= lFlags;
155 if (lFlags.getLength()!=1 || lFlags[0].isEmpty())
162 OUString sFormatName;
163 xFilterSet->getPropertyValue(SFORMATNAME) >>= sFormatName;
167 xTypeAccess->getByName( aEntry.
sType ) >>= xTypeSet;
171 xTypeSet->getPropertyValue(SMEDIATYPE) >>= aEntry.
sMediaType;
172 css::uno::Sequence<OUString> tmp;
173 if (xTypeSet->getPropertyValue(SEXTENSIONS) >>= tmp)
179 if (aExtension.getLength() != 3)
188 if (!( aEntry.
nFlags & 3 ))
217 "svm",
"1",
"SVMETAFILE",
218 "svm",
"2",
"SVMETAFILE",
240 OUString sExtension( OUString::createFromAscii( *pPtr++ ) );
244 aEntry.
sType = sExtension;
247 OString sFlags( *pPtr++ );
248 aEntry.
nFlags = sFlags.toInt32();
250 OUString sUserData( OUString::createFromAscii( *pPtr ) );
277 return aImport[ nFormat ].sFilterName;
284 for (
auto const& elem :
aImport)
286 if ( elem.sUIName.equalsIgnoreAsciiCase( rFormatName ) )
297 for (
auto const& elem :
aImport)
299 for ( OUString
const & s : elem.lExtensionList )
301 if ( s.equalsIgnoreAsciiCase( rExt ) )
314 if ( elem.GetShortName().equalsIgnoreAsciiCase( rShortName ) )
324 for (
auto const& elem :
aImport)
326 if ( elem.sType.equalsIgnoreAsciiCase( rType ) )
336 return aImport[ nFormat ].sUIName;
350 return aImport[ nFormat ].GetShortName();
357 return aImport[ nFormat ].lExtensionList[ nEntry ];
371 return aImport[ nFormat ].sFilterType;
378 if ( !aWildcard.isEmpty() )
379 aWildcard = aWildcard.replaceAt( 0, 0,
"*." );
386 return aExport[ nFormat ].sFilterName;
393 for (
auto const& elem :
aExport)
395 if ( elem.sUIName.equalsIgnoreAsciiCase( rFormatName ) )
405 for (
auto const& elem :
aExport)
407 if ( elem.sMediaType.equalsIgnoreAsciiCase( rMediaType ) )
419 if ( elem.GetShortName().equalsIgnoreAsciiCase( rShortName ) )
429 for (
auto const& elem :
aExport)
431 if ( elem.sType.equalsIgnoreAsciiCase( rType ) )
441 return aExport[ nFormat ].sUIName;
455 return aExport[ nFormat ].GetShortName();
462 return aExport[ nFormat ].lExtensionList[ nEntry ];
469 return aExport[ nFormat ].sInternalFilterName;
476 if ( !aWildcard.isEmpty() )
477 aWildcard = aWildcard.replaceAt( 0, 0,
"*." );
483 return (nFormat <
aExport.size()) &&
aExport[ nFormat ].bIsPixelFormat;
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)
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)
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)
OUString GetExportFormatMediaType(sal_uInt16 nFormat)
OUString sInternalFilterName
constexpr OUStringLiteral sMediaType
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)
static const char * InternalFilterListForSvxLight[]
OUString GetImportWildcard(sal_uInt16 nFormat, sal_Int32 nEntry)
#define GRFILTER_FORMAT_NOTFOUND