Kaydet (Commit) b8183958 authored tarafından Marcos Paulo de Souza's avatar Marcos Paulo de Souza Kaydeden (comit) Matúš Kukan

fdo#60698: Split out slideshow code from animations

Also remove the TargetPropertiesCreator service since just slideshow uses this.

Change-Id: I80816f6225b7bd9fb18f48e69eb5dfd6709b6e56
üst 1349f49a
......@@ -35,7 +35,6 @@ $(eval $(call gb_Library_use_libraries,animcore,\
$(eval $(call gb_Library_add_exception_objects,animcore,\
animations/source/animcore/animcore \
animations/source/animcore/factreg \
animations/source/animcore/targetpropertiescreator \
))
# vim: set noet sw=4 ts=4:
......@@ -49,9 +49,6 @@
<implementation name="animcore::SequenceTimeContainer">
<service name="com.sun.star.animations.SequenceTimeContainer"/>
</implementation>
<implementation name="animcore::TargetPropertiesCreator">
<service name="com.sun.star.animations.TargetPropertiesCreator"/>
</implementation>
<implementation name="animcore::TransitionFilter">
<service name="com.sun.star.animations.TransitionFilter"/>
</implementation>
......
......@@ -53,7 +53,6 @@ static const struct ImplementationEntry g_entries[] =
IMPLEMENTATION_ENTRY( TRANSITIONFILTER ),
IMPLEMENTATION_ENTRY( AUDIO ),
IMPLEMENTATION_ENTRY( COMMAND ),
IMPLEMENTATION_ENTRY( TargetPropertiesCreator ),
{ 0, 0, 0, 0, 0, 0 }
};
......
......@@ -38,7 +38,6 @@ DECL_NODE_FACTORY( ANIMATETRANSFORM );
DECL_NODE_FACTORY( TRANSITIONFILTER );
DECL_NODE_FACTORY( AUDIO );
DECL_NODE_FACTORY( COMMAND );
DECL_NODE_FACTORY( TargetPropertiesCreator );
}
......
......@@ -36,50 +36,6 @@ namespace anim
// only a function pointer, and a thin templated wrapper around
// that which converts member functions into that.
/** Apply given functor to every animation node child.
@param xNode
Parent node
@param rFunctor
Functor to apply. The functor must have an appropriate
operator()( const ::com::sun::star::uno::Reference<
::com::sun::star::animations::XAnimationNode >& ) member.
@return true, if the functor was successfully applied to
all children, false otherwise.
*/
template< typename Functor > inline bool for_each_childNode( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode,
Functor& rFunctor )
{
try
{
// get an XEnumerationAccess to the children
::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess >
xEnumerationAccess( xNode,
::com::sun::star::uno::UNO_QUERY_THROW );
::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration >
xEnumeration( xEnumerationAccess->createEnumeration(),
::com::sun::star::uno::UNO_QUERY_THROW );
while( xEnumeration->hasMoreElements() )
{
::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >
xChildNode( xEnumeration->nextElement(),
::com::sun::star::uno::UNO_QUERY_THROW );
rFunctor( xChildNode );
}
return true;
}
catch( ::com::sun::star::uno::Exception& )
{
return false;
}
}
/** pushes the given node to the given vector and recursivly calls itself for each child node.
*/
inline void create_deep_vector( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode,
......
......@@ -35,7 +35,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/animations,\
IterateContainer \
ParallelTimeContainer \
SequenceTimeContainer \
TargetPropertiesCreator \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/auth,\
SSOManagerFactory \
......@@ -1681,7 +1680,6 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/animations,\
XCommand \
XIterateContainer \
XParallelTimeContainer \
XTargetPropertiesCreator \
XTimeContainer \
XTransitionFilter \
))
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 .
*/
#ifndef __com_sun_star_animations_XTargetPropertiesCreator_idl__
#define __com_sun_star_animations_XTargetPropertiesCreator_idl__
#include <com/sun/star/animations/TargetProperties.idl>
#include <com/sun/star/animations/XAnimationNode.idl>
module com { module sun { module star { module animations {
/** Factory interface to generate properties for all animated targets.<p>
Depending on mode and content of a SMIL animation tree, animation
targets can have global properties different from the target's
default. The most prominent example for such a difference is shape
visibility: when a shape is to become visible in the course of a
SMIL animation, it naturally has to be initially invisible for
that effect to have any visible impact.<p>
This factory interface is able to generate sequences of global
properties for all targets referenced in a given SMIL animation
tree.
*/
interface XTargetPropertiesCreator : ::com::sun::star::uno::XInterface
{
/** Determine a sequence of global target properties.<p>
This method generates a sequence of TargetProperties in effect
before the given SMIL animations start. These properties
should be applied to the given animation targets, to achieve
correct playback of the SMIL animations.<p>
@param rootNode
Root node of the SMIL animation tree.
*/
sequence< TargetProperties > createInitialTargetProperties( [in] XAnimationNode rootNode );
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -108,6 +108,7 @@ $(eval $(call gb_Library_add_exception_objects,slideshow,\
slideshow/source/engine/slideshowimpl \
slideshow/source/engine/slide/slideanimations \
slideshow/source/engine/slide/slideimpl \
slideshow/source/engine/slide/targetpropertiescreator \
slideshow/source/engine/slide/userpaintoverlay \
slideshow/source/engine/slideview \
slideshow/source/engine/smilfunctionparser \
......
......@@ -78,7 +78,6 @@
#include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
#include <com/sun/star/animations/XAudio.hpp>
#include <com/sun/star/animations/XIterateContainer.hpp>
#include <com/sun/star/animations/XTargetPropertiesCreator.hpp>
#include <com/sun/star/animations/XTransitionFilter.hpp>
#include <com/sun/star/awt/FontSlant.hpp>
#include <com/sun/star/awt/FontUnderline.hpp>
......
......@@ -38,7 +38,6 @@
#include <com/sun/star/animations/XAudio.hpp>
#include <com/sun/star/presentation/ParagraphTarget.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <animations/animationnodehelper.hxx>
#include <basegfx/numeric/ftools.hxx>
#include "animationnodefactory.hxx"
......@@ -309,8 +308,7 @@ bool implCreateIteratedNodes(
// ONLY_TEXT, if a paragraph is referenced as the
// master of an iteration effect.
NodeCreator aCreator( rParent, aContext );
if( !::anim::for_each_childNode( xNode,
aCreator ) )
if( !for_each_childNode( xNode, aCreator ) )
{
ENSURE_OR_RETURN_FALSE(
false,
......@@ -431,8 +429,7 @@ bool implCreateIteratedNodes(
}
CloningNodeCreator aCreator( rParent, aContext );
if( !::anim::for_each_childNode( xNode,
aCreator ) )
if( !for_each_childNode( xNode, aCreator ) )
{
ENSURE_OR_RETURN_FALSE(
false, "implCreateIteratedNodes(): "
......@@ -565,7 +562,7 @@ BaseNodeSharedPtr implCreateAnimationNode(
{
// no iterate subset node, just plain child generation now
NodeCreator aCreator( pCreatedContainer, rContext );
if( !::anim::for_each_childNode( xNode, aCreator ) )
if( !for_each_childNode( xNode, aCreator ) )
{
OSL_FAIL( "implCreateAnimationNode(): "
"child node creation failed" );
......
......@@ -39,11 +39,8 @@
#include <com/sun/star/presentation/ParagraphTarget.hpp>
#include <com/sun/star/presentation/EffectNodeType.hpp>
#include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
#include <com/sun/star/animations/XTargetPropertiesCreator.hpp>
#include <com/sun/star/drawing/TextAnimationKind.hpp>
#include <animations/animationnodehelper.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <comphelper/anytostring.hxx>
......@@ -62,6 +59,7 @@
#include "usereventqueue.hxx"
#include "userpaintoverlay.hxx"
#include "event.hxx"
#include "targetpropertiescreator.hxx"
#include "tools.hxx"
#include <o3tl/compat_functional.hxx>
......@@ -849,7 +847,7 @@ bool SlideImpl::implPrefetchShow()
// don't block nextEvent() from issuing the next
// slide)
MainSequenceSearcher aSearcher;
if( ::anim::for_each_childNode( mxRootNode, aSearcher ) )
if( for_each_childNode( mxRootNode, aSearcher ) )
mbMainSequenceFound = aSearcher.getMainSequence().is();
// import successfully done
......@@ -966,44 +964,8 @@ bool SlideImpl::applyInitialShapeAttributes(
// succeeded
}
uno::Reference< animations::XTargetPropertiesCreator > xPropsCreator;
try
{
ENSURE_OR_RETURN_FALSE( maContext.mxComponentContext.is(),
"SlideImpl::applyInitialShapeAttributes(): Invalid component context" );
uno::Reference<lang::XMultiComponentFactory> xFac(
maContext.mxComponentContext->getServiceManager() );
xPropsCreator.set(
xFac->createInstanceWithContext(
OUString(
"com.sun.star.animations.TargetPropertiesCreator"),
maContext.mxComponentContext ),
uno::UNO_QUERY_THROW );
}
catch( uno::RuntimeException& )
{
throw;
}
catch( uno::Exception& )
{
OSL_FAIL(
OUStringToOString(
comphelper::anyToString(cppu::getCaughtException()),
RTL_TEXTENCODING_UTF8).getStr() );
// could not determine initial shape attributes - this
// is an error, as some effects might then be plainly
// invisible
ENSURE_OR_RETURN_FALSE( false,
"SlideImpl::applyInitialShapeAttributes(): "
"couldn't create TargetPropertiesCreator." );
}
uno::Sequence< animations::TargetProperties > aProps(
xPropsCreator->createInitialTargetProperties( xRootAnimationNode ) );
TargetPropertiesCreator::createInitialTargetProperties( xRootAnimationNode ) );
// apply extracted values to our shapes
const ::std::size_t nSize( aProps.getLength() );
......
......@@ -18,93 +18,24 @@
*/
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp>
#include <com/sun/star/animations/XTargetPropertiesCreator.hpp>
#include <com/sun/star/animations/XIterateContainer.hpp>
#include <com/sun/star/animations/TargetProperties.hpp>
#include <com/sun/star/presentation/ParagraphTarget.hpp>
#include <com/sun/star/registry/XRegistryKey.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceName.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/animations/AnimationNodeType.hpp>
#include <com/sun/star/animations/XAnimate.hpp>
#include <animations/animationnodehelper.hxx>
#include <boost/unordered_map.hpp>
#include <cppuhelper/compbase3.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implementationentry.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/broadcasthelper.hxx>
#include <comphelper/sequence.hxx>
#include <vector>
#include "targetpropertiescreator.hxx"
#include "tools.hxx"
using namespace ::com::sun::star;
#define IMPLEMENTATION_NAME "animcore::TargetPropertiesCreator"
#define SERVICE_NAME "com.sun.star.animations.TargetPropertiesCreator"
namespace animcore
namespace slideshow
{
namespace internal
{
typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::animations::XTargetPropertiesCreator,
lang::XServiceInfo,
lang::XServiceName > TargetPropertiesCreator_Base;
class TargetPropertiesCreator : public ::comphelper::OBaseMutex,
public TargetPropertiesCreator_Base
{
public:
static uno::Reference< uno::XInterface > SAL_CALL createInstance( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::Exception )
{
return uno::Reference< uno::XInterface >( static_cast<cppu::OWeakObject*>(new TargetPropertiesCreator( xContext )) );
}
/// Dispose all internal references
virtual void SAL_CALL disposing();
// XTargetPropertiesCreator
virtual uno::Sequence< animations::TargetProperties > SAL_CALL createInitialTargetProperties( const uno::Reference< animations::XAnimationNode >& rootNode ) throw (uno::RuntimeException, std::exception);
// XServiceInfo
virtual OUString SAL_CALL getImplementationName() throw( uno::RuntimeException, std::exception );
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException, std::exception );
virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( uno::RuntimeException, std::exception );
// XServiceName
virtual OUString SAL_CALL getServiceName( ) throw (uno::RuntimeException, std::exception);
protected:
~TargetPropertiesCreator(); // we're a ref-counted UNO class. _We_ destroy ourselves.
private:
// default: disabled copy/assignment
TargetPropertiesCreator(const TargetPropertiesCreator&);
TargetPropertiesCreator& operator=( const TargetPropertiesCreator& );
TargetPropertiesCreator( const uno::Reference< uno::XComponentContext >& rxContext );
};
uno::Reference< uno::XInterface > SAL_CALL createInstance_TargetPropertiesCreator( const uno::Reference< uno::XComponentContext > & rSMgr ) throw (uno::Exception)
{
return TargetPropertiesCreator::createInstance( rSMgr );
}
OUString getImplementationName_TargetPropertiesCreator()
{
return OUString( IMPLEMENTATION_NAME );
}
uno::Sequence< OUString > getSupportedServiceNames_TargetPropertiesCreator(void)
{
uno::Sequence< OUString > aRet(1);
aRet.getArray()[0] = SERVICE_NAME;
return aRet;
}
namespace
{
// Vector containing all properties for a given shape
......@@ -241,8 +172,7 @@ namespace animcore
NodeFunctor aFunctor( mrShapeHash,
xTargetShape,
nParagraphIndex );
if( !::anim::for_each_childNode( xNode,
aFunctor ) )
if( !for_each_childNode( xNode, aFunctor ) )
{
OSL_FAIL( "AnimCore: NodeFunctor::operator(): child node iteration failed, "
"or extraneous container nodes encountered" );
......@@ -356,18 +286,10 @@ namespace animcore
}
}
}
/*if( bVisible )
{
// target is set to 'visible' at the
// first relevant effect. Thus, target
// must be initially _hidden_, for the
// effect to have visible impact.
*/
}
// target is set the 'visible' value,
// so we should record the opposite value
mrShapeHash.insert(
}
// target is set the 'visible' value,
// so we should record the opposite value
mrShapeHash.insert(
XShapeHash::value_type(
aTarget,
VectorOfNamedValues(
......@@ -376,10 +298,8 @@ namespace animcore
//xAnimateNode->getAttributeName(),
OUString("visibility"),
uno::makeAny( !bVisible ) ) ) ) );
//}
//}
}
break;
}
}
}
......@@ -390,28 +310,11 @@ namespace animcore
};
}
TargetPropertiesCreator::TargetPropertiesCreator( const uno::Reference< uno::XComponentContext >& ) :
TargetPropertiesCreator_Base( m_aMutex )
{
}
TargetPropertiesCreator::~TargetPropertiesCreator()
{
}
void SAL_CALL TargetPropertiesCreator::disposing()
{
::osl::MutexGuard aGuard( m_aMutex );
}
// XTargetPropertiesCreator
uno::Sequence< animations::TargetProperties > SAL_CALL TargetPropertiesCreator::createInitialTargetProperties
(
const uno::Reference< animations::XAnimationNode >& xRootNode
) throw (uno::RuntimeException, std::exception)
) //throw (uno::RuntimeException, std::exception)
{
::osl::MutexGuard aGuard( m_aMutex );
// scan all nodes for visibility changes, and record first
// 'visibility=true' for each shape
XShapeHash aShapeHash( 101 );
......@@ -456,31 +359,7 @@ namespace animcore
return aRes;
}
// XServiceInfo
OUString SAL_CALL TargetPropertiesCreator::getImplementationName() throw( uno::RuntimeException, std::exception )
{
return OUString( IMPLEMENTATION_NAME );
}
sal_Bool SAL_CALL TargetPropertiesCreator::supportsService( const OUString& ServiceName ) throw( uno::RuntimeException, std::exception )
{
return cppu::supportsService(this, ServiceName);
}
uno::Sequence< OUString > SAL_CALL TargetPropertiesCreator::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
{
uno::Sequence< OUString > aRet(1);
aRet[0] = SERVICE_NAME;
return aRet;
}
// XServiceName
OUString SAL_CALL TargetPropertiesCreator::getServiceName( ) throw (uno::RuntimeException, std::exception)
{
return OUString( SERVICE_NAME );
}
} // namespace animcore
} // namespace internal
} // namespace slideshow
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -17,19 +17,31 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef __com_sun_star_animations_TargetPropertiesCreator_idl__
#define __com_sun_star_animations_TargetPropertiesCreator_idl__
#include <com/sun/star/animations/XTargetPropertiesCreator.idl>
module com { module sun { module star { module animations {
service TargetPropertiesCreator: XTargetPropertiesCreator;
}; }; }; };
#endif
#include <com/sun/star/animations/TargetProperties.hpp>
#include <comphelper/broadcasthelper.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implementationentry.hxx>
#include <comphelper/sequence.hxx>
using namespace ::com::sun::star;
namespace slideshow
{
namespace internal
{
class TargetPropertiesCreator : public ::comphelper::OBaseMutex
{
public:
static uno::Sequence< animations::TargetProperties > SAL_CALL createInitialTargetProperties( const uno::Reference< animations::XAnimationNode >& rootNode );
private:
// default: disabled copy/assignment
TargetPropertiesCreator(const TargetPropertiesCreator&);
TargetPropertiesCreator& operator=( const TargetPropertiesCreator& );
};
} // namespace internal
} // namespace slideshow
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -22,6 +22,12 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/animations/XAnimationNode.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/container/XEnumeration.hpp>
#include <vector>
#include <cppcanvas/color.hxx>
......@@ -38,8 +44,6 @@
#include <string.h>
#include <algorithm>
namespace com { namespace sun { namespace star { namespace beans {
struct NamedValue;
} } } }
......@@ -388,6 +392,52 @@ namespace slideshow
basegfx::B2IVector getSlideSizePixel( const basegfx::B2DVector& rSize,
const boost::shared_ptr<UnoView>& pView );
}
// TODO(Q1): this could possibly be implemented with a somewhat
// more lightweight template, by having the actual worker receive
// only a function pointer, and a thin templated wrapper around
// that which converts member functions into that.
/** Apply given functor to every animation node child.
@param xNode
Parent node
@param rFunctor
Functor to apply. The functor must have an appropriate
operator()( const ::com::sun::star::uno::Reference<
::com::sun::star::animations::XAnimationNode >& ) member.
@return true, if the functor was successfully applied to
all children, false otherwise.
*/
template< typename Functor > inline bool for_each_childNode( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode,
Functor& rFunctor )
{
try
{
// get an XEnumerationAccess to the children
::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess >
xEnumerationAccess( xNode,
::com::sun::star::uno::UNO_QUERY_THROW );
::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration >
xEnumeration( xEnumerationAccess->createEnumeration(),
::com::sun::star::uno::UNO_QUERY_THROW );
while( xEnumeration->hasMoreElements() )
{
::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >
xChildNode( xEnumeration->nextElement(),
::com::sun::star::uno::UNO_QUERY_THROW );
rFunctor( xChildNode );
}
return true;
}
catch( ::com::sun::star::uno::Exception& )
{
return false;
}
}
}
#endif /* INCLUDED_SLIDESHOW_TOOLS_HXX */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment