summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorDaniel Sikeler <d.sikeler94@gmail.com>2014-11-10 12:23:12 +0000
committerMichael Meeks <michael.meeks@collabora.com>2014-12-04 09:39:01 +0000
commitc1e90457d2ecc6e1171b7a296ab8bd05821e39e6 (patch)
treeafe390d50ef33652cc5019226d1e47a7d4da3644 /sw
parent14c94c97ffcb4b51974a8177a8017d620b4d9293 (diff)
fdo#80403: Writer specific AutoCorr use FastParser
Contextclasses implement XFastContextHandler Importclasses implement XFastDocumentHandler Tokens for BlockList.xml are defined in BlockListTokens.txt Tokens for content.xml are defined in TextBlockTokens.txt A perfect hash table is generated with gperf and used by the tokenhandlers Change-Id: Iff8ad5f1a4df0b808ee6fdf13f75a821596e9ee9 Reviewed-on: https://gerrit.libreoffice.org/12386 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/CustomTarget_generated.mk34
-rw-r--r--sw/Library_sw.mk1
-rw-r--r--sw/Module_sw.mk1
-rw-r--r--sw/source/core/inc/SwXMLBlockImport.hxx76
-rw-r--r--sw/source/core/swg/BlockListTokens.txt7
-rw-r--r--sw/source/core/swg/SwXMLBlockImport.cxx392
-rw-r--r--sw/source/core/swg/SwXMLTextBlocks1.cxx93
-rw-r--r--sw/source/core/swg/TextBlockTokens.txt5
8 files changed, 384 insertions, 225 deletions
diff --git a/sw/CustomTarget_generated.mk b/sw/CustomTarget_generated.mk
new file mode 100644
index 000000000000..27527990e63c
--- /dev/null
+++ b/sw/CustomTarget_generated.mk
@@ -0,0 +1,34 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_CustomTarget_CustomTarget,sw/generated))
+
+sw_SRC := $(SRCDIR)/sw/source/core/swg
+sw_PL := $(SRCDIR)/solenv/bin/gentoken.pl
+sw_INC := $(call gb_CustomTarget_get_workdir,sw/generated)
+
+$(sw_INC)/TextBlockTokens.gperf : $(sw_SRC)/TextBlockTokens.txt $(sw_PL)
+ mkdir -p $(sw_INC)
+ $(PERL) $(sw_PL) $(sw_SRC)/TextBlockTokens.txt $(sw_INC)/TextBlockTokens.gperf
+
+$(sw_INC)/BlockListTokens.gperf : $(sw_SRC)/BlockListTokens.txt $(sw_PL)
+ mkdir -p $(sw_INC)
+ $(PERL) $(sw_PL) $(sw_SRC)/BlockListTokens.txt $(sw_INC)/BlockListTokens.gperf
+
+$(sw_INC)/tokens.cxx : $(sw_INC)/TextBlockTokens.gperf $(sw_INC)/BlockListTokens.gperf
+ $(GPERF) --compare-strncmp --readonly-tables --output-file=$(sw_INC)/tokens.cxx \
+ --class-name=TextBlockTokens --word-array-name=textBlockList --enum $(sw_INC)/TextBlockTokens.gperf
+ $(GPERF) --compare-strncmp --readonly-tables -T $(sw_INC)/BlockListTokens.gperf \
+ --class-name=BlockListTokens --word-array-name=blockListList >> $(sw_INC)/tokens.cxx
+ sed -i -e "s/(char\*)0/(char\*)0, XML_TOKEN_INVALID/g" $(sw_INC)/tokens.cxx
+ sed -i -e "/^#line/d" $(sw_INC)/tokens.cxx
+
+$(call gb_CustomTarget_get_target,sw/generated) : $(sw_INC)/tokens.cxx
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index c4753150a5c8..2816b0524ff7 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -36,6 +36,7 @@ $(eval $(call gb_Library_set_include,sw,\
$(eval $(call gb_Library_use_custom_headers,sw,\
officecfg/registry \
+ sw/generated \
))
$(eval $(call gb_Library_use_sdk_api,sw))
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index a7a31efbab44..bf110be6a29c 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -21,6 +21,7 @@ $(eval $(call gb_Module_Module,sw))
$(eval $(call gb_Module_add_targets,sw,\
$(call gb_Helper_optional,DESKTOP,Executable_tiledrendering) \
+ CustomTarget_generated \
Library_msword \
Library_sw \
Library_swd \
diff --git a/sw/source/core/inc/SwXMLBlockImport.hxx b/sw/source/core/inc/SwXMLBlockImport.hxx
index ac166fd3d459..e64b86b1091e 100644
--- a/sw/source/core/inc/SwXMLBlockImport.hxx
+++ b/sw/source/core/inc/SwXMLBlockImport.hxx
@@ -21,6 +21,14 @@
#define INCLUDED_SW_SOURCE_CORE_INC_SWXMLBLOCKIMPORT_HXX
#include <xmloff/xmlimp.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
+#include <com/sun/star/xml/sax/FastToken.hpp>
+#include <sax/fastattribs.hxx>
+
+using namespace css::xml::sax;
+using namespace xmloff::token;
class SwXMLTextBlocks;
class SwXMLBlockListImport : public SvXMLImport
@@ -31,10 +39,8 @@ private:
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:
SwXMLBlockListImport(
@@ -57,10 +63,8 @@ private:
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:
bool bTextOnly;
@@ -79,6 +83,62 @@ public:
throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
};
+enum SwXMLTextBlockToken : sal_Int32
+{
+ OFFICE_BODY = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_BODY,
+ OFFICE_TEXT = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_TEXT,
+ OFFICE_DOCUMENT = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_DOCUMENT,
+ OFFICE_DOCUMENT_CONTENT = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_DOCUMENT_CONTENT,
+ TEXT_P = FastToken::NAMESPACE | XML_NAMESPACE_TEXT | XML_P
+};
+
+class SwXMLTextBlockTokenHandler : public
+ cppu::WeakImplHelper1< css::xml::sax::XFastTokenHandler >,
+ public sax_fastparser::FastTokenHandlerBase
+{
+public:
+ SwXMLTextBlockTokenHandler();
+ ~SwXMLTextBlockTokenHandler();
+
+ //XFastTokenHandler
+ sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier )
+ throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 Token )
+ throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ //Much fast direct C++ shortcut to the method that matters
+ virtual sal_Int32 getTokenDirect( const char *pTag, sal_Int32 nLength ) const SAL_OVERRIDE;
+};
+
+enum SwXMLBlockListToken : sal_Int32
+{
+ ABBREVIATED_NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_ABBREVIATED_NAME,
+ BLOCK = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_BLOCK,
+ BLOCK_LIST = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_BLOCK_LIST,
+ LIST_NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_LIST_NAME,
+ NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_NAME,
+ PACKAGE_NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_PACKAGE_NAME,
+ UNFORMATTED_TEXT = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_UNFORMATTED_TEXT
+};
+
+class SwXMLBlockListTokenHandler : public
+ cppu::WeakImplHelper1< css::xml::sax::XFastTokenHandler >,
+ public sax_fastparser::FastTokenHandlerBase
+{
+public:
+ SwXMLBlockListTokenHandler();
+ ~SwXMLBlockListTokenHandler();
+
+ //XFastTokenHandler
+ sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier )
+ throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 Token )
+ throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ //Much fast direct C++ shortcut to the method that matters
+ virtual sal_Int32 getTokenDirect( const char *pTag, sal_Int32 nLength ) const SAL_OVERRIDE;
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/swg/BlockListTokens.txt b/sw/source/core/swg/BlockListTokens.txt
new file mode 100644
index 000000000000..0b5a64607b3e
--- /dev/null
+++ b/sw/source/core/swg/BlockListTokens.txt
@@ -0,0 +1,7 @@
+abbreviated-name
+block
+block-list
+list-name
+name
+package-name
+unformatted-text
diff --git a/sw/source/core/swg/SwXMLBlockImport.cxx b/sw/source/core/swg/SwXMLBlockImport.cxx
index 5d5355b293ee..5491aa2252eb 100644
--- a/sw/source/core/swg/SwXMLBlockImport.cxx
+++ b/sw/source/core/swg/SwXMLBlockImport.cxx
@@ -18,16 +18,15 @@
*/
#include <SwXMLBlockImport.hxx>
-#include <xmloff/nmspmap.hxx>
-#include <xmloff/xmlnmspe.hxx>
#include <SwXMLTextBlocks.hxx>
#include <xmloff/xmlictxt.hxx>
#include <unotools/charclass.hxx>
#include <swtypes.hxx>
+#include <tokens.cxx>
+using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
-using namespace ::xmloff::token;
-
+using namespace css::xml::sax;
class SwXMLBlockListImport;
class SwXMLTextBlockImport;
@@ -38,24 +37,20 @@ private:
SwXMLBlockListImport & rLocalRef;
public:
- SwXMLBlockListContext( SwXMLBlockListImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList> & xAttrList);
+ SwXMLBlockListContext( SwXMLBlockListImport& rImport, sal_Int32 Element,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
virtual ~SwXMLBlockListContext ( void );
- virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList> & xAttrList) SAL_OVERRIDE;
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL 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;
};
class SwXMLBlockContext : public SvXMLImportContext
{
public:
- SwXMLBlockContext( SwXMLBlockListImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList> & xAttrList);
+ SwXMLBlockContext( SwXMLBlockListImport& rImport, sal_Int32 Element,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
virtual ~SwXMLBlockContext ( void );
};
@@ -65,13 +60,13 @@ private:
SwXMLTextBlockImport & rLocalRef;
public:
- SwXMLTextBlockDocumentContext( SwXMLTextBlockImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList> & xAttrList);
- virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList> & xAttrList) SAL_OVERRIDE;
+ SwXMLTextBlockDocumentContext( SwXMLTextBlockImport& rImport, sal_Int32 Element,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
+
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL 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 ~SwXMLTextBlockDocumentContext ( void );
};
@@ -81,13 +76,13 @@ private:
SwXMLTextBlockImport & rLocalRef;
public:
- SwXMLTextBlockBodyContext( SwXMLTextBlockImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList > & xAttrList);
- virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList> & xAttrList) SAL_OVERRIDE;
+ SwXMLTextBlockBodyContext( SwXMLTextBlockImport& rImport, sal_Int32 Element,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
+
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
+ sal_Int32, const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList )
+ throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
+
virtual ~SwXMLTextBlockBodyContext ( void );
};
@@ -97,15 +92,14 @@ private:
SwXMLTextBlockImport & rLocalRef;
public:
- SwXMLTextBlockTextContext( SwXMLTextBlockImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<
- xml::sax::XAttributeList > & xAttrList );
- virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<
- xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
+ SwXMLTextBlockTextContext( SwXMLTextBlockImport& rImport, sal_Int32 Element,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
+
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL 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 ~SwXMLTextBlockTextContext ( void );
};
@@ -115,101 +109,119 @@ private:
SwXMLTextBlockImport & rLocalRef;
public:
- SwXMLTextBlockParContext( SwXMLTextBlockImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<
- xml::sax::XAttributeList > & xAttrList );
- virtual void Characters( const OUString& rChars ) SAL_OVERRIDE;
+ SwXMLTextBlockParContext( SwXMLTextBlockImport & rImport, sal_Int32 Element,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
+
+ virtual void SAL_CALL characters( const OUString & aChars )
+ throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
+
virtual ~SwXMLTextBlockParContext ( void );
};
+SwXMLTextBlockTokenHandler::SwXMLTextBlockTokenHandler()
+{
+}
+
+SwXMLTextBlockTokenHandler::~SwXMLTextBlockTokenHandler()
+{
+}
+
+sal_Int32 SAL_CALL SwXMLTextBlockTokenHandler::getTokenFromUTF8( const Sequence< sal_Int8 >& Identifier )
+ throw (css::uno::RuntimeException, std::exception)
+{
+ return getTokenDirect( reinterpret_cast< const char* >( Identifier.getConstArray() ), Identifier.getLength() );
+}
+
+Sequence< sal_Int8 > SAL_CALL SwXMLTextBlockTokenHandler::getUTF8Identifier( sal_Int32 )
+ throw (css::uno::RuntimeException, std::exception)
+{
+ return Sequence< sal_Int8 >();
+}
+
+sal_Int32 SwXMLTextBlockTokenHandler::getTokenDirect( const char *pTag, sal_Int32 nLength ) const
+{
+ if( !nLength )
+ nLength = strlen( pTag );
+ const struct xmltoken* pToken = TextBlockTokens::in_word_set( pTag, nLength );
+ return pToken ? pToken->nToken : XML_TOKEN_INVALID;
+}
+
+SwXMLBlockListTokenHandler::SwXMLBlockListTokenHandler()
+{
+}
+
+SwXMLBlockListTokenHandler::~SwXMLBlockListTokenHandler()
+{
+}
+
+sal_Int32 SAL_CALL SwXMLBlockListTokenHandler::getTokenFromUTF8( const Sequence< sal_Int8 >& Identifier )
+ throw (css::uno::RuntimeException, std::exception)
+{
+ return getTokenDirect( reinterpret_cast< const char* >( Identifier.getConstArray() ), Identifier.getLength() );
+}
+
+Sequence< sal_Int8 > SAL_CALL SwXMLBlockListTokenHandler::getUTF8Identifier( sal_Int32 )
+ throw (css::uno::RuntimeException, std::exception)
+{
+ return Sequence< sal_Int8 >();
+}
+
+sal_Int32 SwXMLBlockListTokenHandler::getTokenDirect( const char *pTag, sal_Int32 nLength ) const
+{
+ if( !nLength )
+ nLength = strlen( pTag );
+ const struct xmltoken* pToken = BlockListTokens::in_word_set( pTag, nLength );
+ return pToken ? pToken->nToken : XML_TOKEN_INVALID;
+}
SwXMLBlockListContext::SwXMLBlockListContext(
- SwXMLBlockListImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<
- xml::sax::XAttributeList > & xAttrList ) :
- SvXMLImportContext ( rImport, nPrefix, rLocalName ),
- rLocalRef (rImport)
-{
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for (sal_Int16 i=0; i < nAttrCount; i++)
- {
- const OUString& rAttrName = xAttrList->getNameByIndex( i );
- OUString aLocalName;
- sal_uInt16 nPrefx = rImport.GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName);
- const OUString& rAttrValue = xAttrList->getValueByIndex( i );
- if ( XML_NAMESPACE_BLOCKLIST == nPrefx )
- {
- if ( IsXMLToken ( aLocalName, XML_LIST_NAME ) )
- {
- rImport.getBlockList().SetName(rAttrValue);
- break;
- }
- }
- }
+ SwXMLBlockListImport& rImport,
+ sal_Int32 /*Element*/,
+ const uno::Reference< xml::sax::XFastAttributeList > & xAttrList ) :
+ SvXMLImportContext( rImport ),
+ rLocalRef( rImport )
+{
+ if( xAttrList.is() && xAttrList->hasAttribute( SwXMLBlockListToken::LIST_NAME ) )
+ rImport.getBlockList().SetName( xAttrList->getValue( SwXMLBlockListToken::LIST_NAME ) );
}
SwXMLBlockListContext::~SwXMLBlockListContext ( void )
{
}
-SvXMLImportContext *SwXMLBlockListContext::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > & xAttrList )
+uno::Reference< ::xml::sax::XFastContextHandler > SAL_CALL
+SwXMLBlockListContext::createFastChildContext( sal_Int32 Element,
+ const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
{
- SvXMLImportContext *pContext = 0;
- if (nPrefix == XML_NAMESPACE_BLOCKLIST &&
- IsXMLToken ( rLocalName, XML_BLOCK ) )
- pContext = new SwXMLBlockContext (rLocalRef, nPrefix, rLocalName, xAttrList);
+ if ( Element == SwXMLBlockListToken::BLOCK )
+ return new SwXMLBlockContext( rLocalRef, Element, xAttrList );
else
- pContext = new SvXMLImportContext( rLocalRef, nPrefix, rLocalName);
- return pContext;
+ return new SvXMLImportContext( rLocalRef );
}
SwXMLBlockContext::SwXMLBlockContext(
- SwXMLBlockListImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<
- xml::sax::XAttributeList > & xAttrList ) :
- SvXMLImportContext ( rImport, nPrefix, rLocalName )
+ SwXMLBlockListImport& rImport,
+ sal_Int32 /*Element*/,
+ const uno::Reference< xml::sax::XFastAttributeList > & xAttrList ) :
+ SvXMLImportContext( rImport )
{
static const CharClass & rCC = GetAppCharClass();
- OUString aShort;
- OUString aLong;
- OUString aPackageName;
+ OUString aShort, aLong, aPackageName;
bool bTextOnly = false;
-
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for (sal_Int16 i=0; i < nAttrCount; i++)
+ if( xAttrList.is() )
{
- const OUString& rAttrName = xAttrList->getNameByIndex( i );
- OUString aLocalName;
- sal_uInt16 nPrefx = rImport.GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName);
- const OUString& rAttrValue = xAttrList->getValueByIndex( i );
- if (XML_NAMESPACE_BLOCKLIST == nPrefx)
+ if( xAttrList->hasAttribute( SwXMLBlockListToken::ABBREVIATED_NAME ) )
+ aShort = rCC.uppercase( xAttrList->getValue( SwXMLBlockListToken::ABBREVIATED_NAME ) );
+ if( xAttrList->hasAttribute( SwXMLBlockListToken::NAME ) )
+ aLong = xAttrList->getValue( SwXMLBlockListToken::NAME );
+ if( xAttrList->hasAttribute( SwXMLBlockListToken::PACKAGE_NAME ) )
+ aPackageName = xAttrList->getValue( SwXMLBlockListToken::PACKAGE_NAME );
+ if( xAttrList->hasAttribute( SwXMLBlockListToken::UNFORMATTED_TEXT ) )
{
- if ( IsXMLToken ( aLocalName, XML_ABBREVIATED_NAME ) )
- {
- aShort = rCC.uppercase(rAttrValue);
- }
- else if ( IsXMLToken ( aLocalName, XML_NAME ) )
- {
- aLong = rAttrValue;
- }
- else if ( IsXMLToken ( aLocalName, XML_PACKAGE_NAME ) )
- {
- aPackageName = rAttrValue;
- }
- else if ( IsXMLToken ( aLocalName, XML_UNFORMATTED_TEXT ) )
- {
- if ( IsXMLToken ( rAttrValue, XML_TRUE ) )
- bTextOnly = true;
- }
+ OUString rAttrValue( xAttrList->getValue( SwXMLBlockListToken::UNFORMATTED_TEXT ) );
+ if( IsXMLToken( rAttrValue, XML_TRUE ) )
+ bTextOnly = true;
}
}
if (aShort.isEmpty() || aLong.isEmpty() || aPackageName.isEmpty())
@@ -222,56 +234,47 @@ SwXMLBlockContext::~SwXMLBlockContext ( void )
}
SwXMLTextBlockDocumentContext::SwXMLTextBlockDocumentContext(
- SwXMLTextBlockImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<
- xml::sax::XAttributeList > & ) :
- SvXMLImportContext ( rImport, nPrefix, rLocalName ),
+ SwXMLTextBlockImport& rImport,
+ sal_Int32 /*Element*/,
+ const uno::Reference< xml::sax::XFastAttributeList > & /*xAttrList*/ ) :
+ SvXMLImportContext( rImport ),
rLocalRef(rImport)
{
}
-SvXMLImportContext *SwXMLTextBlockDocumentContext::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > & xAttrList )
+uno::Reference< ::xml::sax::XFastContextHandler > SAL_CALL
+SwXMLTextBlockDocumentContext::createFastChildContext( sal_Int32 Element,
+ const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
{
- SvXMLImportContext *pContext = 0;
- if (nPrefix == XML_NAMESPACE_OFFICE &&
- IsXMLToken ( rLocalName, XML_BODY ) )
- pContext = new SwXMLTextBlockBodyContext (rLocalRef, nPrefix, rLocalName, xAttrList);
+ if ( Element == SwXMLTextBlockToken::OFFICE_BODY )
+ return new SwXMLTextBlockBodyContext( rLocalRef, Element, xAttrList );
else
- pContext = new SvXMLImportContext( rLocalRef, nPrefix, rLocalName);
- return pContext;
+ return new SvXMLImportContext( rLocalRef );
}
+
SwXMLTextBlockDocumentContext::~SwXMLTextBlockDocumentContext ( void )
{
}
SwXMLTextBlockTextContext::SwXMLTextBlockTextContext(
- SwXMLTextBlockImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<
- xml::sax::XAttributeList > & ) :
- SvXMLImportContext ( rImport, nPrefix, rLocalName ),
- rLocalRef(rImport)
+ SwXMLTextBlockImport& rImport,
+ sal_Int32 /*Element*/,
+ const uno::Reference< xml::sax::XFastAttributeList > & /*xAttrList */) :
+ SvXMLImportContext ( rImport ),
+ rLocalRef( rImport )
{
}
-SvXMLImportContext *SwXMLTextBlockTextContext::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > & xAttrList )
+uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
+SwXMLTextBlockTextContext::createFastChildContext( sal_Int32 Element,
+ const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
{
- SvXMLImportContext *pContext = 0;
- if (nPrefix == XML_NAMESPACE_TEXT &&
- IsXMLToken ( rLocalName, XML_P ) )
- pContext = new SwXMLTextBlockParContext (rLocalRef, nPrefix, rLocalName, xAttrList);
+ if ( Element == SwXMLTextBlockToken::TEXT_P )
+ return new SwXMLTextBlockParContext( rLocalRef, Element, xAttrList );
else
- pContext = new SvXMLImportContext( rLocalRef, nPrefix, rLocalName);
- return pContext;
+ return new SvXMLImportContext( rLocalRef );
}
SwXMLTextBlockTextContext::~SwXMLTextBlockTextContext ( void )
@@ -279,50 +282,46 @@ SwXMLTextBlockTextContext::~SwXMLTextBlockTextContext ( void )
}
SwXMLTextBlockBodyContext::SwXMLTextBlockBodyContext(
- SwXMLTextBlockImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<
- xml::sax::XAttributeList > & ) :
- SvXMLImportContext ( rImport, nPrefix, rLocalName ),
+ SwXMLTextBlockImport& rImport,
+ sal_Int32 /*Element*/,
+ const uno::Reference< xml::sax::XFastAttributeList > & /*xAttrList*/ ) :
+ SvXMLImportContext( rImport ),
rLocalRef(rImport)
{
}
-SvXMLImportContext *SwXMLTextBlockBodyContext::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > & xAttrList )
+uno::Reference < xml::sax::XFastContextHandler > SAL_CALL
+SwXMLTextBlockBodyContext::createFastChildContext( sal_Int32 Element,
+ const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
{
- SvXMLImportContext *pContext = 0;
- if (nPrefix == XML_NAMESPACE_OFFICE &&
- IsXMLToken ( rLocalName, XML_TEXT ) )
- pContext = new SwXMLTextBlockTextContext (rLocalRef, nPrefix, rLocalName, xAttrList);
- else if (nPrefix == XML_NAMESPACE_TEXT &&
- IsXMLToken ( rLocalName, XML_P ) )
- pContext = new SwXMLTextBlockParContext (rLocalRef, nPrefix, rLocalName, xAttrList);
+ if( Element == SwXMLTextBlockToken::OFFICE_TEXT )
+ return new SwXMLTextBlockTextContext( rLocalRef, Element, xAttrList );
+ else if( Element == SwXMLTextBlockToken::TEXT_P )
+ return new SwXMLTextBlockParContext( rLocalRef, Element, xAttrList );
else
- pContext = new SvXMLImportContext( rLocalRef, nPrefix, rLocalName);
- return pContext;
+ return new SvXMLImportContext( rLocalRef );
}
+
SwXMLTextBlockBodyContext::~SwXMLTextBlockBodyContext ( void )
{
}
+
SwXMLTextBlockParContext::SwXMLTextBlockParContext(
- SwXMLTextBlockImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<
- xml::sax::XAttributeList > & ) :
- SvXMLImportContext ( rImport, nPrefix, rLocalName ),
- rLocalRef(rImport)
+ SwXMLTextBlockImport& rImport,
+ sal_Int32 /*Element*/,
+ const uno::Reference< xml::sax::XFastAttributeList > & /*xAttrList*/ ) :
+ SvXMLImportContext( rImport ),
+ rLocalRef( rImport )
{
}
-void SwXMLTextBlockParContext::Characters( const OUString& rChars )
+void SAL_CALL SwXMLTextBlockParContext::characters( const OUString & aChars )
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
{
- rLocalRef.m_rText += rChars;
+ rLocalRef.m_rText += aChars;
}
+
SwXMLTextBlockParContext::~SwXMLTextBlockParContext ( void )
{
if (rLocalRef.bTextOnly)
@@ -335,20 +334,12 @@ SwXMLTextBlockParContext::~SwXMLTextBlockParContext ( void )
}
// SwXMLBlockListImport //////////////////////////////
-
-sal_Char const sXML_np__block_list[] = "_block-list";
-sal_Char const sXML_np__office[] = "_ooffice";
-sal_Char const sXML_np__text[] = "_otext";
-
SwXMLBlockListImport::SwXMLBlockListImport(
const uno::Reference< uno::XComponentContext > xContext,
SwXMLTextBlocks &rBlocks )
: SvXMLImport( xContext, "", 0 ),
rBlockList (rBlocks)
{
- GetNamespaceMap().Add( OUString ( sXML_np__block_list ),
- GetXMLToken ( XML_N_BLOCK_LIST ),
- XML_NAMESPACE_BLOCKLIST );
}
SwXMLBlockListImport::~SwXMLBlockListImport ( void )
@@ -356,19 +347,13 @@ SwXMLBlockListImport::~SwXMLBlockListImport ( void )
{
}
-SvXMLImportContext *SwXMLBlockListImport::CreateContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > & xAttrList )
+SvXMLImportContext* SwXMLBlockListImport::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 SwXMLBlockListContext( *this, nPrefix, rLocalName,
- xAttrList );
+ if( Element == SwXMLBlockListToken::BLOCK_LIST )
+ return new SwXMLBlockListContext( *this, Element, xAttrList );
else
- pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
- return pContext;
+ return SvXMLImport::CreateFastContext( Element, xAttrList );
}
SwXMLTextBlockImport::SwXMLTextBlockImport(
@@ -381,12 +366,6 @@ SwXMLTextBlockImport::SwXMLTextBlockImport(
bTextOnly ( bNewTextOnly ),
m_rText ( rNewText )
{
- GetNamespaceMap().Add( OUString( sXML_np__office ),
- GetXMLToken(XML_N_OFFICE_OOO),
- XML_NAMESPACE_OFFICE );
- GetNamespaceMap().Add( OUString( sXML_np__text ),
- GetXMLToken(XML_N_TEXT_OOO),
- XML_NAMESPACE_TEXT );
}
SwXMLTextBlockImport::~SwXMLTextBlockImport ( void )
@@ -394,19 +373,16 @@ SwXMLTextBlockImport::~SwXMLTextBlockImport ( void )
{
}
-SvXMLImportContext *SwXMLTextBlockImport::CreateContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > & xAttrList )
+SvXMLImportContext* SwXMLTextBlockImport::CreateFastContext( sal_Int32 Element,
+ const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
{
- SvXMLImportContext *pContext = 0;
- if( XML_NAMESPACE_OFFICE == nPrefix &&
- IsXMLToken ( rLocalName, bTextOnly ? XML_DOCUMENT : XML_DOCUMENT_CONTENT ) )
- pContext = new SwXMLTextBlockDocumentContext( *this, nPrefix, rLocalName, xAttrList );
+ if( Element == SwXMLTextBlockToken::OFFICE_DOCUMENT ||
+ Element == SwXMLTextBlockToken::OFFICE_DOCUMENT_CONTENT )
+ return new SwXMLTextBlockDocumentContext( *this, Element, xAttrList );
else
- pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
- return pContext;
+ return SvXMLImport::CreateFastContext( Element, xAttrList );
}
+
void SAL_CALL SwXMLTextBlockImport::endDocument(void)
throw( xml::sax::SAXException, uno::RuntimeException, std::exception )
{
diff --git a/sw/source/core/swg/SwXMLTextBlocks1.cxx b/sw/source/core/swg/SwXMLTextBlocks1.cxx
index bbae9404a150..1bd1be13f620 100644
--- a/sw/source/core/swg/SwXMLTextBlocks1.cxx
+++ b/sw/source/core/swg/SwXMLTextBlocks1.cxx
@@ -27,6 +27,8 @@
#include <com/sun/star/xml/sax/InputSource.hpp>
#include <com/sun/star/io/XActiveDataSource.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/document/XStorageBasedDocument.hpp>
#include <doc.hxx>
@@ -35,6 +37,7 @@
#include <SwXMLTextBlocks.hxx>
#include <SwXMLBlockImport.hxx>
#include <SwXMLBlockExport.hxx>
+#include <xmloff/xmlnmspe.hxx>
#include <swevent.hxx>
#include <swerror.h>
@@ -43,6 +46,8 @@ const char XMLN_BLOCKLIST[] = "BlockList.xml";
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::container;
+using namespace css::xml::sax;
+using namespace xmloff::token;
using ::xmloff::token::XML_BLOCK_LIST;
using ::xmloff::token::XML_UNFORMATTED_TEXT;
@@ -101,11 +106,45 @@ sal_uLong SwXMLTextBlocks::GetDoc( sal_uInt16 nIdx )
aParserInput.aInputStream = xStream->getInputStream();
// get filter
- uno::Reference< xml::sax::XDocumentHandler > xFilter = new SwXMLTextBlockImport( xContext, *this, aCur, true );
+ // uno::Reference< xml::sax::XDocumentHandler > xFilter = new SwXMLTextBlockImport( *this, aCur, sal_True );
+ uno::Reference< xml::sax::XFastDocumentHandler > xFilter = new SwXMLTextBlockImport( xContext, *this, aCur, true );
+ uno::Reference< xml::sax::XFastTokenHandler > xTokenHandler = new SwXMLTextBlockTokenHandler();
// 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);
+ xParser->setFastDocumentHandler( xFilter );
+ xParser->setTokenHandler( xTokenHandler );
+
+ // all namespaces are mentioned in content.xml but only a few of them are handled
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:office:1.0", FastToken::NAMESPACE | XML_NAMESPACE_OFFICE );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:style:1.0", FastToken::NAMESPACE | XML_NAMESPACE_STYLE );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:text:1.0", FastToken::NAMESPACE | XML_NAMESPACE_TEXT );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:table:1.0", FastToken::NAMESPACE | XML_NAMESPACE_TABLE );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0", FastToken::NAMESPACE | XML_NAMESPACE_DRAW );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0", FastToken::NAMESPACE | XML_NAMESPACE_FO );
+ xParser->registerNamespace( "http://www.w3.org/1999/xlink", FastToken::NAMESPACE | XML_NAMESPACE_XLINK );
+ xParser->registerNamespace( "http://purl.org/dc/elements/1.1/", FastToken::NAMESPACE | XML_NAMESPACE_DC );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:meta:1.0", FastToken::NAMESPACE | XML_NAMESPACE_META );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0", FastToken::NAMESPACE | XML_NAMESPACE_NUMBER );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0", FastToken::NAMESPACE | XML_NAMESPACE_SVG );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:chart:1.0", FastToken::NAMESPACE | XML_NAMESPACE_CHART );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0", FastToken::NAMESPACE | XML_NAMESPACE_DR3D );
+ xParser->registerNamespace( "http://www.w3.org/1998/Math/MathML", FastToken::NAMESPACE | XML_NAMESPACE_MATH );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:form:1.0", FastToken::NAMESPACE | XML_NAMESPACE_FORM );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:script:1.0", FastToken::NAMESPACE | XML_NAMESPACE_SCRIPT );
+ xParser->registerNamespace( "http://openoffice.org/2004/office", FastToken::NAMESPACE | XML_NAMESPACE_OOO );
+ xParser->registerNamespace( "http://openoffice.org/2004/writer", FastToken::NAMESPACE | XML_NAMESPACE_OOOW );
+ xParser->registerNamespace( "http://openoffice.org/2004/calc", FastToken::NAMESPACE | XML_NAMESPACE_OOOC );
+ xParser->registerNamespace( "http://www.w3.org/2001/xml-events", FastToken::NAMESPACE | XML_NAMESPACE_DOM );
+ xParser->registerNamespace( "http://openoffice.org/2005/report", FastToken::NAMESPACE | XML_NAMESPACE_REPORT );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:of:1.2", FastToken::NAMESPACE | XML_NAMESPACE_OF );
+ xParser->registerNamespace( "http://www.w3.org/1999/xhtml", FastToken::NAMESPACE | XML_NAMESPACE_XHTML );
+ xParser->registerNamespace( "http://www.w3.org/2003/g/data-view#", FastToken::NAMESPACE | XML_NAMESPACE_GRDDL );
+ xParser->registerNamespace( "http://openoffice.org/2009/office", FastToken::NAMESPACE | XML_NAMESPACE_OFFICE_EXT );
+ xParser->registerNamespace( "http://openoffice.org/2009/table", FastToken::NAMESPACE | XML_NAMESPACE_TABLE_EXT );
+ xParser->registerNamespace( "http://openoffice.org/2009/draw", FastToken::NAMESPACE | XML_NAMESPACE_DRAW_EXT );
+ xParser->registerNamespace( "urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0", FastToken::NAMESPACE | XML_NAMESPACE_CALC_EXT );
+ xParser->registerNamespace( "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0", FastToken::NAMESPACE | XML_NAMESPACE_LO_EXT );
// parse
try
@@ -291,11 +330,44 @@ sal_uLong SwXMLTextBlocks::GetBlockText( const OUString& rShort, OUString& rText
// get filter
// #110680#
// uno::Reference< xml::sax::XDocumentHandler > xFilter = new SwXMLTextBlockImport( *this, rText, bTextOnly );
- uno::Reference< xml::sax::XDocumentHandler > xFilter = new SwXMLTextBlockImport( xContext, *this, rText, bTextOnly );
+ uno::Reference< xml::sax::XFastDocumentHandler > xFilter = new SwXMLTextBlockImport( xContext, *this, rText, bTextOnly );
+ uno::Reference< xml::sax::XFastTokenHandler > xTokenHandler = new SwXMLTextBlockTokenHandler();
// 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);
+ xParser->setFastDocumentHandler( xFilter );
+ xParser->setTokenHandler( xTokenHandler );
+ // all namespaces are mentioned in content.xml but only a few of them are handled
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:office:1.0", FastToken::NAMESPACE | XML_NAMESPACE_OFFICE );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:style:1.0", FastToken::NAMESPACE | XML_NAMESPACE_STYLE );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:text:1.0", FastToken::NAMESPACE | XML_NAMESPACE_TEXT );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:table:1.0", FastToken::NAMESPACE | XML_NAMESPACE_TABLE );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0", FastToken::NAMESPACE | XML_NAMESPACE_DRAW );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0", FastToken::NAMESPACE | XML_NAMESPACE_FO );
+ xParser->registerNamespace( "http://www.w3.org/1999/xlink", FastToken::NAMESPACE | XML_NAMESPACE_XLINK );
+ xParser->registerNamespace( "http://purl.org/dc/elements/1.1/", FastToken::NAMESPACE | XML_NAMESPACE_DC );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:meta:1.0", FastToken::NAMESPACE | XML_NAMESPACE_META );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0", FastToken::NAMESPACE | XML_NAMESPACE_NUMBER );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0", FastToken::NAMESPACE | XML_NAMESPACE_SVG );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:chart:1.0", FastToken::NAMESPACE | XML_NAMESPACE_CHART );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0", FastToken::NAMESPACE | XML_NAMESPACE_DR3D );
+ xParser->registerNamespace( "http://www.w3.org/1998/Math/MathML", FastToken::NAMESPACE | XML_NAMESPACE_MATH );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:form:1.0", FastToken::NAMESPACE | XML_NAMESPACE_FORM );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:script:1.0", FastToken::NAMESPACE | XML_NAMESPACE_SCRIPT );
+ xParser->registerNamespace( "http://openoffice.org/2004/office", FastToken::NAMESPACE | XML_NAMESPACE_OOO );
+ xParser->registerNamespace( "http://openoffice.org/2004/writer", FastToken::NAMESPACE | XML_NAMESPACE_OOOW );
+ xParser->registerNamespace( "http://openoffice.org/2004/calc", FastToken::NAMESPACE | XML_NAMESPACE_OOOC );
+ xParser->registerNamespace( "http://www.w3.org/2001/xml-events", FastToken::NAMESPACE | XML_NAMESPACE_DOM );
+ xParser->registerNamespace( "http://openoffice.org/2005/report", FastToken::NAMESPACE | XML_NAMESPACE_REPORT );
+ xParser->registerNamespace( "urn:oasis:names:tc:opendocument:xmlns:of:1.2", FastToken::NAMESPACE | XML_NAMESPACE_OF );
+ xParser->registerNamespace( "http://www.w3.org/1999/xhtml", FastToken::NAMESPACE | XML_NAMESPACE_XHTML );
+ xParser->registerNamespace( "http://www.w3.org/2003/g/data-view#", FastToken::NAMESPACE | XML_NAMESPACE_GRDDL );
+ xParser->registerNamespace( "http://openoffice.org/2009/office", FastToken::NAMESPACE | XML_NAMESPACE_OFFICE_EXT );
+ xParser->registerNamespace( "http://openoffice.org/2009/table", FastToken::NAMESPACE | XML_NAMESPACE_TABLE_EXT );
+ xParser->registerNamespace( "http://openoffice.org/2009/draw", FastToken::NAMESPACE | XML_NAMESPACE_DRAW_EXT );
+ xParser->registerNamespace( "urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0", FastToken::NAMESPACE | XML_NAMESPACE_CALC_EXT );
+ xParser->registerNamespace( "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0", FastToken::NAMESPACE | XML_NAMESPACE_LO_EXT );
+ xParser->registerNamespace( "http://www.w3.org/TR/css3-text/", FastToken::NAMESPACE | XML_NAMESPACE_CSS3TEXT );
// parse
try
@@ -418,11 +490,14 @@ void SwXMLTextBlocks::ReadInfo( void )
aParserInput.aInputStream = xDocStream->getInputStream();
// get filter
- uno::Reference< xml::sax::XDocumentHandler > xFilter = new SwXMLBlockListImport( xContext, *this );
+ uno::Reference< xml::sax::XFastDocumentHandler > xFilter = new SwXMLBlockListImport( xContext, *this );
+ uno::Reference< xml::sax::XFastTokenHandler > xTokenHandler = new SwXMLBlockListTokenHandler();
// 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);
+ xParser->setFastDocumentHandler( xFilter );
+ xParser->registerNamespace( "http://openoffice.org/2001/block-list", FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST );
+ xParser->setTokenHandler( xTokenHandler );
// parse
try
diff --git a/sw/source/core/swg/TextBlockTokens.txt b/sw/source/core/swg/TextBlockTokens.txt
new file mode 100644
index 000000000000..8698704fcb9a
--- /dev/null
+++ b/sw/source/core/swg/TextBlockTokens.txt
@@ -0,0 +1,5 @@
+body
+text
+document
+document-content
+p