1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2000, 2010 Oracle and/or its affiliates.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # This file is part of OpenOffice.org.
11 # OpenOffice.org is free software: you can redistribute it and/or modify
12 # it under the terms of the GNU Lesser General Public License version 3
13 # only, as published by the Free Software Foundation.
15 # OpenOffice.org is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU Lesser General Public License version 3 for more details
19 # (a copy is included in the LICENSE file that accompanied this code).
21 # You should have received a copy of the GNU Lesser General Public License
22 # version 3 along with OpenOffice.org. If not, see
23 # <http://www.openoffice.org/license.html>
24 # for a copy of the LGPLv3 License.
26 #*************************************************************************
28 package par2script
::undefine
;
30 use par2script
::globals
;
32 ##########################################################
33 # Removing in the script all the gids, that are listed
34 # in undefine scp files
35 ##########################################################
39 my ($parfilecontent) = @_;
42 foreach $item ( @par2script::globals
::allitems
)
44 my $unitem = "Un$item";
46 for ( my $i = 0; $i <= $#{$parfilecontent}; $i++ )
48 if ( ${$parfilecontent}[$i] =~ /^\s*$unitem\s*(\w+?)\s*$/ )
51 delete($par2script::globals
::definitions
{$item}->{$gid});
57 ##########################################################
58 # Collecting all subdirectories of a specified directory
59 ##########################################################
61 sub collect_children_dirs
63 my ($gid, $collector) = @_;
65 my $diritem = "Directory";
66 my $parentkey = "ParentID";
68 if ( exists($par2script::globals
::definitions
{$diritem}) )
72 foreach $onedefinition (keys %{$par2script::globals
::definitions
{$diritem}})
74 if ( $par2script::globals
::definitions
{$diritem}->{$onedefinition}->{$parentkey} eq $gid )
76 push(@
{$collector}, $onedefinition);
77 collect_children_dirs
($onedefinition, $collector);
83 ##########################################################
84 # Removing in the script complete profiles.
85 # This includes the Profile and its ProfileItems.
86 ##########################################################
88 sub remove_complete_item
90 my ($item, $parfilecontent) = @_;
92 my $removeitem = "Remove$item";
93 my $dependentkey = "";
94 my $collect_children = 0;
95 my @gidcollector = ();
96 my @dependentitems = ();
98 if ( $item eq "Profile" )
100 @dependentitems = ("ProfileItem");
101 $dependentkey = "ProfileID";
103 elsif ( $item eq "Directory" )
105 @dependentitems = ("File", "Shortcut", "Unixlink");
106 $dependentkey = "Dir";
107 $collect_children = 1;
110 for ( my $i = 0; $i <= $#{$parfilecontent}; $i++ )
112 if ( ${$parfilecontent}[$i] =~ /^\s*$removeitem\s*(\w+?)\s*$/ )
115 push(@gidcollector, $onegid);
116 if ( $collect_children ) { collect_children_dirs
($onegid, \
@gidcollector); }
119 foreach $gid (@gidcollector)
121 delete($par2script::globals
::definitions
{$item}->{$gid});
123 # also deleting all dependent items, for example "ProfileItems" whose "ProfileID" is this "Profile"
125 foreach $depitem ( @dependentitems )
127 if ( exists($par2script::globals
::definitions
{$depitem}) )
130 foreach $onedefinition (keys %{$par2script::globals
::definitions
{$depitem}})
132 if ( $par2script::globals
::definitions
{$depitem}->{$onedefinition}->{$dependentkey} eq $gid )
134 delete($par2script::globals
::definitions
{$depitem}->{$onedefinition});