summaryrefslogtreecommitdiff
path: root/xmlhelp
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-10-26 17:55:14 +0100
committerAndras Timar <andras.timar@collabora.com>2015-10-29 13:08:59 +0100
commitd42d6dbfc6beac895ee778a1f30eab0435adf544 (patch)
treec4a119eb7c622568d8a4bbe3d8031d40137064aa /xmlhelp
parent6dffbfbc3e98e82a951c6af6d44ae4f559343145 (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. (cherry picked from commit 6948c546fdc00dddec7d58e03150dcc87921d6b2, plus f5174c89cd037d35b975590083cf91b36633808d "...but do not erase localize attributes from image elements," which is needed to make localized image references work again) Conflicts: vcl/osx/vclnsapp.mm Change-Id: Ic1c15fcacb6596a27a2b051093232902202bf472 Reviewed-on: https://gerrit.libreoffice.org/19644 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit 74453dbed460c0c428ce989b07a65d5cac5db49a)
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/compact.xsl5
-rw-r--r--xmlhelp/util/main_transform.xsl53
6 files changed, 36 insertions, 168 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index a2282721c736..c2d11d1cab95 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -121,7 +121,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,
@@ -138,9 +137,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 );
@@ -208,106 +205,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 95f0be7e3868..50d61236c535 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.hxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.hxx
@@ -148,7 +148,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,
@@ -156,7 +155,7 @@ namespace chelp {
~Databases();
- OString getImagesZipFileURL();
+ OString getImageTheme();
OUString getInstallPathAsURL();
@@ -273,9 +272,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 3db0233a09c7..ef143c661697 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/compact.xsl b/xmlhelp/util/compact.xsl
index 457c955e2a23..3b557fb90700 100644
--- a/xmlhelp/util/compact.xsl
+++ b/xmlhelp/util/compact.xsl
@@ -24,6 +24,11 @@
<!-- To remove attributes or nodes,
simply write a matching template that doesn't do anything.
Therefore, it is removed -->
+ <xsl:template match="image/@localize">
+ <xsl:copy>
+ <xsl:apply-templates select="@*[normalize-space()]|node()|text()"/>
+ </xsl:copy>
+ </xsl:template>
<xsl:template match="@localize"/>
<xsl:template match="@xml-lang"/>
<xsl:template match="alt"/>
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">