[Libreoffice-commits] .: 4 commits - cppuhelper/source i18npool/CustomTarget_localedata.mk solenv/bin stoc/source vcl/README

Michael Meeks michael at kemper.freedesktop.org
Fri Apr 13 16:36:21 PDT 2012


 cppuhelper/source/bootstrap.cxx                |   60 +++++++++++++--
 i18npool/CustomTarget_localedata.mk            |    3 
 solenv/bin/linkoo                              |   50 +++++++++----
 stoc/source/simpleregistry/simpleregistry.cxx  |   94 +++++++++++++++++++++----
 stoc/source/simpleregistry/textualservices.cxx |   11 ++
 stoc/source/simpleregistry/textualservices.hxx |    3 
 vcl/README                                     |    2 
 7 files changed, 179 insertions(+), 44 deletions(-)

New commits:
commit 092a90517889ff7b66a4e7229b897e381bf167f9
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Sat Apr 14 01:34:25 2012 +0200

    update vcl readme wrt. fpickers

diff --git a/vcl/README b/vcl/README
index 81afba0..f373bad 100644
--- a/vcl/README
+++ b/vcl/README
@@ -1,4 +1,4 @@
-Visual Components Library is responsible for the widgets (windowing, buttons, controls, etc.) operating system abstraction, including basic rendering (e.g. the output device).
+Visual Components Library is responsible for the widgets (windowing, buttons, controls, file-pickers etc.) operating system abstraction, including basic rendering (e.g. the output device).
 
 Welcome to the Visual Class Libraries (vcl) code
 
commit 5d646f4ba592764de44f50053802b1ed451d93d7
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Fri Apr 13 17:21:21 2012 +0200

    i18npool: use URLs for type database in localedata build

diff --git a/i18npool/CustomTarget_localedata.mk b/i18npool/CustomTarget_localedata.mk
index c21fcd9..e506d46 100644
--- a/i18npool/CustomTarget_localedata.mk
+++ b/i18npool/CustomTarget_localedata.mk
@@ -39,7 +39,8 @@ $(IPLD)/localedata_%.cxx : $(SRCDIR)/i18npool/source/localedata/data/%.xml \
 	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),SAX,1)
 	$(call gb_Helper_abbreviate_dirs_native, \
 		$(call gb_Helper_execute,saxparser) $* $< $@.tmp \
-			$(call gb_Helper_make_url,$(IPLD)/saxparser.rdb) $(OUTDIR_FOR_BUILD)/bin/types.rdb \
+			$(call gb_Helper_make_url,$(IPLD)/saxparser.rdb) \
+			$(call gb_Helper_make_url,$(OUTDIR_FOR_BUILD)/bin/types.rdb) \
 			-env:LO_LIB_DIR=$(call gb_Helper_make_url,$(gb_Helper_OUTDIR_FOR_BUILDLIBDIR)) \
 			$(if $(findstring s,$(MAKEFLAGS)),> /dev/null 2>&1) && \
 		sed 's/\(^.*get[^;]*$$\)/SAL_DLLPUBLIC_EXPORT \1/' $@.tmp > $@ && \
commit 09524d410bbaad2a0b9b39811cb5cc16621b1396
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Fri Apr 13 15:25:23 2012 +0200

    stoc: accelerate opening of multiple XML .rdb files in a directory
    
    Instead of nesting these, we aggregate them into a single non-nested
    registry, which saves lots of CPU at startup, sadly we can only do
    that for the new-style XML registries, so we have to sniff files,
    nevertheless this is still far faster. The merged xml files also
    break the XSimpleRegistry::getURL() method - but it appears not
    to get called.

diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx
index 39e44fe..cc64e07 100644
--- a/cppuhelper/source/bootstrap.cxx
+++ b/cppuhelper/source/bootstrap.cxx
@@ -274,16 +274,17 @@ Reference< registry::XSimpleRegistry > readRdbDirectory(
              url),
             css::uno::Reference< css::uno::XInterface >());
     }
