summaryrefslogtreecommitdiff
path: root/xmloff/source/text
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/source/text
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/source/text')
-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
5 files changed, 67 insertions, 128 deletions
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 );
}
}