22#include <com/sun/star/util/XCloneable.hpp>
23#include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
24#include <com/sun/star/container/XNameAccess.hpp>
25#include <com/sun/star/configuration/theDefaultProvider.hpp>
26#include <com/sun/star/xml/sax/InputSource.hpp>
27#include <com/sun/star/xml/sax/XFastParser.hpp>
28#include <com/sun/star/presentation/EffectPresetClass.hpp>
29#include <com/sun/star/beans/NamedValue.hpp>
53using ::com::sun::star::io::XInputStream;
54using ::com::sun::star::lang::XMultiServiceFactory;
55using ::com::sun::star::container::XNameAccess;
56using ::com::sun::star::util::XCloneable;
57using ::com::sun::star::beans::NamedValue;
61static Reference< XNameAccess >
getNodeAccess(
const Reference< XMultiServiceFactory >& xConfigProvider,
const OUString& rNodePath )
63 Reference< XNameAccess > xConfigAccess;
73 xConfigProvider->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationAccess", aArgs ),
88 Reference< XNameAccess > xConfigAccess(
getNodeAccess( xConfigProvider, rNodePath ) );
89 if( xConfigAccess.is() )
91 Reference< XNameAccess > xNameAccess;
92 const Sequence< OUString > aNames( xConfigAccess->getElementNames() );
93 for(
const OUString& rName : aNames)
95 xConfigAccess->getByName( rName ) >>= xNameAccess;
96 if( xNameAccess.is() )
99 xNameAccess->getByName(
"Label" ) >>=
aUIName;
124 const Sequence< NamedValue > aUserData( pEffect->getNode()->getUserData() );
126 mbIsTextOnly = std::any_of(aUserData.begin(), aUserData.end(),
127 [](
const NamedValue& rProp) { return rProp.Name ==
"text-only"; });
132 maSubTypes[ pEffect->getPresetSubType() ] = pEffect;
137 std::vector<OUString> aSubTypes;
142 [](EffectsSubTypeMap::value_type& rEntry) -> OUString { return rEntry.first; });
152 OUString strSubType( rstrSubType );
153 if( strSubType.isEmpty() )
159 Reference< XCloneable > xCloneable( pEffect->getNode(), UNO_QUERY_THROW );
160 Reference< XAnimationNode > xNode( xCloneable->createClone(), UNO_QUERY_THROW );
169 Reference< XAnimationNode > xNode;
175 std::vector<OUString> aPropertyList;
185 return aPropertyList;
212Reference< XAnimationNode >
implImportEffects(
const Reference< XMultiServiceFactory >& xServiceFactory,
const OUString& rPath )
214 Reference< XAnimationNode > xRootNode;
223 xml::sax::InputSource aParserInput;
224 aParserInput.sSystemId = rPath;
225 aParserInput.aInputStream = xInputStream;
228 Reference< xml::sax::XFastParser > xFilter( xServiceFactory->createInstance(
"com.sun.star.comp.Xmloff.AnimationsImport" ), UNO_QUERY_THROW );
230 xFilter->parseStream( aParserInput );
232 Reference< XAnimationNodeSupplier > xAnimationNodeSupplier( xFilter, UNO_QUERY_THROW );
233 xRootNode = xAnimationNodeSupplier->getAnimationNode();
247 uno::Reference< uno::XComponentContext > xContext(
249 Reference< XMultiServiceFactory > xServiceFactory(
250 xContext->getServiceManager(), UNO_QUERY_THROW );
252 Reference< XMultiServiceFactory > xConfigProvider =
253 configuration::theDefaultProvider::get( xContext );
258 {
"nodepath",
uno::Any(OUString(
"/org.openoffice.Office.Impress/Misc"))}
260 Reference<container::XNameAccess> xNameAccess(
261 xConfigProvider->createInstanceWithArguments(
262 "com.sun.star.configuration.ConfigurationAccess",
263 aArgs ), UNO_QUERY_THROW );
264 uno::Sequence< OUString > aFiles;
265 xNameAccess->getByName(
"EffectFiles" ) >>= aFiles;
267 for(
const auto& rFile : std::as_const(aFiles) )
275 Reference< XTimeContainer > xRootContainer(
mxRootNode, UNO_QUERY_THROW );
278 EffectSequence::iterator aIter( aSequence.
getBegin() );
279 const EffectSequence::iterator aEnd( aSequence.
getEnd() );
281 while( aIter != aEnd )
285 const OUString aPresetId( pEffect->getPresetId() );
288 pDescriptor->add( pEffect );
291 pDescriptor = std::make_shared<CustomAnimationPreset>( pEffect );
314 Reference< XMultiServiceFactory > xConfigProvider =
315 configuration::theDefaultProvider::get( xContext );
342 OUString aMissedPresetIds;
347 Reference< XNameAccess > xTypeAccess(
getNodeAccess( xConfigProvider, rNodePath ) );
348 if( xTypeAccess.is() )
350 Reference< XNameAccess > xCategoryAccess;
352 const Sequence< OUString > aNames( xTypeAccess->getElementNames() );
353 for(
const OUString& rName : aNames)
355 xTypeAccess->getByName( rName ) >>= xCategoryAccess;
357 if( xCategoryAccess.is() && xCategoryAccess->hasByName(
"Label" ) && xCategoryAccess->hasByName(
"Effects" ) )
360 xCategoryAccess->getByName(
"Label" ) >>=
aLabel;
362 Sequence< OUString > aEffects;
363 xCategoryAccess->getByName(
"Effects" ) >>= aEffects;
367 for(
const OUString& rEffectName : std::as_const(aEffects) )
372 aEffectsList.push_back( pEffect );
377 aMissedPresetIds += OUString(rEffectName);
378 aMissedPresetIds +=
"\n";
382 rPresetMap.push_back( std::make_shared<PresetCategory>(
aLabel, std::move(aEffectsList) ) );
393 SAL_WARN_IF(!aMissedPresetIds.isEmpty(),
"sd",
"sd::CustomAnimationPresets::importPresets(), invalid preset id: "
394 << aMissedPresetIds);
404 return (*aIter).second;
424 UStringMap::const_iterator aIter( rNameMap.find( rId ) );
426 if( aIter != rNameMap.end() )
428 return (*aIter).second;
437 if( pEffect && pEffect->getPresetSubType() != rPresetSubType )
443 Reference< XAnimationNode > xNewNode( pDescriptor->create( rPresetSubType ) );
445 pEffect->replaceNode( xNewNode );
472 Reference< XAnimationNode > xNode;
475 switch( nPresetClass )
478 case EffectPresetClass::EXIT: pCategoryList = &
maExitPresets;
break;
482 pCategoryList =
nullptr;
485 if( pCategoryList && !pCategoryList->empty() )
490 if( pCategory && !pCategory->maEffects.empty() )
496 std::vector<OUString> aSubTypes = pPreset->getSubTypes();
499 if( !aSubTypes.empty() )
502 aSubType = aSubTypes[nSubType];
504 xNode = pPreset->create( aSubType );
const OUString & getBcp47(bool bResolveSystem=true) const
LanguageTag GetLanguageTag() const
std::vector< OUString > getSubTypes()
CustomAnimationPreset(const CustomAnimationEffectPtr &pEffect)
std::vector< OUString > getProperties() const
EffectsSubTypeMap maSubTypes
SD_DLLPUBLIC css::uno::Reference< css::animations::XAnimationNode > create(const OUString &rstrSubType)
bool hasProperty(std::u16string_view rProperty) const
void add(const CustomAnimationEffectPtr &pEffect)
SAL_DLLPRIVATE void importEffects()
SAL_DLLPRIVATE ~CustomAnimationPresets()
static SAL_DLLPRIVATE std::map< OUString, CustomAnimationPresets > mPresetsMap
Maps per-language the animation presets.
UStringMap maPropertyNameMap
SAL_DLLPRIVATE void changePresetSubType(const CustomAnimationEffectPtr &pEffect, const OUString &rPresetSubType) const
PresetCategoryList maMotionPathsPresets
SAL_DLLPRIVATE CustomAnimationPresets()
SAL_DLLPRIVATE void importResources()
static SAL_DLLPRIVATE const OUString & translateName(const OUString &rId, const UStringMap &rNameMap)
css::uno::Reference< css::animations::XAnimationNode > mxRootNode
PresetCategoryList maExitPresets
CustomAnimationPresetPtr getEffectDescriptor(const OUString &rPresetId) const
SAL_DLLPRIVATE const OUString & getUINameForPresetId(const OUString &rPresetId) const
EffectDescriptorMap maEffectDescriptorMap
SAL_DLLPRIVATE void importPresets(const css::uno::Reference< css::lang::XMultiServiceFactory > &xConfigProvider, const OUString &rNodePath, PresetCategoryList &rPresetMap)
PresetCategoryList maEmphasisPresets
UStringMap maEffectNameMap
PresetCategoryList maMiscPresets
static const CustomAnimationPresets & getCustomAnimationPresets()
This method gets presets instance, which is localized for the current user's locale.
SAL_DLLPRIVATE const OUString & getUINameForProperty(const OUString &rProperty) const
SAL_DLLPRIVATE css::uno::Reference< css::animations::XAnimationNode > getRandomPreset(sal_Int16 nPresetClass) const
PresetCategoryList maEntrancePresets
SAL_DLLPRIVATE EffectSequence::iterator getEnd()
SAL_DLLPRIVATE EffectSequence::iterator getBegin()
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define SAL_WARN_IF(condition, area, stream)
const LanguageTag & getLanguageTag()
size_t uniform_size_distribution(size_t a, size_t b)
COMPHELPER_DLLPUBLIC OUString getExpandedUri(css::uno::Reference< css::uno::XComponentContext > const &context, OUString const &uri)
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
Reference< XComponentContext > getProcessComponentContext()
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
void implImportLabels(const Reference< XMultiServiceFactory > &xConfigProvider, const OUString &rNodePath, UStringMap &rStringMap)
std::vector< PresetCategoryPtr > PresetCategoryList
std::shared_ptr< CustomAnimationPreset > CustomAnimationPresetPtr
Reference< XAnimationNode > implImportEffects(const Reference< XMultiServiceFactory > &xServiceFactory, const OUString &rPath)
std::unordered_map< OUString, OUString > UStringMap
std::shared_ptr< CustomAnimationEffect > CustomAnimationEffectPtr
std::shared_ptr< PresetCategory > PresetCategoryPtr
static Reference< XNameAccess > getNodeAccess(const Reference< XMultiServiceFactory > &xConfigProvider, const OUString &rNodePath)
std::vector< CustomAnimationPresetPtr > EffectDescriptorList