1*9780544fSAndrew Rist#**************************************************************
2*9780544fSAndrew Rist#
3*9780544fSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
4*9780544fSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
5*9780544fSAndrew Rist#  distributed with this work for additional information
6*9780544fSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
7*9780544fSAndrew Rist#  to you under the Apache License, Version 2.0 (the
8*9780544fSAndrew Rist#  "License"); you may not use this file except in compliance
9*9780544fSAndrew Rist#  with the License.  You may obtain a copy of the License at
10*9780544fSAndrew Rist#
11*9780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
12*9780544fSAndrew Rist#
13*9780544fSAndrew Rist#  Unless required by applicable law or agreed to in writing,
14*9780544fSAndrew Rist#  software distributed under the License is distributed on an
15*9780544fSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9780544fSAndrew Rist#  KIND, either express or implied.  See the License for the
17*9780544fSAndrew Rist#  specific language governing permissions and limitations
18*9780544fSAndrew Rist#  under the License.
19*9780544fSAndrew Rist#
20*9780544fSAndrew Rist#**************************************************************
21*9780544fSAndrew Rist
22*9780544fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir
25cdf0e10cSrcweirpackage par2script::shortcut;
26cdf0e10cSrcweir
27cdf0e10cSrcweiruse par2script::work;
28cdf0e10cSrcweir
29cdf0e10cSrcweir############################################################
30cdf0e10cSrcweir# Writing shortcuts to files behind the correct files and
31cdf0e10cSrcweir# then shortcuts to shortcuts behind these shortcuts.
32cdf0e10cSrcweir############################################################
33cdf0e10cSrcweir
34cdf0e10cSrcweirsub shift_shortcut_positions
35cdf0e10cSrcweir{
36cdf0e10cSrcweir	my ($script) = @_;
37cdf0e10cSrcweir
38cdf0e10cSrcweir	my $allshortcutgids = par2script::work::get_all_gids_from_script($script, "Shortcut");
39cdf0e10cSrcweir
40cdf0e10cSrcweir	# first all shortcuts that are assigned to files
41cdf0e10cSrcweir
42cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$allshortcutgids}; $i++ )
43cdf0e10cSrcweir	{
44cdf0e10cSrcweir		my $codeblock = par2script::work::get_definitionblock_from_script($script, ${$allshortcutgids}[$i]);
45cdf0e10cSrcweir
46cdf0e10cSrcweir		my $filegid = par2script::work::get_value_from_definitionblock($codeblock, "FileID");
47cdf0e10cSrcweir
48cdf0e10cSrcweir		if (!($filegid eq ""))
49cdf0e10cSrcweir		{
50cdf0e10cSrcweir			par2script::work::remove_definitionblock_from_script($script, ${$allshortcutgids}[$i]);
51cdf0e10cSrcweir			par2script::work::add_definitionblock_into_script($script, $codeblock, $filegid);
52cdf0e10cSrcweir		}
53cdf0e10cSrcweir	}
54cdf0e10cSrcweir
55cdf0e10cSrcweir	# secondly all shortcuts that are assigned to other shortcuts
56cdf0e10cSrcweir
57cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$allshortcutgids}; $i++ )
58cdf0e10cSrcweir	{
59cdf0e10cSrcweir		my $codeblock = par2script::work::get_definitionblock_from_script($script, ${$allshortcutgids}[$i]);
60cdf0e10cSrcweir		my $shortcutgid = par2script::work::get_value_from_definitionblock($codeblock, "ShortcutID");
61cdf0e10cSrcweir
62cdf0e10cSrcweir		if (!($shortcutgid eq ""))
63cdf0e10cSrcweir		{
64cdf0e10cSrcweir			par2script::work::remove_definitionblock_from_script($script, ${$allshortcutgids}[$i]);
65cdf0e10cSrcweir			par2script::work::add_definitionblock_into_script($script, $codeblock, $shortcutgid);
66cdf0e10cSrcweir		}
67cdf0e10cSrcweir	}
68cdf0e10cSrcweir}
69cdf0e10cSrcweir
70cdf0e10cSrcweir
71cdf0e10cSrcweir1;
72