summaryrefslogtreecommitdiff
path: root/xmloff/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-02-28 13:50:45 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-03-01 07:34:35 +0100
commitc1dae35c1eaa58159a8a76efdeecf70c1d01e550 (patch)
tree563278171f843331b6dd842c4f87d55b2e6ce931 /xmloff/source
parenta2019689d7dab465a8384631dc38a1a4f45537a9 (diff)
use the SetAttribute override in SvXMLStyleContext subclasses consistently
Change-Id: Ibdbf73c5e54fbbb051e4898fd8b3a7a155647b15 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89702 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff/source')
-rw-r--r--xmloff/source/table/XMLTableImport.cxx25
-rw-r--r--xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx96
-rw-r--r--xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx19
-rw-r--r--xmloff/source/text/XMLLineNumberingImportContext.cxx43
4 files changed, 70 insertions, 113 deletions
diff --git a/xmloff/source/table/XMLTableImport.cxx b/xmloff/source/table/XMLTableImport.cxx
index 513e3e595774..e02170676935 100644
--- a/xmloff/source/table/XMLTableImport.cxx
+++ b/xmloff/source/table/XMLTableImport.cxx
@@ -158,11 +158,13 @@ public:
virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList ) override;
- virtual void StartElement( const Reference< XAttributeList >& xAttrList ) override;
-
virtual void EndElement() override;
virtual void CreateAndInsert( bool bOverwrite ) override;
+protected:
+ virtual void SetAttribute( sal_uInt16 nPrefixKey,
+ const OUString& rLocalName,
+ const OUString& rValue ) override;
private:
XMLTableTemplate maTableTemplate;
OUString msTemplateStyleName;
@@ -743,20 +745,15 @@ XMLTableTemplateContext::XMLTableTemplateContext( SvXMLImport& rImport, sal_uInt
{
}
-void XMLTableTemplateContext::StartElement( const Reference< XAttributeList >& xAttrList )
+void XMLTableTemplateContext::SetAttribute( sal_uInt16 nPrefixKey,
+ const OUString& rLocalName,
+ const OUString& rValue )
{
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for(sal_Int16 i=0; i < nAttrCount; i++)
+ if( (nPrefixKey == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, 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 )))
{
- OUString sAttrName;
- sal_uInt16 nAttrPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( i ), &sAttrName );
- if( (nAttrPrefix == XML_NAMESPACE_TEXT && IsXMLToken( sAttrName, XML_STYLE_NAME ))
- // Writer specific: according to oasis odf 1.2 prefix should be "table" and element name should be "name"
- || (nAttrPrefix == XML_NAMESPACE_TABLE && IsXMLToken( sAttrName, XML_NAME )))
- {
- msTemplateStyleName = xAttrList->getValueByIndex( i );
- break;
- }
+ msTemplateStyleName = rValue;
}
}
diff --git a/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx b/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx
index 3a0ce16d1fe6..3346fafb70d6 100644
--- a/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx
+++ b/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx
@@ -220,64 +220,56 @@ static SvXMLEnumMapEntry<sal_Int16> const aFootnoteNumberingMap[] =
{ XML_TOKEN_INVALID, 0 },
};
-void XMLFootnoteConfigurationImportContext::StartElement(
- const Reference<XAttributeList> & xAttrList )
+void XMLFootnoteConfigurationImportContext::SetAttribute( sal_uInt16 nPrefixKey,
+ const OUString& rLocalName,
+ const OUString& rValue )
{
- sal_Int16 nLength = xAttrList->getLength();
- for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
+ switch (GetFtnConfigAttrTokenMap().Get(nPrefixKey, rLocalName))
{
- OUString sLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
- GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
- &sLocalName );
- OUString sValue = xAttrList->getValueByIndex(nAttr);
- switch (GetFtnConfigAttrTokenMap().Get(nPrefix, sLocalName))
+ case XML_TOK_FTNCONFIG_CITATION_STYLENAME:
+ sCitationStyle = rValue;
+ break;
+ case XML_TOK_FTNCONFIG_ANCHOR_STYLENAME:
+ sAnchorStyle = rValue;
+ break;
+ case XML_TOK_FTNCONFIG_DEFAULT_STYLENAME:
+ sDefaultStyle = rValue;
+ break;
+ case XML_TOK_FTNCONFIG_PAGE_STYLENAME:
+ sPageStyle = rValue;
+ break;
+ case XML_TOK_FTNCONFIG_OFFSET:
{
- case XML_TOK_FTNCONFIG_CITATION_STYLENAME:
- sCitationStyle = sValue;
- break;
- case XML_TOK_FTNCONFIG_ANCHOR_STYLENAME:
- sAnchorStyle = sValue;
- break;
- case XML_TOK_FTNCONFIG_DEFAULT_STYLENAME:
- sDefaultStyle = sValue;
- break;
- case XML_TOK_FTNCONFIG_PAGE_STYLENAME:
- sPageStyle = sValue;
- break;
- case XML_TOK_FTNCONFIG_OFFSET:
+ sal_Int32 nTmp;
+ if (::sax::Converter::convertNumber(nTmp, rValue))
{
- sal_Int32 nTmp;
- if (::sax::Converter::convertNumber(nTmp, sValue))
- {
- nOffset = static_cast<sal_uInt16>(nTmp);
- }
- break;
+ nOffset = static_cast<sal_uInt16>(nTmp);
}
- case XML_TOK_FTNCONFIG_NUM_PREFIX:
- sPrefix = sValue;
- break;
- case XML_TOK_FTNCONFIG_NUM_SUFFIX:
- sSuffix = sValue;
- break;
- case XML_TOK_FTNCONFIG_NUM_FORMAT:
- sNumFormat = sValue;
- break;
- case XML_TOK_FTNCONFIG_NUM_SYNC:
- sNumSync = sValue;
- break;
- case XML_TOK_FTNCONFIG_START_AT:
- {
- (void)SvXMLUnitConverter::convertEnum(nNumbering, sValue,
- aFootnoteNumberingMap);
- break;
- }
- case XML_TOK_FTNCONFIG_POSITION:
- bPosition = IsXMLToken( sValue, XML_DOCUMENT );
- break;
- default:
- ; // ignore
+ break;
}
+ case XML_TOK_FTNCONFIG_NUM_PREFIX:
+ sPrefix = rValue;
+ break;
+ case XML_TOK_FTNCONFIG_NUM_SUFFIX:
+ sSuffix = rValue;
+ break;
+ case XML_TOK_FTNCONFIG_NUM_FORMAT:
+ sNumFormat = rValue;
+ break;
+ case XML_TOK_FTNCONFIG_NUM_SYNC:
+ sNumSync = rValue;
+ break;
+ case XML_TOK_FTNCONFIG_START_AT:
+ {
+ (void)SvXMLUnitConverter::convertEnum(nNumbering, rValue,
+ aFootnoteNumberingMap);
+ break;
+ }
+ case XML_TOK_FTNCONFIG_POSITION:
+ bPosition = IsXMLToken( rValue, XML_DOCUMENT );
+ break;
+ default:
+ ; // ignore
}
}
diff --git a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
index 35fd6e61fd92..96c844af32f5 100644
--- a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
+++ b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
@@ -72,24 +72,7 @@ XMLIndexBibliographyConfigurationContext::~XMLIndexBibliographyConfigurationCont
{
}
-void XMLIndexBibliographyConfigurationContext::StartElement(
- const Reference<XAttributeList> & xAttrList)
-{
- sal_Int16 nLength = xAttrList->getLength();
- for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
- {
- OUString sLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
- GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
- &sLocalName );
-
- ProcessAttribute(nPrefix, sLocalName,
- xAttrList->getValueByIndex(nAttr));
- // else: ignore
- }
-}
-
-void XMLIndexBibliographyConfigurationContext::ProcessAttribute(
+void XMLIndexBibliographyConfigurationContext::SetAttribute(
sal_uInt16 nPrefix,
const OUString& sLocalName,
const OUString& sValue)
diff --git a/xmloff/source/text/XMLLineNumberingImportContext.cxx b/xmloff/source/text/XMLLineNumberingImportContext.cxx
index bfc192b3f907..6cd7f48575b9 100644
--- a/xmloff/source/text/XMLLineNumberingImportContext.cxx
+++ b/xmloff/source/text/XMLLineNumberingImportContext.cxx
@@ -77,8 +77,9 @@ XMLLineNumberingImportContext::~XMLLineNumberingImportContext()
{
}
-void XMLLineNumberingImportContext::StartElement(
- const Reference<XAttributeList> & xAttrList)
+void XMLLineNumberingImportContext::SetAttribute( sal_uInt16 nPrefixKey,
+ const OUString& rLocalName,
+ const OUString& rValue )
{
static const SvXMLTokenMapEntry aLineNumberingTokenMap[] =
{
@@ -109,56 +110,40 @@ void XMLLineNumberingImportContext::StartElement(
static const SvXMLTokenMap aTokenMap(aLineNumberingTokenMap);
- // process attributes
- sal_Int16 nLength = xAttrList->getLength();
- for(sal_Int16 i=0; i<nLength; i++)
- {
- OUString sLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
- GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
-
- ProcessAttribute(
- static_cast<enum LineNumberingToken>(aTokenMap.Get(nPrefix, sLocalName)),
- xAttrList->getValueByIndex(i));
- }
-}
+ enum LineNumberingToken eToken = static_cast<enum LineNumberingToken>(aTokenMap.Get(nPrefixKey, rLocalName));
-void XMLLineNumberingImportContext::ProcessAttribute(
- enum LineNumberingToken eToken,
- const OUString& sValue)
-{
bool bTmp(false);
sal_Int32 nTmp;
switch (eToken)
{
case XML_TOK_LINENUMBERING_STYLE_NAME:
- sStyleName = sValue;
+ sStyleName = rValue;
break;
case XML_TOK_LINENUMBERING_NUMBER_LINES:
- if (::sax::Converter::convertBool(bTmp, sValue))
+ if (::sax::Converter::convertBool(bTmp, rValue))
{
bNumberLines = bTmp;
}
break;
case XML_TOK_LINENUMBERING_COUNT_EMPTY_LINES:
- if (::sax::Converter::convertBool(bTmp, sValue))
+ if (::sax::Converter::convertBool(bTmp, rValue))
{
bCountEmptyLines = bTmp;
}
break;
case XML_TOK_LINENUMBERING_COUNT_IN_TEXT_BOXES:
- if (::sax::Converter::convertBool(bTmp, sValue))
+ if (::sax::Converter::convertBool(bTmp, rValue))
{
bCountInFloatingFrames = bTmp;
}
break;
case XML_TOK_LINENUMBERING_RESTART_NUMBERING:
- if (::sax::Converter::convertBool(bTmp, sValue))
+ if (::sax::Converter::convertBool(bTmp, rValue))
{
bRestartNumbering = bTmp;
}
@@ -166,18 +151,18 @@ void XMLLineNumberingImportContext::ProcessAttribute(
case XML_TOK_LINENUMBERING_OFFSET:
if (GetImport().GetMM100UnitConverter().
- convertMeasureToCore(nTmp, sValue))
+ convertMeasureToCore(nTmp, rValue))
{
nOffset = nTmp;
}
break;
case XML_TOK_LINENUMBERING_NUM_FORMAT:
- sNumFormat = sValue;
+ sNumFormat = rValue;
break;
case XML_TOK_LINENUMBERING_NUM_LETTER_SYNC:
- sNumLetterSync = sValue;
+ sNumLetterSync = rValue;
break;
case XML_TOK_LINENUMBERING_NUMBER_POSITION:
@@ -191,13 +176,13 @@ void XMLLineNumberingImportContext::ProcessAttribute(
{ XML_TOKEN_INVALID, 0 }
};
- (void)SvXMLUnitConverter::convertEnum(nNumberPosition, sValue,
+ (void)SvXMLUnitConverter::convertEnum(nNumberPosition, rValue,
aLineNumberPositionMap);
break;
}
case XML_TOK_LINENUMBERING_INCREMENT:
- if (::sax::Converter::convertNumber(nTmp, sValue, 0))
+ if (::sax::Converter::convertNumber(nTmp, rValue, 0))
{
nIncrement = static_cast<sal_Int16>(nTmp);
}