28#define AS_ENABLE_FILTER_UINAMES
30#include <com/sun/star/configuration/theDefaultProvider.hpp>
31#include <com/sun/star/util/XChangesBatch.hpp>
32#include <com/sun/star/container/XNameContainer.hpp>
33#include <com/sun/star/lang/XSingleServiceFactory.hpp>
34#include <com/sun/star/beans/NamedValue.hpp>
35#include <com/sun/star/beans/XMultiPropertySet.hpp>
36#include <com/sun/star/beans/XProperty.hpp>
37#include <com/sun/star/beans/PropertyValue.hpp>
38#include <com/sun/star/beans/Property.hpp>
39#include <com/sun/star/beans/PropertyAttribute.hpp>
40#include <com/sun/star/document/CorruptedFilterConfigurationException.hpp>
46#include <rtl/ustrbuf.hxx>
53#include <officecfg/Setup.hxx>
60 : m_eFillState(E_CONTAINS_NOTHING )
63 OUString sStandardProps[10];
80 css::uno::Sequence< OUString >(sStandardProps + 3, 7);
82 css::uno::Sequence< OUString >(sStandardProps, 3);
84 css::uno::Sequence< OUString >(sStandardProps,
88 OUString sTypeProps[7];
101 css::uno::Sequence< OUString >(sTypeProps + 1, 6);
103 css::uno::Sequence< OUString >(sTypeProps, 1);
105 css::uno::Sequence< OUString >(sTypeProps,
124 auto pClone = std::make_unique<FilterCache>();
259 std::vector<OUString> lKeys;
260 lKeys.reserve(rList.size());
264 for (
auto const& elem : rList)
267 (elem.second.haveProps(lIProps) ) &&
268 (elem.second.dontHaveProps(lEProps))
271 lKeys.push_back(elem.first);
290 return !rList.empty();
310 std::vector<OUString> lKeys;
311 for (
auto const& elem : rList)
313 lKeys.push_back(elem.first);
320 const OUString& sItem)
333 CacheItemList::const_iterator pIt = rList.find(sItem);
334 if (pIt != rList.end())
343 catch(
const css::container::NoSuchElementException&)
352 const OUString& sItem)
365 const OUString& sItem)
373 CacheItemList::iterator pIt = rList.find(sItem);
374 if (pIt == rList.end())
391 OUString sDocService;
396 bool bIsHelpFilter = sItem ==
"writer_web_HTML_help";
400 OUString sMsg(
"The requested filter '" + sItem +
401 "' exists ... but it should not; because the corresponding LibreOffice module was not installed.");
402 throw css::container::NoSuchElementException(sMsg, css::uno::Reference< css::uno::XInterface >());
411 const OUString& sItem)
421 CacheItemList::iterator pItem = rList.find(sItem);
422 if (pItem == rList.end())
431 const OUString& sItem ,
452 rList[sItem] = aItem;
459 const OUString& sItem)
468 const OUString& sItem)
477 css::uno::Reference< css::container::XNameAccess > xPackage;
478 css::uno::Reference< css::container::XNameAccess > xSet;
505 OUString sDefaultFrameLoader;
507 (aDirectValue >>= sDefaultFrameLoader) &&
508 (!sDefaultFrameLoader.isEmpty() ) &&
509 (sItem == sDefaultFrameLoader )
513 return css::uno::Any(aProps);
531 bool bFinalized, bMandatory;
534 css::uno::Reference< css::beans::XProperty > xItem;
535 xSet->getByName(sItem) >>= xItem;
536 css::beans::Property aDescription = xItem->getAsProperty();
538 bFinalized = ((aDescription.Attributes & css::beans::PropertyAttribute::READONLY ) == css::beans::PropertyAttribute::READONLY );
539 bMandatory = ((aDescription.Attributes & css::beans::PropertyAttribute::REMOVABLE) != css::beans::PropertyAttribute::REMOVABLE);
542 catch(
const css::container::NoSuchElementException&)
559 return css::uno::Any(aProps);
567 if (pIt != rItem.
end())
570 if (pIt != rItem.
end())
586 css::uno::Reference< css::container::XNameAccess > xSet ;
591 css::uno::Reference< css::util::XChangesBatch > xFlush(xConfig, css::uno::UNO_QUERY);
592 xFlush->commitChanges();
598 css::uno::Reference< css::container::XNameAccess > xSet ;
603 css::uno::Reference< css::util::XChangesBatch > xFlush(xConfig, css::uno::UNO_QUERY);
604 xFlush->commitChanges();
614 const std::vector<OUString>& lItems)
616 css::uno::Reference< css::container::XNameContainer > xAddRemoveSet(xSet, css::uno::UNO_QUERY);
617 css::uno::Reference< css::lang::XSingleServiceFactory >
xFactory(xSet, css::uno::UNO_QUERY);
619 for (
auto const& item : lItems)
626 xAddRemoveSet->removeByName(item);
632 css::uno::Reference< css::container::XNameReplace > xItem (
xFactory->createInstance(), css::uno::UNO_QUERY);
637 throw css::uno::Exception(
"Can not add item. Set is finalized or mandatory!",
638 css::uno::Reference< css::uno::XInterface >());
640 CacheItemList::const_iterator pItem = rCache.find(item);
642 xAddRemoveSet->insertByName(item, css::uno::Any(xItem));
648 css::uno::Reference< css::container::XNameReplace > xItem;
649 xSet->getByName(item) >>= xItem;
654 throw css::uno::Exception(
"Can not change item. It's finalized or mandatory!",
655 css::uno::Reference< css::uno::XInterface >());
657 CacheItemList::const_iterator pItem = rCache.find(item);
677 sExtension = sExtension.toAsciiLowerCase();
690 WildCard aPatternCheck(pattern.first);
693 const std::vector<OUString>& rTypesForPattern = pattern.second;
696 aInfo.
sType = *(rTypesForPattern.begin());
699 rFlatTypes.push_back(aInfo);
712 const std::vector<OUString>& rTypesForExtension = pExtReg->second;
713 for (
auto const& elem : rTypesForExtension)
719 rFlatTypes.push_back(aInfo);
737 throw css::uno::RuntimeException(
"unknown sub container requested.",
738 css::uno::Reference< css::uno::XInterface >());
752 throw css::uno::RuntimeException(
"unknown sub container requested.",
753 css::uno::Reference< css::uno::XInterface >());
759 css::uno::Reference< css::uno::XInterface >* pConfig =
nullptr;
760 css::uno::Reference< css::uno::XInterface > xOld ;
771 sRtlLog =
"impl_openconfig(E_PROVIDER_TYPES)";
781 sRtlLog =
"impl_openconfig(E_PROVIDER_FILTERS)";
791 sRtlLog =
"impl_openconfig(E_PROVIDER_OTHERS)";
801 sRtlLog =
"impl_openconfig(E_PROVIDER_OLD)";
805 default :
throw css::uno::RuntimeException(
"These configuration node is not supported here for open!",
nullptr);
809 SAL_INFO(
"filter.config",
"" << sRtlLog);
844 (!::utl::splitLastFromConfigurationPath(sDirectKey, sRoot, sKey)) ||
845 (sRoot.isEmpty() ) ||
848 return css::uno::Any();
854 return css::uno::Any();
856 css::uno::Reference< css::container::XNameAccess > xAccess(xCfg, css::uno::UNO_QUERY);
858 return css::uno::Any();
860 css::uno::Any aValue;
863 aValue = xAccess->getByName(sKey);
865 catch(
const css::uno::RuntimeException&)
867 catch(
const css::uno::Exception&)
878 const OUString& sRoot ,
882 css::uno::Reference< css::uno::XInterface > xCfg;
888 css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider(
891 ::std::vector< css::uno::Any > lParams;
892 css::beans::NamedValue aParam;
895 aParam.Name =
"nodepath";
896 aParam.Value <<= sRoot;
897 lParams.push_back(css::uno::Any(aParam));
902 aParam.Name =
"locale";
903 aParam.Value <<= OUString(
"*");
904 lParams.push_back(css::uno::Any(aParam));
919 throw css::uno::Exception(
920 "Got NULL reference on opening configuration file ... but no exception.",
921 css::uno::Reference< css::uno::XInterface >());
923 catch(
const css::uno::Exception&
ex)
925 throw css::document::CorruptedFilterConfigurationException(
926 "filter configuration, caught: " +
ex.Message,
927 css::uno::Reference< css::uno::XInterface >(),
943#if OSL_DEBUG_LEVEL > 0
945 sal_Int32 nWarnings = 0;
954 bSomeTypesShouldExist &&
m_lTypes.empty()
961 throw css::document::CorruptedFilterConfigurationException(
962 "filter configuration: the list of types or filters is empty",
963 css::uno::Reference< css::uno::XInterface >(),
964 "The list of types or filters is empty." );
971 sal_Int32 nErrors = 0;
972 OUStringBuffer sLog(256);
976 const OUString &
sType = elem.first;
985 css::uno::Sequence< OUString > lExtensions;
986 css::uno::Sequence< OUString > lURLPattern;
988 if (it != aType.
end())
989 it->second >>= lExtensions;
991 if (it != aType.
end())
992 it->second >>= lURLPattern;
993 sal_Int32 ce = lExtensions.getLength();
994 sal_Int32 cu = lURLPattern.getLength();
996#if OSL_DEBUG_LEVEL > 0
998 OUString sInternalTypeNameCheck;
1000 if (it != aType.
end())
1001 it->second >>= sInternalTypeNameCheck;
1002 if (sInternalTypeNameCheck !=
sType)
1004 sLog.append(
"Warning\t:\t" "The type \"" +
sType +
"\" does support the property \"Name\" correctly.\n");
1010 sLog.append(
"Warning\t:\t" "The type \"" +
sType +
"\" does not contain any URL pattern nor any extensions.\n");
1023 bool bPreferred =
false;
1025 if (it != aType.
end())
1026 it->second >>= bPreferred;
1028 const OUString* pExtensions = lExtensions.getConstArray();
1029 for (sal_Int32 e=0; e<ce; ++e)
1033 OUString sNormalizedExtension = pExtensions[e].toAsciiLowerCase();
1036 if (::std::find(lTypesForExtension.begin(), lTypesForExtension.end(),
sType) != lTypesForExtension.end())
1040 lTypesForExtension.insert(lTypesForExtension.begin(),
sType);
1042 lTypesForExtension.push_back(
sType);
1045 const OUString* pURLPattern = lURLPattern.getConstArray();
1046 for (sal_Int32
u=0;
u<cu; ++
u)
1049 if (::std::find(lTypesForURLPattern.begin(), lTypesForURLPattern.end(),
sType) != lTypesForURLPattern.end())
1053 lTypesForURLPattern.insert(lTypesForURLPattern.begin(),
sType);
1055 lTypesForURLPattern.push_back(
sType);
1058#if OSL_DEBUG_LEVEL > 0
1064 if (!bAllFiltersShouldExist)
1067 OUString sPrefFilter;
1069 if (it != aType.
end())
1070 it->second >>= sPrefFilter;
1071 if (sPrefFilter.isEmpty())
1077 bool bReferencedByLoader =
true;
1078 bool bReferencedByHandler =
true;
1079 if (bAllLoadersShouldExist)
1082 if (bAllHandlersShouldExist)
1086 (!bReferencedByLoader ) &&
1087 (!bReferencedByHandler)
1090 sLog.append(
"Warning\t:\t" "The type \"" +
sType +
"\" is not used by any filter, loader or content handler.\n");
1095 if (!sPrefFilter.isEmpty())
1097 CacheItemList::const_iterator pIt2 =
m_lFilters.find(sPrefFilter);
1100 if (bAllFiltersShouldExist)
1103 sLog.append(
"error\t:\t");
1108 sLog.append(
"warning\t:\t");
1111 sLog.append(
"The type \"" +
sType +
"\" points to an invalid filter \"" + sPrefFilter +
"\".\n");
1116 OUString sFilterTypeReg;
1118 if (sFilterTypeReg !=
sType)
1120 sLog.append(
"error\t:\t" "The preferred filter \"" +
1121 sPrefFilter +
"\" of type \"" +
sType +
1122 "\" is registered for another type \"" + sFilterTypeReg +
1127 sal_Int32 nFlags = 0;
1129 if (!(
static_cast<SfxFilterFlags>(nFlags) & SfxFilterFlags::IMPORT))
1131 sLog.append(
"error\t:\t" "The preferred filter \"" + sPrefFilter +
"\" of type \"" +
1132 sType +
"\" is not an IMPORT filter!\n");
1136 OUString sInternalFilterNameCheck;
1138 if (sInternalFilterNameCheck != sPrefFilter)
1140 sLog.append(
"Warning\t:\t" "The filter \"" + sPrefFilter +
1141 "\" does support the property \"Name\" correctly.\n");
1152 OUString sDefaultFrameLoader;
1155 (!(aDirectValue >>= sDefaultFrameLoader)) ||
1156 (sDefaultFrameLoader.isEmpty() )
1159 sLog.append(
"error\t:\t" "There is no valid default frame loader!?\n");
1174 OUString sLoader = frameLoader.first;
1175 if (sLoader == sDefaultFrameLoader)
1178 CacheItem& rLoader = frameLoader.second;
1180 const css::uno::Sequence<OUString> lTypesReg = rTypesReg.get<css::uno::Sequence<OUString> >();
1182 for (
auto const& typeReg : lTypesReg)
1184 auto pTypeCheck = ::std::find(lTypes.begin(), lTypes.end(), typeReg);
1185 if (pTypeCheck != lTypes.end())
1186 lTypes.erase(pTypeCheck);
1194 OUString sLogOut = sLog.makeStringAndClear();
1195 OSL_ENSURE(!nErrors,
OUStringToOString(sLogOut,RTL_TEXTENCODING_UTF8).getStr());
1197 throw css::document::CorruptedFilterConfigurationException(
1198 "filter configuration: " + sLogOut,
1199 css::uno::Reference< css::uno::XInterface >(),
1201#if OSL_DEBUG_LEVEL > 0
1202 OSL_ENSURE(!nWarnings,
OUStringToOString(sLogOut,RTL_TEXTENCODING_UTF8).getStr());
1207 const OUString& sItem)
1209 std::vector<OUString>* pList =
nullptr;
1228 default :
throw css::uno::RuntimeException(
"unsupported item type",
nullptr);
1231 auto pItem = ::std::find(pList->cbegin(), pList->cend(), sItem);
1232 if (pItem == pList->cend())
1233 pList->push_back(sItem);
1238 const OUString& sItem)
1240 bool bExistsInConfigLayer = xSet->hasByName(sItem);
1241 bool bExistsInMemory = (rList.find(sItem) != rList.end());
1246 if (!bExistsInConfigLayer && !bExistsInMemory)
1248 else if (!bExistsInConfigLayer && bExistsInMemory)
1250 else if (bExistsInConfigLayer && bExistsInMemory)
1252 else if (bExistsInConfigLayer && !bExistsInMemory)
1275 SAL_INFO(
"filter.config",
"FilterCache::load std");
1292 SAL_INFO(
"filter.config",
"FilterCache::load all types");
1309 SAL_INFO(
"filter.config",
"FilterCache::load all filters");
1326 SAL_INFO(
"filter.config",
"FilterCache::load all frame loader");
1343 SAL_INFO(
"filter.config",
"FilterCache::load all content handler");
1357 const css::uno::Reference< css::container::XNameAccess >& xConfig,
1384 css::uno::Reference< css::container::XNameAccess > xSet;
1385 css::uno::Sequence< OUString > lItems;
1389 css::uno::Any aVal = xConfig->getByName(sSetName);
1390 if (!(aVal >>= xSet) || !xSet.is())
1392 OUString sMsg(
"Could not open configuration set \"" + sSetName +
"\".");
1393 throw css::uno::Exception(sMsg, css::uno::Reference< css::uno::XInterface >());
1395 lItems = xSet->getElementNames();
1397 catch(
const css::uno::Exception&
ex)
1399 throw css::document::CorruptedFilterConfigurationException(
1400 "filter configuration, caught: " +
ex.Message,
1401 css::uno::Reference< css::uno::XInterface >(),
1411 const OUString* pItems = lItems.getConstArray();
1412 sal_Int32 c = lItems.getLength();
1413 for (sal_Int32
i=0;
i<c; ++
i)
1415 CacheItemList::iterator pItem = pCache->find(pItems[
i]);
1426 catch(
const css::uno::Exception&
ex)
1428 throw css::document::CorruptedFilterConfigurationException(
1429 "filter configuration, caught: " +
ex.Message,
1430 css::uno::Reference< css::uno::XInterface >(),
1441 if (pItem == pCache->end())
1443 OUString sMsg(
"item \"" + pItems[
i] +
"\" not found for update!");
1444 throw css::uno::Exception(sMsg, css::uno::Reference< css::uno::XInterface >());
1449 pItem->second.update(aItem);
1451 catch(
const css::uno::Exception&
ex)
1453 throw css::document::CorruptedFilterConfigurationException(
1454 "filter configuration, caught: " +
ex.Message,
1455 css::uno::Reference< css::uno::XInterface >(),
1466 const css::uno::Reference< css::container::XNameAccess >& xNode,
1473 css::uno::Reference< css::container::XNameAccess > xUIName;
1474 if (!(aVal >>= xUIName) && !xUIName.is())
1478 xUIName->getElementNames()));
1479 ::std::vector< OUString >::const_iterator
pLocale ;
1482 for (
auto const& locale : lLocales)
1485 xUIName->getByName(locale) >>= sValue;
1487 lUINames[locale] <<= sValue;
1496 if (
pLocale == lLocales.end())
1498#if OSL_DEBUG_LEVEL > 0
1499 if ( sActLocale ==
"en-US" )
1503 SAL_WARN(
"filter.config",
"Fallback scenario for filter or type '" <<
sName <<
"' and locale '" <<
1504 sActLocale <<
"' failed. Please check your filter configuration.");
1509 const OUString& sLocale = *
pLocale;
1511 if (pUIName != lUINames.
end())
1518 css::uno::Reference< css::container::XNameContainer > xAdd (xNode, css::uno::UNO_QUERY);
1521 sal_Int32 c = lUINames.getLength();
1522 const css::beans::PropertyValue* pUINames = lUINames.getConstArray();
1524 for (sal_Int32
i=0;
i<c; ++
i)
1526 if (xNode->hasByName(pUINames[
i].Name))
1527 xNode->replaceByName(pUINames[
i].
Name, pUINames[
i].
Value);
1529 xAdd->insertByName(pUINames[
i].
Name, pUINames[
i].
Value);
1541 const css::uno::Reference< css::container::XNameAccess >& xSet ,
1543 const OUString& sItem ,
1550 css::uno::Reference< css::container::XNameAccess > xItem;
1551 css::uno::Any aVal = xSet->getByName(sItem);
1552 if (!(aVal >>= xItem) || !xItem.is())
1554 throw css::uno::RuntimeException(
"found corrupted item \"" + sItem +
"\".",
1555 css::uno::Reference< css::uno::XInterface >());
1568 assert(eOption >= 0 && eOption <=
E_READ_ALL);
1569 css::uno::Sequence< OUString > &rNames =
m_aTypeProps[eOption];
1572 if (rNames.hasElements())
1574 css::uno::Reference< css::beans::XMultiPropertySet >
1575 xPropSet( xItem, css::uno::UNO_QUERY_THROW);
1576 css::uno::Sequence< css::uno::Any > aValues = xPropSet->getPropertyValues(rNames);
1578 for (sal_Int32
i = 0;
i < aValues.getLength();
i++)
1579 aItem[rNames[
i]] = aValues[
i];
1592 assert(eOption >= 0 && eOption <=
E_READ_ALL);
1596 if (rNames.hasElements())
1598 css::uno::Reference< css::beans::XMultiPropertySet >
1599 xPropSet( xItem, css::uno::UNO_QUERY_THROW);
1600 css::uno::Sequence< css::uno::Any > aValues = xPropSet->getPropertyValues(rNames);
1602 for (sal_Int32
i = 0;
i < rNames.getLength();
i++)
1604 const OUString &rPropName = rNames[
i];
1606 aItem[rPropName] = aValues[
i];
1612 css::uno::Sequence< OUString > lFlagNames;
1613 if (aValues[
i] >>= lFlagNames)
1620#ifdef AS_ENABLE_FILTER_UINAMES
1639 const OUString& sItem)
1642 css::uno::Reference< css::uno::XInterface > xConfig ;
1681 throw css::container::NoSuchElementException();
1683 css::uno::Reference< css::container::XNameAccess > xRoot(xConfig, css::uno::UNO_QUERY_THROW);
1684 css::uno::Reference< css::container::XNameAccess > xSet ;
1685 xRoot->getByName(sSet) >>= xSet;
1687 CacheItemList::iterator pItemInCache = pList->find(sItem);
1688 bool bItemInConfig = xSet->hasByName(sItem);
1696 if (pItemInCache != pList->end())
1697 pList->erase(pItemInCache);
1703 throw css::container::NoSuchElementException();
1706 return pList->find(sItem);
1725 if (pIt != copiedItem.
end())
1728 if (pIt != copiedItem.
end())
1731 if (pIt != copiedItem.
end())
1734 if (pIt != copiedItem.
end())
1737 if (pIt != copiedItem.
end())
1740 if (pIt != copiedItem.
end())
1743 if (pIt != copiedItem.
end())
1746 css::uno::Reference< css::container::XNameReplace > xUIName;
1756 if (pIt != copiedItem.
end())
1759 if (pIt != copiedItem.
end())
1762 if (pIt != copiedItem.
end())
1765 if (pIt != copiedItem.
end())
1768 if (pIt != copiedItem.
end())
1771 if (pIt != copiedItem.
end())
1774 if (pIt != copiedItem.
end())
1780 if (pIt != copiedItem.
end())
1782 sal_Int32 nFlags = 0;
1783 pIt->second >>= nFlags;
1784 css::uno::Any aFlagNameList;
1785 aFlagNameList <<= FilterCache::impl_convertFlagField2FlagNames(static_cast<SfxFilterFlags>(nFlags));
1791#ifdef AS_ENABLE_FILTER_UINAMES
1792 css::uno::Reference< css::container::XNameReplace > xUIName;
1804 if (pIt != copiedItem.
end())
1817 std::vector<OUString> lFlagNames;
1820 if (nFlags & SfxFilterFlags::ALIEN ) lFlagNames.emplace_back(
FLAGNAME_ALIEN );
1822 if (nFlags & SfxFilterFlags::DEFAULT ) lFlagNames.emplace_back(
FLAGNAME_DEFAULT );
1824 if (nFlags & SfxFilterFlags::EXPORT ) lFlagNames.emplace_back(
FLAGNAME_EXPORT );
1825 if (nFlags & SfxFilterFlags::IMPORT ) lFlagNames.emplace_back(
FLAGNAME_IMPORT );
1826 if (nFlags & SfxFilterFlags::INTERNAL ) lFlagNames.emplace_back(
FLAGNAME_INTERNAL );
1829 if (nFlags & SfxFilterFlags::OWN ) lFlagNames.emplace_back(
FLAGNAME_OWN );
1830 if (nFlags & SfxFilterFlags::PACKED ) lFlagNames.emplace_back(
FLAGNAME_PACKED );
1832 if (nFlags & SfxFilterFlags::PREFERED ) lFlagNames.emplace_back(
FLAGNAME_PREFERRED );
1834 if (nFlags & SfxFilterFlags::OPENREADONLY ) lFlagNames.emplace_back(
FLAGNAME_READONLY );
1836 if (nFlags & SfxFilterFlags::TEMPLATE ) lFlagNames.emplace_back(
FLAGNAME_TEMPLATE );
1838 if (nFlags & SfxFilterFlags::COMBINED ) lFlagNames.emplace_back(
FLAGNAME_COMBINED );
1841 if (nFlags & SfxFilterFlags::EXOTIC) lFlagNames.emplace_back(
FLAGNAME_EXOTIC);
1853 const OUString* pNames = lNames.getConstArray();
1854 sal_Int32 c = lNames.getLength();
1855 for (sal_Int32
i=0;
i<c; ++
i)
1859 nField |= SfxFilterFlags::STARONEFILTER;
1864 nField |= SfxFilterFlags::ALIEN;
1869 nField |= SfxFilterFlags::CONSULTSERVICE;
1874 nField |= SfxFilterFlags::DEFAULT;
1879 nField |= SfxFilterFlags::ENCRYPTION;
1884 nField |= SfxFilterFlags::EXOTIC;
1889 nField |= SfxFilterFlags::EXPORT;
1894 nField |= SfxFilterFlags::GPGENCRYPTION;
1899 nField |= SfxFilterFlags::IMPORT;
1904 nField |= SfxFilterFlags::INTERNAL;
1909 nField |= SfxFilterFlags::NOTINFILEDLG;
1914 nField |= SfxFilterFlags::MUSTINSTALL;
1919 nField |= SfxFilterFlags::OWN;
1924 nField |= SfxFilterFlags::PACKED;
1929 nField |= SfxFilterFlags::PASSWORDTOMODIFY;
1934 nField |= SfxFilterFlags::PREFERED;
1939 nField |= SfxFilterFlags::STARTPRESENTATION;
1944 nField |= SfxFilterFlags::SUPPORTSSIGNING;
1949 nField |= SfxFilterFlags::OPENREADONLY;
1954 nField |= SfxFilterFlags::SUPPORTSSELECTION;
1959 nField |= SfxFilterFlags::TEMPLATE;
1964 nField |= SfxFilterFlags::TEMPLATEPATH;
1969 nField |= SfxFilterFlags::COMBINED;
1988 case 1: rItem[
PROPNAME_MEDIATYPE] <<= ::rtl::Uri::decode(sValue, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
1991 case 2: rItem[
PROPNAME_CLIPBOARDFORMAT] <<= ::rtl::Uri::decode(sValue, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
2011 sal_Int32 nOrder = sValue.toInt32();
2014 SAL_WARN(
"filter.config",
"FilterCache::impl_interpretDataVal4Filter()\nCan not move Order value from filter to type on demand!");
2019 case 1: rItem[
PROPNAME_TYPE] <<= ::rtl::Uri::decode(sValue, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
2022 case 2: rItem[
PROPNAME_DOCUMENTSERVICE] <<= ::rtl::Uri::decode(sValue, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
2025 case 3: rItem[
PROPNAME_FILTERSERVICE] <<= ::rtl::Uri::decode(sValue, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
2037 case 7: rItem[
PROPNAME_TEMPLATENAME] <<= ::rtl::Uri::decode(sValue, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
2040 case 8: rItem[
PROPNAME_UICOMPONENT] <<= ::rtl::Uri::decode(sValue, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
2057 css::uno::Reference< css::container::XNameAccess > xCfg(xInt, css::uno::UNO_QUERY_THROW);
2059 OUString TYPES_SET(
"Types");
2062 if (xCfg->hasByName(TYPES_SET))
2064 css::uno::Reference< css::container::XNameAccess > xSet;
2065 xCfg->getByName(TYPES_SET) >>= xSet;
2066 const css::uno::Sequence< OUString > lItems = xSet->getElementNames();
2067 for (
const OUString& rName : lItems)
2071 OUString FILTER_SET(
"Filters");
2073 if (xCfg->hasByName(FILTER_SET))
2075 css::uno::Reference< css::container::XNameAccess > xSet;
2076 xCfg->getByName(FILTER_SET) >>= xSet;
2077 const css::uno::Sequence< OUString > lItems = xSet->getElementNames();
2078 for (
const OUString& rName : lItems)
2086 catch(
const css::uno::Exception&)
2092 const css::uno::Reference< css::container::XNameAccess >& xSet ,
2094 const OUString& sItem)
2096 css::uno::Reference< css::container::XNameAccess > xItem;
2097 xSet->getByName(sItem) >>= xItem;
2099 throw css::uno::Exception(
"Can not read old item.", css::uno::Reference< css::uno::XInterface >());
2112 std::vector<OUString> lData;
2113 xItem->getByName(
"Data" ) >>= sData;
2116 (sData.isEmpty()) ||
2120 throw css::uno::Exception(
"Can not read old item property DATA.", css::uno::Reference< css::uno::XInterface >());
2123 sal_Int32 nProp = 0;
2124 for (
auto const& prop : lData)
2147 std::vector<OUString> lData ;
2152 lData.push_back(sToken);
2158#if OSL_DEBUG_LEVEL > 0
2165 const OUString& sItem = frameLoader.first;
2167 const css::uno::Sequence<OUString> lTypes =
2170 if (::std::find(lTypes.begin(), lTypes.end(),
sType) != lTypes.end())
2182 const OUString& sItem = contentHandler.first;
2184 const css::uno::Sequence<OUString> lTypes =
2186 if (::std::find(lTypes.begin(), lTypes.end(),
sType) != lTypes.end())
2197 css::uno::Reference< css::container::XNameAccess > xCfg;
2201 m_xModuleCfg = officecfg::Setup::Office::Factories::get();
2207 return xCfg->hasByName(sModule);
OUString getExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
::std::vector< OUString >::const_iterator getFallback(const ::std::vector< OUString > &rList, const OUString &rReference)
bool Matches(std::u16string_view rStr) const
iterator erase(iterator it)
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
iterator find(const OUString &rKey)
SequenceAsHashMapBase::iterator iterator
css::uno::Sequence< css::beans::PropertyValue > getAsConstPropertyValueList() const
SequenceAsHashMapBase::const_iterator const_iterator
represent an item of a FilterCache instance.
css::uno::Sequence< css::beans::PropertyValue > getAsPackedPropertyValueList(bool bFinalized, bool bMandatory) const
convert this structure to a seq< PropertyValue > and ignore all empty properties!
void validateUINames(const OUString &sActLocale)
because we know two UIName properties (a list with all locales and the value for the current locale o...
implements a listener, which will update the global filter cache, if the underlying configuration wa ...
implements a cache, which contains all elements of our filter and type detection configuration.
std::unique_ptr< FilterCache > clone() const
creates a copy of this container.
static void impl_interpretDataVal4Filter(const OUString &sValue, sal_Int32 nProp, CacheItem &rItem)
TODO.
std::vector< OUString > m_lChangedContentHandlers
bool hasItems(EItemType eType) const
indicates if the requested sub container contains some items.
void impl_load(std::unique_lock< std::mutex > &rGuard, EFillState eRequiredState)
load the underlying configuration into this cache.
css::uno::Reference< css::uno::XInterface > m_xConfigTypes
holds the used configuration provider alive, which provides access to the list of types.
void impl_readPatchUINames(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< css::container::XNameAccess > &xNode, CacheItem &rItem)
TODO.
css::uno::Reference< css::container::XNameAccess > m_xModuleCfg
readonly access to the module configuration of OOo
OUString impl_searchFrameLoaderForType(const OUString &sType) const
TODO.
std::vector< OUString > getMatchingItemsByProps(EItemType eType, o3tl::span< const css::beans::NamedValue > lIProps, o3tl::span< const css::beans::NamedValue > lEProps={}) const
return a list of key names for items, which match the specified criteria.
static css::uno::Reference< css::uno::XInterface > impl_createConfigAccess(std::unique_lock< std::mutex > &rGuard, const OUString &sRoot, bool bReadOnly, bool bLocalesMode)
tries to open the requested configuration root using the specified modi.
static EItemFlushState impl_specifyFlushOperation(const css::uno::Reference< css::container::XNameAccess > &xSet, const CacheItemList &rList, const OUString &sItem)
specify, which save operation is necessary for the specified item.
css::uno::Reference< css::uno::XInterface > m_xConfigFilters
holds the used configuration provider alive, which provides access to the list of filters.
FilterCache()
standard ctor
static css::uno::Any impl_getDirectCFGValue(std::unique_lock< std::mutex > &rGuard, std::u16string_view sDirectKey)
reads the specified configuration key and return its value.
EFillState
indicates, which items already exists inside this cache and which not.
@ E_CONTAINS_CONTENTHANDLERS
@ E_CONTAINS_FRAMELOADERS
CacheItemRegistration m_lURLPattern2Types
optimize mapping of URL pattern to a type representation, by using patterns as key and a list of inte...
std::vector< OUString > m_lChangedFilters
static std::vector< OUString > impl_tokenizeString(std::u16string_view sData, sal_Unicode cSeparator)
TODO.
CacheItem & impl_getItem(std::unique_lock< std::mutex > &rGuard, EItemType eType, const OUString &sItem)
static css::uno::Sequence< OUString > impl_convertFlagField2FlagNames(SfxFilterFlags nFlags)
convert a flag field value to its list representation of flag names.
const CacheItemList & impl_getItemList(std::unique_lock< std::mutex > &rGuard, EItemType eType) const
return a reference to one of our internal sub container, which contains items of the requested type.
CacheItemRegistration m_lExtensions2Types
optimize mapping of URL extensions to a type representation, by using extensions as key and a list of...
OUString m_sActLocale
contains the current locale of the office and will be used to work with localized configuration value...
void flush()
force writing of all changes (which was made after last flush was called) back to the configuration.
std::vector< OUString > m_lChangedTypes
TODO document me ...
~FilterCache()
standard dtor.
static void impl_savePatchUINames(const css::uno::Reference< css::container::XNameReplace > &xNode, const CacheItem &rItem)
TODO.
css::uno::Reference< css::uno::XInterface > m_xConfigOthers
holds the used configuration provider alive, which provides access to the list of other values needed...
static void impl_flushByList(const css::uno::Reference< css::container::XNameAccess > &xSet, EItemType eType, const CacheItemList &rCache, const std::vector< OUString > &lItems)
TODO.
void impl_loadSet(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< css::container::XNameAccess > &xConfig, EItemType eType, EReadOption eOption, CacheItemList *pCache)
read the specified config set into the cache.
static void removeStatePropsFromItem(CacheItem &aValue)
TODO document me.
std::vector< OUString > getItemNames(EItemType eType) const
return a list of all key names, which represent an item inside the specified sub container.
static SfxFilterFlags impl_convertFlagNames2FlagField(const css::uno::Sequence< OUString > &lNames)
convert a list of flag names to its int representation.
bool isFillState(EFillState eRequired) const
return the current fill state of this cache.
bool hasItem(EItemType eType, const OUString &sItem)
check if the required item exist inside this container.
void load(EFillState eRequired)
force special fill state of this cache.
CacheItemList::iterator impl_loadItemOnDemand(std::unique_lock< std::mutex > &rGuard, EItemType eType, const OUString &sItem)
try to load the requested item on demand from the underlying configuration layer.
EConfigProvider
TODO document me.
void refreshItem(EItemType eType, const OUString &sItem)
TODO document me ...
css::uno::Reference< css::uno::XInterface > impl_openConfig(std::unique_lock< std::mutex > &rGuard, EConfigProvider eProvide)
return a valid configuration update access to the underlying configuration package,...
css::uno::Sequence< OUString > m_aStandardProps[4]
standard property names for filter config keyed by EReadOption
CacheItemList m_lFrameLoaders
contains all loaded frame loader with its properties.
EItemType
identify the type of a container item.
css::uno::Any getItemWithStateProps(EItemType eType, const OUString &sItem)
add some implicit properties to the given cache item reference.
void detectFlatForURL(const css::util::URL &aURL, FlatDetection &rFlatTypes) const
supports a flat type detection for given URL.
rtl::Reference< CacheUpdateListener > m_xFiltersChgListener
EFillState m_eFillState
contains status, which cache items/properties was already loaded from the underlying configuration.
EItemFlushState
indicates the state of a configuration set item.
@ E_ITEM_UNCHANGED
indicates an unchanged item (can occur e.g. if an item was added and(!) removed before it was flushed...
@ E_ITEM_REMOVED
indicates an item, which exists inside config layer but not inside our own cache
@ E_ITEM_ADDED
indicates an item, which does not exists inside config layer but inside our own cache
@ E_ITEM_CHANGED
indicates an item, which exists inside config layer and inside our own cache
EReadOption
regulate, which properties of a configured item will be read.
static void impl_interpretDataVal4Type(const OUString &sValue, sal_Int32 nProp, CacheItem &rItem)
TODO.
rtl::Reference< CacheUpdateListener > m_xTypesChglisteners
void removeItem(EItemType eType, const OUString &sItem)
TODO document me ...
void takeOver(const FilterCache &rClone)
copy the cache content or rClone back to this instance.
void impl_validateAndOptimize(std::unique_lock< std::mutex > &rGuard)
validate the whole cache and create structures for optimized items access.
bool impl_isModuleInstalled(std::unique_lock< std::mutex > &rGuard, const OUString &sModule)
check if the specified OOo module is installed.
CacheItemList m_lFilters
contains all loaded filters with its properties.
CacheItem impl_loadItem(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< css::container::XNameAccess > &xSet, EItemType eType, const OUString &sItem, EReadOption eOption)
read the specified container item from the given configuration set.
void impl_addItem2FlushList(EItemType eType, const OUString &sItem)
TODO.
void setItem(EItemType eType, const OUString &sItem, const CacheItem &aValue)
TODO document me ...
CacheItem impl_readOldItem(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< css::container::XNameAccess > &xSet, EItemType eType, const OUString &sItem)
TODO.
void impl_readOldFormat(std::unique_lock< std::mutex > &rGuard)
TODO.
CacheItem getItem(EItemType eType, const OUString &sItem)
return an item, which match the specified type and name.
CacheItemList m_lTypes
contains all loaded types with its properties.
static void impl_saveItem(const css::uno::Reference< css::container::XNameReplace > &xSet, EItemType eType, const CacheItem &aValue)
TODO.
std::vector< OUString > m_lChangedFrameLoaders
css::uno::Sequence< OUString > m_aTypeProps[4]
type property names for filter config keyed by EReadOption
CacheItemList m_lContentHandlers
contains all loaded content handler with its properties.
OUString impl_searchContentHandlerForType(const OUString &sType) const
constexpr OUStringLiteral FLAGNAME_IMPORT
constexpr OUStringLiteral PROPNAME_FLAGS
constexpr OUStringLiteral PROPNAME_USERDATA
constexpr OUStringLiteral SERVICE_CONFIGURATIONACCESS
constexpr OUStringLiteral FLAGNAME_TEMPLATE
constexpr OUStringLiteral PROPNAME_MEDIATYPE
constexpr OUStringLiteral CFGSET_TYPES
used to identify a set of items against the configuration API.
constexpr OUStringLiteral SERVICE_CONFIGURATIONUPDATEACCESS
some uno service names.
constexpr OUStringLiteral CFGPACKAGE_TD_TYPES
some configuration paths.
constexpr OUStringLiteral PROPNAME_EXPORTEXTENSION
constexpr OUStringLiteral PROPNAME_TEMPLATENAME
constexpr OUStringLiteral FLAGNAME_ALIEN
constexpr OUStringLiteral FLAGNAME_PREFERRED
constexpr OUStringLiteral CFGSET_FILTERS
constexpr OUStringLiteral PROPNAME_PREFERRED
constexpr OUStringLiteral FLAGNAME_EXPORT
constexpr OUStringLiteral PROPNAME_ENABLED
constexpr OUStringLiteral PROPNAME_PREFERREDFILTER
constexpr OUStringLiteral CFGDIRECTKEY_DEFAULTFRAMELOADER
constexpr OUStringLiteral PROPNAME_FILTERSERVICE
constexpr OUStringLiteral FLAGNAME_CONSULTSERVICE
constexpr OUStringLiteral PROPNAME_DETECTSERVICE
constexpr OUStringLiteral FLAGNAME_INTERNAL
constexpr OUStringLiteral PROPNAME_TYPE
used to identify a filter item property against the configuration API and can be used at all name con...
constexpr OUStringLiteral FLAGNAME_SUPPORTSSIGNING
constexpr OUStringLiteral FLAGNAME_NOTINSTALLED
constexpr OUStringLiteral PROPNAME_UINAME
used to identify a type item property against the configuration API and can be used at all name conta...
constexpr OUStringLiteral FLAGNAME_GPGENCRYPTION
constexpr OUStringLiteral PROPNAME_NAME
used to identify a some generic item properties against the configuration API and can be used at all ...
constexpr OUStringLiteral PROPNAME_MANDATORY
constexpr OUStringLiteral FLAGNAME_3RDPARTYFILTER
names of filter flags, sorted in alphabetical order
constexpr OUStringLiteral PROPNAME_UICOMPONENT
constexpr OUStringLiteral FLAGNAME_READONLY
constexpr OUStringLiteral CFGDIRECTKEY_OFFICELOCALE
used to address some configuration keys directly.
constexpr OUStringLiteral CFGSET_FRAMELOADERS
constexpr OUStringLiteral CFGSET_CONTENTHANDLERS
constexpr OUStringLiteral CFGPACKAGE_TD_OLD
constexpr OUStringLiteral FLAGNAME_PACKED
constexpr OUStringLiteral PROPNAME_URLPATTERN
constexpr OUStringLiteral FLAGNAME_SUPPORTSSELECTION
constexpr OUStringLiteral PROPNAME_CLIPBOARDFORMAT
constexpr OUStringLiteral FLAGNAME_OWN
constexpr OUStringLiteral FLAGNAME_PASSWORDTOMODIFY
constexpr OUStringLiteral PROPNAME_FILEFORMATVERSION
constexpr OUStringLiteral PROPNAME_UINAMES
constexpr OUStringLiteral PROPNAME_TYPES
used to identify a frame loader or detect service item property against the configuration API and can...
constexpr OUStringLiteral CFGPACKAGE_TD_FILTERS
constexpr OUStringLiteral PROPNAME_DOCUMENTSERVICE
constexpr OUStringLiteral FLAGNAME_NOTINFILEDIALOG
constexpr OUStringLiteral PROPNAME_FINALIZED
implicit properties.
constexpr OUStringLiteral CFGPACKAGE_TD_OTHERS
constexpr OUStringLiteral FLAGNAME_TEMPLATEPATH
constexpr OUStringLiteral FLAGNAME_EXOTIC
constexpr OUStringLiteral FLAGNAME_DEFAULT
constexpr OUStringLiteral FLAGNAME_COMBINED
constexpr OUStringLiteral FLAGNAME_ENCRYPTION
constexpr OUStringLiteral DEFAULT_OFFICELOCALE
some default values.
constexpr OUStringLiteral FLAGNAME_STARTPRESENTATION
constexpr OUStringLiteral PROPNAME_EXTENSIONS
#define TOOLS_WARN_EXCEPTION(area, stream)
Reference< XSingleServiceFactory > xFactory
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
#define SAL_N_ELEMENTS(arr)
DstType sequenceToContainer(const css::uno::Sequence< SrcType > &i_Sequence)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Reference< XComponentContext > getProcessComponentContext()
::std::vector< FlatDetectionInfo > FlatDetection
std::unordered_map< OUString, CacheItem > CacheItemList
represent an item list of a FilterCache instance.
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
is used to collect all matching types of a URL during type detection.