summaryrefslogtreecommitdiff
path: root/comphelper/source/officeinstdir
diff options
context:
space:
mode:
authorKai Sommerfeld <kso@openoffice.org>2010-10-12 09:48:34 +0200
committerKai Sommerfeld <kso@openoffice.org>2010-10-12 09:48:34 +0200
commit1221208c94ca01895fe3d7dd7ec5dfca4bec2f8e (patch)
treef1244b62839d6d1e1e0c8ea7ec2282da02696304 /comphelper/source/officeinstdir
parenteb61f9d1ec810d7156298f4840f70c9370ac97a0 (diff)
#i98699# - Reintroduced support for base installation directory.
Diffstat (limited to 'comphelper/source/officeinstdir')
-rw-r--r--comphelper/source/officeinstdir/officeinstallationdirectories.cxx93
-rw-r--r--comphelper/source/officeinstdir/officeinstallationdirectories.hxx6
2 files changed, 68 insertions, 31 deletions
diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
index b262a14bb73f..ebeedc92839d 100644
--- a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
+++ b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
@@ -101,10 +101,12 @@ static bool makeCanonicalFileURL( rtl::OUString & rURL )
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 )
{
}
@@ -113,6 +115,9 @@ OfficeInstallationDirectories::OfficeInstallationDirectories(
// virtual
OfficeInstallationDirectories::~OfficeInstallationDirectories()
{
+ delete m_pOfficeBrandDir;
+ delete m_pOfficeBaseDir;
+ delete m_pUserDir;
}
//=========================================================================
@@ -124,9 +129,8 @@ rtl::OUString SAL_CALL
OfficeInstallationDirectories::getOfficeInstallationDirectoryURL()
throw ( uno::RuntimeException )
{
- // late init m_pOfficeDir and m_pUserDir
initDirs();
- return rtl::OUString( *m_pOfficeDir );
+ return rtl::OUString( *m_pOfficeBrandDir );
}
//=========================================================================
@@ -135,7 +139,6 @@ rtl::OUString SAL_CALL
OfficeInstallationDirectories::getOfficeUserDataDirectoryURL()
throw ( uno::RuntimeException )
{
- // late init m_pOfficeDir and m_pUserDir
initDirs();
return rtl::OUString( *m_pUserDir );
}
@@ -149,29 +152,39 @@ OfficeInstallationDirectories::makeRelocatableURL( const rtl::OUString& URL )
{
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 ) );
+ }
}
}
}
@@ -186,29 +199,40 @@ OfficeInstallationDirectories::makeAbsoluteURL( const rtl::OUString& URL )
{
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 ) );
+ }
}
}
}
@@ -300,13 +324,14 @@ OfficeInstallationDirectories::Create(
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;
@@ -320,14 +345,24 @@ void OfficeInstallationDirectories::initDirs()
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_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_pOfficeDir );
+ makeCanonicalFileURL( *m_pOfficeBaseDir );
*m_pUserDir =
xExpander->expandMacros(
@@ -335,7 +370,7 @@ void OfficeInstallationDirectories::initDirs()
"${$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 );
}
diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.hxx b/comphelper/source/officeinstdir/officeinstallationdirectories.hxx
index 2ffb3582718a..9c56f7ce80fd 100644
--- a/comphelper/source/officeinstdir/officeinstallationdirectories.hxx
+++ b/comphelper/source/officeinstdir/officeinstallationdirectories.hxx
@@ -94,11 +94,13 @@ public:
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;
};