Kaydet (Commit) 09f27e51 authored tarafından Markus Mohrhard's avatar Markus Mohrhard Kaydeden (comit) Markus Mohrhard

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
üst 54ebae0e
......@@ -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 \
......
......@@ -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, "" }
};
......
/*
* 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 {
// ============================================================================
/*
* 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
#
# 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 );
......@@ -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 );
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