solenv/bin/linkoo |   92 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 84 insertions(+), 8 deletions(-)

New commits:
commit 99338b4b11fab0a857029d35edf6421be05353c7
Author: Cédric Bosdonnat <cedric.bosdon...@free.fr>
Date:   Tue Nov 6 11:54:43 2012 +0100

    linkoo can now link the en-US .ui files
    
    Change-Id: I22b74096d01d56282771f01eb5e966980607632c

diff --git a/solenv/bin/linkoo b/solenv/bin/linkoo
index 6aa4972..da2e720 100755
--- a/solenv/bin/linkoo
+++ b/solenv/bin/linkoo
@@ -5,6 +5,8 @@
 use strict;
 use File::stat;
 use File::Copy;
+use File::Find;
+use File::Spec::Functions qw[splitdir catdir];
 
 #*************************************************************************
 #
@@ -301,24 +303,35 @@ sub scan_one_dir($$$$)
     }
 }
 
-sub scan_and_link_files($$$)
+sub get_modules($$)
 {
     my $build_path = shift;
-    my $installed_files = shift;
     my $target = shift;
 
     my @modules = ();
     my $dirh_toplevel;
     opendir ($dirh_toplevel, $build_path) || die "Can't open '$build_path': 
$!";
-    while (my $subdir = readdir ($dirh_toplevel)) {
-       $subdir =~ m/\./ && next; # eg. vcl.old,
-       $subdir eq 'solver' && next; # skip solver dir itself
-       my $test = "$build_path/$subdir/$target";
-       -d $test || next;
-       push @modules, $test;
+    while ( my $subdir = readdir ($dirh_toplevel) )
+    {
+        $subdir =~ m/\./ && next; # eg. vcl.old,
+            $subdir eq 'solver' && next; # skip solver dir itself
+        my $test = "$build_path/$subdir/$target";
+        -d $test || next;
+        push @modules, $test;
     }
     closedir ($dirh_toplevel);
 
+    return \@modules;
+}
+
+sub scan_and_link_files($$$)
+{
+    my $build_path = shift;
+    my $installed_files = shift;
+    my $target = shift;
+
+    my @modules = get_modules( $build_path, $target );
+
     # Scan the old-style module/$target/lib directories ...
     my %build_files;
     for my $module (@modules) {
@@ -428,6 +441,68 @@ sub link_pagein_files()
     print "\n";
 }
 
+sub link_ui_files()
+{
+    # First find all the en-US .ui files installed
+    my @files = ();
+
+    find( sub
+          {
+              if ( $File::Find::dir !~ /\/res\// && $_ =~ /\.ui$/ )
+              {
+                  push( @files, $File::Find::name );
+              }
+          }, $OOO_INSTALL );
+
+    my @modules = get_modules( $OOO_BUILD, $TARGET );
+
+    # Search the files in the source tree
+    for my $dest ( @files )
+    {
+        my @dest_dirs = splitdir( $dest );
+        my $module_dir = @dest_dirs[-3];
+
+        my $name = @dest_dirs[-1];
+        my $nb_dirs = @dest_dirs - 2;
+        my $dest_dir = catdir( @dest_dirs[0..$nb_dirs] );
+
+        # Find out the file to link to in the source tree
+        my $modulepath = "";
+        my $nb_segments = 3;
+        if ( $dest =~ /\/modules\// )
+        {
+            # Handle the modules/* cases
+            if ( $module_dir =~ /^sw/ || $module_dir eq "sglobal" ) { 
$modulepath = "sw/uiconfig"; }
+            elsif ( $module_dir eq "smath" ) { $modulepath = 
"starmath/uiconfig"; }
+            elsif ( $module_dir eq "simpress" || $module_dir eq "sdraw" ) { 
$modulepath = "sd/uiconfig"; }
+            elsif ( $module_dir eq "scalc" ) { $modulepath = "sc/uiconfig"; }
+            elsif ( $module_dir =~ /^db/ ) { $modulepath = 
"dbaccess/uiconfig"; }
+            elsif ( $module_dir eq "BasicIDE" ) { $modulepath = 
"basctl/uiconfig/basicide"; $nb_segments = 2; }
+            elsif ( $module_dir eq "schart" ) { $modulepath = 
"chart2/uiconfig"; $nb_segments = 2; }
+            elsif ( $module_dir eq "tubes" ) { $modulepath = "tubes/uiconfig"; 
}
+            elsif ( $module_dir eq "StartModule" ) { $modulepath = 
"framework/uiconfig/startmodule"; $nb_segments = 2; }
+        }
+        else
+        {
+            $nb_segments = 2;
+            # Handle the <module>/ui/ cases
+            my $module = $module_dir;
+            if ( $module_dir eq "sfx" ) { $module = "sfx2"; }
+            elsif ( $module_dir eq "svt" ) { $module = "svtools"; }
+            elsif ( $module_dir eq "sw" ) { $module = "sw"; $nb_segments = 3; }
+
+            $modulepath = "$module/uiconfig";
+        }
+        my $subpath = catdir( @dest_dirs[-$nb_segments..-2] );
+        my $src_dir = "$OOO_BUILD/$modulepath/$subpath";
+
+        if ( -e "$src_dir/$name" )
+        {
+            do_link ( $src_dir, $dest_dir, $name, $name );
+        }
+    }
+}
+
 evilness ('undo');
 
 my $installed_files = build_installed_list ($OOO_INSTALL);
@@ -435,6 +510,7 @@ my $installed_files = build_installed_list ($OOO_INSTALL);
 scan_and_link_files ($OOO_BUILD, $installed_files, $TARGET);
 link_gdb_py();
 link_pagein_files();
+link_ui_files();
 
 if (!-f "$OOO_INSTALL/" . $brand_program_dir . "/ooenv") {
     my $ooenv;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to