summaryrefslogtreecommitdiff
path: root/xmlhelp
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-10-26 17:55:14 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-10-26 17:55:14 +0100
commit6948c546fdc00dddec7d58e03150dcc87921d6b2 (patch)
treecb0afa155279289cb8853f02bfbca97415f6aad4 /xmlhelp
parentf5174c89cd037d35b975590083cf91b36633808d (diff)
tdf#75637: Resolve help images via a vnd.libreoffice.image UCP
...which uses the logic already available in VCL's ImplImageTree to locate the image zip files and find fallbacks for incomplete themes and for localized images. Change-Id: Ic1c15fcacb6596a27a2b051093232902202bf472
Diffstat (limited to 'xmlhelp')
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.cxx122
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.hxx6
-rw-r--r--xmlhelp/source/cxxhelp/provider/provider.cxx14
-rw-r--r--xmlhelp/source/cxxhelp/provider/urlparameter.cxx4
-rw-r--r--xmlhelp/util/main_transform.xsl53
5 files changed, 31 insertions, 168 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index 908fdab56177..5f2d0b991f66 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -120,7 +120,6 @@ OUString Databases::expandURL( const OUString& aURL, Reference< uno::XComponentC
Databases::Databases( bool showBasic,
const OUString& instPath,
- const com::sun::star::uno::Sequence< OUString >& imagesZipPaths,
const OUString& productName,
const OUString& productVersion,
const OUString& styleSheet,
@@ -137,9 +136,7 @@ Databases::Databases( bool showBasic,
prodVersion( "%PRODUCTVERSION" ),
vendName( "%VENDORNAME" ),
vendVersion( "%VENDORVERSION" ),
- vendShort( "%VENDORSHORT" ),
- m_aImagesZipPaths( imagesZipPaths ),
- m_aSymbolsStyleName( "" )
+ vendShort( "%VENDORSHORT" )
{
m_xSMgr = Reference< XMultiComponentFactory >( m_xContext->getServiceManager(), UNO_QUERY );
@@ -207,106 +204,33 @@ Databases::~Databases()
}
}
-static bool impl_getZipFile(
- Sequence< OUString > & rImagesZipPaths,
- const OUString & rZipName,
- OUString & rFileName )
-{
- OUString aWorkingDir;
- osl_getProcessWorkingDir( &aWorkingDir.pData );
- const OUString *pPathArray = rImagesZipPaths.getArray();
- for ( int i = 0; i < rImagesZipPaths.getLength(); ++i )
- {
- OUString aFileName = pPathArray[ i ];
- if ( !aFileName.isEmpty() )
- {
- if ( !aFileName.endsWith("/") )
- {
- aFileName += "/";
- }
- aFileName += rZipName;
- // the icons are not read when the URL is a symlink
- osl::File::getAbsoluteFileURL( aWorkingDir, aFileName, rFileName );
-
- // test existence
- osl::DirectoryItem aDirItem;
- if ( osl::DirectoryItem::get( rFileName, aDirItem ) == osl::FileBase::E_None )
- return true;
- }
- }
- return false;
-}
-
-OString Databases::getImagesZipFileURL()
+OString Databases::getImageTheme()
{
+ uno::Reference< lang::XMultiServiceFactory > xConfigProvider =
+ configuration::theDefaultProvider::get(m_xContext);
+
+ // set root path
+ uno::Sequence < uno::Any > lParams(1);
+ beans::PropertyValue aParam ;
+ aParam.Name = "nodepath";
+ aParam.Value <<= OUString("org.openoffice.Office.Common");
+ lParams[0] = uno::makeAny(aParam);
+
+ // open it
+ uno::Reference< uno::XInterface > xCFG( xConfigProvider->createInstanceWithArguments(
+ OUString("com.sun.star.configuration.ConfigurationAccess"),
+ lParams) );
+
+ uno::Reference< container::XHierarchicalNameAccess > xAccess(xCFG, uno::UNO_QUERY_THROW);
+ uno::Any aResult = xAccess->getByHierarchicalName(OUString("Misc/SymbolStyle"));
OUString aSymbolsStyleName;
- try
- {
- uno::Reference< lang::XMultiServiceFactory > xConfigProvider =
- configuration::theDefaultProvider::get(m_xContext);
-
- // set root path
- uno::Sequence < uno::Any > lParams(1);
- beans::PropertyValue aParam ;
- aParam.Name = "nodepath";
- aParam.Value <<= OUString("org.openoffice.Office.Common");
- lParams[0] = uno::makeAny(aParam);
-
- // open it
- uno::Reference< uno::XInterface > xCFG( xConfigProvider->createInstanceWithArguments(
- OUString("com.sun.star.configuration.ConfigurationAccess"),
- lParams) );
-
- bool bChanged = false;
- uno::Reference< container::XHierarchicalNameAccess > xAccess(xCFG, uno::UNO_QUERY_THROW);
- uno::Any aResult = xAccess->getByHierarchicalName(OUString("Misc/SymbolStyle"));
- if ( (aResult >>= aSymbolsStyleName) && m_aSymbolsStyleName != aSymbolsStyleName )
- {
- m_aSymbolsStyleName = aSymbolsStyleName;
- bChanged = true;
- }
-
- if ( m_aImagesZipFileURL.isEmpty() || bChanged )
- {
- OUString aImageZip;
- bool bFound = false;
-
- if ( !aSymbolsStyleName.isEmpty() )
- {
- if ( aSymbolsStyleName == "auto" )
- {
- // with the layered images*.zip, tango is the most
- // complete theme, so show that one
- // FIXME instead of using a general vnd.sun.star.zip://
- // for imgrepos, we should have some vnd.sun.star.image://
- // so that we don't have to re-open the stream for every
- // image in the help
- aSymbolsStyleName = "tango";
- }
- OUString aZipName = "images_" + aSymbolsStyleName + ".zip";
+ aResult >>= aSymbolsStyleName;
- bFound = impl_getZipFile( m_aImagesZipPaths, aZipName, aImageZip );
- }
-
- if ( ! bFound )
- bFound = impl_getZipFile( m_aImagesZipPaths, OUString( "images.zip" ), aImageZip );
-
- if ( ! bFound )
- aImageZip.clear();
-
- m_aImagesZipFileURL = OUStringToOString(
- rtl::Uri::encode(
- aImageZip,
- rtl_UriCharClassPchar,
- rtl_UriEncodeIgnoreEscapes,
- RTL_TEXTENCODING_UTF8 ), RTL_TEXTENCODING_UTF8 );
- }
- }
- catch ( NoSuchElementException const & )
+ if ( aSymbolsStyleName.isEmpty() || aSymbolsStyleName == "auto" )
{
+ aSymbolsStyleName = "tango";
}
-
- return m_aImagesZipFileURL;
+ return aSymbolsStyleName.toUtf8();
}
void Databases::replaceName( OUString& oustring ) const
diff --git a/xmlhelp/source/cxxhelp/provider/databases.hxx b/xmlhelp/source/cxxhelp/provider/databases.hxx
index 9e33a98e02cf..9b331cc96af2 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.hxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.hxx
@@ -140,7 +140,6 @@ namespace chelp {
Databases( bool showBasic,
const OUString& instPath,
- const com::sun::star::uno::Sequence< OUString >& imagesZipPaths,
const OUString& productName,
const OUString& productVersion,
const OUString& styleSheet,
@@ -148,7 +147,7 @@ namespace chelp {
~Databases();
- OString getImagesZipFileURL();
+ OString getImageTheme();
OUString getInstallPathAsURL();
@@ -265,9 +264,6 @@ namespace chelp {
prodName,prodVersion,vendName,vendVersion,vendShort;
OUString m_aInstallDirectory; // Installation directory
- com::sun::star::uno::Sequence< OUString > m_aImagesZipPaths;
- OString m_aImagesZipFileURL;
- OUString m_aSymbolsStyleName;
std::vector< OUString > m_avModules;
diff --git a/xmlhelp/source/cxxhelp/provider/provider.cxx b/xmlhelp/source/cxxhelp/provider/provider.cxx
index 781554d8a445..95b1c6de4d7b 100644
--- a/xmlhelp/source/cxxhelp/provider/provider.cxx
+++ b/xmlhelp/source/cxxhelp/provider/provider.cxx
@@ -35,7 +35,6 @@
#include <cppuhelper/supportsservice.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/pathoptions.hxx>
-#include <rtl/bootstrap.hxx>
#include "databases.hxx"
#include "provider.hxx"
@@ -324,22 +323,9 @@ void ContentProvider::init()
}
OUString productversion( setupversion + " " + setupextension );
-
- uno::Sequence< OUString > aImagesZipPaths( 2 );
- xHierAccess = getHierAccess( sProvider, "org.openoffice.Office.Common" );
-
- OUString aPath( getKey( xHierAccess, "Path/Current/UserConfig" ) );
- subst( aPath );
- aImagesZipPaths[ 0 ] = aPath;
-
- aPath = "$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/config";
- rtl::Bootstrap::expandMacros(aPath);
- aImagesZipPaths[ 1 ] = aPath;
-
bool showBasic = getBooleanKey(xHierAccess,"Help/ShowBasic");
m_pDatabases = new Databases( showBasic,
instPath,
- aImagesZipPaths,
utl::ConfigManager::getProductName(),
productversion,
stylesheet,
diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
index 14f6240d6da5..72a57d1d24f3 100644
--- a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
+++ b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
@@ -890,8 +890,8 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam,
pDatabases->getProductVersion().getLength(),
RTL_TEXTENCODING_UTF8 ) + OString('\'');
- parString[last++] = "imgrepos";
- parString[last++] = OString('\'') + pDatabases->getImagesZipFileURL() + OString('\'');
+ parString[last++] = "imgtheme";
+ parString[last++] = OString('\'') + pDatabases->getImageTheme() + OString('\'');
parString[last++] = "hp";
parString[last++] = OString('\'') + urlParam->getByName( "HelpPrefix" ) + OString('\'');
diff --git a/xmlhelp/util/main_transform.xsl b/xmlhelp/util/main_transform.xsl
index b6b9c2e6c76c..b30effe1ca94 100644
--- a/xmlhelp/util/main_transform.xsl
+++ b/xmlhelp/util/main_transform.xsl
@@ -99,7 +99,7 @@
<xsl:value-of select="translate($productversion,' ','')"/>
</xsl:variable>
<!-- this is were the images are -->
-<xsl:param name="imgrepos" select="''"/>
+<xsl:param name="imgtheme" select="''"/>
<xsl:param name="Id" />
<xsl:param name="Language" select="'en-US'"/>
<xsl:variable name="lang" select="$Language"/>
@@ -110,7 +110,7 @@
<!-- parts of help and image urls -->
<xsl:variable name="help_url_prefix" select="'vnd.sun.star.help://'"/>
-<xsl:variable name="img_url_prefix" select="concat('vnd.sun.star.zip://',$imgrepos,'/')"/>
+<xsl:variable name="img_url_prefix" select="concat('vnd.libreoffice.image://',$imgtheme,'/')"/>
<xsl:variable name="urlpost" select="concat('?Language=',$lang,$am,'System=',$System,$am,'UseDB=no')"/>
<xsl:variable name="urlpre" select="$help_url_prefix" />
<xsl:variable name="linkprefix" select="$urlpre"/>
@@ -801,19 +801,6 @@
<!-- Insert an image -->
<xsl:template name="insertimage">
-
- <xsl:variable name="fpath">
- <xsl:call-template name="getfpath">
- <xsl:with-param name="s"><xsl:value-of select="@src"/></xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:variable name="fname">
- <xsl:call-template name="getfname">
- <xsl:with-param name="s"><xsl:value-of select="@src"/></xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
-
<xsl:variable name="src">
<xsl:choose>
<xsl:when test="not($ExtensionId='') and starts-with(@src,$ExtensionId)">
@@ -821,11 +808,11 @@
</xsl:when>
<xsl:otherwise>
<xsl:choose>
- <xsl:when test="(@localize='true') and not($lang='en-US')">
- <xsl:value-of select="concat($img_url_prefix,$fpath,$lang,'/',$fname)"/>
+ <xsl:when test="@localize='true'">
+ <xsl:value-of select="concat($img_url_prefix,@src,'?lang=',$lang)"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="concat($img_url_prefix,$fpath,$fname)"/>
+ <xsl:value-of select="concat($img_url_prefix,@src)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
@@ -931,36 +918,6 @@
</xsl:choose>
</xsl:template>
-<xsl:template name="getfpath">
- <xsl:param name="s"/>
- <xsl:param name="p"/>
- <xsl:choose>
- <xsl:when test="contains($s,'/')">
- <xsl:call-template name="getfpath">
- <xsl:with-param name="p"><xsl:value-of select="concat($p,substring-before($s,'/'),'/')"/></xsl:with-param>
- <xsl:with-param name="s"><xsl:value-of select="substring-after($s,'/')"/></xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$p"/>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<xsl:template name="getfname">
- <xsl:param name="s"/>
- <xsl:choose>
- <xsl:when test="contains($s,'/')">
- <xsl:call-template name="getfname">
- <xsl:with-param name="s"><xsl:value-of select="substring-after($s,'/')"/></xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$s"/>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
<xsl:template name="createDBpostfix">
<xsl:param name="archive"/>
<xsl:variable name="newDB">