Visio/Layout.pm

filter: Statementstmt 49.0% 26 / 53 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 72.7% 8 / 11 Podpod 0.0% 0 / 3 totaltotal 47.8% 34 / 71 CC 3 SCAR 9.6
CC
3
Cov
46%
new
6.0
set_LayoutProperty
6.0
get_node
2.0
CRAP 2.6
« Visio/Page.pm ↑ Summary Visio/Line.pm »
1 package Visio::Layout;
2  
3  
4  
5 #PLEASE SEE MSPATENTLICENSE
6 # "This product may incorporate intellectual property owned by
7 # Microsoft Corporation. The terms and conditions upon which Microsoft
8 # is licensing such intellectual property may be found at
9 # http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp"
10  
11 # Copyright 2005 Aamer Akhter. All rights reserved.
12  
13 # Redistribution and use in source and binary forms, with or without
14 # modification, are permitted provided that the following conditions are
15 # met:
16  
17 # 1. Redistributions of source code must retain the above copyright
18 # notice, this list of conditions and the following disclaimer.
19  
20 # 2. Redistributions in binary form must reproduce the above copyright
21 # notice, this list of conditions and the following disclaimer in the
22 # documentation and/or other materials provided with the distribution.
23  
24 # THIS SOFTWARE IS PROVIDED BY THE LICENSOR(S) ``AS IS'' AND ANY EXPRESS
25 # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 # DISCLAIMED. IN NO EVENT SHALL THE LICENSOR(S) OR OTHER CONTRIBUTORS BE
28 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
34 # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  
36 # The views and conclusions contained in the software and documentation
37 # are those of the authors and should not be interpreted as representing
38 # official policies, either expressed or implied, of the Licensor(s).
39  
40 # The software may be subject to additional license restrictions
41 # provided by the Licensor(s).
42  
43  
44  
45 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 1 ▶use Log::Log4perl qw(get_logger);
Subroutine BEGIN: called CC=1 SCAR=0.0
49 1 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
53  
54  
55 1 $VERSION = sprintf "%d.%03d", q$Revision: 1.5 $ =~ /: (\d+)\.(\d+)/;
56  
57 1 my $log = get_logger('visio.layout');
58  
59 # Preloaded methods go here.
60  
61 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
62 0 my $class = shift;
63 0 my $parentN = shift;
64 0 my $self = {};
65 0 $self->{parentN} = $parentN;
66 0 $self->{xmldoc} = $parentN->ownerDocument;
67 0 $self->{xmlroot} = $self->{xmldoc}->documentElement;
68 0 bless($self,$class);
69 0 my $NL = $self->{parentN}->findnodes('Layout');
70 0 ▶ if ($NL->size() > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($NL->size > 0) { } 0 0 0
71 0 $self->{layoutNode} = $NL->pop();
72 0 $log->debug("visio layout object already exists");
73 } else {
74 0 $self->{layoutNode} = $self->{xmldoc}->createElement('Layout');
75 0 $self->{parentN}->appendChild($self->{layoutNode});
76 #lets create the page
77 0 $log->debug("visio line object created");
78 }
79 0 return $self;
80 }
81  
82 0 ▶sub get_node {
Subroutine get_node: not called CC=1 SCAR=6.9
Pod undocumented
83 0 my $self = shift;
84 0 return $self->{layoutNode};
85 }
86  
87 0 ▶sub set_LayoutProperty {
Subroutine set_LayoutProperty: not called CC=2 SCAR=17.9
Pod undocumented
88 0 my $self = shift;
89 0 my $property = shift;
90 0 my $value = shift;
91 0 my $format = shift;
92 my $node = Visio::generic_create_node($self->{layoutNode},
93 0 $property,
94 );
95 0 Visio::generic_settext($node,$value);
96 0 ▶ if (defined $format) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $format) 0 0 0
97 0 $node->setAttribute('F',$format);
98 }
99 0 $self->{property}{$property}=$property;
100 0 return $node;
101 }
102  
103  
104 1 1;
105 __END__
« Visio/Page.pm ↑ Summary Visio/Line.pm »