Kaydet (Commit) a8a3e6a7 authored tarafından Szymon Kłos's avatar Szymon Kłos

tdf#115394 import custom slide transition time in PPTX

* custom values are imported correctly
* standard (fast, slow, medium) values are changed
  to match values in the MSO

Change-Id: I004242afbbf641fe414abc8df248a2844c104502
Reviewed-on: https://gerrit.libreoffice.org/49139Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarSzymon Kłos <szymon.klos@collabora.com>
üst e89964eb
...@@ -43,7 +43,10 @@ namespace oox { namespace ppt { ...@@ -43,7 +43,10 @@ namespace oox { namespace ppt {
void setSlideProperties( PropertyMap& props ); void setSlideProperties( PropertyMap& props );
void setTransitionFilterProperties( const css::uno::Reference< css::animations::XTransitionFilter > & xFilter ); void setTransitionFilterProperties( const css::uno::Reference< css::animations::XTransitionFilter > & xFilter );
/// Set one of standard values for slide transition duration
void setOoxTransitionSpeed( sal_Int32 nToken ); void setOoxTransitionSpeed( sal_Int32 nToken );
/// Set slide transition time directly
void setOoxTransitionSpeed( double fDuration );
void setMode( bool bMode ) void setMode( bool bMode )
{ mbMode = bMode; } { mbMode = bMode; }
void setOoxAdvanceTime( sal_Int32 nAdvanceTime ) void setOoxAdvanceTime( sal_Int32 nAdvanceTime )
...@@ -66,6 +69,7 @@ namespace oox { namespace ppt { ...@@ -66,6 +69,7 @@ namespace oox { namespace ppt {
::sal_Int16 mnTransitionSubType; ::sal_Int16 mnTransitionSubType;
bool mbTransitionDirectionNormal; bool mbTransitionDirectionNormal;
css::presentation::AnimationSpeed mnAnimationSpeed; css::presentation::AnimationSpeed mnAnimationSpeed;
double mfTransitionDurationInSeconds;
bool mbMode; /**< http://api.libreoffice.org/docs/common/ref/com/sun/star/animations/XTransitionFilter.html Mode property */ bool mbMode; /**< http://api.libreoffice.org/docs/common/ref/com/sun/star/animations/XTransitionFilter.html Mode property */
::sal_Int32 mnAdvanceTime; ::sal_Int32 mnAdvanceTime;
}; };
......
...@@ -79,11 +79,11 @@ published service DrawPage ...@@ -79,11 +79,11 @@ published service DrawPage
[property] short Layout; [property] short Layout;
/** defines the speed of the fade-in effect of this page. /** Defines the speed of the fade-in effect of this page.
@see TransitionSpeed
*/ */
[property] com::sun::star::presentation::AnimationSpeed Speed; [property] com::sun::star::presentation::AnimationSpeed Speed;
/** defines if a header presentation shape from the master page is visible /** defines if a header presentation shape from the master page is visible
on this page. on this page.
*/ */
...@@ -142,6 +142,11 @@ published service DrawPage ...@@ -142,6 +142,11 @@ published service DrawPage
*/ */
[optional, property] long DateTimeFormat; [optional, property] long DateTimeFormat;
/** Specifies slide transition time in seconds.
@since LibreOffice 6.1
@see Speed
*/
[property, optional] double TransitionDuration;
}; };
......
...@@ -45,6 +45,7 @@ namespace oox { namespace ppt { ...@@ -45,6 +45,7 @@ namespace oox { namespace ppt {
, mnTransitionSubType( 0 ) , mnTransitionSubType( 0 )
, mbTransitionDirectionNormal( true ) , mbTransitionDirectionNormal( true )
, mnAnimationSpeed( AnimationSpeed_FAST ) , mnAnimationSpeed( AnimationSpeed_FAST )
, mfTransitionDurationInSeconds( -1.0 )
, mbMode( true ) , mbMode( true )
, mnAdvanceTime( -1 ) , mnAdvanceTime( -1 )
{ {
...@@ -56,6 +57,7 @@ namespace oox { namespace ppt { ...@@ -56,6 +57,7 @@ namespace oox { namespace ppt {
, mnTransitionSubType( 0 ) , mnTransitionSubType( 0 )
, mbTransitionDirectionNormal( true ) , mbTransitionDirectionNormal( true )
, mnAnimationSpeed( AnimationSpeed_FAST ) , mnAnimationSpeed( AnimationSpeed_FAST )
, mfTransitionDurationInSeconds( -1.0 )
, mbMode( true ) , mbMode( true )
, mnAdvanceTime( -1 ) , mnAdvanceTime( -1 )
{ {
...@@ -76,6 +78,8 @@ namespace oox { namespace ppt { ...@@ -76,6 +78,8 @@ namespace oox { namespace ppt {
aProps.setProperty( PROP_TransitionSubtype, mnTransitionSubType); aProps.setProperty( PROP_TransitionSubtype, mnTransitionSubType);
aProps.setProperty( PROP_TransitionDirection, mbTransitionDirectionNormal); aProps.setProperty( PROP_TransitionDirection, mbTransitionDirectionNormal);
aProps.setProperty( PROP_Speed, mnAnimationSpeed); aProps.setProperty( PROP_Speed, mnAnimationSpeed);
if( mfTransitionDurationInSeconds >= 0.0 )
aProps.setProperty( PROP_TransitionDuration, mfTransitionDurationInSeconds);
aProps.setProperty( PROP_TransitionFadeColor, sal_Int32(0)); aProps.setProperty( PROP_TransitionFadeColor, sal_Int32(0));
if( mnAdvanceTime != -1 ) { if( mnAdvanceTime != -1 ) {
aProps.setProperty( PROP_Duration, mnAdvanceTime/1000); aProps.setProperty( PROP_Duration, mnAdvanceTime/1000);
...@@ -110,19 +114,21 @@ namespace oox { namespace ppt { ...@@ -110,19 +114,21 @@ namespace oox { namespace ppt {
{ {
switch( nToken ) switch( nToken )
{ {
/* In case you want to use time values in second, /* the speed values are located in the PPT97 importer
* the speed values are located in the PPT97 importer * sd/source/filter/ppt/pptin.cxx:1783
* sd/source/filter/ppt/ppt97animations.cxx:664 * (void ImplSdPPTImport::ImportPageEffect)
* (void Ppt97Animation::UpdateCacheData() const)
*/ */
case XML_fast: case XML_fast:
mnAnimationSpeed = AnimationSpeed_FAST; mnAnimationSpeed = AnimationSpeed_FAST;
mfTransitionDurationInSeconds = 0.5;
break; break;
case XML_med: case XML_med:
mnAnimationSpeed = AnimationSpeed_MEDIUM; mnAnimationSpeed = AnimationSpeed_MEDIUM;
mfTransitionDurationInSeconds = 0.75;
break; break;
case XML_slow: case XML_slow:
mnAnimationSpeed = AnimationSpeed_SLOW; mnAnimationSpeed = AnimationSpeed_SLOW;
mfTransitionDurationInSeconds = 1.0;
break; break;
default: default:
// should not happen. just ignore // should not happen. just ignore
...@@ -130,6 +136,14 @@ namespace oox { namespace ppt { ...@@ -130,6 +136,14 @@ namespace oox { namespace ppt {
} }
} }
void SlideTransition::setOoxTransitionSpeed( double fDurationInSeconds )
{
// for compatibility
mnAnimationSpeed = ( fDurationInSeconds <= 0.5 ) ? AnimationSpeed_FAST
: ( fDurationInSeconds >= 1.0 ) ? AnimationSpeed_SLOW : AnimationSpeed_MEDIUM;
mfTransitionDurationInSeconds = fDurationInSeconds;
}
sal_Int16 SlideTransition::ooxToOdpEightDirections( ::sal_Int32 nOoxType ) sal_Int16 SlideTransition::ooxToOdpEightDirections( ::sal_Int32 nOoxType )
{ {
sal_Int16 nOdpDirection; sal_Int16 nOdpDirection;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <oox/helper/attributelist.hxx> #include <oox/helper/attributelist.hxx>
#include <oox/token/namespaces.hxx> #include <oox/token/namespaces.hxx>
#include <oox/token/tokens.hxx> #include <oox/token/tokens.hxx>
#include <oox/token/properties.hxx>
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::oox::core; using namespace ::oox::core;
...@@ -50,6 +51,11 @@ SlideTransitionContext::SlideTransitionContext( FragmentHandler2 const & rParent ...@@ -50,6 +51,11 @@ SlideTransitionContext::SlideTransitionContext( FragmentHandler2 const & rParent
// ST_TransitionSpeed // ST_TransitionSpeed
maTransition.setOoxTransitionSpeed( rAttribs.getToken( XML_spd, XML_fast ) ); maTransition.setOoxTransitionSpeed( rAttribs.getToken( XML_spd, XML_fast ) );
// p14:dur
sal_Int32 nDurationInMs = rAttribs.getInteger( P14_TOKEN( dur ), -1 );
if( nDurationInMs > -1 )
maTransition.setOoxTransitionSpeed( nDurationInMs / 1000.0 );
// TODO // TODO
rAttribs.getBool( XML_advClick, true ); rAttribs.getBool( XML_advClick, true );
......
...@@ -530,6 +530,7 @@ TopMargin ...@@ -530,6 +530,7 @@ TopMargin
TotalsRow TotalsRow
Transformation Transformation
TransitionDirection TransitionDirection
TransitionDuration
TransitionFadeColor TransitionFadeColor
TransitionSubtype TransitionSubtype
TransitionType TransitionType
......
...@@ -174,6 +174,7 @@ public: ...@@ -174,6 +174,7 @@ public:
void testTdf114488(); void testTdf114488();
void testTdf114913(); void testTdf114913();
void testTdf114821(); void testTdf114821();
void testTdf115394();
bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected); bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
void testPatternImport(); void testPatternImport();
...@@ -251,6 +252,7 @@ public: ...@@ -251,6 +252,7 @@ public:
CPPUNIT_TEST(testTdf114488); CPPUNIT_TEST(testTdf114488);
CPPUNIT_TEST(testTdf114913); CPPUNIT_TEST(testTdf114913);
CPPUNIT_TEST(testTdf114821); CPPUNIT_TEST(testTdf114821);
CPPUNIT_TEST(testTdf115394);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
...@@ -2380,6 +2382,38 @@ void SdImportTest::testTdf114821() ...@@ -2380,6 +2382,38 @@ void SdImportTest::testTdf114821()
xDocShRef->DoClose(); xDocShRef->DoClose();
} }
void SdImportTest::testTdf115394()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf115394.pptx"), PPTX);
double fTransitionDuration;
// Slow in MS formats
SdPage* pPage1 = xDocShRef->GetDoc()->GetSdPage(0, PageKind::Standard);
fTransitionDuration = pPage1->getTransitionDuration();
CPPUNIT_ASSERT_EQUAL(1.0, fTransitionDuration);
// Medium in MS formats
SdPage* pPage2 = xDocShRef->GetDoc()->GetSdPage(1, PageKind::Standard);
fTransitionDuration = pPage2->getTransitionDuration();
CPPUNIT_ASSERT_EQUAL(0.75, fTransitionDuration);
// Fast in MS formats
SdPage* pPage3 = xDocShRef->GetDoc()->GetSdPage(2, PageKind::Standard);
fTransitionDuration = pPage3->getTransitionDuration();
CPPUNIT_ASSERT_EQUAL(0.5, fTransitionDuration);
// Custom values
SdPage* pPage4 = xDocShRef->GetDoc()->GetSdPage(3, PageKind::Standard);
fTransitionDuration = pPage4->getTransitionDuration();
CPPUNIT_ASSERT_EQUAL(0.25, fTransitionDuration);
SdPage* pPage5 = xDocShRef->GetDoc()->GetSdPage(4, PageKind::Standard);
fTransitionDuration = pPage5->getTransitionDuration();
CPPUNIT_ASSERT_EQUAL(4.25, fTransitionDuration);
xDocShRef->DoClose();
}
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest); CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#define UNO_NAME_PAGE_NUMBER "Number" #define UNO_NAME_PAGE_NUMBER "Number"
#define UNO_NAME_PAGE_ORIENTATION "Orientation" #define UNO_NAME_PAGE_ORIENTATION "Orientation"
#define UNO_NAME_PAGE_SPEED "Speed" #define UNO_NAME_PAGE_SPEED "Speed"
#define UNO_NAME_PAGE_TRANSITION_DURATION "TransitionDuration"
#define UNO_NAME_PAGE_WIDTH "Width" #define UNO_NAME_PAGE_WIDTH "Width"
#define UNO_NAME_PAGE_PREVIEW "Preview" #define UNO_NAME_PAGE_PREVIEW "Preview"
#define UNO_NAME_PAGE_PREVIEWBITMAP "PreviewBitmap" #define UNO_NAME_PAGE_PREVIEWBITMAP "PreviewBitmap"
......
...@@ -142,7 +142,7 @@ const SvxItemPropertySet* ImplGetDrawPagePropertySet( bool bImpress, PageKind eP ...@@ -142,7 +142,7 @@ const SvxItemPropertySet* ImplGetDrawPagePropertySet( bool bImpress, PageKind eP
{ OUString("TransitionSubtype"), WID_TRANSITION_SUBTYPE, ::cppu::UnoType<sal_Int16>::get(), 0, 0}, { OUString("TransitionSubtype"), WID_TRANSITION_SUBTYPE, ::cppu::UnoType<sal_Int16>::get(), 0, 0},
{ OUString("TransitionDirection"), WID_TRANSITION_DIRECTION, ::cppu::UnoType<sal_Bool>::get(), 0, 0}, { OUString("TransitionDirection"), WID_TRANSITION_DIRECTION, ::cppu::UnoType<sal_Bool>::get(), 0, 0},
{ OUString("TransitionFadeColor"), WID_TRANSITION_FADE_COLOR, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, { OUString("TransitionFadeColor"), WID_TRANSITION_FADE_COLOR, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
{ OUString("TransitionDuration"), WID_TRANSITION_DURATION, ::cppu::UnoType<double>::get(), 0, 0}, { OUString(UNO_NAME_PAGE_TRANSITION_DURATION), WID_TRANSITION_DURATION, ::cppu::UnoType<double>::get(), 0, 0},
{ OUString("LoopSound"), WID_LOOP_SOUND, cppu::UnoType<bool>::get(), 0, 0}, { OUString("LoopSound"), WID_LOOP_SOUND, cppu::UnoType<bool>::get(), 0, 0},
{ OUString("NavigationOrder"), WID_NAVORDER, cppu::UnoType<css::container::XIndexAccess>::get(),0, 0}, { OUString("NavigationOrder"), WID_NAVORDER, cppu::UnoType<css::container::XIndexAccess>::get(),0, 0},
{ OUString(), 0, css::uno::Type(), 0, 0 } { OUString(), 0, css::uno::Type(), 0, 0 }
......
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