[API CHANGE] PPTX filter: fix lost hide-while-show prop for slide narrations

The OOXML markup is <p:cMediaNode ... showWhenStopped="0">, but the UI
uses "Hide During Show", which is easier to understand, so use the
second naming in the code.

With this, the PPTX no longer makes the speaker bitmaps on slides
visible while projecting.

API change, because the animation node is only available via UNO, though
it's likely that no actual external code would ever interact with it
directly. (And also add a stub Narration attribute, so that can be
implemented in a follow-up commit without an API change.)

Change-Id: Ia90a2fb30c2bfdb4cff2901fe11bdf1d4ab38261
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109969
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Miklos Vajna
2021-01-26 21:15:24 +01:00
parent bbce1482f1
commit 1093c931e9
7 changed files with 66 additions and 1 deletions
+31
View File
@@ -254,6 +254,10 @@ public:
virtual void SAL_CALL setSource( const Any& _source ) override;
virtual double SAL_CALL getVolume() override;
virtual void SAL_CALL setVolume( double _volume ) override;
sal_Bool SAL_CALL getHideDuringShow() override;
void SAL_CALL setHideDuringShow(sal_Bool bHideDuringShow) override;
sal_Bool SAL_CALL getNarration() override;
void SAL_CALL setNarration(sal_Bool bNarration) override;
// XCommand - the following two shadowed by animate, unfortunately
@@ -347,6 +351,7 @@ private:
// XAudio
double mfVolume;
bool mbHideDuringShow;
// XCommand
sal_Int16 mnCommand;
@@ -434,6 +439,7 @@ AnimationNode::AnimationNode( sal_Int16 nNodeType )
mbMode(true),
mnFadeColor(0),
mfVolume(1.0),
mbHideDuringShow(false),
mnCommand(0),
mnIterateType( css::presentation::ShapeAnimationSubType::AS_WHOLE ),
mfIterateInterval(0.0)
@@ -504,6 +510,7 @@ AnimationNode::AnimationNode( const AnimationNode& rNode )
// XAudio
mfVolume( rNode.mfVolume ),
mbHideDuringShow(rNode.mbHideDuringShow),
// XCommand
mnCommand( rNode.mnCommand ),
@@ -1807,6 +1814,30 @@ void SAL_CALL AnimationNode::setVolume( double _volume )
}
}
sal_Bool SAL_CALL AnimationNode::getHideDuringShow()
{
osl::Guard<osl::Mutex> aGuard(maMutex);
return mbHideDuringShow;
}
void SAL_CALL AnimationNode::setHideDuringShow(sal_Bool bHideDuringShow)
{
osl::Guard<osl::Mutex> aGuard(maMutex);
if (static_cast<bool>(bHideDuringShow) != mbHideDuringShow)
{
mbHideDuringShow = bHideDuringShow;
fireChangeListener();
}
}
sal_Bool SAL_CALL AnimationNode::getNarration()
{
return false;
}
void SAL_CALL AnimationNode::setNarration(sal_Bool /*bNarration*/)
{
}
// XCommand
sal_Int16 SAL_CALL AnimationNode::getCommand()
+1
View File
@@ -43,6 +43,7 @@ namespace oox::ppt {
NP_ENDSYNC, NP_ITERATETYPE, NP_ITERATEINTERVAL,
NP_SUBITEM, NP_TARGET, NP_COMMAND, NP_PARAMETER,
NP_VALUES, NP_FORMULA, NP_KEYTIMES, NP_DISPLAY,
NP_HIDEDURINGSHOW,
NP_SIZE_
};
+12
View File
@@ -32,6 +32,18 @@ interface XAudio : XAnimationNode
[attribute] any Source;
[attribute] double Volume;
/** Specifies if the source shape should be hidden during slideshow (defaults to false).
@since LibreOffice 7.2
*/
[attribute] boolean HideDuringShow;
/** Specifies if the source shape is a narration for the slide (defaults to false).
@since LibreOffice 7.2
*/
[attribute] boolean Narration;
};
+6
View File
@@ -336,6 +336,12 @@ namespace oox::ppt {
if( xAnimate.is() )
xAnimate->setBy( aValue );
break;
case NP_HIDEDURINGSHOW:
if (xAudio.is() && (aValue >>= bBool))
{
xAudio->setHideDuringShow(bBool);
}
break;
case NP_TARGET:
if (xParent.is() && xParent->getType() == AnimationNodeType::ITERATE)
+9
View File
@@ -152,6 +152,7 @@ namespace oox::ppt {
: TimeNodeContext( rParent, aElement, pNode )
, mbIsNarration( false )
, mbFullScrn( false )
, mbHideDuringShow(false)
{
AttributeList attribs( xAttribs );
@@ -179,6 +180,10 @@ namespace oox::ppt {
{
// TODO deal with mbFullScrn
}
else if (aElement == PPT_TOKEN(cMediaNode))
{
mpNode->getNodeProperties()[NP_HIDEDURINGSHOW] <<= mbHideDuringShow;
}
}
virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs) override
@@ -189,6 +194,9 @@ namespace oox::ppt {
return new CommonTimeNodeContext( *this, aElementToken, rAttribs.getFastAttributeList(), mpNode );
case PPT_TOKEN( tgtEl ):
return new TimeTargetElementContext( *this, mpNode->getTarget() );
case PPT_TOKEN(cMediaNode):
mbHideDuringShow = !rAttribs.getBool(XML_showWhenStopped, true);
break;
default:
break;
}
@@ -199,6 +207,7 @@ namespace oox::ppt {
private:
bool mbIsNarration;
bool mbFullScrn;
bool mbHideDuringShow;
};
/** CT_TLSetBehavior
+5
View File
@@ -1353,6 +1353,11 @@ void SdOOXMLExportTest1::testNarrationMimeType()
// i.e. <p:childTnLst> had no <p:audio> children, the whole audio animation node was lost.
assertXPath(pSlideDoc, "//p:childTnLst/p:audio/p:cMediaNode", 1);
// Without the accompanying fix in place, this test would have failed with:
// - ... no attribute 'showWhenStopped' exist
// i.e. <p:cMediaNode> had the default visibility -> bitmap was visible during slideshow.
assertXPath(pSlideDoc, "//p:childTnLst/p:audio/p:cMediaNode", "showWhenStopped", "0");
xDocShRef->DoClose();
}
+2 -1
View File
@@ -1236,7 +1236,8 @@ void PPTXAnimationExport::WriteAnimationNodeAudio()
}
mpFS->startElementNS(XML_p, XML_audio);
mpFS->startElementNS(XML_p, XML_cMediaNode);
bool bHideDuringShow = xAudio->getHideDuringShow();
mpFS->startElementNS(XML_p, XML_cMediaNode, XML_showWhenStopped, bHideDuringShow ? "0" : "1");
mpFS->startElementNS(XML_p, XML_cTn);
WriteAnimationCondList(mpContext->getCondition(true), XML_stCondLst);