[Libreoffice-commits] .: 6 commits - desktop/source

David Tardon dtardon at kemper.freedesktop.org
Thu Nov 25 06:40:59 PST 2010


 desktop/source/deployment/misc/dp_platform.cxx                 |    4 
 desktop/source/deployment/registry/package/dp_extbackenddb.cxx |    1 
 desktop/source/deployment/registry/package/dp_extbackenddb.hxx |   11 
 desktop/source/deployment/registry/script/dp_lib_container.cxx |    6 
 desktop/source/deployment/registry/script/dp_lib_container.h   |   17 -
 desktop/source/deployment/registry/script/dp_script.cxx        |  159 ++++------
 6 files changed, 90 insertions(+), 108 deletions(-)

New commits:
commit ff1fe0370f360386b91e81636b3ab5111dfecf5e
Author: David Tardon <dtardon at redhat.com>
Date:   Thu Nov 25 15:39:27 2010 +0100

    avoid duplicate code

diff --git a/desktop/source/deployment/misc/dp_platform.cxx b/desktop/source/deployment/misc/dp_platform.cxx
index 0e67097..dff464b 100644
--- a/desktop/source/deployment/misc/dp_platform.cxx
+++ b/desktop/source/deployment/misc/dp_platform.cxx
@@ -113,9 +113,7 @@ namespace
                 ::rtl::OUStringBuffer buf;
                 buf.append( StrOperatingSystem::get() );
                 buf.append( static_cast<sal_Unicode>('_') );
-                OUString arch( RTL_CONSTASCII_USTRINGPARAM("$_ARCH") );
-                ::rtl::Bootstrap::expandMacros( arch );
-                buf.append( arch );
+                buf.append( StrCPU::get() );
                 return buf.makeStringAndClear();
             }
     };
commit 0a661a68df0a1c8e81c0759623a806ab697af9b9
Author: David Tardon <dtardon at redhat.com>
Date:   Thu Nov 25 15:38:06 2010 +0100

    remove unused headers

diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx
index c3b0c09..9da7756 100644
--- a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx
+++ b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx
@@ -29,7 +29,6 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_desktop.hxx"
 
-#include "rtl/string.h"
 #include "rtl/bootstrap.hxx"
 #include "cppuhelper/exc_hlp.hxx"
 #include "com/sun/star/uno/XComponentContext.hpp"
diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx
index ac57bd7..f252031 100644
--- a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx
+++ b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx
@@ -26,13 +26,14 @@
  *
  ************************************************************************/
 
-
 #if ! defined INCLUDED_DP_EXTBACKENDDB_HXX
 #define INCLUDED_DP_EXTBACKENDDB_HXX
 
-#include "rtl/ustring.hxx"
-#include "rtl/string.hxx"
+#include <utility>
 #include <vector>
+
+#include "rtl/ustring.hxx"
+
 #include "dp_backenddb.hxx"
 
 namespace css = ::com::sun::star;
@@ -74,11 +75,9 @@ public:
         ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString> > items;
         typedef ::std::vector<
             ::std::pair< ::rtl::OUString, ::rtl::OUString> >::const_iterator ITC_ITEMS;
-
     };
     
 public:
-
     ExtensionBackendDb( css::uno::Reference<css::uno::XComponentContext> const &  xContext,
                         ::rtl::OUString const & url);
 
@@ -88,8 +87,6 @@ public:
     
 };
 
-
-
 }
 }
 }
commit f55a2a5510a1e35b474cd62c4a4a3b941f740b91
Author: David Tardon <dtardon at redhat.com>
Date:   Thu Nov 25 14:00:50 2010 +0100

    refactor duplicate code

diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx
index 0c99cf4..31b3027 100644
--- a/desktop/source/deployment/registry/script/dp_script.cxx
+++ b/desktop/source/deployment/registry/script/dp_script.cxx
@@ -82,7 +82,7 @@ class BackendImpl : public t_helper
             bool startup,
             ::rtl::Reference<AbortChannel> const & abortChannel,
             Reference<XCommandEnvironment> const & xCmdEnv );
