Re: [Libreoffice-commits] core.git: sw/CustomTarget_generated.mk sw/Library_sw.mk sw/Module_sw.mk sw/source

2014-12-11 Thread Miklos Vajna
Hi Daniel,

On Wed, Dec 10, 2014 at 10:33:01AM -0800, Daniel Sikeler 
d.sikele...@gmail.com wrote:
  sw/CustomTarget_generated.mk|   34 ++
  sw/Library_sw.mk|1 
  sw/Module_sw.mk |1 
  sw/source/core/inc/SwXMLBlockImport.hxx |   76 +-
  sw/source/core/swg/BlockListTokens.txt  |7 
  sw/source/core/swg/SwXMLBlockImport.cxx |  404 
 +++-
  sw/source/core/swg/SwXMLTextBlocks1.cxx |   37 ++
  sw/source/core/swg/TextBlockTokens.txt  |5 

For OOXML, we generate a single token hash in oox and use that for
Writer, Calc and Impress. I wonder if the same would be possible for
xmloff-based importers as well: generate a single hash in xmloff, and
let all importers use that. In the long run, this could save significant
space due to not duplicating the tokens in different applications -- see
http://vmiklos.hu/blog/ooxmltok.html for the exact numbers in the OOXML
case.

It would be great to not fall into that trap for ODF: could you please
consider moving the token handler (and code generation) to xmloff from
sw?

Or if you say that even if it's based on xmloff, it's an independent
format with a few tokens only -- then why bother with code generation
and perfect hashes? :-)

Thanks,

Miklos


signature.asc
Description: Digital signature
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice-commits] core.git: sw/CustomTarget_generated.mk sw/Library_sw.mk sw/Module_sw.mk sw/source

2014-12-11 Thread Miklos Vajna
On Thu, Dec 11, 2014 at 01:57:06PM +0100, Daniel Sikeler 
d.sikele...@gmail.com wrote:
 I've already thought that it would cause a lot of duplicated code.
 
 So I'll try to move it to xmloff and use the code in oox as a
 pattern for xmloff. What came to my mind now is, that i would
 duplicate the code for the fasttokenhandler, because it only calls
 the methods from TokenMap. So probably it would be good to also move
 the fasttokenhandler somewhere else. And create a new base class for
 TokenMaps so that the fasttokenhandler can work with different
 TokenMaps. What do you think?

I would suggest doing it in two steps: first make sure that code that is
interesting for ODF filters is in xmloff, not sw (before a duplicate in
sc or sd appears), then indeed, if you see common functionality in
xmloff and oox regarding the token handler, then that can be abstracted
to a base class. Maybe the filter module would be a good place to store
that base class?


signature.asc
Description: Digital signature
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice-commits] core.git: sw/CustomTarget_generated.mk sw/Library_sw.mk sw/Module_sw.mk sw/source

2014-12-10 Thread Daniel Sikeler
 sw/CustomTarget_generated.mk|   34 ++
 sw/Library_sw.mk|1 
 sw/Module_sw.mk |1 
 sw/source/core/inc/SwXMLBlockImport.hxx |   76 +-
 sw/source/core/swg/BlockListTokens.txt  |7 
 sw/source/core/swg/SwXMLBlockImport.cxx |  404 +++-
 sw/source/core/swg/SwXMLTextBlocks1.cxx |   37 ++
 sw/source/core/swg/TextBlockTokens.txt  |5 
 8 files changed, 340 insertions(+), 225 deletions(-)

New commits:
commit c2c0989794d5a4724da8b8880559764bffd059ec
Author: Daniel Sikeler d.sikele...@gmail.com
Date:   Mon Nov 10 12:23:12 2014 +

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

This is corrected version of c1e90457d2ecc6e1171b7a296ab8bd05821e39e6
(Also pushing again follow-up c940d4d30673dc02ea34b5e60a4a8140648a0dba
loplugin:saloverride and 5f0f3d4e91e9eb1d1f60b0cd073e7bbd8ea38c29
Work around -Werror,-Wdeprecated-register)
The commits were reverted in 7ef4457b9fc06b5c25c607d7e0149f45c7015b10

Change-Id: I08cd852fa751f98fd0ac6a55dda22f82a869b4d8

