Kaydet (Commit) d5d7c7d3 authored tarafından Miklos Vajna's avatar Miklos Vajna

writerfilter: introduce ooxml::OOXMLUniversalMeasureValue

In transitional DOCX, ST_UniversalMeasure is in practice a simple integer,
which means twips. But in case of strict, ST_UniversalMeasure is in points
in practice -- which is perfectly valid, but we didn't handle it so far.

Add a separate Value class that is used only for handling
ST_UniversalMeasure, then there we can handle the various additional
suffixes.

Change-Id: Iebb1ee859076595594d1455a1f826841dae77a0b
üst 28f7f5f6
...@@ -202,6 +202,18 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler, ...@@ -202,6 +202,18 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
pFactory->attributeAction(pHandler, aIt->first, pValue); pFactory->attributeAction(pHandler, aIt->first, pValue);
} }
break; break;
case RT_UniversalMeasure:
{
#ifdef DEBUG_FACTORY
debug_logger->element("universalMeasure");
#endif
OUString aValue(Attribs->getValue(aIt->first));
OOXMLFastHelper<OOXMLUniversalMeasureValue>::newProperty(pHandler, nId, aValue);
OOXMLValue::Pointer_t pValue(new OOXMLUniversalMeasureValue(aValue));
pFactory->attributeAction(pHandler, aIt->first, pValue);
}
break;
case RT_List: case RT_List:
{ {
#ifdef DEBUG_FACTORY #ifdef DEBUG_FACTORY
......
...@@ -54,7 +54,8 @@ enum ResourceType_t { ...@@ -54,7 +54,8 @@ enum ResourceType_t {
RT_TextTable, RT_TextTable,
RT_PropertyTable, RT_PropertyTable,
RT_Math, RT_Math,
RT_Any RT_Any,
RT_UniversalMeasure
}; };
struct AttributeInfo struct AttributeInfo
......
...@@ -661,6 +661,37 @@ string OOXMLHexValue::toString() const ...@@ -661,6 +661,37 @@ string OOXMLHexValue::toString() const
return buffer; return buffer;
} }
// OOXMLUniversalMeasureValue
OOXMLUniversalMeasureValue::OOXMLUniversalMeasureValue(sal_uInt32 nValue)
: mnValue(nValue)
{
}
OOXMLUniversalMeasureValue::OOXMLUniversalMeasureValue(const OUString& rValue)
{
mnValue = rValue.toInt32();
}
OOXMLUniversalMeasureValue::~OOXMLUniversalMeasureValue()
{
}
int OOXMLUniversalMeasureValue::getInt() const
{
return mnValue;
}
OOXMLValue* OOXMLUniversalMeasureValue::clone() const
{
return new OOXMLUniversalMeasureValue(*this);
}
string OOXMLUniversalMeasureValue::toString() const
{
return OString::number(mnValue).getStr();
}
/* /*
class OOXMLShapeValue class OOXMLShapeValue
*/ */
......
...@@ -214,6 +214,21 @@ public: ...@@ -214,6 +214,21 @@ public:
virtual OOXMLValue * clone() const; virtual OOXMLValue * clone() const;
}; };
/// Handles OOXML's ST_UniversalMeasure value.
class OOXMLUniversalMeasureValue : public OOXMLValue
{
protected:
sal_uInt32 mnValue;
public:
explicit OOXMLUniversalMeasureValue(sal_uInt32 nValue);
explicit OOXMLUniversalMeasureValue(const OUString& rValue);
virtual ~OOXMLUniversalMeasureValue();
virtual int getInt() const;
virtual string toString() const;
virtual OOXMLValue* clone() const;
};
class OOXMLShapeValue : public OOXMLValue class OOXMLShapeValue : public OOXMLValue
{ {
protected: protected:
......
...@@ -101,6 +101,7 @@ uno::Reference&lt; xml::sax::XFastContextHandler &gt; OOXMLFactory::createFastCh ...@@ -101,6 +101,7 @@ uno::Reference&lt; xml::sax::XFastContextHandler &gt; OOXMLFactory::createFastCh
<xsl:if test="generate-id(key('resources', @resource)) = generate-id(.)"> <xsl:if test="generate-id(key('resources', @resource)) = generate-id(.)">
<xsl:if test="not(@resource = 'Hex' or <xsl:if test="not(@resource = 'Hex' or
@resource = 'Integer' or @resource = 'Integer' or
@resource = 'UniversalMeasure' or
@resource = 'Boolean' or @resource = 'Boolean' or
@resource = 'List' or @resource = 'List' or
@resource = 'String')"> @resource = 'String')">
......
...@@ -9902,7 +9902,7 @@ ...@@ -9902,7 +9902,7 @@
<resource name="CT_OMathJc" resource="Value" generated="yes" tag="math"> <resource name="CT_OMathJc" resource="Value" generated="yes" tag="math">
<attribute name="val" tokenid="ooxml:CT_OMathJc_val" action="setValue"/> <attribute name="val" tokenid="ooxml:CT_OMathJc_val" action="setValue"/>
</resource> </resource>
<resource name="ST_TwipsMeasure" resource="Integer" generated="yes"/> <resource name="ST_TwipsMeasure" resource="UniversalMeasure"/>
<resource name="CT_TwipsMeasure" resource="Value" generated="yes" tag="math"> <resource name="CT_TwipsMeasure" resource="Value" generated="yes" tag="math">
<attribute name="val" tokenid="ooxml:CT_TwipsMeasure_val" action="setValue"/> <attribute name="val" tokenid="ooxml:CT_TwipsMeasure_val" action="setValue"/>
<action name="start" action="setDefaultIntegerValue"/> <action name="start" action="setDefaultIntegerValue"/>
...@@ -22991,7 +22991,7 @@ ...@@ -22991,7 +22991,7 @@
<action name="start" action="setDefaultIntegerValue"/> <action name="start" action="setDefaultIntegerValue"/>
</resource> </resource>
<resource name="ST_UnsignedDecimalNumber" resource="Integer" generated="yes"/> <resource name="ST_UnsignedDecimalNumber" resource="Integer" generated="yes"/>
<resource name="ST_TwipsMeasure" resource="Integer"/> <resource name="ST_TwipsMeasure" resource="UniversalMeasure"/>
<resource name="CT_TwipsMeasure" resource="Value" tag="attribute"> <resource name="CT_TwipsMeasure" resource="Value" tag="attribute">
<attribute name="val" tokenid="ooxml:CT_TwipsMeasure_val" action="setValue"/> <attribute name="val" tokenid="ooxml:CT_TwipsMeasure_val" action="setValue"/>
<action name="start" action="setDefaultIntegerValue"/> <action name="start" action="setDefaultIntegerValue"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment