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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sun Mar 1 06:35:10 UTC 2020


 include/xmloff/xmlstyle.hxx                                     |    2 
 xmloff/inc/XMLFootnoteConfigurationImportContext.hxx            |    8 
 xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx         |   10 -
 xmloff/inc/XMLLineNumberingImportContext.hxx                    |    9 
 xmloff/source/table/XMLTableImport.cxx                          |   25 +-
 xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx    |   96 ++++------
 xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx |   19 -
 xmloff/source/text/XMLLineNumberingImportContext.cxx            |   43 +---
 8 files changed, 81 insertions(+), 131 deletions(-)

New commits:
commit c1dae35c1eaa58159a8a76efdeecf70c1d01e550
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Feb 28 13:50:45 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Mar 1 07:34:35 2020 +0100

    use the SetAttribute override in SvXMLStyleContext subclasses consistently
    
    Change-Id: Ibdbf73c5e54fbbb051e4898fd8b3a7a155647b15
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89702
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/xmloff/xmlstyle.hxx b/include/xmloff/xmlstyle.hxx
index fc38f53097f0..8f49a61a3b91 100644
--- a/include/xmloff/xmlstyle.hxx
+++ b/include/xmloff/xmlstyle.hxx
@@ -101,7 +101,7 @@ public:
     virtual ~SvXMLStyleContext() override;
 
     virtual void StartElement(
-        const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
+        const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) final override;
 
     const OUString&  GetName() const { return maName; }
     const OUString&  GetDisplayName() const { return maDisplayName.getLength() ? maDisplayName : maName; }
diff --git a/xmloff/inc/XMLFootnoteConfigurationImportContext.hxx b/xmloff/inc/XMLFootnoteConfigurationImportContext.hxx
index 1b5dc4e4838b..3fa5e47e6cea 100644
--- a/xmloff/inc/XMLFootnoteConfigurationImportContext.hxx
+++ b/xmloff/inc/XMLFootnoteConfigurationImportContext.hxx
@@ -51,6 +51,10 @@ class XMLFootnoteConfigurationImportContext final : public SvXMLStyleContext
     bool bPosition;
     bool bIsEndnote;
 
+    /// parse attributes
+    virtual void SetAttribute( sal_uInt16 nPrefixKey,
+                               const OUString& rLocalName,
+                               const OUString& rValue ) override;
 public:
 
 
@@ -62,10 +66,6 @@ public:
 
     virtual ~XMLFootnoteConfigurationImportContext() override;
 
-    /// parse attributes
-    virtual void StartElement(
-        const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList ) override;
-
     /// for footnotes, also parse begin and end notices
     virtual SvXMLImportContextRef CreateChildContext(
         sal_uInt16 nPrefix,
diff --git a/xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx b/xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx
index a0c507f1723a..467ecbd19d8b 100644
--- a/xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx
+++ b/xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx
@@ -64,8 +64,9 @@ public:
 
 private:
 
-    virtual void StartElement(
-        const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList) override;
+    virtual void SetAttribute( sal_uInt16 nPrefixKey,
+                               const OUString& rLocalName,
+                               const OUString& rValue ) override;
 
     virtual void CreateAndInsert( bool bOverwrite ) override;
 
@@ -73,11 +74,6 @@ private:
         sal_uInt16 nPrefix,
         const OUString& rLocalName,
         const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList ) override;
-
-    void ProcessAttribute(
-        sal_uInt16 nPrefix,
-        const OUString& sLocalName,
-        const OUString& sValue);
 };
 
 #endif
diff --git a/xmloff/inc/XMLLineNumberingImportContext.hxx b/xmloff/inc/XMLLineNumberingImportContext.hxx
index 15d66dbf1088..6b6dc74b87b8 100644
--- a/xmloff/inc/XMLLineNumberingImportContext.hxx
+++ b/xmloff/inc/XMLLineNumberingImportContext.hxx
@@ -80,12 +80,9 @@ public:
 
 private:
 
