summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/xmloff/xmlnumi.hxx6
-rw-r--r--include/xmloff/xmlstyle.hxx6
-rw-r--r--sw/source/uibase/config/StoredChapterNumbering.cxx88
-rw-r--r--xmloff/source/style/xmlnumi.cxx10
-rw-r--r--xmloff/source/style/xmlstyle.cxx14
5 files changed, 71 insertions, 53 deletions
diff --git a/include/xmloff/xmlnumi.hxx b/include/xmloff/xmlnumi.hxx
index 8a3d08681096..654583a37563 100644
--- a/include/xmloff/xmlnumi.hxx
+++ b/include/xmloff/xmlnumi.hxx
@@ -57,6 +57,12 @@ public:
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList,
bool bOutl = false );
+ SvxXMLListStyleContext(
+ SvXMLImport& rImport,
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
+ bool bOutl = false );
+
~SvxXMLListStyleContext() override;
virtual SvXMLImportContextRef CreateChildContext(
diff --git a/include/xmloff/xmlstyle.hxx b/include/xmloff/xmlstyle.hxx
index 0d7b5cfe1590..bf0e77098ced 100644
--- a/include/xmloff/xmlstyle.hxx
+++ b/include/xmloff/xmlstyle.hxx
@@ -91,6 +91,12 @@ public:
sal_uInt16 nFamily=0,
bool bDefaultStyle = false );
+ SvXMLStyleContext( SvXMLImport& rImport,
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
+ sal_uInt16 nFamily=0,
+ bool bDefaultStyle = false );
+
virtual ~SvXMLStyleContext() override;
virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
diff --git a/sw/source/uibase/config/StoredChapterNumbering.cxx b/sw/source/uibase/config/StoredChapterNumbering.cxx
index 2416195fb899..1a1e2cf8553c 100644
--- a/sw/source/uibase/config/StoredChapterNumbering.cxx
+++ b/sw/source/uibase/config/StoredChapterNumbering.cxx
@@ -16,7 +16,7 @@
#include <com/sun/star/io/XActiveDataSource.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <com/sun/star/util/MeasureUnit.hpp>
-#include <com/sun/star/xml/sax/Parser.hpp>
+#include <com/sun/star/xml/sax/FastParser.hpp>
#include <com/sun/star/xml/sax/Writer.hpp>
#include <comphelper/processfactory.hxx>
@@ -271,39 +271,27 @@ class StoredChapterNumberingDummyStyleContext
public:
StoredChapterNumberingDummyStyleContext(
SvXMLImport & rImport,
- sal_uInt16 const nPrefix, OUString const& rLocalName,
- uno::Reference<xml::sax::XAttributeList> const& xAttrList)
- : SvXMLImportContext(rImport, nPrefix, rLocalName)
+ uno::Reference<xml::sax::XFastAttributeList> const& xAttrList)
+ : SvXMLImportContext(rImport)
{
OUString name;
OUString displayName;
sal_uInt16 nFamily(0);
- for (sal_Int32 i = 0; i < xAttrList->getLength(); ++i)
- {
- OUString localName;
- sal_uInt16 const prefix(rImport.GetNamespaceMap().GetKeyByAttrName(
- xAttrList->getNameByIndex(i), &localName));
- OUString const& rValue = xAttrList->getValueByIndex(i);
- if (XML_NAMESPACE_STYLE == prefix)
+ sax_fastparser::FastAttributeList *pAttribList =
+ sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
+
+ for (auto &aIter : *pAttribList)
+ if (aIter.getToken() == (XML_NAMESPACE_STYLE | XML_FAMILY))
{
- if (IsXMLToken(localName, XML_FAMILY))
- {
- if (IsXMLToken(rValue, XML_TEXT))
- {
- nFamily = XML_STYLE_FAMILY_TEXT_TEXT;
- }
- }
- else if (IsXMLToken(localName, XML_NAME))
- {
- name = rValue;
- }
- else if (IsXMLToken(localName, XML_DISPLAY_NAME))
- {
- displayName = rValue;
- }
+ if (IsXMLToken(aIter.toString(), XML_TEXT))
+ nFamily = XML_STYLE_FAMILY_TEXT_TEXT;
+ else if (IsXMLToken(aIter.toString(), XML_NAME))
+ name = aIter.toString();
+ else if (IsXMLToken(aIter.toString(), XML_DISPLAY_NAME))
+ displayName = aIter.toString();
}
- }
+
if (nFamily && !name.isEmpty() && !displayName.isEmpty())
{
rImport.AddStyleDisplayName(nFamily, name, displayName);
@@ -323,15 +311,14 @@ private:
public:
StoredChapterNumberingRootContext(
- SwChapterNumRules & rNumRules, SvXMLImport & rImport,
- sal_uInt16 const nPrefix, OUString const& rLocalName)
- : SvXMLImportContext(rImport, nPrefix, rLocalName)
+ SwChapterNumRules & rNumRules, SvXMLImport & rImport)
+ : SvXMLImportContext(rImport)
, m_rNumRules(rNumRules)
, m_nCounter(0)
{
}
- virtual void EndElement() override
+ virtual void SAL_CALL endFastElement(sal_Int32 /*Element*/) override
{
assert(m_Contexts.size() < SwChapterNumRules::nMaxRules);
for (auto iter = m_Contexts.begin(); iter != m_Contexts.end(); ++iter)
@@ -346,30 +333,27 @@ public:
}
}
- virtual SvXMLImportContextRef CreateChildContext(
- sal_uInt16 const nPrefix, OUString const& rLocalName,
- uno::Reference<xml::sax::XAttributeList> const& xAttrList) override
+ virtual css::uno::Reference<XFastContextHandler> SAL_CALL createFastChildContext(
+ sal_Int32 Element,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override
{
- if (XML_NAMESPACE_TEXT == nPrefix && IsXMLToken(rLocalName, XML_OUTLINE_STYLE))
+ if (Element == XML_ELEMENT(TEXT, XML_OUTLINE_STYLE))
{
++m_nCounter;
if (m_nCounter <= SwChapterNumRules::nMaxRules)
{
SvxXMLListStyleContext *const pContext(
- new SvxXMLListStyleContext(GetImport(),
- nPrefix, rLocalName, xAttrList, true));
+ new SvxXMLListStyleContext(GetImport(), Element, xAttrList, true));
m_Contexts.emplace_back(pContext);
return pContext;
}
}
- else if (XML_NAMESPACE_STYLE == nPrefix && IsXMLToken(rLocalName, XML_STYLE))
+ else if (Element == XML_ELEMENT(STYLE, XML_STYLE))
{
- return new StoredChapterNumberingDummyStyleContext(
- GetImport(), nPrefix, rLocalName, xAttrList);
+ return new StoredChapterNumberingDummyStyleContext(GetImport(), xAttrList);
}
- return SvXMLImportContext::CreateChildContext(
- nPrefix, rLocalName, xAttrList);
+ return SvXMLImportContext::createFastChildContext(Element, xAttrList);
}
};
@@ -388,16 +372,14 @@ public:
{
}
- virtual SvXMLImportContext * CreateDocumentContext(
- sal_uInt16 const nPrefix, OUString const& rLocalName,
- uno::Reference<xml::sax::XAttributeList> const& xAttrList) override
+ virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override
{
- if (XML_NAMESPACE_OFFICE == nPrefix && IsXMLToken(rLocalName, XML_STYLES))
+ if (Element == XML_ELEMENT(OFFICE, XML_STYLES))
{
- return new StoredChapterNumberingRootContext(m_rNumRules,
- *this, nPrefix, rLocalName);
+ return new StoredChapterNumberingRootContext(m_rNumRules, *this);
}
- return SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList);
+ return SvXMLImport::CreateFastContext(Element, xAttrList);
}
};
@@ -458,13 +440,13 @@ void ImportStoredChapterNumberingRules(SwChapterNumRules & rRules,
uno::Reference<io::XInputStream> const xInStream(
new ::utl::OInputStreamWrapper(rStream));
- uno::Reference<xml::sax::XParser> const xParser(
- xml::sax::Parser::create(xContext));
+ uno::Reference<xml::sax::XFastParser> const xParser(
+ xml::sax::FastParser::create(xContext));
- uno::Reference<xml::sax::XDocumentHandler> const xHandler(
+ uno::Reference<xml::sax::XFastDocumentHandler> const xHandler(
new StoredChapterNumberingImport(xContext, rRules));
- xParser->setDocumentHandler(xHandler);
+ xParser->setFastDocumentHandler(xHandler);
xml::sax::InputSource const source(xInStream, "", "", rFileName);
diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx
index 0da58ed8ab11..710bb3ede574 100644
--- a/xmloff/source/style/xmlnumi.cxx
+++ b/xmloff/source/style/xmlnumi.cxx
@@ -1022,6 +1022,16 @@ SvxXMLListStyleContext::SvxXMLListStyleContext( SvXMLImport& rImport,
{
}
+SvxXMLListStyleContext::SvxXMLListStyleContext( SvXMLImport& rImport,
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
+ bool bOutl )
+: SvXMLStyleContext( rImport, nElement, xAttrList, bOutl ? XML_STYLE_FAMILY_TEXT_OUTLINE : XML_STYLE_FAMILY_TEXT_LIST )
+, bConsecutive( false )
+, bOutline( bOutl )
+{
+}
+
SvxXMLListStyleContext::~SvxXMLListStyleContext() {}
SvXMLImportContextRef SvxXMLListStyleContext::CreateChildContext(
diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx
index 4d3f2e21f816..5c4c12f667cf 100644
--- a/xmloff/source/style/xmlstyle.cxx
+++ b/xmloff/source/style/xmlstyle.cxx
@@ -140,6 +140,20 @@ SvXMLStyleContext::SvXMLStyleContext(
{
}
+SvXMLStyleContext::SvXMLStyleContext(
+ SvXMLImport& rImp,
+ sal_Int32 /*nElement*/,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > &,
+ sal_uInt16 nFam, bool bDefault ) :
+ SvXMLImportContext( rImp ),
+ mbHidden( false ),
+ mnFamily( nFam ),
+ mbValid( true ),
+ mbNew( true ),
+ mbDefaultStyle( bDefault )
+{
+}
+
SvXMLStyleContext::~SvXMLStyleContext()
{
}