Commits

Anonymous committed fff7de6

#i98699# - Reintroduced support for base installation directory.

Comments (0)

Files changed (2)

comphelper/source/officeinstdir/officeinstallationdirectories.cxx

 
 OfficeInstallationDirectories::OfficeInstallationDirectories(
         const uno::Reference< uno::XComponentContext > & xCtx )
-: m_aOfficeDirMacro( RTL_CONSTASCII_USTRINGPARAM( "$(brandbaseurl)" ) ),
+: m_aOfficeBrandDirMacro( RTL_CONSTASCII_USTRINGPARAM( "$(brandbaseurl)" ) ),
+  m_aOfficeBaseDirMacro( RTL_CONSTASCII_USTRINGPARAM( "$(baseinsturl)" ) ),
   m_aUserDirMacro( RTL_CONSTASCII_USTRINGPARAM( "$(userdataurl)" ) ),
   m_xCtx( xCtx ),
-  m_pOfficeDir( 0 ),
+  m_pOfficeBrandDir( 0 ),
+  m_pOfficeBaseDir( 0 ),
   m_pUserDir( 0 )
 {
 }
 // virtual
 OfficeInstallationDirectories::~OfficeInstallationDirectories()
 {
+    delete m_pOfficeBrandDir;
+    delete m_pOfficeBaseDir;
+    delete m_pUserDir;
 }
 
 //=========================================================================
 OfficeInstallationDirectories::getOfficeInstallationDirectoryURL()
     throw ( uno::RuntimeException )
 {
-    // late init m_pOfficeDir and m_pUserDir
     initDirs();
-    return rtl::OUString( *m_pOfficeDir );
+    return rtl::OUString( *m_pOfficeBrandDir );
 }
 
 //=========================================================================
 OfficeInstallationDirectories::getOfficeUserDataDirectoryURL()
     throw ( uno::RuntimeException )
 {
-    // late init m_pOfficeDir and m_pUserDir
     initDirs();
     return rtl::OUString( *m_pUserDir );
 }
 {
     if ( URL.getLength() > 0 )
     {
-        // late init m_pOfficeDir and m_pUserDir
         initDirs();
 
         rtl::OUString aCanonicalURL( URL );
         makeCanonicalFileURL( aCanonicalURL );
 
-        sal_Int32 nIndex = aCanonicalURL.indexOf( *m_pOfficeDir );
+        sal_Int32 nIndex = aCanonicalURL.indexOf( *m_pOfficeBrandDir );
         if ( nIndex  != -1 )
         {
             return rtl::OUString(
                 URL.replaceAt( nIndex,
-                               m_pOfficeDir->getLength(),
-                               m_aOfficeDirMacro ) );
+                               m_pOfficeBrandDir->getLength(),
+                               m_aOfficeBrandDirMacro ) );
         }
         else
         {
-            nIndex = aCanonicalURL.indexOf( *m_pUserDir );
+            nIndex = aCanonicalURL.indexOf( *m_pOfficeBaseDir );
             if ( nIndex  != -1 )
             {
                 return rtl::OUString(
                     URL.replaceAt( nIndex,
-                                   m_pUserDir->getLength(),
-                                   m_aUserDirMacro ) );
+                                   m_pOfficeBaseDir->getLength(),
+                                   m_aOfficeBaseDirMacro ) );
+            }
+            else
+            {
+                nIndex = aCanonicalURL.indexOf( *m_pUserDir );
+                if ( nIndex  != -1 )
+                {
+                    return rtl::OUString(
+                        URL.replaceAt( nIndex,
+                                       m_pUserDir->getLength(),
+                                       m_aUserDirMacro ) );
+                }
             }
         }
     }
 {
     if ( URL.getLength() > 0 )
     {
-        sal_Int32 nIndex = URL.indexOf( m_aOfficeDirMacro );
+        sal_Int32 nIndex = URL.indexOf( m_aOfficeBrandDirMacro );
         if ( nIndex != -1 )
         {
-            // late init m_pOfficeDir and m_pUserDir
             initDirs();
 
             return rtl::OUString(
                 URL.replaceAt( nIndex,
-                               m_aOfficeDirMacro.getLength(),
-                               *m_pOfficeDir ) );
+                               m_aOfficeBrandDirMacro.getLength(),
+                               *m_pOfficeBrandDir ) );
         }
         else
         {
-            nIndex = URL.indexOf( m_aUserDirMacro );
+            nIndex = URL.indexOf( m_aOfficeBaseDirMacro );
             if ( nIndex != -1 )
             {
-                // late init m_pOfficeDir and m_pUserDir
                 initDirs();
 
                 return rtl::OUString(
                     URL.replaceAt( nIndex,
-                                   m_aUserDirMacro.getLength(),
-                                   *m_pUserDir ) );
+                                   m_aOfficeBaseDirMacro.getLength(),
+                                   *m_pOfficeBaseDir ) );
+            }
+            else
+            {
+                nIndex = URL.indexOf( m_aUserDirMacro );
+                if ( nIndex != -1 )
+                {
+                    initDirs();
+
+                    return rtl::OUString(
+                        URL.replaceAt( nIndex,
+                                       m_aUserDirMacro.getLength(),
+                                       *m_pUserDir ) );
+                }
             }
         }
     }
 
 void OfficeInstallationDirectories::initDirs()
 {
-    if ( m_pOfficeDir == 0 )
+    if ( m_pOfficeBrandDir == 0 )
     {
         osl::MutexGuard aGuard( m_aMutex );
-        if ( m_pOfficeDir == 0 )
+        if ( m_pOfficeBrandDir == 0 )
         {
-            m_pOfficeDir = new rtl::OUString;
-            m_pUserDir   = new rtl::OUString;
+            m_pOfficeBrandDir = new rtl::OUString;
+            m_pOfficeBaseDir  = new rtl::OUString;
+            m_pUserDir        = new rtl::OUString;
 
             uno::Reference< util::XMacroExpander > xExpander;
 
 
             if ( xExpander.is() )
             {
-                *m_pOfficeDir =
+                *m_pOfficeBrandDir =
                     xExpander->expandMacros(
                          rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "$BRAND_BASE_DIR" ) ) );
 
-                OSL_ENSURE( m_pOfficeDir->getLength() > 0,
-                        "Unable to obtain office installation directory!" );
+                OSL_ENSURE( m_pOfficeBrandDir->getLength() > 0,
+                            "Unable to obtain office brand installation directory!" );
 
-                makeCanonicalFileURL( *m_pOfficeDir );
+                makeCanonicalFileURL( *m_pOfficeBrandDir );
+
+                *m_pOfficeBaseDir =
+                    xExpander->expandMacros(
+                        rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+                            "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap" ) ":BaseInstallation}" ) ) );
+
+                OSL_ENSURE( m_pOfficeBaseDir->getLength() > 0,
+                            "Unable to obtain office base installation directory!" );
+
+                makeCanonicalFileURL( *m_pOfficeBaseDir );
 
                 *m_pUserDir =
                     xExpander->expandMacros(
                             "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap" ) ":UserInstallation}" ) ) );
 
                 OSL_ENSURE( m_pUserDir->getLength() > 0,
-                        "Unable to obtain office user data directory!" );
+                            "Unable to obtain office user data directory!" );
 
                 makeCanonicalFileURL( *m_pUserDir );
             }

comphelper/source/officeinstdir/officeinstallationdirectories.hxx

 /*************************************************************************
  *
  * 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
 private:
     void initDirs();
 
-    rtl::OUString                                   m_aOfficeDirMacro;
+    rtl::OUString                                   m_aOfficeBrandDirMacro;
+    rtl::OUString                                   m_aOfficeBaseDirMacro;
     rtl::OUString                                   m_aUserDirMacro;
     com::sun::star::uno::Reference<
         com::sun::star::uno::XComponentContext >    m_xCtx;
-    rtl::OUString *                                 m_pOfficeDir;
+    rtl::OUString *                                 m_pOfficeBrandDir;
+    rtl::OUString *                                 m_pOfficeBaseDir;
     rtl::OUString *                                 m_pUserDir;
 };