Visio/Page.pm

filter: Statementstmt 39.5% 32 / 81 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 58.8% 10 / 17 Podpod 0.0% 0 / 7 totaltotal 37.8% 42 / 111 CC 4 SCAR 12.2
CC
4
Cov
37%
create_shape
12.0
create_pageSheet
6.0
new
2.0
CRAP 3.4
« Visio.pm ↑ Summary Visio/Layout.pm »
1 package Visio::Page;
2  
3 #PLEASE SEE MSPATENTLICENSE
4 # "This product may incorporate intellectual property owned by
5 # Microsoft Corporation. The terms and conditions upon which Microsoft
6 # is licensing such intellectual property may be found at
7 # http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp"
8  
9 # Copyright 2005 Aamer Akhter. All rights reserved.
10  
11 # Redistribution and use in source and binary forms, with or without
12 # modification, are permitted provided that the following conditions are
13 # met:
14  
15 # 1. Redistributions of source code must retain the above copyright
16 # notice, this list of conditions and the following disclaimer.
17  
18 # 2. Redistributions in binary form must reproduce the above copyright
19 # notice, this list of conditions and the following disclaimer in the
20 # documentation and/or other materials provided with the distribution.
21  
22 # THIS SOFTWARE IS PROVIDED BY THE LICENSOR(S) ``AS IS'' AND ANY EXPRESS
23 # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 # DISCLAIMED. IN NO EVENT SHALL THE LICENSOR(S) OR OTHER CONTRIBUTORS BE
26 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  
34 # The views and conclusions contained in the software and documentation
35 # are those of the authors and should not be interpreted as representing
36 # official policies, either expressed or implied, of the Licensor(s).
37  
38 # The software may be subject to additional license restrictions
39 # provided by the Licensor(s).
40  
41  
42  
43 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 1 ▶use Log::Log4perl qw(get_logger);
Subroutine BEGIN: called CC=1 SCAR=0.0
47 1 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 1 ▶use Visio::PageSheet;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 ▶use Visio::Shape;
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55  
56 1 $VERSION = sprintf "%d.%03d", q$Revision: 1.8 $ =~ /: (\d+)\.(\d+)/;
57  
58 1 my $log = get_logger('visio.page');
59  
60 # Preloaded methods go here.
61  
62 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
63 0 my $class = shift;
64 0 my $pagesN = shift;
65 0 my $id = shift;
66 0 my $self = {};
67 0 $self->{pagesN} = $pagesN;
68 0 $self->{xmldoc} = $pagesN->ownerDocument;
69 0 $self->{xmlroot} = $self->{xmldoc}->documentElement;
70 0 $self->{pageid} = $id;
71 0 bless($self,$class);
72 0 $self->{pageN} = $self->{xmldoc}->createElement('Page');
73 0 $self->{pagesN}->appendChild($self->{pageN});
74 0 $self->set_id();
75 #lets create the page
76 0 $log->debug("visio page object ($id) created");
77 0 return $self;
78 }
79  
80 0 ▶sub set_id {
Subroutine set_id: not called CC=1 SCAR=6.9
Pod undocumented
81 0 my $self = shift;
82 0 $self->{pageN}->setAttribute('ID',$self->{pageid});
83 }
84  
85 0 ▶sub set_name {
Subroutine set_name: not called CC=1 SCAR=6.9
Pod undocumented
86 0 my $self = shift;
87 0 my $name = shift;
88 0 $self->{pageN}->setAttribute('Name',$name);
89 }
90  
91 0 ▶sub set_heightWidth {
Subroutine set_heightWidth: not called CC=1 SCAR=6.9
Pod undocumented
92 0 my $self = shift;
93 0 my $height = shift;
94 0 my $width = shift;
95 0 my $ps= $self->create_pageSheet;
96 0 my $pp= $ps->create_pageProps;
97 0 $pp->set_PageWidth($width);
98 0 $pp->set_PageHeight($height)
99 }
100  
101 0 ▶sub create_pageSheet {
Subroutine create_pageSheet: not called CC=2 SCAR=17.9
Pod undocumented
102 #if pageSheet doesn't exist, create it;
103 0 my $self = shift;
104 0 ▶ if (defined $self->{pageSheet}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'pageSheet'}) { } 0 0 0
105 0 return $self->{pageSheet};
106 } else {
107 $self->{pageSheet} =
108 0 new Visio::PageSheet($self->{pageN});
109 0 return $self->{pageSheet};
110 }
111 }
112  
113 0 ▶sub create_shape {
Subroutine create_shape: not called CC=3 SCAR=24.8
Pod undocumented
114 0 my $self = shift;
115 0 my $opts = shift;
116 0 my $fromMaster = $$opts{fromMaster};
117 0 my $shape;
118 my $shapesNode = Visio::generic_create_node($self->{pageN},
119 0 'Shapes'
120 );
121 0 ▶ if (defined $self->{maxShapeid}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'maxShapeid'}) { } 0 0 0
122 0 $self->{maxShapeid} = $self->{maxShapeid} + 1;
123 } else {
124 0 $self->{maxShapeid} = 1;
125 }
126 0 ▶ if (defined $fromMaster) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fromMaster) 0 0 0
127 $shape= new Visio::Shape($shapesNode,
128 $self->{maxShapeid},
129 0 {fromMaster=>$fromMaster,
130 pageSelf=>$self
131 }
132 );
133 }
134 0 return $shape;
135 }
136  
137 0 ▶sub create_connect {
Subroutine create_connect: not called CC=1 SCAR=6.9
Pod undocumented
138 0 my $self = shift;
139 0 my $opts = shift;
140 0 my $connect;
141 my $connectsNode = Visio::generic_create_node($self->{pageN},
142 0 'Connects'
143 );
144 0 $connect = $self->{xmldoc}->createElement('Connect');
145 0 $connectsNode->appendChild($connect);
146 0 return $connect;
147 }
148  
149  
150 1 1;
151 __END__
« Visio.pm ↑ Summary Visio/Layout.pm »