[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - writerfilter/CustomTarget_source.mk writerfilter/source
Cédric Bosdonnat
cedric.bosdonnat at free.fr
Thu Jul 4 00:47:44 PDT 2013
writerfilter/CustomTarget_source.mk | 1
writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 33 +++++++++++---
writerfilter/source/ooxml/OOXMLFastContextHandler.hxx | 1
writerfilter/source/ooxml/model.xml | 40 ++++++++++++++++++
4 files changed, 67 insertions(+), 8 deletions(-)
New commits:
commit 64b78886221e7c63f593f9cd4ba2f9097c1be47b
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date: Wed Jul 3 14:47:02 2013 +0200
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
(cherry picked from commit f4112ce9e7840efbcd567c4d18ed4519a1e91294)
Reviewed-on: https://gerrit.libreoffice.org/4705
Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
Tested-by: Fridrich Strba <fridrich at documentfoundation.org>
diff --git a/writerfilter/CustomTarget_source.mk b/writerfilter/CustomTarget_source.mk
index 0ffd8d9..8903497 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 aae56aa..403bc32 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 b47f611..39bbcac 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 1886188..e4af319 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"/>
More information about the Libreoffice-commits
mailing list