summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-01-21 15:05:09 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-01-21 17:56:38 +0100
commit63b7e282a598ff5dc9d665127f567b20adc56f24 (patch)
tree17140bf1e636b8ced18c15bc85c9ee75e6be3f65
parent3b9797671ce49f53b2c583c9201c348b55b10c96 (diff)
use more FastParser in ScXMLChangeInfoContext
had to hack the token constant generating process a little because we have two tokens that only differ in "-" vs "_" Change-Id: I0744d697918d28cca0c92b83ecfd37c1ae9d2bae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87138 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--include/xmloff/xmltoken.hxx1
-rw-r--r--sc/source/filter/xml/XMLTrackedChangesContext.cxx173
-rw-r--r--sc/source/filter/xml/xmlconti.cxx35
-rw-r--r--sc/source/filter/xml/xmlconti.hxx7
-rw-r--r--solenv/bin/generate-tokens.pl4
-rw-r--r--xmloff/source/core/xmltoken.cxx1
-rw-r--r--xmloff/source/token/tokens.txt1
7 files changed, 106 insertions, 116 deletions
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index f6695d54de3e..d0896bd8507c 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -541,6 +541,7 @@ namespace xmloff { namespace token {
XML_CUSTOM_LABEL_FIELD,
XML_CUT,
XML_CUT_OFFS,
+ XML_CUT_OFFS2,
XML_CX,
XML_CY,
XML_CYLINDER,
diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.cxx b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
index d5cd5601f374..c7537ac9f4a3 100644
--- a/sc/source/filter/xml/XMLTrackedChangesContext.cxx
+++ b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
@@ -55,9 +55,8 @@ public:
const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
- 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 endFastElement( sal_Int32 nElement ) override;
};
@@ -193,6 +192,9 @@ public:
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
+ { return nullptr; }
void CreateTextPContext(bool bIsNewParagraph);
bool IsEditCell() const { return mpEditTextObj.is(); }
@@ -262,21 +264,17 @@ public:
class ScXMLInsertionCutOffContext : public ScXMLImportContext
{
public:
- ScXMLInsertionCutOffContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList,
+ ScXMLInsertionCutOffContext( ScXMLImport& rImport,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList,
ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
-
- virtual void EndElement() override;
};
class ScXMLMovementCutOffContext : public ScXMLImportContext
{
public:
- ScXMLMovementCutOffContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList,
+ ScXMLMovementCutOffContext( ScXMLImport& rImport,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList,
ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
-
- virtual void EndElement() override;
};
class ScXMLCutOffsContext : public ScXMLImportContext
@@ -284,13 +282,11 @@ class ScXMLCutOffsContext : public ScXMLImportContext
ScXMLChangeTrackingImportHelper* const pChangeTrackingImportHelper;
public:
- ScXMLCutOffsContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
- ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
+ ScXMLCutOffsContext( ScXMLImport& rImport,
+ ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
- virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
- virtual void EndElement() 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;
};
class ScXMLDeletionContext : public ScXMLImportContext
@@ -302,10 +298,6 @@ public:
const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
- 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;
@@ -424,27 +416,21 @@ ScXMLChangeInfoContext::ScXMLChangeInfoContext( ScXMLImport& rImport,
}
}
-SvXMLImportContextRef ScXMLChangeInfoContext::CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttrList*/ )
+css::uno::Reference< css::xml::sax::XFastContextHandler > ScXMLChangeInfoContext::createFastChildContext(
+ sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ )
{
SvXMLImportContext *pContext(nullptr);
- if( XML_NAMESPACE_DC == nPrefix )
- {
- if( IsXMLToken( rLocalName, XML_CREATOR ) )
- pContext = new ScXMLContentContext(GetScImport(), nPrefix,
- rLocalName, sAuthorBuffer);
- else if( IsXMLToken( rLocalName, XML_DATE ) )
- pContext = new ScXMLContentContext(GetScImport(), nPrefix,
- rLocalName, sDateTimeBuffer);
- }
- else if ((nPrefix == XML_NAMESPACE_TEXT) && (IsXMLToken(rLocalName, XML_P)) )
+ if( nElement == XML_ELEMENT(DC, XML_CREATOR ) )
+ pContext = new ScXMLContentContext(GetScImport(), sAuthorBuffer);
+ else if( nElement == XML_ELEMENT(DC, XML_DATE ) )
+ pContext = new ScXMLContentContext(GetScImport(), sDateTimeBuffer);
+ else if (nElement == XML_ELEMENT(TEXT, XML_P))
{
if(nParagraphCount)
sCommentBuffer.append('\n');
++nParagraphCount;
- pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLocalName, sCommentBuffer);
+ pContext = new ScXMLContentContext( GetScImport(), sCommentBuffer);
}
return pContext;
@@ -1115,82 +1101,63 @@ void SAL_CALL ScXMLInsertionContext::endFastElement( sal_Int32 /*nElement*/ )
}
ScXMLInsertionCutOffContext::ScXMLInsertionCutOffContext( ScXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList,
+ const uno::Reference<xml::sax::XFastAttributeList>& xAttrList,
ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper ) :
- ScXMLImportContext( rImport, nPrfx, rLName )
+ ScXMLImportContext( rImport )
{
sal_uInt32 nID(0);
sal_Int32 nPosition(0);
- sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
- for( sal_Int16 i=0; i < nAttrCount; ++i )
+ sax_fastparser::FastAttributeList *pAttribList =
+ sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
+ for (auto &aIter : *pAttribList)
{
- 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();
- if (nPrefix == XML_NAMESPACE_TABLE)
+ switch (aIter.getToken())
{
- if (IsXMLToken(aLocalName, XML_ID))
- {
+ case XML_ELEMENT(TABLE, XML_ID):
nID = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue);
- }
- else if (IsXMLToken(aLocalName, XML_POSITION))
- {
+ break;
+ case XML_ELEMENT(TABLE, XML_POSITION):
::sax::Converter::convertNumber(nPosition, sValue);
- }
+ break;
}
}
pChangeTrackingImportHelper->SetInsertionCutOff(nID, nPosition);
}
-void ScXMLInsertionCutOffContext::EndElement()
-{
-}
ScXMLMovementCutOffContext::ScXMLMovementCutOffContext( ScXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList,
+ const uno::Reference<xml::sax::XFastAttributeList>& xAttrList,
ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper ) :
- ScXMLImportContext( rImport, nPrfx, rLName )
+ ScXMLImportContext( rImport )
{
sal_uInt32 nID(0);
sal_Int32 nPosition(0);
sal_Int32 nStartPosition(0);
sal_Int32 nEndPosition(0);
bool bPosition(false);
- sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
- for( sal_Int16 i=0; i < nAttrCount; ++i )
+ sax_fastparser::FastAttributeList *pAttribList =
+ sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
+ for (auto &aIter : *pAttribList)
{
- 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();
- if (nPrefix == XML_NAMESPACE_TABLE)
+ switch (aIter.getToken())
{
- if (IsXMLToken(aLocalName, XML_ID))
- {
+ case XML_ELEMENT(TABLE, XML_ID):
nID = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue);
- }
- else if (IsXMLToken(aLocalName, XML_POSITION))
- {
+ break;
+ case XML_ELEMENT(TABLE, XML_POSITION):
bPosition = true;
::sax::Converter::convertNumber(nPosition, sValue);
- }
- else if (IsXMLToken(aLocalName, XML_START_POSITION))
- {
+ break;
+ case XML_ELEMENT(TABLE, XML_START_POSITION):
::sax::Converter::convertNumber(nStartPosition, sValue);
- }
- else if (IsXMLToken(aLocalName, XML_END_POSITION))
- {
+ break;
+ case XML_ELEMENT(TABLE, XML_END_POSITION):
::sax::Converter::convertNumber(nEndPosition, sValue);
- }
+ break;
}
}
if (bPosition)
@@ -1198,41 +1165,27 @@ ScXMLMovementCutOffContext::ScXMLMovementCutOffContext( ScXMLImport& rImport,
pChangeTrackingImportHelper->AddMoveCutOff(nID, nStartPosition, nEndPosition);
}
-void ScXMLMovementCutOffContext::EndElement()
-{
-}
-
ScXMLCutOffsContext::ScXMLCutOffsContext( ScXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLName,
ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
- ScXMLImportContext( rImport, nPrfx, rLName ),
+ ScXMLImportContext( rImport ),
pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
{
// here are no attributes
}
-SvXMLImportContextRef ScXMLCutOffsContext::CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList )
+css::uno::Reference< css::xml::sax::XFastContextHandler > ScXMLCutOffsContext::createFastChildContext(
+ sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
{
SvXMLImportContext *pContext(nullptr);
- if (nPrefix == XML_NAMESPACE_TABLE)
- {
- if (IsXMLToken(rLocalName, XML_INSERTION_CUT_OFF))
- pContext = new ScXMLInsertionCutOffContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
- else if (IsXMLToken(rLocalName, XML_MOVEMENT_CUT_OFF))
- pContext = new ScXMLMovementCutOffContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
- }
+ if (nElement == XML_ELEMENT(TABLE, XML_INSERTION_CUT_OFF))
+ pContext = new ScXMLInsertionCutOffContext(GetScImport(), xAttrList, pChangeTrackingImportHelper);
+ else if (nElement == XML_ELEMENT(TABLE, XML_MOVEMENT_CUT_OFF))
+ pContext = new ScXMLMovementCutOffContext(GetScImport(), xAttrList, pChangeTrackingImportHelper);
return pContext;
}
-void ScXMLCutOffsContext::EndElement()
-{
-}
-
ScXMLDeletionContext::ScXMLDeletionContext( ScXMLImport& rImport,
const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
@@ -1293,21 +1246,6 @@ ScXMLDeletionContext::ScXMLDeletionContext( ScXMLImport& rImport,
pChangeTrackingImportHelper->SetMultiSpanned(static_cast<sal_Int16>(nMultiSpanned));
}
-SvXMLImportContextRef ScXMLDeletionContext::CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttrList*/ )
-{
- SvXMLImportContext *pContext(nullptr);
-
- if (nPrefix == XML_NAMESPACE_TABLE)
- {
- if (IsXMLToken(rLocalName, XML_CUT_OFFS) || rLocalName == "cut_offs")
- pContext = new ScXMLCutOffsContext(GetScImport(), nPrefix, rLocalName, pChangeTrackingImportHelper);
- }
-
- return pContext;
-}
-
uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLDeletionContext::createFastChildContext(
sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
{
@@ -1326,6 +1264,9 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLDeletionContext::c
case XML_ELEMENT( TABLE, XML_DELETIONS ):
pContext = new ScXMLDeletionsContext(GetScImport(), pChangeTrackingImportHelper);
break;
+ case XML_ELEMENT( TABLE, XML_CUT_OFFS ):
+ case XML_ELEMENT( TABLE, XML_CUT_OFFS2 ): // cut_offs
+ pContext = new ScXMLCutOffsContext(GetScImport(), pChangeTrackingImportHelper);
}
return pContext;
diff --git a/sc/source/filter/xml/xmlconti.cxx b/sc/source/filter/xml/xmlconti.cxx
index cbb451ecf599..41507f589f3e 100644
--- a/sc/source/filter/xml/xmlconti.cxx
+++ b/sc/source/filter/xml/xmlconti.cxx
@@ -35,6 +35,13 @@ ScXMLContentContext::ScXMLContentContext( ScXMLImport& rImport,
{
}
+ScXMLContentContext::ScXMLContentContext( ScXMLImport& rImport,
+ OUStringBuffer& sTempValue) :
+ ScXMLImportContext( rImport ),
+ sValue(sTempValue)
+{
+}
+
ScXMLContentContext::~ScXMLContentContext()
{
}
@@ -67,9 +74,37 @@ SvXMLImportContextRef ScXMLContentContext::CreateChildContext( sal_uInt16 nPrefi
return new SvXMLImportContext( GetImport(), nPrefix, rLName );
}
+css::uno::Reference< css::xml::sax::XFastContextHandler > ScXMLContentContext::createFastChildContext(
+ sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
+{
+ if (nElement == XML_ELEMENT(TEXT, XML_S))
+ {
+ sal_Int32 nRepeat(0);
+ sax_fastparser::FastAttributeList *pAttribList =
+ sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
+ for (auto &aIter : *pAttribList)
+ {
+ if (aIter.getToken() == XML_ELEMENT(TEXT, XML_C))
+ nRepeat = aIter.toInt32();
+ }
+ if (nRepeat)
+ for (sal_Int32 j = 0; j < nRepeat; ++j)
+ sValue.append(' ');
+ else
+ sValue.append(' ');
+ }
+
+ return new SvXMLImportContext( GetImport() );
+}
+
void ScXMLContentContext::Characters( const OUString& rChars )
{
sValue.append(rChars);
}
+void ScXMLContentContext::characters( const OUString& rChars )
+{
+ sValue.append(rChars);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/xmlconti.hxx b/sc/source/filter/xml/xmlconti.hxx
index ee862c173ead..1aabd9f49b5c 100644
--- a/sc/source/filter/xml/xmlconti.hxx
+++ b/sc/source/filter/xml/xmlconti.hxx
@@ -31,6 +31,8 @@ public:
ScXMLContentContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
const OUString& rLName,
OUStringBuffer& sValue);
+ ScXMLContentContext( ScXMLImport& rImport,
+ OUStringBuffer& sValue);
virtual ~ScXMLContentContext() override;
@@ -39,6 +41,11 @@ public:
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
virtual void Characters( const OUString& rChars ) 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 characters( const OUString& rChars ) override;
};
#endif
diff --git a/solenv/bin/generate-tokens.pl b/solenv/bin/generate-tokens.pl
index b6391a760358..d5f8f9fa7d1f 100644
--- a/solenv/bin/generate-tokens.pl
+++ b/solenv/bin/generate-tokens.pl
@@ -48,6 +48,10 @@ while ( <INFILE> )
# check for valid characters
$_ =~ /^[a-zA-Z0-9-_]+$/ or die "Error: invalid character in token '$_'";
$id = "XML_$_";
+ # we have two ids with similar names("cut-offs" and "cut_offs")
+ if ($id eq "XML_cut_offs") {
+ $id = "cut_offs2";
+ }
$id =~ s/-/_/g;
$tokens{$_} = $id;
print( IDFILE "const sal_Int32 $id = $i;\n" );
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index dddb49ed2980..bbd9aa3fcf7c 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -542,6 +542,7 @@ namespace xmloff { namespace token {
TOKEN( "custom-label-field", XML_CUSTOM_LABEL_FIELD ),
TOKEN( "cut", XML_CUT ),
TOKEN( "cut-offs", XML_CUT_OFFS ),
+ TOKEN( "cut_offs", XML_CUT_OFFS2 ),
TOKEN( "cx", XML_CX ),
TOKEN( "cy", XML_CY ),
TOKEN( "cylinder", XML_CYLINDER ),
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index cc25b084ce33..abd7dadcd260 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -465,6 +465,7 @@ custom-iconset-name
custom-label-field
cut
cut-offs
+cut_offs
cx
cy
cylinder