-    for (css::uno::Reference< css::registry::XSimpleRegistry > last(
-             lastRegistry);;)
+    std::vector<rtl::OUString> aURLs;
+    css::uno::Reference< css::registry::XSimpleRegistry > last(lastRegistry);
+    for (;;)
     {
         osl::DirectoryItem i;
-        switch (dir.getNextItem(i, SAL_MAX_UINT32)) {
-        case osl::FileBase::E_None:
+        osl::FileBase::RC eResult;
+        eResult = dir.getNextItem(i, SAL_MAX_UINT32);
+        if (eResult == osl::FileBase::E_NOENT)
             break;
-        case osl::FileBase::E_NOENT:
-            return last;
-        default:
+        if (eResult != osl::FileBase::E_None)
+        {
             throw css::uno::RuntimeException(
                 (rtl::OUString(
                     RTL_CONSTASCII_USTRINGPARAM("cannot iterate directory ")) +
@@ -307,12 +308,49 @@ Reference< registry::XSimpleRegistry > readRdbDirectory(
         if (aName.toChar() == '.' || aName.endsWithAsciiL("~", 1))
             continue;
 
-        if (stat.getFileType() != osl::FileStatus::Directory) { //TODO: symlinks
-            last = readRdbFile(
-                stat.getFileURL(), fatalErrors, last, simpleRegistryFactory,
-                nestedRegistryFactory);
+        if (stat.getFileType() != osl::FileStatus::Directory) //TODO: symlinks
+            aURLs.push_back(stat.getFileURL());
+    }
+
+    size_t nXML = 0;
+    for (std::vector<rtl::OUString>::iterator it = aURLs.begin(); it != aURLs.end(); it++)
+    {
+        // Read / sniff the nasty files ...
+        osl::File aIn( *it );
+        if (aIn.open(osl_File_OpenFlag_Read) != osl::FileBase::E_None)
+            continue;
+
+        sal_uInt64 nRead = 0;
+        char buffer[6];
+        bool bIsXML = aIn.read(buffer, 6, nRead) == osl::FileBase::E_None &&
+                      nRead == 6 && !strncmp(buffer, "<?xml ", 6);
+        aIn.close();
+        if (!bIsXML)
+        {
+            OSL_TRACE (OSL_LOG_PREFIX "rdb '%s' is a legacy format\n",
+                       rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr());
+            break;
+        }
+        nXML++;
+    }
+    if (nXML == aURLs.size())
+    {
+        OSL_TRACE (OSL_LOG_PREFIX "no legacy rdbs in directory '%s'\n",
+                   rtl::OUStringToOString( url, RTL_TEXTENCODING_UTF8 ).getStr());
+        // read whole directory...
+        last = readRdbFile( url, fatalErrors, last,
+                            simpleRegistryFactory, nestedRegistryFactory);
+    }
+    else
+    {
+        for (std::vector<rtl::OUString>::iterator it = aURLs.begin(); it != aURLs.end(); it++)
+        {
+            // Read / sniff the nasty files ...
+            last = readRdbFile(*it, fatalErrors, last,
+                               simpleRegistryFactory, nestedRegistryFactory);
         }
     }
+    return last;
 }
 
 Reference< registry::XSimpleRegistry > nestRegistries(
diff --git a/stoc/source/simpleregistry/simpleregistry.cxx b/stoc/source/simpleregistry/simpleregistry.cxx
index f09b204..9eebb4f 100644
--- a/stoc/source/simpleregistry/simpleregistry.cxx
+++ b/stoc/source/simpleregistry/simpleregistry.cxx
@@ -48,6 +48,7 @@
 #include "cppuhelper/implbase2.hxx"
 #include "cppuhelper/weak.hxx"
 #include "osl/mutex.hxx"
+#include "osl/file.hxx"
 #include "registry/registry.hxx"
 #include "registry/regtype.h"
 #include "rtl/ref.hxx"
@@ -84,6 +85,12 @@ public:
 private:
     virtual rtl::OUString SAL_CALL getURL() throw (css::uno::RuntimeException);
 
+    virtual void SAL_CALL openRdb(
+        rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate)
+        throw (
+            css::registry::InvalidRegistryException,
+            css::uno::RuntimeException);
+
     virtual void SAL_CALL open(
         rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate)
         throw (
@@ -1130,27 +1137,17 @@ rtl::OUString Key::getResolvedName(rtl::OUString const & aKeyName)
     return resolved;
 }
 
-rtl::OUString SimpleRegistry::getURL() throw (css::uno::RuntimeException) {
+rtl::OUString SimpleRegistry::getURL() throw (css::uno::RuntimeException)
+{
     osl::MutexGuard guard(mutex_);
     return textual_.get() == 0 ? registry_.getName() : textual_->getUri();
 }
 
-void SimpleRegistry::open(
+void SimpleRegistry::openRdb(
     rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate)
     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
 {
     osl::MutexGuard guard(mutex_);
-    if (textual_.get() != 0) {
-        throw css::registry::InvalidRegistryException(
-            (rtl::OUString(
-                RTL_CONSTASCII_USTRINGPARAM(
-                    "com.sun.star.registry.SimpleRegistry.open(")) +
-             rURL +
-             rtl::OUString(
-                RTL_CONSTASCII_USTRINGPARAM(
-                    "): instance already open"))),
-            static_cast< OWeakObject * >(this));
-    }
     RegError err = (rURL.isEmpty() && bCreate)
         ? REG_REGISTRY_NOT_EXISTS
         : registry_.open(rURL, bReadOnly ? REG_READONLY : REG_READWRITE);
@@ -1162,7 +1159,10 @@ void SimpleRegistry::open(
         break;
     case REG_INVALID_REGISTRY:
         if (bReadOnly && !bCreate) {
-            textual_.reset(new stoc::simpleregistry::TextualServices(rURL));
+            if (!textual_.get())
+                textual_.reset(new stoc::simpleregistry::TextualServices(rURL));
+            else
+                textual_->merge(rURL);
             break;
         }
         // fall through
@@ -1180,6 +1180,72 @@ void SimpleRegistry::open(
     }
 }
 
+void SimpleRegistry::open(
+    rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate)
+    throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
+{
+    osl::MutexGuard guard(mutex_);
+
+    osl::DirectoryItem aItem;
+    osl::FileBase::RC eErr;
+    osl::FileStatus aStatus(osl_FileStatus_Mask_Type);
+
+    // FIXME: busts the 'create' mode ...
+    if ((eErr = osl::DirectoryItem::get( rURL, aItem )) != osl::FileBase::E_None ||
+        (eErr = aItem.getFileStatus( aStatus )) != osl::FileBase::E_None ||
+        !aStatus.isDirectory())
+    {
+        if (textual_.get() != 0)
+            throw css::registry::InvalidRegistryException(
+                (rtl::OUString("com.sun.star.registry.SimpleRegistry.open(") +
+                 rURL + rtl::OUString("): instance already open")),
+                static_cast< OWeakObject * >(this));
+        openRdb (rURL, bReadOnly, bCreate);
+    }
+    else
+    {
+        osl::Directory dir(rURL);
+        eErr = dir.open();
+        if (eErr != osl::FileBase::E_None)
+            goto err_throw;
+
+        for (;;) {
+            osl::DirectoryItem i;
+            if (dir.getNextItem(i, SAL_MAX_UINT32) != osl::FileBase::E_None)
+                break;
+            osl::FileStatus stat(osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName |
+                                 osl_FileStatus_Mask_FileURL);
+            if (i.getFileStatus(stat) != osl::FileBase::E_None)
+                throw css::uno::RuntimeException(
+                        (rtl::OUString("cannot stat in directory ") + rURL ),
+                        css::uno::Reference< css::uno::XInterface >());
+
+            rtl::OUString aName = stat.getFileName();
+
+            // Ignore backup files - to allow people to edit their
+            // services/ without extremely confusing behaviour
+            if (aName.toChar() == '.' || aName.endsWithAsciiL("~", 1))
+                continue;
+
+            if (stat.getFileType() != osl::FileStatus::Directory)
+                openRdb(stat.getFileURL(), bReadOnly, bCreate);
+        }
+    }
+    return;
+
+err_throw:
+        throw css::registry::InvalidRegistryException(
+            (rtl::OUString(
+                RTL_CONSTASCII_USTRINGPARAM(
+                    "com.sun.star.registry.SimpleRegistry.open(")) +
+             rURL +
+             rtl::OUString(
+                RTL_CONSTASCII_USTRINGPARAM(
+                    "): error statting url = ")) +
+             rtl::OUString::valueOf(static_cast< sal_Int32 >(eErr))),
+            static_cast< OWeakObject * >(this));
+}
+
 sal_Bool SimpleRegistry::isValid() throw (css::uno::RuntimeException) {
     osl::MutexGuard guard(mutex_);
     return textual_.get() != 0 || registry_.isValid();
diff --git a/stoc/source/simpleregistry/textualservices.cxx b/stoc/source/simpleregistry/textualservices.cxx
index ad24a44..2491f55 100644
--- a/stoc/source/simpleregistry/textualservices.cxx
+++ b/stoc/source/simpleregistry/textualservices.cxx
@@ -1236,6 +1236,15 @@ css::uno::Sequence< rtl::OUString > Key::getChildren() {
 TextualServices::TextualServices(rtl::OUString const & uri):
     uri_(uri), data_(new Data)
 {
+    merge(uri);
+}
+
+TextualServices::~TextualServices() {}
+
+// load and merge registry contents from uri
+void TextualServices::merge(const rtl::OUString &uri)
+        throw (com::sun::star::registry::InvalidRegistryException)
+{
     try {
         Parser(uri, data_);
     } catch (css::container::NoSuchElementException &) {
@@ -1247,8 +1256,6 @@ TextualServices::TextualServices(rtl::OUString const & uri):
     }
 }
 
-TextualServices::~TextualServices() {}
-
 css::uno::Reference< css::registry::XRegistryKey > TextualServices::getRootKey()
 {
     return new Key(data_, std::vector< rtl::OUString >());
diff --git a/stoc/source/simpleregistry/textualservices.hxx b/stoc/source/simpleregistry/textualservices.hxx
index 286eb92..0341c15 100644
--- a/stoc/source/simpleregistry/textualservices.hxx
+++ b/stoc/source/simpleregistry/textualservices.hxx
@@ -53,6 +53,9 @@ public:
 
     virtual ~TextualServices();
 
+    void merge(const rtl::OUString &uri)
+        throw (com::sun::star::registry::InvalidRegistryException);
+
     inline rtl::OUString getUri() { return uri_; }
 
     com::sun::star::uno::Reference< com::sun::star::registry::XRegistryKey >
commit a871537f328711f02d3b5ba18612bbf25c6f563b
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Thu Apr 12 12:28:24 2012 +0100

    linkoo: add --copy mode, default to this on windows

diff --git a/solenv/bin/linkoo b/solenv/bin/linkoo
index 8381ccc..f825e30 100755
--- a/solenv/bin/linkoo
+++ b/solenv/bin/linkoo
@@ -3,6 +3,8 @@
         if 0;
 
 use strict;
+use File::stat;
+use File::Copy;
 
 #*************************************************************************
 #
@@ -13,7 +15,7 @@ use strict;
 #*************************************************************************
 #
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-# 
+#
 # Copyright 2000, 2010 Oracle and/or its affiliates.
 #
 # OpenOffice.org - a multi-platform office productivity suite
@@ -56,20 +58,26 @@ export OOO_DISABLE_RECOVERY=1
 export SAL_ALLOW_LINKOO_SYMLINKS=1
 ';
 
-if ($ENV{'OS'} eq 'MACOSX') {
-    print "FIXME: linkoo currently does not work on Mac OS X\n";
-    exit(0);
-}
-
 my $dry_run = 0;
 my $backup = 0;
+my $copy = 0;
 my $usage = 0;
+my $windows = 0;
 my $LANG;
 my $TARGET;
 my $LIBVER;
 my $OOO_BUILD;
 my $OOO_INSTALL;
 
+if ($ENV{'OS'} eq 'MACOSX') {
+    print "FIXME: linkoo currently does not work on Mac OS X\n";
+    exit(0);
+}
+if ($TARGET eq 'wntgcci.pro') {
+    $windows = 1;
+    $copy = 1;
+}
+
 # process options
 for my $a (@ARGV) {
 
@@ -80,7 +88,8 @@ for my $a (@ARGV) {
 	$usage = 1;
     } elsif ($a eq '--backup') {
 	$backup = 1;
-
+    } elsif ($a eq '--copy') {
+	$copy = 1;
     # ordered arguments
     } elsif (!defined $OOO_INSTALL) {
 	$OOO_INSTALL = $a;
@@ -97,7 +106,7 @@ if (!defined $OOO_BUILD && defined $ENV{SRC_ROOT}) {
 }
 
 if ($usage || !defined $OOO_INSTALL || !defined $OOO_BUILD) {
-    printf "Usage: linkoo </path/to/ooo/install> [</path/to/ooo/build/tree>] [--dry-run] [--backup]\n";
+    printf "Usage: linkoo </path/to/ooo/install> [</path/to/ooo/build/tree>] [--dry-run] [--backup] [--copy]\n";
     exit (1);
 }
 
@@ -117,10 +126,10 @@ my $ure_lib_dir = 'ure-link/lib';
 my $win_ure_lib_dir = 'URE/bin';
 
 my @exceptions = ( 'libsunjavaplugin', 'libjvmfwk' );
-push @exceptions, 'cppuhelper' if ($TARGET ne 'wntgcci.pro');
+push @exceptions, 'cppuhelper' if (!$windows);
 
 my $bin;
-$bin = "|\\.bin" if ($TARGET eq 'wntgcci.pro');
+$bin = "|\\.bin" if ($windows);
 my %replaceable = (
     $brand_program_dir => "(\\.so|\\.dll|\\.exe|\\.com$bin)\$",
     $ure_lib_dir => "(\\.so\$|\\.so\\.3\$)",
@@ -200,7 +209,17 @@ sub do_link($$$$@)
     my $dest_name = shift;
     my $dont_check_link = shift;
 
-    if (-l "$dest/$dest_name" ) {
+    if ($copy) { # copy if older ...
+	my $src_mtime = stat("$src/$src_name")->mtime;
+	my $dest_mtime = stat("$dest/$dest_name")->mtime;
+	if ($src_mtime > $dest_mtime) {
+#	    print " copy $src/$src_name ($src_mtime) -> $dest/$dest_name ($dest_mtime)\n";
+	    print " copy $src/$src_name -> $dest/$dest_name\n";
+	    copy("$src/$src_name", "$dest/$dest_name") || die "Failed top copy: $!";
+	} else {
+#	    print " up-to-date $src/$src_name -> $dest/$dest_name\n";
+	}
+    } elsif (-l "$dest/$dest_name" ) {
 	my $link = readlink ("$dest/$dest_name");
 	if ($link =~ /^\//) { # Absolute path
 	    if (!$dry_run) {
@@ -324,6 +343,8 @@ sub evilness($)
     my $src  = "$OOO_BUILD/shell/$TARGET/lib/$name";
     my $dest = "$OOO_BUILD/sfx2/$TARGET/lib/$name";
 
+    return if ($windows);
+
     if ($doit eq 'undo') {
 	if (-l $dest) {
 	    print " unlink $name\n";
@@ -362,8 +383,7 @@ sub do_link_gdb_py($$$)
 
 sub link_gdb_py()
 {
-    return if ($TARGET eq 'wntgcci.pro');
-
+    return if ($windows);
     print "Special gdb.py helpers case: ";
 
     my $dirh;
@@ -396,7 +416,7 @@ sub link_gdb_py()
 
 sub link_pagein_files()
 {
-    return if ($TARGET eq 'wntgcci.pro');
+    return if ($windows);
 
     print "pagein case:";
     my $src  = "$OOO_BUILD/solver/$TARGET/bin";
@@ -427,7 +447,7 @@ if (!-f "$OOO_INSTALL/" . $brand_program_dir . "/ooenv") {
 evilness ('do');
 
 print "\nlinkoo finished";
-print ", please don't forget to source ooenv before ./soffice." if ($TARGET ne 'wntgcci.pro');
+print ", please don't forget to source ooenv before ./soffice." if (!$windows);
 print "\n";
 
 # vim:set shiftwidth=4 softtabstop=4 expandtab:


More information about the Libreoffice-commits mailing list