diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-07-06 02:08:33 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-07-07 12:21:27 +0200 |
commit | b7ed6de51422ca7bc8333e80ae6e9a4d57e07239 (patch) | |
tree | 7d55d33e38731db58d35e8d1fc77ec558f391914 /sd | |
parent | 125f3c4c930bd28a42c6819417b11b885e4586fc (diff) |
Use std::optional to allow optional inclusion of attributes
... instead of converting the O(U)String objects to char*.
Eventually this could allow to drop variants of *Element that take
XFastAttributeListRef.
Change-Id: Ib2748fcd93e655c55a176c00410fdcc7f052930d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98179
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/filter/eppt/pptx-animations.cxx | 38 | ||||
-rw-r--r-- | sd/source/filter/eppt/pptx-epptooxml.cxx | 8 |
2 files changed, 23 insertions, 23 deletions
diff --git a/sd/source/filter/eppt/pptx-animations.cxx b/sd/source/filter/eppt/pptx-animations.cxx index ec0f723c4974..90720501d07a 100644 --- a/sd/source/filter/eppt/pptx-animations.cxx +++ b/sd/source/filter/eppt/pptx-animations.cxx @@ -215,7 +215,7 @@ void WriteAnimateValues(const FSHelperPtr& pFS, const Reference<XAnimate>& rXAni if (aValues[i].hasValue()) { pFS->startElementNS(XML_p, XML_tav, XML_fmla, - sFormula.isEmpty() ? nullptr : sFormula.toUtf8().getStr(), XML_tm, + sax_fastparser::UseIf(sFormula, !sFormula.isEmpty()), XML_tm, OString::number(static_cast<sal_Int32>(aKeyTimes[i] * 100000.0))); pFS->startElementNS(XML_p, XML_val); ValuePair aPair; @@ -901,10 +901,9 @@ void PPTXAnimationExport::WriteAnimationNodeAnimate(sal_Int32 nXmlNodeType) } mpFS->startElementNS(XML_p, nXmlNodeType, XML_calcmode, pCalcMode, XML_valueType, - pValueType, XML_from, - sFrom.isEmpty() ? nullptr : sFrom.toUtf8().getStr(), XML_to, - sTo.isEmpty() ? nullptr : sTo.toUtf8().getStr(), XML_by, - sBy.isEmpty() ? nullptr : sBy.toUtf8().getStr()); + pValueType, XML_from, sax_fastparser::UseIf(sFrom, !sFrom.isEmpty()), + XML_to, sax_fastparser::UseIf(sTo, !sTo.isEmpty()), XML_by, + sax_fastparser::UseIf(sBy, !sBy.isEmpty())); bTo = sTo.isEmpty() && sFrom.isEmpty() && sBy.isEmpty(); } @@ -982,7 +981,7 @@ void PPTXAnimationExport::WriteAnimationNodeAnimateInside(bool bSimple, bool bWr void PPTXAnimationExport::WriteAnimationNodeCommonPropsStart() { const Reference<XAnimationNode>& rXNode = getCurrentNode(); - const char* pDuration = nullptr; + std::optional<OString> sDuration; const char* pRestart = nullptr; const char* pNodeType = nullptr; const char* pPresetClass = nullptr; @@ -999,7 +998,7 @@ void PPTXAnimationExport::WriteAnimationNodeCommonPropsStart() if (aAny >>= eTiming) { if (eTiming == Timing_INDEFINITE) - pDuration = "indefinite"; + sDuration = "indefinite"; } else aAny >>= fDuration; @@ -1013,17 +1012,20 @@ void PPTXAnimationExport::WriteAnimationNodeCommonPropsStart() pNodeType = convertEffectNodeType(nType); if (nType == EffectNodeType::TIMING_ROOT) { - if (!pDuration) - pDuration = "indefinite"; + if (!sDuration) + sDuration = "indefinite"; if (!pRestart) pRestart = "never"; } else if (nType == EffectNodeType::MAIN_SEQUENCE) { - pDuration = "indefinite"; + sDuration = "indefinite"; } } + if (fDuration != 0) + sDuration = OString::number(static_cast<sal_Int32>(fDuration * 1000.0)); + sal_uInt32 nPresetClass = mpContext->getEffectPresetClass(); if (nPresetClass != DFF_ANIM_PRESS_CLASS_USER_DEFINED) pPresetClass = convertEffectPresetClass(nPresetClass); @@ -1057,13 +1059,11 @@ void PPTXAnimationExport::WriteAnimationNodeCommonPropsStart() bool bAutoReverse = rXNode->getAutoReverse(); mpFS->startElementNS( - XML_p, XML_cTn, XML_id, OString::number(GetNextAnimationNodeId(rXNode)), XML_dur, - fDuration != 0 ? OString::number(static_cast<sal_Int32>(fDuration * 1000.0)).getStr() - : pDuration, - XML_autoRev, bAutoReverse ? "1" : nullptr, XML_restart, pRestart, XML_nodeType, pNodeType, - XML_fill, pFill, XML_presetClass, pPresetClass, XML_presetID, - bPresetId ? OString::number(nPresetId).getStr() : nullptr, XML_presetSubtype, - bPresetSubType ? OString::number(nPresetSubType).getStr() : nullptr); + XML_p, XML_cTn, XML_id, OString::number(GetNextAnimationNodeId(rXNode)), XML_dur, sDuration, + XML_autoRev, sax_fastparser::UseIf("1", bAutoReverse), XML_restart, pRestart, XML_nodeType, + pNodeType, XML_fill, pFill, XML_presetClass, pPresetClass, XML_presetID, + sax_fastparser::UseIf(OString::number(nPresetId), bPresetId), XML_presetSubtype, + sax_fastparser::UseIf(OString::number(nPresetSubType), bPresetSubType)); WriteAnimationCondList(mpContext->getCondition(true), XML_stCondLst); WriteAnimationCondList(mpContext->getCondition(false), XML_endCondLst); @@ -1192,8 +1192,8 @@ void PPTXAnimationExport::WriteAnimationNodeAudio() mpFS->startElementNS(XML_p, XML_tgtEl); mpFS->singleElementNS(XML_p, XML_sndTgt, FSNS(XML_r, XML_embed), - sRelId.isEmpty() ? nullptr : sRelId.toUtf8().getStr(), XML_name, - sUrl.isEmpty() ? nullptr : sName.toUtf8().getStr()); + sax_fastparser::UseIf(sRelId, !sRelId.isEmpty()), XML_name, + sax_fastparser::UseIf(sName, !sUrl.isEmpty())); mpFS->endElementNS(XML_p, XML_tgtEl); mpFS->endElementNS(XML_p, XML_cMediaNode); diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index e1cb766858c5..9de1eb5b3f60 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -119,9 +119,9 @@ void WriteSndAc(const FSHelperPtr& pFS, const OUString& sSoundRelId, const OUStr { pFS->startElementNS(XML_p, XML_sndAc); pFS->startElementNS(XML_p, XML_stSnd); - pFS->singleElementNS(XML_p, XML_snd, - FSNS(XML_r, XML_embed), sSoundRelId.isEmpty() ? nullptr : sSoundRelId.toUtf8().getStr(), - XML_name, sSoundName.isEmpty() ? nullptr : sSoundName.toUtf8().getStr()); + pFS->singleElementNS(XML_p, XML_snd, FSNS(XML_r, XML_embed), + sax_fastparser::UseIf(sSoundRelId, !sSoundRelId.isEmpty()), XML_name, + sax_fastparser::UseIf(sSoundName, !sSoundName.isEmpty())); pFS->endElement(FSNS(XML_p, XML_stSnd)); pFS->endElement(FSNS(XML_p, XML_sndAc)); } @@ -900,7 +900,7 @@ void PowerPointExport::WriteTransition(const FSHelperPtr& pFS) pFS->startElementNS(XML_p, XML_transition, XML_spd, speed, - XML_advTm, isAdvanceTimingSet ? OString::number(advanceTiming * 1000).getStr() : nullptr); + XML_advTm, sax_fastparser::UseIf(OString::number(advanceTiming * 1000), isAdvanceTimingSet)); if (nTransition) { |