summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-12-07 22:04:40 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-12-08 07:50:58 +0100
commit7896173f7ff017e338721b8079f00634a8879dab (patch)
treef465f88267d01b469bfe5b727b620b96abaadb31 /xmloff
parent491992d0229afedba29b14778c918f6f9d2d7a07 (diff)
fastparser in styles
Change-Id: I39d285f1dd7dd18c396db96863f77f511741951c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107364 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/PageMasterImportContext.hxx3
-rw-r--r--xmloff/inc/XMLChartStyleContext.hxx4
-rw-r--r--xmloff/inc/XMLFootnoteConfigurationImportContext.hxx10
-rw-r--r--xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx3
-rw-r--r--xmloff/inc/XMLLineNumberingImportContext.hxx3
-rw-r--r--xmloff/source/chart/XMLChartStyleContext.cxx22
-rw-r--r--xmloff/source/draw/XMLShapeStyleContext.cxx16
-rw-r--r--xmloff/source/style/PageMasterImportContext.cxx8
-rw-r--r--xmloff/source/style/XMLFontStylesContext.cxx31
-rw-r--r--xmloff/source/style/XMLFontStylesContext_impl.hxx6
-rw-r--r--xmloff/source/style/prstylei.cxx7
-rw-r--r--xmloff/source/style/xmlnumfi.cxx2
-rw-r--r--xmloff/source/style/xmlnumi.cxx8
-rw-r--r--xmloff/source/style/xmlstyle.cxx55
-rw-r--r--xmloff/source/table/XMLTableImport.cxx10
-rw-r--r--xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx41
-rw-r--r--xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx52
-rw-r--r--xmloff/source/text/XMLLineNumberingImportContext.cxx56
-rw-r--r--xmloff/source/text/XMLTextShapeStyleContext.cxx8
-rw-r--r--xmloff/source/text/txtstyli.cxx38
20 files changed, 138 insertions, 245 deletions
diff --git a/xmloff/inc/PageMasterImportContext.hxx b/xmloff/inc/PageMasterImportContext.hxx
index 08b361fbb84c..44cf86bc99e0 100644
--- a/xmloff/inc/PageMasterImportContext.hxx
+++ b/xmloff/inc/PageMasterImportContext.hxx
@@ -29,8 +29,7 @@ private:
OUString sPageUsage;
bool m_bIsFillStyleAlreadyConverted : 1;
- virtual void SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+ virtual void SetAttribute( sal_Int32 nElement,
const OUString& rValue ) override;
public:
diff --git a/xmloff/inc/XMLChartStyleContext.hxx b/xmloff/inc/XMLChartStyleContext.hxx
index c22df28ffa75..f88be429b8a5 100644
--- a/xmloff/inc/XMLChartStyleContext.hxx
+++ b/xmloff/inc/XMLChartStyleContext.hxx
@@ -29,9 +29,7 @@ private:
SvXMLStylesContext& mrStyles;
/// is called when an attribute at the (auto)style element is found
- virtual void SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
- const OUString& rValue ) override;
+ virtual void SetAttribute( sal_Int32 nElement, const OUString& rValue ) override;
public:
diff --git a/xmloff/inc/XMLFootnoteConfigurationImportContext.hxx b/xmloff/inc/XMLFootnoteConfigurationImportContext.hxx
index 04cc2c8bc17a..aaccbd4f3da2 100644
--- a/xmloff/inc/XMLFootnoteConfigurationImportContext.hxx
+++ b/xmloff/inc/XMLFootnoteConfigurationImportContext.hxx
@@ -44,17 +44,14 @@ class XMLFootnoteConfigurationImportContext final : public SvXMLStyleContext
OUString sBeginNotice;
OUString sEndNotice;
- std::unique_ptr<SvXMLTokenMap> pAttrTokenMap;
-
sal_Int16 nOffset;
sal_Int16 nNumbering;
bool bPosition;
bool bIsEndnote;
/// parse attributes
- virtual void SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
- const OUString& rValue ) override;
+ virtual void SetAttribute( sal_Int32 nElement, const OUString& rValue ) override;
+
public:
@@ -69,9 +66,6 @@ public:
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
- /// get token map for attributes
- const SvXMLTokenMap& GetFtnConfigAttrTokenMap();
-
/// set configuration at document; calls ProcessSettings
/* Move code from <CreateAndInsertLate(..)> to <Finish(..)>, because
at this time all styles it references have been set. (#i40579#)
diff --git a/xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx b/xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx
index d02e799200c3..d3f689b90349 100644
--- a/xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx
+++ b/xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx
@@ -60,8 +60,7 @@ public:
private:
- virtual void SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+ virtual void SetAttribute( sal_Int32 nElement,
const OUString& rValue ) override;
virtual void CreateAndInsert( bool bOverwrite ) override;
diff --git a/xmloff/inc/XMLLineNumberingImportContext.hxx b/xmloff/inc/XMLLineNumberingImportContext.hxx
index 4baeb35048a4..fd0f4597f934 100644
--- a/xmloff/inc/XMLLineNumberingImportContext.hxx
+++ b/xmloff/inc/XMLLineNumberingImportContext.hxx
@@ -75,8 +75,7 @@ public:
private:
- virtual void SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+ virtual void SetAttribute( sal_Int32 nElement,
const OUString& rValue ) override;
virtual void CreateAndInsert(bool bOverwrite) override;
diff --git a/xmloff/source/chart/XMLChartStyleContext.cxx b/xmloff/source/chart/XMLChartStyleContext.cxx
index b000a36b2f03..1f8fa14eee27 100644
--- a/xmloff/source/chart/XMLChartStyleContext.cxx
+++ b/xmloff/source/chart/XMLChartStyleContext.cxx
@@ -42,21 +42,19 @@ using ::xmloff::token::XML_CHART_PROPERTIES;
void XMLChartStyleContext::SetAttribute(
- sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+ sal_Int32 nElement,
const OUString& rValue )
{
- if( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) )
- {
- msDataStyleName =rValue;
- }
- else if( IsXMLToken( rLocalName, XML_PERCENTAGE_DATA_STYLE_NAME ) )
- {
- msPercentageDataStyleName =rValue;
- }
- else
+ switch (nElement & TOKEN_MASK)
{
- XMLShapeStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ case XML_DATA_STYLE_NAME:
+ msDataStyleName = rValue;
+ break;
+ case XML_PERCENTAGE_DATA_STYLE_NAME:
+ msPercentageDataStyleName = rValue;
+ break;
+ default:
+ XMLShapeStyleContext::SetAttribute( nElement, rValue );
}
}
diff --git a/xmloff/source/draw/XMLShapeStyleContext.cxx b/xmloff/source/draw/XMLShapeStyleContext.cxx
index 5dd1da864f05..1da9e11cf074 100644
--- a/xmloff/source/draw/XMLShapeStyleContext.cxx
+++ b/xmloff/source/draw/XMLShapeStyleContext.cxx
@@ -42,10 +42,7 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::drawing;
-using ::xmloff::token::IsXMLToken;
-using ::xmloff::token::XML_TEXT_PROPERTIES;
-using ::xmloff::token::XML_GRAPHIC_PROPERTIES;
-using ::xmloff::token::XML_PARAGRAPH_PROPERTIES;
+using namespace ::xmloff::token;
XMLShapeStyleContext::XMLShapeStyleContext(
@@ -61,22 +58,21 @@ XMLShapeStyleContext::~XMLShapeStyleContext()
{
}
-void XMLShapeStyleContext::SetAttribute( sal_uInt16 nPrefixKey, const OUString& rLocalName, const OUString& rValue )
+void XMLShapeStyleContext::SetAttribute( sal_Int32 nElement, const OUString& rValue )
{
- if (m_sControlDataStyleName.isEmpty() && (::xmloff::token::GetXMLToken(::xmloff::token::XML_DATA_STYLE_NAME) == rLocalName))
+ if (m_sControlDataStyleName.isEmpty() && (nElement & TOKEN_MASK) == XML_DATA_STYLE_NAME)
{
m_sControlDataStyleName = rValue;
}
- else if( (XML_NAMESPACE_STYLE == nPrefixKey) && IsXMLToken( rLocalName, ::xmloff::token::XML_LIST_STYLE_NAME ) )
+ else if( nElement == XML_ELEMENT(STYLE, XML_LIST_STYLE_NAME) )
{
m_sListStyleName = rValue;
}
else
{
- XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ XMLPropStyleContext::SetAttribute( nElement, rValue );
- if( (XML_NAMESPACE_STYLE == nPrefixKey) &&
- ( IsXMLToken( rLocalName, ::xmloff::token::XML_NAME ) || IsXMLToken( rLocalName, ::xmloff::token::XML_DISPLAY_NAME ) ) )
+ if( nElement == XML_ELEMENT(STYLE, XML_NAME) || nElement == XML_ELEMENT(STYLE, XML_DISPLAY_NAME) )
{
if( !GetName().isEmpty() && !GetDisplayName().isEmpty() && GetName() != GetDisplayName() )
{
diff --git a/xmloff/source/style/PageMasterImportContext.cxx b/xmloff/source/style/PageMasterImportContext.cxx
index 7d70190cec89..17d9bf7986da 100644
--- a/xmloff/source/style/PageMasterImportContext.cxx
+++ b/xmloff/source/style/PageMasterImportContext.cxx
@@ -44,18 +44,16 @@ using namespace ::com::sun::star::lang;
//
using namespace ::com::sun::star::beans;
-void PageStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+void PageStyleContext::SetAttribute( sal_Int32 nElement,
const OUString& rValue )
{
- // TODO: use a map here
- if( XML_NAMESPACE_STYLE == nPrefixKey && IsXMLToken( rLocalName, XML_PAGE_USAGE ) )
+ if( nElement == XML_ELEMENT(STYLE, XML_PAGE_USAGE) )
{
sPageUsage = rValue;
}
else
{
- XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ XMLPropStyleContext::SetAttribute( nElement, rValue );
}
}
diff --git a/xmloff/source/style/XMLFontStylesContext.cxx b/xmloff/source/style/XMLFontStylesContext.cxx
index bdd86c93bd73..db22711e039c 100644
--- a/xmloff/source/style/XMLFontStylesContext.cxx
+++ b/xmloff/source/style/XMLFontStylesContext.cxx
@@ -95,41 +95,40 @@ XMLFontStyleContextFontFace::XMLFontStyleContextFontFace( SvXMLImport& rImport,
aEnc <<= static_cast<sal_Int16>(rStyles.GetDfltCharset());
}
-void XMLFontStyleContextFontFace::SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+void XMLFontStyleContextFontFace::SetAttribute( sal_Int32 nElement,
const OUString& rValue )
{
SvXMLUnitConverter& rUnitConv = GetImport().GetMM100UnitConverter();
- const SvXMLTokenMap& rTokenMap = GetStyles()->GetFontStyleAttrTokenMap();
Any aAny;
- switch( rTokenMap.Get( nPrefixKey, rLocalName ) )
+ switch(nElement)
{
- case XML_TOK_FONT_STYLE_ATTR_FAMILY:
+ case XML_ELEMENT(SVG, XML_FONT_FAMILY):
+ case XML_ELEMENT(SVG_COMPAT, XML_FONT_FAMILY):
if( GetStyles()->GetFamilyNameHdl().importXML( rValue, aAny,
rUnitConv ) )
aFamilyName = aAny;
break;
- case XML_TOK_FONT_STYLE_ATTR_STYLENAME:
+ case XML_ELEMENT(STYLE, XML_FONT_ADORNMENTS):
aStyleName <<= rValue;
break;
- case XML_TOK_FONT_STYLE_ATTR_FAMILY_GENERIC:
+ case XML_ELEMENT(STYLE, XML_FONT_FAMILY_GENERIC):
if( GetStyles()->GetFamilyHdl().importXML( rValue, aAny,
rUnitConv ) )
aFamily = aAny;
break;
- case XML_TOK_FONT_STYLE_ATTR_PITCH:
+ case XML_ELEMENT(STYLE, XML_FONT_PITCH):
if( GetStyles()->GetPitchHdl().importXML( rValue, aAny,
rUnitConv ) )
aPitch = aAny;
break;
- case XML_TOK_FONT_STYLE_ATTR_CHARSET:
+ case XML_ELEMENT(STYLE, XML_FONT_CHARSET):
if( GetStyles()->GetEncodingHdl().importXML( rValue, aAny,
rUnitConv ) )
aEnc = aAny;
break;
default:
- SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ SvXMLStyleContext::SetAttribute( nElement, rValue );
break;
}
}
@@ -200,13 +199,13 @@ XMLFontStyleContextFontFaceFormat::XMLFontStyleContextFontFaceFormat( SvXMLImpor
{
}
-void XMLFontStyleContextFontFaceFormat::SetAttribute( sal_uInt16 nPrefixKey, const OUString& rLocalName,
+void XMLFontStyleContextFontFaceFormat::SetAttribute( sal_Int32 nElement,
const OUString& rValue )
{
- if( nPrefixKey == XML_NAMESPACE_SVG && IsXMLToken( rLocalName, XML_STRING ))
+ if( nElement == XML_ELEMENT(SVG, XML_STRING) || nElement == XML_ELEMENT(SVG_COMPAT, XML_STRING))
uri.SetFormat(rValue);
else
- SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ SvXMLStyleContext::SetAttribute( nElement, rValue );
}
@@ -257,13 +256,13 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLFontStyleContextFon
return nullptr;
}
-void XMLFontStyleContextFontFaceUri::SetAttribute( sal_uInt16 nPrefixKey, const OUString& rLocalName,
+void XMLFontStyleContextFontFaceUri::SetAttribute( sal_Int32 nElement,
const OUString& rValue )
{
- if( nPrefixKey == XML_NAMESPACE_XLINK && IsXMLToken( rLocalName, XML_HREF ))
+ if( nElement == XML_ELEMENT(XLINK, XML_HREF) )
linkPath = rValue;
else
- SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ SvXMLStyleContext::SetAttribute( nElement, rValue );
}
void XMLFontStyleContextFontFaceUri::SetFormat( const OUString& rFormat )
diff --git a/xmloff/source/style/XMLFontStylesContext_impl.hxx b/xmloff/source/style/XMLFontStylesContext_impl.hxx
index 72f5af7e2347..2c76ecc6955b 100644
--- a/xmloff/source/style/XMLFontStylesContext_impl.hxx
+++ b/xmloff/source/style/XMLFontStylesContext_impl.hxx
@@ -49,7 +49,7 @@ public:
XMLFontStylesContext& rStyles );
virtual ~XMLFontStyleContextFontFace() override;
- void SetAttribute( sal_uInt16 nPrefixKey, const OUString& rLocalName,
+ void SetAttribute( sal_Int32 nElement,
const OUString& rValue ) override;
void FillProperties( ::std::vector< XMLPropertyState > &rProps,
@@ -98,7 +98,7 @@ public:
XMLFontStyleContextFontFaceUri( SvXMLImport& rImport,
const XMLFontStyleContextFontFace& font );
- virtual void SetAttribute( sal_uInt16 nPrefixKey, const OUString& rLocalName,
+ virtual void SetAttribute( sal_Int32 nElement,
const OUString& rValue ) override;
void SetFormat( const OUString& rFormat );
void SAL_CALL endFastElement(sal_Int32 nElement) override;
@@ -116,7 +116,7 @@ public:
XMLFontStyleContextFontFaceFormat( SvXMLImport& rImport,
XMLFontStyleContextFontFaceUri& uri );
- void SetAttribute( sal_uInt16 nPrefixKey, const OUString& rLocalName,
+ void SetAttribute( sal_Int32 nElement,
const OUString& rValue ) override;
};
diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx
index 5ed852e98e48..3bf2c8ad8af6 100644
--- a/xmloff/source/style/prstylei.cxx
+++ b/xmloff/source/style/prstylei.cxx
@@ -54,17 +54,16 @@ using namespace ::com::sun::star::lang;
using namespace ::xmloff::token;
using namespace com::sun::star::drawing;
-void XMLPropStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+void XMLPropStyleContext::SetAttribute( sal_Int32 nElement,
const OUString& rValue )
{
- if( XML_NAMESPACE_STYLE == nPrefixKey && IsXMLToken( rLocalName, XML_FAMILY ) )
+ if( nElement == XML_ELEMENT(STYLE, XML_FAMILY) )
{
SAL_WARN_IF( GetFamily() != SvXMLStylesContext::GetFamily( rValue ), "xmloff", "unexpected style family" );
}
else
{
- SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ SvXMLStyleContext::SetAttribute( nElement, rValue );
}
}
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index 85c967eea110..1910950e9662 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -1276,7 +1276,7 @@ SvXMLNumFormatContext::SvXMLNumFormatContext( SvXMLImport& rImport,
eDateSecs( XML_DEA_NONE ),
bDateNoDefault( false )
{
- SetAttribute(XML_NAMESPACE_STYLE, GetXMLToken(XML_NAME), rName);
+ SetAttribute(XML_ELEMENT(STYLE, XML_NAME), rName);
}
SvXMLNumFormatContext::~SvXMLNumFormatContext()
diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx
index 16eff2be6aff..dae61e273821 100644
--- a/xmloff/source/style/xmlnumi.cxx
+++ b/xmloff/source/style/xmlnumi.cxx
@@ -845,18 +845,16 @@ SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::SvxXMLListLevelStyleLabelAli
rLLevel.SetLabelFollowedBy( eLabelFollowedBy );
}
-void SvxXMLListStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+void SvxXMLListStyleContext::SetAttribute( sal_Int32 nElement,
const OUString& rValue )
{
- if( XML_NAMESPACE_TEXT == nPrefixKey &&
- IsXMLToken( rLocalName, XML_CONSECUTIVE_NUMBERING ) )
+ if( nElement == XML_ELEMENT(TEXT, XML_CONSECUTIVE_NUMBERING) )
{
bConsecutive = IsXMLToken( rValue, XML_TRUE );
}
else
{
- SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ SvXMLStyleContext::SetAttribute( nElement, rValue );
}
}
diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx
index fdaf07f47b4d..264a57282a8e 100644
--- a/xmloff/source/style/xmlstyle.cxx
+++ b/xmloff/source/style/xmlstyle.cxx
@@ -62,47 +62,37 @@ using namespace ::xmloff::token;
constexpr OUStringLiteral gsParaStyleServiceName( u"com.sun.star.style.ParagraphStyle" );
constexpr OUStringLiteral gsTextStyleServiceName( u"com.sun.star.style.CharacterStyle" );
-void SvXMLStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+void SvXMLStyleContext::SetAttribute( sal_Int32 nElement,
const OUString& rValue )
{
- // TODO: use a map here
- if( XML_NAMESPACE_STYLE == nPrefixKey )
+ switch (nElement)
{
- if( IsXMLToken( rLocalName, XML_FAMILY ) )
+ case XML_ELEMENT(STYLE, XML_FAMILY):
{
if( IsXMLToken( rValue, XML_PARAGRAPH ) )
mnFamily = XmlStyleFamily(SfxStyleFamily::Para);
else if( IsXMLToken( rValue, XML_TEXT ) )
mnFamily = XmlStyleFamily(SfxStyleFamily::Char);
+ break;
}
- else if( IsXMLToken( rLocalName, XML_NAME ) )
- {
+ case XML_ELEMENT(STYLE, XML_NAME):
maName = rValue;
- }
- else if( IsXMLToken( rLocalName, XML_DISPLAY_NAME ) )
- {
+ break;
+ case XML_ELEMENT(STYLE, XML_DISPLAY_NAME):
maDisplayName = rValue;
- }
- else if( IsXMLToken( rLocalName, XML_PARENT_STYLE_NAME ) )
- {
+ break;
+ case XML_ELEMENT(STYLE, XML_PARENT_STYLE_NAME):
maParentName = rValue;
- }
- else if( IsXMLToken( rLocalName, XML_NEXT_STYLE_NAME ) )
- {
+ break;
+ case XML_ELEMENT(STYLE, XML_NEXT_STYLE_NAME):
maFollow = rValue;
- }
- else if( IsXMLToken( rLocalName, XML_HIDDEN ) )
- {
+ break;
+ case XML_ELEMENT(STYLE, XML_HIDDEN):
mbHidden = rValue.toBoolean();
- }
- }
- else if (XML_NAMESPACE_LO_EXT == nPrefixKey)
- {
- if (IsXMLToken(rLocalName, XML_HIDDEN))
- {
+ break;
+ case XML_ELEMENT(LO_EXT, XML_HIDDEN):
mbHidden = rValue.toBoolean();
- }
+ break;
}
}
@@ -127,19 +117,8 @@ void SvXMLStyleContext::startFastElement(
sal_Int32 /*nElement*/,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
{
- // Fall back from fastparser to slowparser code
for( auto &it : sax_fastparser::castToFastAttributeList( xAttrList ) )
- {
- sal_Int32 nToken = it.getToken();
- const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken(nToken, &GetImport().GetNamespaceMap());
- OUString sAttrName = SvXMLImport::getNameFromToken( nToken );
- if ( !rAttrNamespacePrefix.isEmpty() )
- sAttrName = rAttrNamespacePrefix + SvXMLImport::aNamespaceSeparator + sAttrName;
- OUString aLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
-
- SetAttribute( nPrefix, aLocalName, it.toString() );
- }
+ SetAttribute( it.getToken(), it.toString() );
}
void SvXMLStyleContext::SetDefaults()
diff --git a/xmloff/source/table/XMLTableImport.cxx b/xmloff/source/table/XMLTableImport.cxx
index a03fa8445524..6d8b30f474ce 100644
--- a/xmloff/source/table/XMLTableImport.cxx
+++ b/xmloff/source/table/XMLTableImport.cxx
@@ -169,8 +169,7 @@ public:
virtual void CreateAndInsert( bool bOverwrite ) override;
protected:
- virtual void SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+ virtual void SetAttribute( sal_Int32 nElement,
const OUString& rValue ) override;
private:
XMLTableTemplate maTableTemplate;
@@ -732,13 +731,12 @@ XMLTableTemplateContext::XMLTableTemplateContext( SvXMLImport& rImport )
{
}
-void XMLTableTemplateContext::SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+void XMLTableTemplateContext::SetAttribute( sal_Int32 nElement,
const OUString& rValue )
{
- if( (nPrefixKey == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_STYLE_NAME ))
+ if( nElement == XML_ELEMENT(TEXT, XML_STYLE_NAME)
// Writer specific: according to oasis odf 1.2 prefix should be "table" and element name should be "name"
- || (nPrefixKey == XML_NAMESPACE_TABLE && IsXMLToken( rLocalName, XML_NAME )))
+ || nElement == XML_ELEMENT(TABLE, XML_NAME) )
{
msTemplateStyleName = rValue;
}
diff --git a/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx b/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx
index d4415ff29c04..a7d4b93349d5 100644
--- a/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx
+++ b/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx
@@ -190,17 +190,6 @@ const SvXMLTokenMapEntry aTextFieldAttrTokenMap[] =
XML_TOKEN_MAP_END
};
-const SvXMLTokenMap&
- XMLFootnoteConfigurationImportContext::GetFtnConfigAttrTokenMap()
-{
- if (!pAttrTokenMap)
- {
- pAttrTokenMap.reset( new SvXMLTokenMap(aTextFieldAttrTokenMap) );
- }
-
- return *pAttrTokenMap;
-}
-
SvXMLEnumMapEntry<sal_Int16> const aFootnoteNumberingMap[] =
{
{ XML_PAGE, FootnoteNumbering::PER_PAGE },
@@ -209,25 +198,25 @@ SvXMLEnumMapEntry<sal_Int16> const aFootnoteNumberingMap[] =
{ XML_TOKEN_INVALID, 0 },
};
-void XMLFootnoteConfigurationImportContext::SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+void XMLFootnoteConfigurationImportContext::SetAttribute( sal_Int32 nElement,
const OUString& rValue )
{
- switch (GetFtnConfigAttrTokenMap().Get(nPrefixKey, rLocalName))
+ switch (nElement)
{
- case XML_TOK_FTNCONFIG_CITATION_STYLENAME:
+ case XML_ELEMENT(TEXT, XML_CITATION_STYLE_NAME):
sCitationStyle = rValue;
break;
- case XML_TOK_FTNCONFIG_ANCHOR_STYLENAME:
+ case XML_ELEMENT(TEXT, XML_CITATION_BODY_STYLE_NAME):
sAnchorStyle = rValue;
break;
- case XML_TOK_FTNCONFIG_DEFAULT_STYLENAME:
+ case XML_ELEMENT(TEXT, XML_DEFAULT_STYLE_NAME):
sDefaultStyle = rValue;
break;
- case XML_TOK_FTNCONFIG_PAGE_STYLENAME:
+ case XML_ELEMENT(TEXT, XML_MASTER_PAGE_NAME):
sPageStyle = rValue;
break;
- case XML_TOK_FTNCONFIG_OFFSET:
+ case XML_ELEMENT(TEXT, XML_START_VALUE):
+ case XML_ELEMENT(TEXT, XML_OFFSET): // for backwards compatibility with SRC630 & earlier
{
sal_Int32 nTmp;
if (::sax::Converter::convertNumber(nTmp, rValue))
@@ -236,25 +225,27 @@ void XMLFootnoteConfigurationImportContext::SetAttribute( sal_uInt16 nPrefixKey,
}
break;
}
- case XML_TOK_FTNCONFIG_NUM_PREFIX:
+ case XML_ELEMENT(STYLE, XML_NUM_PREFIX):
+ case XML_ELEMENT(TEXT, XML_NUM_PREFIX): // for backwards compatibility with SRC630 & earlier
sPrefix = rValue;
break;
- case XML_TOK_FTNCONFIG_NUM_SUFFIX:
+ case XML_ELEMENT(STYLE, XML_NUM_SUFFIX):
+ case XML_ELEMENT(TEXT, XML_NUM_SUFFIX): // for backwards compatibility with SRC630 & earlier
sSuffix = rValue;
break;
- case XML_TOK_FTNCONFIG_NUM_FORMAT:
+ case XML_ELEMENT(STYLE, XML_NUM_FORMAT):
sNumFormat = rValue;
break;
- case XML_TOK_FTNCONFIG_NUM_SYNC:
+ case XML_ELEMENT(STYLE, XML_NUM_LETTER_SYNC):
sNumSync = rValue;
break;
- case XML_TOK_FTNCONFIG_START_AT:
+ case XML_ELEMENT(TEXT, XML_START_NUMBERING_AT):
{
(void)SvXMLUnitConverter::convertEnum(nNumbering, rValue,
aFootnoteNumberingMap);
break;
}
- case XML_TOK_FTNCONFIG_POSITION:
+ case XML_ELEMENT(TEXT, XML_FOOTNOTES_POSITION):
bPosition = IsXMLToken( rValue, XML_DOCUMENT );
break;
default:
diff --git a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
index 6b1b7e5d37bf..759c786f8aa8 100644
--- a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
+++ b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
@@ -73,62 +73,50 @@ XMLIndexBibliographyConfigurationContext::~XMLIndexBibliographyConfigurationCont
}
void XMLIndexBibliographyConfigurationContext::SetAttribute(
- sal_uInt16 nPrefix,
- const OUString& sLocalName,
+ sal_Int32 nElement,
const OUString& sValue)
{
- if( XML_NAMESPACE_TEXT == nPrefix )
+ switch (nElement)
{
- if( IsXMLToken(sLocalName, XML_PREFIX) )
- {
+ case XML_ELEMENT(TEXT, XML_PREFIX):
sPrefix = sValue;
- }
- else if( IsXMLToken(sLocalName, XML_SUFFIX) )
- {
+ break;
+ case XML_ELEMENT(TEXT, XML_SUFFIX):
sSuffix = sValue;
- }
- else if( IsXMLToken(sLocalName, XML_NUMBERED_ENTRIES) )
+ break;
+ case XML_ELEMENT(TEXT, XML_NUMBERED_ENTRIES):
{
bool bTmp(false);
if (::sax::Converter::convertBool(bTmp, sValue))
{
bNumberedEntries = bTmp;
}
+ break;
}
- else if( IsXMLToken(sLocalName, XML_SORT_BY_POSITION) )
+ case XML_ELEMENT(TEXT, XML_SORT_BY_POSITION):
{
bool bTmp(false);
if (::sax::Converter::convertBool(bTmp, sValue))
{
bSortByPosition = bTmp;
}
+ break;
}
- else if( IsXMLToken(sLocalName, XML_SORT_ALGORITHM) )
- {
+ case XML_ELEMENT(TEXT, XML_SORT_ALGORITHM):
sAlgorithm = sValue;
- }
- }
- else if( XML_NAMESPACE_FO == nPrefix )
- {
- if( IsXMLToken(sLocalName, XML_LANGUAGE) )
- {
+ break;
+ case XML_ELEMENT(FO, XML_LANGUAGE):
maLanguageTagODF.maLanguage = sValue;
- }
- else if( IsXMLToken(sLocalName, XML_SCRIPT) )
- {
+ break;
+ case XML_ELEMENT(FO, XML_SCRIPT):
maLanguageTagODF.maScript = sValue;
- }
- else if( IsXMLToken(sLocalName, XML_COUNTRY) )
- {
+ break;
+ case XML_ELEMENT(FO, XML_COUNTRY):
maLanguageTagODF.maCountry = sValue;
- }
- }
- else if( XML_NAMESPACE_STYLE == nPrefix )
- {
- if( IsXMLToken(sLocalName, XML_RFC_LANGUAGE_TAG) )
- {
+ break;
+ case XML_ELEMENT(STYLE, XML_RFC_LANGUAGE_TAG):
maLanguageTagODF.maRfcLanguageTag = sValue;
- }
+ break;
}
}
diff --git a/xmloff/source/text/XMLLineNumberingImportContext.cxx b/xmloff/source/text/XMLLineNumberingImportContext.cxx
index fde276850f9c..ad0f162013c0 100644
--- a/xmloff/source/text/XMLLineNumberingImportContext.cxx
+++ b/xmloff/source/text/XMLLineNumberingImportContext.cxx
@@ -76,79 +76,47 @@ XMLLineNumberingImportContext::~XMLLineNumberingImportContext()
{
}
-void XMLLineNumberingImportContext::SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+void XMLLineNumberingImportContext::SetAttribute( sal_Int32 nElement,
const OUString& rValue )
{
- static const SvXMLTokenMapEntry aLineNumberingTokenMap[] =
- {
- { XML_NAMESPACE_TEXT, XML_STYLE_NAME, XML_TOK_LINENUMBERING_STYLE_NAME },
- { XML_NAMESPACE_TEXT, XML_NUMBER_LINES,
- XML_TOK_LINENUMBERING_NUMBER_LINES },
- { XML_NAMESPACE_TEXT, XML_COUNT_EMPTY_LINES,
- XML_TOK_LINENUMBERING_COUNT_EMPTY_LINES },
- { XML_NAMESPACE_TEXT, XML_COUNT_IN_TEXT_BOXES,
- XML_TOK_LINENUMBERING_COUNT_IN_TEXT_BOXES },
- { XML_NAMESPACE_TEXT, XML_RESTART_ON_PAGE,
- XML_TOK_LINENUMBERING_RESTART_NUMBERING },
- { XML_NAMESPACE_TEXT, XML_OFFSET, XML_TOK_LINENUMBERING_OFFSET },
- { XML_NAMESPACE_STYLE, XML_NUM_FORMAT, XML_TOK_LINENUMBERING_NUM_FORMAT },
- { XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC,
- XML_TOK_LINENUMBERING_NUM_LETTER_SYNC },
- { XML_NAMESPACE_TEXT, XML_NUMBER_POSITION,
- XML_TOK_LINENUMBERING_NUMBER_POSITION },
- { XML_NAMESPACE_TEXT, XML_INCREMENT, XML_TOK_LINENUMBERING_INCREMENT },
- // { XML_NAMESPACE_TEXT, XML_LINENUMBERING_CONFIGURATION,
- // XML_TOK_LINENUMBERING_LINENUMBERING_CONFIGURATION },
- // { XML_NAMESPACE_TEXT, XML_INCREMENT, XML_TOK_LINENUMBERING_INCREMENT },
- // { XML_NAMESPACE_TEXT, XML_LINENUMBERING_SEPARATOR,
- // XML_TOK_LINENUMBERING_LINENUMBERING_SEPARATOR },
-
- XML_TOKEN_MAP_END
- };
-
- static const SvXMLTokenMap aTokenMap(aLineNumberingTokenMap);
-
- auto eToken = aTokenMap.Get(nPrefixKey, rLocalName);
-
bool bTmp(false);
sal_Int32 nTmp;
- switch (eToken)
+ switch (nElement)
{
- case XML_TOK_LINENUMBERING_STYLE_NAME:
+ case XML_ELEMENT(TEXT, XML_STYLE_NAME):
sStyleName = rValue;
break;
- case XML_TOK_LINENUMBERING_NUMBER_LINES:
+ case XML_ELEMENT(TEXT, XML_NUMBER_LINES):
if (::sax::Converter::convertBool(bTmp, rValue))
{
bNumberLines = bTmp;
}
break;
- case XML_TOK_LINENUMBERING_COUNT_EMPTY_LINES:
+ case XML_ELEMENT(TEXT, XML_COUNT_EMPTY_LINES):
if (::sax::Converter::convertBool(bTmp, rValue))
{
bCountEmptyLines = bTmp;
}
break;
- case XML_TOK_LINENUMBERING_COUNT_IN_TEXT_BOXES:
+ case XML_ELEMENT(TEXT, XML_COUNT_IN_TEXT_BOXES):
if (::sax::Converter::convertBool(bTmp, rValue))
{
bCountInFloatingFrames = bTmp;
}
break;
- case XML_TOK_LINENUMBERING_RESTART_NUMBERING:
+ case XML_ELEMENT(TEXT, XML_RESTART_ON_PAGE):
if (::sax::Converter::convertBool(bTmp, rValue))
{
bRestartNumbering = bTmp;
}
break;
- case XML_TOK_LINENUMBERING_OFFSET:
+ case XML_ELEMENT(TEXT, XML_OFFSET):
if (GetImport().GetMM100UnitConverter().
convertMeasureToCore(nTmp, rValue))
{
@@ -156,15 +124,15 @@ void XMLLineNumberingImportContext::SetAttribute( sal_uInt16 nPrefixKey,
}
break;
- case XML_TOK_LINENUMBERING_NUM_FORMAT:
+ case XML_ELEMENT(STYLE, XML_NUM_FORMAT):
sNumFormat = rValue;
break;
- case XML_TOK_LINENUMBERING_NUM_LETTER_SYNC:
+ case XML_ELEMENT(STYLE, XML_NUM_LETTER_SYNC):
sNumLetterSync = rValue;
break;
- case XML_TOK_LINENUMBERING_NUMBER_POSITION:
+ case XML_ELEMENT(TEXT, XML_NUMBER_POSITION):
{
static const SvXMLEnumMapEntry<sal_Int16> aLineNumberPositionMap[] =
{
@@ -180,7 +148,7 @@ void XMLLineNumberingImportContext::SetAttribute( sal_uInt16 nPrefixKey,
break;
}
- case XML_TOK_LINENUMBERING_INCREMENT:
+ case XML_ELEMENT(TEXT, XML_INCREMENT):
if (::sax::Converter::convertNumber(nTmp, rValue, 0))
{
nIncrement = static_cast<sal_Int16>(nTmp);
diff --git a/xmloff/source/text/XMLTextShapeStyleContext.cxx b/xmloff/source/text/XMLTextShapeStyleContext.cxx
index 27accc1ed1c2..70736d80d6c9 100644
--- a/xmloff/source/text/XMLTextShapeStyleContext.cxx
+++ b/xmloff/source/text/XMLTextShapeStyleContext.cxx
@@ -117,19 +117,17 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTextShapePropertySe
nElement, xAttrList, rProperties, rProp );
}
-void XMLTextShapeStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+void XMLTextShapeStyleContext::SetAttribute( sal_Int32 nElement,
const OUString& rValue )
{
- if( XML_NAMESPACE_STYLE == nPrefixKey &&
- IsXMLToken( rLocalName, XML_AUTO_UPDATE ) )
+ if( nElement == XML_ELEMENT(STYLE, XML_AUTO_UPDATE) )
{
if( IsXMLToken( rValue, XML_TRUE ) )
bAutoUpdate = true;
}
else
{
- XMLShapeStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ XMLShapeStyleContext::SetAttribute( nElement, rValue );
}
}
diff --git a/xmloff/source/text/txtstyli.cxx b/xmloff/source/text/txtstyli.cxx
index 350c0e584830..e765f53417f2 100644
--- a/xmloff/source/text/txtstyli.cxx
+++ b/xmloff/source/text/txtstyli.cxx
@@ -74,38 +74,37 @@ const SvXMLEnumMapEntry<sal_uInt16> aCategoryMap[] =
{ XML_TOKEN_INVALID, 0 }
};
-void XMLTextStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
- const OUString& rLocalName,
+void XMLTextStyleContext::SetAttribute( sal_Int32 nElement,
const OUString& rValue )
{
- if( XML_NAMESPACE_STYLE == nPrefixKey )
+ switch (nElement)
{
- // TODO: use a map here
- if( IsXMLToken( rLocalName, XML_AUTO_UPDATE ) )
+ case XML_ELEMENT(STYLE, XML_AUTO_UPDATE):
{
if( IsXMLToken( rValue, XML_TRUE ) )
m_isAutoUpdate = true;
+ break;
}
- else if( IsXMLToken( rLocalName, XML_LIST_STYLE_NAME ) )
+ case XML_ELEMENT(STYLE, XML_LIST_STYLE_NAME):
{
m_sListStyleName = rValue;
// Inherited paragraph style lost information about unset numbering (#i69523#)
m_bListStyleSet = true;
+ break;
}
- else if( IsXMLToken( rLocalName, XML_MASTER_PAGE_NAME ) )
+ case XML_ELEMENT(STYLE, XML_MASTER_PAGE_NAME):
{
m_sMasterPageName = rValue;
m_bHasMasterPageName = true;
+ break;
}
- else if( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) )
- {
+ case XML_ELEMENT(STYLE, XML_DATA_STYLE_NAME):
m_sDataStyleName = rValue;
- }
- else if( IsXMLToken( rLocalName, XML_CLASS ) )
- {
+ break;
+ case XML_ELEMENT(STYLE, XML_CLASS):
m_sCategoryVal = rValue;
- }
- else if( IsXMLToken( rLocalName, XML_DEFAULT_OUTLINE_LEVEL ) )
+ break;
+ case XML_ELEMENT(STYLE, XML_DEFAULT_OUTLINE_LEVEL):
{
sal_Int32 nTmp;
if (::sax::Converter::convertNumber( nTmp, rValue ) &&
@@ -113,15 +112,10 @@ void XMLTextStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
{
m_nOutlineLevel = static_cast<sal_Int8>(nTmp);
}
+ break;
}
- else
- {
- XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
- }
- }
- else
- {
- XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ default:
+ XMLPropStyleContext::SetAttribute( nElement, rValue );
}
}