use more fastparser in OReportStylesContext

Change-Id: Ie8126206d9144ccba1fb120d47af9ebe35a345d5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101320
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2020-08-25 18:22:02 +02:00
parent e2fe4fde59
commit 5bf60ba188
11 changed files with 79 additions and 30 deletions
@@ -77,6 +77,7 @@ namespace dbaxml
protected:
// Create a style context.
using SvXMLStylesContext::CreateStyleStyleChildContext;
virtual SvXMLStyleContext *CreateStyleStyleChildContext(
XmlStyleFamily nFamily,
sal_uInt16 nPrefix,
@@ -33,6 +33,10 @@ public:
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList,
SvXMLStylesContext& rStyles);
XMLGraphicsDefaultStyle( SvXMLImport& rImport, sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
SvXMLStylesContext& rStyles);
virtual ~XMLGraphicsDefaultStyle() override;
virtual SvXMLImportContextRef CreateChildContext(
@@ -31,6 +31,7 @@ protected:
virtual SvXMLStyleContext *CreateStyleChildContext( sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override;
using SvXMLStylesContext::CreateStyleStyleChildContext;
virtual SvXMLStyleContext *CreateStyleStyleChildContext( XmlStyleFamily nFamily,
sal_uInt16 nPrefix,
const OUString& rLocalName,
+8
View File
@@ -199,11 +199,19 @@ protected:
sal_uInt16 nPrefix, const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList );
virtual SvXMLStyleContext *CreateStyleStyleChildContext( XmlStyleFamily nFamily,
sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
XmlStyleFamily nFamily, sal_uInt16 nPrefix,
const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList );
virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
XmlStyleFamily nFamily, sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
virtual bool InsertStyleFamily( XmlStyleFamily nFamily ) const;
public:
@@ -67,10 +67,10 @@ public:
}
OControlStyleContext::OControlStyleContext( ORptFilter& rImport,
sal_uInt16 nPrfx, const OUString& rLName,
const Reference< XAttributeList > & xAttrList,
sal_Int32 nElement,
const Reference< XFastAttributeList > & xAttrList,
SvXMLStylesContext& rStyles, XmlStyleFamily nFamily ) :
XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily, false/*bDefaultStyle*/ ),
XMLPropStyleContext( rImport, nElement, xAttrList, rStyles, nFamily, false/*bDefaultStyle*/ ),
pStyles(&rStyles),
m_nNumberFormat(-1),
m_rImport(rImport)
@@ -233,34 +233,24 @@ rtl::Reference < SvXMLImportPropertyMapper >
}
SvXMLStyleContext *OReportStylesContext::CreateDefaultStyleStyleChildContext(
XmlStyleFamily nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList > & xAttrList )
XmlStyleFamily nFamily, sal_Int32 nElement,
const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
{
SvXMLStyleContext *pStyle = nullptr;
switch( nFamily )
{
case XmlStyleFamily::SD_GRAPHICS_ID:
// There are no writer specific defaults for graphic styles!
pStyle = new XMLGraphicsDefaultStyle( GetImport(), nPrefix,
rLocalName, xAttrList, *this );
break;
return new XMLGraphicsDefaultStyle( GetImport(), nElement, xAttrList, *this );
default:
pStyle = SvXMLStylesContext::CreateDefaultStyleStyleChildContext( nFamily,
nPrefix,
rLocalName,
xAttrList );
break;
return nullptr;
}
return pStyle;
}
SvXMLStyleContext *OReportStylesContext::CreateStyleStyleChildContext(
XmlStyleFamily nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
const Reference< xml::sax::XAttributeList > & xAttrList )
XmlStyleFamily nFamily, sal_Int32 nElement,
const Reference< xml::sax::XFastAttributeList > & xAttrList )
{
SvXMLStyleContext *pStyle = SvXMLStylesContext::CreateStyleStyleChildContext( nFamily, nPrefix,
rLocalName,
SvXMLStyleContext *pStyle = SvXMLStylesContext::CreateStyleStyleChildContext( nFamily, nElement,
xAttrList );
if (!pStyle)
{
@@ -270,7 +260,7 @@ SvXMLStyleContext *OReportStylesContext::CreateStyleStyleChildContext(
case XmlStyleFamily::TABLE_COLUMN:
case XmlStyleFamily::TABLE_ROW:
case XmlStyleFamily::TABLE_CELL:
pStyle = new OControlStyleContext( GetOwnImport(), nPrefix, rLocalName,
pStyle = new OControlStyleContext( GetOwnImport(), nElement,
xAttrList, *this, nFamily );
break;
default:
@@ -46,9 +46,8 @@ namespace rptxml
public:
OControlStyleContext( ORptFilter& rImport, sal_uInt16 nPrfx,
const OUString& rLName,
const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList,
OControlStyleContext( ORptFilter& rImport, sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
SvXMLStylesContext& rStyles, XmlStyleFamily nFamily );
virtual ~OControlStyleContext() override;
@@ -86,16 +85,16 @@ namespace rptxml
protected:
// Create a style context.
using SvXMLStylesContext::CreateStyleStyleChildContext;
virtual SvXMLStyleContext *CreateStyleStyleChildContext(
XmlStyleFamily nFamily,
sal_uInt16 nPrefix,
const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override;
using SvXMLStylesContext::CreateDefaultStyleStyleChildContext;
virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
XmlStyleFamily nFamily, sal_uInt16 nPrefix,
const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
XmlStyleFamily nFamily, sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override;
public:
+3
View File
@@ -139,12 +139,14 @@ class XMLTableStylesContext : public SvXMLStylesContext
protected:
// Create a style context.
using SvXMLStylesContext::CreateStyleStyleChildContext;
virtual SvXMLStyleContext *CreateStyleStyleChildContext(
XmlStyleFamily nFamily,
sal_uInt16 nPrefix,
const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
using SvXMLStylesContext::CreateDefaultStyleStyleChildContext;
virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
XmlStyleFamily nFamily, sal_uInt16 nPrefix,
const OUString& rLocalName,
@@ -173,6 +175,7 @@ protected:
virtual SvXMLStyleContext *CreateStyleChildContext( sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override;
using SvXMLStylesContext::CreateStyleStyleChildContext;
virtual SvXMLStyleContext *CreateStyleStyleChildContext( XmlStyleFamily nFamily,
sal_uInt16 nPrefix, const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
+2
View File
@@ -754,9 +754,11 @@ protected:
virtual SvXMLStyleContext *CreateStyleChildContext( sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override;
using SvXMLStylesContext::CreateStyleStyleChildContext;
virtual SvXMLStyleContext *CreateStyleStyleChildContext( XmlStyleFamily nFamily,
sal_uInt16 nPrefix, const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList > & xAttrList ) override;
using SvXMLStylesContext::CreateDefaultStyleStyleChildContext;
virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
XmlStyleFamily nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList > & xAttrList ) override;
@@ -54,6 +54,11 @@ XMLGraphicsDefaultStyle::XMLGraphicsDefaultStyle( SvXMLImport& rImport, sal_uInt
{
}
XMLGraphicsDefaultStyle::XMLGraphicsDefaultStyle( SvXMLImport& rImport, sal_Int32 nElement, const Reference< XFastAttributeList >& xAttrList, SvXMLStylesContext& rStyles )
: XMLPropStyleContext( rImport, nElement, xAttrList, rStyles, XmlStyleFamily::SD_GRAPHICS_ID, true )
{
}
XMLGraphicsDefaultStyle::~XMLGraphicsDefaultStyle()
{
}
+2
View File
@@ -187,12 +187,14 @@ protected:
sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList) override;
using SvXMLStylesContext::CreateStyleStyleChildContext;
virtual SvXMLStyleContext *CreateStyleStyleChildContext(
XmlStyleFamily nFamily,
sal_uInt16 nPrefix,
const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList) override;
using SvXMLStylesContext::CreateDefaultStyleStyleChildContext;
virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
XmlStyleFamily nFamily, sal_uInt16 nPrefix,
const OUString& rLocalName,
+34
View File
@@ -416,6 +416,23 @@ SvXMLStyleContext *SvXMLStylesContext::CreateStyleChildContext(
switch (nElement)
{
case XML_ELEMENT(STYLE, XML_STYLE):
case XML_ELEMENT(STYLE, XML_DEFAULT_STYLE):
{
XmlStyleFamily nFamily = XmlStyleFamily::DATA_STYLE;
for( auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ) )
{
if( aIter.getToken() == XML_ELEMENT(STYLE, XML_FAMILY) )
{
nFamily = GetFamily( aIter.toString() );
break;
}
}
pStyle = XML_ELEMENT(STYLE, XML_STYLE)==nElement
? CreateStyleStyleChildContext( nFamily, nElement, xAttrList )
: CreateDefaultStyleStyleChildContext( nFamily, nElement, xAttrList );
break;
}
case XML_ELEMENT(TEXT, XML_BIBLIOGRAPHY_CONFIGURATION):
pStyle = new XMLIndexBibliographyConfigurationContext(
GetImport(), nElement, xAttrList);
@@ -477,6 +494,9 @@ SvXMLStyleContext *SvXMLStylesContext::CreateStyleChildContext(
}
}
if (!pStyle)
SAL_WARN("xmloff", "Unknown element " << SvXMLImport::getPrefixAndNameFromToken(nElement));
return pStyle;
}
@@ -561,6 +581,13 @@ SvXMLStyleContext *SvXMLStylesContext::CreateStyleStyleChildContext(
return pStyle;
}
SvXMLStyleContext *SvXMLStylesContext::CreateStyleStyleChildContext(
XmlStyleFamily /*nFamily*/, sal_Int32 /*nElement*/,
const uno::Reference< xml::sax::XFastAttributeList > & /*xAttrList*/ )
{
return nullptr;
}
SvXMLStyleContext *SvXMLStylesContext::CreateDefaultStyleStyleChildContext(
XmlStyleFamily /*nFamily*/, sal_uInt16 /*nPrefix*/, const OUString& /*rLocalName*/,
const uno::Reference< xml::sax::XAttributeList > & )
@@ -568,6 +595,13 @@ SvXMLStyleContext *SvXMLStylesContext::CreateDefaultStyleStyleChildContext(
return nullptr;
}
SvXMLStyleContext *SvXMLStylesContext::CreateDefaultStyleStyleChildContext(
XmlStyleFamily /*nFamily*/, sal_Int32 /*nElement*/,
const uno::Reference< xml::sax::XFastAttributeList > & )
{
return nullptr;
}
bool SvXMLStylesContext::InsertStyleFamily( XmlStyleFamily ) const
{
return true;