writerfilter/source/ooxml/OOXMLFactory.cxx |   81 +++++++----------------------
 1 file changed, 22 insertions(+), 59 deletions(-)

New commits:
commit 22787b05a8e882533f2e834e2cc62368881a22e7
Author:     Mike Kaganski <[email protected]>
AuthorDate: Fri Apr 16 08:11:31 2021 +0200
Commit:     Mike Kaganski <[email protected]>
CommitDate: Fri Apr 16 09:21:44 2021 +0200

    Small refactor
    
    Change-Id: I5fb506986e650cde1d6be7e4cfb2360335ab625b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114175
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/writerfilter/source/ooxml/OOXMLFactory.cxx 
b/writerfilter/source/ooxml/OOXMLFactory.cxx
index 51d6ada11dab..9e52c2b4c9e6 100644
--- a/writerfilter/source/ooxml/OOXMLFactory.cxx
+++ b/writerfilter/source/ooxml/OOXMLFactory.cxx
@@ -55,92 +55,55 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * 
pHandler,
 
         Id nId = pFactory->getResourceId(nDefine, nToken);
 
+        OOXMLValue::Pointer_t xValue;
         switch (pAttr->m_nResource)
         {
         case ResourceType::Boolean:
-            {
-                const char *pValue = rAttribs.getAsCharByIndex(nAttrIndex);
-                OOXMLValue::Pointer_t 
xValue(OOXMLBooleanValue::Create(pValue));
-                pHandler->newProperty(nId, xValue);
-                pFactory->attributeAction(pHandler, nToken, xValue);
-            }
+            xValue = 
OOXMLBooleanValue::Create(rAttribs.getAsCharByIndex(nAttrIndex));
             break;
         case ResourceType::String:
-            {
-                OUString aValue(rAttribs.getValueByIndex(nAttrIndex));
-                OOXMLValue::Pointer_t xValue(new OOXMLStringValue(aValue));
-                pHandler->newProperty(nId, xValue);
-                pFactory->attributeAction(pHandler, nToken, xValue);
-            }
+            xValue = new 
OOXMLStringValue(rAttribs.getValueByIndex(nAttrIndex));
             break;
         case ResourceType::Integer:
-            {
-                sal_Int32 nValue = rAttribs.getAsIntegerByIndex(nAttrIndex);
-                OOXMLValue::Pointer_t xValue = 
OOXMLIntegerValue::Create(nValue);
-                pHandler->newProperty(nId, xValue);
-                pFactory->attributeAction(pHandler, nToken, xValue);
-            }
+            xValue = 
OOXMLIntegerValue::Create(rAttribs.getAsIntegerByIndex(nAttrIndex));
             break;
         case ResourceType::Hex:
-            {
-                const char *pValue = rAttribs.getAsCharByIndex(nAttrIndex);
-                OOXMLValue::Pointer_t xValue(new OOXMLHexValue(pValue));
-                pHandler->newProperty(nId, xValue);
-                pFactory->attributeAction(pHandler, nToken, xValue);
-            }
+            xValue = new OOXMLHexValue(rAttribs.getAsCharByIndex(nAttrIndex));
             break;
         case ResourceType::HexColor:
-            {
-                const char *pValue = rAttribs.getAsCharByIndex(nAttrIndex);
-                OOXMLValue::Pointer_t xValue(new OOXMLHexColorValue(pValue));
-                pHandler->newProperty(nId, xValue);
-                pFactory->attributeAction(pHandler, nToken, xValue);
-            }
+            xValue = new 
OOXMLHexColorValue(rAttribs.getAsCharByIndex(nAttrIndex));
             break;
         case ResourceType::TwipsMeasure_asSigned:
         case ResourceType::TwipsMeasure_asZero:
+            xValue = new 
OOXMLTwipsMeasureValue(rAttribs.getAsCharByIndex(nAttrIndex));
+            if (xValue->getInt() < 0)
             {
-                const char *pValue = rAttribs.getAsCharByIndex(nAttrIndex);
-                OOXMLValue::Pointer_t xValue(new 
OOXMLTwipsMeasureValue(pValue));
-                if ( xValue->getInt() < 0 )
-                {
-                    if ( pAttr->m_nResource == 
ResourceType::TwipsMeasure_asZero )
-                        xValue = OOXMLIntegerValue::Create(0);
-                }
-                pHandler->newProperty(nId, xValue);
-                pFactory->attributeAction(pHandler, nToken, xValue);
+                if (pAttr->m_nResource == ResourceType::TwipsMeasure_asZero)
+                    xValue = OOXMLIntegerValue::Create(0);
             }
             break;
         case ResourceType::HpsMeasure:
-            {
-                const char *pValue = rAttribs.getAsCharByIndex(nAttrIndex);
-                OOXMLValue::Pointer_t xValue(new OOXMLHpsMeasureValue(pValue));
-                pHandler->newProperty(nId, xValue);
-                pFactory->attributeAction(pHandler, nToken, xValue);
-            }
-        break;
+            xValue = new 
OOXMLHpsMeasureValue(rAttribs.getAsCharByIndex(nAttrIndex));
+            break;
         case ResourceType::MeasurementOrPercent:
-            {
-                const char *pValue = rAttribs.getAsCharByIndex(nAttrIndex);
-                OOXMLValue::Pointer_t xValue(new 
OOXMLMeasurementOrPercentValue(pValue));
-                pHandler->newProperty(nId, xValue);
-                pFactory->attributeAction(pHandler, nToken, xValue);
-            }
+            xValue = new 
OOXMLMeasurementOrPercentValue(rAttribs.getAsCharByIndex(nAttrIndex));
             break;
         case ResourceType::List:
+            if (sal_uInt32 nValue;
+                pFactory->getListValue(pAttr->m_nRef, 
rAttribs.getValueByIndex(nAttrIndex), nValue))
             {
-                sal_uInt32 nValue;
-                if (pFactory->getListValue(pAttr->m_nRef, 
rAttribs.getValueByIndex(nAttrIndex), nValue))
-                {
-                    OOXMLValue::Pointer_t xValue = 
OOXMLIntegerValue::Create(nValue);
-                    pHandler->newProperty(nId, xValue);
-                    pFactory->attributeAction(pHandler, nToken, xValue);
-                }
+                xValue = OOXMLIntegerValue::Create(nValue);
             }
             break;
         default:
             break;
         }
+
+        if (xValue)
+        {
+            pHandler->newProperty(nId, xValue);
+            pFactory->attributeAction(pHandler, nToken, xValue);
+        }
     }
 }
 
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to