diff options
Diffstat (limited to 'filter/source')
60 files changed, 1608 insertions, 1298 deletions
diff --git a/filter/source/config/cache/basecontainer.cxx b/filter/source/config/cache/basecontainer.cxx index 97e7b7f22bea..6f9491eeaac1 100644 --- a/filter/source/config/cache/basecontainer.cxx +++ b/filter/source/config/cache/basecontainer.cxx @@ -236,12 +236,10 @@ css::uno::Any SAL_CALL BaseContainer::getByName(const OUString& sItem) // SAFE -> osl::MutexGuard aLock(m_aMutex); - CacheItem aItem; try { FilterCache* pCache = impl_getWorkingCache(); - aItem = pCache->getItem(m_eType, sItem); - pCache->addStatePropsToItem(m_eType, sItem, aItem); // add implicit props "Finalized"/"Mandatory" + aValue = pCache->getItemWithStateProps(m_eType, sItem); } catch(const css::container::NoSuchElementException&) { @@ -250,10 +248,8 @@ css::uno::Any SAL_CALL BaseContainer::getByName(const OUString& sItem) catch(const css::uno::Exception&) { // TODO invalid cache!? How should it be handled right? - aItem.clear(); } - aValue <<= aItem.getAsPackedPropertyValueList(); // <- SAFE return aValue; @@ -430,7 +426,7 @@ void SAL_CALL BaseContainer::flush() throw css::lang::WrappedTargetRuntimeException( "Flush rejected by internal container.", static_cast< OWeakObject* >(this), - css::uno::makeAny(ex)); + css::uno::Any(ex)); } m_pFlushCache.reset(); diff --git a/filter/source/config/cache/cacheitem.cxx b/filter/source/config/cache/cacheitem.cxx index a406b16ff130..dc28b5471d55 100644 --- a/filter/source/config/cache/cacheitem.cxx +++ b/filter/source/config/cache/cacheitem.cxx @@ -40,13 +40,7 @@ CacheItem::CacheItem() void CacheItem::update(const CacheItem& rUpdateItem) { for (auto const& elem : rUpdateItem) - { - iterator pItThis = find(elem.first); - if (pItThis == end()) - (*this)[elem.first] = elem.second; // add new prop - else - pItThis->second = elem.second; // change value of existing prop - } + (*this)[elem.first] = elem.second; } @@ -83,28 +77,35 @@ void CacheItem::validateUINames(const OUString& sActLocale) } -css::uno::Sequence< css::beans::PropertyValue > CacheItem::getAsPackedPropertyValueList() +css::uno::Sequence< css::beans::PropertyValue > CacheItem::getAsPackedPropertyValueList(bool bFinalized, bool bMandatory) const { sal_Int32 c = static_cast<sal_Int32>(size()); sal_Int32 i = 0; - css::uno::Sequence< css::beans::PropertyValue > lList(c); + css::uno::Sequence< css::beans::PropertyValue > lList(c+2); css::beans::PropertyValue* pList = lList.getArray(); for (const_iterator pProp = begin(); pProp != end() ; ++pProp ) { - const OUString& rName = pProp->first; + const OUString& rName = pProp->first.maString; const css::uno::Any& rValue = pProp->second; if (!rValue.hasValue()) continue; + assert (rName != PROPNAME_FINALIZED && rName != PROPNAME_MANDATORY); pList[i].Name = rName ; pList[i].Value = rValue; ++i; } + pList[i].Name = PROPNAME_FINALIZED ; + pList[i].Value <<= bFinalized; + ++i; + pList[i].Name = PROPNAME_MANDATORY ; + pList[i].Value <<= bMandatory; + ++i; lList.realloc(i); return lList; @@ -122,151 +123,141 @@ static bool isSubSet(const css::uno::Any& aSubSet, return false; } - css::uno::TypeClass aTypeClass = aT1.getTypeClass(); - switch(aTypeClass) + if (aSubSet.hasValue() && aSet.hasValue()) { - - case css::uno::TypeClass_BOOLEAN : - case css::uno::TypeClass_BYTE : - case css::uno::TypeClass_SHORT : - case css::uno::TypeClass_UNSIGNED_SHORT : - case css::uno::TypeClass_LONG : - case css::uno::TypeClass_UNSIGNED_LONG : - case css::uno::TypeClass_HYPER : - case css::uno::TypeClass_UNSIGNED_HYPER : - case css::uno::TypeClass_FLOAT : - case css::uno::TypeClass_DOUBLE : - { - bool bIs = (aSubSet == aSet); - return bIs; - } - - - case css::uno::TypeClass_STRING : + css::uno::TypeClass aTypeClass = aT1.getTypeClass(); + switch(aTypeClass) { - OUString v1; - OUString v2; - if ( - (aSubSet >>= v1) && - (aSet >>= v2) - ) + case css::uno::TypeClass_BOOLEAN : + case css::uno::TypeClass_BYTE : + case css::uno::TypeClass_SHORT : + case css::uno::TypeClass_UNSIGNED_SHORT : + case css::uno::TypeClass_LONG : + case css::uno::TypeClass_UNSIGNED_LONG : + case css::uno::TypeClass_HYPER : + case css::uno::TypeClass_UNSIGNED_HYPER : + case css::uno::TypeClass_FLOAT : + case css::uno::TypeClass_DOUBLE : { - bool bIs = v1 == v2; + bool bIs = (aSubSet == aSet); return bIs; } - } - break; - case css::uno::TypeClass_STRUCT : - { - css::beans::PropertyValue p1; - css::beans::PropertyValue p2; + case css::uno::TypeClass_STRING : + return aSubSet == aSet; + break; - if ( - (aSubSet >>= p1) && - (aSet >>= p2) - ) - { - bool bIs = (p1.Name == p2.Name) && isSubSet(p1.Value, p2.Value); - return bIs; - } - css::beans::NamedValue n1; - css::beans::NamedValue n2; - - if ( - (aSubSet >>= n1) && - (aSet >>= n2) - ) + case css::uno::TypeClass_STRUCT : { - bool bIs = (n1.Name == n2.Name) && isSubSet(n1.Value, n2.Value); - return bIs; - } - } - break; + css::beans::PropertyValue p1; + css::beans::PropertyValue p2; + if ( + (aSubSet >>= p1) && + (aSet >>= p2) + ) + { + bool bIs = (p1.Name == p2.Name) && isSubSet(p1.Value, p2.Value); + return bIs; + } - case css::uno::TypeClass_SEQUENCE : - { - css::uno::Sequence< OUString > uno_s1; - css::uno::Sequence< OUString > uno_s2; - - if ( - (aSubSet >>= uno_s1) && - (aSet >>= uno_s2) - ) - { - std::vector<OUString> stl_s1(comphelper::sequenceToContainer< std::vector<OUString> >(uno_s1)); - std::vector<OUString> stl_s2(comphelper::sequenceToContainer< std::vector<OUString> >(uno_s2)); + css::beans::NamedValue n1; + css::beans::NamedValue n2; - for (auto const& elem : stl_s1) + if ( + (aSubSet >>= n1) && + (aSet >>= n2) + ) { - if (::std::find(stl_s2.begin(), stl_s2.end(), elem) == stl_s2.end()) - { - return false; - } + bool bIs = (n1.Name == n2.Name) && isSubSet(n1.Value, n2.Value); + return bIs; } - return true; } + break; - css::uno::Sequence< css::beans::PropertyValue > uno_p1; - css::uno::Sequence< css::beans::PropertyValue > uno_p2; - if ( - (aSubSet >>= uno_p1) && - (aSet >>= uno_p2) - ) + case css::uno::TypeClass_SEQUENCE : { - ::comphelper::SequenceAsHashMap stl_p1(uno_p1); - ::comphelper::SequenceAsHashMap stl_p2(uno_p2); + css::uno::Sequence< OUString > uno_s1; + css::uno::Sequence< OUString > uno_s2; - for (auto const& elem : stl_p1) + if ( + (aSubSet >>= uno_s1) && + (aSet >>= uno_s2) + ) { - ::comphelper::SequenceAsHashMap::const_iterator it2 = stl_p2.find(elem.first); - if (it2 == stl_p2.end()) - { - return false; - } - if (!isSubSet(elem.second, it2->second)) + auto s2Begin = uno_s2.getConstArray(); + auto s2End = uno_s2.getConstArray() + uno_s2.getLength(); + + for (auto const& elem : uno_s1) { - return false; + if (::std::find(s2Begin, s2End, elem) == s2End) + { + return false; + } } + return true; } - return true; - } - css::uno::Sequence< css::beans::NamedValue > uno_n1; - css::uno::Sequence< css::beans::NamedValue > uno_n2; + css::uno::Sequence< css::beans::PropertyValue > uno_p1; + css::uno::Sequence< css::beans::PropertyValue > uno_p2; - if ( - (aSubSet >>= uno_n1) && - (aSet >>= uno_n2) - ) - { - ::comphelper::SequenceAsHashMap stl_n1(uno_n1); - ::comphelper::SequenceAsHashMap stl_n2(uno_n2); - - for (auto const& elem : stl_n1) + if ( + (aSubSet >>= uno_p1) && + (aSet >>= uno_p2) + ) { - ::comphelper::SequenceAsHashMap::const_iterator it2 = stl_n2.find(elem.first); - if (it2 == stl_n2.end()) + ::comphelper::SequenceAsHashMap stl_p1(uno_p1); + ::comphelper::SequenceAsHashMap stl_p2(uno_p2); + + for (auto const& elem : stl_p1) { - return false; + ::comphelper::SequenceAsHashMap::const_iterator it2 = stl_p2.find(elem.first); + if (it2 == stl_p2.end()) + { + return false; + } + if (!isSubSet(elem.second, it2->second)) + { + return false; + } } - if (!isSubSet(elem.second, it2->second)) + return true; + } + + css::uno::Sequence< css::beans::NamedValue > uno_n1; + css::uno::Sequence< css::beans::NamedValue > uno_n2; + + if ( + (aSubSet >>= uno_n1) && + (aSet >>= uno_n2) + ) + { + ::comphelper::SequenceAsHashMap stl_n1(uno_n1); + ::comphelper::SequenceAsHashMap stl_n2(uno_n2); + + for (auto const& elem : stl_n1) { - return false; + ::comphelper::SequenceAsHashMap::const_iterator it2 = stl_n2.find(elem.first); + if (it2 == stl_n2.end()) + { + return false; + } + if (!isSubSet(elem.second, it2->second)) + { + return false; + } } + return true; } - return true; } + break; + default: break; } - break; - default: break; } - OSL_FAIL("isSubSet() ... this point should not be reached!"); return false; } diff --git a/filter/source/config/cache/cacheitem.hxx b/filter/source/config/cache/cacheitem.hxx index 659d6e696201..965bf7a40126 100644 --- a/filter/source/config/cache/cacheitem.hxx +++ b/filter/source/config/cache/cacheitem.hxx @@ -118,7 +118,7 @@ class CacheItem : public ::comphelper::SequenceAsHashMap as a list of all properties of this cacheitem, where empty properties was removed. */ - css::uno::Sequence< css::beans::PropertyValue > getAsPackedPropertyValueList(); + css::uno::Sequence< css::beans::PropertyValue > getAsPackedPropertyValueList(bool bFinalized, bool bMandatory) const; }; diff --git a/filter/source/config/cache/cacheupdatelistener.cxx b/filter/source/config/cache/cacheupdatelistener.cxx index 14331a190c2d..36e2ac160530 100644 --- a/filter/source/config/cache/cacheupdatelistener.cxx +++ b/filter/source/config/cache/cacheupdatelistener.cxx @@ -46,9 +46,9 @@ CacheUpdateListener::~CacheUpdateListener() void CacheUpdateListener::startListening() { // SAFE -> - osl::ClearableMutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); css::uno::Reference< css::util::XChangesNotifier > xNotifier(m_xConfig, css::uno::UNO_QUERY); - aLock.clear(); + aLock.unlock(); // <- SAFE if (!xNotifier.is()) @@ -62,9 +62,9 @@ void CacheUpdateListener::startListening() void CacheUpdateListener::stopListening() { // SAFE -> - osl::ClearableMutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); css::uno::Reference< css::util::XChangesNotifier > xNotifier(m_xConfig, css::uno::UNO_QUERY); - aLock.clear(); + aLock.unlock(); // <- SAFE if (!xNotifier.is()) @@ -78,7 +78,7 @@ void CacheUpdateListener::stopListening() void SAL_CALL CacheUpdateListener::changesOccurred(const css::util::ChangesEvent& aEvent) { // SAFE -> - osl::ClearableMutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); // disposed ? if ( ! m_xConfig.is()) @@ -86,7 +86,7 @@ void SAL_CALL CacheUpdateListener::changesOccurred(const css::util::ChangesEven FilterCache::EItemType eType = m_eConfigType; - aLock.clear(); + aLock.unlock(); // <- SAFE std::vector<OUString> lChangedItems; @@ -172,7 +172,7 @@ void SAL_CALL CacheUpdateListener::changesOccurred(const css::util::ChangesEven void SAL_CALL CacheUpdateListener::disposing(const css::lang::EventObject& aEvent) { // SAFE -> - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); if (aEvent.Source == m_xConfig) m_xConfig.clear(); // <- SAFE diff --git a/filter/source/config/cache/cacheupdatelistener.hxx b/filter/source/config/cache/cacheupdatelistener.hxx index ff7e02759363..fc0789af8dec 100644 --- a/filter/source/config/cache/cacheupdatelistener.hxx +++ b/filter/source/config/cache/cacheupdatelistener.hxx @@ -21,6 +21,7 @@ #include "filtercache.hxx" #include <com/sun/star/util/XChangesListener.hpp> #include <cppuhelper/implbase.hxx> +#include <mutex> namespace filter::config { @@ -30,14 +31,15 @@ namespace filter::config { global filter cache, if the underlying configuration wa changed by other processes. */ -class CacheUpdateListener : public cppu::BaseMutex // must be the first one to guarantee right initialized mutex member! - , public ::cppu::WeakImplHelper< css::util::XChangesListener > +class CacheUpdateListener : public ::cppu::WeakImplHelper< css::util::XChangesListener > { // member private: + std::mutex m_aMutex; + /** @short reference to the singleton(!) filter cache implementation, which should be updated by this thread. */ FilterCache &m_rCache; diff --git a/filter/source/config/cache/contenthandlerfactory.cxx b/filter/source/config/cache/contenthandlerfactory.cxx index 864911798dfd..7e2ec4fc23cc 100644 --- a/filter/source/config/cache/contenthandlerfactory.cxx +++ b/filter/source/config/cache/contenthandlerfactory.cxx @@ -75,7 +75,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL ContentHandlerFactory::crea aHandler >> lConfig; ::std::vector< css::uno::Any > stlArguments(comphelper::sequenceToContainer< ::std::vector< css::uno::Any > >(lArguments)); - stlArguments.insert(stlArguments.begin(), css::uno::makeAny(lConfig)); + stlArguments.insert(stlArguments.begin(), css::uno::Any(lConfig)); xInit->initialize(comphelper::containerToSequence(stlArguments)); } diff --git a/filter/source/config/cache/filtercache.cxx b/filter/source/config/cache/filtercache.cxx index 4cfda1dc8b10..ec995700a366 100644 --- a/filter/source/config/cache/filtercache.cxx +++ b/filter/source/config/cache/filtercache.cxx @@ -51,6 +51,7 @@ #include <i18nlangtag/languagetag.hxx> #include <officecfg/Setup.hxx> +#include <o3tl/string_view.hxx> namespace filter::config{ @@ -256,6 +257,7 @@ std::vector<OUString> FilterCache::getMatchingItemsByProps( EItemType eTyp const CacheItemList& rList = impl_getItemList(eType); std::vector<OUString> lKeys; + lKeys.reserve(rList.size()); // search items, which provides all needed properties of set "lIProps" // but not of set "lEProps"! @@ -348,6 +350,15 @@ CacheItem FilterCache::getItem( EItemType eType, // SAFE -> osl::MutexGuard aLock(m_aMutex); + CacheItem aItem = impl_getItem(eType, sItem); + // <- SAFE + return aItem; +} + + +CacheItem& FilterCache::impl_getItem( EItemType eType, + const OUString& sItem) +{ // search for right list // An exception is thrown if "eType" is unknown. // => rList will be valid everytimes next line is reached. @@ -388,7 +399,6 @@ CacheItem FilterCache::getItem( EItemType eType, } return pIt->second; - // <- SAFE } @@ -449,13 +459,14 @@ void FilterCache::refreshItem( EItemType eType, } -void FilterCache::addStatePropsToItem( EItemType eType, - const OUString& sItem, - CacheItem& rItem) +css::uno::Any FilterCache::getItemWithStateProps( EItemType eType, + const OUString& sItem) { // SAFE -> osl::MutexGuard aLock(m_aMutex); + const CacheItem& rItem = impl_getItem(eType, sItem); + // Note: Opening of the configuration layer throws some exceptions // if it failed. So we mustn't check any reference here... css::uno::Reference< css::container::XNameAccess > xPackage; @@ -493,9 +504,8 @@ void FilterCache::addStatePropsToItem( EItemType eType, (sItem == sDefaultFrameLoader ) ) { - rItem[PROPNAME_FINALIZED] <<= true; - rItem[PROPNAME_MANDATORY] <<= true; - return; + css::uno::Sequence aProps = rItem.getAsPackedPropertyValueList(true, true); + return css::uno::Any(aProps); } /* <-- HACK */ @@ -513,17 +523,16 @@ void FilterCache::addStatePropsToItem( EItemType eType, default: break; } + bool bFinalized, bMandatory; try { css::uno::Reference< css::beans::XProperty > xItem; xSet->getByName(sItem) >>= xItem; css::beans::Property aDescription = xItem->getAsProperty(); - bool bFinalized = ((aDescription.Attributes & css::beans::PropertyAttribute::READONLY ) == css::beans::PropertyAttribute::READONLY ); - bool bMandatory = ((aDescription.Attributes & css::beans::PropertyAttribute::REMOVABLE) != css::beans::PropertyAttribute::REMOVABLE); + bFinalized = ((aDescription.Attributes & css::beans::PropertyAttribute::READONLY ) == css::beans::PropertyAttribute::READONLY ); + bMandatory = ((aDescription.Attributes & css::beans::PropertyAttribute::REMOVABLE) != css::beans::PropertyAttribute::REMOVABLE); - rItem[PROPNAME_FINALIZED] <<= bFinalized; - rItem[PROPNAME_MANDATORY] <<= bMandatory; } catch(const css::container::NoSuchElementException&) { @@ -536,10 +545,13 @@ void FilterCache::addStatePropsToItem( EItemType eType, => mark item as FINALIZED / MANDATORY, we don't support writing to the old format */ - rItem[PROPNAME_FINALIZED] <<= true; - rItem[PROPNAME_MANDATORY] <<= true; + bFinalized = true; + bMandatory = true; } + css::uno::Sequence<css::beans::PropertyValue> aProps = rItem.getAsPackedPropertyValueList(bFinalized, bMandatory); + + return css::uno::Any(aProps); // <- SAFE } @@ -622,7 +634,7 @@ void FilterCache::impl_flushByList(const css::uno::Reference< css::container::XN CacheItemList::const_iterator pItem = rCache.find(item); impl_saveItem(xItem, eType, pItem->second); - xAddRemoveSet->insertByName(item, css::uno::makeAny(xItem)); + xAddRemoveSet->insertByName(item, css::uno::Any(xItem)); } break; @@ -889,14 +901,14 @@ css::uno::Reference< css::uno::XInterface > FilterCache::impl_createConfigAccess // set root path aParam.Name = "nodepath"; aParam.Value <<= sRoot; - lParams.push_back(css::uno::makeAny(aParam)); + lParams.push_back(css::uno::Any(aParam)); // enable "all locales mode" ... if required if (bLocalesMode) { aParam.Name = "locale"; aParam.Value <<= OUString("*"); - lParams.push_back(css::uno::makeAny(aParam)); + lParams.push_back(css::uno::Any(aParam)); } // open it @@ -1176,7 +1188,7 @@ void FilterCache::impl_validateAndOptimize() CacheItem& rLoader = frameLoader.second; css::uno::Any& rTypesReg = rLoader[PROPNAME_TYPES]; - std::vector<OUString> lTypesReg (comphelper::sequenceToContainer< std::vector<OUString> >(rTypesReg.get<css::uno::Sequence<OUString> >())); + const css::uno::Sequence<OUString> lTypesReg = rTypesReg.get<css::uno::Sequence<OUString> >(); for (auto const& typeReg : lTypesReg) { @@ -1272,7 +1284,7 @@ void FilterCache::impl_load(EFillState eRequiredState) ) { // Attention! If config couldn't be opened successfully - // and exception os thrown automatically and must be forwarded + // and exception is thrown automatically and must be forwarded // to our caller... css::uno::Reference< css::container::XNameAccess > xTypes(impl_openConfig(E_PROVIDER_TYPES), css::uno::UNO_QUERY_THROW); { @@ -1289,7 +1301,7 @@ void FilterCache::impl_load(EFillState eRequiredState) ) { // Attention! If config couldn't be opened successfully - // and exception os thrown automatically and must be forwarded + // and exception is thrown automatically and must be forwarded // to our call... css::uno::Reference< css::container::XNameAccess > xTypes(impl_openConfig(E_PROVIDER_TYPES), css::uno::UNO_QUERY_THROW); { @@ -1306,7 +1318,7 @@ void FilterCache::impl_load(EFillState eRequiredState) ) { // Attention! If config couldn't be opened successfully - // and exception os thrown automatically and must be forwarded + // and exception is thrown automatically and must be forwarded // to our call... css::uno::Reference< css::container::XNameAccess > xFilters(impl_openConfig(E_PROVIDER_FILTERS), css::uno::UNO_QUERY_THROW); { @@ -1323,7 +1335,7 @@ void FilterCache::impl_load(EFillState eRequiredState) ) { // Attention! If config couldn't be opened successfully - // and exception os thrown automatically and must be forwarded + // and exception is thrown automatically and must be forwarded // to our call... css::uno::Reference< css::container::XNameAccess > xLoaders(impl_openConfig(E_PROVIDER_OTHERS), css::uno::UNO_QUERY_THROW); { @@ -1340,7 +1352,7 @@ void FilterCache::impl_load(EFillState eRequiredState) ) { // Attention! If config couldn't be opened successfully - // and exception os thrown automatically and must be forwarded + // and exception is thrown automatically and must be forwarded // to our call... css::uno::Reference< css::container::XNameAccess > xHandlers(impl_openConfig(E_PROVIDER_OTHERS), css::uno::UNO_QUERY_THROW); { @@ -2146,14 +2158,14 @@ CacheItem FilterCache::impl_readOldItem(const css::uno::Reference< css::containe } -std::vector<OUString> FilterCache::impl_tokenizeString(const OUString& sData , +std::vector<OUString> FilterCache::impl_tokenizeString(std::u16string_view sData , sal_Unicode cSeparator) { std::vector<OUString> lData ; sal_Int32 nToken = 0; do { - OUString sToken = sData.getToken(0, cSeparator, nToken); + OUString sToken( o3tl::getToken(sData, 0, cSeparator, nToken) ); lData.push_back(sToken); } while(nToken >= 0); @@ -2169,8 +2181,8 @@ OUString FilterCache::impl_searchFrameLoaderForType(const OUString& sType) const { const OUString& sItem = frameLoader.first; ::comphelper::SequenceAsHashMap lProps(frameLoader.second); - std::vector<OUString> lTypes( - comphelper::sequenceToContainer< std::vector<OUString> >(lProps[PROPNAME_TYPES].get<css::uno::Sequence<OUString> >())); + const css::uno::Sequence<OUString> lTypes = + lProps[PROPNAME_TYPES].get<css::uno::Sequence<OUString> >(); if (::std::find(lTypes.begin(), lTypes.end(), sType) != lTypes.end()) return sItem; @@ -2186,8 +2198,8 @@ OUString FilterCache::impl_searchContentHandlerForType(const OUString& sType) co { const OUString& sItem = contentHandler.first; ::comphelper::SequenceAsHashMap lProps(contentHandler.second); - std::vector<OUString> lTypes( - comphelper::sequenceToContainer< std::vector<OUString> >( lProps[PROPNAME_TYPES].get<css::uno::Sequence<OUString> >() )); + const css::uno::Sequence<OUString> lTypes = + lProps[PROPNAME_TYPES].get<css::uno::Sequence<OUString> >(); if (::std::find(lTypes.begin(), lTypes.end(), sType) != lTypes.end()) return sItem; } diff --git a/filter/source/config/cache/filtercache.hxx b/filter/source/config/cache/filtercache.hxx index 42be4314cb38..8cb34701cc2a 100644 --- a/filter/source/config/cache/filtercache.hxx +++ b/filter/source/config/cache/filtercache.hxx @@ -524,10 +524,8 @@ class FilterCache : public cppu::BaseMutex was not migrated to the new one. So we can't provide write access to such items... */ - void addStatePropsToItem( EItemType eType, - const OUString& sItem, - CacheItem& rItem); - + css::uno::Any getItemWithStateProps( EItemType eType, + const OUString& sItem); /** TODO document me @@ -600,6 +598,7 @@ class FilterCache : public cppu::BaseMutex CacheItemList& impl_getItemList(EItemType eType); + CacheItem& impl_getItem( EItemType eType, const OUString& sItem); /** @short return a valid configuration update access to the underlying configuration package, which @@ -891,7 +890,7 @@ class FilterCache : public cppu::BaseMutex /** TODO */ - static std::vector<OUString> impl_tokenizeString(const OUString& sData , + static std::vector<OUString> impl_tokenizeString(std::u16string_view sData , sal_Unicode cSeparator); diff --git a/filter/source/config/cache/filterfactory.cxx b/filter/source/config/cache/filterfactory.cxx index 6bcb0cc4e326..d98b2f3174e7 100644 --- a/filter/source/config/cache/filterfactory.cxx +++ b/filter/source/config/cache/filterfactory.cxx @@ -103,7 +103,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL FilterFactory::createInstan aFilter >> lConfig; ::std::vector< css::uno::Any > stlArguments(comphelper::sequenceToContainer< ::std::vector< css::uno::Any > >(lArguments)); - stlArguments.insert(stlArguments.begin(), css::uno::makeAny(lConfig)); + stlArguments.insert(stlArguments.begin(), css::uno::Any(lConfig)); xInit->initialize(comphelper::containerToSequence(stlArguments)); } @@ -391,7 +391,7 @@ std::vector<OUString> FilterFactory::impl_getSortedFilterList(const QueryTokeniz { // more complex search for all filters // We check first, which office modules are installed... - std::vector<OUString> lModules = impl_getListOfInstalledModules(); + const css::uno::Sequence<OUString> lModules = impl_getListOfInstalledModules(); for (auto const& module : lModules) { std::vector<OUString> lFilters4Module = impl_getSortedFilterListForModule(module, nIFlags, nEFlags); @@ -406,17 +406,10 @@ std::vector<OUString> FilterFactory::impl_getSortedFilterList(const QueryTokeniz } -std::vector<OUString> FilterFactory::impl_getListOfInstalledModules() const +css::uno::Sequence<OUString> FilterFactory::impl_getListOfInstalledModules() { - // SAFE -> ---------------------- - osl::ClearableMutexGuard aLock(m_aMutex); - css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext; - aLock.clear(); - // <- SAFE ---------------------- - - css::uno::Reference< css::container::XNameAccess > xModuleConfig = officecfg::Setup::Office::Factories::get(xContext); - std::vector<OUString> lModules(comphelper::sequenceToContainer< std::vector<OUString> >(xModuleConfig->getElementNames())); - return lModules; + css::uno::Reference< css::container::XNameAccess > xModuleConfig = officecfg::Setup::Office::Factories::get(); + return xModuleConfig->getElementNames(); } @@ -469,17 +462,11 @@ std::vector<OUString> FilterFactory::impl_getSortedFilterListForModule(const OUS } -std::vector<OUString> FilterFactory::impl_readSortedFilterListFromConfig(const OUString& sModule) const +std::vector<OUString> FilterFactory::impl_readSortedFilterListFromConfig(const OUString& sModule) { - // SAFE -> ---------------------- - osl::ClearableMutexGuard aLock(m_aMutex); - css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext; - aLock.clear(); - // <- SAFE ---------------------- - try { - css::uno::Reference< css::container::XNameAccess > xUISortConfig = officecfg::TypeDetection::UISort::ModuleDependendFilterOrder::get(xContext); + css::uno::Reference< css::container::XNameAccess > xUISortConfig = officecfg::TypeDetection::UISort::ModuleDependendFilterOrder::get(); // don't check the module name here. If it does not exists, an exception is thrown and caught below. // We return an empty list as result then. css::uno::Reference< css::container::XNameAccess > xModule; diff --git a/filter/source/config/cache/filterfactory.hxx b/filter/source/config/cache/filterfactory.hxx index 19abea5d6db0..9be370f4dc56 100644 --- a/filter/source/config/cache/filterfactory.hxx +++ b/filter/source/config/cache/filterfactory.hxx @@ -95,7 +95,7 @@ class FilterFactory : public ::cppu::ImplInheritanceHelper< BaseContainer /** TODO document me */ - std::vector<OUString> impl_getListOfInstalledModules() const; + static css::uno::Sequence<OUString> impl_getListOfInstalledModules(); /** @short implement the container string query: @@ -126,7 +126,7 @@ class FilterFactory : public ::cppu::ImplInheritanceHelper< BaseContainer @return A string list of internal filter names. Can be empty. */ - std::vector<OUString> impl_readSortedFilterListFromConfig(const OUString& sModule) const; + static std::vector<OUString> impl_readSortedFilterListFromConfig(const OUString& sModule); }; diff --git a/filter/source/config/cache/frameloaderfactory.cxx b/filter/source/config/cache/frameloaderfactory.cxx index 3627ea93faa1..af03dbec96f2 100644 --- a/filter/source/config/cache/frameloaderfactory.cxx +++ b/filter/source/config/cache/frameloaderfactory.cxx @@ -73,7 +73,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL FrameLoaderFactory::createI aLoader >> lConfig; ::std::vector< css::uno::Any > stlArguments(comphelper::sequenceToContainer< ::std::vector<css::uno::Any> >(lArguments)); - stlArguments.insert(stlArguments.begin(), css::uno::makeAny(lConfig)); + stlArguments.insert(stlArguments.begin(), css::uno::Any(lConfig)); xInit->initialize(comphelper::containerToSequence(stlArguments)); } diff --git a/filter/source/config/cache/querytokenizer.cxx b/filter/source/config/cache/querytokenizer.cxx index 9b64f68fe6d8..f5b021f53b45 100644 --- a/filter/source/config/cache/querytokenizer.cxx +++ b/filter/source/config/cache/querytokenizer.cxx @@ -20,23 +20,24 @@ #include "querytokenizer.hxx" #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> namespace filter::config{ -QueryTokenizer::QueryTokenizer(const OUString& sQuery) +QueryTokenizer::QueryTokenizer(std::u16string_view sQuery) : m_bValid(true) { sal_Int32 token = 0; while(token != -1) { - OUString sToken = sQuery.getToken(0, ':', token); - if (!sToken.isEmpty()) + std::u16string_view sToken = o3tl::getToken(sQuery,0, ':', token); + if (!sToken.empty()) { sal_Int32 nIdx{ 0 }; - const OUString sKey{ sToken.getToken(0, '=', nIdx) }; - const OUString sVal{ sToken.getToken(0, ':', nIdx) }; + const OUString sKey{ o3tl::getToken(sToken, 0, '=', nIdx) }; + const OUString sVal{ o3tl::getToken(sToken, 0, ':', nIdx) }; if (sKey.isEmpty()) m_bValid = false; diff --git a/filter/source/config/cache/querytokenizer.hxx b/filter/source/config/cache/querytokenizer.hxx index e0b8d5218130..0c7e79b3ddc7 100644 --- a/filter/source/config/cache/querytokenizer.hxx +++ b/filter/source/config/cache/querytokenizer.hxx @@ -73,7 +73,7 @@ class QueryTokenizer : public std::unordered_map< OUString, OUString > @param sQuery the query string. */ - explicit QueryTokenizer(const OUString& sQuery); + explicit QueryTokenizer(std::u16string_view sQuery); /** @short destruct an instance of this class. diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx index ac4d9aed9f2a..8ea578f7161a 100644 --- a/filter/source/config/cache/typedetection.cxx +++ b/filter/source/config/cache/typedetection.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/task/XInteractionHandler.hpp> +#include <o3tl/string_view.hxx> #include <tools/wldcrd.hxx> #include <sal/log.hxx> #include <framework/interaction.hxx> @@ -125,7 +126,7 @@ namespace { * In each category, rank them from strictly-structured to * loosely-structured. */ -int getFlatTypeRank(const OUString& rType) +int getFlatTypeRank(std::u16string_view rType) { // List formats from more complex to less complex. // TODO: Add more. @@ -232,6 +233,7 @@ int getFlatTypeRank(const OUString& rType) "pcd_Photo_CD_Base", "pcd_Photo_CD_Base4", "pcd_Photo_CD_Base16", + "webp_WebP", "impress_CGM_Computer_Graphics_Metafile", // There is binary and ascii variants ? "draw_WordPerfect_Graphics", "draw_Visio_Document", @@ -286,7 +288,7 @@ int getFlatTypeRank(const OUString& rType) for (size_t i = 0; i < n; ++i) { - if (rType.equalsAscii(ranks[i])) + if (o3tl::equalsAscii(rType, ranks[i])) return n - i - 1; } @@ -669,8 +671,8 @@ bool TypeDetection::impl_getPreselectionForType( // otherwise we must know, if it matches to the given URL really. // especially if it matches by its extension or pattern registration. - std::vector<OUString> lExtensions(comphelper::sequenceToContainer< std::vector<OUString> >(aType[PROPNAME_EXTENSIONS].get<css::uno::Sequence<OUString> >() )); - std::vector<OUString> lURLPattern(comphelper::sequenceToContainer< std::vector<OUString> >(aType[PROPNAME_URLPATTERN].get<css::uno::Sequence<OUString> >() )); + const css::uno::Sequence<OUString> lExtensions = aType[PROPNAME_EXTENSIONS].get<css::uno::Sequence<OUString> >(); + const css::uno::Sequence<OUString> lURLPattern = aType[PROPNAME_URLPATTERN].get<css::uno::Sequence<OUString> >(); for (auto const& extension : lExtensions) { diff --git a/filter/source/config/cache/typedetection.hxx b/filter/source/config/cache/typedetection.hxx index 79145e836d17..11441039234c 100644 --- a/filter/source/config/cache/typedetection.hxx +++ b/filter/source/config/cache/typedetection.hxx @@ -24,6 +24,7 @@ #include <unotools/mediadescriptor.hxx> #include <cppuhelper/compbase.hxx> #include <cppuhelper/implbase.hxx> +#include <comphelper/compbase.hxx> namespace filter::config { @@ -316,15 +317,14 @@ public: }; -class TerminateDetection : public cppu::WeakComponentImplHelper<css::frame::XTerminateListener> +class TerminateDetection : public comphelper::WeakComponentImplHelper<css::frame::XTerminateListener> { private: - osl::Mutex m_aLock; TypeDetection* m_pTypeDetection; public: - using cppu::WeakComponentImplHelperBase::disposing; + using comphelper::WeakComponentImplHelperBase::disposing; virtual void SAL_CALL disposing(const css::lang::EventObject&) override { } @@ -340,8 +340,7 @@ public: } TerminateDetection(TypeDetection* pTypeDetection) - : cppu::WeakComponentImplHelper<css::frame::XTerminateListener>(m_aLock) - , m_pTypeDetection(pTypeDetection) + : m_pTypeDetection(pTypeDetection) { } }; diff --git a/filter/source/config/fragments/filters/WEBP___WebP.xcu b/filter/source/config/fragments/filters/WEBP___WebP.xcu new file mode 100644 index 000000000000..9c650e3de42e --- /dev/null +++ b/filter/source/config/fragments/filters/WEBP___WebP.xcu @@ -0,0 +1,30 @@ +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> + <node oor:name="WEBP - WebP" oor:op="replace"> + <prop oor:name="Flags"><value>IMPORT ALIEN</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="FilterService"/> + <prop oor:name="UserData"><value></value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">WEBP - WebP Image</value> + </prop> + <prop oor:name="FileFormatVersion"><value>0</value></prop> + <prop oor:name="Type"><value>webp_WebP</value></prop> + <prop oor:name="TemplateName"/> + <prop oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop> + </node> diff --git a/filter/source/config/fragments/filters/calc_webp_Export.xcu b/filter/source/config/fragments/filters/calc_webp_Export.xcu new file mode 100644 index 000000000000..a6e5d18a3347 --- /dev/null +++ b/filter/source/config/fragments/filters/calc_webp_Export.xcu @@ -0,0 +1,20 @@ +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. +--> + <node oor:name="calc_webp_Export" oor:op="replace"> + <prop oor:name="Flags"><value>EXPORT ALIEN 3RDPARTYFILTER SUPPORTSSELECTION</value></prop> + <prop oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop> + <prop oor:name="FilterService"><value>com.sun.star.comp.GraphicExportFilter</value></prop> + <prop oor:name="UserData"><value></value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">WEBP - WebP Image</value> + </prop> + <prop oor:name="FileFormatVersion"><value>0</value></prop> + <prop oor:name="Type"><value>webp_WebP</value></prop> + <prop oor:name="TemplateName"/> + <prop oor:name="DocumentService"><value>com.sun.star.sheet.SpreadsheetDocument</value></prop> + </node> diff --git a/filter/source/config/fragments/filters/draw_webp_Export.xcu b/filter/source/config/fragments/filters/draw_webp_Export.xcu new file mode 100644 index 000000000000..e6da69197a61 --- /dev/null +++ b/filter/source/config/fragments/filters/draw_webp_Export.xcu @@ -0,0 +1,30 @@ +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> + <node oor:name="draw_webp_Export" oor:op="replace"> + <prop oor:name="Flags"><value>EXPORT ALIEN SUPPORTSSELECTION</value></prop> + <prop oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop> + <prop oor:name="FilterService"/> + <prop oor:name="UserData"><value></value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">WEBP - WebP Image</value> + </prop> + <prop oor:name="FileFormatVersion"><value>0</value></prop> + <prop oor:name="Type"><value>webp_WebP</value></prop> + <prop oor:name="TemplateName"/> + <prop oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop> + </node> diff --git a/filter/source/config/fragments/filters/impress_webp_Export.xcu b/filter/source/config/fragments/filters/impress_webp_Export.xcu new file mode 100644 index 000000000000..00284a272cba --- /dev/null +++ b/filter/source/config/fragments/filters/impress_webp_Export.xcu @@ -0,0 +1,30 @@ +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> + <node oor:name="impress_webp_Export" oor:op="replace"> + <prop oor:name="Flags"><value>EXPORT ALIEN SUPPORTSSELECTION</value></prop> + <prop oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop> + <prop oor:name="FilterService"/> + <prop oor:name="UserData"><value></value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">WEBP - WebP Image</value> + </prop> + <prop oor:name="FileFormatVersion"><value>0</value></prop> + <prop oor:name="Type"><value>webp_WebP</value></prop> + <prop oor:name="TemplateName"/> + <prop oor:name="DocumentService"><value>com.sun.star.presentation.PresentationDocument</value></prop> + </node> diff --git a/filter/source/config/fragments/filters/writer_web_webp_Export.xcu b/filter/source/config/fragments/filters/writer_web_webp_Export.xcu new file mode 100644 index 000000000000..5273bb72228b --- /dev/null +++ b/filter/source/config/fragments/filters/writer_web_webp_Export.xcu @@ -0,0 +1,21 @@ +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * +--> + <node oor:name="writer_web_webp_Export" oor:op="replace"> + <prop oor:name="Flags"><value>EXPORT ALIEN 3RDPARTYFILTER</value></prop> + <prop oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop> + <prop oor:name="FilterService"><value>com.sun.star.comp.GraphicExportFilter</value></prop> + <prop oor:name="UserData"><value></value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">WEBP - WebP Image</value> + </prop> + <prop oor:name="FileFormatVersion"><value>0</value></prop> + <prop oor:name="Type"><value>webp_WebP</value></prop> + <prop oor:name="TemplateName"/> + <prop oor:name="DocumentService"><value>com.sun.star.text.WebDocument</value></prop> + </node> diff --git a/filter/source/config/fragments/filters/writer_webp_Export.xcu b/filter/source/config/fragments/filters/writer_webp_Export.xcu new file mode 100644 index 000000000000..ceb56a8c035f --- /dev/null +++ b/filter/source/config/fragments/filters/writer_webp_Export.xcu @@ -0,0 +1,30 @@ +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> + <node oor:name="writer_webp_Export" oor:op="replace"> + <prop oor:name="Flags"><value>EXPORT ALIEN 3RDPARTYFILTER</value></prop> + <prop oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop> + <prop oor:name="FilterService"><value>com.sun.star.comp.GraphicExportFilter</value></prop> + <prop oor:name="UserData"><value></value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">WEBP - WebP Image</value> + </prop> + <prop oor:name="FileFormatVersion"><value>0</value></prop> + <prop oor:name="Type"><value>webp_WebP</value></prop> + <prop oor:name="TemplateName"/> + <prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop> + </node> diff --git a/filter/source/config/fragments/internalgraphicfilters/webp_Export.xcu b/filter/source/config/fragments/internalgraphicfilters/webp_Export.xcu new file mode 100644 index 000000000000..70ff15429734 --- /dev/null +++ b/filter/source/config/fragments/internalgraphicfilters/webp_Export.xcu @@ -0,0 +1,27 @@ +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> + <node oor:name="webp_Export" oor:op="replace" > + <prop oor:name="Type"><value>webp_WebP</value></prop> + <prop oor:name="FormatName"><value>SVEWEBP</value></prop> + <prop oor:name="RealFilterName"/> + <prop oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">WEBP - WebP Image</value> + </prop> + <prop oor:name="Flags"><value>EXPORT</value></prop> + </node> diff --git a/filter/source/config/fragments/internalgraphicfilters/webp_Import.xcu b/filter/source/config/fragments/internalgraphicfilters/webp_Import.xcu new file mode 100644 index 000000000000..cdce5c9e4047 --- /dev/null +++ b/filter/source/config/fragments/internalgraphicfilters/webp_Import.xcu @@ -0,0 +1,27 @@ +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> + <node oor:name="webp_Import" oor:op="replace" > + <prop oor:name="Type"><value>webp_WebP</value></prop> + <prop oor:name="FormatName"><value>SVIWEBP</value></prop> + <prop oor:name="RealFilterName"><value>WEBP - WebP</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="UIName"> + <value xml:lang="en-US">WEBP - WebP Image</value> + </prop> + <prop oor:name="Flags"><value>IMPORT</value></prop> + </node> diff --git a/filter/source/config/fragments/types/emf_MS_Windows_Metafile.xcu b/filter/source/config/fragments/types/emf_MS_Windows_Metafile.xcu index 6d1564bebd07..2003217aad30 100644 --- a/filter/source/config/fragments/types/emf_MS_Windows_Metafile.xcu +++ b/filter/source/config/fragments/types/emf_MS_Windows_Metafile.xcu @@ -18,7 +18,7 @@ <node oor:name="emf_MS_Windows_Metafile" oor:op="replace" > <prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop> <prop oor:name="URLPattern"/> - <prop oor:name="Extensions"><value>emf</value></prop> + <prop oor:name="Extensions"><value>emf emz</value></prop> <prop oor:name="MediaType"><value>image/x-emf</value></prop> <prop oor:name="Preferred"><value>false</value></prop> <prop oor:name="PreferredFilter"><value>EMF - MS Windows Metafile</value></prop> diff --git a/filter/source/config/fragments/types/webp_WebP.xcu b/filter/source/config/fragments/types/webp_WebP.xcu new file mode 100644 index 000000000000..e58984fbedc7 --- /dev/null +++ b/filter/source/config/fragments/types/webp_WebP.xcu @@ -0,0 +1,29 @@ +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> + <node oor:name="webp_WebP" oor:op="replace" > + <prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop> + <prop oor:name="URLPattern"/> + <prop oor:name="Extensions"><value>webp</value></prop> + <prop oor:name="MediaType"><value>image/webp</value></prop> + <prop oor:name="Preferred"><value>false</value></prop> + <prop oor:name="PreferredFilter"><value>WEBP - WebP</value></prop> + <prop oor:name="UIName"> + <value>WEBP - WebP Image</value> + </prop> + <prop oor:name="ClipboardFormat"/> + </node> diff --git a/filter/source/config/fragments/types/wmf_MS_Windows_Metafile.xcu b/filter/source/config/fragments/types/wmf_MS_Windows_Metafile.xcu index 54c6bf54c33b..7564dd057cf4 100644 --- a/filter/source/config/fragments/types/wmf_MS_Windows_Metafile.xcu +++ b/filter/source/config/fragments/types/wmf_MS_Windows_Metafile.xcu @@ -18,7 +18,7 @@ <node oor:name="wmf_MS_Windows_Metafile" oor:op="replace" > <prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop> <prop oor:name="URLPattern"/> - <prop oor:name="Extensions"><value>wmf</value></prop> + <prop oor:name="Extensions"><value>wmf wmz</value></prop> <prop oor:name="MediaType"><value>image/x-wmf</value></prop> <prop oor:name="Preferred"><value>false</value></prop> <prop oor:name="PreferredFilter"><value>WMF - MS Windows Metafile</value></prop> diff --git a/filter/source/graphic/GraphicExportFilter.cxx b/filter/source/graphic/GraphicExportFilter.cxx index e20c56ddf232..b0b93222dfa3 100644 --- a/filter/source/graphic/GraphicExportFilter.cxx +++ b/filter/source/graphic/GraphicExportFilter.cxx @@ -163,7 +163,7 @@ bool GraphicExportFilter::filterRenderDocument() const SvMemoryStream aMemStream; const GraphicConversionParameters aParameters(aTargetSizePixel, true, true); - const ErrCode nResult = rFilter.ExportGraphic( aGraphic.GetBitmapEx(aParameters), OUString(), aMemStream, + const ErrCode nResult = rFilter.ExportGraphic( aGraphic.GetBitmapEx(aParameters), u"", aMemStream, nFilterFormat, &maFilterDataSequence ); if ( nResult == ERRCODE_NONE ) diff --git a/filter/source/graphicfilter/icgm/actimpr.cxx b/filter/source/graphicfilter/icgm/actimpr.cxx index bb17a380c3b2..c77b55184c5a 100644 --- a/filter/source/graphicfilter/icgm/actimpr.cxx +++ b/filter/source/graphicfilter/icgm/actimpr.cxx @@ -791,7 +791,7 @@ void CGMImpressOutAct::DrawText(awt::Point const & rTextPos, awt::Size const & r maXShape->setSize( awt::Size( nWidth, nHeight ) ); double nX = mpCGM->pElement->nCharacterOrientation[ 2 ]; double nY = mpCGM->pElement->nCharacterOrientation[ 3 ]; - double fSqrt = sqrt(nX * nX + nY * nY); + double fSqrt = std::hypot(nX, nY); double nOrientation = fSqrt != 0.0 ? basegfx::rad2deg(acos(nX / fSqrt)) : 0.0; if ( nY < 0 ) nOrientation = 360 - nOrientation; diff --git a/filter/source/graphicfilter/icgm/bitmap.cxx b/filter/source/graphicfilter/icgm/bitmap.cxx index cb319cb038e0..67652d9eccd6 100644 --- a/filter/source/graphicfilter/icgm/bitmap.cxx +++ b/filter/source/graphicfilter/icgm/bitmap.cxx @@ -216,17 +216,17 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc ) double nX = rDesc.mnR.X - rDesc.mnQ.X; double nY = rDesc.mnR.Y - rDesc.mnQ.Y; - rDesc.mndy = sqrt( nX * nX + nY * nY ); + rDesc.mndy = std::hypot(nX, nY); nX = rDesc.mnR.X - rDesc.mnP.X; nY = rDesc.mnR.Y - rDesc.mnP.Y; - rDesc.mndx = sqrt( nX * nX + nY * nY ); + rDesc.mndx = std::hypot(nX, nY); nX = rDesc.mnR.X - rDesc.mnP.X; nY = rDesc.mnR.Y - rDesc.mnP.Y; - double fSqrt = sqrt(nX * nX + nY * nY); + double fSqrt = std::hypot(nX, nY); rDesc.mnOrientation = fSqrt != 0.0 ? basegfx::rad2deg(acos(nX / fSqrt)) : 0.0; if ( nY > 0 ) rDesc.mnOrientation = 360 - rDesc.mnOrientation; @@ -240,7 +240,7 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc ) nX = fCos * nX + fSin * nY; nY = -( fSin * nX - fCos * nY ); - fSqrt = sqrt(nX * nX + nY * nY); + fSqrt = std::hypot(nX, nY); fAngle = fSqrt != 0.0 ? basegfx::rad2deg(acos(nX / fSqrt)) : 0.0; if ( nY > 0 ) fAngle = 360 - fAngle; diff --git a/filter/source/graphicfilter/icgm/class4.cxx b/filter/source/graphicfilter/icgm/class4.cxx index edf34970a27f..af66ff26ae09 100644 --- a/filter/source/graphicfilter/icgm/class4.cxx +++ b/filter/source/graphicfilter/icgm/class4.cxx @@ -36,7 +36,7 @@ double CGM::ImplGetOrientation( FloatPoint const & rCenter, FloatPoint const & r double nX = rPoint.X - rCenter.X; double nY = rPoint.Y - rCenter.Y; - double fSqrt = sqrt(nX * nX + nY * nY); + double fSqrt = std::hypot(nX, nY); double fOrientation = fSqrt != 0.0 ? basegfx::rad2deg(acos(nX / fSqrt)) : 0.0; if (nY > 0) fOrientation = 360 - fOrientation; @@ -89,10 +89,10 @@ bool CGM::ImplGetEllipse( FloatPoint& rCenter, FloatPoint& rRadius, double& rAng rAngle = ImplGetOrientation( rCenter, aPoint1 ); aPoint1.X -= rCenter.X; aPoint1.Y -= rCenter.Y; - rRadius.X = sqrt( aPoint1.X * aPoint1.X + aPoint1.Y * aPoint1.Y ); + rRadius.X = std::hypot(aPoint1.X, aPoint1.Y); aPoint2.X -= rCenter.X; aPoint2.Y -= rCenter.Y; - rRadius.Y = sqrt( aPoint2.X * aPoint2.X + aPoint2.Y * aPoint2.Y ); + rRadius.Y = std::hypot(aPoint2.X, aPoint2.Y); if ( fRot1 > fRot2 ) { @@ -276,29 +276,21 @@ void CGM::ImplDoClass4() if ( mbFigure ) mpOutAct->CloseRegion(); - sal_uInt16 nPoints = 0; - std::unique_ptr<Point[]> pPoints(new Point[ 0x4000 ]); - + std::vector<Point> aPoints; tools::PolyPolygon aPolyPolygon; FloatPoint aFloatPoint; - sal_uInt32 nEdgeFlag; + while ( mnParaSize < mnElementSize ) { ImplGetPoint( aFloatPoint, true ); - nEdgeFlag = ImplGetUI16(); - pPoints[ nPoints++ ] = Point( static_cast<tools::Long>(aFloatPoint.X), static_cast<tools::Long>(aFloatPoint.Y) ); + sal_uInt32 nEdgeFlag = ImplGetUI16(); + aPoints.push_back(Point(static_cast<tools::Long>(aFloatPoint.X), static_cast<tools::Long>(aFloatPoint.Y))); if ( ( nEdgeFlag & 2 ) || ( mnParaSize == mnElementSize ) ) { - tools::Polygon aPolygon( nPoints ); - for ( sal_uInt16 i = 0; i < nPoints; i++ ) - { - aPolygon.SetPoint( pPoints[ i ], i ); - } - aPolyPolygon.Insert( aPolygon ); - nPoints = 0; + aPolyPolygon.Insert(tools::Polygon(aPoints.size(), aPoints.data())); + aPoints.clear(); } } - pPoints.reset(); mpOutAct->DrawPolyPolygon( aPolyPolygon ); } break; @@ -418,7 +410,7 @@ void CGM::ImplDoClass4() fStartAngle = fEndAngle; fEndAngle = fG; } - double fRadius = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ; + double fRadius = std::hypot(aStartingPoint.X - aCenterPoint.X, aStartingPoint.Y - aCenterPoint.Y); if ( mbFigure ) { @@ -508,7 +500,7 @@ void CGM::ImplDoClass4() fEndAngle = fG; } FloatPoint fRadius; - fRadius.Y = fRadius.X = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ; + fRadius.Y = fRadius.X = std::hypot(aStartingPoint.X - aCenterPoint.X, aStartingPoint.Y - aCenterPoint.Y); sal_uInt32 nType = ImplGetUI16(); if ( nType == 0 ) @@ -548,9 +540,9 @@ void CGM::ImplDoClass4() bool bUseless = useless(vector[0]) || useless(vector[1]) || useless(vector[2]) || useless(vector[3]); if (!bUseless) { - const double fStartSqrt = sqrt(vector[0] * vector[ 0 ] + vector[1] * vector[1]); + const double fStartSqrt = std::hypot(vector[0], vector[1]); fStartAngle = fStartSqrt != 0.0 ? basegfx::rad2deg(acos(vector[0] / fStartSqrt)) : 0.0; - const double fEndSqrt = sqrt(vector[2] * vector[ 2 ] + vector[3] * vector[3]); + const double fEndSqrt = std::hypot(vector[2], vector[3]); fEndAngle = fEndSqrt != 0.0 ? basegfx::rad2deg(acos(vector[ 2 ] / fEndSqrt)) : 0.0; if ( vector[ 1 ] > 0 ) @@ -626,9 +618,9 @@ void CGM::ImplDoClass4() bool bUseless = useless(vector[0]) || useless(vector[1]) || useless(vector[2]) || useless(vector[3]); if (!bUseless) { - const double fStartSqrt = sqrt(vector[0] * vector[0] + vector[1] * vector[1]); + const double fStartSqrt = std::hypot(vector[0], vector[1]); double fStartAngle = fStartSqrt ? basegfx::rad2deg(acos(vector[0] / fStartSqrt)) : 0.0; - const double fEndSqrt = sqrt(vector[2] * vector[2] + vector[3] * vector[3]); + const double fEndSqrt = std::hypot(vector[2], vector[3]); double fEndAngle = fEndSqrt ? basegfx::rad2deg(acos(vector[2] / fEndSqrt)) : 0.0; if ( vector[ 1 ] > 0 ) @@ -683,9 +675,9 @@ void CGM::ImplDoClass4() bool bUseless = useless(vector[0]) || useless(vector[1]) || useless(vector[2]) || useless(vector[3]); if (!bUseless) { - double fStartSqrt = sqrt(vector[0] * vector[0] + vector[1] * vector[1]); + double fStartSqrt = std::hypot(vector[0], vector[1]); fStartAngle = fStartSqrt ? basegfx::rad2deg(acos(vector[0] / fStartSqrt)) : 0.0; - double fEndSqrt = sqrt(vector[2] * vector[2] + vector[3] * vector[3]); + double fEndSqrt = std::hypot(vector[2], vector[3]); fEndAngle = fEndSqrt ? basegfx::rad2deg(acos(vector[2] / fEndSqrt)) : 0.0; if ( vector[ 1 ] > 0 ) @@ -719,9 +711,9 @@ void CGM::ImplDoClass4() bool bUseless = useless(vector[0]) || useless(vector[1]) || useless(vector[2]) || useless(vector[3]); if (!bUseless) { - double fStartSqrt = sqrt(vector[0] * vector[0] + vector[1] * vector[1]); + double fStartSqrt = std::hypot(vector[0], vector[1]); fStartAngle = fStartSqrt ? basegfx::rad2deg(acos(vector[0] / fStartSqrt)) : 0.0; - double fEndSqrt = sqrt(vector[2] * vector[2] + vector[3] * vector[3]); + double fEndSqrt = std::hypot(vector[2], vector[3]); fEndAngle = fEndSqrt ? basegfx::rad2deg(acos(vector[2] / fEndSqrt)) : 0.0; if ( vector[ 1 ] > 0 ) diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index b7ffd449cb22..03f72587e1b2 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -19,6 +19,7 @@ #include "eschesdo.hxx" #include <o3tl/any.hxx> +#include <o3tl/string_view.hxx> #include <svx/svdxcgv.hxx> #include <svx/svdomedia.hxx> #include <svx/xflftrit.hxx> @@ -91,6 +92,7 @@ #include <sal/log.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/numeric/ftools.hxx> #include <osl/diagnose.h> #include <algorithm> @@ -928,16 +930,16 @@ bool EscherPropertyContainer::GetLineArrow( const bool bLineStart, if ( !bIsMapped && comphelper::string::getTokenCount(aArrowStartName, ' ') == 2 ) { sal_Int32 nIdx{ 0 }; - OUString aArrowName( aArrowStartName.getToken( 0, ' ', nIdx ) ); - if ( aArrowName == "msArrowEnd" ) + std::u16string_view aArrowName( o3tl::getToken(aArrowStartName, 0, ' ', nIdx ) ); + if ( aArrowName == u"msArrowEnd" ) reLineEnd = ESCHER_LineArrowEnd; - else if ( aArrowName == "msArrowOpenEnd" ) + else if ( aArrowName == u"msArrowOpenEnd" ) reLineEnd = ESCHER_LineArrowOpenEnd; - else if ( aArrowName == "msArrowStealthEnd" ) + else if ( aArrowName == u"msArrowStealthEnd" ) reLineEnd = ESCHER_LineArrowStealthEnd; - else if ( aArrowName == "msArrowDiamondEnd" ) + else if ( aArrowName == u"msArrowDiamondEnd" ) reLineEnd = ESCHER_LineArrowDiamondEnd; - else if ( aArrowName == "msArrowOvalEnd" ) + else if ( aArrowName == u"msArrowOvalEnd" ) reLineEnd = ESCHER_LineArrowOvalEnd; else nIdx = -1; @@ -945,8 +947,8 @@ bool EscherPropertyContainer::GetLineArrow( const bool bLineStart, // now we have the arrow, and try to determine the arrow size; if ( nIdx>0 ) { - OUString aArrowSize( aArrowStartName.getToken( 0, ' ', nIdx ) ); - sal_Int32 nArrowSize = aArrowSize.toInt32(); + std::u16string_view aArrowSize = o3tl::getToken(aArrowStartName, 0, ' ', nIdx ); + sal_Int32 nArrowSize = o3tl::toInt32(aArrowSize); rnArrowWidth = ( nArrowSize - 1 ) / 3; rnArrowLength = nArrowSize - ( rnArrowWidth * 3 ) - 1; } @@ -2450,13 +2452,13 @@ static void ConvertEnhancedCustomShapeEquation( sal_Int32 i; for ( i = 0; i < nEquationSourceCount; i++ ) { - EnhancedCustomShape2d aCustoShape2d( + EnhancedCustomShape2d aCustomShape2d( const_cast< SdrObjCustomShape& >(rSdrObjCustomShape)); try { std::shared_ptr< EnhancedCustomShape::ExpressionNode > aExpressNode( EnhancedCustomShape::FunctionParser::parseFunction( - sEquationSource[ i ], aCustoShape2d)); + sEquationSource[ i ], aCustomShape2d)); drawing::EnhancedCustomShapeParameter aPara( aExpressNode->fillNode( rEquations, nullptr, 0 ) ); if ( aPara.Type != drawing::EnhancedCustomShapeParameterType::EQUATION ) { @@ -2515,7 +2517,7 @@ bool EscherPropertyContainer::IsDefaultObject( { switch(eShapeType) { - // if the custom shape is not default shape of ppt, return sal_Fasle; + // if the custom shape is not default shape of ppt, return false; case mso_sptTearDrop: return false; @@ -2858,7 +2860,11 @@ void EscherPropertyContainer::CreateCustomShapeProperties( const MSO_SPT eShapeT { double fExtrusionShininess = 0; if ( rrProp.Value >>= fExtrusionShininess ) - AddOpt( DFF_Prop_c3DShininess, static_cast<sal_Int32>( fExtrusionShininess * 655.36 ) ); + { + // ODF to MS Office conversion invers to msdffimp.cxx + fExtrusionShininess = basegfx::fround(fExtrusionShininess / 10.0); + AddOpt( DFF_Prop_c3DShininess, static_cast<sal_Int32>(fExtrusionShininess) ); + } } else if ( rrProp.Name == "Skew" ) { @@ -2875,7 +2881,7 @@ void EscherPropertyContainer::CreateCustomShapeProperties( const MSO_SPT eShapeT { double fExtrusionSpecularity = 0; if ( rrProp.Value >>= fExtrusionSpecularity ) - AddOpt( DFF_Prop_c3DSpecularAmt, static_cast<sal_Int32>( fExtrusionSpecularity * 1333 ) ); + AddOpt( DFF_Prop_c3DSpecularAmt, static_cast<sal_Int32>( fExtrusionSpecularity * 655.36 ) ); } else if ( rrProp.Name == "ProjectionMode" ) { @@ -3712,8 +3718,7 @@ MSO_SPT EscherPropertyContainer::GetCustomShapeType( const uno::Reference< drawi // In case of VML export, try to handle the // ooxml- prefix in rShapeType. If that fails, // just do the same as the binary export. - OString aType = OUStringToOString(rShapeType, RTL_TEXTENCODING_UTF8); - eShapeType = msfilter::util::GETVMLShapeType(aType); + eShapeType = msfilter::util::GETVMLShapeType(rShapeType); if (eShapeType == mso_sptNil) eShapeType = EnhancedCustomShapeTypeNames::Get(rShapeType); } @@ -4195,7 +4200,7 @@ sal_uInt32 EscherGraphicProvider::GetBlibID( SvStream& rPicOutStrm, GraphicObjec SvMemoryStream aGIFStream; const char* const pString = "MSOFFICE9.0"; aGIFStream.WriteBytes(pString, strlen(pString)); - nErrCode = rFilter.ExportGraphic( aGraphic, OUString(), aGIFStream, + nErrCode = rFilter.ExportGraphic( aGraphic, u"", aGIFStream, rFilter.GetExportFormatNumberForShortName( u"GIF" ) ); SAL_WARN_IF( nErrCode != ERRCODE_NONE, "filter.ms", @@ -4214,7 +4219,7 @@ sal_uInt32 EscherGraphicProvider::GetBlibID( SvStream& rPicOutStrm, GraphicObjec aFilterProp.Name = "AdditionalChunks"; aFilterProp.Value <<= aAdditionalChunkSequence; uno::Sequence<beans::PropertyValue> aFilterData{ aFilterProp }; - nErrCode = rFilter.ExportGraphic( aGraphic, OUString(), aStream, + nErrCode = rFilter.ExportGraphic( aGraphic, u"", aStream, rFilter.GetExportFormatNumberForShortName( u"PNG" ), &aFilterData ); } } diff --git a/filter/source/msfilter/eschesdo.cxx b/filter/source/msfilter/eschesdo.cxx index 12e6e62be0a2..d052b5968780 100644 --- a/filter/source/msfilter/eschesdo.cxx +++ b/filter/source/msfilter/eschesdo.cxx @@ -669,7 +669,7 @@ sal_uInt32 ImplEESdrWriter::ImplWriteShape( ImplEESdrObject& rObj, if( SDRLAYER_NOTFOUND != mpEscherEx->GetHellLayerId() && rObj.ImplGetPropertyValue( "LayerID" ) && - *o3tl::doAccess<sal_uInt16>(rObj.GetUsrAny()) == sal_uInt8(mpEscherEx->GetHellLayerId()) ) + *o3tl::doAccess<sal_Int16>(rObj.GetUsrAny()) == mpEscherEx->GetHellLayerId().get() ) { aPropOpt.AddOpt( ESCHER_Prop_fPrint, 0x200020 ); } diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 8832617a4e58..daf047007b49 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -149,6 +149,7 @@ #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeMetalType.hpp> #include <com/sun/star/beans/PropertyValues.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -170,6 +171,18 @@ static sal_uInt32 nMSOleObjCntr = 0; constexpr OUStringLiteral MSO_OLE_Obj = u"MSO_OLE_Obj"; namespace { +/* Office File Formats - 2.2.23 */ +enum class OfficeArtBlipRecInstance : sal_uInt32 +{ + EMF = 0x3D4, // defined in section 2.2.24. + WMF = 0x216, // defined in section 2.2.25. + PICT = 0x542, // as defined in section 2.2.26. + JPEG_RGB = 0x46A, // defined in section 2.2.27. + JPEG_CMYK = 0x6E2, // defined in section 2.2.27. + PNG = 0x6E0, // defined in section 2.2.28. + DIB = 0x7A8, // defined in section 2.2.29. + TIFF = 0x6E4 // defined in section 2.2.30. +}; struct SvxMSDffBLIPInfo { @@ -1675,14 +1688,20 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt aExtrusionPropVec.push_back( aProp ); // "Brightness" + // MS Office default 0x00004E20 16.16 FixedPoint, 20000/65536=0.30517, ODF default 33%. + // Thus must set value even if default. + double fBrightness = 20000.0; if ( IsProperty( DFF_Prop_c3DAmbientIntensity ) ) { - double fBrightness = static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DAmbientIntensity, 0 )); - fBrightness /= 655.36; - aProp.Name = "Brightness"; - aProp.Value <<= fBrightness; - aExtrusionPropVec.push_back( aProp ); + // Value must be in range 0.0 to 1.0 in MS Office binary specification, but larger + // values are in fact interpreted. + fBrightness = GetPropertyValue( DFF_Prop_c3DAmbientIntensity, 0 ); } + fBrightness /= 655.36; + aProp.Name = "Brightness"; + aProp.Value <<= fBrightness; + aExtrusionPropVec.push_back( aProp ); + // "Depth" in 1/100mm if ( IsProperty( DFF_Prop_c3DExtrudeBackward ) || IsProperty( DFF_Prop_c3DExtrudeForward ) ) { @@ -1700,14 +1719,17 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt aExtrusionPropVec.push_back( aProp ); } // "Diffusion" + // ODF default is 0%, MS Office default is 100%. Thus must set value even if default. + double fDiffusion = 100; if ( IsProperty( DFF_Prop_c3DDiffuseAmt ) ) { - double fDiffusion = static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DDiffuseAmt, 0 )); + fDiffusion = static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DDiffuseAmt, 0 )); fDiffusion /= 655.36; - aProp.Name = "Diffusion"; - aProp.Value <<= fDiffusion; - aExtrusionPropVec.push_back( aProp ); } + aProp.Name = "Diffusion"; + aProp.Value <<= fDiffusion; + aExtrusionPropVec.push_back( aProp ); + // "NumberOfLineSegments" if ( IsProperty( DFF_Prop_c3DTolerance ) ) { @@ -1730,24 +1752,35 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt aProp.Name = "SecondLightHarsh"; aProp.Value <<= bExtrusionSecondLightHarsh; aExtrusionPropVec.push_back( aProp ); + // "FirstLightLevel" + // MS Office default 0x00009470 16.16 FixedPoint, 38000/65536 = 0.5798, ODF default 66%. + // Thus must set value even if default. + double fFirstLightLevel = 38000.0; if ( IsProperty( DFF_Prop_c3DKeyIntensity ) ) { - double fFirstLightLevel = static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DKeyIntensity, 0 )); - fFirstLightLevel /= 655.36; - aProp.Name = "FirstLightLevel"; - aProp.Value <<= fFirstLightLevel; - aExtrusionPropVec.push_back( aProp ); + // value<0 and value>1 are allowed in MS Office. Clamp such in ODF export, not here. + fFirstLightLevel = static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DKeyIntensity, 0 )); } + fFirstLightLevel /= 655.36; + aProp.Name = "FirstLightLevel"; + aProp.Value <<= fFirstLightLevel; + aExtrusionPropVec.push_back( aProp ); + // "SecondLightLevel" + // MS Office default 0x00009470 16.16 FixedPoint, 38000/65536 = 0.5798, ODF default 66%. + // Thus must set value even if default. + double fSecondLightLevel = 38000.0; if ( IsProperty( DFF_Prop_c3DFillIntensity ) ) { - double fSecondLightLevel = static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DFillIntensity, 0 )); - fSecondLightLevel /= 655.36; - aProp.Name = "SecondLightLevel"; - aProp.Value <<= fSecondLightLevel; - aExtrusionPropVec.push_back( aProp ); + // value<0 and value>1 are allowed in MS Office. Clamp such in ODF export, not here. + fSecondLightLevel = static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DFillIntensity, 0 )); } + fSecondLightLevel /= 655.36; + aProp.Name = "SecondLightLevel"; + aProp.Value <<= fSecondLightLevel; + aExtrusionPropVec.push_back( aProp ); + // "FirstLightDirection" if ( IsProperty( DFF_Prop_c3DKeyX ) || IsProperty( DFF_Prop_c3DKeyY ) || IsProperty( DFF_Prop_c3DKeyZ ) ) { @@ -1776,6 +1809,10 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt aProp.Name = "Metal"; aProp.Value <<= bExtrusionMetal; aExtrusionPropVec.push_back( aProp ); + aProp.Name = "MetalType"; + aProp.Value <<= css::drawing::EnhancedCustomShapeMetalType::MetalMSCompatible; + aExtrusionPropVec.push_back(aProp); + // "ShadeMode" if ( IsProperty( DFF_Prop_c3DRenderMode ) ) { @@ -1788,7 +1825,7 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt aProp.Value <<= eExtrusionShadeMode; aExtrusionPropVec.push_back( aProp ); } - // "RotateAngle" in Grad + // "RotateAngle" in Degree if ( IsProperty( DFF_Prop_c3DXRotationAngle ) || IsProperty( DFF_Prop_c3DYRotationAngle ) ) { double fAngleX = static_cast<double>(static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DXRotationAngle, 0 ))) / 65536.0; @@ -1821,34 +1858,44 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt } } // "Shininess" + // MS Office default 5, ODF default 50%. if ( IsProperty( DFF_Prop_c3DShininess ) ) { double fShininess = static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DShininess, 0 )); - fShininess /= 655.36; + fShininess *= 10.0; // error in [MS ODRAW] (2021), type is not FixedPoint but long. aProp.Name = "Shininess"; aProp.Value <<= fShininess; aExtrusionPropVec.push_back( aProp ); } + // "Skew" + // MS Office angle file value is 16.16 FixedPoint, default 0xFF790000, + // -8847360/65536=-135, ODF default 45. Thus must set value even if default. + double fSkewAngle = -135.0; + // MS Office amount file value is signed integer in range 0xFFFFFF9C to 0x00000064, + // default 0x00000032, ODF default 50.0 + double fSkewAmount = 50.0; if ( IsProperty( DFF_Prop_c3DSkewAmount ) || IsProperty( DFF_Prop_c3DSkewAngle ) ) { - double fSkewAmount = static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DSkewAmount, 50 )); - double fSkewAngle = static_cast<double>(static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DSkewAngle, sal::static_int_cast< sal_uInt32 >(-135 * 65536) ))) / 65536.0; + fSkewAmount = static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DSkewAmount, 50 )); + fSkewAngle = static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DSkewAngle, sal::static_int_cast< sal_uInt32 >(-135 * 65536) )); + fSkewAngle /= 65536.0; + } + EnhancedCustomShapeParameterPair aSkewPair; + aSkewPair.First.Value <<= fSkewAmount; + aSkewPair.First.Type = EnhancedCustomShapeParameterType::NORMAL; + aSkewPair.Second.Value <<= fSkewAngle; + aSkewPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL; + aProp.Name = "Skew"; + aProp.Value <<= aSkewPair; + aExtrusionPropVec.push_back( aProp ); - EnhancedCustomShapeParameterPair aSkewPair; - aSkewPair.First.Value <<= fSkewAmount; - aSkewPair.First.Type = EnhancedCustomShapeParameterType::NORMAL; - aSkewPair.Second.Value <<= fSkewAngle; - aSkewPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL; - aProp.Name = "Skew"; - aProp.Value <<= aSkewPair; - aExtrusionPropVec.push_back( aProp ); - } // "Specularity" + // Type Fixed point 16.16, percent in API if ( IsProperty( DFF_Prop_c3DSpecularAmt ) ) { double fSpecularity = static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DSpecularAmt, 0 )); - fSpecularity /= 1333; + fSpecularity /= 655.36; aProp.Name = "Specularity"; aProp.Value <<= fSpecularity; aExtrusionPropVec.push_back( aProp ); @@ -1860,16 +1907,22 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt aExtrusionPropVec.push_back( aProp ); // "ViewPoint" in 1/100mm + // MS Office default 1250000 EMU=3472.222 Hmm, ODF default 3.5cm + // Thus must set value even if default. + double fViewX = 1250000.0 / 360.0; + double fViewY = -1250000.0 / 360.0;; + double fViewZ = 9000000.0 / 360.0; if ( IsProperty( DFF_Prop_c3DXViewpoint ) || IsProperty( DFF_Prop_c3DYViewpoint ) || IsProperty( DFF_Prop_c3DZViewpoint ) ) { - double fViewX = static_cast<double>(static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DXViewpoint, 1250000 ))) / 360.0; - double fViewY = static_cast<double>(static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DYViewpoint, sal_uInt32(-1250000) )))/ 360.0; - double fViewZ = static_cast<double>(static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DZViewpoint, 9000000 ))) / 360.0; - css::drawing::Position3D aExtrusionViewPoint( fViewX, fViewY, fViewZ ); - aProp.Name = "ViewPoint"; - aProp.Value <<= aExtrusionViewPoint; - aExtrusionPropVec.push_back( aProp ); + fViewX = static_cast<double>(static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DXViewpoint, 1250000 ))) / 360.0; + fViewY = static_cast<double>(static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DYViewpoint, sal_uInt32(-1250000) )))/ 360.0; + fViewZ = static_cast<double>(static_cast<sal_Int32>(GetPropertyValue( DFF_Prop_c3DZViewpoint, 9000000 ))) / 360.0; } + css::drawing::Position3D aExtrusionViewPoint( fViewX, fViewY, fViewZ ); + aProp.Name = "ViewPoint"; + aProp.Value <<= aExtrusionViewPoint; + aExtrusionPropVec.push_back( aProp ); + // "Origin" if ( IsProperty( DFF_Prop_c3DOriginX ) || IsProperty( DFF_Prop_c3DOriginY ) ) { @@ -4173,13 +4226,11 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r tools::Rectangle& rClientRect, const tools::Rectangle& rGlobalChildRect, int nCalledByGroup, sal_Int32* pShapeId ) { - SdrObject* pRet = nullptr; - if( pShapeId ) *pShapeId = 0; if (!rHd.SeekToBegOfRecord(rSt)) - return pRet; + return nullptr; DffObjData aObjData( rHd, rClientRect, nCalledByGroup ); @@ -4230,7 +4281,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r if ( aObjData.bOpt ) { if (!maShapeRecords.Current()->SeekToBegOfRecord(rSt)) - return pRet; + return nullptr; #ifdef DBG_AUTOSHAPE ReadPropSet( rSt, &rClientData, (sal_uInt32)aObjData.eShapeType ); #else @@ -4285,6 +4336,8 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r if ( aObjData.nSpFlags & ShapeFlag::Background ) aObjData.aBoundRect = tools::Rectangle( Point(), Size( 1, 1 ) ); + SdrObjectUniquePtr xRet; + tools::Rectangle aTextRect; if ( !aObjData.aBoundRect.IsEmpty() ) { // apply rotation to the BoundingBox BEFORE an object has been generated @@ -4309,7 +4362,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r if ( aObjData.nSpFlags & ShapeFlag::Group ) { - pRet = new SdrObjGroup(*pSdrModel); + xRet.reset(new SdrObjGroup(*pSdrModel)); /* After CWS aw033 has been integrated, an empty group object cannot store its resulting bounding rectangle anymore. We have to return this rectangle via rClientRect now, but only, if @@ -4329,9 +4382,9 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r if ( bGraphic ) { if (!mbSkipImages) { - pRet = ImportGraphic( rSt, aSet, aObjData ); // SJ: #68396# is no longer true (fixed in ppt2000) + xRet.reset(ImportGraphic(rSt, aSet, aObjData)); // SJ: #68396# is no longer true (fixed in ppt2000) ApplyAttributes( rSt, aSet, aObjData ); - pRet->SetMergedItemSet(aSet); + xRet->SetMergedItemSet(aSet); } } else if ( aObjData.eShapeType == mso_sptLine && !( GetPropertyValue( DFF_Prop_fc3DLightFace, 0 ) & 8 ) ) @@ -4339,12 +4392,12 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r basegfx::B2DPolygon aPoly; aPoly.append(basegfx::B2DPoint(aObjData.aBoundRect.Left(), aObjData.aBoundRect.Top())); aPoly.append(basegfx::B2DPoint(aObjData.aBoundRect.Right(), aObjData.aBoundRect.Bottom())); - pRet = new SdrPathObj( + xRet.reset(new SdrPathObj( *pSdrModel, SdrObjKind::Line, - basegfx::B2DPolyPolygon(aPoly)); + basegfx::B2DPolyPolygon(aPoly))); ApplyAttributes( rSt, aSet, aObjData ); - pRet->SetMergedItemSet(aSet); + xRet->SetMergedItemSet(aSet); } else { @@ -4353,7 +4406,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r ApplyAttributes( rSt, aSet, aObjData ); - pRet = new SdrObjCustomShape(*pSdrModel); + xRet.reset(new SdrObjCustomShape(*pSdrModel)); sal_uInt32 ngtextFStrikethrough = GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ); bool bIsFontwork = ( ngtextFStrikethrough & 0x4000 ) != 0; @@ -4389,12 +4442,12 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r // this should be replaced through "CharacterRotation" // by 90 degrees, therefore a new Item has to be // supported by svx core, api and xml file format - static_cast<SdrObjCustomShape*>(pRet)->SetVerticalWriting( ( ngtextFStrikethrough & 0x2000 ) != 0 ); + static_cast<SdrObjCustomShape*>(xRet.get())->SetVerticalWriting( ( ngtextFStrikethrough & 0x2000 ) != 0 ); if ( SeekToContent( DFF_Prop_gtextUNICODE, rSt ) ) { aObjectText = MSDFFReadZString( rSt, GetPropertyValue( DFF_Prop_gtextUNICODE, 0 ), true ); - ReadObjText( aObjectText, pRet ); + ReadObjText(aObjectText, xRet.get()); } auto eGeoTextAlign = GetPropertyValue(DFF_Prop_gtextAlign, mso_alignTextCenter); @@ -4461,18 +4514,18 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r } } } - pRet->SetMergedItemSet( aSet ); + xRet->SetMergedItemSet( aSet ); // sj: taking care of rtl, ltr. In case of fontwork mso. seems not to be able to set // proper text directions, instead the text default is depending to the string. // so we have to calculate the a text direction from string: if ( bIsFontwork ) { - OutlinerParaObject* pParaObj = static_cast<SdrObjCustomShape*>(pRet)->GetOutlinerParaObject(); + OutlinerParaObject* pParaObj = static_cast<SdrObjCustomShape*>(xRet.get())->GetOutlinerParaObject(); if ( pParaObj ) { - SdrOutliner& rOutliner = static_cast<SdrObjCustomShape*>(pRet)->ImpGetDrawOutliner(); - rOutliner.SetStyleSheetPool(static_cast< SfxStyleSheetPool* >(pRet->getSdrModelFromSdrObject().GetStyleSheetPool())); + SdrOutliner& rOutliner = static_cast<SdrObjCustomShape*>(xRet.get())->ImpGetDrawOutliner(); + rOutliner.SetStyleSheetPool(static_cast< SfxStyleSheetPool* >(xRet->getSdrModelFromSdrObject().GetStyleSheetPool())); bool bOldUpdateMode = rOutliner.SetUpdateLayout( false ); rOutliner.SetText( *pParaObj ); ScopedVclPtrInstance< VirtualDevice > pVirDev(DeviceFormat::DEFAULT); @@ -4497,7 +4550,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r { std::optional<OutlinerParaObject> pNewText = rOutliner.CreateParaObject(); rOutliner.Init( OutlinerMode::TextObject ); - static_cast<SdrObjCustomShape*>(pRet)->NbcSetOutlinerParaObject( std::move(pNewText) ); + static_cast<SdrObjCustomShape*>(xRet.get())->NbcSetOutlinerParaObject( std::move(pNewText) ); } } rOutliner.Clear(); @@ -4514,7 +4567,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r static const OUStringLiteral sAdjustmentValues( u"AdjustmentValues" ); static const OUStringLiteral sViewBox( u"ViewBox" ); static const OUStringLiteral sPath( u"Path" ); - SdrCustomShapeGeometryItem aGeometryItem( static_cast<SdrObjCustomShape*>(pRet)->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); + SdrCustomShapeGeometryItem aGeometryItem( static_cast<SdrObjCustomShape*>(xRet.get())->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); PropertyValue aPropVal; // The default arc goes form -90deg to 0deg. Replace general defaults used @@ -4706,56 +4759,55 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r aGeometryItem.ClearPropertyValue( "Equations" ); aGeometryItem.ClearPropertyValue( sPath ); - static_cast<SdrObjCustomShape*>(pRet)->SetMergedItem( aGeometryItem ); - static_cast<SdrObjCustomShape*>(pRet)->MergeDefaultAttributes(); + static_cast<SdrObjCustomShape*>(xRet.get())->SetMergedItem( aGeometryItem ); + static_cast<SdrObjCustomShape*>(xRet.get())->MergeDefaultAttributes(); // now setting a new name, so the above correction is only done once when importing from ms - SdrCustomShapeGeometryItem aGeoName( static_cast<SdrObjCustomShape*>(pRet)->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); + SdrCustomShapeGeometryItem aGeoName( static_cast<SdrObjCustomShape*>(xRet.get())->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); aPropVal.Name = "Type"; aPropVal.Value <<= OUString( "mso-spt100" ); aGeoName.SetPropertyValue( aPropVal ); - static_cast<SdrObjCustomShape*>(pRet)->SetMergedItem( aGeoName ); + static_cast<SdrObjCustomShape*>(xRet.get())->SetMergedItem( aGeoName ); } else - static_cast<SdrObjCustomShape*>(pRet)->MergeDefaultAttributes(); + static_cast<SdrObjCustomShape*>(xRet.get())->MergeDefaultAttributes(); - pRet->SetSnapRect( aObjData.aBoundRect ); - EnhancedCustomShape2d aCustomShape2d(static_cast<SdrObjCustomShape&>(*pRet)); + xRet->SetSnapRect( aObjData.aBoundRect ); + EnhancedCustomShape2d aCustomShape2d(static_cast<SdrObjCustomShape&>(*xRet)); aTextRect = aCustomShape2d.GetTextRect(); if( bIsConnector ) { if( nObjectRotation ) - pRet->NbcRotate( aObjData.aBoundRect.Center(), nObjectRotation ); + xRet->NbcRotate( aObjData.aBoundRect.Center(), nObjectRotation ); // mirrored horizontally? if ( nSpFlags & ShapeFlag::FlipH ) { - tools::Rectangle aBndRect( pRet->GetSnapRect() ); + tools::Rectangle aBndRect(xRet->GetSnapRect()); Point aTop( ( aBndRect.Left() + aBndRect.Right() ) >> 1, aBndRect.Top() ); Point aBottom( aTop.X(), aTop.Y() + 1000 ); - pRet->NbcMirror( aTop, aBottom ); + xRet->NbcMirror( aTop, aBottom ); } // mirrored vertically? if ( nSpFlags & ShapeFlag::FlipV ) { - tools::Rectangle aBndRect( pRet->GetSnapRect() ); + tools::Rectangle aBndRect(xRet->GetSnapRect()); Point aLeft( aBndRect.Left(), ( aBndRect.Top() + aBndRect.Bottom() ) >> 1 ); Point aRight( aLeft.X() + 1000, aLeft.Y() ); - pRet->NbcMirror( aLeft, aRight ); + xRet->NbcMirror( aLeft, aRight ); } - basegfx::B2DPolyPolygon aPoly( static_cast<SdrObjCustomShape*>(pRet)->GetLineGeometry( true ) ); - SdrObject::Free( pRet ); + basegfx::B2DPolyPolygon aPoly( static_cast<SdrObjCustomShape*>(xRet.get())->GetLineGeometry( true ) ); - pRet = new SdrEdgeObj(*pSdrModel); + xRet.reset(new SdrEdgeObj(*pSdrModel)); ApplyAttributes( rSt, aSet, aObjData ); - pRet->SetLogicRect( aObjData.aBoundRect ); - pRet->SetMergedItemSet(aSet); + xRet->SetLogicRect( aObjData.aBoundRect ); + xRet->SetMergedItemSet(aSet); // connectors auto eConnectorStyle = GetPropertyValue(DFF_Prop_cxstyle, mso_cxstyleStraight); - static_cast<SdrEdgeObj*>(pRet)->ConnectToNode(true, nullptr); - static_cast<SdrEdgeObj*>(pRet)->ConnectToNode(false, nullptr); + static_cast<SdrEdgeObj*>(xRet.get())->ConnectToNode(true, nullptr); + static_cast<SdrEdgeObj*>(xRet.get())->ConnectToNode(false, nullptr); Point aPoint1( aObjData.aBoundRect.TopLeft() ); Point aPoint2( aObjData.aBoundRect.BottomRight() ); @@ -4795,8 +4847,8 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r nSpFlags &= ~ShapeFlag::FlipV; } - pRet->NbcSetPoint(aPoint1, 0); // start point - pRet->NbcSetPoint(aPoint2, 1); // endpoint + xRet->NbcSetPoint(aPoint1, 0); // start point + xRet->NbcSetPoint(aPoint2, 1); // endpoint sal_Int32 n1HorzDist, n1VertDist, n2HorzDist, n2VertDist; n1HorzDist = n1VertDist = n2HorzDist = n2VertDist = 0; @@ -4820,74 +4872,73 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r aSet.Put( SdrEdgeNode2HorzDistItem( n2HorzDist ) ); aSet.Put( SdrEdgeNode2VertDistItem( n2VertDist ) ); - static_cast<SdrEdgeObj*>(pRet)->SetEdgeTrackPath( aPoly ); - pRet->SetMergedItemSet( aSet ); + static_cast<SdrEdgeObj*>(xRet.get())->SetEdgeTrackPath( aPoly ); + xRet->SetMergedItemSet(aSet); } if ( aObjData.eShapeType == mso_sptLine ) { - pRet->SetMergedItemSet(aSet); - static_cast<SdrObjCustomShape*>(pRet)->MergeDefaultAttributes(); + xRet->SetMergedItemSet(aSet); + static_cast<SdrObjCustomShape*>(xRet.get())->MergeDefaultAttributes(); } } } - if ( pRet ) + if (xRet) { if( nObjectRotation ) - pRet->NbcRotate( aObjData.aBoundRect.Center(), nObjectRotation ); + xRet->NbcRotate( aObjData.aBoundRect.Center(), nObjectRotation ); // mirrored horizontally? if ( nSpFlags & ShapeFlag::FlipH ) { - tools::Rectangle aBndRect( pRet->GetSnapRect() ); + tools::Rectangle aBndRect(xRet->GetSnapRect()); Point aTop( ( aBndRect.Left() + aBndRect.Right() ) >> 1, aBndRect.Top() ); Point aBottom( aTop.X(), aTop.Y() + 1000 ); - pRet->NbcMirror( aTop, aBottom ); + xRet->NbcMirror(aTop, aBottom); } // mirrored vertically? if ( nSpFlags & ShapeFlag::FlipV ) { - tools::Rectangle aBndRect( pRet->GetSnapRect() ); + tools::Rectangle aBndRect(xRet->GetSnapRect()); Point aLeft( aBndRect.Left(), ( aBndRect.Top() + aBndRect.Bottom() ) >> 1 ); Point aRight( aLeft.X() + 1000, aLeft.Y() ); - pRet->NbcMirror( aLeft, aRight ); + xRet->NbcMirror(aLeft, aRight); } } } } // #i51348# #118052# name of the shape - if( pRet ) + if (xRet) { OUString aObjName = GetPropertyString( DFF_Prop_wzName, rSt ); if( !aObjName.isEmpty() ) - pRet->SetName( aObjName ); + xRet->SetName(aObjName); } - pRet = - ProcessObj( rSt, aObjData, rClientData, aTextRect, pRet); + xRet.reset(ProcessObj(rSt, aObjData, rClientData, aTextRect, xRet.release())); - if ( pRet ) + if (xRet) { sal_Int32 nGroupProperties( GetPropertyValue( DFF_Prop_fPrint, 0 ) ); const bool bVisible = ( ( nGroupProperties & 2 ) == 0 ); - pRet->SetVisible( bVisible ); + xRet->SetVisible( bVisible ); // In Excel hidden means not printed if ( !bVisible ) { - pRet->SetPrintable( false ); + xRet->SetPrintable(false); } else { // This property isn't used in Excel anymore, leaving it for legacy reasons - pRet->SetPrintable( ( nGroupProperties & 1 ) != 0 ); + xRet->SetPrintable( ( nGroupProperties & 1 ) != 0 ); } } //Import alt text as description - if ( pRet && SeekToContent( DFF_Prop_wzDescription, rSt ) ) + if (xRet && SeekToContent(DFF_Prop_wzDescription, rSt)) { OUString aAltText = MSDFFReadZString(rSt, GetPropertyValue(DFF_Prop_wzDescription, 0), true); - pRet->SetDescription( aAltText ); + xRet->SetDescription(aAltText); } // If this shape opens a new group, push back its object data because @@ -4900,9 +4951,9 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r } else { - pRet = FinalizeObj(aObjData, pRet); + xRet.reset(FinalizeObj(aObjData, xRet.release())); } - return pRet; + return xRet.release(); } tools::Rectangle SvxMSDffManager::GetGlobalChildAnchor( const DffRecordHeader& rHd, SvStream& rSt, tools::Rectangle& aClientRect ) @@ -5158,7 +5209,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt, case 0x0392: pImpRec->nYRelTo = nUDData; break; - case 0x03BF: pImpRec->nLayoutInTableCell = nUDData; break; + case 0x03BF: pImpRec->nGroupShapeBooleanProperties = nUDData; break; case 0x0393: // This seems to correspond to o:hrpct from .docx (even including // the difference that it's in 0.1% even though the .docx spec @@ -5477,9 +5528,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt, SfxItemSet aSet( pSdrModel->GetItemPool() ); ApplyAttributes( rSt, aSet, rObjData ); - const SfxPoolItem* pPoolItem=nullptr; - SfxItemState eState = aSet.GetItemState( XATTR_FILLCOLOR, - false, &pPoolItem ); + SfxItemState eState = aSet.GetItemState( XATTR_FILLCOLOR ); if( SfxItemState::DEFAULT == eState ) aSet.Put( XFillColorItem( OUString(), mnDefaultColor ) ); pObj->SetMergedItemSet(aSet); @@ -6442,40 +6491,42 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool bool bMtfBLIP = false; bool bZCodecCompression = false; // now position it exactly at the beginning of the embedded graphic - sal_uLong nSkip = ( nInst & 0x0001 ) ? 32 : 16; - - switch( nInst & 0xFFFE ) + sal_uLong nSkip = (nInst & 0x0001) ? 32 : 16; + const OfficeArtBlipRecInstance aRecInstanse = OfficeArtBlipRecInstance(nInst & 0xFFFE); + switch (aRecInstanse) { - case 0x216 : // Metafile header then compressed WMF - case 0x3D4 : // Metafile header then compressed EMF - case 0x542 : // Metafile hd. then compressed PICT + case OfficeArtBlipRecInstance::EMF: + case OfficeArtBlipRecInstance::WMF: + case OfficeArtBlipRecInstance::PICT: { - rBLIPStream.SeekRel( nSkip + 20 ); + rBLIPStream.SeekRel(nSkip + 20); - // read in size of metafile in EMUS + // read in size of metafile in English Metric Units (EMUs) sal_Int32 width(0), height(0); - rBLIPStream.ReadInt32( width ).ReadInt32( height ); - aMtfSize100.setWidth( width ); - aMtfSize100.setHeight( height ); + rBLIPStream.ReadInt32(width).ReadInt32(height); + aMtfSize100.setWidth(width); + aMtfSize100.setHeight(height); + // 1 EMU = 1/360,000 of a centimeter // scale to 1/100mm - aMtfSize100.setWidth( aMtfSize100.Width() / 360 ); - aMtfSize100.setHeight( aMtfSize100.Height() / 360 ); + aMtfSize100.setWidth(aMtfSize100.Width() / 360); + aMtfSize100.setHeight(aMtfSize100.Height() / 360); - if ( pVisArea ) // seem that we currently are skipping the visarea position - *pVisArea = tools::Rectangle( Point(), aMtfSize100 ); + if (pVisArea) // seem that we currently are skipping the visarea position + *pVisArea = tools::Rectangle(Point(), aMtfSize100); // skip rest of header nSkip = 6; bMtfBLIP = bZCodecCompression = true; } break; - case 0x46A : // One byte tag then JPEG (= JFIF) data - case 0x6E0 : // One byte tag then PNG data - case 0x6E2 : // One byte tag then JPEG in CMYK color space - case 0x7A8 : - nSkip += 1; // One byte tag then DIB data - break; + case OfficeArtBlipRecInstance::JPEG_RGB: + case OfficeArtBlipRecInstance::JPEG_CMYK: + case OfficeArtBlipRecInstance::PNG: + case OfficeArtBlipRecInstance::DIB: + case OfficeArtBlipRecInstance::TIFF: + nSkip += 1; // Skip one byte tag + break; } rBLIPStream.SeekRel( nSkip ); @@ -6498,18 +6549,34 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool // extract graphics from ole storage into "dbggfxNNN.*" static sal_Int32 nGrfCount; - OUString aFileName = "dbggfx" + OUString::number( nGrfCount++ ); - switch( nInst &~ 1 ) + OUString aFileName = "dbggfx" + OUString::number(nGrfCount++); + switch (aRecInstanse) { - case 0x216 : aFileName += ".wmf"; break; - case 0x3d4 : aFileName += ".emf"; break; - case 0x542 : aFileName += ".pct"; break; - case 0x46a : aFileName += ".jpg"; break; - case 0x6e0 : aFileName += ".png"; break; - case 0x6e2 : aFileName += ".jpg"; break; - case 0x7a8 : aFileName += ".bmp"; break; + case OfficeArtBlipRecInstance::WMF: + aFileName += ".wmf"; + break; + case OfficeArtBlipRecInstance::EMF: + aFileName += ".emf"; + break; + case OfficeArtBlipRecInstance::PICT: + aFileName += ".pct"; + break; + case OfficeArtBlipRecInstance::JPEG_RGB: + case OfficeArtBlipRecInstance::JPEG_CMYK: + aFileName += ".jpg"; + break; + case OfficeArtBlipRecInstance::PNG: + aFileName += ".png"; + break; + case OfficeArtBlipRecInstance::DIB: + aFileName += ".bmp"; + break; + case OfficeArtBlipRecInstance::TIFF: + aFileName += ".tif"; + break; } + OUString aURLStr; if( osl::FileBase::getFileURLFromSystemPath( Application::GetAppFileName(), aURLStr ) == osl::FileBase::E_None ) { @@ -6546,8 +6613,7 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool } } #endif - - if( ( nInst & 0xFFFE ) == 0x7A8 ) + if (aRecInstanse == OfficeArtBlipRecInstance::DIB) { // getting the DIBs immediately Bitmap aNew; if( ReadDIB(aNew, *pGrStream, false) ) @@ -6577,7 +6643,7 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool nRes = ERRCODE_NONE; } else - nRes = rGF.ImportGraphic( rData, "", *pGrStream ); + nRes = rGF.ImportGraphic( rData, u"", *pGrStream ); // SJ: I40472, sometimes the aspect ratio (aMtfSize100) does not match and we get scaling problems, // then it is better to use the prefsize that is stored within the metafile. Bug #72846# for what the @@ -6585,7 +6651,8 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool // // For pict graphics we will furthermore scale the metafile, because font scaling leads to error if the // dxarray is empty (this has been solved in wmf/emf but not for pict) - if( bMtfBLIP && ( ERRCODE_NONE == nRes ) && ( rData.GetType() == GraphicType::GdiMetafile ) && ( ( nInst & 0xFFFE ) == 0x542 ) ) + if (bMtfBLIP && (ERRCODE_NONE == nRes) && (rData.GetType() == GraphicType::GdiMetafile) + && (aRecInstanse == OfficeArtBlipRecInstance::PICT)) { if ( ( aMtfSize100.Width() >= 1000 ) && ( aMtfSize100.Height() >= 1000 ) ) { // #75956#, scaling does not work properly, if the graphic is less than 1cm @@ -7077,14 +7144,16 @@ css::uno::Reference < css::embed::XEmbeddedObject > SvxMSDffManager::CheckForCo } else { - SfxFilterMatcher aMatch( sStarName ); tools::SvRef<SotStorage> xStorage = new SotStorage( false, aMemStream ); rSrcStg.CopyTo( xStorage.get() ); xStorage->Commit(); xStorage.clear(); OUString aType = SfxFilter::GetTypeFromStorage( rSrcStg ); if (aType.getLength() && !utl::ConfigManager::IsFuzzing()) + { + SfxFilterMatcher aMatch( sStarName ); pFilter = aMatch.GetFilter4EA( aType ); + } } #ifdef DEBUG_FILTER_MSFILTER @@ -7413,7 +7482,7 @@ SvxMSDffImportRec::SvxMSDffImportRec() nClientDataLen( 0 ), nXAlign( 0 ), // position n cm from left nYAlign( 0 ), // position n cm below - nLayoutInTableCell( 0 ), // element is laid out in table cell + nGroupShapeBooleanProperties(0), // 16 settings: LayoutInCell/AllowOverlap/BehindDocument... nFlags( ShapeFlag::NONE ), nDxTextLeft( 144 ), nDyTextTop( 72 ), @@ -7450,7 +7519,7 @@ SvxMSDffImportRec::SvxMSDffImportRec(const SvxMSDffImportRec& rCopy) nXRelTo( rCopy.nXRelTo ), nYAlign( rCopy.nYAlign ), nYRelTo( rCopy.nYRelTo ), - nLayoutInTableCell( rCopy.nLayoutInTableCell ), + nGroupShapeBooleanProperties(rCopy.nGroupShapeBooleanProperties), nFlags( rCopy.nFlags ), nDxTextLeft( rCopy.nDxTextLeft ), nDyTextTop( rCopy.nDyTextTop ), diff --git a/filter/source/msfilter/mstoolbar.cxx b/filter/source/msfilter/mstoolbar.cxx index 339b54766101..f746ad0e8a2d 100644 --- a/filter/source/msfilter/mstoolbar.cxx +++ b/filter/source/msfilter/mstoolbar.cxx @@ -102,7 +102,7 @@ CustomToolBarImportHelper::createCommandFromMacro( std::u16string_view sCmd ) // create script url OUString scriptURL = OUString::Concat("vnd.sun.star.script:") + sCmd + "?language=Basic&location=document"; - return uno::makeAny( scriptURL ); + return uno::Any( scriptURL ); } OUString CustomToolBarImportHelper::MSOCommandToOOCommand( sal_Int16 msoCmd ) @@ -132,7 +132,7 @@ CustomToolBarImportHelper::createMenu( const OUString& rName, const uno::Referen uno::Reference< container::XIndexContainer > xPopup( xCfgManager->createSettings(), uno::UNO_SET_THROW ); uno::Reference< beans::XPropertySet > xProps( xPopup, uno::UNO_QUERY_THROW ); // set name for menubar - xProps->setPropertyValue("UIName", uno::makeAny( rName ) ); + xProps->setPropertyValue("UIName", uno::Any( rName ) ); if ( xPopup.is() ) { uno::Sequence< beans::PropertyValue > aPopupMenu{ @@ -142,7 +142,7 @@ CustomToolBarImportHelper::createMenu( const OUString& rName, const uno::Referen comphelper::makePropertyValue("Type", sal_Int32( 0 )) }; - xPopup->insertByIndex( xPopup->getCount(), uno::makeAny( aPopupMenu ) ); + xPopup->insertByIndex( xPopup->getCount(), uno::Any( aPopupMenu ) ); xCfgManager->insertSettings( sMenuBar, xPopup ); uno::Reference< ui::XUIConfigurationPersistence > xPersistence( xCfgManager, uno::UNO_QUERY_THROW ); xPersistence->store(); diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx index ee40bede6bd4..d55a636fcc14 100644 --- a/filter/source/msfilter/msvbahelper.cxx +++ b/filter/source/msfilter/msvbahelper.cxx @@ -38,7 +38,7 @@ #include <unotools/pathoptions.hxx> #include <rtl/character.hxx> #include <sfx2/objsh.hxx> - +#include <o3tl/string_view.hxx> #include <svtools/acceleratorexecute.hxx> #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> #include <com/sun/star/ui/XUIConfigurationManager.hpp> @@ -66,13 +66,13 @@ OUString extractMacroName( const OUString& rMacroUrl ) return OUString(); } -static OUString trimMacroName( const OUString& rMacroName ) +static std::u16string_view trimMacroName( std::u16string_view rMacroName ) { // the name may contain whitespaces and may be enclosed in apostrophs - OUString aMacroName = rMacroName.trim(); - sal_Int32 nMacroLen = aMacroName.getLength(); + std::u16string_view aMacroName = o3tl::trim(rMacroName); + size_t nMacroLen = aMacroName.size(); if( (nMacroLen >= 2) && (aMacroName[ 0 ] == '\'') && (aMacroName[ nMacroLen - 1 ] == '\'') ) - aMacroName = aMacroName.copy( 1, nMacroLen - 2 ).trim(); + aMacroName = o3tl::trim(aMacroName.substr( 1, nMacroLen - 2 )); return aMacroName; } @@ -112,7 +112,7 @@ static SfxObjectShell* findShellForUrl( const OUString& sMacroURLOrPath ) uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_SET_THROW ); uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW ); xProps->getPropertyValue("Title") >>= aName; - aName = aName.getToken(0, '-').trim(); + aName = o3tl::trim(o3tl::getToken(aName, 0, '-')); if( sMacroURLOrPath.lastIndexOf( aName ) >= 0 ) { pFoundShell = pShell; @@ -173,8 +173,6 @@ static SfxObjectShell* findShellForUrl( const OUString& sMacroURLOrPath ) // if sMod is empty, only standard modules will be searched (no class, document, form modules) static bool hasMacro( SfxObjectShell const * pShell, const OUString& sLibrary, OUString& sMod, const OUString& sMacro ) { - bool bFound = false; - #if !HAVE_FEATURE_SCRIPTING (void) pShell; (void) sLibrary; @@ -200,18 +198,17 @@ static bool hasMacro( SfxObjectShell const * pShell, const OUString& sLibrary, O SbModule* pModule = pBasic->FindModule( sMod ); if ( pModule && pModule->FindMethod( sMacro, SbxClassType::Method )) { - bFound = true; + return true; } } - else if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( sMacro, SbxClassType::Method ) ) ) + else { - if( SbModule* pModule = pMethod->GetModule() ) + for (auto const& rModuleRef : pBasic->GetModules()) { - // when searching for a macro without module name, do not search in class/document/form modules - if( pModule->GetModuleType() == script::ModuleType::NORMAL ) + if (rModuleRef && rModuleRef->FindMethod(sMacro, SbxClassType::Method)) { - sMod = pModule->GetName(); - bFound = true; + sMod = rModuleRef->GetName(); + return true; } } } @@ -219,7 +216,7 @@ static bool hasMacro( SfxObjectShell const * pShell, const OUString& sLibrary, O } } #endif - return bFound; + return false; } #endif @@ -293,34 +290,34 @@ MacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const OUString& Macro return MacroResolvedInfo(); // the name may be enclosed in apostrophs - OUString aMacroName = trimMacroName( MacroName ); + std::u16string_view aMacroName = trimMacroName( MacroName ); // parse the macro name - sal_Int32 nDocSepIndex = aMacroName.indexOf( '!' ); - if( nDocSepIndex > 0 ) + size_t nDocSepIndex = aMacroName.find( '!' ); + if( nDocSepIndex > 0 && nDocSepIndex != std::u16string_view::npos ) { // macro specified by document name // find document shell for document name and call ourselves // recursively // assume for now that the document name is *this* document - OUString sDocUrlOrPath = aMacroName.copy( 0, nDocSepIndex ); - aMacroName = aMacroName.copy( nDocSepIndex + 1 ); + std::u16string_view sDocUrlOrPath = aMacroName.substr( 0, nDocSepIndex ); + aMacroName = aMacroName.substr( nDocSepIndex + 1 ); SAL_INFO("filter.ms", "doc search, current shell is " << pShell); SfxObjectShell* pFoundShell = nullptr; if( bSearchGlobalTemplates ) { SvtPathOptions aPathOpt; const OUString& aAddinPath = aPathOpt.GetAddinPath(); - if( sDocUrlOrPath.startsWith( aAddinPath ) ) + if( o3tl::starts_with(sDocUrlOrPath, aAddinPath) ) pFoundShell = pShell; } if( !pFoundShell ) - pFoundShell = findShellForUrl( sDocUrlOrPath ); + pFoundShell = findShellForUrl( OUString(sDocUrlOrPath) ); SAL_INFO( "filter.ms", "doc search, after find, found shell is " << pFoundShell); - return resolveVBAMacro( pFoundShell, aMacroName ); + return resolveVBAMacro( pFoundShell, OUString(aMacroName) ); } // macro is contained in 'this' document ( or code imported from a template @@ -331,7 +328,7 @@ MacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const OUString& Macro // macro format = Container.Module.Procedure OUString sContainer, sModule, sProcedure; - parseMacro( aMacroName, sContainer, sModule, sProcedure ); + parseMacro( OUString(aMacroName), sContainer, sModule, sProcedure ); #if 0 // As long as service VBAProjectNameProvider isn't supported in the model, disable the createInstance call @@ -556,7 +553,7 @@ OUString SAL_CALL VBAMacroResolver::resolveVBAMacroToScriptURL( const OUString& throw uno::RuntimeException(); // the name may be enclosed in apostrophs - OUString aMacroName = trimMacroName( rVBAMacroName ); + OUString aMacroName( trimMacroName( rVBAMacroName ) ); if( aMacroName.isEmpty() ) throw lang::IllegalArgumentException(); @@ -730,7 +727,7 @@ void applyShortCutKeyBinding ( const uno::Reference< frame::XModel >& rxModel, c { OUString aMacroName = MacroName.trim(); if( aMacroName.startsWith("!") ) - aMacroName = aMacroName.copy(1).trim(); + aMacroName = o3tl::trim(aMacroName.subView(1)); SfxObjectShell* pShell = nullptr; if ( rxModel.is() ) { diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index 5dee2e32e509..1c1cf439b999 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -4764,11 +4764,6 @@ bool PPTTextParagraphStyleAtomInterpreter::Read( SvStream& rIn, const DffRecordH return bValid; } -PPTTextParagraphStyleAtomInterpreter::~PPTTextParagraphStyleAtomInterpreter() -{ - -} - PPTTextSpecInfo::PPTTextSpecInfo( sal_uInt32 _nCharIdx ) : nCharIdx ( _nCharIdx ), nDontKnow ( 1 ) @@ -5140,15 +5135,14 @@ void PPTStyleTextPropReader::ReadCharProps( SvStream& rIn, PPTCharPropSet& aChar sal_uInt32& nExtParaFlags, sal_uInt16& nBuBlip, sal_uInt16& nHasAnm, sal_uInt32& nAnmScheme ) { - sal_uInt32 nMask = 0; //TODO: nMask initialized here to suppress warning for now, see corresponding TODO below - sal_uInt16 nDummy16; - sal_Int32 nCharsToRead; - sal_uInt16 nStringLen = aString.getLength(); + sal_uInt16 nStringLen = aString.getLength(); + sal_uInt16 nDummy16; rIn.ReadUInt16( nDummy16 ); nCharCount = (rIn.good()) ? nDummy16 : 0; rIn.ReadUInt16( nDummy16 ); - nCharsToRead = nStringLen - ( nCharReadCnt + nCharCount ); + + sal_Int32 nCharsToRead = nStringLen - ( nCharReadCnt + nCharCount ); if ( nCharsToRead < 0 ) { nCharCount = nStringLen - nCharReadCnt; @@ -5161,6 +5155,7 @@ void PPTStyleTextPropReader::ReadCharProps( SvStream& rIn, PPTCharPropSet& aChar ImplPPTCharPropSet& aSet = *aCharPropSet.mpImplPPTCharPropSet; // character attributes + sal_uInt32 nMask(0); rIn.ReadUInt32( nMask ); if ( static_cast<sal_uInt16>(nMask) ) { @@ -5194,7 +5189,7 @@ void PPTStyleTextPropReader::ReadCharProps( SvStream& rIn, PPTCharPropSet& aChar } if ( nMask & 0x40000 ) // cfColor { - sal_uInt32 nVal; + sal_uInt32 nVal(0); rIn.ReadUInt32( nVal ); if ( !( nVal & 0xff000000 ) ) nVal = PPT_COLSCHEME_HINTERGRUND; @@ -5748,27 +5743,24 @@ void PPTPortionObj::ApplyTo( SfxItemSet& rSet, SdrPowerPointImport& rManager, T const SfxItemSet* pItemSet = pTextObj->GetBackground(); if ( pItemSet ) { - const SfxPoolItem* pFillStyleItem = nullptr; - pItemSet->GetItemState( XATTR_FILLSTYLE, false, &pFillStyleItem ); + const XFillStyleItem* pFillStyleItem = pItemSet->GetItemIfSet( XATTR_FILLSTYLE, false ); if ( pFillStyleItem ) { - drawing::FillStyle eFillStyle = static_cast<const XFillStyleItem*>(pFillStyleItem)->GetValue(); + drawing::FillStyle eFillStyle = pFillStyleItem->GetValue(); switch( eFillStyle ) { case drawing::FillStyle_SOLID : { - const SfxPoolItem* pFillColorItem = nullptr; - pItemSet->GetItemState( XATTR_FILLCOLOR, false, &pFillColorItem ); + const XColorItem* pFillColorItem = pItemSet->GetItemIfSet( XATTR_FILLCOLOR, false ); if ( pFillColorItem ) - aDefColor = static_cast<const XColorItem*>(pFillColorItem)->GetColorValue(); + aDefColor = pFillColorItem->GetColorValue(); } break; case drawing::FillStyle_GRADIENT : { - const SfxPoolItem* pGradientItem = nullptr; - pItemSet->GetItemState( XATTR_FILLGRADIENT, false, &pGradientItem ); + const XFillGradientItem* pGradientItem = pItemSet->GetItemIfSet( XATTR_FILLGRADIENT, false ); if ( pGradientItem ) - aDefColor = static_cast<const XFillGradientItem*>(pGradientItem)->GetGradientValue().GetStartColor(); + aDefColor = pGradientItem->GetGradientValue().GetStartColor(); } break; case drawing::FillStyle_HATCH : @@ -6540,15 +6532,10 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport else nTextRulerAtomOfs = 0xffffffff; - sal_uInt32 nInstance = 0; switch( rSdrPowerPointImport.m_eCurrentPageKind ) { case PPT_NOTEPAGE : - nInstance++; - [[fallthrough]]; case PPT_MASTERPAGE : - nInstance++; - break; case PPT_SLIDEPAGE : break; default : @@ -7415,7 +7402,7 @@ static void ApplyCellAttributes( const SdrObject* pObj, Reference< XCell > const { eFS = css::drawing::FillStyle_SOLID; Color aFillColor( pObj->GetMergedItem( XATTR_FILLCOLOR ).GetColorValue() ); - xPropSet->setPropertyValue( "FillColor", makeAny( aFillColor ) ); + xPropSet->setPropertyValue( "FillColor", Any( aFillColor ) ); } break; case drawing::FillStyle_GRADIENT : @@ -7448,16 +7435,16 @@ static void ApplyCellAttributes( const SdrObject* pObj, Reference< XCell > const const XFillBitmapItem & rXFillBitmapItem(pObj->GetMergedItem( XATTR_FILLBITMAP )); uno::Reference<graphic::XGraphic> xGraphic = rXFillBitmapItem.GetGraphicObject().GetGraphic().GetXGraphic(); uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY); - xPropSet->setPropertyValue("FillBitmap", uno::makeAny(xBitmap)); + xPropSet->setPropertyValue("FillBitmap", uno::Any(xBitmap)); const XFillBmpStretchItem & rStretchItem(pObj->GetMergedItem( XATTR_FILLBMP_STRETCH )); const XFillBmpTileItem & rTileItem(pObj->GetMergedItem( XATTR_FILLBMP_TILE )); if( rTileItem.GetValue() ) - xPropSet->setPropertyValue("FillBitmapMode", uno::makeAny(drawing::BitmapMode_REPEAT)); + xPropSet->setPropertyValue("FillBitmapMode", uno::Any(drawing::BitmapMode_REPEAT)); else if( rStretchItem.GetValue() ) - xPropSet->setPropertyValue("FillBitmapMode", uno::makeAny(drawing::BitmapMode_STRETCH)); + xPropSet->setPropertyValue("FillBitmapMode", uno::Any(drawing::BitmapMode_STRETCH)); else - xPropSet->setPropertyValue("FillBitmapMode", uno::makeAny(drawing::BitmapMode_NO_REPEAT)); + xPropSet->setPropertyValue("FillBitmapMode", uno::Any(drawing::BitmapMode_NO_REPEAT)); } break; default: diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx index 23b4de1e87be..a01db3452b10 100644 --- a/filter/source/msfilter/util.cxx +++ b/filter/source/msfilter/util.cxx @@ -10,11 +10,13 @@ #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/lang/Locale.hpp> #include <rtl/ustring.hxx> +#include <comphelper/string.hxx> #include <unotools/fontcvt.hxx> #include <unotools/fontdefs.hxx> #include <vcl/BitmapPalette.hxx> #include <filter/msfilter/escherex.hxx> #include <filter/msfilter/util.hxx> +#include <o3tl/string_view.hxx> #include <memory> #include <unordered_map> @@ -308,19 +310,19 @@ const ApiPaperSize& PaperSizeConv::getApiSizeForMSPaperSizeIndex( sal_Int32 nMSO return spPaperSizeTable[ nMSOPaperIndex ]; } -OUString findQuotedText( const OUString& rCommand, +std::u16string_view findQuotedText( std::u16string_view rCommand, const char* cStartQuote, const sal_Unicode uEndQuote ) { - OUString sRet; + std::u16string_view sRet; OUString sStartQuote( OUString::createFromAscii(cStartQuote) ); - sal_Int32 nStartIndex = rCommand.indexOf( sStartQuote ); - if( nStartIndex >= 0 ) + size_t nStartIndex = rCommand.find( sStartQuote ); + if( nStartIndex != std::u16string_view::npos ) { sal_Int32 nStartLength = sStartQuote.getLength(); - sal_Int32 nEndIndex = rCommand.indexOf( uEndQuote, nStartIndex + nStartLength); - if( nEndIndex > nStartIndex ) + size_t nEndIndex = rCommand.find( uEndQuote, nStartIndex + nStartLength); + if( nEndIndex != std::u16string_view::npos && nEndIndex > nStartIndex ) { - sRet = rCommand.copy( nStartIndex + nStartLength, nEndIndex - nStartIndex - nStartLength); + sRet = rCommand.substr( nStartIndex + nStartLength, nEndIndex - nStartIndex - nStartLength); } } return sRet; @@ -484,11 +486,11 @@ bool WW8ReadFieldParams::GetTokenSttFromTo(sal_Int32* pFrom, sal_Int32* pTo, sal const OUString sParams( GetResult() ); sal_Int32 nIndex = 0; - const OUString sStart( sParams.getToken(0, '-', nIndex) ); + const std::u16string_view sStart = o3tl::getToken(sParams, 0, '-', nIndex); if (nIndex>=0) { - nStart = sStart.toInt32(); - nEnd = sParams.copy(nIndex).toInt32(); + nStart = o3tl::toInt32(sStart); + nEnd = o3tl::toInt32(sParams.subView(nIndex)); } } if( pFrom ) *pFrom = nStart; @@ -601,650 +603,616 @@ EquationResult ParseCombinedChars(const OUString& rStr) return aResult; } -namespace { - -struct CustomShapeTypeTranslationTable -{ - const char* sOOo; - const char* sMSO; -}; - -} - -const CustomShapeTypeTranslationTable pCustomShapeTypeTranslationTable[] = +OString GetOOXMLPresetGeometry( std::u16string_view rShapeType ) { - // { "non-primitive", mso_sptMin }, - { "frame", "frame" }, - { "rectangle", "rect" }, - { "round-rectangle", "roundRect" }, - { "ellipse", "ellipse" }, - { "diamond", "diamond" }, - { "isosceles-triangle", "triangle" }, - { "right-triangle", "rtTriangle" }, - { "parallelogram", "parallelogram" }, - { "trapezoid", "trapezoid" }, - { "hexagon", "hexagon" }, - { "octagon", "octagon" }, - { "cross", "plus" }, - { "star5", "star5" }, - { "right-arrow", "rightArrow" }, - // { "mso-spt14", mso_sptThickArrow }, - { "pentagon-right", "homePlate" }, - { "cube", "cube" }, - // { "mso-spt17", mso_sptBalloon }, - // { "mso-spt18", mso_sptSeal }, - { "mso-spt19", "arc" }, - { "mso-spt20", "line" }, - { "mso-spt21", "plaque" }, - { "can", "can" }, - { "ring", "donut" }, - { "mso-spt24", "textPlain" }, - { "mso-spt25", "textStop" }, - { "mso-spt26", "textTriangle" }, - { "mso-spt27", "textCanDown" }, - { "mso-spt28", "textWave1" }, - { "mso-spt29", "textArchUpPour" }, - { "mso-spt30", "textCanDown" }, - { "mso-spt31", "textArchUp" }, - { "mso-spt32", "straightConnector1" }, - { "mso-spt33", "bentConnector2" }, - { "mso-spt34", "bentConnector3" }, - { "mso-spt35", "bentConnector4" }, - { "mso-spt36", "bentConnector5" }, - { "mso-spt37", "curvedConnector2" }, - { "mso-spt38", "curvedConnector3" }, - { "mso-spt39", "curvedConnector4" }, - { "mso-spt40", "curvedConnector5" }, - { "mso-spt41", "callout1" }, - { "mso-spt42", "callout2" }, - { "mso-spt43", "callout3" }, - { "mso-spt44", "accentCallout1" }, - { "mso-spt45", "accentCallout2" }, - { "mso-spt46", "accentCallout3" }, - { "line-callout-1", "borderCallout1" }, - { "line-callout-2", "borderCallout2" }, - { "line-callout-3", "borderCallout3" }, - { "mso-spt49", "borderCallout3" }, - { "mso-spt50", "accentBorderCallout1" }, - { "mso-spt51", "accentBorderCallout2" }, - { "mso-spt52", "accentBorderCallout3" }, - { "mso-spt53", "ribbon" }, - { "mso-spt54", "ribbon2" }, - { "chevron", "chevron" }, - { "pentagon", "pentagon" }, - { "forbidden", "noSmoking" }, - { "star8", "star8" }, - { "mso-spt59", "star16" }, - { "mso-spt60", "star32" }, - { "rectangular-callout", "wedgeRectCallout" }, - { "round-rectangular-callout", "wedgeRoundRectCallout" }, - { "round-callout", "wedgeEllipseCallout" }, - { "mso-spt64", "wave" }, - { "paper", "foldedCorner" }, - { "left-arrow", "leftArrow" }, - { "down-arrow", "downArrow" }, - { "up-arrow", "upArrow" }, - { "left-right-arrow", "leftRightArrow" }, - { "up-down-arrow", "upDownArrow" }, - { "mso-spt71", "irregularSeal1" }, - { "bang", "irregularSeal2" }, - { "lightning", "lightningBolt" }, - { "heart", "heart" }, - { "quad-arrow", "quadArrow" }, - { "left-arrow-callout", "leftArrowCallout" }, - { "right-arrow-callout", "rightArrowCallout" }, - { "up-arrow-callout", "upArrowCallout" }, - { "down-arrow-callout", "downArrowCallout" }, - { "left-right-arrow-callout", "leftRightArrowCallout" }, - { "up-down-arrow-callout", "upDownArrowCallout" }, - { "quad-arrow-callout", "quadArrowCallout" }, - { "quad-bevel", "bevel" }, - { "left-bracket", "leftBracket" }, - { "right-bracket", "rightBracket" }, - { "left-brace", "leftBrace" }, - { "right-brace", "rightBrace" }, - { "mso-spt89", "leftUpArrow" }, - { "mso-spt90", "bentUpArrow" }, - { "mso-spt91", "bentArrow" }, - { "star24", "star24" }, - { "striped-right-arrow", "stripedRightArrow" }, - { "notched-right-arrow", "notchedRightArrow" }, - { "block-arc", "blockArc" }, - { "smiley", "smileyFace" }, - { "vertical-scroll", "verticalScroll" }, - { "horizontal-scroll", "horizontalScroll" }, - { "circular-arrow", "circularArrow" }, - { "mso-spt100", "pie" }, // looks like MSO_SPT is wrong here - { "mso-spt101", "uturnArrow" }, - { "mso-spt102", "curvedRightArrow" }, - { "mso-spt103", "curvedLeftArrow" }, - { "mso-spt104", "curvedUpArrow" }, - { "mso-spt105", "curvedDownArrow" }, - { "cloud-callout", "cloudCallout" }, - { "mso-spt107", "ellipseRibbon" }, - { "mso-spt108", "ellipseRibbon2" }, - { "flowchart-process", "flowChartProcess" }, - { "flowchart-decision", "flowChartDecision" }, - { "flowchart-data", "flowChartInputOutput" }, - { "flowchart-predefined-process", "flowChartPredefinedProcess" }, - { "flowchart-internal-storage", "flowChartInternalStorage" }, - { "flowchart-document", "flowChartDocument" }, - { "flowchart-multidocument", "flowChartMultidocument" }, - { "flowchart-terminator", "flowChartTerminator" }, - { "flowchart-preparation", "flowChartPreparation" }, - { "flowchart-manual-input", "flowChartManualInput" }, - { "flowchart-manual-operation", "flowChartManualOperation" }, - { "flowchart-connector", "flowChartConnector" }, - { "flowchart-card", "flowChartPunchedCard" }, - { "flowchart-punched-tape", "flowChartPunchedTape" }, - { "flowchart-summing-junction", "flowChartSummingJunction" }, - { "flowchart-or", "flowChartOr" }, - { "flowchart-collate", "flowChartCollate" }, - { "flowchart-sort", "flowChartSort" }, - { "flowchart-extract", "flowChartExtract" }, - { "flowchart-merge", "flowChartMerge" }, - { "mso-spt129", "flowChartOfflineStorage" }, - { "flowchart-stored-data", "flowChartOnlineStorage" }, - { "flowchart-sequential-access", "flowChartMagneticTape" }, - { "flowchart-magnetic-disk", "flowChartMagneticDisk" }, - { "flowchart-direct-access-storage", "flowChartMagneticDrum" }, - { "flowchart-display", "flowChartDisplay" }, - { "flowchart-delay", "flowChartDelay" }, - // { "fontwork-plain-text", "textPlainText" }, - // { "fontwork-stop", "textStop" }, - // { "fontwork-triangle-up", "textTriangle" }, - // { "fontwork-triangle-down", "textTriangleInverted" }, - // { "fontwork-chevron-up", "textChevron" }, - // { "fontwork-chevron-down", "textChevronInverted" }, - // { "mso-spt142", "textRingInside" }, - // { "mso-spt143", "textRingOutside" }, - // { "fontwork-arch-up-curve", "textArchUpCurve" }, - // { "fontwork-arch-down-curve", "textArchDownCurve" }, - // { "fontwork-circle-curve", "textCircleCurve" }, - // { "fontwork-open-circle-curve", "textButtonCurve" }, - // { "fontwork-arch-up-pour", "textArchUpPour" }, - // { "fontwork-arch-down-pour", "textArchDownPour" }, - // { "fontwork-circle-pour", "textCirclePour" }, - // { "fontwork-open-circle-pour", "textButtonPour" }, - // { "fontwork-curve-up", "textCurveUp" }, - // { "fontwork-curve-down", "textCurveDown" }, - // { "fontwork-fade-up-and-right", "textCascadeUp" }, - // { "fontwork-fade-up-and-left", "textCascadeDown" }, - // { "fontwork-wave", "textWave1" }, - // { "mso-spt157", "textWave2" }, - // { "mso-spt158", "textWave3" }, - // { "mso-spt159", "textWave4" }, - // { "fontwork-inflate", "textInflate" }, - // { "mso-spt161", "textDeflate" }, - // { "mso-spt162", "textInflateBottom" }, - // { "mso-spt163", "textDeflateBottom" }, - // { "mso-spt164", "textInflateTop" }, - // { "mso-spt165", "textDeflateTop" }, - // { "mso-spt166", "textDeflateInflate" }, - // { "mso-spt167", "textDeflateInflateDeflate" }, - // { "fontwork-fade-right", "textFadeRight" }, - // { "fontwork-fade-left", "textFadeLeft" }, - // { "fontwork-fade-up", "textFadeUp" }, - // { "fontwork-fade-down", "textFadeDown" }, - // { "fontwork-slant-up", "textSlantUp" }, - // { "fontwork-slant-down", "textSlantDown" }, - // { "mso-spt174", "textCanUp" }, - // { "mso-spt175", "textCanDown" }, - { "flowchart-alternate-process", "flowChartAlternateProcess" }, - { "flowchart-off-page-connector", "flowChartOffpageConnector" }, - { "mso-spt178", "callout1" }, - { "mso-spt179", "accentCallout1" }, - { "mso-spt180", "borderCallout1" }, - { "mso-spt182", "leftRightUpArrow" }, - { "sun", "sun" }, - { "moon", "moon" }, - { "bracket-pair", "bracketPair" }, - { "brace-pair", "bracePair" }, - { "star4", "star4" }, - { "mso-spt188", "doubleWave" }, - { "mso-spt189", "actionButtonBlank" }, - { "mso-spt190", "actionButtonHome" }, - { "mso-spt191", "actionButtonHelp" }, - { "mso-spt192", "actionButtonInformation" }, - { "mso-spt193", "actionButtonForwardNext" }, - { "mso-spt194", "actionButtonBackPrevious" }, - { "mso-spt195", "actionButtonEnd" }, - { "mso-spt196", "actionButtonBeginning" }, - { "mso-spt197", "actionButtonReturn" }, - { "mso-spt198", "actionButtonDocument" }, - { "mso-spt199", "actionButtonSound" }, - { "mso-spt200", "actionButtonMovie" }, - // { "mso-spt201", "hostControl" }, - { "mso-spt202", "rect" }, - { "ooxml-actionButtonSound", "actionButtonSound" }, - { "ooxml-borderCallout1", "borderCallout1" }, - { "ooxml-plaqueTabs", "plaqueTabs" }, - { "ooxml-curvedLeftArrow", "curvedLeftArrow" }, - { "ooxml-octagon", "octagon" }, - { "ooxml-leftRightRibbon", "leftRightRibbon" }, - { "ooxml-actionButtonInformation", "actionButtonInformation" }, - { "ooxml-bentConnector5", "bentConnector5" }, - { "ooxml-circularArrow", "circularArrow" }, - { "ooxml-downArrowCallout", "downArrowCallout" }, - { "ooxml-mathMinus", "mathMinus" }, - { "ooxml-gear9", "gear9" }, - { "ooxml-round1Rect", "round1Rect" }, - { "ooxml-sun", "sun" }, - { "ooxml-plaque", "plaque" }, - { "ooxml-chevron", "chevron" }, - { "ooxml-flowChartPreparation", "flowChartPreparation" }, - { "ooxml-diagStripe", "diagStripe" }, - { "ooxml-pentagon", "pentagon" }, - { "ooxml-funnel", "funnel" }, - { "ooxml-chartStar", "chartStar" }, - { "ooxml-accentBorderCallout1", "accentBorderCallout1" }, - { "ooxml-notchedRightArrow", "notchedRightArrow" }, - { "ooxml-rightBracket", "rightBracket" }, - { "ooxml-flowChartOffpageConnector", "flowChartOffpageConnector" }, - { "ooxml-leftRightArrow", "leftRightArrow" }, - { "ooxml-decagon", "decagon" }, - { "ooxml-actionButtonHelp", "actionButtonHelp" }, - { "ooxml-star24", "star24" }, - { "ooxml-mathDivide", "mathDivide" }, - { "ooxml-curvedConnector4", "curvedConnector4" }, - { "ooxml-flowChartOr", "flowChartOr" }, - { "ooxml-borderCallout3", "borderCallout3" }, - { "ooxml-upDownArrowCallout", "upDownArrowCallout" }, - { "ooxml-flowChartDecision", "flowChartDecision" }, - { "ooxml-leftRightArrowCallout", "leftRightArrowCallout" }, - { "ooxml-flowChartManualOperation", "flowChartManualOperation" }, - { "ooxml-snipRoundRect", "snipRoundRect" }, - { "ooxml-mathPlus", "mathPlus" }, - { "ooxml-actionButtonForwardNext", "actionButtonForwardNext" }, - { "ooxml-can", "can" }, - { "ooxml-foldedCorner", "foldedCorner" }, - { "ooxml-star32", "star32" }, - { "ooxml-flowChartInternalStorage", "flowChartInternalStorage" }, - { "ooxml-upDownArrow", "upDownArrow" }, - { "ooxml-irregularSeal2", "irregularSeal2" }, - { "ooxml-mathEqual", "mathEqual" }, - { "ooxml-star12", "star12" }, - { "ooxml-uturnArrow", "uturnArrow" }, - { "ooxml-squareTabs", "squareTabs" }, - { "ooxml-leftRightUpArrow", "leftRightUpArrow" }, - { "ooxml-homePlate", "homePlate" }, - { "ooxml-dodecagon", "dodecagon" }, - { "ooxml-leftArrowCallout", "leftArrowCallout" }, - { "ooxml-chord", "chord" }, - { "ooxml-quadArrowCallout", "quadArrowCallout" }, - { "ooxml-actionButtonBeginning", "actionButtonBeginning" }, - { "ooxml-ellipse", "ellipse" }, - { "ooxml-actionButtonEnd", "actionButtonEnd" }, - { "ooxml-arc", "arc" }, - { "ooxml-star16", "star16" }, - { "ooxml-parallelogram", "parallelogram" }, - { "ooxml-bevel", "bevel" }, - { "ooxml-roundRect", "roundRect" }, - { "ooxml-accentCallout1", "accentCallout1" }, - { "ooxml-flowChartSort", "flowChartSort" }, - { "ooxml-star8", "star8" }, - { "ooxml-flowChartAlternateProcess", "flowChartAlternateProcess" }, - { "ooxml-moon", "moon" }, - { "ooxml-star6", "star6" }, - { "ooxml-round2SameRect", "round2SameRect" }, - { "ooxml-nonIsoscelesTrapezoid", "nonIsoscelesTrapezoid" }, - { "ooxml-diamond", "diamond" }, - { "ooxml-ellipseRibbon", "ellipseRibbon" }, - { "ooxml-callout2", "callout2" }, - { "ooxml-pie", "pie" }, - { "ooxml-star4", "star4" }, - { "ooxml-flowChartPredefinedProcess", "flowChartPredefinedProcess" }, - { "ooxml-flowChartPunchedTape", "flowChartPunchedTape" }, - { "ooxml-curvedConnector2", "curvedConnector2" }, - { "ooxml-bentConnector3", "bentConnector3" }, - { "ooxml-cornerTabs", "cornerTabs" }, - { "ooxml-hexagon", "hexagon" }, - { "ooxml-flowChartConnector", "flowChartConnector" }, - { "ooxml-flowChartMagneticDisk", "flowChartMagneticDisk" }, - { "ooxml-heart", "heart" }, - { "ooxml-ribbon2", "ribbon2" }, - { "ooxml-bracePair", "bracePair" }, - { "ooxml-flowChartExtract", "flowChartExtract" }, - { "ooxml-actionButtonHome", "actionButtonHome" }, - { "ooxml-accentBorderCallout3", "accentBorderCallout3" }, - { "ooxml-flowChartOfflineStorage", "flowChartOfflineStorage" }, - { "ooxml-irregularSeal1", "irregularSeal1" }, - { "ooxml-quadArrow", "quadArrow" }, - { "ooxml-leftBrace", "leftBrace" }, - { "ooxml-leftBracket", "leftBracket" }, - { "ooxml-blockArc", "blockArc" }, - { "ooxml-curvedConnector3", "curvedConnector3" }, - { "ooxml-wedgeRoundRectCallout", "wedgeRoundRectCallout" }, - { "ooxml-actionButtonMovie", "actionButtonMovie" }, - { "ooxml-flowChartOnlineStorage", "flowChartOnlineStorage" }, - { "ooxml-gear6", "gear6" }, - { "ooxml-halfFrame", "halfFrame" }, - { "ooxml-snip2SameRect", "snip2SameRect" }, - { "ooxml-triangle", "triangle" }, - { "ooxml-teardrop", "teardrop" }, - { "ooxml-flowChartDocument", "flowChartDocument" }, - { "ooxml-rightArrowCallout", "rightArrowCallout" }, - { "ooxml-rightBrace", "rightBrace" }, - { "ooxml-chartPlus", "chartPlus" }, - { "ooxml-flowChartManualInput", "flowChartManualInput" }, - { "ooxml-flowChartMerge", "flowChartMerge" }, - { "ooxml-line", "line" }, - { "ooxml-downArrow", "downArrow" }, - { "ooxml-upArrow", "upArrow" }, - { "ooxml-curvedDownArrow", "curvedDownArrow" }, - { "ooxml-actionButtonReturn", "actionButtonReturn" }, - { "ooxml-flowChartInputOutput", "flowChartInputOutput" }, - { "ooxml-bracketPair", "bracketPair" }, - { "ooxml-smileyFace", "smileyFace" }, - { "ooxml-actionButtonBlank", "actionButtonBlank" }, - { "ooxml-wave", "wave" }, - { "ooxml-swooshArrow", "swooshArrow" }, - { "ooxml-flowChartSummingJunction", "flowChartSummingJunction" }, - { "ooxml-lightningBolt", "lightningBolt" }, - { "ooxml-flowChartDisplay", "flowChartDisplay" }, - { "ooxml-actionButtonBackPrevious", "actionButtonBackPrevious" }, - { "ooxml-frame", "frame" }, - { "ooxml-rtTriangle", "rtTriangle" }, - { "ooxml-flowChartMagneticTape", "flowChartMagneticTape" }, - { "ooxml-curvedRightArrow", "curvedRightArrow" }, - { "ooxml-leftUpArrow", "leftUpArrow" }, - { "ooxml-wedgeEllipseCallout", "wedgeEllipseCallout" }, - { "ooxml-doubleWave", "doubleWave" }, - { "ooxml-bentArrow", "bentArrow" }, - { "ooxml-star10", "star10" }, - { "ooxml-leftArrow", "leftArrow" }, - { "ooxml-curvedUpArrow", "curvedUpArrow" }, - { "ooxml-snip1Rect", "snip1Rect" }, - { "ooxml-ellipseRibbon2", "ellipseRibbon2" }, - { "ooxml-plus", "plus" }, - { "ooxml-accentCallout3", "accentCallout3" }, - { "ooxml-leftCircularArrow", "leftCircularArrow" }, - { "ooxml-rightArrow", "rightArrow" }, - { "ooxml-flowChartPunchedCard", "flowChartPunchedCard" }, - { "ooxml-snip2DiagRect", "snip2DiagRect" }, - { "ooxml-verticalScroll", "verticalScroll" }, - { "ooxml-star7", "star7" }, - { "ooxml-chartX", "chartX" }, - { "ooxml-cloud", "cloud" }, - { "ooxml-cube", "cube" }, - { "ooxml-round2DiagRect", "round2DiagRect" }, - { "ooxml-flowChartMultidocument", "flowChartMultidocument" }, - { "ooxml-actionButtonDocument", "actionButtonDocument" }, - { "ooxml-flowChartTerminator", "flowChartTerminator" }, - { "ooxml-flowChartDelay", "flowChartDelay" }, - { "ooxml-curvedConnector5", "curvedConnector5" }, - { "ooxml-horizontalScroll", "horizontalScroll" }, - { "ooxml-bentConnector4", "bentConnector4" }, - { "ooxml-leftRightCircularArrow", "leftRightCircularArrow" }, - { "ooxml-wedgeRectCallout", "wedgeRectCallout" }, - { "ooxml-accentCallout2", "accentCallout2" }, - { "ooxml-flowChartMagneticDrum", "flowChartMagneticDrum" }, - { "ooxml-corner", "corner" }, - { "ooxml-borderCallout2", "borderCallout2" }, - { "ooxml-donut", "donut" }, - { "ooxml-flowChartCollate", "flowChartCollate" }, - { "ooxml-mathNotEqual", "mathNotEqual" }, - { "ooxml-bentConnector2", "bentConnector2" }, - { "ooxml-mathMultiply", "mathMultiply" }, - { "ooxml-heptagon", "heptagon" }, - { "ooxml-rect", "rect" }, - { "ooxml-accentBorderCallout2", "accentBorderCallout2" }, - { "ooxml-pieWedge", "pieWedge" }, - { "ooxml-upArrowCallout", "upArrowCallout" }, - { "ooxml-flowChartProcess", "flowChartProcess" }, - { "ooxml-star5", "star5" }, - { "ooxml-lineInv", "lineInv" }, - { "ooxml-straightConnector1", "straightConnector1" }, - { "ooxml-stripedRightArrow", "stripedRightArrow" }, - { "ooxml-callout3", "callout3" }, - { "ooxml-bentUpArrow", "bentUpArrow" }, - { "ooxml-noSmoking", "noSmoking" }, - { "ooxml-trapezoid", "trapezoid" }, - { "ooxml-cloudCallout", "cloudCallout" }, - { "ooxml-callout1", "callout1" }, - { "ooxml-ribbon", "ribbon" }, - { "ooxml-rect", "rect" }, -}; - -struct { - const char* sDML; - MSO_SPT nVML; -} const pDMLToVMLTable[] = { - {"notPrimitive", mso_sptNotPrimitive}, - {"rectangle", mso_sptRectangle}, - {"roundRectangle", mso_sptRoundRectangle}, - {"ellipse", mso_sptEllipse}, - {"diamond", mso_sptDiamond}, - {"triangle", mso_sptIsocelesTriangle}, - {"rtTriangle", mso_sptRightTriangle}, - {"parallelogram", mso_sptParallelogram}, - {"trapezoid", mso_sptTrapezoid}, - {"hexagon", mso_sptHexagon}, - {"octagon", mso_sptOctagon}, - {"plus", mso_sptPlus}, - {"star5", mso_sptStar}, - {"rightArrow", mso_sptArrow}, - {"thickArrow", mso_sptThickArrow}, - {"homePlate", mso_sptHomePlate}, - {"cube", mso_sptCube}, - {"wedgeRoundRectCallout", mso_sptBalloon}, - {"star16", mso_sptSeal}, - {"arc", mso_sptArc}, - {"line", mso_sptLine}, - {"plaque", mso_sptPlaque}, - {"can", mso_sptCan}, - {"donut", mso_sptDonut}, - {"textPlain", mso_sptTextSimple}, - {"textStop", mso_sptTextOctagon}, - {"textTriangle", mso_sptTextHexagon}, - {"textCanDown", mso_sptTextCurve}, - {"textWave1", mso_sptTextWave}, - {"textArchUpPour", mso_sptTextRing}, - {"textCanDown", mso_sptTextOnCurve}, - {"textArchUp", mso_sptTextOnRing}, - {"straightConnector1", mso_sptStraightConnector1}, - {"bentConnector2", mso_sptBentConnector2}, - {"bentConnector3", mso_sptBentConnector3}, - {"bentConnector4", mso_sptBentConnector4}, - {"bentConnector5", mso_sptBentConnector5}, - {"curvedConnector2", mso_sptCurvedConnector2}, - {"curvedConnector3", mso_sptCurvedConnector3}, - {"curvedConnector4", mso_sptCurvedConnector4}, - {"curvedConnector5", mso_sptCurvedConnector5}, - {"callout1", mso_sptCallout1}, - {"callout2", mso_sptCallout2}, - {"callout3", mso_sptCallout3}, - {"accentCallout1", mso_sptAccentCallout1}, - {"accentCallout2", mso_sptAccentCallout2}, - {"accentCallout3", mso_sptAccentCallout3}, - {"borderCallout1", mso_sptBorderCallout1}, - {"borderCallout2", mso_sptBorderCallout2}, - {"borderCallout3", mso_sptBorderCallout3}, - {"accentBorderCallout1", mso_sptAccentBorderCallout1}, - {"accentBorderCallout2", mso_sptAccentBorderCallout2}, - {"accentBorderCallout3", mso_sptAccentBorderCallout3}, - {"ribbon", mso_sptRibbon}, - {"ribbon2", mso_sptRibbon2}, - {"chevron", mso_sptChevron}, - {"pentagon", mso_sptPentagon}, - {"noSmoking", mso_sptNoSmoking}, - {"star8", mso_sptSeal8}, - {"star16", mso_sptSeal16}, - {"star32", mso_sptSeal32}, - {"wedgeRectCallout", mso_sptWedgeRectCallout}, - {"wedgeRoundRectCallout", mso_sptWedgeRRectCallout}, - {"wedgeEllipseCallout", mso_sptWedgeEllipseCallout}, - {"wave", mso_sptWave}, - {"foldedCorner", mso_sptFoldedCorner}, - {"leftArrow", mso_sptLeftArrow}, - {"downArrow", mso_sptDownArrow}, - {"upArrow", mso_sptUpArrow}, - {"leftRightArrow", mso_sptLeftRightArrow}, - {"upDownArrow", mso_sptUpDownArrow}, - {"irregularSeal1", mso_sptIrregularSeal1}, - {"irregularSeal2", mso_sptIrregularSeal2}, - {"lightningBolt", mso_sptLightningBolt}, - {"heart", mso_sptHeart}, - {"pictureFrame", mso_sptPictureFrame}, - {"quadArrow", mso_sptQuadArrow}, - {"leftArrowCallout", mso_sptLeftArrowCallout}, - {"rightArrowCallout", mso_sptRightArrowCallout}, - {"upArrowCallout", mso_sptUpArrowCallout}, - {"downArrowCallout", mso_sptDownArrowCallout}, - {"leftRightArrowCallout", mso_sptLeftRightArrowCallout}, - {"upDownArrowCallout", mso_sptUpDownArrowCallout}, - {"quadArrowCallout", mso_sptQuadArrowCallout}, - {"bevel", mso_sptBevel}, - {"leftBracket", mso_sptLeftBracket}, - {"rightBracket", mso_sptRightBracket}, - {"leftBrace", mso_sptLeftBrace}, - {"rightBrace", mso_sptRightBrace}, - {"leftUpArrow", mso_sptLeftUpArrow}, - {"bentUpArrow", mso_sptBentUpArrow}, - {"bentArrow", mso_sptBentArrow}, - {"star24", mso_sptSeal24}, - {"stripedRightArrow", mso_sptStripedRightArrow}, - {"notchedRightArrow", mso_sptNotchedRightArrow}, - {"blockArc", mso_sptBlockArc}, - {"smileyFace", mso_sptSmileyFace}, - {"verticalScroll", mso_sptVerticalScroll}, - {"horizontalScroll", mso_sptHorizontalScroll}, - {"circularArrow", mso_sptCircularArrow}, - {"notchedCircularArrow", mso_sptNotchedCircularArrow}, - {"uturnArrow", mso_sptUturnArrow}, - {"curvedRightArrow", mso_sptCurvedRightArrow}, - {"curvedLeftArrow", mso_sptCurvedLeftArrow}, - {"curvedUpArrow", mso_sptCurvedUpArrow}, - {"curvedDownArrow", mso_sptCurvedDownArrow}, - {"cloudCallout", mso_sptCloudCallout}, - {"ellipseRibbon", mso_sptEllipseRibbon}, - {"ellipseRibbon2", mso_sptEllipseRibbon2}, - {"flowChartProcess", mso_sptFlowChartProcess}, - {"flowChartDecision", mso_sptFlowChartDecision}, - {"flowChartInputOutput", mso_sptFlowChartInputOutput}, - {"flowChartPredefinedProcess", mso_sptFlowChartPredefinedProcess}, - {"flowChartInternalStorage", mso_sptFlowChartInternalStorage}, - {"flowChartDocument", mso_sptFlowChartDocument}, - {"flowChartMultidocument", mso_sptFlowChartMultidocument}, - {"flowChartTerminator", mso_sptFlowChartTerminator}, - {"flowChartPreparation", mso_sptFlowChartPreparation}, - {"flowChartManualInput", mso_sptFlowChartManualInput}, - {"flowChartManualOperation", mso_sptFlowChartManualOperation}, - {"flowChartConnector", mso_sptFlowChartConnector}, - {"flowChartPunchedCard", mso_sptFlowChartPunchedCard}, - {"flowChartPunchedTape", mso_sptFlowChartPunchedTape}, - {"flowChartSummingJunction", mso_sptFlowChartSummingJunction}, - {"flowChartOr", mso_sptFlowChartOr}, - {"flowChartCollate", mso_sptFlowChartCollate}, - {"flowChartSort", mso_sptFlowChartSort}, - {"flowChartExtract", mso_sptFlowChartExtract}, - {"flowChartMerge", mso_sptFlowChartMerge}, - {"flowChartOfflineStorage", mso_sptFlowChartOfflineStorage}, - {"flowChartOnlineStorage", mso_sptFlowChartOnlineStorage}, - {"flowChartMagneticTape", mso_sptFlowChartMagneticTape}, - {"flowChartMagneticDisk", mso_sptFlowChartMagneticDisk}, - {"flowChartMagneticDrum", mso_sptFlowChartMagneticDrum}, - {"flowChartDisplay", mso_sptFlowChartDisplay}, - {"flowChartDelay", mso_sptFlowChartDelay}, - {"textPlain", mso_sptTextPlainText}, - {"textStop", mso_sptTextStop}, - {"textTriangle", mso_sptTextTriangle}, - {"textTriangleInverted", mso_sptTextTriangleInverted}, - {"textChevron", mso_sptTextChevron}, - {"textChevronInverted", mso_sptTextChevronInverted}, - {"textRingInside", mso_sptTextRingInside}, - {"textRingOutside", mso_sptTextRingOutside}, - {"textArchUp", mso_sptTextArchUpCurve}, - {"textArchDown", mso_sptTextArchDownCurve}, - {"textCircle", mso_sptTextCircleCurve}, - {"textButton", mso_sptTextButtonCurve}, - {"textArchUpPour", mso_sptTextArchUpPour}, - {"textArchDownPour", mso_sptTextArchDownPour}, - {"textCirclePour", mso_sptTextCirclePour}, - {"textButtonPour", mso_sptTextButtonPour}, - {"textCurveUp", mso_sptTextCurveUp}, - {"textCurveDown", mso_sptTextCurveDown}, - {"textCascadeUp", mso_sptTextCascadeUp}, - {"textCascadeDown", mso_sptTextCascadeDown}, - {"textWave1", mso_sptTextWave1}, - {"textWave2", mso_sptTextWave2}, - {"textWave3", mso_sptTextWave3}, - {"textWave4", mso_sptTextWave4}, - {"textInflate", mso_sptTextInflate}, - {"textDeflate", mso_sptTextDeflate}, - {"textInflateBottom", mso_sptTextInflateBottom}, - {"textDeflateBottom", mso_sptTextDeflateBottom}, - {"textInflateTop", mso_sptTextInflateTop}, - {"textDeflateTop", mso_sptTextDeflateTop}, - {"textDeflateInflate", mso_sptTextDeflateInflate}, - {"textDeflateInflateDeflate", mso_sptTextDeflateInflateDeflate}, - {"textFadeRight", mso_sptTextFadeRight}, - {"textFadeLeft", mso_sptTextFadeLeft}, - {"textFadeUp", mso_sptTextFadeUp}, - {"textFadeDown", mso_sptTextFadeDown}, - {"textSlantUp", mso_sptTextSlantUp}, - {"textSlantDown", mso_sptTextSlantDown}, - {"textCanUp", mso_sptTextCanUp}, - {"textCanDown", mso_sptTextCanDown}, - {"flowChartAlternateProcess", mso_sptFlowChartAlternateProcess}, - {"flowChartOffpageConnector", mso_sptFlowChartOffpageConnector}, - {"callout1", mso_sptCallout90}, - {"accentCallout1", mso_sptAccentCallout90}, - {"borderCallout1", mso_sptBorderCallout90}, - {"accentBorderCallout1", mso_sptAccentBorderCallout90}, - {"leftRightUpArrow", mso_sptLeftRightUpArrow}, - {"sun", mso_sptSun}, - {"moon", mso_sptMoon}, - {"bracketPair", mso_sptBracketPair}, - {"bracePair", mso_sptBracePair}, - {"star4", mso_sptSeal4}, - {"doubleWave", mso_sptDoubleWave}, - {"actionButtonBlank", mso_sptActionButtonBlank}, - {"actionButtonHome", mso_sptActionButtonHome}, - {"actionButtonHelp", mso_sptActionButtonHelp}, - {"actionButtonInformation", mso_sptActionButtonInformation}, - {"actionButtonForwardNext", mso_sptActionButtonForwardNext}, - {"actionButtonBackPrevious", mso_sptActionButtonBackPrevious}, - {"actionButtonEnd", mso_sptActionButtonEnd}, - {"actionButtonBeginning", mso_sptActionButtonBeginning}, - {"actionButtonReturn", mso_sptActionButtonReturn}, - {"actionButtonDocument", mso_sptActionButtonDocument}, - {"actionButtonSound", mso_sptActionButtonSound}, - {"actionButtonMovie", mso_sptActionButtonMovie}, - {"hostControl", mso_sptHostControl}, - {"textBox", mso_sptTextBox}, -}; - -const char* GetOOXMLPresetGeometry( const char* sShapeType ) -{ - typedef std::unordered_map< const char*, const char*, rtl::CStringHash, rtl::CStringEqual> CustomShapeTypeTranslationHashMap; - static CustomShapeTypeTranslationHashMap aCustomShapeTypeTranslationHashMap = []() - { - CustomShapeTypeTranslationHashMap tmp; - for(const msfilter::util::CustomShapeTypeTranslationTable& i : pCustomShapeTypeTranslationTable) - { - tmp[ i.sOOo ] = i.sMSO; - } - return tmp; - }(); - CustomShapeTypeTranslationHashMap::iterator i( - aCustomShapeTypeTranslationHashMap.find(sShapeType)); + typedef std::unordered_map<std::u16string_view, OString> CustomShapeTypeTranslationHashMap; + static const CustomShapeTypeTranslationHashMap aCustomShapeTypeTranslationHashMap{ + // { "non-primitive", mso_sptMin }, + { u"frame", "frame" }, + { u"rectangle", "rect" }, + { u"round-rectangle", "roundRect" }, + { u"ellipse", "ellipse" }, + { u"diamond", "diamond" }, + { u"isosceles-triangle", "triangle" }, + { u"right-triangle", "rtTriangle" }, + { u"parallelogram", "parallelogram" }, + { u"trapezoid", "trapezoid" }, + { u"hexagon", "hexagon" }, + { u"octagon", "octagon" }, + { u"cross", "plus" }, + { u"star5", "star5" }, + { u"right-arrow", "rightArrow" }, + // { u"mso-spt14", mso_sptThickArrow }, + { u"pentagon-right", "homePlate" }, + { u"cube", "cube" }, + // { u"mso-spt17", mso_sptBalloon }, + // { u"mso-spt18", mso_sptSeal }, + { u"mso-spt19", "arc" }, + { u"mso-spt20", "line" }, + { u"mso-spt21", "plaque" }, + { u"can", "can" }, + { u"ring", "donut" }, + { u"mso-spt24", "textPlain" }, + { u"mso-spt25", "textStop" }, + { u"mso-spt26", "textTriangle" }, + { u"mso-spt27", "textCanDown" }, + { u"mso-spt28", "textWave1" }, + { u"mso-spt29", "textArchUpPour" }, + { u"mso-spt30", "textCanDown" }, + { u"mso-spt31", "textArchUp" }, + { u"mso-spt32", "straightConnector1" }, + { u"mso-spt33", "bentConnector2" }, + { u"mso-spt34", "bentConnector3" }, + { u"mso-spt35", "bentConnector4" }, + { u"mso-spt36", "bentConnector5" }, + { u"mso-spt37", "curvedConnector2" }, + { u"mso-spt38", "curvedConnector3" }, + { u"mso-spt39", "curvedConnector4" }, + { u"mso-spt40", "curvedConnector5" }, + { u"mso-spt41", "callout1" }, + { u"mso-spt42", "callout2" }, + { u"mso-spt43", "callout3" }, + { u"mso-spt44", "accentCallout1" }, + { u"mso-spt45", "accentCallout2" }, + { u"mso-spt46", "accentCallout3" }, + { u"line-callout-1", "borderCallout1" }, + { u"line-callout-2", "borderCallout2" }, + { u"line-callout-3", "borderCallout3" }, + { u"mso-spt49", "borderCallout3" }, + { u"mso-spt50", "accentBorderCallout1" }, + { u"mso-spt51", "accentBorderCallout2" }, + { u"mso-spt52", "accentBorderCallout3" }, + { u"mso-spt53", "ribbon" }, + { u"mso-spt54", "ribbon2" }, + { u"chevron", "chevron" }, + { u"pentagon", "pentagon" }, + { u"forbidden", "noSmoking" }, + { u"star8", "star8" }, + { u"mso-spt59", "star16" }, + { u"mso-spt60", "star32" }, + { u"rectangular-callout", "wedgeRectCallout" }, + { u"round-rectangular-callout", "wedgeRoundRectCallout" }, + { u"round-callout", "wedgeEllipseCallout" }, + { u"mso-spt64", "wave" }, + { u"paper", "foldedCorner" }, + { u"left-arrow", "leftArrow" }, + { u"down-arrow", "downArrow" }, + { u"up-arrow", "upArrow" }, + { u"left-right-arrow", "leftRightArrow" }, + { u"up-down-arrow", "upDownArrow" }, + { u"mso-spt71", "irregularSeal1" }, + { u"bang", "irregularSeal2" }, + { u"lightning", "lightningBolt" }, + { u"heart", "heart" }, + { u"quad-arrow", "quadArrow" }, + { u"left-arrow-callout", "leftArrowCallout" }, + { u"right-arrow-callout", "rightArrowCallout" }, + { u"up-arrow-callout", "upArrowCallout" }, + { u"down-arrow-callout", "downArrowCallout" }, + { u"left-right-arrow-callout", "leftRightArrowCallout" }, + { u"up-down-arrow-callout", "upDownArrowCallout" }, + { u"quad-arrow-callout", "quadArrowCallout" }, + { u"quad-bevel", "bevel" }, + { u"left-bracket", "leftBracket" }, + { u"right-bracket", "rightBracket" }, + { u"left-brace", "leftBrace" }, + { u"right-brace", "rightBrace" }, + { u"mso-spt89", "leftUpArrow" }, + { u"mso-spt90", "bentUpArrow" }, + { u"mso-spt91", "bentArrow" }, + { u"star24", "star24" }, + { u"striped-right-arrow", "stripedRightArrow" }, + { u"notched-right-arrow", "notchedRightArrow" }, + { u"block-arc", "blockArc" }, + { u"smiley", "smileyFace" }, + { u"vertical-scroll", "verticalScroll" }, + { u"horizontal-scroll", "horizontalScroll" }, + { u"circular-arrow", "circularArrow" }, + { u"mso-spt100", "pie" }, // looks like MSO_SPT is wrong here + { u"mso-spt101", "uturnArrow" }, + { u"mso-spt102", "curvedRightArrow" }, + { u"mso-spt103", "curvedLeftArrow" }, + { u"mso-spt104", "curvedUpArrow" }, + { u"mso-spt105", "curvedDownArrow" }, + { u"cloud-callout", "cloudCallout" }, + { u"mso-spt107", "ellipseRibbon" }, + { u"mso-spt108", "ellipseRibbon2" }, + { u"flowchart-process", "flowChartProcess" }, + { u"flowchart-decision", "flowChartDecision" }, + { u"flowchart-data", "flowChartInputOutput" }, + { u"flowchart-predefined-process", "flowChartPredefinedProcess" }, + { u"flowchart-internal-storage", "flowChartInternalStorage" }, + { u"flowchart-document", "flowChartDocument" }, + { u"flowchart-multidocument", "flowChartMultidocument" }, + { u"flowchart-terminator", "flowChartTerminator" }, + { u"flowchart-preparation", "flowChartPreparation" }, + { u"flowchart-manual-input", "flowChartManualInput" }, + { u"flowchart-manual-operation", "flowChartManualOperation" }, + { u"flowchart-connector", "flowChartConnector" }, + { u"flowchart-card", "flowChartPunchedCard" }, + { u"flowchart-punched-tape", "flowChartPunchedTape" }, + { u"flowchart-summing-junction", "flowChartSummingJunction" }, + { u"flowchart-or", "flowChartOr" }, + { u"flowchart-collate", "flowChartCollate" }, + { u"flowchart-sort", "flowChartSort" }, + { u"flowchart-extract", "flowChartExtract" }, + { u"flowchart-merge", "flowChartMerge" }, + { u"mso-spt129", "flowChartOfflineStorage" }, + { u"flowchart-stored-data", "flowChartOnlineStorage" }, + { u"flowchart-sequential-access", "flowChartMagneticTape" }, + { u"flowchart-magnetic-disk", "flowChartMagneticDisk" }, + { u"flowchart-direct-access-storage", "flowChartMagneticDrum" }, + { u"flowchart-display", "flowChartDisplay" }, + { u"flowchart-delay", "flowChartDelay" }, + // { u"fontwork-plain-text", "textPlainText" }, + // { u"fontwork-stop", "textStop" }, + // { u"fontwork-triangle-up", "textTriangle" }, + // { u"fontwork-triangle-down", "textTriangleInverted" }, + // { u"fontwork-chevron-up", "textChevron" }, + // { u"fontwork-chevron-down", "textChevronInverted" }, + // { u"mso-spt142", "textRingInside" }, + // { u"mso-spt143", "textRingOutside" }, + // { u"fontwork-arch-up-curve", "textArchUpCurve" }, + // { u"fontwork-arch-down-curve", "textArchDownCurve" }, + // { u"fontwork-circle-curve", "textCircleCurve" }, + // { u"fontwork-open-circle-curve", "textButtonCurve" }, + // { u"fontwork-arch-up-pour", "textArchUpPour" }, + // { u"fontwork-arch-down-pour", "textArchDownPour" }, + // { u"fontwork-circle-pour", "textCirclePour" }, + // { u"fontwork-open-circle-pour", "textButtonPour" }, + // { u"fontwork-curve-up", "textCurveUp" }, + // { u"fontwork-curve-down", "textCurveDown" }, + // { u"fontwork-fade-up-and-right", "textCascadeUp" }, + // { u"fontwork-fade-up-and-left", "textCascadeDown" }, + // { u"fontwork-wave", "textWave1" }, + // { u"mso-spt157", "textWave2" }, + // { u"mso-spt158", "textWave3" }, + // { u"mso-spt159", "textWave4" }, + // { u"fontwork-inflate", "textInflate" }, + // { u"mso-spt161", "textDeflate" }, + // { u"mso-spt162", "textInflateBottom" }, + // { u"mso-spt163", "textDeflateBottom" }, + // { u"mso-spt164", "textInflateTop" }, + // { u"mso-spt165", "textDeflateTop" }, + // { u"mso-spt166", "textDeflateInflate" }, + // { u"mso-spt167", "textDeflateInflateDeflate" }, + // { u"fontwork-fade-right", "textFadeRight" }, + // { u"fontwork-fade-left", "textFadeLeft" }, + // { u"fontwork-fade-up", "textFadeUp" }, + // { u"fontwork-fade-down", "textFadeDown" }, + // { u"fontwork-slant-up", "textSlantUp" }, + // { u"fontwork-slant-down", "textSlantDown" }, + // { u"mso-spt174", "textCanUp" }, + // { u"mso-spt175", "textCanDown" }, + { u"flowchart-alternate-process", "flowChartAlternateProcess" }, + { u"flowchart-off-page-connector", "flowChartOffpageConnector" }, + { u"mso-spt178", "callout1" }, + { u"mso-spt179", "accentCallout1" }, + { u"mso-spt180", "borderCallout1" }, + { u"mso-spt182", "leftRightUpArrow" }, + { u"sun", "sun" }, + { u"moon", "moon" }, + { u"bracket-pair", "bracketPair" }, + { u"brace-pair", "bracePair" }, + { u"star4", "star4" }, + { u"mso-spt188", "doubleWave" }, + { u"mso-spt189", "actionButtonBlank" }, + { u"mso-spt190", "actionButtonHome" }, + { u"mso-spt191", "actionButtonHelp" }, + { u"mso-spt192", "actionButtonInformation" }, + { u"mso-spt193", "actionButtonForwardNext" }, + { u"mso-spt194", "actionButtonBackPrevious" }, + { u"mso-spt195", "actionButtonEnd" }, + { u"mso-spt196", "actionButtonBeginning" }, + { u"mso-spt197", "actionButtonReturn" }, + { u"mso-spt198", "actionButtonDocument" }, + { u"mso-spt199", "actionButtonSound" }, + { u"mso-spt200", "actionButtonMovie" }, + // { u"mso-spt201", "hostControl" }, + { u"mso-spt202", "rect" }, + { u"ooxml-actionButtonSound", "actionButtonSound" }, + { u"ooxml-borderCallout1", "borderCallout1" }, + { u"ooxml-plaqueTabs", "plaqueTabs" }, + { u"ooxml-curvedLeftArrow", "curvedLeftArrow" }, + { u"ooxml-octagon", "octagon" }, + { u"ooxml-leftRightRibbon", "leftRightRibbon" }, + { u"ooxml-actionButtonInformation", "actionButtonInformation" }, + { u"ooxml-bentConnector5", "bentConnector5" }, + { u"ooxml-circularArrow", "circularArrow" }, + { u"ooxml-downArrowCallout", "downArrowCallout" }, + { u"ooxml-mathMinus", "mathMinus" }, + { u"ooxml-gear9", "gear9" }, + { u"ooxml-round1Rect", "round1Rect" }, + { u"ooxml-sun", "sun" }, + { u"ooxml-plaque", "plaque" }, + { u"ooxml-chevron", "chevron" }, + { u"ooxml-flowChartPreparation", "flowChartPreparation" }, + { u"ooxml-diagStripe", "diagStripe" }, + { u"ooxml-pentagon", "pentagon" }, + { u"ooxml-funnel", "funnel" }, + { u"ooxml-chartStar", "chartStar" }, + { u"ooxml-accentBorderCallout1", "accentBorderCallout1" }, + { u"ooxml-notchedRightArrow", "notchedRightArrow" }, + { u"ooxml-rightBracket", "rightBracket" }, + { u"ooxml-flowChartOffpageConnector", "flowChartOffpageConnector" }, + { u"ooxml-leftRightArrow", "leftRightArrow" }, + { u"ooxml-decagon", "decagon" }, + { u"ooxml-actionButtonHelp", "actionButtonHelp" }, + { u"ooxml-star24", "star24" }, + { u"ooxml-mathDivide", "mathDivide" }, + { u"ooxml-curvedConnector4", "curvedConnector4" }, + { u"ooxml-flowChartOr", "flowChartOr" }, + { u"ooxml-borderCallout3", "borderCallout3" }, + { u"ooxml-upDownArrowCallout", "upDownArrowCallout" }, + { u"ooxml-flowChartDecision", "flowChartDecision" }, + { u"ooxml-leftRightArrowCallout", "leftRightArrowCallout" }, + { u"ooxml-flowChartManualOperation", "flowChartManualOperation" }, + { u"ooxml-snipRoundRect", "snipRoundRect" }, + { u"ooxml-mathPlus", "mathPlus" }, + { u"ooxml-actionButtonForwardNext", "actionButtonForwardNext" }, + { u"ooxml-can", "can" }, + { u"ooxml-foldedCorner", "foldedCorner" }, + { u"ooxml-star32", "star32" }, + { u"ooxml-flowChartInternalStorage", "flowChartInternalStorage" }, + { u"ooxml-upDownArrow", "upDownArrow" }, + { u"ooxml-irregularSeal2", "irregularSeal2" }, + { u"ooxml-mathEqual", "mathEqual" }, + { u"ooxml-star12", "star12" }, + { u"ooxml-uturnArrow", "uturnArrow" }, + { u"ooxml-squareTabs", "squareTabs" }, + { u"ooxml-leftRightUpArrow", "leftRightUpArrow" }, + { u"ooxml-homePlate", "homePlate" }, + { u"ooxml-dodecagon", "dodecagon" }, + { u"ooxml-leftArrowCallout", "leftArrowCallout" }, + { u"ooxml-chord", "chord" }, + { u"ooxml-quadArrowCallout", "quadArrowCallout" }, + { u"ooxml-actionButtonBeginning", "actionButtonBeginning" }, + { u"ooxml-ellipse", "ellipse" }, + { u"ooxml-actionButtonEnd", "actionButtonEnd" }, + { u"ooxml-arc", "arc" }, + { u"ooxml-star16", "star16" }, + { u"ooxml-parallelogram", "parallelogram" }, + { u"ooxml-bevel", "bevel" }, + { u"ooxml-roundRect", "roundRect" }, + { u"ooxml-accentCallout1", "accentCallout1" }, + { u"ooxml-flowChartSort", "flowChartSort" }, + { u"ooxml-star8", "star8" }, + { u"ooxml-flowChartAlternateProcess", "flowChartAlternateProcess" }, + { u"ooxml-moon", "moon" }, + { u"ooxml-star6", "star6" }, + { u"ooxml-round2SameRect", "round2SameRect" }, + { u"ooxml-nonIsoscelesTrapezoid", "nonIsoscelesTrapezoid" }, + { u"ooxml-diamond", "diamond" }, + { u"ooxml-ellipseRibbon", "ellipseRibbon" }, + { u"ooxml-callout2", "callout2" }, + { u"ooxml-pie", "pie" }, + { u"ooxml-star4", "star4" }, + { u"ooxml-flowChartPredefinedProcess", "flowChartPredefinedProcess" }, + { u"ooxml-flowChartPunchedTape", "flowChartPunchedTape" }, + { u"ooxml-curvedConnector2", "curvedConnector2" }, + { u"ooxml-bentConnector3", "bentConnector3" }, + { u"ooxml-cornerTabs", "cornerTabs" }, + { u"ooxml-hexagon", "hexagon" }, + { u"ooxml-flowChartConnector", "flowChartConnector" }, + { u"ooxml-flowChartMagneticDisk", "flowChartMagneticDisk" }, + { u"ooxml-heart", "heart" }, + { u"ooxml-ribbon2", "ribbon2" }, + { u"ooxml-bracePair", "bracePair" }, + { u"ooxml-flowChartExtract", "flowChartExtract" }, + { u"ooxml-actionButtonHome", "actionButtonHome" }, + { u"ooxml-accentBorderCallout3", "accentBorderCallout3" }, + { u"ooxml-flowChartOfflineStorage", "flowChartOfflineStorage" }, + { u"ooxml-irregularSeal1", "irregularSeal1" }, + { u"ooxml-quadArrow", "quadArrow" }, + { u"ooxml-leftBrace", "leftBrace" }, + { u"ooxml-leftBracket", "leftBracket" }, + { u"ooxml-blockArc", "blockArc" }, + { u"ooxml-curvedConnector3", "curvedConnector3" }, + { u"ooxml-wedgeRoundRectCallout", "wedgeRoundRectCallout" }, + { u"ooxml-actionButtonMovie", "actionButtonMovie" }, + { u"ooxml-flowChartOnlineStorage", "flowChartOnlineStorage" }, + { u"ooxml-gear6", "gear6" }, + { u"ooxml-halfFrame", "halfFrame" }, + { u"ooxml-snip2SameRect", "snip2SameRect" }, + { u"ooxml-triangle", "triangle" }, + { u"ooxml-teardrop", "teardrop" }, + { u"ooxml-flowChartDocument", "flowChartDocument" }, + { u"ooxml-rightArrowCallout", "rightArrowCallout" }, + { u"ooxml-rightBrace", "rightBrace" }, + { u"ooxml-chartPlus", "chartPlus" }, + { u"ooxml-flowChartManualInput", "flowChartManualInput" }, + { u"ooxml-flowChartMerge", "flowChartMerge" }, + { u"ooxml-line", "line" }, + { u"ooxml-downArrow", "downArrow" }, + { u"ooxml-upArrow", "upArrow" }, + { u"ooxml-curvedDownArrow", "curvedDownArrow" }, + { u"ooxml-actionButtonReturn", "actionButtonReturn" }, + { u"ooxml-flowChartInputOutput", "flowChartInputOutput" }, + { u"ooxml-bracketPair", "bracketPair" }, + { u"ooxml-smileyFace", "smileyFace" }, + { u"ooxml-actionButtonBlank", "actionButtonBlank" }, + { u"ooxml-wave", "wave" }, + { u"ooxml-swooshArrow", "swooshArrow" }, + { u"ooxml-flowChartSummingJunction", "flowChartSummingJunction" }, + { u"ooxml-lightningBolt", "lightningBolt" }, + { u"ooxml-flowChartDisplay", "flowChartDisplay" }, + { u"ooxml-actionButtonBackPrevious", "actionButtonBackPrevious" }, + { u"ooxml-frame", "frame" }, + { u"ooxml-rtTriangle", "rtTriangle" }, + { u"ooxml-flowChartMagneticTape", "flowChartMagneticTape" }, + { u"ooxml-curvedRightArrow", "curvedRightArrow" }, + { u"ooxml-leftUpArrow", "leftUpArrow" }, + { u"ooxml-wedgeEllipseCallout", "wedgeEllipseCallout" }, + { u"ooxml-doubleWave", "doubleWave" }, + { u"ooxml-bentArrow", "bentArrow" }, + { u"ooxml-star10", "star10" }, + { u"ooxml-leftArrow", "leftArrow" }, + { u"ooxml-curvedUpArrow", "curvedUpArrow" }, + { u"ooxml-snip1Rect", "snip1Rect" }, + { u"ooxml-ellipseRibbon2", "ellipseRibbon2" }, + { u"ooxml-plus", "plus" }, + { u"ooxml-accentCallout3", "accentCallout3" }, + { u"ooxml-leftCircularArrow", "leftCircularArrow" }, + { u"ooxml-rightArrow", "rightArrow" }, + { u"ooxml-flowChartPunchedCard", "flowChartPunchedCard" }, + { u"ooxml-snip2DiagRect", "snip2DiagRect" }, + { u"ooxml-verticalScroll", "verticalScroll" }, + { u"ooxml-star7", "star7" }, + { u"ooxml-chartX", "chartX" }, + { u"ooxml-cloud", "cloud" }, + { u"ooxml-cube", "cube" }, + { u"ooxml-round2DiagRect", "round2DiagRect" }, + { u"ooxml-flowChartMultidocument", "flowChartMultidocument" }, + { u"ooxml-actionButtonDocument", "actionButtonDocument" }, + { u"ooxml-flowChartTerminator", "flowChartTerminator" }, + { u"ooxml-flowChartDelay", "flowChartDelay" }, + { u"ooxml-curvedConnector5", "curvedConnector5" }, + { u"ooxml-horizontalScroll", "horizontalScroll" }, + { u"ooxml-bentConnector4", "bentConnector4" }, + { u"ooxml-leftRightCircularArrow", "leftRightCircularArrow" }, + { u"ooxml-wedgeRectCallout", "wedgeRectCallout" }, + { u"ooxml-accentCallout2", "accentCallout2" }, + { u"ooxml-flowChartMagneticDrum", "flowChartMagneticDrum" }, + { u"ooxml-corner", "corner" }, + { u"ooxml-borderCallout2", "borderCallout2" }, + { u"ooxml-donut", "donut" }, + { u"ooxml-flowChartCollate", "flowChartCollate" }, + { u"ooxml-mathNotEqual", "mathNotEqual" }, + { u"ooxml-bentConnector2", "bentConnector2" }, + { u"ooxml-mathMultiply", "mathMultiply" }, + { u"ooxml-heptagon", "heptagon" }, + { u"ooxml-rect", "rect" }, + { u"ooxml-accentBorderCallout2", "accentBorderCallout2" }, + { u"ooxml-pieWedge", "pieWedge" }, + { u"ooxml-upArrowCallout", "upArrowCallout" }, + { u"ooxml-flowChartProcess", "flowChartProcess" }, + { u"ooxml-star5", "star5" }, + { u"ooxml-lineInv", "lineInv" }, + { u"ooxml-straightConnector1", "straightConnector1" }, + { u"ooxml-stripedRightArrow", "stripedRightArrow" }, + { u"ooxml-callout3", "callout3" }, + { u"ooxml-bentUpArrow", "bentUpArrow" }, + { u"ooxml-noSmoking", "noSmoking" }, + { u"ooxml-trapezoid", "trapezoid" }, + { u"ooxml-cloudCallout", "cloudCallout" }, + { u"ooxml-callout1", "callout1" }, + { u"ooxml-ribbon", "ribbon" }, + { u"ooxml-rect", "rect" }, + }; + auto i(aCustomShapeTypeTranslationHashMap.find(rShapeType)); return i == aCustomShapeTypeTranslationHashMap.end() ? "rect" : i->second; } -MSO_SPT GETVMLShapeType(const OString& aType) +MSO_SPT GETVMLShapeType(std::u16string_view aType) { - typedef std::unordered_map< const char*, MSO_SPT, rtl::CStringHash, rtl::CStringEqual> DMLToVMLTranslationHashMap; - static DMLToVMLTranslationHashMap aDMLToVMLMap = []() - { - DMLToVMLTranslationHashMap tmp; - for (auto& i : pDMLToVMLTable) - tmp[i.sDML] = i.nVML; - return tmp; - }(); - - const char* pDML = GetOOXMLPresetGeometry(aType.getStr()); - DMLToVMLTranslationHashMap::iterator i(aDMLToVMLMap.find(pDML)); + typedef std::unordered_map<std::string_view, MSO_SPT> DMLToVMLTranslationHashMap; + static const DMLToVMLTranslationHashMap aDMLToVMLMap{ + {"notPrimitive", mso_sptNotPrimitive}, + {"rectangle", mso_sptRectangle}, + {"roundRectangle", mso_sptRoundRectangle}, + {"ellipse", mso_sptEllipse}, + {"diamond", mso_sptDiamond}, + {"triangle", mso_sptIsocelesTriangle}, + {"rtTriangle", mso_sptRightTriangle}, + {"parallelogram", mso_sptParallelogram}, + {"trapezoid", mso_sptTrapezoid}, + {"hexagon", mso_sptHexagon}, + {"octagon", mso_sptOctagon}, + {"plus", mso_sptPlus}, + {"star5", mso_sptStar}, + {"rightArrow", mso_sptArrow}, + {"thickArrow", mso_sptThickArrow}, + {"homePlate", mso_sptHomePlate}, + {"cube", mso_sptCube}, + {"wedgeRoundRectCallout", mso_sptBalloon}, + {"star16", mso_sptSeal}, + {"arc", mso_sptArc}, + {"line", mso_sptLine}, + {"plaque", mso_sptPlaque}, + {"can", mso_sptCan}, + {"donut", mso_sptDonut}, + {"textPlain", mso_sptTextSimple}, + {"textStop", mso_sptTextOctagon}, + {"textTriangle", mso_sptTextHexagon}, + {"textCanDown", mso_sptTextCurve}, + {"textWave1", mso_sptTextWave}, + {"textArchUpPour", mso_sptTextRing}, + {"textCanDown", mso_sptTextOnCurve}, + {"textArchUp", mso_sptTextOnRing}, + {"straightConnector1", mso_sptStraightConnector1}, + {"bentConnector2", mso_sptBentConnector2}, + {"bentConnector3", mso_sptBentConnector3}, + {"bentConnector4", mso_sptBentConnector4}, + {"bentConnector5", mso_sptBentConnector5}, + {"curvedConnector2", mso_sptCurvedConnector2}, + {"curvedConnector3", mso_sptCurvedConnector3}, + {"curvedConnector4", mso_sptCurvedConnector4}, + {"curvedConnector5", mso_sptCurvedConnector5}, + {"callout1", mso_sptCallout1}, + {"callout2", mso_sptCallout2}, + {"callout3", mso_sptCallout3}, + {"accentCallout1", mso_sptAccentCallout1}, + {"accentCallout2", mso_sptAccentCallout2}, + {"accentCallout3", mso_sptAccentCallout3}, + {"borderCallout1", mso_sptBorderCallout1}, + {"borderCallout2", mso_sptBorderCallout2}, + {"borderCallout3", mso_sptBorderCallout3}, + {"accentBorderCallout1", mso_sptAccentBorderCallout1}, + {"accentBorderCallout2", mso_sptAccentBorderCallout2}, + {"accentBorderCallout3", mso_sptAccentBorderCallout3}, + {"ribbon", mso_sptRibbon}, + {"ribbon2", mso_sptRibbon2}, + {"chevron", mso_sptChevron}, + {"pentagon", mso_sptPentagon}, + {"noSmoking", mso_sptNoSmoking}, + {"star8", mso_sptSeal8}, + {"star16", mso_sptSeal16}, + {"star32", mso_sptSeal32}, + {"wedgeRectCallout", mso_sptWedgeRectCallout}, + {"wedgeRoundRectCallout", mso_sptWedgeRRectCallout}, + {"wedgeEllipseCallout", mso_sptWedgeEllipseCallout}, + {"wave", mso_sptWave}, + {"foldedCorner", mso_sptFoldedCorner}, + {"leftArrow", mso_sptLeftArrow}, + {"downArrow", mso_sptDownArrow}, + {"upArrow", mso_sptUpArrow}, + {"leftRightArrow", mso_sptLeftRightArrow}, + {"upDownArrow", mso_sptUpDownArrow}, + {"irregularSeal1", mso_sptIrregularSeal1}, + {"irregularSeal2", mso_sptIrregularSeal2}, + {"lightningBolt", mso_sptLightningBolt}, + {"heart", mso_sptHeart}, + {"pictureFrame", mso_sptPictureFrame}, + {"quadArrow", mso_sptQuadArrow}, + {"leftArrowCallout", mso_sptLeftArrowCallout}, + {"rightArrowCallout", mso_sptRightArrowCallout}, + {"upArrowCallout", mso_sptUpArrowCallout}, + {"downArrowCallout", mso_sptDownArrowCallout}, + {"leftRightArrowCallout", mso_sptLeftRightArrowCallout}, + {"upDownArrowCallout", mso_sptUpDownArrowCallout}, + {"quadArrowCallout", mso_sptQuadArrowCallout}, + {"bevel", mso_sptBevel}, + {"leftBracket", mso_sptLeftBracket}, + {"rightBracket", mso_sptRightBracket}, + {"leftBrace", mso_sptLeftBrace}, + {"rightBrace", mso_sptRightBrace}, + {"leftUpArrow", mso_sptLeftUpArrow}, + {"bentUpArrow", mso_sptBentUpArrow}, + {"bentArrow", mso_sptBentArrow}, + {"star24", mso_sptSeal24}, + {"stripedRightArrow", mso_sptStripedRightArrow}, + {"notchedRightArrow", mso_sptNotchedRightArrow}, + {"blockArc", mso_sptBlockArc}, + {"smileyFace", mso_sptSmileyFace}, + {"verticalScroll", mso_sptVerticalScroll}, + {"horizontalScroll", mso_sptHorizontalScroll}, + {"circularArrow", mso_sptCircularArrow}, + {"notchedCircularArrow", mso_sptNotchedCircularArrow}, + {"uturnArrow", mso_sptUturnArrow}, + {"curvedRightArrow", mso_sptCurvedRightArrow}, + {"curvedLeftArrow", mso_sptCurvedLeftArrow}, + {"curvedUpArrow", mso_sptCurvedUpArrow}, + {"curvedDownArrow", mso_sptCurvedDownArrow}, + {"cloudCallout", mso_sptCloudCallout}, + {"ellipseRibbon", mso_sptEllipseRibbon}, + {"ellipseRibbon2", mso_sptEllipseRibbon2}, + {"flowChartProcess", mso_sptFlowChartProcess}, + {"flowChartDecision", mso_sptFlowChartDecision}, + {"flowChartInputOutput", mso_sptFlowChartInputOutput}, + {"flowChartPredefinedProcess", mso_sptFlowChartPredefinedProcess}, + {"flowChartInternalStorage", mso_sptFlowChartInternalStorage}, + {"flowChartDocument", mso_sptFlowChartDocument}, + {"flowChartMultidocument", mso_sptFlowChartMultidocument}, + {"flowChartTerminator", mso_sptFlowChartTerminator}, + {"flowChartPreparation", mso_sptFlowChartPreparation}, + {"flowChartManualInput", mso_sptFlowChartManualInput}, + {"flowChartManualOperation", mso_sptFlowChartManualOperation}, + {"flowChartConnector", mso_sptFlowChartConnector}, + {"flowChartPunchedCard", mso_sptFlowChartPunchedCard}, + {"flowChartPunchedTape", mso_sptFlowChartPunchedTape}, + {"flowChartSummingJunction", mso_sptFlowChartSummingJunction}, + {"flowChartOr", mso_sptFlowChartOr}, + {"flowChartCollate", mso_sptFlowChartCollate}, + {"flowChartSort", mso_sptFlowChartSort}, + {"flowChartExtract", mso_sptFlowChartExtract}, + {"flowChartMerge", mso_sptFlowChartMerge}, + {"flowChartOfflineStorage", mso_sptFlowChartOfflineStorage}, + {"flowChartOnlineStorage", mso_sptFlowChartOnlineStorage}, + {"flowChartMagneticTape", mso_sptFlowChartMagneticTape}, + {"flowChartMagneticDisk", mso_sptFlowChartMagneticDisk}, + {"flowChartMagneticDrum", mso_sptFlowChartMagneticDrum}, + {"flowChartDisplay", mso_sptFlowChartDisplay}, + {"flowChartDelay", mso_sptFlowChartDelay}, + {"textPlain", mso_sptTextPlainText}, + {"textStop", mso_sptTextStop}, + {"textTriangle", mso_sptTextTriangle}, + {"textTriangleInverted", mso_sptTextTriangleInverted}, + {"textChevron", mso_sptTextChevron}, + {"textChevronInverted", mso_sptTextChevronInverted}, + {"textRingInside", mso_sptTextRingInside}, + {"textRingOutside", mso_sptTextRingOutside}, + {"textArchUp", mso_sptTextArchUpCurve}, + {"textArchDown", mso_sptTextArchDownCurve}, + {"textCircle", mso_sptTextCircleCurve}, + {"textButton", mso_sptTextButtonCurve}, + {"textArchUpPour", mso_sptTextArchUpPour}, + {"textArchDownPour", mso_sptTextArchDownPour}, + {"textCirclePour", mso_sptTextCirclePour}, + {"textButtonPour", mso_sptTextButtonPour}, + {"textCurveUp", mso_sptTextCurveUp}, + {"textCurveDown", mso_sptTextCurveDown}, + {"textCascadeUp", mso_sptTextCascadeUp}, + {"textCascadeDown", mso_sptTextCascadeDown}, + {"textWave1", mso_sptTextWave1}, + {"textWave2", mso_sptTextWave2}, + {"textWave3", mso_sptTextWave3}, + {"textWave4", mso_sptTextWave4}, + {"textInflate", mso_sptTextInflate}, + {"textDeflate", mso_sptTextDeflate}, + {"textInflateBottom", mso_sptTextInflateBottom}, + {"textDeflateBottom", mso_sptTextDeflateBottom}, + {"textInflateTop", mso_sptTextInflateTop}, + {"textDeflateTop", mso_sptTextDeflateTop}, + {"textDeflateInflate", mso_sptTextDeflateInflate}, + {"textDeflateInflateDeflate", mso_sptTextDeflateInflateDeflate}, + {"textFadeRight", mso_sptTextFadeRight}, + {"textFadeLeft", mso_sptTextFadeLeft}, + {"textFadeUp", mso_sptTextFadeUp}, + {"textFadeDown", mso_sptTextFadeDown}, + {"textSlantUp", mso_sptTextSlantUp}, + {"textSlantDown", mso_sptTextSlantDown}, + {"textCanUp", mso_sptTextCanUp}, + {"textCanDown", mso_sptTextCanDown}, + {"flowChartAlternateProcess", mso_sptFlowChartAlternateProcess}, + {"flowChartOffpageConnector", mso_sptFlowChartOffpageConnector}, + {"callout1", mso_sptCallout90}, + {"accentCallout1", mso_sptAccentCallout90}, + {"borderCallout1", mso_sptBorderCallout90}, + {"accentBorderCallout1", mso_sptAccentBorderCallout90}, + {"leftRightUpArrow", mso_sptLeftRightUpArrow}, + {"sun", mso_sptSun}, + {"moon", mso_sptMoon}, + {"bracketPair", mso_sptBracketPair}, + {"bracePair", mso_sptBracePair}, + {"star4", mso_sptSeal4}, + {"doubleWave", mso_sptDoubleWave}, + {"actionButtonBlank", mso_sptActionButtonBlank}, + {"actionButtonHome", mso_sptActionButtonHome}, + {"actionButtonHelp", mso_sptActionButtonHelp}, + {"actionButtonInformation", mso_sptActionButtonInformation}, + {"actionButtonForwardNext", mso_sptActionButtonForwardNext}, + {"actionButtonBackPrevious", mso_sptActionButtonBackPrevious}, + {"actionButtonEnd", mso_sptActionButtonEnd}, + {"actionButtonBeginning", mso_sptActionButtonBeginning}, + {"actionButtonReturn", mso_sptActionButtonReturn}, + {"actionButtonDocument", mso_sptActionButtonDocument}, + {"actionButtonSound", mso_sptActionButtonSound}, + {"actionButtonMovie", mso_sptActionButtonMovie}, + {"hostControl", mso_sptHostControl}, + {"textBox", mso_sptTextBox}, + }; + + auto i(aDMLToVMLMap.find(GetOOXMLPresetGeometry(aType))); return i == aDMLToVMLMap.end() ? mso_sptNil : i->second; } diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx index c1a3c94d5a85..bd8db83692a0 100644 --- a/filter/source/pdf/impdialog.cxx +++ b/filter/source/pdf/impdialog.cxx @@ -271,6 +271,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, const Sequence< Property GetOKButton().set_label(sOkButtonText); GetCancelButton().connect_clicked(LINK(this, ImpPDFTabDialog, CancelHdl)); + GetOKButton().connect_clicked(LINK(this, ImpPDFTabDialog, OkHdl)); // remove the reset button, not needed in this tabbed dialog RemoveResetButton(); @@ -313,10 +314,45 @@ IMPL_LINK_NOARG(ImpPDFTabDialog, CancelHdl, weld::Button&, void) m_xDialog->response(RET_CANCEL); } +IMPL_LINK_NOARG(ImpPDFTabDialog, OkHdl, weld::Button&, void) +{ + if (getGeneralPage()->IsPdfUaSelected()) + { + SfxObjectShell* pShell = SfxObjectShell::GetShellFromComponent(mrDoc); + if (pShell) + { + sfx::AccessibilityIssueCollection aCollection = pShell->runAccessibilityCheck(); + if (!aCollection.getIssues().empty()) + { + mpAccessibilityCheckDialog = std::make_shared<svx::AccessibilityCheckDialog>(mpParent, aCollection); + weld::DialogController::runAsync(mpAccessibilityCheckDialog, [this](sal_Int32 retValue){ + m_xDialog->response(retValue); + }); + } + else + { + m_xDialog->response(RET_OK); + } + } + else + { + m_xDialog->response(RET_OK); + } + } + else + { + m_xDialog->response(RET_OK); + } +} + ImpPDFTabDialog::~ImpPDFTabDialog() { maConfigItem.WriteModifiedConfig(); maConfigI18N.WriteModifiedConfig(); + if (mpAccessibilityCheckDialog) + { + mpAccessibilityCheckDialog->response(RET_CANCEL); + } } void ImpPDFTabDialog::PageCreated(const OString& rId, SfxTabPage& rPage) @@ -345,26 +381,6 @@ void ImpPDFTabDialog::PageCreated(const OString& rId, SfxTabPage& rPage) } } -short ImpPDFTabDialog::Ok( ) -{ - // here the whole mechanism of the base class is not used - // when Ok is hit, the user means 'convert to PDF', so simply close with ok - - if (getGeneralPage()->IsPdfUaSelected()) - { - SfxObjectShell* pShell = SfxObjectShell::GetShellFromComponent(mrDoc); - if (pShell) - { - sfx::AccessibilityIssueCollection aCollection = pShell->runAccessibilityCheck(); - if (!aCollection.getIssues().empty()) - { - svx::AccessibilityCheckDialog aDialog(mpParent, aCollection); - return aDialog.run(); - } - } - } - return RET_OK; -} Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData() { diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx index 9682adbc111d..219d47e6d613 100644 --- a/filter/source/pdf/impdialog.hxx +++ b/filter/source/pdf/impdialog.hxx @@ -20,6 +20,7 @@ #pragma once #include <sfx2/tabdlg.hxx> +#include <svx/AccessibilityCheckDialog.hxx> #include <vcl/pdfwriter.hxx> #include <vcl/FilterConfigItem.hxx> @@ -66,6 +67,7 @@ class ImpPDFTabDialog final : public SfxTabDialogController Any maSelection; DECL_LINK(CancelHdl, weld::Button&, void); + DECL_LINK(OkHdl, weld::Button&, void); // the following data are the configuration used throughout the dialog and pages bool mbIsPresentation; @@ -123,6 +125,8 @@ class ImpPDFTabDialog final : public SfxTabDialogController bool mbCanExtractForAccessibility; css::uno::Reference< css::beans::XMaterialHolder > mxPreparedPasswords; + std::shared_ptr< svx::AccessibilityCheckDialog > mpAccessibilityCheckDialog; + bool mbIsRangeChecked; OUString msPageRange; bool mbSelectionIsChecked; @@ -163,7 +167,6 @@ public: private: virtual void PageCreated(const OString& rId, SfxTabPage& rPage) override; - virtual short Ok() override; }; diff --git a/filter/source/pdf/pdfdecomposer.cxx b/filter/source/pdf/pdfdecomposer.cxx index f861b4eaf86e..7a032bf3688a 100644 --- a/filter/source/pdf/pdfdecomposer.cxx +++ b/filter/source/pdf/pdfdecomposer.cxx @@ -82,12 +82,12 @@ XPdfDecomposer::getDecomposition(const uno::Reference<util::XBinaryDataContainer BitmapEx aReplacement(aBitmaps[0]); // short form for scale and translate transformation - const Size aDPI( - Application::GetDefaultDevice()->LogicToPixel(Size(1, 1), MapMode(MapUnit::MapInch))); const Size aBitmapSize(aReplacement.GetSizePixel()); + // ImpGraphic::getPrefMapMode() requires mm100 for bitmaps rendered from vector graphic data. + const Size aMM100( + Application::GetDefaultDevice()->PixelToLogic(aBitmapSize, MapMode(MapUnit::Map100thMM))); const basegfx::B2DHomMatrix aBitmapTransform(basegfx::utils::createScaleTranslateB2DHomMatrix( - aBitmapSize.getWidth() * aDPI.getWidth(), aBitmapSize.getHeight() * aDPI.getHeight(), 0, - 0)); + aMM100.getWidth(), aMM100.getHeight(), 0, 0)); // create primitive return drawinglayer::primitive2d::Primitive2DContainer{ diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index 604326b4bdbf..e2c072a146b7 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -38,6 +38,7 @@ #include <unotools/configmgr.hxx> #include <cppuhelper/compbase.hxx> #include <cppuhelper/basemutex.hxx> +#include <officecfg/Office/Common.hxx> #include "pdfexport.hxx" #include <strings.hrc> @@ -60,6 +61,7 @@ #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/security/XCertificate.hpp> #include <com/sun/star/beans/XMaterialHolder.hpp> +#include <com/sun/star/xml/crypto/SEInitializer.hpp> #include <memory> @@ -398,6 +400,25 @@ static OUString getMimetypeForDocument( const Reference< XComponentContext >& xC return aDocMimetype; } +uno::Reference<security::XCertificate> +PDFExport::GetCertificateFromSubjectName(const std::u16string_view& rSubjectName) const +{ + uno::Reference<xml::crypto::XSEInitializer> xSEInitializer + = xml::crypto::SEInitializer::create(mxContext); + uno::Reference<xml::crypto::XXMLSecurityContext> xSecurityContext + = xSEInitializer->createSecurityContext(OUString()); + uno::Reference<xml::crypto::XSecurityEnvironment> xSecurityEnvironment + = xSecurityContext->getSecurityEnvironment(); + for (const auto& xCertificate : xSecurityEnvironment->getPersonalCertificates()) + { + if (xCertificate->getSubjectName() == rSubjectName) + { + return xCertificate; + } + } + + return {}; +} bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& rFilterData ) { @@ -459,12 +480,18 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& } } // getting the string for the producer - aContext.DocumentInfo.Producer = - utl::ConfigManager::getProductName() + - " " + - utl::ConfigManager::getProductVersion(); + OUString aProducerOverride = officecfg::Office::Common::Save::Document::GeneratorOverride::get(); + if( !aProducerOverride.isEmpty()) + aContext.DocumentInfo.Producer = aProducerOverride; + else + aContext.DocumentInfo.Producer = + utl::ConfigManager::getProductName() + + " " + + utl::ConfigManager::getProductVersion(); + aContext.DocumentInfo.Creator = aCreator; + OUString aSignCertificateSubjectName; for ( const beans::PropertyValue& rProp : rFilterData ) { if ( rProp.Name == "PageRange" ) @@ -584,6 +611,8 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& rProp.Value >>= msSignPassword; else if ( rProp.Name == "SignatureCertificate" ) rProp.Value >>= maSignCertificate; + else if (rProp.Name == "SignCertificateSubjectName") + rProp.Value >>= aSignCertificateSubjectName; else if ( rProp.Name == "SignatureTSA" ) rProp.Value >>= msSignTSA; else if ( rProp.Name == "ExportPlaceholders" ) @@ -595,6 +624,11 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& rProp.Value >>= mbIsRedactMode; } + if (!maSignCertificate.is() && !aSignCertificateSubjectName.isEmpty()) + { + maSignCertificate = GetCertificateFromSubjectName(aSignCertificateSubjectName); + } + aContext.URL = aURL.GetMainURL(INetURLObject::DecodeMechanism::ToIUri); // set the correct version, depending on user request @@ -912,14 +946,14 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& xViewProperties->getPropertyValue( sShowOnlineLayout ) >>= bReChangeToNormalView; if( bReChangeToNormalView ) { - xViewProperties->setPropertyValue( sShowOnlineLayout, uno::makeAny( false ) ); + xViewProperties->setPropertyValue( sShowOnlineLayout, uno::Any( false ) ); } // Also, disable hide-whitespace during export. xViewProperties->getPropertyValue(sHideWhitespace) >>= bReHideWhitespace; if (bReHideWhitespace) { - xViewProperties->setPropertyValue(sHideWhitespace, uno::makeAny(false)); + xViewProperties->setPropertyValue(sHideWhitespace, uno::Any(false)); } } catch( const uno::Exception& ) @@ -982,7 +1016,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& { try { - xViewProperties->setPropertyValue( sShowOnlineLayout, uno::makeAny( true ) ); + xViewProperties->setPropertyValue( sShowOnlineLayout, uno::Any( true ) ); } catch( const uno::Exception& ) { @@ -992,7 +1026,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& { try { - xViewProperties->setPropertyValue( sHideWhitespace, uno::makeAny( true ) ); + xViewProperties->setPropertyValue( sHideWhitespace, uno::Any( true ) ); } catch( const uno::Exception& ) { diff --git a/filter/source/pdf/pdfexport.hxx b/filter/source/pdf/pdfexport.hxx index 967668e7421b..12d43ada945e 100644 --- a/filter/source/pdf/pdfexport.hxx +++ b/filter/source/pdf/pdfexport.hxx @@ -35,19 +35,14 @@ class Size; namespace vcl { class PDFWriter; } -using namespace ::com::sun::star; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; - class PDFExport { private: - Reference< XComponent > mxSrcDoc; - Reference< uno::XComponentContext > mxContext; - Reference< task::XStatusIndicator > mxStatusIndicator; - Reference< task::XInteractionHandler > mxIH; + css::uno::Reference< css::lang::XComponent > mxSrcDoc; + css::uno::Reference< css::uno::XComponentContext > mxContext; + css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator; + css::uno::Reference< css::task::XInteractionHandler > mxIH; bool mbUseTaggedPDF; sal_Int32 mnPDFTypeSelection; @@ -115,29 +110,30 @@ private: OUString msSignContact; OUString msSignReason; OUString msSignPassword; - Reference< security::XCertificate > maSignCertificate; + css::uno::Reference< css::security::XCertificate > maSignCertificate; OUString msSignTSA; void ImplWriteWatermark( vcl::PDFWriter& rWriter, const Size& rPageSize ); void ImplWriteTiledWatermark( vcl::PDFWriter& rWriter, const Size& rPageSize ); + css::uno::Reference<css::security::XCertificate> GetCertificateFromSubjectName(const std::u16string_view& rSubjectName) const; public: - PDFExport( const Reference< XComponent >& rxSrcDoc, - const Reference< task::XStatusIndicator >& xStatusIndicator, - const Reference< task::XInteractionHandler >& xIH, - const Reference< uno::XComponentContext >& xFact ); + PDFExport( const css::uno::Reference< css::lang::XComponent >& rxSrcDoc, + const css::uno::Reference< css::task::XStatusIndicator >& xStatusIndicator, + const css::uno::Reference< css::task::XInteractionHandler >& xIH, + const css::uno::Reference< css::uno::XComponentContext >& xFact ); ~PDFExport(); bool ExportSelection( vcl::PDFWriter& rPDFWriter, - Reference< css::view::XRenderable > const & rRenderable, - const Any& rSelection, + css::uno::Reference< css::view::XRenderable > const & rRenderable, + const css::uno::Any& rSelection, const StringRangeEnumerator& rRangeEnum, - Sequence< PropertyValue >& rRenderOptions, + css::uno::Sequence< css::beans::PropertyValue >& rRenderOptions, sal_Int32 nPageCount ); - bool Export( const OUString& rFile, const Sequence< PropertyValue >& rFilterData ); + bool Export( const OUString& rFile, const css::uno::Sequence< css::beans::PropertyValue >& rFilterData ); void showErrors( const std::set<vcl::PDFWriter::ErrorCode>& ); }; diff --git a/filter/source/pdf/pdffilter.cxx b/filter/source/pdf/pdffilter.cxx index 6d1a793a7158..d7fc558d198e 100644 --- a/filter/source/pdf/pdffilter.cxx +++ b/filter/source/pdf/pdffilter.cxx @@ -30,6 +30,9 @@ #include <com/sun/star/io/XOutputStream.hpp> +#include <comphelper/propertysequence.hxx> +#include <comphelper/sequence.hxx> + using namespace ::com::sun::star::io; PDFFilter::PDFFilter( const Reference< XComponentContext > &rxContext ) : @@ -47,6 +50,7 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) { Reference< XOutputStream > xOStm; Sequence< PropertyValue > aFilterData; + OUString aFilterOptions; sal_Int32 nLength = rDescriptor.getLength(); const PropertyValue* pValue = rDescriptor.getConstArray(); bool bIsRedactMode = false; @@ -60,6 +64,8 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) pValue[ i ].Value >>= xOStm; else if ( pValue[ i ].Name == "FilterData" ) pValue[ i ].Value >>= aFilterData; + else if ( pValue[ i ].Name == "FilterOptions" ) + pValue[ i ].Value >>= aFilterOptions; else if ( pValue[ i ].Name == "StatusIndicator" ) pValue[ i ].Value >>= xStatusIndicator; else if ( pValue[i].Name == "InteractionHandler" ) @@ -72,6 +78,13 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) pValue[i].Value >>= bIsRedactMode; } + if (!aFilterData.hasElements() && !aFilterOptions.isEmpty()) + { + // Allow setting filter data keys from the cmdline. + std::vector<PropertyValue> aData = comphelper::JsonToPropertyValues(aFilterOptions.toUtf8()); + aFilterData = comphelper::containerToSequence(aData); + } + /* we don't get FilterData if we are exporting directly to pdf, but we have to use the last user settings (especially for the CompressMode) */ if ( !aFilterData.hasElements() ) diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js index 636fc3a50d37..370bacc5cd72 100644 --- a/filter/source/svg/presentation_engine.js +++ b/filter/source/svg/presentation_engine.js @@ -18622,8 +18622,8 @@ SlideShow.prototype.exitSlideShowInApp = function() { if (window.webkit !== undefined && window.webkit.messageHandlers !== undefined && - window.webkit.messageHandlers.lool !== undefined) - window.webkit.messageHandlers.lool.postMessage('EXITSLIDESHOW', '*'); + window.webkit.messageHandlers.cool !== undefined) + window.webkit.messageHandlers.cool.postMessage('EXITSLIDESHOW', '*'); } SlideShow.prototype.displaySlide = function( nNewSlide, bSkipSlideTransition ) diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index ef0c1ea37a80..c21b041b1bbc 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -796,7 +796,9 @@ bool SVGFilter::implExportWriterTextGraphic( const Reference< view::XSelectionSu const Graphic aOriginalGraphic(xOriginalGraphic); uno::Reference<graphic::XGraphic> xTransformedGraphic; - xPropertySet->getPropertyValue("TransformedGraphic") >>= xTransformedGraphic; + xPropertySet->getPropertyValue( + mbIsPreview ? OUString("GraphicPreview") : OUString("TransformedGraphic")) + >>= xTransformedGraphic; if (!xTransformedGraphic.is()) return false; @@ -971,6 +973,8 @@ bool SVGFilter::implExportDocument() mpSVGWriter->SetEmbeddedBitmapRefs( &maBitmapActionMap ); implExportTiledBackground(); } + if( mbIsPreview ) + mpSVGWriter->SetPreviewMode(); // #i124608# export a given object selection, so no MasterPage export at all if (!mbExportShapeSelection) diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx index 4c3f033d02eb..4538e50213fc 100644 --- a/filter/source/svg/svgfilter.cxx +++ b/filter/source/svg/svgfilter.cxx @@ -77,6 +77,7 @@ SVGFilter::SVGFilter( const Reference< XComponentContext >& rxCtx ) : mnVisiblePage( -1 ), mpObjects( nullptr ), mbExportShapeSelection(false), + mbIsPreview(false), mbWriterFilter(false), mbCalcFilter(false), mbImpressFilter(false), @@ -108,6 +109,15 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto for (const PropertyValue& rProp : rDescriptor) { + if (rProp.Name == "IsPreview") + { + rProp.Value >>= mbIsPreview; + break; + } + } + + for (const PropertyValue& rProp : rDescriptor) + { if (rProp.Name == "FilterName") { OUString sFilterName; @@ -221,7 +231,7 @@ bool SVGFilter::filterImpressOrDraw( const Sequence< PropertyValue >& rDescripto GraphicFilter aGraphicFilter; Graphic aGraphic; const ErrCode nGraphicFilterErrorCode( - aGraphicFilter.ImportGraphic(aGraphic, OUString(), *aStream)); + aGraphicFilter.ImportGraphic(aGraphic, u"", *aStream)); if(ERRCODE_NONE != nGraphicFilterErrorCode) { diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx index eb889e81662e..93e14ec41671 100644 --- a/filter/source/svg/svgfilter.hxx +++ b/filter/source/svg/svgfilter.hxx @@ -209,6 +209,7 @@ private: Sequence< PropertyValue > maFilterData; Reference< css::drawing::XDrawPage > mxDefaultPage; std::vector< Reference< css::drawing::XDrawPage > > mSelectedPages; + bool mbIsPreview; bool mbWriterFilter; bool mbCalcFilter; diff --git a/filter/source/svg/svgfontexport.cxx b/filter/source/svg/svgfontexport.cxx index b0cbed97e4e7..7e75d65e6bc2 100644 --- a/filter/source/svg/svgfontexport.cxx +++ b/filter/source/svg/svgfontexport.cxx @@ -29,6 +29,7 @@ #include <vcl/settings.hxx> #include <i18nlangtag/languagetag.hxx> #include <xmloff/namespacemap.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/i18n/CharacterIteratorMode.hpp> #include <com/sun/star/i18n/XBreakIterator.hpp> @@ -307,9 +308,9 @@ void SVGFontExport::EmbedFonts() } -OUString SVGFontExport::GetMappedFontName( const OUString& rFontName ) const +OUString SVGFontExport::GetMappedFontName( std::u16string_view rFontName ) const { - OUString aRet( rFontName.getToken( 0, ';' ) ); + OUString aRet( o3tl::getToken(rFontName, 0, ';' ) ); if( mnCurFontId ) aRet += " embedded"; diff --git a/filter/source/svg/svgfontexport.hxx b/filter/source/svg/svgfontexport.hxx index 6492ebd9c04c..259196f9e031 100644 --- a/filter/source/svg/svgfontexport.hxx +++ b/filter/source/svg/svgfontexport.hxx @@ -66,7 +66,7 @@ public: ~SVGFontExport(); void EmbedFonts(); - OUString GetMappedFontName( const OUString& rFontName ) const; + OUString GetMappedFontName( std::u16string_view rFontName ) const; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index e066806cea9a..9f889924cfb6 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -37,6 +37,7 @@ #include <xmloff/namespacemap.hxx> #include <xmloff/unointerfacetouniqueidentifiermapper.hxx> #include <i18nlangtag/languagetag.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/container/XIndexReplace.hpp> @@ -301,8 +302,7 @@ void SVGAttributeWriter::AddGradientDef( const tools::Rectangle& rObjRect, const { const double fCenterX = rObjRect.Left() + rObjRect.GetWidth() * rGradient.GetOfsX() * 0.01; const double fCenterY = rObjRect.Top() + rObjRect.GetHeight() * rGradient.GetOfsY() * 0.01; - const double fRadius = sqrt( static_cast< double >( rObjRect.GetWidth() ) * rObjRect.GetWidth() + - rObjRect.GetHeight() * rObjRect.GetHeight() ) * 0.5; + const double fRadius = std::hypot(rObjRect.GetWidth(), rObjRect.GetHeight()) * 0.5; mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrGradientUnits, "userSpaceOnUse" ); mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCX, OUString::number( ImplRound( fCenterX ) ) ); @@ -1099,7 +1099,19 @@ bool SVGTextWriter::nextParagraph() const OUString& rParagraphId = implGetValidIDFromInterface( Reference<XInterface>(xTextContent, UNO_QUERY) ); if( !rParagraphId.isEmpty() ) { - mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", rParagraphId ); + // if there is id for empty paragraph we need to create a empty text paragraph + Reference < XTextRange > xRange( xTextContent, UNO_QUERY_THROW ); + if ( xRange.is() && xRange->getString().isEmpty() ) + { + endTextParagraph(); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "class", "TextParagraph" ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", rParagraphId ); + mpTextParagraphElem.reset(new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemTspan, mbIWS, mbIWS )); + } + else + { + mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", rParagraphId ); + } } return true; } @@ -1775,6 +1787,9 @@ void SVGTextWriter::implWriteTextPortion( const Point& rPos, } else { + // Without the following attribute Google Chrome does not render leading spaces + mrExport.AddAttribute( XML_NAMESPACE_NONE, "style", "white-space: pre" ); + SvXMLElementExport aSVGTspanElem( mrExport, XML_NAMESPACE_NONE, aXMLElemTspan, mbIWS, mbIWS ); mrExport.GetDocHandler()->characters( rText ); } @@ -1796,7 +1811,8 @@ SVGActionWriter::SVGActionWriter( SVGExport& rExport, SVGFontExport& rFontExport mpVDev(VclPtr<VirtualDevice>::Create()), mbClipAttrChanged( false ), mbIsPlaceholderShape( false ), - mpEmbeddedBitmapsMap( nullptr ) + mpEmbeddedBitmapsMap( nullptr ), + mbIsPreview( false ) { mpVDev->EnableOutput( false ); maTargetMapMode = MapMode(MapUnit::Map100thMM); @@ -2930,7 +2946,27 @@ void SVGActionWriter::ImplWriteBmp( const BitmapEx& rBmpEx, } } - if( !(bCached || GraphicConverter::Export( aOStm, rBmpEx, ConvertDataFormat::PNG ) == ERRCODE_NONE) ) + const BitmapEx* pBitmap = &rBmpEx; + std::unique_ptr<BitmapEx> pNewBitmap; + + // for preview we generate downscaled images (1280x720 max) + if (mbIsPreview) + { + Size aSize = rBmpEx.GetSizePixel(); + double fX = static_cast<double>(aSize.getWidth()) / 1280; + double fY = static_cast<double>(aSize.getHeight()) / 720; + double fFactor = fX > fY ? fX : fY; + if (fFactor > 1.0) + { + aSize.setWidth(aSize.getWidth() / fFactor); + aSize.setHeight(aSize.getHeight() / fFactor); + pNewBitmap = std::make_unique<BitmapEx>(rBmpEx); + pNewBitmap->Scale(aSize); + pBitmap = pNewBitmap.get(); + } + } + + if( !(bCached || GraphicConverter::Export( aOStm, *pBitmap, ConvertDataFormat::PNG ) == ERRCODE_NONE) ) return; Point aPt; @@ -3490,7 +3526,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, } } - if(mapCurShape && mapCurShape->maShapePolyPoly.Count() && (aStartArrow.Count() || aEndArrow.Count())) + if (mapCurShape->maShapePolyPoly.Count() && (aStartArrow.Count() || aEndArrow.Count())) { ImplWriteShape( *mapCurShape ); @@ -3666,7 +3702,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, // Both the pattern and the rectangle are embedded in a <defs> element. // The comment content has the following format: "SLIDE_BACKGROUND <background-id>" const OString& sComment = pA->GetComment(); - OUString sRefId = "#" + OUString::fromUtf8( sComment.getToken(1, ' ') ); + OUString sRefId = "#" + OUString::fromUtf8( o3tl::getToken(sComment, 1, ' ') ); mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrXLinkHRef, sRefId ); SvXMLElementExport aRefElem( mrExport, XML_NAMESPACE_NONE, "use", true, true ); diff --git a/filter/source/svg/svgwriter.hxx b/filter/source/svg/svgwriter.hxx index fdfcd24d32b2..d48d68bdec72 100644 --- a/filter/source/svg/svgwriter.hxx +++ b/filter/source/svg/svgwriter.hxx @@ -318,6 +318,7 @@ private: bool mbClipAttrChanged; bool mbIsPlaceholderShape; const MetaBitmapActionMap* mpEmbeddedBitmapsMap; + bool mbIsPreview; tools::Long ImplMap( sal_Int32 nVal ) const; @@ -377,6 +378,7 @@ public: void SetEmbeddedBitmapRefs( const MetaBitmapActionMap* pEmbeddedBitmapsMap ); void StartMask(const Point& rDestPt, const Size& rDestSize, const Gradient& rGradient, sal_uInt32 nWriteFlags, OUString* pTextStyle = nullptr); + void SetPreviewMode(bool bState = true) { mbIsPreview = bState; } }; diff --git a/filter/source/textfilterdetect/filterdetect.cxx b/filter/source/textfilterdetect/filterdetect.cxx index f8fc5cb865eb..9d25e289ec89 100644 --- a/filter/source/textfilterdetect/filterdetect.cxx +++ b/filter/source/textfilterdetect/filterdetect.cxx @@ -20,8 +20,6 @@ #include <com/sun/star/io/XInputStream.hpp> #include <cppuhelper/supportsservice.hxx> #include <memory> -#include <sfx2/fcontnr.hxx> -#include <sfx2/docfilt.hxx> constexpr OUStringLiteral WRITER_TEXT_FILTER = u"Text"; constexpr OUStringLiteral CALC_TEXT_FILTER = u"Text - txt - csv (StarCalc)"; @@ -129,40 +127,6 @@ bool IsHTMLStream( const uno::Reference<io::XInputStream>& xInStream ) OString aToken = sHeader.copy( nStartOfTagIndex, i - nStartOfTagIndex ); return GetHTMLToken( OStringToOUString( aToken.toAsciiLowerCase(), RTL_TEXTENCODING_ASCII_US ) ) != HtmlTokenId::NONE; } - -/** - * Given an (empty) file URL in rMediaDesc and rExt, looks up the best filter type for it and - * writes the type name to rType, the filter name to rMediaDesc. - */ -bool HandleEmptyFileUrlByExtension(MediaDescriptor& rMediaDesc, const OUString& rExt, - OUString& rType, OUString& rService) -{ - OUString aURL = rMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_URL, OUString()); - if (!tools::isEmptyFileUrl(aURL)) - { - return false; - } - - if (rExt.isEmpty()) - { - return false; - } - - // Requiring the export+preferred flags helps to find the relevant filter, e.g. .doc -> WW8 (and - // not WW6 or Mac_Word). - SfxFilterFlags nMust - = SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::PREFERED; - std::shared_ptr<const SfxFilter> pFilter(SfxFilterMatcher().GetFilter4Extension(rExt, nMust)); - if (!pFilter) - { - return false; - } - - rMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= pFilter->GetFilterName(); - rType = pFilter->GetTypeName(); - rService = pFilter->GetServiceName(); - return true; -} } PlainTextFilterDetect::PlainTextFilterDetect() {} @@ -221,15 +185,7 @@ OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyVal OUString aName = aParser.getName().toAsciiLowerCase(); // Decide which filter to use based on the document service first, - // then on extension if that's not available. Make exception for 0-byte files - // whose extensions are handled by the same service as passed document service. - OUString aEmptyType, aEmptyService; - bool bEmpty = HandleEmptyFileUrlByExtension(aMediaDesc, aExt, aEmptyType, aEmptyService); - if (bEmpty && aDocService == aEmptyService) - { - aDocService.clear(); // don't fallback to text filter, use extension-based match - // TODO: maybe reset aExt when it's "xls" - } + // then on extension if that's not available. if (aDocService == CALC_DOCSERVICE) aMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= OUString(CALC_TEXT_FILTER); @@ -237,8 +193,6 @@ OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyVal aMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= OUString(WRITER_TEXT_FILTER); else if (aExt == "csv" || aExt == "tsv" || aExt == "tab" || aExt == "xls" || aName.endsWith(".csv.gz")) aMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= OUString(CALC_TEXT_FILTER); - else if (bEmpty) - aType = aEmptyType; // aMediaDesc is already updated in HandleEmptyFileUrlByExtension else aMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= OUString(WRITER_TEXT_FILTER); } diff --git a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx index c4fb3eef20cd..f31907519890 100644 --- a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx +++ b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx @@ -91,7 +91,7 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& Reference< XPropertySet > xInfoSet( GenericPropertySet_CreateInstance( new PropertySetInfo( aImportInfoMap ) ) ); - xInfoSet->setPropertyValue( "BaseURI", makeAny( aBaseURI )); + xInfoSet->setPropertyValue( "BaseURI", Any( aBaseURI )); OUString aFilterName; auto It = aMediaMap.find(OUString("FilterName")); @@ -101,7 +101,7 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& PropertyValue EmptyDbFieldHidesPara("EmptyDbFieldHidesPara", 0, Any(false), PropertyState::PropertyState_DIRECT_VALUE); Sequence<PropertyValue> aSettings{ EmptyDbFieldHidesPara }; - xInfoSet->setPropertyValue("DefaultDocumentSettings", makeAny(aSettings)); + xInfoSet->setPropertyValue("DefaultDocumentSettings", Any(aSettings)); } Sequence< Any > aAnys{ Any(xInfoSet) }; @@ -290,11 +290,11 @@ bool XmlFilterAdaptor::exportImpl( const Sequence< css::beans::PropertyValue >& Reference< XPropertySet > xInfoSet( GenericPropertySet_CreateInstance( new PropertySetInfo( aImportInfoMap ) ) ); - xInfoSet->setPropertyValue("UsePrettyPrinting", makeAny( bPrettyPrint )); + xInfoSet->setPropertyValue("UsePrettyPrinting", Any( bPrettyPrint )); xInfoSet->setPropertyValue( "ExportTextNumberElement", - makeAny( bExportTextNumberElementForListItems )); - xInfoSet->setPropertyValue("BaseURI", makeAny( aBaseURI )); + Any( bExportTextNumberElementForListItems )); + xInfoSet->setPropertyValue("BaseURI", Any( aBaseURI )); Sequence < Any > aAnys{ Any(xConverter), Any(xInfoSet) }; Reference< XExporter > xExporter( mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( diff --git a/filter/source/xmlfilterdetect/filterdetect.cxx b/filter/source/xmlfilterdetect/filterdetect.cxx index 1a3f80cb589a..e7cab3323fca 100644 --- a/filter/source/xmlfilterdetect/filterdetect.cxx +++ b/filter/source/xmlfilterdetect/filterdetect.cxx @@ -28,6 +28,7 @@ #include <unotools/ucbstreamhelper.hxx> #include <svl/inettype.hxx> #include <memory> +#include <o3tl/string_view.hxx> using namespace com::sun::star::container; using namespace com::sun::star::uno; @@ -35,13 +36,13 @@ using namespace com::sun::star::beans; namespace { -OUString supportedByType( const OUString& clipBoardFormat, const OUString& resultString, const OUString& checkType) +OUString supportedByType( std::u16string_view clipBoardFormat, std::u16string_view resultString, const OUString& checkType) { OUString sTypeName; - if ( clipBoardFormat.match("doctype:") ) + if ( o3tl::starts_with(clipBoardFormat, u"doctype:") ) { - OUString tryStr = clipBoardFormat.copy(8); - if (resultString.indexOf(tryStr) >= 0) + std::u16string_view tryStr = clipBoardFormat.substr(8); + if (resultString.find(tryStr) != std::u16string_view::npos) { sTypeName = checkType; } diff --git a/filter/source/xsltdialog/typedetectionimport.cxx b/filter/source/xsltdialog/typedetectionimport.cxx index bba302de703c..be5766927fbc 100644 --- a/filter/source/xsltdialog/typedetectionimport.cxx +++ b/filter/source/xsltdialog/typedetectionimport.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/xml/sax/XAttributeList.hpp> #include <tools/diagnose_ex.h> #include <rtl/ref.hxx> +#include <o3tl/string_view.hxx> #include "typedetectionimport.hxx" #include "xmlfiltercommon.hxx" @@ -80,18 +81,18 @@ void TypeDetectionImporter::fillFilterVector( std::vector< std::unique_ptr<filt maTypeNodes.clear(); } -static OUString getSubdata( int index, sal_Unicode delimiter, const OUString& rData ) +static std::u16string_view getSubdata( int index, sal_Unicode delimiter, std::u16string_view rData ) { sal_Int32 nLastIndex = 0; - sal_Int32 nNextIndex = rData.indexOf( delimiter ); + size_t nNextIndex = rData.find( delimiter ); - OUString aSubdata; + std::u16string_view aSubdata; while( index ) { - nLastIndex = nNextIndex + 1; - nNextIndex = rData.indexOf( delimiter, nLastIndex ); + nLastIndex = nNextIndex == std::u16string_view::npos ? 0 : nNextIndex + 1; + nNextIndex = rData.find( delimiter, nLastIndex ); index--; @@ -99,13 +100,13 @@ static OUString getSubdata( int index, sal_Unicode delimiter, const OUString& rD return aSubdata; } - if( nNextIndex == -1 ) + if( nNextIndex == std::u16string_view::npos ) { - aSubdata = rData.copy( nLastIndex ); + aSubdata = rData.substr( nLastIndex ); } else { - aSubdata = rData.copy( nLastIndex, nNextIndex - nLastIndex ); + aSubdata = rData.substr( nLastIndex, nNextIndex - nLastIndex ); } return aSubdata; @@ -135,16 +136,16 @@ std::unique_ptr<filter_info_impl> TypeDetectionImporter::createFilterForNode( No pFilter->maType = getSubdata( 1, aComma, aData ); pFilter->maDocumentService = getSubdata( 2, aComma, aData ); - OUString aFilterService( getSubdata( 3, aComma, aData ) ); - pFilter->maFlags = getSubdata( 4, aComma, aData ).toInt32(); + std::u16string_view aFilterService( getSubdata( 3, aComma, aData ) ); + pFilter->maFlags = o3tl::toInt32(getSubdata( 4, aComma, aData )); // parse filter user data sal_Unicode aDelim(';'); - OUString aFilterUserData( getSubdata( 5, aComma, aData ) ); + std::u16string_view aFilterUserData( getSubdata( 5, aComma, aData ) ); - OUString aAdapterService( getSubdata( 0, aDelim, aFilterUserData ) ); + std::u16string_view aAdapterService( getSubdata( 0, aDelim, aFilterUserData ) ); //Import/ExportService - pFilter->mbNeedsXSLT2 = getSubdata( 1, aDelim, aFilterUserData ).toBoolean(); + pFilter->mbNeedsXSLT2 = OUString(getSubdata( 1, aDelim, aFilterUserData )).toBoolean(); pFilter->maImportService = getSubdata( 2, aDelim, aFilterUserData ); pFilter->maExportService = getSubdata( 3, aDelim, aFilterUserData ); pFilter->maImportXSLT = getSubdata( 4, aDelim, aFilterUserData ); @@ -161,7 +162,7 @@ std::unique_ptr<filter_info_impl> TypeDetectionImporter::createFilterForNode( No pFilter->maDocType = getSubdata( 2, aComma, aTypeUserData ); pFilter->maExtension = getSubdata( 4, aComma, aTypeUserData ); - pFilter->mnDocumentIconID = getSubdata( 5, aComma, aTypeUserData ).toInt32(); + pFilter->mnDocumentIconID = o3tl::toInt32(getSubdata( 5, aComma, aTypeUserData )); } bool bOk = true; @@ -181,10 +182,10 @@ std::unique_ptr<filter_info_impl> TypeDetectionImporter::createFilterForNode( No if( pFilter->maFlags == 0 ) bOk = false; - if( aFilterService != "com.sun.star.comp.Writer.XmlFilterAdaptor" ) + if( aFilterService != u"com.sun.star.comp.Writer.XmlFilterAdaptor" ) bOk = false; - if( aAdapterService != "com.sun.star.documentconversion.XSLTFilter" ) + if( aAdapterService != u"com.sun.star.documentconversion.XSLTFilter" ) bOk = false; if( pFilter->maExtension.isEmpty() ) diff --git a/filter/source/xsltdialog/xmlfiltercommon.hxx b/filter/source/xsltdialog/xmlfiltercommon.hxx index 0d340fa12e0f..4ac225183e60 100644 --- a/filter/source/xsltdialog/xmlfiltercommon.hxx +++ b/filter/source/xsltdialog/xmlfiltercommon.hxx @@ -30,7 +30,7 @@ extern OUString string_encode( const OUString & rText ); extern OUString string_decode( const OUString & rText ); bool copyStreams( const css::uno::Reference< css::io::XInputStream >& xIS, const css::uno::Reference< css::io::XOutputStream >& xOS ); -bool createDirectory( OUString const & rURL ); +bool createDirectory( std::u16string_view rURL ); class filter_info_impl diff --git a/filter/source/xsltdialog/xmlfilterjar.cxx b/filter/source/xsltdialog/xmlfilterjar.cxx index e3c8d6239a83..2366aa80e825 100644 --- a/filter/source/xsltdialog/xmlfilterjar.cxx +++ b/filter/source/xsltdialog/xmlfilterjar.cxx @@ -109,7 +109,7 @@ static void addFile_( Reference< XInterface > const & xRootFolder, Reference< XS if( xSink.is() && xTunnel.is()) { Reference< XNameContainer > xNameContainer(xRootFolder, UNO_QUERY ); - xNameContainer->insertByName(encodeZipUri( aName ), makeAny(xTunnel)); + xNameContainer->insertByName(encodeZipUri( aName ), Any(xTunnel)); xSink->setInputStream( xInput ); } } @@ -299,7 +299,7 @@ bool XMLFilterJarHelper::copyFiles( const Reference< XHierarchicalNameAccess >& return bOk; } -bool XMLFilterJarHelper::copyFile( const Reference< XHierarchicalNameAccess >& xIfc, OUString& rURL, const OUString& rTargetURL ) +bool XMLFilterJarHelper::copyFile( const Reference< XHierarchicalNameAccess >& xIfc, OUString& rURL, std::u16string_view rTargetURL ) { if( !rURL.matchIgnoreAsciiCase( sVndSunStarPackage ) ) return true; @@ -308,8 +308,8 @@ bool XMLFilterJarHelper::copyFile( const Reference< XHierarchicalNameAccess >& x { OUString szPackagePath( encodeZipUri( rURL.copy( sVndSunStarPackage.getLength() ) ) ); - if ( ::comphelper::OStorageHelper::PathHasSegment( szPackagePath, ".." ) - || ::comphelper::OStorageHelper::PathHasSegment( szPackagePath, "." ) ) + if ( ::comphelper::OStorageHelper::PathHasSegment( szPackagePath, u".." ) + || ::comphelper::OStorageHelper::PathHasSegment( szPackagePath, u"." ) ) throw lang::IllegalArgumentException(); if( xIfc->hasByHierarchicalName( szPackagePath ) ) diff --git a/filter/source/xsltdialog/xmlfilterjar.hxx b/filter/source/xsltdialog/xmlfilterjar.hxx index 1d8e52fc3e18..d634bb6c4d24 100644 --- a/filter/source/xsltdialog/xmlfilterjar.hxx +++ b/filter/source/xsltdialog/xmlfilterjar.hxx @@ -39,7 +39,7 @@ private: /// @throws css::uno::Exception void addFile( css::uno::Reference< css::uno::XInterface > const & xRootFolder, css::uno::Reference< css::lang::XSingleServiceFactory > const & xFactory, const OUString& rSourceFile ); - static bool copyFile( const css::uno::Reference< css::container::XHierarchicalNameAccess >& xIfc, OUString& rURL, const OUString& rTargetURL ); + static bool copyFile( const css::uno::Reference< css::container::XHierarchicalNameAccess >& xIfc, OUString& rURL, std::u16string_view rTargetURL ); bool copyFiles( const css::uno::Reference< css::container::XHierarchicalNameAccess >& xIfc, filter_info_impl* pFilter ); css::uno::Reference< css::uno::XComponentContext > mxContext; diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx index 8a0d901cb6e6..62a8513d72c3 100644 --- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx +++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx @@ -26,6 +26,7 @@ #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <comphelper/propertyvalue.hxx> +#include <o3tl/string_view.hxx> #include <tools/diagnose_ex.h> #include <tools/urlobj.hxx> #include <unotools/pathoptions.hxx> @@ -183,7 +184,7 @@ void XMLFilterSettingsDialog::updateStates() bool bIsDefault = false; if (bHasSelection) { - filter_info_impl* pInfo = reinterpret_cast<filter_info_impl*>(m_xFilterListBox->get_id(aRows[0]).toInt64()); + filter_info_impl* pInfo = weld::fromId<filter_info_impl*>(m_xFilterListBox->get_id(aRows[0])); bIsReadonly = pInfo->mbReadonly; for( auto nFact : o3tl::enumrange<SvtModuleOptions::EFactory>()) @@ -232,7 +233,7 @@ void XMLFilterSettingsDialog::onNew() void XMLFilterSettingsDialog::onEdit() { // get selected filter info - filter_info_impl* pOldInfo = reinterpret_cast<filter_info_impl*>(m_xFilterListBox->get_selected_id().toInt64()); + filter_info_impl* pOldInfo = weld::fromId<filter_info_impl*>(m_xFilterListBox->get_selected_id()); if (!pOldInfo) return; @@ -368,7 +369,7 @@ OUString XMLFilterSettingsDialog::createUniqueInterfaceName( const OUString& rIn { // if yes, make sure we generate a unique name with a higher number // this is dump but fast - sal_Int32 nNumber = aInterfaceName.copy( rInterfaceName.getLength() ).toInt32(); + sal_Int32 nNumber = o3tl::toInt32(aInterfaceName.subView( rInterfaceName.getLength() )); if( nNumber >= nDefaultNumber ) nDefaultNumber = nNumber + 1; } @@ -513,7 +514,7 @@ bool XMLFilterSettingsDialog::insertOrEdit( filter_info_impl* pNewInfo, const fi // 4. insert new or replace existing filter try { - Any aAny( makeAny( aFilterData ) ); + Any aAny( aFilterData ); if( mxFilterContainer->hasByName( pFilterEntry->maFilterName ) ) { mxFilterContainer->replaceByName( pFilterEntry->maFilterName, aAny ); @@ -566,7 +567,7 @@ bool XMLFilterSettingsDialog::insertOrEdit( filter_info_impl* pNewInfo, const fi { try { - Any aAny( makeAny( aValues ) ); + Any aAny( aValues ); if( mxTypeDetection->hasByName( pFilterEntry->maType ) ) { mxTypeDetection->replaceByName( pFilterEntry->maType, aAny ); @@ -676,7 +677,7 @@ bool XMLFilterSettingsDialog::insertOrEdit( filter_info_impl* pNewInfo, const fi aSequenceRange[nIndex].Value <<= aTypes; - mxExtendedTypeDetection->replaceByName( sFilterDetectService, makeAny( aSequence ) ); + mxExtendedTypeDetection->replaceByName( sFilterDetectService, Any( aSequence ) ); Reference< XFlushable > xFlushable( mxExtendedTypeDetection, UNO_QUERY ); if( xFlushable.is() ) @@ -713,7 +714,7 @@ bool XMLFilterSettingsDialog::insertOrEdit( filter_info_impl* pNewInfo, const fi void XMLFilterSettingsDialog::onTest() { // get the first selected filter - filter_info_impl* pInfo = reinterpret_cast<filter_info_impl*>(m_xFilterListBox->get_selected_id().toInt64()); + filter_info_impl* pInfo = weld::fromId<filter_info_impl*>(m_xFilterListBox->get_selected_id()); if (pInfo) { XMLFilterTestDialog aDlg(m_xDialog.get(), mxContext); @@ -726,7 +727,7 @@ void XMLFilterSettingsDialog::onDelete() int nIndex = m_xFilterListBox->get_selected_index(); if (nIndex == -1) return; - filter_info_impl* pInfo = reinterpret_cast<filter_info_impl*>(m_xFilterListBox->get_id(nIndex).toInt64()); + filter_info_impl* pInfo = weld::fromId<filter_info_impl*>(m_xFilterListBox->get_id(nIndex)); if (pInfo) { OUString aMessage(XsltResId(STR_WARN_DELETE)); @@ -821,7 +822,7 @@ void XMLFilterSettingsDialog::onSave() int nFilters = 0; m_xFilterListBox->selected_foreach([&](weld::TreeIter& rEntry){ - filter_info_impl* pInfo = reinterpret_cast<filter_info_impl*>(m_xFilterListBox->get_id(rEntry).toInt64()); + filter_info_impl* pInfo = weld::fromId<filter_info_impl*>(m_xFilterListBox->get_id(rEntry)); aFilters.push_back(pInfo); ++nFilters; return false; @@ -1209,7 +1210,7 @@ OUString getApplicationUIName( std::u16string_view rServiceName ) void XMLFilterSettingsDialog::addFilterEntry( const filter_info_impl* pInfo ) { int nRow = m_xFilterListBox->n_children(); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pInfo))); + OUString sId(weld::toId(pInfo)); m_xFilterListBox->append(sId, pInfo->maFilterName); m_xFilterListBox->set_text(nRow, getEntryString(pInfo), 1); } @@ -1219,7 +1220,7 @@ void XMLFilterSettingsDialog::changeEntry( const filter_info_impl* pInfo ) const int nCount = m_xFilterListBox->n_children(); for(int nPos = 0; nPos < nCount; ++nPos) { - filter_info_impl* pEntry = reinterpret_cast<filter_info_impl*>(m_xFilterListBox->get_id(nPos).toInt64()); + filter_info_impl* pEntry = weld::fromId<filter_info_impl*>(m_xFilterListBox->get_id(nPos)); if (pEntry == pInfo) { m_xFilterListBox->set_text(nPos, pInfo->maFilterName, 0); @@ -1306,26 +1307,12 @@ Sequence< OUString > filter_info_impl::getFilterUserData() const OUString string_encode( const OUString & rText ) { - static sal_Bool const uricNoSlash[] = { - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, true, false, false, true, false, true, true, // !"#$%&' - true, true, true, true, false, true, true, false, // ()*+,-./ - true, true, true, true, true, true, true, true, // 01234567 - true, true, true, false, false, true, false, true, // 89:;<=>? - true, true, true, true, true, true, true, true, // @ABCDEFG - true, true, true, true, true, true, true, true, // HIJKLMNO - true, true, true, true, true, true, true, true, // PQRSTUVW - true, true, true, false, false, false, false, true, // XYZ[\]^_ - false, true, true, true, true, true, true, true, // `abcdefg - true, true, true, true, true, true, true, true, // hijklmno - true, true, true, true, true, true, true, true, // pqrstuvw - true, true, true, false, false, false, true, false}; // xyz{|}~ - - - return Uri::encode( rText, uricNoSlash, rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_UTF8 ); + static constexpr auto uricNoSlash = rtl::createUriCharClass( + u8"!$&'()*+-.0123456789:=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~"); + + + return + Uri::encode( rText, uricNoSlash.data(), rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_UTF8 ); } OUString string_decode( const OUString & rText ) @@ -1370,15 +1357,15 @@ bool copyStreams( const Reference< XInputStream >& xIS, const Reference< XOutput return false; } -bool createDirectory( OUString const & rURL ) +bool createDirectory( std::u16string_view rURL ) { - sal_Int32 nLastIndex = sizeof( "file:///" ) - 2; - while( nLastIndex != -1 ) + size_t nLastIndex = sizeof( "file:///" ) - 2; + while( nLastIndex != std::u16string_view::npos ) { - nLastIndex = rURL.indexOf( '/', nLastIndex + 1); - if( nLastIndex != -1 ) + nLastIndex = rURL.find( '/', nLastIndex + 1); + if( nLastIndex != std::u16string_view::npos ) { - OUString aDirURL( rURL.copy( 0, nLastIndex ) ); + OUString aDirURL( rURL.substr( 0, nLastIndex ) ); Directory aDir( aDirURL ); Directory::RC rc = aDir.open(); if( rc == Directory::E_NOENT ) diff --git a/filter/source/xsltdialog/xmlfiltertestdialog.cxx b/filter/source/xsltdialog/xmlfiltertestdialog.cxx index 6cbea30926fb..ca38ab547c26 100644 --- a/filter/source/xsltdialog/xmlfiltertestdialog.cxx +++ b/filter/source/xsltdialog/xmlfiltertestdialog.cxx @@ -199,7 +199,7 @@ void XMLFilterTestDialog::test( const filter_info_impl& rFilterInfo ) m_xDialog->run(); } -static OUString getFileNameFromURL( OUString const & rURL ) +static OUString getFileNameFromURL( std::u16string_view rURL ) { INetURLObject aURL( rURL ); OUString aName( aURL.getName(INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset) ); @@ -419,14 +419,14 @@ void XMLFilterTestDialog::doExport( const Reference< XComponent >& xComp ) if( xStorable.is() ) { OUString const ext(".xml"); - utl::TempFile aTempFile(OUString(), true, &ext); + utl::TempFile aTempFile(u"", true, &ext); OUString aTempFileURL( aTempFile.GetURL() ); const application_info_impl* pAppInfo = getApplicationInfo( m_xFilterInfo->maExportService ); if( pAppInfo ) { File aOutputFile( aTempFileURL ); - /* File::RC rc = */ aOutputFile.open( osl_File_OpenFlag_Write ); + (void)aOutputFile.open( osl_File_OpenFlag_Write ); // create xslt exporter Reference< XOutputStream > xIS( new comphelper::OSLOutputStreamWrapper( aOutputFile ) ); @@ -579,14 +579,14 @@ void XMLFilterTestDialog::import( const OUString& rURL ) if( m_xCBXDisplaySource->get_active() ) { OUString const ext(".xml"); - TempFile aTempFile(OUString(), true, &ext); + TempFile aTempFile(u"", true, &ext); OUString aTempFileURL( aTempFile.GetURL() ); Reference< XImportFilter > xImporter( mxContext->getServiceManager()->createInstanceWithContext( "com.sun.star.documentconversion.XSLTFilter", mxContext ), UNO_QUERY ); if( xImporter.is() ) { osl::File aInputFile( rURL ); - aInputFile.open( osl_File_OpenFlag_Read ); + (void)aInputFile.open( osl_File_OpenFlag_Read ); Reference< XInputStream > xIS( new comphelper::OSLInputStreamWrapper( aInputFile ) ); @@ -599,7 +599,7 @@ void XMLFilterTestDialog::import( const OUString& rURL ) Reference< XWriter > xWriter = Writer::create( mxContext ); File aOutputFile( aTempFileURL ); - aOutputFile.open( osl_File_OpenFlag_Write ); + (void)aOutputFile.open( osl_File_OpenFlag_Write ); Reference< XOutputStream > xOS( new OSLOutputStreamWrapper( aOutputFile ) ); xWriter->setOutputStream( xOS ); |