diff options
author | Daniel Sikeler <d.sikeler94@gmail.com> | 2014-10-24 08:36:08 +0000 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-10-31 09:24:47 +0100 |
commit | 328f861dfbe7086c85dbd0d791c5f18b0714ca75 (patch) | |
tree | b40706d5b7ab10275f7a6776a2b60bae7513083a /editeng | |
parent | fdo#80403: Import baseclasses implement FastParser interfaces (diff) | |
download | core-328f861dfbe7086c85dbd0d791c5f18b0714ca75.tar.gz core-328f861dfbe7086c85dbd0d791c5f18b0714ca75.zip |
fdo#80403: AutoCorrect uses XFastParser
depends on c0a5d390e519603dbc19a38c610d0a114b80cfa1
ContextClasses implement fast methods.
ImportClasses implement fast methods.
New TokenHandler for AutoCorrectTokens.
Change-Id: I41ef7266da2068da3ab5f047280b13e57ee2e763
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/Library_editeng.mk | 1 | ||||
-rw-r--r-- | editeng/source/misc/SvXMLAutoCorrectImport.cxx | 161 | ||||
-rw-r--r-- | editeng/source/misc/SvXMLAutoCorrectImport.hxx | 69 | ||||
-rw-r--r-- | editeng/source/misc/SvXMLAutoCorrectTokenHandler.cxx | 44 | ||||
-rw-r--r-- | editeng/source/misc/SvXMLAutoCorrectTokenHandler.hxx | 49 | ||||
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 24 |
6 files changed, 188 insertions, 160 deletions
diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk index 9ffed0aebb52..c1cc0940920f 100644 --- a/editeng/Library_editeng.mk +++ b/editeng/Library_editeng.mk @@ -87,6 +87,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\ editeng/source/misc/hangulhanja \ editeng/source/misc/splwrap \ editeng/source/misc/svxacorr \ + editeng/source/misc/SvXMLAutoCorrectTokenHandler \ editeng/source/misc/SvXMLAutoCorrectExport \ editeng/source/misc/SvXMLAutoCorrectImport \ editeng/source/misc/swafopt \ diff --git a/editeng/source/misc/SvXMLAutoCorrectImport.cxx b/editeng/source/misc/SvXMLAutoCorrectImport.cxx index 2f2550f678ac..f2b3109e8d23 100644 --- a/editeng/source/misc/SvXMLAutoCorrectImport.cxx +++ b/editeng/source/misc/SvXMLAutoCorrectImport.cxx @@ -18,13 +18,10 @@ */ #include <SvXMLAutoCorrectImport.hxx> -#include <vcl/svapp.hxx> -#include <xmloff/xmltoken.hxx> +#include <SvXMLAutoCorrectTokenHandler.hxx> -using namespace ::com::sun::star; -using namespace ::xmloff::token; - -const char aBlockList[] = "_block-list"; +using namespace ::css; +using namespace ::css::xml::sax; SvXMLAutoCorrectImport::SvXMLAutoCorrectImport( const uno::Reference< uno::XComponentContext > xContext, @@ -36,92 +33,61 @@ SvXMLAutoCorrectImport::SvXMLAutoCorrectImport( rAutoCorrect ( rNewAutoCorrect ), xStorage ( rNewStorage ) { - GetNamespaceMap().Add( - OUString(aBlockList), - GetXMLToken ( XML_N_BLOCK_LIST), - XML_NAMESPACE_BLOCKLIST ); } SvXMLAutoCorrectImport::~SvXMLAutoCorrectImport ( void ) throw () { } -SvXMLImportContext *SvXMLAutoCorrectImport::CreateContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +SvXMLImportContext *SvXMLAutoCorrectImport::CreateFastContext( sal_Int32 Element, + const uno::Reference< xml::sax::XFastAttributeList > & xAttrList ) { - SvXMLImportContext *pContext = 0; - - if( XML_NAMESPACE_BLOCKLIST == nPrefix && - IsXMLToken ( rLocalName, XML_BLOCK_LIST ) ) - pContext = new SvXMLWordListContext( *this, nPrefix, rLocalName, xAttrList ); + if( Element == SvXMLAutoCorrectToken::BLOCKLIST ) + return new SvXMLWordListContext( *this, Element, xAttrList ); else - pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList ); - return pContext; + return SvXMLImport::CreateFastContext( Element, xAttrList ); } SvXMLWordListContext::SvXMLWordListContext( SvXMLAutoCorrectImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, + sal_Int32 /*Element*/, const com::sun::star::uno::Reference< - com::sun::star::xml::sax::XAttributeList > & /*xAttrList*/ ) : - SvXMLImportContext ( rImport, nPrefix, rLocalName ), + com::sun::star::xml::sax::XFastAttributeList > & /*xAttrList*/ ) : + SvXMLImportContext ( rImport ), rLocalRef(rImport) { } -SvXMLImportContext *SvXMLWordListContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +com::sun::star::uno::Reference<XFastContextHandler> SvXMLWordListContext::createFastChildContext( + sal_Int32 Element, const uno::Reference< xml::sax::XFastAttributeList > & xAttrList ) +throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) { - SvXMLImportContext *pContext = 0; - - if (nPrefix == XML_NAMESPACE_BLOCKLIST && - IsXMLToken ( rLocalName, XML_BLOCK ) ) - pContext = new SvXMLWordContext (rLocalRef, nPrefix, rLocalName, xAttrList); + if ( Element == SvXMLAutoCorrectToken::BLOCK ) + return new SvXMLWordContext (rLocalRef, Element, xAttrList); else - pContext = new SvXMLImportContext( rLocalRef, nPrefix, rLocalName); - return pContext; + return new SvXMLImportContext( rLocalRef ); } + SvXMLWordListContext::~SvXMLWordListContext ( void ) { } SvXMLWordContext::SvXMLWordContext( SvXMLAutoCorrectImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, + sal_Int32 /*Element*/, const com::sun::star::uno::Reference< - com::sun::star::xml::sax::XAttributeList > & xAttrList ) : - SvXMLImportContext ( rImport, nPrefix, rLocalName ), + com::sun::star::xml::sax::XFastAttributeList > & xAttrList ) : + SvXMLImportContext ( rImport ), rLocalRef(rImport) { - OUString sRight; - OUString sWrong; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + OUString sWrong, sRight; + if ( xAttrList.is() && xAttrList->hasAttribute( SvXMLAutoCorrectToken::ABBREVIATED_NAME ) ) + sWrong = xAttrList->getValue( SvXMLAutoCorrectToken::ABBREVIATED_NAME ); - for (sal_Int16 i=0; i < nAttrCount; i++) - { - const OUString& rAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nAttrPrefix = rImport.GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName); - const OUString& rAttrValue = xAttrList->getValueByIndex( i ); - if (XML_NAMESPACE_BLOCKLIST == nAttrPrefix) - { - if ( IsXMLToken ( aLocalName, XML_ABBREVIATED_NAME ) ) - { - sWrong = rAttrValue; - } - else if ( IsXMLToken ( aLocalName, XML_NAME ) ) - { - sRight = rAttrValue; - } - } - } - if (sWrong.isEmpty() || sRight.isEmpty()) + if ( xAttrList.is() && xAttrList->hasAttribute( SvXMLAutoCorrectToken::NAME ) ) + sRight = xAttrList->getValue( SvXMLAutoCorrectToken::NAME ); + + if ( sWrong.isEmpty() || sRight.isEmpty()) return; bool bOnlyTxt = sRight != sWrong; @@ -148,87 +114,58 @@ SvXMLExceptionListImport::SvXMLExceptionListImport( : SvXMLImport( xContext, "" ), rList (rNewList) { - GetNamespaceMap().Add( - OUString(aBlockList), - GetXMLToken ( XML_N_BLOCK_LIST), - XML_NAMESPACE_BLOCKLIST ); } SvXMLExceptionListImport::~SvXMLExceptionListImport ( void ) throw () { } -SvXMLImportContext *SvXMLExceptionListImport::CreateContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +SvXMLImportContext *SvXMLExceptionListImport::CreateFastContext(sal_Int32 Element, + const uno::Reference< xml::sax::XFastAttributeList > & xAttrList ) { - SvXMLImportContext *pContext = 0; - - if( XML_NAMESPACE_BLOCKLIST==nPrefix && - IsXMLToken ( rLocalName, XML_BLOCK_LIST ) ) - pContext = new SvXMLExceptionListContext( *this, nPrefix, rLocalName, xAttrList ); + if( Element == SvXMLAutoCorrectToken::BLOCKLIST ) + return new SvXMLExceptionListContext( *this, Element, xAttrList ); else - pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList ); - return pContext; + return SvXMLImport::CreateFastContext( Element, xAttrList ); } SvXMLExceptionListContext::SvXMLExceptionListContext( SvXMLExceptionListImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, + sal_Int32 /*Element*/, const com::sun::star::uno::Reference< - com::sun::star::xml::sax::XAttributeList > & /* xAttrList */ ) : - SvXMLImportContext ( rImport, nPrefix, rLocalName ), + com::sun::star::xml::sax::XFastAttributeList > & /* xAttrList */ ) : + SvXMLImportContext ( rImport ), rLocalRef(rImport) { } -SvXMLImportContext *SvXMLExceptionListContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +com::sun::star::uno::Reference<xml::sax::XFastContextHandler> SvXMLExceptionListContext::createFastChildContext( + sal_Int32 Element, const uno::Reference< xml::sax::XFastAttributeList > & xAttrList ) + throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) { - SvXMLImportContext *pContext = 0; - - if (nPrefix == XML_NAMESPACE_BLOCKLIST && - IsXMLToken ( rLocalName, XML_BLOCK ) ) - pContext = new SvXMLExceptionContext (rLocalRef, nPrefix, rLocalName, xAttrList); + if ( Element == SvXMLAutoCorrectToken::BLOCK ) + return new SvXMLExceptionContext (rLocalRef, Element, xAttrList); else - pContext = new SvXMLImportContext( rLocalRef, nPrefix, rLocalName); - return pContext; + return new SvXMLImportContext( rLocalRef ); } + SvXMLExceptionListContext::~SvXMLExceptionListContext ( void ) { } SvXMLExceptionContext::SvXMLExceptionContext( SvXMLExceptionListImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, + sal_Int32 /*Element*/, const com::sun::star::uno::Reference< - com::sun::star::xml::sax::XAttributeList > & xAttrList ) : - SvXMLImportContext ( rImport, nPrefix, rLocalName ), + com::sun::star::xml::sax::XFastAttributeList > & xAttrList ) : + SvXMLImportContext ( rImport ), rLocalRef(rImport) { OUString sWord; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + if( xAttrList.is() && xAttrList->hasAttribute( SvXMLAutoCorrectToken::ABBREVIATED_NAME ) ) + sWord = xAttrList->getValue( SvXMLAutoCorrectToken::ABBREVIATED_NAME ); - for (sal_Int16 i=0; i < nAttrCount; i++) - { - const OUString& rAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nAttrPrefix = rImport.GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName); - const OUString& rAttrValue = xAttrList->getValueByIndex( i ); - if (XML_NAMESPACE_BLOCKLIST == nAttrPrefix) - { - if ( IsXMLToken ( aLocalName, XML_ABBREVIATED_NAME ) ) - { - sWord = rAttrValue; - } - } - } - if (sWord.isEmpty() ) + if (sWord.isEmpty()) return; rLocalRef.rList.insert( sWord ); diff --git a/editeng/source/misc/SvXMLAutoCorrectImport.hxx b/editeng/source/misc/SvXMLAutoCorrectImport.hxx index ccd74a1fffda..49019582f852 100644 --- a/editeng/source/misc/SvXMLAutoCorrectImport.hxx +++ b/editeng/source/misc/SvXMLAutoCorrectImport.hxx @@ -22,8 +22,6 @@ #include <sot/storage.hxx> #include <xmloff/xmlictxt.hxx> #include <xmloff/xmlimp.hxx> -#include <xmloff/nmspmap.hxx> -#include <xmloff/xmlnmspe.hxx> #include <editeng/svxacorr.hxx> class SvXMLAutoCorrectImport : public SvXMLImport @@ -32,20 +30,19 @@ protected: // This method is called after the namespace map has been updated, but // before a context for the current element has been pushed. - virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE; + virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element, + const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > & xAttrList ) SAL_OVERRIDE; + public: SvxAutocorrWordList *pAutocorr_List; SvxAutoCorrect &rAutoCorrect; com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xStorage; SvXMLAutoCorrectImport( - const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext, + const ::css::uno::Reference< ::css::uno::XComponentContext > xContext, SvxAutocorrWordList *pNewAutocorr_List, SvxAutoCorrect &rNewAutoCorrect, - const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rNewStorage); + const ::css::uno::Reference < com::sun::star::embed::XStorage >& rNewStorage); virtual ~SvXMLAutoCorrectImport ( void ) throw (); }; @@ -55,15 +52,13 @@ class SvXMLWordListContext : public SvXMLImportContext private: SvXMLAutoCorrectImport & rLocalRef; public: - SvXMLWordListContext ( SvXMLAutoCorrectImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); - virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE; + SvXMLWordListContext ( SvXMLAutoCorrectImport& rImport, sal_Int32 Element, + const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > & xAttrList ); + + virtual com::sun::star::uno::Reference<XFastContextHandler> createFastChildContext( sal_Int32 Element, + const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > & xAttrList ) + throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; + virtual ~SvXMLWordListContext ( void ); }; @@ -72,11 +67,9 @@ class SvXMLWordContext : public SvXMLImportContext private: SvXMLAutoCorrectImport & rLocalRef; public: - SvXMLWordContext ( SvXMLAutoCorrectImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + SvXMLWordContext ( SvXMLAutoCorrectImport& rImport, sal_Int32 Element, + const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > & xAttrList ); + virtual ~SvXMLWordContext ( void ); }; @@ -87,15 +80,13 @@ protected: // This method is called after the namespace map has been updated, but // before a context for the current element has been pushed. - virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE; + virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element, const ::css::uno::Reference< + ::css::xml::sax::XFastAttributeList > & xAttrList ) SAL_OVERRIDE; public: SvStringsISortDtor &rList; SvXMLExceptionListImport( - const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext, + const ::css::uno::Reference< ::css::uno::XComponentContext > xContext, SvStringsISortDtor & rNewList ); virtual ~SvXMLExceptionListImport ( void ) throw (); @@ -106,15 +97,13 @@ class SvXMLExceptionListContext : public SvXMLImportContext private: SvXMLExceptionListImport & rLocalRef; public: - SvXMLExceptionListContext ( SvXMLExceptionListImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); - virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE; + SvXMLExceptionListContext ( SvXMLExceptionListImport& rImport, sal_Int32 Element, + const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > & xAttrList ); + + virtual com::sun::star::uno::Reference<XFastContextHandler> createFastChildContext( sal_Int32 Element, + const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > & xAttrList ) + throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; + virtual ~SvXMLExceptionListContext ( void ); }; @@ -123,11 +112,9 @@ class SvXMLExceptionContext : public SvXMLImportContext private: SvXMLExceptionListImport & rLocalRef; public: - SvXMLExceptionContext ( SvXMLExceptionListImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + SvXMLExceptionContext ( SvXMLExceptionListImport& rImport, sal_Int32 Element, + const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > & xAttrList ); + virtual ~SvXMLExceptionContext ( void ); }; diff --git a/editeng/source/misc/SvXMLAutoCorrectTokenHandler.cxx b/editeng/source/misc/SvXMLAutoCorrectTokenHandler.cxx new file mode 100644 index 000000000000..81982a63ee0c --- /dev/null +++ b/editeng/source/misc/SvXMLAutoCorrectTokenHandler.cxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <SvXMLAutoCorrectTokenHandler.hxx> +#include <xmloff/xmltoken.hxx> +#include <com/sun/star/xml/sax/FastToken.hpp> + +using namespace ::css::uno; +using namespace ::xmloff::token; + +SvXMLAutoCorrectTokenHandler::SvXMLAutoCorrectTokenHandler() +{ +} + +SvXMLAutoCorrectTokenHandler::~SvXMLAutoCorrectTokenHandler() +{ +} + +sal_Int32 SAL_CALL SvXMLAutoCorrectTokenHandler::getTokenFromUTF8( const Sequence< sal_Int8 >& Identifier ) + throw (::css::uno::RuntimeException, std::exception) +{ + switch( Identifier.getLength() ) + { + case 4: return XML_NAME; + case 5: return XML_BLOCK; + case 10: return XML_BLOCK_LIST; + case 16: return XML_ABBREVIATED_NAME; + default: return css::xml::sax::FastToken::DONTKNOW; + } +} + +Sequence< sal_Int8 > SAL_CALL SvXMLAutoCorrectTokenHandler::getUTF8Identifier( sal_Int32 ) + throw (::css::uno::RuntimeException, std::exception) +{ + return Sequence< sal_Int8 >(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/misc/SvXMLAutoCorrectTokenHandler.hxx b/editeng/source/misc/SvXMLAutoCorrectTokenHandler.hxx new file mode 100644 index 000000000000..dfe876213835 --- /dev/null +++ b/editeng/source/misc/SvXMLAutoCorrectTokenHandler.hxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef EDITENG_SOURCE_MISC_SVXMLAUTOCORRECTTOKENHANDLER_HXX +#define EDITENG_SOURCE_MISC_SVXMLAUTOCORRECTTOKENHANDLER_HXX + +#include <sal/types.h> +#include <xmloff/xmltoken.hxx> +#include <xmloff/xmlnmspe.hxx> +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/xml/sax/XFastTokenHandler.hpp> +#include <com/sun/star/xml/sax/FastToken.hpp> + +using namespace ::css::xml::sax; +using namespace ::xmloff::token; + +enum SvXMLAutoCorrectToken : sal_Int32 +{ + NAMESPACE = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST, //65553 + ABBREVIATED_NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_ABBREVIATED_NAME, //65655 + BLOCK = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_BLOCK, //65791 + BLOCKLIST = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_BLOCK_LIST, //65792 + NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_NAME //66737 +}; + +class SvXMLAutoCorrectTokenHandler : public + cppu::WeakImplHelper1< css::xml::sax::XFastTokenHandler > +{ +public: + SvXMLAutoCorrectTokenHandler(); + virtual ~SvXMLAutoCorrectTokenHandler(); + + //XFastTokenHandler + virtual sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier ) + throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 Token ) + throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; +}; + +#endif // EDITENG_SOURCE_MISC_SVXMLAUTOCORRECTTOKENHANDLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 6b8c7a77660a..9b840f32ae8b 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -50,11 +50,14 @@ #include "vcl/window.hxx" #include <helpid.hrc> #include <com/sun/star/xml/sax/InputSource.hpp> -#include <com/sun/star/xml/sax/Parser.hpp> +#include <com/sun/star/xml/sax/FastParser.hpp> +#include <com/sun/star/xml/sax/FastToken.hpp> #include <com/sun/star/xml/sax/Writer.hpp> +#include <com/sun/star/xml/sax/FastTokenHandler.hpp> #include <unotools/streamwrap.hxx> #include <SvXMLAutoCorrectImport.hxx> #include <SvXMLAutoCorrectExport.hxx> +#include <SvXMLAutoCorrectTokenHandler.hxx> #include <ucbhelper/content.hxx> #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/ucb/TransferInfo.hpp> @@ -64,6 +67,7 @@ using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; using namespace ::com::sun::star; using namespace ::xmloff::token; using namespace ::utl; @@ -2008,11 +2012,14 @@ void SvxAutoCorrectLanguageLists::LoadXMLExceptList_Imp( aParserInput.aInputStream = new utl::OInputStreamWrapper( *xStrm ); // get filter - uno::Reference< xml::sax::XDocumentHandler > xFilter = new SvXMLExceptionListImport ( xContext, *rpLst ); + uno::Reference< xml::sax::XFastDocumentHandler > xFilter = new SvXMLExceptionListImport ( xContext, *rpLst ); // connect parser and filter - uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create( xContext ); - xParser->setDocumentHandler( xFilter ); + uno::Reference< xml::sax::XFastParser > xParser = xml::sax::FastParser::create( xContext ); + uno::Reference< xml::sax::XFastTokenHandler > xTokenHandler = static_cast< xml::sax::XFastTokenHandler* >( new SvXMLAutoCorrectTokenHandler ); + xParser->setFastDocumentHandler( xFilter ); + xParser->registerNamespace( "http://openoffice.org/2001/block-list", SvXMLAutoCorrectToken::NAMESPACE ); + xParser->setTokenHandler( xTokenHandler ); // parse try @@ -2120,12 +2127,15 @@ SvxAutocorrWordList* SvxAutoCorrectLanguageLists::LoadAutocorrWordList() aParserInput.aInputStream = xStrm->getInputStream(); // get parser - uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create(xContext); + uno::Reference< xml::sax::XFastParser > xParser = xml::sax::FastParser::create(xContext); SAL_INFO("editeng", "AutoCorrect Import" ); - uno::Reference< xml::sax::XDocumentHandler > xFilter = new SvXMLAutoCorrectImport( xContext, pAutocorr_List, rAutoCorrect, xStg ); + uno::Reference< xml::sax::XFastDocumentHandler > xFilter = new SvXMLAutoCorrectImport( xContext, pAutocorr_List, rAutoCorrect, xStg ); + uno::Reference< xml::sax::XFastTokenHandler > xTokenHandler = static_cast< xml::sax::XFastTokenHandler* >( new SvXMLAutoCorrectTokenHandler ); // connect parser and filter - xParser->setDocumentHandler( xFilter ); + xParser->setFastDocumentHandler( xFilter ); + xParser->registerNamespace( "http://openoffice.org/2001/block-list", SvXMLAutoCorrectToken::NAMESPACE ); + xParser->setTokenHandler(xTokenHandler); // parse xParser->parseStream( aParserInput ); |