[3] | 1 | # |
---|
| 2 | # Copyright (c) 2004-2007 - Consultas, PKG.fr |
---|
| 3 | # |
---|
| 4 | # This file is part of A2P. |
---|
| 5 | # |
---|
| 6 | # A2P is free software; you can redistribute it and/or modify |
---|
| 7 | # it under the terms of the GNU General Public License as published by |
---|
| 8 | # the Free Software Foundation; either version 2 of the License, or |
---|
| 9 | # (at your option) any later version. |
---|
| 10 | # |
---|
| 11 | # A2P is distributed in the hope that it will be useful, |
---|
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | # GNU General Public License for more details. |
---|
| 15 | # |
---|
| 16 | # You should have received a copy of the GNU General Public License |
---|
| 17 | # along with A2P; if not, write to the Free Software |
---|
| 18 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 19 | # |
---|
| 20 | # $Id: IMM.pm 3 2007-10-18 16:20:19Z guillaume $ |
---|
| 21 | # |
---|
| 22 | # Class to export Invoke Medium Map (COPYGROUP) members |
---|
| 23 | # |
---|
| 24 | # cf ref #2, p. 178-179 |
---|
| 25 | # |
---|
| 26 | |
---|
| 27 | package AFPDS::MODCA::IMM ; |
---|
| 28 | |
---|
| 29 | use strict ; |
---|
| 30 | use A2P::Globals ; |
---|
| 31 | use A2P::Syslog ; |
---|
| 32 | use AFPDS::MODCA::Common ; |
---|
| 33 | |
---|
| 34 | BEGIN { |
---|
| 35 | our $VERSION = sprintf "%s", q$Rev: 1007 $ =~ /([0-9.]+)\s+/ ; |
---|
| 36 | } |
---|
| 37 | our $VERSION ; |
---|
| 38 | our @ISA = ("AFPDS::MODCA"); |
---|
| 39 | our $IDENTS ; |
---|
| 40 | |
---|
| 41 | sub _ID { 0xD3ABCC } |
---|
| 42 | |
---|
| 43 | sub new { |
---|
| 44 | my $class = shift ; |
---|
| 45 | &Debug("new " . __PACKAGE__ . " v$VERSION object"); |
---|
| 46 | |
---|
| 47 | my $self = { |
---|
| 48 | FLUX => 0, # Associated flux |
---|
| 49 | IDENT => _ID, # MO:DCA identity |
---|
| 50 | FLAG => 0, # MO:DCA flags |
---|
| 51 | RESERVED => 0, # MO:DCA reserved |
---|
| 52 | LONG => 0, # MO:DCA buffer length |
---|
| 53 | BUFFER => '' # MO:DCA content buffer |
---|
| 54 | }; |
---|
| 55 | |
---|
| 56 | return bless $self , $class ; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | sub validate { |
---|
| 60 | my $self = shift ; |
---|
| 61 | |
---|
| 62 | &UPSTAT('GETCOPYGROUP'); |
---|
| 63 | &Debug("Found IMM as COPYGROUP"); |
---|
| 64 | |
---|
| 65 | # Check buffer size |
---|
| 66 | if ( $self->{LONG} != 8 ) { |
---|
| 67 | &Debug("Found IMM Field value with bad length (" . $self->{LONG} . |
---|
| 68 | "), keeping only the first 8 chars"); |
---|
| 69 | $self->{BUFFER} = substr( $self->{BUFFER} , 0 , 8 ); |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | # Check FLUX is a Flux object |
---|
| 73 | return ( 251, "IMM needs to be used with Flux object" ) |
---|
| 74 | unless ( ref($self->{FLUX}) =~ /^AFPDS::Flux$/ ); |
---|
| 75 | |
---|
| 76 | return () ; |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | sub create { |
---|
| 80 | my $self = shift ; |
---|
| 81 | my $flux = $self->{FLUX} ; |
---|
| 82 | |
---|
| 83 | # Convert buffer |
---|
| 84 | my $copygroup = $self->convert ; |
---|
| 85 | |
---|
| 86 | # Prepare TeX/LaTeX copygroup code |
---|
| 87 | my $CopyGroup = ""; |
---|
| 88 | |
---|
| 89 | # Close the previous defined PageFormat before setting CopyGroup |
---|
| 90 | $CopyGroup = "}%\n" if ($flux->has_pageformat); |
---|
| 91 | |
---|
| 92 | # Update TeX/LaTeX copygroup code |
---|
| 93 | $CopyGroup .= "%\n\\ResetOffset%\n\\CopyGroup" ; |
---|
| 94 | |
---|
| 95 | # Parse found copygroup name to reset number as lowcase chars |
---|
| 96 | for ( split( // , $copygroup ) ) { |
---|
| 97 | if ( /\d/ ) { |
---|
| 98 | $CopyGroup .= chr( 97 + $_ ) ; |
---|
| 99 | } else { |
---|
| 100 | $CopyGroup .= uc( $_ ) ; |
---|
| 101 | } |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | $flux->updateFlux( { |
---|
| 105 | COPYGROUP => $CopyGroup . "% Load '$copygroup' COPYGROUP", |
---|
| 106 | |
---|
| 107 | # Keep information on this use for statistics |
---|
| 108 | COPYGROUPs => { $copygroup => 1 } |
---|
| 109 | } ); |
---|
| 110 | |
---|
| 111 | &UPSTAT('USECOPYGROUP_' . $copygroup); |
---|
| 112 | |
---|
| 113 | return () ; |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | &Debug("Module " . __PACKAGE__ . " v$VERSION loaded"); |
---|
| 117 | |
---|
| 118 | ( $IDENTS->{&_ID} ) = __PACKAGE__ =~ /(\w+)$/ ; |
---|