-    virtual void StartElement(
-        const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override;
-
-    void ProcessAttribute(
-        enum LineNumberingToken eToken,
-        const OUString& sValue);
+    virtual void SetAttribute( sal_uInt16 nPrefixKey,
+                               const OUString& rLocalName,
+                               const OUString& rValue ) override;
 
     virtual void CreateAndInsert(bool bOverwrite) override;
 
diff --git a/xmloff/source/table/XMLTableImport.cxx b/xmloff/source/table/XMLTableImport.cxx
index 513e3e595774..e02170676935 100644
--- a/xmloff/source/table/XMLTableImport.cxx
+++ b/xmloff/source/table/XMLTableImport.cxx
@@ -158,11 +158,13 @@ public:
 
     virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList ) override;
 
-    virtual void StartElement( const Reference< XAttributeList >& xAttrList ) override;
-
     virtual void EndElement() override;
 
     virtual void CreateAndInsert( bool bOverwrite ) override;
+protected:
+    virtual void SetAttribute( sal_uInt16 nPrefixKey,
+                               const OUString& rLocalName,
+                               const OUString& rValue ) override;
 private:
     XMLTableTemplate maTableTemplate;
     OUString msTemplateStyleName;
@@ -743,20 +745,15 @@ XMLTableTemplateContext::XMLTableTemplateContext( SvXMLImport& rImport, sal_uInt
 {
 }
 
-void XMLTableTemplateContext::StartElement( const Reference< XAttributeList >& xAttrList )
+void XMLTableTemplateContext::SetAttribute( sal_uInt16 nPrefixKey,
+                               const OUString& rLocalName,
+                               const OUString& rValue )
 {
-    sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
-    for(sal_Int16 i=0; i < nAttrCount; i++)
+    if( (nPrefixKey == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_STYLE_NAME ))
+        // Writer specific: according to oasis odf 1.2 prefix should be "table" and element name should be "name"
+        || (nPrefixKey == XML_NAMESPACE_TABLE && IsXMLToken( rLocalName, XML_NAME )))
     {
-        OUString sAttrName;
-        sal_uInt16 nAttrPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( i ), &sAttrName );
-        if( (nAttrPrefix == XML_NAMESPACE_TEXT && IsXMLToken( sAttrName, XML_STYLE_NAME ))
-            // Writer specific: according to oasis odf 1.2 prefix should be "table" and element name should be "name"
-            || (nAttrPrefix == XML_NAMESPACE_TABLE && IsXMLToken( sAttrName, XML_NAME )))
-        {
-            msTemplateStyleName = xAttrList->getValueByIndex( i );
-            break;
-        }
+        msTemplateStyleName = rValue;
     }
 }
 
diff --git a/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx b/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx
index 3a0ce16d1fe6..3346fafb70d6 100644
--- a/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx
+++ b/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx
@@ -220,64 +220,56 @@ static SvXMLEnumMapEntry<sal_Int16> const aFootnoteNumberingMap[] =
     { XML_TOKEN_INVALID,    0 },
 };
 