-        
+
     public:
         PackageImpl(
             ::rtl::Reference<BackendImpl> const & myBackend,
@@ -319,7 +319,60 @@ BackendImpl::PackageImpl::isRegistered_(
         beans::Ambiguous<sal_Bool>( registered, false /* IsAmbiguous */ ) );
 }
 
-//______________________________________________________________________________
+void
+lcl_maybeRemoveScript(
+        bool const bExists,
+        OUString const& rName,
+        OUString const& rScriptURL,
+        Reference<css::script::XLibraryContainer3> const& xScriptLibs)
+{
+    if (bExists && xScriptLibs.is() && xScriptLibs->hasByName(rName))
+    {
+        const OUString sScriptUrl = xScriptLibs->getOriginalLibraryLinkURL(rName);
+        if (sScriptUrl.equals(rScriptURL))
+            xScriptLibs->removeLibrary(rName);
+    }
+}
+
+bool
+lcl_maybeAddScript(
+        bool const bExists,
+        OUString const& rName,
+        OUString const& rScriptURL,
+        Reference<css::script::XLibraryContainer3> const& xScriptLibs)
+{
+    if (bExists && xScriptLibs.is())
+    {
+        bool bCanAdd = true;
+        if (xScriptLibs->hasByName(rName))
+        {
+            const OUString sOriginalUrl = xScriptLibs->getOriginalLibraryLinkURL(rName);
+            //We assume here that library names in extensions are unique, which may not be the case
+            //ToDo: If the script exist in another extension, then both extensions must have the
+            //same id
+            if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE"))
+                || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE"))
+                || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS")))
+            {
+                xScriptLibs->removeLibrary(rName);
+                bCanAdd = true;
+            }
+            else
+            {
+                bCanAdd = false;
+            }
+        }
+
+        if (bCanAdd)
+        {
+            xScriptLibs->createLibraryLink(rName, rScriptURL, false);
+            return xScriptLibs->hasByName(rName);
+        }
+    }
+
+    return false;
+}
+
 void BackendImpl::PackageImpl::processPackage_(
     ::osl::ResettableMutexGuard & /* guard */,
     bool doRegisterPackage,
@@ -375,19 +428,8 @@ void BackendImpl::PackageImpl::processPackage_(
             //we also prevent and live deployment at startup
             if (!isRemoved() && !startup)
             {
-                if (bScript && xScriptLibs.is() && xScriptLibs->hasByName(m_name))
-                {
-                    const OUString sScriptUrl = xScriptLibs->getOriginalLibraryLinkURL(m_name);
-                    if (sScriptUrl.equals(m_scriptURL))
-                        xScriptLibs->removeLibrary(m_name);
-                }
-                    
-                if (bDialog && xDialogLibs.is() && xDialogLibs->hasByName(m_dialogName))
-                {
-                    const OUString sDialogUrl = xDialogLibs->getOriginalLibraryLinkURL(m_dialogName);
-                    if (sDialogUrl.equals(m_dialogURL))
-                        xDialogLibs->removeLibrary(m_dialogName);
-                }
+                lcl_maybeRemoveScript(bScript, m_name, m_scriptURL, xScriptLibs);
+                lcl_maybeRemoveScript(bDialog, m_dialogName, m_dialogURL, xDialogLibs);
             }            
             getMyBackend()->deleteDataFromDb(getURL());
             return;
@@ -398,72 +440,14 @@ void BackendImpl::PackageImpl::processPackage_(
 
     // Update LibraryContainer
     bool bScriptSuccess = false;
-    const bool bReadOnly = false;
-
     bool bDialogSuccess = false;
     if (!startup)
     {
         //If there is a bundled extension, and the user installes the same extension
         //then the script from the bundled extension must be removed. If this does not work
         //then live deployment does not work for scripts.
-        if (bScript && xScriptLibs.is())
-        {
-            bool bCanAdd = true;
-            if (xScriptLibs->hasByName(m_name))
-            {
-                const OUString sOriginalUrl = xScriptLibs->getOriginalLibraryLinkURL(m_name);
-                //We assume here that library names in extensions are unique, which may not be the case
-                //ToDo: If the script exist in another extension, then both extensions must have the
-                //same id
-                if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE"))
-                    || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE"))
-                    || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS")))
-                {
-                    xScriptLibs->removeLibrary(m_name);
-                    bCanAdd = true;
-                }
-                else
-                {
-                    bCanAdd = false;
-                }
-            }
-
-            if (bCanAdd)
-            {
-                xScriptLibs->createLibraryLink( m_name, m_scriptURL, bReadOnly );
-                bScriptSuccess = xScriptLibs->hasByName( m_name );
-            }
-        }
-
-
-        if (bDialog && xDialogLibs.is()) 
-        {
-            bool bCanAdd = true;
-            if (xDialogLibs->hasByName(m_dialogName))
-            {
-                const OUString sOriginalUrl = xDialogLibs->getOriginalLibraryLinkURL(m_dialogName);
-                //We assume here that library names in extensions are unique, which may not be the case
-                //ToDo: If the script exist in another extension, then both extensions must have the
-                //same id
-                if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE"))
-                    || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE"))
-                    || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS")))
-                {
-                    xDialogLibs->removeLibrary(m_dialogName);
-                    bCanAdd = true;
-                }
-                else
-                {
-                    bCanAdd = false;
-                }            
-            }
-
-            if (bCanAdd)
-            {
-                xDialogLibs->createLibraryLink( m_dialogName, m_dialogURL, bReadOnly );
-                bDialogSuccess = xDialogLibs->hasByName(m_dialogName);
-            }
-        }
+        bScriptSuccess = lcl_maybeAddScript(bScript, m_name, m_scriptURL, xScriptLibs);
+        bDialogSuccess = lcl_maybeAddScript(bDialog, m_dialogName, m_dialogURL, xDialogLibs);
     }
     bool bSuccess = bScript || bDialog;		// Something must have happened
     if( bRunning && !startup)
commit c4ea14d08bb97356bbe0ddb0cb2c1f8eae657054
Author: David Tardon <dtardon at redhat.com>
Date:   Thu Nov 25 13:32:55 2010 +0100

    comment out unused arguments

diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx
index 2efa77d..0c99cf4 100644
--- a/desktop/source/deployment/registry/script/dp_script.cxx
+++ b/desktop/source/deployment/registry/script/dp_script.cxx
@@ -306,12 +306,10 @@ BackendImpl * BackendImpl::PackageImpl::getMyBackend() const
 
 beans::Optional< beans::Ambiguous<sal_Bool> >
 BackendImpl::PackageImpl::isRegistered_(
-    ::osl::ResettableMutexGuard &,
-    ::rtl::Reference<AbortChannel> const &,
-    Reference<XCommandEnvironment> const & xCmdEnv )
+    ::osl::ResettableMutexGuard & /* guard */,
+    ::rtl::Reference<AbortChannel> const & /* abortChannel */,
+    Reference<XCommandEnvironment> const & /* xCmdEnv */ )
 {
-    (void)xCmdEnv;
-
     BackendImpl * that = getMyBackend();
     Reference< deployment::XPackage > xThisPackage( this );
 
@@ -323,14 +321,12 @@ BackendImpl::PackageImpl::isRegistered_(
 
 //______________________________________________________________________________
 void BackendImpl::PackageImpl::processPackage_(
-    ::osl::ResettableMutexGuard &,
+    ::osl::ResettableMutexGuard & /* guard */,
     bool doRegisterPackage,
     bool startup,
-    ::rtl::Reference<AbortChannel> const &,
-    Reference<XCommandEnvironment> const & xCmdEnv )
+    ::rtl::Reference<AbortChannel> const & /* abortChannel */,
+    Reference<XCommandEnvironment> const & /* xCmdEnv */ )
 {
-    (void)xCmdEnv;
-
     BackendImpl * that = getMyBackend();
 
     Reference< deployment::XPackage > xThisPackage( this );
commit 5dc7f9867d2d92165691910f1950f0f0da076497
Author: David Tardon <dtardon at redhat.com>
Date:   Thu Nov 25 12:01:04 2010 +0100

    remove unused code

diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx
index 4d65cc6..2efa77d 100644
--- a/desktop/source/deployment/registry/script/dp_script.cxx
+++ b/desktop/source/deployment/registry/script/dp_script.cxx
@@ -41,7 +41,6 @@
 #include "svl/inettype.hxx"
 #include "com/sun/star/util/XUpdatable.hpp"
 #include "com/sun/star/script/XLibraryContainer3.hpp"
-#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
 #include <com/sun/star/util/XMacroExpander.hpp>
 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
 #include <memory>
@@ -62,7 +61,6 @@ namespace {
 typedef ::cppu::ImplInheritanceHelper1<
     ::dp_registry::backend::PackageRegistryBackend, util::XUpdatable > t_helper;
 
-//==============================================================================
 class BackendImpl : public t_helper
 {
     class PackageImpl : public ::dp_registry::backend::Package
@@ -105,11 +103,6 @@ class BackendImpl : public t_helper
     void deleteDataFromDb(OUString const & url);
     bool isRegisteredInDb(OUString const & url);
 
-    
-
-//     Reference< ucb::XSimpleFileAccess > getFileAccess( void );
-// 	Reference< ucb::XSimpleFileAccess > m_xSFA;
-
     const Reference<deployment::XPackageTypeInfo> m_xBasicLibTypeInfo;
     const Reference<deployment::XPackageTypeInfo> m_xDialogLibTypeInfo;
     Sequence< Reference<deployment::XPackageTypeInfo> > m_typeInfos;
@@ -310,7 +303,7 @@ BackendImpl * BackendImpl::PackageImpl::getMyBackend() const
     }
     return pBackend;
 }
-//______________________________________________________________________________
+
 beans::Optional< beans::Ambiguous<sal_Bool> >
 BackendImpl::PackageImpl::isRegistered_(
     ::osl::ResettableMutexGuard &,
commit a70d582f865edd1fa4eeed42bd616f0217239b79
Author: David Tardon <dtardon at redhat.com>
Date:   Thu Nov 25 09:37:12 2010 +0100

    move unnecessary includes to .cxx

diff --git a/desktop/source/deployment/registry/script/dp_lib_container.cxx b/desktop/source/deployment/registry/script/dp_lib_container.cxx
index 4dc71b7..ccc2b29 100644
--- a/desktop/source/deployment/registry/script/dp_lib_container.cxx
+++ b/desktop/source/deployment/registry/script/dp_lib_container.cxx
@@ -29,11 +29,17 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_desktop.hxx"
 
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/ucb/XCommandEnvironment.hpp"
+
 #include "dp_script.hrc"
 #include "dp_resource.h"
 #include "dp_xml.h"
 #include "dp_lib_container.h"
+
+#include "rtl/ustring.hxx"
 #include "ucbhelper/content.hxx"
+#include "xmlscript/xmllib_imexp.hxx"
 
 
 using namespace ::dp_misc;
diff --git a/desktop/source/deployment/registry/script/dp_lib_container.h b/desktop/source/deployment/registry/script/dp_lib_container.h
index b0f29c1..009846a 100644
--- a/desktop/source/deployment/registry/script/dp_lib_container.h
+++ b/desktop/source/deployment/registry/script/dp_lib_container.h
@@ -29,11 +29,20 @@
 #if ! defined INCLUDED_DP_LIB_CONTAINER_H
 #define INCLUDED_DP_LIB_CONTAINER_H
 
-#include "rtl/ustring.hxx"
-#include "xmlscript/xmllib_imexp.hxx"
-#include "com/sun/star/uno/XComponentContext.hpp"
-#include "com/sun/star/ucb/XCommandEnvironment.hpp"
+#include <com/sun/star/uno/Reference.hxx>
 
+namespace com { namespace sun { namespace star {
+    namespace uno {
+        class XComponentContext;
+    }
+    namespace ucb {
+        class XCommandEnvironment;
+    }
+}}}
+
+namespace rtl {
+    class OUString;
+}
 
 namespace css = ::com::sun::star;
 


More information about the Libreoffice-commits mailing list