summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-03-02 17:50:15 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-03-02 17:56:15 +0100
commit09f27e518bdec21774ff62d7c59ed782bc5c20b1 (patch)
tree6e0d0f6672df9e3024dcfd55b9aaca1167bec44c
parent54ebae0eae8829a9325170002120b984e8934cdf (diff)
fix strict namespace list generation
The two perl scripts were apparently only generating the same order by luck. It did not work on all systems. Change-Id: Ib83ee5c6572d3bae2e2ac1846850bd65303e7d43
-rw-r--r--oox/CustomTarget_generated.mk7
-rw-r--r--oox/source/token/namespacemap.cxx2
-rw-r--r--oox/source/token/namespaces-strict.hxx.head27
-rw-r--r--oox/source/token/namespaces-strict.hxx.tail62
-rw-r--r--oox/source/token/namespaces-strict.pl70
-rw-r--r--oox/source/token/namespaces.pl30
6 files changed, 33 insertions, 165 deletions
diff --git a/oox/CustomTarget_generated.mk b/oox/CustomTarget_generated.mk
index 89ac97d40f28..14789d63b53d 100644
--- a/oox/CustomTarget_generated.mk
+++ b/oox/CustomTarget_generated.mk
@@ -27,7 +27,7 @@ $(oox_INC)/tokenhash.inc : $(oox_MISC)/tokenhash.gperf
$(GPERF) --compare-strncmp $< | sed -e 's/(char\*)0/(char\*)0, 0/g' | grep -v '^#line' > $@
define oox_GenTarget
-$(oox_MISC)/$(2)ids.inc $(oox_INC)/$(2)names.inc $(if $(3),$(oox_MISC)/$(3)) : \
+$(oox_MISC)/$(2)ids.inc $(oox_INC)/$(2)names.inc $(if $(3),$(oox_MISC)/$(3)) $(if $(4),$(oox_INC)/$(4)names.inc) : \
$(oox_GENHEADERPATH)/$(1).hxx
@touch $$@
@@ -37,13 +37,13 @@ $(oox_GENHEADERPATH)/$(1).hxx : $(oox_SRC)/$(1).pl $(oox_SRC)/$(1).txt \
mkdir -p $(oox_MISC) $(oox_INC) $(oox_GENHEADERPATH)
perl $(oox_SRC)/$(1).pl $(oox_SRC)/$(1).txt $(oox_MISC)/$(2)ids.inc \
$(oox_INC)/$(2)names.inc $(if $(3),$(oox_MISC)/$(3)) \
+ $(if $(4),$(oox_SRC)/$(4).txt $(oox_INC)/$(4)names.inc) \
&& cat $(oox_SRC)/$(1).hxx.head $(oox_MISC)/$(2)ids.inc \
$(oox_SRC)/$(1).hxx.tail > $(oox_GENHEADERPATH)/$(1).hxx \
&& touch $$@
endef
-$(eval $(call oox_GenTarget,namespaces,namespace,namespaces.txt))
-$(eval $(call oox_GenTarget,namespaces-strict,namespace-strict,namespaces-strict.txt))
+$(eval $(call oox_GenTarget,namespaces,namespace,namespaces.txt,namespaces-strict))
$(eval $(call oox_GenTarget,properties,property,))
$(eval $(call oox_GenTarget,tokens,token,tokenhash.gperf))
@@ -55,7 +55,6 @@ $(call gb_CustomTarget_get_target,oox/generated) : \
$(oox_INC)/propertynames.inc \
$(oox_GENHEADERPATH)/tokens.hxx \
$(oox_GENHEADERPATH)/namespaces.hxx \
- $(oox_GENHEADERPATH)/namespaces-strict.hxx \
$(oox_GENHEADERPATH)/properties.hxx \
$(oox_MISC)/namespaces.txt \
diff --git a/oox/source/token/namespacemap.cxx b/oox/source/token/namespacemap.cxx
index 65487da70308..11567fe16d3e 100644
--- a/oox/source/token/namespacemap.cxx
+++ b/oox/source/token/namespacemap.cxx
@@ -35,7 +35,7 @@ NamespaceMap::NamespaceMap()
static const struct NamespaceStrictUrl { sal_Int32 mnId; const sal_Char* mpcUrl; } spNamespaceStrictUrls[] =
{
// include auto-generated C array with namespace URLs as C strings
-#include "namespace-strictnames.inc"
+#include "namespaces-strictnames.inc"
{ -1, "" }
};
diff --git a/oox/source/token/namespaces-strict.hxx.head b/oox/source/token/namespaces-strict.hxx.head
deleted file mode 100644
index d00a3804a197..000000000000
--- a/oox/source/token/namespaces-strict.hxx.head
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef OOX_TOKEN_NAMESPACES_HXX
-#define OOX_TOKEN_NAMESPACES_HXX
-
-#include <sal/types.h>
-
-namespace oox {
-
-// ============================================================================
-
diff --git a/oox/source/token/namespaces-strict.hxx.tail b/oox/source/token/namespaces-strict.hxx.tail
deleted file mode 100644
index e0baeae0a315..000000000000
--- a/oox/source/token/namespaces-strict.hxx.tail
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-// ============================================================================
-
-const sal_Int32 TOKEN_MASK = static_cast< sal_Int32 >( (1 << NMSP_SHIFT) - 1 );
-const sal_Int32 NMSP_MASK = static_cast< sal_Int32 >( SAL_MAX_INT32 & ~TOKEN_MASK );
-
-/** Returns the raw token identifier without namespace of the passed token. */
-inline sal_Int32 getBaseToken( sal_Int32 nToken ) { return nToken & TOKEN_MASK; }
-
-/** Returns the namespace without token identifier of the passed token. */
-inline sal_Int32 getNamespace( sal_Int32 nToken ) { return nToken & NMSP_MASK; }
-
-
-// defines for tokens with specific namespaces
-#define OOX_TOKEN( namespace, token ) (::oox::NMSP_##namespace | ::oox::XML_##token)
-
-#define A_TOKEN( token ) OOX_TOKEN( dml, token )
-#define AX_TOKEN( token ) OOX_TOKEN( ax, token )
-#define C_TOKEN( token ) OOX_TOKEN( dmlChart, token )
-#define CDR_TOKEN( token ) OOX_TOKEN( dmlChartDr, token )
-#define DGM_TOKEN( token ) OOX_TOKEN( dmlDiagram, token )
-#define MCE_TOKEN( token ) OOX_TOKEN( mce, token)
-#define O_TOKEN( token ) OOX_TOKEN( vmlOffice, token )
-#define PC_TOKEN( token ) OOX_TOKEN( packageContentTypes, token )
-#define PPT_TOKEN( token ) OOX_TOKEN( ppt, token )
-#define PR_TOKEN( token ) OOX_TOKEN( packageRel, token )
-#define R_TOKEN( token ) OOX_TOKEN( officeRel, token )
-#define VML_TOKEN( token ) OOX_TOKEN( vml, token )
-#define VMLX_TOKEN( token ) OOX_TOKEN( vmlExcel, token )
-#define XDR_TOKEN( token ) OOX_TOKEN( dmlSpreadDr, token )
-#define XLS_TOKEN( token ) OOX_TOKEN( xls, token )
-#define XLS_EXT_TOKEN( token ) OOX_TOKEN( xlsExtLst, token )
-#define XM_TOKEN( token ) OOX_TOKEN( xm, token )
-#define XML_TOKEN( token ) OOX_TOKEN( xml, token )
-#define VMLPPT_TOKEN( token ) OOX_TOKEN( vmlPowerpoint, token )
-#define DSP_TOKEN( token ) OOX_TOKEN( dsp, token )
-#define LC_TOKEN( token ) OOX_TOKEN( dmlLockedCanvas, token )
-#define WPS_TOKEN( token ) OOX_TOKEN( wps, token )
-#define WPG_TOKEN( token ) OOX_TOKEN( wpg, token )
-
-// ============================================================================
-
-} // namespace oox
-
-#endif
diff --git a/oox/source/token/namespaces-strict.pl b/oox/source/token/namespaces-strict.pl
deleted file mode 100644
index 225b8f7f0ef2..000000000000
--- a/oox/source/token/namespaces-strict.pl
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# 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/.
-#
-# This file incorporates work covered by the following license notice:
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed
-# with this work for additional information regarding copyright
-# ownership. The ASF licenses this file to you under the Apache
-# License, Version 2.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.apache.org/licenses/LICENSE-2.0 .
-#
-
-$ARGV0 = shift @ARGV;
-$ARGV1 = shift @ARGV;
-$ARGV2 = shift @ARGV;
-$ARGV3 = shift @ARGV;
-
-# parse input file
-
-open( INFILE, $ARGV0 ) or die "cannot open input file: $!";
-my %namespaces;
-while( <INFILE> )
-{
- # trim newline
- chomp( $_ );
- # trim leading/trailing whitespace
- $_ =~ s/^\s*//g;
- $_ =~ s/\s*$//g;
- # trim comments
- $_ =~ s/^#.*//;
- # skip empty lines
- if( $_ )
- {
- # check for valid characters
- $_ =~ /^([a-zA-Z][a-zA-Z0-9]*)\s+([a-zA-Z0-9-.:\/]+)\s*$/ or die "Error: invalid character in input data";
- $namespaces{$1} = $2;
- }
-}
-close( INFILE );
-
-# generate output files
-
-open( IDFILE, ">$ARGV1" ) or die "Error: cannot open output file: $!";
-open( NAMEFILE, ">$ARGV2" ) or die "Error: cannot open output file: $!";
-open( TXTFILE, ">$ARGV3" ) or die "Error: cannot open output file: $!";
-
-# number of bits to shift the namespace identifier
-$shift = 16;
-
-print ( IDFILE "const size_t NMSP_SHIFT = $shift;\n" );
-
-$i = 1;
-foreach( keys( %namespaces ) )
-{
- print( IDFILE "const sal_Int32 NMSP_$_ = $i << NMSP_SHIFT;\n" );
- $id = $i << $shift;
- print( NAMEFILE "{ $id, \"$namespaces{$_}\" },\n" );
- print( TXTFILE "$id $_ $namespaces{$_}\n" );
- ++$i;
-}
-
-close( IDFILE );
-close( nameFILE );
-close( TXTFILE );
diff --git a/oox/source/token/namespaces.pl b/oox/source/token/namespaces.pl
index 225b8f7f0ef2..b7f6083446c5 100644
--- a/oox/source/token/namespaces.pl
+++ b/oox/source/token/namespaces.pl
@@ -20,6 +20,8 @@ $ARGV0 = shift @ARGV;
$ARGV1 = shift @ARGV;
$ARGV2 = shift @ARGV;
$ARGV3 = shift @ARGV;
+$ARGV4 = shift @ARGV;
+$ARGV5 = shift @ARGV;
# parse input file
@@ -44,11 +46,35 @@ while( <INFILE> )
}
close( INFILE );
+# OOXML strict namespaces
+
+open( INFILE_STRICT, $ARGV4 ) or die "cannot open input file: $!";
+my %namespaces_strict;
+while( <INFILE_STRICT> )
+{
+ # trim newline
+ chomp( $_ );
+ # trim leading/trailing whitespace
+ $_ =~ s/^\s*//g;
+ $_ =~ s/\s*$//g;
+ # trim comments
+ $_ =~ s/^#.*//;
+ # skip empty lines
+ if( $_ )
+ {
+ # check for valid characters
+ $_ =~ /^([a-zA-Z][a-zA-Z0-9]*)\s+([a-zA-Z0-9-.:\/]+)\s*$/ or die "Error: invalid character in input data";
+ $namespaces_strict{$1} = $2;
+ }
+}
+close( INFILE_STRICT );
+
# generate output files
open( IDFILE, ">$ARGV1" ) or die "Error: cannot open output file: $!";
open( NAMEFILE, ">$ARGV2" ) or die "Error: cannot open output file: $!";
open( TXTFILE, ">$ARGV3" ) or die "Error: cannot open output file: $!";
+open( NAMEFILE_STRICT, ">$ARGV5" ) or die "Error: cannot open output file: $!";
# number of bits to shift the namespace identifier
$shift = 16;
@@ -61,10 +87,12 @@ foreach( keys( %namespaces ) )
print( IDFILE "const sal_Int32 NMSP_$_ = $i << NMSP_SHIFT;\n" );
$id = $i << $shift;
print( NAMEFILE "{ $id, \"$namespaces{$_}\" },\n" );
+ print( NAMEFILE_STRICT "{ $id, \"$namespaces_strict{$_}\" },\n" );
print( TXTFILE "$id $_ $namespaces{$_}\n" );
++$i;
}
close( IDFILE );
-close( nameFILE );
+close( NAMEFILE );
+close( NAMEFILE_STRICT );
close( TXTFILE );