[Libreoffice-commits] core.git: xmloff/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Nov 12 16:10:23 UTC 2019


 xmloff/source/draw/eventimp.cxx |   83 +++++++++++++++++++++++++---------------
 1 file changed, 52 insertions(+), 31 deletions(-)

New commits:
commit db13ed2efa924cee6acd0699f2676175419da5ad
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Nov 12 12:29:02 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Nov 12 17:08:58 2019 +0100

    refactor SdXMLEventContext to make a separate SdXMLEventContextData
    
    Change-Id: I5614be3bf99ce3529c4a1ef5a0b5d0d7417b1e46
    Reviewed-on: https://gerrit.libreoffice.org/82515
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/xmloff/source/draw/eventimp.cxx b/xmloff/source/draw/eventimp.cxx
index 6312a32510a7..ccb93c379aba 100644
--- a/xmloff/source/draw/eventimp.cxx
+++ b/xmloff/source/draw/eventimp.cxx
@@ -70,17 +70,15 @@ SvXMLEnumMapEntry<ClickAction> const aXML_EventActions_EnumMap[] =
     { XML_TOKEN_INVALID, ClickAction(0) }
 };
 
-class SdXMLEventContext : public SvXMLImportContext
+class SdXMLEventContextData
 {
 private:
     css::uno::Reference< css::drawing::XShape > mxShape;
 
 public:
+    SdXMLEventContextData(const Reference< XShape >& rxShape);
 
-    SdXMLEventContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList>& xAttrList, const Reference< XShape >& rxShape );
-
-    virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,    const Reference< XAttributeList>& xAttrList ) override;
-    virtual void EndElement() override;
+    void ApplyProperties();
 
     bool mbValid;
     bool mbScript;
@@ -97,6 +95,27 @@ public:
     OUString msLanguage;
 };
 
+SdXMLEventContextData::SdXMLEventContextData(const Reference< XShape >& rxShape)
+    : mxShape(rxShape), mbValid(false), mbScript(false)
+    , meClickAction(ClickAction_NONE), meEffect(EK_none)
+    , meDirection(ED_none), mnStartScale(100), meSpeed(AnimationSpeed_MEDIUM)
+    , mnVerb(0), mbPlayFull(false)
+{
+}
+
+class SdXMLEventContext : public SvXMLImportContext
+{
+public:
+    SdXMLEventContextData maData;
+
+public:
+
+    SdXMLEventContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList>& xAttrList, const Reference< XShape >& rxShape );
+
+    virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,    const Reference< XAttributeList>& xAttrList ) override;
+    virtual void EndElement() override;
+};
+
 class XMLEventSoundContext : public SvXMLImportContext
 {
 public:
@@ -123,13 +142,13 @@ XMLEventSoundContext::XMLEventSoundContext( SvXMLImport& rImp, sal_uInt16 nPrfx,
             case XML_NAMESPACE_XLINK:
                 if( IsXMLToken( aAttrLocalName, XML_HREF ) )
                 {
-                    pParent->msSoundURL = rImp.GetAbsoluteReference(sValue);
+                    pParent->maData.msSoundURL = rImp.GetAbsoluteReference(sValue);
                 }
                 break;
             case XML_NAMESPACE_PRESENTATION:
                 if( IsXMLToken( aAttrLocalName, XML_PLAY_FULL ) )
                 {
-                    pParent->mbPlayFull = IsXMLToken( sValue, XML_TRUE );
+                    pParent->maData.mbPlayFull = IsXMLToken( sValue, XML_TRUE );
                 }
             }
         }