-void XMLFootnoteConfigurationImportContext::StartElement(
-    const Reference<XAttributeList> & xAttrList )
+void XMLFootnoteConfigurationImportContext::SetAttribute( sal_uInt16 nPrefixKey,
+                               const OUString& rLocalName,
+                               const OUString& rValue )
 {
-    sal_Int16 nLength = xAttrList->getLength();
-    for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
+    switch (GetFtnConfigAttrTokenMap().Get(nPrefixKey, rLocalName))
     {
-        OUString sLocalName;
-        sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
-            GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
-                              &sLocalName );
-        OUString sValue = xAttrList->getValueByIndex(nAttr);
-        switch (GetFtnConfigAttrTokenMap().Get(nPrefix, sLocalName))
+        case XML_TOK_FTNCONFIG_CITATION_STYLENAME:
+            sCitationStyle = rValue;
+            break;
+        case XML_TOK_FTNCONFIG_ANCHOR_STYLENAME:
+            sAnchorStyle = rValue;
+            break;
+        case XML_TOK_FTNCONFIG_DEFAULT_STYLENAME:
+            sDefaultStyle = rValue;
+            break;
+        case XML_TOK_FTNCONFIG_PAGE_STYLENAME:
+            sPageStyle = rValue;
+            break;
+        case XML_TOK_FTNCONFIG_OFFSET:
         {
-            case XML_TOK_FTNCONFIG_CITATION_STYLENAME:
-                sCitationStyle = sValue;
-                break;
-            case XML_TOK_FTNCONFIG_ANCHOR_STYLENAME:
-                sAnchorStyle = sValue;
-                break;
-            case XML_TOK_FTNCONFIG_DEFAULT_STYLENAME:
-                sDefaultStyle = sValue;
-                break;
-            case XML_TOK_FTNCONFIG_PAGE_STYLENAME:
-                sPageStyle = sValue;
-                break;
-            case XML_TOK_FTNCONFIG_OFFSET:
+            sal_Int32 nTmp;
+            if (::sax::Converter::convertNumber(nTmp, rValue))
             {
-                sal_Int32 nTmp;
-                if (::sax::Converter::convertNumber(nTmp, sValue))
-                {
-                    nOffset = static_cast<sal_uInt16>(nTmp);
-                }
-                break;
+                nOffset = static_cast<sal_uInt16>(nTmp);
             }
-            case XML_TOK_FTNCONFIG_NUM_PREFIX:
-                sPrefix = sValue;
-                break;
-            case XML_TOK_FTNCONFIG_NUM_SUFFIX:
-                sSuffix = sValue;
-                break;
-            case XML_TOK_FTNCONFIG_NUM_FORMAT:
-                sNumFormat = sValue;
-                break;
-            case XML_TOK_FTNCONFIG_NUM_SYNC:
-                sNumSync = sValue;
-                break;
-            case XML_TOK_FTNCONFIG_START_AT:
-            {
-                (void)SvXMLUnitConverter::convertEnum(nNumbering, sValue,
-                                                      aFootnoteNumberingMap);
-                break;
-            }
-            case XML_TOK_FTNCONFIG_POSITION:
-                bPosition = IsXMLToken( sValue, XML_DOCUMENT );
-                break;
-            default:
-                ; // ignore
+            break;
         }
+        case XML_TOK_FTNCONFIG_NUM_PREFIX:
+            sPrefix = rValue;
+            break;
+        case XML_TOK_FTNCONFIG_NUM_SUFFIX:
+            sSuffix = rValue;
+            break;
+        case XML_TOK_FTNCONFIG_NUM_FORMAT:
+            sNumFormat = rValue;
+            break;
+        case XML_TOK_FTNCONFIG_NUM_SYNC:
+            sNumSync = rValue;
+            break;
+        case XML_TOK_FTNCONFIG_START_AT:
+        {
+            (void)SvXMLUnitConverter::convertEnum(nNumbering, rValue,
+                                                  aFootnoteNumberingMap);
+            break;
+        }
+        case XML_TOK_FTNCONFIG_POSITION:
+            bPosition = IsXMLToken( rValue, XML_DOCUMENT );
+            break;
+        default:
+            ; // ignore
     }
 }
 
diff --git a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
index 35fd6e61fd92..96c844af32f5 100644
--- a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
+++ b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
@@ -72,24 +72,7 @@ XMLIndexBibliographyConfigurationContext::~XMLIndexBibliographyConfigurationCont
 {
 }
 