diff --git a/sw/CustomTarget_generated.mk b/sw/CustomTarget_generated.mk
new file mode 100644
index 000..f8244d2
--- /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 1b16def..f9a4e03 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 a7a31ef..bf110be 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 ac166fd..9c4e77c 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
-

[Libreoffice-commits] core.git: sw/CustomTarget_generated.mk sw/Library_sw.mk sw/Module_sw.mk sw/source

2014-12-05 Thread Stephan Bergmann
 sw/CustomTarget_generated.mk|   34 --
 sw/Library_sw.mk|1 
 sw/Module_sw.mk |1 
 sw/source/core/inc/SwXMLBlockImport.hxx |   76 --
 sw/source/core/swg/BlockListTokens.txt  |7 
 sw/source/core/swg/SwXMLBlockImport.cxx |  404 
 sw/source/core/swg/SwXMLTextBlocks1.cxx |   93 ---
 sw/source/core/swg/TextBlockTokens.txt  |5 
 8 files changed, 225 insertions(+), 396 deletions(-)

New commits:
commit 7ef4457b9fc06b5c25c607d7e0149f45c7015b10
Author: Stephan Bergmann sberg...@redhat.com
Date:   Fri Dec 5 14:22:55 2014 +0100

Revert fdo#80403: Writer specific AutoCorr use FastParser

This reverts commit c1e90457d2ecc6e1171b7a296ab8bd05821e39e6 (plus follow-up
c940d4d30673dc02ea34b5e60a4a8140648a0dba loplugin:saloverride and
5f0f3d4e91e9eb1d1f60b0cd073e7bbd8ea38c29 Work around
-Werror,-Wdeprecated-register), it broke JunitTest_sw_unoapi.

Change-Id: I21499f8a7810eef637bb51a30380ae60b3d915cd

diff --git a/sw/CustomTarget_generated.mk b/sw/CustomTarget_generated.mk
deleted file mode 100644
index 2752799..000
--- a/sw/CustomTarget_generated.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-# -*- 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 2816b05..c475315 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -36,7 +36,6 @@ $(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 bf110be..a7a31ef 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -21,7 +21,6 @@ $(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 9c4e77c..ac166fd 100644
--- a/sw/source/core/inc/SwXMLBlockImport.hxx
+++ b/sw/source/core/inc/SwXMLBlockImport.hxx
@@ -21,14 +21,6 @@
 #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
@@ -39,8 +31,10 @@ 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* CreateFastContext( sal_Int32 Element,
-const css::uno::Reference css::xml::sax::XFastAttributeList   
xAttrList ) SAL_OVERRIDE;
+virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
+  const OUString rLocalName,
+  const ::com::sun::star::uno::Reference
+::com::sun::star::xml::sax::XAttributeList   xAttrList ) 
SAL_OVERRIDE;
 
 public:
 SwXMLBlockListImport(
@@ -63,8 +57,10 @@ private:
 protected:
 // This method is called after the namespace map has 

[Libreoffice-commits] core.git: sw/CustomTarget_generated.mk sw/Library_sw.mk sw/Module_sw.mk sw/source

2014-12-04 Thread Daniel Sikeler
 sw/CustomTarget_generated.mk|   34 ++
 sw/Library_sw.mk|1 
 sw/Module_sw.mk |1 
 sw/source/core/inc/SwXMLBlockImport.hxx |   76 +-
 sw/source/core/swg/BlockListTokens.txt  |7 
 sw/source/core/swg/SwXMLBlockImport.cxx |  392 +++-
 sw/source/core/swg/SwXMLTextBlocks1.cxx |   93 ++-
 sw/source/core/swg/TextBlockTokens.txt  |5 
 8 files changed, 384 insertions(+), 225 deletions(-)

New commits:
commit c1e90457d2ecc6e1171b7a296ab8bd05821e39e6
Author: Daniel Sikeler d.sikele...@gmail.com
Date:   Mon Nov 10 12:23:12 2014 +

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.me...@collabora.com
Tested-by: Michael Meeks michael.me...@collabora.com

diff --git a/sw/CustomTarget_generated.mk b/sw/CustomTarget_generated.mk
new file mode 100644
index 000..2752799
--- /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 c475315..2816b05 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 a7a31ef..bf110be 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 ac166fd..e64b86b 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