[Libreoffice-commits] core.git: 2 commits - sax/source writerfilter/CustomTarget_source.mk writerfilter/source

Cédric Bosdonnat cedric.bosdonnat at free.fr
Wed Jul 3 06:18:41 PDT 2013


 sax/source/fastparser/fastparser.cxx                  |    2 
 writerfilter/CustomTarget_source.mk                   |    1 
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |   33 +++++++++++---
 writerfilter/source/ooxml/OOXMLFastContextHandler.hxx |    1 
 writerfilter/source/ooxml/model.xml                   |   40 ++++++++++++++++++
 5 files changed, 68 insertions(+), 9 deletions(-)

New commits:
commit af7d4a5ebf3e6a09cd2079f241dee16aa22e0276
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)

diff --git a/writerfilter/CustomTarget_source.mk b/writerfilter/CustomTarget_source.mk
index 2c467ed..01be99b 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 3adc48b..873ee97 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 45e91e6..5a72be2 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 e0d35a9..4eb2392 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -31,6 +31,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"/>
@@ -12159,6 +12160,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"/>
commit 1c23a37710e27fdc368876738a6eb91fd32e96d4
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Tue Jul 2 15:46:59 2013 +0200

    fastsax: provide the element name instead of prefix for unknown elements
    
    Change-Id: I3effd8a0cfe57875446536bbd0a93a73e630a44f
    (cherry picked from commit 4946cc813704703f7d988a6acf75c4d9e9c068a9)

diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index d373762..71dc093 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -812,7 +812,7 @@ void FastSaxParser::callbackStartElement( const XML_Char* pwName, const XML_Char
                 rEntity.maContextStack.top()->maNamespace = GetNamespaceURL( pPrefix, nPrefixLen );
 
             const OUString aNamespace( rEntity.maContextStack.top()->maNamespace );
-            const OUString aElementName( pPrefix, nPrefixLen, RTL_TEXTENCODING_UTF8 );
+            const OUString aElementName( pName, nNameLen, RTL_TEXTENCODING_UTF8 );
             rEntity.maContextStack.top()->maElementName = aElementName;
 
             if( xParentContext.is() )


More information about the Libreoffice-commits mailing list