From 397d95821cca73927a6bb51c57b075af6a95bd10 Mon Sep 17 00:00:00 2001 From: Tom Houlker Date: Tue, 14 Jan 2014 14:24:11 +1300 Subject: [PATCH] Bug 11539: removing 2 unused files This patch removes C4::Barcodes::PrinterConfig, which is used by no other code in the database. Signed-off-by: Emma Heath Signed-off-by: Kyle M Hall No instances of PrinterConfig found in the codebase Signed-off-by: Katrin Fischer Couldn't find any reference to those files in Koha. Signed-off-by: Galen Charlton --- C4/Barcodes/PrinterConfig.pm | 223 ----------------------------------- t/Barcodes_PrinterConfig.t | 22 ---- 2 files changed, 245 deletions(-) delete mode 100644 C4/Barcodes/PrinterConfig.pm delete mode 100755 t/Barcodes_PrinterConfig.t diff --git a/C4/Barcodes/PrinterConfig.pm b/C4/Barcodes/PrinterConfig.pm deleted file mode 100644 index 25f48ebdb5..0000000000 --- a/C4/Barcodes/PrinterConfig.pm +++ /dev/null @@ -1,223 +0,0 @@ -package C4::Barcodes::PrinterConfig; - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use strict; -#use warnings; FIXME - Bug 2505 -use vars qw($VERSION @EXPORT); - -use PDF::API2; -use PDF::API2::Page; - -BEGIN { - # set the version for version checking - $VERSION = 3.07.00.049; - require Exporter; - @EXPORT = qw(&labelsPage &getLabelPosition setPositionsForX setPositionsForY); -} - -=head1 NAME - -C4::Barcodes::PrinterConfig - Koha module dealing with labels in a PDF. - -=head1 SYNOPSIS - -use C4::Barcodes::PrinterConfig; - -=head1 DESCRIPTION - -This package is used to deal with labels in a pdf file. Giving some parameters, -this package contains several functions to handle every label considering the -environment of the pdf file. - -=head1 FUNCTIONS - -=head2 my @positionsForX; - -Takes all the X positions of the pdf file. - -=head2 my @positionsForY; - -Takes all the Y positions of the pdf file. - -=head2 my $firstLabel = 1; - -Test if the label passed as a parameter is the first label to be printed into the pdf file. - -=head2 setPositionsForX - - C4::Barcodes::PrinterConfig::setPositionsForX($marginLeft, $labelWidth, $columns, $pageType); - -Calculate and stores all the X positions across the pdf page. - -C<$marginLeft> Indicates how much left margin do you want in your page type. - -C<$labelWidth> Indicates the width of the label that you are going to use. - -C<$columns> Indicates how many columns do you want in your page type. - -C<$pageType> Page type to print (eg: a4, legal, etc). - -=cut - -# Globals used by the functions -my @positionsForX; -my @positionsForY; -my $firstLabel = 1; - -sub setPositionsForX { - my ($marginLeft, $labelWidth, $columns, $pageType) = @_; - my $defaultDpi = 72/25.4; # By default we know 25.4 mm -> 1 inch -> 72 dots per inch - my $whereToStart = ($marginLeft + ($labelWidth/2)); - my $firstLabel = $whereToStart*$defaultDpi; - my $spaceBetweenLabels = $labelWidth*$defaultDpi; - my @positions; - for (my $i = 0; $i < $columns ; $i++) { - push @positions, ($firstLabel+($spaceBetweenLabels*$i)); - } - @positionsForX = @positions; -} - -=head2 setPositionsForY - - C4::Barcodes::PrinterConfig::setPositionsForY($marginBottom, $labelHeigth, $rows, $pageType); - -Calculate and stores all tha Y positions across the pdf page. - -C<$marginBottom> Indicates how much bottom margin do you want in your page type. - -C<$labelHeigth> Indicates the height of the label that you are going to use. - -C<$rows> Indicates how many rows do you want in your page type. - -C<$pageType> Page type to print (eg: a4, legal, etc). - -=cut - -sub setPositionsForY { - my ($marginBottom, $labelHeigth, $rows, $pageType) = @_; - my $defaultDpi = 72/25.4; # By default we know 25.4 mm -> 1 inch -> 72 dots per inch - my $whereToStart = ($marginBottom + ($labelHeigth/2)); - my $firstLabel = $whereToStart*$defaultDpi; - my $spaceBetweenLabels = $labelHeigth*$defaultDpi; - my @positions; - for (my $i = 0; $i < $rows; $i++) { - unshift @positions, ($firstLabel+($spaceBetweenLabels*$i)); - } - @positionsForY = @positions; -} - -=head2 getLabelPosition - - (my $x, my $y, $pdfObject, $pageObject, $gfxObject, $textObject, $coreObject, $labelPosition) = - C4::Barcodes::PrinterConfig::getLabelPosition($labelPosition, $pdfObject, $page, $gfx, $text, $fontObject, $pageType); - -Return the (x,y) position of the label that you are going to print considering the environment. - -C<$labelPosition> Indicates which label positions do you want to place by x and y coordinates. - -C<$pdfObject> The PDF object in use. - -C<$page> The page in use. - -C<$gfx> The gfx resource to handle with barcodes objects. - -C<$text> The text resource to handle with text. - -C<$fontObject> The font object - -C<$pageType> Page type to print (eg: a4, legal, etc). - -=cut - -sub getLabelPosition { - my ($labelNum, $pdf, $page, $gfxObject, $textObject, $fontObject, $pageType) = @_; - my $indexX = $labelNum % @positionsForX; - my $indexY = int($labelNum / @positionsForX); - # Calculates the next label position and return that label number - my $nextIndexX = $labelNum % @positionsForX; - my $nextIndexY = $labelNum % @positionsForY; - if ($firstLabel) { - $page = $pdf->page; - $page->mediabox($pageType); - $gfxObject = $page->gfx; - $textObject = $page->text; - $textObject->font($fontObject, 7); - $firstLabel = 0; - } elsif (($nextIndexX == 0) && ($nextIndexY == 0)) { - $page = $pdf->page; - $page->mediabox($pageType); - $gfxObject = $page->gfx; - $textObject = $page->text; - $textObject->font($fontObject, 7); - } - $labelNum = $labelNum + 1; - if ($labelNum == (@positionsForX*@positionsForY)) { - $labelNum = 0; - } - return ($positionsForX[$indexX], $positionsForY[$indexY], $pdf, $page, $gfxObject, $textObject, $fontObject, $labelNum); -} - -=head2 labelsPage - - my @labelTable = C4::Barcodes::PrinterConfig::labelsPage($rows, $columns); - -This function will help you to build the labels panel, where you can choose -wich label position do you want to start the printer process. - -C<$rows> Indicates how many rows do you want in your page type. - -C<$columns> Indicates how many rows do you want in your page type. - -=cut - -sub labelsPage{ - my ($rows, $columns) = @_; - my @pageType; - my $tagname = 0; - my $labelname = 1; - my $check; - for (my $i = 1; $i <= $rows; $i++) { - my @column; - for (my $j = 1; $j <= $columns; $j++) { - my %cell; - if ($tagname == 0) { - $check = 'checked'; - } else { - $check = ''; - } - %cell = (check => $check, - tagname => $tagname, - labelname => $labelname); - $tagname = $tagname + 1; - $labelname = $labelname + 1; - push @column, \%cell; - } - my %columns = (columns => \@column); - push @pageType, \%columns; - } - return @pageType; -} - -1; - -__END__ - -=head1 AUTHOR - -Koha Physics Library UNLP - -=cut diff --git a/t/Barcodes_PrinterConfig.t b/t/Barcodes_PrinterConfig.t deleted file mode 100755 index 94102e5c58..0000000000 --- a/t/Barcodes_PrinterConfig.t +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/perl -# -# This Koha test module is a stub! -# Add more tests here!!! - -use strict; -use warnings; - -use Test::More tests => 6; - -BEGIN { - use_ok('C4::Barcodes::PrinterConfig'); -} - -is(C4::Barcodes::PrinterConfig::setPositionsForY(), "0", "testing setPositionsForY returns'0' when given no arguments"); -is(C4::Barcodes::PrinterConfig::setPositionsForX(), "0", "testing setPositionsForX returns'0' when given no arguments"); - -is(C4::Barcodes::PrinterConfig::setPositionsForY(undef, undef, 5), "5", "testing setPositionsForY returns'5' when given (undef, undef, 5)"); -is(C4::Barcodes::PrinterConfig::setPositionsForX(undef, undef, 5), "5", "testing setPositionsForX returns'5' when given (undef, undef, 5)"); - - -is(C4::Barcodes::PrinterConfig::labelsPage(), "0", "testing labelsPage returns'0' when given no arguments"); -- 2.39.5