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

Noel Grandin noel.grandin at collabora.co.uk
Mon Feb 6 05:47:08 UTC 2017


 writerfilter/source/ooxml/OOXMLFactory.cxx  |   12 +++----
 writerfilter/source/ooxml/OOXMLFactory.hxx  |   47 +++++++++++++---------------
 writerfilter/source/ooxml/factory_ns.py     |    2 -
 writerfilter/source/ooxml/factoryimpl.py    |    6 +--
 writerfilter/source/ooxml/factoryimpl_ns.py |    8 ++--
 5 files changed, 37 insertions(+), 38 deletions(-)

New commits:
commit 005ef926c692f790cd319130243cb053ef9af26c
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Feb 3 15:04:48 2017 +0200

    writerfilter: convert ResourceType to scoped enum
    
    and drop unused constant StreamProperties
    
    Change-Id: I6a358cf7914412231d6c8f926a0d2fbd4bb8009b
    Reviewed-on: https://gerrit.libreoffice.org/33885
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/writerfilter/source/ooxml/OOXMLFactory.cxx b/writerfilter/source/ooxml/OOXMLFactory.cxx
index 4227ae2..ff65144 100644
--- a/writerfilter/source/ooxml/OOXMLFactory.cxx
+++ b/writerfilter/source/ooxml/OOXMLFactory.cxx
@@ -63,7 +63,7 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
 
         switch (pAttr->m_nResource)
         {
-        case RT_Boolean:
+        case ResourceType::Boolean:
             {
                 const char *pValue = "";
                 pAttribs->getAsChar(nToken, pValue);
@@ -72,7 +72,7 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
                 pFactory->attributeAction(pHandler, nToken, xValue);
             }
             break;
-        case RT_String:
+        case ResourceType::String:
             {
                 OUString aValue(pAttribs->getValue(nToken));
                 OOXMLValue::Pointer_t xValue(new OOXMLStringValue(aValue));
@@ -80,7 +80,7 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
                 pFactory->attributeAction(pHandler, nToken, xValue);
             }
             break;
-        case RT_Integer:
+        case ResourceType::Integer:
             {
                 sal_Int32 nValue;
                 pAttribs->getAsInteger(nToken,nValue);
@@ -89,7 +89,7 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
                 pFactory->attributeAction(pHandler, nToken, xValue);
             }
             break;
-        case RT_Hex:
+        case ResourceType::Hex:
             {
                 const char *pValue = "";
                 pAttribs->getAsChar(nToken, pValue);
@@ -98,7 +98,7 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
                 pFactory->attributeAction(pHandler, nToken, xValue);
             }
             break;
-        case RT_UniversalMeasure:
+        case ResourceType::UniversalMeasure:
             {
                 const char *pValue = "";
                 pAttribs->getAsChar(nToken, pValue);
@@ -107,7 +107,7 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
                 pFactory->attributeAction(pHandler, nToken, xValue);
             }
             break;
-        case RT_List:
+        case ResourceType::List:
             {
                 sal_uInt32 nValue;
                 if (pFactory->getListValue(pAttr->m_nRef, Attribs->getValue(nToken), nValue))
diff --git a/writerfilter/source/ooxml/OOXMLFactory.hxx b/writerfilter/source/ooxml/OOXMLFactory.hxx
index e1f7a63..574550b 100644
--- a/writerfilter/source/ooxml/OOXMLFactory.hxx
+++ b/writerfilter/source/ooxml/OOXMLFactory.hxx
@@ -32,34 +32,33 @@
 namespace writerfilter {
 namespace ooxml {
 
-enum ResourceType_t {
-    RT_NoResource,
-    RT_Table,
-    RT_Stream,
-    RT_StreamProperties,
-    RT_List,
-    RT_Integer,
-    RT_Properties,
-    RT_Hex,
-    RT_String,
-    RT_Shape,
-    RT_Boolean,
-    RT_HexValue,
-    RT_Value,
-    RT_XNote,
-    RT_TextTableCell,
-    RT_TextTableRow,
-    RT_TextTable,
-    RT_PropertyTable,
-    RT_Math,
-    RT_Any,
-    RT_UniversalMeasure
+enum class ResourceType {
+    NoResource,
+    Table,
+    Stream,
+    List,
+    Integer,
+    Properties,
+    Hex,
+    String,
+    Shape,
+    Boolean,
+    HexValue,
+    Value,
+    XNote,
+    TextTableCell,
+    TextTableRow,
+    TextTable,
+    PropertyTable,
+    Math,
+    Any,
+    UniversalMeasure
 };
 
 struct AttributeInfo
 {
     Token_t m_nToken;
-    ResourceType_t m_nResource;
+    ResourceType m_nResource;
     Id m_nRef;
 };
 
@@ -79,7 +78,7 @@ public:
     virtual bool getListValue(Id nId, const OUString& rValue, sal_uInt32& rOutValue) = 0;
     virtual Id getResourceId(Id nDefine, sal_Int32 nToken) = 0;
     virtual const AttributeInfo* getAttributeInfoArray(Id nId) = 0;
-    virtual bool getElementId(Id nDefine, Id nId, ResourceType_t& rOutResource, Id& rOutElement) = 0;
+    virtual bool getElementId(Id nDefine, Id nId, ResourceType& rOutResource, Id& rOutElement) = 0;
 };
 
 class OOXMLFactory
diff --git a/writerfilter/source/ooxml/factory_ns.py b/writerfilter/source/ooxml/factory_ns.py
index be990dc..54afd1e 100644
--- a/writerfilter/source/ooxml/factory_ns.py
+++ b/writerfilter/source/ooxml/factory_ns.py
@@ -36,7 +36,7 @@ public:
     static Pointer_t getInstance();
 
     virtual const AttributeInfo* getAttributeInfoArray(Id nId);
-    virtual bool getElementId(Id nDefine, Id nId, ResourceType_t& rOutResource, Id& rOutElement);
+    virtual bool getElementId(Id nDefine, Id nId, ResourceType& rOutResource, Id& rOutElement);
     virtual bool getListValue(Id nId, const OUString& rValue, sal_uInt32& rOutValue);
     virtual Id getResourceId(Id nDefine, sal_Int32 nToken);
 """ % nsToken)
diff --git a/writerfilter/source/ooxml/factoryimpl.py b/writerfilter/source/ooxml/factoryimpl.py
index dbb391c..1e172c5 100644
--- a/writerfilter/source/ooxml/factoryimpl.py
+++ b/writerfilter/source/ooxml/factoryimpl.py
@@ -29,7 +29,7 @@ def createFastChildContextFromFactory(model):
 
     if (pFactory.get() != NULL)
     {
-        ResourceType_t nResource;
+        ResourceType nResource;
         Id nElementId;
         if (pFactory->getElementId(nDefine, Element, nResource, nElementId))
         {
@@ -41,10 +41,10 @@ def createFastChildContextFromFactory(model):
     for resource in [r.getAttribute("resource") for r in model.getElementsByTagName("resource")]:
         if resource not in resources:
             resources.append(resource)
-            print("""            case RT_%s:
+            print("""            case ResourceType::%s:
                 aResult.set(OOXMLFastHelper<OOXMLFastContextHandler%s>::createAndSetParentAndDefine(pHandler, Element, nId, nElementId));
                 break;""" % (resource, resource))
-    print("""            case RT_Any:
+    print("""            case ResourceType::Any:
                 aResult.set(createFastChildContextFromStart(pHandler, Element));
                 break;
             default:
diff --git a/writerfilter/source/ooxml/factoryimpl_ns.py b/writerfilter/source/ooxml/factoryimpl_ns.py
index cee40a7..80e0c84 100644
--- a/writerfilter/source/ooxml/factoryimpl_ns.py
+++ b/writerfilter/source/ooxml/factoryimpl_ns.py
@@ -151,7 +151,7 @@ def collectAttributeToResource(nsNode, defineNode):
                 refName = refNode.getAttribute("name")
                 for define in [i for i in getChildrenByName(getChildByName(nsNode, "grammar"), "define") if i.getAttribute("name") == refName]:
                     refDefine = idForDefine(nsNode, define)
-            ret_dict[attrToken] = "RT_%s, %s" % (resourceName, refDefine)
+            ret_dict[attrToken] = "ResourceType::%s, %s" % (resourceName, refDefine)
             ret_order.append(attrToken)
 
     return [ret_dict, ret_order]
@@ -181,7 +181,7 @@ def factoryAttributeToResourceMap(nsNode):
             print("        {")
             print("            const static AttributeInfo info[] = {")
             print(inner)
-            print("                { -1, RT_NoResource, 0 }")
+            print("                { -1, ResourceType::NoResource, 0 }")
             print("            };")
             print("            return info;")
             print("        }")
@@ -339,7 +339,7 @@ def factoryCreateElementMapInner(files, nsNode, defineNode, resourceNamespaceNod
             if len(resource):
                 break
         if len(resource):
-            ret[fastToken(elementNode)] = "        case %s: rOutResource = RT_%s; rOutElement = %s; break;" % (fastToken(elementNode), resource, idForRef(nsNode, getChildByName(elementNode, "ref")))
+            ret[fastToken(elementNode)] = "        case %s: rOutResource = ResourceType::%s; rOutElement = %s; break;" % (fastToken(elementNode), resource, idForRef(nsNode, getChildByName(elementNode, "ref")))
 
     return ret
 
@@ -357,7 +357,7 @@ def factoryCreateElementMapFromStart(files, nsNode):
 
 
 def factoryCreateElementMap(files, nsNode):
-    print("""bool OOXMLFactory_%s::getElementId(Id nDefine, Id nId, ResourceType_t& rOutResource, Id& rOutElement)
+    print("""bool OOXMLFactory_%s::getElementId(Id nDefine, Id nId, ResourceType& rOutResource, Id& rOutElement)
 {
     (void) rOutResource;
     (void) rOutElement;


More information about the Libreoffice-commits mailing list