xref: /trunk/main/sw/inc/poolfmt.awk (revision cdf0e10c)
1*cdf0e10cSrcweir#*************************************************************************
2*cdf0e10cSrcweir#
3*cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir#
5*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir#
7*cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir#
9*cdf0e10cSrcweir# This file is part of OpenOffice.org.
10*cdf0e10cSrcweir#
11*cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir# only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir#
15*cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir#
21*cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir# version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir# <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir# for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir#
26*cdf0e10cSrcweir#*************************************************************************
27*cdf0e10cSrcweir
28*cdf0e10cSrcweir#
29*cdf0e10cSrcweir# Dieses awk-script generiert ein cxx-file, das alle PoolIds der Vorlage dumpt.
30*cdf0e10cSrcweir# wird fuer den HelpPI gebraucht.
31*cdf0e10cSrcweir# Aufruf:  awk -f poolid.awk poolfmt.hxx > poolid.cxx
32*cdf0e10cSrcweir#          cl poolid.cxx
33*cdf0e10cSrcweir#          poolid.exe > ???.hrc
34*cdf0e10cSrcweir#
35*cdf0e10cSrcweir
36*cdf0e10cSrcweirfunction Header() {
37*cdf0e10cSrcweir    print "// This is an outputfile of an awk-script: $Workfile:   poolfmt.awk  $"
38*cdf0e10cSrcweir    print "#include <solar.h> "
39*cdf0e10cSrcweir    print
40*cdf0e10cSrcweir    print  "#include <stdio.h>"
41*cdf0e10cSrcweir    print  "#include <stdlib.h>"
42*cdf0e10cSrcweir    print
43*cdf0e10cSrcweir    print  "#pragma hdrstop"
44*cdf0e10cSrcweir    print
45*cdf0e10cSrcweir    print "#include <iostream.hxx> "
46*cdf0e10cSrcweir    print "#include \"poolfmt.hxx\""
47*cdf0e10cSrcweir    print
48*cdf0e10cSrcweir}
49*cdf0e10cSrcweir
50*cdf0e10cSrcweirfunction Main() {
51*cdf0e10cSrcweir	print
52*cdf0e10cSrcweir    print  "void main( int , char *[] ) {"
53*cdf0e10cSrcweir    sStr = "#define"
54*cdf0e10cSrcweir    print  "    int nSize = (sizeof(ppPoolIds) / sizeof(PoolFmtIds)) - 1;"
55*cdf0e10cSrcweir    print  "    for( int n = 0; n < nSize; n++ )"
56*cdf0e10cSrcweir    print  "        printf( \"" sStr " %s\\t%8d\\n\", ppPoolIds[ n ].pStr, ppPoolIds[ n ].nId );"
57*cdf0e10cSrcweir    print  "}"
58*cdf0e10cSrcweir}
59*cdf0e10cSrcweir
60*cdf0e10cSrcweirfunction TableHead() {
61*cdf0e10cSrcweir	print
62*cdf0e10cSrcweir    print "struct PoolFmtIds { int nId; const char* pStr; };"
63*cdf0e10cSrcweir    print "static PoolFmtIds ppPoolIds[] = {"
64*cdf0e10cSrcweir}
65*cdf0e10cSrcweir
66*cdf0e10cSrcweirfunction TableTail() {
67*cdf0e10cSrcweir    print  " 0, \"\" };"
68*cdf0e10cSrcweir    print
69*cdf0e10cSrcweir}
70*cdf0e10cSrcweir
71*cdf0e10cSrcweirBEGIN {
72*cdf0e10cSrcweir    Header();
73*cdf0e10cSrcweir    TableHead();
74*cdf0e10cSrcweir}
75*cdf0e10cSrcweir
76*cdf0e10cSrcweir/^[ \t]*RES_/ && !index( $1, "_BEGIN" ) && !index( $1, "_END" ) && !index( $1, "_POOL_" ) {
77*cdf0e10cSrcweir    sStr = $1;
78*cdf0e10cSrcweir	split( $1, sStr, "," );
79*cdf0e10cSrcweir    print  "    " sStr[1] ", \"" sStr[1] "\","
80*cdf0e10cSrcweir}
81*cdf0e10cSrcweir
82*cdf0e10cSrcweirEND {
83*cdf0e10cSrcweir    TableTail();
84*cdf0e10cSrcweir    Main();
85*cdf0e10cSrcweir}
86*cdf0e10cSrcweir
87