Kaydet (Commit) 328f861d authored tarafından Daniel Sikeler's avatar Daniel Sikeler Kaydeden (comit) Matúš Kukan

fdo#80403: AutoCorrect uses XFastParser

depends on c0a5d390
ContextClasses implement fast methods.
ImportClasses implement fast methods.
New TokenHandler for AutoCorrectTokens.

Change-Id: I41ef7266da2068da3ab5f047280b13e57ee2e763
üst c0a5d390
...@@ -87,6 +87,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\ ...@@ -87,6 +87,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\
editeng/source/misc/hangulhanja \ editeng/source/misc/hangulhanja \
editeng/source/misc/splwrap \ editeng/source/misc/splwrap \
editeng/source/misc/svxacorr \ editeng/source/misc/svxacorr \
editeng/source/misc/SvXMLAutoCorrectTokenHandler \
editeng/source/misc/SvXMLAutoCorrectExport \ editeng/source/misc/SvXMLAutoCorrectExport \
editeng/source/misc/SvXMLAutoCorrectImport \ editeng/source/misc/SvXMLAutoCorrectImport \
editeng/source/misc/swafopt \ editeng/source/misc/swafopt \
......
...@@ -18,13 +18,10 @@ ...@@ -18,13 +18,10 @@
*/ */
#include <SvXMLAutoCorrectImport.hxx> #include <SvXMLAutoCorrectImport.hxx>
#include <vcl/svapp.hxx> #include <SvXMLAutoCorrectTokenHandler.hxx>
#include <xmloff/xmltoken.hxx>
using namespace ::com::sun::star; using namespace ::css;
using namespace ::xmloff::token; using namespace ::css::xml::sax;
const char aBlockList[] = "_block-list";
SvXMLAutoCorrectImport::SvXMLAutoCorrectImport( SvXMLAutoCorrectImport::SvXMLAutoCorrectImport(
const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< uno::XComponentContext > xContext,
...@@ -36,92 +33,61 @@ SvXMLAutoCorrectImport::SvXMLAutoCorrectImport( ...@@ -36,92 +33,61 @@ SvXMLAutoCorrectImport::SvXMLAutoCorrectImport(
rAutoCorrect ( rNewAutoCorrect ), rAutoCorrect ( rNewAutoCorrect ),
xStorage ( rNewStorage ) xStorage ( rNewStorage )
{ {
GetNamespaceMap().Add(
OUString(aBlockList),
GetXMLToken ( XML_N_BLOCK_LIST),
XML_NAMESPACE_BLOCKLIST );
} }
SvXMLAutoCorrectImport::~SvXMLAutoCorrectImport ( void ) throw () SvXMLAutoCorrectImport::~SvXMLAutoCorrectImport ( void ) throw ()
{ {
} }
SvXMLImportContext *SvXMLAutoCorrectImport::CreateContext( SvXMLImportContext *SvXMLAutoCorrectImport::CreateFastContext( sal_Int32 Element,
sal_uInt16 nPrefix, const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList > & xAttrList )
{ {
SvXMLImportContext *pContext = 0; if( Element == SvXMLAutoCorrectToken::BLOCKLIST )
return new SvXMLWordListContext( *this, Element, xAttrList );
if( XML_NAMESPACE_BLOCKLIST == nPrefix &&
IsXMLToken ( rLocalName, XML_BLOCK_LIST ) )
pContext = new SvXMLWordListContext( *this, nPrefix, rLocalName, xAttrList );
else else
pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList ); return SvXMLImport::CreateFastContext( Element, xAttrList );
return pContext;
} }
SvXMLWordListContext::SvXMLWordListContext( SvXMLWordListContext::SvXMLWordListContext(
SvXMLAutoCorrectImport& rImport, SvXMLAutoCorrectImport& rImport,
sal_uInt16 nPrefix, sal_Int32 /*Element*/,
const OUString& rLocalName,
const com::sun::star::uno::Reference< const com::sun::star::uno::Reference<
com::sun::star::xml::sax::XAttributeList > & /*xAttrList*/ ) : com::sun::star::xml::sax::XFastAttributeList > & /*xAttrList*/ ) :
SvXMLImportContext ( rImport, nPrefix, rLocalName ), SvXMLImportContext ( rImport ),
rLocalRef(rImport) rLocalRef(rImport)
{ {
} }
SvXMLImportContext *SvXMLWordListContext::CreateChildContext( com::sun::star::uno::Reference<XFastContextHandler> SvXMLWordListContext::createFastChildContext(
sal_uInt16 nPrefix, sal_Int32 Element, const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
const OUString& rLocalName, throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception)
const uno::Reference< xml::sax::XAttributeList > & xAttrList )
{ {
SvXMLImportContext *pContext = 0; if ( Element == SvXMLAutoCorrectToken::BLOCK )
return new SvXMLWordContext (rLocalRef, Element, xAttrList);
if (nPrefix == XML_NAMESPACE_BLOCKLIST &&
IsXMLToken ( rLocalName, XML_BLOCK ) )
pContext = new SvXMLWordContext (rLocalRef, nPrefix, rLocalName, xAttrList);
else else
pContext = new SvXMLImportContext( rLocalRef, nPrefix, rLocalName); return new SvXMLImportContext( rLocalRef );
return pContext;
} }
SvXMLWordListContext::~SvXMLWordListContext ( void ) SvXMLWordListContext::~SvXMLWordListContext ( void )
{ {
} }
SvXMLWordContext::SvXMLWordContext( SvXMLWordContext::SvXMLWordContext(
SvXMLAutoCorrectImport& rImport, SvXMLAutoCorrectImport& rImport,
sal_uInt16 nPrefix, sal_Int32 /*Element*/,
const OUString& rLocalName,
const com::sun::star::uno::Reference< const com::sun::star::uno::Reference<
com::sun::star::xml::sax::XAttributeList > & xAttrList ) : com::sun::star::xml::sax::XFastAttributeList > & xAttrList ) :
SvXMLImportContext ( rImport, nPrefix, rLocalName ), SvXMLImportContext ( rImport ),
rLocalRef(rImport) rLocalRef(rImport)
{ {
OUString sRight; OUString sWrong, sRight;
OUString sWrong; if ( xAttrList.is() && xAttrList->hasAttribute( SvXMLAutoCorrectToken::ABBREVIATED_NAME ) )
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; sWrong = xAttrList->getValue( SvXMLAutoCorrectToken::ABBREVIATED_NAME );
for (sal_Int16 i=0; i < nAttrCount; i++) if ( xAttrList.is() && xAttrList->hasAttribute( SvXMLAutoCorrectToken::NAME ) )
{ sRight = xAttrList->getValue( SvXMLAutoCorrectToken::NAME );
const OUString& rAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName; if ( sWrong.isEmpty() || sRight.isEmpty())
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())
return; return;
bool bOnlyTxt = sRight != sWrong; bool bOnlyTxt = sRight != sWrong;
...@@ -148,87 +114,58 @@ SvXMLExceptionListImport::SvXMLExceptionListImport( ...@@ -148,87 +114,58 @@ SvXMLExceptionListImport::SvXMLExceptionListImport(
: SvXMLImport( xContext, "" ), : SvXMLImport( xContext, "" ),
rList (rNewList) rList (rNewList)
{ {
GetNamespaceMap().Add(
OUString(aBlockList),
GetXMLToken ( XML_N_BLOCK_LIST),
XML_NAMESPACE_BLOCKLIST );
} }
SvXMLExceptionListImport::~SvXMLExceptionListImport ( void ) throw () SvXMLExceptionListImport::~SvXMLExceptionListImport ( void ) throw ()
{ {
} }
SvXMLImportContext *SvXMLExceptionListImport::CreateContext( SvXMLImportContext *SvXMLExceptionListImport::CreateFastContext(sal_Int32 Element,
sal_uInt16 nPrefix, const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList > & xAttrList )
{ {
SvXMLImportContext *pContext = 0; if( Element == SvXMLAutoCorrectToken::BLOCKLIST )
return new SvXMLExceptionListContext( *this, Element, xAttrList );
if( XML_NAMESPACE_BLOCKLIST==nPrefix &&
IsXMLToken ( rLocalName, XML_BLOCK_LIST ) )
pContext = new SvXMLExceptionListContext( *this, nPrefix, rLocalName, xAttrList );
else else
pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList ); return SvXMLImport::CreateFastContext( Element, xAttrList );
return pContext;
} }
SvXMLExceptionListContext::SvXMLExceptionListContext( SvXMLExceptionListContext::SvXMLExceptionListContext(
SvXMLExceptionListImport& rImport, SvXMLExceptionListImport& rImport,
sal_uInt16 nPrefix, sal_Int32 /*Element*/,
const OUString& rLocalName,
const com::sun::star::uno::Reference< const com::sun::star::uno::Reference<
com::sun::star::xml::sax::XAttributeList > & /* xAttrList */ ) : com::sun::star::xml::sax::XFastAttributeList > & /* xAttrList */ ) :
SvXMLImportContext ( rImport, nPrefix, rLocalName ), SvXMLImportContext ( rImport ),
rLocalRef(rImport) rLocalRef(rImport)
{ {
} }
SvXMLImportContext *SvXMLExceptionListContext::CreateChildContext( com::sun::star::uno::Reference<xml::sax::XFastContextHandler> SvXMLExceptionListContext::createFastChildContext(
sal_uInt16 nPrefix, sal_Int32 Element, const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
const OUString& rLocalName, throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception)
const uno::Reference< xml::sax::XAttributeList > & xAttrList )
{ {
SvXMLImportContext *pContext = 0; if ( Element == SvXMLAutoCorrectToken::BLOCK )
return new SvXMLExceptionContext (rLocalRef, Element, xAttrList);
if (nPrefix == XML_NAMESPACE_BLOCKLIST &&
IsXMLToken ( rLocalName, XML_BLOCK ) )
pContext = new SvXMLExceptionContext (rLocalRef, nPrefix, rLocalName, xAttrList);
else else
pContext = new SvXMLImportContext( rLocalRef, nPrefix, rLocalName); return new SvXMLImportContext( rLocalRef );
return pContext;
} }
SvXMLExceptionListContext::~SvXMLExceptionListContext ( void ) SvXMLExceptionListContext::~SvXMLExceptionListContext ( void )
{ {
} }
SvXMLExceptionContext::SvXMLExceptionContext( SvXMLExceptionContext::SvXMLExceptionContext(
SvXMLExceptionListImport& rImport, SvXMLExceptionListImport& rImport,
sal_uInt16 nPrefix, sal_Int32 /*Element*/,
const OUString& rLocalName,
const com::sun::star::uno::Reference< const com::sun::star::uno::Reference<
com::sun::star::xml::sax::XAttributeList > & xAttrList ) : com::sun::star::xml::sax::XFastAttributeList > & xAttrList ) :
SvXMLImportContext ( rImport, nPrefix, rLocalName ), SvXMLImportContext ( rImport ),
rLocalRef(rImport) rLocalRef(rImport)
{ {
OUString sWord; 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++) if (sWord.isEmpty())
{
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() )
return; return;
rLocalRef.rList.insert( sWord ); rLocalRef.rList.insert( sWord );
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include <sot/storage.hxx> #include <sot/storage.hxx>
#include <xmloff/xmlictxt.hxx> #include <xmloff/xmlictxt.hxx>
#include <xmloff/xmlimp.hxx> #include <xmloff/xmlimp.hxx>
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmlnmspe.hxx>
#include <editeng/svxacorr.hxx> #include <editeng/svxacorr.hxx>
class SvXMLAutoCorrectImport : public SvXMLImport class SvXMLAutoCorrectImport : public SvXMLImport
...@@ -32,20 +30,19 @@ protected: ...@@ -32,20 +30,19 @@ protected:
// This method is called after the namespace map has been updated, but // This method is called after the namespace map has been updated, but
// before a context for the current element has been pushed. // before a context for the current element has been pushed.
virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix, virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element,
const OUString& rLocalName, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > & xAttrList ) SAL_OVERRIDE;
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
public: public:
SvxAutocorrWordList *pAutocorr_List; SvxAutocorrWordList *pAutocorr_List;
SvxAutoCorrect &rAutoCorrect; SvxAutoCorrect &rAutoCorrect;
com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xStorage; com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xStorage;
SvXMLAutoCorrectImport( SvXMLAutoCorrectImport(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext, const ::css::uno::Reference< ::css::uno::XComponentContext > xContext,
SvxAutocorrWordList *pNewAutocorr_List, SvxAutocorrWordList *pNewAutocorr_List,
SvxAutoCorrect &rNewAutoCorrect, 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 (); virtual ~SvXMLAutoCorrectImport ( void ) throw ();
}; };
...@@ -55,15 +52,13 @@ class SvXMLWordListContext : public SvXMLImportContext ...@@ -55,15 +52,13 @@ class SvXMLWordListContext : public SvXMLImportContext
private: private:
SvXMLAutoCorrectImport & rLocalRef; SvXMLAutoCorrectImport & rLocalRef;
public: public:
SvXMLWordListContext ( SvXMLAutoCorrectImport& rImport, SvXMLWordListContext ( SvXMLAutoCorrectImport& rImport, sal_Int32 Element,
sal_uInt16 nPrefix, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > & xAttrList );
const OUString& rLocalName,
const ::com::sun::star::uno::Reference< virtual com::sun::star::uno::Reference<XFastContextHandler> createFastChildContext( sal_Int32 Element,
::com::sun::star::xml::sax::XAttributeList > & xAttrList ); const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > & xAttrList )
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
const OUString& rLocalName,
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
virtual ~SvXMLWordListContext ( void ); virtual ~SvXMLWordListContext ( void );
}; };
...@@ -72,11 +67,9 @@ class SvXMLWordContext : public SvXMLImportContext ...@@ -72,11 +67,9 @@ class SvXMLWordContext : public SvXMLImportContext
private: private:
SvXMLAutoCorrectImport & rLocalRef; SvXMLAutoCorrectImport & rLocalRef;
public: public:
SvXMLWordContext ( SvXMLAutoCorrectImport& rImport, SvXMLWordContext ( SvXMLAutoCorrectImport& rImport, sal_Int32 Element,
sal_uInt16 nPrefix, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > & xAttrList );
const OUString& rLocalName,
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList > & xAttrList );
virtual ~SvXMLWordContext ( void ); virtual ~SvXMLWordContext ( void );
}; };
...@@ -87,15 +80,13 @@ protected: ...@@ -87,15 +80,13 @@ protected:
// This method is called after the namespace map has been updated, but // This method is called after the namespace map has been updated, but
// before a context for the current element has been pushed. // before a context for the current element has been pushed.
virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix, virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element, const ::css::uno::Reference<
const OUString& rLocalName, ::css::xml::sax::XFastAttributeList > & xAttrList ) SAL_OVERRIDE;
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
public: public:
SvStringsISortDtor &rList; SvStringsISortDtor &rList;
SvXMLExceptionListImport( SvXMLExceptionListImport(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext, const ::css::uno::Reference< ::css::uno::XComponentContext > xContext,
SvStringsISortDtor & rNewList ); SvStringsISortDtor & rNewList );
virtual ~SvXMLExceptionListImport ( void ) throw (); virtual ~SvXMLExceptionListImport ( void ) throw ();
...@@ -106,15 +97,13 @@ class SvXMLExceptionListContext : public SvXMLImportContext ...@@ -106,15 +97,13 @@ class SvXMLExceptionListContext : public SvXMLImportContext
private: private:
SvXMLExceptionListImport & rLocalRef; SvXMLExceptionListImport & rLocalRef;
public: public:
SvXMLExceptionListContext ( SvXMLExceptionListImport& rImport, SvXMLExceptionListContext ( SvXMLExceptionListImport& rImport, sal_Int32 Element,
sal_uInt16 nPrefix, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > & xAttrList );
const OUString& rLocalName,
const ::com::sun::star::uno::Reference< virtual com::sun::star::uno::Reference<XFastContextHandler> createFastChildContext( sal_Int32 Element,
::com::sun::star::xml::sax::XAttributeList > & xAttrList ); const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > & xAttrList )
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
const OUString& rLocalName,
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
virtual ~SvXMLExceptionListContext ( void ); virtual ~SvXMLExceptionListContext ( void );
}; };
...@@ -123,11 +112,9 @@ class SvXMLExceptionContext : public SvXMLImportContext ...@@ -123,11 +112,9 @@ class SvXMLExceptionContext : public SvXMLImportContext
private: private:
SvXMLExceptionListImport & rLocalRef; SvXMLExceptionListImport & rLocalRef;
public: public:
SvXMLExceptionContext ( SvXMLExceptionListImport& rImport, SvXMLExceptionContext ( SvXMLExceptionListImport& rImport, sal_Int32 Element,
sal_uInt16 nPrefix, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > & xAttrList );
const OUString& rLocalName,
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList > & xAttrList );
virtual ~SvXMLExceptionContext ( void ); virtual ~SvXMLExceptionContext ( void );
}; };
......
/* -*- 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: */
/* -*- 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: */
...@@ -50,11 +50,14 @@ ...@@ -50,11 +50,14 @@
#include "vcl/window.hxx" #include "vcl/window.hxx"
#include <helpid.hrc> #include <helpid.hrc>
#include <com/sun/star/xml/sax/InputSource.hpp> #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/Writer.hpp>
#include <com/sun/star/xml/sax/FastTokenHandler.hpp>
#include <unotools/streamwrap.hxx> #include <unotools/streamwrap.hxx>
#include <SvXMLAutoCorrectImport.hxx> #include <SvXMLAutoCorrectImport.hxx>
#include <SvXMLAutoCorrectExport.hxx> #include <SvXMLAutoCorrectExport.hxx>
#include <SvXMLAutoCorrectTokenHandler.hxx>
#include <ucbhelper/content.hxx> #include <ucbhelper/content.hxx>
#include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <com/sun/star/ucb/TransferInfo.hpp> #include <com/sun/star/ucb/TransferInfo.hpp>
...@@ -64,6 +67,7 @@ ...@@ -64,6 +67,7 @@
using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::ucb;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::xml::sax;
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::xmloff::token; using namespace ::xmloff::token;
using namespace ::utl; using namespace ::utl;
...@@ -2008,11 +2012,14 @@ void SvxAutoCorrectLanguageLists::LoadXMLExceptList_Imp( ...@@ -2008,11 +2012,14 @@ void SvxAutoCorrectLanguageLists::LoadXMLExceptList_Imp(
aParserInput.aInputStream = new utl::OInputStreamWrapper( *xStrm ); aParserInput.aInputStream = new utl::OInputStreamWrapper( *xStrm );
// get filter // 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 // connect parser and filter
uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create( xContext ); uno::Reference< xml::sax::XFastParser > xParser = xml::sax::FastParser::create( xContext );
xParser->setDocumentHandler( xFilter ); 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 // parse
try try
...@@ -2120,12 +2127,15 @@ SvxAutocorrWordList* SvxAutoCorrectLanguageLists::LoadAutocorrWordList() ...@@ -2120,12 +2127,15 @@ SvxAutocorrWordList* SvxAutoCorrectLanguageLists::LoadAutocorrWordList()
aParserInput.aInputStream = xStrm->getInputStream(); aParserInput.aInputStream = xStrm->getInputStream();
// get parser // 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" ); 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 // connect parser and filter
xParser->setDocumentHandler( xFilter ); xParser->setFastDocumentHandler( xFilter );
xParser->registerNamespace( "http://openoffice.org/2001/block-list", SvXMLAutoCorrectToken::NAMESPACE );
xParser->setTokenHandler(xTokenHandler);
// parse // parse
xParser->parseStream( aParserInput ); xParser->parseStream( aParserInput );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment