diff options
author | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2013-07-03 14:47:02 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2013-07-03 14:54:10 +0200 |
commit | f4112ce9e7840efbcd567c4d18ed4519a1e91294 (patch) | |
tree | fe724b88f9a1bd4d17f085c0cd92e5a35c496456 | |
parent | fastsax: provide the element name instead of prefix for unknown elements (diff) | |
download | core-f4112ce9e7840efbcd567c4d18ed4519a1e91294.tar.gz core-f4112ce9e7840efbcd567c4d18ed4519a1e91294.zip |
n#820503: initial MCE support in writerfilter ooxml tokenizer
writerfilter OOXML tokenizer was just ignoring the mce elements and thus
getting the Choice content and the Fallback one. This initial support
drops all mc:Choice contents to read mc:Fallback. At least for drawingML
vs VML support, we have a much better support of the fallback.
Change-Id: Ic0bf69d0436994e9cfcf38accdd57d17e9f391fe
-rw-r--r-- | writerfilter/CustomTarget_source.mk | 1 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 33 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLFastContextHandler.hxx | 1 | ||||
-rw-r--r-- | writerfilter/source/ooxml/model.xml | 40 |
4 files changed, 67 insertions, 8 deletions
diff --git a/writerfilter/CustomTarget_source.mk b/writerfilter/CustomTarget_source.mk index 0ffd8d95d20f..890349768c93 100644 --- a/writerfilter/CustomTarget_source.mk +++ b/writerfilter/CustomTarget_source.mk @@ -38,6 +38,7 @@ writerfilter_OOXMLNAMESPACES= \ vml-main \ vml-officeDrawing \ vml-wordprocessingDrawing \ + mce \ wml writerfilter_ALL = \ diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index 7964c3e7844f..d4068560a9f9 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -127,7 +127,8 @@ OOXMLFastContextHandler::OOXMLFastContextHandler mnInstanceNumber(mnInstanceCount), mnRefCount(0), inPositionV(false), - m_xContext(context) + m_xContext(context), + m_bDiscardChildren(false) { mnInstanceCount++; aSetContexts.insert(this); @@ -150,7 +151,8 @@ OOXMLFastContextHandler::OOXMLFastContextHandler mnInstanceNumber(mnInstanceCount), mnRefCount(0), inPositionV(pContext->inPositionV), - m_xContext(pContext->m_xContext) + m_xContext(pContext->m_xContext), + m_bDiscardChildren(pContext->m_bDiscardChildren) { if (pContext != NULL) { @@ -190,8 +192,14 @@ void SAL_CALL OOXMLFastContextHandler::startFastElement dumpXml( debug_logger ); debug_logger->endElement(); #endif - attributes(Attribs); - lcl_startFastElement(Element, Attribs); + if ((Element & 0xffff0000) == NS_mce && (Element & 0xffff) == OOXML_Choice) + m_bDiscardChildren = true; + + if (!m_bDiscardChildren) + { + attributes(Attribs); + lcl_startFastElement(Element, Attribs); + } } void SAL_CALL OOXMLFastContextHandler::startUnknownElement @@ -218,7 +226,11 @@ throw (uno::RuntimeException, xml::sax::SAXException) (void) sToken; #endif - lcl_endFastElement(Element); + if ((Element & 0xffff0000) == NS_mce && (Element & 0xffff) == OOXML_Choice) + m_bDiscardChildren = false; + + if (!m_bDiscardChildren) + lcl_endFastElement(Element); #ifdef DEBUG_CONTEXT_HANDLER debug_logger->startElement("at-end"); @@ -269,10 +281,14 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL debug_logger->startElement("contexthandler.createFastChildContext"); debug_logger->attribute("token", fastTokenToId(Element)); debug_logger->attribute("type", getType()); + debug_logger->attribute("discard-children", OUString::valueOf(m_bDiscardChildren)); #endif - uno::Reference< xml::sax::XFastContextHandler > xResult - (lcl_createFastChildContext(Element, Attribs)); + uno::Reference< xml::sax::XFastContextHandler > xResult; + if ((Element & 0xffff0000) != NS_mce && !m_bDiscardChildren) + xResult.set(lcl_createFastChildContext(Element, Attribs)); + else if ((Element & 0xffff0000) == NS_mce) + xResult = this; #ifdef DEBUG_CONTEXT_HANDLER debug_logger->endElement(); @@ -322,7 +338,8 @@ void OOXMLFastContextHandler::lcl_characters (const OUString & rString) throw (uno::RuntimeException, xml::sax::SAXException) { - OOXMLFactory::getInstance()->characters(this, rString); + if (!m_bDiscardChildren) + OOXMLFactory::getInstance()->characters(this, rString); } namespace diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx index b1941b65c179..e267ae6dc13c 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx @@ -289,6 +289,7 @@ private: void operator =(OOXMLFastContextHandler &); // not defined uno::Reference< uno::XComponentContext > m_xContext; + bool m_bDiscardChildren; static sal_uInt32 mnInstanceCount; diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index 6fc27981d1d6..6f27ef66e844 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -30,6 +30,7 @@ <namespace-alias name="http://schemas.openxmlformats.org/wordprocessingml/2006/main" alias="wordprocessingml" id="doc"/> <namespace-alias name="http://schemas.openxmlformats.org/officeDocument/2006/math" alias="math" id="officeMath"/> <namespace-alias name="http://schemas.openxmlformats.org/schemaLibrary/2006/main" alias="schemaLibrary" id="schema"/> + <namespace-alias name="http://schemas.openxmlformats.org/markup-compatibility/2006" alias="mce" id="mce"/> <namespace-alias name="http://sprm" alias="sprm" id="sprm"/> <token tokenid="ooxml:shape"/> <token tokenid="ooxml:token"/> @@ -12136,6 +12137,45 @@ <value name="background" tokenid="ooxml:Value_office_ST_FillType_background">background</value> </resource> </namespace> + <namespace name="mce"> + <start name="AlternateContent"/> + <grammar xmlns="http://relaxng.org/ns/structure/1.0" ns="http://schemas.openxmlformats.org/markup-compatibility/2006" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> + <define name="nsList"> + <list> + <zeroOrMore> + <data type="NCName"/> + </zeroOrMore> + </list> + </define> + <define name="AlternateContent"> + <element name="AlternateContent"> + <oneOrMore> + <ref name="choice"/> + </oneOrMore> + <optional> + <ref name="fallback"/> + </optional> + </element> + </define> + <define name="Choice"> + <element name="Choice"> + <attribute name="Requires"> + <ref name="nsList"/> + </attribute> + <text/> + </element> + </define> + <define name="Fallback"> + <element name="Fallback"> + <text/> + </element> + </define> + </grammar> + <resource name="AlternateContent" resource="Value"/> + <resource name="Choice" resource="Value"> + <attribute name="Requires" tokenid="ooxml:mc_Requires"/> + </resource> + </namespace> <namespace name="vml-wordprocessingDrawing" file="vml-wordprocessingDrawing.rng"> <start name="bordertop"/> <start name="borderleft"/> |