summaryrefslogtreecommitdiff
path: root/animations
diff options
context:
space:
mode:
authorMarcos Paulo de Souza <marcos.souza.org@gmail.com>2014-02-28 02:22:12 -0300
committerMatúš Kukan <matus.kukan@collabora.com>2014-03-10 09:15:54 +0100
commitb8183958e6b5367eeebd5d07fa5f26561fa1dc4a (patch)
tree09260dc7a6255394f5eb4f31d84c8027d7f519ca /animations
parent1349f49a72be947aa708e7bcbc7de773894c5684 (diff)
fdo#60698: Split out slideshow code from animations
Also remove the TargetPropertiesCreator service since just slideshow uses this. Change-Id: I80816f6225b7bd9fb18f48e69eb5dfd6709b6e56
Diffstat (limited to 'animations')
-rw-r--r--animations/Library_animcore.mk1
-rw-r--r--animations/source/animcore/animcore.component3
-rw-r--r--animations/source/animcore/factreg.cxx1
-rw-r--r--animations/source/animcore/factreg.hxx1
-rw-r--r--animations/source/animcore/targetpropertiescreator.cxx486
5 files changed, 0 insertions, 492 deletions
diff --git a/animations/Library_animcore.mk b/animations/Library_animcore.mk
index 4cfca5440b87..2f08ae32c036 100644
--- a/animations/Library_animcore.mk
+++ b/animations/Library_animcore.mk
@@ -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:
diff --git a/animations/source/animcore/animcore.component b/animations/source/animcore/animcore.component
index 4b3030edacba..ceb6288daf2f 100644
--- a/animations/source/animcore/animcore.component
+++ b/animations/source/animcore/animcore.component
@@ -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>
diff --git a/animations/source/animcore/factreg.cxx b/animations/source/animcore/factreg.cxx
index d95798109f07..3757e7606203 100644
--- a/animations/source/animcore/factreg.cxx
+++ b/animations/source/animcore/factreg.cxx
@@ -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 }
};
diff --git a/animations/source/animcore/factreg.hxx b/animations/source/animcore/factreg.hxx
index a6ede62668dc..9d503de61ffb 100644
--- a/animations/source/animcore/factreg.hxx
+++ b/animations/source/animcore/factreg.hxx
@@ -38,7 +38,6 @@ DECL_NODE_FACTORY( ANIMATETRANSFORM );
DECL_NODE_FACTORY( TRANSITIONFILTER );
DECL_NODE_FACTORY( AUDIO );
DECL_NODE_FACTORY( COMMAND );
-DECL_NODE_FACTORY( TargetPropertiesCreator );
}
diff --git a/animations/source/animcore/targetpropertiescreator.cxx b/animations/source/animcore/targetpropertiescreator.cxx
deleted file mode 100644
index 84f061863f82..000000000000
--- a/animations/source/animcore/targetpropertiescreator.cxx
+++ /dev/null
@@ -1,486 +0,0 @@
-/* -*- 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 .
- */
-
-#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>
-
-
-using namespace ::com::sun::star;
-
-#define IMPLEMENTATION_NAME "animcore::TargetPropertiesCreator"
-#define SERVICE_NAME "com.sun.star.animations.TargetPropertiesCreator"
-
-namespace animcore
-{
- 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
- typedef ::std::vector< beans::NamedValue > VectorOfNamedValues;
-
- /** The hash map key
-
- This key contains both XShape reference and a paragraph
- index, as we somehow have to handle shape and paragraph
- targets with the same data structure.
- */
- struct ShapeHashKey
- {
- /// Shape target
- uno::Reference< drawing::XShape > mxRef;
-
- /** Paragraph index.
-
- If this is a pure shape target, mnParagraphIndex is
- set to -1.
- */
- sal_Int16 mnParagraphIndex;
-
- /// Comparison needed for boost::unordered_map
- bool operator==( const ShapeHashKey& rRHS ) const
- {
- return mxRef == rRHS.mxRef && mnParagraphIndex == rRHS.mnParagraphIndex;
- }
- };
-
- // A hash functor for ShapeHashKey objects
- struct ShapeKeyHasher
- {
- ::std::size_t operator()( const ShapeHashKey& rKey ) const
- {
- // TODO(P2): Maybe a better hash function would be to
- // spread mnParagraphIndex to 32 bit: a0b0c0d0e0... Hakmem
- // should have a formula.
-
- // Yes it has:
- // x = (x & 0x0000FF00) << 8) | (x >> 8) & 0x0000FF00 | x & 0xFF0000FF;
- // x = (x & 0x00F000F0) << 4) | (x >> 4) & 0x00F000F0 | x & 0xF00FF00F;
- // x = (x & 0x0C0C0C0C) << 2) | (x >> 2) & 0x0C0C0C0C | x & 0xC3C3C3C3;
- // x = (x & 0x22222222) << 1) | (x >> 1) & 0x22222222 | x & 0x99999999;
-
- // Costs about 17 cycles on a RISC machine with infinite
- // instruction level parallelism (~42 basic
- // instructions). Thus I truly doubt this pays off...
- return reinterpret_cast< ::std::size_t >(rKey.mxRef.get()) ^ (rKey.mnParagraphIndex << 16L);
- }
- };
-
- // A hash map which maps a XShape to the corresponding vector of initial properties
- typedef ::boost::unordered_map< ShapeHashKey, VectorOfNamedValues, ShapeKeyHasher > XShapeHash;
-
-
- class NodeFunctor
- {
- public:
- explicit NodeFunctor( XShapeHash& rShapeHash ) :
- mrShapeHash( rShapeHash ),
- mxTargetShape(),
- mnParagraphIndex( -1 )
- {
- }
-
- NodeFunctor( XShapeHash& rShapeHash,
- const uno::Reference< drawing::XShape >& rTargetShape,
- sal_Int16 nParagraphIndex ) :
- mrShapeHash( rShapeHash ),
- mxTargetShape( rTargetShape ),
- mnParagraphIndex( nParagraphIndex )
- {
- }
-
- void operator()( const uno::Reference< animations::XAnimationNode >& xNode ) const
- {
- if( !xNode.is() )
- {
- OSL_FAIL( "AnimCore: NodeFunctor::operator(): invalid XAnimationNode" );
- return;
- }
-
- uno::Reference< drawing::XShape > xTargetShape( mxTargetShape );
- sal_Int16 nParagraphIndex( mnParagraphIndex );
-
- switch( xNode->getType() )
- {
- case animations::AnimationNodeType::ITERATE:
- {
- // extract target shape from iterate node
- // (will override the target for all children)
-
- uno::Reference< animations::XIterateContainer > xIterNode( xNode,
- uno::UNO_QUERY );
-
- // TODO(E1): I'm not too sure what to expect here...
- if( !xIterNode->getTarget().hasValue() )
- {
- OSL_FAIL( "animcore: NodeFunctor::operator(): no target on ITERATE node" );
- return;
- }
-
- xTargetShape.set( xIterNode->getTarget(),
- uno::UNO_QUERY );
-
- if( !xTargetShape.is() )
- {
- ::com::sun::star::presentation::ParagraphTarget aTarget;
-
- // no shape provided. Maybe a ParagraphTarget?
- if( !(xIterNode->getTarget() >>= aTarget) )
- {
- OSL_FAIL( "animcore: NodeFunctor::operator(): could not extract any "
- "target information" );
- return;
- }
-
- xTargetShape = aTarget.Shape;
- nParagraphIndex = aTarget.Paragraph;
-
- if( !xTargetShape.is() )
- {
- OSL_FAIL( "animcore: NodeFunctor::operator(): invalid shape in ParagraphTarget" );
- return;
- }
- }
- }
- // FALLTHROUGH intended
- case animations::AnimationNodeType::PAR:
- // FALLTHROUGH intended
- case animations::AnimationNodeType::SEQ:
- {
- NodeFunctor aFunctor( mrShapeHash,
- xTargetShape,
- nParagraphIndex );
- if( !::anim::for_each_childNode( xNode,
- aFunctor ) )
- {
- OSL_FAIL( "AnimCore: NodeFunctor::operator(): child node iteration failed, "
- "or extraneous container nodes encountered" );
- }
- }
- break;
-
- case animations::AnimationNodeType::CUSTOM:
- // FALLTHROUGH intended
- case animations::AnimationNodeType::ANIMATE:
- // FALLTHROUGH intended
- case animations::AnimationNodeType::ANIMATEMOTION:
- // FALLTHROUGH intended
- case animations::AnimationNodeType::ANIMATECOLOR:
- // FALLTHROUGH intended
- case animations::AnimationNodeType::ANIMATETRANSFORM:
- // FALLTHROUGH intended
- case animations::AnimationNodeType::TRANSITIONFILTER:
- // FALLTHROUGH intended
- case animations::AnimationNodeType::AUDIO:
- // FALLTHROUGH intended
- /*default:
- // ignore this node, no valuable content for now.
- break;*/
-
- case animations::AnimationNodeType::SET:
- {
- // evaluate set node content
- uno::Reference< animations::XAnimate > xAnimateNode( xNode,
- uno::UNO_QUERY );
-
- if( !xAnimateNode.is() )
- break; // invalid node
-
- // determine target shape (if any)
- ShapeHashKey aTarget;
- if( xTargetShape.is() )
- {
- // override target shape with parent-supplied
- aTarget.mxRef = xTargetShape;
- aTarget.mnParagraphIndex = nParagraphIndex;
- }
- else
- {
- // no parent-supplied target, retrieve
- // node target
- if( (xAnimateNode->getTarget() >>= aTarget.mxRef) )
- {
- // pure shape target - set paragraph
- // index to magic
- aTarget.mnParagraphIndex = -1;
- }
- else
- {
- // not a pure shape target - maybe a
- // ParagraphTarget?
- presentation::ParagraphTarget aUnoTarget;
-
- if( !(xAnimateNode->getTarget() >>= aUnoTarget) )
- {
- OSL_FAIL( "AnimCore: NodeFunctor::operator(): unknown target type encountered" );
- break;
- }
-
- aTarget.mxRef = aUnoTarget.Shape;
- aTarget.mnParagraphIndex = aUnoTarget.Paragraph;
- }
- }
-
- if( !aTarget.mxRef.is() )
- {
- OSL_FAIL( "AnimCore: NodeFunctor::operator(): Found target, but XShape is NULL" );
- break; // invalid target XShape
- }
-
- // check whether we already have an entry for
- // this target (we only take the first set
- // effect for every shape)
- XShapeHash::const_iterator aIter;
- if( (aIter=mrShapeHash.find( aTarget )) != mrShapeHash.end() )
- break; // already an entry in existence for given XShape
-
- // if this is an appear effect, hide shape
- // initially. This is currently the only place
- // where a shape effect influences shape
- // attributes outside it's effective duration.
- sal_Bool bVisible( sal_False );
- if( xAnimateNode->getAttributeName().equalsIgnoreAsciiCase("visibility") )
- {
-
- uno::Any aAny( xAnimateNode->getTo() );
-
- // try to extract bool value
- if( !(aAny >>= bVisible) )
- {
- // try to extract string
- OUString aString;
- if( (aAny >>= aString) )
- {
- // we also take the strings "true" and "false",
- // as well as "on" and "off" here
- if( aString.equalsIgnoreAsciiCase("true") ||
- aString.equalsIgnoreAsciiCase("on") )
- {
- bVisible = sal_True;
- }
- if( aString.equalsIgnoreAsciiCase("false") ||
- aString.equalsIgnoreAsciiCase("off") )
- {
- bVisible = sal_False;
- }
- }
- }
-
- /*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(
- XShapeHash::value_type(
- aTarget,
- VectorOfNamedValues(
- 1,
- beans::NamedValue(
- //xAnimateNode->getAttributeName(),
- OUString("visibility"),
- uno::makeAny( !bVisible ) ) ) ) );
- //}
- //}
- }
- break;
- }
- }
-
- private:
- XShapeHash& mrShapeHash;
- uno::Reference< drawing::XShape > mxTargetShape;
- sal_Int16 mnParagraphIndex;
- };
- }
-
- 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)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- // scan all nodes for visibility changes, and record first
- // 'visibility=true' for each shape
- XShapeHash aShapeHash( 101 );
-
- NodeFunctor aFunctor( aShapeHash );
-
- // TODO(F1): Maybe limit functor application to main sequence
- // alone (CL said something that shape visibility is only
- // affected by effects in the main sequence for PPT).
-
- // OTOH, client code can pass us only the main sequence (which
- // it actually does right now, for the slideshow implementation).
- aFunctor( xRootNode );
-
- // output to result sequence
- uno::Sequence< animations::TargetProperties > aRes( aShapeHash.size() );
-
- ::std::size_t nCurrIndex(0);
- XShapeHash::const_iterator aCurr( aShapeHash.begin() );
- const XShapeHash::const_iterator aEnd ( aShapeHash.end() );
- while( aCurr != aEnd )
- {
- animations::TargetProperties& rCurrProps( aRes[ nCurrIndex++ ] );
-
- if( aCurr->first.mnParagraphIndex == -1 )
- {
- rCurrProps.Target = uno::makeAny( aCurr->first.mxRef );
- }
- else
- {
- rCurrProps.Target = uno::makeAny(
- presentation::ParagraphTarget(
- aCurr->first.mxRef,
- aCurr->first.mnParagraphIndex ) );
- }
-
- rCurrProps.Properties = ::comphelper::containerToSequence( aCurr->second );
-
- ++aCurr;
- }
-
- 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
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */