summaryrefslogtreecommitdiff
path: root/xmloff/source/draw/shapeimport.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff/source/draw/shapeimport.cxx')
-rw-r--r--xmloff/source/draw/shapeimport.cxx219
1 files changed, 76 insertions, 143 deletions
diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx
index 9a26ea3576be..e3fcfd70fd56 100644
--- a/xmloff/source/draw/shapeimport.cxx
+++ b/xmloff/source/draw/shapeimport.cxx
@@ -345,48 +345,48 @@ const SvXMLTokenMap& XMLShapeImportHelper::Get3DLightAttrTokenMap()
SvXMLShapeContext* XMLShapeImportHelper::Create3DSceneChildContext(
SvXMLImport& rImport,
- sal_uInt16 p_nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList>& xAttrList,
+ sal_Int32 nElement,
+ const uno::Reference< xml::sax::XFastAttributeList>& xAttrList,
uno::Reference< drawing::XShapes > const & rShapes)
{
SdXMLShapeContext *pContext = nullptr;
if(rShapes.is())
{
- const SvXMLTokenMap& rTokenMap = Get3DSceneShapeElemTokenMap();
- switch(rTokenMap.Get(p_nPrefix, rLocalName))
+ switch(nElement)
{
- case XML_TOK_3DSCENE_3DSCENE:
+ case XML_ELEMENT(DR3D, XML_SCENE):
{
// dr3d:3dscene inside dr3d:3dscene context
pContext = new SdXML3DSceneShapeContext( rImport, xAttrList, rShapes, false);
break;
}
- case XML_TOK_3DSCENE_3DCUBE:
+ case XML_ELEMENT(DR3D, XML_CUBE):
{
// dr3d:3dcube inside dr3d:3dscene context
pContext = new SdXML3DCubeObjectShapeContext( rImport, xAttrList, rShapes);
break;
}
- case XML_TOK_3DSCENE_3DSPHERE:
+ case XML_ELEMENT(DR3D, XML_SPHERE):
{
// dr3d:3dsphere inside dr3d:3dscene context
pContext = new SdXML3DSphereObjectShapeContext( rImport, xAttrList, rShapes);
break;
}
- case XML_TOK_3DSCENE_3DLATHE:
+ case XML_ELEMENT(DR3D, XML_ROTATE):
{
// dr3d:3dlathe inside dr3d:3dscene context
pContext = new SdXML3DLatheObjectShapeContext( rImport, xAttrList, rShapes);
break;
}
- case XML_TOK_3DSCENE_3DEXTRUDE:
+ case XML_ELEMENT(DR3D, XML_EXTRUDE):
{
// dr3d:3dextrude inside dr3d:3dscene context
pContext = new SdXML3DExtrudeObjectShapeContext( rImport, xAttrList, rShapes);
break;
}
+ default:
+ XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
}
}
@@ -394,15 +394,11 @@ SvXMLShapeContext* XMLShapeImportHelper::Create3DSceneChildContext(
return nullptr;
// now parse the attribute list and call the child context for each unknown attribute
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for(sal_Int16 a(0); a < nAttrCount; a++)
+ for(auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList))
{
- const OUString& rAttrName = xAttrList->getNameByIndex(a);
- OUString aLocalName;
- sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
- const OUString aValue( xAttrList->getValueByIndex(a) );
+ if (!pContext->processAttribute( aIter.getToken(), aIter.toString() ))
+ XMLOFF_WARN_UNKNOWN("xmloff", aIter);
- pContext->processAttribute( nPrefix, aLocalName, aValue );
}
return pContext;
@@ -420,279 +416,216 @@ void XMLShapeImportHelper::SetAutoStylesContext(SvXMLStylesContext* pNew)
SvXMLShapeContext* XMLShapeImportHelper::CreateGroupChildContext(
SvXMLImport& rImport,
- sal_Int32 Element,
- const uno::Reference< xml::sax::XFastAttributeList>& Attribs,
- uno::Reference< drawing::XShapes > const & rShapes,
- bool bTemporaryShape)
-{
- // fall back to slow-parser path
- const OUString& rPrefix = SvXMLImport::getNamespacePrefixFromToken(Element, &rImport.GetNamespaceMap());
- const OUString& rLocalName = SvXMLImport::getNameFromToken( Element );
- OUString aName = rPrefix.isEmpty() ? rLocalName : rPrefix + SvXMLImport::aNamespaceSeparator + rLocalName;
- OUString aLocalName;
- sal_uInt16 nPrefix =
- rImport.GetNamespaceMap().GetKeyByAttrName( aName, &aLocalName );
-
- rtl::Reference < comphelper::AttributeList > maAttrList = new comphelper::AttributeList();
-
- if ( Attribs.is() )
- {
- for( auto &it : sax_fastparser::castToFastAttributeList( Attribs ) )
- {
- sal_Int32 nToken = it.getToken();
- const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken(nToken, &rImport.GetNamespaceMap());
- OUString sAttrName = SvXMLImport::getNameFromToken( nToken );
- if ( !rAttrNamespacePrefix.isEmpty() )
- sAttrName = rAttrNamespacePrefix + SvXMLImport::aNamespaceSeparator + sAttrName;
-
- maAttrList->AddAttribute( sAttrName, "CDATA", it.toString() );
- }
-
- const uno::Sequence< xml::Attribute > unknownAttribs = Attribs->getUnknownAttributes();
- for ( const auto& rUnknownAttrib : unknownAttribs )
- {
- const OUString& rAttrValue = rUnknownAttrib.Value;
- const OUString& rAttrName = rUnknownAttrib.Name;
- // note: rAttrName is expected to be namespace-prefixed here
- maAttrList->AddAttribute( rAttrName, "CDATA", rAttrValue );
- }
- }
-
- return CreateGroupChildContext(rImport, nPrefix, aLocalName, maAttrList.get(), rShapes, bTemporaryShape );
-}
-
-SvXMLShapeContext* XMLShapeImportHelper::CreateGroupChildContext(
- SvXMLImport& rImport,
- sal_uInt16 p_nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList>& xAttrList,
+ sal_Int32 nElement,
+ const uno::Reference< xml::sax::XFastAttributeList>& xAttrList,
uno::Reference< drawing::XShapes > const & rShapes,
bool bTemporaryShape)
{
SdXMLShapeContext *pContext = nullptr;
-
- const SvXMLTokenMap& rTokenMap = GetGroupShapeElemTokenMap();
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
-
- switch(rTokenMap.Get(p_nPrefix, rLocalName))
+ switch (nElement)
{
- case XML_TOK_GROUP_GROUP:
- {
+ case XML_ELEMENT(DRAW, XML_G):
// draw:g inside group context (RECURSIVE)
pContext = new SdXMLGroupShapeContext( rImport, xAttrList, rShapes, bTemporaryShape);
break;
- }
- case XML_TOK_GROUP_3DSCENE:
+ case XML_ELEMENT(DR3D, XML_SCENE):
{
// dr3d:3dscene inside group context
pContext = new SdXML3DSceneShapeContext( rImport, xAttrList, rShapes, bTemporaryShape);
break;
}
- case XML_TOK_GROUP_RECT:
+ case XML_ELEMENT(DRAW, XML_RECT):
{
// draw:rect inside group context
pContext = new SdXMLRectShapeContext( rImport, xAttrList, rShapes, bTemporaryShape );
break;
}
- case XML_TOK_GROUP_LINE:
+ case XML_ELEMENT(DRAW, XML_LINE):
{
// draw:line inside group context
pContext = new SdXMLLineShapeContext( rImport, xAttrList, rShapes, bTemporaryShape );
break;
}
- case XML_TOK_GROUP_CIRCLE:
- case XML_TOK_GROUP_ELLIPSE:
+ case XML_ELEMENT(DRAW, XML_CIRCLE):
+ case XML_ELEMENT(DRAW, XML_ELLIPSE):
{
// draw:circle or draw:ellipse inside group context
pContext = new SdXMLEllipseShapeContext( rImport, xAttrList, rShapes, bTemporaryShape );
break;
}
- case XML_TOK_GROUP_POLYGON:
- case XML_TOK_GROUP_POLYLINE:
+ case XML_ELEMENT(DRAW, XML_POLYGON):
+ case XML_ELEMENT(DRAW, XML_POLYLINE):
{
// draw:polygon or draw:polyline inside group context
pContext = new SdXMLPolygonShapeContext( rImport, xAttrList, rShapes,
- rTokenMap.Get(p_nPrefix, rLocalName) == XML_TOK_GROUP_POLYGON, bTemporaryShape );
+ nElement == XML_ELEMENT(DRAW, XML_POLYGON), bTemporaryShape );
break;
}
- case XML_TOK_GROUP_PATH:
+ case XML_ELEMENT(DRAW, XML_PATH):
{
// draw:path inside group context
pContext = new SdXMLPathShapeContext( rImport, xAttrList, rShapes, bTemporaryShape);
break;
}
- case XML_TOK_GROUP_FRAME:
+ case XML_ELEMENT(DRAW, XML_FRAME):
{
// text:text-box inside group context
pContext = new SdXMLFrameShapeContext( rImport, xAttrList, rShapes, bTemporaryShape );
break;
}
- case XML_TOK_GROUP_CONTROL:
+ case XML_ELEMENT(DRAW, XML_CONTROL):
{
// draw:control inside group context
pContext = new SdXMLControlShapeContext( rImport, xAttrList, rShapes, bTemporaryShape );
break;
}
- case XML_TOK_GROUP_CONNECTOR:
+ case XML_ELEMENT(DRAW, XML_CONNECTOR):
{
// draw:connector inside group context
pContext = new SdXMLConnectorShapeContext( rImport, xAttrList, rShapes, bTemporaryShape );
break;
}
- case XML_TOK_GROUP_MEASURE:
+ case XML_ELEMENT(DRAW, XML_MEASURE):
{
// draw:measure inside group context
pContext = new SdXMLMeasureShapeContext( rImport, xAttrList, rShapes, bTemporaryShape );
break;
}
- case XML_TOK_GROUP_PAGE:
+ case XML_ELEMENT(DRAW, XML_PAGE_THUMBNAIL):
{
// draw:page inside group context
pContext = new SdXMLPageShapeContext( rImport, xAttrList, rShapes, bTemporaryShape );
break;
}
- case XML_TOK_GROUP_CAPTION:
- case XML_TOK_GROUP_ANNOTATION:
+ case XML_ELEMENT(DRAW, XML_CAPTION):
+ case XML_ELEMENT(OFFICE, XML_ANNOTATION):
{
// draw:caption inside group context
pContext = new SdXMLCaptionShapeContext( rImport, xAttrList, rShapes, bTemporaryShape );
break;
}
- case XML_TOK_GROUP_CHART:
+ case XML_ELEMENT(CHART, XML_CHART):
{
// chart:chart inside group context
pContext = new SdXMLChartShapeContext( rImport, xAttrList, rShapes, bTemporaryShape );
break;
}
- case XML_TOK_GROUP_CUSTOM_SHAPE:
+ case XML_ELEMENT(DRAW, XML_CUSTOM_SHAPE):
{
// draw:customshape
pContext = new SdXMLCustomShapeContext( rImport, xAttrList, rShapes );
break;
}
- case XML_TOK_GROUP_A:
- {
- return new SdXMLShapeLinkContext( rImport, xAttrList, rShapes );
- }
+ case XML_ELEMENT(DRAW, XML_A):
+ return new SdXMLShapeLinkContext( rImport, xAttrList, rShapes );
+ break;
// add other shapes here...
default:
+ XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
return new SvXMLShapeContext( rImport, bTemporaryShape );
}
// now parse the attribute list and call the child context for each unknown attribute
- for(sal_Int16 a(0); a < nAttrCount; a++)
+ for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
{
- const OUString& rAttrName = xAttrList->getNameByIndex(a);
- OUString aLocalName;
- sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
- const OUString aValue( xAttrList->getValueByIndex(a) );
-
- pContext->processAttribute( nPrefix, aLocalName, aValue );
+ if (!pContext->processAttribute( aIter.getToken(), aIter.toString() ))
+ XMLOFF_WARN_UNKNOWN("xmloff", aIter);
}
-
return pContext;
}
// This method is called from SdXMLFrameShapeContext to create children of draw:frame
SvXMLShapeContext* XMLShapeImportHelper::CreateFrameChildContext(
SvXMLImport& rImport,
- sal_uInt16 p_nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList>& rAttrList,
+ sal_Int32 nElement,
+ const uno::Reference< xml::sax::XFastAttributeList>& rAttrList,
uno::Reference< drawing::XShapes > const & rShapes,
- const uno::Reference< xml::sax::XAttributeList>& rFrameAttrList)
+ const uno::Reference< xml::sax::XFastAttributeList>& rFrameAttrList)
{
SdXMLShapeContext *pContext = nullptr;
- const SvXMLTokenMap& rTokenMap = GetFrameShapeElemTokenMap();
-
- SvXMLAttributeList *pAttrList = new SvXMLAttributeList( rAttrList );
+ rtl::Reference<sax_fastparser::FastAttributeList> xCombinedAttrList = new sax_fastparser::FastAttributeList(rAttrList);
if( rFrameAttrList.is() )
- pAttrList->AppendAttributeList( rFrameAttrList );
- uno::Reference < xml::sax::XAttributeList > xAttrList = pAttrList;
+ xCombinedAttrList->add(rFrameAttrList);
- switch(rTokenMap.Get(p_nPrefix, rLocalName))
+ switch(nElement)
{
- case XML_TOK_FRAME_TEXT_BOX:
+ case XML_ELEMENT(DRAW, XML_TEXT_BOX):
{
// text:text-box inside group context
- pContext = new SdXMLTextBoxShapeContext( rImport, xAttrList, rShapes );
+ pContext = new SdXMLTextBoxShapeContext( rImport, xCombinedAttrList.get(), rShapes );
break;
}
- case XML_TOK_FRAME_IMAGE:
+ case XML_ELEMENT(DRAW, XML_IMAGE):
{
// office:image inside group context
- pContext = new SdXMLGraphicObjectShapeContext( rImport, xAttrList, rShapes );
+ pContext = new SdXMLGraphicObjectShapeContext( rImport, xCombinedAttrList.get(), rShapes );
break;
}
- case XML_TOK_FRAME_OBJECT:
- case XML_TOK_FRAME_OBJECT_OLE:
+ case XML_ELEMENT(DRAW, XML_OBJECT):
+ case XML_ELEMENT(DRAW, XML_OBJECT_OLE):
{
// draw:object or draw:object_ole
- pContext = new SdXMLObjectShapeContext( rImport, xAttrList, rShapes );
+ pContext = new SdXMLObjectShapeContext( rImport, xCombinedAttrList.get(), rShapes );
break;
}
- case XML_TOK_FRAME_TABLE:
+ case XML_ELEMENT(TABLE, XML_TABLE):
{
// draw:object or draw:object_ole
if( rImport.IsTableShapeSupported() )
- pContext = new SdXMLTableShapeContext( rImport, xAttrList, rShapes );
+ pContext = new SdXMLTableShapeContext( rImport, xCombinedAttrList.get(), rShapes );
break;
}
- case XML_TOK_FRAME_PLUGIN:
+ case XML_ELEMENT(DRAW, XML_PLUGIN):
{
// draw:plugin
- pContext = new SdXMLPluginShapeContext( rImport, xAttrList, rShapes );
+ pContext = new SdXMLPluginShapeContext( rImport, xCombinedAttrList.get(), rShapes );
break;
}
- case XML_TOK_FRAME_FLOATING_FRAME:
+ case XML_ELEMENT(DRAW, XML_FLOATING_FRAME):
{
// draw:floating-frame
- pContext = new SdXMLFloatingFrameShapeContext( rImport, xAttrList, rShapes );
+ pContext = new SdXMLFloatingFrameShapeContext( rImport, xCombinedAttrList.get(), rShapes );
break;
}
- case XML_TOK_FRAME_APPLET:
+ case XML_ELEMENT(DRAW, XML_APPLET):
{
// draw:applet
- pContext = new SdXMLAppletShapeContext( rImport, xAttrList, rShapes );
+ pContext = new SdXMLAppletShapeContext( rImport, xCombinedAttrList.get(), rShapes );
break;
}
// add other shapes here...
default:
+ XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
break;
}
if( pContext )
{
// now parse the attribute list and call the child context for each unknown attribute
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for(sal_Int16 a(0); a < nAttrCount; a++)
+ for(auto& aIter : *xCombinedAttrList)
{
- const OUString& rAttrName = xAttrList->getNameByIndex(a);
- OUString aLocalName;
- sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
- const OUString aValue( xAttrList->getValueByIndex(a) );
-
- pContext->processAttribute( nPrefix, aLocalName, aValue );
+ if (!pContext->processAttribute( aIter.getToken(), aIter.toString() ))
+ XMLOFF_WARN_UNKNOWN("xmloff", aIter);
}
}
return pContext;
}
-SvXMLImportContextRef XMLShapeImportHelper::CreateFrameChildContext(
+css::uno::Reference< css::xml::sax::XFastContextHandler > XMLShapeImportHelper::CreateFrameChildContext(
SvXMLImportContext *pThisContext,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList>& xAttrList )
+ sal_Int32 nElement,
+ const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
{
- SvXMLImportContextRef xContext;
-
+ css::uno::Reference< css::xml::sax::XFastContextHandler > xContext;
SdXMLFrameShapeContext *pFrameContext = dynamic_cast<SdXMLFrameShapeContext*>( pThisContext );
if (pFrameContext)
- xContext = pFrameContext->CreateChildContext( nPrefix, rLocalName, xAttrList );
+ xContext = pFrameContext->createFastChildContext( nElement, xAttrList );
+ if (!xContext)
+ XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
return xContext;
}
@@ -700,7 +633,7 @@ SvXMLImportContextRef XMLShapeImportHelper::CreateFrameChildContext(
shape to the given XShapes.
*/
void XMLShapeImportHelper::addShape( uno::Reference< drawing::XShape >& rShape,
- const uno::Reference< xml::sax::XAttributeList >&,
+ const uno::Reference< xml::sax::XFastAttributeList >&,
uno::Reference< drawing::XShapes >& rShapes)
{
if( rShape.is() && rShapes.is() )
@@ -716,7 +649,7 @@ void XMLShapeImportHelper::addShape( uno::Reference< drawing::XShape >& rShape,
*/
void XMLShapeImportHelper::finishShape(
css::uno::Reference< css::drawing::XShape >& rShape,
- const css::uno::Reference< css::xml::sax::XAttributeList >&,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >&,
css::uno::Reference< css::drawing::XShapes >&)
{
/* Set property <PositionLayoutDir>