1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: undefine.pm,v $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 package par2script
::undefine
;
34 use par2script
::globals
;
36 ##########################################################
37 # Removing in the script all the gids, that are listed
38 # in undefine scp files
39 ##########################################################
43 my ($parfilecontent) = @_;
46 foreach $item ( @par2script::globals
::allitems
)
48 my $unitem = "Un$item";
50 for ( my $i = 0; $i <= $#{$parfilecontent}; $i++ )
52 if ( ${$parfilecontent}[$i] =~ /^\s*$unitem\s*(\w+?)\s*$/ )
55 delete($par2script::globals
::definitions
{$item}->{$gid});
61 ##########################################################
62 # Collecting all subdirectories of a specified directory
63 ##########################################################
65 sub collect_children_dirs
67 my ($gid, $collector) = @_;
69 my $diritem = "Directory";
70 my $parentkey = "ParentID";
72 if ( exists($par2script::globals
::definitions
{$diritem}) )
76 foreach $onedefinition (keys %{$par2script::globals
::definitions
{$diritem}})
78 if ( $par2script::globals
::definitions
{$diritem}->{$onedefinition}->{$parentkey} eq $gid )
80 push(@
{$collector}, $onedefinition);
81 collect_children_dirs
($onedefinition, $collector);
87 ##########################################################
88 # Removing in the script complete profiles.
89 # This includes the Profile and its ProfileItems.
90 ##########################################################
92 sub remove_complete_item
94 my ($item, $parfilecontent) = @_;
96 my $removeitem = "Remove$item";
97 my $dependentkey = "";
98 my $collect_children = 0;
99 my @gidcollector = ();
100 my @dependentitems = ();
102 if ( $item eq "Profile" )
104 @dependentitems = ("ProfileItem");
105 $dependentkey = "ProfileID";
107 elsif ( $item eq "Directory" )
109 @dependentitems = ("File", "Shortcut", "Unixlink");
110 $dependentkey = "Dir";
111 $collect_children = 1;
114 for ( my $i = 0; $i <= $#{$parfilecontent}; $i++ )
116 if ( ${$parfilecontent}[$i] =~ /^\s*$removeitem\s*(\w+?)\s*$/ )
119 push(@gidcollector, $onegid);
120 if ( $collect_children ) { collect_children_dirs
($onegid, \
@gidcollector); }
123 foreach $gid (@gidcollector)
125 delete($par2script::globals
::definitions
{$item}->{$gid});
127 # also deleting all dependent items, for example "ProfileItems" whose "ProfileID" is this "Profile"
129 foreach $depitem ( @dependentitems )
131 if ( exists($par2script::globals
::definitions
{$depitem}) )
134 foreach $onedefinition (keys %{$par2script::globals
::definitions
{$depitem}})
136 if ( $par2script::globals
::definitions
{$depitem}->{$onedefinition}->{$dependentkey} eq $gid )
138 delete($par2script::globals
::definitions
{$depitem}->{$onedefinition});