@@ -138,19 +157,16 @@ XMLEventSoundContext::XMLEventSoundContext( SvXMLImport& rImp, sal_uInt16 nPrfx,
 
 SdXMLEventContext::SdXMLEventContext( SvXMLImport& rImp,  sal_uInt16 nPrfx, const OUString& rLocalName,  const Reference< XAttributeList >& xAttrList, const Reference< XShape >& rxShape )
     : SvXMLImportContext(rImp, nPrfx, rLocalName)
-    , mxShape(rxShape), mbValid(false), mbScript(false)
-    , meClickAction(ClickAction_NONE), meEffect(EK_none)
-    , meDirection(ED_none), mnStartScale(100), meSpeed(AnimationSpeed_MEDIUM)
-    , mnVerb(0), mbPlayFull(false)
+    , maData(rxShape)
 {
     if( nPrfx == XML_NAMESPACE_PRESENTATION && IsXMLToken( rLocalName, XML_EVENT_LISTENER ) )
     {
-        mbValid = true;
+        maData.mbValid = true;
     }
     else if( nPrfx == XML_NAMESPACE_SCRIPT && IsXMLToken( rLocalName, XML_EVENT_LISTENER ) )
     {
-        mbScript = true;
-        mbValid = true;
+        maData.mbScript = true;
+        maData.mbValid = true;
     }
     else
     {
@@ -160,7 +176,7 @@ SdXMLEventContext::SdXMLEventContext( SvXMLImport& rImp,  sal_uInt16 nPrfx, cons
     // read attributes
     OUString sEventName;
     const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
-    for(sal_Int16 i=0; (i < nAttrCount) && mbValid; i++)
+    for(sal_Int16 i=0; (i < nAttrCount) && maData.mbValid; i++)
     {
         OUString sAttrName = xAttrList->getNameByIndex( i );
         OUString aAttrLocalName;
@@ -172,29 +188,29 @@ SdXMLEventContext::SdXMLEventContext( SvXMLImport& rImp,  sal_uInt16 nPrfx, cons
         case XML_NAMESPACE_PRESENTATION:
             if( IsXMLToken( aAttrLocalName, XML_ACTION ) )
             {
-                SvXMLUnitConverter::convertEnum( meClickAction, sValue, aXML_EventActions_EnumMap );
+                SvXMLUnitConverter::convertEnum( maData.meClickAction, sValue, aXML_EventActions_EnumMap );
             }
             if( IsXMLToken( aAttrLocalName, XML_EFFECT ) )
             {
-                SvXMLUnitConverter::convertEnum( meEffect, sValue, aXML_AnimationEffect_EnumMap );
+                SvXMLUnitConverter::convertEnum( maData.meEffect, sValue, aXML_AnimationEffect_EnumMap );
             }
             else if( IsXMLToken( aAttrLocalName, XML_DIRECTION ) )
             {
-                SvXMLUnitConverter::convertEnum( meDirection, sValue, aXML_AnimationDirection_EnumMap );
+                SvXMLUnitConverter::convertEnum( maData.meDirection, sValue, aXML_AnimationDirection_EnumMap );
             }
             else if( IsXMLToken( aAttrLocalName, XML_START_SCALE ) )
             {
                 sal_Int32 nScale;
                 if (::sax::Converter::convertPercent( nScale, sValue ))
-                    mnStartScale = static_cast<sal_Int16>(nScale);
+                    maData.mnStartScale = static_cast<sal_Int16>(nScale);
             }
             else if( IsXMLToken( aAttrLocalName, XML_SPEED ) )
             {
-                SvXMLUnitConverter::convertEnum( meSpeed, sValue, aXML_AnimationSpeed_EnumMap );
+                SvXMLUnitConverter::convertEnum( maData.meSpeed, sValue, aXML_AnimationSpeed_EnumMap );
             }
             else if( IsXMLToken( aAttrLocalName, XML_VERB ) )
             {
-                ::sax::Converter::convertNumber( mnVerb, sValue );
+                ::sax::Converter::convertNumber( maData.mnVerb, sValue );
             }
             break;
 
@@ -204,36 +220,36 @@ SdXMLEventContext::SdXMLEventContext( SvXMLImport& rImp,  sal_uInt16 nPrfx, cons
                 sEventName = sValue;
                 sal_uInt16 nScriptPrefix =
                     GetImport().GetNamespaceMap().GetKeyByAttrName( sValue, &sEventName );
-                mbValid = XML_NAMESPACE_DOM == nScriptPrefix && sEventName == "click";
+                maData.mbValid = XML_NAMESPACE_DOM == nScriptPrefix && sEventName == "click";
             }
             else if( IsXMLToken( aAttrLocalName, XML_LANGUAGE ) )
             {
                 // language is not evaluated!
                 OUString aScriptLanguage;
-                msLanguage = sValue;
+                maData.msLanguage = sValue;
                 sal_uInt16 nScriptPrefix = rImp.GetNamespaceMap().
-                    GetKeyByAttrName( msLanguage, &aScriptLanguage );
+                    GetKeyByAttrName( maData.msLanguage, &aScriptLanguage );
                 if( XML_NAMESPACE_OOO == nScriptPrefix )
-                    msLanguage = aScriptLanguage;
+                    maData.msLanguage = aScriptLanguage;
             }
             else if( IsXMLToken( aAttrLocalName, XML_MACRO_NAME ) )
             {
-                msMacroName = sValue;
+                maData.msMacroName = sValue;
             }
             break;
 
         case XML_NAMESPACE_XLINK:
             if( IsXMLToken( aAttrLocalName, XML_HREF ) )
             {
-                if ( mbScript )
+                if ( maData.mbScript )
                 {
-                    msMacroName = sValue;
+                    maData.msMacroName = sValue;
                 }
                 else
                 {
                     const OUString &rTmp =
                         rImp.GetAbsoluteReference(sValue);
-                    INetURLObject::translateToInternal( rTmp, msBookmark,
+                    INetURLObject::translateToInternal( rTmp, maData.msBookmark,
                         INetURLObject::DecodeMechanism::Unambiguous );
                 }
             }
@@ -241,8 +257,8 @@ SdXMLEventContext::SdXMLEventContext( SvXMLImport& rImp,  sal_uInt16 nPrfx, cons
         }
     }
 
-    if( mbValid )
-        mbValid = !sEventName.isEmpty();
+    if( maData.mbValid )
+        maData.mbValid = !sEventName.isEmpty();
 }
 
 SvXMLImportContextRef SdXMLEventContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList>& xAttrList )
@@ -252,6 +268,11 @@ SvXMLImportContextRef SdXMLEventContext::CreateChildContext( sal_uInt16 nPrefix,
 
 void SdXMLEventContext::EndElement()
 {
+    maData.ApplyProperties();
+}
+
+void SdXMLEventContextData::ApplyProperties()
+{
     if( !mbValid )
         return;
 


More information about the Libreoffice-commits mailing list