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

Sync oox -> writerfilter namespace prefixes

Change-Id: Ifbcb7716640cd05d4b98eef22f9ddf49f3bd79aa
üst 63fa1a7b
...@@ -217,7 +217,7 @@ void SAL_CALL OOXMLFastContextHandler::startFastElement ...@@ -217,7 +217,7 @@ void SAL_CALL OOXMLFastContextHandler::startFastElement
const uno::Reference< xml::sax::XFastAttributeList > & Attribs) const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
throw (uno::RuntimeException, xml::sax::SAXException, std::exception) throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
{ {
if (oox::getNamespace(Element) == static_cast<sal_Int32>(NS_mce)) if (oox::getNamespace(Element) == static_cast<sal_Int32>(NMSP_mce))
m_bDiscardChildren = prepareMceContext(Element, Attribs); m_bDiscardChildren = prepareMceContext(Element, Attribs);
else if (!m_bDiscardChildren) else if (!m_bDiscardChildren)
...@@ -237,9 +237,9 @@ throw (uno::RuntimeException, xml::sax::SAXException, std::exception) ...@@ -237,9 +237,9 @@ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
void SAL_CALL OOXMLFastContextHandler::endFastElement(Token_t Element) void SAL_CALL OOXMLFastContextHandler::endFastElement(Token_t Element)
throw (uno::RuntimeException, xml::sax::SAXException, std::exception) throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
{ {
if (Element == (NS_mce | XML_Choice) || Element == (NS_mce | XML_Fallback)) if (Element == (NMSP_mce | XML_Choice) || Element == (NMSP_mce | XML_Fallback))
m_bDiscardChildren = false; m_bDiscardChildren = false;
else if (Element == (NS_mce | XML_AlternateContent)) else if (Element == (NMSP_mce | XML_AlternateContent))
{ {
SavedAlternateState aState(mpParserState->getSavedAlternateStates().back()); SavedAlternateState aState(mpParserState->getSavedAlternateStates().back());
mpParserState->getSavedAlternateStates().pop_back(); mpParserState->getSavedAlternateStates().pop_back();
...@@ -256,9 +256,9 @@ void OOXMLFastContextHandler::lcl_startFastElement ...@@ -256,9 +256,9 @@ void OOXMLFastContextHandler::lcl_startFastElement
throw (uno::RuntimeException, xml::sax::SAXException) throw (uno::RuntimeException, xml::sax::SAXException)
{ {
OOXMLFactory::getInstance()->startAction(this, Element); OOXMLFactory::getInstance()->startAction(this, Element);
if( Element == (NS_wordprocessingDrawing|XML_positionV) ) if( Element == (NMSP_wordprocessingDrawing|XML_positionV) )
inPositionV = true; inPositionV = true;
else if( Element == (NS_wordprocessingDrawing|XML_positionH) ) else if( Element == (NMSP_wordprocessingDrawing|XML_positionH) )
inPositionV = false; inPositionV = false;
} }
...@@ -283,9 +283,9 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ...@@ -283,9 +283,9 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
throw (uno::RuntimeException, xml::sax::SAXException, std::exception) throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
{ {
uno::Reference< xml::sax::XFastContextHandler > xResult; uno::Reference< xml::sax::XFastContextHandler > xResult;
if ((Element & 0xffff0000) != NS_mce && !m_bDiscardChildren) if ((Element & 0xffff0000) != NMSP_mce && !m_bDiscardChildren)
xResult.set(lcl_createFastChildContext(Element, Attribs)); xResult.set(lcl_createFastChildContext(Element, Attribs));
else if ((Element & 0xffff0000) == NS_mce) else if ((Element & 0xffff0000) == NMSP_mce)
xResult = this; xResult = this;
return xResult; return xResult;
...@@ -1143,13 +1143,13 @@ void OOXMLFastContextHandlerProperties::handleXNotes() ...@@ -1143,13 +1143,13 @@ void OOXMLFastContextHandlerProperties::handleXNotes()
{ {
switch (mnToken) switch (mnToken)
{ {
case NS_doc|XML_footnoteReference: case NMSP_doc|XML_footnoteReference:
{ {
OOXMLFootnoteHandler aFootnoteHandler(this); OOXMLFootnoteHandler aFootnoteHandler(this);
mpPropertySet->resolve(aFootnoteHandler); mpPropertySet->resolve(aFootnoteHandler);
} }
break; break;
case NS_doc|XML_endnoteReference: case NMSP_doc|XML_endnoteReference:
{ {
OOXMLEndnoteHandler aEndnoteHandler(this); OOXMLEndnoteHandler aEndnoteHandler(this);
mpPropertySet->resolve(aEndnoteHandler); mpPropertySet->resolve(aEndnoteHandler);
...@@ -1164,13 +1164,13 @@ void OOXMLFastContextHandlerProperties::handleHdrFtr() ...@@ -1164,13 +1164,13 @@ void OOXMLFastContextHandlerProperties::handleHdrFtr()
{ {
switch (mnToken) switch (mnToken)
{ {
case NS_doc|XML_footerReference: case NMSP_doc|XML_footerReference:
{ {
OOXMLFooterHandler aFooterHandler(this); OOXMLFooterHandler aFooterHandler(this);
mpPropertySet->resolve(aFooterHandler); mpPropertySet->resolve(aFooterHandler);
} }
break; break;
case NS_doc|XML_headerReference: case NMSP_doc|XML_headerReference:
{ {
OOXMLHeaderHandler aHeaderHandler(this); OOXMLHeaderHandler aHeaderHandler(this);
mpPropertySet->resolve(aHeaderHandler); mpPropertySet->resolve(aHeaderHandler);
...@@ -1748,7 +1748,7 @@ void OOXMLFastContextHandlerShape::sendShape( Token_t Element ) ...@@ -1748,7 +1748,7 @@ void OOXMLFastContextHandlerShape::sendShape( Token_t Element )
newProperty(NS_ooxml::LN_shape, pValue); newProperty(NS_ooxml::LN_shape, pValue);
m_bShapeSent = true; m_bShapeSent = true;
bool bIsPicture = Element == ( NS_picture | XML_pic ); bool bIsPicture = Element == ( NMSP_picture | XML_pic );
// Notify the dmapper that the shape is ready to use // Notify the dmapper that the shape is ready to use
if ( !bIsPicture ) if ( !bIsPicture )
...@@ -1773,7 +1773,7 @@ void OOXMLFastContextHandlerShape::lcl_endFastElement ...@@ -1773,7 +1773,7 @@ void OOXMLFastContextHandlerShape::lcl_endFastElement
OOXMLFastContextHandlerProperties::lcl_endFastElement(Element); OOXMLFastContextHandlerProperties::lcl_endFastElement(Element);
// Ending the shape should be the last thing to do // Ending the shape should be the last thing to do
bool bIsPicture = Element == ( NS_picture | XML_pic ); bool bIsPicture = Element == ( NMSP_picture | XML_pic );
if ( !bIsPicture && m_bShapeStarted) if ( !bIsPicture && m_bShapeStarted)
mpStream->endShape( ); mpStream->endShape( );
} }
...@@ -1795,16 +1795,16 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext ...@@ -1795,16 +1795,16 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext
{ {
uno::Reference< xml::sax::XFastContextHandler > xContextHandler; uno::Reference< xml::sax::XFastContextHandler > xContextHandler;
bool bGroupShape = Element == Token_t(NS_vml | XML_group); bool bGroupShape = Element == Token_t(NMSP_vml | XML_group);
// drawingML version also counts as a group shape. // drawingML version also counts as a group shape.
bGroupShape |= mrShapeContext->getStartToken() == Token_t(NS_wpg | XML_wgp); bGroupShape |= mrShapeContext->getStartToken() == Token_t(NMSP_wpg | XML_wgp);
sal_uInt32 nNamespace = Element & 0xffff0000; sal_uInt32 nNamespace = Element & 0xffff0000;
switch (nNamespace) switch (nNamespace)
{ {
case NS_doc: case NMSP_doc:
case NS_vml_wordprocessingDrawing: case NMSP_vml_wordprocessingDrawing:
case NS_office: case NMSP_office:
if (!bGroupShape) if (!bGroupShape)
xContextHandler.set(OOXMLFactory::getInstance()->createFastChildContextFromStart(this, Element)); xContextHandler.set(OOXMLFactory::getInstance()->createFastChildContextFromStart(this, Element));
// no break; // no break;
...@@ -1821,10 +1821,10 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext ...@@ -1821,10 +1821,10 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext
if (!bGroupShape) if (!bGroupShape)
{ {
pWrapper->addNamespace(NS_doc); pWrapper->addNamespace(NMSP_doc);
pWrapper->addNamespace(NS_vml_wordprocessingDrawing); pWrapper->addNamespace(NMSP_vml_wordprocessingDrawing);
pWrapper->addNamespace(NS_office); pWrapper->addNamespace(NMSP_office);
pWrapper->addToken( NS_vml|XML_textbox ); pWrapper->addToken( NMSP_vml|XML_textbox );
} }
xContextHandler.set(pWrapper); xContextHandler.set(pWrapper);
...@@ -1839,8 +1839,8 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext ...@@ -1839,8 +1839,8 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext
// OOXMLFastContextHandlerWrapper::lcl_createFastChildContext(), here we // OOXMLFastContextHandlerWrapper::lcl_createFastChildContext(), here we
// handle the WPS import of shape text, as there the parent context is a // handle the WPS import of shape text, as there the parent context is a
// Shape one, so a different situation. // Shape one, so a different situation.
if (Element == static_cast<sal_Int32>(NS_wps | XML_txbx) || if (Element == static_cast<sal_Int32>(NMSP_wps | XML_txbx) ||
Element == static_cast<sal_Int32>(NS_wps | XML_linkedTxbx) ) Element == static_cast<sal_Int32>(NMSP_wps | XML_linkedTxbx) )
sendShape(Element); sendShape(Element);
return xContextHandler; return xContextHandler;
...@@ -1989,7 +1989,7 @@ OOXMLFastContextHandlerWrapper::lcl_createFastChildContext ...@@ -1989,7 +1989,7 @@ OOXMLFastContextHandlerWrapper::lcl_createFastChildContext
// processed by writerfilter (instead of oox), but we have no method to // processed by writerfilter (instead of oox), but we have no method to
// filter out a single token. Just hardwire the wrap token here till we // filter out a single token. Just hardwire the wrap token here till we
// need a more generic solution. // need a more generic solution.
bool bIsWrap = Element == static_cast<sal_Int32>(NS_vml_wordprocessingDrawing | XML_wrap); bool bIsWrap = Element == static_cast<sal_Int32>(NMSP_vml_wordprocessingDrawing | XML_wrap);
if ( bInNamespaces && ((pShapeCtx->isShapeSent() && bIsWrap) || !bIsWrap) ) if ( bInNamespaces && ((pShapeCtx->isShapeSent() && bIsWrap) || !bIsWrap) )
xResult.set(OOXMLFactory::getInstance()->createFastChildContextFromStart(this, Element)); xResult.set(OOXMLFactory::getInstance()->createFastChildContextFromStart(this, Element));
else if (mxContext.is()) else if (mxContext.is())
......
...@@ -129,7 +129,7 @@ string fastTokenToId(sal_uInt32 nToken) ...@@ -129,7 +129,7 @@ string fastTokenToId(sal_uInt32 nToken)
for alias in [a.getAttribute("alias") for a in model.getElementsByTagName("namespace-alias")]: for alias in [a.getAttribute("alias") for a in model.getElementsByTagName("namespace-alias")]:
if not alias in aliases: if not alias in aliases:
aliases.append(alias) aliases.append(alias)
print(""" case NS_%s: print(""" case NMSP_%s:
sResult += "%s:"; sResult += "%s:";
break;""" % (alias, alias)) break;""" % (alias, alias))
print(""" } print(""" }
...@@ -161,7 +161,7 @@ def getFastParser(model): ...@@ -161,7 +161,7 @@ def getFastParser(model):
mxFastParser = css::xml::sax::FastParser::create(mxContext); mxFastParser = css::xml::sax::FastParser::create(mxContext);
""") """)
for alias in model.getElementsByTagName("namespace-alias"): for alias in model.getElementsByTagName("namespace-alias"):
print(""" mxFastParser->registerNamespace("%s", NS_%s);""" % (alias.getAttribute("name"), alias.getAttribute("alias"))) print(""" mxFastParser->registerNamespace("%s", NMSP_%s);""" % (alias.getAttribute("name"), alias.getAttribute("alias")))
print(""" } print(""" }
return mxFastParser; return mxFastParser;
......
...@@ -110,7 +110,7 @@ def idForDefine(nsNode, defineNode): ...@@ -110,7 +110,7 @@ def idForDefine(nsNode, defineNode):
def fastNamespace(attrNode): def fastNamespace(attrNode):
return "NS_%s" % attrNode.getAttribute("prefix") return "NMSP_%s" % attrNode.getAttribute("prefix")
def fastLocalName(attrNode): def fastLocalName(attrNode):
......
...@@ -41,7 +41,7 @@ using namespace ::com::sun::star; ...@@ -41,7 +41,7 @@ using namespace ::com::sun::star;
def startElement(self, name, attrs): def startElement(self, name, attrs):
if name == "namespace-alias": if name == "namespace-alias":
token = """const sal_uInt32 NS_%s = %s;""" % (attrs["alias"], attrs["id"]) token = """const sal_Int32 NMSP_%s = %s;""" % (attrs["alias"], attrs["id"])
if token not in self.tokens: if token not in self.tokens:
self.tokens.append(token) self.tokens.append(token)
print(token) print(token)
......
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