-void XMLIndexBibliographyConfigurationContext::StartElement(
-    const Reference<XAttributeList> & xAttrList)
-{
-    sal_Int16 nLength = xAttrList->getLength();
-    for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
-    {
-        OUString sLocalName;
-        sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
-            GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
-                              &sLocalName );
-
-        ProcessAttribute(nPrefix, sLocalName,
-                         xAttrList->getValueByIndex(nAttr));
-        // else: ignore
-    }
-}
-
-void XMLIndexBibliographyConfigurationContext::ProcessAttribute(
+void XMLIndexBibliographyConfigurationContext::SetAttribute(
     sal_uInt16 nPrefix,
     const OUString& sLocalName,
     const OUString& sValue)
diff --git a/xmloff/source/text/XMLLineNumberingImportContext.cxx b/xmloff/source/text/XMLLineNumberingImportContext.cxx
index bfc192b3f907..6cd7f48575b9 100644
--- a/xmloff/source/text/XMLLineNumberingImportContext.cxx
+++ b/xmloff/source/text/XMLLineNumberingImportContext.cxx
@@ -77,8 +77,9 @@ XMLLineNumberingImportContext::~XMLLineNumberingImportContext()
 {
 }
 
-void XMLLineNumberingImportContext::StartElement(
-    const Reference<XAttributeList> & xAttrList)
+void XMLLineNumberingImportContext::SetAttribute( sal_uInt16 nPrefixKey,
+                               const OUString& rLocalName,
+                               const OUString& rValue )
 {
     static const SvXMLTokenMapEntry aLineNumberingTokenMap[] =
     {
@@ -109,56 +110,40 @@ void XMLLineNumberingImportContext::StartElement(
 
     static const SvXMLTokenMap aTokenMap(aLineNumberingTokenMap);
 
-    // process attributes
-    sal_Int16 nLength = xAttrList->getLength();
-    for(sal_Int16 i=0; i<nLength; i++)
-    {
-        OUString sLocalName;
-        sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
-            GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
-
-        ProcessAttribute(
-            static_cast<enum LineNumberingToken>(aTokenMap.Get(nPrefix, sLocalName)),
-            xAttrList->getValueByIndex(i));
-    }
-}
+    enum LineNumberingToken eToken = static_cast<enum LineNumberingToken>(aTokenMap.Get(nPrefixKey, rLocalName));
 
-void XMLLineNumberingImportContext::ProcessAttribute(
-    enum LineNumberingToken eToken,
-    const OUString& sValue)
-{
     bool bTmp(false);
     sal_Int32 nTmp;
 
     switch (eToken)
     {
         case XML_TOK_LINENUMBERING_STYLE_NAME:
-            sStyleName = sValue;
+            sStyleName = rValue;
             break;
 
         case XML_TOK_LINENUMBERING_NUMBER_LINES:
-            if (::sax::Converter::convertBool(bTmp, sValue))
+            if (::sax::Converter::convertBool(bTmp, rValue))
             {
                 bNumberLines = bTmp;
             }
             break;
 
         case XML_TOK_LINENUMBERING_COUNT_EMPTY_LINES:
-            if (::sax::Converter::convertBool(bTmp, sValue))
+            if (::sax::Converter::convertBool(bTmp, rValue))
             {
                 bCountEmptyLines = bTmp;
             }
             break;
 
         case XML_TOK_LINENUMBERING_COUNT_IN_TEXT_BOXES:
-            if (::sax::Converter::convertBool(bTmp, sValue))
+            if (::sax::Converter::convertBool(bTmp, rValue))
             {
                 bCountInFloatingFrames = bTmp;
             }
             break;
 
         case XML_TOK_LINENUMBERING_RESTART_NUMBERING:
-            if (::sax::Converter::convertBool(bTmp, sValue))
+            if (::sax::Converter::convertBool(bTmp, rValue))
             {
                 bRestartNumbering = bTmp;
             }
@@ -166,18 +151,18 @@ void XMLLineNumberingImportContext::ProcessAttribute(
 
         case XML_TOK_LINENUMBERING_OFFSET:
             if (GetImport().GetMM100UnitConverter().
-                    convertMeasureToCore(nTmp, sValue))
+                    convertMeasureToCore(nTmp, rValue))
             {
                 nOffset = nTmp;
             }
             break;
 
         case XML_TOK_LINENUMBERING_NUM_FORMAT:
-            sNumFormat = sValue;
+            sNumFormat = rValue;
             break;
 
         case XML_TOK_LINENUMBERING_NUM_LETTER_SYNC:
-            sNumLetterSync = sValue;
+            sNumLetterSync = rValue;
             break;
 
         case XML_TOK_LINENUMBERING_NUMBER_POSITION:
@@ -191,13 +176,13 @@ void XMLLineNumberingImportContext::ProcessAttribute(
                 { XML_TOKEN_INVALID, 0 }
             };
 
-            (void)SvXMLUnitConverter::convertEnum(nNumberPosition, sValue,
+            (void)SvXMLUnitConverter::convertEnum(nNumberPosition, rValue,
                                                   aLineNumberPositionMap);
             break;
         }
 
         case XML_TOK_LINENUMBERING_INCREMENT:
-            if (::sax::Converter::convertNumber(nTmp, sValue, 0))
+            if (::sax::Converter::convertNumber(nTmp, rValue, 0))
             {
                 nIncrement = static_cast<sal_Int16>(nTmp);
             }


More information about the Libreoffice-commits mailing list