22#include <com/sun/star/animations/XTransitionFilter.hpp>
23#include <com/sun/star/container/XEnumerationAccess.hpp>
24#include <com/sun/star/container/XNameAccess.hpp>
25#include <com/sun/star/configuration/theDefaultProvider.hpp>
26#include <com/sun/star/beans/NamedValue.hpp>
27#include <com/sun/star/animations/AnimationNodeType.hpp>
28#include <com/sun/star/animations/TransitionType.hpp>
29#include <com/sun/star/animations/TransitionSubType.hpp>
36#include <officecfg/Office/UI/Effects.hxx>
48using ::com::sun::star::uno::UNO_QUERY_THROW;
49using ::com::sun::star::uno::Any;
50using ::com::sun::star::uno::Sequence;
51using ::com::sun::star::uno::Reference;
52using ::com::sun::star::uno::Exception;
53using ::com::sun::star::lang::XMultiServiceFactory;
54using ::com::sun::star::container::XEnumerationAccess;
55using ::com::sun::star::container::XEnumeration;
56using ::com::sun::star::beans::NamedValue;
63 const Sequence< NamedValue > aUserData( xNode->getUserData() );
64 const NamedValue* pProp = std::find_if(aUserData.begin(), aUserData.end(),
65 [](
const NamedValue& rProp) { return rProp.Name ==
"preset-id"; });
66 if (pProp != aUserData.end())
70 Reference< XEnumerationAccess > xEnumerationAccess( xNode, UNO_QUERY_THROW );
71 Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), css::uno::UNO_SET_THROW );
72 Reference< XTransitionFilter > xTransition( xEnumeration->nextElement(), UNO_QUERY_THROW );
81 Reference< XMultiServiceFactory >
const & xServiceFactory,
82 const OUString& aURL )
86 Reference< container::XNameAccess > xTransitionSets( officecfg::Office::UI::Effects::UserInterface::TransitionSets::get() );
87 Reference< container::XNameAccess > xTransitionGroups( officecfg::Office::UI::Effects::UserInterface::TransitionGroups::get() );
88 Reference< container::XNameAccess > xTransitionVariants( officecfg::Office::UI::Effects::UserInterface::TransitionVariants::get() );
89 Reference< container::XNameAccess > xTransitions( officecfg::Office::UI::Effects::UserInterface::Transitions::get() );
92 Reference< XAnimationNode > xAnimationNode;
94 const std::set<sal_Int16> LOKSupportedTransitionTypes = {
95 TransitionType::BARWIPE,
96 TransitionType::BOXWIPE,
97 TransitionType::FOURBOXWIPE,
98 TransitionType::ELLIPSEWIPE,
99 TransitionType::CLOCKWIPE,
100 TransitionType::PINWHEELWIPE,
101 TransitionType::PUSHWIPE,
102 TransitionType::SLIDEWIPE,
103 TransitionType::FADE,
104 TransitionType::RANDOMBARWIPE,
105 TransitionType::CHECKERBOARDWIPE,
106 TransitionType::DISSOLVE,
107 TransitionType::SNAKEWIPE,
108 TransitionType::PARALLELSNAKESWIPE,
109 TransitionType::IRISWIPE,
110 TransitionType::BARNDOORWIPE,
111 TransitionType::VEEWIPE,
112 TransitionType::ZIGZAGWIPE,
113 TransitionType::BARNZIGZAGWIPE,
114 TransitionType::FANWIPE,
115 TransitionType::SINGLESWEEPWIPE,
116 TransitionType::WATERFALLWIPE,
117 TransitionType::SPIRALWIPE,
118 TransitionType::MISCDIAGONALWIPE,
119 TransitionType::BOXSNAKESWIPE
122 const std::set<sal_Int16> LOKSupportedTransitionSubTypes = {
123 TransitionSubType::DEFAULT,
124 TransitionSubType::LEFTTORIGHT,
125 TransitionSubType::TOPTOBOTTOM,
126 TransitionSubType::CORNERSIN,
127 TransitionSubType::CORNERSOUT,
129 TransitionSubType::HORIZONTAL,
130 TransitionSubType::DOWN,
131 TransitionSubType::CIRCLE,
132 TransitionSubType::CLOCKWISETWELVE,
133 TransitionSubType::CLOCKWISETHREE,
134 TransitionSubType::CLOCKWISESIX,
135 TransitionSubType::CLOCKWISENINE,
136 TransitionSubType::TWOBLADEVERTICAL,
137 TransitionSubType::TWOBLADEHORIZONTAL,
138 TransitionSubType::FOURBLADE,
139 TransitionSubType::FROMLEFT,
140 TransitionSubType::FROMTOP,
141 TransitionSubType::FROMRIGHT,
142 TransitionSubType::FROMBOTTOM,
143 TransitionSubType::CROSSFADE,
144 TransitionSubType::FADETOCOLOR,
145 TransitionSubType::FADEFROMCOLOR,
146 TransitionSubType::FADEOVERCOLOR,
147 TransitionSubType::THREEBLADE,
148 TransitionSubType::EIGHTBLADE,
149 TransitionSubType::ONEBLADE,
150 TransitionSubType::ACROSS,
151 TransitionSubType::TOPLEFTVERTICAL,
152 TransitionSubType::TOPLEFTHORIZONTAL,
153 TransitionSubType::TOPLEFTDIAGONAL,
154 TransitionSubType::TOPRIGHTDIAGONAL,
155 TransitionSubType::BOTTOMRIGHTDIAGONAL,
156 TransitionSubType::BOTTOMLEFTDIAGONAL,
157 TransitionSubType::RECTANGLE,
158 TransitionSubType::DIAMOND,
159 TransitionSubType::TOPLEFT,
160 TransitionSubType::TOPRIGHT,
161 TransitionSubType::BOTTOMRIGHT,
162 TransitionSubType::BOTTOMLEFT,
163 TransitionSubType::TOPCENTER,
164 TransitionSubType::RIGHTCENTER,
165 TransitionSubType::BOTTOMCENTER,
166 TransitionSubType::LEFTCENTER,
167 TransitionSubType::LEFT,
168 TransitionSubType::UP,
169 TransitionSubType::RIGHT,
170 TransitionSubType::DIAGONALBOTTOMLEFT,
171 TransitionSubType::DIAGONALTOPLEFT,
172 TransitionSubType::CENTERTOP,
173 TransitionSubType::CENTERRIGHT,
174 TransitionSubType::TOP,
175 TransitionSubType::BOTTOM,
176 TransitionSubType::CLOCKWISETOP,
177 TransitionSubType::CLOCKWISERIGHT,
178 TransitionSubType::CLOCKWISEBOTTOM,
179 TransitionSubType::CLOCKWISELEFT,
180 TransitionSubType::CLOCKWISETOPLEFT,
181 TransitionSubType::COUNTERCLOCKWISEBOTTOMLEFT,
182 TransitionSubType::CLOCKWISEBOTTOMRIGHT,
183 TransitionSubType::COUNTERCLOCKWISETOPRIGHT,
184 TransitionSubType::VERTICALLEFT,
185 TransitionSubType::VERTICALRIGHT,
186 TransitionSubType::HORIZONTALLEFT,
187 TransitionSubType::HORIZONTALRIGHT,
188 TransitionSubType::TOPLEFTCLOCKWISE,
189 TransitionSubType::TOPRIGHTCLOCKWISE,
190 TransitionSubType::BOTTOMRIGHTCLOCKWISE,
191 TransitionSubType::BOTTOMLEFTCLOCKWISE,
192 TransitionSubType::TOPLEFTCOUNTERCLOCKWISE,
193 TransitionSubType::TOPRIGHTCOUNTERCLOCKWISE,
194 TransitionSubType::BOTTOMRIGHTCOUNTERCLOCKWISE,
195 TransitionSubType::BOTTOMLEFTCOUNTERCLOCKWISE,
196 TransitionSubType::DOUBLEBARNDOOR,
197 TransitionSubType::DOUBLEDIAMOND,
198 TransitionSubType::VERTICALTOPSAME,
199 TransitionSubType::VERTICALBOTTOMSAME,
200 TransitionSubType::VERTICALTOPLEFTOPPOSITE,
201 TransitionSubType::VERTICALBOTTOMLEFTOPPOSITE,
202 TransitionSubType::HORIZONTALLEFTSAME,
203 TransitionSubType::HORIZONTALRIGHTSAME,
204 TransitionSubType::HORIZONTALTOPLEFTOPPOSITE,
205 TransitionSubType::HORIZONTALTOPRIGHTOPPOSITE,
206 TransitionSubType::DIAGONALBOTTOMLEFTOPPOSITE,
207 TransitionSubType::DIAGONALTOPLEFTOPPOSITE,
208 TransitionSubType::TWOBOXTOP,
209 TransitionSubType::TWOBOXBOTTOM,
210 TransitionSubType::TWOBOXLEFT,
211 TransitionSubType::TWOBOXRIGHT,
212 TransitionSubType::FOURBOXVERTICAL,
213 TransitionSubType::FOURBOXHORIZONTAL
218 Reference< XEnumerationAccess > xEnumerationAccess( xAnimationNode, UNO_QUERY_THROW );
219 Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), css::uno::UNO_SET_THROW );
221 while( xEnumeration->hasMoreElements() )
223 Reference< XAnimationNode > xChildNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
224 if( xChildNode->getType() == AnimationNodeType::PAR )
230 sal_Int16 eTransitionType = pPreset->getTransition();
231 sal_Int16 eTransitionSubType = pPreset->getSubtype();
232 if( LOKSupportedTransitionTypes.find(eTransitionType) == LOKSupportedTransitionTypes.end()
233 || LOKSupportedTransitionSubTypes.find(eTransitionSubType) == LOKSupportedTransitionSubTypes.end() )
239 OUString aPresetId( pPreset->getPresetId() );
241 if( !aPresetId.isEmpty() )
243 Reference< container::XNameAccess > xTransitionNode;
245 if (xTransitions->hasByName( aPresetId ) &&
246 (xTransitions->getByName( aPresetId ) >>= xTransitionNode) &&
247 xTransitionNode.is() )
252 xTransitionNode->getByName(
"Set" ) >>= sSet;
253 xTransitionNode->getByName(
"Variant" ) >>= sVariant;
255 Reference< container::XNameAccess > xSetNode;
257 xTransitionSets->getByName( sSet ) >>= xSetNode;
260 pPreset->maSetId = sSet;
261 xSetNode->getByName(
"Label" ) >>= sSet;
262 pPreset->maSetLabel = sSet;
266 xSetNode->getByName(
"Group" ) >>= sGroup;
268 Reference< container::XNameAccess > xGroupNode;
269 xTransitionGroups->getByName( sGroup ) >>= xGroupNode;
271 if( xGroupNode.is() )
273 xGroupNode->getByName(
"Label" ) >>= sGroup;
274 if( !sVariant.isEmpty() )
276 Reference< container::XNameAccess > xVariantNode;
277 xTransitionVariants->getByName( sVariant ) >>= xVariantNode;
278 if( xVariantNode.is() )
280 xVariantNode->getByName(
"Label" ) >>= sVariant;
281 pPreset->maVariantLabel = sVariant;
285 pPreset->maSetLabel = sSet;
286 SAL_INFO(
"sd.transitions", aPresetId <<
": " << sGroup <<
"/" << sSet << (sVariant.isEmpty() ? OUString() : OUString(
"/" + sVariant)));
288 rList.push_back( pPreset );
291 SAL_WARN(
"sd.transitions",
"group node " << sGroup <<
" not found");
294 SAL_WARN(
"sd.transitions",
"set node " << sSet <<
" not found");
297 SAL_WARN(
"sd.transitions",
"transition node " << aPresetId <<
" not found");
302 SAL_WARN(
"sd.transitions",
" malformed xml configuration file " <<
aURL );
322 uno::Reference< uno::XComponentContext > xContext(
324 Reference< XMultiServiceFactory > xServiceFactory(
325 xContext->getServiceManager(), UNO_QUERY_THROW );
328 Reference< XMultiServiceFactory > xConfigProvider =
329 configuration::theDefaultProvider::get( xContext );
334 {
"nodepath",
uno::Any(OUString(
"/org.openoffice.Office.Impress/Misc"))}
336 Reference<container::XNameAccess> xNameAccess(
337 xConfigProvider->createInstanceWithArguments(
338 "com.sun.star.configuration.ConfigurationAccess",
341 uno::Sequence< OUString > aFiles;
342 xNameAccess->getByName(
"TransitionFiles") >>= aFiles;
344 for(
const auto& rFile : std::as_const(aFiles) )
const OUString & getBcp47(bool bResolveSystem=true) const
LanguageTag GetLanguageTag() const
TransitionPreset(const css::uno::Reference< css::animations::XAnimationNode > &xNode)
static std::map< OUString, TransitionPresetList > mPresetsMap
static bool importTransitionPresetList(TransitionPresetList &rList)
static const TransitionPresetList & getTransitionPresetList()
static bool importTransitionsFile(TransitionPresetList &rList, css::uno::Reference< css::lang::XMultiServiceFactory > const &xServiceFactory, const OUString &aFilename)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
const LanguageTag & getLanguageTag()
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()
Reference< XAnimationNode > implImportEffects(const Reference< XMultiServiceFactory > &xServiceFactory, const OUString &rPath)
std::vector< TransitionPresetPtr > TransitionPresetList
std::shared_ptr< TransitionPreset > TransitionPresetPtr