summaryrefslogtreecommitdiff
path: root/sc/source/filter/xml
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/filter/xml')
-rw-r--r--sc/source/filter/xml/XMLTableShapesContext.cxx16
-rw-r--r--sc/source/filter/xml/XMLTableShapesContext.hxx6
-rw-r--r--sc/source/filter/xml/xmlannoi.cxx78
-rw-r--r--sc/source/filter/xml/xmlannoi.hxx12
-rw-r--r--sc/source/filter/xml/xmlcelli.cxx92
-rw-r--r--sc/source/filter/xml/xmlcelli.hxx4
6 files changed, 89 insertions, 119 deletions
diff --git a/sc/source/filter/xml/XMLTableShapesContext.cxx b/sc/source/filter/xml/XMLTableShapesContext.cxx
index f645ee09e89a..866d6107d591 100644
--- a/sc/source/filter/xml/XMLTableShapesContext.cxx
+++ b/sc/source/filter/xml/XMLTableShapesContext.cxx
@@ -33,23 +33,21 @@ ScXMLTableShapesContext::~ScXMLTableShapesContext()
{
}
-SvXMLImportContextRef ScXMLTableShapesContext::CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList )
+uno::Reference< xml::sax::XFastContextHandler > ScXMLTableShapesContext::createFastChildContext(
+ sal_Int32 nElement,
+ const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
{
- SvXMLImportContext *pContext = nullptr;
-
ScXMLImport& rXMLImport(GetScImport());
uno::Reference<drawing::XShapes> xShapes (rXMLImport.GetTables().GetCurrentXShapes());
if (xShapes.is())
{
XMLTableShapeImportHelper* pTableShapeImport(static_cast<XMLTableShapeImportHelper*>(rXMLImport.GetShapeImport().get()));
pTableShapeImport->SetOnTable(true);
- pContext = rXMLImport.GetShapeImport()->CreateGroupChildContext(
- rXMLImport, nPrefix, rLName, xAttrList, xShapes);
+ return GetImport().GetShapeImport()->CreateGroupChildContext(
+ rXMLImport, nElement, xAttrList, xShapes);
}
-
- return pContext;
+ XMLOFF_WARN_UNKNOWN_ELEMENT("sc", nElement);
+ return nullptr;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/XMLTableShapesContext.hxx b/sc/source/filter/xml/XMLTableShapesContext.hxx
index 9af805a717a5..8205fc96561a 100644
--- a/sc/source/filter/xml/XMLTableShapesContext.hxx
+++ b/sc/source/filter/xml/XMLTableShapesContext.hxx
@@ -32,9 +32,9 @@ public:
virtual ~ScXMLTableShapesContext() override;
- virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
};
#endif
diff --git a/sc/source/filter/xml/xmlannoi.cxx b/sc/source/filter/xml/xmlannoi.cxx
index 67ec0d50aee5..b78d2cbccb48 100644
--- a/sc/source/filter/xml/xmlannoi.cxx
+++ b/sc/source/filter/xml/xmlannoi.cxx
@@ -41,11 +41,10 @@ ScXMLAnnotationData::~ScXMLAnnotationData()
}
ScXMLAnnotationContext::ScXMLAnnotationContext( ScXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList,
+ sal_Int32 nElement,
+ const uno::Reference<xml::sax::XFastAttributeList>& xAttrList,
ScXMLAnnotationData& rAnnotationData) :
- ScXMLImportContext( rImport, nPrfx, rLName ),
+ ScXMLImportContext( rImport ),
mrAnnotationData( rAnnotationData )
{
uno::Reference<drawing::XShapes> xLocalShapes (GetScImport().GetTables().GetCurrentXShapes());
@@ -53,52 +52,50 @@ ScXMLAnnotationContext::ScXMLAnnotationContext( ScXMLImport& rImport,
{
XMLTableShapeImportHelper* pTableShapeImport = static_cast<XMLTableShapeImportHelper*>(GetScImport().GetShapeImport().get());
pTableShapeImport->SetAnnotation(this);
- pShapeContext.reset( GetScImport().GetShapeImport()->CreateGroupChildContext(
- GetScImport(), nPrfx, rLName, xAttrList, xLocalShapes, true) );
+ pShapeContext.reset( GetImport().GetShapeImport()->CreateGroupChildContext(
+ GetScImport(), nElement, xAttrList, xLocalShapes, true) );
}
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableAnnotationAttrTokenMap();
- for( sal_Int16 i=0; i < nAttrCount; ++i )
+ for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
{
- const OUString& sAttrName(xAttrList->getNameByIndex( i ));
- OUString aLocalName;
- sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
- sAttrName, &aLocalName );
- const OUString& sValue(xAttrList->getValueByIndex( i ));
+ const OUString sValue = aIter.toString();
- switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ switch( aIter.getToken() )
{
- case XML_TOK_TABLE_ANNOTATION_ATTR_AUTHOR:
+ case XML_ELEMENT(OFFICE, XML_AUTHOR):
{
maAuthorBuffer = sValue;
}
break;
- case XML_TOK_TABLE_ANNOTATION_ATTR_CREATE_DATE:
+ case XML_ELEMENT(OFFICE, XML_CREATE_DATE):
{
maCreateDateBuffer = sValue;
}
break;
- case XML_TOK_TABLE_ANNOTATION_ATTR_CREATE_DATE_STRING:
+ case XML_ELEMENT(OFFICE, XML_CREATE_DATE_STRING):
{
maCreateDateStringBuffer = sValue;
}
break;
- case XML_TOK_TABLE_ANNOTATION_ATTR_DISPLAY:
+ case XML_ELEMENT(OFFICE, XML_DISPLAY):
{
mrAnnotationData.mbShown = IsXMLToken(sValue, XML_TRUE);
}
break;
- case XML_TOK_TABLE_ANNOTATION_ATTR_X:
+ case XML_ELEMENT(SVG, XML_X):
+ case XML_ELEMENT(SVG_COMPAT, XML_X):
{
mrAnnotationData.mbUseShapePos = true;
}
break;
- case XML_TOK_TABLE_ANNOTATION_ATTR_Y:
+ case XML_ELEMENT(SVG, XML_Y):
+ case XML_ELEMENT(SVG_COMPAT, XML_Y):
{
mrAnnotationData.mbUseShapePos = true;
}
break;
+ default:
+ SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << aIter.toString());
}
}
}
@@ -113,32 +110,31 @@ void ScXMLAnnotationContext::startFastElement(sal_Int32 nElement, const css::uno
pShapeContext->startFastElement(nElement, xAttrList);
}
-SvXMLImportContextRef ScXMLAnnotationContext::CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLName,
- const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList )
+css::uno::Reference< css::xml::sax::XFastContextHandler > ScXMLAnnotationContext::createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
{
- SvXMLImportContextRef xContext;
-
- if( XML_NAMESPACE_DC == nPrefix )
+ switch (nElement)
{
- if( IsXMLToken( rLName, XML_CREATOR ) )
- xContext = new ScXMLContentContext(GetScImport(), nPrefix,
- rLName, maAuthorBuffer);
- else if( IsXMLToken( rLName, XML_DATE ) )
- xContext = new ScXMLContentContext(GetScImport(), nPrefix,
- rLName, maCreateDateBuffer);
+ case XML_ELEMENT(DC, XML_CREATOR):
+ return new ScXMLContentContext(GetScImport(), maAuthorBuffer);
+ case XML_ELEMENT(DC, XML_DATE):
+ return new ScXMLContentContext(GetScImport(), maCreateDateBuffer);
+ case XML_ELEMENT(META, XML_DATE_STRING):
+ return new ScXMLContentContext(GetScImport(), maCreateDateStringBuffer);
}
- else if( XML_NAMESPACE_META == nPrefix )
+
+ if( pShapeContext )
{
- if( IsXMLToken( rLName, XML_DATE_STRING ) )
- xContext = new ScXMLContentContext(GetScImport(), nPrefix,
- rLName, maCreateDateStringBuffer);
+ auto p = pShapeContext->createFastChildContext(nElement, xAttrList);
+ if (!p)
+ p = pShapeContext->createFastChildContextFallback(nElement, xAttrList);
+ if (p)
+ return p;
}
- if( !xContext && pShapeContext )
- xContext = pShapeContext->CreateChildContext(nPrefix, rLName, xAttrList);
-
- return xContext;
+ XMLOFF_WARN_UNKNOWN_ELEMENT("sc", nElement);
+ return nullptr;
}
void ScXMLAnnotationContext::characters( const OUString& rChars )
diff --git a/sc/source/filter/xml/xmlannoi.hxx b/sc/source/filter/xml/xmlannoi.hxx
index 7b8541df5986..95de84a39df5 100644
--- a/sc/source/filter/xml/xmlannoi.hxx
+++ b/sc/source/filter/xml/xmlannoi.hxx
@@ -68,16 +68,16 @@ class ScXMLAnnotationContext : public ScXMLImportContext
{
public:
- ScXMLAnnotationContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
- const OUString& rLName,
- const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
+ ScXMLAnnotationContext( ScXMLImport& rImport,
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
ScXMLAnnotationData& rAnnotationData);
virtual ~ScXMLAnnotationContext() override;
- virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override;
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList) override;
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 6068fd901905..3b1bab4f34ab 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -628,29 +628,55 @@ void ScXMLTableRowCellContext::PushParagraphEnd()
++mnCurParagraph;
}
-SvXMLImportContextRef ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList )
+uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLTableRowCellContext::createFastChildContext(
+ sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
{
SvXMLImportContext *pContext = nullptr;
+ sax_fastparser::FastAttributeList *pAttribList =
+ &sax_fastparser::castToFastAttributeList( xAttrList );
- const SvXMLTokenMap& rTokenMap = rXMLImport.GetTableRowCellElemTokenMap();
bool bTextP(false);
- switch( rTokenMap.Get( nPrefix, rLName ) )
+ switch (nElement)
{
- case XML_TOK_TABLE_ROW_CELL_P:
+ case XML_ELEMENT( TEXT, XML_P ):
{
+ bIsEmpty = false;
bTextP = true;
+
+ pContext = new ScXMLCellTextParaContext(rXMLImport, *this);
+ }
+ break;
+ case XML_ELEMENT( TABLE, XML_SUB_TABLE ):
+ {
+ SAL_WARN("sc", "ScXMLTableRowCellContext::createFastChildContext: subtables are not supported");
+ }
+ break;
+ case XML_ELEMENT( TABLE, XML_DETECTIVE ):
+ {
+ bIsEmpty = false;
+ if (!pDetectiveObjVec)
+ pDetectiveObjVec.reset( new ScMyImpDetectiveObjVec );
+ pContext = new ScXMLDetectiveContext(
+ rXMLImport, pDetectiveObjVec.get() );
}
break;
- case XML_TOK_TABLE_ROW_CELL_ANNOTATION:
+ case XML_ELEMENT( TABLE, XML_CELL_RANGE_SOURCE ):
+ {
+ bIsEmpty = false;
+ if (!pCellRangeSource)
+ pCellRangeSource.reset(new ScMyImpCellRangeSource());
+ pContext = new ScXMLCellRangeSourceContext(
+ rXMLImport, pAttribList, pCellRangeSource.get() );
+ }
+ break;
+ case XML_ELEMENT(OFFICE, XML_ANNOTATION):
{
bIsEmpty = false;
OSL_ENSURE(
!mxAnnotationData,
"ScXMLTableRowCellContext::CreateChildContext - multiple annotations in one cell");
mxAnnotationData.reset( new ScXMLAnnotationData );
- pContext = new ScXMLAnnotationContext( rXMLImport, nPrefix, rLName,
+ pContext = new ScXMLAnnotationContext( rXMLImport, nElement,
xAttrList, *mxAnnotationData);
}
break;
@@ -671,8 +697,8 @@ SvXMLImportContextRef ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 n
static_cast< XMLTableShapeImportHelper* >( rXMLImport.GetShapeImport().get() );
pTableShapeImport->SetOnTable(false);
pTableShapeImport->SetCell(aCellPos);
- pContext = rXMLImport.GetShapeImport()->CreateGroupChildContext(
- rXMLImport, nPrefix, rLName, xAttrList, xShapes);
+ pContext = GetImport().GetShapeImport()->CreateGroupChildContext(
+ rXMLImport, nElement, xAttrList, xShapes);
if (pContext)
{
bIsEmpty = false;
@@ -684,52 +710,6 @@ SvXMLImportContextRef ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 n
return pContext;
}
-uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLTableRowCellContext::createFastChildContext(
- sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
-{
- SvXMLImportContext *pContext = nullptr;
- sax_fastparser::FastAttributeList *pAttribList =
- &sax_fastparser::castToFastAttributeList( xAttrList );
-
- // bool bTextP(false);
- switch (nElement)
- {
- case XML_ELEMENT( TEXT, XML_P ):
- {
- bIsEmpty = false;
- // bTextP = true;
-
- pContext = new ScXMLCellTextParaContext(rXMLImport, *this);
- }
- break;
- case XML_ELEMENT( TABLE, XML_SUB_TABLE ):
- {
- SAL_WARN("sc", "ScXMLTableRowCellContext::createFastChildContext: subtables are not supported");
- }
- break;
- case XML_ELEMENT( TABLE, XML_DETECTIVE ):
- {
- bIsEmpty = false;
- if (!pDetectiveObjVec)
- pDetectiveObjVec.reset( new ScMyImpDetectiveObjVec );
- pContext = new ScXMLDetectiveContext(
- rXMLImport, pDetectiveObjVec.get() );
- }
- break;
- case XML_ELEMENT( TABLE, XML_CELL_RANGE_SOURCE ):
- {
- bIsEmpty = false;
- if (!pCellRangeSource)
- pCellRangeSource.reset(new ScMyImpCellRangeSource());
- pContext = new ScXMLCellRangeSourceContext(
- rXMLImport, pAttribList, pCellRangeSource.get() );
- }
- break;
- }
-
- return pContext;
-}
-
void ScXMLTableRowCellContext::DoMerge( const ScAddress& rScAddress, const SCCOL nCols, const SCROW nRows )
{
SCCOL mergeToCol = rScAddress.Col() + nCols;
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index 35ab79944c10..4229a86117c2 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -135,10 +135,6 @@ public:
virtual ~ScXMLTableRowCellContext() override;
- virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
-
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;